From 553fa56442ec999960fda8c2842f692136d6ed1c Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Sat, 7 Sep 2002 00:26:23 +0000 Subject: [PATCH] misc changes --- Makefile | 28 ++++---- src/avp/psnd.c | 1 - src/avp/win95/psndplat.h | 2 +- src/fixer.h | 5 ++ src/mathline.c | 138 +++++++++++++++++++-------------------- src/openal.c | 1 - src/openal.h | 6 -- src/win95/bmpnames.cpp | 2 +- src/win95/plspecfn.c | 3 +- 9 files changed, 86 insertions(+), 100 deletions(-) delete mode 100644 src/openal.h diff --git a/Makefile b/Makefile index 1f3dbc7..caad6e6 100644 --- a/Makefile +++ b/Makefile @@ -9,15 +9,12 @@ CFLAGS = -g -Wall -pipe -O2 #CFLAGS = -DNDEBUG -Wall -pipe -O6 -ffast-math -fomit-frame-pointer -march=pentiumpro -mcpu=pentiumpro CFLAGS += -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets +CFLAGS += $(shell sdl-config --cflags) CXXFLAGS = $(CFLAGS) -CFLAGS += $(shell sdl-config --cflags) LDLIBS = $(shell sdl-config --libs) -lGL -lopenal -# Debian SDL+NVIDIA workaround (change /usr/lib to the real location of the files) -#LDLIBS = -L/usr/X11R6/lib -lX11 -lXext /usr/lib/libGL.so.1 $(shell sdl-config --libs) -lopenal -lm - -# required for gcc-3.0 +# required for gcc-3 #LDLIBS += -lstdc++ AFLAGS = -g -w+macro-params -w+orphan-labels -w+number-overflow @@ -61,7 +58,7 @@ OBJ = $(ROOTOBJ) $(AVPOBJ) $(SHAPESOBJ) $(SUPPORTOBJ) $(AVPWIN95OBJ) $(FRONTENDO all: AvP -AvP: depend $(OBJ) +AvP: $(OBJ) # depend $(OBJ) $(CC) -o AvP $(OBJ) $(LDLIBS) compile: $(OBJ) @@ -69,9 +66,6 @@ compile: $(OBJ) .asm.o: $(NASM) $(AFLAGS) -f elf -o $@ $< -tester: - echo $(OBJ) - clean: -rm -rf depend depend.bak $(OBJ) AvP @@ -81,14 +75,14 @@ distclean: clean # I wish I knew how to do dependencies correctly... #depend: Makefile $(SRC) -# $(CC) $(CFLAGS) -MM $(SRC) > depend - +# $(CC) $(CFLAGS) -MM $(SRC) > depend.out +# # insert makefile dependencies here # -include depend - -depend: Makefile # $(SRC) - touch depend - makedepend -fdepend -- $(CFLAGS) -- $(SRC) - --include depend +# +#depend: Makefile # $(SRC) +# touch depend.out +# makedepend -fdepend.out -- $(CFLAGS) -- $(SRC) +# +#-include depend.out # DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/avp/psnd.c b/src/avp/psnd.c index a28ca83..ccb41cb 100644 --- a/src/avp/psnd.c +++ b/src/avp/psnd.c @@ -19,7 +19,6 @@ #include "showcmds.h" #include "avp_userprofile.h" #include "cdplayer.h" -#include "openal.h" /* Patrick 5/6/97 ------------------------------------------------------------- Internal globals diff --git a/src/avp/win95/psndplat.h b/src/avp/win95/psndplat.h index c720ecc..5a6daa9 100644 --- a/src/avp/win95/psndplat.h +++ b/src/avp/win95/psndplat.h @@ -209,7 +209,7 @@ extern ACTIVESOUNDSAMPLE ActiveSounds[]; extern SOUNDSAMPLEDATA BlankGameSound; extern ACTIVESOUNDSAMPLE BlankActiveSound; - +void UpdateSoundFrequencies(void); #ifdef __cplusplus } diff --git a/src/fixer.h b/src/fixer.h index c15e37e..df32540 100644 --- a/src/fixer.h +++ b/src/fixer.h @@ -75,7 +75,12 @@ typedef struct RECT typedef RECT RECT_AVP; +#if !defined(__INTEL_COMPILER) typedef int64_t __int64; +#else +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#endif typedef time_t FILETIME; diff --git a/src/mathline.c b/src/mathline.c index 69b9250..3416800 100644 --- a/src/mathline.c +++ b/src/mathline.c @@ -41,16 +41,16 @@ void ADD_LL(LONGLONGCH *a, LONGLONGCH *b, LONGLONGCH *c) mov [ebx+4],edx } */ - -__asm__("movl 0(%%esi), %%eax \n\t" - "movl 4(%%esi), %%edx \n\t" - "addl 0(%%edi), %%eax \n\t" - "adcl 4(%%edi), %%edx \n\t" - "movl %%eax, 0(%%ebx) \n\t" - "movl %%edx, 4(%%ebx) \n\t" - : +int dummy1, dummy2; +__asm__("movl 0(%%esi), %0 \n\t" + "movl 4(%%esi), %1 \n\t" + "addl 0(%%edi), %0 \n\t" + "adcl 4(%%edi), %1 \n\t" + "movl %0, 0(%%ebx) \n\t" + "movl %1, 4(%%ebx) \n\t" + : "=&r" (dummy1), "=&r" (dummy2) : "S" (a), "D" (b), "b" (c) - : "%eax", "%edx", "memory", "cc" + : "memory", "cc" ); /* @@ -74,18 +74,19 @@ void ADD_LL_PP(LONGLONGCH *c, LONGLONGCH *a) mov edi,c mov esi,a mov eax,[esi] - mov edx,[esi+4] + mov edx,[esi+4] add [edi],eax adc [edi+4],edx } */ -__asm__("movl 0(%%esi), %%eax \n\t" - "movl 4(%%esi), %%edx \n\t" - "addl %%eax, 0(%%edi) \n\t" - "adcl %%edx, 4(%%edi) \n\t" - : +int dummy1, dummy2; +__asm__("movl 0(%%esi), %0 \n\t" + "movl 4(%%esi), %1 \n\t" + "addl %0, 0(%%edi) \n\t" + "adcl %1, 4(%%edi) \n\t" + : "=&r" (dummy1), "=&r" (dummy2) : "D" (c), "S" (a) - : "%eax", "%edx", "memory", "cc" + : "memory", "cc" ); } @@ -107,15 +108,16 @@ void SUB_LL(LONGLONGCH *a, LONGLONGCH *b, LONGLONGCH *c) mov [ebx+4],edx } */ -__asm__("movl 0(%%esi), %%eax \n\t" - "movl 4(%%esi), %%edx \n\t" - "subl 0(%%edi), %%eax \n\t" - "sbbl 4(%%edi), %%edx \n\t" - "movl %%eax, 0(%%ebx) \n\t" - "movl %%edx, 4(%%ebx) \n\t" - : +int dummy1, dummy2; +__asm__("movl 0(%%esi), %0 \n\t" + "movl 4(%%esi), %1 \n\t" + "subl 0(%%edi), %0 \n\t" + "sbbl 4(%%edi), %1 \n\t" + "movl %0, 0(%%ebx) \n\t" + "movl %1, 4(%%ebx) \n\t" + : "=&r" (dummy1), "=&r" (dummy2) : "S" (a), "D" (b), "b" (c) - : "%eax", "%edx", "memory", "cc" + : "memory", "cc" ); } @@ -134,13 +136,14 @@ void SUB_LL_MM(LONGLONGCH *c, LONGLONGCH *a) sbb [edi+4],edx } */ -__asm__("movl 0(%%esi), %%eax \n\t" - "movl 4(%%esi), %%edx \n\t" - "subl %%eax, 0(%%edi) \n\t" - "sbbl %%edx, 4(%%edi) \n\t" - : +int dummy1, dummy2; +__asm__("movl 0(%%esi), %0 \n\t" + "movl 4(%%esi), %1 \n\t" + "subl %0, 0(%%edi) \n\t" + "sbbl %1, 4(%%edi) \n\t" + : "=&r" (dummy1), "=&r" (dummy2) : "D" (c), "S" (a) - : "%eax", "%edx", "memory", "cc" + : "memory", "cc" ); } @@ -164,12 +167,13 @@ void MUL_I_WIDE(int a, int b, LONGLONGCH *c) mov [ebx+4],edx } */ -__asm__("imull %%edx \n\t" +unsigned int d1; +__asm__("imull %3 \n\t" "movl %%eax, 0(%%ebx) \n\t" "movl %%edx, 4(%%ebx) \n\t" - : - : "a" (a), "b" (c), "d" (b) - : "memory", "cc" + : "=a" (d1) + : "0" (a), "b" (c), "m" (b) + : "%edx", "memory", "cc" ); } @@ -315,15 +319,17 @@ void ASR_LL(LONGLONGCH *a, int shift) asrdn: } */ -__asm__("andl %%eax, %%eax \n\t" +unsigned int d1; +__asm__ volatile + ("andl %0, %0 \n\t" "jle 0 \n" /* asrdn */ "1: \n\t" /* asrlp */ "sarl $1, 4(%%esi) \n\t" "rcrl $1, 0(%%esi) \n\t" - "decl %%eax \n\t" + "decl %0 \n\t" "jne 1 \n" "0: \n\t" - : + : "=&r" (d1) : "S" (a), "a" (shift) : "memory", "cc" ); @@ -349,11 +355,10 @@ __asm__("movl 0(%%esi), %%eax \n\t" "cdq \n\t" "movl %%eax, 0(%%edi) \n\t" "movl %%edx, 4(%%edi) \n\t" - : + : : "S" (b), "D" (a) : "%eax", "%edx", "memory", "cc" ); - } /* @@ -394,11 +399,11 @@ int MUL_FIXED(int a, int b) mov retval,eax } */ -__asm__("imull %%edx \n\t" +__asm__("imull %2 \n\t" "shrdl $16, %%edx, %%eax \n\t" : "=a" (retval) - : "a" (a), "d" (b) - : "cc" + : "0" (a), "m" (b) + : "%edx", "cc" ); return retval; } @@ -412,6 +417,8 @@ __asm__("imull %%edx \n\t" int DIV_FIXED(int a, int b) { int retval; + + if (b == 0) printf("DEBUG THIS: a = %d, b = %d\n", a, b); if (b == 0) return 0; /* TODO: debug this! (start with alien on ferarco) */ /* @@ -430,9 +437,9 @@ __asm__("cdq \n\t" "roll $16, %%eax \n\t" "mov %%ax, %%dx \n\t" "xor %%ax, %%ax \n\t" - "idivl %%ebx \n\t" + "idivl %2 \n\t" : "=a" (retval) - : "a" (a), "b" (b) + : "0" (a), "m" (b) : "%edx", "cc" ); return retval; @@ -476,9 +483,9 @@ int NarrowDivide(LONGLONGCH *a, int b) */ __asm__("movl 0(%%esi), %%eax \n\t" "movl 4(%%esi), %%edx \n\t" - "idivl %%ebx \n\t" + "idivl %2 \n\t" : "=a" (retval) - : "S" (a), "b" (b) + : "S" (a), "m" (b) : "%edx", "cc" ); return retval; @@ -504,10 +511,10 @@ int WideMulNarrowDiv(int a, int b, int c) mov retval,eax } */ -__asm__("imull %%ebx \n\t" - "idivl %%ecx \n\t" +__asm__("imull %2 \n\t" + "idivl %3 \n\t" : "=a" (retval) - : "a" (a), "b" (b), "c" (c) + : "0" (a), "m" (b), "m" (c) : "%edx", "cc" ); return retval; @@ -567,13 +574,10 @@ typedef struct matrixch { */ -extern int sqrt_temp1; -extern int sqrt_temp2; +extern volatile int sqrt_temp; int SqRoot32(int A) { -#if 1 - sqrt_temp1 = A; /* _asm { @@ -585,28 +589,19 @@ int SqRoot32(int A) } */ -__asm__("finit \n\t" - "fildl sqrt_temp1 \n\t" +__asm__ volatile + ("finit \n\t" + "fildl %0 \n\t" "fsqrt \n\t" - "fistpl sqrt_temp2 \n\t" + "fistpl sqrt_temp \n\t" "fwait \n\t" : - : + : "m" (A) : "memory", "cc" ); - return sqrt_temp2; -#else -{ /* TODO: clean this please */ - double x = A; - double retvald = sqrt(x); - int retval = retvald; - return retval; + return sqrt_temp; } -#endif -} - - /* @@ -615,13 +610,14 @@ __asm__("finit \n\t" */ -extern float fti_fptmp; -extern int fti_itmp; +extern volatile float fti_fptmp; +extern volatile int fti_itmp; void FloatToInt() { #if 1 -__asm__("fld fti_fptmp \n\t" +__asm__ volatile + ("flds fti_fptmp \n\t" "fistpl fti_itmp \n\t" : : diff --git a/src/openal.c b/src/openal.c index d00a0ab..ba0163c 100644 --- a/src/openal.c +++ b/src/openal.c @@ -21,7 +21,6 @@ #include "dynamics.h" #include "dynblock.h" #include "stratdef.h" -#include "openal.h" ACTIVESOUNDSAMPLE ActiveSounds[SOUND_MAXACTIVE]; ACTIVESOUNDSAMPLE BlankActiveSound = {SID_NOSOUND,ASP_Minimum,0,0,NULL,0,0,0,0,0, { {0,0,0},{0,0,0},0,0 }, 0, 0, { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, NULL, NULL, NULL}; diff --git a/src/openal.h b/src/openal.h deleted file mode 100644 index a227c31..0000000 --- a/src/openal.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef OPENAL_AVP_H -#define OPENAL_AVP_H - -void UpdateSoundFrequencies(); - -#endif diff --git a/src/win95/bmpnames.cpp b/src/win95/bmpnames.cpp index 63e139b..961ac00 100644 --- a/src/win95/bmpnames.cpp +++ b/src/win95/bmpnames.cpp @@ -129,7 +129,7 @@ Chunk_With_BMPs::Chunk_With_BMPs (Chunk_With_Children * parent, const char * con bdata += 4; - for (int i=0; i