Subversion Repositories Kolibri OS

Rev

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

  1. //CODED by Veliant, Leency. 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    = 0x00100000;
  11. dword  x86esp_reg   = 0x00100000;   // 0x0007fff0;
  12. dword  I_Param      = #param;
  13. dword  I_Path       = #program_path;
  14. char param[4096]="";
  15. char program_path[4096]="";
  16.  
  17.  
  18. //Events
  19. #define evMouse         6
  20. #define evButton        3
  21. #define evKey           2
  22. #define evReDraw        1
  23.  
  24. //Button options
  25. #define BT_DEL          0x80000000
  26. #define BT_HIDE         0x40000000
  27. #define BT_NOFRAME      0x20000000
  28.  
  29. #define OLD                     -1
  30. #define true            1
  31. #define false           0
  32.  
  33.  
  34.  
  35. struct mouse{
  36.  int x,y,lkm,pkm,hor,vert;
  37.  void get();
  38. };
  39.  
  40. void mouse::get()
  41. {
  42.         EAX = 37;
  43.         EBX = 1;
  44.         $int    0x40
  45.         $mov    ebx, eax
  46.         $shr    eax, 16
  47.         $and    ebx,0x0000FFFF
  48.         x = EAX;
  49.         y = EBX;
  50.         EAX = 37;
  51.         EBX = 2;
  52.         $int    0x40
  53.         $mov    ebx, eax
  54.         $and    eax, 0x00000001
  55.         $shr    ebx, 1
  56.         $and    ebx, 0x00000001
  57.         lkm = EAX;
  58.         pkm = EBX;
  59.         EAX = 37; //áªà®««
  60.         EBX = 7;
  61.         $int    0x40
  62.         $mov    ebx, eax
  63.         $shr    eax, 16
  64.         $and    ebx,0x0000FFFF
  65.         //hor = EAX;
  66.         vert = EBX;
  67. }
  68.  
  69. //---------------------------------------------------------------------------
  70. struct proc_info{
  71.         dword   use_cpu;
  72.         word    pos_in_stack,num_slot,rezerv1;
  73.         char    name[11];
  74.         char    rezerv2;
  75.         dword   adress,use_memory,ID,left,top,width,height;
  76.         word    status_slot,rezerv3;
  77.         dword   work_left,work_top,work_width,work_height;
  78.         char    status_window;
  79.         void    GetInfo(dword ECX);
  80.         byte    reserved[1024-71];
  81. #define SelfInfo -1
  82. };
  83.  
  84. void proc_info::GetInfo(dword ECX)
  85. {
  86.         EAX = 9;
  87.         EBX = #use_cpu;
  88.         $int  0x40
  89. }
  90. //-------------------------------------------------------------------------------
  91.  
  92. inline fastcall dword WaitEvent(){
  93.  EAX = 10;              // wait here for event
  94.  $int 0x40
  95. }
  96.  
  97. inline fastcall void SetEventMask(dword EBX)
  98. {
  99.  EAX = 40;
  100.  $int 0x40
  101. }
  102.  
  103. inline fastcall word GetKey(){
  104.  EAX = 2;              // just read this key from buffer
  105.  $int  0x40
  106.  EAX = EAX >> 8;
  107. }
  108.  
  109. inline fastcall word GetButtonID(){
  110.  EAX = 17;            // Get ID
  111.  $int  0x40
  112.  EAX = EAX >> 8;
  113. }
  114.  
  115. inline fastcall void ExitProcess(){
  116.  EAX = -1;            // close this program
  117.  $int 0x40
  118. }
  119.  
  120. inline fastcall void Pause(dword EBX){                         
  121.         $mov eax, 5       // ã§ , ¢ á®âëå ¤®«ïå ᥪ㭤ë
  122.         $int 0x40
  123. }
  124.  
  125. //------------------------------------------------------------------------------
  126. void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword
  127.         mainAreaColor,byte headerType,dword headerColor,EDI)
  128. {
  129.         EBX = x << 16 + sizeX;
  130.         ECX = y << 16 + sizeY;
  131.         EDX = mainAreaType << 24 | mainAreaColor;
  132.         ESI = headerType << 24 | headerColor;
  133.         $xor eax,eax
  134.         $int 0x40
  135. }
  136.  
  137. inline fastcall void CreateThread(dword ECX,EDX)
  138. {
  139.         EAX = 51;
  140.         EBX = 1;
  141.         $int 0x40
  142. }
  143.  
  144. inline fastcall void DrawTitle(dword ECX){
  145.         EAX = 71;
  146.         EBX = 1;
  147.         $int 0x40;
  148. }
  149.  
  150.  
  151. inline fastcall void WindowRedrawStatus(dword EBX){
  152.         EAX = 12;              //tell os about windowdraw
  153.         $int 0x40
  154. }
  155.  
  156. inline fastcall dword GetSkinWidth(){
  157.         EAX = 48;
  158.         EBX = 4;
  159.         $int 0x40
  160. }
  161.  
  162. inline fastcall void MoveSize(dword EBX,ECX,EDX,ESI){
  163.         EAX = 67;
  164.         $int 0x40
  165. }
  166.  
  167. //------------------------------------------------------------------------------
  168.  
  169. inline fastcall dword strlen(EDI){
  170.         asm {
  171.           xor ecx, ecx
  172.           xor eax, eax
  173.           dec ecx
  174.           repne scasb
  175.           sub eax, 2
  176.           sub eax, ecx
  177.         }
  178. }
  179.  
  180.  
  181. inline fastcall copystr(dword ESI,EDI)
  182. {
  183.         $cld
  184. l1:
  185.         $lodsb
  186.         $stosb
  187.         $test al,al
  188.         $jnz l1
  189. }
  190.  
  191. byte fastcall TestBit(EAX, CL)
  192. {
  193.         $shr eax,cl
  194.         $and eax,1
  195. }
  196.  
  197.  
  198. char buffer[11]="";
  199. inline fastcall dword IntToStr(dword ESI)
  200. {
  201.      $mov     edi, #buffer
  202.      $mov     ecx, 10
  203.      $test     esi, esi
  204.      $jns     f1
  205.      $mov     al, '-'
  206.      $stosb
  207.      $neg     esi
  208. f1:
  209.      $mov     eax, esi
  210.      $push     -'0'
  211. f2:
  212.      $xor     edx, edx
  213.      $div     ecx
  214.      $push     edx
  215.      $test     eax, eax
  216.      $jnz     f2
  217. f3:
  218.      $pop     eax
  219.      $add     al, '0'
  220.      $stosb
  221.      $jnz     f3
  222.      $mov     eax, #buffer
  223.      $ret
  224. }
  225.  
  226.  
  227. dword StrToCol(char* htmlcolor)
  228. {
  229.   dword j=1, color=0; char ch=0x00;
  230.   IF (ESBYTE[htmlcolor]<>'#') RETURN;
  231.   FOR (;j<7;j++)
  232.   {
  233.     ch=ESBYTE[htmlcolor+j];
  234.     IF ((ch>='0') && (ch<='9')) ch -= '0';
  235.     IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
  236.     IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
  237.     color = color*0x10 + ch;
  238.   }
  239.   EAX=color;
  240. }
  241.  
  242.  
  243. inline fastcall int strcmp(ESI, EDI)
  244. {
  245.         loop()
  246.         {
  247.                 IF (DSBYTE[ESI]<DSBYTE[EDI]) RETURN -1;
  248.                 IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
  249.                 IF (DSBYTE[ESI]=='\0') RETURN 0;
  250.                 ESI++;
  251.                 EDI++;
  252.         }
  253. }
  254.  
  255.  
  256. inline fastcall unsigned int find_symbol(ESI,BL)
  257. {
  258.         int jj=0, last=-1;
  259.         do{
  260.                 jj++;
  261.                 $lodsb
  262.                 IF(AL==BL) last=jj;
  263.         } while(AL!=0);
  264.         return last;
  265. }
  266.  
  267.  
  268. inline fastcall ChangeCase(dword EDX)
  269. {
  270.         AL=DSBYTE[EDX];
  271.         IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
  272.         IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32;        //à-ï
  273.         IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80;        //à-ï
  274.         do{
  275.                 EDX++;
  276.                 AL=DSBYTE[EDX];
  277.                 IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;}
  278.                 IF(AL>='€')&&(AL<='')DSBYTE[EDX]=AL|0x20; // -¯
  279.                 IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80;        //à-ï
  280.         }while(AL!=0);
  281. }
  282.  
  283.  
  284. //------------------------------------------------------------------------------
  285. inline fastcall void PutPixel(dword EBX,ECX,EDX){
  286.   EAX=1;
  287.   $int 0x40
  288. }
  289.  
  290. void DefineButton(dword x,y,w,h,EDX,ESI){
  291.         EAX = 8;
  292.         EBX = x<<16+w;
  293.         ECX = y<<16+h;
  294.         $int 0x40
  295. }
  296.  
  297. inline fastcall void DeleteButton(dword EDX)
  298. {
  299.         EAX = 8;
  300.         EDX += BT_DEL;
  301.         $int 0x40;
  302. }
  303.  
  304. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  305. {
  306.         EAX = 4;
  307.         EBX = x<<16+y;
  308.         ECX = fontType<<24+color;
  309.         $int 0x40;
  310. }
  311.  
  312. void DrawBar(dword x,y,w,h,EDX)
  313. {
  314.         #speed
  315.         EAX = 13;
  316.         EBX = x<<16+w;
  317.         ECX = y<<16+h;
  318.         $int 0x40
  319.         #codesize
  320. }
  321.  
  322. void DrawRegion_3D(dword x,y,width,height,color1,color2)
  323. {
  324.         DrawBar(x,y,width+1,1,color1); //¯®«®á  £®à ᢥàåã
  325.         DrawBar(x,y+1,1,height-1,color1); //¯®«®á  á«¥¢ 
  326.         DrawBar(x+width,y+1,1,height,color2); //¯®«®á  á¯à ¢ 
  327.         DrawBar(x,y+height,width,1,color2); //¯®«®á  £®à á­¨§ã
  328. }
  329.  
  330. void DrawFlatButton(dword x,y,width,height,id,color,text)
  331. {
  332.         DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
  333.         DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
  334.         DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
  335.         IF (id<>0)      DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
  336.         WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
  337. }
  338.  
  339. void PutImage(dword EBX,w,h,x,y)
  340. {
  341.         EAX = 7;
  342.         ECX = w<<16+h;
  343.         EDX = x<<16+y;
  344.         $int 0x40
  345. }
  346.  
  347. void PutPaletteImage(dword EBX,w,h,x,y, EDI)
  348. {
  349.         EAX = 65;
  350.         ECX = w<<16+h;
  351.         EDX = x<<16+y;
  352.         ESI = 8;
  353.         EBP = 0;
  354.         $int 0x40
  355. }  
  356.  
  357. //------------------------------------------------------------------------------
  358. void WriteDebug(dword EDX)
  359. {
  360.         $mov eax, 63
  361.         $mov ebx, 1
  362. next_char:
  363.         $mov ecx, DSDWORD[edx]
  364.         $or      cl, cl
  365.         $jz  done
  366.         $int 0x40
  367.         $inc edx
  368.         $jmp next_char
  369. done:
  370.         $mov cl, 13
  371.         $int 0x40
  372.         $mov cl, 10
  373.         $int 0x40
  374. }
  375.