Prev: B097 Up: Map Next: B145
B115: Save Room Objects
Used by the routine at RunGame.
Copies the first 10 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 B115 LD IY,$A80F Point IY at the record before the seventh one.
B119 LD C,$30 Set a counter in C of 30 records.
SaveRoomObjects_NextRecord B11B LD DE,$0020 Set the size of an object record in DE.
B11E ADD IY,DE Move IY to the next record.
B120 LD A,(IY+$00) Fetch the type of the object.
Look for the store entry that has the same type.
B123 LD HL,$D432 Point HL at ObjectStore.
B126 LD DE,$0010 Set the size of a store entry in DE.
B129 LD B,$12 Set a counter in B of 12 entries.
SaveRoomObjects_TestEntry B12B CP (HL) Compare the type of the object with the type of the entry.
B12C JR Z,SaveRoomObjects_Copy Jump to SaveRoomObjects_Copy if they match.
B12E ADD HL,DE Move HL to the next entry.
B12F DJNZ SaveRoomObjects_TestEntry Decrease the entry counter and test the next entry until none are left.
SaveRoomObjects_Count B131 DEC C Decrease the record counter.
B132 JR NZ,SaveRoomObjects_NextRecord Jump to SaveRoomObjects_NextRecord if there are more records to look at.
B134 RET Return.
Copy the record into the store entry.
SaveRoomObjects_Copy B135 EX DE,HL Point DE at the store entry.
B136 PUSH IY Copy IY to HL (using the stack).
B138 POP HL
B139 PUSH BC Stash the record counter on the stack.
B13A LD BC,$0010 Set a counter in BC of 10 bytes.
B13D LDIR Copy the first 10 bytes of the object to the store entry.
B13F POP BC Restore the record counter from the stack.
B140 LD DE,$0020 Set the size of an object record in DE.
B143 JR SaveRoomObjects_Count Jump to SaveRoomObjects_Count to move on to the next record.
Prev: B097 Up: Map Next: B145