Subversion Repositories Kolibri OS

Rev

Rev 5657 | Rev 5674 | 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. #ifndef INCLUDE_KOLIBRI_H
  3. #define INCLUDE_KOLIBRI_H
  4.  
  5. #startaddress 0
  6. #code32 TRUE
  7. char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
  8. dword  os_version   = 0x00000001;
  9. dword  start_addr   = #______INIT______;
  10. dword  final_addr   = #______STOP______+32;
  11. dword  alloc_mem    = MEMSIZE;
  12. dword  x86esp_reg   = MEMSIZE;
  13. dword  I_Param      = #param;
  14. dword  I_Path       = #program_path;
  15. char param[4096];
  16. char program_path[4096];
  17.  
  18. #define NULL      0
  19. #define OLD      -1
  20. #define true      1
  21. #define false     0
  22.  
  23. //Events
  24. #define evReDraw  1
  25. #define evKey     2
  26. #define evButton  3
  27. #define evDesktop 5
  28. #define evMouse   6
  29. #define evIPC     7
  30. #define evNetwork 8
  31. #define evDebug   9
  32.  
  33. #define EVENT_MOUSE case 6: mouse.get();
  34.  
  35. //Button options
  36. #define BT_DEL      0x80000000
  37. #define BT_HIDE     0x40000000
  38. #define BT_NOFRAME  0x20000000
  39.  
  40. //Button MOUSE
  41. #define MOUSE_LEFT   001b
  42. #define MOUSE_RIGHT  010b
  43. #define MOUSE_LR     011b
  44. #define MOUSE_CENTER 100b
  45.  
  46. //ASCII KEYS
  47. #define ASCII_KEY_BS    008
  48. #define ASCII_KEY_TAB   009
  49. #define ASCII_KEY_ENTER 013
  50. #define ASCII_KEY_ESC   027
  51. #define ASCII_KEY_DEL   182
  52. #define ASCII_KEY_INS   185
  53. #define ASCII_KEY_SPACE 032
  54.  
  55. #define ASCII_KEY_LEFT  176
  56. #define ASCII_KEY_RIGHT 179
  57. #define ASCII_KEY_DOWN  177
  58. #define ASCII_KEY_UP    178
  59. #define ASCII_KEY_HOME  180
  60. #define ASCII_KEY_END   181
  61. #define ASCII_KEY_PGDN  183
  62. #define ASCII_KEY_PGUP  184
  63.  
  64. //allow event mask
  65. #define EVENT_MASK_REDRAW   000000001b
  66. #define EVENT_MASK_KEYBOARD 000000010b
  67. #define EVENT_MASK_BUTTONS  000000100b
  68. #define EVENT_MASK_DESKTOP  000010000b
  69. #define EVENT_MASK_MOUSE    000100000b
  70. #define EVENT_MASK_IPC      001000000b
  71. #define EVENT_MASK_NETWORK  010000000b
  72. #define EVENT_MASK_DEBUG    100000000b
  73.  
  74. //ARGS FUNCTION
  75. #define END_ARGS 0xFF00FF
  76. //-------------------------------------------------------------------------
  77.  
  78. :struct raw_image {
  79.         dword w, h, data;
  80. };
  81.  
  82. /**
  83.  *  The structure of the MOUSE
  84.  *  x - coordinate X
  85.  *  y - coordinate Y
  86.  *  xx and yy - time coordinates
  87.  *  lkm - left MOUSE button
  88.  *  pkm - right MOUSE button
  89.  *  mkm - MOUSE wheel
  90.  *  key - keycode button
  91.  *  tmp - time keycode
  92.  *  down - key event press
  93.  *  up - key release events
  94.  *  move - event MOUSE movements
  95.  *  click - when clicked
  96.  *  dblclick - double-click the default 50 (500 ms)
  97.  *  drag - drag the element event
  98.  */
  99.  
  100. :dword __TMP_TIME,MOUSE_TIME;
  101. :struct MOUSE
  102. {
  103.         signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick,drag,left,top;
  104.         dword handle,_;
  105.         byte cmd;
  106.         void clearTime();
  107.         void get();
  108.         void set();
  109.         void center();
  110.         dword hide();
  111.         void slider();
  112.         void show();
  113. } mouse;
  114. :void MOUSE::clearTime()
  115. {
  116.         tmp_time = GetStartTime()+MOUSE_TIME;
  117. }
  118. :void MOUSE::show()
  119. {
  120.         if(!handle)return;
  121.         ECX = handle;
  122.         EAX = 37;
  123.         EBX = 5;
  124.         $int 0x40;
  125. }
  126. :dword MOUSE::hide()
  127. {
  128.         if(!_)
  129.         {
  130.                 EAX = 68;
  131.                 EBX = 12;
  132.                 ECX = 32*32*4;
  133.                 $int 0x40
  134.                 ECX = EAX;
  135.                 _ = EAX;
  136.         } else ECX = _;
  137.         EAX = 37;
  138.         EBX = 4;
  139.         DX  = 2;
  140.         $int 0x40;
  141.         handle = EAX;
  142.         ECX = EAX;
  143.         EAX = 37;
  144.         EBX = 5;
  145.         $int 0x40;
  146.         handle = EAX;
  147. }
  148.  
  149. //set new attributes MOUSE
  150. :void MOUSE::set()
  151. {
  152.         if((xx!=x)||(yy!=y))
  153.         {
  154.                 EAX = 18;
  155.                 EBX = 19;
  156.                 ECX = 4;
  157.                 EDX = (x<<16)+y;
  158.                 $int 0x40
  159.                 //move = true;
  160.         }
  161.         if((key)||(lkm|mkm|pkm))&&(down|up|click|dblclick|move)
  162.         {
  163.                 if(lkm|mkm|pkm)key=(lkm)|(pkm<<1)|(2<<mkm);
  164.                 EAX = 18;
  165.                 EBX = 19;
  166.                 ECX = key;
  167.                 EDX = (x<<16)+y;
  168.                 $int 0x40
  169.         }
  170. }
  171.  
  172. :void MOUSE::center()
  173. {
  174.         EAX = 18;
  175.         EBX = 15;
  176.         $int 0x40
  177. }
  178.  
  179. //get new attributes MOUSE
  180. :void MOUSE::get()
  181. {
  182.         EAX = 37;
  183.         EBX = 1;
  184.         $int    0x40
  185.         $mov    ebx, eax
  186.         $shr    eax, 16
  187.         $and    ebx,0x0000FFFF
  188.         x = EAX;
  189.         y = EBX;
  190.         if (x>6000) x-=65535;
  191.         if (y>6000) y-=65535;
  192.         EAX = 37;
  193.         EBX = 2;
  194.         $int    0x40
  195.         $mov    ebx, eax
  196.         $mov    ecx, eax
  197.         key = EAX;
  198.         $and    eax, 0x00000001
  199.         $shr    ebx, 1
  200.         $and    ebx, 0x00000001
  201.         $shr    ecx, 2
  202.         $and    ecx, 0x00000001
  203.         lkm = EAX;
  204.         pkm = EBX;
  205.         mkm = ECX;
  206.        
  207.         //when you release the MOUSE button
  208.         // Mouse Move Event
  209.         if(xx!=x)||(yy!=y)
  210.         {
  211.                 move = true;
  212.                 xx = x;
  213.                 yy = y;
  214.         }
  215.         else move = false;
  216.         // Mouse Up Event
  217.         if(cmd)&&(!key){
  218.                 up   = true;
  219.                 down = false;
  220.                 drag = false;
  221.                 if(!move) click = true;
  222.                 __TMP_TIME = GetStartTime();
  223.                 if(__TMP_TIME-tmp_time<=MOUSE_TIME)
  224.                 {
  225.                         dblclick = true;
  226.                         click    = false;
  227.                 }
  228.                 tmp_time = __TMP_TIME;
  229.                 //returns the key code
  230.                 key = tmp;
  231.                 lkm = 1&tmp;
  232.                 pkm = 2&tmp;
  233.                 pkm >>= 1;
  234.                 mkm = 4&tmp;
  235.                 mkm >>= 2;
  236.                 cmd = false;
  237.         }
  238.        
  239.         //when you press the MOUSE button
  240.         // Mouse Down Event/Move Event
  241.         else
  242.         {
  243.             up       = false;
  244.                 click    = false;
  245.                 dblclick = false;
  246.                 down     = false;
  247.                 // Mouse Move Event
  248.                 if(key)if(!cmd)
  249.                 {
  250.                         down = true;
  251.                         if(move)drag = true;
  252.                         cmd = true;
  253.                         tmp=key;
  254.                 }
  255.         }
  256.        
  257.         //scroll
  258.         EAX = 37;
  259.         EBX = 7;
  260.         $int    0x40
  261.         $mov    ebx, eax
  262.         $shr    eax, 16
  263.         $and    ebx,0x0000FFFF
  264.         //hor = EAX;
  265.         vert = EBX;
  266. }
  267.  
  268.  
  269.  
  270. :void MOUSE::slider()
  271. {
  272.         signed _x,_y;
  273.         if(!handle)hide();
  274.         get();
  275.         _x = x;_y = y;
  276.         pause(5);
  277.         get();
  278.         left = _x - x;
  279.         top  = _y - y;
  280.         center();
  281.         get();
  282.         _x = x;_y = y;
  283.         pause(5);
  284. }
  285.  
  286. :struct keyboard
  287. {
  288.         signed key;
  289.         byte down,up,press;
  290.         void get(void);
  291. };
  292.  
  293. :void keyboard::get(void)
  294. {
  295.        
  296. }
  297.  
  298. :struct system_colors
  299. {
  300.         dword frame,grab,grab_button,grab_button_text,grab_text,
  301.               work,work_button,work_button_text,work_text,work_graph;
  302.         void get();
  303. };
  304.  
  305. :void system_colors::get()
  306. {
  307.         EAX = 48;
  308.         EBX = 3;
  309.         ECX = #frame;
  310.         EDX = 40;
  311.         $int 0x40
  312. }
  313.  
  314. //------------------------------------------------------------------------------
  315. :dword wait_event_code;
  316. inline fastcall dword WaitEvent()
  317. {
  318.         $mov eax,10
  319.         $int 0x40
  320.         wait_event_code = EAX;
  321.         //if(wait_event_code==evMouse) MOUSE.get();
  322.         //return wait_event_code;
  323. }
  324.  
  325. inline fastcall dword CheckEvent()
  326. {
  327.         $mov eax,11
  328.         $int 0x40
  329. }
  330.  
  331. inline fastcall dword WaitEventTimeout(EBX)
  332. {
  333.         $mov eax,23
  334.         $int 0x40
  335. }
  336.  
  337. inline fastcall SetEventMask(EBX)
  338. {
  339.         $mov eax,40
  340.         $int 0x40
  341. }
  342.  
  343. inline fastcall ScancodesGeting(){
  344.         $mov eax,66
  345.         $mov ebx,1
  346.         $mov ecx,1 //᪠­ª®¤ë
  347.         $int 0x40
  348. }
  349.  
  350. inline fastcall word GetKey()  //+Gluk fix
  351. {
  352.                 $push edx
  353. GETKEY:
  354.                 $mov  eax,2
  355.                 $int  0x40
  356.                 $cmp eax,1
  357.                 $jne GETKEYI
  358.                 $mov ah,dh
  359.                 $jmp GETKEYII //jz?
  360. GETKEYI:
  361.                 $mov dh,ah
  362.                 $jmp GETKEY
  363. GETKEYII:
  364.                 $pop edx
  365.                 $shr eax,8
  366. }
  367.  
  368. inline fastcall int GetFullKey()
  369. {
  370.         $mov  eax,2
  371.         $int  0x40
  372. }
  373.  
  374.  
  375. inline fastcall pause(EBX)
  376. {
  377.         $mov eax, 5
  378.         $int 0x40
  379. }
  380.  
  381. inline fastcall word GetButtonID()
  382. {
  383.         $mov eax,17
  384.         $int  0x40
  385.         $shr eax,8
  386. }
  387.  
  388. inline fastcall dword GetFreeRAM()
  389. {
  390.         $mov eax, 18
  391.         $mov ebx, 16
  392.         $int 0x40
  393.         //return eax = ðàçìåð ñâîáîäíîé ïàìÿòè â êèëîáàéòàõ
  394. }
  395.  
  396. inline void draw_line(dword x1,y1,x2,y2,color)
  397. {
  398.         x2--;y2--;y1--;
  399.         $mov EAX,38
  400.         EBX = x1<<16;
  401.         EBX |= x2;
  402.         ECX = y1<<16;
  403.         ECX |= y2;
  404.         $mov EDX,color
  405.         $int 0x40
  406. }
  407.  
  408. inline fastcall dword LoadDriver(ECX) //ECX - èìÿ äðàéâåðà
  409. {
  410.         $mov eax, 68
  411.         $mov ebx, 16
  412.         $int 0x40
  413.         //return 0 - íåóäà÷à, èíà÷å eax = õýíäë äðàéâåðà
  414. }
  415.  
  416. inline fastcall dword RuleDriver(ECX) //óêàçàòåëü íà óïðàâëÿþùóþ ñòðóêòóðó
  417. {
  418.         $mov eax, 68
  419.         $mov ebx, 17
  420.         $int 0x40
  421.         //return eax = îïðåäåëÿåòñÿ äðàéâåðîì
  422. }
  423.  
  424. struct proc_info
  425. {
  426.         #define SelfInfo -1
  427.         dword   use_cpu;
  428.         word    pos_in_stack,num_slot,rezerv1;
  429.         unsigned char name[11];
  430.         char    rezerv2;
  431.         dword   adress,use_memory,ID,left,top,width,height;
  432.         word    status_slot,rezerv3;
  433.         dword   work_left,work_top,work_width,work_height;
  434.         char    status_window;
  435.         dword   cwidth,cheight;
  436.         byte    reserved[1024-71-8];
  437. };
  438.  
  439. inline fastcall void GetProcessInfo(EBX, ECX)
  440. {
  441.         $mov eax,9;
  442.         $int  0x40
  443.         DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
  444.         DSDWORD[EBX+75] = DSDWORD[EBX+46] - GetSkinHeight() - 4; //set cheight
  445. }
  446.  
  447. inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
  448. {
  449.         $mov eax,34
  450.         $int 0x40
  451. }
  452.  
  453. inline fastcall int GetProcessSlot( ECX)
  454. {
  455.         EAX = 18;
  456.         EBX = 21;
  457.         $int 0x40
  458. }
  459.  
  460. inline fastcall int GetActiveProcess()
  461. {
  462.         EAX = 18;
  463.         EBX = 7;
  464.         $int 0x40
  465. }
  466.  
  467. :int CheckActiveProcess(int Form_ID)
  468. {
  469.         int id9=GetProcessSlot(Form_ID);
  470.         if (id9==GetActiveProcess()) return 1;
  471.         return 0;
  472. }
  473.  
  474. inline fastcall void ActivateWindow( ECX)
  475. {
  476.         EAX = 18;
  477.         EBX = 3;
  478.         $int 0x40
  479. }
  480.  
  481. inline fastcall int MinimizeWindow()
  482. {
  483.         EAX = 18;
  484.         EBX = 10;
  485.         $int 0x40
  486. }
  487.  
  488. inline fastcall int CreateThread(ECX,EDX)
  489. {
  490.         $mov eax,51
  491.         $mov ebx,1
  492.         $int 0x40
  493. }
  494.  
  495. inline fastcall void SwitchToAnotherThread()
  496. {
  497.         $mov eax,68
  498.         $mov ebx,1
  499.         $int 0x40
  500. }
  501.  
  502. inline fastcall int SendWindowMessage( ECX, EDX)
  503. {
  504.         $mov eax, 72
  505.         $mov ebx, 1
  506.         $int 0x40
  507. }
  508.  
  509. inline fastcall int KillProcess( ECX)
  510. {
  511.         $mov eax,18;
  512.         $mov ebx,18;
  513.         $int 0x40
  514. }
  515.  
  516. #define TURN_OFF 2
  517. #define REBOOT 3
  518. #define KERNEL 4
  519. inline fastcall int ExitSystem( ECX)
  520. {
  521.         $mov eax, 18
  522.         $mov ebx, 9
  523.         $int 0x40
  524. }
  525.  
  526. inline fastcall ExitProcess()
  527. {
  528.         $mov eax,-1;
  529.         $int 0x40
  530. }
  531.  
  532. //------------------------------------------------------------------------------
  533.  
  534. //eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
  535. inline fastcall int GetSystemLanguage()
  536. {
  537.         EAX = 26;
  538.         EBX = 5;
  539.         $int 0x40
  540. }
  541.  
  542. inline fastcall GetSkinHeight()
  543. {
  544.         $push ebx
  545.         $mov  eax,48
  546.         $mov  ebx,4
  547.         $int 0x40
  548.         $pop  ebx
  549. }
  550.  
  551. inline fastcall void SetSystemSkin( ECX)
  552. {
  553.         EAX = 48;
  554.         EBX = 8;
  555.         $int 0x40
  556. }
  557.  
  558. inline fastcall int GetScreenWidth()
  559. {
  560.         $mov eax, 14
  561.         $int 0x40
  562.         $shr eax, 16
  563. }
  564.  
  565. inline fastcall int GetScreenHeight()
  566. {
  567.         $mov eax, 14
  568.         $int 0x40
  569.         $and eax,0x0000FFFF
  570. }
  571.  
  572. inline fastcall int GetClientTop()
  573. {
  574.         $mov eax, 48
  575.         $mov ebx, 5
  576.         $int 0x40
  577.     $mov eax, ebx
  578.     $shr eax, 16
  579. }
  580.  
  581. inline fastcall int GetClientHeight()
  582. {
  583.         $mov eax, 48
  584.         $mov ebx, 5
  585.         $int 0x40
  586.     $mov eax, ebx
  587. }
  588.  
  589.  
  590. inline fastcall dword LoadLibrary( ECX)
  591. {
  592.         $mov eax, 68
  593.         $mov ebx, 19
  594.         $int  0x40
  595. }
  596.  
  597. inline fastcall int TestBit( EAX, CL)
  598. {
  599.         $shr eax,cl
  600.         $and eax,1
  601. }
  602.  
  603. inline fastcall int PlaySpeaker( ESI)
  604. {
  605.         $mov eax, 55
  606.         $mov ebx, 55
  607.         $int 0x40
  608. }
  609.  
  610. inline fastcall void debugln( EDX)
  611. {
  612.         $push eax
  613.         $push ebx
  614.         $push ecx
  615.         $mov eax, 63
  616.         $mov ebx, 1
  617. NEXT_CHAR:
  618.         $mov ecx, DSDWORD[edx]
  619.         $or      cl, cl
  620.         $jz  DONE
  621.         $int 0x40
  622.         $inc edx
  623.         $jmp NEXT_CHAR
  624. DONE:
  625.         $mov cl, 13
  626.         $int 0x40
  627.         $mov cl, 10
  628.         $int 0x40
  629.         $pop ecx
  630.         $pop ebx
  631.         $pop eax
  632. }
  633.  
  634. inline fastcall void debug( EDX)
  635. {
  636.         $push eax
  637.         $push ebx
  638.         $push ecx
  639.         $mov eax, 63
  640.         $mov ebx, 1
  641. NEXT_CHAR:
  642.         $mov ecx, DSDWORD[edx]
  643.         $or      cl, cl
  644.         $jz  DONE
  645.         $int 0x40
  646.         $inc edx
  647.         $jmp NEXT_CHAR
  648. DONE:
  649.         $pop ecx
  650.         $pop ebx
  651.         $pop eax
  652. }
  653.  
  654.  
  655. inline fastcall void debugch( ECX)
  656. {
  657.         $push eax
  658.         $push ebx
  659.         $mov eax,63
  660.         $mov ebx,1
  661.         $int 0x40
  662.         $pop ebx
  663.         $pop eax
  664. }
  665. //------------------------------------------------------------------------------
  666.  
  667. void DefineAndDrawWindow(dword x, y, size_w, size_h, byte WindowType,dword WindowAreaColor, EDI, ESI)
  668. {
  669.         EAX = 12;              // function 12:tell os about windowdraw
  670.         EBX = 1;
  671.         $int 0x40
  672.        
  673.         $xor EAX,EAX
  674.         EBX = x << 16 + size_w;
  675.         ECX = y << 16 + size_h;
  676.  
  677.         EDX = WindowType << 24 | WindowAreaColor;
  678.         $int 0x40
  679.  
  680.         EAX = 12;              // function 12:tell os about windowdraw
  681.         EBX = 2;
  682.         $int 0x40
  683. }
  684.  
  685. inline fastcall MoveSize( EBX,ECX,EDX,ESI)
  686. {
  687.         $mov eax, 67
  688.         $int 0x40
  689. }
  690.  
  691. inline fastcall void DrawTitle( ECX)
  692. {
  693.         EAX = 71;
  694.         EBX = 1;
  695.         $int 0x40;
  696. }
  697.  
  698. void WriteTextB(dword x,y,byte fontType, dword color, EDX)
  699. {
  700.         EAX = 4;
  701.         EBX = x<<16+y;
  702.         ECX = fontType<<24+color;
  703.         ESI = 0;
  704.         $int 0x40;
  705.         $add ebx, 1<<16
  706.         $int 0x40
  707. }
  708.  
  709. void WriteText(dword x,y,byte fontType, dword color, EDX)
  710. {
  711.         EAX = 4;
  712.         EBX = x<<16+y;
  713.         ECX = fontType<<24+color;
  714.         $int 0x40;
  715. }
  716.  
  717. dword WriteBufText(dword x,y,byte fontType, dword color, EDX, EDI)
  718. {
  719.         EAX = 4;
  720.         EBX = x<<16+y;
  721.         ECX = fontType<<24+color;
  722.         $int 0x40;
  723. }
  724.  
  725. void WriteNumber(dword x,y,byte fontType, dword color, count, ECX)
  726. {
  727.         EAX = 47;
  728.         EBX = count<<16;
  729.         EDX = x<<16+y;
  730.         ESI = fontType<<24+color;
  731.         $int 0x40;
  732. }
  733.  
  734. void CopyScreen(dword EBX, x, y, w, h)
  735. {
  736.   EAX = 36;
  737.   ECX = w << 16 + h;
  738.   EDX = x << 16 + y;
  739.   $int  0x40;
  740. }
  741.  
  742. :dword GetPixelColor(dword x, x_size, y)
  743. {
  744.         $mov eax, 35
  745.         EBX= y*x_size+x;
  746.         $int 0x40
  747. }
  748.  
  749.  
  750. void _PutImage(dword x,y, w,h, EBX)
  751. {
  752.         EAX = 7;
  753.         ECX = w<<16+h;
  754.         EDX = x<<16+y;
  755.         $int 0x40
  756. }
  757.  
  758. void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
  759. {
  760.         EAX = 65;
  761.         ECX = w<<16+h;
  762.         EDX = x<<16+y;
  763.         EBP = 0;
  764.         $int 0x40
  765. }
  766.  
  767. inline fastcall void PutPixel( EBX,ECX,EDX)
  768. {
  769.   EAX=1;
  770.   $int 0x40
  771. }
  772.  
  773. void DrawBar(dword x,y,w,h,EDX)
  774. {
  775.         if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
  776.         EAX = 13;
  777.         EBX = x<<16+w;
  778.         ECX = y<<16+h;
  779.         $int 0x40
  780. }
  781.  
  782. void DefineButton(dword x,y,w,h,EDX,ESI)
  783. {
  784.         EAX = 8;
  785.         $push edx
  786.         EDX += BT_DEL;
  787.         $int 0x40;
  788.         $pop edx
  789.         EBX = x<<16+w;
  790.         ECX = y<<16+h;
  791.         $int 0x40
  792. }
  793.  
  794. inline RefreshWindow(dword ID_REFRESH,ID_ACTIVE)
  795. {
  796.         EAX = 18;
  797.         EBX = 22;
  798.         ECX = 3;
  799.         EDX = ID_REFRESH;
  800.         $int 0x40
  801.         EAX = 18;
  802.         EBX = 3;
  803.         EDX = ID_ACTIVE;
  804.         $int 0x40
  805. }
  806.  
  807. inline getIPC(ECX,EDX)
  808. {
  809.         $mov EAX,60
  810.         $mov EBX,2
  811.         $int 0x40
  812. }
  813.  
  814. inline sendIPC(ECX,EDX,ESI)
  815. {
  816.         $mov EAX,60
  817.         $mov EBX,1
  818.         $int 0x40
  819. }
  820.  
  821. void UnsafeDefineButton(dword x,y,w,h,EDX,ESI)
  822. {
  823.         EAX = 8;
  824.         EBX = x<<16+w;
  825.         ECX = y<<16+h;
  826.         $int 0x40
  827. }
  828.  
  829. inline fastcall void DeleteButton( EDX)
  830. {
  831.         EAX = 8;
  832.         EDX += BT_DEL;
  833.         $int 0x40
  834. }
  835.  
  836. inline fastcall dword GetStartTime()
  837. {
  838.         $mov eax,26
  839.         $mov ebx,9
  840.         $int 0x40
  841. }
  842.  
  843. :dword X_EventRedrawWindow,Y_EventRedrawWindow;
  844. :void _EventRedrawWindow()
  845. {
  846.         loop()switch(WaitEvent())
  847.         {
  848.                 case evReDraw:
  849.                         DefineAndDrawWindow(X_EventRedrawWindow,Y_EventRedrawWindow,100,1,1,0x34,0xFFFFFF,"");
  850.                         pause(10);
  851.                         ExitProcess();
  852.                         break;
  853.         }
  854. }
  855. :void EventRedrawWindow(dword x,y)
  856. {
  857.         dword mem = malloc(4096);
  858.         X_EventRedrawWindow = x;
  859.         Y_EventRedrawWindow = y;
  860.         CreateThread(#_EventRedrawWindow,mem+4092);
  861. }
  862.  
  863. :dword ALERT_TEXT;
  864. :void dialog_alert()
  865. {
  866.         byte id;
  867.         loop()switch(WaitEvent())
  868.         {
  869.                 case evReDraw:
  870.                         DefineAndDrawWindow(215,100,250,200,0x34,0xFFFFFF,"Alert");
  871.                         WriteTextB(5,5,0x90,0x0,ALERT_TEXT);
  872.                 break;
  873.                 case evKey:
  874.                 case evButton:
  875.                         id=GetButtonID();
  876.                         if (id==1) ExitProcess();
  877.                 break;
  878.         }
  879. }
  880. :dword alert(dword text)
  881. {
  882.         dword mem = malloc(4096);
  883.         ALERT_TEXT = text;
  884.         CreateThread(#dialog_alert,mem+4092);
  885.         return mem;
  886. }
  887.  
  888. :struct _screen
  889. {
  890.         dword width,height;
  891. } screen;
  892.  
  893. :struct _skin
  894. {
  895.         dword width,height;
  896. } SKIN;
  897.  
  898. :void DrawDate(dword x, y, color, in_date)
  899. {
  900.         //char text[15];
  901.         EDI = in_date;
  902.         EAX = 47;
  903.         EBX = 2<<16;
  904.         EDX = x<<16+y;
  905.         ESI = 0x80<<24+color;
  906.         ECX = EDI.date.day;
  907.         $int 0x40;
  908.         EDX += 18<<16;
  909.         ECX = EDI.date.month;
  910.         $int 0x40;
  911.         EDX += 18<<16;
  912.         EBX = 4<<16;
  913.         ECX = EDI.date.year;
  914.         $int 0x40;
  915.         PutPixel(x+14,y+6,color);
  916.         PutPixel(x+32,y+6,color);
  917.         //sprintf(#text,"%d",EDI.date.year);
  918.         //WriteText(x, y, 0x80, 0x000000, #text);
  919. }
  920.  
  921. :void __path_name__(dword BUF,PATH)
  922. {
  923.         dword beg = PATH;
  924.         dword pos = PATH;
  925.         dword sav = PATH;
  926.         dword i;
  927.         while(DSBYTE[pos])
  928.         {
  929.                 if(DSBYTE[pos]=='/')sav = pos;
  930.                 pos++;
  931.         }
  932.         i = sav-beg;
  933.         while(i)
  934.         {
  935.                 DSBYTE[BUF] = DSBYTE[beg];
  936.                 beg++;
  937.                 BUF++;
  938.                 i--;
  939.         }
  940.         /*while(DSBYTE[beg])
  941.         {
  942.                 DSBYTE[BUF1] = DSBYTE[beg];
  943.                 beg++;
  944.                 BUF1++;
  945.         }*/
  946.         //DSBYTE[BUF1] = 0;
  947.         DSBYTE[BUF] = 0;
  948. }
  949. char __BUF_DIR__[4096];
  950. :struct SELF
  951. {
  952.         dword dir;
  953.         dword file;
  954.         dword path;
  955. } self;
  956.  
  957. dword __generator;  // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
  958.  
  959. :dword program_path_length;
  960.  
  961. //The initialization of the initial data before running
  962. void ______INIT______()
  963. {
  964.         self.dir = #__BUF_DIR__;
  965.         self.file = 0;
  966.         self.path = I_Path;
  967.         __path_name__(#__BUF_DIR__,I_Path);
  968.        
  969.         SKIN.height   = GetSkinHeight();
  970.         screen.width  = GetScreenWidth();
  971.         screen.height = GetScreenHeight();
  972.        
  973.         //program_path_length = strlen(I_Path);
  974.         MOUSE_TIME = 50; //Default 500 ms.
  975.         __generator = GetStartTime();
  976.        
  977.         $push    ebx
  978.         $mov     eax, 68
  979.         $mov     ebx, 11
  980.         $int     0x40
  981.        
  982.         $pop     ebx
  983.  
  984.         main();
  985. }
  986. ______STOP______:
  987. #endif