Sherlock: annotated disassembly

Routines

Prev: A0F7 Up: Map Next: A11A
A104: Find the node before node DE in the list at IY
Leaves IY at the node (or list head) whose link points at DE, so the caller can unlink DE.
Input
IY The list head
DE The node to find
Output
IY The node (or list head) whose link points at DE
A104 INC IY Step IY on to the next byte - Start after the list head's own link
A106 INC IY Step IY on to the next byte
A108 LD L,(IY-$02) Read byte -2 of the record at IY into L - HL = the link (the next node's address) at IY - 2
A10B LD H,(IY-$01) Read byte -1 of the record at IY into H
A10E AND A Test A for zero (this leaves A as it was and clears carry)
A10F PUSH HL Save HL on the stack
A110 SBC HL,DE Subtract DE and the carry from HL - Is it node DE? Then IY is the node before it
A112 JR Z,$A118 If the two values are equal, skip ahead to A118
A114 POP IY Restore IY from the stack - No: step to that node and look again
A116 JR $A108 Go back to A108
A118 POP HL Restore HL from the stack
A119 RET Return to the caller
Prev: A0F7 Up: Map Next: A11A