Better (not best) collision with tank check

.... and corrected two defensive weapon numbers - Mag Deflector and Auto Defence are working.
This commit is contained in:
Pecusx
2022-06-16 17:52:34 +02:00
parent 2992bd40b3
commit f924868459
2 changed files with 30 additions and 35 deletions
BIN
View File
Binary file not shown.
+30 -35
View File
@@ -1850,9 +1850,9 @@ EndOfFlight2
tax tax
dex ; index of tank in X dex ; index of tank in X
lda ActiveDefenceWeapon,x lda ActiveDefenceWeapon,x
cmp #60 ; Auto Defence cmp #61 ; Auto Defence
beq AutoDefence beq AutoDefence
cmp #55 ; Mag Deflector cmp #56 ; Mag Deflector
bne NoDefence bne NoDefence
MagDeflector MagDeflector
; now run defensive-aggressive weapon - Mag Deflector! ; now run defensive-aggressive weapon - Mag Deflector!
@@ -2296,14 +2296,23 @@ MIRValreadyAll
CheckCollisionWithTankLoop CheckCollisionWithTankLoop
lda eXistenZ,x lda eXistenZ,x
beq DeadTank beq DeadTank
; first we test top and bottom (same with and without shield!)
lda ytankstable,x
cmp ydraw ; check range
bcc BelowTheTank ;(ytankstable,ytankstable+3)
sbc #4 ; we must rewrite EndOfTheBarrelY table or remove Y correction completely to "bold" tank !!!
cmp ydraw
bcs OverTheTank
; with or without shield ?
lda ShieldEnergy,x lda ShieldEnergy,x
bne CheckCollisionWithShieldedTank ; tank with shield is bigger :) bne CheckCollisionWithShieldedTank ; tank with shield is bigger :)
lda xtankstableH,x lda xtankstableH,x
cmp xdraw+1 cmp xdraw+1
bne Condition01 bne @+
lda xtankstableL,x lda xtankstableL,x
cmp xdraw cmp xdraw
Condition01 @
bcs LeftFromTheTank ;add 8 double byte bcs LeftFromTheTank ;add 8 double byte
clc clc
adc #8 adc #8
@@ -2311,17 +2320,11 @@ Condition01
lda xtankstableH,x lda xtankstableH,x
adc #0 adc #0
cmp xdraw+1 cmp xdraw+1
bne Condition02 bne @+
cpy xdraw cpy xdraw
Condition02 @
bcc RightFromTheTank bcc RightFromTheTank
TankHit
lda ytankstable,x
cmp ydraw ; check range
bcc BelowTheTank ;(ytankstable,ytankstable+3)
sbc #4
cmp ydraw
bcs OverTheTank
inx inx
stx HitFlag ; index of hit tank+1 stx HitFlag ; index of hit tank+1
dex dex
@@ -2338,38 +2341,30 @@ DeadTank
bne CheckCollisionWithTankLoop bne CheckCollisionWithTankLoop
rts rts
CheckCollisionWithShieldedTank CheckCollisionWithShieldedTank
lda xtankstableH,x
cmp xdraw+1
bne Condition01a
lda xtankstableL,x lda xtankstableL,x
sec sec
sbc #4 ; 5 pixels more on left side sbc #4 ; 5 pixels more on left side
cmp xdraw tay
Condition01a lda xtankstableH,x
bcs LeftFromTheTank ;add 8 double byte sbc #0
; bmi ShieldOverLeftEdge ; I do not know whether to check it. Probably not :) !!!
cmp xdraw+1
bne @+
cpy xdraw
@
bcs LeftFromTheTank
tya ;add 16 double byte
clc clc
adc #16 adc #16
tay tay
lda xtankstableH,x lda xtankstableH,x
adc #0 adc #0
cmp xdraw+1 cmp xdraw+1
bne Condition02a bne @+
cpy xdraw cpy xdraw
Condition02a @
bcc RightFromTheTank bcc RightFromTheTank
bcs TankHit
lda ytankstable,x
cmp ydraw ; check range
bcc BelowTheTank ;(ytankstable,ytankstable+3)
sbc #4 ; we must rewrite EndOfTheBarrelY table or remove Y correction completely to "bold" tank !!!
cmp ydraw
bcs OverTheTank
inx
stx HitFlag ; index of hit tank+1
dex
mwa xdraw XHit
mwa ydraw YHit
rts ; in X there is an index of the hit tank
.endp .endp
;-------------------------------------------------- ;--------------------------------------------------
CalculateExplosionRange0 CalculateExplosionRange0