Prev: 92FA Up: Map Next: 9341
9307: Update Chasing Object
Used by the routine at UpdateShots.
Moves an object that is chasing one of the enemies. The slot number of the target is held in the top four bits of the second set of flags; when all four are set, a new target is chosen with ChooseTarget.
Input
IX Address of the object
UpdateChasingObject 9307 LD A,(IX+$17) Fetch the second set of flags.
930A AND %11110000 Keep the top four bits.
930C CP $F0 Are all of them set?
930E CALL Z,ChooseTarget Choose a target if so.
9311 LD A,(IX+$17) Fetch the second set of flags again.
9314 AND %11110000 Keep the top four bits.
9316 CP $F0 Jump to UpdateObject if all of them set are.
9318 JP Z,UpdateObject
931B RLCA Shift the slot number into the bottom four bits.
931C RLCA
931D RLCA
931E RLCA
931F LD B,A Keep it in B.
9320 LD DE,$0018 Set the length of a slot.
9323 LD IY,$9974 Use the first enemy slot.
9327 AND A Test the slot number.
9328 JR Z,UpdateChasingObject_Target Jump to UpdateChasingObject_Target if it is zero.
UpdateChasingObject_Find 932A ADD IY,DE Move on to the next slot.
932C DJNZ UpdateChasingObject_Find Decrease the slot number by one and loop back to UpdateChasingObject_Find until none remain.
UpdateChasingObject_Target 932E LD A,(IY+$00) Fetch the type of the object in the target slot.
9331 INC A Increment it.
9332 JR NZ,UpdateChasingObject_Chase Jump to UpdateChasingObject_Chase if the slot is in use.
9334 LD (IX+$17),$F0 Otherwise forget the target.
9338 JP UpdateObject Jump to UpdateObject.
UpdateChasingObject_Chase 933B CALL AccelerateTowardsTarget Set the acceleration towards the target.
933E JP UpdateObject Jump to UpdateObject.
Prev: 92FA Up: Map Next: 9341