Rev 5369 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5369 | Rev 5552 | ||
---|---|---|---|
1 | #ifndef __KOS_32_SYS_H__ |
1 | #ifndef __KOS_32_SYS_H__ |
2 | #define __KOS_32_SYS_H__ |
2 | #define __KOS_32_SYS_H__ |
3 | 3 | ||
4 | #include |
4 | #include |
5 | #include |
5 | #include |
6 | #include |
6 | #include |
7 | 7 | ||
8 | #ifdef __cplusplus |
8 | #ifdef __cplusplus |
9 | extern "C" { |
9 | extern "C" { |
10 | #endif |
10 | #endif |
11 | 11 | ||
12 | //#ifdef CONFIG_DEBUF |
12 | //#ifdef CONFIG_DEBUF |
13 | // #define DBG(format,...) printf(format,##__VA_ARGS__) |
13 | // #define DBG(format,...) printf(format,##__VA_ARGS__) |
14 | //#else |
14 | //#else |
15 | // #define DBG(format,...) |
15 | // #define DBG(format,...) |
16 | //#endif |
16 | //#endif |
17 | 17 | ||
18 | #define TYPE_3_BORDER_WIDTH 5 |
18 | #define TYPE_3_BORDER_WIDTH 5 |
19 | #define WIN_STATE_MINIMIZED 0x02 |
19 | #define WIN_STATE_MINIMIZED 0x02 |
20 | #define WIN_STATE_ROLLED 0x04 |
20 | #define WIN_STATE_ROLLED 0x04 |
21 | 21 | ||
22 | typedef unsigned int color_t; |
22 | typedef unsigned int color_t; |
23 | 23 | ||
24 | typedef union __attribute__((packed)) |
24 | typedef union __attribute__((packed)) |
25 | { |
25 | { |
26 | uint32_t val; |
26 | uint32_t val; |
27 | struct |
27 | struct |
28 | { |
28 | { |
29 | short x; |
29 | short x; |
30 | short y; |
30 | short y; |
31 | }; |
31 | }; |
32 | }pos_t; |
32 | }pos_t; |
33 | 33 | ||
34 | typedef union __attribute__((packed)) |
34 | typedef union __attribute__((packed)) |
35 | { |
35 | { |
36 | uint32_t val; |
36 | uint32_t val; |
37 | struct |
37 | struct |
38 | { |
38 | { |
39 | uint8_t state; |
39 | uint8_t state; |
40 | uint8_t code; |
40 | uint8_t code; |
41 | uint16_t ctrl_key; |
41 | uint16_t ctrl_key; |
42 | }; |
42 | }; |
43 | }oskey_t; |
43 | }oskey_t; |
44 | 44 | ||
45 | typedef struct |
45 | typedef struct |
46 | { |
46 | { |
47 | unsigned handle; |
47 | unsigned handle; |
48 | unsigned io_code; |
48 | unsigned io_code; |
49 | void *input; |
49 | void *input; |
50 | int inp_size; |
50 | int inp_size; |
51 | void *output; |
51 | void *output; |
52 | int out_size; |
52 | int out_size; |
53 | }ioctl_t; |
53 | }ioctl_t; |
54 | 54 | ||
55 | 55 | ||
56 | static inline |
56 | static inline |
57 | void DefineButton(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color) |
57 | void define_button(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color) |
58 | { |
58 | { |
59 | __asm__ __volatile__( |
59 | __asm__ __volatile__( |
60 | "int $0x40" |
60 | "int $0x40" |
61 | ::"a"(8), |
61 | ::"a"(8), |
62 | "b"(x_w), |
62 | "b"(x_w), |
63 | "c"(y_h), |
63 | "c"(y_h), |
64 | "d"(id), |
64 | "d"(id), |
65 | "S"(color)); |
65 | "S"(color)); |
66 | - | ||
67 | - | ||
68 | }; |
66 | }; |
- | 67 | static inline void DefineButton(void) __attribute__ ((alias ("define_button"))); |
|
69 | 68 | ||
70 | static inline |
69 | static inline |
71 | uint32_t get_skin_height(void) |
70 | uint32_t get_skin_height(void) |
72 | { |
71 | { |
73 | uint32_t height; |
72 | uint32_t height; |
74 | 73 | ||
75 | __asm__ __volatile__( |
74 | __asm__ __volatile__( |
76 | "int $0x40 \n\t" |
75 | "int $0x40 \n\t" |
77 | :"=a"(height) |
76 | :"=a"(height) |
78 | :"a"(48),"b"(4)); |
77 | :"a"(48),"b"(4)); |
79 | return height; |
78 | return height; |
80 | }; |
79 | }; |
81 | static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height"))); |
80 | static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height"))); |
82 | 81 | ||
83 | static inline |
82 | static inline |
84 | void BeginDraw(void) |
83 | void BeginDraw(void) |
85 | { |
84 | { |
86 | __asm__ __volatile__( |
85 | __asm__ __volatile__( |
87 | "int $0x40" ::"a"(12),"b"(1)); |
86 | "int $0x40" ::"a"(12),"b"(1)); |
88 | }; |
87 | }; |
89 | 88 | ||
90 | static inline |
89 | static inline |
91 | void EndDraw(void) |
90 | void EndDraw(void) |
92 | { |
91 | { |
93 | __asm__ __volatile__( |
92 | __asm__ __volatile__( |
94 | "int $0x40" ::"a"(12),"b"(2)); |
93 | "int $0x40" ::"a"(12),"b"(2)); |
95 | }; |
94 | }; |
96 | 95 | ||
97 | static inline void DrawWindow(int x, int y, int w, int h, const char *name, |
96 | static inline void DrawWindow(int x, int y, int w, int h, const char *name, |
98 | color_t workcolor, uint32_t style) |
97 | color_t workcolor, uint32_t style) |
99 | { |
98 | { |
100 | 99 | ||
101 | __asm__ __volatile__( |
100 | __asm__ __volatile__( |
102 | "int $0x40" |
101 | "int $0x40" |
103 | ::"a"(0), |
102 | ::"a"(0), |
104 | "b"((x << 16) | ((w-1) & 0xFFFF)), |
103 | "b"((x << 16) | ((w-1) & 0xFFFF)), |
105 | "c"((y << 16) | ((h-1) & 0xFFFF)), |
104 | "c"((y << 16) | ((h-1) & 0xFFFF)), |
106 | "d"((style << 24) | (workcolor & 0xFFFFFF)), |
105 | "d"((style << 24) | (workcolor & 0xFFFFFF)), |
107 | "D"(name), |
106 | "D"(name), |
108 | "S"(0) : "memory"); |
107 | "S"(0) : "memory"); |
109 | }; |
108 | }; |
110 | 109 | ||
111 | #define POS_SCREEN 0 |
110 | #define POS_SCREEN 0 |
112 | #define POS_WINDOW 1 |
111 | #define POS_WINDOW 1 |
113 | 112 | ||
114 | static inline |
113 | static inline |
115 | pos_t get_mouse_pos(int origin) |
114 | pos_t get_mouse_pos(int origin) |
116 | { |
115 | { |
117 | pos_t val; |
116 | pos_t val; |
118 | 117 | ||
119 | __asm__ __volatile__( |
118 | __asm__ __volatile__( |
120 | "int $0x40 \n\t" |
119 | "int $0x40 \n\t" |
121 | "rol $16, %%eax" |
120 | "rol $16, %%eax" |
122 | :"=a"(val) |
121 | :"=a"(val) |
123 | :"a"(37),"b"(origin)); |
122 | :"a"(37),"b"(origin)); |
124 | return val; |
123 | return val; |
125 | } |
124 | } |
126 | static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos"))); |
125 | static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos"))); |
127 | 126 | ||
128 | static inline |
127 | static inline |
129 | uint32_t get_mouse_buttons(void) |
128 | uint32_t get_mouse_buttons(void) |
130 | { |
129 | { |
131 | uint32_t val; |
130 | uint32_t val; |
132 | 131 | ||
133 | __asm__ __volatile__( |
132 | __asm__ __volatile__( |
134 | "int $0x40" |
133 | "int $0x40" |
135 | :"=a"(val) |
134 | :"=a"(val) |
136 | :"a"(37),"b"(2)); |
135 | :"a"(37),"b"(2)); |
137 | return val; |
136 | return val; |
138 | }; |
137 | }; |
139 | static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons"))); |
138 | static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons"))); |
140 | 139 | ||
141 | static inline |
140 | static inline |
142 | uint32_t get_mouse_wheels(void) |
141 | uint32_t get_mouse_wheels(void) |
143 | { |
142 | { |
144 | uint32_t val; |
143 | uint32_t val; |
145 | 144 | ||
146 | __asm__ __volatile__( |
145 | __asm__ __volatile__( |
147 | "int $0x40 \n\t" |
146 | "int $0x40 \n\t" |
148 | :"=a"(val) |
147 | :"=a"(val) |
149 | :"a"(37),"b"(7)); |
148 | :"a"(37),"b"(7)); |
150 | return val; |
149 | return val; |
151 | }; |
150 | }; |
152 | static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels"))); |
151 | static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels"))); |
153 | 152 | ||
154 | static inline |
153 | static inline |
155 | uint32_t wait_for_event(uint32_t time) |
154 | uint32_t wait_for_event(uint32_t time) |
156 | { |
155 | { |
157 | uint32_t val; |
156 | uint32_t val; |
158 | __asm__ __volatile__( |
157 | __asm__ __volatile__( |
159 | "int $0x40" |
158 | "int $0x40" |
160 | :"=a"(val) |
159 | :"=a"(val) |
161 | :"a"(23), "b"(time)); |
160 | :"a"(23), "b"(time)); |
162 | return val; |
161 | return val; |
163 | }; |
162 | }; |
164 | 163 | ||
165 | static inline uint32_t check_os_event() |
164 | static inline uint32_t check_os_event() |
166 | { |
165 | { |
167 | uint32_t val; |
166 | uint32_t val; |
168 | __asm__ __volatile__( |
167 | __asm__ __volatile__( |
169 | "int $0x40" |
168 | "int $0x40" |
170 | :"=a"(val) |
169 | :"=a"(val) |
171 | :"a"(11)); |
170 | :"a"(11)); |
172 | return val; |
171 | return val; |
173 | }; |
172 | }; |
174 | 173 | ||
175 | static inline uint32_t get_os_event() |
174 | static inline uint32_t get_os_event() |
176 | { |
175 | { |
177 | uint32_t val; |
176 | uint32_t val; |
178 | __asm__ __volatile__( |
177 | __asm__ __volatile__( |
179 | "int $0x40" |
178 | "int $0x40" |
180 | :"=a"(val) |
179 | :"=a"(val) |
181 | :"a"(10)); |
180 | :"a"(10)); |
182 | return val; |
181 | return val; |
183 | }; |
182 | }; |
184 | static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event"))); |
183 | static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event"))); |
185 | 184 | ||
186 | static inline |
185 | static inline |
187 | uint32_t get_tick_count(void) |
186 | uint32_t get_tick_count(void) |
188 | { |
187 | { |
189 | uint32_t val; |
188 | uint32_t val; |
190 | __asm__ __volatile__( |
189 | __asm__ __volatile__( |
191 | "int $0x40" |
190 | "int $0x40" |
192 | :"=a"(val) |
191 | :"=a"(val) |
193 | :"a"(26),"b"(9)); |
192 | :"a"(26),"b"(9)); |
194 | return val; |
193 | return val; |
195 | }; |
194 | }; |
196 | 195 | ||
197 | static inline |
196 | static inline |
198 | oskey_t get_key(void) |
197 | oskey_t get_key(void) |
199 | { |
198 | { |
200 | oskey_t val; |
199 | oskey_t val; |
201 | __asm__ __volatile__( |
200 | __asm__ __volatile__( |
202 | "int $0x40" |
201 | "int $0x40" |
203 | :"=a"(val) |
202 | :"=a"(val) |
204 | :"a"(2)); |
203 | :"a"(2)); |
205 | return val; |
204 | return val; |
206 | } |
205 | } |
207 | 206 | ||
208 | static inline |
207 | static inline |
209 | uint32_t get_os_button() |
208 | uint32_t get_os_button() |
210 | { |
209 | { |
211 | uint32_t val; |
210 | uint32_t val; |
212 | __asm__ __volatile__( |
211 | __asm__ __volatile__( |
213 | "int $0x40" |
212 | "int $0x40" |
214 | :"=a"(val) |
213 | :"=a"(val) |
215 | :"a"(17)); |
214 | :"a"(17)); |
216 | return val>>8; |
215 | return val>>8; |
217 | }; |
216 | }; |
218 | 217 | ||
219 | static inline uint32_t get_service(char *name) |
218 | static inline uint32_t get_service(char *name) |
220 | { |
219 | { |
221 | uint32_t retval = 0; |
220 | uint32_t retval = 0; |
222 | __asm__ __volatile__( |
221 | __asm__ __volatile__( |
223 | "int $0x40" |
222 | "int $0x40" |
224 | :"=a"(retval) |
223 | :"=a"(retval) |
225 | :"a"(68),"b"(16),"c"(name) |
224 | :"a"(68),"b"(16),"c"(name) |
226 | :"memory"); |
225 | :"memory"); |
227 | 226 | ||
228 | return retval; |
227 | return retval; |
229 | }; |
228 | }; |
230 | 229 | ||
231 | static inline int call_service(ioctl_t *io) |
230 | static inline int call_service(ioctl_t *io) |
232 | { |
231 | { |
233 | int retval; |
232 | int retval; |
234 | 233 | ||
235 | __asm__ __volatile__( |
234 | __asm__ __volatile__( |
236 | "int $0x40" |
235 | "int $0x40" |
237 | :"=a"(retval) |
236 | :"=a"(retval) |
238 | :"a"(68),"b"(17),"c"(io) |
237 | :"a"(68),"b"(17),"c"(io) |
239 | :"memory","cc"); |
238 | :"memory","cc"); |
240 | 239 | ||
241 | return retval; |
240 | return retval; |
242 | }; |
241 | }; |
243 | 242 | ||
244 | 243 | ||
245 | static inline |
244 | static inline |
246 | void draw_line(int xs, int ys, int xe, int ye, color_t color) |
245 | void draw_line(int xs, int ys, int xe, int ye, color_t color) |
247 | { |
246 | { |
248 | __asm__ __volatile__( |
247 | __asm__ __volatile__( |
249 | "int $0x40" |
248 | "int $0x40" |
250 | ::"a"(38), "d"(color), |
249 | ::"a"(38), "d"(color), |
251 | "b"((xs << 16) | xe), |
250 | "b"((xs << 16) | xe), |
252 | "c"((ys << 16) | ye)); |
251 | "c"((ys << 16) | ye)); |
253 | } |
252 | } |
254 | 253 | ||
255 | 254 | ||
256 | 255 | ||
257 | static inline |
256 | static inline |
258 | void draw_bar(int x, int y, int w, int h, color_t color) |
257 | void draw_bar(int x, int y, int w, int h, color_t color) |
259 | { |
258 | { |
260 | __asm__ __volatile__( |
259 | __asm__ __volatile__( |
261 | "int $0x40" |
260 | "int $0x40" |
262 | ::"a"(13), "d"(color), |
261 | ::"a"(13), "d"(color), |
263 | "b"((x << 16) | w), |
262 | "b"((x << 16) | w), |
264 | "c"((y << 16) | h)); |
263 | "c"((y << 16) | h)); |
265 | } |
264 | } |
266 | 265 | ||
267 | static inline |
266 | static inline |
268 | void draw_bitmap(void *bitmap, int x, int y, int w, int h) |
267 | void draw_bitmap(void *bitmap, int x, int y, int w, int h) |
269 | { |
268 | { |
270 | __asm__ __volatile__( |
269 | __asm__ __volatile__( |
271 | "int $0x40" |
270 | "int $0x40" |
272 | ::"a"(7), "b"(bitmap), |
271 | ::"a"(7), "b"(bitmap), |
273 | "c"((w << 16) | h), |
272 | "c"((w << 16) | h), |
274 | "d"((x << 16) | y)); |
273 | "d"((x << 16) | y)); |
275 | } |
274 | } |
276 | 275 | ||
277 | static inline |
276 | static inline |
278 | void draw_text_sys(const char *text, int x, int y, int len, color_t color) |
277 | void draw_text_sys(const char *text, int x, int y, int len, color_t color) |
279 | { |
278 | { |
280 | __asm__ __volatile__( |
279 | __asm__ __volatile__( |
281 | "int $0x40" |
280 | "int $0x40" |
282 | ::"a"(4),"d"(text), |
281 | ::"a"(4),"d"(text), |
283 | "b"((x << 16) | y), |
282 | "b"((x << 16) | y), |
284 | "S"(len),"c"(color) |
283 | "S"(len),"c"(color) |
285 | :"memory"); |
284 | :"memory"); |
286 | } |
285 | } |
287 | 286 | ||
288 | static inline void yield(void) |
287 | static inline void yield(void) |
289 | { |
288 | { |
290 | __asm__ __volatile__( |
289 | __asm__ __volatile__( |
291 | "int $0x40" |
290 | "int $0x40" |
292 | ::"a"(68), "b"(1)); |
291 | ::"a"(68), "b"(1)); |
293 | }; |
292 | }; |
294 | 293 | ||
295 | static inline void delay(uint32_t time) |
294 | static inline void delay(uint32_t time) |
296 | { |
295 | { |
297 | __asm__ __volatile__( |
296 | __asm__ __volatile__( |
298 | "int $0x40" |
297 | "int $0x40" |
299 | ::"a"(5), "b"(time) |
298 | ::"a"(5), "b"(time) |
300 | :"memory"); |
299 | :"memory"); |
301 | }; |
300 | }; |
302 | 301 | ||
303 | static inline |
302 | static inline |
304 | void *user_alloc(size_t size) |
303 | void *user_alloc(size_t size) |
305 | { |
304 | { |
306 | void *val; |
305 | void *val; |
307 | __asm__ __volatile__( |
306 | __asm__ __volatile__( |
308 | "int $0x40" |
307 | "int $0x40" |
309 | :"=a"(val) |
308 | :"=a"(val) |
310 | :"a"(68),"b"(12),"c"(size)); |
309 | :"a"(68),"b"(12),"c"(size)); |
311 | return val; |
310 | return val; |
312 | } |
311 | } |
313 | static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc"))); |
312 | static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc"))); |
314 | 313 | ||
315 | static inline |
314 | static inline |
316 | int user_free(void *mem) |
315 | int user_free(void *mem) |
317 | { |
316 | { |
318 | int val; |
317 | int val; |
319 | __asm__ __volatile__( |
318 | __asm__ __volatile__( |
320 | "int $0x40" |
319 | "int $0x40" |
321 | :"=a"(val) |
320 | :"=a"(val) |
322 | :"a"(68),"b"(13),"c"(mem)); |
321 | :"a"(68),"b"(13),"c"(mem)); |
323 | return val; |
322 | return val; |
324 | } |
323 | } |
325 | static inline int UserFree(void *mem) __attribute__ ((alias ("user_free"))); |
324 | static inline int UserFree(void *mem) __attribute__ ((alias ("user_free"))); |
326 | 325 | ||
327 | static inline |
326 | static inline |
328 | int *user_unmap(void *base, size_t offset, size_t size) |
327 | int *user_unmap(void *base, size_t offset, size_t size) |
329 | { |
328 | { |
330 | int *val; |
329 | int *val; |
331 | __asm__ __volatile__( |
330 | __asm__ __volatile__( |
332 | "int $0x40" |
331 | "int $0x40" |
333 | :"=a"(val) |
332 | :"=a"(val) |
334 | :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size)); |
333 | :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size)); |
335 | return val; |
334 | return val; |
336 | }; |
335 | }; |
337 | static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap"))); |
336 | static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap"))); |
338 | 337 | ||
339 | typedef union |
338 | typedef union |
340 | { |
339 | { |
341 | struct |
340 | struct |
342 | { |
341 | { |
343 | void *data; |
342 | void *data; |
344 | size_t size; |
343 | size_t size; |
345 | }; |
344 | }; |
346 | unsigned long long raw; |
345 | unsigned long long raw; |
347 | }ufile_t; |
346 | }ufile_t; |
348 | 347 | ||
349 | 348 | ||
350 | static inline ufile_t load_file(const char *path) |
349 | static inline ufile_t load_file(const char *path) |
351 | { |
350 | { |
352 | ufile_t uf; |
351 | ufile_t uf; |
353 | 352 | ||
354 | __asm__ __volatile__ ( |
353 | __asm__ __volatile__ ( |
355 | "int $0x40" |
354 | "int $0x40" |
356 | :"=A"(uf.raw) |
355 | :"=A"(uf.raw) |
357 | :"a" (68), "b"(27),"c"(path)); |
356 | :"a" (68), "b"(27),"c"(path)); |
358 | 357 | ||
359 | return uf; |
358 | return uf; |
360 | }; |
359 | }; |
361 | static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file"))); |
360 | static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file"))); |
362 | 361 | ||
363 | static inline int GetScreenSize() |
362 | static inline int GetScreenSize() |
364 | { |
363 | { |
365 | int retval; |
364 | int retval; |
366 | 365 | ||
367 | __asm__ __volatile__( |
366 | __asm__ __volatile__( |
368 | "int $0x40" |
367 | "int $0x40" |
369 | :"=a"(retval) |
368 | :"=a"(retval) |
370 | :"a"(61), "b"(1)); |
369 | :"a"(61), "b"(1)); |
371 | return retval; |
370 | return retval; |
372 | } |
371 | } |
373 | 372 | ||
374 | static inline |
373 | static inline |
375 | uint32_t load_cursor(void *path, uint32_t flags) |
374 | uint32_t load_cursor(void *path, uint32_t flags) |
376 | { |
375 | { |
377 | uint32_t val; |
376 | uint32_t val; |
378 | __asm__ __volatile__( |
377 | __asm__ __volatile__( |
379 | "int $0x40" |
378 | "int $0x40" |
380 | :"=a"(val) |
379 | :"=a"(val) |
381 | :"a"(37), "b"(4), "c"(path), "d"(flags)); |
380 | :"a"(37), "b"(4), "c"(path), "d"(flags)); |
382 | return val; |
381 | return val; |
383 | } |
382 | } |
384 | static inline |
383 | static inline |
385 | uint32_t LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor"))); |
384 | uint32_t LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor"))); |
386 | 385 | ||
387 | static inline |
386 | static inline |
388 | uint32_t set_cursor(uint32_t cursor) |
387 | uint32_t set_cursor(uint32_t cursor) |
389 | { |
388 | { |
390 | uint32_t old; |
389 | uint32_t old; |
391 | __asm__ __volatile__( |
390 | __asm__ __volatile__( |
392 | "int $0x40" |
391 | "int $0x40" |
393 | :"=a"(old) |
392 | :"=a"(old) |
394 | :"a"(37), "b"(5), "c"(cursor)); |
393 | :"a"(37), "b"(5), "c"(cursor)); |
395 | return old; |
394 | return old; |
396 | }; |
395 | }; |
397 | static inline uint32_t SetCursor(uint32_t cursor) __attribute__ ((alias ("set_cursor"))); |
396 | static inline uint32_t SetCursor(uint32_t cursor) __attribute__ ((alias ("set_cursor"))); |
398 | 397 | ||
399 | static inline |
398 | static inline |
400 | int destroy_cursor(uint32_t cursor) |
399 | int destroy_cursor(uint32_t cursor) |
401 | { |
400 | { |
402 | int ret; |
401 | int ret; |
403 | __asm__ __volatile__( |
402 | __asm__ __volatile__( |
404 | "int $0x40" |
403 | "int $0x40" |
405 | :"=a"(ret) |
404 | :"=a"(ret) |
406 | :"a"(37), "b"(6), "c"(cursor) |
405 | :"a"(37), "b"(6), "c"(cursor) |
407 | :"memory"); |
406 | :"memory"); |
408 | return ret; |
407 | return ret; |
409 | }; |
408 | }; |
410 | static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor"))); |
409 | static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor"))); |
411 | 410 | ||
412 | static inline void get_proc_info(char *info) |
411 | static inline void get_proc_info(char *info) |
413 | { |
412 | { |
414 | __asm__ __volatile__( |
413 | __asm__ __volatile__( |
415 | "int $0x40" |
414 | "int $0x40" |
416 | : |
415 | : |
417 | :"a"(9), "b"(info), "c"(-1)); |
416 | :"a"(9), "b"(info), "c"(-1)); |
418 | }; |
417 | }; |
419 | static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info"))); |
418 | static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info"))); |
420 | 419 | ||
421 | static inline |
420 | static inline |
422 | void* user_realloc(void *mem, size_t size) |
421 | void* user_realloc(void *mem, size_t size) |
423 | { |
422 | { |
424 | void *val; |
423 | void *val; |
425 | __asm__ __volatile__( |
424 | __asm__ __volatile__( |
426 | "int $0x40" |
425 | "int $0x40" |
427 | :"=a"(val) |
426 | :"=a"(val) |
428 | :"a"(68),"b"(20),"c"(size),"d"(mem) |
427 | :"a"(68),"b"(20),"c"(size),"d"(mem) |
429 | :"memory"); |
428 | :"memory"); |
430 | 429 | ||
431 | return val; |
430 | return val; |
432 | }; |
431 | }; |
433 | static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc"))); |
432 | static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc"))); |
434 | 433 | ||
435 | void *get_resource(void *data, uint32_t id); |
434 | void *get_resource(void *data, uint32_t id); |
436 | 435 | ||
437 | struct blit_call |
436 | struct blit_call |
438 | { |
437 | { |
439 | int dstx; |
438 | int dstx; |
440 | int dsty; |
439 | int dsty; |
441 | int w; |
440 | int w; |
442 | int h; |
441 | int h; |
443 | 442 | ||
444 | int srcx; |
443 | int srcx; |
445 | int srcy; |
444 | int srcy; |
446 | int srcw; |
445 | int srcw; |
447 | int srch; |
446 | int srch; |
448 | 447 | ||
449 | void *bitmap; |
448 | void *bitmap; |
450 | int stride; |
449 | int stride; |
451 | }; |
450 | }; |
452 | 451 | ||
453 | static inline void Blit(void *bitmap, int dst_x, int dst_y, |
452 | static inline void Blit(void *bitmap, int dst_x, int dst_y, |
454 | int src_x, int src_y, int w, int h, |
453 | int src_x, int src_y, int w, int h, |
455 | int src_w, int src_h, int stride) |
454 | int src_w, int src_h, int stride) |
456 | { |
455 | { |
457 | volatile struct blit_call bc; |
456 | volatile struct blit_call bc; |
458 | 457 | ||
459 | bc.dstx = dst_x; |
458 | bc.dstx = dst_x; |
460 | bc.dsty = dst_y; |
459 | bc.dsty = dst_y; |
461 | bc.w = w; |
460 | bc.w = w; |
462 | bc.h = h; |
461 | bc.h = h; |
463 | bc.srcx = src_x; |
462 | bc.srcx = src_x; |
464 | bc.srcy = src_y; |
463 | bc.srcy = src_y; |
465 | bc.srcw = src_w; |
464 | bc.srcw = src_w; |
466 | bc.srch = src_h; |
465 | bc.srch = src_h; |
467 | bc.stride = stride; |
466 | bc.stride = stride; |
468 | bc.bitmap = bitmap; |
467 | bc.bitmap = bitmap; |
469 | 468 | ||
470 | __asm__ __volatile__( |
469 | __asm__ __volatile__( |
471 | "int $0x40" |
470 | "int $0x40" |
472 | ::"a"(73),"b"(0),"c"(&bc.dstx)); |
471 | ::"a"(73),"b"(0),"c"(&bc.dstx)); |
473 | }; |
472 | }; |
474 | 473 | ||
475 | void* load_library(const char *name); |
474 | void* load_library(const char *name); |
476 | 475 | ||
477 | void* get_proc_address(void *handle, const char *proc_name); |
476 | void* get_proc_address(void *handle, const char *proc_name); |
478 | 477 | ||
479 | void enumerate_libraries(int (*callback)(void *handle, const char* name, |
478 | void enumerate_libraries(int (*callback)(void *handle, const char* name, |
480 | uint32_t base, uint32_t size, void *user_data), |
479 | uint32_t base, uint32_t size, void *user_data), |
481 | void *user_data); |
480 | void *user_data); |
482 | 481 | ||
483 | #ifdef __cplusplus |
482 | #ifdef __cplusplus |
484 | } |
483 | } |
485 | #endif |
484 | #endif |
486 | 485 | ||
487 | 486 | ||
488 | #endif><>><>><>><>><>><>><>><>><>><> |
487 | #endif><>><>><>><>><>><>><>><>><>><> |