Subversion Repositories Kolibri OS

Rev

Rev 5114 | Rev 7482 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1805 yogev_ezra 1
#include "kosSyst.h"
2
#include 
3
 
4
#define atexitBufferSize	32
5
 
5114 clevermous 6
// Autobuild uses FASM method for exe->kos,
7
// MENUET01 header should be present in EXE.
8
#ifdef AUTOBUILD
9
char kosExePath[1024];
10
char exeStack[16384];
11
// must be alphabetically first in the image
12
#pragma data_seg(".1seg")
13
extern "C" struct
14
{
15
	char header[8];
16
	int headerver;
17
	void* entry;
18
	void* i_end;
19
	void* memsize;
20
	void* stack;
21
	void* params;
22
	void* icon;
23
} header = {
24
	{'M', 'E', 'N', 'U', 'E', 'T', '0', '1'},
25
	1,
26
	&crtStartUp,
27
	0,	// filled by doexe2.asm
28
	0,	// filled by doexe2.asm
29
	exeStack + sizeof(exeStack),
30
	NULL,
31
	kosExePath
32
};
33
#pragma data_seg()
34
#else
35
char *kosExePath = NULL;
36
#endif
1805 yogev_ezra 37
 
38
char pureCallMessage[] = "PURE function call!";
39
 
40
//
41
void (__cdecl *atExitList[atexitBufferSize])();
42
int atExitFnNum = 0;
43
//
44
int __cdecl atexit( void (__cdecl *func )( void ))
45
{
46
	//
47
	if ( atExitFnNum < atexitBufferSize )
48
	{
49
		//
50
		atExitList[atExitFnNum++] = func;
51
		return 0;
52
	}
53
	else
54
	{
55
		return 1;
56
	}
57
}
58
 
59
 
60
//
61
Dword RandomSeed = 1;
62
//
63
void rtlSrand( Dword seed )
64
{
65
	RandomSeed = seed;
66
}
67
//
68
Dword rtlRand( void )
69
{
70
  //маска 0x80000776
71
 
72
  Dword dwi, i;
73
 
74
  for ( i = 0; i < 32; i++ )
75
  {
76
 
77
    dwi = RandomSeed & 0x80000776;
78
 
79
      __asm{
80
            mov   eax, dwi
81
            mov   edx, eax
82
            bswap eax
83
            xor   eax, edx
84
            xor   al, ah
85
            setpo al
86
            movzx eax, al
87
            mov   dwi, eax
88
    }
89
 
90
    RandomSeed = ( RandomSeed << 1 ) | ( dwi & 1 );
91
  }
92
 
93
 return RandomSeed;
94
}
95
 
96
//
97
void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount )
98
{
99
	__asm{
100
		mov edi, dst
101
		mov eax, dst
102
		mov esi, src
103
		mov ecx, bytesCount
104
		rep movsb
105
	}
106
}
107
 
108
//
109
void memset( Byte *dst, Byte filler, Dword count )
110
{
111
	//
112
	__asm{
113
		mov edi, dst
114
		mov al, filler
115
		mov ecx, count
116
		rep stosb
117
	}
118
}
119
 
120
//
121
Dword rtlInterlockedExchange( Dword *target, Dword value )
122
{
123
//	Dword result;
124
 
125
	//
126
	__asm{
127
		mov eax, value
128
		mov ebx, target
129
		xchg eax, [ebx]
130
//		mov result, eax
131
	}
132
	//
133
//	return result;
134
}
135
 
136
 
137
//////////////////////////////////////////////////////////////////////
138
//
139
// копирование строки
140
//
141
 
142
char * __cdecl strcpy( char *target, const char *source )
143
{
144
	char *result = target;
145
 
146
	while( target[0] = source[0] )
147
	{
148
		target++;
149
		source++;
150
	}
151
 
152
	return result;
153
}
154
 
155
 
156
//////////////////////////////////////////////////////////////////////
157
//
158
// реверсивный поиск символа
159
//
160
 
161
char * __cdecl strrchr( const char * string, int c )
162
{
163
	char *cPtr;
164
 
165
	//
166
	for ( cPtr = (char *)string + strlen( string ); cPtr >= string; cPtr-- )
167
	{
168
		//
169
		if ( *cPtr == c ) return cPtr;
170
	}
171
	//
172
	return NULL;
173
}
174
 
175
 
176
//////////////////////////////////////////////////////////////////////
177
//
178
// определение длины строки
179
//
180
 
181
int __cdecl strlen( const char *line )
182
{
183
  int i;
184
 
185
  for( i=0; line[i] != 0; i++ );
186
  return i;
187
}
188
 
189
 
190
 
191
//////////////////////////////////////////////////////////////////////
192
//
193
// перевод шестнадцатиричного числа в символ
194
//
195
 
196
unsigned int num2hex( unsigned int num )
197
{
198
  if( num < 10 )
199
    return num + '0';
200
  return num - 10 + 'A';
201
}
202
 
203
 
204
//////////////////////////////////////////////////////////////////////
205
//
206
// вывод строки на печать
207
//
208
 
209
Dword dectab[] = { 1000000000, 100000000, 10000000, 1000000, 100000,
210
                   10000, 1000, 100, 10, 0 };
211
 
212
//
213
void sprintf( char *Str, char* Format, ... )
214
{
215
	int i, fmtlinesize, j, k, flag;
216
	Dword head, tail;
217
	char c;
218
	va_list arglist;
219
	//
220
	va_start(arglist, Format);
221
 
222
	//
223
	fmtlinesize = strlen( Format );
224
	//
225
	if( fmtlinesize == 0 ) return;
226
 
227
	//
228
	for( i = 0, j = 0; i < fmtlinesize; i++ )
229
	{
230
		//
231
		c = Format[i];
232
		//
233
		if( c != '%' )
234
		{
235
			Str[j++] = c;
236
			continue;
237
		}
238
		//
239
		i++;
240
		//
241
		if( i >= fmtlinesize ) break;
242
 
243
		//
244
		flag = 0;
245
		//
246
		c = Format[i];
247
		//
248
		switch( c )
249
		{
250
		//
251
		case '%':
252
			Str[j++] = c;
253
			break;
254
		// вывод строки
255
		case 'S':
256
			Byte* str;
257
			str = va_arg(arglist, Byte*);
258
			for( k = 0; ( c = str[k] ) != 0; k++ )
259
			{
260
				Str[j++] = c;
261
			}
262
			break;
263
		// вывод байта
264
		case 'B':
265
			k = va_arg(arglist, int) & 0xFF;
266
			Str[j++] = num2hex( ( k >> 4 ) & 0xF );
267
			Str[j++] = num2hex( k & 0xF );
268
			break;
269
		// вывод символа
270
		case 'C':
271
			Str[j++] = va_arg(arglist, int) & 0xFF;
272
			break;
273
		// вывод двойного слова в шестнадцатиричном виде
274
		case 'X':
275
			Dword val;
276
			val = va_arg(arglist, Dword);
277
			for( k = 7; k >= 0; k-- )
278
			{
279
				//
280
				c = num2hex ( ( val >> (k * 4) ) & 0xF );
281
				//
282
				if( c == '0' )
283
				{
284
					if( flag ) Str[j++] = c;
285
				}
286
				else
287
				{
288
					flag++;
289
					Str[j++] = c;
290
				}
291
			}
292
			//
293
			if( flag == 0 ) Str[j++] = '0';
294
			break;
295
		// вывод двойного слова в десятичном виде
296
		case 'U':
297
			head = va_arg(arglist, Dword);
298
			tail = 0;
299
			for( k = 0; dectab[k] != 0; k++ )
300
			{
301
				tail = head % dectab[k];
302
				head /= dectab[k];
303
				c = head + '0';
304
				if( c == '0' )
305
				{
306
					if( flag ) Str[j++] = c;
307
				}
308
				else
309
				{
310
					flag++;
311
					Str[j++] = c;
312
				}
313
				//
314
				head = tail;
315
			}
316
			//
317
			c = head + '0';
318
			Str[j++] = c;
319
			break;
320
		// вывод 64-битного слова в шестнадцатиричном виде
321
		case 'Q':
322
			unsigned int low_dword, high_dword;
323
			low_dword = va_arg(arglist, unsigned int);
324
			high_dword = va_arg(arglist, unsigned int);
325
			for( k = 7; k >= 0; k-- )
326
			{
327
				//
328
				c = num2hex ( ( ( high_dword + 1) >> (k * 4) ) & 0xF );
329
				//
330
				if( c == '0' )
331
				{
332
					if( flag ) Str[j++] = c;
333
				}
334
				else
335
				{
336
					flag++;
337
					Str[j++] = c;
338
				}
339
			}
340
			//
341
			for( k=7; k >= 0; k-- )
342
			{
343
				//
344
				c = num2hex ( ( low_dword >> (k * 4) ) & 0xF );
345
				//
346
				if( c == '0' )
347
				{
348
					if( flag ) Str[j++] = c;
349
				}
350
				else
351
				{
352
					flag++;
353
					Str[j++] = c;
354
				}
355
			}
356
			//
357
			if( flag == 0 ) Str[j++] = '0';
358
			//
359
			break;
360
		//
361
		default:
362
			break;
363
		}
364
	}
365
	//
366
	Str[j] = 0;
367
}
368
 
369
 
370
// функция -1 завершения процесса
371
void kos_ExitApp()
372
{
373
	int i;
374
 
375
	//
376
	for ( i = atExitFnNum - 1; i >= 0; i-- )
377
	{
378
		//
379
		atExitList[i]();
380
	}
381
	//
382
	__asm{
383
		mov eax, -1
384
		int 0x40
385
	}
386
}
387
 
388
 
389
// функция 0
390
void kos_DefineAndDrawWindow(
391
	Word x, Word y,
392
	Word sizeX, Word sizeY,
393
	Byte mainAreaType,
394
	Dword mainAreaColour,
395
	Byte headerType,
396
	Dword headerColour,
397
	Dword borderColour
398
	)
399
{
400
	Dword arg1, arg2, arg3, arg4;
401
 
402
	//
403
	arg1 = ( x << 16 ) + sizeX;
404
	arg2 = ( y << 16 ) + sizeY;
405
	arg3 = ( mainAreaType << 24 ) | mainAreaColour;
406
	arg4 = ( headerType << 24 ) | headerColour;
407
	//
408
	__asm{
409
		mov eax, 0
410
		mov ebx, arg1
411
		mov ecx, arg2
412
		mov edx, arg3
413
		mov esi, arg4
414
		mov edi, borderColour
415
		int 0x40
416
	}
417
}
418
 
419
 
420
// функция 1 поставить точку
421
void kos_PutPixel( Dword x, Dword y, Dword colour )
422
{
423
	//
424
	__asm{
425
		mov eax, 1
426
		mov ebx, x
427
		mov ecx, y
428
		mov edx, colour
429
		int 0x40
430
	}
431
}
432
 
433
 
434
// функция 2 получить код нажатой клавиши
435
bool kos_GetKey( Byte &keyCode )
436
{
437
	Dword result;
438
 
439
	//
440
	__asm{
441
		mov eax, 2
442
		int 0x40
443
		mov result, eax
444
	}
445
	//
446
	keyCode = result >> 8;
447
	//
448
	return ( result & 0xFF ) == 0;
449
}
450
 
451
 
452
// функция 3 получить время
453
Dword kos_GetSystemClock()
454
{
455
//	Dword result;
456
 
457
	//
458
	__asm{
459
		mov eax, 3
460
		int 0x40
461
//		mov result, eax
462
	}
463
	//
464
//	return result;
465
}
466
 
467
 
468
// функция 4
469
void kos_WriteTextToWindow(
470
	Word x,
471
	Word y,
472
	Byte fontType,
473
	Dword textColour,
474
	char *textPtr,
475
	Dword textLen
476
	)
477
{
478
	Dword arg1, arg2;
479
 
480
	//
481
	arg1 = ( x << 16 ) | y;
482
	arg2 = ( fontType << 24 ) | textColour;
483
	//
484
	__asm{
485
		mov eax, 4
486
		mov ebx, arg1
487
		mov ecx, arg2
488
		mov edx, textPtr
489
		mov esi, textLen
490
		int 0x40
491
	}
492
}
493
 
494
 
495
// функция 5 пауза, в сотых долях секунды
496
void kos_Pause( Dword value )
497
{
498
	//
499
	__asm{
500
		mov eax, 5
501
		mov ebx, value
502
		int 0x40
503
	}
504
}
505
 
506
 
507
// функция 7 нарисовать изображение
508
void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y )
509
{
510
	Dword arg1, arg2;
511
 
512
	//
513
	arg1 = ( sizeX << 16 ) | sizeY;
514
	arg2 = ( x << 16 ) | y;
515
	//
516
	__asm{
517
		mov eax, 7
518
		mov ebx, imagePtr
519
		mov ecx, arg1
520
		mov edx, arg2
521
		int 0x40
522
	}
523
}
524
 
525
 
526
 
527
// функция 8 определить кнопку
528
void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour )
529
{
530
	Dword arg1, arg2;
531
 
532
	//
533
	arg1 = ( x << 16 ) | sizeX;
534
	arg2 = ( y << 16 ) | sizeY;
535
	//
536
	__asm{
537
		mov eax, 8
538
		mov ebx, arg1
539
		mov ecx, arg2
540
		mov edx, buttonID
541
		mov esi, colour
542
		int 0x40
543
	}
544
}
545
 
546
 
547
// функция 9 - информация о процессе
548
Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID )
549
{
550
//	Dword result;
551
 
552
	//
553
	__asm{
554
		mov eax, 9
555
		mov ebx, targetPtr
556
		mov ecx, processID
557
		int 0x40
558
//		mov result, eax
559
	}
560
	//
561
//	return result;
562
}
563
 
564
 
565
// функция 10
566
Dword kos_WaitForEvent()
567
{
568
//	Dword result;
569
 
570
	__asm{
571
		mov eax, 10
572
		int 0x40
573
//		mov result, eax
574
	}
575
 
576
//	return result;
577
}
578
 
579
 
580
// функция 11
581
Dword kos_CheckForEvent()
582
{
583
//	Dword result;
584
 
585
	__asm{
586
		mov eax, 11
587
		int 0x40
588
//		mov result, eax
589
	}
590
 
591
//	return result;
592
}
593
 
594
 
595
// функция 12
596
void kos_WindowRedrawStatus( Dword status )
597
{
598
	__asm{
599
		mov eax, 12
600
		mov ebx, status
601
		int 0x40
602
	}
603
}
604
 
605
 
606
// функция 13 нарисовать полосу
607
void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour )
608
{
609
	Dword arg1, arg2;
610
 
611
	//
612
	arg1 = ( x << 16 ) | sizeX;
613
	arg2 = ( y << 16 ) | sizeY;
614
	//
615
	__asm{
616
		mov eax, 13
617
		mov ebx, arg1
618
		mov ecx, arg2
619
		mov edx, colour
620
		int 0x40
621
	}
622
}
623
 
624
 
625
// функция 17
626
bool kos_GetButtonID( Dword &buttonID )
627
{
628
	Dword result;
629
 
630
	//
631
	__asm{
632
		mov eax, 17
633
		int 0x40
634
		mov result, eax
635
	}
636
	//
637
	buttonID = result >> 8;
638
	//
639
	return (result & 0xFF) == 0;
640
}
641
 
642
 
643
// функция 23
644
Dword kos_WaitForEvent( Dword timeOut )
645
{
646
//	Dword result;
647
 
648
	__asm{
649
		mov eax, 23
650
		mov ebx, timeOut
651
		int 0x40
652
//		mov result, eax
653
	}
654
 
655
//	return result;
656
}
657
 
658
// функция 26.9 получить значение счётчика времени
659
Dword kos_GetTime()
660
{
661
	__asm{
662
		mov eax, 26
663
		mov ebx, 9
664
		int 0x40
665
	}
666
}
667
 
668
// функция 37 получение информации о состоянии "мыши"
669
void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY )
670
{
671
	Dword mB;
672
	Word curX;
673
	Word curY;
674
	sProcessInfo sPI;
675
 
676
	//
677
	__asm{
678
		mov		eax, 37
679
		mov		ebx, 0
680
		int		0x40
681
		mov		curY, ax
682
		shr		eax, 16
683
		mov		curX, ax
684
		mov		eax, 37
685
		mov		ebx, 2
686
		int		0x40
687
		mov		mB, eax
688
	}
689
	//
690
	kos_ProcessInfo( &sPI );
691
	//
692
	buttons = mB;
693
	cursorX = curX - sPI.processInfo.x_start;
694
	cursorY = curY - sPI.processInfo.y_start;
695
}
696
 
697
// функция 37.1 получение координат "мыши" относительно окна
698
void kos_GetMouseWindowXY( int & cursorX, int & cursorY )
699
{
700
	Word curX;
701
	Word curY;
702
 
703
	__asm{
704
		mov eax, 37
705
		mov ebx, 1
706
		int 0x40
707
 
708
		mov ebx, eax
709
		shr eax, 16
710
		and ebx, 0xffff
711
 
712
		mov curX, ax
713
		mov curY, bx
714
	}
715
 
716
	cursorX = curX;
717
	cursorY = curY;
718
}
719
 
720
// функция 37.2 получение информации о нажатых кнопки "мыши"
721
void kos_GetMouseButtonsState( Dword & buttons )
722
{
723
	Dword mB;
724
 
725
	__asm{
726
		mov		eax, 37
727
		mov		ebx, 2
728
		int		0x40
729
		mov		mB, eax
730
	}
731
 
732
	buttons = mB;
733
}
734
 
735
// функция 37.4 загрузка курсора "мыши"
736
Dword * kos_LoadMouseCursor( Dword * cursor, Dword loadstate )
737
{
738
	//Dword handle;
739
	__asm{
740
		mov		eax, 37
741
		mov		ebx, 4
742
		mov		edx, loadstate
743
		mov		ecx, cursor
744
		int		0x40
745
		//mov		handle, eax
746
	}
747
	//return handle;
748
}
749
 
750
// функция 37.5 установка курсора "мыши"
751
Dword * kos_SetMouseCursor( Dword * handle )
752
{
753
	//Dword handle;
754
	__asm{
755
		mov		eax, 37
756
		mov		ebx, 5
757
		mov		ecx, handle
758
		int		0x40
759
		//mov		handle, eax
760
	}
761
	//return handle;
762
}
763
 
764
// функция 37.6 удаление курсора "мыши"
765
void kos_DeleteMouseCursor( Dword * handle )
766
{
767
	__asm{
768
		mov		eax, 37
769
		mov		ebx, 6
770
		mov		ecx, handle
771
		int		0x40
772
	}
773
}
774
 
7481 leency 775
// 48.4 get windows title bar height
776
Dword kos_GetSkinHeight( Dword * handle )
777
{
778
	__asm{
779
		mov		eax, 48
780
		mov		ebx, 4
781
		int		0x40
782
	}
783
}
784
 
1805 yogev_ezra 785
// функция 38 нарисовать полосу
786
void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour )
787
{
788
	Dword arg1, arg2;
789
 
790
	//
791
	arg1 = ( x1 << 16 ) | x2;
792
	arg2 = ( y1 << 16 ) | y2;
793
	//
794
	__asm{
795
		mov eax, 38
796
		mov ebx, arg1
797
		mov ecx, arg2
798
		mov edx, colour
799
		int 0x40
800
	}
801
}
802
 
803
 
804
// функция 40 установить маску событий
805
void kos_SetMaskForEvents( Dword mask )
806
{
807
	//
808
	__asm{
809
		mov eax, 40
810
		mov ebx, mask
811
		int 0x40
812
	}
813
}
814
 
815
 
816
// функция 47 вывести в окно приложения число
817
void kos_DisplayNumberToWindow(
818
   Dword value,
819
   Dword digitsNum,
820
   Word x,
821
   Word y,
822
   Dword colour,
823
   eNumberBase nBase,
824
   bool valueIsPointer
825
   )
826
{
827
	Dword arg1, arg2;
828
 
829
	//
830
	arg1 = ( valueIsPointer ? 1 : 0 ) |
831
		( ((Byte)nBase) << 8 ) |
832
		( ( digitsNum & 0x1F ) << 16 );
833
	arg2 = ( x << 16 ) | y;
834
	//
835
	__asm{
836
		mov eax, 47
837
		mov ebx, arg1
838
		mov ecx, value
839
		mov edx, arg2
840
		mov esi, colour
841
		int 0x40
842
	}
843
}
844
 
845
// функция 47 вывести в окно приложения число c фоном
846
void kos_DisplayNumberToWindowBg(
847
   Dword value,
848
   Dword digitsNum,
849
   Word x,
850
   Word y,
851
   Dword colour,
852
   Dword bgcolour,
853
   eNumberBase nBase,
854
   bool valueIsPointer
855
   )
856
{
857
	Dword arg1, arg2;
858
 
859
	//
860
	arg1 = ( valueIsPointer ? 1 : 0 ) |
861
		( ((Byte)nBase) << 8 ) |
862
		( ( digitsNum & 0x1F ) << 16 );
863
	arg2 = ( x << 16 ) | y;
864
	//
865
	__asm{
866
		mov eax, 47
867
		mov ebx, arg1
868
		mov ecx, value
869
		mov edx, arg2
870
		mov esi, colour
871
		or	esi, 0x40000000
872
		mov edi, bgcolour
873
		int 0x40
874
	}
875
}
876
 
877
 
878
// функция 70 доступ к файловой системе
879
Dword kos_FileSystemAccess( kosFileInfo *fileInfo )
880
{
881
//	Dword result;
882
 
883
	//
884
	__asm{
885
		mov eax, 70
886
		mov ebx, fileInfo
887
		int 0x40
888
//		mov result, eax
889
	}
890
	//
891
//	return result;
892
}
893
 
894
 
895
// функция 63 вывод символя в окно отладки
896
void kos_DebugOutChar( char ccc )
897
{
898
	//
899
	__asm{
900
		mov eax, 63
901
		mov ebx, 1
902
		mov cl, ccc
903
		int 0x40
904
	}
905
}
906
 
907
 
908
// функция 66 режим получения данных от клавиатуры
909
void kos_SetKeyboardDataMode( Dword mode )
910
{
911
	//
912
	__asm{
913
		mov eax, 66
914
		mov ebx, 1
915
		mov ecx, mode
916
		int 0x40
917
	}
918
}
919
 
920
 
921
// вывод строки в окно отладки
922
void rtlDebugOutString( char *str )
923
{
924
	//
925
	for ( ; str[0] != 0; str++ )
926
	{
927
		kos_DebugOutChar( str[0] );
928
	}
929
	//
930
	kos_DebugOutChar( 13 );
931
	kos_DebugOutChar( 10 );
932
}
933
 
934
 
935
// функция 64 изменение количества памяти, выделенной для программы
936
bool kos_ApplicationMemoryResize( Dword targetSize )
937
{
938
	Dword result;
939
 
940
	//
941
	__asm{
942
		mov eax, 64
943
		mov ebx, 1
944
		mov ecx, targetSize
945
		int 0x40
946
		mov result, eax
947
	}
948
	//
949
	return result == 0;
950
}
951
 
952
 
953
// функция 67 изменить параметры окна, параметр == -1 не меняется
954
void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY )
955
{
956
	//
957
	__asm{
958
		mov eax, 67
959
		mov ebx, x
960
		mov ecx, y
961
		mov edx, sizeX
962
		mov esi, sizeY
963
		int 0x40
964
	}
965
}
966
 
967
 
968
 
969
// вызов абстрактного метода
970
int __cdecl _purecall()
971
{
972
	rtlDebugOutString( pureCallMessage );
973
	kos_ExitApp();
974
	return 0;
975
}
976
 
977
 
978
// вызов статических инициализаторов
979
// заодно инициализация генератора случайных чисел
980
//#pragma section(".CRT$XCA",long,read,write)
981
//#pragma section(".CRT$XCZ",long,read,write)
982
#pragma data_seg(".CRT$XCA")
983
#pragma data_seg(".CRT$XCZ")
984
typedef void (__cdecl *_PVFV)(void);
985
__declspec(allocate(".CRT$XCA"))  _PVFV __xc_a[1] = { NULL };
986
__declspec(allocate(".CRT$XCZ"))  _PVFV __xc_z[1] = { NULL };
987
//
988
#pragma comment(linker, "/merge:.CRT=.rdata")
989
//
990
void crtStartUp()
991
{
5114 clevermous 992
#ifdef AUTOBUILD
993
// linker will try to remove unused variables; force header to be included
994
	header.header;
995
#endif
1805 yogev_ezra 996
	// вызываем инициализаторы по списку, NULL'ы игнорируем
997
	for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ )
998
	{
999
		//
1000
		if ( *pbegin != NULL )
1001
			(**pbegin)();
1002
	}
1003
	// инициализируем генератор случайных чисел
1004
	rtlSrand( kos_GetSystemClock() );
5114 clevermous 1005
#ifndef AUTOBUILD
1805 yogev_ezra 1006
	// путь к файлу процесса
1007
	kosExePath = *((char **)0x20);
5114 clevermous 1008
#endif
1805 yogev_ezra 1009
	// вызов главной функции приложения
1010
	kos_Main();
1011
	// выход
1012
	kos_ExitApp();
1013
}
1014