Subversion Repositories Kolibri OS

Rev

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