Prev: A623 Up: Map Next: A7E7
A637: Smash handling
This gets called whenever the perp is within sight of the hero car.
smash_handler A637 LD A,($A230) Return if perp_caught_stage > 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,smash_handler_0 Jump if zero
A649 JP P,smash_handler_21 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.
smash_handler_0 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_a65e_loop A65E RLC (IY+$00) If the hazard is active then jump to smash_handler_2
A662 JR C,smash_handler_2
smash_handler_1 A664 ADD IY,DE Move to next hazard
A666 DJNZ sh_a65e_loop Loop while B
A668 POP IY Restore IY
A66A JR smash_handler_5 Jump to smash_handler_5
smash_handler_2 A66C LD A,(IY+$0F) A = IY[15]
A66F RLA
A670 JP NC,smash_handler_1
A673 LD A,(IY+$01) A = IY[1] - C
A676 SUB C
A677 JP NC,smash_handler_3
A67A ADD A,$02 A += 2
A67C JR smash_handler_4
smash_handler_3 A67E SUB $03 A -= 3
smash_handler_4 A680 JR NC,smash_handler_1
A682 LD A,(IY+$11) A = IY[17]
A685 CP (IX+$12) CP IX[18]
A688 JP NZ,smash_handler_1
A68B POP IY
A68D JR smash_handler_7
smash_handler_5 A68F LD A,$00 A = 0
A691 AND A Set flags
A692 JR NZ,smash_handler_11
A694 LD A,(IX+$01) A = IX[1]
A697 CP $07 Jump if A >= 7
A699 JR NC,smash_handler_11
Inline decrementing counter.
A69B LD A,$14 A = <self modified> - 1 -- self modified below
A69D DEC A
A69E JR NZ,smash_handler_6 Jump if != 0
When it hits zero we pick a random number...
A6A0 INC C -- why increment C when it's overwritten next?
A6A1 CALL rng C = rng() & $1F
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
smash_handler_6 A6AB LD ($A69C),A *$A69C = A -- Self modify LD A at A69B
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
A6D3 JR Z,smash_handler_7
A6D5 CP B
A6D6 JR NZ,smash_handler_11
smash_handler_7 A6D8 LD C,(IX+$12) C = IX[18]
A6DB CALL rng Call rng
A6DE INC C C++
A6DF AND A Set flags
A6E0 JP P,smash_handler_8 Jump if positive
A6E3 DEC C C -= 2
A6E4 DEC C
smash_handler_8 A6E5 LD A,C A = C
A6E6 AND A Set flags
A6E7 LD C,$02 C = 2
A6E9 JP Z,smash_handler_9 Jump if A is zero
A6EC CP $05 Jump if A < 5
A6EE JR C,smash_handler_10
A6F0 LD C,$FE C = $FE
smash_handler_9 A6F2 ADD A,C A += C
smash_handler_10 A6F3 LD (IX+$12),A IX[18] = A
smash_handler_11 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
A700 JR NC,smash_handler_12
A702 ADD A,$02 A += 2
A704 LD (IX+$12),A IX[18] = A
smash_handler_12 A707 CP C
A708 JR Z,smash_handler_13 Jump to smash_handler_13 if A <= C
A70A JR C,smash_handler_13
A70C SUB $02 A -= 2
A70E LD (IX+$12),A IX[18] = A
smash_handler_13 A711 LD A,(IX+$12) A = IX[18]
A714 LD HL,$A7E6 HL = $A7E6 -> table_a7e7 data block
A717 ADD A,L A += L
A718 LD L,A L = A
A719 LD A,(IX+$05) A = IX[5]
A71C CP (HL) CP *HL
A71D LD C,$01 C = 1
A71F JR Z,smash_handler_16
A721 JR C,smash_handler_15
A723 SUB $0A A -= 10
A725 JR C,smash_handler_14
A727 CP (HL) CP *HL
A728 JR NC,smash_handler_17
smash_handler_14 A72A DEC C C--
A72B LD A,(HL) A = *HL
A72C JR smash_handler_17
smash_handler_15 A72E ADD A,$0A A += 10
A730 JR C,smash_handler_16
A732 CP (HL) CP *HL
A733 JR C,smash_handler_17
smash_handler_16 A735 DEC C C--
A736 LD A,(HL) A = *HL
smash_handler_17 A737 LD (IX+$05),A IX[5] = A
A73A LD A,C Self modify 'LD A' @ smash_handler_5 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,smash_handler_18
A749 LD A,$14 A = <self modified> -- Self modified below
A74B DEC A A--
A74C LD ($A74A),A Self modify 'LD A' @ A749 to load A
A74F JR NZ,smash_handler_19
A751 PUSH HL Preserve HL
A752 CALL rng Call rng
A755 POP HL Restore HL
A756 AND $0F C = A & 15 mask random value
A758 LD C,A
A759 LD A,($5D1C) A = ($5D1C) + C
A75C ADD A,C
A75D LD ($A74A),A Self modify 'LD A' @ A749 to load A
A760 LD A,$0A A = 10
smash_handler_18 A762 DEC A A--
A763 LD ($A73F),A Self modify 'LD A' @ A73E to load A
A766 JR Z,smash_handler_19
A768 LD A,(IX+$01) A = IX[1]
A76B CP $0D CP 13
A76D JR NC,smash_handler_19
A76F CPL B = (13 - 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
smash_handler_19 A776 LD A,(IX+$01) A = IX[1] - 6
A779 SUB $06
A77B JR NC,smash_handler_20 Jump if A >= 6
A77D ADD A,$05 A = (A + 5) * 8
A77F ADD A,A
A780 ADD A,A
A781 ADD A,A
A782 ADD HL,DE HL += DE
smash_handler_20 A783 LD (IX+$0D),L wordat(IX + 13) = HL
A786 LD (IX+$0E),H
A789 RET Return
smash_handler_21 A78A LD (IX+$07),$FC IX[7] = $FC
A78E CP $03 Jump if A < 3 -- preserve A
A790 PUSH AF
A791 JR C,smash_handler_22
A793 SUB $03 A -= 3
smash_handler_22 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 A = $C8 -- value for when not turbo boosting
A79C JR Z,smash_handler_23 Jump if no turbo boost
A79E LD A,$E6 A = $E6 -- value for when turbo boosting
smash_handler_23 A7A0 EX AF,AF'
A7A1 CALL check_collisions_8 (crash testing stuff...)
A7A4 LD HL,($B32F) Read HL from 'LD BC' @ B32E
A7A7 LD DE,$0028 HL += 40
A7AA ADD HL,DE
A7AB LD ($B32F),HL ($B32F) = HL
A7AE LD D,$00 D = 0
A7B0 POP AF -- restore A
A7B1 LD HL,$B4F0 HL = smash
A7B4 PUSH HL Preserve HL
A7B5 JR NC,smash_handler_24
A7B7 CP $02
A7B9 JR Z,smash_handler_24
A7BB PUSH HL
A7BC LD D,$04 D = 4
smash_handler_24 A7BE LD A,($8007) D = wanted_stage_number + D
A7C1 ADD A,D
A7C2 LD D,A
A7C3 LD E,$00 E = 0
A7C5 LD A,($8006) Jump if retry_count is zero
A7C8 AND A
A7C9 JR Z,smash_handler_25
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
smash_handler_25 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 chatter Call chatter (priority 5)
A7E1 LD BC,$0301 BC = $0301
A7E4 JP start_sfx Exit via start_sfx
Prev: A623 Up: Map Next: A7E7