Routines
| Prev: CE8F | Up: Map | Next: CEDE |
CEB8: A plan instruction failed: move on and try again now
|
Counts the failure (CC0B), skips the instruction and any success address, and takes the failure address if bit 4 is set.
How it works:
1. Count the failure in CC0B.
2. Skip the instruction and any success address. If the instruction has a failure address (bit 4), go there.
3. If the new position is the same instruction, wait there until next turn (CD8B); otherwise try the next one now.
|
||||||||
| CEB8 | LD HL,$CC0B | Point HL at "Bytes for the actor's turn (CC37)" (CC0B) - Count the failure | ||||||
| CEBB | INC (HL) | Add one to the byte at "Bytes for the actor's turn (CC37)" (CC0B) | ||||||
| CEBC | CALL $CE83 | The instruction just run | ||||||
| CEBF | CALL $CEFE | Skip it and any success address | ||||||
| CEC2 | BIT 4,(IX+$00) | Test bit 4 of the first byte of the record at IX - Has it a failure address? | ||||||
| CEC6 | JR Z,$CECC | If bit 4 of the first byte of the record at IX is clear, skip ahead to CECC | ||||||
| CEC8 | LD E,(HL) | Read the byte HL points at into E - Yes: go there | ||||||
| CEC9 | INC HL | Step HL on to the next byte | ||||||
| CECA | LD D,(HL) | Read the byte HL points at into D | ||||||
| CECB | EX DE,HL | Swap DE and HL | ||||||
| CECC | LD (IY+$01),L | Store L in byte +1 of the record at IY - Store the new script position | ||||||
| CECF | LD (IY+$02),H | Store H in byte +2 of the record at IY | ||||||
| CED2 | PUSH IX | Save IX on the stack - Back to the same instruction? | ||||||
| CED4 | POP DE | Restore DE from the stack | ||||||
| CED5 | AND A | Clear the carry flag, so that the subtraction that follows is a plain one (a compare) | ||||||
| CED6 | SBC HL,DE | Subtract DE from HL (a compare: carry = HL was smaller, zero = equal) | ||||||
| CED8 | JP Z,$CD8B | Then wait there until next turn | ||||||
| CEDB | JP $CC82 | Otherwise try the next one now | ||||||
| Prev: CE8F | Up: Map | Next: CEDE |