Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3248 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)
70
    :"a"(37),"b"(1));
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)
83
    :"a"(37),"b"(0));
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)
140
    :"a"(26),"b"(9));
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)
151
    :"a"(2));
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
static inline
189
void draw_text_sys(const char *text, int x, int y, int len, color_t color)
190
{
191
    __asm__ __volatile__(
192
    "int $0x40"
193
    ::"a"(4),"d"(text),
194
      "b"((x << 16) | y),
195
      "S"(len),"c"(color));
196
}
197
#endif
198
199
 
200
void *user_alloc(size_t size)
201
{
202
    void  *val;
203
    __asm__ __volatile__(
204
    "int $0x40"
205
    :"=a"(val)
206
    :"a"(68),"b"(12),"c"(size));
207
    return val;
208
}
209
210
 
211
int user_free(void *mem)
212
{
213
    int  val;
214
    __asm__ __volatile__(
215
    "int $0x40"
216
    :"=a"(val)
217
    :"a"(68),"b"(12),"c"(mem));
218
    return val;
219
}
220
221
 
222
int *user_unmap(void *base, size_t offset, size_t size)
223
{
224
    void  *val;
225
    __asm__ __volatile__(
226
    "int $0x40"
227
    :"=a"(val)
228
    :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size));
229
    return val;
230
}
231
232
 
233
extern inline
234
void    exit(int status)  __attribute__((noreturn)) ;
235
236
 
237
void    exit(int status)
238
{
239
    __asm__ __volatile__(
240
    "int $0x40"
241
    ::"a"(-1));
242
    for(;;);
243
}
244
*/
245
246
 
247
uint32_t  load_cursor(void *path, uint32_t flags)
248
{
249
    uint32_t  val;
250
    __asm__ __volatile__(
251
    "int $0x40"
252
    :"=a"(val)
253
    :"a"(37), "b"(4), "c"(path), "d"(flags));
254
    return val;
255
}
256
257
 
258
uint32_t  set_cursor(uint32_t  cursor)
259
{
260
    uint32_t  old;
261
    __asm__ __volatile__(
262
    "int $0x40"
263
    :"=a"(old)
264
    :"a"(37), "b"(5), "c"(cursor));
265
    return old;
266
}
267
268
 
269
int destroy_cursor(uint32_t cursor)
270
{
271
    int ret;
272
    __asm__ __volatile__(
273
    "int $0x40"
274
    :"=a"(ret)
275
    :"a"(37), "b"(6), "c"(cursor)
276
    :"memory");
277
    return ret;
278
};
279
280
 
281
 
282
{
283
    __asm__ __volatile__(
284
    "int $0x40"
285
    :
286
    :"a"(9), "b"(info), "c"(-1));
287
}
288
289
 
290
void* user_realloc(void *mem, size_t size)
291
{
292
    void *val;
293
    __asm__ __volatile__(
294
    "int $0x40"
295
    :"=a"(val)
296
    :"a"(68),"b"(12),"c"(size),"d"(mem)
297
    :"memory");
298
299
 
300
}
301
302
 
303
304
 
305
306
 
307
{
308
    int dstx;
309
    int dsty;
310
    int w;
311
    int h;
312
313
 
314
    int srcy;
315
    int srcw;
316
    int srch;
317
318
 
319
    int   stride;
320
};
321
322
 
323
                        int src_x, int src_y, int w, int h,
324
                        int src_w, int src_h, int stride);
325