diff --git a/Makefile b/Makefile index b7635ad..cedb221 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ NASM = nasm CFLAGS = -g -Wall -pipe -O2 -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets CXXFLAGS = $(CFLAGS) -LDLIBS = -lm # /home/relnev/ElectricFence-2.2.2/libefence.a +LDLIBS = -lm CFLAGS += `sdl-config --cflags` LDLIBS += -L/usr/X11R6/lib -lX11 -lXext -lGL `sdl-config --libs` diff --git a/src/main.c b/src/main.c index 19d67a4..7288619 100644 --- a/src/main.c +++ b/src/main.c @@ -38,7 +38,8 @@ PROCESSORTYPES ReadProcessorType() int InitialiseWindowsSystem() { ScanDrawMode = ScanDrawD3DHardwareRGB; - + +#if 1 if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "SDL Init failed: %s\n", SDL_GetError()); exit(EXIT_FAILURE); @@ -65,7 +66,7 @@ int InitialiseWindowsSystem() glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); - +#endif return 0; } @@ -109,6 +110,7 @@ static void handle_keypress(int keysym, int press) void CheckForWindowsMessages() { +#if 1 SDL_Event event; GotAnyKey = 0; @@ -131,18 +133,23 @@ void CheckForWindowsMessages() } } while (SDL_PollEvent(&event)); } +#endif } void InGameFlipBuffers() { +#if 1 SDL_GL_SwapBuffers(); +#endif } void ThisFramesRenderingHasBegun() { fprintf(stderr, "ThisFramesRenderingHasBegun()\n"); - + +#if 1 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +#endif } void ThisFramesRenderingHasFinished() @@ -152,8 +159,9 @@ void ThisFramesRenderingHasFinished() int ExitWindowsSystem() { +#if 1 SDL_Quit(); - +#endif return 0; } diff --git a/src/mathline.c b/src/mathline.c index 98eb676..7879f95 100644 --- a/src/mathline.c +++ b/src/mathline.c @@ -20,8 +20,10 @@ int WideMulNarrowDiv(int a, int b, int c); void RotateVector_ASM(VECTORCH *v, MATRIXCH *m); void RotateAndCopyVector_ASM(VECTORCH *v1, VECTORCH *v2, MATRIXCH *m); +#if 0 int FloatToInt(float); #define f2i(a, b) { a = FloatToInt(b); } +#endif void ADD_LL(LONGLONGCH *a, LONGLONGCH *b, LONGLONGCH *c) { @@ -568,9 +570,9 @@ int SqRoot32(int A) */ __asm__("finit \n\t" - "fild sqrt_temp1 \n\t" + "fildl sqrt_temp1 \n\t" "fsqrt \n\t" - "fistp sqrt_temp2 \n\t" + "fistpl sqrt_temp2 \n\t" "fwait \n\t" : : @@ -600,6 +602,21 @@ __asm__("finit \n\t" extern float fti_fptmp; extern int fti_itmp; +void FloatToInt() +{ +#if 1 +__asm__("fld fti_fptmp \n\t" + "fistpl fti_itmp \n\t" + : + : + : "memory", "cc" + ); +#else + fti_itmp = (int)fti_fptmp; +#endif +} + +#if 0 int FloatToInt(float fptmp) { #if 1 @@ -623,6 +640,7 @@ __asm__("fld fti_fptmp \n\t" return fptmp; #endif } +#endif void TranslatePoint(float *source, float *dest, float *matrix) { diff --git a/src/opengl.c b/src/opengl.c index 7379066..535a8e3 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -27,6 +27,7 @@ static void *CurrTextureHandle; void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr) { +#if 1 int texoffset; void *TextureHandle; int i; @@ -41,9 +42,9 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER TextureHandle = CurrTextureHandle; } - fprintf(stderr, "D3D_ZBufferedGouraudTexturedPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr); - fprintf(stderr, "\tRenderPolygon.NumberOfVertices = %d\n", RenderPolygon.NumberOfVertices); - fprintf(stderr, "\ttexoffset = %d (ptr = %p)\n", texoffset, texoffset ? (void *)ImageHeaderArray[texoffset].D3DHandle : CurrTextureHandle); +// fprintf(stderr, "D3D_ZBufferedGouraudTexturedPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr); +// fprintf(stderr, "\tRenderPolygon.NumberOfVertices = %d\n", RenderPolygon.NumberOfVertices); +// fprintf(stderr, "\ttexoffset = %d (ptr = %p)\n", texoffset, texoffset ? (void *)ImageHeaderArray[texoffset].D3DHandle : CurrTextureHandle); switch(RenderPolygon.TranslucencyMode) { @@ -81,35 +82,23 @@ switch(RenderPolygon.TranslucencyMode) /* this is just random garbage */ x1 = (vertices->X*(Global_VDB_Ptr->VDB_ProjX+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreX; y1 = (vertices->Y*(Global_VDB_Ptr->VDB_ProjY+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreY; -// x = vertices->X; -// y = vertices->Y; x = x1; y = y1; -// x = x/32768.0; -// y = y/32768.0; -// x = (x - 32768.0)/32768.0; -// y = (y - 32768.0)/32768.0; - x = (x - 320.0)/320.0; - y = (y - 240.0)/240.0; + x = (x - 320.0)/320.0; + y = -(y - 240.0)/240.0; -// z = vertices->Z*16; -// z = -z/65536; - zvalue = 65536 - vertices->Z+HeadUpDisplayZOffset; zvalue = 1.0 - ZNear/zvalue; z = -zvalue; -// x *= 16.0; -// y *= 16.0; -// z *= 16.0; - glColor4ub(vertices->R, vertices->G, vertices->B, vertices->A); glVertex3f(x, y, z); - fprintf(stderr, "Vertex %d: (%f, %f, %f)\n\t[%d, %d, %d]->[%d, %d] (%d, %d, %d, %d)\n", i, x, y, z, vertices->X, vertices->Y, vertices->Z, x1, y1, vertices->R, vertices->G, vertices->B, vertices->A); - fprintf(stderr, "znear = %f, zvalue = %f, z = %f\n", ZNear, zvalue, z); +// fprintf(stderr, "Vertex %d: (%f, %f, %f)\n\t[%d, %d, %d]->[%d, %d] (%d, %d, %d, %d)\n", i, x, y, z, vertices->X, vertices->Y, vertices->Z, x1, y1, vertices->R, vertices->G, vertices->B, vertices->A); +// fprintf(stderr, "znear = %f, zvalue = %f, z = %f\n", ZNear, zvalue, z); } glEnd(); CurrTextureHandle = TextureHandle; +#endif } diff --git a/src/win95/inline.h b/src/win95/inline.h index 52ea527..3bd280d 100644 --- a/src/win95/inline.h +++ b/src/win95/inline.h @@ -1132,8 +1132,20 @@ int WideMulNarrowDiv(int a, int b, int c); void RotateVector_ASM(VECTORCH *v, MATRIXCH *m); void RotateAndCopyVector_ASM(VECTORCH *v1, VECTORCH *v2, MATRIXCH *m); +/* int FloatToInt(float); #define f2i(a, b) { a = FloatToInt(b); } +*/ + +int SqRoot32(int A); +void FloatToInt(); +extern float fti_fptmp; +extern int fti_itmp; + +#define f2i(a, b) { \ +fti_fptmp = (b); \ +FloatToInt(); \ +a = fti_itmp;} #else /* inline stuff */ @@ -1869,6 +1881,16 @@ __asm__("fld fti_fptmp \n\t" a = FloatToInt(b); \ } + +#if 0 +int SqRoot32(int A); +void FloatToInt(); +#define f2i(a, b) { \ +fti_fptmp = (b); \ +FloatToInt(); \ +a = fti_itmp;} +#endif + #endif #endif