![]() |
Routines |
| Prev: E5BA | Up: Map | Next: E734 |
|
Used by the routine at DRAW_ROOM_RECORD.
One command of a room's (or a part's) drawing, at IX; on return IX is at its last byte, and the loop (DRAW_ROOM_RECORD) steps past it. The commands are laid out in the rooms' entries; this is what they do. The point is x, y at IY+$64, IY+$65 and the second point at IY+$66, IY+$67; y counts up from the bottom of the screen, and rows go modulo 192.
Points, $00-$BF: the byte is a row, the next a column, and the point moves there. With mode bit 4 the two are added to the point instead; bit 6 mirrors the column (255 less it, or negated when it is added); bit 3 moves the second point by as much as the point; bit 5 draws a line from the second point to the new point (MORE_ROOM_COMMANDS); and bit 2 then makes the new point the second point too, so that the next line starts where this one ended.
$C0, a row and a column: the second point, set, or with bit 4 moved, as a point is. $CF: the second point to the point. $D0: the two swapped. $D6: the end of a repeat started by $D5 (MORE_ROOM_COMMANDS): IY+$6C counted down, and back to just after the $D5 while it has not run out. $E6-$FF: a flood fill with a texture from the point (FILL_NEXT_SEED; the textures are 32 bytes each from TEXTURES -- not all of them patterns). Everything else goes on to MORE_ROOM_COMMANDS: lines, the mode bits, the repeat's start, parts, the clean copy, and $E4 and its sub-commands.
In object mode (mode bit 7, which $E4 $04 sets for the rest of the room), a code below $E4 is an object: its type and four bytes, made into an object record at the next free one (IY+$38) by PLACE_OBJECT; $E4 does nothing; and $E6 up are patches (PATCH_RECORDS), which set the room's floor, ceiling and walls (FIXED_RECORDS) from the table of patches (at offset 778 of TEMPLATES).
|
||||||||||||
| DO_ROOM_COMMAND | E5E8 | BIT 7,D | Object mode? | |||||||||
| E5EA | JR Z,DO_ROOM_COMMAND_1 | |||||||||||
| E5EC | CP $E4 | Yes: $E4 does nothing; $E6 up are patches. | ||||||||||
| E5EE | RET Z | |||||||||||
| E5EF | JR NC,PATCH_RECORDS | |||||||||||
| E5F1 | PUSH IX | An object: HL at its type, IX at the next free record, and the record made. | ||||||||||
| E5F3 | PUSH IX | |||||||||||
| E5F5 | POP HL | |||||||||||
| E5F6 | LD IX,(FREE_RECORD) | |||||||||||
| E5FA | CALL PLACE_OBJECT | |||||||||||
| E5FD | POP IX | IX at the object's last byte. | ||||||||||
| E5FF | LD DE,$0004 | |||||||||||
| E602 | ADD IX,DE | |||||||||||
| E604 | RET | |||||||||||
| PATCH_RECORDS | E605 | PUSH IX | PATCH_RECORDS: IX at record 1 (the floor); HL at patch n (the code less $E5), six bytes each from the table's base. | |||||||||
| E607 | LD IX,FIXED_RECORDS | |||||||||||
| E60B | SUB $E5 | |||||||||||
| E60D | LD B,A | |||||||||||
| E60E | LD DE,$0006 | |||||||||||
| E611 | LD HL,PATCHES | |||||||||||
| DO_ROOM_COMMAND_0 | E614 | ADD HL,DE | ||||||||||
| E615 | DJNZ DO_ROOM_COMMAND_0 | |||||||||||
| E617 | LD A,(HL) | Its six bytes into the floor's and the ceiling's +7, the walls' +6 (records 3 and 4) and the other walls' +8 (records 5 and 6). | ||||||||||
| E618 | INC HL | |||||||||||
| E619 | LD (IX+OBJ_TOP),A | |||||||||||
| E61C | LD A,(HL) | |||||||||||
| E61D | INC HL | |||||||||||
| E61E | LD (IX+OBJ_SIZE+OBJ_TOP),A | |||||||||||
| E621 | LD A,(HL) | |||||||||||
| E622 | INC HL | |||||||||||
| E623 | LD (IX+$02*OBJ_SIZE+OBJ_X),A | |||||||||||
| E626 | LD A,(HL) | |||||||||||
| E627 | INC HL | |||||||||||
| E628 | LD (IX+$03*OBJ_SIZE+OBJ_X),A | |||||||||||
| E62B | LD A,(HL) | |||||||||||
| E62C | INC HL | |||||||||||
| E62D | LD (IX+$04*OBJ_SIZE+OBJ_Z),A | |||||||||||
| E630 | LD A,(HL) | |||||||||||
| E631 | LD (IX+$05*OBJ_SIZE+OBJ_Z),A | |||||||||||
| E634 | POP IX | |||||||||||
| E636 | RET | |||||||||||
| DO_ROOM_COMMAND_1 | E637 | CP $C0 | A point ($00-$BF)? | |||||||||
| E639 | JR NC,DO_ROOM_COMMAND_11 | |||||||||||
| E63B | LD BC,(POINT) | BC: the point as it was; H: the row; A: the column. | ||||||||||
| E63F | LD H,A | |||||||||||
| E640 | INC IX | |||||||||||
| E642 | LD A,(IX+$00) | |||||||||||
| E645 | BIT 6,D | Mode bit 6 mirrors the column: 255 less it, or negated when it is added (bit 4). | ||||||||||
| E647 | JR Z,DO_ROOM_COMMAND_3 | |||||||||||
| E649 | BIT 4,D | |||||||||||
| E64B | JR Z,DO_ROOM_COMMAND_2 | |||||||||||
| E64D | NEG | |||||||||||
| E64F | JR DO_ROOM_COMMAND_3 | |||||||||||
| DO_ROOM_COMMAND_2 | E651 | CPL | ||||||||||
| DO_ROOM_COMMAND_3 | E652 | LD L,A | Added to the point (mode bit 4)? | |||||||||
| E653 | BIT 4,D | |||||||||||
| E655 | JR Z,DO_ROOM_COMMAND_6 | |||||||||||
| E657 | ADD A,C | Yes: the column to x, and the row to y, modulo 192 (a sum that carries, or reaches 192, has 64 added). | ||||||||||
| E658 | LD C,A | |||||||||||
| E659 | LD A,H | |||||||||||
| E65A | ADD A,B | |||||||||||
| E65B | JR C,DO_ROOM_COMMAND_4 | |||||||||||
| E65D | CP $C0 | |||||||||||
| E65F | JR C,DO_ROOM_COMMAND_5 | |||||||||||
| DO_ROOM_COMMAND_4 | E661 | ADD A,$40 | ||||||||||
| DO_ROOM_COMMAND_5 | E663 | LD B,A | ||||||||||
| E664 | JR DO_ROOM_COMMAND_7 | |||||||||||
| DO_ROOM_COMMAND_6 | E666 | LD C,A | No: the point is the row and column. | |||||||||
| E667 | LD B,H | |||||||||||
| DO_ROOM_COMMAND_7 | E668 | BIT 3,D | Mode bit 3: the second point moves as far as the point does (its row modulo 192). | |||||||||
| E66A | JR Z,DO_ROOM_COMMAND_9 | |||||||||||
| E66C | LD A,(SECOND_POINT) | |||||||||||
| E66F | ADD A,C | |||||||||||
| E670 | SUB (IY+POINT-V) | |||||||||||
| E673 | LD (SECOND_POINT),A | |||||||||||
| E676 | LD A,(SECOND_POINT_ROW) | |||||||||||
| E679 | ADD A,B | |||||||||||
| E67A | SUB (IY+POINT_ROW-V) | |||||||||||
| E67D | CP $C0 | |||||||||||
| E67F | JR C,DO_ROOM_COMMAND_8 | |||||||||||
| E681 | ADD A,$40 | |||||||||||
| DO_ROOM_COMMAND_8 | E683 | LD (SECOND_POINT_ROW),A | ||||||||||
| DO_ROOM_COMMAND_9 | E686 | LD A,B | The new point (its row modulo 192 again, which cannot matter: never ran). | |||||||||
| E687 | CP $C0 | |||||||||||
| E689 | JR C,DO_ROOM_COMMAND_10 | |||||||||||
| E68B | ADD A,$40 | |||||||||||
| DO_ROOM_COMMAND_10 | E68D | LD B,A | ||||||||||
| E68E | LD (POINT),BC | |||||||||||
| E692 | BIT 5,D | Mode bit 5: a line from the second point to it. | ||||||||||
| E694 | CALL NZ,DRAW_LINE | |||||||||||
| E697 | BIT 2,(IY+MODE-V) | Mode bit 2: the second point follows. | ||||||||||
| E69B | RET Z | |||||||||||
| E69C | LD HL,(POINT) | |||||||||||
| E69F | LD (SECOND_POINT),HL | |||||||||||
| E6A2 | RET | |||||||||||
| DO_ROOM_COMMAND_11 | E6A3 | CP $CF | $CF: the second point to the point. | |||||||||
| E6A5 | JR NZ,DO_ROOM_COMMAND_12 | |||||||||||
| E6A7 | LD HL,(POINT) | |||||||||||
| E6AA | LD (SECOND_POINT),HL | |||||||||||
| E6AD | RET | |||||||||||
| DO_ROOM_COMMAND_12 | E6AE | CP $C0 | $C0: a second point, a row and a column. | |||||||||
| E6B0 | JR NZ,DO_ROOM_COMMAND_18 | |||||||||||
| E6B2 | INC IX | |||||||||||
| E6B4 | BIT 4,D | |||||||||||
| E6B6 | JR NZ,DO_ROOM_COMMAND_14 | |||||||||||
| E6B8 | LD A,(IX+$00) | Set: the row, then the column, mirrored with mode bit 6 (never in any room: the CPL never ran). | ||||||||||
| E6BB | LD (SECOND_POINT_ROW),A | |||||||||||
| E6BE | INC IX | |||||||||||
| E6C0 | LD A,(IX+$00) | |||||||||||
| E6C3 | BIT 6,D | |||||||||||
| E6C5 | JR Z,DO_ROOM_COMMAND_13 | |||||||||||
| E6C7 | CPL | |||||||||||
| DO_ROOM_COMMAND_13 | E6C8 | LD (SECOND_POINT),A | ||||||||||
| E6CB | RET | |||||||||||
| DO_ROOM_COMMAND_14 | E6CC | LD A,(IX+$00) | Or added to it (mode bit 4): the row modulo 192, the column negated with bit 6. | |||||||||
| E6CF | ADD A,(IY+SECOND_POINT_ROW-V) | |||||||||||
| E6D2 | JR C,DO_ROOM_COMMAND_15 | |||||||||||
| E6D4 | CP $C0 | |||||||||||
| E6D6 | JR C,DO_ROOM_COMMAND_16 | |||||||||||
| DO_ROOM_COMMAND_15 | E6D8 | ADD A,$40 | ||||||||||
| DO_ROOM_COMMAND_16 | E6DA | LD (SECOND_POINT_ROW),A | ||||||||||
| E6DD | INC IX | |||||||||||
| E6DF | LD A,(IX+$00) | |||||||||||
| E6E2 | BIT 6,D | |||||||||||
| E6E4 | JR Z,DO_ROOM_COMMAND_17 | |||||||||||
| E6E6 | NEG | |||||||||||
| DO_ROOM_COMMAND_17 | E6E8 | ADD A,(IY+SECOND_POINT-V) | ||||||||||
| E6EB | JR DO_ROOM_COMMAND_13 | |||||||||||
| DO_ROOM_COMMAND_18 | E6ED | CP $D6 | $D6: the end of a repeat. Count down; not run out, back to the $D5's count byte. | |||||||||
| E6EF | JR NZ,DO_ROOM_COMMAND_19 | |||||||||||
| E6F1 | DEC (IY+REPEATS-V) | |||||||||||
| E6F4 | RET Z | |||||||||||
| E6F5 | LD IX,(REPEAT_FROM) | |||||||||||
| E6F9 | RET | |||||||||||
| DO_ROOM_COMMAND_19 | E6FA | CP $D0 | $D0: the points swapped. | |||||||||
| E6FC | JR NZ,DO_ROOM_COMMAND_20 | |||||||||||
| E6FE | LD HL,(POINT) | |||||||||||
| E701 | LD DE,(SECOND_POINT) | |||||||||||
| E705 | LD (SECOND_POINT),HL | |||||||||||
| E708 | LD (POINT),DE | |||||||||||
| E70C | RET | |||||||||||
| DO_ROOM_COMMAND_20 | E70D | CP $E6 | The rest below $E6 go on to MORE_ROOM_COMMANDS. | |||||||||
| E70F | JP C,MORE_ROOM_COMMANDS | |||||||||||
| E712 | SUB $E6 | A fill: the texture's address, 32 bytes each from TEXTURES, kept at IY+$78. | ||||||||||
| E714 | LD E,A | |||||||||||
| E715 | LD D,$00 | |||||||||||
| E717 | LD B,$05 | |||||||||||
| DO_ROOM_COMMAND_21 | E719 | SLA E | ||||||||||
| E71B | RL D | |||||||||||
| E71D | DJNZ DO_ROOM_COMMAND_21 | |||||||||||
| E71F | LD HL,TEXTURES | |||||||||||
| E722 | ADD HL,DE | |||||||||||
| E723 | LD (FOUND_RECORD),HL | |||||||||||
| E726 | LD BC,(POINT) | Nothing to fill if the point is set in the fill's map already. | ||||||||||
| E72A | CALL BUFFER_PIXEL | |||||||||||
| E72D | AND (HL) | |||||||||||
| E72E | RET NZ | |||||||||||
| E72F | LD H,$FE | Push the end marker (its high byte $FE), and fill from the point. | ||||||||||
| E731 | PUSH HL | |||||||||||
| E732 | JR FILL_SEED | |||||||||||
| Prev: E5BA | Up: Map | Next: E734 |