Subversion Repositories Kolibri OS

Rev

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

  1. //CODED by Veliant, Leency, Nable. GNU GPL licence.
  2.  
  3. #startaddress 0
  4. #code32 TRUE
  5.  
  6. char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
  7. dword  os_version   = 0x00000001;
  8. dword  start_addr   = #main;
  9. dword  final_addr   = #stop+32;
  10. dword  alloc_mem    = #0x00100000;
  11. dword  x86esp_reg   = #0x00100000;
  12. dword  I_Param      = #param;
  13. dword  I_Path       = #program_path;
  14. char param[4096]="";
  15. char program_path[4096]="";
  16.  
  17. //Events
  18. #define evMouse 6
  19. #define evButton        3
  20. #define evKey           2
  21. #define evReDraw        1
  22.  
  23. //Button options
  24. #define BT_DEL          0x80000000
  25. #define BT_HIDE         0x40000000
  26. #define BT_NOFRAME      0x20000000
  27.  
  28. #define OLD             -1
  29. #define true            1
  30. #define false           0
  31. //-------------------------------------------------------------------------
  32.  
  33. struct mouse{
  34.  dword x,y,lkm,pkm,hor,vert;
  35.  void get();
  36. };
  37.  
  38. void mouse::get()
  39. {
  40.         EAX = 37;
  41.         EBX = 1;
  42.         $int    0x40
  43.         $mov    ebx, eax
  44.         $shr    eax, 16
  45.         $and    ebx,0x0000FFFF
  46.         x = EAX;
  47.         y = EBX;
  48.         EAX = 37;
  49.         EBX = 2;
  50.         $int    0x40
  51.         $mov    ebx, eax
  52.         $and    eax, 0x00000001
  53.         $shr    ebx, 1
  54.         $and    ebx, 0x00000001
  55.         lkm = EAX;
  56.         pkm = EBX;
  57.         EAX = 37; //áªà®««
  58.         EBX = 7;
  59.         $int    0x40
  60.         $mov    ebx, eax
  61.         $shr    eax, 16
  62.         $and    ebx,0x0000FFFF
  63.         //hor = EAX;
  64.         vert = EBX;
  65. }
  66.  
  67. struct proc_info{
  68.         dword   use_cpu;
  69.         word    pos_in_stack,num_slot,rezerv1;
  70.         char    name[11];
  71.         char    rezerv2;
  72.         dword   adress,use_memory,ID,left,top,width,height;
  73.         word    status_slot,rezerv3;
  74.         dword   work_left,work_top,work_width,work_height;
  75.         char    status_window;
  76.         void    GetInfo(dword ECX);
  77.         byte    reserved[1024-71];
  78. #define SelfInfo -1
  79. };
  80.  
  81. void GetProcessInfo(dword EBX, ECX)
  82. {
  83.         EAX = 9;
  84.         $int  0x40
  85. }
  86.  
  87. struct system_colors{
  88.         dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
  89.         void get();
  90. };
  91. void system_colors::get()
  92. {
  93.         EAX = 48;
  94.         EBX = 3;
  95.         ECX = #frame;
  96.         EDX = 40;
  97.         $int 0x40
  98. }
  99.  
  100. //------------------------------------------------------------------------------
  101.  
  102. inline fastcall dword WaitEvent(){
  103.  EAX = 10;
  104.  $int 0x40
  105. }
  106.  
  107. inline fastcall dword WaitEventTimeout(dword EBX){
  108.  EAX = 23;
  109.  $int 0x40
  110. }
  111.  
  112. inline fastcall SetEventMask(dword EBX)
  113. {
  114.  EAX = 40;
  115.  $int 0x40
  116. }
  117.  
  118. inline fastcall ScancodesGeting(){
  119.         $mov eax,66;
  120.         $mov ebx,1;
  121.         $mov ecx,1; //᪠­ª®¤ë
  122.         $int 0x40
  123. }
  124.  
  125.  
  126. inline fastcall word GetKey(){ //Gluk fix
  127.                 $push edx
  128. @getkey:
  129.                 $mov  eax,2
  130.                 $int  0x40
  131.                 $cmp eax,1
  132.                 $jne getkeyi
  133.                 $mov ah,dh
  134.                 $jmp getkeyii //jz?
  135. @getkeyi:
  136.                 $mov dh,ah
  137.                 $jmp getkey
  138. @getkeyii:
  139.                 $pop edx
  140.                 EAX = EAX >> 8;          
  141. }
  142.  
  143. inline fastcall word GetButtonID(){
  144.  EAX = 17;
  145.  $int  0x40
  146.  EAX = EAX >> 8;
  147. }
  148.  
  149. inline fastcall ExitProcess(){
  150.  EAX = -1;              // close this program
  151.  $int 0x40
  152. }
  153.  
  154. inline fastcall Pause(dword EBX)
  155. {                                       // ã§ , ¢ á®âëå ¤®«ïå ᥪ㭤ë EBX = value
  156.         $mov eax, 5
  157.         $int 0x40
  158. }
  159.  
  160. //------------------------------------------------------------------------------
  161.  
  162. //eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
  163. inline fastcall int GetSystemLanguage(){
  164.  EAX = 26;
  165.  EBX = 5;
  166.  $int 0x40
  167.  RETURN EAX;
  168. }
  169.  
  170. inline fastcall void DrawTitle(dword ECX)
  171. {
  172.         EAX = 71;
  173.         EBX = 1;
  174.         $int 0x40;
  175. }
  176.  
  177. inline fastcall dword GetSkinWidth()
  178. {
  179.         EAX = 48;
  180.         EBX = 4;
  181.         $int 0x40
  182. }
  183.  
  184. inline fastcall void ChangeSkin(ECX){
  185.         EAX = 48;
  186.         EBX = 8;
  187.         $int 0x40
  188. }
  189.  
  190. inline fastcall dword GetScreenWidth()
  191. {
  192.         EAX = 14;
  193.         EBX = 4;
  194.         $int 0x40
  195.         $shr eax, 16
  196.         $and eax,0x0000FFFF
  197. }
  198.  
  199. inline fastcall MoveSize(dword EBX,ECX,EDX,ESI)
  200. {
  201.         EAX = 67;
  202.         $int 0x40
  203. }
  204.  
  205. inline fastcall dword LoadLibrary(dword ECX)
  206. {
  207.         $mov eax, 68
  208.         $mov ebx, 19
  209.         $int  0x40
  210. }
  211.  
  212. //------------------------------------------------------------------------------
  213. inline fastcall dword strlen(dword EDI){
  214.         EAX=0;
  215.         ECX=-1;
  216.         $REPNE $SCASB
  217.         EAX-=2+ECX;
  218. }
  219.  
  220. inline fastcall copystr(dword ESI,EDI)
  221. {
  222.         $cld
  223. l1:
  224.         $lodsb
  225.         $stosb
  226.         $test al,al
  227.         $jnz l1
  228. }
  229.  
  230.  
  231. byte fastcall TestBit(EAX, CL)
  232. {
  233.         $shr eax,cl
  234.         $and eax,1
  235. }
  236.  
  237. char buffer[11]="";
  238. inline fastcall dword IntToStr(dword ESI)
  239. {
  240.      $mov     edi, #buffer
  241.      $mov     ecx, 10
  242.      $test     esi, esi
  243.      $jns     f1
  244.      $mov     al, '-'
  245.      $stosb
  246.      $neg     esi
  247. f1:
  248.      $mov     eax, esi
  249.      $push     -'0'
  250. f2:
  251.      $xor     edx, edx
  252.      $div     ecx
  253.      $push     edx
  254.      $test     eax, eax
  255.      $jnz     f2
  256. f3:
  257.      $pop     eax
  258.      $add     al, '0'
  259.      $stosb
  260.      $jnz     f3
  261.      $mov     eax, #buffer
  262.      $ret
  263. }
  264.  
  265.  
  266. inline fastcall dword StrToInt()
  267. {
  268.         ESI=EDI=EAX;
  269.         IF(DSBYTE[ESI]=='-')ESI++;
  270.         EAX=0;
  271.         BH=AL;
  272.         do{
  273.                 BL=DSBYTE[ESI]-'0';
  274.                 EAX=EAX*10+EBX;
  275.                 ESI++;
  276.         }while(DSBYTE[ESI]>0);
  277.         IF(DSBYTE[EDI]=='-') -EAX;
  278. }
  279.  
  280.  
  281. inline fastcall int strcmp(ESI, EDI)
  282. {
  283.         loop()
  284.         {
  285.                 IF (DSBYTE[ESI]<DSBYTE[EDI]) RETURN -1;
  286.                 IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
  287.                 IF (DSBYTE[ESI]=='\0') RETURN 0;
  288.                 ESI++;
  289.                 EDI++;
  290.         }
  291. }
  292.  
  293. inline fastcall unsigned int find_symbol(ESI,BL)
  294. {
  295.         int jj=0, last=-1;
  296.         do{
  297.                 jj++;
  298.                 $lodsb
  299.                 IF(AL==BL) last=jj;
  300.         } while(AL!=0);
  301.         return last;
  302. }
  303.  
  304.  
  305. inline fastcall dword upcase(dword ESI)
  306. {
  307.         do{
  308.                 AL=DSBYTE[ESI];
  309.                 IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f;
  310.                 ESI++;
  311.         }while(AL!=0);
  312. }
  313.  
  314. /*inline fastcall void lowcase(ESI)
  315. {
  316.         do{
  317.                 $LODSB
  318.                 IF(AL>='A')&&(AL<='Z'){
  319.                         AL+=0x20;
  320.                         DSBYTE[ESI-1]=AL;
  321.                         CONTINUE;
  322.                 }
  323.         }while(AL!=0);
  324. }*/
  325.  
  326. inline fastcall lowcase(ESI)
  327. {
  328.         do{
  329.                 $LODSB
  330.                 IF(AL>='A')&&(AL<='Z'){
  331.                         AL+=0x20;
  332.                         DSBYTE[ESI-1]=AL;
  333.                         CONTINUE;
  334.                 }
  335.         }while(AL!=0);
  336. }
  337.  
  338.  
  339. inline fastcall wintodos (dword ESI)
  340. {
  341.    while (BL=ESBYTE[ESI])
  342.    {
  343.         IF (BL>=192)
  344.         {
  345.              IF (BL>=240) ESBYTE[ESI] = BL - 16;
  346.              ELSE ESBYTE[ESI] = BL - 64;
  347.         }
  348.         ELSE
  349.         {
  350.         IF (BL==178) ESBYTE[ESI] = 73;  //I
  351.         IF (BL==179) ESBYTE[ESI] = 105; //i
  352.         IF (BL==175) ESBYTE[ESI] = 244; //J
  353.     IF (BL==191) ESBYTE[ESI] = 245; //j
  354.         IF (BL==170) ESBYTE[ESI] = 242; //E
  355.         IF (BL==186) ESBYTE[ESI] = 243; //e
  356.     IF (BL==168) ESBYTE[ESI] = 240; //ð
  357.     IF (BL==184) ESBYTE[ESI] = 'e'; //e
  358.         IF (BL==180) ESBYTE[ESI] = 254; //ã
  359.     IF ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34;
  360.     IF ((BL==150) || (BL==151)) ESBYTE[ESI] = 45;
  361.         }
  362.         ESI++;
  363.    }
  364. }
  365.  
  366.  
  367. dword Hex2Symb(char* htmlcolor)
  368. {
  369.   dword j=0, symbol=0;
  370.   char ch=0x00;
  371.   FOR (;j<2;j++)
  372.   {
  373.     ch=ESBYTE[htmlcolor+j];
  374.     IF (ch==0x0d) || (ch=='\9') RETURN '';
  375.     IF ((ch>='0') && (ch<='9')) ch -= '0';
  376.     IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
  377.     IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
  378.     symbol = symbol*0x10 + ch;
  379.   }
  380.   wintodos(#symbol);
  381.   AL=symbol;
  382. }
  383.  
  384. /*int hex2char(char c)
  385. {
  386.   if (c <=9)
  387.     return (c+48);
  388.  
  389.   return (c - 10 + 'a');
  390. }
  391.  
  392. int hex2char(dword c)
  393. {
  394.   if (c <=9)
  395.     return (c+48);
  396.  
  397.   return (c - 10 + 'a');
  398. }*/
  399.  
  400. byte mas[66] = "椥ä£å¨©ª«¬­®¯ïàáâ㦢ìë§èíéçꞀ–„…”ƒ•ˆ‰Š‹ŒŽŸ‘’“†‚œ›‡˜™—š";
  401. inline fastcall void koitodos(dword EDI)
  402. {
  403.         WHILE (BL=ESBYTE[EDI])
  404.         {      
  405.                 IF (BL >= 0xC0)
  406.                 {
  407.                         BL -= 0xC0;
  408.                         ESBYTE[EDI] = mas[BL];
  409.                 }
  410.                 //IF (ESBYTE[EDI]=='\244') ESBYTE[EDI]='i';
  411.                 EDI++;
  412.         }
  413. }
  414.  
  415.  
  416. //Asper
  417. //uncomplete
  418. inline fastcall int utf8rutodos(dword ESI) //-
  419. {
  420.     EDI=ESI;
  421.         while (BL=ESBYTE[ESI])
  422.         {      
  423.                 IF (BL == 0xD0) || (BL == 0xD1) EDI--;
  424.         else IF (BL == 0x81) && (ESBYTE[ESI-1]==0xD0) ESBYTE[EDI] = 0xF0; //è
  425.         else IF (BL == 0x91) && (ESBYTE[ESI-1]==0xD1) ESBYTE[EDI] = 0xF1; //¬
  426.         else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80) && (ESBYTE[ESI+2]==0x94)  //long defis
  427.         {
  428.           ESBYTE[EDI] = '-';
  429.           ESI+=2;
  430.         }  
  431.         else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80) && (ESBYTE[ESI+2]==0xA2)  //central point
  432.         {
  433.           ESBYTE[EDI] = '*';
  434.           ESI+=2;
  435.         }  
  436.         else IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xA9)  // (c)
  437.         {
  438.           ESBYTE[EDI] = '(';
  439.           ESBYTE[EDI+1] = 'c';
  440.           ESBYTE[EDI+2] = ')';
  441.           EDI+=2;
  442.           ESI++;
  443.         }  
  444.         ELSE IF (BL == 0xC2) && ((ESBYTE[ESI+1]==0xAB) || (ESBYTE[ESI+1]==0xBB))  // "
  445.         {
  446.           ESBYTE[EDI] = '\"';
  447.           ESI++;
  448.         }  
  449.         ELSE IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xB7)  // _
  450.         {
  451.           ESBYTE[EDI] = '_';
  452.           ESI++;
  453.         }  
  454.         ELSE IF (BL >= 0x90) && (BL <= 0xAF)
  455.                 {
  456.             BL -= 0x10;
  457.                         ESBYTE[EDI] = BL;
  458.                 }
  459.         ELSE IF (BL >= 0x80) && (BL <= 0x8F)
  460.                 {
  461.             BL += 0x60;
  462.                         ESBYTE[EDI] = BL;            
  463.                 }
  464.         ELSE IF (BL >= 0xB0) && (BL <= 0xBF)
  465.                 {
  466.             BL -= 0x10;
  467.                         ESBYTE[EDI] = BL;
  468.                 }
  469.         ELSE ESBYTE[EDI] = BL;
  470.                 ESI++;
  471.         EDI++;
  472.         }
  473.         WHILE (EDI<ESI)
  474.         {
  475.         ESBYTE[EDI] = ' ';
  476.         EDI++;
  477.     }
  478. }
  479.  
  480. //------------------------------------------------------------------------------
  481.  
  482. byte WindowRePaint=0;
  483. inline fastcall void WindowRedrawStatus(dword EBX)
  484. {
  485.         EAX = 12;              // function 12:tell os about windowdraw
  486.         $int 0x40
  487.         IF (EBX==1) WindowRePaint=1; ELSE WindowRePaint=0;
  488. }
  489.  
  490. void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
  491. {
  492.         EBX = x << 16 + sizeX;
  493.         ECX = y << 16 + sizeY;
  494.         EDX = mainAreaType << 24 | mainAreaColour;
  495.         ESI = headerType << 24 | headerColour;
  496.         $xor eax,eax
  497.         $int 0x40
  498. }  
  499.  
  500. inline fastcall dword CreateThread(dword ECX,EDX)
  501. {
  502.         EAX = 51;
  503.         EBX = 1;
  504.         $int 0x40
  505. }
  506.  
  507. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  508. {
  509.         EAX = 4;
  510.         EBX = x<<16+y;
  511.         ECX = fontType<<24+color;
  512.         $int 0x40;
  513. }
  514.  
  515. void PutImage(dword EBX,w,h,x,y)
  516. {
  517.         EAX = 7;
  518.         ECX = w<<16+h;
  519.         EDX = x<<16+y;
  520.         $int 0x40
  521. }
  522.  
  523. void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
  524. {
  525.         EAX = 65;
  526.         ECX = w<<16+h;
  527.         EDX = x<<16+y;
  528.         EBP = 0;
  529.         $int 0x40
  530. }
  531.  
  532. inline fastcall void PutPixel(dword EBX,ECX,EDX){
  533.   EAX=1;
  534.   $int 0x40
  535. }
  536.  
  537. void DrawBar(dword x,y,w,h,EDX)
  538. {
  539.         EAX = 13;
  540.         EBX = x<<16+w;
  541.         ECX = y<<16+h;
  542.         $int 0x40
  543. }
  544.  
  545. void DefineButton(dword x,y,w,h,EDX,ESI)
  546. {
  547.         EAX = 8;
  548.         EBX = x<<16+w;
  549.         ECX = y<<16+h;
  550.         $int 0x40
  551. }
  552.  
  553. inline fastcall void DeleteButton(dword EDX)
  554. {
  555.         EAX = 8;
  556.         EDX += BT_DEL;
  557.         $int 0x40;
  558. }
  559.  
  560. :void DrawRegion(dword x,y,width,height,color1)
  561. {
  562.         DrawBar(x,y,width,1,color1); //¯®«®á  £®à ᢥàåã
  563.         DrawBar(x,y+height,width,1,color1); //¯®«®á  £®à á­¨§ã
  564.         DrawBar(x,y,1,height,color1); //¯®«®á  ¢¥àåã á«¥¢ 
  565.         DrawBar(x+width,y,1,height+1,color1); //¯®«®á  ¢¥àåã á¯à ¢ 
  566. }
  567.  
  568. :void DrawRegion_3D(dword x,y,width,height,color1,color2)
  569. {
  570.         DrawBar(x,y,width+1,1,color1); //¯®«®á  £®à ᢥàåã
  571.         DrawBar(x,y+1,1,height-1,color1); //¯®«®á  á«¥¢ 
  572.         DrawBar(x+width,y+1,1,height,color2); //¯®«®á  á¯à ¢ 
  573.         DrawBar(x,y+height,width,1,color2); //¯®«®á  £®à á­¨§ã
  574. }
  575.  
  576. void DrawFlatButton(dword x,y,width,height,id,color,text)
  577. {
  578.         DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
  579.         DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
  580.         DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
  581.         IF (id<>0)      DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
  582.         WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
  583. }
  584.  
  585. :void DrawCircle(int x, y, r)
  586. {
  587.         int i; float px=0, py=r, ii = r * 3.1415926 * 2;
  588.         FOR (i = 0; i < ii; i++)
  589.         {
  590.         PutPixel(px + x, y - py, 0);
  591.         px = py / r + px;
  592.         py = -px / r + py;
  593.                 //Pause(1);
  594.         }
  595. }
  596.  
  597. //------------------------------------------------------------------------------
  598.  
  599. inline fastcall dword WriteDebug(dword EDX)
  600. {
  601.         $push ebx
  602.         $push ecx
  603.         $mov eax, 63
  604.         $mov ebx, 1
  605. next_char:
  606.         $mov ecx, DSDWORD[edx]
  607.         $or      cl, cl
  608.         $jz  done
  609.         $int 0x40
  610.         $inc edx
  611.         $jmp next_char
  612. done:
  613.         $mov cl, 13
  614.         $int 0x40
  615.         $mov cl, 10
  616.         $int 0x40
  617.         $pop ecx
  618.         $pop ebx
  619. }
  620.