1,12 → 1,23 |
#include <stdint.h> |
#include <libavcodec/avcodec.h> |
#include <libavformat/avformat.h> |
#include <libswscale/swscale.h> |
//#include <libavcodec/avcodec.h> |
//#include <libavformat/avformat.h> |
//#include <libswscale/swscale.h> |
#include <stdio.h> |
#include <fcntl.h> |
//#include <fcntl.h> |
#include "../winlib/winlib.h" |
#include "fplay.h" |
//#include "fplay.h" |
#include "system.h" |
|
typedef struct |
{ |
uint32_t width; |
uint32_t height; |
uint32_t pitch; |
uint32_t handle; |
uint8_t *data; |
}bitmap_t; |
|
|
#define DISPLAY_VERSION 0x0200 /* 2.00 */ |
|
#define SRV_GETVERSION 0 |
13,20 → 24,51 |
#define SRV_GET_CAPS 3 |
|
#define SRV_CREATE_SURFACE 10 |
#define SRV_DESTROY_SURFACE 11 |
#define SRV_LOCK_SURFACE 12 |
#define SRV_UNLOCK_SURFACE 13 |
#define SRV_RESIZE_SURFACE 14 |
#define SRV_BLIT_BITMAP 15 |
#define SRV_BLIT_TEXTURE 16 |
#define SRV_BLIT_VIDEO 17 |
|
#define SRV_BLIT_VIDEO 20 |
|
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
|
//void InitPixlib(uint32_t flags); |
|
#define HW_BIT_BLIT (1<<0) /* BGRX blitter */ |
#define HW_TEX_BLIT (1<<1) /* stretch blit */ |
#define HW_VID_BLIT (1<<2) /* planar and packed video */ |
|
uint32_t InitPixlib(uint32_t flags); |
|
int create_bitmap(bitmap_t *bitmap); |
int lock_bitmap(bitmap_t *bitmap); |
int resize_bitmap(bitmap_t *bitmap); |
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, |
int w, int h); |
|
|
|
static uint32_t service; |
static uint32_t blit_caps; |
static uint32_t screen_width; |
static uint32_t screen_height; |
|
typedef struct |
{ |
unsigned handle; |
unsigned io_code; |
void *input; |
int inp_size; |
void *output; |
int out_size; |
}ioctl_t; |
|
|
|
typedef struct |
{ |
uint32_t idx; |
union |
{ |
38,6 → 80,17 |
}; |
}hwcaps_t; |
|
static inline uint32_t GetScreenSize() |
{ |
uint32_t retval; |
|
__asm__ __volatile__( |
"int $0x40" |
:"=a"(retval) |
:"a"(61), "b"(1)); |
return retval; |
} |
|
static uint32_t get_service(char *name) |
{ |
uint32_t retval = 0; |
68,11 → 121,16 |
uint32_t InitPixlib(uint32_t caps) |
{ |
uint32_t api_version; |
uint32_t screensize; |
hwcaps_t hwcaps; |
ioctl_t io; |
|
// __asm__ __volatile__("int3"); |
|
screensize = GetScreenSize(); |
screen_width = screensize >> 16; |
screen_height = screensize & 0xFFFF; |
|
service = get_service("DISPLAY"); |
if(service == 0) |
goto fail; |
153,8 → 211,8 |
|
io_10.width = bitmap->width; |
io_10.height = bitmap->height; |
io_10.max_width = 0; |
io_10.max_height = 0; |
io_10.max_width = screen_width; |
io_10.max_height = screen_height; |
io_10.format = 0; |
|
io.handle = service; |
201,22 → 259,19 |
int lock_bitmap(bitmap_t *bitmap) |
{ |
// __asm__ __volatile__("int3"); |
int err = 0; |
|
if( blit_caps & HW_BIT_BLIT ) |
{ |
struct __attribute__((packed)) /* SRV_CREATE_SURFACE */ |
struct __attribute__((packed)) /* SRV_LOCK_SURFACE */ |
{ |
uint32_t handle; // ignored |
void *data; // ignored |
uint32_t handle; |
void *data; |
uint32_t pitch; |
|
uint32_t width; |
uint32_t height; |
uint32_t pitch; // ignored |
|
}io_12; |
|
ioctl_t io; |
int err; |
|
io_12.handle = bitmap->handle; |
io_12.pitch = 0; |
225,7 → 280,7 |
io.handle = service; |
io.io_code = SRV_LOCK_SURFACE; |
io.input = &io_12; |
io.inp_size = BUFFER_SIZE(5); |
io.inp_size = BUFFER_SIZE(3); |
io.output = NULL; |
io.out_size = 0; |
|
236,33 → 291,16 |
bitmap->data = io_12.data; |
// printf("Lock hardware surface %x pitch %d, buffer %x\n", |
// bitmap->handle, bitmap->pitch, bitmap->data); |
return 0; |
}; |
return err; |
}; |
|
return 0; |
return err; |
}; |
|
struct blit_call |
{ |
int dstx; |
int dsty; |
int w; |
int h; |
|
int srcx; |
int srcy; |
int srcw; |
int srch; |
|
unsigned char *bitmap; |
int stride; |
}; |
|
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, |
int w, int h) |
{ |
int err; |
|
if( blit_caps & HW_BIT_BLIT ) |
{ |
280,22 → 318,21 |
int src_y; |
uint32_t w; |
uint32_t h; |
}io_20; |
}io_15; |
|
ioctl_t io; |
int err; |
|
io_20.handle = bitmap->handle; |
io_20.dst_x = dst_x; |
io_20.dst_y = dst_y; |
io_20.src_x = 0; |
io_20.src_y = 0; |
io_20.w = w; |
io_20.h = h; |
io_15.handle = bitmap->handle; |
io_15.dst_x = dst_x; |
io_15.dst_y = dst_y; |
io_15.src_x = 0; |
io_15.src_y = 0; |
io_15.w = w; |
io_15.h = h; |
|
io.handle = service; |
io.io_code = SRV_BLIT_VIDEO; |
io.input = &io_20; |
io.io_code = SRV_BLIT_BITMAP; |
io.input = &io_15; |
io.inp_size = BUFFER_SIZE(7); |
io.output = NULL; |
io.out_size = 0; |
303,17 → 340,10 |
// printf("do blit %x pitch %d\n",bitmap->handle, |
// bitmap->pitch); |
err = call_service(&io); |
if (call_service(&io)==0) |
{ |
//bitmap->data = NULL; Not now, Serge |
// printf("blit done\n"); |
// delay(1); |
return 0; |
}; |
return err; |
}; |
|
volatile struct blit_call bc; |
struct blit_call bc; |
|
bc.dstx = dst_x; |
bc.dsty = dst_y; |
328,25 → 358,13 |
|
__asm__ __volatile__( |
"int $0x40" |
::"a"(73),"b"(0x00),"c"(&bc) |
:"=a"(err) |
:"a"(73),"b"(0x00),"c"(&bc) |
:"memory"); |
|
return 0; |
return err; |
}; |
|
|
static inline void* user_realloc(void *mem, size_t size) |
{ |
void *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(20),"c"(size),"d"(mem) |
:"memory"); |
|
return val; |
} |
|
int resize_bitmap(bitmap_t *bitmap) |
{ |
// __asm__ __volatile__("int3"); |
353,8 → 371,37 |
|
if( blit_caps & HW_BIT_BLIT ) |
{ |
/* work in progress */ |
struct __attribute__((packed)) |
{ |
uint32_t handle; |
char *data; |
uint32_t new_w; |
uint32_t new_h; |
uint32_t pitch; |
}io_14; |
|
ioctl_t io; |
int err; |
|
io_14.handle = bitmap->handle; |
io_14.new_w = bitmap->width; |
io_14.new_h = bitmap->height; |
|
io.handle = service; |
io.io_code = SRV_RESIZE_SURFACE; |
io.input = &io_14; |
io.inp_size = BUFFER_SIZE(5); |
io.output = NULL; |
io.out_size = 0; |
|
err = call_service(&io); |
if(err==0) |
{ |
bitmap->pitch = io_14.pitch; |
bitmap->data = io_14.data; |
}; |
return err; |
}; |
|
uint32_t size; |
uint32_t pitch; |