![]() |
Routines |
| Prev: 37798 | Up: Map | Next: 37980 |
|
Drop a thrown platform (type 47): speed it up under gravity and move it along. When it reaches the ground line, stamp it into the terrain and free the slot.
|
||||||||
|
Increase the downward thrust by two, up to a cap of 48.
|
||||||||
| Handler_FallingPlatform | 37864 | LD A,(IX+6) | Fetch the vertical thrust. | |||||
| 37867 | CP 48 | Jump to Handler_FallingPlatform_ApplyGravity if it is already at least 48. | ||||||
| 37869 | JR NC,Handler_FallingPlatform_ApplyGravity | |||||||
| 37871 | INC (IX+6) | Increase the thrust by two. | ||||||
| 37874 | INC (IX+6) | |||||||
|
Turn the thrust into a Y movement and test for the ground.
|
||||||||
| Handler_FallingPlatform_ApplyGravity | 37877 | SRA A | Divide the thrust by 16. | |||||
| 37879 | SRA A | |||||||
| 37881 | SRA A | |||||||
| 37883 | SRA A | |||||||
| 37885 | ADD A,(IX+4) | Add it to the actor's Y position. | ||||||
| 37888 | LD (IX+4),A | Write the Y position back. | ||||||
| 37891 | CP 176 | Jump to Handler_FallingPlatform_AddSpeed if the actor is still above the ground line. | ||||||
| 37893 | JR C,Handler_FallingPlatform_AddSpeed | |||||||
|
When the actor has hit the ground, stamp tile 3 into two terrain cells.
|
||||||||
| 37895 | CALL ReadTerrainCell | Call ReadTerrainCell. | ||||||
|
Snap the actor to the ground line.
|
||||||||
| 37898 | LD A,183 | Write 183 to the actor's Y position. | ||||||
| 37900 | LD (IX+4),A | |||||||
| 37903 | LD DE,28672 | DE=TerrainData_Active. | ||||||
| 37906 | EX DE,HL | Point HL at the terrain cell. | ||||||
| 37907 | ADD HL,DE | |||||||
| 37908 | LD (HL),3 | Write tile 3 into that cell. | ||||||
|
Step to the next cell, wrapping the index, and stamp it too.
|
||||||||
| 37910 | INC DE | Move onto the next cell. | ||||||
| 37911 | LD A,D | Fetch the high byte. | ||||||
| 37912 | AND %00000011 | Keep only bits 0-1. | ||||||
| 37914 | LD D,A | Write it back to D. | ||||||
| 37915 | LD HL,28672 | Point HL at that terrain cell. | ||||||
| 37918 | ADD HL,DE | |||||||
| 37919 | LD (HL),3 | Write tile 3 into that cell. | ||||||
|
Align the actor to a character column, clear the terrain pixels beneath it and free the slot.
|
||||||||
| 37921 | LD A,(IX+2) | Fetch the low byte of the world X. | ||||||
| 37924 | AND %11111000 | Keep only bits 3-7. | ||||||
| 37926 | LD L,A | Align the world X to a character column. | ||||||
| 37927 | LD (IX+2),L | |||||||
| 37930 | CALL ClearTerrainUnderActor | Call ClearTerrainUnderActor. | ||||||
| 37933 | CALL DrawSprite | Call DrawSprite. | ||||||
| 37936 | LD (IX+0),0 | Write 0 to the actor type. | ||||||
| 37940 | RET | Return. | ||||||
|
Add the horizontal speed and redraw the actor.
|
||||||||
| Handler_FallingPlatform_AddSpeed | 37941 | LD A,(IX+5) | Fetch the horizontal speed. | |||||
| 37944 | SRA A | Divide it by 16. | ||||||
| 37946 | SRA A | |||||||
| 37948 | SRA A | |||||||
| 37950 | SRA A | |||||||
| 37952 | LD C,A | Copy the step into C and clear B. | ||||||
| 37953 | LD B,0 | |||||||
| 37955 | JP P,Handler_FallingPlatform_WriteWorldX | Jump to Handler_FallingPlatform_WriteWorldX if the step is positive. | ||||||
| 37958 | LD B,255 | Set B=255 for a negative step. | ||||||
|
Add the step to the world X and redraw the actor.
|
||||||||
| Handler_FallingPlatform_WriteWorldX | 37960 | LD L,(IX+2) | Fetch the low byte of the world X. | |||||
| 37963 | LD H,(IX+3) | Fetch the high byte of the world X. | ||||||
| 37966 | ADD HL,BC | Add the step to the world X. | ||||||
| 37967 | LD (IX+3),H | Write the high byte back. | ||||||
| 37970 | LD (IX+2),L | Write the low byte back. | ||||||
| 37973 | CALL DrawSprite | Call DrawSprite. | ||||||
| 37976 | CALL ColouriseSprite | Call ColouriseSprite. | ||||||
| 37979 | RET | Return. | ||||||
| Prev: 37798 | Up: Map | Next: 37980 |