[KERNEL] fixed bug in sysfn 39.3

git-svn-id: svn://kolibrios.org@9948 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Doczom 2023-10-12 21:52:14 +00:00
parent 52ed04f5cc
commit 6643206b73
4 changed files with 75 additions and 86 deletions

View File

@ -146,12 +146,8 @@ align 4
nosb3:
cmp ebx, 4 ; TILED / STRETCHED
jnz nosb4
cmp ecx, [BgrDrawMode]
je nosb41
mov [BgrDrawMode], ecx
;--------------------------------------
align 4
nosb41:
ret
;--------------------------------------
align 4
@ -408,13 +404,6 @@ align 4
.ret:
ret
;------------------------------------------------------------------------------
align 4
.x dd ?
.y dd ?
.w dd ?
.h dd ?
.subrect_startptr dd ?
.subrect_bytes dd ?
align 4
.nogb2:
dec ebx
@ -425,77 +414,81 @@ align 4
; esi - buffer of 0x00RRGGBB
mov eax, [img_background]
cmp eax, static_background_data
jz .fail_39_3
align 4
@@:
jz .exit_39_3
sub esp, 4*3 ; local values
; get start offset
movzx eax, cx ; store y in eax
mov [.y], eax
cmp eax, [BgrDataHeight]
jae .fail_39_3
mov [esp], eax ; save y
shr ecx, 16 ; ecx = x
mov [.x], ecx
cmp ecx, [BgrDataWidth]
jae .fail_39_3
imul eax, [BgrDataWidth]
add eax, ecx
imul eax, 3
mov [.subrect_startptr], eax
mov [esp + 4*2], eax ; offset first poixel for copy
; get count pixels
movzx eax, dx ; h
shr edx, 16 ; w
add ecx, edx ; get RECT.right
cmp ecx, [BgrDataWidth]
jae .fail_39_3
; check area
mov ecx, [esp]
add ecx, eax
cmp ecx, [BgrDataHeight]
jae .fail_39_3
movzx eax, dx ; store h in eax
mov [.h], eax
mov [esp + 4], eax ; save H
mov [esp], edx ; save W
; check buffer
add eax, edx
lea eax, [eax*3]
stdcall is_region_userspace, esi, eax
jnz .fail_39_3
shr edx, 16 ; edx = w
mov [.w], edx
; loop copy lines
mov edi, esi
mov esi, [img_background]
add esi, [esp + 4*2] ; add offset start copy
xor ecx, ecx ; index in line
cmp ecx, [esp + 4] ; check H == zerro
jz .exit_39_3
xor edx, edx ; offset in line
cld
.loop:
cmp ecx, [esp] ; check ecx < W
jae @f
imul eax, edx
mov [.subrect_bytes], eax
; check bounds
mov ebx, [mem_BACKGROUND]
add ebx, PAGE_SIZE-1
and ebx, -PAGE_SIZE
sub ebx, 4
add eax, [.subrect_startptr]
cmp eax, ebx
ja .fail_39_3
; copy contents
mov edi, [img_background]
xor ecx, ecx ; ecx - row index
.copy_rect:
cmp ecx, [.h]
jae .end_copy_rect
xor edx, edx ; edx - column index
.copy_row:
cmp edx, [.w]
jae .end_copy_row
mov ebx, ecx
imul ebx, [BgrDataWidth]
add ebx, edx
imul ebx, 3
add ebx, [.subrect_startptr]
mov eax, [edi + ebx]
mov ebx, ecx
imul ebx, [.w]
add ebx, edx
mov eax, [esi + edx]
and eax, 0xFFFFFF
mov [esi + ebx*4], eax
inc edx
jmp .copy_row
.end_copy_row:
stosd ; [edi] = eax ; edi+=4;
inc ecx
jmp .copy_rect
.end_copy_rect:
add edx, 3
jmp .loop
@@:
xor edx, edx
mov eax, [BgrDataWidth]
lea esi, [esi + eax*2]
add esi, eax
mov ecx, edx
dec dword[esp + 4] ; h--
jnz .loop
; free stack
.exit_39_3:
add esp, 4*3
xor eax, eax
mov [esp + SYSCALL_STACK.eax], eax
align 4
.ret_39_3:
ret
;--------------------------------------
align 4
.fail_39_3:
add esp, 4*3
mov [esp + SYSCALL_STACK.eax], -1
ret
;--------------------------------------

View File

@ -3505,14 +3505,12 @@ drawbackground:
cmp [BgrDrawMode], dword 1
jne .bgrstr
call vesa20_drawbackground_tiled
; call [draw_pointer]
call __sys_draw_pointer
ret
;--------------------------------------
align 4
.bgrstr:
call vesa20_drawbackground_stretch
; call [draw_pointer]
call __sys_draw_pointer
ret
;-----------------------------------------------------------------------------
@ -3542,11 +3540,11 @@ align 4
;--------------------------------------
align 4
@@:
mov edi, [current_slot_idx]
shl edi, BSF sizeof.WDATA
add dx, word[window_data + edi + WDATA.clientbox.top]
mov edi, [current_slot]
mov edi, APPDATA.window
add dx, word[edi + WDATA.clientbox.top]
rol edx, 16
add dx, word[window_data + edi + WDATA.clientbox.left]
add dx, word[edi + WDATA.clientbox.left]
rol edx, 16
;--------------------------------------
align 4
@ -4199,15 +4197,13 @@ syscall_cdaudio:
;-----------------------------------------------------------------------------
align 4
syscall_getpixel_WinMap: ; GetPixel WinMap
cmp ebx, [_display.width]
jb @f
cmp ecx, [_display.height]
jb @f
xor eax, eax
jmp .store
cmp ebx, [_display.width]
jae .store
cmp ecx, [_display.height]
jae .store
;--------------------------------------
align 4
@@:
mov eax, [d_width_calc_area + ecx*4]
add eax, [_display.win_map]
movzx eax, byte[eax+ebx] ; get value for current point

View File

@ -220,7 +220,7 @@ set_framebuffer:
cli
mov [_display.current_lfb], ecx
.patch_pde:
lea edi, [eax + PROC.pdt_0 + PAGE_SIZE -32] ;last 8 pd entries up to 32Mb framebuffer
lea edi, [eax + PROC.pdt_0 + (LFB_BASE shr 20)] ;last 8 pd entries up to 32Mb framebuffer
mov ecx, 4
rep movsd ;patch pde
sub esi, 16

View File

@ -1601,7 +1601,7 @@ vesa20_drawbackground_tiled:
pushad
; External loop for all y from start to end
mov ebx, [background_window + WDATA.draw_data.top] ; y start
dp2:
.dp2:
mov ebp, [background_window + WDATA.draw_data.left] ; x start
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
; and LFB data (output for our function) [edi]
@ -1651,7 +1651,7 @@ vesa20_drawbackground_tiled:
; edx = 1
; esi -> bgr memory, edi -> output
; ebp = offset in WinMapAddress
dp3:
.dp3:
cmp [ebp], dl
jnz .next_pix
@ -1699,22 +1699,22 @@ vesa20_drawbackground_tiled:
add ebp, edx
add eax, edx
cmp eax, [background_window + WDATA.draw_data.right]
ja dp4
ja .dp4
sub ecx, edx
jnz dp3
jnz .dp3
; next tile block on x-axis
mov ecx, [BgrDataWidth]
sub esi, ecx
sub esi, ecx
sub esi, ecx
jmp dp3
jmp .dp3
dp4:
.dp4:
; next scan line
inc ebx
cmp ebx, [background_window + WDATA.draw_data.bottom]
jbe dp2
jbe .dp2
popad
mov [EGA_counter], 1
cmp [SCR_MODE], 0x12