Prev: BDFB Up: Map Next: C15B
C0E1: Tunnel setup?
Used by the routines at main_loop, cpu_driver and escape_scene.
tunnel_setup C0E1 LD A,($C161) Read 'LD A,x' @ C160 (tunnel drawing code)
C0E4 AND A Set flags
C0E5 LD A,($C890) Read 'LD A,x' @ C88F (TBD)
C0E8 JR NZ,tunnel_setup_1 Jump if tunnel has appeared
Tunnel hasn't appeared.
no_tunnel C0EA AND A Set flags
C0EB JR NZ,yes_a_tunnel Jump if non-zero
C0ED XOR A tunnel_sfx = 0
C0EE LD ($A23B),A
C0F1 LD H,A HL = 0
C0F2 LD L,A
C0F3 LD ($8F82),A 8F82 = NOP (instruction)
C0F6 LD ($8F83),HL 8F83 & 8F84 = NOP (instruction)
C0F9 LD ($8FA7),A 8FA7 = NOP (instruction)
C0FC LD ($8FA8),HL 8FA8 & 8FA9 = NOP (instruction)
C0FF RET Return
Tunnel has appeared.
yes_a_tunnel C100 LD A,$05 tunnel_sfx = 5 -- this quietens noises when in the tunnel
C102 LD ($A23B),A
C105 LD HL,$EAF3 -- somewhere in road height data table
C108 LD B,(HL) BC = wordat(HL); HL -= 4
C109 DEC L
C10A LD C,(HL)
C10B DEC L
C10C DEC L
C10D DEC L
C10E EXX Bank
C10F LD HL,$EAF1 -- somewhere in road height data table
C112 LD D,(HL) DE = wordat(HL); HL -= 4
C113 DEC L
C114 LD E,(HL)
C115 DEC L
C116 DEC L
C117 DEC L
tunnel_loop C118 EXX Bank
C119 LD D,(HL) DE = wordat(HL); HL--
C11A DEC L
C11B LD E,(HL)
C11C PUSH DE Stack DE
C11D DEC L HL -= 3
C11E DEC L
C11F DEC L
C120 EX DE,HL
C121 SBC HL,BC HL -= BC
C123 POP BC Unstack
C124 JR C,tunnel_setup_0 Jump if HL < BC
C126 EX DE,HL
C127 EXX Bank
C128 LD B,(HL) BC = wordat(HL); HL -= 4
C129 DEC L
C12A LD C,(HL)
C12B DEC L
C12C DEC L
C12D DEC L
C12E EX DE,HL Swap
C12F SBC HL,BC HL -= BC
C131 JR C,tunnel_setup_0 Jump if HL < BC
C133 EX DE,HL Swap
C134 LD D,B DE = BC
C135 LD E,C
C136 DEC A A--
C137 JR NZ,tunnel_loop Loop to tunnel_loop
tunnel_setup_0 C139 CPL A = 9 - A
C13A ADD A,$0A
C13C LD ($C15E),A Self modify 'CP x' @ C15D [15 when tunnel is small, 6 when fills screen]
C13F LD A,$02 A = 2
C141 LD ($C161),A Self modify 'LD A,x' @ C160
tunnel_setup_1 C144 XOR $01 A = 3
C146 LD ($C2B9),A Self modify 'LD A,x' @ C2B8
C149 LD HL,$C15B Self modify 8F82 and 8FA7 to be CALL <tunnel drawing code>
C14C LD A,$CD
C14E LD ($8F82),A
C151 LD ($8F83),HL
C154 LD ($8FA7),A
C157 LD ($8FA8),HL
C15A RET Return
Prev: BDFB Up: Map Next: C15B