Routines |
Prev: E336 | Up: Map | Next: E3FD |
|
||||||||
Check if it's an increase or decrease:
|
||||||||
E3CC | LD C,A | Store increase/decrease value in C register | ||||||
E3CD | CP $80 | If bit 7 is set, it indicates an increase in energy (e.g. CHALICE, ENERGIZE, AMULET spells) | ||||||
E3CF | JR NC,$E3DB | |||||||
Decrease Maroc's energy:
|
||||||||
E3D1 | LD A,($EAE0) | Maroc's current energy | ||||||
E3D4 | SUB C | The amount of damage to subtract | ||||||
E3D5 | JR NC,$E3E6 | Is Maroc's energy now less than zero? | ||||||
E3D7 | LD A,$00 | If energy < 0, set energy to zero | ||||||
E3D9 | JR $E3E6 | |||||||
Increase Maroc's energy:
|
||||||||
E3DB | NEG | Maroc is being healed - invert damage (resets bit 7) to indicate energy increase | ||||||
E3DD | LD C,A | |||||||
E3DE | LD A,($EAE0) | Maroc's current energy | ||||||
E3E1 | ADD A,C | Increase by relevant amount | ||||||
E3E2 | JR NC,$E3E6 | |||||||
E3E4 | LD A,$FF | If energy is now > 255, set energy to 255 | ||||||
Play beep sound - pitch corresponds to Maroc's energy
|
||||||||
E3E6 | LD ($EAE0),A | Re-store Maroc's new energy level | ||||||
E3E9 | NEG | Inverts energy value so that the higher the energy, the higher the pitch of the beep sound | ||||||
E3EB | OR $01 | Ensure value to use is at least 1 (i.e. not zero) | ||||||
E3ED | LD D,A | Delay for inner beep loop | ||||||
E3EE | LD C,$10 | Delay for beep sound pitch register (outer loop) | ||||||
E3F0 | LD A,$10 | Set bit 4 (speaker bit) | ||||||
E3F2 | LD B,D | Delay counter | ||||||
E3F3 | DJNZ $E3F3 | Short delay, affects beep pitch based on energy left | ||||||
E3F5 | OUT ($FE),A | Play sound | ||||||
E3F7 | XOR $10 | Toggle speaker bit | ||||||
E3F9 | DEC C | |||||||
E3FA | JR NZ,$E3F2 | Keep toggling for short time (outer repeat loop) | ||||||
E3FC | RET |
Prev: E336 | Up: Map | Next: E3FD |