Subversion Repositories Kolibri OS

Rev

Rev 4536 | Rev 4646 | 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.  
  143. inline fastcall pause( EBX)
  144. {
  145.         $mov eax, 5
  146.         $int 0x40
  147. }
  148.  
  149. inline fastcall word GetButtonID()
  150. {
  151.         $mov eax,17
  152.         $int  0x40
  153.         $shr eax,8
  154. }
  155.  
  156. inline fastcall dword GetFreeRAM()
  157. {
  158.         $mov eax, 18
  159.         $mov ebx, 16
  160.         $int 0x40
  161.         //return eax = ðàçìåð ñâîáîäíîé ïàìÿòè â êèëîáàéòàõ
  162. }
  163.  
  164. inline fastcall dword LoadDriver( ECX) //ECX - èìÿ äðàéâåðà
  165. {
  166.         $mov eax, 68
  167.         $mov ebx, 16
  168.         $int 0x40
  169.         //return 0 - íåóäà÷à, èíà÷å eax = õýíäë äðàéâåðà
  170. }
  171.  
  172. inline fastcall dword RuleDriver( ECX) //óêàçàòåëü íà óïðàâëÿþùóþ ñòðóêòóðó
  173. {
  174.         $mov eax, 68
  175.         $mov ebx, 17
  176.         $int 0x40
  177.         //return eax = îïðåäåëÿåòñÿ äðàéâåðîì
  178. }
  179.  
  180. struct proc_info
  181. {
  182.         #define SelfInfo -1
  183.         dword   use_cpu;
  184.         word    pos_in_stack,num_slot,rezerv1;
  185.         unsigned char name[11];
  186.         char    rezerv2;
  187.         dword   adress,use_memory,ID,left,top,width,height;
  188.         word    status_slot,rezerv3;
  189.         dword   work_left,work_top,work_width,work_height;
  190.         char    status_window;
  191.         dword   cwidth,cheight;
  192.         byte    reserved[1024-71-8];
  193. };
  194.  
  195. inline fastcall void GetProcessInfo( EBX, ECX)
  196. {
  197.         $mov eax,9;
  198.         $int  0x40
  199.         DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
  200.         DSDWORD[EBX+75] = DSDWORD[EBX+46] - GetSkinHeight() - 4; //set cheight
  201. }
  202.  
  203. inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
  204. {
  205.         $mov eax,34
  206.         $int 0x40
  207. }
  208.  
  209. inline fastcall int GetProcessSlot( ECX)
  210. {
  211.         EAX = 18;
  212.         EBX = 21;
  213.         $int 0x40
  214. }
  215.  
  216. inline fastcall int GetActiveProcess()
  217. {
  218.         EAX = 18;
  219.         EBX = 7;
  220.         $int 0x40
  221. }
  222.  
  223. :int CheckActiveProcess(int Form_ID)
  224. {
  225.         int id9=GetProcessSlot(Form_ID);
  226.         if (id9==GetActiveProcess()) return 1;
  227.         return 0;
  228. }
  229.  
  230. inline fastcall void ActivateWindow( ECX)
  231. {
  232.         EAX = 18;
  233.         EBX = 3;
  234.         $int 0x40
  235. }
  236.  
  237. inline fastcall int CreateThread( ECX,EDX)
  238. {
  239.         $mov eax,51
  240.         $mov ebx,1
  241.         $int 0x40
  242. }
  243.  
  244. inline fastcall void SwitchToAnotherThread()
  245. {
  246.         $mov eax,68
  247.         $mov ebx,1
  248.         $int 0x40
  249. }
  250.  
  251. inline fastcall int SendWindowMessage( ECX, EDX)
  252. {
  253.         $mov eax, 72
  254.         $mov ebx, 1
  255.         $int 0x40
  256. }
  257.  
  258. inline fastcall int KillProcess( ECX)
  259. {
  260.         $mov eax,18;
  261.         $mov ebx,18;
  262.         $int 0x40
  263. }
  264.  
  265. #define TURN_OFF 2
  266. #define REBOOT 3
  267. #define KERNEL 4
  268. inline fastcall int ExitSystem( ECX)
  269. {
  270.         $mov eax, 18
  271.         $mov ebx, 9
  272.         $int 0x40
  273. }
  274.  
  275. inline fastcall ExitProcess()
  276. {
  277.         $mov eax,-1;
  278.         $int 0x40
  279. }
  280.  
  281. //------------------------------------------------------------------------------
  282.  
  283. //eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
  284. inline fastcall int GetSystemLanguage()
  285. {
  286.         EAX = 26;
  287.         EBX = 5;
  288.         $int 0x40
  289. }
  290.  
  291. inline fastcall GetSkinHeight()
  292. {
  293.         $push ebx
  294.         $mov  eax,48
  295.         $mov  ebx,4
  296.         $int 0x40
  297.         $pop  ebx
  298. }
  299.  
  300. inline fastcall void SetSystemSkin( ECX)
  301. {
  302.         EAX = 48;
  303.         EBX = 8;
  304.         $int 0x40
  305. }
  306.  
  307. inline fastcall int GetScreenWidth()
  308. {
  309.         $mov eax, 14
  310.         $int 0x40
  311.         $shr eax, 16
  312. }
  313.  
  314. inline fastcall int GetScreenHeight()
  315. {
  316.         $mov eax, 14
  317.         $int 0x40
  318.         $and eax,0x0000FFFF
  319. }
  320.  
  321. inline fastcall dword LoadLibrary( ECX)
  322. {
  323.         $mov eax, 68
  324.         $mov ebx, 19
  325.         $int  0x40
  326. }
  327.  
  328. inline fastcall int TestBit( EAX, CL)
  329. {
  330.         $shr eax,cl
  331.         $and eax,1
  332. }
  333.  
  334. inline fastcall int PlaySpeaker( ESI)
  335. {
  336.         $mov eax, 55
  337.         $mov ebx, 55
  338.         $int 0x40
  339. }
  340.  
  341. inline fastcall void debugln( EDX)
  342. {
  343.         $push eax
  344.         $push ebx
  345.         $push ecx
  346.         $mov eax, 63
  347.         $mov ebx, 1
  348. NEXT_CHAR:
  349.         $mov ecx, DSDWORD[edx]
  350.         $or      cl, cl
  351.         $jz  DONE
  352.         $int 0x40
  353.         $inc edx
  354.         $jmp NEXT_CHAR
  355. DONE:
  356.         $mov cl, 13
  357.         $int 0x40
  358.         $mov cl, 10
  359.         $int 0x40
  360.         $pop ecx
  361.         $pop ebx
  362.         $pop eax
  363. }
  364.  
  365.  
  366. inline fastcall void debugch( ECX)
  367. {
  368.         $push eax
  369.         $push ebx
  370.         $mov eax,63
  371.         $mov ebx,1
  372.         $int 0x40
  373.         $pop ebx
  374.         $pop eax
  375. }
  376. //------------------------------------------------------------------------------
  377.  
  378. void DefineAndDrawWindow(dword x, y, size_w, size_h, byte WindowType,dword WindowAreaColor, EDI, ESI)
  379. {
  380.         EAX = 12;              // function 12:tell os about windowdraw
  381.         EBX = 1;
  382.         $int 0x40
  383.        
  384.         EAX = 0;
  385.         EBX = x << 16 + size_w;
  386.         ECX = y << 16 + size_h;
  387.         EDX = WindowType << 24 | WindowAreaColor;
  388.         $int 0x40
  389.  
  390.         EAX = 12;              // function 12:tell os about windowdraw
  391.         EBX = 2;
  392.         $int 0x40
  393. }
  394.  
  395. inline fastcall MoveSize( EBX,ECX,EDX,ESI)
  396. {
  397.         $mov eax, 67
  398.         $int 0x40
  399. }
  400.  
  401. inline fastcall void DrawTitle( ECX)
  402. {
  403.         EAX = 71;
  404.         EBX = 1;
  405.         $int 0x40;
  406. }
  407.  
  408. void WriteTextB(dword x,y,byte fontType, dword color, EDX)
  409. {
  410.         EAX = 4;
  411.         EBX = x<<16+y;
  412.         ECX = fontType<<24+color;
  413.         ESI = 0;
  414.         $int 0x40;
  415.         $add ebx, 1<<16
  416.         $int 0x40
  417. }
  418.  
  419. void WriteText(dword x,y,byte fontType, dword color, EDX)
  420. {
  421.         EAX = 4;
  422.         EBX = x<<16+y;
  423.         ECX = fontType<<24+color;
  424.         $int 0x40;
  425. }
  426.  
  427. dword WriteBufText(dword x,y,byte fontType, dword color, EDX, EDI)
  428. {
  429.         EAX = 4;
  430.         EBX = x<<16+y;
  431.         ECX = fontType<<24+color;
  432.         $int 0x40;
  433. }
  434.  
  435. void WriteNumber(dword x,y,byte fontType, dword color, count, ECX)
  436. {
  437.         EAX = 47;
  438.         EBX = count<<16;
  439.         EDX = x<<16+y;
  440.         ESI = fontType<<24+color;
  441.         $int 0x40;
  442. }
  443.  
  444. void CopyScreen(dword EBX, x, y, w, h)
  445. {
  446.   EAX = 36;
  447.   ECX = w << 16 + h;
  448.   EDX = x << 16 + y;
  449.   $int  0x40;
  450. }
  451.  
  452. :dword GetPixelColor(dword x, x_size, y)
  453. {
  454.         $mov eax, 35
  455.         EBX= y*x_size+x;
  456.         $int 0x40
  457. }
  458.  
  459.  
  460. void _PutImage(dword x,y, w,h, EBX)
  461. {
  462.         EAX = 7;
  463.         ECX = w<<16+h;
  464.         EDX = x<<16+y;
  465.         $int 0x40
  466. }
  467.  
  468. void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
  469. {
  470.         EAX = 65;
  471.         ECX = w<<16+h;
  472.         EDX = x<<16+y;
  473.         EBP = 0;
  474.         $int 0x40
  475. }
  476.  
  477. inline fastcall void PutPixel( EBX,ECX,EDX)
  478. {
  479.   EAX=1;
  480.   $int 0x40
  481. }
  482.  
  483. void DrawBar(dword x,y,w,h,EDX)
  484. {
  485.         if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
  486.         EAX = 13;
  487.         EBX = x<<16+w;
  488.         ECX = y<<16+h;
  489.         $int 0x40
  490. }
  491.  
  492. void DefineButton(dword x,y,w,h,EDX,ESI)
  493. {
  494.         EAX = 8;
  495.         $push edx
  496.         EDX += BT_DEL;
  497.         $int 0x40;
  498.         $pop edx
  499.         EBX = x<<16+w;
  500.         ECX = y<<16+h;
  501.         $int 0x40
  502. }
  503.  
  504. void UnsafeDefineButton(dword x,y,w,h,EDX,ESI)
  505. {
  506.         EAX = 8;
  507.         EBX = x<<16+w;
  508.         ECX = y<<16+h;
  509.         $int 0x40
  510. }
  511.  
  512. inline fastcall void DeleteButton( EDX)
  513. {
  514.         EAX = 8;
  515.         EDX += BT_DEL;
  516.         $int 0x40;
  517. }