![]() |
Routines |
| Prev: B178 | Up: Map | Next: B278 |
|
Used by the routine at OBJECT_DONE.
Called at the end of every turn (OBJECT_DONE). The list at DRAW_LIST holds every record flagged to be drawn this turn (LIST_DRAWN). First, for each one that moved -- bit 5 of its flags -- the area covering both where it was drawn last turn (+1C to +1F) and where it is now (+18 to +1B) is cleared in the buffer and remembered on the stack. Then every listed object is drawn into the buffer in depth order (SORT_AND_DRAW), and the carried things on the panel if they changed (SHOW_CARRIED); and last the remembered areas -- and only those -- are copied to the screen.
Nothing is ever rubbed out on the screen itself, so nothing flickers; the scenery is made of objects too, so what stood behind a moving thing is simply drawn again. On the first turn in a room nothing is wiped at all: the buffer is freshly built and OBJECT_DONE copies all of it. The areas count towards the turn's drawing work (DRAW_WORK, CONTROL), which sets how long the main loop waits.
|
||||
| RENDER_DYNAMIC_OBJECTS | B19E | XOR A | No areas yet | |
| B19F | LD (WIPE_COUNT),A | |||
| B1A2 | PUSH IX | Kept for the caller | ||
| B1A4 | LD A,(NEW_ROOM) | The first turn in a room: nothing to wipe | ||
| B1A7 | AND A | |||
| B1A8 | JP NZ,RENDER_DYNAMIC_OBJECTS_8 | |||
| B1AB | LD HL,DRAW_LIST | From the start of the list | ||
| B1AE | LD (LIST_POINTER),HL | |||
| RENDER_DYNAMIC_OBJECTS_0 | B1B1 | LD HL,(LIST_POINTER) | The next record's number; $FF ends the list | |
| B1B4 | LD A,(HL) | |||
| B1B5 | INC HL | |||
| B1B6 | LD (LIST_POINTER),HL | |||
| B1B9 | CP $FF | |||
| B1BB | JP Z,RENDER_DYNAMIC_OBJECTS_8 | |||
| B1BE | CALL RECORD_OF | IX = the record | ||
| B1C1 | PUSH HL | |||
| B1C2 | POP IX | |||
| B1C4 | BIT 5,(IX+$07) | Bit 5 of the flags: it moved; the others in the list are only being drawn again | ||
| B1C8 | JR Z,RENDER_DYNAMIC_OBJECTS_0 | |||
| B1CA | RES 5,(IX+$07) | Only once | ||
| B1CE | LD A,(IX+$1A) | C = the further left of the new pixel x (+1A) and the old (+1E) | ||
| B1D1 | SUB (IX+$1E) | |||
| B1D4 | JP C,RENDER_DYNAMIC_OBJECTS_6 | |||
| B1D7 | LD C,(IX+$1E) | |||
| RENDER_DYNAMIC_OBJECTS_1 | B1DA | LD A,(IX+$1E) | The old right edge in bytes: old x / 8 + old width (+1C) | |
| B1DD | RRCA | |||
| B1DE | RRCA | |||
| B1DF | RRCA | |||
| B1E0 | AND $1F | |||
| B1E2 | ADD A,(IX+$1C) | |||
| B1E5 | LD E,A | |||
| B1E6 | LD A,(IX+$1A) | The new one: new x / 8 + new width (+18); E = the further right | ||
| B1E9 | RRCA | |||
| B1EA | RRCA | |||
| B1EB | RRCA | |||
| B1EC | AND $1F | |||
| B1EE | ADD A,(IX+$18) | |||
| B1F1 | CP E | |||
| B1F2 | JR C,RENDER_DYNAMIC_OBJECTS_2 | |||
| B1F4 | LD E,A | |||
| RENDER_DYNAMIC_OBJECTS_2 | B1F5 | LD A,C | H = the width in bytes, from the left edge's byte to the right edge | |
| B1F6 | RRCA | |||
| B1F7 | RRCA | |||
| B1F8 | RRCA | |||
| B1F9 | AND $1F | |||
| B1FB | LD B,A | |||
| B1FC | LD A,E | |||
| B1FD | SUB B | |||
| B1FE | LD H,A | |||
| B1FF | LD A,(IX+$1B) | B = the lower of the new pixel y (+1B) and the old (+1F) | ||
| B202 | SUB (IX+$1F) | |||
| B205 | JR C,RENDER_DYNAMIC_OBJECTS_7 | |||
| B207 | LD B,(IX+$1F) | |||
| RENDER_DYNAMIC_OBJECTS_3 | B20A | LD A,(IX+$1F) | The old top: old y + old height (+1D) | |
| B20D | ADD A,(IX+$1D) | |||
| B210 | LD E,A | |||
| B211 | LD A,(IX+$1B) | The new top: new y + new height (+19); A = the higher | ||
| B214 | ADD A,(IX+$19) | |||
| B217 | CP E | |||
| B218 | JR NC,RENDER_DYNAMIC_OBJECTS_4 | |||
| B21A | LD A,E | |||
| RENDER_DYNAMIC_OBJECTS_4 | B21B | SUB B | L = the height in rows | |
| B21C | LD L,A | |||
| B21D | LD A,B | An area that starts above the top of the screen has nothing to wipe | ||
| B21E | CP $C0 | |||
| B220 | JR NC,RENDER_DYNAMIC_OBJECTS_0 | |||
| B222 | ADD A,L | If it runs past line 192, keep only the part below | ||
| B223 | SUB $C0 | |||
| B225 | JR C,RENDER_DYNAMIC_OBJECTS_5 | |||
| B227 | NEG | |||
| B229 | ADD A,L | |||
| B22A | LD L,A | |||
| RENDER_DYNAMIC_OBJECTS_5 | B22B | CALL CALC_VRAM_ADDR | DE = its display address, BC = its buffer address | |
| B22E | CALL CALC_VIDBUF_ADDR | |||
| B231 | LD A,L | Rearranged: HL = the buffer address, B = the width, C = the height | ||
| B232 | LD L,C | |||
| B233 | LD C,A | |||
| B234 | LD A,H | |||
| B235 | LD H,B | |||
| B236 | LD B,A | |||
| B237 | LD A,(WIPE_COUNT) | One more area | ||
| B23A | INC A | |||
| B23B | LD (WIPE_COUNT),A | |||
| B23E | PUSH BC | On the stack until the objects have been drawn | ||
| B23F | PUSH DE | |||
| B240 | PUSH HL | |||
| B241 | XOR A | Cleared in the buffer: FILL_RECT fills B bytes by C rows with A | ||
| B242 | CALL FILL_RECT | |||
| B245 | JP RENDER_DYNAMIC_OBJECTS_0 | The next record | ||
| RENDER_DYNAMIC_OBJECTS_6 | B248 | LD C,(IX+$1A) | The new x is the further left | |
| B24B | JR RENDER_DYNAMIC_OBJECTS_1 | |||
| RENDER_DYNAMIC_OBJECTS_7 | B24D | LD B,(IX+$1B) | The new y is the lower | |
| B250 | JR RENDER_DYNAMIC_OBJECTS_3 | |||
| RENDER_DYNAMIC_OBJECTS_8 | B252 | CALL SORT_AND_DRAW | Every listed object into the buffer, in depth order | |
| B255 | CALL SHOW_CARRIED | The carried things on the panel, if they changed | ||
| B258 | LD HL,WIPE_COUNT | The areas count towards the turn's drawing work | ||
| B25B | LD A,(DRAW_WORK) | |||
| B25E | ADD A,(HL) | |||
| B25F | LD (DRAW_WORK),A | |||
| RENDER_DYNAMIC_OBJECTS_9 | B262 | LD HL,WIPE_COUNT | None left to copy | |
| B265 | LD A,(HL) | |||
| B266 | AND A | |||
| B267 | JR Z,RENDER_DYNAMIC_OBJECTS_10 | |||
| B269 | DEC (HL) | Take one off the stack, with the width and height swapped into the order BLIT_TO_SCREEN takes them | ||
| B26A | POP HL | |||
| B26B | POP DE | |||
| B26C | POP BC | |||
| B26D | LD A,B | |||
| B26E | LD B,C | |||
| B26F | LD C,A | |||
| B270 | CALL BLIT_TO_SCREEN | Copy it to the screen | ||
| B273 | JR RENDER_DYNAMIC_OBJECTS_9 | The next | ||
| RENDER_DYNAMIC_OBJECTS_10 | B275 | POP IX | Done | |
| B277 | RET | |||
| Prev: B178 | Up: Map | Next: B278 |