Subversion Repositories Kolibri OS

Rev

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