![]() |
Routines |
| Prev: B06C | Up: Map | Next: B1B2 |
|
Draws every item in the sorted draw list at SortedDrawList, in order. The flag in each item selects what is drawn: 01 is an entity, 02 is one of the extra records (which is first copied into the temporary entity at TemporaryEntity) and 03 is one of the 14-byte records.
For a 14-byte record, the items drawn before it that overlap it are collected into the table at B1B3 and then the record is drawn with DrawBlock. An extra record is drawn with DrawEntityItem after its column, row, frame, width and height have been copied into the temporary entity.
|
||||
| DrawItems | B06E | LD HL,$AF8F | Take the sorted draw list. | |
| DrawItems_Next | B071 | LD A,(HL) | Read the kind of the next item. | |
| B072 | AND %01111111 | Keep the kind of the item. | ||
| B074 | RET Z | Return at the end of the list. | ||
| B075 | INC HL | Read the address of the record and step to the next item. | ||
| B076 | LD E,(HL) | |||
| B077 | INC HL | |||
| B078 | LD D,(HL) | |||
| B079 | INC HL | |||
| B07A | PUSH DE | Take that record. | ||
| B07B | POP IX | |||
| B07D | PUSH HL | Remember the next item. | ||
| B07E | DEC A | Draw an entity with DrawEntityItem. | ||
| B07F | JP Z,DrawEntityItem | |||
| B082 | CP $02 | Draw a 14-byte record at DrawItems_Record. | ||
| B084 | JP Z,DrawItems_Record | |||
| DrawItems_Extra | B087 | BIT 7,(IX+$09) | Jump to DrawItems_NextItem to skip an extra record that is not in use. | |
| B08B | JR Z,DrawItems_NextItem | |||
| B08D | LD L,(IX+$00) | Copy the column and the row into the temporary entity. | ||
| B090 | LD H,(IX+$01) | |||
| B093 | LD ($B7B2),HL | |||
| B096 | LD L,(IX+$08) | Copy fields 08 and 09 of the extra record into the screen address of the temporary entity. | ||
| B099 | LD H,(IX+$09) | |||
| B09C | LD ($B7BC),HL | |||
| B09F | LD A,(IX+$0B) | Fetch the frame and the width. | ||
| B0A2 | LD B,A | |||
| B0A3 | AND %00001111 | Keep the width. | ||
| B0A5 | LD ($B7BA),A | Store the width in the temporary entity. | ||
| B0A8 | LD A,(IX+$0C) | Fetch the height byte. | ||
| B0AB | AND %00111111 | Keep the height. | ||
| B0AD | LD ($B7BB),A | Store the height in the temporary entity. | ||
| B0B0 | LD A,B | Move the frame down from the high nibble. | ||
| B0B1 | RRA | |||
| B0B2 | RRA | |||
| B0B3 | RRA | |||
| B0B4 | RRA | |||
| B0B5 | AND %00001111 | Keep the frame. | ||
| B0B7 | LD ($B7A5),A | Store the frame in the temporary entity. | ||
| B0BA | LD IX,$B7A4 | Use the temporary entity. | ||
| B0BE | JP DrawEntityItem | Draw it. | ||
|
This entry point is used by the routine at DrawEntityItem.
|
||||
| DrawItems_NextItem | B0C1 | POP HL | Restore the next item. | |
| B0C2 | JR DrawItems_Next | Take the next item. | ||
|
Look back through the items drawn before this 14-byte record. The alternate C counts the ones that overlap it, and the alternate HL walks the overlap table.
|
||||
| DrawItems_Record | B0C4 | EXX | Switch to the alternate registers. | |
| B0C5 | LD C,$00 | Clear the overlap count. | ||
| B0C7 | LD HL,$B1B3 | Use the overlap table. | ||
| B0CA | EXX | Switch back. | ||
| B0CB | PUSH IX | Keep this record aside. | ||
| B0CD | POP IY | |||
| B0CF | DEC HL | Step back to this item. | ||
| B0D0 | DEC HL | |||
| B0D1 | DEC HL | |||
| DrawItems_Previous | B0D2 | DEC HL | Read the previous item. | |
| B0D3 | LD D,(HL) | |||
| B0D4 | DEC HL | |||
| B0D5 | LD E,(HL) | |||
| B0D6 | DEC HL | |||
| B0D7 | LD A,(HL) | |||
| B0D8 | CP $FF | Stop at the start of the list. | ||
| B0DA | JR Z,DrawItems_Collected | |||
| B0DC | CP $03 | Skip another 14-byte record. | ||
| B0DE | JR Z,DrawItems_Continue | |||
| B0E0 | PUSH DE | Take the previous item. | ||
| B0E1 | POP IX | |||
| B0E3 | PUSH HL | Remember the place in the list. | ||
| B0E4 | DEC A | Test an entity now. | ||
| B0E5 | JR Z,DrawItems_Test | |||
| B0E7 | LD L,(IX+$00) | Copy the column and the row of the extra record into the temporary entity. | ||
| B0EA | LD H,(IX+$01) | |||
| B0ED | LD ($B7B2),HL | |||
| B0F0 | LD L,(IX+$02) | Copy the adjusted x coordinate into the temporary entity. | ||
| B0F3 | LD H,(IX+$03) | |||
| B0F6 | LD ($B7A6),HL | |||
| B0F9 | LD L,(IX+$04) | Copy the adjusted y coordinate into the temporary entity. | ||
| B0FC | LD H,(IX+$05) | |||
| B0FF | LD ($B7A9),HL | |||
| B102 | LD L,(IX+$06) | Copy the adjusted z coordinate into the temporary entity. | ||
| B105 | LD H,(IX+$07) | |||
| B108 | LD ($B7AC),HL | |||
| B10B | LD A,(IX+$0B) | Fetch the frame and the width. | ||
| B10E | AND %00001111 | Keep the width. | ||
| B110 | LD ($B7BA),A | Store the width in the temporary entity. | ||
| B113 | LD A,(IX+$0C) | Fetch the height byte. | ||
| B116 | AND %00111111 | Keep the height. | ||
| B118 | LD ($B7BB),A | Store the height in the temporary entity. | ||
| B11B | LD IX,$B7A4 | Use the temporary entity. | ||
| DrawItems_Test | B11F | CALL TestRecordOverlap | Test this item against the record. | |
| B122 | BIT 7,(IY+$0A) | Test whether the record still has to collect this item. | ||
| B126 | RES 7,(IY+$0A) | Mark the record as having been tested against this item. | ||
| B12A | CALL NZ,CollectOverlappingItem | Collect the item when it overlaps the record. | ||
| B12D | POP HL | Restore the place in the list. | ||
| DrawItems_Continue | B12E | JR DrawItems_Previous | Look at the previous item. | |
|
Patch the drawing routines with this record, then draw the block. A record whose byte 0A is 11 or 12 keeps the default details 1010.
|
||||
| DrawItems_Collected | B130 | EXX | Switch to the alternate registers. | |
| B131 | LD A,C | Test the overlap count. | ||
| B132 | AND A | |||
| B133 | JP Z,DrawItems_NextItem | Leave a record that nothing overlaps. | ||
| B136 | LD ($B1B2),A | Remember how many items overlap the record. | ||
| B139 | LD ($C653),A | Give that count to the overlapped-block routine. | ||
| B13C | LD A,($5CF0) | Fetch the drawing flags. | ||
| B13F | AND %00000111 | Keep the low three drawing flags. | ||
| B141 | LD ($C65D),A | Give the drawing flags to the overlapped-block routine. | ||
| B144 | LD A,(IY+$0A) | Fetch byte 0A of the record. | ||
| B147 | LD ($C1FE),A | Give that byte to the block routine. | ||
| B14A | LD H,A | Build an instruction that loads three times that byte. | ||
| B14B | LD L,$3E | |||
| B14D | ADD A,A | |||
| B14E | ADD A,A | |||
| B14F | SUB H | |||
| B150 | LD H,A | |||
| B151 | LD ($C1A0),HL | Patch that instruction into C1A0. | ||
| B154 | LD A,$C3 | Take the opcode of a jump. | ||
| B156 | LD ($C75D),A | Patch it into C75D. | ||
| B159 | LD HL,$C7AC | Take DrawBlockSection. | ||
| B15C | LD ($C75E),HL | Patch the jump so that it enters DrawBlockSection. | ||
| B15F | LD DE,($5CE7) | Fetch the view origin. | ||
| B163 | LD B,(IY+$00) | Fetch the first two bytes of the record. | ||
| B166 | LD C,(IY+$01) | |||
| B169 | LD HL,$0000 | Start from zero. | ||
| B16C | XOR A | Subtract the view origin and add the first two bytes of the record. | ||
| B16D | SBC HL,DE | |||
| B16F | ADD HL,BC | |||
| B170 | LD ($BB9F),HL | Store the result in the drawing variables. | ||
| B173 | LD H,(IY+$0E) | Fetch the screen position saved in the record. | ||
| B176 | LD L,(IY+$0F) | |||
| B179 | LD ($BBA1),HL | Store it in the drawing variables. | ||
| B17C | LD HL,$1010 | Take the default record details. | ||
| B17F | LD A,(IY+$0A) | Fetch byte 0A of the record. | ||
| B182 | CP $11 | Keep the default details when the byte is 11. | ||
| B184 | JR Z,DrawItems_Details | |||
| B186 | CP $12 | Keep the default details when the byte is 12. | ||
| B188 | JR Z,DrawItems_Details | |||
| B18A | LD H,(IY+$0C) | Take fields 0B and 0C of the record as the details. | ||
| B18D | LD L,(IY+$0B) | |||
| DrawItems_Details | B190 | LD ($5CF3),HL | Store the details. | |
| B193 | LD A,(IY+$0D) | Fetch byte 0D of the record. | ||
| B196 | LD ($5CF5),A | Store the third detail byte. | ||
| B199 | LD HL,$C646 | Take the overlapped-block routine. | ||
| B19C | LD ($C3D8),HL | Patch DrawBlockShape so that it uses DrawOverlappedBlock. | ||
| B19F | LD A,$1A | Take the value 1A. | ||
| B1A1 | LD ($B530),A | Patch it into B530. | ||
| B1A4 | CALL DrawBlock | Draw the block. | ||
| B1A7 | LD A,$08 | Take the row step 08. | ||
| B1A9 | LD ($C794),A | Restore it in C794. | ||
| B1AC | LD ($C7A6),A | Restore it in C7A6. | ||
| B1AF | JP DrawItems_NextItem | Take the next item. | ||
| Prev: B06C | Up: Map | Next: B1B2 |