![]() |
Routines |
| Prev: AF87 | Up: Map | Next: B115 |
|
Used by the routine at RunGame.
Looks through the object store for objects that belong in the current room, and makes an object record in the object table for each one it finds. The pentagram arcs are only made once the pentagram has been revealed. An object that lands inside another one is lifted up until it is clear.
The store is a table of 12 entries of 10 bytes each, which starts at ObjectStore.
|
||||
|
Search the object store for the objects of this room.
|
||||
| LoadRoomObjects | B097 | LD IY,$D422 | Point IY at the entry before the first one in the object store. | |
| B09B | LD B,$12 | Set a counter in B of 12 store entries. | ||
| LoadRoomObjects_Loop | B09D | LD DE,$0010 | Set the size of a store entry in DE. | |
| B0A0 | LD A,($A777) | Fetch the room that the player is in from offset 08 of the first record of ObjectsTable. | ||
| B0A3 | LD C,A | Stash the room in C. | ||
| LoadRoomObjects_NextEntry | B0A4 | ADD IY,DE | Move IY to the next store entry. | |
| B0A6 | LD A,(IY+$00) | Jump to LoadRoomObjects_SkipEntry if the entry is empty. | ||
| B0A9 | AND A | |||
| B0AA | JR Z,LoadRoomObjects_SkipEntry | |||
| B0AC | LD A,(IY+$08) | Jump to LoadRoomObjects_FindRecord if the object belongs to this room. | ||
| B0AF | CP C | |||
| B0B0 | JR Z,LoadRoomObjects_FindRecord | |||
| LoadRoomObjects_SkipEntry | B0B2 | DJNZ LoadRoomObjects_NextEntry | Decrease the entry counter and look at the next entry until there are none left. | |
| B0B4 | RET | Return. | ||
|
Find a free object record for the object.
|
||||
| LoadRoomObjects_FindRecord | B0B5 | LD HL,$A82F | Point HL at the seventh object record, which is the first that is not used for the player or the fixed objects. | |
| B0B8 | LD DE,$0020 | Set the size of an object record in DE. | ||
| B0BB | PUSH BC | Stash the entry counter and the room number on the stack. | ||
| B0BC | LD B,$30 | Set a counter in B of 30 records. | ||
| LoadRoomObjects_TestRecord | B0BE | LD A,(HL) | Jump to LoadRoomObjects_FreeRecord if the record is free. | |
| B0BF | AND A | |||
| B0C0 | JR Z,LoadRoomObjects_FreeRecord | |||
| B0C2 | ADD HL,DE | Move HL to the next record. | ||
| B0C3 | DJNZ LoadRoomObjects_TestRecord | Decrease the record counter and test the next record until none are left. | ||
| B0C5 | POP BC | Restore the entry counter and the room number from the stack and return, as every record is in use. | ||
| B0C6 | RET | |||
|
The pentagram arcs are only made when the pentagram has been revealed.
|
||||
| LoadRoomObjects_FreeRecord | B0C7 | EX DE,HL | Point DE at the free record. | |
| B0C8 | LD A,(IY+$00) | Fetch the type of the stored object. | ||
| B0CB | AND %11111000 | Keep only the type group. | ||
| B0CD | CP $80 | Jump to LoadRoomObjects_Copy if the object is not an arc. | ||
| B0CF | JR NZ,LoadRoomObjects_Copy | |||
| B0D1 | LD A,($A70F) | Skip this object by jumping to LoadRoomObjects_Next if the pentagram has not been revealed. | ||
| B0D4 | AND A | |||
| B0D5 | JR Z,LoadRoomObjects_Next | |||
|
Copy the stored object into the free record.
|
||||
| LoadRoomObjects_Copy | B0D7 | SET 4,(IY+$07) | Flag the stored object as needing to be drawn. | |
| B0DB | PUSH IY | Copy IY to HL (using the stack). | ||
| B0DD | POP HL | |||
| B0DE | LD BC,$0010 | Set a counter in BC of 10 bytes. | ||
| B0E1 | LDIR | Copy the stored entry into the record. | ||
|
Remember which store entry the object came from, and clear the workspace of the record.
|
||||
| B0E3 | PUSH IY | Copy IY to HL (using the stack). | ||
| B0E5 | POP HL | |||
| B0E6 | EX DE,HL | Swap so that HL points to the record and DE to the store entry. | ||
| B0E7 | LD (HL),E | Write the address of the store entry to the record, in the fields at offsets 10 and 11. | ||
| B0E8 | INC HL | |||
| B0E9 | LD (HL),D | |||
| B0EA | INC HL | Move HL to the workspace of the record. | ||
| B0EB | LD B,$0E | Set a counter in B of 0E bytes. | ||
| B0ED | XOR A | Clear A. | ||
| LoadRoomObjects_ClearWorkspace | B0EE | LD (HL),A | Write 00 to the workspace and move on, until all the bytes are done. | |
| B0EF | INC HL | |||
| B0F0 | DJNZ LoadRoomObjects_ClearWorkspace | |||
| B0F2 | LD DE,$FFE0 | Set DE to FFE0, which is minus the size of a record. | ||
| B0F5 | ADD HL,DE | Move HL back to the start of the record. | ||
| B0F6 | PUSH HL | Copy HL to IX (using the stack). | ||
| B0F7 | POP IX | |||
|
Lift the object until it is not inside any other object, unless it is an arc.
|
||||
| B0F9 | LD A,(IX+$00) | Fetch the type of the object. | ||
| B0FC | AND %11111000 | Keep only the type group. | ||
| B0FE | CP $80 | Jump to LoadRoomObjects_Next if the object is an arc. | ||
| B100 | JR Z,LoadRoomObjects_Next | |||
| LoadRoomObjects_TestClear | B102 | CALL TestObjectIntersections | Call TestObjectIntersections to see if the object is inside another one. | |
| B105 | JR NC,LoadRoomObjects_Next | Jump to LoadRoomObjects_Next if it is not. | ||
| B107 | LD A,(IX+$03) | Fetch the height of the object. | ||
| B10A | ADD A,$0C | Add 0C to it. | ||
| B10C | LD (IX+$03),A | Write it back. | ||
| B10F | JR LoadRoomObjects_TestClear | Jump to LoadRoomObjects_TestClear to test the object again. | ||
| LoadRoomObjects_Next | B111 | POP BC | Restore the entry counter and the room number from the stack. | |
| B112 | DJNZ LoadRoomObjects_Loop | Decrease the entry counter and look at the next store entry until there are none left. | ||
| B114 | RET | Return. | ||
| Prev: AF87 | Up: Map | Next: B115 |