From d54a3962dcb42f9921be75cf3754525ecef2bab6 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Tue, 10 Mar 2020 03:31:29 +0200 Subject: [PATCH] moving on --- GNUmakefile | 3 ++- Makefile | 2 +- src/dos/gfx.c | 7 ++++--- src/game.c | 1 + src/game.h | 1 + src/introscr.c | 5 ++--- src/menuscr.c | 16 +++++++++++++--- src/sdl/main.c | 2 +- src/util.h | 14 ++++++++++++-- 9 files changed, 37 insertions(+), 14 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 0468c61..73f7938 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -5,10 +5,11 @@ obj = $(csrc:.c=.o) $(asmsrc:.asm=.o) dep = $(obj:.o=.d) bin = game +def = -DUSE_MMX 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) diff --git a/Makefile b/Makefile index 8f198e5..9640c7a 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ libpath = libpath libs\imago 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 diff --git a/src/dos/gfx.c b/src/dos/gfx.c index c588742..cacd984 100644 --- a/src/dos/gfx.c +++ b/src/dos/gfx.c @@ -238,7 +238,7 @@ void *page_flip(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); } @@ -249,7 +249,7 @@ static void blit_frame_banked(void *pixels, int vsync) unsigned int pending; unsigned char *pptr = pixels; - dbg_fps(pixels); + if(show_fps) dbg_fps(pixels); 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; - 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); diff --git a/src/game.c b/src/game.c index b1f87f4..fdf0066 100644 --- a/src/game.c +++ b/src/game.c @@ -9,6 +9,7 @@ long fb_size; uint16_t *fb_pixels, *vmem; long time_msec; +int show_fps = 1; void (*draw)(void); void (*key_event)(int key, int pressed); diff --git a/src/game.h b/src/game.h index a08ea51..2368572 100644 --- a/src/game.h +++ b/src/game.h @@ -11,6 +11,7 @@ extern long fb_size; extern uint16_t *fb_pixels, *vmem; extern long time_msec; +extern int show_fps; extern void (*swap_buffers)(void*); diff --git a/src/introscr.c b/src/introscr.c index a836650..170cab4 100644 --- a/src/introscr.c +++ b/src/introscr.c @@ -5,8 +5,6 @@ #include "gfxutil.h" #include "game.h" -#define USE_MMX - #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; - //menu_start(); + menu_start(); + return; } #ifdef USE_MMX diff --git a/src/menuscr.c b/src/menuscr.c index a0199a5..9c85249 100644 --- a/src/menuscr.c +++ b/src/menuscr.c @@ -6,6 +6,7 @@ #include "gfx.h" #include "gfxutil.h" #include "game.h" +#include "util.h" static const struct menuent { int x, y, len, height; @@ -38,6 +39,8 @@ void menu_start(void) { draw = menu_draw; key_event = menu_keyb; + + memcpy(fb_pixels, bgpix, fb_size); } void menu_stop(void) @@ -51,7 +54,7 @@ void menu_stop(void) 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); @@ -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); - wait_vsync(); + //wait_vsync(); - memcpy(fb_pixels, bgpix, fb_size); 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); + if(show_fps) { + blit(fb_pixels, fb_width, bgpix, 64, 16, bgwidth); + } + blit_frame(fb_pixels, 0); } diff --git a/src/sdl/main.c b/src/sdl/main.c index 80fab1a..b672ee6 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -99,7 +99,7 @@ void blit_frame(void *pixels, int vsync) int i, j; unsigned short *sptr, *dptr; - dbg_fps(pixels); + if(show_fps) dbg_fps(pixels); if(vsync) { wait_vsync(); diff --git a/src/util.h b/src/util.h index d56bcf5..c95bcf5 100644 --- a/src/util.h +++ b/src/util.h @@ -30,6 +30,7 @@ static INLINE int32_t cround64(double val) 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:" \ @@ -40,7 +41,11 @@ void memcpy64(void *dest, void *src, int count); "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 = \ @@ -64,6 +69,7 @@ void debug_break(void); #endif #ifdef __GNUC__ +#ifdef USE_MMX #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" \ - :: "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" \ -- 1.7.10.4