![]() |
Routines |
| Prev: 32195 | Up: Map | Next: 32382 |
|
Used by the routine at MainLoop.
Reached at the end of every pass of MainLoop. Looks up the list of items for the current room in RoomTable and runs the handler of each one through ProcessRoomItem. Each entry in a list is the address of an item record in the initial entity data at Initialisation_Player. Once the list is finished the counter at CounterLow is incremented and, on the first pass, DrawRoomEntities draws all of the entities in the room and bit 0 of GameFlags is set. The random number seed at RandomSeed is then stirred, the pick-up key, the pause keys and the food are dealt with and the main loop is restarted, unless the player is in room 142 which ends the game with GameComplete.
|
||||||||
|
||||||||
| DrawRoom | 32291 | LD A,(60049) | Fetch the room of the player. | |||||
| 32294 | LD L,A | Double the room number to create an offset in HL. | ||||||
| 32295 | LD H,0 | |||||||
| 32297 | ADD HL,HL | |||||||
| 32298 | LD BC,30077 | Find the entry for the room in the table of item lists at RoomTable. | ||||||
| 32301 | ADD HL,BC | |||||||
| 32302 | LD A,(HL) | Fetch the address of the list of items for the room. | ||||||
| 32303 | INC HL | |||||||
| 32304 | LD H,(HL) | |||||||
| 32305 | LD L,A | |||||||
| 32306 | LD (24091),HL | Update the room pointer in CurrentRoom. | ||||||
|
Each pass of this loop reads one item from the list.
|
||||||||
| Decor_Loop | 32309 | LD HL,(24091) | Fetch the pointer to the next entry in the list of items. | |||||
| 32312 | LD A,(HL) | Fetch the low byte of the item address. | ||||||
| 32313 | INC HL | Move on to the next entry in the list and write the pointer to CurrentRoom. | ||||||
| 32314 | INC HL | |||||||
| 32315 | LD (24091),HL | |||||||
| 32318 | DEC HL | Fetch the address of the item. | ||||||
| 32319 | LD H,(HL) | |||||||
| 32320 | LD L,A | |||||||
| 32321 | OR H | Jump to ProcessRoomItem to process the item if the list has not ended (the item address is not zero). | ||||||
| 32322 | JR NZ,ProcessRoomItem | |||||||
|
The list is finished (it is terminated by an address of 0).
|
||||||||
| 32324 | LD HL,(24082) | Increment the counter held in CounterLow by one. | ||||||
| 32327 | INC HL | |||||||
| 32328 | LD (24082),HL | |||||||
| 32331 | LD HL,24084 | Jump to DrawRoom_Finish if bit 0 of GameFlags is set (the entities are drawn). | ||||||
| 32334 | BIT 0,(HL) | |||||||
| 32336 | JR NZ,DrawRoom_Finish | |||||||
| 32338 | CALL DrawRoomEntities | Call DrawRoomEntities to draw the entities in this room. | ||||||
| DrawRoom_Finish | 32341 | LD HL,24084 | Set bit 0 of GameFlags. | |||||
| 32344 | SET 0,(HL) | |||||||
|
Stir the random number seed with FRAMES and the counter.
|
||||||||
| 32346 | LD HL,(24069) | Fetch the random seed. | ||||||
| 32349 | LD DE,(23672) | Fetch FRAMES. | ||||||
| 32353 | ADD HL,DE | Add FRAMES to the random seed. | ||||||
| 32354 | LD A,(24082) | Fetch the low byte of the counter. | ||||||
| 32357 | ADD A,L | Add the counter to the random seed. | ||||||
| 32358 | LD L,A | |||||||
| 32359 | LD (24069),HL | Store the new random seed. | ||||||
|
Read the pick-up key, check for the game being paused and spawn food.
|
||||||||
| 32362 | CALL ReadPickupKey | Call ReadPickupKey to read the key to pick up an item. | ||||||
| 32365 | CALL PauseGame | Call PauseGame to check whether the game is paused. | ||||||
| 32368 | CALL SpawnFood | Call SpawnFood to spawn the food. | ||||||
|
Finish the game if the player has reached the final room.
|
||||||||
| 32371 | LD A,(60049) | Fetch the room of the player. | ||||||
| 32374 | CP 142 | Jump to GameComplete if the player is in room 142. | ||||||
| 32376 | JP Z,GameComplete | |||||||
| 32379 | JP MainLoop | Jump back to MainLoop to run the next pass of the main loop. | ||||||
| Prev: 32195 | Up: Map | Next: 32382 |