Prev: 80FF Up: Map Next: 812F
8100: Copy the render buffer to the screen
Used by the routine at DRAW_VIEW.
Rows 12-127 of the render buffer go to screen lines 12-127, bytes 1-30 of each: the rows above and below and the columns either side are margins for blocks and sprites to overhang into. Checked by filling the buffer's rows with their own numbers and running this.
COPY_TO_SCREEN 8100 LD HL,$A180 From row 12 of the buffer to line 12 of the screen, column 1, in two passes (the top two thirds of the screen).
8103 LD DE,$4421
8106 LD B,$00
8108 LD A,$02
COPY_TO_SCREEN_0 810A PUSH AF Save the pass count; start the first row.
810B JR COPY_TO_SCREEN_2
COPY_TO_SCREEN_1 810D LD C,$E2 The next screen line: 256 bytes on from the start of the last, less the 30 just copied.
810F EX DE,HL
8110 ADD HL,BC
8111 EX DE,HL
COPY_TO_SCREEN_2 8112 LD C,$1E Skip the buffer's margin column, copy 30 bytes...
8114 INC HL
8115 LDIR
8117 INC HL ...and skip the other margin column.
8118 LD A,L Until the buffer crosses into its next 256 bytes: eight rows, the first time four.
8119 AND $E0
811B JR NZ,COPY_TO_SCREEN_1
811D INC DE The next character row of the screen; every 64 rows of the buffer, the end of a pass.
811E INC DE
811F LD A,H
8120 AND $07
8122 JR Z,COPY_TO_SCREEN_3
8124 LD A,D
8125 ADD A,$F9
8127 LD D,A
8128 JR COPY_TO_SCREEN_2
COPY_TO_SCREEN_3 812A POP AF Next pass.
812B DEC A
812C JR NZ,COPY_TO_SCREEN_0
812E RET
Prev: 80FF Up: Map Next: 812F