Good-bye VESA !

git-svn-id: svn://kolibrios.org@3163 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2013-01-11 17:03:03 +00:00
parent d1a0247624
commit edb957dfa2
4 changed files with 62 additions and 387 deletions

View File

@ -174,6 +174,7 @@ cpugood:
; --------------- APM --------------------- ; --------------- APM ---------------------
and word [es:0x9044], 0 ; ver = 0.0 (APM not found) and word [es:0x9044], 0 ; ver = 0.0 (APM not found)
if 0
mov ax, 0x5300 mov ax, 0x5300
xor bx, bx xor bx, bx
int 0x15 int 0x15
@ -196,6 +197,7 @@ cpugood:
mov [es:0x9054], dx mov [es:0x9054], dx
apm_end: apm_end:
end if
;CHECK current of code ;CHECK current of code
cmp [cfgmanager.loader_block], -1 cmp [cfgmanager.loader_block], -1
@ -208,9 +210,9 @@ apm_end:
noloaderblock: noloaderblock:
; DISPLAY VESA INFORMATION ; DISPLAY VESA INFORMATION
call print_vesa_info ; call print_vesa_info
call calc_vmodes_table ; call calc_vmodes_table
call check_first_parm ;check and enable cursor_pos ; call check_first_parm ;check and enable cursor_pos
; \begin{diamond}[30.11.2005] ; \begin{diamond}[30.11.2005]
cfgmanager: cfgmanager:
@ -264,7 +266,7 @@ cfgmanager:
; ASK GRAPHICS MODE ; ASK GRAPHICS MODE
call set_vmode ; call set_vmode
; GRAPHICS ACCELERATION ; GRAPHICS ACCELERATION
; force yes ; force yes
@ -293,12 +295,17 @@ cfgmanager:
xor ax, ax xor ax, ax
mov es, ax mov es, ax
mov bx, [es:0x9008] ; vga & 320x200 ; mov bx, [es:0x9008] ; vga & 320x200
mov ax, 0x4f02 ; Vesa mov ax, 0xA000 ; AtomBIOS Fn00
mov cx, 0x550A ; 1024x768, 32bpp, ARGB8888
setgr: setgr:
int 0x10 int 0x10
test ah, ah test ah, ah
jnz $ jnz $
mov ax, 0xA006 ; AtomBIOS Fn06
int 0x10
mov [es:0x9018], ebx ; LFB
gmok2: gmok2:
push ds push ds
pop es pop es

View File

@ -1,325 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$
struc VBE_VGAInfo {
.VESASignature dd ? ; char
.VESAVersion dw ? ; short
.OemStringPtr dd ? ; char *
.Capabilities dd ? ; ulong
.VideoModePtr dd ? ; ulong
.TotalMemory dw ? ; short
; VBE 2.0+
.OemSoftwareRev db ? ; short
.OemVendorNamePtr dw ? ; char *
.OemProductNamePtr dw ? ; char *
.OemProductRevPtr dw ? ; char *
.reserved rb 222 ; char
.OemData rb 256 ; char
}
struc VBE_ModeInfo {
.ModeAttributes dw ? ; short
.WinAAttributes db ? ; char
.WinBAttributes db ? ; char
.WinGranularity dw ? ; short
.WinSize dw ? ; short
.WinASegment dw ? ; ushort
.WinBSegment dw ? ; ushort
.WinFuncPtr dd ? ; void *
.BytesPerScanLine dw ? ; short
.XRes dw ? ; short
.YRes dw ? ; short
.XCharSize db ? ; char
.YCharSize db ? ; char
.NumberOfPlanes db ? ; char
.BitsPerPixel db ? ; char
.NumberOfBanks db ? ; char
.MemoryModel db ? ; char
.BankSize db ? ; char
.NumberOfImagePages db ? ; char
.res1 db ? ; char
.RedMaskSize db ? ; char
.RedFieldPosition db ? ; char
.GreenMaskSize db ? ; char
.GreenFieldPosition db ? ; char
.BlueMaskSize db ? ; char
.BlueFieldPosition db ? ; char
.RsvedMaskSize db ? ; char
.RsvedFieldPosition db ? ; char
.DirectColorModeInfo db ? ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE
; VBE 2.0+
.PhysBasePtr dd ? ; ulong
.OffScreenMemOffset dd ? ; ulong
.OffScreenMemSize dw ? ; short
; VBE 3.0+
.LinbytesPerScanLine dw ? ; short
.BankNumberOfImagePages db ? ; char
.LinNumberOfImagePages db ? ; char
.LinRedMaskSize db ? ; char
.LinRedFieldPosition db ? ; char
.LingreenMaskSize db ? ; char
.LinGreenFieldPosition db ? ; char
.LinBlueMaskSize db ? ; char
.LinBlueFieldPosition db ? ; char
.LinRsvdMaskSize db ? ; char
.LinRsvdFieldPosition db ? ; char
.MaxPixelClock dd ? ; ulong
.res2 rb 190 ; char
}
virtual at $A000
vi VBE_VGAInfo
mi VBE_ModeInfo
modes_table:
end virtual
cursor_pos dw 0 ;temporary cursor storage.
home_cursor dw 0 ;current shows rows a table
end_cursor dw 0 ;end of position current shows rows a table
scroll_start dw 0 ;start position of scroll bar
scroll_end dw 0 ;end position of scroll bar
long_v_table equ 9 ;long of visible video table
size_of_step equ 10
scroll_area_size equ (long_v_table-2)
int2str:
dec bl
jz @f
xor edx,edx
div ecx
push edx
call int2str
pop eax
@@: or al,0x30
mov [ds:di],al
inc di
ret
int2strnz:
cmp eax,ecx
jb @f
xor edx,edx
div ecx
push edx
call int2strnz
pop eax
@@: or al,0x30
mov [es:di],al
inc di
ret
;-------------------------------------------------------
print_vesa_info:
mov [es:vi.VESASignature],'VBE2'
mov ax,0x4F00
mov di,vi ;0xa000
int 0x10
or ah,ah
jz @f
mov [es:vi.VESASignature],'VESA'
mov ax,$4F00
mov di,vi
int 0x10
or ah,ah
jnz $
@@:
cmp [es:vi.VESASignature],'VESA'
jne $
cmp [es:vi.VESAVersion],0x0100
jb $
.vesaok2:
ret
;-----------------------------------------------------------------------------
calc_vmodes_table:
pushad
; push 0
; pop es
lfs si, [es:vi.VideoModePtr]
mov bx,modes_table
.next_mode:
mov cx,word [fs:si] ; mode number
cmp cx,-1
je .modes_ok.2
mov ax,0x4F01
mov di,mi
int 0x10
or ah,ah
jnz .modes_ok.2 ;vesa_info.exit
test [es:mi.ModeAttributes],00000001b ;videomode support ?
jz @f
test [es:mi.ModeAttributes],00010000b ;picture ?
jz @f
test [es:mi.ModeAttributes],10000000b ;LFB ?
jz @f
cmp [es:mi.BitsPerPixel], 32 ;to show only 32 bpp videomodes
jb @f
.l0:
cmp [es:mi.XRes],800 ; only 800x600 and higher
jb @f
mov ax,[es:mi.XRes]
mov [es:bx+0],ax ; +0[2] : resolution X
mov ax,[es:mi.YRes]
mov [es:bx+2],ax ; +2[2] : resolution Y
mov ax,[es:mi.ModeAttributes]
mov [es:bx+4],ax ; +4[2] : attributes
;<< cmp [s_vesa.ver],'2'
;<< jb .lp1
or cx,0x4000 ; use LFB <<< ?
.lp1: mov [es:bx+6],cx ; +6 : mode number
movzx ax,byte [es:mi.BitsPerPixel]
mov word [es:bx+8],ax ; +8 : bits per pixel << ?
add bx,size_of_step ; size of record
@@:
add si,2
jmp .next_mode
.modes_ok.2:
mov word[es:bx],-1 ;end video table
mov word[end_cursor],bx ;save end cursor position
popad
ret
check_first_parm:
mov si,word [preboot_graph]
test si,si
jnz .no_zero ;if no zero
.zerro:
mov word[preboot_graph], ax
mov ax,1024
mov bx,768
mov si,modes_table
call .loops
test ax,ax
jz .ok_found_mode
mov si,modes_table
jmp .ok_found_mode
.no_zero:
mov bp,word [number_vm]
cmp bp,word [es:si+6]
jz .ok_found_mode
mov ax,word [x_save]
mov bx,word [y_save]
mov si,modes_table
call .loops
test ax,ax
jz .ok_found_mode
mov si,modes_table
.ok_found_mode:
mov word [home_cursor],si
mov word [preboot_graph],si
mov ax,si
mov ecx,long_v_table
.loop: add ax,size_of_step
cmp ax,word [end_cursor]
jae .next_step
loop .loop
.next_step:
sub ax,size_of_step*long_v_table
cmp ax,modes_table
jae @f
mov ax,modes_table
@@:
mov word [home_cursor],ax
mov si,[preboot_graph]
mov word [cursor_pos],si
push word [es:si]
pop word [x_save]
push word [es:si+2]
pop word [y_save]
push word [es:si+6]
pop word [number_vm]
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;
.loops:
cmp ax,word [es:si]
jne .next
cmp bx,word [es:si+2]
jne .next
je .ok
.next: add si,size_of_step
cmp word [es:si],-1
je .exit
jmp .loops
.ok: xor ax,ax
ret
.exit: or ax,-1
ret
;-----------------------------------------------------------------------------
set_vmode:
push 0 ;0;x1000
pop es
mov si,word [preboot_graph] ;[preboot_graph]
mov cx,word [es:si+6] ; number of mode
mov ax,word [es:si+0] ; resolution X
mov bx,word [es:si+2] ; resolution Y
mov word [es:0x900A],ax ; resolution X
mov word [es:0x900C],bx ; resolution Y
mov word [es:0x9008],cx ; number of mode
; VESA 2 and Vesa 3 only
mov ax,0x4f01
and cx,0xfff
mov di,mi;0xa000
int 0x10
; LFB
mov eax,[es:mi.PhysBasePtr] ;di+0x28]
mov [es:0x9018],eax
; ---- vbe voodoo
BytesPerLine equ 0x10
mov ax, [es:di+BytesPerLine]
mov [es:0x9001], ax
; BPP
.l0:
mov al, byte [es:di+0x19]
mov [es:0x9000], al
jmp .exit
.exit:
ret
;=============================================================================

View File

@ -154,7 +154,7 @@ nsvf:
db 0, 0, 0, 0, 0, 0 ;106..108 db 0, 0, 0, 0, 0, 0 ;106..108
db 0, 0, 0, 0, 0, 0 ;109..111 db 0, 0, 0, 0, 0, 0 ;109..111
.v9: 112 .v9:
db 00100100b, 00100100b, 00b ;112: XXX db 00100100b, 00100100b, 00b ;112: XXX
db 0, 0, 0 ;113: XXXX db 0, 0, 0 ;113: XXXX
db 0, 0, 0 ;114: XXX db 0, 0, 0 ;114: XXX

View File

@ -335,27 +335,27 @@ high_code:
; ----------------------------------------- ; -----------------------------------------
mov al, [BOOT_VAR+0x901F] ; DMA access mov al, [BOOT_VAR+0x901F] ; DMA access
mov [allow_dma_access], al mov [allow_dma_access], al
mov eax, 32 ; bpp mov eax, 32 ; << bpp
mov [ScreenBPP],al mov [ScreenBPP],al
mov [_display.bpp], eax mov [_display.bpp], eax
mov [_display.vrefresh], 60 mov [_display.vrefresh], 60
mov [_display.disable_mouse], __sys_disable_mouse mov [_display.disable_mouse], __sys_disable_mouse
movzx eax,word [BOOT_VAR+0x900A] ; X max mov eax, 1024 ; << X max
mov [_display.width], eax mov [_display.width], eax
dec eax dec eax
mov [Screen_Max_X],eax mov [Screen_Max_X],eax
mov [screen_workarea.right],eax mov [screen_workarea.right],eax
movzx eax,word [BOOT_VAR+0x900C] ; Y max mov eax,768 ; << Y max
mov [_display.height], eax mov [_display.height], eax
dec eax dec eax
mov [Screen_Max_Y],eax mov [Screen_Max_Y],eax
mov [screen_workarea.bottom],eax mov [screen_workarea.bottom],eax
movzx eax,word [BOOT_VAR+0x9008] ; screen mode mov eax, 0x7055 ; << screen mode
mov [SCR_MODE],eax mov [SCR_MODE],eax
movzx eax, word[BOOT_VAR+0x9001] ; for other modes mov eax, 4096 ; << may be different!
mov [BytesPerScanLine],ax mov [BytesPerScanLine],ax
mov [_display.pitch], eax mov [_display.pitch], eax
@ -373,16 +373,9 @@ high_code:
; GRAPHICS ADDRESSES ; GRAPHICS ADDRESSES
and byte [BOOT_VAR+0x901e],0x0 and byte [BOOT_VAR+0x901e],0x0
mov eax,[BOOT_VAR+0x9018] mov eax, [BOOT_VAR+0x9018]
mov [LFBAddress],eax mov [LFBAddress],eax
cmp [SCR_MODE],word 0100000000000000b
jge setvesa20
mov eax, 0xDEADBEEF
hlt
; === EGA, VGA & Vesa 1.2 modes not supported ===
setvesa20:
v20ga32:
mov [PUTPIXEL],dword __sys_putpixel mov [PUTPIXEL],dword __sys_putpixel
mov [GETPIXEL],dword get_pixel mov [GETPIXEL],dword get_pixel