![]() |
Routines |
| Prev: 41024 | Up: Map | Next: 41176 |
|
Used by the routine at LoadOrSaveGame_Save.
Clears the startup flag, updates the date bar, and walks each character until play begins.
|
||||
| Game_Initialisation | 41060 | XOR A | Clear the startup flag. | |
| 41061 | LD (41178),A | |||
| Game_Loop | 41064 | LD A,(41178) | Jump to LoadOrSaveGame if the startup flag is set. | |
| 41067 | AND A | |||
| 41068 | JR NZ,LoadOrSaveGame | |||
| 41070 | CALL Handler_GameClock | Call Handler_GameClock to show the game clock, then call Handler_DateBar to show the date bar. | ||
| 41073 | CALL Handler_DateBar | |||
|
Handler for Sherlock (as he's the first character).
|
||||
| 41076 | LD IY,39008 | Use the timetable at Table_Timetable. | ||
| 41080 | LD A,(IY+3) | Fetch Sherlocks location. | ||
| 41083 | CP 50 | Jump ahead to Handler_ProcessCharacters if the schedule entry is not 50. | ||
| 41085 | JR NZ,Handler_ProcessCharacters | |||
| 41087 | CALL GetKeypress | Call GetKeypress to read the keyboard, and go to Handler_ProcessCharacters if no key was pressed. | ||
| 41090 | BIT 7,A | |||
| 41092 | JR Z,Handler_ProcessCharacters | |||
| 41094 | CP 141 | Jump to Handler_ProcessCharacters if the player did not press "ENTER". | ||
| 41096 | JR NZ,Handler_ProcessCharacters | |||
| 41098 | LD HL,(40925) | Write *CurrentTime_Ticker to *IY+6/ *IY+7. | ||
| 41101 | LD (IY+6),L | |||
| 41104 | LD (IY+7),H | |||
|
Cycle through the character timetable and run through each characters script according to their schedule and current game time.
|
||||
| Handler_ProcessCharacters | 41107 | LD IY,39008 | Use the timetable at Table_Timetable. | |
| CharacterProcessing_Loop | 41111 | LD A,(IY+0) | Jump to Game_Loop if the character id is 255. | |
| 41114 | INC A | |||
| 41115 | JR Z,Game_Loop | |||
|
This is a valid character so begin processing them.
|
||||
| 41117 | LD HL,(40925) | Call CheckCharacterSchedule to check character schedule. | ||
| 41120 | CALL CheckCharacterSchedule | |||
| 41123 | JR C,Character_Next | Go to Character_Next if the current time is below this character's schedule time. | ||
|
The currently processed character has an active schedule so process it.
|
||||
| 41125 | LD A,(IY+0) | Fetch the character ID and store it in A. | ||
| 41128 | PUSH IY | Call ProcessCharacterAction to run this character's action. | ||
| 41130 | PUSH AF | |||
| 41131 | CALL ProcessCharacterAction | |||
|
Repeatedly execute the characters script until it completes or encounters a wait condition.
|
||||
| CharacterScript_Loop | 41134 | POP AF | Restore the character ID from the stack, keeping a copy there. | |
| 41135 | PUSH AF | |||
|
Script interpreter.
|
||||
| 41136 | CALL ScriptInterpreter | Call ScriptInterpreter to run this character's script. | ||
|
Keep looping until the script for this character is finished.
|
||||
| 41139 | LD HL,(40991) | Jump back to CharacterScript_Loop if CharacterScriptCycles is zero. | ||
| 41142 | LD A,L | |||
| 41143 | OR H | |||
| 41144 | JR Z,CharacterScript_Loop | |||
| 41146 | POP AF | Restore the saved character ID and the schedule entry from the stack. | ||
| 41147 | POP IY | |||
|
Set up the next schedule time for this character.
|
||||
| 41149 | LD E,(IY+6) | Add the characters schedule time to the current time. | ||
| 41152 | LD D,(IY+7) | |||
| 41155 | ADD HL,DE | |||
| 41156 | LD (IY+6),L | And write it back to the characters schedule. | ||
| 41159 | LD (IY+7),H | |||
| 41162 | PUSH IY | Call ExecuteCharacterAction to execute character action. | ||
| 41164 | CALL ExecuteCharacterAction | |||
| 41167 | POP IY | |||
|
Move to the next character in the timetable.
|
||||
| Character_Next | 41169 | LD DE,8 | Jump back to CharacterProcessing_Loop, the character processing loop. | |
| 41172 | ADD IY,DE | |||
| 41174 | JR CharacterProcessing_Loop | |||
| Prev: 41024 | Up: Map | Next: 41176 |