Prev: E0FB Up: Map Next: E1AD
E148: Copy the play area's pixels from the buffer to the screen
Used by the routine at SHOW_PLAY_AREA.
The buffer's row 0 is the bottom line of the play area, since the game's y counts upwards, so the copy starts there, at line 127 of the screen, and works up to line 16. It uses the stack: SP is pointed just past the end of a screen line, each PUSH puts two buffer bytes onto it, and eleven of them fill the 22 columns 7 to 28, while HL reads the buffer backwards. Only bytes 2 to 23 of each 24-byte buffer row are copied: the first two are a margin that sprites at the left edge are drawn into unseen (DRAW_SPRITE). Interrupts are off throughout the game, so nothing else uses the stack meanwhile. Checked in the simulator: buffer row 0 goes to line 127, row 111 to line 16, and byte 2 of a row to column 7.
COPY_BUFFER E148 LD (SAVED_SP),SP Keep SP; point it just past column 28 of line 127, the play area's bottom line
E14C LD SP,$4FFD
E14F LD B,$70 112 lines, from the last byte of the buffer's row 0
E151 LD HL,$E5DB
COPY_BUFFER_0 E154 LD D,(HL) Push the row's last 22 bytes onto the line, right to left
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)
E187 DEC HL
E188 LD E,(HL)
E189 PUSH DE
E18A EX DE,HL HL = SP less 234: the same columns a pixel line up, as far as moving within a character cell goes
E18B LD HL,$FF16
E18E ADD HL,SP
E18F LD A,H That is right unless the low bits of H became 7: the line was the top of a character cell
E190 CPL
E191 AND $07
E193 JP NZ,COPY_BUFFER_1
E196 LD A,L Then a character row up: L less 32, and H back up by 8 unless that crossed into the third above
E197 SUB $20
E199 LD L,A
E19A JP C,COPY_BUFFER_1
E19D LD A,H
E19E ADD A,$08
E1A0 LD H,A
COPY_BUFFER_1 E1A1 LD SP,HL Point SP there; HL = the end of the next buffer row (45 on from byte 2 of this one)
E1A2 LD HL,$002D
E1A5 ADD HL,DE
E1A6 DJNZ COPY_BUFFER_0
E1A8 LD SP,(SAVED_SP) Restore SP
E1AC RET
Prev: E0FB Up: Map Next: E1AD