Rev 3068 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3068 | Rev 3248 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | #include |
- | |
2 | //#include |
- | |
3 | //#include |
- | |
4 | //#include |
- | |
- | 1 | #include |
|
5 | #include |
2 | #include |
6 | //#include |
3 | #include "system.h" |
7 | #include "../winlib/winlib.h" |
- | |
8 | //#include "fplay.h" |
- | |
9 | #include "system.h" |
4 | |
Line 10... | Line -... | ||
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; |
- | |
Line 19... | Line 5... | ||
19 | 5 | ||
Line 20... | Line 6... | ||
20 | 6 | #define DISPLAY_VERSION 0x0200 /* 2.00 */ |
|
21 | #define DISPLAY_VERSION 0x0200 /* 2.00 */ |
7 | |
Line 30... | Line 16... | ||
30 | #define SRV_RESIZE_SURFACE 14 |
16 | #define SRV_BLIT_BITMAP 15 |
31 | #define SRV_BLIT_BITMAP 15 |
17 | #define SRV_BLIT_TEXTURE 16 |
32 | #define SRV_BLIT_TEXTURE 16 |
18 | #define SRV_BLIT_VIDEO 17 |
33 | #define SRV_BLIT_VIDEO 17 |
19 | |
Line -... | Line 20... | ||
- | 20 | ||
- | 21 | #define BUFFER_SIZE(n) ((n)*sizeof(uint32_t)) |
|
34 | 22 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
|
35 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
23 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
Line 36... | Line -... | ||
36 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
- | |
37 | - | ||
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); |
- | |
47 | int resize_bitmap(bitmap_t *bitmap); |
- | |
48 | int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, |
- | |
Line 49... | Line 24... | ||
49 | int w, int h); |
24 | |
50 | 25 | ||
51 | 26 | ||
52 | 27 | static uint32_t service; |
|
Line 112... | Line 87... | ||
112 | :"memory","cc"); |
87 | |
Line 113... | Line 88... | ||
113 | 88 | return retval; |
|
114 | return retval; |
89 | }; |
Line 115... | Line -... | ||
115 | }; |
- | |
116 | - | ||
Line 117... | Line -... | ||
117 | #define BUFFER_SIZE(n) ((n)*sizeof(uint32_t)) |
- | |
118 | 90 | ||
119 | 91 | ||
120 | 92 | uint32_t init_pixlib(uint32_t caps) |
|
121 | uint32_t InitPixlib(uint32_t caps) |
93 | { |
122 | { |
94 | uint32_t api_version; |
123 | uint32_t api_version; |
95 | uint32_t screensize; |
Line 185... | Line 157... | ||
185 | 157 | int create_bitmap(bitmap_t *bitmap) |
|
186 | int create_bitmap(bitmap_t *bitmap) |
158 | { |
187 | { |
159 | // __asm__ __volatile__("int3"); |
Line 188... | Line 160... | ||
188 | // __asm__ __volatile__("int3"); |
160 | |
189 | 161 | if( bitmap->flags && blit_caps & HW_BIT_BLIT ) |
|
190 | if( blit_caps & HW_BIT_BLIT ) |
162 | { |
191 | { |
163 | struct __attribute__((packed)) /* SRV_CREATE_SURFACE */ |
192 | struct __attribute__((packed)) /* SRV_CREATE_SURFACE */ |
164 | { |
193 | { |
165 | uint32_t handle; // ignored |
Line 230... | Line 202... | ||
230 | bitmap->data = io_10.data; |
202 | // printf("Create hardware surface %x pitch %d, buffer %x\n", |
231 | // printf("Create hardware surface %x pitch %d, buffer %x\n", |
203 | // bitmap->handle, bitmap->pitch, bitmap->data); |
232 | // bitmap->handle, bitmap->pitch, bitmap->data); |
204 | return 0; |
233 | return 0; |
205 | }; |
234 | }; |
206 | }; |
235 | return err; |
- | |
236 | }; |
207 | |
Line 237... | Line 208... | ||
237 | 208 | uint32_t size; |
|
238 | uint32_t size; |
209 | uint32_t pitch; |
239 | uint32_t pitch; |
210 | uint8_t *buffer; |
Line 246... | Line 217... | ||
246 | if( buffer ) |
217 | { |
247 | { |
218 | bitmap->handle = 0; |
248 | bitmap->handle = 0; |
219 | bitmap->pitch = pitch; |
249 | bitmap->pitch = pitch; |
220 | bitmap->data = buffer; |
250 | bitmap->data = buffer; |
221 | bitmap->flags = 0; |
- | 222 | return 0; |
|
251 | return 0; |
223 | }; |
252 | }; |
224 | |
Line 253... | Line 225... | ||
253 | 225 | printf("Cannot alloc frame buffer\n\r"); |
|
Line 259... | Line 231... | ||
259 | int lock_bitmap(bitmap_t *bitmap) |
231 | { |
260 | { |
232 | // __asm__ __volatile__("int3"); |
261 | // __asm__ __volatile__("int3"); |
233 | int err = 0; |
262 | int err = 0; |
234 | |
Line 263... | Line 235... | ||
263 | 235 | if( bitmap->flags && blit_caps & HW_BIT_BLIT ) |
|
264 | if( blit_caps & HW_BIT_BLIT ) |
236 | { |
265 | { |
237 | struct __attribute__((packed)) /* SRV_LOCK_SURFACE */ |
266 | struct __attribute__((packed)) /* SRV_LOCK_SURFACE */ |
238 | { |
267 | { |
239 | uint32_t handle; |
268 | uint32_t handle; |
240 | void *data; |
Line 300... | Line 272... | ||
300 | int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, |
272 | int w, int h) |
301 | int w, int h) |
273 | { |
302 | { |
274 | int err; |
303 | int err; |
275 | |
Line 304... | Line 276... | ||
304 | 276 | if( bitmap->flags && blit_caps & HW_BIT_BLIT ) |
|
305 | if( blit_caps & HW_BIT_BLIT ) |
277 | { |
Line 306... | Line 278... | ||
306 | { |
278 | |
307 | 279 | /* |
|
308 | /* |
280 | * Now you will experience the full power of the dark side... |
Line 367... | Line 339... | ||
367 | 339 | int resize_bitmap(bitmap_t *bitmap) |
|
368 | int resize_bitmap(bitmap_t *bitmap) |
340 | { |
369 | { |
341 | // __asm__ __volatile__("int3"); |
Line 370... | Line 342... | ||
370 | // __asm__ __volatile__("int3"); |
342 | |
371 | 343 | if( bitmap->flags && blit_caps & HW_BIT_BLIT ) |
|
372 | if( blit_caps & HW_BIT_BLIT ) |
344 | { |
373 | { |
345 | struct __attribute__((packed)) |
374 | struct __attribute__((packed)) |
346 | { |
375 | { |
347 | uint32_t handle; |