Prev: 58410 Up: Map Next: 59165
59099: Populate Display Buffer For Visible Entities
Used by the routine at GameStart.
Walk the simple entity table at StateData_SimpleEntities and process graphic layout data for each visible entity into the current display buffer.
Walk rooms 0–5 and draw every on-camera entity into the current display buffer.
PopulateDisplayBuffer_VisibleEntities 59099 LD C,0 Clear the room-pass index in C to 0.
Start a room-pass over the simple entity table at StateData_SimpleEntities.
PopulateVisible_StartRoomPass 59101 LD IX,35689 Point IX at the simple entity table (StateData_SimpleEntities).
59105 LD DE,14 Load DE with 0014.
Draw each visible entity whose room and camera-window x-band match this pass.
PopulateDisplayBuffer_VisibleEntitiesContinue 59108 LD A,(IX+0) Fetch the current entity's type for the type test.
59111 CP 255 Is A equal to 255? If so, jump to PopulateDisplayBuffer_VisibleEntitiesContinueB2.
59113 JR Z,PopulateDisplayBuffer_VisibleEntitiesContinueB2
59115 OR A Is A zero? If so, jump to PopulateDisplayBuffer_VisibleEntitiesContinueB.
59116 JR Z,PopulateDisplayBuffer_VisibleEntitiesContinueB
59118 BIT 7,A Is bit 7 of A set? If so, jump to PopulateDisplayBuffer_VisibleEntitiesContinueB.
59120 JR NZ,PopulateDisplayBuffer_VisibleEntitiesContinueB
59122 LD A,C Copy the saved count/flag from C into A.
59123 CP (IX+4) Does the candidate share this entity's room? If not, jump to PopulateDisplayBuffer_VisibleEntitiesContinueB.
59126 JR NZ,PopulateDisplayBuffer_VisibleEntitiesContinueB
59128 LD HL,(29435) Load HL with the camera room-origin pointer (Pointer_CameraRoomOrigin).
59131 LD A,H Copy H into A.
59132 CP (IX+7) Is the camera origin's high byte left of this entity's x? If so, jump to PopulateDisplayBuffer_VisibleEntitiesContinueB.
59135 JR C,PopulateDisplayBuffer_VisibleEntitiesContinueB
59137 LD A,(IX+8) Load A with the current entity's x-extent.
59140 CP L Is this entity's x-extent left of the camera origin's low byte in L? If so, jump to PopulateDisplayBuffer_VisibleEntitiesContinueB.
59141 JR C,PopulateDisplayBuffer_VisibleEntitiesContinueB
59143 PUSH DE Stash DE, BC and IX on the stack.
59144 PUSH BC
59145 PUSH IX
59147 CALL Process_GraphicLayoutData_Entity Call Process_GraphicLayoutData_Entity to draw the entity's graphic layout.
59150 POP IX Restore IX, BC and DE from the stack.
59152 POP BC
59153 POP DE
Advance to the next simple-entity record and keep scanning this room pass.
PopulateDisplayBuffer_VisibleEntitiesContinueB 59154 ADD IX,DE IX+=DE.
59156 JR PopulateDisplayBuffer_VisibleEntitiesContinue Jump to PopulateDisplayBuffer_VisibleEntitiesContinue to continue this routine.
Bump the room-pass index; return when it passes 5, otherwise restart at PopulateVisible_StartRoomPass.
PopulateDisplayBuffer_VisibleEntitiesContinueB2 59158 LD A,5 Load A with 5 (last room index).
59160 INC C Advance the room-pass index in C by one.
59161 CP C Return if the room-pass index is now greater than 5.
59162 RET C
59163 JR PopulateVisible_StartRoomPass Jump to PopulateVisible_StartRoomPass to continue the loop.
Prev: 58410 Up: Map Next: 59165