Subversion Repositories Kolibri OS

Rev

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