C128-ANTS-ON-THE-SCREEN-IN-MULTICOLOR --------------------------------------------------------------------------------------------------- TOOL: BASIC-7.0 {Commodore C128} Language: BASIC Extra: none Author: Misel Zivanovic Note: (C) 05th of OCTOBER 2026 - www.lived.ch, mzretro.ch Doc Revision: 1.0 Last update: 15:34 06.11.2026 --------------------------------------------------------------------------------------------------- This is actually working also with just 1MHz CPU clock, but for a real experience, you better turn on the WARP mode of your VICE C128 emulator! I am actually wondering how this would behave on a C64U and this Cyberpunk C64 with 77MHz Clock! Would be nice to see that in action there! Also a Commodore Plus4 version with 127 colors would be nice to see. {now available!} --------------------------------------------------------------------------------------------------- BASIC RANDOM NUMBERS: --------------------------------------------------------------------------------------------------- 100 rem ------------------------------- 110 rem www.mzretro, www.lived.ch 120 rem ------------------------------- 130 graphic 3,1:color 0,1:color4,1 135 sw=159:sh=199:xy=10:max=10:color5,15 141 dim x(xy),y(xy),mx(xy),my(xy) 142 for a=1 to max 143 x(a)=rnd(1)*sw+1:rem x coord 144 y(a)=rnd(1)*sh+1:rem y coord 151 next: 152 rem ******************************* 160 color 1,7:color 2,7:color 1,16 175 for a=1 to max 180 mx(a)=(rnd(1)*10+5)/10 181 my(a)=(rnd(1)*10+5)/10 182 tg=int(rnd(1)*4+1) 183 if tg=1 then x(a)=x(a)+(-mx(a)) 184 if tg=2 then x(a)=x(a)+abs(mx(a)) 185 if tg=3 then y(a)=y(a)+(-my(a)) 186 if tg=4 then y(a)=y(a)+abs(my(a)) 210 if x(a)>=sw then x(a)=159 220 if x(a)<=0 then x(a)=1 230 if y(a)>=sh then y(a)=159 240 if y(a)<=0 then y(a)=1 250 : 260 rem ---------------------------- 270 : 280 co=int(rnd(1)*3+1) 285 if co=1then color1,int(rnd(1)*14+2) 500 draw co,x(a),y(a):next 510 goto 175 *************************************************************************************************** ASSEMBLY RANDOM NUMBERS: --------------------------------------------------------------------------------------------------- 100 rem ------------------------------- 101 rem assembly number generator 102 scnclr 103 for a=0 to 18:read v$ 104 poke 2024+a,dec(v$):next 105 data a9,00,8d,00,ff,a9,ff,8d,0e,d4 106 data 8d,0f,d4,a9,80,8d,12,d4,60 107 rem rnd=peek(54299) 108 sys 2024:n=54299: rem rnd on b15 109 rem ------------------------------- 110 rem www.mzretro, www.lived.ch 120 rem ------------------------------- 130 graphic 3,1:color 0,1:color 4,1 135 sw=159:sh=199:xy=10:max=10:color5,15 141 dim x(xy),y(xy),mx(xy),my(xy) 142 for a=1 to max 143 x(a)=rnd(1)*sw+1:rem x coord 144 y(a)=rnd(1)*sh+1:rem y coord 151 next: 152 rem ******************************* 160 color 1,7:color 2,7:color 1,16 175 fora=1tomax 180 mx(a)=(rnd(1)*10+5)/10 181 my(a)=(rnd(1)*10+5)/10 182 g=int(rnd(1)*4+1) 183 ifg=1thenx(a)=x(a)+(-mx(a)) 184 ifg=2thenx(a)=x(a)+abs(mx(a)) 185 ifg=3theny(a)=y(a)+(-my(a)) 186 ifg=4theny(a)=y(a)+abs(my(a)) 210 ifx(a)>=swthenx(a)=159 220 ifx(a)<=0thenx(a)=1 230 ify(a)>=shtheny(a)=159 240 ify(a)<=0theny(a)=1 280 co=int(rnd(1)*3+1) 285 ifco=1thencolor1,(peek(n)and15)+1 500 drawco,x(a),y(a):next 510 goto175 ***************************************************************************************************