![]() |
Routines |
| Prev: 30866 | Up: Map | Next: 31012 |
|
Controls the paratrooper after landing. The paratrooper walks left and right along a platform, and will leap upward to try to catch Percy if he flies directly overhead. The paratrooper jumps up by 2 pixels per frame to a maximum height of 16 then drops back down to his platform. Walking speed and boundaries vary per room.
|
||||||||
|
Set up the paratrooper state pointer and movement parameters.
|
||||||||
| Handler_Walking_Paratrooper | 30867 | LD IY,31501 | Point IY at Paratrooper_State_Data (paratrooper state data). | |||||
| 30871 | LD HL,31016 | Point HL at Table_ParatrooperSpeed (per-room walking speed table). | ||||||
| 30874 | LD A,(24517) | Fetch the current room from *CurrentRoom, decrement to form a zero-based index and load the walking speed for this room into B. | ||||||
| 30877 | DEC A | |||||||
| 30878 | LD D,0 | |||||||
| 30880 | LD E,A | |||||||
| 30881 | ADD HL,DE | |||||||
| 30882 | LD B,(HL) | |||||||
| 30883 | LD HL,31013 | Point HL at Paratrooper_Direction_Flag (paratrooper movement boundary data). | ||||||
|
||||||||
| 30886 | LD C,83 | Set the base sprite frame in C to 83 (paratrooper walking right). | ||||||
| 30888 | LD A,(24517) | Fetch the current room from *CurrentRoom, decrement and multiply by 4 to index into the state data; add offset to IY. | ||||||
| 30891 | DEC A | |||||||
| 30892 | ADD A,A | |||||||
| 30893 | ADD A,A | |||||||
| 30894 | LD E,A | |||||||
| 30895 | LD D,0 | |||||||
| 30897 | ADD IY,DE | |||||||
|
Check if the paratrooper needs to reset after Percy respawns.
|
||||||||
| 30899 | LD A,(24507) | Skip to Check_Paratrooper_Leap_State if *RespawnFlag is unset. | ||||||
| 30902 | OR A | |||||||
| 30903 | JR Z,Check_Paratrooper_Leap_State | |||||||
| 30905 | XOR A | Write 0 to reset *Paratrooper_Leap_State (set the leap state to idle). | ||||||
| 30906 | LD (31015),A | |||||||
|
Check the current leap state to determine behaviour.
|
||||||||
| Check_Paratrooper_Leap_State | 30909 | LD A,(31015) | Jump to Process_Paratrooper_Leap if *Paratrooper_Leap_State (leap state) is non-zero (already leaping). | |||||
| 30912 | OR A | |||||||
| 30913 | JR NZ,Process_Paratrooper_Leap | |||||||
|
Paratrooper is idle; check if Percy is flying directly overhead to trigger a leap.
|
||||||||
| 30915 | LD A,(56000) | Compare Percy's X position against the paratrooper's X position. | ||||||
| 30918 | AND %11111100 | |||||||
| 30920 | LD E,A | |||||||
| 30921 | LD A,(IX+0) | |||||||
| 30924 | AND %11111100 | |||||||
| 30926 | CP E | |||||||
| 30927 | JP NZ,Cat_Entry | Jump to Cat_Entry if they don't match. | ||||||
| 30930 | LD A,(56001) | Jump to Cat_Entry if Percy's Y position is less than 40 (too high above) or greater than or equal to the paratrooper's Y position (Percy is not above the paratrooper). | ||||||
| 30933 | CP 40 | |||||||
| 30935 | JP C,Cat_Entry | |||||||
| 30938 | CP (IX+1) | |||||||
| 30941 | JP NC,Cat_Entry | |||||||
| 30944 | XOR A | Set A to 0 (begin new leap). | ||||||
|
Process the leap movement based on the current state.
|
||||||||
| Process_Paratrooper_Leap | 30945 | BIT 7,A | Jump to Paratrooper_Descending if bit 7 of the leap state is set (paratrooper is descending back down). | |||||
| 30947 | JR NZ,Paratrooper_Descending | |||||||
|
Paratrooper is leaping upward.
|
||||||||
| 30949 | ADD A,2 | Add 2 to the leap state. | ||||||
| 30951 | CP 16 | Skip to Continue_Paratrooper_Leap if the leap state is still less than the maximum height (16). | ||||||
| 30953 | JR NZ,Continue_Paratrooper_Leap | |||||||
| 30955 | SET 7,A | Else the leap state has reached 16 (maximum height), set bit 7 to begin descending and jump to Store_Paratrooper_Leap_State. | ||||||
| 30957 | JR Store_Paratrooper_Leap_State | |||||||
| Continue_Paratrooper_Leap | 30959 | LD (31015),A | Write the updated leap state to *Paratrooper_Leap_State. | |||||
| 30962 | LD D,A | Calculate the paratrooper's new Y position by subtracting the leap height from the platform Y position at *IY+1; write to *IX+1. | ||||||
| 30963 | LD A,(IY+1) | |||||||
| 30966 | SUB D | |||||||
| 30967 | LD (IX+1),A | |||||||
| 30970 | JR Paratrooper_Walk_Or_Stunned | Jump to Paratrooper_Walk_Or_Stunned. | ||||||
|
Paratrooper is descending back to his platform.
|
||||||||
| Paratrooper_Descending | 30972 | LD E,A | Copy the leap state into E. | |||||
| 30973 | AND %01111111 | Keep only bits 0-6. | ||||||
| 30975 | DEC A | Decrease the descent counter by one. | ||||||
| 30976 | JR Z,Paratrooper_Leap_Complete | Jump to Paratrooper_Leap_Complete if the descent counter has reached zero (back on platform). | ||||||
| 30978 | LD D,A | Calculate the paratrooper's new Y position by subtracting the remaining height from the platform Y position; write to *IX+1. | ||||||
| 30979 | LD A,(IY+1) | |||||||
| 30982 | SUB D | |||||||
| 30983 | LD (IX+1),A | |||||||
| 30986 | LD A,E | Decrement the leap state and write it back to *Paratrooper_Leap_State. | ||||||
| 30987 | DEC A | |||||||
| 30988 | LD (31015),A | |||||||
| 30991 | JR Paratrooper_Walk_Or_Stunned | Jump to Paratrooper_Walk_Or_Stunned. | ||||||
|
Leap is complete; reset to idle.
|
||||||||
| Paratrooper_Leap_Complete | 30993 | XOR A | Write 0 to *Paratrooper_Leap_State (return to idle state). | |||||
| 30994 | LD (31015),A | |||||||
| 30997 | JR Paratrooper_Walk_Or_Stunned | Jump to Paratrooper_Walk_Or_Stunned. | ||||||
| Store_Paratrooper_Leap_State | 30999 | LD (31015),A | Write the leap state to *Paratrooper_Leap_State. | |||||
|
Resume the paratrooper's walking animation or handle stunned state.
|
||||||||
| Paratrooper_Walk_Or_Stunned | 31002 | BIT 7,(IY+0) | Jump to Animate_Stunned_Hazard if bit 7 of *IY+0 is set (paratrooper is stunned by egg). | |||||
| 31006 | JP NZ,Animate_Stunned_Hazard | |||||||
| 31009 | JP Update_Cat_Frame | Jump to Update_Cat_Frame to update the walking animation frame and check for collisions. | ||||||
| Prev: 30866 | Up: Map | Next: 31012 |