home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / FAHR32K.ZIP / FAHR32K.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1993-04-09  |  5.2 KB  |  215 lines

  1. { Orchid Fahrenheit 1280 32000 color test program
  2.   by Danny Thorpe and David Wilhelm  11/9/91
  3.   written in Turbo Pascal 6.0  - does not use BGI }
  4.  
  5. {$X+}
  6. uses Crt;
  7.  
  8. const
  9.   Frgd_Mix_Reg    = $bae8;
  10.   Frgd_Color_Reg  = $a6e8;
  11.   MultiFunc_Cntl  = $bee8;
  12.   Cur_X           = $86e8;
  13.   Cur_Y           = $82e8;
  14.   Maj_Axis_Pcnt   = $96e8;
  15.   DestX_Diastp    = $8ee8;
  16.   DestY_Axstp     = $8ae8;
  17.   Err_Term        = $92e8;
  18.   Cmd_Reg         = $9ae8;
  19.  
  20. { Thanks to Samx on the Orchid BBS for listing these bios mode numbers! }
  21.   m640x480x256   = $201;
  22.   m800x600x16    = $202;
  23.   m800x600x256   = $203;
  24.   m1024x768x16   = $204;
  25.   m1024x768x256  = $205;
  26.   m1280x960x16   = $206;
  27.   m1280x1024x16  = $208;
  28.   m640x480x32K   = $301;
  29.   mText          = $3;
  30.  
  31. var VidMode: word;
  32.  
  33. procedure VideoOff; near; assembler;
  34. asm
  35.   mov  bl,36h
  36.   mov  ax,1201h
  37.   int  10h
  38. end;
  39.  
  40. procedure VideoOn; near; assembler;
  41. asm
  42.   mov  bl,36h
  43.   mov  ax,1200h
  44.   int  10h
  45. end;
  46.  
  47. procedure SetText;
  48. begin
  49.   Portw[$4ae8] := 0;
  50.   Port[$3d4] := $40;
  51.   Port[$3d5] := Port[$3d5] and not 1; { Set VGA }
  52.   Port[$3d4] := $38;
  53.   Port[$3d5] := $0; { lock 1 }
  54.   Port[$3d4] := $39;
  55.   Port[$3d5] := $0; { lock 2 }
  56.   asm
  57.     mov ax, $3
  58.     int $10
  59.   end;
  60.   VidMode := $3;
  61. end;
  62.  
  63.  
  64.  
  65. function SetGraph(Mode: Word): boolean;
  66. begin
  67.   SetGraph := True;  { assume true, prove false }
  68.   VidMode := Mode;
  69.  
  70.   VideoOff;     { turn off video to avoid screen static }
  71.   Port[$3d4] := $38;
  72.   Port[$3d5] := $48; { Enhanced mode unlock 1 }
  73.   Port[$3d4] := $39;
  74.   Port[$3d5] := $a0; { Enhanced mode unlock 2 }
  75.   Port[$3d4] := $40;
  76.   Port[$3d5] := Port[$3d5] or 1; { Enable Enhanced commands & registers }
  77.  
  78.   Port[$3d4] := $36;
  79.   if (Mode = m640x480x32k) and ((Port[$3d5] and 32) <> 0) then {1 meg check }
  80.     begin
  81.       VideoOn;
  82.       SetText;   { to lock the enhanced mode registers }
  83.       SetGraph := False;
  84.       Exit;
  85.     end;
  86.  
  87.   asm
  88.    mov ax, $4f02
  89.    mov bx, Mode
  90.    int $10
  91.   end;
  92.   VideoOn;
  93. end;
  94.  
  95. procedure Wait(W: Word);
  96. begin
  97.   while Portw[$9ae8] and (1 shl w) <> 0 do ;
  98. end;
  99.  
  100. procedure Line(X1, Y1, X2, Y2: Integer; Color: Word);
  101. var
  102.   Min, Max: Integer;
  103.   Reg: Word;
  104.   X, Y: Word;
  105. begin
  106.   X := Abs(X2 - X1);
  107.   Y := Abs(Y2 - Y1);
  108.   if X > Y then
  109.   begin
  110.     Max := X;
  111.     Min := Y;
  112.   end
  113.   else
  114.   begin
  115.     Max := Y;
  116.     Min := X;
  117.   end;
  118.   Wait(3);
  119.   Portw[Frgd_Mix_Reg] := $27;
  120.   Portw[Frgd_Color_Reg] := lo(Color);
  121.   Portw[MultiFunc_Cntl] := $A000;
  122.   Wait(7);
  123.   Portw[Cur_X] := X1;
  124.   Portw[Cur_Y] := Y1;
  125.   Portw[Maj_Axis_Pcnt] := Max;
  126.   Portw[DestX_Diastp] := 2*(Min - Max);
  127.   Portw[DestY_Axstp] := 2 * Min;
  128.   Reg := $2013;
  129.   if X1 < X2 then
  130.   begin
  131.     Portw[Err_Term] := 2 * Min - Max;
  132.     Inc(Reg, 32);
  133.   end
  134.   else
  135.     Portw[Err_Term] := 2 * Min - Max - 1;
  136.   if Y1 < Y2 then Inc(Reg, 128);
  137.   if Y > X then Inc(Reg, 64);
  138.   Portw[Cmd_Reg] := Reg;
  139.   if VidMode = m640x480x32k then  { draw line in second video plane }
  140.   begin
  141.     Wait(1);
  142.     Portw[Frgd_Color_Reg] := hi(Color);
  143.     Wait(7);
  144.     Portw[Cur_X] := X1 + 1024;
  145.     Portw[Cur_Y] := Y1;
  146.     Portw[Maj_Axis_Pcnt] := Max;
  147.     Portw[DestX_Diastp] := 2*(Min - Max);
  148.     Portw[DestY_Axstp] := 2 * Min;
  149.     if X1 < X2 then
  150.       Portw[Err_Term] := 2 * Min - Max
  151.     else
  152.       Portw[Err_Term] := 2 * Min - Max - 1;
  153.     Portw[Cmd_Reg] := Reg;
  154.   end;
  155. end;
  156.  
  157. function SetRGB(Red, Green, Blue: Word): Word;
  158. begin
  159.   SetRGB := (Red and 127) shl 10 + (Green and 127) shl 5 + (Blue and 127);
  160. end;
  161.  
  162. const mag = 3;
  163.       blocksize = 32 * mag;
  164.       xblocks = 640 div blocksize;
  165.       yblocks = 480 div blocksize;
  166.  
  167. var
  168.   I, J, K, L, M, N: Integer;
  169.   Color: Word;
  170.   X, Y: Integer;
  171. begin
  172.    writeln('Orchid Fahrenheit 1280 32000 color test program');
  173.    writeln('by Danny Thorpe and David Wilhelm 11/9/91');
  174.    writeln('written in Turbo Pascal 6.0 - non-BGI');
  175.    writeln;
  176.    writeln('Three screens of color gradient squares will be displayed.');
  177.    writeln('Each square is a 32x32 gradient of 2 colors, for a total of');
  178.    writeln('1024 colors per square.  The third color is graded over the');
  179.    writeln('30 squares that will fit on the 640x480 screen.');
  180.    writeln('Add it up yourself - that''s over 30,000 colors on-screen!');
  181.    writeln;
  182.    writeln('Press any key to display the next screen.');
  183.    readkey;
  184.  
  185.    if not SetGraph(m640x480x32k) then
  186.    begin
  187.      writeln('You don''t appear to have 1Mb of display memory, or your');
  188.      writeln('video card is not an Orchid Fahrenheit 1280.');
  189.    end
  190.    else
  191.    begin
  192.      for N := 1 to 3 do
  193.      begin
  194.        for M := 0 to yblocks-1 do
  195.          for L := 0 to xblocks-1 do
  196.            for I := 0 to 31 do
  197.              for J := 0 to 31 do
  198.                for K := J * mag to J * mag + (mag -1) do
  199.                begin
  200.                  case N of
  201.                    1: Color := SetRGB(L + M * xblocks,I,J);
  202.                    2: Color := SetRGB(I,J,L + M * xblocks);
  203.                    3: Color := SetRGB(I,L + M * xblocks,J);
  204.                  end;
  205.                  X := I * mag + (L * blocksize);
  206.                  Y := K + (M * blocksize);
  207.                  Line(X, Y, X + mag -1, Y, Color);
  208.                end;
  209.        ReadKey;
  210.      end;
  211.      SetText;
  212.    end;
  213. end.
  214.  
  215.