Rev 2693 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2693 | Rev 3068 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
2 | #include |
2 | //#include |
3 | #include |
3 | //#include |
4 | #include |
4 | //#include |
5 | #include |
5 | #include |
6 | #include |
6 | //#include |
7 | #include "../winlib/winlib.h" |
7 | #include "../winlib/winlib.h" |
8 | #include "fplay.h" |
8 | //#include "fplay.h" |
- | 9 | #include "system.h" |
|
- | 10 | ||
- | 11 | typedef struct |
|
- | 12 | { |
|
- | 13 | uint32_t width; |
|
- | 14 | uint32_t height; |
|
- | 15 | uint32_t pitch; |
|
- | 16 | uint32_t handle; |
|
- | 17 | uint8_t *data; |
|
- | 18 | }bitmap_t; |
|
- | 19 | ||
Line 9... | Line 20... | ||
9 | 20 | ||
Line 10... | Line 21... | ||
10 | #define DISPLAY_VERSION 0x0200 /* 2.00 */ |
21 | #define DISPLAY_VERSION 0x0200 /* 2.00 */ |
11 | 22 | ||
Line 12... | Line 23... | ||
12 | #define SRV_GETVERSION 0 |
23 | #define SRV_GETVERSION 0 |
- | 24 | #define SRV_GET_CAPS 3 |
|
13 | #define SRV_GET_CAPS 3 |
25 | |
14 | - | ||
- | 26 | #define SRV_CREATE_SURFACE 10 |
|
- | 27 | #define SRV_DESTROY_SURFACE 11 |
|
- | 28 | #define SRV_LOCK_SURFACE 12 |
|
- | 29 | #define SRV_UNLOCK_SURFACE 13 |
|
15 | #define SRV_CREATE_SURFACE 10 |
30 | #define SRV_RESIZE_SURFACE 14 |
Line 16... | Line 31... | ||
16 | #define SRV_LOCK_SURFACE 12 |
31 | #define SRV_BLIT_BITMAP 15 |
17 | 32 | #define SRV_BLIT_TEXTURE 16 |
|
Line -... | Line 33... | ||
- | 33 | #define SRV_BLIT_VIDEO 17 |
|
- | 34 | ||
- | 35 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
|
- | 36 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
|
- | 37 | ||
18 | #define SRV_BLIT_VIDEO 20 |
38 | |
- | 39 | #define HW_BIT_BLIT (1<<0) /* BGRX blitter */ |
|
- | 40 | #define HW_TEX_BLIT (1<<1) /* stretch blit */ |
|
- | 41 | #define HW_VID_BLIT (1<<2) /* planar and packed video */ |
|
- | 42 | ||
- | 43 | uint32_t InitPixlib(uint32_t flags); |
|
- | 44 | ||
- | 45 | int create_bitmap(bitmap_t *bitmap); |
|
- | 46 | int lock_bitmap(bitmap_t *bitmap); |
|
Line 19... | Line 47... | ||
19 | 47 | int resize_bitmap(bitmap_t *bitmap); |
|
20 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
48 | int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, |
- | 49 | int w, int h); |
|
- | 50 | ||
- | 51 | ||
- | 52 | ||
- | 53 | static uint32_t service; |
|
- | 54 | static uint32_t blit_caps; |
|
- | 55 | static uint32_t screen_width; |
|
- | 56 | static uint32_t screen_height; |
|
- | 57 | ||
- | 58 | typedef struct |
|
- | 59 | { |
|
- | 60 | unsigned handle; |
|
- | 61 | unsigned io_code; |
|
- | 62 | void *input; |
|
Line 21... | Line 63... | ||
21 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
63 | int inp_size; |
22 | 64 | void *output; |
|
23 | //void InitPixlib(uint32_t flags); |
65 | int out_size; |
24 | 66 | }ioctl_t; |
|
Line 36... | Line 78... | ||
36 | uint32_t max_tex_height; |
78 | uint32_t max_tex_height; |
37 | }cap1; |
79 | }cap1; |
38 | }; |
80 | }; |
39 | }hwcaps_t; |
81 | }hwcaps_t; |
Line -... | Line 82... | ||
- | 82 | ||
- | 83 | static inline uint32_t GetScreenSize() |
|
- | 84 | { |
|
- | 85 | uint32_t retval; |
|
- | 86 | ||
- | 87 | __asm__ __volatile__( |
|
- | 88 | "int $0x40" |
|
- | 89 | :"=a"(retval) |
|
- | 90 | :"a"(61), "b"(1)); |
|
- | 91 | return retval; |
|
- | 92 | } |
|
40 | 93 | ||
41 | static uint32_t get_service(char *name) |
94 | static uint32_t get_service(char *name) |
42 | { |
95 | { |
43 | uint32_t retval = 0; |
96 | uint32_t retval = 0; |
44 | asm volatile ("int $0x40" |
97 | asm volatile ("int $0x40" |
Line 66... | Line 119... | ||
66 | 119 | ||
67 | 120 | ||
68 | uint32_t InitPixlib(uint32_t caps) |
121 | uint32_t InitPixlib(uint32_t caps) |
- | 122 | { |
|
69 | { |
123 | uint32_t api_version; |
70 | uint32_t api_version; |
124 | uint32_t screensize; |
Line 71... | Line 125... | ||
71 | hwcaps_t hwcaps; |
125 | hwcaps_t hwcaps; |
Line -... | Line 126... | ||
- | 126 | ioctl_t io; |
|
- | 127 | ||
- | 128 | // __asm__ __volatile__("int3"); |
|
- | 129 | ||
72 | ioctl_t io; |
130 | screensize = GetScreenSize(); |
73 | 131 | screen_width = screensize >> 16; |
|
74 | // __asm__ __volatile__("int3"); |
132 | screen_height = screensize & 0xFFFF; |
Line 75... | Line 133... | ||
75 | 133 | ||
Line 151... | Line 209... | ||
151 | // printf("create bitmap %d x %d\n", |
209 | // printf("create bitmap %d x %d\n", |
152 | // bitmap->width, bitmap->height); |
210 | // bitmap->width, bitmap->height); |
Line 153... | Line 211... | ||
153 | 211 | ||
154 | io_10.width = bitmap->width; |
212 | io_10.width = bitmap->width; |
155 | io_10.height = bitmap->height; |
213 | io_10.height = bitmap->height; |
156 | io_10.max_width = 0; |
214 | io_10.max_width = screen_width; |
157 | io_10.max_height = 0; |
215 | io_10.max_height = screen_height; |
Line 158... | Line 216... | ||
158 | io_10.format = 0; |
216 | io_10.format = 0; |
159 | 217 | ||
160 | io.handle = service; |
218 | io.handle = service; |
Line 199... | Line 257... | ||
199 | }; |
257 | }; |
Line 200... | Line 258... | ||
200 | 258 | ||
201 | int lock_bitmap(bitmap_t *bitmap) |
259 | int lock_bitmap(bitmap_t *bitmap) |
202 | { |
260 | { |
- | 261 | // __asm__ __volatile__("int3"); |
|
Line 203... | Line 262... | ||
203 | // __asm__ __volatile__("int3"); |
262 | int err = 0; |
204 | 263 | ||
205 | if( blit_caps & HW_BIT_BLIT ) |
264 | if( blit_caps & HW_BIT_BLIT ) |
206 | { |
265 | { |
207 | struct __attribute__((packed)) /* SRV_CREATE_SURFACE */ |
266 | struct __attribute__((packed)) /* SRV_LOCK_SURFACE */ |
208 | { |
- | |
209 | uint32_t handle; // ignored |
- | |
210 | void *data; // ignored |
267 | { |
211 | 268 | uint32_t handle; |
|
212 | uint32_t width; |
- | |
Line 213... | Line 269... | ||
213 | uint32_t height; |
269 | void *data; |
Line 214... | Line 270... | ||
214 | uint32_t pitch; // ignored |
270 | uint32_t pitch; |
215 | - | ||
Line 216... | Line 271... | ||
216 | }io_12; |
271 | |
217 | 272 | }io_12; |
|
218 | ioctl_t io; |
273 | |
Line 219... | Line 274... | ||
219 | int err; |
274 | ioctl_t io; |
220 | 275 | ||
221 | io_12.handle = bitmap->handle; |
276 | io_12.handle = bitmap->handle; |
222 | io_12.pitch = 0; |
277 | io_12.pitch = 0; |
223 | io_12.data = 0; |
278 | io_12.data = 0; |
224 | 279 | ||
Line 225... | Line 280... | ||
225 | io.handle = service; |
280 | io.handle = service; |
226 | io.io_code = SRV_LOCK_SURFACE; |
281 | io.io_code = SRV_LOCK_SURFACE; |
227 | io.input = &io_12; |
282 | io.input = &io_12; |
228 | io.inp_size = BUFFER_SIZE(5); |
283 | io.inp_size = BUFFER_SIZE(3); |
229 | io.output = NULL; |
284 | io.output = NULL; |
230 | io.out_size = 0; |
285 | io.out_size = 0; |
231 | 286 | ||
232 | err = call_service(&io); |
- | |
233 | if(err==0) |
- | |
234 | { |
- | |
235 | bitmap->pitch = io_12.pitch; |
287 | err = call_service(&io); |
236 | bitmap->data = io_12.data; |
- | |
237 | // printf("Lock hardware surface %x pitch %d, buffer %x\n", |
- | |
238 | // bitmap->handle, bitmap->pitch, bitmap->data); |
288 | if(err==0) |
Line 239... | Line -... | ||
239 | return 0; |
- | |
240 | }; |
- | |
241 | return err; |
- | |
242 | }; |
- | |
243 | - | ||
244 | return 0; |
- | |
245 | }; |
- | |
246 | 289 | { |
|
247 | struct blit_call |
- | |
248 | { |
- | |
249 | int dstx; |
- | |
250 | int dsty; |
- | |
251 | int w; |
- | |
252 | int h; |
- | |
253 | 290 | bitmap->pitch = io_12.pitch; |
|
Line 254... | Line 291... | ||
254 | int srcx; |
291 | bitmap->data = io_12.data; |
255 | int srcy; |
292 | // printf("Lock hardware surface %x pitch %d, buffer %x\n", |
256 | int srcw; |
293 | // bitmap->handle, bitmap->pitch, bitmap->data); |
- | 294 | }; |
|
Line 257... | Line 295... | ||
257 | int srch; |
295 | }; |
258 | 296 | ||
Line 259... | Line 297... | ||
259 | unsigned char *bitmap; |
297 | return err; |
Line 278... | Line 316... | ||
278 | int dst_y; |
316 | int dst_y; |
279 | int src_x; |
317 | int src_x; |
280 | int src_y; |
318 | int src_y; |
281 | uint32_t w; |
319 | uint32_t w; |
282 | uint32_t h; |
320 | uint32_t h; |
283 | }io_20; |
321 | }io_15; |
Line 284... | Line 322... | ||
284 | 322 | ||
285 | ioctl_t io; |
- | |
Line 286... | Line 323... | ||
286 | int err; |
323 | ioctl_t io; |
287 | 324 | ||
288 | io_20.handle = bitmap->handle; |
325 | io_15.handle = bitmap->handle; |
289 | io_20.dst_x = dst_x; |
326 | io_15.dst_x = dst_x; |
290 | io_20.dst_y = dst_y; |
327 | io_15.dst_y = dst_y; |
291 | io_20.src_x = 0; |
328 | io_15.src_x = 0; |
292 | io_20.src_y = 0; |
329 | io_15.src_y = 0; |
Line 293... | Line 330... | ||
293 | io_20.w = w; |
330 | io_15.w = w; |
294 | io_20.h = h; |
331 | io_15.h = h; |
295 | 332 | ||
296 | io.handle = service; |
333 | io.handle = service; |
297 | io.io_code = SRV_BLIT_VIDEO; |
334 | io.io_code = SRV_BLIT_BITMAP; |
298 | io.input = &io_20; |
335 | io.input = &io_15; |
Line 299... | Line 336... | ||
299 | io.inp_size = BUFFER_SIZE(7); |
336 | io.inp_size = BUFFER_SIZE(7); |
300 | io.output = NULL; |
337 | io.output = NULL; |
301 | io.out_size = 0; |
338 | io.out_size = 0; |
302 | - | ||
303 | // printf("do blit %x pitch %d\n",bitmap->handle, |
- | |
304 | // bitmap->pitch); |
- | |
305 | err = call_service(&io); |
- | |
306 | if (call_service(&io)==0) |
- | |
307 | { |
- | |
308 | //bitmap->data = NULL; Not now, Serge |
- | |
309 | // printf("blit done\n"); |
339 | |
310 | // delay(1); |
340 | // printf("do blit %x pitch %d\n",bitmap->handle, |
Line 311... | Line 341... | ||
311 | return 0; |
341 | // bitmap->pitch); |
Line 312... | Line 342... | ||
312 | }; |
342 | err = call_service(&io); |
313 | return err; |
343 | return err; |
314 | }; |
344 | }; |
315 | 345 | ||
Line 326... | Line 356... | ||
326 | bc.stride = bitmap->pitch; |
356 | bc.stride = bitmap->pitch; |
327 | bc.bitmap = bitmap->data; |
357 | bc.bitmap = bitmap->data; |
Line 328... | Line 358... | ||
328 | 358 | ||
329 | __asm__ __volatile__( |
359 | __asm__ __volatile__( |
- | 360 | "int $0x40" |
|
330 | "int $0x40" |
361 | :"=a"(err) |
331 | ::"a"(73),"b"(0x00),"c"(&bc) |
362 | :"a"(73),"b"(0x00),"c"(&bc) |
Line 332... | Line 363... | ||
332 | :"memory"); |
363 | :"memory"); |
333 | 364 | ||
Line 334... | Line -... | ||
334 | return 0; |
- | |
335 | }; |
- | |
336 | - | ||
337 | - | ||
338 | static inline void* user_realloc(void *mem, size_t size) |
- | |
339 | { |
- | |
340 | void *val; |
- | |
341 | __asm__ __volatile__( |
- | |
342 | "int $0x40" |
- | |
343 | :"=a"(val) |
- | |
344 | :"a"(68),"b"(20),"c"(size),"d"(mem) |
- | |
345 | :"memory"); |
- | |
346 | - | ||
347 | return val; |
365 | return err; |
348 | } |
366 | }; |
349 | 367 | ||
Line 350... | Line 368... | ||
350 | int resize_bitmap(bitmap_t *bitmap) |
368 | int resize_bitmap(bitmap_t *bitmap) |
351 | { |
369 | { |
- | 370 | // __asm__ __volatile__("int3"); |
|
- | 371 | ||
- | 372 | if( blit_caps & HW_BIT_BLIT ) |
|
352 | // __asm__ __volatile__("int3"); |
373 | { |
- | 374 | struct __attribute__((packed)) |
|
- | 375 | { |
|
- | 376 | uint32_t handle; |
|
- | 377 | char *data; |
|
- | 378 | uint32_t new_w; |
|
- | 379 | uint32_t new_h; |
|
- | 380 | uint32_t pitch; |
|
- | 381 | }io_14; |
|
- | 382 | ||
- | 383 | ioctl_t io; |
|
- | 384 | int err; |
|
- | 385 | ||
- | 386 | io_14.handle = bitmap->handle; |
|
- | 387 | io_14.new_w = bitmap->width; |
|
- | 388 | io_14.new_h = bitmap->height; |
|
- | 389 | ||
- | 390 | io.handle = service; |
|
- | 391 | io.io_code = SRV_RESIZE_SURFACE; |
|
- | 392 | io.input = &io_14; |
|
- | 393 | io.inp_size = BUFFER_SIZE(5); |
|
- | 394 | io.output = NULL; |
|
- | 395 | io.out_size = 0; |
|
- | 396 | ||
- | 397 | err = call_service(&io); |
|
- | 398 | if(err==0) |
|
- | 399 | { |
|
353 | 400 | bitmap->pitch = io_14.pitch; |
|
Line 354... | Line 401... | ||
354 | if( blit_caps & HW_BIT_BLIT ) |
401 | bitmap->data = io_14.data; |
355 | { |
402 | }; |
356 | /* work in progress */ |
403 | return err; |