Prev: 44935 Up: Map Next: 45333
45207: Load Room Objects
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 18 entries of 16 bytes each, which starts at ObjectStore.
Search the object store for the objects of this room.
LoadRoomObjects 45207 LD IY,54306 Point IY at the entry before the first one in the object store.
45211 LD B,18 Set a counter in B of 18 store entries.
LoadRoomObjects_Loop 45213 LD DE,16 Set the size of a store entry in DE.
45216 LD A,(42871) Fetch the room that the player is in from offset 8 of the first record of ObjectsTable.
45219 LD C,A Stash the room in C.
LoadRoomObjects_NextEntry 45220 ADD IY,DE Move IY to the next store entry.
45222 LD A,(IY+0) Jump to LoadRoomObjects_SkipEntry if the entry is empty.
45225 AND A
45226 JR Z,LoadRoomObjects_SkipEntry
45228 LD A,(IY+8) Jump to LoadRoomObjects_FindRecord if the object belongs to this room.
45231 CP C
45232 JR Z,LoadRoomObjects_FindRecord
LoadRoomObjects_SkipEntry 45234 DJNZ LoadRoomObjects_NextEntry Decrease the entry counter and look at the next entry until there are none left.
45236 RET Return.
Find a free object record for the object.
LoadRoomObjects_FindRecord 45237 LD HL,43055 Point HL at the seventh object record, which is the first that is not used for the player or the fixed objects.
45240 LD DE,32 Set the size of an object record in DE.
45243 PUSH BC Stash the entry counter and the room number on the stack.
45244 LD B,48 Set a counter in B of 48 records.
LoadRoomObjects_TestRecord 45246 LD A,(HL) Jump to LoadRoomObjects_FreeRecord if the record is free.
45247 AND A
45248 JR Z,LoadRoomObjects_FreeRecord
45250 ADD HL,DE Move HL to the next record.
45251 DJNZ LoadRoomObjects_TestRecord Decrease the record counter and test the next record until none are left.
45253 POP BC Restore the entry counter and the room number from the stack and return, as every record is in use.
45254 RET
The pentagram arcs are only made when the pentagram has been revealed.
LoadRoomObjects_FreeRecord 45255 EX DE,HL Point DE at the free record.
45256 LD A,(IY+0) Fetch the type of the stored object.
45259 AND %11111000 Keep only the type group.
45261 CP 128 Jump to LoadRoomObjects_Copy if the object is not an arc.
45263 JR NZ,LoadRoomObjects_Copy
45265 LD A,(42767) Skip this object by jumping to LoadRoomObjects_Next if the pentagram has not been revealed.
45268 AND A
45269 JR Z,LoadRoomObjects_Next
Copy the stored object into the free record.
LoadRoomObjects_Copy 45271 SET 4,(IY+7) Flag the stored object as needing to be drawn.
45275 PUSH IY Copy IY to HL (using the stack).
45277 POP HL
45278 LD BC,16 Set a counter in BC of 16 bytes.
45281 LDIR Copy the stored entry into the record.
Remember which store entry the object came from, and clear the workspace of the record.
45283 PUSH IY Copy IY to HL (using the stack).
45285 POP HL
45286 EX DE,HL Swap so that HL points to the record and DE to the store entry.
45287 LD (HL),E Write the address of the store entry to the record, in the fields at offsets 16 and 17.
45288 INC HL
45289 LD (HL),D
45290 INC HL Move HL to the workspace of the record.
45291 LD B,14 Set a counter in B of 14 bytes.
45293 XOR A Clear A.
LoadRoomObjects_ClearWorkspace 45294 LD (HL),A Write 0 to the workspace and move on, until all the bytes are done.
45295 INC HL
45296 DJNZ LoadRoomObjects_ClearWorkspace
45298 LD DE,65504 Set DE to 65504, which is minus the size of a record.
45301 ADD HL,DE Move HL back to the start of the record.
45302 PUSH HL Copy HL to IX (using the stack).
45303 POP IX
Lift the object until it is not inside any other object, unless it is an arc.
45305 LD A,(IX+0) Fetch the type of the object.
45308 AND %11111000 Keep only the type group.
45310 CP 128 Jump to LoadRoomObjects_Next if the object is an arc.
45312 JR Z,LoadRoomObjects_Next
LoadRoomObjects_TestClear 45314 CALL TestObjectIntersections Call TestObjectIntersections to see if the object is inside another one.
45317 JR NC,LoadRoomObjects_Next Jump to LoadRoomObjects_Next if it is not.
45319 LD A,(IX+3) Fetch the height of the object.
45322 ADD A,12 Add 12 to it.
45324 LD (IX+3),A Write it back.
45327 JR LoadRoomObjects_TestClear Jump to LoadRoomObjects_TestClear to test the object again.
LoadRoomObjects_Next 45329 POP BC Restore the entry counter and the room number from the stack.
45330 DJNZ LoadRoomObjects_Loop Decrease the entry counter and look at the next store entry until there are none left.
45332 RET Return.
Prev: 44935 Up: Map Next: 45333