Prev: 54842 Up: Map Next: 54907
54865: Determine whether a warlock should materialize in the room
Used by the routine at 54842.
A warlock can appear in the room:
  • After a certain time, based on a slowly decrementing counter byte at 60340 along with a pseudo-random adjustment
  • As long as there aren't already 3 creatures in the room
  • On levels 1-7 (based on room numbers in the table at 50852)
No warlock appears on level 8 (Chambers of Chaos). On level 9 (High Temple of Chaos), DEMONS materialize in rooms instead of warlocks.
54865 LD A,(60105) Get the current level text number (1-9) - calculated from lookup table at 50852
54868 LD B,A Store in B register
There are only 7 warlocks, so we need to do something for levels 8 and 9
54869 CP 8 Are we in the Chambers of Chaos (level 8)?
54871 JP Z,54991 If so there's no warlock on this level - jump to the end of this check routine
54874 CP 9 Are we in the High Temple of Chaos (level 9)?
54876 JR Z,54948 If so, jump out and generate a DEMON instead of a WARLOCK
54878 LD A,(60074) Game cycle timer
54881 AND 63 Check bits 0-5 (values = 0-63)
54883 JP NZ,54991
Every 64 game cycles, reduce the timer counter for a warlock appearing in the room
54886 LD A,(60340) Get warlock appearance timer
54889 DEC A Decrement it
54890 LD (60340),A ...and re-store
54893 LD C,A
54894 CALL 56070 Run pseudo-random number generator to produce a random number (returned in A register)
54897 CP C Compare it against the warlock appearance timer
54898 JR C,54991 If random number < warlock timer, jump out here
54900 LD A,(60333) Random number > warlock timer. Get byte 6 of warlock data set
54903 CP 0
54905 JR NZ,54991 If this byte isn't 0, there's already a warlock so we can jump out at this point
Prev: 54842 Up: Map Next: 54907