Commodore CErco COmmodore - l'iniziativa di appassionati di retrocomputer


Listati BASIC per Commodore 64

Una raccolta di listati in BASIC V2 per il Commodore 64: suono e musica con il SID, grafica in alta risoluzione, stampa con la MPS 801, utility e trucchi sul tasto RESTORE.

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 64 per produrre un suono simile al violino

      10 For i=54272 to 54296
      20 Poke i,0: next
      30 poke 54277,90: poke 54278,94
      40 poke 54296,15
      50 read hf,bf,du
      60 if hf<0 then goto 160
      70 poke 54273,hf:poke 54272,bf
      80 poke 54276,33
      90 for i= 1 to du: next
      100 poke 54276,32: for i= 1 to 90:next
      110 goto 50
      120 data 33,135,128,33,135,128,33,135,128
      130 data 37,162,128,42,62,250,37,62,250
      140 data 33,135,128,42,62,128,37,162,128
      150 data 37,162,128,33,135,250, -1, -1, -1
      160 end
		

Commodore 64 per tracciare una curva ad alta risoluzione

      20 def fna(x)=sin(x)/x
      30 input "intervallo?";x1,x2
      40 pa=(x2-x1)/320
      50 mi=1.7 E 38: ma= 1.7 E 38
      60 for x= 0 to 319
      70 x3=x1+x*pa
      80 if x3=0 then y=1: goto 100
      90 y=fna(x3)
      100 if y < mi then mi = y
      110 if y > ma then ma = y
      120 next
      130 b=ma*199/(ma-mi): a=199/(mi-ma)
      140 poke 53265,peek(53265) or 32
      150 poke 53272,peek(53272) or 8
      160 for i= 8192 to 16383
      170 poke i,0:next
      180 for i= 1024 to 2023
      190 poke i,1:next
      200 for x= 0 to 319
      210 x3=x1+x*pa
      220 if x3= 0 then y=int(a+b): goto 240
      230 y=int (b+a*fna(x3))
      240 li=int(y/8)
      250 co=int(x/8)
      260 lc=y and 7
      270 oc=8192+320*li+8*co+lc
      280 bi=7-(7 and x)
      290 poke oc,peek(oc) or (2 elevato alla bi)
      300 next x
      310 goto 310
		

Commodore 64 che consente di cambiare colore di sfondo

Aggiunge una istruzione con la sintassi SYS49152,x,y dove x e y sono valori compresi da 0 a 15 e consente di cambiare il colore di bordo e sfondo dello schermo. Vengono utilizzate le routine di sistema di salto della virgola in una riga BASIC.

      10 for i=0 to 34:read a:poke 49152+i,a:next
      20 data 32,253,174,32,158,183,224,15,48,3
      30 data 76,72,178,138,141,32,208,32,253,174
      40 data 32,158,183,225,15,48,3,76,72,178
      50 data 138,141,33,208,96
		  

Commodore 64 che consente di disegnare in alta risoluzione e salvare il disegno

I tasti F1 ed F2 servono rispettivamente per cancellare il video ad alta risoluzione e per richiamare o memorizzare il disegno.

        10 For i=20000 to 20121:read q:pokei,q:next
        20 data 169,0,133,251,169,32,133,252,160,0,169,0,145,251,230,251,197,251,240,2
        30 data 208,246,230,252,169,64,197,252,208,236,169,0,133,251,169,4,133,252
        40 data 160,0,138,145,251,230,251,169,232,197,251,208,7,169,7,197,252
        50 data 208,1,96,152,197,251,240,4,138,24,144,230,230,252,24,144,224
        60 data 255,162,0,169,18,157,0,4,232,224,255,208,248,162,0,169,18,157,255,4,232
        70 data 224,255,208,248,162,0,169,18,157,254,5,232,224,255,208,248,162,0,169
        80 data 18,157,253,6,232,224,235,208,248,96
        90 sys 20000:sys 20071
        100 poke53272,peek(53272)or 8
        110 poke53265,peek(53265)or 32
        120 x=160:y=100
        130 z=peek(56320):n=peek(197)
        140 if n=4 then sys20000:sys20071
        150 if n=5 then 1000
        160 if z=126 then y=y-1
        170 if z=125 then y=y+1
        180 if z=123 then x=x-1
        190 if z=119 then x=x+1
        200 if z=118 then x=x+1:y=y-1
        210 if z=117 then x=x+1:y=y+1
        220 if z=121 then x=x-1:y=y+1
        230 if z=122 then x=x-1:y=y-1
        240 ch=int(x/8):ro=int(y/8):ln=yand7:by=8192+ro*320+8*ch+ln:bi=7-(xand7)
        250 pokeby,peek(by)or(2[elevato (freccia in alto sulla tastiera del C64)]bi)
        500 goto 130
        1000 print chr$(147):poke53265,27:poke53272,21
        1010 z1=8192:z2=16191
        1020 input"Nome del file";z$
        1030 input"Disco o Nastro (D/N)";t$
        1040 if t$="n" then x=1
        1050 if t$="d" then x=8
        1060 input"Load o Save (L/S)";s$
        1070 if s$="s" then 1100
        1080 if s$="l" then 1160
        1100 open 1,x,1,z$
        1110 fors=z1toz2:m=peek(i)
        1120 print#1,m
        1130 nexti:close 1
        1140 goto 90
        1160 poke53272,peek(53272)or8:print chr$(147):sys20000:sys20071
        1170 poke53265,peek(53265)or32
        1180 open 1,x,0,z$
        1190 fori=z1toz2
        1200 input#1,m
        1210 pokei,m:next i:close 1:goto 130
		  

Commodore 64 che consente controllare l'esattezza del codice fiscale in Basic 2.0

        10 dim c(16),d(26)
        20 fori=1to16
        30 readc(i)
        40 nexti
        50 fori=1to26
        60 readd(i)
        70 next i
        80 print chr$(147)
        90 input"Inserire il codice fiscale";a$
        100 gosub 20000
        10000 print chr$(147):print "Lunghezza del codice errata":gosub30000
        10010 print chr$(147):print "Codice errato":gosub30000
        20000 z=1
        20010 if len(a$)<>16 then goto 10000
        20020 i=1
        20030 b$=mid$(a$,i,1)
        20040 if b$<"a" or b$>"z" then 20070
        20050 if c(i)<>0 then 10010
        20060 goto 20110
        20070 if b$<"0" or b$>"9" then goto 10010
        20080 if c(i)<>1 then 10010
        20090 i=i+1
        20100 if i<=16 then 20030
        20110 s=0
        20150 for i=1 to 15 step 2
        20160 b$=mid$(a$,i+1,1)
        20170 if c(i)=0 then 20200
        20180 s=s+d(val(b$)+1)
        20190 goto 20120
        20200 s=s+d(val(b$)-64)
        20210 if i=15 then 20270
        20220 b$=mid$(a$,i+1,1)
        20230 if c(i+1)=0 then 20260
        20240 s=s+val(b$)
        20250 goto 20270
        20260 s=s+asc(b$)-65
        20270 next i
        20280 r=s-int(s/26)*26
        20290 if mid$(a$,16,1)<>chr$(r+65) then 10010
        20300 z=0
        20400 print "Il codice";a$;"è esatto"
        30000 print" Se vuoi riinserire il codice premi R"
        30010 print" altrimenti un altro tasto…."
        30020 get x$:if x$="" then 30020
        30030 if x$="r" then run
        30040 end
        30100 data 0,0,0,0,0,0,1,1,0,1,1,0,1,1,1,0,1,0,5,7,9,13,15,17,19,21,2,4,18,20,11
        30110 data 3,6,8,12,14,16,10,22,25,24,23
		  

Commodore 64 che consente di creare degli istogrammi con la stampante MPS801

        100 data 240,152,148,148,244,140,252
        110 fori=1to7
        120 read q:a$=a$+chr$(q)
        130 next i
        140 data 255,128,128,128,255,128,255
        150 fori=1to7
        160 read q:b$=b$+chr$(q)
        170 next i
        180 data 128,128,128,128,128,128,128
        190 fori=1to7
        200 read q:c$=c$+chr$(q)
        210 next i
        220 data 255,129,129,129,128,128,128
        230 fori=1to7
        240 read q:d$=d$+chr$(q)
        250 next i
        260 print chr$(147):poke 646,1:poke53280,0:poke53281,0
        270 print"Numero di elementi da confrontare"
        280 input "Variabile";n
        290 input "Estensione";e
        300 dim p(e,n)
        310 fori=0toe:p(i,0)=3:next
        320 fori=1ton
        330 readv
        340 p((e+1)-v,i)=2:v=v-1
        350 for c=(e+1)-v to e
        360 p(c,i)=1
        370 next c:next i
        380 open2,4
        390 fori=0toe
        400 forc=0ton
        410 x=p(i,c)
        420 if x=3 then print#2,chr$(8)d$;chr$(8) c$;
        430 if x=1 then print#2,chr$(8)b$;chr$(8) c$;
        440 if x=2 then print#2,chr$(8)a$;chr$(8) c$;
        450 if x=0 then print#2,chr$(8)c$;c$;
        460 next c
        470 print#2,chr$(8)
        480 next i
        490 data 16,2
		  

Commodore 64 che consente di fare l'hard-copy dello schermo

Il programma serve a fare l'hard-copy dello schermo (sia modalità testo che modalità grafica). Parte delle routine sono scritte in linguaggio macchina, parte in basic.

        10 if peek(2)<>1 then print"cuore in reverse ed esse in reverse";:goto 30
        20 if peek(2)=1 then 70
        30 fori=49152 to 49179: read d:pokei,d:nexti:print"cuore in reverse ed esse in reverse"; 
        35 rem il cuore in reverse e la s in riverse servono a pulire lo schermo 
        ed a posizionare il cursore nell'angolo superiore sinistro
        40 sys49152:end
        50 data 169,11,141,24,3,169,192,141,25,3,96,169,1,141,2,0,32,89,166,169,0,141
        60 data 0,8,76,174,167,64
        70 sa=0
        80 print"s in reverse";
        90 open3,3:open4,4,sa
        100 for k=0 to 24:a$=""
        110 for j=0 to 38
        120 get#3,b$:a$=a$+b$
        130 next j
        140 print#4,a$;
        150 next k:print
        160 close 3: close 4:clr:r$="":poke2,0:run
		  

Commodore 64 per la riprogrammazione della funzione del tasto restore e di altri tasti

restore: attiva la routine
spazio: disattiva
run/stop: resetta il c64
(freccia sinistra): elimina l'effetto di restore

        1 clr: print chr$ (147): poke 53280,0 : poke 53281,0 : x = 49152 : b= 49273
        10 for i = x to b: read d : poke i,d : next : poke 775,167 : sys x : end
        15 data 169,1,141,134,2
        20 data 169,16,141,24,3,169,192,141,25,3,96,72,169,1,141,2,134,169,0,141,32
        30 data 208,141,33,208,169,127,141,0,220,173,1,220,201,127,240,11,201,239,240,27
        35 data 201,253,240,45
        40 data 76,17,192,169,14,141,134,2,169,254,141,32,208,169,246,141,33,208
        41 data 234,234,76,252,252,169,254,141,32
        50 data 208,169,246,141,33,208,169,1,141,134,2,169,0,141,198,0,104,64
        55 data 169,71,141,24,3,169,254,141,25,3,169,246,141,33,208,169,254,141,33,208
        56 data 169,14,141,134,2,104,64
		

Commodore 64 per la riprogrammazione del tasto restore adibendolo a funzione di "congelamento"

Il tasto restore viene adibito a funzione di "congelamento" dell'attività del C64. Lavorando in background può essere utile, oltre che come esercizio di programmazione assembler, anche unito ad altri programmi per, ad esempio, bloccare la schermata di un gioco su un immagine ed eseguirne l'hard-copy.

Istruzioni per l'uso:
sys 49152 attiva il programma
sys 49227 disattiva il programma
restore congela il C64
spazio ripristina il C64 dopo il blocco

        10 poke 775,191:fori=49152to49318:readd:pokei,d:next
        20 data 169,0,141,32,208,141,33,208,169,15,141,24,212,169,10,141,5,212,141,6
        30 data 212,169,17,141,4,212,169,33,141,0,212,169,135,141,1,212,169,16,141,4
        40 data 212,169,1,141,134,2,169,57,141,24,3,169,192,141,25,3,96,72,173,1,220
        50 data 201,239,240,3,76,58,192,169,0,141,198,0,104,64,174,24,3,224,71,240,3,76
        60 data 86,192,96,169,15,141,24,212,169,10,141,5,212,141,6,212,169,17,141,4,212
        70 data 169,37,141,0,212,169,162,141,1,212,169,16,141,4,212,169,246,141,33,208
        80 data 169,254,141,32,208,169,14,141,134,2,169,71,141,24,3,169,254,141,25,3,96
        90 data 96,96,96,169,24,6,141,33,208,169,254,141,32,208,169,14,141,134,2
        100 data 76,252,252,96
        110 print chr$(147):print "Premi un tasto, un suono conferma l'attivazione della routine"
        120 poke198,0:wait198,1:sys49152:poke775,167:end
		

Commodore 64 per utilizzarlo come un generatore di note

Sfrutta le enormi potenzialità del SID (il suo integrato sonoro). È interamente scritto in basic 2.0 ed è suddiviso in due funzionalità. All'inizio un menù permette di accedere o ad un piano elettronico oppure ad un editor di suoni. Per mezzo dell'editor di suoni si possono inserire note (fino a 1000) che verranno poi suonate in sequenza.

        10 poke775,191:clr:print chr$(147):poke53280,3:poke53281,3:a1$="Programma by Pastore Carlo"
        20 a2$="(c) 1990":a3$="Premi un tasto":aa=len(a1$):bb=len(a2$):cc=len(a3$)
        30 print"qqq]]] in reverse": for i=1 to aa:for j=1 to 50:next j:print mid$(a1$,i,1);:next
        40 print"q in reverse":for i = 1 to bb : for j = 1 to 50 : next j : print mid$ (a,i,1):next
        45 fori=1to600:next
        50 print"q in reverse":fori=1tocc:forj=1to50:nextj:print mid$(a3$,i,1);:next
        60 poke198,0:wait198,1:print chr$(147):poke646,1:poke53280,0:poke53281,0:poke198,0
        70 print"5 q in reverse 5 ]Menù :":print"3 q in reverse 8 ]1- Music editor"
        80 print"2 q in reverse 8 ]2- Piano elettronico"
        90 get d$="": if d$="" then 90
        100 if d$="1" then 1000
        110 if d$="2" then 10000
        120 if d$<>"1" or d$<>"2" then 90
        1000 print chr$(147):poke 646,1
        1010 input"3 q in reverse Quante note vuoi inserire (1-1000)";z
        1020 if z<1 or z>1000 then 1000
        1030 dim x(z),y(z):n=0
        1040 if n=z then 1150
        1041 n=n+1
        1050 input"cuore in reverse Qual'è la nota";x$
        1060 if x$="do" then x(n)=33:y(n)=135:goto 1040
        1070 if x$="re" then x(n)=37:y(n)=162:goto 1040
        1080 if x$="mi" then x(n)=42:y(n)=62:goto 1040
        1090 if x$="fa" then x(n)=44:y(n)=193:goto 1040
        1100 if x$="sol" then x(n)=50:y(n)=60:goto 1040
        1110 if x$="la" then x(n)=56:y(n)=99:goto 1040
        1120 if x$="si" then x(n)=63:y(n)=75:goto 1040
        1121 if x$="hd" then x(n)=67:y(n)=15:goto 1040
        1130 if x$<>"do" or x$<>"re" or x$<>"mi" or x$<>"fa" or x$<>"sol" then 1040
        1140 if x$<>"la" or x$<>"si" or x$<>"hd" then 1040
        1150 poke646,7:print chr$(147):print"suono il motivo (s/n) ?"
        1160 get r$:if r$="" then 1160
        1170 if r$="s" then 1190
        1180 clr:print chr$(147):goto 70
        1190 sid=54272:fori=0to24:pokesid+i,0:next
        1191 print chr$(147):input"Volume (0-15)";v
        1192 if v<0 or v>15 then v=15
        1193 input "2 q in reverse Forma d'onda (17-33-65-129)";q
        1200 print chr$(147):pokesid+24,v:pokesid+5,31:pokesid+6,31:pokesid+4,q
        1210 fori=1ton:pokesid+1,x(i):pokesid,y(i):pokesid+4,q:forh=1to180:nexth
        1220 p  okesid+4,q-1:forj=1to20:nextj:nexti:pokesid+24,0:pokesid+4,q-1
        1230 print chr$(147):input"Ancora";s$
        1240 if s$="si" then 1200
        1250 clr:print chr$(147):poke646,1:goto 70
        10000 w1$="Piano elettronico":w2$="Programma by Pastore Carlo (c) 1990"
        10001 xx=len(w1$):yy=len(w2$):print"2 q in reverse";chr$(147)
        10002 fori=1toxx:forj=1to50:nextj:print mid$(w1$,i,1);:next
        10003 print"q in reverse":for i=1toyy:forj=1to50:nextj:print mid$(w2$,i,1);:next
        10010 print"s in reverse 6 q in reverse Q = do - W = re - E = mi - R = fa"
        10020 print"q in reverse T = sol - Y = la - U = si - I = do (alto)"
        10021 print"q in reverse A = do# - S = re# - D = fa# - F = sol#"
        10022 print"q in reverse G = la#":poke198,0
        10030 sid=54272:fori=0to24:pokesid+i,0:next:pokesid+24,15:pokesid+4,17
        10031 pokesid+5,10:pokesid+6,10
        10040 get z$:if z$="" then 10040
        10050 if z$="q" then pokesid+4,17:goto 12000
        10060   if z$="w" then pokesid+4,17:goto 12010
        10070 if z$="e" then pokesid+4,17:goto 12020
        10080 if z$="r" then pokesid+4,17:goto 12030
        10090 if z$="t" then pokesid+4,17:goto 12040
        10100 if z$="y" then pokesid+4,17:goto 12050
        10110 if z$="u" then pokesid+4,17:goto 12060
        10120 if z$="i" then pokesid+4,17:goto 12070
        10130 if z$="a" then pokesid+4,17:goto 12080
        10140 if z$="s" then pokesid+4,17:goto 12090
        10150 if z$="d" then pokesid+4,17:goto 12100
        10160 if z$="f" then pokesid+4,17:goto 12110
        10170 if z$="g" then pokesid+4,17:goto 12120
        10171 if z$="1" then print chr$(147):clr:end
        10180 if z$<>"q" or z$<>"w" or z$<>"e" or z$<>"r" or z$<>"t" then 10040
        10190 if z$<>"y" or z$<>"u" or z$<>"i" or z$<>"a" or z$<>"s" then 10040
        10200 if z$<>"d" or z$<>"f" or z$<>"g" or z$<>"1" then 10040
        12000 pokesid+1,33:pokesid,135:fori=1to180:next:pokesid+4,16:goto 10040
        12010   pokesid+1,37:pokesid,162:fori=1to180:next:pokesid+4,16:goto 10040
        12020 pokesid+1,42:pokesid,62:fori=1to180:next:pokesid+4,16:goto 10040
        12030 pokesid+1,44:pokesid,193:fori=1to180:next:pokesid+4,16:goto 10040
        12040 pokesid+1,50:pokesid,60:fori=1to180:next:pokesid+4,16:goto 10040
        12050 pokesid+1,56:pokesid,99:fori=1to180:next:pokesid+4,16:goto 10040
        12060 pokesid+1,63:pokesid,75:fori=1to180:next:pokesid+4,16:goto 10040
        12070 pokesid+1,67:pokesid,15:fori=1to180:next:pokesid+4,16:goto 10040
        12080   pokesid+1,35:pokesid,134:fori=1to180:next:pokesid+4,16:goto 10040
        12090 pokesid+1,39:pokesid,223:fori=1to180:next:pokesid+4,16:goto 10040
        12100 pokesid+1,47:pokesid,107:fori=1to180:next:pokesid+4,16:goto 10040
        12110 pokesid+1,53:pokesid,57:fori=1to180:next:pokesid+4,16:goto 10040
        12120 pokesid+1,59:pokesid,190:fori=1to180:next:pokesid+4,16:goto 10040
		

Tutti i listati BASIC



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