Skip to content

Commit 2368ecc

Browse files
committed
Simplify joyas game logic a little.
1 parent dbd3f2a commit 2368ecc

1 file changed

Lines changed: 23 additions & 31 deletions

File tree

samples/int/joyas.bas

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ else
5454
se. 3,2,14
5555
endif
5656

57-
' Memory area for the board
58-
mainBoard = $7000 + 19
59-
fullBoard = $7000 + 16
60-
' Clear board, needed to detect bad moves
61-
mset $7000, 192, 0
57+
' Array to hold the board, cleared on DIM
58+
dim board(192) byte
59+
mainBoard = adr(board) + 19
60+
fullBoard = adr(board) + 16
6261

6362
hiScore = 0
6463
screen = dpeek(88)
@@ -144,32 +143,25 @@ endproc
144143
' Make pieces fall in the board
145144
proc FallPieces
146145

147-
' Loop until there are holes in the board
148-
repeat
149-
150-
endFall = 1
151-
152-
' Move board to screen
153-
move fullBoard, screen, 160
154-
155-
' Search for holes in the board
156-
for A=mainBoard to mainBoard + 151 step 16
157-
for P=A to A+9
158-
if peek(P) & 63 = 9
159-
' If we found a hole, fall pieces!
160-
i = P
161-
while i > mainBoard + 15
162-
poke i, peek(i-16)
163-
i = i-16
164-
wend
165-
' Set new piece and set A to exit outer loop
166-
poke i, pieces(rand(6))
167-
A = mainBoard + 152
168-
endFall = 0
169-
endif
170-
next P
171-
next A
172-
until endFall
146+
' Move board to screen
147+
move fullBoard, screen, 160
148+
149+
' Search for holes in the board
150+
for A=mainBoard to mainBoard + 151 step 16
151+
for P=A to A+9
152+
if peek(P) & 63 = 9
153+
' If we found a hole, fall pieces!
154+
i = P
155+
while i > mainBoard + 15
156+
poke i, peek(i-16)
157+
i = i-16
158+
wend
159+
' Set new piece and display current position
160+
poke i, pieces(rand(6))
161+
move fullBoard, screen, 160
162+
endif
163+
next P
164+
next A
173165

174166
endproc
175167

0 commit comments

Comments
 (0)