From a98a757c383e560a7d1e5e661c500c0bc33cc4dd Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Wed, 5 Oct 2011 09:50:43 +0000 Subject: [PATCH] eolite some code optimizations git-svn-id: svn://kolibrios.org@2266 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/fs/Eolite/trunk/Eolite.c-- | 9 +-- .../include/{LVabout.h-- => about_dialog.h--} | 71 ++----------------- programs/fs/Eolite/trunk/include/icons_f.h-- | 1 - .../fs/Eolite/trunk/include/some_code.h-- | 53 ++++++++++++++ programs/fs/Eolite/trunk/include/sorting.h-- | 8 ++- programs/fs/Eolite/trunk/lib/kolibri.h-- | 25 +++---- 6 files changed, 81 insertions(+), 86 deletions(-) rename programs/fs/Eolite/trunk/include/{LVabout.h-- => about_dialog.h--} (50%) create mode 100644 programs/fs/Eolite/trunk/include/some_code.h-- diff --git a/programs/fs/Eolite/trunk/Eolite.c-- b/programs/fs/Eolite/trunk/Eolite.c-- index 7d20d54b09..43ad7b4945 100644 --- a/programs/fs/Eolite/trunk/Eolite.c-- +++ b/programs/fs/Eolite/trunk/Eolite.c-- @@ -42,7 +42,7 @@ byte PathHistory[4096]; dword file_mas[6898]; int j, i, mouse_dd; -dword stak[100]=0; //окно About +dword stak[100]; //окно About edit_box edit1= {250,247,13,0xffffff,videlenie,0xD3DDEB,0xffffff,0,248,#edit_path,#mouse_dd,64,6,6}; edit_box edit2= {250,213,80,0xFFFFCC,videlenie,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6}; @@ -51,7 +51,8 @@ proc_info Form; dword buf, off; //для текста и буфера dword devbuf, dev_num; -#include "include\LVabout.h--" +#include "include\about_dialog.h--" +#include "include\some_code.h--" #include "include\sorting.h--" #include "include\icons_f.h--" #include "include\ini.h--" @@ -87,7 +88,6 @@ void Devices() WriteText(45,i*16+79,0x80,0,#drive_name,0); PutImage(dev_icon*14*13*3+#devices,14,13,21,i*16+76); } - Actions(); //функции файлов и папок } void main() @@ -387,6 +387,7 @@ inline fastcall void draw_window() DrawRegion_3D(1,40,Form.width-12,onTop(46,0),0x94AECE,0x94AECE); //синий ободок DrawRegion_3D(0,39,Form.width-10,onTop(44,0),0xE4DFE1,0xE4DFE1); //фон Devices(); //панель слева на синем фоне + Actions(); //функции файлов и папок //SortButtons DrawFlatButton(192,40,onLeft(192,168),16,31,0xE4DFE1,"File"); DrawFlatButton(onLeft(168,0),40,73,16,32,0xE4DFE1,"Type"); @@ -598,7 +599,7 @@ inline Sorting() //Собственно сортировка: вначале папки, потом файлы Sort_by_Name(0,k-1); IF (sort_num==1) Sort_by_Name(k,count-1); - IF (sort_num==2) Sort_by_Type(k, count-1); + IF (sort_num==2) Sort_by_Type(k,count-1); IF (sort_num==3) Sort_by_Size(k,count-1); //если папка ".." не первая, ставим её туда IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")<>0) FOR(k=k-1; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) file_mas[k]>23) p=0; ELSE p++; - Pause(25); - mm.get(); - }*/ - break; + case evButton: id=GetButtonID(); IF (id==1) ExitProcess(); IF (id==23) RunProgram(BROWSER_PATH, BROWSER_LINK); break; + case evKey: IF (GetKey()==27) ExitProcess(); break; + case evReDraw: DefineAndDrawWindow(500,200,181,256,0x34,0x10EFEBEF,0,0,"About Eolite"); DrawBar(0,0,172,50,0x8494C4); //голубое сзади @@ -63,57 +53,4 @@ void DrawLink(dword x,y,btn_id, inscription) WriteText(x,y,0x80,0x4E00E7,inscription,0); DrawBar(x,y+8,strlen(inscription)*6,1,0x4E00E7); //подчеркнуть ссылку DefineButton(x-1,y-1,strlen(inscription)*6,10,btn_id+BT_HIDE,0); -} - - -#define add_new_path 1 -#define go_back 2 - -void HistoryPath(byte action) -{ - if (action==add_new_path) - { - IF (strcmp(#PathHistory+find_symbol(#PathHistory,'|'),#path)==0) return; - IF (strlen(#PathHistory)+strlen(#path)>2560) - { - copystr(#PathHistory+1024,#PathHistory); - copystr("/",#PathHistory+strlen(#PathHistory)); - } - copystr("|",#PathHistory+strlen(#PathHistory)); - copystr(#path,#PathHistory+strlen(#PathHistory)); - } - if (action==go_back) - { - i=strlen(#PathHistory)-1; - WHILE (PathHistory[i]<>'|') { i--; }; - IF (i>0) PathHistory[i]=0x00; - WHILE (PathHistory[i]<>'|') { copystr(#PathHistory[i],#path); i--; } - IF (i>0) PathHistory[i]=0x00; - } -} - - -dword onLeft(dword right,left) {EAX=Form.width-right-left;} -dword onTop(dword down,up) {EAX=Form.height-GetSkinWidth()-down-up;} - - -void ShowMessage(dword message) -{ - DrawFlatButton(Form.width/2-13,160,200,80,0,0xFFB6B5, message); - Pause(150); - List_ReDraw(); -} - - -dword ConvertSize(dword bytes) -{ - byte size_prefix[8], temp[3]; - IF (bytes>=1073741824) copystr(" Gb",#temp); - ELSE IF (bytes>=1048576) copystr(" Mb",#temp); - ELSE IF (bytes>=1024) copystr(" Kb",#temp); - ELSE copystr(" b ",#temp); - WHILE (bytes>1023) bytes/=1024; - copystr(IntToStr(bytes),#size_prefix); - copystr(#temp,#size_prefix+strlen(#size_prefix)); - EAX=#size_prefix; -} +} \ No newline at end of file diff --git a/programs/fs/Eolite/trunk/include/icons_f.h-- b/programs/fs/Eolite/trunk/include/icons_f.h-- index 0edfad8c28..d30f1179be 100644 --- a/programs/fs/Eolite/trunk/include/icons_f.h-- +++ b/programs/fs/Eolite/trunk/include/icons_f.h-- @@ -232,7 +232,6 @@ void IconFairing(int filenum, y) DrawBar(195,y+13,4,1,videlenie); DrawBar(195,y+14,6,1,videlenie); - DrawBar(195+11,y,5,1,videlenie); DrawBar(195+13,y+1,3,1,videlenie); DrawBar(195+14,y+2,2,1,videlenie); diff --git a/programs/fs/Eolite/trunk/include/some_code.h-- b/programs/fs/Eolite/trunk/include/some_code.h-- new file mode 100644 index 0000000000..624850840e --- /dev/null +++ b/programs/fs/Eolite/trunk/include/some_code.h-- @@ -0,0 +1,53 @@ +//Leency - 2011 + +#define add_new_path 1 +#define go_back 2 + +void HistoryPath(byte action) +{ + if (action==add_new_path) + { + IF (strcmp(#PathHistory+find_symbol(#PathHistory,'|'),#path)==0) return; + IF (strlen(#PathHistory)+strlen(#path)>2560) + { + copystr(#PathHistory+1024,#PathHistory); + copystr("/",#PathHistory+strlen(#PathHistory)); + } + copystr("|",#PathHistory+strlen(#PathHistory)); + copystr(#path,#PathHistory+strlen(#PathHistory)); + } + if (action==go_back) + { + i=strlen(#PathHistory)-1; + WHILE (PathHistory[i]<>'|') { i--; }; + IF (i>0) PathHistory[i]=0x00; + WHILE (PathHistory[i]<>'|') { copystr(#PathHistory[i],#path); i--; } + IF (i>0) PathHistory[i]=0x00; + } +} + + +dword onLeft(dword right,left) {EAX=Form.width-right-left;} +dword onTop(dword down,up) {EAX=Form.height-GetSkinWidth()-down-up;} + + +void ShowMessage(dword message) +{ + DrawFlatButton(Form.width/2-13,160,200,80,0,0xFFB6B5, message); + Pause(150); + List_ReDraw(); +} + + +dword ConvertSize(dword bytes) +{ + byte size_prefix[8], temp[3]; + IF (bytes>=1073741824) copystr(" Gb",#temp); + ELSE IF (bytes>=1048576) copystr(" Mb",#temp); + ELSE IF (bytes>=1024) copystr(" Kb",#temp); + ELSE copystr(" b ",#temp); + WHILE (bytes>1023) bytes/=1024; + copystr(IntToStr(bytes),#size_prefix); + copystr(#temp,#size_prefix+strlen(#size_prefix)); + EAX=#size_prefix; +} diff --git a/programs/fs/Eolite/trunk/include/sorting.h-- b/programs/fs/Eolite/trunk/include/sorting.h-- index 299e9d237f..4ab2235e44 100644 --- a/programs/fs/Eolite/trunk/include/sorting.h-- +++ b/programs/fs/Eolite/trunk/include/sorting.h-- @@ -2,7 +2,7 @@ void Sort_by_Size(int a, b) // для первого вызова: a = 0, b = <элементов в массиве> - 1 { - int i= a; + int i = a; IF (a >= b) return; FOR (j = a; j <= b; j++) IF (ESDWORD[file_mas[j]*304 + buf+64] <= ESDWORD[file_mas[b]*304 + buf+64]) @@ -25,7 +25,11 @@ void Sort_by_Name(int a, b) // void Sort_by_Type(int a, b) // для первого вызова: a = 0, b = <элементов в массиве> - 1 { - int i=a; dword offset=buf+72; byte filename1[256], filename2[256]; int n; + int i=a; + int n; + dword offset=buf+72; + byte filename1[256], filename2[256]; + IF (a >= b) return; for (j = a; j <= b; j++) { diff --git a/programs/fs/Eolite/trunk/lib/kolibri.h-- b/programs/fs/Eolite/trunk/lib/kolibri.h-- index 2976529234..f07cbb3768 100644 --- a/programs/fs/Eolite/trunk/lib/kolibri.h-- +++ b/programs/fs/Eolite/trunk/lib/kolibri.h-- @@ -11,6 +11,7 @@ dword alloc_mem = 0x00100000; dword x86esp_reg = 0x00100000; // 0x0007fff0; dword I_Param = #param; dword I_Path = #program_path; + char param[4096]=""; char program_path[4096]=""; @@ -37,7 +38,7 @@ struct mouse{ void get(); }; -int TestBit(EAX, CL) +inline fastcall int TestBit(EAX, CL) { $shr eax,cl $and eax,1 @@ -95,14 +96,14 @@ void proc_info::GetInfo(dword EBX, ECX) $int 0x40 } -int GetSlot(dword ECX) +inline fastcall int GetSlot(dword ECX) { EAX = 18; EBX = 21; $int 0x40 } -int ActiveProcess() +inline fastcall int ActiveProcess() { EAX = 18; EBX = 7; @@ -156,21 +157,21 @@ inline fastcall void Pause(dword EBX){ } //------------------------------------------------------------------------------ -void DefineAndDrawWindow(dword x,y,sizeX,sizeY, -byte mainAreaType, dword mainAreaColor,byte headerType,dword headerColor,EDI) +void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType, +dword mainAreaColour,byte headerType,dword headerColour,EDI) { - EAX = 12; + EAX = 12; // function 12:tell os about windowdraw EBX = 1; $int 0x40 EBX = x << 16 + sizeX; ECX = y << 16 + sizeY; - EDX = mainAreaType << 24 | mainAreaColor; - ESI = headerType << 24 | headerColor; + EDX = mainAreaType << 24 | mainAreaColour; + ESI = headerType << 24 | headerColour; $xor eax,eax $int 0x40 - - EAX = 12; + + EAX = 12; // function 12:tell os about windowdraw EBX = 2; $int 0x40 } @@ -366,7 +367,7 @@ void PutImage(dword EBX,w,h,x,y) } //------------------------------------------------------------------------------ -/*void WriteDebug(dword EDX) +inline fastcall void WriteDebug(dword EDX) { $mov eax, 63 $mov ebx, 1 @@ -402,4 +403,4 @@ inline fastcall void WriteFullDebug(dword ESI) WriteDebug(IntToStr(za_kadrom)); Pause(200); -}*/ \ No newline at end of file +} \ No newline at end of file