![]() |
Routines |
| Prev: 6480 | Up: Map | Next: 653D |
|
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 | 64E7 | LD HL,$DAC1 | Write 90 to *Percy_Y_Position (set Percy's Y position to the ground). | ||
| 64EA | LD (HL),$90 | ||||
|
Set Percy's sprite frame to the death frame:
|
|||||
| 64EC | INC HL | Write sprite ID 11 to *Percy_Frame_ID. | |||
| 64ED | INC HL | ||||
| 64EE | LD (HL),$11 | ||||
| 64F0 | PUSH IX | Stash IX on the stack. | |||
| 64F2 | CALL Run_Game_Frame | Call Run_Game_Frame. | |||
|
Play the "lose a life" sound effect.
|
|||||
| 64F5 | LD HL,$0000 | Set HL to 0000 (sound data pointer). | |||
| 64F8 | LD A,$01 | Set A to 01 (initial speaker state). | |||
| 64FA | LD B,$00 | Set B to 00 (outer loop counter, 0100 iterations). | |||
| Lose_Life_Sound_Outer | 64FC | PUSH BC | Stash the outer counter on the stack. | ||
| 64FD | LD D,B | Copy B to D (inner delay length). | |||
| 64FE | RR B | Rotate B right to vary the pitch. | |||
| Lose_Life_Sound_Inner | 6500 | OUT ($FE),A | Output to the speaker port. | ||
| 6502 | NOP | Four NOPs as a timing delay. | |||
| 6503 | NOP | ||||
| 6504 | NOP | ||||
| 6505 | NOP | ||||
| 6506 | DJNZ Lose_Life_Sound_Inner | Decrease the inner counter and loop back to Lose_Life_Sound_Inner. | |||
| 6508 | POP BC | Restore the outer counter from the stack. | |||
| 6509 | XOR %00011000 | Toggle the speaker bits by flipping bits 3-4. | |||
| 650B | OR D | Merge in the delay value from D. | |||
| 650C | AND (HL) | OR with the sound data byte at *HL. | |||
| 650D | AND %11111000 | Mask with F8 to keep only the upper bits. | |||
| 650F | OR %00000001 | Set bit 0 for the border colour. | |||
| 6511 | INC HL | Advance the sound data pointer. | |||
| 6512 | DJNZ Lose_Life_Sound_Outer | Decrease the outer counter and loop back to Lose_Life_Sound_Outer until all 0100 iterations are complete. | |||
| 6514 | POP IX | Restore IX from the stack. | |||
|
Reset any collected worm markers in the room object data back to 00.
|
|||||
| 6516 | LD HL,$DE9E | Point HL at Room_Object_Data. | |||
| 6519 | LD BC,$0160 | Set the byte counter to 0160 in BC. | |||
| Reset_Worm_Markers | 651C | LD A,(HL) | Jump to Reset_Worm_Markers_Next if *HL is not equal to 1E (not a collected worm marker). | ||
| 651D | CP $1E | ||||
| 651F | JR NZ,Reset_Worm_Markers_Next | ||||
| 6521 | LD (HL),$00 | Write 00 to *HL to reset the marker. | |||
| Reset_Worm_Markers_Next | 6523 | DEC BC | Decrement the byte counter by one. | ||
| 6524 | INC HL | Advance HL to the next byte. | |||
| 6525 | LD A,B | Loop back to Reset_Worm_Markers until all 0160 bytes are processed. | |||
| 6526 | OR C | ||||
| 6527 | JR NZ,Reset_Worm_Markers | ||||
| 6529 | CALL Reset_Worm_State | Call Reset_Worm_State to reset the worm-carrying state. | |||
|
Decrease the lives counter by one.
See Infinite Lives.
|
|||||
| 652C | LD HL,$5FB3 | Point HL at LivesDisplayCharacter. | |||
| 652F | DEC (HL) | Decrement the lives counter at *HL. | |||
| 6530 | LD A,(HL) | Jump to Start_Level if *LivesDisplayCharacter has not reached ASCII "0" (30). | |||
| 6531 | CP $30 | ||||
| 6533 | JR NZ,Start_Level | ||||
| 6535 | LD A,$30 | Load A with ASCII "0" (30). | |||
| 6537 | LD HL,$50F0 | Point HL at 50F0 (screen buffer position for the lives display). | |||
| 653A | CALL PrintCharacter | Call PrintCharacter. | |||
|
Continue on to Initialise_Lives.
|
|||||
| Prev: 6480 | Up: Map | Next: 653D |