| ← BB38 | Map | BBE2 → |
BBA4: Blit dirty cells to the display and age their counters
|
Copies every dirty playfield cell from the back buffer to the display file and ages its dirty counter.
|
|||
|
The sprite drawer stamps each covered cell's counter to 2. The blit shows the composed cell and ages the counter to 1. Behind it, the recompose pass then rebuilds the clean background. A frame later the blit copies that background back, so the sprite leaves no trail.
|
|||
| blit_dirty_cells | BBA4 | LD HL,WORKBUF_FB+$5F | Scan from one cell before the first playfield cell. The top three character rows are static and never redrawn. Rows 0 and 1 hold the score panel, and row 2 the top wall's upper half. |
| BBA7 | XOR A | ||
| find_dirty_cell | BBA8 | INC HL | Advance to the next dirty cell; A ORs the flags so clean (0) cells are skipped without a separate test. |
| BBA9 | OR (HL) | ||
| BBAA | JP Z,find_dirty_cell | ||
| BBAD | INC A | Counter $FF is the end-of-list terminator that each level's setup plants; stop here. | |
| BBAE | RET Z | ||
| BBAF | DEC (HL) | Age this cell's dirty counter by one frame. The sprite drawer re-stamps it every frame a sprite covers the cell, so it stays non-zero until one frame after the sprite leaves. | |
| BBB0 | PUSH HL | ||
| BBB1 | INC H | Find the cell on the screen and in the back buffer. The page of the list that holds the cell picks the screen third, one page per third. A stray cell past the end of the list gets no real third. Its copy then lands in the attribute file and reads from the tile map (see Scramble). | |
| BBB2 | LD A,H | ||
| BBB3 | AND $03 | ||
| BBB5 | RLCA | ||
| BBB6 | RLCA | ||
| BBB7 | RLCA | ||
| BBB8 | ADD A,$40 | ||
| BBBA | LD D,A | ||
| BBBB | ADD A,$A0 | ||
| BBBD | LD H,A | ||
| BBBE | LD E,L | ||
| BBBF | LD A,(HL) | Copy the cell's 8 pixel-row bytes from the back buffer to the display file. Consecutive rows of a char cell are $100 apart, so INC H/INC D walk both pointers down one row in lockstep. A real cell never touches the attribute file. The stray cell above writes tile codes there, so the attributes read them as colors. | |
| BBC0 | LD (DE),A | ||
| BBC1 | INC H | ||
| BBC2 | INC D | ||
| BBC3 | LD A,(HL) | ||
| BBC4 | LD (DE),A | ||
| BBC5 | INC H | ||
| BBC6 | INC D | ||
| BBC7 | LD A,(HL) | ||
| BBC8 | LD (DE),A | ||
| BBC9 | INC H | ||
| BBCA | INC D | ||
| BBCB | LD A,(HL) | ||
| BBCC | LD (DE),A | ||
| BBCD | INC H | ||
| BBCE | INC D | ||
| BBCF | LD A,(HL) | ||
| BBD0 | LD (DE),A | ||
| BBD1 | INC H | ||
| BBD2 | INC D | ||
| BBD3 | LD A,(HL) | ||
| BBD4 | LD (DE),A | ||
| BBD5 | INC H | ||
| BBD6 | INC D | ||
| BBD7 | LD A,(HL) | ||
| BBD8 | LD (DE),A | ||
| BBD9 | INC H | ||
| BBDA | INC D | ||
| BBDB | LD A,(HL) | ||
| BBDC | LD (DE),A | ||
| BBDD | POP HL | Restore the flag pointer, reset the accumulator, and continue the scan. | |
| BBDE | XOR A | ||
| BBDF | JP find_dirty_cell | ||
| ← BB38 | Map | BBE2 → |
