.ApplyDeltas LDX #1 \ Set X = 1, to act as an axis counter for xPlayerSpeed \ and zPlayerSpeed \ \ The comments below are for when X = 1 LDY #2 \ Set Y = 2, to act as a variable counter in the \ following loop, iterating through values 0 and 2, as \ Y is decremented twice at the end of the loop \ \ The comments below are for when Y = 2 .delt1 LDA #0 \ Set V = 0, to use as the sign bit for (V A T) STA V LDA xPlayerSpeedHi,X \ Set (V A T) = zPlayerSpeed STA T LDA xPlayerSpeedTop,X BPL delt2 \ If A is positive, jump to delt2 to skip the following \ instruction DEC V \ Set V = &FF, so it contains the correct sign bit for \ (V A T) .delt2 ASL T \ Set (U A T) = (V A T) << 1 ROL A ROL V STA U LDA xPlayerCoordLo,Y \ Set zPlayerCoord = zPlayerCoord + (U A T) ADC T \ = zPlayerCoord + zPlayerSpeed * 2 STA xPlayerCoordLo,Y \ \ starting with the low bytes LDA xPlayerCoordHi,Y \ Then the high bytes ADC U STA xPlayerCoordHi,Y LDA xPlayerCoordTop,Y \ And then the top bytes ADC V STA xPlayerCoordTop,Y DEY \ Decrement Y twice so the next iteration adds to the DEY \ xPlayerCoord variable DEX \ Decrement X so the next iteration sets (V A T) to \ xPlayerSpeed BPL delt1 \ Loop back until we have updated both xPlayerCoord and \ zPlayerCoord LDA playerYawAngleLo \ Set playerYawAngle = playerYawAngle + spinYawAngle CLC \ ADC spinYawAngleHi \ starting with the low bytes STA playerYawAngleLo LDA playerYawAngleHi \ And then the high bytes ADC spinYawAngleTop STA playerYawAngleHi RTS \ Return from the subroutineName: ApplyDeltas [Show more] Type: Subroutine Category: Driving model Summary: Apply the deltas in the x-axis and z-axis to the player's coordinates Deep dive: The core driving modelContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplyDrivingModel calls ApplyDeltas
Calculate the following: xPlayerCoord = xPlayerCoord + xPlayerSpeed * 2 zPlayerCoord = zPlayerCoord + zPlayerSpeed * 2 playerYawAngle = playerYawAngle + spinYawAngle
[X]
Label delt1 is local to this routine
[X]
Label delt2 is local to this routine
[X]
Variable playerYawAngleHi in workspace Zero page
High byte of the player's yaw angle
[X]
Variable playerYawAngleLo in workspace Zero page
Low byte of the player's yaw angle
[X]
Variable spinYawAngleHi (category: Car geometry)
High byte of the amount of yaw angle spin that is being applied to the player's car
[X]
Variable spinYawAngleTop (category: Car geometry)
Top byte of the amount of yaw angle spin that is being applied to the player's car
[X]
Variable xPlayerCoordHi (category: Car geometry)
The high byte of the x-coordinate of the player's 3D coordinates
[X]
Variable xPlayerCoordLo (category: Car geometry)
The low byte of the x-coordinate of the player's 3D coordinates
[X]
Variable xPlayerCoordTop (category: Car geometry)
The top byte of the x-coordinate of the player's 3D coordinates
[X]
Variable xPlayerSpeedHi (category: Driving model)
High byte of the x-coordinate of the velocity vector (i.e. x-axis speed) for the player's car during this main loop iteration
[X]
Variable xPlayerSpeedTop (category: Driving model)
Top byte of the x-coordinate of the velocity vector (i.e. x-axis speed) for the player's car during this main loop iteration