Path : ~m3139/document/spec/vesa_100.txt
Date : 11/11/1992
Subject : VESA BIOS spec. for ALI-SVGA-M3135
By : Eric Hsu

Preface :
  This VESA BIOS follows the standard #VS891001, released on Oct. 1, 1989 by VESA.
  Supported modes include :
    mode 100h       640*400*256
    mode 101h       640*480*256
    mode 102h(6Ah)  800*600*16
    mode 103h       800*600*256
    mode 104h       1024*768*16
    mode 105h       1024*768*256
  All these extended VGA modes can be setup with VESA BIOS calls(AH=4FH, INT10H),
  but output function support(such as write pixel, write character, scroll, etc.)
  is not provided by the VESA BIOS for these modes. 

VESA VGA BIOS :

Function 00 -- return Super VGA information
               Return the information about the capabilities of the Super VGA.

Call INT 10H
     input : AH = 4FH; Super VGA support
	     AL = 00H; Function #0, return Super VGA information
	     ES:DI = Pointer to a 256 bytes information buffer
     output : AL == 4FH; function is supported
	      AL != 4FH; function is not supported
	      AH == 00H; function call successful
	      AH == 01H; function call failed
	      All other registers are preserved

The information block has the following structure :
  VgaInfoBlock struc
      VESASignature    db     'VESA'; VESA signature
      VESAVersion      dw     0100H;  version number
      OEMStringPtr     dd     ?; long pointer to product information
      Capabilities     db     4 dup(?); reserved
      VideoModePtr     dd     ?; long pointer to supported mode list
  VgaInfoBlock ends

Product information string terminated by NULL character :
  db 'Acer Lab. Incorporated. SVGA-M3135-0001",NULL

Supported mode list terminated by 0FFFFH :
  dw 100H,101H,102H,103H,104H,105H,0FFFFH

Function 01 -- return Super VGA mode information
               Return the information for a specific mode. The capabilities
	       of the desired mode is returned in the user provided 256 byte
	       buffer.

Call INT 10H
     input : AH = 4FH; Super VGA support
	     AL = 01H; Function #1, return Super VGA mode information
	     CX = Super VGA mode number
	     ES:DI = Pointer to a 256 bytes information buffer
     output : AL == 4FH; function is supported
	      AL != 4FH; function is not supported
	      AH == 00H; function call successful
	      AH == 01H; function call failed
	      All other registers are preserved

The information block has the following structure :
  ModeInfoBlock struc
  ; mandatory information
      ModeAttributes       dw     ?; mode attributes
      WinAAttributes       db     ?; window A attribues
      WinBAttributes       db     ?; window B attribues
      WinGranularity       dw     ?; window granularity
      WinSize              dw     ?; window size
      WinASegment          dw     ?; window A start segment
      WinBSegment          dw     ?; window B start segment
      WinFuncPtr           dd     ?; pointer to window function
      BytesPerScanLine     dw     ?; bytes per scan line
  ; optional information is not available
  ModeInfoBlock ends

For all extended modes :
      ModeAttributes       dw     0019H; extended mode information is
				       ; not available
      WinAAttributes       db     05H; window A is writeable, not readable
      WinBAttributes       db     03H; window B is readable, not writeable
      WinGranularity       dw     64; 64K
      WinSize              dw     64; 64K
      WinASegment          dw     0A000H;
      WinBSegment          dw     0A000H;
      WinFuncPtr           dd     ?;
      BytesPerScanLine     dw     ?; bytes per scan line
BytesPerScanLine :
      mode 100H    dw     640
      mode 101H    dw     640
      mode 102H    dw     100
      mode 103H    dw     800
      mode 104H    dw     128
      mode 105H    dw     1024

Function 02 -- set Super VGA mode
               initialize a Super VGA mode

Call INT 10H
     input : AH = 4FH; Super VGA support
	     AL = 02H; Function #2, set Super VGA mode
	     BX = Super VGA mode number(bit 14-0)
		  bit 15 == 0, clear video memory
		  bit 15 == 1, do not clear video memory
     output : AL == 4FH; function is supported
	      AL != 4FH; function is not supported
	      AH == 00H; function call successful
	      AH == 01H; function call failed
	      All other registers are preserved

Function 03 -- return current video mode

Call INT 10H
     input : AH = 4FH; Super VGA support
	     AL = 03H; Function #3, return current video mode
     output : AL == 4FH; function is supported
	      AL != 4FH; function is not supported
	      AH == 00H; function call successful
	      AH == 01H; function call failed
	      BX = Current video mode
	      All other registers are preserved

Function 04.0 -- return save/restore state buffer size

Call INT 10H
     input : AH = 4FH; Super VGA support
	     AL = 04H; Function #4, save/restore Super VGA video state
	     DL = 00H; item #0, return save/restore state buffer size
	     CX = requested states
		  D0 : set if save/restore video hardware state
		  D1 : set if save/restore BIOS data state
		  D2 : set if save/restore video DAC state
		  D3 : set if save/restore Super VGA state
     output : AL == 4FH; function is supported
	      AL != 4FH; function is not supported
	      AH == 00H; function call successful
	      AH == 01H; function call failed
	      BX = Number of 64-byte blocks to hold the state buffer
	      All other registers are preserved

Function 04.1 -- save video state

Call INT 10H
     input : AH = 4FH; Super VGA support
	     AL = 04H; Function #4, save/restore Super VGA video state
	     DL = 01H; item #1, save video state
	     CX = requested states
		  D0 : set if save/restore video hardware state
		  D1 : set if save/restore BIOS data state
		  D2 : set if save/restore video DAC state
		  D3 : set if save/restore Super VGA state
     output : AL == 4FH; function is supported
	      AL != 4FH; function is not supported
	      AH == 00H; function call successful
	      AH == 01H; function call failed
	      All other registers are preserved

Function 04.2 -- restore video state

Call INT 10H
     input : AH = 4FH; Super VGA support
	     AL = 04H; Function #4, save/restore Super VGA video state
	     DL = 02H; item #2, restore video state
	     CX = requested states
		  D0 : set if save/restore video hardware state
		  D1 : set if save/restore BIOS data state
		  D2 : set if save/restore video DAC state
		  D3 : set if save/restore Super VGA state
     output : AL == 4FH; function is supported
	      AL != 4FH; function is not supported
	      AH == 00H; function call successful
	      AH == 01H; function call failed
	      All other registers are preserved

The data format used to save video hardware state, BIOS data and DAC state
should be the same as IBM VGA BIOS. Super VGA states include :
  1. Extend 3CE(09H~12H)
  2. Extend 3D4(81H)
       procedure : Out 3D4(FFH), 1(unlock)
		   In/Out 3D4(81H)
		   Out 3D4(FFH), 0(lock)
  3. Extend RAMDAC
       procedure : 
                   save : IN 3C6
		          IN 3C6
		          IN 3C6
		          IN 3C6
			  IN 3C6, result XX
			  save result XX
                restore : IN 3C6
		          IN 3C6
		          IN 3C6
		          IN 3C6
			  OUT 3C6, XX
			  save result XX

Function 05.0 -- CPU video memory window control

Call INT 10H
     input : AH = 4FH; Super VGA support
	     AL = 05H; Function #5, video memory window control
	     BH = 00H; item #0, select video memory window
	     BL = window number
		  0 : window A
		  1 : window B
             DX = Window position in video memory(in window granularity units)
     output : AL == 4FH; function is supported
	      AL != 4FH; function is not supported
	      AH == 00H; function call successful
	      AH == 01H; function call failed
	      All other registers are preserved

Function 05.1 -- CPU video memory window control

Call INT 10H
     input : AH = 4FH; Super VGA support
	     AL = 05H; Function #5, video memory window control
	     BH = 01H; item #1, return video memory window
	     BL = window number
		  0 : window A
		  1 : window B
     output : AL == 4FH; function is supported
	      AL != 4FH; function is not supported
	      AH == 00H; function call successful
	      AH == 01H; function call failed
              DX == Window position in video memory(in window granularity units)
	      All other registers are preserved


Video memory control is the same as M3135 read/write segment control. Basically,
M3135 is a dual window system. One window for write and the other one for read.
Acording to the parameters set in VESA BIOS function 01H, 
  window A is used for write segment(3CE, 10H)
  window B is used for read segment(3CE,11H)
