Variables initialization on strart

This commit is contained in:
Pecusx
2022-08-09 13:30:21 +02:00
parent 234fbc5a4a
commit 664dc1568d
6 changed files with 85 additions and 28 deletions
+22 -6
View File
@@ -2,6 +2,22 @@
.IF *>0 ;this is a trick that prevents compiling this file alone .IF *>0 ;this is a trick that prevents compiling this file alone
; initial values for some variables
initialvaluesStart
I_OptionsTable .by 0,1,2,2,0,1,3,2
I_RoundsInTheGame .by 10 ;how many rounds in the current game
I_seppukuVal .by 75
I_mountainDeltaH .by 3
I_mountainDeltaL .by $ff
;----------------------------------------------------
; 4x4 text buffer
I_ResultLineBuffer
dta d" ", $ff
I_LineHeader1
dta d"# ROUND: "
I_RoundNrDisplay
dta d" #", $ff
initialvaluesCount = *-initialvaluesstart ; MAX 128 bytes !
;=================================================================================== ;===================================================================================
;==========================CONSTANT TABLES, do not erase!=========================== ;==========================CONSTANT TABLES, do not erase!===========================
;=================================================================================== ;===================================================================================
@@ -678,7 +694,7 @@ nineplus dta d"9"+1
space dta d" " space dta d" "
;------credits ;------credits
CreditsStart CreditsStart
dta d" "* dta d" "*
dta d"You were playin",d"g"* dta d"You were playin",d"g"*
dta d"Scorc",d"h"* dta d"Scorc",d"h"*
dta d"Warsaw, Miam",d"i"* dta d"Warsaw, Miam",d"i"*
@@ -690,7 +706,7 @@ CreditsStart
dta d"Tomasz 'Pecus' Peck",d"o"* dta d"Tomasz 'Pecus' Peck",d"o"*
dta d"Pawel 'pirx' Kalinowsk",d"i"* dta d"Pawel 'pirx' Kalinowsk",d"i"*
dta d" "* dta d" "*
dta d"SFX and Music",d"c"* dta d"SFX and Musi",d"c"*
dta d"Michal 'Miker' Szpilowsk",d"i"* dta d"Michal 'Miker' Szpilowsk",d"i"*
dta d" "* dta d" "*
dta d"Additional musi",d"c"* dta d"Additional musi",d"c"*
@@ -704,12 +720,12 @@ CreditsStart
dta d"Krzysztof 'Kaz' Ziembi",d"k"* dta d"Krzysztof 'Kaz' Ziembi",d"k"*
dta d" "* dta d" "*
dta d"Ideas and Q",d"A"* dta d"Ideas and Q",d"A"*
dta d"Bocianu, Probabilitydragon, KrzysRog",d","* dta d"Bocianu, Probabilitydragon, EnderDude",d","*
dta d"Beeblebrox, EnderDude, lopezpb, Dracon",d","* dta d"Beeblebrox, KrzysRog, lopezpb, Dracon",d","*
dta d"brad-colbert, archon800",d","* dta d"brad-colbert, archon800",d","*
dta d"Shaggy the Ataria",d"n"* dta d"Shaggy the Ataria",d"n"*
dta d" "* dta d" "*
dta d"Stay tuned for the FujiNet version",d"!"* dta d"Stay tuned for the FujiNet version",d"!"*
dta d" "* dta d" "*
CreditsEnd CreditsEnd
.endif .endif
+3 -3
View File
@@ -945,7 +945,7 @@ NoFallingSound
and #01 and #01
beq DoNotClearParachute beq DoNotClearParachute
; here we clear the parachute ; here we clear the parachute
ldx TankNr ; ldx TankNr
jsr DrawTankParachute jsr DrawTankParachute
DoNotClearParachute DoNotClearParachute
mva #0 Erase mva #0 Erase
@@ -1087,7 +1087,7 @@ EndOfFCycle
cmp #3 ; parachute and falling cmp #3 ; parachute and falling
bne DoNotDrawParachute bne DoNotDrawParachute
; here we draw parachute ; here we draw parachute
ldx TankNr ; ldx TankNr
jsr DrawTankParachute jsr DrawTankParachute
jsr WaitOneFrame ; only if tank with parachute jsr WaitOneFrame ; only if tank with parachute
RapidFalling RapidFalling
@@ -1115,7 +1115,7 @@ ForceFallLeft
jne TankFallsX jne TankFallsX
EndOfFall EndOfFall
mva #1 Erase mva #1 Erase
ldx TankNr ; ldx TankNr
; if tank was falling down having parachute, ; if tank was falling down having parachute,
; we must deduct one parachute ; we must deduct one parachute
lda Parachute lda Parachute
+40 -6
View File
@@ -112,7 +112,7 @@
icl 'lib/macro.hea' icl 'lib/macro.hea'
;splash screen and musix ;splash screen and musix
;icl 'artwork/HIMARS14.asm' icl 'artwork/HIMARS14.asm'
;Game loading address ;Game loading address
ORG $3000 ORG $3000
WeaponFont WeaponFont
@@ -126,8 +126,25 @@ WeaponFont
;-------------------------------------------------- ;--------------------------------------------------
; Game Code ; Game Code
;-------------------------------------------------- ;--------------------------------------------------
START FirstSTART
mva #0 dmactls ; dark screen
jsr WaitOneFrame
; one time zero variables in RAM (non zero page)
lda #0
ldy #OneTimeZeroVariablesCount-1
@ sta OneTimeZeroVariables
dey
bpl @-
; initialize variables in RAM (non zero page)
ldy #initialvaluesCount-1
@ lda initialvaluesStart,y
sta variablesToInitialize,y
dey
bpl @-
START
; Startup sequence ; Startup sequence
jsr Initialize jsr Initialize
@@ -138,10 +155,14 @@ START
jsr Options ;startup screen jsr Options ;startup screen
mva #0 dmactls ; dark screen
jsr WaitOneFrame
lda escFlag lda escFlag
bne START bne START
jsr EnterPlayerNames jsr EnterPlayerNames
mva #0 dmactls ; dark screen
jsr WaitOneFrame
lda escFlag lda escFlag
bne START bne START
@@ -152,7 +173,8 @@ MainGameLoop
jsr CallPurchaseForEveryTank jsr CallPurchaseForEveryTank
; issue #72 (glitches when switches) ; issue #72 (glitches when switches)
mva #0 dmactls mva #0 dmactls ; dark screen
jsr WaitOneFrame
jsr GetRandomWind jsr GetRandomWind
@@ -268,6 +290,8 @@ eskipzeroing
lda GameIsOver lda GameIsOver
beq NoGameOverYet beq NoGameOverYet
mva #0 dmactls ; dark screen
jsr WaitOneFrame
jsr GameOverScreen jsr GameOverScreen
jmp START jmp START
NoGameOverYet NoGameOverYet
@@ -1059,9 +1083,9 @@ CreditsScroll
sta COLPF2 sta COLPF2
inc CreditsVScrol inc CreditsVScrol
lda CreditsVScrol lda CreditsVScrol
cmp #16 ;not to fast cmp #32 ;not to fast
beq nextlinedisplay beq nextlinedisplay
lsr ;not to fast :2 lsr ;not to fast
sta VSCROL sta VSCROL
jmp EndOfDLI_GO jmp EndOfDLI_GO
nextlinedisplay nextlinedisplay
@@ -1446,6 +1470,16 @@ getkeyend
rts rts
.endp .endp
;-------------------------------------------------- ;--------------------------------------------------
.proc IsKeyPressed ; A=0 - yes , A>0 - no
;--------------------------------------------------
lda SKSTAT
and #%00000100
beq @+
lda #1
@ and TRIG0S
rts
.endp
;--------------------------------------------------
.proc DemoModeOrKey .proc DemoModeOrKey
;-------------------------------------------------- ;--------------------------------------------------
;check demo mode ;check demo mode
@@ -1534,4 +1568,4 @@ TheEnd
run START run FirstSTART
BIN
View File
Binary file not shown.
+5 -2
View File
@@ -16,6 +16,8 @@
; - money each player has on the beginning of the game (moneyL i moneyH) ; - money each player has on the beginning of the game (moneyL i moneyH)
; - and I am sure maxwind, gravity, no_of_rounds in a game, speed of shell flight ; - and I am sure maxwind, gravity, no_of_rounds in a game, speed of shell flight
jsr clearscreen ;let the screen be clean
mwa #OptionsDL dlptrs mwa #OptionsDL dlptrs
; lda dmactls ; lda dmactls
; and #$fc ; and #$fc
@@ -2001,9 +2003,10 @@ FastTank
; ldx TankNr ; ldx TankNr
dex dex
bpl AllTanksFloatingDown bpl AllTanksFloatingDown
lda kbcode jsr IsKeyPressed
and #%00000100
bne MainTanksFloatingLoop ; neverending loop bne MainTanksFloatingLoop ; neverending loop
mva #0 dmactls ; dark screen
jsr WaitOneFrame
jsr GameOverResultsClear jsr GameOverResultsClear
rts rts
RandomizeTankPos RandomizeTankPos
+15 -11
View File
@@ -8,25 +8,29 @@
; compilation to e.g. cartridge ; compilation to e.g. cartridge
; zero page variables are declared in program.s65 module ; zero page variables are declared in program.s65 module
;===================================================== ;=====================================================
TanksNames ; DO NOT ZERO - ticket #24 OneTimeZeroVariables
OneTimeZeroVariablesCount = variablesToInitialize-OneTimeZeroVariables ; MAX 128 bytes !
noMusic .by 0 ; 0 - play music, $ff - do not play music
noSfx .by 0 ; 0 - play SFX, $ff - do not play SFX
;----------------------------------------------------
; Color table for Game Over Screen (created in a gameover routine)
.by $00 ; labels line color
GameOverColoursTable .BYTE $80,$40,$c4,$20,$c0,$e4
;----------------------------------------------------
TanksNames ; DO NOT ZERO ON RESTART GAME - ticket #24
:6 dta d" " :6 dta d" "
;---------------------------------------------------- ;----------------------------------------------------
;Options DO NOT ZERO - ticket #27 skilltable ; computer controlled players' skills (1-8), 0 - human (no cleaning, ticket #30)
.DS [MaxPlayers]
;----------------------------------------------------
variablesToInitialize
;Options DO NOT ZERO ON RESTART GAME - ticket #27
OptionsTable .by 0,1,2,2,0,1,3,2 OptionsTable .by 0,1,2,2,0,1,3,2
RoundsInTheGame .by 10 ;how many rounds in the current game RoundsInTheGame .by 10 ;how many rounds in the current game
seppukuVal .by 75 seppukuVal .by 75
mountainDeltaH .by 3 mountainDeltaH .by 3
mountainDeltaL .by $ff mountainDeltaL .by $ff
;---------------------------------------------------- ;----------------------------------------------------
; Color table for Game Over Screen
.by $00 ; labels line color
GameOverColoursTable .BYTE $80,$40,$c4,$20,$c0,$e4
;----------------------------------------------------
skilltable ; computer controlled players' skills (1-8), 0 - human (no cleaning, ticket #30)
.DS [MaxPlayers]
;----------------------------------------------------
noMusic .by 0 ; 0 - play music, $ff - do not play music
noSfx .by 0 ; 0 - play SFX, $ff - do not play SFX
; 4x4 text buffer ; 4x4 text buffer
ResultLineBuffer ResultLineBuffer
dta d" ", $ff dta d" ", $ff