Support for 16bpp video modes (usefull for embedded devices such as 86duino with vortex86 VGA)

git-svn-id: svn://kolibrios.org@5154 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2014-11-01 17:26:42 +00:00
parent 62b33c4994
commit 274d2c309b
8 changed files with 1431 additions and 839 deletions

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -218,14 +218,16 @@ calc_vmodes_table:
test [es:mi.ModeAttributes], 10000000b ;LFB ?
jz @f
cmp [es:mi.BitsPerPixel], 24 ;It show only videomodes to have support 24 and 32 bpp
cmp [es:mi.BitsPerPixel], 16 ;List only supported videomodes (16, 24 and 32 bpp)
jb @f
; cmp [es:mi.BitsPerPixel],16
; jne .l0
; cmp [es:mi.GreenMaskSize],5
; jne .l0
; 16 bpp might actually be 15 bpp
cmp [es:mi.BitsPerPixel], 16
jne .l0
cmp [es:mi.GreenMaskSize], 5
jne .l0
; mov [es:mi.BitsPerPixel],15
jmp @f ; 15 bpp isnt supported ATM
.l0:

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -430,7 +430,8 @@ struct display_t
y dd ?
width dd ?
height dd ?
bpp dd ?
bits_per_pixel dd ?
bytes_per_pixel dd ?
vrefresh dd ?
pitch dd ?
lfb dd ?

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -378,14 +378,14 @@ _display display_t
_WinMapAddress rd 1
_WinMapSize rd 1
LFBAddress rd 1
Screen_Max_X rd 1
Screen_Max_Y rd 1
LFBAddress dd ?
Screen_Max_X dd ?
Screen_Max_Y dd ?
SCR_MODE rw 2
PUTPIXEL rd 1
GETPIXEL rd 1
PUTPIXEL dd ?
GETPIXEL dd ?
if VESA_1_2_VIDEO
BANK_SWITCH rd 1 reserved for vesa 1.2
@ -401,7 +401,7 @@ d_width_calc_area rd 1140
mouseunder rd 16*24
MOUSE_PICTURE rd 1
MOUSE_PICTURE dd ?
MOUSE_SCROLL_H rw 1
MOUSE_X: rw 1

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -24,16 +24,12 @@ $Revision$
uglobal
;--------------------------------------
align 4
mousecount dd 0x0
mousedata dd 0x0
Y_UNDER_sub_CUR_hot_y_add_curh:
dw 0
Y_UNDER_subtraction_CUR_hot_y:
dw 0
X_UNDER_sub_CUR_hot_x_add_curh:
dw 0
X_UNDER_subtraction_CUR_hot_x:
dw 0
mousecount dd ?
mousedata dd ?
Y_UNDER_sub_CUR_hot_y_add_curh dw ?
Y_UNDER_subtraction_CUR_hot_y dw ?
X_UNDER_sub_CUR_hot_x_add_curh dw ?
X_UNDER_subtraction_CUR_hot_x dw ?
endg
iglobal
@ -44,9 +40,12 @@ mouse_speed_factor:
dd 3
mouse_timer_ticks dd 0
endg
;-----------------------------------------------------------------------------
align 4
draw_mouse_under:
; return old picture
cmp [_display.restore_cursor], 0
je @F
@ -57,15 +56,13 @@ draw_mouse_under:
stdcall [_display.restore_cursor], eax, ebx
popad
ret
;--------------------------------------
align 4
@@:
@@:
pushad
xor ecx, ecx
xor edx, edx
;--------------------------------------
align 4
mres:
mres:
movzx eax, word [X_UNDER]
movzx ebx, word [Y_UNDER]
add eax, ecx
@ -97,7 +94,9 @@ mres:
jnz mres
popad
ret
;-----------------------------------------------------------------------------
align 4
save_draw_mouse:
cmp [_display.move_cursor], 0
@ -173,11 +172,13 @@ drm:
push edx
; helloworld
push ecx
add eax, ecx; save picture under mouse
add eax, ecx ; save picture under mouse
add ebx, edx
push ecx
or ecx, 0x04000000 ; don't load to mouseunder area
call getpixel
push eax ebx edx edi
call [GETPIXEL]
pop edi edx ebx eax
mov [COLOR_TEMP], ecx
pop ecx
mov eax, edx
@ -229,7 +230,9 @@ drm:
add esp, 8
popad
ret
;-----------------------------------------------------------------------------
align 4
combine_colors:
; in
@ -244,7 +247,7 @@ combine_colors:
push edx
push ecx
xor ecx, ecx
; byte 2
; byte 0
mov eax, 0xff
sub al, [esi+0]
mov ebx, [esp]
@ -298,7 +301,9 @@ combine_colors:
pop ebx
pop eax
ret
;-----------------------------------------------------------------------------
align 4
check_mouse_area_for_getpixel:
; in:
@ -317,18 +322,18 @@ check_mouse_area_for_getpixel:
cmp ebx, ecx
ja .no_mouse_area
; offset Y
sub bx, [Y_UNDER] ;[MOUSE_Y]
sub bx, [Y_UNDER] ; [MOUSE_Y]
;--------------------------------------
; check for X
xor ecx, ecx
mov cx, [X_UNDER] ;[MOUSE_X]
mov cx, [X_UNDER] ; [MOUSE_X]
cmp eax, ecx
jb .no_mouse_area
add ecx, 15 ; mouse cursor X size
cmp eax, ecx
ja .no_mouse_area
; offset X
sub ax, [X_UNDER] ;[MOUSE_X]
sub ax, [X_UNDER] ; [MOUSE_X]
;--------------------------------------
; eax = offset x
; ebx = offset y
@ -341,13 +346,14 @@ check_mouse_area_for_getpixel:
or ecx, 0xff000000
pop ebx eax
ret
;--------------------------------------
align 4
.no_mouse_area:
.no_mouse_area:
xor ecx, ecx
pop ebx eax
ret
;-----------------------------------------------------------------------------
align 4
check_mouse_area_for_putpixel:
; in:
@ -364,12 +370,12 @@ check_mouse_area_for_putpixel:
cmp cx, ax
ja .no_mouse_area
; offset Y
sub cx, [Y_UNDER] ;[MOUSE_Y]
sub cx, [Y_UNDER] ; [MOUSE_Y]
mov ax, cx
shl eax, 16
;--------------------------------------
; check for X
mov ax, [X_UNDER] ;[MOUSE_X]
mov ax, [X_UNDER] ; [MOUSE_X]
shr ecx, 16
cmp cx, ax
jb .no_mouse_area
@ -377,9 +383,9 @@ check_mouse_area_for_putpixel:
cmp cx, ax
ja .no_mouse_area
; offset X
sub cx, [X_UNDER] ;[MOUSE_X]
sub cx, [X_UNDER] ; [MOUSE_X]
mov ax, cx
;--------------------------------------
; eax = (offset y) shl 16 + (offset x)
pop ecx
@ -387,8 +393,8 @@ check_mouse_area_for_putpixel:
push eax ebx
mov ebx, eax
shr ebx, 16 ;y
and eax, 0xffff ;x
shr ebx, 16 ; y
and eax, 0xffff ; x
shl ebx, 6
shl eax, 2
@ -411,17 +417,15 @@ check_mouse_area_for_putpixel:
add esi, 16*24*3
call combine_colors
pop edi esi
;--------------------------------------
align 4
.end:
mov eax, ecx
ret
;--------------------------------------
align 4
.no_mouse_area:
.no_mouse_area:
pop eax
ret
;-----------------------------------------------------------------------------
align 4
__sys_draw_pointer:
pushad
@ -433,14 +437,14 @@ __sys_draw_pointer:
je @f
mov [redrawmouse_unconditional], 0
jmp redrawmouse
;--------------------------------------
align 4
@@:
@@:
cmp eax, ecx
jne redrawmouse
cmp ebx, edx
je nodmp
;--------------------------------------
align 4
redrawmouse:
pushfd
@ -468,16 +472,14 @@ redrawmouse:
mov [X_UNDER_subtraction_CUR_hot_x], ax
add eax, [cur.w]
mov [X_UNDER_sub_CUR_hot_x_add_curh], ax
;--------------------------------------
align 4
@@:
@@:
popfd
;--------------------------------------
align 4
nodmp:
nodmp:
popad
ret
;-----------------------------------------------------------------------------
align 4
proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
@ -538,7 +540,9 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
call wakeup_osloop
ret
endp
;-----------------------------------------------------------------------------
align 4
mouse_acceleration:
push eax
@ -550,8 +554,5 @@ mouse_acceleration:
;push edx
imul eax, [mouse_speed_factor]
;pop edx
;--------------------------------------
align 4
@@:
@@:
ret
;-----------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved.
;; PROGRAMMING:
;; Ivan Poddubny
;; Marat Zakiyanov (Mario79)
@ -434,7 +434,7 @@ high_code:
mov al, [BOOT_VARS+BOOT_DMA] ; DMA access
mov [allow_dma_access], al
movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp
mov [_display.bpp], eax
mov [_display.bits_per_pixel], eax
mov [_display.vrefresh], 60
mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen
mov [debug_direct_print], al
@ -480,34 +480,56 @@ high_code:
mov edi, BiosDisksData
rep movsd
; GRAPHICS ADDRESSES
setvideomode:
mov eax, [BOOT_VARS+BOOT_LFB]
mov [LFBAddress], eax
cmp [SCR_MODE], word 0100000000000000b
jge setvesa20
cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors
je v20ga32
jmp v20ga24
cmp word [SCR_MODE], 0x0012 ; VGA (640x480 16 colors)
je .vga
cmp word [SCR_MODE], 0x0013 ; MCGA (320*200 256 colors)
je .32bpp
cmp byte [_display.bits_per_pixel], 32
je .32bpp
cmp byte [_display.bits_per_pixel], 24
je .24bpp
cmp byte [_display.bits_per_pixel], 16
je .16bpp
; cmp byte [_display.bits_per_pixel], 15
; je .15bpp
setvesa20:
mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0
mov [GETPIXEL], dword Vesa20_getpixel24
cmp byte [_display.bpp], 24
jz v20ga24
v20ga32:
mov [PUTPIXEL], dword Vesa20_putpixel32
mov [GETPIXEL], dword Vesa20_getpixel32
jmp no_mode_0x12
v20ga24:
cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480
jne no_mode_0x12
mov [PUTPIXEL], dword VGA_putpixel
mov [GETPIXEL], dword Vesa20_getpixel32
no_mode_0x12:
.vga:
mov [PUTPIXEL], VGA_putpixel
mov [GETPIXEL], Vesa20_getpixel32 ; Conversion buffer is 32 bpp
mov [_display.bytes_per_pixel], 4 ; Conversion buffer is 32 bpp
jmp .finish
mov [MOUSE_PICTURE], dword mousepointer
; .15bpp:
; mov [PUTPIXEL], Vesa20_putpixel15
; mov [GETPIXEL], Vesa20_getpixel15
; mov [_display.bytes_per_pixel], 2
; jmp .finish
.16bpp:
mov [PUTPIXEL], Vesa20_putpixel16
mov [GETPIXEL], Vesa20_getpixel16
mov [_display.bytes_per_pixel], 2
jmp .finish
.24bpp:
mov [PUTPIXEL], Vesa20_putpixel24
mov [GETPIXEL], Vesa20_getpixel24
mov [_display.bytes_per_pixel], 3
jmp .finish
.32bpp:
mov [PUTPIXEL], Vesa20_putpixel32
mov [GETPIXEL], Vesa20_getpixel32
mov [_display.bytes_per_pixel], 4
; jmp .finish
.finish:
mov [MOUSE_PICTURE], mousepointer
mov [_display.check_mouse], check_mouse_area_for_putpixel
mov [_display.check_m_pixel], check_mouse_area_for_getpixel
@ -4997,7 +5019,7 @@ sys_gs: ; direct screen access
mov [esp+32], eax
ret
.2: ; bits per pixel
mov eax, [_display.bpp]
mov eax, [_display.bits_per_pixel]
mov [esp+32], eax
ret
.3: ; bytes per scanline

View File

@ -308,7 +308,7 @@ end virtual
test edx, edx
jz .L57
cmp [_display.bpp], 32
cmp [_display.bits_per_pixel], 32
jne .core_24
lea edi, [edi+ebx*4]

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -580,6 +580,40 @@ align 4
endp
;------------------------------------------------------------------------------
align 4
proc restore_16 stdcall, x:dword, y:dword
push ebx
mov ebx, [cur_saved_base]
mov edx, [cur.h]
test edx, edx
jz .ret
push esi
push edi
mov esi, cur_saved_data
;--------------------------------------
align 4
@@:
mov edi, ebx
add ebx, [_display.pitch]
mov ecx, [cur.w]
rep movsw
dec edx
jnz @B
pop edi
;--------------------------------------
align 4
.ret:
pop esi
pop ebx
ret
endp
;------------------------------------------------------------------------------
align 4
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
locals
h dd ?
@ -815,6 +849,129 @@ align 4
endp
;------------------------------------------------------------------------------
align 4
proc move_cursor_16 stdcall, hcursor:dword, x:dword, y:dword
locals
h dd ?
_dx dd ?
_dy dd ?
endl
mov esi, [hcursor]
mov ecx, [x]
mov eax, [y]
xor edx, edx
sub ecx, [esi+CURSOR.hot_x]
lea ebx, [ecx+32-1]
mov [x], ecx
sets dl
dec edx
and ecx, edx ;clip x to 0<=x
mov [cur.left], ecx
mov edi, ecx
sub edi, [x]
mov [_dx], edi
xor edx, edx
sub eax, [esi+CURSOR.hot_y]
lea edi, [eax+32-1]
mov [y], eax
sets dl
dec edx
and eax, edx ;clip y to 0<=y
mov [cur.top], eax
mov edx, eax
sub edx, [y]
mov [_dy], edx
; mul dword [BytesPerScanLine]
mov eax, [BPSLine_calc_area+eax*4]
lea edx, [LFB_BASE+eax+ecx*2]
mov [cur_saved_base], edx
cmp ebx, [Screen_Max_X]
jbe @F
mov ebx, [Screen_Max_X]
;--------------------------------------
align 4
@@:
cmp edi, [Screen_Max_Y]
jbe @F
mov edi, [Screen_Max_Y]
;--------------------------------------
align 4
@@:
mov [cur.right], ebx
mov [cur.bottom], edi
sub ebx, [x]
sub edi, [y]
inc ebx
inc edi
sub ebx, [_dx]
sub edi, [_dy]
mov [cur.w], ebx
mov [cur.h], edi
mov [h], edi
mov eax, edi
mov edi, cur_saved_data
;--------------------------------------
align 4
@@:
mov esi, edx
add edx, [_display.pitch]
mov ecx, [cur.w]
rep movsw
dec eax
jnz @B
;draw cursor
mov ebx, [cur_saved_base]
mov eax, [_dy]
shl eax, 5
add eax, [_dx]
mov esi, [hcursor]
mov esi, [esi+CURSOR.base]
lea edx, [esi+eax*4]
;--------------------------------------
align 4
.row:
mov ecx, [cur.w]
mov esi, edx
mov edi, ebx
add edx, 32*4
add ebx, [_display.pitch]
;--------------------------------------
align 4
.pix:
lodsd
test eax, 0xFF000000
jz @F
; convert to 16 bpp and store to real LFB
and eax, 00000000111110001111110011111000b
shr ah, 2
shr ax, 3
ror eax, 8
add al, ah
rol eax, 8
mov [edi], ax
;--------------------------------------
align 4
@@:
add edi, 2
dec ecx
jnz .pix
dec [h]
jnz .row
ret
endp
;------------------------------------------------------------------------------
align 4
check_mouse_area_for_getpixel_new:
; in:
; eax = x
@ -850,7 +1007,10 @@ check_mouse_area_for_getpixel_new:
add eax, ebx
mov ebx, eax
shl eax, 2
cmp byte [_display.bpp], 32
cmp byte [_display.bits_per_pixel], 32
je @f
sub eax, ebx
cmp byte [_display.bits_per_pixel], 24
je @f
sub eax, ebx
;--------------------------------------
@ -925,13 +1085,29 @@ align 4
add ecx, ebx
mov ebx, ecx
shl ecx, 2
cmp byte [_display.bpp], 24
cmp byte [_display.bits_per_pixel], 16
je .16
cmp byte [_display.bits_per_pixel], 24
je .24
and eax, 0xFFFFFF
mov [ecx + cur_saved_data], eax ;store new color to
jmp @f
;--------------------------------------
align 4
.16:
sub ecx, ebx
sub ecx, ebx
; convert to 16 bpp and store to real LFB
and eax, 00000000111110001111110011111000b
shr ah, 2
shr ax, 3
ror eax, 8
add al, ah
rol eax, 8
mov [ecx + cur_saved_data], ax ;store new color to
jmp @f
;--------------------------------------
align 4
.24:
sub ecx, ebx
mov [ecx + cur_saved_data], ax ;store new color to
@ -999,9 +1175,9 @@ init_display:
mov ebx, restore_32
mov ecx, move_cursor_32
mov edx, Vesa20_putpixel32_new
mov eax, [_display.bpp]
mov eax, [_display.bits_per_pixel]
cmp al, 32
jne .24
jne .not_32bpp
.set:
mov [_display.select_cursor], select_cursor
@ -1020,12 +1196,30 @@ init_display:
mov [def_cursor], eax
ret
.24:
.not_32bpp:
cmp al, 24
jne .not_24bpp
mov ebx, restore_24
mov ecx, move_cursor_24
mov edx, Vesa20_putpixel24_new
cmp al, 24
je .set
jmp .set
.not_24bpp:
cmp al, 16
jne .not_16bpp
mov ebx, restore_16
mov ecx, move_cursor_16
mov edx, Vesa20_putpixel16_new
jmp .set
.not_16bpp:
; cmp al, 15
; jne .fail
; mov ebx, restore_15
; mov ecx, move_cursor_15
; mov edx, Vesa20_putpixel15_new
; jmp .set
.fail:
xor eax, eax

File diff suppressed because it is too large Load Diff