Prev: 59070 Up: Map Next: 59201
59118: Set Up Stalactites
Used by the routine at Set_Up_Room_Objects.
Sets up the two stalactites of a cave room that has no floor when the room is drawn (see Set_Up_Room_Objects). The stalactites are the records at Object_Record_10 and Object_Record_11.
Each stalactite is described by one byte, and these are the two bytes of the entry of the room in the room visit table (see Room_Visit_Table). If the first byte is zero the room has not been visited before, so both bytes are made up.
The first byte is the tick counter with bit 0 set, if bit 2 of that value is set, or otherwise B with bits 4 and 5 reset (B is whatever the routines that drew the room frame left in it). If the room has no wall on the left, bits 2, 5 and 7 are set. The second byte is the low byte of FRAMES with bit 0 reset, if bit 2 of that value is set, or otherwise B with bits 4 and 5 set. If the room has no wall on the right, bits 2 and 7 are set and bit 5 is reset.
The first stalactite is built with the smallest x position 24 and the first table of template pointers at Stalactite_Template_Pointers, and the second one with the smallest x position 160 and the second table at Stalactite_Template_Pointers_Right. Both are built by Build_Stalactite.
Input
E Flags of the room
IX Object record of Sabreman
Set_Up_Stalactites 59118 CALL Read_Room_State Read the entry of the room in the room visit table. HL holds the address of the entry and A the first byte.
59121 PUSH HL Stash the address of the entry.
59122 AND A Jump to Set_Up_Stalactites_Generate if the room has not been visited before.
59123 JR Z,Set_Up_Stalactites_Generate
Set_Up_Stalactites_Build 59125 LD B,A Store the byte that describes the first stalactite in B.
59126 AND %00000110 Keep only bits 1 and 2, which give the template number.
59128 LD C,24 Set the smallest x position to 24.
59130 LD HL,59201 Point HL at Stalactite_Template_Pointers.
59133 LD DE,36762 Point DE at Object_Record_10.
59136 CALL Build_Stalactite Build the first stalactite.
59139 POP HL Restore the address of the entry to HL.
59140 INC HL Move on to the second byte.
59141 LD A,(HL) Fetch the byte that describes the second stalactite.
59142 LD B,A Store it in B.
59143 AND %00000110 Keep only bits 1 and 2, which give the template number.
59145 LD C,160 Set the smallest x position to 160.
59147 LD HL,59209 Point HL at Stalactite_Template_Pointers_Right.
59150 LD DE,36778 Point DE at Object_Record_11.
59153 JP Build_Stalactite Jump to Build_Stalactite.
Make up the two bytes for a room that has not been visited.
Set_Up_Stalactites_Generate 59156 LD A,(36566) Fetch the tick counter.
59159 OR %00000001 Set bit 0.
59161 BIT 2,A Jump to Set_Up_Stalactites_Check_Left_Wall if it is set.
59163 JR NZ,Set_Up_Stalactites_Check_Left_Wall
59165 LD A,B Fetch B.
59166 AND %11001111 Reset bits 4 and 5.
Set_Up_Stalactites_Check_Left_Wall 59168 BIT 6,E Jump to Set_Up_Stalactites_Store_First if the room has a wall on the left.
59170 JR NZ,Set_Up_Stalactites_Store_First
59172 OR %10100100 Set bits 2, 5 and 7.
Set_Up_Stalactites_Store_First 59174 LD (HL),A Store the first byte of the entry.
59175 LD A,(23672) Fetch the low byte of FRAMES.
59178 AND %11111110 Reset bit 0.
59180 INC HL Move on to the second byte of the entry.
59181 BIT 2,A Jump to Set_Up_Stalactites_Check_Right_Wall if it is set.
59183 JR NZ,Set_Up_Stalactites_Check_Right_Wall
59185 LD A,B Fetch B.
59186 OR %00110000 Set bits 4 and 5.
Set_Up_Stalactites_Check_Right_Wall 59188 BIT 2,E Jump to Set_Up_Stalactites_Store_Second if the room has a wall on the right.
59190 JR NZ,Set_Up_Stalactites_Store_Second
59192 OR %10000100 Set bits 2 and 7.
59194 AND %11011111 Reset bit 5.
Set_Up_Stalactites_Store_Second 59196 LD (HL),A Store the second byte of the entry.
59197 DEC HL Move back to the first byte of the entry.
59198 LD A,(HL) Fetch the first byte of the entry.
59199 JR Set_Up_Stalactites_Build Jump to Set_Up_Stalactites_Build to build the stalactites.
Prev: 59070 Up: Map Next: 59201