We need create a list with which objects the Sonic can attack, here's the main difference of the Homing Attack and the Light Dash (the Light Dash only move the Sonic in ring direction).
Modify this code to get it ready for the enemy list:
If you look, you see that the old code, all not null objects may be chased by Sonic, but in new code, if is a null objects, search for another object, and if not, unlike the old code, the code continues with the enemy list that we will add.
Now below these lines:
This list is to the objects the Sonic can attack, the Bomb enemy per example, is out of the list, because is not good attack it.
Why work with the "touch response number"?
Because is more easy than work with the object number (that goes more or less until $8C), the game itself uses the "touch response number" to know if is a enemy, monitor, and other objects.
In the Homing Attack we use the same principle, mainly, we need to attack the enemy, and a variable that encompasses all enemies is the "touch response number". Thus, instead of program several lines, one for each object, we can program a line for all (with the exception of Yadrin enemy).
Modify this code to get it ready for the enemy list:
- Code:
HA_enemylist:
tst.b (a1) ; is a Null object
bne.s HA_calcdistance ; if not, branch
- Code:
HA_enemylist:
tst.b (a1) ; is a Null object
beq.s HA_nextobject ; if yes, branch
If you look, you see that the old code, all not null objects may be chased by Sonic, but in new code, if is a null objects, search for another object, and if not, unlike the old code, the code continues with the enemy list that we will add.
Now below these lines:
- Code:
HA_enemylist:
tst.b (a1) ; is a Null object
beq.s HA_nextobject ; if yes, branch
- Code:
cmpi.b #5,$20(a1) ; is not an enemy object? (spring, explosion, platform, collected ring, flame thrower (SBZ), among others)
bcs.w HA_nextobject ; if yes, branch
; cmpi.b #5,$20(a1) ; is Burrobot enemy (LZ)
; beq.w HA_calcdistance ; if yes, branch
; cmpi.b #6,$20(a1) ; is Crabmeat enemy (GHZ, SYZ)
; beq.s HA_calcdistance ; if yes, branch
; cmpi.b #8,$20(a1) ; is Buzz Bomber enemy (GHZ, MZ, SYZ)
; beq.s HA_calcdistance ; if yes, branch
; cmpi.b #9,$20(a1) ; is Chopper enemy (GHZ)
; beq.s HA_calcdistance ; if yes, branch
; cmpi.b #$A,$20(a1) ; is Jaws enemy (LZ)
; beq.s HA_calcdistance ; if yes, branch
; cmpi.b #$B,$20(a1) ; is Caterkiller enemy (MZ, SBZ) / Orbinaut enemy (LZ, SLZ, SBZ) / Basaran enemy (MZ)
; beq.s HA_calcdistance ; if yes, branch
; cmpi.b #$C,$20(a1) ; is Roller enemy (SYZ) / Newtron enemy (GHZ)
; beq.s HA_calcdistance ; if yes, branch
; cmpi.b #$D,$20(a1) ; is Newtron enemy (GHZ)
; beq.s HA_calcdistance ; if yes, branch
; cmpi.b #$E,$20(a1) ; is Roller enemy (SYZ)
; beq.s HA_calcdistance ; if yes, branch
; cmpi.b #$F,$20(a1) ; is Eggman
; beq.s HA_calcdistance ; if yes, branch
cmpi.b #$F,$20(a1) ; is some enemy of the list above?
bls.s HA_calcdistance ; if yes, branch
cmpi.b #$46,$20(a1) ; is the monitor?
beq.s HA_calcdistance ; if yes, branch
; cmpi.b #$47,$20(a1) ; is the ring?
; beq.s HA_calcdistance ; if yes, branch
cmpi.b #$52,$20(a1) ; is giant ring for entry to special stage?
beq.s HA_calcdistance ; if yes, branch
cmpi.b #$CC,$20(a1) ; is Yadrin enemy (SYZ)
beq.s HA_calcdistance ; if yes, branch
This list is to the objects the Sonic can attack, the Bomb enemy per example, is out of the list, because is not good attack it.
Why work with the "touch response number"?
Because is more easy than work with the object number (that goes more or less until $8C), the game itself uses the "touch response number" to know if is a enemy, monitor, and other objects.
In the Homing Attack we use the same principle, mainly, we need to attack the enemy, and a variable that encompasses all enemies is the "touch response number". Thus, instead of program several lines, one for each object, we can program a line for all (with the exception of Yadrin enemy).