Subversion Repositories Kolibri OS

Rev

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

  1. #include "kosSyst.h"
  2. #include <stdarg.h>
  3.  
  4. #define atexitBufferSize        32
  5.  
  6.  
  7. char pureCallMessage[] = "PURE function call!";
  8.  
  9. char *kosExePath = NULL;
  10.  
  11. //
  12. void (__cdecl *atExitList[atexitBufferSize])();
  13. int atExitFnNum = 0;
  14. //
  15. int __cdecl atexit( void (__cdecl *func )( void ))
  16. {
  17.         //
  18.         if ( atExitFnNum < atexitBufferSize )
  19.         {
  20.                 //
  21.                 atExitList[atExitFnNum++] = func;
  22.                 return 0;
  23.         }
  24.         else
  25.         {
  26.                 return 1;
  27.         }
  28. }
  29.  
  30.  
  31. //
  32. Dword RandomSeed = 1;
  33. //
  34. void rtlSrand( Dword seed )
  35. {
  36.         RandomSeed = seed;
  37. }
  38. //
  39. Dword rtlRand( void )
  40. {
  41.   //ìàñêà 0x80000776
  42.  
  43.   Dword dwi, i;
  44.  
  45.   for ( i = 0; i < 32; i++ )
  46.   {
  47.  
  48.     dwi = RandomSeed & 0x80000776;
  49.  
  50.       __asm{
  51.             mov   eax, dwi
  52.             mov   edx, eax
  53.             bswap eax
  54.             xor   eax, edx
  55.             xor   al, ah
  56.             setpo al
  57.             movzx eax, al
  58.             mov   dwi, eax
  59.     }
  60.  
  61.     RandomSeed = ( RandomSeed << 1 ) | ( dwi & 1 );
  62.   }
  63.  
  64.  return RandomSeed;
  65. }
  66.  
  67. #if _MSC_VER >= 1400
  68. //
  69. void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount )
  70. {
  71.         __asm{
  72.                 mov edi, dst
  73.                 mov eax, dst
  74.                 mov esi, src
  75.                 mov ecx, bytesCount
  76.                 rep movsb
  77.         }
  78. }
  79.  
  80. //
  81. void memset( Byte *dst, Byte filler, Dword count )
  82. {
  83.         //
  84.         __asm{
  85.                 mov edi, dst
  86.                 mov al, filler
  87.                 mov ecx, count
  88.                 rep stosb
  89.         }
  90. }
  91. #endif
  92.  
  93. //
  94. Dword rtlInterlockedExchange( Dword *target, Dword value )
  95. {
  96. //      Dword result;
  97.  
  98.         //
  99.         __asm{
  100.                 mov eax, value
  101.                 mov ebx, target
  102.                 xchg eax, [ebx]
  103. //              mov result, eax
  104.         }
  105.         //
  106. //      return result;
  107. }
  108.  
  109.  
  110. //////////////////////////////////////////////////////////////////////
  111. //
  112. // êîïèðîâàíèå ñòðîêè
  113. //
  114.  
  115. char * __cdecl strcpy( char *target, const char *source )
  116. {
  117.         char *result = target;
  118.  
  119.         while( target[0] = source[0] )
  120.         {
  121.                 target++;
  122.                 source++;
  123.         }
  124.  
  125.         return result;
  126. }
  127.  
  128.  
  129. //////////////////////////////////////////////////////////////////////
  130. //
  131. // ðåâåðñèâíûé ïîèñê ñèìâîëà
  132. //
  133.  
  134. char * __cdecl strrchr( const char * string, int c )
  135. {
  136.         char *cPtr;
  137.  
  138.         //
  139.         for ( cPtr = (char *)string + strlen( string ); cPtr >= string; cPtr-- )
  140.         {
  141.                 //
  142.                 if ( *cPtr == c ) return cPtr;
  143.         }
  144.         //
  145.         return NULL;
  146. }
  147.  
  148.  
  149. //////////////////////////////////////////////////////////////////////
  150. //
  151. // îïðåäåëåíèå äëèíû ñòðîêè
  152. //
  153.  
  154. int __cdecl strlen( const char *line )
  155. {
  156.   int i;
  157.  
  158.   for( i=0; line[i] != 0; i++ );
  159.   return i;
  160. }
  161.  
  162.  
  163.  
  164. //////////////////////////////////////////////////////////////////////
  165. //
  166. // ïåðåâîä øåñòíàäöàòèðè÷íîãî ÷èñëà â ñèìâîë
  167. //
  168.  
  169. unsigned int num2hex( unsigned int num )
  170. {
  171.   if( num < 10 )
  172.     return num + '0';
  173.   return num - 10 + 'A';
  174. }
  175.  
  176.  
  177. //////////////////////////////////////////////////////////////////////
  178. //
  179. // âûâîä ñòðîêè íà ïå÷àòü
  180. //
  181.  
  182. Dword dectab[] = { 1000000000, 100000000, 10000000, 1000000, 100000,
  183.                    10000, 1000, 100, 10, 0 };
  184.  
  185. //
  186. void sprintf( char *Str, char* Format, ... )
  187. {
  188.         int i, fmtlinesize, j, k, flag;
  189.         Dword head, tail;
  190.         char c;
  191.         va_list arglist;
  192.         //
  193.         va_start(arglist, Format);
  194.  
  195.         //
  196.         fmtlinesize = strlen( Format );
  197.         //
  198.         if( fmtlinesize == 0 ) return;
  199.  
  200.         //
  201.         for( i = 0, j = 0; i < fmtlinesize; i++ )
  202.         {
  203.                 //
  204.                 c = Format[i];
  205.                 //
  206.                 if( c != '%' )
  207.                 {
  208.                         Str[j++] = c;
  209.                         continue;
  210.                 }
  211.                 //
  212.                 i++;
  213.                 //
  214.                 if( i >= fmtlinesize ) break;
  215.  
  216.                 //
  217.                 flag = 0;
  218.                 //
  219.                 c = Format[i];
  220.                 //
  221.                 switch( c )
  222.                 {
  223.                 //
  224.                 case '%':
  225.                         Str[j++] = c;
  226.                         break;
  227.                 // âûâîä ñòðîêè
  228.                 case 'S':
  229.                         Byte* str;
  230.                         str = va_arg(arglist, Byte*);
  231.                         for( k = 0; ( c = str[k] ) != 0; k++ )
  232.                         {
  233.                                 Str[j++] = c;
  234.                         }
  235.                         break;
  236.                 // âûâîä áàéòà
  237.                 case 'B':
  238.                         k = va_arg(arglist, int) & 0xFF;
  239.                         Str[j++] = num2hex( ( k >> 4 ) & 0xF );
  240.                         Str[j++] = num2hex( k & 0xF );
  241.                         break;
  242.                 // âûâîä ñèìâîëà
  243.                 case 'C':
  244.                         Str[j++] = va_arg(arglist, int) & 0xFF;
  245.                         break;
  246.                 // âûâîä äâîéíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå
  247.                 case 'X':
  248.                         Dword val;
  249.                         val = va_arg(arglist, Dword);
  250.                         for( k = 7; k >= 0; k-- )
  251.                         {
  252.                                 //
  253.                                 c = num2hex ( ( val >> (k * 4) ) & 0xF );
  254.                                 //
  255.                                 if( c == '0' )
  256.                                 {
  257.                                         if( flag ) Str[j++] = c;
  258.                                 }
  259.                                 else
  260.                                 {
  261.                                         flag++;
  262.                                         Str[j++] = c;
  263.                                 }
  264.                         }
  265.                         //
  266.                         if( flag == 0 ) Str[j++] = '0';
  267.                         break;
  268.                 // âûâîä äâîéíîãî ñëîâà â äåñÿòè÷íîì âèäå
  269.                 case 'U':
  270.                         head = va_arg(arglist, Dword);
  271.                         tail = 0;
  272.                         for( k = 0; dectab[k] != 0; k++ )
  273.                         {
  274.                                 tail = head % dectab[k];
  275.                                 head /= dectab[k];
  276.                                 c = head + '0';
  277.                                 if( c == '0' )
  278.                                 {
  279.                                         if( flag ) Str[j++] = c;
  280.                                 }
  281.                                 else
  282.                                 {
  283.                                         flag++;
  284.                                         Str[j++] = c;
  285.                                 }
  286.                                 //
  287.                                 head = tail;
  288.                         }
  289.                         //
  290.                         c = head + '0';
  291.                         Str[j++] = c;
  292.                         break;
  293.                 // âûâîä 64-áèòíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå
  294.                 case 'Q':
  295.                         unsigned int low_dword, high_dword;
  296.                         low_dword = va_arg(arglist, unsigned int);
  297.                         high_dword = va_arg(arglist, unsigned int);
  298.                         for( k = 7; k >= 0; k-- )
  299.                         {
  300.                                 //
  301.                                 c = num2hex ( ( ( high_dword + 1) >> (k * 4) ) & 0xF );
  302.                                 //
  303.                                 if( c == '0' )
  304.                                 {
  305.                                         if( flag ) Str[j++] = c;
  306.                                 }
  307.                                 else
  308.                                 {
  309.                                         flag++;
  310.                                         Str[j++] = c;
  311.                                 }
  312.                         }
  313.                         //
  314.                         for( k=7; k >= 0; k-- )
  315.                         {
  316.                                 //
  317.                                 c = num2hex ( ( low_dword >> (k * 4) ) & 0xF );
  318.                                 //
  319.                                 if( c == '0' )
  320.                                 {
  321.                                         if( flag ) Str[j++] = c;
  322.                                 }
  323.                                 else
  324.                                 {
  325.                                         flag++;
  326.                                         Str[j++] = c;
  327.                                 }
  328.                         }
  329.                         //
  330.                         if( flag == 0 ) Str[j++] = '0';
  331.                         //
  332.                         break;
  333.                 //
  334.                 default:
  335.                         break;
  336.                 }
  337.         }
  338.         //
  339.         Str[j] = 0;
  340. }
  341.  
  342.  
  343. // ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà
  344. void kos_ExitApp()
  345. {
  346.         int i;
  347.  
  348.         //
  349.         for ( i = atExitFnNum - 1; i >= 0; i-- )
  350.         {
  351.                 //
  352.                 atExitList[i]();
  353.         }
  354.         //
  355.         __asm{
  356.                 mov eax, -1
  357.                 int 0x40
  358.         }
  359. }
  360.  
  361.  
  362. // ôóíêöèÿ 0
  363. void kos_DefineAndDrawWindow(
  364.         Word x, Word y,
  365.         Word sizeX, Word sizeY,
  366.         Byte mainAreaType,
  367.         Dword mainAreaColour,
  368.         Byte headerType,
  369.         Dword headerColour,
  370.         Dword borderColour
  371.         )
  372. {
  373.         Dword arg1, arg2, arg3, arg4;
  374.  
  375.         //
  376.         arg1 = ( x << 16 ) + sizeX;
  377.         arg2 = ( y << 16 ) + sizeY;
  378.         arg3 = ( mainAreaType << 24 ) | mainAreaColour;
  379.         arg4 = ( headerType << 24 ) | headerColour;
  380.         //
  381.         __asm{
  382.                 mov eax, 0
  383.                 mov ebx, arg1
  384.                 mov ecx, arg2
  385.                 mov edx, arg3
  386.                 mov esi, arg4
  387.                 mov edi, borderColour
  388.                 int 0x40
  389.         }
  390. }
  391.  
  392.  
  393. // ôóíêöèÿ 1 ïîñòàâèòü òî÷êó
  394. void kos_PutPixel( Dword x, Dword y, Dword colour )
  395. {
  396.         //
  397.         __asm{
  398.                 mov eax, 1
  399.                 mov ebx, x
  400.                 mov ecx, y
  401.                 mov edx, colour
  402.                 int 0x40
  403.         }
  404. }
  405.  
  406.  
  407. // ôóíêöèÿ 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
  408. bool kos_GetKey( Byte &keyCode )
  409. {
  410.         Dword result;
  411.  
  412.         //
  413.         __asm{
  414.                 mov eax, 2
  415.                 int 0x40
  416.                 mov result, eax
  417.         }
  418.         //
  419.         keyCode = result >> 8;
  420.         //
  421.         return ( result & 0xFF ) == 0;
  422. }
  423.  
  424.  
  425. // ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ
  426. Dword kos_GetSystemClock()
  427. {
  428. //      Dword result;
  429.  
  430.         //
  431.         __asm{
  432.                 mov eax, 3
  433.                 int 0x40
  434. //              mov result, eax
  435.         }
  436.         //
  437. //      return result;
  438. }
  439.  
  440.  
  441. // ôóíêöèÿ 4
  442. void kos_WriteTextToWindow(
  443.         Word x,
  444.         Word y,
  445.         Byte fontType,
  446.         Dword textColour,
  447.         char *textPtr,
  448.         Dword textLen
  449.         )
  450. {
  451.         Dword arg1, arg2;
  452.  
  453.         //
  454.         arg1 = ( x << 16 ) | y;
  455.         arg2 = ( fontType << 24 ) | textColour;
  456.         //
  457.         __asm{
  458.                 mov eax, 4
  459.                 mov ebx, arg1
  460.                 mov ecx, arg2
  461.                 mov edx, textPtr
  462.                 mov esi, textLen
  463.                 int 0x40
  464.         }
  465. }
  466.  
  467.  
  468. // ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
  469. void kos_Pause( Dword value )
  470. {
  471.         //
  472.         __asm{
  473.                 mov eax, 5
  474.                 mov ebx, value
  475.                 int 0x40
  476.         }
  477. }
  478.  
  479.  
  480. // ôóíêöèÿ 7 íàðèñîâàòü èçîáðàæåíèå
  481. void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y )
  482. {
  483.         Dword arg1, arg2;
  484.  
  485.         //
  486.         arg1 = ( sizeX << 16 ) | sizeY;
  487.         arg2 = ( x << 16 ) | y;
  488.         //
  489.         __asm{
  490.                 mov eax, 7
  491.                 mov ebx, imagePtr
  492.                 mov ecx, arg1
  493.                 mov edx, arg2
  494.                 int 0x40
  495.         }
  496. }
  497.  
  498.  
  499.  
  500. // ôóíêöèÿ 8 îïðåäåëèòü êíîïêó
  501. void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour )
  502. {
  503.         Dword arg1, arg2;
  504.  
  505.         //
  506.         arg1 = ( x << 16 ) | sizeX;
  507.         arg2 = ( y << 16 ) | sizeY;
  508.         //
  509.         __asm{
  510.                 mov eax, 8
  511.                 mov ebx, arg1
  512.                 mov ecx, arg2
  513.                 mov edx, buttonID
  514.                 mov esi, colour
  515.                 int 0x40
  516.         }
  517. }
  518.  
  519.  
  520. // ôóíêöèÿ 9 - èíôîðìàöèÿ î ïðîöåññå
  521. Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID )
  522. {
  523. //      Dword result;
  524.  
  525.         //
  526.         __asm{
  527.                 mov eax, 9
  528.                 mov ebx, targetPtr
  529.                 mov ecx, processID
  530.                 int 0x40
  531. //              mov result, eax
  532.         }
  533.         //
  534. //      return result;
  535. }
  536.  
  537.  
  538. // ôóíêöèÿ 10
  539. Dword kos_WaitForEvent()
  540. {
  541. //      Dword result;
  542.  
  543.         __asm{
  544.                 mov eax, 10
  545.                 int 0x40
  546. //              mov result, eax
  547.         }
  548.        
  549. //      return result;
  550. }
  551.  
  552.  
  553. // ôóíêöèÿ 11
  554. Dword kos_CheckForEvent()
  555. {
  556. //      Dword result;
  557.  
  558.         __asm{
  559.                 mov eax, 11
  560.                 int 0x40
  561. //              mov result, eax
  562.         }
  563.        
  564. //      return result;
  565. }
  566.  
  567.  
  568. // ôóíêöèÿ 12
  569. void kos_WindowRedrawStatus( Dword status )
  570. {
  571.         __asm{
  572.                 mov eax, 12
  573.                 mov ebx, status
  574.                 int 0x40
  575.         }
  576. }
  577.  
  578.  
  579. // ôóíêöèÿ 13 íàðèñîâàòü ïîëîñó
  580. void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour )
  581. {
  582.         Dword arg1, arg2;
  583.  
  584.         //
  585.         arg1 = ( x << 16 ) | sizeX;
  586.         arg2 = ( y << 16 ) | sizeY;
  587.         //
  588.         __asm{
  589.                 mov eax, 13
  590.                 mov ebx, arg1
  591.                 mov ecx, arg2
  592.                 mov edx, colour
  593.                 int 0x40
  594.         }
  595. }
  596.  
  597.  
  598. // ôóíêöèÿ 17
  599. bool kos_GetButtonID( Dword &buttonID )
  600. {
  601.         Dword result;
  602.  
  603.         //
  604.         __asm{
  605.                 mov eax, 17
  606.                 int 0x40
  607.                 mov result, eax
  608.         }
  609.         //
  610.         buttonID = result >> 8;
  611.         //
  612.         return (result & 0xFF) == 0;
  613. }
  614.  
  615.  
  616. // ôóíêöèÿ 23
  617. Dword kos_WaitForEvent( Dword timeOut )
  618. {
  619. //      Dword result;
  620.  
  621.         __asm{
  622.                 mov eax, 23
  623.                 mov ebx, timeOut
  624.                 int 0x40
  625. //              mov result, eax
  626.         }
  627.        
  628. //      return result;
  629. }
  630.  
  631.  
  632. // ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" ôóíêöèÿ 37
  633. void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY )
  634. {
  635.         Dword mB;
  636.         Word curX;
  637.         Word curY;
  638.         sProcessInfo sPI;
  639.  
  640.         //
  641.         __asm{
  642.                 mov             eax, 37
  643.                 mov             ebx, 0
  644.                 int             0x40
  645.                 mov             curY, ax
  646.                 shr             eax, 16
  647.                 mov             curX, ax
  648.                 mov             eax, 37
  649.                 mov             ebx, 2
  650.                 int             0x40
  651.                 mov             mB, eax
  652.         }
  653.         //
  654.         kos_ProcessInfo( &sPI );
  655.         //
  656.         buttons = mB;
  657.         cursorX = curX - sPI.processInfo.x_start;
  658.         cursorY = curY - sPI.processInfo.y_start;
  659. }
  660.  
  661.  
  662. // ôóíêöèÿ 40 óñòàíîâèòü ìàñêó ñîáûòèé
  663. void kos_SetMaskForEvents( Dword mask )
  664. {
  665.         //
  666.         __asm{
  667.                 mov eax, 40
  668.                 mov ebx, mask
  669.                 int 0x40
  670.         }
  671. }
  672.  
  673.  
  674. // ôóíêöèÿ 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî
  675. void kos_DisplayNumberToWindow(
  676.    Dword value,
  677.    Dword digitsNum,
  678.    Word x,
  679.    Word y,
  680.    Dword colour,
  681.    eNumberBase nBase,
  682.    bool valueIsPointer
  683.    )
  684. {
  685.         Dword arg1, arg2;
  686.  
  687.         //
  688.         arg1 = ( valueIsPointer ? 1 : 0 ) |
  689.                 ( ((Byte)nBase) << 8 ) |
  690.                 ( ( digitsNum & 0x1F ) << 16 );
  691.         arg2 = ( x << 16 ) | y;
  692.         //
  693.         __asm{
  694.                 mov eax, 47
  695.                 mov ebx, arg1
  696.                 mov ecx, value
  697.                 mov edx, arg2
  698.                 mov esi, colour
  699.                 int 0x40
  700.         }
  701. }
  702.  
  703. // ôóíêöèÿ 70 äîñòóï ê ôàéëîâîé ñèñòåìå
  704. Dword kos_FileSystemAccess( kosFileInfo *fileInfo )
  705. {
  706. //      Dword result;
  707.  
  708.         //
  709.         __asm{
  710.                 mov eax, 70
  711.                 mov ebx, fileInfo
  712.                 int 0x40
  713. //              mov result, eax
  714.         }
  715.         //
  716. //      return result;
  717. }
  718.  
  719.  
  720. // ôóíêöèÿ 63 âûâîä ñèìâîëÿ â îêíî îòëàäêè
  721. void kos_DebugOutChar( char ccc )
  722. {
  723.         //
  724.         __asm{
  725.                 mov eax, 63
  726.                 mov ebx, 1
  727.                 mov cl, ccc
  728.                 int 0x40
  729.         }
  730. }
  731.  
  732.  
  733. // ôóíêöèÿ 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
  734. void kos_SetKeyboardDataMode( Dword mode )
  735. {
  736.         //
  737.         __asm{
  738.                 mov eax, 66
  739.                 mov ebx, 1
  740.                 mov ecx, mode
  741.                 int 0x40
  742.         }
  743. }
  744.  
  745.  
  746. // âûâîä ñòðîêè â îêíî îòëàäêè
  747. void rtlDebugOutString( char *str )
  748. {
  749.         //
  750.         for ( ; str[0] != 0; str++ )
  751.         {
  752.                 kos_DebugOutChar( str[0] );
  753.         }
  754.         //
  755.         kos_DebugOutChar( 13 );
  756.         kos_DebugOutChar( 10 );
  757. }
  758.  
  759.  
  760. // ôóíêöèÿ 64 èçìåíåíèå êîëè÷åñòâà ïàìÿòè, âûäåëåííîé äëÿ ïðîãðàììû
  761. bool kos_ApplicationMemoryResize( Dword targetSize )
  762. {
  763.         Dword result;
  764.  
  765.         //
  766.         __asm{
  767.                 mov eax, 64
  768.                 mov ebx, 1
  769.                 mov ecx, targetSize
  770.                 int 0x40
  771.                 mov result, eax
  772.         }
  773.         //
  774.         return result == 0;
  775. }
  776.  
  777.  
  778. // ôóíêöèÿ 67 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ
  779. void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY )
  780. {
  781.         //
  782.         __asm{
  783.                 mov eax, 67
  784.                 mov ebx, x
  785.                 mov ecx, y
  786.                 mov edx, sizeX
  787.                 mov esi, sizeY
  788.                 int 0x40
  789.         }
  790. }
  791.  
  792.  
  793.  
  794. // âûçîâ àáñòðàêòíîãî ìåòîäà
  795. int __cdecl _purecall()
  796. {
  797.         rtlDebugOutString( pureCallMessage );
  798.         kos_ExitApp();
  799.         return 0;
  800. }
  801.  
  802.  
  803. // âûçîâ ñòàòè÷åñêèõ èíèöèàëèçàòîðîâ
  804. // çàîäíî èíèöèàëèçàöèÿ ãåíåðàòîðà ñëó÷àéíûõ ÷èñåë
  805. //#pragma section(".CRT$XCA",long,read,write)
  806. //#pragma section(".CRT$XCZ",long,read,write)
  807. #pragma data_seg(".CRT$XCA")
  808. #pragma data_seg(".CRT$XCZ")
  809. typedef void (__cdecl *_PVFV)(void);
  810. __declspec(allocate(".CRT$XCA"))  _PVFV __xc_a[1] = { NULL };
  811. __declspec(allocate(".CRT$XCZ"))  _PVFV __xc_z[1] = { NULL };
  812. //
  813. #pragma comment(linker, "/merge:.CRT=.rdata")
  814. //
  815. void crtStartUp()
  816. {
  817.         // âûçûâàåì èíèöèàëèçàòîðû ïî ñïèñêó, NULL'û èãíîðèðóåì
  818.         for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ )
  819.         {
  820.                 //
  821.                 if ( *pbegin != NULL )
  822.                         (**pbegin)();
  823.         }
  824.         // èíèöèàëèçèðóåì ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
  825.         rtlSrand( kos_GetSystemClock() );
  826.         // ïóòü ê ôàéëó ïðîöåññà
  827.         kosExePath = *((char **)0x20);
  828.         // âûçîâ ãëàâíîé ôóíêöèè ïðèëîæåíèÿ
  829.         kos_Main();
  830.         // âûõîä
  831.         kos_ExitApp();
  832. }
  833.  
  834.  
  835.