Subversion Repositories Kolibri OS

Rev

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