Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #startaddress 0
  2. #code32 TRUE
  3.  
  4. char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
  5. dword  os_version   = 0x00000001;
  6. dword  start_addr   = #main;
  7. dword  final_addr   = #stop+32;
  8. dword  alloc_mem    = #stop+0x100;
  9. dword  x86esp_reg   = #stop+0x100;
  10. dword  I_Param      = 0x0;
  11. dword  I_Icon       = 0x0;
  12. dword    skin_width;
  13.  
  14. //Events
  15. #define evMouse 6
  16. #define evButton  3
  17. #define evKey     2
  18. #define evReDraw  1
  19. #define evNet   8
  20.  
  21. //Button options
  22. #define BT_DEL          0x80000000
  23. #define BT_HIDE         0x40000000
  24. #define BT_NOFRAME      0x20000000
  25.  
  26. #define OLD                     -1
  27. #define true            1
  28. #define false           0
  29.  
  30. struct FileInfo{
  31.  dword read, firstBlock, qnBlockRead, retPtr, Work;
  32.  byte  filedir;
  33. };
  34. //-------------------------------------------------------------------------
  35. struct system_colors{
  36.         dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
  37.         void get();
  38. };
  39. void system_colors::get()
  40. {
  41.         EAX = 48;
  42.         EBX = 3;
  43.         ECX = #frame;
  44.         EDX = 40;
  45.         $int    0x40
  46. }
  47.  
  48.  
  49. int vert;
  50. struct mouse{
  51.  dword x,y,lkm,pkm;
  52.  void get();
  53. };
  54.  
  55. void mouse::get()
  56. {
  57.         EAX = 37;
  58.         EBX = 1;
  59.         $int    0x40
  60.         $mov    ebx, eax
  61.         $shr    eax, 16
  62.         $and    ebx,0x0000FFFF
  63.         x = EAX;
  64.         y = EBX;
  65.         EAX = 37;
  66.         EBX = 2;
  67.         $int    0x40
  68.         $mov    ebx, eax
  69.         $and    eax, 0x00000001
  70.         $shr    ebx, 1
  71.         $and    ebx, 0x00000001
  72.         lkm = EAX;
  73.         pkm = EBX;
  74.         EAX = 37; //ª®«ñᨪ®
  75.         EBX = 7;
  76.         $int    0x40
  77.         $mov    ebx, eax
  78.         $shr    eax, 16
  79.         $and    ebx,0x0000FFFF
  80.         //hor = EAX;
  81.         vert = EBX;
  82. }
  83.  
  84.  
  85. //---------------------------------------------------------------------------
  86. struct f70{
  87.         dword   func;
  88.         dword   param1;
  89.         dword   param2;
  90.         dword   param3;
  91.         dword   param4;
  92.         char    rezerv;
  93.         dword   name;
  94. };
  95. //---------------------------------------------------------------------------
  96. struct BDVK{
  97.         dword   attr;
  98.         byte    type_name;
  99.         byte    rez1, rez2, rez3;
  100.         dword   timecreate;
  101.         dword   datecreate;
  102.         dword   timelastaccess;
  103.         dword   datelastaccess;
  104.         dword   timelastedit;
  105.         dword   datelastedit;
  106.         dword   sizelo;
  107.         dword   sizehi;
  108.         char    name[518];
  109. };
  110. //---------------------------------------------------------------------------
  111. struct proc_info{
  112.         dword   use_cpu;
  113.         word    pos_in_stack,num_slot,rezerv1;
  114.         char    name[11];
  115.         char    rezerv2;
  116.         dword   adress,use_memory,ID,left,top,width,height;
  117.         word    status_slot,rezerv3;
  118.         dword   work_left,work_top,work_width,work_height;
  119.         char    status_window;
  120.         void    getme();
  121. };
  122.  
  123. void proc_info::getme()
  124. {
  125.         EAX = 9;
  126.         EBX = #use_cpu;
  127.         ECX = -1;
  128.         $int    0x40
  129. }
  130. //-------------------------------------------------------------------------------
  131.  
  132. /*
  133.  Žâà¨á®¢ª  ®ª­ 
  134.   {x_start|y_start}, {x_size|y_size}, color_back, color_title, color_frames
  135.  
  136.  DrawWindow(
  137.              EBX = [x_start][x_size]
  138.              ECX = [y_start][y_size]
  139.              EDX, ESI, EDI = [00RRGGBB]
  140.            )
  141. */
  142.  
  143. inline fastcall void DrawWindow(dword EBX, ECX, EDX, ESI, EDI){
  144. #speed
  145.  EAX = 0;               // function 0 : define and draw window
  146.  $int 0x40
  147. #codesize
  148. }
  149.  
  150. inline fastcall void DrawButton(dword EBX, ECX, EDX, ESI){
  151.  EAX = 8;
  152.  $int 0x40
  153. }
  154.  
  155. inline fastcall dword WaitEvent(){
  156.  EAX = 10;              // wait here for event
  157.  $int 0x40
  158. }
  159.  
  160. inline fastcall void ExitProcess(){
  161.  EAX = -1;              // close this program
  162.  $int 0x40
  163. }
  164.  
  165. /*
  166. 02 = GET KEY
  167.  
  168.      ret: al 0 successful -> ah = key
  169.           al 1 no key in buffer
  170. */
  171. inline fastcall word GetKey(){
  172.  EAX = 2;              // just read this key from buffer
  173.  $int  0x40
  174. // EAX = EAX >> 8;
  175. }
  176.  
  177. /*
  178. 17 = GET PRESSED BUTTON ID
  179.  
  180.      ret: al 0 successful -> ah = id number
  181.           al 1 no key in buffer
  182. */
  183. inline fastcall word GetButtonID(){
  184.  EAX = 17;            // Get ID
  185.  $int  0x40
  186.  EAX = EAX >> 8;
  187. }
  188.  
  189. /*
  190. 04 = WRITE TEXT TO WINDOW
  191.  
  192.      ebx [x start]*65536 + [y start]
  193.      ecx text color 0x00RRGGBB
  194.      edx pointer to text beginning
  195.      esi text length
  196.      ret: nothing changed
  197. */
  198. inline fastcall void WriteTextXY(dword EBX, ECX, EDX, ESI){
  199. #speed
  200.  EAX = 4;
  201.  $int 0x40;
  202. #codesize
  203. }
  204.  
  205. /*
  206. 13 = DRAW BAR
  207.  
  208.      ebx [x start]*65536 + [x size]
  209.      ecx [y start]*65536 + [y size]
  210.      edx color 0x00RRGGBB
  211.      ret: nothing changed
  212. */
  213. inline fastcall void kos_DrawBar(dword EBX, ECX, EDX){
  214. #speed
  215.  EAX = 13;
  216.  $int 0x40
  217. #codesize
  218. }
  219.  
  220. /* function EBX=5 (GetBackgroun) ECX[]->EDX[], length ESI
  221. inline fastcall void GetBackground(dword ECX, EDX, ESI){
  222. #speed
  223.  EAX = 39;
  224.  EBX = 5;
  225.  $int 0x40
  226. #codesize
  227. }*/
  228.  
  229. //CODED by Veliant
  230. /*eax = 38 - íîìåð ôóíêöèè
  231. ebx = [êîîðäèíàòà íà÷àëà ïî îñè x]*65536 + [êîîðäèíàòà êîíöà ïî îñè x]
  232. ecx = [êîîðäèíàòà íà÷àëà ïî îñè y]*65536 + [êîîðäèíàòà êîíöà ïî îñè y]
  233. edx = 0x00RRGGBB - öâåò
  234. edx = 0x01xxxxxx - ðèñîâàòü èíâåðñívé îòðåçîê (ìëàäøèå 24 áèòà èãíîðèðó³òñÿ) */
  235. inline fastcall void DrawLine(dword EBX, ECX, EDX){
  236.  EAX = 38;
  237.  $int 0x40
  238. }
  239.  
  240. inline fastcall void DrawTitle(dword ECX)
  241. {
  242.         EAX = 71;
  243.         EBX = 1;
  244.         $int 0x40;
  245. }
  246.  
  247. inline fastcall dword GetSkinWidth()
  248. {
  249.         EAX = 48;
  250.         EBX = 4;
  251.         $int 0x40
  252. }
  253.  
  254. inline fastcall void ChangeSkin(){
  255.         EAX = 48;
  256.         EBX = 8;
  257.         ECX = #file_path;
  258.         $int 0x40
  259. }
  260.  
  261. inline fastcall dword GetScreenWidth()
  262. {
  263.         EAX = 14;
  264.         EBX = 4;
  265.         $int 0x40
  266.         $shr eax, 16
  267.         $and eax,0x0000FFFF
  268. }
  269.  
  270. inline fastcall void DeleteButton(dword EDX)
  271. {
  272.         EAX = 8;
  273.         EDX = EDX + BT_DEL;
  274.         $int 0x40;
  275. }
  276.  
  277. inline fastcall dword LoadLibrary(dword ECX)
  278. {
  279.         $mov eax, 68
  280.         $mov ebx, 19
  281.         $int  0x40
  282. }
  283.  
  284. inline fastcall dword strlen(dword EDI)
  285. {
  286. #speed
  287.         ECX=0;
  288.         EAX=0;
  289.         ECX--;
  290.         $REPNE $SCASB
  291.         EAX=EAX-2-ECX;
  292. #codesize
  293. }
  294.  
  295. //-1 - ­¥ à ¢­ë
  296. // 0 - ­¥ à ¢­ë
  297. inline fastcall dword strcmp(dword ESI,EDI)
  298. {
  299.         dword strcmp_i,ret=-1,len1,len2,sovpadenij=0,str1,str2;
  300.         str1=ESI;
  301.         str2=EDI;
  302.         len1=strlen(str1);
  303.         len2=strlen(str2);
  304.         IF (len1==len2)
  305.         {
  306.                 FOR (strcmp_i=0;strcmp_i<len1;strcmp_i++)
  307.                 {
  308.                         EAX = str1+strcmp_i;
  309.                         EAX = ESBYTE[EAX];
  310.                         EBX = str2+strcmp_i;
  311.                         EBX = ESBYTE[EBX];
  312.                         IF (EAX==EBX) sovpadenij++;
  313.                 }
  314.                 IF (sovpadenij==len1) ret=0;
  315.         } ELSE ret=-1;
  316.         EAX = ret;
  317. }
  318.  
  319. inline fastcall dword upcase(dword ESI)
  320. {
  321.         dword str, i;
  322.         str = ESI;
  323.         for (i=0;i<strlen(str);i++)
  324.         {
  325.                 EAX = str+i;
  326.                 EDX = ESBYTE[EAX];
  327.                 IF (EDX>=97) && (EDX<=122) ESBYTE[str+i] = DL - 32;     //a-z
  328.                 IF (EDX>=160) && (EDX<=175) ESBYTE[str+i] = DL - 32;    //à-ï
  329.                 IF (EDX>=224) && (EDX<=239) ESBYTE[str+i] = DL - 80;    //ð-ÿ
  330.                 IF (EDX == 241) ESBYTE[EAX] = 240;                                      //¿
  331.         }
  332.         EAX = str;
  333.         //EAX = ESDWORD[EAX];
  334.         //if (EAX != 0x5249443C) $int 3;
  335. }
  336.  
  337. inline fastcall dword lowcase(dword ESI)
  338. {
  339.         dword str=ESI, i;
  340.         FOR (i=0;i<strlen(str);i++)
  341.         {
  342.                 EAX = str+i;
  343.                 EDX = ESBYTE[EAX];
  344.                 IF (EDX>=65) && (EDX<=90) ESBYTE[str+i] = DL + 32;      //a-z
  345.                 IF (EDX>=128) && (EDX<=143) ESBYTE[str+i] = DL + 32;    //à-ï
  346.                 IF (EDX>=144) && (EDX<=159) ESBYTE[str+i] = DL + 80;    //ð-ÿ
  347.                 IF (EDX == 240) ESBYTE[EAX] = 241;                                      //¿
  348.         }
  349.         EAX = str;
  350.         //EAX = ESDWORD[EAX];
  351.         //if (EAX != 0x5249443C) $int 3;
  352. }
  353.  
  354. inline fastcall void dostowin (dword ESI)
  355. {
  356.         dword stroka,dlina;
  357.         stroka = ESI;
  358.         while (BL=ESBYTE[ESI])
  359.         {
  360.                 IF (BL>128)
  361.                         IF (BL>=240) ESBYTE[ESI] = BL - 16;
  362.                         ELSE ESBYTE[ESI] = BL - 64;
  363.                 ESI++;
  364.         }
  365. }
  366.  
  367. void WindowRedrawStatus(dword i)
  368. {
  369.         EAX = 12;              // function 12:tell os about windowdraw
  370.         EBX = i;               // 1, start of draw
  371.         $int 0x40
  372. }
  373.  
  374. void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,borderColour)
  375. {
  376.         dword arg1, arg2, arg3, arg4;
  377.         //
  378.         arg1 = x << 16 + sizeX;
  379.         arg2 = y << 16 + sizeY;
  380.         arg3 = mainAreaType << 24 | mainAreaColour;
  381.         arg4 = headerType << 24 | headerColour;
  382.         //
  383.         $mov eax, 0
  384.         $mov ebx, arg1
  385.         $mov ecx, arg2
  386.         $mov edx, arg3
  387.         $mov esi, arg4
  388.         $mov edi, borderColour
  389.         $int 0x40
  390. }
  391.  
  392. void DefineButton(dword x,y,w,h,id,color)
  393. {
  394.         DrawButton(x<<16+w, skin_width+y<<16+h, id, color);
  395. }
  396.  
  397. void WriteText(dword x,y,byte fontType, dword color, text, len)
  398. {
  399.         EBX = x<<16+skin_width+y;
  400.         ECX = fontType<<24+color;
  401.         EDX = text;
  402.         ESI = len;
  403.         EAX = 4;
  404.         $int 0x40;
  405. }
  406.  
  407. inline fastcall void PutPixel(dword EBX,ECX,EDX) //Coded by Leency :D
  408. {
  409.   EAX=1;
  410.   $int 0x40
  411. }
  412.  
  413. void DrawBar(dword x,y,w,h,color)
  414. {
  415.         kos_DrawBar(x<<16+w,skin_width+y<<16+h,color);
  416. }
  417.  
  418. void DrawRegion(dword x,y,width,height,color1)
  419. {
  420.         DrawBar(x,y,width,1,color1); //ïîëîñà ãîð ñâåðõó
  421.         DrawBar(x,y+height,width,1,color1); //ïîëîñà ãîð ñíèçó
  422.         DrawBar(x,y,1,height,color1); //ïîëîñà âåðò ñëåâà
  423.         DrawBar(x+width,y,1,height+1,color1); //ïîëîñà âåðò ñïðàâà
  424. }
  425.  
  426. void DrawFlatButton(dword x,y,width,height,id,color,text)
  427. {
  428.         DrawRegion(x,y,width,height,0x94AECE);
  429.         DrawBar(x+1,y+1,width-1,1,0xFFFFFF); //ïîëîñà ãîð áåëàÿ
  430.         DrawBar(x+1,y+height-1,width-2,1,0xC7C7C7); //òåíü âåðò
  431.         DrawBar(x+1,y+1,1,height-1,0xFFFFFF); //ïîëîñà âåðò áåëàÿ
  432.         DrawBar(x+width-1,y+2,1,height-2,0xC7C7C7); //òåíü âåðò
  433.         DrawBar(x+2,y+2,width-3,height-3,color); //çàëèâêà
  434.         IF (id<>0)      DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //îïðåäåëÿåì êíîïêó
  435.         WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,strlen(text));
  436. }
  437.  
  438.  
  439. void PutImage(dword buf,w,h,x,y)
  440. {
  441.         int i,r,g,b;
  442.         EDI=buf;
  443.         EAX = 7;
  444.         EBX = buf;
  445.         ECX = w<<16+h;
  446.         EDX = x<<16+y+skin_width;
  447.         $int 0x40
  448. }
  449.  
  450.  
  451. void copystr(dword s,d)
  452. {
  453.         $mov esi,s
  454.         $mov edi,d
  455.         $cld
  456. l1:
  457.         $lodsb
  458.         $stosb
  459.         $test al,al
  460.         $jnz l1
  461. }
  462.  
  463.  
  464. int     pos,razr,backup,j=0,chislo;
  465. char    buffer[11]="";
  466. inline fastcall dword IntToStr(dword ESI)
  467. {
  468.         chislo=ESI;
  469.         ECX=12;
  470.         $push edi
  471.         $mov edi,#buffer
  472.         $xor al,al
  473.         $cld
  474.         $rep $stosb
  475.         pos=razr=backup=j=0;
  476.         if (chislo<0)
  477.         {
  478.                 buffer[pos]='-';
  479.                 chislo=-1*chislo;
  480.                 pos++;
  481.         }
  482.         backup=chislo;
  483.         do
  484.         {
  485.                 backup=backup/10;
  486.                 razr++;
  487.         }
  488.         while (backup!=0);
  489.         razr--;
  490.         FOR (j=razr+pos;j>pos-1;j--)
  491.         {
  492.                 backup=chislo/10;
  493.                 backup=backup*10;
  494.                 buffer[j]=chislo-backup+48;
  495.                 chislo=chislo/10;
  496.         }
  497.         //return #buffer;
  498.         $pop edi;
  499.         EAX = #buffer;
  500. }
  501.  
  502.  
  503. inline fastcall dword MoveSize(dword EBX,ECX,EDX,ESI)
  504. {
  505.         EAX = 67;
  506.         $int 0x40
  507. }
  508.  
  509.  
  510. f70     CopyFile_f;
  511. BDVK CopyFile_atr;
  512. inline fastcall dword CopyFile(dword EBX,ECX)
  513. {
  514.         dword s, d, bufer=0;
  515.         s = EBX;
  516.         d = ECX;
  517.  
  518.         CopyFile_f.func = 5;
  519.         CopyFile_f.param1 = 0;
  520.         CopyFile_f.param2 = 0;
  521.         CopyFile_f.param3 = 0;
  522.         CopyFile_f.param4 = #CopyFile_atr;
  523.         CopyFile_f.rezerv = 0;
  524.         CopyFile_f.name = s;
  525.         $mov    eax, 70
  526.         $mov    ebx, #CopyFile_f
  527.         $int    0x40
  528.        
  529.         if (EAX == 0)
  530.         {      
  531.                 bufer = malloc(CopyFile_atr.sizelo);    
  532.                 CopyFile_f.func = 0;
  533.                 CopyFile_f.param1 = 0;
  534.                 CopyFile_f.param2 = 0;
  535.                 CopyFile_f.param3 = CopyFile_atr.sizelo;
  536.                 CopyFile_f.param4 = bufer;
  537.                 CopyFile_f.rezerv = 0;
  538.                 CopyFile_f.name = s;
  539.                 $mov    eax, 70
  540.                 $mov    ebx, #CopyFile_f
  541.                 $int    0x40
  542.        
  543.                 IF (EAX == 0)
  544.                 {
  545.                         CopyFile_f.func = 2;
  546.                         CopyFile_f.param1 = 0;
  547.                         CopyFile_f.param2 = 0;
  548.                         CopyFile_f.param3 = CopyFile_atr.sizelo;
  549.                         CopyFile_f.param4 = bufer;
  550.                         CopyFile_f.rezerv = 0;
  551.                         CopyFile_f.name = d;
  552.                         $mov    eax, 70
  553.                         $mov    ebx, #CopyFile_f
  554.                         $int    0x40
  555.                 }
  556.         }
  557.  
  558. }
  559.