![]() |
Routines |
| Prev: 6456 | Up: Map | Next: 64E7 |
|
Used by the routine at MainGameLoop.
Animates Percy's energy bar at the bottom of the screen. The bar depletes when Percy is airborne and refills when Percy is on the ground. If the bar fully depletes, Percy enters the falling state.
|
||||||||
| UpdateEnergyBar | 6480 | LD HL,$52EC | HL=52EC (screen buffer location for the energy bar). | |||||
|
If *FallingState is non-zero, it's acting as a cooldown timer so decrement it and return.
|
||||||||
| 6483 | LD A,($5FA7) | A=*FallingState. | ||||||
| 6486 | OR A | Jump to UpdateEnergyBar_CheckPosition if *FallingState is zero (Percy isn't falling). | ||||||
| 6487 | JR Z,UpdateEnergyBar_CheckPosition | |||||||
| 6489 | DEC A | Decrement the cooldown timer. | ||||||
| 648A | LD ($5FA7),A | Write A to *FallingState. | ||||||
| 648D | RET | Return. | ||||||
|
Check if Percy is on the ground (Y >= 90). If so, the energy bar
refills. Otherwise it depletes.
|
||||||||
| UpdateEnergyBar_CheckPosition | 648E | LD A,(IX+$01) | Load A with Percy's Y position (from *IX+01). | |||||
| 6491 | CP $90 | Jump to UpdateEnergyBar_Refill if Percy is at, or below the ground level (90). | ||||||
| 6493 | JR NC,UpdateEnergyBar_Refill | |||||||
|
Percy is airborne so deplete the energy bar. Uses a slower frame delay of 07 frames between each step.
|
||||||||
| 6495 | LD A,($5FAB) | Increment the *EnergyBarDelayCounter. | ||||||
| 6498 | INC A | |||||||
| 6499 | LD ($5FAB),A | |||||||
| 649C | CP $07 | Return if it's not yet time to update the energy bar. | ||||||
| 649E | RET NZ | |||||||
|
Reset the frame counter and check if Percy is on a platform (energy doesn't deplete while landed).
|
||||||||
| 649F | XOR A | Write 00 to reset *EnergyBarDelayCounter. | ||||||
| 64A0 | LD ($5FAB),A | |||||||
| 64A3 | LD A,($5FAD) | Return if *LandedOnPlatformFlag is set, indicating Percy is landed on a platform. | ||||||
| 64A6 | OR A | |||||||
| 64A7 | RET NZ | |||||||
|
Deplete the energy bar by shifting pixels left. Scans rightward from the current position to find the rightmost filled byte, then shifts it left by one pixel.
|
||||||||
| UpdateEnergyBar_Deplete_FindByte | 64A8 | LD A,(HL) | Jump to UpdateEnergyBar_Deplete_ScanLeft if *HL is zero (no pixels here). | |||||
| 64A9 | OR A | |||||||
| 64AA | JR Z,UpdateEnergyBar_Deplete_ScanLeft | |||||||
| 64AC | SLA (HL) | Shift *HL left one pixel (remove one pixel of energy). | ||||||
|
Copy the updated byte to the three pixel rows below to give the energy bar its height.
|
||||||||
| UpdateEnergyBar_CopyRows | 64AE | LD A,(HL) | A=*HL. | |||||
| 64AF | INC H | Copy to the first row below. | ||||||
| 64B0 | LD (HL),A | |||||||
| 64B1 | INC H | Copy to the second row below. | ||||||
| 64B2 | LD (HL),A | |||||||
| 64B3 | INC H | Copy to the third row below. | ||||||
| 64B4 | LD (HL),A | |||||||
| 64B5 | RET | Return. | ||||||
|
Current byte is empty so scan leftward for the next filled byte.
|
||||||||
| UpdateEnergyBar_Deplete_ScanLeft | 64B6 | DEC L | Move one byte to the left. | |||||
| 64B7 | LD A,L | Jump to UpdateEnergyBar_Depleted if the energy bar is fully depleted (reached E0 the left edge of the bar). | ||||||
| 64B8 | CP $E0 | |||||||
| 64BA | JR Z,UpdateEnergyBar_Depleted | |||||||
| 64BC | JR UpdateEnergyBar_Deplete_FindByte | Jump to UpdateEnergyBar_Deplete_FindByte to check this byte. | ||||||
|
This entry point is used by the routine at Run_Main_Loop_Body.
Percy is on the ground so refill the energy bar. Uses a faster frame delay of 03 frames between each step.
|
||||||||
| UpdateEnergyBar_Refill | 64BE | LD A,($5FAB) | Increment the *EnergyBarDelayCounter. | |||||
| 64C1 | INC A | |||||||
| 64C2 | LD ($5FAB),A | |||||||
| 64C5 | CP $03 | Return if not yet time to update the bar. | ||||||
| 64C7 | RET C | |||||||
| 64C8 | XOR A | Write 00 to reset *EnergyBarDelayCounter. | ||||||
| 64C9 | LD ($5FAB),A | |||||||
|
This entry point is used by the routines at Start_Level and Handle_Butterfly.
Refill the energy bar by shifting pixels right (filling from the left). Scans leftward to find the first non-full byte and fills it one pixel at a time.
|
||||||||
| UpdateEnergyBar_Refill_Shift | 64CC | LD HL,$52E1 | HL=52E1 (left edge of the energy bar). | |||||
| UpdateEnergyBar_Refill_FindByte | 64CF | LD A,(HL) | A=*HL. | |||||
| 64D0 | CP $FF | Jump to UpdateEnergyBar_Refill_ScanRight if this byte is full (scan next byte). | ||||||
| 64D2 | JR Z,UpdateEnergyBar_Refill_ScanRight | |||||||
| 64D4 | SRL (HL) | Shift *HL right one pixel. | ||||||
| 64D6 | SET 7,(HL) | Set bit 7 of *HL (fill from the left). | ||||||
| 64D8 | JR UpdateEnergyBar_CopyRows | Jump to UpdateEnergyBar_CopyRows to copy the result to the rows below. | ||||||
|
Current byte is fully filled so scan rightward for the next byte to fill.
|
||||||||
| UpdateEnergyBar_Refill_ScanRight | 64DA | INC L | Move one byte to the right. | |||||
| 64DB | LD A,L | Return if the bar is fully refilled (the scan reached ED which is the right edge of the bar). | ||||||
| 64DC | CP $ED | |||||||
| 64DE | RET Z | |||||||
| 64DF | JR UpdateEnergyBar_Refill_FindByte | Jump to UpdateEnergyBar_Refill_FindByte to check this byte. | ||||||
|
Energy bar has fully depleted so set Percy to the falling state.
|
||||||||
| UpdateEnergyBar_Depleted | 64E1 | LD A,$FF | Write FF to *FallingState. | |||||
| 64E3 | LD ($5FA7),A | |||||||
| 64E6 | RET | Return. | ||||||
| Prev: 6456 | Up: Map | Next: 64E7 |