Subversion Repositories Kolibri OS

Rev

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