Prev: CF59 Up: Map Next: D244
CFB5: Handle collision detection of enemy with Rex and projectiles
Used by the routine at BC48.
CFB5 LD A,($A1EE) Return if Rex is dead
CFB8 OR A
CFB9 RET NZ
Configure opcodes for collision box according to enemy type
CFBA LD A,$1E Configure opcode ADD A at $D00E to add $1E (y-position height range)
CFBC LD ($D00F),A
CFBF LD A,$16 Configure opcode ADD A at $D01E to add $1E (x-position width range)
CFC1 LD ($D01F),A
CFC4 LD A,$10 Configure opcode ADD A at $D0A7 and $D0B8 to add $10
CFC6 LD ($D0A8),A
CFC9 LD ($D0B9),A
CFCC LD A,$10 Configure opcode SUB at $D019 to substract $10 (x-position width range)
CFCE LD ($D01A),A
CFD1 LD A,(IX+$02) Jump forward if enemy moving left
CFD4 OR A
CFD5 JP Z,$CFDD
CFD8 LD A,$08 Enemy moving right, configure opcode SUB at $D019 to substract $08 (x-position width range)
CFDA LD ($D01A),A
CFDD LD A,(IX+$09) Check enemy type
CFE0 AND $7F
CFE2 CP $0E is TRIANGLE?
CFE4 JP Z,$CFEA Jump to reconfigure opcodes
CFE7 JP $CFFC Jump forward and check for collision
reconfigure opcodes for TRIANGLE
CFEA LD A,$16 Configure opcode ADD A at $D00E to add $16 (y-position height range)
CFEC LD ($D00F),A
CFEF LD A,$0E Configure opcode ADD A at $D01E to add $0E (x-position width range)
CFF1 LD ($D01F),A
CFF4 LD A,$08 Configure opcode ADD A at $D0A7 and $D0B8 to add $08
CFF6 LD ($D0A8),A
CFF9 LD ($D0B9),A
CFFC LD A,($A1F9) Jump forward if Rex is teleporting
CFFF OR A
D000 JP NZ,$D07E
check collision with Rex
D003 LD HL,$A250 Set HL the y-position of Rex
D006 LD A,(IX+$01) Check if y-position of enemy is in the range of collision with Rex and jump forward if not
D009 SUB $10
D00B CP (HL)
D00C JR NC,$D07E
D00E ADD A,$1E
D010 CP (HL)
D011 JR C,$D07E
D013 LD HL,$A24F Set HL the x-position of Rex
D016 LD A,(IX+$00) Check if x-position of enemy is in the range of collision with Rex
D019 SUB $10
D01B CP (HL)
D01C JR NC,$D07E
D01E ADD A,$16
D020 CP (HL)
D021 JR C,$D07E
collision with Rex detected and shield activated
D023 LD A,($A1E2) Jump forward if shield not activated
D026 OR A
D027 JP Z,$D04D
D02A LD A,(IX+$09) Jump forward if entity is bubble, smartbomb or question
D02D CP $FE
D02F JP Z,$D04D
D032 CP $FD
D034 JP Z,$D04D
D037 CP $FC
D039 JP Z,$D04D
D03C CALL $9807 Destroy enemy
D03F LD A,(IX+$14) Computes shield loss into L shield loss = enemy health * 4
D042 SLA A
D044 SLA A
D046 LD L,A
D047 CALL $98EC Handle shield loss
D04A JP $D069 Jump forward
collision with Rex detected and shield not activated
D04D LD A,(IX+$18) Jump forward if enemy is teleporting
D050 OR A
D051 JP NZ,$D07E
D054 LD A,(IX+$09) Jump forward if entity is bubble, smartbomb or question
D057 CP $FE
D059 JP Z,$D069
D05C CP $FD
D05E JP Z,$D069
D061 CP $FC
D063 JP Z,$D069
D066 CALL $9CC5 Handle Rex dead
Rex takes bubble, smartbombs or question
D069 LD A,(IX+$09) check enemy?
D06C CP $FE is bubble?
D06E CALL Z,$D204 Jump to handles Rex takes bubble
D071 CP $FD is smartbomb?
D073 CALL Z,$D22C Jump to handle Rex takes smartbomb
D076 LD A,(IX+$09)
D079 CP $FC is question?
D07B CALL Z,$D24E Jump to handle question
No collision with Rex - Check collision with Rex projectiles
D07E LD A,(IX+$09) Return if enemy is DROP
D081 CP $82
D083 RET Z
D084 CP $84 Jump forward if enemy is not PINE
D086 JP NZ,$D08E
D089 LD A,(IX+$12) Return if PINE animation state is stand-by
D08C OR A
D08D RET Z
D08E LD IY,$5B60 Set IY to the base address for Rex projectiles configuration
D092 LD B,$1E Set B to the number of projectiles to check
D094 LD A,(IY+$06) Set A to the projectile status
D097 CP $01 is flying?
D099 JP NZ,$D13F Jump to check another projectile if not flying
D09C LD A,(IX+$01) Jump to check another projectile if y-position of projectile is not in range of collision with the enemy y-position
D09F ADD A,$05
D0A1 CP (IY+$01)
D0A4 JP NC,$D13F
D0A7 ADD A,$10
D0A9 CP (IY+$01)
D0AC JP C,$D13F
D0AF LD A,(IX+$00) Jump to check another projectile if x-position of projectile is not in range collision with then enemy x-position
D0B2 CP (IY+$00)
D0B5 JP NC,$D13F
D0B8 ADD A,$10
D0BA CP (IY+$00)
D0BD JP C,$D13F
handle projectile collision with entity
D0C0 LD A,(IX+$09) Check for entity type
D0C3 CP $FE Jump to check another projectile if entity is bubble
D0C5 JP Z,$D13F
D0C8 CP $FD Jump to check another projectile if entity is smartbomb
D0CA JP Z,$D13F
D0CD CP $FC Jump to handle another projectile if entity is question
D0CF JP Z,$D13F
D0D2 LD A,($A1AC) Jump forward if weapon type is laser
D0D5 CP $02
D0D7 JP NZ,$D0E1
D0DA LD (IY+$06),$00 Destroy laser projectile
D0DE JP $D0F3 Jump forward
non laser impact
D0E1 LD (IY+$06),$02 Set projectile status to impact #1
D0E5 LD A,($D5DA) Check channel 3
D0E8 CP $FF Jump forward if channel in use
D0EA JP NZ,$D0F3
D0ED LD DE,$D51F Set DE to base address for projectile impact sound
D0F0 CALL $D37F Configure sound channel and mixer register
handle enemy behaviour on projectile impact
D0F3 LD A,(IX+$09) Check enemy type
D0F6 CP $06 Handle collision if enemy type FOOT MAN DYING 6
D0F8 CALL Z,$D1B7
D0FB LD A,(IX+$09) Check enemy type
D0FE CP $06 Jump to handle next projectile if enemy type is FOOT MAN DYING 6
D100 JP Z,$D13F
D103 LD A,(IX+$14) Jump forward to handle next projectile if enemy health is zero
D106 OR A
D107 JP Z,$D13F
D10A DEC A Decrement enemy health
D10B LD (IX+$14),A
D10E CP $01 Jump forward if enemy health <> 1
D110 JP NZ,$D149
enemy health is equal to 1
D113 LD A,(IX+$09) Jump forward and destroy enemy if enemy type is not FOOT MAN
D116 AND $7F
D118 OR A
D119 JP NZ,$D13C
D11C LD A,(IX+$02) Jump forward to check projectile direction if FOOT MAN is facing left
D11F OR A
D120 JP NZ,$D12E
D123 LD A,(IY+$04) check projectile direction
D126 BIT 7,A
D128 JP NZ,$D136 Jump forward and FOOT MAN dying #6 animation
D12B JP $D13C Jump to destroy enemy
D12E LD A,(IY+$04) check projectile direction
D131 BIT 7,A
D133 JP NZ,$D13C Jump to destroy enemy if projectile is facing left
D136 CALL $D15A Handle FOOT MAN dying #6
D139 JP $D13F Jump to handle next projectile
D13C CALL $9807 Destroy enemy
check for the next projectile if any
D13F LD DE,$000F Set IY point to the next projectile configuration
D142 ADD IY,DE
D144 DEC B Decrement projectile counter
D145 JP NZ,$D094 Jump back and handle next projectil until there are projectiles
D148 RET
Enemy health is <> 1
D149 LD A,(IX+$09) Jump and handle next projectile. Enemy type $08 doesn't exist
D14C AND $7F
D14E CP $08
D150 JP NZ,$D13F
D153 LD (IX+$10),$04 Code not executed
D157 JP $D13F
Handle FOOT MAN dying #6
D15A LD A,($A1AC) Check weapon type
D15D CP $02 Jump to destroy enemy if weapon type is laser
D15F JP Z,$9807
D162 CP $04 Configure FOOT MAN jumping if weapon type is spray
D164 CALL Z,$C673
D167 LD A,(IX+$02) Change direction
D16A XOR $01
D16C LD (IX+$02),A
D16F LD A,$04 Set speed
D171 LD (IX+$10),A
D174 LD HL,$AF7A Set address of table offsets for FOOT MAN dying animation
D177 LD (IX+$0A),L
D17A LD (IX+$0B),H
D17D LD HL,$8258 Set address for graphic data of FOOT MAN dying
D180 LD (IX+$16),L
D183 LD (IX+$17),H
D186 LD (IX+$09),$06 Set enemy type
D18A LD (IX+$11),$06 Set counter for state change
D18E LD (IX+$14),$02 Set health
D192 LD (IX+$0E),$03 Set sprite width
D196 LD A,($A1AC) Return if weapon type is spray or laser
D199 CP $04
D19B RET Z
D19C CP $02
D19E RET Z
D19F LD HL,$5843 Set base address to attribute file for score points
D1A2 LD ($A1D2),HL
D1A5 LD A,$09 Init counter for score points
D1A7 LD ($A1D4),A
D1AA LD HL,$0002 Set next score points
D1AD LD ($A1D5),HL
D1B0 LD DE,$0001 Set actual score points
D1B3 CALL $9945 Increment score
D1B6 RET
handle projectile collision with FOOT MAN dying 6
D1B7 LD A,($A1AC) Return if projectile type is spray
D1BA CP $04
D1BC RET Z
D1BD LD A,$04 Set enemy speed
D1BF LD (IX+$10),A
D1C2 LD HL,$AF7A Set address pointer for offsets animation
D1C5 LD (IX+$0A),L
D1C8 LD (IX+$0B),H
D1CB LD HL,$8258 Set address pointer of graphic data for FOOTMAN dying
D1CE LD (IX+$16),L
D1D1 LD (IX+$17),H
D1D4 LD (IX+$09),$06 Set entity type
D1D8 LD (IX+$11),$06 Set counter for state change
D1DC LD (IX+$14),$02 Set enemy health
D1E0 LD A,($A1D4) Decrement score points counter and return if zero
D1E3 DEC A
D1E4 RET Z
D1E5 LD ($A1D4),A Set the new score point counter value
D1E8 LD DE,($A1D5) Set DE bonus score points
D1EC CALL $9945 Increment score
D1EF LD HL,($A1D5) Increment bonus score points
D1F2 LD DE,$0001
D1F5 ADD HL,DE
D1F6 LD ($A1D5),HL
D1F9 LD HL,($A1D2) Increment base address into attribute file pointing to bonus points icon in HUD
D1FC LD DE,$0003
D1FF ADD HL,DE
D200 LD ($A1D2),HL
D203 RET
handle Rex takes bubble
D204 PUSH AF Save AF
D205 LD DE,$D573 Set DE sound buffer for catching small bubble
D208 CALL $D37F Configure sound channel and mixer register
D20B LD (IX+$0C),$00 Set bubble not visible
D20F LD A,$26 Set A the quantity of energy to increase
D211 CALL $BA09 Handle weapon energy increase
D214 XOR A Active HDU flash
D215 LD ($A1DB),A
D218 LD A,(IX+$15) Jump forward and return if bubble small
D21B OR A
D21C JP Z,$D22A
D21F LD A,$26 Set A the quantity of energy to increase
D221 CALL $BA09 Handle weapon energy increase
D224 LD DE,$D55E Set DE sound buffer for catching big bubble
D227 CALL $D37F Configure sound channel and mixer register
D22A POP AF Restore AF
D22B RET
handle Rex takes smartbomb
D22C LD (IX+$0C),$00 Set smartbomb to not visible
D230 LD A,($A205) Increase number of smartbombs
D233 INC A
D234 CP $04 Return if number of smartbombs is qual to 4
D236 RET Z
D237 LD ($A205),A Set the new number of smartbombs
D23A CALL $A371 Draw smartbombs
D23D LD DE,$D588 Set DE to the address for the smartbomb take sound
D240 CALL $D37F Configure sound channel and mixer register
D243 RET
Prev: CF59 Up: Map Next: D244