![]() |
Routines |
| Prev: 7680 | Up: Map | Next: 7713 |
|
Used by the routine at Handler_Plane.
Controls the plane hazard. The plane flies horizontally across the screen and can drop a bomb on Percy when directly above. The plane has two flight directions and its speed varies by room. On room 03 the boundaries are adjusted. When the plane reaches the screen edge it deactivates and waits for a random trigger to respawn from the opposite side.
|
||||||||
|
Set up the plane state pointer and room-specific parameters.
|
||||||||
| Handle_Plane | 768C | LD IY,$77AF | Point IY at Plane_State_Data. | |||||
| 7690 | LD C,$04 | Set the left boundary to 04 in C. | ||||||
| 7692 | LD B,$38 | Set the right boundary to 38 in B. | ||||||
| 7694 | LD A,($5FC5) | Jump to Plane_Check_Respawn if *CurrentRoom is not equal to 03. | ||||||
| 7697 | CP $03 | |||||||
| 7699 | JR NZ,Plane_Check_Respawn | |||||||
| 769B | LD C,$40 | Set the left boundary to 40 in C. | ||||||
| 769D | LD B,C | Copy to B (both boundaries are 40 on room 03). | ||||||
| Plane_Check_Respawn | 769E | LD A,($5FBB) | Jump to Spawn_Plane if *RespawnFlag is set. | |||||
| 76A1 | OR A | |||||||
| 76A2 | JP NZ,Spawn_Plane | |||||||
| 76A5 | LD A,(IY+$02) | Jump to Plane_Wait_To_Spawn if *IY+02 (plane active flag) is zero (waiting to spawn). | ||||||
| 76A8 | OR A | |||||||
| 76A9 | JR Z,Plane_Wait_To_Spawn | |||||||
| 76AB | BIT 7,(IY+$00) | Jump to Animate_Stunned_Hazard if bit 7 of *IY+00 is set (plane is stunned by egg). | ||||||
| 76AF | JP NZ,Animate_Stunned_Hazard | |||||||
|
Plane is active; move it horizontally based on flight direction.
|
||||||||
| 76B2 | LD HL,$77B3 | Point HL at Plane_Speed. | ||||||
| 76B5 | LD A,(IX+$00) | Fetch the plane X position from *IX+00. | ||||||
| 76B8 | BIT 7,(IY+$01) | Test bit 7 of *IY+01 (flight direction); jump to Plane_Flying_Left if set (flying left). | ||||||
| 76BC | JR NZ,Plane_Flying_Left | |||||||
|
Flying right: add the speed to the X position.
|
||||||||
| 76BE | ADD A,(HL) | Add the speed from *HL. | ||||||
| 76BF | CP $EE | Jump to Plane_Off_Screen if the X position has reached EE (off-screen right). | ||||||
| 76C1 | JR NC,Plane_Off_Screen | |||||||
| 76C3 | LD (IX+$00),A | Write the updated X position to *IX+00. | ||||||
| 76C6 | JR Set_Plane_Frame | Jump to Set_Plane_Frame. | ||||||
|
Flying left: subtract the speed from the X position.
|
||||||||
| Plane_Flying_Left | 76C8 | SUB (HL) | Subtract the speed from *HL. | |||||
| 76C9 | CP C | Jump to Plane_Off_Screen if the X position has dropped below C (off-screen left). | ||||||
| 76CA | JR C,Plane_Off_Screen | |||||||
| 76CC | LD (IX+$00),A | Write the updated X position to *IX+00. | ||||||
|
Set the plane's sprite frame based on flight direction.
|
||||||||
| Set_Plane_Frame | 76CF | LD A,$4D | Set A to 4D (plane flying left frame). | |||||
| 76D1 | BIT 7,(IY+$01) | Jump to Store_Plane_Frame if bit 7 of *IY+01 is set (flying left). | ||||||
| 76D5 | JR NZ,Store_Plane_Frame | |||||||
|
||||||||
| 76D7 | INC A | Increment to 4E (plane flying right frame). | ||||||
| Store_Plane_Frame | 76D8 | LD (IX+$03),A | Write the frame to *IX+03. | |||||
| 76DB | JP Check_Hazard_Collision | Jump to Check_Hazard_Collision to check for collision with Percy or egg. | ||||||
|
Plane is inactive; randomly trigger a respawn.
|
||||||||
| Plane_Wait_To_Spawn | 76DE | LD A,R | Use the Memory Refresh Register masked as a random value. | |||||
| 76E0 | AND %01111111 | |||||||
| 76E2 | CP $7F | Return if the value is not equal to 7F (wait for random trigger). | ||||||
| 76E4 | RET NZ | |||||||
|
Spawn the plane: reset all state and pick a random starting side.
|
||||||||
| Spawn_Plane | 76E5 | SET 7,(IY+$02) | Set bit 7 of *IY+02 (mark plane as active). | |||||
| 76E9 | XOR A | Write 00 to;
|
||||||
| 76EA | LD ($77AE),A | |||||||
| 76ED | LD (IY+$03),A | |||||||
| 76F0 | LD (IY+$01),A | |||||||
| 76F3 | LD (IX+$00),C | |||||||
| 76F6 | LD (IX+$02),A | |||||||
| 76F9 | LD (IX+$01),B | |||||||
| 76FC | LD (IY+$00),A | |||||||
| 76FF | LD A,R | Use the Memory Refresh Register masked to randomly pick a starting side. | ||||||
| 7701 | AND %00000001 | |||||||
| 7703 | RET Z | Return if bit 0 is not set (spawn from the left at X=00). | ||||||
| 7704 | LD (IX+$00),$EE | Write EE to *IX+00 (spawn from the right). | ||||||
| 7708 | SET 7,(IY+$01) | Set bit 7 of *IY+01 (set flight direction to left). | ||||||
| 770C | RET | Return. | ||||||
|
Plane has flown off-screen; deactivate and return to waiting state.
|
||||||||
| Plane_Off_Screen | 770D | LD (IY+$02),$00 | Write 00 to *IY+02 (mark plane as inactive). | |||||
| 7711 | JR Plane_Wait_To_Spawn | Jump to Plane_Wait_To_Spawn. | ||||||
| Prev: 7680 | Up: Map | Next: 7713 |