Subversion Repositories Kolibri OS

Rev

Rev 990 | Rev 7503 | Go to most recent revision | Details | Compare with Previous | 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 *memcpy2(void *dst, const void *src, unsigned size)
237
 
7495 leency 238
	while (size--)
990 barsuk 239
		*((char*)dst+size) = *((char*)src+size);
240
	return dst;
241
}
242
*/
243
244
7495 leency 245
 
246
 
247
 
990 barsuk 248
	int i;
249
250
	if (s1 == NULL)
251
 
252
			return 0;
253
		else
254
			return 1;
255
	else
256
		if (s2 == NULL)
257
			return 1;
258
259
	for (i = 0;;i++)
260
 
261
		if (s1[i] == '\0')
262
			if (s2[i] == '\0')
263
				return 0;
264
			else
265
				return 1;
266
		else
267
			if (s2[i] == '\0')
268
				return 1;
269
			else
270
			{
271
				if (s1[i] != s2[i])
272
					return 1;
273
			}
274
	}
275
	return 0;
276
}
277
278
kol_struct_import* kol_cofflib_load(char *name)
279
 
280
//asm ("int $0x40"::"a"(68), "b"(19), "c"(name));
281
	__asm
282
	{
283
		mov eax, 68
284
		mov ebx, 19
285
		mov ecx, name
286
		int 0x40
287
	}
288
}
289
290
291
 
292
 
293
294
int i;
295
 
296
	if ( NULL == ((imp+i) -> name))
297
		break;
298
	else
299
		if ( 0 == strcmp(name, (imp+i)->name) )
300
			return (imp+i)->data;
301
return NULL;
302
303
}
304
 
305
306
 
307
 
308
309
unsigned i, n;
310
 
311
for (i=n=0;;i++)
312
 
313
		break;
314
	else
315
		n++;
316
317
return n;
318
 
319
}
320
 
321
322
 
323
 
324
325
unsigned i;
326
 
327
328
for (i=0;;i++)
329
 
330
		break;
331
	else
332
		if ( i == n )
333
			{
334
			strcpy(name, ((imp+i)->name));
335
			break;
336
			}
337
338
}
339
 
340
341
 
342
 
343
 
344
*/
345
346
347
 
348
 
349
{
350
	kos_DrawLine(x1,y1,x2,y2,SysColor,0);
351
}
352
353
void outtextxy( int x, int y, char *s, int len)
354
 
355
	kos_WriteTextToWindow(x,y,0,SysColor,s,len);
356
}
357
358
double textwidth( char *s, int len)
359
 
360
	int i;
361
	for (i = 0; i < len; i++)
362
		if (s[i] == 0)
363
			break;
364
	return id(i * 6);
365
}
366
367
double textheight( char *s, int len)
368
 
369
	return 8.0;
370
}
371
372
void setcolor( DWORD color)
373
 
374
	SysColor = color;
375
}
376
377
void rectangle( int x1, int y1, int x2, int y2)
378
 
379
	kos_DrawBar(x1,y1,x2-x1,y2-y1,SysColor);
380
}
381
382
383
 
384
 
385
 
386
	__asm{
387
		mov		eax, 48
388
		mov		ebx, 4
389
		int		0x40
390
	}
391
}
392
393
Dword kos_GetSpecialKeyState()
394
 
395
	__asm{
396
		mov		eax, 66
397
		mov		ebx, 3
398
		int		0x40
399
	}
400
}
401
402
403
 
404
 
405
 
406
	__asm
407
	{
408
		push ebx
409
		push ecx
410
		mov eax, 18
411
		mov ebx, 21
412
		mov ecx, PID
413
		int	0x40
414
		pop ecx
415
		pop ebx
416
	}
417
}
418
419
420
 
421
 
422
	__asm
423
	{
424
		push ebx
425
		mov eax, 18
426
		mov ebx, 7
427
		int	0x40
428
		pop ebx
429
	}
430
}
431
432
433
 
434
 
435
 
436
	short v, h;
437
	__asm
438
	{
439
		mov eax, 37
440
		mov ebx, 7
441
		int	0x40
442
		mov ebx, eax
443
		and eax, 0xffff
444
		mov v, ax
445
		shr ebx, 16
446
		mov h, bx
447
	}
448
	vert = v;
449
	hor = h;
450
}
451
452
453
 
454
 
455
{
456
	Dword mB;
457
	Word curX;
458
	Word curY;
459
	sProcessInfo sPI;
460
461
	//
462
 
463
		mov		eax, 37
464
		mov		ebx, 1
465
		int		0x40
466
		mov		curY, ax
467
		shr		eax, 16
468
		mov		curX, ax
469
		mov		eax, 37
470
		mov		ebx, 2
471
		int		0x40
472
		mov		mB, eax
473
	}
474
	//
475
	kos_ProcessInfo( &sPI );
476
	//
477
	buttons = mB;
478
	cursorX = curX - sPI.processInfo.x_start;
479
	cursorY = curY - sPI.processInfo.y_start;
480
}
481
482
char *ftoa(double d)
483
 
484
	char buffer[256], *p;
485
	sprintf(buffer, "%f", d);
486
	p = (char*)allocmem(strlen(buffer)+1);
487
	strcpy(p, buffer);
488
	return p;
489
}
490
491
double atof(char *s)
492
 
493
	return convert(s, NULL);
494
}
495
496
497
 
498
 
499
	int a;
500
	__asm fld x
501
	__asm fistp a
502
	return a;
503
}
504
505
double id(int x)
506
 
507
	double a;
508
	__asm fild x
509
	__asm fstp a
510
	return a;
511
}
512
}*/
513