Prev: 37626 Up: Map Next: 37697
37639: 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 37639 LD A,(IX+23) Fetch the second set of flags.
37642 AND %11110000 Keep the top four bits.
37644 CP 240 Are all of them set?
37646 CALL Z,ChooseTarget Choose a target if so.
37649 LD A,(IX+23) Fetch the second set of flags again.
37652 AND %11110000 Keep the top four bits.
37654 CP 240 Jump to UpdateObject if all of them set are.
37656 JP Z,UpdateObject
37659 RLCA Shift the slot number into the bottom four bits.
37660 RLCA
37661 RLCA
37662 RLCA
37663 LD B,A Keep it in B.
37664 LD DE,24 Set the length of a slot.
37667 LD IY,39284 Use the first enemy slot.
37671 AND A Test the slot number.
37672 JR Z,UpdateChasingObject_Target Jump to UpdateChasingObject_Target if it is zero.
UpdateChasingObject_Find 37674 ADD IY,DE Move on to the next slot.
37676 DJNZ UpdateChasingObject_Find Decrease the slot number by one and loop back to UpdateChasingObject_Find until none remain.
UpdateChasingObject_Target 37678 LD A,(IY+0) Fetch the type of the object in the target slot.
37681 INC A Increment it.
37682 JR NZ,UpdateChasingObject_Chase Jump to UpdateChasingObject_Chase if the slot is in use.
37684 LD (IX+23),240 Otherwise forget the target.
37688 JP UpdateObject Jump to UpdateObject.
UpdateChasingObject_Chase 37691 CALL AccelerateTowardsTarget Set the acceleration towards the target.
37694 JP UpdateObject Jump to UpdateObject.
Prev: 37626 Up: Map Next: 37697