Subversion Repositories Kolibri OS

Rev

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