Subversion Repositories Kolibri OS

Rev

Rev 2566 | 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.  
  68. struct system_colors{
  69.         dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
  70.         void get();
  71. };
  72. void system_colors::get()
  73. {
  74.         EAX = 48;
  75.         EBX = 3;
  76.         ECX = #frame;
  77.         EDX = 40;
  78.         $int 0x40
  79. }
  80.  
  81. //------------------------------------------------------------------------------
  82.  
  83. inline fastcall dword WaitEvent(){
  84.  EAX = 10;
  85.  $int 0x40
  86. }
  87.  
  88. inline fastcall dword WaitEventTimeout(dword EBX){
  89.  EAX = 23;
  90.  $int 0x40
  91. }
  92.  
  93. inline fastcall SetEventMask(dword EBX)
  94. {
  95.  EAX = 40;
  96.  $int 0x40
  97. }
  98.  
  99. inline fastcall ScancodesGeting(){
  100.         $mov eax,66;
  101.         $mov ebx,1;
  102.         $mov ecx,1; //᪠­ª®¤ë
  103.         $int 0x40
  104. }
  105.  
  106.  
  107. inline fastcall word GetKey(){ //Gluk fix
  108.                 $push edx
  109. @getkey:
  110.                 $mov  eax,2
  111.                 $int  0x40
  112.                 $cmp eax,1
  113.                 $jne getkeyi
  114.                 $mov ah,dh
  115.                 $jmp getkeyii //jz?
  116. @getkeyi:
  117.                 $mov dh,ah
  118.                 $jmp getkey
  119. @getkeyii:
  120.                 $pop edx
  121.                 EAX = EAX >> 8;          
  122. }
  123.  
  124.  
  125. inline fastcall Pause(dword EBX)
  126. {                                       // ã§ , ¢ á®âëå ¤®«ïå ᥪ㭤ë EBX = value
  127.         $mov eax, 5
  128.         $int 0x40
  129. }
  130.  
  131. //==================================================================
  132.  
  133. inline fastcall word GetButtonID(){
  134.  EAX = 17;
  135.  $int  0x40
  136.  EAX = EAX >> 8;
  137. }
  138.  
  139. struct proc_info{
  140.         dword   use_cpu;
  141.         word    pos_in_stack,num_slot,rezerv1;
  142.         char    name[11];
  143.         char    rezerv2;
  144.         dword   adress,use_memory,ID,left,top,width,height;
  145.         word    status_slot,rezerv3;
  146.         dword   work_left,work_top,work_width,work_height;
  147.         char    status_window;
  148.         void    GetInfo(dword ECX);
  149.         byte    reserved[1024-71];
  150. #define SelfInfo -1
  151. };
  152.  
  153. void GetProcessInfo(dword EBX, ECX)
  154. {
  155.         EAX = 9;
  156.         $int  0x40
  157. }
  158.  
  159. int GetProcessSlot(ECX) //ECX = process ID
  160. {
  161.         EAX = 18;
  162.         EBX = 21;
  163.         $int 0x40;     
  164. }
  165.  
  166. inline fastcall ExitProcess(){
  167.  EAX = -1;              // close this program
  168.  $int 0x40
  169. }
  170.  
  171. inline fastcall KillProcess(dword ECX){
  172.         $mov eax,18;
  173.         $mov ebx,18;
  174.         $int 0x40
  175. }
  176.  
  177. //==================================================================
  178.  
  179. //eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
  180. inline fastcall int GetSystemLanguage(){
  181.  EAX = 26;
  182.  EBX = 5;
  183.  $int 0x40
  184.  RETURN EAX;
  185. }
  186.  
  187. inline fastcall void DrawTitle(dword ECX)
  188. {
  189.         EAX = 71;
  190.         EBX = 1;
  191.         $int 0x40;
  192. }
  193.  
  194. inline fastcall dword GetSkinWidth()
  195. {
  196.         EAX = 48;
  197.         EBX = 4;
  198.         $int 0x40
  199. }
  200.  
  201. inline fastcall void SetSystemSkin(ECX){
  202.         EAX = 48;
  203.         EBX = 8;
  204.         $int 0x40
  205. }
  206.  
  207. inline fastcall dword GetScreenWidth()
  208. {
  209.         EAX = 14;
  210.         EBX = 4;
  211.         $int 0x40
  212.         $shr eax, 16
  213.         $and eax,0x0000FFFF
  214. }
  215.  
  216. inline fastcall MoveSize(dword EBX,ECX,EDX,ESI)
  217. {
  218.         EAX = 67;
  219.         $int 0x40
  220. }
  221.  
  222. inline fastcall dword LoadLibrary(dword ECX)
  223. {
  224.         $mov eax, 68
  225.         $mov ebx, 19
  226.         $int  0x40
  227. }
  228.  
  229. //------------------------------------------------------------------------------
  230. inline fastcall dword strlen(dword EDI){
  231.         EAX=0;
  232.         ECX=-1;
  233.         $REPNE $SCASB
  234.         EAX-=2+ECX;
  235. }
  236.  
  237. inline fastcall copystr(dword ESI,EDI)
  238. {
  239.         $cld
  240. l1:
  241.         $lodsb
  242.         $stosb
  243.         $test al,al
  244.         $jnz l1
  245. }
  246.  
  247.  
  248. byte fastcall TestBit(EAX, CL)
  249. {
  250.         $shr eax,cl
  251.         $and eax,1
  252. }
  253.  
  254. char buffer[11]="";
  255. inline fastcall dword IntToStr(dword ESI)
  256. {
  257.      $mov     edi, #buffer
  258.      $mov     ecx, 10
  259.      $test     esi, esi
  260.      $jns     f1
  261.      $mov     al, '-'
  262.      $stosb
  263.      $neg     esi
  264. f1:
  265.      $mov     eax, esi
  266.      $push     -'0'
  267. f2:
  268.      $xor     edx, edx
  269.      $div     ecx
  270.      $push     edx
  271.      $test     eax, eax
  272.      $jnz     f2
  273. f3:
  274.      $pop     eax
  275.      $add     al, '0'
  276.      $stosb
  277.      $jnz     f3
  278.      $mov     eax, #buffer
  279.      $ret
  280. }
  281.  
  282.  
  283. inline fastcall dword StrToInt()
  284. {
  285.         ESI=EDI=EAX;
  286.         IF(DSBYTE[ESI]=='-')ESI++;
  287.         EAX=0;
  288.         BH=AL;
  289.         do{
  290.                 BL=DSBYTE[ESI]-'0';
  291.                 EAX=EAX*10+EBX;
  292.                 ESI++;
  293.         }while(DSBYTE[ESI]>0);
  294.         IF(DSBYTE[EDI]=='-') -EAX;
  295. }
  296.  
  297.  
  298. inline fastcall int strcmp(ESI, EDI)
  299. {
  300.         loop()
  301.         {
  302.                 IF (DSBYTE[ESI]<DSBYTE[EDI]) RETURN -1;
  303.                 IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
  304.                 IF (DSBYTE[ESI]=='\0') RETURN 0;
  305.                 ESI++;
  306.                 EDI++;
  307.         }
  308. }
  309.  
  310. inline fastcall unsigned int find_symbol(ESI,BL)
  311. {
  312.         int jj=0, last=-1;
  313.         do{
  314.                 jj++;
  315.                 $lodsb
  316.                 IF(AL==BL) last=jj;
  317.         } while(AL!=0);
  318.         return last;
  319. }
  320.  
  321.  
  322. inline fastcall dword upcase(dword ESI)
  323. {
  324.         do{
  325.                 AL=DSBYTE[ESI];
  326.                 IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f;
  327.                 ESI++;
  328.         }while(AL!=0);
  329. }
  330.  
  331. /*inline fastcall void lowcase(ESI)
  332. {
  333.         do{
  334.                 $LODSB
  335.                 IF(AL>='A')&&(AL<='Z'){
  336.                         AL+=0x20;
  337.                         DSBYTE[ESI-1]=AL;
  338.                         CONTINUE;
  339.                 }
  340.         }while(AL!=0);
  341. }*/
  342.  
  343. inline fastcall lowcase(ESI)
  344. {
  345.         do{
  346.                 $LODSB
  347.                 IF(AL>='A')&&(AL<='Z'){
  348.                         AL+=0x20;
  349.                         DSBYTE[ESI-1]=AL;
  350.                         CONTINUE;
  351.                 }
  352.         }while(AL!=0);
  353. }
  354.  
  355.  
  356. dword Hex2Symb(char* htmlcolor)
  357. {
  358.   dword j=0, symbol=0;
  359.   char ch=0x00;
  360.   FOR (;j<2;j++)
  361.   {
  362.     ch=ESBYTE[htmlcolor+j];
  363.     IF (ch==0x0d) || (ch=='\9') RETURN '';
  364.     IF ((ch>='0') && (ch<='9')) ch -= '0';
  365.     IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
  366.     IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
  367.     symbol = symbol*0x10 + ch;
  368.   }
  369.   wintodos(#symbol);
  370.   AL=symbol;
  371. }
  372.  
  373. /*int hex2char(char c)
  374. {
  375.   if (c <=9)
  376.     return (c+48);
  377.  
  378.   return (c - 10 + 'a');
  379. }
  380.  
  381. int hex2char(dword c)
  382. {
  383.   if (c <=9)
  384.     return (c+48);
  385.  
  386.   return (c - 10 + 'a');
  387. }*/
  388.  
  389.  
  390.  
  391. void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
  392. {
  393.         EAX = 12;              // function 12:tell os about windowdraw
  394.         EBX = 1;
  395.         $int 0x40
  396.        
  397.         EBX = x << 16 + sizeX;
  398.         ECX = y << 16 + sizeY;
  399.         EDX = mainAreaType << 24 | mainAreaColour;
  400.         ESI = headerType << 24 | headerColour;
  401.         $xor eax,eax
  402.         $int 0x40
  403.  
  404.         EAX = 12;              // function 12:tell os about windowdraw
  405.         EBX = 2;
  406.         $int 0x40
  407. }
  408.  
  409.  
  410. inline fastcall dword CreateThread(dword ECX,EDX)
  411. {
  412.         EAX = 51;
  413.         EBX = 1;
  414.         $int 0x40
  415. }
  416.  
  417. inline fastcall int GetSlot(dword ECX)
  418. {
  419.         EAX = 18;
  420.         EBX = 21;
  421.         $int 0x40
  422. }
  423.  
  424. inline fastcall int GetActiveProcess()
  425. {
  426.         EAX = 18;
  427.         EBX = 7;
  428.         $int 0x40
  429. }
  430.  
  431.  
  432. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  433. {
  434.         EAX = 4;
  435.         EBX = x<<16+y;
  436.         ECX = fontType<<24+color;
  437.         $int 0x40;
  438. }
  439.  
  440. void CopyScreen(dword EBX, x, y, sizeX, sizeY)
  441. {
  442.   EAX = 36;
  443.   ECX = sizeX << 16 + sizeY;
  444.   EDX = x << 16 + y;
  445.   $int  0x40;
  446. }
  447.  
  448. void PutImage(dword EBX,w,h,x,y)
  449. {
  450.         EAX = 7;
  451.         ECX = w<<16+h;
  452.         EDX = x<<16+y;
  453.         $int 0x40
  454. }
  455.  
  456. void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
  457. {
  458.         EAX = 65;
  459.         ECX = w<<16+h;
  460.         EDX = x<<16+y;
  461.         EBP = 0;
  462.         $int 0x40
  463. }
  464.  
  465. inline fastcall void PutPixel(dword EBX,ECX,EDX){
  466.   EAX=1;
  467.   $int 0x40
  468. }
  469.  
  470. void DrawBar(dword x,y,w,h,EDX)
  471. {
  472.         EAX = 13;
  473.         EBX = x<<16+w;
  474.         ECX = y<<16+h;
  475.         $int 0x40
  476. }
  477.  
  478. void DefineButton(dword x,y,w,h,EDX,ESI)
  479. {
  480.         EAX = 8;
  481.         $push edx
  482.         EDX += BT_DEL; //âíà÷àëå óäàëÿåì êíîïó ñ ýòè èä, ïîòîì ñîçäà¸ì
  483.         $int 0x40;
  484.         EBX = x<<16+w;
  485.         ECX = y<<16+h;
  486.         $pop edx
  487.         $int 0x40
  488. }
  489.  
  490. inline fastcall void DeleteButton(dword EDX)
  491. {
  492.         EAX = 8;
  493.         EDX += BT_DEL;
  494.         $int 0x40;
  495. }
  496.  
  497. :void DrawRegion(dword x,y,width,height,color1)
  498. {
  499.         DrawBar(x,y,width,1,color1); //¯®«®á  £®à ᢥàåã
  500.         DrawBar(x,y+height,width,1,color1); //¯®«®á  £®à á­¨§ã
  501.         DrawBar(x,y,1,height,color1); //¯®«®á  ¢¥àåã á«¥¢ 
  502.         DrawBar(x+width,y,1,height+1,color1); //¯®«®á  ¢¥àåã á¯à ¢ 
  503. }
  504.  
  505. :void DrawRegion_3D(dword x,y,width,height,color1,color2)
  506. {
  507.         DrawBar(x,y,width+1,1,color1); //¯®«®á  £®à ᢥàåã
  508.         DrawBar(x,y+1,1,height-1,color1); //¯®«®á  á«¥¢ 
  509.         DrawBar(x+width,y+1,1,height,color2); //¯®«®á  á¯à ¢ 
  510.         DrawBar(x,y+height,width,1,color2); //¯®«®á  £®à á­¨§ã
  511. }
  512.  
  513. void DrawFlatButton(dword x,y,width,height,id,color,text)
  514. {
  515.         DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
  516.         DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
  517.         DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
  518.         IF (id<>0)      DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
  519.         WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
  520. }
  521.  
  522. :void DrawCircle(int x, y, r)
  523. {
  524.         int i; float px=0, py=r, ii = r * 3.1415926 * 2;
  525.         FOR (i = 0; i < ii; i++)
  526.         {
  527.         PutPixel(px + x, y - py, 0);
  528.         px = py / r + px;
  529.         py = -px / r + py;
  530.                 //Pause(1);
  531.         }
  532. }
  533.  
  534. //------------------------------------------------------------------------------
  535.  
  536. inline fastcall dword WriteDebug(dword EDX)
  537. {
  538.         $push ebx
  539.         $push ecx
  540.         $mov eax, 63
  541.         $mov ebx, 1
  542. next_char:
  543.         $mov ecx, DSDWORD[edx]
  544.         $or      cl, cl
  545.         $jz  done
  546.         $int 0x40
  547.         $inc edx
  548.         $jmp next_char
  549. done:
  550.         $mov cl, 13
  551.         $int 0x40
  552.         $mov cl, 10
  553.         $int 0x40
  554.         $pop ecx
  555.         $pop ebx
  556. }
  557.