Prev: 9EE6 Up: Map Next: 9F13
9F03: Move a display file address up one pixel row
The counterpart to PIXEL_TO_SCREEN's arithmetic, done as cheaply as possible because BLIT_SPRITE calls it once per row of every sprite on the screen. Within a character cell the row is the low three bits of H, so most calls are a DEC H and a test; only one in eight has to step back a whole character row, and only one in sixty-four crosses between the display's thirds.
Input
HL A display file address; on exit, the same column one pixel higher
SCREEN_ROW_UP 9F03 DEC H The common case, and usually the only instruction that runs.
9F04 LD A,H Did that take us out of the top of the character cell? If not, done.
9F05 CPL
9F06 AND $07
9F08 RET NZ
9F09 LD A,L It did: back one character row. A borrow here means we also crossed into the third above, where H is already right.
9F0A SUB $20
9F0C LD L,A
9F0D RET C
9F0E LD A,H No borrow, so undo the DEC H's effect on the cell row.
9F0F ADD A,$08
9F11 LD H,A
9F12 RET
Prev: 9EE6 Up: Map Next: 9F13