From cdf5c48fbba1d80994e3c0569d51ffd0e2538a4f Mon Sep 17 00:00:00 2001 From: pavelyakov Date: Thu, 16 Jul 2015 01:44:30 +0000 Subject: [PATCH] Fixed bugs, new functions. git-svn-id: svn://kolibrios.org@5576 a494cfbc-eb01-0410-851d-a64ba20cac60 --- data/common/File Managers/eolite.ini | 2 +- programs/cmm/eolite/Eolite.c | 125 +++++---------- programs/cmm/eolite/include/about.h | 18 ++- programs/cmm/eolite/include/left_panel.h | 64 +++++--- programs/cmm/eolite/include/menu.h | 12 +- programs/cmm/eolite/include/properties.h | 30 ++-- programs/cmm/eolite/include/settings.h | 35 ++-- programs/cmm/lib/dll.h | 23 ++- programs/cmm/lib/file_system.h | 19 ++- programs/cmm/lib/kolibri.h | 195 ++++++++++++++++++++--- programs/cmm/lib/obj/http.h | 27 ++-- programs/cmm/lib/random.h | 41 +++++ programs/cmm/lib/strings.h | 155 +++++++++++++++--- 13 files changed, 534 insertions(+), 212 deletions(-) diff --git a/data/common/File Managers/eolite.ini b/data/common/File Managers/eolite.ini index 3aed230773..85e34d2c4c 100644 --- a/data/common/File Managers/eolite.ini +++ b/data/common/File Managers/eolite.ini @@ -4,4 +4,4 @@ LineHeight=18 ShowDeviceName=1 RealFileNamesCase=0 InfoAfterCopy=0 -TimeDoubleClick=100 \ No newline at end of file +TimeDoubleClick=70 \ No newline at end of file diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 18ca6b4f9d..ae23ebb167 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -164,7 +164,7 @@ edit_box edit2 = {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xFFFFFF,0,248,#file_nam edit_box new_file_ed = {150,213,80,0xFFFFFF,0x94AECE,0x000000,0xFFFFFF,0,248,#new_element_name,#mouse_dd,100000000000010b,6,0}; PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0}; PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0}; - +byte cmd_free; #include "include\copy.h" #include "include\gui.h" #include "include\sorting.h" @@ -176,6 +176,8 @@ PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #t #include "include\settings.h" #include "include\properties.h" +dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak; + void main() { word key, id, can_show, can_select, m_selected; @@ -202,7 +204,7 @@ void main() } Open_Dir(#path,ONLY_OPEN); SetEventMask(0x27); - loop() switch(WaitEvent()) + loop(){ switch(WaitEvent()) { case evMouse: if (del_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2) break; @@ -255,67 +257,18 @@ void main() stats = 0; } } - } - - /* - if (files.MouseOver(m.x, m.y)) && (!can_select) - { - m_selected = m.y - files.y / files.line_h; - if (m.lkm) can_select = 1; - if (m.pkm) - { - can_show = 1; - if (m.y - files.y / files.line_h != files.current) can_select = 1; - } - } - - //select/open file { - if (!m.lkm) && (!m.pkm) && (can_select) - { - can_select = 0; - if (m.y>=files.y) - { - id = m.y - files.y / files.line_h; - if (id!=m_selected) - { - can_show=0; - break; - } - if (files.current!=id) - { - if (id=files.y) - { - SwitchToAnotherThread(); - CreateThread(#FileMenu,#menu_stak+4092); - } - break; - } - // } file menu - */ - - if (files.MouseOver(m.x, m.y))&&(m.up) + } + if (files.MouseOver(m.x, m.y))&&((m.up)||(m.down)||(m.dblclick)) { //select/open file { - if (m.key&MOUSE_LEFT) + if (m.key&MOUSE_LEFT)&&((m.down)||(m.dblclick)) { if (m.y>=files.y)//&&(m.click) { id = m.y - files.y / files.line_h; if (files.current!=id) { + m.clearTime(); if (id=files.y)&&(m.click) + if (m.y>=files.y)//&&(m.click) { id = m.y - files.y / files.line_h; if (files.current!=id) List_Current(id-files.current); - SwitchToAnotherThread(); - CreateThread(#FileMenu,#menu_stak+4092); + //SwitchToAnotherThread(); + menu_stak = malloc(4096); + CreateThread(#FileMenu,menu_stak+4092); } break; } @@ -427,7 +381,8 @@ void main() Copy(#file_path, NOCUT); break; case 26: //paste - CreateThread(#Paste,#copy_stak+4092); + copy_stak = malloc(4096); + CreateThread(#Paste,copy_stak+4092); break; case 31...33: //sort IF(sort_num==1) DrawFilledBar(sorting_arrow_x,42,6,10); @@ -500,7 +455,8 @@ void main() Copy(#file_path, NOCUT); break; case 022: //Ctrl+V - CreateThread(#Paste,#copy_stak+4092); + copy_stak = malloc(4096); + CreateThread(#Paste,copy_stak+4092); break; case 001: //Ctrl+A debugln("press Ctrl+A"); @@ -530,8 +486,9 @@ void main() break; case 074: //menu menu_call_mouse=0; - SwitchToAnotherThread(); - CreateThread(#FileMenu,#menu_stak+4092); + //SwitchToAnotherThread(); + menu_stak = malloc(4096); + CreateThread(#FileMenu,menu_stak+4092); break; case 173: //Ctrl+Enter if (!itdir) ShowOpenWithDialog(); @@ -591,6 +548,15 @@ void main() draw_window(); if (action_buf) { menu_action(action_buf); action_buf=0;} } + if(cmd_free){ + if(cmd_free==1) free(menu_stak); + else if(cmd_free==2)free(about_stak); + else if(cmd_free==3)free(properties_stak); + else if(cmd_free==4)free(settings_stak); + else if(cmd_free==5)free(copy_stak); + cmd_free = 0; + } + } } @@ -619,7 +585,7 @@ void menu_action(dword id) if (id==203) FnProcess(4); //F4 if (id==104) Copy(#file_path, NOCUT); if (id==105) Copy(#file_path, CUT); - if (id==106) CreateThread(#Paste,#copy_stak+4092); + if (id==106) { copy_stak = malloc(4096); CreateThread(#Paste,copy_stak+4092);} if (id==207) FnProcess(2); if (id==108) Del_Form(); if (id==109) FnProcess(5); @@ -645,7 +611,7 @@ void draw_window() DrawBar(246,0,Form.cwidth - 297,12, sc.work); //upper editbox DrawBar(246,29,Form.cwidth - 297,5,sc.work); //under editbox DrawRectangle(246,12,Form.cwidth - 303,16,sc.work_graph); - DefineButton(Form.cwidth - 25,6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about + DefineButton(Form.cwidth - 32,6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal); //main rectangles DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),sc.work_graph); @@ -899,9 +865,10 @@ void Del_Form() } if (cont) { - strcpy(#f_count, DEL_MORE_FILES_1); + /*strcpy(#f_count, DEL_MORE_FILES_1); strcat(#f_count, itoa(cont)); - strcat(#f_count, DEL_MORE_FILES_2); + strcat(#f_count, DEL_MORE_FILES_2);*/ + sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,cont,DEL_MORE_FILES_2); WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,sc.work_text,#f_count); } else @@ -1157,15 +1124,16 @@ void NewElement_Form(byte crt, dword strng) DrawFlatButton(dform_x+120,208,70,20,302,0xC6DFC6,T_CANCEL); } -void FnProcess(char N) +void FnProcess(byte N) { switch(N) { case 1: if (!active_about) { - SwitchToAnotherThread(); - about_window=CreateThread(#about_dialog,#about_stak+4092); + //SwitchToAnotherThread(); + about_stak = malloc(4096); + about_window = CreateThread(#about_dialog,about_stak+4092); break; } else @@ -1231,14 +1199,16 @@ void FnProcess(char N) NewElement_Form(1, T_NEW_FILE); break; case 8: - SwitchToAnotherThread(); - CreateThread(#properties_dialog, #properties_stak+4092); + //SwitchToAnotherThread(); + properties_stak = malloc(8096); + CreateThread(#properties_dialog, properties_stak+8092); break; case 10: //F10 if (!active_settings) { - SwitchToAnotherThread(); - settings_window=CreateThread(#settings_dialog, #settings_stak+4092); + //SwitchToAnotherThread(); + settings_stak = malloc(4096); + settings_window = CreateThread(#settings_dialog, settings_stak+4092); break; } else @@ -1254,10 +1224,3 @@ dword onTop(dword down,up) {EAX=Form.height-GetSkinHeight()-down-up;} stop: - -char menu_stak[4096]; -char copy_stak[4096]; -char open_with_stak[4096]; -char about_stak[4096]; -char properties_stak[4096]; -char settings_stak[4096]; \ No newline at end of file diff --git a/programs/cmm/eolite/include/about.h b/programs/cmm/eolite/include/about.h index 486aedb2c5..5cd884e59c 100644 --- a/programs/cmm/eolite/include/about.h +++ b/programs/cmm/eolite/include/about.h @@ -25,7 +25,7 @@ void about_dialog() byte id; proc_info about_form; - IF (active_about) ExitProcess(); + IF (active_about){cmd_free = 2;ExitProcess();} active_about=1; loop() switch(WaitEvent()) { @@ -34,6 +34,7 @@ void about_dialog() IF (id==1) || (id==10) { active_about=0; + cmd_free = 2; ExitProcess(); } IF (id==23) RunProgram(BROWSER_PATH, BROWSER_LINK); @@ -43,23 +44,24 @@ void about_dialog() IF (GetKey()==27) { active_about=0; + cmd_free = 2; ExitProcess(); } break; case evReDraw: - DefineAndDrawWindow(Form.left + 200,150,181,228+GetSkinHeight(),0x34,sc.work,INTRO_TEXT_1); + DefineAndDrawWindow(Form.left+Form.width/2,Form.top+Form.height/2-114,300,228+GetSkinHeight(),0x34,sc.work,INTRO_TEXT_1); GetProcessInfo(#about_form, SelfInfo); if (Form.status_window>2) break; DrawBar(0,0,about_form.cwidth,50,0x8494C4); - PutPaletteImage(#logo,85,85,43,7,8,#logo_pal); - WriteTextB(46,100,0x90,0xBF40BF,ABOUT_TITLE); + PutPaletteImage(#logo,85,85,about_form.width/2-43,7,8,#logo_pal); + WriteTextB(about_form.width/2-46,100,0x90,0xBF40BF,ABOUT_TITLE); WriteTextCenter(0,120,about_form.cwidth,0,INTRO_TEXT_2); - WriteTextCenter(0,130,about_form.cwidth,0,"Leency Veliant PunkJoker"); + WriteTextCenter(0,130,about_form.cwidth,0,"Leency Veliant PunkJoker Pavelyakov"); WriteTextCenter(0,140,about_form.cwidth,0,"KolibriOS Team"); WriteTextCenter(0,150,about_form.cwidth,0,"2008-2015"); - WriteTextCenter(10,170,70,0,INTRO_TEXT_3); - DrawLink(71,170,0x80,23, "kolibri-n.org"); - DrawFlatButton(85,190,70,22,10,0xE4DFE1, INTRO_TEXT_4); + WriteTextCenter(10,170,about_form.width-125,0,INTRO_TEXT_3); + DrawLink(about_form.width/2-15,170,0x80,23, "kolibri-n.org"); + DrawFlatButton(about_form.width/2-35,about_form.height-60,70,22,10,0xE4DFE1, INTRO_TEXT_4); } } \ No newline at end of file diff --git a/programs/cmm/eolite/include/left_panel.h b/programs/cmm/eolite/include/left_panel.h index 7e06b10c95..07c59659d4 100644 --- a/programs/cmm/eolite/include/left_panel.h +++ b/programs/cmm/eolite/include/left_panel.h @@ -9,6 +9,15 @@ 60, "Ќ бва®©ЄЁ", "F10", 0,0,0 }; + ?define T_PROG "Џа®Ја ¬¬л " + ?define T_SYS "‘Ёб⥬  " + ?define T_UNC "ЌҐЁ§ўҐбв­® " + ?define T_CD "CD-ROM " + ?define T_FD "„ЁбЄҐв  " + ?define T_HD "†ҐбвЄЁ© ¤ЁбЄ " + ?define T_SATA "SATA ¤ЁбЄ " + ?define T_USB "USB ¤ЁбЄ " + ?define T_RAM "RAM ¤ЁбЄ " #elif LANG_EST ?define T_DEVICES "Seadmed" ?define T_ACTIONS "Toimingud" @@ -18,6 +27,15 @@ 60, "Seaded", "F10", 0,0,0 }; + ?define T_PROG "Programs " + ?define T_SYS "System " + ?define T_UNC "Unknown " + ?define T_CD "CD-ROM " + ?define T_FD "Floppy disk " + ?define T_HD "Hard disk " + ?define T_SATA "SATA disk" + ?define T_USB "USB disk" + ?define T_RAM "RAM disk" #else ?define T_DEVICES "Devices" ?define T_ACTIONS "Actions" @@ -27,6 +45,15 @@ 60, "Settings", "F10", 0,0,0 }; + ?define T_PROG "Programs " + ?define T_SYS "System " + ?define T_UNC "Unknown " + ?define T_CD "CD-ROM " + ?define T_FD "Floppy disk " + ?define T_HD "Hard disk " + ?define T_SATA "SATA disk" + ?define T_USB "USB disk" + ?define T_RAM "RAM disk" #endif @@ -50,7 +77,7 @@ dword devbuf; void GetSystemDiscs() { char dev_name[10], sys_discs[10]; - int i1, j1, dev_num, dev_disc_num; + int i1, j1, dev_num, dev_disc_num,l; disc_num=0; if (devbuf) free(devbuf); devbuf = malloc(10000); //буфер где-то на 10 девайсов в левой панели @@ -58,28 +85,25 @@ void GetSystemDiscs() dev_num = EBX; for (i1=0; i18) files.line_h--; + if (id==27) MOUSE_TIME++; + if (id==28) && (MOUSE_TIME>30) MOUSE_TIME--; DrawSettingsCheckBoxes(); break; @@ -72,17 +83,19 @@ void settings_dialog() { active_settings = 0; action_buf = 300; + cmd_free = 4; ExitProcess(); } break; case evReDraw: - DefineAndDrawWindow(Form.left + 100, 150, 300, 232+GetSkinHeight(),0x34,sc.work,TITLE_SETT); + DefineAndDrawWindow(Form.left + Form.width/2, Form.top + Form.height/2 - 75, 300, 232+GetSkinHeight(),0x34,sc.work,TITLE_SETT); GetProcessInfo(#settings_form, SelfInfo); DrawSettingsCheckBoxes(); - DrawFlatButton(9, 138, strlen(EDIT_FILE_ASSOCIATIONS)+4*6, 22, 5, 0xE4DFE1, EDIT_FILE_ASSOCIATIONS); - DrawFlatButton(128, settings_form.cheight - 34, 70, 22, 10, 0xE4DFE1, APPLY_T); - DrawFlatButton(208, settings_form.cheight - 34, 70, 22, 11, 0xE4DFE1, CANCEL_T); + DrawFlatButton(9, 168, strlen(EDIT_FILE_ASSOCIATIONS)+4*6, 22, 5, 0xE4DFE1, EDIT_FILE_ASSOCIATIONS); + DrawFlatButton(128, settings_form.cheight - 30, 70, 22, 10, 0xE4DFE1, APPLY_T); + DrawFlatButton(208, settings_form.cheight - 30, 70, 22, 11, 0xE4DFE1, CANCEL_T); + } } } @@ -93,6 +106,7 @@ void DrawSettingsCheckBoxes() CheckBox2(10, 55, 22, NOTIFY_COPY_END, info_after_copy); CheckBox2(10, 77, 23, USE_BIG_FONTS, use_big_fonts); MoreLessBox(10, 104, 18, 25, 26, #sc, files.line_h, LIST_LINE_HEIGHT); + MoreLessBox(10, 134, 18, 27, 28, #sc, MOUSE_TIME, T_DOUBLE_CLICK); } @@ -127,6 +141,7 @@ void SaveIniSettings() ini_set_int stdcall (eolite_ini_path, #confir_section, "InfoAfterCopy", info_after_copy); ini_set_int stdcall (eolite_ini_path, #confir_section, "UseBigFonts", use_big_fonts); ini_set_int stdcall (eolite_ini_path, #confir_section, "LineHeight", files.line_h); + ini_set_int stdcall (eolite_ini_path, #confir_section, "TimeDoubleClick", MOUSE_TIME); } @@ -137,11 +152,9 @@ void Write_Error(int error_number) dword ii; if (files.current>=0) Line_ReDraw(0xFF0000, files.current); pause(5); - strcpy(#error_message, "\"Eolite\n"); - ii = get_error(error_number); - strcat(#error_message, ii); - strcat(#error_message, "\" -tE"); + sprintf(#error_message,"\"%s\n%s\" -%s","Eolite",get_error(error_number),"tE"); notify(#error_message); + } diff --git a/programs/cmm/lib/dll.h b/programs/cmm/lib/dll.h index 4ded672717..1b46ef8cef 100644 --- a/programs/cmm/lib/dll.h +++ b/programs/cmm/lib/dll.h @@ -1,12 +1,32 @@ char a_libdir[43] = "/sys/lib/\0"; +:inline void error_init(dword text) +{ + dword l,ll; + dword TEXT_ERROR = malloc(1024); + #ifdef LANG_RUS + strcpy(TEXT_ERROR,"'ЋиЁЎЄ  ЇаЁ § Јаг§ЄҐ ЎЁЎ«Ё®вҐЄЁ `"); + #elif LANG_EST + strcpy(TEXT_ERROR,"'Viga teegi laadimisel `"); + #else + strcpy(TEXT_ERROR,"'Error while loading library `"); + #endif + ll = strlen(TEXT_ERROR); + strcpy(TEXT_ERROR+ll,text); + l = strlen(text); + strncpy(TEXT_ERROR+ll+l,"`' -E",4); + notify(TEXT_ERROR); + free(TEXT_ERROR); + ExitProcess(); +} + // stdcall with 1 parameter void dll_Load() { asm { push ebp mov ebp, esp mov esi, SSDWORD[EBP+8] -@next_lib: + @next_lib: mov edx, DSDWORD[ESI] or edx, edx jz exit @@ -213,4 +233,5 @@ int load_dll2(dword dllname, import_table, byte need_init) return 0; @exit01: return -1; + //error_init(dllname); } \ No newline at end of file diff --git a/programs/cmm/lib/file_system.h b/programs/cmm/lib/file_system.h index 7ae45f8787..9c36aac9ee 100644 --- a/programs/cmm/lib/file_system.h +++ b/programs/cmm/lib/file_system.h @@ -31,8 +31,9 @@ }; -:void DrawDate(dword x, y, color, dword in_date) +:void DrawDate(dword x, y, color, in_date) { + //char text[10]; EDI = in_date; EAX = 47; EBX = 2<<16; @@ -47,6 +48,9 @@ EBX = 4<<16; ECX = EDI.date.year; $int 0x40; + + //sprintf(#text,"%d.%d.%d",EDI.date.day,EDI.date.month,EDI.date.year); + //WriteText(x, y, 0x80, 0x80<<24+color, #text); } @@ -297,16 +301,17 @@ enum return #absolute_path; } -:dword ConvertSize(unsigned int bytes) +:dword ConvertSize(dword bytes) { - unsigned char size_prefix[8], size_nm[4]; - if (bytes>=1073741824) strcpy(#size_nm, " Gb"); - else if (bytes>=1048576) strcpy(#size_nm, " Mb"); - else if (bytes>=1024) strcpy(#size_nm, " Kb"); - else strcpy(#size_nm, " b "); + byte size_prefix[8], size_nm[4]; + if (bytes>=1073741824) strcpy(#size_nm, "Gb"); + else if (bytes>=1048576) strcpy(#size_nm, "Mb"); + else if (bytes>=1024) strcpy(#size_nm, "Kb"); + else strcpy(#size_nm, "b"); while (bytes>1023) bytes/=1024; itoa_(#size_prefix, bytes); strcat(#size_prefix, #size_nm); + //sprintf(#size_prefix,"%s","123"); return #size_prefix; } diff --git a/programs/cmm/lib/kolibri.h b/programs/cmm/lib/kolibri.h index 853cc7c5dc..78fa2ea529 100644 --- a/programs/cmm/lib/kolibri.h +++ b/programs/cmm/lib/kolibri.h @@ -1,5 +1,7 @@ //CODED by Veliant, Leency, Nable. GNU GPL licence. +#define LIB_KOLIBRI_H + #startaddress 0 #code32 TRUE @@ -23,9 +25,11 @@ char program_path[4096]; #define evReDraw 1 #define evKey 2 #define evButton 3 +#define evDesktop 5 #define evMouse 6 +#define evIPC 7 #define evNetwork 8 - +#define evDebug 9 //Button options #define BT_DEL 0x80000000 @@ -33,8 +37,9 @@ char program_path[4096]; #define BT_NOFRAME 0x20000000 //Button mouse -#define MOUSE_LEFT 001b -#define MOUSE_RIGHT 010b +#define MOUSE_LEFT 001b +#define MOUSE_RIGHT 010b +#define MOUSE_LR 011b #define MOUSE_CENTER 100b //ASCII KEYS @@ -55,7 +60,18 @@ char program_path[4096]; #define ASCII_KEY_PGDN 183 #define ASCII_KEY_PGUP 184 +//allow event mask +#define EVENT_MASK_REDRAW 000000001b +#define EVENT_MASK_KEYBOARD 000000010b +#define EVENT_MASK_BUTTONS 000000100b +#define EVENT_MASK_DESKTOP 000010000b +#define EVENT_MASK_MOUSE 000100000b +#define EVENT_MASK_IPC 001000000b +#define EVENT_MASK_NETWORK 010000000b +#define EVENT_MASK_DEBUG 100000000b +//ARGS FUNCTION +#define END_ARGS 0xFF00FF //------------------------------------------------------------------------- :struct raw_image { @@ -82,9 +98,81 @@ char program_path[4096]; dword __TMP_TIME,MOUSE_TIME; :struct mouse { - signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick; + signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick,left,top; + dword handle,_; + byte cmd; + void clearTime(); void get(); + void set(); + void center(); + dword hide(); + void slider(); + void show(); }; +:void mouse::clearTime() +{ + tmp_time = GetStartTime()+MOUSE_TIME; +} +:void mouse::show() +{ + if(!handle)return; + ECX = handle; + EAX = 37; + EBX = 5; + $int 0x40; +} +:dword mouse::hide() +{ + if(!_) + { + EAX = 68; + EBX = 12; + ECX = 32*32*4; + $int 0x40 + ECX = EAX; + _ = EAX; + } else ECX = _; + EAX = 37; + EBX = 4; + DX = 2; + $int 0x40; + handle = EAX; + ECX = EAX; + EAX = 37; + EBX = 5; + $int 0x40; + handle = EAX; +} + +//set new attributes mouse +:void mouse::set() +{ + if((xx!=x)||(yy!=y)) + { + EAX = 18; + EBX = 19; + ECX = 4; + EDX = (x<<16)+y; + $int 0x40 + //move = true; + } + if((key)||(lkm|mkm|pkm))&&(down|up|click|dblclick|move) + { + if(lkm|mkm|pkm)key=(lkm)|(pkm<<1)|(2<>= 1; mkm = 4&tmp; mkm >>= 2; + cmd = false; } //when you press the mouse button + // Mouse Down Event/Move Event else { - up = false; - click = false; + up = false; + click = false; dblclick = false; - if(key) + down = false; + // Mouse Move Event + if((xx!=x)||(yy!=y)) { - down = true; - tmp = key; - } - else down = false; - if((xx!=x)||(yy!=y)){ move = true; xx = x; yy = y; } else move = false; + if(key)if(!cmd) {down = true;cmd = true;tmp=key;} } //scroll @@ -161,6 +251,33 @@ dword __TMP_TIME,MOUSE_TIME; vert = EBX; } +:void mouse::slider() +{ + signed _x,_y; + if(!handle)hide(); + get(); + _x = x;_y = y; + pause(5); + get(); + left = _x - x; + top = _y - y; + center(); + get(); + _x = x;_y = y; + pause(5); +} + +:struct keyboard +{ + signed key; + byte down,up,press; + void get(void); +}; + +:void keyboard::get(void) +{ + +} :struct system_colors { @@ -179,11 +296,12 @@ dword __TMP_TIME,MOUSE_TIME; } //------------------------------------------------------------------------------ - +dword wait_event_code; inline fastcall dword WaitEvent() { $mov eax,10 $int 0x40 + wait_event_code = EAX; } inline fastcall dword CheckEvent() @@ -192,13 +310,13 @@ inline fastcall dword CheckEvent() $int 0x40 } -inline fastcall dword WaitEventTimeout( EBX) +inline fastcall dword WaitEventTimeout(EBX) { $mov eax,23 $int 0x40 } -inline fastcall SetEventMask( EBX) +inline fastcall SetEventMask(EBX) { $mov eax,40 $int 0x40 @@ -236,7 +354,7 @@ inline fastcall int GetFullKey() } -inline fastcall pause( EBX) +inline fastcall pause(EBX) { $mov eax, 5 $int 0x40 @@ -257,7 +375,7 @@ inline fastcall dword GetFreeRAM() //return eax = размер свободной памяти в килобайтах } -inline fastcall dword LoadDriver( ECX) //ECX - имя драйвера +inline fastcall dword LoadDriver(ECX) //ECX - имя драйвера { $mov eax, 68 $mov ebx, 16 @@ -265,7 +383,7 @@ inline fastcall dword LoadDriver( ECX) //ECX - //return 0 - неудача, иначе eax = хэндл драйвера } -inline fastcall dword RuleDriver( ECX) //указатель на управляющую структуру +inline fastcall dword RuleDriver(ECX) //указатель на управляющую структуру { $mov eax, 68 $mov ebx, 17 @@ -288,7 +406,7 @@ struct proc_info byte reserved[1024-71-8]; }; -inline fastcall void GetProcessInfo( EBX, ECX) +inline fastcall void GetProcessInfo(EBX, ECX) { $mov eax,9; $int 0x40 @@ -337,7 +455,7 @@ inline fastcall int MinimizeWindow() $int 0x40 } -inline fastcall int CreateThread( ECX,EDX) +inline fastcall int CreateThread(ECX,EDX) { $mov eax,51 $mov ebx,1 @@ -522,9 +640,10 @@ void DefineAndDrawWindow(dword x, y, size_w, size_h, byte WindowType,dword Windo EBX = 1; $int 0x40 - EAX = 0; + $xor EAX,EAX EBX = x << 16 + size_w; ECX = y << 16 + size_h; + EDX = WindowType << 24 | WindowAreaColor; $int 0x40 @@ -664,12 +783,40 @@ inline fastcall dword GetStartTime() $int 0x40 } +:dword ALERT_TEXT; +:void dialog_alert() +{ + byte id; + loop()switch(WaitEvent()) + { + case evReDraw: + DefineAndDrawWindow(215,100,250,200,0x34,0xFFFFFF,"Alert"); + WriteTextB(5,5,0x90,0x0,ALERT_TEXT); + break; + case evButton: + id=GetButtonID(); + if (id==1) ExitProcess(); + break; + } +} + +:dword alert(dword text) +{ + dword mem = malloc(4096); + ALERT_TEXT = text; + CreateThread(#dialog_alert,mem+4092); + return mem; +} + dword __generator; // random number generator - для генерации случайных чисел +dword program_path_length; + //The initialization of the initial data before running void load_init_main() { - MOUSE_TIME = 50; //Default 50 ms. + //program_path_length = strlen(program_path); + MOUSE_TIME = 50; //Default 500 ms. __generator = GetStartTime(); main(); } \ No newline at end of file diff --git a/programs/cmm/lib/obj/http.h b/programs/cmm/lib/obj/http.h index 4a9eb05b17..1440e28b48 100644 --- a/programs/cmm/lib/obj/http.h +++ b/programs/cmm/lib/obj/http.h @@ -3,17 +3,17 @@ dword libHTTP = #alibHTTP; char alibHTTP[23] = "/sys/lib/http.obj\0"; -dword http_lib_init = #aLib_init; -dword http_get = #aHTTPget; -dword http_head = #aHTTPhead; -dword http_post = #aHTTPpost; +dword http_lib_init = #aLib_init; +dword http_get = #aHTTPget; +dword http_head = #aHTTPhead; +dword http_post = #aHTTPpost; dword http_find_header_field = #aFHF; -dword http_send = #aHTTPsend; -dword http_receive = #aHTTPreceive; -dword http_disconnect = #aHTTPdisconnect; -dword http_free = #aHTTPfree; -dword uri_escape = #aURIescape; -dword uri_unescape = #aURIunescape; +dword http_send = #aHTTPsend; +dword http_receive = #aHTTPreceive; +dword http_disconnect = #aHTTPdisconnect; +dword http_free = #aHTTPfree; +dword uri_escape = #aURIescape; +dword uri_unescape = #aURIunescape; $DD 2 dup 0 char aLib_init[9] = "lib_init\0"; @@ -60,4 +60,9 @@ struct http_msg{ dword content_length; dword content_received; char http_header; -}; \ No newline at end of file +}; + +:dword file_get_contents(dword url,...) +{ + http_get(url,FLAG_HTTP11,""); +} \ No newline at end of file diff --git a/programs/cmm/lib/random.h b/programs/cmm/lib/random.h index e974e8d28d..04d1abd440 100644 --- a/programs/cmm/lib/random.h +++ b/programs/cmm/lib/random.h @@ -18,6 +18,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *******************************************************************************/ +#define MASK_RAND 123456789 +#define IQ_RAND 12773 +#define IA_RAND 16807 +#define IR_RAND 2836 +#define IM_RAND 2147483647 +#define AM_RAND (1./2147483647) inline fastcall int random( ECX) // get pseudo-random number - получить псевдослучайное число @@ -40,6 +46,40 @@ inline fastcall int random( ECX) $pop ebx } +:inline long unirand0(void) +{ + long k,ans,tmp,save; + save = __generator; + __generator^=MASK_RAND; /* avoid __generator==0 */ + k=__generator/IQ_RAND; + tmp=__generator-k*IQ_RAND; + __generator*=IA_RAND*tmp; + __generator-=IR_RAND*k; + if(__generator<0) __generator+=IM_RAND; + if(save == __generator) return unirand0(); + ans=__generator; + __generator^=MASK_RAND; /* restore unmasked dummy */ + return ans; +} + +:long RAND_A,RAND_C,RAND_TMP; +:inline long rand(signed long x1,x2) +{ + long tmp,xx; + RAND_A = __generator; + __generator = RAND_A*__generator+RAND_C; + RAND_C = __generator^RAND_A; + RAND_C>>=1; + RAND_A<<=1; + __generator^=RAND_A; + xx=x2; + if(x1<0)xx+=-x1; + tmp = __generator%xx; + if(tmp<0)tmp=-tmp; + tmp+=x1; + return tmp; +} + inline fastcall randomize() // initialize random number __generator - инициализировать генератор случайных чисел { @@ -49,6 +89,7 @@ inline fastcall randomize() int 0x40 ror eax,16 } + //if(EAX == __generator)return randomize(); __generator = EAX; } diff --git a/programs/cmm/lib/strings.h b/programs/cmm/lib/strings.h index af808883fc..d2f3370946 100644 --- a/programs/cmm/lib/strings.h +++ b/programs/cmm/lib/strings.h @@ -178,24 +178,31 @@ L2: $jnz L2 } -inline dword strncpy(dword text1, text2, signed len) +:inline dword strncpy(dword text1, text2, signed len) signed o1,o2; { + if(!text1)||(!len) return text1; + if(len<4) + { + o2 = len; + goto RUN_BYTE; + } o1 = len/4; o2 = len-4*o1; while(o1){ - ESDWORD[text1] = ESDWORD[text2]; + DSDWORD[text1] = DSDWORD[text2]; text1 += 4; text2 += 4; $dec o1 } + RUN_BYTE: while(o2){ - ESBYTE[text1] = ESBYTE[text2]; + DSBYTE[text1] = DSBYTE[text2]; $inc text1 $inc text2 $dec o2 } - ESBYTE[text1] = 0; + DSBYTE[text1] = 0; return text1; } @@ -339,25 +346,26 @@ void strncat(dword text1, text2, signed len) signed o1,o2; char s; { - s = ESBYTE[text1]; + s = DSBYTE[text1]; while(s){ $inc text1 - s = ESBYTE[text1]; + s = DSBYTE[text1]; } o1 = len/4; o2 = len-4*o1; while(o1){ - ESDWORD[text1] = ESDWORD[text2]; + DSDWORD[text1] = DSDWORD[text2]; text1 += 4; text2 += 4; $dec o1 } while(o2){ - ESBYTE[text1] = ESBYTE[text2]; + DSBYTE[text1] = DSBYTE[text2]; $inc text1 $inc text2 $dec o2 } + DSBYTE[text1] = 0; } inline fastcall void chrcat(ESI, BL) @@ -614,22 +622,23 @@ F3: inline dword itoa(signed long number) { unsigned char buf[11]; - dword ret; + dword ret,p; byte cmd; long mask,tmp; mask = 1000000000; cmd = true; + p = #buf; if(!number){ - ESBYTE[buf] = '0'; - ESBYTE[buf+1] = 0; - return buf; + ESBYTE[p] = '0'; + ESBYTE[p+1] = 0; + return p; } - ret = buf; + ret = p; if(number<0) { $neg number - ESBYTE[buf] = '-'; - $inc buf + ESBYTE[p] = '-'; + $inc p } while(mask) { @@ -638,22 +647,22 @@ inline dword itoa(signed long number) if(cmd){ if(tmp){ - ESBYTE[buf] = tmp + '0'; - $inc buf + ESBYTE[p] = tmp + '0'; + $inc p cmd = false; } } else { - ESBYTE[buf] = tmp + '0'; - $inc buf + ESBYTE[p] = tmp + '0'; + $inc p } mask /= 10; } - ESBYTE[buf] = 0; + ESBYTE[p] = 0; return ret; } - -inline fastcall itoa_(signed int EDI, ESI) + +:inline fastcall itoa_(signed int EDI, ESI) { $pusha EBX = EDI; @@ -686,15 +695,27 @@ F3: return EBX; } -inline dword strdup(dword text) +:inline dword memchr(dword s,int c,signed len) +{ + if(!len) return NULL; + do { + if(DSBYTE[s] == c) return s; + $inc s + $dec len + } while(len); + return NULL; +} + +:inline dword strdup(dword text) { dword l = strlen(text); dword ret = malloc(l+1); + if(!ret) return NULL; strncpy(ret,text,l); return ret; } -inline dword strndup(dword str, signed maxlen) +:inline dword strndup(dword str, signed maxlen) { dword copy,len; @@ -702,12 +723,96 @@ inline dword strndup(dword str, signed maxlen) copy = malloc(len + 1); if (copy != NULL) { - memcpy(copy, str, len); + strncpy(copy, str, len); DSBYTE[len+copy] = '\0'; } return copy; } +:inline cdecl int sprintf(dword buf, format,...) +{ + byte s; + char X[10]; + dword ret, tmp, l; + dword arg = #format; + ret = buf; + s = DSBYTE[format]; + while(s){ + if(s=='%'){ + arg+=4; + tmp = DSDWORD[arg]; + if(tmp==END_ARGS)goto END_FUNC_SPRINTF; + $inc format + s = DSBYTE[format]; + if(!s)goto END_FUNC_SPRINTF; + switch(s) + { + case 's': + l = tmp; + s = DSBYTE[tmp]; + while(s) + { + DSBYTE[buf] = s; + $inc tmp + $inc buf + s = DSBYTE[tmp]; + } + break; + case 'c': + DSBYTE[buf] = tmp; + $inc buf + break; + case 'u': //if(tmp<0)return ret; + case 'd': + case 'i': + tmp = itoa(tmp); + if(!DSBYTE[tmp])goto END_FUNC_SPRINTF; + l = strlen(tmp); + strncpy(buf,tmp,l); + buf += l; + break; + case 'a': + case 'A': + strncpy(buf,"0x00000000",10); + buf+=10; + l=buf; + while(tmp) + { + $dec buf + s=tmp&0xF; + if(s>9)DSBYTE[buf]='A'+s-10; + else DSBYTE[buf]='0'+s; + tmp>>=4; + } + buf=l; + break; + case 'p': + tmp = itoa(#tmp); + if(!DSBYTE[tmp])goto END_FUNC_SPRINTF; + l = strlen(tmp); + strncpy(buf,tmp,l); + buf += l; + break; + case '%': + DSBYTE[buf] = '%'; + $inc buf + break; + default: + goto END_FUNC_SPRINTF; + } + } + else { + DSBYTE[buf] = s; + $inc buf + } + $inc format + s = DSBYTE[format]; + } + END_FUNC_SPRINTF: + DSBYTE[buf] = 0; + return buf-ret; +} + void debugi(dword d_int) { char tmpch[12];