![]() |
Routines |
| Prev: AD79 | Up: Map | Next: AE0D |
|
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 0181 state bytes.
|
||||
| GameStart | ADA1 | LD HL,$9F88 | Point HL at the item locations table at Table_ItemLocations. | |
| ADA4 | LD BC,$0181 | Load BC with 0181 bytes to clear. | ||
| GameStart_ClearLoop | ADA7 | LD (HL),$00 | Write 00 through HL. | |
| ADA9 | INC HL | Move HL on to the next byte to clear. | ||
| ADAA | DEC BC | Decrease BC and loop back to GameStart_ClearLoop until every byte is clear. | ||
| ADAB | LD A,B | |||
| ADAC | OR C | |||
| ADAD | JR NZ,GameStart_ClearLoop | |||
|
Copy the starting item locations and carrying limit.
|
||||
| ADAF | LD HL,$BB0B | Copy *Count_Items bytes from Table_InitialItemLocations to Table_ItemLocations. | ||
| ADB2 | LD DE,$9F88 | |||
| ADB5 | LD BC,($BBC7) | |||
| ADB9 | LDIR | |||
| ADBB | LD A,($BBD7) | Write *InitialCarryingLimit to *CarryingLimit. | ||
| ADBE | LD ($A0D3),A | |||
|
Prime each saved-state address from Table_SavedStateAddresses with the matching byte from InitialSavedStateBytes.
|
||||
| ADC1 | LD IX,$BAF9 | Point IX at the saved-state address table at Table_SavedStateAddresses. | ||
| ADC5 | LD DE,$BB05 | Point DE at the initial-state bytes at InitialSavedStateBytes. | ||
| ADC8 | LD A,($BBD1) | Load the saved-state count from *Count_SavedStateBytes into B. | ||
| ADCB | LD B,A | |||
| GameStart_InitStateLoop | ADCC | LD L,(IX+$00) | Fetch the next destination address from *IX into HL. | |
| ADCF | LD H,(IX+$01) | |||
| ADD2 | LD A,(DE) | Fetch the next initial-state byte from *DE into A. | ||
| ADD3 | LD (HL),A | Write that byte through HL. | ||
| ADD4 | INC IX | Move IX on to the next saved-state address. | ||
| ADD6 | INC IX | |||
| ADD8 | INC DE | Move DE on to the next initial-state byte. | ||
| ADD9 | 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.
|
||||
| ADDB | CALL JustReturn | Call JustReturn to clear the play screen. | ||
| ADDE | LD A,($BBD3) | Write *StartingRoom to *CurrentRoom. | ||
| ADE1 | LD ($A106),A | |||
| ADE4 | CALL ChangeRoom | Call ChangeRoom to change into the starting room. | ||
|
Process turn events and scenic events, then read the next command.
|
||||
| GameStart_MainLoop | ADE7 | CALL Handler_GameEvents | Call Handler_GameEvents to process turn-based events. | |
| ADEA | CALL Handler_ScenicEvents | Call Handler_ScenicEvents to process scenic events. | ||
| ADED | LD A,$00 | Load flag bit 00 into A. | ||
| ADEF | CALL TestFlag | Call TestFlag to test whether the player is dead. | ||
| ADF2 | JR NZ,GameOver | Jump to GameOver if the player is dead. | ||
| ADF4 | LD A,$01 | Load flag bit 01 into A. | ||
| ADF6 | CALL TestFlag | Call TestFlag to test the score/end flag. | ||
| ADF9 | JR NZ,GameOver_Score | Jump to GameOver_Score if that flag is set. | ||
| ADFB | LD A,$02 | Load flag bit 02 into A. | ||
| ADFD | CALL TestFlag | Call TestFlag to test the offer-another-game flag. | ||
| AE00 | JR NZ,WantAnotherGameInput | Jump to WantAnotherGameInput if that flag is set. | ||
| AE02 | CALL Handler_UserInput | Call Handler_UserInput to read a command line. | ||
| AE05 | CALL Parser_ProcessItem | Call Parser_ProcessItem to tokenise that command. | ||
| AE08 | CALL NC,Handler_DispatchVerb | Call Handler_DispatchVerb when the command has a verb to dispatch. | ||
| AE0B | JR GameStart_MainLoop | Jump to GameStart_MainLoop. | ||
|
View the equivalent code in;
|
||||
| Prev: AD79 | Up: Map | Next: AE0D |