From 62c84af3483abd59e3b6672559b19a9ea17ff14d Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Tue, 6 Feb 2018 23:47:34 +0200 Subject: [PATCH] - instructed gcc to emit only pentium1 instructions - moved wait_vsync into an assembly macro in gfx.h --- Makefile.dj | 2 +- libs/imago/Makefile.dj | 2 +- libs/oldmik/Makefile.dj | 2 +- src/dos/gfx.c | 37 ------------------------------------- src/dos/gfx.h | 28 ++++++++++++++++++++++++++++ 5 files changed, 31 insertions(+), 40 deletions(-) diff --git a/Makefile.dj b/Makefile.dj index 600403a..ed1a830 100644 --- a/Makefile.dj +++ b/Makefile.dj @@ -16,7 +16,7 @@ dbg = -g CC = $(TOOLPREFIX)gcc AR = $(TOOLPREFIX)ar -CFLAGS = -pedantic -Wall $(dbg) $(opt) $(inc) +CFLAGS = -pedantic -Wall -march=pentium $(dbg) $(opt) $(inc) LDFLAGS = libs/imago/imago.a libs/oldmik/mikmod.a $(bin): $(obj) imago mikmod diff --git a/libs/imago/Makefile.dj b/libs/imago/Makefile.dj index 2d1ead6..5e15016 100644 --- a/libs/imago/Makefile.dj +++ b/libs/imago/Makefile.dj @@ -14,7 +14,7 @@ endif CC = $(TOOLPREFIX)gcc AR = $(TOOLPREFIX)ar -CFLAGS = -pedantic -Wall -Wno-main -g -O3 -ffast-math -Izlib -Ilibpng -Ijpeglib +CFLAGS = -pedantic -Wall -Wno-main -march=pentium -g -O3 -ffast-math -Izlib -Ilibpng -Ijpeglib $(alib): $(obj) $(AR) rcs $@ $(obj) diff --git a/libs/oldmik/Makefile.dj b/libs/oldmik/Makefile.dj index 3d890f2..8162cc4 100644 --- a/libs/oldmik/Makefile.dj +++ b/libs/oldmik/Makefile.dj @@ -15,7 +15,7 @@ endif CC = $(TOOLPREFIX)gcc AR = $(TOOLPREFIX)ar -CFLAGS = $(opt) $(dbg) -Isrc +CFLAGS = -march=pentium $(opt) $(dbg) -Isrc $(alib): $(obj) $(AR) rcs $@ $(obj) diff --git a/src/dos/gfx.c b/src/dos/gfx.c index 46cec31..c2e4f8d 100644 --- a/src/dos/gfx.c +++ b/src/dos/gfx.c @@ -154,43 +154,6 @@ void set_palette(int idx, int r, int g, int b) vbe_set_palette(idx, col, 1, pal_bits); } -#ifdef __WATCOMC__ -void wait_vsync_asm(void); -#pragma aux wait_vsync_asm = \ - "mov dx, 0x3da" \ - "l1:" \ - "in al, dx" \ - "and al, 0x8" \ - "jnz l1" \ - "l2:" \ - "in al, dx" \ - "and al, 0x8" \ - "jz l2" \ - modify[al dx]; - -void wait_vsync(void) -{ - wait_vsync_asm(); -} -#endif - -#ifdef __DJGPP__ -void wait_vsync(void) -{ - asm volatile ( - "mov $0x3da, %%dx\n\t" - "0:\n\t" - "in %%dx, %%al\n\t" - "and $8, %%al\n\t" - "jnz 0b\n\t" - "0:\n\t" - "in %%dx, %%al\n\t" - "and $8, %%al\n\t" - "jz 0b\n\t" - :::"%eax","%edx"); -} -#endif - static unsigned int make_mask(int sz, int pos) { unsigned int i, mask = 0; diff --git a/src/dos/gfx.h b/src/dos/gfx.h index b19c992..7e12554 100644 --- a/src/dos/gfx.h +++ b/src/dos/gfx.h @@ -15,7 +15,35 @@ int get_color_mask(unsigned int *rmask, unsigned int *gmask, unsigned int *bmask void set_palette(int idx, int r, int g, int b); +#ifdef __WATCOMC__ void wait_vsync(void); +#pragma aux wait_vsync = \ + "mov dx, 0x3da" \ + "l1:" \ + "in al, dx" \ + "and al, 0x8" \ + "jnz l1" \ + "l2:" \ + "in al, dx" \ + "and al, 0x8" \ + "jz l2" \ + modify[al dx]; +#endif + +#ifdef __DJGPP__ +#define wait_vsync() asm volatile ( \ + "mov $0x3da, %%dx\n\t" \ + "0:\n\t" \ + "in %%dx, %%al\n\t" \ + "and $8, %%al\n\t" \ + "jnz 0b\n\t" \ + "0:\n\t" \ + "in %%dx, %%al\n\t" \ + "and $8, %%al\n\t" \ + "jz 0b\n\t" \ + :::"%eax","%edx") +#endif + #ifdef __cplusplus } -- 1.7.10.4