From: John Tsiombikas Date: Fri, 6 Mar 2020 19:43:33 +0000 (+0200) Subject: menu X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=eradicate;a=commitdiff_plain;h=ae47c13224ea63ac83f80ab332f7436b3265cdce menu --- diff --git a/Makefile b/Makefile index bcebb62..cf58921 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ LD = wlink CFLAGS = -d3 -5 -fp5 -otebmileran $(def) -s -zq -bt=dos $(incpath) LDFLAGS = option map $(libpath) library { $(libs) } -$(bin): $(obj) +$(bin): cflags.occ $(obj) libs/imago/imago.lib %write objects.lnk $(obj) %write ldflags.lnk $(LDFLAGS) $(LD) debug all name $@ system dos4g file { @objects } @ldflags @@ -39,8 +39,11 @@ $(bin): $(obj) .c: src;src/dos;src/3dgfx .asm: src;src/dos;src/3dgfx +cflags.occ: Makefile + %write $@ $(CFLAGS) + .c.obj: .autodepend - $(CC) -fo=$@ $(CFLAGS) $[* + $(CC) -fo=$@ @cflags.occ $[* .asm.obj: nasm -f obj -o $@ $[*.asm @@ -49,10 +52,12 @@ $(bin): $(obj) clean: .symbolic rm -f $(obj) rm -f $(bin) + rm -f cflags.occ *.lnk !else clean: .symbolic del src\*.obj del src\dos\*.obj del *.lnk + del cflags.occ del $(bin) !endif diff --git a/src/dos/gfx.c b/src/dos/gfx.c index c9a153d..cde439e 100644 --- a/src/dos/gfx.c +++ b/src/dos/gfx.c @@ -83,6 +83,7 @@ int init_video(void) vmptr->rmask = calc_mask(minf.rsize, minf.rpos); vmptr->gmask = calc_mask(minf.gsize, minf.gpos); vmptr->bmask = calc_mask(minf.bsize, minf.bpos); + vmptr->bpp = vmptr->rbits + vmptr->gbits + vmptr->bbits; } if(minf.attr & VBE_ATTR_LFB) { vmptr->fb_addr = minf.fb_addr; diff --git a/src/gfxutil.c b/src/gfxutil.c index cc0732f..64d5b7b 100644 --- a/src/gfxutil.c +++ b/src/gfxutil.c @@ -147,34 +147,58 @@ void draw_line(int x0, int y0, int x1, int y1, unsigned short color) #define BLUR(w, h, pstep, sstep) \ for(i=0; i #include +#include #include "screens.h" #include "imago2.h" #include "gfx.h" @@ -9,9 +10,9 @@ static const struct menuent { int x, y, len, height; } menuent[] = { - {240, 300, 170, 40}, - {230, 360, 184, 40}, - {260, 424, 130, 40} + {240, 300, 170, 48}, + {230, 360, 184, 48}, + {260, 424, 130, 48} }; static int cur; @@ -44,24 +45,36 @@ void menu_stop(void) } +#define BBW 512 +#define BBH 128 void menu_draw(void) { - static uint16_t blurbuf[2][16384]; - int y, offs; - int i, j; + static uint16_t blurbuf[2][BBW * BBH]; + int fboffs, bboffs, tmp; const struct menuent *ent = menuent + cur; - y = ent->y - ent->height / 2; - offs = y * fb_width + ent->x; - blit(blurbuf[0], ent->len, bgpix + offs, ent->len, ent->height, bgwidth); + int blur_rad_x = (int)((sin(time_msec / 1000.0f) * 0.5f + 0.5f) * 50.0f); + int blur_rad_y = (int)((cos(time_msec / 1000.0f) * 0.5f + 0.5f) * 50.0f); - blur_grey_horiz(blurbuf[1], blurbuf[0], ent->len, ent->height, 7, 0x100); + fboffs = (ent->y - ent->height / 2) * fb_width + ent->x; + bboffs = (BBH - ent->height) / 2 * BBW + BBW / 2; + + memset(blurbuf[0], 0, sizeof blurbuf[0]); + blit(blurbuf[0] + bboffs, BBW, bgpix + fboffs, ent->len, ent->height, bgwidth); + + blur_horiz(blurbuf[1], blurbuf[0], BBW, BBH, blur_rad_x + 3, 0x140); + blur_vert(blurbuf[0], blurbuf[1], BBW, BBH, blur_rad_y / 4 + 3, 0x140); wait_vsync(); memcpy(fb_pixels, bgpix, fb_size); - blit(fb_pixels + offs, fb_width, blurbuf[1], ent->len, ent->height, ent->len); + tmp = fboffs; + fboffs -= 16 * fb_width + 128; + bboffs -= 16 * BBW + 128; + blit_key(fb_pixels + fboffs, fb_width, blurbuf[0] + bboffs, ent->len + 256, ent->height + 32, BBW, 0); + fboffs = tmp; + //blit_key(fb_pixels + fboffs, fb_width, bgpix + fboffs, ent->len, ent->height, bgwidth, 0); blit_frame(fb_pixels, 0); } @@ -84,5 +97,21 @@ void menu_keyb(int key, int pressed) cur++; } break; + + case '\n': + case '\r': + switch(cur) { + case 0: + /* enter game */ + break; + + case 1: + //options_start(); + break; + + case 2: + game_quit(); + break; + } } } diff --git a/src/sdl/main.c b/src/sdl/main.c index 616b23d..84bbe00 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) fprintf(stderr, "failed to allocate virtual framebuffer\n"); return 1; } - fb_pixels = (char*)fb_buf + FB_WIDTH * 2; + fb_pixels = (uint16_t*)((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))) { diff --git a/tools/scripts/instdfs b/tools/scripts/instdfs new file mode 100755 index 0000000..24ebf80 --- /dev/null +++ b/tools/scripts/instdfs @@ -0,0 +1,58 @@ +#!/bin/sh + +# NOTES: +# source: svn co https://svn.code.sf.net/p/etherdfs/code +# +# on DOS: etherdfs C-Z +# on GNU/Linux: sudo ethersrv-linux eth0 /etherdfs +# +# /etherdfs is a mount point for a FAT16 image, fstab entry: +# /home/nuclear/code/dos/etherdfs.img /etherdfs msdos loop,fmask=0113,dmask=0002,gid=6 0 0 + +destdir=/etherdfs/eradicat +rev=false +have_dest_arg=false + +for arg in "$@"; do + case "$arg" in + -r) + rev=true + ;; + + -*) + echo "invalid option: $arg" + exit 1 + ;; + + *) + if $have_dest_arg; then + echo "unexpected argument: $arg" + exit 1 + fi + destdir=$arg + have_dest_arg=true + ;; + esac +done + +if $rev; then + cwd=`pwd` + cd $destdir + destdir=$cwd +else + mkdir -p $destdir/data + cp game.exe $destdir + rm -f $destdir/data/* + cp data/* $destdir/data/ +fi + +findsrc() +{ + find . -name '*.c' -o -name '*.h' -o -name '*.asm' -o -name '*.inc' \ + -o -name '*.inl' -o -name Makefile | sed 's/\.\///' +} +for i in `findsrc`; do + dir=`dirname $i` + mkdir -p $destdir/$dir + cp $i $destdir/$i +done diff --git a/tools/scripts/pceminst b/tools/scripts/pceminst new file mode 100755 index 0000000..30244e2 --- /dev/null +++ b/tools/scripts/pceminst @@ -0,0 +1,20 @@ +#!/bin/sh + +# NOTES: +# assumes a PCem setup with a fat16 image mounted at /pcem_dos. fstab entry: +# /home/nuclear/.pcem/pentium_dos.img /pcem_dos msdos user,noauto,loop,fmask=0113,dmask=0002,gid=6,offset=32256 0 0 + +mntpt=/pcem_dos +do_umount=false + +if ! ( mount | grep pcem ); then + mount $mntpt || exit 1 + do_umount=true +fi + +tools/scripts/instdfs $mntpt/tmp + +if $do_umount; then + umount $mntpt +fi +sync