Prev: 39513 Up: Map Next: 39584
39557: Table: Find A Special Object
Finds a special object by its index.
Input
A The index to search for
TableFindASpecialObject 39557 PUSH DE Keep the id being sought.
39558 PUSH BC
39559 LD B,A
39560 LD HL,51915 Point HL at the special-object records.
39563 LD DE,7 Each special-object entry is 7 bytes.
TableFindASpecialObject_Loop 39566 LD A,(HL) If the current pointer matches our key jump to TableFindASpecialObject_PointAtTheRecord.
39567 CP B
39568 JR Z,TableFindASpecialObject_PointAtTheRecord
39570 CP 255 Jump to TableFindASpecialObject_PointAtTheRecord at the end of the special-object records.
39572 JR Z,TableFindASpecialObject_PointAtTheRecord
39574 ADD HL,DE Increase the pointer address by 0007 (using DE).
39575 JP TableFindASpecialObject_Loop Jump back to TableFindASpecialObject_Loop for the next special-object record.
TableFindASpecialObject_PointAtTheRecord 39578 POP BC Restore BC and DE from the stack, and copy the special-object record from HL into IY.
39579 POP DE
39580 PUSH HL
39581 POP IY
39583 RET Return.
Prev: 39513 Up: Map Next: 39584