Prev: 39112 Up: Map Next: 39172
39122: Set Key Positions
Used by the routine at StartGame.
Called when a game starts. Chooses the rooms for three of the keys from the three tables of rooms that follow, using FRAMES and the counter at CounterLow. The green key (Initialisation_Key_Green) uses FRAMES, the red key (Initialisation_Key_Red) uses FRAMES plus the low byte of the counter, and the cyan key (Initialisation_Key_Cyan) uses the high bytes of both. The room of the red key is also given to the mummy (see Initialisation_Mummy). The yellow key does not move.
SetKeyPositions 39122 LD A,(23672) Fetch FRAMES.
39125 LD HL,39180 Point HL at the green key rooms at GreenKeyRooms.
39128 CALL GetKeyRoom Call GetKeyRoom to get a room.
39131 LD (24638),A Update the room of the green key.
39134 LD A,(23672) Fetch FRAMES and keep FRAMES in C.
39137 LD C,A
39138 LD A,(24082) Fetch the counter from CounterLow.
39141 ADD A,C Add FRAMES to the counter.
39142 LD HL,39188 Point HL at the red key rooms at RedKeyRooms.
39145 CALL GetKeyRoom Call GetKeyRoom to get a room.
39148 LD (24646),A Update the room of the red key.
39151 LD (25614),A Update the room of the mummy (offset 1 of Initialisation_Mummy).
39154 LD A,(23673) Fetch the second byte of FRAMES and keep it in C.
39157 LD C,A
39158 LD A,(24083) Fetch the high byte of the counter from CounterHigh.
39161 ADD A,C Add it to the high byte of the counter.
39162 LD HL,39196 Point HL at the cyan key rooms at CyanKeyRooms.
39165 CALL GetKeyRoom Call GetKeyRoom to get a room.
39168 LD (24654),A Update the room of the cyan key.
39171 RET Return.
Prev: 39112 Up: Map Next: 39172