From 46a619a680fd48db5878f6fe411b28fc10772620 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Wed, 31 Oct 2001 07:41:54 +0000 Subject: [PATCH] Sync with d1x --- arch/sdl/event.c | 11 +++++++---- arch/sdl/gr.c | 15 ++++++++------- arch/sdl/init.c | 19 +++++++++++++++--- iff/iff.c | 13 +++++-------- include/3d.h | 9 +++++++-- include/loadgl.h | 46 ++++++++++++++++++++++++++++++++++++++++++-- main/inferno.c | 17 ++++++++++++++-- maths/fixc.c | 11 ++++++----- maths/vecmat.c | 43 +++++++++++++++++------------------------ maths/vecmata.asm | 49 +++++++++++++++++++++++++---------------------- 10 files changed, 152 insertions(+), 81 deletions(-) diff --git a/arch/sdl/event.c b/arch/sdl/event.c index 5498af62..97c8d827 100644 --- a/arch/sdl/event.c +++ b/arch/sdl/event.c @@ -1,12 +1,15 @@ /* * $Source: /cvs/cvsroot/d2x/arch/sdl/event.c,v $ - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Author: bradleyb $ - * $Date: 2001-10-24 09:25:05 $ + * $Date: 2001-10-31 07:41:54 $ * * SDL Event related stuff * * $Log: not supported by cvs2svn $ + * Revision 1.1 2001/10/24 09:25:05 bradleyb + * Moved input stuff to arch subdirs, as in d1x. + * * Revision 1.2 2001/01/29 14:03:57 bradleyb * Fixed build, minor fixes * @@ -53,8 +56,8 @@ void event_poll() //-killed- return; //end this section addition/change - Hans case SDL_QUIT: { -// void quit_request(); -// quit_request(); + void quit_request(); + quit_request(); } break; } } diff --git a/arch/sdl/gr.c b/arch/sdl/gr.c index c624ffe1..076a43ec 100644 --- a/arch/sdl/gr.c +++ b/arch/sdl/gr.c @@ -1,12 +1,15 @@ /* * $Source: /cvs/cvsroot/d2x/arch/sdl/gr.c,v $ - * $Revision: 1.1 $ + * $Revision: 1.2 $ * $Author: bradleyb $ - * $Date: 2001-10-25 08:25:34 $ + * $Date: 2001-10-31 07:41:54 $ * * SDL video functions. * * $Log: not supported by cvs2svn $ + * Revision 1.1 2001/10/25 08:25:34 bradleyb + * Finished moving stuff to arch/blah. I know, it's ugly, but It'll be easier to sync with d1x. + * * Revision 1.5 2001/10/09 08:17:07 bradleyb * changed window caption to include version info * @@ -80,8 +83,7 @@ void gr_palette_clear(); // Function prototype for gr_init; void gr_update() { //added 05/19/99 Matt Mueller - locking stuff -// -//gr_testunlock(); +// gr_testunlock(); //end addition -MM SDL_UpdateRect(screen,0,0,0,0); } @@ -91,6 +93,7 @@ extern int VGA_current_mode; // DPH: kludge - remove at all costs int gr_set_mode(u_int32_t mode) { int w,h; + #ifdef NOGRAPH return 0; #endif @@ -161,9 +164,7 @@ int gr_check_fullscreen(void){ int gr_toggle_fullscreen(void){ sdl_video_flags^=SDL_FULLSCREEN; -/* - grd_curscreen->sc_mode=0;//hack to get it to reset screen mode -*/ +// grd_curscreen->sc_mode=0;//hack to get it to reset screen mode SDL_WM_ToggleFullScreen(screen); return (sdl_video_flags & SDL_FULLSCREEN)?1:0; } diff --git a/arch/sdl/init.c b/arch/sdl/init.c index ae5a9980..46d511ee 100644 --- a/arch/sdl/init.c +++ b/arch/sdl/init.c @@ -1,12 +1,15 @@ /* * $Source: /cvs/cvsroot/d2x/arch/sdl/init.c,v $ - * $Revision: 1.4 $ + * $Revision: 1.5 $ * $Author: bradleyb $ - * $Date: 2001-10-19 09:45:02 $ + * $Date: 2001-10-31 07:41:54 $ * * SDL architecture support * * $Log: not supported by cvs2svn $ + * Revision 1.4 2001/10/19 09:45:02 bradleyb + * Moved arch/sdl_* to arch/sdl + * * Revision 1.4 2001/01/29 13:35:09 bradleyb * Fixed build system, minor fixes * @@ -36,9 +39,19 @@ void arch_sdl_init() { // Initialise the library //edited on 01/03/99 by Matt Mueller - if we use SDL_INIT_EVERYTHING, cdrom is initialized even if -nocdaudio is used + if (SDL_Init( +#if 1 //SDL_VIDEO || SDL_GL + SDL_INIT_VIDEO +#else + 0 +#endif + )<0) { +//end edit -MM + Error("SDL library initialisation failed: %s.",SDL_GetError()); + } #ifdef SDL_INPUT if (!FindArg("-nomouse")) - d_mouse_init(); + d_mouse_init(); #endif if (!FindArg("-nosound")) digi_init(); diff --git a/iff/iff.c b/iff/iff.c index 1169b2d2..e05cade5 100644 --- a/iff/iff.c +++ b/iff/iff.c @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: iff.c,v 1.4 2001-01-31 15:17:48 bradleyb Exp $"; +static char rcsid[] = "$Id: iff.c,v 1.5 2001-10-31 07:41:54 bradleyb Exp $"; #endif #define COMPRESS 1 //do the RLE or not? (for debugging mostly) @@ -144,7 +144,7 @@ int put_sig(long sig,FILE *f) return fputc(s[0],f); } - + char get_byte(FFILE *f) { //return cfgetc(f); @@ -156,8 +156,6 @@ int put_byte(unsigned char c,FILE *f) return fputc(c,f); } - - int get_word(FFILE *f) { unsigned char c0,c1; @@ -994,8 +992,8 @@ int write_body(FILE *ofile,iff_bitmap_header *bitmap_header,int compression_on) put_long(len,ofile); //if (! (new_span = d_malloc(bitmap_header->w+(bitmap_header->w/128+2)*2))) return IFF_NO_MEM; - MALLOC( new_span, ubyte, bitmap_header->w + (bitmap_header->w/128+2)*2); - if (new_span == NULL) return IFF_NO_MEM; + MALLOC( new_span, ubyte, bitmap_header->w + (bitmap_header->w/128+2)*2); + if (new_span == NULL) return IFF_NO_MEM; for (y=bitmap_header->h;y--;) { @@ -1204,8 +1202,7 @@ int iff_read_animbrush(char *ifilename,grs_bitmap **bm_list,int max_bitmaps,int prev_bm = *n_bitmaps>0?bm_list[*n_bitmaps-1]:NULL; - MALLOC(bm_list[*n_bitmaps] , grs_bitmap, 1 ); - + MALLOC(bm_list[*n_bitmaps] , grs_bitmap, 1 ); bm_list[*n_bitmaps]->bm_data = NULL; ret = iff_parse_bitmap(&ifile,bm_list[*n_bitmaps],form_type,*n_bitmaps>0?NULL:palette,prev_bm); diff --git a/include/3d.h b/include/3d.h index 90f5b24c..baff0816 100644 --- a/include/3d.h +++ b/include/3d.h @@ -12,13 +12,16 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * $Source: /cvs/cvsroot/d2x/include/3d.h,v $ - * $Revision: 1.3 $ + * $Revision: 1.4 $ * $Author: bradleyb $ - * $Date: 2001-10-25 02:06:58 $ + * $Date: 2001-10-31 07:41:54 $ * * Header file for 3d library * * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/10/25 02:06:58 bradleyb + * added prototype for g3_uninit_polygon_model + * * Revision 1.2 2001/01/20 13:49:14 bradleyb * Got rid of all compiler warnings, for non-OpenGL on linux, anyway... * @@ -41,7 +44,9 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #ifndef _3D_H #define _3D_H +#include "fix.h" #include "vecmat.h" +#include "gr.h" extern int g3d_interp_outline; //if on, polygon models outlined in white extern vms_vector Matrix_scale; diff --git a/include/loadgl.h b/include/loadgl.h index a308de2e..c725743e 100644 --- a/include/loadgl.h +++ b/include/loadgl.h @@ -1,4 +1,14 @@ -//loadgl.h - dynamic opengl loading - curtousy (sp) of Jeff Slutter +/* + * $Source: /cvs/cvsroot/d2x/include/loadgl.h,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-31 07:41:54 $ + * + * dynamic opengl loading - curtousy (sp) of Jeff Slutter + * + * $Log: not supported by cvs2svn $ + * + */ #ifndef __LOADGL_H__ #define __LOADGL_H__ @@ -17,7 +27,20 @@ #endif #include -#include "types.h" +#include "pstypes.h" + +//gl extensions. +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#endif + +#ifndef GL_SGIS_multitexture +#define GL_SGIS_multitexture 1 +#define GL_TEXTURE0_SGIS 0x835F +#define GL_TEXTURE1_SGIS 0x8360 +#endif #ifdef _cplusplus #define OEXTERN extern "C" @@ -370,6 +393,10 @@ #define glVertexPointer dglVertexPointer #define glViewport dglViewport +#define glMultiTexCoord2fARB dglMultiTexCoord2fARB +#define glActiveTextureARB dglActiveTextureARB +#define glMultiTexCoord2fSGIS dglMultiTexCoord2fSGIS +#define glSelectTextureSGIS dglSelectTextureSGIS #ifdef WIN32 #define wglCopyContext dwglCopyContext @@ -732,6 +759,11 @@ typedef void (OGLFUNCCALL *glVertex4sv_fp)(const GLshort *v); typedef void (OGLFUNCCALL *glVertexPointer_fp)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (OGLFUNCCALL *glViewport_fp)(GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (OGLFUNCCALL *glMultiTexCoord2fARB_fp)(GLenum target, GLfloat s, GLfloat t); +typedef void (OGLFUNCCALL *glActiveTextureARB_fp)(GLenum target); +typedef void (OGLFUNCCALL *glMultiTexCoord2fSGIS_fp)(GLenum target, GLfloat s, GLfloat t); +typedef void (OGLFUNCCALL *glSelectTextureSGIS_fp)(GLenum target); + #ifdef WIN32 typedef BOOL (OGLFUNCCALL *wglCopyContext_fp)(HGLRC, HGLRC, UINT); typedef HGLRC (OGLFUNCCALL *wglCreateContext_fp)(HDC); @@ -1093,6 +1125,11 @@ DEFVAR glVertex4sv_fp dglVertex4sv; DEFVAR glVertexPointer_fp dglVertexPointer; DEFVAR glViewport_fp dglViewport; +DEFVAR glMultiTexCoord2fARB_fp dglMultiTexCoord2fARB; +DEFVAR glActiveTextureARB_fp dglActiveTextureARB; +DEFVAR glMultiTexCoord2fSGIS_fp dglMultiTexCoord2fSGIS; +DEFVAR glSelectTextureSGIS_fp dglSelectTextureSGIS; + #ifdef WIN32 DEFVAR wglCopyContext_fp dwglCopyContext; DEFVAR wglCreateContext_fp dwglCreateContext; @@ -1904,6 +1941,11 @@ void OpenGL_SetFuncsToNull(void) dglVertexPointer = NULL; dglViewport = NULL; + dglMultiTexCoord2fARB = NULL; + dglActiveTextureARB = NULL; + dglMultiTexCoord2fSGIS = NULL; + dglSelectTextureSGIS = NULL; + #ifdef WIN32 dwglCopyContext = NULL; dwglCreateContext = NULL; diff --git a/main/inferno.c b/main/inferno.c index a7e2dd48..81e6a923 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -13,13 +13,16 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. /* * $Source: /cvs/cvsroot/d2x/main/inferno.c,v $ - * $Revision: 1.12 $ + * $Revision: 1.13 $ * $Author: bradleyb $ - * $Date: 2001-10-27 01:39:23 $ + * $Date: 2001-10-31 07:41:54 $ * * FIXME: put description here * * $Log: not supported by cvs2svn $ + * Revision 1.12 2001/10/27 01:39:23 bradleyb + * added some documentation + * * Revision 1.11 2001/10/25 09:12:16 bradleyb * Completed tmap selection code. * @@ -970,3 +973,13 @@ void check_joystick_calibration() { } } + +void quit_request() +{ +#ifdef NETWORK +// void network_abort_game(); +// if(Network_status) +// network_abort_game(); +#endif + exit(0); +} diff --git a/maths/fixc.c b/maths/fixc.c index 5c472ca0..9ebcad73 100644 --- a/maths/fixc.c +++ b/maths/fixc.c @@ -12,13 +12,16 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * $Source: /cvs/cvsroot/d2x/maths/fixc.c,v $ - * $Revision: 1.2 $ + * $Revision: 1.3 $ * $Author: bradleyb $ - * $Date: 2001-01-31 15:18:04 $ + * $Date: 2001-10-31 07:41:54 $ * * C version of fixed point library * * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/01/31 15:18:04 bradleyb + * Makefile and conf.h fixes + * * Revision 1.1.1.1 2001/01/19 03:29:58 bradleyb * Import of d2x-0.0.8 * @@ -66,7 +69,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: fixc.c,v 1.2 2001-01-31 15:18:04 bradleyb Exp $"; +static char rcsid[] = "$Id: fixc.c,v 1.3 2001-10-31 07:41:54 bradleyb Exp $"; #endif #include @@ -75,7 +78,6 @@ static char rcsid[] = "$Id: fixc.c,v 1.2 2001-01-31 15:18:04 bradleyb Exp $"; #include "error.h" #include "maths.h" -#ifndef NO_ASM #ifdef NO_FIX_INLINE #ifdef _MSC_VER #pragma message ("warning: FIX NOT INLINED") @@ -83,7 +85,6 @@ static char rcsid[] = "$Id: fixc.c,v 1.2 2001-01-31 15:18:04 bradleyb Exp $"; #warning "FIX NOT INLINED" #endif #endif -#endif extern ubyte guess_table[]; extern short sincos_table[]; diff --git a/maths/vecmat.c b/maths/vecmat.c index 592c4578..14d97da5 100644 --- a/maths/vecmat.c +++ b/maths/vecmat.c @@ -12,13 +12,16 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * $Source: /cvs/cvsroot/d2x/maths/vecmat.c,v $ - * $Revision: 1.2 $ + * $Revision: 1.3 $ * $Author: bradleyb $ - * $Date: 2001-01-31 15:18:04 $ + * $Date: 2001-10-31 07:41:54 $ * * C version of vecmat library * * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/01/31 15:18:04 bradleyb + * Makefile and conf.h fixes + * * Revision 1.1.1.2 2001/01/19 03:33:42 bradleyb * Import of d2x-0.0.9-pre1 * @@ -54,7 +57,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: vecmat.c,v 1.2 2001-01-31 15:18:04 bradleyb Exp $"; +static char rcsid[] = "$Id: vecmat.c,v 1.3 2001-10-31 07:41:54 bradleyb Exp $"; #endif #include @@ -66,26 +69,7 @@ static char rcsid[] = "$Id: vecmat.c,v 1.2 2001-01-31 15:18:04 bradleyb Exp $"; //#define USE_ISQRT 1 - -// DPH: Kludge: this was overflowing a lot, so I made it use the FPU. -//scales a vector in place, taking n/d for scale. returns ptr to vector -//dest *= n/d -vms_vector *vm_vec_scale2(vms_vector *dest,fix n,fix d) -{ - float nd; -// printf("scale n=%d d=%d\n",n,d); - nd = f2fl(n) / f2fl(d); - dest->x = fl2f( f2fl(dest->x) * nd); - dest->y = fl2f( f2fl(dest->y) * nd); - dest->z = fl2f( f2fl(dest->z) * nd); -/* dest->x = fixmuldiv(dest->x,n,d); - dest->y = fixmuldiv(dest->y,n,d); - dest->z = fixmuldiv(dest->z,n,d);*/ - - return dest; -} - -#ifdef NO_ASM +#ifndef ASM_VECMAT vms_vector vmd_zero_vector = {0,0,0}; vms_matrix vmd_identity_matrix = { { f1_0,0,0 }, { 0,f1_0,0 }, @@ -204,14 +188,23 @@ vms_vector *vm_vec_scale_add2(vms_vector *dest,vms_vector *src,fix k) //scales a vector in place, taking n/d for scale. returns ptr to vector //dest *= n/d -/*vms_vector *vm_vec_scale2(vms_vector *dest,fix n,fix d) +vms_vector *vm_vec_scale2(vms_vector *dest,fix n,fix d) { +#if 1 // DPH: Kludge: this was overflowing a lot, so I made it use the FPU. + float nd; +// printf("scale n=%d d=%d\n",n,d); + nd = f2fl(n) / f2fl(d); + dest->x = fl2f( f2fl(dest->x) * nd); + dest->y = fl2f( f2fl(dest->y) * nd); + dest->z = fl2f( f2fl(dest->z) * nd); +#else dest->x = fixmuldiv(dest->x,n,d); dest->y = fixmuldiv(dest->y,n,d); dest->z = fixmuldiv(dest->z,n,d); +#endif return dest; -}*/ +} fix vm_vec_dotprod(vms_vector *v0,vms_vector *v1) { diff --git a/maths/vecmata.asm b/maths/vecmata.asm index 3ca1c9bd..8b005114 100644 --- a/maths/vecmata.asm +++ b/maths/vecmata.asm @@ -10,13 +10,16 @@ ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; ; $Source: /cvs/cvsroot/d2x/maths/vecmata.asm,v $ -; $Revision: 1.2 $ +; $Revision: 1.3 $ ; $Author: bradleyb $ -; $Date: 2001-10-19 09:34:02 $ +; $Date: 2001-10-31 07:41:54 $ ; ; Source for vector/matrix library ; ; $Log: not supported by cvs2svn $ +; Revision 1.2 2001/10/19 09:34:02 bradleyb +; Changed __ENV_LINUX__ to __linux__ +; ; Revision 1.1.1.1 2001/01/19 03:29:58 bradleyb ; Import of d2x-0.0.8 ; @@ -536,27 +539,27 @@ _vm_vec_scale_add2: ; vec *vm_vec_scale2(vec *dest, fix n, fix d); ; returns dest ; dest*=n/d -;_vm_vec_scale2: -; push ebx -; push edi -; mov edi,[esp+12] -; mov ebx,[esp+16] -; mov ecx,[esp+20] -; or ecx,ecx -; je no_scale2 -;%assign i 0 -;%rep 3 -; mov eax,[edi+i] -; imul ebx -; idiv ecx -; mov [edi+i],eax -;%assign i i+4 -;%endrep -;no_scale2: -; mov eax,edi -; pop edi -; pop ebx -; ret +_vm_vec_scale2: + push ebx + push edi + mov edi,[esp+12] + mov ebx,[esp+16] + mov ecx,[esp+20] + or ecx,ecx + je no_scale2 +%assign i 0 +%rep 3 + mov eax,[edi+i] + imul ebx + idiv ecx + mov [edi+i],eax +%assign i i+4 +%endrep +no_scale2: + mov eax,edi + pop edi + pop ebx + ret ;compute magnitude of vector. takes esi=vector, returns eax=mag _vm_vec_mag: -- 2.39.2