![]() |
Routines |
| Prev: D13A | Up: Map | Next: D1A5 |
|
Used by the routine at RunGame.
Puts the objects of the quest into the object store at the start of a game. The store is copied from the table at InitialObjectStore, in which the five stones are all in room 61. The rooms and positions of the stones are then replaced with five consecutive entries of the table at StonePlaces, starting at one of the first sixteen, which is picked by the random seed.
|
||||
|
Copy the initial store, then pick a set of stone rooms.
|
||||
| InitialiseObjectStore | D16F | LD DE,$D432 | Take the object store, ObjectStore. | |
| D172 | LD HL,$D312 | Take the initial entries of the store, InitialObjectStore. | ||
| D175 | LD BC,$0120 | Set the number of bytes to copy, which is the size of 12 entries. | ||
| D178 | LDIR | Copy the initial entries into the store. | ||
| D17A | LD A,($A70D) | Fetch the random seed. | ||
| D17D | AND %00111100 | Keep bits 2-5, to make a multiple of four from 00 to 3C. | ||
| D17F | LD E,A | Put it in E. | ||
| D180 | LD D,$00 | Clear D. | ||
| D182 | LD HL,$D1A5 | Take the table of rooms and positions of the stones, StonePlaces. | ||
| D185 | ADD HL,DE | Add the offset. | ||
| D186 | LD IY,$D472 | Start at the store entry of the stone of type 94, which is the first of the five, ObjectStore_Stones. | ||
| D18A | LD C,$05 | Set the number of stones. | ||
| D18C | LD DE,$000D | Set the offset from the end of the position to the start of the next entry. | ||
|
Write the room and position of each stone.
|
||||
| InitialiseObjectStore_Stone | D18F | LD A,(HL) | Fetch the room from the table. | |
| D190 | LD (IY+$08),A | Set the room of the stone in the store. | ||
| D193 | LD B,$03 | Set the number of bytes of the position. | ||
| InitialiseObjectStore_Position | D195 | INC HL | Move on to the next byte of the table. | |
| D196 | INC IY | Move on to the next byte of the entry. | ||
| D198 | LD A,(HL) | Fetch the byte of the position. | ||
| D199 | LD (IY+$00),A | Set the byte of the position of the stone in the store. | ||
| D19C | DJNZ InitialiseObjectStore_Position | Jump to InitialiseObjectStore_Position until the position is set. | ||
| D19E | INC HL | Move on to the next entry of the table. | ||
| D19F | ADD IY,DE | Move on to the next entry of the store. | ||
| D1A1 | DEC C | Count the stone as done. | ||
| D1A2 | JR NZ,InitialiseObjectStore_Stone | Jump to InitialiseObjectStore_Stone until all of the stones are set. | ||
| D1A4 | RET | Return. | ||
| Prev: D13A | Up: Map | Next: D1A5 |