Subversion Repositories Kolibri OS

Rev

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