Improved checking collision with the tank.

And other optimizations.
This commit is contained in:
Pecusx
2022-06-02 15:01:49 +02:00
parent 9569b3365a
commit 0fbe3de569
3 changed files with 30 additions and 17 deletions
+8 -3
View File
@@ -242,8 +242,13 @@ CheckCollisionDraw
lda HitFlag lda HitFlag
bne StopHitChecking bne StopHitChecking
mwa xdraw temp clc
adw temp #mountaintable lda xdraw
adc #<mountaintable
sta temp
lda xdraw+1
adc #>mountaintable
sta temp+1
ldy #0 ldy #0
lda ydraw lda ydraw
@@ -255,7 +260,7 @@ CheckCollisionDraw
sec sec
sbc #1 sbc #1
sta YHit sta YHit
mva #0 YHit+1 sty YHit+1
;mwa ydraw YHit ;mwa ydraw YHit
mva #1 HitFlag mva #1 HitFlag
StopHitChecking StopHitChecking
BIN
View File
Binary file not shown.
+22 -14
View File
@@ -738,8 +738,6 @@ UpNotYet
;check tank collision prior to PLOT ;check tank collision prior to PLOT
sty HitFlag sty HitFlag
mwa xdraw xtraj+1
mwa ydraw ytraj+1
jsr CheckCollisionWithTank jsr CheckCollisionWithTank
lda HitFlag lda HitFlag
@@ -2144,11 +2142,12 @@ MIRVcontinueFly
MIRVcheckCollision MIRVcheckCollision
; checking works only with xtraj so copy there all we need ; checking works only with xdraw and ydraw so copy there all we need
lda xtraj01,x lda xtraj01,x
sta xtraj+1 sta xdraw
lda xtraj02,x lda xtraj02,x
sta xtraj+2 sta xdraw+1
mwa ytraj+1 ydraw
mva #0 HitFlag mva #0 HitFlag
jsr CheckCollisionWithTank jsr CheckCollisionWithTank
ldx MirvMissileCounter ldx MirvMissileCounter
@@ -2259,14 +2258,22 @@ MIRValreadyAll
; ------------------------------------------------- ; -------------------------------------------------
.proc CheckCollisionWithTank .proc CheckCollisionWithTank
; ------------------------------------------------- ; -------------------------------------------------
; Check collision with Tank :)
; xdraw , ydraw - coordinates of the checked point
; results:
; HitFlag - 1 - hit, 0 - no hit
; XHit , YHit - coordinates of hit
; X - index of the hit tank
ldx #0 ldx #0
CheckCollisionWithTankLoop CheckCollisionWithTankLoop
lda eXistenZ,x
beq DeadTank
lda xtankstableH,x lda xtankstableH,x
cmp xtraj+2 cmp xdraw+1
bne Condition01 bne Condition01
lda xtankstableL,x lda xtankstableL,x
cmp xtraj+1 cmp xdraw
Condition01 Condition01
bcs LeftFromTheTank ;add 8 double byte bcs LeftFromTheTank ;add 8 double byte
clc clc
@@ -2274,26 +2281,27 @@ Condition01
tay tay
lda xtankstableH,x lda xtankstableH,x
adc #0 adc #0
cmp xtraj+2 cmp xdraw+1
bne Condition02 bne Condition02
cpy xtraj+1 cpy xdraw
Condition02 Condition02
bcc RightFromTheTank bcc RightFromTheTank
lda ytankstable,x lda ytankstable,x
cmp ytraj+1 ; check range cmp ydraw ; check range
bcc BelowTheTank ;(ytankstable,ytankstable+3) bcc BelowTheTank ;(ytankstable,ytankstable+3)
sbc #4 sbc #4
cmp ytraj+1 cmp ydraw
bcs OverTheTank bcs OverTheTank
mva #1 HitFlag mva #1 HitFlag
mwa xtraj+1 XHit mwa xdraw XHit
mwa ytraj+1 YHit mwa ydraw YHit
rts ; in X there is an index of the hit tank rts ; in X there is an index of the hit tank
RightFromTheTank RightFromTheTank
LeftFromTheTank LeftFromTheTank
OverTheTank OverTheTank
BelowTheTank BelowTheTank
DeadTank
inx inx
cpx NumberOfPlayers cpx NumberOfPlayers
bne CheckCollisionWithTankLoop bne CheckCollisionWithTankLoop