Subversion Repositories Kolibri OS

Rev

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