home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_PAS / XLIB_TP5.ZIP / UNITS / X_CONST.PAS < prev    next >
Pascal/Delphi Source File  |  1994-01-22  |  7KB  |  182 lines

  1. unit X_const;
  2.  
  3. (*
  4.     Global equates and variables
  5.  
  6.  
  7.     ****** XLIB - Mode X graphics library                ****************
  8.     ******                                               ****************
  9.     ****** Written By Themie Gouthas ( C-Version )       ****************
  10.     ****** Converted By Christian Harms in TP            ****************
  11.  
  12.     Gouthas : egg@dstos3.dsto.gov.au or teg@bart.dsto.gov.au
  13.     Harms   : harms@minnie.informatik.uni-stuttgart.de
  14.  
  15.     Terminology & notes:
  16.            VRAM ==   Video RAM
  17.            SRAM ==   System RAM
  18.            X coordinates are in pixels unless explicitly stated
  19. *)
  20.  
  21. interface
  22.  
  23. const AC_INDEX        = $03c0;  (* Attribute controller index register    *)
  24.       MISC_OUTPUT     = $03c2;  (* Miscellaneous Output register          *)
  25.       SC_INDEX        = $03c4;  (* Sqence Controller Index                *)
  26.       GC_INDEX        = $03ce;  (*  Graphics controller Index             *)
  27.       CRTC_INDEX      = $03d4;  (* CRT Controller Index                   *)
  28.       DAC_READ_INDEX  = $03c7;
  29.       DAC_WRITE_INDEX = $03c8;
  30.       DAC_DATA          = $03c9;
  31.       INPUT_STATUS_0  = $03da;  (* Input status 0 register                *)
  32.  
  33.  
  34.       SCREEN_SEG    =   $A000;  (* segment of display memory in mode X    *)
  35.  
  36.       MAP_MASK      =   $02;    (* index in SC of Map Mask register       *)
  37.       READ_MAP      =   $04;    (* index in GC of the Read Map register   *)
  38.       BIT_MASK      =   $08;    (* index in GC of Bit Mask register       *)
  39.  
  40.       OVERFLOW      =   $07;    (*  CRTC overflow register index          *)
  41.       MAX_SCAN_LINE =   $09;    (*  CRTC maximum scan line register index *)
  42.       ADDR_HIGH     =   $0c;    (* Index of Start Address High reg in CRTC*)
  43.       ADDR_LOW      =   $0d;    (*                        Low             *)
  44.       CRTC_OFFSET   =   $13;    (*  CRTC offset register index            *)
  45.       UNDERLINE     =   $14;    (*  CRTC underline location register index*)
  46.       MODE_CONTROL  =   $17;    (*  CRTC mode control register index      *)
  47.       LINE_COMPARE  =   $18;    (*  CRTC line compare reg. index (bits 0-7
  48.                         of split screen scan line             *)
  49.  
  50.       AC_MODE_CONTROL = $10;    (*  Index of Mode COntrol register in AC  *)
  51.       PEL_PANNING     = $13;    (*  Pel panning register index in AC      *)
  52.  
  53.       PATTERN_BUFFER  = $0fffc; (* offset in screen memory of pattern buffer *)
  54.  
  55.       OK              = 0;
  56.       ERROR           = 1;
  57.       GetMaxColor     = 255;
  58.  
  59.       X_MODE_320x200  =  0;
  60.       X_MODE_320x240  =  1;
  61.       X_MODE_360x200  =  2;
  62.       X_MODE_360x240  =  3;
  63.       X_MODE_376x282  =  4;
  64.       X_MODE_320x400  =  5;
  65.       X_MODE_320x480  =  6;
  66.       X_MODE_360x400  =  7;
  67.       X_MODE_360x480  =  8;
  68.       X_MODE_360x360  =  9;
  69.       X_MODE_376x308  = 10;
  70.       X_MODE_376x564  = 11;
  71.       X_MODE_256x200  = 12;
  72.       X_MODE_256x240  = 13;
  73.  
  74.  
  75.       X_BACKWARD      = 0;
  76.       X_FORWARD       = 1;
  77.  
  78.       X_MODE_INVALID  = -1;
  79.  
  80.  
  81. type  Palette = Array[0..255,0..2] of Byte;
  82.  
  83. (* ---------------------------------------------------------------------- *)
  84. (* Global variables - XMAIN exports                                       *)
  85.  
  86. var InGraphics             :Boolean;(* non zero if in X graphics mode      *)
  87.     CurrXMode              :word;  (* contains current X graphics mode id *)
  88.     ScrnPhysicalByteWidth  :word;  (* Physical screen width in bytes      *)
  89.     ScrnPhysicalPixelWidth :word;  (* Physical screen width in pixels     *)
  90.     ScrnPhysicalHeight     :word;  (* Physical screen height in pixels    *)
  91.     ErrorValue             :byte;  (* Error return value                  *)
  92.     GetMaxX                :Word absolute ScrnPhysicalPixelWidth;
  93.     GetMaxY                :Word absolute ScrnPhysicalHeight;
  94.  
  95.     SplitScrnOffs          :word;  (* Offset in VRAM  of split screen     *)
  96.     SplitScrnScanLine      :word;  (* Scan line split screen starts at    *)
  97.                    (* initially. Resizing the split scrn  *)
  98.                    (* using the other functions does not  *)
  99.                    (* change this value                   *)
  100.     SplitScrnVisibleHeight :word;  (* Height of the visible portion of the*)
  101.                    (* split screen.                       *)
  102.     SplitScrnActive        :Boolean;
  103.     Page0_Offs             :word;  (* Offset in VRAM of main virt. screen *)
  104.     Page1_Offs             :word;  (* Offset in VRAM of 2nd virt. screen  *)
  105.     Page2_Offs             :Word;
  106.     ScrnLogicalByteWidth   :word;  (* Virtual screen width in bytes       *)
  107.     ScrnLogicalPixelWidth  :word;  (* Virtual screen width in pixels      *)
  108.     ScrnLogicalHeight      :word;  (* Virtual screen height in pixels     *)
  109.  
  110.     MaxScrollX             :word;  (* Max X position of physical screen   *)
  111.                                    (*  within virtual screen              *)
  112.     MaxScrollY             :word;  (* Max Y position of physical screen   *)
  113.                                    (*  within virtual screen              *)
  114.     DoubleBufferActive     :word;  (* Indicates whether double buffering  *)
  115.                                    (* is active                           *)
  116.     VisiblePageIdx         :word;  (* Index number of visible page 0 or 1 *)
  117.     VisiblePageOffs        :word;  (* Offset of Hidden Pg | only valid    *)
  118.     ScreenOfs              :word absolute VisiblePageOffs;
  119.     HiddenPageOffs         :word;  (* Offset of Visible Pg| for D.B. mode *)
  120.     NonVisual_Offs         :word;  (* Offset of first non-visible VRAM    *)
  121.     BGSaveOffs             :Word;
  122.  
  123.     TopClip                :word;  (* Clipping rectangle                  *)
  124.     BottomClip             :word;
  125.     LeftClip               :word;
  126.     RightClip              :word;
  127.  
  128.     PhysicalStartPixelX    :word;  (* Coordinates of physical (visible)   *)
  129.     PhysicalStartByteX     :word;  (* screen relative to the virtual      *)
  130.     PhysicalStartY         :word;  (* screen's U.L. corner                *)
  131.  
  132.     Active_StartX          :Word;  (* absolute pos. U.L. corner of active *)
  133.     Active_StartY          :Word;  (* page.                               *)
  134.     Gray0,Gray1,Gray2,Gray3,Gray4,Gray5:Byte;
  135.  
  136. procedure WaitVsyncStart;
  137. procedure WaitVsyncEnd;
  138.  
  139. implementation
  140.  
  141. (* --------------------------------------------------------------------- *)
  142. (* Procedure to wait for the vertical retrace leading edge               *)
  143.  
  144. procedure WaitVsyncStart; assembler;
  145. asm;
  146.     mov     dx,INPUT_STATUS_0
  147. @WaitNotVsync:
  148.     in      al,dx
  149.     test    al,08h
  150.     jnz     @WaitNotVsync
  151. @WaitVsync:
  152.     in      al,dx
  153.     test    al,08h
  154.     jz      @WaitVsync
  155. end;
  156.  
  157. (* --------------------------------------------------------------------  *)
  158. (* Procedure to wait for the vertical retrace trailing edge              *)
  159.  
  160. procedure WaitVsyncEnd;  assembler;
  161. asm;
  162.     mov     dx,INPUT_STATUS_0
  163. @WaitVsync2:
  164.     in      al,dx
  165.     test    al,08h
  166.     jz     @WaitVsync2
  167. @WaitNotVsync2:
  168.     in      al,dx
  169.     test    al,08h
  170.     jnz    @WaitNotVsync2
  171. end;
  172.  
  173. begin;
  174.   InGraphics := False;
  175.   BGSaveOffs := $FFFF;
  176.   Gray0      :=   0;
  177.   Gray1      := 252;
  178.   Gray2      := 253;           (* included from set_RGB_pal in unit X_Lib, *)
  179.   Gray3      := 153;           (* Add_ButtonGray in X_Button ...           *)
  180.   Gray4      := 202;
  181.   Gray5      := 255;
  182. end.