Prev: C0E1 Up: Map Next: C2E7
C15B: Tunnel entrance/interior/exit drawing code
Called by $8F82 etc. being self modified.
C15B LD A,IYl A = IY.low
C15D CP $00 Compare to <self modified>
C15F RET NZ Return if non-zero
C160 LD A,$00 A = <self modified>
C162 LD D,$EE D = $EE
C164 DEC A A--
C165 JR Z,$C169 Jump if zero
C167 LD D,$FF D = $FF
C169 LD E,D E = D
C16A LD ($C21D),DE Self modify 'LD DE,x' @ C21C
C16E LD ($C2E4),SP Save SP to restore later (self modify)
C172 LD A,(IY+$4E) L = ~((IY[$4E] - 2) << 1)
C175 SUB $02
C177 ADD A,A
C178 CPL
C179 LD L,A
C17A LD C,$00 C = 0
C17C LD H,$EB H = $EB
C17E LD A,(HL) A = *HL
C17F OR A Set flags
C180 JP Z,$C18E Jump if zero
C183 LD D,$10 D = 16
C185 JP P,$C19C Jump if positive
C188 LD D,$16 D = 22
C18A LD L,$1F L = 31
C18C JR $C1C8 Jump
C18E DEC L A = HL[-1]
C18F LD A,(HL)
C190 INC L
C191 AND $F8 Divide by 8
C193 RRCA
C194 RRCA
C195 RRCA
C196 SRL A A >>= 1
C198 RR C Rotate C
C19A INC A A++
C19B LD D,A D = A
C19C LD H,$E8 H = $E8
C19E LD A,(HL) A = *HL
C19F OR A Set flags
C1A0 JR Z,$C1AA Jump if zero
C1A2 LD E,$10 E = 16
C1A4 JP M,$C1BC Jump if negative
C1A7 JP $C188 Jump
C1AA DEC L L--
C1AB LD A,(HL) A = *HL + 8
C1AC ADD A,$08
C1AE JR C,$C188 Jump if carry
C1B0 AND $F8 Divide by 8
C1B2 RRCA
C1B3 RRCA
C1B4 RRCA
C1B5 LD B,A B = A
C1B6 SRL A E = 16 - (A >> 1)
C1B8 CPL
C1B9 ADD A,$11
C1BB LD E,A
C1BC LD A,$20 A = 32 - B
C1BE SUB B
C1BF LD L,$20 L = 32
C1C1 RL C Rotate left
C1C3 JR C,$C1C7 Jump if carry
C1C5 DEC L L--
C1C6 DEC A A--
C1C7 LD C,A C = A
C1C8 LD A,D A = D
C1C9 LD ($C222),A Self modify 'JR x' @ C221 -- jump table target
C1CC LD A,E A = E
C1CD LD ($C237),A Self modify 'JR x' @ C236 -- jump table target
C1D0 LD A,(IY+$35) A = IY[$35]
C1D3 LD B,A B = A
C1D4 AND $0F H = (A & 15) + $F0
C1D6 ADD A,$F0
C1D8 LD H,A
C1D9 LD A,B A = ((B & $70) << 1) + L
C1DA AND $70
C1DC ADD A,A
C1DD ADD A,L
C1DE JR NC,$C1E1 Jump if no carry
C1E0 DEC A A--
C1E1 LD L,A L = A
C1E2 LD A,$80 A = 128 - B
C1E4 SUB B
C1E5 EX AF,AF' Bank/unbank
C1E6 LD A,($A23F) E = fast_counter & $E0
C1E9 AND $E0
C1EB LD E,A
C1EC RRC E E >>= 2
C1EE RRC E
C1F0 SUB E A -= E
C1F1 RRC E E >>= 2
C1F3 RRC E
C1F5 SUB E A -= E
C1F6 ADD A,IYl A += IY.low
C1F8 LD D,$E6 D = $E6
C1FA LD E,A E = A
C1FB LD A,(IY+$00) B = IY[0] - B
C1FE SUB B
C1FF LD B,A
C200 LD A,(DE) A = *DE
C201 LD E,A E = A
C202 LD A,IYl A = (16 - IY.low) + E
C204 CPL
C205 ADD A,$11
C207 ADD A,E
C208 EXX Bank/unbank
C209 LD B,A B = A
C20A EXX Bank/unbank
C20B SUB B A -= B
C20C LD D,A D = A
C20D EX AF,AF' Bank/unbank
C20E ADD A,D A = D
C20F JP P,$C21A Jump if positive
C212 LD E,A E = A
C213 SUB $81 A -= $81
C215 NEG A = -A
C217 ADD A,D A += D
C218 LD D,A D = A
C219 LD A,E A = E
C21A EX AF,AF' Bank/unbank
C21B LD B,D B = D
Pixels of tunnel loaded here. Top byte, D, seems to affect bottom row? Bottom byte, E, affects whole pattern. The LD E,D later would explain that.
C21C LD DE,$EEEE DE = <self modified> -- pixels of tunnel
Loop
C21F LD SP,HL Put it in SP (so we can use PUSH for speed)
C220 LD A,L A = L
C221 JR $C221 Jump table (self modified)
C223 PUSH DE
C224 PUSH DE
C225 PUSH DE
C226 PUSH DE
C227 PUSH DE
C228 PUSH DE
C229 PUSH DE
C22A PUSH DE
C22B PUSH DE
C22C PUSH DE
C22D PUSH DE
C22E PUSH DE
C22F PUSH DE
C230 PUSH DE
C231 PUSH DE
C232 PUSH DE
C233 SUB C A -= C
C234 LD L,A L = A
C235 LD SP,HL Put it in SP (so we can use PUSH for speed)
C236 JR $C236 Jump table (self modified)
C238 PUSH DE
C239 PUSH DE
C23A PUSH DE
C23B PUSH DE
C23C PUSH DE
C23D PUSH DE
C23E PUSH DE
C23F PUSH DE
C240 PUSH DE
C241 PUSH DE
C242 PUSH DE
C243 PUSH DE
C244 PUSH DE
C245 PUSH DE
C246 PUSH DE
C247 PUSH DE
C248 ADD A,C A += C
C249 LD L,A L = A
C24A LD A,H A = H
C24B DEC H H--
C24C AND $0F A &= 15
C24E JP NZ,$C25B Jump if non-zero
C251 LD A,L L -= 32
C252 SUB $20
C254 LD L,A
C255 JR C,$C25B Jump if carry
C257 LD A,H H -= 16
C258 ADD A,$10
C25A LD H,A
C25B RLC D
C25D LD E,D E = D
C25E DJNZ $C21F Loop
C260 EXX Bank/unbank
C261 SRL B B >>= 1
C263 LD A,B A = B
C264 SRL B B >>= 2
C266 SRL B
C268 SUB B A -= B
C269 LD B,A B = A
C26A EX AF,AF' Bank/unbank
C26B AND A Set flags
C26C JP M,$C2E3 Jump if negative
C26F ADD A,B A += B
C270 JP P,$C27B Jump if positive
C273 LD E,A E = A
C274 SUB $81 A -= $81
C276 NEG A = -A
C278 ADD A,B A = B
C279 LD B,A B = A
C27A LD A,E A = E
C27B EX AF,AF' Bank/unbank
C27C LD A,B A = B
C27D EXX Bank/unbank
C27E LD B,A B = A
C27F LD A,L A = L
C280 AND $0F A &= 15
C282 JR NZ,$C285 Jump if non-zero
C284 DEC L L--
C285 LD C,$0F C = 15
Loop
C287 LD SP,HL Put it in SP (so we can use PUSH for speed)
C288 PUSH DE
C289 PUSH DE
C28A PUSH DE
C28B PUSH DE
C28C PUSH DE
C28D PUSH DE
C28E PUSH DE
C28F PUSH DE
C290 PUSH DE
C291 PUSH DE
C292 PUSH DE
C293 PUSH DE
C294 PUSH DE
C295 PUSH DE
C296 PUSH DE
C297 LD A,H A = H
C298 DEC H H--
C299 AND C A &= C
C29A JP NZ,$C2A7 Jump if non-zero
C29D LD A,L L -= 32
C29E SUB $20
C2A0 LD L,A
C2A1 JR C,$C2A7 Jump if carry
C2A3 LD A,H H += 16
C2A4 ADD A,$10
C2A6 LD H,A
C2A7 RLC D
C2A9 LD E,D E = D
C2AA DJNZ $C287 Loop
C2AC EX AF,AF'
C2AD AND A Set flags
C2AE JP M,$C2E3 Jump if negative
C2B1 CPL B = ~A + $82
C2B2 ADD A,$82
C2B4 LD B,A
C2B5 LD DE,$0000 DE = 0
C2B8 LD A,$00 A = <self modified>
C2BA AND A Set flags
C2BB JR Z,$C2C1 Jump if zero
C2BD DEC A A--
C2BE JR NZ,$C2E3 Jump if non-zero
C2C0 DEC DE DE--
C2C1 LD SP,HL Put it in SP (so we can use PUSH for speed)
C2C2 PUSH DE
C2C3 PUSH DE
C2C4 PUSH DE
C2C5 PUSH DE
C2C6 PUSH DE
C2C7 PUSH DE
C2C8 PUSH DE
C2C9 PUSH DE
C2CA PUSH DE
C2CB PUSH DE
C2CC PUSH DE
C2CD PUSH DE
C2CE PUSH DE
C2CF PUSH DE
C2D0 PUSH DE
C2D1 LD A,H A = H
C2D2 DEC H H--
C2D3 AND C A &= C
C2D4 JP NZ,$C2E1 Jump if non-zero
Scanline increment pattern.
C2D7 LD A,L L -= 32
C2D8 SUB $20
C2DA LD L,A
C2DB JR C,$C2E1 Jump if carry
C2DD LD A,H H -= 16
C2DE ADD A,$10
C2E0 LD H,A
C2E1 DJNZ $C2C1 Next scanline ?
C2E3 LD SP,$0000 Restore SP (self modified)
C2E6 RET Return
Prev: C0E1 Up: Map Next: C2E7