Prev: D03E Up: Map Next: D0B4
D04B: Copy Buffer To Screen
Used by the routine at CopyBufferAndClear.
Copies PlayfieldBuffer to the screen, from the bottom row up. Each row copies 16 bytes. In the town the copy sits beside the panel.
copy-buffer
Keep the stack pointer, and point it at the playfield on the screen.
CopyBufferToScreen D04B LD ($A21D),SP Set SavedStackPointer.
D04F LD HL,$4FDB Point HL at 4FDB (in the screen buffer).
Move it to the right in the town.
D052 CALL AddTownOffsetToHL Call AddTownOffsetToHL.
D055 LD SP,HL Point the stack pointer at it.
D056 LD B,$70 Set a count of 70 rows.
D058 LD HL,$D702 Point HL at PlayfieldBuffer_FirstRowEnd.
Copy a row from the buffer to the screen.
CopyBufferToScreen_Row D05B LD D,(HL) Copy eleven words of the row, working backwards.
D05C DEC HL
D05D LD E,(HL)
D05E DEC HL
D05F PUSH DE
D060 LD D,(HL)
D061 DEC HL
D062 LD E,(HL)
D063 DEC HL
D064 PUSH DE
D065 LD D,(HL)
D066 DEC HL
D067 LD E,(HL)
D068 DEC HL
D069 PUSH DE
D06A LD D,(HL)
D06B DEC HL
D06C LD E,(HL)
D06D DEC HL
D06E PUSH DE
D06F LD D,(HL)
D070 DEC HL
D071 LD E,(HL)
D072 DEC HL
D073 PUSH DE
D074 LD D,(HL)
D075 DEC HL
D076 LD E,(HL)
D077 DEC HL
D078 PUSH DE
D079 LD D,(HL)
D07A DEC HL
D07B LD E,(HL)
D07C DEC HL
D07D PUSH DE
D07E LD D,(HL)
D07F DEC HL
D080 LD E,(HL)
D081 DEC HL
D082 PUSH DE
D083 LD D,(HL)
D084 DEC HL
D085 LD E,(HL)
D086 DEC HL
D087 PUSH DE
D088 LD D,(HL)
D089 DEC HL
D08A LD E,(HL)
D08B DEC HL
D08C PUSH DE
D08D LD D,(HL)
D08E DEC HL
D08F LD E,(HL)
D090 PUSH DE
D091 EX DE,HL Keep the address in the buffer in DE.
Move up one pixel line on the screen.
D092 LD HL,$FF16 Find the screen address one pixel line up.
D095 ADD HL,SP
D096 LD A,H Test whether it has crossed into the previous character row.
D097 CPL
D098 AND %00000111 Keep the bits for the pixel line.
D09A JP NZ,CopyBufferToScreen_Next Jump to CopyBufferToScreen_Next if it has not.
Move to the previous character row.
D09D LD A,L Subtract 20 from the low byte.
D09E SUB $20
D0A0 LD L,A
D0A1 JP C,CopyBufferToScreen_Next Jump to CopyBufferToScreen_Next if that is in the previous third.
D0A4 LD A,H Add 08 to the high byte.
D0A5 ADD A,$08
D0A7 LD H,A
Point at the next row.
CopyBufferToScreen_Next D0A8 LD SP,HL Point the stack pointer at the new screen address.
D0A9 LD HL,$002D Find the end of the next row in the buffer.
D0AC ADD HL,DE
D0AD DJNZ CopyBufferToScreen_Row Jump to CopyBufferToScreen_Row.
Restore the stack pointer.
D0AF LD SP,($A21D) Fetch SavedStackPointer.
D0B3 RET Return.
View the equivalent code in;
Prev: D03E Up: Map Next: D0B4