Subversion Repositories Kolibri OS

Rev

Rev 2241 | 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.         EAX = 12;
  163.         EBX = 1;
  164.         $int 0x40
  165.        
  166.         EBX = x << 16 + sizeX;
  167.         ECX = y << 16 + sizeY;
  168.         EDX = mainAreaType << 24 | mainAreaColor;
  169.         ESI = headerType << 24 | headerColor;
  170.         $xor eax,eax
  171.         $int 0x40
  172.        
  173.         EAX = 12;
  174.         EBX = 2;
  175.         $int 0x40
  176. }
  177.  
  178. inline fastcall void CreateThread(dword ECX,EDX)
  179. {
  180.         EAX = 51;
  181.         EBX = 1;
  182.         $int 0x40
  183. }
  184.  
  185. inline fastcall void DrawTitle(dword ECX){
  186.         EAX = 71;
  187.         EBX = 1;
  188.         $int 0x40;
  189. }
  190.  
  191. inline fastcall dword GetSkinWidth(){
  192.         EAX = 48;
  193.         EBX = 4;
  194.         $int 0x40
  195. }
  196.  
  197. inline fastcall void MoveSize(dword EBX,ECX,EDX,ESI){
  198.         EAX = 67;
  199.         $int 0x40
  200. }
  201.  
  202. //------------------------------------------------------------------------------
  203.  
  204. inline fastcall dword strlen(EDI){
  205.         asm {
  206.           xor ecx, ecx
  207.           xor eax, eax
  208.           dec ecx
  209.           repne scasb
  210.           sub eax, 2
  211.           sub eax, ecx
  212.         }
  213. }
  214.  
  215.  
  216. inline fastcall copystr(dword ESI,EDI)
  217. {
  218.         $cld
  219. l1:
  220.         $lodsb
  221.         $stosb
  222.         $test al,al
  223.         $jnz l1
  224. }
  225.  
  226. char buffer[11]="";
  227. inline fastcall dword IntToStr(dword ESI)
  228. {
  229.      $mov     edi, #buffer
  230.      $mov     ecx, 10
  231.      $test     esi, esi
  232.      $jns     f1
  233.      $mov     al, '-'
  234.      $stosb
  235.      $neg     esi
  236. f1:
  237.      $mov     eax, esi
  238.      $push     -'0'
  239. f2:
  240.      $xor     edx, edx
  241.      $div     ecx
  242.      $push     edx
  243.      $test     eax, eax
  244.      $jnz     f2
  245. f3:
  246.      $pop     eax
  247.      $add     al, '0'
  248.      $stosb
  249.      $jnz     f3
  250.      $mov     eax, #buffer
  251.      $ret
  252. }
  253.  
  254. inline fastcall int strcmp(ESI, EDI)
  255. {
  256.         loop()
  257.         {
  258.                 IF (DSBYTE[ESI]<DSBYTE[EDI]) RETURN -1;
  259.                 IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
  260.                 IF (DSBYTE[ESI]=='\0') RETURN 0;
  261.                 ESI++;
  262.                 EDI++;
  263.         }
  264. }
  265.  
  266.  
  267. inline fastcall unsigned int find_symbol(ESI,BL)
  268. {
  269.         int jj=0, last=-1;
  270.         do{
  271.                 jj++;
  272.                 $lodsb
  273.                 IF(AL==BL) last=jj;
  274.         } while(AL!=0);
  275.         return last;
  276. }
  277.  
  278.  
  279. inline fastcall ChangeCase(dword EDX)
  280. {
  281.         AL=DSBYTE[EDX];
  282.         IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
  283.         IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32;        //à-ï
  284.         IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80;        //à-ï
  285.         do{
  286.                 EDX++;
  287.                 AL=DSBYTE[EDX];
  288.                 IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;}
  289.                 IF(AL>='€')&&(AL<='')DSBYTE[EDX]=AL|0x20; // -¯
  290.                 IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80;        //à-ï
  291.         }while(AL!=0);
  292. }
  293.  
  294.  
  295. //------------------------------------------------------------------------------
  296. inline fastcall void PutPixel(dword EBX,ECX,EDX){
  297.   EAX=1;
  298.   $int 0x40
  299. }
  300.  
  301. void DefineButton(dword x,y,w,h,EDX,ESI){
  302.         EAX = 8;
  303.         EBX = x<<16+w;
  304.         ECX = y<<16+h;
  305.         $int 0x40
  306. }
  307.  
  308. inline fastcall void DeleteButton(dword EDX)
  309. {
  310.         EAX = 8;
  311.         EDX += BT_DEL;
  312.         $int 0x40;
  313. }
  314.  
  315. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  316. {
  317.         EAX = 4;
  318.         EBX = x<<16+y;
  319.         ECX = fontType<<24+color;
  320.         $int 0x40;
  321. }
  322.  
  323. void DrawBar(dword x,y,w,h,EDX)
  324. {
  325.         #speed
  326.         EAX = 13;
  327.         EBX = x<<16+w;
  328.         ECX = y<<16+h;
  329.         $int 0x40
  330.         #codesize
  331. }
  332.  
  333. void DrawRegion_3D(dword x,y,width,height,color1,color2)
  334. {
  335.         DrawBar(x,y,width+1,1,color1); //¯®«®á  £®à ᢥàåã
  336.         DrawBar(x,y+1,1,height-1,color1); //¯®«®á  á«¥¢ 
  337.         DrawBar(x+width,y+1,1,height,color2); //¯®«®á  á¯à ¢ 
  338.         DrawBar(x,y+height,width,1,color2); //¯®«®á  £®à á­¨§ã
  339. }
  340.  
  341. void DrawFlatButton(dword x,y,width,height,id,color,text)
  342. {
  343.         DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
  344.         DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
  345.         DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
  346.         IF (id<>0)      DefineButton(x+1,y+1,width-2,height-2,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
  347.         WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
  348. }
  349.  
  350. void PutPaletteImage(dword EBX,w,h,x,y, EDI)
  351. {
  352.         EAX = 65;
  353.         ECX = w<<16+h;
  354.         EDX = x<<16+y;
  355.         ESI = 8;
  356.         EBP = 0;
  357.         $int 0x40
  358. }
  359.  
  360. void PutImage(dword EBX,w,h,x,y)
  361. {
  362.         EAX = 7;
  363.         ECX = w<<16+h;
  364.         EDX = x<<16+y;
  365.         $int 0x40
  366. }
  367.  
  368. //------------------------------------------------------------------------------
  369. /*void WriteDebug(dword EDX)
  370. {
  371.         $mov eax, 63
  372.         $mov ebx, 1
  373. next_char:
  374.         $mov ecx, DSDWORD[edx]
  375.         $or      cl, cl
  376.         $jz  done
  377.         $int 0x40
  378.         $inc edx
  379.         $jmp next_char
  380. done:
  381.         $mov cl, 13
  382.         $int 0x40
  383.         $mov cl, 10
  384.         $int 0x40
  385. }
  386.  
  387. inline fastcall void WriteFullDebug(dword ESI)
  388. {
  389.         WriteDebug("");
  390.         WriteDebug(ESI);
  391.        
  392.         WriteDebug("Number of files:");
  393.         WriteDebug(IntToStr(count));
  394.        
  395.         WriteDebug("but_num:");
  396.         WriteDebug(IntToStr(but_num));
  397.        
  398.         WriteDebug("curbtn");
  399.         WriteDebug(IntToStr(curbtn));
  400.        
  401.         WriteDebug("ra_kadrom:");
  402.         WriteDebug(IntToStr(za_kadrom));
  403.        
  404.         Pause(200);
  405. }*/