Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2415 Serge 1
 
2
#include 
3
#include 
4
5
 
6
  #define DBG(format,...) printf(format,##__VA_ARGS__)
7
#else
8
  #define DBG(format,...)
9
#endif
10
11
 
12
13
 
14
{
15
    uint32_t val;
16
    struct
17
    {
18
        short  x;
19
        short  y;
20
    };
21
}pos_t;
22
23
 
24
{
25
    uint32_t val;
26
    struct
27
    {
28
        uint8_t   state;
29
        uint8_t   code;
30
        uint16_t  ctrl_key;
31
    };
32
}oskey_t;
33
34
 
35
void BeginDraw(void)
36
{
37
    __asm__ __volatile__(
38
    "int $0x40" ::"a"(12),"b"(1));
39
};
40
41
 
42
void EndDraw(void)
43
{
44
    __asm__ __volatile__(
45
    "int $0x40" ::"a"(12),"b"(2));
46
};
47
48
 
49
                       color_t workcolor, uint32_t style)
50
{
51
52
 
53
    "int $0x40"
54
    ::"a"(0),
55
      "b"((x << 16) | (w & 0xFFFF)),
56
      "c"((y << 16) | (h & 0xFFFF)),
57
      "d"((style << 24) | (workcolor & 0xFFFFFF)),
58
      "D"(name));
59
};
60
61
 
62
pos_t get_mouse_pos(void)
63
{
64
    pos_t val;
65
66
 
67
    "int $0x40 \n\t"
68
    "rol $16, %%eax"
69
    :"=a"(val)
2427 Serge 70
    :"a"(37),"b"(1));
2415 Serge 71
    return val;
72
}
73
74
 
75
pos_t get_cursor_pos(void)
76
{
77
    pos_t val;
78
79
 
80
    "int $0x40 \n\t"
81
    "rol $16, %%eax"
82
    :"=a"(val)
2427 Serge 83
    :"a"(37),"b"(0));
2415 Serge 84
    return val;
85
}
86
87
 
88
uint32_t get_mouse_buttons(void)
89
{
90
    uint32_t val;
91
92
 
93
    "int $0x40"
94
    :"=a"(val)
95
    :"a"(37),"b"(2));
96
    return val;
97
};
98
99
 
100
uint32_t get_mouse_wheels(void)
101
{
102
    uint32_t val;
103
104
 
105
    "int $0x40 \n\t"
106
    "rol $16, %%eax"
107
    :"=a"(val)
108
    :"a"(37),"b"(7));
109
    return val;
110
};
111
112
 
113
uint32_t wait_for_event(uint32_t time)
114
{
115
    uint32_t val;
116
    __asm__ __volatile__(
117
    "int $0x40"
118
    :"=a"(val)
119
    :"a"(23), "b"(time));
120
    return val;
121
};
122
123
 
124
{
125
    uint32_t val;
126
    __asm__ __volatile__(
127
    "int $0x40"
128
    :"=a"(val)
129
    :"a"(11));
130
    return val;
131
};
132
133
 
134
uint32_t get_tick_count(void)
135
{
136
    uint32_t val;
137
    __asm__ __volatile__(
138
    "int $0x40"
139
    :"=a"(val)
2427 Serge 140
    :"a"(26),"b"(9));
2415 Serge 141
    return val;
142
};
143
144
 
145
oskey_t get_key(void)
146
{
147
    oskey_t val;
148
    __asm__ __volatile__(
149
    "int $0x40"
150
    :"=a"(val)
2427 Serge 151
    :"a"(2));
2415 Serge 152
    return val;
153
}
154
155
 
156
void draw_line(int xs, int ys, int xe, int ye, color_t color)
157
{
158
    __asm__ __volatile__(
159
    "int $0x40"
160
    ::"a"(38), "d"(color),
161
      "b"((xs << 16) | xe),
162
      "c"((ys << 16) | ye));
163
}
164
165
 
166
 
167
 
168
void draw_bar(int x, int y, int w, int h, color_t color)
169
{
170
    __asm__ __volatile__(
171
    "int $0x40"
172
    ::"a"(13), "d"(color),
173
      "b"((x << 16) | w),
174
      "c"((y << 16) | h));
175
}
176
177
 
178
void draw_bitmap(void *bitmap, int x, int y, int w, int h)
179
{
180
    __asm__ __volatile__(
181
    "int $0x40"
182
    ::"a"(7), "b"(bitmap),
183
      "c"((w << 16) | h),
184
      "d"((x << 16) | y));
185
}
186
187
 
188
void draw_text_sys(const char *text, int x, int y, int len, color_t color)
3248 Serge 189
{
2415 Serge 190
    __asm__ __volatile__(
191
    "int $0x40"
192
    ::"a"(4),"d"(text),
193
      "b"((x << 16) | y),
194
      "S"(len),"c"(color));
195
}
196
197
 
198
void *user_alloc(size_t size)
199
{
200
    void  *val;
201
    __asm__ __volatile__(
202
    "int $0x40"
203
    :"=a"(val)
2427 Serge 204
    :"a"(68),"b"(12),"c"(size));
2415 Serge 205
    return val;
206
}
207
208
 
209
int user_free(void *mem)
210
{
211
    int  val;
212
    __asm__ __volatile__(
213
    "int $0x40"
214
    :"=a"(val)
2427 Serge 215
    :"a"(68),"b"(12),"c"(mem));
2415 Serge 216
    return val;
217
}
218
219
 
220
int *user_unmap(void *base, size_t offset, size_t size)
221
{
222
    void  *val;
223
    __asm__ __volatile__(
224
    "int $0x40"
225
    :"=a"(val)
2427 Serge 226
    :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size));
2415 Serge 227
    return val;
228
}
229
230
 
231
extern inline
232
void    exit(int status)  __attribute__((noreturn)) ;
233
234
 
235
void    exit(int status)
236
{
237
    __asm__ __volatile__(
238
    "int $0x40"
239
    ::"a"(-1));
240
    for(;;);
241
}
242
*/
243
244
 
245
uint32_t  load_cursor(void *path, uint32_t flags)
246
{
247
    uint32_t  val;
248
    __asm__ __volatile__(
249
    "int $0x40"
250
    :"=a"(val)
2427 Serge 251
    :"a"(37), "b"(4), "c"(path), "d"(flags));
2415 Serge 252
    return val;
253
}
254
255
 
256
uint32_t  set_cursor(uint32_t  cursor)
257
{
258
    uint32_t  old;
259
    __asm__ __volatile__(
260
    "int $0x40"
261
    :"=a"(old)
2427 Serge 262
    :"a"(37), "b"(5), "c"(cursor));
2415 Serge 263
    return old;
264
}
265
266
 
3068 serge 267
int destroy_cursor(uint32_t cursor)
268
{
269
    int ret;
270
    __asm__ __volatile__(
271
    "int $0x40"
272
    :"=a"(ret)
273
    :"a"(37), "b"(6), "c"(cursor)
274
    :"memory");
275
    return ret;
276
};
277
278
 
2415 Serge 279
{
280
    __asm__ __volatile__(
281
    "int $0x40"
282
    :
283
    :"a"(9), "b"(info), "c"(-1));
284
}
285
286
 
287
void* user_realloc(void *mem, size_t size)
288
{
289
    void *val;
290
    __asm__ __volatile__(
291
    "int $0x40"
292
    :"=a"(val)
2427 Serge 293
    :"a"(68),"b"(20),"c"(size),"d"(mem)
3068 serge 294
    :"memory");
2415 Serge 295
296
 
297
}
298
299
 
300
301
 
302
303
 
304
{
305
    int dstx;
306
    int dsty;
307
    int w;
308
    int h;
309
310
 
311
    int srcy;
312
    int srcw;
313
    int srch;
314
315
 
316
    int   stride;
317
};
318
319
 
320
                        int src_x, int src_y, int w, int h,
321
                        int src_w, int src_h, int stride);
322