Rev 5963 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | #ifndef __KOS_32_SYS_H__ |
2 | #define __KOS_32_SYS_H__ |
||
3 | |||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | |||
5141 | serge | 8 | #ifdef __cplusplus |
9 | extern "C" { |
||
10 | #endif |
||
11 | |||
4349 | Serge | 12 | //#ifdef CONFIG_DEBUF |
13 | // #define DBG(format,...) printf(format,##__VA_ARGS__) |
||
14 | //#else |
||
15 | // #define DBG(format,...) |
||
16 | //#endif |
||
17 | |||
5369 | serge | 18 | #define TYPE_3_BORDER_WIDTH 5 |
19 | #define WIN_STATE_MINIMIZED 0x02 |
||
20 | #define WIN_STATE_ROLLED 0x04 |
||
4499 | Serge | 21 | |
4349 | Serge | 22 | typedef unsigned int color_t; |
23 | |||
24 | typedef union __attribute__((packed)) |
||
25 | { |
||
26 | uint32_t val; |
||
27 | struct |
||
28 | { |
||
29 | short x; |
||
30 | short y; |
||
31 | }; |
||
32 | }pos_t; |
||
33 | |||
34 | typedef union __attribute__((packed)) |
||
35 | { |
||
36 | uint32_t val; |
||
37 | struct |
||
38 | { |
||
39 | uint8_t state; |
||
40 | uint8_t code; |
||
41 | uint16_t ctrl_key; |
||
42 | }; |
||
43 | }oskey_t; |
||
44 | |||
45 | typedef struct |
||
46 | { |
||
47 | unsigned handle; |
||
48 | unsigned io_code; |
||
49 | void *input; |
||
50 | int inp_size; |
||
51 | void *output; |
||
52 | int out_size; |
||
53 | }ioctl_t; |
||
54 | |||
6099 | serge | 55 | static inline void begin_draw(void) |
56 | { |
||
57 | __asm__ __volatile__( |
||
58 | "int $0x40" ::"a"(12),"b"(1)); |
||
59 | }; |
||
4349 | Serge | 60 | |
61 | static inline |
||
6099 | serge | 62 | void end_draw(void) |
63 | { |
||
64 | __asm__ __volatile__( |
||
65 | "int $0x40" ::"a"(12),"b"(2)); |
||
66 | }; |
||
67 | |||
68 | static inline |
||
69 | void sys_create_window(int x, int y, int w, int h, const char *name, |
||
70 | color_t workcolor, uint32_t style) |
||
71 | { |
||
72 | __asm__ __volatile__( |
||
73 | "int $0x40" |
||
74 | ::"a"(0), |
||
75 | "b"((x << 16) | ((w-1) & 0xFFFF)), |
||
76 | "c"((y << 16) | ((h-1) & 0xFFFF)), |
||
77 | "d"((style << 24) | (workcolor & 0xFFFFFF)), |
||
78 | "D"(name), |
||
79 | "S"(0) : "memory"); |
||
80 | }; |
||
81 | |||
82 | static inline |
||
5552 | serge | 83 | void define_button(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color) |
4349 | Serge | 84 | { |
85 | __asm__ __volatile__( |
||
86 | "int $0x40" |
||
87 | ::"a"(8), |
||
88 | "b"(x_w), |
||
89 | "c"(y_h), |
||
90 | "d"(id), |
||
91 | "S"(color)); |
||
92 | }; |
||
93 | |||
94 | static inline |
||
6099 | serge | 95 | void draw_line(int xs, int ys, int xe, int ye, color_t color) |
4499 | Serge | 96 | { |
6099 | serge | 97 | __asm__ __volatile__( |
98 | "int $0x40" |
||
99 | ::"a"(38), "d"(color), |
||
100 | "b"((xs << 16) | xe), |
||
101 | "c"((ys << 16) | ye)); |
||
102 | } |
||
4499 | Serge | 103 | |
6099 | serge | 104 | static inline |
105 | void draw_bar(int x, int y, int w, int h, color_t color) |
||
106 | { |
||
4499 | Serge | 107 | __asm__ __volatile__( |
6099 | serge | 108 | "int $0x40" |
109 | ::"a"(13), "d"(color), |
||
110 | "b"((x << 16) | w), |
||
111 | "c"((y << 16) | h)); |
||
112 | } |
||
4499 | Serge | 113 | |
114 | static inline |
||
6099 | serge | 115 | void draw_bitmap(void *bitmap, int x, int y, int w, int h) |
4349 | Serge | 116 | { |
117 | __asm__ __volatile__( |
||
6099 | serge | 118 | "int $0x40" |
119 | ::"a"(7), "b"(bitmap), |
||
120 | "c"((w << 16) | h), |
||
121 | "d"((x << 16) | y)); |
||
122 | } |
||
4349 | Serge | 123 | |
124 | static inline |
||
6099 | serge | 125 | void draw_text_sys(const char *text, int x, int y, int len, color_t color) |
4349 | Serge | 126 | { |
127 | __asm__ __volatile__( |
||
6099 | serge | 128 | "int $0x40" |
129 | ::"a"(4),"d"(text), |
||
130 | "b"((x << 16) | y), |
||
131 | "S"(len),"c"(color) |
||
132 | :"memory"); |
||
133 | } |
||
4349 | Serge | 134 | |
6099 | serge | 135 | static inline |
136 | uint32_t get_skin_height(void) |
||
4349 | Serge | 137 | { |
6099 | serge | 138 | uint32_t height; |
4349 | Serge | 139 | |
140 | __asm__ __volatile__( |
||
6099 | serge | 141 | "int $0x40 \n\t" |
142 | :"=a"(height) |
||
143 | :"a"(48),"b"(4)); |
||
144 | return height; |
||
4349 | Serge | 145 | }; |
146 | |||
6099 | serge | 147 | static inline void BeginDraw(void) __attribute__ ((alias ("begin_draw"))); |
148 | static inline void EndDraw(void) __attribute__ ((alias ("end_draw"))); |
||
149 | static inline void DrawWindow(int x, int y, int w, int h, const char *name, |
||
150 | color_t workcolor, uint32_t style) |
||
151 | __attribute__ ((alias ("sys_create_window"))); |
||
152 | static inline void DefineButton(void) __attribute__ ((alias ("define_button"))); |
||
153 | static inline void DrawLine(int xs, int ys, int xe, int ye, color_t color) |
||
154 | __attribute__ ((alias ("draw_line"))); |
||
155 | static inline void DrawBar(int x, int y, int w, int h, color_t color) |
||
156 | __attribute__ ((alias ("draw_bar"))); |
||
157 | static inline void DrawBitmap(void *bitmap, int x, int y, int w, int h) |
||
158 | __attribute__ ((alias ("draw_bitmap"))); |
||
159 | static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height"))); |
||
160 | |||
161 | |||
5061 | serge | 162 | #define POS_SCREEN 0 |
163 | #define POS_WINDOW 1 |
||
4349 | Serge | 164 | |
165 | static inline |
||
5061 | serge | 166 | pos_t get_mouse_pos(int origin) |
4349 | Serge | 167 | { |
168 | pos_t val; |
||
169 | |||
170 | __asm__ __volatile__( |
||
171 | "int $0x40 \n\t" |
||
172 | "rol $16, %%eax" |
||
173 | :"=a"(val) |
||
5061 | serge | 174 | :"a"(37),"b"(origin)); |
4349 | Serge | 175 | return val; |
176 | } |
||
177 | |||
178 | static inline |
||
179 | uint32_t get_mouse_buttons(void) |
||
180 | { |
||
181 | uint32_t val; |
||
182 | |||
183 | __asm__ __volatile__( |
||
184 | "int $0x40" |
||
185 | :"=a"(val) |
||
186 | :"a"(37),"b"(2)); |
||
187 | return val; |
||
188 | }; |
||
189 | |||
190 | static inline |
||
191 | uint32_t get_mouse_wheels(void) |
||
192 | { |
||
193 | uint32_t val; |
||
194 | |||
195 | __asm__ __volatile__( |
||
196 | "int $0x40 \n\t" |
||
197 | :"=a"(val) |
||
198 | :"a"(37),"b"(7)); |
||
199 | return val; |
||
200 | }; |
||
6099 | serge | 201 | |
202 | static inline uint32_t load_cursor(void *path, uint32_t flags) |
||
203 | { |
||
204 | uint32_t val; |
||
205 | __asm__ __volatile__( |
||
206 | "int $0x40" |
||
207 | :"=a"(val) |
||
208 | :"a"(37), "b"(4), "c"(path), "d"(flags)); |
||
209 | return val; |
||
210 | } |
||
211 | |||
212 | static inline uint32_t set_cursor(uint32_t cursor) |
||
213 | { |
||
214 | uint32_t old; |
||
215 | __asm__ __volatile__( |
||
216 | "int $0x40" |
||
217 | :"=a"(old) |
||
218 | :"a"(37), "b"(5), "c"(cursor)); |
||
219 | return old; |
||
220 | }; |
||
221 | |||
222 | static inline int destroy_cursor(uint32_t cursor) |
||
223 | { |
||
224 | int ret; |
||
225 | __asm__ __volatile__( |
||
226 | "int $0x40" |
||
227 | :"=a"(ret) |
||
228 | :"a"(37), "b"(6), "c"(cursor) |
||
229 | :"memory"); |
||
230 | return ret; |
||
231 | }; |
||
232 | |||
233 | static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos"))); |
||
234 | static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons"))); |
||
5061 | serge | 235 | static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels"))); |
4349 | Serge | 236 | |
6099 | serge | 237 |