Subversion Repositories Kolibri OS

Rev

Rev 1805 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //CODED by Veliant, Leency, Nable. GNU GPL licence.
  2.  
  3. #code32 TRUE
  4.  
  5. char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
  6. dword  os_version   = 0x00000001;
  7. dword  start_addr   = #main;
  8. dword  final_addr   = #stop+32;
  9. dword  alloc_mem    = 0x0090000;
  10. dword  x86esp_reg   = 0x0090000;
  11. dword  I_Param      = 0x0;
  12. dword  I_Icon       = 0x0;
  13.  
  14. //Events
  15. #define evButton        3
  16. #define evKey           2
  17. #define evReDraw        1
  18.  
  19. //Button options
  20. #define BT_DEL          0x80000000
  21. #define BT_HIDE         0x40000000
  22. #define BT_NOFRAME      0x20000000
  23.  
  24. #define OLD             -1
  25. #define true            1
  26. #define false           0
  27.  
  28. inline fastcall dword WaitEvent(){
  29.  EAX = 10;
  30.  $int 0x40
  31. }
  32.  
  33. inline fastcall word GetKey(){
  34.  EAX = 2;              // just read this key from buffer
  35.  $int  0x40
  36.  EAX = EAX >> 8;
  37. }
  38.  
  39. inline fastcall word GetButtonID(){
  40.  EAX = 17;
  41.  $int  0x40
  42.  EAX = EAX >> 8;
  43. }
  44.  
  45. inline fastcall ExitProcess(){
  46.  EAX = -1;              // close this program
  47.  $int 0x40
  48. }
  49.  
  50. void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,EDI)
  51. {
  52.         EAX = 12;              // function 12:tell os about windowdraw
  53.         EBX = 1;
  54.         $int 0x40
  55.        
  56.         EBX = x << 16 + sizeX;
  57.         ECX = y << 16 + sizeY;
  58.         EDX = mainAreaType << 24 | mainAreaColour;
  59.         $xor eax,eax
  60.         $int 0x40
  61.        
  62.         EAX = 12;              // function 12:tell os about windowdraw
  63.         EBX = 2;
  64.         $int 0x40
  65. }
  66.  
  67. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  68. {
  69.         EAX = 4;
  70.         EBX = x<<16+y;
  71.         ECX = fontType<<24+color;
  72.         $int 0x40;
  73. }
  74.  
  75. void WriteNumber(dword x,y,byte fontType, ESI, ECX)
  76. {
  77.         EAX = 47;
  78.         EBX = 2<<16;
  79.         EDX = x<<16+y;
  80.         ESI = fontType<<24+ESI;
  81.         $int 0x40;
  82. }
  83.  
  84. void DrawBar(dword x,y,w,h,EDX)
  85. {
  86.         EAX = 13;
  87.         EBX = x<<16+w;
  88.         ECX = y<<16+h;
  89.         $int 0x40
  90. }
  91.  
  92. void DefineButton(dword x,y,w,h,EDX,ESI)
  93. {
  94.         EAX = 8;
  95.         EBX = x<<16+w;
  96.         ECX = y<<16+h;
  97.         $int 0x40
  98. }
  99.  
  100. inline fastcall void DeleteButton(dword EDX)
  101. {
  102.         EAX = 8;
  103.         EDX += BT_DEL;
  104.         $int 0x40;
  105. }
  106.  
  107. dword generator;  // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
  108.  
  109. :int random(int max)
  110. // get pseudo-random number - ïîëó÷èòü ïñåâäîñëó÷àéíîå ÷èñëî
  111. {
  112.   $rdtsc        // eax & edx
  113.   $xor eax,edx
  114.   $not eax
  115.  
  116.   EBX = generator;
  117.   $ror ebx,3
  118.   $xor ebx,0xdeadbeef
  119.   EBX += EAX;
  120.   generator = EBX;
  121.  
  122.   EAX += EBX;
  123.   EAX = EAX % max;
  124.   return EAX;
  125. }
  126.  
  127. :randomize()
  128. // initialize random number generator - èíèöèàëèçèðîâàòü ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
  129. {
  130.   asm
  131.   {
  132.     mov eax,3
  133.     int 0x40
  134.     ror eax,16
  135.   }
  136.   generator = EAX;
  137. }
  138.