Prev: CC72 Up: Map Next: CCDD
CCA8: Maroc has picked up a spell
Input
A Spell number (from list at 6DFC)
Maroc has collected a spell. Collected spells come with a random number of charges (between 3 and 10).
CCA8 LD C,A Temp store for spell number in C register
CCA9 LD A,($EB4E) Get item properties byte
CCAC AND $10 Is the item carried by the servant (i.e. the servant has picked up the spell and moved onto Maroc, rather than Maroc moving over the spell item)?
CCAE JR Z,$CCB5
CCB0 LD A,$00
CCB2 LD ($EBB1),A ...If not, set the item-carried-by-servant byte to 0
Mark this spell as 'acquired' by setting the first byte in its spell set to 16:
CCB5 LD A,C Retrieve spell number
CCB6 LD HL,($EB65) Address pointer to start of spell list at 6DFC
CCB9 LD D,$00
CCBB LD E,A Store spell number in DE register pair...
CCBC EX DE,HL ...Swap into HL register pair. Each spell set contains 16 bytes, so...
CCBD ADD HL,HL x 2
CCBE ADD HL,HL x 4
CCBF ADD HL,HL x 8
CCC0 ADD HL,HL x 16
CCC1 ADD HL,DE Add to the base spell list address (6DFC) so HL is now pointing at the start of the set for this spell
CCC2 LD (HL),$10 Set the first byte of the set to 16, which indicates that Maroc has collected this spell
Collected spells come with a variable number of charges. New spells will start with between 3 and 10 charges. Collecting additional spells of the same type will add 3-10 charges to the existing ones.
CCC4 LD A,($EAAA) Incrementing game cycle counter (used here to generate a pseudo-random number)
CCC7 AND $07 Keep bits 0-2. This provides a random value between 0-7
CCC9 ADD A,$03 Add 3 to give a value between 3-10
CCCB LD B,A Store in B register
CCCC INC HL
CCCD INC HL
CCCE INC HL Move along 3 positions to byte 4 of the set, which indicates how many charges are left for this spell
CCCF LD A,(HL)
CCD0 CP $FF
CCD2 JR Z,$CCD6 Value of 255 means unlimited charges, so skip next two instructions if so.
CCD4 ADD A,B Add the spell's charges to the current number..
CCD5 LD (HL),A ...and re-store the amended count.
After collecting a spell, 'MAGIC' (in the bottom left of the screen) flashes colour and a sound is played 15 times (D331).
CCD6 LD A,$0F
CCD8 LD ($ECA0),A Initialize this counter value to 15
CCDB JR $CD1A
Prev: CC72 Up: Map Next: CCDD