Subversion Repositories Kolibri OS

Rev

Rev 937 | 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-skin_width;
  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 BDVK{
  71.         dword   attr;
  72.         byte    type_name;
  73.         byte    rez1, rez2, rez3;
  74.         dword   timecreate;
  75.         dword   datecreate;
  76.         dword   timelastaccess;
  77.         dword   datelastaccess;
  78.         dword   timelastedit;
  79.         dword   datelastedit;
  80.         dword   sizelo;
  81.         dword   sizehi;
  82.         char    name[518];
  83. };
  84. //---------------------------------------------------------------------------
  85. struct proc_info{
  86.         dword   use_cpu;
  87.         word    pos_in_stack,num_slot,rezerv1;
  88.         char    name[11];
  89.         char    rezerv2;
  90.         dword   adress,use_memory,ID,left,top,width,height;
  91.         word    status_slot,rezerv3;
  92.         dword   work_left,work_top,work_width,work_height;
  93.         char    status_window;
  94.         void    GetInfo(dword ECX);
  95. #define SelfInfo -1
  96. };
  97.  
  98. void proc_info::GetInfo(dword ECX)
  99. {
  100.         EAX = 9;
  101.         EBX = #use_cpu;
  102.         $int  0x40
  103. }
  104. //-------------------------------------------------------------------------------
  105.  
  106. inline fastcall dword WaitEvent(){
  107.  EAX = 10;              // wait here for event
  108.  $int 0x40
  109. }
  110.  
  111. inline fastcall void SetEventMask(dword EBX)
  112. {
  113.  EAX = 40;
  114.  $int 0x40
  115. }
  116.  
  117. inline fastcall word GetKey(){
  118.  EAX = 2;              // just read this key from buffer
  119.  $int  0x40
  120.  EAX = EAX >> 8;
  121. }
  122.  
  123. inline fastcall word GetButtonID(){
  124.  EAX = 17;            // Get ID
  125.  $int  0x40
  126.  EAX = EAX >> 8;
  127. }
  128.  
  129. inline fastcall void ExitProcess(){
  130.  EAX = -1;            // close this program
  131.  $int 0x40
  132. }
  133.  
  134. void Pause(dword EBX){                         
  135.         $mov eax, 5       // ã§ , ¢ á®âëå ¤®«ïå ᥪ㭤ë
  136.         $int 0x40
  137. }
  138.  
  139. //------------------------------------------------------------------------------
  140. void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword
  141.         mainAreaColor,byte headerType,dword headerColor,EDI)
  142. {
  143.         EBX = x << 16 + sizeX;
  144.         ECX = y << 16 + sizeY;
  145.         EDX = mainAreaType << 24 | mainAreaColor;
  146.         ESI = headerType << 24 | headerColor;
  147.         $xor eax,eax
  148.         $int 0x40
  149. }
  150.  
  151. inline fastcall void DrawTitle(dword ECX){
  152.         EAX = 71;
  153.         EBX = 1;
  154.         $int 0x40;
  155. }
  156.  
  157.  
  158. inline fastcall void WindowRedrawStatus(dword EBX){
  159.         EAX = 12;              //tell os about windowdraw
  160.         $int 0x40
  161. }
  162.  
  163. inline fastcall dword GetSkinWidth(){
  164.         EAX = 48;
  165.         EBX = 4;
  166.         $int 0x40
  167. }
  168.  
  169. inline fastcall dword MoveSize(dword EBX,ECX,EDX,ESI){
  170.         EAX = 67;
  171.         $int 0x40
  172. }
  173.  
  174. //------------------------------------------------------------------------------
  175.  
  176. inline fastcall dword strlen(dword EDI){
  177.         ECX=EAX=0;
  178.         ECX--;
  179.         $REPNE $SCASB
  180.         EAX-=2+ECX;
  181. }
  182.  
  183.  
  184. inline fastcall copystr(dword ESI,EDI)
  185. {
  186.         $cld
  187. l1:
  188.         $lodsb
  189.         $stosb
  190.         $test al,al
  191.         $jnz l1
  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. inline fastcall int strcmp(dword EAX,EBX)
  225. {
  226.         #speed
  227.         ESI=EAX;
  228.         EBX--;
  229. TOP:
  230.         EBX++;
  231.         $LODSB
  232.         $CMP AL,0
  233.         $JE HERE
  234.         $CMP DSBYTE[EBX],AL
  235.         $JE TOP
  236. HERE:
  237.         AL-=DSBYTE[EBX];
  238.         return AL;
  239.         #codesize
  240. }
  241.  
  242.  
  243. inline fastcall dword ChangeCase(dword EDX)
  244. {
  245.         #speed
  246.         AL=DSBYTE[EDX];
  247.         IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
  248.         EDX++;
  249.         do{
  250.                 AL=DSBYTE[EDX];
  251.                 IF(AL>='A')&&(AL<='Z')DSBYTE[EDX]=AL|0x20;
  252.                 EDX++;
  253.         }while(AL!=0);
  254.         #codesize
  255. }
  256.  
  257. //------------------------------------------------------------------------------
  258. inline fastcall void PutPixel(dword EBX,ECX,EDX){
  259.   EAX=1;
  260.   ECX+=skin_width;
  261.   $int 0x40
  262. }
  263.  
  264. void DefineButton(dword x,y,w,h,EDX,ESI){
  265.         EAX = 8;
  266.         EBX = x<<16+w;
  267.         ECX = skin_width+y<<16+h;
  268.         $int 0x40
  269. }
  270.  
  271. inline fastcall void DeleteButton(dword EDX)
  272. {
  273.         EAX = 8;
  274.         EDX += BT_DEL;
  275.         $int 0x40;
  276. }
  277.  
  278. void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
  279. {
  280.         EAX = 4;
  281.         EBX = x<<16+skin_width+y;
  282.         ECX = fontType<<24+color;
  283.         $int 0x40;
  284. }
  285.  
  286. void DrawBar(dword x,y,w,h,EDX)
  287. {
  288.         #speed
  289.         EAX = 13;
  290.         EBX = x<<16+w;
  291.         ECX = skin_width+y<<16+h;
  292.         $int 0x40
  293.         #codesize
  294. }
  295.  
  296. void DrawRegion(dword x,y,width,height,color1)
  297. {
  298.         DrawBar(x,y,width,1,color1); //¯®«®á  £®à ᢥàåã
  299.         DrawBar(x,y+height,width,1,color1); //¯®«®á  £®à á­¨§ã
  300.         DrawBar(x,y,1,height,color1); //¯®«®á  ¢¥àåã á«¥¢ 
  301.         DrawBar(x+width,y,1,height+1,color1); //¯®«®á  ¢¥àåã á¯à ¢ 
  302. }
  303.  
  304. void DrawFlatButton(dword x,y,width,height,id,color,text)
  305. {
  306.         DrawRegion(x,y,width,height,0x94AECE);
  307.         DrawBar(x+1,y+1,width-1,1,0xFFFFFF); //¯®«®á  £®à ¡¥« ï
  308.         DrawBar(x+1,y+height-1,width-2,1,0xC7C7C7); //¢¥­¬ ¢¥à¢
  309.         DrawBar(x+1,y+1,1,height-1,0xFFFFFF); //¯®«®á  ¢¥à¢ ¡¥« ¯
  310.         DrawBar(x+width-1,y+2,1,height-2,0xC7C7C7); //¢¥­¬ ¢¥à¢
  311.         DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
  312.         IF (id<>0)      DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
  313.         WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
  314. }
  315.  
  316. void PutImage(dword EBX,w,h,x,y)
  317. {
  318.         EAX = 7;
  319.         ECX = w<<16+h;
  320.         EDX = x<<16+y+skin_width;
  321.         $int 0x40
  322. }
  323.  
  324. void PutPaletteImage(dword EBX,w,h,x,y, EDI)
  325. {
  326.         EAX = 65;
  327.         ECX = w<<16+h;
  328.         EDX = x<<16+y+skin_width;
  329.         ESI = 8;
  330.         EBP = 0;
  331.         $int 0x40
  332. }  
  333.  
  334. //------------------------------------------------------------------------------
  335. inline fastcall dword WriteDebug(dword EDX)
  336. {
  337.         $push ebx
  338.         $push ecx
  339.         $mov eax, 63
  340.         $mov ebx, 1
  341. next_char:
  342.         $mov ecx, DSDWORD[edx]
  343.         $or      cl, cl
  344.         $jz  done
  345.         $int 0x40
  346.         $inc edx
  347.         $jmp next_char
  348. done:
  349.         $mov cl, 13
  350.         $int 0x40
  351.         $mov cl, 10
  352.         $int 0x40
  353.         $pop ecx
  354.         $pop ebx
  355. }
  356.