Prev: C515 Up: Map Next: C591
C525: Place Special Objects In Room
Used by the routine at BuildRoomObjects.
Makes the list of the special objects that are in the room that the player is in, ready to be updated like any other object. Every entry of the table of special objects at SpecialObjectsTable that is in the room is copied to the objects table (up to two of them), with the width and depth of 05, the height of 0C and the flags for drawing and for being able to move. The address of the entry is kept at 10 bytes into the object, so that it can be updated by UpdateSpecialObjects. The rest of the objects table for the special objects is cleared.
Input
IX Address of the player
PlaceSpecialObjectsInRoom C525 LD DE,$5C48 Point DE at the first special object of the room, ObjectsTable_FirstSpecial.
C528 EXX Switch to the alternate registers to keep it there.
C529 LD IY,$6FF2 Point IY at SpecialObjectsTable.
C52D LD B,(IX+$08) Fetch the room that the player is in.
PlaceSpecialObjectsInRoom_TestEntry C530 LD A,(IY+$00) Fetch the graphic number of the entry.
C533 AND A Test whether there is an object.
C534 JR Z,PlaceSpecialObjectsInRoom_NextEntry Jump to PlaceSpecialObjectsInRoom_NextEntry if there is not.
C536 LD A,(IY+$08) Fetch the room that the object is in.
C539 CP B Compare it with the room that the player is in.
C53A JR NZ,PlaceSpecialObjectsInRoom_NextEntry Jump to PlaceSpecialObjectsInRoom_NextEntry if they are different.
C53C PUSH IY Stash the address of the entry on the stack.
C53E EXX Switch back to the registers that hold the address of the special object of the room.
C53F POP HL Restore the address of the entry from the stack.
C540 PUSH HL Stash it again on the stack.
C541 LD A,(HL) Fetch the graphic number.
C542 INC HL Move on to the starting position.
C543 LD (DE),A Set the graphic number of the special object of the room.
C544 INC DE Move on to the X coordinate.
C545 INC HL Point HL at the current position of the object.
C546 INC HL
C547 INC HL
C548 INC HL
C549 LD BC,$0003 Set the number of bytes to copy to 03.
C54C LDIR Copy the coordinates.
C54E EX DE,HL Point HL at the width of the special object of the room.
C54F LD (HL),$05 Set the width to 05.
C551 INC HL Move on to the depth.
C552 LD (HL),$05 Set the depth to 05.
C554 INC HL Move on to the height.
C555 LD (HL),$0C Set the height to 0C.
C557 INC HL Move on to the flags.
C558 LD (HL),$14 Set the flags to draw and to be able to move.
C55A INC HL Move on to the room.
C55B EX DE,HL Point HL at the room of the entry and DE at the room of the special object of the room.
C55C LD A,(HL) Fetch the room.
C55D INC HL Move on to the next byte.
C55E LD (DE),A Set the room.
C55F INC DE Move on to the speeds.
C560 LD B,$07 Set the number of bytes to clear to 07.
C562 CALL ClearBytes Clear them.
C565 POP BC Restore the address of the entry from the stack.
C566 LD A,C Fetch the low byte.
C567 LD (DE),A Store it.
C568 INC DE Move on to the high byte.
C569 LD A,B Fetch the high byte.
C56A LD (DE),A Store it.
C56B INC DE Move on.
C56C LD B,$0E Set the number of bytes to clear to 0E.
C56E CALL ClearBytes Clear them.
C571 EXX Switch to the alternate registers.
PlaceSpecialObjectsInRoom_NextEntry C572 LD DE,$0009 Set DE to the size of an entry.
C575 ADD IY,DE Point IY at the next entry.
C577 PUSH IY Copy IY to HL (using the stack).
C579 POP HL
C57A LD DE,$7112 Point DE at the end of the table, SpriteTable.
C57D AND A Subtract the address of the end of the table.
C57E SBC HL,DE
C580 JR C,PlaceSpecialObjectsInRoom_TestEntry Jump to PlaceSpecialObjectsInRoom_TestEntry until all of the entries have been done.
C582 EXX Switch to the registers that hold the address of the special object of the room.
Clear what is left of the special objects of the room.
PlaceSpecialObjectsInRoom_ClearSlots C583 LD HL,$5C88 Point HL at the end of the special objects of the room, ObjectsTable_RoomObjects.
C586 AND A Subtract the address of the object that is next.
C587 SBC HL,DE
C589 RET Z Return if there is no more room.
C58A LD B,$20 Set the number of bytes to clear to 20.
C58C CALL ClearBytes Clear them.
C58F JR PlaceSpecialObjectsInRoom_ClearSlots Jump to PlaceSpecialObjectsInRoom_ClearSlots.
View the equivalent code in;
Prev: C515 Up: Map Next: C591