letting winds #82

This commit is contained in:
2022-06-04 16:07:01 -04:00
parent bf11a9967f
commit 4c3203854c
6 changed files with 70 additions and 130 deletions
+1 -1
View File
@@ -889,7 +889,7 @@ NamesOfWeapons ;the comment is an index in the tables
dta d"White Flag " ; 63 dta d"White Flag " ; 63
weaponsOfDeath weaponsOfDeath
dta 1,2,3,7,15,16,17,18,19,20,21,22,23,24,25,26,27 dta 1,2,3,7,15,16,17,18,19,20,21,22,23,24,25,26,27
weaponsOfDeathEnd weaponsOfDeathEnd
joyToKeyTable joyToKeyTable
; .by 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15 ; .by 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15
.by $ff,$ff,$ff,$ff,$ff,$ff,$ff,$07,$ff,$ff,$ff,$06,$ff,$0f,$0e,$ff .by $ff,$ff,$ff,$ff,$ff,$ff,$ff,$07,$ff,$ff,$ff,$06,$ff,$0f,$0e,$ff
+18 -5
View File
@@ -399,7 +399,7 @@ RoboTanks
; robotanks shoot here ; robotanks shoot here
jsr ArtificialIntelligence jsr ArtificialIntelligence
jsr MoveBarrelToNewPosition jsr MoveBarrelToNewPosition
jsr StatusDisplay ;all digital values like force, angle, wind, etc. jsr DisplayStatus ;all digital values like force, angle, wind, etc.
jsr PutTankNameOnScreen jsr PutTankNameOnScreen
; let's move the tank's barrel so it points the right ; let's move the tank's barrel so it points the right
; direction ; direction
@@ -414,7 +414,7 @@ AfterManualShooting
inc noDeathCounter inc noDeathCounter
jsr DecreaseWeaponBeforeShoot jsr DecreaseWeaponBeforeShoot
jsr StatusDisplay jsr DisplayStatus
ldx TankNr ldx TankNr
dec Energy,x ; lower energy to eventually let tanks commit suicide dec Energy,x ; lower energy to eventually let tanks commit suicide
@@ -710,18 +710,31 @@ NotNegativeEnergy
;-------------------------------------------------- ;--------------------------------------------------
GetRandomWind .proc GetRandomWind .proc
;in: MaxWind (byte)
;out: Wind (word)
;uses: _
;-------------------------------------------------- ;--------------------------------------------------
lda random lda random
cmp MaxWind cmp MaxWind
bcs GetRandomWind ; if more than MaxWind then randomize again bcs GetRandomWind ; if more than MaxWind then randomize again
sta Wind sta Wind
mva #$00 Wind+1 mva #$00 Wind+1
; multiply Wind by 16 and take it as a decimal part (0.Wind) sta Wind+2
sta Wind+3
; multiply Wind by 16
; two bytes of Wind are treated as a decimal part of vx variable
:4 aslw Wind :4 aslw Wind
; decide the direction
lda random lda random
and #$01 and #$01
sta WindOrientation beq @+
rts sec ; Wind = -Wind
.rept 4
lda #$00
sbc Wind+#
sta Wind+#
.endr
@ rts
.endp .endp
;-------------------------------------------------- ;--------------------------------------------------
BIN
View File
Binary file not shown.
+12 -8
View File
@@ -1600,7 +1600,7 @@ FinishResultDisplay
.endp .endp
;------------------------------------------------- ;-------------------------------------------------
.proc StatusDisplay .proc DisplayStatus
;------------------------------------------------- ;-------------------------------------------------
;lda noDeathCounter ;lda noDeathCounter
@@ -1715,24 +1715,28 @@ AngleDisplay
;========================= ;=========================
;display Wind ;display Wind
;========================= ;=========================
lda WindOrientation mwa Wind temp
bne DisplayLeftWind lda Wind+3 ; highest byte of 4 byte wind
bmi DisplayLeftWind
lda #$7f ; (tab) char lda #$7f ; (tab) char
sta textbuffer+80+28 sta textbuffer+80+28
lda #0 ;space lda #0 ;space
sta textbuffer+80+25 sta textbuffer+80+25
beq DisplayWindValue beq DisplayWindValue
DisplayLeftWind DisplayLeftWind
sec ; Wind = -Wind
lda #$00
sbc temp
sta temp
lda #$00
sbc temp+1
sta temp+1
lda #$7e ;(del) char lda #$7e ;(del) char
sta textbuffer+80+25 sta textbuffer+80+25
lda #0 ;space lda #0 ;space
sta textbuffer+80+28 sta textbuffer+80+28
DisplayWindValue DisplayWindValue
mwa Wind temp :4 lsrw temp ;divide by 16 to have a nice value on a screen
lsrw temp ;divide by 16 to have
lsrw temp ;a nice view on a screen
lsrw temp
lsrw temp
lda temp lda temp
sta decimal sta decimal
mwa #textbuffer+80+26 displayposition mwa #textbuffer+80+26 displayposition
+3 -2
View File
@@ -113,8 +113,9 @@ L1 .DS 1 ; variable used in multiplications (by 10:)
gravity .DS 1 ;only the decimal part (1/10 = 25) gravity .DS 1 ;only the decimal part (1/10 = 25)
;----------------------------------- ;-----------------------------------
Wind .ds 2 ;walue displayed on the screen Wind .ds 4 ;format: 0000.hhll
;multiplied by 16 (decimal part only) ;walue displayed on the screen is
;decimal portion divided by 16 (>>4)
;----------------------------------- ;-----------------------------------
MaxWind .ds 1 ; MaxWind .ds 1 ;
WindOrientation .DS 1 ;(0-right,1-left) WindOrientation .DS 1 ;(0-right,1-left)
+36 -114
View File
@@ -991,7 +991,7 @@ ContinueToCheckMaxForce2
lda MaxForceTableL,x lda MaxForceTableL,x
sta ForceTableL,x sta ForceTableL,x
@ @
jsr StatusDisplay ;all digital values like force, angle, wind, etc. jsr DisplayStatus ;all digital values like force, angle, wind, etc.
jsr PutTankNameOnScreen jsr PutTankNameOnScreen
jsr DrawTankNr jsr DrawTankNr
@@ -1501,7 +1501,8 @@ ThereWasNoParachute
.endp .endp
;-------------------------------------------------- ;--------------------------------------------------
.proc Flight ; Force(byte.byte), Angle(byte), Wind(.byte) 128=0, 255=maxright, 0=maxleft .proc Flight ; Force(byte.byte), Wind(0.word)
; Angle(byte) 128=0, 255=maxright, 0=maxleft
;-------------------------------------------------- ;--------------------------------------------------
;g=-0.1 ;g=-0.1
;vx=Force*sin(Angle) ;vx=Force*sin(Angle)
@@ -1554,7 +1555,7 @@ RepeatIfSmokeTracer
;255-90 (165) horizontally left ;255-90 (165) horizontally left
bpl FlightRight bpl FlightRight
;and if the highest bit is set then ;and if the highest bit is set then
;Flight to LEFT ;Flight to LEFT
;calculate Angle with this formula: ;calculate Angle with this formula:
@@ -1563,12 +1564,14 @@ RepeatIfSmokeTracer
sec sec
txa txa
sbc #165 ;(Angle-165) sbc #165 ;(Angle-165)
sta temp ;dirty trick with selfmodifying code (REMOVED) sta temp
lda #90 ; lda #90
sbc temp ;90-(Angle-165) sbc temp ;90-(Angle-165)
;and we have rady angle here ... and we go LEFT! ;and we have rady angle here ... and we go LEFT!
tax tax
sta Angle sta Angle
;
mva #1 goleft mva #1 goleft
; and now we contine as if nothing happened ; and now we contine as if nothing happened
; (but we have goleft set to 1!!!) ; (but we have goleft set to 1!!!)
@@ -1580,7 +1583,7 @@ FlightRight
dontzerogoleft dontzerogoleft
lda sintable,x ;sin(Angle) lda sintable,x ;sin(Angle)
sta Multiplee ;sin(Angle)*Force sta Multiplee ;sin(Angle)*Force
mwa Force Multiplier mwa Force Multiplier
lda #$0 lda #$0
sta Multiplier+2 sta Multiplier+2
@@ -1605,10 +1608,19 @@ DoNotAdd
rol Multiplier+2 rol Multiplier+2
dex dex
bne MultiplyLoop bne MultiplyLoop
; here in vx there is a number xxxx.yyy = sin(Angle)*Force
mva #0 vx+3
mva #0 vx+3 ;vx=sin(Angle)*Force ; here in vx there is a number
; xxxx.xx00 = sin(Angle)*Force
; negate it if going left
lda goleft
beq @+
.rept 4
lda #$00
sbc vx+#
sta vx+#
.endr
@
;======vy ;======vy
lda #0 ;cos(Angle) lda #0 ;cos(Angle)
sta vy sta vy
@@ -1646,7 +1658,8 @@ DoNotAddY
rol Multiplier+2 rol Multiplier+2
dex dex
bne MultiplyLoopY bne MultiplyLoopY
; here in vy there is a number xxxx.yyy=cos(Angle)*Force ; here in vy there is a number
; yyyy.yy=cos(Angle)*Force
mva #0 vy+3 ;vy=cos(Angle)*Force mva #0 vy+3 ;vy=cos(Angle)*Force
@@ -1682,8 +1695,7 @@ Loopi
cmp #6 ; MIRV cmp #6 ; MIRV
jeq MIRVdownLoop jeq MIRVdownLoop
StillUp StillUp
lda goleft
bne FlightLeft
clc ;xtraj=xtraj+vx (skipping least significant byte of vx) clc ;xtraj=xtraj+vx (skipping least significant byte of vx)
lda xtraj ;here of course Fight to right lda xtraj ;here of course Fight to right
@@ -1695,66 +1707,13 @@ StillUp
lda xtraj+2 lda xtraj+2
adc vx+3 adc vx+3
sta xtraj+2 sta xtraj+2
jmp @+ ;skipping substracting for Flight to left
FlightLeft
sec ;xtraj=xtraj-vx (skipping least significant byte of vx)
lda xtraj ;here of course Fight to left
sbc vx+1
sta xtraj
lda xtraj+1
sbc vx+2
sta xtraj+1
lda xtraj+2
sbc vx+3
sta xtraj+2
@
;vx=vx-Wind (also without least significan byte of vx)
lda goleft
bne FlightsLeft ;blow on bullet flighting left
lda WindOrientation
bne LWindToRight
beq LWindToLeft
FlightsLeft
lda WindOrientation
beq LWindToRight
LWindToLeft
; here Wind to right, bullet goes right as well, so vx=vx+Wind
; here Wind to left, bullet goes left as well, so vx=vx+Wind
clc clc
lda vx .rept 4
adc Wind lda vx+#
sta vx adc Wind+#
lda vx+1 sta vx+#
adc Wind+1 .endr
sta vx+1
lda vx+2
adc #0
sta vx+2
lda vx+3
adc #0
sta vx+3
jmp @+
LWindToRight
;Wind to left, bullet right, so vx=vx-Wind
;Wind to right, bullet left, so vx=vx-Wind
sec
lda vx
sbc Wind
sta vx
lda vx+1
sbc Wind+1
sta vx+1
lda vx+2
sbc #0
sta vx+2
lda vx+3
sbc #0
sta vx+3
@
mwa xtrajold+1 xdraw mwa xtrajold+1 xdraw
mwa ytrajold+1 ydraw mwa ytrajold+1 ydraw
mwa xtraj+1 xbyte mwa xtraj+1 xbyte
@@ -2023,51 +1982,14 @@ mrFlightLeft
mrskip07 mrskip07
;vx=vx-Wind (also without least significan byte of vx) ;vx=vx+Wind
lda goleft
bne mrFlightsLeft ;blow on bullet flighting left
lda WindOrientation
bne mrWindToLeft
beq mrLWindToLeft
mrFlightsLeft
lda WindOrientation
beq mrLWindToRight
mrLWindToLeft
; here Wind to right, bullet goes right as well, so vx=vx+Wind
; here Wind to left, bullet goes left as well, so vx=vx+Wind
clc clc
lda vx00,x .rept 4
adc Wind lda vx+#
sta vx00,x adc Wind+#
lda vx01,x sta vx+#
adc Wind+1 .endr
sta vx01,x
lda vx02,x
adc #0
sta vx02,x
lda vx03,x
adc #0
sta vx03,x
Jmp mrskip08
mrWindToLeft
mrLWindToRight
;Wind to left, bullet right, so vx=vx-Wind
;Wind to right, bullet left, so vx=vx-Wind
sec
lda vx00,x
sbc Wind
sta vx00,x
lda vx01,x
sbc Wind+1
sta vx01,x
lda vx02,x
sbc #0
sta vx02,x
lda vx03,x
sbc #0
sta vx03,x
mrskip08
; rules for a falling MIRV bulets. ; rules for a falling MIRV bulets.
; if Y is negative and any X (bullet over the screen) - continue flying ; if Y is negative and any X (bullet over the screen) - continue flying