Subversion Repositories Kolibri OS

Rev

Rev 5572 | Rev 5575 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //CODED by Veliant, Leency, Nable. 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    = MEMSIZE;
  11. dword  x86esp_reg   = MEMSIZE;
  12. dword  I_Param      = #param;
  13. dword  I_Path       = #program_path;
  14. char param[4096];
  15. char program_path[4096];
  16.  
  17. #define NULL      0
  18. #define OLD      -1
  19. #define true      1
  20. #define false     0
  21.  
  22. //Events
  23. #define evReDraw  1
  24. #define evKey     2
  25. #define evButton  3
  26. #define evMouse   6
  27. #define evNetwork 8
  28.  
  29.  
  30. //Button options
  31. #define BT_DEL      0x80000000
  32. #define BT_HIDE     0x40000000
  33. #define BT_NOFRAME  0x20000000
  34.  
  35. //Button mouse
  36. #define MOUSE_LEFT 100b
  37. #define MOUSE_RIGHT 001b
  38. #define MOUSE_CENTER 010b
  39.  
  40. //ASCII KEYS
  41. #define ASCII_KEY_BS    008
  42. #define ASCII_KEY_TAB   009
  43. #define ASCII_KEY_ENTER 013
  44. #define ASCII_KEY_ESC   027
  45. #define ASCII_KEY_DEL   182
  46. #define ASCII_KEY_INS   185
  47. #define ASCII_KEY_SPACE 032
  48.  
  49. #define ASCII_KEY_LEFT  176
  50. #define ASCII_KEY_RIGHT 179
  51. #define ASCII_KEY_DOWN  177
  52. #define ASCII_KEY_UP    178
  53. #define ASCII_KEY_HOME  180
  54. #define ASCII_KEY_END   181
  55. #define ASCII_KEY_PGDN  183
  56. #define ASCII_KEY_PGUP  184
  57.  
  58.  
  59. //-------------------------------------------------------------------------
  60.  
  61. :struct raw_image {
  62.         dword w, h, data;
  63. };
  64.  
  65. /**
  66.  *  The structure of the mouse
  67.  *  x - coordinate X
  68.  *  y - coordinate Y
  69.  *  xx and yy - time coordinates
  70.  *  lkm - left mouse button
  71.  *  pkm - right mouse button
  72.  *  mkm - mouse wheel
  73.  *  key - keycode button
  74.  *  tmp - time keycode
  75.  *  down - key event press
  76.  *  up - key release events
  77.  *  move - event mouse movements
  78.  */
  79. :struct mouse
  80. {
  81.         signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,hor,vert,down,up,move;
  82.         void get();
  83. };
  84.  
  85. //get new attributes mouse
  86. :void mouse::get()
  87. {
  88.         EAX = 37;
  89.         EBX = 1;
  90.         $int    0x40
  91.         $mov    ebx, eax
  92.         $shr    eax, 16
  93.         $and    ebx,0x0000FFFF
  94.         x = EAX;
  95.         y = EBX;
  96.         if (x>6000) x-=65535;
  97.         if (y>6000) y-=65535;
  98.         EAX = 37;
  99.         EBX = 2;
  100.         $int    0x40
  101.         $mov    ebx, eax
  102.         $mov    ecx, eax
  103.         key = EAX;
  104.         $and    eax, 0x00000001
  105.         $shr    ebx, 1
  106.         $and    ebx, 0x00000001
  107.         $shr    ecx, 2
  108.         $and    ecx, 0x00000001
  109.         lkm = EAX;
  110.         pkm = EBX;
  111.         mkm = ECX;
  112.        
  113.         //when you release the mouse button
  114.         if((down)&&!(key)){
  115.                 up = true;
  116.                 down = false;
  117.                
  118.                 //returns the key code
  119.                 key = tmp;
  120.                 lkm = 1&tmp;
  121.                 pkm = 2&tmp;
  122.                 pkm >>= 1;
  123.                 mkm = 4&tmp;
  124.                 mkm >>= 2;
  125.         }
  126.        
  127.         //when you press the mouse button
  128.         else {
  129.                 up = false;
  130.                 if(key) down = true;
  131.                 else down = false;
  132.                 if(down) tmp = key;
  133.                 if((xx!=x)||(yy!=y)){
  134.                         move = true;
  135.                         xx = x;
  136.                         yy = y;
  137.                 }
  138.                 else move = false;
  139.         }
  140.        
  141.         //scroll
  142.         EAX = 37;
  143.         EBX = 7;
  144.         $int    0x40
  145.         $mov    ebx, eax
  146.         $shr    eax, 16
  147.         $and    ebx,0x0000FFFF
  148.         //hor = EAX;
  149.         vert = EBX;
  150. }
  151.  
  152.  
  153. :struct system_colors
  154. {
  155.         dword frame,grab,grab_button,grab_button_text,grab_text,
  156.               work,work_button,work_button_text,work_text,work_graph;
  157.         void get();
  158. };
  159.  
  160. :void system_colors::get()
  161. {
  162.         EAX = 48;
  163.         EBX = 3;
  164.         ECX = #frame;
  165.         EDX = 40;
  166.         $int 0x40
  167. }
  168.  
  169. //------------------------------------------------------------------------------
  170.  
  171. inline fastcall dword WaitEvent()
  172. {
  173.         $mov eax,10
  174.         $int 0x40
  175. }
  176.  
  177. inline fastcall dword CheckEvent()
  178. {
  179.         $mov eax,11
  180.         $int 0x40
  181. }
  182.  
  183. inline fastcall dword WaitEventTimeout( EBX)
  184. {
  185.         $mov eax,23
  186.         $int 0x40
  187. }
  188.  
  189. inline fastcall SetEventMask( EBX)
  190. {
  191.         $mov eax,40
  192.         $int 0x40
  193. }
  194.  
  195. inline fastcall ScancodesGeting(){
  196.         $mov eax,66
  197.         $mov ebx,1
  198.         $mov ecx,1 //᪠­ª®¤ë
  199.         $int 0x40
  200. }
  201.  
  202. inline fastcall word GetKey()  //+Gluk fix
  203. {
  204.                 $push edx
  205. GETKEY:
  206.                 $mov  eax,2
  207.                 $int  0x40
  208.                 $cmp eax,1
  209.                 $jne GETKEYI
  210.                 $mov ah,dh
  211.                 $jmp GETKEYII //jz?
  212. GETKEYI:
  213.                 $mov dh,ah
  214.                 $jmp GETKEY
  215. GETKEYII:
  216.                 $pop edx
  217.                 $shr eax,8
  218. }
  219.  
  220. inline fastcall int GetFullKey()
  221. {
  222.         $mov  eax,2
  223.         $int  0x40
  224. }
  225.  
  226.  
  227. inline fastcall pause( EBX)
  228. {
  229.         $mov eax, 5
  230.         $int 0x40
  231. }
  232.  
  233. inline fastcall word GetButtonID()
  234. {
  235.         $mov eax,17
  236.         $int  0x40
  237.         $shr eax,8
  238. }
  239.  
  240. inline fastcall dword GetFreeRAM()
  241. {
  242.         $mov eax, 18
  243.         $mov ebx, 16
  244.         $int 0x40
  245.         //return eax = ðàçìåð ñâîáîäíîé ïàìÿòè â êèëîáàéòàõ
  246. }
  247.  
  248. inline fastcall dword LoadDriver( ECX) //ECX - èìÿ äðàéâåðà
  249. {
  250.         $mov eax, 68
  251.         $mov ebx, 16
  252.         $int 0x40
  253.         //return 0 - íåóäà÷à, èíà÷å eax = õýíäë äðàéâåðà
  254. }
  255.  
  256. inline fastcall dword RuleDriver( ECX) //óêàçàòåëü íà óïðàâëÿþùóþ ñòðóêòóðó
  257. {
  258.         $mov eax, 68
  259.         $mov ebx, 17
  260.         $int 0x40
  261.         //return eax = îïðåäåëÿåòñÿ äðàéâåðîì
  262. }
  263.  
  264. struct proc_info
  265. {
  266.         #define SelfInfo -1
  267.         dword   use_cpu;
  268.         word    pos_in_stack,num_slot,rezerv1;
  269.         unsigned char name[11];
  270.         char    rezerv2;
  271.         dword   adress,use_memory,ID,left,top,width,height;
  272.         word    status_slot,rezerv3;
  273.         dword   work_left,work_top,work_width,work_height;
  274.         char    status_window;
  275.         dword   cwidth,cheight;
  276.         byte    reserved[1024-71-8];
  277. };
  278.  
  279. inline fastcall void GetProcessInfo( EBX, ECX)
  280. {
  281.         $mov eax,9;
  282.         $int  0x40
  283.         DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
  284.         DSDWORD[EBX+75] = DSDWORD[EBX+46] - GetSkinHeight() - 4; //set cheight
  285. }
  286.  
  287. inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
  288. {
  289.         $mov eax,34
  290.         $int 0x40
  291. }
  292.  
  293. inline fastcall int GetProcessSlot( ECX)
  294. {
  295.         EAX = 18;
  296.         EBX = 21;
  297.         $int 0x40
  298. }
  299.  
  300. inline fastcall int GetActiveProcess()
  301. {
  302.         EAX = 18;
  303.         EBX = 7;
  304.         $int 0x40
  305. }
  306.  
  307. :int CheckActiveProcess(int Form_ID)
  308. {
  309.         int id9=GetProcessSlot(Form_ID);
  310.         if (id9==GetActiveProcess()) return 1;
  311.         return 0;
  312. }
  313.  
  314. inline fastcall void ActivateWindow( ECX)
  315. {
  316.         EAX = 18;
  317.         EBX = 3;
  318.         $int 0x40
  319. }
  320.  
  321. inline fastcall int MinimizeWindow()
  322. {
  323.         EAX = 18;
  324.         EBX = 10;
  325.         $int 0x40
  326. }
  327.  
  328. inline fastcall int CreateThread( ECX,EDX)
  329. {
  330.         $mov eax,51
  331.         $mov ebx,1
  332.         $int 0x40
  333. }
  334.  
  335. inline fastcall void SwitchToAnotherThread()
  336. {
  337.         $mov eax,68
  338.         $mov ebx,1
  339.         $int 0x40
  340. }
  341.  
  342. inline fastcall int SendWindowMessage( ECX, EDX)
  343. {
  344.         $mov eax, 72
  345.         $mov ebx, 1
  346.         $int 0x40
  347. }
  348.  
  349. inline fastcall int KillProcess( ECX)
  350. {
  351.         $mov eax,18;
  352.         $mov ebx,18;
  353.         $int 0x40
  354. }
  355.  
  356. #define TURN_OFF 2
  357. #define REBOOT 3
  358. #define KERNEL 4
  359. inline fastcall int ExitSystem( ECX)
  360. {
  361.         $mov eax, 18
  362.         $mov ebx, 9
  363.         $int 0x40
  364. }
  365.  
  366. inline fastcall ExitProcess()
  367. {
  368.         $mov eax,-1;
  369.         $int 0x40
  370. }
  371.  
  372. //------------------------------------------------------------------------------
  373.  
  374. //eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
  375. inline fastcall int GetSystemLanguage()
  376. {
  377.         EAX = 26;
  378.         EBX = 5;
  379.         $int 0x40
  380. }
  381.  
  382. inline fastcall GetSkinHeight()
  383. {
  384.         $push ebx
  385.         $mov  eax,48
  386.         $mov  ebx,4
  387.         $int 0x40
  388.         $pop  ebx
  389. }
  390.  
  391. inline fastcall void SetSystemSkin( ECX)
  392. {
  393.         EAX = 48;
  394.         EBX = 8;
  395.         $int 0x40
  396. }
  397.  
  398. inline fastcall int GetScreenWidth()
  399. {
  400.         $mov eax, 14
  401.         $int 0x40
  402.         $shr eax, 16
  403. }
  404.  
  405. inline fastcall int GetScreenHeight()
  406. {
  407.         $mov eax, 14
  408.         $int 0x40
  409.         $and eax,0x0000FFFF
  410. }
  411.  
  412. inline fastcall int GetClientTop()
  413. {
  414.         $mov eax, 48
  415.         $mov ebx, 5
  416.         $int 0x40
  417.     $mov eax, ebx
  418.     $shr eax, 16
  419. }
  420.  
  421. inline fastcall int GetClientHeight()
  422. {
  423.         $mov eax, 48
  424.         $mov ebx, 5
  425.         $int 0x40
  426.     $mov eax, ebx
  427. }
  428.  
  429.  
  430. inline fastcall dword LoadLibrary( ECX)
  431. {
  432.         $mov eax, 68
  433.         $mov ebx, 19
  434.         $int  0x40
  435. }
  436.  
  437. inline fastcall int TestBit( EAX, CL)
  438. {
  439.         $shr eax,cl
  440.         $and eax,1
  441. }
  442.  
  443. inline fastcall int PlaySpeaker( ESI)
  444. {
  445.         $mov eax, 55
  446.         $mov ebx, 55
  447.         $int 0x40
  448. }
  449.  
  450. inline fastcall void debugln( EDX)
  451. {
  452.         $push eax
  453.         $push ebx
  454.         $push ecx
  455.         $mov eax, 63
  456.         $mov ebx, 1
  457. NEXT_CHAR:
  458.         $mov ecx, DSDWORD[edx]
  459.         $or      cl, cl
  460.         $jz  DONE
  461.         $int 0x40
  462.         $inc edx
  463.         $jmp NEXT_CHAR
  464. DONE:
  465.         $mov cl, 13
  466.         $int 0x40
  467.         $mov cl, 10
  468.         $int 0x40
  469.         $pop ecx
  470.         $pop ebx
  471.         $pop eax
  472. }
  473.  
  474. inline fastcall void debug( EDX)
  475. {
  476.         $push eax
  477.         $push ebx
  478.         $push ecx
  479.         $mov eax, 63
  480.         $mov ebx, 1
  481. NEXT_CHAR:
  482.         $mov ecx, DSDWORD[edx]
  483.         $or      cl, cl
  484.         $jz  DONE
  485.         $int 0x40
  486.         $inc edx
  487.         $jmp NEXT_CHAR
  488. DONE:
  489.         $pop ecx
  490.         $pop ebx
  491.         $pop eax
  492. }
  493.  
  494.  
  495. inline fastcall void debugch( ECX)
  496. {
  497.         $push eax
  498.         $push ebx
  499.         $mov eax,63
  500.         $mov ebx,1
  501.         $int 0x40
  502.         $pop ebx
  503.         $pop eax
  504. }
  505. //------------------------------------------------------------------------------
  506.  
  507. void DefineAndDrawWindow(dword x, y, size_w, size_h, byte WindowType,dword WindowAreaColor, EDI, ESI)
  508. {
  509.         EAX = 12;              // function 12:tell os about windowdraw
  510.         EBX = 1;
  511.         $int 0x40
  512.        
  513.         EAX = 0;
  514.         EBX = x << 16 + size_w;
  515.         ECX = y << 16 + size_h;
  516.         EDX = WindowType << 24 | WindowAreaColor;
  517.         $int 0x40
  518.  
  519.         EAX = 12;              // function 12:tell os about windowdraw
  520.         EBX = 2;
  521.         $int 0x40
  522. }
  523.  
  524. inline fastcall MoveSize( EBX,ECX,EDX,ESI)
  525. {
  526.         $mov eax, 67
  527.         $int 0x40
  528. }
  529.  
  530. inline fastcall void DrawTitle( ECX)
  531. {
  532.         EAX = 71;
  533.         EBX = 1;
  534.         $int 0x40;
  535. }
  536.  
  537. void WriteTextB(dword x,y,byte fontType, dword color, EDX)
  538. {
  539.         EAX = 4;
  540.         EBX = x<<16+y;
  541.         ECX = fontType<<24+color;
  542.         ESI = 0;
  543.         $int 0x40;
  544.         $add ebx, 1<<16
  545.         $int 0x40
  546. }
  547.  
  548. void WriteText(dword x,y,byte fontType, dword color, EDX)
  549. {
  550.         EAX = 4;
  551.         EBX = x<<16+y;
  552.         ECX = fontType<<24+color;
  553.         $int 0x40;
  554. }
  555.  
  556. dword WriteBufText(dword x,y,byte fontType, dword color, EDX, EDI)
  557. {
  558.         EAX = 4;
  559.         EBX = x<<16+y;
  560.         ECX = fontType<<24+color;
  561.         $int 0x40;
  562. }
  563.  
  564. void WriteNumber(dword x,y,byte fontType, dword color, count, ECX)
  565. {
  566.         EAX = 47;
  567.         EBX = count<<16;
  568.         EDX = x<<16+y;
  569.         ESI = fontType<<24+color;
  570.         $int 0x40;
  571. }
  572.  
  573. void CopyScreen(dword EBX, x, y, w, h)
  574. {
  575.   EAX = 36;
  576.   ECX = w << 16 + h;
  577.   EDX = x << 16 + y;
  578.   $int  0x40;
  579. }
  580.  
  581. :dword GetPixelColor(dword x, x_size, y)
  582. {
  583.         $mov eax, 35
  584.         EBX= y*x_size+x;
  585.         $int 0x40
  586. }
  587.  
  588.  
  589. void _PutImage(dword x,y, w,h, EBX)
  590. {
  591.         EAX = 7;
  592.         ECX = w<<16+h;
  593.         EDX = x<<16+y;
  594.         $int 0x40
  595. }
  596.  
  597. void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
  598. {
  599.         EAX = 65;
  600.         ECX = w<<16+h;
  601.         EDX = x<<16+y;
  602.         EBP = 0;
  603.         $int 0x40
  604. }
  605.  
  606. inline fastcall void PutPixel( EBX,ECX,EDX)
  607. {
  608.   EAX=1;
  609.   $int 0x40
  610. }
  611.  
  612. void DrawBar(dword x,y,w,h,EDX)
  613. {
  614.         if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
  615.         EAX = 13;
  616.         EBX = x<<16+w;
  617.         ECX = y<<16+h;
  618.         $int 0x40
  619. }
  620.  
  621. void DefineButton(dword x,y,w,h,EDX,ESI)
  622. {
  623.         EAX = 8;
  624.         $push edx
  625.         EDX += BT_DEL;
  626.         $int 0x40;
  627.         $pop edx
  628.         EBX = x<<16+w;
  629.         ECX = y<<16+h;
  630.         $int 0x40
  631. }
  632.  
  633. void UnsafeDefineButton(dword x,y,w,h,EDX,ESI)
  634. {
  635.         EAX = 8;
  636.         EBX = x<<16+w;
  637.         ECX = y<<16+h;
  638.         $int 0x40
  639. }
  640.  
  641. inline fastcall void DeleteButton( EDX)
  642. {
  643.         EAX = 8;
  644.         EDX += BT_DEL;
  645.         $int 0x40;
  646. }
  647.  
  648. inline fastcall dword GetStartTime()
  649. {
  650.         $mov eax,26
  651.         $mov ebx,9
  652.         $int 0x40
  653. }