11

Random Walking

So far my palette cycling was generally drawing one initial screen, and then playing with the colors. But what if the image continues drawing randomly instead? Here were some experiments in that vein.
the 256 DAC registers

Seven variations, starting at 3 AM on New Year's Eve

Random line drawing, worked through in one overnight sitting: five files between 03:12 and 06:29 on 31 December, a sixth at 03:38 on New Year's Day, a seventh on the 2nd. FUN5 is then left alone for seven months and finished on 1996-08-08, the same nineteen minutes in which ALL was switched back on and SAVER001 begun.

randomize inside the loop

The bug that gives the family its look. randomize reseeds from the DOS clock, which ticks at 18.2 Hz, so consecutive calls inside one frame return the same seed, and consecutive points come out nearly identical. Instead of scatter you get short straight dashes.

What makes it readable rather than merely broken is that the dash length differs between the vsync and non-vsync variants: waiting for retrace changes how many points fall inside one 55-millisecond clock tick. The bug is a fingerprint of the frame rate, and you can see which variant you are looking at from the dashes alone.

Two of them drop Mode X entirely

Six of these files open uses crt,jmodex. FUN4 and FUN5.BAK open uses crt - no graphics unit at all. Everything is done by hand from there: the mode set through INT 10h, pixels written straight to $A000, the palette pushed through ports $3C8/$3C9.

That is the night I stopped calling somebody else's routines and started addressing the hardware - and it does not stick immediately, because FUN1.PAS two days later goes back to jmodex. But the machinery survives: it is what ASMSTARS is built on three weeks later, and it is how the rest of the archive talks to the screen.

FUN.PAS

1995-12-31 03:16 · 685 bytes

uses crt,jmodex;var q,x,y,r,s:integer;

procedure circ(x,y,r,l:integer);var b,c:integer;a:real;begin if r=0 then b:=0
else b:=round(sqrt(r*r-1));a:=b;for c:=0to round(r/sqrt(2))do begin if a=0
then a:=1;a:=(a-(c/a));b:=round(a);draw_line(x+b,y+c,x-b,y+c,l);
draw_line(x+b,y-c,x-b,y-c,l);draw_line(x+c,y+b,x-c,y+b,l);
draw_line(x+c,y-b,x-c,y-b,l);end;end;

begin if set_vga_modex(7,360,480,1)=0 then halt(0);clear_vga_screen(0);
for q:=1to 30do set_dac_register(q,q*2,0,0);s:=1;q:=1;x:=180;y:=240;
repeat randomize;inc(x,random(3)-1);inc(y,random(3)-1);
if q>29then s:=-s else if q<1then s:=-s;inc(q,s);circ(x,y,1,q);
until keypressed;asm mov ah,0;mov al,3;int 16;end;end.
FUN1.BAK

1995-12-31 03:12 · 686 bytes · The earliest of the night.

uses crt,jmodex;var q,x,y,r,s:integer;
procedure circ(x,y,r,l:integer);var b,c:integer;a:real;
begin if r=0 then b:=0 else b:=round(sqrt(r*r-1));a:=b;
for c:=0to round(r/sqrt(2))do begin if a=0 then a:=1;
a:=(a-(c/a));b:=round(a);draw_line(x+b,y+c,x-b,y+c,l);
draw_line(x+b,y-c,x-b,y-c,l);draw_line(x+c,y+b,x-c,y+b,l);
draw_line(x+c,y-b,x-c,y-b,l);end;end;
begin if set_vga_modex(7,360,480,1)=0 then halt(0);clear_vga_screen(0);
for q:=1 to 64 do set_dac_register(q,q,0,0);s:=1;q:=1;x:=180;y:=240;
repeat randomize;inc(x,random(3)-1);inc(y,random(3)-1);
if q>62then s:=-s else if q<1then s:=-s;inc(q,s);circ(x,y,10,q);
until keypressed;asm mov ah,0;mov al,3;int 16;end;end.
FUN1.PAS

1996-01-02 05:45 · 825 bytes

uses crt,jmodex;var c,q,x,y,r,s,o:integer;
procedure circ(x,y,r,l:integer);var b,c:integer;a:real;
begin if r=0 then b:=0 else b:=round(sqrt(r*r-1));a:=b;
for c:=0to round(r/sqrt(2))do begin if a=0 then a:=1;
a:=(a-(c/a));b:=round(a);draw_line(x+b,y+c,x-b,y+c,l);
draw_line(x+b,y-c,x-b,y-c,l);draw_line(x+c,y+b,x-c,y+b,l);
draw_line(x+c,y-b,x-c,y-b,l);end;end;
begin if set_vga_modex(7,360,480,1)=0 then halt(0);clear_vga_screen(0);
for q:=1 to 64 do set_dac_register(q,q,0,0);s:=1;q:=1;x:=180;y:=240;o:=0;
repeat randomize;inc(x,(random(3)-1)*3);inc(y,(random(3)-1)*3);inc(o);
if q>62then s:=-s else if q<1then s:=-s;inc(q,s);circ(x,y,10,q);
repeat until(port[$3da]and 8)=0;repeat until(port[$3da]and 8)<>0;
for c:=1to 63do set_dac_register(c,c*2+o,0,0);
until keypressed;asm mov ah,0;mov al,3;int 16;end;end.
FUN2.PAS

1995-12-31 03:21 · 625 bytes

uses crt,jmodex;var q,x,y,s:integer;

procedure circ(x,y,l:integer);var b,c:integer;a:real;begin
b:=0;a:=0;for c:=0to 1do begin if a=0
then a:=1;a:=(a-(c/a));b:=round(a);draw_line(x+b,y+c,x-b,y+c,l);
draw_line(x+b,y-c,x-b,y-c,l);draw_line(x+c,y+b,x-c,y+b,l);
draw_line(x+c,y-b,x-c,y-b,l);end;end;

begin if set_vga_modex(7,360,480,1)=0 then halt(0);clear_vga_screen(0);
for q:=1to 30do set_dac_register(q,q*2,0,0);s:=1;q:=1;x:=180;y:=240;
repeat randomize;inc(x,random(3)-1);inc(y,random(3)-1);
if q>29then s:=-s else if q<1then s:=-s;inc(q,s);circ(x,y,q);
until keypressed;asm mov ah,0;mov al,3;int 16;end;end.
FUN3.PAS

1995-12-31 03:45 · 653 bytes

uses crt,jmodex;var o,c,q,x,y,s:integer;

begin if set_vga_modex(7,360,480,1)=0 then halt(0);clear_vga_screen(0);
for c:=1to 30do set_dac_register(c,c*2,0,0);s:=1;q:=1;x:=180;y:=240;o:=1;
repeat

if q>29then s:=-s else if q<1then s:=-s;inc(q,s);
if o>63then o:=1;inc(o);
randomize;inc(x,random(3)-1);inc(y,random(3)-1);
if x>359then x:=359 else if x<1then x:=1;
if y>479then y:=479 else if y<1then y:=1;
set_point(x,y+1,q);set_point(x,y-1,q);draw_line(x+1,y,x-1,y,q);
repeat until(port[$3da]and 8)=0;repeat until(port[$3da]and 8)<>0;
for c:=1to 30do set_dac_register(c,c*2+o,0,0);

until keypressed;asm mov ah,0;mov al,3;int 16;end;end.
FUN4.PAS

1995-12-31 06:29 · 643 bytes · Raw mode 13h, DAC ports, and the ancestor of ASMSTARS.

uses crt;var o,c,q,x,y,s:integer;

begin
asm mov ah,00;mov al,19;int 16;end;
for c:=1to 64do Begin Port[$3C8]:=c;Port[$3C9]:=c+o;Port[$3C9]:=0;
Port[$3C9]:=0;End;s:=1;q:=1;x:=160;y:=100;o:=1;
repeat

if q>63then s:=-s else if q<1then s:=-s;inc(q,s);
inc(o);
randomize;inc(x,random(3)-1);inc(y,random(3)-1);
if x>319then x:=319 else if x<1then x:=1;
if y>199then y:=199 else if y<1then y:=1;
Mem[$a000:y*320+x]:=q;
repeat until(port[$3da]and 8)=0;repeat until(port[$3da]and 8)<>0;
for c:=1to 64do Begin Port[$3C8]:=c;Port[$3C9]:=c*2+o;Port[$3C9]:=0;
Port[$3C9]:=0;End;

until keypressed;asm mov ah,0;mov al,3;int 16;end;end.
FUN5.BAK

1996-01-01 03:38 · 1,073 bytes

uses crt;var o,c,q,s:integer;x,y:array[1..16]of integer;

begin
asm mov ah,00;mov al,19;int 16;end;
for c:=1to 64do Begin Port[$3C8]:=c;Port[$3C9]:=c+o;Port[$3C9]:=0;
Port[$3C9]:=0;End;s:=1;q:=1;
x[1]:=64;y[1]:=40;
x[2]:=128;y[2]:=40;
x[3]:=192;y[3]:=40;
x[4]:=256;y[4]:=40;
x[5]:=64;y[5]:=80;
x[6]:=128;y[6]:=80;
x[7]:=192;y[7]:=80;
x[8]:=256;y[8]:=80;
x[9]:=64;y[9]:=120;
x[10]:=128;y[10]:=120;
x[11]:=192;y[11]:=120;
x[12]:=256;y[12]:=120;
x[13]:=64;y[13]:=160;
x[14]:=128;y[14]:=160;
x[15]:=192;y[15]:=160;
x[16]:=256;y[16]:=160;
o:=1;
repeat

if q>63then s:=-s else if q<1then s:=-s;inc(q,s);
inc(o);
randomize;
for c:=1to 16do begin
inc(x[c],random(3)-1);inc(y[c],random(3)-1);
if x[c]>319then x[c]:=319 else if x[c]<1then x[c]:=1;
if y[c]>199then y[c]:=199 else if y[c]<1then y[c]:=1;
Mem[$a000:y[c]*320+x[c]]:=q;end;
repeat until(port[$3da]and 8)=0;repeat until(port[$3da]and 8)<>0;
for c:=1to 64do Begin Port[$3C8]:=c;Port[$3C9]:=c*2+o;Port[$3C9]:=0;
Port[$3C9]:=0;End;

until keypressed;asm mov ah,0;mov al,3;int 16;end;end.
FUN5.PAS

1996-08-08 05:13 · 1,019 bytes · Finished seven months later.

uses crt;var o,c,q,s:integer;x,y:array[1..16]of integer;

begin
asm mov ah,00;mov al,19;int 16;end;
for c:=1to 64do Begin Port[$3C8]:=c;Port[$3C9]:=c+o;Port[$3C9]:=0;
Port[$3C9]:=0;End;s:=1;q:=1;
x[1]:=64;y[1]:=40;
x[2]:=128;y[2]:=40;
x[3]:=192;y[3]:=40;
x[4]:=256;y[4]:=40;
x[5]:=64;y[5]:=80;
x[6]:=128;y[6]:=80;
x[7]:=192;y[7]:=80;
x[8]:=256;y[8]:=80;
x[9]:=64;y[9]:=120;
x[10]:=128;y[10]:=120;
x[11]:=192;y[11]:=120;
x[12]:=256;y[12]:=120;
x[13]:=64;y[13]:=160;
x[14]:=128;y[14]:=160;
x[15]:=192;y[15]:=160;
x[16]:=256;y[16]:=160;
o:=1;
repeat

if q>63then s:=-s else if q<1then s:=-s;inc(q,s);
inc(o);
randomize;
for c:=1to 16do begin
inc(x[c],random(3)-1);inc(y[c],random(3)-1);
if x[c]>319then x[c]:=319 else if x[c]<1then x[c]:=1;
if y[c]>199then y[c]:=199 else if y[c]<1then y[c]:=1;
Mem[$a000:y[c]*320+x[c]]:=q;end;
delay(100);
for c:=1to 64do Begin Port[$3C8]:=c;Port[$3C9]:=c*2+o;Port[$3C9]:=0;
Port[$3C9]:=0;End;

until keypressed;asm mov ah,0;mov al,3;int 16;end;end.