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