Subversion Repositories Kolibri OS

Rev

Rev 7495 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
990 barsuk 1
 
2
 
3
int convert_error = 0;
4
 
5
char debuf[50] = "";
6
7
8
 
9
 
10
{
11
	Dword arg1, arg2, arg3;
12
13
	//
14
 
15
	arg2 = ( y1 << 16 ) | y2;
16
	arg3 = (invert)?0x01000000:colour;
17
	//
18
	__asm{
19
		mov eax, 38
20
		mov ebx, arg1
21
		mov ecx, arg2
22
		mov edx, arg3
23
		int 0x40
24
	}
25
}
26
27
// похищено из библиотеки к C--
28
 
29
{
30
	kos_DrawBar(x,y,width,1,color1); //полоса гор сверху
31
	kos_DrawBar(x,y+height,width,1,color1); //полоса гор снизу
32
	kos_DrawBar(x,y,1,height,color1); //полоса верт слева
33
	kos_DrawBar(x+width,y,1,height+1,color1); //полоса верт справа
34
}
35
36
37
 
38
 
39
{
40
	int res=0;
41
	int sign=0;
42
	const char* ptr;
43
	for (ptr=string; *ptr && *ptr<=' ';ptr++);
44
	if (*ptr=='-') {sign=1;++ptr;}
45
	while (*ptr >= '0' && *ptr <= '9')
46
	{
47
		res = res*10 + *ptr++ - '0';
48
	}
49
	if (sign) res = -res;
50
	return res;
51
}
52
53
/*int abs(int n)
54
 
55
	return (n<0)?-n:n;
56
}*/
57
58
59
 
60
 
61
 
62
 
63
 
64
	__asm	fld	x
65
	__asm	fabs
66
}
67
#define M_PI       3.14159265358979323846
68
double cos(double x)
69
{
70
	__asm	fld	x
71
	__asm	fcos
72
}
73
double sin(double x)
74
{
75
	__asm	fld	x
76
	__asm	fsin
77
}
78
79
bool isalpha(char c)
80
 
81
	return (c==' ' || c=='\n' || c=='\t' || c=='\r');
82
}
83
84
// эта функция - велосипед. но проще было написать чем найти.
85
 
86
{
87
88
	int i;
89
 
90
91
 
92
 
93
	convert_error = 0;
94
 
95
	res = 0.0;
96
 
97
	i=0;
98
 
99
	if (len) *len=i;
100
	if (s[i] == '\0')
101
	{
102
		convert_error = ERROR_END;
103
		return 0.0;
104
	}
105
106
	sign=1.0;
107
 
108
	{
109
		sign=-1.0;
110
		i++;
111
	}
112
	while (s[i] && s[i] >= '0' && s[i] <= '9')
113
	{
114
		res *= 10.0;
115
		res += id(s[i] - '0');
116
		i++;
117
	}
118
	if (len) *len=i;
119
	if (!s[i] || isalpha(s[i]))
120
		return sign*res;
121
	if (s[i] != '.' && s[i] != ',')
122
	{
123
		convert_error = ERROR;
124
		return 0;
125
	}
126
	i++;
127
	if (len) *len=i;
128
	if (!s[i])
129
		return sign*res;
130
131
	div = 1.0;
132
 
133
	while (s[i] && s[i] >= '0' && s[i] <= '9')
134
	{
135
		tail *= 10.0;
136
		tail += id(s[i] - '0');
137
		div *= 10.0;
138
		i++;
139
	}
140
	res += tail/div;
141
	if (len) *len=i;
142
	return sign*res;
143
}
144
145
/*
146
 
147
148
double double_tab[]={1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15};
149
 
150
// это sprintf, умеющий форматировать _только_ вещественные числа (double) %f
151
 
152
{
153
	int i, fmtlinesize, j, k, flag;
154
	char c;
155
	va_list arglist;
156
	//
157
	va_start(arglist, Format);
158
159
	//
160
 
161
	//
162
	if( fmtlinesize == 0 ) return;
163
164
	for (i = 0; i < len; i++)
165
 
166
167
	//
168
 
169
	{
170
		//
171
		c = Format[i];
172
		//
173
		if( c != '%' )
174
		{
175
			Str[j++] = c;
176
			continue;
177
		}
178
		//
179
		i++;
180
		//
181
		if( i >= fmtlinesize ) break;
182
183
		//
184
 
185
		//
186
		c = Format[i];
187
		//
188
		switch( c )
189
		{
190
		//
191
		case '%':
192
			Str[j++] = c;
193
			break;
194
		// auaia aauanoaaiiiai ?enea
195
		case 'f':
196
			// ii?aaaeeou ?enei oeo? ai oi?ee
197
			double val, w;
198
			int p;
199
			val = va_arg(arglist, double);
200
			if (val < 0.0)
201
			{
202
				Str[j++] = '-';
203
				val = -val;
204
			}
205
			for (k = 0; k < 15; k++)
206
				if (val < double_tab[k])
207
					break;
208
209
			if (val < 1.0)
210
 
211
				Str[j++] = '0';
212
			}
213
214
			for (p = 1; p < k + 1; p++)
215
 
216
				Str[j++] = '0' + di(val / double_tab[k - p] - 0.499) % 10;
217
			}
218
			Str[j++] = '.';
219
			w = 0.1;
220
			for (p = 0; p < 2; p++)
221
			{
222
				val-=floor(val);
223
				Str[j++] = '0' + di(val / w - 0.499) % 10;
224
				w /= 10.0;
225
			}
226
227
		//
228
 
229
			break;
230
		}
231
	}
232
	//
233
	Str[j] = 0;
234
}
235
236
void *memcpy(void *dst, const void *src, unsigned size)
237
 
238
	while (size--)
239
		*((char*)dst+size) = *((char*)src+size);
240
	return dst;
241
}
242
*/
243
int strcmp(const char *s1, const char *s2)
244
{
245
	int i;
246
247
	if (s1 == NULL)
248
 
249
			return 0;
250
		else
251
			return 1;
252
	else
253
		if (s2 == NULL)
254
			return 1;
255
256
	for (i = 0;;i++)
257
 
258
		if (s1[i] == '\0')
259
			if (s2[i] == '\0')
260
				return 0;
261
			else
262
				return 1;
263
		else
264
			if (s2[i] == '\0')
265
				return 1;
266
			else
267
			{
268
				if (s1[i] != s2[i])
269
					return 1;
270
			}
271
	}
272
	return 0;
273
}
274
275
kol_struct_import* kol_cofflib_load(char *name)
276
 
277
//asm ("int $0x40"::"a"(68), "b"(19), "c"(name));
278
	__asm
279
	{
280
		mov eax, 68
281
		mov ebx, 19
282
		mov ecx, name
283
		int 0x40
284
	}
285
}
286
287
288
 
289
 
290
291
int i;
292
 
293
	if ( NULL == ((imp+i) -> name))
294
		break;
295
	else
296
		if ( 0 == strcmp(name, (imp+i)->name) )
297
			return (imp+i)->data;
298
return NULL;
299
300
}
301
 
302
303
 
304
 
305
306
unsigned i, n;
307
 
308
for (i=n=0;;i++)
309
 
310
		break;
311
	else
312
		n++;
313
314
return n;
315
 
316
}
317
 
318
319
 
320
 
321
322
unsigned i;
323
 
324
325
for (i=0;;i++)
326
 
327
		break;
328
	else
329
		if ( i == n )
330
			{
331
			strcpy(name, ((imp+i)->name));
332
			break;
333
			}
334
335
}
336
 
337
338
 
339
 
340
 
341
*/
342
343
344
 
345
 
346
{
347
	kos_DrawLine(x1,y1,x2,y2,SysColor,0);
348
}
349
350
void outtextxy( int x, int y, char *s, int len)
351
 
352
	kos_WriteTextToWindow(x,y,0,SysColor,s,len);
353
}
354
355
double textwidth( char *s, int len)
356
 
357
	int i;
358
	for (i = 0; i < len; i++)
359
		if (s[i] == 0)
360
			break;
361
	return id(i * 6);
362
}
363
364
double textheight( char *s, int len)
365
 
366
	return 8.0;
367
}
368
369
void setcolor( DWORD color)
370
 
371
	SysColor = color;
372
}
373
374
void rectangle( int x1, int y1, int x2, int y2)
375
 
376
	kos_DrawBar(x1,y1,x2-x1,y2-y1,SysColor);
377
}
378
379
380
 
381
 
382
 
383
	__asm{
384
		mov		eax, 48
385
		mov		ebx, 4
386
		int		0x40
387
	}
388
}
389
390
Dword kos_GetSpecialKeyState()
391
 
392
	__asm{
393
		mov		eax, 66
394
		mov		ebx, 3
395
		int		0x40
396
	}
397
}
398
399
400
 
401
 
402
 
403
	__asm
404
	{
405
		push ebx
406
		push ecx
407
		mov eax, 18
408
		mov ebx, 21
409
		mov ecx, PID
410
		int	0x40
411
		pop ecx
412
		pop ebx
413
	}
414
}
415
416
417
 
418
 
419
	__asm
420
	{
421
		push ebx
422
		mov eax, 18
423
		mov ebx, 7
424
		int	0x40
425
		pop ebx
426
	}
427
}
428
429
430
 
431
 
432
 
433
	short v, h;
434
	__asm
435
	{
436
		mov eax, 37
437
		mov ebx, 7
438
		int	0x40
439
		mov ebx, eax
440
		and eax, 0xffff
441
		mov v, ax
442
		shr ebx, 16
443
		mov h, bx
444
	}
445
	vert = v;
446
	hor = h;
447
}
448
449
450
 
451
 
452
{
453
	Dword mB;
454
	Word curX;
455
	Word curY;
456
	sProcessInfo sPI;
457
458
	//
459
 
460
		mov		eax, 37
461
		mov		ebx, 1
462
		int		0x40
463
		mov		curY, ax
464
		shr		eax, 16
465
		mov		curX, ax
466
		mov		eax, 37
467
		mov		ebx, 2
468
		int		0x40
469
		mov		mB, eax
470
	}
471
	//
472
	kos_ProcessInfo( &sPI );
473
	//
474
	buttons = mB;
475
	cursorX = curX - sPI.processInfo.x_start;
476
	cursorY = curY - sPI.processInfo.y_start;
477
}
478
479
char *ftoa(double d)
480
 
481
	char buffer[256], *p;
482
	sprintf(buffer, "%f", d);
483
	p = (char*)allocmem(strlen(buffer)+1);
484
	strcpy(p, buffer);
485
	return p;
486
}
487
488
double atof(char *s)
489
 
490
	return convert(s, NULL);
491
}
492
493
494
 
495
 
496
	int a;
497
	__asm fld x
498
	__asm fistp a
499
	return a;
500
}
501
502
double id(int x)
503
 
504
	double a;
505
	__asm fild x
506
	__asm fstp a
507
	return a;
508
}
509
}*/
510