Tanks sequence randomization opty

This commit is contained in:
Pecusx
2024-02-29 12:43:36 +01:00
parent 3ce3539d0e
commit d25419c353
2 changed files with 13 additions and 22 deletions
+13 -22
View File
@@ -927,26 +927,22 @@ MakeTanksVisible
; repeat untill NumberOfPlayers ; repeat untill NumberOfPlayers
ldx #0 ldx #0
GetRandomAgain0
lda RANDOM
and #$07 ;NumberOfPlayers < 7
cmp NumberOfPlayers
bcs GetRandomAgain0
sta TankSequence,x
;now first slot is ready, nexts slots are handled
;in a more complicated way
GetRandomAgainX GetRandomAgainX
txa ; destroy A!
tay
dey
lda RANDOM lda RANDOM
and #$07 ;NumberOfPlayers < 7
cmp NumberOfPlayers cmp NumberOfPlayers
bcs GetRandomAgainX bcs GetRandomAgainX
cpx #0
bne NotFirstSlot
sta TankSequence,x ;now first slot is ready
inx
bne GetRandomAgainX
NotFirstSlot
;now we have to check if the value was not used ;now we have to check if the value was not used
;in previous slots ;in previous slots
stx temp
ldy temp
UsageLoop UsageLoop
cmp TankSequence,y cmp TankSequence,y
beq GetRandomAgainX ;apparently we have already used this value beq GetRandomAgainX ;apparently we have already used this value
@@ -954,14 +950,11 @@ UsageLoop
bpl UsageLoop bpl UsageLoop
;well, looks like this value is new! ;well, looks like this value is new!
inx
sta TankSequence,x sta TankSequence,x
inx
stx temp cpx NumberOfPlayers
inc:lda temp ;x+1 bcc GetRandomAgainX
cmp NumberOfPlayers
bne GetRandomAgainX
rts rts
.endp .endp
;---------------------------------------------- ;----------------------------------------------
@@ -972,9 +965,7 @@ UsageLoop
;---------------------------------------------- ;----------------------------------------------
; lets randomize someting between 0 and 180 ; lets randomize someting between 0 and 180
lda RANDOM randomize 0 180
cmp #180
bcs RandomizeAngle
rts rts
.endp .endp
;---------------------------------------------- ;----------------------------------------------
BIN
View File
Binary file not shown.