| Chase H.Q. | Routines |
| Prev: AB9A | Up: Map | Next: AD0D |
|
The hit handler for the static hazards, the barriers and tumbleweeds, hooked into every slot that spawn_hazards spawns.
IX[15] is a three-state machine. 0 is the untouched state: return unless IX[7] shows a hit, otherwise look the wobble parameters up by hero speed, stash them in IX[17] and IX[18], scale the approach speed, play the hit effect and move to state 2. 2 is the wobble itself: each call steps IX[16] through the amplitude table, decays the speed by a thirty-second, toggles the inverted flag and counts IX[18] down, and at zero it clears the speed and the flag and drops to state 1. 1 is finished, and returns at once.
If IX[15] is non-zero then jump forward.
|
||||||||
| 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_dec_test | ||||||
| AC40 | JR NZ,hh_dec_test | |||||||
|
IX[15] is zero.
|
||||||||
| AC42 | LD A,(IX+$07) | If IX[7] (hit counter) == 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,hh_ac51 | If IX[7] (hit counter) < 0 then DE = 280 | ||||||
| AC4E | LD DE,$0118 | |||||||
| hh_ac51 | 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 now an offset into table_ad03 | ||||||
| AC63 | ADD HL,DE | HL += DE | ||||||
|
Copy two bytes to IX+17 from table
|
||||||||
| AC64 | LD A,(HL) | |||||||
| AC65 | LD (IX+$11),A | |||||||
| AC68 | INC HL | |||||||
| AC69 | LD A,(HL) | |||||||
| AC6A | LD (IX+$12),A | -- usually current lane | ||||||
| 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,hh_ac79 | |||||||
| AC76 | LD BC,$015E | |||||||
| hh_ac79 | AC79 | LD (IX+$0D),C | Set bottom byte of horizontal position | |||||
| AC7C | INC (IX+$07) | Increment hit counter | ||||||
| AC7F | JR Z,hh_ac84 | If counter is zero then don't store it | ||||||
| AC81 | LD (IX+$0E),B | Set top byte of horizontal position | ||||||
| hh_ac84 | AC84 | INC (IX+$01) | Increment IX[1] -- distance/buffer offset | |||||
| AC87 | LD BC,$0503 | Effect 5 (hazard hit), Priority 3 | ||||||
| AC8A | CALL start_sfx | Call start_sfx | ||||||
| AC8D | LD A,$02 | A = 2 [set this to 1 and the hazard drives off like a car] | ||||||
| AC8F | LD (IX+$0F),A | Set IX[15] to 2 -- a delay value? | ||||||
| hh_dec_test | AC92 | DEC A | If --A == 0 return | |||||
| AC93 | RET Z | |||||||
| hh_ac94 | 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 (or accel?) 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 | hh_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 |