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