Prev: B145 Up: Map Next: B19E
B178: Copy the screen buffer to the screen
Used by the routines at OBJECT_DONE, DISPLAY_MENU and WON.
All 192 rows of 32 bytes from BUFFER. The buffer runs the other way up from the display -- its first row is the bottom line of the screen -- because the game's pixel y counts up from the bottom; so the copy starts at the display's bottom-left byte and works up a line at a time. Used on the first turn in a room (OBJECT_DONE) and for the text screens (DISPLAY_MENU, WON). Knight Lore's copy clears the buffer as it goes; this one leaves it as it is.
SHOW_BUFFER B178 LD HL,BUFFER From the buffer's first row to the display's bottom line; 192 rows
B17B LD DE,$57E0
B17E LD C,$C0
SHOW_BUFFER_0 B180 PUSH BC A row of 32 bytes; HL runs on to the next row by itself
B181 PUSH DE
B182 LD BC,$0020
B185 LDIR
B187 POP DE Up a display line, unless that crossed a character row
B188 DEC D
B189 LD A,D
B18A CPL
B18B AND $07
B18D JR NZ,SHOW_BUFFER_1
B18F LD A,E Crossing a character row: back 32 in E, and back into this third unless that borrowed
B190 SUB $20
B192 LD E,A
B193 JR C,SHOW_BUFFER_1
B195 LD A,D
B196 ADD A,$08
B198 LD D,A
SHOW_BUFFER_1 B199 POP BC The next row
B19A DEC C
B19B JR NZ,SHOW_BUFFER_0
B19D RET
Prev: B145 Up: Map Next: B19E