Prev: CE7B Up: Map Next: CEAB
CE85: Update Screen
Used by the routines at RunGame, GameOver and DisplayTextList.
Copies the screen buffer to the screen. The buffer holds the lines of the screen from the bottom up, 20 bytes to a line, so the lines are copied from the bottom of the screen to the top.
Before After UpdateScreen
update-screen-before update-screen-after
Copy from ScreenBuffer to the last line of the bitmap.
UpdateScreen CE85 LD HL,$D200 Point HL at ScreenBuffer.
CE88 LD DE,$57E0 Point DE at 57E0 (in the screen buffer).
CE8B LD BC,$C020 Set BC to C020.
UpdateScreen_Line CE8E PUSH BC Stash BC and DE on the stack.
CE8F PUSH DE
CE90 LD B,$00 Set B to 00.
CE92 LDIR Copy C bytes from HL to DE.
CE94 POP DE Restore DE from the stack.
CE95 DEC D Decrement D.
CE96 LD A,D Fetch D and invert it.
CE97 CPL
CE98 AND %00000111 Keep bits 0 to 2.
CE9A JR NZ,UpdateScreen_Next Jump to UpdateScreen_Next if it is not zero.
CE9C LD A,E Subtract 20 from E.
CE9D SUB $20
CE9F LD E,A
CEA0 JR C,UpdateScreen_Next Jump to UpdateScreen_Next if carry is set.
CEA2 LD A,D Add 08 to D.
CEA3 ADD A,$08
CEA5 LD D,A
UpdateScreen_Next CEA6 POP BC Restore BC from the stack.
CEA7 DEC B Decrement B.
CEA8 JR NZ,UpdateScreen_Line Jump to UpdateScreen_Line until B is zero.
CEAA RET Return.
View the equivalent code in;
Prev: CE7B Up: Map Next: CEAB