![]() |
Routines |
| Prev: 44863 | Up: Map | Next: 45018 |
|
Used by the routine at Draw_Room.
Sets up the objects of a room that is in the lower part of the map (the room y is 16 or more) when the room is drawn.
The two decoration records that start at Object_Record_10 are emptied. The two before them are emptied too, unless they hold a bubble. What happens next depends on the first byte of the world map entry of the room (see Draw_Ceiling).
A room with both a ceiling and a floor gets a plant and a rock. Their x positions come from the table at Room_Object_X_Positions, and the rock is one of the four templates at Rock_Templates.
A room with no floor gets the objects that are set up by Set_Up_Stalactites. A room with a floor but no ceiling gets the two objects of type 84 that start at Spikes_Templates.
|
||||
| Set_Up_Room_Objects | 44886 | CALL Read_World_Map | Read the world map entry of the room. The flags of the room are returned in E. | |
| 44889 | XOR A | Clear the type of the first room object record (Object_Record_10). | ||
| 44890 | LD (36762),A | |||
| 44893 | LD (36778),A | Clear the type of the second room object record (Object_Record_11). | ||
| 44896 | LD A,(36730) | Fetch the type of the record at Object_Record_8. | ||
| 44899 | AND %11111100 | Ignore the low two bits. | ||
| 44901 | CP 88 | Jump to Set_Up_Room_Objects_Next_Record if the record holds a bubble (88 to 91). | ||
| 44903 | JR Z,Set_Up_Room_Objects_Next_Record | |||
| 44905 | XOR A | Write 0 to the type of the record at Object_Record_8. | ||
| 44906 | LD (36730),A | |||
| Set_Up_Room_Objects_Next_Record | 44909 | LD A,(36746) | Fetch the type of the record at Object_Record_9. | |
| 44912 | AND %11111100 | Ignore the low two bits. | ||
| 44914 | CP 88 | Jump to Set_Up_Room_Objects_Test_Flags if the record holds a bubble. | ||
| 44916 | JR Z,Set_Up_Room_Objects_Test_Flags | |||
| 44918 | XOR A | Write 0 to the type of the record at Object_Record_9. | ||
| 44919 | LD (36746),A | |||
| Set_Up_Room_Objects_Test_Flags | 44922 | LD A,E | Copy the flags of the room to A. | |
| 44923 | AND %00010001 | Keep only the ceiling bit (bit 0) and the floor bit (bit 4). | ||
| 44925 | CP 17 | Jump to Set_Up_Room_Objects_Test_Floor if the room does not have both. | ||
| 44927 | JR NZ,Set_Up_Room_Objects_Test_Floor | |||
|
Put a plant and a rock in the room. The x positions come from the table at Room_Object_X_Positions, starting at an offset that is the sum of the room coordinates, modulo 16.
|
||||
| 44929 | LD A,(36636) | Fetch the room x of Sabreman. | ||
| 44932 | LD L,A | Copy it to L. | ||
| 44933 | LD A,(36638) | Fetch the room y of Sabreman. | ||
| 44936 | ADD A,L | Add the room x. | ||
| 44937 | LD H,0 | Clear the high byte of the offset. | ||
| 44939 | AND %00001111 | Keep only the low four bits. | ||
| 44941 | LD L,A | Store the offset in L. | ||
| 44942 | LD DE,46935 | Point at the table of x positions (Room_Object_X_Positions). | ||
| 44945 | ADD HL,DE | Add the offset. | ||
| 44946 | EX DE,HL | Move the table address to DE. | ||
| 44947 | LD HL,36731 | Point at the x position of the record (Object_Record_8_X_Position). | ||
| 44950 | LD A,(DE) | Fetch the x position of the plant from the table. | ||
| 44951 | LD (HL),A | Store it in the record. | ||
| 44952 | INC DE | Move on to the x position of the rock. | ||
| 44953 | LD HL,36733 | Point at the y position of the record (Object_Record_8_Y_Position). | ||
| 44956 | LD (HL),159 | Set the y position to 159 which is the floor. | ||
| 44958 | LD HL,36730 | Point at the type of the record (Object_Record_8). | ||
| 44961 | LD (HL),28 | Set the type to 28 (a plant). | ||
| 44963 | LD HL,36745 | Point at the redraw flags of the record (Object_Record_8_Redraw_Flags). | ||
| 44966 | LD (HL),1 | Set the redraw flags to 1 so that the plant is drawn without being erased. | ||
| 44968 | PUSH DE | Stash the table address on the stack. | ||
| 44969 | LD DE,46955 | Point at the templates of the rocks (Rock_Templates). | ||
| 44972 | LD A,(36636) | Fetch the room x of Sabreman. | ||
| 44975 | LD C,A | Copy it to C. | ||
| 44976 | RLA | Multiply it by sixteen (rotate left four times). | ||
| 44977 | RLA | |||
| 44978 | RLA | |||
| 44979 | RLA | |||
| 44980 | AND %00110000 | Keep only bits 4 and 5, which pick one of the four templates. | ||
| 44982 | LD L,A | Store the offset of the template in L. | ||
| 44983 | LD H,0 | Clear the high byte of the offset. | ||
| 44985 | ADD HL,DE | Add the address of the first template. | ||
| 44986 | LD DE,36762 | DE=Object_Record_10 (the first decoration record that is for a room object). | ||
| 44989 | LD A,C | Copy the room x to A (this is not used). | ||
| 44990 | LD BC,16 | Set the size of a record to 16. | ||
| 44993 | LDIR | Copy the template into the record. | ||
| 44995 | POP DE | Restore the table address from the stack. | ||
| 44996 | LD A,(DE) | Fetch the x position of the rock from the table. | ||
| 44997 | LD (36763),A | Store it in the record. | ||
| 45000 | RET | Return. | ||
| Set_Up_Room_Objects_Test_Floor | 45001 | BIT 4,E | Jump to Set_Up_Stalactites if the room has no floor. | |
| 45003 | JP Z,Set_Up_Stalactites | |||
|
The room has a floor but no ceiling.
|
||||
| 45006 | LD HL,47019 | HL=Spikes_Templates (the templates of the two objects of type 84). | ||
| 45009 | LD DE,36762 | DE=Object_Record_10 (the first decoration record that is for a room object). | ||
| 45012 | LD BC,32 | Set the size of two records to 32. | ||
| 45015 | LDIR | Copy the templates into the two records. | ||
| 45017 | RET | Return. | ||
| Prev: 44863 | Up: Map | Next: 45018 |