Subversion Repositories Kolibri OS

Compare Revisions

Ignore whitespace Rev 467 → Rev 469

/kernel/trunk/const.inc
282,7 → 282,6
RESERVED_PORTS equ (OS_BASE+0x02D0000)
IRQ_SAVE equ (OS_BASE+0x02E0000)
BOOT_VAR equ (OS_BASE+0x02f0000)
IMG_BACKGROUND equ (OS_BASE+0x0300000)
WinMapAddress equ (OS_BASE+0x0460000)
display_data equ (OS_BASE+0x0460000)
 
/kernel/trunk/data32.inc
329,6 → 329,8
com2_mouse_detected rb 1
;* end code - Mario79
 
img_background rd 1
mem_BACKGROUND rd 1
wraw_bacground_select rb 1
 
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
/kernel/trunk/kernel.asm
500,12 → 500,22
mov [graph_data_l+4],al
mov [graph_data_l+7],ah
 
 
mov [CURRENT_TASK],dword 1
mov [TASK_COUNT],dword 1
mov [TASK_BASE],dword TASK_DATA
mov [current_slot], SLOT_BASE+256
 
; set background
xor eax,eax
inc eax
mov [display_data-12],eax
mov [display_data-8],eax
mov [display_data-4],eax
mov [mem_BACKGROUND],4095
stdcall kernel_alloc, [mem_BACKGROUND]
mov [img_background], eax
 
 
;!!!!!!!!!!!!!!!!!!!!!!!!!!
include 'detect/disks.inc'
;!!!!!!!!!!!!!!!!!!!!!!!!!!
2296,8 → 2306,37
mov [display_data-8],ebx
mov [display_data-4],ecx
; mov [bgrchanged],1
 
pushad
; return memory for old background
stdcall kernel_free, [img_background]
; calculate RAW size
xor eax,eax
inc eax
cmp [display_data-8],eax
jae @f
mov [display_data-8],eax
@@:
cmp [display_data-4],eax
jae @f
mov [display_data-4],eax
@@:
mov eax,[display_data-8]
imul eax,[display_data-4]
inc eax
imul eax,3
mov [mem_BACKGROUND],eax
; get memory for new background
stdcall kernel_alloc, [mem_BACKGROUND]
test eax, eax
jz .exit_mem
mov [img_background], eax
.exit_mem:
popad
 
sbgrr:
ret
 
nosb1:
 
cmp eax,2 ; SET PIXEL
2309,7 → 2348,12
and edx,0xFF000000 ;255*256*256*256
and ecx,0x00FFFFFF ;255*256*256+255*256+255
add edx,ecx
mov [ebx+IMG_BACKGROUND],edx
 
; mov [ebx+IMG_BACKGROUND],edx
push eax
mov eax,[img_background]
mov [ebx+eax],edx
pop eax
; mov [bgrchanged],1
ret
nosb2:
2342,29 → 2386,17
; bughere
mov edi, [TASK_BASE]
add ebx, [edi+TASKDATA.mem_start]
; mov esi, ebx
; mov edi, ecx
mov eax, ebx
mov ebx, ecx
add ecx, edx
cmp ecx, 0x160000-16
ja .fin
; add edi, 0x300000
add ebx, IMG_BACKGROUND
add ebx, [img_background] ;IMG_BACKGROUND
mov ecx, edx
cmp ecx, 0x160000-16
ja .fin
; mov [bgrchanged],1
; cld
; rep movsb
call memmove
.fin:
ret
nosb5:
 
ret
 
 
align 4
 
sys_getbackground:
2380,10 → 2412,13
 
cmp eax,2 ; PIXEL
jnz nogb2
mov edx,0x160000-16
cmp edx,ebx
jbe nogb2
mov eax, [ebx+IMG_BACKGROUND]
; mov edx,0x160000-16
; cmp edx,ebx
; jbe nogb2
; mov eax, [ebx+IMG_BACKGROUND]
mov eax,[img_background]
mov eax,[ebx+eax]
 
and eax, 0xFFFFFF
mov [esp+36],eax
ret
3533,12 → 3568,12
 
; all black
 
mov [display_data-8],dword 4 ; size x
mov [display_data-4],dword 2 ; size y
; mov [display_data-8],dword 4 ; size x
; mov [display_data-4],dword 2 ; size y
 
mov edi, IMG_BACKGROUND ; set background to black
mov edi, [img_background] ;IMG_BACKGROUND ; set background to black
xor eax, eax
mov ecx, 0x0fff00 / 4
mov ecx, 1023 ;0x0fff00 / 4
cld
rep stosd
 
/kernel/trunk/video/vesa12.inc
220,7 → 220,7
 
push eax
push ebx
mov esi,IMG_BACKGROUND
mov esi,[img_background] ;IMG_BACKGROUND
 
cmp [WinMapAddress-12],dword 1 ; tiled background
jne no_vesa12_tiled_bgr
282,7 → 282,7
add esi,eax
add esi,eax
add esi,eax
add esi,IMG_BACKGROUND
add esi,[img_background] ;IMG_BACKGROUND
pop ebx
pop eax
 
/kernel/trunk/video/vesa20.inc
41,30 → 41,29
; ecx = 00 RR GG BB
 
getpixel:
push eax ebx edx edi
call dword [GETPIXEL]
pop edi edx ebx eax
ret
push eax ebx edx edi
call dword [GETPIXEL]
pop edi edx ebx eax
ret
 
Vesa20_getpixel24:
; eax = x
; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3
add edi, ebx ; edi = x*3+(y*y multiplier)
add edi, [LFBAddress] ; ebx = where pixel is in memory
mov ecx, [edi]
and ecx, 0xffffff
ret
; eax = x
; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3
add edi, ebx ; edi = x*3+(y*y multiplier)
add edi, [LFBAddress] ; ebx = where pixel is in memory
mov ecx, [edi]
and ecx, 0xffffff
ret
 
 
Vesa20_getpixel32:
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
add edi, [LFBAddress] ; ebx = where pixel is in memory
mov ecx, [edi]
and ecx, 0xffffff
ret
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
add edi, [LFBAddress] ; ebx = where pixel is in memory
mov ecx, [edi]
and ecx, 0xffffff
ret
 
;*************************************************
 
102,207 → 101,180
; ebp = pointer to 'get' function
; esi = pointer to 'init' function
; edi = parameter for 'get' function
 
vesa20_putimage:
pushad
call [disable_mouse]
 
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
pushad
call [disable_mouse]
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
; \begin{diamond}[20.08.2006]
; note that WDATA.box.width is one pixel less than real window x-size
inc ebx
inc ebx
; \end{diamond}[20.08.2006]
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
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
; \begin{diamond}[20.08.2006]
inc ebx
inc ebx
; \end{diamond}[20.08.2006]
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]
sub eax, [putimg.real_sx]
;; 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, [ScreenWidth]
inc eax
sub eax, [putimg.real_sx]
mov [putimg.winmap_newline], eax
 
; screen new line increment
mov eax, [BytesPerScanLine]
mov ecx, [putimg.real_sx]
movzx ebx, byte [ScreenBPP]
shr ebx, 3
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 eax, [putimg.abs_cx]
movzx ebx, byte [ScreenBPP]
shr ebx, 3
imul eax, ebx
add edx, eax
add edx, [LFBAddress]
 
; pointer to pixel map
mov eax, [putimg.abs_cy]
imul eax, [ScreenWidth]
add eax, [putimg.abs_cy]
add eax, [putimg.abs_cx]
add eax, WinMapAddress
xchg eax, ebp
 
; get process number
mov ebx, [CURRENT_TASK]
 
cmp byte [ScreenBPP], 32
je put_image_end_32
 
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]
sub eax, [putimg.real_sx]
;; 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, [ScreenWidth]
inc eax
sub eax, [putimg.real_sx]
mov [putimg.winmap_newline], eax
; screen new line increment
mov eax, [BytesPerScanLine]
mov ecx, [putimg.real_sx]
movzx ebx, byte [ScreenBPP]
shr ebx, 3
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 eax, [putimg.abs_cx]
movzx ebx, byte [ScreenBPP]
shr ebx, 3
imul eax, ebx
add edx, eax
add edx, [LFBAddress]
; pointer to pixel map
mov eax, [putimg.abs_cy]
imul eax, [ScreenWidth]
add eax, [putimg.abs_cy]
add eax, [putimg.abs_cx]
add eax, WinMapAddress
xchg eax, ebp
; get process number
mov ebx, [CURRENT_TASK]
cmp byte [ScreenBPP], 32
je put_image_end_32
;put_image_end_24:
mov edi, [putimg.real_sy]
align 4
.new_line:
mov ecx, [putimg.real_sx]
mov edi, [putimg.real_sy]
align 4
.new_line:
mov ecx, [putimg.real_sx]
; push ebp edx
align 4
.new_x:
push [putimg.edi]
mov eax, [putimg.ebp+4]
call eax
cmp [ebp], bl
jne .skip
; mov eax, [esi] ; eax = RRBBGGRR
mov [edx], ax
shr eax, 16
mov [edx+2], al
.skip:
; add esi, 3 ;[putimg.source_bpp]
add edx, 3
inc ebp
dec ecx
jnz .new_x
; pop edx ebp
add esi, [putimg.line_increment]
add edx, [putimg.screen_newline] ;[BytesPerScanLine]
add ebp, [putimg.winmap_newline] ;[ScreenWidth]
; inc ebp
dec edi
jnz .new_line
.finish:
add esp, putimg.stack_data
popad
ret
 
; push ebp edx
align 4
.new_x:
 
push [putimg.edi]
mov eax, [putimg.ebp+4]
call eax
cmp [ebp], bl
jne .skip
; mov eax, [esi] ; eax = RRBBGGRR
mov [edx], ax
shr eax, 16
mov [edx+2], al
.skip:
 
; add esi, 3 ;[putimg.source_bpp]
add edx, 3
inc ebp
 
dec ecx
jnz .new_x
; pop edx ebp
 
add esi, [putimg.line_increment]
add edx, [putimg.screen_newline] ;[BytesPerScanLine]
add ebp, [putimg.winmap_newline] ;[ScreenWidth]
;inc ebp
 
dec edi
jnz .new_line
.finish:
add esp, putimg.stack_data
popad
ret
 
put_image_end_32:
mov edi, [putimg.real_sy]
align 4
.new_line:
mov ecx, [putimg.real_sx]
mov edi, [putimg.real_sy]
align 4
.new_line:
mov ecx, [putimg.real_sx]
; push ebp edx
align 4
.new_x:
push [putimg.edi]
mov eax, [putimg.ebp+4]
call eax
cmp [ebp], bl
jne .skip
; mov eax, [esi] ; ecx = RRBBGGRR
mov [edx], eax
.skip:
; add esi, [putimg.source_bpp]
add edx, 4
inc ebp
dec ecx
jnz .new_x
; pop edx ebp
add esi, [putimg.line_increment]
add edx, [putimg.screen_newline] ;[BytesPerScanLine]
add ebp, [putimg.winmap_newline] ;[ScreenWidth]
; inc ebp
dec edi
jnz .new_line
.finish:
add esp, putimg.stack_data
popad
call VGA__putimage
mov [EGA_counter],1
ret
 
; push ebp edx
align 4
.new_x:
 
push [putimg.edi]
mov eax, [putimg.ebp+4]
call eax
cmp [ebp], bl
jne .skip
; mov eax, [esi] ; ecx = RRBBGGRR
mov [edx], eax
.skip:
 
; add esi, [putimg.source_bpp]
add edx, 4
inc ebp
 
dec ecx
jnz .new_x
; pop edx ebp
 
add esi, [putimg.line_increment]
add edx, [putimg.screen_newline] ;[BytesPerScanLine]
add ebp, [putimg.winmap_newline] ;[ScreenWidth]
;inc ebp
 
dec edi
jnz .new_line
.finish:
add esp, putimg.stack_data
popad
call VGA__putimage
mov [EGA_counter],1
ret
 
 
;*************************************************
align 4
__sys_putpixel:
313,78 → 285,69
; edi = 0x00000001 force
 
;;; mov [novesachecksum], dword 0
pushad
test edi,1 ; force ?
jnz .forced
; not forced:
push ecx ; save 24th bit in case negative pixel wanted
call checkpixel
test ecx,ecx
pop ecx
jnz .exit
.forced:
cmp [ScreenWidth], eax
jb .exit
cmp [ScreenHeight], ebx
jb .exit
.ok:
; check if negation
test ecx,0x01000000
jz .noneg
call getpixel
not ecx
mov [esp+32-8],ecx
.noneg:
; OK to set pixel
call dword [PUTPIXEL] ; call the real put_pixel function
.exit:
popad
ret
 
pushad
test edi,1 ; force ?
jnz .forced
; not forced:
push ecx ; save 24th bit in case negative pixel wanted
call checkpixel
test ecx,ecx
pop ecx
jnz .exit
.forced:
cmp [ScreenWidth], eax
jb .exit
cmp [ScreenHeight], ebx
jb .exit
.ok:
; check if negation
test ecx,0x01000000
jz .noneg
call getpixel
not ecx
mov [esp+32-8],ecx
.noneg:
; OK to set pixel
call dword [PUTPIXEL] ; call the real put_pixel function
.exit:
popad
 
ret
 
align 4
Vesa20_putpixel24:
; eax = x
; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3
mov eax, [esp+32-8+4]
add edi, [LFBAddress]
add edi, ebx ; ebx = where to put pixel in memory
mov [edi], ax
shr eax, 16
mov [edi+2], al
ret
 
; eax = x
; ebx = y
 
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3
mov eax, [esp+32-8+4]
add edi, [LFBAddress]
add edi, ebx ; ebx = where to put pixel in memory
mov [edi], ax
shr eax, 16
mov [edi+2], al
 
ret
 
 
align 4
Vesa20_putpixel32:
; eax = x
; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
mov eax, [esp+32-8+4] ; eax = color
add edi, [LFBAddress] ; ebx = where to put pixel in memory
mov [edi], eax
ret
 
; eax = x
; ebx = y
 
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
mov eax, [esp+32-8+4] ; eax = color
add edi, [LFBAddress] ; ebx = where to put pixel in memory
mov [edi], eax
 
ret
 
 
;*************************************************
 
;align 4
calculate_edi:
mov edi, ebx
imul edi, [ScreenWidth]
add edi, ebx
add edi, eax
ret
mov edi, ebx
imul edi, [ScreenWidth]
add edi, ebx
add edi, eax
ret
 
;*************************************************
 
393,7 → 356,7
align 4
__sys_draw_line:
; inc [mouse_pause]
call [disable_mouse]
call [disable_mouse]
 
; draw a line
; eax = HIWORD = x1
411,126 → 374,107
dl_dx equ esp+4
dl_dy equ esp+0
 
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
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
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
 
; 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
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
 
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)
mov edx, ebp ; edx = counter (number of pixels to draw)
mov ebp, 1 *65536 ; <<16 ; ebp = dy = 1.0
mov esi, eax ; esi = dx
jmp .y_rules
 
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)
mov edx, ebp ; edx = counter (number of pixels to draw)
mov ebp, 1 *65536 ; <<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
 
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)
mov edx, esi ; edx = counter (number of pixels to draw)
mov esi, 1 *65536 ;<< 16 ; esi = dx = 1.0
mov ebp, eax ; ebp = dy
 
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)
mov edx, esi ; edx = counter (number of pixels to draw)
mov esi, 1 *65536 ;<< 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
 
mov eax, [dl_x1]
mov ebx, [dl_y1]
shl eax, 16
shl ebx, 16
align 4
 
.draw:
push eax ebx
shr eax, 16
shr ebx, 16
call [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]
call [putpixel]
push eax ebx
shr eax, 16
shr ebx, 16
call [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]
call [putpixel]
.exit:
add esp, 6*4
popa
add esp, 6*4
popa
; dec [mouse_pause]
call [draw_pointer]
ret
ret
 
 
hline:
540,22 → 484,20
; ebx = y
; ecx = color
; edi = force ?
push eax edx
push eax edx
cmp edx, eax ; make sure x2 is above x1
jge @f
xchg eax, edx
align 4
@@:
call [putpixel]
inc eax
cmp eax, edx
jle @b
pop edx eax
ret
 
cmp edx, eax ; make sure x2 is above x1
jge @f
xchg eax, edx
align 4
@@:
call [putpixel]
inc eax
cmp eax, edx
jle @b
 
pop edx eax
ret
 
 
vline:
; draw a vertical line
; eax = x
563,39 → 505,37
; edx = y2
; ecx = color
; edi = force ?
push ebx edx
push ebx edx
cmp edx, ebx ; make sure y2 is above y1
jge @f
xchg ebx, edx
align 4
@@:
call [putpixel]
inc ebx
cmp ebx, edx
jle @b
pop edx ebx
ret
 
cmp edx, ebx ; make sure y2 is above y1
jge @f
xchg ebx, edx
align 4
@@:
call [putpixel]
inc ebx
cmp ebx, edx
jle @b
 
pop edx ebx
ret
 
 
;*************************************************
 
 
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 ?
.stack_data = 4*11
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 ?
.stack_data = 4*11
end virtual
 
align 4
605,114 → 545,98
; edx ye
; edi color
vesa20_drawbar:
 
pushad
call [disable_mouse]
 
sub esp, drbar.stack_data
 
mov [drbar.color], edi
 
sub edx, ebx
jle .exit ;// mike.dld, 2005-01-29
sub ecx, eax
jle .exit ;// mike.dld, 2005-01-29
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
pushad
call [disable_mouse]
sub esp, drbar.stack_data
mov [drbar.color], edi
sub edx, ebx
jle .exit ;// mike.dld, 2005-01-29
sub ecx, eax
jle .exit ;// mike.dld, 2005-01-29
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
; \begin{diamond}[20.08.2006]
; note that WDATA.box.width is one pixel less than real window x-size
inc ebx
inc ebx
; \end{diamond}[20.08.2006]
sub ebx, [drbar.bar_cx]
ja @f
.exit: ;// mike.dld, 2005-01-29
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
sub ebx, [drbar.bar_cx]
ja @f
.exit: ;// mike.dld, 2005-01-29
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
; \begin{diamond}[20.08.2006]
inc ebx
inc ebx
; \end{diamond}
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, [ScreenWidth]
sub eax, [drbar.real_sx]
inc eax
mov [drbar.line_inc_map], eax
 
; line_inc_scr
mov eax, [drbar.real_sx]
movzx ebx, byte [ScreenBPP]
shr ebx, 3
imul eax, ebx
neg eax
add eax, [BytesPerScanLine]
mov [drbar.line_inc_scr], eax
 
; pointer to screen
mov edx, [drbar.abs_cy]
imul edx, [BytesPerScanLine]
mov eax, [drbar.abs_cx]
; movzx ebx, byte [ScreenBPP]
; shr ebx, 3
imul eax, ebx
add edx, eax
add edx, [LFBAddress]
 
; pointer to pixel map
mov eax, [drbar.abs_cy]
imul eax, [ScreenWidth]
add eax, [drbar.abs_cy]
add eax, [drbar.abs_cx]
add eax, WinMapAddress
xchg eax, ebp
 
; get process number
mov ebx, [CURRENT_TASK]
 
cmp byte [ScreenBPP], 24
jne draw_bar_end_32
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, [ScreenWidth]
sub eax, [drbar.real_sx]
inc eax
mov [drbar.line_inc_map], eax
; line_inc_scr
mov eax, [drbar.real_sx]
movzx ebx, byte [ScreenBPP]
shr ebx, 3
imul eax, ebx
neg eax
add eax, [BytesPerScanLine]
mov [drbar.line_inc_scr], eax
; pointer to screen
mov edx, [drbar.abs_cy]
imul edx, [BytesPerScanLine]
mov eax, [drbar.abs_cx]
; movzx ebx, byte [ScreenBPP]
; shr ebx, 3
imul eax, ebx
add edx, eax
add edx, [LFBAddress]
; pointer to pixel map
mov eax, [drbar.abs_cy]
imul eax, [ScreenWidth]
add eax, [drbar.abs_cy]
add eax, [drbar.abs_cx]
add eax, WinMapAddress
xchg eax, ebp
; get process number
mov ebx, [CURRENT_TASK]
cmp byte [ScreenBPP], 24
jne draw_bar_end_32
draw_bar_end_24:
mov eax, [drbar.color] ;; BBGGRR00
mov bh, al ;; bh = BB
shr eax, 8 ;; eax = RRGG
mov eax, [drbar.color] ;; BBGGRR00
mov bh, al ;; bh = BB
shr eax, 8 ;; eax = RRGG
; eax - color high RRGG
; bl - process num
; bh - color low BB
720,94 → 644,77
; edx - pointer to screen
; esi - counter
; edi - counter
mov esi, [drbar.real_sy]
align 4
.new_y:
mov edi, [drbar.real_sx]
align 4
.new_x:
cmp byte [ebp], bl
jne .skip
mov [edx], bh
mov [edx + 1], ax
.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]
; <Ivan 15.10.04> drawing gradient bars
test eax, 0x00800000
jz @f
test bh, bh
jz @f
dec bh
@@:
; </Ivan 15.10.04>
dec esi
jnz .new_y
add esp, drbar.stack_data
popad
xor eax, eax
ret
 
mov esi, [drbar.real_sy]
align 4
.new_y:
mov edi, [drbar.real_sx]
align 4
.new_x:
 
cmp byte [ebp], bl
jne .skip
mov [edx], bh
mov [edx + 1], ax
.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]
 
; <Ivan 15.10.04> drawing gradient bars
test eax, 0x00800000
jz @f
test bh, bh
jz @f
dec bh
@@:
; </Ivan 15.10.04>
 
dec esi
jnz .new_y
 
add esp, drbar.stack_data
popad
xor eax, eax
ret
 
draw_bar_end_32:
mov eax, [drbar.color] ;; BBGGRR00
mov eax, [drbar.color] ;; BBGGRR00
mov esi, [drbar.real_sy]
align 4
.new_y:
mov edi, [drbar.real_sx]
align 4
.new_x:
cmp byte [ebp], bl
jne .skip
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]
; <Ivan 15.10.04> drawing gradient bars
test eax, 0x80000000
jz @f
test al, al
jz @f
dec al
@@:
; </Ivan 15.10.04>
dec esi
jnz .new_y
add esp, drbar.stack_data
popad
call VGA_draw_bar
xor eax, eax
mov [EGA_counter],1
ret
 
mov esi, [drbar.real_sy]
align 4
.new_y:
mov edi, [drbar.real_sx]
align 4
.new_x:
 
cmp byte [ebp], bl
jne .skip
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]
 
; <Ivan 15.10.04> drawing gradient bars
test eax, 0x80000000
jz @f
test al, al
jz @f
dec al
@@:
; </Ivan 15.10.04>
 
dec esi
jnz .new_y
 
add esp, drbar.stack_data
popad
call VGA_draw_bar
xor eax, eax
mov [EGA_counter],1
ret
 
 
;voodoodbcplimit:
 
; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
868,23 → 775,18
 
;--------------vbe voodoo ------------------------------------------------
vesa20_drawbackground_tiled:
 
call [disable_mouse]
 
push ebp
push eax
push ebx
push ecx
push edx
 
mov edx,dword [WinMapAddress-8] ; B
add edx,dword [WinMapAddress-8] ; +B
add edx,dword [WinMapAddress-8] ; +B
push edx
 
mov ebp,[draw_data+32+RECT.left] ; x start:=(x+Xwin)
mov ebx,[draw_data+32+RECT.top] ; y start:=(y+Ywin)
 
mov eax,[BytesPerScanLine]
mul ebx
xchg ebp, eax ; BytesPerScanLine*(Ywin+y)
891,52 → 793,36
add ebp, eax ; +X
add ebp, eax ; +X
add ebp, eax ; +X
 
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz @f
add ebp,eax ; +X
@@:
@@:
add ebp,[LFBAddress] ; +LFB
 
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
 
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
call calculate_edi
 
 
dp3: ; MAIN LOOP
 
dp3: ; MAIN LOOP
cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
; je ybgp
;
; jmp nbgp
;
; ybgp:
jne nbgp
 
push eax
push ebx
 
mov ecx,dword [WinMapAddress-8] ; B
xor edx,edx ; edx:=0
div ecx ; Xstart/B
 
; eax=Int(qn) edx:=Rem
 
; eax=Int(qn) edx:=Rem
lea esi,[edx+edx*2] ; esi:=edx*3
 
mov ecx,dword [WinMapAddress-4] ; ecx:=H
mov eax,[esp+0] ; eax:=Ystart
xor edx,edx ;
div ecx ; Ystart/H
 
mov eax,edx ; eax:=Rem
xor edx,edx ;
mov ebx,[esp+8] ; ebx:=B*3
mul ebx ;
add esi,eax ;
mov eax,[esi+IMG_BACKGROUND]
; mov eax,[esi+IMG_BACKGROUND]
mov eax,[img_background]
mov eax,[esi+eax]
and eax,0xffffff
 
xchg edi, ebp
stosw
shr eax,16
945,36 → 831,24
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz @f
inc ebp ; +1
@@:
 
@@:
pop ebx
pop eax
 
jmp hook1
 
nbgp:
nbgp:
add ebp,3 ; +3
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz @f
inc ebp ; +1
@@:
 
hook1:
 
@@:
hook1:
inc edi ; ptrBuffer++
add esi,3 ; ptrImage+=3
inc eax
cmp eax,[draw_data+32+RECT.right] ; X > xend?
; jg nodp3
; jmp dp3
;
; nodp3:
jle dp3
 
mov ebp,[draw_data+32+RECT.left]
 
inc ebx
 
mov eax,[BytesPerScanLine]
mul ebx
xchg ebp, eax ; BytesPerScanLine*(Ywin+y)
984,23 → 858,13
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz @f
add ebp,eax ; +X=X*4
@@:
@@:
add ebp,[LFBAddress] ; +LFB
 
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
 
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
call calculate_edi
 
cmp ebx,[draw_data+32+RECT.bottom]
; jg dp4
;
; jmp dp3
;
; dp4:
jle dp3
 
add esp,4
 
pop edx
pop ecx
pop ebx
1014,23 → 878,19
 
 
vesa20_drawbackground_stretch:
 
call [disable_mouse]
 
push ebp
push eax
push ebx
push ecx
push edx
 
mov edx,dword [WinMapAddress-8] ; B
add edx,dword [WinMapAddress-8] ; +B
add edx,dword [WinMapAddress-8] ; +B
push edx
 
mov ebp,[draw_data+32+RECT.left] ; x start:=(x+Xwin)
mov ebx,[draw_data+32+RECT.top] ; y start:=(y+Ywin)
 
dec ebx
mov eax,[BytesPerScanLine]
mul ebx
xchg ebp, eax ; BytesPerScanLine*(Ywin+y)
1037,137 → 897,168
add ebp, eax ; +X
add ebp, eax ; +X
add ebp, eax ; +X
 
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz @f
add ebp,eax ; +X
@@:
@@:
add ebp,[LFBAddress] ; +LFB
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
call calculate_edi
 
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
sdp3: ; MAIN LOOP
cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
jne snbgp
push eax
push ebx
mov eax,dword [WinMapAddress-8]
imul eax, [esp+4] ;4
xor edx,edx
mov ebx,[ScreenWidth]
div ebx
mov cx,dx
lea esi,[eax+eax*2]
mov eax,dword [WinMapAddress-4]
imul eax, [esp+0] ;0
xor edx,edx
mov ebx,[ScreenHeight]
div ebx
shl ecx,16
mov cx,dx
imul eax, [esp+8] ;8
add esi,eax
; mov eax,[esi+IMG_BACKGROUND]
mov eax,[img_background]
 
call calculate_edi
push eax
mov eax,[display_data-4]
imul eax,[display_data-8]
imul eax,3
sub eax,3
cmp eax,esi
pop eax
jbe @f
 
mov eax,[esi+eax]
@@:
push eax
ror ecx,16
xor eax,eax
mov ax,cx
shl eax,1 ; óìíîæåíèå íà 2
lea eax,[eax+eax*4] ; óìíîæåíèå íà 5
xor edx,edx
mov ebx,[ScreenWidth]
div ebx
cmp eax,5
pop eax
jb @f
; mov ebx,[esi+IMG_BACKGROUND+3]
mov ebx,[img_background]
 
sdp3: ; MAIN LOOP
cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
jne snbgp
push eax
push ebx
mov eax,dword [WinMapAddress-8]
imul eax, [esp+4] ;4
xor edx,edx
mov ebx,[ScreenWidth]
div ebx
mov cx,dx
lea esi,[eax+eax*2]
mov eax,dword [WinMapAddress-4]
imul eax, [esp+0] ;0
xor edx,edx
mov ebx,[ScreenHeight]
div ebx
shl ecx,16
mov cx,dx
imul eax, [esp+8] ;8
add esi,eax
mov eax,[esi+IMG_BACKGROUND]
push eax
ror ecx,16
xor eax,eax
mov ax,cx
shl eax,1 ; óìíîæåíèå íà 2
lea eax,[eax+eax*4] ; óìíîæåíèå íà 5
xor edx,edx
mov ebx,[ScreenWidth]
div ebx
cmp eax,5
pop eax
jb @f
mov ebx,[esi+IMG_BACKGROUND+3]
call overlapping_of_points
push eax
mov eax,[display_data-4]
imul eax,[display_data-8]
imul eax,3
sub eax,3
cmp eax,esi
pop eax
jbe @f
 
mov ebx,[esi+ebx+3]
 
call overlapping_of_points
@@:
push eax
ror ecx,16
xor eax,eax
mov ax,cx
shl eax,1 ; óìíîæåíèå íà 2
lea eax,[eax+eax*4] ; óìíîæåíèå íà
xor edx,edx
mov ebx,[ScreenHeight]
div ebx
cmp eax,5
pop eax
jb @f
mov ebx,[display_data-8]
shl ebx,1
add ebx,[display_data-8]
add ebx,IMG_BACKGROUND
add ebx,esi
mov ebx,[ebx]
call overlapping_of_points
push eax
ror ecx,16
xor eax,eax
mov ax,cx
shl eax,1 ; óìíîæåíèå íà 2
lea eax,[eax+eax*4] ; óìíîæåíèå íà
xor edx,edx
mov ebx,[ScreenHeight]
div ebx
cmp eax,5
pop eax
jb @f
mov ebx,[display_data-8]
shl ebx,1
add ebx,[display_data-8]
add ebx,[img_background] ;IMG_BACKGROUND
 
push eax
mov eax,[display_data-4]
imul eax,[display_data-8]
imul eax,3
cmp eax,esi
pop eax
jbe @f
 
add ebx,esi
mov ebx,[ebx]
call overlapping_of_points
@@:
and eax,0xffffff
xchg edi, ebp
stosw
shr eax,16
stosb
xchg ebp, edi ; ebp+=3
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz @f
inc ebp ; +1
and eax,0xffffff
xchg edi, ebp
stosw
shr eax,16
stosb
xchg ebp, edi ; ebp+=3
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz @f
inc ebp ; +1
@@:
pop ebx
pop eax
jmp shook1
pop ebx
pop eax
jmp shook1
 
overlapping_of_points:
push ecx edi
mov ecx,eax
mov edx,ebx
xor eax,eax
mov al,cl
xor ebx,ebx
mov bl,dl
add eax,ebx
rcr eax,1
xor edi,edi
mov di,ax
xor eax,eax
mov al,ch
xor ebx,ebx
mov bl,dh
add eax,ebx
rcr eax,1
ror edi,8
add edi,eax
ror ecx,8
ror edx,8
xor eax,eax
mov al,ch
xor ebx,ebx
mov bl,dh
add eax,ebx
rcr eax,1
ror edi,8
add eax,edi
ror eax,16
pop edi ecx
ret
push ecx edi
mov ecx,eax
mov edx,ebx
xor eax,eax
mov al,cl
xor ebx,ebx
mov bl,dl
add eax,ebx
rcr eax,1
xor edi,edi
mov di,ax
xor eax,eax
mov al,ch
xor ebx,ebx
mov bl,dh
add eax,ebx
rcr eax,1
ror edi,8
add edi,eax
ror ecx,8
ror edx,8
xor eax,eax
mov al,ch
xor ebx,ebx
mov bl,dh
add eax,ebx
rcr eax,1
ror edi,8
add eax,edi
ror eax,16
pop edi ecx
ret
 
snbgp:
snbgp:
add ebp,3 ; +3
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz @f
inc ebp ; +1
@@:
@@:
 
shook1:
 
shook1:
inc edi ; ptrBuffer++
add esi,3 ; ptrImage+=3
inc eax
cmp eax,[draw_data+32+RECT.right] ; X > xend?
jle sdp3
; jbe sdp3
 
mov ebp,[draw_data+32+RECT.left]
 
1182,7 → 1073,7
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
jz @f
add ebp,eax ; +X=X*4
@@:
@@:
add ebp,[LFBAddress] ; +LFB
 
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1189,9 → 1080,13
 
call calculate_edi
 
; cmp ebx,[ScreenHeight]
; ja @f
 
cmp ebx,[draw_data+32+RECT.bottom]
jle sdp3
 
; jbe sdp3
@@:
add esp,4
 
pop edx