As written. y := round(30*sin(x)) feeds the loop counter
straight to sin, so it is 1, 2, 3… radians. A full cycle
takes 2π ≈ 6.28 iterations, and each iteration moves the text 4 pixels right,
so the wave has a wavelength of about 25 pixels on a 320-pixel screen.
It does not wave. It vibrates, and the amplitude is ±30, which is bigger than
the text is tall. I likely didn't realize that was confusing degrees and radians
but liked how it looked at the time and kept it as is.
Everything before this is one effect in one file. MYDEMO has
two named parts behind comment banners (Blue Fade and Meow)
which is a demo's structure rather than a program's. The name says the same
thing. It is forty minutes before I opened the year-old BOX, on the
evening that becomes the busiest stretch in the archive.
The real step forward is invisible: it keeps a clean copy of the background on
another Mode X page and restores only the rectangle it dirtied. Three months
earlier MIMSY cleared and repainted.
The Meow loop runs for x := 1 to 180 and places the text at
x*4. The screen is 320 pixels wide.
| x | x*4 | |
|---|---|---|
| 1 | 4 | first frame |
| 80 | 320 | the text reaches the right edge |
| 180 | 720 | 400 pixels past it |
101 of the 180 iterations draw nothing you can see, and each one
still runs its delay(20), so the program spends about two seconds
animating text that left the screen.
It is the same shape of mistake as the wave itself. Both come from writing a loop bound that felt right (180 for half a circle, 180 for a nice long run) without checking it against the width of the thing it was drawing into.
1995-09-21 22:41 · 1,139 bytes · Both parts, with the banners.
Uses Crt,jmodex;Type xy=array[1..100,1..100]of byte;
Var x,y,z:integer;Col:Byte;a:xy;
Procedure Text(s:string;x,y,B,F:integer);Var a:Array[1..135]of Char;i:byte;
Begin For i:=1to Length(s)DO a[i]:=s[i];Print_Str(a,Length(s),X,Y,B,f);End;
Procedure TText(s:string;X,Y,c:integer);Var a:Array[1..135]of Char;i:byte;
Begin For i:=1to Length(s)DO a[i]:=s[i];TPrint_Str(a,Length(s),X,Y,C);End;
Procedure Page(p:byte);Begin set_active_page(p);set_display_page(p);end;
Procedure Demo;Begin IF SET_VGA_MODEX(1,320,400,2)=0 THEN halt(0);y:=0;
FOR X:=1TO 250DO Begin SET_DAC_REGISTER(X,0,0,X div 4);end;col:=0;
{**************Blue Fade**************}
page(0);for y:=1to 200do draw_line(0,y,320,y,y);for y:=1to 200do
draw_line(0,y+200,320,y+200,200-y);repeat for x:=1to 254do
Set_Dac_Register(x,0,0,(Col+x) div 4);col:=col+5;delay(10);until col=255;
{************Meow*****************}
copy_page(0,1);page(1);for x:=1 to 180 do begin y:=round(30*sin(x));
ttext('Meow?',x*4,200+y,0);delay(20);
copy_bitmap(0,x*4,200+y,x*4+38,208+y,1,x*4,200+y);end;
page(0);
repeat until keypressed;end;Begin Demo;asm mov ah,0;mov al,3;int 16;end;END.