Rev 7504 | 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 toupper(int c) |
||
42 | |||
7517 | leency | 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 | |||
990 | barsuk | 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[]={1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15}; |
||
160 | |||
161 | // это sprintf, умеющий форматировать _только_ вещественные числа (double) %f |
||
162 | |||
163 | { |
||
164 | int i, fmtlinesize, j, k, flag; |
||
165 | char c; |
||
166 | va_list arglist; |
||
167 | // |
||
168 | va_start(arglist, Format); |
||
169 | |||
170 | // |
||
171 | |||
172 | // |
||
173 | if( fmtlinesize == 0 ) return; |
||
174 | |||
175 | for (i = 0; i < len; i++) |
||
176 | |||
177 | |||
178 | // |
||
179 | |||
180 | { |
||
181 | // |
||
182 | c = Format[i]; |
||
183 | // |
||
184 | if( c != '%' ) |
||
185 | { |
||
186 | Str[j++] = c; |
||
187 | continue; |
||
188 | } |
||
189 | // |
||
190 | i++; |
||
191 | // |
||
192 | if( i >= fmtlinesize ) break; |
||
193 | |||
194 | // |
||
195 | |||
196 | // |
||
197 | c = Format[i]; |
||
198 | // |
||
199 | switch( c ) |
||
200 | { |
||
201 | // |
||
202 | case '%': |
||
203 | Str[j++] = c; |
||
204 | break; |
||
205 | // auaia aauanoaaiiiai ?enea |
||
206 | case 'f': |
||
207 | // ii?aaaeeou ?enei oeo? ai oi?ee |
||
208 | double val, w; |
||
209 | int p; |
||
210 | val = va_arg(arglist, double); |
||
211 | if (val < 0.0) |
||
212 | { |
||
213 | Str[j++] = '-'; |
||
214 | val = -val; |
||
215 | } |
||
216 | for (k = 0; k < 15; k++) |
||
217 | if (val < double_tab[k]) |
||
218 | break; |
||
219 | |||
220 | if (val < 1.0) |
||
221 | |||
222 | Str[j++] = '0'; |
||
223 | } |
||
224 | |||
225 | for (p = 1; p < k + 1; p++) |
||
226 | |||
227 | Str[j++] = '0' + di(val / double_tab[k - p] - 0.499) % 10; |
||
228 | } |
||
229 | Str[j++] = '.'; |
||
230 | w = 0.1; |
||
231 | for (p = 0; p < 2; p++) |
||
232 | { |
||
233 | val-=floor(val); |
||
234 | Str[j++] = '0' + di(val / w - 0.499) % 10; |
||
235 | w /= 10.0; |
||
236 | } |
||
237 | |||
238 | // |
||
239 | |||
240 | break; |
||
241 | } |
||
242 | } |
||
243 | // |
||
244 | Str[j] = 0; |
||
245 | } |
||
246 | |||
247 | void *memcpy2(void *dst, const void *src, unsigned size) |
||
248 | |||
7495 | leency | 249 | while (size--) |
990 | barsuk | 250 | *((char*)dst+size) = *((char*)src+size); |
251 | return dst; |
||
252 | } |
||
253 | */ |
||
254 | |||
255 | |||
7495 | leency | 256 | |
257 | |||
258 | |||
990 | barsuk | 259 | int i; |
260 | |||
261 | if (s1 == NULL) |
||
262 | |||
263 | return 0; |
||
264 | else |
||
265 | return 1; |
||
266 | else |
||
267 | if (s2 == NULL) |
||
268 | return 1; |
||
269 | |||
270 | for (i = 0;;i++) |
||
271 | |||
272 | if (s1[i] == '\0') |
||
273 | if (s2[i] == '\0') |
||
274 | return 0; |
||
275 | else |
||
276 | return 1; |
||
277 | else |
||
278 | if (s2[i] == '\0') |
||
279 | return 1; |
||
280 | else |
||
281 | { |
||
282 | if (s1[i] != s2[i]) |
||
283 | return 1; |
||
284 | } |
||
285 | } |
||
286 | return 0; |
||
287 | } |
||
288 | |||
289 | kol_struct_import* kol_cofflib_load(char *name) |
||
290 | |||
291 | //asm ("int $0x40"::"a"(68), "b"(19), "c"(name)); |
||
292 | __asm |
||
293 | { |
||
294 | mov eax, 68 |
||
295 | mov ebx, 19 |
||
296 | mov ecx, name |
||
297 | int 0x40 |
||
298 | } |
||
299 | } |
||
300 | |||
301 | |||
302 | |||
303 | |||
304 | |||
305 | int i; |
||
306 | |||
307 | if ( NULL == ((imp+i) -> name)) |
||
308 | break; |
||
309 | else |
||
310 | if ( 0 == strcmp(name, (imp+i)->name) ) |
||
311 | return (imp+i)->data; |
||
312 | return NULL; |
||
313 | |||
314 | } |
||
315 | |||
316 | |||
317 | |||
318 | |||
319 | |||
320 | unsigned i, n; |
||
321 | |||
322 | for (i=n=0;;i++) |
||
323 | |||
324 | break; |
||
325 | else |
||
326 | n++; |
||
327 | |||
328 | return n; |
||
329 | |||
330 | } |
||
331 | |||
332 | |||
333 | |||
334 | |||
335 | |||
336 | unsigned i; |
||
337 | |||
338 | |||
339 | for (i=0;;i++) |
||
340 | |||
341 | break; |
||
342 | else |
||
343 | if ( i == n ) |
||
344 | { |
||
345 | strcpy(name, ((imp+i)->name)); |
||
346 | break; |
||
347 | } |
||
348 | |||
349 | } |
||
350 | |||
351 | |||
352 | |||
353 | |||
354 | |||
355 | */ |
||
356 | |||
357 | |||
358 | |||
359 | |||
360 | { |
||
361 | kos_DrawLine(x1,y1,x2,y2,SysColor,0); |
||
362 | } |
||
363 | |||
364 | void outtextxy( int x, int y, char *s, int len) |
||
365 | |||
366 | kos_WriteTextToWindow(x,y,0,SysColor,s,len); |
||
367 | } |
||
368 | |||
369 | double textwidth( char *s, int len) |
||
370 | |||
371 | int i; |
||
372 | for (i = 0; i < len; i++) |
||
373 | if (s[i] == 0) |
||
374 | break; |
||
375 | return id(i * 6); |
||
376 | } |
||
377 | |||
378 | double textheight( char *s, int len) |
||
379 | |||
380 | return 8.0; |
||
381 | } |
||
382 | |||
383 | void setcolor( DWORD color) |
||
384 | |||
385 | SysColor = color; |
||
386 | } |
||
387 | |||
388 | void rectangle( int x1, int y1, int x2, int y2) |
||
389 | |||
390 | kos_DrawBar(x1,y1,x2-x1,y2-y1,SysColor); |
||
391 | } |
||
392 | |||
393 | |||
394 | |||
395 | |||
396 | |||
397 | __asm{ |
||
398 | mov eax, 48 |
||
399 | mov ebx, 4 |
||
400 | int 0x40 |
||
401 | } |
||
402 | } |
||
403 | |||
404 | Dword kos_GetSpecialKeyState() |
||
405 | |||
406 | __asm{ |
||
407 | mov eax, 66 |
||
408 | mov ebx, 3 |
||
409 | int 0x40 |
||
410 | } |
||
411 | } |
||
412 | |||
413 | |||
414 | |||
415 | |||
416 | |||
417 | __asm |
||
418 | { |
||
419 | push ebx |
||
420 | push ecx |
||
421 | mov eax, 18 |
||
422 | mov ebx, 21 |
||
423 | mov ecx, PID |
||
424 | int 0x40 |
||
425 | pop ecx |
||
426 | pop ebx |
||
427 | } |
||
428 | } |
||
429 | |||
430 | |||
431 | |||
432 | |||
433 | __asm |
||
434 | { |
||
435 | push ebx |
||
436 | mov eax, 18 |
||
437 | mov ebx, 7 |
||
438 | int 0x40 |
||
439 | pop ebx |
||
440 | } |
||
441 | } |
||
442 | |||
443 | |||
444 | |||
445 | |||
446 | |||
447 | short v, h; |
||
448 | __asm |
||
449 | { |
||
450 | mov eax, 37 |
||
451 | mov ebx, 7 |
||
452 | int 0x40 |
||
453 | mov ebx, eax |
||
454 | and eax, 0xffff |
||
455 | mov v, ax |
||
456 | shr ebx, 16 |
||
457 | mov h, bx |
||
458 | } |
||
459 | vert = v; |
||
460 | hor = h; |
||
461 | } |
||
462 | |||
463 | |||
464 | |||
465 | |||
466 | { |
||
467 | Dword mB; |
||
468 | Word curX; |
||
469 | Word curY; |
||
470 | sProcessInfo sPI; |
||
471 | |||
472 | // |
||
473 | |||
474 | mov eax, 37 |
||
475 | mov ebx, 1 |
||
476 | int 0x40 |
||
477 | mov curY, ax |
||
478 | shr eax, 16 |
||
479 | mov curX, ax |
||
480 | mov eax, 37 |
||
481 | mov ebx, 2 |
||
482 | int 0x40 |
||
483 | mov mB, eax |
||
484 | } |
||
485 | // |
||
486 | kos_ProcessInfo( &sPI ); |
||
487 | // |
||
488 | buttons = mB; |
||
489 | cursorX = curX - sPI.processInfo.x_start; |
||
490 | cursorY = curY - sPI.processInfo.y_start; |
||
491 | } |
||
492 | |||
493 | char *ftoa(double d) |
||
494 | |||
495 | char buffer[256], *p; |
||
496 | sprintf(buffer, "%f", d); |
||
497 | p = (char*)allocmem(strlen(buffer)+1); |
||
498 | strcpy(p, buffer); |
||
499 | return p; |
||
500 | } |
||
501 | |||
502 | double atof(char *s) |
||
503 | |||
504 | return convert(s, NULL); |
||
505 | } |
||
506 | |||
507 | |||
508 | |||
509 | |||
510 | int a; |
||
511 | __asm fld x |
||
512 | __asm fistp a |
||
513 | return a; |
||
514 | } |
||
515 | |||
516 | double id(int x) |
||
517 | |||
518 | double a; |
||
519 | __asm fild x |
||
520 | __asm fstp a |
||
521 | return a; |
||
522 | }>>>>>>>>>=>=>0)?-n:n; |
||
523 | }*/ |
||
524 |