Subversion Repositories Kolibri OS

Rev

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