Here's what you need do first, LFB is only good for Pmode, i think it should be OK for unreal-mode, but not for realmode.
First in realmode you call a int 10h function to test for vesa and modes etc.
Then you call another int 10h function to fill a list of info, in this list is the address of lfb, by writing to this address you can code for vesa just like mode 13h
.
Simple demo, of vesa 640x480x32bpp, fade screen (note: it goes to pmode).
Code: Select all
;************************************
; By Dex
;
; Assemble with fasm
; c:\fasm vesa.asm vesa.bin
;
;************************************
org 0x7C00
use16
;****************************
; Realmode startup code.
;****************************
start:
xor ax,ax
mov ds,ax
mov es,ax
mov ss,ax
mov sp,0x7C00
;****************************
; Fill Vesa info list.
;****************************
mov bx,4112h ;640x480x32bpp screen mod
mov ax,4f01h
mov di,Mode_Info ;info block
mov cx,bx
int 10h
;*****************************
; Switch to vesa mode.
;*****************************
mov ax,4f02h
int 10h
;*****************************
; Setting up, to enter pmode.
;*****************************
cli
lgdt [gdtr]
mov eax, cr0
or al,0x1
mov cr0,eax
jmp 0x10: protected
;*****************************
; Pmode. ;-)
;*****************************
use32
protected:
mov ax,0x8
mov ds,ax
mov es,ax
mov ss,ax
mov esp,0x7C00
;*****************************
; Turn floppy off (if space).
;*****************************
mov dx,3F2h
mov al,0
out dx,al
;*****************************
; fade background screen.
;*****************************
fade_screen:
mov edx,[ModeInfo_PhysBasePtr]
mov edi,edx
xor eax,eax
mov al,0xc5
xor ebx,ebx
mov bl,195
DoLoop:
mov cx,640*2
dec eax
rep stosd
dec ebx
jnz DoLoop
;*****************************
; Just loop.
;*****************************
jmp $
;*************************************
; GDT.
;*************************************
gdt: dw 0x0000, 0x0000, 0x0000, 0x0000
sys_data: dw 0xFFFF, 0x0000, 0x9200, 0x00CF
sys_code: dw 0xFFFF, 0x0000, 0x9800, 0x00CF
gdt_end:
gdtr: dw gdt_end - gdt - 1
dd gdt
;*************************************
; Make program 510 byte's + 0xaa55
;*************************************
times 510- ($-start) db 0
dw 0xaa55
;*************************************
; Put uninitialized data here.
;*************************************
include 'vesa.inc'
vesa.inc
Code: Select all
;=========================================================;
; Vesa Information Block 11/12/03 ;
;---------------------------------------------------------;
; DOS EXTREME OS V0.01 ;
; by Craig Bamford(Dex). ;
; ;
;=========================================================;
Mode_Info:
ModeInfo_ModeAttributes rw 1
ModeInfo_WinAAttributes rb 1
ModeInfo_WinBAttributes rb 1
ModeInfo_WinGranularity rw 1
ModeInfo_WinSize rw 1
ModeInfo_WinASegment rw 1
ModeInfo_WinBSegment rw 1
ModeInfo_WinFuncPtr rd 1
ModeInfo_BytesPerScanLine rw 1
ModeInfo_XResolution rw 1
ModeInfo_YResolution rw 1
ModeInfo_XCharSize rb 1
ModeInfo_YCharSize rb 1
ModeInfo_NumberOfPlanes rb 1
ModeInfo_BitsPerPixel rb 1
ModeInfo_NumberOfBanks rb 1
ModeInfo_MemoryModel rb 1
ModeInfo_BankSize rb 1
ModeInfo_NumberOfImagePages rb 1
ModeInfo_Reserved_page rb 1
ModeInfo_RedMaskSize rb 1
ModeInfo_RedMaskPos rb 1
ModeInfo_GreenMaskSize rb 1
ModeInfo_GreenMaskPos rb 1
ModeInfo_BlueMaskSize rb 1
ModeInfo_BlueMaskPos rb 1
ModeInfo_ReservedMaskSize rb 1
ModeInfo_ReservedMaskPos rb 1
ModeInfo_DirectColorModeInfo rb 1
; VBE 2.0 extensions
ModeInfo_PhysBasePtr rd 1
ModeInfo_OffScreenMemOffset rd 1
ModeInfo_OffScreenMemSize rw 1
You need to assemble with fasm to bin file and use rawrite to put it on floppy to test.
Note: some vesas use 24bpp and it does not check for that in this code, but you will need to (eg: if you get black lines, it users 24bpp) also the vesa info list is a shottened ver.
ps: you will in most case to use full screen need to enable A20.