10 REM *************************
20 REM *    B R I S C O L A    *
30 REM *                       *
40 REM * PORTED TO LM80C BASIC *
50 REM *  BY LEONARDO MILIANI  *
60 REM *    ORIGINAL CODE BY   *
70 REM *   C.& L. BARAZZETTA   *
80 REM *************************
90 REM
100 SCREEN 4:COLOR 1,15,2:VOLUME 0,15:GOSUB 2000:I=RND(-ABS(TMR(0)))
110 DIM MZ(40,2),C(3,2),G(3,2),MT(10,4):FOR A=1 TO 20
120 CX=INT(RND(1)*25):CY=INT(RND(1)*15):CV=INT(RND(1)*14+1):CS=INT(RND(1)*4)
130 GOSUB 15000:GOSUB 10000:NEXT:PAUSE 200:CLS
140 LOCATE 6,1:PRINT CHR$(217);:FOR I=1 TO 17:PRINT CHR$(143);:NEXT:PRINT CHR$(218)
145 LOCATE 6,2:PRINT CHR$(144);" B R I S C O L A ";CHR$(144)
150 LOCATE 6,3:PRINT CHR$(220);:FOR I=1 TO 17:PRINT CHR$(143);:NEXT:PRINT CHR$(219)
160 LOCATE 5,6:PRINT "di C. & L. Barazzetta"
170 LOCATE 9,8:PRINT "conversione di":LOCATE 8,9:PRINT "Leonardo Miliani"
180 LOCATE 6,14:PRINT "[I] per le Istruzioni":LOCATE 6,15:PRINT "[G] per Giocare"
190 LOCATE 6,16:PRINT "[F] per Finire":A=INKEY(0)
200 A=INKEY(50) AND 223:IF A=ASC("G") THEN 500
205 IF A=ASC("I") THEN 220
210 IF A<>ASC("F") THEN 200
215 CLS:PRINT "Ciao!":END
220 CLS:LOCATE 6,0:PRINT "GIOCO DELLA BRISCOLA"
230 LOCATE 6,1:FOR I=1 TO 20:PRINT CHR$(184);:NEXT:LOCATE 0,3
240 PRINT "Si gioca con un mazzo di 40 car-";
245 PRINT "te. La scala dei valori e' la"
250 PRINT "seguente:":PRINT
260 PRINT "CARTA          SIMBOLO    PUNTI"
270 PRINT "----           -------    -----"
280 PRINT "ASSO              A        11"
290 PRINT "TRE               3        10"
300 PRINT "RE                R        4"
310 PRINT "REGINA (DONNA)    D        3"
320 PRINT "FANTE (GOBBO)     F        2"
330 PRINT "7,6,5,4,2                  0"
340 GOSUB 3000
360 CLS
370 PRINT "Il mazzo lo mischia sempre il"
380 PRINT "computer che distribuisce 3"
385 PRINT "carte ciascuno, ed alla fine"
390 PRINT "mostra l'ultima carta del mazzo"
392 PRINT "e il suo seme e' la briscola."
394 PRINT "I semi sono:":PRINT
400 PRINT CHR$(133);"Picche ";CHR$(132);"Fiori ";
410 PRINT CHR$(131);"Quadri ";CHR$(130);"Cuori":PRINT
420 PRINT "Es.: l'ultima carta e' il 5 di"
425 PRINT "cuori (5";CHR$(130);") percio' la briscola"
430 PRINT "e' cuori e tutte le carte di"
435 PRINT "cuori sono briscole."
440 GOSUB 3000:CLS
442 PRINT "Si gioca buttando una carta"
445 PRINT "ciascuno. Tra le 2 carte buttate";
450 PRINT "una vince secondo queste regole:";:PRINT
460 PRINT "- se i semi delle 2 carte sono"
462 PRINT "uguali vince quella di maggior"
464 PRINT "valore;":PRINT "- se sono diversi e una carta e'";
466 PRINT "una una briscola, vince la"
468 PRINT "briscola;":PRINT "- altrimenti vince chi ha tirato";
470 PRINT "la carta per primo.":PRINT
475 PRINT "Chi ha effettuato la presa ha"
480 PRINT "diritto a pescare per primo una"
482 PRINT "carta dal mazzo e ad iniziare la";
484 PRINT "mano successiva. Si prosegue ri-";
486 PRINT "petendo le mosse precedenti fino";
488 PRINT "all'esaurimento delle carte in"
490 PRINT "mano. Alla fine della partita"
492 PRINT "vince chi ha totalizzato piu' di";
494 PRINT "60 punti."
495 GOSUB 3000:CLS
500 REM *** DISPONI CARTE ***
510 CLS:PG=0:PC=0:NP=0:NF=0:NQ=0:NC=0:BC=0:NA=0:FA=0
520 LOCATE 0,0:FOR W=1 TO 32:PRINT CHR$(130+(INT(RND(1)*4)));:NEXT
530 LOCATE 10,0:PRINT "  BRISCOLA  ";
540 LOCATE 0,1:FOR W=1 TO 5:PRINT CHR$(163);:NEXT:PRINT "COMPUTER";
545 FOR W=1 TO 5:PRINT CHR$(163);:NEXT
550 LOCATE 0,22:PRINT "  1     2     3"
560 LOCATE 0,23:FOR W=1 TO 4:PRINT CHR$(166);:NEXT:PRINT "GIOCATORE";
570 FOR W=1 TO 5:PRINT CHR$(166);:NEXT
595 PAUSE 50
600 PC=0:PG=0
605 LOCATE 0,12:PRINT "Mischio il mazzo  ":GOSUB 50000
610 LOCATE 0,12
620 FOR X=0 TO 12 STEP 6
622 FOR Y=13 TO 2 STEP -11
625 IF Y=2 THEN CC=1:C1=X/6+1:GOTO 640
627 CC=0:G1=X/6+1
640 GOSUB 45000
680 NEXT Y,X
682 FOR C1=1 TO 3
684 GOSUB 55010
686 NEXT C1
690 GOSUB 10000:CX=26:CY=5:CV=MZ(40,1):CS=MZ(40,2):GOSUB 15000:REM BRISCOLA
700 LOCATE 23,2:PRINT "Briscola:";:LOCATE 23,3
710 ON MZ(40,2)+1 GOTO 730,740,750,760
730 PRINT "PICCHE";CHR$(133);:GOTO 770
740 PRINT "FIORI";CHR$(132);:GOTO 770
750 PRINT "QUADRI";CHR$(131);:GOTO 770
760 PRINT "CUORI";CHR$(130);
770 BR=MZ(40,2)
775 PAUSE 50
780 GOSUB 10000:CX=26:CY=10:CV=15:CS=1:GOSUB 15000:REM MAZZO
790 GOSUB 47000
795 T=2
800 FOR I=1 TO 40 STEP 2
810 IF T=2 THEN GOSUB 20000:GOSUB 30000:GOTO 830
820 GOSUB 30000:GOSUB 20000
830 GOSUB 60800
950 PP=0
970 IF J1=14 OR J1=15 THEN PP=PP+J1-4
980 IF Y1=14 OR Y1=15 THEN PP=PP+Y1-4
990 IF J1>10 AND J1<14 THEN PP=PP+J1-9
1000 IF Y1>10 AND Y1<14 THEN PP=PP+Y1-9
1020 IF T=2 AND V=1 OR T=1 AND V=0 THEN 1025
1023 GOTO 1030
1025 LOCATE 0,12:PRINT "Prendi tu";:IF PP>0 THEN PRINT PP;"punti";:ELSE PRINT SPC(9);
1028 PG=PG+PP:T=2:GOTO 1040
1030 LOCATE 0,12:PRINT "Prendo io";:IF PP>0 THEN PRINT PP;"punti";:ELSE PRINT SPC(9);
1035 PC=PC+PP:T=1
1040 IF PP<10 THEN PRINT " "
1041 GOSUB 55000:PAUSE 100
1042 CX=19:CY=5:CV=0:CS=0:GOSUB 15000
1044 CX=19:CY=10:CV=0:CS=0:GOSUB 15000
1048 IF I=33 THEN CX=26:CY=5:CV=0:CS=0:GOSUB 15000:CX=26:CY=10:CV=0:CS=0:GOSUB 15000
1050 IF I>34 THEN C(C1,1)=0:G(G1,1)=0:GOTO 1250
1150 IF T=2 THEN X=G1*6-6:Y=13:CC=0:GOTO 1170
1160 X=C1*6-6:Y=2:CC=1
1170 GOSUB 45000:GOSUB 47000
1180 IF T=1 THEN X=G1*6-6:Y=13:CC=0:GOTO 1210
1200 X=C1*6-6:Y=2:CC=1
1210 GOSUB 45000:GOSUB 47000
1250 NEXT I
1260 LOCATE 0,12:PRINT "   FINE PARTITA   ":PAUSE 100
1270 LOCATE 0,12
1280 IF PC=PG THEN PRINT "PARITA' 60 a 60   ":GOTO 1400
1290 IF PC>PG THEN PRINT "HO VINTO IO";PC;"a";PG;"!  ":GOTO 1400
1300 PRINT "HAI VINTO TU";PG;"a";PC;"!  "
1400 PAUSE 300
1410 LOCATE 0,14:PRINT "Un'altra sfida (S/N)?"
1420 A=INKEY(0)
1430 A=INKEY(50) AND 223:IF A=ASC("S") THEN 510
1440 IF A=ASC("N") THEN 215
1450 GOTO 1430
1970 REM
1980 REM *** INIZIALIZZA CARATTERI SEMI-GRAFICI ***
1990 REM
2000 RESTORE 2100
2010 READ A,B:IF A=0 THEN CLS:RETURN
2020 VP=8192+A*8:FOR W=VP TO VP+7:VPOKE W,B:NEXT
2030 GOTO 2010
2090 REM COPPIE DI NUMERI A,B: A=CODICE ASCII, B=COLORI
2100 DATA 130,143,131,143,132,31,133,31,143,47
2110 DATA 217,47,218,47,219,47,220,47,185,79,143,47,144,47
2120 DATA 0,0
2970 REM
2980 REM *** ATTESA DI UN TASTO ***
2990 REM
3000 LOCATE 0,23:PRINT " Premi un tasto per continuare";:A=INKEY(0)
3010 A=INKEY(50):IF A=0 THEN 3010
3020 RETURN
9999 REM
10000 REM SUONO DI CARTA STRUSCIATA
10010 SOUND 4,10:PAUSE 1:SOUND 4,0:RETURN
15000 REM DISEGNA UNA CARTA A CX,CY CON VALORE CV E SEME CS
15010 IF CV=0 OR CV=15 THEN 15160
15020 LOCATE CX,CY
15030 PRINT CHR$(213);:FOR W=1 TO 4:PRINT CHR$(157);:NEXT:PRINT CHR$(214);
15040 LOCATE CX,CY+1:IF CV=1 THEN CV$="A":GOTO 15100
15050 IF CV=13 THEN CV$="R":GOTO 15100
15060 IF CV=12 THEN CV$="D":GOTO 15100
15070 IF CV=11 THEN CV$="F":GOTO 15100
15090 CC$=STR$(CV):CV$=MID$(CC$,2,1)
15100 PRINT CHR$(158);CV$;"  ";CHR$(133-CS);CHR$(158);
15110 FOR W=2 TO 6:LOCATE CX,CY+W:PRINT CHR$(158);"    ";CHR$(158);:NEXT
15120 LOCATE CX,CY+7:PRINT CHR$(158);CHR$(133-CS);"  ";CV$;CHR$(158);
15130 LOCATE CX,CY+8
15140 PRINT CHR$(216);:FOR W=1 TO 4:PRINT CHR$(157);:NEXT:PRINT CHR$(215)
15150 RETURN
15160 IF CV=0 THEN FOR W=0 TO 8:LOCATE CX,CY+W:PRINT "      ";:NEXT:RETURN
15170 LOCATE CX,CY
15180 PRINT CHR$(213);:FOR W=1 TO 4:PRINT CHR$(157);:NEXT:PRINT CHR$(214);
15190 FOR W=1 TO 7:LOCATE CX,CY+W:PRINT CHR$(158);:FOR J=1 TO 4:PRINT CHR$(185);
15200 NEXT:PRINT CHR$(158);:NEXT:LOCATE CX,CY+8
15210 PRINT CHR$(216);:FOR W=1 TO 4:PRINT CHR$(157);:NEXT:PRINT CHR$(215)
15220 RETURN
15970 REM
15980 REM *** MANO AL GIOCATORE ***
15990 REM
20000 LOCATE 0,12:PRINT "Tocca a te, carta?":A=INKEY(0)
20010 A=INKEY(50):IF A<ASC("1") OR A>ASC("3") THEN 20010
20020 G1=A-48
20030 IF G(G1,1)=0 THEN 20010
20040 CX=G1*6-6:CY=13:CV=0:CS=0:GOSUB 15000
20050 GOSUB 10000:CX=19:CY=10:CV=G(G1,1):CS=G(G1,2):GOSUB 15000
20060 LOCATE 0,12:RETURN
30000 LOCATE 0,12:PRINT "Tocca a me...     "
30010 REM IF PC>60 THEN 30100
30020 IF T=2 THEN 30200
30030 IF T=1 THEN 32000
30100 PAUSE 100
30110 C1=INT(RND(1)*3)+1
30120 IF C(C1,1)=0 THEN 30110
30130 GOTO 39000
30200 REM IL COMPUTER RISPONDE AL GIOCO
30201 BC=0
30202 FOR W=1 TO 3:IF C(W,2)=BR THEN BC=BC+1
30203 NEXT
30204 FOR C1=1 TO 3
30205 IF C(C1,1)=0 THEN PT(C1)=-100:GOTO 31290
30210 GOSUB 60800:PP=0
30220 IF J1=14 OR J1=15 THEN PP=PP+J1-4
30230 IF Y1=14 OR Y1=15 THEN PP=PP+Y1-4
30240 IF J1>10 AND J1<14 THEN PP=PP+J1-9
30260 IF Y1>10 AND Y1<14 THEN PP=PP+Y1-9
30270 IF V=1 THEN PT(C1)=-PP:GOTO 30300
30280 PT(C1)=PP-.01
30300 IF Y1=15 AND Y2=BR THEN PT(C1)=PT(C1)-20
30310 IF Y2=BR AND BC<2 THEN PT(C1)=-5
30320 IF Y2=BR THEN PT(C1)=PT(C1)-.7-(.1*(Y1-8))
31290 NEXT C1
31300 FP=0:MX=1
31310 FOR W=2 TO 3
31320 IF PT(W)>PT(MX) THEN MX=W:GOTO 31330
31330 NEXT
31540 C1=MX
31550 GOTO 39000
32000 REM GIOCA COMPUTER PER PRIMO
32010 BC=0:FOR C1=1 TO 3
32020 IF C(C1,2)=BR THEN BC=BC+1
32030 NEXT C1
32040 BA=0:FOR W=1 TO 10
32050 IF MT(W,BR+1)=0 THEN BA=1
32060 NEXT
32070 FOR C1=1 TO 3
32080 GOSUB 62000
32090 NEXT C1
32100 CX=1
32110 FOR W=2 TO 3
32120 IF PT(W)>PT(CX) THEN CX=W
32130 NEXT
32140 C1=CX
39000 LOCATE 0,12
39010 CX=C1*6-6:CY=2:CV=0:CS=0:GOSUB 15000
39020 GOSUB 10000:CX=19:CY=5:CV=C(C1,1):CS=C(C1,2):GOSUB 15000:RETURN
45000 GOSUB 10000
45005 IF CC=1 THEN CX=X:CY=Y:CV=15:CS=1:GOSUB 15000:C(C1,1)=MZ(PS,1):C(C1,2)=MZ(PS,2)
45010 IF CC=0 THEN 45016
45013 GOTO 45020
45016 CX=X:CY=Y:CV=MZ(PS,1):CS=MZ(PS,2):GOSUB 15000:G(G1,1)=MZ(PS,1):G(G1,2)=MZ(PS,2)
45020 PS=PS+1
45030 IF CC=1 THEN GOSUB 55010:RETURN
46970 REM
46980 REM SCRIVE LE CARTE RIMASTE
46990 REM
47000 LOCATE 26,19:PRINT "Carte";
47010 LOCATE 26,20:PRINT "Mazzo";
47020 LOCATE 27,22:PRINT (40-PS+1);
47030 RETURN
49970 REM
49980 REM *** MESCOLAMENTO DEL MAZZO **
49990 REM
50000 FOR C=1 TO 40:MZ(C,1)=0:NEXT C
50008 FOR C=0 TO 3
50010 FOR B=1 TO 10
50015 GOSUB 10000
50020 PS=INT(RND(1)*40+1)
50030 IF MZ(PS,1)=0 THEN MZ(PS,1)=B:MZ(PS,2)=C:GOTO 50070
50040 IF PS=40 THEN PS=0
50050 PS=PS+1
50060 GOTO 50030
50070 NEXT B,C
50080 FOR C=1 TO 40
50090 IF MZ(C,1)>7 THEN MZ(C,1)=MZ(C,1)+3
50100 NEXT
50110 PS=1:RETURN
55000 FL=0:ON G(G1,2)+1 GOSUB 55100,55200,55300,55400
55010 FL=1:ON C(C1,2)+1 GOSUB 55100,55200,55300,55400
55020 RETURN
55100 NP=NP+1
55110 IF FL=1 THEN MT((C(C1,1)+3*(C(C1,1)>10)),1)=1
55120 IF FL=0 THEN MT((G(G1,1)+3*(G(G1,1)>10)),1)=1
55130 RETURN
55200 NF=NF+1
55210 IF FL=1 THEN MT((C(C1,1)+3*(C(C1,1)>10)),2)=1
55220 IF FL=0 THEN MT((G(G1,1)+3*(G(G1,1)>10)),2)=1
55230 RETURN
55300 NQ=NQ+1
55310 IF FL=1 THEN MT((C(C1,1)+3*(C(C1,1)>10)),3)=1
55320 IF FL=0 THEN MT((G(G1,1)+3*(G(G1,1)>10)),3)=1
55330 RETURN
55400 NC=NC+1
55410 IF FL=1 THEN MT((C(C1,1)+3*(C(C1,1)>10)),4)=1
55420 IF FL=0 THEN MT((G(G1,1)+3*(G(G1,1)>10)),4)=1
55430 RETURN
60800 IF T=2 THEN J1=G(G1,1):J2=G(G1,2):Y1=C(C1,1):Y2=C(C1,2):GOTO 60850
60840 J1=C(C1,1):J2=C(C1,2):Y1=G(G1,1):Y2=G(G1,2)
60850 IF J1=1 THEN J1=15
60860 IF Y1=1 THEN Y1=15
60870 IF J1=3 THEN J1=14
60880 IF Y1=3 THEN Y1=14
60890 IF J2<>Y2 AND Y2<>BR THEN V=1:GOTO 60950
60910 IF J2<>Y2 AND Y2=BR THEN V=0:GOTO 60950
60920 IF J1>Y1 THEN V=1:GOTO 60950
60930 V=0
60950 RETURN
62000 REM SCELTA CARTA
62010 NN=C(C1,1)
62012 IF NN=0 THEN PT(C1)=-100:GOTO 63000
62020 IF NN=1 THEN NN=15
62025 IF NN=3 THEN NN=14
62110 PT(C1)=0
62120 IF NN=14 OR NN=15 THEN PT(C1)=-20-NN
62130 IF BC<2 AND C(C1,2)=BR THEN PT(C1)=-17-NN
62140 IF MT(1,C(C1,2)+1)=0 THEN PT(C1)=PT(C1)-5
62150 IF MT(3,C(C1,2)+1)=0 THEN PT(C1)=PT(C1)-4
63000 RETURN
