/kernel/branches/kolibri-lldw/video/blitter.inc |
---|
0,0 → 1,536 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2011-2015. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision$ |
struct BLITTER_BLOCK |
xmin dd ? |
ymin dd ? |
xmax dd ? |
ymax dd ? |
ends |
struct BLITTER |
dc RECT |
sc RECT |
dst_x dd ? ; 32 |
dst_y dd ? ; 36 |
src_x dd ? ; 40 |
src_y dd ? ; 44 |
w dd ? ; 48 |
h dd ? ; 52 |
bitmap dd ? ; 56 |
stride dd ? ; 60 |
ends |
align 4 |
block_clip: |
;esi= clip RECT ptr |
;edi= RECT ptr |
;return code: |
;CF= 0 - draw, 1 - don't draw |
push ebx |
mov eax, [edi+RECT.left] |
mov ebx, [edi+RECT.right] |
mov ecx, [esi+RECT.left] ;clip.left |
mov edx, [esi+RECT.right] ;clip.right |
cmp eax, edx ;left >= clip.right |
jge .fail |
cmp ebx, ecx ;right < clip.left |
jl .fail |
cmp eax, ecx ;left >= clip.left |
jge @F |
mov [edi+RECT.left], ecx |
@@: |
cmp ebx, edx ;right <= clip.right |
jle @f |
mov [edi+RECT.right], edx |
@@: |
mov eax, [edi+RECT.top] |
mov ebx, [edi+RECT.bottom] |
mov ecx, [esi+RECT.top] ;clip.top |
mov edx, [esi+RECT.bottom] ;clip.bottom |
cmp eax, edx ;top >= clip.bottom |
jge .fail |
cmp ebx, ecx ;bottom < clip.top |
jl .fail |
cmp eax, ecx ;top >= clip.top |
jge @F |
mov [edi+RECT.top], ecx |
@@: |
cmp ebx, edx ;bottom <= clip.bottom |
jle @f |
mov [edi+RECT.bottom], edx |
@@: |
pop ebx |
clc |
ret |
.fail: |
pop ebx |
stc |
ret |
align 4 |
blit_clip: |
;return code: |
;CF= 0 - draw, 1 - don't draw |
.sx0 = 8 |
.sy0 = 12 |
.sx1 = 16 |
.sy1 = 20 |
.dx0 = 24 |
.dy0 = 28 |
.dx1 = 32 |
.dy1 = 36 |
push edi |
push esi |
push ebx |
sub esp, 40 |
mov ebx, ecx |
mov edx, [ecx+BLITTER.src_x] |
mov [esp+.sx0], edx |
mov eax, [ecx+BLITTER.src_y] |
mov [esp+.sy0], eax |
add edx, [ecx+BLITTER.w] |
add eax, [ecx+BLITTER.h] |
mov [esp+.sx1], edx |
mov [esp+.sy1], eax |
lea edi, [esp+.sx0] |
lea esi, [ebx+BLITTER.sc] |
call block_clip |
jc .done |
mov edi, [esp+.sx0] |
mov edx, [ebx+BLITTER.dst_x] |
add edx, edi |
sub edx, [ebx+BLITTER.src_x] |
mov [esp+.dx0], edx |
mov ecx, [esp+.sy0] |
mov eax, [ebx+BLITTER.dst_y] |
add eax, ecx |
sub eax, [ebx+BLITTER.src_y] |
mov [esp+.dy0], eax |
sub edx, edi |
add edx, [esp+.sx1] |
mov [esp+.dx1], edx |
sub eax, ecx |
add eax, [esp+.sy1] |
mov [esp+.dy1], eax |
lea edi, [esp+.dx0] |
lea esi, [ebx+BLITTER.dc] |
call block_clip |
jc .done |
mov edx, [esp+.dx0] |
mov eax, [esp+.dx1] |
sub eax, edx |
mov [ebx+BLITTER.w], eax |
mov eax, [esp+.dy0] |
mov ecx, [esp+.dy1] |
sub ecx, eax |
mov [ebx+BLITTER.h], ecx |
mov ecx, [ebx+BLITTER.src_x] |
add ecx, edx |
sub ecx, [ebx+BLITTER.dst_x] |
mov [ebx+BLITTER.src_x], ecx |
mov ecx, [ebx+BLITTER.src_y] |
add ecx, eax |
sub ecx, [ebx+BLITTER.dst_y] |
mov [ebx+BLITTER.src_y], ecx |
mov [ebx+BLITTER.dst_x], edx |
mov [ebx+BLITTER.dst_y], eax |
clc |
.done: |
add esp, 40 |
pop ebx |
pop esi |
pop edi |
purge .sx0 |
purge .sy0 |
purge .sx1 |
purge .sy1 |
purge .dx0 |
purge .dy0 |
purge .dx1 |
purge .dy1 |
ret |
align 4 |
blit_32: |
push ebp |
push edi |
push esi |
push ebx |
virtual at sizeof.BLITTER |
.position dd ? ; (x shl 16) + y |
; ??? |
.extra_var1 dd ? |
.flags dd ? |
.local_vars_size = $ |
end virtual |
sub esp, .local_vars_size |
mov [esp+.flags], ebx |
mov eax, [TASK_BASE] |
mov ebx, [eax-twdw + WDATA.box.width] |
mov edx, [eax-twdw + WDATA.box.height] |
inc ebx |
inc edx |
xor eax, eax |
mov [esp+BLITTER.dc.left], eax |
mov [esp+BLITTER.dc.top], eax |
mov [esp+BLITTER.dc.right], ebx |
mov [esp+BLITTER.dc.bottom], edx |
mov [esp+BLITTER.sc.left], eax |
mov [esp+BLITTER.sc.top], eax |
mov eax, [ecx+24] |
mov [esp+BLITTER.sc.right], eax |
mov eax, [ecx+28] |
mov [esp+BLITTER.sc.bottom], eax |
mov eax, [ecx] |
mov [esp+BLITTER.dst_x], eax |
mov eax, [ecx+4] |
mov [esp+BLITTER.dst_y], eax |
mov eax, [ecx+16] |
mov [esp+BLITTER.src_x], eax |
mov eax, [ecx+20] |
mov [esp+BLITTER.src_y], eax |
mov eax, [ecx+8] |
mov [esp+BLITTER.w], eax |
mov eax, [ecx+12] |
mov [esp+BLITTER.h], eax |
mov eax, [ecx+32] |
mov [esp+BLITTER.bitmap], eax |
mov eax, [ecx+36] |
mov [esp+BLITTER.stride], eax |
mov ecx, esp |
call blit_clip |
jc .L57 |
mov eax, [TASK_BASE] |
mov ebx, [esp+BLITTER.dst_x] |
mov ebp, [esp+BLITTER.dst_y] |
add ebx, [eax-twdw + WDATA.box.left] |
add ebp, [eax-twdw + WDATA.box.top] |
test [esp+.flags], BLIT_CLIENT_RELATIVE |
jz .no_client_relative |
mov eax, [current_slot] |
add ebx, [eax + APPDATA.wnd_clientbox.left] |
add ebp, [eax + APPDATA.wnd_clientbox.top] |
.no_client_relative: |
mov ecx, ebx |
add ecx, [esp+BLITTER.w] |
shl ecx, 16 |
mov cx, bp |
add ecx, [esp+BLITTER.h] |
mov eax, ebx |
shl eax, 16 |
mov ax, bp |
mov [esp+.position], eax |
mov edi, ebp |
; imul edi, [_display.pitch] |
mov edi, [BPSLine_calc_area+edi*4] |
; imul ebp, [_display.width] |
mov ebp, [d_width_calc_area+ebp*4] |
add ebp, ebx |
add ebp, [_display.win_map] |
mov eax, [esp+BLITTER.src_y] |
imul eax, [esp+BLITTER.stride] |
mov esi, [esp+BLITTER.src_x] |
lea esi, [eax+esi*4] |
add esi, [esp+BLITTER.bitmap] |
mov eax, ecx |
mov ecx, [esp+BLITTER.h] |
mov edx, [esp+BLITTER.w] |
test ecx, ecx ;FIXME check clipping |
jz .L57 |
test edx, edx |
jz .L57 |
cmp [_display.bits_per_pixel], 32 |
jne .core_24 |
lea edi, [edi+ebx*4] |
mov ebx, [current_slot_idx] |
; check for hardware cursor |
cmp [_display.select_cursor], select_cursor |
je .core_32.software_cursor |
cmp [_display.select_cursor], 0 |
jne .core_32.hardware_cursor |
;-------------------------------------- |
.core_32.software_cursor: |
align 4 |
.outer32: |
align 4 |
.inner32: |
cmp [ebp], bl |
jne .skip |
;-------------------------------------- |
mov eax, [esi] |
mov ecx, [esp+.position] |
; check mouse area for putpixel |
call [_display.check_mouse] |
;-------------------------------------- |
; store to real LFB |
mov [LFB_BASE+edi], eax |
;-------------------------------------- |
align 4 |
.skip: |
add esi, 4 |
add edi, 4 |
inc ebp |
add [esp+.position], 1 shl 16 |
dec edx |
jnz .inner32 |
add esi, [esp+BLITTER.stride] |
add edi, [_display.lfb_pitch] |
add ebp, [_display.width] |
mov edx, [esp+BLITTER.w] |
mov eax, edx |
inc [esp+.position] |
sub ebp, edx |
shl eax, 2 |
sub esi, eax |
sub edi, eax |
shl eax, 16-2 |
sub [esp+.position], eax |
dec [esp+BLITTER.h] |
jnz .outer32 |
jmp .done |
.core_32.hardware_cursor: |
align 4 |
.hw.outer32: |
xor ecx, ecx |
align 4 |
.hw.inner32: |
cmp [ebp+ecx], bl |
jne .hw.skip |
mov eax, [esi+ecx*4] |
mov [LFB_BASE+edi+ecx*4], eax |
align 4 |
.hw.skip: |
inc ecx |
dec edx |
jnz .hw.inner32 |
add esi, [esp+BLITTER.stride] |
add edi, [_display.lfb_pitch] |
add ebp, [_display.width] |
mov edx, [esp+BLITTER.w] |
dec [esp+BLITTER.h] |
jnz .hw.outer32 |
.done: |
; call [draw_pointer] |
; call __sys_draw_pointer |
.L57: |
add esp, .local_vars_size |
pop ebx |
pop esi |
pop edi |
pop ebp |
ret |
.core_24: |
cmp [_display.bits_per_pixel], 24 |
jne .core_16 |
lea ebx, [ebx+ebx*2] |
lea edi, [LFB_BASE+edi+ebx] |
mov ebx, [current_slot_idx] |
align 4 |
.outer24: |
mov [esp+.extra_var1], edi |
xor ecx, ecx |
align 4 |
.inner24: |
cmp [ebp+ecx], bl ; Does the process own this pixel? |
jne .skip_1 |
;-------------------------------------- |
push eax |
mov eax, [esi+ecx*4] |
lea edi, [edi+ecx*2] |
; check for hardware cursor |
cmp [_display.select_cursor], select_cursor |
je @f |
cmp [_display.select_cursor], 0 |
jne .no_mouseunder_1 |
;-------------------------------------- |
align 4 |
@@: |
push ecx |
mov ecx, [esp+4] |
ror ecx, 16 |
sub ecx, edx |
rol ecx, 16 |
sub ecx, [esp+BLITTER.h + 8] |
; check mouse area for putpixel |
call [_display.check_mouse] |
pop ecx |
;-------------------------------------- |
align 4 |
.no_mouseunder_1: |
mov [edi+ecx], ax |
shr eax, 16 |
mov [edi+ecx+2], al |
pop eax |
;-------------------------------------- |
align 4 |
.skip_1: |
mov edi, [esp+.extra_var1] |
inc ecx |
dec edx |
jnz .inner24 |
add esi, [esp+BLITTER.stride] |
add edi, [_display.lfb_pitch] |
add ebp, [_display.width] |
mov edx, [esp+BLITTER.w] |
dec [esp+BLITTER.h] |
jnz .outer24 |
jmp .done |
.core_16: |
lea edi, [LFB_BASE+edi+ebx*2] |
mov ebx, [current_slot_idx] |
.outer16: |
mov [esp+.extra_var1], edi |
xor ecx, ecx |
.inner16: |
cmp [ebp+ecx], bl ; Does the process own this pixel? |
jne .skip_2 |
;-------------------------------------- |
push eax |
mov eax, [esi+ecx*4] |
; check for hardware cursor |
cmp [_display.select_cursor], select_cursor |
je @f |
cmp [_display.select_cursor], 0 |
jne .no_mouseunder_2 |
;-------------------------------------- |
@@: |
push ecx |
mov ecx, [esp+4] |
ror ecx, 16 |
sub ecx, edx |
rol ecx, 16 |
sub ecx, [esp+BLITTER.h + 8] |
; check mouse area for putpixel |
call [_display.check_mouse] |
pop ecx |
;-------------------------------------- |
.no_mouseunder_2: |
; 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+ecx*2], ax |
pop eax |
;-------------------------------------- |
.skip_2: |
mov edi, [esp+.extra_var1] |
inc ecx |
dec edx |
jnz .inner16 |
add esi, [esp+BLITTER.stride] |
add edi, [_display.lfb_pitch] |
add ebp, [_display.width] |
mov edx, [esp+BLITTER.w] |
dec [esp+BLITTER.h] |
jnz .outer16 |
jmp .done |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Revision |
\ No newline at end of property |
/kernel/branches/kolibri-lldw/video/cursors.inc |
---|
0,0 → 1,1238 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision$ |
LOAD_FROM_FILE = 0 |
LOAD_FROM_MEM = 1 |
LOAD_INDIRECT = 2 |
LOAD_SYSTEM = 3 |
struct BITMAPINFOHEADER |
Size dd ? |
Width dd ? |
Height dd ? |
Planes dw ? |
BitCount dw ? |
Compression dd ? |
SizeImage dd ? |
XPelsPerMeter dd ? |
YPelsPerMeter dd ? |
ClrUsed dd ? |
ClrImportant dd ? |
ends |
;------------------------------------------------------------------------------ |
align 4 |
proc init_cursor stdcall, dst:dword, src:dword |
locals |
rBase dd ? |
pQuad dd ? |
pBits dd ? |
pAnd dd ? |
width dd ? |
height dd ? |
counter dd ? |
endl |
mov esi, [src] |
add esi, [esi+18] |
mov eax, esi |
cmp [esi+BITMAPINFOHEADER.BitCount], 24 |
je .img_24 |
cmp [esi+BITMAPINFOHEADER.BitCount], 8 |
je .img_8 |
cmp [esi+BITMAPINFOHEADER.BitCount], 4 |
je .img_4 |
;-------------------------------------- |
align 4 |
.img_2: |
add eax, [esi] |
mov [pQuad], eax |
add eax, 8 |
mov [pBits], eax |
add eax, 128 |
mov [pAnd], eax |
mov eax, [esi+4] |
mov [width], eax |
mov ebx, [esi+8] |
shr ebx, 1 |
mov [height], ebx |
mov edi, [dst] |
add edi, 32*31*4 |
mov [rBase], edi |
mov esi, [pQuad] |
;-------------------------------------- |
align 4 |
.l21: |
mov ebx, [pBits] |
mov ebx, [ebx] |
bswap ebx |
mov eax, [pAnd] |
mov eax, [eax] |
bswap eax |
mov [counter], 32 |
;-------------------------------------- |
align 4 |
@@: |
xor edx, edx |
shl eax, 1 |
setc dl |
dec edx |
xor ecx, ecx |
shl ebx, 1 |
setc cl |
mov ecx, [esi+ecx*4] |
and ecx, edx |
and edx, 0xFF000000 |
or edx, ecx |
mov [edi], edx |
add edi, 4 |
dec [counter] |
jnz @B |
add [pBits], 4 |
add [pAnd], 4 |
mov edi, [rBase] |
sub edi, 128 |
mov [rBase], edi |
sub [height], 1 |
jnz .l21 |
ret |
;-------------------------------------- |
align 4 |
.img_4: |
add eax, [esi] |
mov [pQuad], eax |
add eax, 64 |
mov [pBits], eax |
add eax, 0x200 |
mov [pAnd], eax |
mov eax, [esi+4] |
mov [width], eax |
mov ebx, [esi+8] |
shr ebx, 1 |
mov [height], ebx |
mov edi, [dst] |
add edi, 32*31*4 |
mov [rBase], edi |
mov esi, [pQuad] |
mov ebx, [pBits] |
;-------------------------------------- |
align 4 |
.l4: |
mov eax, [pAnd] |
mov eax, [eax] |
bswap eax |
mov [counter], 16 |
;-------------------------------------- |
align 4 |
@@: |
xor edx, edx |
shl eax, 1 |
setc dl |
dec edx |
movzx ecx, byte [ebx] |
and cl, 0xF0 |
shr ecx, 2 |
mov ecx, [esi+ecx] |
and ecx, edx |
and edx, 0xFF000000 |
or edx, ecx |
mov [edi], edx |
xor edx, edx |
shl eax, 1 |
setc dl |
dec edx |
movzx ecx, byte [ebx] |
and cl, 0x0F |
mov ecx, [esi+ecx*4] |
and ecx, edx |
and edx, 0xFF000000 |
or edx, ecx |
mov [edi+4], edx |
inc ebx |
add edi, 8 |
dec [counter] |
jnz @B |
add [pAnd], 4 |
mov edi, [rBase] |
sub edi, 128 |
mov [rBase], edi |
sub [height], 1 |
jnz .l4 |
ret |
;-------------------------------------- |
align 4 |
.img_8: |
add eax, [esi] |
mov [pQuad], eax |
add eax, 1024 |
mov [pBits], eax |
add eax, 1024 |
mov [pAnd], eax |
mov eax, [esi+4] |
mov [width], eax |
mov ebx, [esi+8] |
shr ebx, 1 |
mov [height], ebx |
mov edi, [dst] |
add edi, 32*31*4 |
mov [rBase], edi |
mov esi, [pQuad] |
mov ebx, [pBits] |
;-------------------------------------- |
align 4 |
.l81: |
mov eax, [pAnd] |
mov eax, [eax] |
bswap eax |
mov [counter], 32 |
;-------------------------------------- |
align 4 |
@@: |
xor edx, edx |
shl eax, 1 |
setc dl |
dec edx |
movzx ecx, byte [ebx] |
mov ecx, [esi+ecx*4] |
and ecx, edx |
and edx, 0xFF000000 |
or edx, ecx |
mov [edi], edx |
inc ebx |
add edi, 4 |
dec [counter] |
jnz @B |
add [pAnd], 4 |
mov edi, [rBase] |
sub edi, 128 |
mov [rBase], edi |
sub [height], 1 |
jnz .l81 |
ret |
;-------------------------------------- |
align 4 |
.img_24: |
add eax, [esi] |
mov [pQuad], eax |
add eax, 0xC00 |
mov [pAnd], eax |
mov eax, [esi+BITMAPINFOHEADER.Width] |
mov [width], eax |
mov ebx, [esi+BITMAPINFOHEADER.Height] |
shr ebx, 1 |
mov [height], ebx |
mov edi, [dst] |
add edi, 32*31*4 |
mov [rBase], edi |
mov esi, [pAnd] |
mov ebx, [pQuad] |
;-------------------------------------- |
align 4 |
.row_24: |
mov eax, [esi] |
bswap eax |
mov [counter], 32 |
;-------------------------------------- |
align 4 |
@@: |
xor edx, edx |
shl eax, 1 |
setc dl |
dec edx |
mov ecx, [ebx] |
and ecx, 0x00FFFFFF |
and ecx, edx |
and edx, 0xFF000000 |
or edx, ecx |
mov [edi], edx |
add ebx, 3 |
add edi, 4 |
dec [counter] |
jnz @B |
add esi, 4 |
mov edi, [rBase] |
sub edi, 128 |
mov [rBase], edi |
sub [height], 1 |
jnz .row_24 |
ret |
endp |
;------------------------------------------------------------------------------ |
align 4 |
proc set_cursor stdcall, hcursor:dword |
mov eax, [hcursor] |
cmp [eax+CURSOR.magic], 'CURS' |
jne .fail |
; cmp [eax+CURSOR.size], CURSOR_SIZE |
; jne .fail |
mov ebx, [current_slot] |
xchg eax, [ebx+APPDATA.cursor] |
jmp .end |
;-------------------------------------- |
align 4 |
.fail: |
mov eax, [def_cursor] |
mov ebx, [current_slot] |
xchg eax, [ebx+APPDATA.cursor] |
align 4 |
.end: |
mov [redrawmouse_unconditional], 1 |
call __sys_draw_pointer |
ret |
endp |
;------------------------------------------------------------------------------ |
align 4 |
; param |
; eax= pid |
; ebx= src |
; ecx= flags |
create_cursor: |
.src equ esp |
.flags equ esp+4 |
.hcursor equ esp+8 |
sub esp, 4 ;space for .hcursor |
push ecx |
push ebx |
mov ebx, eax |
mov eax, sizeof.CURSOR |
call create_kernel_object |
test eax, eax |
jz .fail |
mov [.hcursor], eax |
xor ebx, ebx |
mov [eax+CURSOR.magic], 'CURS' |
mov [eax+CURSOR.destroy], destroy_cursor |
mov [eax+CURSOR.hot_x], ebx |
mov [eax+CURSOR.hot_y], ebx |
stdcall kernel_alloc, 0x1000 |
test eax, eax |
jz .fail |
mov edi, [.hcursor] |
mov [edi+CURSOR.base], eax |
mov esi, [.src] |
mov ebx, [.flags] |
cmp bx, LOAD_INDIRECT |
je .indirect |
movzx ecx, word [esi+10] |
movzx edx, word [esi+12] |
mov [edi+CURSOR.hot_x], ecx |
mov [edi+CURSOR.hot_y], edx |
stdcall init_cursor, eax, esi |
align 4 |
.add_cursor: |
mov ecx, [.hcursor] |
lea ecx, [ecx+CURSOR.list_next] |
lea edx, [_display.cr_list.next] |
pushfd |
cli |
list_add ecx, edx ;list_add_tail(new, head) |
popfd |
mov eax, [.hcursor] |
cmp [_display.init_cursor], 0 |
je .fail |
push eax |
call [_display.init_cursor] |
add esp, 4 |
mov eax, [.hcursor] |
;-------------------------------------- |
align 4 |
.fail: |
add esp, 12 |
ret |
;-------------------------------------- |
align 4 |
.indirect: |
shr ebx, 16 |
movzx ecx, bh |
movzx edx, bl |
mov [edi+CURSOR.hot_x], ecx |
mov [edi+CURSOR.hot_y], edx |
xchg edi, eax |
mov ecx, 1024 |
cld |
rep movsd |
jmp .add_cursor |
;------------------------------------------------------------------------------ |
align 4 |
proc load_cursor stdcall, src:dword, flags:dword |
locals |
handle dd ? |
endl |
xor eax, eax |
cmp [create_cursor], eax |
je .fail2 |
mov [handle], eax |
cmp word [flags], LOAD_FROM_FILE |
jne @F |
stdcall load_file, [src] |
test eax, eax |
jz .fail |
mov [src], eax |
;-------------------------------------- |
align 4 |
@@: |
push ebx |
push esi |
push edi |
mov eax, [current_slot_idx] |
shl eax, 5 |
mov eax, [TASK_TABLE+eax+4] |
mov ebx, [src] |
mov ecx, [flags] |
call create_cursor ;eax, ebx, ecx |
mov [handle], eax |
cmp word [flags], LOAD_FROM_FILE |
jne .exit |
stdcall kernel_free, [src] |
;-------------------------------------- |
align 4 |
.exit: |
pop edi |
pop esi |
pop ebx |
;-------------------------------------- |
align 4 |
.fail: |
mov eax, [handle] |
;-------------------------------------- |
align 4 |
.fail2: |
ret |
endp |
;------------------------------------------------------------------------------ |
align 4 |
proc delete_cursor stdcall, hcursor:dword |
; DEBUGF 1,'K : delete_cursor %x\n', [hcursor] |
mov esi, [hcursor] |
cmp [esi+CURSOR.magic], 'CURS' |
jne .fail |
mov ebx, [current_slot_idx] |
shl ebx, 5 |
mov ebx, [TASK_TABLE+ebx+4] |
cmp ebx, [esi+CURSOR.pid] |
jne .fail |
mov ebx, [current_slot] |
cmp esi, [ebx+APPDATA.cursor] |
jne @F |
mov eax, [def_cursor] |
mov [ebx+APPDATA.cursor], eax |
;-------------------------------------- |
align 4 |
@@: |
mov eax, [hcursor] |
call [eax+APPOBJ.destroy] |
;-------------------------------------- |
align 4 |
.fail: |
ret |
endp |
;------------------------------------------------------------------------------ |
align 4 |
; param |
; eax= cursor |
destroy_cursor: |
push eax |
stdcall kernel_free, [eax+CURSOR.base] |
mov eax, [esp] |
lea eax, [eax+CURSOR.list_next] |
pushfd |
cli |
list_del eax |
popfd |
pop eax |
call destroy_kernel_object |
ret |
;------------------------------------------------------------------------------ |
align 4 |
select_cursor: |
mov eax, [esp+4] |
mov [_display.cursor], eax |
ret 4 |
;------------------------------------------------------------------------------ |
align 4 |
proc restore_24 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 |
mov ecx, [cur.w] |
lea ecx, [ecx+ecx*2] |
push ecx |
;-------------------------------------- |
align 4 |
@@: |
mov edi, ebx |
add ebx, [_display.lfb_pitch] |
mov ecx, [esp] |
rep movsb |
dec edx |
jnz @B |
pop ecx |
pop edi |
pop esi |
;-------------------------------------- |
align 4 |
.ret: |
pop ebx |
ret |
endp |
;------------------------------------------------------------------------------ |
align 4 |
proc restore_32 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.lfb_pitch] |
mov ecx, [cur.w] |
rep movsd |
dec edx |
jnz @B |
pop edi |
pop esi |
;-------------------------------------- |
align 4 |
.ret: |
pop ebx |
ret |
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.lfb_pitch] |
mov ecx, [cur.w] |
rep movsw |
dec edx |
jnz @B |
pop edi |
pop esi |
;-------------------------------------- |
align 4 |
.ret: |
pop ebx |
ret |
endp |
;------------------------------------------------------------------------------ |
align 4 |
proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword |
locals |
h dd ? |
_dx dd ? |
_dy dd ? |
endl |
mov esi, [hcursor] |
mov ecx, [x] |
mov eax, [y] |
; mov ebx, [BytesPerScanLine] |
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+ecx*3] |
add edx, eax |
mov [cur_saved_base], edx |
cmp ebx, [_display.width] |
jb @F |
mov ebx, [_display.width] |
;-------------------------------------- |
align 4 |
@@: |
cmp edi, [_display.height] |
jb @F |
mov edi, [_display.height] |
;-------------------------------------- |
align 4 |
@@: |
sub ebx, [x] |
sub edi, [y] |
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.lfb_pitch] |
mov ecx, [cur.w] |
lea ecx, [ecx+ecx*2] |
rep movsb |
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.lfb_pitch] |
;-------------------------------------- |
align 4 |
.pix: |
lodsd |
test eax, 0xFF000000 |
jz @F |
mov [edi], ax |
shr eax, 16 |
mov [edi+2], al |
;-------------------------------------- |
align 4 |
@@: |
add edi, 3 |
dec ecx |
jnz .pix |
dec [h] |
jnz .row |
ret |
endp |
;------------------------------------------------------------------------------ |
align 4 |
proc move_cursor_32 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*4] |
mov [cur_saved_base], edx |
cmp ebx, [_display.width] |
jb @F |
mov ebx, [_display.width] |
;-------------------------------------- |
align 4 |
@@: |
cmp edi, [_display.height] |
jb @F |
mov edi, [_display.height] |
;-------------------------------------- |
align 4 |
@@: |
sub ebx, [x] |
sub edi, [y] |
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.lfb_pitch] |
mov ecx, [cur.w] |
rep movsd |
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.lfb_pitch] |
;-------------------------------------- |
align 4 |
.pix: |
lodsd |
test eax, 0xFF000000 |
jz @F |
mov [edi], eax |
;-------------------------------------- |
align 4 |
@@: |
add edi, 4 |
dec ecx |
jnz .pix |
dec [h] |
jnz .row |
ret |
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, [_display.width] |
jb @F |
mov ebx, [_display.width] |
;-------------------------------------- |
align 4 |
@@: |
cmp edi, [_display.height] |
jb @F |
mov edi, [_display.height] |
;-------------------------------------- |
align 4 |
@@: |
sub ebx, [x] |
sub edi, [y] |
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.lfb_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.lfb_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 |
; ebx = y |
; out: |
; ecx = new color |
;-------------------------------------- |
; check for Y |
cmp bx, [Y_UNDER_subtraction_CUR_hot_y] |
jb .no_mouse_area |
cmp bx, [Y_UNDER_sub_CUR_hot_y_add_curh] |
jae .no_mouse_area |
;-------------------------------------- |
; check for X |
cmp ax, [X_UNDER_subtraction_CUR_hot_x] |
jb .no_mouse_area |
cmp ax, [X_UNDER_sub_CUR_hot_x_add_curh] |
jae .no_mouse_area |
;-------------------------------------- |
push eax ebx |
; offset X |
movzx ecx, word [X_UNDER_subtraction_CUR_hot_x] |
sub eax, ecx ; x1 |
; offset Y |
movzx ecx, word [Y_UNDER_subtraction_CUR_hot_y] |
sub ebx, ecx ; y1 |
;-------------------------------------- |
; ebx = offset y |
; eax = offset x |
imul ebx, [cur.w] ;y |
add eax, ebx |
mov ebx, eax |
shl eax, 2 |
cmp byte [_display.bits_per_pixel], 32 |
je @f |
sub eax, ebx |
cmp byte [_display.bits_per_pixel], 24 |
je @f |
sub eax, ebx |
add eax, cur_saved_data |
mov ecx, [eax] |
shl ecx, 3 |
ror ecx, 8 |
shl cx, 2 |
ror ecx, 8 |
shl cl, 3 |
rol ecx, 16 |
or ecx, 0xff000000 |
pop ebx eax |
ret |
;-------------------------------------- |
align 4 |
@@: |
add eax, cur_saved_data |
mov ecx, [eax] |
or ecx, 0xff000000 |
pop ebx eax |
ret |
;-------------------------------------- |
align 4 |
.no_mouse_area: |
xor ecx, ecx |
ret |
;----------------------------------------------------------------------------- |
align 4 |
check_mouse_area_for_putpixel_new: |
; in: |
; ecx = x shl 16 + y |
; eax = color |
; out: |
; eax = new color |
;-------------------------------------- |
; 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 |
;-------------------------------------- |
; 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 |
;-------------------------------------- |
align 4 |
.1: |
push eax |
;-------------------------------------- |
; ecx = (offset x) shl 16 + (offset y) |
push ebx |
mov ebx, ecx |
shr ebx, 16 ; x |
and ecx, 0xffff ; y |
cmp ecx, [cur.h] |
jae @f |
cmp ebx, [cur.w] |
jb .ok |
;-------------------------------------- |
align 4 |
@@: |
; DEBUGF 1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx |
pop ebx |
jmp .sh ; SORRY! SHIT HAPPENS! |
;-------------------------------------- |
align 4 |
.ok: |
; ecx = offset y |
; ebx = offset x |
push ebx ecx |
imul ecx, [cur.w] ;y |
add ecx, ebx |
mov ebx, ecx |
shl ecx, 2 |
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 |
shr eax, 16 |
mov [ecx + cur_saved_data + 2], al ;store new color to |
;-------------------------------------- |
align 4 |
@@: |
pop ecx ebx |
shl ecx, 5 |
add ecx, ebx |
mov eax, [current_cursor] |
mov eax, [eax+CURSOR.base] |
lea eax, [eax+ecx*4] |
mov eax, [eax] |
pop ebx |
test eax, 0xFF000000 |
jz @f |
add esp, 4 |
ret |
;-------------------------------------- |
align 4 |
.sh: |
mov ecx, -1 |
;-------------------------------------- |
align 4 |
@@: |
pop eax |
;-------------------------------------- |
align 4 |
.no_mouse_area: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
get_display: |
mov eax, _display |
ret |
;------------------------------------------------------------------------------ |
align 4 |
init_display: |
xor eax, eax |
mov edi, _display |
mov [edi+display_t.init_cursor], eax |
mov [edi+display_t.select_cursor], eax |
mov [edi+display_t.show_cursor], eax |
mov [edi+display_t.move_cursor], eax |
mov [edi+display_t.restore_cursor], eax |
lea ecx, [edi+display_t.cr_list.next] |
mov [edi+display_t.cr_list.next], ecx |
mov [edi+display_t.cr_list.prev], ecx |
if ~defined UEFI |
cmp [SCR_MODE], word 0x13 |
jbe .fail |
test word [SCR_MODE], 0x4000 |
jz .fail |
end if |
mov ebx, restore_32 |
mov ecx, move_cursor_32 |
mov edx, Vesa20_putpixel32_new |
mov eax, [_display.bits_per_pixel] |
cmp al, 32 |
jne .not_32bpp |
.set: |
mov [_display.select_cursor], select_cursor |
mov [_display.move_cursor], ecx |
mov [_display.restore_cursor], ebx |
mov [_display.check_mouse], check_mouse_area_for_putpixel_new |
mov [_display.check_m_pixel], check_mouse_area_for_getpixel_new |
cmp [PUTPIXEL], dword VGA_putpixel |
je @f |
mov [PUTPIXEL], edx |
@@: |
stdcall load_cursor, clock_arrow, dword LOAD_FROM_MEM |
mov [def_cursor_clock], eax |
stdcall load_cursor, def_arrow, dword LOAD_FROM_MEM |
mov [def_cursor], eax |
ret |
.not_32bpp: |
cmp al, 24 |
jne .not_24bpp |
mov ebx, restore_24 |
mov ecx, move_cursor_24 |
mov edx, Vesa20_putpixel24_new |
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 |
mov [_display.select_cursor], eax |
mov [_display.move_cursor], eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
def_arrow: |
file 'arrow.cur' |
;------------------------------------------------------------------------------ |
align 4 |
clock_arrow: |
file 'arrow_clock.cur' |
;------------------------------------------------------------------------------ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Rev |
\ No newline at end of property |
/kernel/branches/kolibri-lldw/video/vesa20.inc |
---|
0,0 → 1,2518 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; VESA20.INC ;; |
;; ;; |
;; Vesa 2.0 functions for MenuetOS ;; |
;; ;; |
;; Copyright 2002 Ville Turjanmaa ;; |
;; Alexey, kgaz@crosswindws.net ;; |
;; - Voodoo compatible graphics ;; |
;; Juan M. Caravaca ;; |
;; - Graphics optimimizations eg. drawline ;; |
;; ;; |
;; See file COPYING for details ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision$ |
uglobal |
align 4 |
bgr_cur_line rd MAX_SCREEN_WIDTH |
bgr_next_line rd MAX_SCREEN_WIDTH |
endg |
iglobal |
align 4 |
overlapping_of_points_ptr dd overlapping_of_points |
endg |
;----------------------------------------------------------------------------- |
; eax = x |
; ebx = y |
align 4 |
Vesa20_getpixel16: |
; 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*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 |
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, [ebx+eax*4] ; edi = x*4+(y*y multiplier) |
mov ecx, [LFB_BASE+edi] |
@@: |
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 ? |
.real_sy dd ? |
.image_sx dd ? |
.image_sy dd ? |
.image_cx dd ? |
.image_cy dd ? |
.pti dd ? |
.abs_cx dd ? |
.abs_cy dd ? |
.line_increment dd ? |
.winmap_newline dd ? |
.screen_newline dd ? |
.real_sx_and_abs_cx dd ? |
.real_sy_and_abs_cy dd ? |
.stack_data = 4*14 |
.edi dd ? |
.esi dd ? |
.ebp dd ? |
.esp dd ? |
.ebx dd ? |
.edx dd ? |
.ecx dd ? |
.eax dd ? |
.ret_addr dd ? |
.arg_0 dd ? |
end virtual |
pushad |
sub esp, putimg.stack_data |
; save pointer to image |
mov [putimg.pti], ebx |
; unpack the size |
mov eax, ecx |
and ecx, 0xFFFF |
shr eax, 16 |
mov [putimg.image_sx], eax |
mov [putimg.image_sy], ecx |
; unpack the coordinates |
mov eax, edx |
and edx, 0xFFFF |
shr eax, 16 |
mov [putimg.image_cx], eax |
mov [putimg.image_cy], edx |
; calculate absolute (i.e. screen) coordinates |
mov eax, [TASK_BASE] |
mov ebx, [eax-twdw + WDATA.box.left] |
add ebx, [putimg.image_cx] |
mov [putimg.abs_cx], ebx |
mov ebx, [eax-twdw + WDATA.box.top] |
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 |
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 |
@@: |
cmp ebx, [putimg.image_sx] |
jbe .end_x |
mov ebx, [putimg.image_sx] |
.end_x: |
mov [putimg.real_sx], ebx |
; init real_sy |
mov ebx, [eax-twdw + WDATA.box.height] ; ebx = wnd_sy |
inc ebx |
sub ebx, [putimg.image_cy] |
ja @f |
add esp, putimg.stack_data |
popad |
ret |
@@: |
cmp ebx, [putimg.image_sy] |
jbe .end_y |
mov ebx, [putimg.image_sy] |
.end_y: |
mov [putimg.real_sy], ebx |
; line increment |
mov eax, [putimg.image_sx] |
mov ecx, [putimg.real_sx] |
sub eax, ecx |
;; imul eax, [putimg.source_bpp] |
; lea eax, [eax + eax * 2] |
call esi |
add eax, [putimg.arg_0] |
mov [putimg.line_increment], eax |
; winmap new line increment |
mov eax, [_display.width] |
sub eax, [putimg.real_sx] |
mov [putimg.winmap_newline], eax |
; screen new line increment |
mov eax, [_display.lfb_pitch] |
mov ebx, [_display.bytes_per_pixel] |
imul ecx, ebx |
sub eax, ecx |
mov [putimg.screen_newline], eax |
; pointer to image |
mov esi, [putimg.pti] |
; pointer to screen |
mov edx, [putimg.abs_cy] |
; imul edx, [BytesPerScanLine] |
mov edx, [BPSLine_calc_area+edx*4] |
mov eax, [putimg.abs_cx] |
imul eax, ebx |
add edx, eax |
; pointer to pixel map |
mov eax, [putimg.abs_cy] |
; imul eax, [Screen_Max_X] |
; add eax, [putimg.abs_cy] |
mov eax, [d_width_calc_area + eax*4] |
add eax, [putimg.abs_cx] |
add eax, [_display.win_map] |
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_slot_idx] |
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_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 |
.new_line: |
mov ecx, [putimg.real_sx] |
.new_x: |
push [putimg.edi] |
mov eax, [putimg.ebp+4] |
call eax |
cmp [ebp], bl |
jne .skip |
; store to LFB |
mov [LFB_BASE+edx], ax |
shr eax, 16 |
mov [LFB_BASE+edx+2], al |
.skip: |
add edx, 3 |
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_24_old: |
.new_line: |
mov ecx, [putimg.real_sx] |
;-------------------------------------- |
align 4 |
.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 |
; store to LFB |
mov [LFB_BASE+edx], ax |
shr eax, 16 |
mov [LFB_BASE+edx+2], al |
.skip: |
add edx, 3 |
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_24.finish |
;------------------------------------------------------------------------------ |
align 4 |
put_image_end_24_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 |
; store to LFB |
mov [LFB_BASE+edx], ax |
shr eax, 16 |
mov [LFB_BASE+edx+2], al |
.skip: |
add edx, 3 |
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_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 |
.new_line: |
mov ecx, [putimg.real_sx] |
.new_x: |
push [putimg.edi] |
mov eax, [putimg.ebp+4] |
call eax |
cmp [ebp], bl |
jne .skip |
; store to LFB |
mov [LFB_BASE+edx], eax |
.skip: |
add edx, 4 |
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 |
cmp [SCR_MODE], 0x12 |
jne @f |
call VGA__putimage |
@@: |
mov [EGA_counter], 1 |
ret |
;------------------------------------------------------------------------------ |
align 4 |
put_image_end_32_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 |
; store to LFB |
mov [LFB_BASE+edx], eax |
.skip: |
add edx, 4 |
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_32.finish |
;------------------------------------------------------------------------------ |
align 4 |
put_image_end_32_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 |
; store to LFB |
mov [LFB_BASE+edx], eax |
.skip: |
add edx, 4 |
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_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: |
pushad |
cmp eax, [_display.width] |
jge .exit |
cmp ebx, [_display.height] |
jge .exit |
test edi, 1 ; force ? |
jnz .forced |
; not forced |
mov edx, [d_width_calc_area + ebx*4] |
add edx, [_display.win_map] |
movzx edx, byte [eax+edx] |
cmp edx, [current_slot_idx] |
jne .exit |
.forced: |
; check for color inversion |
test ecx, 0x01000000 |
jz .no_inv |
push eax ebx edx edi |
call [GETPIXEL] |
pop edi edx ebx eax |
not ecx |
rol ecx, 8 |
mov cl, [esp+32-8+3] |
ror ecx, 8 |
mov [esp+32-8], ecx |
.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: |
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+eax*2]; edi = x*3 |
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 |
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: |
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+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 |
@@: |
; 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_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 |
; 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 |
@@: |
and eax, 0xffffff |
; store to LFB |
mov [LFB_BASE+edi], eax |
ret |
;----------------------------------------------------------------------------- |
; 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 |
; 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 |
@@: |
and eax, 0x00ffffff |
; store to LFB |
mov [LFB_BASE+edi], eax |
ret |
;----------------------------------------------------------------------------- |
align 4 |
calculate_edi: |
; mov edi, ebx |
; imul edi, [Screen_Max_X] |
; add edi, ebx |
mov edi, [d_width_calc_area + ebx*4] |
add edi, eax |
ret |
;----------------------------------------------------------------------------- |
; DRAWLINE |
;----------------------------------------------------------------------------- |
; eax = x1 shl 16 + x2 |
; ebx = y1 shl 16 + y2 |
; ecx = color |
; edi = force ? |
align 4 |
__sys_draw_line: |
dl_x1 equ esp+20 |
dl_y1 equ esp+16 |
dl_x2 equ esp+12 |
dl_y2 equ esp+8 |
dl_dx equ esp+4 |
dl_dy equ esp+0 |
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 |
; 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) |
call vline |
push edx ; necessary to rightly restore stack frame at .exit |
jmp .exit |
.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) |
call hline |
jmp .exit |
.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 |
jge .no_reverse1 |
neg dword [dl_dx] |
mov edx, [dl_x2] |
mov [dl_x2], eax |
mov [dl_x1], edx |
mov edx, [dl_y2] |
mov [dl_y2], ebx |
mov [dl_y1], edx |
.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) |
; correction for the remainder of the division |
shl edx, 1 |
cmp ebp, edx |
jb @f |
inc eax |
@@: |
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 |
.x_rules: |
cmp [dl_x2], eax ; make sure x1 is at the begining |
jge .no_reverse2 |
neg dword [dl_dy] |
mov edx, [dl_x2] |
mov [dl_x2], eax |
mov [dl_x1], edx |
mov edx, [dl_y2] |
mov [dl_y2], ebx |
mov [dl_y1], edx |
.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) |
; correction for the remainder of the division |
shl edx, 1 |
cmp esi, edx |
jb @f |
inc eax |
@@: |
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 |
.draw: |
push eax ebx |
; correction for the remainder of the division |
test ah, 0x80 |
jz @f |
add eax, 1 shl 16 |
@@: |
shr eax, 16 |
; correction for the remainder of the division |
test bh, 0x80 |
jz @f |
add ebx, 1 shl 16 |
@@: |
shr ebx, 16 |
; and ecx, 0xFBFFFFFF ; negate 0x04000000 save to mouseunder area |
; call [putpixel] |
call __sys_putpixel |
pop ebx eax |
add ebx, ebp ; y = y+dy |
add eax, esi ; x = x+dx |
dec edx |
jnz .draw |
; force last drawn pixel to be at (x2,y2) |
mov eax, [dl_x2] |
mov ebx, [dl_y2] |
; and ecx, 0xFBFFFFFF ;n egate 0x04000000 save to mouseunder area |
; call [putpixel] |
call __sys_putpixel |
.exit: |
add esp, 6*4 |
popa |
; call [draw_pointer] |
ret |
;------------------------------------------------------------------------------ |
; 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 |
@@: |
and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
@@: |
; call [putpixel] |
call __sys_putpixel |
inc eax |
cmp eax, edx |
jle @b |
pop edx eax |
ret |
;------------------------------------------------------------------------------ |
; 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 |
@@: |
and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
@@: |
; call [putpixel] |
call __sys_putpixel |
inc ebx |
cmp ebx, edx |
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 ? |
.bar_sy dd ? |
.bar_cx dd ? |
.bar_cy dd ? |
.abs_cx dd ? |
.abs_cy dd ? |
.real_sx dd ? |
.real_sy dd ? |
.color dd ? |
.line_inc_scr dd ? |
.line_inc_map dd ? |
.real_sx_and_abs_cx dd ? |
.real_sy_and_abs_cy dd ? |
.stack_data = 4*13 |
end virtual |
pushad |
sub esp, drbar.stack_data |
mov [drbar.color], edi |
sub edx, ebx |
jle .exit |
sub ecx, eax |
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 |
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 |
inc ebx ; WDATA.box.width is one pixel less than real window x-size |
sub ebx, [drbar.bar_cx] |
ja @f |
.exit: |
add esp, drbar.stack_data |
popad |
xor eax, eax |
inc eax |
ret |
@@: |
cmp ebx, [drbar.bar_sx] |
jbe .end_x |
mov ebx, [drbar.bar_sx] |
.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 |
inc ebx |
sub ebx, [drbar.bar_cy] |
ja @f |
add esp, drbar.stack_data |
popad |
xor eax, eax |
inc eax |
ret |
@@: |
cmp ebx, [drbar.bar_sy] |
jbe .end_y |
mov ebx, [drbar.bar_sy] |
.end_y: |
mov [drbar.real_sy], ebx |
; line_inc_map |
mov eax, [_display.width] |
sub eax, [drbar.real_sx] |
mov [drbar.line_inc_map], eax |
; line_inc_scr |
mov eax, [drbar.real_sx] |
mov ebx, [_display.bytes_per_pixel] |
imul eax, ebx |
neg eax |
add eax, [_display.lfb_pitch] |
mov [drbar.line_inc_scr], eax |
; pointer to screen |
mov edx, [drbar.abs_cy] |
; imul edx, [BytesPerScanLine] |
mov edx, [BPSLine_calc_area+edx*4] |
mov eax, [drbar.abs_cx] |
imul eax, ebx |
add edx, eax |
; pointer to pixel map |
mov eax, [drbar.abs_cy] |
; imul eax, [Screen_Max_X] |
; add eax, [drbar.abs_cy] |
mov eax, [d_width_calc_area + eax*4] |
add eax, [drbar.abs_cx] |
add eax, [_display.win_map] |
xchg eax, ebp |
mov ebx, [drbar.real_sx] |
add ebx, [drbar.abs_cx] |
mov [drbar.real_sx_and_abs_cx], ebx |
mov ebx, [drbar.real_sy] |
add ebx, [drbar.abs_cy] |
mov [drbar.real_sy_and_abs_cy], ebx |
add edx, LFB_BASE |
; get process number |
mov ebx, [current_slot_idx] ; bl - process num |
mov esi, [drbar.real_sy] |
mov eax, [drbar.color] ; BBGGRR00 |
rol eax, 8 |
mov bh, al ; 0x80 drawing gradient bars |
ror eax, 8 |
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 |
;-------------------------------------- |
; 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 |
.new_y: |
mov edi, [drbar.real_sx] |
.new_x: |
cmp byte [ebp], bl |
jne .skip |
; store to LFB |
mov [edx], ax |
shr eax, 16 |
mov [edx + 2], al |
.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 |
@@: |
dec esi |
jnz .new_y |
.end: |
add esp, drbar.stack_data |
popad |
xor eax, eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
draw_bar_end_24_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 |
; store to LFB |
mov [edx], ax |
shr eax, 16 |
mov [edx + 2], al |
mov eax, [drbar.color] |
.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 |
@@: |
dec esi |
jnz .new_y |
jmp draw_bar_end_24.end |
;------------------------------------------------------------------------------ |
align 4 |
draw_bar_end_24_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 |
mov [edx], ax |
shr eax, 16 |
mov [edx + 2], al |
pop eax |
jmp .skip |
.no_mouse_area: |
; store to LFB |
mov [edx], ax |
ror eax, 16 |
mov [edx + 2], al |
rol eax, 16 |
.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 |
@@: |
dec esi |
jnz .new_y |
jmp draw_bar_end_24.end |
;------------------------------------------------------------------------------ |
; 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 |
.new_y: |
mov edi, [drbar.real_sx] |
.new_x: |
cmp byte [ebp], bl |
jne .skip |
; store to LFB |
mov [edx], eax |
mov eax, [drbar.color] |
.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 |
.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 |
draw_bar_end_32_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 |
; store to LFB |
mov [edx], eax |
mov eax, [drbar.color] |
.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 |
;------------------------------------------------------------------------------ |
align 4 |
draw_bar_end_32_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 |
mov [edx], eax |
pop eax |
jmp .skip |
.no_mouse_area: |
; store to LFB |
mov [edx], eax |
.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] |
; drawing gradient bars |
test bh, 0x80 |
jz @f |
test al, al |
jz @f |
dec al |
@@: |
dec esi |
jnz .new_y |
.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 |
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] |
; 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.bytes_per_pixel], 3 |
je @f |
add ebp, eax |
@@: |
add ebp, LFB_BASE |
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB |
call calculate_edi |
xchg edi, ebp |
add ebp, [_display.win_map] |
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress |
; 2) Calculate offset in background memory block |
push eax |
xor edx, edx |
mov eax, ebx |
div dword [BgrDataHeight] ; edx := y mod BgrDataHeight |
pop eax |
push eax |
mov ecx, [BgrDataWidth] |
mov esi, edx |
imul esi, ecx ; esi := (y mod BgrDataHeight) * BgrDataWidth |
xor edx, edx |
div ecx ; edx := x mod BgrDataWidth |
sub ecx, edx |
add esi, edx ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth) |
pop eax |
lea esi, [esi*3] |
add esi, [img_background] |
xor edx, edx |
inc edx |
; 3) Loop through redraw rectangle and copy background data |
; Registers meaning: |
; eax = x, ebx = y (screen coordinates) |
; ecx = deltax - number of pixels left in current tile block |
; edx = 1 |
; esi -> bgr memory, edi -> output |
; ebp = offset in WinMapAddress |
dp3: |
cmp [ebp], dl |
jnz .next_pix |
push eax ecx |
mov ecx, eax |
shl ecx, 16 |
add ecx, ebx |
mov eax, [esi] |
; check for hardware cursor |
cmp [_display.select_cursor], select_cursor |
je @f |
cmp [_display.select_cursor], 0 |
jne .no_mouseunder |
@@: |
and eax, 0xffffff |
; check mouse area for putpixel |
call [_display.check_mouse] |
.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 |
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, [_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 |
dp4: |
; next scan line |
inc ebx |
cmp ebx, [draw_data+32+RECT.bottom] |
jbe dp2 |
popad |
mov [EGA_counter], 1 |
cmp [SCR_MODE], 0x12 |
jne @f |
call VGA_drawbackground |
@@: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
vesa20_drawbackground_stretch: |
pushad |
; Helper variables |
; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1) |
mov eax, [BgrDataWidth] |
dec eax |
xor edx, edx |
div dword [_display.width] |
push eax ; high |
xor eax, eax |
div dword [_display.width] |
push eax ; low |
; the same for height |
mov eax, [BgrDataHeight] |
dec eax |
xor edx, edx |
div dword [_display.height] |
push eax ; high |
xor eax, eax |
div dword [_display.height] |
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 |
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp] |
; 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 |
jz @f |
add ebp, eax |
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 |
; 2) Calculate offset in background memory block |
mov eax, ebx |
imul ebx, dword [esp+12] |
mul dword [esp+8] |
add edx, ebx ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1) |
mov esi, edx |
imul esi, [BgrDataWidth] |
push edx |
push eax |
mov eax, [esp+8] |
mul dword [esp+28] |
push eax |
mov eax, [esp+12] |
mul dword [esp+28] |
add [esp], edx |
pop edx ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1) |
add esi, edx |
lea esi, [esi*3] |
add esi, [img_background] |
push eax |
push edx |
push esi |
; 3) Smooth horizontal |
bgr_resmooth0: |
mov ecx, [esp+8] |
mov edx, [esp+4] |
mov esi, [esp] |
push edi |
mov edi, bgr_cur_line |
call smooth_line |
bgr_resmooth1: |
mov eax, [esp+16+4] |
inc eax |
cmp eax, [BgrDataHeight] |
jae bgr.no2nd |
mov ecx, [esp+8+4] |
mov edx, [esp+4+4] |
mov esi, [esp+4] |
add esi, [BgrDataWidth] |
add esi, [BgrDataWidth] |
add esi, [BgrDataWidth] |
mov edi, bgr_next_line |
call smooth_line |
bgr.no2nd: |
pop edi |
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 |
; ebp = offset in WinMapAddress |
; dword [esp] = offset in bgr data |
; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1) |
; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1) |
; dword [esp+20] = x |
; dword [esp+24] = y |
; precalculated constants: |
; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1) |
; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1) |
sdp3a: |
mov eax, [_display.win_map] |
cmp [ebp+eax], byte 1 |
jnz snbgp |
mov eax, [bgr_cur_line+esi] |
test ecx, ecx |
jz .novert |
mov ebx, [bgr_next_line+esi] |
call [overlapping_of_points_ptr] |
.novert: |
push ecx |
; check for hardware cursor |
cmp [_display.select_cursor], select_cursor |
je @f |
cmp [_display.select_cursor], 0 |
jne .no_mouseunder |
@@: |
mov ecx, [esp+20+4] ;x |
shl ecx, 16 |
add ecx, [esp+24+4] ;y |
; check mouse area for putpixel |
call [_display.check_mouse] |
.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 |
snbgp: |
add edi, [_display.bytes_per_pixel] |
add ebp, 1 |
mov eax, [esp+20] |
add eax, 1 |
mov [esp+20], eax |
add esi, 4 |
cmp eax, [draw_data+32+RECT.right] |
jbe sdp3a |
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 |
add ebp, [_display.width] |
sub edi, eax |
sub edi, eax |
cmp byte [_display.bytes_per_pixel], 2 |
jz @f |
sub edi, eax |
cmp byte [_display.bytes_per_pixel], 3 |
jz @f |
sub edi, eax |
@@: |
add edi, [_display.lfb_pitch] |
; restore ecx,edx; advance esi to next background line |
mov eax, [esp+28] |
mov ebx, [esp+32] |
add [esp+12], eax |
mov eax, [esp+16] |
adc [esp+16], ebx |
sub eax, [esp+16] |
mov ebx, eax |
lea eax, [eax*3] |
imul eax, [BgrDataWidth] |
sub [esp], eax |
mov eax, [draw_data+32+RECT.left] |
mov [esp+20], eax |
test ebx, ebx |
jz sdp3 |
cmp ebx, -1 |
jnz bgr_resmooth0 |
push edi |
mov esi, bgr_next_line |
mov edi, bgr_cur_line |
mov ecx, [_display.width] |
rep movsd |
jmp bgr_resmooth1 |
sdpdone: |
add esp, 44 |
popad |
mov [EGA_counter], 1 |
cmp [SCR_MODE], 0x12 |
jne @f |
call VGA_drawbackground |
@@: |
ret |
;-------------------------------------- |
align 4 |
smooth_line: |
mov al, [esi+2] |
shl eax, 16 |
mov ax, [esi] |
test ecx, ecx |
jz @f |
mov ebx, [esi+2] |
shr ebx, 8 |
call [overlapping_of_points_ptr] |
@@: |
stosd |
mov eax, [esp+20+8] |
add eax, 1 |
mov [esp+20+8], eax |
cmp eax, [draw_data+32+RECT.right] |
ja @f |
add ecx, [esp+36+8] |
mov eax, edx |
adc edx, [esp+40+8] |
sub eax, edx |
lea eax, [eax*3] |
sub esi, eax |
jmp smooth_line |
@@: |
mov eax, [draw_data+32+RECT.left] |
mov [esp+20+8], eax |
ret |
;------------------------------------------------------------------------------ |
align 16 |
overlapping_of_points: |
if 0 |
; this version of procedure works, but is slower than next version |
push ecx edx |
mov edx, eax |
push esi |
shr ecx, 24 |
mov esi, ecx |
mov ecx, ebx |
movzx ebx, dl |
movzx eax, cl |
sub eax, ebx |
movzx ebx, dh |
imul eax, esi |
add dl, ah |
movzx eax, ch |
sub eax, ebx |
imul eax, esi |
add dh, ah |
ror ecx, 16 |
ror edx, 16 |
movzx eax, cl |
movzx ebx, dl |
sub eax, ebx |
imul eax, esi |
pop esi |
add dl, ah |
mov eax, edx |
pop edx |
ror eax, 16 |
pop ecx |
ret |
else |
push ecx edx |
mov edx, eax |
push esi |
shr ecx, 26 |
mov esi, ecx |
mov ecx, ebx |
shl esi, 9 |
movzx ebx, dl |
movzx eax, cl |
sub eax, ebx |
movzx ebx, dh |
add dl, [BgrAuxTable+(eax+0x100)+esi] |
movzx eax, ch |
sub eax, ebx |
add dh, [BgrAuxTable+(eax+0x100)+esi] |
ror ecx, 16 |
ror edx, 16 |
movzx eax, cl |
movzx ebx, dl |
sub eax, ebx |
add dl, [BgrAuxTable+(eax+0x100)+esi] |
pop esi |
mov eax, edx |
pop edx |
ror eax, 16 |
pop ecx |
ret |
end if |
;------------------------------------------------------------------------------ |
align 4 |
init_background: |
mov edi, BgrAuxTable |
xor edx, edx |
.loop2: |
mov eax, edx |
shl eax, 8 |
neg eax |
mov ecx, 0x200 |
.loop1: |
mov byte [edi], ah |
inc edi |
add eax, edx |
loop .loop1 |
add dl, 4 |
jnz .loop2 |
test byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8) |
jz @f |
mov [overlapping_of_points_ptr], overlapping_of_points_mmx |
@@: |
ret |
;------------------------------------------------------------------------------ |
align 16 |
overlapping_of_points_mmx: |
movd mm0, eax |
movd mm4, eax |
movd mm1, ebx |
pxor mm2, mm2 |
punpcklbw mm0, mm2 |
punpcklbw mm1, mm2 |
psubw mm1, mm0 |
movd mm3, ecx |
psrld mm3, 24 |
packuswb mm3, mm3 |
packuswb mm3, mm3 |
pmullw mm1, mm3 |
psrlw mm1, 8 |
packuswb mm1, mm2 |
paddb mm4, mm1 |
movd eax, mm4 |
ret |
;------------------------------------------------------------------------------ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Rev |
\ No newline at end of property |
/kernel/branches/kolibri-lldw/video/framebuffer.inc |
---|
0,0 → 1,250 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; Synhronization for MenuetOS. ;; |
;; Author: Halyavin Andrey, halyavin@land.ru ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision$ |
struct FRB |
list LHEAD |
magic rd 1 |
handle rd 1 |
destroy rd 1 |
width rd 1 |
height rd 1 |
pitch rd 1 |
format rd 1 |
private rd 1 |
pde rd 8 |
ends |
align 4 |
create_framebuffer: |
mov ecx, sizeof.FRB |
call create_object |
test eax, eax |
jz .fail |
mov [eax+FRB.magic], 'FRMB' |
mov [eax+FRB.destroy], 0 |
.fail: |
ret |
align 4 |
init_video: |
mov ebp, bios_fb |
movzx eax, byte [BOOT.bpp] ; bpp |
mov [_display.bits_per_pixel], eax |
mov [_display.vrefresh], 60 |
movzx eax, word [BOOT.x_res]; X max |
cmp eax, MAX_SCREEN_WIDTH |
ja $ |
mov [_display.width], eax |
mov [ebp+FRB.width], eax |
mov [display_width_standard], eax |
dec eax |
mov [screen_workarea.right], eax |
movzx eax, word [BOOT.y_res]; Y max |
cmp eax, MAX_SCREEN_HEIGHT |
ja $ |
mov [_display.height], eax |
mov [ebp+FRB.height], eax |
mov [display_height_standard], eax |
dec eax |
mov [screen_workarea.bottom], eax |
movzx eax, word [BOOT.vesa_mode] ; screen mode |
mov dword [SCR_MODE], eax |
mov eax, 640 *4 ; Bytes PerScanLine |
cmp [SCR_MODE], word 0x13 ; 320x200 |
je @f |
cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
je @f |
movzx eax, word[BOOT.pitch] ; for other modes |
@@: |
mov [_display.lfb_pitch], eax |
mov [ebp+FRB.pitch], eax |
mov eax, [BOOT.lfb] |
mov [LFBAddress], eax |
mov eax, [_display.width] |
mul [_display.height] |
mov [_display.win_map_size], eax |
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 |
.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 |
.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 |
.finish: |
mov [MOUSE_PICTURE], mousepointer |
mov [_display.check_mouse], check_mouse_area_for_putpixel |
mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
mov ax, word [SCR_MODE] |
cmp ax, 0x0012 |
je .fake |
cmp ax, 0x0013 |
je .fake |
mov esi, [LFBAddress] |
bt [cpu_caps], CAPS_PSE |
jnc .create_page_tables |
mov edx, 0x00400000 |
or esi, PG_GLOBAL+PAT_WC+PG_UWR |
and esi, [pte_valid_mask] |
or esi, PDE_LARGE |
mov [ebp+FRB.pde], esi |
add esi, edx |
mov [ebp+FRB.pde+4], esi |
add esi, edx |
mov [ebp+FRB.pde+8], esi |
add esi, edx |
mov [ebp+FRB.pde+12], esi |
add esi, edx |
.ok: |
call calculate_fast_getting_offset_for_WinMapAddress |
; for Qemu or non standart video cards |
; Unfortunately [BytesPerScanLine] does not always |
; equal to [_display.width] * [ScreenBPP] / 8 |
call calculate_fast_getting_offset_for_LFB |
ret |
.create_page_tables: |
add ebp, FRB.pde |
or esi, PG_GLOBAL+PAT_WC+PG_UWR |
and esi, [pte_valid_mask] |
stdcall alloc_kernel_space, 0x1000 |
mov edi, eax |
mov ebx, 4 |
.new_pd: |
call alloc_page |
lea edx, [eax+PG_UWR] |
mov [ebp], edx |
stdcall map_page, edi, eax, PG_SWR |
mov eax, esi |
mov ecx, 1024 |
@@: |
stosd |
add eax, 0x1000 |
loop @B |
add esi, 0x400000 |
add ebp, 4 |
sub edi, 4096 |
dec ebx |
jnz .new_pd |
stdcall free_kernel_space, edi |
jmp .ok |
.fake: |
mov [BOOT.mtrr], byte 2 |
stdcall alloc_kernel_space, 0x1000 |
push eax ;store in stack for subsequent |
mov edi, eax ;free_kernel_space call |
call alloc_page |
lea edx, [eax+PG_UWR] |
mov [ebp+FRB.pde], edx |
stdcall map_page, edi, eax, PG_SWR |
; max VGA=640*480*4=1228800 bytes |
; + 32*640*4=81920 bytes for mouse pointer |
stdcall alloc_pages, ((1228800+81920)/4096) |
or eax, PG_GLOBAL+PG_UWR |
and eax, [pte_valid_mask] |
mov ecx, (1228800+81920)/4096 |
@@: |
stosd |
add eax, 0x1000 |
loop @B |
call free_kernel_space |
jmp .ok |
align 4 |
set_framebuffer: |
push esi |
push edi |
lea esi, [ecx+FRB.pde] |
mov eax, sys_proc |
cld |
pushfd |
cli |
mov [_display.current_lfb], ecx |
.patch_pde: |
lea edi, [eax+PROC.pdt_0+4096-32] ;last 8 pd entries up to 32Mb framebuffer |
mov ecx, 4 |
rep movsd ;patch pde |
sub esi, 16 |
mov eax, [eax+PROC.list.next] ;next process/address space |
cmp eax, sys_proc |
jne .patch_pde |
bt [cpu_caps], CAPS_PGE |
jnc .cr3_flush |
mov eax, cr4 |
btr eax, 7 ;clear cr4.PGE |
mov cr4, eax ;flush TLB |
bts eax, 7 |
mov cr4, eax ;flush TLB |
.exit: |
popfd |
pop edi |
pop esi |
ret |
.cr3_flush: |
mov eax, cr3 |
mov cr3, eax ;flush TLB |
jmp .exit |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Revision |
\ No newline at end of property |
/kernel/branches/kolibri-lldw/video/vga.inc |
---|
0,0 → 1,534 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; VGA.INC ;; |
;; ;; |
;; 640x480 mode 0x12 VGA functions for MenuetOS ;; |
;; ;; |
;; Paul Butcher, paul.butcher@asa.co.uk ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision$ |
;------------------------------------------------------------------------------ |
align 4 |
paletteVGA: |
;16 colour palette |
mov dx, 0x3c8 |
mov al, 0 |
out dx, al |
mov ecx, 16 |
mov dx, 0x3c9 |
xor eax, eax |
;-------------------------------------- |
align 4 |
palvganew: |
mov al, 0 |
test ah, 4 |
jz palvgalbl1 |
add al, 31 |
test ah, 8 |
jz palvgalbl1 |
add al, 32 |
;-------------------------------------- |
align 4 |
palvgalbl1: |
out dx, al; red 0,31 or 63 |
mov al, 0 |
test ah, 2 |
jz palvgalbl2 |
add al, 31 |
test ah, 8 |
jz palvgalbl2 |
add al, 32 |
;-------------------------------------- |
align 4 |
palvgalbl2: |
out dx, al; blue 0,31 or 63 |
mov al, 0 |
test ah, 1 |
jz palvgalbl3 |
add al, 31 |
test ah, 8 |
jz palvgalbl3 |
add al, 32 |
;-------------------------------------- |
align 4 |
palvgalbl3: |
out dx, al; green 0,31 or 63 |
add ah, 1 |
loop palvganew |
; mov dx, 3ceh |
; mov ax, 0005h |
; out dx, ax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
palette320x200: |
mov edx, 0x3c8 |
xor eax, eax |
out dx, al |
mov ecx, 256 |
mov edx, 0x3c9 |
xor eax, eax |
;-------------------------------------- |
align 4 |
palnew: |
mov al, 0 |
test ah, 64 |
jz pallbl1 |
add al, 21 |
;-------------------------------------- |
align 4 |
pallbl1: |
test ah, 128 |
jz pallbl2 |
add al, 42 |
;-------------------------------------- |
align 4 |
pallbl2: |
out dx, al |
mov al, 0 |
test ah, 8 |
jz pallbl3 |
add al, 8 |
;-------------------------------------- |
align 4 |
pallbl3: |
test ah, 16 |
jz pallbl4 |
add al, 15 |
;-------------------------------------- |
align 4 |
pallbl4: |
test ah, 32 |
jz pallbl5 |
add al, 40 |
;-------------------------------------- |
align 4 |
pallbl5: |
out dx, al |
mov al, 0 |
test ah, 1 |
jz pallbl6 |
add al, 8 |
;-------------------------------------- |
align 4 |
pallbl6: |
test ah, 2 |
jz pallbl7 |
add al, 15 |
;-------------------------------------- |
align 4 |
pallbl7: |
test ah, 4 |
jz pallbl8 |
add al, 40 |
;-------------------------------------- |
align 4 |
pallbl8: |
out dx, al |
add ah, 1 |
loop palnew |
ret |
;------------------------------------------------------------------------------ |
align 4 |
uglobal |
novesachecksum dd 0x0 |
EGA_counter db 0 |
VGA_drawing_screen db 0 |
VGA_8_pixels: |
rb 16 |
temp: |
.cx dd 0 |
endg |
;------------------------------------------------------------------------------ |
align 4 |
checkVga_N13: |
cmp [SCR_MODE], 0x13 |
jne @f |
pushad |
cmp [EGA_counter], 1 |
je novesal |
mov ecx, [MOUSE_X] |
cmp ecx, [novesachecksum] |
jne novesal |
popad |
;-------------------------------------- |
align 4 |
@@: |
ret |
;-------------------------------------- |
align 4 |
novesal: |
mov [novesachecksum], ecx |
mov ecx, 0 |
movzx eax, word [MOUSE_Y] |
cmp eax, 100 |
jge m13l3 |
mov eax, 100 |
;-------------------------------------- |
align 4 |
m13l3: |
cmp eax, 480-100 |
jbe m13l4 |
mov eax, 480-100 |
;-------------------------------------- |
align 4 |
m13l4: |
sub eax, 100 |
imul eax, 640*4 |
add ecx, eax |
movzx eax, word [MOUSE_X] |
cmp eax, 160 |
jge m13l1 |
mov eax, 160 |
;-------------------------------------- |
align 4 |
m13l1: |
cmp eax, 640-160 |
jbe m13l2 |
mov eax, 640-160 |
;-------------------------------------- |
align 4 |
m13l2: |
sub eax, 160 |
shl eax, 2 |
add ecx, eax |
mov esi, [LFBAddress] |
add esi, ecx |
mov edi, VGABasePtr |
mov edx, 200 |
mov ecx, 320 |
cld |
;-------------------------------------- |
align 4 |
m13pix: |
lodsd |
test eax, eax |
jz .save_pixel |
push eax |
mov ebx, eax |
and eax, (128+64+32) ; blue |
shr eax, 5 |
and ebx, (128+64+32)*256; green |
shr ebx, 8+2 |
add eax, ebx |
pop ebx |
and ebx, (128+64)*256*256; red |
shr ebx, 8+8 |
add eax, ebx |
;-------------------------------------- |
align 4 |
.save_pixel: |
stosb |
loop m13pix |
mov ecx, 320 |
add esi, 4*(640-320) |
dec edx |
jnz m13pix |
mov [EGA_counter], 0 |
popad |
ret |
;------------------------------------------------------------------------------ |
align 4 |
VGA_drawbackground: |
; draw all |
pushad |
mov esi, [LFBAddress] |
mov edi, VGABasePtr |
mov ebx, 640/32; 640*480/(8*4) |
mov edx, 480 |
;-------------------------------------- |
align 4 |
@@: |
push ebx edx esi edi |
shl edx, 9 |
lea edx, [edx+edx*4] |
add esi, edx |
shr edx, 5 |
add edi, edx |
call VGA_draw_long_line |
pop edi esi edx ebx |
dec edx |
jnz @r |
call VGA_draw_long_line_1 |
popad |
ret |
;------------------------------------------------------------------------------ |
align 4 |
VGA_draw_long_line: |
mov dx, 3ceh |
mov ax, 0ff08h |
cli |
out dx, ax |
mov ax, 0005h |
out dx, ax |
;-------------------------------------- |
align 4 |
m12pix: |
call VGA_draw_32_pixels |
dec ebx |
jnz m12pix |
mov dx, 3c4h |
mov ax, 0ff02h |
out dx, ax |
mov dx, 3ceh |
mov ax, 0205h |
out dx, ax |
mov dx, 3ceh |
mov al, 08h |
out dx, al |
sti |
ret |
;------------------------------------------------------------------------------ |
align 4 |
VGA_draw_32_pixels: |
xor eax, eax |
mov ebp, VGA_8_pixels |
mov [ebp], eax |
mov [ebp+4], eax |
mov [ebp+8], eax |
mov [ebp+12], eax |
mov ch, 4 |
;-------------------------------------- |
align 4 |
.main_loop: |
mov cl, 8 |
;-------------------------------------- |
align 4 |
.convert_pixels_to_VGA: |
lodsd ; eax = 24bit colour |
test eax, eax |
jz .end |
rol eax, 8 |
mov al, ch |
ror eax, 8 |
mov ch, 1 |
dec cl |
shl ch, cl |
cmp al, 85 |
jbe .p13green |
or [ebp], ch |
cmp al, 170 |
jbe .p13green |
or [ebp+12], ch |
;-------------------------------------- |
align 4 |
.p13green: |
cmp ah, 85 |
jbe .p13red |
or [ebp+4], ch |
cmp ah, 170 |
jbe .p13red |
or [ebp+12], ch |
;-------------------------------------- |
align 4 |
.p13red: |
shr eax, 8 |
cmp ah, 85 |
jbe .p13cont |
or [ebp+8], ch |
cmp ah, 170 |
jbe .p13cont |
or [ebp+12], ch |
;-------------------------------------- |
align 4 |
.p13cont: |
ror eax, 8 |
mov ch, ah |
inc cl |
;-------------------------------------- |
align 4 |
.end: |
dec cl |
jnz .convert_pixels_to_VGA |
inc ebp |
dec ch |
jnz .main_loop |
push esi |
sub ebp, 4 |
mov esi, ebp |
mov dx, 3c4h |
mov ah, 1h |
;-------------------------------------- |
align 4 |
@@: |
mov al, 02h |
out dx, ax |
xchg ax, bp |
lodsd |
mov [edi], eax |
xchg ax, bp |
shl ah, 1 |
cmp ah, 10h |
jnz @r |
add edi, 4 |
pop esi |
ret |
;------------------------------------------------------------------------------ |
align 4 |
VGA_putpixel: |
; eax = x |
; ebx = y |
mov ecx, eax |
mov eax, [esp+32-8+4] ; color |
;-------------------------------------- |
; check for hardware cursor |
cmp [_display.select_cursor], select_cursor |
je @f |
cmp [_display.select_cursor], 0 |
jne .no_mouseunder |
;-------------------------------------- |
align 4 |
@@: |
push ecx |
shl ecx, 16 |
mov cx, bx |
; check mouse area for putpixel |
test eax, 0x04000000 |
jnz @f |
call [_display.check_mouse] |
;-------------------------------------- |
align 4 |
@@: |
pop ecx |
;-------------------------------------- |
align 4 |
.no_mouseunder: |
shl ebx, 9 |
lea ebx, [ebx+ebx*4] ; multiply by 5 |
lea edx, [ebx+ecx*4] ; + x*BytesPerPixel (Vesa2.0 32) |
mov edi, edx |
add edi, [LFBAddress] ; + LFB address |
mov [edi], eax ; write to LFB for Vesa2.0 |
shr edx, 5 ; change BytesPerPixel to 1/8 |
mov edi, edx |
add edi, VGABasePtr ; address of pixel in VGA area |
and ecx, 0x07 ; bit no. (modulo 8) |
pushfd |
; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8) |
xor edx, edx |
test eax, eax |
jz .p13cont |
cmp al, 85 |
jbe .p13green |
or dl, 0x01 |
cmp al, 170 |
jbe .p13green |
or dl, 0x08 |
;-------------------------------------- |
align 4 |
.p13green: |
cmp ah, 85 |
jbe .p13red |
or dl, 0x02 |
cmp ah, 170 |
jbe .p13red |
or dl, 0x08 |
;-------------------------------------- |
align 4 |
.p13red: |
shr eax, 8 |
cmp ah, 85 |
jbe .p13cont |
or dl, 0x04 |
cmp ah, 170 |
jbe .p13cont |
or dl, 0x08 |
;-------------------------------------- |
align 4 |
.p13cont: |
ror edx, 8 |
inc cl |
xor eax, eax |
inc ah |
shr ax, cl |
mov dx, 3cfh |
cli |
out dx, al |
mov al, [edi] ; dummy read |
rol edx, 8 |
mov [edi], dl |
popfd |
ret |
;------------------------------------------------------------------------------ |
align 4 |
VGA__putimage: |
; ecx = size [x|y] |
; edx = coordinates [x|y] |
pushad |
rol edx, 16 |
movzx eax, dx |
rol edx, 16 |
movzx ebx, dx |
movzx edx, cx |
rol ecx, 16 |
movzx ecx, cx |
call VGA_draw_bar_1 |
popad |
ret |
;------------------------------------------------------------------------------ |
align 4 |
VGA_draw_bar: |
; eax cx |
; ebx cy |
; ecx xe |
; edx ye |
pushad |
sub ecx, eax |
sub edx, ebx |
and eax, 0xffff |
and ebx, 0xffff |
and ecx, 0xffff |
and edx, 0xffff |
call VGA_draw_bar_1 |
popad |
ret |
;------------------------------------------------------------------------------ |
align 4 |
VGA_draw_bar_1: |
mov [temp.cx], eax |
mov eax, [TASK_BASE] |
add ebx, [eax-twdw + 4] |
mov eax, [eax-twdw + 0] |
add eax, [temp.cx] |
and eax, 0xfff8 |
shl ebx, 9 |
lea ebx, [ebx+ebx*4] ; multiply by 5 |
lea ebx, [ebx+eax*4] ; + x*BytesPerPixel (Vesa2.0 32) |
mov esi, ebx |
add esi, [LFBAddress] ; + LFB address |
shr ebx, 5 ; change BytesPerPixel to 1/8 |
mov edi, ebx |
add edi, VGABasePtr ; address of pixel in VGA area |
mov ebx, ecx |
shr ebx, 5 |
inc ebx |
;-------------------------------------- |
align 4 |
.main_loop: |
call VGA_draw_long_line_1 |
dec edx |
jnz .main_loop |
call VGA_draw_long_line_1 |
ret |
;------------------------------------------------------------------------------ |
align 4 |
VGA_draw_long_line_1: |
push ebx edx esi edi |
shl edx, 9 |
lea edx, [edx+edx*4] |
add esi, edx |
shr edx, 5 |
add edi, edx |
call VGA_draw_long_line |
pop edi esi edx ebx |
ret |
;------------------------------------------------------------------------------ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Rev |
\ No newline at end of property |
/kernel/branches/kolibri-lldw/video/vesa12.inc |
---|
0,0 → 1,1004 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; VESA12.INC ;; |
;; ;; |
;; Vesa 1.2 functions for MenuetOS ;; |
;; ;; |
;; Copyright 2002 Ville Turjanmaa ;; |
;; ;; |
;; quickcode@mail.ru - bankswitch for S3 cards ;; |
;; ;; |
;; See file COPYING for details ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision$ |
TRIDENT = 0 |
S3_VIDEO = 0 |
INTEL_VIDEO = 0 |
if TRIDENT |
if S3_VIDEO or INTEL_VIDEO |
stop |
end if |
end if |
if S3_VIDEO |
if TRIDENT or INTEL_VIDEO |
stop |
end if |
end if |
if INTEL_VIDEO |
if S3_VIDEO or TRIDENT |
stop |
end if |
end if |
; A complete video driver should include the following types of function |
; |
; Putpixel |
; Getpixel |
; |
; Drawimage |
; Drawbar |
; |
; Drawbackground |
; |
; |
; Modifying the set_bank -function is mostly enough |
; for different Vesa 1.2 setups. |
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
; set_bank for Trident videocards, work on Trident 9440 |
; modified by Mario79 |
if TRIDENT |
set_bank: |
pushfd |
cli |
cmp al, [BANK_RW] |
je .retsb |
mov [BANK_RW], al |
push dx |
mov dx, 3D8h |
out dx, al |
pop dx |
.retsb: |
popfd |
ret |
end if |
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
; set_bank for S3 videocards, work on S3 ViRGE PCI (325) |
; modified by kmeaw |
if S3_VIDEO |
set_bank: |
pushfd |
cli |
cmp al, [BANK_RW] |
je .retsb |
mov [BANK_RW], al |
push ax |
push dx |
push cx |
mov cl, al |
mov dx, 0x3D4 |
mov al, 0x38 |
out dx, al ;CR38 Register Lock 1 ;Note: Traditionally 48h is used to |
;unlock and 00h to lock |
inc dx |
mov al, 0x48 |
out dx, al ;3d5 -? |
dec dx |
mov al, 0x31 |
out dx, al ;CR31 Memory Configuration Register |
;0 Enable Base Address Offset (CPUA BASE). Enables bank operation if set, ;disables if clear. |
;4-5 Bit 16-17 of the Display Start Address. For the 801/5,928 see index 51h, |
;for the 864/964 see index 69h. |
inc dx |
in al, dx |
dec dx |
mov ah, al |
mov al, 0x31 |
out dx, ax |
mov al, ah |
or al, 9 |
inc dx |
out dx, al |
dec dx |
mov al, 0x35 |
out dx, al ;CR35 CRT Register Lock |
inc dx |
in al, dx |
dec dx |
and al, 0xF0 |
mov ch, cl |
and ch, 0x0F |
or ch, al |
mov al, 0x35 |
out dx, al |
inc dx |
mov al, ch |
out dx, ax |
dec dx |
mov al, 0x51 ;Extended System Control 2 Register |
out dx, al |
inc dx |
in al, dx |
dec dx |
and al, 0xF3 |
shr cl, 2 |
and cl, 0x0C |
or cl, al |
mov al, 0x51 |
out dx, al |
inc dx |
mov al, cl |
out dx, al |
dec dx |
mov al, 0x38 |
out dx, al |
inc dx |
xor al, al |
out dx, al |
dec dx |
pop cx |
pop dx |
pop ax |
.retsb: |
popfd |
ret |
end if |
;Set bank function for Intel 810/815 chipsets |
; *****Modified by Protopopius, Russia.***** |
; ********* http://menuetos.hut.ru ************** |
; ************************************************ |
if INTEL_VIDEO |
set_bank: |
pushfd |
cli |
cmp al, [BANK_RW] |
je .retsb |
mov [BANK_RW], al |
push ax |
push dx |
mov dx, 3CEh |
mov ah, al ; Save value for later use |
mov al, 10h ; Index GR10 (Address Mapping) |
out dx, al ; Select GR10 |
inc dl |
mov al, 3 ; Set bits 0 and 1 (Enable linear page mapping) |
out dx, al ; Write value |
dec dl |
mov al, 11h ; Index GR11 (Page Selector) |
out dx, al ; Select GR11 |
inc dl |
mov al, ah ; Write address |
out dx, al ; Write the value |
pop dx |
pop ax |
.retsb: |
popfd |
ret |
end if |
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!} |
if (TRIDENT or S3_VIDEO or INTEL_VIDEO) |
else |
set_bank: |
pushfd |
cli |
cmp al, [BANK_RW] |
je .retsb |
mov [BANK_RW], al |
push ax |
push dx |
mov ah, al |
mov dx, 0x03D4 |
mov al, 0x39 |
out dx, al |
inc dl |
mov al, 0xA5 |
out dx, al |
dec dl |
mov al, 6Ah |
out dx, al |
inc dl |
mov al, ah |
out dx, al |
dec dl |
mov al, 0x39 |
out dx, al |
inc dl |
mov al, 0x5A |
out dx, al |
dec dl |
pop dx |
pop ax |
.retsb: |
popfd |
ret |
end if |
vesa12_drawbackground: |
call [_display.disable_mouse] |
push eax |
push ebx |
push ecx |
push edx |
xor edx, edx |
mov eax, dword[BgrDataWidth] |
mov ebx, dword[BgrDataHeight] |
mul ebx |
mov ebx, 3 |
mul ebx |
mov [imax], eax |
mov eax, [draw_data+32+RECT.left] |
mov ebx, [draw_data+32+RECT.top] |
xor edi, edi;no force |
v12dp3: |
push eax |
push ebx |
cmp [BgrDrawMode], dword 1 ; tiled background |
jne no_vesa12_tiled_bgr |
push edx |
xor edx, edx |
div dword [BgrDataWidth] |
push edx |
mov eax, ebx |
xor edx, edx |
div dword [BgrDataHeight] |
mov ebx, edx |
pop eax |
pop edx |
no_vesa12_tiled_bgr: |
cmp [BgrDrawMode], dword 2 ; stretched background |
jne no_vesa12_stretched_bgr |
push edx |
mul dword [BgrDataWidth] |
mov ecx, [Screen_Max_X] |
inc ecx |
div ecx |
push eax |
mov eax, ebx |
mul dword [BgrDataHeight] |
mov ecx, [Screen_Max_Y] |
inc ecx |
div ecx |
mov ebx, eax |
pop eax |
pop edx |
no_vesa12_stretched_bgr: |
mov esi, ebx |
imul esi, dword [BgrDataWidth] |
add esi, eax |
lea esi, [esi*3] |
add esi, [img_background];IMG_BACKGROUND |
pop ebx |
pop eax |
v12di4: |
mov cl, [esi+2] |
shl ecx, 16 |
mov cx, [esi] |
pusha |
mov esi, eax |
mov edi, ebx |
mov eax, [Screen_Max_X] |
add eax, 1 |
mul ebx |
add eax, [_WinMapAddress] |
cmp [eax+esi], byte 1 |
jnz v12nbgp |
mov eax, [BytesPerScanLine] |
mov ebx, edi |
mul ebx |
add eax, esi |
lea eax, [VGABasePtr+eax+esi*2] |
cmp [ScreenBPP], byte 24 |
jz v12bgl3 |
add eax, esi |
v12bgl3: |
push ebx |
push eax |
sub eax, VGABasePtr |
shr eax, 16 |
call set_bank |
pop eax |
and eax, 65535 |
add eax, VGABasePtr |
pop ebx |
mov [eax], cx |
add eax, 2 |
shr ecx, 16 |
mov [eax], cl |
sti |
v12nbgp: |
popa |
add esi, 3 |
inc eax |
cmp eax, [draw_data+32+RECT.right] |
jg v12nodp31 |
jmp v12dp3 |
v12nodp31: |
mov eax, [draw_data+32+RECT.left] |
inc ebx |
cmp ebx, [draw_data+32+RECT.bottom] |
jg v12dp4 |
jmp v12dp3 |
v12dp4: |
pop edx |
pop ecx |
pop ebx |
pop eax |
ret |
vesa12_drawbar: |
call [_display.disable_mouse] |
;; mov [novesachecksum],dword 0 |
sub edx, ebx |
sub ecx, eax |
push esi |
push edi |
push eax |
push ebx |
push ecx |
push edx |
mov ecx, [TASK_BASE] |
add eax, [ecx-twdw+WDATA.box.left] |
add ebx, [ecx-twdw+WDATA.box.top] |
push eax |
mov eax, ebx ; y |
mov ebx, [BytesPerScanLine] |
mul ebx |
pop ecx |
add eax, ecx ; x |
add eax, ecx |
add eax, ecx |
cmp [ScreenBPP], byte 24; 24 or 32 bpp ? - x start |
jz dbpi2412 |
add eax, ecx |
dbpi2412: |
add eax, VGABasePtr |
mov edi, eax |
; x size |
mov eax, [esp+4]; [esp+6] |
mov ecx, eax |
add ecx, eax |
add ecx, eax |
cmp [ScreenBPP], byte 24; 24 or 32 bpp ? - x size |
jz dbpi24312 |
add ecx, eax |
dbpi24312: |
mov ebx, [esp+0] |
; check limits ? |
push eax |
push ecx |
mov eax, [TASK_BASE] |
mov ecx, [eax+draw_data-CURRENT_TASK+RECT.left] |
cmp ecx, 0 |
jnz dbcblimitlset12 |
mov ecx, [eax+draw_data-CURRENT_TASK+RECT.top] |
cmp ecx, 0 |
jnz dbcblimitlset12 |
mov ecx, [eax+draw_data-CURRENT_TASK+RECT.right] |
cmp ecx, [Screen_Max_X] |
jnz dbcblimitlset12 |
mov ecx, [eax+draw_data-CURRENT_TASK+RECT.bottom] |
cmp ecx, [Screen_Max_Y] |
jnz dbcblimitlset12 |
pop ecx |
pop eax |
push dword 0 |
jmp dbcblimitlno12 |
dbcblimitlset12: |
pop ecx |
pop eax |
push dword 1 |
dbcblimitlno12: |
cmp [ScreenBPP], byte 24; 24 or 32 bpp ? |
jz dbpi24bit12 |
jmp dbpi32bit12 |
; DRAWBAR 24 BBP |
dbpi24bit12: |
push eax |
push ebx |
push edx |
mov eax, ecx |
mov ebx, 3 |
div ebx |
mov ecx, eax |
pop edx |
pop ebx |
pop eax |
cld |
dbnewpi12: |
push ebx |
push edi |
push ecx |
xor edx, edx |
mov eax, edi |
sub eax, VGABasePtr |
mov ebx, 3 |
div ebx |
add eax, [_WinMapAddress] |
mov ebx, [CURRENT_TASK] |
cld |
dbnp2412: |
mov dl, [eax] |
push eax |
push ecx |
cmp dl, bl |
jnz dbimp24no12 |
cmp [esp+5*4], dword 0 |
jz dbimp24yes12 |
; call dbcplimit |
; jnz dbimp24no12 |
dbimp24yes12: |
push edi |
mov eax, edi |
sub eax, VGABasePtr |
shr eax, 16 |
call set_bank |
and edi, 0xffff |
add edi, VGABasePtr |
mov eax, [esp+8+3*4+16+4+4] |
stosw |
shr eax, 16 |
stosb |
sti |
pop edi |
add edi, 3 |
pop ecx |
pop eax |
inc eax |
loop dbnp2412 |
jmp dbnp24d12 |
dbimp24no12: |
pop ecx |
pop eax |
cld |
add edi, 3 |
inc eax |
loop dbnp2412 |
dbnp24d12: |
mov eax, [esp+3*4+16+4] |
test eax, 0x80000000 |
jz nodbgl2412 |
cmp al, 0 |
jz nodbgl2412 |
dec eax |
mov [esp+3*4+16+4], eax |
nodbgl2412: |
pop ecx |
pop edi |
pop ebx |
add edi, [BytesPerScanLine] |
dec ebx |
jz dbnonewpi12 |
jmp dbnewpi12 |
dbnonewpi12: |
add esp, 7*4 |
ret |
; DRAWBAR 32 BBP |
dbpi32bit12: |
cld |
shr ecx, 2 |
dbnewpi3212: |
push ebx |
push edi |
push ecx |
mov eax, edi |
sub eax, VGABasePtr |
shr eax, 2 |
add eax, [_WinMapAddress] |
mov ebx, [CURRENT_TASK] |
cld |
dbnp3212: |
mov dl, [eax] |
push eax |
push ecx |
cmp dl, bl |
jnz dbimp32no12 |
cmp [esp+5*4], dword 0 |
jz dbimp32yes12 |
; call dbcplimit |
; jnz dbimp32no12 |
dbimp32yes12: |
push edi |
mov eax, edi |
sub eax, VGABasePtr |
shr eax, 16 |
call set_bank |
and edi, 0xffff |
add edi, VGABasePtr |
mov eax, [esp+8+3*4+16+4+4] |
stosw |
shr eax, 16 |
stosb |
sti |
pop edi |
add edi, 4 |
inc ebp |
pop ecx |
pop eax |
inc eax |
loop dbnp3212 |
jmp dbnp32d12 |
dbimp32no12: |
pop ecx |
pop eax |
inc eax |
add edi, 4 |
inc ebp |
loop dbnp3212 |
dbnp32d12: |
mov eax, [esp+12+16+4] |
test eax, 0x80000000 |
jz nodbgl3212 |
cmp al, 0 |
jz nodbgl3212 |
dec eax |
mov [esp+12+16+4], eax |
nodbgl3212: |
pop ecx |
pop edi |
pop ebx |
add edi, [BytesPerScanLine] |
dec ebx |
jz nodbnewpi3212 |
jmp dbnewpi3212 |
nodbnewpi3212: |
add esp, 7*4 |
ret |
Vesa12_putpixel24: |
mov edi, eax; x |
mov eax, ebx; y |
lea edi, [edi+edi*2] |
mov ebx, [BytesPerScanLine] |
mul ebx |
add edi, eax |
mov eax, edi |
shr eax, 16 |
call set_bank |
and edi, 65535 |
add edi, VGABasePtr |
mov eax, [esp+28] |
stosw |
shr eax, 16 |
mov [edi], al |
sti |
ret |
Vesa12_putpixel32: |
mov edi, eax; x |
mov eax, ebx; y |
shl edi, 2 |
mov ebx, [BytesPerScanLine] |
mul ebx |
add edi, eax |
mov eax, edi |
shr eax, 16 |
call set_bank |
and edi, 65535 |
add edi, VGABasePtr |
mov ecx, [esp+28] |
mov [edi], ecx |
sti |
ret |
Vesa12_getpixel24: |
mov edi, eax; x |
mov eax, ebx; y |
lea edi, [edi+edi*2] |
mov ebx, [BytesPerScanLine] |
mul ebx |
add edi, eax |
mov eax, edi |
shr eax, 16 |
call set_bank |
and edi, 65535 |
add edi, VGABasePtr |
mov ecx, [edi] |
and ecx, 255*256*256+255*256+255 |
sti |
ret |
Vesa12_getpixel32: |
mov edi, eax; x |
mov eax, ebx; y |
shl edi, 2 |
mov ebx, [BytesPerScanLine] |
xor edx, edx |
mul ebx |
add edi, eax |
mov eax, edi |
shr eax, 16 |
call set_bank |
and edi, 65535 |
add edi, VGABasePtr |
mov ecx, [edi] |
and ecx, 255*256*256+255*256+255 |
sti |
ret |
vesa12_putimage: |
; ebx = pointer to image |
; ecx = size [x|y] |
; edx = coordinates [x|y] |
; ebp = pointer to 'get' function |
; esi = pointer to 'init' function |
; edi = parameter for 'get' function |
; mov ebx,image |
; mov ecx,320*65536+240 |
; mov edx,20*65536+20 |
call [_display.disable_mouse] |
mov [novesachecksum], dword 0 |
push esi |
push edi |
push eax |
push ebx |
push ecx |
push edx |
movzx eax, word [esp+2] |
movzx ebx, word [esp+0] |
mov ecx, [TASK_BASE] |
add eax, [ecx-twdw+WDATA.box.left] |
add ebx, [ecx-twdw+WDATA.box.top] |
push eax |
mov eax, ebx ; y |
mul dword [BytesPerScanLine] |
pop ecx |
add eax, ecx ; x |
add eax, ecx |
add eax, ecx |
cmp [ScreenBPP], byte 24; 24 or 32 bpp ? - x start |
jz pi2412 |
add eax, ecx |
pi2412: |
add eax, VGABasePtr |
mov edi, eax |
; x size |
movzx ecx, word [esp+6] |
mov esi, [esp+8] |
movzx ebx, word [esp+4] |
; check limits while draw ? |
push ecx |
mov eax, [TASK_BASE] |
cmp dword [eax+draw_data-CURRENT_TASK+RECT.left], 0 |
jnz dbcblimitlset212 |
cmp dword [eax+draw_data-CURRENT_TASK+RECT.top], 0 |
jnz dbcblimitlset212 |
mov ecx, [eax+draw_data-CURRENT_TASK+RECT.right] |
cmp ecx, [Screen_Max_X] |
jnz dbcblimitlset212 |
mov ecx, [eax+draw_data-CURRENT_TASK+RECT.bottom] |
cmp ecx, [Screen_Max_Y] |
jnz dbcblimitlset212 |
pop ecx |
push 0 |
jmp dbcblimitlno212 |
dbcblimitlset212: |
pop ecx |
push 1 |
dbcblimitlno212: |
cmp [ScreenBPP], byte 24; 24 or 32 bpp ? |
jnz pi32bit12 |
pi24bit12: |
newpi12: |
push edi |
push ecx |
push ebx |
mov edx, edi |
sub edx, VGABasePtr |
mov ebx, 3 |
div ebx |
add edx, [_WinMapAddress] |
mov ebx, [CURRENT_TASK] |
mov bh, [esp+4*3] |
np2412: |
cmp bl, [edx] |
jnz imp24no12 |
; mov eax,[esi] |
push dword [esp+4*3+20] |
call ebp |
; cmp bh,0 |
; jz imp24yes12 |
; call dbcplimit |
; jnz imp24no12 |
imp24yes12: |
push edi |
push eax |
mov eax, edi |
sub eax, VGABasePtr |
shr eax, 16 |
call set_bank |
pop eax |
and edi, 0xffff |
add edi, VGABasePtr |
mov [edi], ax |
shr eax, 16 |
mov [edi+2], al |
pop edi |
imp24no12: |
inc edx |
; add esi,3 |
add edi, 3 |
dec ecx |
jnz np2412 |
np24d12: |
pop ebx |
pop ecx |
pop edi |
add edi, [BytesPerScanLine] |
add esi, [esp+32] |
cmp ebp, putimage_get1bpp |
jz .correct |
cmp ebp, putimage_get2bpp |
jz .correct |
cmp ebp, putimage_get4bpp |
jnz @f |
.correct: |
mov eax, [esp+20] |
mov byte[eax], 80h |
@@: |
dec ebx |
jnz newpi12 |
nonewpi12: |
pop eax edx ecx ebx eax edi esi |
xor eax, eax |
ret |
pi32bit12: |
newpi3212: |
push edi |
push ecx |
push ebx |
mov edx, edi |
sub edx, VGABasePtr |
shr edx, 2 |
add edx, [_WinMapAddress] |
mov ebx, [CURRENT_TASK] |
mov bh, [esp+4*3] |
np3212: |
cmp bl, [edx] |
jnz imp32no12 |
; mov eax,[esi] |
push dword [esp+4*3+20] |
call ebp |
; cmp bh,0 |
; jz imp32yes12 |
; call dbcplimit |
; jnz imp32no12 |
imp32yes12: |
push edi |
push eax |
mov eax, edi |
sub eax, VGABasePtr |
shr eax, 16 |
call set_bank |
pop eax |
and edi, 0xffff |
mov [edi+VGABasePtr], eax |
pop edi |
imp32no12: |
inc edx |
; add esi,3 |
add edi, 4 |
dec ecx |
jnz np3212 |
np32d12: |
pop ebx |
pop ecx |
pop edi |
add edi, [BytesPerScanLine] |
cmp ebp, putimage_get1bpp |
jz .correct |
cmp ebp, putimage_get2bpp |
jz .correct |
cmp ebp, putimage_get4bpp |
jnz @f |
.correct: |
mov eax, [esp+20] |
mov byte[eax], 80h |
@@: |
dec ebx |
jnz newpi3212 |
nonewpi3212: |
pop eax edx ecx ebx eax edi esi |
xor eax, eax |
ret |
vesa12_read_screen_pixel: |
and eax, 0x3FFFFF |
cmp [ScreenBPP], byte 24; 24 or 32 bpp ? |
jz v12rsp24 |
mov edi, eax |
shl edi, 2 |
mov eax, edi |
shr eax, 16 |
call set_bank |
and edi, 65535 |
add edi, VGABasePtr |
mov eax, [edi] |
and eax, 0x00ffffff |
ret |
v12rsp24: |
imul eax, 3 |
mov edi, eax |
shr eax, 16 |
call set_bank |
and edi, 65535 |
add edi, VGABasePtr |
mov eax, [edi] |
and eax, 0x00ffffff |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Rev |
\ No newline at end of property |
/kernel/branches/kolibri-lldw/video/arrow.cur |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/kernel/branches/kolibri-lldw/video/arrow_clock.cur |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/kernel/branches/kolibri-lldw/video/. |
---|
Property changes: |
Added: svn:ignore |
+*.mnt |
+lang.inc |
+*.bat |
+out.txt |
+scin* |
+*.obj |