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