![]() |
Routines |
| Prev: 44409 | Up: Map | Next: 44557 |
|
Used by the routine at GameEntryPoint.
Clears game state, copies the starting item locations from Table_InitialItemLocations into Table_ItemLocations, primes the saved-state bytes through Table_SavedStateAddresses, places the player in the starting room from StartingRoom, then loops on turn events, scenic events and command input until a game-over flag is set.
|
||||
|
Clear Table_ItemLocations and the following 385 state bytes.
|
||||
| GameStart | 44449 | LD HL,40840 | Point HL at the item locations table at Table_ItemLocations. | |
| 44452 | LD BC,385 | Load BC with 385 bytes to clear. | ||
| GameStart_ClearLoop | 44455 | LD (HL),0 | Write 0 through HL. | |
| 44457 | INC HL | Move HL on to the next byte to clear. | ||
| 44458 | DEC BC | Decrease BC and loop back to GameStart_ClearLoop until every byte is clear. | ||
| 44459 | LD A,B | |||
| 44460 | OR C | |||
| 44461 | JR NZ,GameStart_ClearLoop | |||
|
Copy the starting item locations and carrying limit.
|
||||
| 44463 | LD HL,47883 | Copy *Count_Items bytes from Table_InitialItemLocations to Table_ItemLocations. | ||
| 44466 | LD DE,40840 | |||
| 44469 | LD BC,(48071) | |||
| 44473 | LDIR | |||
| 44475 | LD A,(48087) | Write *InitialCarryingLimit to *CarryingLimit. | ||
| 44478 | LD (41171),A | |||
|
Prime each saved-state address from Table_SavedStateAddresses with the matching byte from InitialSavedStateBytes.
|
||||
| 44481 | LD IX,47865 | Point IX at the saved-state address table at Table_SavedStateAddresses. | ||
| 44485 | LD DE,47877 | Point DE at the initial-state bytes at InitialSavedStateBytes. | ||
| 44488 | LD A,(48081) | Load the saved-state count from *Count_SavedStateBytes into B. | ||
| 44491 | LD B,A | |||
| GameStart_InitStateLoop | 44492 | LD L,(IX+0) | Fetch the next destination address from *IX into HL. | |
| 44495 | LD H,(IX+1) | |||
| 44498 | LD A,(DE) | Fetch the next initial-state byte from *DE into A. | ||
| 44499 | LD (HL),A | Write that byte through HL. | ||
| 44500 | INC IX | Move IX on to the next saved-state address. | ||
| 44502 | INC IX | |||
| 44504 | INC DE | Move DE on to the next initial-state byte. | ||
| 44505 | DJNZ GameStart_InitStateLoop | Decrease the init counter by one and loop back to GameStart_InitStateLoop until every saved-state address is primed. | ||
|
Clear the screen, enter the starting room, then run the main loop.
|
||||
| 44507 | CALL JustReturn | Call JustReturn to clear the play screen. | ||
| 44510 | LD A,(48083) | Write *StartingRoom to *CurrentRoom. | ||
| 44513 | LD (41222),A | |||
| 44516 | CALL ChangeRoom | Call ChangeRoom to change into the starting room. | ||
|
Process turn events and scenic events, then read the next command.
|
||||
| GameStart_MainLoop | 44519 | CALL Handler_GameEvents | Call Handler_GameEvents to process turn-based events. | |
| 44522 | CALL Handler_ScenicEvents | Call Handler_ScenicEvents to process scenic events. | ||
| 44525 | LD A,0 | Load flag bit 0 into A. | ||
| 44527 | CALL TestFlag | Call TestFlag to test whether the player is dead. | ||
| 44530 | JR NZ,GameOver | Jump to GameOver if the player is dead. | ||
| 44532 | LD A,1 | Load flag bit 1 into A. | ||
| 44534 | CALL TestFlag | Call TestFlag to test the score/end flag. | ||
| 44537 | JR NZ,GameOver_Score | Jump to GameOver_Score if that flag is set. | ||
| 44539 | LD A,2 | Load flag bit 2 into A. | ||
| 44541 | CALL TestFlag | Call TestFlag to test the offer-another-game flag. | ||
| 44544 | JR NZ,WantAnotherGameInput | Jump to WantAnotherGameInput if that flag is set. | ||
| 44546 | CALL Handler_UserInput | Call Handler_UserInput to read a command line. | ||
| 44549 | CALL Parser_ProcessItem | Call Parser_ProcessItem to tokenise that command. | ||
| 44552 | CALL NC,Handler_DispatchVerb | Call Handler_DispatchVerb when the command has a verb to dispatch. | ||
| 44555 | JR GameStart_MainLoop | Jump to GameStart_MainLoop. | ||
|
View the equivalent code in;
|
||||
| Prev: 44409 | Up: Map | Next: 44557 |