| Chase H.Q. | Routines |
| Prev: A89C | Up: Map | Next: A955 |
|
Called once a frame for each traffic car: it clamps the car's target lane to the lanes the road offers at its position, slides the car toward that lane and deals with a collision against the hero car.
If perp_caught_phase or dont_spawn_cars is set the car is pushed off screen instead, by setting its speed word to $01FF.
The two lane bytes are distinct: IX[17] is the lane the car occupies now and IX[18] the lane it is heading for. get_spawn_lanes returns the lowest and highest lanes in use at the car's road position -- the range narrows at a fork -- and it is IX[18] that gets clamped to it. While the two disagree, IX[5] slides +/-5 a frame toward the lane's column in hazard_pos_speed; on arrival IX[17] is set to IX[18] and the car has changed lane.
If IX[7] is non-zero the collision engine has hit this car: the slot is freed, the overtake bonus is cleared and scenery_hit is called to apply the crash penalty.
|
||||||||
| hazard_handler | A8CD | LD A,($A230) | Jump if perp_caught_phase > 0 | |||||
| A8D0 | AND A | |||||||
| A8D1 | JR NZ,hzh_perp_caught_or_no_car_spawning | |||||||
| A8D3 | LD A,($A225) | Check dont_spawn_cars flag | ||||||
| A8D6 | AND A | |||||||
| A8D7 | JR Z,hzh_clamp_lanes | |||||||
| hzh_perp_caught_or_no_car_spawning | A8D9 | LD (IX+$0E),$01 | IX[14] = $01 -- horizontal position or accel? | |||||
| A8DD | LD (IX+$0D),$FF | IX[13] = $FF | ||||||
| hzh_clamp_lanes | A8E1 | LD C,(IX+$01) | Load buffer offset (distance from camera) required for next call | |||||
| A8E4 | CALL get_spawn_lanes | Call get_spawn_lanes | ||||||
| A8E7 | LD A,(IX+$11) | Read the lane the car occupies now | ||||||
| A8EA | CP B | If A < B IX[18] = B -- clamp the target lane up to get_spawn_lanes' minimum. IX[18] is the target lane, which is why IX[17] is left alone here | ||||||
| A8EB | JR NC,hzh_clamp_max_lane | |||||||
| A8ED | LD (IX+$12),B | |||||||
| hzh_clamp_max_lane | A8F0 | CP C | If A > C IX[18] = C -- clamp the target lane down to get_spawn_lanes' maximum | |||||
| A8F1 | JR Z,hzh_test_chosen_lane | |||||||
| A8F3 | JR C,hzh_test_chosen_lane | |||||||
| A8F5 | LD (IX+$12),C | |||||||
| hzh_test_chosen_lane | A8F8 | LD A,(IX+$12) | Read back the target lane | |||||
| A8FB | CP (IX+$11) | Jump to hzh_7 if A == IX[17] -- already in the target lane, nothing to slide | ||||||
| A8FE | JR Z,hzh_7 | |||||||
| A900 | RL B | Stash this comparison's carry in B's bottom bit. B's own value (the minimum lane) is finished with | ||||||
| A902 | LD HL,$A7E6 | HL = $A7E6 -> hazard_pos_speed table (1-indexed) | ||||||
| A905 | LD C,A | C = A -- copy chosen lane to C | ||||||
| A906 | ADD A,L | Compute HL[A] | ||||||
| A907 | LD L,A | |||||||
|
breakpoint hit here seemingly when the right hand side narrows and there's a barrier
|
||||||||
| A908 | LD A,(IX+$05) | A = IX[5] e.g. $A19C[5] | ||||||
| A90B | RR B | Recover the carry stashed at A900: set when the target lane is left of the current one | ||||||
| A90D | JR NC,hzh_check_max | Jump to slide right if it is to the right | ||||||
| A90F | SUB $05 | A -= 5 | ||||||
| A911 | CP (HL) | CP *HL -- comparing (IX[5] - 5) to entry from A7E7 table | ||||||
| A912 | JR NC,hzh_set_ix_5 | jump if (IX[5] - 5) > entry | ||||||
| A914 | LD A,(HL) | load entry | ||||||
| A915 | LD (IX+$11),C | IX[17] = C -- set chosen lane | ||||||
| A918 | JR hzh_set_ix_5 | Jump to hzh_set_ix_5 | ||||||
| hzh_check_max | A91A | ADD A,$05 | compute (IX[5] + 5) | |||||
| A91C | CP (HL) | compare to (same) entry from A7E7 table | ||||||
| A91D | JR C,hzh_set_ix_5 | jump if (IX[5] + 5) < entry | ||||||
| A91F | LD A,(HL) | load entry | ||||||
| A920 | LD (IX+$11),C | IX[17] = C -- set chosen lane | ||||||
| hzh_set_ix_5 | A923 | LD (IX+$05),A | IX[5] = A -- set entry from table | |||||
| hzh_7 | A926 | LD A,(IX+$07) | A = IX[7] | |||||
| A929 | AND A | Set flags | ||||||
| A92A | RET Z | Return if zero | ||||||
| A92B | EX AF,AF' | Preserve AF | ||||||
| A92C | LD (IX+$07),$00 | IX[7] = 0 | ||||||
| A930 | LD A,($B326) | Return if crashed flag set | ||||||
| A933 | AND A | |||||||
| A934 | RET NZ | |||||||
|
A is zero.
|
||||||||
| A935 | LD (IX+$00),A | IX[0] = 0 -- unused hazard | ||||||
| A938 | LD ($A13C),A | overtake_bonus_bcd = 0 | ||||||
| A93B | LD A,$96 | A = $96 | ||||||
| A93D | EX AF,AF' | Restore AF | ||||||
| A93E | CP $03 | Jump if A < 3 | ||||||
| A940 | JR C,hzh_crashed | |||||||
| A942 | SUB $03 | A -= 3 | ||||||
| hzh_crashed | A944 | CALL scenery_hit | Call scenery_hit | |||||
| A947 | LD HL,$9904 | Load address of ouch_chatter | ||||||
| A94A | LD A,$03 | Call start_chatter (priority 3) | ||||||
| A94C | CALL start_chatter | |||||||
| A94F | LD BC,$0302 | Effect 3 (car crash), Priority 2 | ||||||
| A952 | JP start_sfx | Call start_sfx | ||||||
| Prev: A89C | Up: Map | Next: A955 |