Rev 8436 | Rev 8452 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8436 | Rev 8446 | ||
---|---|---|---|
1 | #include "kolibri.h" |
1 | #include "kolibri.h" |
2 | #include "string.h" |
2 | #include "string.h" |
3 | #include |
3 | #include |
4 | 4 | ||
5 | 5 | ||
6 | extern char KOL_PATH[256]; |
6 | extern char KOL_PATH[256]; |
7 | extern char KOL_PARAM[256]; |
7 | extern char KOL_PARAM[256]; |
8 | extern char KOL_DIR[256]; |
8 | extern char KOL_DIR[256]; |
9 | 9 | ||
10 | 10 | ||
11 | void kol_exit() |
11 | void kol_exit() |
12 | { |
12 | { |
13 | asm volatile ("int $0x40"::"a"(-1)); |
13 | asm volatile ("int $0x40"::"a"(-1)); |
14 | } |
14 | } |
15 | 15 | ||
16 | 16 | ||
17 | void kol_sleep(unsigned d) |
17 | void kol_sleep(unsigned d) |
18 | { |
18 | { |
19 | asm volatile ("int $0x40"::"a"(5), "b"(d)); |
19 | asm volatile ("int $0x40"::"a"(5), "b"(d)); |
20 | } |
20 | } |
21 | 21 | ||
22 | 22 | ||
23 | // define a window |
23 | // define a window |
24 | // x, y - position; w, h - size; cs - color and style; c - caption; b - boder |
24 | // x, y - position; w, h - size; cs - color and style; c - caption; b - boder |
25 | void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t) |
25 | void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t) |
26 | { |
26 | { |
27 | asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) ); |
27 | asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) ); |
28 | } |
28 | } |
29 | 29 | ||
30 | 30 | ||
31 | void kol_wnd_move(unsigned x, unsigned y) |
31 | void kol_wnd_move(unsigned x, unsigned y) |
32 | { |
32 | { |
33 | asm volatile ("int $0x40"::"a"(67), "b"(x), "c"(y), "d"(-1), "S"(-1)); |
33 | asm volatile ("int $0x40"::"a"(67), "b"(x), "c"(y), "d"(-1), "S"(-1)); |
34 | } |
34 | } |
35 | 35 | ||
36 | 36 | ||
37 | void kol_event_mask(unsigned e) |
37 | void kol_event_mask(unsigned e) |
38 | { |
38 | { |
39 | asm volatile ("int $0x40"::"a"(40), "b"(e)); |
39 | asm volatile ("int $0x40"::"a"(40), "b"(e)); |
40 | } |
40 | } |
41 | 41 | ||
42 | 42 | ||
43 | unsigned kol_event_wait() |
43 | unsigned kol_event_wait() |
44 | { |
44 | { |
45 | asm volatile ("int $0x40"::"a"(10)); |
45 | asm volatile ("int $0x40"::"a"(10)); |
46 | } |
46 | } |
47 | 47 | ||
48 | 48 | ||
49 | unsigned kol_event_wait_time(unsigned time) |
49 | unsigned kol_event_wait_time(unsigned time) |
50 | { |
50 | { |
51 | asm volatile ("int $0x40"::"a"(23), "b"(time)); |
51 | asm volatile ("int $0x40"::"a"(23), "b"(time)); |
52 | } |
52 | } |
53 | 53 | ||
54 | 54 | ||
55 | unsigned kol_event_check() |
55 | unsigned kol_event_check() |
56 | { |
56 | { |
57 | asm volatile ("int $0x40"::"a"(11)); |
57 | asm volatile ("int $0x40"::"a"(11)); |
58 | } |
58 | } |
59 | 59 | ||
60 | 60 | ||
61 | inline void __attribute__((__always_inline__)) kol_paint_start() |
61 | inline void __attribute__((__always_inline__)) kol_paint_start() |
62 | { |
62 | { |
63 | asm volatile ("int $0x40"::"a"(12), "b"(1)); |
63 | asm volatile ("int $0x40"::"a"(12), "b"(1)); |
64 | } |
64 | } |
65 | 65 | ||
66 | 66 | ||
67 | inline void __attribute__((__always_inline__)) kol_paint_end() |
67 | inline void __attribute__((__always_inline__)) kol_paint_end() |
68 | { |
68 | { |
69 | asm volatile ("int $0x40"::"a"(12), "b"(2)); |
69 | asm volatile ("int $0x40"::"a"(12), "b"(2)); |
70 | } |
70 | } |
71 | 71 | ||
72 | 72 | ||
73 | void kol_paint_pixel(unsigned x, unsigned y, unsigned c) |
73 | void kol_paint_pixel(unsigned x, unsigned y, unsigned c) |
74 | { |
74 | { |
75 | asm volatile ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); |
75 | asm volatile ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c)); |
76 | } |
76 | } |
77 | 77 | ||
78 | 78 | ||
79 | void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) |
79 | void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) |
80 | { |
80 | { |
81 | asm volatile ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); |
81 | asm volatile ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); |
82 | } |
82 | } |
83 | 83 | ||
84 | 84 | ||
85 | void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c) |
85 | void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c) |
86 | { |
86 | { |
87 | asm volatile ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); |
87 | asm volatile ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c)); |
88 | } |
88 | } |
89 | 89 | ||
90 | 90 | ||
91 | void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c) |
91 | void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c) |
92 | { |
92 | { |
93 | asm volatile ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); |
93 | asm volatile ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s)); |
94 | } |
94 | } |
95 | 95 | ||
96 | 96 | ||
97 | void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d) |
97 | void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d) |
98 | { |
98 | { |
99 | asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); |
99 | asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d)); |
100 | } |
100 | } |
101 | 101 | ||
102 | 102 | ||
103 | void kol_paint_image_24(unsigned x, unsigned y, unsigned w, unsigned h, char *d) |
103 | void kol_paint_image_24(unsigned x, unsigned y, unsigned w, unsigned h, char *d) |
104 | { |
104 | { |
105 | asm volatile ("int $0x40"::"a"(65), "b"(d), "c"(w*65536+h), "d"(x*65536+y), "S"(32)); |
105 | asm volatile ("int $0x40"::"a"(65), "b"(d), "c"(w*65536+h), "d"(x*65536+y), "S"(32)); |
106 | } |
106 | } |
107 | 107 | ||
108 | 108 | ||
109 | unsigned kol_key_get() |
109 | unsigned kol_key_get() |
110 | { |
110 | { |
111 | asm volatile ("int $0x40"::"a"(2)); |
111 | asm volatile ("int $0x40"::"a"(2)); |
112 | } |
112 | } |
113 | 113 | ||
114 | 114 | ||
115 | unsigned kol_key_control() |
115 | unsigned kol_key_control() |
116 | { |
116 | { |
117 | asm volatile ("int $0x40"::"a"(66), "b"(3)); |
117 | asm volatile ("int $0x40"::"a"(66), "b"(3)); |
118 | } |
118 | } |
119 | 119 | ||
120 | 120 | ||
121 | void kol_key_lang_set(unsigned lang) |
121 | void kol_key_lang_set(unsigned lang) |
122 | { |
122 | { |
123 | asm volatile ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); |
123 | asm volatile ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang)); |
124 | } |
124 | } |
125 | 125 | ||
126 | 126 | ||
127 | unsigned kol_key_lang_get() |
127 | unsigned kol_key_lang_get() |
128 | { |
128 | { |
129 | asm volatile ("int $0x40"::"a"(26), "b"(2), "c"(9)); |
129 | asm volatile ("int $0x40"::"a"(26), "b"(2), "c"(9)); |
130 | } |
130 | } |
131 | 131 | ||
132 | 132 | ||
133 | void kol_key_mode_set(unsigned mode) |
133 | void kol_key_mode_set(unsigned mode) |
134 | { |
134 | { |
135 | asm volatile ("int $0x40"::"a"(66), "b"(1), "c"(mode)); |
135 | asm volatile ("int $0x40"::"a"(66), "b"(1), "c"(mode)); |
136 | } |
136 | } |
137 | 137 | ||
138 | 138 | ||
139 | unsigned kol_key_mode_get() |
139 | unsigned kol_key_mode_get() |
140 | { |
140 | { |
141 | asm volatile ("int $0x40"::"a"(66), "b"(2)); |
141 | asm volatile ("int $0x40"::"a"(66), "b"(2)); |
142 | } |
142 | } |
143 | 143 | ||
144 | 144 | ||
145 | unsigned kol_btn_get() |
145 | unsigned kol_btn_get() |
146 | { |
146 | { |
147 | asm volatile ("int $0x40"::"a"(17)); |
147 | asm volatile ("int $0x40"::"a"(17)); |
148 | } |
148 | } |
149 | 149 | ||
150 | 150 | ||
151 | void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c) |
151 | void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c) |
152 | { |
152 | { |
153 | asm volatile ("int $0x40"::"a"(8), "b"(x*65536+w), "c"(y*65536+h), "d"(d), "S"(c)); |
153 | asm volatile ("int $0x40"::"a"(8), "b"(x*65536+w), "c"(y*65536+h), "d"(d), "S"(c)); |
154 | } |
154 | } |
155 | 155 | ||
156 | 156 | ||
157 | void kol_btn_type(unsigned t) |
157 | void kol_btn_type(unsigned t) |
158 | { |
158 | { |
159 | asm volatile ("int $0x40"::"a"(48), "b"(1), "c"(t)); |
159 | asm volatile ("int $0x40"::"a"(48), "b"(1), "c"(t)); |
160 | } |
160 | } |
161 | 161 | ||
162 | 162 | ||
163 | void kol_wnd_caption(char *s) |
163 | void kol_wnd_caption(char *s) |
164 | { |
164 | { |
165 | asm volatile ("int $0x40"::"a"(71), "b"(1), "c"(s)); |
165 | asm volatile ("int $0x40"::"a"(71), "b"(1), "c"(s)); |
166 | } |
166 | } |
167 | 167 | ||
168 | 168 | ||
169 | unsigned kol_mouse_pos() |
169 | unsigned kol_mouse_pos() |
170 | { |
170 | { |
171 | asm volatile ("int $0x40"::"a"(37), "b"(0)); |
171 | asm volatile ("int $0x40"::"a"(37), "b"(0)); |
172 | } |
172 | } |
173 | 173 | ||
174 | 174 | ||
175 | unsigned kol_mouse_posw() |
175 | unsigned kol_mouse_posw() |
176 | { |
176 | { |
177 | asm volatile ("int $0x40"::"a"(37), "b"(1)); |
177 | asm volatile ("int $0x40"::"a"(37), "b"(1)); |
178 | } |
178 | } |
179 | 179 | ||
180 | 180 | ||
181 | unsigned kol_mouse_btn() |
181 | unsigned kol_mouse_btn() |
182 | { |
182 | { |
183 | asm volatile ("int $0x40"::"a"(37), "b"(2)); |
183 | asm volatile ("int $0x40"::"a"(37), "b"(2)); |
184 | } |
184 | } |
185 | 185 | ||
186 | 186 | ||
187 | void kol_board_putc(char c) |
187 | void kol_board_putc(char c) |
188 | { |
188 | { |
189 | asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); |
189 | asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); |
190 | } |
190 | } |
191 | 191 | ||
192 | 192 | ||
193 | void kol_board_puts(char *s) |
193 | void kol_board_puts(char *s) |
194 | { |
194 | { |
195 | unsigned i; |
195 | unsigned i; |
196 | i = 0; |
196 | i = 0; |
197 | while (*(s+i)) |
197 | while (*(s+i)) |
198 | { |
198 | { |
199 | asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); |
199 | asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); |
200 | i++; |
200 | i++; |
201 | } |
201 | } |
202 | } |
202 | } |
203 | 203 | ||
204 | 204 | ||
205 | void kol_board_puti(int n) |
205 | void kol_board_puti(int n) |
206 | { |
206 | { |
207 | char c; |
207 | char c; |
208 | 208 | ||
209 | if ( n > 1 ) |
209 | if ( n > 1 ) |
210 | kol_board_puti(n / 10); |
210 | kol_board_puti(n / 10); |
211 | 211 | ||
212 | c = n % 10 + '0'; |
212 | c = n % 10 + '0'; |
213 | asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); |
213 | asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c)); |
214 | 214 | ||
215 | } |
215 | } |
216 | 216 | ||
217 | 217 | ||
218 | int kol_file_70(kol_struct70 *k) |
218 | int kol_file_70(kol_struct70 *k) |
219 | { |
219 | { |
220 | asm volatile ("int $0x40"::"a"(70), "b"(k)); |
220 | asm volatile ("int $0x40"::"a"(70), "b"(k)); |
221 | } |
221 | } |
222 | 222 | ||
223 | 223 | ||
224 | kol_struct_import* kol_cofflib_load(char *name) |
224 | kol_struct_import* kol_cofflib_load(char *name) |
225 | { |
225 | { |
226 | asm volatile ("int $0x40"::"a"(68), "b"(19), "c"(name)); |
226 | asm volatile ("int $0x40"::"a"(68), "b"(19), "c"(name)); |
227 | } |
227 | } |
228 | 228 | ||
229 | 229 | ||
230 | void* kol_cofflib_procload (kol_struct_import *imp, char *name) |
230 | void* kol_cofflib_procload (kol_struct_import *imp, char *name) |
231 | { |
231 | { |
232 | int i; |
232 | int i; |
233 | for (i=0;;i++) |
233 | for (i=0;;i++) |
234 | if ( NULL == ((imp+i) -> name)) |
234 | if ( NULL == ((imp+i) -> name)) |
235 | break; |
235 | break; |
236 | else |
236 | else |
237 | if ( 0 == strcmp(name, (imp+i)->name) ) |
237 | if ( 0 == strcmp(name, (imp+i)->name) ) |
238 | return (imp+i)->data; |
238 | return (imp+i)->data; |
239 | return NULL; |
239 | return NULL; |
240 | } |
240 | } |
241 | 241 | ||
242 | 242 | ||
243 | unsigned kol_cofflib_procnum (kol_struct_import *imp) |
243 | unsigned kol_cofflib_procnum (kol_struct_import *imp) |
244 | { |
244 | { |
245 | unsigned i, n; |
245 | unsigned i, n; |
246 | 246 | ||
247 | for (i=n=0;;i++) |
247 | for (i=n=0;;i++) |
248 | if ( NULL == ((imp+i) -> name)) |
248 | if ( NULL == ((imp+i) -> name)) |
249 | break; |
249 | break; |
250 | else |
250 | else |
251 | n++; |
251 | n++; |
252 | 252 | ||
253 | return n; |
253 | return n; |
254 | } |
254 | } |
255 | 255 | ||
256 | 256 | ||
257 | void kol_cofflib_procname (kol_struct_import *imp, char *name, unsigned n) |
257 | void kol_cofflib_procname (kol_struct_import *imp, char *name, unsigned n) |
258 | { |
258 | { |
259 | unsigned i; |
259 | unsigned i; |
260 | *name = 0; |
260 | *name = 0; |
261 | 261 | ||
262 | for (i=0;;i++) |
262 | for (i=0;;i++) |
263 | if ( NULL == ((imp+i) -> name)) |
263 | if ( NULL == ((imp+i) -> name)) |
264 | break; |
264 | break; |
265 | else |
265 | else |
266 | if ( i == n ) |
266 | if ( i == n ) |
267 | { |
267 | { |
268 | strcpy(name, ((imp+i)->name)); |
268 | strcpy(name, ((imp+i)->name)); |
269 | break; |
269 | break; |
270 | } |
270 | } |
271 | 271 | ||
272 | } |
272 | } |
273 | 273 | ||
274 | 274 | ||
275 | unsigned kol_system_cpufreq() |
275 | unsigned kol_system_cpufreq() |
276 | { |
276 | { |
277 | asm volatile ("int $0x40"::"a"(18), "b"(5)); |
277 | asm volatile ("int $0x40"::"a"(18), "b"(5)); |
278 | } |
278 | } |
279 | 279 | ||
280 | 280 | ||
281 | unsigned kol_system_mem() |
281 | unsigned kol_system_mem() |
282 | { |
282 | { |
283 | asm volatile ("int $0x40"::"a"(18), "b"(17)); |
283 | asm volatile ("int $0x40"::"a"(18), "b"(17)); |
284 | } |
284 | } |
285 | 285 | ||
286 | 286 | ||
287 | unsigned kol_system_memfree() |
287 | unsigned kol_system_memfree() |
288 | { |
288 | { |
289 | asm volatile ("int $0x40"::"a"(18), "b"(16)); |
289 | asm volatile ("int $0x40"::"a"(18), "b"(16)); |
290 | } |
290 | } |
291 | 291 | ||
292 | 292 | ||
293 | unsigned kol_system_time_get() |
293 | unsigned kol_system_time_get() |
294 | { |
294 | { |
295 | asm volatile ("int $0x40"::"a"(3)); |
295 | asm volatile ("int $0x40"::"a"(3)); |
296 | } |
296 | } |
297 | 297 | ||
298 | 298 | ||
299 | unsigned kol_system_date_get() |
299 | unsigned kol_system_date_get() |
300 | { |
300 | { |
301 | asm volatile ("int $0x40"::"a"(29)); |
301 | asm volatile ("int $0x40"::"a"(29)); |
302 | } |
302 | } |
303 | 303 | ||
304 | 304 | ||
305 | unsigned kol_system_end(unsigned param) |
305 | unsigned kol_system_end(unsigned param) |
306 | { |
306 | { |
307 | asm volatile ("int $0x40"::"a"(18), "b"(9), "c"(param)); |
307 | asm volatile ("int $0x40"::"a"(18), "b"(9), "c"(param)); |
308 | } |
308 | } |
309 | 309 | ||
310 | 310 | ||
311 | void kol_path_file2dir(char *dir, char *fname) |
311 | void kol_path_file2dir(char *dir, char *fname) |
312 | { |
312 | { |
313 | unsigned i; |
313 | unsigned i; |
314 | strcpy (dir, fname); |
314 | strcpy (dir, fname); |
315 | for ( i = strlen(dir);; --i) |
315 | for ( i = strlen(dir);; --i) |
316 | if ( '/' == dir[i]) |
316 | if ( '/' == dir[i]) |
317 | { |
317 | { |
318 | dir[i] = '\0'; |
318 | dir[i] = '\0'; |
319 | return; |
319 | return; |
320 | } |
320 | } |
321 | } |
321 | } |
322 | 322 | ||
323 | 323 | ||
324 | void kol_path_full(char *full, char *fname) |
324 | void kol_path_full(char *full, char *fname) |
325 | { |
325 | { |
326 | char temp[256]; |
326 | char temp[256]; |
327 | 327 | ||
328 | switch (*fname) |
328 | switch (*fname) |
329 | { |
329 | { |
330 | 330 | ||
331 | case '/': |
331 | case '/': |
332 | strncpy(temp, fname+1, 2); |
332 | strncpy(temp, fname+1, 2); |
333 | temp[2]=0; |
333 | temp[2]=0; |
334 | if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) |
334 | if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) ) |
335 | strcpy (full, fname); |
335 | strcpy (full, fname); |
336 | break; |
336 | break; |
337 | 337 | ||
338 | case '.': |
338 | case '.': |
339 | break; |
339 | break; |
340 | 340 | ||
341 | default: |
341 | default: |
342 | break; |
342 | break; |
343 | 343 | ||
344 | }; |
344 | }; |
345 | 345 | ||
346 | } |
346 | } |
347 | 347 | ||
348 | 348 | ||
349 | 349 | ||
350 | inline void __attribute__((__always_inline__)) kol_screen_wait_rr() |
350 | inline void __attribute__((__always_inline__)) kol_screen_wait_rr() |
351 | { |
351 | { |
352 | asm volatile ("int $0x40"::"a"(18), "b"(14)); |
352 | asm volatile ("int $0x40"::"a"(18), "b"(14)); |
353 | } |
353 | } |
354 | 354 | ||
355 | 355 | ||
356 | 356 | ||
357 | void kol_screen_get_size(unsigned *w, unsigned *h) |
357 | void kol_screen_get_size(unsigned *w, unsigned *h) |
358 | { |
358 | { |
359 | unsigned size; |
359 | unsigned size; |
360 | asm volatile ("int $0x40":"=a"(size):"a"(14)); |
360 | asm volatile ("int $0x40":"=a"(size):"a"(14)); |
361 | *w = size / 65536; |
361 | *w = size / 65536; |
362 | *h = size % 65536; |
362 | *h = size % 65536; |
363 | } |
363 | } |
364 | 364 | ||
365 | 365 | ||
366 | 366 | ||
367 | unsigned kol_skin_height() |
367 | unsigned kol_skin_height() |
368 | { |
368 | { |
369 | asm volatile ("int $0x40"::"a"(48), "b"(4)); |
369 | asm volatile ("int $0x40"::"a"(48), "b"(4)); |
370 | } |
370 | } |
371 | 371 | ||
372 | 372 | ||
373 | unsigned kol_thread_start(unsigned start, unsigned stack) |
373 | unsigned kol_thread_start(unsigned start, unsigned stack) |
374 | { |
374 | { |
375 | asm volatile ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); |
375 | asm volatile ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack)); |
376 | } |
376 | } |
377 | 377 | ||
378 | 378 | ||
379 | unsigned kol_time_tick() |
379 | unsigned kol_time_tick() |
380 | { |
380 | { |
381 | asm volatile ("int $0x40"::"a"(26), "b"(9)); |
381 | asm volatile ("int $0x40"::"a"(26), "b"(9)); |
382 | } |
382 | } |
383 | 383 | ||
384 | 384 | ||
385 | unsigned kol_sound_speaker(char data[]) |
385 | unsigned kol_sound_speaker(char data[]) |
386 | { |
386 | { |
387 | asm volatile ("movl %0, %%esi"::"a"(data)); |
387 | asm volatile ("movl %0, %%esi"::"a"(data)); |
388 | asm volatile ("int $0x40"::"a"(55), "b"(55)); |
388 | asm volatile ("int $0x40"::"a"(55), "b"(55)); |
389 | } |
389 | } |
390 | 390 | ||
391 | 391 | ||
392 | unsigned kol_process_info(unsigned slot, char buf1k[]) |
392 | unsigned kol_process_info(unsigned slot, char buf1k[]) |
393 | { |
393 | { |
394 | asm volatile ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); |
394 | asm volatile ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot)); |
395 | } |
395 | } |
396 | 396 | ||
397 | 397 | ||
398 | int kol_process_kill_pid(unsigned process) |
398 | int kol_process_kill_pid(unsigned process) |
399 | { |
399 | { |
400 | asm volatile ("int $0x40"::"a"(18), "b"(18), "c"(process)); |
400 | asm volatile ("int $0x40"::"a"(18), "b"(18), "c"(process)); |
401 | } |
401 | } |
402 | 402 | ||
403 | int kol_kill_process(unsigned process) |
403 | int kol_kill_process(unsigned process) |
404 | { |
404 | { |
405 | asm volatile ("int $0x40"::"a"(18), "b"(2), "c"(process)); |
405 | asm volatile ("int $0x40"::"a"(18), "b"(2), "c"(process)); |
406 | } |
406 | } |
407 | 407 | ||
408 | void kol_get_kernel_ver(char buff16b[]) |
408 | void kol_get_kernel_ver(char buff16b[]) |
409 | { |
409 | { |
410 | asm volatile ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); |
410 | asm volatile ("int $0x40"::"a"(18), "b"(13), "c"(buff16b)); |
411 | } |
411 | } |
412 | 412 | ||
413 | int kol_buffer_open(char name[], int mode, int size, char **buf) |
413 | int kol_buffer_open(char name[], int mode, int size, char **buf) |
414 | { |
414 | { |
415 | int error; |
415 | int error; |
416 | asm volatile ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); |
416 | asm volatile ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); |
417 | return error; |
417 | return error; |
418 | } |
418 | } |
419 | 419 | ||
420 | void kol_buffer_close(char name[]) |
420 | void kol_buffer_close(char name[]) |
421 | { |
421 | { |
422 | asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name)); |
422 | asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name)); |
423 | } |
423 | } |
424 | 424 | ||
425 | int kol_clip_num() |
425 | int kol_clip_num() |
426 | { |
426 | { |
427 | asm volatile ("int $0x40"::"a"(54), "b"(0)); |
427 | asm volatile ("int $0x40"::"a"(54), "b"(0)); |
428 | } |
428 | } |
429 | 429 | ||
430 | char* kol_clip_get(int n) |
430 | char* kol_clip_get(int n) |
431 | { |
431 | { |
432 | asm volatile ("int $0x40"::"a"(54), "b"(1), "c"(n)); |
432 | asm volatile ("int $0x40"::"a"(54), "b"(1), "c"(n)); |
433 | } |
433 | } |
434 | 434 | ||
435 | int kol_clip_set(int n, char buffer[]) |
435 | int kol_clip_set(int n, char buffer[]) |
436 | { |
436 | { |
437 | asm volatile ("int $0x40"::"a"(54), "b"(2), "c"(n), "d"(buffer)); |
437 | asm volatile ("int $0x40"::"a"(54), "b"(2), "c"(n), "d"(buffer)); |
438 | } |
438 | } |
439 | 439 | ||
440 | int kos_random(int num) |
440 | int kos_random(int num) |
441 | { |
441 | { |
442 | srand(kol_time_tick()); |
442 | srand(kol_time_tick()); |
443 | return rand() % num; |
443 | return rand() % num; |
444 | } |
444 | } |
445 | 445 | ||
446 | int kos_get_mouse_wheels(void) |
446 | int kos_get_mouse_wheels(void) |
447 | { |
447 | { |
448 | int val; |
448 | int val; |
449 | asm ("int $0x40":"=a"(val):"a"(37),"b"(7)); |
449 | asm ("int $0x40":"=a"(val):"a"(37),"b"(7)); |
450 | return val; |
450 | return val; |
451 | }; |
451 | }; |
452 | 452 | ||
453 | 453 | ||
454 | struct blit_call |
454 | struct blit_call |
455 | { |
455 | { |
456 | int dstx; |
456 | int dstx; |
457 | int dsty; |
457 | int dsty; |
458 | int w; |
458 | int w; |
459 | int h; |
459 | int h; |
460 | 460 | ||
461 | int srcx; |
461 | int srcx; |
462 | int srcy; |
462 | int srcy; |
463 | int srcw; |
463 | int srcw; |
464 | int srch; |
464 | int srch; |
465 | 465 | ||
466 | unsigned char *d; |
466 | unsigned char *d; |
467 | int stride; |
467 | int stride; |
468 | }; |
468 | }; |
469 | 469 | ||
470 | void kos_blit(int dstx, int dsty, int w, int h, int srcx, |
470 | void kos_blit(int dstx, int dsty, int w, int h, int srcx, |
471 | int srcy,int srcw, int srch, int stride, char *d) |
471 | int srcy,int srcw, int srch, int stride, char *d) |
472 | { |
472 | { |
473 | volatile struct blit_call image; |
473 | volatile struct blit_call image; |
474 | image.dstx=dstx; |
474 | image.dstx=dstx; |
475 | image.dsty=dsty; |
475 | image.dsty=dsty; |
476 | image.w=w; |
476 | image.w=w; |
477 | image.h=h; |
477 | image.h=h; |
478 | image.srcx=srcx; |
478 | image.srcx=srcx; |
479 | image.srcy=srcy; |
479 | image.srcy=srcy; |
480 | image.srcw=srcw; |
480 | image.srcw=srcw; |
481 | image.srch=srch; |
481 | image.srch=srch; |
482 | image.stride=stride; |
482 | image.stride=stride; |
483 | image.d=d; |
483 | image.d=d; |
484 | asm("int $0x40"::"a"(73),"b"(0),"c"(&image)); |
484 | asm("int $0x40"::"a"(73),"b"(0),"c"(&image)); |
485 | 485 | ||
486 | } |
486 | } |
- | 487 | ||
- | 488 | void kos_move_window(int posx, int posy, int sizex, int sizey) |
|
- | 489 | { |
|
- | 490 | __asm__ __volatile__( |
|
- | 491 | "int $0x40" |
|
- | 492 | ::"a"(67), |
|
- | 493 | "b"(posx), |
|
- | 494 | "c"(posy), |
|
- | 495 | "d"(sizex), |
|
- | 496 | "S"(sizey)); |
|
- | 497 | }; |
|
- | 498 | ||
- | 499 | void kos_text(int x, int y, int color, const char* text, int len) |
|
- | 500 | { |
|
- | 501 | asm volatile ("int $0x40"::"a"(4),"b"((x<<16) | y),"c"(color),"d"((unsigned long)text),"S"(len)); |
|
- | 502 | }; |
|
- | 503 | ||
- | 504 | void kos_screen_max(int* x, int* y) |
|
- | 505 | { |
|
- | 506 | unsigned long v; |
|
- | 507 | __asm__ __volatile__( |
|
- | 508 | "int $0x40" |
|
- | 509 | :"=a"(v) |
|
- | 510 | :"a"(14)); |
|
- | 511 | ||
- | 512 | if(x) *x = v >> 16; |
|
- | 513 | if(y) *y = v & 0xFFFF; |
|
- | 514 | }; |
|
- | 515 | ||
- | 516 | int kol_get_key() |
|
- | 517 | { |
|
- | 518 | unsigned short __ret; |
|
- | 519 | asm volatile("int $0x40":"=a"(__ret):"0"(2)); |
|
- | 520 | if(!(__ret & 0xFF)) return (__ret>>8)&0xFF; else return 0; |
|
- | 521 | }16)><16)> |