Skip to navigation

Screen buffer: ShowScreenBuffer

Name: ShowScreenBuffer [Show more] Type: Subroutine Category: Screen buffer Summary: Update the player's scrolling landscape view by copying the relevant parts of the screen buffer into screen memory
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawUpdatedObject calls ShowScreenBuffer

Arguments: Y The direction of scrolling that we just applied: * 0 = pan right * 1 = pan left * 2 = pan up * 3 = pan down toAddr(1 0) The address of the area in screen memory that we need to update with the contents of the screen buffer
.ShowScreenBuffer \ We start by setting both screenBufferAddr(1 0) and \ fromAddr(1 0) to the address in the screen buffer of \ the content that we need to copy into the screen area \ following the hardware scroll \ \ We do this by taking the current value of the address \ in screenBufferAddr(1 0) and applying the change in \ scrollScreen(Hi Lo) for the current pan direction in \ Y, just as we did when we updated the screen address \ in viewScreenAddr(1 0) in the ScrollPlayerView routine LDA screenBufferAddr \ Add scrollScreen(Hi Lo) for this pan direction to the CLC \ address in screenBufferAddr(1 0), starting with the ADC scrollScreenLo,Y \ low bytes STA screenBufferAddr STA fromAddr \ Store the low byte of the result in fromAddr(1 0) LDA screenBufferAddr+1 \ And then add the high bytes ADC scrollScreenHi,Y STA screenBufferAddr+1 STA fromAddr+1 \ Store the high byte of the result in fromAddr(1 0), so \ fromAddr(1 0) = screenBufferAddr(1 0) and we copy the \ new screen content from the correct address in the \ screen buffer CPY #2 \ If Y >= 2 then we are panning up or down, and we are BCS ShowBufferRow \ scrolling down or up, so jump to ShowBufferRow to \ update the player's scrolling landscape view by \ copying an eight-pixel high character row from the \ screen buffer into screen memory \ Otherwise we are panning left or right, and we are \ scrolling right or left, so fall through into \ ShowBufferColumn to update the player's scrolling \ landscape view by copying a two-pixel wide column from \ the screen buffer into screen memory