Prev: B045 Up: Map Next: B318
B063: Hero car jumps; gear changing; off road checks; speed adjustment
Used by the routines at main_loop and cpu_driver.
move_hero_car B063 LD A,$00 Load jump counter. Self modified by 8827 and B965. Highest is 8.
B065 AND A Jump to mhc_not_jumping if the jump counter is zero
B066 JR Z,mhc_not_jumping
Hero car is jumping.
mhc_jumping B068 DEC A Decrement the jump counter in (self modified) move_hero_car
B069 LD ($B064),A
B06C JR NZ,mhc_midair Jump to mhc_midair if we're still jumping
Hero car has landed.
mhc_landed B06E LD A,$03 smoke = 3
B070 LD ($A24F),A
B073 LD BC,$0203 Thump sfx as the car lands
B076 CALL start_sfx Call start_sfx
Hero car is in mid-air.
mhc_midair B079 LD HL,$0000 Point HL at entry in jump table. Self modified by B96C and B092
B07C XOR A off_road = 0
B07D LD ($A23E),A
B080 LD A,($A0D5) Clear up/down/left/right bits of user input (can't turn in mid-air etc.)
B083 AND $F0
B085 LD ($A0D5),A
B088 LD A,(HL) $B5B0 = *HL++ -- Self modified value in draw_car
B089 LD ($B5B0),A
B08C INC HL
B08D LD A,($B5AB) A = *$B5AB + *HL++ -- Self modified value in draw_car - vertical shift?
B090 ADD A,(HL)
B091 INC HL
B092 LD ($B07A),HL Update HL load above, mhc_midair
mhc_not_jumping B095 LD ($B5AB),A *$B5AB = A
B098 LD HL,$A24E Address of boost timer
B09B LD A,(HL) Jump if a turbo boost is not in effect
B09C AND A
B09D JR Z,mhc_smoke
B09F DEC (HL) Decrement boost timer
B0A0 JR NZ,mhc_smoke Jump if boost timer is non-zero
B0A2 LD A,($A170) Decrement turbo boost count [POKE $B0A5,0 for Infinite turbos]
B0A5 DEC A
B0A6 LD ($A170),A
Handle smoke effect.
mhc_smoke B0A9 INC HL HL now points at smoke
B0AA LD A,(HL) Jump if smoke is zero
B0AB AND A
B0AC JR Z,move_hero_car_0
B0AE DEC (HL) Decrement smoke
Handle gear changes.
move_hero_car_0 B0AF LD A,($A0D5) Read user input
B0B2 LD C,A C = A
B0B3 LD A,($B326) Read from the 'LD A,x' @ main_loop_24_0 (crash flag)
B0B6 AND A Jump if zero
B0B7 JR Z,move_hero_car_1
B0B9 LD A,C C = C & $10, i.e. Fire/Gear
B0BA AND $10
B0BC LD C,A
move_hero_car_1 B0BD LD A,C A = C
B0BE PUSH AF
B0BF BIT 4,A Test it again? [Strange to re-test it?]
B0C1 LD HL,$A253 Address of gear flag
B0C4 LD A,($A252) A = var_a252
B0C7 JR Z,move_hero_car_2 Jump if fire/gear is unset
B0C9 AND A Jump if var_a252 is set
B0CA JR NZ,move_hero_car_2
B0CC LD A,(HL) Toggle gear flag
B0CD XOR $01
B0CF LD (HL),A
B0D0 LD A,$04 A = 4
B0D2 JR Z,move_hero_car_2 Jump if low gear?
B0D4 LD ($A24F),A smoke = A
move_hero_car_2 B0D7 SUB $01 Decement A [why write it as a SUB 1?]
B0D9 JR C,move_hero_car_3 jump if +ve?
B0DB LD ($A252),A var_a252 = A
move_hero_car_3 B0DE LD A,(HL) Read current gear flag
B0DF EX AF,AF' Bank it
B0E0 LD HL,($A24A) Read current speed
B0E3 PUSH HL Stack it
B0E4 LD DE,$0078 HL -= 120
B0E7 SBC HL,DE
B0E9 JR NC,move_hero_car_4 Jump if speed >= 120
B0EB LD A,($A230) Jump if perp_caught_stage > 0
B0EE AND A
B0EF JR NZ,move_hero_car_4
Handle idle timer.
B0F1 LD HL,$A16E Address of idle timer
B0F4 DEC (HL) Decrement idle timer
B0F5 JR NZ,move_hero_car_4 Jump if non-zero
B0F7 LD (HL),$64 Reset idle timer to 100
B0F9 LD A,$0A Set priority to 10
B0FB LD HL,$98F8 HL = get_moving_chatter
B0FE CALL chatter Call chatter (priority 10)
move_hero_car_4 B101 POP HL Pop speed
B102 LD D,H DE = HL
B103 LD E,L
B104 LD A,($A23E) Load the off-road flag
B107 AND A Jump if zero
B108 JR Z,move_hero_car_6
Handle off-road (it can be 1 or 2).
B10A LD BC,$0078 BC = 120 -- factor for off-road == 1
B10D DEC A Jump if off-road was one
B10E JR Z,move_hero_car_5
B110 LD BC,$006E BC = 110 -- factor for off-road == 2
move_hero_car_5 B113 AND A Clear carry?
B114 SBC HL,BC HL -= BC -- 16-bit sub just for testing
B116 LD H,D HL = DE
B117 LD L,E
B118 JR C,move_hero_car_6 Jump if HL < BC (result of subtraction)
B11A LD A,L A = L
B11B RR H H >>= 1 -- 9 bit rotate right through carry
B11D RLA A <<= 4 -- 9 bit rotate left through carry
B11E RLA
B11F RLA
B120 RLA
B121 AND $0F A = -((A & $0F) | 1)
B123 OR $01
B125 NEG
B127 LD C,A BC = $FF00 | A
B128 LD B,$FF
B12A JP move_hero_car_11
move_hero_car_6 B12D LD A,($A24E) A = boost (time remaining)
B130 AND A Test then bank the flags
B131 EX AF,AF' Bank
B132 AND A Check previously banked A
B133 JR NZ,move_hero_car_9
B135 LD BC,$01D6 BC = 470
B138 EX AF,AF' Unbank boost + flags
B139 JR NZ,move_hero_car_7 Uses banked flags
B13B LD BC,$00E6 BC = 230
move_hero_car_7 B13E SBC HL,BC HL -= BC
B140 JP NC,move_hero_car_8
B143 LD A,L C = ~L
B144 CPL
B145 LD C,A
B146 LD A,H B = ~H
B147 CPL
B148 LD B,A
B149 INC BC BC++
B14A LD A,C A = C
B14B SRL B B >>= 1
B14D RRA
B14E SRL B B >>= 1
B150 RRA
B151 RRA
B152 RRA
B153 AND $3F C = (A & $3F) | 1
B155 OR $01
B157 LD C,A
B158 JR move_hero_car_11
move_hero_car_8 B15A LD A,L A = L
B15B SRL H H >>= 1
B15D RRA
B15E SRL H H >>= 1
B160 RRA
B161 RRA
B162 RRA
B163 AND $1F A = -((A & $1F) | 1)
B165 OR $01
B167 NEG
B169 LD C,A BC = $FF00 | A
B16A LD B,$FF
B16C JR move_hero_car_11
move_hero_car_9 B16E LD BC,$00DC BC = 220
B171 SBC HL,BC HL -= BC -- for flags
B173 LD H,D HL = DE
B174 LD L,E
B175 JR NC,move_hero_car_10 from result of calc
B177 LD BC,$01D6 BC = 470
B17A EX AF,AF'
B17B JR NZ,move_hero_car_7
B17D LD A,E A = E
B17E LD B,D B = D
B17F SRL B B >>= 1
B181 RRA
B182 SRL B B >>= 1
B184 RRA
B185 RRA
B186 RRA
B187 OR $01 C = (A | 1) & $1F
B189 AND $1F
B18B LD C,A
B18C JR move_hero_car_11
move_hero_car_10 B18E LD BC,$02B7 BC = 695
B191 EX AF,AF'
B192 JR NZ,move_hero_car_7
B194 LD BC,$0168 BC = 360
B197 JP move_hero_car_7
move_hero_car_11 B19A POP AF Get stacked AF
B19B PUSH AF
B19C RRA Test bit 2?
B19D RRA
B19E RRA
B19F JR NC,move_hero_car_12
B1A1 LD BC,$FFEC BC = $FFEC
B1A4 JR move_hero_car_13
move_hero_car_12 B1A6 RRA
B1A7 JR C,move_hero_car_13
B1A9 LD BC,$FFF6
move_hero_car_13 B1AC LD H,D HL = DE
B1AD LD L,E
B1AE AND A Clear carry?
B1AF ADC HL,BC HL += BC
B1B1 JP P,move_hero_car_14
B1B4 LD HL,$0000 HL = $0000
move_hero_car_14 B1B7 LD A,($A24C) A = var_a24c - 1
B1BA SUB $01
B1BC JR NC,move_hero_car_17
B1BE LD A,($B5B0) A = $B5B0
B1C1 AND A Set flags
B1C2 JR Z,move_hero_car_17
B1C4 LD C,A C = A
B1C5 LD A,H A = H
B1C6 OR L A |= L
B1C7 JR Z,move_hero_car_17
B1C9 LD A,C A = (C - 5) | 1
B1CA SUB $05
B1CC OR $01
B1CE LD C,A C = A
B1CF LD B,$00 B = 0
B1D1 JP P,move_hero_car_15
B1D4 DEC B B--
move_hero_car_15 B1D5 LD D,H DE = HL
B1D6 LD E,L
B1D7 ADD HL,BC HL += BC
B1D8 LD BC,$02B7 BC = 695
B1DB PUSH HL
B1DC SBC HL,BC HL -= BC
B1DE POP HL
B1DF JR C,move_hero_car_16
B1E1 EX DE,HL
move_hero_car_16 B1E2 LD A,$03 A = 3
move_hero_car_17 B1E4 LD ($A24C),A var_a24c = A
B1E7 LD A,H A = H
B1E8 CP $02 CP 2
B1EA JR C,move_hero_car_18
B1EC LD HL,$01FF Cap speed to $1FF
move_hero_car_18 B1EF LD ($A24A),HL Set speed to HL
B1F2 POP HL
B1F3 LD A,($A263) A = var_a263
B1F6 LD B,A B = A
B1F7 LD A,($A264) A = var_a264
B1FA LD C,A C = A
B1FB LD A,($B064) A = *$B064 -- Jump counter [self modified]
B1FE AND A Set flags
B1FF JP NZ,move_hero_car_27
B202 RR H
B204 JR C,move_hero_car_21
B206 RR H
B208 JR C,move_hero_car_23
B20A LD A,C A = C - 9
B20B SUB $09
B20D JR NC,move_hero_car_19
B20F XOR A A = 0
move_hero_car_19 B210 LD C,A C = A
B211 LD A,B A = B - 9
B212 SUB $09
B214 JR NC,move_hero_car_20
B216 XOR A A = 0
move_hero_car_20 B217 LD B,A B = A
B218 JR move_hero_car_25
move_hero_car_21 B21A LD A,B A = B + 4
B21B ADD A,$04
B21D LD B,$24 Jump if A >= 36
B21F CP B
B220 JR NC,move_hero_car_22
B222 LD B,A B = A
move_hero_car_22 B223 LD A,C C -= B
B224 SUB B
B225 LD C,A
B226 JR NC,move_hero_car_25
B228 LD C,$00 C = 0
B22A JR move_hero_car_25
move_hero_car_23 B22C LD A,C A = C + 4
B22D ADD A,$04
B22F LD C,$24 C = $24
B231 CP C
B232 JR NC,move_hero_car_24
B234 LD C,A C = A
move_hero_car_24 B235 LD A,B B -= C
B236 SUB C
B237 LD B,A
B238 JR NC,move_hero_car_25
B23A LD B,$00 B = 0
move_hero_car_25 B23C LD HL,($A24A) HL = speed
B23F LD A,L A = L
B240 RR H
B242 RRA
B243 SRL A A >>= 1
B245 SRL A A >>= 1
B247 LD L,A L = A
B248 SRL L L >>= 1
B24A ADD A,L A += L
B24B CP B
B24C JR NC,move_hero_car_26
B24E LD B,A B = A
move_hero_car_26 B24F CP C
B250 JR NC,move_hero_car_27
B252 LD C,A C = A
move_hero_car_27 B253 PUSH BC
B254 LD BC,$0000 BC = $0000
B257 LD E,B E = B
B258 LD A,($A25C) A = horizon_scroll (e.g. $FA..$06 in multiples of two)
B25B OR A Set flags
B25C JP Z,move_hero_car_32 Jump if zero
B25F JP P,move_hero_car_28 Jump if positive
Negative scroll => scroll horizon right.
B262 INC E E++
B263 NEG A = -A
Positive scroll => scroll horizon left.
move_hero_car_28 B265 LD HL,$B827 HL -> 32-byte table at table_b828
B268 LD C,A C = A -- B is zero at this point
B269 ADD HL,BC HL += BC
B26A LD A,($A261) A = var_a261
B26D LD C,A C = A
B26E EX AF,AF'
B26F LD A,($A23F) A = fast_counter - C
B272 SUB C
B273 AND A Set flags
B274 JR Z,move_hero_car_32 Jump if zero
B276 LD C,(HL) C = *HL
move_hero_car_29 B277 SUB C A -= C
B278 JR C,move_hero_car_30 Jump if carry
B27A INC B B++
B27B EX AF,AF'
B27C ADD A,C A += C
B27D EX AF,AF'
B27E JR move_hero_car_29 Jump
move_hero_car_30 B280 LD A,B A = B
B281 AND A Set flags
B282 JR Z,move_hero_car_31
B284 LD HL,$A262 HL = var_a262
B287 ADD A,(HL) A += *HL
B288 LD (HL),A *HL = A
B289 LD A,B A = B * 3
B28A ADD A,A
B28B ADD A,B
B28C LD B,$00 B = 0
B28E RR E
B290 JR NC,move_hero_car_31
B292 DEC B B--
B293 NEG A = -A
move_hero_car_31 B295 LD C,A C = A
B296 EX AF,AF'
B297 LD ($A261),A var_a261 = A
No scroll required?
move_hero_car_32 B29A LD HL,($A25F) HL = var_a25f + BC
B29D ADD HL,BC
B29E LD DE,$0000 DE = $0000
B2A1 LD ($A25F),DE var_a25f = DE
B2A5 LD A,($B326) A = *$B326 -- Read self modified op in main_loop_24 -- crashed flag
B2A8 AND A Set flags
B2A9 JR Z,move_hero_car_33
B2AB EX DE,HL
B2AC LD D,H D = H
move_hero_car_33 B2AD POP BC
B2AE LD A,B var_a263 = B
B2AF LD ($A263),A
B2B2 LD A,C var_a264 = C
B2B3 LD ($A264),A
B2B6 SUB B A -= B
B2B7 JP P,move_hero_car_34
B2BA DEC D D--
move_hero_car_34 B2BB LD E,A E = A
B2BC SRA E
B2BE ADD HL,DE HL += DE
B2BF OR A Set flags
B2C0 JR Z,move_hero_car_38 Jump if zero
B2C2 JP P,move_hero_car_35 Jump if positive
B2C5 NEG A = -A
move_hero_car_35 B2C7 CP $11 Compare
B2C9 LD A,$00 A = 0 -- not self modified
B2CB JR C,move_hero_car_38 Jump if A < 17
B2CD BIT 7,H Jump if H bit 7 clear
B2CF JR Z,move_hero_car_36
B2D1 BIT 7,D Jump if D bit 7 set
B2D3 JR NZ,move_hero_car_38
B2D5 BIT 7,H Jump if H bit 7 clear -- bug? already tested above
B2D7 JR Z,move_hero_car_38
B2D9 JR move_hero_car_37 Jump
move_hero_car_36 B2DB BIT 7,D Jump if D bit 7 clear
B2DD JR Z,move_hero_car_38
B2DF BIT 7,H Jump if H bit 7 set
B2E1 JR NZ,move_hero_car_38
move_hero_car_37 B2E3 LD A,$01 A = 1
move_hero_car_38 B2E5 LD ($A24D),A cornering = A
B2E8 LD BC,($A26C) BC = road_pos
B2EC ADD HL,BC HL += BC
B2ED LD ($A26C),HL road_pos = HL
B2F0 LD D,$01 D = 1
B2F2 LD A,E A = E
B2F3 OR A Set flags [why are some ORs and some ANDs?]
B2F4 JP P,move_hero_car_39 Jump if positive
B2F7 DEC D D--
B2F8 NEG A = -A
move_hero_car_39 B2FA CP $0C CP 12
B2FC LD B,$02 B = 2
B2FE JR NC,move_hero_car_40
B300 DEC B B--
B301 CP $06 CP 6
B303 JR NC,move_hero_car_40
B305 DEC B B--
move_hero_car_40 B306 LD A,B A = B
B307 LD ($A250),A turn_speed = A
B30A LD A,D A = D
B30B LD ($A251),A flip = A
B30E LD A,($B064) A = *$B064 -- Jump counter [self modified]
B311 AND A Set flags
B312 RET Z Return if zero
B313 XOR A cornering = 0
B314 LD ($A24D),A
B317 RET Return
Prev: B045 Up: Map Next: B318