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