
; ## Modes

  ; graphic modes
  VBE_MODE_640x400x256	 = 100h
  VBE_MODE_640x480x256	 = 101h
  VBE_MODE_800x600x16	 = 102h ;!
  VBE_MODE_800x600x256	 = 103h
  VBE_MODE_1024x768x16	 = 104h
  VBE_MODE_1024x768x256  = 105h
  VBE_MODE_1280x1024x16  = 106h
  VBE_MODE_1280x1024x256 = 107h
  ; text modes
  VBE_MODE_80x60	 = 108h
  VBE_MODE_132x25	 = 109h
  VBE_MODE_132x43	 = 10Ah
  VBE_MODE_132x50	 = 10Bh
  VBE_MODE_132x60	 = 10Ch
  ; graphic modes
  VBE_MODE_320x200x32k	 = 10Dh
  VBE_MODE_320x200x64k	 = 10Eh
  VBE_MODE_320x200x16M	 = 10Fh
  VBE_MODE_640x480x32k	 = 110h
  VBE_MODE_640x480x64k	 = 111h
  VBE_MODE_640x480x16M	 = 112h
  VBE_MODE_800x600x32k	 = 113h
  VBE_MODE_800x600x64k	 = 114h
  VBE_MODE_800x600x16M	 = 115h
  VBE_MODE_1024x768x32k  = 116h
  VBE_MODE_1024x768x64k  = 117h
  VBE_MODE_1024x768x16M  = 118h
  VBE_MODE_1280x1024x32k = 119h
  VBE_MODE_1280x1024x64k = 11Ah
  VBE_MODE_1280x1024x16M = 11Bh

; Functions

  VBE_GET_CONTROL_INFO	 = 00h
  VBE_GET_MODE_INFO	 = 01h
  VBE_SET_MODE		 = 02h
  VBE_GET_CURRENT_MODE	 = 03h
  VBE_SAVE_STATE	 = 04h
  VBE_DISPLAY_WINDOW	 = 05h
  VBE_GET_SCANLINE_LEN	 = 06h
  VBE_GET_DISPLAY_START  = 07h
  VBE_GET_PALLETE_FORMAT = 08h
  VBE_GET_PALLETE_DATA	 = 09h
  VBE_GET_PM_INTERFACE	 = 0Ah
  VBE_GET_PIXEL_CLOCK	 = 0Bh
  VBE_RESTORE_STATE	 = VBE_SAVE_STATE
  VBE_SET_SCANLINE_LEN	 = VBE_GET_SCANLINE_LEN
  VBE_SET_DISPLAY_START  = VBE_GET_DISPLAY_START
  VBE_SET_PALLETE_FORMAT = VBE_GET_PALLETE_FORMAT
  VBE_SET_PALLETE_DATA	 = VBE_GET_PALLETE_DATA
  VBE_SET_PIXEL_CLOCK	 = VBE_GET_PIXEL_CLOCK

  VBE_SUCESSFUL    = 004Fh
  VBE_FAIL	   = 014Fh
  VBE_NOTSUPPORTED = 024Fh
  VBE_SUPPORTED    = 034Fh


; ## Functions

  VBE_GET_CONTROLLER_INFO = 4F00h
  VBE_GET_MODES_INFO	  = 4F01h


; ## Structs


VbeInfoBlock:
  .VbeSignature      db 'VBE2'	    ; VBE Signature
  .VbeVersion	     dw 0300h	    ; VBE Version
  .OemStringPtr      dd ?	    ; VbeFarPtr to OEM String
  .Capabilities      db 4 dup (?)   ; Capabilities of graphics controller
  .VideoModePtr      dd ?	    ; VbeFarPtr to VideoModeList
  .TotalMemory	     dw ?	    ; Number of 64kb memory blocks
  ; Added for VBE 2.0+
  .OemSoftwareRev    dw ?	    ; VBE implementation Software revision
  .OemVendorNamePtr  dd ?	    ; VbeFarPtr to Vendor Name String
  .OemProductNamePtr dd ?	    ; VbeFarPtr to Product Name String
  .OemProductRevPtr  dd ?	    ; VbeFarPtr to Product Revision String
		     db 222 dup (?) ; Reserved for VBE implementation scratch
  ; area
  .OemData	     db 256 dup (?) ; Data Area for OEM Strings

VbeModeInfoBlock:
  ; Mandatory information for all VBE revisions
  .ModeAttributes	 dw ? ; mode attributes
  .WinAAttributes	 db ? ; window A attributes
  .WinBAttributes	 db ? ; window B attributes
  .WinGranularity	 dw ? ; window granularity
  .WinSize		 dw ? ; window size
  .WinASegment		 dw ? ; window A start segment
  .WinBSegment		 dw ? ; window B start segment
  .WinFuncPtr		 dd ? ; real mode pointer to window function
  .BytesPerScanLine	 dw ? ; bytes per scan line
  ; Mandatory information for VBE 1.2 and above
  .XResolution		 dw ? ; horizontal resolution in pixels or characters
  .YResolution		 dw ? ; vertical resolution in pixels or characters
  .XCharSize		 db ? ; character cell width in pixels
  .YCharSize		 db ? ; character cell height in pixels
  .NumberOfPlanes	 db ? ; number of memory planes
  .BitsPerPixel 	 db ? ; bits per pixel
  .NumberOfBanks	 db ? ; number of banks
  .MemoryModel		 db ? ; memory model type
  .BankSize		 db ? ; bank size in KB
  .NumberOfImagePages	 db ? ; number of images
			 db 1 ; reserved for page function
  ; Direct Color fields (required for direct/6 and YUV/7 memory models)
  .RedMaskSize		 db ? ; size of direct color red mask in bits
  .RedFieldPosition	 db ? ; bit position of lsb of red mask
  .GreenMaskSize	 db ? ; size of direct color green mask in bits
  .GreenFieldPosition	 db ? ; bit position of lsb of green mask
  .BlueMaskSize 	 db ? ; size of direct color blue mask in bits
  .BlueFieldPosition	 db ? ; bit position of lsb of blue mask
  .RsvdMaskSize 	 db ? ; size of direct color reserved mask in bits
  .RsvdFieldPosition	 db ? ; bit position of lsb of reserved mask
  .DirectColorModeInfo	 db ? ; direct color mode attributes
  ; Mandatory information for VBE 2.0 and above
  .PhysBasePtr		 dd ? ; physical address for flat memory frame buffer
			 dd 0 ; Reserved - always set to 0
			 dw 0 ; Reserved - always set to 0
  ; Mandatory information for VBE 3.0 and above
  .LinBytesPerScanLine	 dw ? ; bytes per scan line for linear modes
  .BnkNumberOfImagePages db ? ; number of images for banked modes
  .LinNumberOfImagePages db ? ; number of images for linear modes
  .LinRedMaskSize	 db ? ; size of direct color red mask (linear modes)
  .LinRedFieldPosition	 db ? ; bit position of lsb of red mask (linear modes)
  .LinGreenMaskSize	 db ? ; size of direct color green mask  (linear modes)
  .LinGreenFieldPosition db ? ; bit position of lsb of green mask (linear modes)
  .LinBlueMaskSize	 db ? ; size of direct color blue mask  (linear modes)
  .LinBlueFieldPosition  db ? ; bit position of lsb of blue mask (linear modes)
  .LinRsvdMaskSize	 db ? ; size of direct color reserved mask (linear modes)
  .LinRsvdFieldPosition  db ? ; bit position of lsb of reserved mask (linear modes)
  .MaxPixelClock	 dd ? ; maximum pixel clock (in Hz) for graphics mode
			 db 189 dup (?)  ; reserved: remainder of ModeInfoBlock

VbePMInfoBlock:
  .Signature	 db 'PMID' ; PM Info Block Signature
  .EntryPoint	 dw ?	   ; Offset of PM entry point within BIOS
  .PMInitialize  dw ?	   ; Offset of PM initialization entry point
  .BIOSDataSel	 dw 0	   ; Selector to BIOS data area emulation block
  .A0000Sel	 dw 0A000h ; Selector to access A0000h physical mem
  .B0000Sel	 dw 0B000h ; Selector to access B0000h physical mem
  .B8000Sel	 dw 0B800h ; Selector to access B8000h physical mem
  .CodeSegSel	 dw 0C000h ; Selector to access code segment as data
  .InProtectMode db 0	   ; Set to 1 when in protected mode
  .Checksum	 db ?	   ; Checksum byte for structure

VbeCRTCInfoBlock:
  .HorizontalTotal     dw ? ; Horizontal total in pixels
  .HorizontalSyncStart dw ? ; Horizontal sync start in pixels
  .HorizontalSyncEnd   dw ? ; Horizontal sync end in pixels
  .VerticalTotal       dw ? ; Vertical total in lines
  .VerticalSyncStart   dw ? ; Vertical sync start in lines
  .VerticalSyncEnd     dw ? ; Vertical sync end in lines
  .Flags	       db ? ; Flags (Interlaced, Double Scan etc)
  .PixelClock	       dd ? ; Pixel clock in units of Hz
  .RefreshRate	       dw ? ; Refresh rate in units of 0.01 Hz
		       db 40 dup (?)  ; reserved - remainder of ModeInfoBlock

VbePaletteEntry:
  .Blue      db ? ; Blue channel value (6 or 8 bits)
  .Green     db ? ; Green channel value (6 or 8 bits)
  .Red	     db ? ; Red channel value(6 or 8 bits)
  .Alignment db ? ; DWORD alignment byte (unused)
