![]() |
Routines |
| Prev: DF58 | Up: Map | Next: E027 |
|
Handler for the object type 50 a stalactite that falls from the ceiling towards Sabreman (see Spawn_Falling_Stalactite).
The y velocity (byte 09) goes up by two on every call, to a limit of 6D and the y position and its fraction (byte 0D) change by sixteen times the velocity. The stalactite lands on a decoration if it touches the top of one near the middle of it. It lands on the floor if the room has one, and if the room has no floor it falls into the room below. When it lands it becomes the type 51 (see Handle_Rock_Fragments) and is not a stalactite any more.
If Sabreman is not in the room the stalactite carries on falling but is not drawn. The countdown in byte 0A which is reset to 50 while Sabreman is in the room, removes it when he has been away for long enough.
|
||||||||
| Handle_Falling_Stalactite | DF98 | CALL StoreEntity | Save the state of the stalactite. | |||||
| DF9B | LD A,(IX+$09) | Fetch the y velocity. | ||||||
| DF9E | ADD A,$02 | Add two to the y velocity, as gravity pulls the stalactite down. | ||||||
| DFA0 | CP $6E | Jump to Handle_Falling_Stalactite_Move if the stalactite is falling at full speed (the y velocity has reached 6E). | ||||||
| DFA2 | JR NC,Handle_Falling_Stalactite_Move | |||||||
| DFA4 | LD (IX+$09),A | Store the y velocity. | ||||||
| Handle_Falling_Stalactite_Move | DFA7 | LD L,(IX+$09) | Fetch the y velocity into L. | |||||
| DFAA | LD H,$00 | Clear the high byte of the y velocity (as a word). | ||||||
| DFAC | ADD HL,HL | Multiply the y velocity by sixteen. | ||||||
| DFAD | ADD HL,HL | |||||||
| DFAE | ADD HL,HL | |||||||
| DFAF | ADD HL,HL | |||||||
| DFB0 | LD C,(IX+$0D) | Fetch the fraction of the y position. | ||||||
| DFB3 | LD B,(IX+$03) | Fetch the y position. | ||||||
| DFB6 | ADD HL,BC | Add the y velocity. | ||||||
| DFB7 | LD (IX+$0D),L | Store the new fraction of the y position. | ||||||
| DFBA | LD (IX+$03),H | Store the new y position. | ||||||
| DFBD | CALL Read_World_Map | Read the world map entry of the room that the stalactite is in. The flags of the room are returned in E. | ||||||
| DFC0 | LD A,E | Copy the flags of the room to A. | ||||||
| DFC1 | AND %00010000 | Keep only bit 4 (the floor). | ||||||
| DFC3 | LD A,H | Fetch the new y position. | ||||||
| DFC4 | JR Z,Handle_Falling_Stalactite_No_Floor | Jump to Handle_Falling_Stalactite_No_Floor if the room has no floor. | ||||||
| DFC6 | CP $9F | Jump to Handle_Falling_Stalactite_Land_On_Floor if the stalactite has reached the floor. | ||||||
| DFC8 | JR NC,Handle_Falling_Stalactite_Land_On_Floor | |||||||
| DFCA | JR Handle_Falling_Stalactite_Check_Decorations | Jump to Handle_Falling_Stalactite_Check_Decorations. | ||||||
| Handle_Falling_Stalactite_No_Floor | DFCC | CP $BF | Jump to Handle_Falling_Stalactite_Next_Room if the stalactite has fallen out of the bottom of the room. | |||||
| DFCE | JP NC,Handle_Falling_Stalactite_Next_Room | |||||||
| Handle_Falling_Stalactite_Check_Decorations | DFD1 | CALL Check_Decoration_Contact | Check for contact with the decorations. | |||||
| DFD4 | BIT 1,C | Jump to Handle_Falling_Stalactite_Check_Room if the stalactite is not on top of a decoration. | ||||||
| DFD6 | JR Z,Handle_Falling_Stalactite_Check_Room | |||||||
| DFD8 | BIT 0,C | Jump to Handle_Falling_Stalactite_Check_Room if the stalactite is not near the middle of the decoration. | ||||||
| DFDA | JR NZ,Handle_Falling_Stalactite_Check_Room | |||||||
| DFDC | LD A,B | Copy A0 less the y position of the top of the decoration to A. | ||||||
| DFDD | NEG | Negate it. | ||||||
| DFDF | ADD A,$A1 | Add A1 to get the y position just below the top of the decoration. | ||||||
| DFE1 | JR Handle_Falling_Stalactite_Shatter | Jump to Handle_Falling_Stalactite_Shatter. | ||||||
| Handle_Falling_Stalactite_Land_On_Floor | DFE3 | LD A,(IX+$03) | Fetch the y position. | |||||
| DFE6 | AND %11111000 | Round it down to a multiple of eight. | ||||||
| DFE8 | DEC A | Subtract one. | ||||||
| Handle_Falling_Stalactite_Shatter | DFE9 | LD (IX+$03),A | Store the y position. | |||||
| DFEC | LD (IX+$00),$51 | Change the stalactite into the first piece of rock. | ||||||
| DFF0 | LD (IX+$06),$00 | Reset the counter in byte 06. | ||||||
| Handle_Falling_Stalactite_Check_Room | DFF4 | LD A,($8F1C) | Fetch the room x of Sabreman. | |||||
| DFF7 | CP (IX+$02) | Jump to Handle_Falling_Stalactite_Count_Down if the stalactite is in a different room x. | ||||||
| DFFA | JP NZ,Handle_Falling_Stalactite_Count_Down | |||||||
| DFFD | LD A,($8F1E) | Fetch the room y of Sabreman. | ||||||
| E000 | CP (IX+$04) | Jump to Handle_Falling_Stalactite_Count_Down if the stalactite is in a different room y. | ||||||
| E003 | JP NZ,Handle_Falling_Stalactite_Count_Down | |||||||
| E006 | LD (IX+$0A),$50 | Reset the countdown to 50. | ||||||
| E00A | JP Update_Object_Sprite | Jump to Update_Object_Sprite. | ||||||
| Handle_Falling_Stalactite_Next_Room | E00D | LD (IX+$03),$40 | Set the y position to 40. | |||||
| E011 | INC (IX+$04) | Move the stalactite to the room below. | ||||||
| E014 | BIT 0,(IX+$0F) | Return if the stalactite has not been drawn yet. | ||||||
| E018 | RET NZ | |||||||
| E019 | JP RemoveEntity | Erase the sprite of the stalactite. | ||||||
| Handle_Falling_Stalactite_Count_Down | E01C | DEC (IX+$0A) | Decrease the countdown and jump to Remove_Unseen_Weapon to remove the stalactite when it reaches zero. | |||||
| E01F | JP Z,Remove_Unseen_Weapon | |||||||
| E022 | SET 0,(IX+$0F) | Set bit 0 of the redraw flags, as the stalactite is not on the screen. | ||||||
| E026 | RET | Return. | ||||||
| Prev: DF58 | Up: Map | Next: E027 |