Subversion Repositories Kolibri OS

Rev

Rev 9202 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9202 turbocat 1
#ifndef SDL_kos
2
#define SDL_kos
3
 
4
#ifdef __cplusplus
5
extern "C" {
6
#endif
7
 
8
typedef unsigned char       __u8;
9
typedef unsigned short      __u16;
10
typedef unsigned long       __u32;
11
 
9211 turbocat 12
#pragma pack(push)
9202 turbocat 13
struct process_table_entry
14
{
15
 __u32 cpu_usage;
16
 __u16 pos_in_windowing_stack;
17
 __u16 win_stack_val_at_ecx;
18
 __u16 reserved1;
19
 char name[12];
20
 __u32 memstart;
21
 __u32 memused;
22
 __u32 pid;
23
 __u32 winx_start,winy_start;
24
 __u32 winx_size,winy_size;
25
 __u16 thread_state;
26
 __u16 reserved2;
27
 __u32 client_left,client_top,client_width,client_height;
28
 __u8 window_state;
29
 __u8 reserved3[1024-71];
30
};
31
 
9211 turbocat 32
typedef union{
33
    unsigned val;
34
    struct{
35
        short  h;
36
        short  w;
37
    };
38
}__kos__screen_t;
39
#pragma pack(pop)
40
 
9202 turbocat 41
static inline
42
void __kos__define_window(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,
43
     __u32 body_color,__u32 grab_color,__u32 frame_color)
44
{
45
 __u32 a,b;
46
 a=(x1<<16)|xsize;
47
 b=(y1<<16)|ysize;
48
 __asm__ __volatile__("int $0x40"::"a"(0),"b"(a),"c"(b),"d"(body_color),"S"(grab_color),
49
                      "D"(frame_color));
50
}
51
 
52
static inline void __kos__window_redraw(int status)
53
{
54
 __asm__ __volatile__("int $0x40"::"a"(12),"b"(status));
55
}
56
 
57
static inline
58
void __kos__draw_bitmap(void *bitmap, int x, int y, int w, int h)
59
{
60
    __asm__ __volatile__(
61
    "int $0x40"
62
    ::"a"(7), "b"(bitmap),
63
      "c"((w << 16) | h),
64
      "d"((x << 16) | y));
65
}
66
 
67
static inline
68
int __kos__getkey(void)
69
{
70
 __u16 __ret;
71
 __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(2));
72
 if(!(__ret & 0xFF)) return (__ret>>8)&0xFF; else return 0;
73
}
74
 
75
static inline
76
int __kos__check_for_event(void)
77
{
78
 __u32 __ret;
79
 __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(11));
80
 return __ret;
81
}
82
 
83
static inline
84
int __kos__set_events_mask(__u32 mask)
85
{
9211 turbocat 86
    __u32 val;
9202 turbocat 87
    asm volatile ("int $0x40":"=a"(val):"a"(40), "b"(mask));
88
    return val;
89
}
90
 
91
static inline
92
void __kos__delay100(int time)
93
{
94
    __asm__ __volatile__(
95
    "int $0x40"
96
    ::"a"(5), "b"(time)
97
    :"memory");
98
};
99
 
100
static inline
101
int __kos__get_button_id()
102
{
103
    __u32 val;
104
    __asm__ __volatile__(
105
        "int $0x40"
106
        :"=a"(val)
107
        :"a"(17)
108
    );
109
    return val>>8;
110
}
111
 
9211 turbocat 112
 
113
static inline
114
void __kos__change_window(int new_x, int new_y, int new_w, int new_h)
115
{
116
    __asm__ __volatile__(
117
        "int $0x40"
118
        ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h)
119
    );
120
}
121
 
122
static inline
123
__kos__screen_t __kos__screen_size(void)
124
{
125
	__kos__screen_t size;
126
    __asm__ __volatile__(
127
        "int $0x40"
128
        :"=a"(size)
129
        :"a"(14)
130
        :"memory"
131
    );
132
    return size;
133
}
134
 
135
static inline
136
int __kos__get_skinh(void)
137
{
138
    int res;
139
    __asm__ ("int $0x40" : "=a"(res) : "a"(48),"b"(4));
140
    return res;
141
}
142
 
143
static inline
144
void __kos__dbg_write_byte(const char ch){
145
    __asm__ __volatile__(
146
        "int $0x40"
147
        ::"a"(63), "b"(1), "c"(ch)
148
    );
149
}
150
 
151
static inline
152
void __kos__dbg_write_str(const char* str){
153
    while(*str){
154
        __kos__dbg_write_byte(*str++);
155
    }
156
}
157
 
9202 turbocat 158
#ifdef __cplusplus
159
}
160
#endif
161
 
9211 turbocat 162
#endif