Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

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