fixed warnings
authorJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 19 Feb 2018 22:41:22 +0000 (00:41 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 19 Feb 2018 22:41:22 +0000 (00:41 +0200)
GNUmakefile
Makefile.dj
libs/imago/GNUmakefile
libs/imago/Makefile.dj
libs/mikmod/GNUmakefile
src/demo.c
src/dos/watdpmi.c
src/polytest.c
src/screen.c
src/screen.h
src/thunder.c

index 830297d..48805fa 100644 (file)
@@ -4,8 +4,9 @@ dep = $(obj:.o=.d)
 bin = demo
 
 inc = -I/usr/local/include -Isrc -Isrc/sdl -Ilibs/imago/src -Ilibs/mikmod/include
 bin = demo
 
 inc = -I/usr/local/include -Isrc -Isrc/sdl -Ilibs/imago/src -Ilibs/mikmod/include
+warn = -pedantic -Wall -Wno-unused-variable -Wno-unused-function
 
 
-CFLAGS = -pedantic -Wall -g $(inc) `sdl-config --cflags`
+CFLAGS = $(warn) -g $(inc) `sdl-config --cflags`
 LDFLAGS = -Llibs/imago -Llibs/mikmod -limago -lmikmod `sdl-config --libs` -lm
 
 $(bin): $(obj) imago mikmod
 LDFLAGS = -Llibs/imago -Llibs/mikmod -limago -lmikmod `sdl-config --libs` -lm
 
 $(bin): $(obj) imago mikmod
index 575308c..2088717 100644 (file)
@@ -12,12 +12,13 @@ else
 endif
 
 inc = -Isrc -Isrc/dos -Ilibs/imago/src -Ilibs/mikmod/include
 endif
 
 inc = -Isrc -Isrc/dos -Ilibs/imago/src -Ilibs/mikmod/include
-opt = -O3 -ffast-math
+opt = -O3 -ffast-math -fno-strict-aliasing
 dbg = -g
 dbg = -g
+warn = -pedantic -Wall -Wno-unused-function -Wno-unused-variable
 
 CC = $(TOOLPREFIX)gcc
 AR = $(TOOLPREFIX)ar
 
 CC = $(TOOLPREFIX)gcc
 AR = $(TOOLPREFIX)ar
-CFLAGS = -pedantic -Wall -march=pentium $(dbg) $(opt) $(inc)
+CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(inc)
 LDFLAGS = libs/imago/imago.dja libs/mikmod/dos/libmikmod.a
 
 $(bin): $(obj) imago mikmod
 LDFLAGS = libs/imago/imago.dja libs/mikmod/dos/libmikmod.a
 
 $(bin): $(obj) imago mikmod
index c9154c2..2c73904 100644 (file)
@@ -5,7 +5,7 @@ src = $(wildcard src/*.c) \
 obj = $(src:.c=.o)
 alib = libimago.a
 
 obj = $(src:.c=.o)
 alib = libimago.a
 
-CFLAGS = -pedantic -Wall -Wno-main -g -Izlib -Ilibpng -Ijpeglib
+CFLAGS = -Wno-main -g -Izlib -Ilibpng -Ijpeglib
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
index 1f22386..637c4f3 100644 (file)
@@ -14,7 +14,7 @@ endif
 
 CC = $(TOOLPREFIX)gcc
 AR = $(TOOLPREFIX)ar
 
 CC = $(TOOLPREFIX)gcc
 AR = $(TOOLPREFIX)ar
-CFLAGS = -pedantic -Wall -Wno-main -march=pentium -g -O3 -ffast-math -Izlib -Ilibpng -Ijpeglib
+CFLAGS = -Wno-main -march=pentium -g -O3 -ffast-math -Izlib -Ilibpng -Ijpeglib
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
index 9a31d25..a6f162b 100644 (file)
@@ -9,7 +9,8 @@ alib = libmikmod.a
 
 def = -DHAVE_CONFIG_H -DMIKMOD_BUILD
 inc = -I. -Iinclude
 
 def = -DHAVE_CONFIG_H -DMIKMOD_BUILD
 inc = -I. -Iinclude
-CFLAGS = -pedantic -Wall -g $(def) $(inc) `pkg-config --cflags sdl`
+warn = -pedantic -Wall -Wno-unused-variable -Wno-unused-function
+CFLAGS = $(warn) -g $(def) $(inc) `pkg-config --cflags sdl`
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
index 45b889a..072b6ce 100644 (file)
@@ -121,11 +121,11 @@ void demo_keyboard(int key, int press)
                switch(key) {
                case 27:
                        demo_quit();
                switch(key) {
                case 27:
                        demo_quit();
-                       break;
+                       return;
 
                case 127:
                        debug_break();
 
                case 127:
                        debug_break();
-                       break;
+                       return;
 
                case '`':
                        console_active = !console_active;
 
                case '`':
                        console_active = !console_active;
@@ -135,13 +135,16 @@ void demo_keyboard(int key, int press)
                        } else {
                                putchar('\n');
                        }
                        } else {
                                putchar('\n');
                        }
-                       break;
+                       return;
 
                case '\b':
 
                case '\b':
-                       if(console_active && wr != rd) {
-                               printf("\b \b");
-                               fflush(stdout);
-                               wr = (wr + CBUF_SIZE - 1) & CBUF_MASK;
+                       if(console_active) {
+                               if(wr != rd) {
+                                       printf("\b \b");
+                                       fflush(stdout);
+                                       wr = (wr + CBUF_SIZE - 1) & CBUF_MASK;
+                               }
+                               return;
                        }
                        break;
 
                        }
                        break;
 
@@ -165,6 +168,7 @@ void demo_keyboard(int key, int press)
                                        }
                                }
                                console_active = 0;
                                        }
                                }
                                console_active = 0;
+                               return;
                        }
                        break;
 
                        }
                        break;
 
@@ -175,18 +179,23 @@ void demo_keyboard(int key, int press)
                                change_screen(9);
                        }
 
                                change_screen(9);
                        }
 
-                       if(console_active && key < 256 && isprint(key)) {
-                               putchar(key);
-                               fflush(stdout);
-
-                               cbuf[wr] = key;
-                               wr = (wr + 1) & CBUF_MASK;
-                               if(wr == rd) { /* overflow */
-                                       rd = (rd + 1) & CBUF_MASK;
+                       if(console_active) {
+                               if(key < 256 && isprint(key)) {
+                                       putchar(key);
+                                       fflush(stdout);
+
+                                       cbuf[wr] = key;
+                                       wr = (wr + 1) & CBUF_MASK;
+                                       if(wr == rd) { /* overflow */
+                                               rd = (rd + 1) & CBUF_MASK;
+                                       }
                                }
                                }
+                               return;
                        }
                        break;
                }
                        }
                        break;
                }
+
+               scr_keypress(key);
        }
 }
 
        }
 }
 
index 12dcfde..04d7b94 100644 (file)
@@ -54,4 +54,6 @@ void dpmi_munmap(void *addr)
                int 0x31
        }
 }
                int 0x31
        }
 }
+#else
+int stop_gcc_crying_about_empty_translation_units = 0;
 #endif /* __WATCOM__ */
 #endif /* __WATCOM__ */
index 2558389..afe2006 100644 (file)
@@ -23,7 +23,8 @@ static struct screen scr = {
        init,
        destroy,
        start, 0,
        init,
        destroy,
        start, 0,
-       draw
+       draw,
+       0
 };
 
 static float cam_theta, cam_phi = 25;
 };
 
 static float cam_theta, cam_phi = 25;
index 5ba6d40..fa70413 100644 (file)
@@ -97,6 +97,13 @@ void scr_draw(void)
        if(cur) cur->draw();
 }
 
        if(cur) cur->draw();
 }
 
+void scr_keypress(int key)
+{
+       if(cur && cur->keypress) {
+               cur->keypress(key);
+       }
+}
+
 struct screen *scr_lookup(const char *name)
 {
        int i;
 struct screen *scr_lookup(const char *name)
 {
        int i;
index efb43f7..c2e4974 100644 (file)
@@ -11,6 +11,8 @@ struct screen {
        void (*stop)(long trans_time);
 
        void (*draw)(void);
        void (*stop)(long trans_time);
 
        void (*draw)(void);
+
+       void (*keypress)(int key);
 };
 
 int scr_init(void);
 };
 
 int scr_init(void);
@@ -18,6 +20,7 @@ void scr_shutdown(void);
 
 void scr_update(void);
 void scr_draw(void);
 
 void scr_update(void);
 void scr_draw(void);
+void scr_keypress(int key);
 
 struct screen *scr_lookup(const char *name);
 struct screen *scr_screen(int idx);
 
 struct screen *scr_lookup(const char *name);
 struct screen *scr_screen(int idx);
index 197d326..d8c3211 100644 (file)
@@ -33,8 +33,6 @@ static unsigned char *blurBuffer, *blurBuffer2;
 
 #define CAMERA_DISTANCE 1.1f
 
 
 #define CAMERA_DISTANCE 1.1f
 
-#define PI 3.14159f
-
 /* TODO: Load palette from file */
 static unsigned short palette[256];
 
 /* TODO: Load palette from file */
 static unsigned short palette[256];
 
@@ -200,7 +198,7 @@ void blitEffect() {
                        tl = *src1;
                        tr = (*src1 + *(src1 + 1)) >> 1;
                        bl = (*src1 + *src2) >> 1;
                        tl = *src1;
                        tr = (*src1 + *(src1 + 1)) >> 1;
                        bl = (*src1 + *src2) >> 1;
-                       br = tr + ((*src2 + *(src2 + 1)) >> 1) >> 1;
+                       br = (tr + ((*src2 + *(src2 + 1)) >> 1)) >> 1;
 
                        /* Pack 2 pixels in each 32 bit word */
                        *dst1 = (palette[tr] << 16) | palette[tl];
 
                        /* Pack 2 pixels in each 32 bit word */
                        *dst1 = (palette[tr] << 16) | palette[tl];
@@ -290,9 +288,9 @@ void animateMesh() {
        by.y = 1.0f;
        by.z = 0.0f;
 
        by.y = 1.0f;
        by.z = 0.0f;
 
-       bz.x = cos(yRot + PI/2.0f);
+       bz.x = cos(yRot + M_PI/2.0f);
        bz.y = 0.0f;
        bz.y = 0.0f;
-       bz.z = sin(yRot + PI/2.0f);
+       bz.z = sin(yRot + M_PI/2.0f);
 
        for (i = 0; i < VERTEX_COUNT; i++) {
                MyVertex v1, v2;
 
        for (i = 0; i < VERTEX_COUNT; i++) {
                MyVertex v1, v2;