home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / graphic / modexlib.pas < prev    next >
Pascal/Delphi Source File  |  1995-07-28  |  4KB  |  110 lines

  1. unit modexlib;                  {Header for modexlib.asm}
  2. Interface
  3. Var
  4.   Vscreen:Pointer;              {pointer to source area for p13_2_modex}
  5.   vpage:Word;                   {Offset of current invisible page}
  6.   palette:Array[0..256*3-1] of Byte; {VGA - Palette}
  7.  
  8.   Procedure Init_ModeX;         {enable ModeX}
  9.   Procedure Enter400;           {switch from Mode X to 400 lines}
  10.   Procedure Double;             {virtual horiz. resolution of 640 on}
  11.  
  12.   Procedure P13_2_ModeX(start,pic_size:word);  {picture copied to Mode X screen}
  13.   Procedure CopyScreen(Destination,Source:Word);  {Source page copied to destination page}
  14.   Procedure Copy_Block(Destination,Source,Width,Height:Word);
  15.                                 {copies Block from source offset to destination}
  16.   Procedure ClrX(pmask:byte);   {clear Mode X screen}
  17.  
  18.   Procedure Split(Row:Byte);    {Screen-Splitting in line row}
  19.   Procedure Squeeze;            {squeeze picture from above and below}
  20.   Procedure SetStart(t:Word);   {set start address of visible picture}
  21.   Procedure Switch;             {switch back and forth between page 0 and 1}
  22.  
  23.   Procedure WaitRetrace;        {waits for vertical retrace}
  24.   Procedure SetPal;             {copies palette to VGA-DAC}
  25.   Procedure GetPal;             {reads out palette from VGA-DAC}
  26.  
  27.   Procedure Fade_Out;           {fades out picture}
  28.   Procedure Fade_To(Destinationpal:Array of Byte; Step:Byte);
  29.                                 {fades from palette to Destinationpal}
  30.   Procedure Pal_Rot(Start,Destination:Word);
  31.                                 {Rotates palette part by 1,
  32.                                  if Start>Destination up, otherwise down}
  33.  
  34.  
  35. {internal procedures:}
  36.   Procedure Screen_Off;         {switches screen off}
  37.   Procedure Screen_On;          {switches screen back on}
  38.   Procedure CRTC_Unprotect;     {makes access to horizontal timing possible}
  39.   Procedure CRTC_Protect;       {forbids access again}
  40.  
  41.   Procedure Init_Mode13;        {switches Mode 13h on}
  42.   Procedure Show_Pic13;         {copies VScreen to Mode 13h}
  43.  
  44.   Procedure Make_bw(Var WorkPal:Array of Byte); {Palette to black/white}
  45.  
  46. Implementation
  47.   Procedure Init_ModeX;external;
  48.   Procedure Enter400;external;
  49.   Procedure Double;external;
  50.  
  51.   Procedure P13_2_ModeX;external;
  52.   Procedure CopyScreen;external;
  53.   Procedure Copy_Block;external;
  54.   Procedure ClrX;external;
  55.  
  56.   Procedure Split;external;
  57.   Procedure Squeeze;external;
  58.   Procedure SetStart;external;
  59.   Procedure Switch;external;
  60.  
  61.   Procedure WaitRetrace;external;
  62.   Procedure SetPal;external;
  63.   Procedure GetPal;external;
  64.  
  65.   Procedure Fade_Out;external;
  66.   Procedure Fade_To;external;
  67.   Procedure Pal_Rot;external;
  68.   {$l modexlib}
  69.  
  70. Procedure Screen_Off;
  71. Begin
  72.   Port[$3c4]:=1;                {select Register 1 of TS (TS Mode)}
  73.   Port[$3c5]:=Port[$3c5] or 32; {set Bit 5 (Screen Off)}
  74. End;
  75. Procedure Screen_On;
  76. Begin
  77.   Port[$3c4]:=1;                {select Register 1 of TS (TS Mode)}
  78.   Port[$3c5]:=Port[$3c5] and not 32;  {clear Bit 5 (Screen Off)}
  79. End;
  80. Procedure CRTC_UnProtect;
  81. Begin
  82.   Port[$3d4]:=$11;              {Register 11h of CRTC (Vertical Sync End)}
  83.   Port[$3d5]:=Port[$3d5] and not $80  {clear Bit 7 (Protection Bit)}
  84. End;
  85. Procedure CRTC_Protect;
  86. Begin
  87.   Port[$3d4]:=$11;              {Register 11h of CRTC (Vertical Sync End)}
  88.   Port[$3d5]:=Port[$3d5] or $80 {set Bit 7 (Protection Bit)}
  89. End;
  90. Procedure Init_Mode13;assembler;
  91. asm
  92.   mov ax,13h
  93.   int 10h
  94. End;
  95. Procedure Show_Pic13;           {copies VScreen to Mode 13h}
  96. Begin
  97.   Move(Vscreen^,Ptr($a000,0)^,64000);
  98. End;
  99. Procedure Make_bw;              {reduce palette to black/white}
  100. Var i,sum:Word;                 {valuation: 30% red, 59% green, 11% blue}
  101. Begin
  102.   For i:=0 to 255 do Begin
  103.     Sum:=Round(WorkPal[i*3]*0.3 + WorkPal[i*3+1]*0.59 + WorkPal[i*3+2]*0.11);
  104.     FillChar(WorkPal[i*3],3,Sum); {enter values}
  105.   End;
  106. End;
  107.  
  108. Begin
  109. End.
  110.