From 7b3c578d22e5eebc4d048655da7bc711662e2179 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Thu, 5 Mar 2020 17:48:34 +0200 Subject: [PATCH] fixed imago 565, started on menu --- GNUmakefile | 2 +- libs/imago/src/conv.c | 22 +++++++++++----------- libs/imago/src/imago2.c | 2 ++ src/game.c | 5 ++--- src/game.h | 4 +++- src/gfxutil.c | 8 ++++---- src/gfxutil.h | 4 ++-- src/menuscr.c | 38 ++++++++++++++++++++++++++++++++++---- 8 files changed, 59 insertions(+), 26 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index ccb0eb2..65e3d47 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,7 +4,7 @@ obj = $(csrc:.c=.o) dep = $(obj:.o=.d) bin = game -inc = -Isrc -Isrc/sdl -Isrc/3dgfx +inc = -Isrc -Isrc/sdl -Isrc/3dgfx -Ilibs/imago/src CFLAGS = $(arch) -pedantic -Wall -g -MMD $(inc) `sdl-config --cflags` LDFLAGS = $(arch) -Llibs/imago -limago `sdl-config --libs` -lm diff --git a/libs/imago/src/conv.c b/libs/imago/src/conv.c index bd7fb2d..51ecd1f 100644 --- a/libs/imago/src/conv.c +++ b/libs/imago/src/conv.c @@ -192,12 +192,12 @@ static void unpack_rgb565(struct pixel *unp, void *pptr, int count) for(i=0; i> 2) & 0xfc; if(g & 4) g |= 3; /* ditto */ - b = (p >> 8) & 0xf8; - if(b & 8) r |= 7; /* same */ + r = (p >> 8) & 0xf8; + if(r & 8) r |= 7; /* same */ unp->r = (float)r / 255.0f; unp->g = (float)g / 255.0f; @@ -292,13 +292,13 @@ static void pack_rgb565(void *pptr, struct pixel *unp, int count) uint16_t *pix = pptr; for(i=0; ir * 255.0f); - uint16_t g = (uint16_t)(unp->g * 255.0f); - uint16_t b = (uint16_t)(unp->b * 255.0f); - if(r > 255) r = 255; - if(g > 255) g = 255; - if(b > 255) b = 255; - *pix++ = (r >> 3) | ((g & 0x3f) << 2) | ((b & 0x1f) << 8); + uint16_t r = (uint16_t)(unp->r * 31.0f); + uint16_t g = (uint16_t)(unp->g * 63.0f); + uint16_t b = (uint16_t)(unp->b * 31.0f); + if(r > 31) r = 31; + if(g > 63) g = 63; + if(b > 31) b = 31; + *pix++ = (r << 11) | (g << 5) | b; unp++; } } diff --git a/libs/imago/src/imago2.c b/libs/imago/src/imago2.c index 30782dc..816f8c0 100644 --- a/libs/imago/src/imago2.c +++ b/libs/imago/src/imago2.c @@ -426,6 +426,8 @@ static int pixel_size(enum img_fmt fmt) return 3 * sizeof(float); case IMG_FMT_RGBAF: return 4 * sizeof(float); + case IMG_FMT_RGB565: + return 2; default: break; } diff --git a/src/game.c b/src/game.c index 2ec7c45..23aa25c 100644 --- a/src/game.c +++ b/src/game.c @@ -3,7 +3,7 @@ int fb_width, fb_height; long fb_size; -void *fb_pixels, *vmem; +uint16_t *fb_pixels; long time_msec; @@ -20,8 +20,7 @@ int init(int argc, char **argv) return -1; } - draw = intro_draw; - key_event = intro_keyb; + intro_start(); return 0; } diff --git a/src/game.h b/src/game.h index fa94d7a..a080fab 100644 --- a/src/game.h +++ b/src/game.h @@ -1,12 +1,14 @@ #ifndef GAME_H_ #define GAME_H_ +#include "inttypes.h" + #define FB_BPP 16 extern int fb_width; extern int fb_height; extern long fb_size; -extern void *fb_pixels, *vmem; +extern uint16_t *fb_pixels; extern long time_msec; diff --git a/src/gfxutil.c b/src/gfxutil.c index 173eb47..cc0732f 100644 --- a/src/gfxutil.c +++ b/src/gfxutil.c @@ -217,19 +217,19 @@ void convimg_rgb24_rgb16(uint16_t *dest, unsigned char *src, int xsz, int ysz) } } -void blitfb(uint16_t *dest, uint16_t *src, int width, int height, int pitch_pix) +void blit(uint16_t *dest, int destwidth, uint16_t *src, int width, int height, int pitch_pix) { int i; for(i=0; iy - ent->height / 2; + offs = y * ent->len + ent->x; + blit(blurbuf[0], ent->len, bgpix + offs, ent->len, ent->height, bgwidth); + + //blur_grey_horiz(blurbuf[1], blurbuf[0], ent->len, ent->height, 5, 0x100); + for(i=0; iheight; i++) { + for(j=0; jlen; j++) { + blurbuf[1][i * ent->len + j] = 0xff;//~blurbuf[0][i * ent->len + j]; + } + } + + wait_vsync(); + + blit_frame(bgpix, 0); + blit(fb_pixels + offs, fb_width, blurbuf[1], ent->len, ent->height, ent->len); } void menu_keyb(int key, int pressed) -- 1.7.10.4