![]() |
Routines |
| Prev: 52338 | Up: Map | Next: 52445 |
|
||||||||
|
Maroc has collected a spell. Collected spells come with a random number of charges (between 3 and 10).
|
||||||||
| 52392 | LD C,A | Temp store for spell number in C register | ||||||
| 52393 | LD A,(60238) | Get item properties byte | ||||||
| 52396 | AND 16 | 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)? | ||||||
| 52398 | JR Z,52405 | |||||||
| 52400 | LD A,0 | |||||||
| 52402 | LD (60337),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:
|
||||||||
| 52405 | LD A,C | Retrieve spell number | ||||||
| 52406 | LD HL,(60261) | Address pointer to start of spell list at 28156 | ||||||
| 52409 | LD D,0 | |||||||
| 52411 | LD E,A | Store spell number in DE register pair... | ||||||
| 52412 | EX DE,HL | ...Swap into HL register pair. Each spell set contains 16 bytes, so... | ||||||
| 52413 | ADD HL,HL | x 2 | ||||||
| 52414 | ADD HL,HL | x 4 | ||||||
| 52415 | ADD HL,HL | x 8 | ||||||
| 52416 | ADD HL,HL | x 16 | ||||||
| 52417 | ADD HL,DE | Add to the base spell list address (28156) so HL is now pointing at the start of the set for this spell | ||||||
| 52418 | LD (HL),16 | 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.
|
||||||||
| 52420 | LD A,(60074) | Incrementing game cycle counter (used here to generate a pseudo-random number) | ||||||
| 52423 | AND 7 | Keep bits 0-2. This provides a random value between 0-7 | ||||||
| 52425 | ADD A,3 | Add 3 to give a value between 3-10 | ||||||
| 52427 | LD B,A | Store in B register | ||||||
| 52428 | INC HL | |||||||
| 52429 | INC HL | |||||||
| 52430 | INC HL | Move along 3 positions to byte 4 of the set, which indicates how many charges are left for this spell | ||||||
| 52431 | LD A,(HL) | |||||||
| 52432 | CP 255 | |||||||
| 52434 | JR Z,52438 | Value of 255 means unlimited charges, so skip next two instructions if so. | ||||||
| 52436 | ADD A,B | Add the spell's charges to the current number.. | ||||||
| 52437 | 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 (54065).
|
||||||||
| 52438 | LD A,15 | |||||||
| 52440 | LD (60576),A | Initialize this counter value to 15 | ||||||
| 52443 | JR 52506 | |||||||
| Prev: 52338 | Up: Map | Next: 52445 |