![]() |
Routines |
| Prev: E5E8 | Up: Map | Next: E7B2 |
|
Used by the routine at FILL_NEXT_PIXEL.
The textured flood fill of room codes $E6-$FF (DO_ROOM_COMMAND), with the machine stack as its list of places still to fill. A place is x, y in C, B (y up from the bottom), and the list ends at a word whose high byte is $FE, pushed before the first. The fill's map is the 6 KB 32 KB above the screen, laid out like it: the pixels set there bound the fill (room code $E4 $00 clears it and sends the lines there, and $E2 copies the screen there), and the fill sets there every pixel it fills. For each place taken off the list: if it is off the top or the bottom of the screen, or already set in the map, it is dropped; otherwise the fill goes right to the last clear pixel of its run, and from there fills leftwards a pixel at a time (FILL_NEXT_PIXEL), writing the texture's pixels to the screen, setting them in the map, and pushing a place in the row above or below each time a clear run begins there.
This part sets up a run: the map addresses of its pixel and of the pixels above and below it (IY+$7B, IY+$7D, IY+$76), and the texture's two bytes for the row (B' the one for this byte, C' the other). A texture is 16 pixels by 16 rows, in four 8 by 8 cells: bytes 0-7 and 8-15 the left and right cells for the character rows in which y has bit 3 set, bytes 16-23 and 24-31 for the others; each cell's bytes run from the top of its character row. So the pattern lines up with the screen's character cells, and with the colours, whatever the area's shape.
|
||||
| FILL_NEXT_SEED | E734 | POP BC | The next place; the end marker ends the fill; a place off the screen (y 192 or more, or below 0) is dropped. | |
| E735 | LD A,B | |||
| E736 | CP $FE | |||
| E738 | RET Z | |||
| E739 | CP $C0 | |||
| E73B | JR NC,FILL_NEXT_SEED | |||
|
This entry point is used by the routine at DO_ROOM_COMMAND.
|
||||
| FILL_SEED | E73D | CALL BUFFER_PIXEL | FILL_SEED, where DO_ROOM_COMMAND starts: dropped if its pixel is set in the map (HL the byte, D the bit). | |
| E740 | AND (HL) | |||
| E741 | JR NZ,FILL_NEXT_SEED | |||
| FILL_NEXT_SEED_0 | E743 | AND (HL) | Go right to a set pixel, or to the screen's right edge (x back round to 0). | |
| E744 | JR NZ,FILL_NEXT_SEED_1 | |||
| E746 | INC C | |||
| E747 | RRC D | |||
| E749 | LD A,D | |||
| E74A | JR NC,FILL_NEXT_SEED_0 | |||
| E74C | INC HL | |||
| E74D | DEC C | |||
| E74E | INC C | |||
| E74F | JR NZ,FILL_NEXT_SEED_0 | |||
| FILL_NEXT_SEED_1 | E751 | LD E,$00 | Back one pixel, the run's last clear one; E: no run open above or below yet. | |
| E753 | DEC C | |||
| E754 | RLC D | |||
| E756 | JR NC,FILL_NEXT_SEED_2 | |||
| E758 | DEC HL | |||
| FILL_NEXT_SEED_2 | E759 | LD (STEP_AXES),HL | Keep its map address; HL: its screen address. | |
| E75C | LD A,H | |||
| E75D | SUB $80 | |||
| E75F | LD H,A | |||
| E760 | PUSH HL | The map address of the pixel above (y plus 1): the screen address a line up, worked out afresh across the top of a character row. | ||
| E761 | INC B | |||
| E762 | DEC H | |||
| E763 | LD A,H | |||
| E764 | AND $07 | |||
| E766 | XOR $07 | |||
| E768 | CALL Z,PIXEL_ADDRESS | |||
| E76B | LD A,H | |||
| E76C | ADD A,$80 | |||
| E76E | LD H,A | |||
| E76F | LD (WORK_RECORD),HL | |||
| E772 | POP HL | And of the pixel below. | ||
| E773 | DEC B | |||
| E774 | DEC B | |||
| E775 | INC H | |||
| E776 | LD A,H | |||
| E777 | AND $07 | |||
| E779 | CALL Z,PIXEL_ADDRESS | |||
| E77C | LD A,H | |||
| E77D | ADD A,$80 | |||
| E77F | LD H,A | |||
| E780 | INC B | |||
| E781 | LD (WORK_HEADING),HL | |||
| E784 | PUSH BC | x, y into BC'. | ||
| E785 | EXX | |||
| E786 | POP BC | |||
| E787 | LD HL,(FOUND_RECORD) | HL': the texture's byte for this row of the left cell: the second half unless bit 3 of y is set, and the row within the character row, from the top. | ||
| E78A | XOR A | |||
| E78B | BIT 3,B | |||
| E78D | JR NZ,FILL_NEXT_SEED_3 | |||
| E78F | LD A,$10 | |||
| FILL_NEXT_SEED_3 | E791 | ADD A,L | ||
| E792 | LD L,A | |||
| E793 | LD A,B | |||
| E794 | CPL | |||
| E795 | AND $07 | |||
| E797 | ADD A,L | |||
| E798 | LD L,A | |||
| E799 | LD A,C | C' the left cell's byte, B' the right's; swapped when bit 3 of x is clear, so that B' is this byte's. | ||
| E79A | LD C,(HL) | |||
| E79B | LD DE,$0008 | |||
| E79E | ADD HL,DE | |||
| E79F | LD B,(HL) | |||
| E7A0 | BIT 3,A | |||
| E7A2 | JR NZ,FILL_NEXT_SEED_4 | |||
| E7A4 | LD E,B | |||
| E7A5 | LD B,C | |||
| E7A6 | LD C,E | |||
| FILL_NEXT_SEED_4 | E7A7 | LD E,B | E': this byte's; HL': the screen address; and on to fill leftwards. | |
| E7A8 | LD HL,(STEP_AXES) | |||
| E7AB | LD A,H | |||
| E7AC | SUB $80 | |||
| E7AE | LD H,A | |||
| E7AF | EXX | |||
| E7B0 | JR FILL_THIS_PIXEL | |||
| Prev: E5E8 | Up: Map | Next: E7B2 |