Subversion Repositories Kolibri OS

Rev

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