Sherlock: annotated disassembly

Routines

Prev: D237 Up: Map Next: D26C
D249: Move everything inside thing A, at any depth, to room B
Walks the things (D04F, D21C) and, for each one whose container (+1) is A, sets its room (+15) to B and does the same for what it holds (calling itself). Callers: $DD30, $DF1F.
Input
A the container
B the room
D249 PUSH IY Save IY on the stack
D24B PUSH IX Save IX on the stack
D24D CALL $D04F Start at the first thing
D250 CALL $D21C Call the routine "Step to the next thing's record (D206), keeping A" (D21C) - Next thing (IX its list entry, IY its record); Z at the end
D253 JR Z,$D267 If the zero flag is set, skip ahead to D267
D255 CP (IY+$01) Compare A with the holder byte (+1) of the thing record at IY - Held by A?
D258 JR NZ,$D250 If A differs from the holder byte (+1) of the thing record at IY, go back to D250
D25A LD (IY+$0F),B Store B in the rooms byte (+15) of the thing record at IY - Yes: it goes to room B
D25D PUSH AF Save AF on the stack
D25E LD A,(IX+$00) Read the number byte (+0) of the thing record at IX into A - and so does everything it holds
D261 CALL $D249 Call the routine "Move everything inside thing A, at any depth, to room..." (D249)
D264 POP AF Restore AF from the stack
D265 JR $D250 Go back to D250
D267 POP IX Restore IX from the stack
D269 POP IY Restore IY from the stack
D26B RET Return to the caller
Prev: D237 Up: Map Next: D26C