Prev: 9E76 Up: Map Next: 9EBF
9E93: Run a handler with target and instrument swapped
Exchanges the target and the instrument (their numbers and record addresses), calls the handler at HL, and swaps them back. This lets one handler serve two ways of saying the same thing: FILL THE BOTTLE WITH WATER becomes PUT THE WATER IN THE BOTTLE (8ED3), and THROW THE SWORD AT THORIN becomes ATTACK THORIN WITH THE SWORD (8F5F).
9E93 LD DE,($B5F8) DE = the target's own record address
9E97 LD IY,($B5FA) IY = the instrument's own record address
9E9B LD ($B5F8),IY The instrument's record becomes the new "target"...
9E9F LD ($B5FA),DE ...and the target's record becomes the new "instrument"
9EA3 LD BC,($B5D9) BC = the current target and instrument object numbers (C=target, B=instrument)
9EA7 LD A,B A = the instrument's number...
9EA8 LD ($B5D9),A ...which becomes the new target
9EAB LD A,C A = the (old) target's number...
9EAC LD ($B5DA),A ...which becomes the new instrument
9EAF CALL $9AC7 Run the handler, with the two swapped over as far as it can tell
9EB2 LD ($B5D9),BC Put the target and instrument numbers back exactly as they were
9EB6 LD ($B5F8),DE Put the target and instrument records back too
9EBA LD ($B5FA),IY
9EBE RET
Prev: 9E76 Up: Map Next: 9EBF