Prev: 54089 Up: Map Next: 54122
54094: Search Three-Byte Length Table
Input
A Table ID to match
IX Table to search
Output
A Entry ID or 255 for no entry found
IX Pointer to found entry
F The zero flag is set when no entry was found
SearchThreeByteTable 54094 EXX Switch to the shadow registers.
54095 LD E,3 Set the length of the data in E (3 bytes).
This entry point is used by the routine at SearchTwoByteTable.
SearchTable_Start 54097 PUSH IX Copy the table for searching into HL (using the stack).
54099 POP HL
54100 LD B,A Copy the table ID into B.
54101 LD D,0 Reset D to 0 for the length offset calculation.
SearchTable_Loop 54103 LD A,(HL) Fetch a byte from the table.
54104 CP B Jump to SearchTable_Return if the byte is the table ID we're searching for or if the termination character has been reached (255).
54105 JR Z,SearchTable_Return
54107 CP 255
54109 JR Z,SearchTable_Return
54111 ADD HL,DE Move to the next table entry.
54112 JP SearchTable_Loop Jump back to SearchTable_Loop.
Either the table ID was matched, or the terminator was reached.
SearchTable_Return 54115 PUSH HL Copy the table pointer into IX (using the stack).
54116 POP IX
54118 CP 255 Set the zero flag if the termination character was reached (255).
54120 EXX Switch back to the normal registers.
54121 RET Return.
Prev: 54089 Up: Map Next: 54122