Skip to navigation

Screen buffer: ConfigureObjBuffer

Name: ConfigureObjBuffer [Show more] Type: Subroutine Category: Screen buffer Summary: Set up the variables required to configure the screen buffer for updating an object
Context: 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
.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 subroutine