Subversion Repositories Kolibri OS

Rev

Rev 3003 | 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. 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. inline fastcall word GetButtonID()
  144. {
  145.         $mov eax,17
  146.         $int  0x40
  147.         $shr eax,8
  148. }
  149.  
  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. inline fastcall void GetProcessInfo( EBX, ECX)
  168. {
  169.         $mov eax,9;
  170.         $int  0x40
  171. }
  172.  
  173. inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
  174. {
  175.         $mov eax,34
  176.         $int 0x40
  177. }
  178.  
  179. inline fastcall int GetProcessSlot( ECX)
  180. {
  181.         EAX = 18;
  182.         EBX = 21;
  183.         $int 0x40
  184. }
  185.  
  186. inline fastcall int GetActiveProcess()
  187. {
  188.         EAX = 18;
  189.         EBX = 7;
  190.         $int 0x40
  191. }
  192.  
  193. inline fastcall int CreateThread( ECX,EDX)
  194. {
  195.         $mov eax,51
  196.         $mov ebx,1
  197.         $int 0x40
  198. }
  199.  
  200. inline fastcall void SwitchToAnotherThread()
  201. {
  202.         $mov eax,68
  203.         $mov ebx,1
  204.         $int 0x40
  205. }
  206.  
  207. inline fastcall int KillProcess( ECX)
  208. {
  209.         $mov eax,18;
  210.         $mov ebx,18;
  211.         $int 0x40
  212. }
  213.  
  214. #define TURN_OFF 2
  215. #define REBOOT 3
  216. #define KERNEL 4
  217. inline fastcall int ExitSystem( ECX)
  218. {
  219.         $mov eax, 18
  220.         $mov ebx, 9
  221.         $int 0x40
  222. }
  223.  
  224. inline fastcall ExitProcess()
  225. {
  226.         $mov eax,-1;
  227.         $int 0x40
  228. }
  229.  
  230. //------------------------------------------------------------------------------
  231.  
  232. //eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
  233. inline fastcall int GetSystemLanguage()
  234. {
  235.         EAX = 26;
  236.         EBX = 5;
  237.         $int 0x40
  238. }
  239.  
  240. inline fastcall dword GetSkinHeight()
  241. {
  242.         $push ebx
  243.         $mov  eax,48
  244.         $mov  ebx,4
  245.         $int 0x40
  246.         $pop  ebx
  247. }
  248.  
  249. inline fastcall void SetSystemSkin( ECX)
  250. {
  251.         EAX = 48;
  252.         EBX = 8;
  253.         $int 0x40
  254. }
  255.  
  256. inline fastcall int GetScreenWidth()
  257. {
  258.         $mov eax, 14
  259.         $int 0x40
  260.         $shr eax, 16
  261. }
  262.  
  263. inline fastcall int GetScreenHeight()
  264. {
  265.         $mov eax, 14
  266.         $int 0x40
  267.         $and eax,0x0000FFFF
  268. }
  269.  
  270. inline fastcall dword LoadLibrary( ECX)
  271. {
  272.         $mov eax, 68
  273.         $mov ebx, 19
  274.         $int  0x40
  275. }
  276.  
  277. inline fastcall int TestBit( EAX, CL)
  278. {
  279.         $shr eax,cl
  280.         $and eax,1
  281. }
  282.  
  283. inline fastcall int PlaySpeaker( ESI)
  284. {
  285.         $mov eax, 55
  286.         $mov ebx, 55
  287.         $int 0x40
  288. }
  289.  
  290. //------------------------------------------------------------------------------
  291.  
  292. void DefineAndDrawWindow(dword x,y, sizeX,sizeY, byte WindowType,dword WindowAreaColor, EDI)
  293. {
  294.         EAX = 12;              // function 12:tell os about windowdraw
  295.         EBX = 1;
  296.         $int 0x40
  297.        
  298.         EAX = 0;
  299.         EBX = x << 16 + sizeX;
  300.         ECX = y << 16 + sizeY;
  301.         EDX = WindowType << 24 | WindowAreaColor;
  302.         $int 0x40
  303.  
  304.         EAX = 12;              // function 12:tell os about windowdraw
  305.         EBX = 2;
  306.         $int 0x40
  307. }
  308.  
  309. inline fastcall DeleteAllButtons()
  310. {
  311.         EAX = 12;              // function 12:tell os about windowdraw
  312.         EBX = 1;
  313.         $int 0x40
  314.         EBX = 2;
  315.         $int 0x40
  316. }
  317.  
  318. inline fastcall MoveSize( EBX,ECX,EDX,ESI)
  319. {
  320.         $mov eax, 67
  321.         $int 0x40
  322. }
  323.  
  324. inline fastcall void DrawTitle( ECX)
  325. {
  326.         EAX = 71;
  327.         EBX = 1;
  328.         $int 0x40;
  329. }
  330.  
  331. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  332. {
  333.         EAX = 4;
  334.         EBX = x<<16+y;
  335.         ECX = fontType<<24+color;
  336.         $int 0x40;
  337. }
  338.  
  339. void WriteNumber(dword x,y,byte fontType, dword color, count, ECX)
  340. {
  341.         EAX = 47;
  342.         EBX = count<<16;
  343.         EDX = x<<16+y;
  344.         ESI = fontType<<24+color;
  345.         $int 0x40;
  346. }
  347.  
  348. void CopyScreen(dword EBX, x, y, sizeX, sizeY)
  349. {
  350.   EAX = 36;
  351.   ECX = sizeX << 16 + sizeY;
  352.   EDX = x << 16 + y;
  353.   $int  0x40;
  354. }
  355.  
  356. dword GetPixelColor(dword x, x_size, y)
  357. {
  358.         $mov eax, 35
  359.         EBX= y*x_size+x;
  360.         $int 0x40
  361. }
  362.  
  363. void PutImage(dword EBX,w,h,x,y)
  364. {
  365.         EAX = 7;
  366.         ECX = w<<16+h;
  367.         EDX = x<<16+y;
  368.         $int 0x40
  369. }
  370.  
  371. void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
  372. {
  373.         EAX = 65;
  374.         ECX = w<<16+h;
  375.         EDX = x<<16+y;
  376.         EBP = 0;
  377.         $int 0x40
  378. }
  379.  
  380. inline fastcall void PutPixel( EBX,ECX,EDX)
  381. {
  382.   EAX=1;
  383.   $int 0x40
  384. }
  385.  
  386. void DrawBar(dword x,y,w,h,EDX)
  387. {
  388.         EAX = 13;
  389.         EBX = x<<16+w;
  390.         ECX = y<<16+h;
  391.         $int 0x40
  392. }
  393.  
  394. void DefineButton(dword x,y,w,h,EDX,ESI)
  395. {
  396.         EAX = 8;
  397.         EBX = x<<16+w;
  398.         ECX = y<<16+h;
  399.         $int 0x40
  400. }
  401.  
  402. inline fastcall void DeleteButton( EDX)
  403. {
  404.         EAX = 8;
  405.         EDX += BT_DEL;
  406.         $int 0x40;
  407. }
  408.  
  409.  
  410. //------------------------------------------------------------------------------
  411.  
  412. :void DrawRegion(dword x,y,width,height,color1)
  413. {
  414.         DrawBar(x,y,width,1,color1); //¯®«®á  £®à ᢥàåã
  415.         DrawBar(x,y+height,width,1,color1); //¯®«®á  £®à á­¨§ã
  416.         DrawBar(x,y,1,height,color1); //¯®«®á  ¢¥àåã á«¥¢ 
  417.         DrawBar(x+width,y,1,height+1,color1); //¯®«®á  ¢¥àåã á¯à ¢ 
  418. }
  419.  
  420. :void DrawRegion_3D(dword x,y,width,height,color1,color2)
  421. {
  422.         DrawBar(x,y,width+1,1,color1); //¯®«®á  £®à ᢥàåã
  423.         DrawBar(x,y+1,1,height-1,color1); //¯®«®á  á«¥¢ 
  424.         DrawBar(x+width,y+1,1,height,color2); //¯®«®á  á¯à ¢ 
  425.         DrawBar(x,y+height,width,1,color2); //¯®«®á  £®à á­¨§ã
  426. }
  427.  
  428. :void DrawFlatButton(dword x,y,width,height,id,color,text)
  429. {
  430.         DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
  431.         DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
  432.         DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
  433.         IF (id<>0)      DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
  434.         //WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
  435.         WriteText(width/2+x+1,height/2-3+y,0x80,0,text,0);
  436. }
  437.  
  438. :void DrawCircle(int x, y, r)
  439. {
  440.         int i;
  441.         float px=0, py=r, ii = r * 3.1415926 * 2;
  442.         FOR (i = 0; i < ii; i++)
  443.         {
  444.         PutPixel(px + x, y - py, 0);
  445.         px = py / r + px;
  446.         py = -px / r + py;
  447.         }
  448. }
  449.  
  450. //------------------------------------------------------------------------------
  451.  
  452. inline fastcall void debug( EDX)
  453. {
  454.         $push ebx
  455.         $push ecx
  456.         $mov eax, 63
  457.         $mov ebx, 1
  458. next_char:
  459.         $mov ecx, DSDWORD[edx]
  460.         $or      cl, cl
  461.         $jz  done
  462.         $int 0x40
  463.         $inc edx
  464.         $jmp next_char
  465. done:
  466.         $mov cl, 13
  467.         $int 0x40
  468.         $mov cl, 10
  469.         $int 0x40
  470.         $pop ecx
  471.         $pop ebx
  472. }
  473.