Sherlock: annotated disassembly

Routines

Prev: 9FD6 Up: Map Next: A064
A040: Start the game
The game's own entry point. Clears two flag bytes, resets the stack to 5D80 (reusing the loader's own workspace, which is no longer needed), and clears the screen.
Then it waits for a single keypress to choose New Game vs Continue: pressing 'n' or 'N' starts a new game (clears a flag at $A011); anything else leaves that flag set, and the code that follows loads state back from a table at 9860, so this is very likely also how a restored/continued game resumes its characters' positions.
Seeds a simple RNG from the Z80 refresh register (R) - a common period-accurate trick, since R free-runs on every instruction fetch and so is effectively unpredictable at the moment the player first presses a key.
From A064 on is the game's main loop - see there.
Output
F None: this routine never returns, it falls into the main loop
A040 XOR A Clear the 'currently examining' flag
A041 LD ($D6B8),A Store A in "A flag of the player's script step, and spare..." (D6B8)
A044 LD ($A01B),A Clear another one-shot flag
A047 DI No interrupts while we set things up
A048 CALL $C14A Clear the screen and set up the text window
A04B LD SP,$5D80 Stack now safely below the game's own code/data
A04E CALL $C415 Wait here for the player's very first keypress
A051 CP $6E Did they press lowercase 'n'?
A053 JR Z,$A05B If A equals $6E, skip ahead to A05B
A055 CP $4E ...or uppercase 'N'?
A057 LD A,$01 Default: treat as "continue" (flag = 1)
A059 JR NZ,$A05C If A differs from $4E, skip ahead to A05C
A05B XOR A "New game" was chosen instead (flag = 0)
A05C LD ($A011),A Store A in $A011 in "Game variables"
A05F LD A,R A = the free-running refresh register...
A061 LD ($A037),A ...used as an unpredictable RNG seed
Prev: 9FD6 Up: Map Next: A064