hline/vline coolhack a-la Serge

git-svn-id: svn://kolibrios.org@1708 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2010-11-24 00:40:14 +00:00
parent 1feef39077
commit c910c0615f

View File

@ -256,8 +256,8 @@ put_pixel: ; left for compatibility with Vesa20_putpixel32
; ebx = y ; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier) lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
mov eax, [esp+32-8+4] ; eax = color ; mov eax, [esp+32-8+4] ; eax = color
mov [LFB_BASE+edi], eax mov [LFB_BASE+edi], ecx
ret ret
@ -277,7 +277,6 @@ calculate_edi:
align 4 align 4
__sys_draw_line: __sys_draw_line:
; inc [mouse_pause]
call [_display.disable_mouse] call [_display.disable_mouse]
; draw a line ; draw a line
@ -306,6 +305,7 @@ dl_dy equ esp+0
push eax ; save x1 push eax ; save x1
push ebx ; save y1 push ebx ; save y1
push esi ; save x2 push esi ; save x2
push ebp ; save y2 push ebp ; save y2
; checking x-axis... ; checking x-axis...
sub esi, eax ; esi = x2-x1 sub esi, eax ; esi = x2-x1
@ -408,6 +408,9 @@ hline:
cmp ebx, [Screen_Max_Y] cmp ebx, [Screen_Max_Y]
jge .out jge .out
push eax ebp esi ebx edx push eax ebp esi ebx edx
bt ecx, 24 ; color inversion check
rcl edi,1 ; forced graphics check
mov ebp, [_display.width] ; ebp = screen co-ords base mov ebp, [_display.width] ; ebp = screen co-ords base
imul ebp, ebx imul ebp, ebx
add ebp, [_WinMapAddress] add ebp, [_WinMapAddress]
@ -425,28 +428,46 @@ hline:
mov edx, [Screen_Max_X] mov edx, [Screen_Max_X]
.draw: ; -- the line --- .draw: ; -- the line ---
test edi,1 ; forced ? jmp dword [hline.drawtable + edi*4] ; a coolhack (C) Serge
jnz .checked
; check whether the line covered by other windows align 4
movzx esi, byte [ebp+eax] .invert_color:
cmp esi, [CURRENT_TASK]
jne .nextpixel
.checked:
test ecx,0x01000000
jz .noneg
mov ecx, [ebx+eax*4] mov ecx, [ebx+eax*4]
not ecx xor ecx, 0x00FFFFFF
and ecx, 0x01FFFFFF ; keep bit[24] high ! or ecx, 0x01000000 ; keep bit[24] high !
.noneg: align 4
.check_overlap:
movzx esi, byte [ebp+eax] ; check whether the line covered by other windows
cmp esi, [CURRENT_TASK]
je .putpixel
jmp .nextpixel
align 4
.invert_force:
mov ecx, [ebx+eax*4]
xor ecx, 0x00FFFFFF
or ecx, 0x01000000 ; keep bit[24] high !
align 4
.putpixel:
mov [ebx+eax*4], ecx mov [ebx+eax*4], ecx
align 4
.nextpixel: .nextpixel:
inc eax inc eax
cmp eax, edx cmp eax, edx
jle .draw ja .exit
jmp dword [hline.drawtable + edi*4] ; close the loop
.exit: .exit:
shr edi, 1 ; restore the 'force' bit
pop edx ebx esi ebp eax pop edx ebx esi ebp eax
.out: .out:
ret ret
align 4
.drawtable:
dd .check_overlap ; general case
dd .invert_color
dd .putpixel ; force to draw it
dd .invert_force
align 4 align 4
vline: vline:
@ -481,31 +502,47 @@ vline:
jb .draw jb .draw
mov edx, [Screen_Max_Y] ; to prevent off-screen drawing mov edx, [Screen_Max_Y] ; to prevent off-screen drawing
.draw: ; (vertical line itself) .draw:
test edi,1 ; forced ? jmp dword [vline.drawtable + edi*4]
jnz .checked align 4
; check whether the line covered by other windows .invert_color:
mov ecx, [eax]
xor ecx, 0x00FFFFFF
or ecx, 0x01000000
align 4
.check_overlap:
movzx esi, byte [ebp] movzx esi, byte [ebp]
cmp esi, [CURRENT_TASK] cmp esi, [CURRENT_TASK]
jne .nextpixel je .putpixel
.checked: jmp .nextpixel
test ecx,0x01000000
jz .noneg align 4
.invert_force:
mov ecx, [eax] mov ecx, [eax]
not ecx xor ecx, 0x00FFFFFF
and ecx, 0x01FFFFFF ; keep bit[24] high ! or ecx, 0x01000000
.noneg: align 4
.putpixel:
mov [eax], ecx mov [eax], ecx
align 4
.nextpixel: .nextpixel:
add eax, [BytesPerScanLine] add eax, [BytesPerScanLine]
add ebp, [_display.width] add ebp, [_display.width]
inc ebx inc ebx
cmp ebx, edx cmp ebx, edx
jle .draw ja .exit
jmp dword [vline.drawtable + edi*4]
.exit: .exit:
shr edi, 1
pop edx ebx esi ebp eax pop edx ebx esi ebp eax
.out: .out:
ret ret
align 4
.drawtable:
dd .check_overlap ; general case
dd .invert_color
dd .putpixel ; force to draw it
dd .invert_force
;************************************************* ;*************************************************
@ -1005,20 +1042,23 @@ init_background:
align 16 align 16
overlapping_of_points_mmx: overlapping_of_points_mmx:
movd mm0, eax movd mm0, eax
movd mm4, eax movd mm4, eax
movd mm1, ebx movd mm1, ebx
pxor mm2, mm2 pxor mm2, mm2
punpcklbw mm0, mm2 punpcklbw mm0, mm2
punpcklbw mm1, mm2 punpcklbw mm1, mm2
psubw mm1, mm0 psubw mm1, mm0
movd mm3, ecx movd mm3, ecx
psrld mm3, 24 psrld mm3, 24
packuswb mm3, mm3 packuswb mm3, mm3
packuswb mm3, mm3 packuswb mm3, mm3
pmullw mm1, mm3 pmullw mm1, mm3
psrlw mm1, 8 psrlw mm1, 8
packuswb mm1, mm2 packuswb mm1, mm2
paddb mm4, mm1 paddb mm4, mm1
movd eax, mm4 movd eax, mm4
ret ret
diff16 "VESA2 code end ",0,$
diff16 "VESA2 code size",get_pixel,$