| The Hobbit (v1.0) | Routines |
| Prev: 8ED3 | Up: Map | Next: 8F37 |
| 8F17 | LD A,$0A | Pick a random direction from 1 to 10 | ||
| 8F19 | CALL $9BF4 | |||
| 8F1C | CP $00 | |||
| 8F1E | JR Z,$8F17 | (0 is not a real direction: try again) | ||
| 8F20 | LD B,A | B = that direction | ||
| 8F21 | CALL $9E51 | Is there a usable exit that way? | ||
| 8F24 | CP B | |||
| 8F25 | JR Z,$8F31 | Yes: run that way | ||
| 8F27 | LD A,B | No: try the next direction round instead... | ||
| 8F28 | INC A | |||
| 8F29 | CP $0A | |||
| 8F2B | JR C,$8F20 | |||
| 8F2D | LD A,$01 | ...wrapping back to 1 after 10 | ||
| 8F2F | JR $8F20 | |||
| 8F31 | LD ($B5D8),A | That direction becomes the movement action | ||
| 8F34 | JP $8D19 | Move that way | ||
| Prev: 8ED3 | Up: Map | Next: 8F37 |