Prev: 8B07 Up: Map Next: 8C4A
8C01: Lose a life
Used by the routine at 8B07.
8C01 LD A,$47 A=0x47 (INK 7: PAPER 0: BRIGHT 1)
The following loop fills the top two-thirds of the attribute file with a single value (0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41 or 0x40) and makes a sound effect.
8C03 LD HL,$5800 Fill the top two-thirds of the attribute file with the value in A
8C06 LD DE,$5801
8C09 LD BC,$01FF
8C0C LD (HL),A
8C0D LDIR
8C0F LD E,A Save the attribute byte (0x40-0x47) in E for later retrieval
8C10 CPL D=63-8*(E AND 7); this value determines the pitch of the short note that will be played
8C11 AND $07
8C13 RLCA
8C14 RLCA
8C15 RLCA
8C16 OR $07
8C18 LD D,A
8C19 LD C,E C=8+32*(E AND 7); this value determines the duration of the short note that will be played
8C1A RRC C
8C1C RRC C
8C1E RRC C
8C20 OR $10 Set bit 4 of A (for no apparent reason)
8C22 XOR A Set A=0 (this will make the border black)
8C23 OUT ($FE),A Produce a short note whose pitch is determined by D and whose duration is determined by C
8C25 XOR $18
8C27 LD B,D
8C28 DJNZ $8C28
8C2A DEC C
8C2B JR NZ,$8C23
8C2D LD A,E Restore the attribute byte (originally 0x47) to A
8C2E DEC A Decrement it (effectively decrementing the INK colour)
8C2F CP $3F Have we used attribute value 0x40 (INK 0) yet?
8C31 JR NZ,$8C03 If not, jump back to update the INK colour in the top two-thirds of the screen and make another sound effect
Now check whether any lives remain.
8C33 LD HL,$85CC Pick up the number of lives remaining from 85CC
8C36 LD A,(HL)
8C37 OR A Are there any lives remaining?
8C38 JP Z,$8C4A If not, display the game over sequence
8C3B DEC (HL) Decrease the number of lives remaining by one
8C3C LD HL,$85D7 Restore Willy's state upon entry to the room by copying the seven bytes at 85D7 back into 85CF-85D5
8C3F LD DE,$85CF
8C42 LD BC,$0007
8C45 LDIR
8C47 JP $8912 Reinitialise the room and resume the game
Prev: 8B07 Up: Map Next: 8C4A