| The Hobbit (v1.0) | Routines |
| Prev: 832E | Up: Map | Next: 839A |
|
Called by the main loop (6D0A) after parsing. It works through the command frames built by the parser, one per command, starting at B8B8.
For each frame, 83A7 finds the action and the objects it applies to. If that fails, the frame is dropped. Otherwise the action is carried out for real: $B5EB is set to 1, 7122 reports it ('you take the sword.'), 946F performs it, and 9611 ends the turn, letting the characters act and the timers run. So every command the player types costs one turn, and a line with three commands costs three turns.
A command with ALL is repeated (837F) for each object it applies to, one turn each. When a frame is finished, the next frame (24 bytes lower) is taken, skipping the exception frames of ALL EXCEPT, until the frame count $B5F7 reaches 0.
If the previous command was left unfinished ($B60A), it is picked up again at 8385 instead.
|
||||
| 8351 | XOR A | No ALL command is still in progress yet | ||
| 8352 | LD ($B60C),A | |||
| 8355 | LD IY,$B8B8 | IY = the first command frame | ||
| 8359 | LD HL,$B60A | Was the previous line left with an unfinished command (e.g. waiting for "which key?" to be answered)? | ||
| 835C | CP (HL) | |||
| 835D | LD (HL),A | Either way, clear that flag now - this line's typing settles the question | ||
| 835E | JP NZ,$8385 | If it WAS waiting, skip straight to picking up where it left off, rather than starting a fresh frame | ||
| 8361 | CALL $83A7 | Find the action and its objects for this frame | ||
| 8364 | JR NZ,$836B | Found: carry it out below | ||
| 8366 | XOR A | Not found (the command made no sense): give up on the rest of this line too | ||
| 8367 | LD ($B5F6),A | |||
| 836A | RET | |||
| 836B | CALL $84DE | Found: would the action actually succeed? (a dry run, changing nothing) | ||
| 836E | JP Z,$87E6 | No: let the action's own handler explain why, rather than saying nothing at all | ||
| 8371 | LD A,$01 | Yes: mark this as really happening now, not just a trial | ||
| 8373 | LD ($B5EB),A | |||
| 8376 | CALL $7122 | Report it in words ("you take the sword.") | ||
| 8379 | CALL $946F | Carry it out | ||
|
This entry point is used by the routine at 858F.
|
||||
| 837C | CALL $9611 | End the turn: let every other character act, and the timers tick | ||
|
This entry point is used by the routine at 87AD.
|
||||
| 837F | LD A,($B60C) | Is an ALL command still working through more objects? | ||
| 8382 | AND A | |||
| 8383 | JR NZ,$8361 | Yes: go round again for the next one | ||
|
This entry point is used by the routine at 87AD.
|
||||
| 8385 | LD A,($B5F7) | How many more command frames are left on this line? | ||
| 8388 | DEC A | |||
| 8389 | LD ($B5F7),A | |||
| 838C | RET Z | None left: the whole line is finished | ||
| 838D | LD BC,$FFE8 | Step on to the next frame (24 bytes lower, since frames are built downwards) | ||
| 8390 | ADD IY,BC | |||
| 8392 | BIT 6,(IY+$01) | Is this frame only an ALL EXCEPT exception, with no command of its own? | ||
| 8396 | JR NZ,$8390 | Yes: skip over it and look at the one after | ||
| 8398 | JR $8361 | Otherwise carry it out | ||
| Prev: 832E | Up: Map | Next: 839A |