-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcchains.bas
More file actions
548 lines (428 loc) · 12 KB
/
cchains.bas
File metadata and controls
548 lines (428 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
' numeritos
' 2020 COMPILER SOFTWARE
' Versión Spectum: Miguel A. G. Prada.
' Juego original: Cardinal Chains de Daniel Nora.
' ###########################################################
' VARIABLES
' puntero apunta al nivel en juego y puntBuffer al buffer de pantalla.
DIM puntero, puntBuffer as uInteger
' LECTOR DEL CONTENIDO DE LA DIRECCIÓN DEL PUNTERO
DIM a as uByte
DIM a2 as uByte
' CONTADOR PARA VER SI TERMINAMOS EL NIVEL
' AL MAPEAR SUMAMOS EL VALOR DE CADA TILE Y, SEGÚN JUGAMOS, LO VAMOS RESTANDO. AL LLEGAR A CERO, NIVEL TERMINADO
DIM contador as UInteger
DIM dPause as uInteger
' NUMERO DE PLAYERS
DIM nPlayers as uByte
' PLAYER SELECCIONADO
' DE 0 A 5, CORRESPONDE CON EL COLOR -1 (para manejo de arrays). SE EMPIEZA SIEMPRE CON EL BLUE SELECCIONADO
DIM player as Byte
' LAS MEDIDAS EN TILES DEL NIVEL
DIM xAncho, yAlto as uByte
' LAS COORDENADAS DE IMPRESIÓN ESQUINA SUP/IZQ DEL NIVEL
DIM xBoard, yBoard as uByte
' NIVEL EN JUEGO Y MÁXIMO NÚMERO DE NIVELES
DIM level as Integer = 0
dim levelmax as Integer = 312
' PARA LA CADENA DEL MARCADOR DE NIVEL
DIM m$ as string
CONST tile as uInteger = 36
' MATRIZ DE DATOS DE CADA PLAYER
' X,Y,ATTR NO SELEC, ATTR SELEC, BUFF del valor del tile que había antes de pisar con el player,
' MOVIMIENTOS, si el player se ha movido o está en el inicio (para el cambio de attr pos. inicial)
dim players (5,5) as uByte => {_
{0,0,65,72,0,0},_
{0,0,66,80,0,0},_
{0,0,67,88,0,0},_
{0,0,68,96,0,0},_
{0,0,69,104,0,0},_
{0,0,70,112,0,0}_
}
' MATRIZ DE PUNTEROS AL BUFFER POR CADA PLAYER
dim puntPlayers (5) as uInteger
' CONTROLES
DIM keyUp, keyDown, keyRight, keyLeft, keySelectLeft, keySelectRight, keySelectLeft2, keySelectRight2, keyReset, keyMenu as uByte
keyUp = code "q"
keyDown = code "a"
keyRight = code "p"
keyLeft = code "o"
keySelectLeft = code "n"
keySelectLeft2 = code "k"
keySelectRight = code "m"
keySelectRight2 = code "l"
keyReset = code "r"
keyMenu = code "t"
#include "tables.asm"
dim compiler, cardinal as string
compiler = "COMPILER SOFTWARE 2020"
cardinal = "CARDINAL CHAINS SPECTRUM"
' END VARIABLES
' ###########################################################
' ###########################################################
' MENU
menu:
border 0: paper 0: ink 2: bright 0: cls
print at 3, 4; bold 1; cardinal
print at 23, 28; bright 0; ink 2; bold 0; "bout"; at 23,27; bright 1; bold 1; "A"
print at 10, 6; "LEVEL SELECTED"; at 8, 23; "P"; at 12,23;"OWN"; bright 1; bold 1; at 8, 22; "U"; at 12, 22; "D"
print at 15, 6; "PRESS SPACE TO START"
printlogo(0,20)
print at 23, 4; ink 7; bright 1; "2020"
MENULOOP:
print at 10, 22; bold 1; " "; ink 7; bright 1; at 10,22; level + 1
DO
if inkey$ = "u" then
level = level + 1: pausa(5)
if level > levelmax then
level = 0
end if
go to MENULOOP
end if
if inkey$ = "d" then
level = level - 1: pausa(5)
if level < 0
level = levelmax
end if
go to MENULOOP
end if
if inkey$ = "1" then level = 99 : pausa(5): go to MENULOOP
if inkey$ = "2" then level = 199 : pausa(5): go to MENULOOP
if inkey$ = "3" then level = 299 : pausa(5): go to MENULOOP
if inkey$ = " " then pausa(10): go to BUCLE
if inkey$ = "a" then about()
LOOP
' ###########################################################
' ###########################################################
' ABOUT
sub about()
ink 3
cls
print at 3, 4; bold 1; cardinal
print at 6, 0; "ORIGINAL PC GAME BY DANIEL NORA"
print AT 7, 4; "https://danijmn.itch.io"
print at 10, 0; "SPECTRUM VERSION BY MIGUEL PRADA"
print at 12, 11; "THANKS TO"
print at 14, 9; "JAVIER VISPE"
print at 15, 9; "FEDE ALVAREZ"
print at 18, 1; "MOVE: OPQA - SELECT: NM or KL"
print at 19, 4; "R: RESET LEVEL - T: MENU"
print at 21, 2; "https://compiler.speccy.org"
print at 23, 0; bright 1; bold 1; ink 7; compiler; bold 0; at 23, 29; ink 3; bright 0; "ENU"; at 23,28; bold 1; bright 1; "M"
do
if inkey$ ="m" then go to menu
loop
end sub
' ###########################################################
' ###########################################################
' BUCLE PRINCIPAL DEL JUEGO
BUCLE:
SETEO:
border 7: paper 7: ink 0: bright 0: cls
player = 0
players(0,4)=0
players(1,4)=0
players(2,4)=0
players(3,4)=0
players(4,4)=0
players(5,4)=0
players(0,5)=0
players(1,5)=0
players(2,5)=0
players(3,5)=0
players(4,5)=0
players(5,5)=0
INTERFACE()
puntero = tablelevels(level)
MAPEA()
while (contador > 0)
if code inkey$ = keyReset then
border 1
pausa(30)
go to SETEO
end if
if code inkey$ = keyMenu then
border 1
pausa(30)
go to menu
end if
if (code inkey$ = keySelectRight or code inkey$ = keySelectRight2) and nPlayers > 1 then
if players(player, 5) = 0
pintaTile(2)
else
pintaTile(3)
end if
player = player + 1
if player = nPlayers then player = 0: end if
if players(player ,5) = 0
pintaTile(3)
else
pintaTile(2)
end if
coloreaNivel()
pausa(10)
beep 0.01,-2
end if
if (code inkey$ = keySelectLeft or code inkey$ = keySelectLeft2) and nPlayers > 1 then
if players(player, 5) = 0
pintaTile(2)
else
pintaTile(3)
end if
player = player - 1
if player < 0 then player = nPlayers - 1: end if
if players(player, 5) = 0
pintaTile(3)
else
pintaTile(2)
end if
coloreaNivel()
pausa(10)
beep 0.01,-2
end if
' CHEAT
if inkey$ = "7" and level < levelmax then
level = level + 1
pausa(8)
go to BUCLE
end if
if inkey$ = "6" and level > 0 then
level = level - 1
pausa(8)
go to BUCLE
end if
if code inkey$ = keyRight and players(player,0) < (xBoard + (xAncho*2)-2) then
a = players(player,4)
a2 = peek (puntPlayers(player)+1)
if a <= a2 and a2 > 0 then
players(player,4) = a2
contador = contador - a2
puntPlayers(player) = puntPlayers(player) + 1
poke puntPlayers(player), 0
pintaTile(3)
players(player,0) = players(player,0) + 2
pintaTile(3)
pausa(8)
players(player, 5) = 1
beep 0.01,-12
end if
end if
if code inkey$ = keyLeft and players(player,0) > xBoard then
a = players(player,4)
a2 = peek (puntPlayers(player)-1)
if a <= a2 and a2 > 0 then
players(player,4) = a2
contador = contador - a2
puntPlayers(player) = puntPlayers(player) - 1
poke puntPlayers(player), 0
pintaTile(3)
players(player,0) = players(player,0) - 2
pintaTile(3)
pausa(8)
players(player, 5) = 1
beep 0.01,-12
end if
end if
if code inkey$ = keyDown and players(player,1) < (yBoard + (yAlto * 2)-2) then
a = players(player,4)
a2 = peek (puntPlayers(player) + xAncho)
if a <= a2 and a2 > 0 then
players(player,4) = a2
contador = contador - a2
puntPlayers(player) = puntPlayers(player) + xAncho
poke puntPlayers(player), 0
pintaTile(3)
players(player,1) = players(player,1) + 2
pintaTile(3)
pausa(8)
players(player, 5) = 1
beep 0.01,-12
end if
end if
if code inkey$ = keyUp and players(player,1) > yBoard then
a = players(player,4)
a2 = peek (puntPlayers(player) - xAncho)
if a <= a2 and a2 > 0 then
players(player,4) = a2
contador = contador - a2
puntPlayers(player) = puntPlayers(player) - xAncho
poke puntPlayers(player), 0
pintaTile(3)
players(player,1) = players(player,1) - 2
pintaTile(3)
pausa(8)
players(player, 5) = 1
beep 0.01,-12
end if
end if
end while
' CAMBIO DE NIVEL
level = level + 1
if level > levelmax then level = 0: end if
for d = 0 to 23
print at d, 0; over 1; ink 2; " "
pausa(1)
next d
go to BUCLE
' ###########################################################
' ###########################################################
' CUANDO AVANZAMOS POR EL TABLERO PINTA EL TILE QUE DEJA EL PLAYER DEL MISMO COLOR
FUNCTION pintaTile(type2 as uByte) as Integer
dim puntATTR as uInteger
puntATTR = cast(uInteger, players(player,1))*32 + cast(uInteger, players(player,0)) + 22528
poke puntATTR, players(player, type2)
poke puntATTR+1, players(player, type2)
poke puntATTR+32, players(player, type2)
poke puntATTR+33, players(player, type2)
END FUNCTION
' ###########################################################
' ###########################################################
' hace una pausa de n milisegundos
FUNCTION pausa(time as uByte) as uByte
for dPause = 0 to time
asm
ei
halt
end asm
next
END FUNCTION
' ###########################################################
' ###########################################################
' cambia el estado del player seleccionado.
' se le pasa un entero con: 2 para deseleccionar
' 3 para seleccionar
FUNCTION paintPlayer(type as uByte) as uByte
poke (@CURSOR + 32),players(player,type):
poke (@CURSOR + 33),players(player,type):
poke (@CURSOR + 34),players(player,type):
poke (@CURSOR + 35),players(player,type):
putTile(players(player,0),players(player,1),@CURSOR)
end function
' ###########################################################
' ###########################################################
' IMPRIME EL LOGO DE COMPILER EN PANTALLA EN LAS POSICIONES XY
function printlogo(xLogo as uByte, yLogo as uByte) as uByte
for d = 0 to 7
putTile(xLogo, yLogo, tablelogo(d))
xLogo = xLogo +2
if d = 3 then
xLogo = xLogo - 8
yLogo = yLogo + 2
end if
next
end function
' ###########################################################
' ###########################################################
sub INTERFACE()
'IMPRIME MARCADOR DEL NIVEL
m$ = str$(level+1)
DIM prov as uByte = (24-(len(m$)*2))/2
for d = 0 to len (m$) - 1
a = val(m$(d))
putTile(0,prov,(@NUMBERS) + (a*tile))
prov = prov+2
next
' PONE EL COLOR AL NIVEL CORRESPONDIENTE AL PLAYER SELECCIONADO
coloreaNivel()
end sub
'END INTERFACE
' ###########################################################
' ###########################################################
' MAPEA
sub MAPEA()
' ENTRADA en puntero el nivel a volcar
' SETEO DE VARIABLES
puntBuffer = @BUFFER
contador = 0
xAncho = peek (puntero)
yAlto = peek (puntero+1)
puntero = puntero +2
' CALCULA LAS COORDENADAS DE IMPRESIÓN DEL NIVEL
' SIEMPRE LO CENTRA EN PANTALLA
' IGNORA LAS DOS COLUMNAS DEL INTERFACE
xBoard = ((30-(xAncho*2))/2)+2
yBoard = (24-(yAlto*2))/2
for d = yBoard to yBoard + (yAlto*2)-2 step 2
for f = xBoard to xBoard + (xAncho*2)-2 step 2
a = peek (puntero)
if a=0 then go to MAPEA00
if a<10 then go to MAPEA01
if a = 41 then
a = 0:
player = 0:
nPlayers = 1:
players(0,0) = f:
players(0,1) = d:
paintPlayer(3):
puntPlayers(0) = puntBuffer
end if
if a = 42 then
a = 0:
player = 1:
nPlayers = 2:
players(1,0) = f:
players(1,1) = d:
paintPlayer(2):
puntPlayers(1) = puntBuffer
end if
if a = 43 then
a = 0:
player = 2:
nPlayers = 3:
players(2,0) = f:
players(2,1) = d:
paintPlayer(2):
puntPlayers(2) = puntBuffer
end if
if a = 44 then
a = 0:
player = 3:
nPlayers = 4:
players(3,0) = f:
players(3,1) = d:
paintPlayer(2):
puntPlayers(3) = puntBuffer
end if
if a = 45 then
a = 0:
player = 4:
nPlayers = 5:
players(4,0) = f:
players(4,1) = d:
paintPlayer(2):
puntPlayers(4) = puntBuffer
end if
if a=46 then
a = 0:
player = 5:
nPlayers = 6:
players(5,0) = f:
players(5,1) = d:
paintPlayer(2):
puntPlayers(5) = puntBuffer
end if
go to MAPEA00
MAPEA01: putTile(f,d,(@TILES-36) + (a*tile))
MAPEA00: poke (puntBuffer),a: puntero = puntero + 1: puntBuffer = puntBuffer + 1: contador = contador + a
next f
next d
player = 0
END SUB
' END MAPEA
' ###########################################################
' ###########################################################
' CAMBIA EL COLOR DEL INDICADOR DE NIVEL DE ACUERDO CON EL PLAYER SELECCIONADO
SUB coloreaNivel()
for d = 9 to 14
print at d,0; over 1; ink player + 1; " "
next
END SUB
' ###########################################################
#include "putTile.bas"
#include "graphs.asm"
#include "levels.asm"
' BUFFER DE PANTALLA
BUFFER:
ASM
DEFS 180,0
END ASM