Program Sine; uses crt, graph; Type IconMem = array[1..50*50*4] of integer; List = array[1..65] of integer; List2 = array[1..65] of integer; List3 = array[1..65] of integer; List4 = array[1..65] of integer; List5 = array[1..65] of integer; List6 = array[1..65] of integer; var rad, PathX, PathY, xc, yc, mag : real; xi, yi, gd, gm, degree, PathLoc, dif, base : integer; dif2 : real; CirclePathX1 : list; CirclePathY1 : list2; CirclePathX2 : list3; CirclePathY2 : list4; CirclePathX3 : list5; CirclePathY3 : list6; Icons : IconMem; Icons_Found : boolean; Const full : FillPatternType = ( 255, 255, 255, 255, 255, 255, 255, 255 ); {--------------------------------------------------------------} Procedure InitGraphics; Var Gd, Gm : integer; begin Gd := Detect; InitGraph(Gd, Gm, ''); if GraphResult <> grOK then Halt(1); end; {---------------------------------------------------------------} Procedure Generate_sine; begin xc := succ (GetMaxX) div 2; yc := succ (GetMaxY) div 2; mag := 70; rad := 0; degree := 0; Repeat degree := degree + 1; PathX := xc + mag * cos(rad + dif2); PathY := yc + mag * sin(rad); xi := round(PathX); yi := round(PathY); rad := rad + 0.1; CirclePathX1[degree] := xi; CirclePathY1[degree] := yi; { PutPixel(xi,yi,7); } Until degree >= 63 end; {==========================================================================} Procedure Generate_sine2; begin xc := succ (GetMaxX) div 2; yc := succ (GetMaxY) div 2; mag := 70; rad := 0; degree := 0; Repeat degree := degree + 1; PathX := xc + mag * cos(rad); PathY := yc + mag * sin(rad + dif2); xi := round(PathX); yi := round(PathY); rad := rad + 0.1; CirclePathX2[degree] := xi; CirclePathY2[degree] := yi; { PutPixel(xi,yi,7); } Until degree >= 63 end; {==========================================================================} Procedure Generate_sine3; begin xc := 100; yc := 100; mag := 50; rad := 0; degree := 0; Repeat degree := degree + 1; PathX := xc + mag * cos(rad); PathY := yc + mag * sin(rad); xi := round(PathX); yi := round(PathY); rad := rad + 0.1; CirclePathX3[degree] := xi; CirclePathY3[degree] := yi; { PutPixel(xi,yi,7); } Until degree >= 63 end; {==========================================================================} function Does_File_Exist(filename:string):boolean; var f:file; BEGIN {$I-} assign(f,filename); reset(f); close(f); {$I+}; Does_File_Exist := (IOResult = 0) AND (filename <> ''); END; {---------------------------------------------------------------} Procedure load_balls; var FileChar : file of integer; index : integer; data : integer; Filename : string; begin Filename := 'balls'; Icons_Found := True; If Does_File_Exist(Filename+'.anm') = false then begin Writeln; TextColor(Magenta); Write('Could not find '); Textcolor(7); write('balls.anm'); Textcolor(Magenta); write(' file!'); TextColor(7); writeln; Icons_Found := False; end; If Icons_Found = True then begin assign (FileChar, Filename+'.anm'); reset(FileChar); For index := 0 to 50*50*4 do begin read(FileChar,data); Icons[index] := data; end; close(FileChar); end; end; {---------------------------------------------------------------} Procedure Startup; var Count, Count2, Count3, X, X2, y, y2 : Integer; begin delay(500); For Count := 1 to 8 do begin setcolor(white); settextstyle(TriplexFont,HorizDir,count); settextjustify(CenterText, CenterText); outtextxy(Succ(GetMaxX) div 2, Succ(GetMaxY) div 2,'Sine Demo'); delay(20); setcolor(0); settextstyle(TriplexFont,HorizDir,count); settextjustify(CenterText, CenterText); outtextxy(Succ(GetMaxX) div 2, Succ(GetMaxY) div 2,'Sine Demo'); end; setcolor(white); settextstyle(TriplexFont,HorizDir,count); settextjustify(CenterText, CenterText); outtextxy(Succ(GetMaxX) div 2, Succ(GetMaxY) div 2,'Sine Demo'); settextstyle(SmallFont,HorizDir,20); X := -600; For Count := 1 to 18 do begin setcolor(white); outtextxy(X,300,'Written By Franz Ayestaran'); delay(20); setcolor(0); outtextxy(X,300,'Written By Franz Ayestaran'); X := X + 51; end; setcolor(white); outtextxy(X,300,'Written By Franz Ayestaran'); delay(20); {**************************************************************} y := 11; y2 := GetMaxY + 60; for count := 1 to 40 do begin setColor(1); line(1,y,GetMaxX,y); line(1,y2,GetMaxX,y2); delay(5); setColor(0); y := y + 5; y2 := y2 - 5; end; {------------------} y := 11; y2 := GetMaxY + 60; for count := 1 to 39 do begin setColor(9); line(1,y,GetMaxX,y); line(1,y2,GetMaxX,y2); delay(5); setColor(0); y := y + 5; y2 := y2 - 5; end; {------------------} y := 11; y2 := GetMaxY + 60; for count := 1 to 38 do begin setColor(11); line(1,y,GetMaxX,y); line(1,y2,GetMaxX,y2); delay(5); setColor(0); y := y + 5; y2 := y2 - 5; end; {------------------} y := 11; y2 := GetMaxY + 60; for count := 1 to 37 do begin setColor(0); line(1,y,GetMaxX,y); line(1,y2,GetMaxX,y2); delay(5); setColor(0); y := y + 5; y2 := y2 - 5; end; {**************************************************************} setcolor(7); settextstyle(smallfont, horizdir, 5); outtextxy(succ(getmaxX) div 2,330,'For Software Development call 07769924587'); delay(5000); x := 1; x2 := GetMaxX -1; setcolor(0); for count := 1 to GetMaxX do begin setColor(0); line(x,195,x,355); line(x2,195,x2,355); delay(2); x := x + 2; x2 := x2 - 2; end; end; {--------------------------------------------------------------} Procedure Display_Balls_Vals; var index, index2, Index3, data, Horiz, Vert, x, y, x2, y2, x3, y3, lx, lx2, ten_degr, icon, degree, count : integer; begin ten_degr := 0; SetTextJustify(CenterText, CenterText); setcolor(7); SetTextStyle(SmallFont, HorizDir, 10); OutTextXY(succ(GetMaxX) div 2,GetMaxY-70,'Sprite & Sine Table Demo'); SetTextStyle(SmallFont, HorizDir, 7); OutTextXY(succ(GetMaxX) div 2,GetMaxY-40,'Written By Franz Ayestaran 7/9/93'); setcolor(8); SetTextStyle(SmallFont, HorizDir, 4); OutTextXY(553,85,'8-Port (A)'); SetColor(8); line(410,180,430,180); line(410,180,415,175); line(410,180,415,185); SetColor(red); SetTextStyle(SmallFont, HorizDir, 4); OutTextXY(470,179,'Sine Path 1'); SetColor(8); line(410,310,430,310); line(410,310,415,305); line(410,310,415,315); SetColor(blue); SetTextStyle(SmallFont, HorizDir, 4); OutTextXY(470,309,'Sine Path 2'); lx := 520; setcolor(7); for count := 1 to 6 do begin rectangle(lx,60,lx+10,75); lx := lx + 11; end; lx := 520; rectangle(lx-5,55,lx+66+5,75+5); setfillpattern(full,8); setcolor(8); rectangle(lx-4,56,lx+66+4,74+5); rectangle(lx-1,59,lx+66,71+5); floodfill(lx-2,57,8); lx2 := lx+1; for degree := 1 to 63 do begin for count := 1 to 63 do begin putpixel(CirclePathX1[count],CirclePathY1[count]+5,red) end; for count := 1 to 63 do begin putpixel(CirclePathX2[count],CirclePathY2[count]+5,blue) end; for count := 1 to 63 do begin putpixel(CirclePathX3[count],CirclePathY3[count]+5,7); end; SetColor(8); Circle(100,105,54); SetColor(2); line(100,100,CirclePathX3[degree],CirclePathY3[degree]+5); SetColor(4); circle(160,100,3); circle(40,100,3); circle(100,45,3); circle(100,165,3); SetColor(7); SetTextStyle(SmallFont, HorizDir, 4); OutTextXY(170,99,'0'); OutTextXY(24,99,'180'); OutTextXY(100,35,'270'); OutTextXY(100,175,'90'); {**************************************************************} if (ten_degr < 10) and (degree < 60 ) then begin SetFillPattern(full,red); bar(lx2,61,lx2+8,74); end; {**************************************************************} x := CirclePathX1[degree]-dif; y := CirclePathY1[degree]; index := 0; For Vert := 1 to 15 do begin For Horiz := 1 to 24 do begin data := Icons[Index]; if data <>0 then PutPixel(x,y,data); index := index + 1; x := x + 1; end; index := index + 26; x := CirclePathX1[degree]-dif; y := y + 1; end; {**************************************************************} x2 := CirclePathX2[degree]-dif; y2 := CirclePathY2[degree]; index2 := 50*50; For Vert := 1 to 15 do begin For Horiz := 1 to 24 do begin data := Icons[Index2]; if data <>0 then PutPixel(x2,y2,data); index2 := index2 + 1; x2 := x2 + 1; end; index2 := index2 + 26; x2 := CirclePathX2[degree]-dif; y2 := y2 + 1; end; {**************************************************************} x3 := succ (GetMaxX) div 2 - 9; y3 := succ (GetMaxY) div 2 - 3; index3 := 50*50*2; For Vert := 1 to 15 do begin For Horiz := 1 to 24 do begin data := Icons[Index3]; if data <>0 then PutPixel(x3,y3,data); index3 := index3 + 1; x3 := x3 + 1; end; index3 := index3 + 26; x3 := succ (GetMaxX) div 2 - 9; y3 := y3 + 1; end; delay(10); {**************************************************************} SetColor(7); line(CirclePathX1[degree],CirclePathY1[degree]+5, CirclePathX2[degree],CirclePathY2[degree]+5); {**************************************************************} x := CirclePathX1[degree]-dif; y := CirclePathY1[degree]; index := 50*50*3; For Vert := 1 to 15 do begin For Horiz := 1 to 24 do begin data := Icons[Index]; if data = 14 then PutPixel(x,y,0); index := index + 1; x := x + 1; end; index := index + 26; x := CirclePathX1[degree]-dif; y := y + 1; end; {**************************************************************} x2 := CirclePathX2[degree]-dif; y2 := CirclePathY2[degree]; index2 := 50*50*3; For Vert := 1 to 15 do begin For Horiz := 1 to 24 do begin data := Icons[Index2]; if data = 14 then PutPixel(x2,y2,0); index2 := index2 + 1; x2 := x2 + 1; end; index2 :=index2 + 26; x2 := CirclePathX2[degree]-dif; y2 := y2 + 1; end; DirectVideo := False; gotoxy(1,1); textcolor(red); write(chr(219)); textcolor(7); write(' Sine Pos X: ',CirclePathX1[degree],' '); write('Y: ',CirclePathY1[degree],' '); gotoxy(52,1); textcolor(blue); write(chr(219)); textcolor(7); write(' Sine Pos X: ',CirclePathX2[degree],' '); write('Y: ',CirclePathY2[degree],' '); gotoxy(61,3); write('Sine Table Pos: '); write(degree,' '); DirectVideo := True; SetColor(0); line(100,100,CirclePathX3[degree],CirclePathY3[degree]+5); SetColor(0); line(CirclePathX1[degree],CirclePathY1[degree]+5, CirclePathX2[degree],CirclePathY2[degree]+5); if ten_degr = 10 then begin SetFillPattern(full,0); bar(lx2,61,lx2+8,74); lx2 := lx2 + 11; ten_degr := 0; end; ten_degr := ten_degr + 1; {**************************************************************} case degree of 1 : port[base] := 2; 10 : port[base] := 1; 20 : port[base] := 8; 30 : port[base] := 4; 40 : port[base] := 32; 50 : port[base] := 16; end; {**************************************************************} end; end; {---------------------------------------------------------------} begin base := $300; port[base+3] := 128; Load_balls; InitGraphics; dif2 := 1.2; Generate_Sine; Generate_Sine2; Generate_Sine3; dif := 9; startup; Repeat Display_Balls_Vals; Until Keypressed; CloseGraph; port[base] := 0; end.