Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 1101 → Rev 1100

/programs/develop/libraries/box_lib/asm/trunk/cnv_bmp.obj
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/programs/develop/libraries/box_lib/asm/trunk/d_button.mac
File deleted
/programs/develop/libraries/box_lib/asm/trunk/data.inc
File deleted
\ No newline at end of file
/programs/develop/libraries/box_lib/asm/trunk/reload_16x16_8b.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/programs/develop/libraries/box_lib/asm/trunk/load_lib.mac
File deleted
/programs/develop/libraries/box_lib/asm/trunk/build.bat
File deleted
\ No newline at end of file
/programs/develop/libraries/box_lib/asm/trunk/w_about.inc
File deleted
\ No newline at end of file
/programs/develop/libraries/box_lib/asm/trunk/ctrldemo.asm
File deleted
/programs/develop/libraries/box_lib/asm/trunk/editbox_ex.asm
File deleted
\ No newline at end of file
/programs/develop/libraries/box_lib/asm/trunk/editbox_ex.mac
File deleted
/programs/develop/libraries/box_lib/asm/trunk
Property changes:
Deleted: tsvn:logminsize
-5
\ No newline at end of property
/programs/develop/libraries/box_lib/asm
Property changes:
Deleted: tsvn:logminsize
-5
\ No newline at end of property
/programs/develop/libraries/box_lib/trunk/box_lib.asm
8,7 → 8,7
public EXPORTS
 
section '.flat' code readable align 16
include '../../../../macros.inc'
include 'macros.inc'
include 'editbox.mac' ;¬ ªà®á ª®â®àë© ¤®«¦¥­ ®¡«¥£ç¨âì ¦¨§­ì :) ᯥ樠«ì­® ¤«ï editbox
include 'checkbox.mac' ;¬ ªà®á ᮤ¥à¦¨â ॠ«¨§ æ¨î checkbox
include 'optionbox.mac' ;¬ ªà®á ᮤ¥à¦¨â ॠ«¨§ æ¨î optionbox
/programs/develop/libraries/box_lib/trunk/ctrldemo.asm
0,0 → 1,383
;
; Example for Box_lib: scrollbar, menubar, dinamic_button
; 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.
;*****************************************************************************
; import_boxlib procedure written by <Lrz>
;---------------------------------------------------------------------
 
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd IM_END
dd I_END
dd stacktop
dd 0x0
dd path
 
include 'MACROS.INC'
include 'load_lib.mac'
;---------------------------------------------------------------------
;--- Start of program ----------------------------------------------
;---------------------------------------------------------------------
START:
mcall 68, 11
mcall 66, 1, 1
mcall 40, 0x27
;---------------------------------------------------------------------
; Procinfo area for function 9 in MenuBar
mcall 68,12,1024
mov [menu_data_1.procinfo],eax
mov [menu_data_2.procinfo],eax
;---------------------------------------------------------------------
; loading Box_Lib library
load_libraries l_libs_start,end_l_libs
;sys_load_library boxlib_name, path, file_name, system_dir, \
;er_message_found_lib, ihead_f_l, myimport, er_message_import, ihead_f_i
; test eax,eax
; jnz button.exit
 
;----------------------------------old
; mov ebx,boxlib_name
; mov esi,path
; mov edi,file_name
; call copy_path
;
; mcall 68,19,file_name ; load of alternative
; test eax,eax
; jnz @f
;
; mcall 68,19,system_dir ; load of sys directory
; test eax,eax
; jz button.exit
;@@:
; call import_boxlib
;---------------------------------------------------------------------
; Load and convert BMP file for DinamicButton
; This procedures use cnv_bmp.obj and this module used only for
; demonstration of use DinamicButton
 
; mov ebx,plugin_BMP_name
; mov esi,path
; mov edi,file_name
copy_path plugin_BMP_name,path,file_name
;
mcall 68,19,file_name
test eax,eax
jz button.exit
mov eax,[eax+4]
mov [plugin],eax
 
 
;ïðîâåðêà íà ñêîëüêî óäà÷íî çàãóçèëàñü íàøà ëèáà
mov ebp,library01
cmp dword [ebp+ll_struc_size-4],0
jnz button.exit
;
; mov ebp,library02
; cmp dword [ebp+ll_struc_size-4],0x2
; jnz button.exit
; mov eax,dword [ebp+36]
; mov eax,[eax+4]
; mov [plugin],eax
 
; mov ebx,icons_file_name
; mov esi,path
; mov edi,file_name
copy_path icons_file_name,path,file_name
mcall 70, fileinfo
 
mov [fileinfo+0],dword 0
 
mov ecx,[file_info+32]
mov [fileinfo+12],ecx
mov [img_size],ecx
 
mcall 68, 12
 
 
mov [fileinfo+16],eax
mov [image_file],eax
 
 
mcall 70, fileinfo
xor eax,eax
mov [return_code],eax
mov eax,image_file
call [plugin]
mov ecx,[image_file]
mcall 68, 13,
cmp [return_code],dword 0
jne button.exit
mov ebx,[raw_pointer]
mov eax,[ebx+4]
; set of button size
mov [dinamic_button_data_1.size_x],ax
mov [dinamic_button_data_1.size_y],ax
mov [dinamic_button_data_2.size_x],ax
mov [dinamic_button_data_2.size_y],ax
mov eax,[ebx+12]
; set of RAW resolution to pixel
mov [dinamic_button_data_1.resolution_raw],eax
mov [dinamic_button_data_2.resolution_raw],eax
mov eax,[ebx+20]
add eax,ebx
; set RAW palette, use else resolution 8bit or less
mov [dinamic_button_data_1.palette_raw],eax
mov [dinamic_button_data_2.palette_raw],eax
mov eax,[ebx+28]
add eax,ebx
; set RAW area for passive button
mov [dinamic_button_data_1.passive_raw],eax
mov [dinamic_button_data_2.passive_raw],eax
mov ecx,[ebx+4]
imul ecx,[ebx+4]
imul ecx,[ebx+12]
shr ecx,3
add eax,ecx
; set RAW area for active button
mov [dinamic_button_data_1.active_raw],eax
mov [dinamic_button_data_2.active_raw],eax
add eax,ecx
; RAW area for click button
mov [dinamic_button_data_1.click_raw],eax
mov [dinamic_button_data_2.click_raw],eax
;---------------------------------------------------------------------
red:
call draw_window
still:
mcall 10
 
cmp eax,1
je red
cmp eax,2
je key
cmp eax,3
je button
cmp eax,6
je mouse
jmp still
 
 
;---------------------------------------------------------------------
key:
mcall 2
jmp still
;---------------------------------------------------------------------
button:
mcall 17
cmp ah, 1
jne still
.exit:
mcall -1
;---------------------------------------------------------------------
mouse:
;-----------------------------------------------
cmp [scroll_bar_data_horizontal.delta2],0
jne .horizontal
.vertical:
mov eax,[scroll_bar_data_vertical.max_area]
cmp eax,[scroll_bar_data_vertical.cur_area]
jbe .horizontal
; mouse event for Vertical ScrollBar
push dword scroll_bar_data_vertical
call [scrollbar_ver_mouse]
mov eax,scroll_bar_data_vertical.redraw
xor ebx,ebx
cmp [eax],ebx
je @f
mov [eax],ebx
jmp .draw_cube
@@:
cmp [scroll_bar_data_vertical.delta2],0
jne still
.horizontal:
mov eax,[scroll_bar_data_horizontal.max_area]
cmp eax,[scroll_bar_data_horizontal.cur_area]
jbe .other
; mouse event for Horizontal ScrollBar
push dword scroll_bar_data_horizontal
call [scrollbar_hor_mouse]
mov eax,scroll_bar_data_horizontal.redraw
xor ebx,ebx
cmp [eax],ebx
je .other
mov [eax],ebx
.draw_cube:
call draw_cube
jmp still
.other:
cmp [scroll_bar_data_vertical.delta2],0
jne still
cmp [scroll_bar_data_horizontal.delta2],0
jne still
;-----------------------------------------------
.menu_bar_1:
call .set_mouse_flag
@@:
; mouse event for Menu 1
push dword menu_data_1
call [menu_bar_mouse]
cmp [menu_data_1.click],dword 1
jne .menu_bar_2
cmp [menu_data_1.cursor_out],dword 0
jne analyse_out_menu_1
jmp .menu_bar_1
;--------------------------------------------
.menu_bar_2:
; mouse event for Menu 2
push dword menu_data_2
call [menu_bar_mouse]
cmp [menu_data_2.click],dword 1
jne .mouse_dinamic_button
cmp [menu_data_2.cursor_out],dword 0
jne analyse_out_menu_2
jmp .menu_bar_1
;--------------------------------------------
.mouse_dinamic_button:
; mouse event for Dinamic Button 1
push dword dinamic_button_data_1
call [dinamic_button_mouse]
mov eax,dinamic_button_data_1.click
cmp [eax],dword 1
jne @f
mov [eax],dword 0
jmp about
@@:
; mouse event for Dinamic Button 2
push dword dinamic_button_data_2
call [dinamic_button_mouse]
mov eax,dinamic_button_data_2.click
cmp [eax],dword 1
jne still ;@f
mov [eax],dword 0
jmp button.exit
;---------------------------------------------------------------------
.set_mouse_flag:
xor eax,eax
inc eax
mov [menu_data_1.get_mouse_flag],eax
mov [menu_data_2.get_mouse_flag],eax
ret
;---------------------------------------------------------------------
analyse_out_menu_1:
; analyse result of Menu 1
cmp [menu_data_1.cursor_out],dword 3
je button.exit
jmp still
analyse_out_menu_2:
; analyse result of Menu 2
cmp [menu_data_2.cursor_out],dword 2
je about
jmp still
;---------------------------------------------------------------------
about:
mcall 51,1,thread3,thread
jmp still
;---------------------------------------------------------------------
draw_window:
mcall 12, 1
mcall 0, <0,400>, <0,400>, 0x03AABBCC, 0x805080D0, 0x005080D0
mcall 71, 1, header_1
;---------------------------------------------
; draw for Menu 1
push dword menu_data_1
call [menu_bar_draw]
; draw for Menu 2
push dword menu_data_2
call [menu_bar_draw]
;---------------------------------------------
; draw for Dinamic Button 1
push dword dinamic_button_data_1
call [dinamic_button_draw]
; draw for Dinamic Button 2
push dword dinamic_button_data_2
call [dinamic_button_draw]
;---------------------------------------------
; set all_redraw flag for draw all ScrollBar
; In some cases it is necessity to draw only the area
; of moving of a "runner", for acceleration of output -
; in this case the flag needs to be reset to 0 (zero).
xor eax,eax
inc eax
mov [scroll_bar_data_vertical.all_redraw],eax
mov [scroll_bar_data_horizontal.all_redraw],eax
; draw for Vertical ScrollBar
push dword scroll_bar_data_vertical
call [scrollbar_ver_draw]
; draw for Horizontal ScrollBar
push dword scroll_bar_data_horizontal
call [scrollbar_hor_draw]
; reset all_redraw flag
xor eax,eax
mov [scroll_bar_data_vertical.all_redraw],eax
mov [scroll_bar_data_horizontal.all_redraw],eax
;---------------------------------------------
call draw_cube
mcall 12, 2
ret
;---------------------------------------------------------------------
draw_cube:
mcall 13,<30,301>,<50,301>,0xafafaf
mov ecx,[scroll_bar_data_vertical.position]
add ecx,50
shl ecx,16
mov cx,30
mov ebx,[scroll_bar_data_horizontal.position]
add ebx,30
shl ebx,16
mov bx,30
mcall 13, , , 0x0
ret
 
include 'data.inc'
include 'w_about.inc'
IM_END:
rb 1024
thread:
rb 1024
stacktop:
path:
rb 4096
file_name:
rb 4096
file_info:
rb 40
I_END:
 
/programs/develop/libraries/box_lib/trunk/data.inc
0,0 → 1,342
;---------------------------------------------------------------------
;--- ÄÀÍÍÛÅ ÏÐÎÃÐÀÌÌÛ ----------------------------------------------
;---------------------------------------------------------------------
@use_library
header_1 db 'Box_lib Control Demo by Mario79',0
 
ok_btn db 'Ok',0
labelt3 db 'About program',0
;---------------------------------------------------------------------
icons_file_name: db 'reload_16x16_8b.bmp',0
system_dir1 db '/sys/lib/'
plugin_BMP_name db 'cnv_bmp.obj',0
 
system_dir db '/sys/lib/'
boxlib_name db 'box_lib.obj',0
; Åñëè åñòü æåëàíèå ðàçúåäèíèòü, òî íóæíî èñïîëüçîâàòü ñëåäóþùèþ êîíñòðóêöèþ
;system_path db '/sys/lib/box_lib.obj',0
;... ëþáàÿ ïîñëåäîâàòåëüíîñòü äðóãèõ êîìàíä è îïðåäåëåíèé.
;library_name db 'box_lib.obj',0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ihead_f_i:
ihead_f_l db 'System error',0
 
er_message_found_lib db 'Sorry I cannot load library box_lib.obj',0
er_message_import db 'Error on load import library box_lib.obj',0
 
er_message_found_lib2 db 'Sorry I cannot load library cnv_bmp.obj',0
er_message_import2 db 'Error on load import library cnv_bmp.obj',0
 
align 4
l_libs_start:
library01 l_libs boxlib_name, path, file_name, system_dir, \
er_message_found_lib, ihead_f_l, myimport, er_message_import, ihead_f_i
 
;library02 l_libs plugin_BMP_name, path, file_name, system_dir1,\
;er_message_found_lib2, ihead_f_l, myimport, er_message_import2, ihead_f_i
 
end_l_libs:
 
;---------------------------------------------------------------------
fileinfo:
dd 5
dd 0
dd 0
dd 0
dd file_info
string:
db 0
dd file_name
plugin dd 0
;---------------------------------------------------------------------
; not change this section!!!
; start section
;---------------------------------------------------------------------
image_file dd 0
raw_pointer dd 0
return_code dd 0
img_size dd 0
deflate_unpack dd 0
;---------------------------------------------------------------------
; end section
;---------------------------------------------------------------------
 
;---------------------------------------------------------------------
align 4
myimport:
init_lib dd a_init
version_lib dd a_version
 
 
edit_box_draw dd aEdit_box_draw
edit_box_key dd aEdit_box_key
edit_box_mouse dd aEdit_box_mouse
version_ed dd aVersion_ed
 
check_box_draw dd aCheck_box_draw
check_box_mouse dd aCheck_box_mouse
version_ch dd aVersion_ch
 
option_box_draw dd aOption_box_draw
option_box_mouse dd aOption_box_mouse
version_op dd aVersion_op
 
scrollbar_ver_draw dd aScrollbar_ver_draw
scrollbar_ver_mouse dd aScrollbar_ver_mouse
scrollbar_hor_draw dd aScrollbar_hor_draw
scrollbar_hor_mouse dd aScrollbar_hor_mouse
version_scrollbar dd aVersion_scrollbar
 
dinamic_button_draw dd aDbutton_draw
dinamic_button_mouse dd aDbutton_mouse
version_dbutton dd aVersion_dbutton
 
menu_bar_draw dd aMenu_bar_draw
menu_bar_mouse dd aMenu_bar_mouse
version_menu_bar dd aVersion_menu_bar
dd 0
dd 0
 
a_init db 'lib_init',0
a_version db 'version',0
 
aEdit_box_draw db 'edit_box',0
aEdit_box_key db 'edit_box_key',0
aEdit_box_mouse db 'edit_box_mouse',0
aVersion_ed db 'version_ed',0
 
aCheck_box_draw db 'check_box_draw',0
aCheck_box_mouse db 'check_box_mouse',0
aVersion_ch db 'version_ch',0
 
aOption_box_draw db 'option_box_draw',0
aOption_box_mouse db 'option_box_mouse',0
aVersion_op db 'version_op',0
 
aScrollbar_ver_draw db 'scrollbar_v_draw',0
aScrollbar_ver_mouse db 'scrollbar_v_mouse',0
aScrollbar_hor_draw db 'scrollbar_h_draw',0
aScrollbar_hor_mouse db 'scrollbar_h_mouse',0
aVersion_scrollbar db 'version_scrollbar',0
 
aDbutton_draw db 'dbutton_draw',0
aDbutton_mouse db 'dbutton_mouse',0
aVersion_dbutton db 'version_dbutton',0
 
aMenu_bar_draw db 'menu_bar_draw',0
aMenu_bar_mouse db 'menu_bar_mouse',0
aVersion_menu_bar db 'version_menu_bar',0
;---------------------------------------------------------------------
 
;---------------------------------------------------------------------
align 4
scroll_bar_data_vertical:
.x:
.size_x dw 15 ;+0
.start_x dw 370 ;+2
.y:
.size_y dw 300 ;+4
.start_y dw 50 ;+6
.btn_high dd 15 ;+8
.type dd 1 ;+12
.max_area dd 300 ;+16
.cur_area dd 30 ;+20
.position dd 140 ;+24
.bckg_col dd 0xeeeeee ;+28
.frnt_col dd 0xbbddff ;+32
.line_col dd 0 ;+36
.redraw dd 0 ;+40
.delta dw 0 ;+44
.delta2 dw 0 ;+46
.run_x:
.r_size_x dw 0 ;+48
.r_start_x dw 0 ;+50
.run_y:
.r_size_y dw 0 ;+52
.r_start_y dw 0 ;+54
.m_pos dd 0 ;+56
.m_pos_2 dd 0 ;+60
.m_keys dd 0 ;+64
.run_size dd 0 ;+68
.position2 dd 0 ;+72
.work_size dd 0 ;+76
.all_redraw dd 0 ;+80
.ar_offset dd 10 ;+84
;---------------------------------------------------------------------
align 4
scroll_bar_data_horizontal:
.x:
.size_x dw 300 ;0 ;+0
.start_x dw 30 ;0 ;+2
.y:
.size_y dw 15 ;0 ;+4
.start_y dw 370 ;0 ;+6
.btn_high dd 15 ;+8
.type dd 1 ;+12
.max_area dd 300 ;+16
.cur_area dd 30 ;+20
.position dd 140 ;+24
.bckg_col dd 0xeeeeee ;+28
.frnt_col dd 0xbbddff ;+32
.line_col dd 0 ;+36
.redraw dd 0 ;+40
.delta dw 0 ;+44
.delta2 dw 0 ;+46
.run_x:
.r_size_x dw 0 ;+48
.r_start_x dw 0 ;+50
.run_y:
.r_size_y dw 0 ;+52
.r_start_y dw 0 ;+54
.m_pos dd 0 ;+56
.m_pos_2 dd 0 ;+60
.m_keys dd 0 ;+64
.run_size dd 0 ;+68
.position2 dd 0 ;+72
.work_size dd 0 ;+76
.all_redraw dd 0 ;+80
.ar_offset dd 10 ;+84
;---------------------------------------------------------------------
align 4
menu_data_1:
.type: dd 0 ;+0
.x:
.size_x dw 40 ;+4
.start_x dw 20 ;+6
.y:
.size_y dw 15 ;+8
.start_y dw 25 ;+10
.text_pointer: dd menu_text_area ;0 ;+12
.pos_pointer: dd menu_text_area.1 ;0 ;+16
.text_end dd menu_text_area.end ;0 ;+20
.mouse_pos dd 0 ;+24
.mouse_keys dd 0 ;+28
.x1:
.size_x1 dw 40 ;+32
.start_x1 dw 20 ;+34
.y1:
.size_y1 dw 100 ;+36
.start_y1 dw 40 ;+38
.bckg_col dd 0xeeeeee ;+40
.frnt_col dd 0xff ;+44
.menu_col dd 0xffffff ;+48
.select dd 0 ;+52
.out_select dd 0 ;+56
.buf_adress dd 0 ;+60
.procinfo dd 0 ;+64
.click dd 0 ;+68
.cursor dd 0 ;+72
.cursor_old dd 0 ;+76
.interval dd 16 ;+80
.cursor_max dd 0 ;+84
.extended_key dd 0 ;+88
.menu_sel_col dd 0x00cc00 ;+92
.bckg_text_col dd 0 ; +96
.frnt_text_col dd 0xffffff ;+100
.mouse_keys_old dd 0 ;+104
.font_height dd 8 ;+108
.cursor_out dd 0 ;+112
.get_mouse_flag dd 0 ;+116
;-------------------------
menu_text_area:
db 'File',0
.1:
db 'Test1',0
db 'Test2',0
db 'Exit',0
.end:
db 0
;---------------------------------------------------------------------
align 4
menu_data_2:
.type: dd 0 ;+0
.x:
.size_x dw 40 ;+4
.start_x dw 60 ;+6
.y:
.size_y dw 15 ;+8
.start_y dw 25 ;+10
.text_pointer: dd menu_text_area_2 ;0 ;+12
.pos_pointer: dd menu_text_area_2.1 ;0 ;+16
.text_end dd menu_text_area_2.end ;0 ;+20
.mouse_pos dd 0 ;+24
.mouse_keys dd 0 ;+28
.x1:
.size_x1 dw 50 ;+32
.start_x1 dw 60 ;+34
.y1:
.size_y1 dw 100 ;+36
.start_y1 dw 40 ;+38
.bckg_col dd 0xeeeeee ;+40
.frnt_col dd 0xff ;+44
.menu_col dd 0xffffff ;+48
.select dd 0 ;+52
.out_select dd 0 ;+56
.buf_adress dd 0 ;+60
.procinfo dd 0 ;+64
.click dd 0 ;+68
.cursor dd 0 ;+72
.cursor_old dd 0 ;+76
.interval dd 16 ;+80
.cursor_max dd 0 ;+84
.extended_key dd 0 ;+88
.menu_sel_col dd 0x00cc00 ;+92
.bckg_text_col dd 0 ; +96
.frnt_text_col dd 0xffffff ;+100
.mouse_keys_old dd 0 ;+104
.font_height dd 8 ;+108
.cursor_out dd 0 ;+112
.get_mouse_flag dd 0 ;+116
;------------------------
menu_text_area_2:
db 'Help',0
.1:
db 'Test1',0
db 'About',0
.end:
db 0
;---------------------------------------------------------------------
align 4
dinamic_button_data_1:
.type dd 0 ;+0
.x:
.size_x dw 20 ;+4
.start_x dw 150 ;+6
.y:
.size_y dw 20 ;+8
.start_y dw 25 ;+10
.mouse_pos dd 0 ;+12
.mouse_keys dd 0 ;+16
.mouse_keys_old dd 0 ;+20
.active_raw dd 0 ;+24
.passive_raw dd 0 ;+28
.click_raw dd 0 ;+32
.resolution_raw dd 0 ;+36
.palette_raw dd 0 ;+40
.offset_raw dd 0 ;+44
.select dd 0 ;+48
.click dd 0 ;+52
;---------------------------------------------------------------------
align 4
dinamic_button_data_2:
.type dd 0 ;+0
.x:
.size_x dw 20 ;+4
.start_x dw 180 ;+6
.y:
.size_y dw 20 ;+8
.start_y dw 25 ;+10
.mouse_pos dd 0 ;+12
.mouse_keys dd 0 ;+16
.mouse_keys_old dd 0 ;+20
.active_raw dd 0 ;+24
.passive_raw dd 0 ;+28
.click_raw dd 0 ;+32
.resolution_raw dd 0 ;+36
.palette_raw dd 0 ;+40
.offset_raw dd 0 ;+44
.select dd 0 ;+48
.click dd 0 ;+52
;---------------------------------------------------------------------
/programs/develop/libraries/box_lib/trunk/editbox_ex.asm
0,0 → 1,186
;§ £®«®¢®ª ¯à¨«®¦¥­¨ï
use32 ; âà ­á«ïâ®à, ¨á¯®«ì§ãî騩 32 à §à來ëå ª®¬ ­¤ë
org 0x0 ; ¡ §®¢ë©  ¤à¥á ª®¤ , ¢á¥£¤  0x0
db 'MENUET01' ; ¨¤¥­â¨ä¨ª â®à ¨á¯®«­ï¥¬®£® ä ©«  (8 ¡ ©â)
dd 0x1 ; ¢¥àá¨ï ä®à¬ â  § £®«®¢ª  ¨á¯®«­ï¥¬®£® ä ©« 
dd start ;  ¤à¥á, ­  ª®â®àë© á¨á⥬  ¯¥à¥¤ ñâ ã¯à ¢«¥­¨¥
; ¯®á«¥ § £à㧪¨ ¯à¨«®¦¥­¨ï ¢ ¯ ¬ïâì
dd i_end ; à §¬¥à ¯à¨«®¦¥­¨ï
dd mem ; Ž¡ê¥¬ ¨á¯®«ì§ã¥¬®© ¯ ¬ïâ¨, ¤«ï á⥪  ®â¢¥¤¥¬ 0å100 ¡ ©â ¨ ¢ë஢­¨¬ ­  £à­¨æã 4 ¡ ©â 
dd mem ; à á¯®«®¦¨¬ ¯®§¨æ¨î á⥪  ¢ ®¡« á⨠¯ ¬ïâ¨, áࠧ㠧  ⥫®¬ ¯à®£à ¬¬ë. ‚¥à設  á⥪  ¢ ¤¨ ¯ §®­¥ ¯ ¬ïâ¨, 㪠§ ­­®¬ ¢ëè¥
dd 0x0 ; 㪠§ â¥«ì ­  áâபã á ¯ à ¬¥âà ¬¨.
dd cur_dir_path
include 'macros.inc'
include 'editbox_ex.mac'
include 'load_lib.mac'
@use_library ;use load lib macros
start:
;universal load library/librarys
sys_load_library library_name, cur_dir_path, library_path, system_path, \
err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
;if return code =-1 then exit, else nornary work
cmp eax,-1
jz exit
mcall 40,0x27 ;ãáâ ­®¢¨âì ¬ áªã ¤«ï ®¦¨¤ ¥¬ëå ᮡë⨩
red_win:
call draw_window ;¯¥à¢®­ ç «ì­® ­¥®¡å®¤¨¬® ­ à¨á®¢ âì ®ª­®
align 4
still: ;®á­®¢­®© ®¡à ¡®â稪
mcall 10 ;Ž¦¨¤ âì ᮡëâ¨ï
dec eax
jz red_win
dec eax
jz key
dec eax
jz button
 
push dword edit1
call [edit_box_mouse]
 
push dword edit2
call [edit_box_mouse]
 
push dword check1
call [check_box_mouse]
 
push dword check2
call [check_box_mouse]
 
push dword Option_boxs
call [option_box_mouse]
 
push dword Option_boxs2
call [option_box_mouse]
 
jmp still ;¥á«¨ ­¨ç¥£® ¨§ ¯¥à¥ç¨á«¥­­®£® â® á­®¢  ¢ 横«
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
button:
mcall 17 ;¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª« ¢¨è¨
test ah,ah ;¥á«¨ ¢ ah 0, â® ¯¥à¥©â¨ ­  ®¡à ¡®â稪 ᮡë⨩ still
jz still
exit: mcall -1
key:
mcall 2 ;§ £à㧨¬ §­ ç¥­¨¥ 2 ¢ ॣ¨áâ®à eax ¨ ¯®«ã稬 ª®¤ ­ ¦ â®© ª« ¢¨è¨
 
push dword edit1
call [edit_box_key]
 
push dword edit2
call [edit_box_key]
 
jmp still
 
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
align 4
draw_window: ;à¨á®¢ ­¨¥ ®ª­  ¯à¨«®¦¥­¨ï
mcall 12,1
mcall 0,(50*65536+390),(30*65536+200),0x33AABBCC,0x805080DD,hed
 
push dword edit1
call [edit_box_draw]
 
push dword edit2
call [edit_box_draw]
 
push dword check1
call [check_box_draw]
 
push dword check2
call [check_box_draw]
 
push dword Option_boxs
call [option_box_draw]
 
push dword Option_boxs2
call [option_box_draw]
 
mcall 12,2
ret
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;DATA ¤ ­­ë¥
;‚ᥣ¤  ᮡ«î¤ âì ¯®á«¥¤®¢ â¥«ì­®áâì ¢ ¨¬¥­¨.
system_path db '/sys/lib/'
library_name db 'box_lib.obj',0
; …᫨ ¥áâì ¦¥« ­¨¥ ࠧꥤ¨­¨âì, â® ­ã¦­® ¨á¯®«ì§®¢ âì á«¥¤ãîé¨î ª®­áâàãªæ¨î
;system_path db '/sys/lib/box_lib.obj',0
;... «î¡ ï ¯®á«¥¤®¢ â¥«ì­®áâì ¤àã£¨å ª®¬ ­¤ ¨ ®¯à¥¤¥«¥­¨©.
;library_name db 'box_lib.obj',0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
err_message_found_lib db 'Sorry I cannot load library box_lib.obj',0
head_f_i:
head_f_l db 'System error',0
err_message_import db 'Error on load import library box_lib.obj',0
 
myimport:
 
edit_box_draw dd aEdit_box_draw
edit_box_key dd aEdit_box_key
edit_box_mouse dd aEdit_box_mouse
version_ed dd aVersion_ed
 
check_box_draw dd aCheck_box_draw
check_box_mouse dd aCheck_box_mouse
version_ch dd aVersion_ch
 
option_box_draw dd aOption_box_draw
option_box_mouse dd aOption_box_mouse
version_op dd aVersion_op
 
dd 0
dd 0
 
aEdit_box_draw db 'edit_box',0
aEdit_box_key db 'edit_box_key',0
aEdit_box_mouse db 'edit_box_mouse',0
aVersion_ed db 'version_ed',0
 
aCheck_box_draw db 'check_box_draw',0
aCheck_box_mouse db 'check_box_mouse',0
aVersion_ch db 'version_ch',0
 
aOption_box_draw db 'option_box_draw',0
aOption_box_mouse db 'option_box_mouse',0
aVersion_op db 'version_op',0
 
 
 
 
check1 check_box 10,45,6,12,0x80AABBCC,0,0,check_text,14,ch_flag_en
check2 check_box 10,60,6,12,0x80AABBCC,0,0,check_text2,15
 
edit1 edit_box 350,3,5,0xffffff,0x6f9480,0,0xAABBCC,0,308,hed,ed_focus,hed_end-hed-1,hed_end-hed-1
edit2 edit_box 350,3,25,0xffffff,0x6a9480,0,0,0,99,ed_buffer,ed_figure_only
 
op1 option_box option_group1,10,90,6,12,0xffffff,0,0,op_text.1,op_text.e1-op_text.1
op2 option_box option_group1,10,105,6,12,0xFFFFFF,0,0,op_text.2,op_text.e2-op_text.2
op3 option_box option_group1,10,120,6,12,0xffffff,0,0,op_text.3,op_text.e3-op_text.3
op11 option_box option_group2,120,90,6,12,0xffffff,0,0,op_text.1,op_text.e1-op_text.1
op12 option_box option_group2,120,105,6,12,0xffffff,0,0,op_text.2,op_text.e2-op_text.2
op13 option_box option_group2,120,120,6,12,0xffffff,0,0,op_text.3,op_text.e3-op_text.3
 
option_group1 dd op1 ;㪠§ â¥«¨, ®­¨ ®â®¡à ¦ îâáï ¯® 㬮«ç ­¨î, ª®£¤  ¢ë¢®¤¨âáï
option_group2 dd op12 ;¯à¨«®¦¥­¨¥
Option_boxs dd op1,op2,op3,0
Option_boxs2 dd op11,op12,op13,0
hed db 'BOXs load from lib <Lrz> date 27.04.2009',0
hed_end:
rb 256
check_text db 'First checkbox'
check_text2 db 'Second checkbox'
op_text: ; ‘®¯à®¢®¦¤ î騩 ⥪áâ ¤«ï 祪 ¡®ªá®¢
.1 db 'Option_Box #1'
.e1:
.2 db 'Option_Box #2'
.e2:
.3 db 'Option_Box #3'
.e3:
ed_buffer rb 100
;-----------------------
;sc system_colors
p_info process_information
cur_dir_path rb 4096
library_path rb 4096
i_end:
rb 1024
mem:
/programs/develop/libraries/box_lib/trunk/editbox_ex.mac
0,0 → 1,78
ed_struc_size=72
struc edit_box width,left,top,color,shift_color,focus_border_color,\
blur_border_color,text_color,max,text,flags,size,pos
{
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Bit mask from editbox
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ed_figure_only= 1000000000000000b ;®¤­¨ ᨬ¢®«ë
ed_always_focus= 100000000000000b
ed_focus= 10b ;䮪ãá ¯à¨«®¦¥­¨ï
ed_shift_on= 1000b ;¥á«¨ ­¥ ãáâ ­®¢«¥­ -§­ ç¨â ¢¯¥à¢ë¥ ­ ¦ â shift,¥á«¨ ¡ë« ãáâ ­®¢«¥­, §­ ç¨â ¬ë 㦥 çâ® - â® ¤¥« «¨ 㤥ন¢ ï shift
ed_shift_on_off=1111111111110111b
ed_shift= 100b ;¢ª«îç ¥âáï ¯à¨ ­ ¦ â¨¨ ­  shift â.¥. ¥á«¨ ­ ¦¨¬ î
ed_shift_off= 1111111111111011b
ed_shift_bac= 10000b ;¡¨â ¤«ï ®ç¨á⪨ ¢ë¤¥«¥­®£® shift â.¥. ¯à¨ ãáâ ­®¢ª¥ £®¢®à¨â çâ® ¥áâì ¢ë¤¥«¥­¨¥
ed_shift_bac_cl=1111111111101111b ;®ç¨á⪠ ¯à¨ 㤠«¥­¨¨ ¢ë¤¥«¥­¨ï
ed_shift_cl= 1111111111100011b
ed_shift_mcl= 1111111111111011b
ed_left_fl= 100000b
ed_right_fl= 1111111111011111b
ed_offset_fl= 1000000b
ed_offset_cl= 1111111110111111b
ed_insert= 10000000b
ed_insert_cl= 1111111101111111b
ed_mouse_on = 100000000b
ed_mous_adn_b= 100011000b
ed_mouse_on_off=1111111011111111b
ed_height=14 ; ¢ëá®â 
 
.width dd width
.left dd left
.top dd top
.color dd color
.shift_color dd shift_color
.focus_border_color dd focus_border_color
.blur_border_color dd blur_border_color
.text_color dd text_color
.max dd max
.text dd text
.flags dd flags+0
.size dd size+0
.pos dd pos+0
.offset dd 0
.cl_curs_x dd 0
.cl_curs_y dd 0
.shift dd 0
.shift_old dd 0
}
struc check_box left,top,ch_text_margin,ch_size,color,border_color,text_color,text,ch_text_length,flags
{ ;áâàãªâãà  ¯ à ¬¥â஢ ¤«ï 祪 ¡®ªá 
ch_flag_en=10b
.left: dw left ;+0 ;¯®«®¦¥­¨¥ ¯® å
.top: dw top ;¯®«®¦¥­¨¥ ¯® ã
.ch_text_margin: dd ch_text_margin ;à ááâ®ï­¨¥ ®â ¯àאַ㣮«ì­¨ª  祪 ¡®ªá  ¤® ­ ¤¯¨á¨
.ch_size: dd ch_size ;à §¬¥à ª¢ ¤à â  祪 ¡®ªá , ¤«ï ¯à¨¬¥à  12
.color: dd color ;梥⠢­ãâਠ祪¡®ªá 
.border_color: dd border_color ;梥â à ¬ª¨
.text_color: dd text_color ;梥⠭ ¤¯¨á¨
.text: dd text ; ¤à¥á ¢ ª®¤¥ ¯à®£à ¬¬ë £¤¥ à á¯®«®¦¥­ ⥪áâ
.ch_text_length: dd ch_text_length ;¤«¨­­  áâப¨ á ᨬ¢®« ¬¨
.flags: dd flags+0 ; ä« £¨
}
struc option_box point_gr,left,top,op_text_margin,op_size,color,border_color,text_color,text,op_text_length,flags
{ ;áâàãªâãà  ¯ à ¬¥â஢ ¤«ï 祪 ¡®ªá 
op_flag_en=10b
.option_group: dd point_gr
.left: dw left ;+0 ;¯®«®¦¥­¨¥ ¯® å
.top: dw top ;¯®«®¦¥­¨¥ ¯® ã
.ch_text_margin: dd op_text_margin ;à ááâ®ï­¨¥ ®â ¯àאַ㣮«ì­¨ª  祪 ¡®ªá  ¤® ­ ¤¯¨á¨
.ch_size: dd op_size ;à §¬¥à ª¢ ¤à â  祪 ¡®ªá , ¤«ï ¯à¨¬¥à  12
.color: dd color ;梥⠢­ãâਠ祪¡®ªá 
.border_color: dd border_color ;梥â à ¬ª¨
.text_color: dd text_color ;梥⠭ ¤¯¨á¨
.text: dd text ; ¤à¥á ¢ ª®¤¥ ¯à®£à ¬¬ë £¤¥ à á¯®«®¦¥­ ⥪áâ
.ch_text_length: dd op_text_length ;¤«¨­­  áâப¨ á ᨬ¢®« ¬¨
.flags: dd flags+0 ; ä« £¨
}
 
/programs/develop/libraries/box_lib/trunk/load_lib.mac
0,0 → 1,533
;08.05.2009 - bugfix
;14.04.2009 - a macros for code load library the box_lib.obj from '/sys/lib/' or current dirrectory.
; The macros for load any library/libraries:
; Copyright (c) 2009, <Lrz>
; 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 Alexey Teplov aka <Lrz> ''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.
;*****************************************************************************
; This macros based on source code:
; <Lrz> - Alexey Teplov / Àëåêñåé Òåïëîâ
; Mario79, Mario - Marat Zakiyanov / Ìàðàò Çàêèÿíîâ
; Diamondz - Evgeny Grechnikov / Åâãåíèé Ãðå÷íèêîâ
;------------------------
; DESCRIPTION
; Macro load_library
; Logick of work.
; A first time we must to check system path, where I belive find a system library. System path is "/sys/lib/".
; If I cannot found my library, i must to check second way. Second way is current dirrectory.
; If we cannot load library, we must show the error message:
; "I'm sorry,the programm cannot found system library box_lib.obj."
; "The find was make on 2 ways: /sys/lib/ and current dirrectory."
;
;
;---------------------------------------------------------------------
; Macro sys_load_library
; A first time we must to check own path in current dirrectory the program, where I belive find a system library.
; If I cannot found my library, i must to check second way. Second way is system path a "/sys/lib/".
; If we cannot load library, we must show the error message:
; "I'm sorry,the programm cannot found system library box_lib.obj."
; "The find was make on 2 ways: /sys/lib/ and current dirrectory."
;
;---------------------------------------------------------------------
; How can I use it?
;---------------------------------------------------------------------
;-Example using single load library
;-universal load library/librarys
;load_library library_name, cur_dir_path, library_path, system_path, \
;err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
;-if return code =-1 then exit, else normally work
; cmp eax,-1
; jz exit
;- Well, if you get
;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;DATA äàííûå
;Âñåãäà ñîáëþäàòü ïîñëåäîâàòåëüíîñòü â èìåíè.
;system_path db '/sys/lib/'
;library_name db 'box_lib.obj',0
; Åñëè åñòü æåëàíèå ðàçúåäèíèòü, òî íóæíî èñïîëüçîâàòü ñëåäóþùèþ êîíñòðóêöèþ
;system_path db '/sys/lib/box_lib.obj',0
;... ëþáàÿ ïîñëåäîâàòåëüíîñòü äðóãèõ êîìàíä è îïðåäåëåíèé.
;library_name db 'box_lib.obj',0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;err_message_found_lib db 'Sorry I cannot found library box_lib.obj',0
;head_f_i:
;head_f_l db 'System error',0
;err_message_import db 'Error on load import library box_lib.obj',0
 
;myimport:
;
;edit_box_draw dd aEdit_box_draw
;edit_box_key dd aEdit_box_key
;edit_box_mouse dd aEdit_box_mouse
;version_ed dd aVersion_ed
;
;check_box_draw dd aCheck_box_draw
;check_box_mouse dd aCheck_box_mouse
;version_ch dd aVersion_ch
;
;option_box_draw dd aOption_box_draw
;option_box_mouse dd aOption_box_mouse
;version_op dd aVersion_op
 
; dd 0
; dd 0
;
;aEdit_box_draw db 'edit_box',0
;aEdit_box_key db 'edit_box_key',0
;aEdit_box_mouse db 'edit_box_mouse',0
;aVersion_ed db 'version_ed',0
 
;aCheck_box_draw db 'check_box_draw',0
;aCheck_box_mouse db 'check_box_mouse',0
;aVersion_ch db 'version_ch',0
 
;aOption_box_draw db 'option_box_draw',0
;aOption_box_mouse db 'option_box_mouse',0
;aVersion_op db 'version_op',0
 
;---------------------------------------------------------------------
macro @use_library
{
show_err_:
local red_win
local still
local button
local __sc
local start
local ex_lp
local lp
local correction
;/equ
err_message1 equ dword [esp+8]
head1 equ dword [esp+4]
 
 
__sc.frame equ dword [__sc+0]
__sc.grab equ dword [__sc+4]
__sc.grab_button equ dword [__sc+8]
__sc.grab_button_text equ dword [__sc+12]
__sc.grab_text equ dword [__sc+16]
__sc.work equ dword [__sc+20]
__sc.work_button equ dword [__sc+24]
__sc.work_button_text equ dword [__sc+28]
__sc.work_text equ dword [__sc+32]
__sc.work_graph equ dword [__sc+36]
 
;local on_x
;local on_y
 
;;;;;;;;;;;CALC WIDTH & HIGHT WINDOW & CENTER MONITOR POSITION;;;;;;;;;;
mov eax,48 ;get system color
mov ebx,3
mov ecx,__sc
mov edx,sizeof.system_colors
mcall
;---------------------------------------------------------------------
;get with text imul on 6 pix
xor eax,eax
mov esi,err_message1
mov ecx,30
align 4
lp: lodsb
test eax,eax
jz ex_lp
add ecx,7
jmp lp
;---------------------------------------------------------------------
ex_lp:
mcall 48,5 ;get system window
sub eax,ecx
sub bx,90
 
shl eax,15
shl ebx,15
 
mov ax,cx
 
mov bx,90
 
mov dword [on_x],eax
mov dword [on_y],ebx
 
; mov eax,dword [esp+4]
; mov dword [header_xx],eax
 
; mov eax,dword [esp+8]
; mov dword [message_xx],eax
 
jmp start
__sc system_colors
on_x dd ?
on_y dd ?
message_xx dd ?
header_xx dd ?
;;;;;;;;;;;DRAW WINDOW;;;;;;;;;;;;;;
start:
mcall 40,0x5 ;set mask on events rewraw window and get id button.
red_win:
;draw_window:
mcall 12,1
 
xor eax,eax
mov ebx,dword [on_x]
mov ecx,dword [on_y]
mov edx,__sc.work
or edx,0x33000000
mov esi,__sc.grab_text
mov edi,head1
mcall
 
mov eax,4
mov ebx,(10*65536+25)
mov ecx,__sc.grab_text
or ecx,0x90000000
mov edx,err_message1
mcall
mcall 12,2
align 4
still: ;main loop
mcall 10 ;wait event
dec eax
jz red_win
sub eax,2
jnz still ;go to main loop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
button:
mcall 17 ;get id button
test ah,ah ;if in ah 0, then go to still
jz still
or dword [esp+40],-1; modify eax in stack (pushad)
ret
 
;---------------------------------------------------------------------
@library_name equ dword [esp+12]
@cur_dir_path equ dword [esp+8]
@library_path equ dword [esp+4]
 
align 4
@copy_path:
mov ebx,@library_name
mov esi,@cur_dir_path
mov edi,@library_path
 
xor eax,eax
cld
.lp1:
lodsb
stosb
test eax,eax
jnz .lp1
mov esi,edi
 
std
.lp2:
lodsb
cmp al,'/'
jnz .lp2
mov edi,esi
mov esi,ebx
add edi,2
 
 
cld
.lp3:
lodsb
stosb
test eax,eax
jnz .lp3
;---------------------------------------------------------------------
ret
}
 
 
 
macro sys_load_library library_name, cur_dir_path, library_path, system_path, err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
{
local end_steep
local exit
;---------------------------------------------------------------------
; loading Box_Lib library
 
mcall 68,19,system_path ; load of sys directory
test eax,eax
jnz end_steep
 
copy_path library_name, cur_dir_path, library_path ;the macros making way /current pach a program/+ name system library
mcall 68,19,library_path ; load of alternative
test eax,eax
jnz end_steep
show_error_window err_message_found_lib, head_f_l ;show error message /create window
jmp exit
 
 
align 4
end_steep:
 
import_boxlib myimport, err_message_import, head_f_i ;import
exit:
;---------------------------------------------------------------------
}
 
 
macro load_library library_name, cur_dir_path, library_path, system_path, err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
{
local end_steep
local exit
;---------------------------------------------------------------------
; loading Box_Lib library
 
copy_path library_name, cur_dir_path, library_path ;the macros making way /current pach a program/+ name system library
 
mcall 68,19,library_path ; load of alternative
test eax,eax
jnz end_steep
mcall 68,19,system_path ; load of sys directory
test eax,eax
jnz end_steep
 
show_error_window err_message_found_lib, head_f_l ;show error message /create window
jmp exit
 
align 4
end_steep:
 
import_boxlib myimport, err_message_import, head_f_i ;import
exit:
;---------------------------------------------------------------------
}
macro sys_load_libraries _start,_end
{
local lp
local end_steep
local next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
library_name equ [ebp]
cur_dir_path equ [ebp+4]
library_path equ [ebp+8]
system_path equ [ebp+12]
err_message_found_lib equ [ebp+16]
head_f_l equ [ebp+20]
my_import equ [ebp+24]
err_message_import equ [ebp+28]
head_f_i equ [ebp+32]
adr_load_lib equ dword [ebp+36]
status_lib equ dword [ebp+40]
 
; show_error_window err_message_found_lib, head_f_l ;show error message /create window
; int 0x40
 
mov ebp,_start
mov ecx,((_end-_start)/ll_struc_size)
 
align 4
lp: push ecx
mcall 68,19,system_path ; load of sys directory
test eax,eax
jnz end_steep
 
copy_path library_name, cur_dir_path, library_path ;the macros making way /current pach a program/+ name system library
mcall 68,19,library_path ; load of alternative
test eax,eax
jnz end_steep
 
or status_lib,0x1 ; status of code - enable error - not found library
 
show_error_window err_message_found_lib, head_f_l ;show error message /create window
jmp next
 
align 4
end_steep:
mov adr_load_lib,eax ;save adr lib in memory
import_boxlib my_import, err_message_import, head_f_i ;import
 
test eax,eax
jz next
 
or status_lib,0x2 ; status of code - enable error - import error
 
next:
pop ecx
add ebp,ll_struc_size
dec ecx
jnz lp
}
 
macro load_libraries _start,_end
{
local lp
local end_steep
local next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
library_name equ [ebp]
cur_dir_path equ [ebp+4]
library_path equ [ebp+8]
system_path equ [ebp+12]
err_message_found_lib equ [ebp+16]
head_f_l equ [ebp+20]
my_import equ [ebp+24]
err_message_import equ [ebp+28]
head_f_i equ [ebp+32]
adr_load_lib equ dword [ebp+36]
status_lib equ dword [ebp+40]
 
mov ebp,_start
mov ecx,((_end-_start)/ll_struc_size)
 
align 4
lp: push ecx
 
copy_path library_name, cur_dir_path, library_path ;the macros making way /current pach a program/+ name system library
 
mcall 68,19,library_path ; load of alternative
test eax,eax
jnz end_steep
mcall 68,19,system_path ; load of sys directory
test eax,eax
jnz end_steep
 
or status_lib,0x1 ; status of code - enable error - not found library
 
show_error_window err_message_found_lib, head_f_l ;show error message /create window
jmp next
 
align 4
end_steep:
mov adr_load_lib,eax ;save adr lib in memory
 
import_boxlib my_import, err_message_import, head_f_i ;import
 
test eax,eax
jz next
 
or status_lib,0x2 ; status of code - enable error - import error
 
next:
pop ecx
add ebp,ll_struc_size
dec ecx
jnz lp
}
 
 
macro copy_path lib_name,dir_path,lib_path
{
pushad ;save all registers
push dword lib_name
push dword dir_path
push dword lib_path
 
call @copy_path
 
add esp,12
popad ;restore all registers
}
 
macro show_error_window err_message, head
{ pushad ;save all registers
push dword err_message
push dword head
 
call show_err_
 
add esp,8
popad ;restore all registers
}
 
 
macro import_boxlib myimport, err_message_import, head_f_i
{
local import_loop
local import_find
local lp
local import_find_next
local import_found
local import_done
local exit
local e.exit
local import_not_found
; initialize import
mov edx, eax
mov esi,myimport
import_loop:
lodsd
test eax, eax
jz import_done
push edx
import_find:
mov ebx, [ds:edx]
test ebx, ebx
jz import_not_found
push eax
lp:
mov cl, [ds:eax]
cmp cl, [ds:ebx]
jnz import_find_next
test cl, cl
jz import_found
inc eax
inc ebx
jmp lp
import_find_next:
pop eax
add edx, 8
jmp import_find
import_found:
pop eax
mov eax, [ds:edx+4]
mov [esi-4], eax
pop edx
jmp import_loop
import_not_found:
add esp,4
show_error_window err_message_import, head_f_i ;show error message /create window
jmp e.exit
import_done:
xor eax,eax
e.exit:
;---------------------------------------------------------------------
}
ll_struc_size = 44;($-library_name) ; constant size of struct
struc l_libs library_name, cur_dir_path, library_path, system_path, err_message_found_lib, head_f_l, my_import, err_message_import, head_f_i; struct for loading libraries
{
.library_name dd library_name
.cur_dir_path dd cur_dir_path
.library_path dd library_path
.system_path dd system_path
.err_message_found_lib dd err_message_found_lib
.head_f_l dd head_f_l
.my_import dd my_import
.err_message_import dd err_message_import
.head_f_i dd head_f_i
.adr_load_lib dd 0x0
.status_lib dd 0x0 ;status of load library
;
 
}
/programs/develop/libraries/box_lib/trunk/run.bat
1,4 → 1,6
if not exist bin mkdir bin
@fasm.exe -m 16384 box_lib.asm bin\box_lib.obj
@kpack bin\box_lib.obj
@fasm.exe -m 16384 box_lib.asm
@fasm.exe -m 16834 editbox_ex.asm editbox_ex.kex
@fasm.exe -m 16384 ctrldemo.asm ctrldemo.kex
REM ..\FASM\kpack.exe editbox_ex
REM @klbrinwin.exe editbox_ex.kex
pause
/programs/develop/libraries/box_lib/trunk/cnv_bmp.obj
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/develop/libraries/box_lib/trunk/reload_16x16_8b.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/develop/libraries/box_lib/trunk/w_about.inc
0,0 → 1,89
;---------------------------------------------------------------------
thread3:
 
call draw_window3
 
still3:
 
mov eax,10 ; wait here for event
mcall
 
cmp eax,1 ; redraw request ?
je thread3
cmp eax,2 ; key in buffer ?
je key3
cmp eax,3 ; button in buffer ?
je button3
 
jmp still3
 
key3:
mcall
cmp ah,27
je close3
jmp still3
 
 
button3: ; button
mov eax,17 ; get id
mcall
 
cmp ah,1 ; button id=1 ?
je close3
cmp ah,2
jne noclose3
close3:
mov eax,-1 ; close this program
mcall
noclose3:
jmp still3
 
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window3:
 
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
mcall
 
; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window
mov ebx,100*65536+200 ; [x start] *65536 + [x size]
mov ecx,100*65536+100 ; [y start] *65536 + [y size]
mov edx,0x03eeeeee ; color of work area RRGGBB,8->color gl
mcall
 
mcall 4,<10,40>,0x80000000,header_1
mov ebx,70*65536+40
mov ecx,70*65536+20
mov edx,2
mov esi,0xdddddd
mcall 8
 
add ebx,15 shl 16
shr ecx,16
mov bx,cx
add ebx,6
mov ecx,0
mov edx, ok_btn
mov esi,2
mcall 4
; WINDOW LABEL
mcall 71,1, labelt3
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
mcall
 
ret
;---------------------------------------------------------------------
/programs/develop/libraries/box_lib/trunk/config.inc
0,0 → 1,0
__CPU_type fix p5
/programs/develop/libraries/box_lib/trunk/macros.inc
0,0 → 1,502
@^ fix macro comment {
^@ fix }
 
 
macro m2m dest,src {
push src
pop dest
}
 
 
macro iglobal {
IGlobals equ IGlobals,
macro __IGlobalBlock { }
macro uglobal {
UGlobals equ UGlobals,
macro __UGlobalBlock { }
 
endg fix } ; Use endg for ending iglobal and uglobal blocks.
 
 
macro IncludeIGlobals{
macro IGlobals dummy,[n] \{ __IGlobalBlock
purge __IGlobalBlock \}
match I, IGlobals \{ I \} }
 
macro IncludeUGlobals{
macro UGlobals dummy,[n] \{
\common
\local begin, size
begin = $
virtual at $
\forward
__UGlobalBlock
purge __UGlobalBlock
\common
size = $ - begin
end virtual
rb size
\}
match U, UGlobals \{ U \} }
 
uglobal
endg
iglobal
endg
 
 
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
IncludeIGlobals
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
IncludeUGlobals
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
; macro for defining multiline text data
struc mls [sstring]
{
forward
local ssize
virtual at 0
db sstring ; mod
ssize = $
end virtual
db ssize
db sstring
common
db -1 ; mod
}
 
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
name db data
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
forward
if lang eq lng
db data
end if
common
.size = $-name
end if
}
 
macro szc name,elsz,[data] { ; from MFAR [mike.dld]
common
local s,m
m = 0
if used name
label name
forward
virtual at 0
db data
s = $
end virtual
d#elsz s
if m < s
m = s
end if
db data
common
.size = $-name
.maxl = m
end if
}
 
macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld]
common
local s,m,c
m = 0
c = 0
if used name
label name
forward
if lang eq lng
virtual at 0
db data
s = $
end virtual
d#elsz s
if m < s
m = s
end if
db data
c = c+1
end if
common
.size = $-name
.maxl = m
.count = c
end if
}
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
 
include 'config.inc'
;__CPU_type equ p5
SYSENTER_VAR equ 0
 
macro mcall a,b,c,d,e,f,i { ; mike.dld, updated by Ghost for Fast System Calls
local ..ret_point
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
__mov ebp,i
 
if __CPU_type eq p5
int 0x40
else
if __CPU_type eq p6
push ebp
mov ebp, esp
push ..ret_point ; it may be 2 or 5 byte
sysenter
..ret_point:
pop edx
pop ecx
 
else
if __CPU_type eq k6
push ecx
syscall
pop ecx
else
display 'ERROR : unknown CPU type'
int 0x40
end if
end if
end if
}
 
 
; -------------------------
macro header a,[b] {
common
use32
org 0
db 'MENUET',a
forward
if b eq
dd 0
else
dd b
end if }
macro section name { align 16
label name }
macro func name {
if ~used name
display 'FUNC NOT USED: ',`name,13,10
else
align 4
name:
;diff16 `name,0,name
;pushad
;pushfd
;dps `name
;newline
;mcall 5,1
;popfd
;popad
}
macro endf { end if }
 
macro diff16 title,l1,l2
{
local s,d
s = l2-l1
display title,': 0x'
repeat 8
d = '0' + s shr ((8-%) shl 2) and $0F
if d > '9'
d = d + 'A'-'9'-1
end if
display d
end repeat
display 13,10
}
 
macro diff10 title,l1,l2
{
local s,d,z,m
s = l2-l1
z = 0
m = 1000000000
display title,': '
repeat 10
d = '0' + s / m
s = s - (s/m)*m
m = m / 10
if d <> '0'
z = 1
end if
if z <> 0
display d
end if
end repeat
display 13,10
}
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro RGB [a] {
common
match (r=,g=,b),a \{
\dd ((r) shl 16) or ((g) shl 8) or (b)
\}
}
 
 
struc POINT _t,_dx,_dy {
.x _t _dx
.y _t _dy
}
 
; structure definition helper
include 'struct.inc'
 
struct RECT
left dd ?
top dd ?
right dd ?
bottom dd ?
ends
 
struct BOX
left dd ?
top dd ?
width dd ?
height dd ?
ends
 
; structures used in MeOS
struct process_information
cpu_usage dd ? ; +0
window_stack_position dw ? ; +4
window_stack_value dw ? ; +6
dw ? ; +8
process_name rb 12 ; +10
memory_start dd ? ; +22
used_memory dd ? ; +26
PID dd ? ; +30
box BOX ; +34
slot_state dw ? ; +50
dw ? ; +52
client_box BOX ; +54
wnd_state db ? ; +70
rb (1024-71)
ends
 
struct system_colors
frame dd ?
grab dd ?
grab_button dd ?
grab_button_text dd ?
grab_text dd ?
work dd ?
work_button dd ?
work_button_text dd ?
work_text dd ?
work_graph dd ?
ends
 
struct FILEDATE
Second db ?
Minute db ?
Hour db ?
db ?
Day db ?
Month db ?
Year dw ?
ends
 
struct FILEINFO
Attributes dd ?
IsUnicode db ?
db 3 dup(?)
DateCreate FILEDATE
DateAccess FILEDATE
DateModify FILEDATE
Size dq ?
ends
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
/programs/develop/libraries/box_lib/trunk/optionbox.mac
126,26 → 126,24
@@:
movzx ebx,word op_left ;çàãðóçèòü êîîðäèíàòó ïî õ
mov eax,dword op_size
mov bp,ax
push ax
shr eax,2
push ax
push ax
add ebx,eax
add ebx,eax ;äîáàâèòü (ñòîðîíà ïðÿìîóãîëüíèêà/3)
shl ebx,16 ;ñäâèíåì íà 16 ðàçðÿäîâ â ëåâî (óìíîæèì íà 65536)
pop ax
lea eax,[eax*2]
sub bp,ax ;ñîõðàíèì ðåãèñòð bx â ðåãèñòðå óêàçàòåëÿ áàçû
mov bx,bp
pop bx
shr bx,1 ;çàãðóçèòü (ñòîðîíà ïðÿìîóãîëüíèêà/2)
mov bp,bx ;ñîõðàíèì ðåãèñòð bx â ðåãèñòðå óêàçàòåëÿ áàçû
 
movzx ecx,word op_top ;çàãðóçèòü êîîðäèíàòó ïî ó
pop ax
add cx,ax
mov eax,dword op_size
shr eax,2
add ecx,eax ;äîáàâèòü (ñòîðîíà ïðÿìîóãîëüíèêà/4)
shl ecx,16 ;ñäâèíåì íà 16 ðàçðÿäîâ â ëåâî (óìíîæèì íà 65536)
mov cx,bp ;çàãðóçèì çíà÷åíèÿ ðåãèñòðà óêàçàòåëÿ áàçû â cx
mov eax,13 ;â eax - çíà÷åíèÿ ôóíêöèè äëÿ âûâîäà ïîëîñû ò.å. ïî ñóòè ïðÿìîóãîëüíèêà, êîòîðûé îòîáðàæàåò âêëþ÷åííûé êîìïîíåíò ÷åê áîêñ
mcall ;âûâîä
ret ;âûéòè èç ïðîöåäóðû
 
}
 
 
/programs/develop/libraries/box_lib/trunk/proc32.inc
0,0 → 1,270
 
; Macroinstructions for defining and calling procedures
 
macro stdcall proc,[arg] ; directly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call proc }
 
macro invoke proc,[arg] ; indirectly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call [proc] }
 
macro ccall proc,[arg] ; directly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call proc
if size@ccall
add esp,size@ccall
end if }
 
macro cinvoke proc,[arg] ; indirectly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call [proc]
if size@ccall
add esp,size@ccall
end if }
 
macro proc [args] ; define procedure
{ common
match name params, args>
\{ define@proc name,<params \} }
 
prologue@proc equ prologuedef
 
macro prologuedef procname,flag,parmbytes,localbytes,reglist
{ if parmbytes | localbytes
push ebp
mov ebp,esp
if localbytes
sub esp,localbytes
end if
end if
irps reg, reglist \{ push reg \} }
 
epilogue@proc equ epiloguedef
 
macro epiloguedef procname,flag,parmbytes,localbytes,reglist
{ irps reg, reglist \{ reverse pop reg \}
if parmbytes | localbytes
leave
end if
if flag and 10000b
retn
else
retn parmbytes
end if }
 
macro define@proc name,statement
{ local params,flag,regs,parmbytes,localbytes,current
if used name
name:
match =stdcall args, statement \{ params equ args
flag = 11b \}
match =stdcall, statement \{ params equ
flag = 11b \}
match =c args, statement \{ params equ args
flag = 10001b \}
match =c, statement \{ params equ
flag = 10001b \}
match =params, params \{ params equ statement
flag = 0 \}
virtual at ebp+8
match =uses reglist=,args, params \{ regs equ reglist
params equ args \}
match =regs =uses reglist, regs params \{ regs equ reglist
params equ \}
match =regs, regs \{ regs equ \}
match =,args, params \{ defargs@proc args \}
match =args@proc args, args@proc params \{ defargs@proc args \}
parmbytes = $ - (ebp+8)
end virtual
name # % = parmbytes/4
all@vars equ
current = 0
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \}
macro locals
\{ virtual at ebp-localbytes+current
macro label def \\{ match . type,def> \\\{ deflocal@proc .,label,<type \\\} \\}
struc db [val] \\{ \common deflocal@proc .,db,val \\}
struc du [val] \\{ \common deflocal@proc .,du,val \\}
struc dw [val] \\{ \common deflocal@proc .,dw,val \\}
struc dp [val] \\{ \common deflocal@proc .,dp,val \\}
struc dd [val] \\{ \common deflocal@proc .,dd,val \\}
struc dt [val] \\{ \common deflocal@proc .,dt,val \\}
struc dq [val] \\{ \common deflocal@proc .,dq,val \\}
struc rb cnt \\{ deflocal@proc .,rb cnt, \\}
struc rw cnt \\{ deflocal@proc .,rw cnt, \\}
struc rp cnt \\{ deflocal@proc .,rp cnt, \\}
struc rd cnt \\{ deflocal@proc .,rd cnt, \\}
struc rt cnt \\{ deflocal@proc .,rt cnt, \\}
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \}
macro endl
\{ purge label
restruc db,du,dw,dp,dd,dt,dq
restruc rb,rw,rp,rd,rt,rq
current = $-(ebp-localbytes)
end virtual \}
macro ret operand
\{ match any, operand \\{ retn operand \\}
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs>
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2
end if \} }
 
macro defargs@proc [arg]
{ common
if ~ arg eq
forward
local ..arg,current@arg
match argname:type, arg
\{ current@arg equ argname
label ..arg type
argname equ ..arg
if dqword eq type
dd ?,?,?,?
else if tbyte eq type
dd ?,?,?
else if qword eq type | pword eq type
dd ?,?
else
dd ?
end if \}
match =current@arg,current@arg
\{ current@arg equ arg
arg equ ..arg
..arg dd ? \}
common
args@proc equ current@arg
forward
restore current@arg
common
end if }
 
macro deflocal@proc name,def,[val]
{ common
match vars, all@vars \{ all@vars equ all@vars, \}
all@vars equ all@vars name
forward
local ..var,..tmp
match =label,def \{ ..tmp equ \}
match tmp,..tmp \{ ..var def val \}
match ,..tmp \{ label ..var val \}
match =?, val \{ ..tmp equ \}
match any =dup (=?), val \{ ..tmp equ \}
match tmp : value, ..tmp : val
\{ tmp: end virtual
initlocal@proc ..var,def value
virtual at tmp\}
common
match first rest, ..var, \{ name equ first \} }
 
macro initlocal@proc name,def
{ virtual at name
def
size@initlocal = $ - name
end virtual
position@initlocal = 0
while size@initlocal > position@initlocal
virtual at name
def
if size@initlocal - position@initlocal < 2
current@initlocal = 1
load byte@initlocal byte from name+position@initlocal
else if size@initlocal - position@initlocal < 4
current@initlocal = 2
load word@initlocal word from name+position@initlocal
else
current@initlocal = 4
load dword@initlocal dword from name+position@initlocal
end if
end virtual
if current@initlocal = 1
mov byte [name+position@initlocal],byte@initlocal
else if current@initlocal = 2
mov word [name+position@initlocal],word@initlocal
else
mov dword [name+position@initlocal],dword@initlocal
end if
position@initlocal = position@initlocal + current@initlocal
end while }
 
macro endp
{ purge ret,locals,endl
finish@proc
purge finish@proc
restore regs@proc
match all,args@proc \{ restore all \}
restore args@proc
match all,all@vars \{ restore all \} }
 
macro local [var]
{ common
locals
forward done@local equ
match varname[count]:vartype, var
\{ match =BYTE, vartype \\{ varname rb count
restore done@local \\}
match =WORD, vartype \\{ varname rw count
restore done@local \\}
match =DWORD, vartype \\{ varname rd count
restore done@local \\}
match =PWORD, vartype \\{ varname rp count
restore done@local \\}
match =QWORD, vartype \\{ varname rq count
restore done@local \\}
match =TBYTE, vartype \\{ varname rt count
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
rq count+count
restore done@local \\}
match , done@local \\{ virtual
varname vartype
end virtual
rb count*sizeof.\#vartype
restore done@local \\} \}
match :varname:vartype, done@local:var
\{ match =BYTE, vartype \\{ varname db ?
restore done@local \\}
match =WORD, vartype \\{ varname dw ?
restore done@local \\}
match =DWORD, vartype \\{ varname dd ?
restore done@local \\}
match =PWORD, vartype \\{ varname dp ?
restore done@local \\}
match =QWORD, vartype \\{ varname dq ?
restore done@local \\}
match =TBYTE, vartype \\{ varname dt ?
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
dq ?,?
restore done@local \\}
match , done@local \\{ varname vartype
restore done@local \\} \}
match ,done@local
\{ var
restore done@local \}
common
endl }
/programs/develop/libraries/box_lib/trunk/struct.inc
0,0 → 1,180
 
; Macroinstructions for defining data structures
 
macro struct name
{ fields@struct equ name
match child parent, name \{ fields@struct equ child,fields@\#parent \}
sub@struct equ
struc db [val] \{ \common fields@struct equ fields@struct,.,db,<val> \}
struc dw [val] \{ \common fields@struct equ fields@struct,.,dw,<val> \}
struc du [val] \{ \common fields@struct equ fields@struct,.,du,<val> \}
struc dd [val] \{ \common fields@struct equ fields@struct,.,dd,<val> \}
struc dp [val] \{ \common fields@struct equ fields@struct,.,dp,<val> \}
struc dq [val] \{ \common fields@struct equ fields@struct,.,dq,<val> \}
struc dt [val] \{ \common fields@struct equ fields@struct,.,dt,<val> \}
struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \}
struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \}
struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \}
struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \}
struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \}
struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \}
macro db [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,db,<val> \}
macro dw [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dw,<val> \}
macro du [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,du,<val> \}
macro dd [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dd,<val> \}
macro dp [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dp,<val> \}
macro dq [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dq,<val> \}
macro dt [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dt,<val> \}
macro rb count \{ \local anonymous
fields@struct equ fields@struct,anonymous,db,count dup (?) \}
macro rw count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dw,count dup (?) \}
macro rd count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dd,count dup (?) \}
macro rp count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dp,count dup (?) \}
macro rq count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dq,count dup (?) \}
macro rt count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dt,count dup (?) \}
macro union \{ fields@struct equ fields@struct,,union,<
sub@struct equ union \}
macro struct \{ fields@struct equ fields@struct,,substruct,<
sub@struct equ substruct \}
virtual at 0 }
 
macro ends
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt
restruc rb,rw,rd,rp,rq,rt
purge db,dw,du,dd,dp,dq,dt
purge rb,rw,rd,rp,rq,rt
purge union,struct
match name=,fields,fields@struct \\{ fields@struct equ
make@struct name,fields
fields@\\#name equ fields \\}
end virtual \}
match any, sub@struct \{ fields@struct equ fields@struct> \}
restore sub@struct }
 
macro make@struct name,[field,type,def]
{ common
if $
display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah
err
end if
local define
define equ name
forward
local sub
match , field \{ make@substruct type,name,sub def
define equ define,.,sub, \}
match any, field \{ define equ define,.#field,type,<def> \}
common
match fields, define \{ define@struct fields \} }
 
macro define@struct name,[field,type,def]
{ common
local list
list equ
forward
if ~ field eq .
name#field type def
sizeof.#name#field = $ - name#field
else
rb sizeof.#type
end if
local value
match any, list \{ list equ list, \}
list equ list <value>
common
sizeof.#name = $
restruc name
match values, list \{
struc name value \\{
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\}
match , fields@struct \\\{ label .
forward
match , value \\\\{ field type def \\\\}
match any, value \\\\{ field type value
if ~ field eq .
rb sizeof.#name#field - ($-field)
end if \\\\}
common \\\} \\} \} }
 
macro enable@substruct
{ macro make@substruct substruct,parent,name,[field,type,def]
\{ \common
\local define
define equ parent,name
\forward
\local sub
match , field \\{ match any, type \\\{ enable@substruct
make@substruct type,name,sub def
purge make@substruct
define equ define,.,sub, \\\} \\}
match any, field \\{ define equ define,.\#field,type,<def> \\}
\common
match fields, define \\{ define@\#substruct fields \\} \} }
 
enable@substruct
 
macro define@union parent,name,[field,type,def]
{ common
virtual at 0
forward
if ~ field eq .
virtual at 0
parent#field type def
sizeof.#parent#field = $ - parent#field
end virtual
if sizeof.#parent#field > $
rb sizeof.#parent#field - $
end if
else if sizeof.#type > $
rb sizeof.#type - $
end if
common
sizeof.#name = $
end virtual
struc name [value] \{ \common
label .\#name
last@union equ
forward
match any, last@union \\{ virtual at .\#name
field type def
end virtual \\}
match , last@union \\{ match , value \\\{ field type def \\\}
match any, value \\\{ field type value \\\} \\}
last@union equ field
common rb sizeof.#name - ($ - .\#name) \} }
 
macro define@substruct parent,name,[field,type,def]
{ common
virtual at 0
forward
if ~ field eq .
parent#field type def
sizeof.#parent#field = $ - parent#field
else
rb sizeof.#type
end if
local value
common
sizeof.#name = $
end virtual
struc name value \{
label .\#name
forward
match , value \\{ field type def \\}
match any, value \\{ field type value
if ~ field eq .
rb sizeof.#parent#field - ($-field)
end if \\}
common \} }