Subversion Repositories Kolibri OS

Rev

Rev 3123 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. //CODED by Veliant, Leency 2008-2012. GNU GPL licence.
  2.  
  3. #startaddress 0
  4. #code32 TRUE
  5.  
  6. byte   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    = 0x000b0000;
  11. dword  x86esp_reg   = 0x000b0000;
  12. dword  I_Param      = #param;
  13. dword  I_Path       = #program_path;
  14.  
  15. char param[4096];
  16. char program_path[4096];
  17.  
  18. #include "lib\strings.h"
  19.  
  20. //Events
  21. #define evMouse         6
  22. #define evButton        3
  23. #define evKey           2
  24. #define evReDraw        1
  25.  
  26. //Button options
  27. #define BT_DEL          0x80000000
  28. #define BT_HIDE         0x40000000
  29. #define BT_NOFRAME      0x20000000
  30.  
  31. #define OLD                     -1
  32. #define true            1
  33. #define false           0
  34.  
  35. #define NULL            0
  36.  
  37.  
  38. struct mouse
  39. {
  40.         unsigned int x,y,lkm,pkm,hor,vert;
  41.         void get();
  42. };
  43.  
  44. inline fastcall int TestBit(EAX, CL)
  45. {
  46.         $shr eax,cl
  47.         $and eax,1
  48. }
  49.  
  50. void mouse::get()
  51. {
  52.         EAX = 37;
  53.         EBX = 1;
  54.         $int    0x40
  55.         $mov    ebx, eax
  56.         $shr    eax, 16
  57.         $and    ebx,0x0000FFFF
  58.         x = EAX;
  59.         y = EBX;
  60.        
  61.         EAX = 37;
  62.         EBX = 2;
  63.         $int    0x40
  64.         $mov    ebx, eax
  65.         $and    eax, 0x00000001
  66.         $shr    ebx, 1
  67.         $and    ebx, 0x00000001
  68.         lkm = EAX;
  69.         pkm = EBX;
  70.        
  71.         EAX = 37; //scroll
  72.         EBX = 7;
  73.         $int    0x40
  74.         $mov    ebx, eax
  75.         $shr    eax, 16
  76.         $and    ebx,0x0000FFFF
  77.         //hor = EAX;
  78.         vert = EBX;
  79. }
  80.  
  81. //---------------------------------------------------------------------------
  82. struct proc_info
  83. {
  84.         #define SelfInfo -1
  85.         dword   use_cpu;
  86.         word    pos_in_stack,num_slot,rezerv1;
  87.         char    name[11];
  88.         char    rezerv2;
  89.         dword   adress,use_memory,ID,left,top,width,height;
  90.         word    status_slot,rezerv3;
  91.         dword   work_left,work_top,work_width,work_height;
  92.         char    status_window;
  93.         dword   cwidth,cheight;
  94.         byte    reserved[1024-71-8];
  95. };
  96.  
  97. inline fastcall void GetProcessInfo( EBX, ECX)
  98. {
  99.         $mov eax,9;
  100.         $int  0x40
  101.         DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
  102.         DSDWORD[EBX+75] = DSDWORD[EBX+46] - GetSkinHeight() - 4; //set cheight
  103. }
  104.  
  105. inline fastcall int GetSlot( ECX)
  106. {
  107.         $mov eax,18;
  108.         $mov ebx,21;
  109.         $int 0x40
  110. }
  111.  
  112. inline fastcall int GetActiveProcess()
  113. {
  114.         $mov eax,18;
  115.         $mov ebx,7;
  116.         $int 0x40
  117. }
  118.  
  119. inline fastcall void ActivateWindow( ECX)
  120. {
  121.         EAX = 18;
  122.         EBX = 3;
  123.         $int 0x40
  124. }
  125.  
  126. //-------------------------------------------------------------------------------
  127.  
  128. inline fastcall dword WaitEvent(){
  129.         $mov eax,10;
  130.         $int 0x40
  131. }
  132.  
  133. inline fastcall void SetEventMask( EBX)
  134. {
  135.         EAX = 40;
  136.         $int 0x40
  137. }
  138.  
  139. inline fastcall word GetKey(){ //+Gluk fix
  140.                 $push edx
  141. GETKEY:
  142.                 $mov  eax,2
  143.                 $int  0x40
  144.                 $cmp eax,1
  145.                 $jne GETKEYI
  146.                 $mov ah,dh
  147.                 $jmp GETKEYII //jz?
  148. GETKEYI:
  149.                 $mov dh,ah
  150.                 $jmp GETKEY
  151. GETKEYII:
  152.                 $pop edx
  153.                 EAX = EAX >> 8;          
  154. }
  155.  
  156. inline fastcall word GetButtonID(){
  157.         EAX = 17;            // Get ID
  158.         $int  0x40
  159.         EAX = EAX >> 8;
  160. }
  161.  
  162. inline fastcall void ExitProcess(){
  163.         EAX = -1;            // close this program
  164.         $int 0x40
  165. }
  166.  
  167. inline fastcall void Pause( EBX){                              
  168.         $mov eax, 5
  169.         $int 0x40
  170. }
  171.  
  172. //------------------------------------------------------------------------------
  173. void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType, dword mainAreaColour, EDI)
  174. {
  175.         EAX = 12;              // function 12:tell os about windowdraw
  176.         EBX = 1;
  177.         $int 0x40
  178.        
  179.         EBX = x << 16 + sizeX;
  180.         ECX = y << 16 + sizeY;
  181.         EDX = mainAreaType << 24 | mainAreaColour;
  182.         $xor eax,eax
  183.         $int 0x40
  184.  
  185.         EAX = 12;              // function 12:tell os about windowdraw
  186.         EBX = 2;
  187.         $int 0x40
  188. }
  189.  
  190. inline fastcall void CreateThread( ECX,EDX)
  191. {
  192.         EAX = 51;
  193.         EBX = 1;
  194.         $int 0x40
  195. }
  196.  
  197. inline fastcall void DrawTitle( ECX){
  198.         EAX = 71;
  199.         EBX = 1;
  200.         $int 0x40;
  201. }
  202.  
  203. inline fastcall dword GetSkinHeight()
  204. {
  205.         $push ebx
  206.         $mov  eax,48
  207.         $mov  ebx,4
  208.         $int 0x40
  209.         $pop  ebx
  210. }
  211.  
  212. inline fastcall dword GetScreenHeight()
  213. {
  214.         EAX = 14;
  215.         $int 0x40
  216.         $and eax,0x0000FFFF
  217. }
  218.  
  219. inline fastcall dword GetScreenWidth()
  220. {
  221.         $mov eax, 14
  222.         $int 0x40
  223.         $shr eax, 16
  224. }
  225.  
  226. inline fastcall void MoveSize( EBX,ECX,EDX,ESI){
  227.         $mov eax,67;
  228.         $int 0x40
  229. }
  230.  
  231. //------------------------------------------------------------------------------
  232. inline fastcall void PutPixel( EBX,ECX,EDX)
  233. {
  234.   EAX=1;
  235.   $int 0x40
  236. }
  237.  
  238. void DefineButton(dword x,y,w,h,EDX,ESI)
  239. {
  240.         EAX = 8;
  241.         $push edx
  242.         EDX += BT_DEL; //âíà÷àëå óäàëÿåì êíîïó ñ ýòè èä, ïîòîì ñîçäà¸ì
  243.         $int 0x40;
  244.         EBX = x<<16+w;
  245.         ECX = y<<16+h;
  246.         $pop edx
  247.         $int 0x40
  248. }
  249.  
  250. inline fastcall void DeleteButton( EDX)
  251. {
  252.         EAX = 8;
  253.         EDX += BT_DEL;
  254.         $int 0x40;
  255. }
  256.  
  257. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  258. {
  259.         EAX = 4;
  260.         EBX = x<<16+y;
  261.         ECX = fontType<<24+color;
  262.         $int 0x40;
  263. }
  264.  
  265. void DrawBar(dword x,y,w,h,EDX)
  266. {
  267.         if (h<0) || (h>8000) return;
  268.         EAX = 13;
  269.         EBX = x<<16+w;
  270.         ECX = y<<16+h;
  271.         $int 0x40
  272. }
  273.  
  274. void DrawRegion_3D(dword x,y,width,height,color1,color2)
  275. {
  276.         DrawBar(x,y,width+1,1,color1);
  277.         DrawBar(x,y+1,1,height-1,color1);
  278.         DrawBar(x+width,y+1,1,height,color2);
  279.         DrawBar(x,y+height,width,1,color2);
  280. }
  281.  
  282. void PutPaletteImage(dword EBX,w,h,x,y, EDI)
  283. {
  284.         EAX = 65;
  285.         ECX = w<<16+h;
  286.         EDX = x<<16+y;
  287.         ESI = 8;
  288.         EBP = 0;
  289.         $int 0x40
  290. }
  291.  
  292. void PutImage(dword EBX,w,h,x,y)
  293. {
  294.         EAX = 7;
  295.         ECX = w<<16+h;
  296.         EDX = x<<16+y;
  297.         $int 0x40
  298. }
  299.  
  300. //------------------------------------------------------------------------------
  301. inline fastcall void debug( EDX)
  302. {
  303.         $mov eax, 63
  304.         $mov ebx, 1
  305. NEXT_CHAR:
  306.         $mov ecx, DSDWORD[edx]
  307.         $or      cl, cl
  308.         $jz  DONE
  309.         $int 0x40
  310.         $inc edx
  311.         $jmp NEXT_CHAR
  312. DONE:
  313.         $mov cl, 13
  314.         $int 0x40
  315.         $mov cl, 10
  316.         $int 0x40
  317. }