Prev: C525 Up: Map Next: C5C8
C591: Update Special Objects
Used by the routine at BuildRoomObjects.
Copies the graphic number and the current position of each special object of the room back to the table of special objects, so that they are not lost when the player leaves the room.
Copy each special object of the room back to the table.
UpdateSpecialObjects C591 LD IY,$5C48 Point IY at the first special object of the room, ObjectsTable_FirstSpecial.
UpdateSpecialObjects_Next C595 LD A,(IY+$00) Fetch the graphic number of the object.
C598 AND A Test whether there is an object.
C599 JR Z,UpdateSpecialObjects_NextSlot Jump to UpdateSpecialObjects_NextSlot if there is not.
C59B LD E,(IY+$10) Fetch the low byte of the address of the entry in the table of special objects.
C59E LD D,(IY+$11) Fetch the high byte.
C5A1 LD A,(IY+$00) Fetch the graphic number of the object.
C5A4 LD (DE),A Store it in the entry.
C5A5 INC DE Point DE at the current X coordinate of the entry.
C5A6 INC DE
C5A7 INC DE
C5A8 INC DE
C5A9 INC DE
C5AA PUSH IY Copy IY to HL (using the stack).
C5AC POP HL
C5AD INC HL Point HL at the X coordinate of the object.
C5AE LD BC,$0003 Set the number of bytes to copy to 03.
C5B1 LDIR Copy the position of the object to the entry.
C5B3 LD A,(IY+$08) Fetch the room of the object.
C5B6 LD (DE),A Store it in the entry.
UpdateSpecialObjects_NextSlot C5B7 LD BC,$0020 Set BC to the size of an object.
C5BA ADD IY,BC Point IY at the next object.
C5BC PUSH IY Copy IY to HL (using the stack).
C5BE POP HL
C5BF LD BC,$5C88 Point BC at the end of the special objects of the room, ObjectsTable_RoomObjects.
C5C2 AND A Subtract the address of the end.
C5C3 SBC HL,BC
C5C5 JR C,UpdateSpecialObjects_Next Jump to UpdateSpecialObjects_Next until both of the objects have been done.
C5C7 RET Return.
View the equivalent code in;
Prev: C525 Up: Map Next: C5C8