Prev: E0FB Up: Map Next: E1AD
E148: Copy Pixels To Screen
Used by the routine at CopyBuffersToScreen.
Copies the pixels of the screen buffer onto the screen, using the stack to copy two bytes at a time.
Keep the stack pointer, and point it at the playfield on the screen.
CopyPixelsToScreen E148 LD ($BBAE),SP Save the stack pointer.
E14C LD SP,$4FFD Point the stack pointer at the end of the last row of the playing area on the screen.
E14F LD B,$70 Set a count of 70 rows.
E151 LD HL,$E5DB Point HL at the end of the first row of the buffer.
Copy a row from the buffer to the screen.
CopyPixelsToScreen_Row E154 LD D,(HL) Copy the last twenty bytes of the row from the buffer onto the screen, two at a time.
E155 DEC HL
E156 LD E,(HL)
E157 DEC HL
E158 PUSH DE
E159 LD D,(HL)
E15A DEC HL
E15B LD E,(HL)
E15C DEC HL
E15D PUSH DE
E15E LD D,(HL)
E15F DEC HL
E160 LD E,(HL)
E161 DEC HL
E162 PUSH DE
E163 LD D,(HL)
E164 DEC HL
E165 LD E,(HL)
E166 DEC HL
E167 PUSH DE
E168 LD D,(HL)
E169 DEC HL
E16A LD E,(HL)
E16B DEC HL
E16C PUSH DE
E16D LD D,(HL)
E16E DEC HL
E16F LD E,(HL)
E170 DEC HL
E171 PUSH DE
E172 LD D,(HL)
E173 DEC HL
E174 LD E,(HL)
E175 DEC HL
E176 PUSH DE
E177 LD D,(HL)
E178 DEC HL
E179 LD E,(HL)
E17A DEC HL
E17B PUSH DE
E17C LD D,(HL)
E17D DEC HL
E17E LD E,(HL)
E17F DEC HL
E180 PUSH DE
E181 LD D,(HL)
E182 DEC HL
E183 LD E,(HL)
E184 DEC HL
E185 PUSH DE
E186 LD D,(HL) Copy the first two bytes of the row onto the screen.
E187 DEC HL
E188 LD E,(HL)
E189 PUSH DE
E18A EX DE,HL Keep the address in the buffer in DE.
Move up one pixel line on the screen.
E18B LD HL,$FF16 Work out the address on the screen of the end of the row above, which is one pixel row up.
E18E ADD HL,SP
Jump to CopyPixelsToScreen_Next unless that is the last pixel row of a character row.
E18F LD A,H Test whether it has crossed into the previous character row.
E190 CPL
E191 AND %00000111 Keep the bits for the pixel line.
E193 JP NZ,CopyPixelsToScreen_Next Jump to CopyPixelsToScreen_Next if it has not.
Move to the previous character row.
E196 LD A,L Subtract 20 from the low byte.
E197 SUB $20
E199 LD L,A
E19A JP C,CopyPixelsToScreen_Next Jump to CopyPixelsToScreen_Next if that is in the previous third.
E19D LD A,H Move up to the last pixel row of the character row.
E19E ADD A,$08
E1A0 LD H,A
Point at the next row.
CopyPixelsToScreen_Next E1A1 LD SP,HL Point the stack pointer at the row on the screen.
E1A2 LD HL,$002D Move on to the end of the next row of the buffer.
E1A5 ADD HL,DE
E1A6 DJNZ CopyPixelsToScreen_Row Loop back until all of the rows have been copied.
Restore the stack pointer.
E1A8 LD SP,($BBAE) Get the stack pointer back.
E1AC RET Return.
View the equivalent code in;
The buffer holds 112 rows of 24 bytes, and the top row of the buffer is the bottom row of the playing area, so the rows of the buffer are copied from the bottom of the screen upwards. Only the 22 bytes of each row that are inside the border are copied, which are bytes 2 to 23 of the row.
Prev: E0FB Up: Map Next: E1AD