home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / sphinx / vesa.h__ < prev    next >
Text File  |  1994-03-20  |  11KB  |  317 lines

  1. /*
  2.     SPHINX Programming (C) 1994.
  3.     NAME:  VESA.H--
  4.     DESCRIPTION:  This file contains some basic constant and procedure
  5.                   definitions for using VESA standard video modes.  VESA 1.0+
  6.                   video BIOS is required.
  7.     LAST MODIFIED:  20 Mar 1994
  8.     PROCEDURES DEFINED IN THIS FILE:
  9.         byte setVESAvideomode(VESAmode)
  10.       : byte SETVESA_MEMPOS(window_address,window_num)
  11. */
  12.  
  13.  
  14. /* VESA SuperVGA BIOS modes */
  15. enum { VESA_640x400_256=0x100, VESA_640x480_256,    VESA_800x600_16,
  16.        VESA_800x600_256,       VESA_1024x768_16,    VESA_1024x768_256,
  17.        VESA_1280x1024_16,      VESA_1280x1024_256,  VESA_text80x60,
  18.        VESA_text132x25,        VESA_text132x43,     VESA_text132x50,
  19.        VESA_text132x60,        VESA_320x200_32k,    VESA_320x200_64k,
  20.        VESA_320x200_16M,       VESA_640x480_32k,    VESA_640x480_64k,
  21.        VESA_640x480_16M,       VESA_800x600_32k,    VESA_800x600_64k,
  22.        VESA_800x600_16M,       VESA_1024x768_32k,   VESA_1024x768_64k,
  23.        VESA_1024x768_16M,      VESA_1280x1024_32k,  VESA_1280x1024_64k,
  24.        VESA_1280x1024_16M };
  25.  
  26.  
  27. /*** fields below are filled after each successful setVESAvideomode call ***/
  28. word vesa_mode_attr;    // info on selected mode 
  29. byte vesa_win_a_info;   /* window A attributes:
  30.                       bit 0: exists
  31.                 bit 1: readable
  32.                 bit 2: writable
  33.                 bits 3-7 reserved */
  34. byte vesa_win_b_info;   /* window B attributes:
  35.                       bit 0: exists
  36.                 bit 1: readable
  37.                 bit 2: writable
  38.                 bits 3-7 reserved */
  39. word vesa_win_gran;     // window granularity in KB
  40. word vesa_win_size;     // window size in KB
  41. word vesa_win_a_seg;    // start segment location of window A
  42. word vesa_win_b_seg;    // start segment location of window B
  43. dword vesa_pos_func;    /* FAR pointer to window position function
  44.                                 (equivalent to AX=4F05h, INT 0x10) */
  45. word vesa_bytes_scan;   // number of bytes per scan line
  46. /*** fields above are filled after each successful setVESAvideomode call ***/
  47.  
  48.  
  49. byte setVESAvideomode (word VESAmode) 
  50. /* set bit 15 in VESAmode to prevent clearing of video memory */
  51. /*
  52.    Returns 0 on success or non-0 on error.
  53. */
  54. byte vesabuf[256];
  55. {
  56. BX = VESAmode;
  57. AX = 0x4F02;
  58. $ INT 0x10      // set vesa video mode
  59. IF( AX != 0x004F )
  60.     return(1);  // error return
  61.  
  62. ES = SS;
  63. DI = #vesabuf;
  64. CX = VESAmode;
  65. AX = 0x4F01;
  66. $ INT 0x10      // get vesa video mode information
  67. IF( AX != 0x004F )
  68.     return(2);  // error return
  69.  
  70. vesa_mode_attr = SSWORD[#vesabuf[0]];
  71. vesa_win_a_info = vesabuf[2];
  72. vesa_win_b_info = vesabuf[3];
  73. vesa_win_gran = SSWORD[#vesabuf[4]];
  74. vesa_win_size = SSWORD[#vesabuf[6]];
  75. vesa_win_a_seg = SSWORD[#vesabuf[8]];
  76. vesa_win_b_seg = SSWORD[#vesabuf[0xA]];
  77. vesa_pos_func = SSDWORD[#vesabuf[0xC]];
  78. vesa_bytes_scan = SSWORD[#vesabuf[0x10]];
  79.  
  80. IF( vesa_mode_attr & 1 == 0 )  // check if mode supported
  81.     return(3);  // error return
  82.  
  83. IF( vesa_win_a_info & 0b111 != 0b111 )  // check if window A exists R/W
  84.     return(4);  // error return
  85.  
  86. return(0);
  87. }
  88.  
  89.  
  90. : byte SETVESA_MEMPOS ()   /* AX = window address in granularity units
  91.                               BX = window number (0 for A and 1 for B)
  92.                            */
  93. {
  94. DX = AX;
  95. AX = 0x4F05;
  96. // BH = 0;   <<<  BH is already zero so this line is not needed
  97.  
  98. $INT 0x10
  99. // $ CALL FAR vesa_pos_func
  100.  
  101. IF( AX == 0x004F )
  102.     AL = 0;
  103. ELSE AL = 1;
  104.  
  105.  
  106. /* end of VESA.H-- */
  107.  
  108. /*
  109.  
  110. BELOW is some information that might be used to enhance this file in the
  111. future.
  112.  
  113. --------V-104F00-----------------------------
  114. INT 10 - VESA SuperVGA BIOS - GET SuperVGA INFORMATION
  115.     AX = 4F00h
  116.     ES:DI -> 256-byte buffer for SuperVGA information (see below)
  117. Return: AL = 4Fh function supported
  118.     AH = status
  119.         00h successful
  120.         ES:DI buffer filled
  121.         01h failed
  122. Desc:    determine whether VESA BIOS extensions are present and the capabilities
  123.       supported by the display adapter
  124. SeeAlso: AX=4F01h,AX=7F00h
  125. Index:    installation check;VESA
  126.  
  127. Format of SuperVGA information:
  128. Offset    Size    Description
  129.  00h  4 BYTEs    signature ('VESA')
  130.  04h    WORD    VESA version number
  131.  06h    DWORD    pointer to OEM name
  132.         "761295520" for ATI
  133.  0Ah  4 BYTEs    capabilities
  134.  0Eh    DWORD    pointer to list of supported VESA and OEM video modes
  135.         (list of words terminated with FFFFh)
  136.  12h    WORD    total amount of video memory in 64K blocks
  137.  14h 236 BYTEs    reserved
  138. Notes:    the list of supported video modes is stored in the reserved portion of
  139.       the SuperVGA information record by some implementations, and it may
  140.       thus be necessary to either copy the mode list or use a different
  141.       buffer for all subsequent VESA calls
  142.     the 1.1 VESA document specifies 242 reserved bytes at the end, so the
  143.       buffer should be 262 bytes to ensure that it is not overrun
  144. --------V-104F01-----------------------------
  145. INT 10 - VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION
  146.     AX = 4F01h
  147.     CX = SuperVGA video mode
  148.     ES:DI -> 256-byte buffer for mode information (see below)
  149. Return: AL = 4Fh function supported
  150.     AH = status
  151.         00h successful
  152.         ES:DI buffer filled
  153.         01h failed
  154. Desc:    determine the attributes of the specified video mode
  155. SeeAlso: AX=4F00h,AX=4F02h
  156.  
  157. Format of mode information:
  158. Offset    Size    Description
  159.  00h    WORD    mode attributes
  160.         bit 0: mode supported
  161.         bit 1: optional information available
  162.         bit 2: BIOS output supported
  163.         bit 3: set if color, clear if monochrome
  164.         bit 4: set if graphics mode, clear if text mode
  165.  02h    BYTE    window A attributes
  166.         bit 0: exists
  167.         bit 1: readable
  168.         bit 2: writable
  169.         bits 3-7 reserved
  170.  03h    BYTE    window B attributes (as for window A)
  171.  04h    WORD    window granularity in KB
  172.  06h    WORD    window size in KB
  173.  08h    WORD    start segment of window A
  174.  0Ah    WORD    start segment of window B
  175.  0Ch    DWORD    -> FAR window positioning function (equivalent to AX=4F05h)
  176.  10h    WORD    bytes per scan line
  177. ---remainder is optional for VESA modes in v1.0/1.1, needed for OEM modes---
  178.  12h    WORD    width in pixels (graphics) or characters (text)
  179.  14h    WORD    height in pixels (graphics) or characters (text)
  180.  16h    BYTE    width of character cell in pixels
  181.  17h    BYTE    height of character cell in pixels
  182.  18h    BYTE    number of memory planes
  183.  19h    BYTE    number of bits per pixel
  184.  1Ah    BYTE    number of banks
  185.  1Bh    BYTE    memory model type (see below)
  186.  1Ch    BYTE    size of bank in KB
  187.  1Dh    BYTE    number of image pages
  188.  1Eh    BYTE    reserved (0)
  189. ---VBE v1.2+---
  190.  1Fh    BYTE    red mask size
  191.  20h    BYTE    red field position
  192.  21h    BYTE    green mask size
  193.  22h    BYTE    green field size
  194.  23h    BYTE    blue mask size
  195.  24h    BYTE    blue field size
  196.  25h    BYTE    reserved mask size
  197.  26h    BYTE    reserved mask position
  198.  27h    BYTE    direct color mode info
  199.  28h 216 BYTEs    reserved (0)
  200.  
  201. Values for memory model type:
  202.  00h    text
  203.  01h    CGA graphics
  204.  02h    HGC graphics
  205.  03h    16-color (EGA) graphics
  206.  04h    packed pixel graphics
  207.  05h    "sequ 256" (non-chain 4) graphics
  208.  06h    direct color (HiColor, 24-bit color)
  209.  07h    YUV (luminance-chrominance, also called YIQ)
  210.  08h-0Fh reserved for VESA
  211.  10h-FFh OEM memory models
  212. --------V-104F02-----------------------------
  213. INT 10 - VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE
  214.     AX = 4F02h
  215.     BX = mode
  216.         bit 15 set means don't clear video memory
  217. Return: AL = 4Fh function supported
  218.     AH = status
  219.         00h successful
  220.         01h failed
  221. SeeAlso: AX=4F01h,AX=4F03h
  222. --------V-104F03-----------------------------
  223. INT 10 - VESA SuperVGA BIOS - GET CURRENT VIDEO MODE
  224.     AX = 4F03h
  225. Return: AL = 4Fh function supported
  226.     AH = status
  227.         00h successful
  228.         01h failed
  229.     BX = video mode (see AX=4F02h)
  230. SeeAlso: AX=4F02h
  231. --------V-104F04-----------------------------
  232. INT 10 - VESA SuperVGA BIOS - SAVE/RESTORE SuperVGA VIDEO STATE
  233.     AX = 4F04h
  234.     DL = subfunction
  235.         00h get state buffer size
  236.         Return: BX = number of 64-byte blocks needed
  237.         01h save video states
  238.         ES:BX -> buffer
  239.         02h restore video states
  240.         ES:BX -> buffer
  241.     CX = flags for states to save/restore
  242.         bit 0: video hardware state
  243.         bit 1: video BIOS data state
  244.         bit 2: video DAC state
  245.         bit 3: SuperVGA state
  246. Return: AL = 4Fh function supported
  247.     AH = status
  248.         00h successful
  249.         01h failed
  250. --------V-104F05-----------------------------
  251. INT 10 - VESA SuperVGA BIOS - CPU VIDEO MEMORY CONTROL
  252.     AX = 4F05h
  253.     BH = subfunction
  254.         00h select video memory window
  255.         DX = window address in video memory (in granularity units)
  256.         01h get video memory window
  257.         Return: DX = window address in video memory (in gran. units)
  258.     BL = window number
  259.         00h window A
  260.         01h window B
  261. Return: AL = 4Fh function supported
  262.     AH = status
  263.         00h successful
  264.         01h failed
  265. SeeAlso: AX=4F01h,AX=4F06h,AX=4F07h,AX=7000h/BX=0004h
  266. --------V-104F06-----------------------------
  267. INT 10 - VESA SuperVGA BIOS v1.1+ - GET/SET LOGICAL SCAN LINE LENGTH
  268.     AX = 4F06h
  269.     BL = function
  270.         00h set scan line length
  271.         CX = desired width in pixels
  272.         01h get scan line length
  273. Return: AL = 4Fh if function supported
  274.     AH = status
  275.         00h successful
  276.         01h failed
  277.     BX = bytes per scan line
  278.     CX = number of pixels per scan line
  279.     DX = maximum number of scan lines
  280. Notes:    if the desired width is not achievable, the next larger width will be
  281.       set
  282.     the scan line may be wider than the visible area of the screen
  283.     this function is valid in text modes, provided that values are
  284.       multiplied by the character cell width/height
  285. SeeAlso: AX=4F01h,AX=4F05h,AX=4F07h
  286. --------V-104F07BH00-------------------------
  287. INT 10 - VESA SuperVGA BIOS v1.1+ - GET/SET DISPLAY START
  288.     AX = 4F07h
  289.     BH = 00h (reserved)
  290.     BL = function
  291.         00h set display start
  292.         CX = leftmost displayed pixel in scan line
  293.         DX = first displayed scan line
  294.         01h get display start
  295.         Return: BH = 00h
  296.             CX = leftmost displayed pixel in scan line
  297.             DX = first displayed scan line
  298. Return: AL = 4Fh if function supported
  299.     AH = status
  300.         00h successful
  301.         01h failed
  302. Note:    this function is valid in text modes, provided that values are
  303.       multiplied by the character cell width/height
  304. SeeAlso: AX=4F01h,AX=4F05h,AX=4F06h
  305. --------V-104F08-----------------------------
  306. INT 10 - VESA SuperVGA BIOS v1.2+ - GET/SET DAC PALETTE CONTROL
  307.     AX = 4F08h
  308.     BL = function
  309.         00h set DAC palette width
  310.         BH = desired number of bits per primary color
  311.         01h get DAC palette width
  312. Return: AL = 4Fh if function supported
  313.     AH = status
  314.     BH = current number of bits per primary (06h = standard VGA)
  315. ---------------------------------------------
  316. */