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
.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
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
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;
#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 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++) { \
- 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++) { \
- 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; \
- *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++) { \
- 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; \
- *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++) { \
- 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; \
- *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; \
/* 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;
- 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;
- 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);
}
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++) {
dest++;
}
dest += dadv;
+ src += sadv;
}
}
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);
#include <stdio.h>
#include <string.h>
+#include <math.h>
#include "screens.h"
#include "imago2.h"
#include "gfx.h"
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;
}
+#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);
}
cur++;
}
break;
+
+ case '\n':
+ case '\r':
+ switch(cur) {
+ case 0:
+ /* enter game */
+ break;
+
+ case 1:
+ //options_start();
+ break;
+
+ case 2:
+ game_quit();
+ break;
+ }
}
}
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))) {
--- /dev/null
+#!/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
--- /dev/null
+#!/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