Subversion Repositories Kolibri OS

Rev

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