sys/kos.h: more neat +sysfn36 +ZPOS

git-svn-id: svn://kolibrios.org@8611 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
maxcodehack 2021-02-24 09:25:50 +00:00
parent 4657dec23b
commit bf7d612d7b

View File

@ -1,15 +1,18 @@
//////////////////////////////////////////// ////////////////////////////////////////////
// Copyright (C) 2021 maxcodehack, GPLv2 //
// KolibriOS Syscalls // // KolibriOS Syscalls //
// sys/kos.h // // sys/kos.h //
// Based on kos32sys and other wrappers //
// // // //
// Syscalls scheme: kos_XxxYyy // // Syscalls scheme: kos_XxxYyy //
// (e.g. kos_DrawWindow) // // (e.g. kos_DrawWindow) //
//////////////////////////////////////////// ////////////////////////////////////////////
// Some code was written by maxcodehack
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
/*********************** Types *************************/
typedef unsigned int color_t; typedef unsigned int color_t;
// Struct for App running // Struct for App running
@ -65,7 +68,7 @@ struct proc_info
}; };
#pragma pack(pop) #pragma pack(pop)
// Color struct for sysfn ? // Color struct for sysfn 48
struct kolibri_system_colors { struct kolibri_system_colors {
color_t frame_area; color_t frame_area;
color_t grab_bar; color_t grab_bar;
@ -90,7 +93,7 @@ typedef union __attribute__((packed))
} pos_t; } pos_t;
/// Window Syscalls: /*********************** Window Syscalls *************************/
// Start drawing // Start drawing
static inline void kos_BeginDraw(void) static inline void kos_BeginDraw(void)
{ {
@ -119,6 +122,23 @@ static inline void kos_DrawWindow(int x, int y, int w, int h, const char *title,
"S"(0) : "memory"); "S"(0) : "memory");
}; };
// Set window layer behaviour
#define ZPOS_DESKTOP -2
#define ZPOS_ALWAYS_BACK -1
#define ZPOS_NORMAL 0
#define ZPOS_ALWAYS_TOP 1
static inline void kos_SetWindowLayerBehaviour(int zpos)
{
__asm__ __volatile__(
"int $0x40"
::"a"(18),
"b"(25),
"c"(2),
"d"(-1),
"S"(zpos) : "memory");
};
// Change window size // Change window size
#define OLD -1 #define OLD -1
static inline void kos_ChangeWindow(int new_x, int new_y, int new_w, int new_h) static inline void kos_ChangeWindow(int new_x, int new_y, int new_w, int new_h)
@ -129,7 +149,7 @@ static inline void kos_ChangeWindow(int new_x, int new_y, int new_w, int new_h)
); );
} }
/// Other GUI functions: /*********************** Other GUI functions *************************/
// Draw text // Draw text
static inline void kos_DrawText(int x, int y, const char *text, color_t color) static inline void kos_DrawText(int x, int y, const char *text, color_t color)
{ {
@ -203,8 +223,41 @@ static inline void kos_DrawBitmap(void *bitmap, int x, int y, int w, int h)
"d"((x << 16) | y)); "d"((x << 16) | y));
} }
// Blitter
static inline void Blit(void *bitmap, int dst_x, int dst_y,
int src_x, int src_y, int w, int h,
int src_w, int src_h, int stride)
{
volatile struct blit_call bc;
/// Skin: bc.dstx = dst_x;
bc.dsty = dst_y;
bc.w = w;
bc.h = h;
bc.srcx = src_x;
bc.srcy = src_y;
bc.srcw = src_w;
bc.srch = src_h;
bc.stride = stride;
bc.bitmap = bitmap;
__asm__ __volatile__(
"int $0x40"
::"a"(73),"b"(0),"c"(&bc.dstx));
};
// Get screen part as image
static inline void kos_ScreenShot(char* image, int x, int y, int w, int h)
{
__asm__ __volatile__(
"int $0x40"
::"a"(36),
"b"(image),
"c"(w*65536+h),
"d"(x*65536+y) : "memory");
};
/*********************** Skin *************************/
// Return skin height // Return skin height
static inline uint32_t kos_SkinHeight(void) static inline uint32_t kos_SkinHeight(void)
{ {
@ -217,7 +270,7 @@ static inline uint32_t kos_SkinHeight(void)
return height; return height;
}; };
/// Mouse: /*********************** Mouse *************************/
// Get mouse position // Get mouse position
#define POS_SCREEN 0 #define POS_SCREEN 0
#define POS_WINDOW 1 #define POS_WINDOW 1
@ -295,7 +348,7 @@ static inline int kos_DestroyCursor(uint32_t cursor)
return ret; return ret;
}; };
/// OS Events: /*********************** OS Events *************************/
#define evReDraw 1 #define evReDraw 1
#define evKey 2 #define evKey 2
#define evButton 3 #define evButton 3
@ -337,7 +390,7 @@ static inline uint32_t kos_WaitForEvent(void)
return val; return val;
}; };
/// Eventmask: /*********************** Eventmask *************************/
#define EVM_REDRAW 1 #define EVM_REDRAW 1
#define EVM_KEY 2 #define EVM_KEY 2
#define EVM_BUTTON 4 #define EVM_BUTTON 4
@ -362,7 +415,7 @@ static inline uint32_t kos_SetMaskForEvents(uint32_t event_mask)
return old_event_mask; return old_event_mask;
}; };
/// Other: /*********************** Other *************************/
// Get key // Get key
int kos_GetKey() int kos_GetKey()
{ {
@ -424,29 +477,6 @@ static inline void kos_ProcessInfo(char *info)
:"memory"); :"memory");
}; };
// Blitter
static inline void Blit(void *bitmap, int dst_x, int dst_y,
int src_x, int src_y, int w, int h,
int src_w, int src_h, int stride)
{
volatile struct blit_call bc;
bc.dstx = dst_x;
bc.dsty = dst_y;
bc.w = w;
bc.h = h;
bc.srcx = src_x;
bc.srcy = src_y;
bc.srcw = src_w;
bc.srch = src_h;
bc.stride = stride;
bc.bitmap = bitmap;
__asm__ __volatile__(
"int $0x40"
::"a"(73),"b"(0),"c"(&bc.dstx));
};
void kos_RunApp(char* app, char* param) void kos_RunApp(char* app, char* param)
{ {
kos_Struct70 r; kos_Struct70 r;