Prev: A037 Up: Map Next: A0D8
A040: Game Entry Point
Used by the routines at Alias_GameEntryPoint and A0E7.
GameEntryPoint A040 XOR A Write 00 to
A041 LD ($D6B8),A
A044 LD ($A01B),A
A047 DI Disable interrupts.
A048 CALL DrawDecorativeLine Call DrawDecorativeLine.
A04B LD SP,$5D80 SP=Table_WordIndex.
A04E CALL WaitForKeypress_Loop Call WaitForKeypress_Loop.
A051 CP $6E Jump to NoMeansNo if the keypress is ASCII code 6E ("n").
A053 JR Z,NoMeansNo
A055 CP $4E Compare the keypress with ASCII code 4E ("N").
A057 LD A,$01 A=01.
A059 JR NZ,GameEntryPoint_0 Jump to GameEntryPoint_0 if the keypress was not ASCII code 4E ("N").
The player pressed either "N" or "n".
NoMeansNo A05B XOR A A=00.
GameEntryPoint_0 A05C LD ($A011),A Write A to *A011.
A05F LD A,R Write the contents of the Memory Refresh Register to *A037.
A061 LD ($A037),A
This entry point is used by the routine at A0E7.
Game_Initialisation A064 XOR A Write 00 to *A0DA.
A065 LD ($A0DA),A
Game_Loop A068 LD A,($A0DA) Jump to A0E7 if *A0DA is not zero.
A06B AND A
A06C JR NZ,$A0E7
A06E CALL Handler_GameClock Call Handler_GameClock.
A071 CALL Handler_DateBar Call Handler_DateBar.
Handler for Sherlock (as he's the first character).
A074 LD IY,$9860 IY=Table_Timetable.
A078 LD A,(IY+$03) Fetch Sherlocks location.
A07B CP $32 Jump to Handler_ProcessCharacters if Sherlock isn't in room 32: Main Street.
A07D JR NZ,Handler_ProcessCharacters
A07F CALL GetKeypress Call GetKeypress.
A082 BIT 7,A Jump to Handler_ProcessCharacters if the keypress was not valid or if the keypress was not 8D ("ENTER") - which is ASCII code 0D with bit 7 set for being a valid keypress.
A084 JR Z,Handler_ProcessCharacters
A086 CP $8D
A088 JR NZ,Handler_ProcessCharacters
A08A LD HL,($9FDD) Write *CurrentTime_Ticker to *IY+06/ *IY+07.
A08D LD (IY+$06),L
A090 LD (IY+$07),H
Cycle through the character timetable and run through each characters script according to their schedule and current game time.
Handler_ProcessCharacters A093 LD IY,$9860 Load Table_Timetable into IY.
CharacterProcessing_Loop A097 LD A,(IY+$00) Jump to Game_Loop if the character ID is the termination character (FF).
A09A INC A
A09B JR Z,Game_Loop
This is a valid character so begin processing them.
A09D LD HL,($9FDD) Load *CurrentTime_Ticker into HL.
A0A0 CALL CheckCharacterSchedule Call CheckCharacterSchedule.
A0A3 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.
A0A5 LD A,(IY+$00) Fetch the character ID and store it in A.
A0A8 PUSH IY Stash the timetable pointer and character ID on the stack.
A0AA PUSH AF
A0AB CALL $CC37 Call CC37.
Repeatedly execute the characters script until it completes or encounters a wait condition.
CharacterScript_Loop A0AE POP AF Restore the character ID from the stack.
A0AF PUSH AF But keep a copy of the character ID on the stack.
A0B0 CALL ScriptInterpreter Call ScriptInterpreter.
Keep looping until the script for this character is finished.
A0B3 LD HL,($A01F) Jump back to CharacterScript_Loop until *CharacterScriptCycles is zero.
A0B6 LD A,L
A0B7 OR H
A0B8 JR Z,CharacterScript_Loop
A0BA POP AF Restore the character ID and timetable pointer from the stack.
A0BB POP IY
Set up the next schedule time for this character.
A0BD LD E,(IY+$06) Add the characters schedule time to the current time...
A0C0 LD D,(IY+$07)
A0C3 ADD HL,DE
A0C4 LD (IY+$06),L And write it back to the characters schedule.
A0C7 LD (IY+$07),H
A0CA PUSH IY Stash the timetable pointer on the stack briefly.
A0CC CALL ExecuteCharacterAction Call ExecuteCharacterAction.
A0CF POP IY Restore the timetable pointer from the stack.
Move to the next character in the timetable.
Character_Next A0D1 LD DE,$0008 IY+=0008.
A0D4 ADD IY,DE
A0D6 JR CharacterProcessing_Loop Jump to CharacterProcessing_Loop.
Prev: A037 Up: Map Next: A0D8