| 1 | #include "DHL_OSAL.h" |
|---|
| 2 | #include "DHL_DBG.h" |
|---|
| 3 | #include "bgfx_types.h" |
|---|
| 4 | #include "bsettop_graphics.h" |
|---|
| 5 | |
|---|
| 6 | static unsigned char* osd_mem=NULL; |
|---|
| 7 | static bgraphics_t graphics; |
|---|
| 8 | static bdisplay_t display; |
|---|
| 9 | static int g_width = 720; |
|---|
| 10 | static int g_height = 480; |
|---|
| 11 | |
|---|
| 12 | //¹Ýµå½Ã ÃÖÃÊ·Î ºÒ·¯ÁÙ °Í. --> TODO: initÀ¸·Î µû·Î ¶¼¾î³õÀ» °Í |
|---|
| 13 | void dhl_set_display(bdisplay_t disp) |
|---|
| 14 | { |
|---|
| 15 | display=disp; |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | typedef struct dhl_bin_read_t |
|---|
| 19 | { |
|---|
| 20 | int cnt; |
|---|
| 21 | int size; |
|---|
| 22 | unsigned char *data; |
|---|
| 23 | } dhl_bin_read_t; |
|---|
| 24 | |
|---|
| 25 | int bin_read( void *buffer, int size, int count, void *fp ) |
|---|
| 26 | { |
|---|
| 27 | dhl_bin_read_t *p_br = (dhl_bin_read_t*)fp; |
|---|
| 28 | size = size * count; |
|---|
| 29 | if (p_br->cnt + size > p_br->size) |
|---|
| 30 | { |
|---|
| 31 | printf("Requesting more bytes than available (cnt = %d, size = %d,total = %d)\n", |
|---|
| 32 | p_br->cnt,size,p_br->size); |
|---|
| 33 | size = p_br->size - p_br->cnt; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | memcpy(buffer,&p_br->data[p_br->cnt],size); |
|---|
| 37 | p_br->cnt += size; |
|---|
| 38 | return size; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | unsigned int bin_tell(void *fp ) |
|---|
| 42 | { |
|---|
| 43 | dhl_bin_read_t *p_br = (dhl_bin_read_t*)fp; |
|---|
| 44 | |
|---|
| 45 | return p_br->cnt; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | int bin_set(void *fp, int offset, int whence ) |
|---|
| 49 | { |
|---|
| 50 | dhl_bin_read_t *p_br = (dhl_bin_read_t*)fp; |
|---|
| 51 | |
|---|
| 52 | if ((whence != 0) || ((unsigned int)offset > p_br->size)) |
|---|
| 53 | return -1; |
|---|
| 54 | |
|---|
| 55 | p_br->cnt = offset; |
|---|
| 56 | return 0; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | static bgfx_io_t gfx_io = |
|---|
| 60 | { |
|---|
| 61 | bin_read, |
|---|
| 62 | bin_tell, |
|---|
| 63 | bin_set |
|---|
| 64 | }; |
|---|
| 65 | |
|---|
| 66 | static bgfx_hw_t s_gfx_hw = {(BGFX_HW_FILL)bsurface_fill, (BGFX_HW_BLIT)bsurface_blit_surface, (BGFX_HW_SURFACE_CREATE)bsurface_create_surface}; |
|---|
| 67 | static bgfx_hw_t *s_p_gfx_hw = &s_gfx_hw; |
|---|
| 68 | |
|---|
| 69 | int bgfx_init(bgfx_io_t *io_p,bgfx_prot_t *prot_p,bgfx_hw_t *hw_p); |
|---|
| 70 | int bgfx_create(bgfx_surf_p p,uint16_t width,uint16_t height, |
|---|
| 71 | uint8_t *ptr, uint16_t pitch, |
|---|
| 72 | bgfx_palette_t *palette, |
|---|
| 73 | uint32_t flags); |
|---|
| 74 | |
|---|
| 75 | DHL_RESULT DHL_GrpInit() |
|---|
| 76 | { |
|---|
| 77 | static bool binit = false; |
|---|
| 78 | if (binit == true) return; |
|---|
| 79 | binit = true; |
|---|
| 80 | |
|---|
| 81 | bgfx_surf_t surf; |
|---|
| 82 | int pitch=0; |
|---|
| 83 | unsigned int *main_palette; |
|---|
| 84 | |
|---|
| 85 | bgraphics_settings graphics_settings; |
|---|
| 86 | bgraphics_get(&graphics_settings); |
|---|
| 87 | graphics_settings.format = bgraphics_pixel_format_a8_r8_g8_b8; |
|---|
| 88 | bgraphics_set(&graphics_settings); |
|---|
| 89 | BDBG_ASSERT(display != NULL); |
|---|
| 90 | graphics = bgraphics_open(B_ID(0),display); |
|---|
| 91 | bgraphics_get_framebuffer(graphics,(void**)&osd_mem,&main_palette,&g_width,&g_height, &pitch); |
|---|
| 92 | bgraphics_load_palette(graphics); |
|---|
| 93 | bgfx_init(&gfx_io,NULL, s_p_gfx_hw); |
|---|
| 94 | |
|---|
| 95 | bgraphics_get_osd_params(graphics,(bsettop_surf_t*)&(surf),(void**)&(osd_mem),NULL,NULL); |
|---|
| 96 | bgfx_create(&surf,g_width,g_height,(unsigned char *)osd_mem, pitch,NULL,BGFX_SURF_BPP(32)|BGFX_SURF_RGB|BGFX_SURF_GRC); |
|---|
| 97 | memset(osd_mem, 0, g_width * g_height * 4); |
|---|
| 98 | bgraphics_sync(graphics, false); |
|---|
| 99 | return DHL_OK; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | // NEWCON3KRÈ£Ãâ ÇÔ¼ö |
|---|
| 103 | void dhl_draw_image2(char* src, int x, int y, int w, int h) |
|---|
| 104 | { |
|---|
| 105 | char* des = osd_mem + (y * g_width + x) * 4; |
|---|
| 106 | int src_delta = w*4; |
|---|
| 107 | int des_delta = g_width*4; |
|---|
| 108 | int hh =h; |
|---|
| 109 | while (hh--) |
|---|
| 110 | { |
|---|
| 111 | memcpy(des, src, src_delta); |
|---|
| 112 | src += src_delta; |
|---|
| 113 | des += des_delta; |
|---|
| 114 | } |
|---|
| 115 | bgraphics_sync(graphics, false); |
|---|
| 116 | } |
|---|