Prev: B519 Up: Map Next: B531
B520: Find Object Address
Used by the routines at DrawChangedObjects and DrawObjectsInOrder.
Finds the address of an object record, from its number. Bit 7 of the number is ignored, as that is used as a flag in the draw list.
Input
A Object number
Output
HL Address of the object record
Turn the object number into an address in the object table.
FindObjectAddress B520 PUSH BC Stash BC on the stack.
B521 AND %01111111 Ignore bit 7 of the object number.
Set HL to the object number.
B523 LD L,A Copy it to L.
B524 LD H,$00 Set H to 00.
B526 ADD HL,HL Multiply it by 20, the size of an object record.
B527 ADD HL,HL
B528 ADD HL,HL
B529 ADD HL,HL
B52A ADD HL,HL
B52B LD BC,$A76F Start from the object table, ObjectsTable.
B52E ADD HL,BC Add BC to HL.
B52F POP BC Restore BC from the stack.
B530 RET Return.
View the equivalent code in;
Prev: B519 Up: Map Next: B531