Round end in Team game

This commit is contained in:
Pecusx
2025-12-20 17:55:34 +01:00
parent 24de89d9eb
commit 3fa3d417e2
4 changed files with 50 additions and 26 deletions
+2
View File
@@ -443,6 +443,7 @@ ChoosingItemForPurchase
jsr PutLitteChar ; Places pointer at the right position jsr PutLitteChar ; Places pointer at the right position
jsr getkey jsr getkey
and #$3f ;CTRL and SHIFT ellimination
bit escFlag bit escFlag
bpl @+ bpl @+
mva #0 escFlag mva #0 escFlag
@@ -1188,6 +1189,7 @@ CheckKeys
sta NameScreen2+15 ; display tank shape number sta NameScreen2+15 ; display tank shape number
jsr CursorDisplay jsr CursorDisplay
jsr getkey jsr getkey
and #$3f ;CTRL and SHIFT ellimination
bit escFlag bit escFlag
spl:rts spl:rts
+42 -21
View File
@@ -290,35 +290,38 @@ NoEnergy
bpl CheckingIfRoundIsFinished bpl CheckingIfRoundIsFinished
cpy #2 ; is it less than 2 tanks have energy >0 ? cpy #2 ; is it less than 2 tanks have energy >0 ?
bcs DoNotFinishTheRound bcc FinishTheRound
bit TeamGame
;points for the last living tank bvc NoTeams
; Check if one team is not dead
; check team 1
ldx NumberOfPlayers
jsr CheckTeamDead
beq FinishTheRound
; check team 2
ldx NumberOfPlayers
dex ; for team 2
jsr CheckTeamDead
beq FinishTheRound
NoTeams
jmp DoNotFinishTheRound
FinishTheRound
;points for the last living tank(s)
ldx NumberOfPlayers ldx NumberOfPlayers
dex dex
WhichTankWonLoop WhichTankWonLoop
lda eXistenZ,x lda eXistenZ,x
bne ThisOneWon beq CheckNext
dex ; set winning tanks points
bpl WhichTankWonLoop
;error was here!!!
; somehow I believed program will be never here
; but it was a bad assumption
; god knows when there is such a situation
; (we've got a SITUATION here, if you know what I mean)
; there are two tanks left.
; one of them is killed by the second tank
; second tank explodes and kills the first one.
; and code lands here...
; looks like no one won!
rts
ThisOneWon
lda CurrentResult lda CurrentResult
clc clc
adc ResultsTable,x adc ResultsTable,x
sta ResultsTable,x sta ResultsTable,x
inc CurrentResult ; this is for honesty (in Team game) :)
rts ; this Round is finished CheckNext
dex
bpl WhichTankWonLoop
rts
DoNotFinishTheRound DoNotFinishTheRound
; Seppuku here ; Seppuku here
@@ -563,6 +566,24 @@ NotLastPlayerInRound
jmp MainRoundLoop jmp MainRoundLoop
.endp .endp
;---------------------------------
.proc CheckTeamDead
; Optimalisation procedure
; Counts alive in Team
;---------------------------------
dex
ldy #0 ; in Y - number of tanks with energy greater than zero
CheckingTeam
lda eXistenZ,x
beq NoEnergy
iny
NoEnergy
dex
dex
bpl CheckingTeam
cpy #0
rts
.endp
;--------------------------------- ;---------------------------------
.proc PlayerXdeath .proc PlayerXdeath
; this tank should not explode anymore: ; this tank should not explode anymore:
BIN
View File
Binary file not shown.
+6 -5
View File
@@ -1360,11 +1360,12 @@ NoSpyHard
mva #0 escFlag mva #0 escFlag
jmp ReleaseAndLoop jmp ReleaseAndLoop
@ @
/* cmp #$80|@kbcode._up /* .IF TARGET = 800
jeq CTRLPressedUp cmp #$80|@kbcode._up ; Ctrl + Up or Down only in A800
cmp #$80|@kbcode._down jeq CTRLPressedUp
jeq CTRLPressedDown */ cmp #$80|@kbcode._down
jeq CTRLPressedDown
.ENDIF */
cmp #$80|@kbcode._tab cmp #$80|@kbcode._tab
jeq CTRLPressedTAB jeq CTRLPressedTAB