Prev: 50453 Up: Map Next: 50577
50469: 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 5, the height of 12 and the flags for drawing and for being able to move. The address of the entry is kept at 16 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 50469 LD DE,23624 Point DE at the first special object of the room, ObjectsTable_FirstSpecial.
50472 EXX Switch to the alternate registers to keep it there.
50473 LD IY,28658 Point IY at SpecialObjectsTable.
50477 LD B,(IX+8) Fetch the room that the player is in.
PlaceSpecialObjectsInRoom_TestEntry 50480 LD A,(IY+0) Fetch the graphic number of the entry.
50483 AND A Test whether there is an object.
50484 JR Z,PlaceSpecialObjectsInRoom_NextEntry Jump to PlaceSpecialObjectsInRoom_NextEntry if there is not.
50486 LD A,(IY+8) Fetch the room that the object is in.
50489 CP B Compare it with the room that the player is in.
50490 JR NZ,PlaceSpecialObjectsInRoom_NextEntry Jump to PlaceSpecialObjectsInRoom_NextEntry if they are different.
50492 PUSH IY Stash the address of the entry on the stack.
50494 EXX Switch back to the registers that hold the address of the special object of the room.
50495 POP HL Restore the address of the entry from the stack.
50496 PUSH HL Stash it again on the stack.
50497 LD A,(HL) Fetch the graphic number.
50498 INC HL Move on to the starting position.
50499 LD (DE),A Set the graphic number of the special object of the room.
50500 INC DE Move on to the X coordinate.
50501 INC HL Point HL at the current position of the object.
50502 INC HL
50503 INC HL
50504 INC HL
50505 LD BC,3 Set the number of bytes to copy to 3.
50508 LDIR Copy the coordinates.
50510 EX DE,HL Point HL at the width of the special object of the room.
50511 LD (HL),5 Set the width to 5.
50513 INC HL Move on to the depth.
50514 LD (HL),5 Set the depth to 5.
50516 INC HL Move on to the height.
50517 LD (HL),12 Set the height to 12.
50519 INC HL Move on to the flags.
50520 LD (HL),20 Set the flags to draw and to be able to move.
50522 INC HL Move on to the room.
50523 EX DE,HL Point HL at the room of the entry and DE at the room of the special object of the room.
50524 LD A,(HL) Fetch the room.
50525 INC HL Move on to the next byte.
50526 LD (DE),A Set the room.
50527 INC DE Move on to the speeds.
50528 LD B,7 Set the number of bytes to clear to 7.
50530 CALL ClearBytes Clear them.
50533 POP BC Restore the address of the entry from the stack.
50534 LD A,C Fetch the low byte.
50535 LD (DE),A Store it.
50536 INC DE Move on to the high byte.
50537 LD A,B Fetch the high byte.
50538 LD (DE),A Store it.
50539 INC DE Move on.
50540 LD B,14 Set the number of bytes to clear to 14.
50542 CALL ClearBytes Clear them.
50545 EXX Switch to the alternate registers.
PlaceSpecialObjectsInRoom_NextEntry 50546 LD DE,9 Set DE to the size of an entry.
50549 ADD IY,DE Point IY at the next entry.
50551 PUSH IY Copy IY to HL (using the stack).
50553 POP HL
50554 LD DE,28946 Point DE at the end of the table, SpriteTable.
50557 AND A Subtract the address of the end of the table.
50558 SBC HL,DE
50560 JR C,PlaceSpecialObjectsInRoom_TestEntry Jump to PlaceSpecialObjectsInRoom_TestEntry until all of the entries have been done.
50562 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 50563 LD HL,23688 Point HL at the end of the special objects of the room, ObjectsTable_RoomObjects.
50566 AND A Subtract the address of the object that is next.
50567 SBC HL,DE
50569 RET Z Return if there is no more room.
50570 LD B,32 Set the number of bytes to clear to 32.
50572 CALL ClearBytes Clear them.
50575 JR PlaceSpecialObjectsInRoom_ClearSlots Jump to PlaceSpecialObjectsInRoom_ClearSlots.
View the equivalent code in;
Prev: 50453 Up: Map Next: 50577