Subversion Repositories Kolibri OS

Rev

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