Commodore CErco COmmodore - l'iniziativa di appassionati di retrocomputer


Listati BASIC per Commodore 128

Listati in BASIC 7.0 che sfruttano i comandi grafici del Commodore 128: disegno a mano libera, curve matematiche, animazioni e piccoli giochi.

I listati vanno digitati così come sono, rispettando numeri di riga e punteggiatura. Su emulatore si possono incollare direttamente nella finestra del BASIC.

Indice

Commodore 128 che consente di disegnare con i tasti numerici

Utilizzare i tasti numerici (da 0 a 9)

      1060 graphic 0,1: color 5,2
      1070 color 1,2:color 0,1:color 4,1
      1080 sound 1,0,0:sound 2,0,0
      1090 sound 3,0,0: vol 0
      1100 print chr$(142)
      1110 for a=0 to 8
      1120 sprite a,0:next a
      1140 input "inserire colore bordo (1-16) e premere return ";b
      1150 if b>16 or b<1 then 1140
      1160 input "inserire colore fondo (1-16) e premere return ";p
      1170 if p>16 or p<1 then 1160
      1180 input "inserire colore penna (1-16) e premere return ";i
      1190 if i=p or i>16 or i<1 then 1180
      1200 x=50:y=50:d=1
      1210 color 1,i:color 0,p:color 4,b
      1220 graphic 1,1
      1230 get k$
      1240 if k$<>"" then k=asc(k$)-47
      1250 if k<1 or k>10 then 1270
      1260 on k gosub 1490,1350,1360,1390,1370,1410,1450,1430,1470,1330
      1270 draw d,x,y
      1280 a$="x__"+str$(x)+"    ": rem 4 spazi
      1290 b$="y__"+str$(y)+"    ": rem 4 spazi
      1300 char 1,5,24,a$
      1310 char 1,25,24,b$
      1320 k=0:goto 1230
      1330 if x=319 or y=190 then return
      1340 x=x+1:y=y+1:return
      1350 d=1:return
      1360 d=0:return
      1370 if x=0 or y=190 then return
      1380 x=x-1:y=y+1:return
      1390 if x=0 or y=0 then return
      1400 x=x-1:y=y-1:return
      1410 if x=0 then return
      1420 x=x-1:return
      1430 if y=0 then return
      1440 y=y-1:return
      1450 if y=190 then return
      1460 y=y+1:return
      1470 if x=319 then return
      1480 x=x+1:return
      1490 if x=319 or y=0 then return
      1500 x=x+1:y=y-1:return
		  

Commodore 128 che consente di disegnare i contorni dell'Italia

      1060 graphic 0,1
      1070 color 5,2:color 0,1:color 4,1
      1080 sound 1,0,0:sound 2,0,0
      1090 sound 3,0,0:vol 0
      1100 print chr$(142)
      1110 for a=1 to 8
      1120 sprite a,0:next a
      1140 x=112
      1150 y=34
      1160 restore 1260
      1170 graphic 1,1:k=0 :c=0
      1180 color 1,2
      1190 read d:k=k+1
      1200 if d=1111 then 1250
      1210 if d=0 then y=y+1:goto 1240
      1220 d=d-52
      1230 draw 1,(x+d),y
      1240 goto 1190
      1250 goto 1250
      1260 data 94,0,88,89,91,92,93,0,86,87,88,90,93,0,82,83,85,94,0,81,83,84,95,0
      1270 data 79,82,96,97,98,99,0,78,80,81,100,101,102,103,0,64,65,72,78,104,105,0
      1280 data 64,65,71,73,74,75,76,77,78,103,0,64,66,71,103,104,0
      1290 data 63,67,68,70,105,0,59,61,62,68,70,104,0,54,55,56,57,58,60,69,104,0
      1300 data 53,101,104,0,54,100,101,102,103,104,105,0,55,100,101,106,107,0
      1310 data 55,99,107,0,56,95,96,97,98,0,55,94,0,54,94,0
      1320 data 52,53,94,0,52,95,0,53,95,0,53,96,0,54,94,95,96,0,53,94,0
      1330 data 53,94,0,53,94,0,53,67,68,69,94,0,53,65,66,70,71,94,0
      1340 data 54,55,64,72,73,95,0,56,57,58,59,63,73,74,95,0,59,62,75,76,96,0
      1350 data 59,62,77,97,0,58,59,60,61,78,98,0,78,99,100,0,79,101,0,79,102,0
      1360 data 79,103,0,79,104,105,0,80,105,0,8,0,105,0,81,106,0,81,106,0,75,81,107,0
      1370 data 81,82,107,0,83,107,0,77,78,79,83,107,0,79,84,108,0,76,85,108,0
      1380 data 86,109,0,86,87,88,110,0,83,85,89,111,0,90,112,0,90,113,114,0
      1390 data 91,92,115,0,93,116,117,0,94,118,119,122,123,124,125,0,94,120,121,126,0
      1400 data 95,125,0,96,124,0,97,124,0,98,99,125,126,0,69,100,102,103,127,128,129
      1410 data 0,62,69,101,104,105,106,107,130,0,61,67,68,70,71,108,131,132,133,0
      1420 data 66,72,108,134,135,0,60,65,71,109,136,0
      1430 data 60,61,62,63,64,72,109,110,111,137,138,0,60,72,109,112,139,140,0
      1440 data 60,61,72,107,113,114,115,141,142,0,62,73,112,113,116,134,135,143,0
      1450 data 62,73,110,117,133,136,144,0,62,72,117,132,137,138,139,140,145,0
      1460 data 62,72,117,132,142,146,0,63,71,117,188,131,143,147,0
      1470 data 62,72,119,122,131,143,146,0,62,72,120,121,123,130,143,144,146,0
      1480 data 62,72,123,124,131,145,146,0,63,72,124,130,0,63,72,124,130,0
      1490 data 62,63,72,125,130,0,62,71,125,131,132,133,0,61,71,126,134,0
      1500 data 61,71,126,135,0,61,71,127,135,0,59,61,67,68,69,71,127,135,0
      1510 data 62,66,70,127,135,0,61,63,66,127,135,0,63,64,65,128,133,134,135,0
      1520 data 128,132,0,128,131,0,125,126,127,131,0,118,126,131,0,116,126,131,0
      1530 data 126,130,131,0,118,125,129,0,122,124,125,128,0
      1540 data 103,117,120,121,122,124,128,0,98,101,102,103,114,115,116,118,119
      1550 data 122,124,128,0,92,97,99,100,104,105,109,110,111,112,113,121,124,125
      1560 data 126,127,0,94,96,106,107,108,120,0,96,120,0,96,119,0,97,119,0
      1570 data 98,99,100,101,119,0,102,103,118,0,104,118,0,105,106,118,0
      1580 data 107,108,120,0,109,110,111,112,121,0,113,120,0,114,119,0
      1590 data 91,114,115,118,119,0,92,116,117,0,1111
		  

Commodore 128 che disegna in alta risoluzione le curve di alcune funzioni matematiche

        1060 graphic 0,1
        1070 color 5,2: color 0,13: color 4,7
        1080 sound 1,0,0:sound 2,0,0
        1090 sound 3,0,0: vol 0
        1100 print chr$(142)
        1110 for a=1 to 8
        1120 sprite a,0: next a
        1140 graphic 1,1:color 1,2
        1150 for x=0 to 320 
        1160 draw 1,x,199-(x*x/515) 
        1170 next x
        1180 for x=0 to 320
        1190 draw 1,x,199-(x*x/515) to x,199
        1200 next x
        1210 sleep 4
        1220 color 1,14:scnclr
        1230 for x=0 to 320
        1240 y=rnd(1)*x/1.6
        1250 draw 1,x,199-y to x,199
        1260 next x
        1270 sleep 4
        1280 color 1,5:scnclr
        1290 for x=0 to 320
        1300 y=199-log(x/5+1)*47
        1310 draw 1,x,y
        1320 next x
        1330 for x=0 to 320 
        1340 y=199-log(x/5+1)*47
        1350 draw 1,x,y to x,199
        1360 next x
        1370 sleep 4
        1380 color 1,8:scnclr
        1385 for x=0 to 320
        1390 draw 1,x,199-(99+cos(cos/180*(180+x*1.13))*99)
        1410 next x
        1420 for x=0 to 320
        1430 y=99+(cos(cos/180*(180+x*1.13))*99)
        1440 draw 1,x,199-y to x,199
        1450 next x
        1460 sleep 6
        1470 graphic 0,1:color 4,7
        1480 color 0,1:color 5,2
		  

Commodore 128 che disegna il panorama di una città con due file di grattacieli

Ogni volta che si lancia questo programma crea un paesaggio diverso e casuale.

        1060 graphic 3,1: color 5,2: color 3,15
        1070 color 2,8:color 0,1: color 4,1
        1080 sound 1,0,0:sound 2,0,0:sound 3,0,0:vol 0
        1100 print chr$(142)
        1110 for a=1 to 8
        1120 sprite a,0:next a
        1140 for a=1 to 20
        1150 draw 1,rnd(1)*159,rnd(1)*80
        1160 next a
        1170 k=5:n=2
        1180 dim l(20)
        1190 dim h(20)
        1200 print chr$(142)
        1210 for a=1 to 8
        1220 sprite a,0:next a
        1230 for a=1 to 20
        1240 l(a)=((2+int(rnd(1)*3))*4)
        1250 h(a)=(k+int(rnd(1)*(2+k)))*8+int((rnd(1)*k)-1)
        1260 next a
        1270 x=0
        1280 for a=1 to 20
        1290 x=x+l(a)
        1300 if x<160 then gosub 1400
        1310 if x>159 then 1330
        1320 next a
        1330 l(a)=159-(x-l(a))
        1340 x=159
        1350 gosub 1400
        1360 if k=2 then 1390
        1370 k=2:n=3
        1380 goto 1230
        1390 sleep 10:graphic 0,1:end
        1400 for y=0 to h(a) step 2
        1410 draw n,x-l(a),191-y to x-1,191-y
        1420 draw 0,x-l(a),190-y to x-1,190-y
        1430 next y
        1440 draw n,x-l(a),191 to x-l(a),192-h(a)
        1450 draw n,x-1,191 to x-1,192-h(a)
        1460 return
		  

Commodore 128 che disegna una roulette

Il programma sfrutta tutte le potenzialità notevoli del basic 7.0 del C128. La roulette si avvia premendo il tasto N.

        1060 graphic 3,1:color 1,6:color 3,11
        1070 color 2,2:color 0,1:color 4,7
        1080 sound 1,0,0:sound 2,0,0
        1090 sound 3,0,0:vol 10
        1100 print chr$(142)
        1110 for a=1 to 8
        1120 sprite a,0:next a
        1140 dim p(37):dim i(37):dim num$(37)
        1150 c=1:l=3:h=4
        1160 for a=0 to 353 step 9.729
        1170 k==/180*a
        1180 x=75*cos(k)+45
        1190 y=90*sin(k)+91
        1200 read p,i,n$
        1210 p(c)=p:i(c)=i:num$(c)=n$:c=c+1
        1220 if p=2 then z=2
        1230 if p=6 then z=1
        1240 if p=2 or p=6 then gosub 1390
        1250 x=x-1
        1260 if i=1 then z=0
        1270 if i=3 then z=3
        1280 n=asc(left$(n$,1))-48
        1290 gosub 1730
        1300 x=x+5
        1310 n=asc(right$(n$,1))-48
        1320 gosub 1730
        1330 next a
        1340 l=5:h=8
        1350 r=50+int(rnd(1)*75)
        1360 get k$
        1370 if k$="n" then gosub 1430
        1380 goto 1350
        1390 for k=y-(h/2) to y+h*2+(h/2)
        1400 draw z,(x+32)-(l/2),k+4 to x+32+l*+(l/2),k+4
        1410 next k
        1420 return
        1430 v=0
        1440 for f=0 to r*9.729 step 9.729
        1450 v=v+1:if v=38 then v=1
        1460 draw 0,a+32,b+4
        1470 draw 0,a+33,b+4
        1480 draw 0,a+32,b+5
        1490 draw 0,a+33,b+5
        1500 k==/180*f
        1510 a=65*cos(k)+47
        1520 b=78*sin(k)+94
        1530 draw 2,a+32,b+4
        1540 draw 2,a+33,b+4
        1550 draw 2,a+32,b+5
        1560 draw 2,a+33,b+5
        1570 sound 2,50,10
        1580 next f
        1590 x=40:y=86:i=i(v):p=p(v)
        1600 if p=2 then z=2
        1610 if p=1 then z=0
        1620 if p=6 then z=1
        1630 n$=num$(v)
        1640 gosub 1390
        1650 if i=1 then z=0
        1660 if i=3 then z=3
        1670 n=asc(left$(n$,1))-48
        1680 gosub 1730
        1690 x=x+7
        1700 n=asc(right$(n$,1))-48
        1710 gosub 1730
        1720 return
        1730 if n=-16 then return
        1740 if n=0 or n=2 or n=3 or n=5 or n=6 or n=7 or n=8 or n=9 then draw z,x+32,y+4 to x+32+l,y+4
        1750 if n=0 or n=3 or n=4 or n=5 or n=6 or n=8 or n=9 then draw z,x+32,y+4+h to x+32+l,y+4+h
        1760 if n=0 or n=2 or n=3 or n=5 or n=6 or n=8 or n=9 then draw z,x+32,y+4+h+h to x+32+l,y+4+h+h
        1770 if n=0 or n=1 or n=2 or n=3 or n=4 or n=7 or n=8 or n=9 then draw z,x+32+l,y+4 to x+32+l,y+4+h
        1780 if n=0 or n=1 or n=3 or n=4 or n=5 or n=6 or n=7 or n=8 or n=9 then draw z,x+32+l,y+4+h to x+32+l,y+4+h+h
        1790 if n=0 or n=2 or n=6 or n=8 then draw z,x+32,y+4+h to x+32,y+4+h+h
        1800 if n=0 or n=4 or n=5 or n=6 or n=8 or n=9 then draw z,x+32,y+4 to x+32,y+4+h
        1810 return
        1820 data 1,3,"5 ",2,1,"24",1,3,"16",2,1,"33",1,3,"1 "
        1830 data 2,1,"20",1,3,"14",2,1,"31",1,3,"9 ",2,1,"22"
        1840 data 1,3,"18",2,1,"29",1,3," 7",2,1,"28",1,3,"12"
        1850 data 2,1,"35",1,3," 3",2,1,"26",6,1," 0",1,3,"32"
        1860 data 2,1,"15",1,3,"19",2,1," 4",1,3,"21",2,1," 2"
        1870 data 1,3,"25",2,1,"17",1,3,"34",2,1,"6 ",1,3,"27"
        1880 data 2,1,"13",1,3,"36",2,1,"11",1,3,"30",2,1,"8 "
        1890 data 1,3,"23",2,1,"10"
		  

Commodore 128 che crea una animazione

Prima animazione

        1060 graphic 0,1
        1070 color 5,2:color 0,1:color 4,7
        1080 sound 1,0,0:sound 2,0,0
        1090 sound 3,0,0:vol 0
        1100 print chr$(142)
        1110 for a=1 to 8
        1120 sprite a,0:next a
        1140 graphic 1,1:color 1,2:color 0,1
        1150 dx=30:dy=0
        1160 d=int(rnd(1)*2)
        1170 if d=1 then w=dx:dx=dy:dy=w
        1180 x  =30+int(rnd(1)*131)
        1190 y=30+int(rnd(1)*99)
        1200 sr=int(rnd(1)*4)
        1210 if sr=0 then gosub 1240
        1220 if sr=1 or sr=2 or sr=3 then gosub 1290
        1230 goto 1160
        1240 draw 1,x,y to x-dx,y-dy
        1250 draw 1,319-x,y to 319-x+dx,y-dy
        1260 draw 1,x,199-y to x-dx,199-y+dy
        1270 draw 1,319-x,199-y to 319-x+dx,199-y+dy
        1280 return
        1290 draw 0,x,y to x-dx,y-dy
        1300 draw 0,319-x,y to 319-x+dx,y-dy
        1310 draw 0,x,199-y to x-dx,199-y+dy
        1320 draw 0,319-x,199-y to 319-x+dx,199-y+dy
        1330 return
		

Seconda animazione

        1060 graphic 0,1
        1070 color 5,2:color 0,1:color 4,15
        1080 sound 1,0,0:sound 2,0,0
        1090 sound 3,0,0:vol 0
        1100 print chr$(142)
        1110 for a=1 to 8
        1120 sprite a,0:next a
        1140 c=1
        1150 gosub 1400
        1160 for p=1 to 11
        1170 char ,p+9,12-p,chr$(x)
        1180 next p
        1190 for n=1 to 11 step 2
        1200 gosub 1400
        1210 for p=1 to 12-n
        1220 char ,19+p,-1+p+n,chr$(x)
        1230 next p
        1240 gosub 1400
        1250 for p=1 to 12-n
        1260 char ,32-p-n,10+p,chr$(x)
        1270 next p
        1280 gosub 1400
        1290 for p=1 to 11-n
        1300 char ,21-p,23-p-n,chr$(x)
        1310 next p
        1320 gosub 1400
        1330 for p=1 to 11-n
        1340 char ,9+p+n,13-p,chr$(x)
        1350 next p
        1360 next n
        1370 c=c*(-1)
        1380 x=32
        1390 goto 1150
        1400 if c=1 then x=33+int(rnd(1)*96):color 5,int(rnd(1)*14)+2
        1410 return
		

Tutti i listati BASIC



Copyright 2003 - 2026 (c) Cerco Commodore - Tutti i diritti riservati - Privacy e cookie - Termini e condizioni