diff --git a/programs/system/docpak/trunk/docpak.asm b/programs/system/docpak/trunk/docpak.asm new file mode 100755 index 0000000000..e2f661fa6d --- /dev/null +++ b/programs/system/docpak/trunk/docpak.asm @@ -0,0 +1,189 @@ +;--------------------------------------------------------------------- +; +; DOCPAK FOR MENUET v1.1 +; Written in pure assembly by Ivushkin Andrey aka Willow +; +;--------------------------------------------------------------------- + +FILE_COUNT=0 +DEF_FILE equ 'g' + +macro embed_file fn +{ + forward + local label,label2,label3 + dd label2-label + dd label-label3 + label3: + db fn + label: + file fn + label2: + FILE_COUNT=FILE_COUNT+1 +} + + use32 + org 0x0 + db 'MENUET01' ; 8 byte id + dd 0x01 ; header version + dd start ; start of code + dd I_END ; size of image + dd I_END+0x400 ; memory for app + dd I_END+0x400 ; esp + dd my_param , 0x0 ; I_Param , I_Icon +include 'MACROS.INC' + +start: + cmp [my_param],0 + je red + cmp [my_param],'a' + jb .par_a + cmp [my_param],'z' + jbe .ok2 + .par_a: + mov [my_param],DEF_FILE + .ok2: + movzx ecx,[my_param] + mov [my_param],'*' + .open: + sub ecx,'a'-1 + mov edx,embedded + xor esi,esi + .list: + lea edx,[edx+esi+8] + mov esi,[edx-8] + add edx,[edx-4] + test esi,esi + jz .close + loop .list + push edx +; convert number in esi to decimal representation + mov ecx, 10 + push -'0' + mov eax, esi +@@: + xor edx, edx + div ecx + push edx + test eax, eax + jnz @b + mov edi, fsize +@@: + pop eax + add al, '0' + stosb + jnz @b + mcall 70,fileinfo + mov ecx,eax + mcall 5,20 + pop edx + mcall 60,2 + cmp [my_param],'*' + jne still + .close: + mcall -1 + +red: + mov [my_param],'a' + mcall 12,1 + mcall 0,<220,120>,<30,FILECOUNT*16+35>,0x3b0b0b0 + mcall 4,<8,8>,0x10ffffff,title,titlen-title + mov ecx,FILECOUNT + mov ebx,10 shl 16+100 + mov esi,0xb0b0b0 + mov edi,27 shl 16+14 + mov edx,10 + mov eax,8 + .btnlp: + push ecx + mcall ,,edi + add edi,16 shl 16 + inc edx + pop ecx + loop .btnlp + mov ecx,FILECOUNT + mov edx,embedded + xor edi,edi + mov ebx,30 shl 16+30 + mov eax,4 + .list: + lea edx,[edx+edi+8] + mov edi,[edx-8] + pusha + sub ebx,15 shl 16 + mcall ,,0xff,my_param,1 + inc [my_param] + popa + push ecx + mcall ,,0xffffff,,[edx-4] + pop ecx + add edx,esi + add ebx,16 + loop .list + mcall 12,2 + +still: + mcall 10 + cmp eax,1 + je red + cmp eax,2 + jne .nokey + mcall 2 + cmp ah,27 ;Esc + je start.close + cmp ah,'a' + jb still + cmp ah,'a'+FILECOUNT + jae still + jmp .cxax + .nokey: + mcall 17 + cmp ah,1 + je start.close + sub ah,10-'a' + .cxax: + movzx ecx,ah + jmp start.open + +title db 'Doc Pack' +titlen: + +fileinfo: + dd 7 + dd 0 + dd param + dd 0, 0 + db '/RD/1/TINYPAD',0 + +param db '*' +fsize: + times 10 db '0' + db 0 + +embedded: + +; Please use only filenames w/o path! + +; -- Start of embedding area ------ + embed_file 'README.TXT' ;a + embed_file 'GNU.TXT' ;b + embed_file 'HOT_KEYS.TXT' ;c + embed_file 'FASM.TXT' ;d + embed_file 'MTDBG.TXT' ;e + embed_file 'VRR_RUS.TXT' ;f + embed_file 'SYSFUNCR.TXT' ;g + embed_file 'PPP_RUS.TXT' ;h + embed_file 'STACK_RU.TXT' ;i + embed_file 'GROBFAR.TXT' ;j +; -- End of embedding area ------- + + dd 0 +FILECOUNT = FILE_COUNT + + if ~ FILECOUNT>0 + error 'No embedded files' + end if + +my_param db 0 + rb 256 +I_END: diff --git a/programs/system/docpak/trunk/macros.inc b/programs/system/docpak/trunk/macros.inc new file mode 100644 index 0000000000..d599dea0e0 --- /dev/null +++ b/programs/system/docpak/trunk/macros.inc @@ -0,0 +1,267 @@ +; 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: + } +DATA fix data + +macro udata + { + if used __params & ~defined __params + __params: + db 0 + __end: + rb 255 + else + __end: + end if + __udata: + } +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 + } + + +; strings +macro sz name,[data] { ; from MFAR [mike.dld] + common + if used name + label name + end if + forward + if used name + db data + end if + common + if used name + .size = $-name + end if +} + +macro lsz name,[lng,data] { ; from MFAR [mike.dld] + common + if used name + label name + end if + forward + if (used name)&(lang eq lng) + db data + end if + common + if used name + .size = $-name + 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 +} + +macro mcall a,b,c,d,e,f { ; mike.dld + __mov eax,a + __mov ebx,b + __mov ecx,c + __mov edx,d + __mov esi,e + __mov edi,f + int 0x40 +} + + + + + + + +; 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) + 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 struct name + { + virtual at 0 + name name + sizeof.#name = $ - name + end virtual + } + +; structures used in MeOS +struc process_information + { + .cpu_usage dd ? ; +0 + .window_stack_position dw ? ; +4 + .window_stack_value dw ? ; +6 + .not_used1 dw ? ; +8 + .process_name rb 12 ; +10 + .memory_start dd ? ; +22 + .used_memory dd ? ; +26 + .PID dd ? ; +30 + .x_start dd ? ; +34 + .y_start dd ? ; +38 + .x_size dd ? ; +42 + .y_size dd ? ; +46 + .slot_state dw ? ; +50 + rb (1024-52) + } +struct process_information + +struc 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 ? + } +struct system_colors + + +; 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