Subversion Repositories Kolibri OS

Rev

Rev 3045 | 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    = 0x00080000;
  11. dword  x86esp_reg   = 0x00080000;
  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.         void    GetInfo( ECX);
  94.         byte    reserved[1024-71];
  95. };
  96.  
  97. void proc_info::GetInfo( EBX, ECX)
  98. {
  99.         $mov eax,9;
  100.         $int 0x40
  101. }
  102.  
  103. inline fastcall int GetSlot( ECX)
  104. {
  105.         $mov eax,18;
  106.         $mov ebx,21;
  107.         $int 0x40
  108. }
  109.  
  110. inline fastcall int GetActiveProcess()
  111. {
  112.         $mov eax,18;
  113.         $mov ebx,7;
  114.         $int 0x40
  115. }
  116.  
  117. inline fastcall void ActivateWindow( ECX)
  118. {
  119.         EAX = 18;
  120.         EBX = 3;
  121.         $int 0x40
  122. }
  123.  
  124. //-------------------------------------------------------------------------------
  125.  
  126. inline fastcall dword WaitEvent(){
  127.         $mov eax,10;
  128.         $int 0x40
  129. }
  130.  
  131. inline fastcall void SetEventMask( EBX)
  132. {
  133.         EAX = 40;
  134.         $int 0x40
  135. }
  136.  
  137. inline fastcall word GetKey(){ //+Gluk fix
  138.                 $push edx
  139. GETKEY:
  140.                 $mov  eax,2
  141.                 $int  0x40
  142.                 $cmp eax,1
  143.                 $jne GETKEYI
  144.                 $mov ah,dh
  145.                 $jmp GETKEYII //jz?
  146. GETKEYI:
  147.                 $mov dh,ah
  148.                 $jmp GETKEY
  149. GETKEYII:
  150.                 $pop edx
  151.                 EAX = EAX >> 8;          
  152. }
  153.  
  154. inline fastcall word GetButtonID(){
  155.         EAX = 17;            // Get ID
  156.         $int  0x40
  157.         EAX = EAX >> 8;
  158. }
  159.  
  160. inline fastcall void ExitProcess(){
  161.         EAX = -1;            // close this program
  162.         $int 0x40
  163. }
  164.  
  165. inline fastcall void Pause( EBX){                              
  166.         $mov eax, 5
  167.         $int 0x40
  168. }
  169.  
  170. //------------------------------------------------------------------------------
  171. void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType, dword mainAreaColour, EDI)
  172. {
  173.         EAX = 12;              // function 12:tell os about windowdraw
  174.         EBX = 1;
  175.         $int 0x40
  176.        
  177.         EBX = x << 16 + sizeX;
  178.         ECX = y << 16 + sizeY;
  179.         EDX = mainAreaType << 24 | mainAreaColour;
  180.         $xor eax,eax
  181.         $int 0x40
  182.  
  183.         EAX = 12;              // function 12:tell os about windowdraw
  184.         EBX = 2;
  185.         $int 0x40
  186. }
  187.  
  188. inline fastcall void CreateThread( ECX,EDX)
  189. {
  190.         EAX = 51;
  191.         EBX = 1;
  192.         $int 0x40
  193. }
  194.  
  195. inline fastcall void DrawTitle( ECX){
  196.         EAX = 71;
  197.         EBX = 1;
  198.         $int 0x40;
  199. }
  200.  
  201. inline fastcall dword GetSkinHeight()
  202. {
  203.         $push ebx
  204.         $mov  eax,48
  205.         $mov  ebx,4
  206.         $int 0x40
  207.         $pop  ebx
  208. }
  209.  
  210. inline fastcall dword GetScreenHeight()
  211. {
  212.         EAX = 14;
  213.         $int 0x40
  214.         $and eax,0x0000FFFF
  215. }
  216.  
  217. inline fastcall dword GetScreenWidth()
  218. {
  219.         $mov eax, 14
  220.         $int 0x40
  221.         $shr eax, 16
  222. }
  223.  
  224. inline fastcall void MoveSize( EBX,ECX,EDX,ESI){
  225.         $mov eax,67;
  226.         $int 0x40
  227. }
  228.  
  229. //------------------------------------------------------------------------------
  230. inline fastcall void PutPixel( EBX,ECX,EDX)
  231. {
  232.   EAX=1;
  233.   $int 0x40
  234. }
  235.  
  236. void DefineButton(dword x,y,w,h,EDX,ESI)
  237. {
  238.         EAX = 8;
  239.         $push edx
  240.         EDX += BT_DEL; //âíà÷àëå óäàëÿåì êíîïó ñ ýòè èä, ïîòîì ñîçäà¸ì
  241.         $int 0x40;
  242.         EBX = x<<16+w;
  243.         ECX = y<<16+h;
  244.         $pop edx
  245.         $int 0x40
  246. }
  247.  
  248. inline fastcall void DeleteButton( EDX)
  249. {
  250.         EAX = 8;
  251.         EDX += BT_DEL;
  252.         $int 0x40;
  253. }
  254.  
  255. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  256. {
  257.         EAX = 4;
  258.         EBX = x<<16+y;
  259.         ECX = fontType<<24+color;
  260.         $int 0x40;
  261. }
  262.  
  263. void DrawBar(dword x,y,w,h,EDX)
  264. {
  265.         EAX = 13;
  266.         EBX = x<<16+w;
  267.         ECX = y<<16+h;
  268.         $int 0x40
  269. }
  270.  
  271. void DrawRegion_3D(dword x,y,width,height,color1,color2)
  272. {
  273.         DrawBar(x,y,width+1,1,color1);
  274.         DrawBar(x,y+1,1,height-1,color1);
  275.         DrawBar(x+width,y+1,1,height,color2);
  276.         DrawBar(x,y+height,width,1,color2);
  277. }
  278.  
  279. void DrawFlatButton(dword x,y,width,height,id,color,text)
  280. {
  281.         DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
  282.         DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
  283.         DrawBar(x+2,y+2,width-3,height-3,color);
  284.         IF (id<>0)      DefineButton(x+1,y+1,width-2,height-2,id+BT_HIDE,0xEFEBEF);
  285.         WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
  286. }
  287.  
  288. void PutPaletteImage(dword EBX,w,h,x,y, EDI)
  289. {
  290.         EAX = 65;
  291.         ECX = w<<16+h;
  292.         EDX = x<<16+y;
  293.         ESI = 8;
  294.         EBP = 0;
  295.         $int 0x40
  296. }
  297.  
  298. void PutImage(dword EBX,w,h,x,y)
  299. {
  300.         EAX = 7;
  301.         ECX = w<<16+h;
  302.         EDX = x<<16+y;
  303.         $int 0x40
  304. }
  305.  
  306. //------------------------------------------------------------------------------
  307. inline fastcall void debug( EDX)
  308. {
  309.         $mov eax, 63
  310.         $mov ebx, 1
  311. NEXT_CHAR:
  312.         $mov ecx, DSDWORD[edx]
  313.         $or      cl, cl
  314.         $jz  DONE
  315.         $int 0x40
  316.         $inc edx
  317.         $jmp NEXT_CHAR
  318. DONE:
  319.         $mov cl, 13
  320.         $int 0x40
  321.         $mov cl, 10
  322.         $int 0x40
  323. }