Subversion Repositories Kolibri OS

Rev

Rev 5114 | Rev 7482 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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