Sherlock: annotated disassembly

Routines

Prev: D51A Up: Map Next: D57C
D526: List the things in place A, then what each of them holds
Names each listable thing (D57D) with commas and a final AND (D3D9, A414), marking each as seen (+6 bit 7); then, for each that has things of its own to list (D4CC), says how they are held (D590) and lists those too (calling itself). Watson is carrying the daily chronicle.'
How it works:
1. First pass: name each listable thing in the place (D57D), marking it as seen (+6 bit 7).
2. After each name put a comma, but AND before the last two and a full stop after the last.
3. Second pass: for each thing that holds others, say how it holds them (D590) and list what it holds in the same way, going down the levels.
Input
A A place
C The number of things to name
Output
The things named with commas and AND, each marked seen (+6 bit 7)
D526 PUSH IX Save IX on the stack
D528 CALL $D04F Call the routine "IX = just before the start of the thing index (8B6F)" (D04F) - First pass: name everything listable in A
D52B PUSH AF Save AF on the stack
D52C CALL $D57D Call D57D (inside "The next listable thing in place A (carry...") - Next one (D57D); carry: no more
D52F JR C,$D55A If the carry flag is set, jump on to D55A
D531 SET 7,(IY+$06) Mark it as seen (+6 bit 7)
D535 SUB A Clear A to zero - Its name with an article (D3D9)
D536 LD ($A028),A Store A in $A028 in "Game variables"
D539 CALL $D3D9 Call D3D9 (inside "Print thing IX's name")
D53C DEC C Subtract one from C - C counts down the things still to name: the last gets a full stop (A414),
D53D LD A,C Copy C into A
D53E AND A Test A for zero (this leaves A as it was and clears carry)
D53F JR NZ,$D546 If A is not zero, skip ahead to D546
D541 CALL $A414 Call A414 (inside "Print the rest of a narrated command: verb...")
D544 JR $D557 Skip ahead to D557
D546 CP $01 Compare A with $01 - the one before it AND ($005D), the rest a comma
D548 JR Z,$D551 If A equals $01, skip ahead to D551
D54A LD A,$2C Load A with $2C - ...and the rest a comma
D54C CALL $A9B7 Call the routine "Print character A, a word at a time (word wrap)" (A9B7)
D54F JR $D557 Skip ahead to D557
D551 LD DE,$005D Load DE with $005D
D554 CALL $A887 Call A887 (inside "Print the dictionary word that HL refers to")
D557 POP AF Restore AF from the stack
D558 JR $D52B Go back to D52B
D55A POP AF Second pass: for each listed thing that holds things itself (D4CC)...
D55B CALL $D04F Call the routine "IX = just before the start of the thing index (8B6F)" (D04F) - Second pass: for each thing that holds others (D4CC), say how (D590) and list what it holds (recursively, D526)
D55E PUSH AF Save AF on the stack
D55F CALL $D57D Call D57D (inside "The next listable thing in place A (carry...")
D562 JR C,$D578 If the carry flag is set, skip ahead to D578
D564 PUSH AF Save AF on the stack
D565 CALL $D4CC Call the routine "Count the things in place B that should be listed (B)" (D4CC)
D568 JR Z,$D574 If the zero flag is set, skip ahead to D574
D56A LD C,A Copy A into C
D56B POP AF Restore AF from the stack
D56C CALL $D590 Call the routine "Say what a person is carrying, or what is on or in a..." (D590) - ...say how they are held (D590) and list them too (recursion)
D56F CALL $D526 Call the routine "List the things in place A, then what each of them..." (D526)
D572 JR $D575 Skip ahead to D575
D574 POP AF Restore AF from the stack
D575 POP AF Restore AF from the stack
D576 JR $D55E Go back to D55E
D578 POP AF Restore AF from the stack
D579 POP IX Restore IX from the stack
D57B RET Return to the caller
Prev: D51A Up: Map Next: D57C