menu
authorJohn Tsiombikas <nuclear@member.fsf.org>
Fri, 6 Mar 2020 19:43:33 +0000 (21:43 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Fri, 6 Mar 2020 19:43:33 +0000 (21:43 +0200)
Makefile
src/dos/gfx.c
src/gfxutil.c
src/gfxutil.h
src/menuscr.c
src/sdl/main.c
tools/scripts/instdfs [new file with mode: 0755]
tools/scripts/pceminst [new file with mode: 0755]

index bcebb62..cf58921 100644 (file)
--- 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) }
 
 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
        %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
 
 .c: src;src/dos;src/3dgfx
 .asm: src;src/dos;src/3dgfx
 
+cflags.occ: Makefile
+       %write $@ $(CFLAGS)
+
 .c.obj: .autodepend
 .c.obj: .autodepend
-       $(CC) -fo=$@ $(CFLAGS) $[*
+       $(CC) -fo=$@ @cflags.occ $[*
 
 .asm.obj:
        nasm -f obj -o $@ $[*.asm
 
 .asm.obj:
        nasm -f obj -o $@ $[*.asm
@@ -49,10 +52,12 @@ $(bin): $(obj)
 clean: .symbolic
        rm -f $(obj)
        rm -f $(bin)
 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
 !else
 clean: .symbolic
        del src\*.obj
        del src\dos\*.obj
        del *.lnk
+       del cflags.occ
        del $(bin)
 !endif
        del $(bin)
 !endif
index c9a153d..cde439e 100644 (file)
@@ -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->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;
                }
                if(minf.attr & VBE_ATTR_LFB) {
                        vmptr->fb_addr = minf.fb_addr;
index cc0732f..64d5b7b 100644 (file)
@@ -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<h; i++) { \
 
 #define BLUR(w, h, pstep, sstep) \
        for(i=0; i<h; i++) { \
-               int sum = sptr[0] * (rad + 1); \
+               int r, g, b; \
+               int rsum = UNPACK_R16(sptr[0]) * (rad + 1); \
+               int gsum = UNPACK_G16(sptr[0]) * (rad + 1); \
+               int bsum = UNPACK_B16(sptr[0]) * (rad + 1); \
                int count = (rad * 2 + 1) << 8; \
                int midsize = w - rad * 2; \
                int count = (rad * 2 + 1) << 8; \
                int midsize = w - rad * 2; \
-               int firstpix = sptr[0]; \
-               int lastpix = sptr[pstep * (w - 1)]; \
+               int rfirstpix = UNPACK_R16(sptr[0]); \
+               int rlastpix = UNPACK_R16(sptr[pstep * (w - 1)]); \
+               int gfirstpix = UNPACK_G16(sptr[0]); \
+               int glastpix = UNPACK_G16(sptr[pstep * (w - 1)]); \
+               int bfirstpix = UNPACK_B16(sptr[0]); \
+               int blastpix = UNPACK_B16(sptr[pstep * (w - 1)]); \
                /* add up the contributions for the -1 pixel */ \
                for(j=0; j<rad; j++) { \
                /* add up the contributions for the -1 pixel */ \
                for(j=0; j<rad; j++) { \
-                       sum += sptr[pstep * j]; \
+                       rsum += UNPACK_R16(sptr[pstep * j]); \
+                       gsum += UNPACK_G16(sptr[pstep * j]); \
+                       bsum += UNPACK_B16(sptr[pstep * j]); \
                } \
                /* first part adding sptr[rad] and subtracting sptr[0] */ \
                for(j=0; j<=rad; j++) { \
                } \
                /* first part adding sptr[rad] and subtracting sptr[0] */ \
                for(j=0; j<=rad; j++) { \
-                       sum += (int)sptr[pstep * rad] - firstpix; \
+                       rsum += UNPACK_R16((int)sptr[pstep * rad]) - rfirstpix; \
+                       gsum += UNPACK_G16((int)sptr[pstep * rad]) - gfirstpix; \
+                       bsum += UNPACK_B16((int)sptr[pstep * rad]) - bfirstpix; \
                        sptr += pstep; \
                        sptr += pstep; \
-                       *dptr = scale * sum / count; \
+                       r = scale * rsum / count; \
+                       g = scale * gsum / count; \
+                       b = scale * bsum / count; \
+                       *dptr = PACK_RGB16(r, g, b); \
                        dptr += pstep; \
                } \
                /* middle part adding sptr[rad] and subtracting sptr[-(rad+1)] */ \
                for(j=1; j<midsize; j++) { \
                        dptr += pstep; \
                } \
                /* middle part adding sptr[rad] and subtracting sptr[-(rad+1)] */ \
                for(j=1; j<midsize; j++) { \
-                       sum += (int)sptr[pstep * rad] - (int)sptr[-(rad + 1) * pstep]; \
+                       rsum += UNPACK_R16((int)sptr[pstep * rad]) - UNPACK_R16((int)sptr[-(rad + 1) * pstep]); \
+                       gsum += UNPACK_G16((int)sptr[pstep * rad]) - UNPACK_G16((int)sptr[-(rad + 1) * pstep]); \
+                       bsum += UNPACK_B16((int)sptr[pstep * rad]) - UNPACK_B16((int)sptr[-(rad + 1) * pstep]); \
                        sptr += pstep; \
                        sptr += pstep; \
-                       *dptr = scale * sum / count; \
+                       r = scale * rsum / count; \
+                       g = scale * gsum / count; \
+                       b = scale * bsum / count; \
+                       *dptr = PACK_RGB16(r, g, b); \
                        dptr += pstep; \
                } \
                /* last part adding lastpix and subtracting sptr[-(rad+1)] */ \
                for(j=0; j<rad; j++) { \
                        dptr += pstep; \
                } \
                /* last part adding lastpix and subtracting sptr[-(rad+1)] */ \
                for(j=0; j<rad; j++) { \
-                       sum += lastpix - (int)sptr[-(rad + 1) * pstep]; \
+                       rsum += rlastpix - UNPACK_R16((int)sptr[-(rad + 1) * pstep]); \
+                       gsum += glastpix - UNPACK_G16((int)sptr[-(rad + 1) * pstep]); \
+                       bsum += blastpix - UNPACK_B16((int)sptr[-(rad + 1) * pstep]); \
                        sptr += pstep; \
                        sptr += pstep; \
-                       *dptr = scale * sum / count; \
+                       r = scale * rsum / count; \
+                       g = scale * gsum / count; \
+                       b = scale * bsum / count; \
+                       *dptr = PACK_RGB16(r, g, b); \
                        dptr += pstep; \
                } \
                sptr += sstep; \
                        dptr += pstep; \
                } \
                sptr += sstep; \
@@ -183,23 +207,23 @@ void draw_line(int x0, int y0, int x1, int y1, unsigned short color)
 
 /* TODO bound blur rad to image size to avoid inner loop conditionals */
 /* TODO make version with pow2 (rad*2+1) to avoid div with count everywhere */
 
 /* TODO bound blur rad to image size to avoid inner loop conditionals */
 /* TODO make version with pow2 (rad*2+1) to avoid div with count everywhere */
-void blur_grey_horiz(uint16_t *dest, uint16_t *src, int xsz, int ysz, int rad, int scale)
+void blur_horiz(uint16_t *dest, uint16_t *src, int xsz, int ysz, int rad, int scale)
 {
        int i, j;
 {
        int i, j;
-       unsigned char *dptr = (unsigned char*)dest;
-       unsigned char *sptr = (unsigned char*)src;
+       uint16_t *dptr = dest;
+       uint16_t *sptr = src;
 
 
-       BLUR(xsz, ysz, 2, 0);
+       BLUR(xsz, ysz, 1, 0);
 }
 
 
 }
 
 
-void blur_grey_vert(uint16_t *dest, uint16_t *src, int xsz, int ysz, int rad, int scale)
+void blur_vert(uint16_t *dest, uint16_t *src, int xsz, int ysz, int rad, int scale)
 {
        int i, j;
 {
        int i, j;
-       unsigned char *dptr = (unsigned char*)dest;
-       unsigned char *sptr = (unsigned char*)src;
-       int pixel_step = xsz * 2;
-       int scanline_step = 2 - ysz * pixel_step;
+       uint16_t *dptr = dest;
+       uint16_t *sptr = src;
+       int pixel_step = xsz;
+       int scanline_step = 1 - ysz * pixel_step;
 
        BLUR(ysz, xsz, pixel_step, scanline_step);
 }
 
        BLUR(ysz, xsz, pixel_step, scanline_step);
 }
@@ -229,7 +253,9 @@ void blit(uint16_t *dest, int destwidth, uint16_t *src, int width, int height, i
 
 void blit_key(uint16_t *dest, int destwidth, 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 = destwidth - width;
+       int i, j;
+       int dadv = destwidth - width;
+       int sadv = pitch_pix - width;
 
        for(i=0; i<height; i++) {
                for(j=0; j<width; j++) {
 
        for(i=0; i<height; i++) {
                for(j=0; j<width; j++) {
@@ -238,6 +264,7 @@ void blit_key(uint16_t *dest, int destwidth, uint16_t *src, int width, int heigh
                        dest++;
                }
                dest += dadv;
                        dest++;
                }
                dest += dadv;
+               src += sadv;
        }
 
 }
        }
 
 }
index 6f33339..8695f26 100644 (file)
@@ -23,8 +23,8 @@ int clip_line(int *x0, int *y0, int *x1, int *y1, int xmin, int ymin, int xmax,
 void draw_line(int x0, int y0, int x1, int y1, unsigned short color);
 
 /* scale in 24.8 fixed point */
 void draw_line(int x0, int y0, int x1, int y1, unsigned short color);
 
 /* scale in 24.8 fixed point */
-void blur_grey_horiz(uint16_t *dest, uint16_t *src, int xsz, int ysz, int radius, int scale);
-void blur_grey_vert(uint16_t *dest, uint16_t *src, int xsz, int ysz, int radius, int scale);
+void blur_horiz(uint16_t *dest, uint16_t *src, int xsz, int ysz, int radius, int scale);
+void blur_vert(uint16_t *dest, uint16_t *src, int xsz, int ysz, int radius, int scale);
 
 void convimg_rgb24_rgb16(uint16_t *dest, unsigned char *src, int xsz, int ysz);
 
 
 void convimg_rgb24_rgb16(uint16_t *dest, unsigned char *src, int xsz, int ysz);
 
index 04b36f3..e3517c4 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdio.h>
 #include <string.h>
+#include <math.h>
 #include "screens.h"
 #include "imago2.h"
 #include "gfx.h"
 #include "screens.h"
 #include "imago2.h"
 #include "gfx.h"
@@ -9,9 +10,9 @@
 static const struct menuent {
        int x, y, len, height;
 } menuent[] = {
 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;
 };
 
 static int cur;
@@ -44,24 +45,36 @@ void menu_stop(void)
 }
 
 
 }
 
 
+#define BBW            512
+#define BBH            128
 
 void menu_draw(void)
 {
 
 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;
 
        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);
 
        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);
 }
 
        blit_frame(fb_pixels, 0);
 }
@@ -84,5 +97,21 @@ void menu_keyb(int key, int pressed)
                        cur++;
                }
                break;
                        cur++;
                }
                break;
+
+       case '\n':
+       case '\r':
+               switch(cur) {
+               case 0:
+                       /* enter game */
+                       break;
+
+               case 1:
+                       //options_start();
+                       break;
+
+               case 2:
+                       game_quit();
+                       break;
+               }
        }
 }
        }
 }
index 616b23d..84bbe00 100644 (file)
@@ -44,7 +44,7 @@ int main(int argc, char **argv)
                fprintf(stderr, "failed to allocate virtual framebuffer\n");
                return 1;
        }
                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))) {
 
        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 (executable)
index 0000000..24ebf80
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# NOTES:
+# source: svn co https://svn.code.sf.net/p/etherdfs/code
+#
+# on DOS: etherdfs <server MAC addr> 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 (executable)
index 0000000..30244e2
--- /dev/null
@@ -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