From 542cb02ceaeaf0f11aeee96a9cf55488c4be3683 Mon Sep 17 00:00:00 2001 From: "Artem Jerdev (art_zh)" Date: Wed, 9 Feb 2011 14:48:45 +0000 Subject: [PATCH] new "tiled" graph engine (* buggy version *) git-svn-id: svn://kolibrios.org@1859 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../branches/Kolibri-A/trunk/core/syscall.inc | 34 +- kernel/branches/Kolibri-A/trunk/data32.inc | 25 +- kernel/branches/Kolibri-A/trunk/gui/mouse.inc | 855 +++--- .../branches/Kolibri-A/trunk/gui/window.inc | 2569 +++++++++-------- .../branches/Kolibri-A/trunk/hid/mousedrv.inc | 42 +- kernel/branches/Kolibri-A/trunk/kernel.asm | 559 +--- kernel/branches/Kolibri-A/trunk/kernel32.inc | 6 +- .../Kolibri-A/trunk/video/graph32.inc | 1237 ++++++++ .../branches/Kolibri-A/trunk/video/vesa20.inc | 1064 ------- 9 files changed, 3152 insertions(+), 3239 deletions(-) create mode 100644 kernel/branches/Kolibri-A/trunk/video/graph32.inc delete mode 100644 kernel/branches/Kolibri-A/trunk/video/vesa20.inc diff --git a/kernel/branches/Kolibri-A/trunk/core/syscall.inc b/kernel/branches/Kolibri-A/trunk/core/syscall.inc index d66a8af929..cba0ba1d77 100644 --- a/kernel/branches/Kolibri-A/trunk/core/syscall.inc +++ b/kernel/branches/Kolibri-A/trunk/core/syscall.inc @@ -17,7 +17,7 @@ cross_order: mov edx, esi mov esi, edi movzx edi, byte[esp+28 + 4] - sub edi, 53 ; all zeroes before + sub edi, 53 ; all zeroes before call dword [servetable+edi*4] ret @@ -44,10 +44,28 @@ i40: align 32 syscall_entry: + push ecx ; sti - push ecx - and eax, 3 - call dword [servetable3 + eax * 4] +; and eax, 3 +; call dword [servetable3 + eax * 4] + + mov edi, [esp+4] + mov ecx, [esp+8] + mov edx, [esp+12] + mov ebx, [esp+16] + and al, 1 + jz .hline + mov eax, [esp+20] + sti + call vline + jmp .done +.hline: + mov eax, [esp+20] + sti + call hline +.done: + + pop ecx sysret @@ -67,7 +85,7 @@ iglobal dd 0 dd 0 dd 0 - dd 0 ; 62-PCI functions + dd 0 ; 62-PCI functions dd sys_msg_board ; 63-System message board ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -100,7 +118,7 @@ iglobal dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,. dd sys_settime ; 22-setting date,time,clock and alarm-clock dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent - dd undefined_syscall ; syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist + dd undefined_syscall ; syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist dd undefined_syscall ; 25-reserved dd sys_getsetup ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,. dd undefined_syscall ; 27-reserved @@ -155,8 +173,8 @@ iglobal align 4 servetable3: ; Kolibri-A special service - dd paleholder ; 0 - dd paleholder ; 1 + dd hline ; 0 + dd vline ; 1 dd paleholder ; 2 dd sys_end ; last diff --git a/kernel/branches/Kolibri-A/trunk/data32.inc b/kernel/branches/Kolibri-A/trunk/data32.inc index 3da4721830..52cc4e97bf 100644 --- a/kernel/branches/Kolibri-A/trunk/data32.inc +++ b/kernel/branches/Kolibri-A/trunk/data32.inc @@ -315,13 +315,32 @@ srv.fd rd 1 srv.bk rd 1 -align 16 - -_display display_t +align 64 +img_draw_core_fn rd 1 ; putimage variables & helpers +img_draw_edge_fn rd 1 +img_lfb_origin rd 1 +img_buf_origin rd 1 +img_buf_line_size rd 1 +img_palette rd 1 +img_bitoffset rd 1 +img_edgeoffset rd 1 +img_bytes_per_pix rd 1 +img_map_right rd 1 +img_map_x rd 1 +img_pix_x rd 1 ; real Xsize +img_pix_y rd 1 ; real Ysize +img_screen_x rd 1 +img_screen_y rd 1 +align 64 +_WinMapWidth rd 1 +_WinMapHeight rd 1 _WinMapAddress rd 1 _WinMapSize rd 1 +align 16 +_display display_t + def_cursor rd 1 current_cursor rd 1 hw_cursor rd 1 diff --git a/kernel/branches/Kolibri-A/trunk/gui/mouse.inc b/kernel/branches/Kolibri-A/trunk/gui/mouse.inc index c9aca5f503..8144a795a0 100644 --- a/kernel/branches/Kolibri-A/trunk/gui/mouse.inc +++ b/kernel/branches/Kolibri-A/trunk/gui/mouse.inc @@ -13,7 +13,7 @@ include 'mousepointer.inc' ;///// public functions /////////////////////////////////////////////////////// ;============================================================================== -mouse.LEFT_BUTTON_FLAG = 0001b +mouse.LEFT_BUTTON_FLAG = 0001b mouse.RIGHT_BUTTON_FLAG = 0010b mouse.MIDDLE_BUTTON_FLAG = 0100b @@ -26,7 +26,7 @@ mouse.WINDOW_RESIZE_N_FLAG = 000001b mouse.WINDOW_RESIZE_W_FLAG = 000010b mouse.WINDOW_RESIZE_S_FLAG = 000100b mouse.WINDOW_RESIZE_E_FLAG = 001000b -mouse.WINDOW_MOVE_FLAG = 010000b +mouse.WINDOW_MOVE_FLAG = 010000b mouse.WINDOW_RESIZE_SW_FLAG = \ mouse.WINDOW_RESIZE_S_FLAG or \ @@ -42,126 +42,126 @@ mouse_check_events: ;////////////////////////////////////////////////////////// ;? Check if mouse buttons state or cursor position has changed and call ;? appropriate handlers ;------------------------------------------------------------------------------ - push eax ebx + push eax ebx - mov al, [BTN_DOWN] - mov bl, [mouse.state.buttons] - and al, mouse.BUTTONS_MASK - mov cl, al - xchg cl, [mouse.state.buttons] - xor bl, al - push eax ebx + mov al, [BTN_DOWN] + mov bl, [mouse.state.buttons] + and al, mouse.BUTTONS_MASK + mov cl, al + xchg cl, [mouse.state.buttons] + xor bl, al + push eax ebx - ; did any mouse button changed its state? - or bl, bl - jz .check_position + ; did any mouse button changed its state? + or bl, bl + jz .check_position - ; yes it did, is that the first button of all pressed down? - or cl, cl - jnz .check_buttons_released + ; yes it did, is that the first button of all pressed down? + or cl, cl + jnz .check_buttons_released - ; yes it is, activate window user is pointing at, if needed - call mouse._.activate_sys_window_under_cursor + ; yes it is, activate window user is pointing at, if needed + call mouse._.activate_sys_window_under_cursor - ; NOTE: this code wouldn't be necessary if we knew window did - ; already redraw itself after call above - or eax, eax - jz @f + ; NOTE: this code wouldn't be necessary if we knew window did + ; already redraw itself after call above + or eax, eax + jz @f - and [mouse.state.buttons], 0 - jmp .exit + and [mouse.state.buttons], 0 + jmp .exit - ; is there any system button under cursor? - @@: call mouse._.find_sys_button_under_cursor - or eax, eax - jz .check_buttons_released + ; is there any system button under cursor? + @@: call mouse._.find_sys_button_under_cursor + or eax, eax + jz .check_buttons_released - ; yes there is, activate it and exit - mov [mouse.active_sys_button.pbid], eax - mov [mouse.active_sys_button.coord], ebx - mov cl, [mouse.state.buttons] - mov [mouse.active_sys_button.buttons], cl - call sys_button_activate_handler - jmp .exit + ; yes there is, activate it and exit + mov [mouse.active_sys_button.pbid], eax + mov [mouse.active_sys_button.coord], ebx + mov cl, [mouse.state.buttons] + mov [mouse.active_sys_button.buttons], cl + call sys_button_activate_handler + jmp .exit .check_buttons_released: - cmp [mouse.state.buttons], 0 - jnz .buttons_changed + cmp [mouse.state.buttons], 0 + jnz .buttons_changed - ; did we press some button earlier? - cmp [mouse.active_sys_button.pbid], 0 - je .buttons_changed + ; did we press some button earlier? + cmp [mouse.active_sys_button.pbid], 0 + je .buttons_changed - ; yes we did, deactivate it - xor eax, eax - xchg eax, [mouse.active_sys_button.pbid] - mov ebx, [mouse.active_sys_button.coord] - mov cl, [mouse.active_sys_button.buttons] - push eax ebx - call sys_button_deactivate_handler - pop edx ecx + ; yes we did, deactivate it + xor eax, eax + xchg eax, [mouse.active_sys_button.pbid] + mov ebx, [mouse.active_sys_button.coord] + mov cl, [mouse.active_sys_button.buttons] + push eax ebx + call sys_button_deactivate_handler + pop edx ecx - ; is the button under cursor the one we deactivated? - call mouse._.find_sys_button_under_cursor - cmp eax, ecx - jne .exit - cmp ebx, edx - jne .exit + ; is the button under cursor the one we deactivated? + call mouse._.find_sys_button_under_cursor + cmp eax, ecx + jne .exit + cmp ebx, edx + jne .exit - ; yes it is, perform associated action - mov cl, [mouse.active_sys_button.buttons] - call sys_button_perform_handler - jmp .exit + ; yes it is, perform associated action + mov cl, [mouse.active_sys_button.buttons] + call sys_button_perform_handler + jmp .exit .buttons_changed: - test byte[esp], mouse.LEFT_BUTTON_FLAG - jz @f - mov eax, [esp + 4] - call .call_left_button_handler + test byte[esp], mouse.LEFT_BUTTON_FLAG + jz @f + mov eax, [esp + 4] + call .call_left_button_handler - @@: test byte[esp], mouse.RIGHT_BUTTON_FLAG - jz @f - mov eax, [esp + 4] - call .call_right_button_handler + @@: test byte[esp], mouse.RIGHT_BUTTON_FLAG + jz @f + mov eax, [esp + 4] + call .call_right_button_handler - @@: test byte[esp], mouse.MIDDLE_BUTTON_FLAG - jz .check_position - mov eax, [esp + 4] - call .call_middle_button_handler + @@: test byte[esp], mouse.MIDDLE_BUTTON_FLAG + jz .check_position + mov eax, [esp + 4] + call .call_middle_button_handler .check_position: - movzx eax, word[MOUSE_X] - movzx ebx, word[MOUSE_Y] - cmp eax, [mouse.state.pos.x] - jne .position_changed - cmp ebx, [mouse.state.pos.y] - je .exit + movzx eax, word[MOUSE_X] + movzx ebx, word[MOUSE_Y] + cmp eax, [mouse.state.pos.x] + jne .position_changed + cmp ebx, [mouse.state.pos.y] + je .exit .position_changed: - xchg eax, [mouse.state.pos.x] - xchg ebx, [mouse.state.pos.y] + xchg eax, [mouse.state.pos.x] + xchg ebx, [mouse.state.pos.y] - call mouse._.move_handler + call mouse._.move_handler .exit: - add esp, 8 - pop ebx eax - ret + add esp, 8 + pop ebx eax + ret .call_left_button_handler: - test eax, mouse.LEFT_BUTTON_FLAG - jnz mouse._.left_button_press_handler - jmp mouse._.left_button_release_handler + test eax, mouse.LEFT_BUTTON_FLAG + jnz mouse._.left_button_press_handler + jmp mouse._.left_button_release_handler .call_right_button_handler: - test eax, mouse.RIGHT_BUTTON_FLAG - jnz mouse._.right_button_press_handler - jmp mouse._.right_button_release_handler + test eax, mouse.RIGHT_BUTTON_FLAG + jnz mouse._.right_button_press_handler + jmp mouse._.right_button_release_handler .call_middle_button_handler: - test eax, mouse.MIDDLE_BUTTON_FLAG - jnz mouse._.middle_button_press_handler - jmp mouse._.middle_button_release_handler + test eax, mouse.MIDDLE_BUTTON_FLAG + jnz mouse._.middle_button_press_handler + jmp mouse._.middle_button_release_handler ;============================================================================== ;///// private functions ////////////////////////////////////////////////////// @@ -184,12 +184,12 @@ uglobal align 4 mouse.active_sys_window: - .pslot dd ? - .old_box BOX - .new_box BOX - .delta POINT + .pslot dd ? + .old_box BOX + .new_box BOX + .delta POINT .last_ticks dd ? - .action db ? + .action db ? endg align 4 @@ -198,90 +198,90 @@ mouse._.left_button_press_handler: ;/////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? Called when left mouse button has been pressed down ;------------------------------------------------------------------------------ - test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG - jnz .exit + test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG + jnz .exit - call mouse._.find_sys_window_under_cursor - call mouse._.check_sys_window_actions - mov [mouse.active_sys_window.action], al - or eax, eax - jz .exit + call mouse._.find_sys_window_under_cursor + call mouse._.check_sys_window_actions + mov [mouse.active_sys_window.action], al + or eax, eax + jz .exit - xchg eax, edx - test dl, mouse.WINDOW_MOVE_FLAG - jz @f + xchg eax, edx + test dl, mouse.WINDOW_MOVE_FLAG + jz @f - mov eax, [timer_ticks] - mov ebx, eax - xchg ebx, [mouse.active_sys_window.last_ticks] - sub eax, ebx - cmp eax, 50 - jg @f + mov eax, [timer_ticks] + mov ebx, eax + xchg ebx, [mouse.active_sys_window.last_ticks] + sub eax, ebx + cmp eax, 50 + jg @f - mov [mouse.active_sys_window.last_ticks], 0 - call sys_window_maximize_handler - jmp .exit + mov [mouse.active_sys_window.last_ticks], 0 + call sys_window_maximize_handler + jmp .exit - @@: test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED - jnz .exit - mov [mouse.active_sys_window.pslot], esi - lea eax, [edi + WDATA.box] - mov ebx, mouse.active_sys_window.old_box - mov ecx, BOX.sizeof - call memmove - mov ebx, mouse.active_sys_window.new_box - call memmove - test edx, mouse.WINDOW_MOVE_FLAG - jz @f + @@: test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED + jnz .exit + mov [mouse.active_sys_window.pslot], esi + lea eax, [edi + WDATA.box] + mov ebx, mouse.active_sys_window.old_box + mov ecx, BOX.sizeof + call memmove + mov ebx, mouse.active_sys_window.new_box + call memmove + test edx, mouse.WINDOW_MOVE_FLAG + jz @f - call .calculate_n_delta - call .calculate_w_delta - jmp .call_window_handler + call .calculate_n_delta + call .calculate_w_delta + jmp .call_window_handler - @@: test dl, mouse.WINDOW_RESIZE_W_FLAG - jz @f - call .calculate_w_delta + @@: test dl, mouse.WINDOW_RESIZE_W_FLAG + jz @f + call .calculate_w_delta - @@: test dl, mouse.WINDOW_RESIZE_S_FLAG - jz @f - call .calculate_s_delta + @@: test dl, mouse.WINDOW_RESIZE_S_FLAG + jz @f + call .calculate_s_delta - @@: test dl, mouse.WINDOW_RESIZE_E_FLAG - jz .call_window_handler - call .calculate_e_delta + @@: test dl, mouse.WINDOW_RESIZE_E_FLAG + jz .call_window_handler + call .calculate_e_delta .call_window_handler: - mov eax, mouse.active_sys_window.old_box - call sys_window_start_moving_handler + mov eax, mouse.active_sys_window.old_box + call sys_window_start_moving_handler .exit: - ret + ret .calculate_n_delta: - mov eax, [mouse.state.pos.y] - sub eax, [mouse.active_sys_window.old_box.top] - mov [mouse.active_sys_window.delta.y], eax - ret + mov eax, [mouse.state.pos.y] + sub eax, [mouse.active_sys_window.old_box.top] + mov [mouse.active_sys_window.delta.y], eax + ret .calculate_w_delta: - mov eax, [mouse.state.pos.x] - sub eax, [mouse.active_sys_window.old_box.left] - mov [mouse.active_sys_window.delta.x], eax - ret + mov eax, [mouse.state.pos.x] + sub eax, [mouse.active_sys_window.old_box.left] + mov [mouse.active_sys_window.delta.x], eax + ret .calculate_s_delta: - mov eax, [mouse.active_sys_window.old_box.top] - add eax, [mouse.active_sys_window.old_box.height] - sub eax, [mouse.state.pos.y] - mov [mouse.active_sys_window.delta.y], eax - ret + mov eax, [mouse.active_sys_window.old_box.top] + add eax, [mouse.active_sys_window.old_box.height] + sub eax, [mouse.state.pos.y] + mov [mouse.active_sys_window.delta.y], eax + ret .calculate_e_delta: - mov eax, [mouse.active_sys_window.old_box.left] - add eax, [mouse.active_sys_window.old_box.width] - sub eax, [mouse.state.pos.x] - mov [mouse.active_sys_window.delta.x], eax - ret + mov eax, [mouse.active_sys_window.old_box.left] + add eax, [mouse.active_sys_window.old_box.width] + sub eax, [mouse.state.pos.x] + mov [mouse.active_sys_window.delta.x], eax + ret align 4 ;------------------------------------------------------------------------------ @@ -289,24 +289,24 @@ mouse._.left_button_release_handler: ;///////////////////////////////////////// ;------------------------------------------------------------------------------ ;? Called when left mouse button has been released ;------------------------------------------------------------------------------ - xor esi, esi - xchg esi, [mouse.active_sys_window.pslot] - or esi, esi - jz .exit + xor esi, esi + xchg esi, [mouse.active_sys_window.pslot] + or esi, esi + jz .exit - mov eax, esi - shl eax, 5 - add eax, window_data + WDATA.box - mov ebx, mouse.active_sys_window.old_box - mov ecx, BOX.sizeof - call memmove + mov eax, esi + shl eax, 5 + add eax, window_data + WDATA.box + mov ebx, mouse.active_sys_window.old_box + mov ecx, BOX.sizeof + call memmove - mov eax, mouse.active_sys_window.old_box - mov ebx, mouse.active_sys_window.new_box - call sys_window_end_moving_handler + mov eax, mouse.active_sys_window.old_box + mov ebx, mouse.active_sys_window.new_box + call sys_window_end_moving_handler .exit: - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -314,18 +314,18 @@ mouse._.right_button_press_handler: ;////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? Called when right mouse button has been pressed down ;------------------------------------------------------------------------------ - test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG - jnz .exit + test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG + jnz .exit - call mouse._.find_sys_window_under_cursor - call mouse._.check_sys_window_actions - test al, mouse.WINDOW_MOVE_FLAG - jz .exit + call mouse._.find_sys_window_under_cursor + call mouse._.check_sys_window_actions + test al, mouse.WINDOW_MOVE_FLAG + jz .exit - call sys_window_rollup_handler + call sys_window_rollup_handler .exit: - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -333,7 +333,7 @@ mouse._.right_button_release_handler: ;//////////////////////////////////////// ;------------------------------------------------------------------------------ ;? Called when right mouse button has been released ;------------------------------------------------------------------------------ - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -341,7 +341,7 @@ mouse._.middle_button_press_handler: ;///////////////////////////////////////// ;------------------------------------------------------------------------------ ;? Called when middle mouse button has been pressed down ;------------------------------------------------------------------------------ - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -349,7 +349,7 @@ mouse._.middle_button_release_handler: ;/////////////////////////////////////// ;------------------------------------------------------------------------------ ;? Called when middle mouse button has been released ;------------------------------------------------------------------------------ - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -360,148 +360,153 @@ mouse._.move_handler: ;//////////////////////////////////////////////////////// ;> eax = old x coord ;> ebx = old y coord ;------------------------------------------------------------------------------ - cmp [mouse.active_sys_button.pbid], 0 - jnz .exit + cmp [mouse.active_sys_button.pbid], 0 + jnz .exit - mov esi, [mouse.active_sys_window.pslot] - or esi, esi - jz .exit + mov esi, [mouse.active_sys_window.pslot] + or esi, esi + jz .exit - mov eax, mouse.active_sys_window.new_box - mov ebx, mouse.active_sys_window.old_box - mov ecx, BOX.sizeof - call memmove + mov eax, mouse.active_sys_window.new_box + mov ebx, mouse.active_sys_window.old_box + mov ecx, BOX.sizeof + call memmove - mov dl, [mouse.active_sys_window.action] - test dl, mouse.WINDOW_MOVE_FLAG - jz .check_resize_w + mov dl, [mouse.active_sys_window.action] + test dl, mouse.WINDOW_MOVE_FLAG + jz .check_resize_w - mov eax, [mouse.state.pos.x] - sub eax, [mouse.active_sys_window.delta.x] - mov [mouse.active_sys_window.new_box.left], eax - mov eax, [mouse.state.pos.y] - sub eax, [mouse.active_sys_window.delta.y] - mov [mouse.active_sys_window.new_box.top], eax + mov eax, [mouse.state.pos.x] + sub eax, [mouse.active_sys_window.delta.x] + and al, 0xFC ; <<<<<<<<<<<<<<<<<<< + mov [mouse.active_sys_window.new_box.left], eax + mov eax, [mouse.state.pos.y] + sub eax, [mouse.active_sys_window.delta.y] + and al, 0xFE ; <<<<<<<<<<<<<<<<<<< + mov [mouse.active_sys_window.new_box.top], eax - mov eax, [mouse.active_sys_window.new_box.left] - or eax, eax - jge @f - xor eax, eax - mov [mouse.active_sys_window.new_box.left], eax - @@: add eax, [mouse.active_sys_window.new_box.width] - cmp eax, [Screen_Max_X] - jl @f - sub eax, [Screen_Max_X] - sub [mouse.active_sys_window.new_box.left], eax - @@: mov eax, [mouse.active_sys_window.new_box.top] - or eax, eax - jge @f - xor eax, eax - mov [mouse.active_sys_window.new_box.top], eax - @@: add eax, [mouse.active_sys_window.new_box.height] - cmp eax, [Screen_Max_Y] - jle .call_window_handler - sub eax, [Screen_Max_Y] - sub [mouse.active_sys_window.new_box.top], eax - jmp .call_window_handler + mov eax, [mouse.active_sys_window.new_box.left] + or eax, eax + jge @f + xor eax, eax + mov [mouse.active_sys_window.new_box.left], eax + @@: add eax, [mouse.active_sys_window.new_box.width] + cmp eax, [Screen_Max_X] + jl @f + sub eax, [Screen_Max_X] + sub [mouse.active_sys_window.new_box.left], eax + @@: mov eax, [mouse.active_sys_window.new_box.top] + or eax, eax + jge @f + xor eax, eax + mov [mouse.active_sys_window.new_box.top], eax + @@: add eax, [mouse.active_sys_window.new_box.height] + cmp eax, [Screen_Max_Y] + jle .call_window_handler + sub eax, [Screen_Max_Y] + sub [mouse.active_sys_window.new_box.top], eax + jmp .call_window_handler .check_resize_w: - test dl, mouse.WINDOW_RESIZE_W_FLAG - jz .check_resize_s + test dl, mouse.WINDOW_RESIZE_W_FLAG + jz .check_resize_s - mov eax, [mouse.state.pos.x] - sub eax, [mouse.active_sys_window.delta.x] - mov [mouse.active_sys_window.new_box.left], eax - sub eax, [mouse.active_sys_window.old_box.left] - sub [mouse.active_sys_window.new_box.width], eax + mov eax, [mouse.state.pos.x] + sub eax, [mouse.active_sys_window.delta.x] + and al, 0xFC ; <<<<<<<<<<<<<<<<<<< + mov [mouse.active_sys_window.new_box.left], eax + sub eax, [mouse.active_sys_window.old_box.left] + sub [mouse.active_sys_window.new_box.width], eax - mov eax, [mouse.active_sys_window.new_box.width] - sub eax, 127 - jge @f - add [mouse.active_sys_window.new_box.left], eax - mov [mouse.active_sys_window.new_box.width], 127 - @@: mov eax, [mouse.active_sys_window.new_box.left] - or eax, eax - jge .check_resize_s - add [mouse.active_sys_window.new_box.width], eax - xor eax, eax - mov [mouse.active_sys_window.new_box.left], eax + mov eax, [mouse.active_sys_window.new_box.width] + sub eax, 128 + jge @f + add [mouse.active_sys_window.new_box.left], eax + mov [mouse.active_sys_window.new_box.width], 128 + @@: mov eax, [mouse.active_sys_window.new_box.left] + or eax, eax + jge .check_resize_s + add [mouse.active_sys_window.new_box.width], eax + xor eax, eax + mov [mouse.active_sys_window.new_box.left], eax .check_resize_s: - test dl, mouse.WINDOW_RESIZE_S_FLAG - jz .check_resize_e + test dl, mouse.WINDOW_RESIZE_S_FLAG + jz .check_resize_e - mov eax, [mouse.state.pos.y] - add eax, [mouse.active_sys_window.delta.y] - sub eax, [mouse.active_sys_window.old_box.top] - mov [mouse.active_sys_window.new_box.height], eax + mov eax, [mouse.state.pos.y] + add eax, [mouse.active_sys_window.delta.y] + sub eax, [mouse.active_sys_window.old_box.top] + and al, 0xFC ; <<<<<<<<<<<<<<<<<<< + mov [mouse.active_sys_window.new_box.height], eax - push eax - mov edi, esi - shl edi, 5 - add edi, window_data - call window._.get_rolledup_height - mov ecx, eax - pop eax - mov eax, [mouse.active_sys_window.new_box.height] - cmp eax, ecx - jge @f - mov eax, ecx - mov [mouse.active_sys_window.new_box.height], eax - @@: add eax, [mouse.active_sys_window.new_box.top] - cmp eax, [Screen_Max_Y] - jle .check_resize_e - sub eax, [Screen_Max_Y] - neg eax - add [mouse.active_sys_window.new_box.height], eax - mov ecx, [Screen_Max_Y] - cmp ecx, eax - jge .check_resize_e - mov [mouse.active_sys_window.new_box.height], ecx + push eax + mov edi, esi + shl edi, 5 + add edi, window_data + call window._.get_rolledup_height + mov ecx, eax + pop eax + mov eax, [mouse.active_sys_window.new_box.height] + cmp eax, ecx + jge @f + mov eax, ecx + mov [mouse.active_sys_window.new_box.height], eax + @@: add eax, [mouse.active_sys_window.new_box.top] + cmp eax, [Screen_Max_Y] + jle .check_resize_e + sub eax, [Screen_Max_Y] + neg eax + add [mouse.active_sys_window.new_box.height], eax + mov ecx, [Screen_Max_Y] + cmp ecx, eax + jge .check_resize_e + mov [mouse.active_sys_window.new_box.height], ecx .check_resize_e: - test dl, mouse.WINDOW_RESIZE_E_FLAG - jz .call_window_handler + test dl, mouse.WINDOW_RESIZE_E_FLAG + jz .call_window_handler - mov eax, [mouse.state.pos.x] - add eax, [mouse.active_sys_window.delta.x] - sub eax, [mouse.active_sys_window.old_box.left] - mov [mouse.active_sys_window.new_box.width], eax + mov eax, [mouse.state.pos.x] + add eax, [mouse.active_sys_window.delta.x] + sub eax, [mouse.active_sys_window.old_box.left] + and al, 0xFC ; <<<<<<<<<<<<<<<<<<< + mov [mouse.active_sys_window.new_box.width], eax - mov eax, [mouse.active_sys_window.new_box.width] - cmp eax, 127 - jge @f - mov eax, 127 - mov [mouse.active_sys_window.new_box.width], eax - @@: add eax, [mouse.active_sys_window.new_box.left] - cmp eax, [Screen_Max_X] - jle .call_window_handler - sub eax, [Screen_Max_X] - neg eax - add [mouse.active_sys_window.new_box.width], eax - mov ecx, [Screen_Max_X] - cmp ecx, eax - jge .call_window_handler - mov [mouse.active_sys_window.new_box.width], ecx + mov eax, [mouse.active_sys_window.new_box.width] + cmp eax, 128 + jge @f + mov eax, 128 + mov [mouse.active_sys_window.new_box.width], eax + @@: add eax, [mouse.active_sys_window.new_box.left] + cmp eax, [Screen_Max_X] + jle .call_window_handler + sub eax, [Screen_Max_X] + neg eax + add [mouse.active_sys_window.new_box.width], eax + mov ecx, [Screen_Max_X] + cmp ecx, eax + jge .call_window_handler + mov [mouse.active_sys_window.new_box.width], ecx .call_window_handler: - mov eax, mouse.active_sys_window.old_box - mov ebx, mouse.active_sys_window.new_box + mov eax, mouse.active_sys_window.old_box + mov ebx, mouse.active_sys_window.new_box - push esi - mov esi, mouse.active_sys_window.old_box - mov edi, mouse.active_sys_window.new_box - mov ecx, BOX.sizeof / 4 - repe - cmpsd - pop esi - je .exit + push esi + mov esi, mouse.active_sys_window.old_box + mov edi, mouse.active_sys_window.new_box + mov ecx, BOX.sizeof / 4 + repe + cmpsd + pop esi + je .exit - mov [mouse.active_sys_window.last_ticks], 0 - call sys_window_moving_handler + mov [mouse.active_sys_window.last_ticks], 0 + call sys_window_moving_handler .exit: - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -513,16 +518,16 @@ mouse._.find_sys_window_under_cursor: ;//////////////////////////////////////// ;< esi = process slot ;< edi = pointer to WDATA struct ;------------------------------------------------------------------------------ - mov esi, [Screen_Max_X] - inc esi - imul esi, [mouse.state.pos.y] - add esi, [_WinMapAddress] - add esi, [mouse.state.pos.x] - movzx esi, byte[esi] - mov edi, esi - shl edi, 5 - add edi, window_data - ret + mov esi, [Screen_Max_X] + inc esi + imul esi, [mouse.state.pos.y] + add esi, [_WinMapAddress] + add esi, [mouse.state.pos.x] + movzx esi, byte[esi] + mov edi, esi + shl edi, 5 + add edi, window_data + ret align 4 ;------------------------------------------------------------------------------ @@ -530,11 +535,11 @@ mouse._.activate_sys_window_under_cursor: ;//////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - ; activate and redraw window under cursor (if necessary) - call mouse._.find_sys_window_under_cursor - movzx esi, word[WIN_STACK + esi * 2] - lea esi, [WIN_POS + esi * 2] - jmp waredraw + ; activate and redraw window under cursor (if necessary) + call mouse._.find_sys_window_under_cursor + movzx esi, word[WIN_STACK + esi * 2] + lea esi, [WIN_POS + esi * 2] + jmp waredraw align 4 ;------------------------------------------------------------------------------ @@ -546,60 +551,60 @@ mouse._.find_sys_button_under_cursor: ;//////////////////////////////////////// ;< eax = pack[8(process slot), 24(button id)] or 0 ;< ebx = pack[16(button x coord), 16(button y coord)] ;------------------------------------------------------------------------------ - push ecx edx esi edi + push ecx edx esi edi - call mouse._.find_sys_window_under_cursor - mov edx, esi + call mouse._.find_sys_window_under_cursor + mov edx, esi - ; check if any process button contains cursor - mov eax, [BTN_ADDR] - mov ecx, [eax] - imul esi, ecx, SYS_BUTTON.sizeof - add esi, eax - inc ecx - add esi, SYS_BUTTON.sizeof + ; check if any process button contains cursor + mov eax, [BTN_ADDR] + mov ecx, [eax] + imul esi, ecx, SYS_BUTTON.sizeof + add esi, eax + inc ecx + add esi, SYS_BUTTON.sizeof .next_button: - dec ecx - jz .not_found + dec ecx + jz .not_found - add esi, -SYS_BUTTON.sizeof + add esi, -SYS_BUTTON.sizeof - ; does it belong to our process? - cmp dx, [esi + SYS_BUTTON.pslot] - jne .next_button + ; does it belong to our process? + cmp dx, [esi + SYS_BUTTON.pslot] + jne .next_button - ; does it contain cursor coordinates? - mov eax, [mouse.state.pos.x] - sub eax, [edi + WDATA.box.left] - sub ax, [esi + SYS_BUTTON.left] - jl .next_button - sub ax, [esi + SYS_BUTTON.width] - jge .next_button - mov eax, [mouse.state.pos.y] - sub eax, [edi + WDATA.box.top] - sub ax, [esi + SYS_BUTTON.top] - jl .next_button - sub ax, [esi + SYS_BUTTON.height] - jge .next_button + ; does it contain cursor coordinates? + mov eax, [mouse.state.pos.x] + sub eax, [edi + WDATA.box.left] + sub ax, [esi + SYS_BUTTON.left] + jl .next_button + sub ax, [esi + SYS_BUTTON.width] + jge .next_button + mov eax, [mouse.state.pos.y] + sub eax, [edi + WDATA.box.top] + sub ax, [esi + SYS_BUTTON.top] + jl .next_button + sub ax, [esi + SYS_BUTTON.height] + jge .next_button - ; okay, return it - shl edx, 24 - mov eax, dword[esi + SYS_BUTTON.id_hi - 2] - mov ax, [esi + SYS_BUTTON.id_lo] - and eax, 0x0ffffff - or eax, edx - mov ebx, dword[esi + SYS_BUTTON.left - 2] - mov bx, [esi + SYS_BUTTON.top] - jmp .exit + ; okay, return it + shl edx, 24 + mov eax, dword[esi + SYS_BUTTON.id_hi - 2] + mov ax, [esi + SYS_BUTTON.id_lo] + and eax, 0x0ffffff + or eax, edx + mov ebx, dword[esi + SYS_BUTTON.left - 2] + mov bx, [esi + SYS_BUTTON.top] + jmp .exit .not_found: - xor eax, eax - xor ebx, ebx + xor eax, eax + xor ebx, ebx .exit: - pop edi esi edx ecx - ret + pop edi esi edx ecx + ret align 4 ;------------------------------------------------------------------------------ @@ -609,96 +614,96 @@ mouse._.check_sys_window_actions: ;//////////////////////////////////////////// ;------------------------------------------------------------------------------ ;< eax = action flags or 0 ;------------------------------------------------------------------------------ - ; is window movable? - test byte[edi + WDATA.cl_titlebar + 3], 0x01 - jnz .no_action + ; is window movable? + test byte[edi + WDATA.cl_titlebar + 3], 0x01 + jnz .no_action - mov eax, [mouse.state.pos.x] - mov ebx, [mouse.state.pos.y] - sub eax, [edi + WDATA.box.left] - sub ebx, [edi + WDATA.box.top] + mov eax, [mouse.state.pos.x] + mov ebx, [mouse.state.pos.y] + sub eax, [edi + WDATA.box.left] + sub ebx, [edi + WDATA.box.top] - ; is there a window titlebar under cursor? - push eax - call window._.get_titlebar_height - cmp ebx, eax - pop eax - jl .move_action + ; is there a window titlebar under cursor? + push eax + call window._.get_titlebar_height + cmp ebx, eax + pop eax + jl .move_action - ; no there isn't, can it be resized then? - mov dl, [edi + WDATA.fl_wstyle] - and dl, 0x0f - ; NOTE: dangerous optimization, revise if window types changed; - ; this currently implies only types 2 and 3 could be resized - test dl, 2 - jz .no_action + ; no there isn't, can it be resized then? + mov dl, [edi + WDATA.fl_wstyle] + and dl, 0x0f + ; NOTE: dangerous optimization, revise if window types changed; + ; this currently implies only types 2 and 3 could be resized + test dl, 2 + jz .no_action - mov ecx, [edi + WDATA.box.width] - add ecx, -window.BORDER_SIZE - mov edx, [edi + WDATA.box.height] - add edx, -window.BORDER_SIZE + mov ecx, [edi + WDATA.box.width] + add ecx, -window.BORDER_SIZE + mov edx, [edi + WDATA.box.height] + add edx, -window.BORDER_SIZE - ; is it rolled up? - test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP - jnz .resize_w_or_e_action + ; is it rolled up? + test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP + jnz .resize_w_or_e_action - cmp eax, window.BORDER_SIZE - jl .resize_w_action - cmp eax, ecx - jg .resize_e_action - cmp ebx, edx - jle .no_action + cmp eax, window.BORDER_SIZE + jl .resize_w_action + cmp eax, ecx + jg .resize_e_action + cmp ebx, edx + jle .no_action .resize_s_action: - cmp eax, window.BORDER_SIZE + 10 - jl .resize_sw_action - add ecx, -10 - cmp eax, ecx - jge .resize_se_action - mov eax, mouse.WINDOW_RESIZE_S_FLAG - jmp .exit + cmp eax, window.BORDER_SIZE + 10 + jl .resize_sw_action + add ecx, -10 + cmp eax, ecx + jge .resize_se_action + mov eax, mouse.WINDOW_RESIZE_S_FLAG + jmp .exit .resize_w_or_e_action: - cmp eax, window.BORDER_SIZE + 10 - jl .resize_w_action.direct - add ecx, -10 - cmp eax, ecx - jg .resize_e_action.direct - jmp .no_action + cmp eax, window.BORDER_SIZE + 10 + jl .resize_w_action.direct + add ecx, -10 + cmp eax, ecx + jg .resize_e_action.direct + jmp .no_action .resize_w_action: - add edx, -10 - cmp ebx, edx - jge .resize_sw_action + add edx, -10 + cmp ebx, edx + jge .resize_sw_action .resize_w_action.direct: - mov eax, mouse.WINDOW_RESIZE_W_FLAG - jmp .exit + mov eax, mouse.WINDOW_RESIZE_W_FLAG + jmp .exit .resize_e_action: - add edx, -10 - cmp ebx, edx - jge .resize_se_action + add edx, -10 + cmp ebx, edx + jge .resize_se_action .resize_e_action.direct: - mov eax, mouse.WINDOW_RESIZE_E_FLAG - jmp .exit + mov eax, mouse.WINDOW_RESIZE_E_FLAG + jmp .exit .resize_sw_action: - mov eax, mouse.WINDOW_RESIZE_SW_FLAG - jmp .exit + mov eax, mouse.WINDOW_RESIZE_SW_FLAG + jmp .exit .resize_se_action: - mov eax, mouse.WINDOW_RESIZE_SE_FLAG - jmp .exit + mov eax, mouse.WINDOW_RESIZE_SE_FLAG + jmp .exit .move_action: - mov eax, mouse.WINDOW_MOVE_FLAG - jmp .exit + mov eax, mouse.WINDOW_MOVE_FLAG + jmp .exit .no_action: - xor eax, eax + xor eax, eax .exit: - ret + ret diff16 "mouse code end ",0,$ -diff16 "mouse code size",mouse_check_events,$ +diff10 "mouse code size",mouse_check_events,$ diff --git a/kernel/branches/Kolibri-A/trunk/gui/window.inc b/kernel/branches/Kolibri-A/trunk/gui/window.inc index 3f99f8c4a4..6b2e33d707 100644 --- a/kernel/branches/Kolibri-A/trunk/gui/window.inc +++ b/kernel/branches/Kolibri-A/trunk/gui/window.inc @@ -27,7 +27,7 @@ macro FuncTable name, table_name, [label] uglobal common_colours rd 32 - draw_limits RECT + draw_limits RECT endg align 4 @@ -36,54 +36,54 @@ syscall_draw_window: ;///// system function 0 ///////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - mov eax, edx - shr eax, 24 - and al, 0x0f - cmp al, 5 - jae .exit + mov eax, edx + shr eax, 24 + and al, 0x0f + cmp al, 5 + jae .exit - push eax - inc [mouse_pause] - call [_display.disable_mouse] - call window._.sys_set_window - call [_display.disable_mouse] - pop eax + push eax + inc [mouse_pause] + call [_display.disable_mouse] + call window._.sys_set_window + call [_display.disable_mouse] + pop eax - or al, al - jnz @f + or al, al + jnz @f - ; type I - original style - call drawwindow_I - jmp window._.draw_window_caption.2 + ; type I - original style + call drawwindow_I + jmp window._.draw_window_caption.2 - @@: dec al - jnz @f + @@: dec al + jnz @f - ; type II - only reserve area, no draw - call sys_window_mouse - dec [mouse_pause] - call [draw_pointer] - jmp .exit + ; type II - only reserve area, no draw + call sys_window_mouse + dec [mouse_pause] + call [draw_pointer] + jmp .exit - @@: dec al - jnz @f + @@: dec al + jnz @f - ; type III - new style - call drawwindow_III - jmp window._.draw_window_caption.2 + ; type III - new style + call drawwindow_III + jmp window._.draw_window_caption.2 - ; type IV & V - skinned window (resizable & not) - @@: mov eax, [TASK_COUNT] - movzx eax, word[WIN_POS + eax * 2] - cmp eax, [CURRENT_TASK] - setz al - movzx eax, al - push eax - call drawwindow_IV - jmp window._.draw_window_caption.2 + ; type IV & V - skinned window (resizable & not) + @@: mov eax, [TASK_COUNT] + movzx eax, word[WIN_POS + eax * 2] + cmp eax, [CURRENT_TASK] + setz al + movzx eax, al + push eax + call drawwindow_IV + jmp window._.draw_window_caption.2 .exit: - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -130,158 +130,158 @@ syscall_display_settings: ;///// system function 48 /////////////////////////// ;< ecx = pointer to FileInfoBlock struct ;> eax = FS error code ;------------------------------------------------------------------------------ - cmp ebx, .sizeof.ftable / 4 - ja @f - jmp [.ftable + ebx * 4] + cmp ebx, .sizeof.ftable / 4 + ja @f + jmp [.ftable + ebx * 4] @@: ret align 4 syscall_display_settings.00: - xor eax, eax - inc ebx - cmp [windowtypechanged], ebx - jne .exit - mov [windowtypechanged], eax + xor eax, eax + inc ebx + cmp [windowtypechanged], ebx + jne .exit + mov [windowtypechanged], eax - jmp syscall_display_settings._.redraw_whole_screen + jmp syscall_display_settings._.redraw_whole_screen .exit: - ret + ret align 4 syscall_display_settings.01: - and ecx, 1 - cmp ecx, [buttontype] - je .exit - mov [buttontype], ecx - mov [windowtypechanged], ebx + and ecx, 1 + cmp ecx, [buttontype] + je .exit + mov [buttontype], ecx + mov [windowtypechanged], ebx .exit: - ret + ret align 4 syscall_display_settings.02: - dec ebx - mov esi, ecx - and edx, 127 - mov edi, common_colours - mov ecx, edx - rep movsb - mov [windowtypechanged], ebx - ret + dec ebx + mov esi, ecx + and edx, 127 + mov edi, common_colours + mov ecx, edx + rep movsb + mov [windowtypechanged], ebx + ret align 4 syscall_display_settings.03: - mov edi, ecx - and edx, 127 - mov esi, common_colours - mov ecx, edx - rep movsb - ret + mov edi, ecx + and edx, 127 + mov esi, common_colours + mov ecx, edx + rep movsb + ret align 4 syscall_display_settings.04: - mov eax, [_skinh] - mov [esp + 32], eax - ret + mov eax, [_skinh] + mov [esp + 32], eax + ret align 4 syscall_display_settings.05: - mov eax, [screen_workarea.left - 2] - mov ax, word[screen_workarea.right] - mov [esp + 32], eax - mov eax, [screen_workarea.top - 2] - mov ax, word[screen_workarea.bottom] - mov [esp + 20], eax - ret + mov eax, [screen_workarea.left - 2] + mov ax, word[screen_workarea.right] + mov [esp + 32], eax + mov eax, [screen_workarea.top - 2] + mov ax, word[screen_workarea.bottom] + mov [esp + 20], eax + ret align 4 syscall_display_settings.06: - xor esi, esi + xor esi, esi - mov edi, [Screen_Max_X] - mov eax, ecx - movsx ebx, ax - sar eax, 16 - cmp eax, ebx - jge .check_horizontal - inc esi - or eax, eax - jge @f - xor eax, eax - @@: mov [screen_workarea.left], eax - cmp ebx, edi - jle @f - mov ebx, edi - @@: mov [screen_workarea.right], ebx + mov edi, [Screen_Max_X] + mov eax, ecx + movsx ebx, ax + sar eax, 16 + cmp eax, ebx + jge .check_horizontal + inc esi + or eax, eax + jge @f + xor eax, eax + @@: mov [screen_workarea.left], eax + cmp ebx, edi + jle @f + mov ebx, edi + @@: mov [screen_workarea.right], ebx .check_horizontal: - mov edi, [Screen_Max_Y] - mov eax, edx - movsx ebx, ax - sar eax, 16 - cmp eax, ebx - jge .check_if_redraw_needed - inc esi - or eax, eax - jge @f - xor eax, eax - @@: mov [screen_workarea.top], eax - cmp ebx, edi - jle @f - mov ebx, edi - @@: mov [screen_workarea.bottom], ebx + mov edi, [Screen_Max_Y] + mov eax, edx + movsx ebx, ax + sar eax, 16 + cmp eax, ebx + jge .check_if_redraw_needed + inc esi + or eax, eax + jge @f + xor eax, eax + @@: mov [screen_workarea.top], eax + cmp ebx, edi + jle @f + mov ebx, edi + @@: mov [screen_workarea.bottom], ebx .check_if_redraw_needed: - or esi, esi - jz .exit + or esi, esi + jz .exit - call repos_windows - jmp syscall_display_settings._.calculate_whole_screen + call repos_windows + jmp syscall_display_settings._.calculate_whole_screen .exit: - ret + ret align 4 syscall_display_settings.07: - mov eax, [_skinmargins + 0] - mov [esp + 32], eax - mov eax, [_skinmargins + 4] - mov [esp + 20], eax - ret + mov eax, [_skinmargins + 0] + mov [esp + 32], eax + mov eax, [_skinmargins + 4] + mov [esp + 20], eax + ret align 4 syscall_display_settings.08: - mov ebx, ecx - call read_skin_file - mov [esp + 32], eax - test eax, eax - jnz .exit + mov ebx, ecx + call read_skin_file + mov [esp + 32], eax + test eax, eax + jnz .exit - call syscall_display_settings._.calculate_whole_screen - jmp syscall_display_settings._.redraw_whole_screen + call syscall_display_settings._.calculate_whole_screen + jmp syscall_display_settings._.redraw_whole_screen .exit: - ret + ret syscall_display_settings._.calculate_whole_screen: - xor eax, eax - xor ebx, ebx - mov ecx, [Screen_Max_X] - mov edx, [Screen_Max_Y] - jmp calculatescreen + xor eax, eax + xor ebx, ebx + mov ecx, [Screen_Max_X] + mov edx, [Screen_Max_Y] + jmp calculatescreen syscall_display_settings._.redraw_whole_screen: - xor eax, eax - mov [draw_limits.left], eax - mov [draw_limits.top], eax - mov eax, [Screen_Max_X] - mov [draw_limits.right], eax - mov eax, [Screen_Max_Y] - mov [draw_limits.bottom], eax - mov eax, window_data - jmp redrawscreen + xor eax, eax + mov [draw_limits.left], eax + mov [draw_limits.top], eax + mov eax, [Screen_Max_X] + mov [draw_limits.right], eax + mov eax, [Screen_Max_Y] + mov [draw_limits.bottom], eax + mov eax, window_data + jmp redrawscreen align 4 ;------------------------------------------------------------------------------ @@ -295,19 +295,19 @@ syscall_set_window_shape: ;///// system function 50 /////////////////////////// ;> ebx = 1 ;> ecx = scale power (resulting scale is 2^ebx) ;------------------------------------------------------------------------------ - mov edi, [current_slot] + mov edi, [current_slot] - test ebx, ebx - jne .shape_scale - mov [edi + APPDATA.wnd_shape], ecx + test ebx, ebx + jne .shape_scale + mov [edi + APPDATA.wnd_shape], ecx .shape_scale: - dec ebx - jnz .exit - mov [edi + APPDATA.wnd_shape_scale], ecx + dec ebx + jnz .exit + mov [edi + APPDATA.wnd_shape_scale], ecx .exit: - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -315,45 +315,41 @@ syscall_move_window: ;///// system function 67 //////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - mov edi, [CURRENT_TASK] - shl edi, 5 - add edi, window_data + mov edi, [CURRENT_TASK] + shl edi, 5 + add edi, window_data - test [edi + WDATA.fl_wdrawn], 1 - jz .exit + test [edi + WDATA.fl_wdrawn], 1 + jz .exit - test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED - jnz .exit + test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED + jnz .exit - cmp ebx, -1 - jne @f - mov ebx, [edi + WDATA.box.left] - @@: cmp ecx, -1 - jne @f - mov ecx, [edi + WDATA.box.top] - @@: cmp edx, -1 - jne @f - mov edx, [edi + WDATA.box.width] - @@: cmp esi, -1 - jne @f - mov esi, [edi + WDATA.box.height] + cmp ebx, -1 + jne @f + mov ebx, [edi + WDATA.box.left] + and bl, 0xFC + @@: cmp ecx, -1 + jne @f + mov ecx, [edi + WDATA.box.top] + and cl, 0xFE + @@: cmp edx, -1 + jne @f + mov edx, [edi + WDATA.box.width] + and dl, 0xFC + @@: cmp esi, -1 + jne @f + mov esi, [edi + WDATA.box.height] + and esi, 0xFFFFFFFE - @@: push esi edx ecx ebx - mov eax, esp - mov bl, [edi + WDATA.fl_wstate] - call window._.set_window_box - add esp, BOX.sizeof - - ; NOTE: do we really need this? to be reworked -; mov byte[DONT_DRAW_MOUSE], 0 ; mouse pointer -; mov byte[MOUSE_BACKGROUND], 0 ; no mouse under -; mov byte[MOUSE_DOWN], 0 ; react to mouse up/down - - ; NOTE: do we really need this? to be reworked -; call [draw_pointer] + @@: push esi edx ecx ebx + mov eax, esp + mov bl, [edi + WDATA.fl_wstate] + call window._.set_window_box + add esp, BOX.sizeof .exit: - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -361,33 +357,33 @@ syscall_window_settings: ;///// system function 71 ///////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - dec ebx ; subfunction #1 - set window caption - jnz .exit_fail + dec ebx ; subfunction #1 - set window caption + jnz .exit_fail - ; NOTE: only window owner thread can set its caption, - ; so there's no parameter for PID/TID + ; NOTE: only window owner thread can set its caption, + ; so there's no parameter for PID/TID - mov edi, [CURRENT_TASK] - shl edi, 5 + mov edi, [CURRENT_TASK] + shl edi, 5 - mov [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx - or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION + mov [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx + or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION - call window._.draw_window_caption + call window._.draw_window_caption - xor eax, eax ; eax = 0 (success) - ret + xor eax, eax ; eax = 0 (success) + ret ; .get_window_caption: ; dec eax ; subfunction #2 - get window caption ; jnz .exit_fail - ; not implemented yet + ; not implemented yet .exit_fail: - xor eax, eax - inc eax ; eax = 1 (fail) - ret + xor eax, eax + inc eax ; eax = 1 (fail) + ret align 4 ;------------------------------------------------------------------------------ @@ -395,20 +391,20 @@ set_window_defaults: ;///////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - mov byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable - push eax ecx - xor eax, eax - mov ecx, WIN_STACK - @@: inc eax - add ecx, 2 - ; process no - mov [ecx + 0x000], ax - ; positions in stack - mov [ecx + 0x400], ax - cmp ecx, WIN_POS - 2 - jne @b - pop ecx eax - ret + mov byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable + push eax ecx + xor eax, eax + mov ecx, WIN_STACK + @@: inc eax + add ecx, 2 + ; process no + mov [ecx + 0x000], ax + ; positions in stack + mov [ecx + 0x400], ax + cmp ecx, WIN_POS - 2 + jne @b + pop ecx eax + ret align 4 ;------------------------------------------------------------------------------ @@ -422,77 +418,77 @@ calculatescreen: ;///////////////////////////////////////////////////////////// ;> ecx = right ;> edx = bottom ;------------------------------------------------------------------------------ - push esi - pushfd - cli + push esi + pushfd + cli - mov esi, 1 - call window._.set_screen + mov esi, 1 + call window._.set_screen - push ebp + push ebp - mov ebp, [TASK_COUNT] - cmp ebp, 1 - jbe .exit + mov ebp, [TASK_COUNT] + cmp ebp, 1 + jbe .exit - push edx ecx ebx eax + push edx ecx ebx eax .next_window: - movzx edi, word[WIN_POS + esi * 2] - shl edi, 5 + movzx edi, word[WIN_POS + esi * 2] + shl edi, 5 - cmp [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE - je .skip_window + cmp [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE + je .skip_window - add edi, window_data - test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED - jnz .skip_window + add edi, window_data + test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED + jnz .skip_window - mov eax, [edi + WDATA.box.left] - cmp eax, [esp + RECT.right] - jg .skip_window - mov ebx, [edi + WDATA.box.top] - cmp ebx, [esp + RECT.bottom] - jg .skip_window - mov ecx, [edi + WDATA.box.width] - add ecx, eax - cmp ecx, [esp + RECT.left] - jl .skip_window - mov edx, [edi + WDATA.box.height] - add edx, ebx - cmp edx, [esp + RECT.top] - jl .skip_window + mov eax, [edi + WDATA.box.left] + cmp eax, [esp + RECT.right] + jg .skip_window + mov ebx, [edi + WDATA.box.top] + cmp ebx, [esp + RECT.bottom] + jg .skip_window + mov ecx, [edi + WDATA.box.width] + add ecx, eax + cmp ecx, [esp + RECT.left] + jl .skip_window + mov edx, [edi + WDATA.box.height] + add edx, ebx + cmp edx, [esp + RECT.top] + jl .skip_window - cmp eax, [esp + RECT.left] - jae @f - mov eax, [esp + RECT.left] - @@: cmp ebx, [esp + RECT.top] - jae @f - mov ebx, [esp + RECT.top] - @@: cmp ecx, [esp + RECT.right] - jbe @f - mov ecx, [esp + RECT.right] - @@: cmp edx, [esp + RECT.bottom] - jbe @f - mov edx, [esp + RECT.bottom] + cmp eax, [esp + RECT.left] + jae @f + mov eax, [esp + RECT.left] + @@: cmp ebx, [esp + RECT.top] + jae @f + mov ebx, [esp + RECT.top] + @@: cmp ecx, [esp + RECT.right] + jbe @f + mov ecx, [esp + RECT.right] + @@: cmp edx, [esp + RECT.bottom] + jbe @f + mov edx, [esp + RECT.bottom] - @@: push esi - movzx esi, word[WIN_POS + esi * 2] - call window._.set_screen - pop esi + @@: push esi + movzx esi, word[WIN_POS + esi * 2] + call window._.set_screen + pop esi .skip_window: - inc esi - dec ebp - jnz .next_window + inc esi + dec ebp + jnz .next_window - pop eax ebx ecx edx + pop eax ebx ecx edx .exit: - pop ebp - popfd - pop esi - ret + pop ebp + popfd + pop esi + ret align 4 ;------------------------------------------------------------------------------ @@ -500,65 +496,70 @@ repos_windows: ;/////////////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - mov ecx, [TASK_COUNT] - mov edi, window_data + WDATA.sizeof * 2 - call force_redraw_background - dec ecx - jle .exit + mov ecx, [TASK_COUNT] + mov edi, window_data + WDATA.sizeof * 2 + call force_redraw_background + dec ecx + jle .exit .next_window: - mov [edi + WDATA.fl_redraw], 1 - test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED - jnz .fix_maximized + mov [edi + WDATA.fl_redraw], 1 + test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED + jnz .fix_maximized - mov eax, [edi + WDATA.box.left] - add eax, [edi + WDATA.box.width] - mov ebx, [Screen_Max_X] - cmp eax, ebx - jle .fix_vertical - mov eax, [edi + WDATA.box.width] - sub eax, ebx - jle @f - mov [edi + WDATA.box.width], ebx - @@: sub ebx, [edi + WDATA.box.width] - mov [edi + WDATA.box.left], ebx + mov eax, [edi + WDATA.box.left] + add eax, [edi + WDATA.box.width] + mov ebx, [Screen_Max_X] + cmp eax, ebx + jle .fix_vertical + mov eax, [edi + WDATA.box.width] + sub eax, ebx + jle @f + and bl, 0xFC ; <<<<<<< + mov [edi + WDATA.box.width], ebx + @@: sub ebx, [edi + WDATA.box.width] + and bl, 0xFC ; <<<<<<< + mov [edi + WDATA.box.left], ebx .fix_vertical: - mov eax, [edi + WDATA.box.top] - add eax, [edi + WDATA.box.height] - mov ebx, [Screen_Max_Y] - cmp eax, ebx - jle .fix_client_box - mov eax, [edi + WDATA.box.height] - sub eax, ebx - jle @f - mov [edi + WDATA.box.height], ebx - @@: sub ebx, [edi + WDATA.box.height] - mov [edi + WDATA.box.top], ebx - jmp .fix_client_box + mov eax, [edi + WDATA.box.top] + add eax, [edi + WDATA.box.height] + mov ebx, [Screen_Max_Y] + cmp eax, ebx + jle .fix_client_box + mov eax, [edi + WDATA.box.height] + sub eax, ebx + jle @f + and bl, 0xFE ; <<<<<<< + mov [edi + WDATA.box.height], ebx + @@: sub ebx, [edi + WDATA.box.height] + and bl, 0xFE ; <<<<<<< + mov [edi + WDATA.box.top], ebx + jmp .fix_client_box .fix_maximized: - mov eax, [screen_workarea.left] - mov [edi + WDATA.box.left], eax - sub eax, [screen_workarea.right] - neg eax - mov [edi + WDATA.box.width], eax - mov eax, [screen_workarea.top] - mov [edi + WDATA.box.top], eax - test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP - jnz .fix_client_box - sub eax, [screen_workarea.bottom] - neg eax - mov [edi + WDATA.box.height], eax + mov eax, [screen_workarea.left] + mov [edi + WDATA.box.left], eax + sub eax, [screen_workarea.right] + neg eax + mov [edi + WDATA.box.width], eax + mov eax, [screen_workarea.top] + mov [edi + WDATA.box.top], eax + test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP + jnz .fix_client_box + sub eax, [screen_workarea.bottom] + neg eax + mov [edi + WDATA.box.height], eax .fix_client_box: - call window._.set_window_clientbox + call window._.set_window_clientbox - add edi, WDATA.sizeof - loop .next_window + add edi, WDATA.sizeof + dec ecx + jne .next_window ; <<<<<<<<<<< .exit: - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -566,8 +567,8 @@ sys_window_mouse: ;//////////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - ; NOTE: commented out since doesn't provide necessary functionality - ; anyway, to be reworked + ; NOTE: commented out since doesn't provide necessary functionality + ; anyway, to be reworked ; push eax ; ; mov eax, [timer_ticks] @@ -581,7 +582,7 @@ sys_window_mouse: ;//////////////////////////////////////////////////////////// ; ; .exit: ; pop eax - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -591,51 +592,51 @@ draw_rectangle: ;////////////////////////////////////////////////////////////// ;> ebx = pack[16(top), 16(bottom)] ;> esi = color ;------------------------------------------------------------------------------ - push eax ebx ecx edi + push eax ebx ecx edi - xor edi, edi + xor edi, edi .flags_set: - push ebx + push ebx - ; set line color - mov ecx, esi + ; set line color + mov ecx, esi - ; draw top border - rol ebx, 16 - push ebx - rol ebx, 16 - pop bx - call [draw_line] + ; draw top border + rol ebx, 16 + push ebx + rol ebx, 16 + pop bx + call [draw_line] - ; draw bottom border - mov ebx, [esp - 2] - pop bx - call [draw_line] + ; draw bottom border + mov ebx, [esp - 2] + pop bx + call [draw_line] - pop ebx - add ebx, 1 * 65536 - 1 + pop ebx + add ebx, 1 * 65536 - 1 - ; draw left border - rol eax, 16 - push eax - rol eax, 16 - pop ax - call [draw_line] + ; draw left border + rol eax, 16 + push eax + rol eax, 16 + pop ax + call [draw_line] - ; draw right border - mov eax, [esp - 2] - pop ax - call [draw_line] + ; draw right border + mov eax, [esp - 2] + pop ax + call [draw_line] - pop edi ecx ebx eax - ret + pop edi ecx ebx eax + ret .forced: - push eax ebx ecx edi - xor edi, edi - inc edi - jmp .flags_set + push eax ebx ecx edi + xor edi, edi + inc edi + jmp .flags_set align 4 ;------------------------------------------------------------------------------ @@ -643,46 +644,46 @@ drawwindow_I_caption: ;//////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - push [edx + WDATA.cl_titlebar] - mov esi, edx + push [edx + WDATA.cl_titlebar] + mov esi, edx - mov edx, [esi + WDATA.box.top] - mov eax, edx - lea ebx, [edx + 21] - inc edx - add eax, [esi + WDATA.box.height] + mov edx, [esi + WDATA.box.top] + mov eax, edx + lea ebx, [edx + 21] + inc edx + add eax, [esi + WDATA.box.height] - cmp ebx, eax - jbe @f - mov ebx, eax - @@: push ebx + cmp ebx, eax + jbe @f + mov ebx, eax + @@: push ebx - xor edi, edi + xor edi, edi .next_line: - mov ebx, edx - shl ebx, 16 - add ebx, edx - mov eax, [esi + WDATA.box.left] - inc eax - shl eax, 16 - add eax, [esi + WDATA.box.left] - add eax, [esi + WDATA.box.width] - dec eax - mov ecx, [esi + WDATA.cl_titlebar] - test ecx, 0x80000000 - jz @f - sub ecx, 0x00040404 - mov [esi + WDATA.cl_titlebar], ecx - @@: and ecx, 0x00ffffff - call [draw_line] - inc edx - cmp edx, [esp] - jb .next_line + mov ebx, edx + shl ebx, 16 + add ebx, edx + mov eax, [esi + WDATA.box.left] + inc eax + shl eax, 16 + add eax, [esi + WDATA.box.left] + add eax, [esi + WDATA.box.width] + dec eax + mov ecx, [esi + WDATA.cl_titlebar] + test ecx, 0x80000000 + jz @f + sub ecx, 0x00040404 + mov [esi + WDATA.cl_titlebar], ecx + @@: and ecx, 0x00ffffff + call [draw_line] + inc edx + cmp edx, [esp] + jb .next_line - add esp, 4 - pop [esi + WDATA.cl_titlebar] - ret + add esp, 4 + pop [esi + WDATA.cl_titlebar] + ret align 4 ;------------------------------------------------------------------------------ @@ -690,49 +691,49 @@ drawwindow_I: ;//////////////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - pushad + pushad - ; window border + ; window border - mov eax, [edx + WDATA.box.left - 2] - mov ax, word[edx + WDATA.box.left] - add ax, word[edx + WDATA.box.width] - mov ebx, [edx + WDATA.box.top - 2] - mov bx, word[edx + WDATA.box.top] - add bx, word[edx + WDATA.box.height] + mov eax, [edx + WDATA.box.left - 2] + mov ax, word[edx + WDATA.box.left] + add ax, word[edx + WDATA.box.width] + mov ebx, [edx + WDATA.box.top - 2] + mov bx, word[edx + WDATA.box.top] + add bx, word[edx + WDATA.box.height] - mov esi, [edx + WDATA.cl_frames] - call draw_rectangle + mov esi, [edx + WDATA.cl_frames] + call draw_rectangle - ; window caption + ; window caption - call drawwindow_I_caption + call drawwindow_I_caption - ; window client area + ; window client area - ; do we need to draw it? - mov edi, [esi + WDATA.cl_workarea] - test edi, 0x40000000 - jnz .exit + ; do we need to draw it? + mov edi, [esi + WDATA.cl_workarea] + test edi, 0x40000000 + jnz .exit - ; does client area have a positive size on screen? - mov edx, [esi + WDATA.box.top] - add edx, 21 + 5 - mov ebx, [esi + WDATA.box.top] - add ebx, [esi + WDATA.box.height] - cmp edx, ebx - jg .exit + ; does client area have a positive size on screen? + mov edx, [esi + WDATA.box.top] + add edx, 21 + 5 + mov ebx, [esi + WDATA.box.top] + add ebx, [esi + WDATA.box.height] + cmp edx, ebx + jg .exit - ; okay, let's draw it - mov eax, 1 - mov ebx, 21 - mov ecx, [esi + WDATA.box.width] - mov edx, [esi + WDATA.box.height] - call [drawbar] + ; okay, let's draw it + mov eax, 1 + mov ebx, 21 + mov ecx, [esi + WDATA.box.width] + mov edx, [esi + WDATA.box.height] + call [drawbar] .exit: - popad - ret + popad + ret align 4 ;------------------------------------------------------------------------------ @@ -740,49 +741,49 @@ drawwindow_III_caption: ;///////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - mov ecx, [edx + WDATA.cl_titlebar] - push ecx - mov esi, edx - mov edx, [esi + WDATA.box.top] - add edx, 4 - mov ebx, [esi + WDATA.box.top] - add ebx, 20 - mov eax, [esi + WDATA.box.top] - add eax, [esi + WDATA.box.height] + mov ecx, [edx + WDATA.cl_titlebar] + push ecx + mov esi, edx + mov edx, [esi + WDATA.box.top] + add edx, 4 + mov ebx, [esi + WDATA.box.top] + add ebx, 20 + mov eax, [esi + WDATA.box.top] + add eax, [esi + WDATA.box.height] - cmp ebx, eax - jb @f - mov ebx, eax - @@: push ebx + cmp ebx, eax + jb @f + mov ebx, eax + @@: push ebx - xor edi, edi + xor edi, edi .next_line: - mov ebx, edx - shl ebx, 16 - add ebx, edx - mov eax, [esi + WDATA.box.left] - shl eax, 16 - add eax, [esi + WDATA.box.left] - add eax, [esi + WDATA.box.width] - add eax, 4 * 65536 - 4 - mov ecx, [esi + WDATA.cl_titlebar] - test ecx, 0x40000000 - jz @f - add ecx, 0x00040404 - @@: test ecx, 0x80000000 - jz @f - sub ecx, 0x00040404 - @@: mov [esi + WDATA.cl_titlebar], ecx - and ecx, 0x00ffffff - call [draw_line] - inc edx - cmp edx, [esp] - jb .next_line + mov ebx, edx + shl ebx, 16 + add ebx, edx + mov eax, [esi + WDATA.box.left] + shl eax, 16 + add eax, [esi + WDATA.box.left] + add eax, [esi + WDATA.box.width] + add eax, 4 * 65536 - 4 + mov ecx, [esi + WDATA.cl_titlebar] + test ecx, 0x40000000 + jz @f + add ecx, 0x00040404 + @@: test ecx, 0x80000000 + jz @f + sub ecx, 0x00040404 + @@: mov [esi + WDATA.cl_titlebar], ecx + and ecx, 0x00ffffff + call [draw_line] + inc edx + cmp edx, [esp] + jb .next_line - add esp, 4 - pop [esi + WDATA.cl_titlebar] - ret + add esp, 4 + pop [esi + WDATA.cl_titlebar] + ret align 4 ;------------------------------------------------------------------------------ @@ -790,69 +791,69 @@ drawwindow_III: ;////////////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - pushad + pushad - ; window border + ; window border - mov eax, [edx + WDATA.box.left - 2] - mov ax, word[edx + WDATA.box.left] - add ax, word[edx + WDATA.box.width] - mov ebx, [edx + WDATA.box.top - 2] - mov bx, word[edx + WDATA.box.top] - add bx, word[edx + WDATA.box.height] + mov eax, [edx + WDATA.box.left - 2] + mov ax, word[edx + WDATA.box.left] + add ax, word[edx + WDATA.box.width] + mov ebx, [edx + WDATA.box.top - 2] + mov bx, word[edx + WDATA.box.top] + add bx, word[edx + WDATA.box.height] - mov esi, [edx + WDATA.cl_frames] - shr esi, 1 - and esi, 0x007f7f7f - call draw_rectangle + mov esi, [edx + WDATA.cl_frames] + shr esi, 1 + and esi, 0x007f7f7f + call draw_rectangle - push esi - mov ecx, 3 - mov esi, [edx + WDATA.cl_frames] + push esi + mov ecx, 3 + mov esi, [edx + WDATA.cl_frames] .next_frame: - add eax, 1 * 65536 - 1 - add ebx, 1 * 65536 - 1 - call draw_rectangle - dec ecx - jnz .next_frame + add eax, 1 * 65536 - 1 + add ebx, 1 * 65536 - 1 + call draw_rectangle + dec ecx + jnz .next_frame - pop esi - add eax, 1 * 65536 - 1 - add ebx, 1 * 65536 - 1 - call draw_rectangle + pop esi + add eax, 1 * 65536 - 1 + add ebx, 1 * 65536 - 1 + call draw_rectangle - ; window caption + ; window caption - call drawwindow_III_caption + call drawwindow_III_caption - ; window client area + ; window client area - ; do we need to draw it? - mov edi, [esi + WDATA.cl_workarea] - test edi, 0x40000000 - jnz .exit + ; do we need to draw it? + mov edi, [esi + WDATA.cl_workarea] + test edi, 0x40000000 + jnz .exit - ; does client area have a positive size on screen? - mov edx, [esi + WDATA.box.top] - add edx, 21 + 5 - mov ebx, [esi + WDATA.box.top] - add ebx, [esi + WDATA.box.height] - cmp edx, ebx - jg .exit + ; does client area have a positive size on screen? + mov edx, [esi + WDATA.box.top] + add edx, 21 + 5 + mov ebx, [esi + WDATA.box.top] + add ebx, [esi + WDATA.box.height] + cmp edx, ebx + jg .exit - ; okay, let's draw it - mov eax, 5 - mov ebx, 20 - mov ecx, [esi + WDATA.box.width] - mov edx, [esi + WDATA.box.height] - sub ecx, 4 - sub edx, 4 - call [drawbar] + ; okay, let's draw it + mov eax, 5 + mov ebx, 20 + mov ecx, [esi + WDATA.box.width] + mov edx, [esi + WDATA.box.height] + sub ecx, 4 + sub edx, 4 + call [drawbar] .exit: - popad - ret + popad + ret align 4 ;------------------------------------------------------------------------------ @@ -860,60 +861,60 @@ waredraw: ;//////////////////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? Activate window, redrawing if necessary ;------------------------------------------------------------------------------ - push -1 - mov eax, [TASK_COUNT] - lea eax, [WIN_POS + eax * 2] - cmp eax, esi - pop eax - je .exit + push -1 + mov eax, [TASK_COUNT] + lea eax, [WIN_POS + eax * 2] + cmp eax, esi + pop eax + je .exit - ; is it overlapped by another window now? - push ecx - call window._.check_window_draw - test ecx, ecx - pop ecx - jz .do_not_draw + ; is it overlapped by another window now? + push ecx + call window._.check_window_draw + test ecx, ecx + pop ecx + jz .do_not_draw - ; yes it is, activate and update screen buffer - mov byte[MOUSE_DOWN], 1 - call window._.window_activate + ; yes it is, activate and update screen buffer + mov byte[MOUSE_DOWN], 1 + call window._.window_activate - pushad - mov edi, [TASK_COUNT] - movzx esi, word[WIN_POS + edi * 2] - shl esi, 5 - add esi, window_data + pushad + mov edi, [TASK_COUNT] + movzx esi, word[WIN_POS + edi * 2] + shl esi, 5 + add esi, window_data - mov eax, [esi + WDATA.box.left] - mov ebx, [esi + WDATA.box.top] - mov ecx, [esi + WDATA.box.width] - mov edx, [esi + WDATA.box.height] + mov eax, [esi + WDATA.box.left] + mov ebx, [esi + WDATA.box.top] + mov ecx, [esi + WDATA.box.width] + mov edx, [esi + WDATA.box.height] - add ecx, eax - add edx, ebx + add ecx, eax + add edx, ebx - mov edi, [TASK_COUNT] - movzx esi, word[WIN_POS + edi * 2] - call window._.set_screen - popad + mov edi, [TASK_COUNT] + movzx esi, word[WIN_POS + edi * 2] + call window._.set_screen + popad - ; tell application to redraw itself - mov [edi + WDATA.fl_redraw], 1 - xor eax, eax - jmp .exit + ; tell application to redraw itself + mov [edi + WDATA.fl_redraw], 1 + xor eax, eax + jmp .exit .do_not_draw: - ; no it's not, just activate the window - call window._.window_activate - xor eax, eax - mov byte[MOUSE_BACKGROUND], al - mov byte[DONT_DRAW_MOUSE], al + ; no it's not, just activate the window + call window._.window_activate + xor eax, eax + mov byte[MOUSE_BACKGROUND], al + mov byte[DONT_DRAW_MOUSE], al .exit: - mov byte[MOUSE_DOWN], 0 - inc eax - ret + mov byte[MOUSE_DOWN], 0 + inc eax + ret align 4 ;------------------------------------------------------------------------------ @@ -923,42 +924,42 @@ minimize_window: ;///////////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;# corrupts [dl*] ;------------------------------------------------------------------------------ - push edi - pushfd - cli + push edi + pushfd + cli - ; is it already minimized? - movzx edi, word[WIN_POS + eax * 2] - shl edi, 5 - add edi, window_data - test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED - jnz .exit + ; is it already minimized? + movzx edi, word[WIN_POS + eax * 2] + shl edi, 5 + add edi, window_data + test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED + jnz .exit - push eax ebx ecx edx esi + push eax ebx ecx edx esi - ; no it's not, let's do that - or [edi + WDATA.fl_wstate], WSTATE_MINIMIZED - mov eax, [edi + WDATA.box.left] - mov [draw_limits.left], eax - mov ecx, eax - add ecx, [edi + WDATA.box.width] - mov [draw_limits.right], ecx - mov ebx, [edi + WDATA.box.top] - mov [draw_limits.top], ebx - mov edx, ebx - add edx, [edi + WDATA.box.height] - mov [draw_limits.bottom], edx - call calculatescreen - xor esi, esi - xor eax, eax - call redrawscreen + ; no it's not, let's do that + or [edi + WDATA.fl_wstate], WSTATE_MINIMIZED + mov eax, [edi + WDATA.box.left] + mov [draw_limits.left], eax + mov ecx, eax + add ecx, [edi + WDATA.box.width] + mov [draw_limits.right], ecx + mov ebx, [edi + WDATA.box.top] + mov [draw_limits.top], ebx + mov edx, ebx + add edx, [edi + WDATA.box.height] + mov [draw_limits.bottom], edx + call calculatescreen + xor esi, esi + xor eax, eax + call redrawscreen - pop esi edx ecx ebx eax + pop esi edx ecx ebx eax .exit: - popfd - pop edi - ret + popfd + pop edi + ret align 4 ;------------------------------------------------------------------------------ @@ -968,39 +969,39 @@ restore_minimized_window: ;//////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;# corrupts [dl*] ;------------------------------------------------------------------------------ - pushad - pushfd - cli + pushad + pushfd + cli - ; is it already restored? - movzx esi, word[WIN_POS + eax * 2] - mov edi, esi - shl edi, 5 - add edi, window_data - test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED - jz .exit + ; is it already restored? + movzx esi, word[WIN_POS + eax * 2] + mov edi, esi + shl edi, 5 + add edi, window_data + test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED + jz .exit - ; no it's not, let's do that - mov [edi + WDATA.fl_redraw], 1 - and [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED - mov ebp, window._.set_screen - cmp eax, [TASK_COUNT] - jz @f - mov ebp, calculatescreen - @@: mov eax, [edi + WDATA.box.left] - mov ebx, [edi + WDATA.box.top] - mov ecx, [edi + WDATA.box.width] - mov edx, [edi + WDATA.box.height] - add ecx, eax - add edx, ebx - call ebp + ; no it's not, let's do that + mov [edi + WDATA.fl_redraw], 1 + and [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED + mov ebp, window._.set_screen + cmp eax, [TASK_COUNT] + jz @f + mov ebp, calculatescreen + @@: mov eax, [edi + WDATA.box.left] + mov ebx, [edi + WDATA.box.top] + mov ecx, [edi + WDATA.box.width] + mov edx, [edi + WDATA.box.height] + add ecx, eax + add edx, ebx + call ebp - mov byte[MOUSE_BACKGROUND], 0 + mov byte[MOUSE_BACKGROUND], 0 .exit: - popfd - popad - ret + popfd + popad + ret align 4 ; TODO: remove this proc @@ -1009,23 +1010,23 @@ window_check_events: ;///////////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - ; do we have window minimize/restore request? - cmp [window_minimize], 0 - je .exit + ; do we have window minimize/restore request? + cmp [window_minimize], 0 + je .exit - ; okay, minimize or restore top-most window and exit - mov eax, [TASK_COUNT] - mov bl, 0 - xchg [window_minimize], bl - dec bl - jnz @f - call minimize_window - jmp .exit + ; okay, minimize or restore top-most window and exit + mov eax, [TASK_COUNT] + mov bl, 0 + xchg [window_minimize], bl + dec bl + jnz @f + call minimize_window + jmp .exit - @@: call restore_minimized_window + @@: call restore_minimized_window .exit: - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -1035,59 +1036,59 @@ sys_window_maximize_handler: ;///////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;> esi = process slot ;------------------------------------------------------------------------------ - mov edi, esi - shl edi, 5 - add edi, window_data + mov edi, esi + shl edi, 5 + add edi, window_data - ; can window change its height? - ; only types 2 and 3 can be resized - mov dl, [edi + WDATA.fl_wstyle] - test dl, 2 - jz .exit + ; can window change its height? + ; only types 2 and 3 can be resized + mov dl, [edi + WDATA.fl_wstyle] + test dl, 2 + jz .exit - ; toggle normal/maximized window state - mov bl, [edi + WDATA.fl_wstate] - xor bl, WSTATE_MAXIMIZED + ; toggle normal/maximized window state + mov bl, [edi + WDATA.fl_wstate] + xor bl, WSTATE_MAXIMIZED - ; calculate and set appropriate window bounds - test bl, WSTATE_MAXIMIZED - jz .restore_size + ; calculate and set appropriate window bounds + test bl, WSTATE_MAXIMIZED + jz .restore_size - mov eax, [screen_workarea.left] - mov ecx, [screen_workarea.top] - push [screen_workarea.bottom] \ - [screen_workarea.right] \ - ecx \ - eax - sub [esp + BOX.width], eax - sub [esp + BOX.height], ecx - mov eax, esp - jmp .set_box + mov eax, [screen_workarea.left] + mov ecx, [screen_workarea.top] + push [screen_workarea.bottom] \ + [screen_workarea.right] \ + ecx \ + eax + sub [esp + BOX.width], eax + sub [esp + BOX.height], ecx + mov eax, esp + jmp .set_box .restore_size: - mov eax, esi - shl eax, 8 - add eax, SLOT_BASE + APPDATA.saved_box - push [eax + BOX.height] \ - [eax + BOX.width] \ - [eax + BOX.top] \ - [eax + BOX.left] - mov eax, esp + mov eax, esi + shl eax, 8 + add eax, SLOT_BASE + APPDATA.saved_box + push [eax + BOX.height] \ + [eax + BOX.width] \ + [eax + BOX.top] \ + [eax + BOX.left] + mov eax, esp .set_box: - test bl, WSTATE_ROLLEDUP - jz @f + test bl, WSTATE_ROLLEDUP + jz @f - xchg eax, ecx - call window._.get_rolledup_height - mov [ecx + BOX.height], eax - xchg eax, ecx + xchg eax, ecx + call window._.get_rolledup_height + mov [ecx + BOX.height], eax + xchg eax, ecx - @@: call window._.set_window_box - add esp, BOX.sizeof + @@: call window._.set_window_box + add esp, BOX.sizeof .exit: - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -1097,46 +1098,46 @@ sys_window_rollup_handler: ;/////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;> esi = process slot ;------------------------------------------------------------------------------ - mov edx, esi - shl edx, 8 - add edx, SLOT_BASE + mov edx, esi + shl edx, 8 + add edx, SLOT_BASE - ; toggle normal/rolled up window state - mov bl, [edi + WDATA.fl_wstate] - xor bl, WSTATE_ROLLEDUP + ; toggle normal/rolled up window state + mov bl, [edi + WDATA.fl_wstate] + xor bl, WSTATE_ROLLEDUP - ; calculate and set appropriate window bounds - test bl, WSTATE_ROLLEDUP - jz .restore_size + ; calculate and set appropriate window bounds + test bl, WSTATE_ROLLEDUP + jz .restore_size - call window._.get_rolledup_height - push eax \ - [edi + WDATA.box.width] \ - [edi + WDATA.box.top] \ - [edi + WDATA.box.left] - mov eax, esp - jmp .set_box + call window._.get_rolledup_height + push eax \ + [edi + WDATA.box.width] \ + [edi + WDATA.box.top] \ + [edi + WDATA.box.left] + mov eax, esp + jmp .set_box .restore_size: - test bl, WSTATE_MAXIMIZED - jnz @f - add esp, -BOX.sizeof - lea eax, [edx + APPDATA.saved_box] - jmp .set_box + test bl, WSTATE_MAXIMIZED + jnz @f + add esp, -BOX.sizeof + lea eax, [edx + APPDATA.saved_box] + jmp .set_box - @@: mov eax, [screen_workarea.top] - push [screen_workarea.bottom] \ - [edi + WDATA.box.width] \ - eax \ - [edi + WDATA.box.left] - sub [esp + BOX.height], eax - mov eax, esp + @@: mov eax, [screen_workarea.top] + push [screen_workarea.bottom] \ + [edi + WDATA.box.width] \ + eax \ + [edi + WDATA.box.left] + sub [esp + BOX.height], eax + mov eax, esp .set_box: - call window._.set_window_box - add esp, BOX.sizeof + call window._.set_window_box + add esp, BOX.sizeof - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -1147,10 +1148,10 @@ sys_window_start_moving_handler: ;///////////////////////////////////////////// ;> eax = old (original) window box ;> esi = process slot ;------------------------------------------------------------------------------ - mov edi, eax - call window._.draw_negative_box + mov edi, eax + call window._.draw_negative_box - ret + ret align 4 ;------------------------------------------------------------------------------ @@ -1162,17 +1163,17 @@ sys_window_end_moving_handler: ;/////////////////////////////////////////////// ;> ebx = new (final) window box ;> esi = process slot ;------------------------------------------------------------------------------ - mov edi, ebx - call window._.draw_negative_box + mov edi, ebx + call window._.draw_negative_box - mov edi, esi - shl edi, 5 - add edi, window_data + mov edi, esi + shl edi, 5 + add edi, window_data - mov eax, ebx - mov bl, [edi + WDATA.fl_wstate] - call window._.set_window_box - ret + mov eax, ebx + mov bl, [edi + WDATA.fl_wstate] + call window._.set_window_box + ret align 4 ;------------------------------------------------------------------------------ @@ -1184,11 +1185,11 @@ sys_window_moving_handler: ;/////////////////////////////////////////////////// ;> ebx = new (current) window box ;> esi = process_slot ;------------------------------------------------------------------------------ - mov edi, eax - call window._.draw_negative_box - mov edi, ebx - call window._.draw_negative_box - ret + mov edi, eax + call window._.draw_negative_box + mov edi, ebx + call window._.draw_negative_box + ret ;============================================================================== ;///// private functions ////////////////////////////////////////////////////// @@ -1201,10 +1202,10 @@ iglobal align 4 window_topleft dd \ 1, 21, \ ;type 0 - 0, 0, \ ;type 1 + 0, 0, \ ;type 1 5, 20, \ ;type 2 - 5, ?, \ ;type 3 {set by skin} - 5, ? ;type 4 {set by skin} + 5, ?, \ ;type 3 {set by skin} + 5, ? ;type 4 {set by skin} endg ;uglobal @@ -1223,65 +1224,65 @@ window._.invalidate_screen: ;////////////////////////////////////////////////// ;> ebx = new (final) window box ;> edi = pointer to WDATA struct ;------------------------------------------------------------------------------ - push eax ebx + push eax ebx - ; TODO: do we really need `draw_limits`? - ; Yes, they are used by background drawing code. - mov ecx, [eax + BOX.left] - mov edx, [ebx + BOX.left] - cmp ecx, edx - jle @f - mov ecx, edx - @@: mov [draw_limits.left], ecx - mov ecx, [eax + BOX.left] - add ecx, [eax + BOX.width] - add edx, [ebx + BOX.width] - cmp ecx, edx - jae @f - mov ecx, edx - @@: mov [draw_limits.right], ecx - mov ecx, [eax + BOX.top] - mov edx, [ebx + BOX.top] - cmp ecx, edx - jle @f - mov ecx, edx - @@: mov [draw_limits.top], ecx - mov ecx, [eax + BOX.top] - add ecx, [eax + BOX.height] - add edx, [ebx + BOX.height] - cmp ecx, edx - jae @f - mov ecx, edx - @@: mov [draw_limits.bottom], ecx + ; TODO: do we really need `draw_limits`? + ; Yes, they are used by background drawing code. + mov ecx, [eax + BOX.left] + mov edx, [ebx + BOX.left] + cmp ecx, edx + jle @f + mov ecx, edx + @@: mov [draw_limits.left], ecx + mov ecx, [eax + BOX.left] + add ecx, [eax + BOX.width] + add edx, [ebx + BOX.width] + cmp ecx, edx + jae @f + mov ecx, edx + @@: mov [draw_limits.right], ecx + mov ecx, [eax + BOX.top] + mov edx, [ebx + BOX.top] + cmp ecx, edx + jle @f + mov ecx, edx + @@: mov [draw_limits.top], ecx + mov ecx, [eax + BOX.top] + add ecx, [eax + BOX.height] + add edx, [ebx + BOX.height] + cmp ecx, edx + jae @f + mov ecx, edx + @@: mov [draw_limits.bottom], ecx - ; recalculate screen buffer at old position - push ebx - mov edx, [eax + BOX.height] - mov ecx, [eax + BOX.width] - mov ebx, [eax + BOX.top] - mov eax, [eax + BOX.left] - add ecx, eax - add edx, ebx - call calculatescreen - pop eax + ; recalculate screen buffer at old position + push ebx + mov edx, [eax + BOX.height] + mov ecx, [eax + BOX.width] + mov ebx, [eax + BOX.top] + mov eax, [eax + BOX.left] + add ecx, eax + add edx, ebx + call calculatescreen + pop eax - ; recalculate screen buffer at new position - mov edx, [eax + BOX.height] - mov ecx, [eax + BOX.width] - mov ebx, [eax + BOX.top] - mov eax, [eax + BOX.left] - add ecx, eax - add edx, ebx - call calculatescreen + ; recalculate screen buffer at new position + mov edx, [eax + BOX.height] + mov ecx, [eax + BOX.width] + mov ebx, [eax + BOX.top] + mov eax, [eax + BOX.left] + add ecx, eax + add edx, ebx + call calculatescreen - mov eax, edi - call redrawscreen + mov eax, edi + call redrawscreen - ; tell window to redraw itself - mov [edi + WDATA.fl_redraw], 1 + ; tell window to redraw itself + mov [edi + WDATA.fl_redraw], 1 - pop ebx eax - ret + pop ebx eax + ret align 4 ;------------------------------------------------------------------------------ @@ -1293,7 +1294,7 @@ window._.set_window_box: ;///////////////////////////////////////////////////// ;> bl = new window state flags ;> edi = pointer to WDATA struct ;------------------------------------------------------------------------------ - push eax ebx esi + push eax ebx esi ; don't do anything if the new box is identical to the old cmp bl, [edi + WDATA.fl_wstate] @@ -1309,60 +1310,60 @@ end if jz .exit @@: - add esp, -BOX.sizeof + add esp, -BOX.sizeof - mov ebx, esp + mov ebx, esp if WDATA.box - lea esi, [edi + WDATA.box] + lea esi, [edi + WDATA.box] else mov esi, edi ; optimization for WDATA.box = 0 end if - xchg eax, esi - mov ecx, BOX.sizeof - call memmove - xchg eax, esi - xchg ebx, esi - call memmove - mov eax, ebx - mov ebx, esi + xchg eax, esi + mov ecx, BOX.sizeof + call memmove + xchg eax, esi + xchg ebx, esi + call memmove + mov eax, ebx + mov ebx, esi - call window._.check_window_position - call window._.set_window_clientbox - call window._.invalidate_screen + call window._.check_window_position + call window._.set_window_clientbox + call window._.invalidate_screen - add esp, BOX.sizeof + add esp, BOX.sizeof - mov cl, [esp + 4] - mov ch, cl - xchg cl, [edi + WDATA.fl_wstate] + mov cl, [esp + 4] + mov ch, cl + xchg cl, [edi + WDATA.fl_wstate] - or cl, ch - test cl, WSTATE_MAXIMIZED - jnz .exit + or cl, ch + test cl, WSTATE_MAXIMIZED + jnz .exit - mov eax, edi - sub eax, window_data - shl eax, 3 - add eax, SLOT_BASE + mov eax, edi + sub eax, window_data + shl eax, 3 + add eax, SLOT_BASE - lea ebx, [edi + WDATA.box] - xchg esp, ebx + lea ebx, [edi + WDATA.box] + xchg esp, ebx - pop [eax + APPDATA.saved_box.left] \ - [eax + APPDATA.saved_box.top] \ - [eax + APPDATA.saved_box.width] \ - edx + pop [eax + APPDATA.saved_box.left] \ + [eax + APPDATA.saved_box.top] \ + [eax + APPDATA.saved_box.width] \ + edx - xchg esp, ebx + xchg esp, ebx - test ch, WSTATE_ROLLEDUP - jnz .exit + test ch, WSTATE_ROLLEDUP + jnz .exit - mov [eax + APPDATA.saved_box.height], edx + mov [eax + APPDATA.saved_box.height], edx .exit: - pop esi ebx eax - ret + pop esi ebx eax + ret align 4 ;------------------------------------------------------------------------------ @@ -1372,51 +1373,51 @@ window._.set_window_clientbox: ;/////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;> edi = pointer to WDATA struct ;------------------------------------------------------------------------------ - push eax ecx edi + push eax ecx edi - mov eax, [_skinh] - mov [window_topleft + 8 * 3 + 4], eax - mov [window_topleft + 8 * 4 + 4], eax + mov eax, [_skinh] + mov [window_topleft + 8 * 3 + 4], eax + mov [window_topleft + 8 * 4 + 4], eax - mov ecx, edi - sub edi, window_data - shl edi, 3 - test [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE - jz .whole_window + mov ecx, edi + sub edi, window_data + shl edi, 3 + test [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE + jz .whole_window - movzx eax, [ecx + WDATA.fl_wstyle] - and eax, 0x0F - mov eax, [eax * 8 + window_topleft + 0] - mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax - shl eax, 1 - neg eax - add eax, [ecx + WDATA.box.width] - mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax + movzx eax, [ecx + WDATA.fl_wstyle] + and eax, 0x0F + mov eax, [eax * 8 + window_topleft + 0] + mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax + shl eax, 1 + neg eax + add eax, [ecx + WDATA.box.width] + mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax - movzx eax, [ecx + WDATA.fl_wstyle] - and eax, 0x0F - push [eax * 8 + window_topleft + 0] - mov eax, [eax * 8 + window_topleft + 4] - mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax - neg eax - sub eax, [esp] - add eax, [ecx + WDATA.box.height] - mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax - add esp, 4 - jmp .exit + movzx eax, [ecx + WDATA.fl_wstyle] + and eax, 0x0F + push [eax * 8 + window_topleft + 0] + mov eax, [eax * 8 + window_topleft + 4] + mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax + neg eax + sub eax, [esp] + add eax, [ecx + WDATA.box.height] + mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax + add esp, 4 + jmp .exit .whole_window: - xor eax, eax - mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax - mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax - mov eax, [ecx + WDATA.box.width] - mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax - mov eax, [ecx + WDATA.box.height] - mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax + xor eax, eax + mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax + mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax + mov eax, [ecx + WDATA.box.width] + mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax + mov eax, [ecx + WDATA.box.height] + mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax .exit: - pop edi ecx eax - ret + pop edi ecx eax + ret align 4 ;------------------------------------------------------------------------------ @@ -1426,92 +1427,94 @@ window._.sys_set_window: ;///////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;< edx = pointer to WDATA struct ;------------------------------------------------------------------------------ - mov eax, [CURRENT_TASK] - shl eax, 5 - add eax, window_data + mov eax, [CURRENT_TASK] + shl eax, 5 + add eax, window_data - ; save window colors - mov [eax + WDATA.cl_workarea], edx - mov [eax + WDATA.cl_titlebar], esi - mov [eax + WDATA.cl_frames], edi + ; save window colors + mov [eax + WDATA.cl_workarea], edx + mov [eax + WDATA.cl_titlebar], esi + mov [eax + WDATA.cl_frames], edi - mov edi, eax + mov edi, eax - ; was it already defined before? - test [edi + WDATA.fl_wdrawn], 1 - jnz .set_client_box - or [edi + WDATA.fl_wdrawn], 1 + ; was it already defined before? + test [edi + WDATA.fl_wdrawn], 1 + jnz .set_client_box + or [edi + WDATA.fl_wdrawn], 1 - ; NOTE: commented out since doesn't provide necessary functionality - ; anyway, to be reworked + ; NOTE: commented out since doesn't provide necessary functionality + ; anyway, to be reworked ; mov eax, [timer_ticks] ; [0xfdf0] ; add eax, 100 ; mov [new_window_starting], eax - ; no it wasn't, performing initial window definition - movzx eax, bx - mov [edi + WDATA.box.width], eax - movzx eax, cx - mov [edi + WDATA.box.height], eax - sar ebx, 16 - sar ecx, 16 - mov [edi + WDATA.box.left], ebx - mov [edi + WDATA.box.top], ecx + ; no it wasn't, performing initial window definition + movzx eax, bx + mov [edi + WDATA.box.width], eax + movzx eax, cx + mov [edi + WDATA.box.height], eax + sar ebx, 16 + and bl, 0xFC ; <<<<<<<< + sar ecx, 16 + and cl, 0xFE ; <<<<<<<< + mov [edi + WDATA.box.left], ebx + mov [edi + WDATA.box.top], ecx - call window._.check_window_position + call window._.check_window_position - push ecx edi + push ecx edi - mov cl, [edi + WDATA.fl_wstyle] - mov eax, [edi + WDATA.cl_frames] + mov cl, [edi + WDATA.fl_wstyle] + mov eax, [edi + WDATA.cl_frames] - sub edi, window_data - shl edi, 3 - add edi, SLOT_BASE + sub edi, window_data + shl edi, 3 + add edi, SLOT_BASE - and cl, 0x0F - cmp cl, 3 - je @f - cmp cl, 4 - je @f + and cl, 0x0F + cmp cl, 3 + je @f + cmp cl, 4 + je @f - xor eax, eax + xor eax, eax - @@: mov [edi + APPDATA.wnd_caption], eax + @@: mov [edi + APPDATA.wnd_caption], eax - mov esi, [esp] - add edi, APPDATA.saved_box - movsd - movsd - movsd - movsd + mov esi, [esp] + add edi, APPDATA.saved_box + movsd + movsd + movsd + movsd - pop edi ecx + pop edi ecx - mov esi, [CURRENT_TASK] - movzx esi, word[WIN_STACK + esi * 2] - lea esi, [WIN_POS + esi * 2] - call waredraw + mov esi, [CURRENT_TASK] + movzx esi, word[WIN_STACK + esi * 2] + lea esi, [WIN_POS + esi * 2] + call waredraw - mov eax, [edi + WDATA.box.left] - mov ebx, [edi + WDATA.box.top] - mov ecx, [edi + WDATA.box.width] - mov edx, [edi + WDATA.box.height] - add ecx, eax - add edx, ebx - call calculatescreen + mov eax, [edi + WDATA.box.left] + mov ebx, [edi + WDATA.box.top] + mov ecx, [edi + WDATA.box.width] + mov edx, [edi + WDATA.box.height] + add ecx, eax + add edx, ebx + call calculatescreen - mov byte[KEY_COUNT], 0 ; empty keyboard buffer - mov byte[BTN_COUNT], 0 ; empty button buffer + mov byte[KEY_COUNT], 0 ; empty keyboard buffer + mov byte[BTN_COUNT], 0 ; empty button buffer .set_client_box: - ; update window client box coordinates - call window._.set_window_clientbox + ; update window client box coordinates + call window._.set_window_clientbox - ; reset window redraw flag and exit - mov [edi + WDATA.fl_redraw], 0 - mov edx, edi - ret + ; reset window redraw flag and exit + mov [edi + WDATA.fl_redraw], 0 + mov edx, edi + ret align 4 ;------------------------------------------------------------------------------ @@ -1521,71 +1524,71 @@ window._.check_window_position: ;////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;> edi = pointer to WDATA ;------------------------------------------------------------------------------ - push eax ebx ecx edx esi + push eax ebx ecx edx esi - mov eax, [edi + WDATA.box.left] - mov ebx, [edi + WDATA.box.top] - mov ecx, [edi + WDATA.box.width] - mov edx, [edi + WDATA.box.height] + mov eax, [edi + WDATA.box.left] + mov ebx, [edi + WDATA.box.top] + mov ecx, [edi + WDATA.box.width] + mov edx, [edi + WDATA.box.height] - mov esi, [Screen_Max_X] - cmp ecx, esi - ja .fix_width_high + mov esi, [Screen_Max_X] + cmp ecx, esi + ja .fix_width_high .check_left: - or eax, eax - jl .fix_left_low - add eax, ecx - cmp eax, esi - jg .fix_left_high + or eax, eax + jl .fix_left_low + add eax, ecx + cmp eax, esi + jg .fix_left_high .check_height: - mov esi, [Screen_Max_Y] - cmp edx, esi - ja .fix_height_high + mov esi, [Screen_Max_Y] + cmp edx, esi + ja .fix_height_high .check_top: - or ebx, ebx - jl .fix_top_low - add ebx, edx - cmp ebx, esi - jg .fix_top_high + or ebx, ebx + jl .fix_top_low + add ebx, edx + cmp ebx, esi + jg .fix_top_high .exit: - pop esi edx ecx ebx eax - ret + pop esi edx ecx ebx eax + ret .fix_width_high: - mov ecx, esi - mov [edi + WDATA.box.width], esi - jmp .check_left + mov ecx, esi + mov [edi + WDATA.box.width], esi + jmp .check_left .fix_left_low: - xor eax, eax - mov [edi + WDATA.box.left], eax - jmp .check_height + xor eax, eax + mov [edi + WDATA.box.left], eax + jmp .check_height .fix_left_high: - mov eax, esi - sub eax, ecx - mov [edi + WDATA.box.left], eax - jmp .check_height + mov eax, esi + sub eax, ecx + mov [edi + WDATA.box.left], eax + jmp .check_height .fix_height_high: - mov edx, esi - mov [edi + WDATA.box.height], esi - jmp .check_top + mov edx, esi + mov [edi + WDATA.box.height], esi + jmp .check_top .fix_top_low: - xor ebx, ebx - mov [edi + WDATA.box.top], ebx - jmp .exit + xor ebx, ebx + mov [edi + WDATA.box.top], ebx + jmp .exit .fix_top_high: - mov ebx, esi - sub ebx, edx - mov [edi + WDATA.box.top], ebx - jmp .exit + mov ebx, esi + sub ebx, edx + mov [edi + WDATA.box.top], ebx + jmp .exit align 4 ;------------------------------------------------------------------------------ @@ -1595,14 +1598,14 @@ window._.get_titlebar_height: ;//////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;> edi = pointer to WDATA ;------------------------------------------------------------------------------ - mov al, [edi + WDATA.fl_wstyle] - and al, 0x0f - cmp al, 0x03 - jne @f - mov eax, [_skinh] - ret - @@: mov eax, 21 - ret + mov al, [edi + WDATA.fl_wstyle] + and al, 0x0f + cmp al, 0x03 + jne @f + mov eax, [_skinh] + ret + @@: mov eax, 21 + ret align 4 ;------------------------------------------------------------------------------ @@ -1612,19 +1615,19 @@ window._.get_rolledup_height: ;//////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;> edi = pointer to WDATA ;------------------------------------------------------------------------------ - mov al, [edi + WDATA.fl_wstyle] - and al, 0x0f - cmp al, 0x03 - jb @f - mov eax, [_skinh] - add eax, 3 - ret - @@: or al, al - jnz @f - mov eax, 21 - ret - @@: mov eax, 21 + 2 - ret + mov al, [edi + WDATA.fl_wstyle] + and al, 0x0f + cmp al, 0x03 + jb @f + mov eax, [_skinh] + add eax, 3 + ret + @@: or al, al + jnz @f + mov eax, 21 + ret + @@: mov eax, 21 + 2 + ret align 4 ;------------------------------------------------------------------------------ @@ -1639,166 +1642,168 @@ window._.set_screen: ;///////////////////////////////////////////////////////// ;> esi = process number ;------------------------------------------------------------------------------ virtual at esp - ff_x dd ? - ff_y dd ? + ff_x dd ? + ff_y dd ? ff_width dd ? ff_xsz dd ? ff_ysz dd ? ff_scale dd ? end virtual - pushad + pushad - cmp esi, 1 - jz .check_for_shaped_window - mov edi, esi - shl edi, 5 - cmp [window_data + edi + WDATA.box.width], 0 - jnz .check_for_shaped_window - cmp [window_data + edi + WDATA.box.height], 0 - jz .exit + cmp esi, 1 + jz .check_for_shaped_window + mov edi, esi + shl edi, 5 + cmp [window_data + edi + WDATA.box.width], 0 + jnz .check_for_shaped_window + cmp [window_data + edi + WDATA.box.height], 0 + jz .exit .check_for_shaped_window: - mov edi, esi - shl edi, 8 - add edi, SLOT_BASE - cmp [edi + APPDATA.wnd_shape], 0 - jne .shaped_window + mov edi, esi + shl edi, 8 + add edi, SLOT_BASE + cmp [edi + APPDATA.wnd_shape], 0 + jne .shaped_window - ; get x&y size - sub ecx, eax - sub edx, ebx - inc ecx - inc edx + ; get x&y size + sub ecx, eax + sub edx, ebx + inc ecx + inc edx - ; get WinMap start - push esi - mov edi, [Screen_Max_X] - inc edi - mov esi, edi - imul edi, ebx - add edi, eax - add edi, [_WinMapAddress] - pop eax - mov ah, al - push ax - shl eax, 16 - pop ax + ; get WinMap start + push esi + mov edi, [_WinMapWidth] + mov esi, edi + imul edi, ebx + shr eax, 1 + shr eax, 1 + add edi, eax + add edi, [_WinMapAddress] + pop eax + mov ah, al + push ax + shl eax, 16 + pop ax .next_line: - push ecx - shr ecx, 2 - rep stosd - mov ecx, [esp] - and ecx, 3 - rep stosb - pop ecx - add edi, esi - sub edi, ecx - dec edx - jnz .next_line + push ecx + shr ecx, 2 + rep stosd + mov ecx, [esp] + and ecx, 3 + rep stosb + pop ecx + add edi, esi + sub edi, ecx + dec edx + jnz .next_line - jmp .exit + jmp .exit .shaped_window: - ; for (y=0; y <= x_size; y++) - ; for (x=0; x <= x_size; x++) - ; if (shape[coord(x,y,scale)]==1) - ; set_pixel(x, y, process_number); + ; for (y=0; y <= x_size; y++) + ; for (x=0; x <= x_size; x++) + ; if (shape[coord(x,y,scale)]==1) + ; set_pixel(x, y, process_number); - sub ecx, eax - sub edx, ebx - inc ecx - inc edx + sub ecx, eax + sub edx, ebx + inc ecx + inc edx - push [edi + APPDATA.wnd_shape_scale] ; push scale first -> for loop + push [edi + APPDATA.wnd_shape_scale] ; push scale first -> for loop - ; get WinMap start -> ebp - push eax - mov eax, [Screen_Max_X] ; screen_sx - inc eax - imul eax, ebx - add eax, [esp] - add eax, [_WinMapAddress] - mov ebp, eax + ; get WinMap start -> ebp + push eax + mov eax, [_WinMapWidth] ; <<<< + imul eax, ebx + mov ebp, [esp] + shr ebp, 1 + shr ebp, 1 + add ebp, eax + add ebp, [_WinMapAddress] - mov edi, [edi + APPDATA.wnd_shape] - pop eax + mov edi, [edi + APPDATA.wnd_shape] + pop eax - ; eax = x_start - ; ebx = y_start - ; ecx = x_size - ; edx = y_size - ; esi = process_number - ; edi = &shape - ; [scale] - push edx ecx ; for loop - x,y size + ; eax = x_start + ; ebx = y_start + ; ecx = x_size + ; edx = y_size + ; esi = process_number + ; edi = &shape + ; [scale] + push edx ecx ; for loop - x,y size - mov ecx, esi - shl ecx, 5 - mov edx, [window_data + ecx + WDATA.box.top] - push [window_data + ecx + WDATA.box.width] ; for loop - width - mov ecx, [window_data + ecx + WDATA.box.left] - sub ebx, edx - sub eax, ecx - push ebx eax ; for loop - x,y + mov ecx, esi + shl ecx, 5 + mov edx, [window_data + ecx + WDATA.box.top] + push [window_data + ecx + WDATA.box.width] ; for loop - width + mov ecx, [window_data + ecx + WDATA.box.left] + sub ebx, edx + sub eax, ecx + push ebx eax ; for loop - x,y - add [ff_xsz], eax - add [ff_ysz], ebx + add [ff_xsz], eax + add [ff_ysz], ebx - mov ebx, [ff_y] + mov ebx, [ff_y] .ff_new_y: - mov edx, [ff_x] + mov edx, [ff_x] .ff_new_x: - ; -- body -- - mov ecx, [ff_scale] - mov eax, [ff_width] - inc eax - shr eax, cl - push ebx edx - shr ebx, cl - shr edx, cl - imul eax, ebx - add eax, edx - pop edx ebx - add eax, edi - call .read_byte - test al,al - jz @f - mov eax, esi - mov [ebp], al - ; -- end body -- - @@: inc ebp - inc edx - cmp edx, [ff_xsz] - jb .ff_new_x + ; -- body -- + mov ecx, [ff_scale] + mov eax, [ff_width] + inc eax + shr eax, cl + push ebx edx + shr ebx, cl + shr edx, cl + imul eax, ebx + add eax, edx + pop edx ebx + add eax, edi + call .read_byte + test al,al + jz @f + mov eax, esi + mov [ebp], al + ; -- end body -- + @@: inc ebp + inc edx + cmp edx, [ff_xsz] + jb .ff_new_x - sub ebp, [ff_xsz] - add ebp, [ff_x] - add ebp, [Screen_Max_X] ; screen.x - inc ebp - inc ebx - cmp ebx, [ff_ysz] - jb .ff_new_y + sub ebp, [ff_xsz] + add ebp, [ff_x] + add ebp, [Screen_Max_X] ; screen.x + inc ebp + inc ebx + cmp ebx, [ff_ysz] + jb .ff_new_y - add esp, 24 + add esp, 24 .exit: - popad - ret + popad + ret .read_byte: - ; eax - address - ; esi - slot - push eax ecx edx esi - xchg eax, esi - lea ecx, [esp + 12] - mov edx, 1 - call read_process_memory - pop esi edx ecx eax - ret + ; eax - address + ; esi - slot + push eax ecx edx esi + xchg eax, esi + lea ecx, [esp + 12] + mov edx, 1 + call read_process_memory + pop esi edx ecx eax + ret align 4 ;------------------------------------------------------------------------------ @@ -1808,67 +1813,67 @@ window._.window_activate: ;//////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;> esi = pointer to WIN_POS+ window data ;------------------------------------------------------------------------------ - push eax ebx + push eax ebx - ; if type of current active window is 3 or 4, it must be redrawn - mov ebx, [TASK_COUNT] - movzx ebx, word[WIN_POS + ebx * 2] - shl ebx, 5 - add eax, window_data - mov al, [window_data + ebx + WDATA.fl_wstyle] - and al, 0x0f - cmp al, 0x03 - je .set_window_redraw_flag - cmp al, 0x04 - jne .move_others_down + ; if type of current active window is 3 or 4, it must be redrawn + mov ebx, [TASK_COUNT] + movzx ebx, word[WIN_POS + ebx * 2] + shl ebx, 5 + add eax, window_data + mov al, [window_data + ebx + WDATA.fl_wstyle] + and al, 0x0f + cmp al, 0x03 + je .set_window_redraw_flag + cmp al, 0x04 + jne .move_others_down .set_window_redraw_flag: - mov [window_data + ebx + WDATA.fl_redraw], 1 + mov [window_data + ebx + WDATA.fl_redraw], 1 .move_others_down: - ; ax <- process no - movzx ebx, word[esi] - ; ax <- position in window stack - movzx ebx, word[WIN_STACK + ebx * 2] + ; ax <- process no + movzx ebx, word[esi] + ; ax <- position in window stack + movzx ebx, word[WIN_STACK + ebx * 2] - ; drop others - xor eax, eax + ; drop others + xor eax, eax .next_stack_window: - cmp eax, [TASK_COUNT] - jae .move_self_up - inc eax - cmp [WIN_STACK + eax * 2], bx - jbe .next_stack_window - dec word[WIN_STACK + eax * 2] - jmp .next_stack_window + cmp eax, [TASK_COUNT] + jae .move_self_up + inc eax + cmp [WIN_STACK + eax * 2], bx + jbe .next_stack_window + dec word[WIN_STACK + eax * 2] + jmp .next_stack_window .move_self_up: - movzx ebx, word[esi] - ; number of processes - mov ax, [TASK_COUNT] - ; this is the last (and the upper) - mov [WIN_STACK + ebx * 2], ax + movzx ebx, word[esi] + ; number of processes + mov ax, [TASK_COUNT] + ; this is the last (and the upper) + mov [WIN_STACK + ebx * 2], ax - ; update on screen - window stack - xor eax, eax + ; update on screen - window stack + xor eax, eax .next_window_pos: - cmp eax, [TASK_COUNT] - jae .reset_vars - inc eax - movzx ebx, word[WIN_STACK + eax * 2] - mov [WIN_POS + ebx * 2], ax - jmp .next_window_pos + cmp eax, [TASK_COUNT] + jae .reset_vars + inc eax + movzx ebx, word[WIN_STACK + eax * 2] + mov [WIN_POS + ebx * 2], ax + jmp .next_window_pos .reset_vars: - mov byte[KEY_COUNT], 0 - mov byte[BTN_COUNT], 0 - mov word[MOUSE_SCROLL_H], 0 - mov word[MOUSE_SCROLL_V], 0 + mov byte[KEY_COUNT], 0 + mov byte[BTN_COUNT], 0 + mov word[MOUSE_SCROLL_H], 0 + mov word[MOUSE_SCROLL_V], 0 - pop ebx eax - ret + pop ebx eax + ret align 4 ;------------------------------------------------------------------------------ @@ -1878,69 +1883,69 @@ window._.check_window_draw: ;////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;> edi = pointer to WDATA ;------------------------------------------------------------------------------ - mov cl, [edi + WDATA.fl_wstyle] - and cl, 0x0f - cmp cl, 3 - je .exit.redraw ; window type 3 - cmp cl, 4 - je .exit.redraw ; window type 4 + mov cl, [edi + WDATA.fl_wstyle] + and cl, 0x0f + cmp cl, 3 + je .exit.redraw ; window type 3 + cmp cl, 4 + je .exit.redraw ; window type 4 - push eax ebx edx esi + push eax ebx edx esi - mov eax, edi - sub eax, window_data - shr eax, 5 + mov eax, edi + sub eax, window_data + shr eax, 5 - movzx eax, word[WIN_STACK + eax * 2] ; get value of the curr process - lea esi, [WIN_POS + eax * 2] ; get address of this process at 0xC400 + movzx eax, word[WIN_STACK + eax * 2] ; get value of the curr process + lea esi, [WIN_POS + eax * 2] ; get address of this process at 0xC400 .next_window: - add esi, 2 + add esi, 2 - mov eax, [TASK_COUNT] - lea eax, word[WIN_POS + eax * 2] ; number of the upper window + mov eax, [TASK_COUNT] + lea eax, word[WIN_POS + eax * 2] ; number of the upper window - cmp esi, eax - ja .exit.no_redraw + cmp esi, eax + ja .exit.no_redraw - movzx edx, word[esi] - shl edx, 5 - cmp [CURRENT_TASK + edx + TASKDATA.state], TSTATE_FREE - je .next_window + movzx edx, word[esi] + shl edx, 5 + cmp [CURRENT_TASK + edx + TASKDATA.state], TSTATE_FREE + je .next_window - mov eax, [edi + WDATA.box.top] - mov ebx, [edi + WDATA.box.height] - add ebx, eax + mov eax, [edi + WDATA.box.top] + mov ebx, [edi + WDATA.box.height] + add ebx, eax - mov ecx, [window_data + edx + WDATA.box.top] - cmp ecx, ebx - jge .next_window - add ecx, [window_data + edx + WDATA.box.height] - cmp eax, ecx - jge .next_window + mov ecx, [window_data + edx + WDATA.box.top] + cmp ecx, ebx + jge .next_window + add ecx, [window_data + edx + WDATA.box.height] + cmp eax, ecx + jge .next_window - mov eax, [edi + WDATA.box.left] - mov ebx, [edi + WDATA.box.width] - add ebx, eax + mov eax, [edi + WDATA.box.left] + mov ebx, [edi + WDATA.box.width] + add ebx, eax - mov ecx, [window_data + edx + WDATA.box.left] - cmp ecx, ebx - jge .next_window - add ecx, [window_data + edx + WDATA.box.width] - cmp eax, ecx - jge .next_window + mov ecx, [window_data + edx + WDATA.box.left] + cmp ecx, ebx + jge .next_window + add ecx, [window_data + edx + WDATA.box.width] + cmp eax, ecx + jge .next_window - pop esi edx ebx eax + pop esi edx ebx eax .exit.redraw: - xor ecx, ecx - inc ecx - ret + xor ecx, ecx + inc ecx + ret .exit.no_redraw: - pop esi edx ebx eax - xor ecx, ecx - ret + pop esi edx ebx eax + xor ecx, ecx + ret align 4 ;------------------------------------------------------------------------------ @@ -1948,121 +1953,121 @@ window._.draw_window_caption: ;//////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ - inc [mouse_pause] - call [_display.disable_mouse] + inc [mouse_pause] + call [_display.disable_mouse] - xor eax, eax - mov edx, [TASK_COUNT] - movzx edx, word[WIN_POS + edx * 2] - cmp edx, [CURRENT_TASK] - jne @f - inc eax - @@: mov edx, [CURRENT_TASK] - shl edx, 5 - add edx, window_data - movzx ebx, [edx + WDATA.fl_wstyle] - and bl, 0x0F - cmp bl, 3 - je .draw_caption_style_3 - cmp bl, 4 - je .draw_caption_style_3 + xor eax, eax + mov edx, [TASK_COUNT] + movzx edx, word[WIN_POS + edx * 2] + cmp edx, [CURRENT_TASK] + jne @f + inc eax + @@: mov edx, [CURRENT_TASK] + shl edx, 5 + add edx, window_data + movzx ebx, [edx + WDATA.fl_wstyle] + and bl, 0x0F + cmp bl, 3 + je .draw_caption_style_3 + cmp bl, 4 + je .draw_caption_style_3 - jmp .not_style_3 + jmp .not_style_3 .draw_caption_style_3: - push edx - call drawwindow_IV_caption - add esp, 4 - jmp .2 + push edx + call drawwindow_IV_caption + add esp, 4 + jmp .2 .not_style_3: - cmp bl, 2 - jne .not_style_2 + cmp bl, 2 + jne .not_style_2 - call drawwindow_III_caption - jmp .2 + call drawwindow_III_caption + jmp .2 .not_style_2: - cmp bl, 0 - jne .2 + cmp bl, 0 + jne .2 - call drawwindow_I_caption + call drawwindow_I_caption - .2: mov edi, [CURRENT_TASK] - shl edi, 5 - test [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION - jz .exit - mov edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption] - or edx, edx - jz .exit + .2: mov edi, [CURRENT_TASK] + shl edi, 5 + test [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION + jz .exit + mov edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption] + or edx, edx + jz .exit - movzx eax, [edi + window_data + WDATA.fl_wstyle] - and al, 0x0F - cmp al, 3 - je .skinned - cmp al, 4 - je .skinned + movzx eax, [edi + window_data + WDATA.fl_wstyle] + and al, 0x0F + cmp al, 3 + je .skinned + cmp al, 4 + je .skinned - jmp .not_skinned + jmp .not_skinned .skinned: - mov ebp, [edi + window_data + WDATA.box.left - 2] - mov bp, word[edi + window_data + WDATA.box.top] - movzx eax, word[edi + window_data + WDATA.box.width] - sub ax, [_skinmargins.left] - sub ax, [_skinmargins.right] - push edx - cwde - cdq - mov ebx, 6 - idiv ebx - pop edx - or eax, eax - js .exit + mov ebp, [edi + window_data + WDATA.box.left - 2] + mov bp, word[edi + window_data + WDATA.box.top] + movzx eax, word[edi + window_data + WDATA.box.width] + sub ax, [_skinmargins.left] + sub ax, [_skinmargins.right] + push edx + cwde + cdq + mov ebx, 6 + idiv ebx + pop edx + or eax, eax + js .exit - mov esi, eax - mov ebx, dword[_skinmargins.left - 2] - mov bx, word[_skinh] - sub bx, [_skinmargins.bottom] - sub bx, [_skinmargins.top] - sar bx, 1 - adc bx, 0 - add bx, [_skinmargins.top] - add bx, -3 - add ebx, ebp - jmp .dodraw + mov esi, eax + mov ebx, dword[_skinmargins.left - 2] + mov bx, word[_skinh] + sub bx, [_skinmargins.bottom] + sub bx, [_skinmargins.top] + sar bx, 1 + adc bx, 0 + add bx, [_skinmargins.top] + add bx, -3 + add ebx, ebp + jmp .dodraw .not_skinned: - cmp al, 1 - je .exit + cmp al, 1 + je .exit - mov ebp, [edi + window_data + WDATA.box.left - 2] - mov bp, word[edi + window_data + WDATA.box.top] - movzx eax, word[edi + window_data + WDATA.box.width] - sub eax, 16 - push edx - cwde - cdq - mov ebx, 6 - idiv ebx - pop edx - or eax, eax - js .exit + mov ebp, [edi + window_data + WDATA.box.left - 2] + mov bp, word[edi + window_data + WDATA.box.top] + movzx eax, word[edi + window_data + WDATA.box.width] + sub eax, 16 + push edx + cwde + cdq + mov ebx, 6 + idiv ebx + pop edx + or eax, eax + js .exit - mov esi, eax - mov ebx, 0x00080007 - add ebx, ebp + mov esi, eax + mov ebx, 0x00080007 + add ebx, ebp .dodraw: - mov ecx, [common_colours + 16] - or ecx, 0x80000000 - xor edi, edi - call dtext_asciiz_esi + mov ecx, [common_colours + 16] + or ecx, 0x80000000 + xor edi, edi + call dtext_asciiz_esi .exit: - dec [mouse_pause] - call [draw_pointer] - ret + dec [mouse_pause] + call [draw_pointer] + ret align 4 ;------------------------------------------------------------------------------ @@ -2072,17 +2077,17 @@ window._.draw_negative_box: ;////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;> edi = pointer to BOX struct ;------------------------------------------------------------------------------ - push eax ebx esi - mov eax, [edi + BOX.left - 2] - mov ax, word[edi + BOX.left] - add ax, word[edi + BOX.width] - mov ebx, [edi + BOX.top - 2] - mov bx, word[edi + BOX.top] - add bx, word[edi + BOX.height] - mov esi, 0x01000000 - call draw_rectangle.forced - pop esi ebx eax - ret + push eax ebx esi + mov eax, [edi + BOX.left - 2] + mov ax, word[edi + BOX.left] + add ax, word[edi + BOX.width] + mov ebx, [edi + BOX.top - 2] + mov bx, word[edi + BOX.top] + add bx, word[edi + BOX.height] + mov esi, 0x01000000 + call draw_rectangle.forced + pop esi ebx eax + ret diff16 "window code end",0,$ -diff16 "window.inc size",syscall_draw_window,$ +diff10 "window.inc size",syscall_draw_window,$ diff --git a/kernel/branches/Kolibri-A/trunk/hid/mousedrv.inc b/kernel/branches/Kolibri-A/trunk/hid/mousedrv.inc index e80d5410f1..83f62ffad4 100644 --- a/kernel/branches/Kolibri-A/trunk/hid/mousedrv.inc +++ b/kernel/branches/Kolibri-A/trunk/hid/mousedrv.inc @@ -35,19 +35,6 @@ endg ;include 'm_com.inc' -;test_mario79: -; push esi -; push eax -; mov [write_error_to],process_test_m79+43 -; movzx eax,al ;[DevErrorCode] -; call writehex -; mov esi,process_test_m79 -; call sys_msg_board_str -; pop eax -; pop esi -; ret -;process_test_m79 db 'K : Process - test Mario79 error 00000000',13,10,0 - draw_mouse_under: ; return old picture @@ -108,12 +95,15 @@ save_draw_mouse: movzx ebx,word [MOUSE_X] push eax push ebx - - mov ecx, [Screen_Max_X] - inc ecx - mul ecx - add eax, [_WinMapAddress] - movzx edx, byte [ebx+eax] + + mov ecx, ebx ; <<<< + shr ecx, 1 + imul ecx, [_WinMapWidth] + shr eax, 1 + shr eax, 1 + add eax, ecx + add eax, [_WinMapAddress] + movzx edx, byte [ebx+eax] shl edx, 8 mov esi, [edx+SLOT_BASE+APPDATA.cursor] @@ -286,11 +276,13 @@ __sys_disable_mouse: add edx,window_data movzx eax, word [MOUSE_X] movzx ebx, word [MOUSE_Y] - mov ecx,[Screen_Max_X] - inc ecx - imul ecx,ebx - add ecx,eax - add ecx, [_WinMapAddress] + mov ecx, ebx ; <<<< + shr ecx, 1 + imul ecx, [_WinMapWidth] + shr eax, 1 + shr eax, 1 + add ecx, eax + add ecx, [_WinMapAddress] mov eax, [CURRENT_TASK] movzx ebx, byte [ecx] cmp eax,ebx @@ -454,3 +446,5 @@ mouse_acceleration: @@: ret +diff16 "window code end",0,$ +diff10 "mousedrv size ",draw_mouse_under,$ diff --git a/kernel/branches/Kolibri-A/trunk/kernel.asm b/kernel/branches/Kolibri-A/trunk/kernel.asm index b6ef93b188..4016b895d8 100644 --- a/kernel/branches/Kolibri-A/trunk/kernel.asm +++ b/kernel/branches/Kolibri-A/trunk/kernel.asm @@ -320,11 +320,9 @@ high_code: mov eax, [BOOT_VAR + 0x9044] ; version & flags mov [apm_vf], eax ; ----------------------------------------- -; movzx eax,byte [BOOT_VAR+0x9010] ; mouse port -; mov [0xF604],byte 1 ;al mov al, [BOOT_VAR+0x901F] ; DMA access mov [allow_dma_access], al - movzx eax, byte [BOOT_VAR+0x9000] ; bpp + mov eax, 32 ; <<<<<<<<< bpp mov [ScreenBPP],al mov [_display.bpp], eax @@ -336,27 +334,26 @@ high_code: dec eax mov [Screen_Max_X],eax mov [screen_workarea.right],eax - movzx eax,word [BOOT_VAR+0x900C] ; Y max - mov [_display.height], eax + inc eax + shr eax, 2 + mov [_WinMapWidth], eax ; 1 tyle = 4 pixels + movzx eax,word [BOOT_VAR+0x900C] ; Y max + mov [_display.height], eax dec eax mov [Screen_Max_Y],eax mov [screen_workarea.bottom],eax - movzx eax,word [BOOT_VAR+0x9008] ; screen mode + movzx eax,word [BOOT_VAR+0x9008] ; screen mode mov [SCR_MODE],eax - mov eax,[BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add + mov eax,[BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add mov [BANK_SWITCH],eax - mov [BytesPerScanLine],word 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_VAR+0x9001] ; for other modes + movzx eax, word[BOOT_VAR+0x9001] ; for other modes mov [BytesPerScanLine],ax - mov [_display.pitch], eax + mov [_display.pitch], eax @@: - mov eax, [_display.width] - mul [_display.height] - mov [_WinMapSize], eax + mov eax, [_display.height] + shr eax, 1 + mul [_WinMapWidth] + mov [_WinMapSize], eax mov esi, BOOT_VAR+0x9080 movzx ecx, byte [esi-1] @@ -500,10 +497,10 @@ v20ga32: mov [graph_data_l+4],al mov [graph_data_l+7],ah - or [KERNEL_ALLOC_FLAG], dword PG_NOCACHE +; or [KERNEL_ALLOC_FLAG], dword PG_NOCACHE stdcall kernel_alloc, [_WinMapSize] mov [_WinMapAddress], eax - xor [KERNEL_ALLOC_FLAG], dword PG_NOCACHE +; xor [KERNEL_ALLOC_FLAG], dword PG_NOCACHE xor eax,eax inc eax @@ -606,6 +603,17 @@ end if mov esi, boot_memdetect call boot_log +; <<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>> + mov ebx, img_test_struct + mov ecx, 3*65536 + 4 + mov edx, 32*65536 + 512 + mov esi, 32 + xor edi, edi + mov ebp, edi + call sys_putimage_palette.forced + +;<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> + movzx ecx, word [boot_y] or ecx, (10+29*6) shl 16 ; "Determining amount of memory" sub ecx, 10 @@ -2241,6 +2249,7 @@ draw_background_temp: ; je nosb31 ;draw_background_temp: ; mov [bgrchanged],1 ;0 + mov [background_defined], 1 mov byte[BACKGROUND_CHANGED], 1 call force_redraw_background @@ -2838,23 +2847,24 @@ ret ; check if pixel is allowed to be drawn +; -- not in use any more ? -checkpixel: - push eax edx - - mov edx,[Screen_Max_X] ; screen x size - inc edx - imul edx, ebx - add eax, [_WinMapAddress] - mov dl, [eax+edx] ; lea eax, [...] - - xor ecx, ecx - mov eax, [CURRENT_TASK] - cmp al, dl - setne cl - - pop edx eax - ret +;checkpixel: +; push eax ebx edx +; shr ebx, 1 +; mov edx, [_WinMapWidth] ; <<<< +; imul edx, ebx +; shr eax, 2 +; add eax, [_WinMapAddress] +; mov dl, [eax+edx] +; +; xor ecx, ecx +; mov eax, [CURRENT_TASK] +; cmp al, dl +; setne cl +; +; pop edx ebx eax +; ret iglobal cpustring db 'CPU',0 @@ -2903,12 +2913,6 @@ no_set_bgr_event: jz nobackgr cmp [background_defined], 0 jz nobackgr -; mov [draw_data+32 + RECT.left],dword 0 -; mov [draw_data+32 + RECT.top],dword 0 -; mov eax,[Screen_Max_X] -; mov ebx,[Screen_Max_Y] -; mov [draw_data+32 + RECT.right],eax -; mov [draw_data+32 + RECT.bottom],ebx @@: call drawbackground xor eax, eax @@ -2950,8 +2954,6 @@ markz: je system_shutdown noshutdown: - - mov eax,[TASK_COUNT] ; termination mov ebx,TASK_DATA+TASKDATA.state mov esi,1 @@ -2970,19 +2972,13 @@ newct: ret ; redraw screen - -redrawscreen: - ; eax , if process window_data base is eax, do not set flag/limits +redrawscreen: pushad push eax -;;; mov ebx,2 -;;; call delay_hs - - ;mov ecx,0 ; redraw flags for apps - xor ecx,ecx + xor ecx,ecx ; redraw flags for apps newdw2: inc ecx @@ -3034,8 +3030,6 @@ redrawscreen: cmp dword[esp], 1 jnz .az -; cmp byte[BACKGROUND_CHANGED], 0 -; jnz newdw8 cmp byte[REDRAW_BACKGROUND], 0 jz .az mov dl, 0 @@ -3086,6 +3080,7 @@ redrawscreen: jne nobgrd inc byte[REDRAW_BACKGROUND] + newdw8: nobgrd: @@ -3106,7 +3101,6 @@ redrawscreen: ret calculatebackground: ; background - mov edi, [_WinMapAddress] ; set os to use all pixels mov eax,0x01010101 mov ecx, [_WinMapSize] @@ -3122,11 +3116,7 @@ uglobal imax dd 0x0 endg - - delay_ms: ; delay in 1/1000 sec - - push eax push ecx @@ -3154,7 +3144,6 @@ delay_ms: ; delay in 1/1000 sec ret - set_app_param: mov edi, [TASK_BASE] mov eax, [edi + TASKDATA.event_mask] @@ -3162,8 +3151,6 @@ set_app_param: mov [esp+32], eax ret - - delay_hs: ; delay in 1/100 secs ; ebx = delay time push ecx @@ -3189,7 +3176,6 @@ delay_hs: ; delay in 1/100 secs align 16 ;very often call this subrutine memmove: ; memory move in bytes - ; eax = from ; ebx = to ; ecx = no of bytes @@ -3219,54 +3205,6 @@ memmove: ; memory move in bytes ret -; Sysfunction 34, read_floppy_file, is obsolete. Use 58 or 70 function instead. -;align 4 -; -;read_floppy_file: -; -;; as input -;; -;; eax pointer to file -;; ebx file lenght -;; ecx start 512 byte block number -;; edx number of blocks to read -;; esi pointer to return/work area (atleast 20 000 bytes) -;; -;; -;; on return -;; -;; eax = 0 command succesful -;; 1 no fd base and/or partition defined -;; 2 yet unsupported FS -;; 3 unknown FS -;; 4 partition not defined at hd -;; 5 file not found -;; ebx = size of file -; -; mov edi,[TASK_BASE] -; add edi,0x10 -; add esi,[edi] -; add eax,[edi] -; -; pushad -; mov edi,esi -; add edi,1024 -; mov esi,0x100000+19*512 -; sub ecx,1 -; shl ecx,9 -; add esi,ecx -; shl edx,9 -; mov ecx,edx -; cld -; rep movsb -; popad -; -; mov [esp+36],eax -; mov [esp+24],ebx -; ret - - - align 4 sys_programirq: @@ -3294,7 +3232,6 @@ r_f_port_area: reserve_free_irq: - xor esi, esi inc esi cmp ecx, 16 @@ -3317,7 +3254,6 @@ reserve_free_irq: jmp ril1 reserve_irq: - cmp dword [ecx], 0 jne ril1 @@ -3355,76 +3291,65 @@ endg drawbackground: inc [mouse_pause] - cmp [SCR_MODE],word 0x12 - je dbrv20 - dbrv12: - cmp [SCR_MODE],word 0100000000000000b - jge dbrv20 -; cmp [SCR_MODE],word 0x13 -; je dbrv20 -; call vesa12_drawbackground - dec [mouse_pause] - call [draw_pointer] - ret - dbrv20: - cmp [BgrDrawMode],dword 1 - jne bgrstr - call vesa20_drawbackground_tiled - dec [mouse_pause] - call [draw_pointer] - ret - bgrstr: - call vesa20_drawbackground_stretch +; cmp [BgrDrawMode],dword 1 +; jne bgrstr +; call vesa20_drawbackground_tiled + call drawbackground dec [mouse_pause] call [draw_pointer] ret +; bgrstr: +; call vesa20_drawbackground_stretch +; dec [mouse_pause] +; call [draw_pointer] +; ret +; ==================================================================== align 4 - -syscall_putimage: ; PutImage +syscall_putimage: ; PutImage = SysFn07 sys_putimage: - test ecx,0x80008000 - jnz .exit - test ecx,0x0000FFFF + test ecx,0x80008000 ; ecx = { SizeX | SizeY } + jnz .exit ; edx = { OrigX | OrigY } + test ecx,0x0000FFFF ; ebx points to the 24bpp-image jz .exit test ecx,0xFFFF0000 jnz @f .exit: ret @@: + push edi mov edi,[current_slot] add dx,word[edi+APPDATA.wnd_clientbox.top] rol edx,16 add dx,word[edi+APPDATA.wnd_clientbox.left] + pop edi rol edx,16 - .forced: - push ebp esi 0 - mov ebp, putimage_get24bpp - mov esi, putimage_init24bpp -sys_putimage_bpp: -; cmp [SCR_MODE], word 0x12 -; jz @f ;.doit -; mov eax, vesa12_putimage -; cmp [SCR_MODE], word 0100000000000000b -; jae @f -; cmp [SCR_MODE], word 0x13 -; jnz .doit -;@@: - mov eax, vesa20_putimage -.doit: + .forced: ; called from gui/skincode.inc [215] + push esi + mov esi, ecx + shr esi, 16 ; SizeX + lea esi, [esi*2+esi] ; 3 bytes per pixel + mov [img_buf_line_size], esi + mov [img_draw_core_fn], draw_core_24bpp + mov [img_draw_edge_fn], draw_edge_24bpp + mov [img_bytes_per_pix], 3 + pop esi + +sys_putimage_bpp: ; only called from sys_putimage_palette inc [mouse_pause] - call eax + call _putimage dec [mouse_pause] - pop ebp esi ebp jmp [draw_pointer] + + align 4 -sys_putimage_palette: +sys_putimage_palette: ; sysFn 65 ; ebx = pointer to image ; ecx = [xsize]*65536 + [ysize] ; edx = [xstart]*65536 + [ystart] -; esi = number of bits per pixel, must be 8, 24 or 32 +; esi = number of bits per pixel, must be 1, 8, 24 or 32 ; edi = pointer to palette -; ebp = row delta +; ebp = line offset mov eax, [CURRENT_TASK] shl eax, 8 add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] @@ -3432,257 +3357,52 @@ sys_putimage_palette: add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] rol edx, 16 .forced: - cmp esi, 1 - jnz @f - push edi - mov eax, [edi+4] - sub eax, [edi] - push eax - push dword [edi] - push 0ffffff80h - mov edi, esp - call put_mono_image - add esp, 12 - pop edi - ret -@@: - cmp esi, 2 - jnz @f - push edi - push 0ffffff80h - mov edi, esp - call put_2bit_image - pop eax - pop edi - ret -@@: - cmp esi, 4 - jnz @f - push edi - push 0ffffff80h - mov edi, esp - call put_4bit_image - pop eax - pop edi - ret -@@: - push ebp esi ebp - cmp esi, 8 - jnz @f - mov ebp, putimage_get8bpp - mov esi, putimage_init8bpp - jmp sys_putimage_bpp -@@: - cmp esi, 15 - jnz @f - mov ebp, putimage_get15bpp - mov esi, putimage_init15bpp - jmp sys_putimage_bpp -@@: - cmp esi, 16 - jnz @f - mov ebp, putimage_get16bpp - mov esi, putimage_init16bpp - jmp sys_putimage_bpp -@@: - cmp esi, 24 - jnz @f - mov ebp, putimage_get24bpp - mov esi, putimage_init24bpp - jmp sys_putimage_bpp -@@: - cmp esi, 32 - jnz @f - mov ebp, putimage_get32bpp - mov esi, putimage_init32bpp - jmp sys_putimage_bpp -@@: - pop ebp esi ebp - ret + mov [img_palette], edi + mov eax, esi + cmp eax, 32 ;>32bpp (stupid call) + ja .exit + shr al, 3 ; 0=1bpp, other lo-pix modes not supported + push esi + mov [img_bytes_per_pix], eax + mov esi, [eax*4 + img_core_proc_0] + mov [img_draw_core_fn], esi + mov esi, [eax*4 + img_edge_proc_0] + mov [img_draw_edge_fn], esi + mov esi, ecx + shr esi, 16 ; esi = SizeX + or al, al + jz .1bpp + imul esi, eax + jmp .done +.1bpp: + add esi, 7 + shr esi, 3 ; 8 pixels per byte +.done: + add esi, ebp ; + line offset + mov [img_buf_line_size], esi + pop esi + jmp _putimage ;<<< sys_putimage_bpp +.exit: + ret -put_mono_image: - push ebp esi ebp - mov ebp, putimage_get1bpp - mov esi, putimage_init1bpp - jmp sys_putimage_bpp -put_2bit_image: - push ebp esi ebp - mov ebp, putimage_get2bpp - mov esi, putimage_init2bpp - jmp sys_putimage_bpp -put_4bit_image: - push ebp esi ebp - mov ebp, putimage_get4bpp - mov esi, putimage_init4bpp - jmp sys_putimage_bpp +align 4 +img_core_proc_0 dd draw_core_1bpp +img_core_proc_1 dd draw_core_8bpp +img_core_proc_2 dd draw_core_16bpp +img_core_proc_3 dd draw_core_24bpp +img_core_proc_4 dd draw_core_32bpp -putimage_init24bpp: - lea eax, [eax*3] -putimage_init8bpp: - ret - -align 16 -putimage_get24bpp: - movzx eax, byte [esi+2] - shl eax, 16 - mov ax, [esi] - add esi, 3 - ret 4 -align 16 -putimage_get8bpp: - movzx eax, byte [esi] - push edx - mov edx, [esp+8] - mov eax, [edx+eax*4] - pop edx - inc esi - ret 4 - -putimage_init1bpp: - add eax, ecx - push ecx - add eax, 7 - add ecx, 7 - shr eax, 3 - shr ecx, 3 - sub eax, ecx - pop ecx - ret -align 16 -putimage_get1bpp: - push edx - mov edx, [esp+8] - mov al, [edx] - add al, al - jnz @f - lodsb - adc al, al -@@: - mov [edx], al - sbb eax, eax - and eax, [edx+8] - add eax, [edx+4] - pop edx - ret 4 - -putimage_init2bpp: - add eax, ecx - push ecx - add ecx, 3 - add eax, 3 - shr ecx, 2 - shr eax, 2 - sub eax, ecx - pop ecx - ret -align 16 -putimage_get2bpp: - push edx - mov edx, [esp+8] - mov al, [edx] - mov ah, al - shr al, 6 - shl ah, 2 - jnz .nonewbyte - lodsb - mov ah, al - shr al, 6 - shl ah, 2 - add ah, 1 -.nonewbyte: - mov [edx], ah - mov edx, [edx+4] - movzx eax, al - mov eax, [edx+eax*4] - pop edx - ret 4 - -putimage_init4bpp: - add eax, ecx - push ecx - add ecx, 1 - add eax, 1 - shr ecx, 1 - shr eax, 1 - sub eax, ecx - pop ecx - ret -align 16 -putimage_get4bpp: - push edx - mov edx, [esp+8] - add byte [edx], 80h - jc @f - movzx eax, byte [edx+1] - mov edx, [edx+4] - and eax, 0x0F - mov eax, [edx+eax*4] - pop edx - ret 4 -@@: - movzx eax, byte [esi] - add esi, 1 - mov [edx+1], al - shr eax, 4 - mov edx, [edx+4] - mov eax, [edx+eax*4] - pop edx - ret 4 - -putimage_init32bpp: - shl eax, 2 - ret -align 16 -putimage_get32bpp: - lodsd - ret 4 - -putimage_init15bpp: -putimage_init16bpp: - add eax, eax - ret -align 16 -putimage_get15bpp: -; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 - push ecx edx - movzx eax, word [esi] - add esi, 2 - mov ecx, eax - mov edx, eax - and eax, 0x1F - and ecx, 0x1F shl 5 - and edx, 0x1F shl 10 - shl eax, 3 - shl ecx, 6 - shl edx, 9 - or eax, ecx - or eax, edx - pop edx ecx - ret 4 - -align 16 -putimage_get16bpp: -; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 - push ecx edx - movzx eax, word [esi] - add esi, 2 - mov ecx, eax - mov edx, eax - and eax, 0x1F - and ecx, 0x3F shl 5 - and edx, 0x1F shl 11 - shl eax, 3 - shl ecx, 5 - shl edx, 8 - or eax, ecx - or eax, edx - pop edx ecx - ret 4 +img_edge_proc_0 dd draw_edge_1bpp +img_edge_proc_1 dd draw_edge_8bpp +img_edge_proc_2 dd draw_edge_16bpp +img_edge_proc_3 dd draw_edge_24bpp +img_edge_proc_4 dd draw_edge_32bpp +; ================================================== ; eax x beginning ; ebx y beginning ; ecx x end - ; edx y end +; edx y end ; edi color __sys_drawbar: @@ -3693,28 +3413,13 @@ __sys_drawbar: add edx,[esi+APPDATA.wnd_clientbox.top] .forced: inc [mouse_pause] -; call [disable_mouse] - cmp [SCR_MODE],word 0x12 - je dbv20 - sdbv20: -; cmp [SCR_MODE],word 0100000000000000b -; jge dbv20 -; cmp [SCR_MODE],word 0x13 -; je dbv20 -; call vesa12_drawbar -; dec [mouse_pause] -; call [draw_pointer] -; ret - dbv20: +; dbv20: call vesa20_drawbar dec [mouse_pause] - call [draw_pointer] - ret - + jmp [draw_pointer] kb_read: - push ecx edx mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's @@ -3745,15 +3450,6 @@ kb_write: push ecx edx mov dl,al -; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's -; kw_loop1: -; in al,0x64 -; test al,0x20 -; jz kw_ok1 -; loop kw_loop1 -; mov ah,1 -; jmp kw_exit -; kw_ok1: in al,0x60 mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's kw_loop: @@ -4491,7 +4187,12 @@ set_screen: stdcall kernel_free, [_WinMapAddress] mov eax, [_display.width] - mul [_display.height] + shr eax, 1 + shr eax, 1 + mov [_WinMapWidth], eax + mov eax, [_display.height] + shr eax, 1 + mul [_WinMapWidth] mov [_WinMapSize], eax stdcall kernel_alloc, eax diff --git a/kernel/branches/Kolibri-A/trunk/kernel32.inc b/kernel/branches/Kolibri-A/trunk/kernel32.inc index 5d38c531d1..a8f14b9384 100644 --- a/kernel/branches/Kolibri-A/trunk/kernel32.inc +++ b/kernel/branches/Kolibri-A/trunk/kernel32.inc @@ -224,10 +224,8 @@ include "sound/playnote.inc" ; player Note for Speaker PC ; display -;include "video/vesa12.inc" ; Vesa 1.2 functions -include "video/vesa20.inc" ; Vesa 2.0 functions -;include "video/vga.inc" ; VGA 16 color functions -include "video/cursors.inc" ; cursors functions +include "video/graph32.inc" ; 32bpp graphics +include "video/cursors.inc" ; cursors functions ; Network Interface & TCPIP Stack diff --git a/kernel/branches/Kolibri-A/trunk/video/graph32.inc b/kernel/branches/Kolibri-A/trunk/video/graph32.inc new file mode 100644 index 0000000000..d54d243ca7 --- /dev/null +++ b/kernel/branches/Kolibri-A/trunk/video/graph32.inc @@ -0,0 +1,1237 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;; GRAPH32.INC ;; +;; ;; +;; 32bpp graph engine for Kolibri-A ;; +;; ;; +;; art_zh (kolibri@jerdev.co.uk) Dec. 2010 : ;; +;; - 4x2 granularity & tiled winmap structure ;; +;; - speed-optimized line/box graphics ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +$Revision: 1708 $ + + +;************************************************* +; getpixel +; +; in: +; eax = x coordinate +; ebx = y coordinate +; +; ret: +; ecx = 00 RR GG BB + + +get_pixel: + mov ecx, [BytesPerScanLine] + imul ecx, ebx + lea ecx, [ecx+eax*4] ; ecx = x*4+(y*y multiplier) + mov ecx, [ecx+LFB_BASE] + and ecx, 0xffffff + ret + +;----------------------------------------------------------------------------------- +; esi : Buffer origin +; edi : Screen origin +; ebp : Map origin +; ecx : block height (pix) +; ebx : bit[24] = odd line; bh = temp; bl = current task + +align 4 +draw_aligned_box: + pushad + xor edx, edx +.new_line: + btr ebx, 26 + mov eax, [img_map_x] + xor ecx, ecx + cmp bl, byte[ebp] ; check the left tile first + jz .new_tile + bts ebx, 26 ; ebx[26] = 1 if edi/esi already pushed + jc .seek_visible + push edi + push esi + jmp .seek_visible +.new_tile: + inc ecx ; visible - scan the open space + cmp ecx, eax + jz .end_of_line + cmp bl, byte[ebp+ecx] ; overlapped? draw the visible segment if so + je .new_tile + + call [img_draw_core_fn] ; bpp-specific helper (see below) + +.seek_visible: + inc ecx + cmp ecx, eax + je .next_line + cmp bl, byte[ebp+ecx] + jne .seek_visible +.got_visible: + sub eax, ecx + shl ecx, 4 + add edi, ecx ; shift the left edge + shr ecx, 2 + imul ecx, [img_bytes_per_pix] + add esi, ecx + xor ecx, ecx + jmp .new_tile + +.end_of_line: + call [img_draw_core_fn] + +.next_line: + bt ebx, 26 + jnc @f + pop esi + pop edi +@@: inc edx + cmp edx, [esp+24] ; stacked ecx = image height + je .finish + add edi, [BytesPerScanLine] + add esi, [img_buf_line_size] + btc ebx, 24 ; odd line? + jnc .new_line + add ebp, [_WinMapWidth] + jmp .new_line + +.finish: + popad + ret + +;-------------------------------- +; ebx : bit[24] = odd line; bh = reserved; bl = current task +; ecx : column height (pix) +; edx : max tile offset: 0, 4, 8, or 12 bytes (1,2,3 or 4 pix to draw) +; ebp : map origin +; esi : buffer image origin +; edi : LFB-origin (4byte-aligned) + +align 4 +draw_unaligned_edge: + pushad + mov eax, [img_buf_line_size] + mov bh, dl ; store the 1st tile offset + bt ebx, 24 ; check if the 1st line odd + jnc .new_tile + cmp bl, byte[ebp] + jne @f + call [img_draw_edge_fn] ; bpp-specific helper (see below) +@@: + dec ecx + jz .exit + add edi, [BytesPerScanLine] + add ebp, [_WinMapWidth] + add esi, eax + btr ebx, 24 +.new_tile: + cmp bl, byte[ebp] + jne .skip_tile + call [img_draw_edge_fn] + dec ecx + jz .exit + add edi, [BytesPerScanLine] + add esi, eax + call [img_draw_edge_fn] + dec ecx + jz .exit + add edi, [BytesPerScanLine] + add ebp, [_WinMapWidth] + add esi, eax + jmp .new_tile +.skip_tile: + sub cx, 2 + jbe .exit + add edi, [BytesPerScanLine] + add edi, [BytesPerScanLine] + add esi, eax + add esi, eax + add ebp, [_WinMapWidth] + jmp .new_tile +.exit: + popad + ret + + + +;------------- +; unaligned edge helpers +; esi -> left point of the image edge +; edi -> left point of the screen edge +; bh = edx = tile offset (0, 4, 8 or 12 bytes) + +align 4 +draw_edge_32bpp: + push eax +.putpix: + mov eax, [esi+edx] + mov [edi+edx], eax + sub dl, 4 + jae .putpix +.exit: + mov dl, bh + pop eax + ret +align 4 +draw_edge_24bpp: + push eax esi + xor dl, dl +.putpix: + mov eax, [esi] + and eax, 0x00FFFFFF + mov [edi+edx], eax + test dl, bh + jz .exit + add dl, 4 + add esi, 3 + jmp .putpix +.exit: + pop esi eax + ret +align 4 +draw_edge_8bpp: + push eax esi ebp + xor dl, dl + mov ebp, [img_palette] +.putpix: + movzx eax, byte[esi] + mov eax, [ebp+eax*4] + mov [edi+edx], eax + test dl, bh + jz .exit + add dl, 4 + inc esi + jmp .putpix +.exit: + pop ebp esi eax + ret +align 4 +draw_edge_1bpp: + push eax ecx ebx ebp + mov ebp, [img_palette] + mov ebx, [ebp+4] ; forecolor + mov ebp, [ebp] ; backcolor + mov ecx, [img_edgeoffset] ; cl = 1 << left_edge_pix_num + mov ebp, [esi] + xor dl, dl +.testbit: + test ebp, ecx + jnz @f + mov eax, ebp + jmp .putpix +@@: mov eax, ebx +.putpix: + mov [edi+edx], eax + test dl, bh + jz .exit + add dl, 4 + shl ecx, 1 + jmp .testbit +.exit: + pop ebp ebx ecx eax + ret + +draw_edge_16bpp: +draw_core_16bpp: + ret + +;------------- +; aligned core helpers +; esi -> left point address (image) +; edi -> left point address (screen) +; cx = number of tiles to draw +align 4 +draw_core_32bpp: + push ecx + shl ecx, 1 + dec ecx +.putpix: + fld qword[esi+ecx*8] ; 2 qwords = 1 tile + fstp qword[edi+ecx*8] + dec cx + jnb .putpix + pop ecx + ret +align 4 +draw_core_24bpp: + push eax ecx + shl ecx, 2 + dec ecx + lea eax, [ecx*2+ecx] +.putpix: + mov eax, [esi+eax] + and eax, 0x00FFFFFF + mov [edi+ecx*4], eax + sub dx, 3 + dec cx + jnb .putpix + pop ecx eax + ret +align 4 +draw_core_8bpp: + pushad + mov ebp, [img_palette] +.putpix: + xor edx, edx + mov eax, dword[esi] ; block of 4 pixels +.putone: + movzx ebx, al + mov ebx, [ebp+ebx*4] + mov [edi+edx*4], ebx + shr eax, 8 + inc dl + cmp dl, 4 + jnz .putone + add esi, edx ;-) + add edi, 16 + dec cx + jnz .putpix +.exit: + popad + ret +align 4 +draw_core_1bpp: + pushad + mov ebp, [img_palette] + mov edx, [ebp+4] ; foreground color + mov ebp, [ebp] ; background color + mov ebx, [img_bitoffset] + shl ecx, 2 ; 1 tyle = 4 pix + dec ecx + jb .exit +.newblock: + mov eax, [esi] +.putpix: + test ebx, eax + jz .bkcolor + mov [edi], edx + jmp .nextpix +.bkcolor: + mov [edi], ebp +.nextpix: + dec cx + jb .exit + rol ebx, 1 + jc .nextblock + add edi, 4 + jmp .putpix +.nextblock: + add esi, 4 + jmp .newblock +.exit: + popad + ret + +;----------------------------------------- +virtual at esp + putimg: + .image_sx dd ? ; X-size (pix) + .image_sy dd ? ; Y-size + .stack_data = 2*4 +end virtual + +align 4 +; ebx -> Buffer origin +; ecx = packed size [x|y] +; edx = packed coordinates [x|y] + +_putimage: +; call [_display.disable_mouse] + pushad + sub esp, putimg.stack_data + mov [img_buf_origin], ebx ; save pointer to image buffer + mov esi, ebx ; pointer to image +.unpack_coords: + mov eax, ecx + and ecx, 0xFFFF ; Ysize + shr eax, 16 ; Xsize + mov [putimg.image_sy], ecx + mov [putimg.image_sx], eax + mov eax, edx + and edx, 0xFFFF ; Ytop + shr eax, 16 ; Xleft +.calculate_abs_coords: + mov ebx, [TASK_BASE-twdw + WDATA.box.left] + mov ecx, [TASK_BASE-twdw + WDATA.box.top] + add ebx, eax + add ecx, edx + mov [img_screen_x], ebx ; abs Xleft +; mov [img_screen_y], ecx ; ecx = abs Ytop ; hold it ! +.check_x_size: + mov ebx, [TASK_BASE-twdw + WDATA.box.width] + inc ebx ; ebx = window Xsize + sub ebx, eax ; eax = rel Xleft + jbe .finish ; image is out of the window + mov eax, [putimg.image_sx] + cmp ebx, eax ; real_sx = MIN(wnd_sx-image_cx, image_sx); + jae @f + mov eax, ebx +@@: dec eax + mov [img_pix_x], eax +.check_y_size: + mov ebx, [TASK_BASE-twdw + WDATA.box.height] + inc ebx ; ebx = real window y-size + sub ebx, edx ; edx = rel Ytop + jbe .finish ; image isn't visible + mov edx, [putimg.image_sy] + cmp ebx, edx + jae @f + mov edx, ebx +@@: mov [img_pix_y], edx + +.calculate_lfb_origin: + mov edi, ecx ; ecx = absY + imul edi, [BytesPerScanLine] + mov eax, [img_screen_x] ; eax = absX + lea edi, [edi+eax*4] + add edi, LFB_BASE ; edi -> Screen origin + mov [img_lfb_origin], edi +.calculate_map_origin: + xor ebx, ebx + mov bl, byte [img_bytes_per_pix] + or bl, bl + jnz @f + bts ebx, 25 +@@: mov bl, byte [CURRENT_TASK] ; get process number + mov ebp, ecx ; ecx = absY + shr ebp, 1 ; CF= odd line + jnc @f + bts ebx, 24 ; ebx[24] = odd start line +@@: imul ebp, [_WinMapWidth] + add ebp, [_WinMapAddress] + mov ecx, eax ; eax = absX + shr ecx, 2 + add eax, [img_pix_x] + shr eax, 2 + add eax, ebp + mov [img_map_right], eax ; right edge tile + add ebp, ecx ; left edge Map origin + mov ecx, [img_pix_y] + sub eax, ebp + jz .thin_bar ; special case: all image is 1 tile thick + mov [img_map_x], eax ; tiles in row (excluding the right one) + +; ----- at this point: +; esi = [img_buf_origin] -> buffered image +; edi = [img_lfb_origin] -> LFB image (corner point, 0RGB format) +; ebp -> corner tile position +; ecx = [img_pix_y] = image height +; bl = task # +; ebx[24] = 1 if the core Y is odd +; ebx[25] = 1bpp image + +.start: + bt ebx, 25 + jnc @f + xor eax, eax + inc al + mov [img_bitoffset], eax ; 1bpp image must be byte-aligned + mov [img_edgeoffset], eax +@@: + mov edx, edi + and edx, 0x0C + jz .go_right ; left edge already aligned +.left_edge: + mov dh, 0x0C + sub dh, dl + movzx edx, dh + call draw_unaligned_edge + dec [img_map_x] + shr edi, 4 + inc edi ; align edi to the next 16-byte tile + shl edi, 4 + mov [img_lfb_origin], edi ; core Screen origin + shr edx, 2 + inc edx + sub [img_pix_x], edx ; shrink image width + bt ebx, 25 + jnc @f + xchg dl, cl + mov eax, [img_edgeoffset] ; that's for 1bpp images only + shl eax, cl + mov [img_edgeoffset], eax + mov [img_bitoffset], eax + xchg dl, cl +@@: mov eax, edx + imul eax, [img_bytes_per_pix] ; 0 for 1bbp bitmaps + add esi, eax + mov [img_buf_origin], esi ; core Buffer origin + inc ebp ; core Map origin +.go_right: + mov eax, [img_map_x] + mov edx, eax + bt ebx, 25 ; 1bpp image ? + jc .shift_mono + shl eax, 2 + imul eax, [img_bytes_per_pix] + jmp .get_right +.shift_mono: + shr eax, 1 ; 2 tiles = 1 byte Buffer offset + jnc .get_right + rol byte [img_edgeoffset], 4 ; odd number of tiles: shift 4bits +.get_right: + add esi, eax ; rightEdge Buffer origin + push ebp + add ebp, edx ; rightEdge Map origin + mov eax, [img_pix_x] + shl eax, 2 ; 1 pix = 4 bytes + add eax, edi ; rightEdge last pix (LFB addr) + movzx edx, al + and dl, 0x0C + jz .core_block ; rightEdge is already tile-aligned + and al, 0xF0 + mov edi, eax ; rightEdge Screen origin +.right_edge: + call draw_unaligned_edge + dec [img_map_x] +.core_block: + pop ebp + mov eax, [img_map_x] + or eax, eax ; empty central core? + jz .finish + mov edi, [img_lfb_origin] + mov esi, [img_buf_origin] + + call draw_aligned_box + +.finish: + add esp, putimg.stack_data +; call [_display.enable_mouse] + popad + ret + +.thin_bar: ; < a special case > : one-tile-wide image + mov edx, [img_pix_x] + shl edx, 2 ; edx = rightmost tile offset (0, 4, 8, or 12 bytes) + call draw_unaligned_edge + jmp .finish + + +align 64 +img_test_struct: + dd 0x00112233, 0x00223344, 0x00334455, 0x00445566 + dd 0x00223344, 0x00334455, 0x00445566, 0x00334455 + dd 0x00334455, 0x00445566, 0x00334455, 0x00223344 + dd 0x00445566, 0x00334455, 0x00223344, 0x00112233 + +;************************************************************************************** +align 4 +__sys_putpixel: +_putpixel: + +; eax = x coordinate +; ebx = y coordinate +; ecx = ?? RR GG BB ; 0x01000000 negation +; edi = 0x00000001 force + + cmp [Screen_Max_X], eax + jb .exit0 + cmp [Screen_Max_Y], ebx + jb .exit0 +.check_forced: + test edi,1 ; force ? + jnz .checked + +.not_forced: + push ebx eax + shr eax, 1 + shr eax, 1 + shr ebx, 1 + imul ebx, [_WinMapWidth] ; win_map (X size)/2 + add ebx, eax + mov al, byte [CURRENT_TASK] + mov bl, byte [_WinMapAddress+ebx] + cmp bl, al + pop eax ebx + jne .exit0 +.checked: + push ebx + imul ebx, [BytesPerScanLine] + lea ebx, [ebx+eax*4] + bt ecx, 24 + jnc .noneg + mov ecx, [LFB_BASE+ebx] + xor ecx, 0x00FFFFFF +.noneg: + mov [LFB_BASE+ebx], ecx + pop ebx +.exit0: + ret + + + +align 4 +put_pixel: ; left for compatibility with 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 + mov [LFB_BASE+edi], ecx + ret + + +; DRAWLINE + +align 4 +__sys_draw_line: + call [_display.disable_mouse] + +; draw a line +; eax = HIWORD = x1 +; LOWORD = x2 +; ebx = HIWORD = y1 +; LOWORD = y2 +; ecx = color +; edi = force ? + pusha + +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 + + 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) + 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 +.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 +.y_rules: + 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 +.exit: + add esp, 6*4 + popa + call [draw_pointer] ; mouse + ret + +align 4 +hline: +; ------------ draw a horizontal line ------------- +; eax = x1 +; edx = x2 +; ebx = y +; ecx = color +; edi = force ? + cmp ebx, [Screen_Max_Y] + jge .out + pushad + + bt ecx, 24 ; color inversion check + rcl edi,1 ; forced graphics check + + mov ebp, ebx + shr ebp, 1 + imul ebp, [_WinMapWidth] ; ebp = screen map base + add ebp, [_WinMapAddress] + + cmp edx, eax ; to make sure x2 > x1 + jge @f + xchg eax, edx +@@: + cmp eax, [Screen_Max_X] + jge .exit + + mov esi, eax + shr esi, 4 + add ebp, esi ; ebp -> win_map element + + imul ebx, [BytesPerScanLine] ; ebx -> LFB pix_line + add ebx, LFB_BASE + + cmp edx, [Screen_Max_X] ; last check + jb @f + mov edx, [Screen_Max_X] + +@@: mov esi, ecx ; store color here + mov cl, byte [CURRENT_TASK] ; + mov ch, cl + mov [CURRENT_TASK+2], cx + mov [CURRENT_TASK+1], cl ; replicate byte to dword + +.newsegment: + mov ecx, [ebp] ; check the line segment (16 pixels!) + xor ecx, [CURRENT_TASK] +; -- the line --- + jmp dword [hline.drawtable + edi*4] ; a coolhack (C) Serge + + +align 4 ; internal loop +.invert_color: + mov esi, [ebx+eax*4] + xor esi, 0x00FFFFFF +align 4 +.check_overlap: + or cl, cl + jz .putpixel + jmp .nextpixel +align 4 +.invert_force: + mov esi, [ebx+eax*4] + xor esi, 0x00FFFFFF +align 4 +.putpixel: + mov [ebx+eax*4], esi +align 4 +.nextpixel: + inc eax + cmp eax, edx + ja .exit ; line drawn -- exit all loops + test al, 3 + jz .newtile +.newpixel: + jmp dword [hline.drawtable + edi*4] ; the internal loop +.newtile: + inc ebp + test ebp, 3 + jz .newsegment ; the external loop + shr ecx, 8 + jmp dword [hline.drawtable + edi*4] + +.exit: + mov eax, 0x0FF + and [CURRENT_TASK], eax + popad +.out: + ret +align 4 +.drawtable: +dd .check_overlap ; general case +dd .invert_color +dd .putpixel ; force to draw it +dd .invert_force + + +align 4 +vline: +; --------- draw a vertical line ------------ +; eax = x +; ebx = y1 +; edx = y2 +; ecx = color +; edi = force ? + cmp eax, [Screen_Max_X] + jge .out + pushad + bt ecx, 24 ; color inversion check + rcl edi, 1 ; forced graphics check + + cmp edx, ebx ; to make sure y2 > y1 + jge @f + xchg ebx, edx +@@: + cmp ebx, [Screen_Max_Y] + jge .exit + mov ebp, ebx + shr ebp, 1 + imul ebp, [_WinMapWidth] + add ebp, [_WinMapAddress] + mov esi, eax + shr esi, 1 + shr esi, 1 + add ebp, esi ; ebp = screen map at (x, y1) + push ebx + + imul ebx, [BytesPerScanLine] + shl eax, 1 + shl eax, 1 + add eax, ebx + add eax, LFB_BASE + pop ebx ; restore ebx = y1 + cmp edx, [Screen_Max_Y] ; the last check + jb .draw + mov edx, [Screen_Max_Y] ; to prevent off-screen drawing + +.draw: + jmp dword [vline.drawtable + edi*4] +align 4 +.invert_color: + mov ecx, [eax] + xor ecx, 0x00FFFFFF +align 4 +.check_overlap: + movzx esi, byte [ebp] + cmp esi, [CURRENT_TASK] + je .putpixel + jmp .nextpixel + +align 4 +.invert_force: + mov ecx, [eax] + xor ecx, 0x00FFFFFF +align 4 +.putpixel: + mov [eax], ecx +align 4 +.nextpixel: + add eax, [BytesPerScanLine] + inc ebx + test bl, 1 + jnz @f + add ebp, [_WinMapWidth] +@@: + cmp ebx, edx + ja .exit + jmp dword [vline.drawtable + edi*4] +.exit: + shr edi, 1 + popad + +.out: + ret +align 4 +.drawtable: +dd .check_overlap ; general case +dd .invert_color +dd .putpixel ; force to draw it +dd .invert_force + + +;************************************************* + + +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 +end virtual + +align 4 +; eax cx +; ebx cy +; ecx xe +; edx ye +; edi color +vesa20_drawbar: + pushad + call [_display.disable_mouse] + 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 +; note that WDATA.box.width is one pixel less than real window x-size + inc ebx + 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, [Screen_Max_X] + sub eax, [drbar.real_sx] + inc eax + shr eax, 1 ; <<<<<< + shr eax, 1 + mov [drbar.line_inc_map], eax ; vertical increment: map +; line_inc_scr + mov eax, [drbar.real_sx] + shl eax, 1 + shl eax, 1 + neg eax + add eax, [BytesPerScanLine] + mov [drbar.line_inc_scr], eax ; vertical increment: screen +; pointer to screen + mov edx, [drbar.abs_cy] + mov ebx, edx + imul edx, [BytesPerScanLine] ; edx = LFB line offset + mov eax, [drbar.abs_cx] + shl eax, 1 + shl eax, 1 + add edx, eax ; edx = LFB corner offset +; pointer to pixel map + shr ebx, 1 + imul ebx, [_WinMapWidth] ; eax = Wmap corner pos + mov eax, [drbar.abs_cx] + shr eax, 1 + shr eax, 1 + add eax, ebx + add eax, [_WinMapAddress] + xchg eax, ebp ; ebp = Wmap corner +; get process number + mov ebx, [CURRENT_TASK] + +; eax - RGB-color +; bl - process num +; ecx - pix counter (in a tile) +; edx - pointer to screen +; esi - counter +; edi - counter + + mov eax, [drbar.color] ;; BBGGRR00 + mov esi, 0 +align 4 +.new_y: + mov edi, [drbar.real_sx] + movzx ecx, dl + shr cl, 2 ; pix# = edx/4 + and cl, 3 ; pix position in a tile +.new_tile: + cmp byte [ebp], bl + jne .skip +.new_x: + mov [LFB_BASE+edx], eax + add edx, 4 + dec edi + jz .add_line + inc cl + and cl, 3 + jnz .new_x + jmp .new_tile +.skip: + add edx, 4*4 + and dl, 0xF0 ; LFB align 16 + inc ebp + sub edi, 4 ; <<<<< + add edi, ecx ; left tile may be 1,2 or 3px only + jae .new_tile + +.add_line: + add edx, [drbar.line_inc_scr] +; gradient-filled bars + test eax, 0x80000000 + jz @f + test al, al + jz @f + dec al +@@: + inc esi + test esi, 1 + jne @f + add ebp, [drbar.line_inc_map] +@@: + cmp esi, [drbar.real_sy] + jbe .new_y + add esp, drbar.stack_data + popad + xor eax, eax + ret + + +align 4 +;drawbackground: + call [_display.disable_mouse] + pushad +; External loop for all y from start to end + mov ebx, [draw_data+32+RECT.top] ; y start +.fill_line: + mov edi, [draw_data+32+RECT.left] ; x start + shl edi, 1 + shl edi, 1 + mov eax, [BytesPerScanLine] + mul ebx + xchg edi, eax + add edi, eax + add edi, LFB_BASE + + mov ebp, ebx + shr ebp, 1 + imul ebp, [_WinMapWidth] + mov edx, eax + shr edx, 1 + shr edx, 1 + add ebp, edx + add ebp, [_WinMapAddress] + xor edx, edx + inc edx + mov esi, 0x0336677 ; <<< RGB +; eax = x, ebx = y (screen coordinates) +; ecx - aux. var +; edx = 1 +; esi = 0RGB, edi -> output +; ebp = offset in WinMapAddress +.fill_tile: + cmp [ebp], dl + jnz .next_tile + mov [edi], esi + mov [edi+4], esi + mov [edi+8], esi + mov [edi+12],esi + mov ecx, [BytesPerScanLine] + mov [ecx+edi], esi + mov [ecx+edi+4], esi + mov [ecx+edi+8], esi + mov [ecx+edi+12],esi +.next_tile: + add edi, 4*4 + add ebp, edx + add ax, 4 + mov ecx, [draw_data+32+RECT.right] + shr ecx, 1 + shr ecx, 1 + cmp eax, ecx + jbe .fill_tile + +.next_line: + inc ebx + mov ecx, [draw_data+32+RECT.bottom] + shr ecx, 1 + jbe .fill_line + popad + ret + +; ---------- + + +drawbackground_stretch: ; left for future development + call drawbackground + ret +drawbackground_tiled: ; left for future development + call drawbackground + ret + +uglobal +align 4 +bgr_cur_line rd 1920 ; maximum width of screen +bgr_next_line rd 1920 +endg + +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] + inc eax + 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: + 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 + +iglobal +align 4 +overlapping_of_points_ptr dd overlapping_of_points +endg + +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 +diff16 "GRAPH32 code end ",0,$ +diff10 "GRAPH32 code size",get_pixel,$ + + diff --git a/kernel/branches/Kolibri-A/trunk/video/vesa20.inc b/kernel/branches/Kolibri-A/trunk/video/vesa20.inc deleted file mode 100644 index 78734e75c7..0000000000 --- a/kernel/branches/Kolibri-A/trunk/video/vesa20.inc +++ /dev/null @@ -1,1064 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2008. 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$ - - -;************************************************* -; getpixel -; -; in: -; eax = x coordinate -; ebx = y coordinate -; -; ret: -; ecx = 00 RR GG BB - - -get_pixel: - mov ecx, [BytesPerScanLine] - imul ecx, ebx - lea ecx, [ecx+eax*4] ; ecx = x*4+(y*y multiplier) - mov ecx, [ecx+LFB_BASE] - and ecx, 0xffffff - ret - -;************************************************* - -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 ? - .stack_data = 4*12 - .edi dd ? - .esi dd ? - .ebp dd ? - .esp dd ? - .ebx dd ? - .edx dd ? - .ecx dd ? - .eax dd ? - .ret_addr dd ? - .arg_0 dd ? -end virtual - -align 16 -; ebx = pointer -; ecx = size [x|y] -; edx = coordinates [x|y] -; ebp = pointer to 'get' function -; esi = pointer to 'init' function -; edi = parameter for 'get' function - -vesa20_putimage: - pushad - call [_display.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 - 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 - call esi - add eax, [putimg.arg_0] - mov [putimg.line_increment], eax -; winmap new line increment - mov eax, [Screen_Max_X] - inc eax - sub eax, [putimg.real_sx] - mov [putimg.winmap_newline], eax -; screen new line increment - mov eax, [BytesPerScanLine] - shl ecx, 1 - shl ecx, 1 - 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] - shl eax, 1 - shl eax, 1 - add edx, eax -; pointer to pixel map - mov eax, [putimg.abs_cy] - imul eax, [Screen_Max_X] - add eax, [putimg.abs_cy] - add eax, [putimg.abs_cx] - add eax, [_WinMapAddress] - xchg eax, ebp -; get process number - mov ebx, [CURRENT_TASK] - -put_image_end_32: - mov edi, [putimg.real_sy] -align 4 -.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 - 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] ;[BytesPerScanLine] - add ebp, [putimg.winmap_newline] ;[Screen_Max_X] - 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 -__sys_putpixel: - -; eax = x coordinate -; ebx = y coordinate -; ecx = ?? RR GG BB ; 0x01000000 negation -; edi = 0x00000001 force - - cmp [Screen_Max_X], eax - jb .exit - cmp [Screen_Max_Y], ebx - jb .exit -.check_forced: - test edi,1 ; force ? - jnz .checked - -.not_forced: - push edx - mov edx,[_display.width] ; screen x size - imul edx, ebx - add edx, [_WinMapAddress] - movzx edx, byte [eax+edx] - cmp edx, [CURRENT_TASK] - pop edx - jne .exit - -; OK to set pixel -.checked: - push ebx - imul ebx, [BytesPerScanLine] - lea ebx, [ebx+eax*4] - test ecx,0x01000000 - jz .noneg - mov ecx, [LFB_BASE+ebx] - not ecx - and ecx, 0x01FFFFFF -.noneg: - mov [LFB_BASE+ebx], ecx - pop ebx -.exit: - ret - - - -align 4 -put_pixel: ; left for compatibility with 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 - mov [LFB_BASE+edi], ecx - ret - - -;************************************************* - -;align 4 -calculate_edi: - mov edi, ebx - imul edi, [Screen_Max_X] - add edi, ebx - add edi, eax - ret - -;************************************************* - -; DRAWLINE - -align 4 -__sys_draw_line: - call [_display.disable_mouse] - -; draw a line -; eax = HIWORD = x1 -; LOWORD = x2 -; ebx = HIWORD = y1 -; LOWORD = y2 -; ecx = color -; edi = force ? - pusha - -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 - - 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) - 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 -.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 -.y_rules: - 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] -.exit: - add esp, 6*4 - popa - call [draw_pointer] - ret - -align 4 -hline: -; ------------ draw a horizontal line ------------- -; eax = x1 -; edx = x2 -; ebx = y -; ecx = color -; edi = force ? - cmp ebx, [Screen_Max_Y] - jge .out - push eax ebp esi ebx edx - bt ecx, 24 ; color inversion check - rcl edi,1 ; forced graphics check - - mov ebp, [_display.width] ; ebp = screen co-ords base - imul ebp, ebx - add ebp, [_WinMapAddress] - - cmp edx, eax ; to make sure x2 > x1 - jge @f - xchg eax, edx -@@: - cmp eax, [Screen_Max_X] - jge .exit - imul ebx, [BytesPerScanLine] - add ebx, LFB_BASE - cmp edx, [Screen_Max_X] ; last check - jb .draw - mov edx, [Screen_Max_X] - -.draw: ; -- the line --- - jmp dword [hline.drawtable + edi*4] ; a coolhack (C) Serge - -align 4 -.invert_color: - mov ecx, [ebx+eax*4] - xor ecx, 0x00FFFFFF - or ecx, 0x01000000 ; keep bit[24] high ! -align 4 -.check_overlap: - movzx esi, byte [ebp+eax] ; check whether the line covered by other windows - cmp esi, [CURRENT_TASK] - je .putpixel - jmp .nextpixel -align 4 -.invert_force: - mov ecx, [ebx+eax*4] - xor ecx, 0x00FFFFFF - or ecx, 0x01000000 ; keep bit[24] high ! -align 4 -.putpixel: - mov [ebx+eax*4], ecx -align 4 -.nextpixel: - inc eax - cmp eax, edx - ja .exit - jmp dword [hline.drawtable + edi*4] ; close the loop - -.exit: - shr edi, 1 ; restore the 'force' bit - pop edx ebx esi ebp eax -.out: - ret -align 4 -.drawtable: -dd .check_overlap ; general case -dd .invert_color -dd .putpixel ; force to draw it -dd .invert_force - - -align 4 -vline: -; --------- draw a vertical line ------------ -; eax = x -; ebx = y1 -; edx = y2 -; ecx = color -; edi = force ? - cmp eax, [Screen_Max_X] - jge .out - push eax ebp esi ebx edx - mov ebp, [_display.width] ; ebp = screen co-ords base - imul ebp, ebx - add ebp, [_WinMapAddress] - add ebp, eax - - cmp edx, ebx ; to make sure y2 > y1 - jge @f - xchg ebx, edx -@@: - cmp ebx, [Screen_Max_Y] - jge .exit - push ebx - imul ebx, [BytesPerScanLine] - shl eax, 1 - shl eax, 1 - add eax, ebx - add eax, LFB_BASE - pop ebx ; restore ebx = y1 - cmp edx, [Screen_Max_Y] ; the last check - jb .draw - mov edx, [Screen_Max_Y] ; to prevent off-screen drawing - -.draw: - jmp dword [vline.drawtable + edi*4] -align 4 -.invert_color: - mov ecx, [eax] - xor ecx, 0x00FFFFFF - or ecx, 0x01000000 -align 4 -.check_overlap: - movzx esi, byte [ebp] - cmp esi, [CURRENT_TASK] - je .putpixel - jmp .nextpixel - -align 4 -.invert_force: - mov ecx, [eax] - xor ecx, 0x00FFFFFF - or ecx, 0x01000000 -align 4 -.putpixel: - mov [eax], ecx -align 4 -.nextpixel: - add eax, [BytesPerScanLine] - add ebp, [_display.width] - inc ebx - cmp ebx, edx - ja .exit - jmp dword [vline.drawtable + edi*4] -.exit: - shr edi, 1 - pop edx ebx esi ebp eax -.out: - ret -align 4 -.drawtable: -dd .check_overlap ; general case -dd .invert_color -dd .putpixel ; force to draw it -dd .invert_force - - -;************************************************* - - -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 -end virtual - -align 4 -; eax cx -; ebx cy -; ecx xe -; edx ye -; edi color -vesa20_drawbar: - pushad - call [_display.disable_mouse] - 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 -; note that WDATA.box.width is one pixel less than real window x-size - inc ebx - 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, [Screen_Max_X] - sub eax, [drbar.real_sx] - inc eax - mov [drbar.line_inc_map], eax -; line_inc_scr - mov eax, [drbar.real_sx] - shl eax, 1 - shl eax, 1 - 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] - shl eax, 1 - shl eax, 1 - add edx, eax -; pointer to pixel map - mov eax, [drbar.abs_cy] - imul eax, [Screen_Max_X] - add eax, [drbar.abs_cy] - add eax, [drbar.abs_cx] - add eax, [_WinMapAddress] - xchg eax, ebp -; get process number - mov ebx, [CURRENT_TASK] - -draw_bar_end_32: -; eax - color high RRGG -; bl - process num -; bh - color low BB -; ecx - temp -; edx - pointer to screen -; esi - counter -; edi - counter - 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 [LFB_BASE+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 eax, 0x80000000 - jz @f - test al, al - jz @f - dec al -@@: -; - dec esi - jnz .new_y - add esp, drbar.stack_data - popad - xor eax, eax - ret - - -align 4 -vesa20_drawbackground_tiled: - call [_display.disable_mouse] - 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 - xchg ebp, eax - add ebp, eax - add ebp, eax - add ebp, eax - add ebp, eax - add ebp, LFB_BASE -; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB - call calculate_edi - xchg edi, ebp - add ebp, [_WinMapAddress] -; 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 nbgp - movsb - movsb - movsb - jmp @f -nbgp: - add esi, 3 - add edi, 3 -@@: - inc edi ; +1 for 32 bpp - 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 - ret - -; ---------- - - -vesa20_drawbackground_stretch: - call [_display.disable_mouse] - pushad -; Helper variables -; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1) - mov eax, [BgrDataWidth] - dec eax - xor edx, edx - div dword [Screen_Max_X] - push eax ; high - xor eax, eax - div dword [Screen_Max_X] - push eax ; low -; the same for height - mov eax, [BgrDataHeight] - dec eax - xor edx, edx - div dword [Screen_Max_Y] - push eax ; high - xor eax, eax - div dword [Screen_Max_Y] - push eax ; low -; External loop for all y from start to end - mov ebx, [draw_data+32+RECT.top] ; y start - mov ebp, [draw_data+32+RECT.left] ; x start -; 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 - xchg ebp, eax - add ebp, eax - add ebp, eax - add ebp, eax - 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, [_WinMapAddress] - 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: - - mov [LFB_BASE+edi], ax - shr eax, 16 - - mov [LFB_BASE+edi+2], al -snbgp: - add edi, 4 - inc ebp - mov eax, [esp+20] - inc eax - mov [esp+20], eax - add esi, 4 - cmp eax, [draw_data+32+RECT.right] - jbe sdp3a -sdp4: -; next y - mov ebx, [esp+24] - inc ebx - 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, [Screen_Max_X] - inc ebp - sub edi, eax - sub edi, eax - sub edi, eax - sub edi, eax - add edi, [BytesPerScanLine] -; 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, [Screen_Max_X] - inc ecx - rep movsd - jmp bgr_resmooth1 -sdpdone: - add esp, 44 - popad - ret - -uglobal -align 4 -bgr_cur_line rd 1920 ; maximum width of screen -bgr_next_line rd 1920 -endg - -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] - inc eax - 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: - 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 - -iglobal -align 4 -overlapping_of_points_ptr dd overlapping_of_points -endg - -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 -diff16 "VESA2 code end ",0,$ -diff16 "VESA2 code size",get_pixel,$ -