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