Subversion Repositories Kolibri OS

Rev

Rev 2085 | 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. #define SelfInfo -1
  78. };
  79.  
  80. void proc_info::GetInfo(dword ECX)
  81. {
  82.         EAX = 9;
  83.         EBX = #use_cpu;
  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. inline fastcall void DrawTitle(dword ECX)
  163. {
  164.         EAX = 71;
  165.         EBX = 1;
  166.         $int 0x40;
  167. }
  168.  
  169. inline fastcall dword GetSkinWidth()
  170. {
  171.         EAX = 48;
  172.         EBX = 4;
  173.         $int 0x40
  174. }
  175.  
  176. inline fastcall void ChangeSkin(ECX){
  177.         EAX = 48;
  178.         EBX = 8;
  179.         $int 0x40
  180. }
  181.  
  182. inline fastcall dword GetScreenWidth()
  183. {
  184.         EAX = 14;
  185.         EBX = 4;
  186.         $int 0x40
  187.         $shr eax, 16
  188.         $and eax,0x0000FFFF
  189. }
  190.  
  191. inline fastcall MoveSize(dword EBX,ECX,EDX,ESI)
  192. {
  193.         EAX = 67;
  194.         $int 0x40
  195. }
  196.  
  197. inline fastcall dword LoadLibrary(dword ECX)
  198. {
  199.         $mov eax, 68
  200.         $mov ebx, 19
  201.         $int  0x40
  202. }
  203.  
  204. //------------------------------------------------------------------------------
  205. inline fastcall dword strlen(dword EDI){
  206.         EAX=0;
  207.         ECX=-1;
  208.         $REPNE $SCASB
  209.         EAX-=2+ECX;
  210. }
  211.  
  212. inline fastcall copystr(dword ESI,EDI)
  213. {
  214.         $cld
  215. l1:
  216.         $lodsb
  217.         $stosb
  218.         $test al,al
  219.         $jnz l1
  220. }
  221.  
  222. byte fastcall TestBit(EAX, CL)
  223. {
  224.         $shr eax,cl
  225.         $and eax,1
  226. }
  227.  
  228. char buffer[11]="";
  229. inline fastcall dword IntToStr(dword ESI)
  230. {
  231.      $mov     edi, #buffer
  232.      $mov     ecx, 10
  233.      $test     esi, esi
  234.      $jns     f1
  235.      $mov     al, '-'
  236.      $stosb
  237.      $neg     esi
  238. f1:
  239.      $mov     eax, esi
  240.      $push     -'0'
  241. f2:
  242.      $xor     edx, edx
  243.      $div     ecx
  244.      $push     edx
  245.      $test     eax, eax
  246.      $jnz     f2
  247. f3:
  248.      $pop     eax
  249.      $add     al, '0'
  250.      $stosb
  251.      $jnz     f3
  252.      $mov     eax, #buffer
  253.      $ret
  254. }
  255.  
  256.  
  257. inline fastcall dword StrToInt()
  258. {
  259.         ESI=EDI=EAX;
  260.         IF(DSBYTE[ESI]=='-')ESI++;
  261.         EAX=0;
  262.         BH=AL;
  263.         do{
  264.                 BL=DSBYTE[ESI]-'0';
  265.                 EAX=EAX*10+EBX;
  266.                 ESI++;
  267.         }while(DSBYTE[ESI]>0);
  268.         IF(DSBYTE[EDI]=='-') -EAX;
  269. }
  270.  
  271.  
  272. inline fastcall int strcmp(ESI, EDI)
  273. {
  274.         loop()
  275.         {
  276.                 IF (DSBYTE[ESI]<DSBYTE[EDI]) RETURN -1;
  277.                 IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
  278.                 IF (DSBYTE[ESI]=='\0') RETURN 0;
  279.                 ESI++;
  280.                 EDI++;
  281.         }
  282. }
  283.  
  284. inline fastcall unsigned int find_symbol(ESI,BL)
  285. {
  286.         int jj=0, last=-1;
  287.         do{
  288.                 jj++;
  289.                 $lodsb
  290.                 IF(AL==BL) last=jj;
  291.         } while(AL!=0);
  292.         return last;
  293. }
  294.  
  295.  
  296. inline fastcall dword upcase(dword ESI)
  297. {
  298.         do{
  299.                 AL=DSBYTE[ESI];
  300.                 IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f;
  301.                 ESI++;
  302.         }while(AL!=0);
  303. }
  304.  
  305. /*inline fastcall void lowcase(ESI)
  306. {
  307.         do{
  308.                 $LODSB
  309.                 IF(AL>='A')&&(AL<='Z'){
  310.                         AL+=0x20;
  311.                         DSBYTE[ESI-1]=AL;
  312.                         CONTINUE;
  313.                 }
  314.         }while(AL!=0);
  315. }*/
  316.  
  317. inline fastcall lowcase(ESI)
  318. {
  319.         do{
  320.                 $LODSB
  321.                 IF(AL>='A')&&(AL<='Z'){
  322.                         AL+=0x20;
  323.                         DSBYTE[ESI-1]=AL;
  324.                         CONTINUE;
  325.                 }
  326.         }while(AL!=0);
  327. }
  328.  
  329.  
  330. inline fastcall wintodos (dword ESI)
  331. {
  332.    while (BL=ESBYTE[ESI])
  333.    {
  334.         IF (BL>=192)
  335.         {
  336.              IF (BL>=240) ESBYTE[ESI] = BL - 16;
  337.              ELSE ESBYTE[ESI] = BL - 64;
  338.         }
  339.         ELSE
  340.         {
  341.         IF (BL==178) ESBYTE[ESI] = 73;  //I
  342.         IF (BL==179) ESBYTE[ESI] = 105; //i
  343.         IF (BL==175) ESBYTE[ESI] = 244; //J
  344.     IF (BL==191) ESBYTE[ESI] = 245; //j
  345.         IF (BL==170) ESBYTE[ESI] = 242; //E
  346.         IF (BL==186) ESBYTE[ESI] = 243; //e
  347.     IF (BL==168) ESBYTE[ESI] = 240; //ð
  348.     IF (BL==184) ESBYTE[ESI] = 'e'; //e
  349.         IF (BL==180) ESBYTE[ESI] = 254; //ã
  350.     IF ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34;
  351.     IF ((BL==150) || (BL==151)) ESBYTE[ESI] = 45;
  352.         }
  353.         ESI++;
  354.    }
  355. }
  356.  
  357.  
  358. dword Hex2Symb(char* htmlcolor)
  359. {
  360.   dword j=0, symbol=0;
  361.   char ch=0x00;
  362.   FOR (;j<2;j++)
  363.   {
  364.     ch=ESBYTE[htmlcolor+j];
  365.     IF (ch==0x0d) || (ch=='\9') RETURN '';
  366.     IF ((ch>='0') && (ch<='9')) ch -= '0';
  367.     IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
  368.     IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
  369.     symbol = symbol*0x10 + ch;
  370.   }
  371.   wintodos(#symbol);
  372.   AL=symbol;
  373. }
  374.  
  375. byte mas[66] = "椥ä£å¨©ª«¬­®¯ïàáâ㦢ìë§èíéçꞀ–„…”ƒ•ˆ‰Š‹ŒŽŸ‘’“†‚œ›‡˜™—š";
  376. inline fastcall void koitodos(dword EDI)
  377. {
  378.         WHILE (BL=ESBYTE[EDI])
  379.         {      
  380.                 IF (BL >= 0xC0)
  381.                 {
  382.                         BL -= 0xC0;
  383.                         ESBYTE[EDI] = mas[BL];
  384.                 }
  385.                 //IF (ESBYTE[EDI]=='\244') ESBYTE[EDI]='i';
  386.                 EDI++;
  387.         }
  388. }
  389.  
  390.  
  391. //Asper
  392. //uncomplete
  393. inline fastcall int utf8rutodos(dword ESI) //-
  394. {
  395.     EDI=ESI;
  396.         while (BL=ESBYTE[ESI])
  397.         {      
  398.                 IF (BL == 0xD0) || (BL == 0xD1) EDI--;
  399.         else IF (BL == 0x81) && (ESBYTE[ESI-1]==0xD0) ESBYTE[EDI] = 0xF0; //è
  400.         else IF (BL == 0x91) && (ESBYTE[ESI-1]==0xD1) ESBYTE[EDI] = 0xF1; //¬
  401.         else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80) && (ESBYTE[ESI+2]==0x94)  //long defis
  402.         {
  403.           ESBYTE[EDI] = '-';
  404.           ESI+=2;
  405.         }  
  406.         else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80) && (ESBYTE[ESI+2]==0xA2)  //central point
  407.         {
  408.           ESBYTE[EDI] = '*';
  409.           ESI+=2;
  410.         }  
  411.         else IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xA9)  // (c)
  412.         {
  413.           ESBYTE[EDI] = '(';
  414.           ESBYTE[EDI+1] = 'c';
  415.           ESBYTE[EDI+2] = ')';
  416.           EDI+=2;
  417.           ESI++;
  418.         }  
  419.         ELSE IF (BL == 0xC2) && ((ESBYTE[ESI+1]==0xAB) || (ESBYTE[ESI+1]==0xBB))  // "
  420.         {
  421.           ESBYTE[EDI] = '\"';
  422.           ESI++;
  423.         }  
  424.         ELSE IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xB7)  // _
  425.         {
  426.           ESBYTE[EDI] = '_';
  427.           ESI++;
  428.         }  
  429.         ELSE IF (BL >= 0x90) && (BL <= 0xAF)
  430.                 {
  431.             BL -= 0x10;
  432.                         ESBYTE[EDI] = BL;
  433.                 }
  434.         ELSE IF (BL >= 0x80) && (BL <= 0x8F)
  435.                 {
  436.             BL += 0x60;
  437.                         ESBYTE[EDI] = BL;            
  438.                 }
  439.         ELSE IF (BL >= 0xB0) && (BL <= 0xBF)
  440.                 {
  441.             BL -= 0x10;
  442.                         ESBYTE[EDI] = BL;
  443.                 }
  444.         ELSE ESBYTE[EDI] = BL;
  445.                 ESI++;
  446.         EDI++;
  447.         }
  448.         WHILE (EDI<ESI)
  449.         {
  450.         ESBYTE[EDI] = ' ';
  451.         EDI++;
  452.     }
  453. }
  454.  
  455. //------------------------------------------------------------------------------
  456.  
  457. byte WindowRePaint=0;
  458. inline fastcall void WindowRedrawStatus(dword EBX)
  459. {
  460.         EAX = 12;              // function 12:tell os about windowdraw
  461.         $int 0x40
  462.         IF (EBX==1) WindowRePaint=1; ELSE WindowRePaint=0;
  463. }
  464.  
  465. void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
  466. {
  467.         EBX = x << 16 + sizeX;
  468.         ECX = y << 16 + sizeY;
  469.         EDX = mainAreaType << 24 | mainAreaColour;
  470.         ESI = headerType << 24 | headerColour;
  471.         $xor eax,eax
  472.         $int 0x40
  473. }  
  474.  
  475. inline fastcall dword CreateThread(dword ECX,EDX)
  476. {
  477.         EAX = 51;
  478.         EBX = 1;
  479.         $int 0x40
  480. }
  481.  
  482. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  483. {
  484.         EAX = 4;
  485.         EBX = x<<16+y;
  486.         ECX = fontType<<24+color;
  487.         $int 0x40;
  488. }
  489.  
  490. void PutImage(dword EBX,w,h,x,y)
  491. {
  492.         EAX = 7;
  493.         ECX = w<<16+h;
  494.         EDX = x<<16+y;
  495.         $int 0x40
  496. }
  497.  
  498. void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
  499. {
  500.         EAX = 65;
  501.         ECX = w<<16+h;
  502.         EDX = x<<16+y;
  503.         EBP = 0;
  504.         $int 0x40
  505. }
  506.  
  507. inline fastcall void PutPixel(dword EBX,ECX,EDX){
  508.   EAX=1;
  509.   $int 0x40
  510. }
  511.  
  512. void DrawBar(dword x,y,w,h,EDX)
  513. {
  514.         EAX = 13;
  515.         EBX = x<<16+w;
  516.         ECX = y<<16+h;
  517.         $int 0x40
  518. }
  519.  
  520. void DefineButton(dword x,y,w,h,EDX,ESI)
  521. {
  522.         EAX = 8;
  523.         EBX = x<<16+w;
  524.         ECX = y<<16+h;
  525.         $int 0x40
  526. }
  527.  
  528. inline fastcall void DeleteButton(dword EDX)
  529. {
  530.         EAX = 8;
  531.         EDX += BT_DEL;
  532.         $int 0x40;
  533. }
  534.  
  535. void DrawRegion(dword x,y,width,height,color1)
  536. {
  537.         DrawBar(x,y,width,1,color1); //¯®«®á  £®à ᢥàåã
  538.         DrawBar(x,y+height,width,1,color1); //¯®«®á  £®à á­¨§ã
  539.         DrawBar(x,y,1,height,color1); //¯®«®á  ¢¥àåã á«¥¢ 
  540.         DrawBar(x+width,y,1,height+1,color1); //¯®«®á  ¢¥àåã á¯à ¢ 
  541. }
  542.  
  543. void DrawRegion_3D(dword x,y,width,height,color1,color2)
  544. {
  545.         DrawBar(x,y,width+1,1,color1); //¯®«®á  £®à ᢥàåã
  546.         DrawBar(x,y+1,1,height-1,color1); //¯®«®á  á«¥¢ 
  547.         DrawBar(x+width,y+1,1,height,color2); //¯®«®á  á¯à ¢ 
  548.         DrawBar(x,y+height,width,1,color2); //¯®«®á  £®à á­¨§ã
  549. }
  550.  
  551. void DrawFlatButton(dword x,y,width,height,id,color,text)
  552. {
  553.         DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
  554.         DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
  555.         DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
  556.         IF (id<>0)      DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
  557.         WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
  558. }
  559.  
  560. void DrawCircle(int x, y, r)
  561. {
  562.         int i; float px=0, py=r, ii = r * 3.1415926 * 2;
  563.         FOR (i = 0; i < ii; i++)
  564.         {
  565.         PutPixel(px + x, y - py, 0);
  566.         px = py / r + px;
  567.         py = -px / r + py;
  568.                 //Pause(1);
  569.         }
  570. }
  571.  
  572. //------------------------------------------------------------------------------
  573.  
  574. inline fastcall dword WriteDebug(dword EDX)
  575. {
  576.         $push ebx
  577.         $push ecx
  578.         $mov eax, 63
  579.         $mov ebx, 1
  580. next_char:
  581.         $mov ecx, DSDWORD[edx]
  582.         $or      cl, cl
  583.         $jz  done
  584.         $int 0x40
  585.         $inc edx
  586.         $jmp next_char
  587. done:
  588.         $mov cl, 13
  589.         $int 0x40
  590.         $mov cl, 10
  591.         $int 0x40
  592.         $pop ecx
  593.         $pop ebx
  594. }
  595.