Prev: 9883 Up: Map Next: 9921
98CF: Character instruction: action without objects
The byte after the instruction is an action with no target or instrument (typically a movement direction, so a character's program can be a route), tried with 9921. An action of $FF means 'jump to the address that follows' if bit 4 is set. The entry at 9905 counts the instructions done this turn and follows jump addresses.
98CF LD DE,$0002 This instruction is 2 bytes long (plus a failure address)
98D2 CALL $9873 Move the program pointer past it
98D5 LD A,(IX+$01) A = the action
98D8 CP $FF $FF: no action at all?
98DA JR Z,$98EF Yes
98DC LD ($B5D8),A Set the action...
98DF LD A,$FF ...with no target or instrument: the game will choose them
98E1 LD ($B5D9),A
98E4 LD ($B5DA),A
98E7 CALL $9921 Try it
98EA JR Z,$9905 It failed
98EC JP $985C It worked: turn over
98EF BIT 4,(IX+$00) No action. Is there an address after it (bit 4)?
98F3 JP Z,$985C No: just end the turn (the character waits)
98F6 LD L,(IX+$02) Yes: jump there next turn
98F9 LD H,(IX+$03)
98FC LD (IY+$02),L
98FF LD (IY+$03),H
9902 JP $985C Turn over
This entry point is used by the routine at 9883.
9905 LD HL,$9769 FAILURE: count it (six failures end the turn)
9908 INC (HL)
9909 BIT 4,(IX+$00) Is there a failure address (bit 4)?
990D JP Z,$97DA No: go on to the next instruction
9910 ADD IX,DE Yes: fetch it...
9912 LD H,(IX+$01)
9915 LD L,(IX+$00)
9918 LD (IY+$02),L ...make it the program position...
991B LD (IY+$03),H
991E JP $97E0 ...and carry on from there, in the same turn
Prev: 9883 Up: Map Next: 9921