Rev 4481 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4481 | Rev 5107 | ||
---|---|---|---|
1 | #include "kosSyst.h" |
1 | #include "kosSyst.h" |
2 | #include |
2 | #include |
3 | 3 | ||
4 | #define atexitBufferSize 32 |
4 | #define atexitBufferSize 32 |
- | 5 | ||
- | 6 | // Autobuild uses FASM method for exe->kos, |
|
- | 7 | // MENUET01 header should be present in EXE. |
|
- | 8 | #ifdef AUTOBUILD |
|
- | 9 | char kosExePath[1024]; |
|
- | 10 | char exeStack[16384]; |
|
- | 11 | // must be alphabetically first in the image |
|
- | 12 | #pragma data_seg(".1seg") |
|
- | 13 | extern "C" struct |
|
- | 14 | { |
|
- | 15 | char header[8]; |
|
- | 16 | int headerver; |
|
- | 17 | void* entry; |
|
- | 18 | void* i_end; |
|
- | 19 | void* memsize; |
|
- | 20 | void* stack; |
|
- | 21 | void* params; |
|
- | 22 | void* icon; |
|
- | 23 | } header = { |
|
- | 24 | {'M', 'E', 'N', 'U', 'E', 'T', '0', '1'}, |
|
- | 25 | 1, |
|
- | 26 | &crtStartUp, |
|
- | 27 | 0, // filled by doexe2.asm |
|
- | 28 | 0, // filled by doexe2.asm |
|
- | 29 | exeStack + sizeof(exeStack), |
|
- | 30 | NULL, |
|
- | 31 | kosExePath |
|
- | 32 | }; |
|
- | 33 | #pragma data_seg() |
|
- | 34 | #else |
|
- | 35 | char *kosExePath = NULL; |
|
5 | 36 | #endif |
|
6 | 37 | ||
7 | char pureCallMessage[] = "PURE function call!"; |
38 | char pureCallMessage[] = "PURE function call!"; |
8 | - | ||
9 | char *kosExePath = NULL; |
- | |
10 | 39 | ||
11 | // |
40 | // |
12 | void (__cdecl *atExitList[atexitBufferSize])(); |
41 | void (__cdecl *atExitList[atexitBufferSize])(); |
13 | int atExitFnNum = 0; |
42 | int atExitFnNum = 0; |
14 | // |
43 | // |
15 | int __cdecl atexit( void (__cdecl *func )( void )) |
44 | int __cdecl atexit( void (__cdecl *func )( void )) |
16 | { |
45 | { |
17 | // |
46 | // |
18 | if ( atExitFnNum < atexitBufferSize ) |
47 | if ( atExitFnNum < atexitBufferSize ) |
19 | { |
48 | { |
20 | // |
49 | // |
21 | atExitList[atExitFnNum++] = func; |
50 | atExitList[atExitFnNum++] = func; |
22 | return 0; |
51 | return 0; |
23 | } |
52 | } |
24 | else |
53 | else |
25 | { |
54 | { |
26 | return 1; |
55 | return 1; |
27 | } |
56 | } |
28 | } |
57 | } |
29 | 58 | ||
30 | 59 | ||
31 | // |
60 | // |
32 | Dword RandomSeed = 1; |
61 | Dword RandomSeed = 1; |
33 | // |
62 | // |
34 | void rtlSrand( Dword seed ) |
63 | void rtlSrand( Dword seed ) |
35 | { |
64 | { |
36 | RandomSeed = seed; |
65 | RandomSeed = seed; |
37 | } |
66 | } |
38 | // |
67 | // |
39 | Dword rtlRand( void ) |
68 | Dword rtlRand( void ) |
40 | { |
69 | { |
41 | //ìàñêà 0x80000776 |
70 | //ìàñêà 0x80000776 |
42 | 71 | ||
43 | Dword dwi, i; |
72 | Dword dwi, i; |
44 | 73 | ||
45 | for ( i = 0; i < 32; i++ ) |
74 | for ( i = 0; i < 32; i++ ) |
46 | { |
75 | { |
47 | 76 | ||
48 | dwi = RandomSeed & 0x80000776; |
77 | dwi = RandomSeed & 0x80000776; |
49 | 78 | ||
50 | __asm{ |
79 | __asm{ |
51 | mov eax, dwi |
80 | mov eax, dwi |
52 | mov edx, eax |
81 | mov edx, eax |
53 | bswap eax |
82 | bswap eax |
54 | xor eax, edx |
83 | xor eax, edx |
55 | xor al, ah |
84 | xor al, ah |
56 | setpo al |
85 | setpo al |
57 | movzx eax, al |
86 | movzx eax, al |
58 | mov dwi, eax |
87 | mov dwi, eax |
59 | } |
88 | } |
60 | 89 | ||
61 | RandomSeed = ( RandomSeed << 1 ) | ( dwi & 1 ); |
90 | RandomSeed = ( RandomSeed << 1 ) | ( dwi & 1 ); |
62 | } |
91 | } |
63 | 92 | ||
64 | return RandomSeed; |
93 | return RandomSeed; |
65 | } |
94 | } |
66 | 95 | ||
67 | // |
96 | // |
68 | void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount ) |
97 | void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount ) |
69 | { |
98 | { |
70 | __asm{ |
99 | __asm{ |
71 | mov edi, dst |
100 | mov edi, dst |
72 | mov eax, dst |
101 | mov eax, dst |
73 | mov esi, src |
102 | mov esi, src |
74 | mov ecx, bytesCount |
103 | mov ecx, bytesCount |
75 | rep movsb |
104 | rep movsb |
76 | } |
105 | } |
77 | } |
106 | } |
78 | 107 | ||
79 | // |
108 | // |
80 | void memset( Byte *dst, Byte filler, Dword count ) |
109 | void memset( Byte *dst, Byte filler, Dword count ) |
81 | { |
110 | { |
82 | // |
111 | // |
83 | __asm{ |
112 | __asm{ |
84 | mov edi, dst |
113 | mov edi, dst |
85 | mov al, filler |
114 | mov al, filler |
86 | mov ecx, count |
115 | mov ecx, count |
87 | rep stosb |
116 | rep stosb |
88 | } |
117 | } |
89 | } |
118 | } |
90 | 119 | ||
91 | // |
120 | // |
92 | Dword rtlInterlockedExchange( Dword *target, Dword value ) |
121 | Dword rtlInterlockedExchange( Dword *target, Dword value ) |
93 | { |
122 | { |
94 | // Dword result; |
123 | // Dword result; |
95 | 124 | ||
96 | // |
125 | // |
97 | __asm{ |
126 | __asm{ |
98 | mov eax, value |
127 | mov eax, value |
99 | mov ebx, target |
128 | mov ebx, target |
100 | xchg eax, [ebx] |
129 | xchg eax, [ebx] |
101 | // mov result, eax |
130 | // mov result, eax |
102 | } |
131 | } |
103 | // |
132 | // |
104 | // return result; |
133 | // return result; |
105 | } |
134 | } |
106 | 135 | ||
107 | 136 | ||
108 | ////////////////////////////////////////////////////////////////////// |
137 | ////////////////////////////////////////////////////////////////////// |
109 | // |
138 | // |
110 | // êîïèðîâàíèå ñòðîêè |
139 | // êîïèðîâàíèå ñòðîêè |
111 | // |
140 | // |
112 | 141 | ||
113 | char * __cdecl strcpy( char *target, const char *source ) |
142 | char * __cdecl strcpy( char *target, const char *source ) |
114 | { |
143 | { |
115 | char *result = target; |
144 | char *result = target; |
116 | 145 | ||
117 | while( target[0] = source[0] ) |
146 | while( target[0] = source[0] ) |
118 | { |
147 | { |
119 | target++; |
148 | target++; |
120 | source++; |
149 | source++; |
121 | } |
150 | } |
122 | 151 | ||
123 | return result; |
152 | return result; |
124 | } |
153 | } |
125 | 154 | ||
126 | 155 | ||
127 | ////////////////////////////////////////////////////////////////////// |
156 | ////////////////////////////////////////////////////////////////////// |
128 | // |
157 | // |
129 | // ðåâåðñèâíûé ïîèñê ñèìâîëà |
158 | // ðåâåðñèâíûé ïîèñê ñèìâîëà |
130 | // |
159 | // |
131 | 160 | ||
132 | char * __cdecl strrchr( const char * string, int c ) |
161 | char * __cdecl strrchr( const char * string, int c ) |
133 | { |
162 | { |
134 | char *cPtr; |
163 | char *cPtr; |
135 | 164 | ||
136 | // |
165 | // |
137 | for ( cPtr = (char *)string + strlen( string ); cPtr >= string; cPtr-- ) |
166 | for ( cPtr = (char *)string + strlen( string ); cPtr >= string; cPtr-- ) |
138 | { |
167 | { |
139 | // |
168 | // |
140 | if ( *cPtr == c ) return cPtr; |
169 | if ( *cPtr == c ) return cPtr; |
141 | } |
170 | } |
142 | // |
171 | // |
143 | return NULL; |
172 | return NULL; |
144 | } |
173 | } |
145 | 174 | ||
146 | 175 | ||
147 | ////////////////////////////////////////////////////////////////////// |
176 | ////////////////////////////////////////////////////////////////////// |
148 | // |
177 | // |
149 | // îïðåäåëåíèå äëèíû ñòðîêè |
178 | // îïðåäåëåíèå äëèíû ñòðîêè |
150 | // |
179 | // |
151 | 180 | ||
152 | int __cdecl strlen( const char *line ) |
181 | int __cdecl strlen( const char *line ) |
153 | { |
182 | { |
154 | int i; |
183 | int i; |
155 | 184 | ||
156 | for( i=0; line[i] != 0; i++ ); |
185 | for( i=0; line[i] != 0; i++ ); |
157 | return i; |
186 | return i; |
158 | } |
187 | } |
159 | 188 | ||
160 | 189 | ||
161 | 190 | ||
162 | ////////////////////////////////////////////////////////////////////// |
191 | ////////////////////////////////////////////////////////////////////// |
163 | // |
192 | // |
164 | // ïåðåâîä øåñòíàäöàòèðè÷íîãî ÷èñëà â ñèìâîë |
193 | // ïåðåâîä øåñòíàäöàòèðè÷íîãî ÷èñëà â ñèìâîë |
165 | // |
194 | // |
166 | 195 | ||
167 | unsigned int num2hex( unsigned int num ) |
196 | unsigned int num2hex( unsigned int num ) |
168 | { |
197 | { |
169 | if( num < 10 ) |
198 | if( num < 10 ) |
170 | return num + '0'; |
199 | return num + '0'; |
171 | return num - 10 + 'A'; |
200 | return num - 10 + 'A'; |
172 | } |
201 | } |
173 | 202 | ||
174 | 203 | ||
175 | ////////////////////////////////////////////////////////////////////// |
204 | ////////////////////////////////////////////////////////////////////// |
176 | // |
205 | // |
177 | // âûâîä ñòðîêè íà ïå÷àòü |
206 | // âûâîä ñòðîêè íà ïå÷àòü |
178 | // |
207 | // |
179 | 208 | ||
180 | Dword dectab[] = { 1000000000, 100000000, 10000000, 1000000, 100000, |
209 | Dword dectab[] = { 1000000000, 100000000, 10000000, 1000000, 100000, |
181 | 10000, 1000, 100, 10, 0 }; |
210 | 10000, 1000, 100, 10, 0 }; |
182 | 211 | ||
183 | // |
212 | // |
184 | void sprintf( char *Str, char* Format, ... ) |
213 | void sprintf( char *Str, char* Format, ... ) |
185 | { |
214 | { |
186 | int i, fmtlinesize, j, k, flag; |
215 | int i, fmtlinesize, j, k, flag; |
187 | Dword head, tail; |
216 | Dword head, tail; |
188 | char c; |
217 | char c; |
189 | va_list arglist; |
218 | va_list arglist; |
190 | // |
219 | // |
191 | va_start(arglist, Format); |
220 | va_start(arglist, Format); |
192 | 221 | ||
193 | // |
222 | // |
194 | fmtlinesize = strlen( Format ); |
223 | fmtlinesize = strlen( Format ); |
195 | // |
224 | // |
196 | if( fmtlinesize == 0 ) return; |
225 | if( fmtlinesize == 0 ) return; |
197 | 226 | ||
198 | // |
227 | // |
199 | for( i = 0, j = 0; i < fmtlinesize; i++ ) |
228 | for( i = 0, j = 0; i < fmtlinesize; i++ ) |
200 | { |
229 | { |
201 | // |
230 | // |
202 | c = Format[i]; |
231 | c = Format[i]; |
203 | // |
232 | // |
204 | if( c != '%' ) |
233 | if( c != '%' ) |
205 | { |
234 | { |
206 | Str[j++] = c; |
235 | Str[j++] = c; |
207 | continue; |
236 | continue; |
208 | } |
237 | } |
209 | // |
238 | // |
210 | i++; |
239 | i++; |
211 | // |
240 | // |
212 | if( i >= fmtlinesize ) break; |
241 | if( i >= fmtlinesize ) break; |
213 | 242 | ||
214 | // |
243 | // |
215 | flag = 0; |
244 | flag = 0; |
216 | // |
245 | // |
217 | c = Format[i]; |
246 | c = Format[i]; |
218 | // |
247 | // |
219 | switch( c ) |
248 | switch( c ) |
220 | { |
249 | { |
221 | // |
250 | // |
222 | case '%': |
251 | case '%': |
223 | Str[j++] = c; |
252 | Str[j++] = c; |
224 | break; |
253 | break; |
225 | // âûâîä ñòðîêè |
254 | // âûâîä ñòðîêè |
226 | case 'S': |
255 | case 'S': |
227 | Byte* str; |
256 | Byte* str; |
228 | str = va_arg(arglist, Byte*); |
257 | str = va_arg(arglist, Byte*); |
229 | for( k = 0; ( c = str[k] ) != 0; k++ ) |
258 | for( k = 0; ( c = str[k] ) != 0; k++ ) |
230 | { |
259 | { |
231 | Str[j++] = c; |
260 | Str[j++] = c; |
232 | } |
261 | } |
233 | break; |
262 | break; |
234 | // âûâîä áàéòà |
263 | // âûâîä áàéòà |
235 | case 'B': |
264 | case 'B': |
236 | k = va_arg(arglist, int) & 0xFF; |
265 | k = va_arg(arglist, int) & 0xFF; |
237 | Str[j++] = num2hex( ( k >> 4 ) & 0xF ); |
266 | Str[j++] = num2hex( ( k >> 4 ) & 0xF ); |
238 | Str[j++] = num2hex( k & 0xF ); |
267 | Str[j++] = num2hex( k & 0xF ); |
239 | break; |
268 | break; |
240 | // âûâîä ñèìâîëà |
269 | // âûâîä ñèìâîëà |
241 | case 'C': |
270 | case 'C': |
242 | Str[j++] = va_arg(arglist, int) & 0xFF; |
271 | Str[j++] = va_arg(arglist, int) & 0xFF; |
243 | break; |
272 | break; |
244 | // âûâîä äâîéíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå |
273 | // âûâîä äâîéíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå |
245 | case 'X': |
274 | case 'X': |
246 | Dword val; |
275 | Dword val; |
247 | val = va_arg(arglist, Dword); |
276 | val = va_arg(arglist, Dword); |
248 | for( k = 7; k >= 0; k-- ) |
277 | for( k = 7; k >= 0; k-- ) |
249 | { |
278 | { |
250 | // |
279 | // |
251 | c = num2hex ( ( val >> (k * 4) ) & 0xF ); |
280 | c = num2hex ( ( val >> (k * 4) ) & 0xF ); |
252 | // |
281 | // |
253 | if( c == '0' ) |
282 | if( c == '0' ) |
254 | { |
283 | { |
255 | if( flag ) Str[j++] = c; |
284 | if( flag ) Str[j++] = c; |
256 | } |
285 | } |
257 | else |
286 | else |
258 | { |
287 | { |
259 | flag++; |
288 | flag++; |
260 | Str[j++] = c; |
289 | Str[j++] = c; |
261 | } |
290 | } |
262 | } |
291 | } |
263 | // |
292 | // |
264 | if( flag == 0 ) Str[j++] = '0'; |
293 | if( flag == 0 ) Str[j++] = '0'; |
265 | break; |
294 | break; |
266 | // âûâîä äâîéíîãî ñëîâà â äåñÿòè÷íîì âèäå |
295 | // âûâîä äâîéíîãî ñëîâà â äåñÿòè÷íîì âèäå |
267 | case 'U': |
296 | case 'U': |
268 | head = va_arg(arglist, Dword); |
297 | head = va_arg(arglist, Dword); |
269 | tail = 0; |
298 | tail = 0; |
270 | for( k = 0; dectab[k] != 0; k++ ) |
299 | for( k = 0; dectab[k] != 0; k++ ) |
271 | { |
300 | { |
272 | tail = head % dectab[k]; |
301 | tail = head % dectab[k]; |
273 | head /= dectab[k]; |
302 | head /= dectab[k]; |
274 | c = head + '0'; |
303 | c = head + '0'; |
275 | if( c == '0' ) |
304 | if( c == '0' ) |
276 | { |
305 | { |
277 | if( flag ) Str[j++] = c; |
306 | if( flag ) Str[j++] = c; |
278 | } |
307 | } |
279 | else |
308 | else |
280 | { |
309 | { |
281 | flag++; |
310 | flag++; |
282 | Str[j++] = c; |
311 | Str[j++] = c; |
283 | } |
312 | } |
284 | // |
313 | // |
285 | head = tail; |
314 | head = tail; |
286 | } |
315 | } |
287 | // |
316 | // |
288 | c = head + '0'; |
317 | c = head + '0'; |
289 | Str[j++] = c; |
318 | Str[j++] = c; |
290 | break; |
319 | break; |
291 | // âûâîä 64-áèòíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå |
320 | // âûâîä 64-áèòíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå |
292 | case 'Q': |
321 | case 'Q': |
293 | unsigned int low_dword, high_dword; |
322 | unsigned int low_dword, high_dword; |
294 | low_dword = va_arg(arglist, unsigned int); |
323 | low_dword = va_arg(arglist, unsigned int); |
295 | high_dword = va_arg(arglist, unsigned int); |
324 | high_dword = va_arg(arglist, unsigned int); |
296 | for( k = 7; k >= 0; k-- ) |
325 | for( k = 7; k >= 0; k-- ) |
297 | { |
326 | { |
298 | // |
327 | // |
299 | c = num2hex ( ( ( high_dword + 1) >> (k * 4) ) & 0xF ); |
328 | c = num2hex ( ( ( high_dword + 1) >> (k * 4) ) & 0xF ); |
300 | // |
329 | // |
301 | if( c == '0' ) |
330 | if( c == '0' ) |
302 | { |
331 | { |
303 | if( flag ) Str[j++] = c; |
332 | if( flag ) Str[j++] = c; |
304 | } |
333 | } |
305 | else |
334 | else |
306 | { |
335 | { |
307 | flag++; |
336 | flag++; |
308 | Str[j++] = c; |
337 | Str[j++] = c; |
309 | } |
338 | } |
310 | } |
339 | } |
311 | // |
340 | // |
312 | for( k=7; k >= 0; k-- ) |
341 | for( k=7; k >= 0; k-- ) |
313 | { |
342 | { |
314 | // |
343 | // |
315 | c = num2hex ( ( low_dword >> (k * 4) ) & 0xF ); |
344 | c = num2hex ( ( low_dword >> (k * 4) ) & 0xF ); |
316 | // |
345 | // |
317 | if( c == '0' ) |
346 | if( c == '0' ) |
318 | { |
347 | { |
319 | if( flag ) Str[j++] = c; |
348 | if( flag ) Str[j++] = c; |
320 | } |
349 | } |
321 | else |
350 | else |
322 | { |
351 | { |
323 | flag++; |
352 | flag++; |
324 | Str[j++] = c; |
353 | Str[j++] = c; |
325 | } |
354 | } |
326 | } |
355 | } |
327 | // |
356 | // |
328 | if( flag == 0 ) Str[j++] = '0'; |
357 | if( flag == 0 ) Str[j++] = '0'; |
329 | // |
358 | // |
330 | break; |
359 | break; |
331 | // |
360 | // |
332 | default: |
361 | default: |
333 | break; |
362 | break; |
334 | } |
363 | } |
335 | } |
364 | } |
336 | // |
365 | // |
337 | Str[j] = 0; |
366 | Str[j] = 0; |
338 | } |
367 | } |
339 | 368 | ||
340 | 369 | ||
341 | // ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà |
370 | // ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà |
342 | void kos_ExitApp() |
371 | void kos_ExitApp() |
343 | { |
372 | { |
344 | int i; |
373 | int i; |
345 | 374 | ||
346 | // |
375 | // |
347 | for ( i = atExitFnNum - 1; i >= 0; i-- ) |
376 | for ( i = atExitFnNum - 1; i >= 0; i-- ) |
348 | { |
377 | { |
349 | // |
378 | // |
350 | atExitList[i](); |
379 | atExitList[i](); |
351 | } |
380 | } |
352 | // |
381 | // |
353 | __asm{ |
382 | __asm{ |
354 | mov eax, -1 |
383 | mov eax, -1 |
355 | int 0x40 |
384 | int 0x40 |
356 | } |
385 | } |
357 | } |
386 | } |
358 | 387 | ||
359 | 388 | ||
360 | // ôóíêöèÿ 0 |
389 | // ôóíêöèÿ 0 |
361 | void kos_DefineAndDrawWindow( |
390 | void kos_DefineAndDrawWindow( |
362 | Word x, Word y, |
391 | Word x, Word y, |
363 | Word sizeX, Word sizeY, |
392 | Word sizeX, Word sizeY, |
364 | Byte mainAreaType, |
393 | Byte mainAreaType, |
365 | Dword mainAreaColour, |
394 | Dword mainAreaColour, |
366 | Byte headerType, |
395 | Byte headerType, |
367 | Dword headerColour, |
396 | Dword headerColour, |
368 | char *textPtr |
397 | char *textPtr |
369 | ) |
398 | ) |
370 | { |
399 | { |
371 | Dword arg1, arg2, arg3, arg4; |
400 | Dword arg1, arg2, arg3, arg4; |
372 | 401 | ||
373 | // |
402 | // |
374 | arg1 = ( x << 16 ) + sizeX; |
403 | arg1 = ( x << 16 ) + sizeX; |
375 | arg2 = ( y << 16 ) + sizeY; |
404 | arg2 = ( y << 16 ) + sizeY; |
376 | arg3 = ( mainAreaType << 24 ) | mainAreaColour; |
405 | arg3 = ( mainAreaType << 24 ) | mainAreaColour; |
377 | arg4 = ( headerType << 24 ) | headerColour; |
406 | arg4 = ( headerType << 24 ) | headerColour; |
378 | // |
407 | // |
379 | __asm{ |
408 | __asm{ |
380 | mov eax, 0 |
409 | mov eax, 0 |
381 | mov ebx, arg1 |
410 | mov ebx, arg1 |
382 | mov ecx, arg2 |
411 | mov ecx, arg2 |
383 | mov edx, arg3 |
412 | mov edx, arg3 |
384 | mov esi, arg4 |
413 | mov esi, arg4 |
385 | mov edi, textPtr |
414 | mov edi, textPtr |
386 | int 0x40 |
415 | int 0x40 |
387 | } |
416 | } |
388 | } |
417 | } |
389 | 418 | ||
390 | 419 | ||
391 | // ôóíêöèÿ 1 ïîñòàâèòü òî÷êó |
420 | // ôóíêöèÿ 1 ïîñòàâèòü òî÷êó |
392 | void kos_PutPixel( Dword x, Dword y, Dword colour ) |
421 | void kos_PutPixel( Dword x, Dword y, Dword colour ) |
393 | { |
422 | { |
394 | // |
423 | // |
395 | __asm{ |
424 | __asm{ |
396 | mov eax, 1 |
425 | mov eax, 1 |
397 | mov ebx, x |
426 | mov ebx, x |
398 | mov ecx, y |
427 | mov ecx, y |
399 | mov edx, colour |
428 | mov edx, colour |
400 | int 0x40 |
429 | int 0x40 |
401 | } |
430 | } |
402 | } |
431 | } |
403 | 432 | ||
404 | 433 | ||
405 | // ôóíêöèÿ 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè |
434 | // ôóíêöèÿ 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè |
406 | bool kos_GetKey( Byte &keyCode ) |
435 | bool kos_GetKey( Byte &keyCode ) |
407 | { |
436 | { |
408 | Dword result; |
437 | Dword result; |
409 | 438 | ||
410 | // |
439 | // |
411 | __asm{ |
440 | __asm{ |
412 | mov eax, 2 |
441 | mov eax, 2 |
413 | int 0x40 |
442 | int 0x40 |
414 | mov result, eax |
443 | mov result, eax |
415 | } |
444 | } |
416 | // |
445 | // |
417 | keyCode = result >> 8; |
446 | keyCode = result >> 8; |
418 | // |
447 | // |
419 | return ( result & 0xFF ) == 0; |
448 | return ( result & 0xFF ) == 0; |
420 | } |
449 | } |
421 | 450 | ||
422 | 451 | ||
423 | // ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ |
452 | // ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ |
424 | Dword kos_GetSystemClock() |
453 | Dword kos_GetSystemClock() |
425 | { |
454 | { |
426 | // Dword result; |
455 | // Dword result; |
427 | 456 | ||
428 | // |
457 | // |
429 | __asm{ |
458 | __asm{ |
430 | mov eax, 3 |
459 | mov eax, 3 |
431 | int 0x40 |
460 | int 0x40 |
432 | // mov result, eax |
461 | // mov result, eax |
433 | } |
462 | } |
434 | // |
463 | // |
435 | // return result; |
464 | // return result; |
436 | } |
465 | } |
437 | 466 | ||
438 | 467 | ||
439 | // ôóíêöèÿ 4 |
468 | // ôóíêöèÿ 4 |
440 | void kos_WriteTextToWindow( |
469 | void kos_WriteTextToWindow( |
441 | Word x, |
470 | Word x, |
442 | Word y, |
471 | Word y, |
443 | Byte fontType, |
472 | Byte fontType, |
444 | Dword textColour, |
473 | Dword textColour, |
445 | char *textPtr, |
474 | char *textPtr, |
446 | Dword textLen |
475 | Dword textLen |
447 | ) |
476 | ) |
448 | { |
477 | { |
449 | Dword arg1, arg2; |
478 | Dword arg1, arg2; |
450 | 479 | ||
451 | // |
480 | // |
452 | arg1 = ( x << 16 ) | y; |
481 | arg1 = ( x << 16 ) | y; |
453 | arg2 = ( fontType << 24 ) | textColour; |
482 | arg2 = ( fontType << 24 ) | textColour; |
454 | // |
483 | // |
455 | __asm{ |
484 | __asm{ |
456 | mov eax, 4 |
485 | mov eax, 4 |
457 | mov ebx, arg1 |
486 | mov ebx, arg1 |
458 | mov ecx, arg2 |
487 | mov ecx, arg2 |
459 | mov edx, textPtr |
488 | mov edx, textPtr |
460 | mov esi, textLen |
489 | mov esi, textLen |
461 | int 0x40 |
490 | int 0x40 |
462 | } |
491 | } |
463 | } |
492 | } |
464 | 493 | ||
465 | 494 | ||
466 | // ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû |
495 | // ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû |
467 | void kos_Pause( Dword value ) |
496 | void kos_Pause( Dword value ) |
468 | { |
497 | { |
469 | // |
498 | // |
470 | __asm{ |
499 | __asm{ |
471 | mov eax, 5 |
500 | mov eax, 5 |
472 | mov ebx, value |
501 | mov ebx, value |
473 | int 0x40 |
502 | int 0x40 |
474 | } |
503 | } |
475 | } |
504 | } |
476 | 505 | ||
477 | 506 | ||
478 | // ôóíêöèÿ 7 íàðèñîâàòü èçîáðàæåíèå |
507 | // ôóíêöèÿ 7 íàðèñîâàòü èçîáðàæåíèå |
479 | void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ) |
508 | void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ) |
480 | { |
509 | { |
481 | Dword arg1, arg2; |
510 | Dword arg1, arg2; |
482 | 511 | ||
483 | // |
512 | // |
484 | arg1 = ( sizeX << 16 ) | sizeY; |
513 | arg1 = ( sizeX << 16 ) | sizeY; |
485 | arg2 = ( x << 16 ) | y; |
514 | arg2 = ( x << 16 ) | y; |
486 | // |
515 | // |
487 | __asm{ |
516 | __asm{ |
488 | mov eax, 7 |
517 | mov eax, 7 |
489 | mov ebx, imagePtr |
518 | mov ebx, imagePtr |
490 | mov ecx, arg1 |
519 | mov ecx, arg1 |
491 | mov edx, arg2 |
520 | mov edx, arg2 |
492 | int 0x40 |
521 | int 0x40 |
493 | } |
522 | } |
494 | } |
523 | } |
495 | 524 | ||
496 | 525 | ||
497 | 526 | ||
498 | // ôóíêöèÿ 8 îïðåäåëèòü êíîïêó |
527 | // ôóíêöèÿ 8 îïðåäåëèòü êíîïêó |
499 | void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ) |
528 | void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ) |
500 | { |
529 | { |
501 | Dword arg1, arg2; |
530 | Dword arg1, arg2; |
502 | 531 | ||
503 | // |
532 | // |
504 | arg1 = ( x << 16 ) | sizeX; |
533 | arg1 = ( x << 16 ) | sizeX; |
505 | arg2 = ( y << 16 ) | sizeY; |
534 | arg2 = ( y << 16 ) | sizeY; |
506 | // |
535 | // |
507 | __asm{ |
536 | __asm{ |
508 | mov eax, 8 |
537 | mov eax, 8 |
509 | mov ebx, arg1 |
538 | mov ebx, arg1 |
510 | mov ecx, arg2 |
539 | mov ecx, arg2 |
511 | mov edx, buttonID |
540 | mov edx, buttonID |
512 | mov esi, colour |
541 | mov esi, colour |
513 | int 0x40 |
542 | int 0x40 |
514 | } |
543 | } |
515 | } |
544 | } |
516 | 545 | ||
517 | 546 | ||
518 | // ôóíêöèÿ 9 - èíôîðìàöèÿ î ïðîöåññå |
547 | // ôóíêöèÿ 9 - èíôîðìàöèÿ î ïðîöåññå |
519 | Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID ) |
548 | Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID ) |
520 | { |
549 | { |
521 | // Dword result; |
550 | // Dword result; |
522 | 551 | ||
523 | // |
552 | // |
524 | __asm{ |
553 | __asm{ |
525 | mov eax, 9 |
554 | mov eax, 9 |
526 | mov ebx, targetPtr |
555 | mov ebx, targetPtr |
527 | mov ecx, processID |
556 | mov ecx, processID |
528 | int 0x40 |
557 | int 0x40 |
529 | // mov result, eax |
558 | // mov result, eax |
530 | } |
559 | } |
531 | // |
560 | // |
532 | // return result; |
561 | // return result; |
533 | } |
562 | } |
534 | 563 | ||
535 | 564 | ||
536 | // ôóíêöèÿ 10 |
565 | // ôóíêöèÿ 10 |
537 | Dword kos_WaitForEvent() |
566 | Dword kos_WaitForEvent() |
538 | { |
567 | { |
539 | // Dword result; |
568 | // Dword result; |
540 | 569 | ||
541 | __asm{ |
570 | __asm{ |
542 | mov eax, 10 |
571 | mov eax, 10 |
543 | int 0x40 |
572 | int 0x40 |
544 | // mov result, eax |
573 | // mov result, eax |
545 | } |
574 | } |
546 | 575 | ||
547 | // return result; |
576 | // return result; |
548 | } |
577 | } |
549 | 578 | ||
550 | 579 | ||
551 | // ôóíêöèÿ 11 |
580 | // ôóíêöèÿ 11 |
552 | Dword kos_CheckForEvent() |
581 | Dword kos_CheckForEvent() |
553 | { |
582 | { |
554 | // Dword result; |
583 | // Dword result; |
555 | 584 | ||
556 | __asm{ |
585 | __asm{ |
557 | mov eax, 11 |
586 | mov eax, 11 |
558 | int 0x40 |
587 | int 0x40 |
559 | // mov result, eax |
588 | // mov result, eax |
560 | } |
589 | } |
561 | 590 | ||
562 | // return result; |
591 | // return result; |
563 | } |
592 | } |
564 | 593 | ||
565 | 594 | ||
566 | // ôóíêöèÿ 12 |
595 | // ôóíêöèÿ 12 |
567 | void kos_WindowRedrawStatus( Dword status ) |
596 | void kos_WindowRedrawStatus( Dword status ) |
568 | { |
597 | { |
569 | __asm{ |
598 | __asm{ |
570 | mov eax, 12 |
599 | mov eax, 12 |
571 | mov ebx, status |
600 | mov ebx, status |
572 | int 0x40 |
601 | int 0x40 |
573 | } |
602 | } |
574 | } |
603 | } |
575 | 604 | ||
576 | 605 | ||
577 | // ôóíêöèÿ 13 íàðèñîâàòü ïîëîñó |
606 | // ôóíêöèÿ 13 íàðèñîâàòü ïîëîñó |
578 | void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ) |
607 | void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ) |
579 | { |
608 | { |
580 | Dword arg1, arg2; |
609 | Dword arg1, arg2; |
581 | 610 | ||
582 | // |
611 | // |
583 | arg1 = ( x << 16 ) | sizeX; |
612 | arg1 = ( x << 16 ) | sizeX; |
584 | arg2 = ( y << 16 ) | sizeY; |
613 | arg2 = ( y << 16 ) | sizeY; |
585 | // |
614 | // |
586 | __asm{ |
615 | __asm{ |
587 | mov eax, 13 |
616 | mov eax, 13 |
588 | mov ebx, arg1 |
617 | mov ebx, arg1 |
589 | mov ecx, arg2 |
618 | mov ecx, arg2 |
590 | mov edx, colour |
619 | mov edx, colour |
591 | int 0x40 |
620 | int 0x40 |
592 | } |
621 | } |
593 | } |
622 | } |
594 | 623 | ||
595 | 624 | ||
596 | // ôóíêöèÿ 17 |
625 | // ôóíêöèÿ 17 |
597 | bool kos_GetButtonID( Dword &buttonID ) |
626 | bool kos_GetButtonID( Dword &buttonID ) |
598 | { |
627 | { |
599 | Dword result; |
628 | Dword result; |
600 | 629 | ||
601 | // |
630 | // |
602 | __asm{ |
631 | __asm{ |
603 | mov eax, 17 |
632 | mov eax, 17 |
604 | int 0x40 |
633 | int 0x40 |
605 | mov result, eax |
634 | mov result, eax |
606 | } |
635 | } |
607 | // |
636 | // |
608 | buttonID = result >> 8; |
637 | buttonID = result >> 8; |
609 | // |
638 | // |
610 | return (result & 0xFF) == 0; |
639 | return (result & 0xFF) == 0; |
611 | } |
640 | } |
612 | 641 | ||
613 | 642 | ||
614 | // ôóíêöèÿ 23 |
643 | // ôóíêöèÿ 23 |
615 | Dword kos_WaitForEvent( Dword timeOut ) |
644 | Dword kos_WaitForEvent( Dword timeOut ) |
616 | { |
645 | { |
617 | // Dword result; |
646 | // Dword result; |
618 | 647 | ||
619 | __asm{ |
648 | __asm{ |
620 | mov eax, 23 |
649 | mov eax, 23 |
621 | mov ebx, timeOut |
650 | mov ebx, timeOut |
622 | int 0x40 |
651 | int 0x40 |
623 | // mov result, eax |
652 | // mov result, eax |
624 | } |
653 | } |
625 | 654 | ||
626 | // return result; |
655 | // return result; |
627 | } |
656 | } |
628 | 657 | ||
629 | 658 | ||
630 | // ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" ôóíêöèÿ 37 |
659 | // ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" ôóíêöèÿ 37 |
631 | void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY ) |
660 | void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY ) |
632 | { |
661 | { |
633 | Dword mB; |
662 | Dword mB; |
634 | Word curX; |
663 | Word curX; |
635 | Word curY; |
664 | Word curY; |
636 | sProcessInfo sPI; |
665 | sProcessInfo sPI; |
637 | 666 | ||
638 | // |
667 | // |
639 | __asm{ |
668 | __asm{ |
640 | mov eax, 37 |
669 | mov eax, 37 |
641 | mov ebx, 0 |
670 | mov ebx, 0 |
642 | int 0x40 |
671 | int 0x40 |
643 | mov curY, ax |
672 | mov curY, ax |
644 | shr eax, 16 |
673 | shr eax, 16 |
645 | mov curX, ax |
674 | mov curX, ax |
646 | mov eax, 37 |
675 | mov eax, 37 |
647 | mov ebx, 2 |
676 | mov ebx, 2 |
648 | int 0x40 |
677 | int 0x40 |
649 | mov mB, eax |
678 | mov mB, eax |
650 | } |
679 | } |
651 | // |
680 | // |
652 | kos_ProcessInfo( &sPI ); |
681 | kos_ProcessInfo( &sPI ); |
653 | // |
682 | // |
654 | buttons = mB; |
683 | buttons = mB; |
655 | cursorX = curX - sPI.processInfo.x_start; |
684 | cursorX = curX - sPI.processInfo.x_start; |
656 | cursorY = curY - sPI.processInfo.y_start; |
685 | cursorY = curY - sPI.processInfo.y_start; |
657 | } |
686 | } |
658 | 687 | ||
659 | 688 | ||
660 | // ôóíêöèÿ 40 óñòàíîâèòü ìàñêó ñîáûòèé |
689 | // ôóíêöèÿ 40 óñòàíîâèòü ìàñêó ñîáûòèé |
661 | void kos_SetMaskForEvents( Dword mask ) |
690 | void kos_SetMaskForEvents( Dword mask ) |
662 | { |
691 | { |
663 | // |
692 | // |
664 | __asm{ |
693 | __asm{ |
665 | mov eax, 40 |
694 | mov eax, 40 |
666 | mov ebx, mask |
695 | mov ebx, mask |
667 | int 0x40 |
696 | int 0x40 |
668 | } |
697 | } |
669 | } |
698 | } |
670 | 699 | ||
671 | 700 | ||
672 | // ôóíêöèÿ 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî |
701 | // ôóíêöèÿ 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî |
673 | void kos_DisplayNumberToWindow( |
702 | void kos_DisplayNumberToWindow( |
674 | Dword value, |
703 | Dword value, |
675 | Dword digitsNum, |
704 | Dword digitsNum, |
676 | Word x, |
705 | Word x, |
677 | Word y, |
706 | Word y, |
678 | Dword colour, |
707 | Dword colour, |
679 | eNumberBase nBase, |
708 | eNumberBase nBase, |
680 | bool valueIsPointer |
709 | bool valueIsPointer |
681 | ) |
710 | ) |
682 | { |
711 | { |
683 | Dword arg1, arg2; |
712 | Dword arg1, arg2; |
684 | 713 | ||
685 | // |
714 | // |
686 | arg1 = ( valueIsPointer ? 1 : 0 ) | |
715 | arg1 = ( valueIsPointer ? 1 : 0 ) | |
687 | ( ((Byte)nBase) << 8 ) | |
716 | ( ((Byte)nBase) << 8 ) | |
688 | ( ( digitsNum & 0x1F ) << 16 ); |
717 | ( ( digitsNum & 0x1F ) << 16 ); |
689 | arg2 = ( x << 16 ) | y; |
718 | arg2 = ( x << 16 ) | y; |
690 | // |
719 | // |
691 | __asm{ |
720 | __asm{ |
692 | mov eax, 47 |
721 | mov eax, 47 |
693 | mov ebx, arg1 |
722 | mov ebx, arg1 |
694 | mov ecx, value |
723 | mov ecx, value |
695 | mov edx, arg2 |
724 | mov edx, arg2 |
696 | mov esi, colour |
725 | mov esi, colour |
697 | int 0x40 |
726 | int 0x40 |
698 | } |
727 | } |
699 | } |
728 | } |
700 | 729 | ||
701 | 730 | ||
702 | // ôóíêöèÿ 70 äîñòóï ê ôàéëîâîé ñèñòåìå |
731 | // ôóíêöèÿ 70 äîñòóï ê ôàéëîâîé ñèñòåìå |
703 | Dword kos_FileSystemAccess( kosFileInfo *fileInfo ) |
732 | Dword kos_FileSystemAccess( kosFileInfo *fileInfo ) |
704 | { |
733 | { |
705 | // Dword result; |
734 | // Dword result; |
706 | 735 | ||
707 | // |
736 | // |
708 | __asm{ |
737 | __asm{ |
709 | mov eax, 70 |
738 | mov eax, 70 |
710 | mov ebx, fileInfo |
739 | mov ebx, fileInfo |
711 | int 0x40 |
740 | int 0x40 |
712 | // mov result, eax |
741 | // mov result, eax |
713 | } |
742 | } |
714 | // |
743 | // |
715 | // return result; |
744 | // return result; |
716 | } |
745 | } |
717 | 746 | ||
718 | 747 | ||
719 | // ôóíêöèÿ 63 âûâîä ñèìâîëÿ â îêíî îòëàäêè |
748 | // ôóíêöèÿ 63 âûâîä ñèìâîëÿ â îêíî îòëàäêè |
720 | void kos_DebugOutChar( char ccc ) |
749 | void kos_DebugOutChar( char ccc ) |
721 | { |
750 | { |
722 | // |
751 | // |
723 | __asm{ |
752 | __asm{ |
724 | mov eax, 63 |
753 | mov eax, 63 |
725 | mov ebx, 1 |
754 | mov ebx, 1 |
726 | mov cl, ccc |
755 | mov cl, ccc |
727 | int 0x40 |
756 | int 0x40 |
728 | } |
757 | } |
729 | } |
758 | } |
730 | 759 | ||
731 | 760 | ||
732 | // ôóíêöèÿ 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû |
761 | // ôóíêöèÿ 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû |
733 | void kos_SetKeyboardDataMode( Dword mode ) |
762 | void kos_SetKeyboardDataMode( Dword mode ) |
734 | { |
763 | { |
735 | // |
764 | // |
736 | __asm{ |
765 | __asm{ |
737 | mov eax, 66 |
766 | mov eax, 66 |
738 | mov ebx, 1 |
767 | mov ebx, 1 |
739 | mov ecx, mode |
768 | mov ecx, mode |
740 | int 0x40 |
769 | int 0x40 |
741 | } |
770 | } |
742 | } |
771 | } |
743 | 772 | ||
744 | 773 | ||
745 | // âûâîä ñòðîêè â îêíî îòëàäêè |
774 | // âûâîä ñòðîêè â îêíî îòëàäêè |
746 | void rtlDebugOutString( char *str ) |
775 | void rtlDebugOutString( char *str ) |
747 | { |
776 | { |
748 | // |
777 | // |
749 | for ( ; str[0] != 0; str++ ) |
778 | for ( ; str[0] != 0; str++ ) |
750 | { |
779 | { |
751 | kos_DebugOutChar( str[0] ); |
780 | kos_DebugOutChar( str[0] ); |
752 | } |
781 | } |
753 | // |
782 | // |
754 | kos_DebugOutChar( 13 ); |
783 | kos_DebugOutChar( 13 ); |
755 | kos_DebugOutChar( 10 ); |
784 | kos_DebugOutChar( 10 ); |
756 | } |
785 | } |
757 | 786 | ||
758 | 787 | ||
759 | // âûäåëåíèå-îñâîáîæäåíèå-ïåðåðàñïðåäåëåíèå áëîêîâ ïàìÿòè |
788 | // âûäåëåíèå-îñâîáîæäåíèå-ïåðåðàñïðåäåëåíèå áëîêîâ ïàìÿòè |
760 | __declspec(naked) void* __stdcall kos_malloc(Dword size) |
789 | __declspec(naked) void* __stdcall kos_malloc(Dword size) |
761 | { |
790 | { |
762 | __asm |
791 | __asm |
763 | { |
792 | { |
764 | push ebx |
793 | push ebx |
765 | push ecx |
794 | push ecx |
766 | mov ecx, [esp+12] |
795 | mov ecx, [esp+12] |
767 | mov eax, 68 |
796 | mov eax, 68 |
768 | mov ebx, 12 |
797 | mov ebx, 12 |
769 | int 0x40 |
798 | int 0x40 |
770 | pop ecx |
799 | pop ecx |
771 | pop ebx |
800 | pop ebx |
772 | ret 4 |
801 | ret 4 |
773 | } |
802 | } |
774 | } |
803 | } |
775 | __declspec(naked) void __stdcall kos_free(void* mptr) |
804 | __declspec(naked) void __stdcall kos_free(void* mptr) |
776 | { |
805 | { |
777 | __asm |
806 | __asm |
778 | { |
807 | { |
779 | push ebx |
808 | push ebx |
780 | push ecx |
809 | push ecx |
781 | mov ecx, [esp+12] |
810 | mov ecx, [esp+12] |
782 | mov eax, 68 |
811 | mov eax, 68 |
783 | mov ebx, 13 |
812 | mov ebx, 13 |
784 | int 0x40 |
813 | int 0x40 |
785 | pop ecx |
814 | pop ecx |
786 | pop ebx |
815 | pop ebx |
787 | ret 4 |
816 | ret 4 |
788 | } |
817 | } |
789 | } |
818 | } |
790 | __declspec(naked) void* __stdcall kos_realloc(void* mptr, Dword size) |
819 | __declspec(naked) void* __stdcall kos_realloc(void* mptr, Dword size) |
791 | { |
820 | { |
792 | __asm |
821 | __asm |
793 | { |
822 | { |
794 | push ebx |
823 | push ebx |
795 | push ecx |
824 | push ecx |
796 | push edx |
825 | push edx |
797 | mov eax, 68 |
826 | mov eax, 68 |
798 | mov ebx, 20 |
827 | mov ebx, 20 |
799 | mov ecx, [esp+20] |
828 | mov ecx, [esp+20] |
800 | mov edx, [esp+16] |
829 | mov edx, [esp+16] |
801 | int 0x40 |
830 | int 0x40 |
802 | pop edx |
831 | pop edx |
803 | pop ecx |
832 | pop ecx |
804 | pop ebx |
833 | pop ebx |
805 | ret 8 |
834 | ret 8 |
806 | } |
835 | } |
807 | } |
836 | } |
808 | 837 | ||
809 | // ôóíêöèÿ 67 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ |
838 | // ôóíêöèÿ 67 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ |
810 | void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY ) |
839 | void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY ) |
811 | { |
840 | { |
812 | // |
841 | // |
813 | __asm{ |
842 | __asm{ |
814 | mov eax, 67 |
843 | mov eax, 67 |
815 | mov ebx, x |
844 | mov ebx, x |
816 | mov ecx, y |
845 | mov ecx, y |
817 | mov edx, sizeX |
846 | mov edx, sizeX |
818 | mov esi, sizeY |
847 | mov esi, sizeY |
819 | int 0x40 |
848 | int 0x40 |
820 | } |
849 | } |
821 | } |
850 | } |
822 | 851 | ||
823 | 852 | ||
824 | 853 | ||
825 | // âûçîâ àáñòðàêòíîãî ìåòîäà |
854 | // âûçîâ àáñòðàêòíîãî ìåòîäà |
826 | int __cdecl _purecall() |
855 | int __cdecl _purecall() |
827 | { |
856 | { |
828 | rtlDebugOutString( pureCallMessage ); |
857 | rtlDebugOutString( pureCallMessage ); |
829 | kos_ExitApp(); |
858 | kos_ExitApp(); |
830 | return 0; |
859 | return 0; |
831 | } |
860 | } |
832 | 861 | ||
833 | 862 | ||
834 | // âûçîâ ñòàòè÷åñêèõ èíèöèàëèçàòîðîâ |
863 | // âûçîâ ñòàòè÷åñêèõ èíèöèàëèçàòîðîâ |
835 | // çàîäíî èíèöèàëèçàöèÿ ãåíåðàòîðà ñëó÷àéíûõ ÷èñåë |
864 | // çàîäíî èíèöèàëèçàöèÿ ãåíåðàòîðà ñëó÷àéíûõ ÷èñåë |
836 | #pragma section(".CRT$XCA",long,read,write) |
865 | #pragma section(".CRT$XCA",long,read,write) |
837 | #pragma section(".CRT$XCZ",long,read,write) |
866 | #pragma section(".CRT$XCZ",long,read,write) |
838 | typedef void (__cdecl *_PVFV)(void); |
867 | typedef void (__cdecl *_PVFV)(void); |
839 | __declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { NULL }; |
868 | __declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { NULL }; |
840 | __declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL }; |
869 | __declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL }; |
841 | // |
870 | // |
842 | #pragma comment(linker, "/merge:.CRT=.rdata") |
871 | #pragma comment(linker, "/merge:.CRT=.rdata") |
843 | // |
872 | // |
844 | void crtStartUp() |
873 | void crtStartUp() |
845 | { |
874 | { |
- | 875 | #ifdef AUTOBUILD |
|
- | 876 | // linker will try to remove unused variables; force header to be included |
|
- | 877 | header.header; |
|
- | 878 | #endif |
|
846 | // èíèöèàëèçèðóåì êó÷ó |
879 | // èíèöèàëèçèðóåì êó÷ó |
847 | __asm |
880 | __asm |
848 | { |
881 | { |
849 | mov eax, 68 |
882 | mov eax, 68 |
850 | mov ebx, 11 |
883 | mov ebx, 11 |
851 | int 40h |
884 | int 40h |
852 | } |
885 | } |
853 | // âûçûâàåì èíèöèàëèçàòîðû ïî ñïèñêó, NULL'û èãíîðèðóåì |
886 | // âûçûâàåì èíèöèàëèçàòîðû ïî ñïèñêó, NULL'û èãíîðèðóåì |
854 | for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) |
887 | for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) |
855 | { |
888 | { |
856 | // |
889 | // |
857 | if ( *pbegin != NULL ) |
890 | if ( *pbegin != NULL ) |
858 | (**pbegin)(); |
891 | (**pbegin)(); |
859 | } |
892 | } |
860 | // èíèöèàëèçèðóåì ãåíåðàòîð ñëó÷àéíûõ ÷èñåë |
893 | // èíèöèàëèçèðóåì ãåíåðàòîð ñëó÷àéíûõ ÷èñåë |
861 | rtlSrand( kos_GetSystemClock() ); |
894 | rtlSrand( kos_GetSystemClock() ); |
- | 895 | #ifndef AUTOBUILD |
|
862 | // ïóòü ê ôàéëó ïðîöåññà |
896 | // ïóòü ê ôàéëó ïðîöåññà |
863 | kosExePath = *((char **)0x20); |
897 | kosExePath = *((char **)0x20); |
- | 898 | #endif |
|
864 | // âûçîâ ãëàâíîé ôóíêöèè ïðèëîæåíèÿ |
899 | // âûçîâ ãëàâíîé ôóíêöèè ïðèëîæåíèÿ |
865 | kos_Main(); |
900 | kos_Main(); |
866 | // âûõîä |
901 | // âûõîä |
867 | kos_ExitApp(); |
902 | kos_ExitApp(); |
868 | } |
903 | } |
869 | 904 | ||
870 | // sysfn 71.1 |
905 | // sysfn 71.1 |
871 | void kos_ChangeWindowCaption( |
906 | void kos_ChangeWindowCaption( |
872 | char *textPtr |
907 | char *textPtr |
873 | ) |
908 | ) |
874 | { |
909 | { |
875 | __asm{ |
910 | __asm{ |
876 | mov eax, 71 |
911 | mov eax, 71 |
877 | mov ebx, 1 |
912 | mov ebx, 1 |
878 | mov ecx, textPtr |
913 | mov ecx, textPtr |
879 | int 0x40 |
914 | int 0x40 |
880 | } |
915 | } |
881 | }>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>>>><>>> |
916 | }>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>>>><>>> |