From: John Tsiombikas Date: Sun, 22 Dec 2019 09:43:19 +0000 (+0200) Subject: backported build fixes and warnings cleanup from dos X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=commitdiff_plain;h=637ca39c29b03bd3a2beb99521753e83c043283f backported build fixes and warnings cleanup from dos --- diff --git a/Makefile.dj b/Makefile.dj index a018ddb..f2414dc 100644 --- a/Makefile.dj +++ b/Makefile.dj @@ -13,23 +13,24 @@ else TOOLPREFIX = i586-pc-msdosdjgpp- endif -inc = -Isrc -Isrc/scr -Isrc/dos -Ilibs -Ilibs/imago/src -Ilibs/anim/src -Ilibs/mikmod/include +inc = -Isrc -Isrc/scr -Isrc/dos -Ilibs -Ilibs/imago/src -Ilibs/anim/src opt = -O3 -ffast-math -fno-strict-aliasing dbg = -g #prof = -pg warn = -pedantic -Wall -Wno-unused-function -Wno-unused-variable +def = -DNO_MUSIC CC = $(TOOLPREFIX)gcc AR = $(TOOLPREFIX)ar -CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(prof) $(inc) -LDFLAGS = libs/imago/imago.dja libs/anim/anim.dja libs/mikmod/dos/libmikmod.a +CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(prof) $(inc) $(def) +LDFLAGS = libs/imago/imago.dja libs/anim/anim.dja ifneq ($(hostsys), dos) .PHONY: all all: data $(bin) endif -$(bin): $(obj) imago anim mikmod +$(bin): $(obj) imago anim $(CC) -o $@ -Wl,-Map=ld.map $(prof) $(obj) $(LDFLAGS) %.cof: %.asm @@ -54,15 +55,10 @@ imago: anim: $(MAKE) -C libs/anim -f Makefile.dj -.PHONY: mikmod -mikmod: - $(MAKE) -C libs/mikmod/dos -f Makefile.dj - .PHONY: cleanlibs cleanlibs: $(MAKE) -C libs/imago -f Makefile.dj clean $(MAKE) -C libs/anim -f Makefile.dj clean - $(MAKE) -C libs/mikmod/dos -f Makefile.dj clean .PHONY: clean .PHONY: cleandep diff --git a/libs/cgmath/cgmmat.inl b/libs/cgmath/cgmmat.inl index c369b84..2eb4519 100644 --- a/libs/cgmath/cgmmat.inl +++ b/libs/cgmath/cgmmat.inl @@ -445,15 +445,15 @@ static inline void cgm_mget_rotation(const float *m, cgm_quat *res) float root; if(trace > 0.0f) { - // |w| > 1/2 - root = sqrt(trace + 1.0f); // 2w + /* |w| > 1/2 */ + root = sqrt(trace + 1.0f); /* 2w */ res->w = 0.5f * root; - root = 0.5f / root; // 1 / 4w + root = 0.5f / root; /* 1 / 4w */ res->x = (m[6] - m[9]) * root; res->y = (m[8] - m[2]) * root; res->z = (m[1] - m[4]) * root; } else { - // |w| <= 1/2 + /* |w| <= 1/2 */ i = 0; if(m[5] > m[0]) { i = 1; diff --git a/libs/imago/src/imago_gl.c b/libs/imago/src/imago_gl.c index 643fea9..7dc444d 100644 --- a/libs/imago/src/imago_gl.c +++ b/libs/imago/src/imago_gl.c @@ -197,6 +197,10 @@ unsigned int img_gltexture_read(struct img_io *io) return tex; } +#if (defined(__DOS__) || defined(__MSDOS__)) && defined(__unix__) +#undef __unix__ +#endif + #if defined(__unix__) || defined(__APPLE__) #ifndef __USE_GNU #define __USE_GNU diff --git a/libs/imago/src/inttypes.h b/libs/imago/src/inttypes.h index 6f941ad..bfa5d5c 100644 --- a/libs/imago/src/inttypes.h +++ b/libs/imago/src/inttypes.h @@ -18,7 +18,7 @@ along with this program. If not, see . #ifndef INT_TYPES_H_ #define INT_TYPES_H_ -#if defined(__DOS__) || defined(WIN32) +#if defined(__DOS__) || defined(__MSDOS__) || defined(WIN32) typedef char int8_t; typedef short int16_t; typedef long int32_t; diff --git a/src/3dgfx.c b/src/3dgfx.c index 6737094..e58ac89 100644 --- a/src/3dgfx.c +++ b/src/3dgfx.c @@ -62,8 +62,8 @@ struct g3d_state { }; static void imm_flush(void); -static void xform4_vec3(const float *mat, float *vec); -static void xform3_vec3(const float *mat, float *vec); +static __inline void xform4_vec3(const float *mat, float *vec); +static __inline void xform3_vec3(const float *mat, float *vec); static void shade(struct g3d_vertex *v); static struct g3d_state *st; @@ -633,28 +633,24 @@ void g3d_texcoord(float u, float v) st->imm_curv.v = v; } -static void xform4_vec3(const float *mat, float *vec) +static __inline void xform4_vec3(const float *mat, float *vec) { float x = mat[0] * vec[0] + mat[4] * vec[1] + mat[8] * vec[2] + mat[12]; float y = mat[1] * vec[0] + mat[5] * vec[1] + mat[9] * vec[2] + mat[13]; float z = mat[2] * vec[0] + mat[6] * vec[1] + mat[10] * vec[2] + mat[14]; - float w = mat[3] * vec[0] + mat[7] * vec[1] + mat[11] * vec[2] + mat[15]; - - vec[0] = x; - vec[1] = y; + vec[3] = mat[3] * vec[0] + mat[7] * vec[1] + mat[11] * vec[2] + mat[15]; vec[2] = z; - vec[3] = w; + vec[1] = y; + vec[0] = x; } -static void xform3_vec3(const float *mat, float *vec) +static __inline void xform3_vec3(const float *mat, float *vec) { float x = mat[0] * vec[0] + mat[4] * vec[1] + mat[8] * vec[2]; float y = mat[1] * vec[0] + mat[5] * vec[1] + mat[9] * vec[2]; - float z = mat[2] * vec[0] + mat[6] * vec[1] + mat[10] * vec[2]; - - vec[0] = x; + vec[2] = mat[2] * vec[0] + mat[6] * vec[1] + mat[10] * vec[2]; vec[1] = y; - vec[2] = z; + vec[0] = x; } #define NORMALIZE(v) \ diff --git a/src/bsptree.c b/src/bsptree.c index 7783e25..f286ac7 100644 --- a/src/bsptree.c +++ b/src/bsptree.c @@ -263,7 +263,7 @@ static int choose_poly(struct bsppoly *polyarr, int num_polys) } } - //printf("choose_poly(..., %d) -> %d splits\n", num_polys, best_splits); + /*printf("choose_poly(..., %d) -> %d splits\n", num_polys, best_splits);*/ return best; } diff --git a/src/dos/gfx.h b/src/dos/gfx.h index f23e0f6..10d6e0b 100644 --- a/src/dos/gfx.h +++ b/src/dos/gfx.h @@ -17,7 +17,7 @@ void set_palette(int idx, int r, int g, int b); enum { FLIP_NOW, - FLIP_VBLANK, + FLIP_VBLANK }; /* page flip and return pointer to the start of the display area (front buffer) */ void *page_flip(int vsync); diff --git a/src/dos/inttypes.h b/src/dos/inttypes.h index 14d6395..4d40ee2 100644 --- a/src/dos/inttypes.h +++ b/src/dos/inttypes.h @@ -18,7 +18,8 @@ along with this program. If not, see . #ifndef INT_TYPES_H_ #define INT_TYPES_H_ -#if defined(__WATCOMC__) && __WATCOMC__ < 0x1200 +/*#if defined(__WATCOMC__) && __WATCOMC__ < 0x1200*/ +#if defined(__DOS__) || defined(__MSDOS__) typedef char int8_t; typedef short int16_t; typedef long int32_t; diff --git a/src/dos/keyb.c b/src/dos/keyb.c index 36a6021..a13ef81 100644 --- a/src/dos/keyb.c +++ b/src/dos/keyb.c @@ -28,7 +28,6 @@ along with the program. If not, see #include #endif #ifdef __DJGPP__ -#include #include #include #include @@ -36,6 +35,7 @@ along with the program. If not, see #include "keyb.h" #include "scancode.h" +#include "inttypes.h" #define KB_INTR 0x9 #define KB_PORT 0x60 diff --git a/src/dos/sball.c b/src/dos/sball.c index 9b9238a..7eb1fd9 100644 --- a/src/dos/sball.c +++ b/src/dos/sball.c @@ -9,13 +9,13 @@ #endif #ifdef __DJGPP__ -#include #include #include #include #endif #include "sball.h" +#include "inttypes.h" struct motion { int x, y, z; diff --git a/src/dos/timer.c b/src/dos/timer.c index f42fac6..dcf790c 100644 --- a/src/dos/timer.c +++ b/src/dos/timer.c @@ -9,13 +9,13 @@ #endif #ifdef __DJGPP__ -#include #include #include #include #endif #include "pit8254.h" +#include "inttypes.h" #define PIT_TIMER_INTR 8 #define DOS_TIMER_INTR 0x1c diff --git a/src/dos/vbe.h b/src/dos/vbe.h index 84044e3..319f7d3 100644 --- a/src/dos/vbe.h +++ b/src/dos/vbe.h @@ -118,7 +118,7 @@ enum { VBE_ATTR_STEREO = 0x0800, VBE_ATTR_STEREO_2FB = 0x1000, /* VBE/AF */ - VBE_ATTR_MUSTLOCK = 0x0200, /* ! */ + VBE_ATTR_MUSTLOCK = 0x0200 /* ! */ }; /* VBE memory model type (vbe_mode_info.mem_model) */ diff --git a/src/polytmpl.h b/src/polytmpl.h index 11ce0fa..0f50b7d 100644 --- a/src/polytmpl.h +++ b/src/polytmpl.h @@ -162,10 +162,10 @@ void POLYFILL(struct pvertex *pv, int nverts) uint32_t res, tmp; if(winding < 0) { - // clockwise + /* clockwise */ edge = y0 > y1 ? left : right; } else { - // counter-clockwise + /* counter-clockwise */ edge = y0 > y1 ? right : left; } res = SCANEDGE(pv + i, pv + next, edge); diff --git a/src/scr/bump.c b/src/scr/bump.c index b82594b..a595ba6 100644 --- a/src/scr/bump.c +++ b/src/scr/bump.c @@ -1,4 +1,4 @@ -// Bump effect (not moving yet of course, I have many ideas on this to commit before it's ready) +/* Bump effect (not moving yet of course, I have many ideas on this to commit before it's ready) */ #include #include @@ -64,8 +64,9 @@ static int init(void) const int particleLightSize = PARTICLE_LIGHT_WIDTH * PARTICLE_LIGHT_HEIGHT; const int fb_size = fb_width * fb_height; - // Just some parameters to temporary test the colors of 3 lights - // if every light uses it's own channel bits, it's better + /* Just some parameters to temporary test the colors of 3 lights + * if every light uses it's own channel bits, it's better + */ const float rgbMul[9] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}; @@ -83,16 +84,16 @@ static int init(void) memset(bumpOffset, 0, sizeof(*bumpOffset) * fb_size); memset(particlePoint, 0, sizeof(*particlePoint) * NUM_PARTICLES); - // Create random junk + /* Create random junk */ for (i = 0; i < fb_size; i++) heightmap[i] = rand() & 255; - // Blur to smooth + /* Blur to smooth */ for (j = 0; j < numBlurs; j++) for (i = 0; i < fb_size; i++) heightmap[i] = (heightmap[abs((i - 1) % fb_size)] + heightmap[abs((i + 1) % fb_size)] + heightmap[abs((i - fb_width) % fb_size)] + heightmap[abs((i + fb_width) % fb_size)]) >> 2; - // Inclination precalculation + /* Inclination precalculation */ i = 0; for (y = 0; y < fb_height; y++) { @@ -116,7 +117,7 @@ static int init(void) } } - // Generate three lights + /* Generate three lights */ i = 0; for (y = 0; y < BIG_LIGHT_HEIGHT; y++) { @@ -315,7 +316,7 @@ static void draw(void) { memset(lightmap, 0, fb_width * fb_height * sizeof(*lightmap)); - //eraseLights(); + /*eraseLights();*/ animateLights(); renderLights(); diff --git a/src/scr/hairball.c b/src/scr/hairball.c index 89c45c3..82b0535 100644 --- a/src/scr/hairball.c +++ b/src/scr/hairball.c @@ -19,7 +19,7 @@ void wait_vsync(void); #define NSPAWNPOS 64 #define SPAWN_RATE 16.0f -//#define GRAV (-6.0f) +/*#define GRAV (-6.0f)*/ #define GRAV 0.0f #define HAIR_LENGTH 20 diff --git a/src/scr/plasma.c b/src/scr/plasma.c index 5caf4f4..afb9a67 100644 --- a/src/scr/plasma.c +++ b/src/scr/plasma.c @@ -1,4 +1,4 @@ -// Just a test with a run of the mill plasma +/* Just a test with a run of the mill plasma */ #include #include diff --git a/src/scr/thunder.c b/src/scr/thunder.c index cacb7b5..062eb57 100644 --- a/src/scr/thunder.c +++ b/src/scr/thunder.c @@ -69,7 +69,6 @@ void sortPointSprites(); static int init(void); static void destroy(void); static void start(long trans_time); -static void stop(long trans_time); static void draw(void); static unsigned int lastFrameTime = 0; @@ -253,7 +252,7 @@ MyVertex randomVertex() { ret.y = rand() % 200 - 100; if (ret.y == 0) ret.y = 1; ret.z = rand() % 200 - 100; if (ret.z == 0) ret.z = 1; - // Normalize + /* Normalize */ l = sqrt(ret.x * ret.x + ret.y * ret.y + ret.z * ret.z); ret.x /= l; ret.y /= l; diff --git a/src/tinyfps.c b/src/tinyfps.c index 83e010f..d7d1f80 100644 --- a/src/tinyfps.c +++ b/src/tinyfps.c @@ -4,9 +4,10 @@ #include "tinyfps.h" #include "demo.h" -// TinyFPS, just a minimal fraps like font to show FPS during the demo and not just after. -// I'll be using it in my effects for my performance test purposes, just adding it here. -// Maybe it would be nice if initFpsFonts would be called in demo.c once but I avoided touching that code. +/* TinyFPS, just a minimal fraps like font to show FPS during the demo and not just after. + * I'll be using it in my effects for my performance test purposes, just adding it here. + * Maybe it would be nice if initFpsFonts would be called in demo.c once but I avoided touching that code. + */ /* 1110 0010 1110 1110 1010 1110 1110 1110 1110 1110 @@ -123,7 +124,7 @@ void drawFps(unsigned short *vram) startingFpsTime = time_msec; nFrames = 0; } - //drawDecimal(fps, 4, 4, 2, vram); - // Moving this on the lower left side of screen for now, since the lack of double buffering generates flickering for this atm + /*drawDecimal(fps, 4, 4, 2, vram);*/ + /* Moving this on the lower left side of screen for now, since the lack of double buffering generates flickering for this atm */ drawDecimal(fps, 4, fb_height - 12, 2, vram); } diff --git a/src/ts_text.c b/src/ts_text.c index 347c28c..ed3f827 100644 --- a/src/ts_text.c +++ b/src/ts_text.c @@ -216,9 +216,9 @@ static int next_token(struct parser *pst) DYNARR_CLEAR(pst->token); - // skip whitespace + /* skip whitespace */ while((c = fgetc(pst->fp)) != -1) { - if(c == '#') { // skip to end of line + if(c == '#') { /* skip to end of line */ while((c = fgetc(pst->fp)) != -1 && c != '\n'); if(c == -1) return -1; } @@ -230,7 +230,7 @@ static int next_token(struct parser *pst) DYNARR_STRPUSH(pst->token, c); if(isdigit(c) || c == '-' || c == '+') { - // token is a number + /* token is a number */ int found_dot = 0; while((c = fgetc(pst->fp)) != -1 && (isdigit(c) || (c == '.' && !found_dot))) { @@ -241,7 +241,7 @@ static int next_token(struct parser *pst) return TOK_NUM; } if(isalpha(c)) { - // token is an identifier + /* token is an identifier */ while((c = fgetc(pst->fp)) != -1 && (isalnum(c) || c == '_')) { DYNARR_STRPUSH(pst->token, c); } @@ -249,8 +249,8 @@ static int next_token(struct parser *pst) return TOK_ID; } if(c == '"') { - // token is a string constant - // remove the opening quote + /* token is a string constant */ + /* remove the opening quote */ DYNARR_STRPOP(pst->token); while((c = fgetc(pst->fp)) != -1 && c != '"') { DYNARR_STRPUSH(pst->token, c); diff --git a/tools/scripts/instdfs b/tools/scripts/instdfs new file mode 100755 index 0000000..bbd9b1f --- /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/dosdemo +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 demo.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.dj | sed 's/\.\///' +} +for i in `findsrc`; do + dir=`dirname $i` + mkdir -p $destdir/$dir + cp $i $destdir/$i +done