Prev: AB9A Up: Map Next: AD0D
AC3C: Test for collision with hazard
Input
IX Address of hazard structure ($A188+)
hazard_hit AC3C LD A,(IX+$0F) IX[15] appears to be a delay of some sort
AC3F AND A If IX[15] != 0 then goto hh_ac92
AC40 JR NZ,hh_ac92
AC42 LD A,(IX+$07) If IX[7] == 0 then return
AC45 AND A
AC46 RET Z
If we arrive here then a hit has occurred.
AC47 LD DE,($A24A) Load speed
AC4B JP P,hazard_hit_0 If IX[7] < 0 then DE = 280
AC4E LD DE,$0118
hazard_hit_0 AC51 LD B,D BC = DE
AC52 LD C,E
AC53 LD HL,$AD03 Point HL at table_ad03 table
This must be mapping the speed into the 5-entry array.
AC56 LD A,D A = D top part of speed
AC57 RL E E ROL 1 double speed
AC59 RLA A ROL 1
AC5A AND $03 A &= 3 mask top part to 3 (for ref. turbo speed = $1FF)
AC5C RR D RR D halve D to carry?
AC5E LD D,$00 D = 0
AC60 ADC A,D A = (A + D + carry) * 2 scale for element size of 2
AC61 ADD A,A
AC62 LD E,A E = A it's an offset in table_ad03
AC63 ADD HL,DE HL += DE
AC64 LD A,(HL) Copy (two bytes?) to IX+17 from table
AC65 LD (IX+$11),A
AC68 INC HL
AC69 LD A,(HL)
AC6A LD (IX+$12),A
AC6D SLA C double BC? adjusted speed retained from earlier
AC6F RL B
AC71 LD A,B If B >= 2 BC = 350 so this is if we hit the object very fast it gets put on the left?
AC72 CP $02
AC74 JR C,hazard_hit_1
AC76 LD BC,$015E
hazard_hit_1 AC79 LD (IX+$0D),C Set bottom byte of horizontal position
AC7C INC (IX+$07) Increment IX[7]
AC7F JR Z,hazard_hit_2 if B is zero then don't store it
AC81 LD (IX+$0E),B Set top byte of horizontal position
hazard_hit_2 AC84 INC (IX+$01) Increment IX[1]
AC87 LD BC,$0503 Call start_sfx with BC = $0503
AC8A CALL start_sfx
AC8D LD A,$02 A = 2 [set this to 1 and it drives off like a car]
AC8F LD (IX+$0F),A Set IX[15] to 2
hh_ac92 AC92 DEC A A--
AC93 RET Z If A == 0 return
AC94 LD HL,$ACDB IX[16] = table_acdb[IX[17]]
AC97 LD C,(IX+$11)
AC9A LD B,$00
AC9C ADD HL,BC
AC9D LD A,(HL)
AC9E LD (IX+$10),A
ACA1 INC (IX+$11) Increment IX[17]
ACA4 LD H,(IX+$0E) Load horizontal position into HL
ACA7 LD L,(IX+$0D)
ACAA LD D,H DE = HL
ACAB LD E,L
ACAC SRL D Divide horizontal position by 2?
ACAE RR E
ACB0 SRL E Then by 16 once it's 8 bits
ACB2 SRL E
ACB4 SRL E
ACB6 SRL E
ACB8 SBC HL,DE Then subtract from the previous position
ACBA LD (IX+$0E),H Set horizontal position
ACBD LD (IX+$0D),L
ACC0 LD A,(IX+$13) Toggle the bottom bit of IX[19]
ACC3 XOR $01
ACC5 LD (IX+$13),A
ACC8 DEC (IX+$12) Decrement IX[18]
ACCB RET NZ If IX[19] != 0 then return
ACCC XOR A Zero the horizontal position
ACCD LD (IX+$0D),A
ACD0 LD (IX+$0E),A
ACD3 INC A Set IX[19] to 1
ACD4 LD (IX+$13),A
ACD7 LD (IX+$0F),A Set IX[15] to 1
ACDA RET Return
table_acdb ACDB DEFB $19,$28,$32,$37,$39,$37,$32,$28 AC94 uses this
ACE3 DEFB $19,$00,$0F,$19,$1F,$22,$24,$22
ACEB DEFB $1F,$19,$0F,$00,$0A,$10,$13,$15
ACF3 DEFB $13,$10,$0A,$00,$06,$09,$0B,$09
ACFB DEFB $06,$00,$02,$00,$02,$00,$01,$00
table_ad03 AD03 DEFW $0622 AC53 uses this
AD05 DEFW $0C1C
AD07 DEFW $0E14
AD09 DEFW $120A
AD0B DEFW $1400
Prev: AB9A Up: Map Next: AD0D