Prev: E6BE Up: Map Next: E741
E6EE: 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 18 and the first table of template pointers at Stalactite_Template_Pointers, and the second one with the smallest x position A0 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 E6EE 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.
E6F1 PUSH HL Stash the address of the entry.
E6F2 AND A Jump to Set_Up_Stalactites_Generate if the room has not been visited before.
E6F3 JR Z,Set_Up_Stalactites_Generate
Set_Up_Stalactites_Build E6F5 LD B,A Store the byte that describes the first stalactite in B.
E6F6 AND %00000110 Keep only bits 1 and 2, which give the template number.
E6F8 LD C,$18 Set the smallest x position to 18.
E6FA LD HL,$E741 Point HL at Stalactite_Template_Pointers.
E6FD LD DE,$8F9A Point DE at Object_Record_10.
E700 CALL Build_Stalactite Build the first stalactite.
E703 POP HL Restore the address of the entry to HL.
E704 INC HL Move on to the second byte.
E705 LD A,(HL) Fetch the byte that describes the second stalactite.
E706 LD B,A Store it in B.
E707 AND %00000110 Keep only bits 1 and 2, which give the template number.
E709 LD C,$A0 Set the smallest x position to A0.
E70B LD HL,$E749 Point HL at Stalactite_Template_Pointers_Right.
E70E LD DE,$8FAA Point DE at Object_Record_11.
E711 JP Build_Stalactite Jump to Build_Stalactite.
Make up the two bytes for a room that has not been visited.
Set_Up_Stalactites_Generate E714 LD A,($8ED6) Fetch the tick counter.
E717 OR %00000001 Set bit 0.
E719 BIT 2,A Jump to Set_Up_Stalactites_Check_Left_Wall if it is set.
E71B JR NZ,Set_Up_Stalactites_Check_Left_Wall
E71D LD A,B Fetch B.
E71E AND %11001111 Reset bits 4 and 5.
Set_Up_Stalactites_Check_Left_Wall E720 BIT 6,E Jump to Set_Up_Stalactites_Store_First if the room has a wall on the left.
E722 JR NZ,Set_Up_Stalactites_Store_First
E724 OR %10100100 Set bits 2, 5 and 7.
Set_Up_Stalactites_Store_First E726 LD (HL),A Store the first byte of the entry.
E727 LD A,($5C78) Fetch the low byte of FRAMES.
E72A AND %11111110 Reset bit 0.
E72C INC HL Move on to the second byte of the entry.
E72D BIT 2,A Jump to Set_Up_Stalactites_Check_Right_Wall if it is set.
E72F JR NZ,Set_Up_Stalactites_Check_Right_Wall
E731 LD A,B Fetch B.
E732 OR %00110000 Set bits 4 and 5.
Set_Up_Stalactites_Check_Right_Wall E734 BIT 2,E Jump to Set_Up_Stalactites_Store_Second if the room has a wall on the right.
E736 JR NZ,Set_Up_Stalactites_Store_Second
E738 OR %10000100 Set bits 2 and 7.
E73A AND %11011111 Reset bit 5.
Set_Up_Stalactites_Store_Second E73C LD (HL),A Store the second byte of the entry.
E73D DEC HL Move back to the first byte of the entry.
E73E LD A,(HL) Fetch the first byte of the entry.
E73F JR Set_Up_Stalactites_Build Jump to Set_Up_Stalactites_Build to build the stalactites.
Prev: E6BE Up: Map Next: E741