diff --git a/programs/develop/libraries/box_lib/asm/trunk/build.bat b/programs/develop/libraries/box_lib/asm/trunk/build.bat new file mode 100644 index 0000000000..763558ae74 --- /dev/null +++ b/programs/develop/libraries/box_lib/asm/trunk/build.bat @@ -0,0 +1,11 @@ +REM compiling examples +if not exist bin mkdir bin +@fasm.exe -m 16384 ctrldemo.asm bin\ctrldemo.kex +@kpack bin\ctrldemo.kex +@copy cnv_bmp.obj bin\cnv_bmp.obj +@copy reload_16x16_8b.bmp bin\reload_16x16_8b.bmp + +@fasm.exe -m 16384 editbox_ex.asm bin\editbox_ex.kex +@kpack bin\editbox_ex.kex + +pause \ No newline at end of file diff --git a/programs/develop/libraries/box_lib/trunk/cnv_bmp.obj b/programs/develop/libraries/box_lib/asm/trunk/cnv_bmp.obj similarity index 100% rename from programs/develop/libraries/box_lib/trunk/cnv_bmp.obj rename to programs/develop/libraries/box_lib/asm/trunk/cnv_bmp.obj diff --git a/programs/develop/libraries/box_lib/trunk/ctrldemo.asm b/programs/develop/libraries/box_lib/asm/trunk/ctrldemo.asm similarity index 96% rename from programs/develop/libraries/box_lib/trunk/ctrldemo.asm rename to programs/develop/libraries/box_lib/asm/trunk/ctrldemo.asm index 879061b87c..2875702510 100644 --- a/programs/develop/libraries/box_lib/trunk/ctrldemo.asm +++ b/programs/develop/libraries/box_lib/asm/trunk/ctrldemo.asm @@ -40,7 +40,7 @@ dd 0x0 dd path -include 'MACROS.INC' +include '../../../../../macros.inc' include 'load_lib.mac' ;--------------------------------------------------------------------- ;--- Start of program ---------------------------------------------- diff --git a/programs/develop/libraries/box_lib/asm/trunk/d_button.mac b/programs/develop/libraries/box_lib/asm/trunk/d_button.mac new file mode 100644 index 0000000000..d946148930 --- /dev/null +++ b/programs/develop/libraries/box_lib/asm/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 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 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 +} diff --git a/programs/develop/libraries/box_lib/trunk/data.inc b/programs/develop/libraries/box_lib/asm/trunk/data.inc similarity index 100% rename from programs/develop/libraries/box_lib/trunk/data.inc rename to programs/develop/libraries/box_lib/asm/trunk/data.inc diff --git a/programs/develop/libraries/box_lib/trunk/editbox_ex.asm b/programs/develop/libraries/box_lib/asm/trunk/editbox_ex.asm similarity index 96% rename from programs/develop/libraries/box_lib/trunk/editbox_ex.asm rename to programs/develop/libraries/box_lib/asm/trunk/editbox_ex.asm index b1df48e18a..24dde9b2a9 100644 --- a/programs/develop/libraries/box_lib/trunk/editbox_ex.asm +++ b/programs/develop/libraries/box_lib/asm/trunk/editbox_ex.asm @@ -10,7 +10,9 @@ use32 ; dd mem ; à á¯®«®¦¨¬ ¯®§¨æ¨î á⥪  ¢ ®¡« á⨠¯ ¬ïâ¨, áࠧ㠧  ⥫®¬ ¯à®£à ¬¬ë. ‚¥à設  á⥪  ¢ ¤¨ ¯ §®­¥ ¯ ¬ïâ¨, 㪠§ ­­®¬ ¢ëè¥ dd 0x0 ; 㪠§ â¥«ì ­  áâபã á ¯ à ¬¥âà ¬¨. dd cur_dir_path -include 'macros.inc' + + +include '../../../../../macros.inc' include 'editbox_ex.mac' include 'load_lib.mac' @use_library ;use load lib macros diff --git a/programs/develop/libraries/box_lib/trunk/editbox_ex.mac b/programs/develop/libraries/box_lib/asm/trunk/editbox_ex.mac similarity index 100% rename from programs/develop/libraries/box_lib/trunk/editbox_ex.mac rename to programs/develop/libraries/box_lib/asm/trunk/editbox_ex.mac diff --git a/programs/develop/libraries/box_lib/trunk/load_lib.mac b/programs/develop/libraries/box_lib/asm/trunk/load_lib.mac similarity index 100% rename from programs/develop/libraries/box_lib/trunk/load_lib.mac rename to programs/develop/libraries/box_lib/asm/trunk/load_lib.mac diff --git a/programs/develop/libraries/box_lib/trunk/reload_16x16_8b.bmp b/programs/develop/libraries/box_lib/asm/trunk/reload_16x16_8b.bmp similarity index 100% rename from programs/develop/libraries/box_lib/trunk/reload_16x16_8b.bmp rename to programs/develop/libraries/box_lib/asm/trunk/reload_16x16_8b.bmp diff --git a/programs/develop/libraries/box_lib/trunk/w_about.inc b/programs/develop/libraries/box_lib/asm/trunk/w_about.inc similarity index 100% rename from programs/develop/libraries/box_lib/trunk/w_about.inc rename to programs/develop/libraries/box_lib/asm/trunk/w_about.inc diff --git a/programs/develop/libraries/box_lib/trunk/box_lib.asm b/programs/develop/libraries/box_lib/trunk/box_lib.asm index e17b1e422b..015ee66474 100644 --- a/programs/develop/libraries/box_lib/trunk/box_lib.asm +++ b/programs/develop/libraries/box_lib/trunk/box_lib.asm @@ -8,7 +8,7 @@ format MS COFF 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 diff --git a/programs/develop/libraries/box_lib/trunk/config.inc b/programs/develop/libraries/box_lib/trunk/config.inc deleted file mode 100644 index dc70bf9760..0000000000 --- a/programs/develop/libraries/box_lib/trunk/config.inc +++ /dev/null @@ -1 +0,0 @@ -__CPU_type fix p5 diff --git a/programs/develop/libraries/box_lib/trunk/macros.inc b/programs/develop/libraries/box_lib/trunk/macros.inc deleted file mode 100644 index e5de532755..0000000000 --- a/programs/develop/libraries/box_lib/trunk/macros.inc +++ /dev/null @@ -1,502 +0,0 @@ -@^ 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 - -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 \ No newline at end of file diff --git a/programs/develop/libraries/box_lib/trunk/optionbox.mac b/programs/develop/libraries/box_lib/trunk/optionbox.mac index fd12336d0b..8818549f00 100644 --- a/programs/develop/libraries/box_lib/trunk/optionbox.mac +++ b/programs/develop/libraries/box_lib/trunk/optionbox.mac @@ -126,24 +126,26 @@ option_box_draw_op: ; @@: movzx ebx,word op_left ;çàãðóçèòü êîîðäèíàòó ïî õ mov eax,dword op_size - push ax + mov bp,ax shr eax,2 - add ebx,eax ;äîáàâèòü (ñòîðîíà ïðÿìîóãîëüíèêà/3) + push ax + + push ax + add ebx,eax shl ebx,16 ;ñäâèíåì íà 16 ðàçðÿäîâ â ëåâî (óìíîæèì íà 65536) - pop bx - shr bx,1 ;çàãðóçèòü (ñòîðîíà ïðÿìîóãîëüíèêà/2) - mov bp,bx ;ñîõðàíèì ðåãèñòð bx â ðåãèñòðå óêàçàòåëÿ áàçû + pop ax + lea eax,[eax*2] + sub bp,ax ;ñîõðàíèì ðåãèñòð bx â ðåãèñòðå óêàçàòåëÿ áàçû + mov bx,bp movzx ecx,word op_top ;çàãðóçèòü êîîðäèíàòó ïî ó - mov eax,dword op_size - shr eax,2 - add ecx,eax ;äîáàâèòü (ñòîðîíà ïðÿìîóãîëüíèêà/4) + pop ax + add cx,ax shl ecx,16 ;ñäâèíåì íà 16 ðàçðÿäîâ â ëåâî (óìíîæèì íà 65536) mov cx,bp ;çàãðóçèì çíà÷åíèÿ ðåãèñòðà óêàçàòåëÿ áàçû â cx mov eax,13 ;â eax - çíà÷åíèÿ ôóíêöèè äëÿ âûâîäà ïîëîñû ò.å. ïî ñóòè ïðÿìîóãîëüíèêà, êîòîðûé îòîáðàæàåò âêëþ÷åííûé êîìïîíåíò ÷åê áîêñ mcall ;âûâîä ret ;âûéòè èç ïðîöåäóðû - } @@ -166,8 +168,8 @@ pusha @@: mov esi,dword op_text_length ;çàãðóçèòü êîë-âî ñèìâîëîâ â òåêñòîâîé ñòðîêå ;Óìíîæåíèå íà 6 Áûñòðîå óìíîæåíèå ìîæíî âîñïîëüçîâàòüñÿ ëþáûì ìç ìåòîäîâ, íî íà ñòàðûõ Ïðîöåññîðàõ (386,486,P1)áûñòðåå áóäåò ñ èíñòðóêöèåé Lea - ;lea esi,[eax*2+eax] - ;shl eax,1 +; lea esi,[eax*2+eax] +; shl eax,1 imul esi,6 ; èëè ìîæíî è òàê óìíîæèòü íà 6 xor ebx,ebx add esi,dword op_text_margin ;äîáàâèòü 3 - ðàññòîÿíèå îò ÷åê áîêñà äî íàäïèñè diff --git a/programs/develop/libraries/box_lib/trunk/proc32.inc b/programs/develop/libraries/box_lib/trunk/proc32.inc deleted file mode 100644 index aa3ffc9702..0000000000 --- a/programs/develop/libraries/box_lib/trunk/proc32.inc +++ /dev/null @@ -1,270 +0,0 @@ - -; 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, \{ prologue name,flag,parmbytes,localbytes,reglist \} - macro locals - \{ virtual at ebp-localbytes+current - macro label def \\{ match . type,def> \\\{ deflocal@proc .,label, - \\\{ 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 } diff --git a/programs/develop/libraries/box_lib/trunk/run.bat b/programs/develop/libraries/box_lib/trunk/run.bat index 412f8adf65..551c174cc1 100644 --- a/programs/develop/libraries/box_lib/trunk/run.bat +++ b/programs/develop/libraries/box_lib/trunk/run.bat @@ -1,6 +1,4 @@ -@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 +if not exist bin mkdir bin +@fasm.exe -m 16384 box_lib.asm bin\box_lib.obj +@kpack bin\box_lib.obj pause \ No newline at end of file diff --git a/programs/develop/libraries/box_lib/trunk/struct.inc b/programs/develop/libraries/box_lib/trunk/struct.inc deleted file mode 100644 index 947a84e89a..0000000000 --- a/programs/develop/libraries/box_lib/trunk/struct.inc +++ /dev/null @@ -1,180 +0,0 @@ - -; 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, \} - struc dw [val] \{ \common fields@struct equ fields@struct,.,dw, \} - struc du [val] \{ \common fields@struct equ fields@struct,.,du, \} - struc dd [val] \{ \common fields@struct equ fields@struct,.,dd, \} - struc dp [val] \{ \common fields@struct equ fields@struct,.,dp, \} - struc dq [val] \{ \common fields@struct equ fields@struct,.,dq, \} - struc dt [val] \{ \common fields@struct equ fields@struct,.,dt, \} - 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, \} - macro dw [val] \{ \common \local anonymous - fields@struct equ fields@struct,anonymous,dw, \} - macro du [val] \{ \common \local anonymous - fields@struct equ fields@struct,anonymous,du, \} - macro dd [val] \{ \common \local anonymous - fields@struct equ fields@struct,anonymous,dd, \} - macro dp [val] \{ \common \local anonymous - fields@struct equ fields@struct,anonymous,dp, \} - macro dq [val] \{ \common \local anonymous - fields@struct equ fields@struct,anonymous,dq, \} - macro dt [val] \{ \common \local anonymous - fields@struct equ fields@struct,anonymous,dt, \} - 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, \} - 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 - common - sizeof.#name = $ - restruc name - match values, list \{ - struc name value \\{ - match any, fields@struct \\\{ fields@struct equ fields@struct,.,name, \\\} - 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, \\} - \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 \} }