![]() |
Routines |
| Prev: 6D12 | Up: Map | Next: 6DEF |
|
Used by the routines at HandlerCanAccelerate and UpdatePlayerCar.
Stores the new speed, draws the speed gauge and moves the car. The direction is split into the quadrant (the top two bits, held in 5E11) and the position in that quadrant (the top five bits of Player_Direction). The table at MovementTable is then used to share out the speed between the Y and X directions; the X part uses the table from the other end.
|
||||||||
| HandlerAccelerate | 6D73 | LD ($5E0D),A | Write the new speed to Speed. | |||||
|
This entry point is used by the routines at HandlerCanAccelerate and UpdatePlayerCar.
Draw the speed gauge.
|
||||||||
| HandlerAccelerate_Gauge | 6D76 | LD A,($5E0D) | Fetch the speed of the car (Speed). | |||||
| 6D79 | LD HL,$49E2 | Set the screen location of the speed gauge, 49E2. | ||||||
| 6D7C | CALL DrawGaugeLine | Draw the speed gauge using DrawGaugeLine. | ||||||
|
Work out the direction.
|
||||||||
| 6D7F | LD A,($5E11) | Fetch the quadrant of the direction (5E11). | ||||||
| 6D82 | INC A | Add one to the quadrant. | ||||||
| 6D83 | LD C,A | Keep the quadrant in C. | ||||||
| 6D84 | LD A,($5E10) | Fetch the direction (Player_Direction). | ||||||
| 6D87 | RRA | Shift A right three times. | ||||||
| 6D88 | RRA | |||||||
| 6D89 | RRA | |||||||
| 6D8A | AND %00011111 | Keep bits 0-4. | ||||||
| 6D8C | BIT 0,C | Jump to HandlerAccelerate_TableIndex if bit 0 of C is set. | ||||||
| 6D8E | JR NZ,HandlerAccelerate_TableIndex | |||||||
| 6D90 | XOR %00011111 | Reverse bits 0-4 (the position in the quadrant is measured the other way round). | ||||||
| HandlerAccelerate_TableIndex | 6D92 | LD E,A | Use the position in the quadrant as the index into the table. | |||||
| 6D93 | LD D,$00 | Clear the high byte of the index. | ||||||
| 6D95 | PUSH DE | Stash the index on the stack. | ||||||
| 6D96 | LD HL,$7F6B | Point HL at the table which shares out the speed (MovementTable). | ||||||
| 6D99 | ADD HL,DE | Add the index to the start of the table. | ||||||
| 6D9A | LD A,($5E0D) | Fetch the speed of the car (Speed) and keep it in E. | ||||||
| 6D9D | LD E,A | |||||||
| 6D9E | LD D,$00 | Clear the high byte of the speed. | ||||||
| 6DA0 | PUSH DE | Stash DE (the speed) on the stack. | ||||||
| 6DA1 | LD A,(HL) | Fetch the share of the speed from the table. | ||||||
| 6DA2 | CALL MultiplyAByDE | Call MultiplyAByDE to multiply A by the speed. | ||||||
|
Move the car in the Y direction.
|
||||||||
| 6DA5 | LD A,($5E09) | Fetch the top byte of the Y position of the car (PlayerMapPositionY_Fraction + 02). | ||||||
| 6DA8 | LD DE,($5E07) | DE=PlayerMapPositionY_Fraction. | ||||||
| 6DAC | CALL DivideByThirtyTwo | Call DivideByThirtyTwo to divide the result by 20. | ||||||
| 6DAF | BIT 1,C | Jump to SubtractY if the car is moving to a lower Y position. | ||||||
| 6DB1 | JR NZ,SubtractY | |||||||
| 6DB3 | ADD HL,DE | Add the result to the Y position. | ||||||
| 6DB4 | ADC A,$00 | Carry any overflow into the top byte. | ||||||
| 6DB6 | CP $0C | Jump to BounceY if the Y position reached the edge of the map (0C). | ||||||
| 6DB8 | JR NC,BounceY | |||||||
|
This entry point is used by the routine at SubtractY.
|
||||||||
| HandlerAccelerate_StoreY | 6DBA | LD ($5E09),A | Write the top byte of the Y position. | |||||
| 6DBD | LD ($5E07),HL | Write the rest of the Y position. | ||||||
|
This entry point is used by the routine at BounceY.
Move the car in the X direction.
|
||||||||
| HandlerAccelerate_MoveX | 6DC0 | POP HL | Restore the speed from the stack. | |||||
| 6DC1 | POP DE | Restore the offset from the stack. | ||||||
| 6DC2 | PUSH HL | Stash the speed on the stack. | ||||||
| 6DC3 | LD HL,$7F8A | Point HL at the end of the table which shares out the speed (MovementTable_Last). | ||||||
| 6DC6 | AND A | Clear the carry flag. | ||||||
| 6DC7 | SBC HL,DE | HL=MovementTable_Last - offset (this reads the table from the other end). | ||||||
| 6DC9 | LD A,(HL) | Fetch the share of the speed from the table. | ||||||
| 6DCA | POP DE | Restore the speed from the stack. | ||||||
| 6DCB | CALL MultiplyAByDE | Call MultiplyAByDE to multiply A by the speed. | ||||||
| 6DCE | LD A,($5E06) | Fetch the top byte of the X position of the car (PlayerMapPosition_Fraction + 02). | ||||||
| 6DD1 | LD DE,($5E04) | DE=PlayerMapPosition_Fraction. | ||||||
| 6DD5 | CALL DivideByThirtyTwo | Call DivideByThirtyTwo to divide the result by 20. | ||||||
| 6DD8 | DEC C | Decrease C by one. | ||||||
| 6DD9 | BIT 1,C | Jump to SubtractX if the car is moving to a lower X position. | ||||||
| 6DDB | JR NZ,SubtractX | |||||||
| 6DDD | ADD HL,DE | Add the result to the X position. | ||||||
| 6DDE | ADC A,$00 | Carry any overflow into the top byte. | ||||||
| 6DE0 | CP $18 | Jump to BounceX if the X position reached the edge of the map (18). | ||||||
| 6DE2 | JR NC,BounceX | |||||||
|
This entry point is used by the routine at SubtractX.
|
||||||||
| HandlerAccelerate_StoreX | 6DE4 | LD ($5E04),HL | Write the rest of the X position. | |||||
| 6DE7 | LD ($5E06),A | Write the top byte of the X position. | ||||||
|
This entry point is used by the routine at BounceX.
|
||||||||
| HandlerAccelerate_UpdateObject | 6DEA | CALL UpdateCurrentObject | Call UpdateCurrentObject. | |||||
| 6DED | JR HandlerSteering | Jump to HandlerSteering. | ||||||
| Prev: 6D12 | Up: Map | Next: 6DEF |