Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1034 → Rev 1037

/programs/develop/libraries/box_lib/trunk/box_lib.asm
12,6 → 12,9
include 'editbox.mac' ;¬ ªà®á ª®â®àë© ¤®«¦¥­ ®¡«¥£ç¨âì ¦¨§­ì :) ᯥ樠«ì­® ¤«ï editbox
include 'checkbox.mac' ;¬ ªà®á ᮤ¥à¦¨â ॠ«¨§ æ¨î checkbox
include 'optionbox.mac' ;¬ ªà®á ᮤ¥à¦¨â ॠ«¨§ æ¨î optionbox
include 'scrollbar.mac' ;¬ ªà®á ᮤ¥à¦¨â ॠ«¨§ æ¨î scrollbar
include 'd_button.mac' ;¬ ªà®á ᮤ¥à¦¨â ॠ«¨§ æ¨î dinamic button
include 'menubar.mac' ;¬ ªà®á ᮤ¥à¦¨â ॠ«¨§ æ¨î menubar
;----------------------------------------------------
;EditBox
;----------------------------------------------------
34,6 → 37,25
use_optionbox_draw ;¬ ªà®á à ááªà뢠¥â äã­ªæ¨î ®â®¡à ¦¥­¨ï ¡®ªá .
use_optionbox_mouse ;¬ ªà®á à ááªà뢠¥â äã­ªæ¨î ®¡à ¡®âª¨ ¬ëè¨.
 
;--------------------------------------------------
;scrollbar Group
;--------------------------------------------------
use_scroll_bar
use_scroll_bar_vertical
use_scroll_bar_horizontal
 
;--------------------------------------------------
;dinamic button Group
;--------------------------------------------------
use_dinamic_button
 
;--------------------------------------------------
;menubar Group
;--------------------------------------------------
use_menu_bar
 
 
;--------------------------------------------------
align 16
EXPORTS:
 
47,6 → 69,17
dd sz_option_box_draw, option_box_draw
dd sz_option_box_mouse, option_box_mouse
dd szVersion_op, 0x00000001
dd sz_Scrollbar_ver_draw, scroll_bar_vertical.draw
dd sz_Scrollbar_ver_mouse, scroll_bar_vertical.mouse
dd sz_Scrollbar_hor_draw, scroll_bar_horizontal.draw
dd sz_Scrollbar_hor_mouse, scroll_bar_horizontal.mouse
dd szVersion_scrollbar, 0x00010001
dd sz_Dbutton_draw, dinamic_button.draw
dd sz_Dbutton_mouse, dinamic_button.mouse
dd szVersion_dbutton, 0x00010001
dd sz_Menu_bar_draw, menu_bar.draw
dd sz_Menu_bar_mouse, menu_bar.mouse
dd szVersion_menu_bar, 0x00010001
dd 0,0
 
sz_edit_box db 'edit_box',0
59,6 → 92,17
sz_option_box_draw db 'option_box_draw',0
sz_option_box_mouse db 'option_box_mouse',0
szVersion_op db 'version_op',0
sz_Scrollbar_ver_draw db 'scrollbar_v_draw',0
sz_Scrollbar_ver_mouse db 'scrollbar_v_mouse',0
sz_Scrollbar_hor_draw db 'scrollbar_h_draw',0
sz_Scrollbar_hor_mouse db 'scrollbar_h_mouse',0
szVersion_scrollbar db 'version_scrollbar',0
sz_Dbutton_draw db 'dbutton_draw',0
sz_Dbutton_mouse db 'dbutton_mouse',0
szVersion_dbutton db 'version_dbutton',0
sz_Menu_bar_draw db 'menu_bar_draw',0
sz_Menu_bar_mouse db 'menu_bar_mouse',0
szVersion_menu_bar db 'version_menu_bar',0
 
;;;;;;;;;;;
;;Data
/programs/develop/libraries/box_lib/trunk/d_button.mac
0,0 → 1,170
;**************************************************************
; Dinamic Button Macro for Kolibri OS
; Copyright (c) 2009, Mario79
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
; * Neither the name of the <organization> nor the
; names of its contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY Mario79 ''AS IS'' AND ANY
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;*****************************************************************************
macro dinamic_button_exit
{
popa
ret 4
}
;*****************************************************************************
macro use_dinamic_button
{
dinamic_button:
db_type equ [edi]
db_size_x equ [edi+4]
db_start_x equ [edi+6]
db_size_y equ [edi+8]
db_start_y equ [edi+10]
db_mouse_pos equ [edi+12]
db_mouse_keys equ [edi+16]
db_mouse_keys_old equ [edi+20]
db_active_raw equ [edi+24]
db_passive_raw equ [edi+28]
db_click_raw equ [edi+32]
db_resolution_raw equ [edi+36]
db_palette_raw equ [edi+40]
db_offset_raw equ [edi+44]
db_select equ [edi+48]
db_click equ [edi+52]
;*****************************************************************************
;*****************************************************************************
; draw event
;*****************************************************************************
;*****************************************************************************
.draw:
pusha
mov edi,dword [esp+36]
call .draw_1
dinamic_button_exit
 
.draw_1:
cmp db_select,dword 1
je .active_1
cmp db_select,dword 2
je .click_2
mov ebx,db_passive_raw
jmp .draw_2 ;@f
.active_1:
mov ebx,db_active_raw
jmp .draw_2 ;@f
.click_2:
mov ebx,db_click_raw
@@:
.draw_2:
mov cx,db_size_x
shl ecx,16
mov cx,db_size_y
mov dx,db_start_x
shl edx,16
mov dx,db_start_y
 
mov esi,db_resolution_raw
 
mov ebp,db_offset_raw
push edi
mov edi,db_palette_raw
mcall 65
pop edi
ret
;*****************************************************************************
;*****************************************************************************
; mouse event
;*****************************************************************************
;*****************************************************************************
.mouse:
pusha
mov edi,dword [esp+36]
mcall 37,2
mov ebx,db_mouse_keys
mov db_mouse_keys_old,ebx
mov db_mouse_keys,eax
mcall 37,1
mov db_mouse_pos,eax
test eax,0x80000000
jnz .exit_menu
test eax,0x8000
jnz .exit_menu
 
mov ebx,eax
shr ebx,16 ; x position
shl eax,16
shr eax,16 ; y position
mov cx,db_start_x
cmp bx,cx
jb .exit_menu
add cx,db_size_x
cmp bx,cx
ja .exit_menu
 
mov cx,db_start_y
cmp ax,cx
jb .exit_menu
add cx,db_size_y
cmp ax,cx
ja .exit_menu
test db_mouse_keys,dword 1b
jnz @f
cmp db_select,dword 1
je .exit_menu_1
mov db_select,dword 1
call .draw_1
jmp .exit_menu_1
@@:
mov eax,db_mouse_keys
cmp eax,db_mouse_keys_old
je .exit_menu_1
mov db_select,dword 2
call .draw_1
mcall 5, 25
mov db_select,dword 1
call .draw_1
mov db_click,dword 1
jmp .exit_menu_2
.exit_menu:
cmp db_select,dword 0
je .exit_menu_1
mov db_select,dword 0
call .draw_1
 
.exit_menu_1:
; mov db_click,dword 0
.exit_menu_2:
dinamic_button_exit
}
/programs/develop/libraries/box_lib/trunk/menubar.mac
0,0 → 1,571
;**************************************************************
; MenuBar Macro for Kolibri OS
; Copyright (c) 2009, Mario79
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
; * Neither the name of the <organization> nor the
; names of its contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY Mario79 ''AS IS'' AND ANY
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;*****************************************************************************
macro menu_bar_exit
{
popa
ret 4
}
;*****************************************************************************
macro use_menu_bar
{
menu_bar:
m_type equ [edi]
m_size_x equ [edi+4]
m_start_x equ [edi+6]
m_size_y equ [edi+8]
m_start_y equ [edi+10]
m_text_pointer equ [edi+12]
m_pos_pointer equ [edi+16]
m_text_end equ [edi+20]
m_mouse_pos equ [edi+24]
m_mouse_keys equ [edi+28]
m_size_x1 equ [edi+32]
m_start_x1 equ [edi+34]
m_size_y1 equ [edi+36]
m_start_y1 equ [edi+38]
m_bckg_col equ [edi+40]
m_frnt_col equ [edi+44]
m_menu_col equ [edi+48]
m_select equ [edi+52]
m_out_select equ [edi+56]
m_buf_adress equ [edi+60]
m_procinfo equ [edi+64]
m_click equ [edi+68]
m_cursor equ [edi+72]
m_cursor_old equ [edi+76]
m_interval equ [edi+80]
m_cursor_max equ [edi+84]
m_extended_key equ [edi+88]
m_menu_sel_col equ [edi+92]
m_bckg_text_col equ [edi+96]
m_frnt_text_col equ [edi+100]
m_mouse_keys_old equ [edi+104]
m_font_height equ [edi+108]
m_cursor_out equ [edi+112]
m_get_mouse_flag equ [edi+116]
;*****************************************************************************
;*****************************************************************************
; draw event
;*****************************************************************************
;*****************************************************************************
.draw:
pusha
mov edi,dword [esp+36]
call .draw_1
menu_bar_exit
.draw_1:
call .calc_m_cursor_max
dec dword m_cursor_max
mov eax,m_cursor_max
imul eax,m_interval
mov m_size_y1,ax
mov ebx,m_size_x
mov ecx,m_size_y
cmp m_select,dword 1
je .active
mov edx,m_bckg_col
jmp @f
.active:
mov edx,m_frnt_col
@@:
mcall 13
shr ecx,16
mov bx,cx
movzx eax,word m_size_y
call .calculate_font_offset
cmp m_select,dword 1
je .active_1
mov ecx,m_bckg_text_col
add ecx,0x80000000
jmp @f
.active_1:
mov ecx,m_frnt_text_col
add ecx,0x80000000
@@:
mov edx,m_text_pointer
mcall 4
ret
 
.draw_2:
mov ebx,m_size_x1
mov ecx,m_size_y1
mov edx,m_menu_col
mcall 13
ret
 
.calculate_font_offset:
sub eax,m_font_height
shr eax,1
add ebx,eax
add ebx,4 shl 16
ret
.draw_3:
mov ebx,m_size_x1
mov ecx,m_size_y1
 
push ebx ecx
mov eax,m_cursor_old
imul eax,m_interval
shl eax,16
add ecx,eax
mov cx,m_interval
mov edx,m_menu_col
mcall 13
pop ecx ebx
push ebx ecx
mov eax,m_cursor
imul eax,m_interval
shl eax,16
add ecx,eax
mov cx,m_interval
mov edx,m_menu_sel_col
mcall 13
pop ecx ebx
shr ecx,16
mov bx,cx
mov eax,m_interval
call .calculate_font_offset
mov edx,m_pos_pointer
xor ebp,ebp
@@:
cmp ebp,m_cursor
jne .no_active_text
mov ecx,m_frnt_text_col
jmp .active_text
.no_active_text:
mov ecx,m_bckg_text_col
.active_text:
add ecx,0x80000000
mcall 4
call .get_next_text
inc ebp
add ebx,m_interval
jmp @r
.draw_end:
ret
.calc_m_cursor_max:
mov edx,m_pos_pointer
mov m_cursor_max,dword 0
@@:
inc dword m_cursor_max
call .get_next_text
jmp @r
;*****************************************************************************
.get_next_text:
mov esi,edx
@@:
cmp esi,m_text_end
je .get_next_text_end
cld
lodsb
test al,al
jnz @r
mov edx,esi
ret
.get_next_text_end:
add esp,4
ret
;*****************************************************************************
;*****************************************************************************
; mouse event
;*****************************************************************************
;*****************************************************************************
.mouse:
pusha
mov edi,dword [esp+36]
;.mouse_1:
; mov eax,m_mouse_pos
; cmp m_get_mouse_flag,dword 0
; je @f
call .processing_real_mouse
;@@:
test eax,0x80000000
jnz .exit_menu
test eax,0x8000
jnz .exit_menu
 
mov ebx,eax
shr ebx,16 ; x position
shl eax,16
shr eax,16 ; y position
mov cx,m_start_x
cmp bx,cx
jb .exit_menu
add cx,m_size_x
dec cx
cmp bx,cx
ja .exit_menu
 
mov cx,m_start_y
cmp ax,cx
jb .exit_menu
add cx,m_size_y
cmp ax,cx
ja .exit_menu
 
test m_mouse_keys,dword 1b
jnz @f
cmp m_select,dword 1
je .exit_menu_1
mov m_select,dword 1
call .draw_1
jmp .exit_menu_1
@@:
 
cmp m_get_mouse_flag,dword 1
mov m_get_mouse_flag,dword 0
je @f
mov eax,m_mouse_keys
cmp eax,m_mouse_keys_old
je .exit_menu_1
@@:
mov m_select,dword 1
call .draw_1
call .allocate_menu_area
call .get_menu_area
call .draw_2
.red:
call .draw_3
.still:
mcall 10
cmp eax,1
je .exit_menu_3 ;red
cmp eax,2
je .key_menu
cmp eax,3
je .exit_menu_3
cmp eax,6
je .mouse_menu
jmp .still
.key_menu:
mcall 2
cmp m_extended_key,dword 1
je .extended_key
test al,al
jnz .key_menu_end
cmp ah, 0xE0
jne @f
mov m_extended_key,dword 1
.key_menu_end:
jmp .still
@@:
cmp ah,72 ;Arrow Up
je .menu_key_72_1
cmp ah,80 ; Arrow Down
je .menu_key_80_1
cmp ah,28 ; Enter
je .menu_key_28_1
cmp ah,1 ; Esc
je .menu_key_1_1
.key_menu_end_1:
cmp ah,208 ; Arrow Down
je .key_menu_end
cmp ah,200 ; Arrow Up
je .key_menu_end
cmp ah,156 ; Enter
je .key_menu_end
cmp ah,129 ; Esc
je .key_menu_end
; cmp ah,184 ;Alt to Up
; je .end_5
; cmp ah,187 ; F1 to Up
; je .end_1
; cmp ah,188 ; F2 to Up
; je .end_1
cmp ah,199 ;Home
je .key_menu_end
cmp ah,207 ;End
je .key_menu_end
cmp ah,201 ;Page UP
je .key_menu_end
cmp ah,209 ;Page Down
je .key_menu_end
cmp ah,42 ; NumLock ON
je .key_menu_end
cmp ah,170 ; NumLock ON
je .key_menu_end
cmp ah,210 ; Insert
je .key_menu_end
cmp ah,211 ; Delete
je .key_menu_end
; cmp ah,56 ;Alt to Up
; je .end_4
; cmp ah,59 ; F1 to Down
; je .end_2
; cmp ah,60 ; F2 to Down
; je .end_3
 
;.for_all_key:
; mov [close_menu],1
; ret
jmp .exit_menu_3 ;.still
 
;---------------------------------------------------------------------
.extended_key:
mov m_extended_key, dword 0
.menu_key_80:
cmp ah,80 ; arrow down
jne .menu_key_72
.menu_key_80_1:
mov eax,m_cursor_max
dec eax
cmp eax,m_cursor
je .still ;@f
mov ebx,m_cursor
mov m_cursor_old,ebx
inc dword m_cursor
;@@:
jmp .red
;---------------------------------------------------------------------
.menu_key_72:
cmp ah,72 ;arrow up
jne .menu_key_71
.menu_key_72_1:
cmp m_cursor,dword 0
je .still ;@f
mov ebx,m_cursor
mov m_cursor_old,ebx
dec dword m_cursor
;@@:
jmp .red
;---------------------------------------------------------------------
.menu_key_71:
cmp ah,71 ;Home
je @f
cmp ah,73 ;PageUp
jne .menu_key_79
@@:
cmp m_cursor,dword 0
je .still
mov ebx,m_cursor
mov m_cursor_old,ebx
mov m_cursor,dword 0
jmp .red
;---------------------------------------------------------------------
.menu_key_79:
cmp ah,79 ; End
je @f
cmp ah,81 ; PageDown
jne .menu_key_1
@@:
mov ecx,m_cursor_max
dec ecx
cmp m_cursor,ecx
je .still
mov ebx,m_cursor
mov m_cursor_old,ebx
mov m_cursor,ecx
jmp .red
;---------------------------------------------------------------------
.menu_key_1:
cmp ah,1 ; Esc
jne .menu_key_28
.menu_key_1_1:
jmp .exit_menu_3
;---------------------------------------------------------------------
.menu_key_28:
cmp ah,28 ; Enter
jne .menu_key_end
.menu_key_28_1:
; mov [press_enter_menu],1
; ret
jmp .exit_menu_2
.menu_key_end:
jmp .key_menu_end_1
;---------------------------------------------------------------------
.processing_real_mouse:
mcall 37,2
mov ebx,m_mouse_keys
mov m_mouse_keys_old,ebx
mov m_mouse_keys,eax
mcall 37,1
mov m_mouse_pos,eax
ret
;---------------------------------------------------------------------
.allocate_menu_area:
cmp m_buf_adress,dword 0
je @f
call .free_menu_area
@@:
movzx ecx,word m_size_x1
movzx eax,word m_size_y1
imul ecx,eax
lea ecx,[ecx*3]
mcall 68, 12
mov m_buf_adress,eax
ret
;---------------------------------------------------------------------
.free_menu_area:
mcall 68,13,m_buf_adress
xor eax,eax
mov m_buf_adress,eax
ret
;---------------------------------------------------------------------
.get_menu_area:
mcall 9, m_procinfo,-1
mov cx,m_size_x1
shl ecx,16
mov cx,m_size_y1
mov dx,m_start_x1
mov eax,m_procinfo
add dx,[eax+34]
shl edx,16
mov dx,m_start_y1
add dx,[eax+38]
mcall 36, m_buf_adress
ret
;---------------------------------------------------------------------
.put_menu_area:
mov cx,m_size_x1
shl ecx,16
mov cx,m_size_y1
mov dx,m_start_x1
shl edx,16
mov dx,m_start_y1
mcall 7, m_buf_adress
ret
;---------------------------------------------------------------------
.mouse_menu:
call .processing_real_mouse
 
test eax,0x80000000
jnz .still
test eax,0x8000
jnz .still
mov ebx,eax
shr ebx,16
shl eax,16
shr eax,16
xor ecx,ecx
mov cx,m_start_y1
cmp ax,cx
jbe .close
add cx,m_size_y1
cmp ax,cx
jae .close
mov cx,m_start_x1
cmp bx,cx
jbe .close
add cx,m_size_x1
cmp bx,cx
jae .close
sub ax,m_start_y1
mov ebx,m_interval
xor edx,edx
div ebx
mov ebx,m_cursor
cmp eax,ebx
je .no_red
mov m_cursor_old,ebx
cmp eax,m_cursor_max
jb @f
mov eax,m_cursor_max
@@:
mov m_cursor,eax
test m_mouse_keys,dword 1b
jz .red
jmp .exit_menu_2
.no_red:
test m_mouse_keys,dword 1b
jz .still
jmp .exit_menu_2
.close:
test m_mouse_keys,dword 1b
jz .still
jmp .exit_menu_3
.exit_menu:
cmp m_select,dword 0
je .exit_menu_1
mov m_select,dword 0
call .draw_1
; jmp .exit_menu_1
test m_mouse_keys,dword 1b
jz .exit_menu_1
.exit_menu_3:
mov m_select,dword 0
call .put_menu_area
xor eax,eax
mov m_cursor_out,eax
jmp .exit
.exit_menu_2:
mov m_select,dword 0
call .put_menu_area
mov edx,m_pos_pointer
mov ebx,m_cursor
@@:
cmp ebx,0
jz @f
dec ebx
call .get_next_text
jmp @r
@@:
mov m_out_select,edx
mov eax,m_cursor
inc eax
mov m_cursor_out,eax
mov eax,m_mouse_keys
cmp eax,m_mouse_keys_old
jne .exit
xor eax,eax
mov m_cursor_out,eax
.exit:
call .draw_1
mov m_click,dword 1
jmp @f
.exit_menu_1:
mov m_click,dword 0
@@:
menu_bar_exit
}
 
/programs/develop/libraries/box_lib/trunk/scrollbar.mac
0,0 → 1,1326
;**************************************************************
; ScrollBar Macro for Kolibri OS
; Copyright (c) 2009, Mario79
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
; * Neither the name of the <organization> nor the
; names of its contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY Mario79 ''AS IS'' AND ANY
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;*****************************************************************************
macro scroll_bar_exit
{
popa
ret 4
}
;*****************************************************************************
macro draw_up_arrow_vertical
{
push ebx
xor eax,eax
mov ax,sb_size_x
shr eax,1
shl eax,16
add ebx,eax
xor eax,eax
mov ax,sb_btn_high
shr eax,1
shl eax,16
add ecx,eax
mov edx,sb_line_col
sub ebx,4 shl 16
mov bx,7
mov cx,1
mov eax,13
int 0x40
sub ecx,1 shl 16
add ebx,1 shl 16
mov bx,5
int 0x40
sub ecx,1 shl 16
add ebx,1 shl 16
mov bx,3
int 0x40
sub ecx,1 shl 16
add ebx,1 shl 16
mov bx,1
int 0x40
pop ebx
}
;*****************************************************************************
macro draw_down_arrow_vertical
{
push ebx
xor eax,eax
mov ax,sb_size_x
shr eax,1
shl eax,16
add ebx,eax
xor eax,eax
mov ax,sb_btn_high
shr eax,1
shl eax,16
add ecx,eax
mov edx,sb_line_col
sub ebx,4 shl 16
mov bx,7
sub ecx,2 shl 16
mov cx,1
mov eax,13
int 0x40
add ecx,1 shl 16
add ebx,1 shl 16
mov bx,5
int 0x40
add ecx,1 shl 16
add ebx,1 shl 16
mov bx,3
int 0x40
add ecx,1 shl 16
add ebx,1 shl 16
mov bx,1
int 0x40
pop ebx
}
;*****************************************************************************
macro draw_runner_center_vertical
{
push ebx
push ecx
xor eax,eax
mov ax,sb_size_x
shr eax,1
shl eax,16
add ebx,eax
mov edx,sb_run_size
shr edx,1
shl edx,16
add ecx,edx
mov edx,sb_line_col
sub ecx,8 shl 16
sub ebx,5 shl 16
mov bx,10
add ecx,4 shl 16
mov cx,1
mov eax,13
int 0x40
add ecx,3 shl 16
sub ebx,1 shl 16
mov bx,12
int 0x40
add ebx,1 shl 16
mov bx,10
add ecx,3 shl 16
int 0x40
pop ecx
pop ebx
}
;*****************************************************************************
macro draw_up_arrow_horizontal
{
push ecx
xor eax,eax
mov ax,sb_btn_high
shr eax,1
shl eax,16
add ebx,eax
xor eax,eax
mov ax,sb_size_y
shr eax,1
shl eax,16
add ecx,eax
mov edx,sb_line_col
sub ecx,4 shl 16
mov cx,7
mov bx,1
mov eax,13
int 0x40
sub ebx,1 shl 16
add ecx,1 shl 16
mov cx,5
int 0x40
sub ebx,1 shl 16
add ecx,1 shl 16
mov cx,3
int 0x40
sub ebx,1 shl 16
add ecx,1 shl 16
mov cx,1
int 0x40
pop ecx
}
;*****************************************************************************
macro draw_down_arrow_horizontal
{
push ecx
xor eax,eax
mov ax,sb_btn_high
shr eax,1
shl eax,16
add ebx,eax
xor eax,eax
mov ax,sb_size_y
shr eax,1
shl eax,16
add ecx,eax
mov edx,sb_line_col
sub ecx,4 shl 16
mov cx,7
sub ebx,2 shl 16
mov bx,1
mov eax,13
int 0x40
add ebx,1 shl 16
add ecx,1 shl 16
mov cx,5
int 0x40
add ebx,1 shl 16
add ecx,1 shl 16
mov cx,3
int 0x40
add ecx,1 shl 16
add ebx,1 shl 16
mov cx,1
int 0x40
pop ecx
}
;*****************************************************************************
macro draw_runner_center_horizontal
{
push ebx
push ecx
xor eax,eax
mov ax,sb_size_y
shr eax,1
shl eax,16
add ecx,eax
mov edx,sb_run_size
shr edx,1
shl edx,16
add ebx,edx
mov edx,sb_line_col
sub ebx,8 shl 16
sub ecx,5 shl 16
mov cx,10
add ebx,4 shl 16
mov bx,1
mov eax,13
int 0x40
add ebx,3 shl 16
sub ecx,1 shl 16
mov cx,12
int 0x40
add ecx,1 shl 16
mov cx,10
add ebx,3 shl 16
int 0x40
pop ecx
pop ebx
}
;*****************************************************************************
macro use_scroll_bar
{
scroll_bar:
sb_size_x equ [edi]
sb_start_x equ [edi+2]
sb_size_y equ [edi+4]
sb_start_y equ [edi+6]
sb_btn_high equ [edi+8]
sb_type equ [edi+12]
sb_max_area equ [edi+16]
sb_cur_area equ [edi+20]
sb_position equ [edi+24]
sb_bckg_col equ [edi+28]
sb_frnt_col equ [edi+32]
sb_line_col equ [edi+36]
sb_redraw equ [edi+40]
sb_delta equ [edi+44]
sb_delta2 equ [edi+46]
sb_r_size_x equ [edi+48]
sb_r_start_x equ [edi+50]
sb_r_size_y equ [edi+52]
sb_r_start_y equ [edi+54]
sb_m_pos equ [edi+56]
sb_m_pos_2 equ [edi+60]
sb_m_keys equ [edi+64]
sb_run_size equ [edi+68]
sb_position2 equ [edi+72]
sb_work_size equ [edi+76]
sb_all_redraw equ [edi+80]
}
;*****************************************************************************
;*****************************************************************************
; draw event
;*****************************************************************************
;*****************************************************************************
macro use_scroll_bar_vertical
{
scroll_bar_vertical:
.draw:
pusha
mov edi,dword [esp+36]
mov sb_all_redraw,dword 1
call .draw_1
mov sb_all_redraw,dword 0
scroll_bar_exit
.draw_1:
pusha
;*********************************
xor eax,eax
mov ax,sb_size_y
mov edx,sb_btn_high
shl edx,1
sub eax,edx
mov sb_work_size,eax
;*********************************
mov eax,sb_work_size ;sb_max_area
mov ebx,sb_max_area
cmp ebx,sb_cur_area
ja @f
 
jmp .no_size
 
@@:
imul eax,sb_cur_area
xor edx,edx
div ebx
cmp eax,10
jae @f
mov eax,10
@@:
.no_size:
mov sb_run_size,eax
;*********************************
cmp sb_delta,word 1
je .@@_3
mov eax,sb_work_size
sub eax,sb_run_size
mov ebx,sb_max_area
cmp ebx,sb_cur_area
ja @f
xor eax,eax
jmp .@@_1
@@:
sub ebx,sb_cur_area
imul eax,sb_position
xor edx,edx
div ebx
.@@_1:
mov sb_position2,eax
xor edx,edx
mov dx,sb_size_y
sub edx,sb_btn_high
sub edx,sb_btn_high
sub edx,sb_run_size
cmp sb_position2,edx
jbe .@@_3
mov sb_position2,edx
.@@_3:
;*********************************
mov ebx,sb_start_x
shl ebx,16
inc ebx
mov ecx,sb_size_y
mov edx,sb_line_col
mov eax,13
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; left extreme line
@@:
push ebx
ror ebx,16
add bx,sb_size_x
rol ebx,16
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; right extreme line
@@:
pop ebx
 
push ecx
add ebx,1 shl 16
mov bx,sb_size_x
dec ebx
mov cx,1
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; top button - extreme line
@@:
push ecx
add ecx,1 shl 16
add ecx,sb_btn_high
sub ecx,2
mov edx,sb_frnt_col
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; top button filling
;*********************************
draw_up_arrow_vertical
;*********************************
@@:
pop ecx
ror ecx,16
add ecx,sb_btn_high ;14 shl 16
rol ecx,16
mov edx,sb_line_col
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; top button - bottom line
@@:
pop ecx
;*********************************
ror ecx,16
add ecx,sb_btn_high ;15 shl 16
inc ecx
rol ecx,16
sub ecx,sb_btn_high ;30
sub ecx,sb_btn_high
push ecx
mov cx,0
add ecx,sb_position2
dec cx
mov eax,13
test cx,0x8000
jnz @f
mov edx,sb_bckg_col
int 0x40 ; top interval
@@:
;*********************************
shr ecx,16
add ecx,sb_position2
dec ecx
shl ecx,16
inc ecx
mov edx,sb_line_col
int 0x40 ; runner - top extreme line
add ecx,1 shl 16
mov cx,0
add ecx,sb_run_size
mov sb_r_size_x,ebx
mov sb_r_size_y,ecx
sub ecx,2
mov edx,sb_frnt_col
int 0x40 ; runner filling
;*********************************
draw_runner_center_vertical
;*********************************
shr ecx,16
add ecx,sb_run_size
sub ecx,2
shl ecx,16
inc ecx
mov edx,sb_line_col
int 0x40 ; runner - bottom extreme line
add ecx,1 shl 16
mov cx,sb_start_y
add cx,sb_size_y
sub ecx,sb_btn_high
dec ecx
mov eax,ecx
shr eax,16
sub cx,ax
test cx,0x8000
jnz @f
mov edx,sb_bckg_col
mov eax,13
int 0x40 ; bottom interval
@@:
pop ecx
;*********************************
mov ax,cx
shr ecx,16
add cx,ax
sub ecx,2
shl ecx,16
inc ecx
mov edx,sb_line_col
mov eax,13
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; bottom button - top line
@@:
push ecx
add ecx,1 shl 16
add cx,sb_btn_high
sub ecx,2
mov edx,sb_frnt_col
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; bottom button filling
;*********************************
draw_down_arrow_vertical
;*********************************
@@:
pop ecx
ror ecx,16
add ecx,sb_btn_high ;14 shl 16
rol ecx,16
mov edx,sb_line_col
mov cx,1
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; bottom button - extreme line
@@:
popa
ret
;*****************************************************************************
;*****************************************************************************
; mouse event
;*****************************************************************************
;*****************************************************************************
.mouse:
pusha
mov edi,dword [esp+36]
mcall 37,1
mov sb_m_pos,eax
cmp sb_m_pos_2,dword 0
jne @f
mov sb_m_pos_2,eax
@@:
mcall 37,2
mov sb_m_keys,eax
 
cmp sb_m_keys,eax
je @f
mov sb_m_keys,eax
mov sb_delta,dword 0
 
mov eax,sb_m_pos
mov sb_m_pos_2,eax
jmp .continue_2
@@:
cmp sb_m_keys,dword 0
jne @f ;.continue_2
mov eax,sb_m_pos
mov sb_m_pos_2,eax
jmp .correct_1 ;.exit_sb
@@:
mov sb_delta,word 1
 
.continue_2:
mov eax,sb_m_pos
test eax,0x80000000
jnz .exit_sb
test eax,0x8000
jnz .exit_sb
mov ebx,eax
shr ebx,16 ; x position
shl eax,16
shr eax,16 ; y position
 
mov cx,sb_start_y
cmp ax,cx
jb .exit_sb
cmp sb_delta2,word 0
je @f
push ecx
add cx,sb_btn_high
cmp ax,cx
pop ecx
jb .exit_sb
@@:
add cx,sb_size_y
cmp ax,cx
ja .exit_sb
 
cmp sb_delta2,word 0
je @f
sub cx,sb_btn_high
cmp ax,cx
ja .exit_sb
@@:
cmp sb_delta2,word 1
je @f
cmp sb_m_keys,dword 0
je .exit_sb
mov cx,sb_start_x
cmp bx,cx
jb .exit_sb
add cx,sb_size_x
cmp bx,cx
ja .exit_sb
 
mov cx,sb_r_start_y
cmp ax,cx
jb .no_runner
add cx,sb_r_size_y
cmp ax,cx
ja .no_runner
 
mov sb_delta2,word 1
@@:
push eax
mov ax,sb_m_pos
cmp ax,sb_m_pos_2
je .correct ;.exit_sb
shl eax,16
shr eax,16
mov ebx,sb_m_pos_2
shl ebx,16
shr ebx,16
cmp eax,ebx
jb .sub
sub eax,ebx
mov ebx,eax
add sb_position2,ebx
xor eax,eax
mov ax,sb_size_y
sub eax,sb_btn_high
sub eax,sb_btn_high
sub eax,sb_run_size
cmp sb_position2,eax
jbe @f
mov sb_position2,eax
@@:
mov eax,sb_m_pos
mov sb_m_pos_2,eax
pop eax
call .draw_1
jmp .no_runner_1
.correct:
pop eax
jmp .exit_sb
.correct_1:
mov sb_delta,dword 0
jmp .exit_sb
 
.sub:
sub ebx,eax
sub sb_position2,ebx
test sb_position2,dword 0x80000000
jz @f
mov sb_position2,dword 0
@@:
mov eax,sb_m_pos
mov sb_m_pos_2,eax
pop eax
call .draw_1
jmp .no_runner_1
 
;*****************************************************************************
.no_runner:
mov sb_delta,dword 0
.no_runner_1:
xor ecx,ecx
mov cx,sb_start_y
add cx,sb_btn_high ;15
cmp sb_delta,word 1
je .scroll_sb
cmp ax,cx
ja .scroll_sb
cmp sb_m_keys,dword 0
je .exit_sb
cmp sb_position,dword 0
; je .exit_sb
je @f
dec dword sb_position
jmp .all_sb
@@:
mov sb_position2,dword 0
jmp .all_sb
;*****************************************************************************
.scroll_sb:
add cx,sb_size_y
sub cx,sb_btn_high
sub cx,sb_btn_high
cmp sb_delta,word 1
je @f
cmp ax,cx
ja .down_sb
@@:
mov ebx,sb_btn_high ;16 ;15
; inc ebx
add bx,sb_start_y
sub cx,bx
sub ax,bx
.scroll_sb_1:
mov ebx,sb_run_size
;*****************************************************************************
cmp sb_delta,word 1
je .continue
@@:
mov edx,eax
; sub edx,sb_btn_high
push ebx
shr ebx,1
sub edx,ebx
pop ebx
mov sb_position2,edx
test sb_position2,dword 0x80000000
jz .test_1
mov sb_position2,dword 0
jmp .continue
.test_1:
xor edx,edx
mov dx,sb_size_y
sub edx,sb_btn_high
sub edx,sb_btn_high
sub edx,sb_run_size
cmp sb_position2,edx
jbe .continue
mov sb_position2,edx
; jmp .continue_1
.continue:
mov eax,sb_position2
sub ecx,ebx
.continue_1:
;*****************************************************************************
mov ebx,eax
 
mov eax,sb_max_area
cmp eax,sb_cur_area
ja @f
 
xor eax,eax
inc eax
mov sb_position2,eax
jmp .all_sb ;.store_position
@@:
sub eax,sb_cur_area
inc eax
shl eax,10
xor edx,edx
div ecx
shl edx,1
cmp edx,ecx
jb @f
inc eax
@@:
imul eax,ebx
shr eax,10
cmp sb_position,eax
je .exit_sb
cmp eax,0
ja @f
xor eax,eax
@@:
.store_position:
mov sb_position,eax
.all_sb:
mov sb_redraw,dword 1
call .draw_1
mov eax,sb_m_pos
mov sb_m_pos_2,eax
jmp .exit_sb
;*****************************************************************************
.down_sb:
cmp sb_m_keys,dword 0
je .exit_sb
mov eax,sb_max_area
sub eax,sb_cur_area
cmp sb_position,eax
; jae .exit_sb
jae @f
inc dword sb_position
jmp .all_sb
@@:
xor eax,eax
mov ax,sb_size_y
sub eax,sb_btn_high
sub eax,sb_btn_high
sub eax,sb_run_size
mov sb_position2,eax
jmp .all_sb
.exit_sb:
scroll_bar_exit
}
 
;*****************************************************************************
;*****************************************************************************
;*****************************************************************************
;*****************************************************************************
;*****************************************************************************
macro use_scroll_bar_horizontal
{
scroll_bar_horizontal:
.draw:
pusha
mov edi,dword [esp+36]
mov sb_all_redraw,dword 1
call .draw_1
mov sb_all_redraw,dword 0
scroll_bar_exit
.draw_1:
pusha
;*********************************
xor eax,eax
mov ax,sb_size_x ;sb_size_y
mov edx,sb_btn_high
shl edx,1
sub eax,edx
mov sb_work_size,eax
;*********************************
mov eax,sb_work_size ;sb_max_area
mov ebx,sb_max_area
cmp ebx,sb_cur_area
ja @f
 
jmp .no_size
 
@@:
imul eax,sb_cur_area
xor edx,edx
div ebx
cmp eax,10
jae @f
mov eax,10
@@:
.no_size:
mov sb_run_size,eax
;*********************************
cmp sb_delta,word 1
je .@@_3
mov eax,sb_work_size
sub eax,sb_run_size
mov ebx,sb_max_area
cmp ebx,sb_cur_area
ja @f
xor eax,eax
jmp .@@_1
@@:
sub ebx,sb_cur_area
imul eax,sb_position
xor edx,edx
div ebx
.@@_1:
mov sb_position2,eax
xor edx,edx
mov dx,sb_size_x
sub edx,sb_btn_high
sub edx,sb_btn_high
sub edx,sb_run_size
cmp sb_position2,edx
jbe .@@_3
mov sb_position2,edx
.@@_3:
;*********************************
mov ebx,sb_size_x
mov ecx,sb_start_y
shl ecx,16
inc ecx
mov edx,sb_line_col
mov eax,13
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; top extreme line
@@:
push ecx
ror ecx,16
add cx,sb_size_y
rol ecx,16
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; bottom extreme line
@@:
pop ecx
 
push ebx
add ecx,1 shl 16
mov cx,sb_size_y
dec ecx
mov bx,1
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; left button - extreme line
@@:
push ebx
add ebx,1 shl 16
add ebx,sb_btn_high
sub ebx,2
mov edx,sb_frnt_col
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; left button filling
;*********************************
draw_up_arrow_horizontal
;*********************************
@@:
pop ebx
ror ebx,16
add ebx,sb_btn_high ;14 shl 16
rol ebx,16
mov edx,sb_line_col
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; left button - right line
@@:
pop ebx
;*********************************
ror ebx,16
add ebx,sb_btn_high ;15 shl 16
inc ebx
rol ebx,16
sub ebx,sb_btn_high ;30
sub ebx,sb_btn_high
push ebx
mov bx,0
add ebx,sb_position2
dec bx
mov eax,13
test bx,0x8000
jnz @f
mov edx,sb_bckg_col
int 0x40 ; left interval
@@:
;*********************************
shr ebx,16
add ebx,sb_position2
dec ebx
shl ebx,16
inc ebx
mov edx,sb_line_col
int 0x40 ; runner - left extreme line
add ebx,1 shl 16
mov bx,0
add ebx,sb_run_size
mov sb_r_size_x,ebx
mov sb_r_size_y,ecx
sub ebx,2
mov edx,sb_frnt_col
int 0x40 ; runner filling
;*********************************
draw_runner_center_horizontal
;*********************************
shr ebx,16
add ebx,sb_run_size
sub ebx,2
shl ebx,16
inc ebx
mov edx,sb_line_col
int 0x40 ; runner - bottom extreme line
add ebx,1 shl 16
mov bx,sb_start_x
add bx,sb_size_x
sub ebx,sb_btn_high
dec ebx
mov eax,ebx
shr eax,16
sub bx,ax
test bx,0x8000
jnz @f
mov edx,sb_bckg_col
mov eax,13
int 0x40 ; bottom interval
@@:
pop ebx
;*********************************
mov ax,bx
shr ebx,16
add bx,ax
sub ebx,2
shl ebx,16
inc ebx
mov edx,sb_line_col
mov eax,13
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; bottom button - top line
@@:
push ebx
add ebx,1 shl 16
add bx,sb_btn_high
sub ebx,2
mov edx,sb_frnt_col
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; bottom button filling
;*********************************
draw_down_arrow_horizontal
;*********************************
@@:
pop ebx
ror ebx,16
add ebx,sb_btn_high ;14 shl 16
rol ebx,16
mov edx,sb_line_col
mov bx,1
cmp sb_all_redraw,dword 0
je @f
int 0x40 ; bottom button - extreme line
@@:
popa
ret
;*****************************************************************************
; mouse event
;*****************************************************************************
.mouse:
pusha
mov edi,dword [esp+36]
mcall 37,1
mov sb_m_pos,eax
cmp sb_m_pos_2,dword 0
jne @f
mov sb_m_pos_2,eax
@@:
mcall 37,2
mov sb_m_keys,eax
 
cmp sb_m_keys,eax
je @f
mov sb_m_keys,eax
mov sb_delta,dword 0
mov eax,sb_m_pos
mov sb_m_pos_2,eax
jmp .continue_2
@@:
cmp sb_m_keys,dword 0
jne @f ;.continue_2
mov eax,sb_m_pos
mov sb_m_pos_2,eax
jmp .correct_1 ;.exit_sb
@@:
mov sb_delta,word 1
 
.continue_2:
mov eax,sb_m_pos
test eax,0x80000000
jnz .exit_sb
test eax,0x8000
jnz .exit_sb
mov ebx,eax
shr eax,16 ; x position
shl ebx,16
shr ebx,16 ; y position
 
mov cx,sb_start_x ;y
cmp ax,cx
jb .exit_sb
cmp sb_delta2,word 0
je @f
push ecx
add cx,sb_btn_high
cmp ax,cx
pop ecx
jb .exit_sb
@@:
add cx,sb_size_x ;y
cmp ax,cx
ja .exit_sb
 
cmp sb_delta2,word 0
je @f
sub cx,sb_btn_high
cmp ax,cx
ja .exit_sb
@@:
cmp sb_delta2,word 1
je @f
cmp sb_m_keys,dword 0
je .exit_sb
mov cx,sb_start_y ;x
cmp bx,cx
jb .exit_sb
add cx,sb_size_y ;x
cmp bx,cx
ja .exit_sb
mov cx,sb_r_start_x
cmp ax,cx
jb .no_runner
add cx,sb_r_size_x
cmp ax,cx
ja .no_runner
 
mov sb_delta2,word 1
@@:
push eax
mov eax,sb_m_pos
mov ebx,sb_m_pos_2
shr eax,16
shr ebx,16
cmp eax,ebx
je .correct ;.exit_sb
; shl eax,16
; shr eax,16
; mov ebx,sb_m_pos_2
; shl ebx,16
; shr ebx,16
; cmp eax,ebx
jb .sub
sub eax,ebx
mov ebx,eax
add sb_position2,ebx
xor eax,eax
mov ax,sb_size_x ;y
sub eax,sb_btn_high
sub eax,sb_btn_high
sub eax,sb_run_size
cmp sb_position2,eax
jbe @f
mov sb_position2,eax
@@:
mov eax,sb_m_pos
mov sb_m_pos_2,eax
pop eax
call .draw_1
jmp .no_runner_1
.correct:
pop eax
jmp .exit_sb
.correct_1:
mov sb_delta,dword 0
jmp .exit_sb
 
.sub:
sub ebx,eax
sub sb_position2,ebx
test sb_position2,dword 0x80000000
jz @f
mov sb_position2,dword 0
@@:
mov eax,sb_m_pos
mov sb_m_pos_2,eax
pop eax
call .draw_1
jmp .no_runner_1
 
;*****************************************************************************
.no_runner:
mov sb_delta,dword 0
.no_runner_1:
xor ecx,ecx
mov cx,sb_start_x ;y
add cx,sb_btn_high ;15
cmp sb_delta,word 1
je .scroll_sb
cmp ax,cx
ja .scroll_sb
cmp sb_m_keys,dword 0
je .exit_sb
cmp sb_position,dword 0
; je .exit_sb
je @f
dec dword sb_position
jmp .all_sb
@@:
mov sb_position2,dword 0
jmp .all_sb
;*****************************************************************************
.scroll_sb:
add cx,sb_size_x ;y
sub cx,sb_btn_high
sub cx,sb_btn_high
cmp sb_delta,word 1
je @f
cmp ax,cx
ja .down_sb
@@:
mov ebx,sb_btn_high ;16 ;15
; inc ebx
add bx,sb_start_x ;y
sub cx,bx
sub ax,bx
.scroll_sb_1:
mov ebx,sb_run_size
;*****************************************************************************
cmp sb_delta,word 1
je .continue
@@:
mov edx,eax
; sub edx,sb_btn_high
push ebx
shr ebx,1
sub edx,ebx
pop ebx
mov sb_position2,edx
test sb_position2,dword 0x80000000
jz .test_1
mov sb_position2,dword 0
jmp .continue
.test_1:
xor edx,edx
mov dx,sb_size_x ;y
sub edx,sb_btn_high
sub edx,sb_btn_high
sub edx,sb_run_size
cmp sb_position2,edx
jbe .continue
mov sb_position2,edx
; jmp .continue_1
.continue:
mov eax,sb_position2
sub ecx,ebx
.continue_1:
;*****************************************************************************
mov ebx,eax
 
mov eax,sb_max_area
cmp eax,sb_cur_area
ja @f
 
xor eax,eax
inc eax
mov sb_position2,eax
jmp .all_sb ;.store_position
@@:
sub eax,sb_cur_area
inc eax
shl eax,10
xor edx,edx
div ecx
shl edx,1
cmp edx,ecx
jb @f
inc eax
@@:
imul eax,ebx
shr eax,10
cmp sb_position,eax
je .exit_sb
cmp eax,0
ja @f
xor eax,eax
@@:
.store_position:
mov sb_position,eax
.all_sb:
mov sb_redraw,dword 1
call .draw_1
mov eax,sb_m_pos
mov sb_m_pos_2,eax
jmp .exit_sb
;*****************************************************************************
.down_sb:
cmp sb_m_keys,dword 0
je .exit_sb
mov eax,sb_max_area
sub eax,sb_cur_area
cmp sb_position,eax
; jae .exit_sb
jae @f
inc dword sb_position
jmp .all_sb
@@:
xor eax,eax
mov ax,sb_size_x
sub eax,sb_btn_high
sub eax,sb_btn_high
sub eax,sb_run_size
mov sb_position2,eax
jmp .all_sb
.exit_sb:
scroll_bar_exit
}