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
for(i=0; i<count; i++) {
uint16_t r, g, b, p = *pix++;
- r = (p & 0x1f) << 3;
- if(r & 8) r |= 7; /* fill LSbits with whatever bit 0 was */
+ b = (p & 0x1f) << 3;
+ if(b & 8) b |= 7; /* fill LSbits with whatever bit 0 was */
g = (p >> 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;
uint16_t *pix = pptr;
for(i=0; i<count; i++) {
- uint16_t r = (uint16_t)(unp->r * 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++;
}
}
return 3 * sizeof(float);
case IMG_FMT_RGBAF:
return 4 * sizeof(float);
+ case IMG_FMT_RGB565:
+ return 2;
default:
break;
}
int fb_width, fb_height;
long fb_size;
-void *fb_pixels, *vmem;
+uint16_t *fb_pixels;
long time_msec;
return -1;
}
- draw = intro_draw;
- key_event = intro_keyb;
+ intro_start();
return 0;
}
#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;
}
}
-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; i<height; i++) {
memcpy(dest, src, width * 2);
- dest += 320;
+ dest += destwidth;
src += pitch_pix;
}
}
-void blitfb_key(uint16_t *dest, uint16_t *src, int width, int height, int pitch_pix, uint16_t key)
+void blit_key(uint16_t *dest, int destwidth, uint16_t *src, int width, int height, int pitch_pix, uint16_t key)
{
- int i, j, dadv = 320 - width;
+ int i, j, dadv = destwidth - width;
for(i=0; i<height; i++) {
for(j=0; j<width; j++) {
void convimg_rgb24_rgb16(uint16_t *dest, unsigned char *src, int xsz, int ysz);
-void blitfb(uint16_t *dest, uint16_t *src, int xsz, int ysz, int pitch_pix);
-void blitfb_key(uint16_t *dest, uint16_t *src, int xsz, int ysz, int pitch_pix, uint16_t key);
+void blit(uint16_t *dest, int destwidth, uint16_t *src, int xsz, int ysz, int pitch_pix);
+void blit_key(uint16_t *dest, int destwidth, uint16_t *src, int xsz, int ysz, int pitch_pix, uint16_t key);
#endif /* GFXUTIL_H_ */
#include "gfxutil.h"
#include "game.h"
-static void *bgpix;
+static const struct menuent {
+ int x, y, len, height;
+} menuent[] = {
+ {240, 300, 170, 32},
+ {230, 360, 184, 32},
+ {260, 424, 130, 32}
+};
+
+static int cur;
+
+static uint16_t *bgpix;
static int bgwidth, bgheight;
int menu_init(void)
{
- if(!(bgpix = img_load_pixels("data/menbg640.png", &bgwidth, &bgheight, IMG_FMT_RGB24))) {
+ if(!(bgpix = img_load_pixels("data/menbg640.png", &bgwidth, &bgheight, IMG_FMT_RGB565))) {
fprintf(stderr, "failed to load menu bg image\n");
return -1;
}
- convimg_rgb24_rgb16(bgpix, bgpix, bgwidth, bgheight);
return 0;
}
{
}
+
+
void menu_draw(void)
{
- blit_frame(bgpix, 1);
+ static uint16_t blurbuf[2][16384];
+ int y, offs;
+ int i, j;
+ const struct menuent *ent = menuent + cur;
+
+ y = ent->y - 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; i<ent->height; i++) {
+ for(j=0; j<ent->len; 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)