Prev: 53562 Up: Map Next: 53669
53615: Initialise Object Store
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 97. 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 53615 LD DE,54322 Take the object store, ObjectStore.
53618 LD HL,54034 Take the initial entries of the store, InitialObjectStore.
53621 LD BC,288 Set the number of bytes to copy, which is the size of 18 entries.
53624 LDIR Copy the initial entries into the store.
53626 LD A,(42765) Fetch the random seed.
53629 AND %00111100 Keep bits 2-5, to make a multiple of four from 0 to 60.
53631 LD E,A Put it in E.
53632 LD D,0 Clear D.
53634 LD HL,53669 Take the table of rooms and positions of the stones, StonePlaces.
53637 ADD HL,DE Add the offset.
53638 LD IY,54386 Start at the store entry of the stone of type 148, which is the first of the five, ObjectStore_Stones.
53642 LD C,5 Set the number of stones.
53644 LD DE,13 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 53647 LD A,(HL) Fetch the room from the table.
53648 LD (IY+8),A Set the room of the stone in the store.
53651 LD B,3 Set the number of bytes of the position.
InitialiseObjectStore_Position 53653 INC HL Move on to the next byte of the table.
53654 INC IY Move on to the next byte of the entry.
53656 LD A,(HL) Fetch the byte of the position.
53657 LD (IY+0),A Set the byte of the position of the stone in the store.
53660 DJNZ InitialiseObjectStore_Position Jump to InitialiseObjectStore_Position until the position is set.
53662 INC HL Move on to the next entry of the table.
53663 ADD IY,DE Move on to the next entry of the store.
53665 DEC C Count the stone as done.
53666 JR NZ,InitialiseObjectStore_Stone Jump to InitialiseObjectStore_Stone until all of the stones are set.
53668 RET Return.
Prev: 53562 Up: Map Next: 53669