Subversion Repositories Kolibri OS

Rev

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