Subversion Repositories Kolibri OS

Rev

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