Commodore CErco COmmodore - l'iniziativa di appassionati di retrocomputer


Listati BASIC per Commodore VIC-20

Listati per il VIC-20: musica in interrupt, effetti grafici con i caratteri e un piccolo gioco spaziale, tutti digitabili sul BASIC di serie.

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 Vic 20 che consente di ascoltare la musica STAR WARS

La musica si può ascoltare mentre si fa qualunque altra cosa con il computer perchè sfrutta la gestione degli interrupt (gli interrupt sono dei puntatori che gestiscono le varie funzioni del computer, possono essere riprogrammati per far si che mentre il computer esegue le normali routine necessarie al suo funzionamento faccia anche delle altre cose che vogliamo noi). La musica si attiva con SYS 830 e può essere stoppata con i tasti runstop+restore.

      10 poke36878,15
      20 fori=830to976:read c:poke i,c:next 
      30 sys 830
      100data120,169,5,141,60,3,169,6,141,61,3,169,133,133,0,169,3,133,1,169,93,141,20,3,169,3
      110 data 141,21,3,88,96,206,61,3,208,28,72,152,72,172,60
      120 data 3,200,177,0,141,61,3,200,177,0,201
      130 data 1,240,12,141,12,144,140,60,3,104
      140 data 168,104,76,191,234,160,255,208,243
      150 data 15,201,15,201,15,201,60,215,60,228,15
      160 data 225,15,223,15,219,60,235,35,228,15
      170 data 225,15,223,15,219,60,235,35,228,15
      180 data 225,15,223,15,225,60,219,35,201,15
      190 data 201,60,215,60,228,15,225,15,223,15
      200 data 219,60,235,35,228,15,225,15,223,15
      210 data 219,60,235,35,228,15,225,15,223,15
      220 data 219,60,235,1,1
		  

Commodore Vic 20 che consente di generare della musica casuale

      5 print"[cuore in reverse]"
      15 m=int(rnd(1)*8)
      20 a=int(rnd(1)*18)
      30 b=int(rnd(1)*18)
      40 c=7911
      50 d=38631
      60 pokec+a,102:poked+a,m
      70 pokec-a,102:poked-a,m
      80 pokec+11*a+b,102:poked+11*a+b,m
      90 pokec-11*a-b,102:poked-11*a-b,m
      95 if rnd(1)>0.3 then 120
      100 poke36879,16*(int(rnd(1)*16))+int(rnd(1)*8)+8
      120 poke36878,int(rnd(1)*15)+1
      130 poke36874,int(rnd(1)*128)+128
      140 poke36875,int(rnd(1)*128)+128
      150 poke36876,int(rnd(1)*128)+128
      160 poke36877,int(rnd(1)*128)+128
      195 if rnd(1)>0.1 then 205
      200 poke36878,0
      205 if rnd(1)>0.3 then 215
      215 if rnd(1)>0.3 then 230
      220 poke36875,0
      230 fort=1tornd(1)*20+5:next
      240 poke36877,0
      250 poke36876,0
      260 goto 10
		  

Commodore Vic 20 che consente di creare un gioco spaziale

Si ha a disposizione tre vite e con la navicella si deve distruggere asteroidi ed alieni. La collisione con asteroidi o alieni toglie una vita. Il tasto Z permette di ruotare a sinistra, C a destra ed M fa spostare in avanti. Il tasto RETURN consente di spostarsi in un altra zona dello spazio e la BARRA SPAZIATRICE fa sparare.

      5 S=0:li=3:poke36879,8:print"[carattere cuore in reverse per pulire schermo]"
      10 sc=7680:co=30720:cl=38400:as=7680
      15 dim a(7),d(7)
      16 y=11:x=10:d=1:sx=0:sy=0
      20 a=8
      25 fori=0to7:a(i)=7680+int(rnd(1)*506):d(i)=int(rnd(1)*3+21):ifrnd(1)>0.5then d(i)=-d(i)
      30 next
      35 pokecl+y*22+x,3:pokesc+y*22+x,107
      36 ifas>0then pokeas,32
      40 ad=int(rnd(1)*3+21):ifrnd(1)>0.5then ad=-ad
      45 as=int(rnd(1)*506)+7680
      50 fori=0to7:k=peek(197):ifabs(sx)+abs(sy)=0 then poke36877,0:goto55
      51 poke36878,15:poke36877,235:sx=0:sy=0:goto55
      55 d=d+(k=34)-(k=33):ifd<0thend=d+4
      60 ifd>3thend=d-4
      65 sx=sx+((d=1)-(d=3))*(k=36):sy=sy+((d=2)-(d=0))*(k=36)
      70 ifsx<-1thensx=-1
      75 if sx>1thensx=1
      80 if sy<-1thensy=-1
      85 if sy>1 then sy=1
      90 pokesc+y*22+x,32:x=x+sx:y=y+sy
      95 if k=15 then x=int(rnd(1)*22):y=int(rnd(1)*23)
      100 if x<0 then x=21
      105 if x>21 then x=0
      110 if y<0 then y=22
      115 if y>22 then y=0
      116 if peek(sc+y*22+x)<>32then 1000
      120 pokecl+y*22+x,3:c=107:if d=2 then c=114
      125 if d=3 then c=115
      130 if d=0 then c=113
      135 poke sc+y*22+x,c
      140 if a(i)=0 then 200
      141 if a(i)=sc+y*22+x then 1000
      145 pokea(i),32:a(i)=a(i)+d(i)
      150 if a(i)<7680 then a(i)=a(i)+506
      155 if a(i)>8185 then a(i)=a(i)-506
      160 pokea(i)+co,2:pokea(i),81
      200 if k<>32 or int(i/2)*2=i then 260
      201 poke36878,12:forx1=255to230 step -1:poke36877,x1:next
      205 x1=x:y1=y:dx=(d=3)-(d=1):dy=(d=0)-(d=2):c=64:if dy<>0 then c=93
      210 1=x1+dx:y1=y1+dy
      215 pokecl+y1*22+x1,5:if peek(sc+y1*22+x1)=32 then 240
      216 poke36878,15:poke36877,130
      220 pokesc+y1*22+x1,42
      225 forj=0to7:ifa(j)=sc+y1*22+x1 then a=a-1:a(j)=0:s=s+20
      230 nextj
      231 if sc+y1*22+x1=as then s=s+100:as=0
      232 poke 36877,0
      235 goto 250
      240 pokesc+y*22+x1,c:ifx1<21andx1>0andy1>22andy1>0 then 210
      250 x2=x:y2=y
      251 x2=x2+dx:y2=y2+dy:pokesc+y2*22+x2,32
      255 ifx2<>x1ory2<>y1then 251
      256 poke36877,0
      260 ifas=0 then 300
      265 pokeas,32:if rnd(1)>0.9then ad=int(rnd(1)*3+21):if rnd(1)>0.5 then ad=-ad
      267 as=as+ad:if peek(as+ad*2)=81 then ad=-ad
      270 if as<7680 then as=as+506
      275 if as>8185 then as=as-506
      280 pokeas+co,7:pokeas,88
      285 if as=sc+y*22+x then 1000
      300 next i:if a=0 then 20
      305 if as=0 and rnd(1)>0.9 then 40
      310 goto 50
      100 print"[freccia in alto in reverse]PUNTI"s
      1005 fori=1to2000:next:li=li-1:if li>0 then print"[cuore in reverse]":goto 16
      1010 poke36878,0:poke198,0
      9999 end
		  

Commodore Vic 20 che stampa a video i semi delle carte da gioco e fa variare i colori modificando nel registro 16 i bit relativi al colore dello sfondo, del bordo e del modo diretto/inverso

      10 mv=7680:mc=38400
      15 if peek(648)=16 then mv=4096:mc=37888
      17 print"[cuore in reverse]"
      20 pokemv+25,65:pokemv+30,83:pokemv+35,90:pokemv+40,88
      30 pokemv+69,25:pokemv+74,83:pokemv+79,90:pokemv+84,88
      35 x=0
      40 fork=0to15
      45 poke36879,(peek(36879)and15)ork*2[elevato alla]4
      50 foi=0to7
      55 poke36879,(peek(36879)and248)ori
      60 pokemc+25,I:pokemc+30,i:pokemc+35,i:pokemc+40,i
      65 pokemc+69,i:pokemc+74,i:pokemc+79,i:pokemc+84,i
      70 forj=1to300:nextj
      75 next i
      77 if x=0then x=1:goto79
      78 x=0
      79 poke36879,(peek(36879)and247)orx*2[elevato alla]3
      80 next k
      90 end
		  

Commodore Vic 20 che stampa a l'effetto di un caleidoscopio

      10 mv=7680:mc=38400
      20 if peek(648)=16 then mv=4096:mc=37888
      25 print"[cuore in reverse]";
      40 fork=0to505:poke(mv+k),160:next k
      45 z=mc+253:l=0
      50 fori=0to9
      55 forj=0tol
      63 k=(15*rnd(0))+1
      65 poke(z+j),k
      67 poke(z-j-1),k
      70 poke(z+22-21*i+22*j),k
      75 poke(z-21*i-22*j),k
      80 poke(z-23*i+21+22*j),k
      85 poke(z-23*i-1-22*j),k
      90 poke(z-44*i+21-j),k
      95 poke(z-44*i+22+j),k
      100 next j
      105 l=l+1:z=z+22
      110 next i
      120 goto 45
		  

Commodore Vic 20 che fa suonare una melodia mentre si lavora in Basic

Il programma è scritto in linguaggio macchina con la routine di allocazione in memoria in Basic.

        20 fori=0to48:reada:poke7552+i,a:next
        30 fori=0to47:reada:poke7632+i,a:next
        40 poke36878,15:poke176,19:poke177,1
        45 poke643,128:poke644,29:sys7552:sys58232
        50 rem  ON con peek(175) diverso da 0 mentre OFF con peek(175) uguale a 0
        100 data 120,169,144,141,20,3,169,29,141,21,3,169,255,133,175,96,165,,175,240,26
        110 data 198,176,208,22,169,19,133,176,164,177,230,177,192,48,208,4,169,1,133,177
        120 data 185,207,29,141,10,144,76,191,234
        200 data 207,217,223,227,228,227,223,217,207,217,223,227,228,227,227,223,217,183,199
        210 data 207,212,215,212,207,199,207,217,223,227,228,227,223,217,191,203,212,203
        220 data 183,199,207,199,207,217,219,221,223,191,223,191
		  

Tutti i listati BASIC



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