Prev: 59373 Up: Map Next: 59474
59389: Check which spell is being cast
There are 5 sorts of spell type, the value stored in the current spell data byte at 60359.
  • MOVE spell, which switches player control to Maroc (byte value = 1)
  • Spell which switches player control to a graphic/icon cursor, e.g. SERVANT, MISSILE, OPEN (byte value = 2)
  • Missile type spells that don't deactivate after a bolt is fired, reserved just for ELECTRIC and FLAME spells (byte value = 3)
  • Ongoing effect spell, e.g. SHIELD, WRAITHBANE (byte value = 4)
  • Instant effect spell, e.g. ENERGIZE, FREEZE, PORTAL (byte value = 5)
This routine checks for spell type, and jumps to the routine that deals with it.
Check for 'active effect' spell (type = 4):
59389 LD A,(60359)
59392 CP 4
59394 JP Z,59933 Jump here if so, as casting this sort of spell may be cancelling an existing active spell.
Check for other types of spell:
59397 LD A,(60134) Get spell number counter (for spell list at 28604)
59400 LD (60140),A ...and put in temporary store
59403 LD A,(60359) Get spell type
Check for MOVE spell
59406 CP 1
59408 JR NZ,59417
59410 LD A,32 Move spell selected. Set the spell selection byte accordingly.
59412 LD (60129),A
59415 JR 59474
Check if spell is an 'instant effect' spell (ENERGIZE, HAIL, WAYSTONE, FREEZE, SUMMON, PORTAL, MESSAGE):
59417 CP 5
59419 JR NZ,59430
Spell is an 'instant effect' spell. These spells have an energy cost to their casting (positive in the case of ENERGIZE).
59421 LD A,(60358) Get energy cost of spell. This is the second byte in each spell set at 28156, e.g.:
  • ENERGIZE = +64
  • HAIL = -1
  • WAYSTONE = -4
  • FREEZE = -4
  • SUMMON = -4
  • PORTAL = -8
59424 CALL 58316 Reduce/increase Maroc's energy
59427 JP 60018
The spell cast needs a controllable cursor (e.g. SERVANT, OPEN, MISSILE, FIND)
59430 LD A,1
59432 LD (60240),A Set graphic address pointer frame offset (1 = no offset, start at first graphics frame)
59435 LD (60569),A Copy to controllable spell cursor/graphic frame buffer
59438 LD A,(60364) Get graphic number for controllable cursor.
This will either be a pointer to the servant graphic (38931/41180) or the flashing eye cursor (38935/41221)
59441 CALL 57538 Setup graphics (for servant or eye cursor)
Copy/initialize a few spell-related bytes in the spell data buffer:
59444 LD HL,(60241) Get cursor graphics address pointer (38931/38935)
59447 LD (60564),HL ...and store in temporary game buffer
59450 LD A,(60239) Pre-graphics data byte, indicating frames & if graphic can be 'flipped'
59453 LD (60570),A
59456 LD A,40 Starting vertical position for the controllable graphic, in pixels, from the top of the playing area
59458 LD (60159),A
59461 LD A,112 Starting horizontal position for the controllable graphic, in pixels, from the left of the playing area
59463 LD (60160),A
59466 LD A,48 Spell selection status - 48 = servant/cursor controllable spell
59468 LD (60129),A
59471 JP 59689
Prev: 59373 Up: Map Next: 59474