Subversion Repositories Kolibri OS

Rev

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