Prev: D6D2 Up: Map Next: D730
D71C: Tunnel section - Run game timer and randomly generate creatures
Used by the routine at D6D2.
Jump from D6E0 if no new tunnel wall has been generated during this particular game cycle.
Every 8 game cycles, there's a chance of a creature appearing.
D71C LD A,($EAAA) Get the game timer
D71F INC A Increment it
D720 AND $07 Check bits 0-2 (values 0-7)
D722 JR NZ,$D794
Executed after 8 game timer cycles. Combined with a pseudo-random number, this affects the likelihood interval of a creature (spider/bat) appearing in the tunnel.
  • The room number is one of the variables in this calculation
  • There's a slightly lower chance of creatures appearing in higher numbered tunnel rooms
  • The room tunnel numbers (6710) start high and decrease for deeper levels within the game - e.g. interconnecting tunnel room numbers within the Gatehouse Level are 251-255
  • This means Maroc will tend to encounter more creatures within Avalon's deeper tunnels
D724 CALL $DB06 Generate pseudo-random number in A register
D727 LD C,A Store in C register
D728 LD A,($EAB7) Get room number
D72B SUB $30 Because tunnels are rooms 224-255, this will result in a value somewhere in the 176-207 range
D72D CP C Is this value greater than the random number?
D72E JR NC,$D794 If so, jump out of here
If not, continue to the next routine to generate a SPIDER or a BAT
Prev: D6D2 Up: Map Next: D730