Rev 8610 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8610 | Rev 8611 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | //////////////////////////////////////////// |
1 | //////////////////////////////////////////// |
2 | // Copyright (C) 2021 maxcodehack, GPLv2 // |
- | |
3 | // KolibriOS Syscalls // |
2 | // KolibriOS Syscalls // |
4 | // sys/kos.h // |
3 | // sys/kos.h // |
- | 4 | // Based on kos32sys and other wrappers // |
|
5 | // // |
5 | // // |
6 | // Syscalls scheme: kos_XxxYyy // |
6 | // Syscalls scheme: kos_XxxYyy // |
7 | // (e.g. kos_DrawWindow) // |
7 | // (e.g. kos_DrawWindow) // |
8 | //////////////////////////////////////////// |
8 | //////////////////////////////////////////// |
Line -... | Line 9... | ||
- | 9 | ||
- | 10 | // Some code was written by maxcodehack |
|
9 | 11 | ||
10 | #include |
12 | #include |
Line -... | Line 13... | ||
- | 13 | #include |
|
11 | #include |
14 | |
Line 12... | Line 15... | ||
12 | 15 | /*********************** Types *************************/ |
|
13 | typedef unsigned int color_t; |
16 | typedef unsigned int color_t; |
14 | 17 | ||
Line 63... | Line 66... | ||
63 | unsigned char window_state; |
66 | unsigned char window_state; |
64 | unsigned char reserved3[1024-71]; |
67 | unsigned char reserved3[1024-71]; |
65 | }; |
68 | }; |
66 | #pragma pack(pop) |
69 | #pragma pack(pop) |
Line 67... | Line 70... | ||
67 | 70 | ||
68 | // Color struct for sysfn ? |
71 | // Color struct for sysfn 48 |
69 | struct kolibri_system_colors { |
72 | struct kolibri_system_colors { |
70 | color_t frame_area; |
73 | color_t frame_area; |
71 | color_t grab_bar; |
74 | color_t grab_bar; |
72 | color_t grab_bar_button; |
75 | color_t grab_bar_button; |
Line 88... | Line 91... | ||
88 | short y; |
91 | short y; |
89 | }; |
92 | }; |
90 | } pos_t; |
93 | } pos_t; |
Line 91... | Line 94... | ||
91 | 94 | ||
92 | 95 | ||
93 | /// Window Syscalls: |
96 | /*********************** Window Syscalls *************************/ |
94 | // Start drawing |
97 | // Start drawing |
95 | static inline void kos_BeginDraw(void) |
98 | static inline void kos_BeginDraw(void) |
96 | { |
99 | { |
Line 117... | Line 120... | ||
117 | "d"((style << 24) | (bgcolor & 0xFFFFFF)), |
120 | "d"((style << 24) | (bgcolor & 0xFFFFFF)), |
118 | "D"(title), |
121 | "D"(title), |
119 | "S"(0) : "memory"); |
122 | "S"(0) : "memory"); |
120 | }; |
123 | }; |
Line -... | Line 124... | ||
- | 124 | ||
- | 125 | // Set window layer behaviour |
|
- | 126 | #define ZPOS_DESKTOP -2 |
|
- | 127 | #define ZPOS_ALWAYS_BACK -1 |
|
- | 128 | #define ZPOS_NORMAL 0 |
|
- | 129 | #define ZPOS_ALWAYS_TOP 1 |
|
- | 130 | ||
- | 131 | static inline void kos_SetWindowLayerBehaviour(int zpos) |
|
- | 132 | { |
|
- | 133 | __asm__ __volatile__( |
|
- | 134 | "int $0x40" |
|
- | 135 | ::"a"(18), |
|
- | 136 | "b"(25), |
|
- | 137 | "c"(2), |
|
- | 138 | "d"(-1), |
|
- | 139 | "S"(zpos) : "memory"); |
|
- | 140 | }; |
|
121 | 141 | ||
122 | // Change window size |
142 | // Change window size |
123 | #define OLD -1 |
143 | #define OLD -1 |
124 | static inline void kos_ChangeWindow(int new_x, int new_y, int new_w, int new_h) |
144 | static inline void kos_ChangeWindow(int new_x, int new_y, int new_w, int new_h) |
125 | { |
145 | { |
126 | __asm__ __volatile__( |
146 | __asm__ __volatile__( |
127 | "int $0x40" |
147 | "int $0x40" |
128 | ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h) |
148 | ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h) |
129 | ); |
149 | ); |
Line 130... | Line 150... | ||
130 | } |
150 | } |
131 | 151 | ||
132 | /// Other GUI functions: |
152 | /*********************** Other GUI functions *************************/ |
133 | // Draw text |
153 | // Draw text |
134 | static inline void kos_DrawText(int x, int y, const char *text, color_t color) |
154 | static inline void kos_DrawText(int x, int y, const char *text, color_t color) |
135 | { |
155 | { |
Line 201... | Line 221... | ||
201 | ::"a"(7), "b"(bitmap), |
221 | ::"a"(7), "b"(bitmap), |
202 | "c"((w << 16) | h), |
222 | "c"((w << 16) | h), |
203 | "d"((x << 16) | y)); |
223 | "d"((x << 16) | y)); |
204 | } |
224 | } |
Line -... | Line 225... | ||
- | 225 | ||
- | 226 | // Blitter |
|
- | 227 | static inline void Blit(void *bitmap, int dst_x, int dst_y, |
|
- | 228 | int src_x, int src_y, int w, int h, |
|
- | 229 | int src_w, int src_h, int stride) |
|
- | 230 | { |
|
- | 231 | volatile struct blit_call bc; |
|
- | 232 | ||
- | 233 | bc.dstx = dst_x; |
|
- | 234 | bc.dsty = dst_y; |
|
- | 235 | bc.w = w; |
|
- | 236 | bc.h = h; |
|
- | 237 | bc.srcx = src_x; |
|
- | 238 | bc.srcy = src_y; |
|
- | 239 | bc.srcw = src_w; |
|
- | 240 | bc.srch = src_h; |
|
- | 241 | bc.stride = stride; |
|
- | 242 | bc.bitmap = bitmap; |
|
- | 243 | ||
- | 244 | __asm__ __volatile__( |
|
- | 245 | "int $0x40" |
|
- | 246 | ::"a"(73),"b"(0),"c"(&bc.dstx)); |
|
Line -... | Line 247... | ||
- | 247 | }; |
|
- | 248 | ||
- | 249 | // Get screen part as image |
|
- | 250 | static inline void kos_ScreenShot(char* image, int x, int y, int w, int h) |
|
205 | 251 | { |
|
- | 252 | __asm__ __volatile__( |
|
- | 253 | "int $0x40" |
|
- | 254 | ::"a"(36), |
|
- | 255 | "b"(image), |
|
- | 256 | "c"(w*65536+h), |
|
- | 257 | "d"(x*65536+y) : "memory"); |
|
- | 258 | }; |
|
206 | 259 | ||
207 | /// Skin: |
260 | /*********************** Skin *************************/ |
208 | // Return skin height |
261 | // Return skin height |
209 | static inline uint32_t kos_SkinHeight(void) |
262 | static inline uint32_t kos_SkinHeight(void) |
Line 215... | Line 268... | ||
215 | :"=a"(height) |
268 | :"=a"(height) |
216 | :"a"(48),"b"(4)); |
269 | :"a"(48),"b"(4)); |
217 | return height; |
270 | return height; |
218 | }; |
271 | }; |
Line 219... | Line 272... | ||
219 | 272 | ||
220 | /// Mouse: |
273 | /*********************** Mouse *************************/ |
221 | // Get mouse position |
274 | // Get mouse position |
222 | #define POS_SCREEN 0 |
275 | #define POS_SCREEN 0 |
Line 223... | Line 276... | ||
223 | #define POS_WINDOW 1 |
276 | #define POS_WINDOW 1 |
Line 293... | Line 346... | ||
293 | :"a"(37), "b"(6), "c"(cursor) |
346 | :"a"(37), "b"(6), "c"(cursor) |
294 | :"memory"); |
347 | :"memory"); |
295 | return ret; |
348 | return ret; |
296 | }; |
349 | }; |
Line 297... | Line 350... | ||
297 | 350 | ||
298 | /// OS Events: |
351 | /*********************** OS Events *************************/ |
299 | #define evReDraw 1 |
352 | #define evReDraw 1 |
300 | #define evKey 2 |
353 | #define evKey 2 |
301 | #define evButton 3 |
354 | #define evButton 3 |
302 | #define evExit 4 |
355 | #define evExit 4 |
Line 335... | Line 388... | ||
335 | :"=a"(val) |
388 | :"=a"(val) |
336 | :"a"(10)); |
389 | :"a"(10)); |
337 | return val; |
390 | return val; |
338 | }; |
391 | }; |
Line 339... | Line 392... | ||
339 | 392 | ||
340 | /// Eventmask: |
393 | /*********************** Eventmask *************************/ |
341 | #define EVM_REDRAW 1 |
394 | #define EVM_REDRAW 1 |
342 | #define EVM_KEY 2 |
395 | #define EVM_KEY 2 |
343 | #define EVM_BUTTON 4 |
396 | #define EVM_BUTTON 4 |
344 | #define EVM_EXIT 8 |
397 | #define EVM_EXIT 8 |
Line 360... | Line 413... | ||
360 | :"a"(40),"b"(event_mask)); |
413 | :"a"(40),"b"(event_mask)); |
Line 361... | Line 414... | ||
361 | 414 | ||
362 | return old_event_mask; |
415 | return old_event_mask; |
Line 363... | Line 416... | ||
363 | }; |
416 | }; |
364 | 417 | ||
365 | /// Other: |
418 | /*********************** Other *************************/ |
366 | // Get key |
419 | // Get key |
367 | int kos_GetKey() |
420 | int kos_GetKey() |
368 | { |
421 | { |
Line 422... | Line 475... | ||
422 | : |
475 | : |
423 | :"a"(9), "b"(info), "c"(-1) |
476 | :"a"(9), "b"(info), "c"(-1) |
424 | :"memory"); |
477 | :"memory"); |
425 | }; |
478 | }; |
Line 426... | Line -... | ||
426 | - | ||
427 | // Blitter |
- | |
428 | static inline void Blit(void *bitmap, int dst_x, int dst_y, |
- | |
429 | int src_x, int src_y, int w, int h, |
- | |
430 | int src_w, int src_h, int stride) |
- | |
431 | { |
- | |
432 | volatile struct blit_call bc; |
- | |
433 | - | ||
434 | bc.dstx = dst_x; |
- | |
435 | bc.dsty = dst_y; |
- | |
436 | bc.w = w; |
- | |
437 | bc.h = h; |
- | |
438 | bc.srcx = src_x; |
- | |
439 | bc.srcy = src_y; |
- | |
440 | bc.srcw = src_w; |
- | |
441 | bc.srch = src_h; |
- | |
442 | bc.stride = stride; |
- | |
443 | bc.bitmap = bitmap; |
- | |
444 | - | ||
445 | __asm__ __volatile__( |
- | |
446 | "int $0x40" |
- | |
447 | ::"a"(73),"b"(0),"c"(&bc.dstx)); |
- | |
448 | }; |
- | |
449 | 479 | ||
450 | void kos_RunApp(char* app, char* param) |
480 | void kos_RunApp(char* app, char* param) |
451 | { |
481 | { |
452 | kos_Struct70 r; |
482 | kos_Struct70 r; |
453 | r.p00 = 7; |
483 | r.p00 = 7; |