From 5a00ac1b6ff18814600e84e74d4d1e34847e9103 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Fri, 6 Mar 2020 05:37:57 +0200 Subject: [PATCH] foo --- GNUmakefile | 2 +- src/dos/main.c | 3 ++- src/menuscr.c | 32 +++++++++++++++++++++----------- src/sdl/main.c | 6 ++++-- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 65e3d47..817daff 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -7,7 +7,7 @@ bin = game 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 +LDFLAGS = $(arch) -Llibs/imago -limago $(sdl_ldflags) -lm ifneq ($(shell uname -m), i386) arch = -m32 diff --git a/src/dos/main.c b/src/dos/main.c index 8c3096b..7d7806b 100644 --- a/src/dos/main.c +++ b/src/dos/main.c @@ -10,6 +10,7 @@ static struct video_mode *vmode; static int quit; +static void *vmem; int main(int argc, char **argv) { @@ -44,7 +45,7 @@ int main(int argc, char **argv) status = -1; goto break_evloop; } - fb_pixels = (char*)fb_buf + vmode->pitch; + fb_pixels = (uint16_t*)((char*)fb_buf + vmode->pitch); if(init(argc, argv) == -1) { status = -1; diff --git a/src/menuscr.c b/src/menuscr.c index 51f8ae9..04b36f3 100644 --- a/src/menuscr.c +++ b/src/menuscr.c @@ -1,4 +1,5 @@ #include +#include #include "screens.h" #include "imago2.h" #include "gfx.h" @@ -8,9 +9,9 @@ static const struct menuent { int x, y, len, height; } menuent[] = { - {240, 300, 170, 32}, - {230, 360, 184, 32}, - {260, 424, 130, 32} + {240, 300, 170, 40}, + {230, 360, 184, 40}, + {260, 424, 130, 40} }; static int cur; @@ -52,27 +53,36 @@ void menu_draw(void) const struct menuent *ent = menuent + cur; y = ent->y - ent->height / 2; - offs = y * ent->len + ent->x; + offs = y * fb_width + 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]; - } - } + blur_grey_horiz(blurbuf[1], blurbuf[0], ent->len, ent->height, 7, 0x100); wait_vsync(); - blit_frame(bgpix, 0); + memcpy(fb_pixels, bgpix, fb_size); blit(fb_pixels + offs, fb_width, blurbuf[1], ent->len, ent->height, ent->len); + + blit_frame(fb_pixels, 0); } void menu_keyb(int key, int pressed) { + if(!pressed) return; + switch(key) { case 27: game_quit(); break; + + case KB_UP: + if(cur > 0) cur--; + break; + + case KB_DOWN: + if(cur < sizeof menuent / sizeof *menuent - 1) { + cur++; + } + break; } } diff --git a/src/sdl/main.c b/src/sdl/main.c index 8d60d12..616b23d 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -27,6 +27,7 @@ int main(int argc, char **argv) { int s; char *env; + void *fb_buf; if((env = getenv("FBSCALE")) && (s = atoi(env))) { fbscale = s; @@ -38,11 +39,12 @@ int main(int argc, char **argv) fb_width = xsz; fb_height = ysz; - /* allocate 1 extra row as a guard band, until we fucking fix the rasterizer */ - if(!(fb_pixels = malloc(FB_WIDTH * (FB_HEIGHT + 1) * FB_BPP / CHAR_BIT))) { + fb_size = FB_WIDTH * FB_HEIGHT * FB_BPP / 8; + if(!(fb_buf = malloc(fb_size + FB_WIDTH * 4))) { fprintf(stderr, "failed to allocate virtual framebuffer\n"); return 1; } + fb_pixels = (char*)fb_buf + FB_WIDTH * 2; SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE); if(!(fbsurf = SDL_SetVideoMode(xsz, ysz, FB_BPP, sdl_flags))) { -- 1.7.10.4