Prev: 45207 Up: Map Next: 45381
45333: Save Room Objects
Used by the routine at RunGame.
Copies the first 16 bytes of every object record back to the object store entry that has the same type, so that the state of the objects is remembered when the player leaves the room.
Go through the object records, from the seventh.
SaveRoomObjects 45333 LD IY,43023 Point IY at the record before the seventh one.
45337 LD C,48 Set a counter in C of 48 records.
SaveRoomObjects_NextRecord 45339 LD DE,32 Set the size of an object record in DE.
45342 ADD IY,DE Move IY to the next record.
45344 LD A,(IY+0) Fetch the type of the object.
Look for the store entry that has the same type.
45347 LD HL,54322 Point HL at ObjectStore.
45350 LD DE,16 Set the size of a store entry in DE.
45353 LD B,18 Set a counter in B of 18 entries.
SaveRoomObjects_TestEntry 45355 CP (HL) Compare the type of the object with the type of the entry.
45356 JR Z,SaveRoomObjects_Copy Jump to SaveRoomObjects_Copy if they match.
45358 ADD HL,DE Move HL to the next entry.
45359 DJNZ SaveRoomObjects_TestEntry Decrease the entry counter and test the next entry until none are left.
SaveRoomObjects_Count 45361 DEC C Decrease the record counter.
45362 JR NZ,SaveRoomObjects_NextRecord Jump to SaveRoomObjects_NextRecord if there are more records to look at.
45364 RET Return.
Copy the record into the store entry.
SaveRoomObjects_Copy 45365 EX DE,HL Point DE at the store entry.
45366 PUSH IY Copy IY to HL (using the stack).
45368 POP HL
45369 PUSH BC Stash the record counter on the stack.
45370 LD BC,16 Set a counter in BC of 16 bytes.
45373 LDIR Copy the first 16 bytes of the object to the store entry.
45375 POP BC Restore the record counter from the stack.
45376 LD DE,32 Set the size of an object record in DE.
45379 JR SaveRoomObjects_Count Jump to SaveRoomObjects_Count to move on to the next record.
Prev: 45207 Up: Map Next: 45381