Skip to navigation

Screen buffer: ShowBufferRow

Name: ShowBufferRow [Show more] Type: Subroutine Category: Screen buffer Summary: Update the player's scrolling landscape view by copying an 8-pixel high character row from the screen buffer into screen memory
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ShowIconBuffer calls ShowBufferRow * ShowScreenBuffer calls ShowBufferRow * ShowBufferColumn calls via drow3

Arguments: fromAddr(1 0) The source address from which we copy the character row toAddr(1 0) The destination address to which we copy the character row
Other entry points: drow3 Contains an RTS
.ShowBufferRow LDX #40 \ Each character row in screen mode 5 contains 40 \ character blocks of eight bytes, so set a block \ counter in X to count the character blocks .drow1 JSR ShowBufferBlock \ Copy an eight-byte 8x2-pixel character block from the \ screen buffer at fromAddr(1 0) into screen memory at \ toAddr(1 0) LDA fromAddr \ Set fromAddr(1 0) = fromAddr(1 0) + 8 CLC \ ADC #8 \ So this moves the from address to the next character STA fromAddr \ block in the character row LDA fromAddr+1 ADC #0 STA fromAddr+1 LDA toAddr \ Set (A toAddr) = toAddr(1 0) + 8 CLC ADC #8 STA toAddr LDA toAddr+1 ADC #0 CMP #&80 \ If the high byte in A >= &80 then the new address is BCC drow2 \ past the end of screen memory, so subtract &20 from SBC #&20 \ the high byte so the address wraps around within the \ range of screen memory between &6000 and &8000 .drow2 STA toAddr+1 \ Store the high byte of the result, so we now have: \ \ toAddr(1 0) = toAddr(1 0) + 8 \ \ with the address wrapped around as required DEX \ Decrement the counter in X to move on to the next \ character block in the row BNE drow1 \ Loop back until we have copied all 40 character blocks \ in the character row from fromAddr(1 0) to toAddr(1 0) .drow3 RTS \ Return from the subroutine