Prev: D730 Up: Map Next: D7F3
D794: Check for any fired missiles/bolts
Used by the routines at D6C7, D6D2, D71C and D730.
Checking if:
  • a creature has fired a missile at Maroc, or
  • Maroc has fired a missile.
Only one creature missile and one Maroc-fired missile (i.e. 2 missiles total) can be on-screen at any one time.
D794 LD A,$00
D796 LD ($EAD4),A Indicates screen/viewport - 0 = current screen/viewport
D799 LD A,$05
D79B LD ($EB9A),A Pre-set the missile type. 5 = missile fired at Maroc by creatures (rather than vice versa)
Check if a missile/bolt has been set up (and if not, set it up):
D79E LD A,($EB93) Get missile number (table at 6CDC)
D7A1 CP $00
D7A3 JR Z,$D7AD 0 = no missile present
D7A5 CALL $DB1F If not zero, set up this missile set data
D7A8 LD A,$00 Missile has now been set up and stored in the data sets at 7C00, so can now set the missile number to zero
D7AA LD ($EB93),A
Check if Maroc has launched a missile spell:
D7AD LD A,($EC98) This byte contains an 'action' byte set when Maroc presses fire after aiming his missile-based spell cursor, and contains values for the different missile spells
D7B0 CP $00 If zero, Maroc hasn't fired a missile spell - skip next section
D7B2 JR Z,$D7F3
Maroc has launched a missile-type spell. Calculate trajectory of missile:
D7B4 LD A,($EB92) Flag indicating if Maroc has fired a missile (1 = missile fired, 0 = no missile)
D7B7 CP $00
D7B9 JR NZ,$D7EE If there's already one, skip the setup
D7BB INC A Increment so the flag = 1 (missile fired)
D7BC LD ($EB92),A ...and re-store.
D7BF LD A,$00 Precision/overflow byte for horizontal/vertical item position (reset both to 0)
D7C1 LD ($EB94),A
D7C4 LD ($EB96),A
D7C7 LD A,($EAC0) Maroc's horizontal (X-axis) screen position
D7CA LD ($EB95),A Set this as the missile's horizontal (X) co-ordinate origin
D7CD LD A,($EAC1) Maroc's vertical (Y-axis) screen position
D7D0 LD ($EB97),A Set this as the missile's vertical (Y) co-ordinate origin
D7D3 LD A,($EAFF) Get the vertical (Y) pixel position of the aiming cursor
D7D6 LD ($EB99),A Store as the target vertical pixel (Y) co-ordinate for the missile
D7D9 LD A,($EB00) Get the horizontal (X) pixel position of the aiming cursor
D7DC RRA This value is currently in pixel steps, so divide by 4 to get into 4-pixel (half-character steps)
D7DD RRA
D7DE AND $3F Filter out any unnecessary carry bits
D7E0 LD ($EB98),A ...and store
D7E3 LD A,$08 Item/missile type = 8 (missile fired by Maroc)
D7E5 LD ($EB9A),A Store in missile data set
D7E8 LD A,($EC98)
D7EB CALL $DB1F Set up missile data
D7EE LD A,$00 This is the action byte set when Maroc presses fire after aiming his missile-based spell cursor - contains values for the different missile spells
D7F0 LD ($EC98),A Now that the missile has been initialized, set this flag to 0.
Prev: D730 Up: Map Next: D7F3