moving on
authorJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 10 Mar 2020 01:31:29 +0000 (03:31 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 10 Mar 2020 01:31:29 +0000 (03:31 +0200)
GNUmakefile
Makefile
src/dos/gfx.c
src/game.c
src/game.h
src/introscr.c
src/menuscr.c
src/sdl/main.c
src/util.h

index 0468c61..73f7938 100644 (file)
@@ -5,10 +5,11 @@ obj = $(csrc:.c=.o) $(asmsrc:.asm=.o)
 dep = $(obj:.o=.d)
 bin = game
 
 dep = $(obj:.o=.d)
 bin = game
 
+def = -DUSE_MMX
 inc = -Isrc -Isrc/sdl -Isrc/3dgfx -Ilibs/imago/src
 warn = -pedantic -Wall
 
 inc = -Isrc -Isrc/sdl -Isrc/3dgfx -Ilibs/imago/src
 warn = -pedantic -Wall
 
-CFLAGS = $(arch) $(warn) -g -MMD $(inc) `sdl-config --cflags`
+CFLAGS = $(arch) $(warn) -g -MMD $(def) $(inc) `sdl-config --cflags`
 LDFLAGS = $(arch) -Llibs/imago -limago $(sdl_ldflags) -lm
 
 ifneq ($(shell uname -m), i386)
 LDFLAGS = $(arch) -Llibs/imago -limago $(sdl_ldflags) -lm
 
 ifneq ($(shell uname -m), i386)
index 8f198e5..9640c7a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ libpath = libpath libs\imago
 obj = $(dosobj) $(gameobj) $(gfxobj) $(scrobj)
 bin = game.exe
 
 obj = $(dosobj) $(gameobj) $(gfxobj) $(scrobj)
 bin = game.exe
 
-def = -dM_PI=3.141592653589793
+def = -dM_PI=3.141592653589793 -dUSE_MMX
 libs = imago.lib
 
 CC = wcc386
 libs = imago.lib
 
 CC = wcc386
index c588742..cacd984 100644 (file)
@@ -238,7 +238,7 @@ void *page_flip(int vsync)
 
 static void blit_frame_lfb(void *pixels, int vsync)
 {
 
 static void blit_frame_lfb(void *pixels, int vsync)
 {
-       dbg_fps(pixels);
+       if(show_fps) dbg_fps(pixels);
        if(vsync) wait_vsync();
        memcpy64(vpgaddr[frontidx], pixels, pgsize >> 3);
 }
        if(vsync) wait_vsync();
        memcpy64(vpgaddr[frontidx], pixels, pgsize >> 3);
 }
@@ -249,7 +249,7 @@ static void blit_frame_banked(void *pixels, int vsync)
        unsigned int pending;
        unsigned char *pptr = pixels;
 
        unsigned int pending;
        unsigned char *pptr = pixels;
 
-       dbg_fps(pixels);
+       if(show_fps) dbg_fps(pixels);
 
        if(vsync) wait_vsync();
 
 
        if(vsync) wait_vsync();
 
@@ -258,7 +258,8 @@ static void blit_frame_banked(void *pixels, int vsync)
        pending = pgsize;
        while(pending > 0) {
                sz = pending > curmode->bank_size ? curmode->bank_size : pending;
        pending = pgsize;
        while(pending > 0) {
                sz = pending > curmode->bank_size ? curmode->bank_size : pending;
-               memcpy64((void*)0xa0000, pptr, sz >> 3);
+               //memcpy64((void*)0xa0000, pptr, sz >> 3);
+               memcpy((void*)0xa0000, pptr, sz);
                pptr += sz;
                pending -= sz;
                vbe_setwin(0, ++offs);
                pptr += sz;
                pending -= sz;
                vbe_setwin(0, ++offs);
index b1f87f4..fdf0066 100644 (file)
@@ -9,6 +9,7 @@ long fb_size;
 uint16_t *fb_pixels, *vmem;
 
 long time_msec;
 uint16_t *fb_pixels, *vmem;
 
 long time_msec;
+int show_fps = 1;
 
 void (*draw)(void);
 void (*key_event)(int key, int pressed);
 
 void (*draw)(void);
 void (*key_event)(int key, int pressed);
index a08ea51..2368572 100644 (file)
@@ -11,6 +11,7 @@ extern long fb_size;
 extern uint16_t *fb_pixels, *vmem;
 
 extern long time_msec;
 extern uint16_t *fb_pixels, *vmem;
 
 extern long time_msec;
+extern int show_fps;
 
 extern void (*swap_buffers)(void*);
 
 
 extern void (*swap_buffers)(void*);
 
index a836650..170cab4 100644 (file)
@@ -5,8 +5,6 @@
 #include "gfxutil.h"
 #include "game.h"
 
 #include "gfxutil.h"
 #include "game.h"
 
-#define USE_MMX
-
 #define FADE_DUR       800
 
 static void *logo;
 #define FADE_DUR       800
 
 static void *logo;
@@ -55,7 +53,8 @@ void intro_draw(void)
                fade = 256 - (tm - 2 * FADE_DUR) * 256 / FADE_DUR;
        } else {
                fade = 0;
                fade = 256 - (tm - 2 * FADE_DUR) * 256 / FADE_DUR;
        } else {
                fade = 0;
-               //menu_start();
+               menu_start();
+               return;
        }
 
 #ifdef USE_MMX
        }
 
 #ifdef USE_MMX
index a0199a5..9c85249 100644 (file)
@@ -6,6 +6,7 @@
 #include "gfx.h"
 #include "gfxutil.h"
 #include "game.h"
 #include "gfx.h"
 #include "gfxutil.h"
 #include "game.h"
+#include "util.h"
 
 static const struct menuent {
        int x, y, len, height;
 
 static const struct menuent {
        int x, y, len, height;
@@ -38,6 +39,8 @@ void menu_start(void)
 {
        draw = menu_draw;
        key_event = menu_keyb;
 {
        draw = menu_draw;
        key_event = menu_keyb;
+
+       memcpy(fb_pixels, bgpix, fb_size);
 }
 
 void menu_stop(void)
 }
 
 void menu_stop(void)
@@ -51,7 +54,7 @@ void menu_stop(void)
 void menu_draw(void)
 {
        static uint16_t blurbuf[2][BBW * BBH];
 void menu_draw(void)
 {
        static uint16_t blurbuf[2][BBW * BBH];
-       int fboffs, bboffs, tmp;
+       int fboffs, bboffs, tmp, cleartop;
        const struct menuent *ent = menuent + cur;
 
        int blur_rad_x = (int)((sin(time_msec / 1000.0f) * 0.5f + 0.5f) * 50.0f);
        const struct menuent *ent = menuent + cur;
 
        int blur_rad_x = (int)((sin(time_msec / 1000.0f) * 0.5f + 0.5f) * 50.0f);
@@ -66,16 +69,23 @@ void menu_draw(void)
        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);
 
        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();
+       //wait_vsync();
 
 
-       memcpy(fb_pixels, bgpix, fb_size);
        tmp = fboffs;
        fboffs -= 8 * fb_width + 32;
        bboffs -= 8 * BBW + 32;
        tmp = fboffs;
        fboffs -= 8 * fb_width + 32;
        bboffs -= 8 * BBW + 32;
+
+       cleartop = 280 * fb_width;
+       memcpy(fb_pixels + cleartop, bgpix + cleartop, (fb_height - 280) * fb_width << 1);
+
        blit(fb_pixels + fboffs, fb_width, blurbuf[0] + bboffs, ent->len + 64, ent->height + 16, BBW);
        fboffs = tmp;
        blit_key(fb_pixels + fboffs, fb_width, bgpix + fboffs, ent->len, ent->height, bgwidth, 0);
 
        blit(fb_pixels + fboffs, fb_width, blurbuf[0] + bboffs, ent->len + 64, ent->height + 16, BBW);
        fboffs = tmp;
        blit_key(fb_pixels + fboffs, fb_width, bgpix + fboffs, ent->len, ent->height, bgwidth, 0);
 
+       if(show_fps) {
+               blit(fb_pixels, fb_width, bgpix, 64, 16, bgwidth);
+       }
+
        blit_frame(fb_pixels, 0);
 }
 
        blit_frame(fb_pixels, 0);
 }
 
index 80fab1a..b672ee6 100644 (file)
@@ -99,7 +99,7 @@ void blit_frame(void *pixels, int vsync)
        int i, j;
        unsigned short *sptr, *dptr;
 
        int i, j;
        unsigned short *sptr, *dptr;
 
-       dbg_fps(pixels);
+       if(show_fps) dbg_fps(pixels);
 
        if(vsync) {
                wait_vsync();
 
        if(vsync) {
                wait_vsync();
index d56bcf5..c95bcf5 100644 (file)
@@ -30,6 +30,7 @@ static INLINE int32_t cround64(double val)
 extern uint32_t perf_start_count, perf_interval_count;
 
 #ifdef __WATCOMC__
 extern uint32_t perf_start_count, perf_interval_count;
 
 #ifdef __WATCOMC__
+#ifdef USE_MMX
 void memcpy64(void *dest, void *src, int count);
 #pragma aux memcpy64 = \
        "cploop:" \
 void memcpy64(void *dest, void *src, int count);
 #pragma aux memcpy64 = \
        "cploop:" \
@@ -40,7 +41,11 @@ void memcpy64(void *dest, void *src, int count);
        "dec ecx" \
        "jnz cploop" \
        "emms" \
        "dec ecx" \
        "jnz cploop" \
        "emms" \
-       parm[ebx][edx][ecx];
+       parm[ebx][edx][ecx] \
+       modify[8087];
+#else
+#define memcpy64(dest, src, count)     memcpy(dest, src, (count) << 3)
+#endif
 
 void perf_start(void);
 #pragma aux perf_start = \
 
 void perf_start(void);
 #pragma aux perf_start = \
@@ -64,6 +69,7 @@ void debug_break(void);
 #endif
 
 #ifdef __GNUC__
 #endif
 
 #ifdef __GNUC__
+#ifdef USE_MMX
 #define memcpy64(dest, src, count) asm volatile ( \
        "0:\n\t" \
        "movq (%1), %%mm0\n\t" \
 #define memcpy64(dest, src, count) asm volatile ( \
        "0:\n\t" \
        "movq (%1), %%mm0\n\t" \
@@ -73,7 +79,11 @@ void debug_break(void);
        "dec %2\n\t" \
        "jnz 0b\n\t" \
        "emms\n\t" \
        "dec %2\n\t" \
        "jnz 0b\n\t" \
        "emms\n\t" \
-       :: "r"(dest), "r"(src), "r"(count))
+       :: "r"(dest), "r"(src), "r"(count) \
+       : "%mm0")
+#else
+#define memcpy64(dest, src, count)     memcpy(dest, src, (count) << 3)
+#endif
 
 #define perf_start()  asm volatile ( \
        "xor %%eax, %%eax\n" \
 
 #define perf_start()  asm volatile ( \
        "xor %%eax, %%eax\n" \