1,15 → 1,18 |
//////////////////////////////////////////// |
// Copyright (C) 2021 maxcodehack, GPLv2 // |
// KolibriOS Syscalls // |
// sys/kos.h // |
// Based on kos32sys and other wrappers // |
// // |
// Syscalls scheme: kos_XxxYyy // |
// (e.g. kos_DrawWindow) // |
//////////////////////////////////////////// |
|
// Some code was written by maxcodehack |
|
#include <stdint.h> |
#include <string.h> |
|
/*********************** Types *************************/ |
typedef unsigned int color_t; |
|
// Struct for App running |
65,7 → 68,7 |
}; |
#pragma pack(pop) |
|
// Color struct for sysfn ? |
// Color struct for sysfn 48 |
struct kolibri_system_colors { |
color_t frame_area; |
color_t grab_bar; |
90,7 → 93,7 |
} pos_t; |
|
|
/// Window Syscalls: |
/*********************** Window Syscalls *************************/ |
// Start drawing |
static inline void kos_BeginDraw(void) |
{ |
119,6 → 122,23 |
"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 |
#define OLD -1 |
static inline void kos_ChangeWindow(int new_x, int new_y, int new_w, int new_h) |
129,7 → 149,7 |
); |
} |
|
/// Other GUI functions: |
/*********************** Other GUI functions *************************/ |
// Draw text |
static inline void kos_DrawText(int x, int y, const char *text, color_t color) |
{ |
203,8 → 223,41 |
"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 |
static inline uint32_t kos_SkinHeight(void) |
{ |
217,7 → 270,7 |
return height; |
}; |
|
/// Mouse: |
/*********************** Mouse *************************/ |
// Get mouse position |
#define POS_SCREEN 0 |
#define POS_WINDOW 1 |
295,7 → 348,7 |
return ret; |
}; |
|
/// OS Events: |
/*********************** OS Events *************************/ |
#define evReDraw 1 |
#define evKey 2 |
#define evButton 3 |
337,7 → 390,7 |
return val; |
}; |
|
/// Eventmask: |
/*********************** Eventmask *************************/ |
#define EVM_REDRAW 1 |
#define EVM_KEY 2 |
#define EVM_BUTTON 4 |
362,7 → 415,7 |
return old_event_mask; |
}; |
|
/// Other: |
/*********************** Other *************************/ |
// Get key |
int kos_GetKey() |
{ |
424,29 → 477,6 |
:"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) |
{ |
kos_Struct70 r; |