Prev: 9597 Up: Map Next: 9878
9836: Populate primary display buffer with layout data for current character's current room
Used by the routine at GameStart.
PopulatePrimaryDisplay_LayoutData 9836 LD HL,($6DC6) Self-modifying code; alter the value for the LD HL instruction at 98C8 with the address at PrimaryDisplayBuffer.
9839 LD ($98C9),HL
983C LD A,($6D9F) Load C with TempStore_RoomDimension_Depth.
983F LD C,A
9840 LD A,($6D8A) Load B with CurrentRoomIndex.
9843 LD B,A
9844 LD D,$00 Load D with 00.
Start drawing simple entities.
DrawSimpleEntities 9846 LD IX,($6D6F) Load IX with the start address of StateData_SimpleEntities.
984A LD E,$06 Load DE with 06 (as simple state data entries are 06 bytes wide).
DrawSimpleEntities_Loop 984C LD A,(IX+$00) Load first byte of current simple state data entry into A.
984F CP $FF If this is FF (end marker for complex state data) then skip ahead to DecreaseDepth.
9851 JR Z,DecreaseDepth
9853 CP $FE If it is not FE (end marker for simple state data) then skip ahead to PopulatePrimaryDisplay_LayoutData_0.
9855 JR NZ,PopulatePrimaryDisplay_LayoutData_0
9857 SLA E
9859 INC IX Advance IX to start of complex state data block.
985B LD A,(IX+$00) Load A with entity's room index.
At this point, A holds the index of the room to which the simple or complex entity belongs.
PopulatePrimaryDisplay_LayoutData_0 985E CP B If entity's room is not the same as the current character's current room then skip ahead to PrimaryDisplay_NextData.
985F JR NZ,PrimaryDisplay_NextData
9861 LD A,C If entity's depth is not the same as current depth in C then skip ahead to PrimaryDisplay_NextData.
9862 CP (IX+$01)
9865 JR NZ,PrimaryDisplay_NextData
9867 EXX Switch to the shadow registers.
9868 PUSH IX Stash IX on the stack.
986A CALL $9878 Call 9878.
986D POP IX Restore IX from the stack.
986F EXX Switch back to the normal registers.
PrimaryDisplay_NextData 9870 ADD IX,DE Advance IX to next entity's state data.
9872 JR DrawSimpleEntities_Loop Loop back to DrawSimpleEntities_Loop.
DecreaseDepth 9874 DEC C Decrease current depth (i.e. closer to screen).
9875 JR NZ,DrawSimpleEntities If depth is not zero (i.e. still depth levels to process) then loop back to DrawSimpleEntities.
9877 RET Return.
Prev: 9597 Up: Map Next: 9878