| Chase H.Q. | Routines |
| Prev: A623 | Up: Map | Next: A7E7 |
|
This gets called whenever the perp is within sight of the hero car.
|
||||
| smash_handler | A637 | LD A,($A230) | Return if perp_caught_phase > 0 | |
| A63A | AND A | |||
| A63B | RET NZ | |||
| A63C | LD A,($A22E) | Call perp_sighted if sighted_flag is zero | ||
| A63F | AND A | |||
| A640 | CALL Z,perp_sighted | |||
| A643 | LD A,(IX+$07) | A = IX[7] | ||
| A646 | AND A | Set flags | ||
| A647 | JR Z,sh_a650 | Jump if zero | ||
| A649 | JP P,sh_a78a | Jump if positive | ||
|
Otherwise A is negative.
|
||||
| A64C | INC (IX+$07) | IX[7]++ | ||
| A64F | RET NZ | Return if non-zero | ||
|
A must be zero to arrive here.
|
||||
| sh_a650 | A650 | PUSH IY | Preserve IY | |
| A652 | LD C,(IX+$01) | C = IX[1] | ||
| A655 | LD B,$05 | 5 iterations | ||
| A657 | LD IY,$A19C | IY = &hazards[1] | ||
| A65B | LD DE,$0014 | DE = 20 -- stride of hazards | ||
| sh_hazards_loop | A65E | RLC (IY+$00) | If the hazard is active then jump to sh_a66c | |
| A662 | JR C,sh_a66c | |||
| sh_a664 | A664 | ADD IY,DE | Move to next hazard | |
| A666 | DJNZ sh_hazards_loop | Loop while B | ||
| A668 | POP IY | Restore IY | ||
| A66A | JR sh_a68f | Jump to sh_a68f | ||
| sh_a66c | A66C | LD A,(IY+$0F) | A = IY[15] | |
| A66F | RLA | Check top bit | ||
| A670 | JP NC,sh_a664 | Jump if clear | ||
| A673 | LD A,(IY+$01) | A = IY[1] - C | ||
| A676 | SUB C | |||
| A677 | JP NC,sh_a67e | Jump to sh_a67e if IY[1] > c | ||
| A67A | ADD A,$02 | A += 2 | ||
| A67C | JR sh_a680 | Jump to sh_a680 | ||
| sh_a67e | A67E | SUB $03 | A -= 3 | |
| sh_a680 | A680 | JR NC,sh_a664 | ||
| A682 | LD A,(IY+$11) | A = IY[17] | ||
| A685 | CP (IX+$12) | Compare to IX[18] | ||
| A688 | JP NZ,sh_a664 | |||
| A68B | POP IY | Restore IY $A650 pushed | ||
| A68D | JR sh_a6d8 | Jump to sh_a6d8 | ||
| sh_a68f | A68F | LD A,$00 | A = <self modified> | |
| A691 | AND A | Jump if non-zero | ||
| A692 | JR NZ,sh_a6f6 | |||
| A694 | LD A,(IX+$01) | A = IX[1] | ||
| A697 | CP $07 | Jump if A >= 7 | ||
| A699 | JR NC,sh_a6f6 | |||
|
I'm failing to understand what the following section does. It's a countdown that, when it hits zero, picks a new random countdown value summed with smash_5d1b. I can only think that it's a delay loop.
In-place decrementing counter.
|
||||
| A69B | LD A,$14 | A = <self modified> - 1 -- Self modified below | ||
| A69D | DEC A | |||
| A69E | JR NZ,sh_update_counter | Jump to sh_update_counter if non-zero | ||
|
When it hits zero we pick a random number...
|
||||
| A6A0 | INC C | [C incremented but overwritten in a moment - no effect?] | ||
| A6A1 | CALL rng | C = rng() & 31 | ||
| A6A4 | AND $1F | |||
| A6A6 | LD C,A | |||
|
This gets hit at some point during the smash process.
|
||||
| A6A7 | LD A,($5D1B) | A = smash_5d1b + C | ||
| A6AA | ADD A,C | |||
| sh_update_counter | A6AB | LD ($A69C),A | Self modify 'LD A,x' at A69B (above) to load A | |
|
This smells like it's detecting position and turning that into lanes. The values are like those used by get_spawn_lanes.
|
||||
| A6AE | LD HL,($A26C) | HL = road_pos - 164 | ||
| A6B1 | LD DE,$00A4 | |||
| A6B4 | SBC HL,DE | |||
| A6B6 | LD BC,$0404 | BC = $0404 | ||
| A6B9 | JR C,sh_a6cf | Jump to sh_a6cf if HL < 164 | ||
| A6BB | LD E,$46 | DE = $0046 | ||
| A6BD | DEC B | BC = $0304 | ||
| A6BE | SBC HL,DE | HL -= DE -- includes previous | ||
| A6C0 | JR C,sh_a6cf | Jump to sh_a6cf if HL < 70 | ||
| A6C2 | DEC B | BC = $0203 | ||
| A6C3 | DEC C | |||
| A6C4 | SBC HL,DE | HL -= DE -- includes previous | ||
| A6C6 | JR C,sh_a6cf | Jump to sh_a6cf if HL < 70 | ||
| A6C8 | DEC B | BC = $0102 | ||
| A6C9 | DEC C | |||
| A6CA | SBC HL,DE | HL -= DE -- includes previous | ||
| A6CC | JR C,sh_a6cf | Jump to sh_a6cf if HL < 70 | ||
| A6CE | DEC C | BC = $0101 | ||
| sh_a6cf | A6CF | LD A,(IX+$12) | A = IX[18] | |
| A6D2 | CP C | Jump to sh_a6d8 if A == C | ||
| A6D3 | JR Z,sh_a6d8 | |||
| A6D5 | CP B | Jump to sh_a6f6 if A == B | ||
| A6D6 | JR NZ,sh_a6f6 | |||
| sh_a6d8 | A6D8 | LD C,(IX+$12) | C = IX[18] | |
| A6DB | CALL rng | Call rng | ||
| A6DE | INC C | C++ | ||
| A6DF | AND A | Jump if C positive | ||
| A6E0 | JP P,sh_a6e5 | |||
| A6E3 | DEC C | C -= 2 | ||
| A6E4 | DEC C | |||
| sh_a6e5 | A6E5 | LD A,C | A = C | |
| A6E6 | AND A | Set flags | ||
| A6E7 | LD C,$02 | C = 2 | ||
| A6E9 | JP Z,sh_a6f2 | Jump if A is zero | ||
| A6EC | CP $05 | Jump if A < 5 | ||
| A6EE | JR C,sh_a6f3 | |||
| A6F0 | LD C,$FE | C = $FE | ||
| sh_a6f2 | A6F2 | ADD A,C | A += C | |
| sh_a6f3 | A6F3 | LD (IX+$12),A | IX[18] = A | |
| sh_a6f6 | A6F6 | LD C,(IX+$01) | C = IX[1] | |
| A6F9 | CALL get_spawn_lanes | Call get_spawn_lanes | ||
| A6FC | LD A,(IX+$12) | A = IX[18] | ||
| A6FF | CP B | Jump to sh_a707 if A >= B -- upper boundary? | ||
| A700 | JR NC,sh_a707 | |||
| A702 | ADD A,$02 | A += 2 | ||
| A704 | LD (IX+$12),A | IX[18] = A | ||
| sh_a707 | A707 | CP C | Jump to sh_a711 if A <= C -- lower boundary? | |
| A708 | JR Z,sh_a711 | |||
| A70A | JR C,sh_a711 | |||
| A70C | SUB $02 | A -= 2 | ||
| A70E | LD (IX+$12),A | IX[18] = A | ||
| sh_a711 | A711 | LD A,(IX+$12) | A = IX[18] | |
| A714 | LD HL,$A7E6 | HL = $A7E6 -> table_a7e7 data block | ||
| A717 | ADD A,L | L += A | ||
| A718 | LD L,A | |||
| A719 | LD A,(IX+$05) | A = IX[5] | ||
| A71C | CP (HL) | A == *HL ? | ||
| A71D | LD C,$01 | C = 1 | ||
| A71F | JR Z,sh_a735 | Jump if A == *HL | ||
| A721 | JR C,sh_a72e | Jump if A < *HL | ||
| A723 | SUB $0A | A -= 10 | ||
| A725 | JR C,sh_a72a | Jump if A was < 10 | ||
| A727 | CP (HL) | A == *HL ? | ||
| A728 | JR NC,sh_a737 | Jump if A >= *HL | ||
| sh_a72a | A72A | DEC C | C-- | |
| A72B | LD A,(HL) | A = *HL | ||
| A72C | JR sh_a737 | Jump sh_a737 | ||
| sh_a72e | A72E | ADD A,$0A | A += 10 | |
| A730 | JR C,sh_a735 | Jump if A+10 carried | ||
| A732 | CP (HL) | A == *HL ? | ||
| A733 | JR C,sh_a737 | Jump if A < *HL | ||
| sh_a735 | A735 | DEC C | C-- | |
| A736 | LD A,(HL) | A = *HL | ||
| sh_a737 | A737 | LD (IX+$05),A | IX[5] = A | |
| A73A | LD A,C | Self modify 'LD A' @ sh_a68f to load C | ||
| A73B | LD ($A690),A | |||
| A73E | LD A,$00 | A = <self modified> | ||
| A740 | AND A | Set flags | ||
| A741 | LD DE,$001E | DE = $1E | ||
| A744 | LD HL,$00E6 | HL = $E6 | ||
| A747 | JR NZ,sh_a762 | Jump sh_a762 if non-zero | ||
|
Countdown+rng stuff again... as at A69B
In-place decrementing counter.
|
||||
| A749 | LD A,$14 | A = <self modified> - 1 -- Self modified below | ||
| A74B | DEC A | |||
| A74C | LD ($A74A),A | Self modify 'LD A,x' @ A749 (above) to load A | ||
| A74F | JR NZ,sh_a776 | Jump to sh_a776 if non-zero | ||
|
When it hits zero we pick a random number...
|
||||
| A751 | PUSH HL | Preserve HL [what's in it?] | ||
| A752 | CALL rng | Call rng | ||
| A755 | POP HL | Restore HL | ||
| A756 | AND $0F | C = (result of rng) & 15 | ||
| A758 | LD C,A | |||
| A759 | LD A,($5D1C) | A = smash_5d1c + C | ||
| A75C | ADD A,C | |||
| A75D | LD ($A74A),A | Self modify 'LD A,x' @ A749 (above) to load A | ||
| A760 | LD A,$0A | A = 10 | ||
| sh_a762 | A762 | DEC A | A-- | |
| A763 | LD ($A73F),A | Self modify 'LD A,x' @ A73E (above) to load A | ||
| A766 | JR Z,sh_a776 | Jump to sh_a776 if zero | ||
|
sampled IX = $A188 (hazards)
|
||||
| A768 | LD A,(IX+$01) | A = IX[1] -- load hazard_1 distance byte | ||
| A76B | CP $0D | Jump if A >= 13 -- too far | ||
| A76D | JR NC,sh_a776 | |||
|
Distance to perp is 12 or less.
HL += (15 - A) * DE
This seems to be using the distance to the perp as a scale by which to adjust its horizontal position.
|
||||
| A76F | CPL | B = (15 - A) -- iterations | ||
| A770 | ADD A,$0E | |||
| A772 | LD B,A | |||
| sh_a773_loop | A773 | ADD HL,DE | HL += DE | |
| A774 | DJNZ sh_a773_loop | Loop to loop_a773 while B > 0 | ||
| sh_a776 | A776 | LD A,(IX+$01) | A = IX[1] - 6 -- load hazard_1 distance byte again | |
| A779 | SUB $06 | |||
| A77B | JR NC,sh_store_exit | Jump to sh_store_exit if A >= 6 | ||
|
Distance to perp is 5 or less.
|
||||
| A77D | ADD A,$05 | Put back most of what we just subtracted | ||
| A77F | ADD A,A | Multiply by 8 | ||
| A780 | ADD A,A | |||
| A781 | ADD A,A | |||
|
And then we do nothing with A?
|
||||
| A782 | ADD HL,DE | HL += DE | ||
| sh_store_exit | A783 | LD (IX+$0D),L | wordat(IX + 13) = HL -- store horizontal position (or accel?) | |
| A786 | LD (IX+$0E),H | |||
| A789 | RET | Return | ||
| sh_a78a | A78A | LD (IX+$07),$FC | IX[7] = $FC | |
| A78E | CP $03 | Jump if A < 3 -- preserve A | ||
| A790 | PUSH AF | |||
| A791 | JR C,sh_check_boost | |||
| A793 | SUB $03 | A -= 3 -- 0.. | ||
| sh_check_boost | A795 | EX AF,AF' | Bank | |
| A796 | LD A,($A24E) | Load turbo boost time remaining (60..0) | ||
| A799 | AND A | Set flags | ||
| A79A | LD A,$C8 | 200 when not turbo boosting | ||
| A79C | JR Z,sh_a7a0 | Jump if no turbo boost | ||
| A79E | LD A,$E6 | 230 when turbo boosting | ||
| sh_a7a0 | A7A0 | EX AF,AF' | Bank value chosen from boost; Unbank other | |
| A7A1 | CALL cc_hit_scenery2 | Call cc_hit_scenery2 | ||
| A7A4 | LD HL,($B32F) | Read HL from 'LD BC,x' @ B32E | ||
| A7A7 | LD DE,$0028 | HL += 40 | ||
| A7AA | ADD HL,DE | |||
| A7AB | LD ($B32F),HL | Self modify 'LD BC,x' @ B32E | ||
| A7AE | LD D,$00 | D = 0 -- bonus middle digit | ||
| A7B0 | POP AF | -- restore A which holds the IX[7] flags from earlier AND FLAGS TOO | ||
| A7B1 | LD HL,$B4F0 | Put a call to smash on the stack | ||
| A7B4 | PUSH HL | |||
| A7B5 | JR NC,sh_a7be | Jump if no carry | ||
| A7B7 | CP $02 | Jump if A == 2 | ||
| A7B9 | JR Z,sh_a7be | |||
| A7BB | PUSH HL | Put another call to smash on the stack | ||
|
Break?
|
||||
| A7BC | LD D,$04 | D = 4 -- bonus middle digit | ||
| sh_a7be | A7BE | LD A,($8007) | D = wanted_stage_number + D (D could be 0 or 4) | |
| A7C1 | ADD A,D | |||
| A7C2 | LD D,A | |||
| A7C3 | LD E,$00 | E = 0 -- bonus top digit(s) | ||
| A7C5 | LD A,($8006) | Jump if retry_count is zero | ||
| A7C8 | AND A | |||
| A7C9 | JR Z,sh_retry_was_zero | |||
| A7CB | LD A,D | Middle digit(s) of bonus | ||
| A7CC | LD D,E | Set top two digits of bonus | ||
| A7CD | RLCA | Move middle digit into position | ||
| A7CE | RLCA | |||
| A7CF | RLCA | |||
| A7D0 | RLCA | |||
| A7D1 | LD E,A | Set middle digits of bonus | ||
| sh_retry_was_zero | A7D2 | XOR A | Clear low digits of bonus | |
| A7D3 | CALL bonus | Call bonus | ||
| A7D6 | LD A,$05 | A = 5 | ||
| A7D8 | LD ($A73F),A | Self modify 'LD A' @ A73E to load A | ||
| A7DB | LD HL,$98D6 | Point HL at smash_chatter ("BEAR DOWN" / "OH MAN" / etc.) | ||
| A7DE | CALL start_chatter | Call start_chatter (priority 5) | ||
| A7E1 | LD BC,$0301 | Effect 3 (car crash), Priority 1 | ||
| A7E4 | JP start_sfx | Exit via start_sfx | ||
| Prev: A623 | Up: Map | Next: A7E7 |