Prev: A399 Up: Map Next: A4F6
A4B8: Scenery was hit
Sets up the crash state after hitting scenery or a tunnel wall. It returns at once if the car is already crashed, so a second hit during the spin does nothing. The spin speed starts at the greater of 24 and speed/16 + 16, and the speed the car decays to is the lesser of the current speed and the cap passed in A'. The crash flags, the flip direction, the delay counter, the spin speed and that speed cap are then written out, the last two by self modifying B356 and B32E.
Input
A Flip flag: 0 for the right hand side, 1 for the left
A' Speed cap: the crash starts at the lower of this and the current speed
scenery_hit A4B8 LD HL,$B326 Load address of the x in 'LD A,x' @ ahc_check_crashed (crashed flag)
A4BB INC (HL) Set flags
A4BC DEC (HL)
A4BD RET NZ Return if already crashed
sch_new_crash A4BE LD (HL),$01 Set crashed flag
A4C0 LD ($B36F),A *$B36F = A -- set flip flag (0/1 = right/left)
A4C3 INC A *$B38E = A + 1
A4C4 LD ($B38E),A
A4C7 LD A,$05 *$B385 = 5
A4C9 LD ($B385),A
A4CC LD HL,($A24A) Load speed into HL
A4CF PUSH HL Preserve speed
A4D0 SRL H A = HL >> 1
A4D2 LD A,L
A4D3 RR A
A4D5 SRL A A = (A >> 3) + 16
A4D7 SRL A
A4D9 SRL A
A4DB ADD A,$10
A4DD LD L,$18 L = MAX(24, A)
A4DF CP L
A4E0 JR C,sch_a4e3
A4E2 LD L,A
sch_a4e3 A4E3 LD ($B357),HL Self modify 'LD HL,$xxxx' @ B356
A4E6 EX AF,AF'
A4E7 LD L,A HL = A'
A4E8 LD H,$00
A4EA POP DE Restore speed
A4EB PUSH HL
A4EC SBC HL,DE HL -= DE
A4EE POP HL
A4EF JR C,sch_exit
A4F1 EX DE,HL
sch_exit A4F2 LD ($B32F),HL Self modify 'LD BC' @ B32E to load HL
A4F5 RET Return
Prev: A399 Up: Map Next: A4F6