From 274d2c309beff7313fa75830e103432e11d41fdf Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sat, 1 Nov 2014 17:26:42 +0000 Subject: [PATCH] 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 --- kernel/trunk/boot/bootvesa.inc | 14 +- kernel/trunk/const.inc | 5 +- kernel/trunk/data32.inc | 14 +- kernel/trunk/hid/mousedrv.inc | 151 +-- kernel/trunk/kernel.asm | 72 +- kernel/trunk/video/blitter.inc | 2 +- kernel/trunk/video/cursors.inc | 210 +++- kernel/trunk/video/vesa20.inc | 1802 +++++++++++++++++++------------- 8 files changed, 1431 insertions(+), 839 deletions(-) diff --git a/kernel/trunk/boot/bootvesa.inc b/kernel/trunk/boot/bootvesa.inc index 724b2ba0c0..1070ba29bf 100644 --- a/kernel/trunk/boot/bootvesa.inc +++ b/kernel/trunk/boot/bootvesa.inc @@ -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: diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index 5070e3eaf4..90c8deb0a8 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -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 ? diff --git a/kernel/trunk/data32.inc b/kernel/trunk/data32.inc index b2eb352440..e815b89f8f 100644 --- a/kernel/trunk/data32.inc +++ b/kernel/trunk/data32.inc @@ -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 diff --git a/kernel/trunk/hid/mousedrv.inc b/kernel/trunk/hid/mousedrv.inc index cdc3b9c436..9091e9119d 100644 --- a/kernel/trunk/hid/mousedrv.inc +++ b/kernel/trunk/hid/mousedrv.inc @@ -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,29 +24,28 @@ $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 ;-------------------------------------- align 4 -mouse_delay dd 10 +mouse_delay dd 10 mouse_speed_factor: - dd 3 -mouse_timer_ticks dd 0 + 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 + or ecx, 0x04000000 ; don't load to mouseunder area + push eax ebx edx edi + call [GETPIXEL] + pop edi edx ebx eax mov [COLOR_TEMP], ecx pop ecx mov eax, edx @@ -189,12 +190,12 @@ drm: and ebx, 0xffffff mov [eax], ebx pop ecx - mov edi, edx ; y cycle - shl edi, 4 ; *16 bytes per row - add edi, ecx ; x cycle + mov edi, edx ; y cycle + shl edi, 4 ; *16 bytes per row + add edi, ecx ; x cycle mov esi, edi add edi, esi - add edi, esi ; *3 + add edi, esi ; *3 add edi, [MOUSE_PICTURE] ; we have our str address mov esi, edi add esi, 16*24*3 @@ -208,19 +209,19 @@ drm: pop ecx pop ebx pop eax - add eax, ecx ; we have x coord+cycle - add ebx, edx ; and y coord+cycle + add eax, ecx ; we have x coord+cycle + add ebx, edx ; and y coord+cycle push ecx mov ecx, [MOUSE_COLOR_MEM] mov edi, 1 ; force - or ecx, 0x04000000 ; don't save to mouseunder area + or ecx, 0x04000000 ; don't save to mouseunder area ; call [putpixel] call __sys_putpixel pop ecx mov ebx, [esp+0] ; pure y coord again mov eax, [esp+4] ; and x - inc ecx ; +1 cycle - cmp ecx, 16 ; if more than 16 + inc ecx ; +1 cycle + cmp ecx, 16 ; if more than 16 jnz drm xor ecx, ecx inc 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: @@ -309,26 +314,26 @@ check_mouse_area_for_getpixel: push eax ebx ; check for Y xor ecx, ecx - mov cx, [Y_UNDER] ; [MOUSE_Y] + mov cx, [Y_UNDER] ; [MOUSE_Y] cmp ebx, ecx jb .no_mouse_area - add ecx, 23 ; mouse cursor Y size + add ecx, 23 ; mouse cursor Y size 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 + 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: @@ -357,29 +363,29 @@ check_mouse_area_for_putpixel: ; eax = new color push eax ; check for Y - mov ax, [Y_UNDER] ; [MOUSE_Y] + mov ax, [Y_UNDER] ; [MOUSE_Y] cmp cx, ax jb .no_mouse_area - add ax, 23 ; mouse cursor Y size + add ax, 23 ; mouse cursor Y size 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 - add ax, 15 ; mouse cursor X size + add ax, 15 ; mouse cursor X size 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 @@ -401,27 +407,25 @@ check_mouse_area_for_putpixel: push esi edi rol eax, 16 - movzx edi, ax ; y cycle - shl edi, 4 ; *16 bytes per row + movzx edi, ax ; y cycle + shl edi, 4 ; *16 bytes per row shr eax, 16 - add edi, eax ; x cycle + add edi, eax ; x cycle lea edi, [edi*3] add edi, [MOUSE_PICTURE] ; we have our str address mov esi, edi 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,21 +472,19 @@ 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 mov eax, [BtnState] - and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements + and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements mov [BTN_DOWN], eax ;-------------------------------------- mov eax, [XMoving] @@ -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 -;----------------------------------------------------------------------------- diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index f93b9e0601..e7bcee97e6 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -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 diff --git a/kernel/trunk/video/blitter.inc b/kernel/trunk/video/blitter.inc index ccf29c1ffc..d290c3484b 100644 --- a/kernel/trunk/video/blitter.inc +++ b/kernel/trunk/video/blitter.inc @@ -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] diff --git a/kernel/trunk/video/cursors.inc b/kernel/trunk/video/cursors.inc index c07637a05f..076a4ce7d5 100644 --- a/kernel/trunk/video/cursors.inc +++ b/kernel/trunk/video/cursors.inc @@ -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 diff --git a/kernel/trunk/video/vesa20.inc b/kernel/trunk/video/vesa20.inc index 0f997567bb..492f5a4787 100644 --- a/kernel/trunk/video/vesa20.inc +++ b/kernel/trunk/video/vesa20.inc @@ -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 ;; ;; ;; ;; VESA20.INC ;; @@ -19,100 +19,130 @@ $Revision$ - -; If you're planning to write your own video driver I suggest -; you replace the VESA12.INC file and see those instructions. - -;Screen_Max_X equ 0xfe00 -;Screen_Max_Y equ 0xfe04 -;BytesPerScanLine equ 0xfe08 -;LFBAddress equ 0xfe80 -;ScreenBPP equ 0xfbf1 - - - -;----------------------------------------------------------------------------- -; getpixel -; -; in: -; eax = x coordinate -; ebx = y coordinate -; -; ret: -; ecx = 00 RR GG BB -;----------------------------------------------------------------------------- +uglobal align 4 -getpixel: - push eax ebx edx edi - call dword [GETPIXEL] - pop edi edx ebx eax - ret -;----------------------------------------------------------------------------- + bgr_cur_line rd 1920 ; maximum width of screen + bgr_next_line rd 1920 +endg + +iglobal align 4 -Vesa20_getpixel24: + overlapping_of_points_ptr dd overlapping_of_points +endg + + +;----------------------------------------------------------------------------- ; eax = x ; ebx = y -;-------------------------------------- -; check for hardware cursor + +align 4 +Vesa20_getpixel16: + + ; check for hardware cursor cmp [_display.select_cursor], select_cursor je @f cmp [_display.select_cursor], 0 jne .no_mouseunder -;-------------------------------------- -align 4 -@@: -; check mouse area for putpixel - test ecx, 0x04000000 ; don't load to mouseunder area + @@: + + ; check mouse area for putpixel + test ecx, 0x04000000 ; don't load to mouseunder area jnz .no_mouseunder call [_display.check_m_pixel] - test ecx, ecx ;0xff000000 + test ecx, ecx ; 0xff000000 jnz @f -;-------------------------------------- -align 4 -.no_mouseunder: -;-------------------------------------- + + .no_mouseunder: ; imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier mov ebx, [BPSLine_calc_area+ebx*4] - lea edi, [eax+eax*2]; edi = x*3 - add edi, ebx ; edi = x*3+(y*y multiplier) - mov ecx, [LFB_BASE+edi] -;-------------------------------------- -align 4 -@@: - and ecx, 0xffffff + lea edi, [eax*2] ; edi = x*2 + add edi, ebx ; edi = x*2+(y*y multiplier) + + movzx ecx, word[LFB_BASE+edi] + shl ecx, 3 + ror ecx, 8 + shl cx, 2 + ror ecx, 8 + shl cl, 3 + rol ecx, 16 + @@: + and ecx, 0x00ffffff ret + ;----------------------------------------------------------------------------- +; eax = x +; ebx = y + +align 4 +Vesa20_getpixel24: + + ; check for hardware cursor + cmp [_display.select_cursor], select_cursor + je @f + cmp [_display.select_cursor], 0 + jne .no_mouseunder + @@: + + ; check mouse area for putpixel + test ecx, 0x04000000 ; don't load to mouseunder area + jnz .no_mouseunder + call [_display.check_m_pixel] + test ecx, ecx ; 0xff000000 + jnz @f + + .no_mouseunder: +; imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier + mov ebx, [BPSLine_calc_area+ebx*4] + lea edi, [eax+eax*2] ; edi = x*3 + add edi, ebx ; edi = x*3+(y*y multiplier) + + mov ecx, [LFB_BASE+edi] + @@: + and ecx, 0x00ffffff + ret + +;----------------------------------------------------------------------------- +; eax = x +; ebx = y + align 4 Vesa20_getpixel32: -;-------------------------------------- -; check for hardware cursor + + ; check for hardware cursor cmp [_display.select_cursor], select_cursor je @f cmp [_display.select_cursor], 0 jne .no_mouseunder -;-------------------------------------- -align 4 -@@: -; check mouse area for putpixel - test ecx, 0x04000000 ; don't load to mouseunder area + @@: + + ; check mouse area for putpixel + test ecx, 0x04000000 ; don't load to mouseunder area jnz .no_mouseunder call [_display.check_m_pixel] - test ecx, ecx ;0xff000000 + test ecx, ecx ; 0xff000000 jnz @f -;-------------------------------------- -align 4 -.no_mouseunder: -;-------------------------------------- + + .no_mouseunder: ; imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier mov ebx, [BPSLine_calc_area+ebx*4] - lea edi, [ebx+eax*4]; edi = x*4+(y*y multiplier) + lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier) + mov ecx, [LFB_BASE+edi] -;-------------------------------------- -align 4 -@@: - and ecx, 0xffffff + @@: + and ecx, 0x00ffffff ret + ;----------------------------------------------------------------------------- +; ebx = pointer +; ecx = size [x|y] +; edx = coordinates [x|y] +; ebp = pointer to 'get' function +; esi = pointer to 'init' function +; edi = parameter for 'get' function + +align 16 +vesa20_putimage: + virtual at esp putimg: .real_sx dd ? @@ -141,15 +171,7 @@ virtual at esp .ret_addr dd ? .arg_0 dd ? end virtual -;----------------------------------------------------------------------------- -align 16 -; ebx = pointer -; ecx = size [x|y] -; edx = coordinates [x|y] -; ebp = pointer to 'get' function -; esi = pointer to 'init' function -; edi = parameter for 'get' function -vesa20_putimage: + pushad sub esp, putimg.stack_data ; save pointer to image @@ -175,45 +197,34 @@ vesa20_putimage: add ebx, [putimg.image_cy] mov [putimg.abs_cy], ebx ; real_sx = MIN(wnd_sx-image_cx, image_sx); - mov ebx, [eax-twdw + WDATA.box.width]; ebx = wnd_sx -; \begin{diamond}[20.08.2006] -; note that WDATA.box.width is one pixel less than real window x-size - inc ebx -; \end{diamond}[20.08.2006] + mov ebx, [eax-twdw + WDATA.box.width] ; ebx = wnd_sx + inc ebx ; WDATA.box.width is one pixel less than real window x-size sub ebx, [putimg.image_cx] ja @f add esp, putimg.stack_data popad ret -;-------------------------------------- -align 4 -@@: + + @@: cmp ebx, [putimg.image_sx] jbe .end_x mov ebx, [putimg.image_sx] -;-------------------------------------- -align 4 -.end_x: + .end_x: mov [putimg.real_sx], ebx ; init real_sy - mov ebx, [eax-twdw + WDATA.box.height]; ebx = wnd_sy -; \begin{diamond}[20.08.2006] + mov ebx, [eax-twdw + WDATA.box.height] ; ebx = wnd_sy inc ebx -; \end{diamond}[20.08.2006] sub ebx, [putimg.image_cy] ja @f add esp, putimg.stack_data popad ret -;-------------------------------------- -align 4 -@@: + + @@: cmp ebx, [putimg.image_sy] jbe .end_y mov ebx, [putimg.image_sy] -;-------------------------------------- -align 4 -.end_y: + .end_y: mov [putimg.real_sy], ebx ; line increment mov eax, [putimg.image_sx] @@ -231,8 +242,7 @@ align 4 mov [putimg.winmap_newline], eax ; screen new line increment mov eax, [_display.pitch] - mov ebx, [_display.bpp] - shr ebx, 3 + mov ebx, [_display.bytes_per_pixel] imul ecx, ebx sub eax, ecx mov [putimg.screen_newline], eax @@ -243,8 +253,6 @@ align 4 ; imul edx, [BytesPerScanLine] mov edx, [BPSLine_calc_area+edx*4] mov eax, [putimg.abs_cx] -; movzx ebx, byte [ScreenBPP] -; shr ebx, 3 imul eax, ebx add edx, eax ; pointer to pixel map @@ -256,56 +264,257 @@ align 4 add eax, [putimg.abs_cx] add eax, [_WinMapAddress] xchg eax, ebp -;-------------------------------------- + mov ecx, [putimg.real_sx] add ecx, [putimg.abs_cx] mov [putimg.real_sx_and_abs_cx], ecx mov ecx, [putimg.real_sy] add ecx, [putimg.abs_cy] mov [putimg.real_sy_and_abs_cy], ecx -;-------------------------------------- + ; get process number mov ebx, [CURRENT_TASK] - cmp byte [_display.bpp], 32 + + cmp byte [_display.bits_per_pixel], 16 + je put_image_end_16 + cmp byte [_display.bits_per_pixel], 24 + je put_image_end_24 + cmp byte [_display.bits_per_pixel], 32 je put_image_end_32 -;-------------------------------------- -put_image_end_24: + +;------------------------------------------------------------------------------ + +put_image_end_16: + mov edi, [putimg.real_sy] -;-------------------------------------- + +; check for hardware cursor + mov ecx, [_display.select_cursor] + cmp ecx, select_cursor + je put_image_end_16_new + cmp ecx, 0 + je put_image_end_16_old + .new_line: + mov ecx, [putimg.real_sx] + .new_x: + push [putimg.edi] + mov eax, [putimg.ebp+4] + call eax + cmp [ebp], bl + jne .skip +; convert to 16 bpp and store to LFB + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + mov [LFB_BASE+edx], ax + .skip: + add edx, 2 + inc ebp + dec ecx + jnz .new_x + + add esi, [putimg.line_increment] + add edx, [putimg.screen_newline] + add ebp, [putimg.winmap_newline] + + cmp [putimg.ebp], putimage_get1bpp + jz .correct + cmp [putimg.ebp], putimage_get2bpp + jz .correct + cmp [putimg.ebp], putimage_get4bpp + jnz @f + .correct: + mov eax, [putimg.edi] + mov byte [eax], 80h + @@: + dec edi + jnz .new_line + .finish: + add esp, putimg.stack_data + popad + ret + +;------------------------------------------------------------------------------ + +align 4 +put_image_end_16_old: + + .new_line: + mov ecx, [putimg.real_sx] + .new_x: + push [putimg.edi] + mov eax, [putimg.ebp+4] + call eax + cmp [ebp], bl + jne .skip + + push ecx + neg ecx + add ecx, [putimg.real_sx_and_abs_cx + 4] + shl ecx, 16 + add ecx, [putimg.real_sy_and_abs_cy + 4] + sub ecx, edi + +; check mouse area for putpixel + call check_mouse_area_for_putpixel + pop ecx + +; convert to 16 bpp and store to LFB +;; and eax, 00000000111110001111110011111000b +;; shr ah, 2 +;; shr ax, 3 +;; ror eax, 8 +;; add al, ah +;; rol eax, 8 + mov [LFB_BASE+edx], ax + .skip: + inc edx + inc edx + inc ebp + dec ecx + jnz .new_x + + add esi, [putimg.line_increment] + add edx, [putimg.screen_newline] + add ebp, [putimg.winmap_newline] + + cmp [putimg.ebp], putimage_get1bpp + jz .correct + cmp [putimg.ebp], putimage_get2bpp + jz .correct + cmp [putimg.ebp], putimage_get4bpp + jnz @f + .correct: + mov eax, [putimg.edi] + mov byte [eax], 80h + @@: + dec edi + jnz .new_line + jmp put_image_end_16.finish + +;------------------------------------------------------------------------------ + +align 4 +put_image_end_16_new: + + .new_line: + mov ecx, [putimg.real_sx] + + .new_x: + push [putimg.edi] + mov eax, [putimg.ebp+4] + call eax + + cmp [ebp], bl + jne .skip + + push ecx + .sh: + neg ecx + add ecx, [putimg.real_sx_and_abs_cx + 4] + +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae .no_mouse_area + + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb .no_mouse_area + + shl ecx, 16 + add ecx, [putimg.real_sy_and_abs_cy + 4] + sub ecx, edi + +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae .no_mouse_area + + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb .no_mouse_area + +; check mouse area for putpixel + call check_mouse_area_for_putpixel_new.1 + cmp ecx, -1 ; SHIT HAPPENS? + jne .no_mouse_area + + mov ecx, [esp] + jmp .sh + + .no_mouse_area: + pop ecx +; convert to 16 bpp and store to LFB + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + mov [LFB_BASE+edx], ax + + .skip: + add edx, 2 + inc ebp + dec ecx + jnz .new_x + + add esi, [putimg.line_increment] + add edx, [putimg.screen_newline] + add ebp, [putimg.winmap_newline] + + cmp [putimg.ebp], putimage_get1bpp + jz .correct + cmp [putimg.ebp], putimage_get2bpp + jz .correct + cmp [putimg.ebp], putimage_get4bpp + jnz @f + + .correct: + mov eax, [putimg.edi] + mov byte [eax], 80h + + @@: + dec edi + jnz .new_line + jmp put_image_end_16.finish + +;------------------------------------------------------------------------------ + +align 4 +put_image_end_24: + + mov edi, [putimg.real_sy] + ; check for hardware cursor mov ecx, [_display.select_cursor] cmp ecx, select_cursor je put_image_end_24_new cmp ecx, 0 je put_image_end_24_old -;-------------------------------------- -align 4 -.new_line: + .new_line: mov ecx, [putimg.real_sx] -;-------------------------------------- -align 4 -.new_x: + .new_x: push [putimg.edi] mov eax, [putimg.ebp+4] call eax cmp [ebp], bl jne .skip -;-------------------------------------- -; store to real LFB + +; store to LFB mov [LFB_BASE+edx], ax shr eax, 16 mov [LFB_BASE+edx+2], al -;-------------------------------------- -align 4 -.skip: + + .skip: add edx, 3 inc ebp dec ecx jnz .new_x add esi, [putimg.line_increment] - add edx, [putimg.screen_newline];[BytesPerScanLine] - add ebp, [putimg.winmap_newline];[Screen_Max_X] + add edx, [putimg.screen_newline] + add ebp, [putimg.winmap_newline] cmp [putimg.ebp], putimage_get1bpp jz .correct @@ -313,28 +522,23 @@ align 4 jz .correct cmp [putimg.ebp], putimage_get4bpp jnz @f -;-------------------------------------- -align 4 -.correct: + .correct: mov eax, [putimg.edi] mov byte [eax], 80h -;-------------------------------------- -align 4 -@@: + @@: dec edi jnz .new_line -;-------------------------------------- -align 4 -.finish: + .finish: add esp, putimg.stack_data popad ret + ;------------------------------------------------------------------------------ + align 4 put_image_end_24_old: -;-------------------------------------- -align 4 -.new_line: + + .new_line: mov ecx, [putimg.real_sx] ;-------------------------------------- align 4 @@ -344,9 +548,8 @@ align 4 call eax cmp [ebp], bl jne .skip -;-------------------------------------- - push ecx + push ecx neg ecx add ecx, [putimg.real_sx_and_abs_cx + 4] shl ecx, 16 @@ -356,21 +559,20 @@ align 4 ; check mouse area for putpixel call check_mouse_area_for_putpixel pop ecx -; store to real LFB +; store to LFB mov [LFB_BASE+edx], ax shr eax, 16 mov [LFB_BASE+edx+2], al -;-------------------------------------- -align 4 -.skip: + + .skip: add edx, 3 inc ebp dec ecx jnz .new_x add esi, [putimg.line_increment] - add edx, [putimg.screen_newline];[BytesPerScanLine] - add ebp, [putimg.winmap_newline];[Screen_Max_X] + add edx, [putimg.screen_newline] + add ebp, [putimg.winmap_newline] cmp [putimg.ebp], putimage_get1bpp jz .correct @@ -378,40 +580,36 @@ align 4 jz .correct cmp [putimg.ebp], putimage_get4bpp jnz @f -;-------------------------------------- -align 4 -.correct: + + .correct: mov eax, [putimg.edi] mov byte [eax], 80h -;-------------------------------------- -align 4 -@@: + + @@: dec edi jnz .new_line jmp put_image_end_24.finish + ;------------------------------------------------------------------------------ + align 4 put_image_end_24_new: -;-------------------------------------- -align 4 -.new_line: + + .new_line: mov ecx, [putimg.real_sx] -;-------------------------------------- -align 4 -.new_x: + + .new_x: push [putimg.edi] mov eax, [putimg.ebp+4] call eax cmp [ebp], bl jne .skip -;-------------------------------------- + push ecx -;-------------------------------------- -align 4 -.sh: + .sh: neg ecx add ecx, [putimg.real_sx_and_abs_cx + 4] -;-------------------------------------- + ; check for X cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] jae .no_mouse_area @@ -423,40 +621,39 @@ align 4 add ecx, [putimg.real_sy_and_abs_cy + 4] sub ecx, edi -;-------------------------------------- + ; check for Y cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] jae .no_mouse_area sub cx, [Y_UNDER_subtraction_CUR_hot_y] jb .no_mouse_area -;-------------------------------------- + ; check mouse area for putpixel call check_mouse_area_for_putpixel_new.1 - cmp ecx, -1 ;SHIT HAPPENS? + cmp ecx, -1 ; SHIT HAPPENS? jne .no_mouse_area mov ecx, [esp] jmp .sh -;-------------------------------------- -align 4 -.no_mouse_area: + + .no_mouse_area: pop ecx -; store to real LFB + +; store to LFB mov [LFB_BASE+edx], ax shr eax, 16 mov [LFB_BASE+edx+2], al -;-------------------------------------- -align 4 -.skip: + + .skip: add edx, 3 inc ebp dec ecx jnz .new_x add esi, [putimg.line_increment] - add edx, [putimg.screen_newline];[BytesPerScanLine] - add ebp, [putimg.winmap_newline];[Screen_Max_X] + add edx, [putimg.screen_newline] + add ebp, [putimg.winmap_newline] cmp [putimg.ebp], putimage_get1bpp jz .correct @@ -464,54 +661,52 @@ align 4 jz .correct cmp [putimg.ebp], putimage_get4bpp jnz @f -;-------------------------------------- -align 4 -.correct: + + .correct: mov eax, [putimg.edi] mov byte [eax], 80h -;-------------------------------------- -align 4 -@@: + + @@: dec edi jnz .new_line jmp put_image_end_24.finish + ;------------------------------------------------------------------------------ + align 4 put_image_end_32: + mov edi, [putimg.real_sy] -;-------------------------------------- + ; check for hardware cursor mov ecx, [_display.select_cursor] cmp ecx, select_cursor je put_image_end_32_new cmp ecx, 0 je put_image_end_32_old -;-------------------------------------- -align 4 -.new_line: + + .new_line: mov ecx, [putimg.real_sx] -;-------------------------------------- -align 4 -.new_x: + + .new_x: push [putimg.edi] mov eax, [putimg.ebp+4] call eax cmp [ebp], bl jne .skip -;-------------------------------------- -; store to real LFB + +; store to LFB mov [LFB_BASE+edx], eax -;-------------------------------------- -align 4 -.skip: + + .skip: add edx, 4 inc ebp dec ecx jnz .new_x add esi, [putimg.line_increment] - add edx, [putimg.screen_newline];[BytesPerScanLine] - add ebp, [putimg.winmap_newline];[Screen_Max_X] + add edx, [putimg.screen_newline] + add ebp, [putimg.winmap_newline] cmp [putimg.ebp], putimage_get1bpp jz .correct @@ -519,47 +714,40 @@ align 4 jz .correct cmp [putimg.ebp], putimage_get4bpp jnz @f -;-------------------------------------- -align 4 -.correct: + + .correct: mov eax, [putimg.edi] mov byte [eax], 80h -;-------------------------------------- -align 4 -@@: + + @@: dec edi jnz .new_line -;-------------------------------------- -align 4 -.finish: + + .finish: add esp, putimg.stack_data popad cmp [SCR_MODE], 0x12 jne @f call VGA__putimage -;-------------------------------------- -align 4 -@@: + @@: mov [EGA_counter], 1 ret + ;------------------------------------------------------------------------------ + align 4 put_image_end_32_old: -;-------------------------------------- -align 4 -.new_line: + + .new_line: mov ecx, [putimg.real_sx] -;-------------------------------------- -align 4 -.new_x: + .new_x: push [putimg.edi] mov eax, [putimg.ebp+4] call eax cmp [ebp], bl jne .skip -;-------------------------------------- - push ecx + push ecx neg ecx add ecx, [putimg.real_sx_and_abs_cx + 4] shl ecx, 16 @@ -569,19 +757,18 @@ align 4 ; check mouse area for putpixel call check_mouse_area_for_putpixel pop ecx -; store to real LFB +; store to LFB mov [LFB_BASE+edx], eax -;-------------------------------------- -align 4 -.skip: + + .skip: add edx, 4 inc ebp dec ecx jnz .new_x add esi, [putimg.line_increment] - add edx, [putimg.screen_newline];[BytesPerScanLine] - add ebp, [putimg.winmap_newline];[Screen_Max_X] + add edx, [putimg.screen_newline] + add ebp, [putimg.winmap_newline] cmp [putimg.ebp], putimage_get1bpp jz .correct @@ -589,83 +776,76 @@ align 4 jz .correct cmp [putimg.ebp], putimage_get4bpp jnz @f -;-------------------------------------- -align 4 -.correct: + + .correct: mov eax, [putimg.edi] mov byte [eax], 80h -;-------------------------------------- -align 4 -@@: + + @@: dec edi jnz .new_line jmp put_image_end_32.finish + ;------------------------------------------------------------------------------ + align 4 put_image_end_32_new: -;-------------------------------------- -align 4 -.new_line: + + .new_line: mov ecx, [putimg.real_sx] -;-------------------------------------- -align 4 -.new_x: + + .new_x: push [putimg.edi] mov eax, [putimg.ebp+4] call eax cmp [ebp], bl jne .skip -;-------------------------------------- + push ecx -;-------------------------------------- -align 4 -.sh: + + .sh: neg ecx add ecx, [putimg.real_sx_and_abs_cx + 4] -;-------------------------------------- + ; check for X cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] jae .no_mouse_area - sub cx, [X_UNDER_subtraction_CUR_hot_x] jb .no_mouse_area - shl ecx, 16 add ecx, [putimg.real_sy_and_abs_cy + 4] sub ecx, edi -;-------------------------------------- + ; check for Y cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] jae .no_mouse_area - sub cx, [Y_UNDER_subtraction_CUR_hot_y] jb .no_mouse_area -;-------------------------------------- + ; check mouse area for putpixel call check_mouse_area_for_putpixel_new.1 - cmp ecx, -1 ;SHIT HAPPENS? + cmp ecx, -1 ; SHIT HAPPENS? jne .no_mouse_area mov ecx, [esp] jmp .sh -;-------------------------------------- -align 4 -.no_mouse_area: + + .no_mouse_area: pop ecx -; store to real LFB + +; store to LFB mov [LFB_BASE+edx], eax -;-------------------------------------- -align 4 -.skip: + + .skip: add edx, 4 inc ebp dec ecx jnz .new_x add esi, [putimg.line_increment] - add edx, [putimg.screen_newline];[BytesPerScanLine] - add ebp, [putimg.winmap_newline];[Screen_Max_X] + add edx, [putimg.screen_newline] + add ebp, [putimg.winmap_newline] cmp [putimg.ebp], putimage_get1bpp jz .correct @@ -673,72 +853,155 @@ align 4 jz .correct cmp [putimg.ebp], putimage_get4bpp jnz @f -;-------------------------------------- -align 4 -.correct: + + .correct: mov eax, [putimg.edi] mov byte [eax], 80h -;-------------------------------------- -align 4 -@@: + + @@: dec edi jnz .new_line jmp put_image_end_32.finish + ;------------------------------------------------------------------------------ +; eax = x coordinate +; ebx = y coordinate +; ecx = xx RR GG BB +; xx flags: +; 0x01000000 color inversion +; 0x02000000 used for draw_rectangle without top line (for drawwindow_III and drawwindow_IV) +; edi = 0x00000001 force + align 4 __sys_putpixel: -; eax = x coordinate -; ebx = y coordinate -; ecx = ?? RR GG BB ; 0x01000000 negation - ; 0x02000000 used for draw_rectangle without top line - ; for example drawwindow_III and drawwindow_IV -; edi = 0x00000001 force - -;;; mov [novesachecksum], dword 0 pushad cmp [Screen_Max_X], eax jb .exit cmp [Screen_Max_Y], ebx jb .exit - test edi, 1 ; force ? + test edi, 1 ; force ? jnz .forced -; not forced: +; not forced mov edx, [d_width_calc_area + ebx*4] add edx, [_WinMapAddress] movzx edx, byte [eax+edx] cmp edx, [CURRENT_TASK] jne .exit -;-------------------------------------- -align 4 -.forced: -; check if negation + + .forced: +; check for color inversion test ecx, 0x01000000 - jz .noneg + jz .no_inv + + push eax ebx edx edi + call [GETPIXEL] + pop edi edx ebx eax - call getpixel not ecx - rol ecx, 8 mov cl, [esp+32-8+3] ror ecx, 8 mov [esp+32-8], ecx -;-------------------------------------- -align 4 -.noneg: -; OK to set pixel - call dword [PUTPIXEL]; call the real put_pixel function -;-------------------------------------- -align 4 -.exit: + .no_inv: + call [PUTPIXEL] ; call the real put_pixel function + .exit: popad ret + ;----------------------------------------------------------------------------- +; eax = x +; ebx = y + +align 4 +Vesa20_putpixel16: + + mov ecx, eax + shl ecx, 16 + mov cx, bx + +; imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier + mov ebx, [BPSLine_calc_area+ebx*4] + lea edi, [eax*2]; edi = x*2 + mov eax, [esp+32-8+4] + +; check for hardware cursor + cmp [_display.select_cursor], 0 + jne @f +; check mouse area for putpixel + test eax, 0x04000000 + jnz @f + call check_mouse_area_for_putpixel + @@: +; store to LFB + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + + mov [LFB_BASE+ebx+edi], ax + ret + +;----------------------------------------------------------------------------- +; eax = x +; ebx = y + +align 4 +Vesa20_putpixel16_new: + + mov ecx, eax + shl ecx, 16 + mov cx, bx + +; imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier + mov ebx, [BPSLine_calc_area+ebx*4] + lea edi, [eax*2]; edi = x*2 + mov eax, [esp+32-8+4] + +; check for hardware cursor + cmp [_display.select_cursor], select_cursor + jne @f +; check mouse area for putpixel + test eax, 0x04000000 + jnz @f + +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae @f + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb @f + rol ecx, 16 + +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae @f + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb @f + ror ecx, 16 + + call check_mouse_area_for_putpixel_new.1 + @@: +; store to LFB + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + + mov [LFB_BASE+ebx+edi], ax + ret + +;----------------------------------------------------------------------------- +; eax = x +; ebx = y + align 4 Vesa20_putpixel24: -; eax = x -; ebx = y + mov ecx, eax shl ecx, 16 mov cx, bx @@ -747,7 +1010,7 @@ Vesa20_putpixel24: mov ebx, [BPSLine_calc_area+ebx*4] lea edi, [eax+eax*2]; edi = x*3 mov eax, [esp+32-8+4] -;-------------------------------------- + ; check for hardware cursor cmp [_display.select_cursor], 0 jne @f @@ -755,19 +1018,21 @@ Vesa20_putpixel24: test eax, 0x04000000 jnz @f call check_mouse_area_for_putpixel -;-------------------------------------- -align 4 -@@: -; store to real LFB + @@: + +; store to LFB mov [LFB_BASE+ebx+edi], ax shr eax, 16 mov [LFB_BASE+ebx+edi+2], al ret + ;----------------------------------------------------------------------------- +; eax = x +; ebx = y + align 4 Vesa20_putpixel24_new: -; eax = x -; ebx = y + mov ecx, eax shl ecx, 16 mov cx, bx @@ -776,55 +1041,52 @@ Vesa20_putpixel24_new: mov ebx, [BPSLine_calc_area+ebx*4] lea edi, [eax+eax*2]; edi = x*3 mov eax, [esp+32-8+4] -;-------------------------------------- + ; check for hardware cursor cmp [_display.select_cursor], select_cursor jne @f ; check mouse area for putpixel test eax, 0x04000000 jnz @f -;-------------------------------------- + ; check for Y cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] jae @f - sub cx, [Y_UNDER_subtraction_CUR_hot_y] jb @f - rol ecx, 16 -;-------------------------------------- + ; check for X cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] jae @f - sub cx, [X_UNDER_subtraction_CUR_hot_x] jb @f - ror ecx, 16 call check_mouse_area_for_putpixel_new.1 -;-------------------------------------- -align 4 -@@: -; store to real LFB + @@: +; store to LFB mov [LFB_BASE+ebx+edi], ax shr eax, 16 mov [LFB_BASE+ebx+edi+2], al ret + ;----------------------------------------------------------------------------- -align 4 -Vesa20_putpixel32: ; eax = x ; ebx = y + +align 4 +Vesa20_putpixel32: + mov ecx, eax shl ecx, 16 mov cx, bx ; imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier mov ebx, [BPSLine_calc_area+ebx*4] - lea edi, [ebx+eax*4]; edi = x*4+(y*y multiplier) - mov eax, [esp+32-8+4]; eax = color -;-------------------------------------- + lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier) + mov eax, [esp+32-8+4] ; eax = color + ; check for hardware cursor cmp [_display.select_cursor], 0 jne @f @@ -832,61 +1094,58 @@ Vesa20_putpixel32: test eax, 0x04000000 jnz @f call check_mouse_area_for_putpixel -;-------------------------------------- -align 4 -@@: + @@: and eax, 0xffffff -; store to real LFB +; store to LFB mov [LFB_BASE+edi], eax ret + ;----------------------------------------------------------------------------- -align 4 -Vesa20_putpixel32_new: ; eax = x ; ebx = y + +align 4 +Vesa20_putpixel32_new: + mov ecx, eax shl ecx, 16 mov cx, bx ; imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier mov ebx, [BPSLine_calc_area+ebx*4] - lea edi, [ebx+eax*4]; edi = x*4+(y*y multiplier) - mov eax, [esp+32-8+4]; eax = color -;-------------------------------------- + lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier) + mov eax, [esp+32-8+4] ; eax = color + ; check for hardware cursor cmp [_display.select_cursor], select_cursor jne @f ; check mouse area for putpixel test eax, 0x04000000 jnz @f -;-------------------------------------- + ; check for Y cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] jae @f - sub cx, [Y_UNDER_subtraction_CUR_hot_y] jb @f - rol ecx, 16 -;-------------------------------------- + ; check for X cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] jae @f - sub cx, [X_UNDER_subtraction_CUR_hot_x] jb @f - ror ecx, 16 call check_mouse_area_for_putpixel_new.1 -;-------------------------------------- -align 4 -@@: - and eax, 0xffffff -; store to real LFB + @@: + and eax, 0x00ffffff +; store to LFB mov [LFB_BASE+edi], eax ret + ;----------------------------------------------------------------------------- + align 4 calculate_edi: ; mov edi, ebx @@ -895,19 +1154,18 @@ calculate_edi: mov edi, [d_width_calc_area + ebx*4] add edi, eax ret + + ;----------------------------------------------------------------------------- ; DRAWLINE ;----------------------------------------------------------------------------- -align 4 -__sys_draw_line: -; draw a line -; eax = HIWORD = x1 -; LOWORD = x2 -; ebx = HIWORD = y1 -; LOWORD = y2 +; eax = x1 shl 16 + x2 +; ebx = y1 shl 16 + y2 ; ecx = color ; edi = force ? - pusha + +align 4 +__sys_draw_line: dl_x1 equ esp+20 dl_y1 equ esp+16 @@ -916,51 +1174,49 @@ dl_y2 equ esp+8 dl_dx equ esp+4 dl_dy equ esp+0 - xor edx, edx ; clear edx - xor esi, esi ; unpack arguments + pusha + + xor edx, edx ; clear edx + xor esi, esi ; unpack arguments xor ebp, ebp - mov si, ax ; esi = x2 - mov bp, bx ; ebp = y2 - shr eax, 16 ; eax = x1 - shr ebx, 16 ; ebx = y1 - push eax ; save x1 - push ebx ; save y1 - push esi ; save x2 - push ebp ; save y2 + mov si, ax ; esi = x2 + mov bp, bx ; ebp = y2 + shr eax, 16 ; eax = x1 + shr ebx, 16 ; ebx = y1 + push eax ; save x1 + push ebx ; save y1 + push esi ; save x2 + push ebp ; save y2 ; checking x-axis... - sub esi, eax ; esi = x2-x1 - push esi ; save y2-y1 - jl .x2lx1 ; is x2 less than x1 ? - jg .no_vline ; x1 > x2 ? - mov edx, ebp ; else (if x1=x2) + sub esi, eax ; esi = x2-x1 + push esi ; save y2-y1 + jl .x2lx1 ; is x2 less than x1 ? + jg .no_vline ; x1 > x2 ? + mov edx, ebp ; else (if x1=x2) call vline - push edx ; necessary to rightly restore stack frame at .exit + push edx ; necessary to rightly restore stack frame at .exit jmp .exit -;-------------------------------------- -align 4 -.x2lx1: - neg esi ; get esi absolute value -;-------------------------------------- -align 4 -.no_vline: + + .x2lx1: + neg esi ; get esi absolute value + + .no_vline: ; checking y-axis... - sub ebp, ebx ; ebp = y2-y1 - push ebp ; save y2-y1 - jl .y2ly1 ; is y2 less than y1 ? - jg .no_hline ; y1 > y2 ? - mov edx, [dl_x2]; else (if y1=y2) + sub ebp, ebx ; ebp = y2-y1 + push ebp ; save y2-y1 + jl .y2ly1 ; is y2 less than y1 ? + jg .no_hline ; y1 > y2 ? + mov edx, [dl_x2] ; else (if y1=y2) call hline jmp .exit -;-------------------------------------- -align 4 -.y2ly1: - neg ebp ; get ebp absolute value -;-------------------------------------- -align 4 -.no_hline: + + .y2ly1: + neg ebp ; get ebp absolute value + + .no_hline: cmp ebp, esi - jle .x_rules ; |y2-y1| < |x2-x1| ? - cmp [dl_y2], ebx; make sure y1 is at the begining + jle .x_rules ; |y2-y1| < |x2-x1| ? + cmp [dl_y2], ebx ; make sure y1 is at the begining jge .no_reverse1 neg dword [dl_dx] mov edx, [dl_x2] @@ -969,31 +1225,25 @@ align 4 mov edx, [dl_y2] mov [dl_y2], ebx mov [dl_y1], edx -;-------------------------------------- -align 4 -.no_reverse1: + + .no_reverse1: mov eax, [dl_dx] - cdq ; extend eax sing to edx - shl eax, 16 ; using 16bit fix-point maths - idiv ebp ; eax = ((x2-x1)*65536)/(y2-y1) -;-------------------------------------- + cdq ; extend eax sing to edx + shl eax, 16 ; using 16bit fix-point maths + idiv ebp ; eax = ((x2-x1)*65536)/(y2-y1) + ; correction for the remainder of the division shl edx, 1 cmp ebp, edx jb @f inc eax -;-------------------------------------- -align 4 -@@: -;-------------------------------------- - mov edx, ebp ; edx = counter (number of pixels to draw) - mov ebp, 1 *65536; <<16 ; ebp = dy = 1.0 - mov esi, eax ; esi = dx + @@: + mov edx, ebp ; edx = counter (number of pixels to draw) + mov ebp, 1 shl 16 ; ebp = dy = 1.0 + mov esi, eax ; esi = dx jmp .y_rules -;-------------------------------------- -align 4 -.x_rules: - cmp [dl_x2], eax ; make sure x1 is at the begining + .x_rules: + cmp [dl_x2], eax ; make sure x1 is at the begining jge .no_reverse2 neg dword [dl_dy] mov edx, [dl_x2] @@ -1002,61 +1252,45 @@ align 4 mov edx, [dl_y2] mov [dl_y2], ebx mov [dl_y1], edx -;-------------------------------------- -align 4 -.no_reverse2: + .no_reverse2: xor edx, edx mov eax, [dl_dy] - cdq ; extend eax sing to edx - shl eax, 16 ; using 16bit fix-point maths - idiv esi ; eax = ((y2-y1)*65536)/(x2-x1) -;-------------------------------------- + cdq ; extend eax sing to edx + shl eax, 16 ; using 16bit fix-point maths + idiv esi ; eax = ((y2-y1)*65536)/(x2-x1) ; correction for the remainder of the division shl edx, 1 cmp esi, edx jb @f inc eax -;-------------------------------------- -align 4 -@@: -;-------------------------------------- - mov edx, esi ; edx = counter (number of pixels to draw) - mov esi, 1 *65536;<< 16 ; esi = dx = 1.0 - mov ebp, eax ; ebp = dy -;-------------------------------------- -align 4 -.y_rules: + @@: + mov edx, esi ; edx = counter (number of pixels to draw) + mov esi, 1 shl 16 ; esi = dx = 1.0 + mov ebp, eax ; ebp = dy + + .y_rules: mov eax, [dl_x1] mov ebx, [dl_y1] shl eax, 16 shl ebx, 16 - and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area -;----------------------------------------------------------------------------- -align 4 -.draw: + and ecx, 0xFBFFFFFF ; negate 0x04000000 save to mouseunder area + .draw: push eax ebx -;-------------------------------------- + ; correction for the remainder of the division test ah, 0x80 jz @f add eax, 1 shl 16 -;-------------------------------------- -align 4 -@@: -;-------------------------------------- + @@: shr eax, 16 -;-------------------------------------- ; correction for the remainder of the division test bh, 0x80 jz @f add ebx, 1 shl 16 -;-------------------------------------- -align 4 -@@: -;-------------------------------------- + @@: shr ebx, 16 -; and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area +; and ecx, 0xFBFFFFFF ; negate 0x04000000 save to mouseunder area ; call [putpixel] call __sys_putpixel pop ebx eax @@ -1067,36 +1301,34 @@ align 4 ; force last drawn pixel to be at (x2,y2) mov eax, [dl_x2] mov ebx, [dl_y2] -; and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area +; and ecx, 0xFBFFFFFF ;n egate 0x04000000 save to mouseunder area ; call [putpixel] call __sys_putpixel -;-------------------------------------- -align 4 -.exit: + + .exit: add esp, 6*4 popa ; call [draw_pointer] ret + ;------------------------------------------------------------------------------ -align 4 -hline: ; draw an horizontal line ; eax = x1 ; edx = x2 ; ebx = y ; ecx = color ; edi = force ? + +align 4 +hline: + push eax edx cmp edx, eax ; make sure x2 is above x1 jge @f xchg eax, edx -;-------------------------------------- -align 4 -@@: + @@: and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area -;-------------------------------------- -align 4 -@@: + @@: ; call [putpixel] call __sys_putpixel inc eax @@ -1104,26 +1336,25 @@ align 4 jle @b pop edx eax ret + ;------------------------------------------------------------------------------ -align 4 -vline: ; draw a vertical line ; eax = x ; ebx = y1 ; edx = y2 ; ecx = color ; edi = force ? + +align 4 +vline: + push ebx edx cmp edx, ebx ; make sure y2 is above y1 jge @f xchg ebx, edx -;-------------------------------------- -align 4 -@@: + @@: and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area -;-------------------------------------- -align 4 -@@: + @@: ; call [putpixel] call __sys_putpixel inc ebx @@ -1131,8 +1362,17 @@ align 4 jle @b pop edx ebx ret + ;------------------------------------------------------------------------------ +; eax cx +; ebx cy +; ecx xe +; edx ye +; edi color + align 4 +vesa20_drawbar: + virtual at esp drbar: .bar_sx dd ? @@ -1150,61 +1390,43 @@ drbar: .real_sy_and_abs_cy dd ? .stack_data = 4*13 end virtual -;-------------------------------------- -align 4 -; eax cx -; ebx cy -; ecx xe -; edx ye -; edi color -vesa20_drawbar: + pushad sub esp, drbar.stack_data mov [drbar.color], edi sub edx, ebx - jle .exit ;// mike.dld, 2005-01-29 + jle .exit sub ecx, eax - jle .exit ;// mike.dld, 2005-01-29 + jle .exit mov [drbar.bar_sy], edx mov [drbar.bar_sx], ecx mov [drbar.bar_cx], eax mov [drbar.bar_cy], ebx mov edi, [TASK_BASE] - add eax, [edi-twdw + WDATA.box.left]; win_cx - add ebx, [edi-twdw + WDATA.box.top]; win_cy + add eax, [edi-twdw + WDATA.box.left] ; win_cx + add ebx, [edi-twdw + WDATA.box.top] ; win_cy mov [drbar.abs_cx], eax mov [drbar.abs_cy], ebx ; real_sx = MIN(wnd_sx-bar_cx, bar_sx); - mov ebx, [edi-twdw + WDATA.box.width]; ebx = wnd_sx -; \begin{diamond}[20.08.2006] -; note that WDATA.box.width is one pixel less than real window x-size - inc ebx -; \end{diamond}[20.08.2006] + mov ebx, [edi-twdw + WDATA.box.width] ; ebx = wnd_sx + inc ebx ; WDATA.box.width is one pixel less than real window x-size sub ebx, [drbar.bar_cx] ja @f -;-------------------------------------- -align 4 -.exit: ;// mike.dld, 2005-01-29 + .exit: add esp, drbar.stack_data popad xor eax, eax inc eax ret -;-------------------------------------- -align 4 -@@: + @@: cmp ebx, [drbar.bar_sx] jbe .end_x mov ebx, [drbar.bar_sx] -;-------------------------------------- -align 4 -.end_x: + .end_x: mov [drbar.real_sx], ebx ; real_sy = MIN(wnd_sy-bar_cy, bar_sy); - mov ebx, [edi-twdw + WDATA.box.height]; ebx = wnd_sy -; \begin{diamond}[20.08.2006] + mov ebx, [edi-twdw + WDATA.box.height] ; ebx = wnd_sy inc ebx -; \end{diamond} sub ebx, [drbar.bar_cy] ja @f add esp, drbar.stack_data @@ -1212,15 +1434,11 @@ align 4 xor eax, eax inc eax ret -;-------------------------------------- -align 4 -@@: + @@: cmp ebx, [drbar.bar_sy] jbe .end_y mov ebx, [drbar.bar_sy] -;-------------------------------------- -align 4 -.end_y: + .end_y: mov [drbar.real_sy], ebx ; line_inc_map mov eax, [Screen_Max_X] @@ -1229,8 +1447,7 @@ align 4 mov [drbar.line_inc_map], eax ; line_inc_scr mov eax, [drbar.real_sx] - mov ebx, [_display.bpp] - shr ebx, 3 + mov ebx, [_display.bytes_per_pixel] imul eax, ebx neg eax add eax, [_display.pitch] @@ -1251,7 +1468,7 @@ align 4 add eax, [drbar.abs_cx] add eax, [_WinMapAddress] xchg eax, ebp -;-------------------------------------- + mov ebx, [drbar.real_sx] add ebx, [drbar.abs_cx] mov [drbar.real_sx_and_abs_cx], ebx @@ -1260,7 +1477,7 @@ align 4 mov [drbar.real_sy_and_abs_cy], ebx add edx, LFB_BASE -;-------------------------------------- + ; get process number mov ebx, [CURRENT_TASK] ; bl - process num mov esi, [drbar.real_sy] @@ -1268,41 +1485,42 @@ align 4 rol eax, 8 mov bh, al ; 0x80 drawing gradient bars ror eax, 8 - cmp byte [_display.bpp], 24 - jne draw_bar_end_32 + + cmp byte [_display.bits_per_pixel], 16 + je draw_bar_end_16 + cmp byte [_display.bits_per_pixel], 24 + je draw_bar_end_24 + cmp byte [_display.bits_per_pixel], 32 + je draw_bar_end_32 + ;-------------------------------------- -align 4 -draw_bar_end_24: ; eax - color high RRGGBB ; bl - process num ; ecx - temp ; edx - pointer to screen ; esi - counter ; edi - counter -;-------------------------------------- + +align 4 +draw_bar_end_24: + ; check for hardware cursor mov ecx, [_display.select_cursor] cmp ecx, select_cursor je draw_bar_end_24_new cmp ecx, 0 je draw_bar_end_24_old -;-------------------------------------- -align 4 -.new_y: + .new_y: mov edi, [drbar.real_sx] -;-------------------------------------- -align 4 -.new_x: + .new_x: cmp byte [ebp], bl jne .skip -;-------------------------------------- -; store to real LFB + +; store to LFB mov [edx], ax shr eax, 16 mov [edx + 2], al -;-------------------------------------- -align 4 -.skip: + .skip: ; add pixel add edx, 3 inc ebp @@ -1317,31 +1535,26 @@ align 4 test al, al jz @f dec al -;-------------------------------------- -align 4 -@@: + @@: dec esi jnz .new_y -;-------------------------------------- -align 4 -.end: + .end: add esp, drbar.stack_data popad xor eax, eax ret + ;------------------------------------------------------------------------------ + align 4 draw_bar_end_24_old: -;-------------------------------------- -align 4 -.new_y: + + .new_y: mov edi, [drbar.real_sx] -;-------------------------------------- -align 4 -.new_x: + .new_x: cmp byte [ebp], bl jne .skip -;-------------------------------------- + mov ecx, [drbar.real_sx_and_abs_cx] sub ecx, edi shl ecx, 16 @@ -1349,14 +1562,12 @@ align 4 sub ecx, esi ; check mouse area for putpixel call check_mouse_area_for_putpixel -; store to real LFB +; store to LFB mov [edx], ax shr eax, 16 mov [edx + 2], al mov eax, [drbar.color] -;-------------------------------------- -align 4 -.skip: + .skip: ; add pixel add edx, 3 inc ebp @@ -1371,48 +1582,41 @@ align 4 test al, al jz @f dec al -;-------------------------------------- -align 4 -@@: + @@: dec esi jnz .new_y jmp draw_bar_end_24.end + ;------------------------------------------------------------------------------ + align 4 draw_bar_end_24_new: -;-------------------------------------- -align 4 -.new_y: + + .new_y: mov edi, [drbar.real_sx] -;-------------------------------------- -align 4 -.new_x: + .new_x: cmp byte [ebp], bl jne .skip -;-------------------------------------- + mov ecx, [drbar.real_sy_and_abs_cy] sub ecx, esi -;-------------------------------------- + ; check for Y cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] jae .no_mouse_area - sub cx, [Y_UNDER_subtraction_CUR_hot_y] jb .no_mouse_area - rol ecx, 16 add ecx, [drbar.real_sx_and_abs_cx] sub ecx, edi -;-------------------------------------- + ; check for X cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] jae .no_mouse_area - sub cx, [X_UNDER_subtraction_CUR_hot_x] jb .no_mouse_area - ror ecx, 16 -;-------------------------------------- + ; check mouse area for putpixel push eax call check_mouse_area_for_putpixel_new.1 @@ -1421,115 +1625,102 @@ align 4 mov [edx + 2], al pop eax jmp .skip -; store to real LFB -;-------------------------------------- -align 4 -.no_mouse_area: + + .no_mouse_area: +; store to LFB mov [edx], ax ror eax, 16 mov [edx + 2], al rol eax, 16 -;-------------------------------------- -align 4 -.skip: + .skip: + ; add pixel add edx, 3 inc ebp dec edi jnz .new_x + ; add line add edx, [drbar.line_inc_scr] add ebp, [drbar.line_inc_map] + ; drawing gradient bars test bh, 0x80 jz @f test al, al jz @f dec al -;-------------------------------------- -align 4 -@@: + @@: dec esi jnz .new_y jmp draw_bar_end_24.end + ;------------------------------------------------------------------------------ -align 4 -draw_bar_end_32: ; eax - color high RRGGBB ; bl - process num ; ecx - temp ; edx - pointer to screen ; esi - counter ; edi - counter -;-------------------------------------- + +draw_bar_end_32: + ; check for hardware cursor mov ecx, [_display.select_cursor] cmp ecx, select_cursor je draw_bar_end_32_new cmp ecx, 0 je draw_bar_end_32_old -;-------------------------------------- -align 4 -.new_y: + + .new_y: mov edi, [drbar.real_sx] -;-------------------------------------- -align 4 -.new_x: + .new_x: cmp byte [ebp], bl jne .skip -;-------------------------------------- -; store to real LFB + +; store to LFB mov [edx], eax mov eax, [drbar.color] -;-------------------------------------- -align 4 -.skip: + .skip: + ; add pixel add edx, 4 inc ebp dec edi jnz .new_x + ; add line add edx, [drbar.line_inc_scr] add ebp, [drbar.line_inc_map] + ; drawing gradient bars test bh, 0x80 jz @f test al, al jz @f dec al -;-------------------------------------- -align 4 -@@: + @@: dec esi jnz .new_y -;-------------------------------------- -align 4 -.end: + .end: add esp, drbar.stack_data popad cmp [SCR_MODE], 0x12 jne @f call VGA_draw_bar -;-------------------------------------- -align 4 -@@: + @@: xor eax, eax mov [EGA_counter], 1 ret -;------------------------------------------------------------------------------ -align 4 + draw_bar_end_32_old: -;-------------------------------------- -align 4 -.new_y: + + .new_y: mov edi, [drbar.real_sx] -;-------------------------------------- -align 4 -.new_x: + .new_x: cmp byte [ebp], bl jne .skip -;-------------------------------------- + mov ecx, [drbar.real_sx_and_abs_cx] sub ecx, edi shl ecx, 16 @@ -1538,12 +1729,10 @@ align 4 ; check mouse area for putpixel call check_mouse_area_for_putpixel -; store to real LFB +; store to LFB mov [edx], eax mov eax, [drbar.color] -;-------------------------------------- -align 4 -.skip: + .skip: ; add pixel add edx, 4 inc ebp @@ -1558,67 +1747,112 @@ align 4 test al, al jz @f dec al -;-------------------------------------- -align 4 -@@: + @@: dec esi jnz .new_y jmp draw_bar_end_32.end + ;------------------------------------------------------------------------------ + align 4 draw_bar_end_32_new: -;-------------------------------------- -align 4 -.new_y: + + .new_y: mov edi, [drbar.real_sx] -;-------------------------------------- -align 4 -.new_x: + .new_x: cmp byte [ebp], bl jne .skip -;-------------------------------------- + mov ecx, [drbar.real_sy_and_abs_cy] sub ecx, esi -;-------------------------------------- + ; check for Y cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] jae .no_mouse_area - sub cx, [Y_UNDER_subtraction_CUR_hot_y] jb .no_mouse_area - rol ecx, 16 add ecx, [drbar.real_sx_and_abs_cx] sub ecx, edi -;-------------------------------------- + ; check for X cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] jae .no_mouse_area - sub cx, [X_UNDER_subtraction_CUR_hot_x] jb .no_mouse_area - ror ecx, 16 -;-------------------------------------- + ; check mouse area for putpixel push eax call check_mouse_area_for_putpixel_new.1 mov [edx], eax pop eax jmp .skip -; store to real LFB -;-------------------------------------- -align 4 -.no_mouse_area: + .no_mouse_area: + +; store to LFB mov [edx], eax -;-------------------------------------- -align 4 -.skip: + .skip: + ; add pixel add edx, 4 inc ebp dec edi jnz .new_x + +; add line + add edx, [drbar.line_inc_scr] + add ebp, [drbar.line_inc_map] + +; drawing gradient bars + test bh, 0x80 + jz @f + test al, al + jz @f + dec al + @@: + dec esi + jnz .new_y + jmp draw_bar_end_32.end + +;------------------------------------------------------------------------------ +; eax - color high RRGGBB +; bl - process num +; ecx - temp +; edx - pointer to screen +; esi - counter +; edi - counter + +align 4 +draw_bar_end_16: + +; check for hardware cursor + mov ecx, [_display.select_cursor] + cmp ecx, select_cursor + je draw_bar_end_16_new + cmp ecx, 0 + je draw_bar_end_16_old + .new_y: + mov edi, [drbar.real_sx] + .new_x: + cmp byte [ebp], bl + jne .skip +; convert to 16 bpp and store to LFB + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + mov [edx], ax + mov eax, [drbar.color] + .skip: + +; add pixel + add edx, 2 + inc ebp + dec edi + jnz .new_x ; add line add edx, [drbar.line_inc_scr] add ebp, [drbar.line_inc_map] @@ -1628,37 +1862,176 @@ align 4 test al, al jz @f dec al -;-------------------------------------- -align 4 -@@: + @@: dec esi jnz .new_y - jmp draw_bar_end_32.end + .end: + add esp, drbar.stack_data + popad + cmp [SCR_MODE], 0x12 + jne @f + call VGA_draw_bar + @@: + xor eax, eax + mov [EGA_counter], 1 + ret + ;------------------------------------------------------------------------------ + +align 4 +draw_bar_end_16_old: + + .new_y: + mov edi, [drbar.real_sx] + .new_x: + cmp byte [ebp], bl + jne .skip + + mov ecx, [drbar.real_sx_and_abs_cx] + sub ecx, edi + shl ecx, 16 + add ecx, [drbar.real_sy_and_abs_cy] + sub ecx, esi + +; check mouse area for putpixel + call check_mouse_area_for_putpixel +; convert to 16 bpp and store to LFB + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + mov [edx], ax + mov eax, [drbar.color] +.skip: + +; add pixel + add edx, 2 + inc ebp + dec edi + jnz .new_x + +; add line + add edx, [drbar.line_inc_scr] + add ebp, [drbar.line_inc_map] + +; drawing gradient bars + test bh, 0x80 + jz @f + test al, al + jz @f + dec al + @@: + dec esi + jnz .new_y + jmp draw_bar_end_16.end + +;------------------------------------------------------------------------------ + +align 4 +draw_bar_end_16_new: + + .new_y: + mov edi, [drbar.real_sx] + .new_x: + cmp byte [ebp], bl + jne .skip + + mov ecx, [drbar.real_sy_and_abs_cy] + sub ecx, esi + +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae .no_mouse_area + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb .no_mouse_area + rol ecx, 16 + add ecx, [drbar.real_sx_and_abs_cx] + sub ecx, edi + +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae .no_mouse_area + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb .no_mouse_area + ror ecx, 16 + +; check mouse area for putpixel + push eax + call check_mouse_area_for_putpixel_new.1 + push eax + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + mov [edx], ax + pop eax + pop eax + jmp .skip + + .no_mouse_area: +; convert to 16 bpp and store to LFB + push eax + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + mov [edx], ax + pop eax + .skip: + +; add pixel + add edx, 2 + inc ebp + dec edi + jnz .new_x + +; add line + add edx, [drbar.line_inc_scr] + add ebp, [drbar.line_inc_map] + +; drawing gradient bars + test bh, 0x80 + jz @f + test al, al + jz @f + dec al + @@: + dec esi + jnz .new_y + jmp draw_bar_end_16.end + +;------------------------------------------------------------------------------ + align 4 vesa20_drawbackground_tiled: + pushad ; External loop for all y from start to end mov ebx, [draw_data+32+RECT.top] ; y start -;-------------------------------------- -align 4 -dp2: + dp2: mov ebp, [draw_data+32+RECT.left] ; x start ; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp] -; and LFB data (output for our function) [edi] +; and LFB data (output for our function) [edi] ; mov eax, [BytesPerScanLine] ; mul ebx mov eax, [BPSLine_calc_area+ebx*4] xchg ebp, eax add ebp, eax add ebp, eax + cmp byte [_display.bytes_per_pixel], 2 + je @f add ebp, eax - cmp byte [_display.bpp], 24 ; 24 or 32 bpp ? - x size - jz @f + cmp byte [_display.bytes_per_pixel], 3 + je @f add ebp, eax -;-------------------------------------- -align 4 -@@: + + @@: add ebp, LFB_BASE ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB call calculate_edi @@ -1691,14 +2064,11 @@ align 4 ; edx = 1 ; esi -> bgr memory, edi -> output ; ebp = offset in WinMapAddress -;-------------------------------------- -align 4 -dp3: + dp3: cmp [ebp], dl - jnz nbgp -;-------------------------------------- - push eax ecx + jnz .next_pix + push eax ecx mov ecx, eax shl ecx, 16 add ecx, ebx @@ -1710,47 +2080,52 @@ dp3: je @f cmp [_display.select_cursor], 0 jne .no_mouseunder -;-------------------------------------- -align 4 -@@: + @@: and eax, 0xffffff ; check mouse area for putpixel call [_display.check_mouse] -;-------------------------------------- -align 4 -.no_mouseunder: -; store to real LFB + .no_mouseunder: + + cmp byte [_display.bits_per_pixel], 16 + je .16bpp +; store to LFB mov [edi], ax shr eax, 16 mov [edi+2], al - pop ecx eax -;-------------------------------------- -align 4 -nbgp: + jmp .next_pix + + .16bpp: +; convert to 16 bpp and store to LFB + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + mov [edi], ax + pop ecx eax + +; Advance to next pixel + .next_pix: add esi, 3 - add edi, 3 -;-------------------------------------- -align 4 -@@: - cmp byte [_display.bpp], 25 ; 24 or 32 bpp? - sbb edi, -1 ; +1 for 32 bpp -; I do not use 'inc eax' because this is slightly slower then 'add eax,1' + add edi, [_display.bytes_per_pixel] + add ebp, edx add eax, edx cmp eax, [draw_data+32+RECT.right] ja dp4 sub ecx, edx jnz dp3 + ; next tile block on x-axis mov ecx, [BgrDataWidth] sub esi, ecx sub esi, ecx sub esi, ecx jmp dp3 -;-------------------------------------- -align 4 -dp4: + + dp4: ; next scan line inc ebx cmp ebx, [draw_data+32+RECT.bottom] @@ -1760,13 +2135,14 @@ dp4: cmp [SCR_MODE], 0x12 jne @f call VGA_drawbackground -;-------------------------------------- -align 4 -@@: + @@: ret + ;------------------------------------------------------------------------------ + align 4 vesa20_drawbackground_stretch: + pushad ; Helper variables ; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1) @@ -1778,6 +2154,7 @@ vesa20_drawbackground_stretch: xor eax, eax div dword [Screen_Max_X] push eax ; low + ; the same for height mov eax, [BgrDataHeight] dec eax @@ -1787,6 +2164,7 @@ vesa20_drawbackground_stretch: xor eax, eax div dword [Screen_Max_Y] push eax ; low + ; External loop for all y from start to end mov ebx, [draw_data+32+RECT.top] ; y start mov ebp, [draw_data+32+RECT.left] ; x start @@ -1798,16 +2176,18 @@ vesa20_drawbackground_stretch: xchg ebp, eax add ebp, eax add ebp, eax - add ebp, eax - cmp byte [_display.bpp], 24 ; 24 or 32 bpp ? - x size + cmp byte [_display.bytes_per_pixel], 2 jz @f add ebp, eax -;-------------------------------------- -align 4 -@@: + cmp byte [_display.bytes_per_pixel], 3 + jz @f + add ebp, eax + @@: + ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB call calculate_edi xchg edi, ebp + ; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress push ebx push eax @@ -1833,19 +2213,17 @@ align 4 push eax push edx push esi + ; 3) Smooth horizontal -;-------------------------------------- -align 4 -bgr_resmooth0: + bgr_resmooth0: mov ecx, [esp+8] mov edx, [esp+4] mov esi, [esp] push edi mov edi, bgr_cur_line call smooth_line -;-------------------------------------- -align 4 -bgr_resmooth1: + + bgr_resmooth1: mov eax, [esp+16+4] inc eax cmp eax, [BgrDataHeight] @@ -1858,15 +2236,14 @@ bgr_resmooth1: add esi, [BgrDataWidth] mov edi, bgr_next_line call smooth_line -;-------------------------------------- -align 4 -bgr.no2nd: + + bgr.no2nd: pop edi -;-------------------------------------- -align 4 -sdp3: + + sdp3: xor esi, esi mov ecx, [esp+12] + ; 4) Loop through redraw rectangle and copy background data ; Registers meaning: ; esi = offset in current line, edi -> output @@ -1879,9 +2256,8 @@ sdp3: ; precalculated constants: ; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1) ; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1) -;-------------------------------------- -align 4 -sdp3a: + + sdp3a: mov eax, [_WinMapAddress] cmp [ebp+eax], byte 1 jnz snbgp @@ -1890,36 +2266,44 @@ sdp3a: jz .novert mov ebx, [bgr_next_line+esi] call [overlapping_of_points_ptr] -;-------------------------------------- -align 4 -.novert: + + .novert: push ecx ; check for hardware cursor cmp [_display.select_cursor], select_cursor je @f cmp [_display.select_cursor], 0 jne .no_mouseunder -;-------------------------------------- -align 4 -@@: + @@: mov ecx, [esp+20+4] ;x shl ecx, 16 add ecx, [esp+24+4] ;y ; check mouse area for putpixel call [_display.check_mouse] -;-------------------------------------- -align 4 -.no_mouseunder: -; store to real LFB + .no_mouseunder: + + cmp [_display.bits_per_pixel], 16 + jne .not_16bpp +; convert to 16 bpp and store to LFB + and eax, 00000000111110001111110011111000b + shr ah, 2 + shr ax, 3 + ror eax, 8 + add al, ah + rol eax, 8 + mov [LFB_BASE+edi], ax + pop ecx + jmp snbgp + .not_16bpp: + +; store to LFB mov [LFB_BASE+edi], ax shr eax, 16 mov [LFB_BASE+edi+2], al pop ecx -;-------------------------------------- -align 4 -snbgp: - cmp byte [_display.bpp], 25 - sbb edi, -4 + + snbgp: + add edi, [_display.bytes_per_pixel] add ebp, 1 mov eax, [esp+20] add eax, 1 @@ -1927,15 +2311,15 @@ snbgp: add esi, 4 cmp eax, [draw_data+32+RECT.right] jbe sdp3a -;-------------------------------------- -align 4 -sdp4: + + sdp4: ; next y mov ebx, [esp+24] add ebx, 1 mov [esp+24], ebx cmp ebx, [draw_data+32+RECT.bottom] ja sdpdone + ; advance edi, ebp to next scan line sub eax, [draw_data+32+RECT.left] sub ebp, eax @@ -1943,13 +2327,14 @@ sdp4: add ebp, 1 sub edi, eax sub edi, eax - sub edi, eax - cmp byte [_display.bpp], 24 + cmp byte [_display.bytes_per_pixel], 2 jz @f sub edi, eax -;-------------------------------------- -align 4 -@@: + cmp byte [_display.bytes_per_pixel], 3 + jz @f + sub edi, eax + + @@: add edi, [_display.pitch] ; restore ecx,edx; advance esi to next background line mov eax, [esp+28] @@ -1975,28 +2360,19 @@ align 4 inc ecx rep movsd jmp bgr_resmooth1 -;-------------------------------------- -align 4 -sdpdone: + + sdpdone: add esp, 44 popad mov [EGA_counter], 1 cmp [SCR_MODE], 0x12 jne @f call VGA_drawbackground -;-------------------------------------- -align 4 -@@: + @@: ret -uglobal -;-------------------------------------- -align 4 -bgr_cur_line rd 1920 ; maximum width of screen -bgr_next_line rd 1920 -;-------------------------------------- -endg ;-------------------------------------- + align 4 smooth_line: mov al, [esi+2] @@ -2007,9 +2383,7 @@ smooth_line: mov ebx, [esi+2] shr ebx, 8 call [overlapping_of_points_ptr] -;-------------------------------------- -align 4 -@@: + @@: stosd mov eax, [esp+20+8] add eax, 1 @@ -2023,13 +2397,13 @@ align 4 lea eax, [eax*3] sub esi, eax jmp smooth_line -;-------------------------------------- -align 4 -@@: + @@: mov eax, [draw_data+32+RECT.left] mov [esp+20+8], eax ret + ;------------------------------------------------------------------------------ + align 16 overlapping_of_points: if 0 @@ -2093,27 +2467,22 @@ else ret end if -iglobal -;-------------------------------------- -align 4 -overlapping_of_points_ptr dd overlapping_of_points -;-------------------------------------- -endg + ;------------------------------------------------------------------------------ + align 4 init_background: + mov edi, BgrAuxTable xor edx, edx -;-------------------------------------- -align 4 -.loop2: + + .loop2: mov eax, edx shl eax, 8 neg eax mov ecx, 0x200 -;-------------------------------------- -align 4 -.loop1: + + .loop1: mov byte [edi], ah inc edi add eax, edx @@ -2123,13 +2492,14 @@ align 4 test byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8) jz @f mov [overlapping_of_points_ptr], overlapping_of_points_mmx -;-------------------------------------- -align 4 -@@: + @@: ret + ;------------------------------------------------------------------------------ + align 16 overlapping_of_points_mmx: + movd mm0, eax movd mm4, eax movd mm1, ebx @@ -2146,5 +2516,7 @@ overlapping_of_points_mmx: packuswb mm1, mm2 paddb mm4, mm1 movd eax, mm4 + ret + ;------------------------------------------------------------------------------