.ConfigureObjBuffer STA T \ Set T to the number of character columns we need to \ configure to contain the object we are drawing LSR A \ This converts the number of character columns into \ a yaw angle by dividing by 2 \ \ The custom screen mode 5 used by the game is 40 \ character columns wide, and the screen is 20 yaw \ angles wide in terms of the game's coordinate system \ \ So we can simply double the character column count in \ A to convert it into a yaw angle STA bufferMinYawHi \ Set bufferMinYaw(Hi Lo) = A LDA #0 \ = T / 2 ROR A \ STA bufferMinYawLo \ So this stores the character column count as a yaw \ angle in bufferMinYaw(Hi Lo), where the low byte is \ effectively a fractional part \ \ This gives us the yaw angle of the left edge of the \ screen buffer LDA bufferMinYawHi \ Set bufferMaxYawHi = bufferMinYawHi / 2 LSR A \ EOR #%10000000 \ and with bit 7 flipped STA bufferMaxYawHi LDA T \ Set xBufferWidth = T * 4 ASL A \ ASL A \ This gives us the width of the buffer in pixels STA xBufferWidth LSR A \ Set xBufferRight = 128 + T * 2 AND #%11111100 \ ORA #%10000000 \ rounded down to a multiple of 4 STA xBufferRight SEC \ Set xBufferLeft = xBufferRight - xBufferWidth SBC xBufferWidth STA xBufferLeft LSR A \ Set bufferOrigin(Hi Lo) = xBufferLeft / 8 LSR A \ LSR A \ starting with the high byte STA bufferOriginHi LDA #0 \ And then the low byte ROR A STA bufferOriginLo LDA #2 \ Configure the screen buffer as a column buffer STA screenBufferType .buff1 RTS \ Return from the subroutineName: ConfigureObjBuffer [Show more] Type: Subroutine Category: Screen buffer Summary: Set up the variables required to configure the screen buffer for updating an objectContext: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawUpdatedObject calls ConfigureObjBuffer * DrawTileAndObjects calls via buff1
Arguments: A The number of the character columns to configure
Other entry points: buff1 Contains an RTS
[X]
Variable bufferMaxYawHi in workspace Zero page
The maximum allowed yaw angle for points in the current screen buffer (high byte)
[X]
Variable bufferMinYawHi in workspace Zero page
The minimum allowed yaw angle for points in the current screen buffer (high byte)
[X]
Variable bufferMinYawLo in workspace Zero page
The minimum allowed yaw angle for points in the current screen buffer (low byte)
[X]
Variable bufferOriginHi in workspace Zero page
The offset to add to yaw angles for the current screen buffer to convert them from having the origin in the buffer centre to having the origin on the left edge of the buffer (high byte)
[X]
Variable bufferOriginLo in workspace Zero page
The offset to add to yaw angles for the current screen buffer to convert them from having the origin in the buffer centre to having the origin on the left edge of the buffer (low byte)
[X]
Variable screenBufferType in workspace Zero page
The type of screen buffer that is currently being used
[X]
Variable xBufferLeft in workspace Zero page
The left edge of the screen buffer in pixels
[X]
Variable xBufferRight in workspace Zero page
The right edge of the screen buffer in pixels
[X]
Variable xBufferWidth in workspace Zero page
The width in pixels of the screen buffer