![]() |
Routines |
| Prev: 25728 | Up: Map | Next: 25917 |
|
Used by the routine at MainGameLoop.
Handles Percy losing a life. Plays the lose-a-life sound effect, resets any collected worm markers in the room attribute data, decrements the lives counter and updates the display.
|
|||||
|
Set Percy's position and frame for the death animation.
|
|||||
| Lose_Life | 25831 | LD HL,56001 | Write 144 to *Percy_Y_Position (set Percy's Y position to the ground). | ||
| 25834 | LD (HL),144 | ||||
|
Set Percy's sprite frame to the death frame:
|
|||||
| 25836 | INC HL | Write sprite ID 17 to *Percy_Frame_ID. | |||
| 25837 | INC HL | ||||
| 25838 | LD (HL),17 | ||||
| 25840 | PUSH IX | Stash IX on the stack. | |||
| 25842 | CALL Run_Game_Frame | Call Run_Game_Frame. | |||
|
Play the "lose a life" sound effect.
|
|||||
| 25845 | LD HL,0 | Set HL to 0000 (sound data pointer). | |||
| 25848 | LD A,1 | Set A to 1 (initial speaker state). | |||
| 25850 | LD B,0 | Set B to 0 (outer loop counter, 256 iterations). | |||
| Lose_Life_Sound_Outer | 25852 | PUSH BC | Stash the outer counter on the stack. | ||
| 25853 | LD D,B | Copy B to D (inner delay length). | |||
| 25854 | RR B | Rotate B right to vary the pitch. | |||
| Lose_Life_Sound_Inner | 25856 | OUT (254),A | Output to the speaker port. | ||
| 25858 | NOP | Four NOPs as a timing delay. | |||
| 25859 | NOP | ||||
| 25860 | NOP | ||||
| 25861 | NOP | ||||
| 25862 | DJNZ Lose_Life_Sound_Inner | Decrease the inner counter and loop back to Lose_Life_Sound_Inner. | |||
| 25864 | POP BC | Restore the outer counter from the stack. | |||
| 25865 | XOR %00011000 | Toggle the speaker bits by flipping bits 3-4. | |||
| 25867 | OR D | Merge in the delay value from D. | |||
| 25868 | AND (HL) | OR with the sound data byte at *HL. | |||
| 25869 | AND %11111000 | Mask with 248 to keep only the upper bits. | |||
| 25871 | OR %00000001 | Set bit 0 for the border colour. | |||
| 25873 | INC HL | Advance the sound data pointer. | |||
| 25874 | DJNZ Lose_Life_Sound_Outer | Decrease the outer counter and loop back to Lose_Life_Sound_Outer until all 256 iterations are complete. | |||
| 25876 | POP IX | Restore IX from the stack. | |||
|
Reset any collected worm markers in the room object data back to 0.
|
|||||
| 25878 | LD HL,56990 | Point HL at Room_Object_Data. | |||
| 25881 | LD BC,352 | Set the byte counter to 352 in BC. | |||
| Reset_Worm_Markers | 25884 | LD A,(HL) | Jump to Reset_Worm_Markers_Next if *HL is not equal to 30 (not a collected worm marker). | ||
| 25885 | CP 30 | ||||
| 25887 | JR NZ,Reset_Worm_Markers_Next | ||||
| 25889 | LD (HL),0 | Write 0 to *HL to reset the marker. | |||
| Reset_Worm_Markers_Next | 25891 | DEC BC | Decrement the byte counter by one. | ||
| 25892 | INC HL | Advance HL to the next byte. | |||
| 25893 | LD A,B | Loop back to Reset_Worm_Markers until all 352 bytes are processed. | |||
| 25894 | OR C | ||||
| 25895 | JR NZ,Reset_Worm_Markers | ||||
| 25897 | CALL Reset_Worm_State | Call Reset_Worm_State to reset the worm-carrying state. | |||
|
Decrease the lives counter by one.
See Infinite Lives.
|
|||||
| 25900 | LD HL,24499 | Point HL at LivesDisplayCharacter. | |||
| 25903 | DEC (HL) | Decrement the lives counter at *HL. | |||
| 25904 | LD A,(HL) | Jump to Start_Level if *LivesDisplayCharacter has not reached ASCII "0" (48). | |||
| 25905 | CP 48 | ||||
| 25907 | JR NZ,Start_Level | ||||
| 25909 | LD A,48 | Load A with ASCII "0" (48). | |||
| 25911 | LD HL,20720 | Point HL at 20720 (screen buffer position for the lives display). | |||
| 25914 | CALL PrintCharacter | Call PrintCharacter. | |||
|
Continue on to Initialise_Lives.
|
|||||
| Prev: 25728 | Up: Map | Next: 25917 |