Prev: 53157 Up: Map Next: 53234
53167: Find Objects In Cell
Used by the routine at DrawCellAndObjects.
Makes a list at ObjectList of the addresses of all of the objects which are in a cell. The list ends with a zero word.
Input
HL The cell: the column in L and the row in H
Point at the list and the first object slot.
FindObjectsInCell 53167 LD IY,53597 Point IY at ObjectList.
53171 LD IX,48270 Point IX at ObjectTable.
Turn the cell round if the view is rotated.
53175 CALL ConvertCell Call ConvertCell.
53178 EX DE,HL Keep the column in E and the row in D.
Look at this slot.
FindObjectsInCell_Loop 53179 LD A,(IX+0) Jump to FindObjectsInCell_Next to move on if the object is free.
53182 AND A
53183 JR Z,FindObjectsInCell_Next
53185 LD A,E Jump to FindObjectsInCell_Next to move on if the object is not in the column.
53186 CP (IX+2)
53189 JR NZ,FindObjectsInCell_Next
53191 LD A,D Jump to FindObjectsInCell_Next to move on if the object is not in the row.
53192 CP (IX+4)
53195 JR NZ,FindObjectsInCell_Next
53197 PUSH IX Copy the address of the object into HL (using the stack).
53199 POP HL
53200 LD (IY+0),L Add the address of the object to the list.
53203 LD (IY+1),H
53206 INC IY Move on to the next place in the list.
53208 INC IY
Move on to the next object.
FindObjectsInCell_Next 53210 LD BC,16 Move on to the next object slot.
53213 ADD IX,BC
53215 PUSH IX Copy the address of the object to HL (using the stack).
53217 POP HL
See whether every slot has been looked at.
53218 LD BC,48638 Check whether the end of the object table at StartGame has been reached.
53221 AND A
53222 SBC HL,BC
Go back for the next slot.
53224 JR C,FindObjectsInCell_Loop Loop back until all 23 objects have been checked.
End the list.
53226 XOR A Write a zero word to the end of the list.
53227 LD (IY+0),A
53230 LD (IY+1),A
53233 RET Return.
View the equivalent code in;
Prev: 53157 Up: Map Next: 53234