Flight procedure optimization

3 bytes variable (Result) now is unnecessary.
The code is a bit shorter.
This commit is contained in:
Pecusx
2022-06-02 09:12:00 +02:00
parent 94e6caebed
commit 6d9b2907c5
3 changed files with 31 additions and 44 deletions
BIN
View File
Binary file not shown.
-1
View File
@@ -207,7 +207,6 @@ Angle .DS 1
Force .ds 3 ; 0,0,0 Force .ds 3 ; 0,0,0
Multiplier .ds 3 ; 0,0,0 Multiplier .ds 3 ; 0,0,0
Multiplee .ds 2 ; 0,0 Multiplee .ds 2 ; 0,0
Result .ds 3 ; 0,0,0
goleft .DS 1 ;if 1 then flights left goleft .DS 1 ;if 1 then flights left
;-------------------------------------------------- ;--------------------------------------------------
;SoilDown2 ;SoilDown2
+31 -43
View File
@@ -1536,9 +1536,9 @@ RepeatIfSmokeTracer
mva #%01000000 drawFunction mva #%01000000 drawFunction
lda #0 lda #0
sta Result sta vx
sta Result+1 sta vx+1
sta Result+2 sta vx+2
sta HitFlag sta HitFlag
sta xdraw sta xdraw
sta xdraw+1 sta xdraw+1
@@ -1595,14 +1595,14 @@ MultiplyLoop
bcc DoNotAdd bcc DoNotAdd
clc clc
lda Multiplier lda Multiplier
adc Result adc vx
sta Result sta vx
lda Multiplier+1 lda Multiplier+1
adc Result+1 adc vx+1
sta Result+1 sta vx+1
lda Multiplier+2 lda Multiplier+2
adc Result+2 adc vx+2
sta Result+2 sta vx+2
DoNotAdd DoNotAdd
;clc ;carry always cleared here (anyway we hope so :) ;clc ;carry always cleared here (anyway we hope so :)
rol Multiplier rol Multiplier
@@ -1610,21 +1610,15 @@ DoNotAdd
rol Multiplier+2 rol Multiplier+2
dex dex
bne MultiplyLoop bne MultiplyLoop
; here in Result there is a number xxxx.yyy = sin(Angle)*Force ; here in vx there is a number xxxx.yyy = sin(Angle)*Force
lda Result ;vx=sin(Angle)*Force mva #0 vx+3 ;vx=sin(Angle)*Force
sta vx
lda Result+1
sta vx+1
lda Result+2
sta vx+2
mva #0 vx+3
;======vy ;======vy
lda #0 ;cos(Angle) lda #0 ;cos(Angle)
sta Result sta vy
sta Result+1 sta vy+1
sta Result+2 sta vy+2
;-- ;--
lda #90 lda #90
sec sec
@@ -1642,14 +1636,14 @@ MultiplyLoopY
bcc DoNotAddY bcc DoNotAddY
clc clc
lda Multiplier lda Multiplier
adc Result adc vy
sta Result sta vy
lda Multiplier+1 lda Multiplier+1
adc Result+1 adc vy+1
sta Result+1 sta vy+1
lda Multiplier+2 lda Multiplier+2
adc Result+2 adc vy+2
sta Result+2 sta vy+2
DoNotAddY DoNotAddY
;clc ;carry always cleared here (anyway we hope so :) ;clc ;carry always cleared here (anyway we hope so :)
rol Multiplier rol Multiplier
@@ -1657,15 +1651,9 @@ DoNotAddY
rol Multiplier+2 rol Multiplier+2
dex dex
bne MultiplyLoopY bne MultiplyLoopY
; here in Result there is a number xxxx.yyy=cos(Angle)*Force ; here in vy there is a number xxxx.yyy=cos(Angle)*Force
lda Result ;vy=cos(Angle)*Force mva #0 vy+3 ;vy=cos(Angle)*Force
sta vy
lda Result+1
sta vy+1
lda Result+2
sta vy+2
mva #0 vy+3
Loopi Loopi
;ytraj=ytraj-vy (skipping least significant byte of vy) ;ytraj=ytraj-vy (skipping least significant byte of vy)
@@ -1839,7 +1827,7 @@ EndOfFlight2
rts rts
.endp .endp
SecondFlight .proc .proc SecondFlight
; ---------------- copied code fragment from before firing. not too elegant. ; ---------------- copied code fragment from before firing. not too elegant.
; ---------------- get fire parameters again ; ---------------- get fire parameters again
ldx TankNr ldx TankNr
@@ -1890,7 +1878,7 @@ SecondFlight .proc
.endp .endp
; ------------------------------------------------- ; -------------------------------------------------
MIRVdownLoop .proc .proc MIRVdownLoop
; MIRV loop - here mirv bullets fall down ; MIRV loop - here mirv bullets fall down
; ------------------------------------------------- ; -------------------------------------------------
; copy Flight parameters to the table ; copy Flight parameters to the table
@@ -2176,7 +2164,7 @@ MIRVcheckCollision
ldy #0 ldy #0
lda ytraj+1 lda ytraj+1
cmp (temp),y cmp (temp),y ; check collision witch mountains
bcs mrHit bcs mrHit
mrSkipCollisionCheck mrSkipCollisionCheck
@@ -2267,7 +2255,7 @@ MIRValreadyAll
.endp .endp
; ------------------------------------------------- ; -------------------------------------------------
CheckCollisionWithTank .proc .proc CheckCollisionWithTank
; ------------------------------------------------- ; -------------------------------------------------
ldx #0 ldx #0
CheckCollisionWithTankLoop CheckCollisionWithTankLoop
@@ -2355,7 +2343,7 @@ RangesChecked
.endp .endp
;-------------------------------------------------- ;--------------------------------------------------
DecreaseWeaponBeforeShoot .proc .proc DecreaseWeaponBeforeShoot
;-------------------------------------------------- ;--------------------------------------------------
ldx TankNr ldx TankNr
lda ActiveWeapon,x lda ActiveWeapon,x
@@ -2377,7 +2365,7 @@ DecreaseWeaponBeforeShoot .proc
.endp .endp
;-------------------------------------------------- ;--------------------------------------------------
DecreaseWeapon .proc .proc DecreaseWeapon
; in: A: Weapon number, TankNr ; in: A: Weapon number, TankNr
; out: A: number of shells left, Y: weapon number ; out: A: number of shells left, Y: weapon number
; decreases 1 bullet from a weapon(A) of tank(TankNr) ; decreases 1 bullet from a weapon(A) of tank(TankNr)
@@ -2393,10 +2381,10 @@ defaultWeapon
.endp .endp
;-------------------------------------------------- ;--------------------------------------------------
HowManyBullets .proc .proc HowManyBullets
; in: A <-- Weapon number, TankNr ; in: A <-- Weapon number, TankNr
; out: A <-- How many bullets in the weapon, Y: weapon number ; out: A <-- How many bullets in the weapon, Y: weapon number
; how many bullets weapon of tank(TankNr) has, Result w A ; how many bullets weapon of tank(TankNr) has, Result in A
;-------------------------------------------------- ;--------------------------------------------------
tay tay
ldx TankNr ldx TankNr
@@ -2410,7 +2398,7 @@ HowManyBullets .proc
.endp .endp
;-------------------------------------------------- ;--------------------------------------------------
ShellDelay .proc .proc ShellDelay
lda CONSOL lda CONSOL
cmp #6 cmp #6
beq noShellDelay beq noShellDelay