Sherlock: annotated disassembly

Routines

Prev: C142 Up: Map Next: C190
C14A: Set up the screen at the start of the game
Clears the screen (C10F), sets up the command window (36 characters left on its line (C1F4), the cursor at $50E0 - the start of the bottom row - and pixel shift 2), makes the text lines full width (C142), draws the chain strip (C190) across screen row 18, pixel lines 1 to 6, and colours that row with attribute $78. Called once, at $A049.
Output
The screen cleared and the command window set up
C14A CALL $C10F Clear the screen
C14D LD A,$24 Load A with $24 - 36 characters left on the command line
C14F LD ($C1F4),A Store A in "Command-window state" (C1F4)
C152 LD HL,$50E0 Load HL with $50E0 - Cursor at the start of the bottom row ($50E0)
C155 LD ($C1F6),HL Store HL in C1F6 in "Command-window state"
C158 LD A,$02 Load A with $02 - Pixel shift 2
C15A LD ($C1FB),A Store A in C1FB in "Command-window state"
C15D CALL $C142 Text lines full width
C160 LD HL,$5140 Load HL with $5140 - HL = row 18, pixel line 1; DE = the chain pattern
C163 LD DE,$C190 Point DE at "The chain strip that holds the clock: a 32-pixel..." (C190)
C166 LD B,$06 Six pixel lines
C168 LD C,$08 Load C with $08 - Each is the pattern's four bytes eight times over
C16A PUSH BC Save BC on the stack
C16B PUSH HL Save HL on the stack
C16C LD B,$04 Load B with $04
C16E PUSH DE Save DE on the stack
C16F LD A,(DE) Read the byte DE points at into A
C170 LD (HL),A Store A at the address HL points to
C171 INC DE Step DE on to the next byte
C172 INC L Add one to L
C173 DJNZ $C16F Count B down and, while it is not zero, go back to C16F
C175 POP DE Restore DE from the stack
C176 DEC C Subtract one from C
C177 JR NZ,$C16C If C is not zero, go back to C16C
C179 INC DE Step DE on to the next byte - Next four bytes of the pattern
C17A INC DE Step DE on to the next byte
C17B INC DE Step DE on to the next byte
C17C INC DE Step DE on to the next byte
C17D POP HL Restore HL from the stack - Next pixel line down
C17E POP BC Restore BC from the stack
C17F INC H Add one to H
C180 DJNZ $C168 Count B down and, while it is not zero, go back to C168
C182 LD HL,$5A40 Load HL with $5A40 - Colour row 18 with attribute $78
C185 LD DE,$5A41 Load DE with $5A41
C188 LD BC,$001F Load BC with $001F
C18B LD (HL),$78 Store $78 at the address HL points to
C18D LDIR Copy BC bytes from where HL points to where DE points, counting up
C18F RET Return to the caller
Prev: C142 Up: Map Next: C190