Prev: 37510 Up: Map Next: 37592
37521: Draw Room Entities
Used by the routine at DrawRoom.
Draws every entity that is in the same room as the player and is in use. First the 8-byte entities from Player up to CreatureRecords are done, and then the 16-byte ones up to RoomItemEntities.
DrawRoomEntities 37521 LD IX,60048 Point IX at the player at Player.
DrawRoomEntities_Loop 37525 LD A,(IX+0) Fetch the sprite ID of the entity.
37528 AND A Jump to DrawRoomEntities_Next if the entity is not in use.
37529 JR Z,DrawRoomEntities_Next
37531 LD A,(60049) Fetch the room of the player from PlayerRoom.
37534 CP (IX+1) Jump to DrawRoomEntities_Next if the entity is in a different room.
37537 JR NZ,DrawRoomEntities_Next
37539 CALL DrawEntity Call DrawEntity to draw the entity.
DrawRoomEntities_Next 37542 LD DE,8 DE=0008 (the size of an 8-byte entity).
37545 ADD IX,DE Move IX on to the next entity.
37547 PUSH IX Copy IX into HL.
37549 POP HL
37550 LD DE,61024 Point DE at the end of the 8-byte entities at CreatureRecords.
37553 AND A Subtract DE from HL, to check whether all of the 8-byte entities have been done.
37554 SBC HL,DE
37556 JR C,DrawRoomEntities_Loop Loop back to DrawRoomEntities_Loop until all of the 8-byte entities have been drawn.
DrawRoomEntities_Large 37558 LD A,(IX+0) Fetch the sprite ID of the entity.
37561 AND A Jump to DrawRoomEntities_NextLarge if the entity is not in use.
37562 JR Z,DrawRoomEntities_NextLarge
37564 LD A,(60049) Fetch the room of the player from PlayerRoom.
37567 CP (IX+1) Jump to DrawRoomEntities_NextLarge if the entity is in a different room.
37570 JR NZ,DrawRoomEntities_NextLarge
37572 CALL DrawEntity Call DrawEntity to draw the entity.
DrawRoomEntities_NextLarge 37575 LD DE,16 DE=0016 (the size of a 16-byte entity).
37578 ADD IX,DE Move IX on to the next entity.
37580 PUSH IX Copy IX into HL.
37582 POP HL
37583 LD DE,61152 Point DE at the end of the 16-byte entities at RoomItemEntities.
37586 AND A Subtract DE from HL, to check whether all of the 16-byte entities have been done.
37587 SBC HL,DE
37589 JR C,DrawRoomEntities_Large Loop back to DrawRoomEntities_Large until all of the 16-byte entities have been drawn.
37591 RET Return.
Prev: 37510 Up: Map Next: 37592