Subversion Repositories Kolibri OS

Rev

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