| The Hobbit (v1.0) | Routines |
| Prev: 96DD | Up: Map | Next: 9752 |
|
Called at the start of every game. It makes Bilbo the actor and then makes two random choices.
The hidden route: one of five exits listed in the table at C6FD is chosen (a random number 1-5 from 9BF4) and blanked out in its room record, so that way is closed. The address of the chosen entry is written into the instruction at A6C3, where Elrond will need it (A6B8). The candidates are the exits from Beorn's house to the great river, from the forest gate to the bewitched gloomy place, from the treeless opening to the goblins' outside gate, from the long lake to lake town, and from the misty mountain to the narrow place. Because of the way 9BF4 works, the first and last are chosen half as often as the others.
|
||||
| 970B | SUB A | Bilbo is the actor... | ||
| 970C | LD ($B5DB),A | |||
| 970F | LD ($B5E2),A | ...the map has not been read... | ||
| 9712 | LD ($B5EA),A | ...and Gollum is not waiting for an answer | ||
| 9715 | LD HL,$C00B | The actor's record is Bilbo's | ||
| 9718 | LD ($B5FC),HL | |||
| 971B | LD A,$04 | Pick a random number from 0 to 4... | ||
| 971D | CALL $9BF4 | |||
| 9720 | INC A | ...plus 1: one of the five hidden routes | ||
| 9721 | LD B,A | |||
| 9722 | LD IY,$C6F7 | IY = the route table | ||
| 9726 | LD DE,$0006 | Six bytes per entry | ||
| 9729 | ADD IY,DE | Step to the chosen entry | ||
| 972B | DJNZ $9729 | |||
| 972D | LD ($A6C5),IY | Write its address into the LD IY instruction in Elrond's map routine (A6B8) | ||
| 9731 | LD L,(IY+$01) | HL = the address of the exit in the room record | ||
| 9734 | LD H,(IY+$02) | |||
| 9737 | LD B,$03 | Blank out its three bytes: the way is closed | ||
| 9739 | LD (HL),$00 | |||
| 973B | INC HL | |||
| 973C | DJNZ $9739 | |||
| 973E | LD A,$03 | Pick a random number from 0 to 3... | ||
| 9740 | CALL $9BF4 | |||
| 9743 | LD E,A | ...times 4... | ||
| 9744 | LD D,$00 | |||
| 9746 | SLA E | |||
| 9748 | SLA E | |||
| 974A | LD HL,$C6EB | ...to choose one of the four riddle entries | ||
| 974D | ADD HL,DE | |||
| 974E | LD ($B5DF),HL | Remember it for Gollum | ||
| 9751 | RET | |||
| Prev: 96DD | Up: Map | Next: 9752 |