![]()  | 
Routines | 
| Prev: 41015 | Up: Map | Next: 41176 | 
| 
 
Used by the routines at Alias_GameEntryPoint and 41191.
 
 | 
||||
| GameEntryPoint | 41024 | XOR A | Write 0 to | |
| 41025 | LD (54968),A | |||
| 41028 | LD (40987),A | |||
| 41031 | DI | Disable interrupts. | ||
| 41032 | CALL DrawDecorativeLine | Call DrawDecorativeLine. | ||
| 41035 | LD SP,23936 | SP=Table_WordIndex. | ||
| 41038 | CALL WaitForKeypress_Loop | Call WaitForKeypress_Loop. | ||
| 41041 | CP 110 | Jump to NoMeansNo if the keypress is ASCII code 110 ("n"). | ||
| 41043 | JR Z,NoMeansNo | |||
| 41045 | CP 78 | Compare the keypress with ASCII code 78 ("N"). | ||
| 41047 | LD A,1 | A=1. | ||
| 41049 | JR NZ,GameEntryPoint_0 | Jump to GameEntryPoint_0 if the keypress was not ASCII code 78 ("N"). | ||
| 
 
The player pressed either "N" or "n".
 
 | 
||||
| NoMeansNo | 41051 | XOR A | A=0. | |
| GameEntryPoint_0 | 41052 | LD (40977),A | Write A to *40977. | |
| 41055 | LD A,R | Write the contents of the Memory Refresh Register to *41015. | ||
| 41057 | LD (41015),A | |||
| 
 
This entry point is used by the routine at 41191.
 
 | 
||||
| Game_Initialisation | 41060 | XOR A | Write 0 to *41178. | |
| 41061 | LD (41178),A | |||
| Game_Loop | 41064 | LD A,(41178) | Jump to 41191 if *41178 is not zero. | |
| 41067 | AND A | |||
| 41068 | JR NZ,41191 | |||
| 41070 | CALL Handler_GameClock | Call Handler_GameClock. | ||
| 41073 | CALL Handler_DateBar | Call Handler_DateBar. | ||
| 
 
Handler for Sherlock (as he's the first character).
 
 | 
||||
| 41076 | LD IY,39008 | IY=Table_Timetable. | ||
| 41080 | LD A,(IY+3) | Fetch Sherlocks location. | ||
| 41083 | CP 50 | Jump to Handler_ProcessCharacters if Sherlock isn't in room 50: Main Street. | ||
| 41085 | JR NZ,Handler_ProcessCharacters | |||
| 41087 | CALL GetKeypress | Call GetKeypress. | ||
| 41090 | BIT 7,A | Jump to Handler_ProcessCharacters if the keypress was not valid or if the keypress was not 141 ("ENTER") - which is ASCII code 13 with bit 7 set for being a valid keypress. | ||
| 41092 | JR Z,Handler_ProcessCharacters | |||
| 41094 | CP 141 | |||
| 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 | Load Table_Timetable into IY. | |
| CharacterProcessing_Loop | 41111 | LD A,(IY+0) | Jump to Game_Loop if the character ID is the termination character (255). | |
| 41114 | INC A | |||
| 41115 | JR Z,Game_Loop | |||
| 
 
This is a valid character so begin processing them.
 
 | 
||||
| 41117 | LD HL,(40925) | Load *CurrentTime_Ticker into HL. | ||
| 41120 | CALL CheckCharacterSchedule | Call CheckCharacterSchedule. | ||
| 41123 | JR C,Character_Next | Jump to Character_Next if this character is not scheduled to have actions yet. | ||
| 
 
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 | Stash the timetable pointer and character ID on the stack. | ||
| 41130 | PUSH AF | |||
| 41131 | CALL 52279 | Call 52279. | ||
| 
 
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. | |
| 41135 | PUSH AF | But keep a copy of the character ID on the stack. | ||
| 41136 | CALL ScriptInterpreter | Call ScriptInterpreter. | ||
| 
 
Keep looping until the script for this character is finished.
 
 | 
||||
| 41139 | LD HL,(40991) | Jump back to CharacterScript_Loop until *CharacterScriptCycles is zero. | ||
| 41142 | LD A,L | |||
| 41143 | OR H | |||
| 41144 | JR Z,CharacterScript_Loop | |||
| 41146 | POP AF | Restore the character ID and timetable pointer 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 | Stash the timetable pointer on the stack briefly. | ||
| 41164 | CALL ExecuteCharacterAction | Call ExecuteCharacterAction. | ||
| 41167 | POP IY | Restore the timetable pointer from the stack. | ||
| 
 
Move to the next character in the timetable.
 
 | 
||||
| Character_Next | 41169 | LD DE,8 | IY+=0008. | |
| 41172 | ADD IY,DE | |||
| 41174 | JR CharacterProcessing_Loop | Jump to CharacterProcessing_Loop. | ||
| Prev: 41015 | Up: Map | Next: 41176 |