Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1005 barsuk 1
 
2
 
3
int SysColor = 0;
4
 
5
6
// почему-то не было в стандартной библиотеке
7
 
8
{
9
	Dword arg1, arg2, arg3;
10
11
	//
12
 
13
	arg2 = ( y1 << 16 ) | y2;
14
	arg3 = (invert)?0x01000000:colour;
15
	//
16
	__asm{
17
		mov eax, 38
18
		mov ebx, arg1
19
		mov ecx, arg2
20
		mov edx, arg3
21
		int 0x40
22
	}
23
}
24
25
// похищено из библиотеки к C--
26
 
27
{
28
	kos_DrawBar(x,y,width,1,color1); //полоса гор сверху
29
	kos_DrawBar(x,y+height,width,1,color1); //полоса гор снизу
30
	kos_DrawBar(x,y,1,height,color1); //полоса верт слева
31
	kos_DrawBar(x+width,y,1,height+1,color1); //полоса верт справа
32
}
33
34
35
 
36
 
37
{
38
	int res=0;
39
	int sign=0;
40
	const char* ptr;
41
	for (ptr=string; *ptr && *ptr<=' ';ptr++);
42
	if (*ptr=='-') {sign=1;++ptr;}
43
	while (*ptr >= '0' && *ptr <= '9')
44
	{
45
		res = res*10 + *ptr++ - '0';
46
	}
47
	if (sign) res = -res;
48
	return res;
49
}
50
51
/*int abs(int n)
52
 
53
	return (n<0)?-n:n;
54
}*/
55
56
57
 
58
 
59
 
60
 
61
 
62
	__asm	fld	x
63
	__asm	fabs
64
}
65
#define M_PI       3.14159265358979323846
66
double cos(double x)
67
{
68
	__asm	fld	x
69
	__asm	fcos
70
}
71
double sin(double x)
72
{
73
	__asm	fld	x
74
	__asm	fsin
75
}
76
77
int di(double x)
78
 
79
	int a;
80
	__asm fld x
81
	__asm fistp a
82
	return a;
83
}
84
85
double id(int x)
86
 
87
	double a;
88
	__asm fild x
89
	__asm fstp a
90
	return a;
91
}
92
93
bool isalpha(char c)
94
 
95
	return (c==' ' || c=='\n' || c=='\t' || c=='\r');
96
}
97
98
// эта функция - велосипед. но проще было написать чем найти.
99
 
100
{
101
102
	int i;
103
 
104
105
 
106
 
107
	res = 0.0;
108
 
109
	i=0;
110
 
111
	if (len) *len=i;
112
	if (s[i] == '\0')
113
		return ERROR_END;
114
115
	sign=1.0;
116
 
117
	{
118
		sign=-1.0;
119
		i++;
120
	}
121
	while (s[i] && s[i] >= '0' && s[i] <= '9')
122
	{
123
		res *= 10.0;
124
		res += id(s[i] - '0');
125
		i++;
126
	}
127
	if (len) *len=i;
128
	if (!s[i] || isalpha(s[i]))
129
		return sign*res;
130
	if (s[i] != '.' && s[i] != ',')
131
		return ERROR;
132
	i++;
133
	if (len) *len=i;
134
	if (!s[i])
135
		return sign*res;
136
137
	div = 1.0;
138
 
139
	while (s[i] && s[i] >= '0' && s[i] <= '9')
140
	{
141
		tail *= 10.0;
142
		tail += id(s[i] - '0');
143
		div *= 10.0;
144
		i++;
145
	}
146
	res += tail/div;
147
	if (len) *len=i;
148
	return sign*res;
149
}
150
151
152
 
153
 
154
 
155
double double_tab[]={1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15};
156
 
157
// это sprintf, умеющий форматировать _только_ вещественные числа (double) %f
158
 
159
{
160
	int i, fmtlinesize, j, k, flag;
161
	char c;
162
	va_list arglist;
163
	//
164
	va_start(arglist, Format);
165
166
	//
167
 
168
	//
169
	if( fmtlinesize == 0 ) return;
170
171
	for (i = 0; i < len; i++)
172
 
173
174
	//
175
 
176
	{
177
		//
178
		c = Format[i];
179
		//
180
		if( c != '%' )
181
		{
182
			Str[j++] = c;
183
			continue;
184
		}
185
		//
186
		i++;
187
		//
188
		if( i >= fmtlinesize ) break;
189
190
		//
191
 
192
		//
193
		c = Format[i];
194
		//
195
		switch( c )
196
		{
197
		//
198
		case '%':
199
			Str[j++] = c;
200
			break;
201
		// auaia aauanoaaiiiai ?enea
202
		case 'f':
203
			// ii?aaaeeou ?enei oeo? ai oi?ee
204
			double val, w;
205
			int p;
206
			val = va_arg(arglist, double);
207
			if (val < 0.0)
208
			{
209
				Str[j++] = '-';
210
				val = -val;
211
			}
212
			for (k = 0; k < 15; k++)
213
				if (val < double_tab[k])
214
					break;
215
216
			if (val < 1.0)
217
 
218
				Str[j++] = '0';
219
			}
220
221
			for (p = 1; p < k + 1; p++)
222
 
223
				Str[j++] = '0' + di(val / double_tab[k - p] - 0.499) % 10;
224
			}
225
			Str[j++] = '.';
226
			w = 0.1;
227
			for (p = 0; p < 2; p++)
228
			{
229
				val-=floor(val);
230
				Str[j++] = '0' + di(val / w - 0.499) % 10;
231
				w /= 10.0;
232
			}
233
234
		//
235
 
236
			break;
237
		}
238
	}
239
	//
240
	Str[j] = 0;
241
}
242
243
void *memcpy(void *dst, const void *src, unsigned size)
244
 
245
	while (size--)
246
		*((char*)dst+size) = *((char*)src+size);
247
	return dst;
248
}
249
250
int strcmp(const char *s1, const char *s2)
251
 
252
	int i;
253
254
	if (s1 == NULL)
255
 
256
			return 0;
257
		else
258
			return 1;
259
	else
260
		if (s2 == NULL)
261
			return 1;
262
263
	for (i = 0;;i++)
264
 
265
		if (s1[i] == '\0')
266
			if (s2[i] == '\0')
267
				return 0;
268
			else
269
				return 1;
270
		else
271
			if (s2[i] == '\0')
272
				return 1;
273
			else
274
			{
275
				if (s1[i] != s2[i])
276
					return 1;
277
			}
278
	}
279
	return 0;
280
}
281
282
kol_struct_import* kol_cofflib_load(char *name)
283
 
284
//asm ("int $0x40"::"a"(68), "b"(19), "c"(name));
285
	__asm
286
	{
287
		mov eax, 68
288
		mov ebx, 19
289
		mov ecx, name
290
		int 0x40
291
	}
292
}
293
294
295
 
296
 
297
298
int i;
299
 
300
	if ( NULL == ((imp+i) -> name))
301
		break;
302
	else
303
		if ( 0 == strcmp(name, (imp+i)->name) )
304
			return (imp+i)->data;
305
return NULL;
306
307
}
308
 
309
310
 
311
 
312
313
unsigned i, n;
314
 
315
for (i=n=0;;i++)
316
 
317
		break;
318
	else
319
		n++;
320
321
return n;
322
 
323
}
324
 
325
326
 
327
 
328
329
unsigned i;
330
 
331
332
for (i=0;;i++)
333
 
334
		break;
335
	else
336
		if ( i == n )
337
			{
338
			strcpy(name, ((imp+i)->name));
339
			break;
340
			}
341
342
}
343
 
344
345
 
346
 
347
 
348
*/
349
350
351
 
352
 
353
{
354
	kos_DrawLine(x1,y1,x2,y2,SysColor,0);
355
}
356
357
void outtextxy( int x, int y, char *s, int len)
358
 
359
	kos_WriteTextToWindow(x,y,0,SysColor,s,len);
360
}
361
362
double textwidth( char *s, int len)
363
 
364
	int i;
365
	for (i = 0; i < len; i++)
366
		if (s[i] == 0)
367
			break;
368
	return id(i * 6);
369
}
370
371
double textheight( char *s, int len)
372
 
373
	return 8.0;
374
}
375
376
void setcolor( DWORD color)
377
 
378
	SysColor = color;
379
}
380
381
void rectangle( int x1, int y1, int x2, int y2)
382
 
383
	kos_DrawBar(x1,y1,x2-x1,y2-y1,SysColor);
384
}
385
}*/
386
387
 
388
 
389