Subversion Repositories Kolibri OS

Rev

Rev 2839 | 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. #define OLD      -1
  24. #define true      1
  25. #define false     0
  26.  
  27. //Button options
  28. #define BT_DEL      0x80000000
  29. #define BT_HIDE     0x40000000
  30. #define BT_NOFRAME  0x20000000
  31.  
  32. //-------------------------------------------------------------------------
  33.  
  34. struct mouse
  35. {
  36.         int x,y,lkm,pkm,hor,vert;
  37.         void get();
  38. };
  39.  
  40. void mouse::get()
  41. {
  42.         EAX = 37;
  43.         EBX = 1;
  44.         $int    0x40
  45.         $mov    ebx, eax
  46.         $shr    eax, 16
  47.         $and    ebx,0x0000FFFF
  48.         x = EAX;
  49.         y = EBX;
  50.         EAX = 37;
  51.         EBX = 2;
  52.         $int    0x40
  53.         $mov    ebx, eax
  54.         $and    eax, 0x00000001
  55.         $shr    ebx, 1
  56.         $and    ebx, 0x00000001
  57.         lkm = EAX;
  58.         pkm = EBX;
  59.         EAX = 37; //áªà®««
  60.         EBX = 7;
  61.         $int    0x40
  62.         $mov    ebx, eax
  63.         $shr    eax, 16
  64.         $and    ebx,0x0000FFFF
  65.         //hor = EAX;
  66.         vert = EBX;
  67. }
  68.  
  69.  
  70. struct system_colors
  71. {
  72.         dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
  73.         void get();
  74. };
  75.  
  76. void system_colors::get()
  77. {
  78.         EAX = 48;
  79.         EBX = 3;
  80.         ECX = #frame;
  81.         EDX = 40;
  82.         $int 0x40
  83. }
  84.  
  85. //------------------------------------------------------------------------------
  86.  
  87. inline fastcall dword WaitEvent()
  88. {
  89.         $mov eax,10
  90.         $int 0x40
  91. }
  92.  
  93. inline fastcall dword CheckEvent()
  94. {
  95.         $mov eax,11
  96.         $int 0x40
  97. }
  98.  
  99. inline fastcall dword WaitEventTimeout( EBX)
  100. {
  101.         $mov eax,23
  102.         $int 0x40
  103. }
  104.  
  105. inline fastcall SetEventMask( EBX)
  106. {
  107.         $mov eax,40
  108.         $int 0x40
  109. }
  110.  
  111. inline fastcall ScancodesGeting(){
  112.         $mov eax,66
  113.         $mov ebx,1
  114.         $mov ecx,1 //᪠­ª®¤ë
  115.         $int 0x40
  116. }
  117.  
  118.  
  119. inline fastcall word GetKey()  //+Gluk fix
  120. {
  121.                 $push edx
  122. @getkey:
  123.                 $mov  eax,2
  124.                 $int  0x40
  125.                 $cmp eax,1
  126.                 $jne getkeyi
  127.                 $mov ah,dh
  128.                 $jmp getkeyii //jz?
  129. @getkeyi:
  130.                 $mov dh,ah
  131.                 $jmp getkey
  132. @getkeyii:
  133.                 $pop edx
  134.                 $shr eax,8
  135. }
  136.  
  137.  
  138. inline fastcall Pause( EBX)
  139. {
  140.         $mov eax, 5
  141.         $int 0x40
  142. }
  143.  
  144. inline fastcall word GetButtonID()
  145. {
  146.         $mov eax,17
  147.         $int  0x40
  148.         $shr eax,8
  149. }
  150.  
  151. //----------------------------------------
  152.  
  153. struct proc_info
  154. {
  155.         #define SelfInfo -1
  156.         dword   use_cpu;
  157.         word    pos_in_stack,num_slot,rezerv1;
  158.         char    name[11];
  159.         char    rezerv2;
  160.         dword   adress,use_memory,ID,left,top,width,height;
  161.         word    status_slot,rezerv3;
  162.         dword   work_left,work_top,work_width,work_height;
  163.         char    status_window;
  164.         void    GetInfo( ECX);
  165.         byte    reserved[1024-71];
  166. };
  167.  
  168. inline fastcall void GetProcessInfo( EBX, ECX)
  169. {
  170.         $mov eax,9;
  171.         $int  0x40
  172. }
  173.  
  174. inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
  175. {
  176.         $mov eax,34
  177.         $int 0x40
  178. }
  179.  
  180. inline fastcall int GetProcessSlot( ECX)
  181. {
  182.         EAX = 18;
  183.         EBX = 21;
  184.         $int 0x40
  185. }
  186.  
  187. inline fastcall int GetActiveProcess()
  188. {
  189.         EAX = 18;
  190.         EBX = 7;
  191.         $int 0x40
  192. }
  193.  
  194. inline fastcall int CreateThread( ECX,EDX)
  195. {
  196.         $mov eax,51
  197.         $mov ebx,1
  198.         $int 0x40
  199. }
  200.  
  201. inline fastcall void SwitchToAnotherThread()
  202. {
  203.         $mov eax,68
  204.         $mov ebx,1
  205.         $int 0x40
  206. }
  207.  
  208. inline fastcall int KillProcess( ECX)
  209. {
  210.         $mov eax,18;
  211.         $mov ebx,18;
  212.         $int 0x40
  213. }
  214.  
  215. inline fastcall int ExitSystem( ECX)
  216. {
  217.         #define TURN_OFF 2
  218.         #define REBOOT 3
  219.         #define KERNEL 4
  220.        
  221.         $mov eax, 18
  222.         $mov ebx, 9
  223.         $int 0x40
  224. }
  225.  
  226. inline fastcall ExitProcess()
  227. {
  228.         $mov eax,-1;
  229.         $int 0x40
  230. }
  231.  
  232. //------------------------------------------------------------------------------
  233.  
  234. //eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
  235. inline fastcall int GetSystemLanguage()
  236. {
  237.         EAX = 26;
  238.         EBX = 5;
  239.         $int 0x40
  240. }
  241.  
  242. inline fastcall dword GetSkinHeight()
  243. {
  244.         $push ebx
  245.         $mov  eax,48
  246.         $mov  ebx,4
  247.         $int 0x40
  248.         $pop  ebx
  249. }
  250.  
  251. inline fastcall void SetSystemSkin( ECX)
  252. {
  253.         EAX = 48;
  254.         EBX = 8;
  255.         $int 0x40
  256. }
  257.  
  258. inline fastcall int GetScreenWidth()
  259. {
  260.         $mov eax, 14
  261.         $int 0x40
  262.         $shr eax, 16
  263. }
  264.  
  265. inline fastcall int GetScreenHeight()
  266. {
  267.         $mov eax, 14
  268.         $int 0x40
  269.         $and eax,0x0000FFFF
  270. }
  271.  
  272. inline fastcall dword LoadLibrary( ECX)
  273. {
  274.         $mov eax, 68
  275.         $mov ebx, 19
  276.         $int  0x40
  277. }
  278.  
  279. inline fastcall int TestBit( EAX, CL)
  280. {
  281.         $shr eax,cl
  282.         $and eax,1
  283. }
  284.  
  285.  
  286. //------------------------------------------------------------------------------
  287.  
  288. void DefineAndDrawWindow(dword x,y, sizeX,sizeY, byte WindowType,dword WindowAreaColor, EDI)
  289. {
  290.         EAX = 12;              // function 12:tell os about windowdraw
  291.         EBX = 1;
  292.         $int 0x40
  293.        
  294.         EAX = 0;
  295.         EBX = x << 16 + sizeX;
  296.         ECX = y << 16 + sizeY;
  297.         EDX = WindowType << 24 | WindowAreaColor;
  298.         $int 0x40
  299.  
  300.         EAX = 12;              // function 12:tell os about windowdraw
  301.         EBX = 2;
  302.         $int 0x40
  303. }
  304.  
  305. inline fastcall MoveSize( EBX,ECX,EDX,ESI)
  306. {
  307.         $mov eax, 67
  308.         $int 0x40
  309. }
  310.  
  311. inline fastcall void DrawTitle( ECX)
  312. {
  313.         EAX = 71;
  314.         EBX = 1;
  315.         $int 0x40;
  316. }
  317.  
  318. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  319. {
  320.         EAX = 4;
  321.         EBX = x<<16+y;
  322.         ECX = fontType<<24+color;
  323.         $int 0x40;
  324. }
  325.  
  326. void CopyScreen(dword EBX, x, y, sizeX, sizeY)
  327. {
  328.   EAX = 36;
  329.   ECX = sizeX << 16 + sizeY;
  330.   EDX = x << 16 + y;
  331.   $int  0x40;
  332. }
  333.  
  334. dword GetPixelColor(dword x, x_size, y)
  335. {
  336.         $mov eax, 35
  337.         EBX= y*x_size+x;
  338.         $int 0x40
  339. }
  340.  
  341. void PutImage(dword EBX,w,h,x,y)
  342. {
  343.         EAX = 7;
  344.         ECX = w<<16+h;
  345.         EDX = x<<16+y;
  346.         $int 0x40
  347. }
  348.  
  349. void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
  350. {
  351.         EAX = 65;
  352.         ECX = w<<16+h;
  353.         EDX = x<<16+y;
  354.         EBP = 0;
  355.         $int 0x40
  356. }
  357.  
  358. inline fastcall void PutPixel( EBX,ECX,EDX)
  359. {
  360.   EAX=1;
  361.   $int 0x40
  362. }
  363.  
  364. void DrawBar(dword x,y,w,h,EDX)
  365. {
  366.         EAX = 13;
  367.         EBX = x<<16+w;
  368.         ECX = y<<16+h;
  369.         $int 0x40
  370. }
  371.  
  372. void DefineButton(dword x,y,w,h,EDX,ESI)
  373. {
  374.         EAX = 8;
  375.         EBX = x<<16+w;
  376.         ECX = y<<16+h;
  377.         $int 0x40
  378. }
  379.  
  380. inline fastcall void DeleteButton( EDX)
  381. {
  382.         EAX = 8;
  383.         EDX += BT_DEL;
  384.         $int 0x40;
  385. }
  386.  
  387.  
  388. //------------------------------------------------------------------------------
  389.  
  390. :void DrawRegion(dword x,y,width,height,color1)
  391. {
  392.         DrawBar(x,y,width,1,color1); //¯®«®á  £®à ᢥàåã
  393.         DrawBar(x,y+height,width,1,color1); //¯®«®á  £®à á­¨§ã
  394.         DrawBar(x,y,1,height,color1); //¯®«®á  ¢¥àåã á«¥¢ 
  395.         DrawBar(x+width,y,1,height+1,color1); //¯®«®á  ¢¥àåã á¯à ¢ 
  396. }
  397.  
  398. :void DrawRegion_3D(dword x,y,width,height,color1,color2)
  399. {
  400.         DrawBar(x,y,width+1,1,color1); //¯®«®á  £®à ᢥàåã
  401.         DrawBar(x,y+1,1,height-1,color1); //¯®«®á  á«¥¢ 
  402.         DrawBar(x+width,y+1,1,height,color2); //¯®«®á  á¯à ¢ 
  403.         DrawBar(x,y+height,width,1,color2); //¯®«®á  £®à á­¨§ã
  404. }
  405.  
  406. :void DrawFlatButton(dword x,y,width,height,id,color,text)
  407. {
  408.         DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
  409.         DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
  410.         DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
  411.         IF (id<>0)      DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
  412.         //WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
  413.         WriteText(width/2+x+1,height/2-3+y,0x80,0,text,0);
  414. }
  415.  
  416. :void DrawCircle(int x, y, r)
  417. {
  418.         int i;
  419.         float px=0, py=r, ii = r * 3.1415926 * 2;
  420.         FOR (i = 0; i < ii; i++)
  421.         {
  422.         PutPixel(px + x, y - py, 0);
  423.         px = py / r + px;
  424.         py = -px / r + py;
  425.         }
  426. }
  427.  
  428. //------------------------------------------------------------------------------
  429.  
  430. inline fastcall void debug( EDX)
  431. {
  432.         $push ebx
  433.         $push ecx
  434.         $mov eax, 63
  435.         $mov ebx, 1
  436. next_char:
  437.         $mov ecx, DSDWORD[edx]
  438.         $or      cl, cl
  439.         $jz  done
  440.         $int 0x40
  441.         $inc edx
  442.         $jmp next_char
  443. done:
  444.         $mov cl, 13
  445.         $int 0x40
  446.         $mov cl, 10
  447.         $int 0x40
  448.         $pop ecx
  449.         $pop ebx
  450. }
  451.