Prev: 9B7F Up: Map Next: 9C41
9C07: Search Pair Table
Walks the character-id list at 9B7F and stops when the id matches either column, or when the list ends.
SearchPairTable 9C07 LD IX,$9B7F Use the location pairs (9B7F).
9C0B PUSH BC
9C0C LD B,A
SearchPairTable_Loop 9C0D LD A,(IX+$00) Jump to SearchPairTable_TestStepSucceedsScript if this pair's first byte is the end marker FF.
9C10 CP $FF
9C12 JR Z,SearchPairTable_TestStepSucceedsScript
9C14 LD A,B Jump ahead to SearchPairTable_Next if this id matches the first room in this pair.
9C15 CP (IX+$00)
9C18 JR Z,SearchPairTable_Next
9C1A CP (IX+$01) Jump ahead to SearchPairTable_TestAdvanceCharacterPair if this id does not match the second room in this pair.
9C1D JR NZ,SearchPairTable_TestAdvanceCharacterPair
9C1F LD A,C Jump ahead to SearchPairTable_PairMatchedCaller if C is zero.
9C20 AND A
9C21 JR Z,SearchPairTable_PairMatchedCaller
9C23 CP (IX+$00) Jump ahead to SearchPairTable_TestAdvanceCharacterPair if C does not match the first room in this pair.
9C26 JR NZ,SearchPairTable_TestAdvanceCharacterPair
9C28 JR SearchPairTable_PairMatchedCaller Both rooms in this pair match, so accept the pair at SearchPairTable_PairMatchedCaller.
A zero in C, or a match in the second column, accepts the pair.
SearchPairTable_Next 9C2A LD A,C Jump ahead to SearchPairTable_PairMatchedCaller if C is zero.
9C2B AND A
9C2C JR Z,SearchPairTable_PairMatchedCaller
9C2E CP (IX+$01) Jump ahead to SearchPairTable_PairMatchedCaller if C matches the second room in this pair.
9C31 JR Z,SearchPairTable_PairMatchedCaller
SearchPairTable_TestAdvanceCharacterPair 9C33 INC IX Advance to the next character pair and keep looking.
9C35 INC IX
9C37 INC IX
9C39 JR SearchPairTable_Loop
The pair matched, so return the id the caller passed in.
SearchPairTable_PairMatchedCaller 9C3B POP BC Restore the id the caller passed in from the stack.
9C3C RET Return.
SearchPairTable_TestStepSucceedsScript 9C3D OR $01 Reset the zero flag.
9C3F POP BC Restore BC from the stack.
9C40 RET Return.
Prev: 9B7F Up: Map Next: 9C41