Prev: 99E0 Up: Map Next: 9A28
99FB: Change a character's behaviour
Looks for action B in the reaction table of character A (a list of 3-byte entries: action and program address). If found, the character's current program is switched to that address. This is how characters respond to what happens to them: for example the reaction to ATTACK is to fight back.
Input
A Character
B Action
99FB PUSH IY
99FD PUSH IX
99FF CALL $99E0 IY = the character's table entry
9A02 CP $FF Is it a character?
9A04 JR Z,$9A23 No: nothing to do
9A06 LD L,(IY+$04) IX = its reaction table
9A09 LD H,(IY+$05)
9A0C PUSH HL
9A0D POP IX
9A0F LD A,B A = the action that was done to it
9A10 CALL $9D12 Is there a reaction to it?
9A13 CP $FF
9A15 JR Z,$9A23 No: carry on as before
9A17 LD L,(IX+$01) Yes: switch its program to the reaction
9A1A LD H,(IX+$02)
9A1D LD (IY+$02),L
9A20 LD (IY+$03),H
9A23 POP IX
9A25 POP IY
9A27 RET
Prev: 99E0 Up: Map Next: 9A28