home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / doom / source / _vgapas.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-02-05  |  4.1 KB  |  169 lines

  1. {----------------------------------------------------------------------------
  2.   Mode13h - DOS 16bit realmode (Turbo Pascal version)
  3.   Copyright (c) 1994,95 by J.E. Hoffmann
  4.   All rights reserved
  5.  ----------------------------------------------------------------------------}
  6. {$A+,B-,D-,E-,F-,G+,I-,L-,N-,O-,P-,Q-,R-,S-,T-,V-,X+,Y-}
  7. unit _VGAPas;
  8.  
  9.  
  10.  
  11. interface
  12.  
  13.  
  14.  
  15. const
  16.   {--General Register----------------------------------------}
  17.   GR_InputStatus1            = $3DA;
  18.  
  19.  
  20.   {--Cathode Ray Tube Controller-----------------------------}
  21.   CC_Index                   = $3D4;
  22.   CC_Data                    = $3D5;
  23.  
  24.   cc_HorizontalTotal         = $00;
  25.   cc_HorizontalDisplayEnd    = $01;
  26.   cc_StartHorizontalBlanking = $02;
  27.   cc_EndHorizontalBlanking   = $03;
  28.   cc_StartHorizontalRetrace  = $04;
  29.   cc_EndHorizontalRetrace    = $05;
  30.   cc_VerticalTotal           = $06;
  31.   cc_Overflow                = $07;
  32.   cc_PresetRowScan           = $08;
  33.   cc_MaximumScanLine         = $09;
  34.   cc_CursorStart             = $0A;
  35.   cc_CursorEnd               = $0B;
  36.   cc_StartAddressHigh        = $0C;
  37.   cc_StartAddressLow         = $0D;
  38.   cc_CursorLocationHigh      = $0E;
  39.   cc_CursorLocationLow       = $0F;
  40.   cc_StartVerticalRetrace    = $10;
  41.   cc_EndVerticalRetrace      = $11;
  42.   cc_VerticalDisplayEnd      = $12;
  43.   cc_Offset                  = $13;
  44.   cc_UnderlineLocation       = $14;
  45.   cc_StartVerticalBlanking   = $15;
  46.   cc_EndVerticalBlanking     = $16;
  47.   cc_ModeControl             = $17;
  48.   cc_LineCompare             = $18;
  49.  
  50.  
  51.   {--Graphics Controller-----------------------------}
  52.   GC_Index                   = $3CE;
  53.   GC_Data                    = $3CF;
  54.  
  55.   gc_SetReset                = $00;
  56.   gc_EnableSetReset          = $01;
  57.   gc_ColorCompare            = $02;
  58.   gc_DataRotate              = $03;
  59.   gc_ReadMapSelect           = $04;
  60.   gc_Mode                    = $05;
  61.   gc_Miscellaneous           = $06;
  62.   gc_ColorDontCare           = $07;
  63.   gc_BitMask                 = $08;
  64.  
  65.  
  66.   {--Sequencer Controller-----------------------------}
  67.   SC_Index                   = $3C4;
  68.   SC_Data                    = $3C5;
  69.  
  70.   sc_Reset                   = $00;
  71.   sc_ClockingMode            = $01;
  72.   sc_MapMask                 = $02;
  73.   sc_CharacterMapSelect      = $03;
  74.   sc_MemoryMode              = $04;
  75.  
  76.  
  77.   {--Attribute Controller-----------------------------}
  78.   AC_Write                   = $3C0;
  79.   AC_Read                    = $3C1;
  80.  
  81.   ac_ModeControl             = $10;
  82.   ac_OverScanColor           = $11;
  83.   ac_ColorPlaneEnable        = $12;
  84.   ac_HorizontalPixPanning    = $13;
  85.   ac_ColorSelect             = $14;
  86.  
  87.  
  88.   {--Digital Analog Converter-------------------------}
  89.   DC_PELAddressReadMode_W    = $3C7;
  90.   DC_PELAddressReadMode_R    = $3C8;
  91.   DC_PELAddressWriteMode     = $3C8;
  92.   DC_PELData                 = $3C9;
  93.   DC_DACState                = $3C7;
  94.   DC_PELMask                 = $3C6;
  95.  
  96.  
  97.   red                        = 0;
  98.   green                      = 1;
  99.   blue                       = 2;
  100.  
  101.   xSize        :Word = 320;
  102.   TexXSize     :Integer = 256;
  103.   TexYSize     :Integer = 256;
  104.   _VirtualVSeg :Word = $A000;
  105.  
  106.  
  107.  
  108. type
  109.   TRGB      = array[red..blue] of Byte;
  110.   TDACBlock = array[0..255] of TRGB;
  111.  
  112.  
  113.  
  114. procedure Init13h;
  115. procedure Done13h;
  116. procedure InitVBuffer;
  117. procedure DoneVBuffer;
  118. procedure IsColorVGA;
  119. procedure WaitVertRetrace;
  120. procedure ClearScreen(Col :Byte);
  121. procedure ShowVBuffer;
  122. procedure SetDACBlock(StartReg :Byte; Count :Integer; var Block);
  123.  
  124.  
  125.  
  126. implementation
  127.  
  128.  
  129.  
  130. procedure Init13h; external;
  131. procedure Done13h; external;
  132. procedure IsColorVGA; external;
  133. procedure WaitVertRetrace; external;
  134. procedure ClearScreen(Col :Byte); external;
  135. procedure ShowVBuffer; external;
  136. procedure SetDACBlock(StartReg :Byte; Count :Integer; var Block); external;
  137. {$L _VGAPAS.OBJ}
  138.  
  139.  
  140.  
  141. procedure InitVBuffer;
  142. var
  143.   P :Pointer;
  144. begin
  145.   Getmem(P,$FFFF);
  146.   asm
  147.     mov ax,[WORD PTR P+2]
  148.     mov [_VirtualVSeg],ax
  149.   end;
  150. end;
  151.  
  152.  
  153.  
  154. procedure DoneVBuffer;
  155. var
  156.   P :Pointer;
  157. begin
  158.   asm
  159.     mov ax,[_VirtualVSeg]
  160.     mov [WORD PTR P+2],ax
  161.     xor ax,ax
  162.     mov [WORD PTR P],ax
  163.   end;
  164.   FreeMem(P,$FFFF);
  165. end;
  166.  
  167.  
  168.  
  169. end.