From 3382f347cc88a9d28cec4c0285565b7e77303046 Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 29 May 2003 06:26:29 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create tag 'd2x-0_1_2'. --- .cvsignore | 13 - 2d/.cvsignore | 1 - 2d/2dsline.c | 298 +-- 2d/Makefile.am | 12 +- 2d/bitblt.c | 2055 ++++------------ 2d/bitmap.c | 319 +-- 2d/bitmap.h | 68 +- 2d/box.c | 1 - 2d/canvas.c | 1 - 2d/circle.c | 17 +- 2d/clip.h | 181 +- 2d/disc.c | 15 +- 2d/font.c | 247 +- 2d/gpixel.c | 8 +- 2d/ibitblt.c | 802 +----- 2d/line.c | 40 +- 2d/linear.asm | 12 +- 2d/linear.h | 482 ++++ 2d/palette.c | 168 +- 2d/pcx.c | 277 +-- 2d/pixel.c | 23 +- 2d/poly.c | 22 +- 2d/rect.c | 3 +- 2d/rle.c | 782 ++---- 2d/scale.c | 14 +- 2d/scalea.asm | 9 +- 2d/scalea.h | 1 - 2d/scalec.c | 193 +- 2d/tmerge.c | 29 +- 2d/tmerge_a.asm | 17 +- 3d/.cvsignore | 1 - 3d/Makefile.am | 2 +- 3d/clipper.c | 3 +- 3d/clipper.h | 11 +- 3d/draw.c | 3 +- 3d/globvars.c | 17 +- 3d/globvars.h | 11 +- 3d/instance.c | 19 +- 3d/interp.asm | 3 +- 3d/interp.c | 311 +-- 3d/matrix.c | 17 +- 3d/points.c | 21 +- 3d/rod.c | 20 +- 3d/setup.c | 27 +- COPYING | 64 +- ChangeLog | 1964 --------------- Info.plist.in | 30 - Makefile.am | 97 +- NEWS | 42 - README | 190 +- README.utils | 43 - TODO | 6 - acconfig.h | 82 + arch/.cvsignore | 1 - arch/dos/.cvsignore | 1 - arch/dos/Makefile.am | 4 +- arch/dos/{rbaudio.c => cdrom.c} | 11 +- arch/dos/digimm.c | 4 +- arch/ggi/.cvsignore | 1 - arch/ggi/Makefile.am | 2 +- arch/ggi/key.c | 14 +- arch/include/joy.h | 18 +- arch/linux/.cvsignore | 1 - arch/linux/Makefile.am | 14 +- arch/linux/alsadigi.c | 7 +- arch/linux/findfile.c | 15 +- arch/linux/hmiplay.c | 9 +- arch/linux/include/ipx_bsd.h | 11 +- arch/linux/include/ipx_drv.h | 72 - arch/linux/include/ipx_hlpr.h | 10 +- arch/linux/include/ipx_kali.h | 11 +- arch/linux/include/ipx_ld.h | 10 +- arch/linux/include/ipx_lin.h | 12 +- arch/linux/include/ipx_udp.h | 11 +- arch/linux/include/joystick.h | 2 - arch/linux/include/music.h | 2 - arch/linux/include/serial.h | 13 +- arch/linux/include/ukali.h | 16 +- arch/linux/init.c | 14 +- arch/linux/ipx_bsd.c | 346 +-- arch/linux/ipx_kali.c | 69 +- arch/linux/ipx_lin.c | 12 +- arch/linux/ipx_udp.c | 9 +- arch/linux/joydefs.c | 11 +- arch/linux/joystick.c | 15 +- arch/linux/linuxnet.c | 372 +-- arch/linux/ukali.c | 12 +- arch/ogl/.cvsignore | 1 - arch/ogl/Makefile.am | 2 +- arch/ogl/glx.c | 16 +- arch/ogl/gr.c | 50 +- arch/ogl/ogl.c | 71 +- arch/ogl/sdlgl.c | 37 +- arch/ogl/wgl.c | 12 +- arch/sdl/.cvsignore | 1 - arch/sdl/Makefile.am | 8 +- arch/sdl/cdrom.c | 137 ++ arch/sdl/digi.c | 103 +- arch/sdl/event.c | 28 +- arch/sdl/gr.c | 62 +- arch/sdl/init.c | 39 +- arch/sdl/joy.c | 264 +- arch/sdl/joydefs.c | 86 +- arch/sdl/key.c | 15 +- arch/sdl/mouse.c | 46 +- arch/sdl/rbaudio.c | 203 -- arch/sdl/timer.c | 33 +- arch/svgalib/.cvsignore | 1 - arch/svgalib/Makefile.am | 2 +- arch/svgalib/key.c | 14 +- arch/win32/.cvsignore | 1 - arch/win32/Makefile.am | 15 +- arch/win32/digi.c | 6 +- arch/win32/ipx_drv.h | 84 - arch/win32/ipx_win.c | 85 +- arch/win32/mingw_init.c | 6 + arch/win32/winnet.c | 356 +-- autogen.sh | 5 +- cfile/.cvsignore | 1 - cfile/Makefile.am | 2 +- cfile/cfile.c | 233 +- compilerdefs.txt | 205 +- configure.ac | 478 ++-- cvshowto.txt | 149 +- d2x-gl.sh | 42 - d2x-sdl.sh | 7 - debian/changelog.in | 6 - debian/control | 20 - debian/d2x-gl.files | 1 - debian/d2x-gl.menu | 2 - debian/d2x-sdl.files | 1 - debian/d2x-sdl.menu | 2 - debian/rules | 105 - iff/.cvsignore | 1 - iff/Makefile.am | 2 +- iff/iff.c | 46 +- include/3d.h | 191 +- include/byteswap.h | 36 +- include/cfile.h | 66 +- include/d1x.xpm | 41 - include/d_delay.h | 8 + include/descent.xpm | 45 - include/error.h | 57 +- include/gr.h | 216 +- include/grdef.h | 51 +- include/ibitblt.h | 56 +- include/iff.h | 29 +- include/interp.h | 71 - include/ipx.h | 73 +- include/ipx_drv.h | 89 + include/libmve.h | 13 - include/loadgl.h | 8 +- include/maths.h | 20 +- include/ogl_init.h | 10 +- include/palette.h | 44 +- include/pcx.h | 55 +- include/pstypes.h | 28 +- include/rle.h | 36 +- include/strutil.h | 6 +- include/texmap.h | 11 +- include/timer.h | 45 +- include/u_mem.h | 16 +- include/vecmat.h | 18 +- installation.txt | 102 +- libmve/.cvsignore | 1 - libmve/Makefile.am | 15 - libmve/decoder16.c | 716 ------ libmve/decoder8.c | 871 ------- libmve/decoders.h | 16 - libmve/mve_audio.c | 55 - libmve/mve_audio.h | 6 - libmve/mve_main.c | 155 -- libmve/mvelib.c | 617 ----- libmve/mvelib.h | 109 - libmve/mveplay.c | 945 -------- debian/copyright => license.txt | 37 +- main/.cvsignore | 1 - main/Makefile.am | 71 +- main/ai.c | 1030 +++----- main/ai.h | 497 ++-- main/automap.c | 165 +- main/automap.h | 8 - main/bm.c | 1126 +++++---- main/bm.h | 82 +- main/cdrom.h | 13 + main/cntrlcen.c | 44 +- main/cntrlcen.h | 21 +- main/collide.c | 413 +--- main/config.c | 6 +- main/console.c | 39 +- main/credits.c | 15 +- main/crypt.c | 56 +- main/digi.h | 92 +- main/editor/.cvsignore | 1 - main/editor/Makefile.am | 2 +- main/effects.c | 29 +- main/effects.h | 40 +- main/endlevel.c | 165 +- main/endlevel.h | 7 +- main/escort.c | 14 +- main/escort.h | 20 - main/fuelcen.c | 29 +- main/fuelcen.h | 23 - main/game.c | 140 +- main/game.h | 10 +- main/gamecntl.c | 105 +- main/gamefont.c | 11 +- main/gamefont.h | 1 - main/gamemine.c | 819 ++----- main/gamemine.h | 40 +- main/gamepal.c | 3 +- main/gamerend.c | 17 +- main/gamesave.c | 820 +++++-- main/gamesave.h | 9 +- main/gameseq.c | 234 +- main/gameseq.h | 37 +- main/hud.c | 56 +- main/inferno.c | 1047 ++------ main/ipx_drv.c | 438 ++++ main/joydefs.h | 6 +- main/kconfig.c | 527 +--- main/kconfig.h | 8 - main/kludge.c | 81 +- main/laser.c | 19 +- main/laser.h | 155 +- main/menu.c | 354 +-- main/menu.h | 40 +- main/mission.c | 629 ++--- main/mission.h | 96 +- main/morph.c | 128 +- main/movie.c | 626 ++--- main/movie.h | 1 - main/multi.c | 3637 ++++++++++++++-------------- main/multi.h | 299 +-- main/netmisc.c | 43 +- main/netmisc.h | 59 +- main/network.c | 789 +++--- main/network.h | 128 +- main/newdemo.c | 2220 ++++++----------- main/newdemo.h | 184 +- main/newmenu.c | 834 +------ main/newmenu.h | 53 +- main/object.h | 9 +- main/{ => old}/joydefs.c | 436 +--- main/old/movie.c | 1279 ++++++++++ main/piggy.c | 1105 ++------- main/piggy.h | 97 +- main/player.c | 32 - main/player.h | 272 +-- main/playsave.c | 452 +--- main/polyobj.c | 250 +- main/polyobj.h | 53 +- main/powerup.c | 20 +- main/powerup.h | 132 +- main/render.c | 492 +--- main/render.h | 15 +- main/reorder.h | 20 - main/robot.c | 201 +- main/robot.h | 225 +- main/scores.c | 258 +- main/scores.h | 27 +- main/segment.c | 52 - main/segment.h | 21 - main/songs.c | 71 +- main/sounds.h | 172 +- main/state.c | 22 +- main/switch.c | 63 +- main/switch.h | 61 +- main/terrain.c | 30 +- main/texmerge.c | 181 +- main/text.c | 74 +- main/text.h | 1375 +++++------ main/titles.c | 995 ++++---- main/titles.h | 58 +- main/vclip.c | 23 +- main/vclip.h | 50 +- main/vers_id.h | 3 +- main/wall.c | 136 +- main/wall.h | 284 +-- main/weapon.c | 78 +- main/weapon.h | 332 ++- maths/.cvsignore | 1 - maths/Makefile.am | 2 +- maths/fix.asm | 3 +- maths/fixc.c | 68 +- maths/rand.c | 7 +- maths/tables.c | 18 +- maths/vecmat.c | 37 +- maths/vecmata.asm | 128 +- mem/.cvsignore | 1 - mem/Makefile.am | 2 +- mem/mem.c | 30 +- mingw32.txt | 56 + misc/.cvsignore | 1 - misc/Makefile.am | 10 +- misc/args.c | 66 +- misc/byteswap.c | 3 +- misc/d_delay.c | 45 + misc/d_glob.c | 97 + misc/d_io.c | 7 +- misc/dos_disk.h | 1 - misc/error.c | 82 +- misc/fileutil.c | 130 +- {include => misc}/fileutil.h | 38 +- misc/hash.c | 5 +- misc/parsarg.c | 5 +- misc/parsarg.h | 49 +- misc/strio.c | 5 +- misc/strutil.c | 34 +- readme.txt | 23 +- rpm/.cvsignore | 1 - rpm/d2x.spec.in | 118 - texmap/.cvsignore | 1 - texmap/Makefile.am | 2 +- texmap/ntmap.c | 117 +- texmap/scanline.c | 44 +- texmap/scanline.h | 24 +- texmap/texmapl.h | 47 +- texmap/tmap_flt.asm | 10 +- texmap/tmap_inc.asm | 13 +- texmap/tmap_lin.asm | 32 +- texmap/tmap_ll.asm | 10 +- texmap/tmap_per.asm | 13 +- texmap/tmapfade.asm | 10 +- texmap/tmapflat.c | 51 +- texmap/tmappent.S | 1 - texmap/tmapppro.S | 1 - tools/cvs2cl/cvs2cl.pl | 1787 ++++++++++++++ {include => unused/bios}/rbaudio.h | 6 +- unused/lib/fix.h | 147 ++ unused/lib/rbaudio.h | 58 + unused/novga/files.rc | 0 unused/novga/novesa.c | 117 + utilities/.cvsignore | 1 - utilities/Makefile.am | 17 - utilities/hogcreate.c | 78 - utilities/hogextract.c | 79 - utilities/mvlcreate.c | 96 - utilities/mvlextract.c | 92 - utilities/tex2txb.c | 63 - utilities/txb2tex.c | 60 - 341 files changed, 18062 insertions(+), 32458 deletions(-) delete mode 100644 .cvsignore delete mode 100644 2d/.cvsignore create mode 100644 2d/linear.h delete mode 100644 3d/.cvsignore delete mode 100644 ChangeLog delete mode 100644 Info.plist.in delete mode 100644 README.utils delete mode 100644 TODO create mode 100644 acconfig.h delete mode 100644 arch/.cvsignore delete mode 100644 arch/dos/.cvsignore rename arch/dos/{rbaudio.c => cdrom.c} (81%) delete mode 100644 arch/ggi/.cvsignore delete mode 100644 arch/linux/.cvsignore delete mode 100644 arch/linux/include/ipx_drv.h delete mode 100644 arch/ogl/.cvsignore delete mode 100644 arch/sdl/.cvsignore create mode 100644 arch/sdl/cdrom.c delete mode 100644 arch/sdl/rbaudio.c delete mode 100644 arch/svgalib/.cvsignore delete mode 100644 arch/win32/.cvsignore delete mode 100644 arch/win32/ipx_drv.h delete mode 100644 cfile/.cvsignore delete mode 100644 d2x-gl.sh delete mode 100644 d2x-sdl.sh delete mode 100644 debian/changelog.in delete mode 100644 debian/control delete mode 100644 debian/d2x-gl.files delete mode 100644 debian/d2x-gl.menu delete mode 100644 debian/d2x-sdl.files delete mode 100644 debian/d2x-sdl.menu delete mode 100644 debian/rules delete mode 100644 iff/.cvsignore delete mode 100644 include/d1x.xpm create mode 100644 include/d_delay.h delete mode 100644 include/descent.xpm delete mode 100644 include/interp.h create mode 100644 include/ipx_drv.h delete mode 100644 include/libmve.h delete mode 100644 libmve/.cvsignore delete mode 100644 libmve/Makefile.am delete mode 100644 libmve/decoder16.c delete mode 100644 libmve/decoder8.c delete mode 100644 libmve/decoders.h delete mode 100644 libmve/mve_audio.c delete mode 100644 libmve/mve_audio.h delete mode 100644 libmve/mve_main.c delete mode 100644 libmve/mvelib.c delete mode 100644 libmve/mvelib.h delete mode 100644 libmve/mveplay.c rename debian/copyright => license.txt (54%) delete mode 100644 main/.cvsignore create mode 100644 main/cdrom.h delete mode 100644 main/editor/.cvsignore delete mode 100644 main/escort.h create mode 100644 main/ipx_drv.c rename main/{ => old}/joydefs.c (71%) create mode 100644 main/old/movie.c delete mode 100644 main/player.c delete mode 100644 main/reorder.h delete mode 100644 main/segment.c delete mode 100644 maths/.cvsignore delete mode 100644 mem/.cvsignore create mode 100644 mingw32.txt delete mode 100644 misc/.cvsignore create mode 100644 misc/d_delay.c create mode 100644 misc/d_glob.c rename {include => misc}/fileutil.h (54%) delete mode 100644 rpm/.cvsignore delete mode 100644 rpm/d2x.spec.in delete mode 100644 texmap/.cvsignore create mode 100644 tools/cvs2cl/cvs2cl.pl rename {include => unused/bios}/rbaudio.h (94%) create mode 100644 unused/lib/fix.h create mode 100644 unused/lib/rbaudio.h create mode 100644 unused/novga/files.rc create mode 100644 unused/novga/novesa.c delete mode 100644 utilities/.cvsignore delete mode 100644 utilities/Makefile.am delete mode 100644 utilities/hogcreate.c delete mode 100644 utilities/hogextract.c delete mode 100644 utilities/mvlcreate.c delete mode 100644 utilities/mvlextract.c delete mode 100755 utilities/tex2txb.c delete mode 100755 utilities/txb2tex.c diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 6440c0c8..00000000 --- a/.cvsignore +++ /dev/null @@ -1,13 +0,0 @@ -Makefile.in -aclocal.m4 -autom4te.cache -compile -conf.h.in -config.guess -config.sub -configure -depcomp -install-sh -missing -mkinstalldirs -stamp-h.in diff --git a/2d/.cvsignore b/2d/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/2d/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/2d/2dsline.c b/2d/2dsline.c index 62f0a1ce..c765cd83 100644 --- a/2d/2dsline.c +++ b/2d/2dsline.c @@ -1,4 +1,3 @@ -/* $Id: 2dsline.c,v 1.10 2003-04-29 08:05:41 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,56 +7,19 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/2d/2dsline.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-18 22:45:58 $ * - * Graphical routines for drawing solid scanlines. + * FIXME: add description * - * Old Log: - * Revision 1.6 1995/09/14 14:24:03 allender - * fixed MW compile error - * - * Revision 1.5 1995/09/14 13:45:17 allender - * quick optimization for scanline - * - * Revision 1.4 1995/04/27 07:36:05 allender - * remove some memsets since all old is here now - * - * Revision 1.3 1995/04/19 14:35:33 allender - * *** empty log message *** - * - * Revision 1.2 1995/04/18 12:03:40 allender - * *** empty log message *** - * - * Revision 1.1 1995/03/09 09:24:06 allender - * Initial revision - * - * - * --- PC RCS information --- - * Revision 1.7 1994/11/18 22:50:48 john - * Changed a bunch of shorts to ints in calls. - * - * Revision 1.6 1994/09/02 11:40:32 john - * fixed bug with urect scanline drakening still - * only using 16 levels of fade. - * - * Revision 1.5 1994/04/08 16:59:12 john - * Add fading poly's; Made palette fade 32 instead of 16. - * - * Revision 1.4 1994/03/22 18:36:27 john - * Added darkening scanlines - * - * Revision 1.3 1993/10/15 16:22:52 john - * y - * - * Revision 1.2 1993/09/08 11:56:29 john - * neatened - * - * Revision 1.1 1993/09/08 11:44:27 john - * Initial revision + * $Log: not supported by cvs2svn $ * */ @@ -71,34 +33,28 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gr.h" #include "grdef.h" -#include "error.h" -#ifdef __MSDOS__ +#ifdef __DJGPP__ #include "modex.h" #include "vesa.h" #endif -#if defined(POLY_ACC) -#include "poly_acc.h" -#endif - int Gr_scanline_darkening_level = GR_FADE_LEVELS; -#if !defined(NO_ASM) && defined(__WATCOMC__) - +#ifndef NO_ASM +# ifdef __WATCOMC__ void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table ); -#pragma aux gr_linear_darken parm [edi] [eax] [ecx] [edx] modify exact [eax ebx ecx edx edi] = \ -" xor ebx, ebx " \ -" mov bh, al " \ -"gld_loop: mov bl, [edi] " \ -" mov al, [ebx+edx] " \ -" mov [edi], al " \ -" inc edi " \ -" dec ecx " \ -" jnz gld_loop " - -#elif !defined(NO_ASM) && defined(__GNUC__) - +# pragma aux gr_linear_darken parm [edi] [eax] [ecx] [edx] modify exact [eax ebx ecx edx edi] = \ +" xor ebx, ebx " \ +" mov bh, al " \ +"gld_loop: mov bl, [edi] " \ +" mov al, [ebx+edx] " \ +" mov [edi], al " \ +" inc edi " \ +" dec ecx " \ +" jnz gld_loop " + +# elif defined __GNUC__ static inline void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table ) { int dummy[4]; __asm__ __volatile__ ( @@ -114,180 +70,82 @@ static inline void gr_linear_darken( ubyte * dest, int darkening_level, int coun : "0" (dest), "1" (darkening_level), "2" (count), "3" (fade_table) : "%ebx"); } - -#elif !defined(NO_ASM) && defined(_MSC_VER) - +# elif defined _MSC_VER __inline void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table ) { - __asm { + __asm { mov edi,[dest] - mov eax,[darkening_level] - mov ecx,[count] - mov edx,[fade_table] - xor ebx, ebx - mov bh, al + mov eax,[darkening_level] + mov ecx,[count] + mov edx,[fade_table] + xor ebx, ebx + mov bh, al gld_loop: - mov bl,[edi] - mov al,[ebx+edx] - mov [edi],al - inc edi - dec ecx - jnz gld_loop - } -} - -#else // Unknown compiler, or no assembler. So we use C. - -void gr_linear_darken(ubyte * dest, int darkening_level, int count, ubyte * fade_table) { - register int i; - - for (i=0;i 3) { - while ((int)(dest) & 0x3) { *dest++ = color; count--; }; - if (count >= 4) { - x = (color << 24) | (color << 16) | (color << 8) | color; - while (count > 4) { *(int *)dest = x; dest += 4; count -= 4; }; - } - while (count > 0) { *dest++ = color; count--; }; - } else { - for (i=0; i> 16; - } - - pa_flush(); - for (i=0; i> 10) & 0x1f)] | - gt[((*dest >> 5) & 0x1f)] | - bt[((*dest >> 0) & 0x1f)] | - 0x8000; - dest++; - } -} +#ifdef USE_C_GR_LINEAR_DARKEN +void gr_linear_darken(ubyte * dest, int darkening_level, int count, ubyte * fade_table) { + register int i; -void gr_linear15_stosd( short * dest, ubyte color, unsigned short count ) -{ - //$$ this routine is a prime candidate for using the alpha blender. - short c = pa_clut[color]; - pa_flush(); - while(count--) - *dest++ = c; + for (i=0;i= GR_FADE_LEVELS ) { + if (Gr_scanline_darkening_level >= GR_FADE_LEVELS ) { +#ifdef __DJGPP__ switch(TYPE) { case BM_LINEAR: -#ifdef OGL - case BM_OGL: #endif gr_linear_stosd( DATA + ROWSIZE*y + x1, (unsigned char)COLOR, x2-x1+1); - break; -#ifdef __MSDOS__ +#ifdef __DJGPP__ + break; case BM_MODEX: gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR ); break; case BM_SVGA: gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR ); break; -#endif -#if defined(POLY_ACC) - case BM_LINEAR15: - gr_linear15_stosd( (short *)(DATA + ROWSIZE*y + x1 * PA_BPP), COLOR, x2-x1+1); - break; -#endif } +#endif } else { +#ifdef __DJGPP__ switch(TYPE) { case BM_LINEAR: -#ifdef OGL - case BM_OGL: #endif gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table); +#ifdef __DJGPP__ break; -#ifdef __MSDOS__ case BM_MODEX: gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR ); break; case BM_SVGA: -#if 1 - { - ubyte * vram = (ubyte *)0xA0000; - int VideoLocation,page,offset1, offset2; - - VideoLocation = (ROWSIZE * y) + x1; - page = VideoLocation >> 16; - offset1 = VideoLocation & 0xFFFF; - offset2 = offset1 + (x2-x1+1); - - gr_vesa_setpage( page ); - if ( offset2 <= 0xFFFF ) { - gr_linear_darken( &vram[offset1], Gr_scanline_darkening_level, x2-x1+1, gr_fade_table); - } else { - gr_linear_darken( &vram[offset1], Gr_scanline_darkening_level, 0xFFFF-offset1+1, gr_fade_table); - page++; - gr_vesa_setpage(page); - gr_linear_darken( vram, Gr_scanline_darkening_level, offset2 - 0xFFFF, gr_fade_table); - } - } -#else gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR ); -#endif break; -#endif -#if defined(POLY_ACC) - case BM_LINEAR15: - gr_linear15_darken( (short *)(DATA + ROWSIZE*y + x1 * PA_BPP), Gr_scanline_darkening_level, x2-x1+1, gr_fade_table); - break; -#endif } +#endif } } @@ -303,73 +161,39 @@ void gr_scanline( int x1, int x2, int y ) if (x1 < MINX) x1 = MINX; if (x2 > MAXX) x2 = MAXX; - if (Gr_scanline_darkening_level >= GR_FADE_LEVELS ) { + if (Gr_scanline_darkening_level >= GR_FADE_LEVELS ) { +#ifdef __DJGPP__ switch(TYPE) { case BM_LINEAR: -#ifdef OGL - case BM_OGL: #endif gr_linear_stosd( DATA + ROWSIZE*y + x1, (unsigned char)COLOR, x2-x1+1); +#ifdef __DJGPP__ break; -#ifdef __MSDOS__ case BM_MODEX: gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR ); break; case BM_SVGA: gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR ); break; -#endif -#if defined(POLY_ACC) - case BM_LINEAR15: - gr_linear15_stosd( (short *)(DATA + ROWSIZE*y + x1 * PA_BPP), COLOR, x2-x1+1); - break; -#endif } +#endif } else { +#ifdef __DJGPP__ switch(TYPE) { case BM_LINEAR: -#ifdef OGL - case BM_OGL: #endif gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table); +#ifdef __DJGPP__ break; -#ifdef __MSDOS__ case BM_MODEX: gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR ); break; case BM_SVGA: -#if 1 - { - ubyte * vram = (ubyte *)0xA0000; - int VideoLocation,page,offset1, offset2; - - VideoLocation = (ROWSIZE * y) + x1; - page = VideoLocation >> 16; - offset1 = VideoLocation & 0xFFFF; - offset2 = offset1 + (x2-x1+1); - - gr_vesa_setpage( page ); - if ( offset2 <= 0xFFFF ) { - gr_linear_darken( &vram[offset1], Gr_scanline_darkening_level, x2-x1+1, gr_fade_table); - } else { - gr_linear_darken( &vram[offset1], Gr_scanline_darkening_level, 0xFFFF-offset1+1, gr_fade_table); - page++; - gr_vesa_setpage(page); - gr_linear_darken( vram, Gr_scanline_darkening_level, offset2 - 0xFFFF, gr_fade_table); - } - } -#else gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR ); -#endif break; -#endif -#if defined(POLY_ACC) - case BM_LINEAR15: - gr_linear15_darken( (short *)(DATA + ROWSIZE*y + x1 * PA_BPP), Gr_scanline_darkening_level, x2-x1+1, gr_fade_table); - break; -#endif } +#endif } } diff --git a/2d/Makefile.am b/2d/Makefile.am index 298e9deb..2ce85c7c 100644 --- a/2d/Makefile.am +++ b/2d/Makefile.am @@ -1,5 +1,5 @@ noinst_LIBRARIES = lib2d.a -INCLUDES = -I $(top_srcdir)/include +INCLUDES = -I $(top_srcdir)/includes if USE_ASM ASM_SRCS = @@ -7,12 +7,6 @@ else ASM_SRCS = tmerge.c endif -if MACDATA -TRANSPARENCY_COLOR = 0 -else -TRANSPARENCY_COLOR = 255 -endif - lib2d_a_SOURCES = ${ASM_SRCS} \ 2dsline.c box.c disc.c ibitblt.c pcx.c rect.c scalec.c \ bitblt.c canvas.c font.c line.c pixel.c rle.c \ @@ -20,7 +14,7 @@ bitmap.c circle.c gpixel.c palette.c poly.c SUFFIXES = .asm %.o: %.asm - $(NASM) -dTRANSPARENCY_COLOR=${TRANSPARENCY_COLOR} $(NASMFLAGS) $< -o $@ + $(NASM) $(NASMFLAGS) $< -o $@ if USE_ASM lib2d_a_LIBADD = linear.o tmerge_a.o @@ -28,5 +22,5 @@ endif EXTRA_DIST = \ linear.asm scalea.asm tmerge_a.asm \ -bitmap.h clip.h scalea.h \ +bitmap.h clip.h linear.h scalea.h \ scale.c tmerge.c diff --git a/2d/bitblt.c b/2d/bitblt.c index 0c6e7d8e..ad8faba0 100644 --- a/2d/bitblt.c +++ b/2d/bitblt.c @@ -1,4 +1,3 @@ -/* $Id: bitblt.c,v 1.10 2002-09-07 07:15:50 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,643 +7,76 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Routines for bitblt's. - * - * Old Log: - * Revision 1.29 1995/03/14 12:14:28 john - * Added code to double horz/vert bitblts. - * - * Revision 1.28 1995/03/13 09:01:48 john - * Fixed bug with VFX1 screen not tall enough. - * - * Revision 1.27 1995/03/01 15:38:10 john - * Better ModeX support. - * - * Revision 1.26 1994/12/15 12:19:00 john - * Added gr_bm_bitblt (clipped!) function. - * - * Revision 1.25 1994/12/09 18:58:42 matt - * Took out include of 3d.h - * - * Revision 1.24 1994/11/28 17:08:32 john - * Took out some unused functions in linear.asm, moved - * gr_linear_movsd from linear.asm to bitblt.c, made sure that - * the code in ibiblt.c sets the direction flags before rep movsing. - * - * Revision 1.22 1994/11/23 16:04:00 john - * Fixed generic rle'ing to use new bit method. - * - * Revision 1.21 1994/11/18 22:51:03 john - * Changed a bunch of shorts to ints in calls. - * - * Revision 1.20 1994/11/10 15:59:48 john - * Fixed bugs with canvas's being created with bogus bm_flags. - * - * Revision 1.19 1994/11/09 21:03:35 john - * Added RLE for svga gr_ubitmap. - * - * Revision 1.18 1994/11/09 17:41:29 john - * Made a slow version of rle bitblt to svga, modex. - * - * Revision 1.17 1994/11/09 16:35:15 john - * First version with working RLE bitmaps. - * - * Revision 1.16 1994/11/04 10:06:58 john - * Added fade table for fading fonts. Made font that partially clips - * not print a warning message. - * - * Revision 1.15 1994/09/22 16:08:38 john - * Fixed some palette stuff. - * - * Revision 1.14 1994/09/19 11:44:27 john - * Changed call to allocate selector to the dpmi module. - * - * Revision 1.13 1994/08/08 13:03:00 john - * Fixed bug in gr_bitmap in modex - * - * Revision 1.12 1994/07/13 19:47:23 john - * Fixed bug with modex bitblt to page 2 not working. - * - * Revision 1.11 1994/05/31 11:10:52 john - * *** empty log message *** - * - * Revision 1.10 1994/03/18 15:24:34 matt - * Removed interlace stuff - * - * Revision 1.9 1994/02/18 15:32:20 john - * *** empty log message *** - * - * Revision 1.8 1994/02/01 13:22:54 john - * *** empty log message *** - * - * Revision 1.7 1994/01/13 08:28:25 mike - * Modify rect copy to copy alternate scanlines when in interlaced mode. - * - * Revision 1.6 1993/12/28 12:09:46 john - * added lbitblt.asm - * - * Revision 1.5 1993/10/26 13:18:09 john - * *** empty log message *** - * - * Revision 1.4 1993/10/15 16:23:30 john - * y - * - * Revision 1.3 1993/09/13 17:52:58 john - * Fixed bug in BitBlt linear to SVGA - * - * Revision 1.2 1993/09/08 14:47:00 john - * Made bitmap00 add rowsize instead of bitmap width. - * Other routines might have this problem too. - * - * Revision 1.1 1993/09/08 11:43:01 john - * Initial revision - * - */ - #ifdef HAVE_CONFIG_H #include #endif -#include "pa_enabl.h" //$$POLY_ACC +#include #include "u_mem.h" #include "gr.h" #include "grdef.h" #include "rle.h" -#include "mono.h" -#include "byteswap.h" // because of rle code that has short for row offsets #include "error.h" #ifdef OGL #include "ogl_init.h" #endif -#if defined(POLY_ACC) -#include "poly_acc.h" -#endif - int gr_bitblt_dest_step_shift = 0; int gr_bitblt_double = 0; ubyte *gr_bitblt_fade_table=NULL; -extern void gr_vesa_bitmap( grs_bitmap * source, grs_bitmap * dest, int x, int y ); - -void gr_linear_movsd( ubyte * source, ubyte * dest, unsigned int nbytes); -// This code aligns edi so that the destination is aligned to a dword boundry before rep movsd - -#if !defined(NO_ASM) && defined(__WATCOMC__) - -#pragma aux gr_linear_movsd parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] = \ -" cld " \ -" mov ebx, ecx " \ -" mov eax, edi" \ -" and eax, 011b" \ -" jz d_aligned" \ -" mov ecx, 4" \ -" sub ecx, eax" \ -" sub ebx, ecx" \ -" rep movsb" \ -" d_aligned: " \ -" mov ecx, ebx" \ -" shr ecx, 2" \ -" rep movsd" \ -" mov ecx, ebx" \ -" and ecx, 11b" \ -" rep movsb"; - -#elif !defined(NO_ASM) && defined(__GNUC__) - -inline void gr_linear_movsd(ubyte *src, ubyte *dest, unsigned int num_pixels) { - int dummy[3]; - __asm__ __volatile__ ( -" cld;" -" movl %%ecx, %%ebx;" -" movl %%edi, %%eax;" -" andl $3, %%eax;" -" jz 0f;" -" movl $4, %%ecx;" -" subl %%eax,%%ecx;" -" subl %%ecx,%%ebx;" -" rep; movsb;" -"0: ;" -" movl %%ebx, %%ecx;" -" shrl $2, %%ecx;" -" rep; movsl;" -" movl %%ebx, %%ecx;" -" andl $3, %%ecx;" -" rep; movsb" - : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2]) - : "0" (src), "1" (dest), "2" (num_pixels) - : "%eax", "%ebx"); -} - -#elif !defined(NO_ASM) && defined(_MSC_VER) - -__inline void gr_linear_movsd(ubyte *src, ubyte *dest, unsigned int num_pixels) -{ - __asm { - mov esi, [src] - mov edi, [dest] - mov ecx, [num_pixels] - cld - mov ebx, ecx - mov eax, edi - and eax, 011b - jz d_aligned - mov ecx, 4 - sub ecx, eax - sub ebx, ecx - rep movsb -d_aligned: - mov ecx, ebx - shr ecx, 2 - rep movsd - mov ecx, ebx - and ecx, 11b - rep movsb - } -} - -#else // NO_ASM or unknown compiler - -#define THRESHOLD 8 - -#ifdef RELEASE -#define test_byteblit 0 -#else -ubyte test_byteblit = 0; -#endif - -void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels ) -{ - int i; - uint n, r; - double *d, *s; - ubyte *d1, *s1; - -// check to see if we are starting on an even byte boundry -// if not, move appropriate number of bytes to even -// 8 byte boundry - - if ( (num_pixels < THRESHOLD) || (((int)src & 0x7) != ((int)dest & 0x7)) || test_byteblit ) { - for (i = 0; i < num_pixels; i++) - *dest++ = *src++; - return; - } - - i = 0; - if ((r = (int)src & 0x7)) { - for (i = 0; i < 8 - r; i++) - *dest++ = *src++; - } - num_pixels -= i; - - n = num_pixels / 8; - r = num_pixels % 8; - s = (double *)src; - d = (double *)dest; - for (i = 0; i < n; i++) - *d++ = *s++; - s1 = (ubyte *)s; - d1 = (ubyte *)d; - for (i = 0; i < r; i++) - *d1++ = *s1++; -} - -#endif //#ifdef NO_ASM - - -static void gr_linear_rep_movsdm(ubyte * src, ubyte * dest, unsigned int num_pixels ); - -#if !defined(NO_ASM) && defined(__WATCOMC__) - -#pragma aux gr_linear_rep_movsdm parm [esi] [edi] [ecx] modify exact [ecx esi edi eax] = \ -"nextpixel:" \ - "mov al,[esi]" \ - "inc esi" \ - "cmp al, " TRANSPARENCY_COLOR_STR \ - "je skip_it" \ - "mov [edi], al" \ -"skip_it:" \ - "inc edi" \ - "dec ecx" \ - "jne nextpixel"; - -#elif !defined(NO_ASM) && defined(__GNUC__) - -static inline void gr_linear_rep_movsdm(ubyte * src, ubyte * dest, unsigned int num_pixels ) { - int dummy[3]; - __asm__ __volatile__ ( -"0: ;" -" movb (%%esi), %%al;" -" incl %%esi;" -" cmpb $" TRANSPARENCY_COLOR_STR ", %%al;" -" je 1f;" -" movb %%al,(%%edi);" -"1: ;" -" incl %%edi;" -" decl %%ecx;" -" jne 0b" - : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2]) - : "0" (src), "1" (dest), "2" (num_pixels) - : "%eax"); -} - -#elif !defined(NO_ASM) && defined(_MSC_VER) - -__inline void gr_linear_rep_movsdm(ubyte * src, ubyte * dest, unsigned int num_pixels ) -{ - __asm { - nextpixel: - mov esi, [src] - mov edi, [dest] - mov ecx, [num_pixels] - mov al, [esi] - inc esi - cmp al, TRANSPARENCY_COLOR - je skip_it - mov [edi], al - skip_it: - inc edi - dec ecx - jne nextpixel - } -} - -#else - -static void gr_linear_rep_movsdm(ubyte * src, ubyte * dest, unsigned int num_pixels ) -{ - int i; - for (i=0; i> 8) & 0x00FFFF00) | (temp & 0xFF0000FF); // 0xABCDEFGH -> 0xABABCDEF - temp = ((temp >> 8) & 0x000000FF) | (temp & 0xFFFFFF00); // 0xABABCDEF -> 0xABABCDCD - doubletemp[0] = temp; - - work = ((work << 8) & 0x00FFFF00) | (work & 0xFF0000FF); // 0xABCDEFGH -> 0xABEFGHGH - work = ((work << 8) & 0xFF000000) | (work & 0x00FFFFFF); // 0xABEFGHGH -> 0xEFEFGHGH - doubletemp[1] = work; - - *d = *(double *) &(doubletemp[0]); - d++; } } - -#endif - - -#ifdef __MSDOS__ - -static void modex_copy_column(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ); - -#if !defined(NO_ASM) && defined(__WATCOMC__) - -#pragma aux modex_copy_column parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = \ -"nextpixel:" \ - "mov al,[esi]" \ - "add esi, ebx" \ - "mov [edi], al" \ - "add edi, edx" \ - "dec ecx" \ - "jne nextpixel" - -#elif !defined(NO_ASM) && defined(__GNUC__) - -static inline void modex_copy_column(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) { -/*#pragma aux modex_copy_column parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = */ - __asm__ __volatile__ ( -"0: ;" - "movb (%%esi), %%al;" - "addl %%ebx, %%esi;" - "movb %%al, (%%edi);" - "addl %%edx, %%edi;" - "decl %%ecx;" - "jne 0b" - : : "S" (src), "D" (dest), "c" (num_pixels), "b" (src_rowsize), "d" (dest_rowsize) - : "%eax", "%ecx", "%esi", "%edi"); -} - -#else - -static void modex_copy_column(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) -{ - src = src; - dest = dest; - num_pixels = num_pixels; - src_rowsize = src_rowsize; - dest_rowsize = dest_rowsize; - Int3(); -} - #endif - - -static void modex_copy_column_m(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ); - -#if !defined(NO_ASM) && defined(__WATCOMC__) - -#pragma aux modex_copy_column_m parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = \ -"nextpixel:" \ - "mov al,[esi]" \ - "add esi, ebx" \ - "cmp al, " TRANSPARENCY_COLOR_STR \ - "je skip_itx" \ - "mov [edi], al" \ -"skip_itx:" \ - "add edi, edx" \ - "dec ecx" \ - "jne nextpixel" - -#elif !defined(NO_ASM) && defined(__GNUC__) - -static inline void modex_copy_column_m(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) { -/* #pragma aux modex_copy_column_m parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = */ - int dummy[3]; - __asm__ __volatile__ ( -"0: ;" - "movb (%%esi), %%al;" - "addl %%ebx, %%esi;" - "cmpb $" TRANSPARENCY_COLOR_STR ", %%al;" - "je 1f;" - "movb %%al, (%%edi);" -"1: ;" - "addl %%edx, %%edi;" - "decl %%ecx;" - "jne 0b" - : "=c" (dummy[0]), "=S" (dummy[1]), "=D" (dummy[2]) - : "1" (src), "2" (dest), "0" (num_pixels), "b" (src_rowsize), "d" (dest_rowsize) - : "%eax" ); -} - -#else - -static void modex_copy_column_m(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) -{ - src = src; - dest = dest; - num_pixels = num_pixels; - src_rowsize = src_rowsize; - dest_rowsize = dest_rowsize; - Int3(); -} - +#ifdef D1XD3D +#include "d3dhelp.h" #endif -#endif /* __MSDOS__ */ - void gr_ubitmap00( int x, int y, grs_bitmap *bm ) { register int y1; @@ -681,7 +113,7 @@ void gr_ubitmap00m( int x, int y, grs_bitmap *bm ) src = bm->bm_data; - if (gr_bitblt_fade_table==NULL) { + if (gr_bitblt_fade_table==NULL) { for (y1=0; y1 < bm->bm_h; y1++ ) { gr_linear_rep_movsdm( src, dest, bm->bm_w ); src += bm->bm_rowsize; @@ -696,193 +128,23 @@ void gr_ubitmap00m( int x, int y, grs_bitmap *bm ) } } -#if 0 -" jmp aligned4 " \ -" mov eax, edi " \ -" and eax, 11b " \ -" jz aligned4 " \ -" mov ebx, 4 " \ -" sub ebx, eax " \ -" sub ecx, ebx " \ -"alignstart: " \ -" mov al, [esi] " \ -" add esi, 4 " \ -" mov [edi], al " \ -" inc edi " \ -" dec ebx " \ -" jne alignstart " \ -"aligned4: " -#endif - -#ifdef __MSDOS__ - -static void modex_copy_scanline( ubyte * src, ubyte * dest, int npixels ); - -#if !defined(NO_ASM) && defined(__WATCOMC__) - -#pragma aux modex_copy_scanline parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = \ -" mov ebx, ecx " \ -" and ebx, 11b " \ -" shr ecx, 2 " \ -" cmp ecx, 0 " \ -" je no2group " \ -"next4pixels: " \ -" mov al, [esi+8] " \ -" mov ah, [esi+12] " \ -" shl eax, 16 " \ -" mov al, [esi] " \ -" mov ah, [esi+4] " \ -" mov [edi], eax " \ -" add esi, 16 " \ -" add edi, 4 " \ -" dec ecx " \ -" jne next4pixels " \ -"no2group: " \ -" cmp ebx, 0 " \ -" je done2 " \ -"finishend: " \ -" mov al, [esi] " \ -" add esi, 4 " \ -" mov [edi], al " \ -" inc edi " \ -" dec ebx " \ -" jne finishend " \ -"done2: "; - -#elif !defined (NO_ASM) && defined(__GNUC__) - -static inline void modex_copy_scanline( ubyte * src, ubyte * dest, int npixels ) { -/* #pragma aux modex_copy_scanline parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] */ -int dummy[3]; - __asm__ __volatile__ ( -" movl %%ecx, %%ebx;" -" andl $3, %%ebx;" -" shrl $2, %%ecx;" -" cmpl $0, %%ecx;" -" je 1f;" -"0: ;" -" movb 8(%%esi), %%al;" -" movb 12(%%esi), %%ah;" -" shll $16, %%eax;" -" movb (%%esi), %%al;" -" movb 4(%%esi), %%ah;" -" movl %%eax, (%%edi);" -" addl $16, %%esi;" -" addl $4, %%edi;" -" decl %%ecx;" -" jne 0b;" -"1: ;" -" cmpl $0, %%ebx;" -" je 3f;" -"2: ;" -" movb (%%esi), %%al;" -" addl $4, %%esi;" -" movb %%al, (%%edi);" -" incl %%edi;" -" decl %%ebx;" -" jne 2b;" -"3:" - : "=c" (dummy[0]), "=S" (dummy[1]), "=D" (dummy[2]) - : "1" (src), "2" (dest), "0" (npixels) - : "%eax", "%ebx", "%edx" ); -} - -#else - -static void modex_copy_scanline( ubyte * src, ubyte * dest, int npixels ) -{ - src = src; - dest = dest; - npixels = npixels; - Int3(); -} - -#endif - -static void modex_copy_scanline_2x( ubyte * src, ubyte * dest, int npixels ); - -#if !defined(NO_ASM) && defined(__WATCOMC__) - -#pragma aux modex_copy_scanline_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = \ -" mov ebx, ecx " \ -" and ebx, 11b " \ -" shr ecx, 2 " \ -" cmp ecx, 0 " \ -" je no2group " \ -"next4pixels: " \ -" mov al, [esi+4] " \ -" mov ah, [esi+6] " \ -" shl eax, 16 " \ -" mov al, [esi] " \ -" mov ah, [esi+2] " \ -" mov [edi], eax " \ -" add esi, 8 " \ -" add edi, 4 " \ -" dec ecx " \ -" jne next4pixels " \ -"no2group: " \ -" cmp ebx, 0 " \ -" je done2 " \ -"finishend: " \ -" mov al, [esi] " \ -" add esi, 2 " \ -" mov [edi], al " \ -" inc edi " \ -" dec ebx " \ -" jne finishend " \ -"done2: "; - -#elif !defined(NO_ASM) && defined(__GNUC__) - -static inline void modex_copy_scanline_2x( ubyte * src, ubyte * dest, int npixels ) { -/* #pragma aux modex_copy_scanline_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = */ -int dummy[3]; - __asm__ __volatile__ ( -" movl %%ecx, %%ebx;" -" andl $3, %%ebx;" -" shrl $2, %%ecx;" -" cmpl $0, %%ecx;" -" je 1f;" -"0: ;" -" movb 4(%%esi), %%al;" -" movb 6(%%esi), %%ah;" -" shll $16, %%eax;" -" movb (%%esi), %%al;" -" movb 2(%%esi), %%ah;" -" movl %%eax, (%%edi);" -" addl $8, %%esi;" -" addl $4, %%edi;" -" decl %%ecx;" -" jne 0b;" -"1: ;" -" cmp $0, %%ebx;" -" je 3f;" -"2:" -" movb (%%esi),%%al;" -" addl $2, %%esi;" -" movb %%al, (%%edi);" -" incl %%edi;" -" decl %%ebx;" -" jne 2b;" -"3:" - : "=c" (dummy[0]), "=S" (dummy[1]), "=D" (dummy[2]) - : "1" (src), "2" (dest), "0" (npixels) - : "%eax", "%ebx", "%edx" ); -} - -#else - -static void modex_copy_scanline_2x( ubyte * src, ubyte * dest, int npixels ) -{ - src = src; - dest = dest; - npixels = npixels; - Int3(); -} - -#endif - - +//" jmp aligned4 " +//" mov eax, edi " +//" and eax, 11b " +//" jz aligned4 " +//" mov ebx, 4 " +//" sub ebx, eax " +//" sub ecx, ebx " +//"alignstart: " +//" mov al, [esi] " +//" add esi, 4 " +//" mov [edi], al " +//" inc edi " +//" dec ebx " +//" jne alignstart " +//"aligned4: " + +#ifdef __DJGPP__ // From Linear to ModeX void gr_bm_ubitblt01(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { @@ -897,28 +159,28 @@ void gr_bm_ubitblt01(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * sstep = src->bm_rowsize; dstep = dest->bm_rowsize << gr_bitblt_dest_step_shift; - if (!gr_bitblt_double) { - for (plane=0; plane<4; plane++ ) { + if (!gr_bitblt_double) { + for (plane=0; plane<4; plane++ ) { gr_modex_setplane( (plane+dx)&3 ); sbits = src->bm_data + (src->bm_rowsize * sy) + sx + plane; dbits = &gr_video_memory[(dest->bm_rowsize * dy) + ((plane+dx)/4) ]; w1 = w >> 2; if ( (w&3) > plane ) w1++; - for (y=dy; y < dy+h; y++ ) { - modex_copy_scanline( sbits, dbits, w1 ); + for (y=dy; y < dy+h; y++ ) { + modex_copy_scanline( sbits, dbits, w1 ); dbits += dstep; sbits += sstep; } } } else { - for (plane=0; plane<4; plane++ ) { + for (plane=0; plane<4; plane++ ) { gr_modex_setplane( (plane+dx)&3 ); sbits = src->bm_data + (src->bm_rowsize * sy) + sx + plane/2; dbits = &gr_video_memory[(dest->bm_rowsize * dy) + ((plane+dx)/4) ]; w1 = w >> 2; if ( (w&3) > plane ) w1++; - for (y=dy; y < dy+h; y++ ) { - modex_copy_scanline_2x( sbits, dbits, w1 ); + for (y=dy; y < dy+h; y++ ) { + modex_copy_scanline_2x( sbits, dbits, w1 ); dbits += dstep; sbits += sstep; } @@ -932,17 +194,17 @@ void gr_bm_ubitblt01m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * { //ubyte * dbits1; //ubyte * sbits1; - + ubyte * dbits; ubyte * sbits; int x; - //int y; +// int y; sbits = src->bm_data + (src->bm_rowsize * sy) + sx; dbits = &gr_video_memory[(dest->bm_rowsize * dy) + dx/4]; - for (x=dx; x < dx+w; x++ ) { + for (x=dx; x < dx+w; x++ ) { gr_modex_setplane( x&3 ); //sbits1 = sbits; @@ -951,7 +213,7 @@ void gr_bm_ubitblt01m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * // *dbits1 = *sbits1; // sbits1 += src_bm_rowsize; // dbits1 += dest_bm_rowsize; - //} + // } modex_copy_column_m(sbits, dbits, h, src->bm_rowsize, dest->bm_rowsize << gr_bitblt_dest_step_shift ); sbits++; @@ -960,7 +222,7 @@ void gr_bm_ubitblt01m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * } } -#endif /* __MSDOS__ */ +#endif void gr_ubitmap012( int x, int y, grs_bitmap *bm ) @@ -985,9 +247,9 @@ void gr_ubitmap012m( int x, int y, grs_bitmap *bm ) src = bm->bm_data; - for (y1=y; y1 < (y+bm->bm_h); y1++ ) { - for (x1=x; x1 < (x+bm->bm_w); x1++ ) { - if ( *src != TRANSPARENCY_COLOR ) { + for (y1=y; y1 < (y+bm->bm_h); y1++ ) { + for (x1=x; x1 < (x+bm->bm_w); x1++ ) { + if ( *src != 255 ) { gr_setcolor( *src ); gr_upixel( x1, y1 ); } @@ -996,146 +258,135 @@ void gr_ubitmap012m( int x, int y, grs_bitmap *bm ) } } -#if defined(POLY_ACC) -void gr_ubitmap05( int x, int y, grs_bitmap *bm ) + +void gr_ubitmapGENERIC(int x, int y, grs_bitmap * bm) { register int x1, y1; - unsigned char *src; - short *dst; - int mod; - - pa_flush(); - src = bm->bm_data; - dst = (short *)(DATA + y * ROWSIZE + x * PA_BPP); - mod = ROWSIZE / 2 - bm->bm_w; - for (y1=y; y1 < (y+bm->bm_h); y1++ ) { - for (x1=x; x1 < (x+bm->bm_w); x1++ ) { - *dst++ = pa_clut[*src++]; + for (y1=0; y1 < bm->bm_h; y1++ ) { + for (x1=0; x1 < bm->bm_w; x1++ ) { + gr_setcolor( gr_gpixel(bm,x1,y1) ); + gr_upixel( x+x1, y+y1 ); } - dst += mod; } } -void gr_ubitmap05m( int x, int y, grs_bitmap *bm ) +void gr_ubitmapGENERICm(int x, int y, grs_bitmap * bm) { register int x1, y1; - unsigned char *src; - short *dst; - int mod; - - pa_flush(); - src = bm->bm_data; - dst = (short *)(DATA + y * ROWSIZE + x * PA_BPP); - mod = ROWSIZE / 2 - bm->bm_w; + ubyte c; - for (y1=y; y1 < (y+bm->bm_h); y1++ ) { - for (x1=x; x1 < (x+bm->bm_w); x1++ ) { - if ( *src != TRANSPARENCY_COLOR ) { - *dst = pa_clut[*src]; + for (y1=0; y1 < bm->bm_h; y1++ ) { + for (x1=0; x1 < bm->bm_w; x1++ ) { + c = gr_gpixel(bm,x1,y1); + if ( c != 255 ) { + gr_setcolor( c ); + gr_upixel( x+x1, y+y1 ); } - src++; - ++dst; } - dst += mod; } } -void gr_bm_ubitblt05_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) -{ - unsigned short * dbits; - unsigned char * sbits, scanline[640]; - int i, data_offset, j, nextrow; - - pa_flush(); - nextrow=dest->bm_rowsize/PA_BPP; - - data_offset = 1; - if (src->bm_flags & BM_FLAG_RLE_BIG) - data_offset = 2; - - sbits = &src->bm_data[4 + (src->bm_h*data_offset)]; - for (i=0; ibm_data[4+(i*data_offset)])); +void gr_ubitmap( int x, int y, grs_bitmap *bm ) +{ int source, dest; - dbits = (unsigned short *)(dest->bm_data + (dest->bm_rowsize * dy) + dx*PA_BPP); + source = bm->bm_type; + dest = TYPE; - // No interlacing, copy the whole buffer. - for (i=0; i < h; i++ ) { - gr_rle_expand_scanline( scanline, sbits, sx, sx+w-1 ); - for(j = 0; j != w; ++j) - dbits[j] = pa_clut[scanline[j]]; - if ( src->bm_flags & BM_FLAG_RLE_BIG ) - sbits += (int)INTEL_SHORT(*((short *)&(src->bm_data[4+((i+sy)*data_offset)]))); - else - sbits += (int)(src->bm_data[4+i+sy]); - dbits += nextrow; + if (source==BM_LINEAR) { + switch( dest ) + { + case BM_LINEAR: + if ( bm->bm_flags & BM_FLAG_RLE ) + gr_bm_ubitblt00_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap ); + else + gr_ubitmap00( x, y, bm ); + return; +#ifdef OGL + case BM_OGL: + ogl_ubitmapm(x,y,bm); + return; +#endif +#ifdef D1XD3D + case BM_DIRECTX: + Assert ((int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_RENDER || (int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_DISPLAY); + Win32_BlitLinearToDirectX_bm(bm, 0, 0, bm->bm_w, bm->bm_h, x, y, 0); + return; +#endif +#ifdef __DJGPP__ + case BM_SVGA: + if ( bm->bm_flags & BM_FLAG_RLE ) + gr_bm_ubitblt0x_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap, 0 ); + else + gr_bm_ubitblt02( bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap); + return; + case BM_MODEX: + gr_bm_ubitblt01(bm->bm_w, bm->bm_h, x+XOFFSET, y+YOFFSET, 0, 0, bm, &grd_curcanv->cv_bitmap); + return; +#endif + default: + gr_ubitmap012( x, y, bm ); + return; + } + } else { + gr_ubitmapGENERIC(x, y, bm); } } -void gr_bm_ubitblt05m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) -{ - unsigned short * dbits; - unsigned char * sbits, scanline[640]; - int i, data_offset, j, nextrow; - - pa_flush(); - nextrow=dest->bm_rowsize/PA_BPP; - data_offset = 1; - if (src->bm_flags & BM_FLAG_RLE_BIG) - data_offset = 2; +void gr_ubitmapm( int x, int y, grs_bitmap *bm ) +{ int source, dest; - sbits = &src->bm_data[4 + (src->bm_h*data_offset)]; - for (i=0; ibm_data[4+(i*data_offset)])); - dbits = (unsigned short *)(dest->bm_data + (dest->bm_rowsize * dy) + dx*PA_BPP); + source = bm->bm_type; + dest = TYPE; - // No interlacing, copy the whole buffer. - for (i=0; i < h; i++ ) { - gr_rle_expand_scanline( scanline, sbits, sx, sx+w-1 ); - for(j = 0; j != w; ++j) - if(scanline[j] != TRANSPARENCY_COLOR) - dbits[j] = pa_clut[scanline[j]]; - if ( src->bm_flags & BM_FLAG_RLE_BIG ) - sbits += (int)INTEL_SHORT(*((short *)&(src->bm_data[4+((i+sy)*data_offset)]))); - else - sbits += (int)(src->bm_data[4+i+sy]); - dbits += nextrow; - } -} + if (source==BM_LINEAR) { + switch( dest ) + { + case BM_LINEAR: + if ( bm->bm_flags & BM_FLAG_RLE ) + gr_bm_ubitblt00m_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap ); + else + gr_ubitmap00m( x, y, bm ); + return; +#ifdef OGL + case BM_OGL: + ogl_ubitmapm(x,y,bm); + return; #endif - -void gr_ubitmapGENERIC(int x, int y, grs_bitmap * bm) -{ - register int x1, y1; - - for (y1=0; y1 < bm->bm_h; y1++ ) { - for (x1=0; x1 < bm->bm_w; x1++ ) { - gr_setcolor( gr_gpixel(bm,x1,y1) ); - gr_upixel( x+x1, y+y1 ); - } - } -} - -void gr_ubitmapGENERICm(int x, int y, grs_bitmap * bm) -{ - register int x1, y1; - ubyte c; - - for (y1=0; y1 < bm->bm_h; y1++ ) { - for (x1=0; x1 < bm->bm_w; x1++ ) { - c = gr_gpixel(bm,x1,y1); - if ( c != TRANSPARENCY_COLOR ) { - gr_setcolor( c ); - gr_upixel( x+x1, y+y1 ); +#ifdef D1XD3D + case BM_DIRECTX: + if (bm->bm_w < 35 && bm->bm_h < 35) { + // ugly hack needed for reticle + if ( bm->bm_flags & BM_FLAG_RLE ) + gr_bm_ubitblt0x_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap, 1 ); + else + gr_ubitmapGENERICm(x, y, bm); + return; } + Assert ((int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_RENDER || (int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_DISPLAY); + Win32_BlitLinearToDirectX_bm(bm, 0, 0, bm->bm_w, bm->bm_h, x, y, 1); + return; +#endif +#ifdef __DJGPP__ + case BM_SVGA: + gr_ubitmapGENERICm(x, y, bm); + return; + case BM_MODEX: + gr_bm_ubitblt01m(bm->bm_w, bm->bm_h, x+XOFFSET, y+YOFFSET, 0, 0, bm, &grd_curcanv->cv_bitmap); + return; +#endif + default: + gr_ubitmap012m( x, y, bm ); + return; } + } else { + gr_ubitmapGENERICm(x, y, bm); } } -#ifdef __MSDOS__ +#ifdef __DJGPP__ // From linear to SVGA void gr_bm_ubitblt02(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { @@ -1165,9 +416,9 @@ void gr_bm_ubitblt02(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * if ( EndingOffset <= 0xFFFF ) { if ( gr_bitblt_double ) - gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+0xA0000), w ); + gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+gr_video_memory), w ); else - gr_linear_movsd( (void *)sbits, (void *)(offset+0xA0000), w ); + gr_linear_movsd( (void *)sbits, (void *)(offset+gr_video_memory), w ); VideoLocation += dbpr; sbits += sbpr; @@ -1177,76 +428,23 @@ void gr_bm_ubitblt02(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * BytesToMove = 0xFFFF-offset+1; if ( gr_bitblt_double ) - gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+0xA0000), BytesToMove ); + gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+gr_video_memory), BytesToMove ); else - gr_linear_movsd( (void *)sbits, (void *)(offset+0xA0000), BytesToMove ); + gr_linear_movsd( (void *)sbits, (void *)(offset+gr_video_memory), BytesToMove ); page++; gr_vesa_setpage(page); if ( gr_bitblt_double ) - gr_linear_rep_movsd_2x( (void *)(sbits+BytesToMove/2), (void *)0xA0000, EndingOffset - 0xFFFF ); + gr_linear_rep_movsd_2x( (void *)(sbits+BytesToMove/2), (void *)gr_video_memory, EndingOffset - 0xFFFF ); else - gr_linear_movsd( (void *)(sbits+BytesToMove), (void *)0xA0000, EndingOffset - 0xFFFF ); + gr_linear_movsd( (void *)(sbits+BytesToMove), (void *)gr_video_memory, EndingOffset - 0xFFFF ); VideoLocation += dbpr; sbits += sbpr; } } } -#endif - -#ifdef __MSDOS__ - -void gr_bm_ubitblt02m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) -{ - unsigned char * sbits; - - unsigned int offset, EndingOffset, VideoLocation; - - int sbpr, dbpr, y1, page, BytesToMove; - - sbpr = src->bm_rowsize; - - dbpr = dest->bm_rowsize << gr_bitblt_dest_step_shift; - - VideoLocation = (unsigned int)dest->bm_data + (dest->bm_rowsize * dy) + dx; - - sbits = src->bm_data + ( sbpr*sy ) + sx; - - for (y1=0; y1 < h; y1++ ) { - - page = VideoLocation >> 16; - offset = VideoLocation & 0xFFFF; - - gr_vesa_setpage( page ); - - EndingOffset = offset+w-1; - - if ( EndingOffset <= 0xFFFF ) - { - gr_linear_rep_movsdm( (void *)sbits, (void *)(offset+0xA0000), w ); - - VideoLocation += dbpr; - sbits += sbpr; - } - else - { - BytesToMove = 0xFFFF-offset+1; - - gr_linear_rep_movsdm( (void *)sbits, (void *)(offset+0xA0000), BytesToMove ); - - page++; - gr_vesa_setpage(page); - - gr_linear_rep_movsdm( (void *)(sbits+BytesToMove), (void *)0xA0000, EndingOffset - 0xFFFF ); - - VideoLocation += dbpr; - sbits += sbpr; - } - } -} - // From SVGA to linear void gr_bm_ubitblt20(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) @@ -1285,9 +483,7 @@ void gr_bm_ubitblt20(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * } } - -#endif - +#endif // __DJGPP__ //@extern int Interlacing_on; // From Linear to Linear @@ -1295,32 +491,38 @@ void gr_bm_ubitblt00(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * { unsigned char * dbits; unsigned char * sbits; - //int src_bm_rowsize_2, dest_bm_rowsize_2; + //int src_bm_rowsize_2, dest_bm_rowsize_2; int dstep; int i; - sbits = src->bm_data + (src->bm_rowsize * sy) + sx; + sbits = src->bm_data + (src->bm_rowsize * sy) + sx; dbits = dest->bm_data + (dest->bm_rowsize * dy) + dx; dstep = dest->bm_rowsize << gr_bitblt_dest_step_shift; // No interlacing, copy the whole buffer. - for (i=0; i < h; i++ ) { - if (gr_bitblt_double) - gr_linear_rep_movsd_2x( sbits, dbits, w ); - else - gr_linear_movsd( sbits, dbits, w ); + if (gr_bitblt_double) + for (i=0; i < h; i++ ) { + gr_linear_rep_movsd_2x( sbits, dbits, w ); sbits += src->bm_rowsize; dbits += dstep; - } + } + else + for (i=0; i < h; i++ ) { + gr_linear_movsd( sbits, dbits, w ); + //memcpy(dbits, sbits, w); + sbits += src->bm_rowsize; + dbits += dstep; + } } + // From Linear to Linear Masked void gr_bm_ubitblt00m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { unsigned char * dbits; unsigned char * sbits; - //int src_bm_rowsize_2, dest_bm_rowsize_2; + //int src_bm_rowsize_2, dest_bm_rowsize_2; int i; @@ -1329,7 +531,7 @@ void gr_bm_ubitblt00m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * // No interlacing, copy the whole buffer. - if (gr_bitblt_fade_table==NULL) { + if (gr_bitblt_fade_table==NULL) { for (i=0; i < h; i++ ) { gr_linear_rep_movsdm( sbits, dbits, w ); sbits += src->bm_rowsize; @@ -1345,153 +547,120 @@ void gr_bm_ubitblt00m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * } -extern void gr_lbitblt( grs_bitmap * source, grs_bitmap * dest, int height, int width ); - -#if 1 //def MACINTOSH - -// width == number of destination pixels - -void gr_linear_movsd_double(ubyte *src, ubyte *dest, int width) +void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { - double *d = (double *)dest; - uint *s = (uint *)src; - uint doubletemp[2]; - uint temp, work; - int i, num_pixels; - - num_pixels = width / 2; - if ( (num_pixels & 0x3) || (((int)src & 0x7) != ((int)dest & 0x7)) ) { - // not a multiple of 4? do single pixel at a time - for (i=0; ibm_w-1; + int dy1=dy, dy2=dy+dest->bm_h-1; - temp = ((temp >> 8) & 0x00FFFF00) | (temp & 0xFF0000FF); // 0xABCDEFGH -> 0xABABCDEF - temp = ((temp >> 8) & 0x000000FF) | (temp & 0xFFFFFF00); // 0xABABCDEF -> 0xABABCDCD - doubletemp[0] = temp; + int sx1=sx, sx2=sx+src->bm_w-1; + int sy1=sy, sy2=sy+src->bm_h-1; - work = ((work << 8) & 0x00FFFF00) | (work & 0xFF0000FF); // 0xABCDEFGH -> 0xABEFGHGH - work = ((work << 8) & 0xFF000000) | (work & 0x00FFFFFF); // 0xABEFGHGH -> 0xEFEFGHGH - doubletemp[1] = work; + if ((dx1 >= dest->bm_w ) || (dx2 < 0)) return; + if ((dy1 >= dest->bm_h ) || (dy2 < 0)) return; + if ( dx1 < 0 ) { sx1 += -dx1; dx1 = 0; } + if ( dy1 < 0 ) { sy1 += -dy1; dy1 = 0; } + if ( dx2 >= dest->bm_w ) { dx2 = dest->bm_w-1; } + if ( dy2 >= dest->bm_h ) { dy2 = dest->bm_h-1; } - *d = *(double *) &(doubletemp[0]); - d++; - } -} + if ((sx1 >= src->bm_w ) || (sx2 < 0)) return; + if ((sy1 >= src->bm_h ) || (sy2 < 0)) return; + if ( sx1 < 0 ) { dx1 += -sx1; sx1 = 0; } + if ( sy1 < 0 ) { dy1 += -sy1; sy1 = 0; } + if ( sx2 >= src->bm_w ) { sx2 = src->bm_w-1; } + if ( sy2 >= src->bm_h ) { sy2 = src->bm_h-1; } -//extern void BlitLargeAlign(ubyte *draw_buffer, int dstRowBytes, ubyte *dstPtr, int w, int h, int modulus); + // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2) + if ( dx2-dx1+1 < w ) + w = dx2-dx1+1; + if ( dy2-dy1+1 < h ) + h = dy2-dy1+1; + if ( sx2-sx1+1 < w ) + w = sx2-sx1+1; + if ( sy2-sy1+1 < h ) + h = sy2-sy1+1; -#ifdef MACINTOSH -asm void BlitLargeAlign(ubyte *rSrcPtr, int rDblDStrd, ubyte *rDst1Ptr, int rWidth, int rHeight, int rModulus) -{ - stw r31,-4(SP) // store non-volatile reg in red zone - addi r5,r5,-8 // subtract 8 from dst - stw r30,-8(SP) // store non-volatile reg in red zone - - la r30,-16(SP) // calculate copy of local 8-byte variable - sub r9,r8,r6 - // rSStrd = modulus - w - add r31,r5,r4 // dst2 = dstRowBytes + dst1 - sub r4,r4,r6 // r4 = dstRowBytes - w - addi r7,r7,-1 // subtract 1 from height count - srawi r6,r6,2 // rWidth = w >> 2 - addi r3,r3,-4 // subtract 4 from src - addi r6,r6,-1 // subtract 1 from width count - add r4,r4,r4 // rDblDStrd = 2 * r4 - -BlitLargeAlignY: // y count is in r7 - lwzu r10,4(r3) // load a long into r10 - mr r0,r10 // put a copy in r0 - mr r11,r10 -// these are simplified -- can't use 'em inslwi r0,r10,16,8 -// these are simplified -- can't use 'em insrwi r11,r10,16,8 - rlwimi r0,r10,24,8,31 - rlwimi r11,r10,8,8,23 - rlwimi r0,r10,16,24,31 - stw r0,0(r30) - rlwimi r11,r10,16,0,7 - stw r11,4(r30) - mtctr r6 // copy x count into the counter - lfd fp0,0(r30) - -BlitLargeAlignX: - lwzu r10,4(r3) // load a long into r10 - stfdu fp0,8(r5) - mr r0,r10 // put a copy in r0 - mr r11,r10 -// simplefied inslwi r0,r10,16,8 -// simplefied insrwi r11,r10,16,8 - rlwimi r0,r10,24,8,31 - rlwimi r11,r10,8,8,23 - rlwimi r0,r10,16,24,31 - stw r0,0(r30) - rlwimi r11,r10,16,0,7 - stw r11,4(r30) - stfdu fp0,8(r31) - lfd fp0,0(r30) - bdnz BlitLargeAlignX // loop over all x - - stfdu fp0,8(r5) - addic. r7,r7,-1 // decrement the counter - add r3,r3,r9 - // src += sstride - add r5,r5,r4 - // dst1 += dstride - stfdu fp0,8(r31) - add r31,r31,r4 - // dst2 += dstride - bne BlitLargeAlignY // loop for all y - - lwz r30,-8(SP) // restore non-volatile regs - lwz r31,-4(SP) // restore non-volatile regs - blr // return to caller + gr_bm_ubitblt(w,h, dx1, dy1, sx1, sy1, src, dest ); } -void gr_bm_ubitblt_double(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap *src, grs_bitmap *dest) +void gr_bm_ubitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { - ubyte * dbits; - ubyte * sbits; - int dstep, i; - - sbits = src->bm_data + (src->bm_rowsize * sy) + sx; - dbits = dest->bm_data + (dest->bm_rowsize * dy) + dx; - dstep = dest->bm_rowsize << gr_bitblt_dest_step_shift; - Assert( !((int)dbits & 0x7) ); // assert to check double word alignment - BlitLargeAlign(sbits, dstep, dbits, src->bm_w, src->bm_h, src->bm_rowsize); -} -#endif + register int x1, y1; -// w and h are the doubled width and height + if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_LINEAR )) + { + if ( src->bm_flags & BM_FLAG_RLE ) + gr_bm_ubitblt00_rle( w, h, dx, dy, sx, sy, src, dest ); + else + gr_bm_ubitblt00( w, h, dx, dy, sx, sy, src, dest ); + return; + } -void gr_bm_ubitblt_double_slow(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap *src, grs_bitmap *dest) -{ - ubyte * dbits; - ubyte * sbits; - int dstep, i; +#ifdef OGL + if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_OGL )) + { + ogl_ubitblt(w, h, dx, dy, sx, sy, src, dest); + return; + } + if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_LINEAR )) + { + ogl_ubitblt_tolinear(w, h, dx, dy, sx, sy, src, dest); + return; + } + if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_OGL )) + { + ogl_ubitblt_copy(w, h, dx, dy, sx, sy, src, dest); + return; + } +#endif - sbits = src->bm_data + (src->bm_rowsize * sy) + sx; - dbits = dest->bm_data + (dest->bm_rowsize * dy) + dx; - dstep = dest->bm_rowsize << gr_bitblt_dest_step_shift; +#ifdef D1XD3D + if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_DIRECTX )) + { + Assert ((int)dest->bm_data == BM_D3D_RENDER || (int)dest->bm_data == BM_D3D_DISPLAY); + Win32_BlitLinearToDirectX_bm (src, sx, sy, w, h, dx, dy, 0); + return; + } + if ( (src->bm_type == BM_DIRECTX) && (dest->bm_type == BM_LINEAR )) + { + return; + } + if ( (src->bm_type == BM_DIRECTX) && (dest->bm_type == BM_DIRECTX )) + { + return; + } +#endif - for (i=0; i < h; i++ ) { + if ( (src->bm_flags & BM_FLAG_RLE ) && (src->bm_type == BM_LINEAR) ) { + gr_bm_ubitblt0x_rle(w, h, dx, dy, sx, sy, src, dest, 0 ); + return; + } +#ifdef __DJGPP__ + if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_SVGA )) + { + gr_bm_ubitblt02( w, h, dx, dy, sx, sy, src, dest ); + return; + } - gr_linear_movsd_double(sbits, dbits, w); - dbits += dstep; - if (i & 1) - sbits += src->bm_rowsize; + if ( (src->bm_type == BM_SVGA) && (dest->bm_type == BM_LINEAR )) + { + gr_bm_ubitblt20( w, h, dx, dy, sx, sy, src, dest ); + return; } -} + if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_MODEX )) + { + gr_bm_ubitblt01( w, h, dx+XOFFSET, dy+YOFFSET, sx, sy, src, dest ); + return; + } #endif + for (y1=0; y1 < h; y1++ ) { + for (x1=0; x1 < w; x1++ ) { + gr_bm_pixel( dest, dx+x1, dy+y1, gr_gpixel(src,sx+x1,sy+y1) ); + } + } +} - -// Clipped bitmap ... +// Clipped bitmap ... void gr_bitmap( int x, int y, grs_bitmap *bm ) { @@ -1503,64 +672,139 @@ void gr_bitmap( int x, int y, grs_bitmap *bm ) if ((dy1 >= grd_curcanv->cv_bitmap.bm_h) || (dy2 < 0)) return; if ( dx1 < 0 ) { sx = -dx1; dx1 = 0; } if ( dy1 < 0 ) { sy = -dy1; dy1 = 0; } - if ( dx2 >= grd_curcanv->cv_bitmap.bm_w ) { dx2 = grd_curcanv->cv_bitmap.bm_w-1; } - if ( dy2 >= grd_curcanv->cv_bitmap.bm_h ) { dy2 = grd_curcanv->cv_bitmap.bm_h-1; } - + if ( dx2 >= grd_curcanv->cv_bitmap.bm_w ) { dx2 = grd_curcanv->cv_bitmap.bm_w-1; } + if ( dy2 >= grd_curcanv->cv_bitmap.bm_h ) { dy2 = grd_curcanv->cv_bitmap.bm_h-1; } + // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2) gr_bm_ubitblt(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); } +void gr_bitmapm( int x, int y, grs_bitmap *bm ) +{ + int dx1=x, dx2=x+bm->bm_w-1; + int dy1=y, dy2=y+bm->bm_h-1; + int sx=0, sy=0; + + if ((dx1 >= grd_curcanv->cv_bitmap.bm_w ) || (dx2 < 0)) return; + if ((dy1 >= grd_curcanv->cv_bitmap.bm_h) || (dy2 < 0)) return; + if ( dx1 < 0 ) { sx = -dx1; dx1 = 0; } + if ( dy1 < 0 ) { sy = -dy1; dy1 = 0; } + if ( dx2 >= grd_curcanv->cv_bitmap.bm_w ) { dx2 = grd_curcanv->cv_bitmap.bm_w-1; } + if ( dy2 >= grd_curcanv->cv_bitmap.bm_h ) { dy2 = grd_curcanv->cv_bitmap.bm_h-1; } + + // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2) + + if ( (bm->bm_type == BM_LINEAR) && (grd_curcanv->cv_bitmap.bm_type == BM_LINEAR )) + { + if ( bm->bm_flags & BM_FLAG_RLE ) + gr_bm_ubitblt00m_rle(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); + else + gr_bm_ubitblt00m(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); + return; + } + + gr_bm_ubitbltm(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); + +} + +void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) +{ + register int x1, y1; + ubyte c; + +#ifdef OGL + if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_OGL )) + { + ogl_ubitblt(w, h, dx, dy, sx, sy, src, dest); + return; + } + if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_LINEAR )) + { + ogl_ubitblt_tolinear(w, h, dx, dy, sx, sy, src, dest); + return; + } + if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_OGL )) + { + ogl_ubitblt_copy(w, h, dx, dy, sx, sy, src, dest); + return; + } +#endif +#ifdef D1XD3D + if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_DIRECTX )) + { + Assert ((int)dest->bm_data == BM_D3D_RENDER || (int)dest->bm_data == BM_D3D_DISPLAY); + Win32_BlitLinearToDirectX_bm (src, sx, sy, w, h, dx, dy, 1); + return; + } + if ( (src->bm_type == BM_DIRECTX) && (dest->bm_type == BM_DIRECTX )) + { + Assert ((int)src->bm_data == BM_D3D_RENDER || (int)src->bm_data == BM_D3D_DISPLAY); +// Win32_BlitDirectXToDirectX (w, h, dx, dy, sx, sy, src->bm_data, dest->bm_data, 0); + return; + } +#endif + + + for (y1=0; y1 < h; y1++ ) { + for (x1=0; x1 < w; x1++ ) { + if ((c=gr_gpixel(src,sx+x1,sy+y1))!=255) + gr_bm_pixel( dest, dx+x1, dy+y1,c ); + } + } + +} + //-NOT-used // From linear to SVGA //-NOT-used void gr_bm_ubitblt02_2x(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) //-NOT-used { //-NOT-used unsigned char * sbits; -//-NOT-used +//-NOT-used //-NOT-used unsigned int offset, EndingOffset, VideoLocation; -//-NOT-used +//-NOT-used //-NOT-used int sbpr, dbpr, y1, page, BytesToMove; -//-NOT-used +//-NOT-used //-NOT-used sbpr = src->bm_rowsize; -//-NOT-used +//-NOT-used //-NOT-used dbpr = dest->bm_rowsize << gr_bitblt_dest_step_shift; -//-NOT-used +//-NOT-used //-NOT-used VideoLocation = (unsigned int)dest->bm_data + (dest->bm_rowsize * dy) + dx; -//-NOT-used +//-NOT-used //-NOT-used sbits = src->bm_data + ( sbpr*sy ) + sx; -//-NOT-used +//-NOT-used //-NOT-used for (y1=0; y1 < h; y1++ ) { -//-NOT-used +//-NOT-used //-NOT-used page = VideoLocation >> 16; //-NOT-used offset = VideoLocation & 0xFFFF; -//-NOT-used +//-NOT-used //-NOT-used gr_vesa_setpage( page ); -//-NOT-used +//-NOT-used //-NOT-used EndingOffset = offset+w-1; -//-NOT-used +//-NOT-used //-NOT-used if ( EndingOffset <= 0xFFFF ) //-NOT-used { -//-NOT-used gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+0xA0000), w ); -//-NOT-used +//-NOT-used gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+gr_video_memory), w ); +//-NOT-used //-NOT-used VideoLocation += dbpr; //-NOT-used sbits += sbpr; //-NOT-used } //-NOT-used else //-NOT-used { //-NOT-used BytesToMove = 0xFFFF-offset+1; -//-NOT-used -//-NOT-used gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+0xA0000), BytesToMove ); -//-NOT-used +//-NOT-used +//-NOT-used gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+gr_video_memory), BytesToMove ); +//-NOT-used //-NOT-used page++; //-NOT-used gr_vesa_setpage(page); -//-NOT-used -//-NOT-used gr_linear_rep_movsd_2x( (void *)(sbits+BytesToMove/2), (void *)0xA0000, EndingOffset - 0xFFFF ); -//-NOT-used +//-NOT-used +//-NOT-used gr_linear_rep_movsd_2x( (void *)(sbits+BytesToMove/2), (void *)gr_video_memory, EndingOffset - 0xFFFF ); +//-NOT-used //-NOT-used VideoLocation += dbpr; //-NOT-used sbits += sbpr; //-NOT-used } -//-NOT-used -//-NOT-used +//-NOT-used +//-NOT-used //-NOT-used } //-NOT-used } @@ -1570,17 +814,17 @@ void gr_bitmap( int x, int y, grs_bitmap *bm ) //-NOT-used { //-NOT-used unsigned char * dbits; //-NOT-used unsigned char * sbits; -//-NOT-used //int src_bm_rowsize_2, dest_bm_rowsize_2; -//-NOT-used +//-NOT-used //int src_bm_rowsize_2, dest_bm_rowsize_2; +//-NOT-used //-NOT-used int i; -//-NOT-used +//-NOT-used //-NOT-used sbits = src->bm_data + (src->bm_rowsize * sy) + sx; //-NOT-used dbits = dest->bm_data + (dest->bm_rowsize * dy) + dx; -//-NOT-used +//-NOT-used //-NOT-used // No interlacing, copy the whole buffer. //-NOT-used for (i=0; i < h; i++ ) { //-NOT-used gr_linear_rep_movsd_2x( sbits, dbits, w ); -//-NOT-used +//-NOT-used //-NOT-used sbits += src->bm_rowsize; //-NOT-used dbits += dest->bm_rowsize << gr_bitblt_dest_step_shift; //-NOT-used } @@ -1590,26 +834,19 @@ void gr_bm_ubitblt00_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitma { unsigned char * dbits; unsigned char * sbits; - int i, data_offset; - - data_offset = 1; - if (src->bm_flags & BM_FLAG_RLE_BIG) - data_offset = 2; - sbits = &src->bm_data[4 + (src->bm_h*data_offset)]; + int i; + sbits = &src->bm_data[4 + src->bm_h]; for (i=0; ibm_data[4+(i*data_offset)])); + sbits += (int)src->bm_data[4+i]; dbits = dest->bm_data + (dest->bm_rowsize * dy) + dx; // No interlacing, copy the whole buffer. for (i=0; i < h; i++ ) { gr_rle_expand_scanline( dbits, sbits, sx, sx+w-1 ); - if ( src->bm_flags & BM_FLAG_RLE_BIG ) - sbits += (int)INTEL_SHORT(*((short *)&(src->bm_data[4+((i+sy)*data_offset)]))); - else - sbits += (int)(src->bm_data[4+i+sy]); + sbits += (int)src->bm_data[4+i+sy]; dbits += dest->bm_rowsize << gr_bitblt_dest_step_shift; } } @@ -1618,499 +855,47 @@ void gr_bm_ubitblt00m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitm { unsigned char * dbits; unsigned char * sbits; - int i, data_offset; - data_offset = 1; - if (src->bm_flags & BM_FLAG_RLE_BIG) - data_offset = 2; + int i; - sbits = &src->bm_data[4 + (src->bm_h*data_offset)]; + sbits = &src->bm_data[4 + src->bm_h]; for (i=0; ibm_data[4+(i*data_offset)])); + sbits += (int)src->bm_data[4+i]; dbits = dest->bm_data + (dest->bm_rowsize * dy) + dx; // No interlacing, copy the whole buffer. for (i=0; i < h; i++ ) { gr_rle_expand_scanline_masked( dbits, sbits, sx, sx+w-1 ); - if ( src->bm_flags & BM_FLAG_RLE_BIG ) - sbits += (int)INTEL_SHORT(*((short *)&(src->bm_data[4+((i+sy)*data_offset)]))); - else - sbits += (int)(src->bm_data[4+i+sy]); + sbits += (int)src->bm_data[4+i+sy]; dbits += dest->bm_rowsize << gr_bitblt_dest_step_shift; } } // in rle.c -extern void gr_rle_expand_scanline_generic( grs_bitmap * dest, int dx, int dy, ubyte *src, int x1, int x2 ); -extern void gr_rle_expand_scanline_generic_masked( grs_bitmap * dest, int dx, int dy, ubyte *src, int x1, int x2 ); -extern void gr_rle_expand_scanline_svga_masked( grs_bitmap * dest, int dx, int dy, ubyte *src, int x1, int x2 ); +extern void gr_rle_expand_scanline_generic( grs_bitmap * dest, int dx, int dy, ubyte *src, + int x1, int x2, int masked ); -void gr_bm_ubitblt0x_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) + +void gr_bm_ubitblt0x_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, + grs_bitmap * dest, int masked ) { - int i, data_offset; + int i; register int y1; unsigned char * sbits; - //mprintf( 0, "SVGA RLE!\n" ); - - data_offset = 1; - if (src->bm_flags & BM_FLAG_RLE_BIG) - data_offset = 2; - - sbits = &src->bm_data[4 + (src->bm_h*data_offset)]; + sbits = &src->bm_data[4 + src->bm_h]; for (i=0; ibm_data[4+(i*data_offset)])); + sbits += (int)src->bm_data[4+i]; for (y1=0; y1 < h; y1++ ) { - gr_rle_expand_scanline_generic( dest, dx, dy+y1, sbits, sx, sx+w-1 ); - if ( src->bm_flags & BM_FLAG_RLE_BIG ) - sbits += (int)INTEL_SHORT(*((short *)&(src->bm_data[4+((y1+sy)*data_offset)]))); - else - sbits += (int)src->bm_data[4+y1+sy]; + gr_rle_expand_scanline_generic( dest, dx, dy+y1, sbits, sx, sx+w-1, + masked ); + sbits += (int)src->bm_data[4+y1+sy]; } - } -void gr_bm_ubitblt0xm_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) -{ - int i, data_offset; - register int y1; - unsigned char * sbits; - - //mprintf( 0, "SVGA RLE!\n" ); - - data_offset = 1; - if (src->bm_flags & BM_FLAG_RLE_BIG) - data_offset = 2; - - sbits = &src->bm_data[4 + (src->bm_h*data_offset)]; - for (i=0; ibm_data[4+(i*data_offset)])); - - for (y1=0; y1 < h; y1++ ) { - gr_rle_expand_scanline_generic_masked( dest, dx, dy+y1, sbits, sx, sx+w-1 ); - if ( src->bm_flags & BM_FLAG_RLE_BIG ) - sbits += (int)INTEL_SHORT(*((short *)&(src->bm_data[4+((y1+sy)*data_offset)]))); - else - sbits += (int)src->bm_data[4+y1+sy]; - } - -} - -#ifdef __MSDOS__ -void gr_bm_ubitblt02m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) -{ - int i, data_offset; - register int y1; - unsigned char * sbits; - - //mprintf( 0, "SVGA RLE!\n" ); - - data_offset = 1; - if (src->bm_flags & BM_FLAG_RLE_BIG) - data_offset = 2; - - sbits = &src->bm_data[4 + (src->bm_h*data_offset)]; - for (i=0; ibm_data[4+(i*data_offset)])); - - for (y1=0; y1 < h; y1++ ) { - gr_rle_expand_scanline_svga_masked( dest, dx, dy+y1, sbits, sx, sx+w-1 ); - if ( src->bm_flags & BM_FLAG_RLE_BIG ) - sbits += (int)INTEL_SHORT(*((short *)&(src->bm_data[4+((y1+sy)*data_offset)]))); - else - sbits += (int)src->bm_data[4+y1+sy]; - } -} -#endif - -void gr_bm_ubitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) -{ - register int x1, y1; - - if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_LINEAR )) - { - if ( src->bm_flags & BM_FLAG_RLE ) - gr_bm_ubitblt00_rle( w, h, dx, dy, sx, sy, src, dest ); - else - gr_bm_ubitblt00( w, h, dx, dy, sx, sy, src, dest ); - return; - } - -#ifdef OGL - if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_OGL )) - { - ogl_ubitblt(w, h, dx, dy, sx, sy, src, dest); - return; - } - if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_LINEAR )) - { - ogl_ubitblt_tolinear(w, h, dx, dy, sx, sy, src, dest); - return; - } - if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_OGL )) - { - ogl_ubitblt_copy(w, h, dx, dy, sx, sy, src, dest); - return; - } -#endif - -#ifdef D1XD3D - if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_DIRECTX )) - { - Assert ((int)dest->bm_data == BM_D3D_RENDER || (int)dest->bm_data == BM_D3D_DISPLAY); - Win32_BlitLinearToDirectX_bm (src, sx, sy, w, h, dx, dy, 0); - return; - } - if ( (src->bm_type == BM_DIRECTX) && (dest->bm_type == BM_LINEAR )) - { - return; - } - if ( (src->bm_type == BM_DIRECTX) && (dest->bm_type == BM_DIRECTX )) - { - return; - } -#endif - - if ( (src->bm_flags & BM_FLAG_RLE ) && (src->bm_type == BM_LINEAR) ) { - gr_bm_ubitblt0x_rle(w, h, dx, dy, sx, sy, src, dest ); - return; - } - -#ifdef __MSDOS__ - if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_SVGA )) - { - gr_bm_ubitblt02( w, h, dx, dy, sx, sy, src, dest ); - return; - } - - if ( (src->bm_type == BM_SVGA) && (dest->bm_type == BM_LINEAR )) - { - gr_bm_ubitblt20( w, h, dx, dy, sx, sy, src, dest ); - return; - } - - if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_MODEX )) - { - gr_bm_ubitblt01( w, h, dx+XOFFSET, dy+YOFFSET, sx, sy, src, dest ); - return; - } -#endif - -#if defined(POLY_ACC) - if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_LINEAR15 )) - { - ubyte *s = src->bm_data + sy * src->bm_rowsize + sx; - ushort *t = (ushort *)(dest->bm_data + dy * dest->bm_rowsize + dx * PA_BPP); - int x; - pa_flush(); - for(;h--;) - { - for(x = 0; x < w; x++) - t[x] = pa_clut[s[x]]; - s += src->bm_rowsize; - t += dest->bm_rowsize / PA_BPP; - } - return; - } - - if ( (src->bm_type == BM_LINEAR15) && (dest->bm_type == BM_LINEAR15 )) - { - pa_blit(dest, dx, dy, src, sx, sy, w, h); - return; - } -#endif - - for (y1=0; y1 < h; y1++ ) { - for (x1=0; x1 < w; x1++ ) { - gr_bm_pixel( dest, dx+x1, dy+y1, gr_gpixel(src,sx+x1,sy+y1) ); - } - } -} - -void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) -{ - int dx1=dx, dx2=dx+dest->bm_w-1; - int dy1=dy, dy2=dy+dest->bm_h-1; - - int sx1=sx, sx2=sx+src->bm_w-1; - int sy1=sy, sy2=sy+src->bm_h-1; - - if ((dx1 >= dest->bm_w ) || (dx2 < 0)) return; - if ((dy1 >= dest->bm_h ) || (dy2 < 0)) return; - if ( dx1 < 0 ) { sx1 += -dx1; dx1 = 0; } - if ( dy1 < 0 ) { sy1 += -dy1; dy1 = 0; } - if ( dx2 >= dest->bm_w ) { dx2 = dest->bm_w-1; } - if ( dy2 >= dest->bm_h ) { dy2 = dest->bm_h-1; } - - if ((sx1 >= src->bm_w ) || (sx2 < 0)) return; - if ((sy1 >= src->bm_h ) || (sy2 < 0)) return; - if ( sx1 < 0 ) { dx1 += -sx1; sx1 = 0; } - if ( sy1 < 0 ) { dy1 += -sy1; sy1 = 0; } - if ( sx2 >= src->bm_w ) { sx2 = src->bm_w-1; } - if ( sy2 >= src->bm_h ) { sy2 = src->bm_h-1; } - - // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2) - if ( dx2-dx1+1 < w ) - w = dx2-dx1+1; - if ( dy2-dy1+1 < h ) - h = dy2-dy1+1; - if ( sx2-sx1+1 < w ) - w = sx2-sx1+1; - if ( sy2-sy1+1 < h ) - h = sy2-sy1+1; - - gr_bm_ubitblt(w,h, dx1, dy1, sx1, sy1, src, dest ); -} - -void gr_ubitmap( int x, int y, grs_bitmap *bm ) -{ - int source, dest; - - source = bm->bm_type; - dest = TYPE; - - if (source==BM_LINEAR) { - switch( dest ) - { - case BM_LINEAR: - if ( bm->bm_flags & BM_FLAG_RLE ) - gr_bm_ubitblt00_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap ); - else - gr_ubitmap00( x, y, bm ); - return; -#ifdef OGL - case BM_OGL: - ogl_ubitmapm(x,y,bm); - return; -#endif -#ifdef D1XD3D - case BM_DIRECTX: - Assert ((int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_RENDER || (int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_DISPLAY); - Win32_BlitLinearToDirectX_bm(bm, 0, 0, bm->bm_w, bm->bm_h, x, y, 0); - return; -#endif -#ifdef __MSDOS__ - case BM_SVGA: - if ( bm->bm_flags & BM_FLAG_RLE ) - gr_bm_ubitblt0x_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap ); - else - gr_vesa_bitmap( bm, &grd_curcanv->cv_bitmap, x, y ); - return; - case BM_MODEX: - gr_bm_ubitblt01(bm->bm_w, bm->bm_h, x+XOFFSET, y+YOFFSET, 0, 0, bm, &grd_curcanv->cv_bitmap); - return; -#endif -#if defined(POLY_ACC) - case BM_LINEAR15: - if ( bm->bm_flags & BM_FLAG_RLE ) - gr_bm_ubitblt05_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap ); - else - gr_ubitmap05( x, y, bm); - return; - -#endif - default: - gr_ubitmap012( x, y, bm ); - return; - } - } else { - gr_ubitmapGENERIC(x, y, bm); - } -} - - -void gr_ubitmapm( int x, int y, grs_bitmap *bm ) -{ - int source, dest; - - source = bm->bm_type; - dest = TYPE; - - Assert(x+bm->bm_w <= grd_curcanv->cv_w); - Assert(y+bm->bm_h <= grd_curcanv->cv_h); - -#ifdef _3DFX - _3dfx_Blit( x, y, bm ); - if ( _3dfx_skip_ddraw ) - return; -#endif - - if (source==BM_LINEAR) { - switch( dest ) - { - case BM_LINEAR: - if ( bm->bm_flags & BM_FLAG_RLE ) - gr_bm_ubitblt00m_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap ); - else - gr_ubitmap00m( x, y, bm ); - return; -#ifdef OGL - case BM_OGL: - ogl_ubitmapm(x,y,bm); - return; -#endif -#ifdef D1XD3D - case BM_DIRECTX: - if (bm->bm_w < 35 && bm->bm_h < 35) { - // ugly hack needed for reticle - if ( bm->bm_flags & BM_FLAG_RLE ) - gr_bm_ubitblt0x_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap, 1 ); - else - gr_ubitmapGENERICm(x, y, bm); - return; - } - Assert ((int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_RENDER || (int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_DISPLAY); - Win32_BlitLinearToDirectX_bm(bm, 0, 0, bm->bm_w, bm->bm_h, x, y, 1); - return; -#endif -#ifdef __MSDOS__ - case BM_SVGA: - if (bm->bm_flags & BM_FLAG_RLE) - gr_bm_ubitblt02m_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap); - //gr_bm_ubitblt0xm_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap); - else - gr_bm_ubitblt02m(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap); - //gr_ubitmapGENERICm(x, y, bm); - return; - case BM_MODEX: - gr_bm_ubitblt01m(bm->bm_w, bm->bm_h, x+XOFFSET, y+YOFFSET, 0, 0, bm, &grd_curcanv->cv_bitmap); - return; -#endif -#if defined(POLY_ACC) - case BM_LINEAR15: - if ( bm->bm_flags & BM_FLAG_RLE ) - gr_bm_ubitblt05m_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap ); - else - gr_ubitmap05m( x, y, bm ); - return; -#endif - - default: - gr_ubitmap012m( x, y, bm ); - return; - } - } else { - gr_ubitmapGENERICm(x, y, bm); - } -} - - -void gr_bitmapm( int x, int y, grs_bitmap *bm ) -{ - int dx1=x, dx2=x+bm->bm_w-1; - int dy1=y, dy2=y+bm->bm_h-1; - int sx=0, sy=0; - - if ((dx1 >= grd_curcanv->cv_bitmap.bm_w ) || (dx2 < 0)) return; - if ((dy1 >= grd_curcanv->cv_bitmap.bm_h) || (dy2 < 0)) return; - if ( dx1 < 0 ) { sx = -dx1; dx1 = 0; } - if ( dy1 < 0 ) { sy = -dy1; dy1 = 0; } - if ( dx2 >= grd_curcanv->cv_bitmap.bm_w ) { dx2 = grd_curcanv->cv_bitmap.bm_w-1; } - if ( dy2 >= grd_curcanv->cv_bitmap.bm_h ) { dy2 = grd_curcanv->cv_bitmap.bm_h-1; } - - // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2) - - if ( (bm->bm_type == BM_LINEAR) && (grd_curcanv->cv_bitmap.bm_type == BM_LINEAR )) - { - if ( bm->bm_flags & BM_FLAG_RLE ) - gr_bm_ubitblt00m_rle(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); - else - gr_bm_ubitblt00m(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); - return; - } -#ifdef __MSDOS__ - else if ( (bm->bm_type == BM_LINEAR) && (grd_curcanv->cv_bitmap.bm_type == BM_SVGA )) - { - gr_bm_ubitblt02m(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); - return; - } -#endif - - gr_bm_ubitbltm(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); - -} - -void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) -{ - register int x1, y1; - ubyte c; - -#ifdef OGL - if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_OGL )) - { - ogl_ubitblt(w, h, dx, dy, sx, sy, src, dest); - return; - } - if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_LINEAR )) - { - ogl_ubitblt_tolinear(w, h, dx, dy, sx, sy, src, dest); - return; - } - if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_OGL )) - { - ogl_ubitblt_copy(w, h, dx, dy, sx, sy, src, dest); - return; - } -#endif -#ifdef D1XD3D - if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_DIRECTX )) - { - Assert ((int)dest->bm_data == BM_D3D_RENDER || (int)dest->bm_data == BM_D3D_DISPLAY); - Win32_BlitLinearToDirectX_bm (src, sx, sy, w, h, dx, dy, 1); - return; - } - if ( (src->bm_type == BM_DIRECTX) && (dest->bm_type == BM_DIRECTX )) - { - Assert ((int)src->bm_data == BM_D3D_RENDER || (int)src->bm_data == BM_D3D_DISPLAY); - //Win32_BlitDirectXToDirectX (w, h, dx, dy, sx, sy, src->bm_data, dest->bm_data, 0); - return; - } -#endif -#if defined(POLY_ACC) - if(src->bm_type == BM_LINEAR && dest->bm_type == BM_LINEAR15) - { - ubyte *s; - ushort *d; - ushort u; - int smod, dmod; - - pa_flush(); - s = (ubyte *)(src->bm_data + src->bm_rowsize * sy + sx); - smod = src->bm_rowsize - w; - d = (ushort *)(dest->bm_data + dest->bm_rowsize * dy + dx * PA_BPP); - dmod = dest->bm_rowsize / PA_BPP - w; - for (; h--;) { - for (x1=w; x1--; ) { - if ((u = *s) != TRANSPARENCY_COLOR) - *d = pa_clut[u]; - ++s; - ++d; - } - s += smod; - d += dmod; - } - } - - if(src->bm_type == BM_LINEAR15) - { - Assert(src->bm_type == dest->bm_type); // I don't support 15 to 8 yet. - pa_blit_transparent(dest, dx, dy, src, sx, sy, w, h); - return; - } -#endif - - for (y1=0; y1 < h; y1++ ) { - for (x1=0; x1 < w; x1++ ) { - if ((c=gr_gpixel(src,sx+x1,sy+y1))!=TRANSPARENCY_COLOR) - gr_bm_pixel( dest, dx+x1, dy+y1,c ); - } - } -} - - // rescalling bitmaps, 10/14/99 Jan Bobrowski jb@wizard.ae.krakow.pl inline void scale_line(byte *in, byte *out, int ilen, int olen) @@ -2126,7 +911,7 @@ inline void scale_line(byte *in, byte *out, int ilen, int olen) goto inside; } while(--i>=0) { - inside: +inside: *out++ = *in; } in++; @@ -2149,7 +934,7 @@ void gr_bitmap_scale_to(grs_bitmap *src, grs_bitmap *dst) goto inside; } while(--i>=0) { - inside: +inside: scale_line(s, d, src->bm_w, dst->bm_w); d += dst->bm_rowsize; } diff --git a/2d/bitmap.c b/2d/bitmap.c index 94660cb9..92ec8a63 100644 --- a/2d/bitmap.c +++ b/2d/bitmap.c @@ -1,4 +1,3 @@ -/* $Id: bitmap.c,v 1.5 2002-10-10 19:11:23 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,104 +7,10 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Graphical routines for manipulating grs_bitmaps. - * - * Old Log: - * Revision 1.11 1995/08/23 18:46:06 allender - * fixed compiler warning - * - * Revision 1.10 1995/08/14 14:25:45 allender - * changed transparency color to 0 - * - * Revision 1.9 1995/07/05 16:04:51 allender - * transparency/game kitchen changes - * - * Revision 1.8 1995/06/15 09:50:48 allender - * new malloc to align bitmap on 8 byte bountry - * - * Revision 1.7 1995/05/12 11:52:19 allender - * changed memory stuff again - * - * Revision 1.6 1995/05/11 12:48:34 allender - * nge transparency color - * - * Revision 1.5 1995/05/04 19:59:21 allender - * use NewPtr instead of malloc - * - * Revision 1.4 1995/04/27 07:33:04 allender - * rearrange functions - * - * Revision 1.3 1995/04/19 14:37:17 allender - * removed dead asm code - * - * Revision 1.2 1995/04/18 12:04:51 allender - * *** empty log message *** - * - * Revision 1.1 1995/03/09 08:48:06 allender - * Initial revision - * - * - * ------- PC version RCS information - * Revision 1.17 1994/11/18 22:50:25 john - * Changed shorts to ints in parameters. - * - * Revision 1.16 1994/11/10 15:59:46 john - * Fixed bugs with canvas's being created with bogus bm_flags. - * - * Revision 1.15 1994/10/26 23:55:53 john - * Took out roller; Took out inverse table. - * - * Revision 1.14 1994/09/19 14:40:21 john - * Changed dpmi stuff. - * - * Revision 1.13 1994/09/19 11:44:04 john - * Changed call to allocate selector to the dpmi module. - * - * Revision 1.12 1994/06/09 13:14:57 john - * Made selectors zero our - * out, I meant. - * - * Revision 1.11 1994/05/06 12:50:07 john - * Added supertransparency; neatend things up; took out warnings. - * - * Revision 1.10 1994/04/08 16:59:39 john - * Add fading poly's; Made palette fade 32 instead of 16. - * - * Revision 1.9 1994/03/16 17:21:09 john - * Added slow palette searching options. - * - * Revision 1.8 1994/03/14 17:59:35 john - * Added function to check bitmap's transparency. - * - * Revision 1.7 1994/03/14 17:16:21 john - * fixed bug with counting freq of pixels. - * - * Revision 1.6 1994/03/14 16:55:47 john - * Changed grs_bitmap structure to include bm_flags. - * - * Revision 1.5 1994/02/18 15:32:22 john - * *** empty log message *** - * - * Revision 1.4 1993/10/15 16:22:49 john - * *** empty log message *** - * - * Revision 1.3 1993/09/08 17:37:11 john - * Checking for errors with Yuan... - * - * Revision 1.2 1993/09/08 14:46:27 john - * looking for possible bugs... - * - * Revision 1.1 1993/09/08 11:43:05 john - * Initial revision - * - */ - #ifdef HAVE_CONFIG_H #include #endif @@ -119,16 +24,15 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gr.h" #include "grdef.h" #include "u_dpmi.h" +#include "bitmap.h" #include "error.h" -#if defined(POLY_ACC) -#include "poly_acc.h" -#endif - #ifdef OGL #include "ogl_init.h" #endif +void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq ); + void gr_set_bitmap_data (grs_bitmap *bm, unsigned char *data) { #ifdef OGL @@ -142,59 +46,6 @@ void gr_set_bitmap_data (grs_bitmap *bm, unsigned char *data) #endif } -grs_bitmap *gr_create_bitmap(int w, int h ) -{ - return gr_create_bitmap_raw (w, h, d_malloc(w * h)); -} - -grs_bitmap *gr_create_bitmap_raw(int w, int h, unsigned char * raw_data ) -{ - grs_bitmap *new; - - new = (grs_bitmap *)d_malloc( sizeof(grs_bitmap) ); - gr_init_bitmap (new, 0, 0, 0, w, h, w, raw_data); - - return new; -} - - -#if defined(POLY_ACC) -// -// Creates a bitmap of the requested size and type. -// w, and h are in pixels. -// type is a BM_... and is used to set the rowsize. -// if data is NULL, memory is allocated, otherwise data is used for bm_data. -// -// This function is used only by the polygon accelerator code to handle the mixture of 15bit and -// 8bit bitmaps. -// -grs_bitmap *gr_create_bitmap2(int w, int h, int type, void *data ) -{ - grs_bitmap *new; - - new = (grs_bitmap *)malloc( sizeof(grs_bitmap) ); - new->bm_x = 0; - new->bm_y = 0; - new->bm_w = w; - new->bm_h = h; - new->bm_flags = 0; - new->bm_type = type; - switch(type) - { - case BM_LINEAR: new->bm_rowsize = w; break; - case BM_LINEAR15: new->bm_rowsize = w*PA_BPP; break; - default: Int3(); // unsupported type. - } - if(data) - new->bm_data = data; - else - new->bm_data = malloc(new->bm_rowsize * new->bm_h); - new->bm_handle = 0; - - return new; -} -#endif - void gr_init_bitmap( grs_bitmap *bm, int mode, int x, int y, int w, int h, int bytesperline, unsigned char * data ) // TODO: virtualize { #ifdef D1XD3D @@ -254,16 +105,6 @@ void gr_init_bitmap_data (grs_bitmap *bm) // TODO: virtulize #endif } -grs_bitmap *gr_create_sub_bitmap(grs_bitmap *bm, int x, int y, int w, int h ) -{ - grs_bitmap *new; - - new = (grs_bitmap *)d_malloc( sizeof(grs_bitmap) ); - gr_init_sub_bitmap (new, bm, x, y, w, h); - - return new; -} - void gr_free_bitmap(grs_bitmap *bm ) { gr_free_bitmap_data (bm); @@ -271,18 +112,6 @@ void gr_free_bitmap(grs_bitmap *bm ) d_free(bm); } -void gr_free_sub_bitmap(grs_bitmap *bm ) -{ - if (bm!=NULL) - { -#ifdef D1XD3D - bm->iMagic = 0; -#endif - d_free(bm); - } -} - - void gr_free_bitmap_data (grs_bitmap *bm) // TODO: virtulize { #ifdef D1XD3D @@ -331,77 +160,43 @@ void gr_init_sub_bitmap (grs_bitmap *bm, grs_bitmap *bmParent, int x, int y, int } -void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count ); - -#if !defined(NO_ASM) && defined(__WATCOMC__) - -#pragma aux decode_data_asm parm [esi] [ecx] [edi] [ebx] modify exact [esi edi eax ebx ecx] = \ -"again_ddn:" \ - "xor eax,eax" \ - "mov al,[esi]" \ - "inc dword ptr [ebx+eax*4]" \ - "mov al,[edi+eax]" \ - "mov [esi],al" \ - "inc esi" \ - "dec ecx" \ - "jne again_ddn" - -#elif !defined(NO_ASM) && defined(__GNUC__) - -inline void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count ) { - int dummy[4]; - __asm__ __volatile__ ( - "xorl %%eax,%%eax;" -"0:;" - "movb (%%esi), %%al;" - "incl (%%ebx, %%eax, 4);" - "movb (%%edi, %%eax), %%al;" - "movb %%al, (%%esi);" - "incl %%esi;" - "decl %%ecx;" - "jne 0b" - : "=S" (dummy[0]), "=c" (dummy[1]), "=D" (dummy[2]), "=b" (dummy[3]) - : "0" (data), "1" (num_pixels), "2" (colormap), "3" (count) - : "%eax"); +void gr_free_sub_bitmap(grs_bitmap *bm ) +{ + if (bm!=NULL) + { +#ifdef D1XD3D + bm->iMagic = 0; +#endif + d_free(bm); + } } -#elif !defined(NO_ASM) && defined(_MSC_VER) -__inline void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count ) +grs_bitmap *gr_create_bitmap(int w, int h ) { - __asm { - mov esi,[data] - mov ecx,[num_pixels] - mov edi,[colormap] - mov ebx,[count] -again_ddn: - xor eax,eax - mov al,[esi] - inc dword ptr [ebx+eax*4] - mov al,[edi+eax] - mov [esi],al - inc esi - dec ecx - jne again_ddn - } + return gr_create_bitmap_raw (w, h, d_malloc(w * h)); } -#else // NO_ASM or unknown compiler - -void decode_data_asm(ubyte *data, int num_pixels, ubyte *colormap, int *count) +grs_bitmap *gr_create_bitmap_raw(int w, int h, unsigned char * raw_data ) { - int i; - ubyte mapped; - - for (i = 0; i < num_pixels; i++) { - count[*data]++; - mapped = *data; - *data = colormap[mapped]; - data++; - } + grs_bitmap *new; + + new = (grs_bitmap *)d_malloc( sizeof(grs_bitmap) ); + gr_init_bitmap (new, 0, 0, 0, w, h, w, raw_data); + + return new; } -#endif + +grs_bitmap *gr_create_sub_bitmap(grs_bitmap *bm, int x, int y, int w, int h ) +{ + grs_bitmap *new; + + new = (grs_bitmap *)d_malloc( sizeof(grs_bitmap) ); + gr_init_sub_bitmap (new, bm, x, y, w, h); + + return new; +} void gr_set_bitmap_flags (grs_bitmap *pbm, int flags) { @@ -443,27 +238,11 @@ void gr_set_super_transparent (grs_bitmap *pbm, int bTransparent) } } -void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq ) -{ - int i, r, g, b; - - for (i=0; i<256; i++ ) { - r = *palette++; - g = *palette++; - b = *palette++; - *colormap++ = gr_find_closest_color( r, g, b ); - *freq++ = 0; - } -} - void gr_remap_bitmap( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color ) { ubyte colormap[256]; int freq[256]; - if (bmp->bm_type != BM_LINEAR) - return; //can't do it - // This should be build_colormap_asm, but we're not using invert table, so... build_colormap_good( palette, colormap, freq ); @@ -471,7 +250,7 @@ void gr_remap_bitmap( grs_bitmap * bmp, ubyte * palette, int transparent_color, colormap[super_transparent_color] = 254; if ( (transparent_color>=0) && (transparent_color<=255)) - colormap[transparent_color] = TRANSPARENCY_COLOR; + colormap[transparent_color] = 255; decode_data_asm(bmp->bm_data, bmp->bm_w * bmp->bm_h, colormap, freq ); @@ -482,26 +261,34 @@ void gr_remap_bitmap( grs_bitmap * bmp, ubyte * palette, int transparent_color, gr_set_super_transparent (bmp, 0); } +void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq ) +{ + int i, r, g, b; + + for (i=0; i<256; i++ ) { + r = *palette++; + g = *palette++; + b = *palette++; + *colormap++ = gr_find_closest_color( r, g, b ); + *freq++ = 0; + } +} + + void gr_remap_bitmap_good( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color ) { ubyte colormap[256]; int freq[256]; + build_colormap_good( palette, colormap, freq ); if ( (super_transparent_color>=0) && (super_transparent_color<=255)) colormap[super_transparent_color] = 254; if ( (transparent_color>=0) && (transparent_color<=255)) - colormap[transparent_color] = TRANSPARENCY_COLOR; - - if (bmp->bm_w == bmp->bm_rowsize) - decode_data_asm(bmp->bm_data, bmp->bm_w * bmp->bm_h, colormap, freq ); - else { - int y; - ubyte *p = bmp->bm_data; - for (y=0;ybm_h;y++,p+=bmp->bm_rowsize) - decode_data_asm(p, bmp->bm_w, colormap, freq ); - } + colormap[transparent_color] = 255; + + decode_data_asm(bmp->bm_data, bmp->bm_w * bmp->bm_h, colormap, freq ); if ( (transparent_color>=0) && (transparent_color<=255) && (freq[transparent_color]>0) ) gr_set_transparent (bmp, 1); @@ -527,10 +314,10 @@ void gr_bitmap_check_transparency( grs_bitmap * bmp ) ubyte * data; data = bmp->bm_data; - + for (y=0; ybm_h; y++ ) { for (x=0; xbm_w; x++ ) { - if (*data++ == TRANSPARENCY_COLOR ) { + if (*data++ == 255 ) { gr_set_transparent (bmp, 1); return; } diff --git a/2d/bitmap.h b/2d/bitmap.h index 6d6996fb..736ec581 100644 --- a/2d/bitmap.h +++ b/2d/bitmap.h @@ -1,8 +1,72 @@ -/* $Id: bitmap.h,v 1.4 2002-09-05 07:55:20 btb Exp $ */ #ifndef _BITMAP_H #define _BITMAP_H -void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq ); +#ifndef NO_ASM +#ifdef __WATCOMC__ void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count ); +#pragma aux decode_data_asm parm [esi] [ecx] [edi] [ebx] modify exact [esi edi eax ebx ecx] = \ +"again_ddn:" \ + "xor eax,eax" \ + "mov al,[esi]" \ + "inc dword ptr [ebx+eax*4]" \ + "mov al,[edi+eax]" \ + "mov [esi],al" \ + "inc esi" \ + "dec ecx" \ + "jne again_ddn" +#elif defined __GNUC__ +static inline void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count ) { + int dummy[4]; + __asm__ __volatile__ ( + "xorl %%eax,%%eax;" +"0:;" + "movb (%%esi), %%al;" + "incl (%%ebx, %%eax, 4);" + "movb (%%edi, %%eax), %%al;" + "movb %%al, (%%esi);" + "incl %%esi;" + "decl %%ecx;" + "jne 0b" + : "=S" (dummy[0]), "=c" (dummy[1]), "=D" (dummy[2]), "=b" (dummy[3]) + : "0" (data), "1" (num_pixels), "2" (colormap), "3" (count) + : "%eax"); +} +#elif defined _MSC_VER +__inline void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count ) +{ + __asm { + mov esi,[data] + mov ecx,[num_pixels] + mov edi,[colormap] + mov ebx,[count] +again_ddn: + xor eax,eax + mov al,[esi] + inc dword ptr [ebx+eax*4] + mov al,[edi+eax] + mov [esi],al + inc esi + dec ecx + jne again_ddn + } +} +#else +#define NO_ASM 1 // We really do want no assembler... +#endif +#endif +#ifdef NO_ASM +static void decode_data_asm(ubyte *data, int num_pixels, ubyte *colormap, int *count) +{ + int i; + ubyte mapped; + + for (i = 0; i < num_pixels; i++) { + count[*data]++; + mapped = *data; + *data = colormap[mapped]; + data++; + } +} +#endif #endif diff --git a/2d/box.c b/2d/box.c index 7fddb419..a091c780 100644 --- a/2d/box.c +++ b/2d/box.c @@ -1,4 +1,3 @@ -/* $Id: box.c,v 1.4 2002-07-17 21:55:19 bradleyb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO diff --git a/2d/canvas.c b/2d/canvas.c index 9b40656b..7a6aabf3 100644 --- a/2d/canvas.c +++ b/2d/canvas.c @@ -1,4 +1,3 @@ -/* $Id: canvas.c,v 1.5 2002-07-17 21:55:19 bradleyb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO diff --git a/2d/circle.c b/2d/circle.c index cd7f59d0..42b7ff23 100644 --- a/2d/circle.c +++ b/2d/circle.c @@ -1,4 +1,3 @@ -/* $Id: circle.c,v 1.4 2002-10-10 18:55:32 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,7 +16,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: circle.c,v 1.4 2002-10-10 18:55:32 btb Exp $"; +static char rcsid[] = "$Id: circle.c,v 1.2 2001-01-31 15:17:47 bradleyb Exp $"; #endif #include "u_mem.h" @@ -52,9 +51,9 @@ int gr_circle(fix xc1,fix yc1,fix r1) gr_pixel( xc-y, yc+x ); gr_pixel( xc+y, yc+x ); - if (p<0) + if (p<0) p=p+(x<<2)+6; - else { + else { // Draw the second octant gr_pixel( xc-x, yc-y ); gr_pixel( xc+x, yc-y ); @@ -65,7 +64,7 @@ int gr_circle(fix xc1,fix yc1,fix r1) } x++; } - if(x==y) { + if(x==y) { gr_pixel( xc-x, yc-y ); gr_pixel( xc+x, yc-y ); gr_pixel( xc-x, yc+y ); @@ -93,9 +92,9 @@ int gr_ucircle(fix xc1,fix yc1,fix r1) gr_upixel( xc-y, yc+x ); gr_upixel( xc+y, yc+x ); - if (p<0) + if (p<0) p=p+(x<<2)+6; - else { + else { // Draw the second octant gr_upixel( xc-x, yc-y ); gr_upixel( xc+x, yc-y ); @@ -106,7 +105,7 @@ int gr_ucircle(fix xc1,fix yc1,fix r1) } x++; } - if(x==y) { + if(x==y) { gr_upixel( xc-x, yc-y ); gr_upixel( xc+x, yc-y ); gr_upixel( xc-x, yc+y ); diff --git a/2d/clip.h b/2d/clip.h index 59919aa8..b4bd2f1f 100644 --- a/2d/clip.h +++ b/2d/clip.h @@ -1,4 +1,3 @@ -/* $Id: clip.h,v 1.3 2002-10-10 18:55:32 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,46 +7,52 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/2d/clip.h,v $ + * $Revision: 1.1.1.1 $ + * $Author: bradleyb $ + * $Date: 2001-01-19 03:29:57 $ * * Macros used for clipping * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 1999/06/14 21:57:39 donut + * Import of d1x 1.37 source. * * Revision 1.3 1993/10/15 16:22:28 john * *** empty log message *** - * + * * Revision 1.2 1993/09/29 16:14:31 john * made work with fix point - * + * * Revision 1.1 1993/09/08 11:40:53 john * Initial revision - * + * * */ -/*#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +/*#define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) */ #define IABS(x) (((x) < 0) ? -(x) : (x)) #define EXCHG(a,b) do { \ - int __temp__ = (a); \ - (a) = (b); \ - (b) = __temp__; \ + int __temp__ = (a); \ + (a) = (b); \ + (b) = __temp__; \ } while(0) // sort two values #define SORT2(a,b) do { \ - if((a) > (b)) EXCHG(a,b); \ + if((a) > (b)) EXCHG(a,b); \ } while(0) # define SCALE(var,arg,num,den) \ - ((var) = ((arg) * (num)) / (den)) + ((var) = ((arg) * (num)) / (den)) # define USCALE(var,arg,num,den) \ ((var) = ((unsigned)(arg) * (unsigned)(num)) / (unsigned)(den)) @@ -55,99 +60,99 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. # define FSCALE(var,arg,num,den) ((var) = fixmuldiv((arg),(num),(den))) #define CLIPDOT(xx,yy,WHEN_OUTSIDE,WHEN_CLIPPED) { \ - if((xx > XMAX) || (xx < XMIN)) { WHEN_OUTSIDE; } \ - if((yy > YMAX) || (yy < YMIN)) { WHEN_OUTSIDE; } \ + if((xx > XMAX) || (xx < XMIN)) { WHEN_OUTSIDE; } \ + if((yy > YMAX) || (yy < YMIN)) { WHEN_OUTSIDE; } \ } #define CLIPHLINE(x1,x2,yy,WHEN_OUTSIDE,WHEN_CLIPPED) { \ - if(x1 > x2) EXCHG(x1,x2); \ - if((x1 > XMAX) || (x2 < XMIN)) { WHEN_OUTSIDE; } \ - if((yy > YMAX) || (yy < YMIN)) { WHEN_OUTSIDE; } \ - if(x1 < XMIN) { x1 = XMIN; WHEN_CLIPPED; } \ - if(x2 > XMAX) { x2 = XMAX; WHEN_CLIPPED; } \ + if(x1 > x2) EXCHG(x1,x2); \ + if((x1 > XMAX) || (x2 < XMIN)) { WHEN_OUTSIDE; } \ + if((yy > YMAX) || (yy < YMIN)) { WHEN_OUTSIDE; } \ + if(x1 < XMIN) { x1 = XMIN; WHEN_CLIPPED; } \ + if(x2 > XMAX) { x2 = XMAX; WHEN_CLIPPED; } \ } #define CLIPVLINE(xx,y1,y2,WHEN_OUTSIDE,WHEN_CLIPPED) { \ - if(y1 > y2) EXCHG(y1,y2); \ - if((xx > XMAX) || (xx < XMIN)) { WHEN_OUTSIDE; } \ - if((y1 > YMAX) || (y2 < YMIN)) { WHEN_OUTSIDE; } \ - if(y1 < YMIN) { y1 = YMIN; WHEN_CLIPPED; } \ - if(y2 > YMAX) { y2 = YMAX; WHEN_CLIPPED; } \ + if(y1 > y2) EXCHG(y1,y2); \ + if((xx > XMAX) || (xx < XMIN)) { WHEN_OUTSIDE; } \ + if((y1 > YMAX) || (y2 < YMIN)) { WHEN_OUTSIDE; } \ + if(y1 < YMIN) { y1 = YMIN; WHEN_CLIPPED; } \ + if(y2 > YMAX) { y2 = YMAX; WHEN_CLIPPED; } \ } #define CLIPBOX(x1,y1,x2,y2,WHEN_OUTSIDE,WHEN_CLIPPED) { \ - if(x1 > x2) EXCHG(x1,x2); \ - if(y1 > y2) EXCHG(y1,y2); \ - if((x1 > XMAX) || (x2 < 0)) { WHEN_OUTSIDE; } \ - if((y1 > YMAX) || (y2 < 0)) { WHEN_OUTSIDE; } \ - if(x1 < 0) { x1 = 0; WHEN_CLIPPED; } \ - if(y1 < 0) { y1 = 0; WHEN_CLIPPED; } \ - if(x2 > XMAX) { x2 = XMAX; WHEN_CLIPPED; } \ - if(y2 > YMAX) { y2 = YMAX; WHEN_CLIPPED; } \ + if(x1 > x2) EXCHG(x1,x2); \ + if(y1 > y2) EXCHG(y1,y2); \ + if((x1 > XMAX) || (x2 < 0)) { WHEN_OUTSIDE; } \ + if((y1 > YMAX) || (y2 < 0)) { WHEN_OUTSIDE; } \ + if(x1 < 0) { x1 = 0; WHEN_CLIPPED; } \ + if(y1 < 0) { y1 = 0; WHEN_CLIPPED; } \ + if(x2 > XMAX) { x2 = XMAX; WHEN_CLIPPED; } \ + if(y2 > YMAX) { y2 = YMAX; WHEN_CLIPPED; } \ } - + #define CLIPLINE(x1,y1,x2,y2,XMIN,YMIN,XMAX,YMAX,WHEN_OUTSIDE,WHEN_CLIPPED,MY_SCALE) do { \ - register int temp; \ - if(y1 > y2) \ - { EXCHG(y1,y2); EXCHG(x1,x2); } \ - if((y2 < YMIN) || (y1 > YMAX)) \ - { WHEN_OUTSIDE; } \ - if(x1 < x2) { \ - if((x2 < XMIN) || (x1 > XMAX)) { \ - WHEN_OUTSIDE; \ - } \ - if(x1 < XMIN) { \ + register int temp; \ + if(y1 > y2) \ + { EXCHG(y1,y2); EXCHG(x1,x2); } \ + if((y2 < YMIN) || (y1 > YMAX)) \ + { WHEN_OUTSIDE; } \ + if(x1 < x2) { \ + if((x2 < XMIN) || (x1 > XMAX)) { \ + WHEN_OUTSIDE; \ + } \ + if(x1 < XMIN) { \ MY_SCALE(temp,(y2 - y1),(XMIN - x1),(x2 - x1)); \ - if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \ - x1 = XMIN; \ - WHEN_CLIPPED; \ - } \ - if(x2 > XMAX) { \ + if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \ + x1 = XMIN; \ + WHEN_CLIPPED; \ + } \ + if(x2 > XMAX) { \ MY_SCALE(temp,(y2 - y1),(x2 - XMAX),(x2 - x1)); \ - if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \ - x2 = XMAX; \ - WHEN_CLIPPED; \ - } \ - if(y1 < YMIN) { \ + if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \ + x2 = XMAX; \ + WHEN_CLIPPED; \ + } \ + if(y1 < YMIN) { \ MY_SCALE(temp,(x2 - x1),(YMIN - y1),(y2 - y1)); \ - x1 += temp; \ - y1 = YMIN; \ - WHEN_CLIPPED; \ - } \ - if(y2 > YMAX) { \ + x1 += temp; \ + y1 = YMIN; \ + WHEN_CLIPPED; \ + } \ + if(y2 > YMAX) { \ MY_SCALE(temp,(x2 - x1),(y2 - YMAX),(y2 - y1)); \ - x2 -= temp; \ - y2 = YMAX; \ - WHEN_CLIPPED; \ - } \ - } \ - else { \ - if((x1 < XMIN) || (x2 > XMAX)) { \ - WHEN_OUTSIDE; \ - } \ - if(x1 > XMAX) { \ + x2 -= temp; \ + y2 = YMAX; \ + WHEN_CLIPPED; \ + } \ + } \ + else { \ + if((x1 < XMIN) || (x2 > XMAX)) { \ + WHEN_OUTSIDE; \ + } \ + if(x1 > XMAX) { \ MY_SCALE(temp,(y2 - y1),(x1 - XMAX),(x1 - x2)); \ - if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \ - x1 = XMAX; \ - WHEN_CLIPPED; \ - } \ - if(x2 < XMIN) { \ + if((y1 += temp) > YMAX) { WHEN_OUTSIDE; } \ + x1 = XMAX; \ + WHEN_CLIPPED; \ + } \ + if(x2 < XMIN) { \ MY_SCALE(temp,(y2 - y1),(XMIN - x2),(x1 - x2)); \ - if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \ - x2 = XMIN; \ - WHEN_CLIPPED; \ - } \ - if(y1 < YMIN) { \ + if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; } \ + x2 = XMIN; \ + WHEN_CLIPPED; \ + } \ + if(y1 < YMIN) { \ MY_SCALE(temp,(x1 - x2),(YMIN - y1),(y2 - y1)); \ - x1 -= temp; \ - y1 = YMIN; \ - WHEN_CLIPPED; \ - } \ - if(y2 > YMAX) { \ + x1 -= temp; \ + y1 = YMIN; \ + WHEN_CLIPPED; \ + } \ + if(y2 > YMAX) { \ MY_SCALE(temp,(x1 - x2),(y2 - YMAX),(y2 - y1)); \ - x2 += temp; \ - y2 = YMAX; \ - WHEN_CLIPPED; \ - } \ - } \ + x2 += temp; \ + y2 = YMAX; \ + WHEN_CLIPPED; \ + } \ + } \ } while(0) diff --git a/2d/disc.c b/2d/disc.c index 6638b3d1..a8582ad4 100644 --- a/2d/disc.c +++ b/2d/disc.c @@ -1,4 +1,3 @@ -/* $Id: disc.c,v 1.4 2002-10-10 18:55:32 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -44,9 +43,9 @@ int gr_disk(fix xc1,fix yc1,fix r1) gr_scanline( xc-y, xc+y, yc-x ); gr_scanline( xc-y, xc+y, yc+x ); - if (p<0) + if (p<0) p=p+(x<<2)+6; - else { + else { // Draw the second octant gr_scanline( xc-x, xc+x, yc-y ); gr_scanline( xc-x, xc+x, yc+y ); @@ -55,7 +54,7 @@ int gr_disk(fix xc1,fix yc1,fix r1) } x++; } - if(x==y) { + if(x==y) { gr_scanline( xc-x, xc+x, yc-y ); gr_scanline( xc-x, xc+x, yc+y ); } @@ -79,9 +78,9 @@ int gr_udisk(fix xc1,fix yc1,fix r1) gr_uscanline( xc-y, xc+y, yc-x ); gr_uscanline( xc-y, xc+y, yc+x ); - if (p<0) + if (p<0) p=p+(x<<2)+6; - else { + else { // Draw the second octant gr_uscanline( xc-x, xc+x, yc-y ); gr_uscanline( xc-x, xc+x, yc+y ); @@ -90,7 +89,7 @@ int gr_udisk(fix xc1,fix yc1,fix r1) } x++; } - if(x==y) { + if(x==y) { gr_uscanline( xc-x, xc+x, yc-y ); gr_uscanline( xc-x, xc+x, yc+y ); } diff --git a/2d/font.c b/2d/font.c index eada64bd..259f012c 100644 --- a/2d/font.c +++ b/2d/font.c @@ -1,4 +1,3 @@ -/* $Id: font.c,v 1.25 2003-03-19 19:21:34 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,14 +7,31 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* +/* $Source: /cvs/cvsroot/d2x/2d/font.c,v $ + * $Revision: 1.10 $ + * $Author: bradleyb $ + * $Date: 2001-11-14 09:34:32 $ * * Graphical routines for drawing fonts. * + * $Log: not supported by cvs2svn $ + * Revision 1.9 2001/11/08 10:37:25 bradleyb + * free OGL font data when rereading + * + * Revision 1.8 2001/11/04 03:58:25 bradleyb + * re-init ogl fonts after remapping colors. + * + * Revision 1.7 2001/11/02 10:46:23 bradleyb + * fixed gr_remap_font, minor stuff + * + * Revision 1.6 2001/11/02 02:03:35 bradleyb + * Enable OpenGL fonts\! + * + * */ #ifdef HAVE_CONFIG_H @@ -54,7 +70,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. typedef struct openfont { char filename[FILENAME_LEN]; grs_font *ptr; - char *dataptr; } openfont; //list of open fonts, for use (for now) for palette remapping @@ -1102,7 +1117,7 @@ int gr_internal_color_string(int x, int y, char *s ) } #else //OGL - +#include "../main/inferno.h" #include "ogl_init.h" #include "args.h" //font handling routines for OpenGL - Added 9/25/99 Matthew Mueller - they are here instead of in arch/ogl because they use all these defines @@ -1338,8 +1353,7 @@ int ogl_internal_string(int x, int y, char *s ) // ogl_ubitblt(FONT->ft_bitmaps[letter].bm_w,FONT->ft_bitmaps[letter].bm_h,xx,yy,0,0,&FONT->ft_bitmaps[letter],NULL); // if (*text_ptr>='0' && *text_ptr<='9'){ if (FFLAGS&FT_COLOR) - //gr_ubitmapm(xx,yy,&FONT->ft_bitmaps[letter]); - gr_bitmapm(xx,yy,&FONT->ft_bitmaps[letter]); // credits need clipping + gr_ubitmapm(xx,yy,&FONT->ft_bitmaps[letter]); else{ if (grd_curcanv->cv_bitmap.bm_type==BM_OGL) ogl_ubitmapm_c(xx,yy,&FONT->ft_bitmaps[letter],FG_COLOR); @@ -1533,20 +1547,16 @@ void gr_close_font( grs_font * font ) if (font) { int fontnum; - char * font_data; //find font in list for (fontnum=0;fontnumft_chars ) d_free( font->ft_chars ); + d_free( font->oldfont ); #ifdef OGL if (font->ft_bitmaps) d_free( font->ft_bitmaps ); @@ -1555,7 +1565,6 @@ void gr_close_font( grs_font * font ) #endif d_free( font ); - } } @@ -1568,51 +1577,44 @@ void gr_remap_color_fonts() grs_font *font; font = open_font[fontnum].ptr; - + if (font && (font->ft_flags & FT_COLOR)) - gr_remap_font(font, open_font[fontnum].filename, open_font[fontnum].dataptr); + gr_remap_font(font,open_font[fontnum].filename); } } -#ifdef FAST_FILE_IO -#define grs_font_read(gf, fp) cfread(gf, GRS_FONT_SIZE, 1, fp) -#else -/* - * reads a grs_font structure from a CFILE - */ -void grs_font_read(grs_font *gf, CFILE *fp) -{ - gf->ft_w = cfile_read_short(fp); - gf->ft_h = cfile_read_short(fp); - gf->ft_flags = cfile_read_short(fp); - gf->ft_baseline = cfile_read_short(fp); - gf->ft_minchar = cfile_read_byte(fp); - gf->ft_maxchar = cfile_read_byte(fp); - gf->ft_bytewidth = cfile_read_short(fp); - gf->ft_data = (ubyte *)cfile_read_int(fp); - gf->ft_chars = (ubyte **)cfile_read_int(fp); - gf->ft_widths = (short *)cfile_read_int(fp); - gf->ft_kerndata = (ubyte *)cfile_read_int(fp); -} +void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq ); +void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count ); +#ifdef __WATCOMC__ +#pragma aux decode_data_asm parm [esi] [ecx] [edi] [ebx] modify exact [esi edi eax ebx ecx] = \ +"again_ddn:" \ + "xor eax,eax" \ + "mov al,[esi]" \ + "inc dword ptr [ebx+eax*4]" \ + "mov al,[edi+eax]" \ + "mov [esi],al" \ + "inc esi" \ + "dec ecx" \ + "jne again_ddn" + #endif grs_font * gr_init_font( char * fontname ) { static int first_time=1; - grs_font *font; - char *font_data; + old_grs_font *font; + grs_font *newfont; int i,fontnum; unsigned char * ptr; int nchars; CFILE *fontfile; - char file_id[4]; - int datasize; //size up to (but not including) palette + u_int32_t file_id; + int32_t datasize; //size up to (but not including) palette if (first_time) { int i; for (i=0;ioldfont=font; - MALLOC(font_data, char, datasize); - cfread(font_data, 1, datasize, fontfile); + open_font[fontnum].ptr = newfont; - open_font[fontnum].ptr = font; - open_font[fontnum].dataptr = font_data; + cfread(font,1,datasize,fontfile); - // make these offsets relative to font_data - font->ft_data = (ubyte *)((int)font->ft_data - GRS_FONT_SIZE); - font->ft_widths = (short *)((int)font->ft_widths - GRS_FONT_SIZE); - font->ft_kerndata = (ubyte *)((int)font->ft_kerndata - GRS_FONT_SIZE); + newfont->ft_flags=swapint(font->ft_flags); + newfont->ft_w=swapshort(font->ft_w); + newfont->ft_h=swapshort(font->ft_h); + newfont->ft_baseline=swapshort(font->ft_baseline); + newfont->ft_maxchar=font->ft_maxchar; + newfont->ft_minchar=font->ft_minchar; + newfont->ft_bytewidth=swapshort(font->ft_bytewidth); - nchars = font->ft_maxchar - font->ft_minchar + 1; + nchars = newfont->ft_maxchar-newfont->ft_minchar+1; - if (font->ft_flags & FT_PROPORTIONAL) { + if (newfont->ft_flags & FT_PROPORTIONAL) { - font->ft_widths = (short *) &font_data[(int)font->ft_widths]; - font->ft_data = &font_data[(int)font->ft_data]; - font->ft_chars = (unsigned char **)d_malloc( nchars * sizeof(unsigned char *)); + newfont->ft_widths = (short *) (swapint(font->ft_widths) + ((ubyte *) font)); + newfont->ft_data = (swapint(font->ft_data)) + ((ubyte *) font); + newfont->ft_chars = (unsigned char **)d_malloc( nchars * sizeof(unsigned char *)); - ptr = font->ft_data; + ptr = newfont->ft_data; for (i=0; i< nchars; i++ ) { - font->ft_widths[i] = INTEL_SHORT(font->ft_widths[i]); - font->ft_chars[i] = ptr; - if (font->ft_flags & FT_COLOR) - ptr += font->ft_widths[i] * font->ft_h; + newfont->ft_chars[i] = ptr; + if (newfont->ft_flags & FT_COLOR) + ptr += newfont->ft_widths[i] * newfont->ft_h; else - ptr += BITS_TO_BYTES(font->ft_widths[i]) * font->ft_h; + ptr += BITS_TO_BYTES(newfont->ft_widths[i]) * newfont->ft_h; } } else { - font->ft_data = font_data; - font->ft_chars = NULL; - font->ft_widths = NULL; + newfont->ft_data = ((unsigned char *) font) + sizeof(*font); + newfont->ft_chars = NULL; + newfont->ft_widths = NULL; - ptr = font->ft_data + (nchars * font->ft_w * font->ft_h); + ptr = newfont->ft_data + (nchars * newfont->ft_w * newfont->ft_h); } - if (font->ft_flags & FT_KERNED) - font->ft_kerndata = &font_data[(int)font->ft_kerndata]; + if (newfont->ft_flags & FT_KERNED) + newfont->ft_kerndata = swapint(font->ft_kerndata) + ((ubyte *) font); - if (font->ft_flags & FT_COLOR) { //remap palette + if (newfont->ft_flags & FT_COLOR) { //remap palette ubyte palette[256*3]; ubyte colormap[256]; int freq[256]; cfread(palette,3,256,fontfile); //read the palette -#ifdef SWAP_0_255 // swap the first and last palette entries (black and white) +#ifdef MACINTOSH // swap the first and last palette entries (black and white) { int i; ubyte c; @@ -1703,11 +1703,11 @@ grs_font * gr_init_font( char * fontname ) // we also need to swap the data entries as well. black is white and white is black - for (i = 0; i < ptr-font->ft_data; i++) { - if (font->ft_data[i] == 0) - font->ft_data[i] = 255; - else if (font->ft_data[i] == 255) - font->ft_data[i] = 0; + for (i = 0; i < ptr-newfont->ft_data; i++) { + if (newfont->ft_data[i] == 0) + newfont->ft_data[i] = 255; + else if (newfont->ft_data[i] == 255) + newfont->ft_data[i] = 0; } } @@ -1715,17 +1715,20 @@ grs_font * gr_init_font( char * fontname ) build_colormap_good( (ubyte *)&palette, colormap, freq ); - colormap[TRANSPARENCY_COLOR] = TRANSPARENCY_COLOR; // changed from colormap[255] = 255 to this for macintosh + colormap[TRANSPARENCY_COLOR] = TRANSPARENCY_COLOR; // chaged from colormap[255] = 255 to this for macintosh - decode_data_asm(font->ft_data, ptr - font->ft_data, colormap, freq ); + decode_data_asm(newfont->ft_data, ptr-newfont->ft_data, colormap, freq ); } cfclose(fontfile); +// memcpy(newfont,font,(ubyte*)&newfont->oldfont-(ubyte*)newfont);//fill in newfont data from oldfont struct +// mprintf((0,"%i %i %i\n",sizeof(grs_font),sizeof(old_grs_font),(ubyte*)&newfont->oldfont-(ubyte*)newfont)); + //set curcanv vars - FONT = font; + FONT = newfont; FG_COLOR = 0; BG_COLOR = 0; @@ -1737,22 +1740,22 @@ grs_font * gr_init_font( char * fontname ) } #ifdef OGL - ogl_init_font(font); + ogl_init_font(newfont); #endif - return font; + return newfont; } //remap a font by re-reading its data & palette -void gr_remap_font( grs_font *font, char * fontname, char *font_data ) +void gr_remap_font( grs_font *font, char * fontname ) { int i; int nchars; CFILE *fontfile; - char file_id[4]; - int datasize; //size up to (but not including) palette - unsigned char *ptr; + u_int32_t file_id; + int32_t datasize; //size up to (but not including) palette + int data_len; if (! (font->ft_flags & FT_COLOR)) return; @@ -1762,62 +1765,40 @@ void gr_remap_font( grs_font *font, char * fontname, char *font_data ) if (!fontfile) Error( "Can't open font file %s", fontname ); - cfread(file_id, 4, 1, fontfile); - if ( !strncmp( file_id, "NFSP", 4 ) ) - Error( "File %s is not a font file", fontname ); - + file_id = cfile_read_int(fontfile); datasize = cfile_read_int(fontfile); - datasize -= GRS_FONT_SIZE; // subtract the size of the header. - d_free(font->ft_chars); - grs_font_read(font, fontfile); // have to reread in case mission hogfile overrides font. - - cfread(font_data, 1, datasize, fontfile); //read raw data - - // make these offsets relative to font_data - font->ft_data = (ubyte *)((int)font->ft_data - GRS_FONT_SIZE); - font->ft_widths = (short *)((int)font->ft_widths - GRS_FONT_SIZE); - font->ft_kerndata = (ubyte *)((int)font->ft_kerndata - GRS_FONT_SIZE); + if (file_id != MAKE_SIG('N','F','S','P')) + Error( "File %s is not a font file", fontname ); - nchars = font->ft_maxchar - font->ft_minchar + 1; + nchars = font->ft_maxchar-font->ft_minchar+1; + //compute data length + data_len = 0; if (font->ft_flags & FT_PROPORTIONAL) { - font->ft_widths = (short *) &font_data[(int)font->ft_widths]; - font->ft_data = &font_data[(int)font->ft_data]; - font->ft_chars = (unsigned char **)d_malloc( nchars * sizeof(unsigned char *)); - - ptr = font->ft_data; - for (i=0; i< nchars; i++ ) { - font->ft_widths[i] = INTEL_SHORT(font->ft_widths[i]); - font->ft_chars[i] = ptr; if (font->ft_flags & FT_COLOR) - ptr += font->ft_widths[i] * font->ft_h; + data_len += font->ft_widths[i] * font->ft_h; else - ptr += BITS_TO_BYTES(font->ft_widths[i]) * font->ft_h; + data_len += BITS_TO_BYTES(font->ft_widths[i]) * font->ft_h; } - } else { - - font->ft_data = font_data; - font->ft_chars = NULL; - font->ft_widths = NULL; + } else + data_len = nchars * font->ft_w * font->ft_h; - ptr = font->ft_data + (nchars * font->ft_w * font->ft_h); - } - - if (font->ft_flags & FT_KERNED) - font->ft_kerndata = &font_data[(int)font->ft_kerndata]; + cfread(font->oldfont, 1, datasize, fontfile); //read raw data if (font->ft_flags & FT_COLOR) { //remap palette ubyte palette[256*3]; ubyte colormap[256]; int freq[256]; + cfseek(fontfile,-sizeof(palette),SEEK_END); + cfread(palette,3,256,fontfile); //read the palette -#ifdef SWAP_0_255 // swap the first and last palette entries (black and white) +#ifdef MACINTOSH // swap the first and last palette entries (black and white) { int i; ubyte c; @@ -1830,7 +1811,7 @@ void gr_remap_font( grs_font *font, char * fontname, char *font_data ) // we also need to swap the data entries as well. black is white and white is black - for (i = 0; i < ptr-font->ft_data; i++) { + for (i = 0; i < data_len; i++) { if (font->ft_data[i] == 0) font->ft_data[i] = 255; else if (font->ft_data[i] == 255) @@ -1842,9 +1823,9 @@ void gr_remap_font( grs_font *font, char * fontname, char *font_data ) build_colormap_good( (ubyte *)&palette, colormap, freq ); - colormap[TRANSPARENCY_COLOR] = TRANSPARENCY_COLOR; // changed from colormap[255] = 255 to this for macintosh + colormap[TRANSPARENCY_COLOR] = TRANSPARENCY_COLOR; // changed from colormap[255] = 255; - decode_data_asm(font->ft_data, ptr - font->ft_data, colormap, freq ); + decode_data_asm(font->ft_data, data_len, colormap, freq ); } diff --git a/2d/gpixel.c b/2d/gpixel.c index 92e37aa5..d8fb3948 100644 --- a/2d/gpixel.c +++ b/2d/gpixel.c @@ -1,4 +1,3 @@ -/* $Id: gpixel.c,v 1.5 2002-10-10 18:55:32 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -34,7 +33,7 @@ unsigned char gr_ugpixel( grs_bitmap * bitmap, int x, int y ) #endif return bitmap->bm_data[ bitmap->bm_rowsize*y + x ]; #ifdef __DJGPP__ - case BM_MODEX: + case BM_MODEX: x += bitmap->bm_x; y += bitmap->bm_y; gr_modex_setplane( x & 3 ); @@ -61,7 +60,7 @@ unsigned char gr_gpixel( grs_bitmap * bitmap, int x, int y ) #endif return bitmap->bm_data[ bitmap->bm_rowsize*y + x ]; #ifdef __DJGPP__ - case BM_MODEX: + case BM_MODEX: x += bitmap->bm_x; y += bitmap->bm_y; gr_modex_setplane( x & 3 ); @@ -77,3 +76,4 @@ unsigned char gr_gpixel( grs_bitmap * bitmap, int x, int y ) return 0; #endif } + diff --git a/2d/ibitblt.c b/2d/ibitblt.c index ba3bc439..3d7099a6 100644 --- a/2d/ibitblt.c +++ b/2d/ibitblt.c @@ -1,4 +1,3 @@ -/* $Id: ibitblt.c,v 1.6 2002-09-04 22:18:43 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,675 +7,44 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* + * Routines to to inverse bitblitting -- well not really. + * We don't inverse bitblt like in the PC, but this code + * does set up a structure that blits around the cockpit * - * Mac Version: - * Routines to to inverse bitblitting -- well not really. - * We don't inverse bitblt like in the PC, but this code - * does set up a structure that blits around the cockpit - * - * Old Log: ibitblt.c - * Revision 1.3 1995/09/13 11:43:22 allender - * start on optimizing cockpit copy code - * - * Revision 1.2 1995/09/07 10:16:57 allender - * fixed up cockpit and rearview hole blitting - * - * Revision 1.1 1995/08/18 15:50:48 allender - * Initial revision - * - * PC version: - * Routines to copy a bitmap on top of another bitmap, but - * only copying to pixels that are transparent. - * - * Old Log: - * Revision 1.6 1994/11/28 17:07:29 john - * Took out some unused functions in linear.asm, moved - * gr_linear_movsd from linear.asm to bitblt.c, made sure that - * the code in ibiblt.c sets the direction flags before rep movsing. - * - * Revision 1.5 1994/11/18 22:50:22 john - * Changed shorts to ints in parameters. - * - * Revision 1.4 1994/11/09 16:35:16 john - * First version with working RLE bitmaps. - * - * Revision 1.3 1994/10/03 17:18:05 john - * Fixed bug with edi not getting intialized to zero - * in create_mask. - * - * Revision 1.2 1994/05/31 11:10:55 john - * *** empty log message *** - * - * Revision 1.1 1994/05/30 16:08:27 john - * Initial revision - * - */ +*/ #ifdef HAVE_CONFIG_H #include #endif -#ifdef RCS -static char rcsid[] = "$Id: ibitblt.c,v 1.6 2002-09-04 22:18:43 btb Exp $"; -#endif - -#ifdef __MSDOS__ - -#include -#include -#include -#include #include - -#include "pa_enabl.h" //$$POLY_ACC -#include "types.h" -#include "gr.h" -#include "mem.h" -#include "error.h" -#include "ibitblt.h" -#include "grdef.h" - -#if defined(POLY_ACC) -#include "poly_acc.h" -#endif - -#define MODE_NONE 0 -#define MODE_SKIP 1 -#define MODE_DRAW 2 - -#define OPCODE_ADD 0x81 -#define OPCODE_ESI 0xC6 // Followed by a dword (add esi, ????) -#define OPCODE_EDI 0xC7 // Followed by a dword (add edi, ????) -#define OPCODE_MOV_ECX 0xB9 // Followed by a dword (mov ecx,????) -#define OPCODE_MOVSB 0xA4 // movsb -#define OPCODE_16BIT 0x66 // movsw -#define OPCODE_MOVSD 0xA5 // movsd -#define OPCODE_REP 0xF3 // rep -#define OPCODE_RET 0xC3 // ret -#define OPCODE_MOV_EAX 0xB8 // mov eax, im dword -#define OPCODE_MOV_EBX 0xBB // mov ebx, im dword -#define OPCODE_CALL_EBX1 0xFF // call -#define OPCODE_CALL_EBX2 0xD3 // ebx -#define OPCODE_MOV_EDI 0xBF // mov edi, im dword - - -ubyte *Code_pointer = NULL; -int Code_counter = 0; -int ibitblt_svga_page = 0; -int is_svga = 0; -uint linear_address; - - - -void count_block( int ecx ) -{ - int blocks; - - while ( ecx > 0 ) { - switch(ecx) { - case 1: Code_counter++; ecx = 0; break; // MOVSB - case 2: Code_counter+=2; ecx = 0; break; // MOVSW - case 3: Code_counter+=3; ecx = 0; break; // MOVSW, MOVSB - case 4: Code_counter++; ecx = 0; break; // MOVSD - default: - blocks = ecx / 4; - if ( blocks == 1 ) - Code_counter++; // MOVSD - else - Code_counter+=7; - ecx -= blocks*4; - } - } -} - - -void move_and_count( int dsource, int ddest, int ecx ) -{ - if ( ecx <= 0 ) - return; - - if ( dsource > 0 ) { - // ADD ESI, dsource - Code_counter += 6; - } - if ( !is_svga ) { - if ( ddest > 0 ) { - // ADD EDI, ddest - Code_counter += 6; - } - count_block( ecx ); - } else { - int p1, p2, o1; - - linear_address += ddest; // Skip to next block - - p1 = linear_address >> 16; o1 = linear_address & 0xFFFF; - p2 = (linear_address+ecx) >> 16; - if ( p1 != ibitblt_svga_page ) { - // Set page - // MOV EAX, ?, CALL EBX - Code_counter += 7; - ibitblt_svga_page = p1; - } - - Code_counter += 5; // mov edi, ???? - - if ( p1 == p2 ) { - count_block( ecx ); - } else { - int nbytes; - nbytes = 0xFFFF-o1+1; - count_block( nbytes ); - // set page - // MOV EAX, 0 - Code_counter += 7; // mov eax,???? call ebx - - ibitblt_svga_page = p2; - - Code_counter += 5; // mov edi, ???? - - nbytes = ecx - nbytes; - if (nbytes > 0 ) - count_block( nbytes ); - } - linear_address += ecx; - } -} - - - -void draw_block( int ecx ) -{ - int blocks; - int * iptr; - - while ( ecx > 0 ) { - switch( ecx ) { - case 1: - // MOVSB - *Code_pointer++ = OPCODE_MOVSB; - ecx = 0; - break; - case 2: - // MOVSW - *Code_pointer++ = OPCODE_16BIT; - *Code_pointer++ = OPCODE_MOVSD; - ecx = 0; - break; - case 3: - // MOVSW, MOVSB - *Code_pointer++ = OPCODE_16BIT; - *Code_pointer++ = OPCODE_MOVSD; - *Code_pointer++ = OPCODE_MOVSB; - ecx = 0; - break; - case 4: - // MOVSD - *Code_pointer++ = OPCODE_MOVSD; - ecx = 0; - break; - default: - blocks = ecx / 4; - - if ( blocks == 1 ) { - // MOVSD - *Code_pointer++ = OPCODE_MOVSD; - } else { - // MOV ECX, blocks - *Code_pointer++ = OPCODE_MOV_ECX; - iptr = (int *)Code_pointer; - *iptr++ = blocks; - Code_pointer = (ubyte *)iptr; - // REP MOVSD - *Code_pointer++ = OPCODE_REP; - *Code_pointer++ = OPCODE_MOVSD; - } - ecx -= blocks*4; - } - } -} - - -void move_and_draw( int dsource, int ddest, int ecx ) -{ - int * iptr; - - if ( ecx <= 0 ) - return; - - if ( dsource > 0 ) { - // ADD ESI, dsource - *Code_pointer++ = OPCODE_ADD; - *Code_pointer++ = OPCODE_ESI; - iptr = (int *)Code_pointer; - *iptr++ = dsource; - Code_pointer = (ubyte *)iptr; - } - if ( !is_svga ) { - if ( ddest > 0 ) { - // ADD EDI, ddest - *Code_pointer++ = OPCODE_ADD; - *Code_pointer++ = OPCODE_EDI; - iptr = (int *)Code_pointer; - *iptr++ = ddest; - Code_pointer = (ubyte *)iptr; - } - draw_block( ecx ); - } else { - unsigned int temp; - int temp_offset; - int p1, p2, o1; - - linear_address += ddest; // Skip to next block - - p1 = linear_address >> 16; o1 = linear_address & 0xFFFF; - p2 = (linear_address+ecx) >> 16; - if ( p1 != ibitblt_svga_page ) { - // Set page - // MOV EAX, 0 - *Code_pointer++ = OPCODE_MOV_EAX; - temp = p1; - memcpy( Code_pointer, &temp, sizeof(int) ); - Code_pointer += sizeof(int); - // CALL EBX - *Code_pointer++ = OPCODE_CALL_EBX1; - *Code_pointer++ = OPCODE_CALL_EBX2; - ibitblt_svga_page = p1; - } - - temp_offset = 0xA0000 + o1; - *Code_pointer++ = OPCODE_MOV_EDI; - iptr = (int *)Code_pointer; - *iptr++ = temp_offset; - Code_pointer = (ubyte *)iptr; - - if ( p1 == p2 ) { - draw_block( ecx ); - } else { - int nbytes; - nbytes = 0xFFFF-o1+1; - draw_block( nbytes ); - // set page - // MOV EAX, 0 - *Code_pointer++ = OPCODE_MOV_EAX; - temp = p2; - memcpy( Code_pointer, &temp, sizeof(int) ); - Code_pointer += sizeof(int); - // CALL EBX - *Code_pointer++ = OPCODE_CALL_EBX1; - *Code_pointer++ = OPCODE_CALL_EBX2; - ibitblt_svga_page = p2; - - temp_offset = 0xA0000; - *Code_pointer++ = OPCODE_MOV_EDI; - iptr = (int *)Code_pointer; - *iptr++ = temp_offset; - Code_pointer = (ubyte *)iptr; - - nbytes = ecx - nbytes; - if (nbytes > 0 ) - draw_block( nbytes ); - } - linear_address += ecx; - } - -} - -//----------------------------------------------------------------------------------------- -// Given bitmap, bmp, finds the size of the code - -int gr_ibitblt_find_code_size_sub( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize, int dest_type ) -{ - int x,y; - ubyte pixel; - int draw_mode = MODE_NONE; - int source_offset = 0; - int dest_offset = 0; - int num_to_draw, draw_start_source, draw_start_dest; - int esi, edi; - - Assert( (!(mask_bmp->bm_flags&BM_FLAG_RLE)) ); - - Code_counter = 0; - - if ( dest_type == BM_SVGA ) { - Code_counter += 1+4; // move ebx, gr_vesa_set_page - Code_counter += 1+4; // move eax, 0 - Code_counter += 2; // call ebx - ibitblt_svga_page = 0; - linear_address = 0; - is_svga = 1; - } else { - is_svga = 0; - } - - esi = source_offset = 0; - edi = dest_offset = 0; - draw_start_source = draw_start_dest = 0; - - for ( y=sy; ybm_rowsize+x; - pixel = mask_bmp->bm_data[dest_offset]; - if ( pixel!=255 ) { - switch ( draw_mode) { - case MODE_DRAW: - move_and_count( draw_start_source-esi, draw_start_dest-edi, num_to_draw ); - esi = draw_start_source + num_to_draw; - edi = draw_start_dest + num_to_draw; - // fall through!!! - case MODE_NONE: - case MODE_SKIP: - break; - } - draw_mode = MODE_SKIP; - } else { - switch ( draw_mode) { - case MODE_SKIP: - case MODE_NONE: - draw_start_source = source_offset; - draw_start_dest = dest_offset; - num_to_draw = 0; - // fall through - case MODE_DRAW: - num_to_draw++; - break; - } - draw_mode = MODE_DRAW; - } - source_offset++; - } - if ( draw_mode == MODE_DRAW ) { - move_and_count( draw_start_source-esi, draw_start_dest-edi, num_to_draw ); - esi = draw_start_source + num_to_draw; - edi = draw_start_dest + num_to_draw; - } - draw_mode = MODE_NONE; - source_offset += (srowsize - sw); - } - Code_counter++; // for return - - //printf( "Code will be %d bytes\n", Code_counter ); - - Code_counter += 16; // for safety was 16 - - return Code_counter; -} - -int gr_ibitblt_find_code_size( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize ) -{ - return gr_ibitblt_find_code_size_sub( mask_bmp, sx, sy, sw, sh, srowsize, BM_LINEAR ); -} - -int gr_ibitblt_find_code_size_svga( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize ) -{ - return gr_ibitblt_find_code_size_sub( mask_bmp, sx, sy, sw, sh, srowsize, BM_SVGA ); -} - -//----------------------------------------------------------------------------------------- -// Given bitmap, bmp, create code that transfers a bitmap of size sw*sh to position -// (sx,sy) on top of bmp, only overwritting transparent pixels of the bitmap. - -ubyte *gr_ibitblt_create_mask_sub( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize, int dest_type ) -{ - int x,y; - ubyte pixel; - int draw_mode = MODE_NONE; - int source_offset = 0; - int dest_offset = 0; - int num_to_draw, draw_start_source, draw_start_dest; - int esi, edi; - int code_size; - ubyte *code; - uint temp; - - Assert( (!(mask_bmp->bm_flags&BM_FLAG_RLE)) ); - - if ( dest_type == BM_SVGA ) - code_size = gr_ibitblt_find_code_size_svga( mask_bmp, sx, sy, sw, sh, srowsize ); - else - code_size = gr_ibitblt_find_code_size( mask_bmp, sx, sy, sw, sh, srowsize ); - - code = malloc( code_size ); - if ( code == NULL ) - return NULL; - - Code_pointer = code; - - if ( dest_type == BM_SVGA ) { - // MOV EBX, gr_vesa_setpage - *Code_pointer++ = OPCODE_MOV_EBX; - temp = (uint)gr_vesa_setpage; - memcpy( Code_pointer, &temp, sizeof(int) ); - Code_pointer += sizeof(int); - // MOV EAX, 0 - *Code_pointer++ = OPCODE_MOV_EAX; - temp = 0; - memcpy( Code_pointer, &temp, sizeof(int) ); - Code_pointer += sizeof(int); - // CALL EBX - *Code_pointer++ = OPCODE_CALL_EBX1; - *Code_pointer++ = OPCODE_CALL_EBX2; - - ibitblt_svga_page = 0; - is_svga = 1; - linear_address = 0; - } else { - is_svga = 0; - } - esi = source_offset = 0; - edi = dest_offset = 0; - draw_start_source = draw_start_dest = 0; - - for ( y=sy; ybm_rowsize+x; - pixel = mask_bmp->bm_data[dest_offset]; - if ( pixel!=255 ) { - switch ( draw_mode) { - case MODE_DRAW: - move_and_draw( draw_start_source-esi, draw_start_dest-edi, num_to_draw ); - esi = draw_start_source + num_to_draw; - edi = draw_start_dest + num_to_draw; - // fall through!!! - case MODE_NONE: - case MODE_SKIP: - break; - } - draw_mode = MODE_SKIP; - } else { - switch ( draw_mode) { - case MODE_SKIP: - case MODE_NONE: - draw_start_source = source_offset; - draw_start_dest = dest_offset; - num_to_draw = 0; - // fall through - case MODE_DRAW: - num_to_draw++; - break; - } - draw_mode = MODE_DRAW; - } - source_offset++; - } - if ( draw_mode == MODE_DRAW ) { - move_and_draw( draw_start_source-esi, draw_start_dest-edi, num_to_draw ); - esi = draw_start_source + num_to_draw; - edi = draw_start_dest + num_to_draw; - } - draw_mode = MODE_NONE; - source_offset += (srowsize - sw); - } - *Code_pointer++ = OPCODE_RET; - - if ( Code_pointer >= &code[code_size-1] ) - Error( "ibitblt overwrote allocated code block\n" ); - - //printf( "Code is %d bytes\n", Code_pointer - code ); - - return code; -} - -ubyte *gr_ibitblt_create_mask( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize ) -{ - return gr_ibitblt_create_mask_sub( mask_bmp, sx, sy, sw, sh, srowsize, BM_LINEAR ); -} - -#if defined(POLY_ACC) -ulong *pa_emit_blit(int gencode, ulong *buf, int w, int h, int sx, int sy, int dx, int dy) -{ - if(w == 0 || h == 0) - return buf; - - if(gencode) - { - buf[0] = (w << 16) | h; - buf[1] = (sx << 16) | sy; - buf[2] = (dx << 16) | dy; - } - return buf + 3; -} - -ubyte *gr_ibitblt_create_mask_pa( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize ) -{ - ulong *ret, *code = 0; - int pass, x, y, n; - ushort *s; - - Assert(mask_bmp->bm_type == BM_LINEAR15); - - srowsize /= PA_BPP; - - pa_flush(); - - // make two passes, first pass gets size of output block, second actually creates data. - for(pass = 0; pass != 2; ++pass) - { - for (y = sy; y < sy + sh; y++ ) - { - // first byte of interest in mask - s = (ushort *)(mask_bmp->bm_data + y * mask_bmp->bm_rowsize + sx * PA_BPP); - for ( x=0; x < sw; ) - { - for(; x != sw && (s[x] & 0x8000); ++x) // while opaque... - ; - for(n = 0; x != sw && !(s[x] & 0x8000); ++n, ++x) // while transparent... - ; - code = pa_emit_blit(pass, code, n, 1, x - n, y - sy, x + sx - n, y); - } - } - if(pass == 0) - { - ret = malloc((int)code + sizeof(ulong)); - ret[0] = (int)code / sizeof(ulong); // store num ulongs in list. - code = ret + 1; - } - } - return (ubyte *)ret; -} - -#else -ubyte *gr_ibitblt_create_mask_svga( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize ) -{ - return gr_ibitblt_create_mask_sub( mask_bmp, sx, sy, sw, sh, srowsize, BM_SVGA ); -} -#endif - - -void gr_ibitblt_do_asm(char *start_si, char *start_di, ubyte * code); -#pragma aux gr_ibitblt_do_asm parm [esi] [edi] [eax] modify [ecx edi esi eax] = \ - "pusha" \ - "cld" \ - "call eax" \ - "popa" - - -void gr_ibitblt(grs_bitmap * source_bmp, grs_bitmap * dest_bmp, ubyte * mask ) -{ -#if defined(POLY_ACC) - Assert(source_bmp->bm_type == BM_LINEAR15); - pa_ibitblt(source_bmp->bm_data, dest_bmp->bm_data, mask); -#else - if (mask != NULL ) - gr_ibitblt_do_asm( source_bmp->bm_data, dest_bmp->bm_data, mask ); -#endif -} - - -void gr_ibitblt_find_hole_size( grs_bitmap * mask_bmp, int *minx, int *miny, int *maxx, int *maxy ) -{ - int x, y, count=0; -#if defined(POLY_ACC) - short c; -#else - ubyte c; -#endif - - Assert( (!(mask_bmp->bm_flags&BM_FLAG_RLE)) ); - -#if defined(POLY_ACC) - Assert(mask_bmp->bm_type == BM_LINEAR15); - pa_flush(); -#endif - - *minx = mask_bmp->bm_w-1; - *maxx = 0; - *miny = mask_bmp->bm_h-1; - *maxy = 0; - - for ( y=0; ybm_h; y++ ) - for ( x=0; xbm_w; x++ ) { -#if defined(POLY_ACC) - c = *(short *)(mask_bmp->bm_data + mask_bmp->bm_rowsize * y + x * PA_BPP); - if (c >= 0) { // hi true means opaque. -#else - c = mask_bmp->bm_data[mask_bmp->bm_rowsize*y+x]; - if (c == 255 ) { -#endif - if ( x < *minx ) *minx = x; - if ( y < *miny ) *miny = y; - if ( x > *maxx ) *maxx = x; - if ( y > *maxy ) *maxy = y; - count++; - } - } - - if ( count == 0 ) { - Error( "Bitmap for ibitblt doesn't have transparency!\n" ); - } -} - -#else // ifdef __MSDOS__ - -#include "pa_enabl.h" #include "pstypes.h" #include "gr.h" +#include "grdef.h" #include "ibitblt.h" #include "error.h" +//added 05/17/99 Matt Mueller #include "u_mem.h" -#include "grdef.h" +//end addition -MM -#if defined(POLY_ACC) -#include "poly_acc.h" -#endif - -#define FIND_START 1 -#define FIND_STOP 2 +#define FIND_START 1 +#define FIND_STOP 2 -#define MAX_WIDTH 640 -#define MAX_SCANLINES 480 -#define MAX_HOLES 5 +#define MAX_WIDTH 1280 +#define MAX_SCANLINES 1024 +#define MAX_HOLES 10 static short start_points[MAX_SCANLINES][MAX_HOLES]; static short hole_length[MAX_SCANLINES][MAX_HOLES]; static double *scanline = NULL; +// adb: gr_linear_movsd assumes c >= 4 +#define gr_linear_movsd(s,d,c) memcpy(d,s,c) + void gr_ibitblt(grs_bitmap *src_bmp, grs_bitmap *dest_bmp, ubyte pixel_double) { int x, y, sw, sh, srowsize, drowsize, dstart, sy, dy; @@ -685,11 +53,6 @@ void gr_ibitblt(grs_bitmap *src_bmp, grs_bitmap *dest_bmp, ubyte pixel_double) // variable setup -#if defined(POLY_ACC) - if ( PAEnabled ) - return; -#endif - sw = src_bmp->bm_w; sh = src_bmp->bm_h; srowsize = src_bmp->bm_rowsize; @@ -702,13 +65,13 @@ void gr_ibitblt(grs_bitmap *src_bmp, grs_bitmap *dest_bmp, ubyte pixel_double) sy++; dest += drowsize; } - + if (pixel_double) { - ubyte *scan = (ubyte *)scanline; // set up for byte processing of scanline - + ubyte *scan = (ubyte *)scanline; // set up for byte processing of scanline + dy = sy; for (y = sy; y < sy + sh; y++) { - gr_linear_movsd_double(src, scan, sw*2); + gr_linear_rep_movsd_2x(src, scan, sw); current_hole = start_points[dy]; current_hole_length = hole_length[dy]; for (x = 0; x < MAX_HOLES; x++) { @@ -751,67 +114,12 @@ void gr_ibitblt(grs_bitmap *src_bmp, grs_bitmap *dest_bmp, ubyte pixel_double) } } -#if defined(POLY_ACC) - -ulong *pa_emit_blit(int gencode, ulong *buf, int w, int h, int sx, int sy, int dx, int dy) -{ - if(w == 0 || h == 0) - return buf; - - if(gencode) - { - buf[0] = (w << 16) | h; - buf[1] = (sx << 16) | sy; - buf[2] = (dx << 16) | dy; - } - return buf + 3; -} - -void gr_ibitblt_create_mask_pa( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize ) -{ - ulong *ret, *code = 0; - int pass, x, y, n; - ushort *s; - - Assert(mask_bmp->bm_type == BM_LINEAR15); - - srowsize /= PA_BPP; - - pa_flush(); - - // make two passes, first pass gets size of output block, second actually creates data. - for(pass = 0; pass != 2; ++pass) - { - for (y = sy; y < sy + sh; y++ ) - { - // first byte of interest in mask - s = (ushort *)(mask_bmp->bm_data + y * mask_bmp->bm_rowsize + sx * PA_BPP); - for ( x=0; x < sw; ) - { - for(; x != sw && (s[x] & 0x8000); ++x) // while opaque... - ; - for(n = 0; x != sw && !(s[x] & 0x8000); ++n, ++x) // while transparent... - ; - code = pa_emit_blit(pass, code, n, 1, x - n, y - sy, x + sx - n, y); - } - } - - if(pass == 0) { - ret = malloc((int)code + sizeof(ulong)); - ret[0] = (int)code / sizeof(ulong); // store num ulongs in list. - code = ret + 1; - } - } -// return (ubyte *)ret; -} -#endif - void gr_ibitblt_create_mask(grs_bitmap *mask_bmp, int sx, int sy, int sw, int sh, int srowsize) { int x, y; ubyte mode; int count = 0; - + Assert( (!(mask_bmp->bm_flags&BM_FLAG_RLE)) ); for (y = 0; y < MAX_SCANLINES; y++) { @@ -820,7 +128,7 @@ void gr_ibitblt_create_mask(grs_bitmap *mask_bmp, int sx, int sy, int sw, int sh hole_length[y][x] = -1; } } - + for (y = sy; y < sy+sh; y++) { count = 0; mode = FIND_START; @@ -842,68 +150,38 @@ void gr_ibitblt_create_mask(grs_bitmap *mask_bmp, int sx, int sy, int sw, int sh } } -#if defined(POLY_ACC) - -void gr_ibitblt_find_hole_size_pa( grs_bitmap * mask_bmp, int *minx, int *miny, int *maxx, int *maxy ) +//added 7/11/99 by adb to prevent memleaks +static void free_scanline(void) { - int x, y, count=0; - short c; - - Assert( (!(mask_bmp->bm_flags&BM_FLAG_RLE)) ); - - Assert(mask_bmp->bm_type == BM_LINEAR15); - while(!pa_idle()); - - *minx = mask_bmp->bm_w-1; - *maxx = 0; - *miny = mask_bmp->bm_h-1; - *maxy = 0; - - for ( y=0; ybm_h; y++ ) - for ( x=0; xbm_w; x++ ) { - c = *(short *)(mask_bmp->bm_data + mask_bmp->bm_rowsize * y + x * PA_BPP); - if (c >= 0) { // hi true means opaque. - if ( x < *minx ) *minx = x; - if ( y < *miny ) *miny = y; - if ( x > *maxx ) *maxx = x; - if ( y > *maxy ) *maxy = y; - count++; - } - } - - if ( count == 0 ) { - Error( "Bitmap for ibitblt doesn't have transparency!\n" ); - } + if (scanline) d_free(scanline); } -#endif +//end additions - adb + void gr_ibitblt_find_hole_size(grs_bitmap *mask_bmp, int *minx, int *miny, int *maxx, int *maxy) { ubyte c; int x, y, count = 0; - -#if defined(POLY_ACC) - if ( PAEnabled ) { - gr_ibitblt_find_hole_size_pa( mask_bmp, minx, miny, maxx, maxy ); - return; - } -#endif - + Assert( (!(mask_bmp->bm_flags&BM_FLAG_RLE)) ); Assert( mask_bmp->bm_flags&BM_FLAG_TRANSPARENT ); - + *minx = mask_bmp->bm_w - 1; *maxx = 0; *miny = mask_bmp->bm_h - 1; *maxy = 0; - if (scanline == NULL) - scanline = (double *)malloc(sizeof(double) * (MAX_WIDTH / sizeof(double))); - + //changed 7/11/99 by adb to prevent memleaks + if (scanline == NULL) { + scanline = (double *)d_malloc(sizeof(double) * (MAX_WIDTH / sizeof(double))); + atexit(free_scanline); + } + //end changes - adb + for (y = 0; y < mask_bmp->bm_h; y++) { for (x = 0; x < mask_bmp->bm_w; x++) { c = mask_bmp->bm_data[mask_bmp->bm_rowsize*y+x]; - if (c == TRANSPARENCY_COLOR) { // don't look for transparancy color here. + if (c == TRANSPARENCY_COLOR) { // don't look for transparancy color here. count++; if (x < *minx) *minx = x; if (y < *miny) *miny = y; @@ -912,7 +190,5 @@ void gr_ibitblt_find_hole_size(grs_bitmap *mask_bmp, int *minx, int *miny, int * } } } - Assert (count); + Assert (count); } - -#endif // ifdef __MSDOS__ diff --git a/2d/line.c b/2d/line.c index 3c2382ab..44746586 100644 --- a/2d/line.c +++ b/2d/line.c @@ -1,4 +1,3 @@ -/* $Id: line.c,v 1.5 2002-10-10 18:55:32 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* @@ -46,16 +45,14 @@ from "Graphics Gems", Academic Press, 1990 /* non-zero flag indicates the pixels needing EXCHG back. */ void plot(int x,int y,int flag) -{ - if (flag) +{ if (flag) gr_upixel(y, x); else gr_upixel(x, y); } int gr_hline(int x1, int x2, int y) -{ - int i; +{ int i; if (x1 > x2) EXCHG(x1,x2); for (i=x1; i<=x2; i++ ) @@ -64,8 +61,7 @@ int gr_hline(int x1, int x2, int y) } int gr_vline(int y1, int y2, int x) -{ - int i; +{ int i; if (y1 > y2) EXCHG(y1,y2); for (i=y1; i<=y2; i++ ) gr_upixel( x, i ); @@ -132,7 +128,7 @@ void gr_universal_uline(int a1, int b1, int a2, int b2) /* In fact (dx-1)/4 as 2 pixels are already plottted */ xend = (dx - 1) / 4; pixels_left = (dx - 1) % 4; /* number of pixels left over at the - * end */ + * end */ plot(x, y, reverse); plot(x1, y1, reverse); /* plot first two points */ incr2 = 4 * dy - 2 * dx; @@ -275,27 +271,27 @@ int gr_uline(fix _a1, fix _b1, fix _a2, fix _b2) switch(TYPE) { #ifdef OGL - case BM_OGL: - ogl_ulinec(a1,b1,a2,b2,COLOR); - return 0; + case BM_OGL: + ogl_ulinec(a1,b1,a2,b2,COLOR); + return 0; #endif case BM_LINEAR: -#ifdef NO_ASM - gr_universal_uline( a1,b1,a2,b2); -#else + #ifdef NO_ASM + gr_universal_uline( a1,b1,a2,b2); + #else gr_linear_line( a1, b1, a2, b2 ); -#endif + #endif return 0; #ifdef __DJGPP__ - case BM_MODEX: - modex_line_x1 = a1+XOFFSET; - modex_line_y1 = b1+YOFFSET; - modex_line_x2 = a2+XOFFSET; - modex_line_y2 = b2+YOFFSET; + case BM_MODEX: + modex_line_x1 = a1+XOFFSET; + modex_line_y1 = b1+YOFFSET; + modex_line_x2 = a2+XOFFSET; + modex_line_y2 = b2+YOFFSET; modex_line_Color = grd_curcanv->cv_color; gr_modex_line(); return 0; - default: + default: gr_universal_uline( a1, b1, a2, b2 ); return 0; #endif diff --git a/2d/linear.asm b/2d/linear.asm index 854e5f1a..81626d8d 100644 --- a/2d/linear.asm +++ b/2d/linear.asm @@ -1,4 +1,3 @@ -; $Id: linear.asm,v 1.3 2002-07-17 21:55:19 bradleyb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -10,10 +9,19 @@ ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; +; $Source: /cvs/cvsroot/d2x/2d/linear.asm,v $ +; $Revision: 1.2 $ +; $Author: bradleyb $ +; $Date: 2001-10-19 09:34:02 $ ; ; Routines to access linear VGA memory ; -; Old Log: +; $Log: not supported by cvs2svn $ +; Revision 1.1.1.1 2001/01/19 03:29:57 bradleyb +; Import of d2x-0.0.8 +; +; Revision 1.1.1.1 1999/06/14 21:57:07 donut +; Import of d1x 1.37 source. ; ; Revision 1.20 1994/11/28 17:08:30 john ; Took out some unused functions in linear.asm, moved diff --git a/2d/linear.h b/2d/linear.h new file mode 100644 index 00000000..0a168c23 --- /dev/null +++ b/2d/linear.h @@ -0,0 +1,482 @@ +#ifndef _LINEAR_H +#define _LINEAR_H + +#ifndef NO_ASM +#ifdef __WATCOMC__ +extern unsigned int gr_var_color; +extern unsigned int gr_var_bwidth; +extern unsigned char * gr_var_bitmap; + +void gr_linear_stosd( void * source, unsigned char color, unsigned int nbytes); +void gr_linear_line( int x0, int y0, int x1, int y1); +void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size ); + +// This code aligns edi so that the destination is aligned to a dword boundry before rep movsd +void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels ); +#pragma aux gr_linear_movsd parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] = \ +" cld " \ +" mov ebx, ecx " \ +" mov eax, edi" \ +" and eax, 011b" \ +" jz d_aligned" \ +" mov ecx, 4" \ +" sub ecx, eax" \ +" sub ebx, ecx" \ +" rep movsb" \ +" d_aligned: " \ +" mov ecx, ebx" \ +" shr ecx, 2" \ +" rep movsd" \ +" mov ecx, ebx" \ +" and ecx, 11b" \ +" rep movsb"; + +void gr_linear_rep_movsdm(void * src, void * dest, unsigned int num_pixels ); +#pragma aux gr_linear_rep_movsdm parm [esi] [edi] [ecx] modify exact [ecx esi edi eax] = \ +"nextpixel:" \ + "mov al,[esi]" \ + "inc esi" \ + "cmp al, 255" \ + "je skip_it" \ + "mov [edi], al" \ +"skip_it:" \ + "inc edi" \ + "dec ecx" \ + "jne nextpixel"; + +void gr_linear_rep_movsdm_faded(void * src, void * dest, unsigned int num_pixels, ubyte fade_value ); +#pragma aux gr_linear_rep_movsdm_faded parm [esi] [edi] [ecx] [ebx] modify exact [ecx esi edi eax ebx] = \ +" xor eax, eax" \ +" mov ah, bl" \ +"nextpixel:" \ + "mov al,[esi]" \ + "inc esi" \ + "cmp al, 255" \ + "je skip_it" \ + "movb al, gr_fade_table[eax]" \ + "movb [edi], al" \ +"skip_it:" \ + "inc edi" \ + "dec ecx" \ + "jne nextpixel"; + + +void gr_linear_rep_movsd_2x(ubyte * src, ubyte * dest, int num_dest_pixels ); +#pragma aux gr_linear_rep_movsd_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] = \ + "shr ecx, 1" \ + "jnc nextpixel" \ + "mov al, [esi]" \ + "mov [edi], al" \ + "inc esi" \ + "inc edi" \ + "cmp ecx, 0" \ + "je done" \ +"nextpixel:" \ + "mov al,[esi]" \ + "mov ah, al" \ + "mov [edi], ax" \ + "inc esi" \ + "inc edi" \ + "inc edi" \ + "dec ecx" \ + "jne nextpixel" \ +"done:" + + + +void modex_copy_column(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ); +#pragma aux modex_copy_column parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = \ +"nextpixel:" \ + "mov al,[esi]" \ + "add esi, ebx" \ + "mov [edi], al" \ + "add edi, edx" \ + "dec ecx" \ + "jne nextpixel" + +void modex_copy_column_m(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ); +#pragma aux modex_copy_column_m parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = \ +"nextpixel:" \ + "mov al,[esi]" \ + "add esi, ebx" \ + "cmp al, 255" \ + "je skip_itx" \ + "mov [edi], al" \ +"skip_itx:" \ + "add edi, edx" \ + "dec ecx" \ + "jne nextpixel" + +void modex_copy_scanline( ubyte * src, ubyte * dest, int npixels ); +#pragma aux modex_copy_scanline parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = \ +" mov ebx, ecx " \ +" and ebx, 11b " \ +" shr ecx, 2 " \ +" cmp ecx, 0 " \ +" je no2group " \ +"next4pixels: " \ +" mov al, [esi+8] " \ +" mov ah, [esi+12] " \ +" shl eax, 16 " \ +" mov al, [esi] " \ +" mov ah, [esi+4] " \ +" mov [edi], eax " \ +" add esi, 16 " \ +" add edi, 4 " \ +" dec ecx " \ +" jne next4pixels " \ +"no2group: " \ +" cmp ebx, 0 " \ +" je done2 " \ +"finishend: " \ +" mov al, [esi] " \ +" add esi, 4 " \ +" mov [edi], al " \ +" inc edi " \ +" dec ebx " \ +" jne finishend " \ +"done2: "; + +void modex_copy_scanline_2x( ubyte * src, ubyte * dest, int npixels ); +#pragma aux modex_copy_scanline_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = \ +" mov ebx, ecx " \ +" and ebx, 11b " \ +" shr ecx, 2 " \ +" cmp ecx, 0 " \ +" je no2group " \ +"next4pixels: " \ +" mov al, [esi+4] " \ +" mov ah, [esi+6] " \ +" shl eax, 16 " \ +" mov al, [esi] " \ +" mov ah, [esi+2] " \ +" mov [edi], eax " \ +" add esi, 8 " \ +" add edi, 4 " \ +" dec ecx " \ +" jne next4pixels " \ +"no2group: " \ +" cmp ebx, 0 " \ +" je done2 " \ +"finishend: " \ +" mov al, [esi] " \ +" add esi, 2 " \ +" mov [edi], al " \ +" inc edi " \ +" dec ebx " \ +" jne finishend " \ +"done2: "; + +#elif defined __GNUC__ +// This code aligns edi so that the destination is aligned to a dword boundry before rep movsd +inline void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels ) { + int dummy[3]; + __asm__ __volatile__ ( +" cld;" +" movl %%ecx, %%ebx;" +" movl %%edi, %%eax;" +" andl $3, %%eax;" +" jz 0f;" +" movl $4, %%ecx;" +" subl %%eax,%%ecx;" +" subl %%ecx,%%ebx;" +" rep; movsb;" +"0: ;" +" movl %%ebx, %%ecx;" +" shrl $2, %%ecx;" +" rep; movsl;" +" movl %%ebx, %%ecx;" +" andl $3, %%ecx;" +" rep; movsb" + : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2]) + : "0" (src), "1" (dest), "2" (num_pixels) + : "%eax", "%ebx"); +} + +static inline void gr_linear_rep_movsdm(void * src, void * dest, unsigned int num_pixels ) { + int dummy[3]; + __asm__ __volatile__ ( +"0: ;" +" movb (%%esi), %%al;" +" incl %%esi;" +" cmpb $255, %%al;" +" je 1f;" +" movb %%al,(%%edi);" +"1: ;" +" incl %%edi;" +" decl %%ecx;" +" jne 0b" + : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2]) + : "0" (src), "1" (dest), "2" (num_pixels) + : "%eax"); +} + +/* #pragma aux gr_linear_rep_movsdm_faded parm [esi] [edi] [ecx] [ebx] modify exact [ecx esi edi eax ebx] */ +static inline void gr_linear_rep_movsdm_faded(void * src, void * dest, unsigned int num_pixels, ubyte fade_value ) { + int dummy[4]; + __asm__ __volatile__ ( +" xorl %%eax, %%eax;" +" movb %%bl, %%ah;" +"0:;" +" movb (%%esi), %%al;" +" incl %%esi;" +" cmpb $255, %%al;" +" je 1f;" +#ifdef __linux__ +" movb gr_fade_table(%%eax), %%al;" +#else +" movb _gr_fade_table(%%eax), %%al;" +#endif +" movb %%al, (%%edi);" +"1:" +" incl %%edi;" +" decl %%ecx;" +" jne 0b" + : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2]), "=b" (dummy[3]) + : "0" (src), "1" (dest), "2" (num_pixels), "3" (fade_value) + : "%eax"); +} + +inline void gr_linear_rep_movsd_2x(ubyte * src, ubyte * dest, unsigned int num_dest_pixels ) { +/* #pragma aux gr_linear_rep_movsd_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx] */ + int dummy[3]; + __asm__ __volatile__ ( + "shrl $1, %%ecx;" + "jnc 0f;" + "movb (%%esi), %%al;" + "movb %%al, (%%edi);" + "incl %%esi;" + "incl %%edi;" + "cmpl $0, %%ecx;" + "je 1f;" +"0: ;" + "movb (%%esi), %%al;" + "movb %%al, %%ah;" + "movw %%ax, (%%edi);" + "incl %%esi;" + "incl %%edi;" + "incl %%edi;" + "decl %%ecx;" + "jne 0b;" +"1:" + : "=S" (dummy[0]), "=D" (dummy[1]), "=c" (dummy[2]) + : "0" (src), "1" (dest), "2" (num_dest_pixels) + : "%eax"); +} + +static inline void modex_copy_column(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) { +/*#pragma aux modex_copy_column parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = */ + __asm__ __volatile__ ( +"0: ;" + "movb (%%esi), %%al;" + "addl %%ebx, %%esi;" + "movb %%al, (%%edi);" + "addl %%edx, %%edi;" + "decl %%ecx;" + "jne 0b" + : : "S" (src), "D" (dest), "c" (num_pixels), "b" (src_rowsize), "d" (dest_rowsize) + : "%eax", "%ecx", "%esi", "%edi"); +} + +static inline void modex_copy_column_m(ubyte * src, ubyte * dest, int num_pixels, int src_rowsize, int dest_rowsize ) { +/* #pragma aux modex_copy_column_m parm [esi] [edi] [ecx] [ebx] [edx] modify exact [ecx esi edi] = */ + int dummy[3]; + __asm__ __volatile__ ( +"0: ;" + "movb (%%esi), %%al;" + "addl %%ebx, %%esi;" + "cmpb $255, %%al;" + "je 1f;" + "movb %%al, (%%edi);" +"1: ;" + "addl %%edx, %%edi;" + "decl %%ecx;" + "jne 0b" + : "=c" (dummy[0]), "=S" (dummy[1]), "=D" (dummy[2]) + : "1" (src), "2" (dest), "0" (num_pixels), "b" (src_rowsize), "d" (dest_rowsize) + : "%eax" ); +} + +static inline void modex_copy_scanline( ubyte * src, ubyte * dest, int npixels ) { +/* #pragma aux modex_copy_scanline parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] */ +int dummy[3]; + __asm__ __volatile__ ( +" movl %%ecx, %%ebx;" +" andl $3, %%ebx;" +" shrl $2, %%ecx;" +" cmpl $0, %%ecx;" +" je 1f;" +"0: ;" +" movb 8(%%esi), %%al;" +" movb 12(%%esi), %%ah;" +" shll $16, %%eax;" +" movb (%%esi), %%al;" +" movb 4(%%esi), %%ah;" +" movl %%eax, (%%edi);" +" addl $16, %%esi;" +" addl $4, %%edi;" +" decl %%ecx;" +" jne 0b;" +"1: ;" +" cmpl $0, %%ebx;" +" je 3f;" +"2: ;" +" movb (%%esi), %%al;" +" addl $4, %%esi;" +" movb %%al, (%%edi);" +" incl %%edi;" +" decl %%ebx;" +" jne 2b;" +"3:" + : "=c" (dummy[0]), "=S" (dummy[1]), "=D" (dummy[2]) + : "1" (src), "2" (dest), "0" (npixels) + : "%eax", "%ebx", "%edx" ); +} + +static inline void modex_copy_scanline_2x( ubyte * src, ubyte * dest, int npixels ) { +/* #pragma aux modex_copy_scanline_2x parm [esi] [edi] [ecx] modify exact [ecx esi edi eax ebx edx] = */ +int dummy[3]; + __asm__ __volatile__ ( +" movl %%ecx, %%ebx;" +" andl $3, %%ebx;" +" shrl $2, %%ecx;" +" cmpl $0, %%ecx;" +" je 1f;" +"0: ;" +" movb 4(%%esi), %%al;" +" movb 6(%%esi), %%ah;" +" shll $16, %%eax;" +" movb (%%esi), %%al;" +" movb 2(%%esi), %%ah;" +" movl %%eax, (%%edi);" +" addl $8, %%esi;" +" addl $4, %%edi;" +" decl %%ecx;" +" jne 0b;" +"1: ;" +" cmp $0, %%ebx;" +" je 3f;" +"2:" +" movb (%%esi),%%al;" +" addl $2, %%esi;" +" movb %%al, (%%edi);" +" incl %%edi;" +" decl %%ebx;" +" jne 2b;" +"3:" + : "=c" (dummy[0]), "=S" (dummy[1]), "=D" (dummy[2]) + : "1" (src), "2" (dest), "0" (npixels) + : "%eax", "%ebx", "%edx" ); +} +#elif defined _MSC_VER + +extern unsigned int gr_var_color; +extern unsigned int gr_var_bwidth; +extern unsigned char * gr_var_bitmap; + +void gr_linear_stosd( ubyte * source, unsigned char color, unsigned int nbytes); +void gr_linear_line( int x0, int y0, int x1, int y1); +void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size ); + +// This code aligns edi so that the destination is aligned to a dword boundry before rep movsd +__inline void gr_linear_movsd(ubyte * src, ubyte * dest, unsigned int num_pixels ) +{ + __asm { + mov esi, [src] + mov edi, [dest] + mov ecx, [num_pixels] + cld + mov ebx, ecx + mov eax, edi + and eax, 011b + jz d_aligned + mov ecx, 4 + sub ecx, eax + sub ebx, ecx + rep movsb +d_aligned: + mov ecx, ebx + shr ecx, 2 + rep movsd + mov ecx, ebx + and ecx, 11b + rep movsb + } +} + +__inline void gr_linear_rep_movsdm(void * src, void * dest, unsigned int num_pixels ) +{ + __asm { + nextpixel: + mov esi, [src] + mov edi, [dest] + mov ecx, [num_pixels] + mov al, [esi] + inc esi + cmp al, 255 + je skip_it + mov [edi], al + skip_it: + inc edi + dec ecx + jne nextpixel + } +} + +__inline void gr_linear_rep_movsdm_faded(void * src, void * dest, unsigned int num_pixels, ubyte fade_value ) +{ + __asm { + mov esi, [src] + mov edi, [dest] + mov ecx, [num_pixels] + movzx ebx, byte ptr [fade_value] + xor eax, eax + mov ah, bl + nextpixel: + mov al, [esi] + inc esi + cmp al, 255 + je skip_it + mov al, gr_fade_table[eax] + mov [edi], al + skip_it: + inc edi + dec ecx + jne nextpixel + } +} + +__inline void gr_linear_rep_movsd_2x(ubyte * src, ubyte * dest, uint num_dest_pixels ) +{ + __asm { + mov esi, [src] + mov edi, [dest] + mov ecx, [num_dest_pixels] + shr ecx, 1 + jnc nextpixel + mov al, [esi] + mov [edi], al + inc esi + inc edi + cmp ecx, 0 + je done +nextpixel: + mov al, [esi] + mov ah, al + mov [edi], ax + inc esi + inc edi + inc edi + dec ecx + jne nextpixel +done: + } +} + +#else +#define NO_ASM 1 // We really do want no assembler... + +#endif +#endif // NO_ASM + +#endif diff --git a/2d/palette.c b/2d/palette.c index fa9a31ed..bf9e7773 100644 --- a/2d/palette.c +++ b/2d/palette.c @@ -1,4 +1,3 @@ -/* $Id: palette.c,v 1.8 2003-03-19 19:21:34 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,137 +7,12 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* * Graphical routines for setting the palette * - * Old Log: - * Revision 1.41 1995/02/02 14:26:31 john - * Made palette fades work better with gamma thingy.. - * - * Revision 1.40 1994/12/08 19:03:46 john - * Made functions use cfile. - * - * Revision 1.39 1994/12/01 11:23:27 john - * Limited Gamma from 0-8. - * - * Revision 1.38 1994/11/28 01:31:08 mike - * optimize color lookup function, caching recently used colors. - * - * Revision 1.37 1994/11/18 22:50:18 john - * Changed shorts to ints in parameters. - * - * Revision 1.36 1994/11/15 17:54:59 john - * Made text palette fade in when game over. - * - * Revision 1.35 1994/11/10 19:53:14 matt - * Fixed error handling is gr_use_palette_table() - * - * Revision 1.34 1994/11/07 13:53:48 john - * Added better gamma stufff. - * - * Revision 1.33 1994/11/07 13:37:56 john - * Added gamma correction stuff. - * - * Revision 1.32 1994/11/05 13:20:14 john - * Fixed bug with find_closest_color_current not working. - * - * Revision 1.31 1994/11/05 13:08:09 john - * MAde it return 0 when palette already faded out. - * - * Revision 1.30 1994/11/05 13:05:34 john - * Added back in code to allow keys during fade. - * - * Revision 1.29 1994/11/05 12:49:50 john - * Fixed bug with previous comment.. - * - * Revision 1.28 1994/11/05 12:48:46 john - * Made palette only fade in / out when its supposed to. - * - * Revision 1.27 1994/11/05 12:46:43 john - * Changed palette stuff a bit. - * - * Revision 1.26 1994/11/01 12:59:35 john - * Reduced palette.256 size. - * - * Revision 1.25 1994/10/26 23:55:35 john - * Took out roller; Took out inverse table. - * - * Revision 1.24 1994/10/04 22:03:05 matt - * Fixed bug: palette wasn't fading all the way out or in - * - * Revision 1.23 1994/09/22 16:08:40 john - * Fixed some palette stuff. - * - * Revision 1.22 1994/09/19 11:44:31 john - * Changed call to allocate selector to the dpmi module. - * - * Revision 1.21 1994/09/12 19:28:09 john - * Fixed bug with unclipped fonts clipping. - * - * Revision 1.20 1994/09/12 18:18:39 john - * Set 254 and 255 to fade to themselves in fadetable - * - * Revision 1.19 1994/09/12 14:40:10 john - * Neatend. - * - * Revision 1.18 1994/09/09 09:31:55 john - * Made find_closest_color not look at superx spot of 254 - * - * Revision 1.17 1994/08/09 11:27:08 john - * Add cthru stuff. - * - * Revision 1.16 1994/08/01 11:03:51 john - * MAde it read in old/new palette.256 - * - * Revision 1.15 1994/07/27 18:30:27 john - * Took away the blending table. - * - * Revision 1.14 1994/06/09 10:39:52 john - * In fade out.in functions, returned 1 if key was pressed... - * - * Revision 1.13 1994/05/31 19:04:16 john - * Added key to stop fade if desired. - * - * Revision 1.12 1994/05/06 12:50:20 john - * Added supertransparency; neatend things up; took out warnings. - * - * Revision 1.11 1994/05/03 19:39:02 john - * *** empty log message *** - * - * Revision 1.10 1994/04/22 11:16:07 john - * *** empty log message *** - * - * Revision 1.9 1994/04/08 16:59:40 john - * Add fading poly's; Made palette fade 32 instead of 16. - * - * Revision 1.8 1994/03/16 17:21:17 john - * Added slow palette searching options. - * - * Revision 1.7 1994/01/07 11:47:33 john - * made use cflib - * - * Revision 1.6 1993/12/21 11:41:04 john - * *** empty log message *** - * - * Revision 1.5 1993/12/09 15:02:47 john - * Changed palette stuff majorly - * - * Revision 1.4 1993/12/07 12:31:41 john - * moved bmd_palette to gr_palette - * - * Revision 1.3 1993/10/15 16:22:23 john - * *** empty log message *** - * - * Revision 1.2 1993/09/26 18:59:46 john - * fade stuff - * - * Revision 1.1 1993/09/08 11:44:03 john - * Initial revision - * */ #ifdef HAVE_CONFIG_H @@ -160,8 +34,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //#include "key.h" //end remove -#include "palette.h" - extern int gr_installed; ubyte gr_palette[256*3]; @@ -172,21 +44,21 @@ ubyte gr_palette_gamma = 0; int gr_palette_gamma_param = 0; ubyte gr_palette_faded_out = 1; -int grd_fades_disabled=0; // Used to skip fading for development +extern void gr_palette_load( ubyte * pal ); void gr_palette_set_gamma( int gamma ) { if ( gamma < 0 ) gamma = 0; //added/changed on 10/27/98 by Victor Rachels to increase brightness slider if ( gamma > 16 ) gamma = 16; //was 8 -//end this section change - Victor Rachels +//end this section change - Victor Rachels if (gr_palette_gamma_param != gamma ) { gr_palette_gamma_param = gamma; gr_palette_gamma = gamma; if (!gr_palette_faded_out) gr_palette_load( gr_palette ); - } + } } int gr_palette_get_gamma() @@ -199,24 +71,10 @@ void gr_use_palette_table( char * filename ) { CFILE *fp; int i,fsize; -#ifdef SWAP_0_255 - ubyte c; -#endif fp = cfopen( filename, "rb" ); - - // the following is a hack to enable the loading of d2 levels - // even if only the d2 mac shareware datafiles are present. - // However, if the pig file is present but the palette file isn't, - // the textures in the level will look wierd... if ( fp==NULL) - fp = cfopen( DEFAULT_LEVEL_PALETTE, "rb" ); - if ( fp==NULL) - Error("Can open neither palette file <%s> " - "nor default palette file <" - DEFAULT_LEVEL_PALETTE - ">.\n", - filename); + Error("Can't open palette file <%s>",filename); fsize = cfilelength( fp ); Assert( fsize == 9472 ); @@ -229,22 +87,6 @@ void gr_use_palette_table( char * filename ) gr_fade_table[i*256+255] = 255; } -// swap colors 0 and 255 of the palette along with fade table entries - -#ifdef SWAP_0_255 - for (i = 0; i < 3; i++) { - c = gr_palette[i]; - gr_palette[i] = gr_palette[765+i]; - gr_palette[765+i] = c; - } - - for (i = 0; i < GR_FADE_LEVELS * 256; i++) { - if (gr_fade_table[i] == 0) - gr_fade_table[i] = 255; - } - for (i=0; iManufacturer = cfile_read_byte(fp); - ph->Version = cfile_read_byte(fp); - ph->Encoding = cfile_read_byte(fp); - ph->BitsPerPixel = cfile_read_byte(fp); - ph->Xmin = cfile_read_short(fp); - ph->Ymin = cfile_read_short(fp); - ph->Xmax = cfile_read_short(fp); - ph->Ymax = cfile_read_short(fp); - ph->Hdpi = cfile_read_short(fp); - ph->Vdpi = cfile_read_short(fp); - cfread(&ph->ColorMap, 16*3, 1, fp); - ph->Reserved = cfile_read_byte(fp); - ph->Nplanes = cfile_read_byte(fp); - ph->BytesPerLine = cfile_read_short(fp); - cfread(&ph->filler, 60, 1, fp); - } - return i; -} -#endif - -int pcx_get_dimensions( char *filename, int *width, int *height) -{ - CFILE *PCXfile; - PCXHeader header; - - PCXfile = cfopen(filename, "rb"); - if (!PCXfile) return PCX_ERROR_OPENING; - - if (PCXHeader_read_n(&header, 1, PCXfile) != 1) { - cfclose(PCXfile); - return PCX_ERROR_NO_HEADER; - } - cfclose(PCXfile); - - *width = header.Xmax - header.Xmin+1; - *height = header.Ymax - header.Ymin+1; - - return PCX_ERROR_NONE; -} - -#ifdef MACINTOSH -int pcx_read_bitmap_palette( char *filename, ubyte *palette) -{ - PCXHeader header; - CFILE * PCXfile; - ubyte data; - int i; - - PCXfile = cfopen( filename , "rb" ); - if ( !PCXfile ) - return PCX_ERROR_OPENING; - - // read 128 char PCX header - if (PCXHeader_read_n( &header, 1, PCXfile )!=1) { - cfclose( PCXfile ); - return PCX_ERROR_NO_HEADER; - } - // Is it a 256 color PCX file? - if ((header.Manufacturer != 10)||(header.Encoding != 1)||(header.Nplanes != 1)||(header.BitsPerPixel != 8)||(header.Version != 5)) { - cfclose( PCXfile ); - return PCX_ERROR_WRONG_VERSION; - } +typedef struct { + ubyte Manufacturer; + ubyte Version; + ubyte Encoding; + ubyte BitsPerPixel; + short Xmin; + short Ymin; + short Xmax; + short Ymax; + short Hdpi; + short Vdpi; + ubyte ColorMap[16][3]; + ubyte Reserved; + ubyte Nplanes; + short BytesPerLine; + ubyte filler[60]; +} PCXHeader; - // Read the extended palette at the end of PCX file - // Read in a character which should be 12 to be extended palette file - - if (palette != NULL) { - cfseek( PCXfile, -768, SEEK_END ); - cfread( palette, 3, 256, PCXfile ); - cfseek( PCXfile, PCXHEADER_SIZE, SEEK_SET ); - for (i=0; i<768; i++ ) - palette[i] >>= 2; -#ifdef MACINTOSH - for (i = 0; i < 3; i++) { - data = palette[i]; - palette[i] = palette[765+i]; - palette[765+i] = data; - } -#endif - } -} -#endif int pcx_read_bitmap( char * filename, grs_bitmap * bmp,int bitmap_type ,ubyte * palette ) { @@ -182,18 +59,13 @@ int pcx_read_bitmap( char * filename, grs_bitmap * bmp,int bitmap_type ,ubyte * CFILE * PCXfile; int i, row, col, count, xsize, ysize; ubyte data, *pixdata; -#if defined(POLY_ACC) - unsigned char local_pal[768]; - - pa_flush(); -#endif PCXfile = cfopen( filename , "rb" ); if ( !PCXfile ) return PCX_ERROR_OPENING; // read 128 char PCX header - if (PCXHeader_read_n( &header, 1, PCXfile )!=1) { + if (cfread( &header, sizeof(PCXHeader), 1, PCXfile )!=1) { cfclose( PCXfile ); return PCX_ERROR_NO_HEADER; } @@ -208,20 +80,6 @@ int pcx_read_bitmap( char * filename, grs_bitmap * bmp,int bitmap_type ,ubyte * xsize = header.Xmax - header.Xmin + 1; ysize = header.Ymax - header.Ymin + 1; -#if defined(POLY_ACC) - // Read the extended palette at the end of PCX file - if(bitmap_type == BM_LINEAR15) // need palette for conversion from 8bit pcx to 15bit. - { - cfseek( PCXfile, -768, SEEK_END ); - cfread( local_pal, 3, 256, PCXfile ); - cfseek( PCXfile, PCXHEADER_SIZE, SEEK_SET ); - for (i=0; i<768; i++ ) - local_pal[i] >>= 2; - pa_save_clut(); - pa_update_clut(local_pal, 0, 256, 0); - } -#endif - if ( bitmap_type == BM_LINEAR ) { if ( bmp->bm_data == NULL ) { gr_init_bitmap_alloc (bmp, bitmap_type, 0, 0, xsize, ysize, xsize); @@ -233,80 +91,35 @@ int pcx_read_bitmap( char * filename, grs_bitmap * bmp,int bitmap_type ,ubyte * pixdata = &bmp->bm_data[bmp->bm_rowsize*row]; for (col=0; col< xsize ; ) { if (cfread( &data, 1, 1, PCXfile )!=1 ) { - cfclose( PCXfile ); + cfclose( PCXfile ); return PCX_ERROR_READING; } if ((data & 0xC0) == 0xC0) { count = data & 0x3F; if (cfread( &data, 1, 1, PCXfile )!=1 ) { - cfclose( PCXfile ); + cfclose( PCXfile ); return PCX_ERROR_READING; } -#ifdef MACINTOSH - if (data == 0) - data = 255; - else if (data == 255) - data = 0; -#endif memset( pixdata, data, count ); pixdata += count; col += count; } else { -#ifdef MACINTOSH - if (data == 0) - data = 255; - else if (data == 255) - data = 0; -#endif *pixdata++ = data; col++; } } } -#if defined(POLY_ACC) - } else if( bmp->bm_type == BM_LINEAR15 ) { - ushort *pixdata2, pix15; - PA_DFX (pa_set_backbuffer_current()); - PA_DFX (pa_set_write_mode(0)); - for (row=0; row< ysize ; row++) { - pixdata2 = (ushort *)&bmp->bm_data[bmp->bm_rowsize*row]; - for (col=0; col< xsize ; ) { - if (cfread( &data, 1, 1, PCXfile )!=1 ) { - cfclose( PCXfile ); - return PCX_ERROR_READING; - } - if ((data & 0xC0) == 0xC0) { - count = data & 0x3F; - if (cfread( &data, 1, 1, PCXfile )!=1 ) { - cfclose( PCXfile ); - return PCX_ERROR_READING; - } - pix15 = pa_clut[data]; - for(i = 0; i != count; ++i) pixdata2[i] = pix15; - pixdata2 += count; - col += count; - } else { - *pixdata2++ = pa_clut[data]; - col++; - } - } - } - pa_restore_clut(); - PA_DFX (pa_swap_buffer()); - PA_DFX (pa_set_frontbuffer_current()); - -#endif } else { for (row=0; row< ysize ; row++) { for (col=0; col< xsize ; ) { if (cfread( &data, 1, 1, PCXfile )!=1 ) { - cfclose( PCXfile ); + cfclose( PCXfile ); return PCX_ERROR_READING; } if ((data & 0xC0) == 0xC0) { count = data & 0x3F; if (cfread( &data, 1, 1, PCXfile )!=1 ) { - cfclose( PCXfile ); + cfclose( PCXfile ); return PCX_ERROR_READING; } for (i=0;i>= 2; -#ifdef MACINTOSH - for (i = 0; i < 3; i++) { - data = palette[i]; - palette[i] = palette[765+i]; - palette[765+i] = data; - } -#endif } } else { - cfclose( PCXfile ); + cfclose( PCXfile ); return PCX_ERROR_NO_PALETTE; } } @@ -356,7 +162,7 @@ int pcx_write_bitmap( char * filename, grs_bitmap * bmp, ubyte * palette ) PCXHeader header; FILE * PCXfile; - memset( &header, 0, PCXHEADER_SIZE ); + memset( &header, 0, sizeof( PCXHeader ) ); header.Manufacturer = 10; header.Encoding = 1; @@ -371,7 +177,7 @@ int pcx_write_bitmap( char * filename, grs_bitmap * bmp, ubyte * palette ) if ( !PCXfile ) return PCX_ERROR_OPENING; - if ( fwrite( &header, PCXHEADER_SIZE, 1, PCXfile ) != 1 ) { + if ( fwrite( &header, sizeof( PCXHeader ), 1, PCXfile ) != 1 ) { fclose( PCXfile ); return PCX_ERROR_WRITING; } @@ -383,7 +189,7 @@ int pcx_write_bitmap( char * filename, grs_bitmap * bmp, ubyte * palette ) } } - // Mark an extended palette + // Mark an extended palette data = 12; if (fwrite( &data, 1, 1, PCXfile )!=1) { fclose( PCXfile ); @@ -391,12 +197,12 @@ int pcx_write_bitmap( char * filename, grs_bitmap * bmp, ubyte * palette ) } // Write the extended palette - for (i=0; i<768; i++ ) + for (i=0; i<768; i++ ) palette[i] <<= 2; - + retval = fwrite( palette, 768, 1, PCXfile ); - for (i=0; i<768; i++ ) + for (i=0; i<768; i++ ) palette[i] >>= 2; if (retval !=1) { @@ -409,15 +215,15 @@ int pcx_write_bitmap( char * filename, grs_bitmap * bmp, ubyte * palette ) } -// returns number of bytes written into outBuff, 0 if failed +// returns number of bytes written into outBuff, 0 if failed int pcx_encode_line(ubyte *inBuff, int inLen, FILE * fp) -{ +{ ubyte this, last; int srcIndex, i; register int total; register ubyte runCount; // max single runlength is 63 total = 0; - last = *(inBuff); + last = *(inBuff); runCount = 1; for (srcIndex = 1; srcIndex < inLen; srcIndex++) { @@ -439,7 +245,7 @@ int pcx_encode_line(ubyte *inBuff, int inLen, FILE * fp) last = this; runCount = 1; } - } + } if (runCount) { // finish up if (!(i=pcx_encode_byte(last, runCount, fp))) @@ -449,9 +255,9 @@ int pcx_encode_line(ubyte *inBuff, int inLen, FILE * fp) return total; } -// subroutine for writing an encoded byte pair +// subroutine for writing an encoded byte pair // returns count of bytes written, 0 if error -int pcx_encode_byte(ubyte byt, ubyte cnt, FILE * fid) +int pcx_encode_byte(ubyte byt, ubyte cnt, FILE * fid) { if (cnt) { if ( (cnt==1) && (0xc0 != (0xc0 & byt)) ) { @@ -495,7 +301,6 @@ char *pcx_errormsg(int error_number) } return p; - } // fullscreen loading, 10/14/99 Jan Bobrowski @@ -506,12 +311,8 @@ int pcx_read_fullscr(char * filename, ubyte * palette) grs_bitmap bm; gr_init_bitmap_data(&bm); pcx_error = pcx_read_bitmap(filename, &bm, BM_LINEAR, palette); - if (pcx_error == PCX_ERROR_NONE) { -#ifdef OGL - gr_palette_load(palette); -#endif + if (pcx_error == PCX_ERROR_NONE) show_fullscr(&bm); - } gr_free_bitmap_data(&bm); return pcx_error; } diff --git a/2d/pixel.c b/2d/pixel.c index 5271754e..2ddbb5db 100644 --- a/2d/pixel.c +++ b/2d/pixel.c @@ -1,4 +1,3 @@ -/* $Id: pixel.c,v 1.5 2002-10-10 18:55:32 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* @@ -38,15 +37,15 @@ void gr_upixel( int x, int y ) switch (TYPE) { #ifdef OGL - case BM_OGL: - ogl_upixelc(x,y,COLOR); - return; + case BM_OGL: + ogl_upixelc(x,y,COLOR); + return; #endif case BM_LINEAR: DATA[ ROWSIZE*y+x ] = COLOR; return; #ifdef __DJGPP__ - case BM_MODEX: + case BM_MODEX: gr_modex_setplane( (x+XOFFSET) & 3 ); gr_video_memory[(ROWSIZE * (y+YOFFSET)) + ((x+XOFFSET)>>2)] = COLOR; return; @@ -54,7 +53,7 @@ void gr_upixel( int x, int y ) gr_vesa_pixel( COLOR, (unsigned int)DATA + (unsigned int)ROWSIZE * y + x); return; #endif - } + } } #endif @@ -70,15 +69,15 @@ inline void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color ) switch (bm->bm_type) { #ifdef OGL - case BM_OGL: - ogl_upixelc(bm->bm_x+x,bm->bm_y+y,color); - return; + case BM_OGL: + ogl_upixelc(bm->bm_x+x,bm->bm_y+y,color); + return; #endif case BM_LINEAR: bm->bm_data[ bm->bm_rowsize*y+x ] = color; return; #ifdef __DJGPP__ - case BM_MODEX: + case BM_MODEX: x += bm->bm_x; y += bm->bm_y; gr_modex_setplane( x & 3 ); @@ -88,7 +87,7 @@ inline void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color ) gr_vesa_pixel(color,(unsigned int)bm->bm_data + (unsigned int)bm->bm_rowsize * y + x); return; #endif - } + } } #endif diff --git a/2d/poly.c b/2d/poly.c index 43c34dff..693fd782 100644 --- a/2d/poly.c +++ b/2d/poly.c @@ -1,4 +1,3 @@ -/* $Id: poly.c,v 1.4 2002-10-10 18:55:32 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* @@ -27,14 +26,14 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //#define USE_POLY_CODE 1 -#define MAX_SCAN_LINES 1200 +#define MAX_SCAN_LINES 1200 -#ifdef USE_POLY_CODE +#ifdef USE_POLY_CODE int y_edge_list[MAX_SCAN_LINES]; void gr_upoly(int nverts, int *vert ) -{ +{ int temp; int startx, stopx; // X coordinates of both ends of current edge. int firstx, firsty; // Saved copy of the first vertex to connect later. @@ -112,7 +111,7 @@ void gr_upoly(int nverts, int *vert ) //gr_uscanline( x2, x1-1, stopy ); gr_uscanline( x2, x1, stopy ); - } else { + } else { dx_dy = (stopx - startx) / (stopy - starty); @@ -207,7 +206,7 @@ void gr_poly(int nverts, int *vert ) } - if (stopy < starty ) { + if (stopy < starty ) { temp = stopy; stopy = starty; starty = temp; @@ -223,7 +222,7 @@ void gr_poly(int nverts, int *vert ) x1 = startx>>16; x2 = stopx>>16; - if (x1 > x2 ) { + if (x1 > x2 ) { temp = x2; x2 = x1; x1 = temp; @@ -237,7 +236,7 @@ void gr_poly(int nverts, int *vert ) gr_scanline( x1, x2, stopy ); } } - } else { + } else { dx_dy = (stopx - startx) / (stopy - starty); @@ -254,11 +253,11 @@ void gr_poly(int nverts, int *vert ) for (; starty < stopy; starty++ ) { if (y_edge_list[starty]==-1) y_edge_list[starty] = startx; - else { + else { x1 = y_edge_list[starty]>>16; x2 = startx>>16; - if (x1 > x2 ) { + if (x1 > x2 ) { temp = x2; x2 = x1; x1 = temp; @@ -281,3 +280,4 @@ void gr_poly(int nverts, int *vert ) } #endif + diff --git a/2d/rect.c b/2d/rect.c index d8859318..716f6a86 100644 --- a/2d/rect.c +++ b/2d/rect.c @@ -1,4 +1,3 @@ -/* $Id: rect.c,v 1.4 2002-10-10 18:55:32 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* diff --git a/2d/rle.c b/2d/rle.c index ecc7cd92..9d0c92e0 100644 --- a/2d/rle.c +++ b/2d/rle.c @@ -1,6 +1,4 @@ -/* $Id: rle.c,v 1.16 2003-03-20 22:48:36 btb Exp $ */ -/* -THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX +/*THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS @@ -8,124 +6,20 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * - * Routines to do run length encoding/decoding - * on bitmaps. - * - * Changed shorts to ints in parameters. - * - * - * Old Log: - * Revision 1.10 1995/08/14 14:26:34 allender - * changed transparency color to 0 - * - * Revision 1.9 1995/07/05 16:07:49 allender - * transparency/kitchen chagnes - * - * Revision 1.8 1995/05/12 11:54:03 allender - * changed memory stuff again - * - * Revision 1.7 1995/05/11 12:49:19 allender - * change transparency color - * - * Revision 1.6 1995/05/04 20:00:30 allender - * use NewPtr instead of malloc. Fix gr_rle_scanline (which caused me - * *many* hours of frustration!!!!) - * - * Revision 1.5 1995/05/01 08:40:32 allender - * trying to find memory bug....this stuff works -- it's johns code - * - * Revision 1.4 1995/04/27 07:38:24 allender - * new rle code ala John - * - * Revision 1.3 1995/04/19 14:36:06 allender - * *** empty log message *** - * - * Revision 1.2 1995/04/18 12:08:30 allender - * *** empty log message *** - * - * Revision 1.1 1995/03/09 09:23:04 allender - * Initial revision - * - * - * --- PC RCS information --- - * Revision 1.19 1995/01/14 19:18:31 john - * Added assert to check for paged out bitmap. - * - * Revision 1.18 1995/01/14 11:32:07 john - * Added rle_cache_flush function. - * - * Revision 1.17 1994/12/13 10:58:27 john - * Fixed bug with 2 consecutive calls to get_expanded_Texture - * with 2 different bitmaps, returning the same rle texture, - * causing doors to disapper. - * - * Revision 1.16 1994/11/30 00:55:03 mike - * optimization - * - * Revision 1.15 1994/11/24 13:24:44 john - * Made sure that some rep movs had the cld set first. - * Took some unused functions out. - * - * Revision 1.14 1994/11/23 16:03:46 john - * Fixed generic rle'ing to use new bit method. - * - * Revision 1.13 1994/11/23 15:45:51 john - * Changed to a 3 bit rle scheme. - * - * Revision 1.12 1994/11/18 22:50:24 john * Changed shorts to ints in parameters. - * - * Revision 1.11 1994/11/14 17:06:13 john - * Took out Key_f12. - * - * Revision 1.10 1994/11/14 15:54:09 john - * Put code in for maybe checking bogus rle data. - * - * Revision 1.9 1994/11/14 15:51:58 john - * Added rle_disable_caching variable to prove the stability of my rle - * caching code to any non-believers. - * - * Revision 1.8 1994/11/10 10:31:20 john - * Reduce cache buffers to 16. - * - * Revision 1.7 1994/11/09 19:53:43 john - * Added texture rle caching. - * - * Revision 1.6 1994/11/09 17:41:44 john - * Made a slow version of rle bitblt to svga, modex. - * - * Revision 1.5 1994/11/09 17:07:50 john - * Fixed bug with bitmap that gets bigger with rle. - * - * Revision 1.4 1994/11/09 16:35:17 john - * First version with working RLE bitmaps. - * - * Revision 1.3 1994/10/26 12:54:47 john - * Fixed bug with decode that used rep movsd instead of - * rep stosd. - * - * Revision 1.2 1994/10/06 17:05:25 john - * First version of rle stuff. - * - * Revision 1.1 1994/10/06 16:53:34 john - * Initial revision - * - * + * */ - #ifdef HAVE_CONFIG_H #include #endif #ifdef RCS -static char rcsid[] = "$Id: rle.c,v 1.16 2003-03-20 22:48:36 btb Exp $"; +static char rcsid[] = "$Id: rle.c,v 1.3 2001-12-23 09:10:31 bradleyb Exp $"; #endif #include @@ -142,56 +36,56 @@ static char rcsid[] = "$Id: rle.c,v 1.16 2003-03-20 22:48:36 btb Exp $"; #include "error.h" //#include "key.h" #include "rle.h" -#include "byteswap.h" - -#define RLE_CODE 0xE0 -#define NOT_RLE_CODE 31 +//#define RLE_CODE 0xC0 +//#define NOT_RLE_CODE 63 -#define IS_RLE_CODE(x) (((x) & RLE_CODE) == RLE_CODE) +#define RLE_CODE 0xE0 +#define NOT_RLE_CODE 31 -#if !defined(NO_ASM) && defined(__WATCOMC__) -#define RLE_DECODE_ASM +void rle_expand_texture_sub( grs_bitmap * bmp, grs_bitmap * rle_temp_bitmap_1 ); -ubyte *gr_rle_decode_asm( ubyte * src, ubyte * dest ); +#ifndef NO_ASM +#ifdef __WATCOMC__ +int gr_rle_decode_asm( ubyte * src, ubyte * dest ); #pragma aux gr_rle_decode_asm parm [esi] [edi] value [edi] modify exact [eax ebx ecx edx esi edi] = \ -" cld " \ -" xor ecx, ecx " \ -" cld " \ -" jmp NextByte " \ -" " \ -"Unique: " \ -" mov [edi],al " \ +" cld " \ +" xor ecx, ecx " \ +" cld " \ +" jmp NextByte " \ +" " \ +"Unique: " \ +" mov [edi],al " \ " inc edi " \ -" " \ -"NextByte: " \ -" mov al,[esi] " \ +" " \ +"NextByte: " \ +" mov al,[esi] " \ " inc esi " \ -" " \ +" " \ " mov ah, al " \ " and ah, 0xE0 " \ -" cmp ah, 0xE0 " \ -" jne Unique " \ -" " \ +" cmp ah, 0xE0 " \ +" jne Unique " \ +" " \ " mov cl, al " \ -" and cl, 31 " \ -" je done " \ -" " \ -" mov al,[esi] " \ +" and cl, 31 " \ +" je done " \ +" " \ +" mov al,[esi] " \ " inc esi " \ " mov ah, al " \ -" shr ecx,1 " \ -" rep stosw " \ -" jnc NextByte " \ -" mov [edi],al " \ +" shr ecx,1 " \ +" rep stosw " \ +" jnc NextByte " \ +" mov [edi],al " \ " inc edi " \ -" " \ -" jmp NextByte " \ -" " \ -"done: "; - -#elif !defined(NO_ASM) && defined(__GNUC__) -#define RLE_DECODE_ASM +" " \ +" jmp NextByte " \ +" " \ +"done: "; +void rle_stosb(char *dest, int len, int color); +#pragma aux rle_stosb = "cld rep stosb" parm [edi] [ecx] [eax] modify exact [edi ecx]; +#elif defined __GNUC__ static inline int gr_rle_decode_asm( ubyte * src, ubyte * dest ) { register int __ret; int dummy; @@ -226,9 +120,14 @@ static inline int gr_rle_decode_asm( ubyte * src, ubyte * dest ) { return __ret; } -#elif !defined(NO_ASM) && defined(_MSC_VER) -#define RLE_DECODE_ASM - +static inline void rle_stosb(char *dest, int len, int color) { + int dummy[2]; + __asm__ __volatile__ ( + "cld; rep; stosb" + : "=D" (dummy[0]), "=c" (dummy[1]) + : "0" (dest), "1" (len), "a" (color) ); +} +#elif defined _MSC_VER __inline int gr_rle_decode_asm( ubyte * src, ubyte * dest ) { int retval; @@ -268,105 +167,71 @@ done: return retval; } -#endif - -#ifdef RLE_DECODE_ASM - -#if 0 -void gr_rle_decode( ubyte * src, ubyte * dest, int dest_len ) +__inline void rle_stosb(char *dest, int len, int color) { - ubyte *dest_end; - - dest_end = (ubyte *)gr_rle_decode_asm( src, dest ); - - Assert(dest_end-src < dest_len); + __asm { + mov edi,[dest] + mov ecx,[len] + mov eax,[color] + cld + rep stosb + } } + #else -void gr_rle_decode( ubyte * src, ubyte * dest ) +# undef NO_ASM +# define NO_ASM 1 +/* Well, if inline assembler is not supported for this compiler, we don't + **really** want ASM... */ +#endif +#endif + +#ifdef NO_ASM +void rle_stosb(ubyte *dest, int len, int color) { - gr_rle_decode_asm( src, dest ); + int i; + for (i=0; i x2 ) { count = x2-x1+1; - if ( color != TRANSPARENCY_COLOR ) rle_stosb( dest, count, color ); + if ( color != 255 ) rle_stosb( dest, count, color ); return; } - if ( color != TRANSPARENCY_COLOR ) rle_stosb( dest, count, color ); + if ( color != 255 ) rle_stosb( dest, count, color ); dest += count; i += count; while( i <= x2 ) { color = *src++; if ( color == RLE_CODE ) return; - if ( IS_RLE_CODE(color) ) { + if ( (color & RLE_CODE) == (RLE_CODE) ) { count = color & (~RLE_CODE); color = *src++; } else { @@ -401,12 +266,12 @@ void gr_rle_expand_scanline_masked( ubyte *dest, ubyte *src, int x1, int x2 ) } // we know have '*count' pixels of 'color'. if ( i+count <= x2 ) { - if ( color != TRANSPARENCY_COLOR )rle_stosb( dest, count, color ); + if ( color != 255 )rle_stosb( dest, count, color ); i += count; dest += count; } else { count = x2-i+1; - if ( color != TRANSPARENCY_COLOR )rle_stosb( dest, count, color ); + if ( color != 255 )rle_stosb( dest, count, color ); i += count; dest += count; } @@ -417,16 +282,15 @@ void gr_rle_expand_scanline_masked( ubyte *dest, ubyte *src, int x1, int x2 ) void gr_rle_expand_scanline( ubyte *dest, ubyte *src, int x1, int x2 ) { int i = 0; - ubyte count; - ubyte color=0; + ubyte count=0; + ubyte color=0; if ( x2 < x1 ) return; - count = 0; while ( i < x1 ) { color = *src++; if ( color == RLE_CODE ) return; - if ( IS_RLE_CODE(color) ) { + if ( (color & RLE_CODE)==RLE_CODE ) { count = color & (~RLE_CODE); color = *src++; } else { @@ -452,7 +316,7 @@ void gr_rle_expand_scanline( ubyte *dest, ubyte *src, int x1, int x2 ) while( i <= x2 ) { color = *src++; if ( color == RLE_CODE ) return; - if ( IS_RLE_CODE(color) ) { + if ( (color & RLE_CODE)==RLE_CODE ) { count = color & (~RLE_CODE); color = *src++; } else { @@ -470,7 +334,7 @@ void gr_rle_expand_scanline( ubyte *dest, ubyte *src, int x1, int x2 ) i += count; dest += count; } - } + } } @@ -486,10 +350,10 @@ int gr_rle_encode( int org_size, ubyte *src, ubyte *dest ) count = 1; for (i=1; ibm_h; y++ ) { - d1= gr_rle_getsize( bmp->bm_w, &bmp->bm_data[bmp->bm_w*y] ); - if (d1 > 255) { - large_rle = 1; - break; - } - } - rle_data=d_malloc( (bmp->bm_w+1) * bmp->bm_h ); + rle_data=d_malloc( (bmp->bm_w+1)* bmp->bm_h ); if (rle_data==NULL) return 0; - if (!large_rle) - doffset = 4 + bmp->bm_h; - else - doffset = 4 + (2 * bmp->bm_h); // each row of rle'd bitmap has short instead of byte offset now - + doffset = 4 + bmp->bm_h; for (y=0; ybm_h; y++ ) { d1= gr_rle_getsize( bmp->bm_w, &bmp->bm_data[bmp->bm_w*y] ); - if ( ((doffset+d1) > bmp->bm_w*bmp->bm_h) || (d1 > (large_rle?32767:255) ) ) { + if ( ((doffset+d1) > bmp->bm_w*bmp->bm_h) || (d1 > 255 ) ) { d_free(rle_data); return 0; } d = gr_rle_encode( bmp->bm_w, &bmp->bm_data[bmp->bm_w*y], &rle_data[doffset] ); Assert( d==d1 ); doffset += d; - if (large_rle) - *((short *)&(rle_data[(y*2)+4])) = (short)d; - else - rle_data[y+4] = d; + rle_data[y+4] = d; } //mprintf( 0, "Bitmap of size %dx%d, (%d bytes) went down to %d bytes\n", bmp->bm_w, bmp->bm_h, bmp->bm_h*bmp->bm_w, doffset ); memcpy( rle_data, &doffset, 4 ); memcpy( bmp->bm_data, rle_data, doffset ); d_free(rle_data); bmp->bm_flags |= BM_FLAG_RLE; - if (large_rle) - bmp->bm_flags |= BM_FLAG_RLE_BIG; return 1; } @@ -622,7 +466,7 @@ int gr_bitmap_rle_compress( grs_bitmap * bmp ) typedef struct rle_cache_element { grs_bitmap * rle_bitmap; ubyte * rle_data; - grs_bitmap * expanded_bitmap; + grs_bitmap * expanded_bitmap; int last_used; } rle_cache_element; @@ -653,7 +497,7 @@ void rle_cache_init() rle_cache[i].expanded_bitmap = gr_create_bitmap( 64, 64 ); rle_cache[i].last_used = 0; Assert( rle_cache[i].expanded_bitmap != NULL ); - } + } rle_cache_initialized = 1; atexit( rle_cache_close ); } @@ -664,57 +508,9 @@ void rle_cache_flush() for (i=0; iiMagic == BM_MAGIC_NUMBER); -#endif - - sbits = &bmp->bm_data[4 + bmp->bm_h]; - dbits = rle_temp_bitmap_1->bm_data; - - rle_temp_bitmap_1->bm_flags = bmp->bm_flags & (~BM_FLAG_RLE); - - for (i=0; i < bmp->bm_h; i++ ) { -#ifdef RLE_DECODE_ASM - dbits1=(unsigned char *)gr_rle_decode_asm( sbits, dbits ); -#else - gr_rle_decode( sbits, dbits ); -#endif - sbits += (int)bmp->bm_data[4+i]; - dbits += bmp->bm_w; -#ifdef RLE_DECODE_ASM - Assert( dbits == dbits1 ); // Get John, bogus rle data! -#endif - } -#ifdef D1XD3D - gr_set_bitmap_data (rle_temp_bitmap_1, rle_temp_bitmap_1->bm_data); -#endif + } } -#if defined(POLY_ACC) -grs_bitmap *rle_get_id_sub(grs_bitmap *bmp) -{ - int i; - - for (i=0;i= MAX_CACHE_BITMAPS ) rle_next = 0; - + for (i=0; ibm_w<=64 && bmp->bm_h<=64); //dest buffer is 64x64 + } rle_misses++; rle_expand_texture_sub( bmp, rle_cache[least_recently_used].expanded_bitmap ); rle_cache[least_recently_used].rle_bitmap = bmp; @@ -765,80 +559,55 @@ grs_bitmap * rle_expand_texture( grs_bitmap * bmp ) return rle_cache[least_recently_used].expanded_bitmap; } - -void gr_rle_expand_scanline_generic( grs_bitmap * dest, int dx, int dy, ubyte *src, int x1, int x2 ) +void rle_expand_texture_sub( grs_bitmap * bmp, grs_bitmap * rle_temp_bitmap_1 ) { - int i = 0, j; - int count; - ubyte color=0; - - if ( x2 < x1 ) return; + unsigned char * dbits; + unsigned char * sbits; + int i; +#ifndef NO_ASM + unsigned char * dbits1; +#endif - count = 0; - while ( i < x1 ) { - color = *src++; - if ( color == RLE_CODE ) return; - if ( IS_RLE_CODE(color) ) { - count = color & NOT_RLE_CODE; - color = *src++; - } else { - // unique - count = 1; - } - i += count; - } - count = i - x1; - i = x1; - // we know have '*count' pixels of 'color'. +#ifdef D1XD3D + Assert (bmp->iMagic == BM_MAGIC_NUMBER); +#endif - if ( x1+count > x2 ) { - count = x2-x1+1; - for ( j=0; jbm_data[4 + 64]; + dbits = rle_temp_bitmap_1->bm_data; - for ( j=0; jbm_flags = bmp->bm_flags & (~BM_FLAG_RLE); - while( i <= x2 ) { - color = *src++; - if ( color == RLE_CODE ) return; - if ( IS_RLE_CODE(color) ) { - count = color & NOT_RLE_CODE; - color = *src++; - } else { - // unique - count = 1; - } - // we know have '*count' pixels of 'color'. - if ( i+count <= x2 ) { - for ( j=0; jbm_data[4+i]; + dbits += 64; +#ifndef NO_ASM + Assert( dbits == dbits1 ); // Get John, bogus rle data! +#endif } +#ifdef D1XD3D + gr_set_bitmap_data (rle_temp_bitmap_1, rle_temp_bitmap_1->bm_data); +#endif } -void gr_rle_expand_scanline_generic_masked( grs_bitmap * dest, int dx, int dy, ubyte *src, int x1, int x2 ) + +void gr_rle_expand_scanline_generic( grs_bitmap * dest, int dx, int dy, ubyte *src, + int x1, int x2, int masked ) { int i = 0, j; - int count; - ubyte color = 0; + int count=0; + ubyte color=0; if ( x2 < x1 ) return; - count = 0; while ( i < x1 ) { color = *src++; if ( color == RLE_CODE ) return; - if ( IS_RLE_CODE(color) ) { + if ( (color & RLE_CODE) == RLE_CODE ) { count = color & NOT_RLE_CODE; color = *src++; } else { @@ -850,27 +619,26 @@ void gr_rle_expand_scanline_generic_masked( grs_bitmap * dest, int dx, int dy, u count = i - x1; i = x1; // we know have '*count' pixels of 'color'. - + if ( x1+count > x2 ) { count = x2-x1+1; - if (color != TRANSPARENCY_COLOR) { - for ( j=0; jbm_data + (dest->bm_rowsize * dy) + dx; - page = VideoLocation >> 16; - offset = VideoLocation & 0xFFFF; - - gr_vesa_setpage( page ); - - if ( (offset + (x2-x1+1)) < 65536 ) { - // We don't cross a svga page, so blit it fast! - gr_rle_expand_scanline_masked( &vram[offset], src, x1, x2 ); - return; - } - - count = 0; - while ( i < x1 ) { - color = *src++; - if ( color == RLE_CODE ) return; - if ( IS_RLE_CODE(color) ) { - count = color & NOT_RLE_CODE; - color = *src++; - } else { - // unique - count = 1; - } - i += count; - } - count = i - x1; - i = x1; - // we know have '*count' pixels of 'color'. - - if ( x1+count > x2 ) { - count = x2-x1+1; - if (color != TRANSPARENCY_COLOR) { - for ( j=0; j= 65536 ) { - offset -= 65536; - page++; - gr_vesa_setpage(page); - } - } - } - return; - } - - if ( color != TRANSPARENCY_COLOR ) { - for ( j=0; j= 65536 ) { - offset -= 65536; - page++; - gr_vesa_setpage(page); - } - } - } else { - offset += count; - if ( offset >= 65536 ) { - offset -= 65536; - page++; - gr_vesa_setpage(page); - } - } - i += count; - - while( i <= x2 ) { - color = *src++; - if ( color == RLE_CODE ) return; - if ( IS_RLE_CODE(color) ) { - count = color & NOT_RLE_CODE; - color = *src++; - } else { - // unique - count = 1; - } - // we know have '*count' pixels of 'color'. - if ( i+count <= x2 ) { - if ( color != TRANSPARENCY_COLOR ) { - for ( j=0; j= 65536 ) { - offset -= 65536; - page++; - gr_vesa_setpage(page); - } - } - } else { - offset += count; - if ( offset >= 65536 ) { - offset -= 65536; - page++; - gr_vesa_setpage(page); - } - } - i += count; - } else { - count = x2-i+1; - if ( color != TRANSPARENCY_COLOR ) { - for ( j=0; j= 65536 ) { - offset -= 65536; - page++; - gr_vesa_setpage(page); - } - } - } else { - offset += count; - if ( offset >= 65536 ) { - offset -= 65536; - page++; - gr_vesa_setpage(page); - } - } - i += count; - } - } -} -#endif // __MSDOS__ - - -/* - * swaps entries 0 and 255 in an RLE bitmap without uncompressing it - */ -void rle_swap_0_255(grs_bitmap *bmp) -{ - int i, j, len, rle_big; - unsigned char *ptr, *ptr2, *temp, *start; - unsigned short line_size; - - rle_big = bmp->bm_flags & BM_FLAG_RLE_BIG; - - temp = d_malloc(4 + bmp->bm_h + (bmp->bm_w + 1) * bmp->bm_h); - - if (rle_big) { // set ptrs to first lines - ptr = bmp->bm_data + 4 + 2 * bmp->bm_h; - ptr2 = temp + 4 + 2 * bmp->bm_h; - } else { - ptr = bmp->bm_data + 4 + bmp->bm_h; - ptr2 = temp + 4 + bmp->bm_h; - } - for (i = 0; i < bmp->bm_h; i++) { - start = ptr2; - if (rle_big) - line_size = INTEL_SHORT(*((unsigned short *)&bmp->bm_data[4 + 2 * i])); - else - line_size = bmp->bm_data[4 + i]; - for (j = 0; j < line_size; j++) { - if ( ! IS_RLE_CODE(ptr[j]) ) { - if (ptr[j] == 0) { - *ptr2++ = RLE_CODE | 1; - *ptr2++ = 255; - } else - *ptr2++ = ptr[j]; - } else { - *ptr2++ = ptr[j]; - if ((ptr[j] & NOT_RLE_CODE) == 0) - break; - j++; - if (ptr[j] == 0) - *ptr2++ = 255; - else if (ptr[j] == 255) - *ptr2++ = 0; - else - *ptr2++ = ptr[j]; - } - } - if (rle_big) // set line size - *((unsigned short *)&temp[4 + 2 * i]) = INTEL_SHORT(ptr2 - start); - else - temp[4 + i] = ptr2 - start; - ptr += line_size; // go to next line - } - len = ptr2 - temp; - *((int *)temp) = len; // set total size - memcpy(bmp->bm_data, temp, len); - d_free(temp); -} - -/* - * remaps all entries using colormap in an RLE bitmap without uncompressing it - */ -void rle_remap(grs_bitmap *bmp, ubyte *colormap) -{ - int i, j, len, rle_big; - unsigned char *ptr, *ptr2, *temp, *start; - unsigned short line_size; - - rle_big = bmp->bm_flags & BM_FLAG_RLE_BIG; - - temp = d_malloc(4 + bmp->bm_h + (bmp->bm_w + 1) * bmp->bm_h + 30000); - - if (rle_big) { // set ptrs to first lines - ptr = bmp->bm_data + 4 + 2 * bmp->bm_h; - ptr2 = temp + 4 + 2 * bmp->bm_h; - } else { - ptr = bmp->bm_data + 4 + bmp->bm_h; - ptr2 = temp + 4 + bmp->bm_h; - } - for (i = 0; i < bmp->bm_h; i++) { - start = ptr2; - if (rle_big) - line_size = INTEL_SHORT(*((unsigned short *)&bmp->bm_data[4 + 2 * i])); - else - line_size = bmp->bm_data[4 + i]; - for (j = 0; j < line_size; j++) { - if ( ! IS_RLE_CODE(ptr[j])) { - if (IS_RLE_CODE(colormap[ptr[j]])) - *ptr2++ = RLE_CODE | 1; // add "escape sequence" - *ptr2++ = colormap[ptr[j]]; // translate - } else { - *ptr2++ = ptr[j]; // just copy current rle code - if ((ptr[j] & NOT_RLE_CODE) == 0) - break; - j++; - *ptr2++ = colormap[ptr[j]]; // translate - } - } - if (rle_big) // set line size - *((unsigned short *)&temp[4 + 2 * i]) = INTEL_SHORT(ptr2 - start); - else - temp[4 + i] = ptr2 - start; - ptr += line_size; // go to next line - } - len = ptr2 - temp; - *((int *)temp) = len; // set total size - memcpy(bmp->bm_data, temp, len); - d_free(temp); + } } diff --git a/2d/scale.c b/2d/scale.c index 4d409a08..7864834a 100644 --- a/2d/scale.c +++ b/2d/scale.c @@ -1,4 +1,3 @@ -/* $Id: scale.c,v 1.3 2002-07-17 21:55:19 bradleyb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,10 +11,19 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/2d/scale.c,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-01-31 15:17:48 $ * * Routines for scaling a bitmap. * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 2001/01/19 03:29:57 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 21:57:36 donut + * Import of d1x 1.37 source. * * Revision 1.12 1995/03/14 15:14:11 john * Increased max scanline length to 640. @@ -64,7 +72,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: scale.c,v 1.3 2002-07-17 21:55:19 bradleyb Exp $"; +static char rcsid[] = "$Id: scale.c,v 1.2 2001-01-31 15:17:48 bradleyb Exp $"; #endif #include diff --git a/2d/scalea.asm b/2d/scalea.asm index 609dd631..fa569b52 100644 --- a/2d/scalea.asm +++ b/2d/scalea.asm @@ -1,4 +1,3 @@ -; $ Id: $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -10,10 +9,16 @@ ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; +; $Source: /cvs/cvsroot/d2x/2d/scalea.asm,v $ +; $Revision: 1.1.1.1 $ +; $Author: bradleyb $ +; $Date: 2001-01-19 03:29:57 $ ; ; Asm inner loop for scaler. ; -; Old Log: +; $Log: not supported by cvs2svn $ +; Revision 1.1.1.1 1999/06/14 21:57:07 donut +; Import of d1x 1.37 source. ; ; Revision 1.2 1994/01/12 18:02:52 john ; Asm code for the scaler... first iteration here diff --git a/2d/scalea.h b/2d/scalea.h index 2992b27a..7cd6e341 100644 --- a/2d/scalea.h +++ b/2d/scalea.h @@ -1,4 +1,3 @@ -/* $Id: scalea.h,v 1.3 2002-07-17 21:34:56 bradleyb Exp $ */ extern char scale_trans_color; extern int scale_error_term; extern int scale_initial_pixel_count; diff --git a/2d/scalec.c b/2d/scalec.c index e9f5fce2..e31a7c74 100644 --- a/2d/scalec.c +++ b/2d/scalec.c @@ -1,4 +1,3 @@ -/* $Id: scalec.c,v 1.5 2002-09-05 08:20:03 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -36,8 +35,8 @@ ubyte * scale_dest_ptr; ubyte scale_rle_data[640]; -void scale_up_bitmap(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1, int orientation ); -void scale_up_bitmap_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1, int orientation ); +void scale_up_bitmap(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 ); +void scale_up_bitmap_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 ); void rls_stretch_scanline_setup( int XDelta, int YDelta ); void rls_stretch_scanline(void); @@ -45,33 +44,19 @@ void rls_stretch_scanline(void); void decode_row( grs_bitmap * bmp, int y ) { int i, offset=4+bmp->bm_h; - + for (i=0; ibm_data[4+i]; gr_rle_decode( &bmp->bm_data[offset], scale_rle_data ); } -void scale_up_bitmap(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1, int orientation ) +void scale_up_bitmap(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 ) { fix dv, v; int y; - if (orientation & 1) { - int t; - t = u0; u0 = u1; u1 = t; - } - - if (orientation & 2) { - int t; - t = v0; v0 = v1; v1 = t; - if (v1 < v0) - v0--; - } - - v = v0; - dv = (v1-v0) / (y1-y0); - + rls_stretch_scanline_setup( (int)(x1-x0), f2i(u1)-f2i(u0) ); if ( scale_ydelta_minus_1 < 1 ) return; @@ -88,25 +73,13 @@ void scale_up_bitmap(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y -void scale_up_bitmap_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1, int orientation ) +void scale_up_bitmap_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 ) { fix dv, v; int y, last_row = -1; - if (orientation & 1) { - int t; - t = u0; u0 = u1; u1 = t; - } - - if (orientation & 2) { - int t; - t = v0; v0 = v1; v1 = t; - if (v1 < v0) - v0--; - } - dv = (v1-v0) / (y1-y0); - + rls_stretch_scanline_setup( (int)(x1-x0), f2i(u1)-f2i(u0) ); if ( scale_ydelta_minus_1 < 1 ) return; @@ -119,7 +92,7 @@ void scale_up_bitmap_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, i } scale_source_ptr = &scale_rle_data[f2i(u0)]; scale_dest_ptr = &dest_bmp->bm_data[dest_bmp->bm_rowsize*y+x0]; - rls_stretch_scanline( ); + rls_stretch_scanline(); v += dv; } } @@ -169,62 +142,9 @@ void rls_stretch_scanline_setup( int XDelta, int YDelta ) } -void rls_stretch_scanline( ) -{ - ubyte c, *src_ptr, *dest_ptr; - int i, j, len, ErrorTerm, initial_count, final_count; - - // Draw the first, partial run of pixels - - src_ptr = scale_source_ptr; - dest_ptr = scale_dest_ptr; - ErrorTerm = scale_error_term; - initial_count = scale_initial_pixel_count; - final_count = scale_final_pixel_count; - - c = *src_ptr++; - if ( c != TRANSPARENCY_COLOR ) { - for (i=0; i 0) { - len++; - ErrorTerm -= scale_adj_down; // reset the error term - } - - // Draw this run o' pixels - c = *src_ptr++; - if ( c != TRANSPARENCY_COLOR ) { - for (i=len; i>0; i-- ) - *dest_ptr++ = c; - } else { - dest_ptr += len; - } - } - - // Draw the final run of pixels - c = *src_ptr++; - if ( c != TRANSPARENCY_COLOR ) { - for (i=0; i0; i-- ) - *scale_dest_ptr++ = c; + + if (len > 3) { + while ((size_t)(scale_dest_ptr) & 0x3) { *scale_dest_ptr++ = c; len--; }; + if (len >= 4) { + x = (c << 24) | (c << 16) | (c << 8) | c; + while (len > 4) { *((int *)scale_dest_ptr) = x; scale_dest_ptr += 4; len -= 4; }; + } + while (len > 0) { *scale_dest_ptr++ = c; len--; }; + } else { + for (i=0; ibm_data[source_bmp->bm_rowsize*f2i(v)]; dbits = &dest_bmp->bm_data[dest_bmp->bm_rowsize*y+x0]; - u = u0; + u = u0; v += dv; for (x=x0; x<=x1; x++ ) { - c = sbits[u >> 16]; - if (c != TRANSPARENCY_COLOR) - *dbits = c; - dbits++; + *dbits++ = sbits[ u >> 16 ]; u += du; } } @@ -319,7 +234,7 @@ void scale_row_asm_transparent( ubyte * sbits, ubyte * dbits, int width, fix u, for (i=0; i> 16 ]; - if ( c!=TRANSPARENCY_COLOR) + if ( c!=TRANSPARENCY_COLOR) *dbits = c; dbits++; u += du; @@ -372,50 +287,26 @@ NonTransparent: } else { for ( i=0; i= 0); - //Int3(); //this should be checked in higher-level routine - return; - } - for (y=y0; y<=y1; y++ ) { if ( f2i(v) != last_row ) { last_row = f2i(v); @@ -429,7 +320,7 @@ void scale_bitmap_c_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, in #define FIND_SCALED_NUM(x,x0,x1,y0,y1) (fixmuldiv((x)-(x0),(y1)-(y0),(x1)-(x0))+(y0)) // Scales bitmap, bp, into vertbuf[0] to vertbuf[1] -void scale_bitmap(grs_bitmap *bp, grs_point *vertbuf, int orientation ) +void scale_bitmap(grs_bitmap *bp, grs_point *vertbuf ,int orientation) { grs_bitmap * dbp = &grd_curcanv->cv_bitmap; fix x0, y0, x1, y1; @@ -505,16 +396,22 @@ void scale_bitmap(grs_bitmap *bp, grs_point *vertbuf, int orientation ) dtemp = f2i(clipped_u1)-f2i(clipped_u0); +#if 0 + if ( bp->bm_flags & BM_FLAG_RLE ) + scale_bitmap_c_rle(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 ); + else + scale_bitmap_c(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 ); +#endif if ( bp->bm_flags & BM_FLAG_RLE ) { if ( (dtemp < (f2i(clipped_x1)-f2i(clipped_x0))) && (dtemp>0) ) - scale_up_bitmap_rle(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1, orientation ); + scale_up_bitmap_rle(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 ); else - scale_bitmap_c_rle(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1, orientation ); + scale_bitmap_c_rle(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 ); } else { if ( (dtemp < (f2i(clipped_x1)-f2i(clipped_x0))) && (dtemp>0) ) - scale_up_bitmap(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1, orientation ); + scale_up_bitmap(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 ); else - scale_bitmap_c(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1, orientation ); + scale_bitmap_c(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 ); } } diff --git a/2d/tmerge.c b/2d/tmerge.c index d10e7fc5..5d7362f6 100644 --- a/2d/tmerge.c +++ b/2d/tmerge.c @@ -1,10 +1,5 @@ -/* $Id: tmerge.c,v 1.4 2002-10-10 18:55:32 btb Exp $ */ -/* - * - * tmerge.c - C Texture merge routines for use with D1X - * Ripped from ldescent by - * - */ +// tmerge.c - C Texture merge routines for use with D1X +// Ripped from ldescent by #ifdef HAVE_CONFIG_H #include @@ -14,27 +9,27 @@ void gr_merge_textures( ubyte * lower, ubyte * upper, ubyte * dest ) { - int x,y; - ubyte c; - for (y=0;y<64;y++) for (x=0;x<64;x++) { + int x,y; + ubyte c; + for (y=0;y<64;y++) for (x=0;x<64;x++) { c=upper[64*y+x]; if (c==TRANSPARENCY_COLOR) c=lower[64*y+x]; *dest++=c; - } + } } void gr_merge_textures_1( ubyte * lower, ubyte * upper, ubyte * dest ) { - int x,y; - ubyte c; + int x,y; + ubyte c; for (y=0; y<64; y++ ) - for (x=0; x<64; x++ ) { + for (x=0; x<64; x++ ) { c = upper[ 64*x+(63-y) ]; if (c==TRANSPARENCY_COLOR) c = lower[ 64*y+x ]; *dest++ = c; - } + } } void gr_merge_textures_2( ubyte * lower, ubyte * upper, ubyte * dest ) @@ -42,7 +37,7 @@ void gr_merge_textures_2( ubyte * lower, ubyte * upper, ubyte * dest ) int x,y; ubyte c; for (y=0; y<64; y++ ) - for (x=0; x<64; x++ ) { + for (x=0; x<64; x++ ) { c = upper[ 64*(63-y)+(63-x) ]; if (c==TRANSPARENCY_COLOR) c = lower[ 64*y+x ]; @@ -55,7 +50,7 @@ void gr_merge_textures_3( ubyte * lower, ubyte * upper, ubyte * dest ) int x,y; ubyte c; for (y=0; y<64; y++ ) - for (x=0; x<64; x++ ) { + for (x=0; x<64; x++ ) { c = upper[ 64*(63-x)+y ]; if (c==TRANSPARENCY_COLOR) c = lower[ 64*y+x ]; diff --git a/2d/tmerge_a.asm b/2d/tmerge_a.asm index d80b0626..dca02bc0 100644 --- a/2d/tmerge_a.asm +++ b/2d/tmerge_a.asm @@ -1,4 +1,3 @@ -; $Id: tmerge_a.asm,v 1.3 2002-10-10 18:39:45 btb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -7,7 +6,7 @@ ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE ;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. [BITS 32] @@ -29,7 +28,7 @@ global gr_merge_textures, gr_merge_textures_1, gr_merge_textures_2, gr_merge_tex ; for (y=0; y<64; y++ ) ; for (x=0; x<64; x++ ) { ; c = top_data[ 64*x+(63-y) ]; -; if (c==TRANSPARENCY_COLOR) +; if (c==255) ; c = bottom_data[ 64*y+x ]; ; *dest_data++ = c; ; } @@ -39,7 +38,7 @@ global gr_merge_textures, gr_merge_textures_1, gr_merge_textures_2, gr_merge_tex ; for (y=0; y<64; y++ ) ; for (x=0; x<64; x++ ) { ; c = top_data[ 64*(63-y)+(63-x) ]; -; if (c==TRANSPARENCY_COLOR) +; if (c==255) ; c = bottom_data[ 64*y+x ]; ; *dest_data++ = c; ; } @@ -49,7 +48,7 @@ global gr_merge_textures, gr_merge_textures_1, gr_merge_textures_2, gr_merge_tex ; for (y=0; y<64; y++ ) ; for (x=0; x<64; x++ ) { ; c = top_data[ 64*(63-x)+y ]; -; if (c==TRANSPARENCY_COLOR) +; if (c==255) ; c = bottom_data[ 64*y+x ]; ; *dest_data++ = c; ; } @@ -72,7 +71,7 @@ gr_merge_textures: mov ebp, edx mov edi, ebx - mov bl, TRANSPARENCY_COLOR + mov bl, 255 mov bh, bl and ebx, 0ffffh and edx, 0ffffh @@ -141,7 +140,7 @@ gr_merge_textures_1: mov edx, [esp+24] mov ebx, [esp+28] - mov ch, TRANSPARENCY_COLOR ; transparent color, stick in a register, is this faster? + mov ch, 255 ; transparent color, stick in a register, is this faster? mov esi, 63 ; esi will be the offset to the current pixel mov [row_count], esi @@ -193,7 +192,7 @@ gr_merge_textures_2: mov edx, [esp+24] mov ebx, [esp+28] - mov ch, TRANSPARENCY_COLOR ; transparent color, stick in a register, is this faster? + mov ch, 255 ; transparent color, stick in a register, is this faster? mov esi, 63 + 64*63 ; esi will be the offset to the current pixel @@ -235,7 +234,7 @@ gr_merge_textures_3: mov edx, [esp+24] mov ebx, [esp+28] - mov ch, TRANSPARENCY_COLOR ; transparent color, stick in a register, is this faster? + mov ch, 255 ; transparent color, stick in a register, is this faster? mov esi, 64*63 ; esi will be the offset to the current pixel mov dword [row_count], 64 diff --git a/3d/.cvsignore b/3d/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/3d/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/3d/Makefile.am b/3d/Makefile.am index e91b648c..fcdb3ff5 100644 --- a/3d/Makefile.am +++ b/3d/Makefile.am @@ -1,5 +1,5 @@ noinst_LIBRARIES = lib3d.a -INCLUDES = -I $(top_srcdir)/include +INCLUDES = -I $(top_srcdir)/includes lib3d_a_SOURCES = \ clipper.c globvars.c interp.c points.c setup.c \ diff --git a/3d/clipper.c b/3d/clipper.c index d36845e5..14d3f133 100644 --- a/3d/clipper.c +++ b/3d/clipper.c @@ -1,4 +1,3 @@ -/* $Id: clipper.c,v 1.5 2002-10-03 03:46:34 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ diff --git a/3d/clipper.h b/3d/clipper.h index 41e22e9c..fa104ba0 100644 --- a/3d/clipper.h +++ b/3d/clipper.h @@ -1,4 +1,3 @@ -/* $Id: clipper.h,v 1.2 2002-07-17 21:55:19 bradleyb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,10 +11,16 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/3d/clipper.h,v $ + * $Revision: 1.1.1.1 $ + * $Author: bradleyb $ + * $Date: 2001-01-19 03:29:58 $ * * Header for clipper.c * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 1999/06/14 21:57:51 donut + * Import of d1x 1.37 source. * * Revision 1.1 1995/05/05 08:50:13 allender * Initial revision @@ -26,6 +31,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. * */ + + #ifndef _CLIPPER_H #define _CLIPPER_H diff --git a/3d/draw.c b/3d/draw.c index 46cdab0b..ea19ea02 100644 --- a/3d/draw.c +++ b/3d/draw.c @@ -1,4 +1,3 @@ -/* $Id: draw.c,v 1.4 2002-07-17 21:55:19 bradleyb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -22,7 +21,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: draw.c,v 1.4 2002-07-17 21:55:19 bradleyb Exp $"; +static char rcsid[] = "$Id: draw.c,v 1.3 2001-10-31 03:54:50 bradleyb Exp $"; #endif #include "error.h" diff --git a/3d/globvars.c b/3d/globvars.c index 3debcf53..cd389cd3 100644 --- a/3d/globvars.c +++ b/3d/globvars.c @@ -1,4 +1,3 @@ -/* $Id: globvars.c,v 1.4 2002-07-17 21:55:19 bradleyb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,10 +11,22 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/3d/globvars.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-31 03:54:50 $ * * Global variables for 3d * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/01/31 15:17:48 bradleyb + * Makefile and conf.h fixes + * + * Revision 1.1.1.1 2001/01/19 03:29:58 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 21:57:45 donut + * Import of d1x 1.37 source. * * Revision 1.2 1995/09/13 11:30:47 allender * added fCanv_w2 and vCanv_h2 for PPC implementation @@ -34,7 +45,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: globvars.c,v 1.4 2002-07-17 21:55:19 bradleyb Exp $"; +static char rcsid[] = "$Id: globvars.c,v 1.3 2001-10-31 03:54:50 bradleyb Exp $"; #endif #include "3d.h" diff --git a/3d/globvars.h b/3d/globvars.h index 3dfa89b9..62e7850f 100644 --- a/3d/globvars.h +++ b/3d/globvars.h @@ -1,4 +1,3 @@ -/* $Id: globvars.h,v 1.2 2002-07-17 21:55:19 bradleyb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,10 +11,16 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/3d/globvars.h,v $ + * $Revision: 1.1.1.1 $ + * $Author: bradleyb $ + * $Date: 2001-01-19 03:29:58 $ * * Private (internal) header for 3d library * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 1999/06/14 21:57:51 donut + * Import of d1x 1.37 source. * * Revision 1.2 1995/09/13 11:31:19 allender * added fCanv_w2 and vCanv_h2 for PPC implementation @@ -29,6 +34,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. * */ + + #ifndef _GLOBVARS_H #define _GLOBVARS_H diff --git a/3d/instance.c b/3d/instance.c index fbd2e4f9..77154361 100644 --- a/3d/instance.c +++ b/3d/instance.c @@ -1,4 +1,3 @@ -/* $Id: instance.c,v 1.4 2002-07-17 21:55:19 bradleyb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,10 +11,22 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/3d/instance.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-31 03:54:50 $ * * Instancing routines * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/01/31 15:17:48 bradleyb + * Makefile and conf.h fixes + * + * Revision 1.1.1.1 2001/01/19 03:29:58 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 21:57:45 donut + * Import of d1x 1.37 source. * * Revision 1.2 1995/06/12 12:36:57 allender * fixed bug where g3_start_instance_angles recursively called itself @@ -33,6 +44,10 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #endif +#ifdef RCS +static char rcsid[] = "$Id: instance.c,v 1.3 2001-10-31 03:54:50 bradleyb Exp $"; +#endif + #include #include "error.h" diff --git a/3d/interp.asm b/3d/interp.asm index b46991d6..f459abbf 100644 --- a/3d/interp.asm +++ b/3d/interp.asm @@ -1,4 +1,3 @@ -; $Id: interp.asm,v 1.2 2002-07-17 21:55:19 bradleyb Exp $ ; THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ; SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ; END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -25,7 +24,7 @@ _DATA segment dword public USE32 'DATA' -rcsid db "$Id: interp.asm,v 1.2 2002-07-17 21:55:19 bradleyb Exp $" +rcsid db "$Id: interp.asm,v 1.1.1.1 2001-01-19 03:29:58 bradleyb Exp $" align 4 ;table with address for each opcode diff --git a/3d/interp.c b/3d/interp.c index 842aa5c3..7edd2719 100644 --- a/3d/interp.c +++ b/3d/interp.c @@ -1,4 +1,3 @@ -/* $Id: interp.c,v 1.14 2003-03-19 19:21:34 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,15 +7,30 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * + * $Source: /cvs/cvsroot/d2x/3d/interp.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-31 03:54:50 $ + * * Polygon object interpreter + * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/10/19 08:06:20 bradleyb + * Partial application of linux/alpha patch. Courtesy of Falk Hueffner + * + * Revision 1.2 2001/01/31 15:17:48 bradleyb + * Makefile and conf.h fixes + * + * Revision 1.1.1.1 2001/01/19 03:29:58 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 21:57:47 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.4 1995/10/10 22:20:09 allender * new morphing code from Matt * @@ -31,8 +45,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. * * Revision 1.1 1995/04/17 06:44:33 matt * Initial revision - * - * + * + * */ #ifdef HAVE_CONFIG_H @@ -40,36 +54,34 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: interp.c,v 1.14 2003-03-19 19:21:34 btb Exp $"; +static char rcsid[] = "$Id: interp.c,v 1.4 2001-10-31 03:54:50 bradleyb Exp $"; #endif #include #include "error.h" -#include "interp.h" +#include "3d.h" #include "globvars.h" #include "gr.h" -#include "byteswap.h" -#include "u_mem.h" -#define OP_EOF 0 //eof -#define OP_DEFPOINTS 1 //defpoints -#define OP_FLATPOLY 2 //flat-shaded polygon -#define OP_TMAPPOLY 3 //texture-mapped polygon -#define OP_SORTNORM 4 //sort by normal -#define OP_RODBM 5 //rod bitmap -#define OP_SUBCALL 6 //call a subobject -#define OP_DEFP_START 7 //defpoints with start -#define OP_GLOW 8 //glow value for next poly +#define OP_EOF 0 //eof +#define OP_DEFPOINTS 1 //defpoints +#define OP_FLATPOLY 2 //flat-shaded polygon +#define OP_TMAPPOLY 3 //texture-mapped polygon +#define OP_SORTNORM 4 //sort by normal +#define OP_RODBM 5 //rod bitmap +#define OP_SUBCALL 6 //call a subobject +#define OP_DEFP_START 7 //defpoints with start +#define OP_GLOW 8 //glow value for next poly -//#define N_OPCODES (sizeof(opcode_table) / sizeof(*opcode_table)) +#define N_OPCODES (sizeof(opcode_table) / sizeof(*opcode_table)) -#define MAX_POINTS_PER_POLY 25 +#define MAX_POINTS_PER_POLY 25 -short highest_texture_num; -int g3d_interp_outline; +short highest_texture_num; +int g3d_interp_outline; -g3s_point *Interp_point_list = NULL; +g3s_point *Interp_point_list=NULL; #define MAX_INTERP_COLORS 100 @@ -86,7 +98,6 @@ void g3_set_interp_points(g3s_point *pointlist) #define w(p) (*((short *) (p))) #define wp(p) ((short *) (p)) -#define fp(p) ((fix *) (p)) #define vp(p) ((vms_vector *) (p)) void rotate_point_list(g3s_point *dest,vms_vector *src,int n) @@ -101,245 +112,6 @@ g3s_point *point_list[MAX_POINTS_PER_POLY]; int glow_num = -1; -#ifdef WORDS_BIGENDIAN -void short_swap(short *s) -{ - *s = SWAPSHORT(*s); -} - -void fix_swap(fix *f) -{ - *f = (fix)SWAPINT((int)*f); -} - -void vms_vector_swap(vms_vector *v) -{ - fix_swap(fp(&v->x)); - fix_swap(fp(&v->y)); - fix_swap(fp(&v->z)); -} - -void fixang_swap(fixang *f) -{ - *f = (fixang)SWAPSHORT((short)*f); -} - -void vms_angvec_swap(vms_angvec *v) -{ - fixang_swap(&v->p); - fixang_swap(&v->b); - fixang_swap(&v->h); -} - -void swap_polygon_model_data(ubyte *data) -{ - int i; - short n; - g3s_uvl *uvl_val; - ubyte *p = data; - - short_swap(wp(p)); - - while (w(p) != OP_EOF) { - switch (w(p)) { - case OP_DEFPOINTS: - short_swap(wp(p + 2)); - n = w(p+2); - for (i = 0; i < n; i++) - vms_vector_swap(vp((p + 4) + (i * sizeof(vms_vector)))); - p += n*sizeof(struct vms_vector) + 4; - break; - - case OP_DEFP_START: - short_swap(wp(p + 2)); - short_swap(wp(p + 4)); - n = w(p+2); - for (i = 0; i < n; i++) - vms_vector_swap(vp((p + 8) + (i * sizeof(vms_vector)))); - p += n*sizeof(struct vms_vector) + 8; - break; - - case OP_FLATPOLY: - short_swap(wp(p+2)); - n = w(p+2); - vms_vector_swap(vp(p + 4)); - vms_vector_swap(vp(p + 16)); - short_swap(wp(p+28)); -#ifdef MACINTOSH - // swap the colors 0 and 255 here!!!! - if (w(p+28) == 0) - w(p+28) = 255; - else if (w(p+28) == 255) - w(p+28) = 0; -#endif - for (i=0; i < n; i++) - short_swap(wp(p + 30 + (i * 2))); - p += 30 + ((n&~1)+1)*2; - break; - - case OP_TMAPPOLY: - short_swap(wp(p+2)); - n = w(p+2); - vms_vector_swap(vp(p + 4)); - vms_vector_swap(vp(p + 16)); - for (i=0;iu); - fix_swap(&uvl_val->v); - } - short_swap(wp(p+28)); - for (i=0;ix - View_position.x),View_matrix.fvec.x); diff --git a/3d/rod.c b/3d/rod.c index f742b691..62c1521c 100644 --- a/3d/rod.c +++ b/3d/rod.c @@ -1,4 +1,3 @@ -/* $Id: rod.c,v 1.4 2002-07-17 21:55:19 bradleyb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,10 +11,25 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/3d/rod.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-31 03:54:51 $ * * Rod routines * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/01/31 15:17:48 bradleyb + * Makefile and conf.h fixes + * + * Revision 1.1.1.1 2001/01/19 03:29:58 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.2 1999/09/21 04:05:55 donut + * mostly complete OGL implementation (still needs bitmap handling (reticle), and door/fan textures are corrupt) + * + * Revision 1.1.1.1 1999/06/14 21:57:50 donut + * Import of d1x 1.37 source. * * Revision 1.2 1995/09/13 11:31:46 allender * removed checkmuldiv in PPC implemenation @@ -34,7 +48,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: rod.c,v 1.4 2002-07-17 21:55:19 bradleyb Exp $"; +static char rcsid[] = "$Id: rod.c,v 1.3 2001-10-31 03:54:51 bradleyb Exp $"; #endif #include "3d.h" diff --git a/3d/setup.c b/3d/setup.c index 5917a886..58ee3438 100644 --- a/3d/setup.c +++ b/3d/setup.c @@ -1,4 +1,3 @@ -/* $Id: setup.c,v 1.5 2003-03-19 19:21:34 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,10 +11,28 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/3d/setup.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-31 03:54:51 $ * * Setup for 3d library * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/01/31 15:17:48 bradleyb + * Makefile and conf.h fixes + * + * Revision 1.1.1.1 2001/01/19 03:29:58 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.3 1999/10/07 02:27:14 donut + * OGL includes to remove warnings + * + * Revision 1.2 1999/09/21 04:05:55 donut + * mostly complete OGL implementation (still needs bitmap handling (reticle), and door/fan textures are corrupt) + * + * Revision 1.1.1.1 1999/06/14 21:57:50 donut + * Import of d1x 1.37 source. * * Revision 1.4 1995/10/11 00:27:04 allender * bash free_num_points to 0 @@ -40,7 +57,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: setup.c,v 1.5 2003-03-19 19:21:34 btb Exp $"; +static char rcsid[] = "$Id: setup.c,v 1.3 2001-10-31 03:54:51 bradleyb Exp $"; #endif #include @@ -54,8 +71,6 @@ static char rcsid[] = "$Id: setup.c,v 1.5 2003-03-19 19:21:34 btb Exp $"; #ifdef OGL #include "ogl_init.h" -#else -#include "texmap.h" // for init_interface_vars_to_assembler() #endif //initialize the 3d system @@ -68,6 +83,8 @@ void g3_init(void) //close down the 3d system void g3_close(void) {} +extern void init_interface_vars_to_assembler(void); + //start the frame void g3_start_frame(void) { diff --git a/COPYING b/COPYING index 542c0315..cbceffdb 100644 --- a/COPYING +++ b/COPYING @@ -1,5 +1,4 @@ -The Descent 2 source code was released by Parallax with this license: ---------------------------------------------------------------------------- +Original Descent 2 code license: THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -14,58 +13,13 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. We make no warranties as to the usability or correctness of this code. ---------------------------------------------------------------------------- +Additional restrictions: +Any executable created using files or code taken from this source tree +MUST be open source. By using this source, you are agreeing to this +term, in the interest of the descent and descent programming +communities. The only exception is if the writer of the original +source gives explicit permission for the code to be used otherwise. -The modifications to Descent 2 which make up d2x are covered by the -same license as the d1x project, given below. +Portions of d2x code are taken from the d1x project. This code is +covered by the d1x license, in the file license.txt -There used to be an additional clause here, but it was functionally -equivalent to the d1x license, and the d1x license would override it -anyway, so it has been removed. - ---------------------------------------------------------------------------- - -D1x License - -Preamble --------- - -This License is designed to allow the Descent programming community to -continue to have the Descent source open and available to anyone. - -Original Parallax License -------------------------- - -THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX -SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO -END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A -ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS -IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS -SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE -FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE -CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. - -We make no warranties as to the usability or correctness of this code. -------------------------- - -The D1x project is the combination of the original Parallax code and the -modifications and additions made to source code. While the original code is -only under the Original Parallax License the D1x project contains original -code that was not made by Parallax. This ADDED and/or CHANGED code has the -following added restrictions: - -1) By using this source you are agreeing to these terms. - -2) D1x and derived works may only be modified if ONE of the following is done: - - a) The modified version is placed under this license. The source - code used to create the modified version is freely and publicly - available under this license. - - b) The modified version is only used by the developer. - -3) D1X IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index ab45b24c..00000000 --- a/ChangeLog +++ /dev/null @@ -1,1964 +0,0 @@ -0.2.4: - -2003-05-12 Bradley Bell - - * configure.ac: increment version number - - * main/bm.c: use con_printf for exit model warnings - - * configure.ac: must check for timespec after setting -mno-cygwin - - * main/inferno.c: added -nohogdir and -userdir options - - * NEWS, main/titles.c: use briefings with no extension - -0.2.3: - -2003-04-30 Bradley Bell - - * configure.ac: have to include time.h when checking for nanosleep - - * configure.ac, libmve/mveplay.c: use autoconf to check for struct - timespec - - * Makefile.am, NEWS, README, configure.ac: fix linking bug, - increment version number - - * main/Makefile.am: make dist fix - -0.2.2: - -2003-04-29 Bradley Bell - - * configure.ac, 2d/2dsline.c, main/automap.c, libmve/mveplay.c: - fixes for OS X 10.2 - -2003-04-24 Bradley Bell - - * configure.ac: increment version number - - * main/inferno.c: redeclare main() 'the SDL way', make sure SDL.h - is always included. - -2003-04-24 Ingo van Lil - - * main/render.c: fix misspellings of NDEBUG - -0.2.1: - -2003-04-14 Bradley Bell - - * cfile/cfile.c: prefer files from d2 hog over d1 hog - -2003-04-11 Bradley Bell - - * main/automap.c, main/gamemine.c, main/menu.c: fix compiler - warnings - -0.2.0: - -2003-04-11 Bradley Bell - - * libmve/mveplay.c: use _sleep instead of sleep on win32 - - * Makefile.am, README, README.utils, arch/sdl/digi.c, - arch/sdl/joy.c, arch/win32/Makefile.am, include/byteswap.h, - include/cfile.h, include/error.h, libmve/Makefile.am, - libmve/decoders.h, main/Makefile.am, main/endlevel.c, - main/endlevel.h, main/playsave.c, misc/fileutil.c: - utilities/Makefile.am: comments/formatting/dist problems - - * configure.ac: use different defines for os x - -2003-04-07 Bradley Bell - - * include/error.h, misc/error.c: put some old stuff back in, - eliminate duplicate error messages - - * main/text.c: don't die on text not found - formatting - - * main/inferno.c: print some useful info if hog not found, allow - -help to work if no text available - -2003-04-07 Steffen Pohle - - * arch/linux/Makefile.am: revert to previous version, so linux - joystick works - -2003-04-03 Bradley Bell - - * main/endlevel.c: fixed exit model scheme yet again - -2003-04-02 Bradley Bell - - * misc/error.c: call Int3 on Assert - - * main/cntrlcen.c, main/cntrlcen.h, main/gamesave.c: modified - trigger reader - - * main/wall.c: don't die when trying to toggle nonexistent - segment... vertigo level 10 is buggy! - - * main/gamemine.c: comments/formatting - -2003-03-31 Micah J. Lieske - - * arch/dos/digimm.c, arch/sdl/digi.c, arch/win32/digi.c, - main/inferno.c: Allow use of 22K sound samples - -2003-03-29 Bradley Bell - - * arch/ogl/gr.c: default to bitmapped reticle - - * main/bm.c, main/endlevel.c, main/piggy.c, main/piggy.h, - main/polyobj.c: rewrote endlevel stuff to reread exit model info - every time - - * arch/sdl/joy.c: fixed text seen for hats in control config - screen - -2003-03-28 Bradley Bell - - * main/bm.c: heh, model nums in vertigo are hardcoded, - N_D2_POLYGON_MODELS can't change - - * configure.ac, include/d1x.xpm, include/descent.xpm, - arch/ogl/sdlgl.c, arch/sdl/gr.c: enabled setting icon with - SDL_image - -2003-03-27 Bradley Bell - - * main/text.h: fixed text references for hat directions - - * arch/ogl/Makefile.am: oops, can't get rid of main INCLUDE yet... - -2003-03-26 Bradley Bell - - * main/playsave.c: make d2x keys backward compatible - -2003-03-26 Micah J. Lieske - - * arch/sdl/event.c, arch/sdl/joy.c: added hat support for sdl - joysticks - -2003-03-26 Bradley Bell - - * main/piggy.c: fix crash when d1 data not present - - * main/gamecntl.c, main/kconfig.c, main/playsave.c: fix d2x keys, - read/write from plr file - - * main/ai.h, main/collide.c, main/escort.c, main/escort.h, - main/fuelcen.c, main/gamecntl.c, main/playsave.c, main/powerup.c: - added escort.h header - -2003-03-25 Bradley Bell - - * main/bm.c, main/piggy.c, main/piggy.h, main/gameseq.c: added - D1_PIGFILE ("descent.pig") macro - - * main/bm.c, main/piggy.c, main/piggy.h: ability to load exit - models from d1 pig file - - * main/bm.c, main/bm.h, main/endlevel.c, main/piggy.c, - main/piggy.h: ability to load exit model bitmaps (or any bitmap, - really) from d1 pig file - -2003-03-23 Bradley Bell - - * main/bm.c: stop extra robots from overwriting exit models - - * include/ogl_init.h: increased OGL_TEXTURE_LIST_SIZE so the - texture list doesn't get full - - * main/bm.c: fix mem leak when reading extra robots - -2003-03-21 Bradley Bell - - * main/menu.c: Added option to set movie resolution (mostly works) - -2003-03-21 Martin Schaffner - - * main/gameseq.c, main/piggy.c, main/piggy.h: move bitmap - replacement functions to piggy.c - - * main/gameseq.c: attempt to support mac d1 descent.pig - - * main/bm.c: fix mem leak - - * main/gameseq.c: fix bug: when opening d1 level 1 with oem data - files, both d1 and d2 oem briefing where showed - - * main/inferno.c, main/movie.c: Change the default movie - resolution to "high", implement the option -lowresmovies - -2003-03-20 Bradley Bell - - * arch/sdl/rbaudio.c, main/songs.c: cd detection works now - - * main/piggy.c: comments - -2003-03-20 Martin Schaffner - - * main/gameseq.c: delete duplicate function - - * 2d/rle.c: fix color swapping on big endian of big rle bitmaps - -2003-03-19 Bradley Bell - - * arch/sdl/rbaudio.c, include/rbaudio.h: starting d2 cd detection - (cddb discid) support - - * arch/sdl/digi.c, main/kludge.c: implemented - digi_link_sound_to_object3 for looping sounds, other looping stuff - - * arch/sdl/gr.c: removing dependencies on stuff in main/ - - * arch/linux/Makefile.am, arch/linux/init.c, - arch/linux/linuxnet.c, arch/linux/include/ukali.h, - arch/ogl/Makefile.am, main/inferno.c: moved joy_init back to main, - other header cleanups - - * arch/win32/ipx_win.c, configure.ac: ipx on win32 fixed! - -2003-03-19 Martin Schaffner - - * 2d/rle.c, include/gr.h, include/rle.h, main/bm.c, main/bm.h, - main/gamemine.c, main/gamemine.h, main/gameseq.c, main/piggy.c, - main/piggy.h, main/wall.c, main/wall.h: if descent.pig available, - load d1 textures for d1 levels - -2003-03-19 Bradley Bell - - * 2d/font.c, 2d/palette.c, 3d/interp.c, 3d/setup.c, - arch/sdl/rbaudio.c, include/texmap.h, libmve/decoder16.c, - libmve/decoder8.c, libmve/decoders.h, libmve/mveplay.c, - texmap/ntmap.c, texmap/texmapl.h: header/extern declaration - housekeeping - - * README: added some OS X info - -2003-03-17 Bradley Bell - - * main/newdemo.c: simplify DEMO_FILENAME macro - - * main/console.c, main/game.c: enable experimental console support - - * main/gamerend.c: fixed location of fps meter in multi - -2003-03-16 Bradley Bell - - * main/menu.c, main/newdemo.c, main/newdemo.h, main/newmenu.c: - also look in shared data dir for demos - - * main/newdemo.c, main/newdemo.h: comments/formatting - -2003-03-15 Christopher Thielen - - * main/kludge.c: set CDROM_dir back to "." - tricks game into - thinking d2 cd is always present - -2003-03-15 Bradley Bell - - * 2d/font.c, main/credits.c, main/scores.c: fixed opengl credits, - scores - - * arch/sdl/rbaudio.c: formatting, enabled volume control under - linux - - * arch/ogl/gr.c: fixed dark font bug by calling gr_set_mode from - gr_init. don't really know why this works, though - -2003-03-14 Bradley Bell - - * main/gameseq.c: fix Bitmap_replacement_data mem leakage - - * unused/bios/rbaudio.h: removed duplicate file - -2003-03-14 Christopher Thielen - - * arch/sdl/rbaudio.c: stop cd audio when exiting - -2003-03-14 Micah J. Lieske - - * main/gamecntl.c: add comments to the "only matt knows" cheats - -2003-03-14 Martin Schaffner - - * main/gamemine.c: formatting, better texture conversion for d1 - levels - -2003-03-14 Bradley Bell - - * main/piggy.c: must swap all mac version pigfiles - - * main/ai.c, main/ai.h, main/bm.h, main/crypt.c, main/joydefs.h, - main/multi.c: formatting, minor cleanups - - * 2d/rle.c: need to swap line_size on bigendian machines - - * main/mission.c, main/mission.h: detect mac full version hogfile - -2003-03-13 Bradley Bell - - * arch/sdl/joydefs.c, main/kconfig.c, main/kconfig.h, main/menu.c: - added joy/mouse sensitivity slider, increased range to 16, and - added d2x keys menu - - * main/Makefile.am, main/joydefs.c, main/old/joydefs.c: moved old - joydefs to main - - * arch/linux/Makefile.am: removed extra backslash - - * TODO, installation.txt: updated some documentation - - * main/gamecntl.c, main/menu.c, main/menu.h: added "d2x options" - menu, with maxfps option - -2003-03-12 Bradley Bell - - * main/game.c, main/game.h, main/inferno.c: added -maxfps option - - * arch/linux/alsadigi.c, arch/linux/findfile.c, - arch/linux/hmiplay.c, arch/linux/init.c, arch/linux/ipx_bsd.c, - arch/linux/ipx_kali.c, arch/linux/ipx_lin.c, arch/linux/ipx_udp.c, - arch/linux/joydefs.c, arch/linux/ukali.c, arch/linux/include, - arch/linux/include/ipx_bsd.h, arch/linux/include/ipx_drv.h, - arch/linux/include/ipx_hlpr.h, arch/linux/include/ipx_kali.h, - arch/linux/include/ipx_ld.h, arch/linux/include/ipx_lin.h, - arch/linux/include/ipx_udp.h, arch/linux/include/joystick.h, - arch/linux/include/music.h, arch/linux/include/serial.h, - arch/linux/include/ukali.h: formatting - -2003-03-11 Chris Arena - - * main/menu.c: fixed brightness slider - -2003-03-01 Bradley Bell - - * main/piggy.c, main/titles.c: d1 briefing text fixed, spinning - robots and animated bitmaps work, but colors are messed up - -2003-02-28 Bradley Bell - - * main/player.h: whitespace - - * main/automap.c, main/cntrlcen.c, main/collide.c, - main/gamerend.c: use Builtin_mission_num instead of 0 (if - descent.hog is present, d1 becomes mission 0) - - * configure.ac, arch/win32/Makefile.am, arch/win32/ipx_drv.h, - arch/win32/ipx_win.c, arch/win32/mingw_init.c, - arch/win32/winnet.c: MinGW compiles with network enabled again, - but still doesn't work - - * NEWS: Updated - -2003-02-28 Bradley Bell - - * 2d/pcx.c, arch/ogl/gr.c, libmve/mveplay.c, main/gameseq.c, - main/inferno.c, main/menu.c, main/movie.c, main/newmenu.c: Fixed - many opengl glitches - -2003-02-27 Bradley Bell - - * main/Makefile.am, main/gamesave.c, main/hoard.c, main/hoard.h, - main/inferno.c, main/menu.c, main/mission.c, main/mission.h, - main/network.c, main/network.h: noted that hoard.ham is only needed - for multiplayer HOARD games, and should not be equated with - "vertigo". put HoardEquipped() back in network.c. - - * arch/ggi/key.c, arch/sdl/key.c, arch/svgalib/key.c, - include/d_delay.h, main/automap.c, main/game.c, main/kconfig.c, - main/multi.c, main/newdemo.c, misc/Makefile.am, misc/d_delay.c: - use timer_delay instead of d_delay - -2003-02-27 Martin Schaffner - - * main/render.c: added replacement qsort for solaris - -2003-02-26 Bradley Bell - - * main/gamemine.c: texture conversion for d1 shareware - -2003-02-26 Martin Schaffner - - * main/gamemine.c: better texture conversion for d1 levels - -2003-02-26 Micah J. Lieske - - * main/kconfig.c: fix joystick support under MinGW - -2003-02-26 Bradley Bell - - * main/playsave.c: fix swapping glitch - - * configure.ac, readme.txt: clean stuff up, getting ready for - 0.2.0 release - - * main/titles.c: begin support for rendering spinning robots in - briefings - - * main/mission.c, main/mission.h: load d1 oem mission, d1 v1.0 - mission - - * main/gamemine.c: load d1 shareware levels! - -2003-02-25 Bradley Bell - - * TODO: update - - * autogen.sh: add warning about old auto* versions, use - automake --copy - -2003-02-24 Bradley Bell - - * main/gameseq.c, main/movies.c, main/titles.c: Descent I - briefings mostly working - * main/movie.c, main/titles.c: fixed some more briefing glitches - -2003-02-23 Bradley Bell - - * main/movie.c: fixed crash when using shareware data files - without -nohires - * arch/sdl/digi.c: fix crash on non-existent sounds - (i.e. shareware data) - -2003-02-22 Bradley Bell - - * main/titles.c: fixed fullscreen toggle in briefings - -2003-02-21 Bradley Bell - - * configure.ac: check for mingw when enabling nasm - * main/playsave.c: enable loading player files of either byte - order - -2003-02-20 Bradley Bell - - * main/bm.c, main/bm.h, main/endlevel.c: fixed up endlevel stuff - * arch/sdl/digi.c, main/kludge.c: oops, meant to say: fixed bug - #343, not "rest of solution to bug #344" - * arch/sdl/timer.c, include/timer.h: revert to more accurate - timers - * main/kludge.c: partial solution to bug #344 - * Makefile.am, tools/cvs2cl/cvs2cl.pl: get rid of cvs2cl.pl - * compilerdefs.txt: added linux/mips info - * ChangeLog: clean up changelog - -2003-02-19 Bradley Bell - - * libmve/mveplay.c: os x needs nanosleep prototype. - -2003-02-18 Bradley Bell - - * .cvsignore, libmve/.cvsignore: added files to .cvsignore - * include/libmve.h, libmve/mveplay.c, main/movie.c: added function - to disable/enable audio - * libmve/: mve_main.c, mveplay.c: bigendian fixes - * main/: movie.h, titles.c: make sure movie's palette is set before - writing briefing text. Fixes bug #359 - * libmve/mveplay.c: make MVE_rmStepMovie play a full frame instead - of a chunk - * misc/: args.c, byteswap.c, d_delay.c, d_io.c, dos_disk.h, - error.c, hash.c, parsarg.c, parsarg.h, strio.c, strutil.c: - formatting - * maths/: fix.asm, rand.c, tables.c, vecmat.c, vecmata.asm: - formatting - * texmap/: ntmap.c, scanline.c, scanline.h, texmapl.h, - tmap_flt.asm, tmap_inc.asm, tmap_lin.asm, tmap_ll.asm, - tmap_per.asm, tmapfade.asm, tmapflat.c, tmappent.S, tmapppro.S: - formatting - * include/libmve.h: blah - -2003-02-18 Martin Schaffner - - * main/render.c: 2nd attempt to fix solaris qsort bug - -2003-02-18 Bradley Bell - - * configure.ac, include/pstypes.h: put alignment detection in - configure.ac - -2003-02-17 Bradley Bell - - * Makefile.am, README.utils, configure.ac, include/libmve.h, - include/mve_audio.h, include/mvelib.h, libmve/Makefile.am, - libmve/decoder16.c, libmve/decoder8.c, libmve/mve_audio.c, - libmve/mve_audio.h, libmve/mve_main.c, libmve/mvelib.c, - libmve/mvelib.h, libmve/mveplay.c, main/Makefile.am, - main/decoder16.c, main/decoder8.c, main/movie.c, main/mve_audio.c, - main/mve_main.c, main/mvelib.c, main/mveplay.c, main/mveplay.h: - moved mve stuff to separate subdir - * include/mvelib.h, main/movie.c, main/mve_main.c, main/mvelib.c, - main/mveplay.c, main/mveplay.h, main/titles.c: many improvements to - mve code. Fixes (at least) bugs #41, #348, and #350. - -2003-02-14 Bradley Bell - - * main/Makefile.am: no more Makefile.mveplay. again - * main/mveplay.c: typo - -2003-02-13 Bradley Bell - - * utilities/mvlextract.c: uint -> unsigned int - * main/: mve_main.c, mvelib.c, mveplay.c: add fullscreen mode to - standalone mveplayer, win32 support - * main/movie.c: random bugfixes, win32 support - * arch/sdl/Makefile.am: formatting - * configure.ac: disable networking on mac/win for now - * main/newmenu.c: comments - -2003-02-13 Martin Schaffner - - * 3d/interp.c, include/interp.h, main/polyobj.c: get rid of some - redundant swap functions. - -2003-02-13 Bradley Bell - - * ChangeLog: update changelog - -2003-02-13 Martin Schaffner - - * 3d/interp.c, include/interp.h, main/polyobj.c: fix remaining - polymodel alignment issues. - -2003-02-13 Bradley Bell - - * utilities/: hogcreate.c, hogextract.c, mvlcreate.c, mvlextract.c: - fix various little bugs - * main/mveplay.c, utilities/hogextract.c, utilities/mvlextract.c, - utilities/tex2txb.c, utilities/txb2tex.c: eliminate warning - * main/: Makefile.am, Makefile.mveplay: build mveplayer from - regular makefiles - * README.utils: new file - * main/: mve_main.c, mveplay.c: more movie fixes - * README: updated README - * 2d/Makefile.am, main/Makefile.am: some OS X and dist fixes - -2003-02-12 Bradley Bell - - * utilities/mvlextract.c: bigendian mvl support - * main/mveplay.c: formatting, stuff - * main/: Makefile.am, Makefile.mveplay: lotsa movie cleanups, added - truecolor mve support, standalone mveplayer - * include/mve_audio.h, include/mvelib.h, main/decoder16.c, - main/decoder8.c, main/movie.c, main/mve_main.c, main/mvelib.c, - main/mveplay.c: lotsa movie cleanups, added truecolor mve support, - standalone mveplayer - -2003-01-22 Bradley Bell - - * include/: interp.h, interp.h: restore prototype for - swap_polygon_model_data - -2003-01-21 Bradley Bell - - * main/piggy.c: use memcpy to avoid alignment problem - * compilerdefs.txt: updated some defs, added sunos/sparc - -2003-01-15 Bradley Bell - - * main/render.c, arch/ogl/ogl.c: use __sun__ for sunos - * main/gamemine.c: attempting to support d1 shareware - * compilerdefs.txt: update defs - -2003-01-15 David Costanzo - - * main/mveplay.c: fix several bugs, comments, formatting. - -2003-01-15 Bradley Bell - - * arch/ogl/sdlgl.c, arch/sdl/digi.c, arch/sdl/event.c, - arch/sdl/gr.c, arch/sdl/init.c, arch/sdl/joy.c, arch/sdl/key.c, - arch/sdl/mouse.c, arch/sdl/rbaudio.c, arch/sdl/timer.c, - include/error.h, main/gamecntl.c, main/inferno.c: changed path for - SDL headers - * arch/: ogl/glx.c, ogl/gr.c, ogl/ogl.c, ogl/wgl.c, sdl/joydefs.c: - formatting, comments - -2003-01-11 Bradley Bell - - * main/: mission.c, mission.h: attempt to support d1 for mac - mission - * arch/sdl/joy.c, main/mvelib.c, main/titles.c: gcc 3.2 warnings - * main/object.h: foo - -2003-01-09 Bradley Bell - - * main/movie.c: use ifdef around gr_toggle_fullscreen - -2003-01-07 Bradley Bell - - * Makefile.am, descent.msn, installation.txt, main/mission.c, - main/mission.h: don't need .msn file for descent.hog anymore - * README: stuff - -2003-01-06 Bradley Bell - - * main/mission.h, main/mission.c: comments - * README, TODO, cvshowto.txt, installation.txt, debian/copyright: - documentations - -2003-01-03 Bradley Bell - - * utilities/: txb2txt.c, txt2txb.c: remove old files - * 3d/interp.c, include/byteswap.h, main/gamemine.c: formatting - * main/polyobj.c: attempt to make read_model_file - bigendian-friendly - * main/menu.c: move vertigo text - -2003-01-02 Bradley Bell - - * 3d/interp.c, include/interp.h, main/morph.c, main/polyobj.c, - main/polyobj.h: cleanup alignment changes - * NEWS, 3d/interp.c, include/3d.h, include/interp.h, - include/pstypes.h, main/Makefile.am, main/bm.c, main/collide.c, - main/object.h: fix alignment issues on sparc - * cvshowto.txt: update cvs info - * NEWS: news - * 2d/rle.c: make rle_swap handle RLE_BIG - -2003-01-01 Martin Schaffner - - * main/render.c: workaround solaris qsort bug - -2003-01-01 Steffen Pohle - - * arch/linux/linuxnet.c, arch/linux/ukali.c, - arch/linux/include/ukali.h, main/inferno.c: enabled kali - * arch/linux/Makefile.am: enabled linux joystick, kali - * configure.ac, arch/linux/joystick.c, arch/sdl/Makefile.am, - arch/sdl/event.c: enabled linux joystick - -2002-12-31 Bradley Bell - - * main/gamemine.c: simplified warning msg - * NEWS, TODO, main/multi.c, main/netmisc.c: comments/whitespace - * main/render.h: fix compiler warning - -2002-12-31 Martin Schaffner - - * 2d/rle.c, main/inferno.c, main/piggy.c: fixed rle_swap leaks. - -2002-12-24 Bradley Bell - - * main/mission.c: fixes an infinite loop which was caused by d2x - thinking d2demo was a descent 1 mission - -2002-12-24 Martin Schaffner - - * arch/ogl/ogl.c, main/render.c: fix compiler warnings. - -2002-12-24 Bradley Bell - - * main/render.c: comments - -2002-10-30 Bradley Bell - - * main/inferno.c: add help for -hogdir option - * main/inferno.c: added -hogdir option - -2002-10-28 Bradley Bell - - * main/: inferno.c, menu.c: enabled Vertigo displays - * include/3d.h: typo - -2002-10-28 Martin Schaffner and Bradley Bell - - * 3d/interp.c, include/3d.h, include/byteswap.h, main/bm.c, - main/netmisc.c, main/network.c: simplify and eliminate redundant - swap macros. - -2002-10-28 Martin Schaffner - - * maths/fixc.c: fix infinite loop in quad_sqrt. - * 3d/points.c, include/maths.h, include/pstypes.h, maths/fixc.c, - maths/vecmat.c: sparc/sunos support: rename quad to quadint. - -2002-10-12 Bradley Bell - - * 2d/2dsline.c: handle BM_OGL in gr_scanline() - -2002-10-11 Bradley Bell - - * main/hud.c: make hud_message work correctly - * 2d/palette.c, arch/sdl/gr.c, include/palette.h, main/inferno.c: - enable -nofade - * main/network.c: formatting, small fixes - -2002-10-10 Bradley Bell - - * main/netmisc.h: no swap_object for little-endian - * main/: netmisc.h, network.c: use macros to simplify network - endian conversion - * main/piggy.c: disable autodetect of mac pig (use --enable-macdata - for now) - * main/inferno.c: enable loading screen for mac shareware with - -nohires - * main/netmisc.c: whitespace - * 2d/bitmap.c, main/inferno.c, main/mission.c, main/playsave.c: - comments - * main/hud.c: whitespace - * configure.ac: remove shareware build, add macdata build - * main/songs.c: whitespace - * 2d/circle.c, 2d/clip.h, 2d/disc.c, 2d/gpixel.c, 2d/line.c, - 2d/pixel.c, 2d/poly.c, 2d/rect.c, 2d/tmerge.c, main/gamerend.c: - whitespace - * 2d/: Makefile.am, tmerge_a.asm: enable TRANSPARENCY_COLOR for - assembly - -2002-10-04 Martin Schaffner - - * cfile/cfile.c, include/iff.h, main/gamepal.c, main/titles.c: - comments, formatting, etc. - * iff/iff.c: fix bigendian iff loading. - -2002-10-03 Bradley Bell - - * utilities/txb2tex.c: typo - * 3d/clipper.c, main/bm.c, main/game.c, main/gamecntl.c, - main/newmenu.c, main/switch.c, main/terrain.c, main/text.c: - whitespace - * arch/sdl/mouse.c: whitespace - -2002-09-19 Bradley Bell - - * main/kconfig.c: fix a oops, add old logs - * main/kconfig.c: support for >3 mouse buttons - -2002-09-18 Bradley Bell - - * include/gr.h: fix palette swap define - -2002-09-14 Bradley Bell - - * main/titles.c: load hires briefing screen if lores doesn't exist - (i.e. vertigo) and MenuHires=0 - -2002-09-14 Werner Augustin - - * main/: multi.h, network.h: pack some structures for ipx - compatibility. - -2002-09-14 Bradley Bell - - * cfile/cfile.c, main/endlevel.c, main/gamesave.c: revert cfgets() - and load_endlevel_data() to expect newline-terminated strings, fix - load_game_data to read null-terminated string for - Current_level_name - -2002-09-07 Bradley Bell - - * main/newmenu.c: added error message - * main/menu.h: enable -nohires with mac shareware - * 2d/palette.c, include/gr.h: enable 0/255 palette swap - * 2d/font.c: enable 0/255 palette swap for fonts - * 2d/bitblt.c: add TRANSPARENCY_COLOR to assembly code, nother OGL - fix - * 2d/2dsline.c: fix ogl blooper - -2002-09-05 Bradley Bell - - * 2d/rle.c, 2d/scalec.c, include/rle.h: better just do it the old - way - * include/strutil.h: need string.h for strcasecmp - * include/rle.h: okay, maybe it needs to be this way - * include/: 3d.h, gr.h: more stuff from d2src, mostly formatting - * 2d/scalec.c: more stuff from d2src - * 2d/rle.c: more stuff from d2src, formatting - * 2d/font.c: useless cruft - * 2d/: 2dsline.c, bitmap.c, bitmap.h: more stuff from d2src - * 2d/bitblt.c, include/grdef.h: moved gr_linear_movsd assembly from - grdef.h to bitblt.c - -2002-09-04 Bradley Bell - - * include/grdef.h: fix compiler warnings - * 2d/bitblt.c: fix compiler warnings, #ifdef out dos-only code - * include/grdef.h: gr_linear_movsd isn't static for NO_ASM, - obviously - * main/game.c: we want the mac ibitblt for everything but dos and - windows, I think. - * main/texmerge.c: these routines are in tmerge.c - * main/credits.c: enable credits for mac and oem data - * main/bm.c: use either exit.ham or exit.pofs - * include/ibitblt.h: enable some more code from d2src - * include/gr.h: enable mac ubitblt_double - * 2d/rle.c: added gr_rle_expand_scanline_generic_masked from d2src - * include/grdef.h: moved some inline asm from linear.h - * 2d/ibitblt.c: brought in line with original d2 version - * 2d/bitblt.c: reverted to original d2 version of this file, then - added d1x enhancements - * 2d/2dsline.c: formatting, use __MSDOS__ instead of __DJGPP__ - * 2d/linear.h: moved these back to their original locations - (bitblt.c, grdef.h) - * main/mveplay.c: close some memory holes, speed up palette loading - * main/movie.c: added fullscreen toggle while playing movies - * main/inferno.c: comment out -superhires help text (always on) - * include/timer.h: added approx_fsec_to_usec macro - * arch/sdl/joy.c: fix compiler warning - -2002-09-01 Bradley Bell - - * main/network.c: oops - * main/: movie.c, mveplay.c, mveplay.h: more movie improvements - * arch/sdl/timer.c, include/timer.h: added timer_delay, faster - timer_get_fixed_seconds - * TODO: todo - -2002-08-31 Bradley Bell - - * TODO, main/inferno.c, main/movie.c, main/mveplay.c: movie - improvements - * main/multi.h: network endian stuff - * 2d/font.c, include/gr.h: fast file i/o for font headers - * arch/win32/arch_ip.cpp: unused file - * main/: netmisc.c, netmisc.h, network.c, network.h: formatting, - bigendian networking fixes - * main/menu.c: make net menu more accurate, also make superhires - always on - * include/pstypes.h: better to have __pack__ all the time, I think. - needed for networking, e.g. - * arch/win32/: ipx_drv.h, ipx_win.c, winnet.c: win32 networking - backtrack - * arch/win32/Makefile.am: unused file - * TODO: todo stuff - -2002-08-30 Bradley Bell - - * arch/win32/ipx_drv.h: re-added arch/win32/ipx_drv.h - * main/: newmenu.h, titles.c: formatting - * NEWS, arch/linux/Makefile.am, arch/linux/include/ukali.h, - main/multi.h: networking works, finally - * TODO: added TODO file - * arch/linux/arch_ip.cpp: unused fine - * README: network sorta working - * main/: Makefile.am, multi.c, network.c, network.h: more - networking fixes - * main/menu.c: load builtin mission correctly - * main/inferno.c: documentation - * main/: hoard.c, hoard.h, gamesave.c, mission.c: move hoard stuff - out of network - * main/Makefile.mveplay: don't need no more - -2002-08-29 Bradley Bell - - * main/: ip_base.cpp, ip_base.h, ip_basec.h, ipclienc.c, - ipclient.cpp, ipclient.h, ipserver.cpp, ipx_drv.c, multipow.c, - multipow.h, netlist.c, netpkt.c, netpkt.h: deleting unused d1x - stuff - * include/ipx_drv.h: more network fixing - * arch/linux/include/ipx_drv.h: more network fixing - * include/ipx.h: formatting - * arch/linux/ipx_kali.c, include/ipx.h: fixed networking fuck-up? - * NEWS, arch/linux/Makefile.am, arch/linux/ipx_bsd.c, - arch/linux/ipx_udp.c, arch/linux/linuxnet.c, main/Makefile.am, - main/inferno.c: fixed networking fuck-up? - * Makefile.am: moved mingw info to README - * README, mingw32.txt: moved mingw info to README - -2002-08-27 Bradley Bell - - * utilities/mvlextract.c: allow specifying file to extract - * utilities/: tex2txb.c, txb2tex.c: use default extension to - convert tex<->txb - * utilities/hogextract.c: allow specifying file to extract - * main/mission.c: Have to get mission_num _after_ promoting... - * main/: gameseq.c, titles.c: beginning d1 briefing support - * descent.msn: beginning d1 briefing support - * main/: titles.c, titles.h: d1-style mission briefings - * main/piggy.h: whitespace - * main/movie.c: beginning robot movie support, fall back on lo/hi - res if hi/lo not available - * main/mission.c: added Builtin_mission_num for builtin mission, - D1Hogdir, d1-style mission briefings - * main/: gameseq.c, mission.h: added Builtin_mission_num for - builtin mission - * cfile/cfile.c, include/cfile.h: add capability for 3rd hogfile - (for d1 missions that need d1 data) - * 2d/ibitblt.c: whitespace - -2002-08-26 Bradley Bell - - * utilities/mvlcreate.c: oops - * utilities/: Makefile.am, mvlcreate.c, mvlextract.c: added mvl - utilities - * utilities/hogextract.c: added [v]iew option - * utilities/: tex2txb.c, txb2tex.c: changed txt to tex - * main/titles.c: fix writable string, disable DumbAdjust thing - * main/polyobj.h: whitespace - * main/newmenu.c: added pcx_get_dimensions(), other stuff from - d2src - * main/movie.c: read movies from AltHogDir, other fixes - * main/: mission.c, mission.h: fix bug w/mission filename - * main/gameseq.c: comments - * main/digi.h: whitespace n stuff - * include/mve_audio.h: added audio flag macros - * 2d/pcx.c, include/pcx.h: added pcx_get_dimensions(), other stuff - from d2src - * 2d/font.c: stuff - -2002-08-23 Bradley Bell - - * main/: gameseq.c, inferno.c, mission.c, mission.h, titles.c: fix - briefing stuff - * Makefile.am: remove d2demo.mn2 - * cfile/cfile.c, include/cfile.h: add cfile_size function - * d2demo.mn2, installation.txt, main/gameseq.h, main/mission.c: - eliminate need for .mn2 files for oem and demo - -2002-08-22 Bradley Bell - - * main/bm.c: fix for vertigo - * main/menu.h: make OEM menu pcx available - * 2d/rle.c: merge with original d2 file - * Makefile.am, configure.ac: let mission files get installed by - make - -2002-08-17 Bradley Bell - - * configure.ac: make FAST_FILE_IO the default on little-endian - machines - * NEWS, README, compilerdefs.txt, readme.txt: documentation - * 2d/bitblt.c, 2d/rle.c, arch/ogl/ogl.c: implement BM_FLAG_RLE_BIG - (cockpit support?) - -2002-08-15 Martin Schaffner - - * main/: game.c, menu.c, mission.c: promote builtin missions. - -2002-08-15 Bradley Bell - - * 2d/font.c, 2d/rle.c, include/gr.h, include/rle.h, main/piggy.c: - improved mac pig loading/reverted TRANSPARENCY_COLOR changes - * utilities/.cvsignore: added cvsignore - * 2d/palette.c, include/palette.h, main/gamesave.c: mac data file - loading - * main/piggy.c: mac data file loading - * 2d/font.c, 2d/rle.c, include/gr.h, include/rle.h: set - transparency and swap 0/255 correctly for mac data files - -2002-08-13 Bradley Bell - - * Makefile.am, configure.ac, utilities/Makefile.am: moved utility - to utilities to avoid conflict with c++ std lib - * utilities/: Makefile.am, hogcreate.c, hogextract.c, txb2txt.c, - txt2txb.c: moved utility to utilities to avoid conflict with c++ - std lib - * Makefile.am, configure.ac: add utilities - -2002-08-09 Bradley Bell - - * 2d/palette.c, 3d/interp.c, include/gr.h, main/render.c: - formatting - -2002-08-08 Bradley Bell - - * main/inferno.c: comments - * main/: newmenu.c, songs.c: mac demo datafile support - * installation.txt: update - * main/gamesave.c: use lowercase for consistency - * main/: bm.c, bm.h, endlevel.c, polyobj.c: enable loading of exit - models for other than d2demo - -2002-08-07 Martin Schaffner - - * main/gamemine.c: formatting, better d1 texture conversion - * Makefile.am, descent.mn2, descent.msn, main/mission.c, - main/mission.h: recognize .msn mission files. - -2002-08-07 Bradley Bell - - * .cvsignore, 2d/.cvsignore, 3d/.cvsignore, arch/.cvsignore, - arch/dos/.cvsignore, arch/ggi/.cvsignore, arch/linux/.cvsignore, - arch/ogl/.cvsignore, arch/sdl/.cvsignore, arch/svgalib/.cvsignore, - arch/win32/.cvsignore, cfile/.cvsignore, iff/.cvsignore, - main/.cvsignore, main/editor/.cvsignore, maths/.cvsignore, - mem/.cvsignore, misc/.cvsignore, texmap/.cvsignore: added - .cvsignore files - -2002-08-06 Bradley Bell - - * main/: automap.c, laser.c, songs.c, titles.c: shareware stuff - * main/Makefile.am: formatting - * 2d/font.c: make gr_remap_font just reload the whole thing - * configure.ac: formatting - * Makefile.am: added d2demo.mn2 - * d2demo.mn2: mission file for shareware - * include/u_mem.h, main/ai.c, main/gamesave.c, main/inferno.c, - main/laser.h, main/text.h, main/titles.c, main/weapon.c: whitespace - * main/sounds.h: shareware stuff, whitespace - * main/: polyobj.c, polyobj.h: more fast i/o macros - * main/: menu.c, menu.h, mission.c, newmenu.c, piggy.c, piggy.h: - shareware stuff - * main/: endlevel.c, endlevel.h, gamemine.c, gameseq.c: merged - endlevel stuff to non-shareware, allow movies/endlevel for - alternate missions - * main/cntrlcen.c: typo - * main/bm.h: use global Piggy_hamfile_version - * main/bm.c: merged endlevel stuff to non-shareware, more fast i/o - macros, use global Piggy_hamfile_version - * main/Makefile.am: terrain and movie stuff always used now - * 2d/pcx.c, include/pcx.h: make pcx header available to other - files, whitespace - * main/: gamemine.c, gamesave.c: load DMB levels - * main/: bm.c, cntrlcen.c, cntrlcen.h, fuelcen.c, fuelcen.h, - segment.c, segment.h, switch.c, switch.h: fast i/o macros - -2002-08-04 Martin Schaffner - - * main/gamemine.c, main/gamesave.c, mem/mem.c: d1 level stuff. - -2002-08-04 Bradley Bell - - * main/inferno.c: shareware stuff, formatting - * arch/sdl/rbaudio.c: gracefully handle redbook non-availability - * arch/sdl/gr.c: don't need to set mode in gr_init - -2002-08-02 Martin Schaffner - - * main/: gamemine.c, gamemine.h, gamesave.c, gamesave.h: more d1 - level loading stuff - * Makefile.am, descent.mn2: added mission file for descent 1 - -2002-08-02 Bradley Bell - - * arch/sdl/digi.c, arch/sdl/gr.c, include/error.h, - include/oldsdl.h, main/gamecntl.c, main/inferno.c, main/laser.c, - main/piggy.h, misc/error.c: junk - * main/: endlevel.c, escort.c, gameseq.c, newmenu.c, render.c, - render.h, scores.c, scores.h, terrain.c: shareware stuff - * configure.ac, include/pstypes.h, main/bm.c, main/bm.h, - main/effects.c, main/effects.h, main/piggy.c, main/piggy.h, - main/powerup.c, main/powerup.h, main/robot.c, main/robot.h, - main/vclip.c, main/vclip.h, main/wall.c, main/wall.h, - main/weapon.c, main/weapon.h: fast i/o macros - -2002-08-01 Martin Schaffner - - * NEWS, cfile/cfile.c, main/console.c, main/gamemine.c, - main/gamemine.h, main/gamesave.c: load d1 levels - -2002-07-30 Bradley Bell - - * configure.ac: oops - * configure.ac, arch/ogl/gr.c, arch/ogl/ogl.c, include/ogl_init.h: - OSX OGL fixes - * main/menu.c, main/titles.c, NEWS, 2d/font.c, include/gr.h, - include/grdef.h, main/game.c, main/gamefont.c, main/gamefont.h, - main/gamemine.c, main/inferno.c, main/movie.c, main/newmenu.c, - main/piggy.c, main/titles.c: support shareware datafiles! - * main/: bm.c, gamemine.c, piggy.c, piggy.h, weapon.c, gamemine.c, - piggy.c: SHAREWARE fixes - -2002-07-29 Bradley Bell - - * NEWS, include/fileutil.h, main/bm.c, main/gameseq.c, - main/mveplay.c, main/piggy.c, main/piggy.h, main/playsave.c, - misc/fileutil.c: Portability - OS X support - -2002-07-27 Bradley Bell - - * main/: Makefile.am, fuelcen.c, fuelcen.h, game.c, game.h, - gamemine.c, gamesave.c, gameseq.c, piggy.c, piggy.h, segment.c, - segment.h: portability - * cfile/cfile.c, include/cfile.h, main/cntrlcen.c, main/cntrlcen.h, - main/gamesave.c, main/switch.c, main/switch.h, main/wall.c, - main/wall.h: portabilization - * 2d/font.c, include/gr.h: portability - -2002-07-26 Bradley Bell - - * 2d/font.c, 2d/pcx.c, include/gr.h, main/movie.c: portability - * arch/linux/findfile.c, include/pstypes.h: os x fixes - * main/player.c: foo - * misc/fileutil.c, include/fileutil.h, misc/fileutil.c: oops - * include/fileutil.h, misc/Makefile.am, misc/fileutil.c, - misc/fileutil.h: portable file i/o utils - * main/: Makefile.mveplay, inferno.c, movie.c, newmenu.c: s not a - writable string anymore... / formatting - * main/Makefile.am, main/bm.c, main/bm.h, main/cntrlcen.c, - main/cntrlcen.h, main/effects.c, main/effects.h, main/piggy.c, - main/piggy.h, main/player.c, main/player.h, main/polyobj.c, - main/polyobj.h, main/powerup.c, main/powerup.h, main/robot.c, - main/robot.h, main/vclip.c, main/vclip.h, main/wall.c, main/wall.h, - main/weapon.c, main/weapon.h, 3d/interp.c, include/cfile.h: - portable-izing file loading routines - -2002-07-24 Bradley Bell - - * main/mveplay.c: correctly play files with 16bit uncompressed - audio, mem checking, etc - * main/: Makefile.mveplay, mvelib.c, mveplay.c: enable standalone - mve player - -2002-07-23 Bradley Bell - - * misc/Makefile.am: unused file - * configure.ac, main/endlevel.c, main/endlevel.h, main/menu.c, - main/sounds.h: remove experimental nmovie stuff - * main/movie.c: add some debugging output - -2002-07-22 Bradley Bell - - * main/: console.c, state.c: simplified header - * main/movie.c: enable mveplay audio - * main/old/movie.c: moved to main/ - * include/mve_audio.h, include/mvelib.h, main/Makefile.am, - main/inferno.c, main/kludge.c, main/movie.c, main/mve_audio.c, - main/mvelib.c, main/mveplay.c: initial movie support - * arch/linux/findfile.c, arch/ogl/gr.c, arch/ogl/ogl.c, - arch/sdl/init.c, arch/sdl/joy.c, include/byteswap.h, - include/ogl_init.h, include/pstypes.h, main/console.c, - main/state.c, mem/mem.c: OS X stuff - * configure.ac: OS X and movie stuff - -2002-07-19 Bradley Bell - - * compilerdefs.txt: OSX defs - -2002-07-18 Bradley Bell - - * main/inferno.c: use simpler rcs tags - * autogen.sh: keep Changelog in cvs (and use --accum) - * arch/dos/Makefile.am, arch/dos/cdrom.c, arch/dos/rbaudio.c, - arch/sdl/Makefile.am, arch/sdl/cdrom.c, arch/sdl/rbaudio.c, - include/rbaudio.h, main/Makefile.am, main/cdrom.h, main/gamecntl.c, - main/songs.c: changed cdrom->rbaudio - * include/rbaudio.h: moved to /include - -2002-07-17 Bradley Bell - - * 2d/d2sline.c, 2d/bitblt.c, 2d/bitmap.c, 2d/bitmap.h, 2d/box.c, - 2d/canvas.c, 2d/circle.c, 2d/clip.h, 2d/disc.c, 2d/font.c, - 2d/gpixel.c, 2d/ibitblt.c, 2d/line.c, 2d/linear.asm, 2d/linear.h, - 2d/palette.c, 2d/pcx.c, 2d/pixel.c, 2d/poly.c, 2d/rect.c, - 2d/rle.c, 2d/scale.c, 2d/scalea.asm, 2d/scalea.h, 2d/scalec.c, - 2d/tmerge.c, 2d/tmerge_a.asm, 3d/clipper.c, 3d/clipper.h, - 3d/draw.c, 3d/globvars.c, 3d/globvars.h, 3d/instance.c, - 3d/interp.asm, 3d/interp.c, 3d/matrix.c, 3d/points.c, 3d/rod.c, - 3d/setup.c: use simpler rcs tags - - -0.1.3: - -2002-07-17 Bradley Bell - - * tools/cvs2cl/cvs2cl.pl: upgrade cvs2cl - * d2x-gl.sh, d2x-ogl.sh: changed d2x-ogl to d2x-gl - * debian/rules: don't need readme's - * debian/rules: move d1x license to COPYING, license clarifications - * COPYING, license.txt, debian/copyright, Makefile.am: move d1x - license to COPYING, license clarifications - * debian/rules: fix debian docs - * debian/rules: fix debian manpages - * debian/d2x-sdl.menu: fix debian menu - * debian/rules: link to undocumented man page for debs - * Makefile.am, configure.ac, debian/control, debian/copyright, - debian/d2x-gl.files, debian/d2x-gl.menu, debian/d2x-sdl.files, - debian/d2x-sdl.menu, debian/d2x.files, debian/d2x.menu, - debian/rules, rpm/d2x.spec.in: change d2x-ogl to d2x-gl, other - packaging stuff - -2002-07-16 Bradley Bell - - * debian/: rules, changelog.in: deb stuff - * configure.ac: cleaner nasm detection - * debian/: changelog.in, control, rules: deb stuff - * README, installation.txt: typos, stuff - * configure.ac: better #defines - * configure.ac: whitespace - * configure.ac: better documentation - * configure.ac, arch/sdl/event.c, arch/sdl/init.c: SDL_AUDIO and - SDL_JOYSTICK not needed - * configure.ac, main/inferno.c: __SDL__ ugly and not needed at all - * configure.ac: need higher SDL for joystick - * debian/: control, rules: deb stuff - * arch/sdl/joy.c: old junk - * Makefile.am, configure.ac: automake updates - * main/: inferno.c, text.c: don't use althogdir on non-unix - * configure.ac: more autoconf updates - * misc/strutil.c: better strrev - * main/inferno.c: need limits.h on mingw also - * acconfig.h, configure.ac: Updated for autoconf 2.53 (no more - acconfig.h) - -2002-04-19 Bradley Bell - - * main/network.c: let hoard.ham be a cfile - * main/text.c: better error message when hog not found - * NEWS: more news - -2002-03-23 Bradley Bell - - * acconfig.h, configure.ac, arch/linux/Makefile.am, - arch/sdl/Makefile.am: Use SDL joystick automatically - * arch/sdl/joy.c, main/kconfig.c: SDL Joystick works! - -2002-03-05 Bradley Bell - - * arch/sdl/joydefs.c, arch/sdl/joy.c: SDL joystick stuff mostly - done - -2002-02-23 Bradley Bell - - * texmap/ntmap.c: fix bug preventing higher res sdl modes - * arch/dos/Makefile.am, arch/ggi/Makefile.am, - arch/linux/Makefile.am, arch/ogl/Makefile.am, arch/sdl/Makefile.am, - arch/svgalib/Makefile.am, arch/win32/Makefile.am, - main/editor/Makefile.am: moved includes to include - * arch/sdl/gr.c: use SDL_VERSION_ATLEAST - * Makefile.am, 2d/Makefile.am, 3d/Makefile.am, cfile/Makefile.am, - iff/Makefile.am, main/Makefile.am, maths/Makefile.am, - mem/Makefile.am, misc/Makefile.am, texmap/Makefile.am: moved - includes to include - * main/game.c: disabled cockpit for OGL, formatting - * 2d/ibitblt.c: formatting - -2002-02-16 Bradley Bell - - * include/oldsdl.h: check for older macros - * configure.ac, arch/sdl/digi.c, arch/sdl/event.c, arch/sdl/gr.c, - include/error.h, include/oldsdl.h, main/gamecntl.c, main/inferno.c: - allow older sdl versions - -2002-02-15 Bradley Bell - - * main/: automap.c, automap.h, inferno.c: automap resolution now - selectable - * include/: gr.h, grdef.h: moved protos to from grdef.h to gr.h - * arch/: dos/key_arch.c, dos/include/key_arch.h, ggi/key_arch.c, - sdl/key_arch.c, svgalib/key_arch.c, win32/key_arch.c, - win32/include/key_arch.h: never mind - that would be pointless - * arch/: dos/key_arch.c, dos/include/key_arch.h, ggi/key_arch.c, - sdl/key_arch.c, svgalib/key_arch.c, win32/key_arch.c, - win32/include/key_arch.h: copied files from d1x - * arch/linux/arch_ip.cpp, arch/win32/arch_ip.cpp, main/ip_base.cpp, - main/ip_base.h, main/ipclient.cpp: enable udp debug messages - * main/multipow.c: need conf.h - * arch/win32/Makefile.am: new file - * include/pstypes.h: added u_int16_t (needed in base_ip) - * arch/win32/arch_ip.cpp: copied from d1x - -2002-02-14 Bradley Bell - - * arch/sdl/gr.c, main/inferno.c: allow gr_init lowres - * NEWS, include/gr.h, main/game.c, main/game.h, main/gamecntl.c, - main/netlist.c: Added hotkeys to toggle fullscreen mode - * main/: ip_base.cpp, ip_base.h, multi.h, netlist.c, netpkt.c, - network.c, network.h, ipclient.cpp, netpkt.h: d1x->d2x - * main/: multipow.c, multipow.h, netlist.c, netpkt.c, netpkt.h, - reorder.h: Lotsa networking stuff from d1x - -2002-02-13 Bradley Bell - - * include/gr.h, main/game.c: Fullscreen toggle stuff - * arch/linux/Makefile.am, include/ipx.h: Lotsa networking stuff - from d1x - * main/: Makefile.am, inferno.c, ip_base.cpp, ip_base.h, menu.c, - multi.h, network.c, network.h, newmenu.c: Lotsa networking stuff - from d1x - -2002-02-11 Bradley Bell - - * main/bm.c: use portable loader if bigendian - * include/pstypes.h: don't define bool for c++ - * include/cfile.h: extern AltHogDir stuff - * include/byteswap.h: use WORDS_BIGENDIAN - * main/: newmenu.c, newmenu.h: added fixedfont menu functions - * main/vers_id.h: added D2X_IVER - * misc/args.c: don't use d1x.ini - * Makefile.am: rpm stuff - * acconfig.h, configure.ac: c++, versioning, endianness, deb, rpm - stuff - -2002-02-09 Bradley Bell - - * rpm/: d2x.spec, d2x.spec.in: auto-generate rpm spec file - -2002-02-09 Paolo Ulivi - - * d2x-ogl.sh, d2x-sdl.sh, rpm/.cvsignore, rpm/d2x.spec: rpm - support - -2002-02-06 Bradley Bell - - * arch/linux/arch_ip.cpp, main/ip_base.cpp, main/ip_base.h, - main/ip_basec.h, main/ipclienc.c, main/ipclient.cpp, - main/ipclient.h, main/ipserver.cpp: Adding d1x network code - * debian/: changelog.in, control, copyright, d2x-gl.files, - d2x-gl.menu, d2x.files, d2x.menu, rules: Added debian stuff - -0.1.2: - -2002-02-02 Bradley Bell - - * NEWS, arch/ggi/Makefile.am: reenabled ggi build - * NEWS, acconfig.h, configure.ac, main/gamecntl.c, main/inferno.c: - Enabled RELEASE option - -2002-01-31 Bradley Bell - - * Makefile.am, configure.ac: specify prerequisite versions of - autoconf and automake - -2002-01-29 Bradley Bell - - * main/mission.c: RCS header added - * main/inferno.c: update copyright date - * main/mission.c: allow missions to be in AltHogDir - * configure.ac: Display results of configure - * include/d_io.h, main/inferno.c, main/newdemo.c: Added d_mkdir - macro - -2002-01-28 Bradley Bell - - * NEWS, acconfig.h, configure.ac, cfile/cfile.c, main/newdemo.c: - Data files now go in DATADIR/games/d2x, user files now go in - ~/.d2x - -2002-01-28 Falk Hueffner - - * main/inferno.c: Data files now go in DATADIR/games/d2x, user - files now go in ~/.d2x - -2002-01-24 Bradley Bell - - * configure.ac: fix nasm not found error message - -2002-01-18 Bradley Bell - - * configure.in: getting rid of old configure.in - * acconfig.h, configure.ac, main/Makefile.am, main/kludge.c, - main/movie.c: Movie playing kludgey stuff - * misc/args.c: formatting - * main/inferno.c: allow -h for help - * include/error.h: don't die on int3, unless -debug given - * mingw32.txt: more stuff - -2001-12-29 Bradley Bell - - * Makefile.am: Got rid of thinking.txt - * main/inferno.c: document -nomovies option - -2001-12-28 Bradley Bell - - * main/titles.c: formatting, put some code into place for rendering - of robots during briefings - -2001-12-27 Bradley Bell - - * NEWS: stuff - -2001-12-23 Craig Hadady - - * 2d/rle.c: fixed bug in dummy array. - -2001-12-03 Bradley Bell - - * arch/sdl/init.c: fix formatting - * Makefile.am, acconfig.h, configure.ac, arch/linux/Makefile.am, - arch/sdl/Makefile.am, arch/sdl/event.c, arch/sdl/init.c, - arch/sdl/joy.c, arch/svgalib/Makefile.am: lots of makefile fixes, - and sdl joystick stuff - -2001-11-30 Bradley Bell - - * thinking.txt: not needed - -2001-11-27 Bradley Bell - - * cygconf, mingw32.txt: use sdl from source on cygwin - * Makefile.am, configure.ac, arch/ogl/Makefile.am, - arch/sdl/Makefile.am, main/Makefile.am: move SDL_LIBS to LIBS, - SDL_CFLAGS to CFLAGS - -2001-11-27 Bradley Bell - - * AUTHORS: typo - -2001-11-14 Bradley Bell - - * texmap/scanline.c: use optimization flags as texmap default - * NEWS: mouse wheel, etc - * arch/include/mouse.h, arch/sdl/mouse.c, main/kconfig.c: use mouse - wheel to emulate 3rd axis - * Makefile.am, configure.ac: change ENV_DJGPP to DJGPP - * include/error.h: kludge to ungrab mouse when we hit an int3 - * include/d_io.h: change __ENV_WINDOWS__ to __WINDOWS__, - __ENV_MSDOS__ to __MSDOS__ - * arch/sdl/mouse.c: remove cruft, fix formatting, use mouse wheel - to emulate 3rd axis - * arch/sdl/event.c: remove cruft, fix formatting, begin joystick - stuff - * arch/sdl/digi.c: implemented digi_set_volume - * include/grdef.h, main/config.c, misc/d_io.c: change - __ENV_WINDOWS__ to __WINDOWS__, __ENV_MSDOS__ to __MSDOS__ - * 2d/font.c, main/bm.c, main/gamesave.c, main/gameseq.c, - main/piggy.c: use MAKE_SIG - * installation.txt: update - * configure.ac: new file - * arch/sdl/joydefs.c: #include pstypes.h - * arch/sdl/init.c: SDL joystick stuff - * acconfig.h: adjust MINGW defines - * arch/sdl/joydefs.c: copied joydefs_config from linux/joydefs.c - - controls menu now works - -2001-11-13 Bradley Bell - - * main/Makefile.am: Make sure bmread.c and terrain.c get included - in dist - * Makefile.am: New file - * arch/dos/Makefile.am: Make sure gr.c and joy2.asm get included in - dist - * compilerdefs.txt: New file - * main/aipath.c: use D_RAND_MAX instead of RAND_MAX - -2001-11-12 Bradley Bell - - * main/playsave.c: load player files regardless of byte order of - sig - -2001-11-11 Bradley Bell - - * include/makesig.h, main/playsave.c: Created header for MAKE_SIG - macro - * main/Makefile.am: Don't use terrain.c unless SHAREWARE - * NEWS: GL savegame thumbnails - * acconfig.h, configure.in: make option for NMOVIES, default to off - -2001-11-09 Bradley Bell - - * main/state.c: Enabled savegame thumbnails under OpenGL - * unused/pa_null/pa_enabl.h: remove duplicate header - * misc/args.c: use d2x.ini for option file - * mem/mem.c: Move mem_realloc inside the ifdef - * main/menu.c: fix 640x400 menu text - * main/inferno.c: added documentation - * main/endlevel.c: fix warnings - * arch/ogl/gr.c: Get rid of gl spew - * arch/linux/Makefile.am: move unused ipx_udp.c to EXTRA_DIST - * acconfig.h: Define __SDL__ for mingw - -2001-11-08 Bradley Bell - - * 2d/font.c: free OGL font data when rereading - * main/collide.c, main/endlevel.c, main/endlevel.h, main/gameseq.c, - main/gauges.c, acconfig.h, configure.in, main/inferno.c, - main/laser.c, main/menu.c, main/menu.h, main/newmenu.c, - main/piggy.c, main/sounds.h, main/switch.c, main/titles.c, - main/weapon.h: Enabled shareware build, endlevel flythrough - sequence - * main/: Makefile.am, terrain.c, old/terrain.c: moved file, will be - of use for shareware build - * arch/ogl/: gr.c, sdlgl.c: use new d_realloc function, so mem - manager doesn't die - * include/u_mem.h, mem/mem.c: added d_realloc/mem_realloc functions - -2001-11-05 Bradley Bell - - * include/args.h, main/inferno.c, misc/args.c: Change args_init - back to InitArgs - * include/3d.h: Add comment - -2001-11-04 Bradley Bell - - * cfile/Makefile.am, cfile/nocfile.h, include/nocfile.h: Move - header to includes/ - * arch/ogl/sdlgl.c: Hack to keep SDL from screwing up X when it - crashes - * main/: gamecntl.c, inferno.c: SDL applies to more than X11... - * arch/ogl/gr.c, main/Makefile.am, main/gauges.c, main/hud.c, - main/hudmsg.h: Enable d1x-style hud_message - * arch/ogl/: glx.c, wgl.c: Sync with d1x - * 2d/font.c: re-init ogl fonts after remapping colors. - -2001-11-02 Bradley Bell - - * misc/Makefile.am: remove byteswap.h (duplicate header) - * 2d/font.c: fixed gr_remap_font, minor stuff - * configure.in: take out -O2 if doing debug build - * main/bm.c: formatting - * 2d/font.c, include/gr.h, NEWS: Enable OpenGL fonts! - * include/byteswap.h, misc/Makefile.am: fix swapint, swapshort - macros, get rid of functions - -2001-11-01 Bradley Bell - - * misc/byteswap.h: removed duplicate header - -2001-10-31 Bradley Bell - - * NEWS, main/automap.c: automap works in opengl - * NEWS, configure.in: Added news - * main/newmenu.c: Must call set_screen_mode for menus when using GL - * 2d/: bitblt.c, canvas.c, linear.h, scalea.h: Sync with d1x - * arch/sdl/event.c, arch/sdl/gr.c, arch/sdl/init.c, iff/iff.c, - include/3d.h, include/loadgl.h, main/inferno.c, maths/fixc.c, - maths/vecmat.c, maths/vecmata.asm: Sync with d1x - * Makefile.am, arch/sdl/Makefile.am: Makefile fixes - * arch/ogl/: glx.c, gr.c, ogl.c, sdlgl.c: Sync with d1x - * 3d/: clipper.c, draw.c, globvars.c, instance.c, interp.c, - matrix.c, points.c, rod.c, setup.c: Minor sync with d1x - -2001-10-27 Bradley Bell - - * main/inferno.c: added some documentation - -2001-10-25 Bradley Bell - - * main/inferno.c, texmap/ntmap.c, texmap/tmapflat.c: Completed tmap - selection code. - * Makefile.am, configure.in, arch/Makefile.am, - arch/dos/Makefile.am, arch/dos/cdrom.c, arch/dos/digi.c, - arch/dos/gr.c, arch/ggi/Makefile.am, arch/ggi/gr.c, - arch/ogl/Makefile.am, arch/ogl/glx.c, arch/ogl/gr.c, - arch/ogl/ogl.c, arch/ogl/sdlgl.c, arch/ogl/wgl.c, - arch/sdl/Makefile.am, arch/sdl/cdrom.c, arch/sdl/digi.c, - arch/sdl/gr.c, arch/svgalib/Makefile.am, arch/svgalib/gr.c, - texmap/scanline.c: Finished moving stuff to arch/blah. I know, - it's ugly, but It'll be easier to sync with d1x. - * Makefile.am, configure.in, main/Makefile.am, main/editor/med.c, - main/editor/medwall.h, main/editor/segment.c, main/editor/seguvs.h, - main/editor/Makefile.am: attempt at support for editor, makefile - changes, etc - * misc/d_delay.c: formatting fix - * texmap/: Makefile.am, ntmap.c, scanline.c, scanline.h, texmapl.h, - tmappent.S, tmapppro.S: adding support for runtime selection of - tmap funcs - * main/: bmread.c, game.c, gamecntl.c, gamesave.c, inferno.c, - inferno.h, piggy.c, render.c, editor/editor.h: conditionalize - including multi.h and network.h, fix backslashes, fix compiler - errors with EDITOR - * main/: ai.c, ai2.c, aipath.c, automap.c, bm.c, cntrlcen.c, - collide.c, controls.c, credits.c, dumpmine.c, endlevel.c, escort.c, - fireball.c, fuelcen.c, gamemine.c, gameseq.c, gauges.c, laser.c, - menu.c, multi.h, netmisc.c, network.h, newdemo.c, newmenu.c, - object.c, powerup.c, state.c, switch.c, wall.c: conditionalize - including multi.h and network.h, fix backslashes - * include/pstypes.h: added typedef for u_int64_t on mingw - * include/3d.h: added prototype for g3_uninit_polygon_model - * arch/sdl/Makefile.am: Don't use SDL joystick except on mingw - -2001-10-24 Bradley Bell - - * arch/: ggi/Makefile.am, svgalib/Makefile.am: Moved input stuff to - arch subdirs, as in d1x. - * Makefile.am, configure.in, main/kconfig.c: Revert bin_programs to - earlier style until i understand automake 1.5 better. remove input - from SUBDIRS - * arch/: Makefile.am, dos/Makefile.am, dos/joy2.asm, dos/joyc.c, - dos/joydefs.c, dos/key.c, dos/mouse.c, ggi/event.c, ggi/init.c, - ggi/key.c, ggi/mouse.c, linux/Makefile.am, linux/joydefs.c, - linux/joystick.c, linux/include/joystick.h, sdl/Makefile.am, - sdl/event.c, sdl/joy.c, sdl/joydefs.c, sdl/key.c, sdl/mouse.c, - svgalib/event.c, svgalib/init.c, svgalib/key.c, svgalib/mouse.c: - Moved input stuff to arch subdirs, as in d1x. - * NEWS, configure.in: blah blah - -2001-10-23 Bradley Bell - - * include/ui.h, unused/ui/ui.h: Moved ui.h to includes/ - * texmap/tmapppro.S: no need for #include here - * main/Makefile.am: Build fixes. EDITOR_SRCS added to - libmain_a_SOURCES. - * main/: Makefile.am, network.c: No longer #ifdef'ing out the whole - file. RCS header added - * main/: bmread.c, kmatrix.c, multi.c, multibot.c: No longer - #ifdef'ing out the whole file. RCS header added - * Makefile.am, acconfig.h, configure.in, arch/dos/Makefile.am, - main/Makefile.am, maths/Makefile.am, texmap/Makefile.am: Build - fixes. Now works with automake 1.5 and autoconf 2.52. - --enable-editor option added. SDL_VIDEO and SDL_INPUT defined for - mingw (-grabmouse now works on win32). - * config.guess, config.sub, install-sh, missing, mkinstalldirs: - These don't belong in cvs - -0.1.1: - -2001-10-20 Bradley Bell - - * 2d/font.c: Don't free unused variables... - * 2d/font.c, include/gr.h: Bringing font stuff more in line with - d1x - * Makefile.am, arch/Makefile.am, arch/dos/Makefile.am, - arch/linux/Makefile.am, arch/win32/Makefile.am, iff/Makefile.am, - main/Makefile.am: make dist more sensible - * Makefile.am: Kludge for linking on mingw - -2001-10-19 Bradley Bell - - * Makefile.am, configure.in, arch/win32/Makefile.am, - arch/win32/ipx_win.c, arch/win32/winnet.c: Little fixes - * include/ipx_drv.h: Check for __MINGW32__ - * include/i86.h: Imported from d1x - * arch/dos/: Makefile.am, ipx.c: Re-import of d1x files - * arch/dos/modex.asm: Fixed %include - * main/console.c: RCS headers added - * arch/sdl/: Makefile.am, init.c, timer.c: Moved arch/sdl_* to - arch/sdl - * Makefile.am, main/Makefile.am: Moved final link to top-level - directory instead of main/ - * 2d/linear.asm, maths/fix.asm, maths/vecmata.asm: Changed - __ENV_LINUX__ to __linux__ - * configure.in, arch/Makefile.am, arch/dos_dpmi.c, - arch/dos_findfile.c, arch/dos_init.c, arch/dos_ipx.c, - arch/dos_modex.asm, arch/dos_timer.asm, arch/dos_tweak.inc, - arch/dos_vesa.c, arch/dos_vgaregs.inc, arch/linux_init.c, - arch/sdl_init.c, arch/sdl_timer.c, arch/dos/Makefile.am, - arch/dos/dpmi.c, arch/dos/findfile.c, arch/dos/init.c, - arch/dos/ipx.c, arch/dos/modex.asm, arch/dos/timer.asm, - arch/dos/tweak.inc, arch/dos/vesa.c, arch/dos/vgaregs.inc, - arch/linux/Makefile.am, arch/linux/init.c, arch/win32/Makefile.am, - arch/win32/mingw_init.c, main/Makefile.am: Moved arch/sdl_* to - arch/sdl - * configure.in: add --enable-xploader, support arch/linux subdir, - fix NASMFLAGS. - * main/inferno.c: conditionalize conf.h - -2001-10-19 Falk Hueffner - - * acconfig.h, 2d/bitmap.h, 3d/interp.c, cfile/cfile.c, - include/cfile.h, main/bm.c, mem/mem.c, misc/fileutil.c, - misc/fileutil.h: Partial application of linux/alpha patch. - -2001-10-19 Bradley Bell - - * main/Makefile.am, arch/linux/Makefile.am: Brought linux - networking in line with d1x, moved some arch/linux_* stuff to - arch/linux/ - * arch/linux/: findfile.c, ipx_bsd.c, ipx_kali.c, ipx_lin.c, - linuxnet.c, ukali.c, include/ipx_bsd.h, include/ipx_hlpr.h, - include/ipx_kali.h, include/ipx_ld.h, include/ipx_lin.h, - include/ipx_udp.h, include/ukali.h: remove pesky * from RCS log - entry - * arch/: Makefile.am, linux_findfile.c, linux_ipx_bsd.c, - linux_ipx_lin.c, linux_ipx_udp.c, linux_net.c, linux/findfile.c, - linux/ipx_bsd.c, linux/ipx_kali.c, linux/ipx_lin.c, - linux/ipx_udp.c, linux/linuxnet.c, linux/ukali.c, - linux/include/ipx_bsd.h, linux/include/ipx_hlpr.h, - linux/include/ipx_kali.h, linux/include/ipx_ld.h, - linux/include/ipx_lin.h, linux/include/ipx_udp.h, - linux/include/ukali.h: Brought linux networking in line with d1x, - moved some arch/linux_* stuff to arch/linux/* - * include/ipx_drv.h: Imported from d1x - * main/ipx_drv.c: RCS info added, conf.h added, etc... - * main/ipx_drv.c: Imported from d1x - * include/args.h, include/ipx.h, main/inferno.c, main/network.c, - main/network.h, main/Makefile.am: Trying to get network working on - win32 - * configure.in, 2d/Makefile.am, arch/win32/Makefile.am, - main/Makefile.am: build fixes - * arch/: win32/Makefile.am, win32/findfile.c, win32/ipx_drv.h, - win32/ipx_win.c, win32/winnet.c, Makefile.am, win32_findfile.c, - linux/include/ipx_drv.h: Moved win32_* to win32/* (a la d1x), - starting to get net working. - * include/pstypes.h: Changed __ENV_LINUX__ to __linux__, - conditionalized min,max macros - -2001-10-18 Bradley Bell - - * acconfig.h, 2d/linear.h, arch/include/joy.h, include/loadgl.h, - include/strutil.h, include/vecmat.h, main/kconfig.c, misc/d_glob.c, - texmap/tmap_inc.asm, texmap/tmap_per.asm, texmap/tmappent.S, - texmap/tmapppro.S, main/console.c: Changed __ENV_LINUX__ to - __linux__ - * 2d/2dsline.c: RCS headers added/changed - * configure.in: fix NASMFLAGS bug - * main/: collide.c, inferno.c, object.c, render.c: RCS headers - added/changed - -2001-10-17 Bradley Bell - - * NEWS: Fixed the invulnerable robots bug! - * main/collide.c: Fixed the invulnerable robots bug! - -2001-10-14 Bradley Bell - - * Makefile.am, arch/Makefile.am, iff/Makefile.am, main/Makefile.am: - Minor dist fix - -2001-10-13 Bradley Bell - - * Makefile.am, autogen.sh, configure.in, 2d/Makefile.am, - arch/Makefile.am, arch/dos/Makefile.am, - arch/dos/allg_snd/Makefile.am, arch/dos/allg_snd/sound/Makefile.am, - arch/dos/allg_snd/sound/drv/Makefile.am, arch/dos/bak/Makefile.am, - arch/dos/comm/Makefile.am, arch/dos/comm/include/Makefile.am, - arch/dos/include/Makefile.am, arch/dos/mm_snd/Makefile.am, - arch/dos/mm_snd/include/Makefile.am, arch/include/Makefile.am, - arch/linux/Makefile.am, arch/linux/include/Makefile.am, - arch/win32/Makefile.am, arch/win32/d3dframe/Makefile.am, - arch/win32/include/Makefile.am, iff/Makefile.am, - iff/archive/Makefile.am, include/Makefile.am, main/Makefile.am, - main/editor/Makefile.am, main/old/Makefile.am, tools/Makefile.am, - tools/cvs2cl/Makefile.am, unused/Makefile.am, - unused/bios/Makefile.am, unused/lib/Makefile.am, - unused/novga/Makefile.am, unused/pa_null/Makefile.am, - unused/ui/Makefile.am, unused/vga/Makefile.am, - unused/vga/new/Makefile.am, unused/win95/Makefile.am: Removed - automake stuff from "inert" subdirs. And there was much rejoicing. - * Makefile.am, NEWS, configure.in: Stuff - * ChangeLog: removing auto-generated file - * cygconf: Added instructions for mingw32 build - * Makefile.am: renamed INSTALL to installation.txt - * installation.txt, INSTALL: renamed INSTALL to installation.txt - * mingw32.txt: Added instructions for mingw32 build - * configure.in: Enable assembly under mingw32 - -2001-10-12 Bradley Bell - - * acconfig.h, aclocal.m4, conf.h.in: remove superfluous files - * acconfig.h, aclocal.m4, conf.h.in, configure.in, 2d/2dsline.c, - 2d/bitblt.c, 2d/box.c, 2d/canvas.c, 2d/gpixel.c, 2d/line.c, - 2d/pixel.c, include/pstypes.h, include/strutil.h, include/timer.h, - main/digi.h, main/kludge.c, main/object.c, main/render.c, - misc/d_glob.c, misc/d_io.c, misc/strutil.c: Changed __ENV_DJGPP__ - to __DJGPP__, since it's built-in. - -2001-10-12 Paolo Ulivi - - * aclocal.m4, conf.h.in, include/vecmat.h, main/collide.c, - main/kludge.c, main/piggy.h: fix some gcc 3.0 warnings. - -0.1.0: - -2001-10-12 Bradley Bell - - * Makefile.am, unused/win95/Makefile.am: Fix some dist stuff - * Makefile.am: make sure cygconf gets archived - * configure.in: Increment version number in preparation for release - * configure.in: Fix detection of opengl - * Makefile.am, aclocal.m4, autogen.sh, conf.h.in, configure.in, - cygconf, arch/Makefile.am, arch/include/joy.h, - arch/include/mouse.h, include/loadgl.h, include/pstypes.h, - include/strutil.h, main/Makefile.am, main/config.c, main/console.c, - main/gamepal.h, main/gamerend.c, main/inferno.c, main/kconfig.c, - main/multi.c, main/newdemo.c, misc/d_delay.c, misc/d_glob.c, - misc/strutil.c: Switched from Cygwin to mingw32 on MS boxes. - Vastly improved compilability. - -2001-10-11 Bradley Bell - - * Makefile.am: Added macros/sdl.m4 - * autogen.sh: Added macros/sdl.m4 - -2001-10-09 Bradley Bell - - * main/vers_id.h: Added DESCENT_VERSION constant - * main/inferno.c: Added command-line help. - * include/ogl_init.h: opengl improvments (following d1x changes) - -2001-10-07 Bradley Bell - - * aclocal.m4, conf.h.in, configure.in, arch/Makefile.am, - arch/ogl/Makefile.am: Remove duplicate headers. - -2001-08-02 Thimo Neubauer - - * mem/mem.c: totally crippled the memory manager because it does - not make sense for non-DOS-systems and it would have been too - complicated to get it 64bit clean - -2001-06-19 Bradley Bell - - * cvshowto.txt: updated anonymous password - -2001-02-08 Bradley Bell - - * COPYING, license.txt: Added d1x license - -2001-02-01 Bradley Bell - - * aclocal.m4, configure.in: Better detecting of SDL and GL/GLU - -2001-01-31 Bradley Bell - - * configure.in, arch/include/mouse.h, include/pstypes.h, - main/game.c, main/gamepal.h: OpenGL support under Cygwin/SDL - * main/polyobj.c: fix typo - * 2d/Makefile.am, 2d/bitblt.c, 2d/bitmap.c, 2d/box.c, 2d/canvas.c, - 2d/circle.c, 2d/disc.c, 2d/font.c, 2d/gpixel.c, 2d/ibitblt.c, - 2d/line.c, 2d/palette.c, 2d/pcx.c, 2d/pixel.c, 2d/poly.c, - 2d/rect.c, 2d/rle.c, 2d/scale.c, 2d/scalec.c, 2d/tmerge.c, - 3d/clipper.c, 3d/draw.c, 3d/globvars.c, 3d/instance.c, 3d/interp.c, - 3d/matrix.c, 3d/points.c, 3d/rod.c, 3d/setup.c, arch/Makefile.am, - cfile/cfile.c, iff/iff.c, main/ai.c, main/ai2.c, main/aipath.c, - main/automap.c, main/bm.c, main/bmread.c, main/cmd.c, - main/cntrlcen.c, main/collide.c, main/config.c, main/console.c, - main/controls.c, main/credits.c, main/crypt.c, main/dumpmine.c, - main/effects.c, main/endlevel.c, main/escort.c, main/fireball.c, - main/fuelcen.c, main/fvi.c, main/game.c, main/gamecntl.c, - main/gamefont.c, main/gamemine.c, main/gamepal.c, main/gamerend.c, - main/gamesave.c, main/gameseg.c, main/gameseq.c, main/hostage.c, - main/kconfig.c, main/kmatrix.c, main/laser.c, main/lighting.c, - main/mglobal.c, main/mission.c, main/morph.c, main/netmisc.c, - main/network.c, main/newdemo.c, main/newmenu.c, main/object.c, - main/paging.c, main/physics.c, main/piggy.c, main/polyobj.c, - main/powerup.c, main/render.c, main/robot.c, main/slew.c, - main/songs.c, main/switch.c, main/texmerge.c, main/text.c, - main/titles.c, main/vclip.c, main/wall.c, main/weapon.c, - maths/Makefile.am, maths/fixc.c, maths/rand.c, maths/tables.c, - maths/vecmat.c, mem/mem.c, misc/args.c, misc/byteswap.c, - misc/d_delay.c, misc/d_glob.c, misc/d_io.c, misc/error.c, - misc/hash.c, misc/strio.c, misc/strutil.c, texmap/Makefile.am, - texmap/ntmap.c, texmap/scanline.c, texmap/tmapflat.c: Makefile and - conf.h fixes - * arch/dos_findfile.c, arch/dos_modex.asm, include/console.h, - include/modex.h, main/collide.c, main/gamesave.c, main/gameseq.c, - main/gauges.c, main/object.c, main/playsave.c, main/render.c, - main/state.c, mem/mem.c, texmap/ntmap.c, texmap/tmapflat.c: Fix - compiler warnings - * include/gr.h, main/menu.c: Fullscreen toggle added to screen res - menu - * configure.in, include/pstypes.h, main/kconfig.c: Support for - cross-compiling, and cygwin fixes - -2001-01-30 Bradley Bell - - * configure.in, arch/Makefile.am, arch/win32_findfile.c, - include/pstypes.h, include/strutil.h, main/Makefile.am, - misc/strutil.c, unused/win95/findfile.c: Cygwin support, using SDL. - needs --without-assembler and --without-network to compile - -2001-01-29 Bradley Bell - - * configure.in, main/Makefile.am: Fixes to build system - * main/kconfig.c: fix for non-linux joysticks - * arch/: dos/Makefile.am, dos/cdrom.c, dos/digi.c, dos/dosgr.c, - dos/dpmi.c, dos/findfile.c, dos/init.c, dos/ipx.c, dos/joy2.asm, - dos/joyc.c, dos/joydefs.c, dos/key.c, dos/modex.asm, dos/mouse.c, - dos/timer.asm, dos/tweak.inc, dos/vesa.c, dos/vgaregs.inc, - include/joy.h, linux/Makefile.am, linux/findfile.c, linux/init.c, - linux/ipx_bsd.c, linux/ipx_lin.c, linux/ipx_udp.c, - linux/linuxnet.c, sdl/Makefile.am, sdl/init.c, sdl/timer.c: Removed - duplicate files - * arch/: Makefile.am, dos_dpmi.c, dos_findfile.c, dos_init.c, - dos_ipx.c, dos_modex.asm, dos_timer.asm, dos_tweak.inc, dos_vesa.c, - dos_vgaregs.inc, linux_findfile.c, linux_init.c, linux_ipx_bsd.c, - linux_ipx_lin.c, linux_ipx_udp.c, linux_net.c, sdl_init.c, - sdl_timer.c: Fixed build system, minor fixes - * arch/dos/include/: joy.h, key.h, mouse.h: Unified input headers. - * arch/linux/Makefile.am, configure.in: Duplicate file removal. - -2001-01-28 Bradley Bell - - * conf.h.in, configure.in, arch/Makefile.am, - arch/dos/include/Makefile.am, arch/include/Makefile.am, - arch/include/key.h, main/Makefile.am: More header unification... - * main/newdemo.c: Added - * arch/include/: event.h, joy.h: unified input headers. - * acconfig.h, include/d_delay.h, main/Makefile.am, main/game.c: - OpenGL now uses SDL-GL instead of gii - * arch/include/: key.h, mouse.h: Unified arch headers - -2001-01-25 Bradley Bell - - * autogen.sh: use "set -e" so execution stops if something goes - wrong. - -2001-01-24 Bradley Bell - - * Makefile.am: typo - * Makefile.am: Add ChangeLog to dist - * ChangeLog: Putting this here so automake doesn't complain - -0.0.9: - -2001-01-24 Bradley Bell - - * INSTALL, NEWS, README, cvshowto.txt: updated documentation - * tools/: Makefile.am, cvs2cl/Makefile.am, cvs2cl/cvs2cl.pl: cvs2cl - for building ChangeLog from RCS entries - * Makefile.am, acconfig.h, autogen.sh, conf.h.in, configure.in, - arch/dos/allg_snd/Makefile.am, arch/dos/allg_snd/sound/Makefile.am, - arch/dos/allg_snd/sound/drv/Makefile.am, arch/dos/bak/Makefile.am, - arch/dos/comm/Makefile.am, arch/dos/comm/include/Makefile.am, - arch/dos/include/Makefile.am, 2d/Makefile.am, 3d/Makefile.am, - arch/Makefile.am, arch/dos/Makefile.am, - arch/dos/mm_snd/Makefile.am, arch/dos/mm_snd/include/Makefile.am, - arch/linux/Makefile.am, arch/linux/include/Makefile.am, - arch/ogl/Makefile.am, arch/sdl/Makefile.am, arch/win32/Makefile.am, - arch/win32/d3dframe/Makefile.am, arch/win32/include/Makefile.am, - cfile/Makefile.am, iff/Makefile.am, iff/archive/Makefile.am, - include/Makefile.am, main/editor/Makefile.am, main/old/Makefile.am, - unused/Makefile.am, unused/bios/Makefile.am, - unused/lib/Makefile.am, unused/novga/Makefile.am, - unused/pa_null/Makefile.am, unused/ui/Makefile.am, - unused/vga/Makefile.am, unused/vga/new/Makefile.am, - unused/win95/Makefile.am, main/Makefile.am, maths/Makefile.am, - misc/Makefile.am, texmap/Makefile.am: improved automake config. - make dist, VPATH builds, ... - * configure, Makefile.in, libtool, ltconfig, ltmain.sh, - stamp-h.in, 2d/Makefile.in, 3d/Makefile.in, arch/Makefile.in, - arch/dos/Makefile.in, arch/linux/Makefile.in, - arch/sdl/Makefile.in, cfile/Makefile.in, iff/Makefile.in, - main/Makefile.in, maths/Makefile.in, mem/Makefile.in, - misc/Makefile.in, texmap/Makefile.in: cruft removal - * 2d/diff, arch/dos/sgrep.out, arch/linux/stHqFIq1, main/test.txt: - junk removal - * ChangeLog, NEWS: moved old ChangeLog to NEWS - * configure.in, conf.h.in: moved NDEBUG to conf.h.in - * main/: game.c, kconfig.c, text.c: changed args_find to FindArg - * main/: gamecntl.c, inferno.c: changed args_find to FindArg, added - -grabmouse option - * arch/dos_init.c, arch/linux_init.c, arch/linux_ipx_udp.c, - arch/linux_net.c, arch/sdl_init.c, arch/dos/init.c, - arch/dos/joyc.c, arch/linux/init.c, arch/linux/ipx_udp.c, - arch/linux/linuxnet.c, arch/sdl/init.c, include/args.h, - main/config.c, main/hud.c, main/menu.c, main/multi.c, - main/network.c, main/piggy.c, main/polyobj.c, main/slew.c, - main/songs.c, misc/args.c: changed args_find to FindArg - -2001-01-22 Bradley Bell - - * configure, main/Makefile.am, main/Makefile.in: configuration - fixes - * include/error.h, include/mono.h, main/game.c, main/gamerend.c: - fix compiler warnings w/opengl - * include/console.h: ggi support - * arch/linux_init.c: svgalib support - * Makefile.in, conf.h.in, configure, configure.in, 2d/Makefile.am, - 2d/Makefile.in, 3d/Makefile.in, arch/Makefile.am, arch/Makefile.in, - arch/svgalib_init.c, cfile/Makefile.in, iff/Makefile.in, - main/Makefile.am, main/Makefile.in, maths/Makefile.am, - maths/Makefile.in, mem/Makefile.in, misc/Makefile.in, - texmap/Makefile.am, texmap/Makefile.in: configuration fixes - * iff/iff.c, include/u_mem.h: NDEBUG fixes - * main/: ai.h, inferno.c, lighting.c, object.c, render.c: fix - warnings and enable NDEBUG - * arch/svgalib_init.c: svgalib support - -2001-01-22 Michael Wagener - - * main/kconfig.c: joystick support - -2001-01-21 Bradley Bell - - * cvshowto.txt: new file, taken from d1x webpage - * AUTHORS, README: Taking over as maintainer of d2x - * ChangeLog: Grab mouse with SDL/X11 - * main/: gamecntl.c, inferno.c: Grab mouse with SDL/X11 - -2001-01-20 Bradley Bell - - * configure, configure.in: Turned -Werror back off by default - * README, configure, configure.in, 2d/font.c, arch/sdl_init.c, - iff/iff.c, include/3d.h, include/d_io.h, main/Makefile.am, - main/Makefile.in, main/bm.c, main/collide.c, main/credits.c, - main/fuelcen.h, main/game.c, main/gamecntl.c, main/gamepal.c, - main/gamerend.c, main/gamesave.c, main/gameseg.c, main/gameseq.c, - main/gauges.c, main/kconfig.c, main/kludge.c, main/kmatrix.c, - main/laser.c, main/multi.c, main/network.c, main/network.h, - main/newdemo.c, main/newmenu.c, main/object.c, main/object.h, - main/physics.c, main/piggy.c, main/polyobj.c, main/state.c, - main/switch.c, main/titles.c, main/wall.c: Got rid of all compiler - warnings, for non-OpenGL on linux, anyway... - -2001-01-19 Bradley Bell - - * copying: remove duplicate file - * Import of d2x-0.0.9-pre1 - * Import of d2x-0.0.8 diff --git a/Info.plist.in b/Info.plist.in deleted file mode 100644 index a4b3e848..00000000 --- a/Info.plist.in +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - @TARGETS@ - CFBundleGetInfoString - @VERSION@, Copyright 2003 Bradley Bell - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - @PACKAGE@ - CFBundlePackageType - APPL - CFBundleShortVersionString - @VERSION@ - CFBundleSignature - ???? - CFBundleVersion - @VERSION@ - NSMainNibFile - SDLMain.nib - NSPrincipalClass - NSApplication - NSHumanReadableCopyright - Copyright 2003 Bradley Bell - - diff --git a/Makefile.am b/Makefile.am index 28db43f2..20269ea4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,18 +1,16 @@ -SUBDIRS = 2d 3d maths mem cfile iff texmap misc arch main libmve utilities +AUTOMAKE_OPTIONS=1.5 -EXTRA_SUBDIRS = include unused debian rpm +SUBDIRS = 2d 3d maths mem cfile iff texmap misc arch main -if BUILD_MACOSX_BUNDLE -bundle_contents = @PACKAGE@.app/Contents -else -if BUILD_SIMPLE_BUNDLE -bundle_contents = @PACKAGE@ -endif -endif +EXTRA_SUBDIRS = includes tools unused bin_PROGRAMS = @TARGETS@ -EXTRA_PROGRAMS = d2x d2x-sdl d2x-gl d2x-svga d2x-ggi +EXTRA_PROGRAMS = d2x d2x-sdl d2x-ogl d2x-svga d2x-ggi + +CCLD = ${CC} +LDFLAGS = -export-dynamic +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ ARCH_LIBS = $(foreach subdir,${D2X_ARCH_SUBDIRS},arch/${subdir}/libarch_${subdir}.a) @@ -20,21 +18,17 @@ if MINGW32 LD_KLUDGE = main/inferno.o endif -if MACOSX -AM_LDFLAGS = -all_load -endif - if EDITOR EDITOR_LIBS = main/editor/libeditor.a endif d2x_SOURCES = d2x_sdl_SOURCES = -d2x_gl_SOURCES = +d2x_ogl_SOURCES = d2x_svga_SOURCES = d2x_ggi_SOURCES = -d2x_LDADD = ${LD_KLUDGE} main/libmain.a ${EDITOR_LIBS} 3d/lib3d.a 2d/lib2d.a ${ARCH_LIBS} libmve/libmve.a mem/libmem.a cfile/libcfile.a iff/libiff.a texmap/libtexmap.a misc/libmisc.a maths/libmaths.a +d2x_LDADD = ${LD_KLUDGE} main/libmain.a ${EDITOR_LIBS} 3d/lib3d.a 2d/lib2d.a ${ARCH_LIBS} mem/libmem.a cfile/libcfile.a iff/libiff.a texmap/libtexmap.a misc/libmisc.a maths/libmaths.a if MINGW32 if USE_NETWORK @@ -43,77 +37,26 @@ else d2x_sdl_LDADD = ${d2x_LDADD} endif else -d2x_sdl_LDADD = ${d2x_LDADD} -lm +d2x_sdl_LDADD = ${d2x_LDADD} -lm -ldl -lpthread endif -d2x_gl_LDADD = ${d2x_sdl_LDADD} ${OGL_LIBS} +d2x_ogl_LDADD = ${d2x_sdl_LDADD} ${OGL_LIBS} d2x_svga_LDADD = ${d2x_sdl_LDADD} ${SVGA_LIBS} d2x_ggi_LDADD = ${d2x_sdl_LDADD} ${GGI_LIBS} dist-hook: rm -rf `find $(distdir) -name CVS` # rm -f `find $(distdir) -name Makefile` + $(MAKE) changelog + cp -a $(srcdir)/ChangeLog $(distdir) -pkgdatadir = @sharepath@ -missiondir = ${pkgdatadir}/missions - -CLEANFILES = @TARGETS@ Info.plist - -if BUILD_MACOSX_BUNDLE - -@PACKAGE@_bundle: @TARGETS@ - mkdir -p $(bundle_contents)/MacOS - echo "APPL????" > $(bundle_contents)/PkgInfo - $(INSTALL_DATA) Info.plist $(bundle_contents) - $(INSTALL_PROGRAM) @TARGETS@ $(bundle_contents)/MacOS/ - -install-exec-hook: @PACKAGE@_bundle - rm -rf $(DESTDIR)$(prefix)/@PACKAGE@.app - mkdir -p $(DESTDIR)$(prefix)/ - cp -r @PACKAGE@.app $(DESTDIR)$(prefix)/ - -clean-local: - rm -rf $(bundle_contents) - -else - -if BUILD_SIMPLE_BUNDLE - -@PACKAGE@_bundle: @TARGETS@ - $(INSTALL_PROGRAM) @TARGETS@ $(bundle_contents)/ - -install-exec-hook: @PACKAGE@_bundle - rm -rf $(DESTDIR)/$(prefix)/@PACKAGE@ - mkdir -p $(DESTDIR)/$(prefix)/ - cp COPYING @PACKAGE@/COPYING.txt - cp COPYING.LIB @PACKAGE@/COPYING_LIB.txt - cp ChangeLog @PACKAGE@/ChangeLog.txt - cp TODO @PACKAGE@/TODO.txt - cp README @PACKAGE@/README.txt - cp README.jp @PACKAGE@/README_jp.txt - cp README.sfont @PACKAGE@/sfont.txt - cp README.xkobo @PACKAGE@/xkobo.txt - cp README.xkobo.jp @PACKAGE@/xkobo_jp.txt - cp 501 @PACKAGE@/scores/42 - cp -r @PACKAGE@ $(DESTDIR)/$(prefix)/ - -clean-local: - rm -rf $(bundle_contents) - -else -@PACKAGE@_bundle: - -install-exec-hook: - -clean-local: - -endif - -endif +changelog:: + rm -f $(srcdir)/ChangeLog + touch $(srcdir)/ChangeLog + cd $(srcdir) && tools/cvs2cl/cvs2cl.pl -b --utc + rm -f $(srcdir)/ChangeLog.bak EXTRA_DIST = ${EXTRA_SUBDIRS} \ ChangeLog \ -README.utils \ djgpp.bat djgpp.sh \ autogen.sh cygconf \ -cvshowto.txt readme.txt installation.txt compilerdefs.txt \ -d2x-sdl.sh d2x-gl.sh +cvshowto.txt readme.txt license.txt installation.txt mingw32.txt compilerdefs.txt diff --git a/NEWS b/NEWS index 7cab2a01..c9bdcba2 100644 --- a/NEWS +++ b/NEWS @@ -1,45 +1,3 @@ ---- Version 0.2.4 --- -- Fix crash on some mission briefings - ---- Version 0.2.3 --- -- Fix linking bug on OS X - ---- Version 0.2.2 --- -- Support for OS X 10.2 added - ---- Version 0.2.1 --- -- D1 Mac versions should now work. - ---- Version 0.2.0 --- -- Movie support :-) -- Bigendian linux/unix support, including OS X and Sparc/Solaris -- Menus now look right w/OpenGL -- Loads just about every conceivable d1/d2 level, including: - Descent I Shareware - Descent I OEM (Destination Saturn) - Descent I Full Version - Descent II Shareware - Descent II OEM (Destination Quartzon) - Descent II Full Version - Descent II Vertigo - Descent I add-on levels - Descent II add-on levels -- UDP, IPX, and Kali Networking -- Re-enabled linux joystick -- Added some standalone utilities: - mveplayer - Plays .mve movie files. - hogcreate, hogextract - create and extract .hog archives - mvlcreate, mvlextract - create and extract .mvl archives - tex2txb, txb2tex - encode and decode text for briefings, etc. - ---- Version 0.1.3 --- -- deb and rpm support added -- Added hotkeys to toggle fullscreen mode (same as d1x) -- joystick (via SDL) works -- fixed bug preventing some high-res modes in SDL -- disabled cockpit in ogl modes (causes crashes) -- automap resolution selectable with -automapx or -automap_gameres - --- Version 0.1.2 --- - SDL uses mouse wheel to emulate 3rd axis. - Player files created with descent 2 should now work with d2x. diff --git a/README b/README index 46ca5552..4a88aa4d 100644 --- a/README +++ b/README @@ -1,97 +1,51 @@ =========== - D2X +D2X =========== -http://icculus.org/d2x +http://shelob.classrooms.washington.edu/d2x +(anybody with a cooler domain want to host? or CNAME it?) - -Useful Links: -============= -Nasm: http://nasm.sourceforge.net -SDL: http://www.libsdl.org - - -Linux/Unix: -=========== +Linux: +====== Required tools: -* GCC 2.95 or higher -* SDL 1.1.0 or higher -* NASM 0.98 (OPTIONAL but RECOMMENDED for x86) +* GCC 2.95 +* SDL 1.0 or higher + (get it from http://www.devolution.com/~slouken/projects/SDL/) +* NASM 0.98 (OPTIONAL but RECOMMENDED, not sure, try your linux distribution) * A thread safe X server. -* GNU make is probably required as well. +* Make, sed, etc... + Build instructions: Install all of the components above. Next, from the d2x directory: ./configure - ./configure --help will show you the available options. - If you have a 3d graphics card, use --with-opengl - -VPATH builds also work (i.e., you can put the source in one directory -and build in another. Just execute the configure script from the -build directory like so: -mkdir d2x-build -cd d2x-build -../d2x-source/configure +(./configure --help will show you the available options) +For OpenGL support, try configuring with --with-opengl. Your mileage may vary +(but basically, you need an accelerated Mesa sitting somewhere where d2x can + see it)... The OpenGL support isn't perfect, but it works... make -make install -on systems where `make' isn't GNU make, use `gmake' instead. +Hopefully d2x will build. Do not be concerned about warnings, they are fairly +unimportant. -see installation.txt for info on where to put your datafiles, etc. Known bugs/issues: - * Serial support doesn't work. (UDP and IPX networking does) +* Movies (unlikely ever to be supported) * Sound glitches (due to stuff I haven't implemented) * The mouse support is at the same level as it was in d1x (as in, it - kind of works) (btb: works pretty good for me.) - - -Win32: -====== - -Required tools: -* Cygwin - d2x doesn't use Cygwin, but it makes building it easier (to me). - You can probably build it with just MinGW, but I haven't tried yet. -* SDL 1.1.0 or higher -* NASM 0.98 (OPTIONAL but RECOMMENDED) - -Note that SDL.dll needs to be in your executable PATH, since that is -where windows looks for dlls. -I recommend copying or moving it to /usr/local/bin: -cp /usr/local/lib/SDL.dll /usr/local/bin - -If you need to run autogen.sh (e.g. to rebuild the configure scripts, -or to build from cvs) sdl.m4 will have to be somewhere where aclocal -can find it. -You can fix this by setting the ACLOCAL_FLAGS variable like this: -export ACLOCAL_FLAGS=/usr/local/share/aclocal - -Now you can configure d2x as normal. i.e. -./configure -or -./configure --with-opengl - -automake/autoconf in cygwin has a problem with not always putting the -.exe extentions where they need to be. So you may have to run make -twice, like so: -make && make d2x-sdl.exe -or -make && make d2x-gl.exe - -Then just copy your executable and SDL.dll into the descent2 directory. + kind of works) +* Something went screwy with the control config system, it kinda got "d1xed"... +* OpenGL leaks memory like it is going out of fashion. It leaked about + 64meg in a few minutes for me. I need to debug this =) MS-DOS: ======= -Dos support isn't a high priority right now, so things may be a little -messed up. - Required tools: * DJGPP v2 The following DJGPP packages are ALL REQUIRED (newer versions are ok)! @@ -120,34 +74,94 @@ Hopefully things will work out and the package will build correctly for you. Known bugs/issues: * Serial and network support missing. * Sound support missing. +* Movie support missing + + + +Reporting bugs/feedback: +======================== + +There are two ways to report bugs and give feedback: +1) Get on the descent-source mailing list by sending an email to +majordomo@warpcore.org with the body as: "subscribe descent-source +". Discussions about the source code in general +are available here, and is the main list that d2x and d1x, a similar +project for descent 1 is discussed on. Patches and questions can be +posted there, as well. +2) Send feedback directly to me, bradleyb@u.washington.edu. I'll try +to get back to you ASAP, depending on real-life concerns =) -MAC OS X -======== +/* THE OLD README FOLLOWS */ +Legal Stuff: -Install the latest version of apple's developer tools. -Compile and install SDL from source: d2x doesn't use Project Builder. +THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX +SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO +END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A +ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS +IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS +SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE +FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE +CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. -configure and compile as with other unices. +We make no warranties as to the usability or correctness of this code. -Known bugs/issues: -* Serial and network support missing -* GL version very buggy +============================================ +Message from Matt Toschlog & Mike Kulas: +Descent fans: -Bugs/feedback: -============== +Here, finally, is the source for Descent II. We've been so busy with +Descent 3, Mercenary, FreeSpace, FreeSpace 2, and several other +projects that we haven't given much thought to this old code. But we +know that many of you are eager to get it, so here you go. -There are three places to report bugs and give feedback: +We were amazed and impressed at the cool things people did with +the Descent source we released a few years ago. It touches us +deeply how devoted some people are to the Descent series, and we +look forward to seeing what people can do with this Descent II +source. -You can get on the descent-source mailing list by sending an email to -majordomo@warpcore.org with the body as: "subscribe descent-source -". Discussions about the source code in general -are available here, and is the main list that d2x and d1x, a similar -project for descent 1, are discussed on. Patches and questions can be -posted there, as well. +Matt Toschlog Mike Kulas +Outrage Entertainment Volition, Inc. + +============================================ + +About the Source Code: + +Included is almost all the source code to Descent 2, ver. 1.2. We removed +all code to which we did not own the copyright. This mainly involved low- +level sound and modem code and the movie code. + +The Descent Network has agreed to provide a list of mirror locations where +this code can be downloaded. The location is: + +http://www.descent2.com/ddn/sources/descent2 + +The following tools were used in the development of Descent: +Watcom C/C++, version 9.5 +Microsoft Macro Assembler, version 6.1x +Opus Make, version 6.01 + +Have fun with the code! +Parallax Software Corporation +12/14/1999 + + +As Packaged the code currently will not compile. Some code had to be removed +to release it, therefore you will get some missing file errors when building. + +Much of this code is very close to the Descent 1 source code. Many people have +put effort into porting that code, so if you are interested in porting D2, you +should be able to take advantage of some of that work. + +A few good web sites to check out are: + +The D1X Project: +http://d1x.warpcore.org -Use Bugzilla. https://bugzilla.icculus.org/ +The Descent Network: +http://www.descent-network.com -Contact me directly, btb@icculus.org. I'll try to get back to you -ASAP, depending on real-life concerns =) diff --git a/README.utils b/README.utils deleted file mode 100644 index 42da0b68..00000000 --- a/README.utils +++ /dev/null @@ -1,43 +0,0 @@ -The d2x source code includes a few other programs besides Descent II -itself. These are: - -mveplayer -========= -A standalone MVE movie player. So far, it is able to play all MVE -files I have been able to find. If you find one that doesn't work, -please let me know. Note that the "mve" files found in the Macintosh -version of Descent II are not really mve files. They appear to be -some sort of quicktime-related format. - -To build mveplayer, configure the source tree as normal, then execute -"make mveplayer" from within the libmve subdirectory. - - -hogcreate -========= -Creates a hog file from all the files in the current directory. - -hogextract -========== -Extracts a hog file into the current directory - -mvlcreate -========= -Creates an mvl file from all the files in the current directory. - -mvlextract -========== -Extracts an mvl file into the current directory - -tex2txb -======= -Converts an ascii tex (briefing) file to an "encrypted" txb file. - -txb2tex -======= -Converts an encrypted txb file to an ascii tex file. - -To build the rest of the utilities, configure the source tree as -normal. Then, from within the utilities subdirectory, execute "make -" to build just that utility, or "make utils" to build all of -them. diff --git a/TODO b/TODO deleted file mode 100644 index 635b7d24..00000000 --- a/TODO +++ /dev/null @@ -1,6 +0,0 @@ -See bugzilla for a more complete list of issues: -https://bugzilla.icculus.org/buglist.cgi?product=d2x&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED - -* Rearrange build system -* use autoconf macros to replace junk in pstypes.h -* use unarj (or code) to extract necessary files from the CD as needed. diff --git a/acconfig.h b/acconfig.h new file mode 100644 index 00000000..c337f994 --- /dev/null +++ b/acconfig.h @@ -0,0 +1,82 @@ +/* Define if you want an assembler free build */ +#undef NO_ASM + +/* Define if you want a network build */ +#undef NETWORK + +/* Define if you want to build the editor */ +#undef EDITOR + +/* Define if you want to build the demo version */ +#undef SHAREWARE + +/* Define if you want an OpenGL build */ +#undef OGL + +/* Define if you want an SVGALib build */ +#undef SVGA + +/* Define if you want a GGI build */ +#undef GGI + +/* Define to disable asserts, int3, etc. */ +#undef NDEBUG + +/* Define for a "release" build */ +#undef RELEASE + +/* Define to enable cross-platform bitmap/palette loading functions */ +#undef PORTABLE_LOADER + +/* Define to enable trick to show movies */ +#undef MOVIE_TRICK + +/* Define to render endlevel flythrough sequences (instead of movies) */ +#undef NMOVIES + +/* Define to use SDL Joystick */ +#undef SDL_JOYSTICK + +/* Define this to be the shared game directory root */ +#undef SHAREPATH + +@BOTTOM@ + +/* General defines */ +#define NMONO 1 +#define PIGGY_USE_PAGING 1 +#define NEWDEMO 1 + +#ifdef __linux__ +# define __SDL__ 1 +# define SDL_AUDIO 1 + +# ifdef OGL +# define SDL_GL_VIDEO 1 +# define SDL_INPUT 1 +# else +# ifdef GGI +# define GGI_VIDEO 1 +# define GII_INPUT 1 +# else +# ifdef SVGA +# define SVGALIB_VIDEO 1 +# define SVGALIB_INPUT 1 +# else +# define SDL_VIDEO 1 +# define SDL_INPUT 1 +# endif +# endif +# endif +#endif + +#ifdef __MINGW32__ +# define __SDL__ 1 +# define SDL_AUDIO 1 +# define SDL_INPUT 1 +# ifdef OGL +# define SDL_GL_VIDEO 1 +# else +# define SDL_VIDEO 1 +# endif +#endif diff --git a/arch/.cvsignore b/arch/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/arch/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/arch/dos/.cvsignore b/arch/dos/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/arch/dos/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/arch/dos/Makefile.am b/arch/dos/Makefile.am index f96fa2df..ae118fdd 100644 --- a/arch/dos/Makefile.am +++ b/arch/dos/Makefile.am @@ -2,10 +2,10 @@ EXTRA_SUBDIRS = allg_snd bak comm include mm_snd noinst_LIBRARIES = libarch_dos.a -INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/include -I$(top_srcdir)/main -I$(srcdir)/include +INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/includes -I$(top_srcdir)/main -I$(srcdir)/include libarch_dos_a_SOURCES = \ -digi.c dpmi.c findfile.c gr.c init.c ipx.c joyc.c joydefs.c key.c mouse.c rbaudio.c vesa.c +cdrom.c digi.c dpmi.c findfile.c gr.c init.c ipx.c joyc.c joydefs.c key.c mouse.c vesa.c SUFFIXES = .asm %.o: %.asm diff --git a/arch/dos/rbaudio.c b/arch/dos/cdrom.c similarity index 81% rename from arch/dos/rbaudio.c rename to arch/dos/cdrom.c index dce0db47..bb94ff95 100644 --- a/arch/dos/rbaudio.c +++ b/arch/dos/cdrom.c @@ -1,16 +1,13 @@ /* - * $Source: /cvs/cvsroot/d2x/arch/dos/rbaudio.c,v $ - * $Revision: 1.1 $ + * $Source: /cvs/cvsroot/d2x/arch/dos/cdrom.c,v $ + * $Revision: 1.3 $ * $Author: bradleyb $ - * $Date: 2002-07-18 08:22:18 $ + * $Date: 2001-10-25 08:25:33 $ * * DPH: This is the file where all the stub functions go. * The aim is to have nothing in here, eventually * * $Log: not supported by cvs2svn $ - * Revision 1.3 2001/10/25 08:25:33 bradleyb - * Finished moving stuff to arch/blah. I know, it's ugly, but It'll be easier to sync with d1x. - * * Revision 1.3 2001/01/31 14:04:45 bradleyb * Fix compiler warnings * @@ -28,7 +25,7 @@ #include "pstypes.h" #include "error.h" #include "args.h" -#include "rbaudio.h" + extern int Redbook_playing; static int initialised = 0; diff --git a/arch/dos/digimm.c b/arch/dos/digimm.c index 9416e3cc..34087a7a 100644 --- a/arch/dos/digimm.c +++ b/arch/dos/digimm.c @@ -268,7 +268,7 @@ MDRIVER *drv = &drv_sb; char allegro_error[128]; int md_mode = DMODE_STEREO; -int md_mixfreq = digi_sample_rate; //11025; +int md_mixfreq = 11025; int md_dmabufsize = 1024; void install_int_ex(void (*)(), long speed); @@ -288,7 +288,7 @@ int digi_init() //end edit by adb #if 0 - WaveSpec.freq = digi_sample_rate; //11025; + WaveSpec.freq = 11025; WaveSpec.format = AUDIO_U8 | AUDIO_STEREO; WaveSpec.samples = SOUND_BUFFER_SIZE; WaveSpec.callback = audio_mixcallback; diff --git a/arch/ggi/.cvsignore b/arch/ggi/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/arch/ggi/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/arch/ggi/Makefile.am b/arch/ggi/Makefile.am index b24dc640..5f766aa7 100644 --- a/arch/ggi/Makefile.am +++ b/arch/ggi/Makefile.am @@ -2,6 +2,6 @@ EXTRA_SUBDIRS = linux noinst_LIBRARIES = libarch_ggi.a -INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/include -I$(top_srcdir)/main +INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/includes -I$(top_srcdir)/main libarch_ggi_a_SOURCES = event.c gr.c init.c key.c mouse.c diff --git a/arch/ggi/key.c b/arch/ggi/key.c index fb4845dc..5985d593 100644 --- a/arch/ggi/key.c +++ b/arch/ggi/key.c @@ -1,15 +1,12 @@ /* * $Source: /cvs/cvsroot/d2x/arch/ggi/key.c,v $ - * $Revision: 1.2 $ - * $Author: btb $ - * $Date: 2003-02-27 22:07:21 $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2001-10-24 09:25:05 $ * * GGI keyboard input support * * $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.3 2001/01/29 14:03:57 bradleyb * Fixed build, minor fixes * @@ -30,6 +27,9 @@ #include "timer.h" #include "mono.h" +//added on 9/3/98 by Matt Mueller to free some cpu instead of hogging during menus and such +#include "d_delay.h" +//end this section addition - Matt Mueller #define KEY_BUFFER_SIZE 16 @@ -382,7 +382,7 @@ int key_inkey() key_data.keyhead = add_one(key_data.keyhead); } //added 9/3/98 by Matt Mueller to free cpu time instead of hogging during menus and such -// else timer_delay(1); +// else d_delay(1); //end addition - Matt Mueller return key; } diff --git a/arch/include/joy.h b/arch/include/joy.h index f146efa8..52ff12a9 100644 --- a/arch/include/joy.h +++ b/arch/include/joy.h @@ -1,4 +1,3 @@ -/* $ Id: $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -13,9 +12,22 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/arch/include/joy.h,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-18 23:59:22 $ * * Header for joystick functions * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/10/12 00:18:37 bradleyb + * Switched from Cygwin to mingw32 on MS boxes. Vastly improved compilability. + * + * Revision 1.2 2001/01/29 13:36:14 bradleyb + * Removed duplicate files + * + * Revision 1.1 2001/01/28 16:10:57 bradleyb + * unified input headers. * */ @@ -40,7 +52,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #if defined WINDOWS #define JOY_NUM_AXES 7 -#elif defined __unix__ +#elif defined __linux__ #define JOY_NUM_AXES 5 #else #define JOY_NUM_AXES 4 @@ -62,7 +74,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. /* not present in d2src, maybe we don't really need it? */ #define JOY_FRIENDLY_READINGS 8 -#ifdef __unix__ +#ifdef __linux__ #define MAX_BUTTONS 64 #else #define MAX_BUTTONS 20 diff --git a/arch/linux/.cvsignore b/arch/linux/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/arch/linux/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/arch/linux/Makefile.am b/arch/linux/Makefile.am index ea61115f..bb181f0c 100644 --- a/arch/linux/Makefile.am +++ b/arch/linux/Makefile.am @@ -2,21 +2,21 @@ EXTRA_SUBDIRS = include noinst_LIBRARIES = libarch_linux.a -INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/include -I$(top_srcdir)/main -I$(srcdir)/include +INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/includes -I$(top_srcdir)/main -I$(srcdir)/include + if USE_NETWORK -NETWORK_SRCS = ipx_bsd.c ipx_kali.c ipx_lin.c ipx_udp.c linuxnet.c ukali.c +NETWORK_SRCS = ipx_bsd.c ipx_kali.c ipx_lin.c linuxnet.c ukali.c endif -if USE_LINUX_JOY -JOYSTICK_SRCS = joystick.c joydefs.c +if !SDL_JOYSTICK +JOYSTICK_SRCS = joydefs.c joystick.c endif libarch_linux_a_SOURCES = ${NETWORK_SRCS} ${JOYSTICK_SRCS} findfile.c init.c EXTRA_libarch_linux_a_SOURCES = \ -ipx_bsd.c ipx_kali.c ipx_lin.c ipx_udp.c linuxnet.c ukali.c \ -joydefs.c joystick.c +ipx_bsd.c ipx_kali.c ipx_lin.c joydefs.c joystick.c linuxnet.c ukali.c EXTRA_DIST = ${EXTRA_SUBDIRS} \ -alsadigi.c hmistub.c hmiplay.c mono.c serial.c timer.c +alsadigi.c hmistub.c hmiplay.c ipx_udp.c mono.c serial.c timer.c ukali.c diff --git a/arch/linux/alsadigi.c b/arch/linux/alsadigi.c index 94bc8898..d68a80fe 100644 --- a/arch/linux/alsadigi.c +++ b/arch/linux/alsadigi.c @@ -1,9 +1,4 @@ -/* $Id: alsadigi.c,v 1.2 2003-03-13 00:20:21 btb Exp $ */ -/* - * - * ALSA digital audio support - * - */ +// ALSA digital audio support #include #include diff --git a/arch/linux/findfile.c b/arch/linux/findfile.c index d8adadc1..a1cc47e0 100644 --- a/arch/linux/findfile.c +++ b/arch/linux/findfile.c @@ -1,8 +1,17 @@ -/* $Id: findfile.c,v 1.7 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/findfile.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:25 $ * * Linux findfile functions * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/10/19 07:29:36 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * Revision 1.2 2001/01/29 13:35:08 bradleyb + * Fixed build system, minor fixes * */ @@ -30,9 +39,7 @@ int FileFindFirst(char *search_str, FILEFINDSTRUCT *ffstruct) Assert(ffstruct != NULL); r = glob(search_str, 0, NULL, &glob_a); - if (r) return 1; - - if (! glob_a.gl_pathc) return 1; + if (r == GLOB_NOMATCH) return -1; glob_whichfile = 0; diff --git a/arch/linux/hmiplay.c b/arch/linux/hmiplay.c index afc23d66..4002c1df 100644 --- a/arch/linux/hmiplay.c +++ b/arch/linux/hmiplay.c @@ -1,12 +1,9 @@ -/* $Id: hmiplay.c,v 1.2 2003-03-13 00:20:21 btb Exp $ */ -/* - * HMI midi playing routines by Jani Frilander - * +/* HMI midi playing routines by Jani Frilander + * * External device support by Patrick McCarthy * * Ported to d1x/sdl_threads by Matthew Mueller - * - */ +*/ #include #include diff --git a/arch/linux/include/ipx_bsd.h b/arch/linux/include/ipx_bsd.h index 6bea9f45..10a2f79b 100644 --- a/arch/linux/include/ipx_bsd.h +++ b/arch/linux/include/ipx_bsd.h @@ -1,8 +1,16 @@ -/* $Id: ipx_bsd.h,v 1.4 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/include/ipx_bsd.h,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ * * FIXME: add description * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * */ #ifndef _IPX_BSD_H @@ -10,5 +18,4 @@ #include "ipx_drv.h" extern struct ipx_driver ipx_bsd; - #endif diff --git a/arch/linux/include/ipx_drv.h b/arch/linux/include/ipx_drv.h deleted file mode 100644 index 44b5799b..00000000 --- a/arch/linux/include/ipx_drv.h +++ /dev/null @@ -1,72 +0,0 @@ -/* $Id: ipx_drv.h,v 1.4 2003-03-13 00:20:21 btb Exp $ */ -/* - * - * IPX driver interface - * - * parts from: - * ipx.h header file for IPX for the DOS emulator - * Tim Bird, tbird@novell.com - * - */ - -#ifndef _IPX_DRV_H -#define _IPX_DRV_H -#include - -#define IPX_MANUAL_ADDRESS - -#define MAX_PACKET_DATA 1500 - -typedef struct IPXAddressStruct { - u_char Network[4] __attribute__((packed)); - u_char Node[6] __attribute__((packed)); - u_char Socket[2] __attribute__((packed)); -} IPXAddress_t; - -typedef struct IPXPacketStructure { - u_short Checksum __attribute__((packed)); - u_short Length __attribute__((packed)); - u_char TransportControl __attribute__((packed)); - u_char PacketType __attribute__((packed)); - IPXAddress_t Destination __attribute__((packed)); - IPXAddress_t Source __attribute__((packed)); -} IPXPacket_t; - -typedef struct ipx_socket_struct { -#ifdef DOSEMU - struct ipx_socket_struct *next; - far_t listenList; - int listenCount; - far_t AESList; - int AESCount; - u_short PSP; -#endif - u_short socket; - int fd; -} ipx_socket_t; - -struct ipx_recv_data { - /* all network order */ - u_char src_network[4]; - u_char src_node[6]; - u_short src_socket; - u_short dst_socket; - int pkt_type; -}; - -struct ipx_driver { - int (*GetMyAddress)(void); - int (*OpenSocket)(ipx_socket_t *sk, int port); - void (*CloseSocket)(ipx_socket_t *mysock); - int (*SendPacket)(ipx_socket_t *mysock, IPXPacket_t *IPXHeader, - u_char *data, int dataLen); - int (*ReceivePacket)(ipx_socket_t *s, char *buffer, int bufsize, - struct ipx_recv_data *rec); - int (*PacketReady)(ipx_socket_t *s); -}; - -int ipx_general_PacketReady(ipx_socket_t *s); - -extern unsigned char ipx_MyAddress[10]; - -#endif /* _IPX_DRV_H */ diff --git a/arch/linux/include/ipx_hlpr.h b/arch/linux/include/ipx_hlpr.h index c0015249..056258a6 100644 --- a/arch/linux/include/ipx_hlpr.h +++ b/arch/linux/include/ipx_hlpr.h @@ -1,8 +1,16 @@ -/* $Id: ipx_hlpr.h,v 1.4 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/include/ipx_hlpr.h,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ * * FIXME: add description * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * */ #ifndef IPXHELPER_H_ diff --git a/arch/linux/include/ipx_kali.h b/arch/linux/include/ipx_kali.h index fa67e161..74e978c0 100644 --- a/arch/linux/include/ipx_kali.h +++ b/arch/linux/include/ipx_kali.h @@ -1,8 +1,16 @@ -/* $Id: ipx_kali.h,v 1.4 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/include/ipx_kali.h,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ * * FIXME: add description * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * */ #ifndef _IPX_KALI_H @@ -10,5 +18,4 @@ #include "ipx_drv.h" extern struct ipx_driver ipx_kali; - #endif diff --git a/arch/linux/include/ipx_ld.h b/arch/linux/include/ipx_ld.h index 6a42d86f..5ded27ea 100644 --- a/arch/linux/include/ipx_ld.h +++ b/arch/linux/include/ipx_ld.h @@ -1,10 +1,18 @@ -/* $Id: ipx_ld.h,v 1.4 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/include/ipx_ld.h,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ * * parts from: * ipx.h header file for IPX for the DOS emulator * Tim Bird, tbird@novell.com * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * */ #ifndef _IPX_DOSEMU diff --git a/arch/linux/include/ipx_lin.h b/arch/linux/include/ipx_lin.h index e9b064bc..da49c941 100644 --- a/arch/linux/include/ipx_lin.h +++ b/arch/linux/include/ipx_lin.h @@ -1,16 +1,22 @@ -/* $Id: ipx_lin.h,v 1.4 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/include/ipx_lin.h,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ * * FIXME: add description * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * */ #ifndef IPX_LINUX_H_ #define IPX_LINUX_H_ - #include #include "ipx_hlpr.h" - int ipx_linux_GetMyAddress(void); int ipx_linux_OpenSocket(ipx_socket_t *sk, int port); void ipx_linux_CloseSocket(ipx_socket_t *mysock); diff --git a/arch/linux/include/ipx_udp.h b/arch/linux/include/ipx_udp.h index 81da99f4..9862d5c8 100644 --- a/arch/linux/include/ipx_udp.h +++ b/arch/linux/include/ipx_udp.h @@ -1,8 +1,16 @@ -/* $Id: ipx_udp.h,v 1.4 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/include/ipx_udp.h,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ * * FIXME: add description * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * */ #ifndef _IPX_UDP_H @@ -10,5 +18,4 @@ #include "ipx_drv.h" extern struct ipx_driver ipx_udp; - #endif diff --git a/arch/linux/include/joystick.h b/arch/linux/include/joystick.h index 412284c4..a039aff0 100644 --- a/arch/linux/include/joystick.h +++ b/arch/linux/include/joystick.h @@ -1,5 +1,3 @@ -/* $Id: joystick.h,v 1.2 2003-03-13 00:20:21 btb Exp $ */ - #define MAX_AXES 32 typedef struct joystick_device { diff --git a/arch/linux/include/music.h b/arch/linux/include/music.h index 64c6d184..f5ba340b 100644 --- a/arch/linux/include/music.h +++ b/arch/linux/include/music.h @@ -1,5 +1,3 @@ -/* $Id: music.h,v 1.2 2003-03-13 00:20:21 btb Exp $ */ - #include #define SEQ_DEV "/dev/sequencer" diff --git a/arch/linux/include/serial.h b/arch/linux/include/serial.h index 70727cc7..e31839ae 100644 --- a/arch/linux/include/serial.h +++ b/arch/linux/include/serial.h @@ -1,15 +1,9 @@ -/* $Id: serial.h,v 1.2 2003-03-13 00:20:21 btb Exp $ */ -/* - * - * Name: Serial port support for Linux D1X - * Author: dph - * Date: Sun Oct 18, 1998 - * - */ +// Name: Serial port support for Linux D1X +// Author: dph +// Date: Sun Oct 18, 1998 #ifndef _SERIAL_H #define _SERIAL_H - void com_done(void); int com_init(void); int com_read(char *buffer, int len, int timeout_value); @@ -21,5 +15,4 @@ void com_setbaudrate(int rate); int com_readline(int timeout, char *input_buffer,int len); extern int commlib_initialised; - #endif diff --git a/arch/linux/include/ukali.h b/arch/linux/include/ukali.h index 398b2c04..e132e187 100644 --- a/arch/linux/include/ukali.h +++ b/arch/linux/include/ukali.h @@ -1,13 +1,25 @@ -/* $Id: ukali.h,v 1.7 2003-03-19 23:20:09 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/include/ukali.h,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ + * + * FIXME: add description + * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ * - * Header for kali support functions * */ #ifndef __UKALI_H__ #define __UKALI_H__ +//added on 10/04/98 by Matt Mueller to show correct ver in kali +#include "vers_id.h" +//end addition -MM + // 4213 is the port that KaliNix is listening on // // char code; // 1 == open, 2 == close, 3 == data, 5 == GetMyAddr diff --git a/arch/linux/init.c b/arch/linux/init.c index fd5ac065..7e13fb66 100644 --- a/arch/linux/init.c +++ b/arch/linux/init.c @@ -1,8 +1,15 @@ -/* $Id: init.c,v 1.6 2003-03-19 23:20:09 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/init.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 09:01:56 $ * * linux init.c - added Matt Mueller 9/6/98 * + * $Log: not supported by cvs2svn $ + * Revision 1.4 2001/01/29 13:35:08 bradleyb + * Fixed build system, minor fixes + * */ #ifdef HAVE_CONFIG_H @@ -13,6 +20,7 @@ #include #include "pstypes.h" #include "console.h" +#include "text.h" #include "event.h" #include "error.h" #include "joy.h" @@ -36,6 +44,10 @@ void arch_init() #ifdef SVGALIB_INPUT arch_svgalib_init(); #endif + if (!FindArg( "-nojoystick" )) { + con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_6); + joy_init(); + } //added 06/09/99 Matt Mueller - fix nonetwork compile #ifdef NETWORK //end addition -MM diff --git a/arch/linux/ipx_bsd.c b/arch/linux/ipx_bsd.c index 38a9fdf8..383918ef 100644 --- a/arch/linux/ipx_bsd.c +++ b/arch/linux/ipx_bsd.c @@ -1,16 +1,25 @@ -/* $Id: ipx_bsd.c,v 1.6 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/ipx_bsd.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:25 $ * * IPX driver using BSD style sockets * Mostly taken from dosemu * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/10/19 07:29:36 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * Revision 1.2 2001/01/29 13:35:08 bradleyb + * Fixed build system, minor fixes + * */ #ifdef HAVE_CONFIG_H #include #endif -#include #include #include #include @@ -28,7 +37,6 @@ #include #include -#include "pstypes.h" #include "ipx_drv.h" #include "ipx_bsd.h" @@ -39,195 +47,211 @@ #define leave_priv_setting() #endif -static int ipx_bsd_GetMyAddress(void) +static ipx_socket_t mysock; + +static int ipx_bsd_GetMyAddress( void ) { - int sock; - struct sockaddr_ipx ipxs; - struct sockaddr_ipx ipxs2; - int len; - int i; - - sock=socket(AF_IPX,SOCK_DGRAM,PF_IPX); - if (sock == -1) { - n_printf("IPX: could not open socket in GetMyAddress\n"); - return(-1); - } - - /* bind this socket to network 0 */ - ipxs.sipx_family=AF_IPX; + int sock; + struct sockaddr_ipx ipxs; + struct sockaddr_ipx ipxs2; + int len; + int i; + + sock=socket(AF_IPX,SOCK_DGRAM,PF_IPX); + if(sock==-1) + { + n_printf("IPX: could not open socket in GetMyAddress\n"); + return(-1); + } + + /* bind this socket to network 0 */ + ipxs.sipx_family=AF_IPX; #ifdef IPX_MANUAL_ADDRESS - memcpy(&ipxs.sipx_network, ipx_MyAddress, 4); + memcpy(&ipxs.sipx_network, ipx_MyAddress, 4); #else - ipxs.sipx_network=0; -#endif - ipxs.sipx_port=0; - - if (bind(sock,(struct sockaddr *)&ipxs,sizeof(ipxs)) == -1) { - n_printf("IPX: could bind to network 0 in GetMyAddress\n"); - close( sock ); - return(-1); - } - - len = sizeof(ipxs2); - if (getsockname(sock,(struct sockaddr *)&ipxs2,&len) < 0) { - n_printf("IPX: could not get socket name in GetMyAddress\n"); - close( sock ); - return(-1); - } - - memcpy(ipx_MyAddress, &ipxs2.sipx_network, 4); - for (i = 0; i < 6; i++) { - ipx_MyAddress[4+i] = ipxs2.sipx_node[i]; - } - close( sock ); - return(0); + ipxs.sipx_network=0; +#endif + ipxs.sipx_port=0; + + if(bind(sock,(struct sockaddr *)&ipxs,sizeof(ipxs))==-1) + { + n_printf("IPX: could bind to network 0 in GetMyAddress\n"); + close( sock ); + return(-1); + } + + len = sizeof(ipxs2); + if (getsockname(sock,(struct sockaddr *)&ipxs2,&len) < 0) { + n_printf("IPX: could not get socket name in GetMyAddress\n"); + close( sock ); + return(-1); + } + + memcpy(ipx_MyAddress, &ipxs2.sipx_network, 4); + for (i = 0; i < 6; i++) { + ipx_MyAddress[4+i] = ipxs2.sipx_node[i]; + } + close( sock ); + return(0); } -static int ipx_bsd_OpenSocket(ipx_socket_t *sk, int port) +static int ipx_bsd_OpenSocket(int port) { - int sock; /* sock here means Linux socket handle */ - int opt; - struct sockaddr_ipx ipxs; - int len; - struct sockaddr_ipx ipxs2; - - /* DANG_FIXTHIS - kludge to support broken linux IPX stack */ - /* need to convert dynamic socket open into a real socket number */ - /* - if (port == 0) { - n_printf("IPX: using socket %x\n", nextDynamicSocket); - port = nextDynamicSocket++; - } - */ - /* do a socket call, then bind to this port */ - sock = socket(AF_IPX, SOCK_DGRAM, PF_IPX); - if (sock == -1) { - n_printf("IPX: could not open IPX socket.\n"); - return -1; - } + int sock; /* sock here means Linux socket handle */ + int opt; + struct sockaddr_ipx ipxs; + int len; + struct sockaddr_ipx ipxs2; + + /* DANG_FIXTHIS - kludge to support broken linux IPX stack */ + /* need to convert dynamic socket open into a real socket number */ +/* if (port == 0) { + n_printf("IPX: using socket %x\n", nextDynamicSocket); + port = nextDynamicSocket++; + } +*/ + /* do a socket call, then bind to this port */ + sock = socket(AF_IPX, SOCK_DGRAM, PF_IPX); + if (sock == -1) { + n_printf("IPX: could not open IPX socket.\n"); + return -1; + } #ifdef DOSEMU - opt = 1; - /* turn on socket debugging */ - if (d.network) { - enter_priv_on(); - if (setsockopt(sock, SOL_SOCKET, SO_DEBUG, &opt, sizeof(opt)) == -1) { - leave_priv_setting(); - n_printf("IPX: could not set socket option for debugging.\n"); - return -1; - } - leave_priv_setting(); - } -#endif - opt = 1; - /* Permit broadcast output */ - enter_priv_on(); - if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, - &opt, sizeof(opt)) == -1) { - leave_priv_setting(); - n_printf("IPX: could not set socket option for broadcast.\n"); - return -1; - } + opt = 1; + /* turn on socket debugging */ + if (d.network) { + enter_priv_on(); + if (setsockopt(sock, SOL_SOCKET, SO_DEBUG, &opt, sizeof(opt)) == -1) { + leave_priv_setting(); + n_printf("IPX: could not set socket option for debugging.\n"); + return -1; + } + leave_priv_setting(); + } +#endif + opt = 1; + /* Permit broadcast output */ + enter_priv_on(); + if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, + &opt, sizeof(opt)) == -1) { + leave_priv_setting(); + n_printf("IPX: could not set socket option for broadcast.\n"); + return -1; + } #ifdef DOSEMU - /* allow setting the type field in the IPX header */ - opt = 1; + /* allow setting the type field in the IPX header */ + opt = 1; #if 0 /* this seems to be wrong: IPX_TYPE can only be set on level SOL_IPX */ - if (setsockopt(sock, SOL_SOCKET, IPX_TYPE, &opt, sizeof(opt)) == -1) { + if (setsockopt(sock, SOL_SOCKET, IPX_TYPE, &opt, sizeof(opt)) == -1) { #else - /* the socket _is_ an IPX socket, hence it first passes ipx_setsockopt() - * in file linux/net/ipx/af_ipx.c. This one handles SOL_IPX itself and - * passes SOL_SOCKET-levels down to sock_setsockopt(). - * Hence I guess the below is correct (can somebody please verify this?) - * -- Hans, June 14 1997 - */ - if (setsockopt(sock, SOL_IPX, IPX_TYPE, &opt, sizeof(opt)) == -1) { + /* the socket _is_ an IPX socket, hence it first passes ipx_setsockopt() + * in file linux/net/ipx/af_ipx.c. This one handles SOL_IPX itself and + * passes SOL_SOCKET-levels down to sock_setsockopt(). + * Hence I guess the below is correct (can somebody please verify this?) + * -- Hans, June 14 1997 + */ + if (setsockopt(sock, SOL_IPX, IPX_TYPE, &opt, sizeof(opt)) == -1) { #endif - leave_priv_setting(); - n_printf("IPX: could not set socket option for type.\n"); - return -1; - } -#endif - ipxs.sipx_family = AF_IPX; - ipxs.sipx_network = *((unsigned int *)&ipx_MyAddress[0]); - /* ipxs.sipx_network = htonl(MyNetwork); */ - bzero(ipxs.sipx_node, 6); /* Please fill in my node name */ - ipxs.sipx_port = htons(port); - - /* now bind to this port */ - if (bind(sock, (struct sockaddr *) &ipxs, sizeof(ipxs)) == -1) { - n_printf("IPX: could not bind socket to address\n"); - close( sock ); - leave_priv_setting(); - return -1; - } - - if( port==0 ) { - len = sizeof(ipxs2); - if (getsockname(sock,(struct sockaddr *)&ipxs2,&len) < 0) { - n_printf("IPX: could not get socket name in IPXOpenSocket\n"); - close( sock ); - leave_priv_setting(); - return -1; - } else { - port = htons(ipxs2.sipx_port); - n_printf("IPX: opened dynamic socket %04x\n", port); - } - } - leave_priv_setting(); - sk->fd = sock; - sk->socket = port; - return 0; -} + leave_priv_setting(); + n_printf("IPX: could not set socket option for type.\n"); + return -1; + } +#endif + ipxs.sipx_family = AF_IPX; + ipxs.sipx_network = *((unsigned int *)&ipx_MyAddress[0]); +/* ipxs.sipx_network = htonl(MyNetwork); */ + bzero(ipxs.sipx_node, 6); /* Please fill in my node name */ + ipxs.sipx_port = htons(port); + + /* now bind to this port */ + if (bind(sock, (struct sockaddr *) &ipxs, sizeof(ipxs)) == -1) { + n_printf("IPX: could not bind socket to address\n"); + close( sock ); + leave_priv_setting(); + return -1; + } + + if( port==0 ) { + len = sizeof(ipxs2); + if (getsockname(sock,(struct sockaddr *)&ipxs2,&len) < 0) { + n_printf("IPX: could not get socket name in IPXOpenSocket\n"); + close( sock ); + leave_priv_setting(); + return -1; + } else { + port = htons(ipxs2.sipx_port); + n_printf("IPX: opened dynamic socket %04x\n", port); + } + } + leave_priv_setting(); + mysock.fd = sock; + mysock.socket = port; -static void ipx_bsd_CloseSocket(ipx_socket_t *mysock) { - /* now close the file descriptor for the socket, and free it */ - n_printf("IPX: closing file descriptor on socket %x\n", mysock->socket); - close(mysock->fd); + ipx_bsd_GetMyAddress(); + + return 0; } -static int ipx_bsd_SendPacket(ipx_socket_t *mysock, IPXPacket_t *IPXHeader, - u_char *data, int dataLen) { - struct sockaddr_ipx ipxs; +static void ipx_bsd_CloseSocket(void) { + /* now close the file descriptor for the socket, and free it */ + n_printf("IPX: closing file descriptor on socket %x\n", mysock.socket); + close(mysock.fd); +} - ipxs.sipx_family = AF_IPX; - /* get destination address from IPX packet header */ - memcpy(&ipxs.sipx_network, IPXHeader->Destination.Network, 4); - /* if destination address is 0, then send to my net */ - if (ipxs.sipx_network == 0) { - ipxs.sipx_network = *((unsigned int *)&ipx_MyAddress[0]); - /* ipxs.sipx_network = htonl(MyNetwork); */ - } - memcpy(&ipxs.sipx_node, IPXHeader->Destination.Node, 6); - memcpy(&ipxs.sipx_port, IPXHeader->Destination.Socket, 2); - ipxs.sipx_type = IPXHeader->PacketType; - /* ipxs.sipx_port=htons(0x452); */ - return sendto(mysock->fd, data, dataLen, 0, - (struct sockaddr *) &ipxs, sizeof(ipxs)); +static int ipx_bsd_SendPacket(IPXPacket_t *IPXHeader, + u_char *data, int dataLen) { + struct sockaddr_ipx ipxs; + + ipxs.sipx_family = AF_IPX; + /* get destination address from IPX packet header */ + memcpy(&ipxs.sipx_network, IPXHeader->Destination.Network, 4); + /* if destination address is 0, then send to my net */ + if (ipxs.sipx_network == 0) { + ipxs.sipx_network = *((unsigned int *)&ipx_MyAddress[0]); +/* ipxs.sipx_network = htonl(MyNetwork); */ + } + memcpy(&ipxs.sipx_node, IPXHeader->Destination.Node, 6); + //memcpy(&ipxs.sipx_port, IPXHeader->Destination.Socket, 2); + ipxs.sipx_port=htons(mysock.socket); + ipxs.sipx_type = IPXHeader->PacketType; + /* ipxs.sipx_port=htons(0x452); */ + return sendto(mysock.fd, data, dataLen, 0, + (struct sockaddr *) &ipxs, sizeof(ipxs)); } -static int ipx_bsd_ReceivePacket(ipx_socket_t *s, char *buffer, int bufsize, - struct ipx_recv_data *rd) { +static int ipx_bsd_ReceivePacket(char *buffer, int bufsize, + struct ipx_recv_data *rd) { int sz, size; struct sockaddr_ipx ipxs; - + sz = sizeof(ipxs); - if ((size = recvfrom(s->fd, buffer, bufsize, 0, - (struct sockaddr *) &ipxs, &sz)) <= 0) - return size; + if ((size = recvfrom(mysock.fd, buffer, bufsize, 0, + (struct sockaddr *) &ipxs, &sz)) <= 0) + return size; memcpy(rd->src_network, &ipxs.sipx_network, 4); memcpy(rd->src_node, ipxs.sipx_node, 6); rd->src_socket = ipxs.sipx_port; - rd->dst_socket = s->socket; + rd->dst_socket = mysock.socket; rd->pkt_type = ipxs.sipx_type; - + return size; } +static int ipx_bsd_general_PacketReady(void) { + return ipx_general_PacketReady(mysock.fd); +} + struct ipx_driver ipx_bsd = { - ipx_bsd_GetMyAddress, +// ipx_bsd_GetMyAddress, ipx_bsd_OpenSocket, ipx_bsd_CloseSocket, ipx_bsd_SendPacket, ipx_bsd_ReceivePacket, - ipx_general_PacketReady + ipx_bsd_general_PacketReady, + NULL, + 1, + NULL, + NULL, + NULL }; diff --git a/arch/linux/ipx_kali.c b/arch/linux/ipx_kali.c index a9cd7668..34f0d72c 100644 --- a/arch/linux/ipx_kali.c +++ b/arch/linux/ipx_kali.c @@ -1,8 +1,16 @@ -/* $Id: ipx_kali.c,v 1.5 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/ipx_kali.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ * * IPX driver for KaliNix interface * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 07:29:36 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * */ #ifdef HAVE_CONFIG_H @@ -15,11 +23,11 @@ #include "ipx_drv.h" #include "ukali.h" -extern unsigned char ipx_MyAddress[10]; +static ipx_socket_t mysock; static int open_sockets = 0; static int dynamic_socket = 0x401; -static int last_socket = 0; +//static int last_socket = 0; int have_empty_address() { int i; @@ -27,8 +35,7 @@ int have_empty_address() { return i == 10; } -int ipx_kali_GetMyAddress(void) -{ +int ipx_kali_GetMyAddress(void) { kaliaddr_ipx mKaliAddr; @@ -44,8 +51,7 @@ int ipx_kali_GetMyAddress(void) return 0; } -int ipx_kali_OpenSocket(ipx_socket_t *sk, int port) -{ +int ipx_kali_OpenSocket(int port) { printf("IPX_kali: OpenSocket on port(%d)\n", port); if (!open_sockets) { @@ -59,56 +65,54 @@ int ipx_kali_OpenSocket(ipx_socket_t *sk, int port) if (!port) port = dynamic_socket++; - if ((sk->fd = KaliOpenSocket(htons(port))) < 0) { + if ((mysock.fd = KaliOpenSocket(htons(port))) < 0) { printf("IPX_kali: OpenSocket Failed on port(%d)\n", port); - sk->fd = -1; + mysock.fd = -1; return -1; } open_sockets++; - last_socket = port; - sk->socket = port; +// last_socket = port; + mysock.socket = port; return 0; } -void ipx_kali_CloseSocket(ipx_socket_t *mysock) -{ +void ipx_kali_CloseSocket(void) { if (!open_sockets) { printf("IPX_kali: close w/o open\n"); return; } - printf("IPX_kali: CloseSocket on port(%d)\n", mysock->socket); - KaliCloseSocket(mysock->fd); + printf("IPX_kali: CloseSocket on port(%d)\n", mysock.socket); + KaliCloseSocket(mysock.fd); if (--open_sockets) { printf("IPX_kali: (closesocket) %d sockets left\n", open_sockets); return; } } -int ipx_kali_SendPacket(ipx_socket_t *mysock, IPXPacket_t *IPXHeader, - u_char *data, int dataLen) -{ +int ipx_kali_SendPacket(IPXPacket_t *IPXHeader, + u_char *data, int dataLen) { kaliaddr_ipx toaddr; int i; - + memcpy(toaddr.sa_nodenum, IPXHeader->Destination.Node, sizeof(toaddr.sa_nodenum)); - memcpy(&toaddr.sa_socket, IPXHeader->Destination.Socket, sizeof(toaddr.sa_socket)); +// memcpy(&toaddr.sa_socket, IPXHeader->Destination.Socket, sizeof(toaddr.sa_socket)); + toaddr.sa_socket=htons(mysock.socket); - if ((i = KaliSendPacket(mysock->fd, (char *)data, dataLen, &toaddr)) < 0) + if ((i = KaliSendPacket(mysock.fd, (char *)data, dataLen, &toaddr)) < 0) return -1; return i; } -int ipx_kali_ReceivePacket(ipx_socket_t *s, char *outbuf, int outbufsize, - struct ipx_recv_data *rd) -{ +int ipx_kali_ReceivePacket(char *outbuf, int outbufsize, + struct ipx_recv_data *rd) { int size; kaliaddr_ipx fromaddr; - if ((size = KaliReceivePacket(s->fd, outbuf, outbufsize, &fromaddr)) < 0) + if ((size = KaliReceivePacket(mysock.fd, outbuf, outbufsize, &fromaddr)) < 0) return -1; - rd->dst_socket = s->socket; + rd->dst_socket = mysock.socket; rd->src_socket = ntohs(fromaddr.sa_socket); memcpy(rd->src_node, fromaddr.sa_nodenum, sizeof(fromaddr.sa_nodenum)); memset(rd->src_network, 0, 4); @@ -117,11 +121,20 @@ int ipx_kali_ReceivePacket(ipx_socket_t *s, char *outbuf, int outbufsize, return size; } +static int ipx_kali_general_PacketReady(void) { + return ipx_general_PacketReady(mysock.fd); +} + struct ipx_driver ipx_kali = { - ipx_kali_GetMyAddress, +// ipx_kali_GetMyAddress, ipx_kali_OpenSocket, ipx_kali_CloseSocket, ipx_kali_SendPacket, ipx_kali_ReceivePacket, - ipx_general_PacketReady + ipx_kali_general_PacketReady, + NULL, + 1, + NULL, + NULL, + NULL }; diff --git a/arch/linux/ipx_lin.c b/arch/linux/ipx_lin.c index c1cb8465..0c21c7da 100644 --- a/arch/linux/ipx_lin.c +++ b/arch/linux/ipx_lin.c @@ -1,8 +1,18 @@ -/* $Id: ipx_lin.c,v 1.5 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/ipx_lin.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ * * Linux IPX * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * Revision 1.2 2001/01/29 13:35:08 bradleyb + * Fixed build system, minor fixes + * */ #ifdef HAVE_CONFIG_H diff --git a/arch/linux/ipx_udp.c b/arch/linux/ipx_udp.c index d04fe5d9..3a12396d 100644 --- a/arch/linux/ipx_udp.c +++ b/arch/linux/ipx_udp.c @@ -1,5 +1,8 @@ -/* $Id: ipx_udp.c,v 1.6 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/ipx_udp.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:29:37 $ * * IPX driver for native Linux TCP/IP networking (UDP implementation) * Version 0.99.2 @@ -60,6 +63,10 @@ * * Have fun! * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/01/29 13:35:08 bradleyb + * Fixed build system, minor fixes + * */ #ifdef HAVE_CONFIG_H diff --git a/arch/linux/joydefs.c b/arch/linux/joydefs.c index 85b02773..a2e0faf6 100644 --- a/arch/linux/joydefs.c +++ b/arch/linux/joydefs.c @@ -1,4 +1,3 @@ -/* $Id: joydefs.c,v 1.2 2003-03-13 00:20:21 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,14 +7,22 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/joydefs.c,v $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2001-10-24 09:25:05 $ * * Linux joystick support * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/01/29 14:03:57 bradleyb + * Fixed build, minor fixes + * */ #ifdef HAVE_CONFIG_H diff --git a/arch/linux/joystick.c b/arch/linux/joystick.c index c4f2b9ab..b569796c 100644 --- a/arch/linux/joystick.c +++ b/arch/linux/joystick.c @@ -1,8 +1,15 @@ -/* $Id: joystick.c,v 1.2 2003-01-01 00:55:03 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/joystick.c,v $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2001-10-24 09:25:05 $ * * Linux joystick support * + * $Log: not supported by cvs2svn $ + * Revision 1.4 2001/01/29 14:03:57 bradleyb + * Fixed build, minor fixes + * */ #ifdef HAVE_CONFIG_H @@ -105,9 +112,7 @@ int j_Update_state () { } -void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max) -{ -/* stpohle - this is already done in the "joy_init" function, so we don't need it in here. +void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max) { int i; for (i = 0; i < 4; i++) { @@ -115,8 +120,6 @@ void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max) j_axis[i].min_val = axis_min[i]; j_axis[i].max_val = axis_max[i]; } - -*/ } diff --git a/arch/linux/linuxnet.c b/arch/linux/linuxnet.c index 0e84f527..d1d237df 100644 --- a/arch/linux/linuxnet.c +++ b/arch/linux/linuxnet.c @@ -1,374 +1,42 @@ -/* $Id: linuxnet.c,v 1.8 2003-03-19 23:20:09 btb Exp $ */ -/* -THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX -SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO -END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A -ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS -IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS -SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE -FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE -CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. -*/ - /* + * $Source: /cvs/cvsroot/d2x/arch/linux/linuxnet.c,v $ + * $Revision: 1.5 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ * * Linux net * + * $Log: not supported by cvs2svn $ + * Revision 1.4 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ + * + * Revision 1.3 2001/01/29 13:35:09 bradleyb + * Fixed build system, minor fixes + * */ #ifdef HAVE_CONFIG_H #include #endif -#ifdef NETWORK -#include -#include -#include -#include -#include -#include /* for htons & co. */ - #include "pstypes.h" -#include "args.h" #include "ipx_drv.h" #include "ipx_bsd.h" #include "ipx_kali.h" #include "ipx_udp.h" -//added 05/17/99 Matt Mueller - needed to redefine FD_* so that no asm is used -//#include "checker.h" -//end addition -MM -#define MAX_IPX_DATA 576 - -int ipx_fd; -ipx_socket_t ipx_socket_data; -ubyte ipx_installed=0; -ushort ipx_socket = 0; -uint ipx_network = 0; -ubyte ipx_MyAddress[10]; -int ipx_packetnum = 0; /* Sequence number */ -//int ipx_packettotal=0,ipx_lastspeed=0; - -/* User defined routing stuff */ -typedef struct user_address { - ubyte network[4]; - ubyte node[6]; - ubyte address[6]; -} user_address; -#define MAX_USERS 64 -int Ipx_num_users = 0; -user_address Ipx_users[MAX_USERS]; - -#define MAX_NETWORKS 64 -int Ipx_num_networks = 0; -uint Ipx_networks[MAX_NETWORKS]; - -void ipx_close(void); - -int ipx_general_PacketReady(ipx_socket_t *s) { - fd_set set; - struct timeval tv; - - FD_ZERO(&set); - FD_SET(s->fd, &set); - tv.tv_sec = tv.tv_usec = 0; - if (select(s->fd + 1, &set, NULL, NULL, &tv) > 0) - return 1; - else - return 0; -} - -struct ipx_driver *driver = &ipx_bsd; - -ubyte * ipx_get_my_server_address() -{ - return (ubyte *)&ipx_network; -} - -ubyte * ipx_get_my_local_address() -{ - return (ubyte *)(ipx_MyAddress + 4); -} - -//--------------------------------------------------------------- -// Initializes all IPX internals. -// If socket_number==0, then opens next available socket. -// Returns: 0 if successful. -// -1 if socket already open. -// -2 if socket table full. -// -3 if IPX not installed. -// -4 if couldn't allocate low dos memory -// -5 if error with getting internetwork address -int ipx_init( int socket_number, int show_address ) -{ - int i; - - if (FindArg("-kali")) { - printf("Using Kali for network games\n"); - driver = &ipx_kali; -//added on 12/20/98 by Jan Kratochvil for direct TCP/IP games - } else if (FindArg("-udp")) { - printf("Using native TCP/IP (UDP) for network games\n"); - driver = &ipx_udp; -//end this section addition - JK - } else { - printf("Using real IPX for network games\n"); - driver = &ipx_bsd; - } - if ((i = FindArg("-ipxnetwork")) && Args[i + 1]) { - unsigned long n = strtol(Args[i + 1], NULL, 16); - ipx_MyAddress[0] = n >> 24; ipx_MyAddress[1] = (n >> 16) & 255; - ipx_MyAddress[2] = (n >> 8) & 255; ipx_MyAddress[3] = n & 255; - printf("IPX: Using network %08x\n", (unsigned int)n); - } - if (driver->OpenSocket(&ipx_socket_data, socket_number)) { - return -3; - } - driver->GetMyAddress(); - memcpy(&ipx_network, ipx_MyAddress, 4); - Ipx_num_networks = 0; - memcpy( &Ipx_networks[Ipx_num_networks++], &ipx_network, 4 ); - ipx_installed = 1; - atexit(ipx_close); - return 0; -} - -void ipx_close() -{ - if (ipx_installed) - driver->CloseSocket(&ipx_socket_data); - ipx_installed = 0; -} - -int ipx_get_packet_data( ubyte * data ) -{ - struct ipx_recv_data rd; - char buf[MAX_IPX_DATA]; -//killed 6-15-99 to get rid of compile warnings - OE -// uint best_id = 0; -// uint pkt_num; -//end kill - OE - int size; - int best_size = 0; -//edited 04/12/99 Matt Mueller - duh, we don't want to throw all that data away! - //--killed-- Like the original, only take latest packet, throw away rest - //do _NOT_ throw them away! - while (driver->PacketReady(&ipx_socket_data)) { - if ((size = - driver->ReceivePacket(&ipx_socket_data, buf, - sizeof(buf), &rd)) > 4) { - if (!memcmp(rd.src_network, ipx_MyAddress, 10)) - continue; /* don't get own pkts */ -//--killed-- pkt_num = *(uint *)buf; -//--killed-- if (pkt_num >= best_id) { - memcpy(data, buf + 4, size - 4); - return size-4; -//--killed-- best_id = pkt_num; -//--killed-- best_size = size - 4; -//--killed-- } -//end edit -MM - } - } - return best_size; -} - -void ipx_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ) -{ - u_char buf[MAX_IPX_DATA]; - IPXPacket_t ipx_header; - - memcpy(ipx_header.Destination.Network, network, 4); - memcpy(ipx_header.Destination.Node, immediate_address, 6); - *(u_short *)ipx_header.Destination.Socket = htons(ipx_socket_data.socket); - ipx_header.PacketType = 4; /* Packet Exchange */ - *(uint *)buf = ipx_packetnum++; - //ipx_packettotal+=datasize+4; - //if (f2i(Players[Player_num].time_level) && (f2i(Players[Player_num].time_level)%10!=ipx_lastspeed)) - //{ - // ipx_lastspeed=f2i(Players[Player_num].time_level)%10; - // printf("tot=%i,t2=%i,time=%i,avg=%i,a2=%i\n",ipx_packetnum,ipx_packettotal,(int)f2i(Players[Player_num].time_level), - // ipx_packetnum/(int)f2i(Players[Player_num].time_level), - // ipx_packettotal/(int)f2i(Players[Player_num].time_level)); - //} - memcpy(buf + 4, data, datasize); - driver->SendPacket(&ipx_socket_data, &ipx_header, buf, datasize + 4); -} - -void ipx_get_local_target( ubyte * server, ubyte * node, ubyte * local_target ) -{ - // let's hope Linux knows how to route it - memcpy( local_target, node, 6 ); -} - -void ipx_send_broadcast_packet_data( ubyte * data, int datasize ) -{ - int i, j; - ubyte broadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - ubyte local_address[6]; - - // Set to all networks besides mine - for (i=0; iCloseSocket(&ipx_socket_data); - if (driver->OpenSocket(&ipx_socket_data, socket_number)) { - return -3; - } - return 0; -} - -void ipx_read_user_file(char * filename) -{ - FILE * fp; - user_address tmp; - char temp_line[132], *p1; - int n, ln=0, x; - - if (!filename) return; - - Ipx_num_users = 0; - - fp = fopen( filename, "rt" ); - if ( !fp ) return; - - printf( "Broadcast Users:\n" ); - - while (fgets(temp_line, 132, fp)) { - ln++; - p1 = strchr(temp_line,'\n'); if (p1) *p1 = '\0'; - p1 = strchr(temp_line,';'); if (p1) *p1 = '\0'; -#if 1 // adb: replaced sscanf(..., "%2x...", (char *)...) with better, but longer code - if (strlen(temp_line) >= 21 && temp_line[8] == '/') { - for (n = 0; n < 4; n++) { - if (sscanf(temp_line + n * 2, "%2x", &x) != 1) - break; - tmp.network[n] = x; - } - if (n != 4) - continue; - for (n = 0; n < 6; n++) { - if (sscanf(temp_line + 9 + n * 2, "%2x", &x) != 1) - break; - tmp.node[n] = x; - } - if (n != 6) - continue; - } else - continue; -#else - n = sscanf( temp_line, "%2x%2x%2x%2x/%2x%2x%2x%2x%2x%2x", &tmp.network[0], &tmp.network[1], &tmp.network[2], &tmp.network[3], &tmp.node[0], &tmp.node[1], &tmp.node[2],&tmp.node[3], &tmp.node[4], &tmp.node[5] ); - if ( n != 10 ) continue; -#endif - if ( Ipx_num_users < MAX_USERS ) { - ubyte * ipx_real_buffer = (ubyte *)&tmp; - ipx_get_local_target( tmp.network, tmp.node, tmp.address ); - Ipx_users[Ipx_num_users++] = tmp; - printf( "%02X%02X%02X%02X/", ipx_real_buffer[0],ipx_real_buffer[1],ipx_real_buffer[2],ipx_real_buffer[3] ); - printf( "%02X%02X%02X%02X%02X%02X\n", ipx_real_buffer[4],ipx_real_buffer[5],ipx_real_buffer[6],ipx_real_buffer[7],ipx_real_buffer[8],ipx_real_buffer[9] ); - } else { - printf( "Too many addresses in %s! (Limit of %d)\n", filename, MAX_USERS ); - fclose(fp); - return; - } - } - fclose(fp); -} +#include -void ipx_read_network_file(char * filename) +struct ipx_driver * arch_ipx_set_driver(char *arg) { - FILE * fp; - user_address tmp; - char temp_line[132], *p1; - int i, n, ln=0, x; - - if (!filename) return; - - fp = fopen( filename, "rt" ); - if ( !fp ) return; - - printf( "Using Networks:\n" ); - for (i=0; i= 8) { - for (n = 0; n < 4; n++) { - if (sscanf(temp_line + n * 2, "%2x", &x) != 1) - break; - tmp.network[n] = x; - } - if (n != 4) - continue; - } else - continue; -#else - n = sscanf( temp_line, "%2x%2x%2x%2x", &tmp.network[0], &tmp.network[1], &tmp.network[2], &tmp.network[3] ); - if ( n != 4 ) continue; + if (strcmp(arg,"kali")==0){ + return &ipx_kali; +#if 0 + }else if (strcmp(arg,"udp")==0){ + return &ipx_udp; #endif - if ( Ipx_num_networks < MAX_NETWORKS ) { - int j; - for (j=0; j= Ipx_num_networks ) { - memcpy( &Ipx_networks[Ipx_num_networks++], tmp.network, 4 ); - printf(" %02x%02x%02x%02x\n", tmp.network[0], tmp.network[1], tmp.network[2], tmp.network[3] ); - } - } else { - printf( "Too many networks in %s! (Limit of %d)\n", filename, MAX_NETWORKS ); - fclose(fp); - return; - } + }else { + return &ipx_bsd; } - fclose(fp); } -#endif //NETWORK diff --git a/arch/linux/ukali.c b/arch/linux/ukali.c index f2def070..a57c7b64 100644 --- a/arch/linux/ukali.c +++ b/arch/linux/ukali.c @@ -1,7 +1,15 @@ -/* $Id: ukali.c,v 1.5 2003-03-13 00:20:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/linux/ukali.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 07:39:26 $ + * + * FIXME: add description + * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 07:29:37 bradleyb + * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ * - * Kali support functions * */ diff --git a/arch/ogl/.cvsignore b/arch/ogl/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/arch/ogl/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/arch/ogl/Makefile.am b/arch/ogl/Makefile.am index 5dbe9e75..d493fe7e 100644 --- a/arch/ogl/Makefile.am +++ b/arch/ogl/Makefile.am @@ -1,6 +1,6 @@ noinst_LIBRARIES = libarch_ogl.a -INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/arch/include -I$(top_srcdir)/main +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/includes -I$(top_srcdir)/main -I$(top_srcdir)/arch/include libarch_ogl_a_SOURCES = gr.c ogl.c sdlgl.c diff --git a/arch/ogl/glx.c b/arch/ogl/glx.c index dde24146..48d710e4 100644 --- a/arch/ogl/glx.c +++ b/arch/ogl/glx.c @@ -1,8 +1,20 @@ -/* $Id: glx.c,v 1.4 2003-01-15 02:40:54 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/ogl/glx.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-11-04 08:49:57 $ * * opengl platform specific functions for GLX - Added 9/15/99 Matthew Mueller * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/31 07:35:47 bradleyb + * Sync with d1x + * + * 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.3 2001/01/29 13:47:52 bradleyb + * Fixed build, some minor cleanups. * */ @@ -23,7 +35,7 @@ #include #include #endif - + #include diff --git a/arch/ogl/gr.c b/arch/ogl/gr.c index 077f4493..0065c5bb 100644 --- a/arch/ogl/gr.c +++ b/arch/ogl/gr.c @@ -1,8 +1,35 @@ -/* $Id: gr.c,v 1.13 2003-04-11 23:51:48 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/ogl/gr.c,v $ + * $Revision: 1.5 $ + * $Author: bradleyb $ + * $Date: 2001-11-09 06:53:37 $ * - * OGL video functions. - Added 9/15/99 Matthew Mueller + * // OGL video functions. - Added 9/15/99 Matthew Mueller * + * $Log: not supported by cvs2svn $ + * Revision 1.4 2001/11/08 10:19:52 bradleyb + * use new d_realloc function, so mem manager doesn't die + * + * Revision 1.3 2001/11/04 09:00:25 bradleyb + * Enable d1x-style hud_message + * + * Revision 1.2 2001/10/31 07:35:47 bradleyb + * Sync with d1x + * + * 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.7 2001/10/25 02:23:48 bradleyb + * formatting fix + * + * Revision 1.6 2001/10/18 23:59:23 bradleyb + * Changed __ENV_LINUX__ to __linux__ + * + * Revision 1.5 2001/10/12 00:18:40 bradleyb + * Switched from Cygwin to mingw32 on MS boxes. Vastly improved compilability. + * + * Revision 1.4 2001/01/29 13:47:52 bradleyb + * Fixed build, some minor cleanups. * */ @@ -17,11 +44,7 @@ #include #endif -#if defined(__APPLE__) && defined(__MACH__) -//#include -#else //#include -#endif #include #include #include @@ -48,12 +71,7 @@ #define DECLARE_VARS #include "ogl_init.h" -#if defined(__APPLE__) && defined(__MACH__) -#include -#undef GL_ARB_multitexture // hack! -#else #include -#endif int ogl_voodoohack=0; @@ -62,7 +80,7 @@ int gr_installed = 0; void gr_palette_clear(); // Function prototype for gr_init; int gl_initialized=0; -int gl_reticle = 0; +int gl_reticle=1; int ogl_fullscreen=0; @@ -312,7 +330,7 @@ int ogl_testneedmipmaps(int i){ #if defined(__WINDOWS__) || defined(__MINGW32__) char *OglLibPath="opengl32.dll"; #endif -#ifdef __unix__ +#ifdef __linux__ char *OglLibPath="libGL.so"; #endif @@ -345,9 +363,8 @@ int ogl_init_load_library(void) int gr_init() { - int mode = SM(640,480); - int retcode, t, glt = 0; - + int mode = SM(640,480); + int retcode,t,glt=0; // Only do this function once! if (gr_installed==1) return -1; @@ -417,7 +434,6 @@ int gr_init() { return retcode; } - grd_curscreen->sc_canvas.cv_color = 0; grd_curscreen->sc_canvas.cv_drawmode = 0; grd_curscreen->sc_canvas.cv_font = NULL; diff --git a/arch/ogl/ogl.c b/arch/ogl/ogl.c index 5fd4dc6c..936878e6 100644 --- a/arch/ogl/ogl.c +++ b/arch/ogl/ogl.c @@ -1,8 +1,29 @@ -/* $Id: ogl.c,v 1.9 2003-04-11 23:51:48 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/ogl/ogl.c,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-10-31 07:35:47 $ * * Graphics support functions for OpenGL. * + * $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.7 2001/10/12 00:18:40 bradleyb + * Switched from Cygwin to mingw32 on MS boxes. Vastly improved compilability. + * + * Revision 1.6 2001/10/09 03:00:08 bradleyb + * opengl improvments (following d1x changes) + * + * Revision 1.5 2001/10/09 02:38:52 bradleyb + * re-imported d1x version of this file + * + * Revision 1.4 2001/01/31 16:31:14 bradleyb + * OpenGL support under Cygwin/SDL + * + * Revision 1.3 2001/01/29 13:47:52 bradleyb + * Fixed build, some minor cleanups. * */ @@ -15,13 +36,8 @@ #include #include #endif -#if defined(__APPLE__) && defined(__MACH__) -#include -#include -#else #include #include -#endif #include #include @@ -43,7 +59,6 @@ #include "powerup.h" #include "polyobj.h" #include "gamefont.h" -#include "byteswap.h" //change to 1 for lots of spew. #if 0 @@ -56,7 +71,7 @@ #define M_PI 3.14159 #endif -#if defined(__WINDOWS__) || defined(__MINGW32__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__sun__) +#if defined(__WINDOWS__) || defined(__MINGW32__) #define cosf(a) cos(a) #define sinf(a) sin(a) #endif @@ -896,7 +911,6 @@ bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, int ori return 0; } - bool ogl_ubitmapm_c(int x, int y,grs_bitmap *bm,int c) { GLfloat xo,yo,xf,yf; @@ -1217,7 +1231,7 @@ int tex_format_supported(int iformat,int format){ if (!ogl_rgba2_ok) return 0; break; } if (ogl_gettexlevelparam_ok){ - GLint internalFormat; + int internalFormat; glTexImage2D(GL_PROXY_TEXTURE_2D, 0, iformat, 64, 64, 0, format, GL_UNSIGNED_BYTE, texbuf);//NULL? glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, @@ -1339,10 +1353,9 @@ void tex_set_size1(ogl_texture *tex,int dbits,int bits,int w, int h){ glmprintf((0,"tex_set_size1: %ix%i, %ib(%i) %iB\n",w,h,bits,dbits,tex->bytes)); } void tex_set_size(ogl_texture *tex){ - GLint w,h; - int bi=16,a=0; + int w,h,bi=16,a=0; if (ogl_gettexlevelparam_ok){ - GLint t; + int t; glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&w); glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&h); glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_LUMINANCE_SIZE,&t);a+=t; @@ -1376,8 +1389,7 @@ void tex_set_size(ogl_texture *tex){ //In theory this could be a problem for repeating textures, but all real //textures (not sprites, etc) in descent are 64x64, so we are ok. //stores OpenGL textured id in *texid and u/v values required to get only the real data in *u/*v -void ogl_loadtexture(unsigned char * data, int dxo,int dyo, ogl_texture *tex) -{ +void ogl_loadtexture(unsigned char * data, int dxo,int dyo, ogl_texture *tex){ //void ogl_loadtexture(unsigned char * data, int width, int height,int dxo,int dyo, int *texid,float *u,float *v,char domipmap,float prio){ // int internalformat=GL_RGBA; // int format=GL_RGBA; @@ -1434,11 +1446,8 @@ void ogl_loadtexture(unsigned char * data, int dxo,int dyo, ogl_texture *tex) glmprintf((0,"ogl_loadtexture(%p,%i,%i,%ix%i,%p):%i u=%f v=%f b=%i bu=%i (%i)\n",data,tex->tw,tex->th,dxo,dyo,tex,tex->handle,tex->u,tex->v,tex->bytes,tex->bytesu,r_texcount)); } - unsigned char decodebuf[512*512]; - -void ogl_loadbmtexture_m(grs_bitmap *bm,int domipmap) -{ +void ogl_loadbmtexture_m(grs_bitmap *bm,int domipmap){ unsigned char *buf; while (bm->bm_parent) bm=bm->bm_parent; @@ -1462,36 +1471,24 @@ void ogl_loadbmtexture_m(grs_bitmap *bm,int domipmap) if (bm->bm_flags & BM_FLAG_RLE){ unsigned char * dbits; unsigned char * sbits; - int i, data_offset; - - data_offset = 1; - if (bm->bm_flags & BM_FLAG_RLE_BIG) - data_offset = 2; - - sbits = &bm->bm_data[4 + (bm->bm_h * data_offset)]; + int i; + sbits = &bm->bm_data[4 + bm->bm_h]; dbits = decodebuf; for (i=0; i < bm->bm_h; i++ ) { gr_rle_decode(sbits,dbits); - if ( bm->bm_flags & BM_FLAG_RLE_BIG ) - sbits += (int)INTEL_SHORT(*((short *)&(bm->bm_data[4+(i*data_offset)]))); - else - sbits += (int)bm->bm_data[4+i]; + sbits += (int)bm->bm_data[4+i]; dbits += bm->bm_w; } buf=decodebuf; } ogl_loadtexture(buf,0,0,bm->gltexture); } - -void ogl_loadbmtexture(grs_bitmap *bm) -{ +void ogl_loadbmtexture(grs_bitmap *bm){ ogl_loadbmtexture_m(bm,1); } - -void ogl_freetexture(ogl_texture *gltexture) -{ - if (gltexture->handle>0) { +void ogl_freetexture(ogl_texture *gltexture){ + if (gltexture->handle>0){ r_texcount--; glmprintf((0,"ogl_freetexture(%p):%i (last rend %is) (%i left)\n",gltexture,gltexture->handle,(GameTime-gltexture->lastrend)/f1_0,r_texcount)); glDeleteTextures( 1, &gltexture->handle ); diff --git a/arch/ogl/sdlgl.c b/arch/ogl/sdlgl.c index d80eccc6..9e80cf7f 100644 --- a/arch/ogl/sdlgl.c +++ b/arch/ogl/sdlgl.c @@ -1,8 +1,29 @@ -/* $Id: sdlgl.c,v 1.6 2003-03-28 09:27:07 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/ogl/sdlgl.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-11-08 10:19:52 $ * * Graphics functions for SDL-GL. * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/11/04 09:02:18 bradleyb + * Hack to keep SDL from screwing up X when it crashes + * + * Revision 1.2 2001/10/31 07:35:48 bradleyb + * Sync with d1x + * + * 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.4 2001/10/09 08:17:07 bradleyb + * changed window caption to include version info + * + * Revision 1.3 2001/10/09 02:58:20 bradleyb + * Added window caption, hide mouse cursor + * + * Revision 1.2 2001/01/29 13:47:52 bradleyb + * Fixed build, some minor cleanups. * */ @@ -10,11 +31,7 @@ #include #endif -#include -#ifdef SDL_IMAGE -#include -#endif - +#include #include "ogl_init.h" #include "vers_id.h" #include "error.h" @@ -39,14 +56,6 @@ int ogl_init_window(int x, int y){ ogl_smash_texture_list_internal();//if we are or were fullscreen, changing vid mode will invalidate current textures } SDL_WM_SetCaption(DESCENT_VERSION, "Descent II"); - -#ifdef SDL_IMAGE - { -#include "descent.xpm" - SDL_WM_SetIcon(IMG_ReadXPMFromArray(pixmap), NULL); - } -#endif - if (!SDL_SetVideoMode(x,y, 16, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0))) { Error("Could not set %dx%dx16 opengl video mode\n",x,y); } diff --git a/arch/ogl/wgl.c b/arch/ogl/wgl.c index f76e21b3..45fc2e6b 100644 --- a/arch/ogl/wgl.c +++ b/arch/ogl/wgl.c @@ -1,11 +1,20 @@ -/* $Id: wgl.c,v 1.3 2003-01-15 02:40:54 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/ogl/wgl.c,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-11-04 08:49:57 $ * * opengl platform specific functions for WGL - added by Peter Hawkins * fullscreen example code courtesy of Jeff Slutter * everything merged together and cleaned up by Matt Mueller * (with some win32 help from Nirvana) * + * $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.2 2001/01/29 13:47:52 bradleyb + * Fixed build, some minor cleanups. * */ @@ -15,7 +24,6 @@ #include #include - #include "ogl_init.h" #include "vers_id.h" #include "error.h" diff --git a/arch/sdl/.cvsignore b/arch/sdl/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/arch/sdl/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/arch/sdl/Makefile.am b/arch/sdl/Makefile.am index 841b4275..edb9f1de 100644 --- a/arch/sdl/Makefile.am +++ b/arch/sdl/Makefile.am @@ -2,9 +2,9 @@ EXTRA_SUBDIRS = include noinst_LIBRARIES = libarch_sdl.a -INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/include -I$(top_srcdir)/main +INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/includes -I$(top_srcdir)/main -if !USE_LINUX_JOY +if SDL_JOYSTICK JOYSTICK_SRCS = joy.c joydefs.c endif @@ -15,11 +15,11 @@ endif endif if !USE_OPENGL -VIDEO_SRCS = gr.c +VIDEO_SRCS = gr.c endif libarch_sdl_a_SOURCES = ${JOYSTICK_SRCS} ${VIDEO_SRCS} ${INPUT_SRCS} \ -digi.c init.c rbaudio.c timer.c +cdrom.c digi.c init.c timer.c EXTRA_libarch_sdl_a_SOURCES = \ event.c gr.c joy.c joydefs.c key.c mouse.c diff --git a/arch/sdl/cdrom.c b/arch/sdl/cdrom.c new file mode 100644 index 00000000..e4018678 --- /dev/null +++ b/arch/sdl/cdrom.c @@ -0,0 +1,137 @@ +/* + * $Source: /cvs/cvsroot/d2x/arch/sdl/cdrom.c,v $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2001-10-25 08:25:34 $ + * + * DPH: This is the file where all the stub functions go. + * The aim is to have nothing in here, eventually + * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/01/29 13:53:28 bradleyb + * Fixed build, minor fixes + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include "pstypes.h" +#include "error.h" +#include "args.h" + + +static SDL_CD *s_cd = NULL; +extern int Redbook_playing; +static int initialised = 0; + +void RBAExit() +{ + if (initialised) + { + SDL_CDClose(s_cd); + } +} + +void RBAInit() +{ + if (initialised) return; + if (FindArg("-nocdrom")) return; + + if (SDL_Init(SDL_INIT_CDROM) < 0) + { + Warning("SDL library initialisation failed: %s.",SDL_GetError()); + return; + } + + if (SDL_CDNumDrives() == 0) + { + Warning("No cdrom drives found!\n"); + return; + } + s_cd = SDL_CDOpen(0); + atexit(RBAExit); + initialised = 1; +} + +int RBAEnabled() +{ + return 1; +} + +void RBARegisterCD() +{ + +} + +int RBAPlayTrack(int a) +{ + if (!initialised) return -1; + + if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) { + SDL_CDPlayTracks(s_cd, a-1, 0, 0, 0); + } + return a; + +} + +void RBAStop() +{ + if (!initialised) return; + SDL_CDStop(s_cd); +} + +void RBASetVolume(int a) +{ + +} + +void RBAPause() +{ + if (!initialised) return; + SDL_CDPause(s_cd); +} + +void RBAResume() +{ + if (!initialised) return; + SDL_CDResume(s_cd); +} + +int RBAGetNumberOfTracks() +{ + if (!initialised) return -1; + SDL_CDStatus(s_cd); + return s_cd->numtracks; +} + +int RBAPlayTracks(int tracknum,int something) +{ + if (!initialised) return -1; + if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) { + SDL_CDPlayTracks(s_cd, tracknum-1, 0, 0, 0); + } + return tracknum; +} + +int RBAGetTrackNum() +{ + if (!initialised) return -1; + SDL_CDStatus(s_cd); + return s_cd->cur_track; +} + +int RBAPeekPlayStatus() +{ + return 1; +} + +int CD_blast_mixer() +{ + return 0; +} diff --git a/arch/sdl/digi.c b/arch/sdl/digi.c index 573d6ecd..cbd10114 100644 --- a/arch/sdl/digi.c +++ b/arch/sdl/digi.c @@ -1,8 +1,20 @@ -/* $Id: digi.c,v 1.11 2003-04-12 00:11:46 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/sdl/digi.c,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-11-14 10:42:15 $ * * SDL digital audio support * + * $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.3 2001/10/12 06:36:55 bradleyb + * Fix a gcc 3.0 warning, couple updates from d1x + * + * Revision 1.2 2001/01/29 13:53:28 bradleyb + * Fixed build, minor fixes * */ @@ -14,7 +26,8 @@ #include #include -#include +#include +#include #include "pstypes.h" #include "error.h" @@ -29,7 +42,7 @@ #include "newdemo.h" #include "kconfig.h" -int digi_sample_rate = SAMPLE_RATE_11K; +int digi_sample_rate=11025; //edited 05/17/99 Matt Mueller - added ifndef NO_ASM //added on 980905 by adb to add inline fixmul for mixer on i386 @@ -116,7 +129,6 @@ static const Uint8 mix8[] = #define SOF_LINK_TO_OBJ 4 // Sound is linked to a moving object. If object dies, then finishes play and quits. #define SOF_LINK_TO_POS 8 // Sound is linked to segment, pos #define SOF_PLAY_FOREVER 16 // Play forever (or until level is stopped), otherwise plays once -#define SOF_PERMANANT 32 // Part of the level, like a waterfall or fan typedef struct sound_object { short signature; // A unique signature to this sound @@ -127,8 +139,6 @@ typedef struct sound_object { int pan; // Pan value that this sound is playing at int handle; // What handle this sound is playing on. Valid only if SOF_PLAYING is set. short soundnum; // The sound number that is playing - int loop_start; // The start point of the loop. -1 means no loop - int loop_end; // The end point of the loop union { struct { short segnum; // Used if SOF_LINK_TO_POS field is used @@ -249,7 +259,7 @@ int digi_init() memset(SampleHandles, 255, sizeof(SampleHandles)); //end edit by adb - WaveSpec.freq = digi_sample_rate; + WaveSpec.freq = 11025; //added/changed by Sam Lantinga on 12/01/98 for new SDL version WaveSpec.format = AUDIO_U8; WaveSpec.channels = 2; @@ -291,8 +301,6 @@ int digi_xlat_sound(int soundno) soundno = AltSounds[soundno]; if ( soundno == 255 ) return -1; } - if (Sounds[soundno] == 255) return -1; - return Sounds[soundno]; } @@ -306,15 +314,13 @@ static int get_free_slot() return -1; } -int digi_start_sound(int soundnum, fix volume, fix pan, int looping, int loop_start, int loop_end, int soundobj) +int digi_start_sound(int soundnum, fix volume, fix pan, int unknown1, int unknown2, int unknown3, int unknown4) { int ntries; int slot; if (!digi_initialised) return -1; - if (soundnum < 0) return -1; - //added on 980905 by adb from original source to add sound kill system // play at most digi_max_channel samples, if possible kill sample with low volume ntries = 0; @@ -346,7 +352,7 @@ TryNextChannel: SoundSlots[slot].volume = fixmul(digi_volume, volume); SoundSlots[slot].pan = pan; SoundSlots[slot].position = 0; - SoundSlots[slot].looped = looping; + SoundSlots[slot].looped = 0; SoundSlots[slot].playing = 1; //added on 980905 by adb to add sound kill system from original sos digi.c @@ -380,11 +386,6 @@ int digi_start_sound_object(int obj) if (slot<0) return -1; -#if 0 - // only use up to half the sound channels for "permanant" sounts - if ((SoundObjects[i].flags & SOF_PERMANANT) && (N_active_sound_objects >= max(1,digi_get_max_channels()/4)) ) - return -1; -#endif SoundSlots[slot].soundno = SoundObjects[obj].soundnum; SoundSlots[slot].samples = GameSounds[SoundObjects[obj].soundnum].data; @@ -504,10 +505,7 @@ void digi_get_sound_loc( vms_matrix * listener, vms_vector * listener_pos, int l } } -//hack to not start object when loading level -int Dont_start_sound_objects = 0; - -int digi_link_sound_to_object3( int org_soundnum, short objnum, int forever, fix max_volume, fix max_distance, int loop_start, int loop_end ) +int digi_link_sound_to_object2( int org_soundnum, short objnum, int forever, fix max_volume, fix max_distance ) { int i,volume,pan; object * objp; @@ -534,12 +532,6 @@ int digi_link_sound_to_object3( int org_soundnum, short objnum, int forever, fix return -1; } -#ifdef NEWDEMO - if ( Newdemo_state == ND_STATE_RECORDING ) { - newdemo_record_link_sound_to_object3( org_soundnum, objnum, max_volume, max_distance, loop_start, loop_end ); - } -#endif - for (i=0; iorient, &Viewer->pos, Viewer->segnum, + objp = &Objects[SoundObjects[i].lo_objnum]; + digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, &objp->pos, objp->segnum, SoundObjects[i].max_volume, &SoundObjects[i].volume, &SoundObjects[i].pan, SoundObjects[i].max_distance ); - //if (!forever || SoundObjects[i].volume >= MIN_VOLUME) + if (!forever || SoundObjects[i].volume >= MIN_VOLUME) digi_start_sound_object(i); - // If it's a one-shot sound effect, and it can't start right away, then - // just cancel it and be done with it. - if ( (SoundObjects[i].handle < 0) && (!(SoundObjects[i].flags & SOF_PLAY_FOREVER)) ) { - SoundObjects[i].flags = 0; - return -1; - } - } - return SoundObjects[i].signature; } - -int digi_link_sound_to_object2( int org_soundnum, short objnum, int forever, fix max_volume, fix max_distance ) -{ - return digi_link_sound_to_object3( org_soundnum, objnum, forever, max_volume, max_distance, -1, -1 ); -} - - int digi_link_sound_to_object( int soundnum, short objnum, int forever, fix max_volume ) { return digi_link_sound_to_object2( soundnum, objnum, forever, max_volume, 256*F1_0); } @@ -647,17 +616,7 @@ int digi_link_sound_to_pos2( int org_soundnum, short segnum, short sidenum, vms_ SoundObjects[i].max_distance = max_distance; SoundObjects[i].volume = 0; SoundObjects[i].pan = 0; - SoundObjects[i].loop_start = SoundObjects[i].loop_end = -1; - - if (Dont_start_sound_objects) { //started at level start - - SoundObjects[i].flags |= SOF_PERMANANT; - - SoundObjects[i].handle = -1; - } - else { - - digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, + digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, &SoundObjects[i].lp_position, SoundObjects[i].lp_segnum, SoundObjects[i].max_volume, &SoundObjects[i].volume, &SoundObjects[i].pan, SoundObjects[i].max_distance ); @@ -665,14 +624,6 @@ int digi_link_sound_to_pos2( int org_soundnum, short segnum, short sidenum, vms_ if (!forever || SoundObjects[i].volume >= MIN_VOLUME) digi_start_sound_object(i); - // If it's a one-shot sound effect, and it can't start right away, then - // just cancel it and be done with it. - if ( (SoundObjects[i].handle < 0) && (!(SoundObjects[i].flags & SOF_PLAY_FOREVER)) ) { - SoundObjects[i].flags = 0; - return -1; - } - } - return SoundObjects[i].signature; } @@ -898,12 +849,6 @@ int digi_get_max_channels() { } // end edit by adb -void digi_stop_sound(int channel) -{ - //FIXME: Is this correct? I dunno, it works. - SoundSlots[channel].playing=0; -} - void digi_reset_digi_sounds() { int i; diff --git a/arch/sdl/event.c b/arch/sdl/event.c index a83a7b79..244634d5 100644 --- a/arch/sdl/event.c +++ b/arch/sdl/event.c @@ -1,8 +1,23 @@ -/* $Id: event.c,v 1.9 2003-03-27 02:26:02 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/sdl/event.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-12-03 02:43:02 $ * * SDL Event related stuff * + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/11/14 10:43:10 bradleyb + * remove cruft, fix formatting, begin joystick stuff + * + * Revision 1.2 2001/10/31 07:41:54 bradleyb + * Sync with d1x + * + * 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 * */ @@ -13,16 +28,13 @@ #include #include -#include +#include extern void key_handler(SDL_KeyboardEvent *event); extern void mouse_button_handler(SDL_MouseButtonEvent *mbe); extern void mouse_motion_handler(SDL_MouseMotionEvent *mme); -#ifndef USE_LINUX_JOY // stpohle - so we can choose at compile time.. extern void joy_button_handler(SDL_JoyButtonEvent *jbe); -extern void joy_hat_handler(SDL_JoyHatEvent *jhe); extern void joy_axis_handler(SDL_JoyAxisEvent *jae); -#endif static int initialised=0; @@ -43,7 +55,7 @@ void event_poll() case SDL_MOUSEMOTION: mouse_motion_handler((SDL_MouseMotionEvent *)&event); break; -#ifndef USE_LINUX_JOY // stpohle - so we can choose at compile time.. +#if SDL_JOYSTICK case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: joy_button_handler((SDL_JoyButtonEvent *)&event); @@ -51,10 +63,8 @@ void event_poll() case SDL_JOYAXISMOTION: joy_axis_handler((SDL_JoyAxisEvent *)&event); break; - case SDL_JOYHATMOTION: - joy_hat_handler((SDL_JoyHatEvent *)&event); - break; case SDL_JOYBALLMOTION: + case SDL_JOYHATMOTION: break; #endif case SDL_QUIT: { diff --git a/arch/sdl/gr.c b/arch/sdl/gr.c index 7b1dd36f..076a43ec 100644 --- a/arch/sdl/gr.c +++ b/arch/sdl/gr.c @@ -1,8 +1,23 @@ -/* $Id: gr.c,v 1.11 2003-03-28 09:27:07 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/sdl/gr.c,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $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 + * + * Revision 1.4 2001/01/31 13:59:23 bradleyb + * Fullscreen toggle added to screen res menu + * + * Revision 1.3 2001/01/29 13:47:52 bradleyb + * Fixed build, some minor cleanups. * */ @@ -12,17 +27,17 @@ #include #include -#include -#ifdef SDL_IMAGE -#include -#endif - +#include #include "gr.h" #include "grdef.h" #include "palette.h" #include "u_mem.h" #include "error.h" -#include "menu.h" +//added on 9/30/98 by Matt Mueller to set the title bar. Woohoo! +#include "vers_id.h" +//end addition -MM + +#include "gamefont.h" //added 10/05/98 by Matt Mueller - make fullscreen mode optional #include "args.h" @@ -99,16 +114,9 @@ int gr_set_mode(u_int32_t mode) //Style "D1X*" NoTitle, NoHandles, BorderWidth 0 //if you can't use -fullscreen like me (crashes X), this is a big help in //getting the window centered correctly (if you use SmartPlacement) - SDL_WM_SetCaption(PACKAGE_STRING, "Descent II"); + SDL_WM_SetCaption(DESCENT_VERSION, "Descent II"); //end addition -MM -#ifdef SDL_IMAGE - { -#include "descent.xpm" - SDL_WM_SetIcon(IMG_ReadXPMFromArray(pixmap), NULL); - } -#endif - //edited 10/05/98 by Matt Mueller - make fullscreen mode optional // changed by adb on 980913: added SDL_HWPALETTE (should be option?) // changed by someone on 980923 to add SDL_FULLSCREEN @@ -156,12 +164,15 @@ int gr_check_fullscreen(void){ int gr_toggle_fullscreen(void){ sdl_video_flags^=SDL_FULLSCREEN; - SDL_WM_ToggleFullScreen(screen); +// 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; } int gr_init(void) { + int retcode; + int mode = SM(640,480); // Only do this function once! if (gr_installed==1) return -1; @@ -184,6 +195,11 @@ int gr_init(void) if (FindArg("-nosdlvidmodecheck")) checkvidmodeok=0; + // Set the mode. + if ((retcode=gr_set_mode(mode))) + { + return retcode; + } grd_curscreen->sc_canvas.cv_color = 0; grd_curscreen->sc_canvas.cv_drawmode = 0; grd_curscreen->sc_canvas.cv_font = NULL; @@ -324,13 +340,6 @@ int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys) if (gr_palette_faded_out) return 0; -#if 1 //ifndef NDEBUG - if (grd_fades_disabled) { - gr_palette_clear(); - return 0; - } -#endif - palette = screen->format->palette; if (palette == NULL) { return -1; // Display is not palettised @@ -391,13 +400,6 @@ int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys) if (!gr_palette_faded_out) return 0; -#if 1 //ifndef NDEBUG - if (grd_fades_disabled) { - gr_palette_load(pal); - return 0; - } -#endif - palette = screen->format->palette; if (palette == NULL) { diff --git a/arch/sdl/init.c b/arch/sdl/init.c index 9801aaa6..0634ddd4 100644 --- a/arch/sdl/init.c +++ b/arch/sdl/init.c @@ -1,8 +1,26 @@ -/* $Id: init.c,v 1.11 2003-01-15 02:42:41 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/sdl/init.c,v $ + * $Revision: 1.8 $ + * $Author: bradleyb $ + * $Date: 2001-12-03 02:45:02 $ * * SDL architecture support * + * $Log: not supported by cvs2svn $ + * Revision 1.7 2001/12/03 02:43:02 bradleyb + * lots of makefile fixes, and sdl joystick stuff + * + * Revision 1.6 2001/11/14 03:56:16 bradleyb + * SDL joystick stuff + * + * Revision 1.5 2001/10/31 07:41:54 bradleyb + * Sync with d1x + * + * 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 * */ @@ -12,9 +30,7 @@ #include #include - -#include - +#include #include "text.h" #include "event.h" #include "error.h" @@ -30,12 +46,19 @@ void sdl_close() void arch_sdl_init() { + // Initialise the library + if (SDL_Init( +#ifdef SDL_JOYSTICK + SDL_INIT_JOYSTICK | +#endif #if defined(SDL_VIDEO) || defined(SDL_GL_VIDEO) - if (SDL_Init(SDL_INIT_VIDEO) < 0) - { - Error("SDL library video initialisation failed: %s.",SDL_GetError()); - } + SDL_INIT_VIDEO +#else + 0 #endif + )<0) { + Error("SDL library initialisation failed: %s.",SDL_GetError()); + } #ifdef SDL_INPUT if (!FindArg("-nomouse")) d_mouse_init(); diff --git a/arch/sdl/joy.c b/arch/sdl/joy.c index a327cc6a..69002faa 100644 --- a/arch/sdl/joy.c +++ b/arch/sdl/joy.c @@ -1,8 +1,18 @@ -/* $Id: joy.c,v 1.12 2003-04-12 00:11:46 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/sdl/joy.c,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-12-03 02:43:02 $ * * SDL joystick support * + * $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.1 2001/10/10 03:01:29 bradleyb + * Replacing win32 joystick (broken) with SDL joystick (stubs) + * * */ @@ -10,49 +20,34 @@ #include #endif -#include // for memset -#include +#include #include "joy.h" #include "error.h" #include "timer.h" #include "console.h" -#include "event.h" -#include "text.h" #define MAX_JOYSTICKS 16 #define MAX_AXES 32 #define MAX_AXES_PER_JOYSTICK 8 #define MAX_BUTTONS_PER_JOYSTICK 16 -#define MAX_HATS_PER_JOYSTICK 4 - -extern int joybutton_text[]; //from kconfig.c char joy_present = 0; int num_joysticks = 0; -int joy_deadzone = 0; - struct joybutton { int state; - int last_state; fix time_went_down; + fix time_held_down; int num_downs; int num_ups; }; -struct joyaxis { - int value; - int min_val; - int center_val; - int max_val; -}; - static struct joyinfo { int n_axes; int n_buttons; - struct joyaxis axes[MAX_AXES]; + int axes[MAX_AXES]; struct joybutton buttons[MAX_BUTTONS]; } Joystick; @@ -60,8 +55,6 @@ static struct { SDL_Joystick *handle; int n_axes; int n_buttons; - int n_hats; - int hat_map[MAX_HATS_PER_JOYSTICK]; //Note: Descent expects hats to be buttons, so these are indices into Joystick.buttons int axis_map[MAX_AXES_PER_JOYSTICK]; int button_map[MAX_BUTTONS_PER_JOYSTICK]; } SDL_Joysticks[MAX_JOYSTICKS]; @@ -81,51 +74,21 @@ void joy_button_handler(SDL_JoyButtonEvent *jbe) Joystick.buttons[button].num_downs++; break; case SDL_JOYBUTTONUP: + Joystick.buttons[button].time_held_down + += timer_get_fixed_seconds() + - Joystick.buttons[button].time_went_down; Joystick.buttons[button].num_ups++; break; } } -void joy_hat_handler(SDL_JoyHatEvent *jhe) -{ - int hat = SDL_Joysticks[jhe->which].hat_map[jhe->hat]; - int hbi; - - //Save last state of the hat-button - Joystick.buttons[hat ].last_state = Joystick.buttons[hat ].state; - Joystick.buttons[hat+1].last_state = Joystick.buttons[hat+1].state; - Joystick.buttons[hat+2].last_state = Joystick.buttons[hat+2].state; - Joystick.buttons[hat+3].last_state = Joystick.buttons[hat+3].state; - - //get current state of the hat-button - Joystick.buttons[hat ].state = ((jhe->value & SDL_HAT_UP)>0); - Joystick.buttons[hat+1].state = ((jhe->value & SDL_HAT_RIGHT)>0); - Joystick.buttons[hat+2].state = ((jhe->value & SDL_HAT_DOWN)>0); - Joystick.buttons[hat+3].state = ((jhe->value & SDL_HAT_LEFT)>0); - - //determine if a hat-button up or down event based on state and last_state - for(hbi=0;hbi<4;hbi++) - { - if( !Joystick.buttons[hat+hbi].last_state && Joystick.buttons[hat+hbi].state) //last_state up, current state down - { - Joystick.buttons[hat+hbi].time_went_down - = timer_get_fixed_seconds(); - Joystick.buttons[hat+hbi].num_downs++; - } - else if(Joystick.buttons[hat+hbi].last_state && !Joystick.buttons[hat+hbi].state) //last_state down, current state up - { - Joystick.buttons[hat+hbi].num_ups++; - } - } -} - void joy_axis_handler(SDL_JoyAxisEvent *jae) { int axis; axis = SDL_Joysticks[jae->which].axis_map[jae->axis]; - Joystick.axes[axis].value = jae->value; + Joystick.axes[axis] = jae->value; } @@ -135,73 +98,31 @@ int joy_init() { int i,j,n; - if (SDL_Init(SDL_INIT_JOYSTICK) < 0) { - con_printf(CON_VERBOSE, "sdl-joystick: initialisation failed: %s.",SDL_GetError()); - return 0; - } - memset(&Joystick,0,sizeof(Joystick)); n = SDL_NumJoysticks(); - con_printf(CON_VERBOSE, "sdl-joystick: found %d joysticks\n", n); + con_printf(CON_VERBOSE, "Joystick: found %d joysticks\n", n); for (i = 0; i < n; i++) { - con_printf(CON_VERBOSE, "sdl-joystick %d: %s\n", i, SDL_JoystickName(i)); + con_printf(CON_VERBOSE, "Joystick %d: %s\n", i, SDL_JoystickName(i)); SDL_Joysticks[num_joysticks].handle = SDL_JoystickOpen(i); if (SDL_Joysticks[num_joysticks].handle) { joy_present = 1; - SDL_Joysticks[num_joysticks].n_axes = SDL_JoystickNumAxes(SDL_Joysticks[num_joysticks].handle); - if(SDL_Joysticks[num_joysticks].n_axes > MAX_AXES_PER_JOYSTICK) - { - Warning("sdl-joystick: found %d axes, only %d supported. Game may be unstable.\n", SDL_Joysticks[num_joysticks].n_axes, MAX_AXES_PER_JOYSTICK); - SDL_Joysticks[num_joysticks].n_axes = MAX_AXES_PER_JOYSTICK; - } - SDL_Joysticks[num_joysticks].n_buttons = SDL_JoystickNumButtons(SDL_Joysticks[num_joysticks].handle); - if(SDL_Joysticks[num_joysticks].n_buttons > MAX_BUTTONS_PER_JOYSTICK) - { - Warning("sdl-joystick: found %d buttons, only %d supported. Game may be unstable.\n", SDL_Joysticks[num_joysticks].n_buttons, MAX_BUTTONS_PER_JOYSTICK); - SDL_Joysticks[num_joysticks].n_buttons = MAX_BUTTONS_PER_JOYSTICK; - } - - SDL_Joysticks[num_joysticks].n_hats - = SDL_JoystickNumHats(SDL_Joysticks[num_joysticks].handle); - if(SDL_Joysticks[num_joysticks].n_hats > MAX_HATS_PER_JOYSTICK) - { - Warning("sdl-joystick: found %d hats, only %d supported. Game may be unstable.\n", SDL_Joysticks[num_joysticks].n_hats, MAX_HATS_PER_JOYSTICK); - SDL_Joysticks[num_joysticks].n_hats = MAX_HATS_PER_JOYSTICK; - } - - con_printf(CON_VERBOSE, "sdl-joystick: %d axes\n", SDL_Joysticks[num_joysticks].n_axes); - con_printf(CON_VERBOSE, "sdl-joystick: %d buttons\n", SDL_Joysticks[num_joysticks].n_buttons); - con_printf(CON_VERBOSE, "sdl-joystick: %d hats\n", SDL_Joysticks[num_joysticks].n_hats); - + con_printf(CON_VERBOSE, "Joystick: %d axes\n", SDL_Joysticks[num_joysticks].n_axes); + con_printf(CON_VERBOSE, "Joystick: %d buttons\n", SDL_Joysticks[num_joysticks].n_buttons); for (j=0; j < SDL_Joysticks[num_joysticks].n_axes; j++) SDL_Joysticks[num_joysticks].axis_map[j] = Joystick.n_axes++; for (j=0; j < SDL_Joysticks[num_joysticks].n_buttons; j++) SDL_Joysticks[num_joysticks].button_map[j] = Joystick.n_buttons++; - for (j=0; j < SDL_Joysticks[num_joysticks].n_hats; j++) - { - SDL_Joysticks[num_joysticks].hat_map[j] = Joystick.n_buttons; - //a hat counts as four buttons - joybutton_text[Joystick.n_buttons++] = j?TNUM_HAT2_U:TNUM_HAT_U; - joybutton_text[Joystick.n_buttons++] = j?TNUM_HAT2_R:TNUM_HAT_R; - joybutton_text[Joystick.n_buttons++] = j?TNUM_HAT2_D:TNUM_HAT_D; - joybutton_text[Joystick.n_buttons++] = j?TNUM_HAT2_L:TNUM_HAT_L; - } - num_joysticks++; - } - else - con_printf(CON_VERBOSE, "sdl-joystick: initialization failed!\n"); - - con_printf(CON_VERBOSE, "sdl-joystick: %d axes (total)\n", Joystick.n_axes); - con_printf(CON_VERBOSE, "sdl-joystick: %d buttons (total)\n", Joystick.n_buttons); + } else + con_printf(CON_VERBOSE, "Joystick: initialization failed!\n"); } - + return joy_present; } @@ -213,172 +134,55 @@ void joy_close() void joy_get_pos(int *x, int *y) { - int axis[MAX_AXES]; - - if (!num_joysticks) { - *x=*y=0; - return; - } - - joystick_read_raw_axis (JOY_ALL_AXIS, axis); - - *x = joy_get_scaled_reading( axis[0], 0 ); - *y = joy_get_scaled_reading( axis[1], 1 ); + *x = Joystick.axes[0] << 8; + *y = Joystick.axes[1] << 8; } int joy_get_btns() { -#if 0 // This is never used? - int i, buttons = 0; - for (i=0; i++; i= Joystick.n_buttons) - return 0; - - event_poll(); - - return Joystick.buttons[btn].state; + return 0; } void joy_get_cal_vals(int *axis_min, int *axis_center, int *axis_max) { - int i; - - for (i = 0; i < JOY_NUM_AXES; i++) { - axis_center[i] = Joystick.axes[i].center_val; - axis_min[i] = Joystick.axes[i].min_val; - axis_max[i] = Joystick.axes[i].max_val; - } } void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max) { - int i; - - for (i = 0; i < JOY_NUM_AXES; i++) { - Joystick.axes[i].center_val = axis_center[i]; - Joystick.axes[i].min_val = axis_min[i]; - Joystick.axes[i].max_val = axis_max[i]; - } } -int joy_get_scaled_reading( int raw, int axis_num ) +int joy_get_scaled_reading( int raw, int axn ) { -#if 1 - return raw/256; -#else - int d, x; - - raw -= Joystick.axes[axis_num].center_val; - - if (raw < 0) - d = Joystick.axes[axis_num].center_val - Joystick.axes[axis_num].min_val; - else if (raw > 0) - d = Joystick.axes[axis_num].max_val - Joystick.axes[axis_num].center_val; - else - d = 0; - - if (d) - x = ((raw << 7) / d); - else - x = 0; - - if ( x < -128 ) - x = -128; - if ( x > 127 ) - x = 127; - - d = (joy_deadzone) * 6; - if ((x > (-1*d)) && (x < d)) - x = 0; - - return x; -#endif + return 0; } void joy_set_slow_reading( int flag ) diff --git a/arch/sdl/joydefs.c b/arch/sdl/joydefs.c index c9d62fe0..44a2b801 100644 --- a/arch/sdl/joydefs.c +++ b/arch/sdl/joydefs.c @@ -1,8 +1,21 @@ -/* $Id: joydefs.c,v 1.6 2003-03-14 05:11:29 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/sdl/joydefs.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-11-14 03:56:53 $ * * SDL joystick support * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/11/14 03:29:39 bradleyb + * copied joydefs_config from linux/joydefs.c - controls menu now works + * + * Revision 1.1 2001/10/24 09:25:05 bradleyb + * Moved input stuff to arch subdirs, as in d1x. + * + * Revision 1.1 2001/10/10 03:01:29 bradleyb + * Replacing win32 joystick (broken) with SDL joystick (stubs) + * * */ @@ -17,71 +30,28 @@ #include "text.h" #include "kconfig.h" -extern int num_joysticks; - int joydefs_calibrate_flag = 0; void joydefs_calibrate() { - joydefs_calibrate_flag = 0; - - if (!num_joysticks) { - nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK ); - return; - } - - //Actual calibration if necessary - } void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem ) { - int i; - int oc_type = Config_control_type; - - nitems = nitems; - last_key = last_key; - citem = citem; - - for (i=0; i<3; i++ ) - if (items[i].value) Config_control_type = i; - - if (Config_control_type == 2) Config_control_type = CONTROL_MOUSE; - - if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) { - nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS ); - } - - if (oc_type != Config_control_type) { - switch (Config_control_type) { - // case CONTROL_NONE: - case CONTROL_JOYSTICK: - case CONTROL_FLIGHTSTICK_PRO: - case CONTROL_THRUSTMASTER_FCS: - case CONTROL_GRAVIS_GAMEPAD: - // case CONTROL_MOUSE: - // case CONTROL_CYBERMAN: - joydefs_calibrate_flag = 1; - } - kc_set_controls(); - } } void joydefs_config() { - newmenu_item m[13]; - int i, i1 = 5, j, nitems = 10; + newmenu_item m[13]; + int i, i1=5, j, nitems=7; m[0].type = NM_TYPE_RADIO; m[0].text = "KEYBOARD"; m[0].value = 0; m[0].group = 0; m[1].type = NM_TYPE_RADIO; m[1].text = "JOYSTICK"; m[1].value = 0; m[1].group = 0; m[2].type = NM_TYPE_RADIO; m[2].text = "MOUSE"; m[2].value = 0; m[2].group = 0; m[3].type = NM_TYPE_TEXT; m[3].text=""; - m[4].type = NM_TYPE_MENU; m[4].text = TXT_CUST_ABOVE; - m[5].type = NM_TYPE_TEXT; m[5].text = ""; - m[6].type = NM_TYPE_SLIDER; m[6].text = TXT_JOYS_SENSITIVITY; m[6].value = Config_joystick_sensitivity; m[6].min_value =0; m[6].max_value = 16; - m[7].type = NM_TYPE_TEXT; m[7].text = ""; - m[8].type = NM_TYPE_MENU; m[8].text = TXT_CUST_KEYBOARD; - m[9].type = NM_TYPE_MENU; m[9].text = "CUSTOMIZE D2X KEYS"; + m[4].type = NM_TYPE_MENU; m[4].text="CUSTOMIZE ABOVE"; + m[5].type = NM_TYPE_MENU; m[5].text="CUSTOMIZE KEYBOARD"; + m[6].type = NM_TYPE_MENU; m[6].text="CUSTOMIZE D1X KEYS"; do { @@ -91,8 +61,6 @@ void joydefs_config() i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 ); - Config_joystick_sensitivity = m[6].value; - for (j = 0; j <= 2; j++) if (m[j].value) Config_control_type = j; @@ -100,18 +68,18 @@ void joydefs_config() if (Config_control_type == 2) Config_control_type = CONTROL_MOUSE; - switch (i1) { - case 4: + switch(i1) { + case 4: kconfig (i, m[i].text); break; - case 8: - kconfig(0, "KEYBOARD"); + case 5: + kconfig(0, "KEYBOARD"); break; - case 9: - kconfig(4, "D2X KEYS"); + case 6: + kconfig(3, "D1X KEYS"); break; - } + } - } while (i1>-1); + } while(i1>-1); } diff --git a/arch/sdl/key.c b/arch/sdl/key.c index de8a654a..d6229a45 100644 --- a/arch/sdl/key.c +++ b/arch/sdl/key.c @@ -1,8 +1,14 @@ -/* $Id: key.c,v 1.3 2003-02-27 22:07:21 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/sdl/key.c,v $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2001-10-24 09:25:05 $ * * SDL keyboard input support * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/01/29 14:03:57 bradleyb + * Fixed build, minor fixes * */ @@ -13,13 +19,16 @@ #include #include -#include +#include #include "event.h" #include "error.h" #include "key.h" #include "timer.h" +//added on 9/3/98 by Matt Mueller to free some cpu instead of hogging during menus and such +#include "d_delay.h" +//end this section addition - Matt Mueller #define KEY_BUFFER_SIZE 16 @@ -512,7 +521,7 @@ int key_inkey() key_data.keyhead = add_one(key_data.keyhead); } //added 9/3/98 by Matt Mueller to free cpu time instead of hogging during menus and such - else timer_delay(1); + else d_delay(1); //end addition - Matt Mueller return key; diff --git a/arch/sdl/mouse.c b/arch/sdl/mouse.c index 85ef5289..5e255011 100644 --- a/arch/sdl/mouse.c +++ b/arch/sdl/mouse.c @@ -1,8 +1,20 @@ -/* $Id: mouse.c,v 1.5 2003-01-15 02:42:41 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/sdl/mouse.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-11-14 11:02:55 $ * * SDL mouse driver. * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/11/14 10:44:21 bradleyb + * remove cruft, fix formatting, use mouse wheel to emulate 3rd axis + * + * Revision 1.1 2001/10/24 09:25:05 bradleyb + * Moved input stuff to arch subdirs, as in d1x. + * + * Revision 1.3 2001/01/29 14:03:57 bradleyb + * Fixed build, minor fixes * */ @@ -11,9 +23,7 @@ #endif #include - -#include - +#include #include "fix.h" #include "timer.h" #include "event.h" @@ -59,9 +69,9 @@ void mouse_button_handler(SDL_MouseButtonEvent *mbe) MB_HEAD_LEFT, MB_HEAD_RIGHT }; - + int button = button_remap[mbe->button - 1]; // -1 since SDL seems to start counting at 1 - + if (mbe->state == SDL_PRESSED) { Mouse.buttons[button].pressed = 1; Mouse.buttons[button].time_went_down = timer_get_fixed_seconds(); @@ -93,9 +103,9 @@ void mouse_flush() // clears all mice events... { int i; fix current_time; - + event_poll(); - + current_time = timer_get_fixed_seconds(); for (i=0; i -#endif - -#include -#include - -#include - -#ifdef __linux__ -#include -#include -#endif - -#include "pstypes.h" -#include "error.h" -#include "args.h" -#include "rbaudio.h" - -static SDL_CD *s_cd = NULL; -static int initialised = 0; - -void RBAExit() -{ - if (initialised) - { - SDL_CDStop(s_cd); - SDL_CDClose(s_cd); - } -} - -void RBAInit() -{ - if (initialised) return; - if (FindArg("-nocdrom")) return; - - if (SDL_Init(SDL_INIT_CDROM) < 0) - { - Warning("SDL library initialisation failed: %s.",SDL_GetError()); - return; - } - - if (SDL_CDNumDrives() == 0) - { - Warning("No cdrom drives found!\n"); - return; - } - s_cd = SDL_CDOpen(0); - if (s_cd == NULL) { - Warning("Could not open cdrom for redbook audio!\n"); - return; - } - atexit(RBAExit); - initialised = 1; -} - -int RBAEnabled() -{ - return 1; -} - -void RBARegisterCD() -{ - -} - -int RBAPlayTrack(int a) -{ - if (!initialised) return -1; - - if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) { - SDL_CDPlayTracks(s_cd, a-1, 0, 0, 0); - } - return a; -} - -void RBAStop() -{ - if (!initialised) return; - SDL_CDStop(s_cd); -} - -void RBASetVolume(int volume) -{ -#ifdef __linux__ - int cdfile, level; - struct cdrom_volctrl volctrl; - - if (!initialised) return; - - cdfile = s_cd->id; - level = volume * 3; - - if ((level<0) || (level>255)) { - fprintf(stderr, "illegal volume value (allowed values 0-255)\n"); - return; - } - - volctrl.channel0 - = volctrl.channel1 - = volctrl.channel2 - = volctrl.channel3 - = level; - if ( ioctl(cdfile, CDROMVOLCTRL, &volctrl) == -1 ) { - fprintf(stderr, "CDROMVOLCTRL ioctl failed\n"); - return; - } -#endif -} - -void RBAPause() -{ - if (!initialised) return; - SDL_CDPause(s_cd); -} - -int RBAResume() -{ - if (!initialised) return -1; - SDL_CDResume(s_cd); - return 1; -} - -int RBAGetNumberOfTracks() -{ - if (!initialised) return -1; - SDL_CDStatus(s_cd); - return s_cd->numtracks; -} - -int RBAPlayTracks(int tracknum,int something) -{ - if (!initialised) return -1; - if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) { - SDL_CDPlayTracks(s_cd, tracknum-1, 0, 0, 0); - } - return tracknum; -} - -int RBAGetTrackNum() -{ - if (!initialised) return -1; - SDL_CDStatus(s_cd); - return s_cd->cur_track; -} - -int RBAPeekPlayStatus() -{ - return (SDL_CDStatus(s_cd) == CD_PLAYING); -} - -int CD_blast_mixer() -{ - return 0; -} - - -static int cddb_sum(int n) -{ - int ret; - - /* For backward compatibility this algorithm must not change */ - - ret = 0; - - while (n > 0) { - ret = ret + (n % 10); - n = n / 10; - } - - return (ret); -} - - -unsigned long RBAGetDiscID() -{ - int i, t = 0, n = 0; - - if (!initialised) - return 0; - - /* For backward compatibility this algorithm must not change */ - - i = 0; - - while (i < s_cd->numtracks) { - n += cddb_sum(s_cd->track[i].offset / CD_FPS); - i++; - } - - t = (s_cd->track[s_cd->numtracks].offset / CD_FPS) - - (s_cd->track[0].offset / CD_FPS); - - return ((n % 0xff) << 24 | t << 8 | s_cd->numtracks); -} diff --git a/arch/sdl/timer.c b/arch/sdl/timer.c index 986e084e..bbec27f3 100644 --- a/arch/sdl/timer.c +++ b/arch/sdl/timer.c @@ -1,8 +1,14 @@ -/* $Id: timer.c,v 1.6 2003-02-21 04:08:48 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/arch/sdl/timer.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 09:45:02 $ * * SDL library timer functions * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/01/29 13:35:09 bradleyb + * Fixed build system, minor fixes * */ @@ -10,25 +16,12 @@ #include #endif -#include - +#include #include "maths.h" -#include "timer.h" - -fix timer_get_approx_seconds(void) -{ - return approx_msec_to_fsec(SDL_GetTicks()); -} - -fix timer_get_fixed_seconds(void) -{ - fix x; - unsigned long tv_now = SDL_GetTicks(); - x=i2f(tv_now/1000) | fixdiv(i2f(tv_now % 1000),i2f(1000)); - return x; -} -void timer_delay(fix seconds) -{ - SDL_Delay(f2i(fixmul(seconds, i2f(1000)))); +fix timer_get_fixed_seconds(void) { + fix x; + unsigned long tv_now = SDL_GetTicks(); + x=i2f(tv_now/1000) | fixdiv(i2f(tv_now % 1000),i2f(1000)); + return x; } diff --git a/arch/svgalib/.cvsignore b/arch/svgalib/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/arch/svgalib/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/arch/svgalib/Makefile.am b/arch/svgalib/Makefile.am index 108018a8..1eda7513 100644 --- a/arch/svgalib/Makefile.am +++ b/arch/svgalib/Makefile.am @@ -2,6 +2,6 @@ EXTRA_SUBDIRS = linux noinst_LIBRARIES = libarch_svgalib.a -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/main -I$(top_srcdir)/arch/include +INCLUDES = -I$(top_srcdir)/includes -I$(top_srcdir)/main -I$(top_srcdir)/arch/include libarch_svgalib_a_SOURCES = event.c gr.c key.c mouse.c init.c diff --git a/arch/svgalib/key.c b/arch/svgalib/key.c index 8206c010..572e3546 100644 --- a/arch/svgalib/key.c +++ b/arch/svgalib/key.c @@ -1,15 +1,12 @@ /* * $Source: /cvs/cvsroot/d2x/arch/svgalib/key.c,v $ - * $Revision: 1.2 $ - * $Author: btb $ - * $Date: 2003-02-27 22:07:21 $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2001-10-24 09:25:05 $ * * SVGALib keyboard input support * * $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 * @@ -29,6 +26,9 @@ #include "key.h" #include "timer.h" +//added on 9/3/98 by Matt Mueller to free some cpu instead of hogging during menus and such +#include "d_delay.h" +//end this section addition - Matt Mueller #define KEY_BUFFER_SIZE 16 @@ -269,7 +269,7 @@ int key_inkey() key_data.keyhead = add_one(key_data.keyhead); } //added 9/3/98 by Matt Mueller to free cpu time instead of hogging during menus and such -// else timer_delay(1); +// else d_delay(1); //end addition - Matt Mueller return key; } diff --git a/arch/win32/.cvsignore b/arch/win32/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/arch/win32/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/arch/win32/Makefile.am b/arch/win32/Makefile.am index 3c2a761d..2f28bfe1 100644 --- a/arch/win32/Makefile.am +++ b/arch/win32/Makefile.am @@ -2,18 +2,15 @@ EXTRA_SUBDIRS = include d3dframe noinst_LIBRARIES = libarch_win32.a -INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/include -I$(top_srcdir)/main -I$(srcdir)/include +INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/includes -I$(top_srcdir)/main -I$(srcdir)/include if USE_NETWORK -NETWORK_SRCS = winnet.c ipx_win.c +libarch_win32_a_SOURCES = findfile.c mingw_init.c winnet.c ipx_win.c +else +libarch_win32_a_SOURCES = findfile.c mingw_init.c endif -libarch_win32_a_SOURCES = ${NETWORK_SRCS} findfile.c mingw_init.c - -EXTRA_libarch_win32_a_SOURCES = winnet.c ipx_win.c - EXTRA_DIST = ${EXTRA_SUBDIRS} \ d1x.ico d1x.rc d3d.ico debug.cpp descent.ico digi.c findfile.c glinit.c gr.c \ -hmpfile.c init.c joydefs.c joyhh.c key.c mono.c mouse.c palw32.c \ -pch.cpp scene.cpp serial.c texture.cpp timer.c win32.c winmain.cpp \ -ipx_drv.h +hmpfile.c init.c ipx_win.c joydefs.c joyhh.c key.c mono.c mouse.c palw32.c \ +pch.cpp scene.cpp serial.c texture.cpp timer.c win32.c winmain.cpp winnet.c diff --git a/arch/win32/digi.c b/arch/win32/digi.c index d22c22f1..a4977660 100644 --- a/arch/win32/digi.c +++ b/arch/win32/digi.c @@ -134,7 +134,7 @@ int digi_init() waveformat.wFormatTag=WAVE_FORMAT_PCM; waveformat.wBitsPerSample=8; waveformat.nChannels = 1; - waveformat.nSamplesPerSec = digi_sample_rate; //11025; + waveformat.nSamplesPerSec = 11025; waveformat.nBlockAlign = waveformat.nChannels * (waveformat.wBitsPerSample/8); waveformat.nAvgBytesPerSec = @@ -255,7 +255,7 @@ TryNextChannel: waveformat.wFormatTag=WAVE_FORMAT_PCM; waveformat.wBitsPerSample=8; waveformat.nChannels = 1; - waveformat.nSamplesPerSec = digi_sample_rate; //11025; + waveformat.nSamplesPerSec = 11025; waveformat.nBlockAlign = waveformat.nChannels * (waveformat.wBitsPerSample/8); waveformat.nAvgBytesPerSec = @@ -333,7 +333,7 @@ int digi_start_sound_object(int obj) waveformat.wFormatTag=WAVE_FORMAT_PCM; waveformat.wBitsPerSample=8; waveformat.nChannels = 1; - waveformat.nSamplesPerSec = digi_sample_rate; // 11025; + waveformat.nSamplesPerSec = 11025; waveformat.nBlockAlign = waveformat.nChannels * (waveformat.wBitsPerSample/8); waveformat.nAvgBytesPerSec = diff --git a/arch/win32/ipx_drv.h b/arch/win32/ipx_drv.h deleted file mode 100644 index 0f7f1bac..00000000 --- a/arch/win32/ipx_drv.h +++ /dev/null @@ -1,84 +0,0 @@ -/* $Id: */ - -/* - * - * IPX driver interface - * - * parts from: - * ipx.h header file for IPX for the DOS emulator - * Tim Bird, tbird@novell.com - * - */ - -#ifndef _IPX_DRV_H -#define _IPX_DRV_H - -#define IPX_MANUAL_ADDRESS - -#include - -typedef unsigned char ubyte; -typedef unsigned short ushort; -typedef unsigned int uint; - -#ifdef __GNUC__ -# define __pack__ __attribute__((packed)) -#else -# define __pack__ -#endif - -#define MAX_PACKET_DATA 1500 - -#ifdef _MSC_VER -#pragma pack (push, 1) -#endif - -typedef struct IPXAddressStruct { - u_char Network[4] __pack__; - u_char Node[6] __pack__; - u_char Socket[2] __pack__; -} IPXAddress_t; - -typedef struct IPXPacketStructure { - u_short Checksum __pack__; - u_short Length __pack__; - u_char TransportControl __pack__; - u_char PacketType __pack__; - IPXAddress_t Destination __pack__; - IPXAddress_t Source __pack__; -} IPXPacket_t; - -#ifdef _MSC_VER -#pragma pack (pop) -#endif - -typedef struct ipx_socket_struct { - u_short socket; - int fd; -} ipx_socket_t; - -struct ipx_recv_data { - /* all network order */ - u_char src_network[4]; - u_char src_node[6]; - u_short src_socket; - u_short dst_socket; - int pkt_type; -}; - -struct ipx_driver { - int (*GetMyAddress)(void); - int (*OpenSocket)(ipx_socket_t *sk, int port); - void (*CloseSocket)(ipx_socket_t *mysock); - int (*SendPacket)(ipx_socket_t *mysock, IPXPacket_t *IPXHeader, - u_char *data, int dataLen); - int (*ReceivePacket)(ipx_socket_t *s, char *buffer, int bufsize, - struct ipx_recv_data *rec); - int (*PacketReady)(ipx_socket_t *s); -}; - -int ipx_general_PacketReady(ipx_socket_t *s); - -extern unsigned char ipx_MyAddress[10]; - -#endif /* _IPX_DRV_H */ diff --git a/arch/win32/ipx_win.c b/arch/win32/ipx_win.c index 47cda640..8deb746c 100644 --- a/arch/win32/ipx_win.c +++ b/arch/win32/ipx_win.c @@ -1,10 +1,19 @@ -/* $Id: ipx_win.c,v 1.6 2003-03-19 23:10:34 btb Exp $ */ - /* + * $Source: /cvs/cvsroot/d2x/arch/win32/ipx_win.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 10:52:38 $ * * IPX driver using BSD style sockets * Mostly taken from dosemu * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 00:23:56 bradleyb + * Moved win32_* to win32/ (a la d1x), starting to get net working. + * + * Revision 1.3 2001/01/29 13:35:09 bradleyb + * Fixed build system, minor fixes + * */ #ifdef HAVE_CONFIG_H @@ -14,14 +23,14 @@ #include #include #include -#include -#include -#include +//#include #include "ipx_drv.h" +#include "wsipx.h" + +#include "mono.h" -#define _do_mprintf(n, format, args...) printf(format, ## args) -#define mprintf(args) _do_mprintf args +static ipx_socket_t mysock; //#define n_printf(format, args...) mprintf((1, format, ## args)) @@ -79,7 +88,7 @@ static int ipx_win_GetMyAddress( void ) return(0); } -static int ipx_win_OpenSocket(ipx_socket_t *sk, int port) +static int ipx_win_OpenSocket(int port) { int sock; /* sock here means Linux socket handle */ int opt; @@ -87,6 +96,24 @@ static int ipx_win_OpenSocket(ipx_socket_t *sk, int port) int len; struct sockaddr_ipx ipxs2; + WORD wVersionRequested; + WSADATA wsaData; + + wVersionRequested = MAKEWORD(2, 0); + if (WSAStartup( wVersionRequested, &wsaData)) + { + return -1; + } +#if 0 + if ( LOBYTE( wsaData.wVersion ) != 2 || + HIBYTE( wsaData.wVersion ) != 0 ) { + /* We couldn't find a usable WinSock DLL. */ + WSACleanup( ); + return -2; + } +#endif + + /* DANG_FIXTHIS - kludge to support broken linux IPX stack */ /* need to convert dynamic socket open into a real socket number */ /* if (port == 0) { @@ -150,19 +177,23 @@ static int ipx_win_OpenSocket(ipx_socket_t *sk, int port) memcpy(ipx_MyAddress, ipxs2.sa_netnum, 4); memcpy(ipx_MyAddress + 4, ipxs2.sa_nodenum, 6); - sk->fd = sock; - sk->socket = port; + mysock.fd = sock; + mysock.socket = port; + + ipx_win_GetMyAddress(); + return 0; } -static void ipx_win_CloseSocket(ipx_socket_t *mysock) { +static void ipx_win_CloseSocket(void) { /* now close the file descriptor for the socket, and free it */ - mprintf((1,"IPX: closing file descriptor on socket %x\n", mysock->socket)); - closesocket(mysock->fd); + mprintf((1,"IPX: closing file descriptor on socket %x\n", mysock.socket)); + closesocket(mysock.fd); + WSACleanup(); } -static int ipx_win_SendPacket(ipx_socket_t *mysock, IPXPacket_t *IPXHeader, - u_char *data, int dataLen) { +static int ipx_win_SendPacket(IPXPacket_t *IPXHeader, + ubyte *data, int dataLen) { struct sockaddr_ipx ipxs; ipxs.sa_family = AF_IPX; @@ -174,36 +205,46 @@ static int ipx_win_SendPacket(ipx_socket_t *mysock, IPXPacket_t *IPXHeader, /* ipxs.sa_netnum = htonl(MyNetwork); */ } memcpy(&ipxs.sa_nodenum, IPXHeader->Destination.Node, 6); - memcpy(&ipxs.sa_socket, IPXHeader->Destination.Socket, 2); +// memcpy(&ipxs.sa_socket, IPXHeader->Destination.Socket, 2); + ipxs.sa_socket=htons(mysock.socket); // ipxs.sa_type = IPXHeader->PacketType; /* ipxs.sipx_port=htons(0x452); */ - return sendto(mysock->fd, data, dataLen, 0, + return sendto(mysock.fd, data, dataLen, 0, (struct sockaddr *) &ipxs, sizeof(ipxs)); } -static int ipx_win_ReceivePacket(ipx_socket_t *s, char *buffer, int bufsize, +static int ipx_win_ReceivePacket(char *buffer, int bufsize, struct ipx_recv_data *rd) { int sz, size; struct sockaddr_ipx ipxs; sz = sizeof(ipxs); - if ((size = recvfrom(s->fd, buffer, bufsize, 0, + if ((size = recvfrom(mysock.fd, buffer, bufsize, 0, (struct sockaddr *) &ipxs, &sz)) <= 0) return size; memcpy(rd->src_network, ipxs.sa_netnum, 4); memcpy(rd->src_node, ipxs.sa_nodenum, 6); rd->src_socket = ipxs.sa_socket; - rd->dst_socket = s->socket; + rd->dst_socket = mysock.socket; // rd->pkt_type = ipxs.sipx_type; return size; } +static int ipx_win_general_PacketReady(void) { + return ipx_general_PacketReady(mysock.fd); +} + struct ipx_driver ipx_win = { - ipx_win_GetMyAddress, +// ipx_win_GetMyAddress, ipx_win_OpenSocket, ipx_win_CloseSocket, ipx_win_SendPacket, ipx_win_ReceivePacket, - ipx_general_PacketReady + ipx_win_general_PacketReady, + NULL, + 1, + NULL, + NULL, + NULL }; diff --git a/arch/win32/mingw_init.c b/arch/win32/mingw_init.c index 377c432c..5d66e16d 100644 --- a/arch/win32/mingw_init.c +++ b/arch/win32/mingw_init.c @@ -1,7 +1,13 @@ /* + * $Source: /cvs/cvsroot/d2x/arch/win32/mingw_init.c,v $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 09:01:56 $ * * mingw_init.c - Basically same as linux init.c * + * $Log: not supported by cvs2svn $ + * */ #ifdef HAVE_CONFIG_H diff --git a/arch/win32/winnet.c b/arch/win32/winnet.c index 5b4b4075..c12ac2e5 100644 --- a/arch/win32/winnet.c +++ b/arch/win32/winnet.c @@ -1,362 +1,28 @@ -/* $Id: winnet.c,v 1.5 2003-02-28 23:34:15 btb Exp $ */ -/* -THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX -SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO -END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A -ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS -IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS -SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE -FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE -CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. -*/ - /* + * $Source: /cvs/cvsroot/d2x/arch/win32/winnet.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 10:52:38 $ * * Win32 net * + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/19 00:23:56 bradleyb + * Moved win32_* to win32/ (a la d1x), starting to get net working. + * */ #ifdef HAVE_CONFIG_H #include #endif -#include -#include -#include -#include +#include "pstypes.h" -#include "args.h" #include "ipx_drv.h" extern struct ipx_driver ipx_win; -#define MAX_IPX_DATA 576 - -int ipx_fd; -ipx_socket_t ipx_socket_data; -ubyte ipx_installed=0; -ushort ipx_socket = 0; -uint ipx_network = 0; -ubyte ipx_MyAddress[10]; -int ipx_packetnum = 0; /* Sequence number */ - -/* User defined routing stuff */ -typedef struct user_address { - ubyte network[4]; - ubyte node[6]; - ubyte address[6]; -} user_address; -#define MAX_USERS 64 -int Ipx_num_users = 0; -user_address Ipx_users[MAX_USERS]; - -#define MAX_NETWORKS 64 -int Ipx_num_networks = 0; -uint Ipx_networks[MAX_NETWORKS]; - -void ipx_close(void); - -int ipx_general_PacketReady(ipx_socket_t *s) { - fd_set set; - struct timeval tv; - - FD_ZERO(&set); - FD_SET(s->fd, &set); - tv.tv_sec = tv.tv_usec = 0; - if (select(FD_SETSIZE, &set, NULL, NULL, &tv) > 0) - return 1; - else - return 0; -} - -struct ipx_driver *driver = &ipx_win; - -ubyte * ipx_get_my_server_address() -{ - return (ubyte *)&ipx_network; -} - -ubyte * ipx_get_my_local_address() -{ - return (ubyte *)(ipx_MyAddress + 4); -} - -//--------------------------------------------------------------- -// Initializes all IPX internals. -// If socket_number==0, then opens next available socket. -// Returns: 0 if successful. -// -1 if socket already open. -// -2 if socket table full. -// -3 if IPX not installed. -// -4 if couldn't allocate low dos memory -// -5 if error with getting internetwork address -int ipx_init( int socket_number, int show_address ) -{ - int i; - - WORD wVersionRequested; - WSADATA wsaData; - - wVersionRequested = MAKEWORD(2, 0); - if (WSAStartup( wVersionRequested, &wsaData)) - { - return -1; - } - -#if 0 - if ( LOBYTE( wsaData.wVersion ) != 2 || - HIBYTE( wsaData.wVersion ) != 0 ) { - /* We couldn't find a usable WinSock DLL. */ - WSACleanup( ); - return -2; - } -#endif - - printf("Using real IPX for network games\n"); - driver = &ipx_win; - if ((i = FindArg("-ipxnetwork")) && Args[i + 1]) { - unsigned long n = strtol(Args[i + 1], NULL, 16); - ipx_MyAddress[0] = (unsigned char)n >> 24; ipx_MyAddress[1] = (unsigned char)(n >> 16) & 255; - ipx_MyAddress[2] = (unsigned char)(n >> 8) & 255; ipx_MyAddress[3] = (unsigned char)n & 255; - printf("IPX: Using network %08x\n", (int) n); - } - if (driver->OpenSocket(&ipx_socket_data, socket_number)) { - return -3; - } - driver->GetMyAddress(); - memcpy(&ipx_network, ipx_MyAddress, 4); - Ipx_num_networks = 0; - memcpy( &Ipx_networks[Ipx_num_networks++], &ipx_network, 4 ); - ipx_installed = 1; - atexit(ipx_close); - printf("ipx succesfully installed\n"); - return 0; -} - -void ipx_close() -{ - if (ipx_installed) { - WSACleanup(); - driver->CloseSocket(&ipx_socket_data); - } - ipx_installed = 0; -} - -int ipx_get_packet_data( ubyte * data ) -{ - struct ipx_recv_data rd; - char buf[MAX_IPX_DATA]; - uint best_id = 0; - uint pkt_num; - int size; - int best_size = 0; - - // Like the original, only take latest packet, throw away rest - while (driver->PacketReady(&ipx_socket_data)) { - if ((size = - driver->ReceivePacket(&ipx_socket_data, buf, - sizeof(buf), &rd)) > 4) { - if (!memcmp(rd.src_network, ipx_MyAddress, 10)) - continue; /* don't get own pkts */ - pkt_num = *(uint *)buf; - if (pkt_num >= best_id) { - memcpy(data, buf + 4, size - 4); - best_id = pkt_num; - best_size = size - 4; - } - } - } - return best_size; -} - -void ipx_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ) -{ - u_char buf[MAX_IPX_DATA]; - IPXPacket_t ipx_header; - - memcpy(ipx_header.Destination.Network, network, 4); - memcpy(ipx_header.Destination.Node, immediate_address, 6); - *(u_short *)ipx_header.Destination.Socket = htons(ipx_socket_data.socket); - ipx_header.PacketType = 4; /* Packet Exchange */ - *(uint *)buf = ipx_packetnum++; - memcpy(buf + 4, data, datasize); - driver->SendPacket(&ipx_socket_data, &ipx_header, buf, datasize + 4); -} - -void ipx_get_local_target( ubyte * server, ubyte * node, ubyte * local_target ) +struct ipx_driver * arch_ipx_set_driver(char *arg) { - // let's hope Linux knows how to route it - memcpy( local_target, node, 6 ); -} - -void ipx_send_broadcast_packet_data( ubyte * data, int datasize ) -{ - int i, j; - ubyte broadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - ubyte local_address[6]; - - // Set to all networks besides mine - for (i=0; iCloseSocket(&ipx_socket_data); - if (driver->OpenSocket(&ipx_socket_data, socket_number)) { - return -3; - } - return 0; -} - -void ipx_read_user_file(char * filename) -{ - FILE * fp; - user_address tmp; - char temp_line[132], *p1; - int n, ln=0, x; - - if (!filename) return; - - Ipx_num_users = 0; - - fp = fopen( filename, "rt" ); - if ( !fp ) return; - - printf( "Broadcast Users:\n" ); - - while (fgets(temp_line, 132, fp)) { - ln++; - p1 = strchr(temp_line,'\n'); if (p1) *p1 = '\0'; - p1 = strchr(temp_line,';'); if (p1) *p1 = '\0'; -#if 1 // adb: replaced sscanf(..., "%2x...", (char *)...) with better, but longer code - if (strlen(temp_line) >= 21 && temp_line[8] == '/') { - for (n = 0; n < 4; n++) { - if (sscanf(temp_line + n * 2, "%2x", &x) != 1) - break; - tmp.network[n] = x; - } - if (n != 4) - continue; - for (n = 0; n < 6; n++) { - if (sscanf(temp_line + 9 + n * 2, "%2x", &x) != 1) - break; - tmp.node[n] = x; - } - if (n != 6) - continue; - } else - continue; -#else - n = sscanf( temp_line, "%2x%2x%2x%2x/%2x%2x%2x%2x%2x%2x", &tmp.network[0], &tmp.network[1], &tmp.network[2], &tmp.network[3], &tmp.node[0], &tmp.node[1], &tmp.node[2],&tmp.node[3], &tmp.node[4], &tmp.node[5] ); - if ( n != 10 ) continue; -#endif - if ( Ipx_num_users < MAX_USERS ) { - ubyte * ipx_real_buffer = (ubyte *)&tmp; - ipx_get_local_target( tmp.network, tmp.node, tmp.address ); - Ipx_users[Ipx_num_users++] = tmp; - printf( "%02X%02X%02X%02X/", ipx_real_buffer[0],ipx_real_buffer[1],ipx_real_buffer[2],ipx_real_buffer[3] ); - printf( "%02X%02X%02X%02X%02X%02X\n", ipx_real_buffer[4],ipx_real_buffer[5],ipx_real_buffer[6],ipx_real_buffer[7],ipx_real_buffer[8],ipx_real_buffer[9] ); - } else { - printf( "Too many addresses in %s! (Limit of %d)\n", filename, MAX_USERS ); - fclose(fp); - return; - } - } - fclose(fp); -} - - -void ipx_read_network_file(char * filename) -{ - FILE * fp; - user_address tmp; - char temp_line[132], *p1; - int i, n, ln=0, x; - - if (!filename) return; - - fp = fopen( filename, "rt" ); - if ( !fp ) return; - - printf( "Using Networks:\n" ); - for (i=0; i= 8) { - for (n = 0; n < 4; n++) { - if (sscanf(temp_line + n * 2, "%2x", &x) != 1) - break; - tmp.network[n] = x; - } - if (n != 4) - continue; - } else - continue; -#else - n = sscanf( temp_line, "%2x%2x%2x%2x", &tmp.network[0], &tmp.network[1], &tmp.network[2], &tmp.network[3] ); - if ( n != 4 ) continue; -#endif - if ( Ipx_num_networks < MAX_NETWORKS ) { - int j; - for (j=0; j= Ipx_num_networks ) { - memcpy( &Ipx_networks[Ipx_num_networks++], tmp.network, 4 ); - printf(" %02x%02x%02x%02x\n", tmp.network[0], tmp.network[1], tmp.network[2], tmp.network[3] ); - } - } else { - printf( "Too many networks in %s! (Limit of %d)\n", filename, MAX_NETWORKS ); - fclose(fp); - return; - } - } - fclose(fp); + return &ipx_win; } diff --git a/autogen.sh b/autogen.sh index d1397d84..99035ad6 100644 --- a/autogen.sh +++ b/autogen.sh @@ -1,10 +1,9 @@ #!/bin/sh set -e -echo "If you get errors, you may need newer versions of automake and autoconf." -echo "You'll need at least automake 1.5 and autoconf 2.50." +touch ChangeLog aclocal $ACLOCAL_FLAGS autoheader -automake --add-missing --copy +automake --add-missing autoconf #./configure "$@" echo "Now you are ready to run ./configure" diff --git a/cfile/.cvsignore b/cfile/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/cfile/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/cfile/Makefile.am b/cfile/Makefile.am index b5f1c6ee..e1e0391f 100644 --- a/cfile/Makefile.am +++ b/cfile/Makefile.am @@ -1,4 +1,4 @@ noinst_LIBRARIES = libcfile.a -INCLUDES = -I $(top_srcdir)/include +INCLUDES = -I $(top_srcdir)/includes libcfile_a_SOURCES = cfile.c diff --git a/cfile/cfile.c b/cfile/cfile.c index 7d6c8b9b..ad310441 100644 --- a/cfile/cfile.c +++ b/cfile/cfile.c @@ -1,4 +1,3 @@ -/* $Id: cfile.c,v 1.11 2003-04-14 18:34:40 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,124 +7,16 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Functions for accessing compressed files. - * - * Old Log: - * Revision 1.7 1995/10/27 15:18:20 allender - * get back to descent directory before trying to read a hog file - * - * Revision 1.6 1995/10/21 23:48:24 allender - * hogfile(s) are now in :Data: folder - * - * Revision 1.5 1995/08/14 09:27:31 allender - * added byteswap header - * - * Revision 1.4 1995/05/12 11:54:33 allender - * changed memory stuff again - * - * Revision 1.3 1995/05/04 20:03:38 allender - * added code that was missing...use NewPtr instead of malloc - * - * Revision 1.2 1995/04/03 09:59:49 allender - * *** empty log message *** - * - * Revision 1.1 1995/03/30 10:25:02 allender - * Initial revision - * - * - * --- PC RCS Information --- - * Revision 1.24 1995/03/15 14:20:27 john - * Added critical error checker. - * - * Revision 1.23 1995/03/13 15:16:53 john - * Added alternate directory stuff. - * - * Revision 1.22 1995/02/09 23:08:47 matt - * Increased the max number of files in hogfile to 250 - * - * Revision 1.21 1995/02/01 20:56:47 john - * Added cfexist function - * - * Revision 1.20 1995/01/21 17:53:48 john - * Added alternate pig file thing. - * - * Revision 1.19 1994/12/29 15:10:02 john - * Increased hogfile max files to 200. - * - * Revision 1.18 1994/12/12 13:20:57 john - * Made cfile work with fiellentth. - * - * Revision 1.17 1994/12/12 13:14:25 john - * Made cfiles prefer non-hog files. - * - * Revision 1.16 1994/12/09 18:53:26 john - * *** empty log message *** - * - * Revision 1.15 1994/12/09 18:52:56 john - * Took out mem, error checking. - * - * Revision 1.14 1994/12/09 18:10:31 john - * Speed up cfgets, which was slowing down the reading of - * bitmaps.tbl, which was making POF loading look slow. - * - * Revision 1.13 1994/12/09 17:53:51 john - * Added error checking to number of hogfiles.. - * - * Revision 1.12 1994/12/08 19:02:55 john - * Added cfgets. - * - * Revision 1.11 1994/12/07 21:57:48 john - * Took out data dir. - * - * Revision 1.10 1994/12/07 21:38:02 john - * Made cfile not return error.. - * - * Revision 1.9 1994/12/07 21:35:34 john - * Made it read from data directory. - * - * Revision 1.8 1994/12/07 21:33:55 john - * Stripped out compression stuff... - * - * Revision 1.7 1994/04/13 23:44:59 matt - * When file cannot be opened, free up the buffer for that file. - * - * Revision 1.6 1994/02/18 12:38:20 john - * Optimized a bit - * - * Revision 1.5 1994/02/15 18:13:20 john - * Fixed more bugs. - * - * Revision 1.4 1994/02/15 13:27:58 john - * Works ok... - * - * Revision 1.3 1994/02/15 12:51:57 john - * Crappy inbetween version - * - * Revision 1.2 1994/02/14 20:12:29 john - * First version working with new cfile stuff. - * - * Revision 1.1 1994/02/14 15:51:33 john - * Initial revision - * - * Revision 1.1 1994/02/10 15:45:12 john - * Initial revision - * - * - */ - #ifdef HAVE_CONFIG_H #include #endif #include #include -#include #include "pstypes.h" #include "u_mem.h" @@ -136,9 +27,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "byteswap.h" typedef struct hogfile { - char name[13]; - int offset; - int length; + char name[13]; + int offset; + int length; } hogfile; #define MAX_HOGFILES 300 @@ -146,16 +37,11 @@ typedef struct hogfile { hogfile HogFiles[MAX_HOGFILES]; char Hogfile_initialized = 0; int Num_hogfiles = 0; -char HogFilename[64]; - -hogfile D1HogFiles[MAX_HOGFILES]; -char D1Hogfile_initialized = 0; -int D1Num_hogfiles = 0; -char D1HogFilename[64]; hogfile AltHogFiles[MAX_HOGFILES]; char AltHogfile_initialized = 0; int AltNum_hogfiles = 0; +char HogFilename[64]; char AltHogFilename[64]; char AltHogDir[64]; @@ -170,16 +56,16 @@ char AltHogdir_initialized = 0; void macify_dospath(char *dos_path, char *mac_path) { char *p; - + if (!strncmp(dos_path, ".\\", 2)) { strcpy(mac_path, ":"); strcat(mac_path, &(dos_path[2]) ); } else strcpy(mac_path, dos_path); - + while ( (p = strchr(mac_path, '\\')) != NULL) *p = ':'; - + } #endif @@ -199,7 +85,7 @@ int default_error_counter=0; //ptr to counter of how many critical errors int *critical_error_counter_ptr=&default_error_counter; -//tell cfile about your critical error counter +//tell cfile about your critical error counter void cfile_set_critical_error_counter_ptr(int *ptr) { critical_error_counter_ptr = ptr; @@ -228,7 +114,7 @@ FILE * cfile_get_filehandle( char * filename, char * mode ) fclose(fp); fp = NULL; } - } + } return fp; } @@ -250,8 +136,8 @@ int cfile_init_hogfile(char *fname, hogfile * hog_files, int * nfiles ) return 0; } - while( 1 ) - { + while( 1 ) + { if ( *nfiles >= MAX_HOGFILES ) { fclose(fp); Error( "HOGFILE is limited to %d files.\n", MAX_HOGFILES ); @@ -279,10 +165,10 @@ int cfile_init(char *hogname) { #ifdef MACINTOSH char mac_path[255]; - + macify_dospath(hogname, mac_path); #endif - + Assert(Hogfile_initialized == 0); #ifndef MACINTOSH @@ -291,7 +177,7 @@ int cfile_init(char *hogname) #else if (cfile_init_hogfile(mac_path, HogFiles, &Num_hogfiles )) { strcpy( HogFilename, mac_path ); - #endif + #endif Hogfile_initialized = 1; return 1; } @@ -300,22 +186,6 @@ int cfile_init(char *hogname) } -int cfile_size(char *hogname) -{ - CFILE *fp; - struct stat statbuf; - - fp = cfopen(hogname, "rb"); - if (fp == NULL) - return -1; - fstat(fileno(fp->file), &statbuf); - cfclose(fp); - return statbuf.st_size; -} - -/* - * return handle for file called "name", embedded in one of the hogfiles - */ FILE * cfile_find_libfile(char * name, int * length) { FILE * fp; @@ -349,19 +219,6 @@ FILE * cfile_find_libfile(char * name, int * length) return fp; } } - - if (D1Hogfile_initialized) { - for (i = 0; i < D1Num_hogfiles; i++) { - if (!stricmp(D1HogFiles[i].name, name)) { - fp = cfile_get_filehandle(D1HogFilename, "rb"); - if (fp == NULL) return NULL; - fseek(fp, D1HogFiles[i].offset, SEEK_SET); - *length = D1HogFiles[i].length; - return fp; - } - } - } - return NULL; } @@ -370,7 +227,7 @@ int cfile_use_alternate_hogfile( char * name ) if ( name ) { #ifdef MACINTOSH char mac_path[255]; - + macify_dospath(name, mac_path); strcpy( AltHogFilename, mac_path); #else @@ -385,26 +242,6 @@ int cfile_use_alternate_hogfile( char * name ) } } -int cfile_use_descent1_hogfile( char * name ) -{ - if (name) { -#ifdef MACINTOSH - char mac_path[255]; - - macify_dospath(name, mac_path); - strcpy(D1HogFilename, mac_path); -#else - strcpy(D1HogFilename, name); -#endif - cfile_init_hogfile(D1HogFilename, D1HogFiles, &D1Num_hogfiles); - D1Hogfile_initialized = 1; - return (D1Num_hogfiles > 0); - } else { - D1Hogfile_initialized = 0; - return 1; - } -} - int cfexist( char * filename ) { int length; @@ -433,12 +270,12 @@ int cfexist( char * filename ) } -CFILE * cfopen(char * filename, char * mode ) +CFILE * cfopen(char * filename, char * mode ) { int length; FILE * fp; CFILE *cfile; - + if (stricmp( mode, "rb")) { Error( "cfiles can only be opened with mode==rb\n" ); } @@ -446,7 +283,7 @@ CFILE * cfopen(char * filename, char * mode ) if (filename[0] != '\x01') { #ifdef MACINTOSH char mac_path[255]; - + macify_dospath(filename, mac_path); fp = cfile_get_filehandle( mac_path, mode); #else @@ -490,14 +327,14 @@ int cfilelength( CFILE *fp ) return fp->size; } -int cfgetc( CFILE * fp ) +int cfgetc( CFILE * fp ) { int c; if (fp->raw_position >= fp->size ) return EOF; c = getc( fp->file ); - if (c!=EOF) + if (c!=EOF) fp->raw_position++; // Assert( fp->raw_position==(ftell(fp->file)-fp->lib_offset) ); @@ -511,7 +348,7 @@ char * cfgets( char * buf, size_t n, CFILE * fp ) int i; int c; - for (i=0; iraw_position >= fp->size ) { *buf = 0; @@ -519,21 +356,23 @@ char * cfgets( char * buf, size_t n, CFILE * fp ) } c = fgetc( fp->file ); fp->raw_position++; - if (c == 0 || c == 10) // Unix line ending - break; - if (c == 13) { // Mac or DOS line ending +#ifdef MACINTOSH + if (c == 13) { int c1; - + c1 = fgetc( fp->file ); fseek( fp->file, -1, SEEK_CUR); - if ( c1 == 10 ) // DOS line ending + if ( c1 == 10 ) continue; - else // Mac line ending + else break; } +#endif } while ( c == 13 ); - if ( c == 13 ) // because cr-lf is a bad thing on the mac - c = '\n'; // and anyway -- 0xod is CR on mac, not 0x0a +#ifdef MACINTOSH // because cr-lf is a bad thing on the mac + if ( c == 13 ) // and anyway -- 0xod is CR on mac, not 0x0a + c = '\n'; +#endif *buf++ = c; if ( c=='\n' ) break; } @@ -658,11 +497,3 @@ void cfile_read_angvec(vms_angvec *v, CFILE *file) v->b = cfile_read_fixang(file); v->h = cfile_read_fixang(file); } - -void cfile_read_matrix(vms_matrix *m,CFILE *file) -{ - cfile_read_vector(&m->rvec,file); - cfile_read_vector(&m->uvec,file); - cfile_read_vector(&m->fvec,file); -} - diff --git a/compilerdefs.txt b/compilerdefs.txt index f64ced1b..9b369ce7 100644 --- a/compilerdefs.txt +++ b/compilerdefs.txt @@ -2,95 +2,68 @@ Typical predefined macros, obtained by executing something like: gcc -dM -E - < /dev/null MinGW: -#define _WIN32 1 -#define _X86_ 1 -#define __HAVE_BUILTIN_SETJMP__ 1 -#define __tune_pentium2__ 1 -#define __i386__ 1 -#define __SIZE_TYPE__ unsigned int -#define __GNUC_PATCHLEVEL__ 0 -#define _stdcall __attribute__((__stdcall__)) -#define __MSVCRT__ 1 -#define __USER_LABEL_PREFIX__ _ -#define __STDC_HOSTED__ 1 -#define __WIN32 1 -#define __stdcall __attribute__((__stdcall__)) -#define __tune_i686__ 1 -#define __WCHAR_TYPE__ short unsigned int -#define __MINGW32__ 1 -#define WIN32 1 -#define __WINT_TYPE__ unsigned int -#define __GNUC__ 3 -#define _cdecl __attribute__((__cdecl__)) -#define __tune_pentium3__ 1 -#define __tune_pentiumpro__ 1 -#define __fastcall __attribute__((__fastcall__)) +#define _stdcall __attribute__((__stdcall__)) +#define __i386__ 1 +#define _X86_ 1 +#define __i386 1 +#define WIN32 1 +#define __i686 1 +#define __GNUC_MINOR__ 95 +#define WINNT 1 +#define __declspec(x) __attribute__((x)) +#define pentiumpro 1 +#define __MSVCRT__ 1 +#define __MINGW32__ 1 +#define _cdecl __attribute__((__cdecl__)) +#define __pentiumpro 1 +#define i386 1 +#define i686 1 +#define __pentiumpro__ 1 +#define _WIN32 1 +#define __stdcall __attribute__((__stdcall__)) +#define __WIN32__ 1 +#define __i686__ 1 +#define __GNUC__ 2 +#define __cdecl __attribute__((__cdecl__)) +#define __WIN32 1 Cygwin: -#define _X86_ 1 -#define __HAVE_BUILTIN_SETJMP__ 1 -#define __tune_pentium2__ 1 -#define __unix__ 1 -#define unix 1 -#define __i386__ 1 -#define __SIZE_TYPE__ unsigned int -#define __GNUC_PATCHLEVEL__ 0 -#define _stdcall __attribute__((__stdcall__)) -#define __CYGWIN__ 1 -#define __unix 1 -#define __USER_LABEL_PREFIX__ _ -#define __STDC_HOSTED__ 1 -#define __stdcall __attribute__((__stdcall__)) -#define __tune_i686__ 1 -#define __WCHAR_TYPE__ short unsigned int -#define __WINT_TYPE__ unsigned int -#define __GNUC__ 3 -#define _cdecl __attribute__((__cdecl__)) -#define __tune_pentium3__ 1 -#define __tune_pentiumpro__ 1 -#define __fastcall __attribute__((__fastcall__)) -#define _fastcall __attribute__((__fastcall__)) -#define __CYGWIN32__ 1 -#define __GXX_ABI_VERSION 102 -#define i386 1 -#define __GNUC_MINOR__ 2 -#define __STDC__ 1 -#define __PTRDIFF_TYPE__ int -#define __REGISTER_PREFIX__ -#define __cdecl __attribute__((__cdecl__)) -#define __NO_INLINE__ 1 -#define __i386 1 -#define __VERSION__ "3.2 20020927 (prerelease)" -#define __declspec(x) __attribute__((x)) +#define _stdcall __attribute__((__stdcall__)) +#define __i386__ 1 +#define _X86_ 1 +#define __i386 1 +#define __i686 1 +#define __GNUC_MINOR__ 95 +#define __declspec(x) __attribute__((x)) +#define pentiumpro 1 +#define __CYGWIN__ 1 +#define _cdecl __attribute__((__cdecl__)) +#define __pentiumpro 1 +#define i386 1 +#define i686 1 +#define __pentiumpro__ 1 +#define __stdcall __attribute__((__stdcall__)) +#define __unix 1 +#define __unix__ 1 +#define __i686__ 1 +#define __GNUC__ 2 +#define __cdecl __attribute__((__cdecl__)) +#define __CYGWIN32__ 1 +#define unix 1 -Linux/x86: -#define __HAVE_BUILTIN_SETJMP__ 1 -#define __unix__ 1 -#define unix 1 -#define __i386__ 1 -#define __SIZE_TYPE__ unsigned int -#define __ELF__ 1 -#define __GNUC_PATCHLEVEL__ 2 -#define __linux 1 -#define __unix 1 +Linux: #define __linux__ 1 -#define __USER_LABEL_PREFIX__ #define linux 1 -#define __STDC_HOSTED__ 1 -#define __WCHAR_TYPE__ long int -#define __gnu_linux__ 1 -#define __WINT_TYPE__ unsigned int -#define __GNUC__ 3 -#define __GXX_ABI_VERSION 102 -#define i386 1 -#define __GNUC_MINOR__ 2 -#define __STDC__ 1 -#define __PTRDIFF_TYPE__ int -#define __tune_i386__ 1 -#define __REGISTER_PREFIX__ -#define __NO_INLINE__ 1 +#define __i386__ 1 #define __i386 1 -#define __VERSION__ "3.2.2 20030109 (Debian prerelease)" +#define __GNUC_MINOR__ 95 +#define i386 1 +#define __unix 1 +#define __unix__ 1 +#define __GNUC__ 2 +#define __linux 1 +#define __ELF__ 1 +#define unix 1 Djgpp: #define __DJGPP_MINOR 3 @@ -114,69 +87,3 @@ Djgpp: #define __DJGPP_MINOR__ 3 #define unix 1 #define __GO32 1 - -Mac OS X: -#define __MACH__ 1 -#define __NATURAL_ALIGNMENT__ 1 -#define __APPLE__ 1 -#define __GNUC_MINOR__ 95 -#define __ppc__ 1 -#define __GNUC__ 2 -#define __STDC__ 1 -#define __DYNAMIC__ 1 -#define __APPLE_CC__ 937 -#define __BIG_ENDIAN__ 1 - -SunOS/Sparc: -#define __GCC_NEW_VARARGS__ 1 -#define __sparc 1 -#define __svr4__ 1 -#define __GNUC_MINOR__ 95 -#define __sun 1 -#define sparc 1 -#define __sun__ 1 -#define __unix 1 -#define __unix__ 1 -#define __SVR4 1 -#define sun 1 -#define __GNUC__ 2 -#define __sparc__ 1 -#define unix 1 - -Linux/Mips -#define __LANGUAGE_C 1 -#define R3000 1 -#define __linux__ 1 -#define __MIPSEB 1 -#define _LANGUAGE_C 1 -#define _MIPS_SZLONG 32 -#define linux 1 -#define __mips__ 1 -#define __mips 1 -#define __SIZE_TYPE__ unsigned int -#define _R3000 1 -#define __GNUC_MINOR__ 95 -#define MIPSEB 1 -#define __pic__ 1 -#define __R3000__ 1 -#define _MIPS_SZINT 32 -#define __PTRDIFF_TYPE__ int -#define mips 1 -#define _MIPS_SZPTR 32 -#define ___mips 1 -#define __unix 1 -#define __R3000 1 -#define __unix__ 1 -#define _MIPSEB 1 -#define __PIC__ 1 -#define _MIPS_FPSET 32 -#define __GNUC__ 2 -#define ___mips__ 1 -#define __linux 1 -#define _MIPS_ISA _MIPS_ISA_MIPS1 -#define LANGUAGE_C 1 -#define __ELF__ 1 -#define _mips 1 -#define _MIPS_SIM _MIPS_SIM_ABI32 -#define __MIPSEB__ 1 -#define unix 1 diff --git a/configure.ac b/configure.ac index 8cc5f1a4..00effaf9 100644 --- a/configure.ac +++ b/configure.ac @@ -1,23 +1,13 @@ # -*- mode: shell-script -*- - -define([D2X_MAJOR],0) -define([D2X_MINOR],2) -define([D2X_MICRO],4) - -AC_INIT(d2x,[D2X_MAJOR.D2X_MINOR.D2X_MICRO],[descent-source@warpcore.org]) +AC_INIT(main/inferno.c) AC_PREREQ(2.52) AC_CANONICAL_BUILD AC_CANONICAL_HOST AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE([1.6]) - AM_CONFIG_HEADER(conf.h) - -AC_DEFINE_UNQUOTED(D2XMAJOR,D2X_MAJOR,[d2x major version]) -AC_DEFINE_UNQUOTED(D2XMINOR,D2X_MINOR,[d2x minor version]) -AC_DEFINE_UNQUOTED(D2XMICRO,D2X_MICRO,[d2x micro version]) +AM_INIT_AUTOMAKE(d2x, 0.1.2) AM_MAINTAINER_MODE @@ -32,92 +22,91 @@ AC_CHECK_TOOL(RANLIB, ranlib, :) AC_CHECK_TOOL(STRIP, strip, :) AC_CHECK_TOOL(AR, ar, :) AC_PROG_CC -AC_PROG_CXX AC_STDC_HEADERS -AC_PATH_PROGS(NASM, nasm nasmw, no) -AC_C_BIGENDIAN - -case $host_cpu in - sparc) - AC_DEFINE(WORDS_NEED_ALIGNMENT,,[Define if your processor needs data to be word-aligned]) - ;; -esac - -build_macosx_bundle=no -build_simple_bundle=no - -case $host_os in - cygwin) - AC_MSG_WARN([Cygwin found, setting -mno-cygwin]) - CFLAGS="-mno-cygwin $CFLAGS" - MINGW32=yes - ;; - mingw*) - MINGW32=yes - ;; - darwin*) - MACOSX=yes - AC_MSG_RESULT(Mac OS X/Darwin; Mac OS X bundle) - build_macosx_bundle=yes - DATADIR='EXE>>../Resources' - #SCOREDIR='/Library/Preferences/KoboDeluxe/scores' - #CONFIGDIR='HOME>>Library/Preferences' - #CONFIGFILE='KoboDeluxe Preferences' - MATHLIB="" - ;; - msdos*) - MSDOS=yes - ;; -esac - -AC_CHECK_DECLS(nanosleep,,,[#include ]) -AC_CHECK_TYPES(struct timespec) +AC_PATH_PROGS(NASM, nasmw nasm, no) + +AC_CYGWIN +AC_MINGW32 +if test x$CYGWIN = xyes; then + AC_MSG_WARN([Cygwin found, setting -mno-cygwin]) + CFLAGS="-mno-cygwin $CFLAGS" + MINGW32=yes +fi AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes) if test x$MINGW32 = xyes; then GL_LIBS="opengl32 glu32" -elif test x$MACOSX = xyes; then - GL_LIBS="" else GL_LIBS="GL GLU" fi -AM_CONDITIONAL(MACOSX, test x$MACOSX = xyes) -AM_CONDITIONAL(BUILD_MACOSX_BUNDLE, test x$build_macosx_bundle = xyes) -AM_CONDITIONAL(BUILD_SIMPLE_BUNDLE, test x$build_simple_bundle = xyes) - dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set test "x$prefix" = "xNONE" && prefix=$ac_default_prefix test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}" dnl Set default locations to find data files. -default_sharepath="$datadir/games/$PACKAGE" +eval foo="$datadir" +default_sharepath="$foo/games/$PACKAGE" CFLAGS="-Wall $CFLAGS" dnl Enable editor build? AC_ARG_ENABLE(editor, - [ --enable-editor Build editor? (not functional)],,) + [ --enable-editor Build editor? (not functional)],,) if test x$enable_editor = xyes; then - AC_DEFINE(EDITOR,,[Define if you want to build the editor]) + AC_DEFINE(EDITOR) D2X_MAIN_SUBDIRS=editor fi AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes) -dnl Enable macdata build? -AC_ARG_ENABLE(macdata, - [ --enable-macdata Build for mac datafiles],,) -if test x$enable_macdata = xyes; then - AC_DEFINE(MACDATA,,[Define if you want to build for mac datafiles]) - D2X_FEATURES="macdata ${D2X_FEATURES}" +dnl Enable shareware build? +AC_ARG_ENABLE(shareware, + [ --enable-shareware Build for demo datafiles (not functional)],,) +if test x$enable_shareware = xyes; then + AC_DEFINE(SHAREWARE) + D2X_FEATURES="shareware ${D2X_FEATURES}" +fi +AM_CONDITIONAL(SHAREWARE, test x$enable_shareware = xyes) + +dnl Enable movie trick? +AC_ARG_ENABLE(movies, + [ --enable-movie-trick Enable trick to show movies],,) +if test x$enable_movie_trick = xyes; then + AC_DEFINE(MOVIE_TRICK) + D2X_FEATURES="movie_trick ${D2X_FEATURES}" +fi +AM_CONDITIONAL(MOVIE_TRICK, test x$enable_movie_trick = xyes) + +dnl Enable NMOVIES? +AC_ARG_ENABLE(nmovies, + [ --enable-nmovies Turn off movies (render endlevel flythrough)],,) +if test x$enable_nmovies = xyes; then + AC_DEFINE(NMOVIES) + D2X_FEATURES="nmovies ${D2X_FEATURES}" +fi +AM_CONDITIONAL(NMOVIES, test x$enable_nmovies = xyes) + +dnl Enable cross-platform bitmap/palette loader? +AC_ARG_ENABLE(xploader, + [ --enable-xploader Enable cross-platform bitmap/palette loader ],,) +if test x$enable_xploader = xyes; then + AC_DEFINE(PORTABLE_LOADER) + D2X_FEATURES="xploader ${D2X_FEATURES}" +fi + +dnl Count warnings as errors? +AC_ARG_ENABLE(werror, + [ --enable-werror Count compiler warning as errors ],,) +if test x$enable_werror = xyes; then + CFLAGS="-Werror $CFLAGS" + D2X_FEATURES="werror ${D2X_FEATURES}" fi -AM_CONDITIONAL(MACDATA, test x$enable_macdata = xyes) dnl Build with NDEBUG? AC_ARG_ENABLE(debug, - [ --disable-debug Take out debug symbols, Asserts, Int3, etc ],,) + [ --disable-debug Take out debug symbols, Asserts, Int3, etc ],,) if test x$enable_debug = xno; then - AC_DEFINE(NDEBUG,,[Define to disable asserts, int3, etc.]) + AC_DEFINE(NDEBUG) CFLAGS="-O2 $CFLAGS" else CFLAGS="-g $CFLAGS" @@ -126,234 +115,156 @@ fi dnl Build with RELEASE? AC_ARG_ENABLE(release, - [ --enable-release Release build. Removes debug/editor things ],,) + [ --enable-release Release build. Removes debug/editor things ],,) if test x$enable_release = xyes; then - AC_DEFINE(RELEASE,,[Define for a "release" build]) + AC_DEFINE(RELEASE) D2X_FEATURES="release ${D2X_FEATURES}" fi -dnl Build without using sdl-joystick ? -AC_ARG_ENABLE(linuxjoy, - [ --enable-linuxjoy do not use the SDL Joystick. (eg for MS Sidewinder)],,) -if test x$enable_linuxjoy = xyes; then - AC_DEFINE(USE_LINUX_JOY,,[define to not use the SDL_Joystick routines.]) -fi -AM_CONDITIONAL(USE_LINUX_JOY, test x$enable_linuxjoy = xyes) - -dnl Build with FAST_FILE_IO? -AC_ARG_ENABLE(fastfileio, - [ --disable-fastfileio Disable fast file i/o. ],,) -if test x$enable_fastfileio != xno; then - if test x$ac_cv_c_bigendian = xyes; then - AC_MSG_WARN([big-endian cpu detected. disabling fastfileio]) - enable_fastfileio="no"; - fi -fi -if test x$enable_fastfileio != xno; then - AC_DEFINE(FAST_FILE_IO,,[Define for faster i/o on little-endian cpus]) - D2X_FEATURES="fastfileio ${D2X_FEATURES}" -fi - -dnl Build with CONSOLE? -AC_ARG_ENABLE(console, - [ --enable-console Enable console (very experimental) ],,) -if test x$enable_console = xyes; then - AC_DEFINE(CONSOLE,,[Define to enable console]) - D2X_FEATURES="console ${D2X_FEATURES}" -fi - AC_ARG_WITH(sharepath, - [[ --with-sharepath=DIR Use DIR for shared game data (unix only) [DATADIR/games/d2x]]], - sharepath=$withval, sharepath="auto") + [[ --with-sharepath=DIR Use DIR for shared game data [DATADIR/games/d2x]]], + sharepath=$withval, sharepath="auto") if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then sharepath="$default_sharepath" fi -AC_SUBST(sharepath) -eval sharepath=$sharepath -AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath",[Define this to be the shared game directory root]) - -# Test for MSDOS -if test x$MSDOS = xyes; then - CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS" - TARGETS=d2x - D2X_ARCH_SUBDIRS=dos -else +AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath") + +# Test for DJGPP +AM_CONDITIONAL(DJGPP, test "$host_os" = "msdosdjgpp") +if test "$host_os" = "msdosdjgpp"; then - CFLAGS="-pipe $CFLAGS" + CFLAGS="-I \$(top_srcdir)/arch/dos/include $CFLAGS" + TARGETS=d2x + D2X_ARCH_SUBDIRS=dos +else - dnl Check for SDL - AM_PATH_SDL(1.1.0, - :, - AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix) - ) - CFLAGS="$SDL_CFLAGS $CFLAGS" - LIBS="$SDL_LIBS $LIBS" + CFLAGS="-pipe $CFLAGS" - TARGETS=d2x-sdl - D2X_ARCH_SUBDIRS=sdl + dnl Check for SDL + AM_PATH_SDL(1.1.7, + :, + AC_MSG_ERROR(SDL not found. Make sure sdl-config is in your PATH, or specify with --with-sdl-prefix) + ) + CFLAGS="$SDL_CFLAGS $CFLAGS" + LIBS="$SDL_LIBS $LIBS" - AC_CHECK_HEADERS(netipx/ipx.h) + TARGETS=d2x-sdl + D2X_ARCH_SUBDIRS=sdl - # Check for SDL_image - AC_CHECK_LIB(SDL_image, IMG_ReadXPMFromArray, - LIBS="-lSDL_image $LIBS" - AC_DEFINE(SDL_IMAGE,,[Define if you have the SDL_image library])) + AC_CHECK_HEADERS(netipx/ipx.h) # Check for OpenGL - AC_ARG_WITH(opengl, - [ --with-opengl Build OpenGL support ],,) - if test x$with_opengl = xyes; then - for lib in $GL_LIBS; do - AC_CHECK_LIB($lib, main, - OGL_LIBS="${OGL_LIBS} -l$lib", - [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used]) - opengl=false], - ${OGL_LIBS} - ) - done - AC_DEFINE(OGL,,[Define if you want an OpenGL build]) - TARGETS=d2x-gl - D2X_ARCH_SUBDIRS="ogl ${D2X_ARCH_SUBDIRS}" - fi - AC_SUBST(OGL_LIBS) - AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes) + AC_ARG_WITH(opengl, + [ --with-opengl Build OpenGL support ],,) + if test x$with_opengl = xyes; then + for lib in $GL_LIBS; do + AC_CHECK_LIB($lib, main, + OGL_LIBS="${OGL_LIBS} -l$lib", + [AC_MSG_ERROR([$lib not found, --with-opengl cannot be used]) + opengl=false], + ${OGL_LIBS} + ) + done + AC_DEFINE(OGL) + TARGETS=d2x-ogl + D2X_ARCH_SUBDIRS="ogl ${D2X_ARCH_SUBDIRS}" + fi + AC_SUBST(OGL_LIBS) + AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes) # Check for GGI - AC_ARG_WITH(ggi, - [ --with-ggi Build GGI support ],,) - if test x$with_ggi = xyes; then - AC_CHECK_LIB(ggi, ggiInit, - GGI_LIBS="-lggi", - [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false]) - AC_CHECK_LIB(gii, giiInit, - GGI_LIBS="${GGI_LIBS} -lgii", - [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false]) - AC_DEFINE(GGI,,[Define if you want a GGI build]) - TARGETS=d2x-ggi - D2X_ARCH_SUBDIRS="ggi ${D2X_ARCH_SUBDIRS}" - fi - AC_SUBST(GGI_LIBS) - AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes) + AC_ARG_WITH(ggi, + [ --with-ggi Build GGI support ],,) + if test x$with_ggi = xyes; then + AC_CHECK_LIB(ggi, ggiInit, + GGI_LIBS="-lggi", + [AC_MSG_ERROR([GGI not found, GGI version cannot be built]); ggi=false]) + AC_CHECK_LIB(gii, giiInit, + GGI_LIBS="${GGI_LIBS} -lgii", + [AC_MSG_ERROR([GII not found, GGI version cannot be built]); ggi=false]) + AC_DEFINE(GGI) + TARGETS=d2x-ggi + D2X_ARCH_SUBDIRS="ggi ${D2X_ARCH_SUBDIRS}" + fi + AC_SUBST(GGI_LIBS) + AM_CONDITIONAL(USE_GGI, test x$with_ggi = xyes) # Check for SVGALib - AC_ARG_WITH(svga, - [ --with-svga Build SVGALib support ],,) - if test x$with_svga = xyes; then - AC_CHECK_LIB(vga,vga_getmousetype, - SVGA_LIBS="-lvga", - [AC_MSG_ERROR([vga not found, SVGALib cannot be built]) - svga=false], - ) - AC_CHECK_LIB(vgagl,gl_getcontext, - SVGA_LIBS="${SVGA_LIBS} -lvgagl", - [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built]) - svga=false], - -lvga) - AC_DEFINE(SVGA,,[Define if you want an SVGALib build]) - TARGETS=d2x-svga - D2X_ARCH_SUBDIRS="svgalib ${D2X_ARCH_SUBDIRS}" - fi - AC_SUBST(SVGA_LIBS) - AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes) - - if test x$MINGW32 = xyes; then - D2X_ARCH_SUBDIRS="win32 ${D2X_ARCH_SUBDIRS}" - else - CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS" - D2X_ARCH_SUBDIRS="linux ${D2X_ARCH_SUBDIRS}" + AC_ARG_WITH(svga, + [ --with-svga Build SVGALib support ],,) + if test x$with_svga = xyes; then + AC_CHECK_LIB(vga,vga_getmousetype, + SVGA_LIBS="-lvga", + [AC_MSG_ERROR([vga not found, SVGALib cannot be built]) + svga=false], + ) + AC_CHECK_LIB(vgagl,gl_getcontext, + SVGA_LIBS="${SVGA_LIBS} -lvgagl", + [AC_MSG_ERROR([vgagl not found, SVGALib cannot be built]) + svga=false], + -lvga) + AC_DEFINE(SVGA) + TARGETS=d2x-svga + D2X_ARCH_SUBDIRS="svgalib ${D2X_ARCH_SUBDIRS}" + fi + AC_SUBST(SVGA_LIBS) + AM_CONDITIONAL(USE_SVGALIB, test x$with_svga = xyes) + + if test x$MINGW32 = xyes; then + D2X_ARCH_SUBDIRS="win32 ${D2X_ARCH_SUBDIRS}" + AC_DEFINE(SDL_JOYSTICK) + else + CFLAGS="-I \$(top_srcdir)/arch/linux/include $CFLAGS" + D2X_ARCH_SUBDIRS="linux ${D2X_ARCH_SUBDIRS}" + + dnl Check for SDL joystick + AC_ARG_ENABLE(sdl-joystick, + [ --enable-sdl-joystick Use SDL joystick (required for mingw) ],,) + if test x$enable_sdl_joystick = xyes; then + AC_DEFINE(SDL_JOYSTICK) + D2X_FEATURES="sdl_joystick ${D2X_FEATURES}" fi + AM_CONDITIONAL(SDL_JOYSTICK, test x$enable_sdl_joystick = xyes) + fi fi dnl Check for network AC_ARG_ENABLE(network, - [ --disable-network Do not build network/serial support ],,) + [ --disable-network Do not build network/serial support ],,) if test x$enable_network != xno; then - if test x$MACOSX = xyes; then - AC_MSG_WARN([OS X detected. disabling network]) - enable_network="no"; - fi -fi -if test x$enable_network != xno; then - AC_DEFINE(NETWORK,,[Define if you want a network build]) + AC_DEFINE(NETWORK) D2X_FEATURES="network ${D2X_FEATURES}" fi AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno) dnl Check for assembler AC_ARG_ENABLE(assembler, - [ --disable-assembler Do not use assembler optimization ],,) -if test x$enable_assembler != xno; then + [ --disable-assembler Do not use assembler optimization ],,) +if test x$enable_assembler = xno; then + AC_DEFINE(NO_ASM) + D2X_FEATURES="no_asm ${D2X_FEATURES}" +else if test x$NASM = xno; then - AC_MSG_WARN([nasm not found. disabling assembler]) - enable_assembler="no" + AC_MSG_ERROR([nasm not found. Install it or use --disable-assembler]) else NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS" case $host_os in - cygwin* | mingw*) - NASMFLAGS="-f win32 $NASMFLAGS" - ;; - msdos*) - NASMFLAGS="-f coff $NASMFLAGS" - ;; - linux*) - NASMFLAGS="-f elf -d__linux__ $NASMFLAGS" - ;; - *) - AC_MSG_WARN([nasm not supported for this OS. disabling assembler]) - enable_assembler="no" - ;; + cygwin) + NASMFLAGS="-f win32 $NASMFLAGS" + ;; + msdosdjgpp) + NASMFLAGS="-f coff $NASMFLAGS" + ;; + linux*) + NASMFLAGS="-f elf -d__linux__ $NASMFLAGS" + ;; + *) + AC_MSG_ERROR([Assembler not supported for this OS]) esac fi fi -if test x$enable_assembler = xno; then - AC_DEFINE(NO_ASM,,[Define if you want an assembler free build]) - D2X_FEATURES="no_asm ${D2X_FEATURES}" -fi AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno) -AH_BOTTOM([ - /* General defines */ -#ifndef PACKAGE_STRING -#define PACKAGE_STRING PACKAGE " " VERSION -#endif -#define VERSION_NAME PACKAGE_STRING -#define NMONO 1 -#define PIGGY_USE_PAGING 1 -#define NEWDEMO 1 - -#if defined(__APPLE__) && defined(__MACH__) -#define __unix__ -#endif - -#ifdef __unix__ -# ifdef GGI -# define GII_INPUT 1 -# define GGI_VIDEO 1 -# else -# ifdef SVGA -# define SVGALIB_INPUT 1 -# define SVGALIB_VIDEO 1 -# else -# define SDL_INPUT 1 -# ifdef OGL -# define SDL_GL_VIDEO 1 -# else -# define SDL_VIDEO 1 -# endif -# endif -# endif -#endif - -#ifdef __MINGW32__ -# define SDL_INPUT 1 -# ifdef OGL -# define SDL_GL_VIDEO 1 -# else -# define SDL_VIDEO 1 -# endif -#endif - ]) - AM_PROG_AS AC_SUBST(D2X_ARCH_SUBDIRS) @@ -367,37 +278,32 @@ AC_SUBST(NASMFLAGS) AC_SUBST(CFLAGS) AC_OUTPUT( - Makefile - 2d/Makefile - 3d/Makefile - arch/Makefile - arch/dos/Makefile - arch/ggi/Makefile - arch/linux/Makefile - arch/ogl/Makefile - arch/sdl/Makefile - arch/svgalib/Makefile - arch/win32/Makefile - cfile/Makefile - iff/Makefile - libmve/Makefile - main/Makefile - main/editor/Makefile - maths/Makefile - mem/Makefile - misc/Makefile - texmap/Makefile - utilities/Makefile - debian/changelog - rpm/d2x.spec - Info.plist +Makefile +2d/Makefile +3d/Makefile +arch/Makefile +arch/dos/Makefile +arch/ggi/Makefile +arch/linux/Makefile +arch/ogl/Makefile +arch/sdl/Makefile +arch/svgalib/Makefile +arch/win32/Makefile +cfile/Makefile +iff/Makefile +main/Makefile +main/editor/Makefile +maths/Makefile +mem/Makefile +misc/Makefile +texmap/Makefile ) AC_MSG_RESULT([ - d2x has been configured successfully. + d2x has been configured successfully. - Platform(s): $D2X_ARCH_SUBDIRS - Features : $D2X_FEATURES $D2X_MAIN_SUBDIRS + Platform(s): $D2X_ARCH_SUBDIRS + Features : $D2X_FEATURES $D2X_MAIN_SUBDIRS - Shared game data directory (unix only): $sharepath - ]) + Shared game data directory: $sharepath +]) diff --git a/cvshowto.txt b/cvshowto.txt index 36282e5c..32f0dc64 100644 --- a/cvshowto.txt +++ b/cvshowto.txt @@ -1,75 +1,74 @@ -Adapted from the d1x cvs howto -by Bradley Bell - -A quick howto on accessing the d2x source with CVS. - -0) if you are using windows, or some other non unix os, and the standard - command line cvs client, you will need to set your home directory. - set home=c:\home\ - or something like that. - -1) cd - -2) Log in to the cvs server: - cvs -d :pserver:anonymous@cvs.icculus.org:/cvs/cvsroot login - (password is "anonymous"). You can also try it this way: - cvs -d :pserver:anonymous:anonymous@cvs.icculus.org:/cvs/cvsroot login - - Download the source code: - cvs -z3 -d :pserver:anonymous@cvs.icculus.org:/cvs/cvsroot co d2x - - This will retrieve the source into /d2x - (note that this should only be done once. After you already have the code, - merely do a "cvs update -PAd" from the d2x dir to update to the latest code) - -3) Make your changes and stuff. (Test them too). - -4) You will want to do a cvs update before commiting, to make sure your - changes still work with any other changes that may have been commited while - you were working. - -5) If you have readonly access: - If you have only modified existing files, this should generate a usable diff: - cvs -q diff -uRN . > mychanges.patch - (hopefully you would use a more useful name, and remember to examine the - result first, to make sure its ok.) - If you have added files or directories, this won't be as useful since you - can't use the 'cvs add' command to get cvs to recognize them. In this case - you should diff manually, or just zip up the new files. - - Once you have the patches/zips made, the best way to get them included is to - post a message to the descent-source list with the files attached, or an url - to the files. (see notes below) - --or- if you have full cvs access: - - cvs commit -m "summary of changes" - or, if you want to commit all changes (in current, and sub dirs), just: - cvs commit -m "summary of changes" - (note, only the files that CVS knows about will be commited. *.o/*.bak/etc - will be ignored. If you want to add a new file, use 'cvs add ') - If you have made several unrelated changes, please commit each file seperatly - with appropriate log messages, rather than blanketing them all in an - ambiguous message. - -6) Now that you have the source downloaded, you no longer need steps 1-2. - Merely do a "cvs update" whenever you want to bring your tree up to the - latest code, and continue from step 3. - -Notes: -It is highly recommend that all developers subscribe to the descent-source -mailing list. To signup, send an email to majordomo@warpcore.org with -"subscribe descent-source your@email.address" in the body. - -If some of your changes are too close to other peoples, update or commit may -cause a "conflict". You should probably talk with whoevers code it conflicts -with, unless the solution is obvious. - -Of course, this is only a brief overview. It is recommended you browse the CVS -documention as well. (info cvs, or equivilant). If you have questions, or -think this howto could use some clarification, feel free to ask. - - A great book on cvs is available online: - http://cvsbook.red-bean.com/cvsbook.html - -Where to download CVS: http://www.cyclic.com/cyclic-pages/howget.html +Adapted from the d1x cvs howto +by Bradley Bell + +A quick howto on accessing the d2x source with CVS. + +0) if you are using windows, or some other non unix os, and the standard + command line cvs client, you will need to set your home directory. + set home=c:\home\ + or something like that. + +1) cd + +1.5) cvs -d ":pserver:@shelob.classrooms.washington.edu:/var/cvs" login + Unless you already know your username and password, you want + "anonymous" for the username, and "readonly" for the password. + +2) cvs -d ":pserver:@shelob.classrooms.washington.edu:/var/cvs" checkout d2x + This will retrieve the source into /d2x + (you may wish to look into the -z flag, ex "-z3" to compress the code for + faster transmission) + (note that this should only be done once. After you already have the code, + merely do a "cvs update -PAd" from the d2x dir to update to the latest code) + +3) Make your changes and stuff. (Test them too). + +4) You will want to do a cvs update before commiting, to make sure your + changes still work with any other changes that may have been commited while + you were working. + +5) If you have readonly access: + If you have only modified existing files, this should generate a usable diff: + cvs -q diff -uRN . > mychanges.patch + (hopefully you would use a more useful name, and remember to examine the + result first, to make sure its ok.) + If you have added files or directories, this won't be as useful since you + can't use the 'cvs add' command to get cvs to recognize them. In this case + you should diff manually, or just zip up the new files. + + Once you have the patches/zips made, the best way to get them included is to + post a message to the descent-source list with the files attached, or an url + to the files. (see notes below) + +-or- if you have full cvs access: + + cvs commit -m "summary of changes" + or, if you want to commit all changes (in current, and sub dirs), just: + cvs commit -m "summary of changes" + (note, only the files that CVS knows about will be commited. *.o/*.bak/etc + will be ignored. If you want to add a new file, use 'cvs add ') + If you have made several unrelated changes, please commit each file seperatly + with appropriate log messages, rather than blanketing them all in an + ambiguous message. + +6) Now that you have the source downloaded, you no longer need steps 1-2. + Merely do a "cvs update" whenever you want to bring your tree up to the + latest code, and continue from step 3. + +Notes: +It is highly recommend that all developers subscribe to the descent-source +mailing list. To signup, send an email to majordomo@warpcore.org with +"subscribe descent-source your@email.address" in the body. + +If some of your changes are too close to other peoples, update or commit may +cause a "conflict". You should probably talk with whoevers code it conflicts +with, unless the solution is obvious. + +Of course, this is only a brief overview. It is recommended you browse the CVS +documention as well. (info cvs, or equivilant). If you have questions, or +think this howto could use some clarification, feel free to ask. + + A great book on cvs is available online: + http://cvsbook.red-bean.com/cvsbook.html + +Where to download CVS: http://www.cyclic.com/cyclic-pages/howget.html diff --git a/d2x-gl.sh b/d2x-gl.sh deleted file mode 100644 index d7a0c571..00000000 --- a/d2x-gl.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# -# Enable some 3Dfx OpenGL hints -# -export MESA_GLX_FX="f" -export MESA_CONFIG="quake2" -# -# Disable the 3Dfx GLIDE logo -# -export FX_GLIDE_NO_SPLASH="1" -# -# Change the swap buffers in Voodoo FIFO from 2 to 4 -# -export MESA_FX_SWAP_PENDING="4" -# -# Print Mesa statistics at end of game -# -export MESA_FX_INFO="1" -# -# Enable monitor's vertical refresh rate syncing on _most_ NVidia cards. -# (see /usr/share/doc/NVIDIA_GLX-1.0/README) -export __GL_SYNC_TO_VBLANK="1" -# -# Enable Full Scene Anti-Aliasing on NVidia cards who supports it. -# (see /usr/share/doc/NVIDIA_GLX-1.0/README) -export __GL_FSAA_MODE="3" -# -# Note: this is *mandatory* with single-threaded applications -# like d2x-gl on systems equipped with NVidia cards and an old -# version of ld.so. -# (see /usr/share/doc/NVIDIA_GLX-1.0/README) -# -export __GL_SINGLE_THREADED="1" -# -# Finally, run the real game. -# All switches can be overwritten by command-line arguments. -# -nice /usr/games/d2x-gl.real -tmap fp -nocdrom -nomovies \ - -gl_mipmap -gl_alttexmerge -gl_reticle 2 \ - -nofades \ - $1 $2 $3 $4 $5 - diff --git a/d2x-sdl.sh b/d2x-sdl.sh deleted file mode 100644 index 003ee00f..00000000 --- a/d2x-sdl.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# -# Run the real game. -# All switches can be overwritten by command-line arguments. -# -nice /usr/games/d2x-sdl.real -nocdrom -nomovies -nofades $1 $2 $3 $4 $5 - diff --git a/debian/changelog.in b/debian/changelog.in deleted file mode 100644 index 2ccfd87c..00000000 --- a/debian/changelog.in +++ /dev/null @@ -1,6 +0,0 @@ -d2x (@VERSION@) unstable; urgency=low - - * Please see the file NEWS. - - -- Bradley Bell Tue, 5 Feb 2002 22:16:01 -0800 - diff --git a/debian/control b/debian/control deleted file mode 100644 index 20bdd6e2..00000000 --- a/debian/control +++ /dev/null @@ -1,20 +0,0 @@ -Source: d2x -Section: games -Priority: extra -Maintainer: Bradley Bell -Build-Depends: debhelper (>> 3.0.0), libsdl-dev, nasm, libgl-dev -Standards-Version: 3.5.0 - -Package: d2x-sdl -Architecture: any -Depends: ${shlibs:Depends} -Provides: d2x -Description: Descent II - Descent II - -Package: d2x-gl -Architecture: any -Depends: ${shlibs:Depends} -Provides: d2x -Description: Descent II, GL-accelerated - Descent II, GL-accelerated diff --git a/debian/d2x-gl.files b/debian/d2x-gl.files deleted file mode 100644 index 75de4a89..00000000 --- a/debian/d2x-gl.files +++ /dev/null @@ -1 +0,0 @@ -/usr/games/d2x-gl diff --git a/debian/d2x-gl.menu b/debian/d2x-gl.menu deleted file mode 100644 index dfae069a..00000000 --- a/debian/d2x-gl.menu +++ /dev/null @@ -1,2 +0,0 @@ -?package(d2x-gl):needs=X11 section=Games/Arcade\ - title="d2x-gl" command="/usr/games/d2x-gl" diff --git a/debian/d2x-sdl.files b/debian/d2x-sdl.files deleted file mode 100644 index eb48ce74..00000000 --- a/debian/d2x-sdl.files +++ /dev/null @@ -1 +0,0 @@ -usr/games/d2x-sdl diff --git a/debian/d2x-sdl.menu b/debian/d2x-sdl.menu deleted file mode 100644 index 2d8bd970..00000000 --- a/debian/d2x-sdl.menu +++ /dev/null @@ -1,2 +0,0 @@ -?package(d2x-sdl):needs=X11 section=Games/Arcade\ - title="d2x-sdl" command="/usr/games/d2x-sdl" diff --git a/debian/rules b/debian/rules deleted file mode 100644 index abd9feeb..00000000 --- a/debian/rules +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/make -f -# Sample debian/rules that uses debhelper. -# GNU copyright 1997 to 1999 by Joey Hess. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -# This is the debhelper compatability version to use. -export DH_COMPAT=3 - -configure: configure-stamp configure-gl-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - mkdir -p build_d2x-sdl - cd build_d2x-sdl && ../configure --disable-debug --enable-release \ - --prefix=/usr --bindir=\$${prefix}/games - - touch configure-stamp - -configure-gl-stamp: - dh_testdir - # Add here commands to configure the package. - mkdir -p build_d2x-gl - cd build_d2x-gl && ../configure --disable-debug --enable-release --with-opengl \ - --prefix=/usr --bindir=\$${prefix}/games - - touch configure-gl-stamp - -build: build-stamp build-gl-stamp - -build-stamp: configure-stamp - dh_testdir - - # Add here commands to compile the package. - cd build_d2x-sdl && $(MAKE) - - touch build-stamp - -build-gl-stamp: configure-gl-stamp - dh_testdir - - # Add here commands to compile the package. - cd build_d2x-gl && $(MAKE) - - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - rm -rf build_d2x-sdl build_d2x-gl - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/d2x. - cd build_d2x-sdl && $(MAKE) install DESTDIR=$(CURDIR)/debian/d2x-sdl - cd build_d2x-gl && $(MAKE) install DESTDIR=$(CURDIR)/debian/d2x-gl - - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot -# dh_installdebconf - dh_installdocs -A NEWS - dh_installexamples - dh_installmenu -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_installinit - dh_installcron - dh_installman - dh_installinfo - dh_undocumented -pd2x-sdl d2x-sdl.6 - dh_undocumented -pd2x-gl d2x-gl.6 - dh_installchangelogs - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_makeshlibs - dh_installdeb -# dh_perl - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/iff/.cvsignore b/iff/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/iff/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/iff/Makefile.am b/iff/Makefile.am index 78268e17..9ea5d231 100644 --- a/iff/Makefile.am +++ b/iff/Makefile.am @@ -1,7 +1,7 @@ EXTRA_SUBDIRS = archive noinst_LIBRARIES = libiff.a -INCLUDES = -I $(top_srcdir)/include +INCLUDES = -I $(top_srcdir)/includes libiff_a_SOURCES = iff.c diff --git a/iff/iff.c b/iff/iff.c index be22fb8c..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.6 2002-10-04 07:14:31 btb 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) @@ -111,7 +111,7 @@ long get_sig(FFILE *f) // if ((s[1]=cfgetc(f))==EOF) return(EOF); // if ((s[0]=cfgetc(f))==EOF) return(EOF); -#ifndef WORDS_BIGENDIAN +#ifndef MACINTOSH if (f->position>=f->length) return EOF; s[3] = f->data[f->position++]; if (f->position>=f->length) return EOF; @@ -747,7 +747,8 @@ int iff_parse_bitmap(FFILE *ifile,grs_bitmap *bm,int bitmap_type,byte *palette,g sig=get_sig(ifile); if (sig != form_sig) { - return IFF_NOT_IFF; + ret = IFF_NOT_IFF; + goto done; } form_len = get_long(ifile); @@ -763,7 +764,7 @@ int iff_parse_bitmap(FFILE *ifile,grs_bitmap *bm,int bitmap_type,byte *palette,g if (ret != IFF_NO_ERROR) { //got an error parsing if (bmheader.raw_data) d_free(bmheader.raw_data); - return ret; + goto done; } //If IFF file is ILBM, convert to PPB @@ -771,8 +772,7 @@ int iff_parse_bitmap(FFILE *ifile,grs_bitmap *bm,int bitmap_type,byte *palette,g ret = convert_ilbm_to_pbm(&bmheader); - if (ret != IFF_NO_ERROR) - return ret; + if (ret != IFF_NO_ERROR) goto done; } //Copy data from iff_bitmap_header structure into grs_bitmap structure @@ -800,10 +800,11 @@ int iff_parse_bitmap(FFILE *ifile,grs_bitmap *bm,int bitmap_type,byte *palette,g if (bitmap_type == BM_RGB15) { ret = convert_rgb15(bm,&bmheader); - if (ret != IFF_NO_ERROR) - return ret; + if (ret != IFF_NO_ERROR) goto done; } +done: + return ret; } @@ -815,10 +816,13 @@ int iff_read_bitmap(char *ifilename,grs_bitmap *bm,int bitmap_type,ubyte *palett FFILE ifile; ret = open_fake_file(ifilename,&ifile); //read in entire file - if (ret == IFF_NO_ERROR) { - bm->bm_data = NULL; - ret = iff_parse_bitmap(&ifile,bm,bitmap_type,palette,NULL); - } + if (ret != IFF_NO_ERROR) goto done; + + bm->bm_data = NULL; + + ret = iff_parse_bitmap(&ifile,bm,bitmap_type,palette,NULL); + +done: if (ifile.data) d_free(ifile.data); @@ -837,9 +841,11 @@ int iff_read_into_bitmap(char *ifilename,grs_bitmap *bm,byte *palette) FFILE ifile; ret = open_fake_file(ifilename,&ifile); //read in entire file - if (ret == IFF_NO_ERROR) { - ret = iff_parse_bitmap(&ifile,bm,bm->bm_type,palette,NULL); - } + if (ret != IFF_NO_ERROR) goto done; + + ret = iff_parse_bitmap(&ifile,bm,bm->bm_type,palette,NULL); + +done: if (ifile.data) d_free(ifile.data); @@ -1147,11 +1153,11 @@ int iff_write_bitmap(char *ofilename,grs_bitmap *bm,ubyte *palette) //open file and write - if ((ofile = fopen(ofilename,"wb")) == NULL) { - ret=IFF_NO_FILE; - } else { - ret = write_pbm(ofile,&bmheader,compression_on); - } + if ((ofile = fopen(ofilename,"wb")) == NULL) {ret=IFF_NO_FILE; goto done;} + + ret = write_pbm(ofile,&bmheader,compression_on); + +done: fclose(ofile); diff --git a/include/3d.h b/include/3d.h index c4d42b6d..bf1e41c3 100644 --- a/include/3d.h +++ b/include/3d.h @@ -1,4 +1,3 @@ -/* $Id: 3d.h,v 1.9 2003-01-02 23:13:21 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,135 +7,52 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* + * $Source: /cvs/cvsroot/d2x/include/3d.h,v $ + * $Revision: 1.5 $ + * $Author: bradleyb $ + * $Date: 2001-11-05 07:38:09 $ * * Header file for 3d library - * except for functions implemented in interp.c - * - * Old Log: - * Revision 1.2 1995/09/14 14:08:58 allender - * return value for g3_draw_sphere - * - * Revision 1.1 1995/05/05 08:48:41 allender - * Initial revision - * - * Revision 1.34 1994/11/11 19:22:14 matt - * Added new function, g3_calc_point_depth() - * - * Revision 1.33 1994/09/09 14:23:58 matt - * Added support for glowing textures, to add engine glow to Descent. - * - * Revision 1.32 1994/09/01 10:42:27 matt - * Blob routine, renamed g3_draw_bitmap(), now takes seperate 3d width & height. - * - * Revision 1.31 1994/07/29 18:16:14 matt - * Added instance by angles, and corrected parms for g3_init() - * - * Revision 1.30 1994/07/25 00:00:00 matt - * Made 3d no longer deal with point numbers, but only with pointers. - * - * Revision 1.29 1994/07/22 17:57:27 matt - * Changed the name of the rod functions, and took out some debugging code - * - * Revision 1.28 1994/06/07 16:49:12 matt - * Made interpreter take lighting value as parm, rather than in global var - * - * Revision 1.27 1994/05/31 18:35:28 matt - * Added light value to g3_draw_facing_bitmap() - * - * Revision 1.26 1994/05/30 22:48:04 matt - * Added support for morph effect - * - * Revision 1.25 1994/05/30 11:34:57 matt - * Added g3_set_special_render() to allow a user to specify functions to - * call for 2d draws. - * - * Revision 1.24 1994/05/19 21:46:31 matt - * Moved texture lighting out of 3d and into the game - * - * Revision 1.23 1994/05/14 15:26:48 matt - * Added extern for polyobj outline flag - * - * Revision 1.22 1994/04/19 18:26:33 matt - * Added g3_draw_sphere() function. - * - * Revision 1.21 1994/03/25 18:22:28 matt - * g3_draw_polygon_model() now takes ptr to list of angles - * - * Revision 1.20 1994/03/15 21:23:23 matt - * Added interpreter functions - * - * Revision 1.19 1994/02/15 17:37:34 matt - * New function, g3_draw_blob() * - * Revision 1.18 1994/02/09 11:47:47 matt - * Added rod & delta point functions + * $Log: not supported by cvs2svn $ + * Revision 1.4 2001/10/31 07:41:54 bradleyb + * Sync with d1x * - * Revision 1.17 1994/01/26 12:38:11 matt - * Added function g3_compute_lighting_value() + * Revision 1.3 2001/10/25 02:06:58 bradleyb + * added prototype for g3_uninit_polygon_model * - * Revision 1.16 1994/01/25 18:00:02 yuan - * Fixed variable beam_brightness... + * Revision 1.2 2001/01/20 13:49:14 bradleyb + * Got rid of all compiler warnings, for non-OpenGL on linux, anyway... * - * Revision 1.15 1994/01/24 14:08:34 matt - * Added instancing functions + * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb + * Import of d2x-0.0.8 * - * Revision 1.14 1994/01/22 18:21:48 matt - * New lighting stuff now done in 3d; g3_draw_tmap() takes lighting parm + * Revision 1.1.1.1 1999/06/14 22:02:03 donut + * Import of d1x 1.37 source. * - * Revision 1.13 1994/01/20 17:21:24 matt - * New function g3_compute_sky_polygon() - * - * Revision 1.12 1994/01/14 17:20:25 matt - * Added prototype for new function g3_draw_horizon() - * - * Revision 1.10 1993/12/20 20:21:52 matt - * Added g3_point_2_vec() - * - * Revision 1.9 1993/12/07 23:05:47 matt - * Fixed mistyped function name. - * - * Revision 1.8 1993/12/05 23:47:03 matt - * Added function g3_draw_line_ptrs() - * - * Revision 1.7 1993/12/05 23:13:22 matt - * Added prototypes for g3_rotate_point() and g3_project_point() - * - * Revision 1.6 1993/12/05 23:03:28 matt - * Changed uvl structs to g3s_uvl - * - * Revision 1.5 1993/11/22 10:51:09 matt - * Moved uvl structure here from segment.h, made texture map functions use it - * - * Revision 1.4 1993/11/21 20:08:31 matt - * Added function g3_draw_object() - * - * Revision 1.3 1993/11/04 18:49:19 matt - * Added system to only rotate points once per frame - * - * Revision 1.2 1993/11/04 08:16:06 mike - * Add light field (p3_l) to g3s_point. + * Revision 1.2 1995/09/14 14:08:58 allender + * return value for g3_draw_sphere * - * Revision 1.1 1993/10/29 22:20:56 matt + * Revision 1.1 1995/05/05 08:48:41 allender * Initial revision * + * + * */ #ifndef _3D_H #define _3D_H #include "fix.h" -#include "vecmat.h" //the vector/matrix library +#include "vecmat.h" //the vector/matrix library #include "gr.h" -extern int g3d_interp_outline; //if on, polygon models outlined in white - -extern vms_vector Matrix_scale; //how the matrix is currently scaled - +extern int g3d_interp_outline; //if on, polygon models outlined in white +extern vms_vector Matrix_scale; extern short highest_texture_num; //Structure for storing u,v,light values. This structure doesn't have a @@ -147,36 +63,36 @@ typedef struct g3s_uvl { //Stucture to store clipping codes in a word typedef struct g3s_codes { - ubyte or,and; //or is low byte, and is high byte + ubyte or,and; //or is low byte, and is high byte } g3s_codes; //flags for point structure -#define PF_PROJECTED 1 //has been projected, so sx,sy valid -#define PF_OVERFLOW 2 //can't project -#define PF_TEMP_POINT 4 //created during clip -#define PF_UVS 8 //has uv values set -#define PF_LS 16 //has lighting values set +#define PF_PROJECTED 1 //has been projected, so sx,sy valid +#define PF_OVERFLOW 2 //can't project +#define PF_TEMP_POINT 4 //created during clip +#define PF_UVS 8 //has uv values set +#define PF_LS 16 //has lighting values set //clipping codes flags -#define CC_OFF_LEFT 1 -#define CC_OFF_RIGHT 2 -#define CC_OFF_BOT 4 -#define CC_OFF_TOP 8 -#define CC_BEHIND 0x80 +#define CC_OFF_LEFT 1 +#define CC_OFF_RIGHT 2 +#define CC_OFF_BOT 4 +#define CC_OFF_TOP 8 +#define CC_BEHIND 0x80 //Used to store rotated points for mines. Has frame count to indictate //if rotated, and flag to indicate if projected. typedef struct g3s_point { - vms_vector p3_vec; //x,y,z of rotated point + vms_vector p3_vec; //reference as vector... #ifdef D1XD3D vms_vector p3_orig; #endif - fix p3_u,p3_v,p3_l; //u,v,l coords - fix p3_sx,p3_sy; //screen x&y - ubyte p3_codes; //clipping codes - ubyte p3_flags; //projected? - short p3_pad; //keep structure longword aligned + fix p3_u,p3_v,p3_l; + fix p3_sx,p3_sy; //screen x&y + ubyte p3_codes; //clipping codes + ubyte p3_flags; //projected? + short p3_pad; //keep structure longwork aligned } g3s_point; //macros to reference x,y,z elements of a 3d point @@ -323,12 +239,33 @@ bool g3_draw_rod_flat(g3s_point *bot_point,fix bot_width,g3s_point *top_point,fi //returns 1 if off screen, 0 if drew bool g3_draw_rod_tmap(grs_bitmap *bitmap,g3s_point *bot_point,fix bot_width,g3s_point *top_point,fix top_width,fix light); -//draws a bitmap with the specified 3d width & height +//draws a bitmap with the specified 3d width & height //returns 1 if off screen, 0 if drew -bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, int orientation); +bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm,int orientation); //specifies 2d drawing routines to use instead of defaults. Passing //NULL for either or both restores defaults void g3_set_special_render(void (*tmap_drawer)(),void (*flat_drawer)(),int (*line_drawer)(fix, fix, fix, fix)); +//Object functions: + +//gives the interpreter an array of points to use +void g3_set_interp_points(g3s_point *pointlist); + +//calls the object interpreter to render an object. The object renderer +//is really a seperate pipeline. returns true if drew +bool g3_draw_polygon_model(void *model_ptr,grs_bitmap **model_bitmaps,vms_angvec *anim_angles,fix light,fix *glow_values); + +//init code for bitmap models +void g3_init_polygon_model(void *model_ptr); +//maps the colors back to RGB15 +void g3_uninit_polygon_model(void *model_ptr); + +//alternate interpreter for morphing object +bool g3_draw_morphing_model(void *model_ptr,grs_bitmap **model_bitmaps,vms_angvec *anim_angles,fix light,vms_vector *new_points); + +// routine to convert little to big endian in polygon model data +void swap_polygon_model_data(ubyte *data); + #endif + diff --git a/include/byteswap.h b/include/byteswap.h index 29bae32e..ba95c15c 100644 --- a/include/byteswap.h +++ b/include/byteswap.h @@ -1,4 +1,3 @@ -/* $Id: byteswap.h,v 1.7 2003-04-12 00:11:46 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,38 +7,26 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * code to swap bytes because of big/little endian problems. - * - * Old Log: - * Revision 1.4 1995/08/23 21:28:15 allender - * fix mcc compiler warning - * - * Revision 1.3 1995/08/18 15:51:42 allender - * put back in old byteswapping code - * - * Revision 1.2 1995/05/04 20:10:18 allender - * proper prototypes - * - * Revision 1.1 1995/03/30 15:02:11 allender - * Initial revision - * - */ + #ifndef _BYTESWAP_H #define _BYTESWAP_H #include "pstypes.h" -#define SWAPSHORT(x) (((ubyte)(x) << 8) | (((ushort)(x)) >> 8)) -#define SWAPINT(x) (((x)<<24) | (((uint)(x)) >> 24) | (((x) &0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8)) +#if 0 +extern ushort swapshort(ushort s); +extern uint swapint(uint i); +#endif -#ifndef WORDS_BIGENDIAN +#define SWAPSHORT(x) (((ubyte)x << 8) | (((ushort)x) >> 8)) +#define SWAPINT(x) ((x<<24) | (((ulong)x) >> 24) | ((x &0x0000ff00) << 8) | ((x & 0x00ff00000) >> 8)) + +#ifndef BIGENDIAN //MACINTOSH #define INTEL_INT(x) x #define INTEL_SHORT(x) x #else @@ -47,4 +34,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define INTEL_SHORT(x) SWAPSHORT(x) #endif +#define swapint(x) INTEL_INT(x) +#define swapshort(x) INTEL_SHORT(x) + #endif diff --git a/include/cfile.h b/include/cfile.h index 4346d5e1..7a7c6bfe 100644 --- a/include/cfile.h +++ b/include/cfile.h @@ -1,4 +1,3 @@ -/* $Id: cfile.h,v 1.8 2003-04-12 00:11:46 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,66 +7,20 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Prototypes for compressed file functions... - * - * Old Log: - * Revision 1.1 1995/03/30 10:25:08 allender - * Initial revision - * - * - * -- PC RCS Information --- - * Revision 1.10 1995/03/13 15:16:47 john - * Added alternate directory stuff. - * - * Revision 1.9 1995/02/01 20:56:40 john - * Added cfexist function - * - * Revision 1.8 1995/01/21 17:53:41 john - * Added alternate pig file thing. - * - * Revision 1.7 1994/12/12 13:19:47 john - * Made cfile work with fiellentth. - * - * Revision 1.6 1994/12/08 19:02:52 john - * Added cfgets. - * - * Revision 1.5 1994/12/07 21:34:07 john - * Stripped out compression stuff... - * - * Revision 1.4 1994/07/13 00:16:53 matt - * Added include - * - * Revision 1.3 1994/02/17 17:36:19 john - * Added CF_READ_MODE and CF_WRITE_MODE constants. - * - * Revision 1.2 1994/02/15 12:52:08 john - * Crappy inbetween version - * - * Revision 1.1 1994/02/15 10:54:23 john - * Initial revision - * - * Revision 1.1 1994/02/10 15:50:54 john - * Initial revision - * - * - */ + #ifndef _CFILE_H #define _CFILE_H -#include - #include "maths.h" #include "vecmat.h" typedef struct CFILE { - FILE *file; + FILE *file; int size; int lib_offset; int raw_position; @@ -76,8 +29,6 @@ typedef struct CFILE { //Specify the name of the hogfile. Returns 1 if hogfile found & had files int cfile_init(char *hogname); -int cfile_size(char *hogname); - CFILE * cfopen(char * filename, char * mode); int cfilelength( CFILE *fp ); // Returns actual size of file... size_t cfread( void * buf, size_t elsize, size_t nelem, CFILE * fp ); @@ -95,12 +46,6 @@ int cfexist( char * filename ); // Returns true if file exists on disk (1) or in // If NULL passed, returns 1 int cfile_use_alternate_hogfile( char * name ); -// Allows files to be gotten from the Descent 1 hog file. -// Passing NULL disables this. -// Returns 1 if hogfile found (& contains file), else 0. -// If NULL passed, returns 1 -int cfile_use_descent1_hogfile(char * name); - // All cfile functions will check this directory if no file exists // in the current directory. void cfile_use_alternate_hogdir( char * path ); @@ -113,12 +58,7 @@ int cfile_read_int(CFILE *file); short cfile_read_short(CFILE *file); byte cfile_read_byte(CFILE *file); fix cfile_read_fix(CFILE *file); -fixang cfile_read_fixang(CFILE *file); void cfile_read_vector(vms_vector *v, CFILE *file); void cfile_read_angvec(vms_angvec *v, CFILE *file); -void cfile_read_matrix(vms_matrix *v, CFILE *file); - -extern char AltHogDir[]; -extern char AltHogdir_initialized; #endif diff --git a/include/d1x.xpm b/include/d1x.xpm deleted file mode 100644 index ca4b262c..00000000 --- a/include/d1x.xpm +++ /dev/null @@ -1,41 +0,0 @@ -/* XPM */ -static char *pixmap[] = { -/* width height ncols cpp */ -"32 32 3 2", - /* Colors */ - "00 c #000000", - "01 c #FF0000", - ".. s None c None", - "................................................................", - "..............01................................01..............", - "..............0101............................0101..............", - "..............010101........................010101..............", - "..............01010101....................01010101..............", - "..............0101010101................0101010101..............", - "..............010101010101............010101010101..............", - "..............01010101010101........01010101010101..............", - "..............0101000101010101......01010101010001..............", - "..............010001010101010101......010101010100..............", - "..............00010101010101010101......010101010100............", - "..............0000010101010101010101......0101010000............", - "............00000000010101010100000001......0100000000..........", - "............0000..0000010101000000000001....0000..0000..........", - "................0000000000000000000000000000000000..............", - "................0000..0000000000000000000000..0000..............", - "..................0100000000000000000000000000..................", - "................0000000000000000000000000000000000..............", - "..............00000101000000000000000000000001010000............", - "............000000000101000000000000000000010100000000..........", - "..........000001000001010101....010101010101010000010000........", - "........0000010101010101010101....010101010101010101010000......", - "....00000101010101010101010101......01010101010101010101010000..", - "....0000..............................010101010101010101010000..", - "........................................010101010101010101......", - "..........................................0101010101010101......", - "............................................01010101010101......", - "..............................................010101010101......", - "................................................0101010101......", - "..................................................01010101......", - "....................................................010101......", - "................................................................", -}; diff --git a/include/d_delay.h b/include/d_delay.h new file mode 100644 index 00000000..fda286c1 --- /dev/null +++ b/include/d_delay.h @@ -0,0 +1,8 @@ +//added on 9/2/98 by Matt Mueller + +#ifndef _D_DELAY +#define _D_DELAY + +void d_delay (int ms); + +#endif diff --git a/include/descent.xpm b/include/descent.xpm deleted file mode 100644 index e1c5acf2..00000000 --- a/include/descent.xpm +++ /dev/null @@ -1,45 +0,0 @@ -/* XPM */ -static char *pixmap[] = { -/* width height ncols cpp */ -"32 32 7 2", - /* Colors */ - "00 c #000000", - "01 c #800000", - "02 c #C0C0C0", - "03 c #808080", - "04 c #FF0000", - "05 c #FFFFFF", - ".. s None c None", - "................................................................", - "................................................................", - "..........0303..........0301........0304..............03........", - "..........030303........040301....03030304........030303........", - "..........0303030303..0303030304010303030304..0303030303........", - "..........0303030303030303020303000303020303030303030303........", - "..........0303030303030303020303030303030303030303030303........", - "..........0303030303030303020303030303020303030303030303........", - "............0101000303030303030303030303030303010100............", - "..............01010303030303030303030303030303010101............", - "............0301010303030303030303030203030303010103............", - "..........03010101030303030300000003000303030301010103..........", - "........030101010101030300000000000000030303030301010103........", - "........020101010303030300000000000000000303020303010403........", - "......03010101040103030300000000000000000303..040401010103......", - "......010101030402..030300000000000000030303..050503010103......", - "....030101030304....030300030000000000030300..04040303010103....", - "....03010303..00....000303030000000000030302..04040303030103....", - "....030303..........0303030300000000030303..........03030303....", - "....030303..........0303030300000000030303............030303....", - "....0302............030303030303030303030303..........040103....", - "......04............030303030303030303030303............0103....", - "......04............030303030303030303030303............04......", - "....0401............030303030303030303030303............04......", - "....0000............0303030303030303030303..............04......", - "....................0303030303030303030303..............00......", - "......................030303030303030303........................", - "......................030303030303030303........................", - "......................0303030303030303..........................", - "................................................................", - "................................................................", - "................................................................", -}; diff --git a/include/error.h b/include/error.h index 755c2c22..ee9dab78 100644 --- a/include/error.h +++ b/include/error.h @@ -1,4 +1,3 @@ -/* $Id: error.h,v 1.9 2003-04-12 00:11:46 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,52 +7,74 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* + * $Source: /cvs/cvsroot/d2x/include/error.h,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2002-01-18 07:00:59 $ * * Header for error handling/printing/exiting code * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/11/14 10:51:04 bradleyb + * kludge to ungrab mouse when we hit an int3 + * + * Revision 1.2 2001/01/22 15:49:14 bradleyb + * fix compiler warnings w/opengl + * + * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.3 1999/10/14 04:48:21 donut + * alpha fixes, and gl_font args + * + * Revision 1.2 1999/08/05 22:53:41 sekmu + * + * D3D patch(es) from ADB + * + * Revision 1.1.1.1 1999/06/14 22:02:09 donut + * Import of d1x 1.37 source. + * * Revision 1.12 1994/06/17 15:22:46 matt * Added pragma for Error() for when NDEBUG - * + * * Revision 1.11 1994/03/07 13:22:14 matt * Since the Error() function has 'aborts' set in pragma, we do a jmp * to the function rather than call. - * + * * Revision 1.10 1994/02/17 12:37:15 matt * Combined two pragma's for Error(), since second superseded the first - * + * * Revision 1.9 1994/02/10 18:02:53 matt * Changed 'if DEBUG_ON' to 'ifndef NDEBUG' - * + * * Revision 1.8 1994/02/09 15:18:29 matt * Added pragma saying that Error() never returns - * + * * Revision 1.7 1993/10/19 12:57:53 matt * If DEBUG_ON not defined, define it to be 1 - * + * * Revision 1.6 1993/10/15 21:40:39 matt * Made error functions generate int3's if debugging on - * + * * Revision 1.5 1993/10/14 15:29:22 matt * Added new function clear_warn_func() - * + * * Revision 1.4 1993/10/08 16:16:47 matt * Made Assert() call function _Assert(), rather to do 'if...' inline. - * + * * Revision 1.3 1993/09/29 11:39:07 matt * Added Assert() macro, like the system one, but calls Error() - * + * * Revision 1.2 1993/09/27 11:47:03 matt * Added function set_warn_func() - * + * * Revision 1.1 1993/09/23 20:17:46 matt * Initial revision - * + * * */ @@ -70,7 +91,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define __format #endif -int error_init(void (*func)(char *), char *fmt,...); //init error system, set default message, returns 0=ok +int error_init(char *fmt,...); //init error system, set default message, returns 0=ok void set_exit_message(char *fmt,...); //specify message to print at exit void Warning(char *fmt,...); //print out warning message to user void set_warn_func(void (*f)(char *s));//specifies the function to call with warning messages @@ -88,7 +109,7 @@ void Int3(); #define Int3() ((void)0) #else #ifdef SDL_INPUT -#include +#include #endif #include "args.h" static inline void _Int3() diff --git a/include/gr.h b/include/gr.h index 5900fe4f..3efa29ae 100644 --- a/include/gr.h +++ b/include/gr.h @@ -1,4 +1,3 @@ -/* $Id: gr.h,v 1.19 2003-03-19 22:44:15 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -18,15 +17,12 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "pstypes.h" #include "fix.h" -#if defined(MACINTOSH) || defined(MACDATA) -#error foo -#define SWAP_0_255 // swap black and white -#define TRANSPARENCY_COLOR 0 // palette entry of transparency color -- 0 on the mac -#define TRANSPARENCY_COLOR_STR "0" +#ifdef MACINTOSH +#define SWAP_0_255 1 // swap black and white +#define TRANSPARENCY_COLOR 0 // palette entry of transparency color -- 0 on the mac #else -/* #undef SWAP_0_255 */ // no swapping for PC people -#define TRANSPARENCY_COLOR 255 // palette entry of transparency color -- 255 on the PC -#define TRANSPARENCY_COLOR_STR "255" +#define SWAP_0_255 0 // no swapping for PC people +#define TRANSPARENCY_COLOR 255 // palette entry of transparency color -- 255 on the PC #endif #define GR_FADE_LEVELS 34 @@ -41,20 +37,34 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. extern int Gr_scanline_darkening_level; typedef struct _grs_point { - fix x,y; + fix x,y; } grs_point; //these are control characters that have special meaning in the font code -#define CC_COLOR 1 //next char is new foreground color -#define CC_LSPACING 2 //next char specifies line spacing -#define CC_UNDERLINE 3 //next char is underlined +#define CC_COLOR 1 //next char is new foreground color +#define CC_LSPACING 2 //next char specifies line spacing +#define CC_UNDERLINE 3 //next char is underlined //now have string versions of these control characters (can concat inside a string) -#define CC_COLOR_S "\x1" //next char is new foreground color -#define CC_LSPACING_S "\x2" //next char specifies line spacing -#define CC_UNDERLINE_S "\x3" //next char is underlined +#define CC_COLOR_S "\x1" //next char is new foreground color +#define CC_LSPACING_S "\x2" //next char specifies line spacing +#define CC_UNDERLINE_S "\x3" //next char is underlined + +//old font structure, could not add new items to it without screwing up gr_init_font +typedef struct _grs_font { + int16_t ft_w,ft_h; // Width and height in pixels + int16_t ft_flags; // Proportional? + int16_t ft_baseline; // + ubyte ft_minchar, // The first and last chars defined by + ft_maxchar; // This font + int16_t ft_bytewidth; // Width in unsigned chars + u_int32_t ft_data; // Ptr to raw data. + u_int32_t ft_chars; // Ptrs to data for each char (required for prop font) + u_int32_t ft_widths; // Array of widths (required for prop font) + u_int32_t ft_kerndata; // Array of kerning triplet data +} __pack__ old_grs_font; #define BM_LINEAR 0 #define BM_MODEX 1 @@ -65,83 +75,84 @@ typedef struct _grs_point { #define BM_OGL 5 #endif -//@@// Define these modes for Gameplay too, since the game was developed under -//@@// DOS, we will adapt these modes to other systems thru rendering. -//@@#define SM_ORIGINAL -1 -//@@#define SM_320x200C 0 -//@@#define SM_320x200U 1 -//@@#define SM_320x240U 2 -//@@#define SM_360x200U 3 -//@@#define SM_360x240U 4 -//@@#define SM_376x282U 5 -//@@#define SM_320x400U 6 -//@@#define SM_320x480U 7 -//@@#define SM_360x400U 8 -//@@#define SM_360x480U 9 -//@@#define SM_360x360U 10 -//@@#define SM_376x308U 11 -//@@#define SM_376x564U 12 -//@@#define SM_640x400V 13 -//@@#define SM_640x480V 14 -//@@#define SM_800x600V 15 -//@@#define SM_1024x768V 16 -//@@#define SM_640x480V15 17 -//@@#define SM_800x600V15 18 - +//@@// Define these modes for Gameplay too, since the game was developed under +//@@// DOS, we will adapt these modes to other systems thru rendering. #define SM(w,h) ((((u_int32_t)w)<<16)+(((u_int32_t)h)&0xFFFF)) #define SM_W(m) (m>>16) #define SM_H(m) (m&0xFFFF) +#define SM_ORIGINAL 0 +/* +#define SM_ORIGINAL -1 +#define SM_320x200C 0 +#define SM_320x200U 1 +#define SM_320x240U 2 +#define SM_360x200U 3 +#define SM_360x240U 4 +#define SM_376x282U 5 +#define SM_320x400U 6 +#define SM_320x480U 7 +#define SM_360x400U 8 +#define SM_360x480U 9 +#define SM_360x360U 10 +#define SM_376x308U 11 +#define SM_376x564U 12 +#define SM_640x400V 13 +#define SM_640x480V 14 +#define SM_800x600V 15 +#define SM_1024x768V 16 +#define SM_640x480V15 17 +#define SM_800x600V15 18 +#define SM_1280x1024V 19 +*/ -#define BM_FLAG_TRANSPARENT 1 -#define BM_FLAG_SUPER_TRANSPARENT 2 -#define BM_FLAG_NO_LIGHTING 4 -#define BM_FLAG_RLE 8 // A run-length encoded bitmap. -#define BM_FLAG_PAGED_OUT 16 // This bitmap's data is paged out. -#define BM_FLAG_RLE_BIG 32 // for bitmaps that RLE to > 255 per row (i.e. cockpits) +#define BM_FLAG_TRANSPARENT 1 +#define BM_FLAG_SUPER_TRANSPARENT 2 +#define BM_FLAG_NO_LIGHTING 4 +#define BM_FLAG_RLE 8 // A run-length encoded bitmap. +#define BM_FLAG_PAGED_OUT 16 // This bitmap's data is paged out. +#define BM_FLAG_RLE_BIG 32 // for bitmaps that RLE to > 255 per row (i.e. cockpits) typedef struct _grs_bitmap { - short bm_x,bm_y; // Offset from parent's origin - short bm_w,bm_h; // width,height - byte bm_type; // 0=Linear, 1=ModeX, 2=SVGA - byte bm_flags; // bit 0 on means it has transparency. - // bit 1 on means it has supertransparency - // bit 2 on means it doesn't get passed through lighting. - short bm_rowsize; // unsigned char offset to next row - unsigned char * bm_data; // ptr to pixel data... - // Linear = *parent+(rowsize*y+x) - // ModeX = *parent+(rowsize*y+x/4) - // SVGA = *parent+(rowsize*y+x) - unsigned short bm_handle; //for application. initialized to 0 - ubyte avg_color; // Average color of all pixels in texture map. - byte unused; // to 4-byte align. + short bm_x,bm_y; // Offset from parent's origin + short bm_w,bm_h; // width,height + byte bm_type; // 0=Linear, 1=ModeX, 2=SVGA + byte bm_flags; // bit 0 on means it has transparency. + // bit 1 on means it has supertransparency + // bit 2 on means it doesn't get passed through lighting. + short bm_rowsize; // unsigned char offset to next row + unsigned char * bm_data; // ptr to pixel data... + // Linear = *parent+(rowsize*y+x) + // ModeX = *parent+(rowsize*y+x/4) + // SVGA = *parent+(rowsize*y+x) + unsigned short bm_handle; //for application. initialized to 0 + ubyte avg_color; // Average color of all pixels in texture map. + byte unused; // to 4-byte align. #ifdef OGL - struct _ogl_texture *gltexture; - struct _grs_bitmap *bm_parent; + struct _ogl_texture *gltexture; + struct _grs_bitmap *bm_parent; #endif + } grs_bitmap; -//font structure -typedef struct _grs_font { - short ft_w; // Width in pixels - short ft_h; // Height in pixels - short ft_flags; // Proportional? - short ft_baseline; // - ubyte ft_minchar; // First char defined by this font - ubyte ft_maxchar; // Last char defined by this font - short ft_bytewidth; // Width in unsigned chars - ubyte * ft_data; // Ptr to raw data. - ubyte ** ft_chars; // Ptrs to data for each char (required for prop font) - short * ft_widths; // Array of widths (required for prop font) - ubyte * ft_kerndata; // Array of kerning triplet data +//new font structure, which does not suffer from the inability to add new items +typedef struct _new_grs_font { + short ft_w,ft_h; // Width and height in pixels + short ft_flags; // Proportional? + short ft_baseline; // + ubyte ft_minchar, // The first and last chars defined by + ft_maxchar; // This font + short ft_bytewidth; // Width in unsigned chars + ubyte * ft_data; // Ptr to raw data. + ubyte ** ft_chars; // Ptrs to data for each char (required for prop font) + short * ft_widths; // Array of widths (required for prop font) + ubyte * ft_kerndata; // Array of kerning triplet data + old_grs_font * oldfont; #ifdef OGL - // These fields do not participate in disk i/o! grs_bitmap *ft_bitmaps; grs_bitmap ft_parent_bitmap; #endif -} __pack__ grs_font; - -#define GRS_FONT_SIZE 28 // how much space it takes up on disk +} grs_font; typedef struct _grs_canvas { grs_bitmap cv_bitmap; // the bitmap for this canvas @@ -156,11 +167,11 @@ typedef struct _grs_canvas { #define cv_w cv_bitmap.bm_w #define cv_h cv_bitmap.bm_h -typedef struct _grs_screen { // This is a video screen - grs_canvas sc_canvas; // Represents the entire screen - int sc_mode; // Video mode number - short sc_w, sc_h; // Actual Width and Height - fix sc_aspect; //aspect ratio (w/h) for this screen +typedef struct _grs_screen { // This is a video screen + grs_canvas sc_canvas; // Represents the entire screen + int sc_mode; // Video mode number + short sc_w, sc_h; // Actual Width and Height + fix sc_aspect; //aspect ratio (w/h) for this screen } grs_screen; @@ -190,7 +201,7 @@ extern void gr_pal_getblock( int start, int number, unsigned char * pal ); extern unsigned char *gr_video_memory; - // All graphic modules will define this value. + // All graphic modules will define this value. //shut down the 2d. Restore the screen mode. void gr_close(void); @@ -253,10 +264,6 @@ grs_bitmap *gr_create_sub_bitmap(grs_bitmap *bm,int x,int y,int w, int h); // Free the bitmap and its pixel data void gr_free_bitmap(grs_bitmap *bm); -// Free the bitmap's data -void gr_free_bitmap_data (grs_bitmap *bm); -void gr_init_bitmap_data (grs_bitmap *bm); - // Free the bitmap, but not the pixel data buffer void gr_free_sub_bitmap(grs_bitmap *bm); @@ -265,7 +272,7 @@ void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color ); void gr_bm_ubitblt( int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest); void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest); -#ifndef __MSDOS__ +#ifdef MACINTOSH void gr_bm_ubitblt_double(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap *src, grs_bitmap *dest); void gr_linear_movsd_double(ubyte *src, ubyte *dest, int num_pixels); #endif @@ -320,9 +327,6 @@ int gr_uaaline(fix x0,fix y0,fix x1,fix y1); // Draw the bitmap into the current canvas at the specified location. void gr_bitmap(int x,int y,grs_bitmap *bm); void gr_ubitmap(int x,int y,grs_bitmap *bm); -void gr_bitmap_scale_to(grs_bitmap *src, grs_bitmap *dst); -void show_fullscr(grs_bitmap *bm); - // bitmap function with transparency void gr_bitmapm( int x, int y, grs_bitmap *bm ); void gr_ubitmapm( int x, int y, grs_bitmap *bm ); @@ -352,7 +356,7 @@ grs_font * gr_init_font( char * fontfile ); void gr_close_font( grs_font * font ); //remap a font, re-reading its data & palette -void gr_remap_font( grs_font *font, char * fontname, char *font_data ); +void gr_remap_font( grs_font *font, char * fontname ); //remap (by re-reading) all the color fonts void gr_remap_color_fonts(); @@ -367,7 +371,7 @@ int gr_uprintf( int x, int y, char * format, ... ); void gr_get_string_size(char *s, int *string_width, int *string_height, int *average_width ); -// From roller.c +// From roller.c void rotate_bitmap(grs_bitmap *bp, grs_point *vertbuf, int light_value); // From scale.c @@ -388,9 +392,9 @@ extern void gr_show_canvas( grs_canvas *canv ); extern void gr_set_current_canvas( grs_canvas *canv ); //flags for fonts -#define FT_COLOR 1 -#define FT_PROPORTIONAL 2 -#define FT_KERNED 4 +#define FT_COLOR 1 +#define FT_PROPORTIONAL 2 +#define FT_KERNED 4 extern void gr_vesa_update( grs_bitmap * source1, grs_bitmap * dest, grs_bitmap * source2 ); @@ -408,10 +412,10 @@ extern ushort gr_palette_selector; extern ushort gr_inverse_table_selector; extern ushort gr_fade_table_selector; -// Remaps a bitmap into the current palette. If transparent_color is -// between 0 and 255 then all occurances of that color are mapped to -// whatever color the 2d uses for transparency. This is normally used -// right after a call to iff_read_bitmap like this: +// Remaps a bitmap into the current palette. If transparent_color is between 0 and 255 +// then all occurances of that color are mapped to whatever color the 2d uses for +// transparency. This is normally used right after a call to iff_read_bitmap like +// this: // iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal); // if (iff_error != IFF_NO_ERROR) Error("Can't load IFF file <%s>, error=%d",filename,iff_error); // if ( iff_has_transparency ) @@ -420,12 +424,10 @@ extern ushort gr_fade_table_selector; // gr_remap_bitmap( new, newpal, -1 ); extern void gr_remap_bitmap( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color ); -// Same as above, but searches using gr_find_closest_color which uses -// 18-bit accurracy instead of 15bit when translating colors. +// Same as above, but searches using gr_find_closest_color which uses 18-bit accurracy +// instaed of 15bit when translating colors. extern void gr_remap_bitmap_good( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color ); -extern void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq ); - extern void gr_palette_step_up( int r, int g, int b ); extern void gr_bitmap_check_transparency( grs_bitmap * bmp ); @@ -480,6 +482,4 @@ int gr_toggle_fullscreen(void); #endif -int gr_toggle_fullscreen_menu(void);//returns state after toggling (ie, same as if you had called check_fullscreen immediatly after) - #endif diff --git a/include/grdef.h b/include/grdef.h index 6ffdaf73..9a36c0c3 100644 --- a/include/grdef.h +++ b/include/grdef.h @@ -1,4 +1,3 @@ -/* $Id: grdef.h,v 1.8 2002-09-05 01:30:00 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,15 +7,27 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* + * $Source: /cvs/cvsroot/d2x/include/grdef.h,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-11-14 10:31:40 $ * * Internal definitions for graphics lib. * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.2 2001/01/19 03:34:09 bradleyb + * Import of d2x-0.0.9-pre1 + * + * Revision 1.2 1999/11/20 10:05:16 donut + * variable size menu patch from Jan Bobrowski. Variable menu font size support and a bunch of fixes for menus that didn't work quite right, by me (MPM). + * + * Revision 1.1.1.1 1999/06/14 22:02:14 donut + * Import of d1x 1.37 source. + * * Revision 1.5 1995/09/14 15:36:33 allender * added stuff for 68k version * @@ -36,31 +47,36 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. * --- PC RCS information --- * Revision 1.8 1994/05/06 12:50:09 john * Added supertransparency; neatend things up; took out warnings. - * + * * Revision 1.7 1994/01/25 11:40:29 john * Added gr_check_mode function. - * + * * Revision 1.6 1993/10/15 16:22:53 john * y - * + * * Revision 1.5 1993/09/29 17:31:00 john * added gr_vesa_pixel - * + * * Revision 1.4 1993/09/29 16:14:43 john * added global canvas descriptors. - * + * * Revision 1.3 1993/09/08 17:38:02 john * Looking for errors - * + * * Revision 1.2 1993/09/08 15:54:29 john * *** empty log message *** - * + * * Revision 1.1 1993/09/08 11:37:57 john * Initial revision + * * */ - +#define USE_2D_ASM 1 + void gr_init_bitmap_alloc( grs_bitmap *bm, int mode, int x, int y, int w, int h, int bytesperline); +void show_fullscr(grs_bitmap *bm); +void gr_init_bitmap_data (grs_bitmap *bm); +void gr_free_bitmap_data (grs_bitmap *bm); void gr_init_sub_bitmap (grs_bitmap *bm, grs_bitmap *bmParent, int x, int y, int w, int h ); void gr_init_bitmap( grs_bitmap *bm, int mode, int x, int y, int w, int h, int bytesperline, unsigned char * data ); @@ -72,19 +88,22 @@ extern void gr_pal_setone( int index, unsigned char red, unsigned char green, un void gr_linear_movsb( ubyte * source, ubyte * dest, int nbytes); void gr_linear_movsw( ubyte * source, ubyte * dest, int nbytes); +#if ( defined(__MWERKS__) && defined(__MC68K__) && defined(USE_2D_ASM) ) +void gr_linear_movsd(ubyte * src:__A0, ubyte * dest:__A1, uint num_pixels:__D0 ); +#else +void gr_linear_movsd( ubyte * source, ubyte * dest, unsigned int nbytes); +#endif +void gr_linear_rep_movsd_2x( ubyte * source, ubyte * dest, uint nbytes); void gr_linear_stosd( ubyte * dest, unsigned char color, unsigned int nbytes); - extern unsigned int gr_var_color; extern unsigned int gr_var_bwidth; extern unsigned char * gr_var_bitmap; -void gr_linear_movsd( ubyte * source, ubyte * dest, unsigned int nbytes); - void gr_linear_line( int x0, int y0, int x1, int y1); extern unsigned int Table8to32[256]; -#ifdef __MSDOS__ +#ifdef __DJGPP__ extern unsigned char * gr_video_memory; #endif diff --git a/include/ibitblt.h b/include/ibitblt.h index cc7945d5..c1c068ac 100644 --- a/include/ibitblt.h +++ b/include/ibitblt.h @@ -1,4 +1,3 @@ -/* $Id: ibitblt.h,v 1.2 2002-09-04 22:27:54 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,53 +7,54 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * + * $Source: /cvs/cvsroot/d2x/include/ibitblt.h,v $ + * $Revision: 1.1.1.1 $ + * $Author: bradleyb $ + * $Date: 2001-01-19 03:30:16 $ + * * Prototypes for the ibitblt functions. - * - * Old Log: - * Revision 1.1 1995/08/18 15:50:57 allender - * Initial revision + * + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 1999/06/14 22:02:14 donut + * Import of d1x 1.37 source. * * Revision 1.2 1994/05/31 11:10:56 john * *** empty log message *** - * + * * Revision 1.1 1994/05/30 16:08:46 john * Initial revision - * + * + * */ + + #ifndef _IBITBLT_H #define _IBITBLT_H // Finds location/size of the largest "hole" in bitmap mask_bmp -void gr_ibitblt_find_hole_size ( grs_bitmap * mask_bmp, int *minx, int *miny, int *maxx, int *maxy ); +void gr_ibitblt_find_hole_size ( grs_bitmap * mask_bmp, int *minx, int *miny, int *maxx, int *maxy ); -// Creates a code mask that will copy data from a bitmap that is sw by -// sh starting from location sx, sy with a rowsize of srowsize onto -// another bitmap but only copies into pixel locations that are -// defined as transparent in bitmap bmp. - -#ifdef __MSDOS__ -ubyte * gr_ibitblt_create_mask(grs_bitmap *mask_bmp, int sx, int sy, int sw, int sh, int srowsize); -ubyte * gr_ibitblt_create_mask_svga(grs_bitmap *mask_bmp, int sx, int sy, int sw, int sh, int srowsize); -ubyte * gr_ibitblt_create_mask_pa( grs_bitmap *mask_bmp, int sx, int sy, int sw, int sh, int srowsize); +// Creates a code mask that will copy data from a bitmap that is sw by sh starting from +// location sx, sy with a rowsize of srowsize onto another bitmap but only copies +// into pixel locations that are defined as transparent in bitmap bmp. +#ifdef PCCODE +ubyte * gr_ibitblt_create_mask ( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize ); #else -void gr_ibitblt_create_mask_pa(grs_bitmap *mask_bmp, int sx, int sy, int sw, int sh, int srowsize); -void gr_ibitblt_create_mask(grs_bitmap *mask_bmp, int sx, int sy, int sw, int sh, int srowsize); +void gr_ibitblt_create_mask ( grs_bitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowsize ); #endif -// Copy source bitmap onto destination bitmap, not copying pixels that -// are defined transparent by the mask - -#ifdef __MSDOS__ -void gr_ibitblt(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, ubyte *mask); +// Copy source bitmap onto destination bitmap, not copying pixels that are defined +// transparent by the mask +#ifdef PCCODE +void gr_ibitblt (grs_bitmap * source_bmp, grs_bitmap * dest_bmp, ubyte * mask ); #else -void gr_ibitblt(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, ubyte pixel_double); +void gr_ibitblt(grs_bitmap *src_bmp, grs_bitmap *dest_bmp, ubyte pixel_double); #endif #endif + diff --git a/include/iff.h b/include/iff.h index 11fa2fae..9624fca0 100644 --- a/include/iff.h +++ b/include/iff.h @@ -1,4 +1,3 @@ -/* $Id: iff.h,v 1.2 2002-10-04 07:19:59 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -56,19 +55,19 @@ char *iff_errormsg(int error_number); //Error codes for read & write routines -#define IFF_NO_ERROR 0 //everything is fine, have a nice day -#define IFF_NO_MEM 1 //not enough mem for loading or processing -#define IFF_UNKNOWN_FORM 2 //IFF file, but not a bitmap -#define IFF_NOT_IFF 3 //this isn't even an IFF file -#define IFF_NO_FILE 4 //cannot find or open file -#define IFF_BAD_BM_TYPE 5 //tried to save invalid type, like BM_RGB15 -#define IFF_CORRUPT 6 //bad data in file -#define IFF_FORM_ANIM 7 //this is an anim, with non-anim load rtn -#define IFF_FORM_BITMAP 8 //this is not an anim, with anim load rtn -#define IFF_TOO_MANY_BMS 9 //anim read had more bitmaps than room for -#define IFF_UNKNOWN_MASK 10 //unknown masking type -#define IFF_READ_ERROR 11 //error reading from file -#define IFF_BM_MISMATCH 12 //bm being loaded doesn't match bm loaded into +#define IFF_NO_ERROR 0 //everything is fine, have a nice day +#define IFF_NO_MEM 1 //not enough mem for loading or processing +#define IFF_UNKNOWN_FORM 2 //IFF file, but not a bitmap +#define IFF_NOT_IFF 3 //this isn't even an IFF file +#define IFF_NO_FILE 4 //cannot find or open file +#define IFF_BAD_BM_TYPE 5 //tried to save invalid type, like BM_RGB15 +#define IFF_CORRUPT 6 //bad data in file +#define IFF_FORM_ANIM 7 //this is an anim, with non-anim load rtn +#define IFF_FORM_BITMAP 8 //this is not an anim, with anim load rtn +#define IFF_TOO_MANY_BMS 9 //anim read had more bitmaps than room for +#define IFF_UNKNOWN_MASK 10 //unknown masking type +#define IFF_READ_ERROR 11 //error reading from file +#define IFF_BM_MISMATCH 12 //bm being loaded doesn't match bm loaded into #endif diff --git a/include/interp.h b/include/interp.h deleted file mode 100644 index 6787bf78..00000000 --- a/include/interp.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $Id: interp.h,v 1.6 2003-02-13 22:07:58 btb Exp $ */ -/* - * - * took out functions declarations from include/3d.h - * which are implemented in 3d/interp.c - * - */ - -#ifndef _INTERP_H -#define _INTERP_H - -#include "fix.h" -//#include "vecmat.h" //the vector/matrix library -#include "gr.h" -#include "cfile.h" -#include "3d.h" - -//Object functions: - -//gives the interpreter an array of points to use -void g3_set_interp_points(g3s_point *pointlist); - -//calls the object interpreter to render an object. The object renderer -//is really a seperate pipeline. returns true if drew -bool g3_draw_polygon_model(void *model_ptr,grs_bitmap **model_bitmaps,vms_angvec *anim_angles,fix light,fix *glow_values); - -//init code for bitmap models -void g3_init_polygon_model(void *model_ptr); - -//un-initialize, i.e., convert color entries back to RGB15 -void g3_uninit_polygon_model(void *model_ptr); - -//alternate interpreter for morphing object -bool g3_draw_morphing_model(void *model_ptr,grs_bitmap **model_bitmaps,vms_angvec *anim_angles,fix light,vms_vector *new_points); - -//this remaps the 15bpp colors for the models into a new palette. It should -//be called whenever the palette changes -void g3_remap_interp_colors(void); - -#ifdef WORDS_BIGENDIAN -// routine to convert little to big endian in polygon model data -void swap_polygon_model_data(ubyte *data); -//routines to convert little to big endian in vectors -void vms_vector_swap(vms_vector *v); -void vms_angvec_swap(vms_angvec *v); -#endif - -#ifdef WORDS_NEED_ALIGNMENT -/* - * A chunk struct (as used for alignment) contains all relevant data - * concerning a piece of data that may need to be aligned. - * To align it, we need to copy it to an aligned position, - * and update all pointers to it. - * (Those pointers are actually offsets - * relative to start of model_data) to it. - */ -typedef struct chunk { - ubyte *old_base; // where the offset sets off from (relative to beginning of model_data) - ubyte *new_base; // where the base is in the aligned structure - short offset; // how much to add to base to get the address of the offset - short correction; // how much the value of the offset must be shifted for alignment -} chunk; -#define MAX_CHUNKS 100 // increase if insufficent -/* - * finds what chunks the data points to, adds them to the chunk_list, - * and returns the length of the current chunk - */ -int get_chunks(ubyte *data, ubyte *new_data, chunk *list, int *no); -#endif //def WORDS_NEED_ALIGNMENT - -#endif //_INTERP_H diff --git a/include/ipx.h b/include/ipx.h index a2056187..44b65d2a 100644 --- a/include/ipx.h +++ b/include/ipx.h @@ -1,4 +1,3 @@ -/* $Id: ipx.h,v 1.5 2002-08-29 09:03:36 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,90 +7,100 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* - * + * $Source: /cvs/cvsroot/d2x/include/ipx.h,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 00:31:51 $ + * * Prototype for IPX communications. + * + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 22:02:16 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 2.6 1995/03/29 11:19:32 john * Added broadcasting over a net. - * + * * Revision 2.5 1995/03/28 20:04:43 john * Took away alternate server stuff. - * + * * Revision 2.4 1995/03/23 19:00:10 john * Added user list capabitly. - * + * * Revision 2.3 1995/03/23 12:26:57 john * Move IPX into bios lib. - * + * * Revision 2.2 1995/03/22 19:08:14 john * Added code to fix sending packets over router... now * we just need to make broadcasts go over router!! - * + * * Revision 2.1 1995/03/21 08:39:56 john * Ifdef'd out the NETWORK code. - * + * * Revision 2.0 1995/02/27 11:30:16 john * New version 2.0, which has no anonymous unions, builds with * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * + * * Revision 1.16 1995/02/16 17:34:52 john * Added code to allow dynamic socket changing. - * + * * Revision 1.15 1995/01/04 21:43:27 rob * Remove SPX size definition. - * + * * Revision 1.14 1995/01/03 13:46:18 john * Added code that should make ipx work over different servers, * but ifdef'd it out with SHAREWARE in ipx.c. I haven't tested * this, and I hope it doesn't introduce net bugs. - * + * * Revision 1.13 1994/11/02 11:37:16 rob * Changed default socket number to a higher regions. - * + * * Revision 1.12 1994/11/01 15:56:51 rob * Added defines for SPX socketsx. - * + * * Revision 1.11 1994/10/31 19:23:31 rob * Added a prototype for the new object send function. - * + * * Revision 1.10 1994/09/07 13:37:25 john - * Changed default socket to 0x4000, because + * Changed default socket to 0x4000, because * the ipx/spx book says that we can only use * sockets 0x4000 - 0x7fff. - * + * * Revision 1.9 1994/08/25 18:14:45 matt * Changed socket because of packet change - * + * * Revision 1.8 1994/08/12 22:42:24 john * Took away Player_stats; added Players array. - * + * * Revision 1.7 1994/08/09 19:31:47 john * Networking changes. - * + * * Revision 1.6 1994/08/05 16:11:46 john * Psuedo working version of networking. - * + * * Revision 1.5 1994/08/04 19:17:20 john * Inbetween version of network stuff. - * + * * Revision 1.4 1994/07/29 16:08:59 john * *** empty log message *** - * + * * Revision 1.3 1994/07/25 12:33:22 john * Network "pinging" in. - * + * * Revision 1.2 1994/07/20 15:58:29 john * First installment of ipx stuff. - * + * * Revision 1.1 1994/07/19 15:43:05 john * Initial revision - * - * + * + * */ #ifndef _IPX_H @@ -105,7 +114,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif //--------------------------------------------------------------- -// Initializes all IPX internals. +// Initializes all IPX internals. // If socket_number==0, then opens next available socket. // Returns: 0 if successful. // -1 if socket already open. @@ -113,7 +122,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. // -3 if IPX not installed. // -4 if couldn't allocate low dos memory // -5 if error with getting internetwork address -extern int ipx_init( int socket_number, int show_address ); +extern int ipx_init( int socket_number); extern int ipx_change_default_socket( ushort socket_number ); @@ -142,3 +151,5 @@ extern void ipx_read_user_file(char * filename); extern void ipx_read_network_file(char * filename); #endif + + diff --git a/include/ipx_drv.h b/include/ipx_drv.h new file mode 100644 index 00000000..9db4ab6b --- /dev/null +++ b/include/ipx_drv.h @@ -0,0 +1,89 @@ +/* + * IPX driver interface + * + * parts from: + * ipx.h header file for IPX for the DOS emulator + * Tim Bird, tbird@novell.com + */ +#ifndef _IPX_DRV_H +#define _IPX_DRV_H +#define IPX_MANUAL_ADDRESS + +#include "pstypes.h" + +#if defined(__WINDOWS__) || defined(__MINGW32__) +#include +#else +#include /* for htons & co. */ +#endif + +#define MAX_PACKET_DATA 1500 + +#ifdef _MSC_VER +#pragma pack (push, 1) +#endif + +typedef struct IPXAddressStruct { + ubyte Network[4] __pack__; + ubyte Node[6] __pack__; + ubyte Socket[2] __pack__; +} IPXAddress_t; + +typedef struct IPXPacketStructure { + ushort Checksum __pack__; + ushort Length __pack__; + ubyte TransportControl __pack__; + ubyte PacketType __pack__; + IPXAddress_t Destination __pack__; + IPXAddress_t Source __pack__; +} IPXPacket_t; + +#ifdef _MSC_VER +#pragma pack (pop) +#endif + +typedef struct ipx_socket_struct { + ushort socket; + int fd; +} ipx_socket_t; + +struct ipx_recv_data { + /* all network order */ + ubyte src_network[4]; + ubyte src_node[6]; + ushort src_socket; + ushort dst_socket; + int pkt_type; +}; + +struct ipx_driver { +// int (*GetMyAddress)(void); + int (*OpenSocket)(int port); + void (*CloseSocket)(void); + int (*SendPacket)(IPXPacket_t *IPXHeader, + ubyte *data, int dataLen); + int (*ReceivePacket)(char *buffer, int bufsize, + struct ipx_recv_data *rec); + int (*PacketReady)(void); + int (*CheckReadyToJoin)(unsigned char *server, unsigned char *node); + int usepacketnum;//we can save 4 bytes + void (*GetLocalTarget) ( ubyte * server, ubyte * node, ubyte * local_target ); + int (*GetPacketData) ( ubyte * data ); + void (*SendPacketData) ( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ); +}; + +int ipx_general_PacketReady(int fd); + +extern unsigned char ipx_MyAddress[10]; + +extern ubyte broadcast_addr[]; +extern ubyte null_addr[]; +extern u_int32_t ipx_network; + +struct ipx_driver * arch_ipx_set_driver(char *arg); + +#ifdef SUPPORTS_NET_IP +extern struct ipx_driver ipx_ip; +#endif + +#endif /* _IPX_DRV_H */ diff --git a/include/libmve.h b/include/libmve.h deleted file mode 100644 index 74b055d8..00000000 --- a/include/libmve.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _LIBMVE_H -#define _LIBMVE_H - -#define MVE_ERR_EOF 1 - -int MVE_rmPrepMovie(int filehandle, int x, int y, int track); -int MVE_rmStepMovie(); -void MVE_rmHoldMovie(); -void MVE_rmEndMovie(); - -void MVE_sndInit(int x); - -#endif /* _LIBMVE_H */ diff --git a/include/loadgl.h b/include/loadgl.h index a4a3f18f..c725743e 100644 --- a/include/loadgl.h +++ b/include/loadgl.h @@ -1,8 +1,12 @@ -/* $ Id: $ */ /* + * $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 $ * */ @@ -1177,7 +1181,7 @@ void *dll_GetSymbol(void *dllhandle,const char *symname) return (void *)GetProcAddress((HINSTANCE)dllhandle,symname); } #endif -#ifdef __unix__ +#ifdef __linux__ #include void *dll_LoadModule(const char *name) { diff --git a/include/maths.h b/include/maths.h index a5b614a5..9d641069 100644 --- a/include/maths.h +++ b/include/maths.h @@ -21,12 +21,12 @@ int d_rand (); // Random number function which returns in the range 0-0x7FFF typedef int32_t fix; //16 bits int, 16 bits frac typedef int16_t fixang; //angles -typedef struct quadint // integer 64 bit, previously called "quad" +typedef struct quad { u_int32_t low; int32_t high; } -quadint; +quad; //Convert an int to a fix @@ -162,22 +162,22 @@ fixmuldiv (fix a, fix b, fix c) #endif -//multiply two fixes, and add 64-bit product to a quadint -void fixmulaccum (quadint * q, fix a, fix b); +//multiply two fixes, and add 64-bit product to a quad +void fixmulaccum (quad * q, fix a, fix b); -//extract a fix from a quadint product -fix fixquadadjust (quadint * q); +//extract a fix from a quad product +fix fixquadadjust (quad * q); -//divide a quadint by a long +//divide a quad by a long int32_t fixdivquadlong (u_int32_t qlow, u_int32_t qhigh, u_int32_t d); -//negate a quadint -void fixquadnegate (quadint * q); +//negate a quad +void fixquadnegate (quad * q); //computes the square root of a long, returning a short ushort long_sqrt (int32_t a); -//computes the square root of a quadint, returning a long +//computes the square root of a quad, returning a long u_int32_t quad_sqrt (u_int32_t low, int32_t high); //ulong quad_sqrt (long low, long high); diff --git a/include/ogl_init.h b/include/ogl_init.h index 393571fc..c4a2df64 100644 --- a/include/ogl_init.h +++ b/include/ogl_init.h @@ -15,11 +15,7 @@ #include "loadgl.h" int ogl_init_load_library(void); #else -#if defined(__APPLE__) && defined(__MACH__) -#include -#else #include -#endif //######hack, since multi texture support is not working #undef GL_ARB_multitexture #undef GL_SGIS_multitexture @@ -37,11 +33,11 @@ int ogl_init_load_library(void); #include "palette.h" #include "pstypes.h" -/* I assume this ought to be >= MAX_BITMAP_FILES in piggy.h? */ -#define OGL_TEXTURE_LIST_SIZE 3000 + +#define OGL_TEXTURE_LIST_SIZE 2000 typedef struct _ogl_texture { - GLuint handle; + int handle; GLint internalformat; GLenum format; int w,h,tw,th,lw; diff --git a/include/palette.h b/include/palette.h index f1f8e664..9af0aa26 100644 --- a/include/palette.h +++ b/include/palette.h @@ -1,4 +1,3 @@ -/* $Id: palette.h,v 1.3 2002-10-11 03:37:58 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,60 +7,65 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* - * + * $Source: /cvs/cvsroot/d2x/include/palette.h,v $ + * $Revision: 1.1.1.1 $ + * $Author: bradleyb $ + * $Date: 2001-01-19 03:30:16 $ + * * Protoypes for palette functions + * + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 1999/06/14 22:02:19 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.11 1994/11/15 17:55:10 john * Made text palette fade in when game over. - * + * * Revision 1.10 1994/11/07 13:53:42 john * Added better gamma stufff. - * + * * Revision 1.9 1994/11/07 13:38:03 john * Added gamma correction stuff. - * + * * Revision 1.8 1994/11/05 13:05:59 john * Added back in code to allow keys during fade. - * + * * Revision 1.7 1994/11/05 12:46:37 john * Changed palette stuff a bit. - * + * * Revision 1.6 1994/09/22 16:08:37 john * Fixed some palette stuff. - * + * * Revision 1.5 1994/08/09 11:27:04 john * Add cthru stuff. - * + * * Revision 1.4 1994/06/09 10:39:33 john * In fade out.in functions, returned 1 if key was pressed... - * + * * Revision 1.3 1994/05/31 19:04:24 john * Added key to stop fade if desired. - * + * * Revision 1.2 1994/05/06 12:50:42 john * Added supertransparency; neatend things up; took out warnings. - * + * * Revision 1.1 1994/05/04 14:59:57 john * Initial revision - * - * + * + * */ + #ifndef _PALETTE_H #define _PALETTE_H -#define DEFAULT_LEVEL_PALETTE "groupa.256" //don't confuse with DEFAULT_PALETTE - extern void gr_palette_set_gamma( int gamma ); extern int gr_palette_get_gamma(); extern ubyte gr_palette_faded_out; -extern int grd_fades_disabled; extern void gr_palette_clear(); extern int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys ); extern int gr_palette_fade_in(ubyte *pal,int nsteps, int allow_keys ); @@ -71,6 +75,8 @@ extern int gr_find_closest_color_current( int r, int g, int b ); extern void gr_palette_read(ubyte * palette); extern void init_computed_colors(void); + + extern ubyte gr_palette_gamma; extern ubyte gr_current_pal[256*3]; diff --git a/include/pcx.h b/include/pcx.h index 06811d42..4679bc6f 100644 --- a/include/pcx.h +++ b/include/pcx.h @@ -1,4 +1,3 @@ -/* $Id: pcx.h,v 1.3 2002-08-26 06:41:53 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,48 +7,57 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* - * + * $Source: /cvs/cvsroot/d2x/include/pcx.h,v $ + * $Revision: 1.1.1.1 $ + * $Author: bradleyb $ + * $Date: 2001-01-19 03:30:16 $ + * * Routines to read/write pcx images. + * + * $Log: not supported by cvs2svn $ + * Revision 1.2 1999/11/20 10:05:16 donut + * variable size menu patch from Jan Bobrowski. Variable menu font size support and a bunch of fixes for menus that didn't work quite right, by me (MPM). + * + * Revision 1.1.1.1 1999/06/14 22:02:19 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.4 1995/01/21 17:07:34 john * Added out of memory error. - * + * * Revision 1.3 1994/11/29 02:53:10 john * Added error messages; made call be more similiar to iff. - * + * * Revision 1.2 1994/11/28 20:03:48 john * Added PCX functions. - * + * * Revision 1.1 1994/11/28 19:57:45 john * Initial revision - * - * + * + * */ + #ifndef _PCX_H #define _PCX_H -#define PCX_ERROR_NONE 0 -#define PCX_ERROR_OPENING 1 -#define PCX_ERROR_NO_HEADER 2 -#define PCX_ERROR_WRONG_VERSION 3 -#define PCX_ERROR_READING 4 -#define PCX_ERROR_NO_PALETTE 5 -#define PCX_ERROR_WRITING 6 -#define PCX_ERROR_MEMORY 7 +#define PCX_ERROR_NONE 0 +#define PCX_ERROR_OPENING 1 +#define PCX_ERROR_NO_HEADER 2 +#define PCX_ERROR_WRONG_VERSION 3 +#define PCX_ERROR_READING 4 +#define PCX_ERROR_NO_PALETTE 5 +#define PCX_ERROR_WRITING 6 +#define PCX_ERROR_MEMORY 7 -// Reads filename into bitmap bmp, and fills in palette. If bmp->bm_data==NULL, -// then bmp->bm_data is allocated and the w,h are filled. +// Reads filename into bitmap bmp, and fills in palette. If bmp->bm_data==NULL, +// then bmp->bm_data is allocated and the w,h are filled. // If palette==NULL the palette isn't read in. Returns error code. -extern int pcx_get_dimensions( char *filename, int *width, int *height); - extern int pcx_read_bitmap( char * filename, grs_bitmap * bmp, int bitmap_type, ubyte * palette ); // Writes the bitmap bmp to filename, using palette. Returns error code. @@ -58,10 +66,7 @@ extern int pcx_write_bitmap( char * filename, grs_bitmap * bmp, ubyte * palette extern char *pcx_errormsg(int error_number); -#ifdef MACINTOSH -extern int pcx_read_bitmap_palette( char *filename, ubyte *palette); -#endif - int pcx_read_fullscr(char * filename, ubyte * palette); #endif + diff --git a/include/pstypes.h b/include/pstypes.h index 4b8a6caf..d8b6eb58 100644 --- a/include/pstypes.h +++ b/include/pstypes.h @@ -1,4 +1,3 @@ -/* $Id: pstypes.h,v 1.19 2003-04-11 23:51:48 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -18,12 +17,12 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. // define a dboolean typedef int dboolean; -//define a byte +//define a byte typedef signed char byte; //define unsigned types; typedef unsigned char ubyte; -#ifndef __unix__ +#ifndef __linux__ typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; @@ -40,20 +39,11 @@ typedef unsigned long ulong; #include typedef uint64_t u_int64_t; typedef uint32_t u_int32_t; -typedef uint16_t u_int16_t; -#elif defined __unix__ +#elif defined __linux__ # include # define _MAX_PATH 1024 # define _MAX_DIR 256 -# if defined(__APPLE__) && defined(__MACH__) -typedef unsigned long ulong; -# endif -# ifdef __sun__ -typedef uint64_t u_int64_t; -typedef uint32_t u_int32_t; -typedef uint16_t u_int16_t; -# endif #elif defined __DJGPP__ # include @@ -66,22 +56,18 @@ typedef unsigned short u_int16_t; #endif -#ifndef __cplusplus //define a boolean typedef ubyte bool; -#endif #ifndef NULL #define NULL 0 #endif -// the following stuff has nothing to do with types but needed everywhere, -// and since this file is included everywhere, it's here. #ifdef __GNUC__ -# define __pack__ __attribute__((packed)) +#define __pack__ __attribute__((packed)) #else -# define __pack__ +#define __pack__ #endif -#endif //_TYPES_H +#endif diff --git a/include/rle.h b/include/rle.h index 5d517580..3bc9212a 100644 --- a/include/rle.h +++ b/include/rle.h @@ -7,43 +7,48 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* - * + * $Source: /cvs/cvsroot/d2x/include/rle.h,v $ + * $Revision: 1.1.1.1 $ + * $Author: bradleyb $ + * $Date: 2001-01-19 03:30:16 $ + * * Protypes for rle functions. + * + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 1999/06/14 22:02:19 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.5 1995/01/14 11:32:20 john * Added rle_cache_flush function. - * + * * Revision 1.4 1994/11/10 13:16:01 matt * Added includes - * + * * Revision 1.3 1994/11/09 19:53:51 john * Added texture rle caching. - * + * * Revision 1.2 1994/11/09 16:35:18 john * First version with working RLE bitmaps. - * + * * Revision 1.1 1994/11/09 12:40:17 john * Initial revision - * - * + * + * */ + + #ifndef _RLE_H #define _RLE_H #include "pstypes.h" #include "gr.h" -#if 0 -void gr_rle_decode( ubyte * src, ubyte * dest, int dest_len ); -#else void gr_rle_decode( ubyte * src, ubyte * dest ); -#endif int gr_rle_encode( int org_size, ubyte *src, ubyte *dest ); int gr_rle_getsize( int org_size, ubyte *src ); ubyte * gr_rle_find_xth_pixel( ubyte *src, int x,int * count, ubyte color ); @@ -55,8 +60,5 @@ grs_bitmap * rle_expand_texture( grs_bitmap * bmp ); void rle_cache_flush(); -void rle_swap_0_255(grs_bitmap *bmp); - -void rle_remap(grs_bitmap *bmp, ubyte *colormap); - #endif + diff --git a/include/strutil.h b/include/strutil.h index 1cd64b07..6047dfc1 100644 --- a/include/strutil.h +++ b/include/strutil.h @@ -1,4 +1,3 @@ -/* $ Id: $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -15,8 +14,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #ifndef _STRUTILS_H #define _STRUTILS_H -#ifdef __unix__ -#include +char *d_strdup(char *str); + +#ifdef __linux__ #define stricmp(a,b) strcasecmp(a,b) #define strnicmp(a,b,c) strncasecmp(a,b,c) #elif 0 diff --git a/include/texmap.h b/include/texmap.h index ce74614c..26f518ee 100644 --- a/include/texmap.h +++ b/include/texmap.h @@ -12,16 +12,13 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * $Source: /cvs/cvsroot/d2x/include/texmap.h,v $ - * $Revision: 1.2 $ - * $Author: btb $ - * $Date: 2003-03-19 19:21:34 $ + * $Revision: 1.1.1.1 $ + * $Author: bradleyb $ + * $Date: 2001-01-19 03:30:16 $ * * Include file for entities using texture mapper library. * * $Log: not supported by cvs2svn $ - * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb - * Import of d2x-0.0.8 - * * Revision 1.2 1999/07/07 21:21:56 donut * increased recip table size to better accommodate 640 res * @@ -180,7 +177,5 @@ extern int Window_clip_left, Window_clip_bot, Window_clip_right, Window_clip_top #define FIX_XLIMIT (639 * F1_0) #define FIX_YLIMIT (479 * F1_0) -extern void init_interface_vars_to_assembler(void); - #endif diff --git a/include/timer.h b/include/timer.h index 3abe2844..f3e38f11 100644 --- a/include/timer.h +++ b/include/timer.h @@ -1,4 +1,3 @@ -/* $Id: timer.h,v 1.5 2003-02-21 04:08:48 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,41 +7,54 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* + * $Source: /cvs/cvsroot/d2x/include/timer.h,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-10-12 10:03:32 $ * * Header for timer functions * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.2 2001/01/19 03:34:09 bradleyb + * Import of d2x-0.0.9-pre1 + * + * Revision 1.1.1.1 1999/06/14 22:02:21 donut + * Import of d1x 1.37 source. + * * Revision 1.8 1994/12/10 12:27:23 john * Added timer_get_approx_seconds. - * + * * Revision 1.7 1994/12/10 12:10:25 john * Added types.h. - * + * + * + * + * * Revision 1.6 1994/12/10 12:07:06 john * Added tick counter variable. - * + * * Revision 1.5 1994/11/15 12:04:15 john * Cleaned up timer code a bit... took out unused functions * like timer_get_milliseconds, etc. - * + * * Revision 1.4 1994/04/28 23:50:08 john * Changed calling for init_timer. Made the function that the * timer calls be a far function. All of this was done to make * our timer system compatible with the HMI sound stuff. - * + * * Revision 1.3 1994/02/17 15:57:12 john * Changed key libary to C. - * + * * Revision 1.2 1994/01/18 10:58:34 john * Added timer_get_fixed_seconds - * + * * Revision 1.1 1993/07/10 13:10:41 matt * Initial revision + * * */ @@ -86,8 +98,7 @@ extern fix timer_get_approx_seconds(); // Returns time since program started... extern void timer_set_joyhandler( void (*joy_handler)() ); #else #define timer_get_fixed_secondsX timer_get_fixed_seconds -//#define timer_get_approx_seconds timer_get_fixed_seconds -extern fix timer_get_approx_seconds(); +#define timer_get_approx_seconds timer_get_fixed_seconds #endif //NOT_USED extern unsigned int timer_get_microseconds(); @@ -96,8 +107,6 @@ extern fix timer_get_approx_seconds(); //NOT_USED extern unsigned int timer_get_milliseconds(); //NOT_USED extern unsigned int timer_get_millisecondsX(); // Assume interrupts disabled -void timer_delay(fix seconds); - //========================================================================== // Use to access the BIOS ticker... ie... i = TICKER #ifndef __DJGPP__ @@ -116,10 +125,4 @@ void timer_delay(fix seconds); #define USECS_PER_READING( start, stop, frames ) (((stop-start)*54945)/frames) #endif - -#define approx_usec_to_fsec(usec) ((usec) >> 4) -#define approx_fsec_to_usec(fsec) ((fsec) << 4) -#define approx_msec_to_fsec(msec) ((msec) << 6) -#define approx_fsec_to_msec(fsec) ((fsec) >> 6) - #endif diff --git a/include/u_mem.h b/include/u_mem.h index bdeb7842..cad21f7d 100644 --- a/include/u_mem.h +++ b/include/u_mem.h @@ -1,4 +1,3 @@ -/* $Id: u_mem.h,v 1.5 2002-08-06 05:21:33 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -26,14 +25,12 @@ void mem_display_blocks(); extern void * mem_malloc( unsigned int size, char * var, char * file, int line, int fill_zero ); extern void * mem_realloc( void * buffer, unsigned int size, char * var, char * file, int line ); extern void mem_free( void * buffer ); -extern char * mem_strdup(char * str, char * var, char * file, int line ); /* DPH: Changed malloc, etc. to d_malloc. Overloading system calls is very evil and error prone */ -#define d_malloc(size) mem_malloc((size),"Unknown", __FILE__,__LINE__, 0 ) -#define d_calloc(n,size) mem_malloc((n*size),"Unknown", __FILE__,__LINE__, 1 ) +#define d_malloc(size) mem_malloc((size),"Unknown", __FILE__,__LINE__, 0 ) +#define d_calloc(n,size) mem_malloc((n*size),"Unknown", __FILE__,__LINE__, 1 ) #define d_realloc(ptr,size) mem_realloc((ptr),(size),"Unknown", __FILE__,__LINE__ ) -#define d_free(ptr) do{ mem_free(ptr); ptr=NULL; } while(0) -#define d_strdup(str) mem_strdup((str),"Unknown",__FILE__,__LINE__) +#define d_free(ptr) do{ mem_free(ptr); ptr=NULL; } while(0) #define MALLOC( var, type, count ) (var=(type *)mem_malloc((count)*sizeof(type),#var, __FILE__,__LINE__,0 )) @@ -42,11 +39,10 @@ void mem_validate_heap(); #else -#define d_malloc(size) malloc(size) -#define d_calloc(size) calloc(n*size) +#define d_malloc(size) malloc(size) +#define d_calloc(size) calloc(n*size) #define d_realloc(ptr,size) realloc(ptr,size) -#define d_free(ptr) do{ free(ptr); ptr=NULL; } while(0) -#define d_strdup(str) strdup(str) +#define d_free(ptr) do{ free(ptr); ptr=NULL; } while(0) #define MALLOC( var, type, count ) (var=(type *)malloc((count)*sizeof(type))) diff --git a/include/vecmat.h b/include/vecmat.h index a0d5aab5..09b30f82 100644 --- a/include/vecmat.h +++ b/include/vecmat.h @@ -1,4 +1,4 @@ -/* $ Id: $ */ + /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,10 +12,22 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/include/vecmat.h,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $Date: 2001-10-18 23:59:22 $ * * Header file for vector/matrix library * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/10/12 06:40:49 bradleyb + * fix some gcc 3.0 warnings, courtesy of paoloulivi@tin.it + * + * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 22:02:28 donut + * Import of d1x 1.37 source. * * Revision 1.1 1995/04/17 16:18:05 allender * Initial revision @@ -221,7 +233,7 @@ __pack__ vms_matrix; // DPH (18/9/98): Begin mod to fix linefeed problem under linux. Uses an // inline function instead of a multi-line macro to fix CR/LF problems. -#ifdef __unix__ +#ifdef __linux__ static inline void vm_set_identity(vms_matrix *m) { m->rvec.x = m->uvec.y = m->fvec.z = f1_0; diff --git a/installation.txt b/installation.txt index a7e08f1f..021ae37a 100644 --- a/installation.txt +++ b/installation.txt @@ -1,37 +1,12 @@ -In addition to d2x, you need some data files to play. On un*x, these -files need to go into a shared data directory -(/usr/local/share/games/d2x by default). On Windows or DOS, they go -in the same directory as the d2x binary. +Firstly, compile d2x. -Base Installation ------------------ +Then stick it in a directory with these files from Descent 2 +Registered (the version _does not_ matter). Shareware may work +eventually, but the datafiles are of a differnt format. -The base install depends on which version of the datafiles you have. -d2x currently supports just about any version of Descent II, and can -use almost any version of Descent I as an add-on. - -Place these files into your shared data dir: - -Full Version (PC or Mac): -descent2.ham -descent2.hog -descent2.s11 -descent2.s22 +I needed these files: (in addition to the d2x binary) alien1.pig alien2.pig -fire.pig -groupa.pig -ice.pig -water.pig - -If you want movies, place the .mvl files in your shared data dir: -intro-h.mvl and/or intro-l.mvl -other-h.mvl and/or other-l.mvl -robots-h.mvl and/or robots-l.mvl -The mvl files from the Mac version will not work. They are in a -different format! - -OEM Version (Destination: Quartzon): descent2.ham descent2.hog descent2.s11 @@ -41,69 +16,8 @@ groupa.pig ice.pig water.pig -If you want movies, place the .mvl files in your shared data dir: -intro-l.mvl -other-l.mvl -robots-h.mvl and/or robots-l.mvl - -PC Shareware: -d2demo.ham -d2demo.hog -d2demo.pig - -Mac Shareware: -d2demo.ham -d2demo.hog -d2demo.pig -descent2.s11 -exit.ham -d2.mn2 - - -Mission Installation --------------------- - -d2x should be able to play any missions for Descent I or Descent II, -including the original Descent I mission (Descent: First Strike) - -In order to play any add-on missions, you need to have a full set of -textures. That is, your base installation above must be the "Full -Version", the "OEM Version", or the "Mac Shareware" version. - -To install an additional mission, just place the .hog and the .msn or -.mn2 file into your missions directory. The missions directory can be -inside the system-wide data dir, or your $HOME/.d2x dir. d2x will -look in both places. - -To install the original Descent I mission: -Place descent.hog into your data dir. - - -Vertigo Installation --------------------- - -Vertigo consists of both netgame enhancements (codenamed HOARD) and an -additional mission. To install HOARD, place hoard.ham in your data -dir. To play the vertigo mission, place d2x.hog and d2x.mn2 in your -mission dir. -If you want the movies that go with the vertigo mission, place -d2x-h.mvl and/or d2x-l.mvl in your data dir. - - -Notes ------ - -In unix, all filenames must be in _lower case_. It's important. - -It is not necessary to run the D2 setup program to extract the files -you need, just use unarj to extract the files from descent2.sow on the -cd. +Note the filenames must be in _lower case_. It's important. -If you use the mac demo data files, and they are not auto-detected -(colors come out wrong), use the -macdata switch. +Note that you don't have to run the D2 setup program to extract the +files, just unarj descent2.sow from the cd. -If your computer has performance problems playing the movies, you can -tell it to play the low resolution versions by setting MovieHires=0 in -your descent.cfg file. -You can also override this setting by passing the -lowresmovies switch -or by deleting all *-h.mvl files. diff --git a/libmve/.cvsignore b/libmve/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/libmve/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/libmve/Makefile.am b/libmve/Makefile.am deleted file mode 100644 index 1c80f669..00000000 --- a/libmve/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -EXTRA_PROGRAMS = mveplayer - -mveplayer_SOURCES = decoder16.c decoder8.c mve_audio.c mve_main.c mvelib.c mveplay.c - -mveplayer_CFLAGS = -DSTANDALONE - - - -noinst_LIBRARIES = libmve.a - -INCLUDES = -I$(top_srcdir)/include - -libmve_a_SOURCES = decoder16.c decoder8.c mve_audio.c mvelib.c mveplay.c - -EXTRA_DIST = decoders.h mve_audio.h mvelib.h diff --git a/libmve/decoder16.c b/libmve/decoder16.c deleted file mode 100644 index a7150c1f..00000000 --- a/libmve/decoder16.c +++ /dev/null @@ -1,716 +0,0 @@ -/* 16 bit decoding routines */ - -#include -#include -#include - -#include "decoders.h" - -static unsigned short *backBuf1, *backBuf2; -static int lookup_initialized; - -static void dispatchDecoder16(unsigned short **pFrame, unsigned char codeType, unsigned char **pData, unsigned char **pOffData, int *pDataRemain, int *curXb, int *curYb); -static void genLoopkupTable(); - -void decodeFrame16(unsigned char *pFrame, unsigned char *pMap, int mapRemain, unsigned char *pData, int dataRemain) -{ - unsigned char *pOrig; - unsigned char *pOffData, *pEnd; - unsigned short offset; - int length; - int op; - int i, j; - int xb, yb; - - if (!lookup_initialized) { - genLoopkupTable(); - } - - backBuf1 = (unsigned short *)g_vBackBuf1; - backBuf2 = (unsigned short *)g_vBackBuf2; - - xb = g_width >> 3; - yb = g_height >> 3; - - offset = pData[0]|(pData[1]<<8); - - pOffData = pData + offset; - pEnd = pData + offset; - - pData += 2; - - pOrig = pData; - length = offset - 2; /*dataRemain-2;*/ - - for (j=0; j= backBuf1 + g_width*g_height) - fprintf(stderr, "danger! pointing out of bounds above after dispatch decoder: %d, %d (1) [%x]\n", i, j, (*pMap) & 0xf); - */ - - op = ((*pMap) >> 4) & 0xf; - dispatchDecoder16((unsigned short **)&pFrame, op, &pData, &pOffData, &dataRemain, &i, &j); - - /* - if ((unsigned short *)pFrame < backBuf1) - fprintf(stderr, "danger! pointing out of bounds below after dispatch decoder: %d, %d (2) [%x]\n", i, j, (*pMap) >> 4); - else if ((unsigned short *)pFrame >= backBuf1 + g_width*g_height) - fprintf(stderr, "danger! pointing out of bounds above after dispatch decoder: %d, %d (2) [%x]\n", i, j, (*pMap) >> 4); - */ - - ++pMap; - --mapRemain; - } - - pFrame += 7*g_width*2; - } - - if ((length-(pData-pOrig)) != 0) { - fprintf(stderr, "DEBUG: junk left over: %d,%d,%d\n", (pData-pOrig), length, (length-(pData-pOrig))); - } -} - -static unsigned short GETPIXEL(unsigned char **buf, int off) -{ - unsigned short val = (*buf)[0+off] | ((*buf)[1+off] << 8); - return val; -} - -static unsigned short GETPIXELI(unsigned char **buf, int off) -{ - unsigned short val = (*buf)[0+off] | ((*buf)[1+off] << 8); - (*buf) += 2; - return val; -} - -static void relClose(int i, int *x, int *y) -{ - int ma, mi; - - ma = i >> 4; - mi = i & 0xf; - - *x = mi - 8; - *y = ma - 8; -} - -static void relFar(int i, int sign, int *x, int *y) -{ - if (i < 56) - { - *x = sign * (8 + (i % 7)); - *y = sign * (i / 7); - } - else - { - *x = sign * (-14 + (i - 56) % 29); - *y = sign * (8 + (i - 56) / 29); - } -} - -static int close_table[512]; -static int far_p_table[512]; -static int far_n_table[512]; - -static void genLoopkupTable() -{ - int i; - int x, y; - - for (i = 0; i < 256; i++) { - relClose(i, &x, &y); - - close_table[i*2+0] = x; - close_table[i*2+1] = y; - - relFar(i, 1, &x, &y); - - far_p_table[i*2+0] = x; - far_p_table[i*2+1] = y; - - relFar(i, -1, &x, &y); - - far_n_table[i*2+0] = x; - far_n_table[i*2+1] = y; - } - - lookup_initialized = 1; -} - -static void copyFrame(unsigned short *pDest, unsigned short *pSrc) -{ - int i; - - for (i=0; i<8; i++) - { - memcpy(pDest, pSrc, 16); - pDest += g_width; - pSrc += g_width; - } -} - -static void patternRow4Pixels(unsigned short *pFrame, - unsigned char pat0, unsigned char pat1, - unsigned short *p) -{ - unsigned short mask=0x0003; - unsigned short shift=0; - unsigned short pattern = (pat1 << 8) | pat0; - - while (mask != 0) - { - *pFrame++ = p[(mask & pattern) >> shift]; - mask <<= 2; - shift += 2; - } -} - -static void patternRow4Pixels2(unsigned short *pFrame, - unsigned char pat0, - unsigned short *p) -{ - unsigned char mask=0x03; - unsigned char shift=0; - unsigned short pel; - /* ORIGINAL VERSION IS BUGGY - int skip=1; - - while (mask != 0) - { - pel = p[(mask & pat0) >> shift]; - pFrame[0] = pel; - pFrame[2] = pel; - pFrame[g_width + 0] = pel; - pFrame[g_width + 2] = pel; - pFrame += skip; - skip = 4 - skip; - mask <<= 2; - shift += 2; - } - */ - while (mask != 0) - { - pel = p[(mask & pat0) >> shift]; - pFrame[0] = pel; - pFrame[1] = pel; - pFrame[g_width + 0] = pel; - pFrame[g_width + 1] = pel; - pFrame += 2; - mask <<= 2; - shift += 2; - } -} - -static void patternRow4Pixels2x1(unsigned short *pFrame, unsigned char pat, - unsigned short *p) -{ - unsigned char mask=0x03; - unsigned char shift=0; - unsigned short pel; - - while (mask != 0) - { - pel = p[(mask & pat) >> shift]; - pFrame[0] = pel; - pFrame[1] = pel; - pFrame += 2; - mask <<= 2; - shift += 2; - } -} - -static void patternQuadrant4Pixels(unsigned short *pFrame, - unsigned char pat0, unsigned char pat1, unsigned char pat2, - unsigned char pat3, unsigned short *p) -{ - unsigned long mask = 0x00000003UL; - int shift=0; - int i; - unsigned long pat = (pat3 << 24) | (pat2 << 16) | (pat1 << 8) | pat0; - - for (i=0; i<16; i++) - { - pFrame[i&3] = p[(pat & mask) >> shift]; - - if ((i&3) == 3) - pFrame += g_width; - - mask <<= 2; - shift += 2; - } -} - - -static void patternRow2Pixels(unsigned short *pFrame, unsigned char pat, - unsigned short *p) -{ - unsigned char mask=0x01; - - while (mask != 0) - { - *pFrame++ = p[(mask & pat) ? 1 : 0]; - mask <<= 1; - } -} - -static void patternRow2Pixels2(unsigned short *pFrame, unsigned char pat, - unsigned short *p) -{ - unsigned short pel; - unsigned char mask=0x1; - - /* ORIGINAL VERSION IS BUGGY - int skip=1; - while (mask != 0x10) - { - pel = p[(mask & pat) ? 1 : 0]; - pFrame[0] = pel; - pFrame[2] = pel; - pFrame[g_width + 0] = pel; - pFrame[g_width + 2] = pel; - pFrame += skip; - skip = 4 - skip; - mask <<= 1; - } - */ - while (mask != 0x10) { - pel = p[(mask & pat) ? 1 : 0]; - - pFrame[0] = pel; - pFrame[1] = pel; - pFrame[g_width + 0] = pel; - pFrame[g_width + 1] = pel; - pFrame += 2; - - mask <<= 1; - } -} - -static void patternQuadrant2Pixels(unsigned short *pFrame, unsigned char pat0, - unsigned char pat1, unsigned short *p) -{ - unsigned short mask = 0x0001; - int i; - unsigned short pat = (pat1 << 8) | pat0; - - for (i=0; i<16; i++) - { - pFrame[i&3] = p[(pat & mask) ? 1 : 0]; - - if ((i&3) == 3) - pFrame += g_width; - - mask <<= 1; - } -} - -static void dispatchDecoder16(unsigned short **pFrame, unsigned char codeType, unsigned char **pData, unsigned char **pOffData, int *pDataRemain, int *curXb, int *curYb) -{ - unsigned short p[4]; - unsigned char pat[16]; - int i, j, k; - int x, y; - unsigned short *pDstBak; - - pDstBak = *pFrame; - - switch(codeType) - { - case 0x0: - copyFrame(*pFrame, *pFrame + (backBuf2 - backBuf1)); - case 0x1: - break; - case 0x2: /* - relFar(*(*pOffData)++, 1, &x, &y); - */ - - k = *(*pOffData)++; - x = far_p_table[k*2+0]; - y = far_p_table[k*2+1]; - - copyFrame(*pFrame, *pFrame + x + y*g_width); - --*pDataRemain; - break; - case 0x3: /* - relFar(*(*pOffData)++, -1, &x, &y); - */ - - k = *(*pOffData)++; - x = far_n_table[k*2+0]; - y = far_n_table[k*2+1]; - - copyFrame(*pFrame, *pFrame + x + y*g_width); - --*pDataRemain; - break; - case 0x4: /* - relClose(*(*pOffData)++, &x, &y); - */ - - k = *(*pOffData)++; - x = close_table[k*2+0]; - y = close_table[k*2+1]; - - copyFrame(*pFrame, *pFrame + (backBuf2 - backBuf1) + x + y*g_width); - --*pDataRemain; - break; - case 0x5: - x = (char)*(*pData)++; - y = (char)*(*pData)++; - copyFrame(*pFrame, *pFrame + (backBuf2 - backBuf1) + x + y*g_width); - *pDataRemain -= 2; - break; - case 0x6: - fprintf(stderr, "STUB: encoding 6 not tested\n"); - for (i=0; i<2; i++) - { - *pFrame += 16; - if (++*curXb == (g_width >> 3)) - { - *pFrame += 7*g_width; - *curXb = 0; - if (++*curYb == (g_height >> 3)) - return; - } - } - break; - - case 0x7: - p[0] = GETPIXELI(pData, 0); - p[1] = GETPIXELI(pData, 0); - - if (!((p[0]/*|p[1]*/)&0x8000)) - { - for (i=0; i<8; i++) - { - patternRow2Pixels(*pFrame, *(*pData), p); - (*pData)++; - - *pFrame += g_width; - } - } - else - { - for (i=0; i<2; i++) - { - patternRow2Pixels2(*pFrame, *(*pData) & 0xf, p); - *pFrame += 2*g_width; - patternRow2Pixels2(*pFrame, *(*pData) >> 4, p); - (*pData)++; - - *pFrame += 2*g_width; - } - } - break; - - case 0x8: - p[0] = GETPIXEL(pData, 0); - - if (!(p[0] & 0x8000)) - { - for (i=0; i<4; i++) - { - p[0] = GETPIXELI(pData, 0); - p[1] = GETPIXELI(pData, 0); - - pat[0] = (*pData)[0]; - pat[1] = (*pData)[1]; - (*pData) += 2; - - patternQuadrant2Pixels(*pFrame, pat[0], pat[1], p); - - if (i & 1) - *pFrame -= (4*g_width - 4); - else - *pFrame += 4*g_width; - } - - - } else { - p[2] = GETPIXEL(pData, 8); - - if (!(p[2]&0x8000)) { - for (i=0; i<4; i++) - { - if ((i & 1) == 0) - { - p[0] = GETPIXELI(pData, 0); - p[1] = GETPIXELI(pData, 0); - } - pat[0] = *(*pData)++; - pat[1] = *(*pData)++; - patternQuadrant2Pixels(*pFrame, pat[0], pat[1], p); - - if (i & 1) - *pFrame -= (4*g_width - 4); - else - *pFrame += 4*g_width; - } - } else { - for (i=0; i<8; i++) - { - if ((i & 3) == 0) - { - p[0] = GETPIXELI(pData, 0); - p[1] = GETPIXELI(pData, 0); - } - patternRow2Pixels(*pFrame, *(*pData), p); - (*pData)++; - - *pFrame += g_width; - } - } - } - break; - - case 0x9: - p[0] = GETPIXELI(pData, 0); - p[1] = GETPIXELI(pData, 0); - p[2] = GETPIXELI(pData, 0); - p[3] = GETPIXELI(pData, 0); - - *pDataRemain -= 8; - - if (!(p[0] & 0x8000)) - { - if (!(p[2] & 0x8000)) - { - - for (i=0; i<8; i++) - { - pat[0] = (*pData)[0]; - pat[1] = (*pData)[1]; - (*pData) += 2; - patternRow4Pixels(*pFrame, pat[0], pat[1], p); - *pFrame += g_width; - } - *pDataRemain -= 16; - - } - else - { - patternRow4Pixels2(*pFrame, (*pData)[0], p); - *pFrame += 2*g_width; - patternRow4Pixels2(*pFrame, (*pData)[1], p); - *pFrame += 2*g_width; - patternRow4Pixels2(*pFrame, (*pData)[2], p); - *pFrame += 2*g_width; - patternRow4Pixels2(*pFrame, (*pData)[3], p); - - (*pData) += 4; - *pDataRemain -= 4; - - } - } - else - { - if (!(p[2] & 0x8000)) - { - for (i=0; i<8; i++) - { - pat[0] = (*pData)[0]; - (*pData) += 1; - patternRow4Pixels2x1(*pFrame, pat[0], p); - *pFrame += g_width; - } - *pDataRemain -= 8; - } - else - { - for (i=0; i<4; i++) - { - pat[0] = (*pData)[0]; - pat[1] = (*pData)[1]; - - (*pData) += 2; - - patternRow4Pixels(*pFrame, pat[0], pat[1], p); - *pFrame += g_width; - patternRow4Pixels(*pFrame, pat[0], pat[1], p); - *pFrame += g_width; - } - *pDataRemain -= 8; - } - } - break; - - case 0xa: - p[0] = GETPIXEL(pData, 0); - - if (!(p[0] & 0x8000)) - { - for (i=0; i<4; i++) - { - p[0] = GETPIXELI(pData, 0); - p[1] = GETPIXELI(pData, 0); - p[2] = GETPIXELI(pData, 0); - p[3] = GETPIXELI(pData, 0); - pat[0] = (*pData)[0]; - pat[1] = (*pData)[1]; - pat[2] = (*pData)[2]; - pat[3] = (*pData)[3]; - - (*pData) += 4; - - patternQuadrant4Pixels(*pFrame, pat[0], pat[1], pat[2], pat[3], p); - - if (i & 1) - *pFrame -= (4*g_width - 4); - else - *pFrame += 4*g_width; - } - } - else - { - p[0] = GETPIXEL(pData, 16); - - if (!(p[0] & 0x8000)) - { - for (i=0; i<4; i++) - { - if ((i&1) == 0) - { - p[0] = GETPIXELI(pData, 0); - p[1] = GETPIXELI(pData, 0); - p[2] = GETPIXELI(pData, 0); - p[3] = GETPIXELI(pData, 0); - } - - pat[0] = (*pData)[0]; - pat[1] = (*pData)[1]; - pat[2] = (*pData)[2]; - pat[3] = (*pData)[3]; - - (*pData) += 4; - - patternQuadrant4Pixels(*pFrame, pat[0], pat[1], pat[2], pat[3], p); - - if (i & 1) - *pFrame -= (4*g_width - 4); - else - *pFrame += 4*g_width; - } - } - else - { - for (i=0; i<8; i++) - { - if ((i&3) == 0) - { - p[0] = GETPIXELI(pData, 0); - p[1] = GETPIXELI(pData, 0); - p[2] = GETPIXELI(pData, 0); - p[3] = GETPIXELI(pData, 0); - } - - pat[0] = (*pData)[0]; - pat[1] = (*pData)[1]; - patternRow4Pixels(*pFrame, pat[0], pat[1], p); - *pFrame += g_width; - - (*pData) += 2; - } - } - } - break; - - case 0xb: - for (i=0; i<8; i++) - { - memcpy(*pFrame, *pData, 16); - *pFrame += g_width; - *pData += 16; - *pDataRemain -= 16; - } - break; - - case 0xc: - for (i=0; i<4; i++) - { - p[0] = GETPIXEL(pData, 0); - p[1] = GETPIXEL(pData, 2); - p[2] = GETPIXEL(pData, 4); - p[3] = GETPIXEL(pData, 6); - - for (j=0; j<2; j++) - { - for (k=0; k<4; k++) - { - (*pFrame)[j+2*k] = p[k]; - (*pFrame)[g_width+j+2*k] = p[k]; - } - *pFrame += g_width; - } - *pData += 8; - *pDataRemain -= 8; - } - break; - - case 0xd: - for (i=0; i<2; i++) - { - p[0] = GETPIXEL(pData, 0); - p[1] = GETPIXEL(pData, 2); - - for (j=0; j<4; j++) - { - for (k=0; k<4; k++) - { - (*pFrame)[k*g_width+j] = p[0]; - (*pFrame)[k*g_width+j+4] = p[1]; - } - } - - *pFrame += 4*g_width; - - *pData += 4; - *pDataRemain -= 4; - } - break; - - case 0xe: - p[0] = GETPIXEL(pData, 0); - - for (i = 0; i < 8; i++) { - for (j = 0; j < 8; j++) { - (*pFrame)[j] = p[0]; - } - - *pFrame += g_width; - } - - *pData += 2; - *pDataRemain -= 2; - - break; - - case 0xf: - p[0] = GETPIXEL(pData, 0); - p[1] = GETPIXEL(pData, 1); - - for (i=0; i<8; i++) - { - for (j=0; j<8; j++) - { - (*pFrame)[j] = p[(i+j)&1]; - } - *pFrame += g_width; - } - - *pData += 4; - *pDataRemain -= 4; - break; - - default: - break; - } - - *pFrame = pDstBak+8; -} diff --git a/libmve/decoder8.c b/libmve/decoder8.c deleted file mode 100644 index 53cbb1e7..00000000 --- a/libmve/decoder8.c +++ /dev/null @@ -1,871 +0,0 @@ -/* 8 bit decoding routines */ - -#include -#include - -#include "decoders.h" - -static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, unsigned char **pData, int *pDataRemain, int *curXb, int *curYb); - -void decodeFrame8(unsigned char *pFrame, unsigned char *pMap, int mapRemain, unsigned char *pData, int dataRemain) -{ - int i, j; - int xb, yb; - - xb = g_width >> 3; - yb = g_height >> 3; - for (j=0; j= ((unsigned char *)g_vBackBuf1) + g_width*g_height) - fprintf(stderr, "danger! pointing out of bounds above after dispatch decoder: %d, %d (1) [%x]\n", i, j, (*pMap) & 0xf); - dispatchDecoder(&pFrame, (*pMap) >> 4, &pData, &dataRemain, &i, &j); - if (pFrame < (unsigned char *)g_vBackBuf1) - fprintf(stderr, "danger! pointing out of bounds below after dispatch decoder: %d, %d (2) [%x]\n", i, j, (*pMap) >> 4); - else if (pFrame >= ((unsigned char *)g_vBackBuf1) + g_width*g_height) - fprintf(stderr, "danger! pointing out of bounds above after dispatch decoder: %d, %d (2) [%x]\n", i, j, (*pMap) >> 4); - - ++pMap; - --mapRemain; - } - - pFrame += 7*g_width; - } -} - -static void relClose(int i, int *x, int *y) -{ - int ma, mi; - - ma = i >> 4; - mi = i & 0xf; - - *x = mi - 8; - *y = ma - 8; -} - -static void relFar(int i, int sign, int *x, int *y) -{ - if (i < 56) - { - *x = sign * (8 + (i % 7)); - *y = sign * (i / 7); - } - else - { - *x = sign * (-14 + (i - 56) % 29); - *y = sign * (8 + (i - 56) / 29); - } -} - -/* copies an 8x8 block from pSrc to pDest. - pDest and pSrc are both g_width bytes wide */ -static void copyFrame(unsigned char *pDest, unsigned char *pSrc) -{ - int i; - - for (i=0; i<8; i++) - { - memcpy(pDest, pSrc, 8); - pDest += g_width; - pSrc += g_width; - } -} - -// Fill in the next eight bytes with p[0], p[1], p[2], or p[3], -// depending on the corresponding two-bit value in pat0 and pat1 -static void patternRow4Pixels(unsigned char *pFrame, - unsigned char pat0, unsigned char pat1, - unsigned char *p) -{ - unsigned short mask=0x0003; - unsigned short shift=0; - unsigned short pattern = (pat1 << 8) | pat0; - - while (mask != 0) - { - *pFrame++ = p[(mask & pattern) >> shift]; - mask <<= 2; - shift += 2; - } -} - -// Fill in the next four 2x2 pixel blocks with p[0], p[1], p[2], or p[3], -// depending on the corresponding two-bit value in pat0. -static void patternRow4Pixels2(unsigned char *pFrame, - unsigned char pat0, - unsigned char *p) -{ - unsigned char mask=0x03; - unsigned char shift=0; - unsigned char pel; - - while (mask != 0) - { - pel = p[(mask & pat0) >> shift]; - pFrame[0] = pel; - pFrame[1] = pel; - pFrame[g_width + 0] = pel; - pFrame[g_width + 1] = pel; - pFrame += 2; - mask <<= 2; - shift += 2; - } -} - -// Fill in the next four 2x1 pixel blocks with p[0], p[1], p[2], or p[3], -// depending on the corresponding two-bit value in pat. -static void patternRow4Pixels2x1(unsigned char *pFrame, unsigned char pat, unsigned char *p) -{ - unsigned char mask=0x03; - unsigned char shift=0; - unsigned char pel; - - while (mask != 0) - { - pel = p[(mask & pat) >> shift]; - pFrame[0] = pel; - pFrame[1] = pel; - pFrame += 2; - mask <<= 2; - shift += 2; - } -} - -// Fill in the next 4x4 pixel block with p[0], p[1], p[2], or p[3], -// depending on the corresponding two-bit value in pat0, pat1, pat2, and pat3. -static void patternQuadrant4Pixels(unsigned char *pFrame, unsigned char pat0, unsigned char pat1, unsigned char pat2, unsigned char pat3, unsigned char *p) -{ - unsigned long mask = 0x00000003UL; - int shift=0; - int i; - unsigned long pat = (pat3 << 24) | (pat2 << 16) | (pat1 << 8) | pat0; - - for (i=0; i<16; i++) - { - pFrame[i&3] = p[(pat & mask) >> shift]; - - if ((i&3) == 3) - pFrame += g_width; - - mask <<= 2; - shift += 2; - } -} - -// fills the next 8 pixels with either p[0] or p[1], depending on pattern -static void patternRow2Pixels(unsigned char *pFrame, unsigned char pat, unsigned char *p) -{ - unsigned char mask=0x01; - - while (mask != 0) - { - *pFrame++ = p[(mask & pat) ? 1 : 0]; - mask <<= 1; - } -} - -// fills the next four 2 x 2 pixel boxes with either p[0] or p[1], depending on pattern -static void patternRow2Pixels2(unsigned char *pFrame, unsigned char pat, unsigned char *p) -{ - unsigned char pel; - unsigned char mask=0x1; - - while (mask != 0x10) - { - pel = p[(mask & pat) ? 1 : 0]; - - pFrame[0] = pel; // upper-left - pFrame[1] = pel; // upper-right - pFrame[g_width + 0] = pel; // lower-left - pFrame[g_width + 1] = pel; // lower-right - pFrame += 2; - - mask <<= 1; - } -} - -// fills pixels in the next 4 x 4 pixel boxes with either p[0] or p[1], depending on pat0 and pat1. -static void patternQuadrant2Pixels(unsigned char *pFrame, unsigned char pat0, unsigned char pat1, unsigned char *p) -{ - unsigned char pel; - unsigned short mask = 0x0001; - int i, j; - unsigned short pat = (pat1 << 8) | pat0; - - for (i=0; i<4; i++) - { - for (j=0; j<4; j++) - { - pel = p[(pat & mask) ? 1 : 0]; - - pFrame[j + i * g_width] = pel; - - mask <<= 1; - } - } -} - -static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, unsigned char **pData, int *pDataRemain, int *curXb, int *curYb) -{ - unsigned char p[4]; - unsigned char pat[16]; - int i, j, k; - int x, y; - - /* Data is processed in 8x8 pixel blocks. - There are 16 ways to encode each block. - */ - - switch(codeType) - { - case 0x0: - /* block is copied from block in current frame */ - copyFrame(*pFrame, *pFrame + (g_vBackBuf2 - g_vBackBuf1)); - case 0x1: - /* block is unchanged from two frames ago */ - *pFrame += 8; - break; - - case 0x2: - /* Block is copied from nearby (below and/or to the right) within the - new frame. The offset within the buffer from which to grab the - patch of 8 pixels is given by grabbing a byte B from the data - stream, which is broken into a positive x and y offset according - to the following mapping: - - if B < 56: - x = 8 + (B % 7) - y = B / 7 - else - x = -14 + ((B - 56) % 29) - y = 8 + ((B - 56) / 29) - */ - relFar(*(*pData)++, 1, &x, &y); - copyFrame(*pFrame, *pFrame + x + y*g_width); - *pFrame += 8; - --*pDataRemain; - break; - - case 0x3: - /* Block is copied from nearby (above and/or to the left) within the - new frame. - - if B < 56: - x = -(8 + (B % 7)) - y = -(B / 7) - else - x = -(-14 + ((B - 56) % 29)) - y = -( 8 + ((B - 56) / 29)) - */ - relFar(*(*pData)++, -1, &x, &y); - copyFrame(*pFrame, *pFrame + x + y*g_width); - *pFrame += 8; - --*pDataRemain; - break; - - case 0x4: - /* Similar to 0x2 and 0x3, except this method copies from the - "current" frame, rather than the "new" frame, and instead of the - lopsided mapping they use, this one uses one which is symmetric - and centered around the top-left corner of the block. This uses - only 1 byte still, though, so the range is decreased, since we - have to encode all directions in a single byte. The byte we pull - from the data stream, I'll call B. Call the highest 4 bits of B - BH and the lowest 4 bytes BL. Then the offset from which to copy - the data is: - - x = -8 + BL - y = -8 + BH - */ - relClose(*(*pData)++, &x, &y); - copyFrame(*pFrame, *pFrame + (g_vBackBuf2 - g_vBackBuf1) + x + y*g_width); - *pFrame += 8; - --*pDataRemain; - break; - - case 0x5: - /* Similar to 0x4, but instead of one byte for the offset, this uses - two bytes to encode a larger range, the first being the x offset - as a signed 8-bit value, and the second being the y offset as a - signed 8-bit value. - */ - x = (signed char)*(*pData)++; - y = (signed char)*(*pData)++; - copyFrame(*pFrame, *pFrame + (g_vBackBuf2 - g_vBackBuf1) + x + y*g_width); - *pFrame += 8; - *pDataRemain -= 2; - break; - - case 0x6: - /* I can't figure out how any file containing a block of this type - could still be playable, since it appears that it would leave the - internal bookkeeping in an inconsistent state in the BG player - code. Ahh, well. Perhaps it was a bug in the BG player code that - just didn't happen to be exposed by any of the included movies. - Anyway, this skips the next two blocks, doing nothing to them. - Note that if you've reached the end of a row, this means going on - to the next row. - */ - for (i=0; i<2; i++) - { - *pFrame += 16; - if (++*curXb == (g_width >> 3)) - { - *pFrame += 7*g_width; - *curXb = 0; - if (++*curYb == (g_height >> 3)) - return; - } - } - break; - - case 0x7: - /* Ok, here's where it starts to get really...interesting. This is, - incidentally, the part where they started using self-modifying - code. So, most of the following encodings are "patterned" blocks, - where we are given a number of pixel values and then bitmapped - values to specify which pixel values belong to which squares. For - this encoding, we are given the following in the data stream: - - P0 P1 - - These are pixel values (i.e. 8-bit indices into the palette). If - P0 <= P1, we then get 8 more bytes from the data stream, one for - each row in the block: - - B0 B1 B2 B3 B4 B5 B6 B7 - - For each row, the leftmost pixel is represented by the low-order - bit, and the rightmost by the high-order bit. Use your imagination - in between. If a bit is set, the pixel value is P1 and if it is - unset, the pixel value is P0. - - So, for example, if we had: - - 11 22 fe 83 83 83 83 83 83 fe - - This would represent the following layout: - - 11 22 22 22 22 22 22 22 ; fe == 11111110 - 22 22 11 11 11 11 11 22 ; 83 == 10000011 - 22 22 11 11 11 11 11 22 ; 83 == 10000011 - 22 22 11 11 11 11 11 22 ; 83 == 10000011 - 22 22 11 11 11 11 11 22 ; 83 == 10000011 - 22 22 11 11 11 11 11 22 ; 83 == 10000011 - 22 22 11 11 11 11 11 22 ; 83 == 10000011 - 11 22 22 22 22 22 22 22 ; fe == 11111110 - - If, on the other hand, P0 > P1, we get two more bytes from the - data stream: - - B0 B1 - - Each of these bytes contains two 4-bit patterns. These patterns - work like the patterns above with 8 bytes, except each bit - represents a 2x2 pixel region. - - B0 contains the pattern for the top two rows and B1 contains - the pattern for the bottom two rows. Note that the low-order - nibble of each byte contains the pattern for the upper of the - two rows that that byte controls. - - So if we had: - - 22 11 7e 83 - - The output would be: - - 11 11 22 22 22 22 22 22 ; e == 1 1 1 0 - 11 11 22 22 22 22 22 22 ; - 22 22 22 22 22 22 11 11 ; 7 == 0 1 1 1 - 22 22 22 22 22 22 11 11 ; - 11 11 11 11 11 11 22 22 ; 3 == 1 0 0 0 - 11 11 11 11 11 11 22 22 ; - 22 22 22 22 11 11 11 11 ; 8 == 0 0 1 1 - 22 22 22 22 11 11 11 11 ; - */ - p[0] = *(*pData)++; - p[1] = *(*pData)++; - if (p[0] <= p[1]) - { - for (i=0; i<8; i++) - { - patternRow2Pixels(*pFrame, *(*pData)++, p); - *pFrame += g_width; - } - } - else - { - for (i=0; i<2; i++) - { - patternRow2Pixels2(*pFrame, *(*pData) & 0xf, p); - *pFrame += 2*g_width; - patternRow2Pixels2(*pFrame, *(*pData)++ >> 4, p); - *pFrame += 2*g_width; - } - } - *pFrame -= (8*g_width - 8); - break; - - case 0x8: - /* Ok, this one is basically like encoding 0x7, only more - complicated. Again, we start out by getting two bytes on the data - stream: - - P0 P1 - - if P0 <= P1 then we get the following from the data stream: - - B0 B1 - P2 P3 B2 B3 - P4 P5 B4 B5 - P6 P7 B6 B7 - - P0 P1 and B0 B1 are used for the top-left corner, P2 P3 B2 B3 for - the bottom-left corner, P4 P5 B4 B5 for the top-right, P6 P7 B6 B7 - for the bottom-right. (So, each codes for a 4x4 pixel array.) - Since we have 16 bits in B0 B1, there is one bit for each pixel in - the array. The convention for the bit-mapping is, again, left to - right and top to bottom. - - So, basically, the top-left quarter of the block is an arbitrary - pattern with 2 pixels, the bottom-left a different arbitrary - pattern with 2 different pixels, and so on. - - For example if the next 16 bytes were: - - 00 22 f9 9f 44 55 aa 55 11 33 cc 33 66 77 01 ef - - We'd draw: - - 22 22 22 22 | 11 11 33 33 ; f = 1111, c = 1100 - 22 00 00 22 | 11 11 33 33 ; 9 = 1001, c = 1100 - 22 00 00 22 | 33 33 11 11 ; 9 = 1001, 3 = 0011 - 22 22 22 22 | 33 33 11 11 ; f = 1111, 3 = 0011 - ------------+------------ - 44 55 44 55 | 66 66 66 66 ; a = 1010, 0 = 0000 - 44 55 44 55 | 77 66 66 66 ; a = 1010, 1 = 0001 - 55 44 55 44 | 66 77 77 77 ; 5 = 0101, e = 1110 - 55 44 55 44 | 77 77 77 77 ; 5 = 0101, f = 1111 - - I've added a dividing line in the above to clearly delineate the - quadrants. - - - Now, if P0 > P1 then we get 10 more bytes from the data stream: - - B0 B1 B2 B3 P2 P3 B4 B5 B6 B7 - - Now, if P2 <= P3, then the first six bytes [P0 P1 B0 B1 B2 B3] - represent the left half of the block and the latter six bytes - [P2 P3 B4 B5 B6 B7] represent the right half. - - For example: - - 22 00 01 37 f7 31 11 66 8c e6 73 31 - - yeilds: - - 22 22 22 22 | 11 11 11 66 ; 0: 0000 | 8: 1000 - 00 22 22 22 | 11 11 66 66 ; 1: 0001 | C: 1100 - 00 00 22 22 | 11 66 66 66 ; 3: 0011 | e: 1110 - 00 00 00 22 | 11 66 11 66 ; 7: 0111 | 6: 0101 - 00 00 00 00 | 66 66 66 11 ; f: 1111 | 7: 0111 - 00 00 00 22 | 66 66 11 11 ; 7: 0111 | 3: 0011 - 00 00 22 22 | 66 66 11 11 ; 3: 0011 | 3: 0011 - 00 22 22 22 | 66 11 11 11 ; 1: 0001 | 1: 0001 - - - On the other hand, if P0 > P1 and P2 > P3, then - [P0 P1 B0 B1 B2 B3] represent the top half of the - block and [P2 P3 B4 B5 B6 B7] represent the bottom half. - - For example: - - 22 00 cc 66 33 19 66 11 18 24 42 81 - - yeilds: - - 22 22 00 00 22 22 00 00 ; cc: 11001100 - 22 00 00 22 22 00 00 22 ; 66: 01100110 - 00 00 22 22 00 00 22 22 ; 33: 00110011 - 00 22 22 00 00 22 22 22 ; 19: 00011001 - ----------------------- - 66 66 66 11 11 66 66 66 ; 18: 00011000 - 66 66 11 66 66 11 66 66 ; 24: 00100100 - 66 11 66 66 66 66 11 66 ; 42: 01000010 - 11 66 66 66 66 66 66 11 ; 81: 10000001 - */ - if ( (*pData)[0] <= (*pData)[1]) - { - // four quadrant case - for (i=0; i<4; i++) - { - p[0] = *(*pData)++; - p[1] = *(*pData)++; - pat[0] = *(*pData)++; - pat[1] = *(*pData)++; - patternQuadrant2Pixels(*pFrame, pat[0], pat[1], p); - - // alternate between moving down and moving up and right - if (i & 1) - *pFrame += 4 - 4*g_width; // up and right - else - *pFrame += 4*g_width; // down - } - } - else if ( (*pData)[6] <= (*pData)[7]) - { - // split horizontal - for (i=0; i<4; i++) - { - if ((i & 1) == 0) - { - p[0] = *(*pData)++; - p[1] = *(*pData)++; - } - pat[0] = *(*pData)++; - pat[1] = *(*pData)++; - patternQuadrant2Pixels(*pFrame, pat[0], pat[1], p); - - if (i & 1) - *pFrame -= (4*g_width - 4); - else - *pFrame += 4*g_width; - } - } - else - { - // split vertical - for (i=0; i<8; i++) - { - if ((i & 3) == 0) - { - p[0] = *(*pData)++; - p[1] = *(*pData)++; - } - patternRow2Pixels(*pFrame, *(*pData)++, p); - *pFrame += g_width; - } - *pFrame -= (8*g_width - 8); - } - break; - - case 0x9: - /* Similar to the previous 2 encodings, only more complicated. And - it will get worse before it gets better. No longer are we dealing - with patterns over two pixel values. Now we are dealing with - patterns over 4 pixel values with 2 bits assigned to each pixel - (or block of pixels). - - So, first on the data stream are our 4 pixel values: - - P0 P1 P2 P3 - - Now, if P0 <= P1 AND P2 <= P3, we get 16 bytes of pattern, each - 2 bits representing a 1x1 pixel (00=P0, 01=P1, 10=P2, 11=P3). The - ordering is again left to right and top to bottom. The most - significant bits represent the left side at the top, and so on. - - If P0 <= P1 AND P2 > P3, we get 4 bytes of pattern, each 2 bits - representing a 2x2 pixel. Ordering is left to right and top to - bottom. - - if P0 > P1 AND P2 <= P3, we get 8 bytes of pattern, each 2 bits - representing a 2x1 pixel (i.e. 2 pixels wide, and 1 high). - - if P0 > P1 AND P2 > P3, we get 8 bytes of pattern, each 2 bits - representing a 1x2 pixel (i.e. 1 pixel wide, and 2 high). - */ - if ( (*pData)[0] <= (*pData)[1]) - { - if ( (*pData)[2] <= (*pData)[3]) - { - p[0] = *(*pData)++; - p[1] = *(*pData)++; - p[2] = *(*pData)++; - p[3] = *(*pData)++; - - for (i=0; i<8; i++) - { - pat[0] = *(*pData)++; - pat[1] = *(*pData)++; - patternRow4Pixels(*pFrame, pat[0], pat[1], p); - *pFrame += g_width; - } - - *pFrame -= (8*g_width - 8); - } - else - { - p[0] = *(*pData)++; - p[1] = *(*pData)++; - p[2] = *(*pData)++; - p[3] = *(*pData)++; - - patternRow4Pixels2(*pFrame, *(*pData)++, p); - *pFrame += 2*g_width; - patternRow4Pixels2(*pFrame, *(*pData)++, p); - *pFrame += 2*g_width; - patternRow4Pixels2(*pFrame, *(*pData)++, p); - *pFrame += 2*g_width; - patternRow4Pixels2(*pFrame, *(*pData)++, p); - *pFrame -= (6*g_width - 8); - } - } - else - { - if ( (*pData)[2] <= (*pData)[3]) - { - // draw 2x1 strips - p[0] = *(*pData)++; - p[1] = *(*pData)++; - p[2] = *(*pData)++; - p[3] = *(*pData)++; - - for (i=0; i<8; i++) - { - pat[0] = *(*pData)++; - patternRow4Pixels2x1(*pFrame, pat[0], p); - *pFrame += g_width; - } - - *pFrame -= (8*g_width - 8); - } - else - { - // draw 1x2 strips - p[0] = *(*pData)++; - p[1] = *(*pData)++; - p[2] = *(*pData)++; - p[3] = *(*pData)++; - - for (i=0; i<4; i++) - { - pat[0] = *(*pData)++; - pat[1] = *(*pData)++; - patternRow4Pixels(*pFrame, pat[0], pat[1], p); - *pFrame += g_width; - patternRow4Pixels(*pFrame, pat[0], pat[1], p); - *pFrame += g_width; - } - - *pFrame -= (8*g_width - 8); - } - } - break; - - case 0xa: - /* Similar to the previous, only a little more complicated. - - We are still dealing with patterns over 4 pixel values with 2 bits - assigned to each pixel (or block of pixels). - - So, first on the data stream are our 4 pixel values: - - P0 P1 P2 P3 - - Now, if P0 <= P1, the block is divided into 4 quadrants, ordered - (as with opcode 0x8) TL, BL, TR, BR. In this case the next data - in the data stream should be: - - B0 B1 B2 B3 - P4 P5 P6 P7 B4 B5 B6 B7 - P8 P9 P10 P11 B8 B9 B10 B11 - P12 P13 P14 P15 B12 B13 B14 B15 - - Each 2 bits represent a 1x1 pixel (00=P0, 01=P1, 10=P2, 11=P3). - The ordering is again left to right and top to bottom. The most - significant bits represent the right side at the top, and so on. - - If P0 > P1 then the next data on the data stream is: - - B0 B1 B2 B3 B4 B5 B6 B7 - P4 P5 P6 P7 B8 B9 B10 B11 B12 B13 B14 B15 - - Now, in this case, if P4 <= P5, - [P0 P1 P2 P3 B0 B1 B2 B3 B4 B5 B6 B7] represent the left half of - the block and the other bytes represent the right half. If P4 > - P5, then [P0 P1 P2 P3 B0 B1 B2 B3 B4 B5 B6 B7] represent the top - half of the block and the other bytes represent the bottom half. - */ - if ( (*pData)[0] <= (*pData)[1]) - { - for (i=0; i<4; i++) - { - p[0] = *(*pData)++; - p[1] = *(*pData)++; - p[2] = *(*pData)++; - p[3] = *(*pData)++; - pat[0] = *(*pData)++; - pat[1] = *(*pData)++; - pat[2] = *(*pData)++; - pat[3] = *(*pData)++; - - patternQuadrant4Pixels(*pFrame, pat[0], pat[1], pat[2], pat[3], p); - - if (i & 1) - *pFrame -= (4*g_width - 4); - else - *pFrame += 4*g_width; - } - } - else - { - if ( (*pData)[12] <= (*pData)[13]) - { - // split vertical - for (i=0; i<4; i++) - { - if ((i&1) == 0) - { - p[0] = *(*pData)++; - p[1] = *(*pData)++; - p[2] = *(*pData)++; - p[3] = *(*pData)++; - } - - pat[0] = *(*pData)++; - pat[1] = *(*pData)++; - pat[2] = *(*pData)++; - pat[3] = *(*pData)++; - - patternQuadrant4Pixels(*pFrame, pat[0], pat[1], pat[2], pat[3], p); - - if (i & 1) - *pFrame -= (4*g_width - 4); - else - *pFrame += 4*g_width; - } - } - else - { - // split horizontal - for (i=0; i<8; i++) - { - if ((i&3) == 0) - { - p[0] = *(*pData)++; - p[1] = *(*pData)++; - p[2] = *(*pData)++; - p[3] = *(*pData)++; - } - - pat[0] = *(*pData)++; - pat[1] = *(*pData)++; - patternRow4Pixels(*pFrame, pat[0], pat[1], p); - *pFrame += g_width; - } - - *pFrame -= (8*g_width - 8); - } - } - break; - - case 0xb: - /* In this encoding we get raw pixel data in the data stream -- 64 - bytes of pixel data. 1 byte for each pixel, and in the standard - order (l->r, t->b). - */ - for (i=0; i<8; i++) - { - memcpy(*pFrame, *pData, 8); - *pFrame += g_width; - *pData += 8; - *pDataRemain -= 8; - } - *pFrame -= (8*g_width - 8); - break; - - case 0xc: - /* In this encoding we get raw pixel data in the data stream -- 16 - bytes of pixel data. 1 byte for each block of 2x2 pixels, and in - the standard order (l->r, t->b). - */ - for (i=0; i<4; i++) - { - for (j=0; j<2; j++) - { - for (k=0; k<4; k++) - { - (*pFrame)[2*k] = (*pData)[k]; - (*pFrame)[2*k+1] = (*pData)[k]; - } - *pFrame += g_width; - } - *pData += 4; - *pDataRemain -= 4; - } - *pFrame -= (8*g_width - 8); - break; - - case 0xd: - /* In this encoding we get raw pixel data in the data stream -- 4 - bytes of pixel data. 1 byte for each block of 4x4 pixels, and in - the standard order (l->r, t->b). - */ - for (i=0; i<2; i++) - { - for (j=0; j<4; j++) - { - for (k=0; k<4; k++) - { - (*pFrame)[k*g_width+j] = (*pData)[0]; - (*pFrame)[k*g_width+j+4] = (*pData)[1]; - } - } - *pFrame += 4*g_width; - *pData += 2; - *pDataRemain -= 2; - } - *pFrame -= (8*g_width - 8); - break; - - case 0xe: - /* This encoding represents a solid 8x8 frame. We get 1 byte of pixel - data from the data stream. - */ - for (i=0; i<8; i++) - { - memset(*pFrame, **pData, 8); - *pFrame += g_width; - } - ++*pData; - --*pDataRemain; - *pFrame -= (8*g_width - 8); - break; - - case 0xf: - /* This encoding represents a "dithered" frame, which is - checkerboarded with alternate pixels of two colors. We get 2 - bytes of pixel data from the data stream, and these bytes are - alternated: - - P0 P1 P0 P1 P0 P1 P0 P1 - P1 P0 P1 P0 P1 P0 P1 P0 - ... - P0 P1 P0 P1 P0 P1 P0 P1 - P1 P0 P1 P0 P1 P0 P1 P0 - */ - for (i=0; i<8; i++) - { - for (j=0; j<8; j++) - { - (*pFrame)[j] = (*pData)[(i+j)&1]; - } - *pFrame += g_width; - } - *pData += 2; - *pDataRemain -= 2; - *pFrame -= (8*g_width - 8); - break; - - default: - break; - } -} diff --git a/libmve/decoders.h b/libmve/decoders.h deleted file mode 100644 index 9cff2f25..00000000 --- a/libmve/decoders.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * - * INTERNAL header - not to be included outside of libmve - * - */ - -#ifndef _DECODERS_H -#define _DECODERS_H - -extern int g_width, g_height; -extern void *g_vBackBuf1, *g_vBackBuf2; - -extern void decodeFrame8(unsigned char *pFrame, unsigned char *pMap, int mapRemain, unsigned char *pData, int dataRemain); -extern void decodeFrame16(unsigned char *pFrame, unsigned char *pMap, int mapRemain, unsigned char *pData, int dataRemain); - -#endif // _DECODERS_H diff --git a/libmve/mve_audio.c b/libmve/mve_audio.c deleted file mode 100644 index 4495a035..00000000 --- a/libmve/mve_audio.c +++ /dev/null @@ -1,55 +0,0 @@ -static int audio_exp_table[256] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 47, 51, 56, 61, - 66, 72, 79, 86, 94, 102, 112, 122, 133, 145, 158, 173, 189, 206, 225, 245, - 267, 292, 318, 348, 379, 414, 452, 493, 538, 587, 640, 699, 763, 832, 908, 991, - 1081, 1180, 1288, 1405, 1534, 1673, 1826, 1993, 2175, 2373, 2590, 2826, 3084, 3365, 3672, 4008, - 4373, 4772, 5208, 5683, 6202, 6767, 7385, 8059, 8794, 9597, 10472, 11428, 12471, 13609, 14851, 16206, - 17685, 19298, 21060, 22981, 25078, 27367, 29864, 32589, -29973, -26728, -23186, -19322, -15105, -10503, -5481, -1, - 1, 1, 5481, 10503, 15105, 19322, 23186, 26728, 29973, -32589, -29864, -27367, -25078, -22981, -21060, -19298, - -17685, -16206, -14851, -13609, -12471, -11428, -10472, -9597, -8794, -8059, -7385, -6767, -6202, -5683, -5208, -4772, - -4373, -4008, -3672, -3365, -3084, -2826, -2590, -2373, -2175, -1993, -1826, -1673, -1534, -1405, -1288, -1180, - -1081, -991, -908, -832, -763, -699, -640, -587, -538, -493, -452, -414, -379, -348, -318, -292, - -267, -245, -225, -206, -189, -173, -158, -145, -133, -122, -112, -102, -94, -86, -79, -72, - -66, -61, -56, -51, -47, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, - -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, - -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1 -}; - -static int getWord(unsigned char **fin) -{ - int value = ((*fin)[1] << 8) | (*fin)[0]; - *fin += 2; - return value; -} - -static void sendWord(short **fout, int nOffset) -{ - *(*fout)++ = nOffset; -} - -static void processSwath(short *fout, unsigned char *data, int swath, int *offsets) -{ - int i; - for (i=0; i -#endif - -#include -#include -#include -#include -#include - -#include - -#include "mvelib.h" - -#define SWAPINT(x) (((x)<<24) | (((unsigned int)(x)) >> 24) | (((x) &0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8)) - -#define MAX_FILES 256 - -extern int g_spdFactorNum; -extern int g_sdlVidFlags; -extern int g_loop; - -void initializeMovie(MVESTREAM *mve); -void playMovie(MVESTREAM *mve); -void shutdownMovie(MVESTREAM *mve); - -static void usage(void) -{ - fprintf(stderr, "usage: mveplay [-f] [-l] [-s ] [] \n" - "-f\tFullscreen mode\n" - "-s\tSpeed Factor \n" - ); - exit(1); -} - -static int doPlay(int filehandle) -{ - MVESTREAM *mve = mve_open_filehandle(filehandle); - if (mve == NULL) { - fprintf(stderr, "can't open MVE file\n"); - exit(1); - } - - initializeMovie(mve); - playMovie(mve); - shutdownMovie(mve); - - mve_close_filehandle(mve); - - return 1; -} - -int main(int argc, char *argv[]) -{ - int i, filehandle; - char *mvlfile = NULL, *mvefile = NULL; - - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-h")) - usage(); - - if (!strcmp(argv[i], "-f")) - g_sdlVidFlags |= SDL_FULLSCREEN; - - if (!strcmp(argv[i], "-l")) - g_loop = 1; - - if (!strcmp(argv[i], "-s")) { - if (argc < i + 2) - usage(); - g_spdFactorNum = atoi(argv[i + 1]); - i++; - } - - if (strchr(argv[i], '.') && !strcasecmp(strchr(argv[i], '.'), ".mvl")) - mvlfile = argv[i]; - - if (strchr(argv[i], '.') && !strcasecmp(strchr(argv[i], '.'), ".mve")) - mvefile = argv[i]; - } - - if (mvlfile) { - int nfiles; - char filename[MAX_FILES][13]; - int filesize[MAX_FILES]; - char sig[4]; - -#ifdef O_BINARY - filehandle = open(mvlfile, O_RDONLY | O_BINARY); -#else - filehandle = open(mvlfile, O_RDONLY); -#endif - if (filehandle == -1) { - fprintf(stderr, "Error opening %s\n", mvlfile); - exit(1); - } - if ((read(filehandle, sig, 4) < 4) || - (strncmp(sig, "DMVL", 4)) || - (read(filehandle, &nfiles, 4) < 4)) { - fprintf(stderr, "Error reading %s\n", mvlfile); - exit(1); - } -#ifdef WORDS_BIGENDIAN - nfiles = SWAPINT(nfiles); -#endif - if (nfiles > MAX_FILES) { - fprintf(stderr, "Error reading %s: nfiles = %d, MAX_FILES = %d\n", - mvlfile, nfiles, MAX_FILES); - } - for (i = 0; i < nfiles; i++) { - if ((read(filehandle, filename[i], 13) < 13) || - (read(filehandle, &filesize[i], 4) < 4) || - (strlen(filename[i]) > 12)) { - fprintf(stderr, "Error reading %s\n", mvlfile); - exit(1); - } -#ifdef WORDS_BIGENDIAN - filesize[i] = SWAPINT(filesize[i]); -#endif - } - - for (i = 0; i < nfiles; i++) { - if (mvefile) { - if (!strcasecmp(filename[i], mvefile)) - break; - else - lseek(filehandle, filesize[i], SEEK_CUR); - } else - printf("%13s\t%d\n", filename[i], filesize[i]); - } - if (!mvefile) - exit(0); - - } else if (mvefile) { -#ifdef O_BINARY - filehandle = open(mvefile, O_RDONLY | O_BINARY); -#else - filehandle = open(mvefile, O_RDONLY); -#endif - } else - usage(); - - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) - { - fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); - exit(1); - } - atexit(SDL_Quit); - - doPlay(filehandle); - - return 0; -} diff --git a/libmve/mvelib.c b/libmve/mvelib.c deleted file mode 100644 index a2b12c6f..00000000 --- a/libmve/mvelib.c +++ /dev/null @@ -1,617 +0,0 @@ -#include // for mem* functions -#include -#include -#include -#include - -#include "mvelib.h" - -static const char MVE_HEADER[] = "Interplay MVE File\x1A"; -static const short MVE_HDRCONST1 = 0x001A; -static const short MVE_HDRCONST2 = 0x0100; -static const short MVE_HDRCONST3 = 0x1133; - -/* - * private utility functions - */ -static short _mve_get_short(unsigned char *data); -static unsigned short _mve_get_ushort(unsigned char *data); - -/* - * private functions for mvefile - */ -static MVEFILE *_mvefile_alloc(void); -static void _mvefile_free(MVEFILE *movie); -static void _mvefile_free_filehandle(MVEFILE *movie); -static int _mvefile_open(MVEFILE *movie, const char *filename); -static int _mvefile_open_filehandle(MVEFILE *movie, int filehandle); -static void _mvefile_reset(MVEFILE *movie); -static int _mvefile_read_header(MVEFILE *movie); -static void _mvefile_set_buffer_size(MVEFILE *movie, int buf_size); -static int _mvefile_fetch_next_chunk(MVEFILE *movie); - -/* - * private functions for mvestream - */ -static MVESTREAM *_mvestream_alloc(void); -static void _mvestream_free(MVESTREAM *movie); -static void _mvestream_free_filehandle(MVESTREAM *movie); -static int _mvestream_open(MVESTREAM *movie, const char *filename); -static int _mvestream_open_filehandle(MVESTREAM *movie, int filehandle); -static void _mvestream_reset(MVESTREAM *movie); - -/************************************************************ - * public MVEFILE functions - ************************************************************/ - -/* - * open an MVE file - */ -MVEFILE *mvefile_open(const char *filename) -{ - MVEFILE *file; - - /* create the file */ - file = _mvefile_alloc(); - if (! _mvefile_open(file, filename)) - { - _mvefile_free(file); - return NULL; - } - - /* initialize the file */ - _mvefile_set_buffer_size(file, 1024); - - /* verify the file's header */ - if (! _mvefile_read_header(file)) - { - _mvefile_free(file); - return NULL; - } - - /* now, prefetch the next chunk */ - _mvefile_fetch_next_chunk(file); - - return file; -} - -MVEFILE *mvefile_open_filehandle(int filehandle) -{ - MVEFILE *file; - - /* create the file */ - file = _mvefile_alloc(); - if (! _mvefile_open_filehandle(file, filehandle)) - { - _mvefile_free_filehandle(file); - return NULL; - } - - /* initialize the file */ - _mvefile_set_buffer_size(file, 1024); - - /* verify the file's header */ - if (! _mvefile_read_header(file)) - { - _mvefile_free_filehandle(file); - return NULL; - } - - /* now, prefetch the next chunk */ - _mvefile_fetch_next_chunk(file); - - return file; -} - -/* - * close a MVE file - */ -void mvefile_close(MVEFILE *movie) -{ - _mvefile_free(movie); -} - -void mvefile_close_filehandle(MVEFILE *movie) -{ - _mvefile_free_filehandle(movie); -} - -/* - * reset a MVE file - */ -void mvefile_reset(MVEFILE *file) -{ - _mvefile_reset(file); - - /* initialize the file */ - _mvefile_set_buffer_size(file, 1024); - - /* verify the file's header */ - if (! _mvefile_read_header(file)) - { - _mvefile_free_filehandle(file); - //return NULL; - } - - /* now, prefetch the next chunk */ - _mvefile_fetch_next_chunk(file); -} - -/* - * get the size of the next segment - */ -int mvefile_get_next_segment_size(MVEFILE *movie) -{ - /* if nothing is cached, fail */ - if (movie->cur_chunk == NULL || movie->next_segment >= movie->cur_fill) - return -1; - - /* if we don't have enough data to get a segment, fail */ - if (movie->cur_fill - movie->next_segment < 4) - return -1; - - /* otherwise, get the data length */ - return _mve_get_short(movie->cur_chunk + movie->next_segment); -} - -/* - * get type of next segment in chunk (0xff if no more segments in chunk) - */ -unsigned char mvefile_get_next_segment_major(MVEFILE *movie) -{ - /* if nothing is cached, fail */ - if (movie->cur_chunk == NULL || movie->next_segment >= movie->cur_fill) - return 0xff; - - /* if we don't have enough data to get a segment, fail */ - if (movie->cur_fill - movie->next_segment < 4) - return 0xff; - - /* otherwise, get the data length */ - return movie->cur_chunk[movie->next_segment + 2]; -} - -/* - * get subtype (version) of next segment in chunk (0xff if no more segments in - * chunk) - */ -unsigned char mvefile_get_next_segment_minor(MVEFILE *movie) -{ - /* if nothing is cached, fail */ - if (movie->cur_chunk == NULL || movie->next_segment >= movie->cur_fill) - return 0xff; - - /* if we don't have enough data to get a segment, fail */ - if (movie->cur_fill - movie->next_segment < 4) - return 0xff; - - /* otherwise, get the data length */ - return movie->cur_chunk[movie->next_segment + 3]; -} - -/* - * see next segment (return NULL if no next segment) - */ -unsigned char *mvefile_get_next_segment(MVEFILE *movie) -{ - /* if nothing is cached, fail */ - if (movie->cur_chunk == NULL || movie->next_segment >= movie->cur_fill) - return NULL; - - /* if we don't have enough data to get a segment, fail */ - if (movie->cur_fill - movie->next_segment < 4) - return NULL; - - /* otherwise, get the data length */ - return movie->cur_chunk + movie->next_segment + 4; -} - -/* - * advance to next segment - */ -void mvefile_advance_segment(MVEFILE *movie) -{ - /* if nothing is cached, fail */ - if (movie->cur_chunk == NULL || movie->next_segment >= movie->cur_fill) - return; - - /* if we don't have enough data to get a segment, fail */ - if (movie->cur_fill - movie->next_segment < 4) - return; - - /* else, advance to next segment */ - movie->next_segment += - (4 + _mve_get_ushort(movie->cur_chunk + movie->next_segment)); -} - -/* - * fetch the next chunk (return 0 if at end of stream) - */ -int mvefile_fetch_next_chunk(MVEFILE *movie) -{ - return _mvefile_fetch_next_chunk(movie); -} - -/************************************************************ - * public MVESTREAM functions - ************************************************************/ - -/* - * open an MVE stream - */ -MVESTREAM *mve_open(const char *filename) -{ - MVESTREAM *movie; - - /* allocate */ - movie = _mvestream_alloc(); - - /* open */ - if (! _mvestream_open(movie, filename)) - { - _mvestream_free(movie); - return NULL; - } - - return movie; -} - -MVESTREAM *mve_open_filehandle(int filehandle) -{ - MVESTREAM *movie; - - /* allocate */ - movie = _mvestream_alloc(); - - /* open */ - if (! _mvestream_open_filehandle(movie, filehandle)) - { - _mvestream_free_filehandle(movie); - return NULL; - } - - return movie; -} - -/* - * close an MVE stream - */ -void mve_close(MVESTREAM *movie) -{ - _mvestream_free(movie); -} - -void mve_close_filehandle(MVESTREAM *movie) -{ - _mvestream_free_filehandle(movie); -} - -/* - * reset an MVE stream - */ -void mve_reset(MVESTREAM *movie) -{ - _mvestream_reset(movie); -} - -/* - * set segment type handler - */ -void mve_set_handler(MVESTREAM *movie, unsigned char major, MVESEGMENTHANDLER handler) -{ - if (major < 32) - movie->handlers[major] = handler; -} - -/* - * set segment handler context - */ -void mve_set_handler_context(MVESTREAM *movie, void *context) -{ - movie->context = context; -} - -/* - * play next chunk - */ -int mve_play_next_chunk(MVESTREAM *movie) -{ - unsigned char major, minor; - unsigned char *data; - int len; - - /* loop over segments */ - major = mvefile_get_next_segment_major(movie->movie); - while (major != 0xff) - { - /* check whether to handle the segment */ - if (major < 32 && movie->handlers[major] != NULL) - { - minor = mvefile_get_next_segment_minor(movie->movie); - len = mvefile_get_next_segment_size(movie->movie); - data = mvefile_get_next_segment(movie->movie); - - if (! movie->handlers[major](major, minor, data, len, movie->context)) - return 0; - } - - /* advance to next segment */ - mvefile_advance_segment(movie->movie); - major = mvefile_get_next_segment_major(movie->movie); - } - - if (! mvefile_fetch_next_chunk(movie->movie)) - return 0; - - /* return status */ - return 1; -} - -/************************************************************ - * private functions - ************************************************************/ - -/* - * allocate an MVEFILE - */ -static MVEFILE *_mvefile_alloc(void) -{ - MVEFILE *file = (MVEFILE *)malloc(sizeof(MVEFILE)); - file->stream = -1; - file->cur_chunk = NULL; - file->buf_size = 0; - file->cur_fill = 0; - file->next_segment = 0; - - return file; -} - -/* - * free an MVE file - */ -static void _mvefile_free(MVEFILE *movie) -{ - /* free the stream */ - if (movie->stream != -1) - close(movie->stream); - movie->stream = -1; - - /* free the buffer */ - if (movie->cur_chunk) - free(movie->cur_chunk); - movie->cur_chunk = NULL; - - /* not strictly necessary */ - movie->buf_size = 0; - movie->cur_fill = 0; - movie->next_segment = 0; - - /* free the struct */ - free(movie); -} - -static void _mvefile_free_filehandle(MVEFILE *movie) -{ - /* free the stream */ - movie->stream = -1; - - /* free the buffer */ - if (movie->cur_chunk) - free(movie->cur_chunk); - movie->cur_chunk = NULL; - - /* not strictly necessary */ - movie->buf_size = 0; - movie->cur_fill = 0; - movie->next_segment = 0; - - /* free the struct */ - free(movie); -} - -/* - * open the file stream in thie object - */ -static int _mvefile_open(MVEFILE *file, const char *filename) -{ -#ifdef O_BINARY - file->stream = open(filename, O_RDONLY | O_BINARY); -#else - file->stream = open(filename, O_RDONLY); -#endif - if (file->stream == -1) - return 0; - - return 1; -} - -static int _mvefile_open_filehandle(MVEFILE *file, int filehandle) -{ - file->stream = filehandle; - if (file->stream == -1) - return 0; - - return 1; -} - -/* - * allocate an MVEFILE - */ -static void _mvefile_reset(MVEFILE *file) -{ -#if 0 - file->cur_chunk = NULL; - file->buf_size = 0; - file->cur_fill = 0; - file->next_segment = 0; -#endif -} - -/* - * read and verify the header of the recently opened file - */ -static int _mvefile_read_header(MVEFILE *movie) -{ - unsigned char buffer[26]; - - /* check the file is open */ - if (movie->stream == -1) - return 0; - - /* check the file is long enough */ - if (read(movie->stream, buffer, 26) < 26) - return 0; - - /* check the signature */ - if (memcmp(buffer, MVE_HEADER, 20)) - return 0; - - /* check the hard-coded constants */ - if (_mve_get_short(buffer+20) != MVE_HDRCONST1) - return 0; - if (_mve_get_short(buffer+22) != MVE_HDRCONST2) - return 0; - if (_mve_get_short(buffer+24) != MVE_HDRCONST3) - return 0; - - return 1; -} - -static void _mvefile_set_buffer_size(MVEFILE *movie, int buf_size) -{ - unsigned char *new_buffer; - int new_len; - - /* check if this would be a redundant operation */ - if (buf_size <= movie->buf_size) - return; - - /* allocate new buffer */ - new_len = 100 + buf_size; - new_buffer = (unsigned char *)malloc(new_len); - - /* copy old data */ - if (movie->cur_chunk && movie->cur_fill) - memcpy(new_buffer, movie->cur_chunk, movie->cur_fill); - - /* free old buffer */ - if (movie->cur_chunk) - { - free(movie->cur_chunk); - movie->cur_chunk = 0; - } - - /* install new buffer */ - movie->cur_chunk = new_buffer; - movie->buf_size = new_len; -} - -static int _mvefile_fetch_next_chunk(MVEFILE *movie) -{ - unsigned char buffer[4]; - unsigned short length; - - /* fail if not open */ - if (movie->stream == -1) - return 0; - - /* fail if we can't read the next segment descriptor */ - if (read(movie->stream, buffer, 4) < 4) - return 0; - - /* pull out the next length */ - length = _mve_get_short(buffer); - - /* make sure we've got sufficient space */ - _mvefile_set_buffer_size(movie, length); - - /* read the chunk */ - if (read(movie->stream, movie->cur_chunk, length) < length) - return 0; - movie->cur_fill = length; - movie->next_segment = 0; - - return 1; -} - -static short _mve_get_short(unsigned char *data) -{ - short value; - value = data[0] | (data[1] << 8); - return value; -} - -static unsigned short _mve_get_ushort(unsigned char *data) -{ - unsigned short value; - value = data[0] | (data[1] << 8); - return value; -} - -/* - * allocate an MVESTREAM - */ -static MVESTREAM *_mvestream_alloc(void) -{ - MVESTREAM *movie; - - /* allocate and zero-initialize everything */ - movie = (MVESTREAM *)malloc(sizeof(MVESTREAM)); - movie->movie = NULL; - movie->context = 0; - memset(movie->handlers, 0, sizeof(movie->handlers)); - - return movie; -} - -/* - * free an MVESTREAM - */ -static void _mvestream_free(MVESTREAM *movie) -{ - /* close MVEFILE */ - if (movie->movie) - mvefile_close(movie->movie); - movie->movie = NULL; - - /* clear context and handlers */ - movie->context = NULL; - memset(movie->handlers, 0, sizeof(movie->handlers)); -} - -static void _mvestream_free_filehandle(MVESTREAM *movie) -{ - /* close MVEFILE */ - if (movie->movie) - mvefile_close_filehandle(movie->movie); - movie->movie = NULL; - - /* clear context and handlers */ - movie->context = NULL; - memset(movie->handlers, 0, sizeof(movie->handlers)); -} - -/* - * open an MVESTREAM object - */ -static int _mvestream_open(MVESTREAM *movie, const char *filename) -{ - movie->movie = mvefile_open(filename); - - return (movie->movie == NULL) ? 0 : 1; -} - -static int _mvestream_open_filehandle(MVESTREAM *movie, int filehandle) -{ - movie->movie = mvefile_open_filehandle(filehandle); - - return (movie->movie == NULL) ? 0 : 1; -} - -/* - * reset an MVESTREAM - */ -static void _mvestream_reset(MVESTREAM *movie) -{ - mvefile_reset(movie->movie); -} diff --git a/libmve/mvelib.h b/libmve/mvelib.h deleted file mode 100644 index 8e289094..00000000 --- a/libmve/mvelib.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef INCLUDED_MVELIB_H -#define INCLUDED_MVELIB_H - -#include -#include - -/* - * structure for maintaining info on a MVEFILE stream - */ -typedef struct MVEFILE -{ - int stream; - unsigned char *cur_chunk; - int buf_size; - int cur_fill; - int next_segment; -} MVEFILE; - -/* - * open a .MVE file - */ -MVEFILE *mvefile_open(const char *filename); -MVEFILE *mvefile_open_filehandle(int filehandle); - -/* - * close a .MVE file - */ -void mvefile_close(MVEFILE *movie); -void mvefile_close_filehandle(MVEFILE *movie); - -/* - * get size of next segment in chunk (-1 if no more segments in chunk) - */ -int mvefile_get_next_segment_size(MVEFILE *movie); - -/* - * get type of next segment in chunk (0xff if no more segments in chunk) - */ -unsigned char mvefile_get_next_segment_major(MVEFILE *movie); - -/* - * get subtype (version) of next segment in chunk (0xff if no more segments in - * chunk) - */ -unsigned char mvefile_get_next_segment_minor(MVEFILE *movie); - -/* - * see next segment (return NULL if no next segment) - */ -unsigned char *mvefile_get_next_segment(MVEFILE *movie); - -/* - * advance to next segment - */ -void mvefile_advance_segment(MVEFILE *movie); - -/* - * fetch the next chunk (return 0 if at end of stream) - */ -int mvefile_fetch_next_chunk(MVEFILE *movie); - -/* - * callback for segment type - */ -typedef int (*MVESEGMENTHANDLER)(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context); - -/* - * structure for maintaining an MVE stream - */ -typedef struct MVESTREAM -{ - MVEFILE *movie; - void *context; - MVESEGMENTHANDLER handlers[32]; -} MVESTREAM; - -/* - * open an MVE stream - */ -MVESTREAM *mve_open(const char *filename); -MVESTREAM *mve_open_filehandle(int filehandle); - -/* - * close an MVE stream - */ -void mve_close(MVESTREAM *movie); -void mve_close_filehandle(MVESTREAM *movie); - -/* - * reset an MVE stream - */ -void mve_reset(MVESTREAM *movie); - -/* - * set segment type handler - */ -void mve_set_handler(MVESTREAM *movie, unsigned char major, MVESEGMENTHANDLER handler); - -/* - * set segment handler context - */ -void mve_set_handler_context(MVESTREAM *movie, void *context); - -/* - * play next chunk - */ -int mve_play_next_chunk(MVESTREAM *movie); - -#endif /* INCLUDED_MVELIB_H */ diff --git a/libmve/mveplay.c b/libmve/mveplay.c deleted file mode 100644 index b377a394..00000000 --- a/libmve/mveplay.c +++ /dev/null @@ -1,945 +0,0 @@ -/* $Id: mveplay.c,v 1.11 2003-04-30 20:05:52 btb Exp $ */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifndef __MSDOS__ -#define AUDIO -#endif -//#define DEBUG - -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(STANDALONE) || defined(AUDIO) -#include -#endif - -#include "mvelib.h" -#include "mve_audio.h" - -#include "decoders.h" - -#ifndef STANDALONE -#include "libmve.h" -#include "u_mem.h" -#include "gr.h" -#include "palette.h" -#endif - -#ifdef STANDALONE -#define d_malloc(size) malloc(size) -#define d_free(ptr) free(ptr) -#endif - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -#define MVE_OPCODE_ENDOFSTREAM 0x00 -#define MVE_OPCODE_ENDOFCHUNK 0x01 -#define MVE_OPCODE_CREATETIMER 0x02 -#define MVE_OPCODE_INITAUDIOBUFFERS 0x03 -#define MVE_OPCODE_STARTSTOPAUDIO 0x04 -#define MVE_OPCODE_INITVIDEOBUFFERS 0x05 - -#define MVE_OPCODE_DISPLAYVIDEO 0x07 -#define MVE_OPCODE_AUDIOFRAMEDATA 0x08 -#define MVE_OPCODE_AUDIOFRAMESILENCE 0x09 -#define MVE_OPCODE_INITVIDEOMODE 0x0A - -#define MVE_OPCODE_SETPALETTE 0x0C -#define MVE_OPCODE_SETPALETTECOMPRESSED 0x0D - -#define MVE_OPCODE_SETDECODINGMAP 0x0F - -#define MVE_OPCODE_VIDEODATA 0x11 - -#define MVE_AUDIO_FLAGS_STEREO 1 -#define MVE_AUDIO_FLAGS_16BIT 2 -#define MVE_AUDIO_FLAGS_COMPRESSED 4 - -int g_spdFactorNum=0; -static int g_spdFactorDenom=10; -static int g_frameUpdated = 0; - -#ifdef STANDALONE -static int playing = 1; -int g_sdlVidFlags = SDL_ANYFORMAT | SDL_DOUBLEBUF; -int g_loop = 0; - -void initializeMovie(MVESTREAM *mve); -void playMovie(MVESTREAM *mve); -void shutdownMovie(MVESTREAM *mve); -#endif - -static short get_short(unsigned char *data) -{ - short value; - value = data[0] | (data[1] << 8); - return value; -} - -static unsigned short get_ushort(unsigned char *data) -{ - unsigned short value; - value = data[0] | (data[1] << 8); - return value; -} - -static int get_int(unsigned char *data) -{ - int value; - value = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); - return value; -} - -static unsigned int unhandled_chunks[32*256]; - -static int default_seg_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ - unhandled_chunks[major<<8|minor]++; - //fprintf(stderr, "unknown chunk type %02x/%02x\n", major, minor); - return 1; -} - - -/************************* - * general handlers - *************************/ -static int end_movie_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ - return 0; -} - -/************************* - * timer handlers - *************************/ - -/* - * timer variables - */ -static int timer_created = 0; -static int micro_frame_delay=0; -static int timer_started=0; -static struct timeval timer_expire = {0, 0}; - -#if !HAVE_STRUCT_TIMESPEC -struct timespec -{ - long int tv_sec; /* Seconds. */ - long int tv_nsec; /* Nanoseconds. */ -}; -#endif - -#if defined(HAVE_DECL_NANOSLEEP) && !HAVE_DECL_NANOSLEEP -int nanosleep(struct timespec *ts, void *rem); -#endif - -#ifdef __WIN32 -#include - -int gettimeofday(struct timeval *tv, void *tz) -{ - static int counter = 0; - struct timeb tm; - - counter++; /* to avoid collisions */ - ftime(&tm); - tv->tv_sec = tm.time; - tv->tv_usec = (tm.millitm * 1000) + counter; - - return 0; -} - -int nanosleep(struct timespec *ts, void *rem) -{ - _sleep(ts->tv_sec * 1000 + ts->tv_nsec / 1000000); - - return 0; -} -#endif - -static int create_timer_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ - __extension__ long long temp; - - if (timer_created) - return 1; - else - timer_created = 1; - - micro_frame_delay = get_int(data) * (int)get_short(data+4); - if (g_spdFactorNum != 0) - { - temp = micro_frame_delay; - temp *= g_spdFactorNum; - temp /= g_spdFactorDenom; - micro_frame_delay = (int)temp; - } - - return 1; -} - -static void timer_stop(void) -{ - timer_expire.tv_sec = 0; - timer_expire.tv_usec = 0; - timer_started = 0; -} - -static void timer_start(void) -{ - int nsec=0; - gettimeofday(&timer_expire, NULL); - timer_expire.tv_usec += micro_frame_delay; - if (timer_expire.tv_usec > 1000000) - { - nsec = timer_expire.tv_usec / 1000000; - timer_expire.tv_sec += nsec; - timer_expire.tv_usec -= nsec*1000000; - } - timer_started=1; -} - -static void do_timer_wait(void) -{ - int nsec=0; - struct timespec ts; - struct timeval tv; - if (! timer_started) - return; - - gettimeofday(&tv, NULL); - if (tv.tv_sec > timer_expire.tv_sec) - goto end; - else if (tv.tv_sec == timer_expire.tv_sec && tv.tv_usec >= timer_expire.tv_usec) - goto end; - - ts.tv_sec = timer_expire.tv_sec - tv.tv_sec; - ts.tv_nsec = 1000 * (timer_expire.tv_usec - tv.tv_usec); - if (ts.tv_nsec < 0) - { - ts.tv_nsec += 1000000000UL; - --ts.tv_sec; - } -#ifdef __CYGWIN__ - usleep(ts.tv_sec * 1000000 + ts.tv_nsec / 1000); -#else - if (nanosleep(&ts, NULL) == -1 && errno == EINTR) - exit(1); -#endif - - end: - timer_expire.tv_usec += micro_frame_delay; - if (timer_expire.tv_usec > 1000000) - { - nsec = timer_expire.tv_usec / 1000000; - timer_expire.tv_sec += nsec; - timer_expire.tv_usec -= nsec*1000000; - } -} - -/************************* - * audio handlers - *************************/ -#ifdef AUDIO -#define TOTAL_AUDIO_BUFFERS 64 - -static int audiobuf_created = 0; -static void mve_audio_callback(void *userdata, unsigned char *stream, int len); -static short *mve_audio_buffers[TOTAL_AUDIO_BUFFERS]; -static int mve_audio_buflens[TOTAL_AUDIO_BUFFERS]; -static int mve_audio_curbuf_curpos=0; -static int mve_audio_bufhead=0; -static int mve_audio_buftail=0; -static int mve_audio_playing=0; -static int mve_audio_canplay=0; -static int mve_audio_compressed=0; -static int mve_audio_enabled = 1; -static SDL_AudioSpec *mve_audio_spec=NULL; - -static void mve_audio_callback(void *userdata, unsigned char *stream, int len) -{ - int total=0; - int length; - if (mve_audio_bufhead == mve_audio_buftail) - return /* 0 */; - - //fprintf(stderr, "+ <%d (%d), %d, %d>\n", mve_audio_bufhead, mve_audio_curbuf_curpos, mve_audio_buftail, len); - - while (mve_audio_bufhead != mve_audio_buftail /* while we have more buffers */ - && len > (mve_audio_buflens[mve_audio_bufhead]-mve_audio_curbuf_curpos)) /* and while we need more data */ - { - length = mve_audio_buflens[mve_audio_bufhead]-mve_audio_curbuf_curpos; - memcpy(stream, /* cur output position */ - ((unsigned char *)mve_audio_buffers[mve_audio_bufhead])+mve_audio_curbuf_curpos, /* cur input position */ - length); /* cur input length */ - - total += length; - stream += length; /* advance output */ - len -= length; /* decrement avail ospace */ - d_free(mve_audio_buffers[mve_audio_bufhead]); /* free the buffer */ - mve_audio_buffers[mve_audio_bufhead]=NULL; /* free the buffer */ - mve_audio_buflens[mve_audio_bufhead]=0; /* free the buffer */ - - if (++mve_audio_bufhead == TOTAL_AUDIO_BUFFERS) /* next buffer */ - mve_audio_bufhead = 0; - mve_audio_curbuf_curpos = 0; - } - - //fprintf(stderr, "= <%d (%d), %d, %d>: %d\n", mve_audio_bufhead, mve_audio_curbuf_curpos, mve_audio_buftail, len, total); - /* return total; */ - - if (len != 0 /* ospace remaining */ - && mve_audio_bufhead != mve_audio_buftail) /* buffers remaining */ - { - memcpy(stream, /* dest */ - ((unsigned char *)mve_audio_buffers[mve_audio_bufhead]) + mve_audio_curbuf_curpos, /* src */ - len); /* length */ - - mve_audio_curbuf_curpos += len; /* advance input */ - stream += len; /* advance output (unnecessary) */ - len -= len; /* advance output (unnecessary) */ - - if (mve_audio_curbuf_curpos >= mve_audio_buflens[mve_audio_bufhead]) /* if this ends the current chunk */ - { - d_free(mve_audio_buffers[mve_audio_bufhead]); /* free buffer */ - mve_audio_buffers[mve_audio_bufhead]=NULL; - mve_audio_buflens[mve_audio_bufhead]=0; - - if (++mve_audio_bufhead == TOTAL_AUDIO_BUFFERS) /* next buffer */ - mve_audio_bufhead = 0; - mve_audio_curbuf_curpos = 0; - } - } - - //fprintf(stderr, "- <%d (%d), %d, %d>\n", mve_audio_bufhead, mve_audio_curbuf_curpos, mve_audio_buftail, len); -} -#endif - -static int create_audiobuf_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ -#ifdef AUDIO - int flags; - int sample_rate; - int desired_buffer; - - int stereo; - int bitsize; - int compressed; - - int format; - - if (!mve_audio_enabled) - return 1; - - if (audiobuf_created) - return 1; - else - audiobuf_created = 1; - - flags = get_ushort(data + 2); - sample_rate = get_ushort(data + 4); - desired_buffer = get_int(data + 6); - - stereo = (flags & MVE_AUDIO_FLAGS_STEREO) ? 1 : 0; - bitsize = (flags & MVE_AUDIO_FLAGS_16BIT) ? 1 : 0; - - if (minor > 0) { - compressed = flags & MVE_AUDIO_FLAGS_COMPRESSED ? 1 : 0; - } else { - compressed = 0; - } - - mve_audio_compressed = compressed; - - if (bitsize == 1) { -#ifdef WORDS_BIGENDIAN - format = AUDIO_S16MSB; -#else - format = AUDIO_S16LSB; -#endif - } else { - format = AUDIO_U8; - } - - fprintf(stderr, "creating audio buffers:\n"); - fprintf(stderr, "sample rate = %d, stereo = %d, bitsize = %d, compressed = %d\n", - sample_rate, stereo, bitsize ? 16 : 8, compressed); - - mve_audio_spec = (SDL_AudioSpec *)d_malloc(sizeof(SDL_AudioSpec)); - mve_audio_spec->freq = sample_rate; - mve_audio_spec->format = format; - mve_audio_spec->channels = (stereo) ? 2 : 1; - mve_audio_spec->samples = 4096; - mve_audio_spec->callback = mve_audio_callback; - mve_audio_spec->userdata = NULL; - if (SDL_OpenAudio(mve_audio_spec, NULL) >= 0) - { - fprintf(stderr, " success\n"); - mve_audio_canplay = 1; - } - else - { - fprintf(stderr, " failure : %s\n", SDL_GetError()); - mve_audio_canplay = 0; - } - - memset(mve_audio_buffers, 0, sizeof(mve_audio_buffers)); - memset(mve_audio_buflens, 0, sizeof(mve_audio_buflens)); -#endif - - return 1; -} - -static int play_audio_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ -#ifdef AUDIO - if (mve_audio_canplay && !mve_audio_playing && mve_audio_bufhead != mve_audio_buftail) - { - SDL_PauseAudio(0); - mve_audio_playing = 1; - } -#endif - return 1; -} - -static int audio_data_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ -#ifdef AUDIO - static const int selected_chan=1; - int chan; - int nsamp; - if (mve_audio_canplay) - { - if (mve_audio_playing) - SDL_LockAudio(); - - chan = get_ushort(data + 2); - nsamp = get_ushort(data + 4); - if (chan & selected_chan) - { - /* HACK: +4 mveaudio_uncompress adds 4 more bytes */ - if (major == MVE_OPCODE_AUDIOFRAMEDATA) { - if (mve_audio_compressed) { - nsamp += 4; - - mve_audio_buflens[mve_audio_buftail] = nsamp; - mve_audio_buffers[mve_audio_buftail] = (short *)d_malloc(nsamp); - mveaudio_uncompress(mve_audio_buffers[mve_audio_buftail], data, -1); /* XXX */ - } else { - nsamp -= 8; - data += 8; - - mve_audio_buflens[mve_audio_buftail] = nsamp; - mve_audio_buffers[mve_audio_buftail] = (short *)d_malloc(nsamp); - memcpy(mve_audio_buffers[mve_audio_buftail], data, nsamp); - } - } else { - mve_audio_buflens[mve_audio_buftail] = nsamp; - mve_audio_buffers[mve_audio_buftail] = (short *)d_malloc(nsamp); - - memset(mve_audio_buffers[mve_audio_buftail], 0, nsamp); /* XXX */ - } - - if (++mve_audio_buftail == TOTAL_AUDIO_BUFFERS) - mve_audio_buftail = 0; - - if (mve_audio_buftail == mve_audio_bufhead) - fprintf(stderr, "d'oh! buffer ring overrun (%d)\n", mve_audio_bufhead); - } - - if (mve_audio_playing) - SDL_UnlockAudio(); - } -#endif - - return 1; -} - -/************************* - * video handlers - *************************/ -static int videobuf_created = 0; -static int video_initialized = 0; -int g_width, g_height; -void *g_vBuffers = NULL, *g_vBackBuf1, *g_vBackBuf2; - -#ifdef STANDALONE -static SDL_Surface *g_screen; -#else -static int g_destX, g_destY; -#endif -static int g_screenWidth, g_screenHeight; -static unsigned char g_palette[768]; -static unsigned char *g_pCurMap=NULL; -static int g_nMapLength=0; -static int g_truecolor; - -static int create_videobuf_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ - short w, h; - short count, truecolor; - - if (videobuf_created) - return 1; - else - videobuf_created = 1; - - w = get_short(data); - h = get_short(data+2); - - if (minor > 0) { - count = get_short(data+4); - } else { - count = 1; - } - - if (minor > 1) { - truecolor = get_short(data+6); - } else { - truecolor = 0; - } - - g_width = w << 3; - g_height = h << 3; - - /* TODO: * 4 causes crashes on some files */ - g_vBackBuf1 = g_vBuffers = d_malloc(g_width * g_height * 8); - if (truecolor) { - g_vBackBuf2 = (unsigned short *)g_vBackBuf1 + (g_width * g_height); - } else { - g_vBackBuf2 = (unsigned char *)g_vBackBuf1 + (g_width * g_height); - } - - memset(g_vBackBuf1, 0, g_width * g_height * 4); - -#ifdef DEBUG - fprintf(stderr, "DEBUG: w,h=%d,%d count=%d, tc=%d\n", w, h, count, truecolor); -#endif - - g_truecolor = truecolor; - - return 1; -} - -#ifdef STANDALONE -static int do_sdl_events() -{ - SDL_Event event; - int retr = 0; - while (SDL_PollEvent(&event)) { - switch(event.type) { - case SDL_QUIT: - playing=0; - break; - case SDL_KEYDOWN: - if (event.key.keysym.sym == SDLK_ESCAPE) - playing=0; - break; - case SDL_KEYUP: - retr = 1; - break; - case SDL_MOUSEBUTTONDOWN: - /* - if (event.button.button == SDL_BUTTON_LEFT) { - printf("GRID: %d,%d (pix:%d,%d)\n", - event.button.x / 16, event.button.y / 8, - event.button.x, event.button.y); - } - */ - break; - default: - break; - } - } - - return retr; -} - -static void ConvertAndDraw() -{ - int i; - unsigned char *pal = g_palette; - unsigned char *pDest; - unsigned char *pixels = g_vBackBuf1; - SDL_Surface *screenSprite, *initSprite; - SDL_Rect renderArea; - int x, y; - - initSprite = SDL_CreateRGBSurface(SDL_SWSURFACE, g_width, g_height, g_truecolor?16:8, 0x7C00, 0x03E0, 0x001F, 0); - - if (!g_truecolor) { - for(i = 0; i < 256; i++) { - initSprite->format->palette->colors[i].r = (*pal++) << 2; - initSprite->format->palette->colors[i].g = (*pal++) << 2; - initSprite->format->palette->colors[i].b = (*pal++) << 2; - initSprite->format->palette->colors[i].unused = 0; - } - } - - pDest = initSprite->pixels; - - if (0 /*g_truecolor*/) { - - unsigned short *pSrcs, *pDests; - - pSrcs = (unsigned short *)pixels; - pDests = (unsigned short *)pDest; - - for (y=0; ypitch; - } - } - - screenSprite = SDL_DisplayFormat(initSprite); - SDL_FreeSurface(initSprite); - - if (g_screenWidth > screenSprite->w) - x = (g_screenWidth - screenSprite->w) >> 1; - else - x=0; - if (g_screenHeight > screenSprite->h) - y = (g_screenHeight - screenSprite->h) >> 1; - else - y=0; - renderArea.x = x; - renderArea.y = y; - renderArea.w = MIN(g_screenWidth - x, screenSprite->w); - renderArea.h = MIN(g_screenHeight - y, screenSprite->h); - SDL_BlitSurface(screenSprite, NULL, g_screen, &renderArea); - - SDL_FreeSurface(screenSprite); -} -#endif - -static int display_video_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ -#ifdef STANDALONE - ConvertAndDraw(); - - SDL_Flip(g_screen); - - do_sdl_events(); -#else - grs_bitmap *bitmap; - - bitmap = gr_create_bitmap_raw(g_width, g_height, g_vBackBuf1); - - if (g_destX == -1) // center it - g_destX = (g_screenWidth - g_width) >> 1; - if (g_destY == -1) // center it - g_destY = (g_screenHeight - g_height) >> 1; - - gr_palette_load(g_palette); - - gr_bitmap(g_destX, g_destY, bitmap); - - gr_free_sub_bitmap(bitmap); -#endif - g_frameUpdated = 1; - - return 1; -} - -static int init_video_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ - short width, height; - - if (video_initialized) - return 1; - else - video_initialized = 1; - - width = get_short(data); - height = get_short(data+2); -#ifdef STANDALONE - g_screen = SDL_SetVideoMode(width, height, 16, g_sdlVidFlags); -#endif - g_screenWidth = width; - g_screenHeight = height; - memset(g_palette, 0, 765); - // 255 needs to default to white, for subtitles, etc - memset(g_palette + 765, 63, 3); - - return 1; -} - -static int video_palette_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ - short start, count; - start = get_short(data); - count = get_short(data+2); - memcpy(g_palette + 3*start, data+4, 3*count); - - return 1; -} - -static int video_codemap_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ - g_pCurMap = data; - g_nMapLength = len; - return 1; -} - -static int video_data_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ - short nFrameHot, nFrameCold; - short nXoffset, nYoffset; - short nXsize, nYsize; - unsigned short nFlags; - unsigned char *temp; - - nFrameHot = get_short(data); - nFrameCold = get_short(data+2); - nXoffset = get_short(data+4); - nYoffset = get_short(data+6); - nXsize = get_short(data+8); - nYsize = get_short(data+10); - nFlags = get_ushort(data+12); - - if (nFlags & 1) - { - temp = (unsigned char *)g_vBackBuf1; - g_vBackBuf1 = g_vBackBuf2; - g_vBackBuf2 = temp; - } - - /* convert the frame */ - if (g_truecolor) { - decodeFrame16((unsigned char *)g_vBackBuf1, g_pCurMap, g_nMapLength, data+14, len-14); - } else { - decodeFrame8(g_vBackBuf1, g_pCurMap, g_nMapLength, data+14, len-14); - } - - return 1; -} - -static int end_chunk_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) -{ - g_pCurMap=NULL; - return 1; -} - - -#ifdef STANDALONE -void initializeMovie(MVESTREAM *mve) -{ - int i; - - for (i = 0; i < 32; i++) - mve_set_handler(mve, i, default_seg_handler); - - memset(unhandled_chunks, 0, 32*256); - - mve_set_handler(mve, MVE_OPCODE_ENDOFSTREAM, end_movie_handler); - mve_set_handler(mve, MVE_OPCODE_ENDOFCHUNK, end_chunk_handler); - mve_set_handler(mve, MVE_OPCODE_CREATETIMER, create_timer_handler); - mve_set_handler(mve, MVE_OPCODE_INITAUDIOBUFFERS, create_audiobuf_handler); - mve_set_handler(mve, MVE_OPCODE_STARTSTOPAUDIO, play_audio_handler); - mve_set_handler(mve, MVE_OPCODE_INITVIDEOBUFFERS, create_videobuf_handler); - - mve_set_handler(mve, MVE_OPCODE_DISPLAYVIDEO, display_video_handler); - mve_set_handler(mve, MVE_OPCODE_AUDIOFRAMEDATA, audio_data_handler); - mve_set_handler(mve, MVE_OPCODE_AUDIOFRAMESILENCE, audio_data_handler); - mve_set_handler(mve, MVE_OPCODE_INITVIDEOMODE, init_video_handler); - - mve_set_handler(mve, MVE_OPCODE_SETPALETTE, video_palette_handler); - mve_set_handler(mve, MVE_OPCODE_SETPALETTECOMPRESSED, video_palette_handler); - mve_set_handler(mve, MVE_OPCODE_SETDECODINGMAP, video_codemap_handler); - - mve_set_handler(mve, MVE_OPCODE_VIDEODATA, video_data_handler); -} - -void playMovie(MVESTREAM *mve) -{ - int init_timer=0; - int cont=1; - - mve_audio_enabled = 1; - - while (cont && playing) - { - cont = mve_play_next_chunk(mve); - if (micro_frame_delay && !init_timer) - { - timer_start(); - init_timer = 1; - } - - do_timer_wait(); - - if (g_loop && !cont) { - mve_reset(mve); - cont = 1; - } - } -} - -void shutdownMovie(MVESTREAM *mve) -{ -#ifdef DEBUG - int i; -#endif - - timer_stop(); - -#ifdef DEBUG - for (i = 0; i < 32*256; i++) { - if (unhandled_chunks[i]) { - fprintf(stderr, "unhandled chunks of type %02x/%02x: %d\n", i>>8, i&0xFF, unhandled_chunks[i]); - } - } -#endif -} - -#else -static MVESTREAM *mve = NULL; - -int MVE_rmPrepMovie(int filehandle, int x, int y, int track) -{ - int i; - - if (mve) { - mve_reset(mve); - return 0; - } - - mve = mve_open_filehandle(filehandle); - - if (!mve) - return 1; - - g_destX = x; - g_destY = y; - - for (i = 0; i < 32; i++) - mve_set_handler(mve, i, default_seg_handler); - - mve_set_handler(mve, MVE_OPCODE_ENDOFSTREAM, end_movie_handler); - mve_set_handler(mve, MVE_OPCODE_ENDOFCHUNK, end_chunk_handler); - mve_set_handler(mve, MVE_OPCODE_CREATETIMER, create_timer_handler); - mve_set_handler(mve, MVE_OPCODE_INITAUDIOBUFFERS, create_audiobuf_handler); - mve_set_handler(mve, MVE_OPCODE_STARTSTOPAUDIO, play_audio_handler); - mve_set_handler(mve, MVE_OPCODE_INITVIDEOBUFFERS, create_videobuf_handler); - - mve_set_handler(mve, MVE_OPCODE_DISPLAYVIDEO, display_video_handler); - mve_set_handler(mve, MVE_OPCODE_AUDIOFRAMEDATA, audio_data_handler); - mve_set_handler(mve, MVE_OPCODE_AUDIOFRAMESILENCE, audio_data_handler); - mve_set_handler(mve, MVE_OPCODE_INITVIDEOMODE, init_video_handler); - - mve_set_handler(mve, MVE_OPCODE_SETPALETTE, video_palette_handler); - mve_set_handler(mve, MVE_OPCODE_SETPALETTECOMPRESSED, default_seg_handler); - - mve_set_handler(mve, MVE_OPCODE_SETDECODINGMAP, video_codemap_handler); - - mve_set_handler(mve, MVE_OPCODE_VIDEODATA, video_data_handler); - - return 0; -} - -int MVE_rmStepMovie() -{ - static int init_timer=0; - int cont=1; - - if (!timer_started) - timer_start(); - - while (cont && !g_frameUpdated) // make a "step" be a frame, not a chunk... - cont = mve_play_next_chunk(mve); - g_frameUpdated = 0; - - if (micro_frame_delay && !init_timer) { - timer_start(); - init_timer = 1; - } - - do_timer_wait(); - - if (cont) - return 0; - else - return MVE_ERR_EOF; -} - -void MVE_rmEndMovie() -{ -#ifdef AUDIO - int i; -#endif - - timer_stop(); - timer_created = 0; - -#ifdef AUDIO - if (mve_audio_canplay) { - // only close audio if we opened it - SDL_CloseAudio(); - mve_audio_canplay = 0; - } - for (i = 0; i < TOTAL_AUDIO_BUFFERS; i++) - if (mve_audio_buffers[i] != NULL) - d_free(mve_audio_buffers[i]); - memset(mve_audio_buffers, 0, sizeof(mve_audio_buffers)); - memset(mve_audio_buflens, 0, sizeof(mve_audio_buflens)); - mve_audio_curbuf_curpos=0; - mve_audio_bufhead=0; - mve_audio_buftail=0; - mve_audio_playing=0; - mve_audio_canplay=0; - mve_audio_compressed=0; - if (mve_audio_spec) - d_free(mve_audio_spec); - mve_audio_spec=NULL; - audiobuf_created = 0; -#endif - - d_free(g_vBuffers); - g_vBuffers = NULL; - g_pCurMap=NULL; - g_nMapLength=0; - videobuf_created = 0; - video_initialized = 0; - - mve_close_filehandle(mve); - mve = NULL; -} - - -void MVE_rmHoldMovie() -{ - timer_started = 0; -} - - -void MVE_sndInit(int x) -{ -#ifdef AUDIO - if (x == -1) - mve_audio_enabled = 0; - else - mve_audio_enabled = 1; -#endif -} - -#endif diff --git a/debian/copyright b/license.txt similarity index 54% rename from debian/copyright rename to license.txt index 0d7b331e..f4762929 100644 --- a/debian/copyright +++ b/license.txt @@ -1,39 +1,3 @@ -This package was debianized by Bradley Bell on -Tue, 5 Feb 2002 22:16:01 -0800. - -It was downloaded from - -Copyright: - -The Descent 2 source code was released by Parallax with this license: ---------------------------------------------------------------------------- - -THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX -SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO -END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A -ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS -IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS -SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE -FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE -CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. - -We make no warranties as to the usability or correctness of this code. - ---------------------------------------------------------------------------- - -The modifications to Descent 2 which make up d2x are covered by the -same license as the d1x project, given below. - -There used to be an additional clause here, but it was functionally -equivalent to the d1x license, and the d1x license would override it -anyway, so it has been removed. - ---------------------------------------------------------------------------- - D1x License Preamble @@ -78,3 +42,4 @@ following added restrictions: 3) D1X IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + diff --git a/main/.cvsignore b/main/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/main/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/main/Makefile.am b/main/Makefile.am index bc57cadb..5de0e4b0 100644 --- a/main/Makefile.am +++ b/main/Makefile.am @@ -6,49 +6,60 @@ EXTRA_SUBDIRS = old noinst_LIBRARIES = libmain.a -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/arch/include +INCLUDES = -I$(top_srcdir)/includes -I$(top_srcdir)/arch/include + +CFLAGS += -fwritable-strings if USE_NETWORK -NETWORK_SRCS = kmatrix.c multi.c multibot.c network.c netmisc.c +NETWORK_SRCS = ipx_drv.c kmatrix.c multi.c multibot.c network.c endif if EDITOR EDITOR_SRCS = bmread.c endif -libmain_a_SOURCES = ${EDITOR_SRCS} ${NETWORK_SRCS} \ -ai.c ai2.c aipath.c automap.c bm.c \ -cmd.c cntrlcen.c collide.c config.c console.c \ -controls.c credits.c crypt.c effects.c endlevel.c \ -escort.c fireball.c fuelcen.c fvi.c game.c \ -gamecntl.c gamefont.c gamemine.c gamepal.c gamerend.c \ -gamesave.c gameseg.c gameseq.c gauges.c hostage.c \ -hud.c inferno.c kconfig.c kludge.c laser.c \ -lighting.c menu.c mglobal.c mission.c morph.c \ -movie.c \ -newdemo.c newmenu.c object.c paging.c physics.c \ -piggy.c player.c playsave.c polyobj.c powerup.c \ -render.c robot.c scores.c segment.c slew.c \ -songs.c state.c switch.c terrain.c texmerge.c \ -text.c titles.c vclip.c wall.c weapon.c +if SHAREWARE +SHAREWARE_SRCS = terrain.c +endif + +if MOVIE_TRICK +MOVIE_SRCS = movie.c +endif + +libmain_a_SOURCES = \ +${EDITOR_SRCS} ${NETWORK_SRCS} ${SHAREWARE_SRCS} ${MOVIE_SRCS} \ +ai.c gamerend.c lighting.c paging.c switch.c \ +ai2.c effects.c gamesave.c menu.c physics.c texmerge.c \ +aipath.c endlevel.c gameseg.c mglobal.c piggy.c text.c \ +automap.c escort.c gameseq.c mission.c playsave.c titles.c \ +bm.c fireball.c gauges.c morph.c polyobj.c vclip.c \ +fuelcen.c hostage.c powerup.c wall.c \ +cntrlcen.c fvi.c hud.c render.c weapon.c \ +collide.c game.c inferno.c netmisc.c robot.c \ +config.c gamecntl.c kconfig.c scores.c \ +controls.c gamefont.c kludge.c newdemo.c slew.c \ +credits.c gamemine.c newmenu.c songs.c \ +crypt.c gamepal.c laser.c object.c state.c \ +console.c cmd.c EXTRA_libmain_a_SOURCES = \ -kmatrix.c multi.c multibot.c network.c netmisc.c \ -bmread.c +ipx_drv.c kmatrix.c multi.c multibot.c network.c \ +bmread.c \ +terrain.c \ +movie.c EXTRA_DIST = ${EXTRA_SUBDIRS} \ descent.cfg inferno.ini \ link.bat \ -ai.h aistruct.h automap.h bm.h bmread.h cntrlcen.h collide.h \ -compbit.h config.h controls.h credits.h desc_id.h desw.h digi.h \ -effects.h endlevel.h escort.h \ -fireball.h fuelcen.h fvi.h fvi_a.h game.h gamefont.h gamemine.h \ -gamepal.h gamesave.h gameseg.h gameseq.h gamestat.h gauges.h \ -hostage.h hudmsg.h inferno.h joydefs.h kconfig.h \ -kmatrix.h laser.h lighting.h menu.h mission.h modem.h morph.h movie.h multi.h \ -multibot.h netmisc.h network.h newdemo.h newmenu.h \ -object.h paging.h physics.h piggy.h player.h playsave.h polyobj.h powerup.h \ -render.h reorder.h robot.h scores.h screens.h segment.h segpoint.h slew.h \ +ai.h aistruct.h automap.h bm.h bmread.h cdrom.h cntrlcen.h collide.h \ +compbit.h config.h controls.h credits.h desc_id.h desw.h digi.h effects.h \ +endlevel.h fireball.h fuelcen.h fvi.h fvi_a.h game.h gamefont.h gamemine.h \ +gamepal.h gamesave.h gameseg.h gameseq.h gamestat.h gauges.h hostage.h \ +hudmsg.h \ +inferno.h joydefs.h kconfig.h kmatrix.h laser.h lighting.h menu.h mission.h \ +modem.h morph.h movie.h multi.h multibot.h netmisc.h network.h newdemo.h \ +newmenu.h object.h paging.h physics.h piggy.h player.h playsave.h polyobj.h \ +powerup.h render.h robot.h scores.h screens.h segment.h segpoint.h slew.h \ songs.h sounds.h state.h switch.h terrain.h texmerge.h text.h textures.h \ titles.h vclip.h vers_id.h wall.h weapon.h \ -dumpmine.c joydefs.c +dumpmine.c ipx_drv.c diff --git a/main/ai.c b/main/ai.c index eb82ae03..0287b1e9 100644 --- a/main/ai.c +++ b/main/ai.c @@ -1,4 +1,3 @@ -/* $Id: ai.c,v 1.5 2003-03-14 21:24:03 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,267 +7,16 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Autonomous Individual movement. - * - * Old Log: - * Revision 1.1 1995/12/05 14:15:37 allender - * Initial revision - * - * Revision 1.10 1995/11/09 09:36:12 allender - * cheats not active during demo playback - * - * Revision 1.9 1995/11/03 12:51:55 allender - * shareware changes - * - * Revision 1.8 1995/10/31 10:25:07 allender - * shareware stuff - * - * Revision 1.7 1995/10/26 14:01:38 allender - * optimization for doing robot stuff only if anim angles done last frame - * - * Revision 1.6 1995/10/25 09:35:43 allender - * prototype some functions causing mcc problems - * - * Revision 1.5 1995/10/17 13:11:40 allender - * fix in ai code that makes bots only look for you every so often - * - * Revision 1.4 1995/10/10 11:48:10 allender - * PC ai code - * - * Revision 2.11 1995/07/09 11:15:48 john - * Put in Mike's code to fix bug where bosses don't gate in bots after - * 32767 seconds of playing. - * - * Revision 2.10 1995/06/15 12:31:08 john - * Fixed bug with cheats getting enabled when you type - * the whole alphabet. - * - * Revision 2.9 1995/05/26 16:16:18 john - * Split SATURN into define's for requiring cd, using cd, etc. - * Also started adding all the Rockwell stuff. - * - * Revision 2.8 1995/04/06 15:12:27 john - * Fixed bug with insane not working. - * - * Revision 2.7 1995/03/30 16:36:44 mike - * text localization. - * - * Revision 2.6 1995/03/28 11:22:24 john - * Added cheats to save file. Changed lunacy text. - * - * Revision 2.5 1995/03/27 16:45:07 john - * Fixed some cheat bugs. Added astral cheat. - * - * Revision 2.4 1995/03/24 15:29:17 mike - * add new cheats. - * - * Revision 2.3 1995/03/21 14:39:45 john - * Ifdef'd out the NETWORK code. - * - * Revision 2.2 1995/03/14 18:24:39 john - * Force Destination Saturn to use CD-ROM drive. - * - * Revision 2.1 1995/03/06 16:47:14 mike - * destination saturn - * - * Revision 2.0 1995/02/27 11:30:01 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.295 1995/02/22 13:23:04 allender - * remove anonymous unions from object structure - * - * Revision 1.294 1995/02/13 11:00:43 rob - * Make brain guys high enough to get an open slot. - * - * Revision 1.293 1995/02/13 10:31:55 mike - * Make brains understand they can't open locked doors. - * - * Revision 1.292 1995/02/13 10:18:01 rob - * Reduced brain guy's level of awareness to keep him from hogging slots. - * - * Revision 1.291 1995/02/11 12:27:12 mike - * fix path-to-exit cheat. - * - * Revision 1.290 1995/02/11 01:56:30 mike - * robots don't fire cheat. - * - * Revision 1.289 1995/02/10 17:15:09 rob - * Fixed some stuff with 64 awareness stuff. - * - * Revision 1.288 1995/02/10 16:31:32 mike - * oops. - * - * Revision 1.287 1995/02/10 16:24:45 mike - * fix the network follow path fix. - * - * Revision 1.286 1995/02/10 16:11:40 mike - * in serial or modem games, follow path guys don't move if far away and - * can't see player. - * - * Revision 1.285 1995/02/09 13:11:35 mike - * comment out a bunch of mprintfs. - * add toaster (drops prox bombs, runs away) to boss gate list. - * - * Revision 1.284 1995/02/08 22:44:53 rob - * Lowerd anger level for follow path of any sort. - * - * Revision 1.283 1995/02/08 22:30:43 mike - * lower awareness on station guys if they are returning home (multiplayer). - * - * Revision 1.282 1995/02/08 17:01:06 rob - * Fixed problem with toasters dropping of proximity bombs. - * - * Revision 1.281 1995/02/08 11:49:35 rob - * Reduce Green-guy attack awareness level so we don't let him attack us too. - * - * Revision 1.280 1995/02/08 11:37:52 mike - * Check for failures in call to obj_create. - * - * Revision 1.279 1995/02/07 20:38:46 mike - * fix toasters in multiplayer - * - * - * Revision 1.278 1995/02/07 16:51:07 mike - * fix sound time play bug. - * - * Revision 1.277 1995/02/06 22:33:04 mike - * make robots follow path better in cooperative/roboarchy. - * - * Revision 1.276 1995/02/06 18:15:42 rob - * Added forced sends for evasion movemnet. - * - * Revision 1.275 1995/02/06 16:41:22 rob - * Change some positioning calls. - * - * Revision 1.274 1995/02/06 11:40:33 mike - * replace some lint-related hacks with clean, proper code. - * - * Revision 1.273 1995/02/04 17:28:19 mike - * make station guys return better. - * - * Revision 1.272 1995/02/03 17:40:55 mike - * fix problem with robots falling asleep if you sit in game overnight, not in pause...bah. - * - * Revision 1.271 1995/02/02 21:11:25 rob - * Tweaking stuff for multiplayer ai. - * - * Revision 1.270 1995/02/02 17:32:06 john - * Added Hack for Assert that Mike put in after using Lint to find - * uninitialized variables. - * - * Revision 1.269 1995/02/02 16:46:31 mike - * fix boss gating. - * - * Revision 1.268 1995/02/02 16:27:29 mike - * make boss not put out infinite robots. - * - * Revision 1.267 1995/02/01 21:10:02 mike - * lint found bug! player_visibility not initialized! - * - * Revision 1.266 1995/02/01 20:51:27 john - * Lintized - * - * Revision 1.265 1995/02/01 17:14:05 mike - * fix robot sounds. - * - * Revision 1.264 1995/01/31 16:16:40 mike - * Comment out "Darn you, John" Int3(). - * - * Revision 1.263 1995/01/30 20:55:04 mike - * fix nonsense in robot firing when a player is cloaked. - * - * Revision 1.262 1995/01/30 17:15:10 rob - * Fixed problems with bigboss eclip messages. - * Tweaked robot position sending for modem purposes. - * - * Revision 1.261 1995/01/30 15:30:31 rob - * Prevent non-master players from gating in robots. - * - * Revision 1.260 1995/01/30 13:30:55 mike - * new cases for firing at other players were bogus, could send position - * without permission. - * - * Revision 1.259 1995/01/30 13:01:17 mike - * Make robots fire at player other than one they are controlled by sometimes. - * - * Revision 1.258 1995/01/29 16:09:17 rob - * Trying to get robots to shoot at non-controlling players. - * - * Revision 1.257 1995/01/29 13:47:05 mike - * Make boss have more fireballs on death, have until end (though silent at end). - * Fix bug which was preventing him from teleporting until hit, so he'd always - * be in the same place when the player enters the room. - * - * Revision 1.256 1995/01/28 17:40:18 mike - * make boss teleport & gate before you see him. - * - * Revision 1.255 1995/01/27 17:02:08 mike - * move code around, was sending one frame (or worse!) old robot information. - * - * Revision 1.254 1995/01/26 17:02:43 mike - * make fusion cannon have more chrome, make fusion, mega rock you! - * - * Revision 1.253 1995/01/26 15:11:17 rob - * Shutup! I fixed it! - * - * Revision 1.252 1995/01/26 15:08:55 rob - * Changed robot gating to accomodate multiplayer. - * - * Revision 1.251 1995/01/26 14:49:04 rob - * Increase awareness level for firing to 94. - * - * Revision 1.250 1995/01/26 12:41:20 mike - * fix bogus multiplayer code, would send permission without getting permission. - * - * Revision 1.249 1995/01/26 12:23:23 rob - * Removed defines that were moved to ai.h - * - * Revision 1.248 1995/01/25 23:38:48 mike - * modify list of robots gated in by super boss. - * - * Revision 1.247 1995/01/25 21:21:13 rob - * Trying to let robots fire at a player even if they're not in control. - * - * Revision 1.246 1995/01/25 13:50:37 mike - * Robots make angry sounds. - * - * Revision 1.245 1995/01/25 10:53:47 mike - * better handling of robots which poke out of mine and try to recover. - * - * Revision 1.244 1995/01/24 22:03:02 mike - * Tricky code to move a robot to a legal position if he is poking out of - * the mine, even if it means moving him to another segment. - * - * Revision 1.243 1995/01/24 20:12:06 rob - * Changed robot fire awareness level from 74 to 94. - * - * Revision 1.242 1995/01/24 13:22:32 mike - * make robots accelerate faster, and Difficulty_level dependent. - * - * Revision 1.241 1995/01/24 12:09:39 mike - * make robots animate in multiplayer. - * - * Revision 1.240 1995/01/21 21:21:10 mike - * Make boss only gate robots into specified segments. - * - * Revision 1.239 1995/01/20 20:21:26 mike - * prevent unnecessary boss cloaking. - * - */ - #ifdef HAVE_CONFIG_H #include #endif -char ai_rcsid[] = "$Id: ai.c,v 1.5 2003-03-14 21:24:03 btb Exp $"; +char ai_rcsid[] = "$Id: ai.c,v 1.3 2001-10-25 02:15:55 bradleyb Exp $"; #include #include @@ -323,68 +71,68 @@ char ai_rcsid[] = "$Id: ai.c,v 1.5 2003-03-14 21:24:03 btb Exp $"; #include #endif -// ---------- John: These variables must be saved as part of gamesave. -------- -int Ai_initialized = 0; -int Overall_agitation; -ai_local Ai_local_info[MAX_OBJECTS]; -point_seg Point_segs[MAX_POINT_SEGS]; -point_seg *Point_segs_free_ptr = Point_segs; -ai_cloak_info Ai_cloak_info[MAX_AI_CLOAK_INFO]; -fix Boss_cloak_start_time = 0; -fix Boss_cloak_end_time = 0; -fix Last_teleport_time = 0; -fix Boss_teleport_interval = F1_0*8; -fix Boss_cloak_interval = F1_0*10; // Time between cloaks -fix Boss_cloak_duration = BOSS_CLOAK_DURATION; -fix Last_gate_time = 0; -fix Gate_interval = F1_0*6; -fix Boss_dying_start_time; -fix Boss_hit_time; -byte Boss_dying, Boss_dying_sound_playing, unused123, unused234; +// ---------- John: These variables must be saved as part of gamesave. ---------- +int Ai_initialized = 0; +int Overall_agitation; +ai_local Ai_local_info[MAX_OBJECTS]; +point_seg Point_segs[MAX_POINT_SEGS]; +point_seg *Point_segs_free_ptr = Point_segs; +ai_cloak_info Ai_cloak_info[MAX_AI_CLOAK_INFO]; +fix Boss_cloak_start_time = 0; +fix Boss_cloak_end_time = 0; +fix Last_teleport_time = 0; +fix Boss_teleport_interval = F1_0*8; +fix Boss_cloak_interval = F1_0*10; // Time between cloaks +fix Boss_cloak_duration = BOSS_CLOAK_DURATION; +fix Last_gate_time = 0; +fix Gate_interval = F1_0*6; +fix Boss_dying_start_time; +fix Boss_hit_time; +byte Boss_dying, Boss_dying_sound_playing, unused123, unused234; -// -- MK, 10/21/95, unused! -- int Boss_been_hit=0; +// -- MK, 10/21/95, unused! -- int Boss_been_hit=0; -// ------ John: End of variables which must be saved as part of gamesave. ----- +// ---------- John: End of variables which must be saved as part of gamesave. ---------- -// -- ubyte Boss_cloaks[NUM_D2_BOSSES] = {1,1,1,1,1,1}; // Set byte if this boss can cloak +// -- ubyte Boss_cloaks[NUM_D2_BOSSES] = {1,1,1,1,1,1}; // Set byte if this boss can cloak -ubyte Boss_teleports[NUM_D2_BOSSES] = {1,1,1,1,1,1, 1,1}; // Set byte if this boss can teleport -ubyte Boss_spew_more[NUM_D2_BOSSES] = {0,1,0,0,0,0, 0,0}; // If set, 50% of time, spew two bots. -ubyte Boss_spews_bots_energy[NUM_D2_BOSSES] = {1,1,0,1,0,1, 1,1}; // Set byte if boss spews bots when hit by energy weapon. -ubyte Boss_spews_bots_matter[NUM_D2_BOSSES] = {0,0,1,1,1,1, 0,1}; // Set byte if boss spews bots when hit by matter weapon. -ubyte Boss_invulnerable_energy[NUM_D2_BOSSES] = {0,0,1,1,0,0, 0,0}; // Set byte if boss is invulnerable to energy weapons. -ubyte Boss_invulnerable_matter[NUM_D2_BOSSES] = {0,0,0,0,1,1, 1,0}; // Set byte if boss is invulnerable to matter weapons. -ubyte Boss_invulnerable_spot[NUM_D2_BOSSES] = {0,0,0,0,0,1, 0,1}; // Set byte if boss is invulnerable in all but a certain spot. (Dot product fvec|vec_to_collision < BOSS_INVULNERABLE_DOT) +ubyte Boss_teleports[NUM_D2_BOSSES] = {1,1,1,1,1,1, 1,1}; // Set byte if this boss can teleport +ubyte Boss_spew_more[NUM_D2_BOSSES] = {0,1,0,0,0,0, 0,0}; // If set, 50% of time, spew two bots. +ubyte Boss_spews_bots_energy[NUM_D2_BOSSES] = {1,1,0,1,0,1, 1,1}; // Set byte if boss spews bots when hit by energy weapon. +ubyte Boss_spews_bots_matter[NUM_D2_BOSSES] = {0,0,1,1,1,1, 0,1}; // Set byte if boss spews bots when hit by matter weapon. +ubyte Boss_invulnerable_energy[NUM_D2_BOSSES] = {0,0,1,1,0,0, 0,0}; // Set byte if boss is invulnerable to energy weapons. +ubyte Boss_invulnerable_matter[NUM_D2_BOSSES] = {0,0,0,0,1,1, 1,0}; // Set byte if boss is invulnerable to matter weapons. +ubyte Boss_invulnerable_spot[NUM_D2_BOSSES] = {0,0,0,0,0,1, 0,1}; // Set byte if boss is invulnerable in all but a certain spot. (Dot product fvec|vec_to_collision < BOSS_INVULNERABLE_DOT) -int ai_evaded=0; +int ai_evaded=0; -// -- byte Super_boss_gate_list[MAX_GATE_INDEX] = {0, 1, 8, 9, 10, 11, 12, 15, 16, 18, 19, 20, 22, 0, 8, 11, 19, 20, 8, 20, 8}; +// -- byte Super_boss_gate_list[MAX_GATE_INDEX] = {0, 1, 8, 9, 10, 11, 12, 15, 16, 18, 19, 20, 22, 0, 8, 11, 19, 20, 8, 20, 8}; -int Robot_firing_enabled = 1; -int Animation_enabled = 1; +int Robot_firing_enabled = 1; +int Animation_enabled = 1; #ifndef NDEBUG -int Ai_info_enabled=0; +int Ai_info_enabled=0; #endif -// These globals are set by a call to find_vector_intersection, which is a slow routine, -// so we don't want to call it again (for this object) unless we have to. -vms_vector Hit_pos; -int Hit_type, Hit_seg; -fvi_info Hit_data; +// These globals are set by a call to find_vector_intersection, which is a slow routine, +// so we don't want to call it again (for this object) unless we have to. +vms_vector Hit_pos; +int Hit_type, Hit_seg; +fvi_info Hit_data; -int Num_awareness_events = 0; -awareness_event Awareness_events[MAX_AWARENESS_EVENTS]; +int Num_awareness_events = 0; +awareness_event Awareness_events[MAX_AWARENESS_EVENTS]; -vms_vector Believed_player_pos; -int Believed_player_seg; +vms_vector Believed_player_pos; +int Believed_player_seg; #ifndef NDEBUG -// Index into this array with ailp->mode -char *mode_text[18] = { +// Index into this array with ailp->mode +char *mode_text[18] = { "STILL", "WANDER", "FOL_PATH", @@ -403,10 +151,11 @@ char *mode_text[18] = { "TH_ATTACK", "TH_RETREAT", "TH_WAIT", + }; // Index into this array with aip->behavior -char behavior_text[6][9] = { +char behavior_text[6][9] = { "STILL ", "NORMAL ", "HIDE ", @@ -415,8 +164,8 @@ char behavior_text[6][9] = { "STATION " }; -// Index into this array with aip->GOAL_STATE or aip->CURRENT_STATE -char state_text[8][5] = { +// Index into this array with aip->GOAL_STATE or aip->CURRENT_STATE +char state_text[8][5] = { "NONE", "REST", "SRCH", @@ -431,68 +180,68 @@ char state_text[8][5] = { #endif // Current state indicates where the robot current is, or has just done. -// Transition table between states for an AI object. -// First dimension is trigger event. -// Second dimension is current state. -// Third dimension is goal state. -// Result is new goal state. -// ERR_ means something impossible has happened. +// Transition table between states for an AI object. +// First dimension is trigger event. +// Second dimension is current state. +// Third dimension is goal state. +// Result is new goal state. +// ERR_ means something impossible has happened. byte Ai_transition_table[AI_MAX_EVENT][AI_MAX_STATE][AI_MAX_STATE] = { { - // Event = AIE_FIRE, a nearby object fired - // none rest srch lock flin fire reco // CURRENT is rows, GOAL is columns - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO }, // none - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO }, // rest - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO }, // search - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO }, // lock - { AIS_ERR_, AIS_REST, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FIRE, AIS_RECO }, // flinch - { AIS_ERR_, AIS_FIRE, AIS_FIRE, AIS_FIRE, AIS_FLIN, AIS_FIRE, AIS_RECO }, // fire - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_FIRE } // recoil + // Event = AIE_FIRE, a nearby object fired + // none rest srch lock flin fire reco // CURRENT is rows, GOAL is columns + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, // none + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, // rest + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, // search + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, // lock + { AIS_ERR_, AIS_REST, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FIRE, AIS_RECO}, // flinch + { AIS_ERR_, AIS_FIRE, AIS_FIRE, AIS_FIRE, AIS_FLIN, AIS_FIRE, AIS_RECO}, // fire + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_FIRE} // recoil }, - // Event = AIE_HITT, a nearby object was hit (or a wall was hit) + // Event = AIE_HITT, a nearby object was hit (or a wall was hit) { - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FLIN}, - { AIS_ERR_, AIS_REST, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_FIRE} + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FLIN}, + { AIS_ERR_, AIS_REST, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_FIRE} }, - // Event = AIE_COLL, player collided with robot + // Event = AIE_COLL, player collided with robot { - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_LOCK, AIS_FLIN, AIS_FLIN}, - { AIS_ERR_, AIS_REST, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FIRE, AIS_RECO}, - { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_FIRE} + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_LOCK, AIS_FLIN, AIS_FLIN}, + { AIS_ERR_, AIS_REST, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FIRE, AIS_RECO}, + { AIS_ERR_, AIS_LOCK, AIS_LOCK, AIS_LOCK, AIS_FLIN, AIS_FIRE, AIS_FIRE} }, - // Event = AIE_HURT, player hurt robot (by firing at and hitting it) - // Note, this doesn't necessarily mean the robot JUST got hit, only that that is the most recent thing that happened. + // Event = AIE_HURT, player hurt robot (by firing at and hitting it) + // Note, this doesn't necessarily mean the robot JUST got hit, only that that is the most recent thing that happened. { - { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, - { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, - { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, - { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, - { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, - { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, - { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN} + { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, + { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, + { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, + { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, + { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, + { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN}, + { AIS_ERR_, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN, AIS_FLIN} } }; -fix Dist_to_last_fired_upon_player_pos = 0; +fix Dist_to_last_fired_upon_player_pos = 0; -// ---------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- void init_ai_frame(void) { - int ab_state; + int ab_state; Dist_to_last_fired_upon_player_pos = vm_vec_dist_quick(&Last_fired_upon_player_pos, &Believed_player_pos); @@ -503,10 +252,10 @@ void init_ai_frame(void) } } -// ---------------------------------------------------------------------------- -// Return firing status. -// If ready to fire a weapon, return true, else return false. -// Ready to fire a weapon if next_fire <= 0 or next_fire2 <= 0. +// -------------------------------------------------------------------------------------------------------------------- +// Return firing status. +// If ready to fire a weapon, return true, else return false. +// Ready to fire a weapon if next_fire <= 0 or next_fire2 <= 0. int ready_to_fire(robot_info *robptr, ai_local *ailp) { if (robptr->weapon_type2 != -1) @@ -515,22 +264,21 @@ int ready_to_fire(robot_info *robptr, ai_local *ailp) return (ailp->next_fire <= 0); } -// ---------------------------------------------------------------------------- -// Make a robot near the player snipe. +// -------------------------------------------------------------------------------------------------------------------- +// Make a robot near the player snipe. #define MNRS_SEG_MAX 70 void make_nearby_robot_snipe(void) { - int bfs_length, i; - short bfs_list[MNRS_SEG_MAX]; + int bfs_length, i; + short bfs_list[MNRS_SEG_MAX]; create_bfs_list(ConsoleObject->segnum, bfs_list, &bfs_length, MNRS_SEG_MAX); for (i=0; iid]; + object *objp = &Objects[objnum]; + robot_info *robptr = &Robot_info[objp->id]; if ((objp->type == OBJ_ROBOT) && (objp->id != ROBOT_BRAIN)) { if ((objp->ctype.ai_info.behavior != AIB_SNIPE) && (objp->ctype.ai_info.behavior != AIB_RUN_FROM) && !Robot_info[objp->id].boss_flag && !robptr->companion) { @@ -545,31 +293,31 @@ void make_nearby_robot_snipe(void) } mprintf((0, "Couldn't find a robot to make snipe!\n")); - + } -int Ai_last_missile_camera; +int Ai_last_missile_camera; -int Robots_kill_robots_cheat = 0; +int Robots_kill_robots_cheat = 0; // -------------------------------------------------------------------------------------------------------------------- void do_ai_frame(object *obj) { - int objnum = obj-Objects; - ai_static *aip = &obj->ctype.ai_info; - ai_local *ailp = &Ai_local_info[objnum]; - fix dist_to_player; - vms_vector vec_to_player; - fix dot; - robot_info *robptr; - int player_visibility=-1; - int obj_ref; - int object_animates; - int new_goal_state; - int visibility_and_vec_computed = 0; - int previous_visibility; - vms_vector gun_point; - vms_vector vis_vec_pos; + int objnum = obj-Objects; + ai_static *aip = &obj->ctype.ai_info; + ai_local *ailp = &Ai_local_info[objnum]; + fix dist_to_player; + vms_vector vec_to_player; + fix dot; + robot_info *robptr; + int player_visibility=-1; + int obj_ref; + int object_animates; + int new_goal_state; + int visibility_and_vec_computed = 0; + int previous_visibility; + vms_vector gun_point; + vms_vector vis_vec_pos; ailp->next_action_time -= FrameTime; @@ -591,16 +339,16 @@ void do_ai_frame(object *obj) if (do_any_robot_dying_frame(obj)) return; - // Kind of a hack. If a robot is flinching, but it is time for it to fire, unflinch it. - // Else, you can turn a big nasty robot into a wimp by firing flares at it. - // This also allows the player to see the cool flinch effect for mechs without unbalancing the game. + // Kind of a hack. If a robot is flinching, but it is time for it to fire, unflinch it. + // Else, you can turn a big nasty robot into a wimp by firing flares at it. + // This also allows the player to see the cool flinch effect for mechs without unbalancing the game. if ((aip->GOAL_STATE == AIS_FLIN) && ready_to_fire(robptr, ailp)) { aip->GOAL_STATE = AIS_FIRE; } #ifndef NDEBUG if ((aip->behavior == AIB_RUN_FROM) && (ailp->mode != AIM_RUN_FROM_OBJECT)) - Int3(); // This is peculiar. Behavior is run from, but mode is not. Contact Mike. + Int3(); // This is peculiar. Behavior is run from, but mode is not. Contact Mike. mprintf_animation_info((obj)); @@ -609,15 +357,15 @@ void do_ai_frame(object *obj) if (Break_on_object != -1) if ((obj-Objects) == Break_on_object) - Int3(); // Contact Mike: This is a debug break + Int3(); // Contact Mike: This is a debug break #endif - //mprintf((0, "Object %i: behavior = %02x, mode = %i, awareness = %i, time = %7.3f\n", obj-Objects, aip->behavior, ailp->mode, ailp->player_awareness_type, f2fl(ailp->player_awareness_time))); - //mprintf((0, "Object %i: behavior = %02x, mode = %i, awareness = %i, cur=%i, goal=%i\n", obj-Objects, aip->behavior, ailp->mode, ailp->player_awareness_type, aip->CURRENT_STATE, aip->GOAL_STATE)); + // mprintf((0, "Object %i: behavior = %02x, mode = %i, awareness = %i, time = %7.3f\n", obj-Objects, aip->behavior, ailp->mode, ailp->player_awareness_type, f2fl(ailp->player_awareness_time))); + // mprintf((0, "Object %i: behavior = %02x, mode = %i, awareness = %i, cur=%i, goal=%i\n", obj-Objects, aip->behavior, ailp->mode, ailp->player_awareness_type, aip->CURRENT_STATE, aip->GOAL_STATE)); - //Assert((aip->behavior >= MIN_BEHAVIOR) && (aip->behavior <= MAX_BEHAVIOR)); +// Assert((aip->behavior >= MIN_BEHAVIOR) && (aip->behavior <= MAX_BEHAVIOR)); if (!((aip->behavior >= MIN_BEHAVIOR) && (aip->behavior <= MAX_BEHAVIOR))) { - //mprintf((0, "Object %i behavior is %i, setting to AIB_NORMAL, fix in editor!\n", objnum, aip->behavior)); + // mprintf((0, "Object %i behavior is %i, setting to AIB_NORMAL, fix in editor!\n", objnum, aip->behavior)); aip->behavior = AIB_NORMAL; } @@ -638,17 +386,17 @@ void do_ai_frame(object *obj) if (ailp->time_since_processed < F1_0*256) ailp->time_since_processed += FrameTime; - previous_visibility = ailp->previous_visibility; // Must get this before we toast the master copy! + previous_visibility = ailp->previous_visibility; // Must get this before we toast the master copy! // -- (No robots have this behavior...) - // -- // Deal with cloaking for robots which are cloaked except just before firing. + // -- // Deal with cloaking for robots which are cloaked except just before firing. // -- if (robptr->cloak_type == RI_CLOAKED_EXCEPT_FIRING) // -- if (ailp->next_fire < F1_0/2) // -- aip->CLOAKED = 1; // -- else // -- aip->CLOAKED = 0; - // If only awake because of a camera, make that the believed player position. + // If only awake because of a camera, make that the believed player position. if ((aip->SUB_FLAGS & SUB_FLAGS_CAMERA_AWAKE) && (Ai_last_missile_camera != -1)) Believed_player_pos = Objects[Ai_last_missile_camera].pos; else { @@ -656,8 +404,8 @@ void do_ai_frame(object *obj) vis_vec_pos = obj->pos; compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); if (player_visibility) { - int ii, min_obj = -1; - fix min_dist = F1_0*200, cur_dist; + int ii, min_obj = -1; + fix min_dist = F1_0*200, cur_dist; for (ii=0; ii<=Highest_object_index; ii++) if ((Objects[ii].type == OBJ_ROBOT) && (ii != objnum)) { @@ -688,14 +436,14 @@ _exit_cheat: } } dist_to_player = vm_vec_dist_quick(&Believed_player_pos, &obj->pos); - //if (robptr->companion) - // mprintf((0, "%3i: %3i %8.3f %8s %8s [%3i %4i]\n", objnum, obj->segnum, f2fl(dist_to_player), mode_text[ailp->mode], behavior_text[aip->behavior-0x80], aip->hide_index, aip->path_length)); +// if (robptr->companion) +// mprintf((0, "%3i: %3i %8.3f %8s %8s [%3i %4i]\n", objnum, obj->segnum, f2fl(dist_to_player), mode_text[ailp->mode], behavior_text[aip->behavior-0x80], aip->hide_index, aip->path_length)); - // If this robot can fire, compute visibility from gun position. - // Don't want to compute visibility twice, as it is expensive. (So is call to calc_gun_point). + // If this robot can fire, compute visibility from gun position. + // Don't want to compute visibility twice, as it is expensive. (So is call to calc_gun_point). if ((previous_visibility || !(obj_ref & 3)) && ready_to_fire(robptr, ailp) && (dist_to_player < F1_0*200) && (robptr->n_guns) && !(robptr->attack_type)) { - // Since we passed ready_to_fire(), either next_fire or next_fire2 <= 0. calc_gun_point from relevant one. - // If both are <= 0, we will deal with the mess in ai_do_actual_firing_stuff + // Since we passed ready_to_fire(), either next_fire or next_fire2 <= 0. calc_gun_point from relevant one. + // If both are <= 0, we will deal with the mess in ai_do_actual_firing_stuff if (ailp->next_fire <= 0) calc_gun_point(&gun_point, obj, aip->CURRENT_GUN); else @@ -704,17 +452,17 @@ _exit_cheat: } else { vis_vec_pos = obj->pos; vm_vec_zero(&gun_point); - //mprintf((0, "Visibility = %i, computed from center.\n", player_visibility)); + // mprintf((0, "Visibility = %i, computed from center.\n", player_visibility)); } // MK: Debugging, July 26, 1995! // if (objnum == 1) // { -// compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); -// mprintf((0, "Frame %i: dist=%7.3f, vecdot = %7.3f, mode=%i\n", FrameCount, f2fl(dist_to_player), f2fl(vm_vec_dot(&vec_to_player, &obj->orient.fvec)), ailp->mode)); +// compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); +// mprintf((0, "Frame %i: dist=%7.3f, vecdot = %7.3f, mode=%i\n", FrameCount, f2fl(dist_to_player), f2fl(vm_vec_dot(&vec_to_player, &obj->orient.fvec)), ailp->mode)); // } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Occasionally make non-still robots make a path to the player. Based on agitation and distance from player. + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // Occasionally make non-still robots make a path to the player. Based on agitation and distance from player. if ((aip->behavior != AIB_SNIPE) && (aip->behavior != AIB_RUN_FROM) && (aip->behavior != AIB_STILL) && !(Game_mode & GM_MULTI) && (robptr->companion != 1) && (robptr->thief != 1)) if (Overall_agitation > 70) { if ((dist_to_player < F1_0*200) && (d_rand() < FrameTime/4)) { @@ -726,12 +474,11 @@ _exit_cheat: } } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // If retry count not 0, then add it into consecutive_retries. - // If it is 0, cut down consecutive_retries. - // This is largely a hack to speed up physics and deal with stupid - // AI. This is low level communication between systems of a sort - // that should not be done. + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // If retry count not 0, then add it into consecutive_retries. + // If it is 0, cut down consecutive_retries. + // This is largely a hack to speed up physics and deal with stupid AI. This is low level + // communication between systems of a sort that should not be done. if ((ailp->retry_count) && !(Game_mode & GM_MULTI)) { ailp->consecutive_retries += ailp->retry_count; ailp->retry_count = 0; @@ -747,11 +494,11 @@ _exit_cheat: case AIM_GOTO_OBJECT: // -- mprintf((0, "Buddy stuck going to object...\n")); Escort_goal_object = ESCORT_GOAL_UNSPECIFIED; - //if (obj->segnum == ConsoleObject->segnum) { - // if (Point_segs[aip->hide_index + aip->cur_path_index].segnum == obj->segnum) - // if ((aip->cur_path_index + aip->PATH_DIR >= 0) && (aip->cur_path_index + aip->PATH_DIR < aip->path_length-1)) - // aip->cur_path_index += aip->PATH_DIR; - //} +// if (obj->segnum == ConsoleObject->segnum) { +// if (Point_segs[aip->hide_index + aip->cur_path_index].segnum == obj->segnum) +// if ((aip->cur_path_index + aip->PATH_DIR >= 0) && (aip->cur_path_index + aip->PATH_DIR < aip->path_length-1)) +// aip->cur_path_index += aip->PATH_DIR; +// } break; case AIM_CHASE_OBJECT: // -- mprintf((0, "(2) Object #%i, retries while chasing, creating path to player in frame %i\n", objnum, FrameCount)); @@ -760,11 +507,11 @@ _exit_cheat: case AIM_STILL: if (robptr->attack_type) move_towards_segment_center(obj); - else if (!((aip->behavior == AIB_STILL) || (aip->behavior == AIB_STATION) || (aip->behavior == AIB_FOLLOW))) // Behavior is still, so don't follow path. + else if (!((aip->behavior == AIB_STILL) || (aip->behavior == AIB_STATION) || (aip->behavior == AIB_FOLLOW))) // Behavior is still, so don't follow path. attempt_to_resume_path(obj); - break; + break; case AIM_FOLLOW_PATH: - // mprintf((0, "Object %i following path got %i retries in frame %i\n", obj-Objects, ailp->consecutive_retries, FrameCount)); + // mprintf((0, "Object %i following path got %i retries in frame %i\n", obj-Objects, ailp->consecutive_retries, FrameCount)); if (Game_mode & GM_MULTI) { ailp->mode = AIM_STILL; } else @@ -790,7 +537,7 @@ _exit_cheat: break; #ifndef NDEBUG case AIM_FOLLOW_PATH_2: - Int3(); // Should never happen! + Int3(); // Should never happen! break; #endif } @@ -799,31 +546,31 @@ _exit_cheat: } else ailp->consecutive_retries /= 2; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // If in materialization center, exit - if (!(Game_mode & GM_MULTI) && (Segment2s[obj->segnum].special == SEGMENT_IS_ROBOTMAKER)) { + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // If in materialization center, exit + if (!(Game_mode & GM_MULTI) && (Segment2s[obj->segnum].special == SEGMENT_IS_ROBOTMAKER)) { if (Station[Segment2s[obj->segnum].value].Enabled) { - ai_follow_path(obj, 1, 1, NULL); // 1 = player is visible, which might be a lie, but it works. - return; + ai_follow_path(obj, 1, 1, NULL); // 1 = player is visible, which might be a lie, but it works. + return; } - } + } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Decrease player awareness due to the passage of time. + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // Decrease player awareness due to the passage of time. if (ailp->player_awareness_type) { if (ailp->player_awareness_time > 0) { ailp->player_awareness_time -= FrameTime; if (ailp->player_awareness_time <= 0) { - ailp->player_awareness_time = F1_0*2; //new: 11/05/94 - ailp->player_awareness_type--; //new: 11/05/94 + ailp->player_awareness_time = F1_0*2; //new: 11/05/94 + ailp->player_awareness_type--; //new: 11/05/94 } } else { ailp->player_awareness_type--; ailp->player_awareness_time = F1_0*2; - //aip->GOAL_STATE = AIS_REST; + // aip->GOAL_STATE = AIS_REST; } } else - aip->GOAL_STATE = AIS_REST; //new: 12/13/94 + aip->GOAL_STATE = AIS_REST; //new: 12/13/94 if (Player_is_dead && (ailp->player_awareness_type == 0)) @@ -845,22 +592,22 @@ _exit_cheat: } } - // -- // Make sure that if this guy got hit or bumped, then he's chasing player. - // -- if ((ailp->player_awareness_type == PA_WEAPON_ROBOT_COLLISION) || (ailp->player_awareness_type >= PA_PLAYER_COLLISION)) { - // -- if ((ailp->mode != AIM_BEHIND) && (aip->behavior != AIB_STILL) && (aip->behavior != AIB_SNIPE) && (aip->behavior != AIB_RUN_FROM) && (!robptr->companion) && (!robptr->thief) && (obj->id != ROBOT_BRAIN)) { - // -- ailp->mode = AIM_CHASE_OBJECT; - // -- ailp->player_awareness_type = 0; - // -- ailp->player_awareness_time = 0; - // -- } - // -- } +// -- // Make sure that if this guy got hit or bumped, then he's chasing player. +// -- if ((ailp->player_awareness_type == PA_WEAPON_ROBOT_COLLISION) || (ailp->player_awareness_type >= PA_PLAYER_COLLISION)) { +// -- if ((ailp->mode != AIM_BEHIND) && (aip->behavior != AIB_STILL) && (aip->behavior != AIB_SNIPE) && (aip->behavior != AIB_RUN_FROM) && (!robptr->companion) && (!robptr->thief) && (obj->id != ROBOT_BRAIN)) { +// -- ailp->mode = AIM_CHASE_OBJECT; +// -- ailp->player_awareness_type = 0; +// -- ailp->player_awareness_time = 0; +// -- } +// -- } - // Make sure that if this guy got hit or bumped, then he's chasing player. + // Make sure that if this guy got hit or bumped, then he's chasing player. if ((ailp->player_awareness_type == PA_WEAPON_ROBOT_COLLISION) || (ailp->player_awareness_type >= PA_PLAYER_COLLISION)) { compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); - if (player_visibility == 1) // Only increase visibility if unobstructed, else claw guys attack through doors. + if (player_visibility == 1) // Only increase visibility if unobstructed, else claw guys attack through doors. player_visibility = 2; } else if (((obj_ref&3) == 0) && !previous_visibility && (dist_to_player < F1_0*100)) { - fix sval, rval; + fix sval, rval; rval = d_rand(); sval = (dist_to_player * (Difficulty_level+1))/64; @@ -880,35 +627,34 @@ _exit_cheat: } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if ((aip->GOAL_STATE == AIS_FLIN) && (aip->CURRENT_STATE == AIS_FLIN)) aip->GOAL_STATE = AIS_LOCK; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Note: Should only do these two function calls for objects which animate + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // Note: Should only do these two function calls for objects which animate if (Animation_enabled && (dist_to_player < F1_0*100)) { // && !(Game_mode & GM_MULTI)) { object_animates = do_silly_animation(obj); if (object_animates) ai_frame_animation(obj); //mprintf((0, "Object %i: goal=%i, current=%i\n", obj-Objects, obj->ctype.ai_info.GOAL_STATE, obj->ctype.ai_info.CURRENT_STATE)); } else { - // If Object is supposed to animate, but we don't let it animate due to distance, then - // we must change its state, else it will never update. + // If Object is supposed to animate, but we don't let it animate due to distance, then + // we must change its state, else it will never update. aip->CURRENT_STATE = aip->GOAL_STATE; - object_animates = 0; // If we're not doing the animation, then should pretend it doesn't animate. + object_animates = 0; // If we're not doing the animation, then should pretend it doesn't animate. } switch (Robot_info[obj->id].boss_flag) { - case 0: - break; + case 0: + break; - case 1: - case 2: - mprintf((1, "Warning: D1 boss detected. Not supported!\n")); - break; + case 1: + case 2: + mprintf((1, "Warning: D1 boss detected. Not supported!\n")); + break; - default: - { + default: { int pv; fix dtp = dist_to_player/4; @@ -921,7 +667,7 @@ _exit_cheat: pv = player_visibility; - // If player cloaked, visibility is screwed up and superboss will gate in robots when not supposed to. + // If player cloaked, visibility is screwed up and superboss will gate in robots when not supposed to. if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) { pv = 0; dtp = vm_vec_dist_quick(&ConsoleObject->pos, &obj->pos)/4; @@ -932,39 +678,37 @@ _exit_cheat: break; } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Time-slice, don't process all the time, purely an efficiency hack. - // Guys whose behavior is station and are not at their hide segment get processed anyway. + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // Time-slice, don't process all the time, purely an efficiency hack. + // Guys whose behavior is station and are not at their hide segment get processed anyway. if (!((aip->behavior == AIB_SNIPE) && (ailp->mode != AIM_SNIPE_WAIT)) && !robptr->companion && !robptr->thief && (ailp->player_awareness_type < PA_WEAPON_ROBOT_COLLISION-1)) { // If robot got hit, he gets to attack player always! -#ifndef NDEBUG - if (Break_on_object != objnum) { // don't time slice if we're interested in this object. -#endif + #ifndef NDEBUG + if (Break_on_object != objnum) { // don't time slice if we're interested in this object. + #endif if ((aip->behavior == AIB_STATION) && (ailp->mode == AIM_FOLLOW_PATH) && (aip->hide_segment != obj->segnum)) { - if (dist_to_player > F1_0*250) // station guys not at home always processed until 250 units away. + if (dist_to_player > F1_0*250) // station guys not at home always processed until 250 units away. return; - } else if ((!ailp->previous_visibility) && ((dist_to_player >> 7) > ailp->time_since_processed)) { // 128 units away (6.4 segments) processed after 1 second. + } else if ((!ailp->previous_visibility) && ((dist_to_player >> 7) > ailp->time_since_processed)) { // 128 units away (6.4 segments) processed after 1 second. if (robptr->thief) mprintf((0, "T")); return; } -#ifndef NDEBUG + #ifndef NDEBUG } -#endif + #endif } - // Reset time since processed, but skew objects so not everything - // processed synchronously, else we get fast frames with the - // occasional very slow frame. + // Reset time since processed, but skew objects so not everything processed synchronously, else + // we get fast frames with the occasional very slow frame. // AI_proc_time = ailp->time_since_processed; ailp->time_since_processed = - ((objnum & 0x03) * FrameTime ) / 2; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Perform special ability switch (obj->id) { case ROBOT_BRAIN: - // Robots function nicely if behavior is Station. This - // means they won't move until they can see the player, at - // which time they will start wandering about opening doors. + // Robots function nicely if behavior is Station. This means they won't move until they + // can see the player, at which time they will start wandering about opening doors. if (ConsoleObject->segnum == obj->segnum) { if (!ai_multiplayer_awareness(obj, 97)) return; @@ -972,7 +716,7 @@ _exit_cheat: move_away_from_player(obj, &vec_to_player, 0); ai_multi_send_robot_position(objnum, -1); } else if (ailp->mode != AIM_STILL) { - int r; + int r; r = openable_doors_in_segment(obj->segnum); if (r != -1) { @@ -981,7 +725,7 @@ _exit_cheat: } else if (ailp->mode != AIM_FOLLOW_PATH) { if (!ai_multiplayer_awareness(obj, 50)) return; - create_n_segment_path_to_door(obj, 8+Difficulty_level, -1); // third parameter is avoid_seg, -1 means avoid nothing. + create_n_segment_path_to_door(obj, 8+Difficulty_level, -1); // third parameter is avoid_seg, -1 means avoid nothing. ai_multi_send_robot_position(objnum, -1); } @@ -997,7 +741,7 @@ _exit_cheat: if (player_visibility) { if (!ai_multiplayer_awareness(obj, 50)) return; - create_n_segment_path_to_door(obj, 8+Difficulty_level, -1); // third parameter is avoid_seg, -1 means avoid nothing. + create_n_segment_path_to_door(obj, 8+Difficulty_level, -1); // third parameter is avoid_seg, -1 means avoid nothing. ai_multi_send_robot_position(objnum, -1); } } @@ -1016,7 +760,7 @@ _exit_cheat: if (!(obj_ref & 3) || previous_visibility) { compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); - // If this sniper is in still mode, if he was hit or can see player, switch to snipe mode. + // If this sniper is in still mode, if he was hit or can see player, switch to snipe mode. if (ailp->mode == AIM_STILL) if (player_visibility || (ailp->player_awareness_type == PA_WEAPON_ROBOT_COLLISION)) ailp->mode = AIM_SNIPE_ATTACK; @@ -1027,7 +771,7 @@ _exit_cheat: return; } - // More special ability stuff, but based on a property of a robot, not its ID. + // More special ability stuff, but based on a property of a robot, not its ID. if (robptr->companion) { compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); @@ -1037,7 +781,7 @@ _exit_cheat: object *dobjp = &Objects[obj->ctype.ai_info.danger_laser_num]; if ((dobjp->type == OBJ_WEAPON) && (dobjp->signature == obj->ctype.ai_info.danger_laser_signature)) { - fix circle_distance; + fix circle_distance; // -- mprintf((0, "Evading! ")); circle_distance = robptr->circle_distance[Difficulty_level] + ConsoleObject->size; ai_move_relative_to_player(obj, ailp, dist_to_player, &vec_to_player, circle_distance, 1, player_visibility); @@ -1045,7 +789,7 @@ _exit_cheat: } if (ready_to_fire(robptr, ailp)) { - int do_stuff = 0; + int do_stuff = 0; if (openable_doors_in_segment(obj->segnum) != -1) do_stuff = 1; else if (openable_doors_in_segment(Point_segs[aip->hide_index + aip->cur_path_index + aip->PATH_DIR].segnum) != -1) @@ -1061,7 +805,7 @@ _exit_cheat: if (do_stuff) { Laser_create_new_easy( &obj->orient.fvec, &obj->pos, obj-Objects, FLARE_ID, 1); ailp->next_fire = F1_0/2; - if (!Buddy_allowed_to_talk) // If buddy not talking, make him fire flares less often. + if (!Buddy_allowed_to_talk) // If buddy not talking, make him fire flares less often. ailp->next_fire += d_rand()*4; } @@ -1074,7 +818,7 @@ _exit_cheat: do_thief_frame(obj, dist_to_player, player_visibility, &vec_to_player); if (ready_to_fire(robptr, ailp)) { - int do_stuff = 0; + int do_stuff = 0; if (openable_doors_in_segment(obj->segnum) != -1) do_stuff = 1; else if (openable_doors_in_segment(Point_segs[aip->hide_index + aip->cur_path_index + aip->PATH_DIR].segnum) != -1) @@ -1083,28 +827,28 @@ _exit_cheat: do_stuff = 1; if (do_stuff) { - // @mk, 05/08/95: Firing flare from center of object, this is dumb... + // @mk, 05/08/95: Firing flare from center of object, this is dumb... Laser_create_new_easy( &obj->orient.fvec, &obj->pos, obj-Objects, FLARE_ID, 1); ailp->next_fire = F1_0/2; - if (Stolen_item_index == 0) // If never stolen an item, fire flares less often (bad: Stolen_item_index wraps, but big deal) + if (Stolen_item_index == 0) // If never stolen an item, fire flares less often (bad: Stolen_item_index wraps, but big deal) ailp->next_fire += d_rand()*4; } } } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - switch (ailp->mode) { - case AIM_CHASE_OBJECT: { // chasing player, sort of, chase if far, back off if close, circle in between - fix circle_distance; + case AIM_CHASE_OBJECT: { // chasing player, sort of, chase if far, back off if close, circle in between + fix circle_distance; circle_distance = robptr->circle_distance[Difficulty_level] + ConsoleObject->size; - // Green guy doesn't get his circle distance boosted, else he might never attack. + // Green guy doesn't get his circle distance boosted, else he might never attack. if (robptr->attack_type != 1) circle_distance += (objnum&0xf) * F1_0/2; compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); - // @mk, 12/27/94, structure here was strange. Would do both clauses of what are now this if/then/else. Used to be if/then, if/then. + // @mk, 12/27/94, structure here was strange. Would do both clauses of what are now this if/then/else. Used to be if/then, if/then. if ((player_visibility < 2) && (previous_visibility == 2)) { // this is redundant: mk, 01/15/95: && (ailp->mode == AIM_CHASE_OBJECT)) { // -- mprintf((0, "I used to be able to see the player!\n")); if (!ai_multiplayer_awareness(obj, 53)) { @@ -1116,9 +860,8 @@ _exit_cheat: create_path_to_player(obj, 8, 1); ai_multi_send_robot_position(objnum, -1); } else if ((player_visibility == 0) && (dist_to_player > F1_0*80) && (!(Game_mode & GM_MULTI))) { - // If pretty far from the player, player cannot be seen - // (obstructed) and in chase mode, switch to follow path mode. - // This has one desirable benefit of avoiding physics retries. + // If pretty far from the player, player cannot be seen (obstructed) and in chase mode, switch to follow path mode. + // This has one desirable benefit of avoiding physics retries. if (aip->behavior == AIB_STATION) { ailp->goal_segment = aip->hide_segment; // -- mprintf((0, "(1) Object #%i going from chase to STATION in frame %i.\n", objnum, FrameCount)); @@ -1171,9 +914,9 @@ _exit_cheat: if (ai_evaded) { ai_multi_send_robot_position(objnum, 1); ai_evaded = 0; - } else + } else ai_multi_send_robot_position(objnum, -1); - + do_firing_stuff(obj, player_visibility, &vec_to_player); } break; @@ -1188,7 +931,7 @@ _exit_cheat: } - // If in multiplayer, only do if player visible. If not multiplayer, do always. + // If in multiplayer, only do if player visible. If not multiplayer, do always. if (!(Game_mode & GM_MULTI) || player_visibility) if (ai_multiplayer_awareness(obj, 75)) { ai_follow_path(obj, player_visibility, previous_visibility, &vec_to_player); @@ -1200,17 +943,14 @@ _exit_cheat: else if (aip->CURRENT_STATE == AIS_FLIN) aip->GOAL_STATE = AIS_LOCK; - // Bad to let run_from robot fire at player because it - // will cause a war in which it turns towards the player - // to fire and then towards its goal to move. + // Bad to let run_from robot fire at player because it will cause a war in which it turns towards the + // player to fire and then towards its goal to move. // do_firing_stuff(obj, player_visibility, &vec_to_player); - // Instead, do this: - // (Note, only drop if player is visible. This prevents - // the bombs from being a giveaway, and also ensures that - // the robot is moving while it is dropping. Also means - // fewer will be dropped.) + // Instead, do this: + // (Note, only drop if player is visible. This prevents the bombs from being a giveaway, and + // also ensures that the robot is moving while it is dropping. Also means fewer will be dropped.) if ((ailp->next_fire <= 0) && (player_visibility)) { - vms_vector fire_vec, fire_pos; + vms_vector fire_vec, fire_pos; if (!ai_multiplayer_awareness(obj, 75)) return; @@ -1224,31 +964,31 @@ _exit_cheat: else Laser_create_new_easy( &fire_vec, &fire_pos, obj-Objects, PROXIMITY_ID, 1); - ailp->next_fire = (F1_0/2)*(NDL+5 - Difficulty_level); // Drop a proximity bomb every 5 seconds. - + ailp->next_fire = (F1_0/2)*(NDL+5 - Difficulty_level); // Drop a proximity bomb every 5 seconds. + #ifdef NETWORK -#ifndef SHAREWARE + #ifndef SHAREWARE if (Game_mode & GM_MULTI) { ai_multi_send_robot_position(obj-Objects, -1); - if (aip->SUB_FLAGS & SUB_FLAGS_SPROX) - multi_send_robot_fire(obj-Objects, -2, &fire_vec); - else - multi_send_robot_fire(obj-Objects, -1, &fire_vec); - } -#endif + if (aip->SUB_FLAGS & SUB_FLAGS_SPROX) + multi_send_robot_fire(obj-Objects, -2, &fire_vec); + else + multi_send_robot_fire(obj-Objects, -1, &fire_vec); + } + #endif #endif } break; case AIM_GOTO_PLAYER: case AIM_GOTO_OBJECT: - ai_follow_path(obj, 2, previous_visibility, &vec_to_player); // Follows path as if player can see robot. + ai_follow_path(obj, 2, previous_visibility, &vec_to_player); // Follows path as if player can see robot. ai_multi_send_robot_position(objnum, -1); break; case AIM_FOLLOW_PATH: { - int anger_level = 65; + int anger_level = 65; if (aip->behavior == AIB_STATION) if (Point_segs[aip->hide_index + aip->path_length - 1].segnum == aip->hide_segment) { @@ -1285,7 +1025,7 @@ _exit_cheat: if ((player_visibility == 2) && (aip->behavior != AIB_SNIPE) && (aip->behavior != AIB_FOLLOW) && (aip->behavior != AIB_RUN_FROM) && (obj->id != ROBOT_BRAIN) && (robptr->companion != 1) && (robptr->thief != 1)) { if (robptr->attack_type == 0) ailp->mode = AIM_CHASE_OBJECT; - // This should not just be distance based, but also time-since-player-seen based. + // This should not just be distance based, but also time-since-player-seen based. } else if ((dist_to_player > F1_0*(20*(2*Difficulty_level + robptr->pursuit))) && (GameTime - ailp->time_player_seen > (F1_0/2*(Difficulty_level+robptr->pursuit))) && (player_visibility == 0) @@ -1313,20 +1053,20 @@ _exit_cheat: compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); if (player_visibility == 2) { - // Get behind the player. - // Method: - // If vec_to_player dot player_rear_vector > 0, behind is goal. - // Else choose goal with larger dot from left, right. - vms_vector goal_point, goal_vector, vec_to_goal, rand_vec; - fix dot; - + // Get behind the player. + // Method: + // If vec_to_player dot player_rear_vector > 0, behind is goal. + // Else choose goal with larger dot from left, right. + vms_vector goal_point, goal_vector, vec_to_goal, rand_vec; + fix dot; + dot = vm_vec_dot(&ConsoleObject->orient.fvec, &vec_to_player); - if (dot > 0) { // Remember, we're interested in the rear vector dot being < 0. + if (dot > 0) { // Remember, we're interested in the rear vector dot being < 0. goal_vector = ConsoleObject->orient.fvec; vm_vec_negate(&goal_vector); // -- mprintf((0, "Goal is BEHIND\n")); } else { - fix dot; + fix dot; dot = vm_vec_dot(&ConsoleObject->orient.rvec, &vec_to_player); goal_vector = ConsoleObject->orient.rvec; if (dot > 0) { @@ -1335,7 +1075,7 @@ _exit_cheat: } else ; // -- mprintf((0, "Goal is RIGHT\n")); } - + vm_vec_scale(&goal_vector, 2*(ConsoleObject->size + obj->size + (((objnum*4 + FrameCount) & 63) << 12))); vm_vec_add(&goal_point, &ConsoleObject->pos, &goal_vector); make_random_vector(&rand_vec); @@ -1359,7 +1099,7 @@ _exit_cheat: if ((dist_to_player < F1_0*120+Difficulty_level*F1_0*20) || (ailp->player_awareness_type >= PA_WEAPON_ROBOT_COLLISION-1)) { compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); - // turn towards vector if visible this time or last time, or rand + // turn towards vector if visible this time or last time, or rand // new! if ((player_visibility == 2) || (previous_visibility == 2)) { // -- MK, 06/09/95: || ((d_rand() > 0x4000) && !(Game_mode & GM_MULTI))) { if (!ai_multiplayer_awareness(obj, 71)) { @@ -1372,7 +1112,7 @@ _exit_cheat: } do_firing_stuff(obj, player_visibility, &vec_to_player); - if (player_visibility == 2) { // Changed @mk, 09/21/95: Require that they be looking to evade. Change, MK, 01/03/95 for Multiplayer reasons. If robots can't see you (even with eyes on back of head), then don't do evasion. + if (player_visibility == 2) { // Changed @mk, 09/21/95: Require that they be looking to evade. Change, MK, 01/03/95 for Multiplayer reasons. If robots can't see you (even with eyes on back of head), then don't do evasion. if (robptr->attack_type == 1) { aip->behavior = AIB_NORMAL; if (!ai_multiplayer_awareness(obj, 80)) { @@ -1388,7 +1128,7 @@ _exit_cheat: else ai_multi_send_robot_position(objnum, -1); } else { - // Robots in hover mode are allowed to evade at half normal speed. + // Robots in hover mode are allowed to evade at half normal speed. if (!ai_multiplayer_awareness(obj, 81)) { if (maybe_ai_do_actual_firing_stuff(obj, aip)) ai_do_actual_firing_stuff(obj, aip, ailp, robptr, &vec_to_player, dist_to_player, &gun_point, player_visibility, object_animates, aip->CURRENT_GUN); @@ -1399,14 +1139,12 @@ _exit_cheat: ai_multi_send_robot_position(objnum, -1); ai_evaded = 0; } - else + else ai_multi_send_robot_position(objnum, -1); } } else if ((obj->segnum != aip->hide_segment) && (dist_to_player > F1_0*80) && (!(Game_mode & GM_MULTI))) { - // If pretty far from the player, player cannot be - // seen (obstructed) and in chase mode, switch to - // follow path mode. - // This has one desirable benefit of avoiding physics retries. + // If pretty far from the player, player cannot be seen (obstructed) and in chase mode, switch to follow path mode. + // This has one desirable benefit of avoiding physics retries. if (aip->behavior == AIB_STATION) { ailp->goal_segment = aip->hide_segment; // -- mprintf((0, "(2) Object #%i going from STILL to STATION in frame %i.\n", objnum, FrameCount)); @@ -1417,9 +1155,9 @@ _exit_cheat: } break; - case AIM_OPEN_DOOR: { // trying to open a door. - vms_vector center_point, goal_vector; - Assert(obj->id == ROBOT_BRAIN); // Make sure this guy is allowed to be in this mode. + case AIM_OPEN_DOOR: { // trying to open a door. + vms_vector center_point, goal_vector; + Assert(obj->id == ROBOT_BRAIN); // Make sure this guy is allowed to be in this mode. if (!ai_multiplayer_awareness(obj, 62)) return; @@ -1454,28 +1192,28 @@ _exit_cheat: case AIM_THIEF_WAIT: case AIM_THIEF_ATTACK: case AIM_THIEF_RETREAT: - case AIM_WANDER: // Used for Buddy Bot + case AIM_WANDER: // Used for Buddy Bot break; default: mprintf((0, "Unknown mode = %i in robot %i, behavior = %i\n", ailp->mode, obj-Objects, aip->behavior)); ailp->mode = AIM_CHASE_OBJECT; break; - } // end: switch (ailp->mode) { + } // end: switch (ailp->mode) { - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // If the robot can see you, increase his awareness of you. - // This prevents the problem of a robot looking right at you but doing nothing. - // Assert(player_visibility != -1); // Means it didn't get initialized! + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // If the robot can see you, increase his awareness of you. + // This prevents the problem of a robot looking right at you but doing nothing. + // Assert(player_visibility != -1); // Means it didn't get initialized! compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); if ((player_visibility == 2) && (aip->behavior != AIB_FOLLOW) && (!robptr->thief)) { if ((ailp->player_awareness_type == 0) && (aip->SUB_FLAGS & SUB_FLAGS_CAMERA_AWAKE)) aip->SUB_FLAGS &= ~SUB_FLAGS_CAMERA_AWAKE; - else if (ailp->player_awareness_type == 0) + else if (ailp->player_awareness_type == 0) ailp->player_awareness_type = PA_PLAYER_COLLISION; } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (!object_animates) { aip->CURRENT_STATE = aip->GOAL_STATE; // mprintf((0, "Setting current to goal (%i) because object doesn't animate.\n", aip->GOAL_STATE)); @@ -1485,11 +1223,11 @@ _exit_cheat: Assert(aip->CURRENT_STATE < AIS_MAX); Assert(aip->GOAL_STATE < AIS_MAX); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (ailp->player_awareness_type) { new_goal_state = Ai_transition_table[ailp->player_awareness_type-1][aip->CURRENT_STATE][aip->GOAL_STATE]; if (ailp->player_awareness_type == PA_WEAPON_ROBOT_COLLISION) { - // Decrease awareness, else this robot will flinch every frame. + // Decrease awareness, else this robot will flinch every frame. ailp->player_awareness_type--; ailp->player_awareness_time = F1_0*3; } @@ -1504,100 +1242,100 @@ _exit_cheat: } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // If new state = fire, then set all gun states to fire. + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // If new state = fire, then set all gun states to fire. if ((aip->GOAL_STATE == AIS_FIRE) ) { - int i,num_guns; + int i,num_guns; num_guns = Robot_info[obj->id].n_guns; for (i=0; igoal_state[i] = AIS_FIRE; } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Hack by mk on 01/04/94, if a guy hasn't animated to the firing state, but his next_fire says ok to fire, bash him there + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // Hack by mk on 01/04/94, if a guy hasn't animated to the firing state, but his next_fire says ok to fire, bash him there if (ready_to_fire(robptr, ailp) && (aip->GOAL_STATE == AIS_FIRE)) aip->CURRENT_STATE = AIS_FIRE; if ((aip->GOAL_STATE != AIS_FLIN) && (obj->id != ROBOT_BRAIN)) { switch (aip->CURRENT_STATE) { - case AIS_NONE: - compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); - - dot = vm_vec_dot(&obj->orient.fvec, &vec_to_player); - if (dot >= F1_0/2) - if (aip->GOAL_STATE == AIS_REST) - aip->GOAL_STATE = AIS_SRCH; - break; - case AIS_REST: - if (aip->GOAL_STATE == AIS_REST) { + case AIS_NONE: compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); - if (ready_to_fire(robptr, ailp) && (player_visibility)) { - // mprintf((0, "Setting goal state to fire from rest.\n")); - aip->GOAL_STATE = AIS_FIRE; - } - } - break; - case AIS_SRCH: - if (!ai_multiplayer_awareness(obj, 60)) - return; - compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); - - if (player_visibility == 2) { - ai_turn_towards_vector(&vec_to_player, obj, robptr->turn_time[Difficulty_level]); - ai_multi_send_robot_position(objnum, -1); - } - break; - case AIS_LOCK: - compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); - - if (!(Game_mode & GM_MULTI) || (player_visibility)) { - if (!ai_multiplayer_awareness(obj, 68)) + dot = vm_vec_dot(&obj->orient.fvec, &vec_to_player); + if (dot >= F1_0/2) + if (aip->GOAL_STATE == AIS_REST) + aip->GOAL_STATE = AIS_SRCH; + break; + case AIS_REST: + if (aip->GOAL_STATE == AIS_REST) { + compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); + if (ready_to_fire(robptr, ailp) && (player_visibility)) { + // mprintf((0, "Setting goal state to fire from rest.\n")); + aip->GOAL_STATE = AIS_FIRE; + } + } + break; + case AIS_SRCH: + if (!ai_multiplayer_awareness(obj, 60)) return; - if (player_visibility == 2) { // @mk, 09/21/95, require that they be looking towards you to turn towards you. + compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); + + if (player_visibility == 2) { ai_turn_towards_vector(&vec_to_player, obj, robptr->turn_time[Difficulty_level]); ai_multi_send_robot_position(objnum, -1); } - } - break; - case AIS_FIRE: - compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); + break; + case AIS_LOCK: + compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); - if (player_visibility == 2) { - if (!ai_multiplayer_awareness(obj, (ROBOT_FIRE_AGITATION-1))) { - if (Game_mode & GM_MULTI) { - ai_do_actual_firing_stuff(obj, aip, ailp, robptr, &vec_to_player, dist_to_player, &gun_point, player_visibility, object_animates, aip->CURRENT_GUN); + if (!(Game_mode & GM_MULTI) || (player_visibility)) { + if (!ai_multiplayer_awareness(obj, 68)) return; + + if (player_visibility == 2) { // @mk, 09/21/95, require that they be looking towards you to turn towards you. + ai_turn_towards_vector(&vec_to_player, obj, robptr->turn_time[Difficulty_level]); + ai_multi_send_robot_position(objnum, -1); } } - ai_turn_towards_vector(&vec_to_player, obj, robptr->turn_time[Difficulty_level]); - ai_multi_send_robot_position(objnum, -1); - } - - // Fire at player, if appropriate. - ai_do_actual_firing_stuff(obj, aip, ailp, robptr, &vec_to_player, dist_to_player, &gun_point, player_visibility, object_animates, aip->CURRENT_GUN); - - break; - case AIS_RECO: - if (!(obj_ref & 3)) { + break; + case AIS_FIRE: compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); + if (player_visibility == 2) { - if (!ai_multiplayer_awareness(obj, 69)) - return; + if (!ai_multiplayer_awareness(obj, (ROBOT_FIRE_AGITATION-1))) { + if (Game_mode & GM_MULTI) { + ai_do_actual_firing_stuff(obj, aip, ailp, robptr, &vec_to_player, dist_to_player, &gun_point, player_visibility, object_animates, aip->CURRENT_GUN); + return; + } + } ai_turn_towards_vector(&vec_to_player, obj, robptr->turn_time[Difficulty_level]); ai_multi_send_robot_position(objnum, -1); - } // -- MK, 06/09/95: else if (!(Game_mode & GM_MULTI)) { - } - break; - case AIS_FLIN: - // mprintf((0, "State = flinch, goal = %i.\n", aip->GOAL_STATE)); - break; - default: - mprintf((1, "Unknown mode for AI object #%i\n", objnum)); - aip->GOAL_STATE = AIS_REST; - aip->CURRENT_STATE = AIS_REST; - break; + } + + // Fire at player, if appropriate. + ai_do_actual_firing_stuff(obj, aip, ailp, robptr, &vec_to_player, dist_to_player, &gun_point, player_visibility, object_animates, aip->CURRENT_GUN); + + break; + case AIS_RECO: + if (!(obj_ref & 3)) { + compute_vis_and_vec(obj, &vis_vec_pos, ailp, &vec_to_player, &player_visibility, robptr, &visibility_and_vec_computed); + if (player_visibility == 2) { + if (!ai_multiplayer_awareness(obj, 69)) + return; + ai_turn_towards_vector(&vec_to_player, obj, robptr->turn_time[Difficulty_level]); + ai_multi_send_robot_position(objnum, -1); + } // -- MK, 06/09/95: else if (!(Game_mode & GM_MULTI)) { + } + break; + case AIS_FLIN: + // mprintf((0, "State = flinch, goal = %i.\n", aip->GOAL_STATE)); + break; + default: + mprintf((1, "Unknown mode for AI object #%i\n", objnum)); + aip->GOAL_STATE = AIS_REST; + aip->CURRENT_STATE = AIS_REST; + break; } } // end of: if (aip->GOAL_STATE != AIS_FLIN) { @@ -1606,7 +1344,7 @@ _exit_cheat: aip->CURRENT_GUN++; if (aip->CURRENT_GUN >= Robot_info[obj->id].n_guns) { - if ((robptr->n_guns == 1) || (robptr->weapon_type2 == -1)) // Two weapon types hack. + if ((robptr->n_guns == 1) || (robptr->weapon_type2 == -1)) // Two weapon types hack. aip->CURRENT_GUN = 0; else aip->CURRENT_GUN = 1; @@ -1615,10 +1353,10 @@ _exit_cheat: } -// ---------------------------------------------------------------------------- +// ----------------------------------------------------------------------------------- void ai_do_cloak_stuff(void) { - int i; + int i; for (i=0; ipos; @@ -1626,17 +1364,17 @@ void ai_do_cloak_stuff(void) Ai_cloak_info[i].last_time = GameTime; } - // Make work for control centers. + // Make work for control centers. Believed_player_pos = Ai_cloak_info[0].last_position; Believed_player_seg = Ai_cloak_info[0].last_segment; } -// ---------------------------------------------------------------------------- -// Returns false if awareness is considered too puny to add, else returns true. +// ----------------------------------------------------------------------------------- +// Returns false if awareness is considered too puny to add, else returns true. int add_awareness_event(object *objp, int type) { - // If player cloaked and hit a robot, then increase awareness + // If player cloaked and hit a robot, then increase awareness if ((type == PA_WEAPON_ROBOT_COLLISION) || (type == PA_WEAPON_WALL_COLLISION) || (type == PA_PLAYER_COLLISION)) ai_do_cloak_stuff(); @@ -1644,27 +1382,26 @@ int add_awareness_event(object *objp, int type) if ((type == PA_WEAPON_WALL_COLLISION) || (type == PA_WEAPON_ROBOT_COLLISION)) if (objp->id == VULCAN_ID) if (d_rand() > 3276) - return 0; // For vulcan cannon, only about 1/10 actually cause awareness + return 0; // For vulcan cannon, only about 1/10 actually cause awareness Awareness_events[Num_awareness_events].segnum = objp->segnum; Awareness_events[Num_awareness_events].pos = objp->pos; Awareness_events[Num_awareness_events].type = type; Num_awareness_events++; } else { - //Int3(); // Hey -- Overflowed Awareness_events, make more or something - // This just gets ignored, so you can just - // continue. +// Int3(); // Hey -- Overflowed Awareness_events, make more or something + // This just gets ignored, so you can just continue. } return 1; } // ---------------------------------------------------------------------------------- -// Robots will become aware of the player based on something that occurred. -// The object (probably player or weapon) which created the awareness is objp. +// Robots will become aware of the player based on something that occurred. +// The object (probably player or weapon) which created the awareness is objp. void create_awareness_event(object *objp, int type) { - // If not in multiplayer, or in multiplayer with robots, do this, else unnecessary! + // If not in multiplayer, or in multiplayer with robots, do this, else unnecessary! if (!(Game_mode & GM_MULTI) || (Game_mode & GM_MULTI_ROBOTS)) { if (add_awareness_event(objp, type)) { if (((d_rand() * (type+4)) >> 15) > 4) @@ -1675,12 +1412,12 @@ void create_awareness_event(object *objp, int type) } } -byte New_awareness[MAX_SEGMENTS]; +byte New_awareness[MAX_SEGMENTS]; // ---------------------------------------------------------------------------------- void pae_aux(int segnum, int type, int level) { - int j; + int j; if (New_awareness[segnum] < type) New_awareness[segnum] = type; @@ -1703,7 +1440,7 @@ void pae_aux(int segnum, int type, int level) // ---------------------------------------------------------------------------------- void process_awareness_events(void) { - int i; + int i; if (!(Game_mode & GM_MULTI) || (Game_mode & GM_MULTI_ROBOTS)) { memset(New_awareness, 0, sizeof(New_awareness[0]) * (Highest_segment_index+1)); @@ -1719,7 +1456,7 @@ void process_awareness_events(void) // ---------------------------------------------------------------------------------- void set_player_awareness_all(void) { - int i; + int i; process_awareness_events(); @@ -1730,23 +1467,23 @@ void set_player_awareness_all(void) Ai_local_info[i].player_awareness_time = PLAYER_AWARENESS_INITIAL_TIME; } - // Clear the bit that says this robot is only awake because a camera woke it up. + // Clear the bit that says this robot is only awake because a camera woke it up. if (New_awareness[Objects[i].segnum] > Ai_local_info[i].player_awareness_type) Objects[i].ctype.ai_info.SUB_FLAGS &= ~SUB_FLAGS_CAMERA_AWAKE; } } #ifndef NDEBUG -int Ai_dump_enable = 0; +int Ai_dump_enable = 0; FILE *Ai_dump_file = NULL; -char Ai_error_message[128] = ""; +char Ai_error_message[128] = ""; // ---------------------------------------------------------------------------------- void force_dump_ai_objects_all(char *msg) { - int tsave; + int tsave; tsave = Ai_dump_enable; @@ -1773,9 +1510,9 @@ void turn_off_ai_dump(void) extern void do_boss_dying_frame(object *objp); // ---------------------------------------------------------------------------------- -// Do things which need to get done for all AI objects each frame. -// This includes: -// Setting player_awareness (a fix, time in seconds which object is aware of player) +// Do things which need to get done for all AI objects each frame. +// This includes: +// Setting player_awareness (a fix, time in seconds which object is aware of player) void do_ai_frame_all(void) { #ifndef NDEBUG @@ -1785,9 +1522,9 @@ void do_ai_frame_all(void) set_player_awareness_all(); if (Ai_last_missile_camera != -1) { - // Clear if supposed misisle camera is not a weapon, or just every so often, just in case. + // Clear if supposed misisle camera is not a weapon, or just every so often, just in case. if (((FrameCount & 0x0f) == 0) || (Objects[Ai_last_missile_camera].type != OBJ_WEAPON)) { - int i; + int i; Ai_last_missile_camera = -1; for (i=0; i<=Highest_object_index; i++) @@ -1796,9 +1533,9 @@ void do_ai_frame_all(void) } } - // (Moved here from do_boss_stuff() because that only gets called if robot aware of player.) + // (Moved here from do_boss_stuff() because that only gets called if robot aware of player.) if (Boss_dying) { - int i; + int i; for (i=0; i<=Highest_object_index; i++) if (Objects[i].type == OBJ_ROBOT) @@ -1811,12 +1548,12 @@ void do_ai_frame_all(void) extern int Final_boss_is_dead; extern fix Boss_invulnerable_dot; -// Initializations to be performed for all robots for a new level. +// Initializations to be performed for all robots for a new level. void init_robots_for_level(void) { Overall_agitation = 0; - Final_boss_is_dead=0; - + Final_boss_is_dead=0; + Buddy_objnum = 0; Buddy_allowed_to_talk = 0; @@ -1898,7 +1635,7 @@ int ai_restore_state( FILE * fp, int version ) fread( &Escort_goal_index, sizeof(Escort_goal_index), 1, fp); fread( &Stolen_items, sizeof(Stolen_items[0])*MAX_STOLEN_ITEMS, 1, fp); } else { - int i; + int i; Escort_kill_object = -1; Escort_last_path_created = 0; @@ -1913,7 +1650,7 @@ int ai_restore_state( FILE * fp, int version ) } if (version >= 15) { - int temp; + int temp; fread( &temp, sizeof(int), 1, fp ); Point_segs_free_ptr = &Point_segs[temp]; } else @@ -1933,9 +1670,10 @@ int ai_restore_state( FILE * fp, int version ) // -- Num_boss_gate_segs = 1; // -- Boss_teleport_segs[0] = 0; // -- Boss_gate_segs[0] = 0; - // Note: Maybe better to leave alone...will probably be ok. + // Note: Maybe better to leave alone...will probably be ok. mprintf((1, "Warning: If you fight the boss, he might teleport to segment #0!\n")); } + return 1; } diff --git a/main/ai.h b/main/ai.h index 91b605e5..4b82901a 100644 --- a/main/ai.h +++ b/main/ai.h @@ -1,4 +1,3 @@ -/* $Id: ai.h,v 1.5 2003-03-27 01:23:18 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,142 +7,10 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Header file for AI system. - * - * Old Log: - * Revision 1.3 1995/10/15 16:28:07 allender - * added flag to player_is_visible function - * - * Revision 1.2 1995/10/10 11:48:32 allender - * PC ai header - * - * Revision 1.1 1995/05/16 15:54:00 allender - * Initial revision - * - * Revision 2.0 1995/02/27 11:33:07 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.57 1995/02/04 17:28:31 mike - * make station guys return better. - * - * Revision 1.56 1995/02/04 10:03:23 mike - * Fly to exit cheat. - * - * Revision 1.55 1995/02/01 19:23:52 rob - * Externed a boss var. - * - * Revision 1.54 1995/01/30 13:00:58 mike - * Make robots fire at player other than one they are controlled by sometimes. - * - * Revision 1.53 1995/01/26 15:09:16 rob - * Changed robot gating to accomodate multiplayer. - * - * Revision 1.52 1995/01/26 12:23:12 rob - * Added new externs needed for multiplayer. - * - * Revision 1.51 1995/01/21 21:22:14 mike - * Kill prototype of init_boss_segments, which didn't need to be public - * and had changed. - * - * Revision 1.50 1995/01/16 19:24:29 mike - * Publicize BOSS_GATE_MATCEN_NUM and Boss_been_hit. - * - * Revision 1.49 1995/01/02 16:17:35 mike - * prototype some super boss function for gameseq. - * - * Revision 1.48 1994/12/19 17:08:06 mike - * deal with new ai_multiplayer_awareness which returns a value saying whether this object can be moved by this player. - * - * Revision 1.47 1994/12/12 17:18:04 mike - * make boss cloak/teleport when get hit, make quad laser 3/4 as powerful. - * - * Revision 1.46 1994/12/08 15:46:16 mike - * better robot behavior. - * - * Revision 1.45 1994/11/27 23:16:08 matt - * Made debug code go away when debugging turned off - * - * Revision 1.44 1994/11/16 23:38:41 mike - * new improved boss teleportation behavior. - * - * Revision 1.43 1994/11/10 17:45:11 mike - * debugging. - * - * Revision 1.42 1994/11/07 10:37:42 mike - * hooks for rob's network code. - * - * Revision 1.41 1994/11/06 15:10:50 mike - * prototype a debug function for dumping ai info. - * - * Revision 1.40 1994/11/02 17:57:30 rob - * Added extern of Believe_player_pos needed to get control centers - * locating people. - * - * Revision 1.39 1994/10/28 19:43:39 mike - * Prototype Boss_cloak_start_time, Boss_cloak_end_time. - * - * Revision 1.38 1994/10/22 14:14:42 mike - * Prototype ai_reset_all_paths. - * - * Revision 1.37 1994/10/21 20:42:01 mike - * Define MAX_PATH_LENGTH: maximum allowed length of a path. - * - * Revision 1.36 1994/10/20 09:49:18 mike - * Prototype something. - * - * - * Revision 1.35 1994/10/18 15:37:52 mike - * Define ROBOT_BOSS1. - * - * Revision 1.34 1994/10/13 11:12:25 mike - * Prototype some door functions. - * - * Revision 1.33 1994/10/12 21:28:51 mike - * Prototype create_n_segment_path_to_door - * Prototype ai_open_doors_in_segment - * Prototype ai_door_is_openable. - * - * Revision 1.32 1994/10/11 15:59:41 mike - * Prototype Robot_firing_enabled. - * - * Revision 1.31 1994/10/09 22:02:48 mike - * Adapt create_path_points and create_n_segment_path prototypes to use avoid_seg for player evasion. - * - * Revision 1.30 1994/09/18 18:07:44 mike - * Update prototypes for create_path_points and create_path_to_player. - * - * Revision 1.29 1994/09/15 16:34:08 mike - * Prototype do_ai_robot_hit_attack. - * - * Revision 1.28 1994/09/12 19:12:35 mike - * Prototype attempt_to_resume_path. - * - * Revision 1.27 1994/08/25 21:55:32 mike - * Add some prototypes. - * - * Revision 1.26 1994/08/10 19:53:24 mike - * Prototype create_path_to_player and init_robots_for_level. - * - * Revision 1.25 1994/08/04 16:32:58 mike - * prototype create_path_to_player. - * - * Revision 1.24 1994/08/03 15:17:20 mike - * Prototype make_random_vector. - * - * Revision 1.23 1994/07/31 18:10:34 mike - * Update prototype for create_path_points. - * - * Revision 1.22 1994/07/28 12:36:14 matt - * Cleaned up object bumping code - * - */ #ifndef _AI_H #define _AI_H @@ -154,45 +21,45 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "fvi.h" #include "robot.h" -#define PLAYER_AWARENESS_INITIAL_TIME (3*F1_0) -#define MAX_PATH_LENGTH 30 // Maximum length of path in ai path following. -#define MAX_DEPTH_TO_SEARCH_FOR_PLAYER 10 -#define BOSS_GATE_MATCEN_NUM -1 -#define MAX_BOSS_TELEPORT_SEGS 100 -#define BOSS_ECLIP_NUM 53 +#define PLAYER_AWARENESS_INITIAL_TIME (3*F1_0) +#define MAX_PATH_LENGTH 30 // Maximum length of path in ai path following. +#define MAX_DEPTH_TO_SEARCH_FOR_PLAYER 10 +#define BOSS_GATE_MATCEN_NUM -1 +#define MAX_BOSS_TELEPORT_SEGS 100 +#define BOSS_ECLIP_NUM 53 -#define ROBOT_BRAIN 7 -#define ROBOT_BOSS1 17 +#define ROBOT_BRAIN 7 +#define ROBOT_BOSS1 17 #define ROBOT_FIRE_AGITATION 94 -#define BOSS_D2 21 // Minimum D2 boss value. -#define BOSS_COOL 21 -#define BOSS_WATER 22 -#define BOSS_FIRE 23 -#define BOSS_ICE 24 -#define BOSS_ALIEN1 25 -#define BOSS_ALIEN2 26 - -#define NUM_D2_BOSSES 8 - -extern ubyte Boss_teleports[NUM_D2_BOSSES]; // Set byte if this boss can teleport -extern ubyte Boss_spew_more[NUM_D2_BOSSES]; // Set byte if this boss can teleport -//extern ubyte Boss_cloaks[NUM_D2_BOSSES]; // Set byte if this boss can cloak -extern ubyte Boss_spews_bots_energy[NUM_D2_BOSSES]; // Set byte if boss spews bots when hit by energy weapon. -extern ubyte Boss_spews_bots_matter[NUM_D2_BOSSES]; // Set byte if boss spews bots when hit by matter weapon. -extern ubyte Boss_invulnerable_energy[NUM_D2_BOSSES]; // Set byte if boss is invulnerable to energy weapons. -extern ubyte Boss_invulnerable_matter[NUM_D2_BOSSES]; // Set byte if boss is invulnerable to matter weapons. -extern ubyte Boss_invulnerable_spot[NUM_D2_BOSSES]; // Set byte if boss is invulnerable in all but a certain spot. (Dot product fvec|vec_to_collision < BOSS_INVULNERABLE_DOT) +#define BOSS_D2 21 // Minimum D2 boss value. +#define BOSS_COOL 21 +#define BOSS_WATER 22 +#define BOSS_FIRE 23 +#define BOSS_ICE 24 +#define BOSS_ALIEN1 25 +#define BOSS_ALIEN2 26 + +#define NUM_D2_BOSSES 8 + +extern ubyte Boss_teleports[NUM_D2_BOSSES]; // Set byte if this boss can teleport +extern ubyte Boss_spew_more[NUM_D2_BOSSES]; // Set byte if this boss can teleport +//extern ubyte Boss_cloaks[NUM_D2_BOSSES]; // Set byte if this boss can cloak +extern ubyte Boss_spews_bots_energy[NUM_D2_BOSSES]; // Set byte if boss spews bots when hit by energy weapon. +extern ubyte Boss_spews_bots_matter[NUM_D2_BOSSES]; // Set byte if boss spews bots when hit by matter weapon. +extern ubyte Boss_invulnerable_energy[NUM_D2_BOSSES]; // Set byte if boss is invulnerable to energy weapons. +extern ubyte Boss_invulnerable_matter[NUM_D2_BOSSES]; // Set byte if boss is invulnerable to matter weapons. +extern ubyte Boss_invulnerable_spot[NUM_D2_BOSSES]; // Set byte if boss is invulnerable in all but a certain spot. (Dot product fvec|vec_to_collision < BOSS_INVULNERABLE_DOT) extern fix Boss_cloak_start_time, Boss_cloak_end_time; -extern int Num_boss_teleport_segs; -extern short Boss_teleport_segs[MAX_BOSS_TELEPORT_SEGS]; -extern fix Last_teleport_time; -extern fix Boss_cloak_duration; +extern int Num_boss_teleport_segs; +extern short Boss_teleport_segs[MAX_BOSS_TELEPORT_SEGS]; +extern fix Last_teleport_time; +extern fix Boss_cloak_duration; -extern ai_local Ai_local_info[MAX_OBJECTS]; -extern vms_vector Believed_player_pos; +extern ai_local Ai_local_info[MAX_OBJECTS]; +extern vms_vector Believed_player_pos; extern int Believed_player_seg; extern void move_towards_segment_center(object *objp); @@ -205,7 +72,7 @@ extern void ai_move_one(object *objp); extern void do_ai_frame(object *objp); extern void init_ai_object(int objnum, int initial_mode, int hide_segment); extern void update_player_awareness(object *objp, fix new_awareness); -extern void create_awareness_event(object *objp, int type); // object *objp can create awareness of player, amount based on "type" +extern void create_awareness_event(object *objp, int type); // object *objp can create awareness of player, amount based on "type" extern void do_ai_frame_all(void); extern void init_ai_system(void); extern void reset_ai_states(object *objp); @@ -228,20 +95,20 @@ extern int ready_to_fire(robot_info *robptr, ai_local *ailp); extern int polish_path(object *objp, point_seg *psegs, int num_points); extern void move_towards_player(object *objp, vms_vector *vec_to_player); -// max_length is maximum depth of path to create. -// If -1, use default: MAX_DEPTH_TO_SEARCH_FOR_PLAYER +// max_length is maximum depth of path to create. +// If -1, use default: MAX_DEPTH_TO_SEARCH_FOR_PLAYER extern void create_path_to_player(object *objp, int max_length, int safety_flag); extern void attempt_to_resume_path(object *objp); -// When a robot and a player collide, some robots attack! +// When a robot and a player collide, some robots attack! extern void do_ai_robot_hit_attack(object *robot, object *player, vms_vector *collision_point); extern void ai_open_doors_in_segment(object *robot); extern int ai_door_is_openable(object *objp, segment *segp, int sidenum); extern int player_is_visible_from_object(object *objp, vms_vector *pos, fix field_of_view, vms_vector *vec_to_player); -extern void ai_reset_all_paths(void); // Reset all paths. Call at the start of a level. +extern void ai_reset_all_paths(void); // Reset all paths. Call at the start of a level. extern int ai_multiplayer_awareness(object *objp, int awareness_level); -// In escort.c +// In escort.c extern void do_escort_frame(object *objp, fix dist_to_player, int player_visibility); extern void do_snipe_frame(object *objp, fix dist_to_player, int player_visibility, vms_vector *vec_to_player); extern void do_thief_frame(object *objp, fix dist_to_player, int player_visibility, vms_vector *vec_to_player); @@ -257,167 +124,167 @@ extern void ai_init_boss_for_ship(void); extern int Boss_been_hit; extern fix AI_proc_time; -// Stuff moved from ai.c by MK on 05/25/95. -#define ANIM_RATE (F1_0/16) -#define DELTA_ANG_SCALE 16 +// Stuff moved from ai.c by MK on 05/25/95. +#define ANIM_RATE (F1_0/16) +#define DELTA_ANG_SCALE 16 -#define OVERALL_AGITATION_MAX 100 -#define MAX_AI_CLOAK_INFO 8 // Must be a power of 2! +#define OVERALL_AGITATION_MAX 100 +#define MAX_AI_CLOAK_INFO 8 // Must be a power of 2! typedef struct { - fix last_time; - int last_segment; - vms_vector last_position; + fix last_time; + int last_segment; + vms_vector last_position; } ai_cloak_info; -#define BOSS_CLOAK_DURATION (F1_0*7) -#define BOSS_DEATH_DURATION (F1_0*6) +#define BOSS_CLOAK_DURATION (F1_0*7) +#define BOSS_DEATH_DURATION (F1_0*6) -#define CHASE_TIME_LENGTH (F1_0*8) -#define DEFAULT_ROBOT_SOUND_VOLUME F1_0 +#define CHASE_TIME_LENGTH (F1_0*8) +#define DEFAULT_ROBOT_SOUND_VOLUME F1_0 -extern fix Dist_to_last_fired_upon_player_pos; -extern vms_vector Last_fired_upon_player_pos; -extern int Laser_rapid_fire; +extern fix Dist_to_last_fired_upon_player_pos; +extern vms_vector Last_fired_upon_player_pos; +extern int Laser_rapid_fire; -#define MAX_AWARENESS_EVENTS 64 +#define MAX_AWARENESS_EVENTS 64 typedef struct awareness_event { - short segnum; // segment the event occurred in - short type; // type of event, defines behavior - vms_vector pos; // absolute 3 space location of event + short segnum; // segment the event occurred in + short type; // type of event, defines behavior + vms_vector pos; // absolute 3 space location of event } awareness_event; -#define AIS_MAX 8 -#define AIE_MAX 4 - -#define ESCORT_GOAL_UNSPECIFIED -1 - -#define ESCORT_GOAL_UNSPECIFIED -1 -#define ESCORT_GOAL_BLUE_KEY 1 -#define ESCORT_GOAL_GOLD_KEY 2 -#define ESCORT_GOAL_RED_KEY 3 -#define ESCORT_GOAL_CONTROLCEN 4 -#define ESCORT_GOAL_EXIT 5 - -// Custom escort goals. -#define ESCORT_GOAL_ENERGY 6 -#define ESCORT_GOAL_ENERGYCEN 7 -#define ESCORT_GOAL_SHIELD 8 -#define ESCORT_GOAL_POWERUP 9 -#define ESCORT_GOAL_ROBOT 10 -#define ESCORT_GOAL_HOSTAGE 11 -#define ESCORT_GOAL_PLAYER_SPEW 12 -#define ESCORT_GOAL_SCRAM 13 -#define ESCORT_GOAL_EXIT2 14 -#define ESCORT_GOAL_BOSS 15 -#define ESCORT_GOAL_MARKER1 16 -#define ESCORT_GOAL_MARKER2 17 -#define ESCORT_GOAL_MARKER3 18 -#define ESCORT_GOAL_MARKER4 19 -#define ESCORT_GOAL_MARKER5 20 -#define ESCORT_GOAL_MARKER6 21 -#define ESCORT_GOAL_MARKER7 22 -#define ESCORT_GOAL_MARKER8 23 -#define ESCORT_GOAL_MARKER9 24 - -#define MAX_ESCORT_GOALS 25 - -#define MAX_ESCORT_DISTANCE (F1_0*80) -#define MIN_ESCORT_DISTANCE (F1_0*40) - -#define FUELCEN_CHECK 1000 - -extern fix Escort_last_path_created; -extern int Escort_goal_object, Escort_special_goal, Escort_goal_index; - -#define GOAL_WIDTH 11 - -#define SNIPE_RETREAT_TIME (F1_0*5) -#define SNIPE_ABORT_RETREAT_TIME (SNIPE_RETREAT_TIME/2) // Can abort a retreat with this amount of time left in retreat -#define SNIPE_ATTACK_TIME (F1_0*10) -#define SNIPE_WAIT_TIME (F1_0*5) -#define SNIPE_FIRE_TIME (F1_0*2) - -#define THIEF_PROBABILITY 16384 // 50% chance of stealing an item at each attempt -#define MAX_STOLEN_ITEMS 10 // Maximum number kept track of, will keep stealing, causes stolen weapons to be lost! - -extern int Max_escort_length; -extern int Escort_kill_object; +#define AIS_MAX 8 +#define AIE_MAX 4 + +#define ESCORT_GOAL_UNSPECIFIED -1 + +#define ESCORT_GOAL_UNSPECIFIED -1 +#define ESCORT_GOAL_BLUE_KEY 1 +#define ESCORT_GOAL_GOLD_KEY 2 +#define ESCORT_GOAL_RED_KEY 3 +#define ESCORT_GOAL_CONTROLCEN 4 +#define ESCORT_GOAL_EXIT 5 + +// Custom escort goals. +#define ESCORT_GOAL_ENERGY 6 +#define ESCORT_GOAL_ENERGYCEN 7 +#define ESCORT_GOAL_SHIELD 8 +#define ESCORT_GOAL_POWERUP 9 +#define ESCORT_GOAL_ROBOT 10 +#define ESCORT_GOAL_HOSTAGE 11 +#define ESCORT_GOAL_PLAYER_SPEW 12 +#define ESCORT_GOAL_SCRAM 13 +#define ESCORT_GOAL_EXIT2 14 +#define ESCORT_GOAL_BOSS 15 +#define ESCORT_GOAL_MARKER1 16 +#define ESCORT_GOAL_MARKER2 17 +#define ESCORT_GOAL_MARKER3 18 +#define ESCORT_GOAL_MARKER4 19 +#define ESCORT_GOAL_MARKER5 20 +#define ESCORT_GOAL_MARKER6 21 +#define ESCORT_GOAL_MARKER7 22 +#define ESCORT_GOAL_MARKER8 23 +#define ESCORT_GOAL_MARKER9 24 + +#define MAX_ESCORT_GOALS 25 + +#define MAX_ESCORT_DISTANCE (F1_0*80) +#define MIN_ESCORT_DISTANCE (F1_0*40) + +#define FUELCEN_CHECK 1000 + +extern fix Escort_last_path_created; +extern int Escort_goal_object, Escort_special_goal, Escort_goal_index; + +#define GOAL_WIDTH 11 + +#define SNIPE_RETREAT_TIME (F1_0*5) +#define SNIPE_ABORT_RETREAT_TIME (SNIPE_RETREAT_TIME/2) // Can abort a retreat with this amount of time left in retreat +#define SNIPE_ATTACK_TIME (F1_0*10) +#define SNIPE_WAIT_TIME (F1_0*5) +#define SNIPE_FIRE_TIME (F1_0*2) + +#define THIEF_PROBABILITY 16384 // 50% chance of stealing an item at each attempt +#define MAX_STOLEN_ITEMS 10 // Maximum number kept track of, will keep stealing, causes stolen weapons to be lost! + +extern int Max_escort_length; +extern int Escort_kill_object; extern ubyte Stolen_items[MAX_STOLEN_ITEMS]; -extern fix Escort_last_path_created; -extern int Escort_goal_object, Escort_special_goal, Escort_goal_index; +extern fix Escort_last_path_created; +extern int Escort_goal_object, Escort_special_goal, Escort_goal_index; -extern void create_buddy_bot(void); +extern void create_buddy_bot(void); -extern int Max_escort_length; +extern int Max_escort_length; -extern char *Escort_goal_text[MAX_ESCORT_GOALS]; +extern char *Escort_goal_text[MAX_ESCORT_GOALS]; -extern void ai_multi_send_robot_position(int objnum, int force); +extern void ai_multi_send_robot_position(int objnum, int force); -extern int Flinch_scale; -extern int Attack_scale; -extern byte Mike_to_matt_xlate[]; +extern int Flinch_scale; +extern int Attack_scale; +extern byte Mike_to_matt_xlate[]; -// Amount of time since the current robot was last processed for things such as movement. -// It is not valid to use FrameTime because robots do not get moved every frame. +// Amount of time since the current robot was last processed for things such as movement. +// It is not valid to use FrameTime because robots do not get moved every frame. -extern int Num_boss_teleport_segs; +extern int Num_boss_teleport_segs; extern short Boss_teleport_segs[]; -extern int Num_boss_gate_segs; -extern short Boss_gate_segs[]; - - -// --------- John: These variables must be saved as part of gamesave. --------- -extern int Ai_initialized; -extern int Overall_agitation; -extern ai_local Ai_local_info[MAX_OBJECTS]; -extern point_seg Point_segs[MAX_POINT_SEGS]; -extern point_seg *Point_segs_free_ptr; -extern ai_cloak_info Ai_cloak_info[MAX_AI_CLOAK_INFO]; -extern fix Boss_cloak_start_time; -extern fix Boss_cloak_end_time; -extern fix Last_teleport_time; -extern fix Boss_teleport_interval; -extern fix Boss_cloak_interval; // Time between cloaks -extern fix Boss_cloak_duration; -extern fix Last_gate_time; -extern fix Gate_interval; -extern fix Boss_dying_start_time; -extern byte Boss_dying, Boss_dying_sound_playing; -extern fix Boss_hit_time; -// -- extern int Boss_been_hit; -// ------ John: End of variables which must be saved as part of gamesave. ----- - -extern int ai_evaded; - -extern byte Super_boss_gate_list[]; -#define MAX_GATE_INDEX 25 - -extern int Ai_info_enabled; -extern int Robot_firing_enabled; - - -// These globals are set by a call to find_vector_intersection, which is a slow routine, -// so we don't want to call it again (for this object) unless we have to. -extern vms_vector Hit_pos; -extern int Hit_type, Hit_seg; -extern fvi_info Hit_data; - -extern int Num_awareness_events; -extern awareness_event Awareness_events[MAX_AWARENESS_EVENTS]; - -extern vms_vector Believed_player_pos; +extern int Num_boss_gate_segs; +extern short Boss_gate_segs[]; + + +// ---------- John: These variables must be saved as part of gamesave. ---------- +extern int Ai_initialized; +extern int Overall_agitation; +extern ai_local Ai_local_info[MAX_OBJECTS]; +extern point_seg Point_segs[MAX_POINT_SEGS]; +extern point_seg *Point_segs_free_ptr; +extern ai_cloak_info Ai_cloak_info[MAX_AI_CLOAK_INFO]; +extern fix Boss_cloak_start_time; +extern fix Boss_cloak_end_time; +extern fix Last_teleport_time; +extern fix Boss_teleport_interval; +extern fix Boss_cloak_interval; // Time between cloaks +extern fix Boss_cloak_duration; +extern fix Last_gate_time; +extern fix Gate_interval; +extern fix Boss_dying_start_time; +extern byte Boss_dying, Boss_dying_sound_playing; +extern fix Boss_hit_time; +// -- extern int Boss_been_hit; +// ---------- John: End of variables which must be saved as part of gamesave. ---------- + +extern int ai_evaded; + +extern byte Super_boss_gate_list[]; +#define MAX_GATE_INDEX 25 + +extern int Ai_info_enabled; +extern int Robot_firing_enabled; + + +// These globals are set by a call to find_vector_intersection, which is a slow routine, +// so we don't want to call it again (for this object) unless we have to. +extern vms_vector Hit_pos; +extern int Hit_type, Hit_seg; +extern fvi_info Hit_data; + +extern int Num_awareness_events; +extern awareness_event Awareness_events[MAX_AWARENESS_EVENTS]; + +extern vms_vector Believed_player_pos; #ifndef NDEBUG -// Index into this array with ailp->mode -extern char *mode_text[18]; +// Index into this array with ailp->mode +extern char *mode_text[18]; -// Index into this array with aip->behavior -extern char behavior_text[6][9]; +// Index into this array with aip->behavior +extern char behavior_text[6][9]; -// Index into this array with aip->GOAL_STATE or aip->CURRENT_STATE -extern char state_text[8][5]; +// Index into this array with aip->GOAL_STATE or aip->CURRENT_STATE +extern char state_text[8][5]; extern int Do_ai_flag, Break_on_object; @@ -425,7 +292,7 @@ extern void mprintf_animation_info(object *objp); #endif //ifndef NDEBUG -extern int Stolen_item_index; // Used in ai.c for controlling rate of Thief flare firing. +extern int Stolen_item_index; // Used in ai.c for controlling rate of Thief flare firing. extern void ai_frame_animation(object *objp); extern int do_silly_animation(object *objp); @@ -441,23 +308,27 @@ extern void ai_move_relative_to_player(object *objp, ai_local *ailp, fix dist_to extern void move_away_from_player(object *objp, vms_vector *vec_to_player, int attack_type); extern void move_towards_vector(object *objp, vms_vector *vec_goal, int dot_based); extern void init_ai_frame(void); +extern void detect_escort_goal_accomplished(int index); +extern void set_escort_special_goal(int key); extern void create_bfs_list(int start_seg, short bfs_list[], int *length, int max_segs); extern void init_thief_for_level(); + + extern int Escort_goal_object; extern int ai_save_state( FILE * fp ); extern int ai_restore_state( FILE * fp, int version ); -extern int Buddy_objnum, Buddy_allowed_to_talk; +extern int Buddy_objnum, Buddy_allowed_to_talk; extern void start_robot_death_sequence(object *objp); extern int do_any_robot_dying_frame(object *objp); extern void buddy_message(char * format, ... ); -#define SPECIAL_REACTOR_ROBOT 65 +#define SPECIAL_REACTOR_ROBOT 65 extern void special_reactor_stuff(void); -#endif /* _AI_H */ +#endif diff --git a/main/automap.c b/main/automap.c index a80fae43..954c0eec 100644 --- a/main/automap.c +++ b/main/automap.c @@ -1,4 +1,3 @@ -/* $Id: automap.c,v 1.10 2003-04-29 08:33:25 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,14 +7,19 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/automap.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-31 11:16:08 $ * * FIXME: put description here * + * $Log: not supported by cvs2svn $ * */ @@ -80,10 +84,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "poly_acc.h" #endif -#ifdef OGL -#define AUTOMAP_DIRECT_RENDER -#endif - #define EF_USED 1 // This edge is used #define EF_DEFINING 2 // A structure defining edge that should always draw. #define EF_FRONTIER 4 // An edge between the known and the unknown. @@ -175,7 +175,6 @@ static short DrawingListBright[MAX_EDGES]; #define ZOOM_SPEED_FACTOR 500 //(1500) #define ROT_SPEED_DIVISOR (115000) -#ifndef AUTOMAP_DIRECT_RENDER // Screen anvas variables static int current_page=0; #ifdef WINDOWS @@ -194,7 +193,6 @@ static dd_grs_canvas ddDrawingPages[2]; static grs_canvas Pages[2]; static grs_canvas DrawingPages[2]; #endif -#endif /* AUTOMAP_DIRECT_RENDER */ #define Page Pages[0] #define DrawingPage DrawingPages[0] @@ -408,7 +406,6 @@ void automap_clear_visited() } grs_canvas *name_canv_left,*name_canv_right; -char name_level[128]; void draw_player( object * obj ) { @@ -613,7 +610,6 @@ void draw_automap() #endif #endif -#ifndef AUTOMAP_DIRECT_RENDER if (!AutomapHires) { WIN(mprintf((1, "Can't do lores automap in Windows!\n"))); WIN(Int3()); @@ -626,7 +622,6 @@ void draw_automap() gr_set_current_canvas(&DrawingPage) ); } -#endif #if defined(POLY_ACC) pa_flush(); @@ -723,16 +718,9 @@ WIN(DDGRLOCK(dd_grd_curcanv)); gr_bitmapm(AutomapHires?10:AutomapHires?10:5,5,&name_canv_left->cv_bitmap); gr_bitmapm(grd_curcanv->cv_bitmap.bm_w-(AutomapHires?10:5)-name_canv_right->cv_bitmap.bm_w,AutomapHires?10:5,&name_canv_right->cv_bitmap); - gr_set_curfont(GAME_FONT); - gr_set_fontcolor(BM_XRGB(0,31,0),-1); - gr_uprintf(5,5,name_level); } WIN(DDGRUNLOCK(dd_grd_curcanv)); -#ifdef OGL - ogl_swap_buffers(); -#else -#ifndef AUTOMAP_DIRECT_RENDER if (!AutomapHires) gr_show_canvas( &Pages[current_page] ); else { @@ -743,9 +731,12 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); dd_gr_blt_screen(&ddPage, 0,0,0,0,0,0,0,0); #endif } +#ifdef OGL + ogl_swap_buffers(); +#else gr_update(); #endif -#endif + } #ifdef WINDOWS @@ -841,7 +832,7 @@ void create_name_canv() else sprintf(name_level_left, "Secret Level %i",-Current_level_num); - if (Current_mission_num == Builtin_mission_num && Current_level_num>0) //built-in mission + if (Current_mission_num == 0 && Current_level_num>0) //built-in mission sprintf(name_level_right,"%s %d: ",system_name[(Current_level_num-1)/4],((Current_level_num-1)%4)+1); else strcpy(name_level_right, " "); @@ -857,27 +848,18 @@ void create_name_canv() void modex_print_message(int x, int y, char *str) { if (!AutomapHires) { -#ifndef AUTOMAP_DIRECT_RENDER int i; for (i=0; i<2; i++ ) { gr_set_current_canvas(&Pages[i]); -#endif - modex_printf(x, y, str, MEDIUM1_FONT,Font_color_20); -#ifndef AUTOMAP_DIRECT_RENDER } gr_set_current_canvas(&DrawingPages[current_page]); -#endif } else { -#ifndef AUTOMAP_DIRECT_RENDER gr_set_current_canvas(&Page); -#endif modex_printf(x, y, str, MEDIUM1_FONT,Font_color_20); -#ifndef AUTOMAP_DIRECT_RENDER gr_set_current_canvas(&DrawingPage); -#endif } } @@ -889,7 +871,7 @@ int Automap_active = 0; #ifdef RELEASE #define MAP_BACKGROUND_FILENAME (AutomapHires?"\x01MAPB.PCX":"\x01MAP.PCX") //load only from hog file #else -#define MAP_BACKGROUND_FILENAME ((AutomapHires && cfexist("mapb.pcx"))?"MAPB.PCX":"MAP.PCX") +#define MAP_BACKGROUND_FILENAME (AutomapHires?"MAPB.PCX":"MAP.PCX") #endif int Automap_always_hires=0; @@ -897,11 +879,6 @@ extern int MenuHiresAvailable; extern int Current_display_mode; -u_int32_t automap_mode = SM(640,480); -int automap_width = 640; -int automap_height = 480; -int automap_use_game_res=0; - void do_automap( int key_code ) { int done=0; vms_matrix tempm; @@ -909,9 +886,7 @@ void do_automap( int key_code ) { int leave_mode=0; int first_time=1; int pcx_error; -#if !defined(AUTOMAP_DIRECT_RENDER) || !defined(NDEBUG) int i; -#endif int c, marker_num; fix entry_time; int pause_game=1; // Set to 1 if everything is paused during automap...No pause during net. @@ -949,14 +924,7 @@ void do_automap( int key_code ) { #if !defined (WINDOWS) && !defined(MACINTOSH) if ((Current_display_mode!=0 && Current_display_mode!=2) || (Automap_always_hires && MenuHiresAvailable)) { #if !defined(POLY_ACC) - //edit 4/23/99 Matt Mueller - don't switch res unless we need to - if (grd_curscreen->sc_mode != AUTOMAP_MODE) - gr_set_mode( AUTOMAP_MODE ); - else - gr_set_current_canvas(NULL); - //end edit -MM - automap_width=grd_curscreen->sc_canvas.cv_bitmap.bm_w; - automap_height=grd_curscreen->sc_canvas.cv_bitmap.bm_h; + gr_set_mode( SM(640, 480) ); #endif PA_DFX (pa_set_frontbuffer_current()); AutomapHires = 1; @@ -975,7 +943,7 @@ void do_automap( int key_code ) { set_screen_mode(SCREEN_GAME); #endif - FontHires = FontHiresAvailable && AutomapHires; + FontHires = AutomapHires; create_name_canv(); @@ -983,75 +951,72 @@ void do_automap( int key_code ) { WIN(AutomapRedraw:) if (!AutomapHires) { -#ifndef MACINTOSH -#ifndef AUTOMAP_DIRECT_RENDER + #ifndef MACINTOSH gr_init_sub_canvas(&Pages[0],grd_curcanv,0,0,320,400); gr_init_sub_canvas(&Pages[1],grd_curcanv,0,401,320,400); gr_init_sub_canvas(&DrawingPages[0],&Pages[0],16,69,WINDOW_WIDTH,272); gr_init_sub_canvas(&DrawingPages[1],&Pages[1],16,69,WINDOW_WIDTH,272); -#endif - - gr_init_bitmap_data (&Automap_background); -// pcx_error = pcx_read_bitmap(MAP_BACKGROUND_FILENAME,&Automap_background,BM_LINEAR,pal); -// if ( pcx_error != PCX_ERROR_NONE ) -// Error("File %s - PCX error: %s",MAP_BACKGROUND_FILENAME,pcx_errormsg(pcx_error)); -// gr_remap_bitmap_good( &Automap_background, pal, -1, -1 ); - -#ifndef AUTOMAP_DIRECT_RENDER + + Automap_background.bm_data = NULL; + pcx_error = pcx_read_bitmap(MAP_BACKGROUND_FILENAME,&Automap_background,BM_LINEAR,pal); + if ( pcx_error != PCX_ERROR_NONE ) + Error("File %s - PCX error: %s",MAP_BACKGROUND_FILENAME,pcx_errormsg(pcx_error)); + gr_remap_bitmap_good( &Automap_background, pal, -1, -1 ); + for (i=0; i<2; i++ ) { gr_set_current_canvas(&Pages[i]); -// gr_bitmap( 0, 0, &Automap_background ); -// modex_printf( 40, 22,TXT_AUTOMAP,HUGE_FONT,Font_color_20); -// modex_printf( 30,353,TXT_TURN_SHIP,SMALL_FONT,Font_color_20); -// modex_printf( 30,369,TXT_SLIDE_UPDOWN,SMALL_FONT,Font_color_20); -// modex_printf( 30,385,TXT_VIEWING_DISTANCE,SMALL_FONT,Font_color_20); + gr_bitmap( 0, 0, &Automap_background ); + modex_printf( 40, 22,TXT_AUTOMAP,HUGE_FONT,Font_color_20); + modex_printf( 30,353,TXT_TURN_SHIP,SMALL_FONT,Font_color_20); + modex_printf( 30,369,TXT_SLIDE_UPDOWN,SMALL_FONT,Font_color_20); + modex_printf( 30,385,TXT_VIEWING_DISTANCE,SMALL_FONT,Font_color_20); } - gr_free_bitmap_data(&Automap_background); + if ( Automap_background.bm_data ) + d_free( Automap_background.bm_data ); + Automap_background.bm_data = NULL; + gr_set_current_canvas(&DrawingPages[current_page]); -#endif /* AUTOMAP_DIRECT_RENDER */ -#endif /* MACINTOSH */ + #endif } else { -#ifndef AUTOMAP_DIRECT_RENDER - if (VR_render_buffer[0].cv_w >= automap_width && VR_render_buffer[0].cv_h >= automap_height) + if (VR_render_buffer[0].cv_w >= 640 && VR_render_buffer[0].cv_h >= 480) { - WIN(dd_gr_init_sub_canvas(&ddPage, &dd_VR_render_buffer[0], 0, 0, automap_width,automap_height)); + WIN(dd_gr_init_sub_canvas(&ddPage, &dd_VR_render_buffer[0], 0, 0, 640,480)); #if defined(MACINTOSH) && defined(POLY_ACC) if (PAEnabled) { // we want all the automap border stuff to be drawn straight to the screen - gr_init_sub_canvas(&Page,&(grd_curscreen->sc_canvas),0, 0, automap_width, automap_height); + gr_init_sub_canvas(&Page,&(grd_curscreen->sc_canvas),0, 0, 640, 480); } else { - gr_init_sub_canvas(&Page,&VR_render_buffer[0],0, 0, automap_width, automap_height); + gr_init_sub_canvas(&Page,&VR_render_buffer[0],0, 0, 640, 480); } #else - gr_init_sub_canvas(&Page,&VR_render_buffer[0],0, 0, automap_width, automap_height); + gr_init_sub_canvas(&Page,&VR_render_buffer[0],0, 0, 640, 480); #endif } else { #ifndef WINDOWS void *raw_data; - MALLOC(raw_data,ubyte,automap_width*automap_height); - gr_init_canvas(&Page,raw_data,BM_LINEAR,automap_width,automap_height); + MALLOC(raw_data,ubyte,640*480); + gr_init_canvas(&Page,raw_data,BM_LINEAR,640,480); #else - dd_gr_init_canvas(&ddPage, BM_LINEAR, automap_width,automap_height); - gr_init_canvas(&Page,NULL,BM_LINEAR,automap_width,automap_height); + dd_gr_init_canvas(&ddPage, BM_LINEAR, 640,480); + gr_init_canvas(&Page,NULL,BM_LINEAR,640,480); #endif must_free_canvas = 1; } - WIN(dd_gr_init_sub_canvas(&ddDrawingPage, &ddPage, 0,0,automap_width,automap_height)); - gr_init_sub_canvas(&DrawingPage,&Page, 0,0,automap_width,automap_height); + WIN(dd_gr_init_sub_canvas(&ddDrawingPage, &ddPage, 27,80,582,334)); + gr_init_sub_canvas(&DrawingPage,&Page,27,80,582,334); WINDOS( dd_gr_set_current_canvas(&ddPage), gr_set_current_canvas(&Page) ); -#endif #if defined(POLY_ACC) @@ -1102,12 +1067,10 @@ WIN(AutomapRedraw:) gr_printf( 60, 460,TXT_VIEWING_DISTANCE); WIN(DDGRUNLOCK(dd_grd_curcanv)); -#ifndef AUTOMAP_DIRECT_RENDER WINDOS( dd_gr_set_current_canvas(&ddDrawingPage), gr_set_current_canvas(&DrawingPage) ); -#endif } @@ -1205,10 +1168,8 @@ WIN(if (redraw_screen) redraw_screen = 0); gr_set_current_canvas(NULL) ); } -#ifndef AUTOMAP_DIRECT_RENDER else gr_set_current_canvas(&Pages[current_page]); -#endif save_screen_shot(1); break; } @@ -1281,18 +1242,14 @@ WIN(if (redraw_screen) redraw_screen = 0); break; case KEY_D+KEY_CTRLED: -#ifndef AUTOMAP_DIRECT_RENDER if (current_page) //menu will only work on page 0 draw_automap(); //..so switch from 1 to 0 -#endif if (HighlightMarker > -1 && MarkerObject[HighlightMarker] != -1) { -#ifndef AUTOMAP_DIRECT_RENDER WINDOS( dd_gr_set_current_canvas(&ddPages[current_page]), gr_set_current_canvas(&Pages[current_page]) ); -#endif if (nm_messagebox( NULL, 2, TXT_YES, TXT_NO, "Delete Marker?" ) == 0) { obj_delete(MarkerObject[HighlightMarker]); @@ -1311,42 +1268,8 @@ WIN(if (redraw_screen) redraw_screen = 0); case KEY_PERIOD: if (MarkerScale<30.0) MarkerScale+=.5; - break; #endif -//added 8/23/99 by Matt Mueller for hot key res/fullscreen changing, and menu access -#if 0 - case KEY_CTRLED+KEY_SHIFTED+KEY_PADDIVIDE: - case KEY_ALTED+KEY_CTRLED+KEY_PADDIVIDE: - case KEY_ALTED+KEY_SHIFTED+KEY_PADDIVIDE: - d1x_options_menu(); - break; - case KEY_CTRLED+KEY_SHIFTED+KEY_PADMULTIPLY: - case KEY_ALTED+KEY_CTRLED+KEY_PADMULTIPLY: - case KEY_ALTED+KEY_SHIFTED+KEY_PADMULTIPLY: - change_res(); - break; - case KEY_CTRLED+KEY_SHIFTED+KEY_PADMINUS: - case KEY_ALTED+KEY_CTRLED+KEY_PADMINUS: - case KEY_ALTED+KEY_SHIFTED+KEY_PADMINUS: - //lower res - //should we just cycle through the list that is displayed in the res change menu? - // what if their card/X/etc can't handle that mode? hrm. - //well, the quick access to the menu is good enough for now. - break; - case KEY_CTRLED+KEY_SHIFTED+KEY_PADPLUS: - case KEY_ALTED+KEY_CTRLED+KEY_PADPLUS: - case KEY_ALTED+KEY_SHIFTED+KEY_PADPLUS: - //increase res - break; -#endif - case KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER: - case KEY_ALTED+KEY_CTRLED+KEY_PADENTER: - case KEY_ALTED+KEY_SHIFTED+KEY_PADENTER: - gr_toggle_fullscreen_game(); - break; -//end addition -MM - } } @@ -1405,12 +1328,10 @@ WIN(if (redraw_screen) redraw_screen = 0); gr_free_canvas(name_canv_right); name_canv_right=NULL; if (must_free_canvas) { -#ifndef AUTOMAP_DIRECT_RENDER WINDOS( DDFreeSurface(ddPages[0].lpdds), d_free(Page.cv_bitmap.bm_data) ); -#endif } mprintf( (0, "Automap memory freed\n" )); diff --git a/main/automap.h b/main/automap.h index e13f2be1..e4d99bcd 100644 --- a/main/automap.h +++ b/main/automap.h @@ -33,12 +33,4 @@ extern char MarkerMessage[NUM_MARKERS][MARKER_MESSAGE_LEN]; extern char MarkerOwner[NUM_MARKERS][CALLSIGN_LEN+1]; extern int MarkerObject[NUM_MARKERS]; -//added on 9/30/98 by Matt Mueller for selectable automap modes -extern u_int32_t automap_mode ; -#define AUTOMAP_MODE (automap_use_game_res?grd_curscreen->sc_mode:automap_mode) -//extern int automap_width ; -//extern int automap_height ; -//end addition -MM -extern int automap_use_game_res; - #endif diff --git a/main/bm.c b/main/bm.c index d76a1d3a..7fc7660d 100644 --- a/main/bm.c +++ b/main/bm.c @@ -1,4 +1,3 @@ -/* $Id: bm.c,v 1.32 2003-05-13 01:13:08 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,30 +7,28 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/bm.c,v $ + * $Revision: 1.7 $ + * $Author: bradleyb $ + * $Date: 2001-11-14 09:34:32 $ * * Bitmap and palette loading functions. * - * Old Log: - * Revision 1.1 1995/05/16 15:23:08 allender - * Initial revision + * $Log: not supported by cvs2svn $ + * Revision 1.6 2001/11/02 02:22:25 bradleyb + * formatting * - * Revision 2.3 1995/03/14 16:22:04 john - * Added cdrom alternate directory stuff. + * Revision 1.5 2001/10/25 02:15:55 bradleyb + * conditionalize including multi.h and network.h, fix backslashes * - * Revision 2.2 1995/03/07 16:51:48 john - * Fixed robots not moving without edtiro bug. + * Revision 1.4 2001/10/19 08:06:20 bradleyb + * Partial application of linux/alpha patch. Courtesy of Falk Hueffner * - * Revision 2.1 1995/03/06 15:23:06 john - * New screen techniques. - * - * Revision 2.0 1995/02/27 11:27:05 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. * */ @@ -41,7 +38,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #include -#include #include "pstypes.h" #include "inferno.h" @@ -72,8 +68,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "player.h" #include "endlevel.h" #include "cntrlcen.h" +#include "byteswap.h" #include "makesig.h" -#include "interp.h" ubyte Sounds[MAX_SOUNDS]; ubyte AltSounds[MAX_SOUNDS]; @@ -92,70 +88,488 @@ int Dead_modelnums[MAX_POLYGON_MODELS]; //the polygon model number to use for the marker int Marker_model_num = -1; -//right now there's only one player ship, but we can have another by +//right now there's only one player ship, but we can have another by //adding an array and setting the pointer to the active ship. player_ship only_player_ship,*Player_ship=&only_player_ship; //----------------- Miscellaneous bitmap pointers --------------- -int Num_cockpits = 0; -bitmap_index cockpit_bitmap[N_COCKPIT_BITMAPS]; +int Num_cockpits = 0; +bitmap_index cockpit_bitmap[N_COCKPIT_BITMAPS]; //---------------- Variables for wall textures ------------------ -int Num_tmaps; -tmap_info TmapInfo[MAX_TEXTURES]; +int Num_tmaps; +tmap_info TmapInfo[MAX_TEXTURES]; //---------------- Variables for object textures ---------------- -int First_multi_bitmap_num=-1; +int First_multi_bitmap_num=-1; -int N_ObjBitmaps; -bitmap_index ObjBitmaps[MAX_OBJ_BITMAPS]; -ushort ObjBitmapPtrs[MAX_OBJ_BITMAPS]; // These point back into ObjBitmaps, since some are used twice. +bitmap_index ObjBitmaps[MAX_OBJ_BITMAPS]; +ushort ObjBitmapPtrs[MAX_OBJ_BITMAPS]; // These point back into ObjBitmaps, since some are used twice. -#ifdef FAST_FILE_IO -#define tmap_info_read_n(ti, n, fp) cfread(ti, sizeof(tmap_info), n, fp) -#else -/* - * reads n tmap_info structs from a CFILE - */ -int tmap_info_read_n(tmap_info *ti, int n, CFILE *fp) +#ifdef PORTABLE_LOADER +void read_tmap_info(CFILE *fp, int inNumTexturesToRead, int inOffset) { int i; + + for (i = inOffset; i < (inNumTexturesToRead + inOffset); i++) + { + TmapInfo[i].flags = cfile_read_byte(fp); + TmapInfo[i].pad[0] = cfile_read_byte(fp); + TmapInfo[i].pad[1] = cfile_read_byte(fp); + TmapInfo[i].pad[2] = cfile_read_byte(fp); + TmapInfo[i].lighting = cfile_read_fix(fp); + TmapInfo[i].damage = cfile_read_fix(fp); + TmapInfo[i].eclip_num = cfile_read_short(fp); + TmapInfo[i].destroyed = cfile_read_short(fp); + TmapInfo[i].slide_u = cfile_read_short(fp); + TmapInfo[i].slide_v = cfile_read_short(fp); + } +} - for (i = 0; i < n; i++) { - ti[i].flags = cfile_read_byte(fp); - ti[i].pad[0] = cfile_read_byte(fp); - ti[i].pad[1] = cfile_read_byte(fp); - ti[i].pad[2] = cfile_read_byte(fp); - ti[i].lighting = cfile_read_fix(fp); - ti[i].damage = cfile_read_fix(fp); - ti[i].eclip_num = cfile_read_short(fp); - ti[i].destroyed = cfile_read_short(fp); - ti[i].slide_u = cfile_read_short(fp); - ti[i].slide_v = cfile_read_short(fp); +void read_vclip_info(CFILE *fp, int inNumVClipsToRead, int inOffset) +{ + int i, j; + + for (i = inOffset; i < (inNumVClipsToRead + inOffset); i++) + { + Vclip[i].play_time = cfile_read_fix(fp); + Vclip[i].num_frames = cfile_read_int(fp); + Vclip[i].frame_time = cfile_read_fix(fp); + Vclip[i].flags = cfile_read_int(fp); + Vclip[i].sound_num = cfile_read_short(fp); + for (j = 0; j < VCLIP_MAX_FRAMES; j++) + Vclip[i].frames[j].index = cfile_read_short(fp); + Vclip[i].light_value = cfile_read_fix(fp); } - return i; } -#endif -int tmap_info_read_n_d1(tmap_info *ti, int n, CFILE *fp) +void read_effect_info(CFILE *fp, int inNumEffectsToRead, int inOffset) +{ + int i, j; + + + for (i = inOffset; i < (inNumEffectsToRead + inOffset); i++) + { + Effects[i].vc.play_time = cfile_read_fix(fp); + Effects[i].vc.num_frames = cfile_read_int(fp); + Effects[i].vc.frame_time = cfile_read_fix(fp); + Effects[i].vc.flags = cfile_read_int(fp); + Effects[i].vc.sound_num = cfile_read_short(fp); + for (j = 0; j < VCLIP_MAX_FRAMES; j++) + Effects[i].vc.frames[j].index = cfile_read_short(fp); + Effects[i].vc.light_value = cfile_read_fix(fp); + Effects[i].time_left = cfile_read_fix(fp); + Effects[i].frame_count = cfile_read_int(fp); + Effects[i].changing_wall_texture = cfile_read_short(fp); + Effects[i].changing_object_texture = cfile_read_short(fp); + Effects[i].flags = cfile_read_int(fp); + Effects[i].crit_clip = cfile_read_int(fp); + Effects[i].dest_bm_num = cfile_read_int(fp); + Effects[i].dest_vclip = cfile_read_int(fp); + Effects[i].dest_eclip = cfile_read_int(fp); + Effects[i].dest_size = cfile_read_fix(fp); + Effects[i].sound_num = cfile_read_int(fp); + Effects[i].segnum = cfile_read_int(fp); + Effects[i].sidenum = cfile_read_int(fp); + } +} + +void read_wallanim_info(CFILE *fp, int inNumWallAnimsToRead, int inOffset) +{ + int i, j; + + for (i = inOffset; i < (inNumWallAnimsToRead + inOffset); i++) + { + WallAnims[i].play_time = cfile_read_fix(fp);; + WallAnims[i].num_frames = cfile_read_short(fp);; + for (j = 0; j < MAX_CLIP_FRAMES; j++) + WallAnims[i].frames[j] = cfile_read_short(fp); + WallAnims[i].open_sound = cfile_read_short(fp); + WallAnims[i].close_sound = cfile_read_short(fp); + WallAnims[i].flags = cfile_read_short(fp); + cfread(WallAnims[i].filename, 13, 1, fp); + WallAnims[i].pad = cfile_read_byte(fp); + } +} + +void read_robot_info(CFILE *fp, int inNumRobotsToRead, int inOffset) +{ + int i, j, k; + + for (i = inOffset; i < (inNumRobotsToRead + inOffset); i++) + { + Robot_info[i].model_num = cfile_read_int(fp); + for (j = 0; j < MAX_GUNS; j++) + cfile_read_vector(&(Robot_info[i].gun_points[j]), fp); + for (j = 0; j < MAX_GUNS; j++) + Robot_info[i].gun_submodels[j] = cfile_read_byte(fp); + + Robot_info[i].exp1_vclip_num = cfile_read_short(fp); + Robot_info[i].exp1_sound_num = cfile_read_short(fp); + + Robot_info[i].exp2_vclip_num = cfile_read_short(fp); + Robot_info[i].exp2_sound_num = cfile_read_short(fp); + + Robot_info[i].weapon_type = cfile_read_byte(fp); + Robot_info[i].weapon_type2 = cfile_read_byte(fp); + Robot_info[i].n_guns = cfile_read_byte(fp); + Robot_info[i].contains_id = cfile_read_byte(fp); + + Robot_info[i].contains_count = cfile_read_byte(fp); + Robot_info[i].contains_prob = cfile_read_byte(fp); + Robot_info[i].contains_type = cfile_read_byte(fp); + Robot_info[i].kamikaze = cfile_read_byte(fp); + + Robot_info[i].score_value = cfile_read_short(fp); + Robot_info[i].badass = cfile_read_byte(fp); + Robot_info[i].energy_drain = cfile_read_byte(fp); + + Robot_info[i].lighting = cfile_read_fix(fp); + Robot_info[i].strength = cfile_read_fix(fp); + + Robot_info[i].mass = cfile_read_fix(fp); + Robot_info[i].drag = cfile_read_fix(fp); + + for (j = 0; j < NDL; j++) + Robot_info[i].field_of_view[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + Robot_info[i].firing_wait[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + Robot_info[i].firing_wait2[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + Robot_info[i].turn_time[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + Robot_info[i].max_speed[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + Robot_info[i].circle_distance[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + cfread(&(Robot_info[i].rapidfire_count[j]), sizeof(byte), 1, fp); + for (j = 0; j < NDL; j++) + cfread(&(Robot_info[i].evade_speed[j]), sizeof(byte), 1, fp); + Robot_info[i].cloak_type = cfile_read_byte(fp); + Robot_info[i].attack_type = cfile_read_byte(fp); + + Robot_info[i].see_sound = cfile_read_byte(fp); + Robot_info[i].attack_sound = cfile_read_byte(fp); + Robot_info[i].claw_sound = cfile_read_byte(fp); + Robot_info[i].taunt_sound = cfile_read_byte(fp); + + Robot_info[i].boss_flag = cfile_read_byte(fp); + Robot_info[i].companion = cfile_read_byte(fp); + Robot_info[i].smart_blobs = cfile_read_byte(fp); + Robot_info[i].energy_blobs = cfile_read_byte(fp); + + Robot_info[i].thief = cfile_read_byte(fp); + Robot_info[i].pursuit = cfile_read_byte(fp); + Robot_info[i].lightcast = cfile_read_byte(fp); + Robot_info[i].death_roll = cfile_read_byte(fp); + + Robot_info[i].flags = cfile_read_byte(fp); + Robot_info[i].pad[0] = cfile_read_byte(fp); + Robot_info[i].pad[1] = cfile_read_byte(fp); + Robot_info[i].pad[2] = cfile_read_byte(fp); + + Robot_info[i].deathroll_sound = cfile_read_byte(fp); + Robot_info[i].glow = cfile_read_byte(fp); + Robot_info[i].behavior = cfile_read_byte(fp); + Robot_info[i].aim = cfile_read_byte(fp); + + for (j = 0; j < MAX_GUNS + 1; j++) { + for (k = 0; k < N_ANIM_STATES; k++) { + Robot_info[i].anim_states[j][k].n_joints = cfile_read_short(fp); + Robot_info[i].anim_states[j][k].offset = cfile_read_short(fp); + } + } + + Robot_info[i].always_0xabcd = cfile_read_int(fp); + } +} + +void read_robot_joint_info(CFILE *fp, int inNumRobotJointsToRead, int inOffset) { int i; - for (i = 0; i < n; i++) { - cfseek(fp, 13, SEEK_CUR);// skip filename - ti[i].flags = cfile_read_byte(fp); - ti[i].lighting = cfile_read_fix(fp); - ti[i].damage = cfile_read_fix(fp); - ti[i].eclip_num = cfile_read_int(fp); + for (i = inOffset; i < (inNumRobotJointsToRead + inOffset); i++) + { + Robot_joints[i].jointnum = cfile_read_short(fp); + cfile_read_angvec(&(Robot_joints[i].angles), fp); + } +} + +void read_weapon_info(CFILE *fp, int inNumWeaponsToRead, int inOffset) +{ + int i, j; + + for (i = inOffset; i < (inNumWeaponsToRead + inOffset); i++) + { + Weapon_info[i].render_type = cfile_read_byte(fp); + Weapon_info[i].persistent = cfile_read_byte(fp); + Weapon_info[i].model_num = cfile_read_short(fp); + Weapon_info[i].model_num_inner = cfile_read_short(fp); + + Weapon_info[i].flash_vclip = cfile_read_byte(fp); + Weapon_info[i].robot_hit_vclip = cfile_read_byte(fp); + Weapon_info[i].flash_sound = cfile_read_short(fp); + + Weapon_info[i].wall_hit_vclip = cfile_read_byte(fp); + Weapon_info[i].fire_count = cfile_read_byte(fp); + Weapon_info[i].robot_hit_sound = cfile_read_short(fp); + + Weapon_info[i].ammo_usage = cfile_read_byte(fp); + Weapon_info[i].weapon_vclip = cfile_read_byte(fp); + Weapon_info[i].wall_hit_sound = cfile_read_short(fp); + + Weapon_info[i].destroyable = cfile_read_byte(fp); + Weapon_info[i].matter = cfile_read_byte(fp); + Weapon_info[i].bounce = cfile_read_byte(fp); + Weapon_info[i].homing_flag = cfile_read_byte(fp); + + Weapon_info[i].speedvar = cfile_read_byte(fp); + Weapon_info[i].flags = cfile_read_byte(fp); + Weapon_info[i].flash = cfile_read_byte(fp); + Weapon_info[i].afterburner_size = cfile_read_byte(fp); + + Weapon_info[i].children = cfile_read_byte(fp); + + Weapon_info[i].energy_usage = cfile_read_fix(fp); + Weapon_info[i].fire_wait = cfile_read_fix(fp); + + Weapon_info[i].multi_damage_scale = cfile_read_fix(fp); + + Weapon_info[i].bitmap.index = cfile_read_short(fp); // bitmap_index = short + + Weapon_info[i].blob_size = cfile_read_fix(fp); + Weapon_info[i].flash_size = cfile_read_fix(fp); + Weapon_info[i].impact_size = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + Weapon_info[i].strength[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + Weapon_info[i].speed[j] = cfile_read_fix(fp); + Weapon_info[i].mass = cfile_read_fix(fp); + Weapon_info[i].drag = cfile_read_fix(fp); + Weapon_info[i].thrust = cfile_read_fix(fp); + Weapon_info[i].po_len_to_width_ratio = cfile_read_fix(fp); + Weapon_info[i].light = cfile_read_fix(fp); + Weapon_info[i].lifetime = cfile_read_fix(fp); + Weapon_info[i].damage_radius = cfile_read_fix(fp); + Weapon_info[i].picture.index = cfile_read_short(fp); // bitmap_index is a short + Weapon_info[i].hires_picture.index = cfile_read_short(fp); // bitmap_index is a short + } +} + +void read_powerup_info(CFILE *fp, int inNumPowerupsToRead, int inOffset) +{ + int i; + + for (i = inOffset; i < (inNumPowerupsToRead + inOffset); i++) + { + Powerup_info[i].vclip_num = cfile_read_int(fp); + Powerup_info[i].hit_sound = cfile_read_int(fp); + Powerup_info[i].size = cfile_read_fix(fp); + Powerup_info[i].light = cfile_read_fix(fp); + } +} + +void read_polygon_models(CFILE *fp, int inNumPolygonModelsToRead, int inOffset) +{ + int i, j; + + for (i = inOffset; i < (inNumPolygonModelsToRead + inOffset); i++) + { + Polygon_models[i].n_models = cfile_read_int(fp); + Polygon_models[i].model_data_size = cfile_read_int(fp); + Polygon_models[i].model_data = (ubyte *) cfile_read_int(fp); + for (j = 0; j < MAX_SUBMODELS; j++) + Polygon_models[i].submodel_ptrs[j] = cfile_read_int(fp); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_offsets[j]), fp); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_norms[j]), fp); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_pnts[j]), fp); + for (j = 0; j < MAX_SUBMODELS; j++) + Polygon_models[i].submodel_rads[j] = cfile_read_fix(fp); + for (j = 0; j < MAX_SUBMODELS; j++) + Polygon_models[i].submodel_parents[j] = cfile_read_byte(fp); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_mins[j]), fp); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_maxs[j]), fp); + cfile_read_vector(&(Polygon_models[i].mins), fp); + cfile_read_vector(&(Polygon_models[i].maxs), fp); + Polygon_models[i].rad = cfile_read_fix(fp); + Polygon_models[i].n_textures = cfile_read_byte(fp); + Polygon_models[i].first_texture = cfile_read_short(fp); + Polygon_models[i].simpler_model = cfile_read_byte(fp); + } +} + +void read_player_ship(CFILE *fp) +{ + int i; + + only_player_ship.model_num = cfile_read_int(fp); + only_player_ship.expl_vclip_num = cfile_read_int(fp); + only_player_ship.mass = cfile_read_fix(fp); + only_player_ship.drag = cfile_read_fix(fp); + only_player_ship.max_thrust = cfile_read_fix(fp); + only_player_ship.reverse_thrust = cfile_read_fix(fp); + only_player_ship.brakes = cfile_read_fix(fp); + only_player_ship.wiggle = cfile_read_fix(fp); + only_player_ship.max_rotthrust = cfile_read_fix(fp); + for (i = 0; i < N_PLAYER_GUNS; i++) + cfile_read_vector(&(only_player_ship.gun_points[i]), fp); +} + +void read_reactor_info(CFILE *fp, int inNumReactorsToRead, int inOffset) +{ + int i, j; + + for (i = inOffset; i < (inNumReactorsToRead + inOffset); i++) + { + Reactors[i].model_num = cfile_read_int(fp); + Reactors[i].n_guns = cfile_read_int(fp); + for (j = 0; j < MAX_CONTROLCEN_GUNS; j++) + cfile_read_vector(&(Reactors[i].gun_points[j]), fp); + for (j = 0; j < MAX_CONTROLCEN_GUNS; j++) + cfile_read_vector(&(Reactors[i].gun_dirs[j]), fp); + } +} + +#ifdef SHAREWARE +extern int exit_modelnum,destroyed_exit_modelnum, Num_bitmap_files; +int N_ObjBitmaps, extra_bitmap_num; + +bitmap_index exitmodel_bm_load_sub( char * filename ) +{ + bitmap_index bitmap_num; + grs_bitmap * new; + ubyte newpal[256*3]; + int i, iff_error; //reference parm to avoid warning message + + bitmap_num.index = 0; + + MALLOC( new, grs_bitmap, 1 ); + iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal); + new->bm_handle=0; + if (iff_error != IFF_NO_ERROR) { + Error("Error loading exit model bitmap <%s> - IFF error: %s",filename,iff_errormsg(iff_error)); + } + + if ( iff_has_transparency ) + gr_remap_bitmap_good( new, newpal, iff_transparent_color, 254 ); + else + gr_remap_bitmap_good( new, newpal, -1, 254 ); + + new->avg_color = 0; //compute_average_pixel(new); + + bitmap_num.index = extra_bitmap_num; + + GameBitmaps[extra_bitmap_num++] = *new; + + d_free( new ); + return bitmap_num; +} + +grs_bitmap *load_exit_model_bitmap(char *name) +{ + Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS); + + { + ObjBitmaps[N_ObjBitmaps] = exitmodel_bm_load_sub(name); + if (GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_w!=64 || GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_h!=64) + Error("Bitmap <%s> is not 64x64",name); + ObjBitmapPtrs[N_ObjBitmaps] = N_ObjBitmaps; + N_ObjBitmaps++; + Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS); + return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index]; } - return i; } +void load_exit_models() +{ + CFILE *exit_hamfile; + int i, j; + ubyte pal[768]; + int start_num; + + start_num = N_ObjBitmaps; + extra_bitmap_num = Num_bitmap_files; + load_exit_model_bitmap("steel1.bbm"); + load_exit_model_bitmap("rbot061.bbm"); + load_exit_model_bitmap("rbot062.bbm"); + + load_exit_model_bitmap("steel1.bbm"); + load_exit_model_bitmap("rbot061.bbm"); + load_exit_model_bitmap("rbot063.bbm"); + + exit_hamfile = cfopen(":Data:exit.ham","rb"); + + exit_modelnum = N_polygon_models++; + destroyed_exit_modelnum = N_polygon_models++; + +#ifndef PORTABLE_LOADER + cfread( &Polygon_models[exit_modelnum], sizeof(polymodel), 1, exit_hamfile ); + cfread( &Polygon_models[destroyed_exit_modelnum], sizeof(polymodel), 1, exit_hamfile ); +#else + for (i = exit_modelnum; i <= destroyed_exit_modelnum; i++) { + Polygon_models[i].n_models = cfile_read_int(exit_hamfile); + Polygon_models[i].model_data_size = cfile_read_int(exit_hamfile); + Polygon_models[i].model_data = (ubyte *)read_int_swap(exit_hamfile); + for (j = 0; j < MAX_SUBMODELS; j++) + Polygon_models[i].submodel_ptrs[j] = cfile_read_int(exit_hamfile); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_offsets), exit_hamfile); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_norms), exit_hamfile); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_pnts), exit_hamfile); + for (j = 0; j < MAX_SUBMODELS; j++) + Polygon_models[i].submodel_rads[j] = cfile_read_fix(exit_hamfile); + for (j = 0; j < MAX_SUBMODELS; j++) + Polygon_models[i].submodel_parents[j] = cfile_read_byte(exit_hamfile); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_mins), exit_hamfile); + for (j = 0; j < MAX_SUBMODELS; j++) + cfile_read_vector(&(Polygon_models[i].submodel_maxs), exit_hamfile); + cfile_read_vector(&(Polygon_models[i].mins), exit_hamfile); + cfile_read_vector(&(Polygon_models[i].maxs), exit_hamfile); + Polygon_models[i].rad = cfile_read_fix(exit_hamfile); + Polygon_models[i].n_textures = cfile_read_byte(exit_hamfile); + Polygon_models[i].first_texture = cfile_read_short(exit_hamfile); + Polygon_models[i].simpler_model = cfile_read_byte(exit_hamfile); + } + Polygon_models[exit_modelnum].first_texture = start_num; + Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3; +#endif + + Polygon_models[exit_modelnum].model_data = d_malloc(Polygon_models[exit_modelnum].model_data_size); + Assert( Polygon_models[exit_modelnum].model_data != NULL ); + cfread( Polygon_models[exit_modelnum].model_data, sizeof(ubyte), Polygon_models[exit_modelnum].model_data_size, exit_hamfile ); + #ifdef MACINTOSH + swap_polygon_model_data(Polygon_models[exit_modelnum].model_data); + #endif + g3_init_polygon_model(Polygon_models[exit_modelnum].model_data); + + Polygon_models[destroyed_exit_modelnum].model_data = d_malloc(Polygon_models[destroyed_exit_modelnum].model_data_size); + Assert( Polygon_models[destroyed_exit_modelnum].model_data != NULL ); + cfread( Polygon_models[destroyed_exit_modelnum].model_data, sizeof(ubyte), Polygon_models[destroyed_exit_modelnum].model_data_size, exit_hamfile ); + #ifdef MACINTOSH + swap_polygon_model_data(Polygon_models[destroyed_exit_modelnum].model_data); + #endif + g3_init_polygon_model(Polygon_models[destroyed_exit_modelnum].model_data); + + cfclose(exit_hamfile); + +} +#endif // SHAREWARE + +#endif // PORTABLE_LOADER //----------------------------------------------------------------- // Read data from piggy. -// This is called when the editor is OUT. +// This is called when the editor is OUT. // If editor is in, bm_init_use_table() is called. int bm_init() { @@ -165,7 +579,9 @@ int bm_init() piggy_read_sounds(); + #ifdef SHAREWARE init_endlevel(); //this is in bm_init_use_tbl(), so I gues it goes here + #endif return 0; } @@ -175,58 +591,129 @@ void bm_read_all(CFILE * fp) int i,t; NumTextures = cfile_read_int(fp); - bitmap_index_read_n(Textures, NumTextures, fp ); - tmap_info_read_n(TmapInfo, NumTextures, fp); +#ifndef PORTABLE_LOADER + cfread( Textures, sizeof(bitmap_index), NumTextures, fp ); + cfread( TmapInfo, sizeof(tmap_info), NumTextures, fp ); +#else + for (i = 0; i < NumTextures; i++) + Textures[i].index = cfile_read_short(fp); + read_tmap_info(fp, NumTextures, 0); +#endif - t = cfile_read_int(fp); + t = cfile_read_int(fp); cfread( Sounds, sizeof(ubyte), t, fp ); cfread( AltSounds, sizeof(ubyte), t, fp ); Num_vclips = cfile_read_int(fp); - vclip_read_n(Vclip, Num_vclips, fp); +#ifndef PORTABLE_LOADER + cfread( Vclip, sizeof(vclip), Num_vclips, fp ); +#else + read_vclip_info(fp, Num_vclips, 0); +#endif Num_effects = cfile_read_int(fp); - eclip_read_n(Effects, Num_effects, fp); +#ifndef PORTABLE_LOADER + cfread( Effects, sizeof(eclip), Num_effects, fp ); +#else + read_effect_info(fp, Num_effects, 0); +#endif Num_wall_anims = cfile_read_int(fp); - wclip_read_n(WallAnims, Num_wall_anims, fp); +#ifndef PORTABLE_LOADER + cfread( WallAnims, sizeof(wclip), Num_wall_anims, fp ); +#else + read_wallanim_info(fp, Num_wall_anims, 0); +#endif N_robot_types = cfile_read_int(fp); - robot_info_read_n(Robot_info, N_robot_types, fp); - +#ifndef PORTABLE_LOADER + cfread( Robot_info, sizeof(robot_info), N_robot_types, fp ); +#else + read_robot_info(fp, N_robot_types, 0); +#endif N_robot_joints = cfile_read_int(fp); - jointpos_read_n(Robot_joints, N_robot_joints, fp); +#ifndef PORTABLE_LOADER + cfread( Robot_joints, sizeof(jointpos), N_robot_joints, fp ); +#else + read_robot_joint_info(fp, N_robot_joints, 0); +#endif N_weapon_types = cfile_read_int(fp); - weapon_info_read_n(Weapon_info, N_weapon_types, fp, Piggy_hamfile_version); +#ifndef PORTABLE_LOADER + cfread( Weapon_info, sizeof(weapon_info), N_weapon_types, fp ); +#else + read_weapon_info(fp, N_weapon_types, 0); +#endif N_powerup_types = cfile_read_int(fp); - powerup_type_info_read_n(Powerup_info, N_powerup_types, fp); - +#ifndef PORTABLE_LOADER + cfread( Powerup_info, sizeof(powerup_type_info), N_powerup_types, fp ); +#else + read_powerup_info(fp, N_powerup_types, 0); +#endif + N_polygon_models = cfile_read_int(fp); - polymodel_read_n(Polygon_models, N_polygon_models, fp); +#ifndef PORTABLE_LOADER + cfread( Polygon_models, sizeof(polymodel), N_polygon_models, fp ); +#else + read_polygon_models(fp, N_polygon_models, 0); +#endif - for (i=0; i N_D2_POLYGON_MODELS) - free_model(&Polygon_models[--N_polygon_models]); - while (N_polygon_models > exit_modelnum) - free_model(&Polygon_models[--N_polygon_models]); -} - -//type==1 means 1.1, type==2 means 1.2 (with weapons) +//type==1 means 1.1, type==2 means 1.2 (with weaons) void bm_read_extra_robots(char *fname,int type) { CFILE *fp; int t,i; int version; + + #ifdef MACINTOSH + ulong varSave = 0; + #endif fp = cfopen(fname,"rb"); @@ -452,55 +776,95 @@ void bm_read_extra_robots(char *fname,int type) else version = 0; - bm_free_extra_models(); - bm_free_extra_objbitmaps(); - //read extra weapons t = cfile_read_int(fp); N_weapon_types = N_D2_WEAPON_TYPES+t; if (N_weapon_types >= MAX_WEAPON_TYPES) Error("Too many weapons (%d) in <%s>. Max is %d.",t,fname,MAX_WEAPON_TYPES-N_D2_WEAPON_TYPES); - weapon_info_read_n(&Weapon_info[N_D2_WEAPON_TYPES], t, fp, 3); - + #ifdef MACINTOSH + read_weapon_info(fp, t, N_D2_WEAPON_TYPES); + #else + cfread( &Weapon_info[N_D2_WEAPON_TYPES], sizeof(weapon_info), t, fp ); + #endif + //now read robot info t = cfile_read_int(fp); N_robot_types = N_D2_ROBOT_TYPES+t; if (N_robot_types >= MAX_ROBOT_TYPES) Error("Too many robots (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_TYPES-N_D2_ROBOT_TYPES); - robot_info_read_n(&Robot_info[N_D2_ROBOT_TYPES], t, fp); - + #ifdef MACINTOSH + read_robot_info(fp, t, N_D2_ROBOT_TYPES); + #else + cfread( &Robot_info[N_D2_ROBOT_TYPES], sizeof(robot_info), t, fp ); + #endif + t = cfile_read_int(fp); N_robot_joints = N_D2_ROBOT_JOINTS+t; if (N_robot_joints >= MAX_ROBOT_JOINTS) Error("Too many robot joints (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_JOINTS-N_D2_ROBOT_JOINTS); - jointpos_read_n(&Robot_joints[N_D2_ROBOT_JOINTS], t, fp); - + #ifdef MACINTOSH + read_robot_joint_info(fp, t, N_D2_ROBOT_JOINTS); + #else + cfread( &Robot_joints[N_D2_ROBOT_JOINTS], sizeof(jointpos), t, fp ); + #endif + t = cfile_read_int(fp); N_polygon_models = N_D2_POLYGON_MODELS+t; if (N_polygon_models >= MAX_POLYGON_MODELS) Error("Too many polygon models (%d) in <%s>. Max is %d.",t,fname,MAX_POLYGON_MODELS-N_D2_POLYGON_MODELS); - polymodel_read_n(&Polygon_models[N_D2_POLYGON_MODELS], t, fp); - + #ifdef MACINTOSH + read_polygon_models(fp, t, N_D2_POLYGON_MODELS); + #else + cfread( &Polygon_models[N_D2_POLYGON_MODELS], sizeof(polymodel), t, fp ); + #endif + for (i=N_D2_POLYGON_MODELS; i= MAX_OBJ_BITMAPS) Error("Too many object bitmaps (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPS); - bitmap_index_read_n(&ObjBitmaps[N_D2_OBJBITMAPS], t, fp); + cfread( &ObjBitmaps[N_D2_OBJBITMAPS], sizeof(bitmap_index), t, fp ); + #ifdef MACINTOSH + for (i = N_D2_OBJBITMAPS; i < (N_D2_OBJBITMAPS + t); i++) + { + ObjBitmaps[i].index = SWAPSHORT(ObjBitmaps[i].index); + } + #endif t = cfile_read_int(fp); if (N_D2_OBJBITMAPPTRS+t >= MAX_OBJ_BITMAPS) Error("Too many object bitmap pointers (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPPTRS); - for (i = N_D2_OBJBITMAPPTRS; i < (N_D2_OBJBITMAPPTRS + t); i++) - ObjBitmapPtrs[i] = cfile_read_short(fp); + cfread( &ObjBitmapPtrs[N_D2_OBJBITMAPPTRS], sizeof(ushort), t, fp ); + #ifdef MACINTOSH + for (i = N_D2_OBJBITMAPPTRS; i < (N_D2_OBJBITMAPPTRS + t); i++) + { + ObjBitmapPtrs[i] = SWAPSHORT(ObjBitmapPtrs[i]); + } + #endif cfclose(fp); } @@ -516,26 +880,30 @@ void load_robot_replacements(char *level_name) char ifile_name[FILENAME_LEN]; change_filename_extension(ifile_name, level_name, ".HXM" ); - + fp = cfopen(ifile_name,"rb"); if (!fp) //no robot replacement file return; t = cfile_read_int(fp); //read id "HXM!" - if (t!= 0x21584d48) + if (t!= 0x21584d48) Error("ID of HXM! file incorrect"); t = cfile_read_int(fp); //read version if (t<1) - Error("HXM! version too old (%d)",t); + Error("HXM! version too old (%d)",t); t = cfile_read_int(fp); //read number of robots for (j=0;j=N_robot_types) + if (i<0 || i>=N_robot_types) Error("Robots number (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_types-1); - robot_info_read_n(&Robot_info[i], 1, fp); + #ifdef MACINTOSH + read_robot_info(fp, 1, i); + #else + cfread( &Robot_info[i], sizeof(robot_info), 1, fp ); + #endif } t = cfile_read_int(fp); //read number of joints @@ -543,7 +911,11 @@ void load_robot_replacements(char *level_name) i = cfile_read_int(fp); //read joint number if (i<0 || i>=N_robot_joints) Error("Robots joint (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_joints-1); - jointpos_read_n(&Robot_joints[i], 1, fp); + #ifdef MACINTOSH + read_robot_joint_info(fp, 1, i); + #else + cfread( &Robot_joints[i], sizeof(jointpos), 1, fp ); + #endif } t = cfile_read_int(fp); //read number of polygon models @@ -552,10 +924,22 @@ void load_robot_replacements(char *level_name) i = cfile_read_int(fp); //read model number if (i<0 || i>=N_polygon_models) Error("Polygon model (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_polygon_models-1); - polymodel_read(&Polygon_models[i], fp); - - free_model(&Polygon_models[i]); - polygon_model_data_read(&Polygon_models[i], fp); + + #ifdef MACINTOSH + read_polygon_models(fp, 1, i); + #else + cfread( &Polygon_models[i], sizeof(polymodel), 1, fp ); + #endif + + d_free(Polygon_models[i].model_data); + Polygon_models[i].model_data = d_malloc(Polygon_models[i].model_data_size); + Assert( Polygon_models[i].model_data != NULL ); + + cfread( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp ); + #ifdef MACINTOSH + swap_polygon_model_data(Polygon_models[i].model_data); + #endif + g3_init_polygon_model(Polygon_models[i].model_data); Dying_modelnums[i] = cfile_read_int(fp); Dead_modelnums[i] = cfile_read_int(fp); @@ -566,7 +950,7 @@ void load_robot_replacements(char *level_name) i = cfile_read_int(fp); //read objbitmap number if (i<0 || i>=MAX_OBJ_BITMAPS) Error("Object bitmap number (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1); - bitmap_index_read(&ObjBitmaps[i], fp); + ObjBitmaps[i].index = cfile_read_short(fp); } t = cfile_read_int(fp); //read number of objbitmapptrs @@ -579,169 +963,3 @@ void load_robot_replacements(char *level_name) cfclose(fp); } - - -/* - * Routines for loading exit models - * - * Used by d1 levels (including some add-ons), and by d2 shareware. - * Could potentially be used by d2 add-on levels, but only if they - * don't use "extra" robots... - */ - -// formerly exitmodel_bm_load_sub -bitmap_index read_extra_bitmap_iff( char * filename ) -{ - bitmap_index bitmap_num; - grs_bitmap * new = &GameBitmaps[extra_bitmap_num]; - ubyte newpal[256*3]; - int iff_error; //reference parm to avoid warning message - - bitmap_num.index = 0; - - //MALLOC( new, grs_bitmap, 1 ); - iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal); - new->bm_handle=0; - if (iff_error != IFF_NO_ERROR) { - con_printf(CON_DEBUG, "Error loading exit model bitmap <%s> - IFF error: %s\n", filename, iff_errormsg(iff_error)); - return bitmap_num; - } - - if ( iff_has_transparency ) - gr_remap_bitmap_good( new, newpal, iff_transparent_color, 254 ); - else - gr_remap_bitmap_good( new, newpal, -1, 254 ); - - new->avg_color = 0; //compute_average_pixel(new); - - bitmap_num.index = extra_bitmap_num; - - GameBitmaps[extra_bitmap_num++] = *new; - - //d_free( new ); - return bitmap_num; -} - -// formerly load_exit_model_bitmap -grs_bitmap *bm_load_extra_objbitmap(char *name) -{ - Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS); - - { - ObjBitmaps[N_ObjBitmaps] = read_extra_bitmap_iff(name); - - if (ObjBitmaps[N_ObjBitmaps].index == 0) - { - char *name2 = d_strdup(name); - *strrchr(name2, '.') = '\0'; - ObjBitmaps[N_ObjBitmaps] = read_extra_bitmap_d1_pig(name2); - d_free(name2); - } - if (ObjBitmaps[N_ObjBitmaps].index == 0) - return NULL; - - if (GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_w!=64 || GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_h!=64) - Error("Bitmap <%s> is not 64x64",name); - ObjBitmapPtrs[N_ObjBitmaps] = N_ObjBitmaps; - N_ObjBitmaps++; - Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS); - return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index]; - } -} - -#ifdef OGL -void ogl_cache_polymodel_textures(int model_num); -#endif - -int load_exit_models() -{ - CFILE *exit_hamfile; - int start_num; - - bm_free_extra_models(); - bm_free_extra_objbitmaps(); - - start_num = N_ObjBitmaps; - if (!bm_load_extra_objbitmap("steel1.bbm") || - !bm_load_extra_objbitmap("rbot061.bbm") || - !bm_load_extra_objbitmap("rbot062.bbm") || - !bm_load_extra_objbitmap("steel1.bbm") || - !bm_load_extra_objbitmap("rbot061.bbm") || - !bm_load_extra_objbitmap("rbot063.bbm")) - { - con_printf(CON_NORMAL, "Can't load exit models!\n"); - return 0; - } - -#ifndef MACINTOSH - exit_hamfile = cfopen("exit.ham","rb"); -#else - exit_hamfile = cfopen(":Data:exit.ham","rb"); -#endif - if (exit_hamfile) { - exit_modelnum = N_polygon_models++; - destroyed_exit_modelnum = N_polygon_models++; - polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile); - polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile); - Polygon_models[exit_modelnum].first_texture = start_num; - Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3; - - polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile); - - polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile); - - cfclose(exit_hamfile); - - } else if (cfexist("exit01.pof") && cfexist("exit01d.pof")) { - - exit_modelnum = load_polygon_model("exit01.pof", 3, start_num, NULL); - destroyed_exit_modelnum = load_polygon_model("exit01d.pof", 3, start_num + 3, NULL); - -#ifdef OGL - ogl_cache_polymodel_textures(exit_modelnum); - ogl_cache_polymodel_textures(destroyed_exit_modelnum); -#endif - } - else if (cfexist(D1_PIGFILE)) - { - int offset, offset2; - - exit_hamfile = cfopen(D1_PIGFILE, "rb"); - switch (cfilelength(exit_hamfile)) { //total hack for loading models - case D1_PIGSIZE: - offset = 91848; /* and 92582 */ - offset2 = 383390; /* and 394022 */ - break; - default: - case D1_SHAREWARE_10_PIGSIZE: - case D1_SHAREWARE_PIGSIZE: - Int3(); /* exit models should be in .pofs */ - case D1_OEM_PIGSIZE: - case D1_MAC_PIGSIZE: - case D1_MAC_SHARE_PIGSIZE: - con_printf(CON_NORMAL, "Can't load exit models!\n"); - return 0; - break; - } - cfseek(exit_hamfile, offset, SEEK_SET); - exit_modelnum = N_polygon_models++; - destroyed_exit_modelnum = N_polygon_models++; - polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile); - polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile); - Polygon_models[exit_modelnum].first_texture = start_num; - Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3; - - cfseek(exit_hamfile, offset2, SEEK_SET); - polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile); - polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile); - - cfclose(exit_hamfile); - } else { - con_printf(CON_NORMAL, "Can't load exit models!\n"); - return 0; - } - - atexit(bm_free_extra_objbitmaps); - - return 1; -} diff --git a/main/bm.h b/main/bm.h index 920ce7be..7801b749 100644 --- a/main/bm.h +++ b/main/bm.h @@ -1,4 +1,3 @@ -/* $Id: bm.h,v 1.9 2003-03-25 08:19:12 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -18,27 +17,27 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gr.h" #include "piggy.h" -#define MAX_TEXTURES 1200 +#define MAX_TEXTURES 1200 //tmapinfo flags -#define TMI_VOLATILE 1 //this material blows up when hit -#define TMI_WATER 2 //this material is water -#define TMI_FORCE_FIELD 4 //this is force field - flares don't stick -#define TMI_GOAL_BLUE 8 //this is used to remap the blue goal -#define TMI_GOAL_RED 16 //this is used to remap the red goal -#define TMI_GOAL_HOARD 32 //this is used to remap the goals +#define TMI_VOLATILE 1 //this material blows up when hit +#define TMI_WATER 2 //this material is water +#define TMI_FORCE_FIELD 4 //this is force field - flares don't stick +#define TMI_GOAL_BLUE 8 //this is used to remap the blue goal +#define TMI_GOAL_RED 16 //this is used to remap the red goal +#define TMI_GOAL_HOARD 32 //this is used to remap the goals typedef struct { - ubyte flags; //values defined above - ubyte pad[3]; //keep alignment - fix lighting; //how much light this casts - fix damage; //how much damage being against this does (for lava) - short eclip_num; //the eclip that changes this, or -1 - short destroyed; //bitmap to show when destroyed, or -1 - short slide_u,slide_v; //slide rates of texture, stored in 8:8 fix + ubyte flags; //values defined above + ubyte pad[3]; //keep alignment + fix lighting; //how much light this casts + fix damage; //how much damage being against this does (for lava) + short eclip_num; //the eclip that changes this, or -1 + short destroyed; //bitmap to show when destroyed, or -1 + short slide_u,slide_v; //slide rates of texture, stored in 8:8 fix #ifdef EDITOR - char filename[13]; //used by editor to remap textures - char pad2[3]; + char filename[13]; //used by editor to remap textures + char pad2[3]; #endif } __pack__ tmap_info; @@ -69,24 +68,27 @@ void bm_close(); // Initializes the Texture[] array of bmd_bitmap structures. void init_textures(); -#define OL_ROBOT 1 -#define OL_HOSTAGE 2 -#define OL_POWERUP 3 -#define OL_CONTROL_CENTER 4 -#define OL_PLAYER 5 -#define OL_CLUTTER 6 //some sort of misc object -#define OL_EXIT 7 //the exit model for external scenes -#define OL_WEAPON 8 //a weapon that can be placed - -#define MAX_OBJTYPE 140 - -extern int Num_total_object_types; // Total number of object types, including robots, hostages, powerups, control centers, faces -extern byte ObjType[MAX_OBJTYPE]; // Type of an object, such as Robot, eg if ObjType[11] == OL_ROBOT, then object #11 is a robot -extern byte ObjId[MAX_OBJTYPE]; // ID of a robot, within its class, eg if ObjType[11] == 3, then object #11 is the third robot -extern fix ObjStrength[MAX_OBJTYPE]; // initial strength of each object - -#define MAX_OBJ_BITMAPS 610 - +#define OL_ROBOT 1 +#define OL_HOSTAGE 2 +#define OL_POWERUP 3 +#define OL_CONTROL_CENTER 4 +#define OL_PLAYER 5 +#define OL_CLUTTER 6 //some sort of misc object +#define OL_EXIT 7 //the exit model for external scenes +#define OL_WEAPON 8 //a weapon that can be placed + +#define MAX_OBJTYPE 140 + +extern int Num_total_object_types; // Total number of object types, including robots, hostages, powerups, control centers, faces +extern byte ObjType[MAX_OBJTYPE]; // Type of an object, such as Robot, eg if ObjType[11] == OL_ROBOT, then object #11 is a robot +extern byte ObjId[MAX_OBJTYPE]; // ID of a robot, within its class, eg if ObjType[11] == 3, then object #11 is the third robot +extern fix ObjStrength[MAX_OBJTYPE]; // initial strength of each object + +#if defined(MACINTOSH) && defined(SHAREWARE) +#define MAX_OBJ_BITMAPS 610 +#else +#define MAX_OBJ_BITMAPS 600 +#endif extern bitmap_index ObjBitmaps[MAX_OBJ_BITMAPS]; extern ushort ObjBitmapPtrs[MAX_OBJ_BITMAPS]; extern int First_multi_bitmap_num; @@ -94,11 +96,5 @@ extern int First_multi_bitmap_num; // Initializes all bitmaps from BITMAPS.TBL file. int bm_init_use_tbl(void); -extern void bm_read_all(CFILE * fp); - -extern void bm_read_all_d1(CFILE * fp); -extern void undo_bm_read_all_d1(void); - -int load_exit_models(); +#endif -#endif /* _BM_H */ diff --git a/main/cdrom.h b/main/cdrom.h new file mode 100644 index 00000000..1a06c72d --- /dev/null +++ b/main/cdrom.h @@ -0,0 +1,13 @@ +void RBAExit(); +void RBAInit(); +int RBAEnabled(); +void RBARegisterCD(); +int RBAPlayTrack(int a); +void RBAStop(); +void RBASetVolume(int a); +void RBAPause(); +void RBAResume(); +int RBAGetNumberOfTracks(); +int RBAPlayTracks(int tracknum,int something); +int RBAGetTrackNum(); +int RBAPeekPlayStatus(); diff --git a/main/cntrlcen.c b/main/cntrlcen.c index 9ec060c4..9f98ed3f 100644 --- a/main/cntrlcen.c +++ b/main/cntrlcen.c @@ -1,4 +1,3 @@ -/* $Id: cntrlcen.c,v 1.9 2003-04-03 07:15:43 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: cntrlcen.c,v 1.9 2003-04-03 07:15:43 btb Exp $"; +static char rcsid[] = "$Id: cntrlcen.c,v 1.3 2001-10-25 02:15:55 bradleyb Exp $"; #endif #ifdef WINDOWS @@ -161,7 +160,7 @@ void do_countdown_frame() #if !defined(D2_OEM) && !defined(SHAREWARE) // get countdown in OEM and SHAREWARE only // On last level, we don't want a countdown. - if ((Current_mission_num == Builtin_mission_num) && (Current_level_num == Last_level)) + if ((Current_mission_num == 0) && (Current_level_num == Last_level)) { if (!(Game_mode & GM_MULTI)) return; @@ -508,40 +507,3 @@ void special_reactor_stuff(void) } } -#ifndef FAST_FILE_IO -/* - * reads n reactor structs from a CFILE - */ -extern int reactor_read_n(reactor *r, int n, CFILE *fp) -{ - int i, j; - - for (i = 0; i < n; i++) { - r[i].model_num = cfile_read_int(fp); - r[i].n_guns = cfile_read_int(fp); - for (j = 0; j < MAX_CONTROLCEN_GUNS; j++) - cfile_read_vector(&(r[i].gun_points[j]), fp); - for (j = 0; j < MAX_CONTROLCEN_GUNS; j++) - cfile_read_vector(&(r[i].gun_dirs[j]), fp); - } - return i; -} - -/* - * reads a control_center_triggers structure from a CFILE - */ -extern int control_center_triggers_read_n(control_center_triggers *cct, int n, CFILE *fp) -{ - int i, j; - - for (i = 0; i < n; i++) - { - cct->num_links = cfile_read_short(fp); - for (j = 0; j < MAX_CONTROLCEN_LINKS; j++) - cct->seg[j] = cfile_read_short(fp); - for (j = 0; j < MAX_CONTROLCEN_LINKS; j++) - cct->side[j] = cfile_read_short(fp); - } - return i; -} -#endif diff --git a/main/cntrlcen.h b/main/cntrlcen.h index 048ec103..8cb1c8f7 100644 --- a/main/cntrlcen.h +++ b/main/cntrlcen.h @@ -26,9 +26,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define MAX_CONTROLCEN_LINKS 10 typedef struct control_center_triggers { - short num_links; - short seg[MAX_CONTROLCEN_LINKS]; - short side[MAX_CONTROLCEN_LINKS]; + short num_links; + short seg[MAX_CONTROLCEN_LINKS]; + short side[MAX_CONTROLCEN_LINKS]; } __pack__ control_center_triggers; extern control_center_triggers ControlCenterTriggers; @@ -74,19 +74,4 @@ extern int Control_center_destroyed,Countdown_seconds_left; extern int Base_control_center_explosion_time; //how long to blow up on insane extern int Reactor_strength; -#ifdef FAST_FILE_IO -#define reactor_read_n(r, n, fp) cfread(r, sizeof(reactor), n, fp) -#define control_center_triggers_read_n(cct, n, fp) cfread(cct, sizeof(control_center_triggers), n, fp) -#else -/* - * reads n reactor structs from a CFILE - */ -extern int reactor_read_n(reactor *r, int n, CFILE *fp); - -/* - * reads n control_center_triggers structs from a CFILE - */ -extern int control_center_triggers_read_n(control_center_triggers *cct, int n, CFILE *fp); -#endif - #endif diff --git a/main/collide.c b/main/collide.c index c06e1567..5de0153b 100644 --- a/main/collide.c +++ b/main/collide.c @@ -1,4 +1,3 @@ -/* $Id: collide.c,v 1.12 2003-03-27 01:23:18 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,407 +7,25 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/collide.c,v $ + * $Revision: 1.9 $ + * $Author: bradleyb $ + * $Date: 2001-11-08 10:30:27 $ * - * Routines to handle collisions + * FIXME: put description here * - * Old Log: - * Revision 1.3 1995/11/08 17:15:21 allender - * make collide_player_and_weapon play player_hit_sound if - * shareware and not my playernum + * $Log: not supported by cvs2svn $ + * Revision 1.8 2001/10/25 02:15:55 bradleyb + * conditionalize including multi.h and network.h, fix backslashes * - * Revision 1.2 1995/10/31 10:24:37 allender - * shareware stuff + * Revision 1.7 2001/10/18 00:01:00 bradleyb + * RCS headers added/changed * - * Revision 1.1 1995/05/16 15:23:34 allender - * Initial revision - * - * Revision 2.5 1995/07/26 12:07:46 john - * Made code that pages in weapon_info->robot_hit_vclip not - * page in unless it is a badass weapon. Took out old functionallity - * of using this if no robot exp1_vclip, since all robots have these. - * - * Revision 2.4 1995/03/30 16:36:09 mike - * text localization. - * - * Revision 2.3 1995/03/24 15:11:13 john - * Added ugly robot cheat. - * - * Revision 2.2 1995/03/21 14:41:04 john - * Ifdef'd out the NETWORK code. - * - * Revision 2.1 1995/03/20 18:16:02 john - * Added code to not store the normals in the segment structure. - * - * Revision 2.0 1995/02/27 11:32:20 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.289 1995/02/22 13:56:06 allender - * remove anonymous unions from object structure - * - * Revision 1.288 1995/02/11 15:52:45 rob - * Included text.h. - * - * Revision 1.287 1995/02/11 15:04:11 rob - * Localized a string. - * - * Revision 1.286 1995/02/11 14:25:41 rob - * Added invul. controlcen option. - * - * Revision 1.285 1995/02/06 15:53:00 mike - * create awareness event for player:wall collision. - * - * Revision 1.284 1995/02/05 23:18:17 matt - * Deal with objects (such as fusion blobs) that get created already - * poking through a wall - * - * Revision 1.283 1995/02/01 17:51:33 mike - * fusion bolt can now toast multiple proximity bombs. - * - * Revision 1.282 1995/02/01 17:29:20 john - * Lintized - * - * Revision 1.281 1995/02/01 15:04:00 rob - * Changed sound of weapons hitting invulnerable players. - * - * Revision 1.280 1995/01/31 16:16:35 mike - * Separate smart blobs for robot and player. - * - * Revision 1.279 1995/01/29 15:57:10 rob - * Fixed another bug with robot_request_change calls. - * - * Revision 1.278 1995/01/28 18:15:06 rob - * Fixed a bug in multi_request_robot_change. - * - * Revision 1.277 1995/01/27 15:15:44 rob - * Fixing problems with controlcen damage. - * - * Revision 1.276 1995/01/27 15:13:10 mike - * comment out mprintf. - * - * Revision 1.275 1995/01/26 22:11:51 mike - * Purple chromo-blaster (ie, fusion cannon) spruce up (chromification) - * - * Revision 1.274 1995/01/26 18:57:55 rob - * Changed two uses of digi_play_sample to digi_link_sound_to_pos which - * made more sense. - * - * Revision 1.273 1995/01/25 23:37:58 mike - * make persistent objects not hit player more than once. - * Also, make them hit player before degrading them, else they often did 0 damage. - * - * Revision 1.272 1995/01/25 18:23:54 rob - * Don't let players pick up powerups in exit tunnel. - * - * Revision 1.271 1995/01/25 13:43:18 rob - * Added robot transfer for player collisions. - * Removed mprintf from collide.c on Mike's request. - * - * Revision 1.270 1995/01/25 10:24:01 mike - * Make sizzle and rock happen in lava even if you're invulnerable. - * - * Revision 1.269 1995/01/22 17:05:33 mike - * Call multi_robot_request_change when a robot gets whacked by a player or - * player weapon, if player_num != Player_num - * - * Revision 1.268 1995/01/21 21:20:28 matt - * Fixed stupid bug - * - * Revision 1.267 1995/01/21 18:47:47 rob - * Fixed a really dumb bug with player keys. - * - * Revision 1.266 1995/01/21 17:39:30 matt - * Cleaned up laser/player hit wall confusions - * - * Revision 1.265 1995/01/19 17:44:42 mike - * damage_force removed, that information coming from strength field. - * - * Revision 1.264 1995/01/18 17:12:56 rob - * Fixed control stuff for multiplayer. - * - * Revision 1.263 1995/01/18 16:12:33 mike - * Make control center aware of a cloaked playerr when he fires. - * - * Revision 1.262 1995/01/17 17:48:42 rob - * Added key syncing for coop players. - * - * Revision 1.261 1995/01/16 19:30:28 rob - * Fixed an assert error in fireball.c - * - * Revision 1.260 1995/01/16 19:23:51 mike - * Say Boss_been_hit if he been hit so he gates appropriately. - * - * Revision 1.259 1995/01/16 11:55:16 mike - * make enemies become aware of player if he damages control center. - * - * Revision 1.258 1995/01/15 16:42:00 rob - * Fixed problem with robot bumping damage. - * - * Revision 1.257 1995/01/14 19:16:36 john - * First version of new bitmap paging code. - * - * Revision 1.256 1995/01/03 17:58:37 rob - * Fixed scoring problems. - * - * Revision 1.255 1994/12/29 12:41:11 rob - * Tweaking robot exploding in coop. - * - * Revision 1.254 1994/12/28 10:37:59 rob - * Fixed ifdef of multibot stuff. - * - * Revision 1.253 1994/12/21 19:03:14 rob - * Fixing score accounting for multiplayer robots - * - * Revision 1.252 1994/12/21 17:36:31 rob - * Fix hostage pickup problem in network. - * tweaking robot powerup drops. - * - * Revision 1.251 1994/12/19 20:32:34 rob - * Remove awareness events from player collisions and lasers that are not the console player. - * - * Revision 1.250 1994/12/19 20:01:22 rob - * Added multibot.h include. - * - * Revision 1.249 1994/12/19 16:36:41 rob - * Patches damaging of multiplayer robots. - * - * Revision 1.248 1994/12/14 21:15:18 rob - * play lava hiss across network. - * - * Revision 1.247 1994/12/14 17:09:09 matt - * Fixed problem with no sound when lasers hit closed walls, like grates. - * - * Revision 1.246 1994/12/14 09:51:49 mike - * make any weapon cause proximity bomb detonation. - * - * Revision 1.245 1994/12/13 12:55:25 mike - * change number of proximity bomb powerups which get dropped. - * - * Revision 1.244 1994/12/12 17:17:53 mike - * make boss cloak/teleport when get hit, make quad laser 3/4 as powerful. - * - * Revision 1.243 1994/12/12 12:07:51 rob - * Don't take damage if we're in endlevel sequence. - * - * Revision 1.242 1994/12/11 23:44:52 mike - * less phys_apply_rot() at higher skill levels. - * - * Revision 1.241 1994/12/11 12:37:02 mike - * remove stupid robot spinning code. it was really stupid. (actually, call here, code in ai.c). - * - * Revision 1.240 1994/12/10 16:44:51 matt - * Added debugging code to track down door that turns into rock - * - * Revision 1.239 1994/12/09 14:59:19 matt - * Added system to attach a fireball to another object for rendering purposes, - * so the fireball always renders on top of (after) the object. - * - * Revision 1.238 1994/12/09 09:57:02 mike - * Don't allow robots or their weapons to pass through control center. - * - * Revision 1.237 1994/12/08 15:46:03 mike - * better robot behavior. - * - * Revision 1.236 1994/12/08 12:32:56 mike - * make boss dying more interesting. - * - * Revision 1.235 1994/12/07 22:49:15 mike - * tweak rotation due to collision. - * - * Revision 1.234 1994/12/07 16:44:50 mike - * make bump sound if supposed to, even if not taking damage. - * - * Revision 1.233 1994/12/07 12:55:08 mike - * tweak rotvel applied from collisions. - * - * Revision 1.232 1994/12/05 19:30:48 matt - * Fixed horrible segment over-dereferencing - * - * Revision 1.231 1994/12/05 00:32:15 mike - * do rotvel on badass and bump collisions. - * - * Revision 1.230 1994/12/03 12:49:22 mike - * don't play bonk sound when you collide with a volatile wall (like lava). - * - * Revision 1.229 1994/12/02 16:51:09 mike - * make lava sound only happen at 4 Hz. - * - * Revision 1.228 1994/11/30 23:55:27 rob - * Fixed a bug where a laser hitting a wall was making 2 sounds. - * - * Revision 1.227 1994/11/30 20:11:00 rob - * Fixed # of dropped laser powerups. - * - * Revision 1.226 1994/11/30 19:19:03 rob - * Transmit collission sounds for net games. - * - * Revision 1.225 1994/11/30 16:33:01 mike - * new boss behavior. - * - * Revision 1.224 1994/11/30 15:44:17 mike - * /2 on boss smart children damage. - * - * Revision 1.223 1994/11/30 14:03:03 mike - * hook for claw sounds - * - * Revision 1.222 1994/11/29 20:41:09 matt - * Deleted a bunch of commented-out lines - * - * Revision 1.221 1994/11/27 23:15:08 matt - * Made changes for new mprintf calling convention - * - * Revision 1.220 1994/11/19 16:11:28 rob - * Collision damage with walls or lava is counted as suicides in net games - * - * Revision 1.219 1994/11/19 15:20:41 mike - * rip out unused code and data - * - * Revision 1.218 1994/11/17 18:44:27 rob - * Added OBJ_GHOST to list of valid player types to create eggs. - * - * Revision 1.217 1994/11/17 14:57:59 mike - * moved segment validation functions from editor to main. - * - * Revision 1.216 1994/11/16 23:38:36 mike - * new improved boss teleportation behavior. - * - * Revision 1.215 1994/11/16 12:16:29 mike - * Enable collisions between robots. A hack in fvi.c only does this for robots which lunge to attack (eg, green guy) - * - * Revision 1.214 1994/11/15 16:51:50 mike - * bump player when he hits a volatile wall. - * - * Revision 1.213 1994/11/12 16:38:44 mike - * allow flares to open doors. - * - * Revision 1.212 1994/11/10 13:09:19 matt - * Added support for new run-length-encoded bitmaps - * - * Revision 1.211 1994/11/09 17:05:43 matt - * Fixed problem with volatile walls - * - * Revision 1.210 1994/11/09 12:11:46 mike - * only award points if ConsoleObject killed robot. - * - * Revision 1.209 1994/11/09 11:11:03 yuan - * Made wall volatile if either tmap_num1 or tmap_num2 is a volatile wall. - * - * Revision 1.208 1994/11/08 12:20:15 mike - * moved do_controlcen_destroyed_stuff from here to cntrlcen.c - * - * Revision 1.207 1994/11/02 23:22:08 mike - * Make ` (backquote, KEY_LAPOSTRO) tell what wall was hit by laser. - * - * Revision 1.206 1994/11/02 18:03:00 rob - * Fix control_center_been_hit logic so it only cares about the local player. - * Other players take care of their own control center 'ai'. - * - * Revision 1.205 1994/11/01 19:37:33 rob - * Changed the max # of consussion missiles to 4. - * (cause they're lame and clutter things up) - * - * Revision 1.204 1994/11/01 18:06:35 john - * Tweaked wall banging sound constant. - * - * Revision 1.203 1994/11/01 18:01:40 john - * Made wall bang less obnoxious, but volume based. - * - * Revision 1.202 1994/11/01 17:11:05 rob - * Changed some stuff in drop_player_eggs. - * - * Revision 1.201 1994/11/01 12:18:23 john - * Added sound volume support. Made wall collisions be louder/softer. - * - * Revision 1.200 1994/10/31 13:48:44 rob - * Fixed bug in opening doors over network/modem. Added a new message - * type to multi.c that communicates door openings across the net. - * Changed includes in multi.c and wall.c to accomplish this. - * - * Revision 1.199 1994/10/28 14:42:52 john - * Added sound volumes to all sound calls. - * - * Revision 1.198 1994/10/27 16:58:37 allender - * added demo recording of monitors blowing up - * - * Revision 1.197 1994/10/26 23:20:52 matt - * Tone down flash even more - * - * Revision 1.196 1994/10/26 23:01:50 matt - * Toned down red flash when damaged - * - * Revision 1.195 1994/10/26 15:56:29 yuan - * Tweaked some palette flashes. - * - * Revision 1.194 1994/10/25 11:32:26 matt - * Fixed bugs with vulcan powerups in mutliplayer - * - * Revision 1.193 1994/10/25 10:51:18 matt - * Vulcan cannon powerups now contain ammo count - * - * Revision 1.192 1994/10/24 14:14:05 matt - * Fixed bug in bump_two_objects() - * - * Revision 1.191 1994/10/23 19:17:04 matt - * Fixed bug with "no key" messages - * - * Revision 1.190 1994/10/22 00:08:46 matt - * Fixed up problems with bonus & game sequencing - * Player doesn't get credit for hostages unless he gets them out alive - * - * Revision 1.189 1994/10/21 20:42:34 mike - * Clear number of hostages on board between levels. - * - * Revision 1.188 1994/10/20 15:17:43 mike - * control center in boss handling. - * - * Revision 1.187 1994/10/20 10:09:47 mike - * Only ever drop 1 shield powerup in multiplayer (as an egg). - * - * Revision 1.186 1994/10/20 09:47:11 mike - * Fix bug in dropping vulcan ammo in multiplayer. - * Also control center stuff. - * - * Revision 1.185 1994/10/19 15:14:32 john - * Took % hits out of player structure, made %kills work properly. - * - * Revision 1.184 1994/10/19 11:33:16 john - * Fixed hostage rescued percent. - * - * Revision 1.183 1994/10/19 11:16:49 mike - * Don't allow crazy josh to open locked doors. - * Don't allow weapons to harm parent. - * - * Revision 1.182 1994/10/18 18:37:01 mike - * No more hostage killing. Too much stuff to do to integrate into game. - * - * Revision 1.181 1994/10/18 16:37:35 mike - * Debug function for Yuan: Show seg:side when hit by puny laser if Show_seg_and_side != 0. - * - * Revision 1.180 1994/10/18 10:53:17 mike - * Support attack type as a property of a robot, not of being == GREEN_GUY. - * - * Revision 1.179 1994/10/17 21:18:36 mike - * diminish damage player does to robot due to collision, only took 2-3 hits to kill a josh. - * - * Revision 1.178 1994/10/17 20:30:40 john - * Made player_hostages_rescued or whatever count properly. - * - * Revision 1.177 1994/10/16 12:42:56 mike - * Trap bogus amount of vulcan ammo dropping. - * - * Revision 1.176 1994/10/15 19:06:51 mike - * Drop vulcan ammo if player has it, but no vulcan cannon (when he dies). - * - * Revision 1.175 1994/10/13 15:42:06 mike - * Remove afterburner. - * - * Revision 1.174 1994/10/13 11:12:57 mike - * Apply damage to robots. I hosed it a couple weeks ago when I made the green guy special. * */ @@ -416,6 +33,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #endif +#include // for memset #include #include @@ -481,7 +99,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #include "collide.h" -#include "escort.h" #define STANDARD_EXPL_DELAY (f1_0/4) @@ -1765,9 +1382,9 @@ int apply_damage_to_robot(object *robot, fix damage, int killer_objnum) // Buddy invulnerable on level 24 so he can give you his important messages. Bah. // Also invulnerable if his cheat for firing weapons is in effect. if (Robot_info[robot->id].companion) { -// if ((Current_mission_num == Builtin_mission_num && Current_level_num == Last_level) || Buddy_dude_cheat) +// if ((Current_mission_num == 0 && Current_level_num == Last_level) || Buddy_dude_cheat) #ifdef NETWORK - if ((Current_mission_num == Builtin_mission_num && Current_level_num == Last_level) ) + if ((Current_mission_num == 0 && Current_level_num == Last_level) ) return 0; #endif } @@ -1783,7 +1400,7 @@ int apply_damage_to_robot(object *robot, fix damage, int killer_objnum) // Do unspeakable hacks to make sure player doesn't die after killing boss. Or before, sort of. if (Robot_info[robot->id].boss_flag) #ifdef NETWORK - if ((Current_mission_num == Builtin_mission_num) && Current_level_num == Last_level) + if ((Current_mission_num == 0) && Current_level_num == Last_level) #endif if (robot->shields < 0) { diff --git a/main/config.c b/main/config.c index b1dfb42a..d3fa92fb 100644 --- a/main/config.c +++ b/main/config.c @@ -48,7 +48,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #ifdef RCS -static char rcsid[] = "$Id: config.c,v 1.6 2003-03-22 04:04:47 btb Exp $"; +static char rcsid[] = "$Id: config.c,v 1.5 2001-11-14 10:31:40 bradleyb Exp $"; #endif ubyte Config_digi_volume = 8; @@ -508,7 +508,7 @@ int WriteConfigFile() fputs(str, infile); sprintf (str, "%s=%d\n", config_vr_tracking_str, Config_vr_tracking ); fputs(str, infile); - sprintf (str, "%s=%d\n", movie_hires_str, (FindArg("-nohires") || FindArg("-nohighres") || FindArg("-lowresmovies"))?SaveMovieHires:MovieHires); + sprintf (str, "%s=%d\n", movie_hires_str, SaveMovieHires ); fputs(str, infile); fclose(infile); @@ -578,7 +578,7 @@ int WriteConfigFile() #endif #ifdef RCS -static char rcsid[] = "$Id: config.c,v 1.6 2003-03-22 04:04:47 btb Exp $"; +static char rcsid[] = "$Id: config.c,v 1.5 2001-11-14 10:31:40 bradleyb Exp $"; #endif #define MAX_CTB_LEN 512 diff --git a/main/console.c b/main/console.c index 1eaa0c60..09f2192f 100644 --- a/main/console.c +++ b/main/console.c @@ -1,8 +1,12 @@ -/* $Id: console.c,v 1.9 2003-03-17 09:33:49 btb Exp $ */ /* + * $Source: /cvs/cvsroot/d2x/main/console.c,v $ + * $Revision: 1.5 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 09:47:34 $ * * FIXME: put description here * + * $Log: not supported by cvs2svn $ * */ @@ -20,9 +24,8 @@ #include "error.h" #include "console.h" #include "cmd.h" -#include "gr.h" -#ifndef __MSDOS__ +#if defined(__linux__) || defined(__MINGW32__) int text_console_enabled = 1; #else int isvga(); @@ -58,7 +61,7 @@ int con_init(void) /* Initialise the cvars */ cvar_registervariable (&con_threshold); - return 0; + return 0; } /* ====== @@ -73,17 +76,13 @@ void con_printf(int priority, char *fmt, ...) if (priority <= ((int)con_threshold.value)) { va_start (arglist, fmt); - vsprintf (buffer, fmt, arglist); + vsprintf (buffer, fmt, arglist); + if (text_console_enabled) vprintf(fmt, arglist); va_end (arglist); - if (text_console_enabled) { - va_start (arglist, fmt); - vprintf(fmt, arglist); - va_end (arglist); - } /* for (i=0; inext = NULL; @@ -166,12 +165,12 @@ float cvar (char *cvar_name) */ void con_draw(void) { - char buffer[CON_LINE_LEN+1]; - int i,j; - for (i = con_line, j=0; j < 20; i = (i+1) % CON_NUM_LINES, j++) +/* char buffer[CON_LINE_LEN+1]; + int i,j; */ +/* for (i = con_line, j=0; j < 20; i = (i+1) % CON_NUM_LINES, j++) { memcpy(buffer, con_display[i], CON_LINE_LEN); buffer[CON_LINE_LEN] = 0; gr_string(1,j*10,buffer); - } + }*/ } diff --git a/main/credits.c b/main/credits.c index 7f96f44d..14ff1a07 100644 --- a/main/credits.c +++ b/main/credits.c @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: credits.c,v 1.6 2003-03-15 14:17:52 btb Exp $"; +static char rcsid[] = "$Id: credits.c,v 1.4 2001-10-25 02:15:55 bradleyb Exp $"; #endif #ifdef WINDOWS @@ -116,7 +116,15 @@ typedef struct box { int left, top, width, height; } box; -#define CREDITS_FILE (cfexist("mcredits.tex")?"mcredits.tex":cfexist("ocredits.tex")?"ocredits.tex":"credits.tex") +#ifdef MACINTOSH +#define CREDITS_FILE "mcredits.tex" +#else +#ifdef D2_OEM +#define CREDITS_FILE "ocredits.tex" +#else +#define CREDITS_FILE "credits.tex" +#endif +#endif //if filename passed is NULL, show normal credits void credits_show(char *credits_filename) @@ -190,9 +198,6 @@ WIN(int credinit = 0;) CreditsPaint: #endif gr_use_palette_table( "credits.256" ); -#ifdef OGL - gr_palette_load(gr_palette); -#endif #if defined(POLY_ACC) pa_update_clut(gr_palette, 0, 256, 0); #endif diff --git a/main/crypt.c b/main/crypt.c index 9ef7ec2a..7a72842c 100644 --- a/main/crypt.c +++ b/main/crypt.c @@ -1,4 +1,3 @@ -/* $Id: crypt.c,v 1.3 2003-03-14 21:24:03 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,35 +16,44 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -char crypt_rcsid[] = "$Id: crypt.c,v 1.3 2003-03-14 21:24:03 btb Exp $"; +char crypt_rcsid[] = "$Id: crypt.c,v 1.2 2001-01-31 15:17:50 bradleyb Exp $"; #endif -//#include -//#include +#include +#include #include -//#include "inferno.h" +#include "inferno.h" char *jcrypt (char *plainstring) -{ - int i,t,len; - static char cryptstring[20]; - - len=strlen (plainstring); - if (len>8) - len=8; - - for (i=0;i8) + len=8; + + for (i=0;i @@ -169,30 +169,3 @@ void restart_effect(int effect_num) //Assert(Effects[effect_num].bm_ptr != -1); } -#ifndef FAST_FILE_IO -/* - * reads n eclip structs from a CFILE - */ -int eclip_read_n(eclip *ec, int n, CFILE *fp) -{ - int i; - - for (i = 0; i < n; i++) { - vclip_read_n(&ec[i].vc, 1, fp); - ec[i].time_left = cfile_read_fix(fp); - ec[i].frame_count = cfile_read_int(fp); - ec[i].changing_wall_texture = cfile_read_short(fp); - ec[i].changing_object_texture = cfile_read_short(fp); - ec[i].flags = cfile_read_int(fp); - ec[i].crit_clip = cfile_read_int(fp); - ec[i].dest_bm_num = cfile_read_int(fp); - ec[i].dest_vclip = cfile_read_int(fp); - ec[i].dest_eclip = cfile_read_int(fp); - ec[i].dest_size = cfile_read_fix(fp); - ec[i].sound_num = cfile_read_int(fp); - ec[i].segnum = cfile_read_int(fp); - ec[i].sidenum = cfile_read_int(fp); - } - return i; -} -#endif diff --git a/main/effects.h b/main/effects.h index aa7815ec..b85157e4 100644 --- a/main/effects.h +++ b/main/effects.h @@ -1,4 +1,3 @@ -/* $Id: effects.h,v 1.3 2002-08-02 04:57:19 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -28,26 +27,26 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define EF_STOPPED 4 //this has been stopped typedef struct eclip { - vclip vc; //imbedded vclip - fix time_left; //for sequencing - int frame_count; //for sequencing - short changing_wall_texture; //Which element of Textures array to replace. - short changing_object_texture; //Which element of ObjBitmapPtrs array to replace. - int flags; //see above - int crit_clip; //use this clip instead of above one when mine critical - int dest_bm_num; //use this bitmap when monitor destroyed - int dest_vclip; //what vclip to play when exploding - int dest_eclip; //what eclip to play when exploding - fix dest_size; //3d size of explosion - int sound_num; //what sound this makes - int segnum,sidenum; //what seg & side, for one-shot clips + vclip vc; //imbedded vclip + fix time_left; //for sequencing + int frame_count; //for sequencing + short changing_wall_texture; //Which element of Textures array to replace. + short changing_object_texture; //Which element of ObjBitmapPtrs array to replace. + int flags; //see above + int crit_clip; //use this clip instead of above one when mine critical + int dest_bm_num; //use this bitmap when monitor destroyed + int dest_vclip; //what vclip to play when exploding + int dest_eclip; //what eclip to play when exploding + fix dest_size; //3d size of explosion + int sound_num; //what sound this makes + int segnum,sidenum; //what seg & side, for one-shot clips } __pack__ eclip; extern int Num_effects; extern eclip Effects[MAX_EFFECTS]; // Set up special effects. -extern void init_special_effects(); +extern void init_special_effects(); // Clear any active one-shots void reset_special_effects(); @@ -64,13 +63,4 @@ void stop_effect(int effect_num); //restart a stopped effect void restart_effect(int effect_num); -#ifdef FAST_FILE_IO -#define eclip_read_n(ec, n, fp) cfread(ec, sizeof(eclip), n, fp) -#else -/* - * reads n eclip structs from a CFILE - */ -extern int eclip_read_n(eclip *ec, int n, CFILE *fp); -#endif - #endif diff --git a/main/endlevel.c b/main/endlevel.c index 7e821317..badd953c 100644 --- a/main/endlevel.c +++ b/main/endlevel.c @@ -1,4 +1,3 @@ -/* $Id: endlevel.c,v 1.15 2003-04-12 00:11:46 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: endlevel.c,v 1.15 2003-04-12 00:11:46 btb Exp $"; +static char rcsid[] = "$Id: endlevel.c,v 1.5 2001-11-09 06:54:23 bradleyb Exp $"; #endif //#define SLEW_ON 1 @@ -202,13 +201,13 @@ extern int Kmatrix_nomovie_message; int start_endlevel_movie() { char movie_name[] = "esa.mve"; - int r; + int r; ubyte save_pal[768]; - //Assert(Current_mission_num == Builtin_mission_num); //only play movie for built-in mission + Assert(Current_mission_num == 0); //only play movie for built-in mission - //Assert(N_MOVIES >= Last_level); - //Assert(N_MOVIES_SECRET >= -Last_secret_level); + Assert(N_MOVIES >= Last_level); + Assert(N_MOVIES_SECRET >= -Last_secret_level); #ifndef D2_OEM if (Current_level_num == Last_level) @@ -219,7 +218,7 @@ int start_endlevel_movie() movie_name[2] = movie_table[Current_level_num-1]; else { #ifndef SHAREWARE - return 0; //no escapes for secret level + return 0; //no escapes for secret level #else Error("Invalid level number <%d>",Current_level_num); #endif @@ -227,7 +226,7 @@ int start_endlevel_movie() memcpy(save_pal,gr_palette,768); - #ifndef SHAREWARE + #if !defined(SHAREWARE) && !defined (NMOVIES) r=PlayMovie(movie_name,(Game_mode & GM_MULTI)?0:MOVIE_REQUIRED); #else return 0; // movie not played for shareware @@ -244,11 +243,12 @@ int start_endlevel_movie() else Kmatrix_nomovie_message=0; #endif - + return (r); } +#ifdef SHAREWARE void free_endlevel_data() { @@ -266,7 +266,7 @@ void init_endlevel() //## //##load_terrain("matt5b.bbm"); //load bitmap as height array //##//load_terrain("ttest2.bbm"); //load bitmap as height array - + #ifdef STATION_ENABLED station_bitmap = bm_load("steel3.bbm"); station_bitmap_list[0] = &station_bitmap; @@ -286,6 +286,7 @@ void init_endlevel() terrain_bm_instance.bm_data = satellite_bm_instance.bm_data = NULL; } +#endif //SHAREWARE object external_explosion; int ext_expl_playing,mine_destroyed; @@ -303,22 +304,20 @@ void start_endlevel_sequence() { int i; int movie_played = MOVIE_NOT_PLAYED; - int inited = 0; - + #if defined(MACINTOSH) && defined(SHAREWARE) + static int inited = 0; + if (!inited) { - if (Piggy_hamfile_version >= 3 && - (Mission_list[Current_mission_num].descent_version == 1 || - Current_mission_num == Builtin_mission_num)) - inited = load_exit_models(); - else - inited = 1; + load_exit_models(); + inited = 1; } + #endif if (Newdemo_state == ND_STATE_RECORDING) // stop demo recording Newdemo_state = ND_STATE_PAUSED; if (Newdemo_state == ND_STATE_PLAYBACK) { // don't do this if in playback mode - if (Current_mission_num == Builtin_mission_num) //only play movie for built-in mission + if (Current_mission_num == 0) //only play movie for built-in mission start_endlevel_movie(); strcpy(last_palette_loaded,""); //force palette load next time return; @@ -346,26 +345,37 @@ void start_endlevel_sequence() } #endif - if (Current_mission_num == Builtin_mission_num) { - // only play movie for built-in mission + if (Current_mission_num == 0) { //only play movie for built-in mission + + //try playing movie. If it plays, great. if not, do rendered ending + if (!(Game_mode & GM_MULTI)) movie_played = start_endlevel_movie(); - } + + #if defined(SHAREWARE) || defined(NMOVIES) + if (movie_played == MOVIE_NOT_PLAYED) { //don't have movie. Do rendered sequence + #ifndef WINDOWS + start_rendered_endlevel_sequence(); + #endif + return; + } + #endif - if (inited && endlevel_data_loaded && (movie_played == MOVIE_NOT_PLAYED)) { - //don't have movie. Do rendered sequence, if available -#ifndef WINDOWS - start_rendered_endlevel_sequence(); -#endif - return; } - - //don't have movie or rendered sequence, fade out - gr_palette_fade_out(gr_palette, 32, 0); + else + gr_palette_fade_out(gr_palette, 32, 0); PlayerFinishedLevel(0); //done with level } +#if !defined(SHAREWARE) && !defined(NMOVIES) + +void do_endlevel_frame() {Int3();} +void stop_endlevel_sequence() {Int3();} +void render_endlevel_frame(fix eye_offset) {Int3();} + +#else + static int cockpit_mode_save; void start_rendered_endlevel_sequence() @@ -562,8 +572,10 @@ void get_angs_to_object(vms_angvec *av,vms_vector *targ_pos,vms_vector *cur_pos) void do_endlevel_frame() { + #if defined(SHAREWARE) || defined(NMOVIES) static fix timer; static fix bank_rate; + #endif vms_vector save_last_pos; static fix explosion_wait1=0; static fix explosion_wait2=0; @@ -624,7 +636,7 @@ void do_endlevel_frame() ext_expl_playing = 1; } - + digi_link_sound_to_pos( SOUND_BIG_ENDLEVEL_EXPLOSION, exit_segnum, 0, &mine_side_exit_point, 0, i2f(3)/4 ); } } @@ -701,46 +713,48 @@ void do_endlevel_frame() if (ConsoleObject->segnum == transition_segnum) { - if ((Current_mission_num == Builtin_mission_num) && - (start_endlevel_movie() != MOVIE_NOT_PLAYED)) + #if !defined(SHAREWARE) && !defined(NMOVIES) + start_endlevel_movie(); stop_endlevel_sequence(); - else { - int objnum; + #else - //songs_play_song( SONG_ENDLEVEL, 0 ); + int objnum; - Endlevel_sequence = EL_LOOKBACK; + //songs_play_song( SONG_ENDLEVEL, 0 ); - objnum = obj_create(OBJ_CAMERA, 0, - ConsoleObject->segnum,&ConsoleObject->pos,&ConsoleObject->orient,0, - CT_NONE,MT_NONE,RT_NONE); + Endlevel_sequence = EL_LOOKBACK; - if (objnum == -1) { //can't get object, so abort - mprintf((1, "Can't get object for endlevel sequence. Aborting endlevel sequence.\n")); - stop_endlevel_sequence(); - return; - } + objnum = obj_create(OBJ_CAMERA, 0, + ConsoleObject->segnum,&ConsoleObject->pos,&ConsoleObject->orient,0, + CT_NONE,MT_NONE,RT_NONE); - Viewer = endlevel_camera = &Objects[objnum]; + if (objnum == -1) { //can't get object, so abort + mprintf((1, "Can't get object for endlevel sequence. Aborting endlevel sequence.\n")); + stop_endlevel_sequence(); + return; + } - select_cockpit(CM_LETTERBOX); + Viewer = endlevel_camera = &Objects[objnum]; - fly_objects[1] = fly_objects[0]; - fly_objects[1].obj = endlevel_camera; - fly_objects[1].speed = (5*cur_fly_speed)/4; - fly_objects[1].offset_frac = 0x4000; + select_cockpit(CM_LETTERBOX); - vm_vec_scale_add2(&endlevel_camera->pos,&endlevel_camera->orient.fvec,i2f(7)); + fly_objects[1] = fly_objects[0]; + fly_objects[1].obj = endlevel_camera; + fly_objects[1].speed = (5*cur_fly_speed)/4; + fly_objects[1].offset_frac = 0x4000; - timer=0x20000; + vm_vec_scale_add2(&endlevel_camera->pos,&endlevel_camera->orient.fvec,i2f(7)); - } + timer=0x20000; + + #endif } break; } +#if defined(SHAREWARE) || defined(NMOVIES) case EL_LOOKBACK: { do_endlevel_flythrough(0); @@ -774,7 +788,7 @@ void do_endlevel_frame() slew_obj = endlevel_camera; #endif } - + break; } @@ -925,6 +939,7 @@ void do_endlevel_frame() } #endif //ifdef SHORT_SEQUENCE +#endif } } @@ -1076,7 +1091,7 @@ void draw_stars() if ((i&63) == 0) { gr_setcolor(BM_XRGB(intensity,intensity,intensity)); intensity-=3; - } + } //g3_rotate_point(&p,&stars[i]); g3_rotate_delta_vec(&p.p3_vec,&stars[i]); @@ -1164,8 +1179,10 @@ void render_endlevel_frame(fix eye_offset) if (Endlevel_sequence < EL_OUTSIDE) endlevel_render_mine(eye_offset); + #ifdef SHAREWARE else render_external_scene(eye_offset); + #endif g3_end_frame(); @@ -1326,7 +1343,7 @@ void do_endlevel_flythrough(int n) compute_segment_center(&nextcenter,&Segments[pseg->children[exit_side]]); vm_vec_sub(&flydata->headvec,&nextcenter,&curcenter); - #ifdef COMPACT_SEGS + #ifdef COMPACT_SEGS { vms_vector _v1; get_side_normal(pseg, up_side, 0, &_v1 ); @@ -1396,20 +1413,20 @@ int _do_slew_movement(object *obj, int check_keys, int check_joy ) if (check_joy && joy_present) { joy_get_pos(&joy_x,&joy_y); btns=joy_get_btns(); - + joyx_moved = (abs(joy_x - old_joy_x)>JOY_NULL); joyy_moved = (abs(joy_y - old_joy_y)>JOY_NULL); - + if (abs(joy_x) < JOY_NULL) joy_x = 0; if (abs(joy_y) < JOY_NULL) joy_y = 0; - + if (btns) if (!rotang.pitch) rotang.pitch = fixmul(-joy_y * 512,FrameTime); else; else if (joyy_moved) obj->phys_info.velocity.z = -joy_y * 8192; - + if (!rotang.head) rotang.head = fixmul(joy_x * 512,FrameTime); - + if (joyx_moved) old_joy_x = joy_x; if (joyy_moved) old_joy_y = joy_y; } @@ -1489,9 +1506,7 @@ try_again: if (!ifile) { if (level_num==1) { - con_printf(CON_DEBUG, "Cannot load file text of binary version of <%s>\n",filename); - endlevel_data_loaded = 0; - return; + Error("Cannot load file text of binary version of <%s>",filename); } else { level_num = 1; @@ -1537,16 +1552,17 @@ try_again: d_free(terrain_bm_instance.bm_data); Assert(terrain_bm_instance.bm_data == NULL); - + iff_error = iff_read_bitmap(p,&terrain_bm_instance,BM_LINEAR,pal); if (iff_error != IFF_NO_ERROR) { + mprintf((1, "File %s - IFF error: %s",p,iff_errormsg(iff_error))); Error("File %s - IFF error: %s",p,iff_errormsg(iff_error)); } terrain_bitmap = &terrain_bm_instance; gr_remap_bitmap_good( terrain_bitmap, pal, iff_transparent_color, -1); - + break; } @@ -1654,11 +1670,11 @@ try_again: vm_vec_rotate(&tv,&station_pos,&tm); vm_vec_scale_add(&station_pos,&mine_exit_point,&tv,STATION_DIST); - vm_vec_rotate(&tv,&satellite_pos,&tm); - vm_vec_scale_add(&satellite_pos,&mine_exit_point,&tv,SATELLITE_DIST); +vm_vec_rotate(&tv,&satellite_pos,&tm); +vm_vec_scale_add(&satellite_pos,&mine_exit_point,&tv,SATELLITE_DIST); - vm_vector_2_matrix(&tm,&tv,&surface_orient.uvec,NULL); - vm_vec_copy_scale(&satellite_upvec,&tm.uvec,SATELLITE_HEIGHT); +vm_vector_2_matrix(&tm,&tv,&surface_orient.uvec,NULL); +vm_vec_copy_scale(&satellite_upvec,&tm.uvec,SATELLITE_HEIGHT); } @@ -1668,3 +1684,6 @@ try_again: endlevel_data_loaded = 1; } + +#endif + diff --git a/main/endlevel.h b/main/endlevel.h index 5c57ce5b..1baf0423 100644 --- a/main/endlevel.h +++ b/main/endlevel.h @@ -1,4 +1,3 @@ -/* $Id: endlevel.h,v 1.5 2003-04-12 00:11:46 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,6 +11,8 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ + + #ifndef _OUTSIDE_H #define _OUTSIDE_H @@ -23,6 +24,8 @@ void stop_endlevel_sequence(); void start_endlevel_sequence(); void render_endlevel_frame(fix eye_offset); +#if defined(SHAREWARE) || defined(NMOVIES) + void render_external_scene(); void draw_exit_model(); void init_endlevel(); @@ -40,3 +43,5 @@ void load_endlevel_data(int level_num); extern int exit_modelnum,destroyed_exit_modelnum; #endif + +#endif diff --git a/main/escort.c b/main/escort.c index 5a2bde81..b018f810 100644 --- a/main/escort.c +++ b/main/escort.c @@ -1,4 +1,3 @@ -/* $Id: escort.c,v 1.5 2003-03-27 01:23:18 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -16,7 +15,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #endif -#include // for printf() +#include // for printf() #include // for rand() and qsort() #include // for memset() @@ -53,7 +52,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "automap.h" #include "laser.h" #include "pa_enabl.h" -#include "escort.h" #ifdef EDITOR #include "editor/editor.h" @@ -105,6 +103,8 @@ int Last_buddy_key; fix Last_buddy_message_time; +//if change this length, change in playsave.c also +#define GUIDEBOT_NAME_LEN 9 char guidebot_name[GUIDEBOT_NAME_LEN+1] = "GUIDE-BOT"; char real_guidebot_name[GUIDEBOT_NAME_LEN+1] = "GUIDE-BOT"; @@ -980,12 +980,6 @@ int maybe_buddy_fire_mega(int objnum) if (!object_to_object_visibility(buddy_objp, objp, FQ_TRANSWALL)) return 0; - if (Weapon_info[MEGA_ID].render_type == 0) { - con_printf(CON_VERBOSE, "Buddy can't fire mega (shareware)\n"); - buddy_message("CLICK!"); - return 0; - } - mprintf((0, "Buddy firing mega in frame %i\n", FrameCount)); buddy_message("GAHOOGA!"); @@ -998,7 +992,7 @@ int maybe_buddy_fire_mega(int objnum) return 1; } -//----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- int maybe_buddy_fire_smart(int objnum) { object *objp = &Objects[objnum]; diff --git a/main/escort.h b/main/escort.h deleted file mode 100644 index 533d7132..00000000 --- a/main/escort.h +++ /dev/null @@ -1,20 +0,0 @@ -/* $Id: escort.h,v 1.1 2003-03-27 01:23:18 btb Exp $ */ - -#ifndef _ESCORT_H -#define _ESCORT_H - -extern int Buddy_dude_cheat; - - -#define GUIDEBOT_NAME_LEN 9 -extern char guidebot_name[]; -extern char real_guidebot_name[]; - -extern void change_guidebot_name(void); - - -extern void do_escort_menu(void); -extern void detect_escort_goal_accomplished(int index); -extern void set_escort_special_goal(int key); - -#endif // _ESCORT_H diff --git a/main/fuelcen.c b/main/fuelcen.c index 2786c8d6..3cc40a22 100644 --- a/main/fuelcen.c +++ b/main/fuelcen.c @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: fuelcen.c,v 1.6 2003-03-27 01:23:18 btb Exp $"; +static char rcsid[] = "$Id: fuelcen.c,v 1.3 2001-10-25 02:15:56 bradleyb Exp $"; #endif #include @@ -52,7 +52,6 @@ static char rcsid[] = "$Id: fuelcen.c,v 1.6 2003-03-27 01:23:18 btb Exp $"; #include "multi.h" #endif #include "multibot.h" -#include "escort.h" // The max number of fuel stations per mine. @@ -1129,29 +1128,5 @@ void fuelcen_check_for_hoard_goal(segment *segp) #endif -#ifndef FAST_FILE_IO -/* - * reads an old_matcen_info structure from a CFILE - */ -void old_matcen_info_read(old_matcen_info *mi, CFILE *fp) -{ - mi->robot_flags = cfile_read_int(fp); - mi->hit_points = cfile_read_fix(fp); - mi->interval = cfile_read_fix(fp); - mi->segnum = cfile_read_short(fp); - mi->fuelcen_num = cfile_read_short(fp); -} -/* - * reads a matcen_info structure from a CFILE - */ -void matcen_info_read(matcen_info *mi, CFILE *fp) -{ - mi->robot_flags[0] = cfile_read_int(fp); - mi->robot_flags[1] = cfile_read_int(fp); - mi->hit_points = cfile_read_fix(fp); - mi->interval = cfile_read_fix(fp); - mi->segnum = cfile_read_short(fp); - mi->fuelcen_num = cfile_read_short(fp); -} -#endif + diff --git a/main/fuelcen.h b/main/fuelcen.h index 61cdf5ff..7b8bc8b2 100644 --- a/main/fuelcen.h +++ b/main/fuelcen.h @@ -107,14 +107,6 @@ typedef struct FuelCenter { extern int Num_robot_centers; -typedef struct { - int robot_flags; // Up to 32 different robots - fix hit_points; // How hard it is to destroy this particular matcen - fix interval; // Interval between materialogrifizations - short segnum; // Segment this is attached to. - short fuelcen_num; // Index in fuelcen array. -} __pack__ old_matcen_info; - typedef struct matcen_info { int robot_flags[2]; // Up to 64 different robots fix hit_points; // How hard it is to destroy this particular matcen @@ -141,19 +133,4 @@ extern fix EnergyToCreateOneRobot; void fuelcen_check_for_hoard_goal(segment *segp); -#ifdef FAST_FILE_IO -#define old_matcen_info_read(mi, fp) cfread(mi, sizeof(old_matcen_info), 1, fp) -#define matcen_info_read(mi, fp) cfread(mi, sizeof(matcen_info), 1, fp) -#else -/* - * reads an old_matcen_info structure from a CFILE - */ -void old_matcen_info_read(old_matcen_info *mi, CFILE *fp); - -/* - * reads a matcen_info structure from a CFILE - */ -void matcen_info_read(matcen_info *ps, CFILE *fp); -#endif - #endif diff --git a/main/game.c b/main/game.c index 850d75d5..a188dbaf 100644 --- a/main/game.c +++ b/main/game.c @@ -1,4 +1,3 @@ -/* $Id: game.c,v 1.20 2003-03-17 09:33:49 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -char game_rcsid[] = "$Id: game.c,v 1.20 2003-03-17 09:33:49 btb Exp $"; +char game_rcsid[] = "$Id: game.c,v 1.8 2001-10-25 02:19:31 bradleyb Exp $"; #endif #ifdef WINDOWS @@ -117,7 +116,7 @@ char game_rcsid[] = "$Id: game.c,v 1.20 2003-03-17 09:33:49 btb Exp $"; #include "robot.h" #include "playsave.h" #include "fix.h" -#include "hudmsg.h" +#include "d_delay.h" int VGA_current_mode; @@ -327,7 +326,7 @@ void init_game() set_detail_level_parameters(Detail_level); - build_mission_list(0); + build_mission_list(0); // This also loads mission 0. /* Register cvars */ cvar_registervariable(&r_framerate); @@ -464,9 +463,11 @@ void init_cockpit() //Initialize the on-screen canvases - if (Newdemo_state==ND_STATE_RECORDING) { + if (Newdemo_state==ND_STATE_RECORDING) + { + newdemo_record_cockpit_change(Cockpit_mode); - } + } if ( VR_render_mode != VR_NONE ) Cockpit_mode = CM_FULL_SCREEN; @@ -477,17 +478,10 @@ void init_cockpit() if ( Screen_mode == SCREEN_EDITOR ) Cockpit_mode = CM_FULL_SCREEN; -#ifdef OGL - if (Cockpit_mode == CM_FULL_COCKPIT || Cockpit_mode == CM_REAR_VIEW) { - hud_message(MSGC_GAME_FEEDBACK, "Cockpit not available in GL mode"); - Cockpit_mode = CM_FULL_SCREEN; - } -#endif - - WINDOS( - dd_gr_set_current_canvas(NULL), - gr_set_current_canvas(NULL) - ); + WINDOS( + dd_gr_set_current_canvas(NULL), + gr_set_current_canvas(NULL) + ); gr_set_curfont( GAME_FONT ); #if !defined(MACINTOSH) && !defined(WINDOWS) @@ -507,52 +501,54 @@ void init_cockpit() game_win_init_cockpit_mask(0); #endif - switch( Cockpit_mode ) { + switch( Cockpit_mode ) + { case CM_FULL_COCKPIT: - case CM_REAR_VIEW: { + case CM_REAR_VIEW: { grs_bitmap *bm = &GameBitmaps[cockpit_bitmap[Cockpit_mode+(Current_display_mode?(Num_cockpits/2):0)].index]; PIGGY_PAGE_IN(cockpit_bitmap[Cockpit_mode+(Current_display_mode?(Num_cockpits/2):0)]); -#ifdef WINDOWS + #ifdef WINDOWS dd_gr_set_current_canvas(NULL); game_win_init_cockpit_mask(1); dd_gr_set_current_canvas(dd_VR_offscreen_buffer); -#else - gr_set_current_canvas(VR_offscreen_buffer); -#endif + #else + gr_set_current_canvas(VR_offscreen_buffer) + #endif - WIN(DDGRLOCK(dd_grd_curcanv)); + WIN(DDGRLOCK(dd_grd_curcanv)); gr_bitmap( 0, 0, bm ); bm = &VR_offscreen_buffer->cv_bitmap; bm->bm_flags = BM_FLAG_TRANSPARENT; gr_ibitblt_find_hole_size ( bm, &minx, &miny, &maxx, &maxy ); - WIN( win_get_span_list(bm, miny, maxy); - DDGRUNLOCK(dd_grd_curcanv) - ); + WIN( win_get_span_list(bm, miny, maxy); + DDGRUNLOCK(dd_grd_curcanv) + ); #ifndef WINDOWS -#ifndef __MSDOS__ - gr_ibitblt_create_mask( bm, minx, miny, maxx-minx+1, maxy-miny+1, VR_offscreen_buffer->cv_bitmap.bm_rowsize); -#else - if ( Current_display_mode ) { -#if defined(POLY_ACC) + #if 1 // def MACINTOSH + gr_ibitblt_create_mask( bm, minx, miny, maxx-minx+1, maxy-miny+1, VR_offscreen_buffer->cv_bitmap.bm_rowsize); + #else + if ( Current_display_mode ) + { + #if defined(POLY_ACC) Game_cockpit_copy_code = gr_ibitblt_create_mask_pa( bm, minx, miny, maxx-minx+1, maxy-miny+1, VR_offscreen_buffer->cv_bitmap.bm_rowsize ); pa_clear_buffer(1, 0); // clear offscreen to reduce white flash. -#else + #else Game_cockpit_copy_code = gr_ibitblt_create_mask_svga( bm, minx, miny, maxx-minx+1, maxy-miny+1, VR_offscreen_buffer->cv_bitmap.bm_rowsize ); -#endif + #endif } else Game_cockpit_copy_code = gr_ibitblt_create_mask( bm, minx, miny, maxx-minx+1, maxy-miny+1, VR_offscreen_buffer->cv_bitmap.bm_rowsize ); -#endif + #endif bm->bm_flags = 0; // Clear all flags for offscreen canvas #else - Game_cockpit_copy_code = (ubyte *)(1); + Game_cockpit_copy_code = (ubyte *)(1); bm->bm_flags = 0; // Clear all flags for offscreen canvas #endif game_init_render_sub_buffers( 0, 0, maxx-minx+1, maxy-miny+1 ); break; - } + } case CM_FULL_SCREEN: @@ -906,7 +902,7 @@ WIN(static int saved_window_h); dd_grd_screencanv->canvas.cv_bitmap.bm_w, dd_grd_screencanv->canvas.cv_bitmap.bm_h); MenuHires = 1; - FontHires = FontHiresAvailable; + FontHires = 1; #else { @@ -934,7 +930,7 @@ WIN(static int saved_window_h); gr_init_sub_canvas( &VR_screen_pages[0], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h ); gr_init_sub_canvas( &VR_screen_pages[1], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h ); - FontHires = FontHiresAvailable && MenuHires; + FontHires = MenuHires; } #endif @@ -1026,15 +1022,15 @@ WIN(static int saved_window_h); init_cockpit(); #ifdef WINDOWS - FontHires = FontHiresAvailable && (Current_display_mode != 0); + FontHires = (Current_display_mode != 0); MenuHires = 1; #else - FontHires = FontHiresAvailable && (MenuHires = ((Current_display_mode != 0) && (Current_display_mode != 2))); + FontHires = MenuHires = ((Current_display_mode != 0) && (Current_display_mode != 2)); #endif if ( VR_render_mode != VR_NONE ) { // for 640x480 or higher, use hires font. - if (FontHiresAvailable && (grd_curscreen->sc_h > 400)) + if ( grd_curscreen->sc_h > 400 ) FontHires = 1; else FontHires = 0; @@ -1084,38 +1080,6 @@ WIN(static int saved_window_h); return 1; } -int gr_toggle_fullscreen_game(void){ -#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE - int i; - hud_message(MSGC_GAME_FEEDBACK, "toggling fullscreen mode %s",(i=gr_toggle_fullscreen())?"on":"off" ); - //added 2000/06/19 Matthew Mueller - hack to fix "infinite toggle" problem - //it seems to be that the screen mode change takes long enough that the key has already sent repeat codes, or that its unpress event gets dropped, etc. This is a somewhat ugly fix, but it works. -// generic_key_handler(KEY_PADENTER,0); - key_flush(); - //end addition -MM - return i; -#else - hud_message(MSGC_GAME_FEEDBACK, "fullscreen toggle not supported by this target"); - return -1; -#endif -} - -int arch_toggle_fullscreen_menu(void); - -int gr_toggle_fullscreen_menu(void){ -#ifdef GR_SUPPORTS_FULLSCREEN_MENU_TOGGLE - int i; - i=arch_toggle_fullscreen_menu(); - -// generic_key_handler(KEY_PADENTER,0); - key_flush(); - - return i; -#else - return -1; -#endif -} - static int timer_paused=0; void stop_time() @@ -1193,9 +1157,7 @@ int Movie_fixed_frametime; #define Movie_fixed_frametime 0 #endif -//added on 8/18/98 by Victor Rachels to add maximum framerate -int maxfps = 80; -//end this section +static const int max_fps = 80; void calc_frame_time() { @@ -1211,9 +1173,11 @@ void calc_frame_time() do { timer_value = timer_get_fixed_seconds(); FrameTime = timer_value - last_timer_value; - if (FrameTime < f1_0/maxfps); - timer_delay(1); - } while (FrameTime < f1_0/maxfps); + if (FrameTime < f1_0/max_fps); + { + d_delay(1); + } + } while (FrameTime < f1_0/max_fps); #if defined(TIMER_TEST) && !defined(NDEBUG) _timer_value = timer_value; @@ -2605,9 +2569,7 @@ void flicker_lights(); void GameLoop(int RenderFlag, int ReadControlsFlag ) { -#ifdef CONSOLE con_update(); -#endif #ifndef NDEBUG // Used to slow down frame rate for testing things. // RenderFlag = 1; // DEBUG @@ -3358,15 +3320,3 @@ void game_win_init_cockpit_mask(int sram) //@@} #endif - -/* - * reads a flickering_light structure from a CFILE - */ -void flickering_light_read(flickering_light *fl, CFILE *fp) -{ - fl->segnum = cfile_read_short(fp); - fl->sidenum = cfile_read_short(fp); - fl->mask = cfile_read_int(fp); - fl->timer = cfile_read_fix(fp); - fl->delay = cfile_read_fix(fp); -} diff --git a/main/game.h b/main/game.h index 4a26ece2..3aef5894 100644 --- a/main/game.h +++ b/main/game.h @@ -255,13 +255,5 @@ void enable_flicker(int segnum,int sidenum); //returns 1 if ok, 0 if error int add_flicker(int segnum,int sidenum,fix delay,ulong mask); -int gr_toggle_fullscreen_game(void); - -/* - * reads a flickering_light structure from a CFILE - */ -void flickering_light_read(flickering_light *fl, CFILE *fp); - -extern int maxfps; - #endif + diff --git a/main/gamecntl.c b/main/gamecntl.c index 1dbdda59..f871040f 100644 --- a/main/gamecntl.c +++ b/main/gamecntl.c @@ -1,4 +1,5 @@ -/* $Id: gamecntl.c,v 1.17 2003-03-27 01:25:41 btb Exp $ */ +//#define DOOR_DEBUGGING + /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +9,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -16,8 +17,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #endif -//#define DOOR_DEBUGGING - #include #include #include @@ -95,9 +94,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "piggy.h" #include "multibot.h" #include "ai.h" -#include "rbaudio.h" #include "switch.h" -#include "escort.h" +#include "cdrom.h" #ifdef POLY_ACC #include "poly_acc.h" @@ -122,7 +120,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef SDL_INPUT -#include +#include #endif extern void full_palette_save(void); @@ -977,6 +975,7 @@ int select_next_window_function(int w) return 1; //screen_changed } +extern void do_escort_menu(void),change_guidebot_name(void); extern int Game_paused; void songs_goto_next_song(); @@ -1388,49 +1387,7 @@ int HandleSystemKey(int key) break; #endif -//added 8/23/99 by Matt Mueller for hot key res/fullscreen changing, and menu access - case KEY_CTRLED+KEY_SHIFTED+KEY_PADDIVIDE: - case KEY_ALTED+KEY_CTRLED+KEY_PADDIVIDE: - case KEY_ALTED+KEY_SHIFTED+KEY_PADDIVIDE: - d2x_options_menu(); - break; -#if 0 - case KEY_CTRLED+KEY_SHIFTED+KEY_PADMULTIPLY: - case KEY_ALTED+KEY_CTRLED+KEY_PADMULTIPLY: - case KEY_ALTED+KEY_SHIFTED+KEY_PADMULTIPLY: - change_res(); - break; - case KEY_CTRLED+KEY_SHIFTED+KEY_PADMINUS: - case KEY_ALTED+KEY_CTRLED+KEY_PADMINUS: - case KEY_ALTED+KEY_SHIFTED+KEY_PADMINUS: - //lower res - //should we just cycle through the list that is displayed in the res change menu? - // what if their card/X/etc can't handle that mode? hrm. - //well, the quick access to the menu is good enough for now. - break; - case KEY_CTRLED+KEY_SHIFTED+KEY_PADPLUS: - case KEY_ALTED+KEY_CTRLED+KEY_PADPLUS: - case KEY_ALTED+KEY_SHIFTED+KEY_PADPLUS: - //increase res - break; -#endif - case KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER: - case KEY_ALTED+KEY_CTRLED+KEY_PADENTER: - case KEY_ALTED+KEY_SHIFTED+KEY_PADENTER: - gr_toggle_fullscreen_game(); - break; -//end addition -MM - -//added 11/01/98 Matt Mueller -#if 0 - case KEY_CTRLED+KEY_ALTED+KEY_LAPOSTRO: - toggle_hud_log(); - break; -#endif -//end addition -MM - - default: - break; + default: break; } //switch (key) @@ -1532,7 +1489,6 @@ void HandleGameKey(int key) case KEY_COMMAND+KEY_F: r_framerate.value = !r_framerate.value; break; #endif -#if 0 // weapon selection handled in controls_read_all, d1x-style // MWA changed the weapon select cases to have each case call do_weapon_select // the macintosh keycodes aren't consecutive from 1 -- 0 on the keyboard -- boy is that STUPID!!!! // Select primary or secondary weapon. @@ -1567,7 +1523,6 @@ void HandleGameKey(int key) case KEY_0: do_weapon_select(4 , 1); break; -#endif case KEY_1 + KEY_SHIFTED: case KEY_2 + KEY_SHIFTED: @@ -2040,27 +1995,27 @@ char *LamerCheats[]={ "!UyN#E$I", // gabba-gabbahey #define N_LAMER_CHEATS (sizeof(LamerCheats) / sizeof(*LamerCheats)) -char *WowieCheat ="F_JMO3CV"; //only Matt knows / h-onestbob -char *AllKeysCheat ="%v%MrgbU"; //only Matt knows / or-algroove -char *InvulCheat ="Wv_\\JJ\\Z"; //only Matt knows / almighty -char *HomingCheatString ="t\\LIhSB["; //only Matt knows / l-pnlizard -char *BouncyCheat ="bGbiChQJ"; //only Matt knows / duddaboo -char *FullMapCheat ="PI @@ -27,7 +27,6 @@ static char rcsid[] = "$Id: gamefont.c,v 1.3 2002-07-30 11:05:53 btb Exp $"; //if 1, use high-res versions of fonts int FontHires=0; -int FontHiresAvailable=0; char * Gamefont_filenames[] = { "font1-1.fnt", // Font 0 "font1-1h.fnt", // Font 0 High-res @@ -51,15 +50,9 @@ void gamefont_init() if (Gamefont_installed) return; Gamefont_installed = 1; - FontHiresAvailable = 1; - for (i=0; i #endif #ifdef RCS -static char rcsid[] = "$Id: gamemine.c,v 1.23 2003-04-12 02:52:38 btb Exp $"; +static char rcsid[] = "$Id: gamemine.c,v 1.3 2001-10-25 02:15:56 bradleyb Exp $"; #endif #include @@ -170,7 +44,7 @@ static char rcsid[] = "$Id: gamemine.c,v 1.23 2003-04-12 02:52:38 btb Exp $"; #include "editor/editor.h" #endif -#include "cfile.h" +#include "cfile.h" #include "fuelcen.h" #include "hash.h" @@ -178,13 +52,12 @@ static char rcsid[] = "$Id: gamemine.c,v 1.23 2003-04-12 02:52:38 btb Exp $"; #include "piggy.h" #include "byteswap.h" -#include "gamesave.h" #define REMOVE_EXT(s) (*(strchr( (s), '.' ))='\0') -fix Level_shake_frequency = 0, Level_shake_duration = 0; -int Secret_return_segment = 0; -vms_matrix Secret_return_orient; +fix Level_shake_frequency = 0, Level_shake_duration = 0; +int Secret_return_segment = 0; +vms_matrix Secret_return_orient; struct mtfi mine_top_fileinfo; // Should be same as first two fields below... struct mfi mine_fileinfo; @@ -192,384 +65,121 @@ struct mh mine_header; struct me mine_editor; typedef struct v16_segment { - #ifdef EDITOR - short segnum; // segment number, not sure what it means + #ifdef EDITOR + short segnum; // segment number, not sure what it means #endif - side sides[MAX_SIDES_PER_SEGMENT]; // 6 sides - short children[MAX_SIDES_PER_SEGMENT]; // indices of 6 children segments, front, left, top, right, bottom, back - short verts[MAX_VERTICES_PER_SEGMENT]; // vertex ids of 4 front and 4 back vertices - #ifdef EDITOR - short group; // group number to which the segment belongs. + side sides[MAX_SIDES_PER_SEGMENT]; // 6 sides + short children[MAX_SIDES_PER_SEGMENT]; // indices of 6 children segments, front, left, top, right, bottom, back + short verts[MAX_VERTICES_PER_SEGMENT]; // vertex ids of 4 front and 4 back vertices + #ifdef EDITOR + short group; // group number to which the segment belongs. #endif - short objects; // pointer to objects in this segment - ubyte special; // what type of center this is - byte matcen_num; // which center segment is associated with. - short value; - fix static_light; // average static light in segment - #ifndef EDITOR - short pad; // make structure longword aligned + short objects; // pointer to objects in this segment + ubyte special; // what type of center this is + byte matcen_num; // which center segment is associated with. + short value; + fix static_light; //average static light in segment + #ifndef EDITOR + short pad; //make structure longword aligned #endif } v16_segment; struct mfi_v19 { - ushort fileinfo_signature; - ushort fileinfo_version; - int fileinfo_sizeof; - int header_offset; // Stuff common to game & editor - int header_size; - int editor_offset; // Editor specific stuff - int editor_size; - int segment_offset; - int segment_howmany; - int segment_sizeof; - int newseg_verts_offset; - int newseg_verts_howmany; - int newseg_verts_sizeof; - int group_offset; - int group_howmany; - int group_sizeof; - int vertex_offset; - int vertex_howmany; - int vertex_sizeof; - int texture_offset; - int texture_howmany; - int texture_sizeof; - int walls_offset; - int walls_howmany; - int walls_sizeof; - int triggers_offset; - int triggers_howmany; - int triggers_sizeof; - int links_offset; - int links_howmany; - int links_sizeof; - int object_offset; // Object info - int object_howmany; - int object_sizeof; - int unused_offset; // was: doors_offset - int unused_howmamy; // was: doors_howmany - int unused_sizeof; // was: doors_sizeof - short level_shake_frequency; // Shakes every level_shake_frequency seconds - short level_shake_duration; // for level_shake_duration seconds (on average, random). In 16ths second. - int secret_return_segment; - vms_matrix secret_return_orient; - - int dl_indices_offset; - int dl_indices_howmany; - int dl_indices_sizeof; - - int delta_light_offset; - int delta_light_howmany; - int delta_light_sizeof; + ushort fileinfo_signature; + ushort fileinfo_version; + int fileinfo_sizeof; + int header_offset; // Stuff common to game & editor + int header_size; + int editor_offset; // Editor specific stuff + int editor_size; + int segment_offset; + int segment_howmany; + int segment_sizeof; + int newseg_verts_offset; + int newseg_verts_howmany; + int newseg_verts_sizeof; + int group_offset; + int group_howmany; + int group_sizeof; + int vertex_offset; + int vertex_howmany; + int vertex_sizeof; + int texture_offset; + int texture_howmany; + int texture_sizeof; + int walls_offset; + int walls_howmany; + int walls_sizeof; + int triggers_offset; + int triggers_howmany; + int triggers_sizeof; + int links_offset; + int links_howmany; + int links_sizeof; + int object_offset; // Object info + int object_howmany; + int object_sizeof; + int unused_offset; //was: doors_offset + int unused_howmamy; //was: doors_howmany + int unused_sizeof; //was: doors_sizeof + short level_shake_frequency, level_shake_duration; // Shakes every level_shake_frequency seconds + // for level_shake_duration seconds (on average, random). In 16ths second. + int secret_return_segment; + vms_matrix secret_return_orient; + + int dl_indices_offset; + int dl_indices_howmany; + int dl_indices_sizeof; + + int delta_light_offset; + int delta_light_howmany; + int delta_light_sizeof; }; int CreateDefaultNewSegment(); -int New_file_format_load = 1; // "new file format" is everything newer than d1 shareware - -int d1_pig_loaded = 0; // can descent.pig from descent 1 be loaded? - -#define TMAP_NUM_MASK 0x3FFF - -/* converts descent 1 texture numbers to descent 2 texture numbers - * textures whose names don't match between versions have extra spaces around "return" - * updated using the file config/convtabl.ini from the devil 2.2 level editor - */ -short convert_d1_tmap_num(short d1_tmap_num) { - if (d1_pig_loaded && d1_tmap_num < 324) // we use original d1 textures for non-animated textures - return d1_tmap_num; - switch (d1_tmap_num) { - case 0: return 43; // grey (devil:95) - case 1: return 0; - case 2: return 43; // grey - case 3: return 1; - case 4: return 43; // grey - case 5: return 43; // grey - case 6: return 270; // blue - case 7: return 271; // yellow - case 8: return 2; - case 9: return 62; // purple (devil:179) - case 10: return 272; // red - case 11: return 117; - case 12: return 12; //devil:43 - case 13: return 3; - case 14: return 4; - case 15: return 5; - case 16: return 6; - case 17: return 52; - case 18: return 129; - case 19: return 7; - case 20: return 22; - case 21: return 9; - case 22: return 8; - case 23: return 9; - case 24: return 10; - case 25: return 12; //devil:35 - case 26: return 11; - case 27: return 12; - case 28: return 11; //devil:43 - case 29: return 13; - case 30: return 14; - case 31: return 15; - case 32: return 16; - case 33: return 17; - case 34: return 18; - case 35: return 19; - case 36: return 20; - case 37: return 21; - case 38: return 163; //devil:27 - case 39: return 31; //devil:147 - case 40: return 22; - case 41: return 266; - case 42: return 23; - case 43: return 24; - case 44: return 136; //devil:135 - case 45: return 25; - case 46: return 26; - case 47: return 27; - case 48: return 28; - case 49: return 43; //devil:60 - case 50: return 131; //devil:138 - case 51: return 29; - case 52: return 30; - case 53: return 31; - case 54: return 32; - case 55: return 165; //devil:193 - case 56: return 33; - case 57: return 132; //devil:119 - // range handled by default case - case 88: return 197; //devil:15 - // range handled by default case - case 132: return 167; - case 133: return 107; - case 134: return 108; - case 135: return 109; - case 136: return 110; - case 137: return 111; - case 138: return 112; - case 139: return 113; - case 140: return 114; - case 141: return 110; //devil:106 - case 142: return 115; - case 143: return 116; - case 144: return 117; - case 145: return 118; - case 146: return 119; - case 147: return 93; - case 148: return 120; - case 149: return 121; - case 150: return 122; - case 151: return 123; - case 152: return 124; - case 153: return 125; - case 154: return 27; - case 155: return 126; //was: 66 - case 156: return 200; - case 157: return 201; - case 158: return 186; //devil:227 - case 159: return 190; //devil:246 - case 160: return 206; - case 161: return 114; //devil:206 - case 162: return 202; - case 163: return 203; - case 164: return 204; - case 165: return 205; - case 166: return 206; - case 167: return 206; - case 168: return 206; - case 169: return 206; - case 170: return 227;//206; - case 171: return 206;//227; - case 172: return 207; - case 173: return 208; - case 174: return 202; - case 175: return 206; - case 176: return 209; - case 177: return 210; - case 178: return 211; - case 179: return 212; - case 180: return 213; - case 181: return 214; - case 182: return 215; - case 183: return 216; - case 184: return 217; - case 185: return 217; - case 186: return 218; - case 187: return 219; - case 188: return 220; - case 189: return 221; - case 190: return 222; - case 191: return 223; - case 192: return 224; - case 193: return 206; - case 194: return 203;//206; - case 195: return 234; - case 196: return 225; - case 197: return 226; - case 198: return 225; - case 199: return 206; //devil:204 - case 200: return 206; //devil:204 - case 201: return 227; - case 202: return 206; //devil:227 - case 203: return 228; - case 204: return 229; - case 205: return 230; - case 206: return 231; - case 207: return 232; - case 208: return 233; - case 209: return 234; - case 210: return 234; //devil:242 - case 211: return 206; //devil:240 - case 212: return 235; - case 213: return 236; - case 214: return 237; - case 215: return 238; - case 216: return 239; - case 217: return 240; - case 218: return 241; - case 219: return 242; - case 220: return 242; //devil:240 - case 221: return 243; - case 222: return 244; - case 223: return 313; - case 224: return 245; - case 225: return 246; - case 226: return 164;//247; matching names but not matching textures - case 227: return 179; //devil:181 - case 228: return 196;//248; matching names but not matching textures - case 229: return 15; //devil:66 - case 230: return 15; //devil:66 - case 231: return 249; - case 232: return 250; - case 233: return 251; - case 234: return 252; - case 235: return 253; - case 236: return 254; - case 237: return 255; - case 238: return 256; - case 239: return 257; - case 240: return 6; //devil:132 - case 241: return 130; //devil:131 - case 242: return 78; //devil:15 - case 243: return 33; //devil:38 - case 244: return 258; - case 245: return 259; - case 246: return 321; - case 247: return 260; - case 248: return 261; - case 249: return 262; - case 250: return 340; // white entrance - case 251: return 412; // red entrance - case 252: return 410; // blue entrance - case 253: return 411; // yellow entrance - case 254: return 263; - case 255: return 264; - case 256: return 265; - case 257: return 249;//246; - case 258: return 251;//246; - case 259: return 252;//246; - case 260: return 256;//246; - case 261: return 273; - case 262: return 274; - case 263: return 281; - case 264: return 275; - case 265: return 276; - case 266: return 279; //devil:291 - // range handled by default case - case 282: return 293; - case 283: return 295; - case 284: return 295; - case 285: return 296; - case 286: return 298; - // range handled by default case - case 298: return 364; //devil:374 - // range handled by default case - case 315: return 361; // broken producer - // range handled by default case - case 327: return 352; - case 328: return 353; - case 329: return 354; - case 330: return 380; - case 331: return 379;//373; matching names but not matching textures; - case 332: return 355;//344; matching names but not matching textures - case 333: return 409; // lava //devil:404 - case 334: return 356; - case 335: return 357; - case 336: return 358; - case 337: return 359; - case 338: return 360; - case 339: return 361; - case 340: return 362; - case 341: return 364; - case 342: return 363; - case 343: return 366; - case 344: return 365; - case 345: return 368; - case 346: return 376; - case 347: return 370; - case 348: return 367; - case 349: return 372; - case 350: return 369; - case 351: return 374;//429; matching names but not matching textures - case 352: return 375;//387; matching names but not matching textures - case 353: return 371; - case 354: return 377;//425; matching names but not matching textures - case 355: return 408; - case 356: return 378; // lava02 - case 357: return 383;//384; matching names but not matching textures - case 358: return 384;//385; matching names but not matching textures - case 359: return 385;//386; matching names but not matching textures - case 360: return 386; - case 361: return 387; - case 362: return 388; // mntr04a (devil: -1) - case 363: return 388; - case 364: return 391; - case 365: return 392; - case 366: return 393; - case 367: return 394; - case 368: return 395; - case 369: return 396; - case 370: return 392; // mntr04b (devil: -1) - // range 371 - 584 handled by default - default: - // ranges: - if (d1_tmap_num >= 58 && d1_tmap_num <= 87) - return d1_tmap_num - 24; - if (d1_tmap_num >= 89 && d1_tmap_num <= 131) - return d1_tmap_num - 25; - if (d1_tmap_num >= 267 && d1_tmap_num <= 281) - return d1_tmap_num + 10; - if (d1_tmap_num >= 287 && d1_tmap_num <= 297) - return d1_tmap_num + 13; - if (d1_tmap_num >= 299 && d1_tmap_num <= 314) - return d1_tmap_num + 12; - if (d1_tmap_num >= 316 && d1_tmap_num <= 326) - return d1_tmap_num + 11; - // wall01 and door frames: - if (d1_tmap_num > 370 && d1_tmap_num < 584) { - if (New_file_format_load) return d1_tmap_num + 64; - // d1 shareware needs special treatment: - if (d1_tmap_num < 410) return d1_tmap_num + 68; - if (d1_tmap_num < 417) return d1_tmap_num + 73; - if (d1_tmap_num < 446) return d1_tmap_num + 91; - if (d1_tmap_num < 453) return d1_tmap_num + 104; - if (d1_tmap_num < 462) return d1_tmap_num + 111; - if (d1_tmap_num < 486) return d1_tmap_num + 117; - if (d1_tmap_num < 494) return d1_tmap_num + 141; - if (d1_tmap_num < 584) return d1_tmap_num + 147; - } - { // handle rare case where orientation != 0 - short tmap_num = d1_tmap_num & TMAP_NUM_MASK; - short orient = d1_tmap_num & ~TMAP_NUM_MASK; - if (orient != 0) { - return orient | convert_d1_tmap_num(tmap_num); - } else { - Warning("can't convert unknown descent 1 texture #%d.\n", tmap_num); - return d1_tmap_num; - } - } - } +// hmm.. moved here by allender from gamesave.c -- We should really put these +// routines into the cfile library (i.e. cfile_read_int, etc....) +// This is yet another quick and dirty hack....yeech + +static fix read_fix(CFILE *file) +{ + fix f; + + if (cfread( &f, sizeof(f), 1, file) != 1) + Error( "Error reading fix in gamesave.c" ); + + f = (fix)INTEL_INT((int)f); + return f; +} + +static void read_vector(vms_vector *v,CFILE *file) +{ + v->x = read_fix(file); + v->y = read_fix(file); + v->z = read_fix(file); +} + +static short read_short(CFILE *file) +{ + short s; + + if (cfread( &s, sizeof(s), 1, file) != 1) + Error( "Error reading short in gamesave.c" ); + + s = INTEL_SHORT(s); + return s; +} + +static byte read_byte(CFILE *file) +{ + byte b; + + if (cfread( &b, sizeof(b), 1, file) != 1) + Error( "Error reading byte in gamesave.c" ); + + return b; } #ifdef EDITOR @@ -594,7 +204,7 @@ int load_mine_data(CFILE *LoadFile) for (i=0; i>5, write as short, l>>1 write as short) for (i=0; i<4; i++ ) { - temp_short = cfile_read_short(LoadFile); +// cfread( &temp_short, sizeof(short), 1, LoadFile ); + temp_short = read_short(LoadFile); Segments[segnum].sides[sidenum].uvls[i].u = ((fix)temp_short) << 5; - temp_short = cfile_read_short(LoadFile); +// cfread( &temp_short, sizeof(short), 1, LoadFile ); + temp_short = read_short(LoadFile); Segments[segnum].sides[sidenum].uvls[i].v = ((fix)temp_short) << 5; - temp_ushort = cfile_read_short(LoadFile); +// cfread( &temp_ushort, sizeof(temp_ushort), 1, LoadFile ); + temp_ushort = read_short(LoadFile); Segments[segnum].sides[sidenum].uvls[i].l = ((fix)temp_ushort) << 1; //cfread( &Segments[segnum].sides[sidenum].uvls[i].l, sizeof(fix), 1, LoadFile ); - } + } } else { Segments[segnum].sides[sidenum].tmap_num = 0; Segments[segnum].sides[sidenum].tmap_num2 = 0; @@ -1197,49 +794,55 @@ int load_mine_data_compiled(CFILE *LoadFile) Segments[segnum].sides[sidenum].uvls[i].u = 0; Segments[segnum].sides[sidenum].uvls[i].v = 0; Segments[segnum].sides[sidenum].uvls[i].l = 0; - } + } } } } -#if 0 +#if 0 { FILE *fp; - + fp = fopen("segments.out", "wt"); for (i = 0; i <= Highest_segment_index; i++) { - side sides[MAX_SIDES_PER_SEGMENT]; // 6 sides - short children[MAX_SIDES_PER_SEGMENT]; // indices of 6 children segments, front, left, top, right, bottom, back - short verts[MAX_VERTICES_PER_SEGMENT]; // vertex ids of 4 front and 4 back vertices - int objects; // pointer to objects in this segment - for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) { - byte type; // replaces num_faces and tri_edge, 1 = quad, 2 = 0:2 triangulation, 3 = 1:3 triangulation - ubyte pad; //keep us longword alligned - short wall_num; - short tmap_num; - short tmap_num2; - uvl uvls[4]; - vms_vector normals[2]; // 2 normals, if quadrilateral, both the same. - fprintf(fp, "%d\n", Segments[i].sides[j].type); - fprintf(fp, "%d\n", Segments[i].sides[j].pad); - fprintf(fp, "%d\n", Segments[i].sides[j].wall_num); - fprintf(fp, "%d\n", Segments[i].tmap_num); + side sides[MAX_SIDES_PER_SEGMENT]; // 6 sides + short children[MAX_SIDES_PER_SEGMENT]; // indices of 6 children segments, front, left, top, right, bottom, back + short verts[MAX_VERTICES_PER_SEGMENT]; // vertex ids of 4 front and 4 back vertices + int objects; // pointer to objects in this segment - } - fclose(fp); + for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) { + byte type; // replaces num_faces and tri_edge, 1 = quad, 2 = 0:2 triangulation, 3 = 1:3 triangulation + ubyte pad; //keep us longword alligned + short wall_num; + short tmap_num; + short tmap_num2; + uvl uvls[4]; + vms_vector normals[2]; // 2 normals, if quadrilateral, both the same. + fprintf(fp, "%d\n", Segments[i].sides[j].type; + fprintf(fp, "%d\n", Segments[i].sides[j].pad; + fprintf(fp, "%d\n", Segments[i].sides[j].wall_num; + fprintf(fp, "%d\n", Segments[i].tmap_num + } + fclose(fp); } -#endif +#endif Highest_vertex_index = Num_vertices-1; Highest_segment_index = Num_segments-1; validate_segment_all(); // Fill in side type and normals. +// MIKE!!!!! You should know better than this when the mac is involved!!!!!! + for (i=0; i 5) - segment2_read(&Segment2s[i], LoadFile); +// NO NO!!!! cfread( &Segment2s[i], sizeof(segment2), 1, LoadFile ); + Segment2s[i].special = read_byte(LoadFile); + Segment2s[i].matcen_num = read_byte(LoadFile); + Segment2s[i].value = read_byte(LoadFile); + Segment2s[i].s2_flags = read_byte(LoadFile); + Segment2s[i].static_light = read_fix(LoadFile); fuelcen_activate( &Segments[i], Segment2s[i].special ); } diff --git a/main/gamemine.h b/main/gamemine.h index 11a572a9..fa097f52 100644 --- a/main/gamemine.h +++ b/main/gamemine.h @@ -1,4 +1,3 @@ -/* $Id: gamemine.h,v 1.4 2003-03-19 22:44:15 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -59,12 +58,12 @@ struct mfi { int links_howmany; int links_sizeof; int object_offset; // Object info - int object_howmany; - int object_sizeof; + int object_howmany; + int object_sizeof; int unused_offset; //was: doors_offset int unused_howmamy; //was: doors_howmany int unused_sizeof; //was: doors_sizeof - short level_shake_frequency, level_shake_duration; // Shakes every level_shake_frequency seconds + short level_shake_frequency, level_shake_duration; // Shakes every level_shake_frequency seconds // for level_shake_duration seconds (on average, random). In 16ths second. int secret_return_segment; vms_matrix secret_return_orient; @@ -89,17 +88,17 @@ struct mh { }; struct me { - int current_seg; - int newsegment_offset; - int newsegment_size; - int Curside; - int Markedsegp; - int Markedside; - int Groupsegp[10]; - int Groupside[10]; - int num_groups; - int current_group; -// int num_objects; + int current_seg; + int newsegment_offset; + int newsegment_size; + int Curside; + int Markedsegp; + int Markedside; + int Groupsegp[10]; + int Groupside[10]; + int num_groups; + int current_group; +// int num_objects; }; extern struct mtfi mine_top_fileinfo; // Should be same as first two fields below... @@ -110,15 +109,8 @@ extern struct me mine_editor; // returns 1 if error, else 0 int game_load_mine(char * filename); -//loads from an already-open file -// returns 0=everything ok, 1=old version, -1=error -int load_mine_data(CFILE *LoadFile); -int load_mine_data_compiled(CFILE *LoadFile); - extern short tmap_xlate_table[]; extern fix Level_shake_frequency, Level_shake_duration; extern int Secret_return_segment; extern vms_matrix Secret_return_orient; -extern int d1_pig_loaded; // has descent.pig from descent 1 been loaded? - -#endif // _GAMEMINE_H +#endif diff --git a/main/gamepal.c b/main/gamepal.c index e27da338..88b855a4 100644 --- a/main/gamepal.c +++ b/main/gamepal.c @@ -124,7 +124,8 @@ int load_palette(char *name,int used_for_level,int no_change_screen) if (used_for_level && stricmp(last_palette_loaded_pig,name) != 0) { _splitpath(name,NULL,NULL,pigname,NULL); - strcat(pigname,".pig"); + strcat(pigname,".PIG"); + //if not editor, load pig first so small install message can come //up in old palette. If editor version, we must load the pig after //the palette is loaded so we can remap new textures. diff --git a/main/gamerend.c b/main/gamerend.c index b82dbb35..8fea3546 100644 --- a/main/gamerend.c +++ b/main/gamerend.c @@ -7,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: gamerend.c,v 1.8 2003-03-17 09:07:57 btb Exp $"; +static char rcsid[] = "$Id: gamerend.c,v 1.5 2001-10-12 00:18:38 bradleyb Exp $"; #endif #ifdef WINDOWS @@ -194,7 +194,6 @@ void show_framerate() //static int q; fix rate; - int x = 8, y = 5; // position measured from lower right corner frame_time_total += RealFrameTime - frame_time_list[frame_time_cntr]; frame_time_list[frame_time_cntr] = RealFrameTime; @@ -206,9 +205,7 @@ void show_framerate() gr_set_fontcolor(gr_getcolor(0,31,0),-1 ); ftoa( temp, rate ); // Convert fixed to string - if (Game_mode & GM_MULTI) - y = 7; - gr_printf(grd_curcanv->cv_w-(x*GAME_FONT->ft_w),grd_curcanv->cv_h-y*(GAME_FONT->ft_h+GAME_FONT->ft_h/4),"FPS: %s ", temp ); + gr_printf(grd_curcanv->cv_w-(8*GAME_FONT->ft_w),grd_curcanv->cv_h-5*(GAME_FONT->ft_h+GAME_FONT->ft_h/4),"FPS: %s ", temp ); // if ( !( q++ % 30 ) ) // mprintf( (0,"fps: %s\n", temp ) ); } @@ -280,7 +277,7 @@ void render_countdown_gauge() #if !defined(D2_OEM) && !defined(SHAREWARE) // no countdown on registered only // On last level, we don't want a countdown. - if ((Current_mission_num == Builtin_mission_num) && (Current_level_num == Last_level)) + if ((Current_mission_num == 0) && (Current_level_num == Last_level)) { if (!(Game_mode & GM_MULTI)) return; @@ -1770,20 +1767,20 @@ void update_cockpits(int force_redraw) WINDOS ( dd_gr_clear_canvas( BM_XRGB(0,0,0) ), gr_clear_canvas( BM_XRGB(0,0,0) ) ); - // In a modex mode, clear the other buffer. + // In a modex mode, clear the other buffer. if (grd_curcanv->cv_bitmap.bm_type == BM_MODEX) { gr_set_current_canvas(&VR_screen_pages[VR_current_page^1]); gr_clear_canvas( BM_XRGB(0,0,0) ); gr_set_current_canvas(&VR_screen_pages[VR_current_page]); } break; - + } WINDOS ( dd_gr_set_current_canvas(&dd_VR_screen_pages[VR_current_page]), gr_set_current_canvas(&VR_screen_pages[VR_current_page]) ); - + if (Cockpit_mode==CM_FULL_COCKPIT || Cockpit_mode==CM_STATUS_BAR) init_gauges(); diff --git a/main/gamesave.c b/main/gamesave.c index fd386921..d45eba3a 100644 --- a/main/gamesave.c +++ b/main/gamesave.c @@ -1,4 +1,3 @@ -/* $Id $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,23 +7,31 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/gamesave.c,v $ + * $Revision: 1.6 $ + * $Author: bradleyb $ + * $Date: 2001-11-14 09:34:32 $ * * Save game information * + * $Log: not supported by cvs2svn $ * */ #ifdef HAVE_CONFIG_H #include #endif +#ifdef HAVE_CONFIG_H +#include +#endif #ifdef RCS -char gamesave_rcsid[] = "$Id: gamesave.c,v 1.19 2003-04-03 07:15:43 btb Exp $"; +char gamesave_rcsid[] = "$Id: gamesave.c,v 1.6 2001-11-14 09:34:32 bradleyb Exp $"; #endif #include @@ -74,65 +81,134 @@ char gamesave_rcsid[] = "$Id: gamesave.c,v 1.19 2003-04-03 07:15:43 btb Exp $"; char Gamesave_current_filename[128]; -int Gamesave_current_version; - -#define GAME_VERSION 32 -#define GAME_COMPATIBLE_VERSION 22 +#define GAME_VERSION 32 +#define GAME_COMPATIBLE_VERSION 22 -//version 28->29 add delta light support +//version 28->29 add delta light support //version 27->28 controlcen id now is reactor number, not model number //version 28->29 ?? -//version 29->30 changed trigger structure -//version 30->31 changed trigger structure some more -//version 31->32 change segment structure, make it 512 bytes w/o editor, add Segment2s array. - -#define MENU_CURSOR_X_MIN MENU_X -#define MENU_CURSOR_X_MAX MENU_X+6 +//version 29->30 changed trigger structure +//version 30->31 changed trigger structure some more +//version 31->32 change segment structure, make it 512 bytes w/o editor, add Segment2s array. + +#define MENU_CURSOR_X_MIN MENU_X +#define MENU_CURSOR_X_MAX MENU_X+6 + +//Start old wall structures + +typedef struct v16_wall { + byte type; // What kind of special wall. + byte flags; // Flags for the wall. + fix hps; // "Hit points" of the wall. + byte trigger; // Which trigger is associated with the wall. + byte clip_num; // Which animation associated with the wall. + byte keys; + } v16_wall; + +typedef struct v19_wall { + int segnum,sidenum; // Seg & side for this wall + byte type; // What kind of special wall. + byte flags; // Flags for the wall. + fix hps; // "Hit points" of the wall. + byte trigger; // Which trigger is associated with the wall. + byte clip_num; // Which animation associated with the wall. + byte keys; + int linked_wall; // number of linked wall + } v19_wall; + +typedef struct v19_door { + int n_parts; // for linked walls + short seg[2]; // Segment pointer of door. + short side[2]; // Side number of door. + short type[2]; // What kind of door animation. + fix open; // How long it has been open. +} v19_door; + +//End old wall structures + +//old trigger structs + +typedef struct v29_trigger { + byte type; + short flags; + fix value; + fix time; + byte link_num; + short num_links; + short seg[MAX_WALLS_PER_LINK]; + short side[MAX_WALLS_PER_LINK]; + } v29_trigger; + +typedef struct v30_trigger { + short flags; + byte num_links; + byte pad; //keep alignment + fix value; + fix time; + short seg[MAX_WALLS_PER_LINK]; + short side[MAX_WALLS_PER_LINK]; + } v30_trigger; + +//flags for V30 & below triggers +#define TRIGGER_CONTROL_DOORS 1 // Control Trigger +#define TRIGGER_SHIELD_DAMAGE 2 // Shield Damage Trigger +#define TRIGGER_ENERGY_DRAIN 4 // Energy Drain Trigger +#define TRIGGER_EXIT 8 // End of level Trigger +#define TRIGGER_ON 16 // Whether Trigger is active +#define TRIGGER_ONE_SHOT 32 // If Trigger can only be triggered once +#define TRIGGER_MATCEN 64 // Trigger for materialization centers +#define TRIGGER_ILLUSION_OFF 128 // Switch Illusion OFF trigger +#define TRIGGER_SECRET_EXIT 256 // Exit to secret level +#define TRIGGER_ILLUSION_ON 512 // Switch Illusion ON trigger +#define TRIGGER_UNLOCK_DOORS 1024 // Unlocks a door +#define TRIGGER_OPEN_WALL 2048 // Makes a wall open +#define TRIGGER_CLOSE_WALL 4096 // Makes a wall closed +#define TRIGGER_ILLUSORY_WALL 8192 // Makes a wall illusory struct { - ushort fileinfo_signature; - ushort fileinfo_version; - int fileinfo_sizeof; + ushort fileinfo_signature; + ushort fileinfo_version; + int fileinfo_sizeof; } game_top_fileinfo; // Should be same as first two fields below... struct { - ushort fileinfo_signature; - ushort fileinfo_version; - int fileinfo_sizeof; - char mine_filename[15]; - int level; - int player_offset; // Player info - int player_sizeof; - int object_offset; // Object info - int object_howmany; - int object_sizeof; - int walls_offset; - int walls_howmany; - int walls_sizeof; - int doors_offset; - int doors_howmany; - int doors_sizeof; - int triggers_offset; - int triggers_howmany; - int triggers_sizeof; - int links_offset; - int links_howmany; - int links_sizeof; - int control_offset; - int control_howmany; - int control_sizeof; - int matcen_offset; - int matcen_howmany; - int matcen_sizeof; - int dl_indices_offset; - int dl_indices_howmany; - int dl_indices_sizeof; - int delta_light_offset; - int delta_light_howmany; - int delta_light_sizeof; + ushort fileinfo_signature; + ushort fileinfo_version; + int fileinfo_sizeof; + char mine_filename[15]; + int level; + int player_offset; // Player info + int player_sizeof; + int object_offset; // Object info + int object_howmany; + int object_sizeof; + int walls_offset; + int walls_howmany; + int walls_sizeof; + int doors_offset; + int doors_howmany; + int doors_sizeof; + int triggers_offset; + int triggers_howmany; + int triggers_sizeof; + int links_offset; + int links_howmany; + int links_sizeof; + int control_offset; + int control_howmany; + int control_sizeof; + int matcen_offset; + int matcen_howmany; + int matcen_sizeof; + int dl_indices_offset; + int dl_indices_howmany; + int dl_indices_sizeof; + int delta_light_offset; + int delta_light_howmany; + int delta_light_sizeof; } game_fileinfo; -// LINT: adding function prototypes +// LINT: adding function prototypes void read_object(object *obj, CFILE *f, int version); void write_object(object *obj, FILE *f); void do_load_save_levels(int save); @@ -152,11 +228,11 @@ int Gamesave_num_org_robots = 0; //--unused-- grs_bitmap * Gamesave_saved_bitmap = NULL; #ifdef EDITOR -// Return true if this level has a name of the form "level??" -// Note that a pathspec can appear at the beginning of the filename. +// Return true if this level has a name of the form "level??" +// Note that a pathspec can appear at the beginning of the filename. int is_real_level(char *filename) { - int len = strlen(filename); + int len = strlen(filename); if (len < 6) return 0; @@ -212,7 +288,7 @@ void verify_object( object * obj ) { if ( obj->id >= N_robot_types ) obj->id = obj->id % N_robot_types; - // Make sure model number & size are correct... + // Make sure model number & size are correct... if ( obj->render_type == RT_POLYOBJ ) { Assert(Robot_info[obj->id].model_num != -1); //if you fail this assert, it means that a robot in this level @@ -221,8 +297,8 @@ void verify_object( object * obj ) { Assert(Robot_info[obj->id].always_0xabcd == 0xabcd); //if you fail this assert, it means that the robot_ai for - //a robot in this level hasn't been loaded, possibly because - //it's marked as non-shareware. To see what robot number, + //a robot in this level hasn't been loaded, possibly because + //it's marked as non-shareware. To see what robot number, //print obj->id. obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num; @@ -312,21 +388,17 @@ void verify_object( object * obj ) { } } - if ( obj->type == OBJ_CNTRLCEN ) { + if ( obj->type == OBJ_CNTRLCEN ) { obj->render_type = RT_POLYOBJ; obj->control_type = CT_CNTRLCEN; - if (Gamesave_current_version <= 1) { // descent 1 reactor - obj->id = 0; // used to be only one kind of reactor - obj->rtype.pobj_info.model_num = Reactors[0].model_num;// descent 1 reactor - } - //@@// Make model number is correct... - //@@for (i=0; irtype.pobj_info.model_num = ObjId[i]; //@@ obj->shields = ObjStrength[i]; - //@@ break; + //@@ break; //@@ } #ifdef EDITOR @@ -371,6 +443,81 @@ void verify_object( object * obj ) { } +static int read_int(CFILE *file) +{ + int i; + + if (cfread( &i, sizeof(i), 1, file) != 1) + Error( "Error reading int in gamesave.c" ); + + i = INTEL_INT(i); + return i; +} + +static fix read_fix(CFILE *file) +{ + fix f; + + if (cfread( &f, sizeof(f), 1, file) != 1) + Error( "Error reading fix in gamesave.c" ); + + f = (fix)INTEL_INT((int)f); + return f; +} + +static short read_short(CFILE *file) +{ + short s; + + if (cfread( &s, sizeof(s), 1, file) != 1) + Error( "Error reading short in gamesave.c" ); + + s = INTEL_SHORT(s); + return s; +} + +static short read_fixang(CFILE *file) +{ + fixang f; + + if (cfread( &f, sizeof(f), 1, file) != 1) + Error( "Error reading fixang in gamesave.c" ); + + f = (fixang)INTEL_SHORT((short)f); + return f; +} + +static byte read_byte(CFILE *file) +{ + byte b; + + if (cfread( &b, sizeof(b), 1, file) != 1) + Error( "Error reading byte in gamesave.c" ); + + return b; +} + +static void read_vector(vms_vector *v,CFILE *file) +{ + v->x = read_fix(file); + v->y = read_fix(file); + v->z = read_fix(file); +} + +static void read_matrix(vms_matrix *m,CFILE *file) +{ + read_vector(&m->rvec,file); + read_vector(&m->uvec,file); + read_vector(&m->fvec,file); +} + +static void read_angvec(vms_angvec *v,CFILE *file) +{ + v->p = read_fixang(file); + v->b = read_fixang(file); + v->h = read_fixang(file); +} + //static gs_skip(int len,CFILE *file) //{ // @@ -441,52 +588,55 @@ extern int multi_powerup_is_4pack(int); //reads one object of the given version from the given file void read_object(object *obj,CFILE *f,int version) { + + obj->type = read_byte(f); + obj->id = read_byte(f); - obj->type = cfile_read_byte(f); - obj->id = cfile_read_byte(f); + if (obj->type == OBJ_CNTRLCEN && version<28) + obj->id = 0; //used to be only one kind of reactor - obj->control_type = cfile_read_byte(f); - obj->movement_type = cfile_read_byte(f); - obj->render_type = cfile_read_byte(f); - obj->flags = cfile_read_byte(f); + obj->control_type = read_byte(f); + obj->movement_type = read_byte(f); + obj->render_type = read_byte(f); + obj->flags = read_byte(f); - obj->segnum = cfile_read_short(f); - obj->attached_obj = -1; + obj->segnum = read_short(f); + obj->attached_obj = -1; - cfile_read_vector(&obj->pos,f); - cfile_read_matrix(&obj->orient,f); + read_vector(&obj->pos,f); + read_matrix(&obj->orient,f); - obj->size = cfile_read_fix(f); - obj->shields = cfile_read_fix(f); + obj->size = read_fix(f); + obj->shields = read_fix(f); - cfile_read_vector(&obj->last_pos,f); + read_vector(&obj->last_pos,f); - obj->contains_type = cfile_read_byte(f); - obj->contains_id = cfile_read_byte(f); - obj->contains_count = cfile_read_byte(f); + obj->contains_type = read_byte(f); + obj->contains_id = read_byte(f); + obj->contains_count = read_byte(f); switch (obj->movement_type) { case MT_PHYSICS: - cfile_read_vector(&obj->mtype.phys_info.velocity,f); - cfile_read_vector(&obj->mtype.phys_info.thrust,f); + read_vector(&obj->mtype.phys_info.velocity,f); + read_vector(&obj->mtype.phys_info.thrust,f); - obj->mtype.phys_info.mass = cfile_read_fix(f); - obj->mtype.phys_info.drag = cfile_read_fix(f); - obj->mtype.phys_info.brakes = cfile_read_fix(f); + obj->mtype.phys_info.mass = read_fix(f); + obj->mtype.phys_info.drag = read_fix(f); + obj->mtype.phys_info.brakes = read_fix(f); - cfile_read_vector(&obj->mtype.phys_info.rotvel,f); - cfile_read_vector(&obj->mtype.phys_info.rotthrust,f); + read_vector(&obj->mtype.phys_info.rotvel,f); + read_vector(&obj->mtype.phys_info.rotthrust,f); - obj->mtype.phys_info.turnroll = cfile_read_fixang(f); - obj->mtype.phys_info.flags = cfile_read_short(f); + obj->mtype.phys_info.turnroll = read_fixang(f); + obj->mtype.phys_info.flags = read_short(f); break; case MT_SPINNING: - cfile_read_vector(&obj->mtype.spin_rate,f); + read_vector(&obj->mtype.spin_rate,f); break; case MT_NONE: @@ -501,19 +651,19 @@ void read_object(object *obj,CFILE *f,int version) case CT_AI: { int i; - obj->ctype.ai_info.behavior = cfile_read_byte(f); + obj->ctype.ai_info.behavior = read_byte(f); for (i=0;ictype.ai_info.flags[i] = cfile_read_byte(f); + obj->ctype.ai_info.flags[i] = read_byte(f); - obj->ctype.ai_info.hide_segment = cfile_read_short(f); - obj->ctype.ai_info.hide_index = cfile_read_short(f); - obj->ctype.ai_info.path_length = cfile_read_short(f); - obj->ctype.ai_info.cur_path_index = cfile_read_short(f); + obj->ctype.ai_info.hide_segment = read_short(f); + obj->ctype.ai_info.hide_index = read_short(f); + obj->ctype.ai_info.path_length = read_short(f); + obj->ctype.ai_info.cur_path_index = read_short(f); if (version <= 25) { - cfile_read_short(f); // obj->ctype.ai_info.follow_path_start_seg = - cfile_read_short(f); // obj->ctype.ai_info.follow_path_end_seg = + read_short(f); // obj->ctype.ai_info.follow_path_start_seg = + read_short(f); // obj->ctype.ai_info.follow_path_end_seg = } break; @@ -521,9 +671,9 @@ void read_object(object *obj,CFILE *f,int version) case CT_EXPLOSION: - obj->ctype.expl_info.spawn_time = cfile_read_fix(f); - obj->ctype.expl_info.delete_time = cfile_read_fix(f); - obj->ctype.expl_info.delete_objnum = cfile_read_short(f); + obj->ctype.expl_info.spawn_time = read_fix(f); + obj->ctype.expl_info.delete_time = read_fix(f); + obj->ctype.expl_info.delete_objnum = read_short(f); obj->ctype.expl_info.next_attach = obj->ctype.expl_info.prev_attach = obj->ctype.expl_info.attach_parent = -1; break; @@ -532,21 +682,21 @@ void read_object(object *obj,CFILE *f,int version) //do I really need to read these? Are they even saved to disk? - obj->ctype.laser_info.parent_type = cfile_read_short(f); - obj->ctype.laser_info.parent_num = cfile_read_short(f); - obj->ctype.laser_info.parent_signature = cfile_read_int(f); + obj->ctype.laser_info.parent_type = read_short(f); + obj->ctype.laser_info.parent_num = read_short(f); + obj->ctype.laser_info.parent_signature = read_int(f); break; case CT_LIGHT: - obj->ctype.light_info.intensity = cfile_read_fix(f); + obj->ctype.light_info.intensity = read_fix(f); break; case CT_POWERUP: if (version >= 25) - obj->ctype.powerup_info.count = cfile_read_int(f); + obj->ctype.powerup_info.count = read_int(f); else obj->ctype.powerup_info.count = 1; @@ -590,14 +740,14 @@ void read_object(object *obj,CFILE *f,int version) case RT_POLYOBJ: { int i,tmo; - obj->rtype.pobj_info.model_num = cfile_read_int(f); + obj->rtype.pobj_info.model_num = read_int(f); for (i=0;irtype.pobj_info.anim_angles[i],f); + read_angvec(&obj->rtype.pobj_info.anim_angles[i],f); - obj->rtype.pobj_info.subobj_flags = cfile_read_int(f); + obj->rtype.pobj_info.subobj_flags = read_int(f); - tmo = cfile_read_int(f); + tmo = read_int(f); #ifndef EDITOR obj->rtype.pobj_info.tmap_override = tmo; @@ -625,9 +775,9 @@ void read_object(object *obj,CFILE *f,int version) case RT_POWERUP: case RT_FIREBALL: - obj->rtype.vclip_info.vclip_num = cfile_read_int(f); - obj->rtype.vclip_info.frametime = cfile_read_fix(f); - obj->rtype.vclip_info.framenum = cfile_read_byte(f); + obj->rtype.vclip_info.vclip_num = read_int(f); + obj->rtype.vclip_info.frametime = read_fix(f); + obj->rtype.vclip_info.framenum = read_byte(f); break; @@ -810,6 +960,14 @@ void write_object(object *obj,FILE *f) } #endif +typedef struct { + int robot_flags; // Up to 32 different robots + fix hit_points; // How hard it is to destroy this particular matcen + fix interval; // Interval between materialogrifizations + short segnum; // Segment this is attached to. + short fuelcen_num; // Index in fuelcen array. +} old_matcen_info; + extern int remove_trigger_num(int trigger_num); // ----------------------------------------------------------------------------- @@ -866,9 +1024,9 @@ int load_game_data(CFILE *LoadFile) // if (cfread( &game_top_fileinfo, sizeof(game_top_fileinfo), 1, LoadFile) != 1) // Error( "Error reading game_top_fileinfo in gamesave.c" ); - game_top_fileinfo.fileinfo_signature = cfile_read_short(LoadFile); - game_top_fileinfo.fileinfo_version = cfile_read_short(LoadFile); - game_top_fileinfo.fileinfo_sizeof = cfile_read_int(LoadFile); + game_top_fileinfo.fileinfo_signature = read_short(LoadFile); + game_top_fileinfo.fileinfo_version = read_short(LoadFile); + game_top_fileinfo.fileinfo_sizeof = read_int(LoadFile); // Check signature if (game_top_fileinfo.fileinfo_signature != 0x6705) @@ -885,68 +1043,63 @@ int load_game_data(CFILE *LoadFile) // if (cfread( &game_fileinfo, game_top_fileinfo.fileinfo_sizeof, 1, LoadFile )!=1) // Error( "Error reading game_fileinfo in gamesave.c" ); - game_fileinfo.fileinfo_signature = cfile_read_short(LoadFile); - game_fileinfo.fileinfo_version = cfile_read_short(LoadFile); - game_fileinfo.fileinfo_sizeof = cfile_read_int(LoadFile); + game_fileinfo.fileinfo_signature = read_short(LoadFile); + game_fileinfo.fileinfo_version = read_short(LoadFile); + game_fileinfo.fileinfo_sizeof = read_int(LoadFile); for(i=0; i<15; i++) - game_fileinfo.mine_filename[i] = cfile_read_byte(LoadFile); - game_fileinfo.level = cfile_read_int(LoadFile); - game_fileinfo.player_offset = cfile_read_int(LoadFile); // Player info - game_fileinfo.player_sizeof = cfile_read_int(LoadFile); - game_fileinfo.object_offset = cfile_read_int(LoadFile); // Object info - game_fileinfo.object_howmany = cfile_read_int(LoadFile); - game_fileinfo.object_sizeof = cfile_read_int(LoadFile); - game_fileinfo.walls_offset = cfile_read_int(LoadFile); - game_fileinfo.walls_howmany = cfile_read_int(LoadFile); - game_fileinfo.walls_sizeof = cfile_read_int(LoadFile); - game_fileinfo.doors_offset = cfile_read_int(LoadFile); - game_fileinfo.doors_howmany = cfile_read_int(LoadFile); - game_fileinfo.doors_sizeof = cfile_read_int(LoadFile); - game_fileinfo.triggers_offset = cfile_read_int(LoadFile); - game_fileinfo.triggers_howmany = cfile_read_int(LoadFile); - game_fileinfo.triggers_sizeof = cfile_read_int(LoadFile); - game_fileinfo.links_offset = cfile_read_int(LoadFile); - game_fileinfo.links_howmany = cfile_read_int(LoadFile); - game_fileinfo.links_sizeof = cfile_read_int(LoadFile); - game_fileinfo.control_offset = cfile_read_int(LoadFile); - game_fileinfo.control_howmany = cfile_read_int(LoadFile); - game_fileinfo.control_sizeof = cfile_read_int(LoadFile); - game_fileinfo.matcen_offset = cfile_read_int(LoadFile); - game_fileinfo.matcen_howmany = cfile_read_int(LoadFile); - game_fileinfo.matcen_sizeof = cfile_read_int(LoadFile); + game_fileinfo.mine_filename[i] = read_byte(LoadFile); + game_fileinfo.level = read_int(LoadFile); + game_fileinfo.player_offset = read_int(LoadFile); // Player info + game_fileinfo.player_sizeof = read_int(LoadFile); + game_fileinfo.object_offset = read_int(LoadFile); // Object info + game_fileinfo.object_howmany = read_int(LoadFile); + game_fileinfo.object_sizeof = read_int(LoadFile); + game_fileinfo.walls_offset = read_int(LoadFile); + game_fileinfo.walls_howmany = read_int(LoadFile); + game_fileinfo.walls_sizeof = read_int(LoadFile); + game_fileinfo.doors_offset = read_int(LoadFile); + game_fileinfo.doors_howmany = read_int(LoadFile); + game_fileinfo.doors_sizeof = read_int(LoadFile); + game_fileinfo.triggers_offset = read_int(LoadFile); + game_fileinfo.triggers_howmany = read_int(LoadFile); + game_fileinfo.triggers_sizeof = read_int(LoadFile); + game_fileinfo.links_offset = read_int(LoadFile); + game_fileinfo.links_howmany = read_int(LoadFile); + game_fileinfo.links_sizeof = read_int(LoadFile); + game_fileinfo.control_offset = read_int(LoadFile); + game_fileinfo.control_howmany = read_int(LoadFile); + game_fileinfo.control_sizeof = read_int(LoadFile); + game_fileinfo.matcen_offset = read_int(LoadFile); + game_fileinfo.matcen_howmany = read_int(LoadFile); + game_fileinfo.matcen_sizeof = read_int(LoadFile); if (game_top_fileinfo.fileinfo_version >= 29) { - game_fileinfo.dl_indices_offset = cfile_read_int(LoadFile); - game_fileinfo.dl_indices_howmany = cfile_read_int(LoadFile); - game_fileinfo.dl_indices_sizeof = cfile_read_int(LoadFile); + game_fileinfo.dl_indices_offset = read_int(LoadFile); + game_fileinfo.dl_indices_howmany = read_int(LoadFile); + game_fileinfo.dl_indices_sizeof = read_int(LoadFile); - game_fileinfo.delta_light_offset = cfile_read_int(LoadFile); - game_fileinfo.delta_light_howmany = cfile_read_int(LoadFile); - game_fileinfo.delta_light_sizeof = cfile_read_int(LoadFile); + game_fileinfo.delta_light_offset = read_int(LoadFile); + game_fileinfo.delta_light_howmany = read_int(LoadFile); + game_fileinfo.delta_light_sizeof = read_int(LoadFile); } - if (game_top_fileinfo.fileinfo_version >= 31) { //load mine filename - // read newline-terminated string, not sure what version this changed. + if (game_top_fileinfo.fileinfo_version >= 14) { //load mine filename + //@@char *p=Current_level_name; + //@@//must do read one char at a time, since no cfgets() + //@@do *p = cfgetc(LoadFile); while (*p++!=0); + cfgets(Current_level_name,sizeof(Current_level_name),LoadFile); if (Current_level_name[strlen(Current_level_name)-1] == '\n') Current_level_name[strlen(Current_level_name)-1] = 0; } - else if (game_top_fileinfo.fileinfo_version >= 14) { //load mine filename - // read null-terminated string - char *p=Current_level_name; - //must do read one char at a time, since no cfgets() - do *p = cfgetc(LoadFile); while (*p++!=0); - } else Current_level_name[0]=0; if (game_top_fileinfo.fileinfo_version >= 19) { //load pof names - N_save_pof_names = cfile_read_short(LoadFile); - if (N_save_pof_names != 0x614d && N_save_pof_names != 0x5547) { // "Ma"de w/DMB beta/"GU"ILE - Assert(N_save_pof_names < MAX_POLYGON_MODELS); - cfread(Save_pof_names,N_save_pof_names,FILENAME_LEN,LoadFile); - } +// cfread(&N_save_pof_names,2,1,LoadFile); + N_save_pof_names = read_short(LoadFile); + cfread(Save_pof_names,N_save_pof_names,FILENAME_LEN,LoadFile); } //===================== READ PLAYER INFO ========================== @@ -958,12 +1111,12 @@ int load_game_data(CFILE *LoadFile) Gamesave_num_players = 0; if (game_fileinfo.object_offset > -1) { - if (cfseek( LoadFile, game_fileinfo.object_offset, SEEK_SET )) + if (cfseek( LoadFile, game_fileinfo.object_offset, SEEK_SET )) Error( "Error seeking to object_offset in gamesave.c" ); + + for (i=0;i= 20) - wall_read(&Walls[i], LoadFile); // v20 walls and up. + if (game_top_fileinfo.fileinfo_version >= 20) { + + Assert(sizeof(Walls[i]) == game_fileinfo.walls_sizeof); + +// code to correctly read wall structure on mac. I'm assuming only v20 walls +// and up. +#ifndef MACINTOSH + if (cfread(&Walls[i], game_fileinfo.walls_sizeof, 1,LoadFile)!=1) + Error( "Error reading Walls[%d] in gamesave.c", i); +#else + Walls[i].segnum = read_int(LoadFile); + Walls[i].sidenum = read_int(LoadFile); + Walls[i].hps = read_fix(LoadFile); + Walls[i].linked_wall = read_int(LoadFile); + Walls[i].type = read_byte(LoadFile); + Walls[i].flags = read_byte(LoadFile); + Walls[i].state = read_byte(LoadFile); + Walls[i].trigger = read_byte(LoadFile); + Walls[i].clip_num = read_byte(LoadFile); + Walls[i].keys = read_byte(LoadFile); + Walls[i].controlling_trigger = read_byte(LoadFile); + Walls[i].cloak_value = read_byte(LoadFile); +#endif + } else if (game_top_fileinfo.fileinfo_version >= 17) { v19_wall w; - v19_wall_read(&w, LoadFile); + Assert(sizeof(w) == game_fileinfo.walls_sizeof); - Walls[i].segnum = w.segnum; + if (cfread(&w, game_fileinfo.walls_sizeof, 1,LoadFile)!=1) + Error( "Error reading Walls[%d] in gamesave.c", i); + + Walls[i].segnum = w.segnum; Walls[i].sidenum = w.sidenum; Walls[i].linked_wall = w.linked_wall; @@ -998,10 +1176,14 @@ int load_game_data(CFILE *LoadFile) Walls[i].keys = w.keys; Walls[i].state = WALL_DOOR_CLOSED; - } else { + } + else { v16_wall w; - v16_wall_read(&w, LoadFile); + Assert(sizeof(w) == game_fileinfo.walls_sizeof); + + if (cfread(&w, game_fileinfo.walls_sizeof, 1,LoadFile)!=1) + Error( "Error reading Walls[%d] in gamesave.c", i); Walls[i].segnum = Walls[i].sidenum = Walls[i].linked_wall = -1; @@ -1025,13 +1207,31 @@ int load_game_data(CFILE *LoadFile) for (i=0;i= 20) - active_door_read(&ActiveDoors[i], LoadFile); // version 20 and up + if (game_top_fileinfo.fileinfo_version >= 20) { + + Assert(sizeof(ActiveDoors[i]) == game_fileinfo.doors_sizeof); + +// code to read doors for mac -- assume version 20 and greater for doors +#ifndef MACINTOSH + if (cfread(&ActiveDoors[i], game_fileinfo.doors_sizeof,1,LoadFile)!=1) + Error( "Error reading ActiveDoors[%d] in gamesave.c", i); +#else + ActiveDoors[i].n_parts = read_int(LoadFile); + ActiveDoors[i].front_wallnum[0] = read_short(LoadFile); + ActiveDoors[i].front_wallnum[1] = read_short(LoadFile); + ActiveDoors[i].back_wallnum[0] = read_short(LoadFile); + ActiveDoors[i].back_wallnum[1] = read_short(LoadFile); + ActiveDoors[i].time = read_fix(LoadFile); +#endif + } else { v19_door d; int p; - v19_door_read(&d, LoadFile); + Assert(sizeof(d) == game_fileinfo.doors_sizeof); + + if (cfread(&d, game_fileinfo.doors_sizeof, 1,LoadFile)!=1) + Error( "Error reading Doors[%d] in gamesave.c", i); ActiveDoors[i].n_parts = d.n_parts; @@ -1068,22 +1268,24 @@ int load_game_data(CFILE *LoadFile) if (game_top_fileinfo.fileinfo_version < 30) { v29_trigger trig29; int t; - - v29_trigger_read(&trig29, LoadFile); - + + if (cfread(&trig29, game_fileinfo.triggers_sizeof,1,LoadFile)!=1) + Error( "Error reading Triggers[%d] in gamesave.c", i); + trig.flags = trig29.flags; trig.num_links = trig29.num_links; trig.num_links = trig29.num_links; trig.value = trig29.value; trig.time = trig29.time; - + for (t=0;t -1) - if (!cfseek(LoadFile, game_fileinfo.control_offset, SEEK_SET)) - { - Assert(game_fileinfo.control_sizeof == sizeof(control_center_triggers)); - control_center_triggers_read_n(&ControlCenterTriggers, game_fileinfo.control_howmany, LoadFile); + { + if (!cfseek( LoadFile, game_fileinfo.control_offset,SEEK_SET )) { + for (i=0;i 2 add palette name //2 -> 3 add control center explosion time //3 -> 4 add reactor strength //4 -> 5 killed hostage text stuff //5 -> 6 added Secret_return_segment and Secret_return_orient -//6 -> 7 added flickering lights +//6 -> 7 added flickering lights //7 -> 8 made version 8 to be not compatible with D2 1.0 & 1.1 #ifndef RELEASE @@ -1384,7 +1651,9 @@ char *Level_being_loaded=NULL; extern void ncache_flush(); #endif -extern int Slide_segs_computed; +extern int HoardEquipped(); + +extern int Slide_segs_computed; int no_old_level_file_error=0; @@ -1392,13 +1661,13 @@ int no_old_level_file_error=0; //returns 0 if success, else error code int load_level(char * filename_passed) { -#ifdef EDITOR + #ifdef EDITOR int use_compiled_level=1; -#endif + #endif CFILE * LoadFile; char filename[128]; - int sig, minedata_offset, gamedata_offset; - int mine_err, game_err; + int sig,version,minedata_offset,gamedata_offset; + int mine_err,game_err; #ifdef NETWORK int i; #endif @@ -1425,17 +1694,18 @@ int load_level(char * filename_passed) #endif strcpy(filename,filename_passed); + strupr(filename); #ifdef EDITOR //if we have the editor, try the LVL first, no matter what was passed. //if we don't have an LVL, try RDL //if we don't have the editor, we just use what was passed - change_filename_extension(filename,filename_passed,".lvl"); + change_filename_extension(filename,filename_passed,".LVL"); use_compiled_level = 0; if (!cfexist(filename)) { - change_filename_extension(filename,filename,".rl2"); + change_filename_extension(filename,filename,".RL2"); use_compiled_level = 1; } #endif @@ -1458,82 +1728,93 @@ int load_level(char * filename_passed) // newdemo_record_start_demo(); // #endif - sig = cfile_read_int(LoadFile); - Gamesave_current_version = cfile_read_int(LoadFile); - mprintf((0, "Gamesave_current_version = %d\n", Gamesave_current_version)); - minedata_offset = cfile_read_int(LoadFile); - gamedata_offset = cfile_read_int(LoadFile); + sig = read_int(LoadFile); + version = read_int(LoadFile); + minedata_offset = read_int(LoadFile); + gamedata_offset = read_int(LoadFile); Assert(sig == MAKE_SIG('P','L','V','L')); - if (Gamesave_current_version >= 8) { //read dummy data - cfile_read_int(LoadFile); - cfile_read_short(LoadFile); - cfile_read_byte(LoadFile); + if (version >= 8) { //read dummy data +#ifdef NETWORK + if (HoardEquipped()) + { + read_int(LoadFile); + read_short(LoadFile); + read_byte(LoadFile); + } + else +#endif + // NOTE LINK TO ABOVE! + Error("This level requires the Vertigo Enhanced version of D2."); + } - if (Gamesave_current_version < 5) - cfile_read_int(LoadFile); //was hostagetext_offset + if (version < 5) + read_int(LoadFile); //was hostagetext_offset - if (Gamesave_current_version > 1) { + if (version > 1) { cfgets(Current_level_palette,sizeof(Current_level_palette),LoadFile); if (Current_level_palette[strlen(Current_level_palette)-1] == '\n') Current_level_palette[strlen(Current_level_palette)-1] = 0; } - if (Gamesave_current_version <= 1 || Current_level_palette[0]==0) // descent 1 level - strcpy(Current_level_palette, DEFAULT_LEVEL_PALETTE); - if (Gamesave_current_version >= 3) - Base_control_center_explosion_time = cfile_read_int(LoadFile); + if (version >= 3) + Base_control_center_explosion_time = read_int(LoadFile); else Base_control_center_explosion_time = DEFAULT_CONTROL_CENTER_EXPLOSION_TIME; - - if (Gamesave_current_version >= 4) - Reactor_strength = cfile_read_int(LoadFile); + + if (version >= 4) + Reactor_strength = read_int(LoadFile); else - Reactor_strength = -1; //use old defaults + Reactor_strength = -1; //use old defaults - if (Gamesave_current_version >= 7) { - int i; - - Num_flickering_lights = cfile_read_int(LoadFile); - Assert((Num_flickering_lights >= 0) && (Num_flickering_lights < MAX_FLICKERING_LIGHTS)); - for (i = 0; i < Num_flickering_lights; i++) - flickering_light_read(&Flickering_lights[i], LoadFile); + if (version >= 7) { + Num_flickering_lights = read_int(LoadFile); + #ifdef MACINTOSH + Assert((Num_flickering_lights >= 0) && (Num_flickering_lights < MAX_FLICKERING_LIGHTS)); + for (i = 0; i < Num_flickering_lights; i++) + { + Flickering_lights[i].segnum = read_short(LoadFile); + Flickering_lights[i].sidenum = read_short(LoadFile); + Flickering_lights[i].mask = read_int(LoadFile); + Flickering_lights[i].timer = read_fix(LoadFile); + Flickering_lights[i].delay = read_fix(LoadFile); + } + #else + cfread(Flickering_lights,sizeof(*Flickering_lights),Num_flickering_lights,LoadFile); + #endif } else Num_flickering_lights = 0; - if (Gamesave_current_version < 6) { + if (version <= 1 || Current_level_palette[0]==0) + strcpy(Current_level_palette,"groupa.256"); + + if (version < 6) { Secret_return_segment = 0; - Secret_return_orient.rvec.x = F1_0; - Secret_return_orient.rvec.y = 0; - Secret_return_orient.rvec.z = 0; - Secret_return_orient.fvec.x = 0; - Secret_return_orient.fvec.y = F1_0; - Secret_return_orient.fvec.z = 0; - Secret_return_orient.uvec.x = 0; - Secret_return_orient.uvec.y = 0; - Secret_return_orient.uvec.z = F1_0; + Secret_return_orient.rvec.x = F1_0; Secret_return_orient.rvec.y = 0; Secret_return_orient.rvec.z = 0; + Secret_return_orient.fvec.x = 0; Secret_return_orient.fvec.y = F1_0; Secret_return_orient.fvec.z = 0; + Secret_return_orient.uvec.x = 0; Secret_return_orient.uvec.y = 0; Secret_return_orient.uvec.z = F1_0; } else { - Secret_return_segment = cfile_read_int(LoadFile); - Secret_return_orient.rvec.x = cfile_read_int(LoadFile); - Secret_return_orient.rvec.y = cfile_read_int(LoadFile); - Secret_return_orient.rvec.z = cfile_read_int(LoadFile); - Secret_return_orient.fvec.x = cfile_read_int(LoadFile); - Secret_return_orient.fvec.y = cfile_read_int(LoadFile); - Secret_return_orient.fvec.z = cfile_read_int(LoadFile); - Secret_return_orient.uvec.x = cfile_read_int(LoadFile); - Secret_return_orient.uvec.y = cfile_read_int(LoadFile); - Secret_return_orient.uvec.z = cfile_read_int(LoadFile); + Secret_return_segment = read_int(LoadFile); + Secret_return_orient.rvec.x = read_int(LoadFile); + Secret_return_orient.rvec.y = read_int(LoadFile); + Secret_return_orient.rvec.z = read_int(LoadFile); + Secret_return_orient.fvec.x = read_int(LoadFile); + Secret_return_orient.fvec.y = read_int(LoadFile); + Secret_return_orient.fvec.z = read_int(LoadFile); + Secret_return_orient.uvec.x = read_int(LoadFile); + Secret_return_orient.uvec.y = read_int(LoadFile); + Secret_return_orient.uvec.z = read_int(LoadFile); } cfseek(LoadFile,minedata_offset,SEEK_SET); #ifdef EDITOR if (!use_compiled_level) { mine_err = load_mine_data(LoadFile); -#if 0 // get from d1src if needed - // Compress all uv coordinates in mine, improves texmap precision. --MK, 02/19/96 +#if 0 //dunno - 3rd party stuff? + // Compress all uv coordinates in mine, improves texmap precision. --MK, 02/19/96 compress_uv_coordinates_all(); #endif } else @@ -1541,7 +1822,7 @@ int load_level(char * filename_passed) //NOTE LINK TO ABOVE!! mine_err = load_mine_data_compiled(LoadFile); - if (mine_err == -1) { //error!! + if (mine_err == -1) { //error!! cfclose(LoadFile); return 2; } @@ -1549,7 +1830,7 @@ int load_level(char * filename_passed) cfseek(LoadFile,gamedata_offset,SEEK_SET); game_err = load_game_data(LoadFile); - if (game_err == -1) { //error!! + if (game_err == -1) { //error!! cfclose(LoadFile); return 3; } @@ -1578,10 +1859,10 @@ int load_level(char * filename_passed) #ifdef EDITOR //If an old version, ask the use if he wants to save as new version - if (!no_old_level_file_error && (Function_mode == FMODE_EDITOR) && (((LEVEL_FILE_VERSION > 3) && Gamesave_current_version < LEVEL_FILE_VERSION) || mine_err == 1 || game_err == 1)) { + if (!no_old_level_file_error && (Function_mode == FMODE_EDITOR) && (((LEVEL_FILE_VERSION>3) && versioncv_bitmap.bm_type == BM_MODEX) { - WIN(Int3()); // No no no no .... + WIN(Int3()); // No no no no .... ycrd -= h; h *= 2; modex_hud_message((grd_curcanv->cv_bitmap.bm_w-w)/2, ycrd, message, SMALL_FONT, HUD_color); @@ -318,7 +312,7 @@ void HUD_render_message_frame() } WIN(DDGRUNLOCK(dd_grd_curcanv)); } - } + } #ifndef WINDOWS else if (get_current_game_screen()->cv_bitmap.bm_type == BM_MODEX) { if (Modex_hud_msg_count) { @@ -330,16 +324,16 @@ void HUD_render_message_frame() } #endif - gr_set_curfont( GAME_FONT ); + gr_set_curfont( GAME_FONT ); } int PlayerMessage=1; - // Call to flash a message on the HUD. Returns true if message drawn. // (message might not be drawn if previous message was same) -int HUD_init_message_va(char * format, va_list args) +int HUD_init_message(char * format, ... ) { + va_list args; int temp, temp2; char *message = NULL; char *last_message=NULL; @@ -351,9 +345,11 @@ int HUD_init_message_va(char * format, va_list args) Int3(); // Get Rob!! // -- mprintf((0, "message timer: %7.3f\n", f2fl(HUD_message_timer))); + va_start(args, format ); message = &HUD_messages[hud_last][0]; vsprintf(message,format,args); - + va_end(args); + /* Produce a sanitised version and send it to the console */ cleanmessage = d_strdup(message); for (temp=0,temp2=0; message[temp]!=0; temp++) @@ -409,19 +405,6 @@ int HUD_init_message_va(char * format, va_list args) } -int HUD_init_message(char * format, ... ) -{ - int ret; - va_list args; - - va_start(args, format); - ret = HUD_init_message_va(format, args); - va_end(args); - - return ret; -} - - //@@void player_dead_message(void) //@@{ //@@ if (!Arcade_mode && Player_exploded) { //(ConsoleObject->flags & OF_EXPLODING)) { @@ -483,13 +466,12 @@ void player_dead_message(void) void hud_message(int class, char *format, ...) { - va_list vp; - - va_start(vp, format); - if ((!MSG_Noredundancy || (class & MSGC_NOREDUNDANCY)) && - (!MSG_Playermessages || !(Game_mode & GM_MULTI) || - (class & MSGC_PLAYERMESSAGES))) - HUD_init_message_va(format, vp); - va_end(vp); + va_list vp; + va_start(vp, format); + if ((!MSG_Noredundancy || (class & MSGC_NOREDUNDANCY)) && + (!MSG_Playermessages || !(Game_mode & GM_MULTI) || + (class & MSGC_PLAYERMESSAGES))) + HUD_init_message(format, vp); + va_end(vp); } diff --git a/main/inferno.c b/main/inferno.c index 30744a99..3d43c4ca 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -1,4 +1,3 @@ -/* $Id: inferno.c,v 1.62 2003-05-12 22:46:01 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,702 +7,67 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/inferno.c,v $ + * $Revision: 1.23 $ + * $Author: bradleyb $ + * $Date: 2002-02-02 23:30:26 $ * - * inferno.c: Entry point of program (main procedure) + * FIXME: put description here * - * After main initializes everything, most of the time is spent in the loop - * while (Function_mode != FMODE_EXIT) - * In this loop, the main menu is brought up first. + * $Log: not supported by cvs2svn $ + * Revision 1.22 2002/01/29 10:11:56 bradleyb + * update copyright date * - * main() for Inferno + * Revision 1.21 2002/01/29 00:08:13 bradleyb + * Added d_mkdir macro * - * Old Log: - * Revision 1.1 1995/12/05 15:57:49 allender - * Initial revision + * Revision 1.20 2002/01/28 00:03:47 bradleyb + * Data files now go in DATADIR/games/d2x, user files now go in ~/.d2x * - * Revision 1.19 1995/11/07 17:03:12 allender - * added splash screen for descent contest + * Revision 1.19 2002/01/18 07:01:37 bradleyb + * allow -h for help * - * Revision 1.18 1995/10/31 10:22:22 allender - * shareware stuff + * Revision 1.18 2001/12/28 09:26:41 bradleyb + * document -nomovies option * - * Revision 1.17 1995/10/18 01:53:07 allender - * mouse click to leave do not distribute screen + * Revision 1.17 2001/11/09 06:55:08 bradleyb + * added documentation * - * Revision 1.16 1995/10/17 12:00:12 allender - * mouse click gets past endgame screen + * Revision 1.16 2001/11/08 10:30:28 bradleyb + * Enabled shareware build, endlevel flythrough sequence * - * Revision 1.15 1995/10/12 17:40:12 allender - * read config file after digi initialized + * Revision 1.15 2001/11/05 07:39:08 bradleyb + * Change args_init back to InitArgs * - * Revision 1.14 1995/10/05 10:38:22 allender - * changed key_getch at exit to be key_inkey and moved - * mouse init until after macintosh windowing init call + * Revision 1.14 2001/11/04 09:01:41 bradleyb + * SDL applies to more than X11... * - * Revision 1.13 1995/09/18 17:01:04 allender - * put gr_init call before render buffer stuff + * Revision 1.13 2001/10/31 07:41:54 bradleyb + * Sync with d1x * - * Revision 1.12 1995/08/31 15:50:53 allender - * call init for appletalk, and change name of intro screens + * Revision 1.12 2001/10/27 01:39:23 bradleyb + * added some documentation * - * Revision 1.11 1995/08/26 16:26:19 allender - * whole bunch 'o stuff!! + * Revision 1.11 2001/10/25 09:12:16 bradleyb + * Completed tmap selection code. * - * Revision 1.10 1995/07/12 21:48:18 allender - * removed Int3 from beginning of program + * Revision 1.10 2001/10/25 02:19:31 bradleyb + * conditionalize including multi.h and network.h, fix backslashes, fix compiler errors with EDITOR * - * Revision 1.9 1995/07/05 16:45:48 allender - * removed hide_cursor call + * Revision 1.9 2001/10/19 08:08:50 bradleyb + * conditionalize conf.h * - * Revision 1.8 1995/06/20 16:44:57 allender - * game now renders in 640x480 at all times. Changed code - * to call game_init_render_buffers with right params + * Revision 1.8 2001/10/19 00:31:51 bradleyb + * Trying to get network working on win32 * - * Revision 1.7 1995/06/13 13:07:55 allender - * change macintosh initialzation. Mac windows now init'ed through gr_init. + * Revision 1.7 2001/10/18 00:01:01 bradleyb + * RCS headers added/changed * - * Revision 1.6 1995/06/08 16:36:53 allender - * "ifdef" profile include - * - * Revision 1.5 1995/06/07 08:08:18 allender - * dont' make memory info show at end of program - * - * Revision 1.4 1995/06/02 07:47:40 allender - * removed network initialzation for now - * - * Revision 1.3 1995/05/26 06:54:52 allender - * put digi_init after timer and key stuff since I was testing stuff - * that needed the keyboard handler installed - * - * Revision 1.2 1995/05/19 11:28:09 allender - * removed printf - * - * Revision 1.1 1995/05/16 15:26:39 allender - * Initial revision - * - * Revision 2.36 1996/01/05 16:52:16 john - * Improved 3d stuff. - * - * Revision 2.35 1995/10/07 13:20:06 john - * Added new modes for LCDBIOS, also added support for -JoyNice, - * and added Shift+F1-F4 to controls various stereoscopic params. - * - * Revision 2.34 1995/06/26 11:30:57 john - * Made registration/copyright screen go away after 5 minutes. - * - * Revision 2.33 1995/05/31 14:26:55 unknown - * Fixed ugly spacing. - * - * Revision 2.32 1995/05/26 16:15:28 john - * Split SATURN into define's for requiring cd, using cd, etc. - * Also started adding all the Rockwell stuff. - * - * Revision 2.31 1995/05/11 13:30:01 john - * Changed 3dbios detection to work like Didde Kim wanted it to. - * - * Revision 2.30 1995/05/08 13:53:50 john - * Added code to read vipport environemnt variable. - * - * Revision 2.29 1995/05/08 11:26:18 john - * Reversed eyes in 3dmax mode. - * - * Revision 2.28 1995/05/08 11:24:06 john - * Made 3dmax work like Kasan wants it to. - * - * Revision 2.27 1995/04/23 16:06:25 john - * Moved rinvul into modem/null modem menu. - * - * Revision 2.26 1995/04/12 13:39:26 john - * Fixed bug with -lowmem not working. - * - * Revision 2.25 1995/04/09 14:43:00 john - * Made Dynamic sockets not print Msockets for help. - * - * Revision 2.24 1995/04/07 16:11:33 john - * Fixed problem with VFX display when using setup. - * - * Revision 2.23 1995/04/06 15:40:51 john - * Synced VFX with setup #'s. - * - * Revision 2.22 1995/04/06 12:12:53 john - * Fixed some bugs with 3dmax. - * - * Revision 2.21 1995/03/30 16:36:51 mike - * text localization. - * - * Revision 2.20 1995/03/29 15:33:52 john - * Added code to parse descent.net file. - * - * Revision 2.19 1995/03/28 20:08:21 john - * Took away alternate server thing. - * - * Revision 2.18 1995/03/27 09:43:08 john - * Added VR Settings in config file. - * - * Revision 2.17 1995/03/23 19:02:21 john - * Added descent.net file use. - * - * Revision 2.16 1995/03/23 12:25:11 john - * Moved IPX stuff into BIOS lib. - * - * Revision 2.15 1995/03/21 16:52:34 john - * Added 320x100. - * - * Revision 2.14 1995/03/21 14:40:33 john - * Ifdef'd out the NETWORK code. - * - * Revision 2.13 1995/03/16 23:13:35 john - * Fixed bug with piggy paging in bitmap not checking for disk - * error, hence bogifying textures if you pull the CD out. - * - * Revision 2.12 1995/03/16 21:45:22 john - * Made all paged modes have incompatible menus! - * - * Revision 2.11 1995/03/15 15:19:34 john - * Took out code that changes to exe dir. - * - * Revision 2.10 1995/03/15 14:33:37 john - * Added code to force the Descent CD-rom in the drive. - * - * Revision 2.9 1995/03/15 11:41:27 john - * Better Saturn CD-ROM support. - * - * Revision 2.8 1995/03/14 18:24:46 john - * Force Destination Saturn to use CD-ROM drive. - * - * Revision 2.7 1995/03/14 16:22:35 john - * Added cdrom alternate directory stuff. - * - * Revision 2.6 1995/03/13 15:17:19 john - * Added alternate hogfile directory. - * - * Revision 2.5 1995/03/10 13:05:35 john - * Added code so that palette is correct for VFX1 helmets. - * - * Revision 2.4 1995/03/07 15:12:43 john - * Fixed VFX,3dmax support. - * - * Revision 2.3 1995/03/07 14:19:35 mike - * More destination saturn stuff. - * - * Revision 2.2 1995/03/06 16:47:34 mike - * destination saturn - * - * Revision 2.1 1995/03/06 15:24:06 john - * New screen techniques. - * - * Revision 2.0 1995/02/27 11:31:29 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.295 1995/02/23 12:02:14 john - * Made mono windows smaller. - * - * Revision 1.294 1995/02/16 17:35:00 john - * Added code to allow dynamic socket changing. - * - * Revision 1.293 1995/02/14 19:29:29 john - * Locked down critical error handler. - * - * Revision 1.292 1995/02/14 15:29:20 john - * Added CR-LF to last line of menu help text. - * - * Revision 1.291 1995/02/14 11:39:01 john - * Added polled/bios joystick readers. - * - * Revision 1.290 1995/02/13 20:35:03 john - * Lintized - * - * Revision 1.289 1995/02/11 16:20:02 john - * Added code to make the default mission be the one last played. - * - * Revision 1.288 1995/02/11 15:54:13 rob - * changed cinvul to rinvul. - * - * Revision 1.287 1995/02/11 14:48:43 rob - * Added max of 314 seconds to control invul. times - * - * Revision 1.286 1995/02/11 12:42:01 john - * Added new song method, with FM bank switching.. - * - * Revision 1.285 1995/02/11 11:36:11 rob - * Added cinvul option. - * - * Revision 1.284 1995/02/10 16:07:45 matt - * Took 'registered' out of printed info at startup - * - * Revision 1.283 1995/02/09 22:00:59 john - * Added i-glasses tracking. - * - * Revision 1.282 1995/02/02 11:11:27 john - * Added -nocyberman switch. - * - * Revision 1.281 1995/02/01 16:35:14 john - * Linted. - * - * Revision 1.280 1995/01/31 02:04:25 matt - * Fixed up cmdline help - * - * Revision 1.279 1995/01/30 16:25:55 john - * Put back in graphical screen at program end. - * - * Revision 1.278 1995/01/28 17:05:50 matt - * Changed imbedded copyright to use comma instead of hyphen - * - * Revision 1.277 1995/01/28 15:57:26 john - * Made joystick calibration be only when wrong detected in - * menu or joystick axis changed. - * - * Revision 1.276 1995/01/25 14:37:49 john - * Made joystick only prompt for calibration once... - * - * Revision 1.275 1995/01/24 18:21:00 john - * Added Adam's text warning. - * - * Revision 1.274 1995/01/22 15:57:20 john - * Took out code that printed warning out as game exited. - * - * Revision 1.273 1995/01/22 13:31:35 matt - * Added load of mission 0, so there's always a default mission - * - * Revision 1.272 1995/01/19 17:00:41 john - * Made save game work between levels. - * - * Revision 1.271 1995/01/18 11:47:57 adam - * changed copyright notice - * - * Revision 1.270 1995/01/15 13:42:42 john - * Moved low_mem cutoff higher. - * - * Revision 1.269 1995/01/12 18:53:50 john - * Put ifdef EDITOR around the code that checked for - * a 800x600 mode, because this trashed some people's - * computers (maybe) causing the mem allocation error in - * mouse.c that many users reported. - * - * Revision 1.268 1995/01/12 11:41:42 john - * Added external control reading. - * - * Revision 1.267 1995/01/06 10:26:55 john - * Added -nodoscheck command line switch. - * - * Revision 1.266 1995/01/05 16:59:30 yuan - * Don't show orderform in editor version. - * - * Revision 1.265 1994/12/28 15:33:51 john - * Added -slowjoy option. - * - * Revision 1.264 1994/12/15 16:44:15 matt - * Added trademark notice - * - * Revision 1.263 1994/12/14 20:13:59 john - * Reduced physical mem requments to 2 MB. - * - * Revision 1.262 1994/12/14 19:06:17 john - * Lowered physical memory requments to 2 MB. - * - * Revision 1.261 1994/12/14 09:41:29 allender - * change to drive and directory (if needed) of command line invocation - * so descent can be started from anywhere - * - * Revision 1.260 1994/12/13 19:08:59 john - * Updated memory requirements. - * - * Revision 1.259 1994/12/13 17:30:33 john - * Made the timer rate be changed right after initializing it. - * - * Revision 1.258 1994/12/13 02:46:25 matt - * Added imbedded copyright - * - * Revision 1.257 1994/12/13 02:06:46 john - * Added code to check stack used by descent... initial - * check showed stack used 35k/50k, so we decided it wasn't - * worth pursuing any more. - * - * Revision 1.256 1994/12/11 23:17:54 john - * Added -nomusic. - * Added RealFrameTime. - * Put in a pause when sound initialization error. - * Made controlcen countdown and framerate use RealFrameTime. - * - * Revision 1.255 1994/12/10 00:56:51 matt - * Added -nomusic to command-line help - * - * Revision 1.254 1994/12/08 11:55:11 john - * Took out low memory print. - * - * Revision 1.253 1994/12/08 11:51:00 john - * Made strcpy only copy corect number of chars,. - * - * Revision 1.252 1994/12/08 00:38:29 matt - * Cleaned up banner messages - * - * Revision 1.251 1994/12/07 19:14:52 matt - * Cleaned up command-line options and command-line help message - * - * Revision 1.250 1994/12/06 19:33:28 john - * Fixed text of message to make more sense. - * - * Revision 1.249 1994/12/06 16:30:55 john - * Neatend mem message,.. - * - * Revision 1.248 1994/12/06 16:17:35 john - * Added better mem checking/printing. - * - * Revision 1.247 1994/12/06 14:14:37 john - * Added code to set low mem based on memory. - * - * Revision 1.246 1994/12/05 12:29:09 allender - * removed ifdefs around -norun option - * - * Revision 1.245 1994/12/05 00:03:30 matt - * Added -norun option to exit after writing pig - * - * Revision 1.244 1994/12/04 14:47:01 john - * MAde the intro and menu be the same song. - * - * Revision 1.243 1994/12/04 14:36:42 john - * Added menu music. - * - * Revision 1.242 1994/12/02 13:50:17 yuan - * Localization. - * - * Revision 1.241 1994/12/01 17:28:30 adam - * added end-shareware stuff - * - * Revision 1.240 1994/11/30 12:10:57 adam - * added support for PCX titles/brief screens - * - * Revision 1.239 1994/11/29 15:47:33 matt - * Moved error_init to start of game, so error message prints last - * - * Revision 1.238 1994/11/29 14:19:22 jasen - * reduced dos mem requirments. - * - * Revision 1.237 1994/11/29 03:46:35 john - * Added joystick sensitivity; Added sound channels to detail menu. Removed -maxchannels - * command line arg. - * - * Revision 1.236 1994/11/29 02:50:18 john - * Increased the amount a joystick has to be off before - * asking if they want to recalibrate their joystick. - * - * Revision 1.235 1994/11/29 02:01:29 john - * Corrected some of the Descent command line help items. - * - * Revision 1.234 1994/11/29 01:39:56 john - * Fixed minor bug with vfx_light help not wrapping correctly. - * - * Revision 1.233 1994/11/28 21:34:17 john - * Reduced dos mem rqment to 70k. - * - * Revision 1.232 1994/11/28 21:20:38 john - * First version with memory checking. - * - * Revision 1.231 1994/11/28 20:06:21 rob - * Removed old serial param command line options. - * Added -noserial and -nonetwork to help listing. - * - * Revision 1.230 1994/11/27 23:15:24 matt - * Made changes for new mprintf calling convention - * - * Revision 1.229 1994/11/27 20:50:51 matt - * Don't set mem stuff if no debug - * - * Revision 1.228 1994/11/27 18:46:21 matt - * Cleaned up command-line switches a little - * - * Revision 1.227 1994/11/21 17:48:00 matt - * Added text to specifiy whether shareware or registered version - * - * Revision 1.226 1994/11/21 14:44:20 john - * Fixed some bugs with setting volumes even when -nosound was used. Duh! - * - * Revision 1.225 1994/11/21 13:53:42 matt - * Took out dos extender copyright - * - * Revision 1.224 1994/11/21 09:46:54 john - * Added -showmeminfo parameter. - * - * Revision 1.223 1994/11/20 22:12:05 mike - * Make some stuff dependent on SHAREWARE. - * - * Revision 1.222 1994/11/20 21:14:09 john - * Changed -serial to -noserial. MAde a 1 sec delay - * before leaving title screen. Clear keyboard buffer - * before asking for player name. - * - * Revision 1.221 1994/11/19 15:20:20 mike - * rip out unused code and data - * - * Revision 1.220 1994/11/17 19:14:29 adam - * prevented order screen from coming up when -notitles is used - * - * Revision 1.219 1994/11/16 11:34:39 john - * Added -nottitle switch. - * - * Revision 1.218 1994/11/16 10:05:53 john - * Added verbose messages. - * - * Revision 1.217 1994/11/15 20:12:34 john - * Added back in inferno and parallax screens. - * - * Revision 1.216 1994/11/15 18:35:30 john - * Added verbose setting. - * - * Revision 1.215 1994/11/15 17:47:44 john - * Added ordering info screen. - * - * Revision 1.214 1994/11/15 08:57:44 john - * Added MS-DOS version checking and -nonetwork option. - * - * Revision 1.213 1994/11/15 08:34:32 john - * Added better error messages for IPX init. - * - * Revision 1.212 1994/11/14 20:14:18 john - * Fixed some warnings. - * - * Revision 1.211 1994/11/14 19:50:49 john - * Added joystick cal values to descent.cfg. - * - * Revision 1.210 1994/11/14 17:56:44 allender - * make call to ReadConfigFile at startup - * - * Revision 1.209 1994/11/14 11:41:55 john - * Fixed bug with editor/game sequencing. - * - * Revision 1.208 1994/11/13 17:05:11 john - * Made the callsign entry be a list box and gave the ability - * to delete players. - * - * Revision 1.207 1994/11/13 15:39:22 john - * Added critical error handler to game. Took out -editor command line - * option because it didn't work anymore and wasn't worth fixing. Made scores - * not use MINER enviroment variable on release version, and made scores - * not print an error if there is no descent.hi. - * - * Revision 1.206 1994/11/10 20:53:29 john - * Used new sound install parameters. - * - * Revision 1.205 1994/11/10 11:07:52 mike - * Set default detail level. - * - * Revision 1.204 1994/11/09 13:45:43 matt - * Made -? work again for help - * - * Revision 1.203 1994/11/09 10:55:58 matt - * Cleaned up initialization for editor -> game transitions - * - * Revision 1.202 1994/11/07 21:35:47 matt - * Use new function iff_read_into_bitmap() - * - * Revision 1.201 1994/11/05 17:22:16 john - * Fixed lots of sequencing problems with newdemo stuff. - * - * Revision 1.200 1994/11/05 14:05:44 john - * Fixed fade transitions between all screens by making - * gr_palette_fade_in and out keep track of whether the palette is - * faded in or not. Then, wherever the code needs to fade out, it - * just calls gr_palette_fade_out and it will fade out if it isn't - * already. The same with fade_in. - * This eliminates the need for all the flags like Menu_fade_out, - * game_fade_in palette, etc. - * - * Revision 1.199 1994/11/04 14:36:30 allender - * change Auto_demo meaning to mean autostart from menu only. Use - * FindArgs when searching for AutoDemo from command line. also, - * set N_Players to 1 when starting in editor mode. - * - * Revision 1.198 1994/11/02 11:59:49 john - * Moved menu out of game into inferno main loop. - * - * Revision 1.197 1994/11/01 17:57:39 mike - * -noscreens option to bypass all screens. - * - * Revision 1.196 1994/10/28 15:42:34 allender - * don't register player if Autodemo is on - * - * Revision 1.195 1994/10/28 10:58:01 matt - * Added copyright notice for DOS4GW - * - * Revision 1.194 1994/10/20 21:26:48 matt - * Took out old serial name/number code, and put up message if this - * is a marked version. - * - * Revision 1.193 1994/10/19 09:52:14 allender - * Print out who descent.exe belongs to if descent.exe is stamped. - * - * Revision 1.192 1994/10/18 16:43:05 allender - * Added check for identifier stamp and time after which descent will - * no longer run. - * - * Revision 1.191 1994/10/17 13:07:17 john - * Moved the descent.cfg info into the player config file. - * - * Revision 1.190 1994/10/04 10:26:31 matt - * Support new menu fade in - * - * Revision 1.189 1994/10/03 22:58:46 matt - * Changed some values of game_mode - * - * Revision 1.188 1994/10/03 18:55:39 rob - * Changed defaults for com port settings. - * - * Revision 1.187 1994/10/03 13:34:47 matt - * Added new (and hopefully better) game sequencing functions - * - * Revision 1.186 1994/09/30 12:37:28 john - * Added midi,digi volume to configuration. - * - * Revision 1.185 1994/09/30 10:08:48 john - * Changed sound stuff... made it so the reseting card doesn't hang, - * made volume change only if sound is installed. - * - * Revision 1.184 1994/09/28 17:25:00 matt - * Added first draft of game save/load system - * - * Revision 1.183 1994/09/28 16:18:23 john - * Added capability to play midi song. - * - * Revision 1.182 1994/09/28 11:31:18 john - * Made text output unbuffered. - * - * Revision 1.181 1994/09/27 19:23:44 john - * Added -nojoystick and -nomouse - * - * Revision 1.180 1994/09/24 16:55:29 rob - * No longer open COM port immediately upon program start. - * No longer set Network_active is serial_active is set. - * - * Revision 1.179 1994/09/24 14:16:30 mike - * Support new game mode constants. - * - * Revision 1.178 1994/09/22 17:52:31 rob - * Added Findargs hooks for -serial, -speed, and -com. - * - * Revision 1.177 1994/09/22 16:14:11 john - * Redid intro sequecing. - * - * Revision 1.176 1994/09/21 16:32:58 john - * Made mouse and keyboard init after bm_init. Why? - * Because it seems to work better under virtual - * memory. - * - * Revision 1.175 1994/09/21 16:27:52 john - * Added mouse_init - * - * Revision 1.174 1994/09/20 15:14:10 matt - * New message for new VFX switches - * - * Revision 1.173 1994/09/16 16:14:27 john - * Added acrade sequencing. - * - * Revision 1.172 1994/09/16 11:49:52 john - * Added first version of arcade joystick support; - * Also fixed some bugs in kconfig.c, such as reading non-present - * joysticks, which killed frame rate, and not reading key_down_time - * when in slide mode or bank mode. - * - * Revision 1.171 1994/09/15 16:11:35 john - * Added support for VFX1 head tracking. Fixed bug with memory over- - * write when using stereo mode. - * - * Revision 1.170 1994/09/12 19:38:23 john - * Made some stuff that prints to the DOS screen go to the - * mono instead, since it really is debugging info. - * - * Revision 1.169 1994/08/29 21:18:28 john - * First version of new keyboard/oystick remapping stuff. - * - * Revision 1.168 1994/08/26 13:02:00 john - * Put high score system in. - * - * Revision 1.167 1994/08/24 19:00:23 john - * Changed key_down_time to return fixed seconds instead of - * milliseconds. - * - * Revision 1.166 1994/08/18 16:24:20 john - * changed socket to channel in text. - * - * Revision 1.165 1994/08/18 16:16:51 john - * Added support for different sockets. - * - * Revision 1.164 1994/08/18 10:47:53 john - * *** empty log message *** - * - * Revision 1.163 1994/08/12 09:15:54 john - * *** empty log message *** - * - * Revision 1.162 1994/08/12 03:11:19 john - * Made network be default off; Moved network options into - * main menu. Made starting net game check that mines are the - * same. - * - * Revision 1.161 1994/08/10 19:57:05 john - * Changed font stuff; Took out old menu; messed up lots of - * other stuff like game sequencing messages, etc. - * - * Revision 1.160 1994/08/05 16:30:23 john - * Added capability to turn off network. - * - * Revision 1.159 1994/08/04 19:42:51 matt - * Moved serial number & name (and version name) from inferno.c to inferno.ini - * - * Revision 1.158 1994/08/03 10:30:23 matt - * Change cybermaxx switches, updated command-line help, and added serial number system - * - * Revision 1.157 1994/07/29 18:30:10 matt - * New parms (lack of parms, actually) for g3_init() - * - * Revision 1.156 1994/07/24 00:39:25 matt - * Added more text to TEX file; make NewGame() take a start level; made game - * load/save menus use open/close window funcs. - * - * Revision 1.155 1994/07/21 21:31:27 john - * First cheapo version of VictorMaxx tracking. - * - * Revision 1.154 1994/07/21 18:15:34 matt - * Ripped out a bunch of unused stuff - * - * Revision 1.153 1994/07/21 17:59:10 matt - * Cleaned up initial mode game/editor code - * - * Revision 1.152 1994/07/21 13:11:19 matt - * Ripped out remants of old demo system, and added demo only system that - * disables object movement and game options from menu. - * - * Revision 1.151 1994/07/20 15:58:27 john - * First installment of ipx stuff. - * - * Revision 1.150 1994/07/15 16:04:24 matt - * Changed comment for milestone 3 version - * - * Revision 1.149 1994/07/15 13:59:24 matt - * Fixed stupid mistake I make in the last revision - * - * Revision 1.148 1994/07/15 13:20:15 matt - * Updated comand-line help - * - * Revision 1.147 1994/07/14 23:29:43 matt - * Open two mono debug messages, one for errors & one for spew - * - * Revision 1.146 1994/07/09 22:48:05 matt - * Added localizable text - * - * Revision 1.145 1994/07/02 13:49:47 matt - * Cleaned up includes - * - * Revision 1.144 1994/06/30 20:04:43 john - * Added -joydef support. - * - * Revision 1.143 1994/06/24 17:01:44 john - * Add VFX support; Took Game Sequencing, like EndGame and stuff and - * took it out of game.c and into gameseq.c * */ @@ -716,10 +80,10 @@ char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPOR #include #include #include -#include #ifdef __unix__ #include +#include #include #include #endif @@ -784,10 +148,6 @@ char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPOR // # include "3dfx_des.h" -//added on 9/30/98 by Matt Mueller for selectable automap modes -#include "automap.h" -//end addition -MM - #include "../texmap/scanline.h" //for select_tmap -MM #if defined(POLY_ACC) @@ -801,8 +161,8 @@ extern int Current_display_mode; //$$ there's got to be a better way than #include "ui.h" #endif -#ifndef __MSDOS__ -#include +#ifdef SDL_INPUT +#include #endif #include "vers_id.h" @@ -856,6 +216,7 @@ extern int VR_low_res; extern int Config_vr_type; extern int Config_vr_resolution; extern int Config_vr_tracking; +int grd_fades_disabled=1; #define LINE_LEN 100 @@ -870,35 +231,30 @@ void print_commandline_help() if (!ifile) { ifile = cfopen("help.txb","rb"); if (!ifile) - Warning("Cannot load help text file."); + Error("Cannot load help text file."); have_binary = 1; } - if (ifile) - { - - while (cfgets(line,LINE_LEN,ifile)) { + while (cfgets(line,LINE_LEN,ifile)) { - if (have_binary) { - int i; - for (i = 0; i < strlen(line) - 1; i++) { - encode_rotate_left(&(line[i])); - line[i] = line[i] ^ BITMAP_TBL_XOR; - encode_rotate_left(&(line[i])); - } + if (have_binary) { + int i; + for (i = 0; i < strlen(line) - 1; i++) { + encode_rotate_left(&(line[i])); + line[i] = line[i] ^ BITMAP_TBL_XOR; + encode_rotate_left(&(line[i])); } - - if (line[0] == ';') - continue; //don't show comments - - printf("%s",line); - } - cfclose(ifile); + if (line[0] == ';') + continue; //don't show comments + + printf("%s",line); } + cfclose(ifile); + // printf( " Diagnostic:\n\n"); // printf( " -emul %s\n", "Certain video cards need this option in order to run game"); // printf( " -ddemul %s\n", "If -emul doesn't work, use this option"); @@ -907,20 +263,15 @@ void print_commandline_help() printf( " Editor Options:\n\n"); printf( " -autoload %s\n", "Autoload a level in the editor"); printf( " -hoarddata %s\n","FIXME: Undocumented"); + printf( " -macdata %s\n","FIXME: Undocumented"); // printf( " -nobm %s\n","FIXME: Undocumented"); printf( "\n"); #endif printf( " D2X Options:\n\n"); printf( " -noredundancy %s\n", "Do not send messages when picking up redundant items in multi"); printf( " -shortpackets %s\n", "Set shortpackets to default as on"); - printf( " -maxfps %s\n", "Set maximum framerate (1-100)"); printf( " -notitles %s\n", "Do not show titlescreens on startup"); - printf( " -hogdir %s\n", "set shared data directory to "); -#ifdef __unix__ - printf( " -nohogdir %s\n", "don't try to use shared data directory"); - printf( " -userdir %s\n", "set user dir to instead of $HOME/.d2x"); -#endif - printf( " -ini %s\n", "option file (alternate to command line), defaults to d2x.ini"); + printf( " -ini %s\n", "option file (alternate to command line) defaults to d2x.ini, or d1x.ini"); printf( " -autodemo %s\n", "Start in demo mode"); printf( " -bigpig %s\n","FIXME: Undocumented"); printf( " -bspgen %s\n","FIXME: Undocumented"); @@ -947,23 +298,17 @@ void print_commandline_help() printf( " -ipxnetwork %s\n","Use IPX network number "); printf( " -jasen %s\n","FIXME: Undocumented"); printf( " -joyslow %s\n","FIXME: Undocumented"); -#ifdef NETWORK - printf( " -kali %s\n","use Kali for networking"); -#endif // printf( " -logfile %s\n","FIXME: Undocumented"); - printf( " -lowresmovies %s\n","Play low resolution movies if available (for slow machines)"); -#if defined(EDITOR) || !defined(MACDATA) - printf( " -macdata %s\n","Read (and, for editor, write) mac data files (swap colors)"); -#endif +// printf( " -lowresmovies %s\n","FIXME: Undocumented"); // printf( " -memdbg %s\n","FIXME: Undocumented"); // printf( " -monodebug %s\n","FIXME: Undocumented"); +#if defined(__DJGPP__) || defined(__SDL__) printf( " -nocdrom %s\n","FIXME: Undocumented"); +#endif #ifdef __DJGPP__ printf( " -nocyberman %s\n","FIXME: Undocumented"); #endif -#ifndef NDEBUG printf( " -nofade %s\n","Disable fades"); -#endif #ifdef NETWORK printf( " -nomatrixcheat %s\n","FIXME: Undocumented"); printf( " -norankings %s\n","Disable multiplayer ranking system"); @@ -973,7 +318,7 @@ void print_commandline_help() #endif #if !defined(MACINTOSH) && !defined(WINDOWS) printf( " -nomixer %s\n","Don't crank music volume"); -// printf( " -superhires %s\n","Allow higher-resolution modes"); + printf( " -superhires %s\n","Allow higher-resolution modes"); #endif // printf( " -nomodex %s\n","FIXME: Undocumented"); #ifndef RELEASE @@ -992,31 +337,25 @@ void print_commandline_help() printf( " -stickmag %s\n","FIXME: Undocumented"); #endif // printf( " -stopwatch %s\n","FIXME: Undocumented"); - printf( " -subtitles %s\n","Turn on movie subtitles (English-only)"); +// printf( " -subtitles %s\n","Turn on movie subtitles (English-only)"); // printf( " -sysram %s\n","FIXME: Undocumented"); printf( " -text %s\n","Specify alternate .tex file"); // printf( " -tsengdebug1 %s\n","FIXME: Undocumented"); // printf( " -tsengdebug2 %s\n","FIXME: Undocumented"); // printf( " -tsengdebug3 %s\n","FIXME: Undocumented"); -#ifdef NETWORK - printf( " -udp %s\n","Use TCP/UDP for networking"); -#endif +// printf( " -udp %s\n","FIXME: Undocumented"); // printf( " -vidram %s\n","FIXME: Undocumented"); printf( " -xcontrol %s\n","FIXME: Undocumented"); printf( " -xname %s\n","FIXME: Undocumented"); printf( " -xver %s\n","FIXME: Undocumented"); printf( " -tmap %s\n","select texmapper to use (c,fp,i386,pent,ppro)"); - printf( " -automapx %s\n","Set automap resolution to by "); - printf( " -automap_gameres %s\n","Set automap to use the same resolution as in game"); -// printf( " -menux %s\n","Set menu resolution to by "); -// printf( " -menu_gameres %s\n","Set menus to use the same resolution as in game"); printf( "\n"); printf( "D2X System Options:\n\n"); #ifdef __MSDOS__ printf( " -joy209 %s\n", "Use alternate port 209 for joystick"); #endif -#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE +#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE printf( " -fullscreen %s\n", "Use fullscreen mode if available"); #endif #ifdef OGL @@ -1026,7 +365,7 @@ void print_commandline_help() printf( " -gl_simple %s\n","set gl texture filters to gl_nearest for \"original\" look. (default)"); printf( " -gl_alttexmerge %s\n","use new texmerge, usually uses less ram (default)"); printf( " -gl_stdtexmerge %s\n","use old texmerge, uses more ram, but _might_ be a bit faster"); -#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE +#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE printf( " -gl_voodoo %s\n","force fullscreen mode only"); #endif printf( " -gl_16bittextures %s\n","attempt to use 16bit textures"); @@ -1046,7 +385,7 @@ void print_commandline_help() printf( " -nosdlvidmodecheck %s\n", "Some X servers don't like checking vidmode first, so just switch"); printf( " -hwsurface %s\n","FIXME: Undocumented"); #endif -#ifdef __unix__ +#ifdef __linux__ printf( " -serialdevice %s\n", "Set serial/modem device to "); printf( " -serialread %s\n", "Set serial/modem to read from "); #endif @@ -1057,6 +396,7 @@ void print_commandline_help() void do_joystick_init() { + if (!FindArg( "-nojoystick" )) { con_printf(CON_VERBOSE, "\n%s", TXT_VERBOSE_6); @@ -1091,10 +431,10 @@ void do_register_player(ubyte *title_pal) key_flush(); - //now, before we bring up the register player menu, we need to + //now, before we bring up the register player menu, we need to //do some stuff to make sure the palette is ok. First, we need to //get our current palette into the 2d's array, so the remapping will - //work. Second, we need to remap the fonts. Third, we need to fill + //work. Second, we need to remap the fonts. Third, we need to fill //in part of the fade tables so the darkening of the menu edges works memcpy(gr_palette,title_pal,sizeof(gr_palette)); @@ -1108,14 +448,14 @@ void do_register_player(ubyte *title_pal) void do_network_init() { if (!FindArg( "-nonetwork" )) { - int socket = 0, showaddress = 0, t; + int socket=0, t; int ipx_error; con_printf(CON_VERBOSE, "\n%s ", TXT_INITIALIZING_NETWORK); if ((t=FindArg("-socket"))) socket = atoi( Args[t+1] ); //@@if ( FindArg("-showaddress") ) showaddress=1; - if ((ipx_error=ipx_init(IPX_DEFAULT_SOCKET+socket, showaddress))==0) { + if ((ipx_error=ipx_init(IPX_DEFAULT_SOCKET+socket))==0) { con_printf(CON_VERBOSE, "%s %d.\n", TXT_IPX_CHANNEL, socket ); Network_active = 1; } else { @@ -1149,16 +489,12 @@ extern char Language[]; //can we do highres menus? extern int MenuHiresAvailable; +#ifdef D2_OEM int intro_played = 0; +#endif int Inferno_verbose = 0; -//added on 11/18/98 by Victor Rachels to add -mission and -startgame -int start_net_immediately = 0; -//int start_with_mission = 0; -//char *start_with_mission_name; -//end this section addition - int open_movie_file(char *filename,int must_have); #if defined(POLY_ACC) @@ -1177,31 +513,23 @@ int Auto_exit = 0; char Auto_file[128] = ""; #endif -int main(int argc, char *argv[]) +int main(int argc,char **argv) { - int i, t; + int i,t; ubyte title_pal[768]; - int screen_width = 640; - int screen_height = 480; - u_int32_t screen_mode = SM(screen_width,screen_height); con_init(); // Initialise the console mem_init(); error_init(NULL, NULL); - InitArgs( argc,argv ); - #ifdef __unix__ { char *home = getenv("HOME"); - if ((t = FindArg("-userdir"))) - chdir(Args[t+1]); - - else if (home) { + if (home) { char buf[PATH_MAX + 5]; - + strcpy(buf, home); strcat(buf, "/.d2x"); if (chdir(buf)) { @@ -1213,44 +541,45 @@ int main(int argc, char *argv[]) } #endif - if (FindArg("-debug")) + InitArgs( argc,argv ); + + if ( FindArg( "-debug") ) + { con_threshold.value = (float)2; - else if (FindArg("-verbose")) - con_threshold.value = (float)1; + + } else + if ( FindArg( "-verbose" ) ) + { + con_threshold.value = (float)1; + } + + arch_init_start(); + + arch_init(); //tell cfile where hogdir is - if ((t=FindArg("-hogdir"))) - cfile_use_alternate_hogdir(Args[t+1]); -#ifdef __unix__ - else if (!FindArg("-nohogdir")) - cfile_use_alternate_hogdir(SHAREPATH); -#endif + cfile_use_alternate_hogdir(SHAREPATH); //tell cfile about our counter cfile_set_critical_error_counter_ptr(&descent_critical_error); - if (! cfile_init("descent2.hog")) - if (! cfile_init("d2demo.hog")) - Warning("Could not find a valid hog file (descent2.hog or d2demo.hog)\nPossible locations are:\n" -#ifdef __unix__ - "\t$HOME/.d2x\n" - "\t" SHAREPATH "\n" -#else - "\tCurrent directory\n" -#endif - "Or use the -hogdir option to specify an alternate location."); + #ifdef SHAREWARE + cfile_init("d2demo.hog"); //specify name of hogfile + #else + #define HOGNAME "descent2.hog" + if (! cfile_init(HOGNAME)) { //didn't find HOG. Check on CD + #ifdef RELEASE + Error("Could not find required file <%s>",HOGNAME); + #endif + } + #endif + load_text(); //print out the banner title con_printf(CON_NORMAL, "\nDESCENT 2 %s v%d.%d",VERSION_TYPE,Version_major,Version_minor); - #ifdef VERSION_NAME - con_printf(CON_NORMAL, " %s", VERSION_NAME); - #endif - if (cfexist(MISSION_DIR "d2x.hog")) - con_printf(CON_NORMAL, " Vertigo Enhanced"); - con_printf(CON_NORMAL, " %s %s\n", __DATE__,__TIME__); - con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK); + con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK); con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2. Copyright (c) 1999 Peter Hawkins\n"); con_printf(CON_NORMAL, " Copyright (c) 2002 Bradley Bell\n"); @@ -1268,30 +597,7 @@ int main(int argc, char *argv[]) con_printf(CON_NORMAL, TXT_HELP, PROGNAME); //help message has %s for program name con_printf(CON_NORMAL, "\n"); - //(re)added Mar 30, 2003 Micah Lieske - Allow use of 22K sound samples again. - if(FindArg("-sound22k")) - { - digi_sample_rate = SAMPLE_RATE_22K; - } - - if(FindArg("-sound11k")) - { - digi_sample_rate = SAMPLE_RATE_11K; - } - - arch_init_start(); - - arch_init(); - - //con_printf(CON_VERBOSE, "\n%s...", "Checking for Descent 2 CD-ROM"); - - //added/edited 8/18/98 by Victor Rachels to set maximum fps <= 100 - if ((t = FindArg( "-maxfps" ))) { - t=atoi(Args[t+1]); - if (t>0&&t<=80) - maxfps=t; - } - //end addition - Victor Rachels + con_printf(CON_VERBOSE, "\n%s...", "Checking for Descent 2 CD-ROM"); if ( FindArg( "-autodemo" )) Auto_demo = 1; @@ -1323,8 +629,6 @@ int main(int argc, char *argv[]) con_printf (CON_VERBOSE, "%s", TXT_VERBOSE_1); ReadConfigFile(); - do_joystick_init(); - #ifdef NETWORK do_network_init(); #endif @@ -1338,67 +642,6 @@ int main(int argc, char *argv[]) set_display_mode(0); //..then set default display mode #endif - { -//added on 12/14/98 by Matt Mueller - override res in d1x.ini with command line args - int i, argnum=INT_MAX; -//end addition -MM - int vr_mode = VR_NONE; - int screen_compatible = 1; - int use_double_buffer = 0; - -//added/edited on 12/14/98 by Matt Mueller - override res in d1x.ini with command line args -//added on 9/30/98 by Matt Mueller clean up screen mode code, and add higher resolutions -#define SCREENMODE(X,Y,C) if ( (i=FindArg( "-" #X "x" #Y ))&&(i 0 ) { kconfig_init_external_controls( strtol(Args[i+1], NULL, 0), strtol(Args[i+2], NULL, 0) ); @@ -1407,19 +650,7 @@ int main(int argc, char *argv[]) con_printf(CON_VERBOSE, "\n%s\n\n", TXT_INITIALIZING_GRAPHICS); if (FindArg("-nofade")) grd_fades_disabled=1; - - //determine whether we're using high-res menus & movies -#if !defined(POLY_ACC) - if (FindArg("-nohires") || FindArg("-nohighres") || (gr_check_mode(MENU_HIRES_MODE) != 0) || disable_high_res) - MovieHires = MenuHires = MenuHiresAvailable = 0; - else -#endif - //NOTE LINK TO ABOVE! - MenuHires = MenuHiresAvailable = 1; - - if (FindArg( "-lowresmovies" )) - MovieHires = 0; - + if ((t=gr_init())!=0) //doesn't do much Error(TXT_CANT_INIT_GFX,t); @@ -1428,26 +659,33 @@ int main(int argc, char *argv[]) #endif // Load the palette stuff. Returns non-zero if error. - con_printf(CON_DEBUG, "Initializing palette system...\n" ); - gr_use_palette_table(DEFAULT_PALETTE ); + con_printf(CON_DEBUG, "\nInitializing palette system..." ); + gr_use_palette_table(DEFAULT_PALETTE ); - con_printf(CON_DEBUG, "Initializing font system...\n" ); + con_printf(CON_DEBUG, "\nInitializing font system..." ); gamefont_init(); // must load after palette data loaded. - con_printf( CON_DEBUG, "Initializing movie libraries...\n" ); + //determine whether we're using high-res menus & movies +#if !defined(POLY_ACC) + if (FindArg("-nohires") || FindArg("-nohighres") || (gr_check_mode(MENU_HIRES_MODE) != 0) || disable_high_res) + MovieHires = MenuHires = MenuHiresAvailable = 0; + else +#endif + //NOTE LINK TO ABOVE! + MenuHires = MenuHiresAvailable = 1; + + con_printf( CON_DEBUG, "\nInitializing movie libraries..." ); init_movies(); //init movie libraries -#if 0 - con_printf(CON_VERBOSE, "Going into graphics mode...\n"); + con_printf(CON_VERBOSE, "\nGoing into graphics mode...\n"); #if defined(POLY_ACC) gr_set_mode(SM_640x480x15xPA); #else gr_set_mode(MovieHires?SM(640,480):SM(320,200)); -#endif #endif #ifndef RELEASE - if ( FindArg( "-notitles" ) ) + if ( FindArg( "-notitles" ) ) songs_play_song( SONG_TITLE, 1); else #endif @@ -1499,7 +737,7 @@ int main(int argc, char *argv[]) if (played == MOVIE_NOT_PLAYED) { #if defined(POLY_ACC) - gr_set_mode(SM_640x480x15xPA); + gr_set_mode(SM_640x480x15xPA); #else gr_set_mode(MenuHires?SM_640x480V:SM_320x200C); #endif @@ -1545,7 +783,7 @@ int main(int argc, char *argv[]) } - PA_DFX (pa_splash()); + PA_DFX (pa_splash()); con_printf( CON_DEBUG, "\nShowing loading screen..." ); { @@ -1553,26 +791,25 @@ int main(int argc, char *argv[]) int pcx_error; char filename[14]; + #ifdef SHAREWARE + strcpy(filename, "descentd.pcx"); + #else + #ifdef D2_OEM + strcpy(filename, MenuHires?"descntob.pcx":"descento.pcx"); + #else strcpy(filename, MenuHires?"descentb.pcx":"descent.pcx"); - if (! cfexist(filename)) - strcpy(filename, MenuHires?"descntob.pcx":"descento.pcx"); // OEM - if (! cfexist(filename)) - strcpy(filename, "descentd.pcx"); // SHAREWARE - if (! cfexist(filename)) - strcpy(filename, "descentb.pcx"); // MAC SHAREWARE + #endif + #endif #if defined(POLY_ACC) gr_set_mode(SM_640x480x15xPA); #else gr_set_mode(MenuHires?SM(640,480):SM(320,200)); #endif -#ifdef OGL - set_screen_mode(SCREEN_MENU); -#endif - FontHires = FontHiresAvailable && MenuHires; + FontHires = MenuHires; - if ((pcx_error=pcx_read_fullscr( filename, title_pal ))==PCX_ERROR_NONE) { + if ((pcx_error=pcx_read_bitmap( filename, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, title_pal ))==PCX_ERROR_NONE) { //vfx_set_palette_sub( title_pal ); gr_palette_clear(); gr_palette_fade_in( title_pal, 32, 0 ); @@ -1614,7 +851,7 @@ int main(int argc, char *argv[]) for (i=0;ibm_data,1,bm[i]->bm_w*bm[i]->bm_h,ofile); - iff_error = iff_read_animbrush("orbgoal.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette); + iff_error = iff_read_animbrush("orbgoal.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette); Assert(iff_error == IFF_NO_ERROR); Assert(bm[0]->bm_w == 64 && bm[0]->bm_h == 64); nframes_short = nframes; @@ -1741,6 +978,7 @@ int main(int argc, char *argv[]) /* keep the mouse from wandering in SDL */ if (FindArg("-grabmouse")) SDL_WM_GrabInput(SDL_GRAB_ON); + #endif game(); @@ -1775,11 +1013,10 @@ int main(int argc, char *argv[]) WriteConfigFile(); -#if 0 +#if 0 /* ????? */ #ifndef RELEASE if (!FindArg( "-notitles" )) #endif - show_order_form(); #endif #ifndef NDEBUG @@ -1832,7 +1069,7 @@ void show_order_form() gr_set_current_canvas( NULL ); gr_palette_clear(); - key_flush(); + key_flush(); #ifdef D2_OEM strcpy(exit_screen, MenuHires?"ordrd2ob.pcx":"ordrd2o.pcx"); @@ -1844,16 +1081,16 @@ void show_order_form() #endif #endif - if ((pcx_error=pcx_read_fullscr( exit_screen, title_pal ))==PCX_ERROR_NONE) { + if ((pcx_error=pcx_read_bitmap( exit_screen, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, title_pal ))==PCX_ERROR_NONE) { //vfx_set_palette_sub( title_pal ); gr_palette_fade_in( title_pal, 32, 0 ); key_getch(); - gr_palette_fade_out( title_pal, 32, 0 ); + gr_palette_fade_out( title_pal, 32, 0 ); } else Int3(); //can't load order screen - key_flush(); + key_flush(); #endif } diff --git a/main/ipx_drv.c b/main/ipx_drv.c new file mode 100644 index 00000000..ed8b28cd --- /dev/null +++ b/main/ipx_drv.c @@ -0,0 +1,438 @@ +/* +THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX +SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO +END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A +ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS +IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS +SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE +FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE +CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. +*/ + +/* + * $Source: /cvs/cvsroot/d2x/main/ipx_drv.c,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-10-19 04:10:27 $ + * + * FIXME: put description here + * + * $Log: not supported by cvs2svn $ + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "pstypes.h" +#include "config.h" +#include "args.h" +#include "text.h" + +#include "network.h" +#include "mono.h" + +#include "ipx.h" +#include "ipx_drv.h" +//added 05/17/99 Matt Mueller - needed to redefine FD_* so that no asm is used +#include "checker.h" +//end addition -MM +#define MAX_IPX_DATA 576 + +ubyte broadcast_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; +ubyte null_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +//int ipx_fd; +//ipx_socket_t ipx_socket_data; +ubyte ipx_installed=0; +ubyte ipx_atexit_installed=0; +//ushort ipx_socket = 0; +u_int32_t ipx_network = 0; +ubyte ipx_MyAddress[10]; +int ipx_packetnum = 0; /* Sequence number */ + +/* User defined routing stuff */ +typedef struct user_address { + ubyte network[4]; + ubyte node[6]; + ubyte address[6]; +} user_address; +#define MAX_USERS 64 +int Ipx_num_users = 0; +user_address Ipx_users[MAX_USERS]; + +#define MAX_NETWORKS 64 +int Ipx_num_networks = 0; +uint Ipx_networks[MAX_NETWORKS]; + +void ipx_close(void); + +int ipx_general_PacketReady(int fd) { + fd_set set; + struct timeval tv; + + FD_ZERO(&set); + FD_SET(fd, &set); + tv.tv_sec = tv.tv_usec = 0; + if (select(fd + 1, &set, NULL, NULL, &tv) > 0) + return 1; + else + return 0; +} + +struct ipx_driver *driver = NULL; + +ubyte * ipx_get_my_server_address() +{ + return (ubyte *)&ipx_network; +} + +ubyte * ipx_get_my_local_address() +{ + return (ubyte *)(ipx_MyAddress + 4); +} + +//--------------------------------------------------------------- +// Initializes all IPX internals. +// If socket_number==0, then opens next available socket. +// Returns: 0 if successful. +// -1 if socket already open. +// -2 if socket table full. +// -3 if IPX not installed. +// -4 if couldn't allocate low dos memory +// -5 if error with getting internetwork address +int ipx_init( int socket_number ) +{ + int i; + if (!driver) return -1; + memset(ipx_MyAddress,0,10); + if ((i = FindArg("-ipxnetwork")) && Args[i + 1]) { + unsigned long n = strtol(Args[i + 1], NULL, 16); + ipx_MyAddress[0] = n >> 24; ipx_MyAddress[1] = (n >> 16) & 255; + ipx_MyAddress[2] = (n >> 8) & 255; ipx_MyAddress[3] = n & 255; + printf("IPX: Using network %08x\n", (unsigned int)n); + } + if (driver->OpenSocket(socket_number)) { + return -3; + } + +// if (driver->GetMyAddress) +// driver->GetMyAddress(); + memcpy(&ipx_network, ipx_MyAddress, 4); + Ipx_num_networks = 0; + memcpy( &Ipx_networks[Ipx_num_networks++], &ipx_network, 4 ); + ipx_installed = 1; + if (ipx_atexit_installed==0){ + atexit(ipx_close); + ipx_atexit_installed=1; + } + return 0; +} + +void ipx_close() +{ + if (ipx_installed) + driver->CloseSocket(); + ipx_installed = 0; +} + +//########printfs?? +int ipx_set_driver(char *arg) +{ + ipx_close(); + + if (!FindArg( "-nonetwork" )) { + int socket=0; + int ipx_error; + int t; + if (Inferno_verbose) printf( "\n%s ", TXT_INITIALIZING_NETWORK); + if ((t=FindArg("-socket"))) + socket = atoi( Args[t+1] ); + + if ((t=FindArg("-pps")) && (t = atoi(Args[t+1])) && (t >= 2) && (t <= 20)) { + Network_initial_pps = t; + } + if ( FindArg("-shortpackets") ) + Network_initial_shortpackets = 1; + +#ifdef SUPPORTS_NET_IP + if (strcmp(arg,"ip")==0){ + driver=&ipx_ip; + }else +#endif + driver=arch_ipx_set_driver(arg); + if ((ipx_error=ipx_init(IPX_DEFAULT_SOCKET+socket))==0) { + if (Inferno_verbose) printf( "%s %d.\n", TXT_IPX_CHANNEL, socket ); + Network_active = 1; + } else { + switch( ipx_error ) { + case 3: if (Inferno_verbose) printf( "%s\n", TXT_NO_NETWORK); break; + case -2: if (Inferno_verbose) printf( "%s 0x%x.\n", TXT_SOCKET_ERROR, IPX_DEFAULT_SOCKET+socket); break; + case -4: if (Inferno_verbose) printf( "%s\n", TXT_MEMORY_IPX ); break; + default: + if (Inferno_verbose) printf( "%s %d", TXT_ERROR_IPX, ipx_error ); + } + if (Inferno_verbose) printf( "%s\n",TXT_NETWORK_DISABLED); + Network_active = 0; // Assume no network + } + ipx_read_user_file( "descent.usr" ); + ipx_read_network_file( "descent.net" ); + //if ( FindArg( "-dynamicsockets" )) + // Network_allow_socket_changes = 1; + //else + // Network_allow_socket_changes = 0; + } else { + if (Inferno_verbose) printf( "%s\n", TXT_NETWORK_DISABLED); + Network_active = 0; // Assume no network + } + + return ipx_installed?0:-1; +} + +int ipx_get_packet_data( ubyte * data ) +{ + if (driver->GetPacketData) + return driver->GetPacketData(data); + else { + struct ipx_recv_data rd; + char *buf; + int size; + if (driver->usepacketnum) + buf=alloca(MAX_IPX_DATA); + else + buf=data; + //edited 04/12/99 Matt Mueller - duh, we don't want to throw all that data away! + while (driver->PacketReady()) { + if ((size = driver->ReceivePacket(buf, MAX_IPX_DATA, &rd)) > 4) { + if (!memcmp(rd.src_network, ipx_MyAddress, 10)) { + mprintf((0,"dumped my own packet\n")); + continue; /* don't get own pkts */ + } + if (driver->usepacketnum){ + memcpy(data, buf + 4, size - 4); + return size-4; + }else{ + return size; + } + } + } + return 0; + } +} + +void ipx_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ) +{ + if (driver->SendPacketData) + driver->SendPacketData(data,datasize,network,address,immediate_address); + else{ + IPXPacket_t ipx_header; + + memcpy(ipx_header.Destination.Network, network, 4); + memcpy(ipx_header.Destination.Node, immediate_address, 6); +// *(ushort *)ipx_header.Destination.Socket = htons(ipx_socket_data.socket); + ipx_header.PacketType = 4; /* Packet Exchange */ + + if (driver->usepacketnum){ + ubyte buf[MAX_IPX_DATA]; + *(uint *)buf = ipx_packetnum++; + + memcpy(buf + 4, data, datasize); + driver->SendPacket(&ipx_header, buf, datasize + 4); + }else + driver->SendPacket(&ipx_header, data, datasize);//we can save 4 bytes + } +} + +void ipx_get_local_target( ubyte * server, ubyte * node, ubyte * local_target ) +{ + if (driver->GetLocalTarget) + driver->GetLocalTarget(server,node,local_target); + else + // let's hope Linux knows how to route it + memcpy( local_target, node, 6 ); +} + +void ipx_send_broadcast_packet_data( ubyte * data, int datasize ) +{ + int i, j; + ubyte local_address[6]; + + // Set to all networks besides mine + for (i=0; iCheckReadyToJoin) + return 1; + return driver->CheckReadyToJoin(server,node); +} + + +int ipx_change_default_socket( ushort socket_number ) +{ + if ( !ipx_installed ) return -3; + + driver->CloseSocket(); + if (driver->OpenSocket(socket_number)) { + return -3; + } + return 0; +} + +void ipx_read_user_file(char * filename) +{ + FILE * fp; + user_address tmp; + char temp_line[132], *p1; + int n, ln=0, x; + + if (!filename) return; + + Ipx_num_users = 0; + + fp = fopen( filename, "rt" ); + if ( !fp ) return; + + printf( "Broadcast Users:\n" ); + + while (fgets(temp_line, 132, fp)) { + ln++; + p1 = strchr(temp_line,'\n'); if (p1) *p1 = '\0'; + p1 = strchr(temp_line,';'); if (p1) *p1 = '\0'; +#if 1 // adb: replaced sscanf(..., "%2x...", (char *)...) with better, but longer code + if (strlen(temp_line) >= 21 && temp_line[8] == '/') { + for (n = 0; n < 4; n++) { + if (sscanf(temp_line + n * 2, "%2x", &x) != 1) + break; + tmp.network[n] = x; + } + if (n != 4) + continue; + for (n = 0; n < 6; n++) { + if (sscanf(temp_line + 9 + n * 2, "%2x", &x) != 1) + break; + tmp.node[n] = x; + } + if (n != 6) + continue; + } else + continue; +#else + n = sscanf( temp_line, "%2x%2x%2x%2x/%2x%2x%2x%2x%2x%2x", &tmp.network[0], &tmp.network[1], &tmp.network[2], &tmp.network[3], &tmp.node[0], &tmp.node[1], &tmp.node[2],&tmp.node[3], &tmp.node[4], &tmp.node[5] ); + if ( n != 10 ) continue; +#endif + if ( Ipx_num_users < MAX_USERS ) { + ubyte * ipx_real_buffer = (ubyte *)&tmp; + ipx_get_local_target( tmp.network, tmp.node, tmp.address ); + Ipx_users[Ipx_num_users++] = tmp; + printf( "%02X%02X%02X%02X/", ipx_real_buffer[0],ipx_real_buffer[1],ipx_real_buffer[2],ipx_real_buffer[3] ); + printf( "%02X%02X%02X%02X%02X%02X\n", ipx_real_buffer[4],ipx_real_buffer[5],ipx_real_buffer[6],ipx_real_buffer[7],ipx_real_buffer[8],ipx_real_buffer[9] ); + } else { + printf( "Too many addresses in %s! (Limit of %d)\n", filename, MAX_USERS ); + fclose(fp); + return; + } + } + fclose(fp); +} + + +void ipx_read_network_file(char * filename) +{ + FILE * fp; + user_address tmp; + char temp_line[132], *p1; + int i, n, ln=0, x; + + if (!filename) return; + + fp = fopen( filename, "rt" ); + if ( !fp ) return; + + printf( "Using Networks:\n" ); + for (i=0; i= 8) { + for (n = 0; n < 4; n++) { + if (sscanf(temp_line + n * 2, "%2x", &x) != 1) + break; + tmp.network[n] = x; + } + if (n != 4) + continue; + } else + continue; +#else + n = sscanf( temp_line, "%2x%2x%2x%2x", &tmp.network[0], &tmp.network[1], &tmp.network[2], &tmp.network[3] ); + if ( n != 4 ) continue; +#endif + if ( Ipx_num_networks < MAX_NETWORKS ) { + int j; + for (j=0; j= Ipx_num_networks ) { + memcpy( &Ipx_networks[Ipx_num_networks++], tmp.network, 4 ); + printf(" %02x%02x%02x%02x\n", tmp.network[0], tmp.network[1], tmp.network[2], tmp.network[3] ); + } + } else { + printf( "Too many networks in %s! (Limit of %d)\n", filename, MAX_NETWORKS ); + fclose(fp); + return; + } + } + fclose(fp); +} diff --git a/main/joydefs.h b/main/joydefs.h index bec1c4b9..803f5ca4 100644 --- a/main/joydefs.h +++ b/main/joydefs.h @@ -1,4 +1,3 @@ -/* $Id: joydefs.h,v 1.2 2003-03-14 21:24:03 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,10 +7,9 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - #ifndef _JOYDEFS_H #define _JOYDEFS_H @@ -24,5 +22,5 @@ extern int joydefs_calibrate_flag; extern void joydefs_set_type(ubyte type); #endif -#endif /* _JOYDEFS_H */ +#endif diff --git a/main/kconfig.c b/main/kconfig.c index a6a1b5ce..a15a3958 100644 --- a/main/kconfig.c +++ b/main/kconfig.c @@ -1,4 +1,3 @@ -/* $Id: kconfig.c,v 1.19 2003-03-27 01:25:41 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -16,337 +15,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #endif -/* - * - * Routines to configure keyboard, joystick, etc.. - * - * Old Log: - * Revision 1.18 1995/10/29 20:14:10 allender - * don't read mouse 30x/sec. Still causes problems -- left with - * exposure at > 60 frame/s - * - * Revision 1.17 1995/10/27 14:16:35 allender - * don't set lastreadtime when doing mouse stuff if we didn't - * read mouse this frame - * - * Revision 1.16 1995/10/24 18:10:22 allender - * get mouse stuff working right this time? - * - * Revision 1.15 1995/10/23 14:50:50 allender - * corrected values for control type in kc_set_controls - * - * Revision 1.14 1995/10/21 16:36:54 allender - * fix up mouse read time - * - * Revision 1.13 1995/10/20 00:46:53 allender - * fix up mouse reading problem - * - * Revision 1.12 1995/10/19 13:36:38 allender - * mouse support in kconfig screens - * - * Revision 1.11 1995/10/18 21:06:06 allender - * removed Int3 in cruise stuff -- was in there for debugging and - * now not needed - * - * Revision 1.10 1995/10/17 13:12:47 allender - * fixed config menus so buttons don't get configured - * - * Revision 1.9 1995/10/15 23:07:55 allender - * added return key as second button for primary fire - * - * Revision 1.8 1995/09/05 08:49:47 allender - * change 'PADRTN' label to 'ENTER' - * - * Revision 1.7 1995/09/01 15:38:22 allender - * took out cap of reading controls max 25 times/sec - * - * Revision 1.6 1995/09/01 13:33:59 allender - * erase all old text - * - * Revision 1.5 1995/08/18 10:20:55 allender - * keep controls reading to 25 times/s max so fast - * frame rates don't mess up control reading - * - * Revision 1.4 1995/07/28 15:43:13 allender - * make mousebutton control primary fire - * - * Revision 1.3 1995/07/26 17:04:32 allender - * new defaults and make joystick main button work correctly - * - * Revision 1.2 1995/07/17 08:51:03 allender - * fixed up configuration menus to look right - * - * Revision 1.1 1995/05/16 15:26:56 allender - * Initial revision - * - * Revision 2.11 1995/08/23 16:08:04 john - * Added version 2 of external controls that passes the ship - * position and orientation the drivers. - * - * Revision 2.10 1995/07/07 16:48:01 john - * Fixed bug with new interface. - * - * Revision 2.9 1995/07/03 15:02:32 john - * Added new version of external controls for Cybermouse absolute position. - * - * Revision 2.8 1995/06/30 12:30:28 john - * Added -Xname command line. - * - * Revision 2.7 1995/03/30 16:36:56 mike - * text localization. - * - * Revision 2.6 1995/03/21 14:39:31 john - * Ifdef'd out the NETWORK code. - * - * Revision 2.5 1995/03/16 10:53:07 john - * Move VFX center to Shift+Z instead of Enter because - * it conflicted with toggling HUD on/off. - * - * Revision 2.4 1995/03/10 13:47:24 john - * Added head tracking sensitivity. - * - * Revision 2.3 1995/03/09 18:07:06 john - * Fixed bug with iglasses tracking not "centering" right. - * Made VFX have bright headlight lighting. - * - * Revision 2.2 1995/03/08 15:32:39 john - * Made VictorMaxx head tracking use Greenleaf code. - * - * Revision 2.1 1995/03/06 15:23:31 john - * New screen techniques. - * - * Revision 2.0 1995/02/27 11:29:26 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.105 1995/02/22 14:11:58 allender - * remove anonymous unions from object structure - * - * Revision 1.104 1995/02/13 12:01:56 john - * Fixed bug with buggin not mmaking player faster. - * - * Revision 1.103 1995/02/09 22:00:46 john - * Added i-glasses tracking. - * - * Revision 1.102 1995/01/24 21:25:47 john - * Fixed bug with slide/bank on not working with - * Cyberman heading., - * - * Revision 1.101 1995/01/24 16:09:56 john - * Fixed bug with Wingman extreme customize text overwriting title. - * - * Revision 1.100 1995/01/24 12:37:46 john - * Made Esc exit key define menu. - * - * Revision 1.99 1995/01/23 23:54:43 matt - * Made keypad enter work - * - * Revision 1.98 1995/01/23 16:42:00 john - * Made the external controls always turn banking off, leveling off - * and passed automap state thru to the tsr. - * - * Revision 1.97 1995/01/12 11:41:33 john - * Added external control reading. - * - * Revision 1.96 1995/01/05 10:43:58 mike - * Handle case when timer_get_fixed_seconds() goes negative. Happens at 9.1 - * hours. Previously, joystick would stop functioning. Now will work. - * - * Revision 1.95 1994/12/29 11:17:38 john - * Took out some warnings and mprintf. - * - * Revision 1.94 1994/12/29 11:07:41 john - * Fixed Thrustmaster and Logitech Wingman extreme - * Hat by reading the y2 axis during the center stage - * of the calibration, and using 75, 50, 27, and 3 % - * as values for the 4 positions. - * - * Revision 1.93 1994/12/27 12:16:20 john - * Fixed bug with slide on not working with joystick or mouse buttons. - * - * Revision 1.92 1994/12/20 10:34:15 john - * Made sensitivity work for mouse & joystick and made - * it only affect, pitch, heading, and roll. - * - * Revision 1.91 1994/12/16 00:11:23 matt - * Made delete key act normally when debug out - * - * Revision 1.90 1994/12/14 17:41:15 john - * Added more buttons so that Yoke would work. - * - * Revision 1.89 1994/12/13 17:25:35 allender - * Added Assert for bogus time for joystick reading. - * - * Revision 1.88 1994/12/13 14:48:01 john - * Took out some debugging mprintf's - * - * - * Revision 1.87 1994/12/13 14:43:02 john - * Took out the code in kconfig to build direction array. - * Called kc_set_controls after selecting a new control type. - * - * Revision 1.86 1994/12/13 01:11:32 john - * Fixed bug with message clearing overwriting - * right border. - * - * Revision 1.85 1994/12/12 00:35:58 john - * Added or thing for keys. - * - * Revision 1.84 1994/12/09 17:08:06 john - * Made mouse a bit less sensitive. - * - * Revision 1.83 1994/12/09 16:04:00 john - * Increased mouse sensitivity. - * - * Revision 1.82 1994/12/09 00:41:26 mike - * fix hang in automap print screen - * - * Revision 1.81 1994/12/08 11:50:37 john - * Made strcpy only copy corect number of chars,. - * - * Revision 1.80 1994/12/07 16:16:06 john - * Added command to check to see if a joystick axes has been used. - * - * Revision 1.79 1994/12/07 14:52:28 yuan - * Localization 492 - * - * Revision 1.78 1994/12/07 13:37:40 john - * Made the joystick thrust work in reverse. - * - * Revision 1.77 1994/12/07 11:28:24 matt - * Did a little localization support - * - * Revision 1.76 1994/12/04 12:30:03 john - * Made the Thrustmaster stick read every frame, not every 10 frames, - * because it uses analog axis as buttons. - * - * Revision 1.75 1994/12/03 22:35:25 yuan - * Localization 412 - * - * Revision 1.74 1994/12/03 15:39:24 john - * Made numeric keypad move in conifg. - * - * Revision 1.73 1994/12/01 16:23:39 john - * Fixed include mistake. - * - * Revision 1.72 1994/12/01 16:07:57 john - * Fixed bug that disabled joystick in automap because it used gametime, which is - * paused during automap. Fixed be used timer_Get_fixed_seconds instead of GameTime. - * - * Revision 1.71 1994/12/01 12:30:49 john - * Made Ctrl+D delete, not Ctrl+E - * - * Revision 1.70 1994/12/01 11:52:52 john - * Added default values for GamePad. - * - * Revision 1.69 1994/11/30 00:59:12 mike - * optimizations. - * - * Revision 1.68 1994/11/29 03:45:50 john - * Added joystick sensitivity; Added sound channels to detail menu. Removed -maxchannels - * command line arg. - * - * Revision 1.67 1994/11/27 23:13:44 matt - * Made changes for new mprintf calling convention - * - * Revision 1.66 1994/11/27 19:52:12 matt - * Made screen shots work in a few more places - * - * Revision 1.65 1994/11/22 16:54:50 mike - * autorepeat on missiles. - * - * Revision 1.64 1994/11/21 11:16:17 rob - * Changed calls to GameLoop to calls to multi_menu_poll and changed - * conditions under which they are called. - * - * Revision 1.63 1994/11/19 15:14:48 mike - * remove unused code and data - * - * Revision 1.62 1994/11/18 23:37:56 john - * Changed some shorts to ints. - * - * Revision 1.61 1994/11/17 13:36:35 rob - * Added better network hook in kconfig menu. - * - * Revision 1.60 1994/11/14 20:09:13 john - * Made Tab be default for automap. - * - * Revision 1.59 1994/11/13 16:34:07 matt - * Fixed victormaxx angle conversions - * - * Revision 1.58 1994/11/12 14:47:05 john - * Added support for victor head tracking. - * - * Revision 1.57 1994/11/08 15:14:55 john - * Added more calls so net doesn't die in net game. - * - * Revision 1.56 1994/11/07 14:01:07 john - * Changed the gamma correction sequencing. - * - * Revision 1.55 1994/11/01 16:40:08 john - * Added Gamma correction. - * - * Revision 1.54 1994/10/25 23:09:26 john - * Made the automap key configurable. - * - * Revision 1.53 1994/10/25 13:11:59 john - * Made keys the way Adam speced 'em for final game. - * - * Revision 1.52 1994/10/24 17:44:22 john - * Added stereo channel reversing. - * - * Revision 1.51 1994/10/22 13:23:18 john - * Made default rear view key be R. - * - * Revision 1.50 1994/10/22 13:20:09 john - * Took out toggle primary/secondary weapons. Fixed black - * background for 'axes' and 'buttons' text. - * - * Revision 1.49 1994/10/21 15:20:15 john - * Made PrtScr do screen dump, not F2. - * - * Revision 1.48 1994/10/21 13:41:36 john - * Allowed F2 to screen dump. - * - * Revision 1.47 1994/10/17 13:07:05 john - * Moved the descent.cfg info into the player config file. - * - * Revision 1.46 1994/10/14 15:30:22 john - * Added Cyberman default positions. - * - * Revision 1.45 1994/10/14 15:24:54 john - * Made Cyberman work with config. - * - * Revision 1.44 1994/10/14 12:46:04 john - * Added the ability to reset all to default. - * - * Revision 1.43 1994/10/14 12:18:31 john - * Made mouse invert axis always be 0 or 1. - * - * Revision 1.42 1994/10/14 12:16:03 john - * Changed code so that by doing DEL+F12 saves the current kconfig - * values as default. Added support for drop_bomb key. Took out - * unused slots for keyboard. Made keyboard use control_type of 0 - * save slots. - * - * Revision 1.41 1994/10/13 21:27:02 john - * Made axis invert value always be 0 or 1. - * - * Revision 1.40 1994/10/13 20:18:15 john - * Added some more system keys, such as F? and CAPSLOCK. - * - * Revision 1.39 1994/10/13 19:22:29 john - * Added separate config saves for different devices. - * Made all the devices work together better, such as mice won't - * get read when you're playing with the joystick. - * - * Revision 1.38 1994/10/13 15:41:57 mike - * Remove afterburner. - * - */ - #ifdef RCS -static char rcsid[] = "$Id: kconfig.c,v 1.19 2003-03-27 01:25:41 btb Exp $"; +static char rcsid[] = "$Id: kconfig.c,v 1.11 2001-11-14 11:02:55 bradleyb Exp $"; #endif #ifdef WINDOWS @@ -398,9 +68,10 @@ static char rcsid[] = "$Id: kconfig.c,v 1.19 2003-03-27 01:25:41 btb Exp $"; #include "poly_acc.h" #endif +#include "d_delay.h" #include "collide.h" -#ifdef __unix__ +#ifdef __linux__ #include "joystick.h" #endif @@ -456,7 +127,6 @@ int invert_text[2] = { TNUM_N, TNUM_Y }; int mouseaxis_text[3] = { TNUM_L_R, TNUM_F_B, TNUM_Z1 }; #ifndef MACINTOSH int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID }; -char * mousebutton_textra[13] = { "M4", "M5", "M6", "M7", "M8", "M9", "M10","M11","M12","M13","M14","M15","M16" };//text for buttons above 3. -MPM #else char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac #endif @@ -505,9 +175,7 @@ char * key_text[256] = { \ #endif /* OGL */ #endif -//added/removed by Victor Rachels for adding rebindable keys for these -// KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0 -ubyte system_keys[] = { KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_MINUS, KEY_EQUAL, KEY_PRINT_SCREEN }; +ubyte system_keys[] = { KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_MINUS, KEY_EQUAL, KEY_PRINT_SCREEN }; //extern void GameLoop(int, int ); @@ -560,10 +228,6 @@ kc_item *All_items; ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS]; -//added on 2/4/99 by Victor Rachels to add d1x new keys -ubyte kconfig_d2x_settings[MAX_D2X_CONTROLS]; -//end this section addition - VR - //----------- WARNING!!!!!!! ------------------------------------------- // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE @@ -752,42 +416,6 @@ kc_item kc_mouse[NUM_OTHER_CONTROLS] = { { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 }, }; -//added on 2/4/99 by Victor Rachels to add d1x new keys -kc_item kc_d2x[NUM_D2X_CONTROLS] = { -// id,x,y,w1,w2,u,d,l,r,text_num1,type,value - { 0, 15, 49, 71, 26, 27, 2, 27, 1, "WEAPON 1", BT_KEY, 255}, - { 1, 15, 49,100, 26, 26, 3, 0, 2, "WEAPON 1", BT_JOY_BUTTON, 255}, - { 2, 15, 57, 71, 26, 0, 4, 1, 3, "WEAPON 2", BT_KEY, 255}, - { 3, 15, 57,100, 26, 1, 5, 2, 4, "WEAPON 2", BT_JOY_BUTTON, 255}, - { 4, 15, 65, 71, 26, 2, 6, 3, 5, "WEAPON 3", BT_KEY, 255}, - { 5, 15, 65,100, 26, 3, 7, 4, 6, "WEAPON 3", BT_JOY_BUTTON, 255}, - { 6, 15, 73, 71, 26, 4, 8, 5, 7, "WEAPON 4", BT_KEY, 255}, - { 7, 15, 73,100, 26, 5, 9, 6, 8, "WEAPON 4", BT_JOY_BUTTON, 255}, - { 8, 15, 81, 71, 26, 6, 10, 7, 9, "WEAPON 5", BT_KEY, 255}, - { 9, 15, 81,100, 26, 7, 11, 8, 10, "WEAPON 5", BT_JOY_BUTTON, 255}, - - { 10, 15, 89, 71, 26, 8, 12, 9, 11, "WEAPON 6", BT_KEY, 255}, - { 11, 15, 89,100, 26, 9, 13, 10, 12, "WEAPON 6", BT_JOY_BUTTON, 255}, - { 12, 15, 97, 71, 26, 10, 14, 11, 13, "WEAPON 7", BT_KEY, 255}, - { 13, 15, 97,100, 26, 11, 15, 12, 14, "WEAPON 7", BT_JOY_BUTTON, 255}, - { 14, 15,105, 71, 26, 12, 16, 13, 15, "WEAPON 8", BT_KEY, 255}, - { 15, 15,105,100, 26, 13, 17, 14, 16, "WEAPON 8", BT_JOY_BUTTON, 255}, - { 16, 15,113, 71, 26, 14, 18, 15, 17, "WEAPON 9", BT_KEY, 255}, - { 17, 15,113,100, 26, 15, 19, 16, 18, "WEAPON 9", BT_JOY_BUTTON, 255}, - { 18, 15,121, 71, 26, 16, 20, 17, 19, "WEAPON 0", BT_KEY, 255}, - { 19, 15,121,100, 26, 17, 21, 18, 20, "WEAPON 0", BT_JOY_BUTTON, 255}, - - //{ 20, 15,131, 71, 26, 18, 22, 19, 21, "CYC PRIMARY", BT_KEY, 255}, - //{ 21, 15,131,100, 26, 19, 23, 20, 22, "CYC PRIMARY", BT_JOY_BUTTON, 255}, - //{ 22, 15,139, 71, 26, 20, 24, 21, 23, "CYC SECONDARY", BT_KEY, 255}, - //{ 23, 15,139,100, 26, 21, 25, 22, 24, "CYC SECONDARY", BT_JOY_BUTTON, 255}, - //{ 24, 8,147, 78, 26, 22, 26, 23, 25, "TOGGLE_PRIM AUTO", BT_KEY, 255}, - //{ 25, 8,147,107, 26, 23, 27, 24, 26, "TOGGLE_PRIM_AUTO", BT_JOY_BUTTON, 255}, - //{ 26, 8,155, 78, 26, 24, 1, 25, 27, "TOGGLE SEC AUTO", BT_KEY, 255}, - //{ 27, 8,155,107, 26, 25, 0, 26, 0, "TOGGLE SEC AUTO", BT_JOY_BUTTON, 255}, -}; -//end this section addition - VR - #else // ifndef MACINTOSH (following are macintosh controls) ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = { @@ -964,13 +592,6 @@ kc_item kc_mouse[NUM_OTHER_CONTROLS] = { #endif -//added on 2/4/99 by Victor Rachels to add new keys system -ubyte default_kconfig_d2x_settings[MAX_D2X_CONTROLS] = { - 0x2 ,0xff,0x3 ,0xff,0x4 ,0xff,0x5 ,0xff,0x6 ,0xff,0x7 ,0xff,0x8 ,0xff,0x9 , - 0xff,0xa ,0xff,0xb ,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }; -//end this section addition - VR - void kc_drawitem( kc_item *item, int is_current ); void kc_change_key( kc_item * item ); void kc_change_joybutton( kc_item * item ); @@ -1218,7 +839,7 @@ WIN(DDGRLOCK(dd_grd_curcanv)); gr_rect(close_x, close_y, close_x + close_size, close_y + close_size); gr_setcolor( BM_XRGB(21, 21, 21) ); gr_rect( close_x + 2, close_y + 2, close_x + close_size - 2, close_y + close_size -2 ); -#endif + #endif grd_curcanv->cv_font = GAME_FONT; gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); @@ -1278,15 +899,6 @@ WIN(DDGRLOCK(dd_grd_curcanv)); gr_string( LHX(169), LHY(129), TXT_AXIS ); gr_string( LHX(199), LHY(129), TXT_INVERT ); } - else if ( items == kc_d2x ) - { - gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); - gr_setcolor( BM_XRGB(31,27,6) ); - - gr_string(LHX( 94), LHY(40), "KB"); - gr_string(LHX(121), LHY(40), "JOY"); - } - WIN(DDGRUNLOCK(dd_grd_curcanv)); for (i=0; ivalue], 10 ); break; case BT_MOUSE_BUTTON: #ifndef MACINTOSH - //strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break; - strncpy( btext, (item->value <= 3)?Text_string[mousebutton_text[item->value]]:mousebutton_textra[item->value-3], 10 ); break; + strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break; #else strncpy( btext, mousebutton_text[item->value], 10 ); break; #endif @@ -1735,7 +1340,7 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); // if ( Game_mode & GM_MULTI ) // GameLoop( 0, 0 ); // Continue k = key_inkey(); - timer_delay(f0_1/10); + d_delay(10); kc_drawquestion( item ); for (i=0; i<256; i++ ) { @@ -1804,7 +1409,7 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); // if ( Game_mode & GM_MULTI ) // GameLoop( 0, 0 ); // Continue k = key_inkey(); - timer_delay(f0_1/10); + d_delay(10); if (k == KEY_PRINT_SCREEN) save_screen_shot(0); @@ -1893,7 +1498,7 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); // if ( Game_mode & GM_MULTI ) // GameLoop( 0, 0 ); // Continue k = key_inkey(); - timer_delay(f0_1/10); + d_delay(10); if (k == KEY_PRINT_SCREEN) save_screen_shot(0); @@ -1901,7 +1506,7 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); kc_drawquestion( item ); b = mouse_get_btns(); - for (i = 0; i < 16; i++ ) { + for (i=0; i<3; i++ ) { if ( b & (1<200 ) { #endif code = i; - con_printf(CON_DEBUG, "Axis Movement detected: Axis %i\n", i); + printf("Axis Movement detected: Axis %i\n", i); } //old_axis[i] = axis[i]; } @@ -2058,7 +1663,7 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); // if ( Game_mode & GM_MULTI ) // GameLoop( 0, 0 ); // Continue k = key_inkey(); - timer_delay(f0_1/10); + d_delay(10); if (k == KEY_PRINT_SCREEN) save_screen_shot(0); @@ -2140,10 +1745,7 @@ void kconfig(int n, char * title) case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break; case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break; case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break; - //added on 2/4/99 by Victor Rachels for new keys menu - case 4:kconfig_sub( kc_d2x, NUM_D2X_CONTROLS, title ); break; - //end this section addition - VR - default: + default: Int3(); return; } @@ -2174,9 +1776,6 @@ void kconfig(int n, char * title) for (i=0; iprimary_order[valu]&&player_has_weapon(i,0)) - valu = i; - LaserPowSelected = valu; - */ - } - //----------------Weapon 2---------------- - if(key_down_count(kc_d2x[2].value) || - (joy_get_button_state(kc_d2x[3].value) && - (d2x_joystick_state[1]!=d2x_joystick_ostate[1]) ) ) - do_weapon_select(1,0); - //----------------Weapon 3---------------- - if(key_down_count(kc_d2x[4].value) || - (joy_get_button_state(kc_d2x[5].value) && - (d2x_joystick_state[2]!=d2x_joystick_ostate[2]) ) ) - do_weapon_select(2,0); - //----------------Weapon 4---------------- - if(key_down_count(kc_d2x[6].value) || - (joy_get_button_state(kc_d2x[7].value) && - (d2x_joystick_state[3]!=d2x_joystick_ostate[3]) ) ) - do_weapon_select(3,0); - //----------------Weapon 5---------------- - if(key_down_count(kc_d2x[8].value) || - (joy_get_button_state(kc_d2x[9].value) && - (d2x_joystick_state[4]!=d2x_joystick_ostate[4]) ) ) - do_weapon_select(4,0); - - //--------- Read secondary weapon select ---------- - //----------------Weapon 6---------------- - if(key_down_count(kc_d2x[10].value) || - (joy_get_button_state(kc_d2x[11].value) && - (d2x_joystick_state[5]!=d2x_joystick_ostate[5]) ) ) - do_weapon_select(0,1); - //----------------Weapon 7---------------- - if(key_down_count(kc_d2x[12].value) || - (joy_get_button_state(kc_d2x[13].value) && - (d2x_joystick_state[6]!=d2x_joystick_ostate[6]) ) ) - do_weapon_select(1,1); - //----------------Weapon 8---------------- - if(key_down_count(kc_d2x[14].value) || - (joy_get_button_state(kc_d2x[15].value) && - (d2x_joystick_state[7]!=d2x_joystick_ostate[7]) ) ) - do_weapon_select(2,1); - //----------------Weapon 9---------------- - if(key_down_count(kc_d2x[16].value) || - (joy_get_button_state(kc_d2x[17].value) && - (d2x_joystick_state[8]!=d2x_joystick_ostate[8]) ) ) - do_weapon_select(3,1); - //----------------Weapon 0---------------- - if(key_down_count(kc_d2x[18].value) || - (joy_get_button_state(kc_d2x[19].value) && - (d2x_joystick_state[9]!=d2x_joystick_ostate[9]) ) ) - do_weapon_select(4,1); - memcpy(d2x_joystick_ostate,d2x_joystick_state,10*sizeof(int)); - } - //end this section addition - VR - - - }//end "if (!Player_is_dead)" - WraithX - - //------------- Read slide_on ------------- // From keyboard... @@ -3910,9 +3424,6 @@ void kc_set_controls() } } } - - for (i=0; i @@ -2042,16 +2041,16 @@ int create_homing_missile(object *objp, int goal_obj, int objtype, int make_soun extern void blast_nearby_glass(object *objp, fix damage); -//----------------------------------------------------------------------------- -// Create the children of a smart bomb, which is a bunch of homing missiles. +// ------------------------------------------------------------------------------------------- +// Create the children of a smart bomb, which is a bunch of homing missiles. void create_smart_children(object *objp, int num_smart_children) { - int parent_type, parent_num; + int parent_type, parent_num; #ifndef SHAREWARE - int make_sound; - int numobjs=0; - int objlist[MAX_OBJDISTS]; - int blob_id; + int make_sound; + int numobjs=0; + int objlist[MAX_OBJDISTS]; + int blob_id; #endif if (objp->type == OBJ_WEAPON) { @@ -2070,12 +2069,10 @@ void create_smart_children(object *objp, int num_smart_children) blast_nearby_glass(objp, Weapon_info[EARTHSHAKER_ID].strength[Difficulty_level]); #ifndef SHAREWARE -#if 0 // -- DEBUG -- if ((objp->type == OBJ_WEAPON) && ((objp->id == SMART_ID) || (objp->id == SUPERPROX_ID) || (objp->id == ROBOT_SUPERPROX_ID) || (objp->id == EARTHSHAKER_ID))) Assert(Weapon_info[objp->id].children != -1); // -- DEBUG -- -#endif if (((objp->type == OBJ_WEAPON) && (Weapon_info[objp->id].children != -1)) || (objp->type == OBJ_ROBOT)) { int i, objnum; diff --git a/main/laser.h b/main/laser.h index 3bb143a4..f3a1a7f9 100644 --- a/main/laser.h +++ b/main/laser.h @@ -1,4 +1,3 @@ -/* $Id: laser.h,v 1.2 2002-08-06 05:21:33 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -15,75 +14,75 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #ifndef _LASER_H #define _LASER_H -#define LASER_ID 0 //0..3 are lasers -#define CONCUSSION_ID 8 -#define FLARE_ID 9 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. -#define VULCAN_ID 11 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. -#define SPREADFIRE_ID 12 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. -#define PLASMA_ID 13 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. -#define FUSION_ID 14 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. -#define HOMING_ID 15 -#define PROXIMITY_ID 16 -#define SMART_ID 17 -#define MEGA_ID 18 - -#define PLAYER_SMART_HOMING_ID 19 -#define SUPER_MECH_MISS 21 -#define REGULAR_MECH_MISS 22 -#define SILENT_SPREADFIRE_ID 23 -#define ROBOT_SMART_HOMING_ID 29 -#define EARTHSHAKER_MEGA_ID 54 - -#define SUPER_LASER_ID 30 // 30,31 are super lasers (level 5,6) - -#define GAUSS_ID 32 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. -#define HELIX_ID 33 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. -#define PHOENIX_ID 34 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. -#define OMEGA_ID 35 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. - -#define FLASH_ID 36 -#define GUIDEDMISS_ID 37 -#define SUPERPROX_ID 38 -#define MERCURY_ID 39 -#define EARTHSHAKER_ID 40 - -#define SMART_MINE_HOMING_ID 47 -#define ROBOT_SMART_MINE_HOMING_ID 49 -#define ROBOT_SUPERPROX_ID 53 -#define ROBOT_EARTHSHAKER_ID 58 - -#define PMINE_ID 51 //the mine that the designers can place - -#define OMEGA_MULTI_LIFELEFT (F1_0/6) +#define LASER_ID 0 //0..3 are lasers +#define CONCUSSION_ID 8 +#define FLARE_ID 9 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. +#define VULCAN_ID 11 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. +#define SPREADFIRE_ID 12 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. +#define PLASMA_ID 13 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. +#define FUSION_ID 14 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. +#define HOMING_ID 15 +#define PROXIMITY_ID 16 +#define SMART_ID 17 +#define MEGA_ID 18 + +#define PLAYER_SMART_HOMING_ID 19 +#define SUPER_MECH_MISS 21 +#define REGULAR_MECH_MISS 22 +#define SILENT_SPREADFIRE_ID 23 +#define ROBOT_SMART_HOMING_ID 29 +#define EARTHSHAKER_MEGA_ID 54 + +#define SUPER_LASER_ID 30 //30,31 are super lasers (level 5,6) + +#define GAUSS_ID 32 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. +#define HELIX_ID 33 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. +#define PHOENIX_ID 34 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. +#define OMEGA_ID 35 // NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time. + +#define FLASH_ID 36 +#define GUIDEDMISS_ID 37 +#define SUPERPROX_ID 38 +#define MERCURY_ID 39 +#define EARTHSHAKER_ID 40 + +#define SMART_MINE_HOMING_ID 47 +#define ROBOT_SMART_MINE_HOMING_ID 49 +#define ROBOT_SUPERPROX_ID 53 +#define ROBOT_EARTHSHAKER_ID 58 + +#define PMINE_ID 51 //the mine that the designers can place + +#define OMEGA_MULTI_LIFELEFT (F1_0/6) // These are new defines for the value of 'flags' passed to do_laser_firing. // The purpose is to collect other flags like QUAD_LASER and Spreadfire_toggle // into a single 8-bit quantity so it can be easily used in network mode. -#define LASER_QUAD 1 -#define LASER_SPREADFIRE_TOGGLED 2 -#define LASER_HELIX_FLAG0 4 // helix uses 3 bits for angle -#define LASER_HELIX_FLAG1 8 // helix uses 3 bits for angle -#define LASER_HELIX_FLAG2 16 // helix uses 3 bits for angle +#define LASER_QUAD 1 +#define LASER_SPREADFIRE_TOGGLED 2 +#define LASER_HELIX_FLAG0 4 //helix uses 3 bits for angle +#define LASER_HELIX_FLAG1 8 //helix uses 3 bits for angle +#define LASER_HELIX_FLAG2 16 //helix uses 3 bits for angle -#define LASER_HELIX_SHIFT 2 //how far to shift count to put in flags -#define LASER_HELIX_MASK 7 //must match number of bits in flags +#define LASER_HELIX_SHIFT 2 //how far to shift count to put in flags +#define LASER_HELIX_MASK 7 //must match number of bits in flags -#define MAX_LASER_LEVEL 3 // Note, laser levels are numbered from 0. -#define MAX_SUPER_LASER_LEVEL 5 // Note, laser levels are numbered from 0. +#define MAX_LASER_LEVEL 3 // Note, laser levels are numbered from 0. +#define MAX_SUPER_LASER_LEVEL 5 // Note, laser levels are numbered from 0. -#define MAX_LASER_BITMAPS 6 +#define MAX_LASER_BITMAPS 6 -// For muzzle firing casting light. -#define MUZZLE_QUEUE_MAX 8 +// For muzzle firing casting light. +#define MUZZLE_QUEUE_MAX 8 -// Constants governing homing missile behavior. -// MIN_TRACKABLE_DOT gets inversely scaled by FrameTime and stuffed in Min_trackable_dot -#define MIN_TRACKABLE_DOT (7*F1_0/8) -#define MAX_TRACKABLE_DIST (F1_0*250) -#define HOMING_MISSILE_STRAIGHT_TIME (F1_0/8) // Changed as per request of John, Adam, Yuan, but mostly John +// Constants governing homing missile behavior. +// MIN_TRACKABLE_DOT gets inversely scaled by FrameTime and stuffed in Min_trackable_dot +#define MIN_TRACKABLE_DOT (7*F1_0/8) +#define MAX_TRACKABLE_DIST (F1_0*250) +#define HOMING_MISSILE_STRAIGHT_TIME (F1_0/8) // Changed as per request of John, Adam, Yuan, but mostly John -extern fix Min_trackable_dot; // MIN_TRACKABLE_DOT inversely scaled by FrameTime +extern fix Min_trackable_dot; // MIN_TRACKABLE_DOT inversely scaled by FrameTime extern object *Guided_missile[]; extern int Guided_missile_sig[]; @@ -101,17 +100,17 @@ extern void net_missile_firing(int player, int weapon, int flags); int Laser_create_new( vms_vector * direction, vms_vector * position, int segnum, int parent, int type, int make_sound ); -// Fires a laser-type weapon (a Primary weapon) -// Fires from object objnum, weapon type weapon_id. -// Assumes that it is firing from a player object, so it knows which gun to fire from. -// Returns the number of shots actually fired, which will typically be 1, but could be -// higher for low frame rates when rapidfire weapons, such as vulcan or plasma are fired. +// Fires a laser-type weapon (a Primary weapon) +// Fires from object objnum, weapon type weapon_id. +// Assumes that it is firing from a player object, so it knows which gun to fire from. +// Returns the number of shots actually fired, which will typically be 1, but could be +// higher for low frame rates when rapidfire weapons, such as vulcan or plasma are fired. extern int do_laser_firing(int objnum, int weapon_id, int level, int flags, int nfires); -// Easier to call than Laser_create_new because it determines the segment containing the firing point -// and deals with it being stuck in an object or through a wall. -// Fires a laser of type "weapon_type" from an object (parent) in the direction "direction" from the position "position" -// Returns object number of laser fired or -1 if not possible to fire laser. +// Easier to call than Laser_create_new because it determines the segment containing the firing point +// and deals with it being stuck in an object or through a wall. +// Fires a laser of type "weapon_type" from an object (parent) in the direction "direction" from the position "position" +// Returns object number of laser fired or -1 if not possible to fire laser. int Laser_create_new_easy( vms_vector * direction, vms_vector * position, int parent, int weapon_type, int make_sound ); //creates a weapon object @@ -123,20 +122,20 @@ void release_guided_missile(int player_num); extern void create_smart_children(object *objp, int count); extern int object_to_object_visibility(object *obj1, object *obj2, int trans_type); -extern int Muzzle_queue_index; +extern int Muzzle_queue_index; typedef struct muzzle_info { - fix create_time; - short segnum; - vms_vector pos; -} muzzle_info; + fix create_time; + short segnum; + vms_vector pos; +} muzzle_info; -extern muzzle_info Muzzle_data[MUZZLE_QUEUE_MAX]; +extern muzzle_info Muzzle_data[MUZZLE_QUEUE_MAX]; -// Omega cannon stuff. -#define MAX_OMEGA_CHARGE (F1_0) // Maximum charge level for omega cannonw -extern fix Omega_charge; -//NOTE: OMEGA_CHARGE_SCALE moved to laser.c to avoid long rebuilds if changed +// Omega cannon stuff. +#define MAX_OMEGA_CHARGE (F1_0) // Maximum charge level for omega cannonw +extern fix Omega_charge; +//NOTE: OMEGA_CHARGE_SCALE moved to laser.c to avoid long rebuilds if changed #endif diff --git a/main/menu.c b/main/menu.c index dc1547f7..8b416d4f 100644 --- a/main/menu.c +++ b/main/menu.c @@ -1,4 +1,3 @@ -/* $Id: menu.c,v 1.24 2003-04-12 02:52:38 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,20 +7,11 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Inferno main menu. - * - */ - -#ifdef HAVE_CONFIG_H #include -#endif - #ifdef WINDOWS #include "desw.h" #endif @@ -79,7 +69,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gauges.h" #include "powerup.h" #include "strutil.h" -#include "reorder.h" #ifdef MACINTOSH #include "resource.h" @@ -98,39 +87,39 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //char *menu_difficulty_text[] = { "Trainee", "Rookie", "Fighter", "Hotshot", "Insane" }; //char *menu_detail_text[] = { "Lowest", "Low", "Medium", "High", "Highest", "", "Custom..." }; -#define MENU_NEW_GAME 0 -#define MENU_GAME 1 -#define MENU_EDITOR 2 -#define MENU_VIEW_SCORES 3 -#define MENU_QUIT 4 -#define MENU_LOAD_GAME 5 -#define MENU_SAVE_GAME 6 -#define MENU_DEMO_PLAY 8 -#define MENU_LOAD_LEVEL 9 -#define MENU_START_IPX_NETGAME 10 -#define MENU_JOIN_IPX_NETGAME 11 -#define MENU_CONFIG 13 -#define MENU_REJOIN_NETGAME 14 -#define MENU_DIFFICULTY 15 -#define MENU_START_SERIAL 18 -#define MENU_HELP 19 -#define MENU_NEW_PLAYER 20 -#define MENU_MULTIPLAYER 21 -#define MENU_STOP_MODEM 22 -#define MENU_SHOW_CREDITS 23 -#define MENU_ORDER_INFO 24 -#define MENU_PLAY_SONG 25 -#define MENU_START_TCP_NETGAME 26 -#define MENU_JOIN_TCP_NETGAME 27 -#define MENU_START_APPLETALK_NETGAME 28 -#define MENU_JOIN_APPLETALK_NETGAME 30 +#define MENU_NEW_GAME 0 +#define MENU_GAME 1 +#define MENU_EDITOR 2 +#define MENU_VIEW_SCORES 3 +#define MENU_QUIT 4 +#define MENU_LOAD_GAME 5 +#define MENU_SAVE_GAME 6 +#define MENU_DEMO_PLAY 8 +#define MENU_LOAD_LEVEL 9 +#define MENU_START_IPX_NETGAME 10 +#define MENU_JOIN_IPX_NETGAME 11 +#define MENU_CONFIG 13 +#define MENU_REJOIN_NETGAME 14 +#define MENU_DIFFICULTY 15 +#define MENU_START_SERIAL 18 +#define MENU_HELP 19 +#define MENU_NEW_PLAYER 20 +#define MENU_MULTIPLAYER 21 +#define MENU_STOP_MODEM 22 +#define MENU_SHOW_CREDITS 23 +#define MENU_ORDER_INFO 24 +#define MENU_PLAY_SONG 25 +#define MENU_START_TCP_NETGAME 26 +#define MENU_JOIN_TCP_NETGAME 27 +#define MENU_START_APPLETALK_NETGAME 28 +#define MENU_JOIN_APPLETALK_NETGAME 30 //ADD_ITEM("Start netgame...", MENU_START_NETGAME, -1 ); //ADD_ITEM("Send net message...", MENU_SEND_NET_MESSAGE, -1 ); #define ADD_ITEM(t,value,key) do { m[num_options].type=NM_TYPE_MENU; m[num_options].text=t; menu_choice[num_options]=value;num_options++; } while (0) -//unused - extern int last_joy_time; //last time the joystick was used +extern int last_joy_time; //last time the joystick was used #ifndef NDEBUG extern int Speedtest_on; #else @@ -154,6 +143,9 @@ void do_multi_player_menu(void); void do_detail_level_menu_custom(void); void do_new_game_menu(void); +extern void ReorderSecondary(); +extern void ReorderPrimary(); + //returns the number of demo files on the disk int newdemo_count_demos(); extern ubyte Version_major,Version_minor; @@ -201,11 +193,12 @@ void autodemo_menu_check(int nitems, newmenu_item * items, int *last_key, int ci gr_printf(grd_curcanv->cv_bitmap.bm_w-w-2,grd_curcanv->cv_bitmap.bm_h-GAME_FONT->ft_h-2,"V%d.%d",Version_major,Version_minor); #endif - //say this is vertigo version - if (cfexist(MISSION_DIR "d2x.hog")) { + #ifdef SANTA //say this is hoard version + if (HoardEquipped()) { gr_set_curfont(MEDIUM2_FONT); - gr_printf(MenuHires?495:248, MenuHires?88:37, "Vertigo"); + gr_printf(MenuHires?495:00,MenuHires?88:44,"Vertigo"); } + #endif WIN(DDGRUNLOCK(dd_grd_curcanv)); } @@ -229,14 +222,11 @@ try_again:; if ((d_rand() % (n_demos+1)) == 0) { - #ifndef SHAREWARE + #if !defined(SHAREWARE) && !defined(NMOVIES) #ifdef WINDOWS mouse_set_mode(1); //re-enable centering mode HideCursorW(); #endif -#ifdef OGL - Screen_mode = -1; -#endif PlayMovie("intro.mve",0); songs_play_song(SONG_TITLE,1); *last_key = -3; //exit menu to force redraw even if not going to game mode. -3 tells menu system not to restore @@ -274,8 +264,6 @@ void create_main_menu(newmenu_item *m, int *menu_choice, int *callers_num_option #ifndef DEMO_ONLY num_options = 0; - set_screen_mode (SCREEN_MENU); - ADD_ITEM(TXT_NEW_GAME,MENU_NEW_GAME,KEY_N); ADD_ITEM(TXT_LOAD_GAME,MENU_LOAD_GAME,KEY_L); @@ -335,8 +323,7 @@ int DoMenu() do { keyd_time_when_last_pressed = timer_get_fixed_seconds(); // .. 20 seconds from now! - if (main_menu_choice < 0 ) - main_menu_choice = 0; + if (main_menu_choice < 0 ) main_menu_choice = 0; Menu_draw_copyright = 1; main_menu_choice = newmenu_do2( "", NULL, num_options, m, autodemo_menu_check, main_menu_choice, Menu_pcx_name); if ( main_menu_choice > -1 ) do_option(menu_choice[main_menu_choice]); @@ -345,7 +332,7 @@ int DoMenu() // if (main_menu_choice != -2) // do_auto_demo = 0; // No more auto demos - if ( Function_mode==FMODE_GAME ) + if ( Function_mode==FMODE_GAME ) gr_palette_fade_out( gr_palette, 32, 0 ); return main_menu_choice; @@ -368,12 +355,13 @@ void do_option ( int select) case MENU_GAME: break; case MENU_DEMO_PLAY: - { - char demo_file[16]; - if (newmenu_get_filename( TXT_SELECT_DEMO, DEMO_DIR "*.dem", demo_file, 1 )) - newdemo_start_playback(demo_file); + { + char demo_file[16]; + if (newmenu_get_filename( TXT_SELECT_DEMO, "demos/*.dem", demo_file, 1 )) { + newdemo_start_playback(demo_file); + } + } break; - } case MENU_LOAD_GAME: state_restore_all(0, 0, NULL); break; @@ -446,18 +434,17 @@ void do_option ( int select) #ifdef NETWORK case MENU_START_IPX_NETGAME: - case MENU_START_TCP_NETGAME: - load_mission(Builtin_mission_num); + load_mission(0); #ifdef MACINTOSH Network_game_type = IPX_GAME; #endif // WIN(ipx_create_read_thread()); network_start_game(); + break; case MENU_JOIN_IPX_NETGAME: - case MENU_JOIN_TCP_NETGAME: - load_mission(Builtin_mission_num); + load_mission(0); #ifdef MACINTOSH Network_game_type = IPX_GAME; #endif @@ -467,7 +454,7 @@ void do_option ( int select) #ifdef MACINTOSH case MENU_START_APPLETALK_NETGAME: - load_mission(Builtin_mission_num); + load_mission(0); #ifdef MACINTOSH Network_game_type = APPLETALK_GAME; #endif @@ -475,27 +462,27 @@ void do_option ( int select) break; case MENU_JOIN_APPLETALK_NETGAME: - load_mission(Builtin_mission_num); + load_mission(0); #ifdef MACINTOSH Network_game_type = APPLETALK_GAME; #endif network_join_game(); break; #endif -#if 0 + case MENU_START_TCP_NETGAME: case MENU_JOIN_TCP_NETGAME: nm_messagebox (TXT_SORRY,1,TXT_OK,"Not available in shareware version!"); // DoNewIPAddress(); break; -#endif + case MENU_START_SERIAL: com_main_menu(); break; case MENU_MULTIPLAYER: do_multi_player_menu(); break; -#endif //NETWORK +#endif case MENU_CONFIG: do_options_menu(); break; @@ -607,7 +594,7 @@ void set_detail_level_parameters(int detail_level) void do_detail_level_menu(void) { int s; - newmenu_item m[8]; + newmenu_item m[7]; m[0].type=NM_TYPE_MENU; m[0].text=MENU_DETAIL_TEXT(0); m[1].type=NM_TYPE_MENU; m[1].text=MENU_DETAIL_TEXT(1); @@ -616,9 +603,8 @@ void do_detail_level_menu(void) m[4].type=NM_TYPE_MENU; m[4].text=MENU_DETAIL_TEXT(4); m[5].type=NM_TYPE_TEXT; m[5].text=""; m[6].type=NM_TYPE_MENU; m[6].text=MENU_DETAIL_TEXT(5); - m[7].type=NM_TYPE_CHECK; m[7].text="Show High Res movies"; m[7].value=MovieHires; - s = newmenu_do1( NULL, TXT_DETAIL_LEVEL , NDL+3, m, NULL, Detail_level); + s = newmenu_do1( NULL, TXT_DETAIL_LEVEL , NDL+2, m, NULL, Detail_level); if (s > -1 ) { switch (s) { @@ -637,7 +623,7 @@ void do_detail_level_menu(void) break; } } - MovieHires = m[7].value; + } // ----------------------------------------------------------------------------- @@ -804,7 +790,7 @@ void set_display_mode(int mode) return; //...don't change #if !defined(MACINTOSH) && !defined(WINDOWS) - if (0) // (mode >= 5 && !FindArg("-superhires")) + if (mode >= 5 && !FindArg("-superhires")) mode = 4; #endif @@ -953,7 +939,7 @@ void do_screen_res_menu() m[5].type=NM_TYPE_RADIO; m[5].value=0; m[5].group=0; m[5].text=" 640x400"; m[6].type=NM_TYPE_RADIO; m[6].value=0; m[6].group=0; m[6].text=" 800x600"; n_items = 7; - if (1) { //(FindArg("-superhires")) { + if (FindArg("-superhires")) { m[7].type=NM_TYPE_RADIO; m[7].value=0; m[7].group=0; m[7].text=" 1024x768"; m[8].type=NM_TYPE_RADIO; m[8].value=0; m[8].group=0; m[8].text=" 1280x1024"; n_items += 2; @@ -1021,17 +1007,17 @@ void do_screen_res_menu() } #endif -#ifdef SHAREWARE + #ifdef SHAREWARE if (i != 0) nm_messagebox(TXT_SORRY, 1, TXT_OK, "High resolution modes are\n" "only available in the\n" "Commercial version of Descent 2."); return; -#else + #else if (i != Current_display_mode) set_display_mode(i); -#endif + #endif } #endif // end of PC version of do_screen_res_menu() @@ -1047,16 +1033,14 @@ void do_new_game_menu() n_missions = build_mission_list(0); - if (n_missions <= 1) { - load_mission(0); - } else { + if (n_missions > 1) { int new_mission_num,i, default_mission; char * m[MAX_MISSIONS]; default_mission = 0; for (i=0;i-1) - { - if(i80) - { - nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for maximum framerate"); - maxfps = 80; - i = (inputs+0); - } - } -#if 0 - else if(i==inputs+2) - cfile_use_alternate_hogdir(thogdir); - else if(i==inputs+4) - { - HUD_max_num_disp = atoi(shudmaxnumdisp); - if(HUD_max_num_disp < 1||HUD_max_num_disp>HUD_MAX_NUM) - { - nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for hud lines"); - HUD_max_num_disp=4; - // i=(inputs+4);//??? - } - } - gr_message_color_level=m[inputs+5].value; - - sprintf(shudmaxnumdisp,"%d",HUD_max_num_disp); -#endif // 0 - sprintf(smaxfps,"%d",maxfps); - // m[inputs+0].text=smaxfps;//redundant.. its not going anywhere -#if 0 - sprintf(thogdir,AltHogDir); - // m[inputs+2].text=thogdir;//redundant -#endif - } - else - break; - } - -#if 0 - write_player_file(); - -#ifdef __MSDOS__ - Joy_is_Sidewinder=m[(checks+0)].value; -#endif -#ifdef __LINUX__ - Joy_is_Sidewinder=0; -#endif -#ifdef SUPPORTS_NICEFPS - use_nice_fps=m[(checks+0)].value; -#else - use_nice_fps=0; -#endif -#endif // 0 -} - -//end edit - Victor Rachels -//end addition - Victor Rachels - - void do_options_menu() { - newmenu_item m[13]; + newmenu_item m[12]; int i = 0; do { @@ -1354,11 +1166,7 @@ void do_options_menu() m[ 5].type = NM_TYPE_TEXT; m[ 5].text=""; #endif #else - m[5].type = NM_TYPE_SLIDER; - m[5].text = TXT_BRIGHTNESS; - m[5].value = gr_palette_get_gamma(); - m[5].min_value = 0; - m[5].max_value = 16; // CCA too dim, was 8; + m[ 5].type = NM_TYPE_SLIDER; m[ 5].text=TXT_BRIGHTNESS; m[5].value=gr_palette_get_gamma();m[5].min_value=0; m[5].max_value=8; #endif @@ -1390,9 +1198,7 @@ void do_options_menu() m[ 9].type = NM_TYPE_MENU; m[ 9].text="Primary autoselect ordering..."; m[10].type = NM_TYPE_MENU; m[10].text="Secondary autoselect ordering..."; m[11].type = NM_TYPE_MENU; m[11].text="Toggles..."; - - m[12].type = NM_TYPE_MENU; m[12].text="D2X options..."; - + i = newmenu_do1( NULL, TXT_OPTIONS, sizeof(m)/sizeof(*m), m, options_menuset, i ); switch(i) { @@ -1404,7 +1210,6 @@ void do_options_menu() case 9: ReorderPrimary(); break; case 10: ReorderSecondary(); break; case 11: do_toggles_menu(); break; - case 12: d2x_options_menu(); break; } } while( i>-1 ); @@ -1483,7 +1288,7 @@ void sound_menuset(int nitems, newmenu_item * items, int *last_key, int citem ) // don't enable redbook for a non-apple demo version of the shareware demo #if !defined(SHAREWARE) || ( defined(SHAREWARE) && defined(APPLE_DEMO) ) - + if (Config_redbook_volume != items[2].value ) { Config_redbook_volume = items[2].value; set_redbook_volume(Config_redbook_volume); @@ -1545,11 +1350,11 @@ void do_sound_menu() do { m[ 0].type = NM_TYPE_SLIDER; m[ 0].text=TXT_FX_VOLUME; m[0].value=Config_digi_volume;m[0].min_value=0; m[0].max_value=8; - m[ 1].type = (Redbook_playing?NM_TYPE_TEXT:NM_TYPE_SLIDER); m[ 1].text="MIDI music volume"; m[1].value=Config_midi_volume;m[1].min_value=0; m[1].max_value=8; + m[ 1].type = (Redbook_playing?NM_TYPE_TEXT:NM_TYPE_SLIDER); m[ 1].text="MIDI music volume"; m[1].value=Config_midi_volume;m[1].min_value=0; m[1].max_value=8; #ifdef WINDOWS if (!wmidi_support_volchange() && !Redbook_playing) { - m[1].type = NM_TYPE_CHECK; + m[1].type = NM_TYPE_CHECK; m[1].text = "MIDI MUSIC"; if (Config_midi_volume) m[1].value = 1; } @@ -1560,13 +1365,13 @@ void do_sound_menu() m[ 3].type = NM_TYPE_TEXT; m[ 3].text=""; m[ 4].type = NM_TYPE_TEXT; m[ 4].text=""; #ifdef MACINTOSH - m[ 3].type = NM_TYPE_SLIDER; m[ 3].text="Sound Manager Volume"; m[3].value=Config_master_volume;m[3].min_value=0; m[3].max_value=8; - + m[ 3].type = NM_TYPE_SLIDER; m[ 3].text="Sound Manager Volume"; m[3].value=Config_master_volume;m[3].min_value=0; m[3].max_value=8; + #ifdef APPLE_DEMO m[ 2].type = (Redbook_playing?NM_TYPE_SLIDER:NM_TYPE_TEXT); m[ 2].text="CD music volume"; m[2].value=Config_redbook_volume;m[2].min_value=0; m[2].max_value=8; m[ 4].type = NM_TYPE_CHECK; m[ 4].text="CD Music (Redbook) enabled"; m[4].value=(Redbook_playing!=0); #endif - + #endif #else // ifdef SHAREWARE @@ -1702,13 +1507,10 @@ void do_multi_player_menu() old_game_mode = Game_mode; num_options = 0; - if (!FindArg("-udp")) { - ADD_ITEM(TXT_START_IPX_NET_GAME, MENU_START_IPX_NETGAME, -1 ); - ADD_ITEM(TXT_JOIN_IPX_NET_GAME, MENU_JOIN_IPX_NETGAME, -1 ); - } else { - ADD_ITEM(TXT_START_TCP_NET_GAME, MENU_START_TCP_NETGAME, -1 ); - ADD_ITEM(TXT_JOIN_TCP_NET_GAME, MENU_JOIN_TCP_NETGAME, -1 ); - } + ADD_ITEM(TXT_START_IPX_NET_GAME, MENU_START_IPX_NETGAME, -1 ); + ADD_ITEM(TXT_JOIN_IPX_NET_GAME, MENU_JOIN_IPX_NETGAME, -1 ); + // ADD_ITEM(TXT_START_TCP_NET_GAME, MENU_START_TCP_NETGAME, -1 ); + // ADD_ITEM(TXT_JOIN_TCP_NET_GAME, MENU_JOIN_TCP_NETGAME, -1 ); #ifdef MACINTOSH ADD_ITEM("Start Appletalk Netgame", MENU_START_APPLETALK_NETGAME, -1 ); @@ -1746,3 +1548,7 @@ void DoNewIPAddress () nm_messagebox (TXT_SORRY,1,TXT_OK,"That address is not valid!"); } + + + + diff --git a/main/menu.h b/main/menu.h index 7593d20e..61fe0c6a 100644 --- a/main/menu.h +++ b/main/menu.h @@ -1,4 +1,3 @@ -/* $Id: menu.h,v 1.6 2003-03-13 22:34:58 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -19,25 +18,36 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //returns number of item chosen extern int DoMenu(); extern void do_options_menu(); -extern void d2x_options_menu(); extern int MenuHires; -#ifdef RELEASE //read only from hog file -#define MENU_PCX_MAC_SHARE ("\x01menub.pcx") -#define MENU_PCX_SHAREWARE ("\x01menud.pcx") -#define MENU_PCX_OEM (MenuHires?"\x01menuob.pcx":"\x01menuo.pcx") -#define MENU_PCX_FULL (MenuHires?"\x01menub.pcx":"\x01menu.pcx") +#ifdef SHAREWARE + #ifdef RELEASE + #ifdef MACINTOSH + #define Menu_pcx_name "\x01menub.pcx" //read only from hog file + #else + #define Menu_pcx_name "\x01menud.pcx" //read only from hog file + #endif + #else +// #define Menu_pcx_name (MenuHires?"menub.pcx":"menud.pcx") //name of background bitmap + #define Menu_pcx_name "menud.pcx" + #endif #else -#define MENU_PCX_MAC_SHARE ("menub.pcx") -#define MENU_PCX_SHAREWARE ("menud.pcx") -#define MENU_PCX_OEM (MenuHires?"menuob.pcx":"menuo.pcx") -#define MENU_PCX_FULL (MenuHires?"menub.pcx":"menu.pcx") + #ifdef D2_OEM + #ifdef RELEASE + #define Menu_pcx_name (MenuHires?"\x01menuob.pcx":"\x01menuo.pcx") //read only from hog file + #else + #define Menu_pcx_name (MenuHires?"menuob.pcx":"menuo.pcx") //name of background bitmap + #endif + #else //Full version + #ifdef RELEASE + #define Menu_pcx_name (MenuHires?"\x01menub.pcx":"\x01menu.pcx") //read only from hog file + #else + #define Menu_pcx_name (MenuHires?"menub.pcx":"menu.pcx") //name of background bitmap + #endif + #endif #endif -//name of background bitmap -#define Menu_pcx_name (cfexist(MENU_PCX_FULL)?MENU_PCX_FULL:(cfexist(MENU_PCX_OEM)?MENU_PCX_OEM:cfexist(MENU_PCX_SHAREWARE)?MENU_PCX_SHAREWARE:MENU_PCX_MAC_SHARE)) - extern void set_detail_level_parameters(int detail_level); extern char *menu_difficulty_text[]; diff --git a/main/mission.c b/main/mission.c index dc122366..47ca4587 100644 --- a/main/mission.c +++ b/main/mission.c @@ -1,4 +1,3 @@ -/* $Id: mission.c,v 1.21 2003-03-14 09:17:08 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,105 +7,19 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/mission.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2002-01-29 10:14:25 $ * - * Code to handle multiple missions - * - * Old Log: - * Revision 1.4 1995/10/31 10:21:40 allender - * no mission support in shareware - * - * Revision 1.3 1995/10/21 22:53:04 allender - * moved missions to data folder - * - * Revision 1.2 1995/09/13 08:47:29 allender - * made to work with Chris' direct stuff - * - * Revision 1.1 1995/05/16 15:27:48 allender - * Initial revision - * - * Revision 2.9 1995/05/26 16:16:32 john - * Split SATURN into define's for requiring cd, using cd, etc. - * Also started adding all the Rockwell stuff. - * - * Revision 2.8 1995/03/20 15:49:31 mike - * Remove eof char from comment which confused make depend, causing - * no mission.obj: line in makefile. Pretty stupid tool, huh? - * - * Revision 2.7 1995/03/20 12:12:11 john - * Added ifdef SATURN. - * - * Revision 2.6 1995/03/15 14:32:49 john - * Added code to force the Descent CD-rom in the drive. - * - * Revision 2.5 1995/03/15 11:41:15 john - * Better Saturn CD-ROM support. - * - * Revision 2.4 1995/03/14 18:24:14 john - * Force Destination Saturn to use CD-ROM drive. - * - * Revision 2.3 1995/03/07 14:19:41 mike - * More destination saturn stuff. - * - * Revision 2.2 1995/03/06 23:09:03 mike - * more saturn stuff: make briefings work for saturn mission. - * - * Revision 2.1 1995/03/06 16:47:48 mike - * destination saturn - * - * Revision 2.0 1995/02/27 11:27:49 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.14 1995/02/15 11:30:37 john - * Fixed bug with potential mem overwrite on line 160. - * - * Revision 1.13 1995/02/10 17:53:20 matt - * Changed mission name again - * - * Revision 1.12 1995/02/10 17:35:38 matt - * Changed name of built-in mission - * - * Revision 1.11 1995/02/07 17:13:51 allender - * removed return statement in load_mission so that built in mission will - * actually set the Current_mission_name and _filename - * - * Revision 1.10 1995/01/31 01:19:45 matt - * Made build_mission_list() sort missions by name - * - * Revision 1.9 1995/01/30 13:49:58 allender - * changed build_mission_list in load_mission_by_name to include - * anarchy levels. - * - * Revision 1.8 1995/01/30 13:03:51 matt - * Fixed dumb mistake - * - * Revision 1.7 1995/01/30 12:55:22 matt - * Added vars to point to mission names - * - * Revision 1.6 1995/01/22 18:57:28 matt - * Made player highest level work with missions - * - * Revision 1.5 1995/01/22 14:13:08 matt - * Added flag in mission list for anarchy-only missions - * - * Revision 1.4 1995/01/21 23:13:12 matt - * Made high scores with (not work, really) with loaded missions - * Don't give player high score when quit game - * - * Revision 1.3 1995/01/21 16:27:12 matt - * Made endlevel briefing work with missions - * - * Revision 1.2 1995/01/20 22:47:50 matt - * Mission system implemented, though imcompletely - * - * Revision 1.1 1995/01/20 13:42:19 matt - * Initial revision + * Stuff for loading missions * + * $Log: not supported by cvs2svn $ * */ @@ -136,159 +49,110 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. mle Mission_list[MAX_MISSIONS]; int Current_mission_num; -int N_secret_levels; // Made a global by MK for scoring purposes. August 1, 1995. +int N_secret_levels; // Made a global by MK for scoring purposes. August 1, 1995. char *Current_mission_filename,*Current_mission_longname; -int Builtin_mission_num; -char Builtin_mission_filename[9]; -int Builtin_mission_hogsize; - -int D1_Builtin_mission_num; -char D1_Builtin_mission_filename[9]; -int D1_Builtin_mission_hogsize; - //this stuff should get defined elsewhere char Level_names[MAX_LEVELS_PER_MISSION][FILENAME_LEN]; char Secret_level_names[MAX_SECRET_LEVELS_PER_MISSION][FILENAME_LEN]; -//values for d1 built-in mission -#define BIM_LAST_LEVEL 27 -#define BIM_LAST_SECRET_LEVEL -3 -#define BIM_BRIEFING_FILE "briefing.tex" -#define BIM_ENDING_FILE "endreg.tex" +//where the missions go +#ifndef EDITOR +#define MISSION_DIR "missions/" +#else +#define MISSION_DIR "./" +#endif + +#ifdef SHAREWARE // -// Special versions of mission routines for d1 builtins +// Special versions of mission routines for shareware // -int load_mission_d1(int mission_num) -{ - int i; +#define SHAREWARE_MISSION_FILENAME "d2demo" +#define SHAREWARE_MISSION_NAME "Descent 2 Demo" - cfile_use_descent1_hogfile("descent.hog"); +int build_mission_list(int anarchy_mode) +{ + anarchy_mode++; //kill warning - Current_mission_num = mission_num; - Current_mission_filename = Mission_list[mission_num].filename; - Current_mission_longname = Mission_list[mission_num].mission_name; - - switch (D1_Builtin_mission_hogsize) { - case D1_SHAREWARE_MISSION_HOGSIZE: - case D1_SHAREWARE_10_MISSION_HOGSIZE: - N_secret_levels = 0; - - Last_level = 7; - Last_secret_level = 0; - - //build level names - for (i=0;i", FULL_MISSION_FILENAME ".mn2"); - } - - strcpy(Builtin_mission_filename, Mission_list[*count].filename); - Mission_list[*count].descent_version = 2; - Mission_list[*count].anarchy_only_flag = 0; - ++(*count); -} - - -void add_missions_to_list(char *search_name, int *count, int anarchy_mode) -{ - FILEFINDSTRUCT find; - if( !FileFindFirst( search_name, &find ) ) { - do { - if (read_mission_file( find.name, *count, ML_MISSIONDIR )) { - - if (anarchy_mode || !Mission_list[*count].anarchy_only_flag) - ++(*count); - } - - } while( !FileFindNext( &find ) && *count < MAX_MISSIONS); - FileFindClose(); - if (*count >= MAX_MISSIONS) - mprintf((0, "Warning: more missions than d2x can handle\n")); - } -} - -/* move to on mission list, increment */ -void promote (char * mission_name, int * top_place, int num_missions) -{ - int i; - char name[FILENAME_LEN], * t; - strcpy(name, mission_name); - if ((t = strchr(name,'.')) != NULL) - *t = 0; //kill extension - //printf("promoting: %s\n", name); - for (i = *top_place; i < num_missions; i++) - if (!stricmp(Mission_list[i].filename, name)) { - //swap mission positions - mle temp; - - temp = Mission_list[*top_place]; - Mission_list[*top_place] = Mission_list[i]; - Mission_list[i] = temp; - ++(*top_place); - break; - } -} - - //fills in the global list of missions. Returns the number of missions //in the list. If anarchy_mode set, don't include non-anarchy levels. +//if there is only one mission, this function will call load_mission on it. extern char CDROM_dir[]; extern char AltHogDir[]; @@ -587,8 +351,9 @@ extern char AltHogdir_initialized; int build_mission_list(int anarchy_mode) { static int num_missions=-1; - int count = 0; - int top_place; + int count=0,special_count=0; + FILEFINDSTRUCT find; + char search_name[PATH_MAX + 5] = MISSION_DIR "*.mn2"; //now search for levels on disk @@ -604,44 +369,69 @@ int build_mission_list(int anarchy_mode) //@@ return num_missions; //@@ } - add_builtin_mission_to_list(&count); //read built-in first - add_d1_builtin_mission_to_list(&count); - add_missions_to_list(MISSION_DIR "*.mn2", &count, anarchy_mode); - add_missions_to_list(MISSION_DIR "*.msn", &count, anarchy_mode); + if (!read_mission_file(BUILTIN_MISSION,0,ML_CURDIR)) //read built-in first + Error("Could not find required mission file <%s>",BUILTIN_MISSION); + + special_count = count=1; + + if( !FileFindFirst( search_name, &find ) ) { + do { + if (stricmp(find.name,BUILTIN_MISSION)==0) + continue; //skip the built-in + + if (read_mission_file(find.name,count,ML_MISSIONDIR)) { + + if (anarchy_mode || !Mission_list[count].anarchy_only_flag) + count++; + } + + } while( !FileFindNext( &find ) && count top_place) - qsort(&Mission_list[top_place], - count - top_place, - sizeof(*Mission_list), - (int (*)( const void *, const void * ))ml_sort_func); + break; + } + } - if (count > top_place) - qsort(&Mission_list[top_place], - count - top_place, - sizeof(*Mission_list), - (int (*)( const void *, const void * ))ml_sort_func); + if (count>special_count) + qsort(&Mission_list[special_count],count-special_count,sizeof(*Mission_list), + (int (*)( const void *, const void * ))ml_sort_func); - //load_mission(0); //set built-in mission as default + load_mission(0); //set built-in mission as default num_missions = count; @@ -652,9 +442,9 @@ void init_extra_robot_movie(char *filename); //values for built-in mission -//loads the specfied mission from the mission list. -//build_mission_list() must have been called. -//Returns true if mission loaded ok, else false. +//loads the specfied mission from the mission list. build_mission_list() +//must have been called. If build_mission_list() returns 0, this function +//does not need to be called. Returns true if mission loaded ok, else false. int load_mission(int mission_num) { CFILE *mfile; @@ -662,65 +452,20 @@ int load_mission(int mission_num) int found_hogfile; int enhanced_mission = 0; - if (mission_num == D1_Builtin_mission_num) { - cfile_use_descent1_hogfile("descent.hog"); - switch (D1_Builtin_mission_hogsize) { - default: - Int3(); // fall through - case D1_MISSION_HOGSIZE: - case D1_10_MISSION_HOGSIZE: - case D1_MAC_MISSION_HOGSIZE: - case D1_OEM_MISSION_HOGSIZE: - case D1_SHAREWARE_MISSION_HOGSIZE: - case D1_SHAREWARE_10_MISSION_HOGSIZE: - case D1_MAC_SHARE_MISSION_HOGSIZE: - return load_mission_d1(mission_num); - break; - } - } - - if (mission_num == Builtin_mission_num) { - switch (Builtin_mission_hogsize) { - case SHAREWARE_MISSION_HOGSIZE: - case MAC_SHARE_MISSION_HOGSIZE: - return load_mission_shareware(mission_num); - break; - case OEM_MISSION_HOGSIZE: - return load_mission_oem(mission_num); - break; - default: - Int3(); // fall through - case FULL_MISSION_HOGSIZE: - case MAC_FULL_MISSION_HOGSIZE: - // continue on... (use d2.mn2 from hogfile) - break; - } - } - Current_mission_num = mission_num; mprintf(( 0, "Loading mission %d\n", mission_num )); - //read mission from file + //read mission from file switch (Mission_list[mission_num].location) { - case ML_MISSIONDIR: - strcpy(buf,MISSION_DIR); - break; - case ML_CDROM: - strcpy(buf,CDROM_dir); - break; - default: - Int3(); //fall through - case ML_CURDIR: - strcpy(buf,""); - break; + case ML_MISSIONDIR: strcpy(buf,MISSION_DIR); break; + case ML_CDROM: strcpy(buf,CDROM_dir); break; + default: Int3(); //fall through + case ML_CURDIR: strcpy(buf,""); break; } strcat(buf,Mission_list[mission_num].filename); - if (Mission_list[mission_num].descent_version == 2) - strcat(buf,".mn2"); - else - strcat(buf,".msn"); + strcat(buf,".mn2"); mfile = cfopen(buf,"rb"); if (mfile == NULL) { @@ -728,8 +473,7 @@ int load_mission(int mission_num) return 0; //error! } - //for non-builtin missions, load HOG - if (strcmp(Mission_list[mission_num].filename, Builtin_mission_filename)) { + if (mission_num != 0) { //for non-builtin missions, load HOG strcpy(buf+strlen(buf)-4,".hog"); //change extension @@ -742,18 +486,11 @@ int load_mission(int mission_num) return 0; } #endif - - // for Descent 1 missions, load descent.hog - if (Mission_list[mission_num].descent_version == 1 && strcmp(buf, "descent.hog")) - if (!cfile_use_descent1_hogfile("descent.hog")) - Warning("descent.hog not available, this mission may be missing some files required for briefings\n"); } //init vars - Last_level = 0; + Last_level = 0; Last_secret_level = 0; - Briefing_text_filename[0] = 0; - Ending_text_filename[0] = 0; while (mfgets(buf,80,mfile)) { @@ -768,7 +505,7 @@ int load_mission(int mission_num) continue; //already have name, go to next line } else if (istok(buf,"type")) - continue; //already have name, go to next line + continue; //already have name, go to next line else if (istok(buf,"hog")) { char *bufp = buf; @@ -782,20 +519,6 @@ int load_mission(int mission_num) cfile_use_alternate_hogfile(bufp); mprintf((0, "Hog file override = [%s]\n", bufp)); } - else if (istok(buf,"briefing")) { - if ((v = get_value(buf)) != NULL) { - add_term(v); - if (strlen(v) < 13) - strcpy(Briefing_text_filename,v); - } - } - else if (istok(buf,"ending")) { - if ((v = get_value(buf)) != NULL) { - add_term(v); - if (strlen(v) < 13) - strcpy(Ending_text_filename,v); - } - } else if (istok(buf,"num_levels")) { if ((v=get_value(buf))!=NULL) { @@ -886,3 +609,7 @@ int load_mission_by_name(char *mission_name) return 0; //couldn't find mission } + +#endif +#endif + diff --git a/main/mission.h b/main/mission.h index 333ed453..1465166f 100644 --- a/main/mission.h +++ b/main/mission.h @@ -1,4 +1,3 @@ -/* $Id: mission.h,v 1.11 2003-03-14 09:17:08 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,106 +7,37 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Header for mission.h - * - * Old Log: - * Revision 1.1 1995/05/16 15:59:22 allender - * Initial revision - * - * Revision 2.0 1995/02/27 11:31:35 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.6 1995/01/30 12:55:41 matt - * Added vars to point to mission names - * - * Revision 1.5 1995/01/22 18:57:21 matt - * Made player highest level work with missions - * - * Revision 1.4 1995/01/22 14:13:21 matt - * Added flag in mission list for anarchy-only missions - * - * Revision 1.3 1995/01/21 23:13:12 matt - * Made high scores with (not work, really) with loaded missions - * Don't give player high score when quit game - * - * Revision 1.2 1995/01/20 22:47:53 matt - * Mission system implemented, though imcompletely - * - * Revision 1.1 1995/01/20 13:42:26 matt - * Initial revision - * - * - */ - #ifndef _MISSION_H #define _MISSION_H #include -#define MAX_MISSIONS 300 -#define MAX_LEVELS_PER_MISSION 30 -#define MAX_SECRET_LEVELS_PER_MISSION 6 -#define MISSION_NAME_LEN 25 - -#define D1_MISSION_FILENAME "descent" -#define D1_MISSION_NAME "Descent: First Strike" -#define D1_MISSION_HOGSIZE 6856701 -#define D1_10_MISSION_HOGSIZE 7261423 -#define D1_MAC_MISSION_HOGSIZE 7456179 -#define D1_OEM_MISSION_NAME "Destination Saturn" -#define D1_OEM_MISSION_HOGSIZE 4492107 -#define D1_SHAREWARE_MISSION_NAME "Descent Demo" -#define D1_SHAREWARE_MISSION_HOGSIZE 2339773 -#define D1_SHAREWARE_10_MISSION_HOGSIZE 2365676 -#define D1_MAC_SHARE_MISSION_HOGSIZE 3370339 - -#define SHAREWARE_MISSION_FILENAME "d2demo" -#define SHAREWARE_MISSION_NAME "Descent 2 Demo" -#define SHAREWARE_MISSION_HOGSIZE 2292566 -#define MAC_SHARE_MISSION_HOGSIZE 4292746 - -#define OEM_MISSION_FILENAME "d2" -#define OEM_MISSION_NAME "D2 Destination:Quartzon" -#define OEM_MISSION_HOGSIZE 6132957 - -#define FULL_MISSION_FILENAME "d2" -#define FULL_MISSION_HOGSIZE 7595079 -#define MAC_FULL_MISSION_HOGSIZE 7110007 +#define MAX_MISSIONS 300 +#define MAX_LEVELS_PER_MISSION 30 +#define MAX_SECRET_LEVELS_PER_MISSION 6 +#define MISSION_NAME_LEN 25 //mission list entry typedef struct mle { - char filename[9]; // path and filename without extension - char mission_name[MISSION_NAME_LEN+1]; - ubyte anarchy_only_flag; // if true, mission is anarchy only - ubyte location; // see defines below - ubyte descent_version; // descent 1 or descent 2? + char filename[9]; //path and filename without extension + char mission_name[MISSION_NAME_LEN+1]; + ubyte anarchy_only_flag; //if true, mission is anarchy only + ubyte location; //see defines below } mle; //values that describe where a mission is located -#define ML_CURDIR 0 -#define ML_MISSIONDIR 1 -#define ML_CDROM 2 - -//where the missions go -#ifndef EDITOR -#define MISSION_DIR "missions/" -#else -#define MISSION_DIR "./" -#endif +#define ML_CURDIR 0 +#define ML_MISSIONDIR 1 +#define ML_CDROM 2 extern mle Mission_list[MAX_MISSIONS]; -extern int Current_mission_num, Builtin_mission_num; +extern int Current_mission_num; extern char *Current_mission_filename,*Current_mission_longname; -extern char Builtin_mission_filename[9]; -extern int Builtin_mission_hogsize; //arrays of name of the level files extern char Level_names[MAX_LEVELS_PER_MISSION][FILENAME_LEN]; diff --git a/main/morph.c b/main/morph.c index e7e350ee..b94689ea 100644 --- a/main/morph.c +++ b/main/morph.c @@ -1,4 +1,3 @@ -/* $Id: morph.c,v 1.3 2003-01-02 23:31:50 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,138 +7,16 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Morphing code - * - * Old Log: - * Revision 1.5 1995/08/23 21:36:10 allender - * mcc compiler warnings fixed - * - * Revision 1.4 1995/08/12 11:34:19 allender - * removed #ifdef NEWDEMO -- always in - * - * Revision 1.3 1995/07/28 15:39:51 allender - * removed fixdiv thing - * - * Revision 1.2 1995/07/28 15:21:23 allender - * inverse magnitude fixup thing - * - * Revision 1.1 1995/05/16 15:28:05 allender - * Initial revision - * - * Revision 2.1 1995/02/27 18:26:33 john - * Fixed bug that was caused by externing Polygon_models, and I had - * changed the type of it in polyobj.c, thus causing page faults. - * - * Revision 2.0 1995/02/27 11:27:44 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.35 1995/02/22 14:45:37 allender - * remove anonymous unions from object structure - * - * Revision 1.34 1995/01/14 19:16:52 john - * First version of new bitmap paging code. - * - * Revision 1.33 1995/01/03 20:38:36 john - * Externed MAX_MORPH_OBJECTS - * - * Revision 1.32 1994/11/17 15:34:04 matt - * Attempt #4 to fix morph bug - * - * Revision 1.31 1994/11/15 10:57:14 matt - * Tried again to fix morph - * - * Revision 1.30 1994/11/14 14:06:45 matt - * Fixed stupid bug - * - * Revision 1.29 1994/11/14 11:55:13 matt - * Added divide overflow check - * - * Revision 1.28 1994/09/26 17:28:14 matt - * Made new multiple-object morph code work with the demo system - * - * Revision 1.27 1994/09/26 15:39:56 matt - * Allow multiple simultaneous morphing objects - * - * Revision 1.26 1994/09/11 22:44:59 mike - * quick on vecmat function. - * - * Revision 1.25 1994/08/26 15:36:00 matt - * Made eclips usable on more than one object at a time - * - * Revision 1.24 1994/07/25 00:02:46 matt - * Various changes to accomodate new 3d, which no longer takes point numbers - * as parms, and now only takes pointers to points. - * - * Revision 1.23 1994/07/12 12:39:58 matt - * Revamped physics system - * - * Revision 1.22 1994/06/28 11:54:51 john - * Made newdemo system record/play directly to/from disk, so - * we don't need the 4 MB buffer anymore. - * - * Revision 1.21 1994/06/27 15:53:01 john - * #define'd out the newdemo stuff - * - * - * Revision 1.20 1994/06/16 14:30:19 matt - * Moved morph record data call to reder routine - * - * Revision 1.19 1994/06/16 13:57:23 matt - * Added support for morphing objects in demos - * - * Revision 1.18 1994/06/16 12:24:23 matt - * Made robot lighting not mess with Lighting_on so robots now night - * according to this variable. - * - * Revision 1.17 1994/06/14 16:55:01 matt - * Got rid of physics_object speed field - * - * Revision 1.16 1994/06/08 21:16:29 matt - * Made objects spin while morphing - * - * Revision 1.15 1994/06/08 18:21:53 matt - * Made morphing objects light correctly - * - * Revision 1.14 1994/06/07 16:50:49 matt - * Made object lighting work correctly; changed name of Ambient_light to - * Dynamic_light; cleaned up polygobj object rendering a little. - * - * Revision 1.13 1994/06/01 16:33:59 yuan - * Fixed bug. - * - * - * Revision 1.12 1994/06/01 16:29:08 matt - * If morph_frame called on object this isn't the morph object, kill it. - * - * Revision 1.11 1994/06/01 12:46:34 matt - * Added needed include - * - * Revision 1.10 1994/05/31 22:12:41 matt - * Set lighting for morph objects - * Don't let another object start morph while one is morphing, unless - * that one dies. - * - * Revision 1.9 1994/05/31 18:49:53 john - * Took out debugging printf's that Matt left in. - * - * Revision 1.8 1994/05/30 22:50:22 matt - * Added morph effect for robots - * - */ - #ifdef HAVE_CONFIG_H #include #endif #ifdef RCS -static char rcsid[] = "$Id: morph.c,v 1.3 2003-01-02 23:31:50 btb Exp $"; +static char rcsid[] = "$Id: morph.c,v 1.2 2001-01-31 15:17:54 bradleyb Exp $"; #endif #include @@ -162,7 +39,6 @@ static char rcsid[] = "$Id: morph.c,v 1.3 2003-01-02 23:31:50 btb Exp $"; #include "mono.h" #include "bm.h" -#include "interp.h" morph_data morph_objects[MAX_MORPH_OBJECTS]; diff --git a/main/movie.c b/main/movie.c index 42836144..3f33a1d5 100644 --- a/main/movie.c +++ b/main/movie.c @@ -1,4 +1,3 @@ -/* $Id: movie.c,v 1.25 2003-03-21 23:13:25 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,56 +7,53 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ +/* + * $Source: /cvs/cvsroot/d2x/main/movie.c,v $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2002-01-18 07:26:54 $ + * + * Movie stuff (converts mve's to exe files, and plays them externally (e.g. with wine) + * + * $Log: not supported by cvs2svn $ + * + */ + #ifdef HAVE_CONFIG_H #include #endif -#ifdef RCS -static char rcsid[] = "$Id: movie.c,v 1.25 2003-03-21 23:13:25 btb Exp $"; -#endif - -#define DEBUG_LEVEL CON_NORMAL - #include -#include -#include -#include #include +#include #include +#include +#include -#include "movie.h" -#include "console.h" +#include "inferno.h" #include "args.h" +#include "movie.h" #include "key.h" -#include "digi.h" #include "songs.h" -#include "inferno.h" -#include "palette.h" #include "strutil.h" +#include "mono.h" #include "error.h" +#include "digi.h" #include "u_mem.h" #include "byteswap.h" -#include "gr.h" -#include "gamefont.h" #include "cfile.h" -#include "menu.h" -#include "libmve.h" -#include "text.h" -#include "fileutil.h" -#include "screens.h" - -extern int MenuHiresAvailable; -extern char CDROM_dir[]; - -#define VID_PLAY 0 -#define VID_PAUSE 1 +#include "gr.h" +#include "palette.h" +#include "newmenu.h" -int Vid_State; +int RoboFile=0,MVEPaletteCalls=0; +// Function Prototypes +int RunMovie(char *filename, int highres_flag, int allow_abort,int dx,int dy); // Subtitle data typedef struct { @@ -65,60 +61,14 @@ typedef struct { char *msg; } subtitle; + +// #define BUFFER_MOVIE + #define MAX_SUBTITLES 500 -#define MAX_ACTIVE_SUBTITLES 3 subtitle Subtitles[MAX_SUBTITLES]; int Num_subtitles; - -// Movielib data -typedef struct { - char name[FILENAME_LEN]; - int offset,len; -} ml_entry; - -#define MLF_ON_CD 1 -#define MAX_MOVIES_PER_LIB 50 //determines size of malloc - -typedef struct { - char name[100]; //[FILENAME_LEN]; - int n_movies; - ubyte flags,pad[3]; - ml_entry *movies; -} movielib; - -#ifdef D2_OEM -char movielib_files[][FILENAME_LEN] = {"intro-l.mvl","other-l.mvl","robots-l.mvl","oem-l.mvl"}; -#else -char movielib_files[][FILENAME_LEN] = {"intro-l.mvl","other-l.mvl","robots-l.mvl"}; -#endif - -#define N_BUILTIN_MOVIE_LIBS (sizeof(movielib_files)/sizeof(*movielib_files)) -#define N_MOVIE_LIBS (N_BUILTIN_MOVIE_LIBS+1) -#define EXTRA_ROBOT_LIB N_BUILTIN_MOVIE_LIBS -movielib *movie_libs[N_MOVIE_LIBS]; - - -//do we have the robot movies available -int robot_movies = 0; //0 means none, 1 means lowres, 2 means hires - -int MovieHires = 1; //default is highres - -int RoboFile = 0, RoboFilePos = 0; - -// Function Prototypes -int RunMovie(char *filename, int highres_flag, int allow_abort,int dx,int dy); - -int open_movie_file(char *filename,int must_have); -int reset_movie_file(int handle); - -void change_filename_ext( char *dest, char *src, char *ext ); -void decode_text_line(char *p); -void draw_subtitles(int frame_num); - - -//----------------------------------------------------------------------- - +int MovieHires = 0; //default for now is lores //filename will actually get modified to be either low-res or high-res //returns status. see values in movie.h @@ -148,268 +98,140 @@ int PlayMovie(const char *filename, int must_have) // Stop all songs songs_stop_all(); - digi_close(); - - // Start sound - if (!FindArg("-nosound")) - MVE_sndInit(1); - else - MVE_sndInit(-1); - ret = RunMovie(name,MovieHires,must_have,-1,-1); - if (!FindArg("-nosound")) - digi_init(); - - Screen_mode = -1; //force screen reset - return ret; } - - -#if 0 -typedef struct bkg { - short x, y, w, h; // The location of the menu. - grs_bitmap * bmp; // The background under the menu. -} bkg; - -bkg movie_bg = {0,0,0,0,NULL}; -#endif - -#define BOX_BORDER (MenuHires?40:20) - - -void show_pause_message(char *msg) -{ - int w,h,aw; - int x,y; - - gr_set_current_canvas(NULL); - gr_set_curfont( SMALL_FONT ); - - gr_get_string_size(msg,&w,&h,&aw); - - x = (grd_curscreen->sc_w-w)/2; - y = (grd_curscreen->sc_h-h)/2; - -#if 0 - if (movie_bg.bmp) { - gr_free_bitmap(movie_bg.bmp); - movie_bg.bmp = NULL; - } - - // Save the background of the display - movie_bg.x=x; movie_bg.y=y; movie_bg.w=w; movie_bg.h=h; - - movie_bg.bmp = gr_create_bitmap( w+BOX_BORDER, h+BOX_BORDER ); - - gr_bm_ubitblt(w+BOX_BORDER, h+BOX_BORDER, 0, 0, x-BOX_BORDER/2, y-BOX_BORDER/2, &(grd_curcanv->cv_bitmap), movie_bg.bmp ); -#endif - - gr_setcolor(0); - gr_rect(x-BOX_BORDER/2,y-BOX_BORDER/2,x+w+BOX_BORDER/2-1,y+h+BOX_BORDER/2-1); - - gr_set_fontcolor( 255, -1 ); - - gr_ustring( 0x8000, y, msg ); - - gr_update(); -} - -void clear_pause_message() -{ -#if 0 - if (movie_bg.bmp) { - - gr_bitmap(movie_bg.x-BOX_BORDER/2, movie_bg.y-BOX_BORDER/2, movie_bg.bmp); - - gr_free_bitmap(movie_bg.bmp); - movie_bg.bmp = NULL; - } -#endif -} - + +int open_movie_file(char *filename,int must_have, int *lenp); //returns status. see movie.h int RunMovie(char *filename, int hires_flag, int must_have,int dx,int dy) { - int filehndl; - int result=1,aborted=0; - int track = 0; - int frame_num; - int key; -#ifdef OGL - char pal_save[768]; -#endif - - result=1; + int filehndl, size; + int aborted=0; // Open Movie file. If it doesn't exist, no movie, just return. - filehndl = open_movie_file(filename,must_have); + filehndl = open_movie_file(filename,must_have, &size); if (filehndl == -1) { +#ifndef EDITOR if (must_have) - Warning("movie: RunMovie: Cannot open movie <%s>\n",filename); + { + strupr(filename); + Error("Cannot open movie file <%s>",filename); + } + else + return MOVIE_NOT_PLAYED; +#else return MOVIE_NOT_PLAYED; - } - - if (hires_flag) { - gr_set_mode(SM(640,480)); - } else { - gr_set_mode(SM(320,200)); - } -#ifdef OGL - set_screen_mode(SCREEN_MENU); - gr_copy_palette(pal_save, gr_palette, 768); - memset(gr_palette, 0, 768); - gr_palette_load(gr_palette); #endif - - if (MVE_rmPrepMovie(filehndl, dx, dy, track)) { - Int3(); - return MOVIE_NOT_PLAYED; } - frame_num = 0; - - FontHires = FontHiresAvailable && hires_flag; - - while((result = MVE_rmStepMovie()) == 0) { - - draw_subtitles(frame_num); - - gr_update(); - - key = key_inkey(); +#if 0 + if (hires_flag) + gr_set_mode(SM_640x480V); + else + gr_set_mode(SM_320x200C); +#endif - // If ESCAPE pressed, then quit movie. - if (key == KEY_ESC) { - result = aborted = 1; - break; + // play! + { + char *buf; + int len; + FILE *fil; + struct stat stats; + char *stubfile; + char *execcmd; + + strcpy(filename+strlen(filename)-4,".exe"); //change extension + if (stat(filename, &stats)) { + stubfile = "fstrailw.stub"; + if (stat(stubfile, &stats)) { + con_printf(CON_NORMAL, "Error loading %s, aborting movie.\n", stubfile); + return MOVIE_NOT_PLAYED; + } + + len = stats.st_size; + buf = d_malloc(len); + fil = fopen(stubfile, "r"); + fread(buf, len, 1, fil); + fclose(fil); + + fil = fopen(filename, "w"); + fwrite(buf, len, 1, fil); + d_free(buf); + + len = size; + buf = d_malloc(len); + read(filehndl, buf, len); + fwrite(buf, len, 1, fil); + d_free(buf); + fclose(fil); } - - // If PAUSE pressed, then pause movie - if (key == KEY_PAUSE) { - MVE_rmHoldMovie(); - show_pause_message(TXT_PAUSE); - while (!key_inkey()) ; - clear_pause_message(); + sprintf(execcmd, "wine %s", filename); + if(system(execcmd) == -1) { + con_printf(CON_NORMAL, "Error executing %s, movie aborted.\n", filename); + return MOVIE_NOT_PLAYED; } + -#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE - if ((key == KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER) || - (key == KEY_ALTED+KEY_CTRLED+KEY_PADENTER) || - (key == KEY_ALTED+KEY_SHIFTED+KEY_PADENTER)) - gr_toggle_fullscreen(); -#endif - - frame_num++; } - Assert(aborted || result == MVE_ERR_EOF); ///movie should be over - - MVE_rmEndMovie(); - close(filehndl); // Close Movie File - - // Restore old graphic state - - Screen_mode=-1; //force reset of screen mode -#ifdef OGL - gr_copy_palette(gr_palette, pal_save, 768); - gr_palette_load(pal_save); -#endif - + + Screen_mode=-1; //force reset of screen mode + return (aborted?MOVIE_ABORTED:MOVIE_PLAYED_FULL); } - -int InitMovieBriefing() +int InitMovieBriefing () { -#if 0 - if (MenuHires) - gr_set_mode(SM(640,480)); - else - gr_set_mode(SM(320,200)); - - gr_init_sub_canvas( &VR_screen_pages[0], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h ); - gr_init_sub_canvas( &VR_screen_pages[1], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h ); -#endif - return 1; } - //returns 1 if frame updated ok -int RotateRobot() +int RotateRobot () { - int err; - - err = MVE_rmStepMovie(); - - if (err == MVE_ERR_EOF) //end of movie, so reset - { - reset_movie_file(RoboFile); - if (MVE_rmPrepMovie(RoboFile, MenuHires?280:140, MenuHires?200:80, 0)) { - Int3(); - return 0; - } - } - else if (err) { - Int3(); - return 0; - } - return 1; } - -void DeInitRobotMovie(void) +void DeInitRobotMovie() { - MVE_rmEndMovie(); close(RoboFile); // Close Movie File } - -int InitRobotMovie(char *filename) +int InitRobotMovie (char *filename) { + int len; + if (FindArg("-nomovies")) - return 0; + return MOVIE_NOT_PLAYED; - con_printf(DEBUG_LEVEL, "RoboFile=%s\n", filename); +// digi_stop_all(); - MVE_sndInit(-1); //tell movies to play no sound for robots + mprintf ((0,"RoboFile=%s\n",filename)); - RoboFile = open_movie_file(filename, 1); + RoboFile = open_movie_file(filename,1, &len); if (RoboFile == -1) { - Warning("movie: InitRobotMovie: Cannot open movie file <%s>",filename); - return MOVIE_NOT_PLAYED; + #ifdef RELEASE + Error("Cannot open movie file <%s>",filename); + #else + return MOVIE_NOT_PLAYED; + #endif } - - Vid_State = VID_PLAY; - - if (MVE_rmPrepMovie(RoboFile, MenuHires?280:140, MenuHires?200:80, 0)) { - Int3(); - return 0; - } - - RoboFilePos=lseek (RoboFile,0L,SEEK_CUR); - - con_printf(DEBUG_LEVEL, "RoboFilePos=%d!\n", RoboFilePos); - + return 1; } - /* * Subtitle system code */ ubyte *subtitle_raw_data; - //search for next field following whitespace ubyte *next_field(ubyte *p) { @@ -428,6 +250,8 @@ ubyte *next_field(ubyte *p) return p; } +void change_filename_ext( char *dest, char *src, char *ext ); +void decode_text_line(char *p); int init_subtitles(char *filename) { @@ -453,17 +277,17 @@ int init_subtitles(char *filename) } size = cfilelength(ifile); + + MALLOC (subtitle_raw_data, ubyte, size+1); - MALLOC (subtitle_raw_data, ubyte, size+1); - - read_count = cfread(subtitle_raw_data, 1, size, ifile); + read_count = cfread(subtitle_raw_data, 1, size, ifile); cfclose(ifile); subtitle_raw_data[size] = 0; if (read_count != size) { - d_free(subtitle_raw_data); + free(subtitle_raw_data); return 0; } @@ -500,71 +324,32 @@ int init_subtitles(char *filename) } return 1; -} +} void close_subtitles() { if (subtitle_raw_data) - d_free(subtitle_raw_data); + free(subtitle_raw_data); subtitle_raw_data = NULL; Num_subtitles = 0; } +typedef struct { + char name[FILENAME_LEN]; + int offset,len; +} ml_entry; -//draw the subtitles for this frame -void draw_subtitles(int frame_num) -{ - static int active_subtitles[MAX_ACTIVE_SUBTITLES]; - static int num_active_subtitles,next_subtitle,line_spacing; - int t,y; - int must_erase=0; - - if (frame_num == 0) { - num_active_subtitles = 0; - next_subtitle = 0; - gr_set_curfont( GAME_FONT ); - line_spacing = grd_curcanv->cv_font->ft_h + (grd_curcanv->cv_font->ft_h >> 2); - gr_set_fontcolor(255,-1); - } - - //get rid of any subtitles that have expired - for (t=0;t Subtitles[active_subtitles[t]].last_frame) { - int t2; - for (t2=t;t2= Subtitles[next_subtitle].first_frame) { - if (num_active_subtitles >= MAX_ACTIVE_SUBTITLES) - Error("Too many active subtitles!"); - active_subtitles[num_active_subtitles++] = next_subtitle; - next_subtitle++; - } - - //find y coordinate for first line of subtitles - y = grd_curcanv->cv_bitmap.bm_h-((line_spacing+1)*MAX_ACTIVE_SUBTITLES+2); - - //erase old subtitles if necessary - if (must_erase) { - gr_setcolor(0); - gr_rect(0,y,grd_curcanv->cv_bitmap.bm_w-1,grd_curcanv->cv_bitmap.bm_h-1); - } +#define MLF_ON_CD 0 - //now draw the current subtitles - for (t=0;tmovies, ml_entry, nfiles); + table = malloc(sizeof(*table) + sizeof(ml_entry)*nfiles); strcpy(table->name,filename); table->n_movies = nfiles; @@ -592,9 +375,11 @@ movielib *init_new_movie_lib(char *filename,FILE *fp) if ( n != 1 ) break; //end of file (probably) - len = file_read_int(fp); + n = fread( &len, 4, 1, fp ); + if ( n != 1 ) + Error("error reading movie library <%s>",filename); - table->movies[i].len = len; + table->movies[i].len = INTEL_INT(len); table->movies[i].offset = offset; offset += table->movies[i].len; @@ -609,7 +394,6 @@ movielib *init_new_movie_lib(char *filename,FILE *fp) } - movielib *init_old_movie_lib(char *filename,FILE *fp) { int nfiles,size; @@ -619,7 +403,7 @@ movielib *init_old_movie_lib(char *filename,FILE *fp) nfiles = 0; //allocate big table - table = d_malloc(sizeof(*table) + sizeof(ml_entry)*MAX_MOVIES_PER_LIB); + table = malloc(sizeof(*table) + sizeof(ml_entry)*MAX_MOVIES_PER_LIB); while( 1 ) { int len; @@ -642,9 +426,9 @@ movielib *init_old_movie_lib(char *filename,FILE *fp) //allocate correct-sized table size = sizeof(*table) + sizeof(ml_entry)*nfiles; - table2 = d_malloc(size); + table2 = malloc(size); memcpy(table2,table,size); - d_free(table); + free(table); table = table2; strcpy(table->name,filename); @@ -659,26 +443,16 @@ movielib *init_old_movie_lib(char *filename,FILE *fp) } - -//find the specified movie library, and read in list of movies in it +//find the specified movie library, and read in list of movies in it movielib *init_movie_lib(char *filename) { //note: this based on cfile_init_hogfile() char id[4]; FILE * fp; - + fp = fopen( filename, "rb" ); - - if ((fp == NULL) && (AltHogdir_initialized)) { - char temp[128]; - strcpy(temp, AltHogDir); - strcat(temp, "/"); - strcat(temp, filename); - fp = fopen(temp, "rb"); - } - - if ( fp == NULL ) + if ( fp == NULL ) return NULL; fread( id, 4, 1, fp ); @@ -694,16 +468,23 @@ movielib *init_movie_lib(char *filename) } } +#ifdef D2_OEM +char *movielib_files[] = {"intro-l.mvl","other-l.mvl","robots-l.mvl","oem-l.mvl"}; +#else +char *movielib_files[] = {"intro-l.mvl","other-l.mvl","robots-l.mvl"}; +#endif + +#define N_BUILTIN_MOVIE_LIBS (sizeof(movielib_files)/sizeof(*movielib_files)) +#define N_MOVIE_LIBS (N_BUILTIN_MOVIE_LIBS+1) +#define EXTRA_ROBOT_LIB N_BUILTIN_MOVIE_LIBS +movielib *movie_libs[N_MOVIE_LIBS]; void close_movie(int i) { - if (movie_libs[i]) { - d_free(movie_libs[i]->movies); - d_free(movie_libs[i]); - } + if (movie_libs[i]) + free(movie_libs[i]); } - void close_movies() { int i; @@ -712,13 +493,20 @@ void close_movies() close_movie(i); } +#include "gamepal.h" + +extern char CDROM_dir[]; +extern int MenuHiresAvailable; + +extern ubyte last_palette_for_color_fonts[]; + +extern int force_rb_register; //ask user to put the D2 CD in. //returns -1 if ESC pressed, 0 if OK chosen //CD may not have been inserted -int request_cd(void) +int request_cd() { -#if 0 ubyte save_pal[256*3]; grs_canvas *save_canv,*tcanv; int ret,was_faded=gr_palette_faded_out; @@ -733,12 +521,12 @@ int request_cd(void) gr_set_current_canvas(save_canv); gr_clear_canvas(BM_XRGB(0,0,0)); - + memcpy(save_pal,gr_palette,sizeof(save_pal)); memcpy(gr_palette,last_palette_for_color_fonts,sizeof(gr_palette)); - try_again:; +try_again:; ret = nm_messagebox( "CD ERROR", 1, "Ok", "Please insert your Descent II CD"); @@ -751,12 +539,12 @@ int request_cd(void) goto try_again; } - force_rb_register = 1; //disc has changed; force register new CD - + force_rb_register = 1; //disc has changed; force register new CD + gr_palette_clear(); memcpy(gr_palette,save_pal,sizeof(save_pal)); - + gr_ubitmap(0,0,&tcanv->cv_bitmap); if (!was_faded) @@ -765,24 +553,21 @@ int request_cd(void) gr_free_canvas(tcanv); return ret; -#else - con_printf(DEBUG_LEVEL, "STUB: movie: request_cd\n"); - return 0; -#endif } +//do we have the robot movies available +int robot_movies=0; //0 means none, 1 means lowres, 2 means hires void init_movie(char *filename,int libnum,int is_robots,int required) { int high_res; - int try = 0; -#ifndef RELEASE + #ifndef RELEASE if (FindArg("-nomovies")) { movie_libs[libnum] = NULL; return; } -#endif + #endif //for robots, load highres versions if highres menus set if (is_robots) @@ -793,11 +578,13 @@ void init_movie(char *filename,int libnum,int is_robots,int required) if (high_res) strchr(filename,'.')[-1] = 'h'; +#if defined(D2_OEM) try_again:; +#endif if ((movie_libs[libnum] = init_movie_lib(filename)) == NULL) { char name2[100]; - + strcpy(name2,CDROM_dir); strcat(name2,filename); movie_libs[libnum] = init_movie_lib(name2); @@ -806,24 +593,23 @@ try_again:; movie_libs[libnum]->flags |= MLF_ON_CD; else { if (required) { - Warning("Cannot open movie file <%s>\n",filename); + #if defined(RELEASE) && !defined(D2_OEM) //allow no movies if not release + strupr(filename); + Error("Cannot open movie file <%s>",filename); + #endif } - - if (!try) { // first try - if (strchr(filename, '.')[-1] == 'h') { // try again with lowres - strchr(filename, '.')[-1] = 'l'; - high_res = 0; - Warning("Trying to open movie file <%s> instead\n", filename); - try++; - goto try_again; - } else if (strchr(filename, '.')[-1] == 'l') { // try again with highres - strchr(filename, '.')[-1] = 'h'; - high_res = 1; - Warning("Trying to open movie file <%s> instead\n", filename); - try++; - goto try_again; - } + #if defined(D2_OEM) //if couldn't get higres, try low + if (is_robots == 1) { //first try, try again with lowres + strchr(filename,'.')[-1] = 'l'; + high_res = 0; + is_robots++; + goto try_again; } + else if (is_robots == 2) { //failed twice. bail with error + strupr(filename); + Error("Cannot open movie file <%s>",filename); + } + #endif } } @@ -831,7 +617,6 @@ try_again:; robot_movies = high_res?2:1; } - //find and initialize the movie libraries void init_movies() { @@ -851,8 +636,8 @@ void init_movies() movie_libs[EXTRA_ROBOT_LIB] = NULL; atexit(close_movies); -} +} void init_extra_robot_movie(char *filename) { @@ -860,12 +645,11 @@ void init_extra_robot_movie(char *filename) init_movie(filename,EXTRA_ROBOT_LIB,1,0); } - int movie_handle,movie_start; //looks through a movie library for a movie file //returns filehandle, with fileposition at movie, or -1 if can't find -int search_movie_lib(movielib *lib,char *filename,int must_have) +int search_movie_lib(movielib *lib,char *filename,int must_have, int *lenp) { int i; int filehandle; @@ -877,6 +661,8 @@ int search_movie_lib(movielib *lib,char *filename,int must_have) if (!stricmp(filename,lib->movies[i].name)) { //found the movie in a library int from_cd; + *lenp = lib->movies[i].len; + from_cd = (lib->flags & MLF_ON_CD); if (from_cd) @@ -884,23 +670,7 @@ int search_movie_lib(movielib *lib,char *filename,int must_have) do { //keep trying until we get the file handle -#ifdef O_BINARY - movie_handle = filehandle = open(lib->name, O_RDONLY | O_BINARY); -#else movie_handle = filehandle = open(lib->name, O_RDONLY); -#endif - - if ((filehandle == -1) && (AltHogdir_initialized)) { - char temp[128]; - strcpy(temp, AltHogDir); - strcat(temp, "/"); - strcat(temp, lib->name); -#ifdef O_BINARY - movie_handle = filehandle = open(temp, O_RDONLY | O_BINARY); -#else - movie_handle = filehandle = open(temp, O_RDONLY); -#endif - } if (must_have && from_cd && filehandle == -1) { //didn't get file! @@ -919,26 +689,16 @@ int search_movie_lib(movielib *lib,char *filename,int must_have) return -1; } - //returns file handle -int open_movie_file(char *filename,int must_have) +int open_movie_file(char *filename,int must_have, int *lenp) { int filehandle,i; for (i=0;i= N_players) || (owner < -1)) { Int3(); // Illegal! @@ -284,7 +290,7 @@ int objnum_remote_to_local(int remote_objnum, int owner) if (owner == -1) return(remote_objnum); - + if ((remote_objnum < 0) || (remote_objnum >= MAX_OBJECTS)) return(-1); @@ -301,8 +307,8 @@ int objnum_remote_to_local(int remote_objnum, int owner) { mprintf((1, "Remote object owner %d number %d doesn't match owner %d.\n", owner, remote_objnum, object_owner[result])); } -#endif - //Assert(object_owner[result] == owner); +#endif +// Assert(object_owner[result] == owner); return(result); } @@ -328,11 +334,11 @@ int objnum_local_to_remote(int local_objnum, byte *owner) *owner = -1; return local_objnum; } - + result = local_to_remote[local_objnum]; - - //mprintf((0, "Local object %d mapped to owner %d objnum %d.\n", local_objnum, - // *owner, result)); + +// mprintf((0, "Local object %d mapped to owner %d objnum %d.\n", local_objnum, +// *owner, result)); if (result < 0) { @@ -386,7 +392,7 @@ map_objnum_local_to_local(int local_objnum) void multi_endlevel_score(void) { - int old_connect=0; + int old_connect=0; int i; // Show a score list to end of net players @@ -397,9 +403,9 @@ multi_endlevel_score(void) { old_connect = Players[Player_num].connected; if (Players[Player_num].connected!=3) - Players[Player_num].connected = CONNECT_END_MENU; + Players[Player_num].connected = CONNECT_END_MENU; Network_status = NETSTAT_ENDLEVEL; - + } #endif @@ -407,7 +413,7 @@ multi_endlevel_score(void) Function_mode = FMODE_MENU; - kmatrix_view(Game_mode & GM_NETWORK); + kmatrix_view(Game_mode & GM_NETWORK); Function_mode = FMODE_GAME; @@ -415,30 +421,30 @@ multi_endlevel_score(void) if (Game_mode & GM_NETWORK) { - Players[Player_num].connected = old_connect; + Players[Player_num].connected = old_connect; } #ifndef SHAREWARE if (Game_mode & GM_MULTI_COOP) { - int i; + int i; for (i = 0; i < MaxNumNetPlayers; i++) - // Reset keys + // Reset keys Players[i].flags &= ~(PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY); } for (i = 0; i < MaxNumNetPlayers; i++) - Players[i].flags &= ~(PLAYER_FLAGS_FLAG); // Clear capture flag - + Players[i].flags &= ~(PLAYER_FLAGS_FLAG); // Clear capture flag + #endif - for (i=0;i= MAX_NUM_NET_PLAYERS) || (playernum < 0)) { @@ -593,17 +599,17 @@ int multi_get_kill_list(int *plist) int n = 0; for (i = 0; i < N_players; i++) - //if (Players[sorted_kills[i]].connected) - plist[n++] = sorted_kills[i]; +// if (Players[sorted_kills[i]].connected) + plist[n++] = sorted_kills[i]; if (n == 0) Int3(); // SEE ROB OR MATT - //memcpy(plist, sorted_kills, N_players*sizeof(int)); +// memcpy(plist, sorted_kills, N_players*sizeof(int)); return(n); } - + void multi_sort_kill_list(void) { @@ -612,7 +618,7 @@ multi_sort_kill_list(void) int kills[MAX_NUM_NET_PLAYERS]; int i; int changed = 1; - + for (i = 0; i < MAX_NUM_NET_PLAYERS; i++) { #ifndef SHAREWARE @@ -621,13 +627,13 @@ multi_sort_kill_list(void) else #endif if (Show_kill_list==2) - { - if (Players[i].net_killed_total+Players[i].net_kills_total==0) - kills[i]=-1; // always draw the ones without any ratio last - else - kills[i]=(int)((float)((float)Players[i].net_kills_total/((float)Players[i].net_killed_total+(float)Players[i].net_kills_total))*100.0); - } - else + { + if (Players[i].net_killed_total+Players[i].net_kills_total==0) + kills[i]=-1; // always draw the ones without any ratio last + else + kills[i]=(int)((float)((float)Players[i].net_kills_total/((float)Players[i].net_killed_total+(float)Players[i].net_kills_total))*100.0); + } + else kills[i] = Players[i].net_kills_total; } @@ -645,7 +651,7 @@ multi_sort_kill_list(void) } } } - mprintf((0, "Sorted kills %d %d.\n", sorted_kills[0], sorted_kills[1])); + mprintf((0, "Sorted kills %d %d.\n", sorted_kills[0], sorted_kills[1])); } extern object *obj_find_first_of_type (int); @@ -663,9 +669,9 @@ void multi_compute_kill(int killer, int killed) char killer_name[(CALLSIGN_LEN*2)+4]; kmatrix_kills_changed = 1; - Multi_killed_yourself=0; - - // Both object numbers are localized already! + Multi_killed_yourself=0; + + // Both object numbers are localized already! mprintf((0, "compute_kill passed: object %d killed object %d.\n", killer, killed)); @@ -677,9 +683,9 @@ void multi_compute_kill(int killer, int killed) killed_type = Objects[killed].type; killer_type = Objects[killer].type; - killer_id = Objects[killer].id; + killer_id = Objects[killer].id; - if ((killed_type != OBJ_PLAYER) && (killed_type != OBJ_GHOST)) + if ((killed_type != OBJ_PLAYER) && (killed_type != OBJ_GHOST)) { Int3(); // compute_kill passed non-player object! return; @@ -687,7 +693,7 @@ void multi_compute_kill(int killer, int killed) killed_pnum = Objects[killed].id; - PKilledFlags[killed_pnum]=1; + PKilledFlags[killed_pnum]=1; Assert ((killed_pnum >= 0) && (killed_pnum < N_players)); @@ -701,8 +707,8 @@ void multi_compute_kill(int killer, int killed) digi_play_sample( SOUND_HUD_KILL, F3_0 ); - if (Control_center_destroyed) - Players[killed_pnum].connected=3; + if (Control_center_destroyed) + Players[killed_pnum].connected=3; if (killer_type == OBJ_CNTRLCEN) { @@ -713,37 +719,37 @@ void multi_compute_kill(int killer, int killed) newdemo_record_multi_kill(killed_pnum, -1); if (killed_pnum == Player_num) - { + { HUD_init_message("%s %s.", TXT_YOU_WERE, TXT_KILLED_BY_NONPLAY); multi_add_lifetime_killed (); - } + } else HUD_init_message("%s %s %s.", killed_name, TXT_WAS, TXT_KILLED_BY_NONPLAY ); - return; + return; } #ifndef SHAREWARE else if ((killer_type != OBJ_PLAYER) && (killer_type != OBJ_GHOST)) { - if (killer_id==PMINE_ID && killer_type!=OBJ_ROBOT) - { - if (killed_pnum == Player_num) + if (killer_id==PMINE_ID && killer_type!=OBJ_ROBOT) + { + if (killed_pnum == Player_num) HUD_init_message("You were killed by a mine!"); else HUD_init_message("%s was killed by a mine!",killed_name); - } + } else - { - if (killed_pnum == Player_num) - { - HUD_init_message("%s %s.", TXT_YOU_WERE, TXT_KILLED_BY_ROBOT); + { + if (killed_pnum == Player_num) + { + HUD_init_message("%s %s.", TXT_YOU_WERE, TXT_KILLED_BY_ROBOT); multi_add_lifetime_killed(); - } - else + } + else HUD_init_message("%s %s %s.", killed_name, TXT_WAS, TXT_KILLED_BY_ROBOT ); - } + } Players[killed_pnum].net_killed_total++; - return; + return; } #else else if ((killer_type != OBJ_PLAYER) && (killer_type != OBJ_GHOST) && (killer_id!=PMINE_ID)) @@ -751,17 +757,17 @@ void multi_compute_kill(int killer, int killed) Int3(); // Illegal killer type? return; } - if (killer_id==PMINE_ID) - { - if (killed_pnum==Player_num) - HUD_init_message("You were killed by a mine!"); - else - HUD_init_message("%s was killed by a mine!",killed_name); - - Players[killed_pnum].net_killed_total++; - - return; - } + if (killer_id==PMINE_ID) + { + if (killed_pnum==Player_num) + HUD_init_message("You were killed by a mine!"); + else + HUD_init_message("%s was killed by a mine!",killed_name); + + Players[killed_pnum].net_killed_total++; + + return; + } #endif killer_pnum = Objects[killer].id; @@ -780,7 +786,7 @@ void multi_compute_kill(int killer, int killed) if (killer_pnum == killed_pnum) { - if (!(Game_mode & GM_HOARD)) + if (!(Game_mode & GM_HOARD)) { if (Game_mode & GM_TEAM) team_kills[get_team(killed_pnum)] -= 1; @@ -794,11 +800,11 @@ void multi_compute_kill(int killer, int killed) kill_matrix[killed_pnum][killed_pnum] += 1; // # of suicides if (killer_pnum == Player_num) - { - HUD_init_message("%s %s %s!", TXT_YOU, TXT_KILLED, TXT_YOURSELF ); - Multi_killed_yourself=1; + { + HUD_init_message("%s %s %s!", TXT_YOU, TXT_KILLED, TXT_YOURSELF ); + Multi_killed_yourself=1; multi_add_lifetime_killed(); - } + } else HUD_init_message("%s %s", killed_name, TXT_SUICIDE); } @@ -829,7 +835,7 @@ void multi_compute_kill(int killer, int killed) Multi_killed_yourself=1; } } - + kill_matrix[killer_pnum][killed_pnum] += 1; Players[killed_pnum].net_killed_total += 1; if (killer_pnum == Player_num) { @@ -839,50 +845,50 @@ void multi_compute_kill(int killer, int killed) add_points_to_score(-1000); } else if (killed_pnum == Player_num) - { + { HUD_init_message("%s %s %s!", killer_name, TXT_KILLED, TXT_YOU); multi_add_lifetime_killed(); - if (Game_mode & GM_HOARD) - { + if (Game_mode & GM_HOARD) + { if (Players[Player_num].secondary_ammo[PROXIMITY_INDEX]>3) multi_send_play_by_play (1,killer_pnum,Player_num); else if (Players[Player_num].secondary_ammo[PROXIMITY_INDEX]>0) multi_send_play_by_play (0,killer_pnum,Player_num); - } - } + } + } else HUD_init_message("%s %s %s!", killer_name, TXT_KILLED, killed_name); } - TheGoal=Netgame.KillGoal*5; + TheGoal=Netgame.KillGoal*5; - if (Netgame.KillGoal>0) + if (Netgame.KillGoal>0) { - if (Players[killer_pnum].KillGoalCount>=TheGoal) - { - if (killer_pnum==Player_num) - { - HUD_init_message("You reached the kill goal!"); - Players[Player_num].shields=i2f(200); - } - else - HUD_init_message ("%s has reached the kill goal!",Players[killer_pnum].callsign); + if (Players[killer_pnum].KillGoalCount>=TheGoal) + { + if (killer_pnum==Player_num) + { + HUD_init_message("You reached the kill goal!"); + Players[Player_num].shields=i2f(200); + } + else + HUD_init_message ("%s has reached the kill goal!",Players[killer_pnum].callsign); - HUD_init_message ("The control center has been destroyed!"); - net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN)); - } + HUD_init_message ("The control center has been destroyed!"); + net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN)); + } } multi_sort_kill_list(); multi_show_player_list(); - Players[killed_pnum].flags&=(~(PLAYER_FLAGS_HEADLIGHT_ON)); // clear the killed guys flags/headlights + Players[killed_pnum].flags&=(~(PLAYER_FLAGS_HEADLIGHT_ON)); // clear the killed guys flags/headlights } void multi_do_frame(void) { - static int lasttime=0; - int i; + static int lasttime=0; + int i; if (!(Game_mode & GM_MULTI)) { @@ -890,18 +896,18 @@ multi_do_frame(void) return; } - if ((Game_mode & GM_NETWORK) && Netgame.PlayTimeAllowed && lasttime!=f2i (ThisLevelTime)) + if ((Game_mode & GM_NETWORK) && Netgame.PlayTimeAllowed && lasttime!=f2i (ThisLevelTime)) { - for (i=0;i= 0); +// Assert(buf[0] >= 0); if (Game_mode & GM_NETWORK) Assert(buf[0] > 0); @@ -952,8 +958,8 @@ void multi_leave_game(void) { - // if (Function_mode != FMODE_GAME) - // return; +// if (Function_mode != FMODE_GAME) +// return; if (!(Game_mode & GM_MULTI)) return; @@ -980,17 +986,17 @@ multi_leave_game(void) Game_mode |= GM_GAME_OVER; - if (Function_mode!=FMODE_EXIT) + if (Function_mode!=FMODE_EXIT) Function_mode = FMODE_MENU; - // N_players = 0; +// N_players = 0; - // change_playernum_to(0); - // Viewer = ConsoleObject = &Objects[0]; +// change_playernum_to(0); +// Viewer = ConsoleObject = &Objects[0]; } - -void + +void multi_show_player_list() { if (!(Game_mode & GM_MULTI) || (Game_mode & GM_MULTI_COOP)) @@ -1003,7 +1009,7 @@ multi_show_player_list() Show_kill_list = 1; } -int +int multi_endlevel(int *secret) { int result = 0; @@ -1012,8 +1018,8 @@ multi_endlevel(int *secret) com_endlevel(secret); // an opportunity to re-sync or whatever else if (Game_mode & GM_NETWORK) result = network_endlevel(secret); - - return(result); + + return(result); } // @@ -1025,7 +1031,7 @@ multi_endlevel(int *secret) //extern PORT *com_port; #endif -int +int multi_menu_poll(void) { fix old_shields; @@ -1047,12 +1053,13 @@ multi_menu_poll(void) multi_in_menu++; // Track level of menu nesting - GameLoop( 0, 0 ); + GameLoop( 0, 0 ); multi_in_menu--; - timer_delay(f0_1); // delay 100 milliseconds - +// timer_delay(f1_0/10); changed by allender for portability + d_delay(100); // delay 100 milliseconds + if (Endlevel_sequence || (Control_center_destroyed && !was_fuelcen_alive) || (Player_is_dead != player_was_dead) || (Players[Player_num].shields < old_shields)) { multi_leave_menu = 1; @@ -1083,18 +1090,18 @@ multi_define_macro(int key) key &= (~KEY_SHIFTED); - switch(key) + switch(key) { - case KEY_F9: - multi_defining_message = 1; break; - case KEY_F10: - multi_defining_message = 2; break; - case KEY_F11: - multi_defining_message = 3; break; - case KEY_F12: - multi_defining_message = 4; break; - default: - Int3(); + case KEY_F9: + multi_defining_message = 1; break; + case KEY_F10: + multi_defining_message = 2; break; + case KEY_F11: + multi_defining_message = 3; break; + case KEY_F12: + multi_defining_message = 4; break; + default: + Int3(); } if (multi_defining_message) { @@ -1158,9 +1165,9 @@ multi_message_feedback(void) Assert(strlen(feedback_result) < 200); HUD_init_message(feedback_result); - //sprintf (temp,"%s",colon); - //sprintf (Network_message,"%s",temp); - +// sprintf (temp,"%s",colon); +// sprintf (Network_message,"%s",temp); + } } @@ -1170,18 +1177,18 @@ multi_send_macro(int key) if (! (Game_mode & GM_MULTI) ) return; - switch(key) + switch(key) { - case KEY_F9: - key = 0; break; - case KEY_F10: - key = 1; break; - case KEY_F11: - key = 2; break; - case KEY_F12: - key = 3; break; - default: - Int3(); + case KEY_F9: + key = 0; break; + case KEY_F10: + key = 1; break; + case KEY_F11: + key = 2; break; + case KEY_F12: + key = 3; break; + default: + Int3(); } if (!Network_message_macro[key][0]) @@ -1198,7 +1205,7 @@ multi_send_macro(int key) } -void +void multi_send_message_start() { if (Game_mode&GM_MULTI) { @@ -1212,7 +1219,9 @@ extern fix StartingShields; fix PingLaunchTime,PingReturnTime; extern void network_send_ping (ubyte); +extern void network_dump_player(ubyte * server, ubyte *node, int why); extern int network_who_is_master(); +extern void network_send_netgame_update(); extern char NameReturning; extern int force_cockpit_redraw; @@ -1221,38 +1230,38 @@ void network_dump_appletalk_player(ubyte node, ushort net, ubyte socket, int why void multi_send_message_end() { char *mytempbuf; - int i,t; - + int i,t; + Network_message_reciever = 100; if (!strnicmp (Network_message,"!Names",6)) - { - NameReturning=1-NameReturning; - HUD_init_message ("Name returning is now %s.",NameReturning?"active":"disabled"); - } - else if (!strnicmp (Network_message,"Handicap:",9)) - { - mytempbuf=&Network_message[9]; - mprintf ((0,"Networkhandi=%s\n",mytempbuf)); - StartingShields=atol (mytempbuf); - if (StartingShields<10) - StartingShields=10; - if (StartingShields>100) { - sprintf (Network_message,"%s has tried to cheat!",Players[Player_num].callsign); - StartingShields=100; + NameReturning=1-NameReturning; + HUD_init_message ("Name returning is now %s.",NameReturning?"active":"disabled"); } - else + else if (!strnicmp (Network_message,"Handicap:",9)) + { + mytempbuf=&Network_message[9]; + mprintf ((0,"Networkhandi=%s\n",mytempbuf)); + StartingShields=atol (mytempbuf); + if (StartingShields<10) + StartingShields=10; + if (StartingShields>100) + { + sprintf (Network_message,"%s has tried to cheat!",Players[Player_num].callsign); + StartingShields=100; + } + else sprintf (Network_message,"%s handicap is now %d",Players[Player_num].callsign,StartingShields); - HUD_init_message ("Telling others of your handicap of %d!",StartingShields); - StartingShields=i2f(StartingShields); - } + HUD_init_message ("Telling others of your handicap of %d!",StartingShields); + StartingShields=i2f(StartingShields); + } else if (!strnicmp (Network_message,"NoBombs",7)) - Netgame.DoSmartMine=0; + Netgame.DoSmartMine=0; else if (!strnicmp (Network_message,"Ping:",5)) - { - if (Game_mode & GM_NETWORK) + { + if (Game_mode & GM_NETWORK) { int name_index=5; if (strlen(Network_message) > 5) @@ -1260,108 +1269,108 @@ void multi_send_message_end() name_index++; if (strlen(Network_message)<=name_index) - { + { HUD_init_message ("You must specify a name to ping"); return; - } + } for (i = 0; i < N_players; i++) - if ((!strnicmp(Players[i].callsign, &Network_message[name_index], strlen(Network_message)-name_index)) && (i != Player_num) && (Players[i].connected)) - { - PingLaunchTime=timer_get_fixed_seconds(); - network_send_ping (i); - HUD_init_message("Pinging %s...",Players[i].callsign); - multi_message_index = 0; - multi_sending_message = 0; - return; - } + if ((!strnicmp(Players[i].callsign, &Network_message[name_index], strlen(Network_message)-name_index)) && (i != Player_num) && (Players[i].connected)) + { + PingLaunchTime=timer_get_fixed_seconds(); + network_send_ping (i); + HUD_init_message("Pinging %s...",Players[i].callsign); + multi_message_index = 0; + multi_sending_message = 0; + return; + } } - else // Modem/Serial ping - { - PingLaunchTime=timer_get_fixed_seconds(); - multi_send_modem_ping (); - HUD_init_message("Pinging opponent..."); + else // Modem/Serial ping + { + PingLaunchTime=timer_get_fixed_seconds(); + multi_send_modem_ping (); + HUD_init_message("Pinging opponent..."); multi_message_index = 0; - multi_sending_message = 0; - return; - } - } + multi_sending_message = 0; + return; + } + } else if (!strnicmp (Network_message,"move:",5)) - { + { mprintf ((0,"moving?\n")); - - if ((Game_mode & GM_NETWORK) && (Game_mode & GM_TEAM)) + + if ((Game_mode & GM_NETWORK) && (Game_mode & GM_TEAM)) { int name_index=5; if (strlen(Network_message) > 5) while (Network_message[name_index] == ' ') name_index++; - if (!network_i_am_master()) - { - HUD_init_message ("Only %s can move players!",Players[network_who_is_master()].callsign); - return; + if (!network_i_am_master()) + { + HUD_init_message ("Only %s can move players!",Players[network_who_is_master()].callsign); + return; } - + if (strlen(Network_message)<=name_index) - { + { HUD_init_message ("You must specify a name to move"); return; - } + } for (i = 0; i < N_players; i++) - if ((!strnicmp(Players[i].callsign, &Network_message[name_index], strlen(Network_message)-name_index)) && (Players[i].connected)) - { - if ((Game_mode & GM_CAPTURE) && (Players[i].flags & PLAYER_FLAGS_FLAG)) - { - HUD_init_message ("Can't move player because s/he has a flag!"); - return; - } - - if (Netgame.team_vector & (1< 5) while (Network_message[name_index] == ' ') name_index++; - if (!network_i_am_master()) - { - HUD_init_message ("Only %s can kick others out!",Players[network_who_is_master()].callsign); - multi_message_index = 0; - multi_sending_message = 0; - return; + if (!network_i_am_master()) + { + HUD_init_message ("Only %s can kick others out!",Players[network_who_is_master()].callsign); + multi_message_index = 0; + multi_sending_message = 0; + return; } if (strlen(Network_message)<=name_index) - { + { HUD_init_message ("You must specify a name to kick"); multi_message_index = 0; multi_sending_message = 0; return; - } + } if (Network_message[name_index] == '#' && isdigit(Network_message[name_index+1])) { int players[MAX_NUM_NET_PLAYERS]; @@ -1372,9 +1381,9 @@ void multi_send_message_end() if (Show_kill_list==1 || Show_kill_list==2) { if (listpos == 0 || listpos >= N_players) { HUD_init_message ("Invalid player number for kick."); - multi_message_index = 0; - multi_sending_message = 0; - return; + multi_message_index = 0; + multi_sending_message = 0; + return; } multi_get_kill_list(players); i = players[listpos]; @@ -1382,34 +1391,34 @@ void multi_send_message_end() goto kick_player; } else HUD_init_message ("You cannot use # kicking with in team display."); - + multi_message_index = 0; - multi_sending_message = 0; - return; + multi_sending_message = 0; + return; } for (i = 0; i < N_players; i++) - if ((!strnicmp(Players[i].callsign, &Network_message[name_index], strlen(Network_message)-name_index)) && (i != Player_num) && (Players[i].connected)) { - kick_player:; - if (Network_game_type == IPX_GAME) + if ((!strnicmp(Players[i].callsign, &Network_message[name_index], strlen(Network_message)-name_index)) && (i != Player_num) && (Players[i].connected)) { +kick_player:; + if (Network_game_type == IPX_GAME) network_dump_player(NetPlayers.players[i].network.ipx.server,NetPlayers.players[i].network.ipx.node, 7); else network_dump_appletalk_player(NetPlayers.players[i].network.appletalk.node,NetPlayers.players[i].network.appletalk.net, NetPlayers.players[i].network.appletalk.socket, 7); - + HUD_init_message("Dumping %s...",Players[i].callsign); multi_message_index = 0; multi_sending_message = 0; return; } - } + } - else + else HUD_init_message("%s '%s'", TXT_SENDING, Network_message); multi_send_message(); - multi_message_feedback(); + multi_message_feedback(); multi_message_index = 0; multi_sending_message = 0; @@ -1443,7 +1452,7 @@ void multi_message_input_sub( int key ) Network_message[multi_message_index] = 0; break; case KEY_ENTER: - if ( multi_sending_message ) + if ( multi_sending_message ) multi_send_message_end(); else if ( multi_defining_message ) multi_define_macro_end(); @@ -1456,7 +1465,7 @@ void multi_message_input_sub( int key ) if (multi_message_index < MAX_MESSAGE_LEN-2 ) { Network_message[multi_message_index++] = ascii; Network_message[multi_message_index] = 0; - } else if ( multi_sending_message ) { + } else if ( multi_sending_message ) { int i; char * ptext, * pcolon; ptext = NULL; @@ -1478,14 +1487,14 @@ void multi_message_input_sub( int key ) else strcpy( Network_message, ptext ); multi_message_index = strlen( Network_message ); - } + } } } } } } -void +void multi_send_message_dialog(void) { newmenu_item m[1]; @@ -1502,7 +1511,7 @@ multi_send_message_dialog(void) if ((choice > -1) && (strlen(Network_message) > 0)) { Network_message_reciever = 100; HUD_init_message("%s '%s'", TXT_SENDING, Network_message); - multi_message_feedback(); + multi_message_feedback(); } } @@ -1515,7 +1524,7 @@ multi_do_death(int objnum) objnum = objnum; - if (!(Game_mode & GM_MULTI_COOP)) + if (!(Game_mode & GM_MULTI_COOP)) { mprintf((0, "Setting all keys for player %d.\n", Player_num)); Players[Player_num].flags |= (PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_GOLD_KEY); @@ -1528,25 +1537,25 @@ multi_do_fire(char *buf) ubyte weapon; char pnum; byte flags; - //static dum=0; - + //static dum=0; + // Act out the actual shooting pnum = buf[1]; #ifndef MACINTOSH - weapon = (int)buf[2]; + weapon = (int)buf[2]; #else weapon = buf[2]; #endif flags = buf[4]; Network_laser_track = INTEL_SHORT(*(short *)(buf+6)); - + Assert (pnum < N_players); if (Objects[Players[(int)pnum].objnum].type == OBJ_GHOST) multi_make_ghost_player(pnum); - // mprintf((0,"multi_do_fire, weapon = %d\n",weapon)); + // mprintf((0,"multi_do_fire, weapon = %d\n",weapon)); if (weapon == FLARE_ADJUST) Laser_player_fire( Objects+Players[(int)pnum].objnum, FLARE_ID, 6, 1, 0); @@ -1558,10 +1567,10 @@ multi_do_fire(char *buf) mprintf((0,"missile id = %d, gun = %d\n",weapon_id,weapon_gun)); if (weapon-MISSILE_ADJUST==GUIDED_INDEX) - { - mprintf ((0,"Missile is guided!!!\n")); - Multi_is_guided=1; - } + { + mprintf ((0,"Missile is guided!!!\n")); + Multi_is_guided=1; + } Laser_player_fire( Objects+Players[(int)pnum].objnum, weapon_id, weapon_gun, 1, 0 ); } @@ -1578,38 +1587,38 @@ multi_do_fire(char *buf) else Players[(int)pnum].flags &= ~PLAYER_FLAGS_QUAD_LASERS; } - + do_laser_firing(Players[(int)pnum].objnum, weapon, (int)buf[3], flags, (int)buf[5]); - + if (weapon == FUSION_INDEX) Fusion_charge = save_charge; } } -void +void multi_do_message(char *buf) { char *colon; - char *tilde,mesbuf[100]; - int tloc,t; + char *tilde,mesbuf[100]; + int tloc,t; int loc = 2; - - if ((tilde=strchr (buf+loc,'$'))) // do that stupid name stuff - { // why'd I put this in? Probably for the - tloc=tilde-(buf+loc); // same reason you can name your guidebot - mprintf ((0,"Tloc=%d\n",tloc)); - - if (tloc>0) - strncpy (mesbuf,buf+loc,tloc); - strcpy (mesbuf+tloc,Players[Player_num].callsign); - strcpy (mesbuf+strlen(Players[Player_num].callsign)+tloc,buf+loc+tloc+1); - strcpy (buf+loc,mesbuf); - } - + + if ((tilde=strchr (buf+loc,'$'))) // do that stupid name stuff + { // why'd I put this in? Probably for the + tloc=tilde-(buf+loc); // same reason you can name your guidebot + mprintf ((0,"Tloc=%d\n",tloc)); + + if (tloc>0) + strncpy (mesbuf,buf+loc,tloc); + strcpy (mesbuf+tloc,Players[Player_num].callsign); + strcpy (mesbuf+strlen(Players[Player_num].callsign)+tloc,buf+loc+tloc+1); + strcpy (buf+loc,mesbuf); + } + if (((colon = strrchr(buf+loc, ':')) == NULL) || (colon-(buf+loc) < 1) || (colon-(buf+loc) > CALLSIGN_LEN)) { - mesbuf[0] = 1; + mesbuf[0] = 1; mesbuf[1] = BM_XRGB(28, 0, 0); strcpy(&mesbuf[2], Players[(int)buf[1]].callsign); t = strlen(mesbuf); @@ -1624,9 +1633,9 @@ multi_do_message(char *buf) else { if ( (!strnicmp(Players[Player_num].callsign, buf+loc, colon-(buf+loc))) || - ((Game_mode & GM_TEAM) && ( (get_team(Player_num) == atoi(buf+loc)-1) || !strnicmp(Netgame.team_name[get_team(Player_num)], buf+loc, colon-(buf+loc)))) ) + ((Game_mode & GM_TEAM) && ( (get_team(Player_num) == atoi(buf+loc)-1) || !strnicmp(Netgame.team_name[get_team(Player_num)], buf+loc, colon-(buf+loc)))) ) { - mesbuf[0] = 1; + mesbuf[0] = 1; mesbuf[1] = BM_XRGB(0, 32, 32); strcpy(&mesbuf[2], Players[(int)buf[1]].callsign); t = strlen(mesbuf); @@ -1635,15 +1644,15 @@ multi_do_message(char *buf) mesbuf[t+2] = BM_XRGB(0, 31, 0); mesbuf[t+3] = 0; - digi_play_sample(SOUND_HUD_MESSAGE, F1_0); - HUD_init_message("%s %s", mesbuf, colon+1); + digi_play_sample(SOUND_HUD_MESSAGE, F1_0); + HUD_init_message("%s %s", mesbuf, colon+1); } } } void multi_do_position(char *buf) -{ +{ #ifdef MACINTOSH shortpos sp; #endif @@ -1656,11 +1665,11 @@ multi_do_position(char *buf) Assert(&Objects[Players[pnum].objnum] != ConsoleObject); if (Game_mode & GM_NETWORK) - { - Int3(); // Get Jason, what the hell are we doing here? - return; + { + Int3(); // Get Jason, what the hell are we doing here? + return; } - + #ifndef MACINTOSH extract_shortpos(&Objects[Players[pnum].objnum], (shortpos *)(buf+1),0); @@ -1682,15 +1691,15 @@ multi_do_reappear(char *buf) objnum = INTEL_SHORT(*(short *)(buf+1)); Assert(objnum >= 0); - // Assert(Players[Objects[objnum].id]].objnum == objnum); - - // mprintf((0, "Switching rendering back on for object %d.\n", objnum)); +// Assert(Players[Objects[objnum].id]].objnum == objnum); + +// mprintf((0, "Switching rendering back on for object %d.\n", objnum)); multi_make_ghost_player(Objects[objnum].id); create_player_appearance_effect(&Objects[objnum]); PKilledFlags[Objects[objnum].id]=0; } - + void multi_do_player_explode(char *buf) { @@ -1723,7 +1732,7 @@ multi_do_player_explode(char *buf) #endif // Stuff the Players structure to prepare for the explosion - + count = 2; Players[pnum].primary_weapon_flags = INTEL_SHORT(*(ushort *)(buf+count)); count += 2; Players[pnum].secondary_weapon_flags = INTEL_SHORT(*(ushort *)(buf+count)); count += 2; @@ -1743,20 +1752,20 @@ multi_do_player_explode(char *buf) Players[pnum].primary_ammo[VULCAN_INDEX] = INTEL_SHORT(*(ushort *)(buf+count)); count += 2; Players[pnum].primary_ammo[GAUSS_INDEX] = INTEL_SHORT(*(ushort *)(buf+count)); count += 2; Players[pnum].flags = INTEL_INT(*(uint *)(buf+count)); count += 4; - + multi_adjust_remote_cap (pnum); objp = Objects+Players[pnum].objnum; - // objp->phys_info.velocity = *(vms_vector *)(buf+16); // 12 bytes - // objp->pos = *(vms_vector *)(buf+28); // 12 bytes +// objp->phys_info.velocity = *(vms_vector *)(buf+16); // 12 bytes +// objp->pos = *(vms_vector *)(buf+28); // 12 bytes remote_created = buf[count++]; // How many did the other guy create? Net_create_loc = 0; drop_player_eggs(objp); - + // Create mapping from remote to local numbering system mprintf((0, "I Created %d powerups, remote created %d.\n", Net_create_loc, remote_created)); @@ -1768,20 +1777,20 @@ multi_do_player_explode(char *buf) for (i = 0; i < remote_created; i++) { short s; - + s = INTEL_SHORT(*(short *)(buf+count)); - + if ((i < Net_create_loc) && (s > 0)) - map_objnum_local_to_remote((short)Net_create_objnums[i], s, pnum); + map_objnum_local_to_remote((short)Net_create_objnums[i], s, pnum); else if (*(short *)(buf+count) <= 0) { mprintf((0, "WARNING: Remote created object has non-valid number %d (player %d)", s, pnum)); } - else + else { mprintf((0, "WARNING: Could not create all powerups created by player %d.\n", pnum)); } - // Assert(s > 0); +// Assert(s > 0); count += 2; } for (i = remote_created; i < Net_create_loc; i++) { @@ -1792,7 +1801,7 @@ multi_do_player_explode(char *buf) if (buf[0] == MULTI_PLAYER_EXPLODE) { explode_badass_player(objp); - + objp->flags &= ~OF_SHOULD_BE_DEAD; //don't really kill player multi_make_player_ghost(pnum); } @@ -1811,17 +1820,17 @@ multi_do_kill(char *buf) int killer, killed; int count = 1; int pnum; - + pnum = (int)(buf[count]); if ((pnum < 0) || (pnum >= N_players)) { Int3(); // Invalid player number killed return; } - killed = Players[pnum].objnum; + killed = Players[pnum].objnum; count += 1; - killer = INTEL_SHORT(*(short *)(buf+count)); + killer = INTEL_SHORT(*(short *)(buf+count)); if (killer > 0) killer = objnum_remote_to_local(killer, (byte)buf[count+2]); @@ -1832,7 +1841,7 @@ multi_do_kill(char *buf) mprintf( (1, "SOFT INT3: MULTI.C Non-player object %d of type %d killed! (JOHN)\n", killed, Objects[killed].type )); return; } -#endif +#endif multi_compute_kill(killer, killed); @@ -1849,14 +1858,14 @@ void multi_do_controlcen_destroy(char *buf) objnum = INTEL_SHORT(*(short *)(buf+1)); who = buf[3]; - if (Control_center_destroyed != 1) + if (Control_center_destroyed != 1) { if ((who < N_players) && (who != Player_num)) { HUD_init_message("%s %s", Players[who].callsign, TXT_HAS_DEST_CONTROL); } else if (who == Player_num) HUD_init_message(TXT_YOU_DEST_CONTROL); - else + else HUD_init_message(TXT_CONTROL_DESTROYED); if (objnum != -1) @@ -1866,7 +1875,7 @@ void multi_do_controlcen_destroy(char *buf) } } -void +void multi_do_escape(char *buf) { int objnum; @@ -1875,7 +1884,7 @@ multi_do_escape(char *buf) digi_play_sample(SOUND_HUD_MESSAGE, F1_0); digi_kill_sound_linked_to_object (objnum); - + if (buf[2] == 0) { HUD_init_message("%s %s", Players[(int)buf[1]].callsign, TXT_HAS_ESCAPED); @@ -1884,7 +1893,7 @@ multi_do_escape(char *buf) if (!multi_goto_secret) multi_goto_secret = 2; } - else if (buf[2] == 1) + else if (buf[2] == 1) { HUD_init_message("%s %s", Players[(int)buf[1]].callsign, TXT_HAS_FOUND_SECRET); if (Game_mode & GM_NETWORK) @@ -1913,7 +1922,7 @@ multi_do_remobj(char *buf) local_objnum = objnum_remote_to_local(objnum, obj_owner); // translate to local objnum - // mprintf((0, "multi_do_remobj: %d owner %d = %d.\n", objnum, obj_owner, local_objnum)); +// mprintf((0, "multi_do_remobj: %d owner %d = %d.\n", objnum, obj_owner, local_objnum)); if (local_objnum < 0) { @@ -1926,39 +1935,39 @@ multi_do_remobj(char *buf) mprintf((1, "multi_get_remobj: tried to remove invalid type %d.\n", Objects[local_objnum].type)); return; } - + if (Network_send_objects && network_objnum_is_past(local_objnum)) { mprintf((0, "Resetting object sync due to object removal.\n")); Network_send_objnum = -1; } if (Objects[local_objnum].type==OBJ_POWERUP) - if (Game_mode & GM_NETWORK) + if (Game_mode & GM_NETWORK) { - if (PowerupsInMine[Objects[local_objnum].id]>0) - PowerupsInMine[Objects[local_objnum].id]--; + if (PowerupsInMine[Objects[local_objnum].id]>0) + PowerupsInMine[Objects[local_objnum].id]--; - if (multi_powerup_is_4pack (Objects[local_objnum].id)) - { + if (multi_powerup_is_4pack (Objects[local_objnum].id)) + { mprintf ((0,"Hey babe! Doing that wacky 4 pack stuff.")); - + if (PowerupsInMine[Objects[local_objnum].id-1]-4<0) PowerupsInMine[Objects[local_objnum].id-1]=0; else PowerupsInMine[Objects[local_objnum].id-1]-=4; - } - - mprintf ((0,"Decrementing powerups! %d\n",PowerupsInMine[Objects[local_objnum].id])); + } + + mprintf ((0,"Decrementing powerups! %d\n",PowerupsInMine[Objects[local_objnum].id])); } Objects[local_objnum].flags |= OF_SHOULD_BE_DEAD; // quick and painless - + } void multi_do_quit(char *buf) { - + if (Game_mode & GM_NETWORK) { int i, n = 0; @@ -1966,7 +1975,7 @@ multi_do_quit(char *buf) digi_play_sample( SOUND_HUD_MESSAGE, F1_0 ); HUD_init_message( "%s %s", Players[(int)buf[1]].callsign, TXT_HAS_LEFT_THE_GAME); - + network_disconnect_player(buf[1]); if (multi_in_menu) @@ -2000,7 +2009,7 @@ multi_do_cloak(char *buf) pnum = (int)(buf[1]); Assert(pnum < N_players); - + mprintf((0, "Cloaking player %d\n", pnum)); Players[pnum].flags |= PLAYER_FLAGS_CLOAKED; @@ -2015,7 +2024,7 @@ multi_do_cloak(char *buf) if (Newdemo_state == ND_STATE_RECORDING) newdemo_record_multi_cloak(pnum); } - + void multi_do_decloak(char *buf) { @@ -2027,7 +2036,7 @@ multi_do_decloak(char *buf) newdemo_record_multi_decloak(pnum); } - + void multi_do_door_open(char *buf) { @@ -2041,7 +2050,7 @@ multi_do_door_open(char *buf) side = buf[3]; flag= buf[4]; - // mprintf((0, "Opening door on side %d of segment # %d.\n", side, segnum)); +// mprintf((0, "Opening door on side %d of segment # %d.\n", side, segnum)); if ((segnum < 0) || (segnum > Highest_segment_index) || (side < 0) || (side > 5)) { @@ -2070,13 +2079,13 @@ multi_do_door_open(char *buf) else if (w->state != WALL_DOOR_OPENING) { wall_open_door(seg, side); - w->flags=flag; + w->flags=flag; } else - w->flags=flag; + w->flags=flag; - // else - // mprintf((0, "Door already opening!\n")); +// else +// mprintf((0, "Door already opening!\n")); } void @@ -2087,10 +2096,10 @@ multi_do_create_explosion(char *buf) pnum = buf[count++]; - // mprintf((0, "Creating small fireball.\n")); +// mprintf((0, "Creating small fireball.\n")); create_small_fireball_on_object(&Objects[Players[pnum].objnum], F1_0, 1); } - + void multi_do_controlcen_fire(char *buf) { @@ -2100,11 +2109,11 @@ multi_do_controlcen_fire(char *buf) int count = 1; memcpy(&to_target, buf+count, 12); count += 12; -#ifdef MACINTOSH // swap the vector to_target + #ifdef MACINTOSH // swap the vector to_target to_target.x = (fix)INTEL_INT((int)to_target.x); to_target.y = (fix)INTEL_INT((int)to_target.y); to_target.z = (fix)INTEL_INT((int)to_target.z); -#endif + #endif gun_num = buf[count]; count += 1; objnum = INTEL_SHORT(*(short *)(buf+count)); count += 2; @@ -2134,7 +2143,7 @@ multi_do_create_powerup(char *buf) Int3(); return; } - + new_pos = *(vms_vector *)(buf+count); count+=sizeof(vms_vector); #ifdef MACINTOSH new_pos.x = (fix)SWAPINT((int)new_pos.x); @@ -2159,7 +2168,7 @@ multi_do_create_powerup(char *buf) Objects[my_objnum].pos = new_pos; vm_vec_zero(&Objects[my_objnum].mtype.phys_info.velocity); - + obj_relink(my_objnum, segnum); map_objnum_local_to_remote(my_objnum, objnum, pnum); @@ -2167,9 +2176,9 @@ multi_do_create_powerup(char *buf) object_create_explosion(segnum, &new_pos, i2f(5), VCLIP_POWERUP_DISAPPEARANCE); mprintf((0, "Creating powerup type %d in segment %i.\n", powerup_type, segnum)); - if (Game_mode & GM_NETWORK) + if (Game_mode & GM_NETWORK) PowerupsInMine[(int)powerup_type]++; -} +} void multi_do_play_sound(char *buf) @@ -2184,14 +2193,14 @@ multi_do_play_sound(char *buf) Assert(Players[pnum].objnum >= 0); Assert(Players[pnum].objnum <= Highest_object_index); - digi_link_sound_to_object( sound_num, Players[pnum].objnum, 0, volume); + digi_link_sound_to_object( sound_num, Players[pnum].objnum, 0, volume); } void multi_do_score(char *buf) { int pnum = (int)(buf[1]); - + if ((pnum < 0) || (pnum >= N_players)) { Int3(); // Non-terminal, see rob @@ -2211,8 +2220,8 @@ multi_do_trigger(char *buf) { int pnum = (int)(buf[1]); int trigger = (int)(buf[2]); - - mprintf ((0,"MULTI doing trigger!\n")); + + mprintf ((0,"MULTI doing trigger!\n")); if ((pnum < 0) || (pnum >= N_players) || (pnum == Player_num)) { @@ -2228,31 +2237,31 @@ multi_do_trigger(char *buf) } void multi_do_drop_marker (char *buf) -{ - int i; - int pnum=(int)(buf[1]); - int mesnum=(int)(buf[2]); - vms_vector position; + { + int i; + int pnum=(int)(buf[1]); + int mesnum=(int)(buf[2]); + vms_vector position; - if (pnum==Player_num) // my marker? don't set it down cuz it might screw up the orientation - return; + if (pnum==Player_num) // my marker? don't set it down cuz it might screw up the orientation + return; - position.x=(fix)INTEL_INT(*(int *)(buf+3)); - position.y=(fix)INTEL_INT(*(int *)(buf+7)); - position.z=(fix)INTEL_INT(*(int *)(buf+11)); + position.x=(fix)INTEL_INT(*(int *)(buf+3)); + position.y=(fix)INTEL_INT(*(int *)(buf+7)); + position.z=(fix)INTEL_INT(*(int *)(buf+11)); - for (i=0;i<40;i++) - MarkerMessage[(pnum*2)+mesnum][i]=buf[15+i]; + for (i=0;i<40;i++) + MarkerMessage[(pnum*2)+mesnum][i]=buf[15+i]; - MarkerPoint[(pnum*2)+mesnum]=position; + MarkerPoint[(pnum*2)+mesnum]=position; - if (MarkerObject[(pnum*2)+mesnum] !=-1 && Objects[MarkerObject[(pnum*2)+mesnum]].type!=OBJ_NONE && MarkerObject[(pnum*2)+mesnum] !=0) + if (MarkerObject[(pnum*2)+mesnum] !=-1 && Objects[MarkerObject[(pnum*2)+mesnum]].type!=OBJ_NONE && MarkerObject[(pnum*2)+mesnum] !=0) obj_delete(MarkerObject[(pnum*2)+mesnum]); - MarkerObject[(pnum*2)+mesnum] = drop_marker_object(&position,Objects[Players[Player_num].objnum].segnum,&Objects[Players[Player_num].objnum].orient,(pnum*2)+mesnum); - strcpy (MarkerOwner[(pnum*2)+mesnum],Players[pnum].callsign); - mprintf ((0,"Dropped player %d message: %s\n",pnum,MarkerMessage[(pnum*2)+mesnum])); -} + MarkerObject[(pnum*2)+mesnum] = drop_marker_object(&position,Objects[Players[Player_num].objnum].segnum,&Objects[Players[Player_num].objnum].orient,(pnum*2)+mesnum); + strcpy (MarkerOwner[(pnum*2)+mesnum],Players[pnum].callsign); + mprintf ((0,"Dropped player %d message: %s\n",pnum,MarkerMessage[(pnum*2)+mesnum])); + } void multi_do_hostage_door_status(char *buf) @@ -2260,7 +2269,7 @@ void multi_do_hostage_door_status(char *buf) // Update hit point status of a door int count = 1; - int wallnum; + int wallnum; fix hps; wallnum = INTEL_SHORT(*(short *)(buf+count)); count += 2; @@ -2272,7 +2281,7 @@ void multi_do_hostage_door_status(char *buf) return; } - // mprintf((0, "Damaging wall number %d to %f points.\n", wallnum, f2fl(hps))); +// mprintf((0, "Damaging wall number %d to %f points.\n", wallnum, f2fl(hps))); if (hps < Walls[wallnum].hps) wall_damage(&Segments[Walls[wallnum].segnum], Walls[wallnum].sidenum, Walls[wallnum].hps - hps); @@ -2304,7 +2313,7 @@ void multi_do_restore_game(char *buf) multi_restore_game( slot, id ); } - + void multi_do_req_player(char *buf) { netplayer_stats ps; @@ -2323,7 +2332,7 @@ void multi_do_send_player(char *buf) { // Got a player packet from someone!!! netplayer_stats * p; - p = (netplayer_stats *)buf; + p = (netplayer_stats *)buf; Assert( p->Player_num <= N_players ); @@ -2337,7 +2346,7 @@ void multi_reset_stuff(void) { // A generic, emergency function to solve problems that crop up - // when a player exits quick-out from the game because of a + // when a player exits quick-out from the game because of a // serial connection loss. Fixes several weird bugs! dead_player_end(); @@ -2367,7 +2376,7 @@ multi_reset_player_object(object *objp) objp->mtype.phys_info.brakes = objp->mtype.phys_info.turnroll = 0; objp->mtype.phys_info.mass = Player_ship->mass; objp->mtype.phys_info.drag = Player_ship->drag; - // objp->mtype.phys_info.flags &= ~(PF_TURNROLL | PF_LEVELLING | PF_WIGGLE | PF_USES_THRUST); +// objp->mtype.phys_info.flags &= ~(PF_TURNROLL | PF_LEVELLING | PF_WIGGLE | PF_USES_THRUST); objp->mtype.phys_info.flags &= ~(PF_TURNROLL | PF_LEVELLING | PF_WIGGLE); //Init render info @@ -2380,19 +2389,19 @@ multi_reset_player_object(object *objp) //reset textures for this, if not player 0 - multi_reset_object_texture (objp); - + multi_reset_object_texture (objp); + // Clear misc objp->flags = 0; - + if (objp->type == OBJ_GHOST) objp->render_type = RT_NONE; } void multi_reset_object_texture (object *objp) -{ + { int id,i; if (Game_mode & GM_TEAM) @@ -2412,8 +2421,8 @@ void multi_reset_object_texture (object *objp) multi_player_textures[id-1][5] = ObjBitmaps[ObjBitmapPtrs[First_multi_bitmap_num+(id-1)*2+1]]; objp->rtype.pobj_info.alt_textures = id; - } -} + } + } @@ -2425,7 +2434,7 @@ void multi_process_bigdata(char *buf, int len) { // Takes a bunch of messages, check them for validity, - // and pass them to multi_process_data. + // and pass them to multi_process_data. int type, sub_len, bytes_processed = 0; @@ -2468,11 +2477,11 @@ multi_send_fire(void) multibuf[3] = (char)Network_laser_level; multibuf[4] = (char)Network_laser_flags; multibuf[5] = (char)Network_laser_fired; - + *(short *)(multibuf+6) = INTEL_SHORT(Network_laser_track); multi_send_data(multibuf, 8, 0); - + Network_laser_fired = 0; } @@ -2489,35 +2498,35 @@ multi_send_destroy_controlcen(int objnum, int player) multibuf[0] = (char)MULTI_CONTROLCEN; *(ushort *)(multibuf+1) = INTEL_SHORT(objnum); multibuf[3] = player; - multi_send_data(multibuf, 4, 2); + multi_send_data(multibuf, 4, 2); } void multi_send_drop_marker (int player,vms_vector position,char messagenum,char text[]) -{ - int i; - - if (player message_length[MULTI_PLAYER_EXPLODE]) { @@ -2620,206 +2629,206 @@ extern ubyte Primary_weapon_to_powerup[]; // to prevent rampant powerups in netgames void multi_cap_objects () -{ - char type,flagtype; - int index; + { + char type,flagtype; + int index; - if (!(Game_mode & GM_NETWORK)) - return; + if (!(Game_mode & GM_NETWORK)) + return; - for (index=0;index=MaxPowerupsAllowed[(int)type]) - if(Players[Player_num].primary_weapon_flags & (1 << index)) + if (PowerupsInMine[(int)type]>=MaxPowerupsAllowed[(int)type]) + if(Players[Player_num].primary_weapon_flags & (1 << index)) { - mprintf ((0,"PIM=%d MPA=%d\n",PowerupsInMine[(int)type],MaxPowerupsAllowed[(int)type])); - mprintf ((0,"Killing a primary cuz there's too many! (%d)\n",(int)type)); - Players[Player_num].primary_weapon_flags&=(~(1 << index)); + mprintf ((0,"PIM=%d MPA=%d\n",PowerupsInMine[(int)type],MaxPowerupsAllowed[(int)type])); + mprintf ((0,"Killing a primary cuz there's too many! (%d)\n",(int)type)); + Players[Player_num].primary_weapon_flags&=(~(1 << index)); } } + + // Don't do the adjustment stuff for Hoard mode + if (!(Game_mode & GM_HOARD)) + Players[Player_num].secondary_ammo[2]/=4; - // Don't do the adjustment stuff for Hoard mode - if (!(Game_mode & GM_HOARD)) - Players[Player_num].secondary_ammo[2]/=4; - - Players[Player_num].secondary_ammo[7]/=4; - - for (index=0;indexMaxPowerupsAllowed[(int)type]) - { - if (MaxPowerupsAllowed[(int)type]-PowerupsInMine[(int)type]<0) - Players[Player_num].secondary_ammo[index]=0; - else - Players[Player_num].secondary_ammo[index]=(MaxPowerupsAllowed[(int)type]-PowerupsInMine[(int)type]); - + + if ((Players[Player_num].secondary_ammo[index]+PowerupsInMine[(int)type])>MaxPowerupsAllowed[(int)type]) + { + if (MaxPowerupsAllowed[(int)type]-PowerupsInMine[(int)type]<0) + Players[Player_num].secondary_ammo[index]=0; + else + Players[Player_num].secondary_ammo[index]=(MaxPowerupsAllowed[(int)type]-PowerupsInMine[(int)type]); + mprintf ((0,"Hey! I killed secondary type %d because PIM=%d MPA=%d\n",(int)type,PowerupsInMine[(int)type],MaxPowerupsAllowed[(int)type])); - } + } } - if (!(Game_mode & GM_HOARD)) - Players[Player_num].secondary_ammo[2]*=4; - Players[Player_num].secondary_ammo[7]*=4; - - if (Players[Player_num].laser_level > MAX_LASER_LEVEL) - if (PowerupsInMine[POW_SUPER_LASER]+1 > MaxPowerupsAllowed[POW_SUPER_LASER]) + if (!(Game_mode & GM_HOARD)) + Players[Player_num].secondary_ammo[2]*=4; + Players[Player_num].secondary_ammo[7]*=4; + + if (Players[Player_num].laser_level > MAX_LASER_LEVEL) + if (PowerupsInMine[POW_SUPER_LASER]+1 > MaxPowerupsAllowed[POW_SUPER_LASER]) Players[Player_num].laser_level=0; - if (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS) - if (PowerupsInMine[POW_QUAD_FIRE]+1 > MaxPowerupsAllowed[POW_QUAD_FIRE]) + if (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS) + if (PowerupsInMine[POW_QUAD_FIRE]+1 > MaxPowerupsAllowed[POW_QUAD_FIRE]) Players[Player_num].flags&=(~PLAYER_FLAGS_QUAD_LASERS); - if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) - if (PowerupsInMine[POW_CLOAK]+1 > MaxPowerupsAllowed[POW_CLOAK]) + if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) + if (PowerupsInMine[POW_CLOAK]+1 > MaxPowerupsAllowed[POW_CLOAK]) Players[Player_num].flags&=(~PLAYER_FLAGS_CLOAKED); - if (Players[Player_num].flags & PLAYER_FLAGS_MAP_ALL) - if (PowerupsInMine[POW_FULL_MAP]+1 > MaxPowerupsAllowed[POW_FULL_MAP]) + if (Players[Player_num].flags & PLAYER_FLAGS_MAP_ALL) + if (PowerupsInMine[POW_FULL_MAP]+1 > MaxPowerupsAllowed[POW_FULL_MAP]) Players[Player_num].flags&=(~PLAYER_FLAGS_MAP_ALL); - if (Players[Player_num].flags & PLAYER_FLAGS_AFTERBURNER) - if (PowerupsInMine[POW_AFTERBURNER]+1 > MaxPowerupsAllowed[POW_AFTERBURNER]) + if (Players[Player_num].flags & PLAYER_FLAGS_AFTERBURNER) + if (PowerupsInMine[POW_AFTERBURNER]+1 > MaxPowerupsAllowed[POW_AFTERBURNER]) Players[Player_num].flags&=(~PLAYER_FLAGS_AFTERBURNER); - if (Players[Player_num].flags & PLAYER_FLAGS_AMMO_RACK) - if (PowerupsInMine[POW_AMMO_RACK]+1 > MaxPowerupsAllowed[POW_AMMO_RACK]) + if (Players[Player_num].flags & PLAYER_FLAGS_AMMO_RACK) + if (PowerupsInMine[POW_AMMO_RACK]+1 > MaxPowerupsAllowed[POW_AMMO_RACK]) Players[Player_num].flags&=(~PLAYER_FLAGS_AMMO_RACK); - if (Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) - if (PowerupsInMine[POW_CONVERTER]+1 > MaxPowerupsAllowed[POW_CONVERTER]) + if (Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) + if (PowerupsInMine[POW_CONVERTER]+1 > MaxPowerupsAllowed[POW_CONVERTER]) Players[Player_num].flags&=(~PLAYER_FLAGS_CONVERTER); - if (Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT) - if (PowerupsInMine[POW_HEADLIGHT]+1 > MaxPowerupsAllowed[POW_HEADLIGHT]) + if (Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT) + if (PowerupsInMine[POW_HEADLIGHT]+1 > MaxPowerupsAllowed[POW_HEADLIGHT]) Players[Player_num].flags&=(~PLAYER_FLAGS_HEADLIGHT); - - if (Game_mode & GM_CAPTURE) - { - if (Players[Player_num].flags & PLAYER_FLAGS_FLAG) + + if (Game_mode & GM_CAPTURE) { - if (get_team(Player_num)==TEAM_RED) + if (Players[Player_num].flags & PLAYER_FLAGS_FLAG) + { + if (get_team(Player_num)==TEAM_RED) flagtype=POW_FLAG_BLUE; - else + else flagtype=POW_FLAG_RED; - - if (PowerupsInMine[(int)flagtype]+1 > MaxPowerupsAllowed[(int)flagtype]) - Players[Player_num].flags&=(~PLAYER_FLAGS_FLAG); + + if (PowerupsInMine[(int)flagtype]+1 > MaxPowerupsAllowed[(int)flagtype]) + Players[Player_num].flags&=(~PLAYER_FLAGS_FLAG); + } } - } -} + } // adds players inventory to multi cap void multi_adjust_cap_for_player (int pnum) -{ - char type; + { + char type; + + int index; - int index; - - if (!(Game_mode & GM_NETWORK)) - return; + if (!(Game_mode & GM_NETWORK)) + return; - for (index=0;index MAX_LASER_LEVEL) - MaxPowerupsAllowed[POW_SUPER_LASER]++; + if (Players[pnum].laser_level > MAX_LASER_LEVEL) + MaxPowerupsAllowed[POW_SUPER_LASER]++; - if (Players[pnum].flags & PLAYER_FLAGS_QUAD_LASERS) - MaxPowerupsAllowed[POW_QUAD_FIRE]++; + if (Players[pnum].flags & PLAYER_FLAGS_QUAD_LASERS) + MaxPowerupsAllowed[POW_QUAD_FIRE]++; - if (Players[pnum].flags & PLAYER_FLAGS_CLOAKED) - MaxPowerupsAllowed[POW_CLOAK]++; + if (Players[pnum].flags & PLAYER_FLAGS_CLOAKED) + MaxPowerupsAllowed[POW_CLOAK]++; - if (Players[pnum].flags & PLAYER_FLAGS_MAP_ALL) - MaxPowerupsAllowed[POW_FULL_MAP]++; + if (Players[pnum].flags & PLAYER_FLAGS_MAP_ALL) + MaxPowerupsAllowed[POW_FULL_MAP]++; - if (Players[pnum].flags & PLAYER_FLAGS_AFTERBURNER) - MaxPowerupsAllowed[POW_AFTERBURNER]++; + if (Players[pnum].flags & PLAYER_FLAGS_AFTERBURNER) + MaxPowerupsAllowed[POW_AFTERBURNER]++; - if (Players[pnum].flags & PLAYER_FLAGS_AMMO_RACK) - MaxPowerupsAllowed[POW_AMMO_RACK]++; + if (Players[pnum].flags & PLAYER_FLAGS_AMMO_RACK) + MaxPowerupsAllowed[POW_AMMO_RACK]++; - if (Players[pnum].flags & PLAYER_FLAGS_CONVERTER) - MaxPowerupsAllowed[POW_CONVERTER]++; + if (Players[pnum].flags & PLAYER_FLAGS_CONVERTER) + MaxPowerupsAllowed[POW_CONVERTER]++; - if (Players[pnum].flags & PLAYER_FLAGS_HEADLIGHT) - MaxPowerupsAllowed[POW_HEADLIGHT]++; -} + if (Players[pnum].flags & PLAYER_FLAGS_HEADLIGHT) + MaxPowerupsAllowed[POW_HEADLIGHT]++; + } void multi_adjust_remote_cap (int pnum) -{ - char type; - - int index; + { + char type; + + int index; - if (!(Game_mode & GM_NETWORK)) - return; + if (!(Game_mode & GM_NETWORK)) + return; - for (index=0;index MAX_LASER_LEVEL) - PowerupsInMine[POW_SUPER_LASER]++; + if (Players[pnum].laser_level > MAX_LASER_LEVEL) + PowerupsInMine[POW_SUPER_LASER]++; - if (Players[pnum].flags & PLAYER_FLAGS_QUAD_LASERS) - PowerupsInMine[POW_QUAD_FIRE]++; + if (Players[pnum].flags & PLAYER_FLAGS_QUAD_LASERS) + PowerupsInMine[POW_QUAD_FIRE]++; - if (Players[pnum].flags & PLAYER_FLAGS_CLOAKED) - PowerupsInMine[POW_CLOAK]++; + if (Players[pnum].flags & PLAYER_FLAGS_CLOAKED) + PowerupsInMine[POW_CLOAK]++; - if (Players[pnum].flags & PLAYER_FLAGS_MAP_ALL) - PowerupsInMine[POW_FULL_MAP]++; + if (Players[pnum].flags & PLAYER_FLAGS_MAP_ALL) + PowerupsInMine[POW_FULL_MAP]++; - if (Players[pnum].flags & PLAYER_FLAGS_AFTERBURNER) - PowerupsInMine[POW_AFTERBURNER]++; + if (Players[pnum].flags & PLAYER_FLAGS_AFTERBURNER) + PowerupsInMine[POW_AFTERBURNER]++; - if (Players[pnum].flags & PLAYER_FLAGS_AMMO_RACK) - PowerupsInMine[POW_AMMO_RACK]++; + if (Players[pnum].flags & PLAYER_FLAGS_AMMO_RACK) + PowerupsInMine[POW_AMMO_RACK]++; - if (Players[pnum].flags & PLAYER_FLAGS_CONVERTER) - PowerupsInMine[POW_CONVERTER]++; + if (Players[pnum].flags & PLAYER_FLAGS_CONVERTER) + PowerupsInMine[POW_CONVERTER]++; - if (Players[pnum].flags & PLAYER_FLAGS_HEADLIGHT) - PowerupsInMine[POW_HEADLIGHT]++; + if (Players[pnum].flags & PLAYER_FLAGS_HEADLIGHT) + PowerupsInMine[POW_HEADLIGHT]++; -} + } void multi_send_message(void) @@ -2841,7 +2850,7 @@ multi_send_reappear() { multibuf[0] = (char)MULTI_REAPPEAR; *(short *)(multibuf+1) = INTEL_SHORT(Players[Player_num].objnum); - + multi_send_data(multibuf, 3, 2); PKilledFlags[Player_num]=0; } @@ -2857,7 +2866,7 @@ multi_send_position(int objnum) if (Game_mode & GM_NETWORK) { return; } - + multibuf[count++] = (char)MULTI_POSITION; #ifndef MACINTOSH create_shortpos((shortpos *)(multibuf+count), Objects+objnum,0); @@ -2885,15 +2894,15 @@ multi_send_kill(int objnum) killer_objnum = Players[Player_num].killer_objnum; multi_compute_kill(killer_objnum, objnum); - + multibuf[0] = (char)MULTI_KILL; count += 1; multibuf[1] = Player_num; count += 1; - if (killer_objnum > -1) { + if (killer_objnum > -1) { short s; // do it with variable since INTEL_SHORT won't work on return val from function. - + s = (short)objnum_local_to_remote(killer_objnum, (byte *)&multibuf[count+2]); *(short *)(multibuf+count) = INTEL_SHORT(s); - } + } else { *(short *)(multibuf+count) = INTEL_SHORT((short)-1); @@ -2916,33 +2925,33 @@ multi_send_remobj(int objnum) byte obj_owner; short remote_objnum; - if (Objects[objnum].type==OBJ_POWERUP && (Game_mode & GM_NETWORK)) + if (Objects[objnum].type==OBJ_POWERUP && (Game_mode & GM_NETWORK)) { if (PowerupsInMine[Objects[objnum].id] > 0) - { - PowerupsInMine[Objects[objnum].id]--; - if (multi_powerup_is_4pack (Objects[objnum].id)) - { + { + PowerupsInMine[Objects[objnum].id]--; + if (multi_powerup_is_4pack (Objects[objnum].id)) + { mprintf ((0,"Hey babe! Doing that wacky 4 pack stuff.")); - + if (PowerupsInMine[Objects[objnum].id-1]-4<0) PowerupsInMine[Objects[objnum].id-1]=0; else PowerupsInMine[Objects[objnum].id-1]-=4; - } - } - - } - - multibuf[0] = (char)MULTI_REMOVE_OBJECT; + } + } + + } + + multibuf[0] = (char)MULTI_REMOVE_OBJECT; remote_objnum = objnum_local_to_remote((short)objnum, &obj_owner); *(short *)(multibuf+1) = INTEL_SHORT(remote_objnum); // Map to network objnums - multibuf[3] = obj_owner; + multibuf[3] = obj_owner; - // mprintf((0, "multi_send_remobj: %d = %d owner %d.\n", objnum, remote_objnum, obj_owner)); +// mprintf((0, "multi_send_remobj: %d = %d owner %d.\n", objnum, remote_objnum, obj_owner)); multi_send_data(multibuf, 4, 0); @@ -2952,7 +2961,7 @@ multi_send_remobj(int objnum) Network_send_objnum = -1; } } - + void multi_send_quit(int why) { @@ -3001,8 +3010,8 @@ multi_send_door_open(int segnum, int side,ubyte flag) multibuf[0] = MULTI_DOOR_OPEN; *(short *)(multibuf+1) = INTEL_SHORT( (short)segnum ); multibuf[3] = (byte)side; - multibuf[4] = flag; - + multibuf[4] = flag; + multi_send_data(multibuf, 5, 2); } @@ -3014,19 +3023,19 @@ multi_send_door_open_specific(int pnum,int segnum, int side,ubyte flag) // For sending doors only to a specific person (usually when they're joining) Assert (Game_mode & GM_NETWORK); - // Assert (pnum>-1 && pnum-1 && pnumx ); swapped_vec.y = (fix)INTEL_INT( (int)to_goal->y ); swapped_vec.z = (fix)INTEL_INT( (int)to_goal->z ); memcpy(multibuf+count, &swapped_vec, 12); count += 12; -#endif + #endif multibuf[count] = (char)best_gun_num; count += 1; *(short *)(multibuf+count) = INTEL_SHORT( (short)objnum ); count += 2; // ------------ @@ -3081,8 +3090,8 @@ multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector * #endif int count = 0; - if (Game_mode & GM_NETWORK) - PowerupsInMine[powerup_type]++; + if (Game_mode & GM_NETWORK) + PowerupsInMine[powerup_type]++; multibuf[count] = MULTI_CREATE_POWERUP; count += 1; multibuf[count] = Player_num; count += 1; @@ -3109,7 +3118,7 @@ multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector * mprintf((0, "Creating powerup type %d in segment %i.\n", powerup_type, segnum)); map_objnum_local_to_local(objnum); -} +} void multi_send_play_sound(int sound_num, fix volume) @@ -3160,14 +3169,14 @@ multi_send_score(void) *(int *)(multibuf+count) = INTEL_INT( Players[Player_num].score ); count += 4; multi_send_data(multibuf, count, 0); } -} +} void multi_send_save_game(ubyte slot, uint id, char * desc) { int count = 0; - + multibuf[count] = MULTI_SAVE_GAME; count += 1; multibuf[count] = slot; count += 1; // Save slot=0 *(uint *)(multibuf+count) = INTEL_INT( id ); count += 4; // Save id @@ -3180,7 +3189,7 @@ void multi_send_restore_game(ubyte slot, uint id) { int count = 0; - + multibuf[count] = MULTI_RESTORE_GAME; count += 1; multibuf[count] = slot; count += 1; // Save slot=0 *(uint *)(multibuf+count) = INTEL_INT( id ); count += 4; // Save id @@ -3192,7 +3201,7 @@ void multi_send_netplayer_stats_request(ubyte player_num) { int count = 0; - + multibuf[count] = MULTI_REQ_PLAYER; count += 1; multibuf[count] = player_num; count += 1; @@ -3203,17 +3212,17 @@ void multi_send_trigger(int triggernum) { // Send an even to trigger something in the mine - + int count = 0; - + multibuf[count] = MULTI_TRIGGER; count += 1; multibuf[count] = Player_num; count += 1; multibuf[count] = (ubyte)triggernum; count += 1; + + mprintf ((0,"Sending trigger %d\n",triggernum)); - mprintf ((0,"Sending trigger %d\n",triggernum)); - - multi_send_data(multibuf, count, 1); - //multi_send_data(multibuf, count, 1); // twice? + multi_send_data(multibuf, count, 1); +// multi_send_data(multibuf, count, 1); // twice? } void @@ -3223,14 +3232,14 @@ multi_send_hostage_door_status(int wallnum) // should be int count = 0; - + Assert(Walls[wallnum].type == WALL_BLASTABLE); multibuf[count] = MULTI_HOSTAGE_DOOR; count += 1; *(short *)(multibuf+count) = INTEL_SHORT( (short)wallnum ); count += 2; *(fix *)(multibuf+count) = (fix)INTEL_INT( (int)Walls[wallnum].hps ); count += 4; - // mprintf((0, "Door %d damaged by %f points.\n", wallnum, f2fl(Walls[wallnum].hps))); +// mprintf((0, "Door %d damaged by %f points.\n", wallnum, f2fl(Walls[wallnum].hps))); multi_send_data(multibuf, count, 0); } @@ -3245,7 +3254,7 @@ void multi_prep_level(void) // Do any special stuff to the level required for serial games // before we begin playing in it. - // Player_num MUST be set before calling this procedure. + // Player_num MUST be set before calling this procedure. // This function must be called before checksuming the Object array, // since the resulting checksum with depend on the value of Player_num @@ -3257,15 +3266,15 @@ void multi_prep_level(void) Assert(Game_mode & GM_MULTI); Assert(NumNetPlayerPositions > 0); - - PhallicLimit=0; - PhallicMan=-1; - Drop_afterburner_blob_flag=0; - ConsistencyCount=0; - - for (i=0;i= POW_KEY_BLUE) && (Objects[i].id <= POW_KEY_GOLD)) - { - Objects[i].id = POW_SHIELD_BOOST; - Objects[i].rtype.vclip_info.vclip_num = Powerup_info[Objects[i].id].vclip_num; - Objects[i].rtype.vclip_info.frametime = Vclip[Objects[i].rtype.vclip_info.vclip_num].frame_time; - } + { + Objects[i].id = POW_SHIELD_BOOST; + Objects[i].rtype.vclip_info.vclip_num = Powerup_info[Objects[i].id].vclip_num; + Objects[i].rtype.vclip_info.frametime = Vclip[Objects[i].rtype.vclip_info.vclip_num].frame_time; + } if (Objects[i].id == POW_INVULNERABILITY) { - if (inv_count >= 3 || (ng && !Netgame.DoInvulnerability)) { + if (inv_count >= 3 || (ng && !Netgame.DoInvulnerability)) { mprintf((0, "Bashing Invulnerability object #%i to shield.\n", i)); Objects[i].id = POW_SHIELD_BOOST; Objects[i].rtype.vclip_info.vclip_num = Powerup_info[Objects[i].id].vclip_num; @@ -3364,7 +3373,7 @@ void multi_prep_level(void) } if (Objects[i].id == POW_CLOAK) { - if (cloak_count >= 3 || (ng && !Netgame.DoCloak)) { + if (cloak_count >= 3 || (ng && !Netgame.DoCloak)) { mprintf((0, "Bashing Cloak object #%i to shield.\n", i)); Objects[i].id = POW_SHIELD_BOOST; Objects[i].rtype.vclip_info.vclip_num = Powerup_info[Objects[i].id].vclip_num; @@ -3373,95 +3382,95 @@ void multi_prep_level(void) cloak_count++; } - if (Objects[i].id == POW_AFTERBURNER && ng && !Netgame.DoAfterburner) - bash_to_shield (i,"afterburner"); - if (Objects[i].id == POW_FUSION_WEAPON && ng && !Netgame.DoFusions) - bash_to_shield (i,"fusion"); - if (Objects[i].id == POW_PHOENIX_WEAPON && ng && !Netgame.DoPhoenix) - bash_to_shield (i,"phoenix"); - - if (Objects[i].id == POW_HELIX_WEAPON && ng && !Netgame.DoHelix) - bash_to_shield (i,"helix"); - - if (Objects[i].id == POW_MEGA_WEAPON && ng && !Netgame.DoMegas) - bash_to_shield (i,"mega"); - - if (Objects[i].id == POW_SMARTBOMB_WEAPON && ng && !Netgame.DoSmarts) - bash_to_shield (i,"smartmissile"); - - if (Objects[i].id == POW_GAUSS_WEAPON && ng && !Netgame.DoGauss) - bash_to_shield (i,"gauss"); - - if (Objects[i].id == POW_VULCAN_WEAPON && ng && !Netgame.DoVulcan) - bash_to_shield (i,"vulcan"); - - if (Objects[i].id == POW_PLASMA_WEAPON && ng && !Netgame.DoPlasma) - bash_to_shield (i,"plasma"); - - if (Objects[i].id == POW_OMEGA_WEAPON && ng && !Netgame.DoOmega) - bash_to_shield (i,"omega"); - - if (Objects[i].id == POW_SUPER_LASER && ng && !Netgame.DoSuperLaser) - bash_to_shield (i,"superlaser"); - - if (Objects[i].id == POW_PROXIMITY_WEAPON && ng && !Netgame.DoProximity) - bash_to_shield (i,"proximity"); - - // Special: Make all proximity bombs into shields if in - // hoard mode because we use the proximity slot in the - // player struct to signify how many orbs the player has. - - if (Objects[i].id == POW_PROXIMITY_WEAPON && ng && (Game_mode & GM_HOARD)) - bash_to_shield (i,"proximity"); - - if (Objects[i].id==POW_VULCAN_AMMO && ng && (!Netgame.DoVulcan && !Netgame.DoGauss)) - bash_to_shield(i,"vulcan ammo"); - - if (Objects[i].id == POW_SPREADFIRE_WEAPON && ng && !Netgame.DoSpread) - bash_to_shield (i,"spread"); - if (Objects[i].id == POW_SMART_MINE && ng && !Netgame.DoSmartMine) - bash_to_shield (i,"smartmine"); - if (Objects[i].id == POW_SMISSILE1_1 && ng && !Netgame.DoFlash) - bash_to_shield (i,"flash"); - if (Objects[i].id == POW_SMISSILE1_4 && ng && !Netgame.DoFlash) - bash_to_shield (i,"flash"); - if (Objects[i].id == POW_GUIDED_MISSILE_1 && ng && !Netgame.DoGuided) - bash_to_shield (i,"guided"); - if (Objects[i].id == POW_GUIDED_MISSILE_4 && ng && !Netgame.DoGuided) - bash_to_shield (i,"guided"); - if (Objects[i].id == POW_EARTHSHAKER_MISSILE && ng && !Netgame.DoEarthShaker) - bash_to_shield (i,"earth"); - if (Objects[i].id == POW_MERCURY_MISSILE_1 && ng && !Netgame.DoMercury) - bash_to_shield (i,"Mercury"); - if (Objects[i].id == POW_MERCURY_MISSILE_4 && ng && !Netgame.DoMercury) - bash_to_shield (i,"Mercury"); - if (Objects[i].id == POW_CONVERTER && ng && !Netgame.DoConverter) - bash_to_shield (i,"Converter"); - if (Objects[i].id == POW_AMMO_RACK && ng && !Netgame.DoAmmoRack) - bash_to_shield (i,"Ammo rack"); - if (Objects[i].id == POW_HEADLIGHT && ng && !Netgame.DoHeadlight) - bash_to_shield (i,"Headlight"); - if (Objects[i].id == POW_LASER && ng && !Netgame.DoLaserUpgrade) - bash_to_shield (i,"Laser powerup"); - if (Objects[i].id == POW_HOMING_AMMO_1 && ng && !Netgame.DoHoming) - bash_to_shield (i,"Homing"); - if (Objects[i].id == POW_HOMING_AMMO_4 && ng && !Netgame.DoHoming) - bash_to_shield (i,"Homing"); - if (Objects[i].id == POW_QUAD_FIRE && ng && !Netgame.DoQuadLasers) - bash_to_shield (i,"Quad Lasers"); - if (Objects[i].id == POW_FLAG_BLUE && !(Game_mode & GM_CAPTURE)) - bash_to_shield (i,"Blue flag"); - if (Objects[i].id == POW_FLAG_RED && !(Game_mode & GM_CAPTURE)) - bash_to_shield (i,"Red flag"); - } - } - + if (Objects[i].id == POW_AFTERBURNER && ng && !Netgame.DoAfterburner) + bash_to_shield (i,"afterburner"); + if (Objects[i].id == POW_FUSION_WEAPON && ng && !Netgame.DoFusions) + bash_to_shield (i,"fusion"); + if (Objects[i].id == POW_PHOENIX_WEAPON && ng && !Netgame.DoPhoenix) + bash_to_shield (i,"phoenix"); + + if (Objects[i].id == POW_HELIX_WEAPON && ng && !Netgame.DoHelix) + bash_to_shield (i,"helix"); + + if (Objects[i].id == POW_MEGA_WEAPON && ng && !Netgame.DoMegas) + bash_to_shield (i,"mega"); + + if (Objects[i].id == POW_SMARTBOMB_WEAPON && ng && !Netgame.DoSmarts) + bash_to_shield (i,"smartmissile"); + + if (Objects[i].id == POW_GAUSS_WEAPON && ng && !Netgame.DoGauss) + bash_to_shield (i,"gauss"); + + if (Objects[i].id == POW_VULCAN_WEAPON && ng && !Netgame.DoVulcan) + bash_to_shield (i,"vulcan"); + + if (Objects[i].id == POW_PLASMA_WEAPON && ng && !Netgame.DoPlasma) + bash_to_shield (i,"plasma"); + + if (Objects[i].id == POW_OMEGA_WEAPON && ng && !Netgame.DoOmega) + bash_to_shield (i,"omega"); + + if (Objects[i].id == POW_SUPER_LASER && ng && !Netgame.DoSuperLaser) + bash_to_shield (i,"superlaser"); + + if (Objects[i].id == POW_PROXIMITY_WEAPON && ng && !Netgame.DoProximity) + bash_to_shield (i,"proximity"); + +// Special: Make all proximity bombs into shields if in hoard mode because +// we use the proximity slot in the player struct to signify how many orbs +// the player has. + + if (Objects[i].id == POW_PROXIMITY_WEAPON && ng && (Game_mode & GM_HOARD)) + bash_to_shield (i,"proximity"); + + if (Objects[i].id==POW_VULCAN_AMMO && ng && (!Netgame.DoVulcan && !Netgame.DoGauss)) + bash_to_shield(i,"vulcan ammo"); + + if (Objects[i].id == POW_SPREADFIRE_WEAPON && ng && !Netgame.DoSpread) + bash_to_shield (i,"spread"); + if (Objects[i].id == POW_SMART_MINE && ng && !Netgame.DoSmartMine) + bash_to_shield (i,"smartmine"); + if (Objects[i].id == POW_SMISSILE1_1 && ng && !Netgame.DoFlash) + bash_to_shield (i,"flash"); + if (Objects[i].id == POW_SMISSILE1_4 && ng && !Netgame.DoFlash) + bash_to_shield (i,"flash"); + if (Objects[i].id == POW_GUIDED_MISSILE_1 && ng && !Netgame.DoGuided) + bash_to_shield (i,"guided"); + if (Objects[i].id == POW_GUIDED_MISSILE_4 && ng && !Netgame.DoGuided) + bash_to_shield (i,"guided"); + if (Objects[i].id == POW_EARTHSHAKER_MISSILE && ng && !Netgame.DoEarthShaker) + bash_to_shield (i,"earth"); + if (Objects[i].id == POW_MERCURY_MISSILE_1 && ng && !Netgame.DoMercury) + bash_to_shield (i,"Mercury"); + if (Objects[i].id == POW_MERCURY_MISSILE_4 && ng && !Netgame.DoMercury) + bash_to_shield (i,"Mercury"); + if (Objects[i].id == POW_CONVERTER && ng && !Netgame.DoConverter) + bash_to_shield (i,"Converter"); + if (Objects[i].id == POW_AMMO_RACK && ng && !Netgame.DoAmmoRack) + bash_to_shield (i,"Ammo rack"); + if (Objects[i].id == POW_HEADLIGHT && ng && !Netgame.DoHeadlight) + bash_to_shield (i,"Headlight"); + if (Objects[i].id == POW_LASER && ng && !Netgame.DoLaserUpgrade) + bash_to_shield (i,"Laser powerup"); + if (Objects[i].id == POW_HOMING_AMMO_1 && ng && !Netgame.DoHoming) + bash_to_shield (i,"Homing"); + if (Objects[i].id == POW_HOMING_AMMO_4 && ng && !Netgame.DoHoming) + bash_to_shield (i,"Homing"); + if (Objects[i].id == POW_QUAD_FIRE && ng && !Netgame.DoQuadLasers) + bash_to_shield (i,"Quad Lasers"); + if (Objects[i].id == POW_FLAG_BLUE && !(Game_mode & GM_CAPTURE)) + bash_to_shield (i,"Blue flag"); + if (Objects[i].id == POW_FLAG_RED && !(Game_mode & GM_CAPTURE)) + bash_to_shield (i,"Red flag"); + } + } + if (Game_mode & GM_HOARD) init_hoard_data(); - if ((Game_mode & GM_CAPTURE) || (Game_mode & GM_HOARD)) - multi_apply_goal_textures(); - + if ((Game_mode & GM_CAPTURE) || (Game_mode & GM_HOARD)) + multi_apply_goal_textures(); + multi_sort_kill_list(); multi_show_player_list(); @@ -3479,22 +3488,22 @@ void multi_apply_goal_textures() int i,j,tex; segment *seg; segment2 *seg2; - + for (i=0; i <= Highest_segment_index; i++) - { + { seg = &Segments[i]; seg2 = &Segment2s[i]; - - if (seg2->special==SEGMENT_IS_GOAL_BLUE) - { - + + if (seg2->special==SEGMENT_IS_GOAL_BLUE) + { + Goal_blue_segnum = i; if (Game_mode & GM_HOARD) tex=find_goal_texture (TMI_GOAL_HOARD); else tex=find_goal_texture (TMI_GOAL_BLUE); - + if (tex>-1) for (j = 0; j < 6; j++) { int v; @@ -3505,10 +3514,10 @@ void multi_apply_goal_textures() seg2->static_light = i2f(100); //make static light bright - } - - if (seg2->special==SEGMENT_IS_GOAL_RED) - { + } + + if (seg2->special==SEGMENT_IS_GOAL_RED) + { Goal_red_segnum = i; // Make both textures the same if Hoard mode @@ -3517,7 +3526,7 @@ void multi_apply_goal_textures() tex=find_goal_texture (TMI_GOAL_HOARD); else tex=find_goal_texture (TMI_GOAL_RED); - + if (tex>-1) for (j = 0; j < 6; j++) { int v; @@ -3527,37 +3536,37 @@ void multi_apply_goal_textures() } seg2->static_light = i2f(100); //make static light bright - } - } -} + } + } + } int find_goal_texture (ubyte t) -{ - int i; - - for (i=0;itype==OBJ_PLAYER) || (objp->type==OBJ_GHOST)) + if ((objp->type==OBJ_PLAYER) || (objp->type==OBJ_GHOST)) nnp++; else if ((objp->type==OBJ_ROBOT) && (Game_mode & GM_MULTI_ROBOTS)) ; else if ( (objp->type!=OBJ_NONE) && (objp->type!=OBJ_PLAYER) && (objp->type!=OBJ_POWERUP) && (objp->type!=OBJ_CNTRLCEN) && (objp->type!=OBJ_HOSTAGE) && !(objp->type==OBJ_WEAPON && objp->id==PMINE_ID) ) { - // Before deleting object, if it's a robot, drop it's special powerup, if any + // Before deleting object, if it's a robot, drop it's special powerup, if any if (objp->type == OBJ_ROBOT) if (objp->contains_count && (objp->contains_type == OBJ_POWERUP)) object_create_egg(objp); @@ -3608,7 +3617,7 @@ int multi_delete_extra_objects() return nnp; } -void change_playernum_to( int new_Player_num ) +void change_playernum_to( int new_Player_num ) { if (Player_num > -1) memcpy( Players[new_Player_num].callsign, Players[Player_num].callsign, CALLSIGN_LEN+1 ); @@ -3616,15 +3625,15 @@ void change_playernum_to( int new_Player_num ) } int multi_all_players_alive() -{ - int i; - for (i=0;iflags = INTEL_INT(pd->flags); // Powerup flags, see below... - ps->energy = (fix)INTEL_INT(pd->energy); // Amount of energy remaining. - ps->shields = (fix)INTEL_INT(pd->shields); // shields remaining (protection) - ps->lives = pd->lives; // Lives remaining, 0 = game over. - ps->laser_level = pd->laser_level; // Current level of the laser. - ps->primary_weapon_flags=pd->primary_weapon_flags; // bit set indicates the player has this weapon. - ps->secondary_weapon_flags=pd->secondary_weapon_flags; // bit set indicates the player has this weapon. + + ps->flags = INTEL_INT(pd->flags); // Powerup flags, see below... + ps->energy = (fix)INTEL_INT(pd->energy); // Amount of energy remaining. + ps->shields = (fix)INTEL_INT(pd->shields); // shields remaining (protection) + ps->lives = pd->lives; // Lives remaining, 0 = game over. + ps->laser_level = pd->laser_level; // Current level of the laser. + ps->primary_weapon_flags=pd->primary_weapon_flags; // bit set indicates the player has this weapon. + ps->secondary_weapon_flags=pd->secondary_weapon_flags; // bit set indicates the player has this weapon. for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) ps->primary_ammo[i] = INTEL_SHORT(pd->primary_ammo[i]); for (i = 0; i < MAX_SECONDARY_WEAPONS; i++) ps->secondary_ammo[i] = INTEL_SHORT(pd->secondary_ammo[i]); - //memcpy( ps->primary_ammo, pd->primary_ammo, MAX_PRIMARY_WEAPONS*sizeof(short) ); // How much ammo of each type. - //memcpy( ps->secondary_ammo, pd->secondary_ammo, MAX_SECONDARY_WEAPONS*sizeof(short) ); // How much ammo of each type. +// memcpy( ps->primary_ammo, pd->primary_ammo, MAX_PRIMARY_WEAPONS*sizeof(short) ); // How much ammo of each type. +// memcpy( ps->secondary_ammo, pd->secondary_ammo, MAX_SECONDARY_WEAPONS*sizeof(short) ); // How much ammo of each type. - ps->last_score=INTEL_INT(pd->last_score); // Score at beginning of current level. - ps->score=INTEL_INT(pd->score); // Current score. - ps->cloak_time=(fix)INTEL_INT(pd->cloak_time); // Time cloaked - ps->homing_object_dist=(fix)INTEL_INT(pd->homing_object_dist); // Distance of nearest homing object. - ps->invulnerable_time=(fix)INTEL_INT(pd->invulnerable_time); // Time invulnerable + ps->last_score=INTEL_INT(pd->last_score); // Score at beginning of current level. + ps->score=INTEL_INT(pd->score); // Current score. + ps->cloak_time=(fix)INTEL_INT(pd->cloak_time); // Time cloaked + ps->homing_object_dist=(fix)INTEL_INT(pd->homing_object_dist); // Distance of nearest homing object. + ps->invulnerable_time=(fix)INTEL_INT(pd->invulnerable_time); // Time invulnerable ps->KillGoalCount=INTEL_SHORT(pd->KillGoalCount); - ps->net_killed_total=INTEL_SHORT(pd->net_killed_total); // Number of times killed total - ps->net_kills_total=INTEL_SHORT(pd->net_kills_total); // Number of net kills total - ps->num_kills_level=INTEL_SHORT(pd->num_kills_level); // Number of kills this level - ps->num_kills_total=INTEL_SHORT(pd->num_kills_total); // Number of kills total - ps->num_robots_level=INTEL_SHORT(pd->num_robots_level); // Number of initial robots this level - ps->num_robots_total=INTEL_SHORT(pd->num_robots_total); // Number of robots total - ps->hostages_rescued_total=INTEL_SHORT(pd->hostages_rescued_total); // Total number of hostages rescued. - ps->hostages_total=INTEL_SHORT(pd->hostages_total); // Total number of hostages. - ps->hostages_on_board=pd->hostages_on_board; // Number of hostages on ship. + ps->net_killed_total=INTEL_SHORT(pd->net_killed_total); // Number of times killed total + ps->net_kills_total=INTEL_SHORT(pd->net_kills_total); // Number of net kills total + ps->num_kills_level=INTEL_SHORT(pd->num_kills_level); // Number of kills this level + ps->num_kills_total=INTEL_SHORT(pd->num_kills_total); // Number of kills total + ps->num_robots_level=INTEL_SHORT(pd->num_robots_level); // Number of initial robots this level + ps->num_robots_total=INTEL_SHORT(pd->num_robots_total); // Number of robots total + ps->hostages_rescued_total=INTEL_SHORT(pd->hostages_rescued_total); // Total number of hostages rescued. + ps->hostages_total=INTEL_SHORT(pd->hostages_total); // Total number of hostages. + ps->hostages_on_board=pd->hostages_on_board; // Number of hostages on ship. } void use_netplayer_stats( player * ps, netplayer_stats *pd ) { int i; - - ps->flags = INTEL_INT(pd->flags); // Powerup flags, see below... - ps->energy = (fix)INTEL_INT((int)pd->energy); // Amount of energy remaining. - ps->shields = (fix)INTEL_INT((int)pd->shields); // shields remaining (protection) - ps->lives = pd->lives; // Lives remaining, 0 = game over. - ps->laser_level = pd->laser_level; // Current level of the laser. - ps->primary_weapon_flags=pd->primary_weapon_flags; // bit set indicates the player has this weapon. - ps->secondary_weapon_flags=pd->secondary_weapon_flags; // bit set indicates the player has this weapon. + + ps->flags = INTEL_INT(pd->flags); // Powerup flags, see below... + ps->energy = (fix)INTEL_INT((int)pd->energy); // Amount of energy remaining. + ps->shields = (fix)INTEL_INT((int)pd->shields); // shields remaining (protection) + ps->lives = pd->lives; // Lives remaining, 0 = game over. + ps->laser_level = pd->laser_level; // Current level of the laser. + ps->primary_weapon_flags=pd->primary_weapon_flags; // bit set indicates the player has this weapon. + ps->secondary_weapon_flags=pd->secondary_weapon_flags; // bit set indicates the player has this weapon. for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) ps->primary_ammo[i] = INTEL_SHORT(pd->primary_ammo[i]); for (i = 0; i < MAX_SECONDARY_WEAPONS; i++) ps->secondary_ammo[i] = INTEL_SHORT(pd->secondary_ammo[i]); - //memcpy( ps->primary_ammo, pd->primary_ammo, MAX_PRIMARY_WEAPONS*sizeof(short) ); // How much ammo of each type. - //memcpy( ps->secondary_ammo, pd->secondary_ammo, MAX_SECONDARY_WEAPONS*sizeof(short) ); // How much ammo of each type. - ps->last_score = INTEL_INT(pd->last_score); // Score at beginning of current level. - ps->score = INTEL_INT(pd->score); // Current score. - ps->cloak_time = (fix)INTEL_INT((int)pd->cloak_time); // Time cloaked - ps->homing_object_dist = (fix)INTEL_INT((int)pd->homing_object_dist); // Distance of nearest homing object. - ps->invulnerable_time = (fix)INTEL_INT((int)pd->invulnerable_time); // Time invulnerable +// memcpy( ps->primary_ammo, pd->primary_ammo, MAX_PRIMARY_WEAPONS*sizeof(short) ); // How much ammo of each type. +// memcpy( ps->secondary_ammo, pd->secondary_ammo, MAX_SECONDARY_WEAPONS*sizeof(short) ); // How much ammo of each type. + ps->last_score = INTEL_INT(pd->last_score); // Score at beginning of current level. + ps->score = INTEL_INT(pd->score); // Current score. + ps->cloak_time = (fix)INTEL_INT((int)pd->cloak_time); // Time cloaked + ps->homing_object_dist = (fix)INTEL_INT((int)pd->homing_object_dist); // Distance of nearest homing object. + ps->invulnerable_time = (fix)INTEL_INT((int)pd->invulnerable_time); // Time invulnerable ps->KillGoalCount=INTEL_SHORT(pd->KillGoalCount); - ps->net_killed_total = INTEL_SHORT(pd->net_killed_total); // Number of times killed total - ps->net_kills_total = INTEL_SHORT(pd->net_kills_total); // Number of net kills total - ps->num_kills_level = INTEL_SHORT(pd->num_kills_level); // Number of kills this level - ps->num_kills_total = INTEL_SHORT(pd->num_kills_total); // Number of kills total - ps->num_robots_level = INTEL_SHORT(pd->num_robots_level); // Number of initial robots this level - ps->num_robots_total = INTEL_SHORT(pd->num_robots_total); // Number of robots total - ps->hostages_rescued_total = INTEL_SHORT(pd->hostages_rescued_total); // Total number of hostages rescued. - ps->hostages_total = INTEL_SHORT(pd->hostages_total); // Total number of hostages. - ps->hostages_on_board=pd->hostages_on_board; // Number of hostages on ship. + ps->net_killed_total = INTEL_SHORT(pd->net_killed_total); // Number of times killed total + ps->net_kills_total = INTEL_SHORT(pd->net_kills_total); // Number of net kills total + ps->num_kills_level = INTEL_SHORT(pd->num_kills_level); // Number of kills this level + ps->num_kills_total = INTEL_SHORT(pd->num_kills_total); // Number of kills total + ps->num_robots_level = INTEL_SHORT(pd->num_robots_level); // Number of initial robots this level + ps->num_robots_total = INTEL_SHORT(pd->num_robots_total); // Number of robots total + ps->hostages_rescued_total = INTEL_SHORT(pd->hostages_rescued_total); // Total number of hostages rescued. + ps->hostages_total = INTEL_SHORT(pd->hostages_total); // Total number of hostages. + ps->hostages_on_board=pd->hostages_on_board; // Number of hostages on ship. } void multi_send_drop_weapon (int objnum,int seed) -{ + { object *objp; - int count=0; + int count=0; int ammo_count; objp = &Objects[objnum]; @@ -3855,31 +3861,31 @@ void multi_send_drop_weapon (int objnum,int seed) ammo_count = objp->ctype.powerup_info.count; if (objp->id == POW_OMEGA_WEAPON && ammo_count == F1_0) - ammo_count = F1_0 - 1; //make fit in short - - Assert(ammo_count < F1_0); //make sure fits in short - - multibuf[count++]=(char)MULTI_DROP_WEAPON; - multibuf[count++]=(char)objp->id; + ammo_count = F1_0 - 1; //make fit in short - *(short *) (multibuf+count)=INTEL_SHORT(Player_num); count += 2; - *(short *) (multibuf+count)=INTEL_SHORT(objnum); count += 2; - *(short *) (multibuf+count)=INTEL_SHORT(ammo_count); count += 2; - *(int *) (multibuf+count)=INTEL_INT(seed); + Assert(ammo_count < F1_0); //make sure fits in short - map_objnum_local_to_local(objnum); + multibuf[count++]=(char)MULTI_DROP_WEAPON; + multibuf[count++]=(char)objp->id; - if (Game_mode & GM_NETWORK) - PowerupsInMine[objp->id]++; + *(short *) (multibuf+count)=INTEL_SHORT(Player_num); count += 2; + *(short *) (multibuf+count)=INTEL_SHORT(objnum); count += 2; + *(short *) (multibuf+count)=INTEL_SHORT(ammo_count); count += 2; + *(int *) (multibuf+count)=INTEL_INT(seed); + + map_objnum_local_to_local(objnum); + + if (Game_mode & GM_NETWORK) + PowerupsInMine[objp->id]++; - multi_send_data(multibuf, 12, 2); -} + multi_send_data(multibuf, 12, 2); + } void multi_do_drop_weapon (char *buf) -{ - int pnum,ammo,objnum,remote_objnum,seed; + { + int pnum,ammo,objnum,remote_objnum,seed; object *objp; - int powerup_id; + int powerup_id; powerup_id=(int)(buf[1]); pnum = INTEL_SHORT(*(short *)(buf+2)); @@ -3891,34 +3897,34 @@ void multi_do_drop_weapon (char *buf) objnum = spit_powerup(objp, powerup_id, seed); - map_objnum_local_to_remote(objnum, remote_objnum, pnum); + map_objnum_local_to_remote(objnum, remote_objnum, pnum); if (objnum!=-1) - Objects[objnum].ctype.powerup_info.count = ammo; - - if (Game_mode & GM_NETWORK) + Objects[objnum].ctype.powerup_info.count = ammo; + + if (Game_mode & GM_NETWORK) PowerupsInMine[powerup_id]++; - mprintf ((0,"Dropped weapon %d!\n")); - -} + mprintf ((0,"Dropped weapon %d!\n")); + + } void multi_send_guided_info (object *miss,char done) { #ifdef MACINTOSH shortpos sp; #endif - int count=0; + int count=0; - mprintf ((0,"Sending guided info!\n")); + mprintf ((0,"Sending guided info!\n")); - multibuf[count++]=(char)MULTI_GUIDED; - multibuf[count++]=(char)Player_num; - multibuf[count++]=done; + multibuf[count++]=(char)MULTI_GUIDED; + multibuf[count++]=(char)Player_num; + multibuf[count++]=done; #ifndef MACINTOSH - create_shortpos((shortpos *)(multibuf+count), miss,0); - count+=sizeof(shortpos); + create_shortpos((shortpos *)(multibuf+count), miss,0); + count+=sizeof(shortpos); #else create_shortpos(&sp, miss, 1); memcpy(&(multibuf[count]), (ubyte *)(sp.bytemat), 9); @@ -3927,331 +3933,330 @@ void multi_send_guided_info (object *miss,char done) count += 14; #endif - multi_send_data(multibuf, count, 0); -} + multi_send_data(multibuf, count, 0); + } void multi_do_guided (char *buf) -{ - char pnum=buf[1]; - int count=3; - static int fun=200; + { + char pnum=buf[1]; + int count=3; + static int fun=200; #ifdef MACINTOSH shortpos sp; #endif - if (Guided_missile[(int)pnum]==NULL) - { - if (++fun>=50) - { - mprintf ((0,"Guided missile for %s is NULL!\n",Players[(int)pnum].callsign)); - fun=0; - } - return; - } - else if (++fun>=50) - { - mprintf ((0,"Got guided info for %d (%s)\n",pnum,Players[(int)pnum].callsign)); - fun=0; - } + if (Guided_missile[(int)pnum]==NULL) + { + if (++fun>=50) + { + mprintf ((0,"Guided missile for %s is NULL!\n",Players[(int)pnum].callsign)); + fun=0; + } + return; + } + else if (++fun>=50) + { + mprintf ((0,"Got guided info for %d (%s)\n",pnum,Players[(int)pnum].callsign)); + fun=0; + } - if (buf[2]) - { - release_guided_missile(pnum); - return; + if (buf[2]) + { + release_guided_missile(pnum); + return; } - if (Guided_missile[(int)pnum]-Objects<0 || Guided_missile[(int)pnum]-Objects > Highest_object_index) - { - Int3(); // Get Jason immediately! - return; + if (Guided_missile[(int)pnum]-Objects<0 || Guided_missile[(int)pnum]-Objects > Highest_object_index) + { + Int3(); // Get Jason immediately! + return; } -#ifndef MACINTOSH - extract_shortpos(Guided_missile[(int)pnum], (shortpos *)(buf+count),0); +#ifndef MACINTOSH + extract_shortpos(Guided_missile[(int)pnum], (shortpos *)(buf+count),0); #else memcpy((ubyte *)(sp.bytemat), (ubyte *)(buf + count), 9); memcpy((ubyte *)&(sp.xo), (ubyte *)(buf + count + 9), 14); extract_shortpos(Guided_missile[(int)pnum], &sp, 1); #endif - count+=sizeof (shortpos); + count+=sizeof (shortpos); - update_object_seg(Guided_missile[(int)pnum]); -} + update_object_seg(Guided_missile[(int)pnum]); + } void multi_send_stolen_items () -{ - int i,count=1; - multibuf[0]=MULTI_STOLEN_ITEMS; - - for (i=0;i-1 && pnum-1 && pnum=0); - Walls[wallnum].type=type; - Walls[wallnum].flags=flag; - //Assert(state <= 4); - Walls[wallnum].state=state; - - if (Walls[wallnum].type==WALL_OPEN) - { - digi_kill_sound_linked_to_segment(Walls[wallnum].segnum,Walls[wallnum].sidenum,SOUND_FORCEFIELD_HUM); - //digi_kill_sound_linked_to_segment(csegp-Segments,cside,SOUND_FORCEFIELD_HUM); - } - + { + short wallnum; + ubyte flag,type,state; + + wallnum=INTEL_SHORT( *(short *)(buf+1) ); + type=buf[3]; + flag=buf[4]; + state=buf[5]; + + Assert (wallnum>=0); + Walls[wallnum].type=type; + Walls[wallnum].flags=flag; +// Assert(state <= 4); + Walls[wallnum].state=state; + + if (Walls[wallnum].type==WALL_OPEN) + { + digi_kill_sound_linked_to_segment(Walls[wallnum].segnum,Walls[wallnum].sidenum,SOUND_FORCEFIELD_HUM); + // digi_kill_sound_linked_to_segment(csegp-Segments,cside,SOUND_FORCEFIELD_HUM); + } - //mprintf ((0,"Got a walls packet.\n")); -} + +// mprintf ((0,"Got a walls packet.\n")); + } void multi_send_jason_cheat (int num) -{ - num=num; - return; -} + { + num=num; + return; + } void multi_send_kill_goal_counts() -{ - int i,count=1; - multibuf[0]=MULTI_KILLGOALS; - - for (i=0;ibest) - { - best=Players[i].KillGoalCount; - bestnum=i; - } - } - - if (bestnum==Player_num) - { - HUD_init_message("You have the best score at %d kills!",best); - //Players[Player_num].shields=i2f(200); - } - else - - HUD_init_message ("%s has the best score with %d kills!",Players[bestnum].callsign,best); + { + int i,best=0,bestnum=0; + object *objp; + + + if (Control_center_destroyed) + return; + + for (i=0;ibest) + { + best=Players[i].KillGoalCount; + bestnum=i; + } + } - HUD_init_message ("The control center has been destroyed!"); + if (bestnum==Player_num) + { + HUD_init_message("You have the best score at %d kills!",best); +// Players[Player_num].shields=i2f(200); + } + else - objp=obj_find_first_of_type (OBJ_CNTRLCEN); - net_destroy_controlcen (objp); -} + HUD_init_message ("%s has the best score with %d kills!",Players[bestnum].callsign,best); + HUD_init_message ("The control center has been destroyed!"); + + objp=obj_find_first_of_type (OBJ_CNTRLCEN); + net_destroy_controlcen (objp); + } + void multi_send_seismic (fix start,fix end) -{ - int count=1; - - multibuf[0]=MULTI_SEISMIC; - *(fix *)(multibuf+count)=(fix)INTEL_INT(start); count+=(sizeof(fix)); - *(fix *)(multibuf+count)=(fix)INTEL_INT(end); count+=(sizeof(fix)); - - multi_send_data(multibuf, count, 1); -} + { + int count=1; + + multibuf[0]=MULTI_SEISMIC; + *(fix *)(multibuf+count)=(fix)INTEL_INT(start); count+=(sizeof(fix)); + *(fix *)(multibuf+count)=(fix)INTEL_INT(end); count+=(sizeof(fix)); + + multi_send_data(multibuf, count, 1); + } extern fix Seismic_disturbance_start_time; extern fix Seismic_disturbance_end_time; - + void multi_do_seismic (char *buf) -{ - Seismic_disturbance_start_time=(fix)INTEL_INT( *(int *)(buf+1) ); - Seismic_disturbance_end_time=(fix)INTEL_INT( *(int *)(buf+5) ); - digi_play_sample (SOUND_SEISMIC_DISTURBANCE_START, F1_0); -} + { + Seismic_disturbance_start_time=(fix)INTEL_INT( *(int *)(buf+1) ); + Seismic_disturbance_end_time=(fix)INTEL_INT( *(int *)(buf+5) ); + digi_play_sample (SOUND_SEISMIC_DISTURBANCE_START, F1_0); + } void multi_send_light (int segnum,ubyte val) -{ - int count=1,i; - multibuf[0]=MULTI_LIGHT; - *(int *)(multibuf+count)=INTEL_INT(segnum); count+=(sizeof(int)); - *(char *)(multibuf+count)=val; count++; - for (i=0;i<6;i++) + { + int count=1,i; + multibuf[0]=MULTI_LIGHT; + *(int *)(multibuf+count)=INTEL_INT(segnum); count+=(sizeof(int)); + *(char *)(multibuf+count)=val; count++; + for (i=0;i<6;i++) { - //mprintf ((0,"Sending %d!\n",Segments[segnum].sides[i].tmap_num2)); - *(short *)(multibuf+count)=INTEL_SHORT(Segments[segnum].sides[i].tmap_num2); count+=2; + //mprintf ((0,"Sending %d!\n",Segments[segnum].sides[i].tmap_num2)); + *(short *)(multibuf+count)=INTEL_SHORT(Segments[segnum].sides[i].tmap_num2); count+=2; } - multi_send_data(multibuf, count, 1); -} + multi_send_data(multibuf, count, 1); + } void multi_send_light_specific (int pnum,int segnum,ubyte val) -{ - int count=1,i; - - Assert (Game_mode & GM_NETWORK); - // Assert (pnum>-1 && pnum-1 && pnum= N_players) || (pnum == Player_num)) //@@ { @@ -4264,8 +4269,8 @@ void multi_do_light (char *buf) //@@ return; //@@ } //@@ -//@@ if (!(Triggers[trigger].flags & TF_SPRUNG)) -//@@ check_trigger_sub(trigger, pnum,0); +//@@ if (!(Triggers[trigger].flags & TF_SPRUNG)) +//@@ check_trigger_sub(trigger, pnum,0); //@@} @@ -4279,71 +4284,71 @@ void multi_do_flags (char *buf) } void multi_send_flags (char pnum) -{ - multibuf[0]=MULTI_FLAGS; - multibuf[1]=pnum; - *(uint *)(multibuf+2)=INTEL_INT(Players[(int)pnum].flags); - - multi_send_data(multibuf, 6, 1); -} - + { + multibuf[0]=MULTI_FLAGS; + multibuf[1]=pnum; + *(uint *)(multibuf+2)=INTEL_INT(Players[(int)pnum].flags); + + multi_send_data(multibuf, 6, 1); + } + void multi_send_drop_blobs (char pnum) -{ - multibuf[0]=MULTI_DROP_BLOB; - multibuf[1]=pnum; + { + multibuf[0]=MULTI_DROP_BLOB; + multibuf[1]=pnum; - multi_send_data(multibuf, 2, 0); -} + multi_send_data(multibuf, 2, 0); + } void multi_do_drop_blob (char *buf) -{ - char pnum=buf[1]; - drop_afterburner_blobs (&Objects[Players[(int)pnum].objnum], 2, i2f(5)/2, -1); -} + { + char pnum=buf[1]; + drop_afterburner_blobs (&Objects[Players[(int)pnum].objnum], 2, i2f(5)/2, -1); + } void multi_send_powerup_update () -{ - int i; - + { + int i; - multibuf[0]=MULTI_POWERUP_UPDATE; - for (i=0;iMaxPowerupsAllowed[i]) - MaxPowerupsAllowed[i]=buf[i+1]; -} + for (i=0;iMaxPowerupsAllowed[i]) + MaxPowerupsAllowed[i]=buf[i+1]; + } extern active_door ActiveDoors[]; -extern int Num_open_doors; // Number of open doors - +extern int Num_open_doors; // Number of open doors + void multi_send_active_door (char i) { int count; - + multibuf[0]=MULTI_ACTIVE_DOOR; multibuf[1]=i; - multibuf[2]=Num_open_doors; + multibuf[2]=Num_open_doors; count = 3; #ifndef MACINTOSH memcpy ((char *)(&multibuf[3]),&ActiveDoors[(int)i],sizeof(struct active_door)); count += sizeof(active_door); #else - *(int *)(multibuf + count) = INTEL_INT(ActiveDoors[i].n_parts); count += 4; - *(short *)(multibuf + count) = INTEL_SHORT(ActiveDoors[i].front_wallnum[0]); count += 2; - *(short *)(multibuf + count) = INTEL_SHORT(ActiveDoors[i].front_wallnum[1]) count += 2; - *(short *)(multibuf + count) = INTEL_SHORT(ActiveDoors[i].back_wallnum[0]); count += 2; - *(short *)(multibuf + count) = INTEL_SHORT(ActiveDoors[i].back_wallnum[1]); count += 2; - *(int *)(multibuf + count) = INTEL_INT(ActiveDoors[i].time); count += 4; + *(int *)(multibuf + count) = INTEL_INT(ActiveDoors[i].n_parts); count += 4; + *(short *)(multibuf + count) = INTEL_SHORT(ActiveDoors[i].front_wallnum[0]); count += 2; + *(short *)(multibuf + count) = INTEL_SHORT(ActiveDoors[i].front_wallnum[1]); count += 2; + *(short *)(multibuf + count) = INTEL_SHORT(ActiveDoors[i].back_wallnum[0]); count += 2; + *(short *)(multibuf + count) = INTEL_SHORT(ActiveDoors[i].back_wallnum[1]); count += 2; + *(int *)(multibuf + count) = INTEL_INT(ActiveDoors[i].time); count += 4; #endif - //multi_send_data (multibuf,sizeof(struct active_door)+3,1); +// multi_send_data (multibuf,sizeof(struct active_door)+3,1); multi_send_data (multibuf,count,1); } @@ -4352,90 +4357,90 @@ void multi_do_active_door (char *buf) int count; char i=multibuf[1]; Num_open_doors=buf[2]; - + count = 3; #ifndef MACINTOSH memcpy (&ActiveDoors[(int)i],buf+count,sizeof(struct active_door)); #else - ActiveDoors[i].n_parts = INTEL_INT( *(int *)(buf+count) ); count += 4; - ActiveDoors[i].front_wallnum[0] = INTEL_SHORT( *(short *)(buf+count) ); count +=2; - ActiveDoors[i].front_wallnum[1] = INTEL_SHORT( *(short *)(buf+count) ); count +=2; - ActiveDoors[i].back_wallnum[0] = INTEL_SHORT( *(short *)(buf+count) ); count +=2; - ActiveDoors[i].back_wallnum[1] = INTEL_SHORT( *(short *)(buf+count) ); count +=2; - ActiveDoors[i].time = INTEL_INT( *(int *)(buf+count) ); count += 4; + ActiveDoors[i].n_parts = INTEL_INT( *(int *)(buf+count) ); count += 4; + ActiveDoors[i].front_wallnum[0] = INTEL_SHORT( *(short *)(buf+count) ); count +=2; + ActiveDoors[i].front_wallnum[1] = INTEL_SHORT( *(short *)(buf+count) ); count +=2; + ActiveDoors[i].back_wallnum[0] = INTEL_SHORT( *(short *)(buf+count) ); count +=2; + ActiveDoors[i].back_wallnum[1] = INTEL_SHORT( *(short *)(buf+count) ); count +=2; + ActiveDoors[i].time = INTEL_INT( *(int *)(buf+count) ); count += 4; #endif -} +} void multi_send_sound_function (char whichfunc,char sound) { int count=0; - - multibuf[0]=MULTI_SOUND_FUNCTION; count++; - multibuf[1]=Player_num; count++; - multibuf[2]=whichfunc; count++; -#ifndef MACINTOSH - *(uint *)(multibuf+count)=sound; count++; -#else - multibuf[3] = sound; count++; // this would probably work on the PC as well. Jason? -#endif + + multibuf[0]=MULTI_SOUND_FUNCTION; count++; + multibuf[1]=Player_num; count++; + multibuf[2]=whichfunc; count++; + #ifndef MACINTOSH + *(uint *)(multibuf+count)=sound; count++; + #else + multibuf[3] = sound; count++; // this would probably work on the PC as well. Jason? + #endif multi_send_data (multibuf,4,0); } -#define AFTERBURNER_LOOP_START 20098 -#define AFTERBURNER_LOOP_END 25776 +#define AFTERBURNER_LOOP_START 20098 +#define AFTERBURNER_LOOP_END 25776 void multi_do_sound_function (char *buf) { - // for afterburner - + // for afterburner + char pnum,whichfunc; - int sound; + int sound; - if (Players[Player_num].connected!=1) - return; + if (Players[Player_num].connected!=1) + return; - pnum=buf[1]; + pnum=buf[1]; whichfunc=buf[2]; sound=buf[3]; - + if (whichfunc==0) digi_kill_sound_linked_to_object (Players[(int)pnum].objnum); else if (whichfunc==3) - digi_link_sound_to_object3( sound, Players[(int)pnum].objnum, 1,F1_0, i2f(256), AFTERBURNER_LOOP_START, AFTERBURNER_LOOP_END); -} + digi_link_sound_to_object3( sound, Players[(int)pnum].objnum, 1,F1_0, i2f(256), AFTERBURNER_LOOP_START, AFTERBURNER_LOOP_END); +} void multi_send_capture_bonus (char pnum) { - Assert (Game_mode & GM_CAPTURE); - - multibuf[0]=MULTI_CAPTURE_BONUS; - multibuf[1]=pnum; + Assert (Game_mode & GM_CAPTURE); + + multibuf[0]=MULTI_CAPTURE_BONUS; + multibuf[1]=pnum; - multi_send_data (multibuf,2,1); - multi_do_capture_bonus (multibuf); + multi_send_data (multibuf,2,1); + multi_do_capture_bonus (multibuf); } void multi_send_orb_bonus (char pnum) { - Assert (Game_mode & GM_HOARD); + Assert (Game_mode & GM_HOARD); + + multibuf[0]=MULTI_ORB_BONUS; + multibuf[1]=pnum; + multibuf[2]=Players[Player_num].secondary_ammo[PROXIMITY_INDEX]; - multibuf[0]=MULTI_ORB_BONUS; - multibuf[1]=pnum; - multibuf[2]=Players[Player_num].secondary_ammo[PROXIMITY_INDEX]; - - multi_send_data (multibuf,3,1); - multi_do_orb_bonus (multibuf); + multi_send_data (multibuf,3,1); + multi_do_orb_bonus (multibuf); } void multi_do_capture_bonus(char *buf) { // Figure out the results of a network kills and add it to the // appropriate player's tally. - char pnum=buf[1]; - int TheGoal; + char pnum=buf[1]; + int TheGoal; kmatrix_kills_changed = 1; - - if (pnum==Player_num) + + if (pnum==Player_num) HUD_init_message("You have Scored!"); else HUD_init_message("%s has Scored!",Players[(int)pnum].callsign); @@ -4453,23 +4458,23 @@ void multi_do_capture_bonus(char *buf) Players[(int)pnum].net_kills_total += 5; Players[(int)pnum].KillGoalCount+=5; - if (Netgame.KillGoal>0) + if (Netgame.KillGoal>0) { - TheGoal=Netgame.KillGoal*5; + TheGoal=Netgame.KillGoal*5; - if (Players[(int)pnum].KillGoalCount>=TheGoal) - { - if (pnum==Player_num) - { - HUD_init_message("You reached the kill goal!"); - Players[Player_num].shields=i2f(200); - } - else - HUD_init_message ("%s has reached the kill goal!",Players[(int)pnum].callsign); + if (Players[(int)pnum].KillGoalCount>=TheGoal) + { + if (pnum==Player_num) + { + HUD_init_message("You reached the kill goal!"); + Players[Player_num].shields=i2f(200); + } + else + HUD_init_message ("%s has reached the kill goal!",Players[(int)pnum].callsign); - HUD_init_message ("The control center has been destroyed!"); - net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN)); - } + HUD_init_message ("The control center has been destroyed!"); + net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN)); + } } multi_sort_kill_list(); @@ -4477,25 +4482,25 @@ void multi_do_capture_bonus(char *buf) } int GetOrbBonus (char num) -{ - int bonus; + { + int bonus; - bonus=num*(num+1)/2; - return (bonus); -} + bonus=num*(num+1)/2; + return (bonus); + } void multi_do_orb_bonus(char *buf) { // Figure out the results of a network kills and add it to the // appropriate player's tally. - char pnum=buf[1]; - int TheGoal; + char pnum=buf[1]; + int TheGoal; int bonus=GetOrbBonus (buf[2]); kmatrix_kills_changed = 1; - - if (pnum==Player_num) + + if (pnum==Player_num) HUD_init_message("You have scored %d points!",bonus); else HUD_init_message("%s has scored with %d orbs!",Players[(int)pnum].callsign,buf[2]); @@ -4503,28 +4508,28 @@ void multi_do_orb_bonus(char *buf) if (pnum==Player_num) digi_start_sound_queued (SOUND_HUD_YOU_GOT_GOAL,F1_0*2); else if (Game_mode & GM_TEAM) - { - if (get_team(pnum)==TEAM_RED) - digi_play_sample (SOUND_HUD_RED_GOT_GOAL,F1_0*2); - else - digi_play_sample (SOUND_HUD_BLUE_GOT_GOAL,F1_0*2); - } + { + if (get_team(pnum)==TEAM_RED) + digi_play_sample (SOUND_HUD_RED_GOT_GOAL,F1_0*2); + else + digi_play_sample (SOUND_HUD_BLUE_GOT_GOAL,F1_0*2); + } else digi_play_sample (SOUND_OPPONENT_HAS_SCORED,F1_0*2); - if (bonus>PhallicLimit) + if (bonus>PhallicLimit) { - if (pnum==Player_num) - HUD_init_message ("You have the record with %d points!",bonus); - else - HUD_init_message ("%s has the record with %d points!",Players[(int)pnum].callsign,bonus); - digi_play_sample (SOUND_BUDDY_MET_GOAL,F1_0*2); - PhallicMan=pnum; - PhallicLimit=bonus; - } + if (pnum==Player_num) + HUD_init_message ("You have the record with %d points!",bonus); + else + HUD_init_message ("%s has the record with %d points!",Players[(int)pnum].callsign,bonus); + digi_play_sample (SOUND_BUDDY_MET_GOAL,F1_0*2); + PhallicMan=pnum; + PhallicLimit=bonus; + } Players[(int)pnum].flags &= ~(PLAYER_FLAGS_FLAG); // Clear orb flag - + team_kills[get_team(pnum)] += bonus; Players[(int)pnum].net_kills_total += bonus; Players[(int)pnum].KillGoalCount+=bonus; @@ -4533,23 +4538,23 @@ void multi_do_orb_bonus(char *buf) Players[(int)pnum].net_kills_total%=1000; Players[(int)pnum].KillGoalCount%=1000; - if (Netgame.KillGoal>0) + if (Netgame.KillGoal>0) { - TheGoal=Netgame.KillGoal*5; - - if (Players[(int)pnum].KillGoalCount>=TheGoal) - { - if (pnum==Player_num) - { - HUD_init_message("You reached the kill goal!"); - Players[Player_num].shields=i2f(200); - } - else - HUD_init_message ("%s has reached the kill goal!",Players[(int)pnum].callsign); - - HUD_init_message ("The control center has been destroyed!"); - net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN)); - } + TheGoal=Netgame.KillGoal*5; + + if (Players[(int)pnum].KillGoalCount>=TheGoal) + { + if (pnum==Player_num) + { + HUD_init_message("You reached the kill goal!"); + Players[Player_num].shields=i2f(200); + } + else + HUD_init_message ("%s has reached the kill goal!",Players[(int)pnum].callsign); + + HUD_init_message ("The control center has been destroyed!"); + net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN)); + } } multi_sort_kill_list(); multi_show_player_list(); @@ -4557,13 +4562,13 @@ void multi_do_orb_bonus(char *buf) void multi_send_got_flag (char pnum) { - multibuf[0]=MULTI_GOT_FLAG; - multibuf[1]=pnum; + multibuf[0]=MULTI_GOT_FLAG; + multibuf[1]=pnum; + + digi_start_sound_queued (SOUND_HUD_YOU_GOT_FLAG,F1_0*2); - digi_start_sound_queued (SOUND_HUD_YOU_GOT_FLAG,F1_0*2); - - multi_send_data (multibuf,2,1); - multi_send_flags (Player_num); + multi_send_data (multibuf,2,1); + multi_send_flags (Player_num); } int SoundHacked=0; @@ -4571,45 +4576,45 @@ digi_sound ReversedSound; void multi_send_got_orb (char pnum) { - multibuf[0]=MULTI_GOT_ORB; - multibuf[1]=pnum; - - digi_play_sample (SOUND_YOU_GOT_ORB,F1_0*2); + multibuf[0]=MULTI_GOT_ORB; + multibuf[1]=pnum; + + digi_play_sample (SOUND_YOU_GOT_ORB,F1_0*2); - multi_send_data (multibuf,2,1); - multi_send_flags (Player_num); + multi_send_data (multibuf,2,1); + multi_send_flags (Player_num); } void multi_do_got_flag (char *buf) { char pnum=buf[1]; - if (pnum==Player_num) + if (pnum==Player_num) digi_start_sound_queued (SOUND_HUD_YOU_GOT_FLAG,F1_0*2); else if (get_team(pnum)==TEAM_RED) digi_start_sound_queued (SOUND_HUD_RED_GOT_FLAG,F1_0*2); - else + else digi_start_sound_queued (SOUND_HUD_BLUE_GOT_FLAG,F1_0*2); - Players[(int)pnum].flags|=PLAYER_FLAGS_FLAG; + Players[(int)pnum].flags|=PLAYER_FLAGS_FLAG; HUD_init_message ("%s picked up a flag!",Players[(int)pnum].callsign); } void multi_do_got_orb (char *buf) { char pnum=buf[1]; - Assert (Game_mode & GM_HOARD); + Assert (Game_mode & GM_HOARD); - if (Game_mode & GM_TEAM) - { - if (get_team(pnum)==get_team(Player_num)) - digi_play_sample (SOUND_FRIEND_GOT_ORB,F1_0*2); - else - digi_play_sample (SOUND_OPPONENT_GOT_ORB,F1_0*2); - } - else + if (Game_mode & GM_TEAM) + { + if (get_team(pnum)==get_team(Player_num)) + digi_play_sample (SOUND_FRIEND_GOT_ORB,F1_0*2); + else digi_play_sample (SOUND_OPPONENT_GOT_ORB,F1_0*2); + } + else + digi_play_sample (SOUND_OPPONENT_GOT_ORB,F1_0*2); - Players[(int)pnum].flags|=PLAYER_FLAGS_FLAG; + Players[(int)pnum].flags|=PLAYER_FLAGS_FLAG; HUD_init_message ("%s picked up an orb!",Players[(int)pnum].callsign); } @@ -4619,32 +4624,32 @@ void DropOrb () int objnum,seed; if (!(Game_mode & GM_HOARD)) - Int3(); // How did we get here? Get Leighton! + Int3(); // How did we get here? Get Leighton! if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX]) { - HUD_init_message("No orbs to drop!"); + HUD_init_message("No orbs to drop!"); return; } seed = d_rand(); - objnum = spit_powerup(ConsoleObject,POW_HOARD_ORB,seed); - - if (objnum<0) + objnum = spit_powerup(ConsoleObject,POW_HOARD_ORB,seed); + + if (objnum<0) return; HUD_init_message("Orb dropped!"); digi_play_sample (SOUND_DROP_WEAPON,F1_0); if ((Game_mode & GM_HOARD) && objnum>-1) - multi_send_drop_flag(objnum,seed); - + multi_send_drop_flag(objnum,seed); + Players[Player_num].secondary_ammo[PROXIMITY_INDEX]--; - // If empty, tell everyone to stop drawing the box around me + // If empty, tell everyone to stop drawing the box around me if (Players[Player_num].secondary_ammo[PROXIMITY_INDEX]==0) - multi_send_flags (Player_num); + multi_send_flags (Player_num); } void DropFlag () @@ -4657,11 +4662,11 @@ void DropFlag () { DropOrb(); return; - } + } if (!(Players[Player_num].flags & PLAYER_FLAGS_FLAG)) { - HUD_init_message("No flag to drop!"); + HUD_init_message("No flag to drop!"); return; } @@ -4671,12 +4676,12 @@ void DropFlag () seed = d_rand(); - if (get_team (Player_num)==TEAM_RED) - objnum = spit_powerup(ConsoleObject,POW_FLAG_BLUE,seed); + if (get_team (Player_num)==TEAM_RED) + objnum = spit_powerup(ConsoleObject,POW_FLAG_BLUE,seed); else - objnum = spit_powerup(ConsoleObject,POW_FLAG_RED,seed); - - if (objnum<0) + objnum = spit_powerup(ConsoleObject,POW_FLAG_RED,seed); + + if (objnum<0) return; if ((Game_mode & GM_CAPTURE) && objnum>-1) @@ -4695,19 +4700,19 @@ void multi_send_drop_flag (int objnum,int seed) multibuf[count++]=(char)MULTI_DROP_FLAG; multibuf[count++]=(char)objp->id; - + *(short *) (multibuf+count)=INTEL_SHORT(Player_num); count += 2; *(short *) (multibuf+count)=INTEL_SHORT(objnum); count += 2; *(short *) (multibuf+count)=INTEL_SHORT(objp->ctype.powerup_info.count); count += 2; *(int *) (multibuf+count)=INTEL_INT(seed); - + map_objnum_local_to_local(objnum); - - if (!(Game_mode & GM_HOARD)) + + if (!(Game_mode & GM_HOARD)) if (Game_mode & GM_NETWORK) PowerupsInMine[objp->id]++; - multi_send_data(multibuf, 12, 2); + multi_send_data(multibuf, 12, 2); } void multi_do_drop_flag (char *buf) @@ -4726,26 +4731,26 @@ void multi_do_drop_flag (char *buf) objnum = spit_powerup(objp, powerup_id, seed); - map_objnum_local_to_remote(objnum, remote_objnum, pnum); + map_objnum_local_to_remote(objnum, remote_objnum, pnum); if (objnum!=-1) - Objects[objnum].ctype.powerup_info.count = ammo; - + Objects[objnum].ctype.powerup_info.count = ammo; + if (!(Game_mode & GM_HOARD)) { if (Game_mode & GM_NETWORK) PowerupsInMine[powerup_id]++; - Players[pnum].flags &= ~(PLAYER_FLAGS_FLAG); - } + Players[pnum].flags &= ~(PLAYER_FLAGS_FLAG); + } mprintf ((0,"Dropped flag %d!\n")); - + } void multi_bad_restore () { Function_mode = FMODE_MENU; - nm_messagebox(NULL, 1, TXT_OK, - "A multi-save game was restored\nthat you are missing or does not\nmatch that of the others.\nYou must rejoin if you wish to\ncontinue."); + nm_messagebox(NULL, 1, TXT_OK, +"A multi-save game was restored\nthat you are missing or does not\nmatch that of the others.\nYou must rejoin if you wish to\ncontinue."); Function_mode = FMODE_GAME; multi_quit_game = 1; multi_leave_menu = 1; @@ -4763,313 +4768,313 @@ extern byte robot_fire_buf[MAX_ROBOTS_CONTROLLED][18+3]; void multi_send_robot_controls (char pnum) -{ - int count=2; - - mprintf ((0,"Sending ROBOT_CONTROLS!!!\n")); - - multibuf[0]=MULTI_ROBOT_CONTROLS; - multibuf[1]=pnum; - memcpy (&(multibuf[count]),&robot_controlled,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_agitation,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_controlled_time,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_last_send_time,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_last_message_time,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_send_pending,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_fired,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - - network_send_naked_packet (multibuf,142,pnum); -} + { + int count=2; + + mprintf ((0,"Sending ROBOT_CONTROLS!!!\n")); + + multibuf[0]=MULTI_ROBOT_CONTROLS; + multibuf[1]=pnum; + memcpy (&(multibuf[count]),&robot_controlled,MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&(multibuf[count]),&robot_agitation,MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&(multibuf[count]),&robot_controlled_time,MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&(multibuf[count]),&robot_last_send_time,MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&(multibuf[count]),&robot_last_message_time,MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&(multibuf[count]),&robot_send_pending,MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&(multibuf[count]),&robot_fired,MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + + network_send_naked_packet (multibuf,142,pnum); + } void multi_do_robot_controls(char *buf) -{ - int count=2; - - mprintf ((0,"Recieved ROBOT_CONTROLS!!!\n")); + { + int count=2; - if (buf[1]!=Player_num) + mprintf ((0,"Recieved ROBOT_CONTROLS!!!\n")); + + if (buf[1]!=Player_num) { - Int3(); // Get Jason! Recieved a coop_sync that wasn't ours! - return; - } + Int3(); // Get Jason! Recieved a coop_sync that wasn't ours! + return; + } - memcpy (&robot_controlled,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_agitation,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_controlled_time,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_last_send_time,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_last_message_time,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_send_pending,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_fired,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); -} + memcpy (&robot_controlled,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&robot_agitation,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&robot_controlled_time,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&robot_last_send_time,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&robot_last_message_time,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&robot_send_pending,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + memcpy (&robot_fired,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); + count+=(MAX_ROBOTS_CONTROLLED*4); + } #define POWERUPADJUSTS 5 int PowerupAdjustMapping[]={11,19,39,41,44}; int multi_powerup_is_4pack (int id) -{ - int i; - - for (i=0;irank) - strcpy (rankstr,"demoted"); - else - return; - - NetPlayers.players[(int)pnum].rank=rank; - - if (!FindArg("-norankings")) - HUD_init_message ("%s has been %s to %s!",Players[(int)pnum].callsign,rankstr,RankStrings[(int)rank]); -} + { + char rankstr[20]; + char pnum=buf[1]; + char rank=buf[2]; + + if (NetPlayers.players[(int)pnum].rankrank) + strcpy (rankstr,"demoted"); + else + return; + + NetPlayers.players[(int)pnum].rank=rank; + + if (!FindArg("-norankings")) + HUD_init_message ("%s has been %s to %s!",Players[(int)pnum].callsign,rankstr,RankStrings[(int)rank]); + } void multi_send_modem_ping () { - multibuf[0]=MULTI_MODEM_PING; - multi_send_data (multibuf,1,1); + multibuf[0]=MULTI_MODEM_PING; + multi_send_data (multibuf,1,1); } void multi_send_modem_ping_return () -{ - multibuf[0]=MULTI_MODEM_PING_RETURN; - multi_send_data (multibuf,1,1); -} + { + multibuf[0]=MULTI_MODEM_PING_RETURN; + multi_send_data (multibuf,1,1); + } void multi_do_modem_ping_return () -{ - if (PingLaunchTime==0) + { + if (PingLaunchTime==0) { - mprintf ((0,"Got invalid PING RETURN from opponent!\n")); - return; - } - - PingReturnTime=timer_get_fixed_seconds(); - - HUD_init_message ("Ping time for opponent is %d ms!",f2i(fixmul(PingReturnTime-PingLaunchTime,i2f(1000)))); - PingLaunchTime=0; -} + mprintf ((0,"Got invalid PING RETURN from opponent!\n")); + return; + } + + PingReturnTime=timer_get_fixed_seconds(); + HUD_init_message ("Ping time for opponent is %d ms!",f2i(fixmul(PingReturnTime-PingLaunchTime,i2f(1000)))); + PingLaunchTime=0; + } -void multi_quick_sound_hack (int num) -{ - int length,i; - num = digi_xlat_sound(num); - length=GameSounds[num].length; - ReversedSound.data=(ubyte *)d_malloc (length); - ReversedSound.length=length; - for (i=0;i"); + Error("can't open "); n_orb_frames = cfile_read_short(ifile); orb_w = cfile_read_short(ifile); @@ -5166,17 +5171,17 @@ void init_hoard_data() //Create obj powerup Powerup_info[POW_HOARD_ORB].vclip_num = orb_vclip; - Powerup_info[POW_HOARD_ORB].hit_sound = -1; //Powerup_info[POW_SHIELD_BOOST].hit_sound; + Powerup_info[POW_HOARD_ORB].hit_sound = -1; //Powerup_info[POW_SHIELD_BOOST].hit_sound; Powerup_info[POW_HOARD_ORB].size = Powerup_info[POW_SHIELD_BOOST].size; Powerup_info[POW_HOARD_ORB].light = Powerup_info[POW_SHIELD_BOOST].light; //Create orb goal wall effect Hoard_goal_eclip = Num_effects++; Assert(Num_effects < MAX_EFFECTS); - Effects[Hoard_goal_eclip] = Effects[94]; //copy from blue goal + Effects[Hoard_goal_eclip] = Effects[94]; //copy from blue goal Effects[Hoard_goal_eclip].changing_wall_texture = NumTextures; Effects[Hoard_goal_eclip].vc.num_frames=n_goal_frames; - + TmapInfo[NumTextures] = TmapInfo[find_goal_texture(TMI_GOAL_BLUE)]; TmapInfo[NumTextures].eclip_num = Hoard_goal_eclip; TmapInfo[NumTextures].flags = TMI_GOAL_HOARD; @@ -5201,7 +5206,7 @@ void init_hoard_data() } //Load and remap bitmap data for goal texture - cfile_read_short(ifile); //skip frame count + cfile_read_short(ifile); //skip frame count cfread(palette,3,256,ifile); for (i=0;i MULTI_MAX_TYPE) { mprintf((1, "multi_process_data: invalid type %d.\n", type)); @@ -5275,141 +5280,141 @@ multi_process_data(char *buf, int len) } -#ifdef NETPROFILING - TTRecv[type]++; - fprintf (RecieveLogFile,"Packet type: %d Len:%d TT=%d\n",type,len,TTRecv[type]); - fflush (RecieveLogFile); -#endif - - switch(type) + #ifdef NETPROFILING + TTRecv[type]++; + fprintf (RecieveLogFile,"Packet type: %d Len:%d TT=%d\n",type,len,TTRecv[type]); + fflush (RecieveLogFile); + #endif + + switch(type) { - case MULTI_POSITION: - if (!Endlevel_sequence) multi_do_position(buf); break; - case MULTI_REAPPEAR: - if (!Endlevel_sequence) multi_do_reappear(buf); break; - case MULTI_FIRE: - if (!Endlevel_sequence) multi_do_fire(buf); break; - case MULTI_KILL: - multi_do_kill(buf); break; - case MULTI_REMOVE_OBJECT: - if (!Endlevel_sequence) multi_do_remobj(buf); break; - case MULTI_PLAYER_DROP: - case MULTI_PLAYER_EXPLODE: - if (!Endlevel_sequence) multi_do_player_explode(buf); break; - case MULTI_MESSAGE: - if (!Endlevel_sequence) multi_do_message(buf); break; - case MULTI_QUIT: - if (!Endlevel_sequence) multi_do_quit(buf); break; - case MULTI_BEGIN_SYNC: - break; - case MULTI_CONTROLCEN: - if (!Endlevel_sequence) multi_do_controlcen_destroy(buf); break; - case MULTI_POWERUP_UPDATE: - if (!Endlevel_sequence) multi_do_powerup_update(buf); break; - case MULTI_SOUND_FUNCTION: - multi_do_sound_function(buf); break; - case MULTI_MARKER: - if (!Endlevel_sequence) multi_do_drop_marker (buf); break; - case MULTI_DROP_WEAPON: - if (!Endlevel_sequence) multi_do_drop_weapon(buf); break; - case MULTI_DROP_FLAG: - if (!Endlevel_sequence) multi_do_drop_flag(buf); break; - case MULTI_GUIDED: - if (!Endlevel_sequence) multi_do_guided (buf); break; - case MULTI_STOLEN_ITEMS: - if (!Endlevel_sequence) multi_do_stolen_items(buf); break; - case MULTI_WALL_STATUS: - if (!Endlevel_sequence) multi_do_wall_status(buf); break; - case MULTI_HEARTBEAT: - if (!Endlevel_sequence) multi_do_heartbeat (buf); break; - case MULTI_SEISMIC: + case MULTI_POSITION: + if (!Endlevel_sequence) multi_do_position(buf); break; + case MULTI_REAPPEAR: + if (!Endlevel_sequence) multi_do_reappear(buf); break; + case MULTI_FIRE: + if (!Endlevel_sequence) multi_do_fire(buf); break; + case MULTI_KILL: + multi_do_kill(buf); break; + case MULTI_REMOVE_OBJECT: + if (!Endlevel_sequence) multi_do_remobj(buf); break; + case MULTI_PLAYER_DROP: + case MULTI_PLAYER_EXPLODE: + if (!Endlevel_sequence) multi_do_player_explode(buf); break; + case MULTI_MESSAGE: + if (!Endlevel_sequence) multi_do_message(buf); break; + case MULTI_QUIT: + if (!Endlevel_sequence) multi_do_quit(buf); break; + case MULTI_BEGIN_SYNC: + break; + case MULTI_CONTROLCEN: + if (!Endlevel_sequence) multi_do_controlcen_destroy(buf); break; + case MULTI_POWERUP_UPDATE: + if (!Endlevel_sequence) multi_do_powerup_update(buf); break; + case MULTI_SOUND_FUNCTION: + multi_do_sound_function(buf); break; + case MULTI_MARKER: + if (!Endlevel_sequence) multi_do_drop_marker (buf); break; + case MULTI_DROP_WEAPON: + if (!Endlevel_sequence) multi_do_drop_weapon(buf); break; + case MULTI_DROP_FLAG: + if (!Endlevel_sequence) multi_do_drop_flag(buf); break; + case MULTI_GUIDED: + if (!Endlevel_sequence) multi_do_guided (buf); break; + case MULTI_STOLEN_ITEMS: + if (!Endlevel_sequence) multi_do_stolen_items(buf); break; + case MULTI_WALL_STATUS: + if (!Endlevel_sequence) multi_do_wall_status(buf); break; + case MULTI_HEARTBEAT: + if (!Endlevel_sequence) multi_do_heartbeat (buf); break; + case MULTI_SEISMIC: if (!Endlevel_sequence) multi_do_seismic (buf); break; - case MULTI_LIGHT: + case MULTI_LIGHT: if (!Endlevel_sequence) multi_do_light (buf); break; - case MULTI_KILLGOALS: - - if (!Endlevel_sequence) multi_do_kill_goal_counts (buf); break; - case MULTI_ENDLEVEL_START: - if (!Endlevel_sequence) multi_do_escape(buf); break; - case MULTI_END_SYNC: - break; - case MULTI_CLOAK: - if (!Endlevel_sequence) multi_do_cloak(buf); break; - case MULTI_DECLOAK: - if (!Endlevel_sequence) multi_do_decloak(buf); break; - case MULTI_DOOR_OPEN: - if (!Endlevel_sequence) multi_do_door_open(buf); break; - case MULTI_CREATE_EXPLOSION: - if (!Endlevel_sequence) multi_do_create_explosion(buf); break; - case MULTI_CONTROLCEN_FIRE: - if (!Endlevel_sequence) multi_do_controlcen_fire(buf); break; - case MULTI_CREATE_POWERUP: - if (!Endlevel_sequence) multi_do_create_powerup(buf); break; - case MULTI_PLAY_SOUND: - if (!Endlevel_sequence) multi_do_play_sound(buf); break; - case MULTI_CAPTURE_BONUS: - if (!Endlevel_sequence) multi_do_capture_bonus(buf); break; - case MULTI_ORB_BONUS: - if (!Endlevel_sequence) multi_do_orb_bonus(buf); break; - case MULTI_GOT_FLAG: - if (!Endlevel_sequence) multi_do_got_flag(buf); break; - case MULTI_GOT_ORB: - if (!Endlevel_sequence) multi_do_got_orb(buf); break; - case MULTI_PLAY_BY_PLAY: - if (!Endlevel_sequence) multi_do_play_by_play(buf); break; - case MULTI_RANK: - if (!Endlevel_sequence) multi_do_ranking (buf); break; - case MULTI_MODEM_PING: - if (!Endlevel_sequence) multi_send_modem_ping_return(); break; - case MULTI_MODEM_PING_RETURN: - if (!Endlevel_sequence) multi_do_modem_ping_return(); break; + case MULTI_KILLGOALS: + + if (!Endlevel_sequence) multi_do_kill_goal_counts (buf); break; + case MULTI_ENDLEVEL_START: + if (!Endlevel_sequence) multi_do_escape(buf); break; + case MULTI_END_SYNC: + break; + case MULTI_CLOAK: + if (!Endlevel_sequence) multi_do_cloak(buf); break; + case MULTI_DECLOAK: + if (!Endlevel_sequence) multi_do_decloak(buf); break; + case MULTI_DOOR_OPEN: + if (!Endlevel_sequence) multi_do_door_open(buf); break; + case MULTI_CREATE_EXPLOSION: + if (!Endlevel_sequence) multi_do_create_explosion(buf); break; + case MULTI_CONTROLCEN_FIRE: + if (!Endlevel_sequence) multi_do_controlcen_fire(buf); break; + case MULTI_CREATE_POWERUP: + if (!Endlevel_sequence) multi_do_create_powerup(buf); break; + case MULTI_PLAY_SOUND: + if (!Endlevel_sequence) multi_do_play_sound(buf); break; + case MULTI_CAPTURE_BONUS: + if (!Endlevel_sequence) multi_do_capture_bonus(buf); break; + case MULTI_ORB_BONUS: + if (!Endlevel_sequence) multi_do_orb_bonus(buf); break; + case MULTI_GOT_FLAG: + if (!Endlevel_sequence) multi_do_got_flag(buf); break; + case MULTI_GOT_ORB: + if (!Endlevel_sequence) multi_do_got_orb(buf); break; + case MULTI_PLAY_BY_PLAY: + if (!Endlevel_sequence) multi_do_play_by_play(buf); break; + case MULTI_RANK: + if (!Endlevel_sequence) multi_do_ranking (buf); break; + case MULTI_MODEM_PING: + if (!Endlevel_sequence) multi_send_modem_ping_return(); break; + case MULTI_MODEM_PING_RETURN: + if (!Endlevel_sequence) multi_do_modem_ping_return(); break; #ifndef SHAREWARE - case MULTI_FINISH_GAME: - multi_do_finish_game(buf); break; // do this one regardless of endsequence - case MULTI_ROBOT_CONTROLS: - if (!Endlevel_sequence) multi_do_robot_controls(buf); break; - case MULTI_ROBOT_CLAIM: - if (!Endlevel_sequence) multi_do_claim_robot(buf); break; - case MULTI_ROBOT_POSITION: - if (!Endlevel_sequence) multi_do_robot_position(buf); break; - case MULTI_ROBOT_EXPLODE: - if (!Endlevel_sequence) multi_do_robot_explode(buf); break; - case MULTI_ROBOT_RELEASE: - if (!Endlevel_sequence) multi_do_release_robot(buf); break; - case MULTI_ROBOT_FIRE: - if (!Endlevel_sequence) multi_do_robot_fire(buf); break; + case MULTI_FINISH_GAME: + multi_do_finish_game(buf); break; // do this one regardless of endsequence + case MULTI_ROBOT_CONTROLS: + if (!Endlevel_sequence) multi_do_robot_controls(buf); break; + case MULTI_ROBOT_CLAIM: + if (!Endlevel_sequence) multi_do_claim_robot(buf); break; + case MULTI_ROBOT_POSITION: + if (!Endlevel_sequence) multi_do_robot_position(buf); break; + case MULTI_ROBOT_EXPLODE: + if (!Endlevel_sequence) multi_do_robot_explode(buf); break; + case MULTI_ROBOT_RELEASE: + if (!Endlevel_sequence) multi_do_release_robot(buf); break; + case MULTI_ROBOT_FIRE: + if (!Endlevel_sequence) multi_do_robot_fire(buf); break; #endif - case MULTI_SCORE: - if (!Endlevel_sequence) multi_do_score(buf); break; - case MULTI_CREATE_ROBOT: - if (!Endlevel_sequence) multi_do_create_robot(buf); break; - case MULTI_TRIGGER: - if (!Endlevel_sequence) multi_do_trigger(buf); break; - case MULTI_START_TRIGGER: - if (!Endlevel_sequence) multi_do_start_trigger(buf); break; - case MULTI_FLAGS: - if (!Endlevel_sequence) multi_do_flags(buf); break; - case MULTI_DROP_BLOB: - if (!Endlevel_sequence) multi_do_drop_blob(buf); break; - case MULTI_ACTIVE_DOOR: - if (!Endlevel_sequence) multi_do_active_door(buf); break; - case MULTI_BOSS_ACTIONS: - if (!Endlevel_sequence) multi_do_boss_actions(buf); break; - case MULTI_CREATE_ROBOT_POWERUPS: - if (!Endlevel_sequence) multi_do_create_robot_powerups(buf); break; - case MULTI_HOSTAGE_DOOR: - if (!Endlevel_sequence) multi_do_hostage_door_status(buf); break; - case MULTI_SAVE_GAME: - if (!Endlevel_sequence) multi_do_save_game(buf); break; - case MULTI_RESTORE_GAME: - if (!Endlevel_sequence) multi_do_restore_game(buf); break; - case MULTI_REQ_PLAYER: - if (!Endlevel_sequence) multi_do_req_player(buf); break; - case MULTI_SEND_PLAYER: - if (!Endlevel_sequence) multi_do_send_player(buf); break; - - default: - mprintf((1, "Invalid type in multi_process_input().\n")); - Int3(); + case MULTI_SCORE: + if (!Endlevel_sequence) multi_do_score(buf); break; + case MULTI_CREATE_ROBOT: + if (!Endlevel_sequence) multi_do_create_robot(buf); break; + case MULTI_TRIGGER: + if (!Endlevel_sequence) multi_do_trigger(buf); break; + case MULTI_START_TRIGGER: + if (!Endlevel_sequence) multi_do_start_trigger(buf); break; + case MULTI_FLAGS: + if (!Endlevel_sequence) multi_do_flags(buf); break; + case MULTI_DROP_BLOB: + if (!Endlevel_sequence) multi_do_drop_blob(buf); break; + case MULTI_ACTIVE_DOOR: + if (!Endlevel_sequence) multi_do_active_door(buf); break; + case MULTI_BOSS_ACTIONS: + if (!Endlevel_sequence) multi_do_boss_actions(buf); break; + case MULTI_CREATE_ROBOT_POWERUPS: + if (!Endlevel_sequence) multi_do_create_robot_powerups(buf); break; + case MULTI_HOSTAGE_DOOR: + if (!Endlevel_sequence) multi_do_hostage_door_status(buf); break; + case MULTI_SAVE_GAME: + if (!Endlevel_sequence) multi_do_save_game(buf); break; + case MULTI_RESTORE_GAME: + if (!Endlevel_sequence) multi_do_restore_game(buf); break; + case MULTI_REQ_PLAYER: + if (!Endlevel_sequence) multi_do_req_player(buf); break; + case MULTI_SEND_PLAYER: + if (!Endlevel_sequence) multi_do_send_player(buf); break; + + default: + mprintf((1, "Invalid type in multi_process_input().\n")); + Int3(); } } diff --git a/main/multi.h b/main/multi.h index 47bba24d..a8cdb041 100644 --- a/main/multi.h +++ b/main/multi.h @@ -1,4 +1,3 @@ -/* $Id: multi.h,v 1.8 2002-09-14 00:23:06 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,14 +7,20 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/multi.h,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-10-25 02:15:56 $ * * FIXME: put description here * + * $Log: not supported by cvs2svn $ + * */ #ifndef _MULTI_H @@ -30,9 +35,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. // What version of the multiplayer protocol is this? #ifdef SHAREWARE -#define MULTI_PROTO_VERSION 3 +#define MULTI_PROTO_VERSION 3 #else -#define MULTI_PROTO_VERSION 4 +#define MULTI_PROTO_VERSION 4 #endif // Protocol versions: @@ -47,80 +52,80 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. // How many simultaneous network players do we support? -#define MAX_NUM_NET_PLAYERS 8 - -#define MULTI_POSITION 0 -#define MULTI_REAPPEAR 1 -#define MULTI_FIRE 2 -#define MULTI_KILL 3 -#define MULTI_REMOVE_OBJECT 4 -#define MULTI_PLAYER_EXPLODE 5 -#define MULTI_MESSAGE 6 -#define MULTI_QUIT 7 -#define MULTI_PLAY_SOUND 8 -#define MULTI_BEGIN_SYNC 9 -#define MULTI_CONTROLCEN 10 -#define MULTI_ROBOT_CLAIM 11 -#define MULTI_END_SYNC 12 -#define MULTI_CLOAK 13 -#define MULTI_ENDLEVEL_START 14 -#define MULTI_DOOR_OPEN 15 -#define MULTI_CREATE_EXPLOSION 16 -#define MULTI_CONTROLCEN_FIRE 17 -#define MULTI_PLAYER_DROP 18 -#define MULTI_CREATE_POWERUP 19 -#define MULTI_CONSISTENCY 20 -#define MULTI_DECLOAK 21 -#define MULTI_MENU_CHOICE 22 -#define MULTI_ROBOT_POSITION 23 -#define MULTI_ROBOT_EXPLODE 24 -#define MULTI_ROBOT_RELEASE 25 -#define MULTI_ROBOT_FIRE 26 -#define MULTI_SCORE 27 -#define MULTI_CREATE_ROBOT 28 -#define MULTI_TRIGGER 29 -#define MULTI_BOSS_ACTIONS 30 -#define MULTI_CREATE_ROBOT_POWERUPS 31 -#define MULTI_HOSTAGE_DOOR 32 - -#define MULTI_SAVE_GAME 33 -#define MULTI_RESTORE_GAME 34 - -#define MULTI_REQ_PLAYER 35 // Someone requests my player structure -#define MULTI_SEND_PLAYER 36 // Sending someone my player structure -#define MULTI_MARKER 37 -#define MULTI_DROP_WEAPON 38 -#define MULTI_GUIDED 39 -#define MULTI_STOLEN_ITEMS 40 -#define MULTI_WALL_STATUS 41 // send to new players -#define MULTI_HEARTBEAT 42 -#define MULTI_KILLGOALS 43 -#define MULTI_SEISMIC 44 -#define MULTI_LIGHT 45 -#define MULTI_START_TRIGGER 46 -#define MULTI_FLAGS 47 -#define MULTI_DROP_BLOB 48 -#define MULTI_POWERUP_UPDATE 49 -#define MULTI_ACTIVE_DOOR 50 -#define MULTI_SOUND_FUNCTION 51 -#define MULTI_CAPTURE_BONUS 52 -#define MULTI_GOT_FLAG 53 -#define MULTI_DROP_FLAG 54 -#define MULTI_ROBOT_CONTROLS 55 -#define MULTI_FINISH_GAME 56 -#define MULTI_RANK 57 -#define MULTI_MODEM_PING 58 -#define MULTI_MODEM_PING_RETURN 59 -#define MULTI_ORB_BONUS 60 -#define MULTI_GOT_ORB 61 -#define MULTI_DROP_ORB 62 -#define MULTI_PLAY_BY_PLAY 63 - -#define MULTI_MAX_TYPE 63 - -#define MAX_NET_CREATE_OBJECTS 40 - -#define MAX_MULTI_MESSAGE_LEN 120 +#define MAX_NUM_NET_PLAYERS 8 + +#define MULTI_POSITION 0 +#define MULTI_REAPPEAR 1 +#define MULTI_FIRE 2 +#define MULTI_KILL 3 +#define MULTI_REMOVE_OBJECT 4 +#define MULTI_PLAYER_EXPLODE 5 +#define MULTI_MESSAGE 6 +#define MULTI_QUIT 7 +#define MULTI_PLAY_SOUND 8 +#define MULTI_BEGIN_SYNC 9 +#define MULTI_CONTROLCEN 10 +#define MULTI_ROBOT_CLAIM 11 +#define MULTI_END_SYNC 12 +#define MULTI_CLOAK 13 +#define MULTI_ENDLEVEL_START 14 +#define MULTI_DOOR_OPEN 15 +#define MULTI_CREATE_EXPLOSION 16 +#define MULTI_CONTROLCEN_FIRE 17 +#define MULTI_PLAYER_DROP 18 +#define MULTI_CREATE_POWERUP 19 +#define MULTI_CONSISTENCY 20 +#define MULTI_DECLOAK 21 +#define MULTI_MENU_CHOICE 22 +#define MULTI_ROBOT_POSITION 23 +#define MULTI_ROBOT_EXPLODE 24 +#define MULTI_ROBOT_RELEASE 25 +#define MULTI_ROBOT_FIRE 26 +#define MULTI_SCORE 27 +#define MULTI_CREATE_ROBOT 28 +#define MULTI_TRIGGER 29 +#define MULTI_BOSS_ACTIONS 30 +#define MULTI_CREATE_ROBOT_POWERUPS 31 +#define MULTI_HOSTAGE_DOOR 32 + +#define MULTI_SAVE_GAME 33 +#define MULTI_RESTORE_GAME 34 + +#define MULTI_REQ_PLAYER 35 // Someone requests my player structure +#define MULTI_SEND_PLAYER 36 // Sending someone my player structure +#define MULTI_MARKER 37 +#define MULTI_DROP_WEAPON 38 +#define MULTI_GUIDED 39 +#define MULTI_STOLEN_ITEMS 40 +#define MULTI_WALL_STATUS 41 // send to new players +#define MULTI_HEARTBEAT 42 +#define MULTI_KILLGOALS 43 +#define MULTI_SEISMIC 44 +#define MULTI_LIGHT 45 +#define MULTI_START_TRIGGER 46 +#define MULTI_FLAGS 47 +#define MULTI_DROP_BLOB 48 +#define MULTI_POWERUP_UPDATE 49 +#define MULTI_ACTIVE_DOOR 50 +#define MULTI_SOUND_FUNCTION 51 +#define MULTI_CAPTURE_BONUS 52 +#define MULTI_GOT_FLAG 53 +#define MULTI_DROP_FLAG 54 +#define MULTI_ROBOT_CONTROLS 55 +#define MULTI_FINISH_GAME 56 +#define MULTI_RANK 57 +#define MULTI_MODEM_PING 58 +#define MULTI_MODEM_PING_RETURN 59 +#define MULTI_ORB_BONUS 60 +#define MULTI_GOT_ORB 61 +#define MULTI_DROP_ORB 62 +#define MULTI_PLAY_BY_PLAY 63 + +#define MULTI_MAX_TYPE 63 + +#define MAX_NET_CREATE_OBJECTS 40 + +#define MAX_MULTI_MESSAGE_LEN 120 // Exported functions @@ -168,7 +173,7 @@ int multi_endlevel(int *secret); int multi_menu_poll(void); void multi_leave_game(void); void multi_process_data(char *dat, int len); -void multi_process_bigdata(char *buf, int len); +void multi_process_bigdata(char *buf, int len); void multi_do_death(int objnum); void multi_send_message_dialog(void); int multi_delete_extra_objects(void); @@ -217,7 +222,7 @@ extern fix Show_kill_list_timer; // Used to send network messages -extern char Network_message[MAX_MESSAGE_LEN]; +extern char Network_message[MAX_MESSAGE_LEN]; extern char Network_message_macro[4][MAX_MESSAGE_LEN]; extern int Network_message_reciever; @@ -247,17 +252,17 @@ extern int control_invul_time; extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES]; -#define NETGAME_FLAG_CLOSED 1 -#define NETGAME_FLAG_SHOW_ID 2 -#define NETGAME_FLAG_SHOW_MAP 4 -#define NETGAME_FLAG_HOARD 8 -#define NETGAME_FLAG_TEAM_HOARD 16 -#define NETGAME_FLAG_REALLY_ENDLEVEL 32 -#define NETGAME_FLAG_REALLY_FORMING 64 +#define NETGAME_FLAG_CLOSED 1 +#define NETGAME_FLAG_SHOW_ID 2 +#define NETGAME_FLAG_SHOW_MAP 4 +#define NETGAME_FLAG_HOARD 8 +#define NETGAME_FLAG_TEAM_HOARD 16 +#define NETGAME_FLAG_REALLY_ENDLEVEL 32 +#define NETGAME_FLAG_REALLY_FORMING 64 -#define NETGAME_NAME_LEN 15 +#define NETGAME_NAME_LEN 15 -enum __pack__ comp_type {DOS,WIN_32,WIN_95,MAC}; +enum comp_type {DOS,WIN_32,WIN_95,MAC}; // sigh...the socket structure member was moved away from it's friends. // I'll have to create a union for appletalk network info with just @@ -265,62 +270,62 @@ enum __pack__ comp_type {DOS,WIN_32,WIN_95,MAC}; // members. typedef struct netplayer_info { - char callsign[CALLSIGN_LEN+1]; + char callsign[CALLSIGN_LEN+1]; union { struct { - ubyte server[4]; - ubyte node[6]; + ubyte server[4]; + ubyte node[6]; } ipx; struct { - ushort net; - ubyte node; - ubyte socket; + ushort net; + ubyte node; + ubyte socket; } appletalk; } network; - ubyte version_major; - ubyte version_minor; + ubyte version_major; + ubyte version_minor; enum comp_type computer_type; - byte connected; + byte connected; - ushort socket; + ushort socket; - ubyte rank; + ubyte rank; -} __pack__ netplayer_info; +} netplayer_info; typedef struct AllNetPlayers_info -{ - char type; - int Security; - struct netplayer_info players[MAX_PLAYERS+4]; -} __pack__ AllNetPlayers_info; + { + char type; + int Security; + struct netplayer_info players[MAX_PLAYERS+4]; + } AllNetPlayers_info; typedef struct netgame_info { - ubyte type; - int Security; - char game_name[NETGAME_NAME_LEN+1]; - char mission_title[MISSION_NAME_LEN+1]; - char mission_name[9]; - int levelnum; - ubyte gamemode; - ubyte RefusePlayers; - ubyte difficulty; - ubyte game_status; - ubyte numplayers; - ubyte max_numplayers; - ubyte numconnected; - ubyte game_flags; - ubyte protocol_version; - ubyte version_major; - ubyte version_minor; - ubyte team_vector; + ubyte type; + int Security; + char game_name[NETGAME_NAME_LEN+1]; + char mission_title[MISSION_NAME_LEN+1]; + char mission_name[9]; + int levelnum; + ubyte gamemode; + ubyte RefusePlayers; + ubyte difficulty; + ubyte game_status; + ubyte numplayers; + ubyte max_numplayers; + ubyte numconnected; + ubyte game_flags; + ubyte protocol_version; + ubyte version_major; + ubyte version_minor; + ubyte team_vector; // change the order of the bit fields for the mac compiler. // doing so will mean I don't have to do screwy things to // send this as network information -#ifndef WORDS_BIGENDIAN +#ifndef MACINTOSH short DoMegas:1; short DoSmarts:1; short DoFusions:1; @@ -342,7 +347,7 @@ typedef struct netgame_info { short DoEarthShaker:1; short DoMercury:1; short Allow_marker_view:1; - short AlwaysLighting:1; + short AlwaysLighting:1; short DoAmmoRack:1; short DoConverter:1; short DoHeadlight:1; @@ -380,7 +385,7 @@ typedef struct netgame_info { short DoHeadlight:1; short DoConverter:1; short DoAmmoRack:1; - short AlwaysLighting:1; + short AlwaysLighting:1; short Allow_marker_view:1; short DoMercury:1; short DoEarthShaker:1; @@ -388,24 +393,24 @@ typedef struct netgame_info { short DoFlash:1; #endif - char team_name[2][CALLSIGN_LEN+1]; - int locations[MAX_PLAYERS]; - short kills[MAX_PLAYERS][MAX_PLAYERS]; - ushort segments_checksum; - short team_kills[2]; - short killed[MAX_PLAYERS]; - short player_kills[MAX_PLAYERS]; - int KillGoal; - fix PlayTimeAllowed; - fix level_time; - int control_invul_time; - int monitor_vector; - int player_score[MAX_PLAYERS]; - ubyte player_flags[MAX_PLAYERS]; - short PacketsPerSec; - ubyte ShortPackets; - -} __pack__ netgame_info; + char team_name[2][CALLSIGN_LEN+1]; + int locations[MAX_PLAYERS]; + short kills[MAX_PLAYERS][MAX_PLAYERS]; + ushort segments_checksum; + short team_kills[2]; + short killed[MAX_PLAYERS]; + short player_kills[MAX_PLAYERS]; + int KillGoal; + fix PlayTimeAllowed; + fix level_time; + int control_invul_time; + int monitor_vector; + int player_score[MAX_PLAYERS]; + ubyte player_flags[MAX_PLAYERS]; + short PacketsPerSec; + ubyte ShortPackets; + +} netgame_info; extern struct netgame_info Netgame; extern struct AllNetPlayers_info NetPlayers; @@ -414,8 +419,8 @@ int network_i_am_master(void); void change_playernum_to(int new_pnum); //how to encode missiles & flares in weapon packets -#define MISSILE_ADJUST 100 -#define FLARE_ADJUST 127 +#define MISSILE_ADJUST 100 +#define FLARE_ADJUST 127 #endif diff --git a/main/netmisc.c b/main/netmisc.c index 2ad94051..085c127b 100644 --- a/main/netmisc.c +++ b/main/netmisc.c @@ -7,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: netmisc.c,v 1.7 2002-12-31 23:19:42 btb Exp $"; +static char rcsid[] = "$Id: netmisc.c,v 1.3 2001-10-25 02:15:57 bradleyb Exp $"; #endif #include @@ -26,7 +26,7 @@ static char rcsid[] = "$Id: netmisc.c,v 1.7 2002-12-31 23:19:42 btb Exp $"; #include "pstypes.h" #include "mono.h" -#ifdef WORDS_BIGENDIAN +#ifdef MACINTOSH #include "byteswap.h" #include "segment.h" @@ -128,6 +128,7 @@ ushort netmisc_calc_checksum_pc( void * vptr, int len ) // this code must be kept in total sync #include "ipx.h" +#include "byteswap.h" #include "multi.h" #ifdef NETWORK #include "network.h" @@ -141,17 +142,17 @@ byte out_buffer[IPX_MAX_DATA_SIZE]; // used for tmp netgame packets as well as void receive_netplayer_info(ubyte *data, netplayer_info *info) { int loc = 0; - - memcpy(info->callsign, &(data[loc]), CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1; - memcpy(&(info->network.ipx.server), &(data[loc]), 4); loc += 4; - memcpy(&(info->network.ipx.node), &(data[loc]), 6); loc += 6; - info->version_major = data[loc]; loc++; - info->version_minor = data[loc]; loc++; - memcpy(&(info->computer_type), &(data[loc]), 1); loc++; // memcpy to avoid compile time warning about enum - info->connected = data[loc]; loc++; - memcpy(&(info->socket), &(data[loc]), 2); loc += 2; - memcpy (&(info->rank),&(data[loc]),1); loc++; -//MWA don't think we need to swap this because we need it in high order info->socket = INTEL_SHORT(info->socket); + + memcpy(info->callsign, &(data[loc]), CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1; + memcpy(&(info->network.ipx.server), &(data[loc]), 4); loc += 4; + memcpy(&(info->network.ipx.node), &(data[loc]), 6); loc += 6; + info->version_major = data[loc]; loc++; + info->version_minor = data[loc]; loc++; + memcpy(&(info->computer_type), &(data[loc]), 1); loc++; // memcpy to avoid compile time warning about enum + info->connected = data[loc]; loc++; + memcpy(&(info->socket), &(data[loc]), 2); loc += 2; + memcpy (&(info->rank),&(data[loc]),1); loc++; +//MWA don't think we need to swap this because we need it in high order info->socket = swapshort(info->socket); } void send_netplayers_packet(ubyte *server, ubyte *node) @@ -214,7 +215,7 @@ void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte out_buffer[loc] = seq.player.version_minor; loc++; out_buffer[loc] = seq.player.computer_type; loc++; out_buffer[loc] = seq.player.connected; loc++; - tmps = INTEL_SHORT(seq.player.socket); + tmps = swapshort(seq.player.socket); memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; out_buffer[loc]=seq.player.rank; loc++; // for pad byte if (net_address != NULL) @@ -238,7 +239,7 @@ void receive_sequence_packet(ubyte *data, sequence_packet *seq) void send_netgame_packet(ubyte *server, ubyte *node, ubyte *net_address, int lite_flag) // lite says shorter netgame packets { uint tmpi; - ushort tmps; // p; + ushort tmps, p; int i, j; int loc = 0; @@ -360,7 +361,7 @@ void receive_netgame_packet(ubyte *data, netgame_info *netgame, int lite_flag) { int i, j; int loc = 0; - short bitfield; // new_field; + short bitfield, new_field; memcpy(&(netgame->type), &(data[loc]), 1); loc++; memcpy(&(netgame->Security), &(data[loc]), 4); loc += 4; @@ -368,7 +369,7 @@ void receive_netgame_packet(ubyte *data, netgame_info *netgame, int lite_flag) memcpy(netgame->game_name, &(data[loc]), NETGAME_NAME_LEN+1); loc += (NETGAME_NAME_LEN+1); memcpy(netgame->mission_title, &(data[loc]), MISSION_NAME_LEN+1); loc += (MISSION_NAME_LEN+1); memcpy(netgame->mission_name, &(data[loc]), 9); loc += 9; - memcpy(&(netgame->levelnum), &(data[loc]), 4); loc += 4; + memcpy(&(netgame->levelnum), &(data[loc]), 4); loc += 4; netgame->levelnum = INTEL_INT(netgame->levelnum); memcpy(&(netgame->gamemode), &(data[loc]), 1); loc++; memcpy(&(netgame->RefusePlayers), &(data[loc]), 1); loc++; @@ -449,12 +450,12 @@ void receive_netgame_packet(ubyte *data, netgame_info *netgame, int lite_flag) memcpy(&(netgame->level_time), &(data[loc]), 4); loc += 4; netgame->level_time = INTEL_INT(netgame->level_time); memcpy(&(netgame->control_invul_time), &(data[loc]), 4); loc += 4; - netgame->control_invul_time = INTEL_INT(netgame->control_invul_time); + netgame->control_invul_time = swapint(netgame->control_invul_time); memcpy(&(netgame->monitor_vector), &(data[loc]), 4); loc += 4; - netgame->monitor_vector = INTEL_INT(netgame->monitor_vector); + netgame->monitor_vector = swapint(netgame->monitor_vector); for (i = 0; i < MAX_PLAYERS; i++) { memcpy(&(netgame->player_score[i]), &(data[loc]), 4); loc += 4; - netgame->player_score[i] = INTEL_INT(netgame->player_score[i]); + netgame->player_score[i] = swapint(netgame->player_score[i]); } for (i = 0; i < MAX_PLAYERS; i++) { memcpy(&(netgame->player_flags[i]), &(data[loc]), 1); loc++; diff --git a/main/netmisc.h b/main/netmisc.h index 09ad81ff..bbd4e9bd 100644 --- a/main/netmisc.h +++ b/main/netmisc.h @@ -28,7 +28,7 @@ extern int netmisc_find_diff( void *block1, void *block2, int block_size, void * //Applies diff_buffer to block1 to create a new block1. Returns the final size of block1. extern int netmisc_apply_diff(void *block1, void *diff_buffer, int diff_size ); -#ifdef WORDS_BIGENDIAN +#ifdef MACINTOSH // some mac only routines to deal with incorrectly aligned network structures @@ -36,72 +36,15 @@ void receive_netplayer_info(ubyte *data, AllNetPlayers_info *info); void receive_netplayers_packet(ubyte *data, AllNetPlayers_info *pinfo); void send_netplayers_packet(ubyte *server, ubyte *node); -#define send_broadcast_netplayers_packet() \ - send_netplayers_packet(NULL, NULL) void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address); -#define send_internetwork_sequence_packet(seq, server, node) \ - send_sequence_packet(seq, server, node, NULL) -#define send_broadcast_sequence_packet(seq) \ - send_sequence_packet(seq, NULL, NULL, NULL) void receive_sequence_packet(ubyte *data, sequence_packet *seq); void send_netgame_packet(ubyte *server, ubyte *node, ubyte *net_address, int lite_flag); -#define send_full_netgame_packet(server, node, net_address) \ - send_netgame_packet(server, node, net_address, 0) -#define send_lite_netgame_packet(server, node, net_address) \ - send_netgame_packet(server, node, net_address, 1) -#define send_internetwork_full_netgame_packet(server, node) \ - send_netgame_packet(server, node, NULL, 0) -#define send_internetwork_lite_netgame_packet(server, node) \ - send_netgame_packet(server, node, NULL, 1) -#define send_broadcast_full_netgame_packet() \ - send_netgame_packet(NULL, NULL, NULL, 0) -#define send_broadcast_lite_netgame_packet() \ - send_netgame_packet(NULL, NULL, NULL, 1) void receive_netgame_packet(ubyte *data, netgame_info *netgame, int lite_flag); -#define receive_full_netgame_packet(data, netgame) \ - receive_netgame_packet(data, netgame, 0) -#define receive_lite_netgame_packet(data, netgame) \ - receive_netgame_packet(data, netgame, 1) void swap_object(object *obj); -#else - -#define receive_netplayers_packet(data, pinfo) \ - memcpy(pinfo, data, sizeof(AllNetPlayers_info)) -#define send_netplayers_packet(server, node) \ - ipx_send_internetwork_packet_data((ubyte *)&NetPlayers, sizeof(AllNetPlayers_info), server, node) -#define send_broadcast_netplayers_packet() \ - ipx_send_broadcast_packet_data((ubyte *)&NetPlayers, sizeof(AllNetPlayers_info)) - -#define send_sequence_packet(seq, server, node, net_address) \ - ipx_send_packet_data((ubyte *)&seq, sizeof(sequence_packet), server, node, net_address) -#define send_internetwork_sequence_packet(seq, server, node) \ - ipx_send_internetwork_packet_data((ubyte *)&seq, sizeof(sequence_packet), server, node) -#define send_broadcast_sequence_packet(seq) \ - ipx_send_broadcast_packet_data((ubyte *)&seq, sizeof(sequence_packet)) - -#define send_full_netgame_packet(server, node, net_address) \ - ipx_send_packet_data((ubyte *)&Netgame, sizeof(netgame_info), server, node, net_address) -#define send_lite_netgame_packet(server, node, net_address) \ - ipx_send_packet_data((ubyte *)&Netgame, sizeof(lite_info), server, node, net_address) -#define send_internetwork_full_netgame_packet(server, node) \ - ipx_send_internetwork_packet_data((ubyte *)&Netgame, sizeof(netgame_info), server, node) -#define send_internetwork_lite_netgame_packet(server, node) \ - ipx_send_internetwork_packet_data((ubyte *)&Netgame, sizeof(lite_info), server, node) -#define send_broadcast_full_netgame_packet() \ - ipx_send_broadcast_packet_data((ubyte *)&Netgame, sizeof(netgame_info)) -#define send_broadcast_lite_netgame_packet() \ - ipx_send_broadcast_packet_data((ubyte *)&Netgame, sizeof(lite_info)) -#define receive_full_netgame_packet(data, netgame) \ - memcpy((ubyte *)(netgame), data, sizeof(netgame_info)) -#define receive_lite_netgame_packet(data, netgame) \ - memcpy((ubyte *)(netgame), data, sizeof(lite_info)) - -#define swap_object(obj) - #endif #endif diff --git a/main/network.c b/main/network.c index eb2c16a0..ca0549c4 100644 --- a/main/network.c +++ b/main/network.c @@ -1,4 +1,3 @@ -/* $Id: network.c,v 1.17 2003-02-28 03:54:55 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,18 +7,26 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ +/* + * $Source: /cvs/cvsroot/d2x/main/network.c,v $ + * $Revision: 1.6 $ + * $Author: bradleyb $ + * $Date: 2001-10-23 22:03:03 $ + * + * FIXME: put description here + * + * $Log: not supported by cvs2svn $ + * + */ + #ifdef HAVE_CONFIG_H #include #endif -#ifdef RCS -static char rcsid[] = "$Id: network.c,v 1.17 2003-02-28 03:54:55 btb Exp $"; -#endif - #define PATCH12 #include @@ -66,70 +73,102 @@ static char rcsid[] = "$Id: network.c,v 1.17 2003-02-28 03:54:55 btb Exp $"; #include "netmisc.h" #include "kconfig.h" #include "playsave.h" -#include "cfile.h" #ifdef MACINTOSH #include -#include // for appletalk networking errors +#include // for appletalk networking errors #include "appltalk.h" #endif +void network_send_rejoin_sync(int player_num); +void network_update_netgame(void); +void network_read_endlevel_packet( ubyte *data ); +void network_read_object_packet( ubyte *data ); +void network_read_sync_packet( netgame_info * sp, int d1x ); +void network_flush(); +void network_listen(); +void network_read_pdata_packet(frame_info *pd ); + +void network_check_for_old_version (char pnum); +void network_send_endlevel_short_sub(int from_player_num,int to_player); +int network_wait_for_playerinfo(); +void network_process_pdata (char *data); +void network_read_endlevel_short_packet( ubyte *data ); +void network_ping (ubyte flag,int pnum); +void network_handle_ping_return (ubyte pnum); +void network_process_names_return (char *data); +void network_send_player_names (sequence_packet *their); +int network_choose_connect (); +void network_more_game_options (); +void network_count_powerups_in_mine(void); +int network_wait_for_all_info (int choice); +void network_do_big_wait(int choice); +void network_send_extras (); +void network_read_pdata_short_packet(short_frame_info *pd ); + +void network_AdjustMaxDataSize (); + +void ClipRank (signed char *rank); +void DoRefuseStuff (sequence_packet *their); +void SetAllAllowablesTo (int on); +int GetNewPlayerNumber (sequence_packet *their); + #define LHX(x) ((x)*(MenuHires?2:1)) #define LHY(y) ((y)*(MenuHires?2.4:1)) -#define PID_LITE_INFO 43 -#define PID_SEND_ALL_GAMEINFO 44 -#define PID_PLAYERSINFO 45 -#define PID_REQUEST 46 -#define PID_SYNC 47 -#define PID_PDATA 48 -#define PID_ADDPLAYER 49 -#define PID_DUMP 51 -#define PID_ENDLEVEL 52 -#define PID_QUIT_JOINING 54 -#define PID_OBJECT_DATA 55 -#define PID_GAME_LIST 56 -#define PID_GAME_INFO 57 -#define PID_PING_SEND 58 -#define PID_PING_RETURN 59 -#define PID_GAME_UPDATE 60 -#define PID_ENDLEVEL_SHORT 61 -#define PID_NAKED_PDATA 62 -#define PID_GAME_PLAYERS 63 -#define PID_NAMES_RETURN 64 - -#define NETGAME_ANARCHY 0 -#define NETGAME_TEAM_ANARCHY 1 -#define NETGAME_ROBOT_ANARCHY 2 -#define NETGAME_COOPERATIVE 3 -#define NETGAME_CAPTURE_FLAG 4 -#define NETGAME_HOARD 5 -#define NETGAME_TEAM_HOARD 6 - -#define NETSECURITY_OFF 0 -#define NETSECURITY_WAIT_FOR_PLAYERS 1 -#define NETSECURITY_WAIT_FOR_GAMEINFO 2 -#define NETSECURITY_WAIT_FOR_SYNC 3 +#define PID_LITE_INFO 43 +#define PID_SEND_ALL_GAMEINFO 44 +#define PID_PLAYERSINFO 45 +#define PID_REQUEST 46 +#define PID_SYNC 47 +#define PID_PDATA 48 +#define PID_ADDPLAYER 49 +#define PID_DUMP 51 +#define PID_ENDLEVEL 52 +#define PID_QUIT_JOINING 54 +#define PID_OBJECT_DATA 55 +#define PID_GAME_LIST 56 +#define PID_GAME_INFO 57 +#define PID_PING_SEND 58 +#define PID_PING_RETURN 59 +#define PID_GAME_UPDATE 60 +#define PID_ENDLEVEL_SHORT 61 +#define PID_NAKED_PDATA 62 +#define PID_GAME_PLAYERS 63 +#define PID_NAMES_RETURN 64 + +#define NETGAME_ANARCHY 0 +#define NETGAME_TEAM_ANARCHY 1 +#define NETGAME_ROBOT_ANARCHY 2 +#define NETGAME_COOPERATIVE 3 +#define NETGAME_CAPTURE_FLAG 4 +#define NETGAME_HOARD 5 +#define NETGAME_TEAM_HOARD 6 + +#define NETSECURITY_OFF 0 +#define NETSECURITY_WAIT_FOR_PLAYERS 1 +#define NETSECURITY_WAIT_FOR_GAMEINFO 2 +#define NETSECURITY_WAIT_FOR_SYNC 3 // MWA -- these structures are aligned -- please save me sanity and // headaches by keeping alignment if these are changed!!!! Contact // me for info. typedef struct endlevel_info { - ubyte type; - ubyte player_num; - byte connected; - ubyte seconds_left; - short kill_matrix[MAX_PLAYERS][MAX_PLAYERS]; - short kills; - short killed; + ubyte type; + ubyte player_num; + byte connected; + ubyte seconds_left; + short kill_matrix[MAX_PLAYERS][MAX_PLAYERS]; + short kills; + short killed; } endlevel_info; typedef struct endlevel_info_short { - ubyte type; - ubyte player_num; - byte connected; - ubyte seconds_left; + ubyte type; + ubyte player_num; + byte connected; + ubyte seconds_left; } endlevel_info_short; // WARNING!!! This is the top part of netgame_info...if that struct changes, @@ -158,26 +197,25 @@ typedef struct lite_info { ubyte version_major; ubyte version_minor; ubyte team_vector; -} __pack__ lite_info; + } lite_info; // IF YOU CHANGE THE SIZE OF ANY OF THE FOLLOWING STRUCTURES // MAKE THE MACINTOSH DEFINES BE THE SAME SIZE AS THE PC OR // I WILL HAVE TO HURT YOU VERY BADLY!!! -- MWA #ifdef MACINTOSH -#define NETGAME_INFO_SIZE ( Network_game_type == IPX_GAME?355:sizeof(netgame_info) ) -#define ALLNETPLAYERSINFO_SIZE ( Network_game_type == IPX_GAME?317:sizeof(AllNetPlayers_info) ) -#define LITE_INFO_SIZE ( Network_game_type == IPX_GAME?72:sizeof(lite_info) ) -#define SEQUENCE_PACKET_SIZE ( Network_game_type == IPX_GAME?34:sizeof(sequence_packet) ) -#define FRAME_INFO_SIZE ( Network_game_type == IPX_GAME?541:sizeof(frame_info) ) -#define IPX_SHORT_INFO_SIZE ( 490 ) +#define NETGAME_INFO_SIZE ( Network_game_type == IPX_GAME?355:sizeof(netgame_info) ) +#define ALLNETPLAYERSINFO_SIZE ( Network_game_type == IPX_GAME?317:sizeof(AllNetPlayers_info) ) +#define LITE_INFO_SIZE ( Network_game_type == IPX_GAME?72:sizeof(lite_info) ) +#define SEQUENCE_PACKET_SIZE ( Network_game_type == IPX_GAME?34:sizeof(sequence_packet) ) +#define FRAME_INFO_SIZE ( Network_game_type == IPX_GAME?541:sizeof(frame_info) ) +#define IPX_SHORT_INFO_SIZE ( 490 ) #else -#define NETGAME_INFO_SIZE sizeof(netgame_info) +#define NETGAME_INFO_SIZE sizeof(netgame_info) #define ALLNETPLAYERSINFO_SIZE sizeof(AllNetPlayers_info) -#define LITE_INFO_SIZE sizeof(lite_info) +#define LITE_INFO_SIZE sizeof(lite_info) #define SEQUENCE_PACKET_SIZE sizeof(sequence_packet) -#define FRAME_INFO_SIZE sizeof(frame_info) -#define IPX_SHORT_INFO_SIZE sizeof(short_frame_info) +#define FRAME_INFO_SIZE sizeof(frame_info) #endif #define MAX_ACTIVE_NETGAMES 12 @@ -197,44 +235,11 @@ extern int newmenu_dotiny( char * title, char * subtitle, int nitems, newmenu_it void network_process_naked_pdata (char *,int); extern void multi_send_robot_controls(char); -void network_flush(); -void network_listen(); -void network_update_netgame(); -void network_check_for_old_version(char pnum); -void network_send_objects(); -void network_send_rejoin_sync(int player_num); -void network_send_game_info(sequence_packet *their); -void network_send_endlevel_short_sub(int from_player_num, int to_player); -void network_read_sync_packet(netgame_info * sp, int rsinit); -int network_wait_for_playerinfo(); -void network_process_pdata(char *data); -void network_read_object_packet(ubyte *data ); -void network_read_endlevel_packet(ubyte *data ); -void network_read_endlevel_short_packet(ubyte *data ); -void network_ping(ubyte flat, int pnum); -void network_handle_ping_return(ubyte pnum); -void network_process_names_return(char *data); -void network_send_player_names(sequence_packet *their); -int network_choose_connect(); -void network_more_game_options(); -void network_count_powerups_in_mine(); -int network_wait_for_all_info(int choice); -void network_AdjustMaxDataSize(); -void network_do_big_wait(int choice); -void network_send_extras(); -void network_read_pdata_packet(frame_info *pd); -void network_read_pdata_short_packet(short_frame_info *pd); - -void ClipRank(signed char *rank); -void DoRefuseStuff(sequence_packet *their); -int GetNewPlayerNumber(sequence_packet *their); -void SetAllAllowablesTo(int on); - int num_active_games = 0; int PacketsPerSec=10; int MaxXDataSize=NET_XDATA_SIZE; -int Netlife_kills=0, Netlife_killed=0; +int Netlife_kills=0, Netlife_killed=0; int Network_debug=0; int Network_active=0; @@ -245,11 +250,14 @@ int Network_games_changed = 0; int Network_socket = 0; int Network_allow_socket_changes = 1; +int Network_initial_pps = 10; +int Network_initial_shortpackets = 0; + int NetSecurityFlag=NETSECURITY_OFF; int NetSecurityNum=0; -int Network_sending_extras=0; -int VerifyPlayerJoined=-1; -int Player_joining_extras=-1; // This is so we know who to send 'latecomer' packets to. +int Network_sending_extras=0; +int VerifyPlayerJoined=-1; +int Player_joining_extras=-1; // This is so we know who to send 'latecomer' packets to. // We could just send updates to everyone but that kills the sender! // For rejoin object syncing @@ -265,7 +273,7 @@ sequence_packet Network_player_rejoining; // Who is rejoining now? fix LastPacketTime[MAX_PLAYERS]; // For timeouts of idle/crashed players int PacketUrgent = 0; -int NetGameType=0; +int NetGameType=0; int TotalMissedPackets=0,TotalPacketsGot=0; frame_info MySyncPack,UrgentSyncPack; @@ -283,14 +291,14 @@ extern obj_position Player_init[MAX_PLAYERS]; extern int force_cockpit_redraw; -#define DUMP_CLOSED 0 -#define DUMP_FULL 1 -#define DUMP_ENDLEVEL 2 -#define DUMP_DORK 3 -#define DUMP_ABORTED 4 -#define DUMP_CONNECTED 5 -#define DUMP_LEVEL 6 -#define DUMP_KICKED 7 +#define DUMP_CLOSED 0 +#define DUMP_FULL 1 +#define DUMP_ENDLEVEL 2 +#define DUMP_DORK 3 +#define DUMP_ABORTED 4 +#define DUMP_CONNECTED 5 +#define DUMP_LEVEL 6 +#define DUMP_KICKED 7 extern ubyte Version_major,Version_minor; extern ubyte SurfingNet; @@ -321,7 +329,7 @@ void network_dump_appletalk_player(ubyte node, ushort net, ubyte socket, int why int Network_game_type; // used to tell IPX vs. appletalk games -#define MAX_ZONES 255 +#define MAX_ZONES 255 #define MAX_ZONE_LENGTH 33 #define DEFAULT_ZONE_NAME "\p*" #define MAX_REGISTER_TRIES 5 // maximum time we will try and register a netgame @@ -467,10 +475,10 @@ int network_how_many_connected() return (num); } -#define ENDLEVEL_SEND_INTERVAL (F1_0*2) +#define ENDLEVEL_SEND_INTERVAL (F1_0*2) #define ENDLEVEL_IDLE_TIME (F1_0*20) -/* -void +/* +void network_endlevel_poll( int nitems, newmenu_item * menus, int * key, int citem ) { // Polling loop for End-of-level menu @@ -846,7 +854,7 @@ void network_welcome_player(sequence_packet *their) if (FindArg("-NoMatrixCheat")) { - if ((their->player.version_minor & 0x0F) < 3) + if (their->player.version_minor & (0x0F<3)) { network_dump_player(their->player.network.ipx.server, their->player.network.ipx.node, DUMP_DORK); return; @@ -1266,9 +1274,9 @@ void network_send_objects(void) obj_count = 0; Network_send_object_mode = 0; // mprintf((0, "Sending object array to player %d.\n", player_num)); - *(short *)(object_buffer+loc) = INTEL_SHORT(-1); loc += 2; - object_buffer[loc] = player_num; loc += 1; - /* Placeholder for remote_objnum, not used here */ loc += 2; + *(short *)(object_buffer+loc) = INTEL_SHORT(-1); loc += 2; + object_buffer[loc] = player_num; loc += 1; + loc += 2; // Placeholder for remote_objnum, not used here Network_send_objnum = 0; obj_count_frame = 1; frame_num = 0; @@ -1295,13 +1303,22 @@ void network_send_objects(void) remote_objnum = objnum_local_to_remote((short)i, &owner); Assert(owner == object_owner[i]); - *(short *)(object_buffer+loc) = INTEL_SHORT((short)i); loc += 2; - object_buffer[loc] = owner; loc += 1; - *(short *)(object_buffer+loc) = INTEL_SHORT(remote_objnum); loc += 2; - memcpy(&object_buffer[loc], &Objects[i], sizeof(object)); - if (Network_game_type == IPX_GAME) - swap_object((object *)&object_buffer[loc]); - loc += sizeof(object); + *(short *)(object_buffer+loc) = INTEL_SHORT((short)i); loc += 2; + object_buffer[loc] = owner; loc += 1; + *(short *)(object_buffer+loc) = INTEL_SHORT(remote_objnum); loc += 2; +#ifndef MACINTOSH + memcpy(object_buffer+loc, &Objects[i], sizeof(object)); loc += sizeof(object); +#else + if (Network_game_type == IPX_GAME) { + object tmpobj; + + memcpy(&tmpobj, &(Objects[i]), sizeof(object)); + swap_object(&tmpobj); + memcpy(&(object_buffer[loc]), &tmpobj, sizeof(object)); loc += sizeof(object); + } + else + memcpy(object_buffer+loc, &Objects[i], sizeof(object)); loc += sizeof(object); +#endif // mprintf((0, "..packing object %d, remote %d\n", i, remote_objnum)); } @@ -1415,7 +1432,11 @@ void network_send_rejoin_sync(int player_num) { if ((i != player_num) && (i != Player_num) && (Players[i].connected)) if (Network_game_type == IPX_GAME) { + #ifndef MACINTOSH + ipx_send_packet_data( (ubyte *)&Network_player_rejoining, sizeof(sequence_packet), NetPlayers.players[i].network.ipx.server, NetPlayers.players[i].network.ipx.node, Players[i].net_address); + #else send_sequence_packet( Network_player_rejoining, NetPlayers.players[i].network.ipx.server, NetPlayers.players[i].network.ipx.node, Players[i].net_address); + #endif #ifdef MACINTOSH } else { appletalk_send_packet_data( (ubyte *)&Network_player_rejoining, sizeof(sequence_packet), NetPlayers.players[i].network.appletalk.node, @@ -1445,8 +1466,13 @@ void network_send_rejoin_sync(int player_num) mprintf((0, "Sending rejoin sync packet!!!\n")); if (Network_game_type == IPX_GAME) { - send_internetwork_full_netgame_packet(Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node); + #ifndef MACINTOSH + ipx_send_internetwork_packet_data( (ubyte *)&Netgame, sizeof(netgame_info), Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node ); + ipx_send_internetwork_packet_data( (ubyte *)&NetPlayers, sizeof(AllNetPlayers_info), Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node ); + #else + send_netgame_packet(Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node, NULL, 0); send_netplayers_packet(Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node); + #endif #ifdef MACINTOSH } else { appletalk_send_packet_data( (ubyte *)&Netgame, sizeof(netgame_info), Network_player_rejoining.player.network.appletalk.node, @@ -1481,8 +1507,13 @@ void resend_sync_due_to_packet_loss_for_allender () Netgame.monitor_vector = network_create_monitor_vector(); if (Network_game_type == IPX_GAME) { - send_internetwork_full_netgame_packet(Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node); + #ifndef MACINTOSH + ipx_send_internetwork_packet_data( (ubyte *)&Netgame, sizeof(netgame_info), Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node ); + ipx_send_internetwork_packet_data( (ubyte *)&NetPlayers, sizeof(AllNetPlayers_info), Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node ); + #else + send_netgame_packet(Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node, NULL, 0); send_netplayers_packet(Network_player_rejoining.player.network.ipx.server, Network_player_rejoining.player.network.ipx.node); + #endif #ifdef MACINTOSH } else { appletalk_send_packet_data( (ubyte *)&Netgame, sizeof(netgame_info), Network_player_rejoining.player.network.appletalk.node, @@ -1615,7 +1646,11 @@ network_dump_player(ubyte * server, ubyte *node, int why) memcpy(temp.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1); temp.player.connected = why; if (Network_game_type == IPX_GAME) { - send_internetwork_sequence_packet(temp, server, node); + #ifndef MACINTOSH + ipx_send_internetwork_packet_data( (ubyte *)&temp, sizeof(sequence_packet), server, node); + #else + send_sequence_packet( temp, server, node, NULL); + #endif } else { Int3(); } @@ -1652,7 +1687,11 @@ network_send_game_list_request() memcpy( me.player.network.ipx.node, ipx_get_my_local_address(), 6 ); memcpy( me.player.network.ipx.server, ipx_get_my_server_address(), 4 ); - send_broadcast_sequence_packet(me); + #ifndef MACINTOSH + ipx_send_broadcast_packet_data( (ubyte *)&me, sizeof(sequence_packet) ); + #else + send_sequence_packet( me, NULL, NULL, NULL); + #endif #ifdef MACINTOSH } else { me.player.network.appletalk.node = appletalk_get_my_node(); @@ -1679,7 +1718,11 @@ void network_send_all_info_request(char type,int which_security) memcpy( me.player.network.ipx.node, ipx_get_my_local_address(), 6 ); memcpy( me.player.network.ipx.server, ipx_get_my_server_address(), 4 ); - send_broadcast_sequence_packet(me); + #ifndef MACINTOSH + ipx_send_broadcast_packet_data( (ubyte *)&me, sizeof(sequence_packet) ); + #else + send_sequence_packet(me, NULL, NULL, NULL); + #endif #ifdef MACINTOSH } else { me.player.network.appletalk.node = appletalk_get_my_node(); @@ -1757,7 +1800,7 @@ network_send_endlevel_sub(int player_num) end.kills = INTEL_SHORT(Players[player_num].net_kills_total); end.killed = INTEL_SHORT(Players[player_num].net_killed_total); memcpy(end.kill_matrix, kill_matrix[player_num], MAX_PLAYERS*sizeof(short)); -#ifdef WORDS_BIGENDIAN +#ifdef MACINTOSH for (i = 0; i < MAX_PLAYERS; i++) for (j = 0; j < MAX_PLAYERS; j++) end.kill_matrix[i][j] = INTEL_SHORT(end.kill_matrix[i][j]); @@ -1870,13 +1913,23 @@ network_send_game_info(sequence_packet *their) if (!their) { if (Network_game_type == IPX_GAME) { - send_broadcast_full_netgame_packet(); - send_broadcast_netplayers_packet(); + #ifndef MACINTOSH + ipx_send_broadcast_packet_data((ubyte *)&Netgame, sizeof(netgame_info)); + ipx_send_broadcast_packet_data((ubyte *)&NetPlayers,sizeof(AllNetPlayers_info)); + #else + send_netgame_packet(NULL, NULL, NULL, 0); // server == NULL says to broadcast packet + send_netplayers_packet(NULL, NULL); + #endif } // nothing to do for appletalk games I think.... } else { if (Network_game_type == IPX_GAME) { - send_internetwork_full_netgame_packet(their->player.network.ipx.server, their->player.network.ipx.node); + #ifndef MACINTOSH + ipx_send_internetwork_packet_data((ubyte *)&Netgame, sizeof(netgame_info), their->player.network.ipx.server, their->player.network.ipx.node); + ipx_send_internetwork_packet_data((ubyte *)&NetPlayers,sizeof(AllNetPlayers_info),their->player.network.ipx.server,their->player.network.ipx.node); + #else + send_netgame_packet(their->player.network.ipx.server, their->player.network.ipx.node, NULL, 0); send_netplayers_packet(their->player.network.ipx.server, their->player.network.ipx.node); + #endif #ifdef MACINTOSH } else { appletalk_send_packet_data( (ubyte *)&Netgame, sizeof(netgame_info), their->player.network.appletalk.node, @@ -1926,11 +1979,19 @@ void network_send_lite_info(sequence_packet *their) if (!their) { if (Network_game_type == IPX_GAME) { - send_broadcast_lite_netgame_packet(); + #ifndef MACINTOSH + ipx_send_broadcast_packet_data((ubyte *)&Netgame, sizeof(lite_info)); + #else + send_netgame_packet(NULL, NULL, NULL, 1); // server == NULL says broadcast + #endif } // nothing to do for appletalk I think.... } else { if (Network_game_type == IPX_GAME) { - send_internetwork_lite_netgame_packet(their->player.network.ipx.server, their->player.network.ipx.node); + #ifndef MACINTOSH + ipx_send_internetwork_packet_data((ubyte *)&Netgame, sizeof(lite_info), their->player.network.ipx.server, their->player.network.ipx.node); + #else + send_netgame_packet(their->player.network.ipx.server, their->player.network.ipx.node, NULL, 1); + #endif #ifdef MACINTOSH } else { appletalk_send_packet_data( (ubyte *)&Netgame, sizeof(lite_info), their->player.network.appletalk.node, @@ -1981,7 +2042,11 @@ void network_send_netgame_update() for (i=0; iplayer.callsign, their->player.connected)); if (their->player.connected!=7) @@ -2234,10 +2307,12 @@ extern void multi_reset_object_texture (object *); void network_process_packet(ubyte *data, int length ) { - sequence_packet *their = (sequence_packet *)data; -#ifdef WORDS_BIGENDIAN +#ifdef MACINTOSH sequence_packet tmp_packet; +#endif + sequence_packet *their = (sequence_packet *)data; +#ifdef MACINTOSH if (Network_game_type == IPX_GAME) { receive_sequence_packet(data, &tmp_packet); their = &tmp_packet; // reassign their to point to correctly alinged structure @@ -2261,10 +2336,14 @@ void network_process_packet(ubyte *data, int length ) if (Network_status==NETSTAT_WAITING) { +#ifndef MACINTOSH + memcpy (&TempPlayersBase,data,sizeof(AllNetPlayers_info)); +#else if (Network_game_type == IPX_GAME) receive_netplayers_packet(data, &TempPlayersBase); else memcpy (&TempPlayersBase,data,sizeof(AllNetPlayers_info)); +#endif if (TempPlayersBase.Security!=Netgame.Security) { @@ -2396,10 +2475,14 @@ void network_process_packet(ubyte *data, int length ) if (Network_status == NETSTAT_WAITING) { +#ifndef MACINTOSH + memcpy((ubyte *)&(TempNetInfo), data, sizeof(netgame_info)); +#else if (Network_game_type == IPX_GAME) - receive_full_netgame_packet(data, &TempNetInfo); + receive_netgame_packet(data, &TempNetInfo, 0); else memcpy((ubyte *)&(TempNetInfo), data, sizeof(netgame_info)); +#endif if (TempNetInfo.Security!=Netgame.Security) { @@ -2462,10 +2545,14 @@ void network_process_packet(ubyte *data, int length ) if (Network_status==NETSTAT_PLAYING) { +#ifndef MACINTOSH + memcpy((ubyte *)&TempNetInfo, data, sizeof(lite_info) ); +#else if (Network_game_type == IPX_GAME) - receive_lite_netgame_packet(data, &TempNetInfo); + receive_netgame_packet(data, &TempNetInfo, 1); else memcpy((ubyte *)&TempNetInfo, data, sizeof(lite_info) ); +#endif if (TempNetInfo.Security==Netgame.Security) memcpy (&Netgame,(ubyte *)&TempNetInfo,sizeof(lite_info)); } @@ -2528,11 +2615,14 @@ void network_read_endlevel_packet( ubyte *data ) { // Special packet for end of level syncing - int playernum; - endlevel_info *end = (endlevel_info *)data; -#ifdef WORDS_BIGENDIAN +#ifdef MACINTOSH int i, j; +#endif + int playernum; + endlevel_info *end; + end = (endlevel_info *)data; +#ifdef MACINTOSH for (i = 0; i < MAX_PLAYERS; i++) for (j = 0; j < MAX_PLAYERS; j++) end->kill_matrix[i][j] = INTEL_SHORT(end->kill_matrix[i][j]); @@ -2638,7 +2728,7 @@ network_verify_objects(int remote, int local) return(1); } - + void network_read_object_packet( ubyte *data ) { @@ -2664,8 +2754,8 @@ network_read_object_packet( ubyte *data ) for (i = 0; i < nobj; i++) { objnum = INTEL_SHORT( *(short *)(data+loc) ); loc += 2; - obj_owner = data[loc]; loc += 1; - remote_objnum = INTEL_SHORT( *(short *)(data+loc) ); loc += 2; + obj_owner = data[loc]; loc += 1; + remote_objnum = INTEL_SHORT( *(short *)(data+loc) ); loc += 2; if (objnum == -1) { @@ -2733,10 +2823,11 @@ network_read_object_packet( ubyte *data ) obj_unlink(objnum); Assert(obj->segnum == -1); Assert(objnum < MAX_OBJECTS); - memcpy(obj, &data[loc], sizeof(object)); + memcpy(obj,data+loc,sizeof(object)); loc += sizeof(object); +#ifdef MACINTOSH if (Network_game_type == IPX_GAME) swap_object(obj); - loc += sizeof(object); +#endif segnum = obj->segnum; obj->next = obj->prev = obj->segnum = -1; obj->attached_obj = -1; @@ -2967,28 +3058,28 @@ int netgame_difficulty; int network_get_game_params( char * game_name, int *mode, int *game_flags, int *level ) { int i; - int opt, opt_name, opt_level, opt_mode,opt_moreopts; + int opt, opt_name, opt_level, opt_mode,opt_moreopts; newmenu_item m[20]; char name[NETGAME_NAME_LEN+1]; char slevel[5]; char level_text[32]; - char srmaxnet[50]; + char srmaxnet[50]; int new_mission_num; int anarchy_only; + + *game_flags=*game_flags; - *game_flags=*game_flags; - - SetAllAllowablesTo (1); - NamesInfoSecurity=-1; + SetAllAllowablesTo (1); + NamesInfoSecurity=-1; for (i=0;i99) - Network_socket=99; - if (Network_socket<-99) - Network_socket=-99; - + Network_socket=99; + if (Network_socket<-99) + Network_socket=-99; + if ( Network_socket+IPX_DEFAULT_SOCKET > 0x8000 ) Network_socket = 0x8000 - IPX_DEFAULT_SOCKET; - + if ( Network_socket+IPX_DEFAULT_SOCKET < 0 ) Network_socket = IPX_DEFAULT_SOCKET; - + if (Network_socket != osocket ) { sprintf( menus[0].text, "\t%s %+d (PgUp/PgDn to change)", TXT_CURRENT_IPX_SOCKET, Network_socket ); menus[0].redraw = 1; @@ -3842,14 +3941,14 @@ void network_join_poll( int nitems, newmenu_item * menus, int * key, int citem ) } } - // send a request for game info every 3 seconds - - if (Network_game_type == IPX_GAME) { + // send a request for game info every 3 seconds + + if (Network_game_type == IPX_GAME) { if (timer_get_approx_seconds() > t1+F1_0*3) { t1 = timer_get_approx_seconds(); network_send_game_list_request(); } -#ifdef MACINTOSH + #ifdef MACINTOSH } else if (timer_get_approx_seconds() > t1+F1_0*20) { hide_cursor(); t1 = timer_get_approx_seconds(); @@ -3858,115 +3957,115 @@ void network_join_poll( int nitems, newmenu_item * menus, int * key, int citem ) network_send_game_list_request(); clear_boxed_message(); show_cursor(); -#endif + #endif } - - temp=num_active_games; - + + temp=num_active_games; + network_listen(); - NumActiveNetgames=num_active_games; + NumActiveNetgames=num_active_games; - if (!Network_games_changed) - return; - - if (temp!=num_active_games) - digi_play_sample (SOUND_HUD_MESSAGE,F1_0); + if (!Network_games_changed) + return; + if (temp!=num_active_games) + digi_play_sample (SOUND_HUD_MESSAGE,F1_0); + Network_games_changed = 0; - mprintf ((0,"JOIN POLL: I'm looking at %d games!\n",num_active_games)); + mprintf ((0,"JOIN POLL: I'm looking at %d games!\n",num_active_games)); // Copy the active games data into the menu options for (i = 0; i < num_active_games; i++) { int game_status = Active_games[i].game_status; - int j,x, k,tx,ty,ta,nplayers = 0; - char levelname[8],MissName[25],GameName[25],thold[2]; - thold[1]=0; - - // These next two loops protect against menu skewing - // if missiontitle or gamename contain a tab - - for (x=0,tx=0,k=0,j=0;j<15;j++) - { - if (Active_games[i].mission_title[j]=='\t') - continue; - thold[0]=Active_games[i].mission_title[j]; - gr_get_string_size (thold,&tx,&ty,&ta); - - if ((x+=tx)>=LHX(55)) - { - MissName[k]=MissName[k+1]=MissName[k+2]='.'; - k+=3; - break; - } - - MissName[k++]=Active_games[i].mission_title[j]; - } - MissName[k]=0; - - for (x=0,tx=0,k=0,j=0;j<15;j++) - { - if (Active_games[i].game_name[j]=='\t') - continue; - thold[0]=Active_games[i].game_name[j]; - gr_get_string_size (thold,&tx,&ty,&ta); - - if ((x+=tx)>=LHX(55)) - { - GameName[k]=GameName[k+1]=GameName[k+2]='.'; - k+=3; - break; - } - GameName[k++]=Active_games[i].game_name[j]; - } - GameName[k]=0; + int j,x, k,tx,ty,ta,nplayers = 0; + char levelname[8],MissName[25],GameName[25],thold[2]; + thold[1]=0; + + // These next two loops protect against menu skewing + // if missiontitle or gamename contain a tab + + for (x=0,tx=0,k=0,j=0;j<15;j++) + { + if (Active_games[i].mission_title[j]=='\t') + continue; + thold[0]=Active_games[i].mission_title[j]; + gr_get_string_size (thold,&tx,&ty,&ta); + + if ((x+=tx)>=LHX(55)) + { + MissName[k]=MissName[k+1]=MissName[k+2]='.'; + k+=3; + break; + } + + MissName[k++]=Active_games[i].mission_title[j]; + } + MissName[k]=0; + for (x=0,tx=0,k=0,j=0;j<15;j++) + { + if (Active_games[i].game_name[j]=='\t') + continue; + thold[0]=Active_games[i].game_name[j]; + gr_get_string_size (thold,&tx,&ty,&ta); + + if ((x+=tx)>=LHX(55)) + { + GameName[k]=GameName[k+1]=GameName[k+2]='.'; + k+=3; + break; + } + GameName[k++]=Active_games[i].game_name[j]; + } + GameName[k]=0; - nplayers=Active_games[i].numconnected; + + nplayers=Active_games[i].numconnected; if (Active_games[i].levelnum < 0) sprintf(levelname, "S%d", -Active_games[i].levelnum); - else + else sprintf(levelname, "%d", Active_games[i].levelnum); - - if (game_status == NETSTAT_STARTING) + + if (game_status == NETSTAT_STARTING) { - sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Forming"); + sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", + i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, + Active_games[i].max_numplayers,MissName,levelname,"Forming"); } else if (game_status == NETSTAT_PLAYING) { - join_status=can_join_netgame(&Active_games[i],NULL); - // mprintf ((0,"Joinstatus=%d\n",join_status)); - - if (join_status==1) - sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Open"); + join_status=can_join_netgame(&Active_games[i],NULL); +// mprintf ((0,"Joinstatus=%d\n",join_status)); + + if (join_status==1) + sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", + i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, + Active_games[i].max_numplayers,MissName,levelname,"Open"); else if (join_status==2) - sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Full"); + sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", + i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, + Active_games[i].max_numplayers,MissName,levelname,"Full"); else if (join_status==3) - sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Restrict"); + sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", + i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, + Active_games[i].max_numplayers,MissName,levelname,"Restrict"); else - sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Closed"); + sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", + i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, + Active_games[i].max_numplayers,MissName,levelname,"Closed"); } else - sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Between"); - + sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", + i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, + Active_games[i].max_numplayers,MissName,levelname,"Between"); + - Assert(strlen(menus[i+2].text) < 100); - menus[i+2].redraw = 1; + Assert(strlen(menus[i+2].text) < 100); + menus[i+2].redraw = 1; } for (i = num_active_games; i < MAX_ACTIVE_NETGAMES; i++) @@ -4017,7 +4116,11 @@ menu: if (Network_game_type == IPX_GAME) { memcpy( me.player.network.ipx.node, ipx_get_my_local_address(), 6 ); memcpy( me.player.network.ipx.server, ipx_get_my_server_address(), 4 ); - send_internetwork_sequence_packet(me, NetPlayers.players[0].network.ipx.server, NetPlayers.players[0].network.ipx.node); + #ifndef MACINTOSH + ipx_send_internetwork_packet_data( (ubyte *)&me, sizeof(sequence_packet), NetPlayers.players[0].network.ipx.server, NetPlayers.players[0].network.ipx.node ); + #else + send_sequence_packet(me, NetPlayers.players[0].network.ipx.server, NetPlayers.players[0].network.ipx.node, NULL); + #endif #ifdef MACINTOSH } else { me.player.network.appletalk.node = appletalk_get_my_node(); @@ -4345,7 +4448,7 @@ void network_join_game() if (Network_allow_socket_changes) sprintf( m[0].text, "\tCurrent IPX Socket is default %+d (PgUp/PgDn to change)", Network_socket ); else - strcpy( m[0].text, "" ); //sprintf( m[0].text, "" ); + strcpy( m[0].text, "" ); #ifdef MACINTOSH } else { p2cstr(Network_zone_name); @@ -4562,10 +4665,8 @@ void network_do_big_wait(int choice) int size; ubyte packet[IPX_MAX_DATA_SIZE],*data; AllNetPlayers_info *temp_info; -#ifdef WORDS_BIGENDIAN - AllNetPlayers_info info_struct; -#endif #ifdef MACINTOSH + AllNetPlayers_info info_struct; ubyte apacket[APPLETALK_MAX_DATA_SIZE]; #endif @@ -4590,7 +4691,11 @@ void network_do_big_wait(int choice) case PID_GAME_INFO: if (Network_game_type == IPX_GAME) { - receive_full_netgame_packet(data, &TempNetInfo); + #ifndef MACINTOSH + memcpy((ubyte *)&TempNetInfo, data, sizeof(netgame_info)); + #else + receive_netgame_packet(data, &TempNetInfo, 0); + #endif } else { memcpy((ubyte *)&TempNetInfo, data, sizeof(netgame_info)); } @@ -4635,12 +4740,12 @@ void network_do_big_wait(int choice) mprintf ((0,"Got a PID_PLAYERSINFO!\n")); if (Network_game_type == IPX_GAME) { -#ifndef WORDS_BIGENDIAN + #ifndef MACINTOSH temp_info=(AllNetPlayers_info *)data; -#else + #else receive_netplayers_packet(data, &info_struct); temp_info = &info_struct; -#endif + #endif } else { temp_info = (AllNetPlayers_info *)data; } @@ -4773,10 +4878,8 @@ int network_wait_for_playerinfo() struct AllNetPlayers_info *TempInfo; fix basetime; ubyte id; -#ifdef WORDS_BIGENDIAN - AllNetPlayers_info info_struct; -#endif #ifdef MACINTOSH + AllNetPlayers_info info_struct; ubyte apacket[APPLETALK_MAX_DATA_SIZE]; #endif @@ -4816,20 +4919,17 @@ int network_wait_for_playerinfo() if (size>0 && id==PID_PLAYERSINFO) { -#ifdef WORDS_BIGENDIAN -#ifdef MACINTOSH + #ifdef MACINTOSH if (Network_game_type == APPLETALK_GAME) { TempInfo = (AllNetPlayers_info *)apacket; - } else -#endif - { + } else { receive_netplayers_packet(packet, &info_struct); TempInfo = &info_struct; } -#else + #else TempInfo=(AllNetPlayers_info *)packet; -#endif - + #endif + retries++; if (NetSecurityFlag==NETSECURITY_WAIT_FOR_PLAYERS) @@ -4933,40 +5033,39 @@ void network_timeout_player(int playernum) fix last_send_time = 0; fix last_timeout_check = 0; -#ifdef WORDS_BIGENDIAN +#ifdef MACINTOSH void squish_short_frame_info(short_frame_info old_info, ubyte *data) { int loc = 0; int tmpi; short tmps; - data[0] = old_info.type; loc++; - /* skip three for pad byte */ loc += 3; - tmpi = INTEL_INT(old_info.numpackets); - memcpy(&(data[loc]), &tmpi, 4); loc += 4; + data[0] = old_info.type; loc++; loc += 3; // skip three for pad byte + tmpi = swapint(old_info.numpackets); + memcpy(&(data[loc]), &tmpi, 4); loc += 4; - memcpy(&(data[loc]), old_info.thepos.bytemat, 9); loc += 9; + memcpy(&(data[loc]), old_info.thepos.bytemat, 9); loc += 9; tmps = INTEL_SHORT(old_info.thepos.xo); - memcpy(&(data[loc]), &tmps, 2); loc += 2; + memcpy(&(data[loc]), &tmps, 2); loc += 2; tmps = INTEL_SHORT(old_info.thepos.yo); - memcpy(&(data[loc]), &tmps, 2); loc += 2; + memcpy(&(data[loc]), &tmps, 2); loc += 2; tmps = INTEL_SHORT(old_info.thepos.zo); - memcpy(&(data[loc]), &tmps, 2); loc += 2; + memcpy(&(data[loc]), &tmps, 2); loc += 2; tmps = INTEL_SHORT(old_info.thepos.segment); - memcpy(&(data[loc]), &tmps, 2); loc += 2; + memcpy(&(data[loc]), &tmps, 2); loc += 2; tmps = INTEL_SHORT(old_info.thepos.velx); - memcpy(&(data[loc]), &tmps, 2); loc += 2; + memcpy(&(data[loc]), &tmps, 2); loc += 2; tmps = INTEL_SHORT(old_info.thepos.vely); - memcpy(&(data[loc]), &tmps, 2); loc += 2; + memcpy(&(data[loc]), &tmps, 2); loc += 2; tmps = INTEL_SHORT(old_info.thepos.velz); - memcpy(&(data[loc]), &tmps, 2); loc += 2; + memcpy(&(data[loc]), &tmps, 2); loc += 2; - tmps = INTEL_SHORT(old_info.data_size); - memcpy(&(data[loc]), &tmps, 2); loc += 2; + tmps = swapshort(old_info.data_size); + memcpy(&(data[loc]), &tmps, 2); loc += 2; - data[loc] = old_info.playernum; loc++; - data[loc] = old_info.obj_render_type; loc++; - data[loc] = old_info.level_num; loc++; + data[loc] = old_info.playernum; loc++; + data[loc] = old_info.obj_render_type; loc++; + data[loc] = old_info.level_num; loc++; memcpy(&(data[loc]), old_info.data, old_info.data_size); } #endif @@ -5021,9 +5120,9 @@ void network_do_frame(int force, int listen) if (Netgame.ShortPackets) { -#ifdef WORDS_BIGENDIAN +#ifdef MACINTOSH ubyte send_data[IPX_MAX_DATA_SIZE]; - //int squished_size; + int squished_size; #endif create_shortpos(&ShortSyncPack.thepos, Objects+objnum, 0); ShortSyncPack.type = PID_PDATA; @@ -5038,12 +5137,12 @@ void network_do_frame(int force, int listen) MySyncPack.numpackets = Players[i].n_packets_sent++; ShortSyncPack.numpackets=MySyncPack.numpackets; if (Network_game_type == IPX_GAME) { -#ifndef WORDS_BIGENDIAN + #ifndef MACINTOSH ipx_send_packet_data( (ubyte *)&ShortSyncPack, sizeof(short_frame_info)-MaxXDataSize+MySyncPack.data_size, NetPlayers.players[i].network.ipx.server, NetPlayers.players[i].network.ipx.node,Players[i].net_address ); -#else + #else squish_short_frame_info(ShortSyncPack, send_data); ipx_send_packet_data( (ubyte *)send_data, IPX_SHORT_INFO_SIZE-MaxXDataSize+MySyncPack.data_size, NetPlayers.players[i].network.ipx.server, NetPlayers.players[i].network.ipx.node,Players[i].net_address ); -#endif + #endif #ifdef MACINTOSH } else { appletalk_send_packet_data( (ubyte *)&ShortSyncPack, sizeof(short_frame_info)-MaxXDataSize+MySyncPack.data_size, NetPlayers.players[i].network.appletalk.node, NetPlayers.players[i].network.appletalk.net, NetPlayers.players[i].network.appletalk.socket ); @@ -5068,7 +5167,7 @@ void network_do_frame(int force, int listen) send_data_size = MySyncPack.data_size; // do this so correct size data is sent -#ifdef WORDS_BIGENDIAN // do the swap stuff + #ifdef MACINTOSH // do the swap stuff if (Network_game_type == IPX_GAME) { MySyncPack.obj_segnum = INTEL_SHORT(MySyncPack.obj_segnum); MySyncPack.obj_pos.x = INTEL_INT((int)MySyncPack.obj_pos.x); @@ -5095,14 +5194,16 @@ void network_do_frame(int force, int listen) MySyncPack.data_size = INTEL_SHORT(MySyncPack.data_size); } -#endif + #endif for (i=0; inumpackets = INTEL_INT(pd->numpackets); pd->obj_pos.x = INTEL_INT(pd->obj_pos.x); @@ -5376,23 +5477,22 @@ void network_read_pdata_packet(frame_info *pd ) } -#ifdef WORDS_BIGENDIAN +#ifdef MACINTOSH void get_short_frame_info(ubyte *old_info, short_frame_info *new_info) { int loc = 0; - new_info->type = old_info[loc]; loc++; - /* skip three for pad byte */ loc += 3; - memcpy(&(new_info->numpackets), &(old_info[loc]), 4); loc += 4; + new_info->type = old_info[loc]; loc++; loc += 3; // skip three for pad byte + memcpy(&(new_info->numpackets), &(old_info[loc]), 4); loc += 4; new_info->numpackets = INTEL_INT(new_info->numpackets); - memcpy(new_info->thepos.bytemat, &(old_info[loc]), 9); loc += 9; - memcpy(&(new_info->thepos.xo), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.yo), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.zo), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.segment), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.velx), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.vely), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.velz), &(old_info[loc]), 2); loc += 2; + memcpy(new_info->thepos.bytemat, &(old_info[loc]), 9); loc += 9; + memcpy(&(new_info->thepos.xo), &(old_info[loc]), 2); loc += 2; + memcpy(&(new_info->thepos.yo), &(old_info[loc]), 2); loc += 2; + memcpy(&(new_info->thepos.zo), &(old_info[loc]), 2); loc += 2; + memcpy(&(new_info->thepos.segment), &(old_info[loc]), 2); loc += 2; + memcpy(&(new_info->thepos.velx), &(old_info[loc]), 2); loc += 2; + memcpy(&(new_info->thepos.vely), &(old_info[loc]), 2); loc += 2; + memcpy(&(new_info->thepos.velz), &(old_info[loc]), 2); loc += 2; new_info->thepos.xo = INTEL_SHORT(new_info->thepos.xo); new_info->thepos.yo = INTEL_SHORT(new_info->thepos.yo); new_info->thepos.zo = INTEL_SHORT(new_info->thepos.zo); @@ -5401,16 +5501,13 @@ void get_short_frame_info(ubyte *old_info, short_frame_info *new_info) new_info->thepos.vely = INTEL_SHORT(new_info->thepos.vely); new_info->thepos.velz = INTEL_SHORT(new_info->thepos.velz); - memcpy(&(new_info->data_size), &(old_info[loc]), 2); loc += 2; + memcpy(&(new_info->data_size), &(old_info[loc]), 2); loc += 2; new_info->data_size = INTEL_SHORT(new_info->data_size); - new_info->playernum = old_info[loc]; loc++; - new_info->obj_render_type = old_info[loc]; loc++; - new_info->level_num = old_info[loc]; loc++; + new_info->playernum = old_info[loc]; loc++; + new_info->obj_render_type = old_info[loc]; loc++; + new_info->level_num = old_info[loc]; loc++; memcpy(new_info->data, &(old_info[loc]), new_info->data_size); } -#else -#define get_short_frame_info(old_info, new_info) \ - memcpy(new_info, old_info, sizeof(short_frame_info)) #endif void network_read_pdata_short_packet(short_frame_info *pd ) @@ -5424,7 +5521,11 @@ void network_read_pdata_short_packet(short_frame_info *pd ) // will call totally hacked and gross function to fix this up. if (Network_game_type == IPX_GAME) { + #ifndef MACINTOSH + memcpy(&new_pd, (ubyte *)pd, sizeof(short_frame_info)); + #else get_short_frame_info((ubyte *)pd, &new_pd); + #endif } else { memcpy(&new_pd, (ubyte *)pd, sizeof(short_frame_info)); } @@ -6391,19 +6492,21 @@ void network_send_player_names (sequence_packet *their) ipx_send_internetwork_packet_data((ubyte *)buf, count, their->player.network.ipx.server, their->player.network.ipx.node); #endif } + +extern int file_exists (char *); -int HoardEquipped() +int HoardEquipped () { static int checked=-1; - -#ifdef WINDOWS - return 0; -#endif + + #ifdef WINDOWS + return 0; + #endif if (checked==-1) { - if (cfexist("hoard.ham")) + if (file_exists ("hoard.ham")) checked=1; else checked=0; diff --git a/main/network.h b/main/network.h index f9060e2b..6b228da7 100644 --- a/main/network.h +++ b/main/network.h @@ -1,4 +1,3 @@ -/* $Id: network.h,v 1.11 2003-02-28 03:54:55 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,10 +7,22 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ +/* + * $Source: /cvs/cvsroot/d2x/main/network.h,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-25 02:15:57 $ + * + * FIXME: put description here + * + * $Log: not supported by cvs2svn $ + * + */ + #ifndef _NETWORK_H #define _NETWORK_H @@ -19,28 +30,28 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "multi.h" #include "newmenu.h" -#define NETSTAT_MENU 0 -#define NETSTAT_PLAYING 1 -#define NETSTAT_BROWSING 2 -#define NETSTAT_WAITING 3 -#define NETSTAT_STARTING 4 -#define NETSTAT_ENDLEVEL 5 +#define NETSTAT_MENU 0 +#define NETSTAT_PLAYING 1 +#define NETSTAT_BROWSING 2 +#define NETSTAT_WAITING 3 +#define NETSTAT_STARTING 4 +#define NETSTAT_ENDLEVEL 5 -#define CONNECT_DISCONNECTED 0 -#define CONNECT_PLAYING 1 -#define CONNECT_WAITING 2 -#define CONNECT_DIED_IN_MINE 3 -#define CONNECT_FOUND_SECRET 4 -#define CONNECT_ESCAPE_TUNNEL 5 -#define CONNECT_END_MENU 6 +#define CONNECT_DISCONNECTED 0 +#define CONNECT_PLAYING 1 +#define CONNECT_WAITING 2 +#define CONNECT_DIED_IN_MINE 3 +#define CONNECT_FOUND_SECRET 4 +#define CONNECT_ESCAPE_TUNNEL 5 +#define CONNECT_END_MENU 6 -#define NETGAMEIPX 1 -#define NETGAMETCP 2 +#define NETGAMEIPX 1 +#define NETGAMETCP 2 // defines and other things for appletalk/ipx games on mac -#define IPX_GAME 1 -#define APPLETALK_GAME 2 +#define IPX_GAME 1 +#define APPLETALK_GAME 2 #ifdef MACINTOSH extern int Network_game_type; #else @@ -48,11 +59,11 @@ extern int Network_game_type; #endif typedef struct sequence_packet { - ubyte type; - int Security; - ubyte pad1[3]; - netplayer_info player; -} __pack__ sequence_packet; + ubyte type; + int Security; + ubyte pad1[3]; + netplayer_info player; +} sequence_packet; #define NET_XDATA_SIZE 454 @@ -60,24 +71,24 @@ typedef struct sequence_packet { // frame info is aligned -- 01/18/96 -- MWA // if you change this structure -- be sure to keep // alignment: -// bytes on byte boundries -// shorts on even byte boundries -// ints on even byte boundries +// bytes on byte boundries +// shorts on even byte boundries +// ints on even byte boundries typedef struct frame_info { - ubyte type; // What type of packet - ubyte pad[3]; // Pad out length of frame_info packet - int numpackets; - vms_vector obj_pos; - vms_matrix obj_orient; - vms_vector phys_velocity; - vms_vector phys_rotvel; - short obj_segnum; - ushort data_size; // Size of data appended to the net packet - ubyte playernum; - ubyte obj_render_type; - ubyte level_num; - ubyte data[NET_XDATA_SIZE]; // extra data to be tacked on the end + ubyte type; // What type of packet + ubyte pad[3]; // Pad out length of frame_info packet + int numpackets; + vms_vector obj_pos; + vms_matrix obj_orient; + vms_vector phys_velocity; + vms_vector phys_rotvel; + short obj_segnum; + ushort data_size; // Size of data appended to the net packet + ubyte playernum; + ubyte obj_render_type; + ubyte level_num; + ubyte data[NET_XDATA_SIZE]; // extra data to be tacked on the end } __pack__ frame_info; // short_frame_info is not aligned -- 01/18/96 -- MWA @@ -85,15 +96,15 @@ typedef struct frame_info { // to stay in current form. typedef struct short_frame_info { - ubyte type; // What type of packet - ubyte pad[3]; // Pad out length of frame_info packet - int numpackets; - shortpos thepos; - ushort data_size; // Size of data appended to the net packet - ubyte playernum; - ubyte obj_render_type; - ubyte level_num; - ubyte data[NET_XDATA_SIZE]; // extra data to be tacked on the end + ubyte type; // What type of packet + ubyte pad[3]; // Pad out length of frame_info packet + int numpackets; + shortpos thepos; + ushort data_size; // Size of data appended to the net packet + ubyte playernum; + ubyte obj_render_type; + ubyte level_num; + ubyte data[NET_XDATA_SIZE]; // extra data to be tacked on the end } __pack__ short_frame_info; void network_start_game(); @@ -103,7 +114,6 @@ void network_leave_game(); int network_endlevel(int *secret); void network_endlevel_poll2( int nitems, struct newmenu_item * menus, int * key, int citem ); - int network_level_sync(); void network_send_endlevel_packet(); @@ -112,12 +122,8 @@ int network_find_max_net_players(); int network_objnum_is_past(int objnum); char * network_get_player_name( int objnum ); void network_send_endlevel_sub(int player_num); -void network_disconnect_player(int playernum); - -extern void network_dump_player(ubyte * server, ubyte *node, int why); -extern void network_send_netgame_update(); -extern int GetMyNetRanking(); +void network_disconnect_player(int playernum); extern int NetGameType; extern int Network_send_objects; @@ -131,6 +137,10 @@ extern int Network_status; extern fix LastPacketTime[MAX_PLAYERS]; extern ushort my_segments_checksum; + +extern int Network_initial_pps; +extern int Network_initial_shortpackets; + // By putting an up-to-20-char-message into Network_message and // setting Network_message_reciever to the player num you want to // send it to (100 for broadcast) the next frame the player will @@ -143,7 +153,11 @@ void network_do_frame(int force, int listen); // packet that we're transmitting. void network_send_data( ubyte * ptr, int len, int urgent ); -// returns 1 if hoard.ham available -extern int HoardEquipped(); +void network_send_objects(void); +void network_dump_player(ubyte * server, ubyte *node, int why); +void network_send_game_info(sequence_packet *their); + +int GetMyNetRanking(); +int HoardEquipped(); #endif diff --git a/main/newdemo.c b/main/newdemo.c index b3f3ca15..6ca68dc4 100644 --- a/main/newdemo.c +++ b/main/newdemo.c @@ -1,4 +1,3 @@ -/* $Id: newdemo.c,v 1.12 2003-03-18 02:31:16 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,730 +7,10 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Code to make a complete demo playback system. - * - * $Log: not supported by cvs2svn $ - * Revision 1.11 2003/03/17 07:59:11 btb - * also look in shared data dir for demos - * - * Revision 1.10 2003/03/17 07:10:21 btb - * comments/formatting - * - * Revision 1.12 1995/10/31 10:19:43 allender - * shareware stuff - * - * Revision 1.11 1995/10/17 13:19:16 allender - * close boxes for demo save - * - * Revision 1.10 1995/10/05 10:36:07 allender - * fixed calls to digi_play_sample to account for differing volume and angle calculations - * - * Revision 1.9 1995/09/12 15:49:13 allender - * define __useAppleExts__ if not already defined - * - * Revision 1.8 1995/09/05 14:28:32 allender - * fixed previous N_players bug in newdemo_goto_end - * - * Revision 1.7 1995/09/05 14:16:51 allender - * added space to allowable demo filename characters - * and fixed bug with netgame demos N_players got getting - * set correctly - * - * Revision 1.6 1995/09/01 16:10:47 allender - * fixed bug with reading in N_players variable on - * netgame demo playback - * - * Revision 1.5 1995/08/24 16:04:11 allender - * fix signed byte problem - * - * Revision 1.4 1995/08/12 12:21:59 allender - * made call to create_shortpos not swap the shortpos - * elements - * - * Revision 1.3 1995/08/01 16:04:19 allender - * made random picking of demo work - * - * Revision 1.2 1995/08/01 13:56:56 allender - * demo system working on the mac - * - * Revision 1.1 1995/05/16 15:28:59 allender - * Initial revision - * - * Revision 2.7 1995/05/26 16:16:06 john - * Split SATURN into define's for requiring cd, using cd, etc. - * Also started adding all the Rockwell stuff. - * - * Revision 2.6 1995/03/21 14:39:38 john - * Ifdef'd out the NETWORK code. - * - * Revision 2.5 1995/03/14 18:24:31 john - * Force Destination Saturn to use CD-ROM drive. - * - * Revision 2.4 1995/03/14 16:22:29 john - * Added cdrom alternate directory stuff. - * - * Revision 2.3 1995/03/10 12:58:33 allender - * only display rear view cockpit when cockpit mode was CM_FULL_COCKPIT. - * - * Revision 2.2 1995/03/08 16:12:15 allender - * changes for Destination Saturn - * - * Revision 2.1 1995/03/08 12:11:26 allender - * fix shortpos reading - * - * Revision 2.0 1995/02/27 11:29:40 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.189 1995/02/22 14:53:42 allender - * missed some anonymous stuff - * - * Revision 1.188 1995/02/22 13:24:53 john - * Removed the vecmat anonymous unions. - * - * Revision 1.187 1995/02/22 13:13:54 allender - * remove anonymous unions from object structure - * - * Revision 1.186 1995/02/14 15:36:41 allender - * fix fix for morph effect - * - * Revision 1.185 1995/02/14 11:25:48 allender - * save cockpit mode and restore after playback. get orientation for morph - * effect when object is morph vclip - * - * Revision 1.184 1995/02/13 12:18:14 allender - * change to decide about interpolating or not - * - * Revision 1.183 1995/02/12 00:46:23 adam - * don't decide to skip frames until after at least 10 frames have - * passed -- allender - * - * Revision 1.182 1995/02/11 22:34:01 john - * Made textures page in for newdemos before playback time. - * - * Revision 1.181 1995/02/11 17:28:32 allender - * strip frames from end of demo - * - * Revision 1.180 1995/02/11 16:40:35 allender - * start of frame stripping debug code - * - * Revision 1.179 1995/02/10 17:40:06 allender - * put back in wall_hit_process code to fix door problem - * - * Revision 1.178 1995/02/10 17:17:24 adam - * allender } fix - * - * Revision 1.177 1995/02/10 17:16:24 allender - * fix possible tmap problems - * - * Revision 1.176 1995/02/10 15:54:37 allender - * changes for out of space on device. - * - * Revision 1.175 1995/02/09 19:55:00 allender - * fix bug with morph recording -- force rendertype to RT_POLYOBJ when - * playing back since it won't render until fully morphed otherwise - * - * Revision 1.174 1995/02/07 17:15:35 allender - * DOH!!!!! - * - * Revision 1.173 1995/02/07 17:14:21 allender - * immediately return when loading bogus level stuff when reading a frame - * - * Revision 1.172 1995/02/02 11:15:03 allender - * after loading new level, read next frame (forward or back) always because - * of co-op ships showing up when level is loaded - * - * Revision 1.171 1995/02/02 10:24:16 allender - * removed cfile stuff. Use standard FILE functions for demo playback - * - * Revision 1.170 1995/01/30 13:54:32 allender - * support for missions - * - * Revision 1.169 1995/01/27 16:27:35 allender - * put game mode to demo_game_mode when sorting multiplayer kill (and score) - * list - * - * Revision 1.168 1995/01/27 09:52:25 allender - * minor changes because of object/segment linking problems - * - * Revision 1.167 1995/01/27 09:22:28 allender - * changed way multi-player score is recorded. Record difference, not - * actual - * - * Revision 1.166 1995/01/25 14:32:44 allender - * changed with recorded player flags. More checks for paused state - * during interpolation reading of objects - * - * Revision 1.165 1995/01/25 11:23:32 allender - * found bug with out of disk space problem - * - * Revision 1.164 1995/01/25 11:11:33 allender - * coupla' things. Fix problem with objects apparently being linked in - * the wrong segment. Put an Int3 in to check why demos will write to - * end of space on drive. close demo file if demo doens't start playing - * back. Put obj->type == OBJ_ROBOT around checking for boss cloaking - * - * Revision 1.163 1995/01/24 19:44:30 allender - * fix obscure problem with rewinding and having the wrong object linked - * to the wrong segments. will investigate further. - * - * Revision 1.162 1995/01/23 09:31:28 allender - * add team score in team mode playback - * - * Revision 1.161 1995/01/20 22:47:39 matt - * Mission system implemented, though imcompletely - * - * Revision 1.160 1995/01/20 09:30:37 allender - * don't call LoadLevel with bogus data - * - * Revision 1.159 1995/01/20 09:13:23 allender - * *&^%&*%$ typo - * - * Revision 1.158 1995/01/20 09:12:04 allender - * record team names during demo recoring in GM_TEAM - * - * Revision 1.157 1995/01/19 16:31:09 allender - * forgot to bump demo version for new weapon change stuff - * - * Revision 1.156 1995/01/19 16:29:33 allender - * added new byte for weapon change (old weapon) so rewinding works - * correctly for weapon changes in registered - * - * Revision 1.155 1995/01/19 15:00:05 allender - * remove code to take away blastable walls in multiplayer demo playbacks - * - * Revision 1.154 1995/01/19 11:07:05 allender - * put in psuedo cloaking for boss robots. Problem is that cloaking is - * time based, and that don't get done in demos, so bosses just disappear. - * oh well - * - * Revision 1.153 1995/01/19 09:42:29 allender - * record laser levels in demos - * - * Revision 1.152 1995/01/18 20:43:12 allender - * fix laser level stuff on goto-beginning and goto-end - * - * Revision 1.151 1995/01/18 20:28:18 allender - * cloak robots now cloak (except maybe for boss........) Put in function - * to deal with control center triggers - * - * Revision 1.150 1995/01/18 18:55:07 allender - * bug fix - * - * Revision 1.149 1995/01/18 18:49:03 allender - * lots 'o stuff....record laser level. Record beginning of door opening - * sequence. Fix some problems with control center stuff. Control center - * triggers now work in reverse - * - * Revision 1.148 1995/01/18 08:51:40 allender - * forgot to record ammo counts at beginning of demo - * - * Revision 1.147 1995/01/17 17:42:07 allender - * added primary and secondary ammo counts. Changed goto_end routine - * to be more efficient - * - * Revision 1.146 1995/01/17 13:46:35 allender - * fix problem with destroyed control center and rewinding a demo. - * Save callsign and restore after demo playback - * - * Revision 1.145 1995/01/12 10:21:53 allender - * fixes for 1.0 to 1.1 demo incompatibility - * - * Revision 1.144 1995/01/05 13:51:43 allender - * fixed type of player num variable - * - * Revision 1.143 1995/01/04 16:58:28 allender - * bumped up demo version number - * - * Revision 1.142 1995/01/04 14:59:02 allender - * added more information to end of demo for registered. Forced game mode - * to be GM_NORMAL on demo playback - * - * Revision 1.141 1995/01/03 17:30:47 allender - * fixed logic problem with cloak stuf - * - * Revision 1.140 1995/01/03 17:12:23 allender - * fix for getting cloak stuff at end of demo for shareware - * - * Revision 1.139 1995/01/03 15:20:24 allender - * fix goto_end for shareware -- changes to goto_end for registered - * - * Revision 1.138 1995/01/03 13:13:26 allender - * add } I forgot - * - * Revision 1.137 1995/01/03 13:10:29 allender - * make score work forwards and backwards - * - * Revision 1.136 1995/01/03 11:45:20 allender - * added code to record players scores - * - * Revision 1.135 1994/12/30 10:03:57 allender - * put cloak stuff at end of demo for fast forward to the end - * - * Revision 1.134 1994/12/29 17:02:55 allender - * spelling fix on SHAREWARE - * - * Revision 1.133 1994/12/29 16:43:41 allender - * lots of new multiplayer stuff. wrapped much code with SHAREWARE defines - * - * Revision 1.132 1994/12/28 14:15:01 allender - * added routines to deal with connecting and reconnecting players when - * recording multiplayer demos - * - * Revision 1.131 1994/12/21 12:57:59 allender - * bug fix - * - * Revision 1.130 1994/12/21 12:46:53 allender - * record multi player deaths and kills - * - * Revision 1.129 1994/12/19 16:37:27 allender - * pick good filename when trying to save in network play and player - * gets bumped out of menu by multi-player code - * - * Revision 1.128 1994/12/14 10:49:01 allender - * reset bad_read variable when starting demo playback - * - * Revision 1.127 1994/12/14 08:53:06 allender - * lowered watermark for out of space - * - * Revision 1.126 1994/12/14 08:49:52 allender - * put up warning when starting demo recording if not enough space and - * not let them record - * - * Revision 1.125 1994/12/13 00:01:37 allender - * CLOAK FIX -- (I'm tempted to take cloak out of game because I can't - * seem to get it right in demo playback) - * - * Revision 1.124 1994/12/12 14:51:21 allender - * more fixed to multiplayer cloak stuff - * - * Revision 1.123 1994/12/12 11:33:11 allender - * fixed rearview mode to work again - * - * Revision 1.122 1994/12/12 11:00:16 matt - * Added code to handle confusion with attached objects - * - * Revision 1.121 1994/12/12 00:31:29 allender - * give better warning when out of space when recording. Don't record - * until no space left. We have 500K watermark when we now stop recording - * - * Revision 1.120 1994/12/10 16:44:54 matt - * Added debugging code to track down door that turns into rock - * - * Revision 1.119 1994/12/09 18:46:15 matt - * Added code to handle odd error condition - * - * Revision 1.118 1994/12/09 17:27:37 allender - * force playernum to 0 when demo is done playing - * - * Revision 1.117 1994/12/09 16:40:39 allender - * yet more cloak stuff. Assign cloak/invuln time when starting demo - * if flags are set. Check cloak and invuln time when demo - * even when paused - * - * Revision 1.116 1994/12/09 14:59:22 matt - * Added system to attach a fireball to another object for rendering purposes, - * so the fireball always renders on top of (after) the object. - * - * Revision 1.115 1994/12/09 12:21:45 allender - * only allow valid chars when typing in demo filename - * - * Revision 1.114 1994/12/08 23:19:02 allender - * final(?) fix for getting cloak gauge to work on demo playback - * with forward and reverse - * - * Revision 1.113 1994/12/08 21:34:38 allender - * record old and new player flags to accuratedly record cloaking and - * decloaking - * ./ - * - * Revision 1.112 1994/12/08 18:04:47 allender - * bashed playernum right after reading it in demo header so shields - * and energy are put in right place - * - * Revision 1.111 1994/12/08 17:10:07 allender - * encode playernum in demo header. Bash viewer segment to 0 if in - * bogus segnum. Don't link render objs for same reason - * - * Revision 1.110 1994/12/08 15:36:12 allender - * cloak stuff works forwards and backwards - * - * Revision 1.109 1994/12/08 13:46:03 allender - * don't record rearview anymore, but leave in case statement for playback - * purposes. change the way letterbox <--> cockpit transitions happen - * - * Revision 1.108 1994/12/08 12:36:06 matt - * Added new object allocation & deallocation functions so other code - * could stop messing around with internal object data structures. - * - * Revision 1.107 1994/12/08 11:19:04 allender - * handle out of space (more) gracefully then before - * - * Revision 1.106 1994/12/08 00:29:49 allender - * fixed bug that didn't load level on goto_beginning - * - * Revision 1.105 1994/12/08 00:11:51 mike - * change matrix interpolation. - * - * Revision 1.104 1994/12/07 23:46:37 allender - * changed invulnerability and cloak to work (almost) correctly both - * in single and multi player - * - * Revision 1.103 1994/12/07 11:48:49 adam - * BY ALLENDER -- added dampening of interpolation factor to 1 if greater - * than 1 (although I have not seen this happen). this is attempt to - * get wobbling problem solved - * - * Revision 1.102 1994/12/07 11:23:56 allender - * attempt at getting rid of wobbling on demo playback - * - * Revision 1.101 1994/12/06 19:31:17 allender - * moved blastable wall stuff code to where we load level during demo - * playback - * - * Revision 1.100 1994/12/06 19:21:51 allender - * multi games, destroy blastable walls. Do wall toggle when control center - * destroyed - * - * Revision 1.99 1994/12/06 16:54:48 allender - * fixed code so if demo automatically started from menu, don't bring up - * message if demo is too old - * - * Revision 1.98 1994/12/06 13:55:15 matt - * Use new rounding func, f2ir() - * - * Revision 1.97 1994/12/06 13:44:45 allender - * suppressed compiler warnings - * - * Revision 1.96 1994/12/06 13:38:03 allender - * removed recording of wall hit process. I think that all bases are covered - * elsewhere - * - * Revision 1.95 1994/12/06 12:57:35 allender - * added recording of multi_decloaking. Fixed some other cloaking code so - * that cloak should last as long as player was cloaked. We will lose the - * guage effect, but the time is probably more important on playback - * - * Revision 1.94 1994/12/05 23:37:17 matt - * Took out calls to warning() function - * - * Revision 1.93 1994/12/03 17:52:04 yuan - * Localization 380ish - * - * Revision 1.92 1994/12/02 12:53:39 allender - * fixed goto_beginning and goto_end on demo playback - * - * Revision 1.91 1994/12/01 12:01:49 allender - * added multi player cloak stuff - * - * Revision 1.90 1994/11/30 09:33:58 allender - * added field in header to tell what version (shareware or registered) - * demo was recorded with. Don't allow demo recorded on one to playback - * on the other - * - * Revision 1.89 1994/11/29 00:31:01 allender - * major changes -- added level recording feature which records level - * advancement. Changes to internal code to handle this. - * - * Revision 1.88 1994/11/27 23:13:54 matt - * Made changes for new mprintf calling convention - * - * Revision 1.87 1994/11/27 23:07:35 allender - * starting on code to get all level transitions recorded. not done yet - * - * Revision 1.86 1994/11/27 17:39:47 matt - * Don't xlate tmap numbers when editor compiled out - * - * Revision 1.85 1994/11/23 09:27:21 allender - * put up info box with message if demo version is too old or level - * cannot be loaded - * - * Revision 1.84 1994/11/22 19:37:39 allender - * fix array mistake - * - * Revision 1.83 1994/11/22 19:35:09 allender - * record player ship colors in multiplayer demo recordings - * - * Revision 1.82 1994/11/19 15:36:42 mike - * fix fix. - * - * Revision 1.81 1994/11/19 15:23:21 mike - * rip out unused code - * - * Revision 1.80 1994/11/16 14:51:49 rob - * Fixed network/demo incompatibility. - * - * Revision 1.79 1994/11/15 10:55:48 allender - * made start of demo playback read initial demo information so - * level will get loaded. Made demo record to single file which - * will get renamed. Added numerics after old filename so - * sequential filenames would be defaulted to - * - * Revision 1.78 1994/11/15 09:46:06 allender - * added versioning. Fixed problems with trying to interpolating a completely - * 0 orientation matrix - * - * Revision 1.77 1994/11/14 14:34:31 matt - * Fixed up handling when textures can't be found during remap - * - * Revision 1.76 1994/11/14 09:15:29 allender - * make ESC from file save menu exit w/o saving. Fix letterbox, rear view, - * to normal cockpit mode transition to work correctly when skipping and - * interpolating frames - * - * Revision 1.75 1994/11/11 16:22:07 allender - * made morphing objects record only the object being morphed. - * - * Revision 1.74 1994/11/08 14:59:19 john - * Added code to respond to network while in menus. - * - * Revision 1.73 1994/11/08 14:52:20 adam - * *** empty log message *** - * - * Revision 1.72 1994/11/07 15:47:04 allender - * prompt for filename when done recording demo - * - * Revision 1.71 1994/11/07 11:47:19 allender - * when interpolating frames, delete weapon, fireball, and debris objects - * from an inpolated frame if they don't appear in the next recorded - * frame - * - * Revision 1.70 1994/11/07 11:02:41 allender - * more with interpolation. I believe that I have it right now - * - * Revision 1.69 1994/11/07 08:47:40 john - * Made wall state record. - * - * Revision 1.68 1994/11/05 17:22:51 john - * Fixed lots of sequencing problems with newdemo stuff. - * - * Revision 1.67 1994/11/04 20:11:52 john - * Neatening up palette stuff with demos. - * - * Revision 1.66 1994/11/04 16:49:44 allender - * changed newdemo_do_interpolate to default to on - * - * Revision 1.65 1994/11/04 16:44:51 allender - * added filename support for demo recording. more auto demo stuff - * - * Revision 1.64 1994/11/04 13:05:31 allender - * fixing the lifeleft variable again. (I think I got it right this time) - * - * Revision 1.63 1994/11/04 11:37:37 allender - * commented out fprintfs and fixed compiler warning - * - * Revision 1.62 1994/11/04 11:33:50 allender - * added OBJ_FLARE and OBJ_LIGHT to obj->lifeleft recording - * - * Revision 1.61 1994/11/04 11:29:21 allender - * more interpolation stuff -- not done yet. Fixed so hostage vclips - * render correctly. Changed lifeleft to full precision, but only - * write it when object is fireball or weapon type of object - * - * Revision 1.60 1994/11/03 10:00:11 allender - * fixed divide by zero in calculating render time. more interpolation - * stuff which isn't quite done - * - * Revision 1.59 1994/11/02 17:10:59 allender - * never play recorded frames when interpolation is occuring - * - * Revision 1.58 1994/11/02 14:28:58 allender - * profile total playback time and average frame render time - * - * Revision 1.57 1994/11/02 14:09:03 allender - * record rear view. start of playback interpolation code -- this - * is not yet done - * - * Revision 1.56 1994/11/01 13:25:30 allender - * drop frames if playing back demo on slower machine - * - * Revision 1.55 1994/10/31 16:10:40 allender - * record letterbox mode on death seq, and then restore - * - * Revision 1.54 1994/10/29 16:01:38 allender - * added ND_STATE_NODEMOS to indicate that there are no demos currently - * available for playback - * - * Revision 1.53 1994/10/29 15:38:42 allender - * in newdemo_start_playback, make Newdemo_at_eof = 0 - * - * Revision 1.52 1994/10/28 14:45:28 john - * fixed typo from last checkin. - * - * Revision 1.51 1994/10/28 14:42:55 john - * Added sound volumes to all sound calls. - * - * Revision 1.50 1994/10/28 14:31:57 allender - * homing missle and autodemo stuff - * - * Revision 1.49 1994/10/28 12:42:14 allender - * record homing distance - * - * Revision 1.48 1994/10/27 16:57:54 allender - * changed demo vcr to be able to play any number of frames by storing - * frame length (in bytes) in the demo file. Added blowing up monitors - * - * Revision 1.47 1994/10/26 16:50:50 allender - * put two functions inside of VCR_MODE ifdef - * - * Revision 1.46 1994/10/26 15:20:32 allender - * added CT_REMOTE as valid control type for recording - * - * Revision 1.45 1994/10/26 14:45:35 allender - * completed hacked in vcr demo playback stuff - * - * Revision 1.44 1994/10/26 13:40:52 allender - * vcr playback of demo stuff - * - * Revision 1.43 1994/10/26 08:51:57 allender - * record player weapon change - * - * Revision 1.42 1994/10/25 15:48:01 allender - * add shields, energy, and player flags to demo recording. - * , - * - * Revision 1.41 1994/10/24 08:19:35 allender - * fixed compilation errors - * - * Revision 1.40 1994/10/23 19:17:08 matt - * Fixed bug with "no key" messages - * - * Revision 1.39 1994/10/22 14:15:08 mike - * Suppress compiler warnings. - * - * Revision 1.38 1994/10/21 15:24:55 allender - * compressed writing of object structures with specialized code - * to write out only pertinent object structures. - * - * Revision 1.37 1994/10/20 13:03:17 matt - * Replaced old save files (MIN/SAV/HOT) with new LVL files - * - * Revision 1.36 1994/09/28 23:13:10 matt - * Macroized palette flash system - * - * Revision 1.35 1994/09/26 17:28:32 matt - * Made new multiple-object morph code work with the demo system - * - * Revision 1.34 1994/09/10 13:31:54 matt - * Made exploding walls a type of blastable walls. - * Cleaned up blastable walls, making them tmap2 bitmaps. - * - * Revision 1.33 1994/08/15 18:05:28 john - * *** empty log message *** - * - * Revision 1.32 1994/08/15 17:56:38 john - * , - * - * Revision 1.31 1994/08/10 09:44:54 john - * *** empty log message *** - * - * Revision 1.30 1994/07/22 12:35:48 matt - * Cleaned up editor/game interactions some more. - * - * Revision 1.29 1994/07/21 13:06:45 matt - * Ripped out remants of old demo system, and added demo only system that - * disables object movement and game options from menu. - * - * Revision 1.28 1994/07/18 16:22:44 john - * Made all file read/writes call the same routine. - * - * Revision 1.27 1994/07/14 22:38:27 matt - * Added exploding doors - * - * Revision 1.26 1994/07/05 12:49:04 john - * Put functionality of New Hostage spec into code. - * - * Revision 1.25 1994/06/29 11:05:38 john - * Made demos read in compressed. - * - * Revision 1.24 1994/06/29 09:14:06 john - * Made files write out uncompressed and read in compressed. - * - * Revision 1.23 1994/06/28 11:55:28 john - * Made newdemo system record/play directly to/from disk, so - * we don't need the 4 MB buffer anymore. - * - * Revision 1.22 1994/06/27 15:52:38 john - * #define'd out the newdemo stuff - * - * - * Revision 1.21 1994/06/22 00:29:04 john - * Fixed bug with playing demo then playing game without - * loading new mine. - * - * Revision 1.20 1994/06/22 00:14:23 john - * Attempted to fix sign. - * - * Revision 1.19 1994/06/21 23:57:54 john - * Hopefully fixed bug with negative countdowns. - * - * Revision 1.18 1994/06/21 23:47:44 john - * MAde Malloc always 4*1024*1024. - * - * Revision 1.17 1994/06/21 22:58:47 john - * Added error if out of memory. - * - * Revision 1.16 1994/06/21 22:15:48 john - * Added % done to demo recording. - * - * - * Revision 1.15 1994/06/21 19:45:55 john - * Added palette effects to demo recording. - * - * Revision 1.14 1994/06/21 15:08:54 john - * Made demo record HUD message and cleaned up the HUD code. - * - * Revision 1.13 1994/06/21 14:20:08 john - * Put in hooks to record HUD messages. - * - * Revision 1.12 1994/06/20 11:50:15 john - * Made demo record flash effect, and control center triggers. - * - * Revision 1.11 1994/06/17 18:01:33 john - * A bunch of new stuff by John - * - * Revision 1.10 1994/06/17 12:13:31 john - * More newdemo stuff; made editor->game transition start in slew mode. - * - * Revision 1.9 1994/06/16 13:14:36 matt - * Fixed typo - * - * Revision 1.8 1994/06/16 13:02:07 john - * Added morph hooks. - * - * Revision 1.7 1994/06/15 19:01:33 john - * Added the capability to make 3d sounds play just once for the - * laser hit wall effects. - * - * Revision 1.6 1994/06/15 14:56:59 john - * Added triggers to demo recording. - * - * Revision 1.5 1994/06/14 20:42:15 john - * Made robot matztn cntr not work until no robots or player are - * in the segment. - * - * Revision 1.4 1994/06/14 14:43:27 john - * Made doors work with newdemo system. - * - * Revision 1.3 1994/06/14 11:32:29 john - * Made Newdemo record & restore the current mine. - * - * Revision 1.2 1994/06/13 21:02:43 john - * Initial version of new demo recording system. - * - * Revision 1.1 1994/06/13 11:09:00 john - * Initial revision - * - * - */ - - #ifdef HAVE_CONFIG_H #include #endif @@ -739,10 +18,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #include #include -#include // for memset +#include // for memset #include #include /* for isdigit */ -#include #ifdef __unix__ #include #include @@ -765,7 +43,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "object.h" #include "physics.h" -#include "slew.h" +#include "slew.h" #include "render.h" #include "wall.h" #include "vclip.h" @@ -806,7 +84,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "piggy.h" #include "controls.h" #include "d_io.h" -#include "timer.h" +#include "d_delay.h" #include "findfile.h" @@ -815,7 +93,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef MACINTOSH -#pragma global_optimizer off // pretty much sucks...need to look into this +#pragma global_optimizer off // pretty much sucks...need to look into this #endif void DoJasonInterpolate (fix recorded_time); @@ -829,70 +107,76 @@ byte WasRecorded [MAX_OBJECTS]; byte ViewWasRecorded[MAX_OBJECTS]; byte RenderingWasRecorded[32]; -#define ND_EVENT_EOF 0 // EOF -#define ND_EVENT_START_DEMO 1 // Followed by 16 character, NULL terminated filename of .SAV file to use -#define ND_EVENT_START_FRAME 2 // Followed by integer frame number, then a fix FrameTime -#define ND_EVENT_VIEWER_OBJECT 3 // Followed by an object structure -#define ND_EVENT_RENDER_OBJECT 4 // Followed by an object structure -#define ND_EVENT_SOUND 5 // Followed by int soundum -#define ND_EVENT_SOUND_ONCE 6 // Followed by int soundum -#define ND_EVENT_SOUND_3D 7 // Followed by int soundum, int angle, int volume -#define ND_EVENT_WALL_HIT_PROCESS 8 // Followed by int segnum, int side, fix damage -#define ND_EVENT_TRIGGER 9 // Followed by int segnum, int side, int objnum -#define ND_EVENT_HOSTAGE_RESCUED 10 // Followed by int hostage_type -#define ND_EVENT_SOUND_3D_ONCE 11 // Followed by int soundum, int angle, int volume -#define ND_EVENT_MORPH_FRAME 12 // Followed by ? data -#define ND_EVENT_WALL_TOGGLE 13 // Followed by int seg, int side -#define ND_EVENT_HUD_MESSAGE 14 // Followed by char size, char * string (+null) -#define ND_EVENT_CONTROL_CENTER_DESTROYED 15 // Just a simple flag -#define ND_EVENT_PALETTE_EFFECT 16 // Followed by short r,g,b -#define ND_EVENT_PLAYER_ENERGY 17 // followed by byte energy -#define ND_EVENT_PLAYER_SHIELD 18 // followed by byte shields -#define ND_EVENT_PLAYER_FLAGS 19 // followed by player flags -#define ND_EVENT_PLAYER_WEAPON 20 // followed by weapon type and weapon number -#define ND_EVENT_EFFECT_BLOWUP 21 // followed by segment, side, and pnt -#define ND_EVENT_HOMING_DISTANCE 22 // followed by homing distance -#define ND_EVENT_LETTERBOX 23 // letterbox mode for death seq. -#define ND_EVENT_RESTORE_COCKPIT 24 // restore cockpit after death -#define ND_EVENT_REARVIEW 25 // going to rear view mode -#define ND_EVENT_WALL_SET_TMAP_NUM1 26 // Wall changed -#define ND_EVENT_WALL_SET_TMAP_NUM2 27 // Wall changed -#define ND_EVENT_NEW_LEVEL 28 // followed by level number -#define ND_EVENT_MULTI_CLOAK 29 // followed by player num -#define ND_EVENT_MULTI_DECLOAK 30 // followed by player num -#define ND_EVENT_RESTORE_REARVIEW 31 // restore cockpit after rearview mode -#define ND_EVENT_MULTI_DEATH 32 // with player number -#define ND_EVENT_MULTI_KILL 33 // with player number -#define ND_EVENT_MULTI_CONNECT 34 // with player number -#define ND_EVENT_MULTI_RECONNECT 35 // with player number -#define ND_EVENT_MULTI_DISCONNECT 36 // with player number -#define ND_EVENT_MULTI_SCORE 37 // playernum / score -#define ND_EVENT_PLAYER_SCORE 38 // followed by score -#define ND_EVENT_PRIMARY_AMMO 39 // with old/new ammo count -#define ND_EVENT_SECONDARY_AMMO 40 // with old/new ammo count -#define ND_EVENT_DOOR_OPENING 41 // with segment/side -#define ND_EVENT_LASER_LEVEL 42 // no data -#define ND_EVENT_PLAYER_AFTERBURNER 43 // followed by byte old ab, current ab -#define ND_EVENT_CLOAKING_WALL 44 // info changing while wall cloaking -#define ND_EVENT_CHANGE_COCKPIT 45 // change the cockpit -#define ND_EVENT_START_GUIDED 46 // switch to guided view -#define ND_EVENT_END_GUIDED 47 // stop guided view/return to ship -#define ND_EVENT_SECRET_THINGY 48 // 0/1 = secret exit functional/non-functional -#define ND_EVENT_LINK_SOUND_TO_OBJ 49 // record digi_link_sound_to_object3 -#define ND_EVENT_KILL_SOUND_TO_OBJ 50 // record digi_kill_sound_linked_to_object - - -#define NORMAL_PLAYBACK 0 -#define SKIP_PLAYBACK 1 -#define INTERPOLATE_PLAYBACK 2 -#define INTERPOL_FACTOR (F1_0 + (F1_0/5)) - -#define DEMO_VERSION 15 // last D1 version was 13 -#define DEMO_GAME_TYPE 3 // 1 was shareware, 2 registered - -#define DEMO_FILENAME DEMO_DIR "tmpdemo.dem" - -#define DEMO_MAX_LEVELS 29 +#define ND_EVENT_EOF 0 // EOF +#define ND_EVENT_START_DEMO 1 // Followed by 16 character, NULL terminated filename of .SAV file to use +#define ND_EVENT_START_FRAME 2 // Followed by integer frame number, then a fix FrameTime +#define ND_EVENT_VIEWER_OBJECT 3 // Followed by an object structure +#define ND_EVENT_RENDER_OBJECT 4 // Followed by an object structure +#define ND_EVENT_SOUND 5 // Followed by int soundum +#define ND_EVENT_SOUND_ONCE 6 // Followed by int soundum +#define ND_EVENT_SOUND_3D 7 // Followed by int soundum, int angle, int volume +#define ND_EVENT_WALL_HIT_PROCESS 8 // Followed by int segnum, int side, fix damage +#define ND_EVENT_TRIGGER 9 // Followed by int segnum, int side, int objnum +#define ND_EVENT_HOSTAGE_RESCUED 10 // Followed by int hostage_type +#define ND_EVENT_SOUND_3D_ONCE 11 // Followed by int soundum, int angle, int volume +#define ND_EVENT_MORPH_FRAME 12 // Followed by ? data +#define ND_EVENT_WALL_TOGGLE 13 // Followed by int seg, int side +#define ND_EVENT_HUD_MESSAGE 14 // Followed by char size, char * string (+null) +#define ND_EVENT_CONTROL_CENTER_DESTROYED 15 // Just a simple flag +#define ND_EVENT_PALETTE_EFFECT 16 // Followed by short r,g,b +#define ND_EVENT_PLAYER_ENERGY 17 // followed by byte energy +#define ND_EVENT_PLAYER_SHIELD 18 // followed by byte shields +#define ND_EVENT_PLAYER_FLAGS 19 // followed by player flags +#define ND_EVENT_PLAYER_WEAPON 20 // followed by weapon type and weapon number +#define ND_EVENT_EFFECT_BLOWUP 21 // followed by segment, side, and pnt +#define ND_EVENT_HOMING_DISTANCE 22 // followed by homing distance +#define ND_EVENT_LETTERBOX 23 // letterbox mode for death seq. +#define ND_EVENT_RESTORE_COCKPIT 24 // restore cockpit after death +#define ND_EVENT_REARVIEW 25 // going to rear view mode +#define ND_EVENT_WALL_SET_TMAP_NUM1 26 // Wall changed +#define ND_EVENT_WALL_SET_TMAP_NUM2 27 // Wall changed +#define ND_EVENT_NEW_LEVEL 28 // followed by level number +#define ND_EVENT_MULTI_CLOAK 29 // followed by player num +#define ND_EVENT_MULTI_DECLOAK 30 // followed by player num +#define ND_EVENT_RESTORE_REARVIEW 31 // restore cockpit after rearview mode +#define ND_EVENT_MULTI_DEATH 32 // with player number +#define ND_EVENT_MULTI_KILL 33 // with player number +#define ND_EVENT_MULTI_CONNECT 34 // with player number +#define ND_EVENT_MULTI_RECONNECT 35 // with player number +#define ND_EVENT_MULTI_DISCONNECT 36 // with player number +#define ND_EVENT_MULTI_SCORE 37 // playernum / score +#define ND_EVENT_PLAYER_SCORE 38 // followed by score +#define ND_EVENT_PRIMARY_AMMO 39 // with old/new ammo count +#define ND_EVENT_SECONDARY_AMMO 40 // with old/new ammo count +#define ND_EVENT_DOOR_OPENING 41 // with segment/side +#define ND_EVENT_LASER_LEVEL 42 // no data +#define ND_EVENT_PLAYER_AFTERBURNER 43 // followed by byte old ab, current ab +#define ND_EVENT_CLOAKING_WALL 44 // info changing while wall cloaking +#define ND_EVENT_CHANGE_COCKPIT 45 // change the cockpit +#define ND_EVENT_START_GUIDED 46 // switch to guided view +#define ND_EVENT_END_GUIDED 47 // stop guided view/return to ship +#define ND_EVENT_SECRET_THINGY 48 // 0/1 = secret exit functional/non-functional +#define ND_EVENT_LINK_SOUND_TO_OBJ 49 // record digi_link_sound_to_object3 +#define ND_EVENT_KILL_SOUND_TO_OBJ 50 // record digi_kill_sound_linked_to_object + + +#define NORMAL_PLAYBACK 0 +#define SKIP_PLAYBACK 1 +#define INTERPOLATE_PLAYBACK 2 +#define INTERPOL_FACTOR (F1_0 + (F1_0/5)) + +#define DEMO_VERSION 15 //last D1 version was 13 +#define DEMO_GAME_TYPE 3 //1 was shareware, 2 registered + +#ifndef MACINTOSH +#define DEMO_FILENAME "demos/tmpdemo.dem" +#define DEMO_DIR "demos/" +#else +#define DEMO_FILENAME ":Demos:tmpdemo.dem" +#define DEMO_DIR ":Demos:" +#endif + +#define DEMO_MAX_LEVELS 29 char nd_save_callsign[CALLSIGN_LEN+1]; @@ -923,11 +207,11 @@ fix JasonPlaybackTotal=0; FILE *infile; FILE *outfile=NULL; -int newdemo_get_percent_done() { - if ( Newdemo_state == ND_STATE_PLAYBACK ) { +int newdemo_get_percent_done() { + if ( Newdemo_state == ND_STATE_PLAYBACK ) { return (ftell(infile)*100)/Newdemo_size; } - if ( Newdemo_state == ND_STATE_RECORDING ) { + if ( Newdemo_state == ND_STATE_RECORDING ) { return ftell(outfile); } return 0; @@ -937,8 +221,8 @@ int newdemo_get_percent_done() { void my_extract_shortpos(object *objp, shortpos *spp) { - int segnum; - byte *sp; + int segnum; + byte *sp; sp = spp->bytemat; objp->orient.rvec.x = *sp++ << MATRIX_PRECISION; @@ -969,7 +253,7 @@ int newdemo_read( void *buffer, int elsize, int nelem ) { int num_read; num_read = fread( buffer,elsize,nelem, infile ); - if (ferror(infile) || feof(infile)) + if (ferror(infile) || feof(infile)) nd_bad_read = -1; return num_read; @@ -980,7 +264,7 @@ int newdemo_find_object( int signature ) int i; object * objp; objp = Objects; - for (i=0; i<=Highest_object_index; i++, objp++ ) { + for (i=0; i<=Highest_object_index; i++, objp++ ) { if ( (objp->type != OBJ_NONE) && (objp->signature == signature)) return i; } @@ -996,11 +280,11 @@ int newdemo_write( void *buffer, int elsize, int nelem ) Newdemo_num_written += total_size; Assert(outfile != NULL); num_written = fwrite( buffer, elsize, nelem, outfile ); - //if ((Newdemo_num_written > Newdemo_size) && !Newdemo_no_space) { - // Newdemo_no_space=1; - // newdemo_stop_recording(); - // return -1; - //} +// if ((Newdemo_num_written > Newdemo_size) && !Newdemo_no_space) { +// Newdemo_no_space=1; +// newdemo_stop_recording(); +// return -1; +// } if ((Newdemo_num_written > Newdemo_size) && !Newdemo_no_space) Newdemo_no_space=1; if (num_written == nelem && !Newdemo_no_space) @@ -1079,7 +363,7 @@ void nd_write_shortpos(object *obj) break; } if (i == 9) { - Int3(); // contact Allender about this. + Int3(); // contact Allender about this. } } @@ -1127,8 +411,8 @@ static void nd_read_fixang(fixang *f) static void nd_read_vector(vms_vector *v) { - nd_read_fix(&(v->x)); - nd_read_fix(&(v->y)); + nd_read_fix(&(v->x)); + nd_read_fix(&(v->y)); nd_read_fix(&(v->z)); } @@ -1165,18 +449,18 @@ static void nd_read_shortpos(object *obj) } -object *prev_obj=NULL; //ptr to last object read in - +object *prev_obj=NULL; //ptr to last object read in + void nd_read_object(object *obj) { memset(obj, 0, sizeof(object)); - /* - * Do render type first, since with render_type == RT_NONE, we - * blow by all other object information - */ +/* + * Do render type first, since with render_type == RT_NONE, we + * blow by all other object information +*/ nd_read_byte(&(obj->render_type)); - nd_read_byte(&(obj->type)); + nd_read_byte(&(obj->type)); if ((obj->render_type == RT_NONE) && (obj->type != OBJ_CAMERA)) return; @@ -1185,60 +469,60 @@ void nd_read_object(object *obj) nd_read_short((short *)&(obj->signature)); nd_read_shortpos(obj); - if ((obj->type == OBJ_ROBOT) && (obj->id == SPECIAL_REACTOR_ROBOT)) - Int3(); +if ((obj->type == OBJ_ROBOT) && (obj->id == SPECIAL_REACTOR_ROBOT)) + Int3(); - obj->attached_obj = -1; + obj->attached_obj = -1; switch(obj->type) { - case OBJ_HOSTAGE: - obj->control_type = CT_POWERUP; - obj->movement_type = MT_NONE; - obj->size = HOSTAGE_SIZE; - break; - - case OBJ_ROBOT: - obj->control_type = CT_AI; - // (MarkA and MikeK said we should not do the crazy last secret stuff with multiple reactors... - // This necessary code is our vindication. --MK, 2/15/96) - if (obj->id != SPECIAL_REACTOR_ROBOT) + case OBJ_HOSTAGE: + obj->control_type = CT_POWERUP; + obj->movement_type = MT_NONE; + obj->size = HOSTAGE_SIZE; + break; + + case OBJ_ROBOT: + obj->control_type = CT_AI; + // (MarkA and MikeK said we should not do the crazy last secret stuff with multiple reactors... + // This necessary code is our vindication. --MK, 2/15/96) + if (obj->id != SPECIAL_REACTOR_ROBOT) + obj->movement_type = MT_PHYSICS; + else + obj->movement_type = MT_NONE; + obj->size = Polygon_models[Robot_info[obj->id].model_num].rad; + obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num; + obj->rtype.pobj_info.subobj_flags = 0; + obj->ctype.ai_info.CLOAKED = (Robot_info[obj->id].cloak_type?1:0); + break; + + case OBJ_POWERUP: + obj->control_type = CT_POWERUP; + nd_read_byte(&(obj->movement_type)); // might have physics movement + obj->size = Powerup_info[obj->id].size; + break; + + case OBJ_PLAYER: + obj->control_type = CT_NONE; obj->movement_type = MT_PHYSICS; - else + obj->size = Polygon_models[Player_ship->model_num].rad; + obj->rtype.pobj_info.model_num = Player_ship->model_num; + obj->rtype.pobj_info.subobj_flags = 0; + break; + + case OBJ_CLUTTER: + obj->control_type = CT_NONE; obj->movement_type = MT_NONE; - obj->size = Polygon_models[Robot_info[obj->id].model_num].rad; - obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num; - obj->rtype.pobj_info.subobj_flags = 0; - obj->ctype.ai_info.CLOAKED = (Robot_info[obj->id].cloak_type?1:0); - break; - - case OBJ_POWERUP: - obj->control_type = CT_POWERUP; - nd_read_byte(&(obj->movement_type)); // might have physics movement - obj->size = Powerup_info[obj->id].size; - break; - - case OBJ_PLAYER: - obj->control_type = CT_NONE; - obj->movement_type = MT_PHYSICS; - obj->size = Polygon_models[Player_ship->model_num].rad; - obj->rtype.pobj_info.model_num = Player_ship->model_num; - obj->rtype.pobj_info.subobj_flags = 0; - break; - - case OBJ_CLUTTER: - obj->control_type = CT_NONE; - obj->movement_type = MT_NONE; - obj->size = Polygon_models[obj->id].rad; - obj->rtype.pobj_info.model_num = obj->id; - obj->rtype.pobj_info.subobj_flags = 0; - break; - - default: - nd_read_byte(&(obj->control_type)); - nd_read_byte(&(obj->movement_type)); - nd_read_fix(&(obj->size)); - break; + obj->size = Polygon_models[obj->id].rad; + obj->rtype.pobj_info.model_num = obj->id; + obj->rtype.pobj_info.subobj_flags = 0; + break; + + default: + nd_read_byte(&(obj->control_type)); + nd_read_byte(&(obj->movement_type)); + nd_read_fix(&(obj->size)); + break; } @@ -1247,10 +531,10 @@ void nd_read_object(object *obj) nd_read_fix(&(obj->lifeleft)); else { ubyte b; - + nd_read_byte(&b); obj->lifeleft = (fix)b; - // MWA old way -- won't work with big endian machines nd_read_byte((ubyte *)&(obj->lifeleft)); +// MWA old way -- won't work with big endian machines nd_read_byte((ubyte *)&(obj->lifeleft)); obj->lifeleft = (fix)((int)obj->lifeleft << 12); } @@ -1265,126 +549,126 @@ void nd_read_object(object *obj) switch (obj->movement_type) { - case MT_PHYSICS: - nd_read_vector(&(obj->mtype.phys_info.velocity)); - nd_read_vector(&(obj->mtype.phys_info.thrust)); - break; + case MT_PHYSICS: + nd_read_vector(&(obj->mtype.phys_info.velocity)); + nd_read_vector(&(obj->mtype.phys_info.thrust)); + break; - case MT_SPINNING: - nd_read_vector(&(obj->mtype.spin_rate)); - break; + case MT_SPINNING: + nd_read_vector(&(obj->mtype.spin_rate)); + break; - case MT_NONE: - break; + case MT_NONE: + break; - default: - Int3(); + default: + Int3(); } switch (obj->control_type) { - case CT_EXPLOSION: + case CT_EXPLOSION: - nd_read_fix(&(obj->ctype.expl_info.spawn_time)); - nd_read_fix(&(obj->ctype.expl_info.delete_time)); - nd_read_short(&(obj->ctype.expl_info.delete_objnum)); + nd_read_fix(&(obj->ctype.expl_info.spawn_time)); + nd_read_fix(&(obj->ctype.expl_info.delete_time)); + nd_read_short(&(obj->ctype.expl_info.delete_objnum)); - obj->ctype.expl_info.next_attach = obj->ctype.expl_info.prev_attach = obj->ctype.expl_info.attach_parent = -1; + obj->ctype.expl_info.next_attach = obj->ctype.expl_info.prev_attach = obj->ctype.expl_info.attach_parent = -1; - if (obj->flags & OF_ATTACHED) { //attach to previous object - Assert(prev_obj!=NULL); - if (prev_obj->control_type == CT_EXPLOSION) { - if (prev_obj->flags & OF_ATTACHED && prev_obj->ctype.expl_info.attach_parent!=-1) - obj_attach(&Objects[prev_obj->ctype.expl_info.attach_parent],obj); + if (obj->flags & OF_ATTACHED) { //attach to previous object + Assert(prev_obj!=NULL); + if (prev_obj->control_type == CT_EXPLOSION) { + if (prev_obj->flags & OF_ATTACHED && prev_obj->ctype.expl_info.attach_parent!=-1) + obj_attach(&Objects[prev_obj->ctype.expl_info.attach_parent],obj); + else + obj->flags &= ~OF_ATTACHED; + } else - obj->flags &= ~OF_ATTACHED; + obj_attach(prev_obj,obj); } - else - obj_attach(prev_obj,obj); - } - break; - - case CT_LIGHT: - nd_read_fix(&(obj->ctype.light_info.intensity)); - break; - - case CT_AI: - case CT_WEAPON: - case CT_NONE: - case CT_FLYING: - case CT_DEBRIS: - case CT_POWERUP: - case CT_SLEW: - case CT_CNTRLCEN: - case CT_REMOTE: - case CT_MORPH: - break; - - case CT_FLYTHROUGH: - case CT_REPAIRCEN: - default: - Int3(); + break; + + case CT_LIGHT: + nd_read_fix(&(obj->ctype.light_info.intensity)); + break; + + case CT_AI: + case CT_WEAPON: + case CT_NONE: + case CT_FLYING: + case CT_DEBRIS: + case CT_POWERUP: + case CT_SLEW: + case CT_CNTRLCEN: + case CT_REMOTE: + case CT_MORPH: + break; + case CT_FLYTHROUGH: + case CT_REPAIRCEN: + default: + Int3(); + } switch (obj->render_type) { - case RT_NONE: - break; + case RT_NONE: + break; - case RT_MORPH: - case RT_POLYOBJ: { - int i, tmo; + case RT_MORPH: + case RT_POLYOBJ: { + int i, tmo; - if ((obj->type != OBJ_ROBOT) && (obj->type != OBJ_PLAYER) && (obj->type != OBJ_CLUTTER)) { - nd_read_int(&(obj->rtype.pobj_info.model_num)); - nd_read_int(&(obj->rtype.pobj_info.subobj_flags)); - } + if ((obj->type != OBJ_ROBOT) && (obj->type != OBJ_PLAYER) && (obj->type != OBJ_CLUTTER)) { + nd_read_int(&(obj->rtype.pobj_info.model_num)); + nd_read_int(&(obj->rtype.pobj_info.subobj_flags)); + } - if ((obj->type != OBJ_PLAYER) && (obj->type != OBJ_DEBRIS)) + if ((obj->type != OBJ_PLAYER) && (obj->type != OBJ_DEBRIS)) #if 0 - for (i=0;ipobj_info.anim_angles[i])); + for (i=0;ipobj_info.anim_angles[i])); #endif - for (i = 0; i < Polygon_models[obj->rtype.pobj_info.model_num].n_models; i++) - nd_read_angvec(&obj->rtype.pobj_info.anim_angles[i]); + for (i = 0; i < Polygon_models[obj->rtype.pobj_info.model_num].n_models; i++) + nd_read_angvec(&obj->rtype.pobj_info.anim_angles[i]); - nd_read_int(&tmo); + nd_read_int(&tmo); -#ifndef EDITOR - obj->rtype.pobj_info.tmap_override = tmo; -#else - if (tmo==-1) - obj->rtype.pobj_info.tmap_override = -1; - else { - int xlated_tmo = tmap_xlate_table[tmo]; - if (xlated_tmo < 0) { - //mprintf( (0, "Couldn't find texture for demo object, model_num = %d\n", obj->pobj_info.model_num)); - Int3(); - xlated_tmo = 0; + #ifndef EDITOR + obj->rtype.pobj_info.tmap_override = tmo; + #else + if (tmo==-1) + obj->rtype.pobj_info.tmap_override = -1; + else { + int xlated_tmo = tmap_xlate_table[tmo]; + if (xlated_tmo < 0) { +// mprintf( (0, "Couldn't find texture for demo object, model_num = %d\n", obj->pobj_info.model_num)); + Int3(); + xlated_tmo = 0; + } + obj->rtype.pobj_info.tmap_override = xlated_tmo; } - obj->rtype.pobj_info.tmap_override = xlated_tmo; - } -#endif + #endif - break; - } + break; + } - case RT_POWERUP: - case RT_WEAPON_VCLIP: - case RT_FIREBALL: - case RT_HOSTAGE: - nd_read_int(&(obj->rtype.vclip_info.vclip_num)); - nd_read_fix(&(obj->rtype.vclip_info.frametime)); - nd_read_byte(&(obj->rtype.vclip_info.framenum)); - break; + case RT_POWERUP: + case RT_WEAPON_VCLIP: + case RT_FIREBALL: + case RT_HOSTAGE: + nd_read_int(&(obj->rtype.vclip_info.vclip_num)); + nd_read_fix(&(obj->rtype.vclip_info.frametime)); + nd_read_byte(&(obj->rtype.vclip_info.framenum)); + break; - case RT_LASER: - break; + case RT_LASER: + break; - default: - Int3(); + default: + Int3(); } @@ -1395,13 +679,13 @@ void nd_write_object(object *obj) { int life; - if ((obj->type == OBJ_ROBOT) && (obj->id == SPECIAL_REACTOR_ROBOT)) - Int3(); +if ((obj->type == OBJ_ROBOT) && (obj->id == SPECIAL_REACTOR_ROBOT)) + Int3(); - /* - * Do render_type first so on read, we can make determination of - * what else to read in - */ +/* + * Do render_type first so on read, we can make determination of + * what else to read in +*/ nd_write_byte(obj->render_type); nd_write_byte(obj->type); if ((obj->render_type == RT_NONE) && (obj->type != OBJ_CAMERA)) @@ -1443,99 +727,99 @@ void nd_write_object(object *obj) switch (obj->movement_type) { - case MT_PHYSICS: - nd_write_vector(&obj->mtype.phys_info.velocity); - nd_write_vector(&obj->mtype.phys_info.thrust); - break; + case MT_PHYSICS: + nd_write_vector(&obj->mtype.phys_info.velocity); + nd_write_vector(&obj->mtype.phys_info.thrust); + break; - case MT_SPINNING: - nd_write_vector(&obj->mtype.spin_rate); - break; + case MT_SPINNING: + nd_write_vector(&obj->mtype.spin_rate); + break; - case MT_NONE: - break; + case MT_NONE: + break; - default: - Int3(); + default: + Int3(); } switch (obj->control_type) { - case CT_AI: - break; - - case CT_EXPLOSION: - nd_write_fix(obj->ctype.expl_info.spawn_time); - nd_write_fix(obj->ctype.expl_info.delete_time); - nd_write_short(obj->ctype.expl_info.delete_objnum); - break; + case CT_AI: + break; - case CT_WEAPON: - break; + case CT_EXPLOSION: + nd_write_fix(obj->ctype.expl_info.spawn_time); + nd_write_fix(obj->ctype.expl_info.delete_time); + nd_write_short(obj->ctype.expl_info.delete_objnum); + break; - case CT_LIGHT: + case CT_WEAPON: + break; - nd_write_fix(obj->ctype.light_info.intensity); - break; + case CT_LIGHT: - case CT_NONE: - case CT_FLYING: - case CT_DEBRIS: - case CT_POWERUP: - case CT_SLEW: //the player is generally saved as slew - case CT_CNTRLCEN: - case CT_REMOTE: - case CT_MORPH: - break; + nd_write_fix(obj->ctype.light_info.intensity); + break; - case CT_REPAIRCEN: - case CT_FLYTHROUGH: - default: - Int3(); + case CT_NONE: + case CT_FLYING: + case CT_DEBRIS: + case CT_POWERUP: + case CT_SLEW: //the player is generally saved as slew + case CT_CNTRLCEN: + case CT_REMOTE: + case CT_MORPH: + break; + case CT_REPAIRCEN: + case CT_FLYTHROUGH: + default: + Int3(); + } switch (obj->render_type) { - case RT_NONE: - break; + case RT_NONE: + break; - case RT_MORPH: - case RT_POLYOBJ: { - int i; + case RT_MORPH: + case RT_POLYOBJ: { + int i; - if ((obj->type != OBJ_ROBOT) && (obj->type != OBJ_PLAYER) && (obj->type != OBJ_CLUTTER)) { - nd_write_int(obj->rtype.pobj_info.model_num); - nd_write_int(obj->rtype.pobj_info.subobj_flags); - } + if ((obj->type != OBJ_ROBOT) && (obj->type != OBJ_PLAYER) && (obj->type != OBJ_CLUTTER)) { + nd_write_int(obj->rtype.pobj_info.model_num); + nd_write_int(obj->rtype.pobj_info.subobj_flags); + } - if ((obj->type != OBJ_PLAYER) && (obj->type != OBJ_DEBRIS)) + if ((obj->type != OBJ_PLAYER) && (obj->type != OBJ_DEBRIS)) #if 0 - for (i=0;ipobj_info.anim_angles[i]); + for (i=0;ipobj_info.anim_angles[i]); #endif - for (i = 0; i < Polygon_models[obj->rtype.pobj_info.model_num].n_models; i++) - nd_write_angvec(&obj->rtype.pobj_info.anim_angles[i]); + for (i = 0; i < Polygon_models[obj->rtype.pobj_info.model_num].n_models; i++) + nd_write_angvec(&obj->rtype.pobj_info.anim_angles[i]); - nd_write_int(obj->rtype.pobj_info.tmap_override); + nd_write_int(obj->rtype.pobj_info.tmap_override); - break; - } + break; + } - case RT_POWERUP: - case RT_WEAPON_VCLIP: - case RT_FIREBALL: - case RT_HOSTAGE: - nd_write_int(obj->rtype.vclip_info.vclip_num); - nd_write_fix(obj->rtype.vclip_info.frametime); - nd_write_byte(obj->rtype.vclip_info.framenum); - break; + case RT_POWERUP: + case RT_WEAPON_VCLIP: + case RT_FIREBALL: + case RT_HOSTAGE: + nd_write_int(obj->rtype.vclip_info.vclip_num); + nd_write_fix(obj->rtype.vclip_info.frametime); + nd_write_byte(obj->rtype.vclip_info.framenum); + break; - case RT_LASER: - break; + case RT_LASER: + break; - default: - Int3(); + default: + Int3(); } @@ -1552,7 +836,7 @@ void newdemo_record_start_demo() nd_write_byte(DEMO_VERSION); nd_write_byte(DEMO_GAME_TYPE); nd_write_fix(GameTime); - + #ifdef NETWORK if (Game_mode & GM_MULTI) nd_write_int(Game_mode | (Player_num << 16)); @@ -1600,12 +884,12 @@ void newdemo_record_start_demo() nd_write_byte((byte)(f2ir(Players[Player_num].energy))); nd_write_byte((byte)(f2ir(Players[Player_num].shields))); - nd_write_int(Players[Player_num].flags); // be sure players flags are set + nd_write_int(Players[Player_num].flags); // be sure players flags are set nd_write_byte((byte)Primary_weapon); nd_write_byte((byte)Secondary_weapon); Newdemo_start_frame = FrameCount; - JustStartedRecording=1; - + JustStartedRecording=1; + newdemo_set_new_level(Current_level_num); start_time(); @@ -1613,29 +897,30 @@ void newdemo_record_start_demo() void newdemo_record_start_frame(int frame_number, fix frame_time ) { - int i; - + int i; + if (Newdemo_no_space) { newdemo_stop_playback(); return; } - + + stop_time(); - for (i=0;i= 0 ); nd_write_byte(ND_EVENT_START_FRAME); - nd_write_short(frame_bytes_written - 1); // from previous frame + nd_write_short(frame_bytes_written - 1); // from previous frame frame_bytes_written=3; nd_write_int(frame_number); nd_write_int(frame_time); @@ -1645,12 +930,12 @@ void newdemo_record_start_frame(int frame_number, fix frame_time ) void newdemo_record_render_object(object * obj) { - if (ViewWasRecorded[obj-Objects]) - return; - - //if (obj==&Objects[Players[Player_num].objnum] && !Player_is_dead) - // return; + if (ViewWasRecorded[obj-Objects]) + return; + // if (obj==&Objects[Players[Player_num].objnum] && !Player_is_dead) + // return; + stop_time(); nd_write_byte(ND_EVENT_RENDER_OBJECT); nd_write_object(obj); @@ -1662,49 +947,46 @@ extern ubyte RenderingType; void newdemo_record_viewer_object(object * obj) { - if (ViewWasRecorded[obj-Objects] && (ViewWasRecorded[obj-Objects]-1)==RenderingType) + if (ViewWasRecorded[obj-Objects] && (ViewWasRecorded[obj-Objects]-1)==RenderingType) return; //if (WasRecorded[obj-Objects]) - // return; + // return; if (RenderingWasRecorded[RenderingType]) return; - - ViewWasRecorded[obj-Objects]=RenderingType+1; + + ViewWasRecorded[obj-Objects]=RenderingType+1; RenderingWasRecorded[RenderingType]=1; stop_time(); nd_write_byte(ND_EVENT_VIEWER_OBJECT); - nd_write_byte(RenderingType); + nd_write_byte(RenderingType); nd_write_object(obj); start_time(); } -void newdemo_record_sound( int soundno ) -{ +void newdemo_record_sound( int soundno ) { stop_time(); nd_write_byte(ND_EVENT_SOUND); nd_write_int( soundno ); start_time(); } - -//--unused-- void newdemo_record_sound_once( int soundno ) { +//--unused-- void newdemo_record_sound_once( int soundno ) { //--unused-- stop_time(); //--unused-- nd_write_byte( ND_EVENT_SOUND_ONCE ); //--unused-- nd_write_int( soundno ); //--unused-- start_time(); //--unused-- } -//--unused-- +//--unused-- void newdemo_record_cockpit_change (int mode) -{ - stop_time(); - nd_write_byte (ND_EVENT_CHANGE_COCKPIT); - nd_write_int(mode); - start_time(); -} + { + stop_time(); + nd_write_byte (ND_EVENT_CHANGE_COCKPIT); + nd_write_int(mode); + start_time(); + } -void newdemo_record_sound_3d( int soundno, int angle, int volume ) -{ +void newdemo_record_sound_3d( int soundno, int angle, int volume ) { stop_time(); nd_write_byte( ND_EVENT_SOUND_3D ); nd_write_int( soundno ); @@ -1713,8 +995,7 @@ void newdemo_record_sound_3d( int soundno, int angle, int volume ) start_time(); } -void newdemo_record_sound_3d_once( int soundno, int angle, int volume ) -{ +void newdemo_record_sound_3d_once( int soundno, int angle, int volume ) { stop_time(); nd_write_byte( ND_EVENT_SOUND_3D_ONCE ); nd_write_int( soundno ); @@ -1749,10 +1030,10 @@ void newdemo_record_kill_sound_linked_to_object( int objnum ) void newdemo_record_wall_hit_process( int segnum, int side, int damage, int playernum ) { stop_time(); - //segnum = segnum; - //side = side; - //damage = damage; - //playernum = playernum; +// segnum = segnum; +// side = side; +// damage = damage; +// playernum = playernum; nd_write_byte( ND_EVENT_WALL_HIT_PROCESS ); nd_write_int( segnum ); nd_write_int( side ); @@ -1762,14 +1043,13 @@ void newdemo_record_wall_hit_process( int segnum, int side, int damage, int play } void newdemo_record_guided_start () -{ - nd_write_byte (ND_EVENT_START_GUIDED); -} - + { + nd_write_byte (ND_EVENT_START_GUIDED); + } void newdemo_record_guided_end () -{ - nd_write_byte (ND_EVENT_END_GUIDED); -} + { + nd_write_byte (ND_EVENT_END_GUIDED); + } void newdemo_record_secret_exit_blown(int truth) { @@ -1790,15 +1070,14 @@ void newdemo_record_trigger( int segnum, int side, int objnum,int shot ) start_time(); } -void newdemo_record_hostage_rescued( int hostage_number ) { +void newdemo_record_hostage_rescued( int hostage_number ) { stop_time(); nd_write_byte( ND_EVENT_HOSTAGE_RESCUED ); nd_write_int( hostage_number ); start_time(); } -void newdemo_record_morph_frame(morph_data *md) -{ +void newdemo_record_morph_frame(morph_data *md) { stop_time(); nd_write_byte( ND_EVENT_MORPH_FRAME ); @@ -1811,8 +1090,7 @@ void newdemo_record_morph_frame(morph_data *md) start_time(); } -void newdemo_record_wall_toggle( int segnum, int side ) -{ +void newdemo_record_wall_toggle( int segnum, int side ) { stop_time(); nd_write_byte( ND_EVENT_WALL_TOGGLE ); nd_write_int( segnum ); @@ -2041,7 +1319,7 @@ void newdemo_record_multi_score(int pnum, int score) stop_time(); nd_write_byte(ND_EVENT_MULTI_SCORE); nd_write_byte((byte)pnum); - nd_write_int(score - Players[pnum].score); // called before score is changed!!!! + nd_write_int(score - Players[pnum].score); // called before score is changed!!!! start_time(); } @@ -2098,7 +1376,7 @@ void newdemo_record_cloaking_wall(int front_wall_num, int back_wall_num, ubyte t nd_write_byte(type); nd_write_byte(state); nd_write_byte(cloak_value); - nd_write_short(l0>>8); + nd_write_short(l0>>8); nd_write_short(l1>>8); nd_write_short(l2>>8); nd_write_short(l3>>8); @@ -2115,24 +1393,24 @@ void newdemo_set_new_level(int level_num) nd_write_byte(ND_EVENT_NEW_LEVEL); nd_write_byte((byte)level_num); nd_write_byte((byte)Current_level_num); - - if (JustStartedRecording==1) - { - nd_write_int(Num_walls); + + if (JustStartedRecording==1) + { + nd_write_int(Num_walls); for (i=0;isides[side].tmap_num); - nd_write_short (seg->sides[side].tmap_num2); - JustStartedRecording=0; - } - } - + { + nd_write_byte (Walls[i].type); + nd_write_byte (Walls[i].flags); + nd_write_byte (Walls[i].state); + + seg = &Segments[Walls[i].segnum]; + side = Walls[i].sidenum; + nd_write_short (seg->sides[side].tmap_num); + nd_write_short (seg->sides[side].tmap_num2); + JustStartedRecording=0; + } + } + start_time(); } @@ -2159,7 +1437,7 @@ int newdemo_read_demo_start(int rnd_demo) sprintf(text, "%s %s", TXT_CANT_PLAYBACK, TXT_RECORDED); m[ 0].type = NM_TYPE_TEXT; m[ 0].text = text; m[ 1].type = NM_TYPE_TEXT; m[ 1].text = " In Descent: First Strike"; - + newmenu_do( NULL, NULL, sizeof(m)/sizeof(*m), m, NULL ); return 1; } @@ -2169,7 +1447,7 @@ int newdemo_read_demo_start(int rnd_demo) sprintf(text, "%s %s", TXT_CANT_PLAYBACK, TXT_RECORDED); m[ 0].type = NM_TYPE_TEXT; m[ 0].text = text; m[ 1].type = NM_TYPE_TEXT; m[ 1].text = " In Unknown Descent version"; - + newmenu_do( NULL, NULL, sizeof(m)/sizeof(*m), m, NULL ); return 1; } @@ -2183,9 +1461,9 @@ int newdemo_read_demo_start(int rnd_demo) return 1; } nd_read_fix(&GameTime); - Boss_cloak_start_time=Boss_cloak_end_time=GameTime; + Boss_cloak_start_time=Boss_cloak_end_time=GameTime; JasonPlaybackTotal=0; - + nd_read_int(&Newdemo_game_mode); #ifdef NETWORK @@ -2200,9 +1478,9 @@ int newdemo_read_demo_start(int rnd_demo) multi_new_game(); nd_read_byte(&c); N_players = (int)c; - // changed this to above two lines -- breaks on the mac because of - // endian issues - // nd_read_byte((byte *)&N_players); +// changed this to above two lines -- breaks on the mac because of +// endian issues +// nd_read_byte((byte *)&N_players); for (i = 0 ; i < N_players; i++) { Players[i].cloak_time = 0; Players[i].invulnerable_time = 0; @@ -2221,7 +1499,7 @@ int newdemo_read_demo_start(int rnd_demo) Game_mode = GM_NORMAL; } else #endif - nd_read_int(&(Players[Player_num].score)); // Note link to above if! + nd_read_int(&(Players[Player_num].score)); // Note link to above if! for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) nd_read_short((short*)&(Players[Player_num].primary_ammo[i])); @@ -2235,7 +1513,7 @@ int newdemo_read_demo_start(int rnd_demo) update_laser_weapon_info(); } - // Support for missions +// Support for missions nd_read_string(current_mission); if (!load_mission_by_name(current_mission)) { @@ -2265,9 +1543,9 @@ int newdemo_read_demo_start(int rnd_demo) nd_read_byte((byte *)&Primary_weapon); nd_read_byte((byte *)&Secondary_weapon); - // Next bit of code to fix problem that I introduced between 1.0 and 1.1 - // check the next byte -- it _will_ be a load_new_level event. If it is - // not, then we must shift all bytes up by one. +// Next bit of code to fix problem that I introduced between 1.0 and 1.1 +// check the next byte -- it _will_ be a load_new_level event. If it is +// not, then we must shift all bytes up by one. Players[Player_num].energy = i2f(energy); Players[Player_num].shields = i2f(shield); @@ -2281,14 +1559,14 @@ void newdemo_pop_ctrlcen_triggers() int side, cside; segment *seg, *csegp; - for (i = 0; i < ControlCenterTriggers.num_links; i++) { + for (i = 0; i < ControlCenterTriggers.num_links; i++) { seg = &Segments[ControlCenterTriggers.seg[i]]; side = ControlCenterTriggers.side[i]; csegp = &Segments[seg->children[side]]; cside = find_connect_side(seg, csegp); anim_num = Walls[seg->sides[side].wall_num].clip_num; n = WallAnims[anim_num].num_frames; - if (WallAnims[anim_num].flags & WCF_TMAP1) { + if (WallAnims[anim_num].flags & WCF_TMAP1) { seg->sides[side].tmap_num = csegp->sides[cside].tmap_num = WallAnims[anim_num].frames[n-1]; } else { seg->sides[side].tmap_num2 = csegp->sides[cside].tmap_num2 = WallAnims[anim_num].frames[n-1]; @@ -2309,9 +1587,9 @@ int newdemo_read_frame_information() ubyte c,WhichWindow; static byte saved_letter_cockpit; static byte saved_rearview_cockpit; - object extraobj; - static char LastReadValue=101; - segment *seg; + object extraobj; + static char LastReadValue=101; + segment *seg; done = 0; @@ -2324,13 +1602,13 @@ int newdemo_read_frame_information() prev_obj = NULL; - while( !done ) { + while( !done ) { nd_read_byte(&c); if (nd_bad_read) { done = -1; break; } - switch( c ) { + switch( c ) { - case ND_EVENT_START_FRAME: { // Followed by an integer frame number, then a fix FrameTime + case ND_EVENT_START_FRAME: { // Followed by an integer frame number, then a fix FrameTime short last_frame_length; done=1; @@ -2340,48 +1618,48 @@ int newdemo_read_frame_information() if (Newdemo_vcr_state == ND_STATE_PLAYBACK) nd_recorded_total += nd_recorded_time; NewdemoFrameCount--; - + if (nd_bad_read) { done = -1; break; } break; } - case ND_EVENT_VIEWER_OBJECT: // Followed by an object structure - nd_read_byte (&WhichWindow); - if (WhichWindow&15) - { - //mprintf ((0,"Reading extra!\n")); - nd_read_object (&extraobj); - if (Newdemo_vcr_state!=ND_STATE_PAUSED) - { + case ND_EVENT_VIEWER_OBJECT: // Followed by an object structure + nd_read_byte (&WhichWindow); + if (WhichWindow&15) + { +// mprintf ((0,"Reading extra!\n")); + nd_read_object (&extraobj); + if (Newdemo_vcr_state!=ND_STATE_PAUSED) + { if (nd_bad_read) { done = -1; break; } - - nd_render_extras (WhichWindow,&extraobj); - } - } + + nd_render_extras (WhichWindow,&extraobj); + } + } else - { - //mprintf ((0,"Reading viewer!\n")); + { + // mprintf ((0,"Reading viewer!\n")); //Viewer=&Objects[0]; - nd_read_object(Viewer); + nd_read_object(Viewer); if (Newdemo_vcr_state != ND_STATE_PAUSED) { if (nd_bad_read) { done = -1; break; } segnum = Viewer->segnum; Viewer->next = Viewer->prev = Viewer->segnum = -1; - // HACK HACK HACK -- since we have multiple level recording, it can be the case - // HACK HACK HACK -- that when rewinding the demo, the viewer is in a segment - // HACK HACK HACK -- that is greater than the highest index of segments. Bash - // HACK HACK HACK -- the viewer to segment 0 for bogus view. +// HACK HACK HACK -- since we have multiple level recording, it can be the case +// HACK HACK HACK -- that when rewinding the demo, the viewer is in a segment +// HACK HACK HACK -- that is greater than the highest index of segments. Bash +// HACK HACK HACK -- the viewer to segment 0 for bogus view. if (segnum > Highest_segment_index) segnum = 0; obj_link(Viewer-Objects,segnum); } - } + } break; - case ND_EVENT_RENDER_OBJECT: // Followed by an object structure + case ND_EVENT_RENDER_OBJECT: // Followed by an object structure objnum = obj_allocate(); if (objnum==-1) break; @@ -2392,8 +1670,8 @@ int newdemo_read_frame_information() segnum = obj->segnum; obj->next = obj->prev = obj->segnum = -1; - // HACK HACK HACK -- don't render objects is segments greater than Highest_segment_index - // HACK HACK HACK -- (see above) +// HACK HACK HACK -- don't render objects is segments greater than Highest_segment_index +// HACK HACK HACK -- (see above) if (segnum > Highest_segment_index) break; @@ -2429,12 +1707,12 @@ int newdemo_read_frame_information() digi_play_sample( soundno, F1_0 ); break; - //--unused case ND_EVENT_SOUND_ONCE: - //--unused nd_read_int(&soundno); - //--unused if (nd_bad_read) { done = -1; break; } - //--unused if (Newdemo_vcr_state == ND_STATE_PLAYBACK) - //--unused digi_play_sample_once( soundno, F1_0 ); - //--unused break; +//--unused case ND_EVENT_SOUND_ONCE: +//--unused nd_read_int(&soundno); +//--unused if (nd_bad_read) { done = -1; break; } +//--unused if (Newdemo_vcr_state == ND_STATE_PLAYBACK) +//--unused digi_play_sample_once( soundno, F1_0 ); +//--unused break; case ND_EVENT_SOUND_3D: nd_read_int(&soundno); @@ -2465,7 +1743,7 @@ int newdemo_read_frame_information() nd_read_int( &loop_start ); nd_read_int( &loop_end ); objnum = newdemo_find_object( signature ); - if ( objnum > -1 ) { // @mk, 2/22/96, John told me to. + if ( objnum > -1 ) { // @mk, 2/22/96, John told me to. digi_link_sound_to_object3( soundno, objnum, 1, max_volume, max_distance, loop_start, loop_end ); } } @@ -2476,7 +1754,7 @@ int newdemo_read_frame_information() int objnum, signature; nd_read_int( &signature ); objnum = newdemo_find_object( signature ); - if ( objnum > -1 ) { // @mk, 2/22/96, John told me to. + if ( objnum > -1 ) { // @mk, 2/22/96, John told me to. digi_kill_sound_linked_to_object(objnum); } } @@ -2507,7 +1785,7 @@ int newdemo_read_frame_information() mprintf ((0,"EVENT TRIGGER! shot=%d\n",shot)); if (Triggers[Walls[Segments[segnum].sides[side].wall_num].trigger].type == TT_SECRET_EXIT) { - int truth; + int truth; nd_read_byte(&c); Assert(c == ND_EVENT_SECRET_THINGY); @@ -2570,7 +1848,7 @@ int newdemo_read_frame_information() if (!Newdemo_cntrlcen_destroyed) { newdemo_pop_ctrlcen_triggers(); Newdemo_cntrlcen_destroyed = 1; - //do_controlcen_destroyed_stuff(NULL); +// do_controlcen_destroyed_stuff(NULL); } break; @@ -2582,14 +1860,14 @@ int newdemo_read_frame_information() HUD_init_message( hud_msg ); break; } - case ND_EVENT_START_GUIDED: + case ND_EVENT_START_GUIDED: Newdemo_flying_guided=1; - if ((Newdemo_vcr_state == ND_STATE_REWINDING) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEBACKWARD)) + if ((Newdemo_vcr_state == ND_STATE_REWINDING) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEBACKWARD)) Newdemo_flying_guided=0; break; - case ND_EVENT_END_GUIDED: + case ND_EVENT_END_GUIDED: Newdemo_flying_guided=0; - if ((Newdemo_vcr_state == ND_STATE_REWINDING) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEBACKWARD)) + if ((Newdemo_vcr_state == ND_STATE_REWINDING) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEBACKWARD)) Newdemo_flying_guided=1; break; @@ -2689,7 +1967,7 @@ int newdemo_read_frame_information() if ((oflags & PLAYER_FLAGS_INVULNERABLE) && !(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE)) Players[Player_num].invulnerable_time = 0; } - update_laser_weapon_info(); // in case of quad laser change + update_laser_weapon_info(); // in case of quad laser change break; } @@ -2720,7 +1998,7 @@ int newdemo_read_frame_information() vms_vector pnt; object dummy; - //create a dummy object which will be the weapon that hits + //create a dummy object which will be the weapon that hits //the monitor. the blowup code wants to know who the parent of the //laser is, so create a laser whose parent is the player dummy.ctype.laser_info.parent_type = OBJ_PLAYER; @@ -2749,14 +2027,15 @@ int newdemo_read_frame_information() select_cockpit(saved_letter_cockpit); break; - case ND_EVENT_CHANGE_COCKPIT: { + case ND_EVENT_CHANGE_COCKPIT: + { int dummy; - nd_read_int (&dummy); + nd_read_int (&dummy); select_cockpit (dummy); - break; - } + break; + } case ND_EVENT_REARVIEW: if ((Newdemo_vcr_state == ND_STATE_PLAYBACK) || (Newdemo_vcr_state == ND_STATE_FASTFORWARD) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEFORWARD)) { saved_rearview_cockpit = Cockpit_mode; @@ -2764,7 +2043,7 @@ int newdemo_read_frame_information() select_cockpit(CM_REAR_VIEW); Rear_view=1; } else if ((Newdemo_vcr_state == ND_STATE_REWINDING) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEBACKWARD)) { - if (saved_rearview_cockpit == CM_REAR_VIEW) // hack to be sure we get a good cockpit on restore + if (saved_rearview_cockpit == CM_REAR_VIEW) // hack to be sure we get a good cockpit on restore saved_rearview_cockpit = CM_FULL_COCKPIT; select_cockpit(saved_rearview_cockpit); Rear_view=0; @@ -2787,7 +2066,7 @@ int newdemo_read_frame_information() select_cockpit(CM_REAR_VIEW); Rear_view=1; } else if ((Newdemo_vcr_state == ND_STATE_PLAYBACK) || (Newdemo_vcr_state == ND_STATE_FASTFORWARD) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEFORWARD)) { - if (saved_rearview_cockpit == CM_REAR_VIEW) // hack to be sure we get a good cockpit on restore + if (saved_rearview_cockpit == CM_REAR_VIEW) // hack to be sure we get a good cockpit on restore saved_rearview_cockpit = CM_FULL_COCKPIT; select_cockpit(saved_rearview_cockpit); Rear_view=0; @@ -2795,7 +2074,7 @@ int newdemo_read_frame_information() break; - case ND_EVENT_WALL_SET_TMAP_NUM1: { + case ND_EVENT_WALL_SET_TMAP_NUM1: { short seg, cseg, tmap; ubyte side,cside; @@ -2809,7 +2088,7 @@ int newdemo_read_frame_information() break; } - case ND_EVENT_WALL_SET_TMAP_NUM2: { + case ND_EVENT_WALL_SET_TMAP_NUM2: { short seg, cseg, tmap; ubyte side,cside; @@ -2877,19 +2156,19 @@ int newdemo_read_frame_information() nd_read_byte(&kill); if ((Newdemo_vcr_state == ND_STATE_REWINDING) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEBACKWARD)) { Players[pnum].net_kills_total -= kill; - if (Newdemo_game_mode & GM_TEAM) - team_kills[get_team(pnum)] -= kill; - } else if ((Newdemo_vcr_state == ND_STATE_PLAYBACK) || (Newdemo_vcr_state == ND_STATE_FASTFORWARD) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEFORWARD)) { + if (Newdemo_game_mode & GM_TEAM) + team_kills[get_team(pnum)] -= kill; + } else if ((Newdemo_vcr_state == ND_STATE_PLAYBACK) || (Newdemo_vcr_state == ND_STATE_FASTFORWARD) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEFORWARD)) { Players[pnum].net_kills_total += kill; - if (Newdemo_game_mode & GM_TEAM) - team_kills[get_team(pnum)] += kill; + if (Newdemo_game_mode & GM_TEAM) + team_kills[get_team(pnum)] += kill; } Game_mode = Newdemo_game_mode; multi_sort_kill_list(); Game_mode = GM_NORMAL; break; } - + case ND_EVENT_MULTI_CONNECT: { byte pnum, new_player; int killed_total, kills_total; @@ -3016,9 +2295,9 @@ int newdemo_read_frame_information() cside = find_connect_side(segp, csegp); anim_num = Walls[segp->sides[side].wall_num].clip_num; - if (WallAnims[anim_num].flags & WCF_TMAP1) { + if (WallAnims[anim_num].flags & WCF_TMAP1) { segp->sides[side].tmap_num = csegp->sides[cside].tmap_num = WallAnims[anim_num].frames[0]; - } else { + } else { segp->sides[side].tmap_num2 = csegp->sides[cside].tmap_num2 = WallAnims[anim_num].frames[0]; } } @@ -3079,9 +2358,9 @@ int newdemo_read_frame_information() break; } - case ND_EVENT_NEW_LEVEL: { + case ND_EVENT_NEW_LEVEL: { byte new_level, old_level, loaded_level; - + nd_read_byte (&new_level); nd_read_byte (&old_level); if (Newdemo_vcr_state == ND_STATE_PAUSED) @@ -3111,53 +2390,53 @@ int newdemo_read_frame_information() Newdemo_cntrlcen_destroyed = 0; if (JustStartedPlayback) - { + { nd_read_int (&Num_walls); for (i=0;isides[side].tmap_num); - nd_read_short (&seg->sides[side].tmap_num2); - } + { + nd_read_byte (&Walls[i].type); + nd_read_byte (&Walls[i].flags); + nd_read_byte (&Walls[i].state); + + seg = &Segments[Walls[i].segnum]; + side = Walls[i].sidenum; + nd_read_short (&seg->sides[side].tmap_num); + nd_read_short (&seg->sides[side].tmap_num2); + } #ifdef NETWORK - if (Newdemo_game_mode & GM_CAPTURE) - multi_apply_goal_textures (); + if (Newdemo_game_mode & GM_CAPTURE) + multi_apply_goal_textures (); #endif - JustStartedPlayback=0; - } - - - // so says Rob H.!!! if (Newdemo_game_mode & GM_MULTI) { - // so says Rob H.!!! for (i = 0; i < Num_walls; i++) { - // so says Rob H.!!! if (Walls[i].type == WALL_BLASTABLE) - // so says Rob H.!!! { - // so says Rob H.!!! int a, n; - // so says Rob H.!!! int side; - // so says Rob H.!!! segment *seg; - // so says Rob H.!!! - // so says Rob H.!!! seg = &Segments[Walls[i].segnum]; - // so says Rob H.!!! side = Walls[i].sidenum; - // so says Rob H.!!! a = Walls[i].clip_num; - // so says Rob H.!!! n = WallAnims[a].num_frames; - // so says Rob H.!!! seg->sides[side].tmap_num = WallAnims[a].frames[n-1]; - // so says Rob H.!!! Walls[i].flags |= WALL_BLASTED; - // so says Rob H.!!! } - // so says Rob H.!!! } - // so says Rob H.!!! } - - reset_palette_add(); // get palette back to normal + JustStartedPlayback=0; + } + + +// so says Rob H.!!! if (Newdemo_game_mode & GM_MULTI) { +// so says Rob H.!!! for (i = 0; i < Num_walls; i++) { +// so says Rob H.!!! if (Walls[i].type == WALL_BLASTABLE) +// so says Rob H.!!! { +// so says Rob H.!!! int a, n; +// so says Rob H.!!! int side; +// so says Rob H.!!! segment *seg; +// so says Rob H.!!! +// so says Rob H.!!! seg = &Segments[Walls[i].segnum]; +// so says Rob H.!!! side = Walls[i].sidenum; +// so says Rob H.!!! a = Walls[i].clip_num; +// so says Rob H.!!! n = WallAnims[a].num_frames; +// so says Rob H.!!! seg->sides[side].tmap_num = WallAnims[a].frames[n-1]; +// so says Rob H.!!! Walls[i].flags |= WALL_BLASTED; +// so says Rob H.!!! } +// so says Rob H.!!! } +// so says Rob H.!!! } + + reset_palette_add(); // get palette back to normal start_time(); break; } case ND_EVENT_EOF: { done=-1; - fseek(infile, -1, SEEK_CUR); // get back to the EOF marker + fseek(infile, -1, SEEK_CUR); // get back to the EOF marker Newdemo_at_eof = 1; NewdemoFrameCount++; break; @@ -3167,9 +2446,9 @@ int newdemo_read_frame_information() Int3(); } } - - LastReadValue=c; - + + LastReadValue=c; + if (nd_bad_read) { newmenu_item m[2]; @@ -3183,8 +2462,8 @@ int newdemo_read_frame_information() void newdemo_goto_beginning() { - //if (NewdemoFrameCount == 0) - // return; +// if (NewdemoFrameCount == 0) +// return; fseek(infile, 0, SEEK_SET); Newdemo_vcr_state = ND_STATE_PLAYBACK; if (newdemo_read_demo_start(0)) @@ -3233,7 +2512,7 @@ void newdemo_goto_end() nd_read_byte(&bbyte); nd_read_short(&bshort); nd_read_int(&bint); - + nd_read_byte(&energy); nd_read_byte(&shield); Players[Player_num].energy = i2f(energy); @@ -3248,9 +2527,9 @@ void newdemo_goto_end() nd_read_byte((byte *)&Primary_weapon); nd_read_byte((byte *)&Secondary_weapon); for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) - nd_read_short((short *)&(Players[Player_num].primary_ammo[i])); + nd_read_short((short *)&(Players[Player_num].primary_ammo[i])); for (i = 0; i < MAX_SECONDARY_WEAPONS; i++) - nd_read_short((short *)&(Players[Player_num].secondary_ammo[i])); + nd_read_short((short *)&(Players[Player_num].secondary_ammo[i])); nd_read_byte(&laser_level); if (laser_level != Players[Player_num].laser_level) { Players[Player_num].laser_level = laser_level; @@ -3260,9 +2539,9 @@ void newdemo_goto_end() if (Newdemo_game_mode & GM_MULTI) { nd_read_byte(&c); N_players = (int)c; - // see newdemo_read_start_demo for explanation of - // why this is commented out - // nd_read_byte((byte *)&N_players); +// see newdemo_read_start_demo for explanation of +// why this is commented out +// nd_read_byte((byte *)&N_players); for (i = 0; i < N_players; i++) { nd_read_string(Players[i].callsign); nd_read_byte(&(Players[i].connected)); @@ -3279,11 +2558,11 @@ void newdemo_goto_end() fseek(infile, loc, SEEK_SET); fseek(infile, -frame_length, SEEK_CUR); - nd_read_int(&NewdemoFrameCount); // get the frame count + nd_read_int(&NewdemoFrameCount); // get the frame count NewdemoFrameCount--; fseek(infile, 4, SEEK_CUR); Newdemo_vcr_state = ND_STATE_PLAYBACK; - newdemo_read_frame_information(); // then the frame information + newdemo_read_frame_information(); // then the frame information Newdemo_vcr_state = ND_STATE_PAUSED; return; } @@ -3296,7 +2575,7 @@ void newdemo_back_frames(int frames) for (i = 0; i < frames; i++) { fseek(infile, -10, SEEK_CUR); - nd_read_short(&last_frame_length); + nd_read_short(&last_frame_length); fseek(infile, 8 - last_frame_length, SEEK_CUR); if (!Newdemo_at_eof && newdemo_read_frame_information() == -1) { @@ -3307,7 +2586,7 @@ void newdemo_back_frames(int frames) Newdemo_at_eof = 0; fseek(infile, -10, SEEK_CUR); - nd_read_short(&last_frame_length); + nd_read_short(&last_frame_length); fseek(infile, 8 - last_frame_length, SEEK_CUR); } @@ -3354,82 +2633,82 @@ void interpolate_frame(fix d_play, fix d_recorded) for (j = 0; j <= Highest_object_index; j++) { if (cur_objs[i].signature == Objects[j].signature) { ubyte render_type = cur_objs[i].render_type; - //fix delta_p, delta_h, delta_b; - fix delta_x, delta_y, delta_z; - //vms_angvec cur_angles, dest_angles; + // fix delta_p, delta_h, delta_b; + fix delta_x, delta_y, delta_z; + // vms_angvec cur_angles, dest_angles; - // Extract the angles from the object orientation matrix. - // Some of this code taken from ai_turn_towards_vector - // Don't do the interpolation on certain render types which don't use an orientation matrix +// Extract the angles from the object orientation matrix. +// Some of this code taken from ai_turn_towards_vector +// Don't do the interpolation on certain render types which don't use an orientation matrix if (!((render_type == RT_LASER) || (render_type == RT_FIREBALL) || (render_type == RT_POWERUP))) { - vms_vector fvec1, fvec2, rvec1, rvec2; - fix mag1; - - fvec1 = cur_objs[i].orient.fvec; - vm_vec_scale(&fvec1, F1_0-factor); - fvec2 = Objects[j].orient.fvec; - vm_vec_scale(&fvec2, factor); - vm_vec_add2(&fvec1, &fvec2); - mag1 = vm_vec_normalize_quick(&fvec1); - if (mag1 > F1_0/256) { - rvec1 = cur_objs[i].orient.rvec; - vm_vec_scale(&rvec1, F1_0-factor); - rvec2 = Objects[j].orient.rvec; - vm_vec_scale(&rvec2, factor); - vm_vec_add2(&rvec1, &rvec2); - vm_vec_normalize_quick(&rvec1); // Note: Doesn't matter if this is null, if null, vm_vector_2_matrix will just use fvec1 - vm_vector_2_matrix(&cur_objs[i].orient, &fvec1, NULL, &rvec1); - } - - //--old new way -- vms_vector fvec1, fvec2, rvec1, rvec2; - //--old new way -- - //--old new way -- fvec1 = cur_objs[i].orient.fvec; - //--old new way -- vm_vec_scale(&fvec1, F1_0-factor); - //--old new way -- fvec2 = Objects[j].orient.fvec; - //--old new way -- vm_vec_scale(&fvec2, factor); - //--old new way -- vm_vec_add2(&fvec1, &fvec2); - //--old new way -- vm_vec_normalize_quick(&fvec1); - //--old new way -- - //--old new way -- rvec1 = cur_objs[i].orient.rvec; - //--old new way -- vm_vec_scale(&rvec1, F1_0-factor); - //--old new way -- rvec2 = Objects[j].orient.rvec; - //--old new way -- vm_vec_scale(&rvec2, factor); - //--old new way -- vm_vec_add2(&rvec1, &rvec2); - //--old new way -- vm_vec_normalize_quick(&rvec1); - //--old new way -- - //--old new way -- vm_vector_2_matrix(&cur_objs[i].orient, &fvec1, NULL, &rvec1); - - // -- old fashioned way -- vm_extract_angles_matrix(&cur_angles, &(cur_objs[i].orient)); - // -- old fashioned way -- vm_extract_angles_matrix(&dest_angles, &(Objects[j].orient)); - // -- old fashioned way -- - // -- old fashioned way -- delta_p = (dest_angles.p - cur_angles.p); - // -- old fashioned way -- delta_h = (dest_angles.h - cur_angles.h); - // -- old fashioned way -- delta_b = (dest_angles.b - cur_angles.b); - // -- old fashioned way -- - // -- old fashioned way -- if (delta_p != 0) { - // -- old fashioned way -- if (delta_p > F1_0/2) delta_p = dest_angles.p - cur_angles.p - F1_0; - // -- old fashioned way -- if (delta_p < -F1_0/2) delta_p = dest_angles.p - cur_angles.p + F1_0; - // -- old fashioned way -- delta_p = fixmul(delta_p, factor); - // -- old fashioned way -- cur_angles.p += delta_p; - // -- old fashioned way -- } - // -- old fashioned way -- if (delta_h != 0) { - // -- old fashioned way -- if (delta_h > F1_0/2) delta_h = dest_angles.h - cur_angles.h - F1_0; - // -- old fashioned way -- if (delta_h < -F1_0/2) delta_h = dest_angles.h - cur_angles.h + F1_0; - // -- old fashioned way -- delta_h = fixmul(delta_h, factor); - // -- old fashioned way -- cur_angles.h += delta_h; - // -- old fashioned way -- } - // -- old fashioned way -- if (delta_b != 0) { - // -- old fashioned way -- if (delta_b > F1_0/2) delta_b = dest_angles.b - cur_angles.b - F1_0; - // -- old fashioned way -- if (delta_b < -F1_0/2) delta_b = dest_angles.b - cur_angles.b + F1_0; - // -- old fashioned way -- delta_b = fixmul(delta_b, factor); - // -- old fashioned way -- cur_angles.b += delta_b; - // -- old fashioned way -- } +vms_vector fvec1, fvec2, rvec1, rvec2; +fix mag1; + +fvec1 = cur_objs[i].orient.fvec; +vm_vec_scale(&fvec1, F1_0-factor); +fvec2 = Objects[j].orient.fvec; +vm_vec_scale(&fvec2, factor); +vm_vec_add2(&fvec1, &fvec2); +mag1 = vm_vec_normalize_quick(&fvec1); +if (mag1 > F1_0/256) { + rvec1 = cur_objs[i].orient.rvec; + vm_vec_scale(&rvec1, F1_0-factor); + rvec2 = Objects[j].orient.rvec; + vm_vec_scale(&rvec2, factor); + vm_vec_add2(&rvec1, &rvec2); + vm_vec_normalize_quick(&rvec1); // Note: Doesn't matter if this is null, if null, vm_vector_2_matrix will just use fvec1 + vm_vector_2_matrix(&cur_objs[i].orient, &fvec1, NULL, &rvec1); +} + +//--old new way -- vms_vector fvec1, fvec2, rvec1, rvec2; +//--old new way -- +//--old new way -- fvec1 = cur_objs[i].orient.fvec; +//--old new way -- vm_vec_scale(&fvec1, F1_0-factor); +//--old new way -- fvec2 = Objects[j].orient.fvec; +//--old new way -- vm_vec_scale(&fvec2, factor); +//--old new way -- vm_vec_add2(&fvec1, &fvec2); +//--old new way -- vm_vec_normalize_quick(&fvec1); +//--old new way -- +//--old new way -- rvec1 = cur_objs[i].orient.rvec; +//--old new way -- vm_vec_scale(&rvec1, F1_0-factor); +//--old new way -- rvec2 = Objects[j].orient.rvec; +//--old new way -- vm_vec_scale(&rvec2, factor); +//--old new way -- vm_vec_add2(&rvec1, &rvec2); +//--old new way -- vm_vec_normalize_quick(&rvec1); +//--old new way -- +//--old new way -- vm_vector_2_matrix(&cur_objs[i].orient, &fvec1, NULL, &rvec1); + +// -- old fashioned way -- vm_extract_angles_matrix(&cur_angles, &(cur_objs[i].orient)); +// -- old fashioned way -- vm_extract_angles_matrix(&dest_angles, &(Objects[j].orient)); +// -- old fashioned way -- +// -- old fashioned way -- delta_p = (dest_angles.p - cur_angles.p); +// -- old fashioned way -- delta_h = (dest_angles.h - cur_angles.h); +// -- old fashioned way -- delta_b = (dest_angles.b - cur_angles.b); +// -- old fashioned way -- +// -- old fashioned way -- if (delta_p != 0) { +// -- old fashioned way -- if (delta_p > F1_0/2) delta_p = dest_angles.p - cur_angles.p - F1_0; +// -- old fashioned way -- if (delta_p < -F1_0/2) delta_p = dest_angles.p - cur_angles.p + F1_0; +// -- old fashioned way -- delta_p = fixmul(delta_p, factor); +// -- old fashioned way -- cur_angles.p += delta_p; +// -- old fashioned way -- } +// -- old fashioned way -- if (delta_h != 0) { +// -- old fashioned way -- if (delta_h > F1_0/2) delta_h = dest_angles.h - cur_angles.h - F1_0; +// -- old fashioned way -- if (delta_h < -F1_0/2) delta_h = dest_angles.h - cur_angles.h + F1_0; +// -- old fashioned way -- delta_h = fixmul(delta_h, factor); +// -- old fashioned way -- cur_angles.h += delta_h; +// -- old fashioned way -- } +// -- old fashioned way -- if (delta_b != 0) { +// -- old fashioned way -- if (delta_b > F1_0/2) delta_b = dest_angles.b - cur_angles.b - F1_0; +// -- old fashioned way -- if (delta_b < -F1_0/2) delta_b = dest_angles.b - cur_angles.b + F1_0; +// -- old fashioned way -- delta_b = fixmul(delta_b, factor); +// -- old fashioned way -- cur_angles.b += delta_b; +// -- old fashioned way -- } } - // Interpolate the object position. This is just straight linear - // interpolation. +// Interpolate the object position. This is just straight linear +// interpolation. delta_x = Objects[j].pos.x - cur_objs[i].pos.x; delta_y = Objects[j].pos.y - cur_objs[i].pos.y; @@ -3442,20 +2721,20 @@ void interpolate_frame(fix d_play, fix d_recorded) cur_objs[i].pos.x += delta_x; cur_objs[i].pos.y += delta_y; cur_objs[i].pos.z += delta_z; - - // -- old fashioned way --// stuff the new angles back into the object structure - // -- old fashioned way -- vm_angles_2_matrix(&(cur_objs[i].orient), &cur_angles); + +// -- old fashioned way --// stuff the new angles back into the object structure +// -- old fashioned way -- vm_angles_2_matrix(&(cur_objs[i].orient), &cur_angles); } } } - // get back to original position in the demo file. Reread the current - // frame information again to reset all of the object stuff not covered - // with Highest_object_index and the object array (previously rendered - // objects, etc....) +// get back to original position in the demo file. Reread the current +// frame information again to reset all of the object stuff not covered +// with Highest_object_index and the object array (previously rendered +// objects, etc....) - newdemo_back_frames(1); - newdemo_back_frames(1); + newdemo_back_frames(1); + newdemo_back_frames(1); if (newdemo_read_frame_information() == -1) newdemo_stop_playback(); Newdemo_vcr_state = ND_STATE_PLAYBACK; @@ -3471,23 +2750,23 @@ void newdemo_playback_one_frame() int frames_back, i, level; static fix base_interpol_time = 0; static fix d_recorded = 0; - + for (i = 0; i < MAX_PLAYERS; i++) if (Newdemo_players_cloaked & (1 << i)) Players[i].cloak_time = GameTime - (CLOAK_TIME_MAX / 2); if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) Players[Player_num].invulnerable_time = GameTime - (INVULNERABLE_TIME_MAX / 2); - - if (Newdemo_vcr_state == ND_STATE_PAUSED) // render a frame or not + + if (Newdemo_vcr_state == ND_STATE_PAUSED) // render a frame or not return; - + if (Newdemo_vcr_state == ND_STATE_PLAYBACK) DoJasonInterpolate(nd_recorded_time); - + Control_center_destroyed = 0; Countdown_seconds_left = -1; - PALETTE_FLASH_SET(0,0,0); //clear flash + PALETTE_FLASH_SET(0,0,0); //clear flash if ((Newdemo_vcr_state == ND_STATE_REWINDING) || (Newdemo_vcr_state == ND_STATE_ONEFRAMEBACKWARD)) { @@ -3529,7 +2808,7 @@ void newdemo_playback_one_frame() newdemo_stop_playback(); break; } - } + } } else Newdemo_vcr_state = ND_STATE_PAUSED; @@ -3553,27 +2832,27 @@ void newdemo_playback_one_frame() } else { - // First, uptate the total playback time to date. Then we check to see - // if we need to change the playback style to interpolate frames or - // skip frames based on where the playback time is relative to the - // recorded time. +// First, uptate the total playback time to date. Then we check to see +// if we need to change the playback style to interpolate frames or +// skip frames based on where the playback time is relative to the +// recorded time. if (NewdemoFrameCount <= 0) - nd_playback_total = nd_recorded_total; // baseline total playback time + nd_playback_total = nd_recorded_total; // baseline total playback time else nd_playback_total += FrameTime; if ((playback_style == NORMAL_PLAYBACK) && (NewdemoFrameCount > 10)) if ((nd_playback_total * INTERPOL_FACTOR) < nd_recorded_total) { playback_style = INTERPOLATE_PLAYBACK; - nd_playback_total = nd_recorded_total + FrameTime; // baseline playback time + nd_playback_total = nd_recorded_total + FrameTime; // baseline playback time base_interpol_time = nd_recorded_total; - d_recorded = nd_recorded_time; // baseline delta recorded + d_recorded = nd_recorded_time; // baseline delta recorded } if ((playback_style == NORMAL_PLAYBACK) && (NewdemoFrameCount > 10)) if (nd_playback_total > nd_recorded_total) playback_style = SKIP_PLAYBACK; - + if ((playback_style == INTERPOLATE_PLAYBACK) && Newdemo_do_interpolate) { fix d_play = 0; @@ -3606,10 +2885,10 @@ void newdemo_playback_one_frame() break; } - // for each new object in the frame just read in, determine if there is - // a corresponding object that we have been interpolating. If so, then - // copy that interpolated object to the new Objects array so that the - // interpolated position and orientation can be preserved. +// for each new object in the frame just read in, determine if there is +// a corresponding object that we have been interpolating. If so, then +// copy that interpolated object to the new Objects array so that the +// interpolated position and orientation can be preserved. for (i = 0; i <= num_objs; i++) { for (j = 0; j <= Highest_object_index; j++) { @@ -3631,13 +2910,13 @@ void newdemo_playback_one_frame() return; } else { - //mprintf ((0, "*")); +// mprintf ((0, "*")); if (newdemo_read_frame_information() == -1) { newdemo_stop_playback(); return; } if (playback_style == SKIP_PLAYBACK) { - //mprintf ((0, ".")); +// mprintf ((0, ".")); while (nd_playback_total > nd_recorded_total) { if (newdemo_read_frame_information() == -1) { newdemo_stop_playback(); @@ -3650,23 +2929,23 @@ void newdemo_playback_one_frame() } void newdemo_start_recording() -{ -#ifdef WINDOWS - Newdemo_size=GetFreeDiskSpace(); - mprintf((0, "Free space = %d\n", Newdemo_size)); -#else - Newdemo_size = GetDiskFree(); -#endif +{ + #ifdef WINDOWS + Newdemo_size=GetFreeDiskSpace(); + mprintf((0, "Free space = %d\n", Newdemo_size)); + #else + Newdemo_size = GetDiskFree(); + #endif Newdemo_size -= 100000; - if ((Newdemo_size+100000) < 2000000000) { + if ((Newdemo_size+100000) < 2000000000) { if (((int)(Newdemo_size)) < 500000) { -#ifndef MACINTOSH + #ifndef MACINTOSH nm_messagebox(NULL, 1, TXT_OK, TXT_DEMO_NO_SPACE); -#else + #else nm_messagebox(NULL, 1, TXT_OK, "Not enough space on current\ndrive to start demo recording."); -#endif + #endif return; } } @@ -3676,23 +2955,23 @@ void newdemo_start_recording() Newdemo_state = ND_STATE_RECORDING; outfile = fopen( DEMO_FILENAME, "wb" ); -#ifndef MACINTOSH - if (outfile == NULL && errno == ENOENT) { //dir doesn't exist? -#else - if (outfile == NULL) { //dir doesn't exist and no errno on mac! -#endif + #ifndef MACINTOSH + if (outfile == NULL && errno == ENOENT) { //dir doesn't exist? + #else + if (outfile == NULL) { //dir doesn't exist and no errno on mac! + #endif d_mkdir(DEMO_DIR); //try making directory outfile = fopen( DEMO_FILENAME, "wb" ); } if (outfile == NULL) - { + { nm_messagebox(NULL, 1, TXT_OK, "Cannot open demo temp file"); - Newdemo_state = ND_STATE_NORMAL; - } + Newdemo_state = ND_STATE_NORMAL; + } else newdemo_record_start_demo(); - + } char demoname_allowed_chars[] = "azAZ09__--"; @@ -3723,11 +3002,11 @@ void newdemo_stop_recording() nd_write_short(ND_EVENT_EOF); nd_write_int(ND_EVENT_EOF); - byte_count += 10; // from frame_bytes_written - + byte_count += 10; // from frame_bytes_written + nd_write_byte((byte)(f2ir(Players[Player_num].energy))); nd_write_byte((byte)(f2ir(Players[Player_num].shields))); - nd_write_int(Players[Player_num].flags); // be sure players flags are set + nd_write_int(Players[Player_num].flags); // be sure players flags are set nd_write_byte((byte)Primary_weapon); nd_write_byte((byte)Secondary_weapon); byte_count += 8; @@ -3774,22 +3053,22 @@ void newdemo_stop_recording() gr_palette_load( gr_palette ); if (filename[0] != '\0') { - int num, i = strlen(filename) - 1; - char newfile[15]; - - while (isdigit(filename[i])) { - i--; - if (i == -1) - break; - } - i++; - num = atoi(&(filename[i])); - num++; - filename[i] = '\0'; - sprintf (newfile, "%s%d", filename, num); - strncpy(filename, newfile, 8); - filename[8] = '\0'; - } + int num, i = strlen(filename) - 1; + char newfile[15]; + + while (isdigit(filename[i])) { + i--; + if (i == -1) + break; + } + i++; + num = atoi(&(filename[i])); + num++; + filename[i] = '\0'; + sprintf (newfile, "%s%d", filename, num); + strncpy(filename, newfile, 8); + filename[8] = '\0'; + } try_again: ; @@ -3809,7 +3088,7 @@ try_again: } Newmenu_allowed_chars = NULL; - if (exit == -2) { // got bumped out from network menu + if (exit == -2) { // got bumped out from network menu char save_file[7+FILENAME_LEN]; if (filename[0] != '\0') { @@ -3822,12 +3101,12 @@ try_again: rename(DEMO_FILENAME, save_file); return; } - if (exit == -1) { // pressed ESC - remove(DEMO_FILENAME); // might as well remove the file - return; // return without doing anything + if (exit == -1) { // pressed ESC + remove(DEMO_FILENAME); // might as well remove the file + return; // return without doing anything } - - if (filename[0]==0) //null string + + if (filename[0]==0) //null string goto try_again; //check to make sure name is ok @@ -3852,25 +3131,13 @@ int newdemo_count_demos() FILEFINDSTRUCT find; int NumFiles=0; - if( !FileFindFirst( DEMO_DIR "*.dem", &find ) ) { - do { + if( !FileFindFirst("demos/*.dem", &find ) ) { + do { NumFiles++; } while( !FileFindNext( &find ) ); FileFindClose(); } - if ( AltHogdir_initialized ) { - char search_name[PATH_MAX + 5]; - strcpy(search_name, AltHogDir); - strcat(search_name, "/" DEMO_DIR "*.dem"); - if( !FileFindFirst( search_name, &find ) ) { - do { - NumFiles++; - } while( !FileFindNext( &find ) ); - FileFindClose(); - } - } - return NumFiles; } @@ -3878,29 +3145,29 @@ void newdemo_start_playback(char * filename) { FILEFINDSTRUCT find; int rnd_demo = 0; - char filename2[PATH_MAX+FILENAME_LEN] = DEMO_DIR; + char filename2[7+FILENAME_LEN] = DEMO_DIR; #ifdef NETWORK change_playernum_to(0); #endif - First_time_playback=1; + First_time_playback=1; JasonPlaybackTotal=0; if (filename==NULL) { - // Randomly pick a filename + // Randomly pick a filename int NumFiles = 0, RandFileNum; rnd_demo = 1; NumFiles = newdemo_count_demos(); - if ( NumFiles == 0 ) { - return; // No files found! + if ( NumFiles == 0 ) { + return; // No files found! } RandFileNum = d_rand() % NumFiles; NumFiles = 0; - if( !FileFindFirst( DEMO_DIR "*.dem", &find ) ) { - do { - if ( NumFiles==RandFileNum ) { + if( !FileFindFirst( "demos/*.dem", &find ) ) { + do { + if ( NumFiles==RandFileNum ) { filename = (char *)&find.name; break; } @@ -3908,23 +3175,6 @@ void newdemo_start_playback(char * filename) } while( !FileFindNext( &find ) ); FileFindClose(); } - - if ( filename == NULL && AltHogdir_initialized ) { - char search_name[PATH_MAX + 5]; - strcpy(search_name, AltHogDir); - strcat(search_name, "/" DEMO_DIR "*.dem"); - if( !FileFindFirst( search_name, &find ) ) { - do { - if ( NumFiles==RandFileNum ) { - filename = (char *)&find.name; - break; - } - NumFiles++; - } while( !FileFindNext( &find ) ); - FileFindClose(); - } - } - if ( filename==NULL) return; } @@ -3934,25 +3184,17 @@ void newdemo_start_playback(char * filename) strcat(filename2,filename); infile = fopen( filename2, "rb" ); - - if (infile==NULL && AltHogdir_initialized) { - strcpy(filename2, AltHogDir); - strcat(filename2, "/" DEMO_DIR); - strcat(filename2, filename); - infile = fopen( filename2, "rb" ); - } - - if (infile==NULL) { + if (infile==NULL) { mprintf( (0, "Error reading '%s'\n", filename )); return; } nd_bad_read = 0; #ifdef NETWORK - change_playernum_to(0); // force playernum to 0 + change_playernum_to(0); // force playernum to 0 #endif strncpy(nd_save_callsign, Players[Player_num].callsign, CALLSIGN_LEN); - Viewer = ConsoleObject = &Objects[0]; // play properly as if console player + Viewer = ConsoleObject = &Objects[0]; // play properly as if console player if (newdemo_read_demo_start(rnd_demo)) { fclose(infile); return; @@ -3969,10 +3211,10 @@ void newdemo_start_playback(char * filename) Newdemo_players_cloaked = 0; playback_style = NORMAL_PLAYBACK; Function_mode = FMODE_GAME; - Cockpit_3d_view[0] = CV_NONE; //turn off 3d views on cockpit - Cockpit_3d_view[1] = CV_NONE; //turn off 3d views on cockpit - newdemo_playback_one_frame(); // this one loads new level - newdemo_playback_one_frame(); // get all of the objects to renderb game + Cockpit_3d_view[0] = CV_NONE; //turn off 3d views on cockpit + Cockpit_3d_view[1] = CV_NONE; //turn off 3d views on cockpit + newdemo_playback_one_frame(); // this one loads new level + newdemo_playback_one_frame(); // get all of the objects to renderb game } void newdemo_stop_playback() @@ -3980,13 +3222,13 @@ void newdemo_stop_playback() fclose( infile ); Newdemo_state = ND_STATE_NORMAL; #ifdef NETWORK - change_playernum_to(0); //this is reality + change_playernum_to(0); //this is reality #endif strncpy(Players[Player_num].callsign, nd_save_callsign, CALLSIGN_LEN); Cockpit_mode = Newdemo_old_cockpit; Game_mode = GM_GAME_OVER; Function_mode = FMODE_MENU; - longjmp(LeaveGame,0); // Exit game loop + longjmp(LeaveGame,0); // Exit game loop } @@ -4029,9 +3271,9 @@ void newdemo_strip_frames(char *outname, int bytes_to_strip) bytes_back = 0; while (bytes_back < bytes_to_strip) { loc1 = ftell(infile); - //fseek(infile, -10, SEEK_CUR); - //nd_read_short(&last_frame_length); - //fseek(infile, 8 - last_frame_length, SEEK_CUR); +// fseek(infile, -10, SEEK_CUR); +// nd_read_short(&last_frame_length); +// fseek(infile, 8 - last_frame_length, SEEK_CUR); newdemo_back_frames(1); loc2 = ftell(infile); bytes_back += (loc1 - loc2); @@ -4068,64 +3310,66 @@ object DemoRightExtra,DemoLeftExtra; ubyte DemoDoRight=0,DemoDoLeft=0; void nd_render_extras (ubyte which,object *obj) -{ - ubyte w=which>>4; - ubyte type=which&15; - - if (which==255) - { - Int3(); // how'd we get here? - do_cockpit_window_view(w,NULL,0,WBU_WEAPON,NULL); - return; - } - - if (w) - { - memcpy (&DemoRightExtra,obj,sizeof(object)); DemoDoRight=type; - } - else - { - memcpy (&DemoLeftExtra,obj,sizeof(object)); DemoDoLeft=type; - } - -} + { + ubyte w=which>>4; + ubyte type=which&15; + + if (which==255) + { + Int3(); // how'd we get here? + do_cockpit_window_view(w,NULL,0,WBU_WEAPON,NULL); + return; + } + + if (w) + { memcpy (&DemoRightExtra,obj,sizeof(object)); DemoDoRight=type; } + else + { memcpy (&DemoLeftExtra,obj,sizeof(object)); DemoDoLeft=type;} + + } void DoJasonInterpolate (fix recorded_time) -{ - fix the_delay; - - JasonPlaybackTotal+=FrameTime; - - if (!First_time_playback) - { - // get the difference between the recorded time and the playback time - the_delay=(recorded_time - FrameTime); - //mprintf ((0,"The delay=%d\n", f2i(the_delay))); - if (the_delay >= f0_0) - { - stop_time(); - timer_delay(the_delay); - start_time(); - } + { + int the_delay; + float MyRecFrameTime,ThisFrameTime; + + JasonPlaybackTotal+=FrameTime; + + + if (!First_time_playback) + { + // get the difference between the recorded time and the playback time + + MyRecFrameTime=f2fl(recorded_time); + ThisFrameTime=f2fl(FrameTime); + + the_delay=((MyRecFrameTime-ThisFrameTime)*1000.0); + //mprintf ((0,"The delay=%d\n",the_delay)); + if (the_delay>=0) + { + stop_time(); + d_delay (the_delay); + start_time(); + } else - { - while (JasonPlaybackTotal > nd_recorded_total) - if (newdemo_read_frame_information() == -1) - { - newdemo_stop_playback(); - return; - } - - //the_delay = nd_recorded_total - JasonPlaybackTotal; - //if (the_delay > f0_0) - // timer_delay(the_delay); - } - - } - - First_time_playback=0; -} - + { + while (JasonPlaybackTotal > nd_recorded_total) + if (newdemo_read_frame_information() == -1) + { + newdemo_stop_playback(); + return; + } + + // the_delay=(f2fl(nd_recorded_total-JasonPlaybackTotal))*1000.0; + //if (delay>0) + // delay (the_delay); + } + + } + + First_time_playback=0; + } + #ifdef MACINTOSH #pragma global_optimizer reset #endif diff --git a/main/newdemo.h b/main/newdemo.h index 8659c534..212e6318 100644 --- a/main/newdemo.h +++ b/main/newdemo.h @@ -1,4 +1,3 @@ -/* $Id: newdemo.h,v 1.3 2003-03-17 07:59:11 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,160 +7,10 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * header for demo playback system - * - * Old Log: - * Revision 1.1 1995/05/16 16:00:24 allender - * Initial revision - * - * Revision 2.0 1995/02/27 11:27:18 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.43 1995/01/19 09:41:43 allender - * prototype for laser level recording - * - * Revision 1.42 1995/01/18 18:48:49 allender - * added function prototype for door_open - * - * Revision 1.41 1995/01/17 17:42:31 allender - * new prototypes for ammo counts - * - * Revision 1.40 1995/01/04 15:04:27 allender - * added some different prototypes for registered - * - * Revision 1.39 1995/01/03 11:45:11 allender - * extern function definition - * - * Revision 1.38 1994/12/29 16:43:31 allender - * new function prototype - * - * Revision 1.37 1994/12/28 14:15:27 allender - * new function prototypes - * - * Revision 1.36 1994/12/21 12:46:41 allender - * new functions for multiplayer deaths and kills - * - * Revision 1.35 1994/12/12 11:32:55 allender - * added new record function to restore after in rearview mode - * - * Revision 1.34 1994/12/08 21:03:15 allender - * added new param to record_player_flags - * - * Revision 1.33 1994/12/08 13:47:01 allender - * removed function call to record_rearview - * - * Revision 1.32 1994/12/06 12:57:10 allender - * added new prototype for multi decloaking - * - * Revision 1.31 1994/12/01 11:46:34 allender - * added recording prototype for multi player cloak - * - * Revision 1.30 1994/11/27 23:04:22 allender - * function prototype for recording new levels - * - * Revision 1.29 1994/11/07 08:47:43 john - * Made wall state record. - * - * Revision 1.28 1994/11/05 17:22:53 john - * Fixed lots of sequencing problems with newdemo stuff. - * - * Revision 1.27 1994/11/04 16:48:49 allender - * extern Newdemo_do_interpolate variable - * - * Revision 1.26 1994/11/02 14:08:53 allender - * record rearview - * - * Revision 1.25 1994/10/31 13:35:04 allender - * added two record functions to save and restore cockpit state on - * death sequence - * - * Revision 1.24 1994/10/29 16:01:11 allender - * added ND_STATE_NODEMOS to indicate that there are no demos currently - * available for playback - * - * Revision 1.23 1994/10/28 12:41:58 allender - * add homing distance recording event - * - * Revision 1.22 1994/10/27 16:57:32 allender - * removed VCR_MODE stuff, and added monitor blowup effects - * - * Revision 1.21 1994/10/26 14:44:48 allender - * completed hacked in vcr type demo playback states - * - * Revision 1.20 1994/10/26 13:40:38 allender - * more vcr demo playback defines - * - * Revision 1.19 1994/10/26 08:51:26 allender - * record player weapon change - * - * Revision 1.18 1994/10/25 16:25:31 allender - * prototypes for shield, energy and flags - * - * Revision 1.17 1994/08/15 18:05:30 john - * *** empty log message *** - * - * Revision 1.16 1994/07/21 13:11:26 matt - * Ripped out remants of old demo system, and added demo only system that - * disables object movement and game options from menu. - * - * Revision 1.15 1994/07/05 12:49:02 john - * Put functionality of New Hostage spec into code. - * - * Revision 1.14 1994/06/27 15:53:12 john - * #define'd out the newdemo stuff - * - * - * Revision 1.13 1994/06/24 17:01:25 john - * Add VFX support; Took Game Sequencing, like EndGame and stuff and - * took it out of game.c and into gameseq.c - * - * Revision 1.12 1994/06/21 19:46:05 john - * Added palette effects to demo recording. - * - * Revision 1.11 1994/06/21 14:19:58 john - * Put in hooks to record HUD messages. - * - * Revision 1.10 1994/06/20 11:50:42 john - * Made demo record flash effect, and control center triggers. - * - * Revision 1.9 1994/06/17 18:01:29 john - * A bunch of new stuff by John - * - * Revision 1.8 1994/06/17 12:13:34 john - * More newdemo stuff; made editor->game transition start in slew mode. - * - * Revision 1.7 1994/06/16 13:02:02 john - * Added morph hooks. - * - * Revision 1.6 1994/06/15 19:01:42 john - * Added the capability to make 3d sounds play just once for the - * laser hit wall effects. - * - * Revision 1.5 1994/06/15 14:57:11 john - * Added triggers to demo recording. - * - * Revision 1.4 1994/06/14 20:42:19 john - * Made robot matztn cntr not work until no robots or player are - * in the segment. - * - * Revision 1.3 1994/06/14 14:43:52 john - * Made doors work with newdemo system. - * - * Revision 1.2 1994/06/13 21:02:44 john - * Initial version of new demo recording system. - * - * Revision 1.1 1994/06/13 15:51:09 john - * Initial revision - * - * - */ #ifndef _NEWDEMO_H @@ -169,21 +18,15 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #ifdef NEWDEMO -#define ND_STATE_NORMAL 0 -#define ND_STATE_RECORDING 1 -#define ND_STATE_PLAYBACK 2 -#define ND_STATE_PAUSED 3 -#define ND_STATE_REWINDING 4 -#define ND_STATE_FASTFORWARD 5 -#define ND_STATE_ONEFRAMEFORWARD 6 -#define ND_STATE_ONEFRAMEBACKWARD 7 -#define ND_STATE_PRINTSCREEN 8 - -#ifndef MACINTOSH -#define DEMO_DIR "demos/" -#else -#define DEMO_DIR ":Demos:" -#endif +#define ND_STATE_NORMAL 0 +#define ND_STATE_RECORDING 1 +#define ND_STATE_PLAYBACK 2 +#define ND_STATE_PAUSED 3 +#define ND_STATE_REWINDING 4 +#define ND_STATE_FASTFORWARD 5 +#define ND_STATE_ONEFRAMEFORWARD 6 +#define ND_STATE_ONEFRAMEBACKWARD 7 +#define ND_STATE_PRINTSCREEN 8 // Gives state of recorder extern int Newdemo_state; @@ -258,12 +101,11 @@ extern void newdemo_stop_playback(); extern void newdemo_start_recording(); extern void newdemo_stop_recording(); -extern int newdemo_get_percent_done(); +extern int newdemo_get_percent_done(); extern void newdemo_record_link_sound_to_object3( int soundno, short objnum, fix max_volume, fix max_distance, int loop_start, int loop_end ); extern int newdemo_find_object( int signature ); extern void newdemo_record_kill_sound_linked_to_object( int objnum ); -#endif // NEWDEMO - -#endif // _NEWDEMO_H +#endif +#endif diff --git a/main/newmenu.c b/main/newmenu.c index d5c9d354..81529216 100644 --- a/main/newmenu.c +++ b/main/newmenu.c @@ -1,4 +1,3 @@ -/* $Id: newmenu.c,v 1.19 2003-03-17 07:59:11 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,562 +7,18 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Routines for menus. - * - * Old Log: - * Revision 1.26 1996/04/14 21:07:35 allender - * some change for update - * - * Revision 1.25 1995/10/31 10:19:25 allender - * shareware stuff - * - * Revision 1.24 1995/10/27 11:09:04 allender - * always cd to descent dir before any menu processing -- - * sanity check because of way mac does volume mounting and - * other file stuff - * - * Revision 1.23 1995/10/24 18:11:19 allender - * do_appl_quit saves and restores background -- don't - * do any special processing. fixed newmenu_do3 to pass width - * and height to ...do_4 - * - * Revision 1.22 1995/10/21 23:26:25 allender - * can't do cmd-q in multiplayer games - * - * Revision 1.21 1995/10/21 22:53:25 allender - * menus need to be 8 byte multiple wide -- printscreen stuff - * - * Revision 1.20 1995/10/20 00:50:15 allender - * redbook stuff and make esc leave menu always - * - * Revision 1.19 1995/10/17 13:14:52 allender - * mouse support for other menus now operational -- dragging - * mouse will also move sliders - * - * Revision 1.18 1995/10/12 17:35:19 allender - * mouse support for pilot and demos - * - * Revision 1.17 1995/10/11 12:17:47 allender - * removed event loop processing - * - * Revision 1.16 1995/10/10 11:51:29 allender - * align menus to 8 byte boundry - * - * Revision 1.15 1995/10/05 14:09:36 allender - * lowered starting x location on menus to fixup network - * status screen chopping off characters - * - * Revision 1.14 1995/09/24 10:52:27 allender - * made close boxes work - * maybe some other minor stuff? - * - * Revision 1.13 1995/09/15 09:02:04 allender - * started putting mouse support in listboxes - * - * Revision 1.12 1995/09/13 08:50:14 allender - * close box in this rev? Worked on getting list box better - * looking - * - * Revision 1.11 1995/09/01 10:52:37 allender - * fixed up list boxes - * - * Revision 1.10 1995/08/24 16:23:08 allender - * mouse support for most menus - * - * Revision 1.9 1995/08/08 13:46:56 allender - * added macsys header file - * - * Revision 1.8 1995/08/01 16:03:54 allender - * added file list with Desalvo's directory stuff - * - * Revision 1.7 1995/07/26 17:03:37 allender - * show then hide cursor during newmenu operations -- not quite - * right yet - * - * Revision 1.6 1995/07/17 08:56:26 allender - * fixed up menus to look better with new high res fonts - * - * Revision 1.5 1995/07/12 10:35:52 allender - * removed old debug thing - * - * Revision 1.4 1995/06/23 10:23:21 allender - * menus should work in any resolution now - * - * Revision 1.3 1995/06/20 09:11:19 allender - * changed menu system to support 640x480 instead of 320x200 - * - * Revision 1.2 1995/06/13 13:07:30 allender - * added special key to move 320x200 window to upper left corner of screen - * - * Revision 1.1 1995/05/16 15:29:13 allender - * Initial revision - * - * Revision 2.8 1995/05/26 16:16:28 john - * Split SATURN into define's for requiring cd, using cd, etc. - * Also started adding all the Rockwell stuff. - * - * Revision 2.7 1995/04/23 14:54:17 john - * Fixed bug with background breaking in first menu. - * - * Revision 2.6 1995/03/21 14:38:46 john - * Ifdef'd out the NETWORK code. - * - * Revision 2.5 1995/03/15 14:33:29 john - * Added code to force the Descent CD-rom in the drive. - * - * Revision 2.4 1995/03/14 18:24:28 john - * Force Destination Saturn to use CD-ROM drive. - * - * Revision 2.3 1995/03/14 16:22:23 john - * Added cdrom alternate directory stuff. - * - * Revision 2.2 1995/03/06 18:30:51 john - * Fixed bug with newmenu trashing editor font. - * - * Revision 2.1 1995/03/06 15:23:17 john - * New screen techniques. - * - * Revision 2.0 1995/02/27 11:27:55 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.129 1995/02/11 16:19:56 john - * Added code to make the default mission be the one last played. - * - * Revision 1.128 1995/02/02 19:41:33 john - * Added 10 save game slots. - * - * Revision 1.127 1995/02/01 18:13:52 john - * Fixed some constants. - * - * Revision 1.126 1995/02/01 18:04:01 yuan - * Added 50 characters to list. - * - * Revision 1.125 1995/02/01 13:39:35 john - * Made menu text that changes not overwrite. - * - * Revision 1.124 1995/01/31 10:47:57 john - * Added menu that you can specify the width of the menu. - * - * Revision 1.123 1995/01/28 17:18:12 john - * Added file list box. - * - * Revision 1.122 1995/01/27 17:15:55 john - * Made prev comment actually work. - * - * Revision 1.121 1995/01/27 16:49:03 john - * *** empty log message *** - * - * Revision 1.120 1995/01/27 16:46:40 john - * Made so that input_menu only clears text if -empty-. - * - * Revision 1.119 1995/01/27 15:25:04 john - * Delete saved game when deleteing a pilot file. - * - * Revision 1.118 1995/01/25 16:36:09 john - * Made so that when you hit enter during - * game save, -empty- goes away. - * - * Revision 1.117 1995/01/24 16:59:30 john - * took out mono debugging text. - * - * Revision 1.116 1995/01/24 16:23:16 john - * Fixed some bugs with listboxes. - * - * Revision 1.115 1995/01/23 23:47:36 matt - * Made keypad enter work in menus - * - * Revision 1.114 1995/01/23 19:29:59 john - * Added scrolling listbox menus. - * - * Revision 1.113 1995/01/19 12:33:34 john - * Made keys jump to sliders, etc in menus. - * - * Revision 1.112 1995/01/15 14:33:08 rob - * Fixed problem with nested nm_messageboxes. - * - * Revision 1.111 1995/01/03 17:33:40 john - * Made scrolling textbox. Used it for scores cool saying. - * - * Revision 1.110 1994/12/28 10:42:58 john - * More VFX tweaking. - * - * Revision 1.109 1994/12/28 10:26:39 john - * Fixed some VFX problems. - * - * Revision 1.108 1994/12/15 23:18:10 john - * Added fix so that VFX mode doesn't hang. - * - * Revision 1.107 1994/12/15 12:19:55 john - * Made menu use clipped bitblt functions. - * - * Revision 1.106 1994/12/09 00:41:30 mike - * fix hang in automap print screen - * - * Revision 1.105 1994/12/08 10:01:34 john - * Changed the way the player callsign stuff works. - * - * Revision 1.104 1994/12/04 15:34:30 john - * Fixed bug with newmenu not restoring font properly. - * - * Revision 1.103 1994/12/03 17:47:09 john - * Fixed bug that didn't free filename mem when not .plr files found. - * - * Revision 1.102 1994/12/03 15:06:15 john - * If no pilot exists, bring up box asking for name. - * - * Revision 1.101 1994/12/03 11:04:02 john - * Changed newmenu code a bit to fix bug with bogus - * backgrounds occcasionally. - * - * Revision 1.100 1994/12/01 20:15:48 yuan - * Localization. - * - * Revision 1.99 1994/12/01 10:33:28 john - * Fixed bug with large menu backgrounds not drawing correctly. - * - * Revision 1.98 1994/12/01 02:41:56 john - * Fixed warnining. - * - * Revision 1.97 1994/11/30 22:52:43 john - * Fixed bug in code that made the backgrounds behind menus. - * - * Revision 1.96 1994/11/30 19:47:42 john - * Added a check for out o' memory when mallocing background. - * - * Revision 1.95 1994/11/30 19:39:10 john - * .. - * - * Revision 1.94 1994/11/30 19:38:27 john - * fixed bug with previous. - * - * Revision 1.93 1994/11/30 19:36:47 john - * Made Gravis Ultrasound work again. Made the scores blink - * at a constant rate. Revamped the newmenu background storage, - * which hopefully fixed some bugs. Made menus in ame not pause - * sound, except for the pause key. ^== Game! - * - * Revision 1.92 1994/11/30 18:06:05 matt - * When player types space in callsign, comes up as underscore - * - * Revision 1.91 1994/11/30 12:28:22 adam - * added PCX support - * - * Revision 1.90 1994/11/30 12:10:59 adam - * added support for PCX titles/brief screens - * - * Revision 1.89 1994/11/29 00:59:12 allender - * change newmenu_get_filename so demo files can be deleted too - * - * Revision 1.88 1994/11/27 21:16:18 allender - * made some return values in newmenu_get_filename 0 instead of -1 - * - * Revision 1.87 1994/11/27 16:58:17 matt - * Made printscreen work all the time (not just when no ndebug) and made it - * work when getting a filename. - * - * Revision 1.86 1994/11/27 16:47:51 john - * Made the call to fade in palette only happen if it needs to be, just - * because I thought it might reduce code paging with vm in menus. - * - * Revision 1.85 1994/11/26 15:30:16 matt - * Allow escape out of change pilot menu - * - * Revision 1.84 1994/11/26 14:17:26 matt - * Player can now only enter valid chars for his name - * - * Revision 1.83 1994/11/23 14:13:17 allender - * if no demo files, displays less "techy" message - * - * Revision 1.82 1994/11/21 11:55:52 john - * Fixed some sound pausing in menus bugs. - * - * Revision 1.81 1994/11/19 15:14:58 mike - * remove unused code and data - * - * Revision 1.80 1994/11/18 23:37:54 john - * Changed some shorts to ints. - * - * Revision 1.79 1994/11/15 09:29:21 john - * Made it so that pressing a letter when selecting players moves to - * a matching choice. - * - * Revision 1.78 1994/11/14 17:12:28 adam - * *** empty log message *** - * - * Revision 1.77 1994/11/14 16:58:31 rob - * Tried to fix a problem with save demo dialog. - * - * Revision 1.76 1994/11/14 16:13:46 matt - * Fixed handling of players with DOS device names - * - * Revision 1.75 1994/11/13 18:12:53 matt - * Fixed handling of filenames that are the same as DOS devices - * - * Revision 1.74 1994/11/13 17:20:44 john - * Fixed text a bit. - * - * Revision 1.73 1994/11/13 17:18:22 john - * Changed wording of new pilot. - * - * Revision 1.72 1994/11/13 17:14:21 john - * Fixed bug with player list box. - * - * Revision 1.71 1994/11/13 17:12:48 john - * Fixed broken demo file list. - * - * Revision 1.70 1994/11/13 17:04:49 john - * Made the callsign entry be a list box and gave the ability - * to delete players. - * - * Revision 1.69 1994/11/13 15:38:03 john - * Added critical error handler to game. Took out -editor command line - * option because it didn't work anymore and wasn't worth fixing. Made scores - * not use MINER enviroment variable on release version, and made scores - * not print an error if there is no descent.hi. - * - * Revision 1.68 1994/11/11 18:17:03 rob - * Made multi_menu_poll return a value to exit menus. - * - * Revision 1.67 1994/11/11 11:07:06 rob - * Added include of multi.h - * - * Revision 1.66 1994/11/10 20:25:16 rob - * John's stuff to make network menus work. - * - * Revision 1.65 1994/11/08 14:51:39 john - * Added nm_messagebox1, (like the original, only you can pass a function). - * - * Revision 1.64 1994/11/08 08:30:39 john - * Fixed bug with centering titles. - * - * Revision 1.63 1994/11/08 08:27:00 john - * Made titles and subtitles center. - * - * Revision 1.62 1994/11/07 09:40:48 john - * Neatend file list box some. - * - * Revision 1.61 1994/11/05 17:22:41 john - * Fixed lots of sequencing problems with newdemo stuff. - * - * Revision 1.60 1994/11/05 15:04:08 john - * Added non-popup menu for the main menu, so that scores and credits don't have to save - * the background. - * - * Revision 1.59 1994/11/05 14:03:52 john - * Fixed fade transitions between all screens by making gr_palette_fade_in and out keep - * track of whether the palette is faded in or not. Then, wherever the code needs to fade out, - * it just calls gr_palette_fade_out and it will fade out if it isn't already. The same with fade_in. - * This eliminates the need for all the flags like Menu_fade_out, game_fade_in palette, etc. - * - * Revision 1.58 1994/11/04 20:11:50 john - * Neatening up palette stuff with demos. - * - * Revision 1.57 1994/11/04 13:49:24 allender - * fixed newmenu_get_filename to work with less than 10 files - * - * Revision 1.56 1994/11/03 19:37:44 john - * Added scrolling file list box - * - * Revision 1.55 1994/10/31 18:16:42 john - * Made Pad arrows work with menus. - * - * Revision 1.54 1994/10/28 14:54:25 john - * Added forward dec. for newmenu_close. - * .\ - * - * Revision 1.53 1994/10/28 14:53:00 john - * Fixed hideous bug that would bomb if you called newmenu_draw_background - * before any menus were ever displayed. - * - * Revision 1.52 1994/10/24 19:56:53 john - * Made the new user setup prompt for config options. - * - * Revision 1.51 1994/10/24 15:15:49 john - * Made Esc exit nm_messagebox's, - * , - * - * Revision 1.50 1994/10/21 15:20:20 john - * Made PrtScr do screen dump, not F2. - * - * Revision 1.49 1994/10/18 12:33:38 john - * Only used copy the item text into the saved_text field - * if it is an inputbox or inputbox_menu. - * - * Revision 1.48 1994/10/17 11:04:01 john - * Made backtab work also. - * - * Revision 1.47 1994/10/17 10:47:49 john - * MAde Tab work like down arrow. - * - * Revision 1.46 1994/10/17 10:45:10 john - * Made the player able to abort death by pressing any button or key. - * - * Revision 1.45 1994/10/13 21:52:02 john - * Made it so that if a messagebox has 1 choice, then - * Esc will return -1. - * - * Revision 1.44 1994/10/13 11:35:38 john - * Made Thrustmaster FCS Hat work. Put a background behind the - * keyboard configure. Took out turn_sensitivity. Changed sound/config - * menu to new menu. Made F6 be calibrate joystick. - * - * Revision 1.43 1994/10/11 17:18:52 john - * Fixed bug with sliders always starting at -1. - * - * Revision 1.42 1994/10/11 17:08:29 john - * Added sliders for volume controls. - * - * Revision 1.41 1994/10/06 16:04:40 john - * Made text items color differently than others. Adam - * is gonna make a diff colored font for these. - * - * Revision 1.40 1994/10/06 15:08:23 rob - * Allowed any negative key value to abort the menu and return. - * - * Revision 1.39 1994/10/04 10:26:06 matt - * Changed fade in to happen every time a global var is set - * - * Revision 1.38 1994/10/04 09:16:08 john - * If you pass -1 as choice in newmenu_do1, then - * no item is highlighted until you press up or - * down arrows. - * - * Revision 1.37 1994/10/03 23:44:37 matt - * Save & restore palette effect around menus & pause message - * - * Revision 1.36 1994/10/03 22:59:40 matt - * Re-enabled backspace to generate Int3() - * - * Revision 1.35 1994/10/03 19:11:21 matt - * Changed string input cursor to blinking underscore - * - * Revision 1.34 1994/10/03 14:44:15 john - * Added newmenu_do1, which allows you to pass the starting - * item to the menu system - * - * Revision 1.33 1994/09/30 11:51:21 john - * Added Matt's NM_TYPE_INPUT_MENU - * - * Revision 1.32 1994/09/28 17:22:56 matt - * Added extra space between subtitle and menu items - * Made shortcut key check ignore leading spaces in text - * - * Revision 1.31 1994/09/15 16:11:22 john - * Added support for VFX1 head tracking. Fixed bug with memory over- - * write when using stereo mode. - * - * Revision 1.30 1994/09/12 09:52:59 john - * Made global flush function that flushes keyboard,mouse, and joystick. - * - * Revision 1.29 1994/09/10 19:10:54 matt - * Fixed a few things (like arrow key handling) for menus with all - * text items, such as the key help message. - * - * Revision 1.28 1994/09/01 18:55:38 john - * freed scores.lbm - * - * Revision 1.27 1994/09/01 18:03:50 john - * Neatened up scores a bit. - * - * Revision 1.26 1994/08/30 20:38:13 john - * Passed citem in newmenu sub. - * - * Revision 1.25 1994/08/30 11:13:01 john - * Added beveled edges to menus. - * - * Revision 1.24 1994/08/26 13:01:58 john - * Put high score system in. - * - * Revision 1.23 1994/08/16 00:18:44 john - * Made pressing the first letter of a menu - * item move to it. - * - * Revision 1.22 1994/08/15 23:17:43 john - * *** empty log message *** - * - * Revision 1.21 1994/08/15 23:15:28 john - * Made 1 menu/checkbox return with any keypress. - * - * Revision 1.20 1994/08/12 10:18:23 john - * *** empty log message *** - * - * Revision 1.19 1994/08/12 10:09:11 john - * Made borders better. - * - * Revision 1.18 1994/08/12 03:11:16 john - * Made network be default off; Moved network options into - * main menu. Made starting net game check that mines are the - * same. - * - * Revision 1.17 1994/08/11 22:14:43 john - * Free'd up some memory that I forgot to free. - * - * Revision 1.16 1994/08/11 19:27:35 john - * Made the Backspace drop into the debugger only - * if you're not in an inputbox. - * - * Revision 1.15 1994/08/11 18:01:49 matt - * Added F2 and BACKSPACE keys to new menu system - * - * Revision 1.14 1994/08/11 14:25:58 john - * *** empty log message *** - * - * Revision 1.13 1994/08/11 14:25:40 john - * *** empty log message *** - * - * Revision 1.12 1994/08/11 13:47:02 john - * Made newmenu have subtitles, passed key through to - * the newmenu subfunctions. - * - * Revision 1.11 1994/08/11 12:45:08 john - * *** empty log message *** - * - * Revision 1.10 1994/08/11 12:25:45 john - * Made right_offset spacing different - * - * Revision 1.9 1994/08/11 12:09:49 john - * Made work with bitmapped fonts. - * - * Revision 1.8 1994/08/10 19:56:16 john - * Changed font stuff; Took out old menu; messed up lots of - * other stuff like game sequencing messages, etc. - * - * Revision 1.7 1994/07/27 16:12:23 john - * Changed newmenu system to have a callback function. - * /. - * - * Revision 1.6 1994/07/25 15:10:23 john - * *** empty log message *** - * - * Revision 1.5 1994/07/25 12:33:35 john - * Network "pinging" in. - * - * Revision 1.4 1994/07/24 18:21:27 john - * Took out first time stuff. - * - * Revision 1.3 1994/07/24 17:32:47 john - * Added percent item. Also neatend up a bit. - * - * Revision 1.2 1994/07/22 17:48:13 john - * Added new menuing system. - * - * Revision 1.1 1994/07/22 13:55:38 john - * Initial revision - * - * - */ - #ifdef HAVE_CONFIG_H #include #endif +#ifdef RCS +static char rcsid[] = "$Id: newmenu.c,v 1.6 2001-11-08 10:30:28 bradleyb Exp $"; +#endif + #ifdef WINDOWS #include "desw.h" #endif @@ -574,7 +29,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #include #include -#include #include "pa_enabl.h" //$$POLY_ACC #include "error.h" @@ -625,26 +79,26 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define MAXDISPLAYABLEITEMS 15 -#define LHX(x) ((x)*(MenuHires?2:1)) -#define LHY(y) ((y)*(MenuHires?2.4:1)) +#define LHX(x) ((x)*(MenuHires?2:1)) +#define LHY(y) ((y)*(MenuHires?2.4:1)) -#define TITLE_FONT HUGE_FONT -#define NORMAL_FONT MEDIUM1_FONT //normal, non-highlighted item -#define SELECTED_FONT MEDIUM2_FONT //highlighted item -#define SUBTITLE_FONT MEDIUM3_FONT +#define TITLE_FONT HUGE_FONT +#define NORMAL_FONT MEDIUM1_FONT //normal, non-highlighted item +#define SELECTED_FONT MEDIUM2_FONT //highlighted item +#define SUBTITLE_FONT MEDIUM3_FONT -#define NORMAL_CHECK_BOX "" -#define CHECKED_CHECK_BOX "‚" +#define NORMAL_CHECK_BOX "" +#define CHECKED_CHECK_BOX "‚" -#define NORMAL_RADIO_BOX "" -#define CHECKED_RADIO_BOX "€" -#define CURSOR_STRING "_" -#define SLIDER_LEFT "ƒ" // 131 -#define SLIDER_RIGHT "„" // 132 -#define SLIDER_MIDDLE "…" // 133 -#define SLIDER_MARKER "†" // 134 -#define UP_ARROW_MARKER "‡" // 135 -#define DOWN_ARROW_MARKER "ˆ" // 136 +#define NORMAL_RADIO_BOX "" +#define CHECKED_RADIO_BOX "€" +#define CURSOR_STRING "_" +#define SLIDER_LEFT "ƒ" // 131 +#define SLIDER_RIGHT "„" // 132 +#define SLIDER_MIDDLE "…" // 133 +#define SLIDER_MARKER "†" // 134 +#define UP_ARROW_MARKER "‡" // 135 +#define DOWN_ARROW_MARKER "ˆ" // 136 int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int citem, char * filename, int width, int height, int TinyMode ); void show_extra_netgame_info(int choice); @@ -705,17 +159,12 @@ void nm_draw_background1(char * filename) int pcx_error; grs_bitmap *bmp; ubyte pal[256*3]; - int width, height; //@@//I think this only gets called to fill the whole screen //@@Assert(grd_curcanv->cv_bitmap.bm_w == 320); //@@Assert(grd_curcanv->cv_bitmap.bm_h == 200); - pcx_error = pcx_get_dimensions(filename, &width, &height); - if (pcx_error != PCX_ERROR_NONE) - Error("Could not open pcx file <%s>\n", filename); - - bmp = gr_create_bitmap(width, height); + bmp = gr_create_bitmap(grd_curcanv->cv_bitmap.bm_w,grd_curcanv->cv_bitmap.bm_h); pcx_error = pcx_read_bitmap(filename,bmp,bmp->bm_type,pal); Assert(pcx_error == PCX_ERROR_NONE); @@ -725,16 +174,13 @@ void nm_draw_background1(char * filename) { //remap stuff. this code is kindof a hack - //now, before we bring up the menu, we need to + //now, before we bring up the menu, we need to //do some stuff to make sure the palette is ok. First, we need to //get our current palette into the 2d's array, so the remapping will - //work. Second, we need to remap the fonts. Third, we need to fill + //work. Second, we need to remap the fonts. Third, we need to fill //in part of the fade tables so the darkening of the menu edges works gr_copy_palette(gr_palette, pal, sizeof(gr_palette)); -#ifdef OGL - gr_palette_load(gr_palette); -#endif remap_fonts_and_menus(1); } @@ -744,7 +190,7 @@ WIN(DDGRLOCK(dd_grd_curcanv)); pa_save_clut(); pa_update_clut(gr_palette, 0, 256, 0); #endif - show_fullscr(bmp); + gr_bitmap(0,0,bmp); #if defined(POLY_ACC) pa_restore_clut(); #endif @@ -756,10 +202,15 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); } -#define MENU_BACKGROUND_BITMAP_HIRES (cfexist("scoresb.pcx")?"scoresb.pcx":"scores.pcx") -#define MENU_BACKGROUND_BITMAP_LORES (cfexist("scores.pcx")?"scores.pcx":"scoresb.pcx") // Mac datafiles only have scoresb.pcx - -#define MENU_BACKGROUND_BITMAP (MenuHires?MENU_BACKGROUND_BITMAP_HIRES:MENU_BACKGROUND_BITMAP_LORES) +#ifdef SHAREWARE +#define MENU_BACKGROUND_BITMAP "scores.pcx" +#else +#ifdef RELEASE +#define MENU_BACKGROUND_BITMAP (MenuHires?"\x01scoresb.pcx":"\x01scores.pcx") //read only from hog file +#else +#define MENU_BACKGROUND_BITMAP (MenuHires?"scoresb.pcx":"scores.pcx") +#endif +#endif int Background_hires; int No_darkening=0; @@ -799,44 +250,40 @@ void nm_draw_background(int x1, int y1, int x2, int y2 ) w = x2-x1+1; h = y2-y1+1; - //if ( w > nm_background.bm_w ) w = nm_background.bm_w; - //if ( h > nm_background.bm_h ) h = nm_background.bm_h; + if ( w > nm_background.bm_w ) w = nm_background.bm_w; + if ( h > nm_background.bm_h ) h = nm_background.bm_h; x2 = x1 + w - 1; y2 = y1 + h - 1; - { - grs_bitmap *tmp = gr_create_bitmap(w, h); - - gr_bitmap_scale_to(&nm_background, tmp); - - WIN(DDGRLOCK(dd_grd_curcanv)); - if (No_darkening) - gr_bm_bitblt(w, h, x1, y1, LHX(10), LHY(10), tmp, &(grd_curcanv->cv_bitmap) ); - else - gr_bm_bitblt(w, h, x1, y1, 0, 0, tmp, &(grd_curcanv->cv_bitmap) ); - gr_free_bitmap(tmp); - } +WIN(DDGRLOCK(dd_grd_curcanv)); + if (No_darkening) + gr_bm_bitblt(w, h, x1, y1, LHX(10), LHY(10), &nm_background, &(grd_curcanv->cv_bitmap) ); + else + gr_bm_bitblt(w, h, x1, y1, 0, 0, &nm_background, &(grd_curcanv->cv_bitmap) ); - if (!No_darkening) { - Gr_scanline_darkening_level = 2*7; - gr_setcolor( BM_XRGB(0,0,0) ); - gr_urect( x2-5, y1+5, x2-5, y2-5 ); - gr_urect( x2-4, y1+4, x2-4, y2-5 ); - gr_urect( x2-3, y1+3, x2-3, y2-5 ); - gr_urect( x2-2, y1+2, x2-2, y2-5 ); - gr_urect( x2-1, y1+1, x2-1, y2-5 ); - gr_urect( x2+0, y1+0, x2-0, y2-5 ); - - gr_urect( x1+5, y2-5, x2, y2-5 ); - gr_urect( x1+4, y2-4, x2, y2-4 ); - gr_urect( x1+3, y2-3, x2, y2-3 ); - gr_urect( x1+2, y2-2, x2, y2-2 ); - gr_urect( x1+1, y2-1, x2, y2-1 ); - gr_urect( x1+0, y2, x2, y2-0 ); - } - WIN(DDGRUNLOCK(dd_grd_curcanv)); +if (!No_darkening) + { + Gr_scanline_darkening_level = 2*7; + + + gr_setcolor( BM_XRGB(0,0,0) ); + gr_urect( x2-5, y1+5, x2-5, y2-5 ); + gr_urect( x2-4, y1+4, x2-4, y2-5 ); + gr_urect( x2-3, y1+3, x2-3, y2-5 ); + gr_urect( x2-2, y1+2, x2-2, y2-5 ); + gr_urect( x2-1, y1+1, x2-1, y2-5 ); + gr_urect( x2+0, y1+0, x2-0, y2-5 ); + + gr_urect( x1+5, y2-5, x2, y2-5 ); + gr_urect( x1+4, y2-4, x2, y2-4 ); + gr_urect( x1+3, y2-3, x2, y2-3 ); + gr_urect( x1+2, y2-2, x2, y2-2 ); + gr_urect( x1+1, y2-1, x2, y2-1 ); + gr_urect( x1+0, y2, x2, y2-0 ); + } +WIN(DDGRUNLOCK(dd_grd_curcanv)); Gr_scanline_darkening_level = GR_FADE_LEVELS; } @@ -865,61 +312,63 @@ void nm_restore_background( int x, int y, int w, int h ) // Draw a left justfied string void nm_string( bkg * b, int w1,int x, int y, char * s) { - int w,h,aw,tx=0,t=0,i; - char *p,*s1,*s2,measure[2]; - int XTabs[]={15,87,124,162,228,253}; + int w,h,aw,tx=0,t=0,i; + char *p,*s1,measure[2]; + int XTabs[]={15,87,124,162,228,253}; - p=s1=NULL; - s2 = d_strdup(s); + p=s1=NULL; - for (i=0;i<6;i++) { - XTabs[i]=(LHX(XTabs[i])); - XTabs[i]+=x; - } + for (i=0;i<6;i++) + { + XTabs[i]=(LHX(XTabs[i])); + XTabs[i]+=x; + } - measure[1]=0; + measure[1]=0; - if (!SurfingNet) { - p = strchr( s2, '\t' ); - if (p && (w1>0) ) { - *p = '\0'; - s1 = p+1; - } - } + if (!SurfingNet) + { + p = strchr( s, '\t' ); + if (p && (w1>0) ) { + *p = '\0'; + s1 = p+1; + } + } - gr_get_string_size(s2, &w, &h, &aw ); + gr_get_string_size(s, &w, &h, &aw ); if (w1 > 0) w = w1; - // CHANGED - gr_bm_bitblt(b->background->bm_w-15, h+2, 5, y-1, 5, y-1, b->background, &(grd_curcanv->cv_bitmap) ); - //gr_bm_bitblt(w, h, x, y, x, y, b->background, &(grd_curcanv->cv_bitmap) ); - - if (SurfingNet) { - for (i=0;ibackground->bm_w-15, h+2, 5, y-1, 5, y-1, b->background, &(grd_curcanv->cv_bitmap) ); + //gr_bm_bitblt(w, h, x, y, x, y, b->background, &(grd_curcanv->cv_bitmap) ); + + if (SurfingNet) + { + for (i=0;i0) ) { - gr_get_string_size(s1, &w, &h, &aw ); + if (!SurfingNet && p && (w1>0) ) { + gr_get_string_size(s1, &w, &h, &aw ); - gr_string( x+w1-w, y, s1 ); + gr_string( x+w1-w, y, s1 ); - *p = '\t'; - } - d_free(s2); + *p = '\t'; + } } // Draw a slider and it's string @@ -1207,13 +656,7 @@ int newmenu_do2( char * title, char * subtitle, int nitems, newmenu_item * item, int newmenu_do3( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int citem, char * filename, int width, int height ) { return newmenu_do4( title, subtitle, nitems, item, subfunction, citem, filename, width, height,0 ); - } - -int newmenu_do_fixedfont( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem), int citem, char * filename, int width, int height){ - set_screen_mode(SCREEN_MENU);//hafta set the screen mode before calling or fonts might get changed/freed up if screen res changes -// return newmenu_do3_real( title, subtitle, nitems, item, subfunction, citem, filename, width,height, GAME_FONT, GAME_FONT, GAME_FONT, GAME_FONT); - return newmenu_do4( title, subtitle, nitems, item, subfunction, citem, filename, width,height, 0); -} + } //returns 1 if a control device button has been pressed int check_button_press() @@ -1463,13 +906,13 @@ RePaintNewmenu4: aw = average_width; h += string_height+1; // Find the height of all strings } - + // Big hack for allowing the netgame options menu to spill over MaxOnMenu=MAXDISPLAYABLEITEMS; - if (ExtGameStatus==GAMESTAT_NETGAME_OPTIONS || ExtGameStatus==GAMESTAT_MORE_NETGAME_OPTIONS) + if (ExtGameStatus==GAMESTAT_NETGAME_OPTIONS || ExtGameStatus==GAMESTAT_MORE_NETGAME_OPTIONS) MaxOnMenu++; - + if (!TinyMode && (h>((MaxOnMenu+1)*(string_height+1))+(LHY(8)))) { IsScrollBox=1; @@ -1509,10 +952,10 @@ RePaintNewmenu4: if (RestoringMenu) { right_offset=0; twidth=0;} - + mprintf(( 0, "Right offset = %d\n", right_offset )); - + // Find min point of menu border // x = (grd_curscreen->sc_w-w)/2; // y = (grd_curscreen->sc_h-h)/2; @@ -1528,7 +971,7 @@ RePaintNewmenu4: if ( x < 0 ) x = 0; if ( y < 0 ) y = 0; - + if ( filename != NULL ) { nm_draw_background1( filename ); gr_palette_load(gr_palette); @@ -2650,24 +2093,6 @@ ReadFileNames: FileFindClose(); } - if (demo_mode && AltHogdir_initialized) { - char filespec2[PATH_MAX + FILENAME_LEN]; - strcpy(filespec2, AltHogDir); - strcat(filespec2, "/"); - strcat(filespec2, filespec); - if ( !FileFindFirst( filespec2, &find ) ) { - do { - if (NumFiles 1 ) { // unlink( items[*citem] ); // Delete the file @@ -120,7 +121,7 @@ extern char *Newmenu_allowed_chars; // return 1; // redraw; // } // *keypress = 0; -// } +// } // return 0; // } @@ -129,10 +130,6 @@ extern int newmenu_listbox1( char * title, int nitems, char * items[], int allow extern int newmenu_filelist( char * title, char * filespace, char * filename ); -//added on 10/14/98 by Victor Rachels to attempt a fixedwidth font messagebox -int nm_messagebox_fixedfont( char *title, int nchoices, ... ); -//end this section addition - //should be called whenever the palette changes extern void nm_remap_background(void); diff --git a/main/object.h b/main/object.h index 83356eac..f216b41a 100644 --- a/main/object.h +++ b/main/object.h @@ -1,4 +1,3 @@ -/* $Id: object.h,v 1.4 2003-01-11 01:11:37 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -205,9 +204,6 @@ typedef struct object { int signature; // Every object ever has a unique signature... ubyte type; // what type of object this is... robot, weapon, hostage, powerup, fireball ubyte id; // which form of object...which powerup, robot, etc. -#ifdef WORDS_NEED_ALIGNMENT - short pad; -#endif short next,prev; // id of next and previous connected object in Objects, -1 = no connection ubyte control_type; // how this object is controlled ubyte movement_type; // how this object moves @@ -250,9 +246,6 @@ typedef struct object { } __pack__ rtype; -#ifdef WORDS_NEED_ALIGNMENT - short pad2; -#endif } __pack__ object; typedef struct obj_position { diff --git a/main/joydefs.c b/main/old/joydefs.c similarity index 71% rename from main/joydefs.c rename to main/old/joydefs.c index 0905c67a..c9155e2f 100644 --- a/main/joydefs.c +++ b/main/old/joydefs.c @@ -1,4 +1,3 @@ -/* $Id: joydefs.c,v 1.1 2003-03-14 05:01:11 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,310 +7,18 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * FIXME: add description - * - * Old Log: - * Revision 1.10 1995/10/18 22:21:21 allender - * fixed bug with gravis mousestick and call key_flush when - * calibrating joystick since it used keystrokes for the trigger - * (at least most of them do) - * - * Revision 1.9 1995/10/17 13:12:32 allender - * fixed up controller support for mac world - * - * Revision 1.8 1995/10/15 19:27:04 allender - * new Dave Denhart controller code - * - * Revision 1.7 1995/10/15 16:14:59 allender - * fixed axis value for Thrustmaster rudders - * - * Revision 1.6 1995/09/13 11:39:39 allender - * made joystick cal menu all text so buttons will work properly - * - * Revision 1.5 1995/09/01 13:13:13 allender - * added close box on controls menu - * - * Revision 1.4 1995/08/18 10:22:47 allender - * if thrustmaster choosen, set joystick at thrustmaster type - * for proper reading in joyc.c - * - * Revision 1.3 1995/07/26 17:00:34 allender - * put back in code to make joysticks work - * - * Revision 1.2 1995/07/17 08:52:21 allender - * put back in code that was taken out previously - * - * Revision 1.1 1995/05/16 15:26:48 allender - * Initial revision - * - * Revision 2.2 1995/06/30 12:30:22 john - * Added -Xname command line. - * - * Revision 2.1 1995/04/06 12:13:20 john - * Made so you can calibrate Gravis Gamepad. - * - * Revision 2.0 1995/02/27 11:30:27 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.71 1995/02/12 02:06:10 john - * Fixed bug with joystick incorrectly asking for - * calibration. - * - * Revision 1.70 1995/01/28 15:58:07 john - * Made joystick calibration be only when wrong detected in - * menu or joystick axis changed. - * - * Revision 1.69 1995/01/25 14:37:55 john - * Made joystick only prompt for calibration once... - * - * Revision 1.68 1995/01/24 16:34:29 john - * Made so that if you reconfigure joystick and - * add or subtract an axis, it asks for a recalibration - * upon leaving. - * - * Revision 1.67 1994/12/29 11:08:51 john - * Fixed Thrustmaster and Logitech Wingman extreme - * Hat by reading the y2 axis during the center stage - * of the calibration, and using 75, 50, 27, and 3 % - * as values for the 4 positions. - * - * Revision 1.66 1994/12/15 18:17:39 john - * Fixed warning with previous. - * - * Revision 1.65 1994/12/15 18:15:48 john - * Made the joy cal only write the .cfg file, not - * the player file. - * - * Revision 1.64 1994/12/13 14:43:35 john - * Took out the code in kconfig to build direction array. - * Called kc_set_controls after selecting a new control type. - * - * Revision 1.63 1994/12/10 12:08:47 john - * Changed some delays to use TICKER instead of timer_get_fixed_seconds. - * - * Revision 1.62 1994/12/09 11:01:07 mike - * force calibration of joystick on joystick selection from Controls... menu. - * - * Revision 1.61 1994/12/07 21:50:27 john - * Put stop/start time around joystick delay. - * - * Revision 1.60 1994/12/07 19:34:39 john - * Added delay. - * - * Revision 1.59 1994/12/07 18:12:14 john - * NEatened up joy cal., - * - * Revision 1.58 1994/12/07 17:07:51 john - * Fixed up joy cal. - * - * Revision 1.57 1994/12/07 16:48:53 yuan - * localization - * - * Revision 1.56 1994/12/07 16:05:55 john - * Changed the way joystick calibration works. - * - * Revision 1.55 1994/12/06 20:15:22 john - * Took out code that unpauses songs that were never paused. - * - * Revision 1.54 1994/12/06 15:14:09 yuan - * Localization - * - * Revision 1.53 1994/12/05 16:29:16 john - * Took out music pause around the cheat menu. - * - * Revision 1.52 1994/12/04 12:39:10 john - * MAde so that FCS calibration doesn't ask for axis #2. - * - * Revision 1.51 1994/12/03 15:14:59 john - * Took out the delay mentioned previosuly cause it would - * cause bigger problems than it helps, especially with netgames. - * - * Revision 1.50 1994/12/03 14:16:14 john - * Put a delay between screens in joy cal to keep Yuan from - * double hitting. - * - * Revision 1.49 1994/12/03 11:04:06 john - * Changed newmenu code a bit to fix bug with bogus - * backgrounds occcasionally. - * - * Revision 1.48 1994/12/02 11:03:44 yuan - * Localization. - * - * Revision 1.47 1994/12/02 10:50:33 yuan - * Localization - * - * Revision 1.46 1994/12/01 12:21:59 john - * Added code to calibrate 2 joysticks separately. - * - * Revision 1.45 1994/12/01 11:52:31 john - * Added message when you select FCS to say that if - * you have WCS, see manuel. - * - * Revision 1.44 1994/11/29 02:26:28 john - * Made the prompts for upper-left, lower right for joy - * calibration more obvious. - * - * Revision 1.43 1994/11/26 13:13:59 matt - * Changed "none" option to "keyboard only" - * - * Revision 1.42 1994/11/21 19:35:13 john - * Replaced calls to joy_init with if (joy_present) - * - * Revision 1.41 1994/11/21 19:28:34 john - * Changed warning for no joystick to use nm_messagebox.. - * - * Revision 1.40 1994/11/21 19:06:25 john - * Made it so that it only stops sound when your in game mode. - * - * Revision 1.39 1994/11/21 11:47:18 john - * Made sound pause during joystick calibration. - * - * Revision 1.38 1994/11/10 20:34:18 rob - * Removed menu-specific network mode support in favor in new stuff - * in newmenu.c - * - * Revision 1.37 1994/11/08 21:21:38 john - * Made Esc exit joystick calibration. - * - * Revision 1.36 1994/11/08 15:14:42 john - * Added more calls so net doesn't die in net game. - * - * Revision 1.35 1994/11/08 14:59:12 john - * Added code to respond to network while in menus. - * - * Revision 1.34 1994/10/24 19:56:32 john - * Made the new user setup prompt for config options. - * - * Revision 1.33 1994/10/22 14:11:52 mike - * Suppress compiler warning message. - * - * Revision 1.32 1994/10/19 12:44:24 john - * Added hours field to player structure. - * - * Revision 1.31 1994/10/17 13:07:13 john - * Moved the descent.cfg info into the player config file. - * - * Revision 1.30 1994/10/13 21:41:12 john - * MAde Esc exit out of joystick calibration. - * - * Revision 1.29 1994/10/13 19:22:27 john - * Added separate config saves for different devices. - * Made all the devices work together better, such as mice won't - * get read when you're playing with the joystick. - * - * Revision 1.28 1994/10/13 11:40:18 john - * Took out warnings. - * - * Revision 1.27 1994/10/13 11:35:23 john - * Made Thrustmaster FCS Hat work. Put a background behind the - * keyboard configure. Took out turn_sensitivity. Changed sound/config - * menu to new menu. Made F6 be calibrate joystick. - * - * Revision 1.26 1994/10/11 21:29:03 matt - * Made a bunch of menus have good initial selected values - * - * Revision 1.25 1994/10/11 17:08:39 john - * Added sliders for volume controls. - * - * Revision 1.24 1994/10/10 17:59:21 john - * Neatend previous. - * - * Revision 1.23 1994/10/10 17:57:59 john - * Neatend previous. - * - * Revision 1.22 1994/10/10 17:56:11 john - * Added messagebox that tells that config has been saved. - * - * Revision 1.21 1994/09/30 12:37:26 john - * Added midi,digi volume to configuration. - * - * Revision 1.20 1994/09/22 16:14:14 john - * Redid intro sequecing. - * - * Revision 1.19 1994/09/19 18:50:15 john - * Added switch to disable joystick. - * - * Revision 1.18 1994/09/12 11:47:36 john - * Made stupid cruise work better. Make kconfig values get - * read/written to disk. - * - * Revision 1.17 1994/09/10 15:46:47 john - * First version of new keyboard configuration. - * - * Revision 1.16 1994/09/06 19:35:44 john - * Fixed bug that didn';t load new size .cal file. - * - * Revision 1.15 1994/09/06 14:51:58 john - * Added sensitivity adjustment, fixed bug with joystick button not - * staying down. - * - * Revision 1.14 1994/09/02 16:13:47 john - * Made keys fill in position. - * - * Revision 1.13 1994/08/31 17:58:50 john - * Made a bit simpler. - * - * Revision 1.12 1994/08/31 14:17:54 john - * *** empty log message *** - * - * Revision 1.11 1994/08/31 14:10:56 john - * Made keys not work when KEY_DELETE pressed. - * - * Revision 1.10 1994/08/31 13:40:47 mike - * Change constant - * - * Revision 1.9 1994/08/31 12:56:27 john - * *** empty log message *** - * - * Revision 1.8 1994/08/30 20:38:29 john - * Add more config stuff.. - * - * Revision 1.7 1994/08/30 16:37:25 john - * Added menu options to set controls. - * - * Revision 1.6 1994/08/30 09:27:18 john - * *** empty log message *** - * - * Revision 1.5 1994/08/30 09:12:01 john - * *** empty log message *** - * - * Revision 1.4 1994/08/29 21:18:32 john - * First version of new keyboard/oystick remapping stuff. - * - * Revision 1.3 1994/08/24 19:00:29 john - * Changed key_down_time to return fixed seconds instead of - * milliseconds. - * - * Revision 1.2 1994/08/17 16:50:37 john - * Added damaging fireballs, missiles. - * - * Revision 1.1 1994/08/17 10:07:12 john - * Initial revision - * - * - */ - -#ifdef RCS -static char rcsid[] = "$Id: joydefs.c,v 1.1 2003-03-14 05:01:11 btb Exp $"; -#endif -#ifdef HAVE_CONFIG_H -#include -#endif +#pragma off (unreferenced) +static char rcsid[] = "$Id: joydefs.c,v 1.1.1.1 2001-01-19 03:30:14 bradleyb Exp $"; +#pragma on (unreferenced) #include #include #include -#if 0 -#include -#endif #include "mono.h" #include "key.h" @@ -326,9 +33,6 @@ static char rcsid[] = "$Id: joydefs.c,v 1.1 2003-03-14 05:01:11 btb Exp $"; #include "controls.h" #include "joydefs.h" -#if 0 -#include "victor.h" -#endif #include "render.h" #include "palette.h" #include "newmenu.h" @@ -347,8 +51,8 @@ ubyte joydefs_calibrating = 0; // stupid hack all because of silly mouse cursor void joy_delay() { stop_time(); - timer_delay(.25); - //delay(250); // changed by allender because 1) more portable +// timer_delay(.25); + delay(250); // changed by allender because 1) more portable // 2) was totally broken on PC joy_flush(); start_time(); @@ -364,17 +68,17 @@ int joycal_message( char * title, char * text ) m[1].type = NM_TYPE_MENU; m[1].text = TXT_OK; i = newmenu_do( title, NULL, 2, m, NULL ); MAC(joydefs_calibrating = 0;) - if ( i < 0 ) + if ( i < 0 ) return 1; return 0; } -extern int WriteConfigFile(); +extern int WriteConfigFile(); void joydefs_calibrate(void) { #ifndef MACINTOSH - if ( (Config_control_type!=CONTROL_JOYSTICK) && (Config_control_type!=CONTROL_FLIGHTSTICK_PRO) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) + if ( (Config_control_type!=CONTROL_JOYSTICK) && (Config_control_type!=CONTROL_FLIGHTSTICK_PRO) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) return; #else if ( (Config_control_type == CONTROL_NONE) || (Config_control_type == CONTROL_MOUSE) ) @@ -386,9 +90,7 @@ void joydefs_calibrate(void) reset_palette_add(); gr_palette_load(gr_palette); -#if 0 joydefs_calibrate2(); -#endif reset_cockpit(); @@ -396,7 +98,6 @@ void joydefs_calibrate(void) } -#if 0 #ifndef MACINTOSH void joydefs_calibrate2() { @@ -425,7 +126,7 @@ void joydefs_calibrate2() nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK ); return; } - + masks = joy_get_present_mask(); #ifndef WINDOWS @@ -447,7 +148,7 @@ void joydefs_calibrate2() sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT); sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL); } - + if (joycal_message( title, text )) { joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); return; @@ -515,7 +216,7 @@ void joydefs_calibrate2() sprintf( title, "Joystick X2 axis\nRIGHT"); sprintf( text, "Move joystick X2 axis\nall the way right"); if (joycal_message( title, text )) { - joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); + joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); return; } joystick_read_raw_axis( JOY_ALL_AXIS, temp_values ); @@ -543,14 +244,14 @@ void joydefs_calibrate2() sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT); sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR); if (joycal_message( title, text )) { - joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); + joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); return; } joystick_read_raw_axis( JOY_ALL_AXIS, temp_values ); axis_max[2] = temp_values[2]; axis_max[3] = temp_values[3]; joy_delay(); - + sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER); sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C); if (joycal_message( title, text )) { @@ -559,11 +260,11 @@ void joydefs_calibrate2() } joystick_read_raw_axis( JOY_ALL_AXIS, temp_values ); axis_cen[2] = temp_values[2]; - axis_cen[3] = temp_values[3]; + axis_cen[3] = temp_values[3]; joy_delay(); } } - #ifndef WINDOWS + #ifndef WINDOWS else if ( (!(masks & JOY_2_X_AXIS)) && (masks & JOY_2_Y_AXIS) ) { if ( kconfig_is_axes_used(3) ) { // A throttle axis!!!!! @@ -575,7 +276,7 @@ void joydefs_calibrate2() joystick_read_raw_axis( JOY_ALL_AXIS, temp_values ); axis_min[3] = temp_values[3]; joy_delay(); - + sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE); if (joycal_message( title, TXT_MOVE_THROTTLE_R)) { joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); @@ -584,7 +285,7 @@ void joydefs_calibrate2() joystick_read_raw_axis( JOY_ALL_AXIS, temp_values ); axis_max[3] = temp_values[3]; joy_delay(); - + sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER); if (joycal_message( title, TXT_MOVE_THROTTLE_C)) { joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); @@ -599,7 +300,7 @@ void joydefs_calibrate2() } joy_set_cal_vals(axis_min, axis_cen, axis_max); - WriteConfigFile(); + WriteConfigFile(); } #else void joydefs_calibrate2() @@ -630,10 +331,10 @@ void joydefs_calibrate2() joy_set_cal_vals(axis_min, axis_cen, axis_max); return; } - + if ( Config_control_type == CONTROL_FLIGHTSTICK_PRO ) // no calibration needed return; - + joy_get_cal_vals(org_axis_min, org_axis_center, org_axis_max); joy_set_cen(); @@ -643,7 +344,7 @@ void joydefs_calibrate2() nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK ); return; } - + masks = joy_get_present_mask(); if ( masks == JOY_ALL_AXIS ) @@ -661,7 +362,7 @@ void joydefs_calibrate2() sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT); sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL); } - + if (joycal_message( title, text )) { joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); return; @@ -722,14 +423,14 @@ void joydefs_calibrate2() sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT); sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR); if (joycal_message( title, text )) { - joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); + joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); return; } joystick_read_raw_axis( JOY_ALL_AXIS, temp_values ); axis_max[2] = temp_values[2]; axis_max[3] = temp_values[3]; joy_delay(); - + sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER); sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C); if (joycal_message( title, text )) { @@ -738,7 +439,7 @@ void joydefs_calibrate2() } joystick_read_raw_axis( JOY_ALL_AXIS, temp_values ); axis_cen[2] = temp_values[2]; - axis_cen[3] = temp_values[3]; + axis_cen[3] = temp_values[3]; joy_delay(); } } else { @@ -752,7 +453,7 @@ void joydefs_calibrate2() joystick_read_raw_axis( JOY_ALL_AXIS, temp_values ); axis_min[3] = temp_values[3]; joy_delay(); - + sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE); if (joycal_message( title, TXT_MOVE_THROTTLE_R)) { joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); @@ -761,7 +462,7 @@ void joydefs_calibrate2() joystick_read_raw_axis( JOY_ALL_AXIS, temp_values ); axis_max[3] = temp_values[3]; joy_delay(); - + sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER); if (joycal_message( title, TXT_MOVE_THROTTLE_C)) { joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); @@ -774,10 +475,10 @@ void joydefs_calibrate2() } joy_set_cal_vals(axis_min, axis_cen, axis_max); - WriteConfigFile(); + WriteConfigFile(); } #endif -#endif // 0 + //char *control_text[CONTROL_MAX_TYPES] = { "Keyboard only", "Joystick", "Flightstick Pro", "Thrustmaster FCS", "Gravis Gamepad", "Mouse", "Cyberman" }; @@ -792,7 +493,7 @@ void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem nitems = nitems; last_key = last_key; - citem = citem; + citem = citem; for (i=0; i-1); @@ -985,7 +688,7 @@ void joydefs_config() void joydefs_set_type(ubyte type) { ubyte joy_type; - + switch (type) { case CONTROL_NONE: joy_type = JOY_AS_NONE; break; @@ -1000,7 +703,7 @@ void joydefs_set_type(ubyte type) #else // #ifdef MACINTOSH -//NOTE: UNIX/DOS VERSION +//NOTE: DOS VERSION void joydefs_config() { int i, old_masks, masks,nitems; @@ -1031,9 +734,7 @@ void joydefs_config() m[12].type = NM_TYPE_CHECK; m[12].text = xtext; m[12].value = kc_enable_external_control; nitems++; } - - m[nitems].type = NM_TYPE_MENU; m[nitems].text="CUSTOMIZE D2X KEYS"; nitems++; - + i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 ); Config_joystick_sensitivity = m[9].value; @@ -1045,11 +746,11 @@ void joydefs_config() old_masks |= (1< +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pa_enabl.h" //$$POLY_ACC +#include "inferno.h" +#include "text.h" +#include "args.h" +#include "mem.h" +#include "sos.h" +#include "byteswap.h" +#include "cfile.h" +#include "gamefont.h" +#include "gr.h" +#include "palette.h" +#include "config.h" +#include "mvelib32.h" +#include "mvegfx.h" +#include "mono.h" +#include "error.h" +#include "digi.h" +#include "songs.h" +#include "timer.h" +#include "joy.h" +#include "key.h" +#include "movie.h" +#include "screens.h" +#include "newmenu.h" +#include "vga.h" +#include "menu.h" + +#if defined(POLY_ACC) +#include "poly_acc.h" +#endif + +extern char *Args[100]; // Arguments from args.c for +char *FirstVid,*SecondVid; +char *RoboBuffer[50]; +char RobBufCount=0,PlayingBuf=0,RobBufLimit=0; + +unsigned RobSX=75,RobSY=50,RobDX=100,RobDY=100; +int RoboFile=0,RoboFilePos=0,MVEPaletteCalls=0; + +// Function Prototypes +int RunMovie(char *filename, int highres_flag, int allow_abort,int dx,int dy); +extern void do_briefing_screens (char *,int); + +// Subtitle data +typedef struct { + short first_frame,last_frame; + char *msg; +} subtitle; + + +// #define BUFFER_MOVIE + +#define MAX_SUBTITLES 500 +subtitle Subtitles[MAX_SUBTITLES]; +int Num_subtitles; + +// ---------------------------------------------------------------------- +void* __cdecl MPlayAlloc(unsigned size) +{ + return malloc(size); +} + +void __cdecl MPlayFree(void *p) +{ + free(p); +} + +extern WORD hSOSDigiDriver; + +int HiResRoboMovie=0; + +//----------------------------------------------------------------------- + +unsigned __cdecl FileRead(int handle, void *buf, unsigned count) +{ + unsigned numread; + numread = read(handle, buf, count); + return (numread == count); +} + +#define VID_PLAY 0 +#define VID_PAUSE 1 + +int Vid_State; + +extern int Digi_initialized; +extern int digi_timer_rate; + +int MovieHires = 0; //default for now is lores + +#define MOVIE_VOLUME_SCALE (32767) //32767 is MAX + +//filename will actually get modified to be either low-res or high-res +//returns status. see values in movie.h +int PlayMovie(const char *filename, int must_have) +{ + char name[FILENAME_LEN],*p; + int c,ret; + int save_sample_rate; + + #if defined(POLY_ACC) + PA_DFX (pa_set_write_mode (1)); + PA_DFX (pa_set_frontbuffer_current()); + #endif + + if (!Digi_initialized) + return MOVIE_NOT_PLAYED; + + #ifndef RELEASE + if (FindArg("-nomovies")) + return MOVIE_NOT_PLAYED; + #endif + + strcpy(name,filename); + + if ((p=strchr(name,'.')) == NULL) //add extension, if missing + strcat(name,".mve"); + + //check for escape already pressed & abort if so + while ((c=key_inkey()) != 0) + if (c == KEY_ESC) + return MOVIE_ABORTED; + + // Stop all digital sounds currently playing. + digi_stop_all(); + + // Stop all songs + songs_stop_all(); + + save_sample_rate = digi_sample_rate; + digi_sample_rate = SAMPLE_RATE_22K; //always 22K for movies + digi_reset(); digi_reset(); + + // Start sound + if (hSOSDigiDriver < 0xffff) { + MVE_SOS_sndInit(hSOSDigiDriver); + MVE_sndVolume((Config_digi_volume*MOVIE_VOLUME_SCALE)/8); + } + else + MVE_SOS_sndInit(-1); + + MVE_rmFastMode (MVE_RM_NORMAL); + + ret = RunMovie(name,MovieHires,must_have,-1,-1); + +//@@ if (ret == MOVIE_NOT_PLAYED) { //couldn't find movie. try other version +//@@ name[strlen(name)-5] = MovieHires?'l':'h'; //change name +//@@ ret = RunMovie(name,!MovieHires,allow_abort,-1,-1); //try again +//@@ } + + gr_palette_clear(); //clear out palette in case movie aborted + + digi_sample_rate = save_sample_rate; //restore rate for game + digi_reset(); digi_reset(); + + Screen_mode = -1; //force screen reset + + #if defined(POLY_ACC) + PA_DFX(pa_set_write_mode (0)); + #endif + + return ret; + +} + +void __cdecl MovieShowFrame (ubyte *buf,uint bufw,uint bufh,uint sx,uint sy,uint w,uint h,uint dstx,uint dsty) +{ + grs_bitmap source_bm; + + //mprintf((0,"MovieShowFrame %d,%d %d,%d %d,%d %d,%d\n",bufw,bufh,sx,sy,w,h,dstx,dsty)); + + Assert(bufw == w && bufh == h); + + source_bm.bm_x = source_bm.bm_y = 0; + source_bm.bm_w = source_bm.bm_rowsize = bufw; + source_bm.bm_h = bufh; + source_bm.bm_type = BM_LINEAR; + source_bm.bm_flags = 0; + source_bm.bm_data = buf; + + gr_bm_ubitblt(bufw,bufh,dstx,dsty,sx,sy,&source_bm,&grd_curcanv->cv_bitmap); +} + +//our routine to set the pallete, called from the movie code +void __cdecl MovieSetPalette(unsigned char *p, unsigned start, unsigned count) +{ + if (count == 0) + return; + + //mprintf((0,"SetPalette p=%x, start=%d, count=%d\n",p,start,count)); + + //Color 0 should be black, and we get color 255 + Assert(start>=1 && start+count-1<=254); + + //Set color 0 to be black + gr_palette[0] = gr_palette[1] = gr_palette[2] = 0; + + //Set color 255 to be our subtitle color + gr_palette[765] = gr_palette[766] = gr_palette[767] = 50; + + //movie libs palette into our array + memcpy(gr_palette+start*3,p+start*3,count*3); + + //finally set the palette in the hardware + gr_palette_load(gr_palette); + + //MVE_SetPalette(p, start, count); +} + +typedef struct bkg { + short x, y, w, h; // The location of the menu. + grs_bitmap * bmp; // The background under the menu. +} bkg; + +bkg movie_bg = {0,0,0,0,NULL}; + +#define BOX_BORDER (MenuHires?40:20) + +void show_pause_message(char *msg) +{ + int w,h,aw; + int x,y; + + gr_set_current_canvas(NULL); + gr_set_curfont( SMALL_FONT ); + + gr_get_string_size(msg,&w,&h,&aw); + + x = (grd_curscreen->sc_w-w)/2; + y = (grd_curscreen->sc_h-h)/2; + + if (movie_bg.bmp) { + gr_free_bitmap(movie_bg.bmp); + movie_bg.bmp = NULL; + } + + // Save the background of the display + movie_bg.x=x; movie_bg.y=y; movie_bg.w=w; movie_bg.h=h; + + movie_bg.bmp = gr_create_bitmap( w+BOX_BORDER, h+BOX_BORDER ); + + gr_bm_ubitblt(w+BOX_BORDER, h+BOX_BORDER, 0, 0, x-BOX_BORDER/2, y-BOX_BORDER/2, &(grd_curcanv->cv_bitmap), movie_bg.bmp ); + + gr_setcolor(0); + gr_rect(x-BOX_BORDER/2,y-BOX_BORDER/2,x+w+BOX_BORDER/2-1,y+h+BOX_BORDER/2-1); + + gr_set_fontcolor( 255, -1 ); + + gr_ustring( 0x8000, y, msg ); +} + +void clear_pause_message() +{ + + if (movie_bg.bmp) { + + gr_bitmap(movie_bg.x-BOX_BORDER/2, movie_bg.y-BOX_BORDER/2, movie_bg.bmp); + + gr_free_bitmap(movie_bg.bmp); + movie_bg.bmp = NULL; + } +} + +int open_movie_file(char *filename,int must_have); + +//returns status. see movie.h +int RunMovie(char *filename, int hires_flag, int must_have,int dx,int dy) +{ + int filehndl; + int result,aborted=0; + int track = 0; + int frame_num; + + // Open Movie file. If it doesn't exist, no movie, just return. + + filehndl = open_movie_file(filename,must_have); + + if (filehndl == -1) { + #ifndef EDITOR + if (must_have) + { + strupr(filename); + Error("Cannot open movie file <%s>",filename); + } + else + return MOVIE_NOT_PLAYED; + #else + return MOVIE_NOT_PLAYED; + #endif + } + + MVE_memCallbacks(MPlayAlloc, MPlayFree); + MVE_ioCallbacks(FileRead); + +#if defined(POLY_ACC) + Assert(hires_flag); + + pa_flush(); + #ifdef PA_3DFX_VOODOO + pa_begin_lfb(); + MVE_sfSVGA( 640, 480, 2048, 0, pa_get_buffer_address(0), 0, 0, NULL, 1); + pa_end_lfb(); + #else + MVE_sfSVGA( 640, 480, 1280, 0, pa_get_buffer_address(0), 0, 0, NULL, 1); + #endif + + pa_clear_buffer(0, 0); +#else + if (hires_flag) { + vga_set_mode(SM_640x480V); + if (!MVE_gfxMode(MVE_GFX_VESA_CURRENT)) { + Int3(); + close(filehndl); // Close Movie File + return MOVIE_NOT_PLAYED; + } + } + else { + vga_set_mode(SM_320x200C); + if (!MVE_gfxMode(MVE_GFX_VGA_CURRENT)) { + Int3(); + close(filehndl); // Close Movie File + return MOVIE_NOT_PLAYED; + } + } +#endif + + Vid_State = VID_PLAY; // Set to PLAY + + if (MVE_rmPrepMovie(filehndl, dx, dy, track)) { + Int3(); + return MOVIE_NOT_PLAYED; + } + +#if !defined(POLY_ACC) + MVE_sfCallbacks ((mve_cb_ShowFrame *) MovieShowFrame); + MVE_palCallbacks ((mve_cb_SetPalette *) MovieSetPalette); +#endif + + frame_num = 0; + + FontHires = hires_flag; + + while((result = MVE_rmStepMovie()) == 0) { + int key; + + draw_subtitles(frame_num); + + key = key_inkey(); + + // If ESCAPE pressed, then quit movie. + if (key == KEY_ESC) { + result = aborted = 1; + break; + } + + // If PAUSE pressed, then pause movie + if (key == KEY_PAUSE) { + MVE_rmHoldMovie(); + show_pause_message(TXT_PAUSE); + while (!key_inkey()) ; + clear_pause_message(); + } + + frame_num++; + } + + Assert(aborted || result == MVE_ERR_EOF); ///movie should be over + + MVE_rmEndMovie(); + MVE_ReleaseMem(); + + close(filehndl); // Close Movie File + + //MVE_gfxReset(); + + // Restore old graphic state + + Screen_mode=-1; //force reset of screen mode + +//@@ if (MenuHires) +//@@ vga_set_mode(SM_640x480V); +//@@ else +//@@ vga_set_mode(SM_320x200C); + + return (aborted?MOVIE_ABORTED:MOVIE_PLAYED_FULL); +} + + +int InitMovieBriefing () + { +#if defined(POLY_ACC) + Assert(MenuHires); + pa_flush(); + + #ifdef PA_3DFX_VOODOO + pa_begin_lfb(); + MVE_sfSVGA( 640, 480, 2048, 0, pa_get_buffer_address(0), 0, 0, NULL, 1); + pa_end_lfb(); + #else + MVE_sfSVGA( 640, 480, 1280, 0, pa_get_buffer_address(0), 0, 0, NULL, 1); + #endif + + pa_clear_buffer(0, 0); + return 1; +#endif + + if (MenuHires) { + vga_set_mode(SM_640x480V); + if (!MVE_gfxMode(MVE_GFX_VESA_CURRENT)) { + Int3(); + return MOVIE_NOT_PLAYED; + } + } + else { + vga_set_mode(SM_320x200C); + if (!MVE_gfxMode(MVE_GFX_VGA_CURRENT)) { + Int3(); + return MOVIE_NOT_PLAYED; + } + } + return (1); + } + +int FlipFlop=0; + +int MyShowFrame (void) + { + grs_bitmap source_bm; + + int rw,rh,rdx,rdy; + + if (MenuHires) + { rw=320; rh=200; rdx=280; rdy=200;} + else + { rw=160; rh=100; rdx=140; rdy=80;} + + source_bm.bm_x = source_bm.bm_y = 0; + source_bm.bm_w = source_bm.bm_rowsize = rw; + source_bm.bm_h = rh; + source_bm.bm_type = BM_LINEAR; + source_bm.bm_flags = 0; + if (FlipFlop) + { + #ifdef BUFFER_MOVIE + memcpy (RoboBuffer[RobBufCount++],SecondVid,rw*rh); + #endif + source_bm.bm_data = SecondVid; + } + else + { + source_bm.bm_data = FirstVid; + #ifdef BUFFER_MOVIE + memcpy (RoboBuffer[RobBufCount++],FirstVid,rw*rh); + #endif + } + + gr_bm_ubitblt(rw,rh,rdx,rdy,0,0,&source_bm,&grd_curcanv->cv_bitmap); + + FlipFlop=1-FlipFlop; + + return (NULL); + } + +#ifdef BUFFER_MOVIE +static fix RobBufTime=0; +#endif + +void ShowRobotBuffer () + { + // shows a frame from the robot buffer + +#ifndef BUFFER_MOVIE + Int3(); // Get Jason...how'd we get here? + return; +#else + grs_bitmap source_bm; + int rw,rh,rdx,rdy; + + if (timer_get_approx_seconds()<(RobBufTime+fixdiv (F1_0,i2f(15)))) + return; + + RobBufTime=timer_get_approx_seconds(); + + if (MenuHires) + { rw=320; rh=200; rdx=280; rdy=200;} + else + { rw=160; rh=100; rdx=140; rdy=80;} + + source_bm.bm_x = source_bm.bm_y = 0; + source_bm.bm_w = source_bm.bm_rowsize = rw; + source_bm.bm_h = rh; + source_bm.bm_type = BM_LINEAR; + source_bm.bm_flags = 0; + + source_bm.bm_data = RoboBuffer[RobBufCount]; + + gr_bm_ubitblt(rw,rh,rdx,rdy,0,0,&source_bm,&grd_curcanv->cv_bitmap); + + RobBufCount++; + RobBufCount%=RobBufLimit; +#endif + } + +//returns 1 if frame updated ok +int RotateRobot () +{ + int err; + + if (!Digi_initialized) //we should fix this for full version + return 0; +#ifdef BUFFER_MOVIE + if (PlayingBuf) + { + ShowRobotBuffer (); + return (1); + } +#endif + + #if defined(POLY_ACC) + PA_DFX (pa_set_write_mode (1)); + #endif + + err = MVE_rmStepMovie(); + + #if defined(POLY_ACC) + PA_DFX (pa_set_write_mode (0)); + #endif + + + if (err == MVE_ERR_EOF) //end of movie, so reset + { +#ifdef BUFFER_MOVIE + PlayingBuf=1; + RobBufLimit=RobBufCount; + RobBufCount=0; + //RobBufTime=timer_get_approx_seconds(); + return 1; +#else + reset_movie_file(RoboFile); +#if defined(POLY_ACC) + if (MVE_rmPrepMovie(RoboFile, 280, 200, 0)) { +#else + if (MVE_rmPrepMovie(RoboFile, -1, -1, 0)) { +#endif + Int3(); + return 0; + } +#endif + } + else if (err) { + Int3(); + return 0; + } + + return 1; +} + +void FreeRoboBuffer (int n) + { + // frees the 64k frame buffers, starting with n and then working down + + #ifndef BUFFER_MOVIE + n++; //kill warning + return; + #else + int i; + + for (i=n;i>=0;i--) + free (RoboBuffer[i]); + + #endif + } + + +void DeInitRobotMovie() + { + RobBufCount=0; PlayingBuf=0; + +#if !defined(POLY_ACC) + memset (FirstVid,0,64000); + memset (SecondVid,0,64000); + MyShowFrame(); +#endif + + MVE_rmEndMovie(); + MVE_ReleaseMem(); + free (FirstVid); + free (SecondVid); + + FreeRoboBuffer (49); + + MVE_palCallbacks (MVE_SetPalette); + close(RoboFile); // Close Movie File + } + +void __cdecl PaletteChecker (unsigned char *p,unsigned start,unsigned count) + { + int i; + + for (i=0;i<256;i++) + if (p[i]!=0) + break; + + if (i>=255 && (MVEPaletteCalls++)>0) + return; + + MVE_SetPalette (p,start,count); + } + + +int InitRobotMovie (char *filename) + { + #ifdef BUFFER_MOVIE + int i; + #endif + + FlipFlop=0; + + RobBufCount=0; PlayingBuf=0; RobBufLimit=0; + + if (FindArg("-nomovies")) + return (0); + +// digi_stop_all(); + +//@@ if (MovieHires) +//@@ filename[4]='h'; +//@@ else +//@@ filename[4]='l'; + + mprintf ((0,"RoboFile=%s\n",filename)); + +#ifdef BUFFER_MOVIE + + for (i=0;i<50;i++) + { + if (MenuHires) + RoboBuffer[i]=malloc(65000L); + else + RoboBuffer[i]=malloc(17000L); + + if (RoboBuffer[i]==NULL) + { + mprintf ((0,"ROBOERROR: Could't allocate frame %d!\n",i)); + if (i) + FreeRoboBuffer (i-1); + return (NULL); + } + } +#endif + + if ((FirstVid=calloc (65000L,1))==NULL) + { + FreeRoboBuffer(49); + return (NULL); + } + if ((SecondVid=calloc (65000L,1))==NULL) + { + free (FirstVid); + FreeRoboBuffer(49); + return (NULL); + } + + MVE_SOS_sndInit(-1); //tell movies to play no sound for robots + + MVE_memCallbacks(MPlayAlloc, MPlayFree); + MVE_ioCallbacks(FileRead); + MVE_memVID (FirstVid,SecondVid,65000); + + RoboFile = open_movie_file(filename,1); + + if (RoboFile == -1) { + free (FirstVid); + free (SecondVid); + FreeRoboBuffer (49); + #ifdef RELEASE + Error("Cannot open movie file <%s>",filename); + #else + return MOVIE_NOT_PLAYED; + #endif + } + + Vid_State = VID_PLAY; + +#if !defined(POLY_ACC) + MVE_sfCallbacks ((mve_cb_ShowFrame *)MyShowFrame); +#endif + +#if defined(POLY_ACC) + if (MVE_rmPrepMovie(RoboFile, 280, 200, 0)) { +#else + if (MVE_rmPrepMovie(RoboFile, -1, -1, 0)) { +#endif + Int3(); + free (FirstVid); + free (SecondVid); + FreeRoboBuffer (49); + return 0; + } + +#if !defined(POLY_ACC) + MVE_palCallbacks (PaletteChecker); +#endif + + RoboFilePos=lseek (RoboFile,0L,SEEK_CUR); + + mprintf ((0,"RoboFilePos=%d!\n",RoboFilePos)); + return (1); + } + +/* + * Subtitle system code + */ + +ubyte *subtitle_raw_data; + +//search for next field following whitespace +ubyte *next_field(ubyte *p) +{ + while (*p && !isspace(*p)) + p++; + + if (!*p) + return NULL; + + while (*p && isspace(*p)) + p++; + + if (!*p) + return NULL; + + return p; +} + +void change_filename_ext( char *dest, char *src, char *ext ); +void decode_text_line(char *p); + +int init_subtitles(char *filename) +{ + CFILE *ifile; + int size,read_count; + ubyte *p; + int have_binary = 0; + + Num_subtitles = 0; + + if (! FindArg("-subtitles")) + return 0; + + ifile = cfopen(filename,"rb"); //try text version + + if (!ifile) { //no text version, try binary version + char filename2[FILENAME_LEN]; + change_filename_ext(filename2,filename,".TXB"); + ifile = cfopen(filename2,"rb"); + if (!ifile) + return 0; + have_binary = 1; + } + + size = cfilelength(ifile); + + MALLOC (subtitle_raw_data, ubyte, size+1); + + read_count = cfread(subtitle_raw_data, 1, size, ifile); + + cfclose(ifile); + + subtitle_raw_data[size] = 0; + + if (read_count != size) { + free(subtitle_raw_data); + return 0; + } + + p = subtitle_raw_data; + + while (p && p < subtitle_raw_data+size) { + char *endp; + + endp = strchr(p,'\n'); + if (endp) { + if (endp[-1] == '\r') + endp[-1] = 0; //handle 0d0a pair + *endp = 0; //string termintor + } + + if (have_binary) + decode_text_line(p); + + if (*p != ';') { + Subtitles[Num_subtitles].first_frame = atoi(p); + p = next_field(p); if (!p) continue; + Subtitles[Num_subtitles].last_frame = atoi(p); + p = next_field(p); if (!p) continue; + Subtitles[Num_subtitles].msg = p; + + Assert(Num_subtitles==0 || Subtitles[Num_subtitles].first_frame >= Subtitles[Num_subtitles-1].first_frame); + Assert(Subtitles[Num_subtitles].last_frame >= Subtitles[Num_subtitles].first_frame); + + Num_subtitles++; + } + + p = endp+1; + + } + + return 1; + +} + +void close_subtitles() +{ + if (subtitle_raw_data) + free(subtitle_raw_data); + subtitle_raw_data = NULL; + Num_subtitles = 0; +} + +#define MAX_ACTIVE_SUBTITLES 3 + +//draw the subtitles for this frame +void draw_subtitles(int frame_num) +{ + static int active_subtitles[MAX_ACTIVE_SUBTITLES]; + static int num_active_subtitles,next_subtitle,line_spacing; + int t,y; + int must_erase=0; + + if (frame_num == 0) { + num_active_subtitles = 0; + next_subtitle = 0; + gr_set_curfont( GAME_FONT ); + line_spacing = grd_curcanv->cv_font->ft_h + (grd_curcanv->cv_font->ft_h >> 2); + gr_set_fontcolor(255,-1); + } + + //get rid of any subtitles that have expired + for (t=0;t Subtitles[active_subtitles[t]].last_frame) { + int t2; + for (t2=t;t2= Subtitles[next_subtitle].first_frame) { + if (num_active_subtitles >= MAX_ACTIVE_SUBTITLES) + Error("Too many active subtitles!"); + active_subtitles[num_active_subtitles++] = next_subtitle; + next_subtitle++; + } + + //find y coordinate for first line of subtitles + y = grd_curcanv->cv_bitmap.bm_h-((line_spacing+1)*MAX_ACTIVE_SUBTITLES+2); + + //erase old subtitles if necessary + if (must_erase) { + gr_setcolor(0); + gr_rect(0,y,grd_curcanv->cv_bitmap.bm_w-1,grd_curcanv->cv_bitmap.bm_h-1); + } + + //now draw the current subtitles + for (t=0;tname,filename); + table->n_movies = nfiles; + + offset = 4+4+nfiles*(13+4); //id + nfiles + nfiles * (filename + size) + + for (i=0;imovies[i].name, 13, 1, fp ); + if ( n != 1 ) + break; //end of file (probably) + + n = fread( &len, 4, 1, fp ); + if ( n != 1 ) + Error("error reading movie library <%s>",filename); + + table->movies[i].len = INTEL_INT(len); + table->movies[i].offset = offset; + + offset += table->movies[i].len; + + } + + fclose(fp); + + table->flags = 0; + + return table; + +} + +movielib *init_old_movie_lib(char *filename,FILE *fp) +{ + int nfiles,size; + int i; + movielib *table,*table2; + + nfiles = 0; + + //allocate big table + table = malloc(sizeof(*table) + sizeof(ml_entry)*MAX_MOVIES_PER_LIB); + + while( 1 ) { + int len; + + i = fread( table->movies[nfiles].name, 13, 1, fp ); + if ( i != 1 ) + break; //end of file (probably) + + i = fread( &len, 4, 1, fp ); + if ( i != 1 ) + Error("error reading movie library <%s>",filename); + + table->movies[nfiles].len = INTEL_INT(len); + table->movies[nfiles].offset = ftell( fp ); + + fseek( fp, INTEL_INT(len), SEEK_CUR ); //skip data + + nfiles++; + } + + //allocate correct-sized table + size = sizeof(*table) + sizeof(ml_entry)*nfiles; + table2 = malloc(size); + memcpy(table2,table,size); + free(table); + table = table2; + + strcpy(table->name,filename); + + table->n_movies = nfiles; + + fclose(fp); + + table->flags = 0; + + return table; + +} + +//find the specified movie library, and read in list of movies in it +movielib *init_movie_lib(char *filename) +{ + //note: this based on cfile_init_hogfile() + + char id[4]; + FILE * fp; + + fp = fopen( filename, "rb" ); + if ( fp == NULL ) + return NULL; + + fread( id, 4, 1, fp ); + if ( !strncmp( id, "DMVL", 4 ) ) + return init_new_movie_lib(filename,fp); + else if ( !strncmp( id, "DHF", 3 ) ) { + fseek(fp,-1,SEEK_CUR); //old file had 3 char id + return init_old_movie_lib(filename,fp); + } + else { + fclose(fp); + return NULL; + } +} + +#ifdef D2_OEM +char *movielib_files[] = {"intro-l.mvl","other-l.mvl","robots-l.mvl","oem-l.mvl"}; +#else +char *movielib_files[] = {"intro-l.mvl","other-l.mvl","robots-l.mvl"}; +#endif + +#define N_BUILTIN_MOVIE_LIBS (sizeof(movielib_files)/sizeof(*movielib_files)) +#define N_MOVIE_LIBS (N_BUILTIN_MOVIE_LIBS+1) +#define EXTRA_ROBOT_LIB N_BUILTIN_MOVIE_LIBS +movielib *movie_libs[N_MOVIE_LIBS]; + +close_movie(int i) +{ + if (movie_libs[i]) + free(movie_libs[i]); +} + +close_movies() +{ + int i; + + for (i=0;icv_w,grd_curcanv->cv_h); + + gr_set_current_canvas(tcanv); + gr_ubitmap(0,0,&save_canv->cv_bitmap); + gr_set_current_canvas(save_canv); + + gr_clear_canvas(BM_XRGB(0,0,0)); + + memcpy(save_pal,gr_palette,sizeof(save_pal)); + + memcpy(gr_palette,last_palette_for_color_fonts,sizeof(gr_palette)); + +try_again:; + + ret = nm_messagebox( "CD ERROR", 1, "Ok", "Please insert your Descent II CD"); + + if (ret == -1) { + int ret2; + + ret2 = nm_messagebox( "CD ERROR", 2, "Try Again", "Leave Game", "You must insert your\nDescent II CD to Continue"); + + if (ret2 == -1 || ret2 == 0) + goto try_again; + } + + force_rb_register = 1; //disc has changed; force register new CD + + gr_palette_clear(); + + memcpy(gr_palette,save_pal,sizeof(save_pal)); + + gr_ubitmap(0,0,&tcanv->cv_bitmap); + + if (!was_faded) + gr_palette_load(gr_palette); + + gr_free_canvas(tcanv); + + return ret; +} + +//do we have the robot movies available +int robot_movies=0; //0 means none, 1 means lowres, 2 means hires + +init_movie(char *filename,int libnum,int is_robots,int required) +{ + int high_res; + + #ifndef RELEASE + if (FindArg("-nomovies")) { + movie_libs[libnum] = NULL; + return; + } + #endif + + //for robots, load highres versions if highres menus set + if (is_robots) + high_res = MenuHiresAvailable; + else + high_res = MovieHires; + + if (high_res) + strchr(filename,'.')[-1] = 'h'; + +try_again:; + + if ((movie_libs[libnum] = init_movie_lib(filename)) == NULL) { + char name2[100]; + + strcpy(name2,CDROM_dir); + strcat(name2,filename); + movie_libs[libnum] = init_movie_lib(name2); + + if (movie_libs[libnum] != NULL) + movie_libs[libnum]->flags |= MLF_ON_CD; + else { + if (required) { + #if defined(RELEASE) && !defined(D2_OEM) //allow no movies if not release + strupr(filename); + Error("Cannot open movie file <%s>",filename); + #endif + } + #if defined(D2_OEM) //if couldn't get higres, try low + if (is_robots == 1) { //first try, try again with lowres + strchr(filename,'.')[-1] = 'l'; + high_res = 0; + is_robots++; + goto try_again; + } + else if (is_robots == 2) { //failed twice. bail with error + strupr(filename); + Error("Cannot open movie file <%s>",filename); + } + #endif + } + } + + if (is_robots && movie_libs[libnum]!=NULL) + robot_movies = high_res?2:1; +} + +//find and initialize the movie libraries +init_movies() +{ + int i; + int is_robots; + + for (i=0;in_movies;i++) + if (!stricmp(filename,lib->movies[i].name)) { //found the movie in a library + int from_cd; + + from_cd = (lib->flags & MLF_ON_CD); + + if (from_cd) + songs_stop_redbook(); //ready to read from CD + + do { //keep trying until we get the file handle + + movie_handle = filehandle = open(lib->name, O_RDONLY + O_BINARY); + + if (must_have && from_cd && filehandle == -1) { //didn't get file! + + if (request_cd() == -1) //ESC from requester + break; //bail from here. will get error later + } + + } while (must_have && from_cd && filehandle == -1); + + if (filehandle != -1) + lseek(filehandle,(movie_start=lib->movies[i].offset),SEEK_SET); + + return filehandle; + } + + return -1; +} + +//returns file handle +int open_movie_file(char *filename,int must_have) +{ + int filehandle,i; + + for (i=0;i 512 bytes wide -- check these by name - * - * Revision 1.5 1995/07/05 16:47:05 allender - * kitchen stuff - * - * Revision 1.4 1995/06/23 08:55:28 allender - * make "loading data" text y loc based off of curcanv - * - * Revision 1.3 1995/06/08 14:08:52 allender - * PPC aligned data sets - * - * Revision 1.2 1995/05/26 06:54:27 allender - * removed refences to sound data at end of pig file (since they will - * now be Macintosh snd resources for effects - * - * Revision 1.1 1995/05/16 15:29:51 allender - * Initial revision - * - * Revision 2.10 1995/10/07 13:17:26 john - * Made all bitmaps paged out by default. - * - * Revision 2.9 1995/04/14 14:05:24 john - * *** empty log message *** - * - * Revision 2.8 1995/04/12 13:39:37 john - * Fixed bug with -lowmem not working. - * - * Revision 2.7 1995/03/29 23:23:17 john - * Fixed major bug with sounds not building into pig right. - * - * Revision 2.6 1995/03/28 18:05:00 john - * Fixed it so you don't have to delete pig after changing bitmaps.tbl - * - * Revision 2.5 1995/03/16 23:13:06 john - * Fixed bug with piggy paging in bitmap not checking for disk - * error, hence bogifying textures if you pull the CD out. - * - * Revision 2.4 1995/03/14 16:22:27 john - * Added cdrom alternate directory stuff. - * - * Revision 2.3 1995/03/06 15:23:20 john - * New screen techniques. - * - * Revision 2.2 1995/02/27 13:13:40 john - * Removed floating point. - * - * Revision 2.1 1995/02/27 12:31:25 john - * Made work without editor. - * - * Revision 2.0 1995/02/27 11:28:02 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.85 1995/02/09 12:54:24 john - * Made paged out bitmaps have bm_data be a valid pointer - * instead of NULL, in case anyone accesses it. - * - * Revision 1.84 1995/02/09 12:50:59 john - * Bullet-proofed the piggy loading code. - * - * Revision 1.83 1995/02/07 17:08:51 john - * Added some error handling stuff instead of asserts. - * - * Revision 1.82 1995/02/03 17:06:48 john - * Changed sound stuff to allow low memory usage. - * Also, changed so that Sounds isn't an array of digi_sounds, it - * is a ubyte pointing into GameSounds, this way the digi.c code that - * locks sounds won't accidentally unlock a sound that is already playing, but - * since it's Sounds[soundno] is different, it would erroneously be unlocked. - * - * Revision 1.81 1995/02/02 21:56:39 matt - * Added data for new gauge bitmaps - * - * Revision 1.80 1995/02/01 23:31:57 john - * Took out loading bar. - * - * Revision 1.79 1995/01/28 15:13:18 allender - * bumped up Piggy_bitmap_cache_size - * - * Revision 1.78 1995/01/26 12:30:43 john - * Took out prev. - * - * Revision 1.77 1995/01/26 12:12:17 john - * Made buffer be big for bitmaps. - * - * Revision 1.76 1995/01/25 20:15:38 john - * Made editor allocate all mem. - * - * Revision 1.75 1995/01/25 14:52:56 john - * Made bitmap buffer be 1.5 MB. - * - * Revision 1.74 1995/01/22 16:03:19 mike - * localization. - * - * Revision 1.73 1995/01/22 15:58:36 mike - * localization - * - * Revision 1.72 1995/01/18 20:51:20 john - * Took out warnings. - * - * Revision 1.71 1995/01/18 20:47:21 john - * Added code to allocate sounds & bitmaps into diff - * buffers, also made sounds not be compressed for registered. - * - * Revision 1.70 1995/01/18 15:08:41 john - * Added start/stop time around paging. - * Made paging clear screen around globe. - * - * Revision 1.69 1995/01/18 10:07:51 john - * - * Took out debugging mprintfs. - * - * Revision 1.68 1995/01/17 14:27:42 john - * y - * - * Revision 1.67 1995/01/17 12:14:39 john - * Made walls, object explosion vclips load at level start. - * - * Revision 1.66 1995/01/15 13:15:44 john - * Made so that paging always happens, lowmem just loads less. - * Also, make KB load print to hud. - * - * Revision 1.65 1995/01/15 11:56:28 john - * Working version of paging. - * - * Revision 1.64 1995/01/14 19:17:07 john - * First version of new bitmap paging code. - * - * Revision 1.63 1994/12/15 12:26:44 john - * Added -nolowmem function. - * - * Revision 1.62 1994/12/14 21:12:26 john - * Fixed bug with page fault when exiting and using - * -nosound. - * - * Revision 1.61 1994/12/14 11:35:31 john - * Evened out thermometer for pig read. - * - * Revision 1.60 1994/12/14 10:51:00 john - * Sped up sound loading. - * - * Revision 1.59 1994/12/14 10:12:08 john - * Sped up pig loading. - * - * Revision 1.58 1994/12/13 09:14:47 john - * *** empty log message *** - * - * Revision 1.57 1994/12/13 09:12:57 john - * Made the bar always fill up. - * - * Revision 1.56 1994/12/13 03:49:08 john - * Made -lowmem not load the unnecessary bitmaps. - * - * Revision 1.55 1994/12/06 16:06:35 john - * Took out piggy sorting. - * - * Revision 1.54 1994/12/06 15:11:14 john - * Fixed bug with reading pigs. - * - * Revision 1.53 1994/12/06 14:14:47 john - * Added code to set low mem based on memory. - * - * Revision 1.52 1994/12/06 14:01:10 john - * Fixed bug that was causing -lowmem all the time.. - * - * Revision 1.51 1994/12/06 13:33:48 john - * Added lowmem option. - * - * Revision 1.50 1994/12/05 19:40:10 john - * If -nosound or no sound card selected, don't load sounds from pig. - * - * Revision 1.49 1994/12/05 12:17:44 john - * Added code that locks/unlocks digital sounds on demand. - * - * Revision 1.48 1994/12/05 11:39:03 matt - * Fixed little mistake - * - * Revision 1.47 1994/12/05 09:29:22 john - * Added clength to the sound field. - * - * Revision 1.46 1994/12/04 15:27:15 john - * Fixed my stupid bug that looked at -nosound instead of digi_driver_card - * to see whether or not to lock down sound memory. - * - * Revision 1.45 1994/12/03 14:17:00 john - * Took out my debug mprintf. - * - * Revision 1.44 1994/12/03 13:32:37 john - * Fixed bug with offscreen bitmap. - * - * Revision 1.43 1994/12/03 13:07:13 john - * Made the pig read/write compressed sounds. - * - * Revision 1.42 1994/12/03 11:48:51 matt - * Added option to not dump sounds to pigfile - * - * Revision 1.41 1994/12/02 20:02:20 matt - * Made sound files constant match constant for table - * - * Revision 1.40 1994/11/29 11:03:09 adam - * upped # of sounds - * - * Revision 1.39 1994/11/27 23:13:51 matt - * Made changes for new mprintf calling convention - * - * Revision 1.38 1994/11/20 18:40:34 john - * MAde the piggy.lst and piggy.all not dump for release. - * - * Revision 1.37 1994/11/19 23:54:45 mike - * up number of bitmaps for shareware version. - * - * Revision 1.36 1994/11/19 19:53:05 mike - * change MAX_BITMAP_FILES - * - * Revision 1.35 1994/11/19 10:42:56 matt - * Increased number of bitmaps for non-shareware version - * - * Revision 1.34 1994/11/19 09:11:52 john - * Added avg_color to bitmaps saved in pig. - * - * Revision 1.33 1994/11/19 00:07:05 john - * Fixed bug with 8 char sound filenames not getting read from pig. - * - * Revision 1.32 1994/11/18 22:24:54 john - * Added -bigpig command line that doesn't rle your pig. - * - * Revision 1.31 1994/11/18 21:56:53 john - * Added a better, leaner pig format. - * - * Revision 1.30 1994/11/16 12:06:16 john - * Fixed bug with calling .bbms abms. - * - * Revision 1.29 1994/11/16 12:00:56 john - * Added piggy.all dump. - * - * Revision 1.28 1994/11/10 21:16:02 adam - * nothing important - * - * Revision 1.27 1994/11/10 13:42:00 john - * Made sounds not lock down if using -nosound. - * - * Revision 1.26 1994/11/09 19:55:40 john - * Added full rle support with texture rle caching. - * - * Revision 1.25 1994/11/09 16:36:42 john - * First version with RLE bitmaps in Pig. - * - * Revision 1.24 1994/10/27 19:42:59 john - * Disable the piglet option. - * - * Revision 1.23 1994/10/27 18:51:40 john - * Added -piglet option that only loads needed textures for a - * mine. Only saved ~1MB, and code still doesn't free textures - * before you load a new mine. - * - * Revision 1.22 1994/10/25 13:11:42 john - * Made the sounds sort. Dumped piggy.lst. - * - * Revision 1.21 1994/10/06 17:06:23 john - * Took out rle stuff. - * - * Revision 1.20 1994/10/06 15:45:36 adam - * bumped MAX_BITMAP_FILES again! - * - * Revision 1.19 1994/10/06 11:01:17 yuan - * Upped MAX_BITMAP_FILES - * - * Revision 1.18 1994/10/06 10:44:45 john - * Added diagnostic message and psuedo run-length-encoder - * to see how much memory we would save by storing bitmaps - * in a RLE method. Also, I commented out the code that - * stores 4K bitmaps on a 4K boundry to reduce pig size - * a bit. - * - * Revision 1.17 1994/10/04 20:03:13 matt - * Upped maximum number of bitmaps - * - * Revision 1.16 1994/10/03 18:04:20 john - * Fixed bug with data_offset not set right for bitmaps - * that are 64x64 and not aligned on a 4k boundry. - * - * Revision 1.15 1994/09/28 11:30:55 john - * changed inferno.pig to descent.pig, changed the way it - * is read. - * - * Revision 1.14 1994/09/22 16:14:17 john - * Redid intro sequecing. - * - * Revision 1.13 1994/09/19 14:42:47 john - * Locked down sounds with Virtual memory. - * - * Revision 1.12 1994/09/10 17:31:52 mike - * Increase number of loadable bitmaps. - * - * Revision 1.11 1994/09/01 19:32:49 mike - * Boost texture map allocation. - * - * Revision 1.10 1994/08/16 11:51:02 john - * Added grwased pigs. - * - * Revision 1.9 1994/07/06 09:18:03 adam - * upped bitmap #s - * - * Revision 1.8 1994/06/20 22:02:15 matt - * Fixed bug from last change - * - * Revision 1.7 1994/06/20 21:33:18 matt - * Made bm.h not include sounds.h, to reduce dependencies - * - * Revision 1.6 1994/06/20 16:52:19 john - * cleaned up init output a bit. - * - * Revision 1.5 1994/06/08 14:20:57 john - * Made piggy dump before going into game. - * - * Revision 1.4 1994/06/02 18:59:22 matt - * Clear selector field of bitmap loaded from pig file - * - * Revision 1.3 1994/05/06 15:31:41 john - * Made name field a bit longer. - * - * Revision 1.2 1994/05/06 13:02:44 john - * Added piggy stuff; worked on supertransparency - * - * Revision 1.1 1994/05/06 11:47:26 john - * Initial revision - * - * - */ - - #ifdef HAVE_CONFIG_H #include #endif #ifdef RCS -static char rcsid[] = "$Id: piggy.c,v 1.31 2003-03-29 22:35:00 btb Exp $"; +static char rcsid[] = "$Id: piggy.c,v 1.7 2001-11-14 09:34:32 bradleyb Exp $"; #endif @@ -430,35 +60,31 @@ static char rcsid[] = "$Id: piggy.c,v 1.31 2003-03-29 22:35:00 btb Exp $"; #include #endif -//#define NO_DUMP_SOUNDS 1 //if set, dump bitmaps but not sounds +//#define NO_DUMP_SOUNDS 1 //if set, dump bitmaps but not sounds #define DEFAULT_PIGFILE_REGISTERED "groupa.pig" #define DEFAULT_PIGFILE_SHAREWARE "d2demo.pig" -#define DEFAULT_HAMFILE_REGISTERED "descent2.ham" -#define DEFAULT_HAMFILE_SHAREWARE "d2demo.ham" - -#define D1_PALETTE "palette.256" -#define DEFAULT_PIGFILE (cfexist(DEFAULT_PIGFILE_REGISTERED)?DEFAULT_PIGFILE_REGISTERED:DEFAULT_PIGFILE_SHAREWARE) -#define DEFAULT_HAMFILE (cfexist(DEFAULT_HAMFILE_REGISTERED)?DEFAULT_HAMFILE_REGISTERED:DEFAULT_HAMFILE_SHAREWARE) -#define DEFAULT_SNDFILE ((Piggy_hamfile_version < 3)?DEFAULT_HAMFILE_SHAREWARE:(digi_sample_rate==SAMPLE_RATE_22K)?"descent2.s22":"descent2.s11") -#define MAC_ALIEN1_PIGSIZE 5013035 -#define MAC_ALIEN2_PIGSIZE 4909916 -#define MAC_FIRE_PIGSIZE 4969035 -#define MAC_GROUPA_PIGSIZE 4929684 // also used for mac shareware -#define MAC_ICE_PIGSIZE 4923425 -#define MAC_WATER_PIGSIZE 4832403 +#ifdef SHAREWARE + #define DEFAULT_HAMFILE "d2demo.ham" + #define DEFAULT_PIGFILE DEFAULT_PIGFILE_SHAREWARE + #define DEFAULT_SNDFILE "descent2.s11" +#else + #define DEFAULT_HAMFILE "descent2.ham" + #define DEFAULT_PIGFILE DEFAULT_PIGFILE_REGISTERED + #define DEFAULT_SNDFILE ((digi_sample_rate==SAMPLE_RATE_22K)?"descent2.s22":"descent2.s11") +#endif // end of ifdef SHAREWARE ubyte *BitmapBits = NULL; ubyte *SoundBits = NULL; -typedef struct BitmapFile { - char name[15]; +typedef struct BitmapFile { + char name[15]; } BitmapFile; -typedef struct SoundFile { - char name[15]; +typedef struct SoundFile { + char name[15]; } SoundFile; hashtable AllBitmapsNames; @@ -480,8 +106,6 @@ int Num_sound_files_new = 0; BitmapFile AllBitmaps[ MAX_BITMAP_FILES ]; static SoundFile AllSounds[ MAX_SOUND_FILES ]; -int Piggy_hamfile_version = 0; - int piggy_low_memory = 0; int Piggy_bitmap_cache_size = 0; @@ -510,6 +134,24 @@ int piggy_page_flushed = 0; #define DBM_FLAG_ABM 64 +typedef struct DiskBitmapHeader { + char name[8]; + ubyte dflags; //bits 0-5 anim frame num, bit 6 abm flag + ubyte width; //low 8 bits here, 4 more bits in wh_extra + ubyte height; //low 8 bits here, 4 more bits in wh_extra + ubyte wh_extra; //bits 0-3 width, bits 4-7 height + ubyte flags; + ubyte avg_color; + int offset; +} __pack__ DiskBitmapHeader; + +typedef struct DiskSoundHeader { + char name[8]; + int length; + int data_length; + int offset; +} __pack__ DiskSoundHeader; + ubyte BigPig = 0; #ifdef MACINTOSH @@ -524,7 +166,6 @@ int piggy_is_substitutable_bitmap( char * name, char * subst_name ); #ifdef EDITOR void piggy_write_pigfile(char *filename); static void write_int(int i,FILE *file); -#endif void swap_0_255(grs_bitmap *bmp) { @@ -537,6 +178,7 @@ void swap_0_255(grs_bitmap *bmp) bmp->bm_data[i] = 0; } } +#endif bitmap_index piggy_register_bitmap( grs_bitmap * bmp, char * name, int in_file ) { @@ -901,23 +543,24 @@ void piggy_init_pigfile(char *filename) piggy_close_file(); //close old pig if still open - //rename pigfile for shareware - if (stricmp(DEFAULT_PIGFILE, DEFAULT_PIGFILE_SHAREWARE) == 0 && !cfexist(filename)) + #ifdef SHAREWARE //rename pigfile for shareware + if (stricmp(filename,DEFAULT_PIGFILE_REGISTERED)==0) filename = DEFAULT_PIGFILE_SHAREWARE; + #endif #ifndef MACINTOSH Piggy_fp = cfopen( filename, "rb" ); #else sprintf(name, ":Data:%s", filename); Piggy_fp = cfopen( name, "rb" ); - + #ifdef SHAREWARE // if we are in the shareware version, we must have the pig by now. if (Piggy_fp == NULL) { Error("Cannot load required file <%s>",name); } #endif // end of if def shareware - + #endif if (!Piggy_fp) { @@ -952,7 +595,7 @@ void piggy_init_pigfile(char *filename) N_bitmaps = cfile_read_int(Piggy_fp); - header_size = N_bitmaps*DISKBITMAPHEADER_SIZE; + header_size = N_bitmaps*sizeof(DiskBitmapHeader); data_start = header_size + cftell(Piggy_fp); @@ -961,7 +604,18 @@ void piggy_init_pigfile(char *filename) Num_bitmap_files = 1; for (i=0; iavg_color = compute_average_pixel(bm[fnum]); #ifdef EDITOR @@ -1232,7 +898,7 @@ void piggy_new_pigfile(char *pigname) mprintf((1, "File %s - IFF error: %s",bbmname,iff_errormsg(iff_error))); Error("File %s - IFF error: %s",bbmname,iff_errormsg(iff_error)); } - + SuperX = (GameBitmapFlags[i]&BM_FLAG_SUPER_TRANSPARENT)?254:-1; //above makes assumption that supertransparent color is 254 @@ -1240,12 +906,12 @@ void piggy_new_pigfile(char *pigname) gr_remap_bitmap_good( new, newpal, iff_transparent_color, SuperX ); else gr_remap_bitmap_good( new, newpal, -1, SuperX ); - + new->avg_color = compute_average_pixel(new); - + #ifdef EDITOR - if ( FindArg("-macdata") ) - swap_0_255( new ); + if ( FindArg("-macdata") ) + swap_0_255( new ); #endif if ( !BigPig ) gr_bitmap_rle_compress( new ); @@ -1279,7 +945,7 @@ void piggy_new_pigfile(char *pigname) piggy_write_pigfile(pigname); Current_pigfile[0] = 0; //say no pig, to force reload - + piggy_new_pigfile(pigname); //read in just-generated pig @@ -1293,8 +959,14 @@ grs_bitmap bogus_bitmap; ubyte bogus_bitmap_initialized=0; digi_sound bogus_sound; +extern void bm_read_all(CFILE * fp); + #define HAMFILE_ID MAKE_SIG('!','M','A','H') //HAM! +#ifdef SHAREWARE +#define HAMFILE_VERSION 2 +#else #define HAMFILE_VERSION 3 +#endif //version 1 -> 2: save marker_model_num //version 2 -> 3: removed sound files @@ -1304,19 +976,18 @@ digi_sound bogus_sound; int read_hamfile() { CFILE * ham_fp = NULL; - int ham_id; - int sound_offset = 0; + int ham_id,ham_version; #ifdef MACINTOSH char name[255]; #endif - + #ifndef MACINTOSH ham_fp = cfopen( DEFAULT_HAMFILE, "rb" ); #else sprintf(name, ":Data:%s", DEFAULT_HAMFILE ); ham_fp = cfopen( name, "rb" ); #endif - + if (ham_fp == NULL) { Must_write_hamfile = 1; return 0; @@ -1324,77 +995,30 @@ int read_hamfile() //make sure ham is valid type file & is up-to-date ham_id = cfile_read_int(ham_fp); - Piggy_hamfile_version = cfile_read_int(ham_fp); - if (ham_id != HAMFILE_ID) - Error("Cannot open ham file %s\n", DEFAULT_HAMFILE); -#if 0 - if (ham_id != HAMFILE_ID || Piggy_hamfile_version != HAMFILE_VERSION) { + ham_version = cfile_read_int(ham_fp); + if (ham_id != HAMFILE_ID || ham_version != HAMFILE_VERSION) { Must_write_hamfile = 1; cfclose(ham_fp); //out of date ham return 0; } -#endif - if (Piggy_hamfile_version < 3) // hamfile contains sound info - sound_offset = cfile_read_int(ham_fp); + if (ham_version < 3) //mystery value + cfseek(ham_fp, 4, SEEK_CUR); #ifndef EDITOR { - //int i; - - bm_read_all(ham_fp); + bm_read_all( ham_fp ); // Note connection to above if!!! cfread( GameBitmapXlat, sizeof(ushort)*MAX_BITMAP_FILES, 1, ham_fp ); - // no swap here? - //for (i = 0; i < MAX_BITMAP_FILES; i++) { - //GameBitmapXlat[i] = INTEL_SHORT(GameBitmapXlat[i]); - //printf("GameBitmapXlat[%d] = %d\n", i, GameBitmapXlat[i]); - //} - } - #endif - - if (Piggy_hamfile_version < 3) { - int N_sounds; - int sound_start; - int header_size; - int i; - DiskSoundHeader sndh; - digi_sound temp_sound; - char temp_name_read[16]; - int sbytes = 0; - - cfseek(ham_fp, sound_offset, SEEK_SET); - N_sounds = cfile_read_int(ham_fp); - - sound_start = cftell(ham_fp); - - header_size = N_sounds * DISKSOUNDHEADER_SIZE; - - //Read sounds - - for (i=0; icv_h-20, "%s...", TXT_LOADING_DATA ); WIN(DDGRUNLOCK(dd_grd_curcanv)); - -#if 1 //def EDITOR //need for d1 mission briefings + + #ifdef EDITOR piggy_init_pigfile(DEFAULT_PIGFILE); -#endif + #endif - snd_ok = ham_ok = read_hamfile(); + ham_ok = read_hamfile(); - if (Piggy_hamfile_version >= 3) - snd_ok = read_sndfile(); + snd_ok = read_sndfile(); atexit(piggy_close); - mprintf ((0,"HamOk=%d SndOk=%d\n",ham_ok,snd_ok)); + mprintf ((0,"HamOk=%d SndOk=%d\n",ham_ok,snd_ok)); return (ham_ok && snd_ok); //read ok } @@ -1589,7 +1216,7 @@ void piggy_read_sounds(void) if ( SoundOffset[i] > 0 ) { if ( piggy_is_needed(i) ) { cfseek( fp, SoundOffset[i], SEEK_SET ); - + // Read in the sound data!!! snd->data = ptr; ptr += snd->length; @@ -1636,8 +1263,8 @@ void piggy_bitmap_page_in( bitmap_index bitmap ) grs_bitmap * bmp; int i,org_i,temp; - org_i = 0; - + org_i = 0; + i = bitmap.index; Assert( i >= 0 ); Assert( i < MAX_BITMAP_FILES ); @@ -1647,14 +1274,14 @@ void piggy_bitmap_page_in( bitmap_index bitmap ) if ( i < 1 ) return; if ( i >= MAX_BITMAP_FILES ) return; if ( i >= Num_bitmap_files ) return; - - if ( GameBitmapOffset[i] == 0 ) return; // A read-from-disk bitmap!!! + + if ( GameBitmapOffset[i] == 0 ) return; // A read-from-disk bitmap!!! if ( piggy_low_memory ) { org_i = i; i = GameBitmapXlat[i]; // Xlat for low-memory settings! } - + bmp = &GameBitmaps[i]; if ( bmp->bm_flags & BM_FLAG_PAGED_OUT ) { @@ -1667,10 +1294,10 @@ void piggy_bitmap_page_in( bitmap_index bitmap ) piggy_critical_error(); goto ReDoIt; } - + bmp->bm_data = &Piggy_bitmap_cache_data[Piggy_bitmap_cache_next]; bmp->bm_flags = GameBitmapFlags[i]; - + if ( bmp->bm_flags & BM_FLAG_RLE ) { int zsize = 0; descent_critical_error = 0; @@ -1679,50 +1306,26 @@ void piggy_bitmap_page_in( bitmap_index bitmap ) piggy_critical_error(); goto ReDoIt; } - + // GET JOHN NOW IF YOU GET THIS ASSERT!!! - //Assert( Piggy_bitmap_cache_next+zsize < Piggy_bitmap_cache_size ); + //Assert( Piggy_bitmap_cache_next+zsize < Piggy_bitmap_cache_size ); if ( Piggy_bitmap_cache_next+zsize >= Piggy_bitmap_cache_size ) { Int3(); piggy_bitmap_page_out_all(); goto ReDoIt; } + memcpy( &Piggy_bitmap_cache_data[Piggy_bitmap_cache_next], &zsize, sizeof(int) ); + Piggy_bitmap_cache_next += sizeof(int); descent_critical_error = 0; - temp = cfread( &Piggy_bitmap_cache_data[Piggy_bitmap_cache_next+4], 1, zsize-4, Piggy_fp ); + temp = cfread( &Piggy_bitmap_cache_data[Piggy_bitmap_cache_next], 1, zsize-4, Piggy_fp ); if ( descent_critical_error ) { piggy_critical_error(); goto ReDoIt; } - -#ifndef MACDATA - switch (cfilelength(Piggy_fp)) { - default: - if (!FindArg("-macdata")) - break; - // otherwise, fall through... - case MAC_ALIEN1_PIGSIZE: - case MAC_ALIEN2_PIGSIZE: - case MAC_FIRE_PIGSIZE: - case MAC_GROUPA_PIGSIZE: - case MAC_ICE_PIGSIZE: - case MAC_WATER_PIGSIZE: - rle_swap_0_255( bmp ); - memcpy(&zsize, bmp->bm_data, 4); - break; - } -#endif - - memcpy( &Piggy_bitmap_cache_data[Piggy_bitmap_cache_next], &zsize, sizeof(int) ); - Piggy_bitmap_cache_next += zsize; - if ( Piggy_bitmap_cache_next+zsize >= Piggy_bitmap_cache_size ) { - Int3(); - piggy_bitmap_page_out_all(); - goto ReDoIt; - } - + Piggy_bitmap_cache_next += zsize-4; } else { // GET JOHN NOW IF YOU GET THIS ASSERT!!! - Assert( Piggy_bitmap_cache_next+(bmp->bm_h*bmp->bm_w) < Piggy_bitmap_cache_size ); + Assert( Piggy_bitmap_cache_next+(bmp->bm_h*bmp->bm_w) < Piggy_bitmap_cache_size ); if ( Piggy_bitmap_cache_next+(bmp->bm_h*bmp->bm_w) >= Piggy_bitmap_cache_size ) { piggy_bitmap_page_out_all(); goto ReDoIt; @@ -1734,25 +1337,8 @@ void piggy_bitmap_page_in( bitmap_index bitmap ) goto ReDoIt; } Piggy_bitmap_cache_next+=bmp->bm_h*bmp->bm_w; - -#ifndef MACDATA - switch (cfilelength(Piggy_fp)) { - default: - if (!FindArg("-macdata")) - break; - // otherwise, fall through... - case MAC_ALIEN1_PIGSIZE: - case MAC_ALIEN2_PIGSIZE: - case MAC_FIRE_PIGSIZE: - case MAC_GROUPA_PIGSIZE: - case MAC_ICE_PIGSIZE: - case MAC_WATER_PIGSIZE: - swap_0_255( bmp ); - break; - } -#endif } - + //@@if ( bmp->bm_selector ) { //@@#if !defined(WINDOWS) && !defined(MACINTOSH) //@@ if (!dpmi_modify_selector_base( bmp->bm_selector, bmp->bm_data )) @@ -1843,7 +1429,7 @@ void piggy_write_pigfile(char *filename) Num_bitmap_files++; bitmap_data_start = ftell(pig_fp); - bitmap_data_start += (Num_bitmap_files-1)*DISKBITMAPHEADER_SIZE; + bitmap_data_start += (Num_bitmap_files-1)*sizeof(DiskBitmapHeader); data_offset = bitmap_data_start; change_filename_ext(tname,filename,"lst"); @@ -1917,7 +1503,7 @@ void piggy_write_pigfile(char *filename) bmh.flags &= ~BM_FLAG_PAGED_OUT; } bmh.avg_color=GameBitmaps[i].avg_color; - fwrite( &bmh, DISKBITMAPHEADER_SIZE, 1, pig_fp ); // Mark as a bitmap + fwrite( &bmh, sizeof(DiskBitmapHeader), 1, pig_fp ); // Mark as a bitmap } fclose(pig_fp); @@ -2144,420 +1730,7 @@ void piggy_bitmap_page_out_all_w() { } -#endif // WINDOWS - - -/* - * Functions for loading replacement textures - * 1) From .pog files - * 2) From descent.pig (for loading d1 levels) - */ - -extern void change_filename_extension( char *dest, char *src, char *new_ext ); -extern char last_palette_loaded_pig[]; - -ubyte *Bitmap_replacement_data=NULL; - -void free_bitmap_replacements() -{ - if (Bitmap_replacement_data) { - d_free(Bitmap_replacement_data); - Bitmap_replacement_data = NULL; - } -} - -void load_bitmap_replacements(char *level_name) -{ - char ifile_name[FILENAME_LEN]; - CFILE *ifile; - int i; - - //first, free up data allocated for old bitmaps - free_bitmap_replacements(); - - change_filename_extension(ifile_name, level_name, ".POG" ); - - ifile = cfopen(ifile_name,"rb"); - - if (ifile) { - int id,version,n_bitmaps; - int bitmap_data_size; - ushort *indices; - - id = cfile_read_int(ifile); - version = cfile_read_int(ifile); - - if (id != MAKE_SIG('G','O','P','D') || version != 1) { - cfclose(ifile); - return; - } - - n_bitmaps = cfile_read_int(ifile); - - MALLOC( indices, ushort, n_bitmaps ); - - for (i = 0; i < n_bitmaps; i++) - indices[i] = cfile_read_short(ifile); - - bitmap_data_size = cfilelength(ifile) - cftell(ifile) - DISKBITMAPHEADER_SIZE * n_bitmaps; - MALLOC( Bitmap_replacement_data, ubyte, bitmap_data_size ); - - for (i=0;i= FIRST_D1_TEXTURE && d1_index <= LAST_D1_STATIC_TEXTURE) { - d2_index = d1_index + FIRST_D2_TEXTURE - FIRST_D1_TEXTURE; - - cfseek(d1_Piggy_fp, bitmap_header_start + (d1_index-1) * DISKBITMAPHEADER_D1_SIZE, SEEK_SET); - DiskBitmapHeader_d1_read(&bmh, d1_Piggy_fp); - - memset( &temp_bitmap, 0, sizeof(grs_bitmap) ); - - temp_bitmap.bm_w = temp_bitmap.bm_rowsize = bmh.width + ((short) (bmh.wh_extra&0x0f)<<8); - temp_bitmap.bm_h = bmh.height + ((short) (bmh.wh_extra&0xf0)<<4); - temp_bitmap.avg_color = bmh.avg_color; - - //GameBitmapFlags[convert_d1_bitmap_num(d1_index)] = 0; - - if ( bmh.flags & BM_FLAG_TRANSPARENT ) - temp_bitmap.bm_flags |= BM_FLAG_TRANSPARENT; - if ( bmh.flags & BM_FLAG_SUPER_TRANSPARENT ) - temp_bitmap.bm_flags |= BM_FLAG_SUPER_TRANSPARENT; - if ( bmh.flags & BM_FLAG_NO_LIGHTING ) - temp_bitmap.bm_flags |= BM_FLAG_NO_LIGHTING; - if ( bmh.flags & BM_FLAG_RLE ) - temp_bitmap.bm_flags |= BM_FLAG_RLE; - if ( bmh.flags & BM_FLAG_RLE_BIG ) - temp_bitmap.bm_flags |= BM_FLAG_RLE_BIG; - - temp_bitmap.bm_data = next_bitmap; - - cfseek(d1_Piggy_fp, bitmap_data_start + bmh.offset, SEEK_SET); - zsize = cfile_read_int(d1_Piggy_fp); - cfseek(d1_Piggy_fp, bitmap_data_start + bmh.offset, SEEK_SET); - cfread(next_bitmap, 1, zsize, d1_Piggy_fp); - - switch(cfilelength(d1_Piggy_fp)) { - case D1_MAC_PIGSIZE: - case D1_MAC_SHARE_PIGSIZE: - rle_swap_0_255(&temp_bitmap); - } - rle_remap(&temp_bitmap, colormap); - - GameBitmaps[d2_index] = temp_bitmap; - - memcpy(&zsize, temp_bitmap.bm_data, 4); - next_bitmap += zsize; - } - } - - cfclose(d1_Piggy_fp); - - last_palette_loaded_pig[0]= 0; //force pig re-load - - texmerge_flush(); //for re-merging with new textures - - atexit(free_bitmap_replacements); -} - - -extern int extra_bitmap_num; - -/* - * Find and load the named bitmap from descent.pig - * similar to read_extra_bitmap_iff - */ -bitmap_index read_extra_bitmap_d1_pig(char *name) -{ - bitmap_index bitmap_num; - grs_bitmap * new = &GameBitmaps[extra_bitmap_num]; - - bitmap_num.index = 0; - - { - CFILE *d1_Piggy_fp; - int i; - DiskBitmapHeader bmh; - int pig_data_start, bitmap_header_start, bitmap_data_start; - int N_bitmaps, zsize; - ubyte colormap[256]; - - d1_Piggy_fp = cfopen(D1_PIGFILE, "rb"); - if (!d1_Piggy_fp) - { - con_printf(CON_DEBUG, "could not open %s\n", D1_PIGFILE); - return bitmap_num; - } - - // read d1 palette, build colormap - { - int freq[256]; - ubyte d1_palette[256*3]; - CFILE * palette_file = cfopen(D1_PALETTE, "rb"); - if (!palette_file || cfilelength(palette_file) != 9472) - { - con_printf(CON_DEBUG, "could not open %s\n", D1_PALETTE); - return bitmap_num; - } - cfread( d1_palette, 256, 3, palette_file); - cfclose( palette_file ); - build_colormap_good( d1_palette, colormap, freq ); - // don't change transparencies: - colormap[254] = 254; - colormap[255] = 255; - } - - switch (cfilelength(d1_Piggy_fp)) { - case D1_SHAREWARE_10_PIGSIZE: - case D1_SHAREWARE_PIGSIZE: - pig_data_start = 0; - break; - default: - Int3(); - case D1_PIGSIZE: - case D1_OEM_PIGSIZE: - case D1_MAC_PIGSIZE: - case D1_MAC_SHARE_PIGSIZE: - pig_data_start = cfile_read_int(d1_Piggy_fp); - break; - } - - cfseek(d1_Piggy_fp, pig_data_start, SEEK_SET); - N_bitmaps = cfile_read_int(d1_Piggy_fp); - { - int N_sounds = cfile_read_int(d1_Piggy_fp); - int header_size = N_bitmaps * DISKBITMAPHEADER_D1_SIZE - + N_sounds * DISKSOUNDHEADER_SIZE; - bitmap_header_start = pig_data_start + 2 * sizeof(int); - bitmap_data_start = bitmap_header_start + header_size; - } - - for (i = 0; i < N_bitmaps; i++) - { - DiskBitmapHeader_d1_read(&bmh, d1_Piggy_fp); - if (!strnicmp(bmh.name, name, 8)) - break; - } - - if (strnicmp(bmh.name, name, 8)) - { - con_printf(CON_DEBUG, "could not find bitmap %s\n", name); - return bitmap_num; - } - - memset( new, 0, sizeof(grs_bitmap) ); - - new->bm_w = new->bm_rowsize = bmh.width + ((short) (bmh.wh_extra&0x0f)<<8); - new->bm_h = bmh.height + ((short) (bmh.wh_extra&0xf0)<<4); - new->avg_color = bmh.avg_color; - - if ( bmh.flags & BM_FLAG_TRANSPARENT ) - new->bm_flags |= BM_FLAG_TRANSPARENT; - if ( bmh.flags & BM_FLAG_SUPER_TRANSPARENT ) - new->bm_flags |= BM_FLAG_SUPER_TRANSPARENT; - if ( bmh.flags & BM_FLAG_NO_LIGHTING ) - new->bm_flags |= BM_FLAG_NO_LIGHTING; - if ( bmh.flags & BM_FLAG_RLE ) - new->bm_flags |= BM_FLAG_RLE; - if ( bmh.flags & BM_FLAG_RLE_BIG ) - new->bm_flags |= BM_FLAG_RLE_BIG; - - if ( bmh.flags & BM_FLAG_RLE ) - { - cfseek(d1_Piggy_fp, bitmap_data_start + bmh.offset, SEEK_SET); - zsize = cfile_read_int(d1_Piggy_fp); - } - else - zsize = new->bm_w * new->bm_h; - new->bm_data = d_malloc(zsize); - cfseek(d1_Piggy_fp, bitmap_data_start + bmh.offset, SEEK_SET); - cfread(new->bm_data, 1, zsize, d1_Piggy_fp); - - switch(cfilelength(d1_Piggy_fp)) { - case D1_MAC_PIGSIZE: - case D1_MAC_SHARE_PIGSIZE: - rle_swap_0_255(new); - } - rle_remap(new, colormap); - - cfclose(d1_Piggy_fp); - } - - new->avg_color = 0; //compute_average_pixel(new); - - bitmap_num.index = extra_bitmap_num; - - GameBitmaps[extra_bitmap_num++] = *new; - - return bitmap_num; -} - - -#ifndef FAST_FILE_IO -/* - * reads a bitmap_index structure from a CFILE - */ -void bitmap_index_read(bitmap_index *bi, CFILE *fp) -{ - bi->index = cfile_read_short(fp); -} - -/* - * reads n bitmap_index structs from a CFILE - */ -int bitmap_index_read_n(bitmap_index *bi, int n, CFILE *fp) -{ - int i; - - for (i = 0; i < n; i++) - bi[i].index = cfile_read_short(fp); - return i; -} -/* - * reads a DiskBitmapHeader structure from a CFILE - */ -void DiskBitmapHeader_read(DiskBitmapHeader *dbh, CFILE *fp) -{ - cfread(dbh->name, 8, 1, fp); - dbh->dflags = cfile_read_byte(fp); - dbh->width = cfile_read_byte(fp); - dbh->height = cfile_read_byte(fp); - dbh->wh_extra = cfile_read_byte(fp); - dbh->flags = cfile_read_byte(fp); - dbh->avg_color = cfile_read_byte(fp); - dbh->offset = cfile_read_int(fp); -} +#endif -/* - * reads a DiskSoundHeader structure from a CFILE - */ -void DiskSoundHeader_read(DiskSoundHeader *dsh, CFILE *fp) -{ - cfread(dsh->name, 8, 1, fp); - dsh->length = cfile_read_int(fp); - dsh->data_length = cfile_read_int(fp); - dsh->offset = cfile_read_int(fp); -} -#endif // FAST_FILE_IO -/* - * reads a descent 1 DiskBitmapHeader structure from a CFILE - */ -void DiskBitmapHeader_d1_read(DiskBitmapHeader *dbh, CFILE *fp) -{ - cfread(dbh->name, 8, 1, fp); - dbh->dflags = cfile_read_byte(fp); - dbh->width = cfile_read_byte(fp); - dbh->height = cfile_read_byte(fp); - dbh->wh_extra = 0; - dbh->flags = cfile_read_byte(fp); - dbh->avg_color = cfile_read_byte(fp); - dbh->offset = cfile_read_int(fp); -} diff --git a/main/piggy.h b/main/piggy.h index efa3a0e0..bf48e44e 100644 --- a/main/piggy.h +++ b/main/piggy.h @@ -1,4 +1,3 @@ -/* $Id: piggy.h,v 1.16 2003-03-29 22:35:00 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,26 +7,18 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ + + #ifndef _PIGGY_H #define _PIGGY_H #include "digi.h" #include "sounds.h" #include "inferno.h" -#include "cfile.h" - -#define D1_PIGFILE "descent.pig" - -#define D1_SHAREWARE_10_PIGSIZE 2529454 // v1.0 - 1.2 -#define D1_SHAREWARE_PIGSIZE 2509799 // v1.4 -#define D1_PIGSIZE 4920305 -#define D1_OEM_PIGSIZE 5039735 // Destination: Saturn -#define D1_MAC_PIGSIZE 3975533 -#define D1_MAC_SHARE_PIGSIZE 2714487 #define MAX_ALIASES 20 @@ -39,36 +30,10 @@ typedef struct alias { extern alias alias_list[MAX_ALIASES]; extern int Num_aliases; -extern int Piggy_hamfile_version; - -// an index into the bitmap collection of the piggy file typedef struct bitmap_index { - ushort index; + ushort index; } __pack__ bitmap_index; -typedef struct DiskBitmapHeader { - char name[8]; - ubyte dflags; //bits 0-5 anim frame num, bit 6 abm flag - ubyte width; //low 8 bits here, 4 more bits in wh_extra - ubyte height; //low 8 bits here, 4 more bits in wh_extra - ubyte wh_extra; //bits 0-3 width, bits 4-7 height - ubyte flags; - ubyte avg_color; - int offset; -} __pack__ DiskBitmapHeader; - -#define DISKBITMAPHEADER_SIZE 18 // for disk i/o -#define DISKBITMAPHEADER_D1_SIZE 17 // for disk i/o - -typedef struct DiskSoundHeader { - char name[8]; - int length; - int data_length; - int offset; -} __pack__ DiskSoundHeader; - -#define DISKSOUNDHEADER_SIZE 20 // for disk i/o - int piggy_init(); void piggy_close(); void piggy_dump_all(); @@ -80,12 +45,12 @@ int piggy_find_sound( char * name ); extern int Pigfile_initialized; void piggy_read_bitmap_data(grs_bitmap * bmp); -void piggy_read_sound_data(digi_sound *snd); +void piggy_read_sound_data(digi_sound *snd); void piggy_load_level_data(); -#define MAX_BITMAP_FILES 2620 // Upped for CD Enhanced -#define MAX_SOUND_FILES MAX_SOUNDS +#define MAX_BITMAP_FILES 2620 // Upped for CD Enhanced +#define MAX_SOUND_FILES MAX_SOUNDS extern digi_sound GameSounds[MAX_SOUND_FILES]; extern grs_bitmap GameBitmaps[MAX_BITMAP_FILES]; @@ -106,7 +71,7 @@ static inline void _piggy_page_in(bitmap_index bmp) { } # else /* __GNUC__ */ - + #define PIGGY_PAGE_IN(bmp) \ do { \ if ( GameBitmaps[(bmp).index].bm_flags & BM_FLAG_PAGED_OUT ) {\ @@ -116,7 +81,7 @@ do { \ /* mprintf(( 0, "Paging in '%s' from file '%s', line %d\n", #bmp, __FILE__,__LINE__ )); \ */ # endif /* __GNUC__ */ #else -# define PIGGY_PAGE_IN(bmp) + #define PIGGY_PAGE_IN(bmp) #endif void piggy_read_sounds(); @@ -125,46 +90,4 @@ void piggy_read_sounds(); //returns the size of all the bitmap data void piggy_new_pigfile(char *pigname); -//loads custom bitmaps for current level -void load_bitmap_replacements(char *level_name); -//if descent.pig exists, loads descent 1 texture bitmaps -void load_d1_bitmap_replacements(); - -#ifdef FAST_FILE_IO -#define bitmap_index_read(bi, fp) cfread(bi, sizeof(bitmap_index), 1, fp) -#define bitmap_index_read_n(bi, n, fp) cfread(bi, sizeof(bitmap_index), n, fp) -#define DiskBitmapHeader_read(dbh, fp) cfread(dbh, sizeof(DiskBitmapHeader), 1, fp) -#define DiskSoundHeader_read(dsh, fp) cfread(dsh, sizeof(DiskSoundHeader), 1, fp) -#else -/* - * reads a bitmap_index structure from a CFILE - */ -void bitmap_index_read(bitmap_index *bi, CFILE *fp); - -/* - * reads n bitmap_index structs from a CFILE - */ -int bitmap_index_read_n(bitmap_index *bi, int n, CFILE *fp); - -/* - * reads a DiskBitmapHeader structure from a CFILE - */ -void DiskBitmapHeader_read(DiskBitmapHeader *dbh, CFILE *fp); - -/* - * reads a DiskSoundHeader structure from a CFILE - */ -void DiskSoundHeader_read(DiskSoundHeader *dsh, CFILE *fp); -#endif // FAST_FILE_IO - -/* - * reads a descent 1 DiskBitmapHeader structure from a CFILE - */ -void DiskBitmapHeader_d1_read(DiskBitmapHeader *dbh, CFILE *fp); - -/* - * Find and load the named bitmap from descent.pig - */ -bitmap_index read_extra_bitmap_d1_pig(char *name); - -#endif //_PIGGY_H +#endif diff --git a/main/player.c b/main/player.c deleted file mode 100644 index fb706cfc..00000000 --- a/main/player.c +++ /dev/null @@ -1,32 +0,0 @@ -/* $Id: player.c,v 1.2 2002-07-26 20:23:30 btb Exp $ */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "player.h" -#include "cfile.h" - -#ifdef RCS -static char rcsid[] = "$Id: player.c,v 1.2 2002-07-26 20:23:30 btb Exp $"; -#endif - -/* - * reads a player_ship structure from a CFILE - */ -void player_ship_read(player_ship *ps, CFILE *fp) -{ - int i; - - ps->model_num = cfile_read_int(fp); - ps->expl_vclip_num = cfile_read_int(fp); - ps->mass = cfile_read_fix(fp); - ps->drag = cfile_read_fix(fp); - ps->max_thrust = cfile_read_fix(fp); - ps->reverse_thrust = cfile_read_fix(fp); - ps->brakes = cfile_read_fix(fp); - ps->wiggle = cfile_read_fix(fp); - ps->max_rotthrust = cfile_read_fix(fp); - for (i = 0; i < N_PLAYER_GUNS; i++) - cfile_read_vector(&(ps->gun_points[i]), fp); -} diff --git a/main/player.h b/main/player.h index 38f0032e..1acd5836 100644 --- a/main/player.h +++ b/main/player.h @@ -1,4 +1,3 @@ -/* $Id: player.h,v 1.3 2003-03-01 03:56:55 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,10 +7,12 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ + + #ifndef _PLAYER_H #define _PLAYER_H @@ -24,178 +25,169 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define MAX_MULTI_PLAYERS MAX_PLAYERS+3 // Initial player stat values -#define INITIAL_ENERGY i2f(100) //100% energy to start -#define INITIAL_SHIELDS i2f(100) //100% shields to start +#define INITIAL_ENERGY i2f(100) //100% energy to start +#define INITIAL_SHIELDS i2f(100) //100% shields to start -#define MAX_ENERGY i2f(200) //go up to 200 -#define MAX_SHIELDS i2f(200) +#define MAX_ENERGY i2f(200) //go up to 200 +#define MAX_SHIELDS i2f(200) -#define INITIAL_LIVES 3 //start off with 3 lives +#define INITIAL_LIVES 3 //start off with 3 lives // Values for special flags -#define PLAYER_FLAGS_INVULNERABLE 1 // Player is invincible -#define PLAYER_FLAGS_BLUE_KEY 2 // Player has blue key -#define PLAYER_FLAGS_RED_KEY 4 // Player has red key -#define PLAYER_FLAGS_GOLD_KEY 8 // Player has gold key -#define PLAYER_FLAGS_FLAG 16 // Player has his team's flag -#define PLAYER_FLAGS_UNUSED 32 // -#define PLAYER_FLAGS_MAP_ALL 64 // Player can see unvisited areas on map -#define PLAYER_FLAGS_AMMO_RACK 128 // Player has ammo rack -#define PLAYER_FLAGS_CONVERTER 256 // Player has energy->shield converter -#define PLAYER_FLAGS_MAP_ALL_CHEAT 512 // Player can see unvisited areas on map normally -#define PLAYER_FLAGS_QUAD_LASERS 1024 // Player shoots 4 at once -#define PLAYER_FLAGS_CLOAKED 2048 // Player is cloaked for awhile -#define PLAYER_FLAGS_AFTERBURNER 4096 // Player's afterburner is engaged -#define PLAYER_FLAGS_HEADLIGHT 8192 // Player has headlight boost -#define PLAYER_FLAGS_HEADLIGHT_ON 16384 // is headlight on or off? - -#define AFTERBURNER_MAX_TIME (F1_0*5) // Max time afterburner can be on. -#define CALLSIGN_LEN 8 // so can use as filename (was: 12) - -// Amount of time player is cloaked. -#define CLOAK_TIME_MAX (F1_0*30) -#define INVULNERABLE_TIME_MAX (F1_0*30) - -#define PLAYER_STRUCT_VERSION 17 //increment this every time player struct changes +#define PLAYER_FLAGS_INVULNERABLE 1 // Player is invincible +#define PLAYER_FLAGS_BLUE_KEY 2 // Player has blue key +#define PLAYER_FLAGS_RED_KEY 4 // Player has red key +#define PLAYER_FLAGS_GOLD_KEY 8 // Player has gold key +#define PLAYER_FLAGS_FLAG 16 // Player has his team's flag +#define PLAYER_FLAGS_UNUSED 32 // +#define PLAYER_FLAGS_MAP_ALL 64 // Player can see unvisited areas on map +#define PLAYER_FLAGS_AMMO_RACK 128 // Player has ammo rack +#define PLAYER_FLAGS_CONVERTER 256 // Player has energy->shield converter +#define PLAYER_FLAGS_MAP_ALL_CHEAT 512 // Player can see unvisited areas on map normally +#define PLAYER_FLAGS_QUAD_LASERS 1024 // Player shoots 4 at once +#define PLAYER_FLAGS_CLOAKED 2048 // Player is cloaked for awhile +#define PLAYER_FLAGS_AFTERBURNER 4096 // Player's afterburner is engaged +#define PLAYER_FLAGS_HEADLIGHT 8192 // Player has headlight boost +#define PLAYER_FLAGS_HEADLIGHT_ON 16384 // is headlight on or off? + +#define AFTERBURNER_MAX_TIME (F1_0*5) // Max time afterburner can be on. +#define CALLSIGN_LEN 8 //so can use as filename (was: 12) + +// Amount of time player is cloaked. +#define CLOAK_TIME_MAX (F1_0*30) +#define INVULNERABLE_TIME_MAX (F1_0*30) + +#define PLAYER_STRUCT_VERSION 17 //increment this every time player struct changes //defines for teams -#define TEAM_BLUE 0 -#define TEAM_RED 1 +#define TEAM_BLUE 0 +#define TEAM_RED 1 //When this structure changes, increment the constant SAVE_FILE_VERSION //in playsave.c typedef struct player { // Who am I data - char callsign[CALLSIGN_LEN+1]; // The callsign of this player, for net purposes. - ubyte net_address[6]; // The network address of the player. - byte connected; // Is the player connected or not? - int objnum; // What object number this player is. (made an int by mk because it's very often referenced) - int n_packets_got; // How many packets we got from them - int n_packets_sent; // How many packets we sent to them + char callsign[CALLSIGN_LEN+1]; // The callsign of this player, for net purposes. + ubyte net_address[6]; // The network address of the player. + byte connected; // Is the player connected or not? + int objnum; // What object number this player is. (made an int by mk because it's very often referenced) + int n_packets_got; // How many packets we got from them + int n_packets_sent; // How many packets we sent to them - // -- make sure you're 4 byte aligned now! + // -- make sure you're 4 byte aligned now! // Game data - uint flags; // Powerup flags, see below... - fix energy; // Amount of energy remaining. - fix shields; // shields remaining (protection) - ubyte lives; // Lives remaining, 0 = game over. - byte level; // Current level player is playing. (must be signed for secret levels) - ubyte laser_level; // Current level of the laser. - byte starting_level; // What level the player started on. - short killer_objnum; // Who killed me.... (-1 if no one) - ushort primary_weapon_flags; // bit set indicates the player has this weapon. - ushort secondary_weapon_flags; // bit set indicates the player has this weapon. - ushort primary_ammo[MAX_PRIMARY_WEAPONS]; // How much ammo of each type. - ushort secondary_ammo[MAX_SECONDARY_WEAPONS]; // How much ammo of each type. - - ushort pad; // Pad because increased weapon_flags from byte to short -YW 3/22/95 - - // -- make sure you're 4 byte aligned now + uint flags; // Powerup flags, see below... + fix energy; // Amount of energy remaining. + fix shields; // shields remaining (protection) + ubyte lives; // Lives remaining, 0 = game over. + byte level; // Current level player is playing. (must be signed for secret levels) + ubyte laser_level; // Current level of the laser. + byte starting_level; // What level the player started on. + short killer_objnum; // Who killed me.... (-1 if no one) + ushort primary_weapon_flags; // bit set indicates the player has this weapon. + ushort secondary_weapon_flags; // bit set indicates the player has this weapon. + ushort primary_ammo[MAX_PRIMARY_WEAPONS]; // How much ammo of each type. + ushort secondary_ammo[MAX_SECONDARY_WEAPONS]; // How much ammo of each type. + + ushort pad; // Pad because increased weapon_flags from byte to short -YW 3/22/95 + + // -- make sure you're 4 byte aligned now // Statistics... - int last_score; // Score at beginning of current level. - int score; // Current score. - fix time_level; // Level time played - fix time_total; // Game time played (high word = seconds) - - fix cloak_time; // Time cloaked - fix invulnerable_time; // Time invulnerable - - short KillGoalCount; // Num of players killed this level - short net_killed_total; // Number of times killed total - short net_kills_total; // Number of net kills total - short num_kills_level; // Number of kills this level - short num_kills_total; // Number of kills total - short num_robots_level; // Number of initial robots this level - short num_robots_total; // Number of robots total - ushort hostages_rescued_total; // Total number of hostages rescued. - ushort hostages_total; // Total number of hostages. - ubyte hostages_on_board; // Number of hostages on ship. - ubyte hostages_level; // Number of hostages on this level. - fix homing_object_dist; // Distance of nearest homing object. - byte hours_level; // Hours played (since time_total can only go up to 9 hours) - byte hours_total; // Hours played (since time_total can only go up to 9 hours) -} __pack__ player; + int last_score; // Score at beginning of current level. + int score; // Current score. + fix time_level; // Level time played + fix time_total; // Game time played (high word = seconds) + + fix cloak_time; // Time cloaked + fix invulnerable_time; // Time invulnerable + + short KillGoalCount; // Num of players killed this level + short net_killed_total; // Number of times killed total + short net_kills_total; // Number of net kills total + short num_kills_level; // Number of kills this level + short num_kills_total; // Number of kills total + short num_robots_level; // Number of initial robots this level + short num_robots_total; // Number of robots total + ushort hostages_rescued_total; // Total number of hostages rescued. + ushort hostages_total; // Total number of hostages. + ubyte hostages_on_board; // Number of hostages on ship. + ubyte hostages_level; // Number of hostages on this level. + fix homing_object_dist; // Distance of nearest homing object. + byte hours_level; // Hours played (since time_total can only go up to 9 hours) + byte hours_total; // Hours played (since time_total can only go up to 9 hours) +} __pack__ player; #define N_PLAYER_GUNS 8 typedef struct player_ship { - int model_num; - int expl_vclip_num; - fix mass,drag; - fix max_thrust,reverse_thrust,brakes; //low_thrust - fix wiggle; - fix max_rotthrust; + int model_num; + int expl_vclip_num; + fix mass,drag; + fix max_thrust,reverse_thrust,brakes; //low_thrust + fix wiggle; + fix max_rotthrust; vms_vector gun_points[N_PLAYER_GUNS]; -} player_ship; +} __pack__ player_ship; -extern int N_players; // Number of players ( >1 means a net game, eh?) -extern int Player_num; // The player number who is on the console. +extern int N_players; // Number of players ( >1 means a net game, eh?) +extern int Player_num; // The player number who is on the console. -extern player Players[MAX_PLAYERS+4]; // Misc player info +extern player Players[MAX_PLAYERS+4]; // Misc player info extern player_ship *Player_ship; //version 16 structure - -#define MAX_PRIMARY_WEAPONS16 5 -#define MAX_SECONDARY_WEAPONS16 5 - typedef struct player16 { // Who am I data - char callsign[CALLSIGN_LEN+1]; // The callsign of this player, for net purposes. - ubyte net_address[6]; // The network address of the player. - byte connected; // Is the player connected or not? - int objnum; // What object number this player is. (made an int by mk because it's very often referenced) - int n_packets_got; // How many packets we got from them - int n_packets_sent; // How many packets we sent to them + char callsign[8+1]; // The callsign of this player, for net purposes. + ubyte net_address[6]; // The network address of the player. + byte connected; // Is the player connected or not? + int objnum; // What object number this player is. (made an int by mk because it's very often referenced) + int n_packets_got; // How many packets we got from them + int n_packets_sent; // How many packets we sent to them - // -- make sure you're 4 byte aligned now! + // -- make sure you're 4 byte aligned now! // Game data - uint flags; // Powerup flags, see below... - fix energy; // Amount of energy remaining. - fix shields; // shields remaining (protection) - ubyte lives; // Lives remaining, 0 = game over. - byte level; // Current level player is playing. (must be signed for secret levels) - ubyte laser_level; // Current level of the laser. - byte starting_level; // What level the player started on. - short killer_objnum; // Who killed me.... (-1 if no one) - ubyte primary_weapon_flags; // bit set indicates the player has this weapon. - ubyte secondary_weapon_flags; // bit set indicates the player has this weapon. - ushort primary_ammo[MAX_PRIMARY_WEAPONS16]; // How much ammo of each type. - ushort secondary_ammo[MAX_SECONDARY_WEAPONS16];// How much ammo of each type. - - // -- make sure you're 4 byte aligned now + uint flags; // Powerup flags, see below... + fix energy; // Amount of energy remaining. + fix shields; // shields remaining (protection) + ubyte lives; // Lives remaining, 0 = game over. + byte level; // Current level player is playing. (must be signed for secret levels) + ubyte laser_level; // Current level of the laser. + byte starting_level; // What level the player started on. + short killer_objnum; // Who killed me.... (-1 if no one) + ubyte primary_weapon_flags; // bit set indicates the player has this weapon. + ubyte secondary_weapon_flags; // bit set indicates the player has this weapon. + ushort primary_ammo[5]; // How much ammo of each type. + ushort secondary_ammo[5]; // How much ammo of each type. + + // -- make sure you're 4 byte aligned now // Statistics... - int last_score; // Score at beginning of current level. - int score; // Current score. - fix time_level; // Level time played - fix time_total; // Game time played (high word = seconds) - - fix cloak_time; // Time cloaked - fix invulnerable_time; // Time invulnerable - - short net_killed_total; // Number of times killed total - short net_kills_total; // Number of net kills total - short num_kills_level; // Number of kills this level - short num_kills_total; // Number of kills total - short num_robots_level; // Number of initial robots this level - short num_robots_total; // Number of robots total - ushort hostages_rescued_total; // Total number of hostages rescued. - ushort hostages_total; // Total number of hostages. - ubyte hostages_on_board; // Number of hostages on ship. - ubyte hostages_level; // Number of hostages on this level. - fix homing_object_dist; // Distance of nearest homing object. - byte hours_level; // Hours played (since time_total can only go up to 9 hours) - byte hours_total; // Hours played (since time_total can only go up to 9 hours) + int last_score; // Score at beginning of current level. + int score; // Current score. + fix time_level; // Level time played + fix time_total; // Game time played (high word = seconds) + + fix cloak_time; // Time cloaked + fix invulnerable_time; // Time invulnerable + + short net_killed_total; // Number of times killed total + short net_kills_total; // Number of net kills total + short num_kills_level; // Number of kills this level + short num_kills_total; // Number of kills total + short num_robots_level; // Number of initial robots this level + short num_robots_total; // Number of robots total + ushort hostages_rescued_total; // Total number of hostages rescued. + ushort hostages_total; // Total number of hostages. + ubyte hostages_on_board; // Number of hostages on ship. + ubyte hostages_level; // Number of hostages on this level. + fix homing_object_dist; // Distance of nearest homing object. + byte hours_level; // Hours played (since time_total can only go up to 9 hours) + byte hours_total; // Hours played (since time_total can only go up to 9 hours) } __pack__ player16; -/* - * reads a player_ship structure from a CFILE - */ -void player_ship_read(player_ship *ps, CFILE *fp); - #endif diff --git a/main/playsave.c b/main/playsave.c index 76973662..82bfaa41 100644 --- a/main/playsave.c +++ b/main/playsave.c @@ -1,4 +1,3 @@ -/* $Id: playsave.c,v 1.12 2003-04-12 00:11:46 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,244 +7,22 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/playsave.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-11-12 00:59:07 $ * * Functions to load & save player games * - * Old Log: - * Revision 1.1 1995/12/05 16:05:47 allender - * Initial revision + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/11/11 23:39:22 bradleyb + * Created header for MAKE_SIG macro * - * Revision 1.10 1995/11/03 12:53:24 allender - * shareware changes - * - * Revision 1.9 1995/10/31 10:19:12 allender - * shareware stuff - * - * Revision 1.8 1995/10/23 14:50:11 allender - * set control type for new player *before* calling kc_set_controls - * - * Revision 1.7 1995/10/21 22:25:31 allender - * *** empty log message *** - * - * Revision 1.6 1995/10/17 15:57:42 allender - * removed line setting wrong COnfig_control_type - * - * Revision 1.5 1995/10/17 13:16:44 allender - * new controller support - * - * Revision 1.4 1995/08/24 16:03:38 allender - * call joystick code when player file uses joystick - * - * Revision 1.3 1995/08/03 15:15:39 allender - * got player save file working (more to go for shareware) - * - * Revision 1.2 1995/08/01 13:57:20 allender - * macified the player file stuff -- in a seperate folder - * - * Revision 1.1 1995/05/16 15:30:00 allender - * Initial revision - * - * Revision 2.3 1995/05/26 16:16:23 john - * Split SATURN into define's for requiring cd, using cd, etc. - * Also started adding all the Rockwell stuff. - * - * Revision 2.2 1995/03/24 17:48:21 john - * Made player files from saturn excrement the highest level for - * normal descent levels. - * - * Revision 2.1 1995/03/21 14:38:49 john - * Ifdef'd out the NETWORK code. - * - * Revision 2.0 1995/02/27 11:27:59 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.57 1995/02/13 20:34:55 john - * Lintized - * - * Revision 1.56 1995/02/13 13:23:24 john - * Fixed bug with new player joystick selection. - * - * Revision 1.55 1995/02/13 12:01:19 john - * Fixed bug with joystick throttle still asking for - * calibration with new pilots. - * - * Revision 1.54 1995/02/13 10:29:12 john - * Fixed bug with creating new player not resetting everything to default. - * - * Revision 1.53 1995/02/03 10:58:46 john - * Added code to save shareware style saved games into new format... - * Also, made new player file format not have the saved game array in it. - * - * Revision 1.52 1995/02/02 21:09:28 matt - * Let player start of level 8 if he made it to level 7 in the shareware - * - * Revision 1.51 1995/02/02 18:50:14 john - * Added warning for FCS when new pilot chooses. - * - * Revision 1.50 1995/02/02 11:21:34 john - * Made joystick calibrate when new user selects. - * - * Revision 1.49 1995/02/01 18:06:38 rob - * Put defaults macros into descent.tex - * - * Revision 1.48 1995/01/25 14:37:53 john - * Made joystick only prompt for calibration once... - * - * Revision 1.47 1995/01/24 19:37:12 matt - * Took out incorrect mprintf - * - * Revision 1.46 1995/01/22 18:57:22 matt - * Made player highest level work with missions - * - * Revision 1.45 1995/01/21 16:36:05 matt - * Made starting level system work for now, pending integration with - * mission code. - * - * Revision 1.44 1995/01/20 22:47:32 matt - * Mission system implemented, though imcompletely - * - * Revision 1.43 1995/01/04 14:58:39 rob - * Fixed for shareware build. - * - * Revision 1.42 1995/01/04 11:36:43 rob - * Added compatibility with older shareware pilot files. - * - * Revision 1.41 1995/01/03 11:01:58 rob - * fixed a default macro. - * - * Revision 1.40 1995/01/03 10:44:06 rob - * Added default taunt macros. - * - * Revision 1.39 1994/12/13 10:01:16 allender - * pop up message box when unable to correctly save player file - * - * Revision 1.38 1994/12/12 11:37:14 matt - * Fixed auto leveling defaults & saving - * - * Revision 1.37 1994/12/12 00:26:59 matt - * Added support for no-levelling option - * - * Revision 1.36 1994/12/10 19:09:54 matt - * Added assert for valid player number when loading game - * - * Revision 1.35 1994/12/08 10:53:07 rob - * Fixed a bug in highest_level tracking. - * - * Revision 1.34 1994/12/08 10:01:36 john - * Changed the way the player callsign stuff works. - * - * Revision 1.33 1994/12/07 18:30:38 rob - * Load highest level along with player (used to be only if higher) - * Capped at LAST_LEVEL in case a person loads a registered player in shareware. - * - * Revision 1.32 1994/12/03 16:01:12 matt - * When player file has bad version, force player to choose another - * - * Revision 1.31 1994/12/02 19:54:00 yuan - * Localization. - * - * Revision 1.30 1994/12/02 11:01:36 yuan - * Localization. - * - * Revision 1.29 1994/11/29 03:46:28 john - * Added joystick sensitivity; Added sound channels to detail menu. Removed -maxchannels - * command line arg. - * - * Revision 1.28 1994/11/29 01:10:23 john - * Took out code that allowed new players to - * configure keyboard. - * - * Revision 1.27 1994/11/25 22:47:10 matt - * Made saved game descriptions longer - * - * Revision 1.26 1994/11/22 12:10:42 rob - * Fixed file handle left open if player file versions don't - * match. - * - * Revision 1.25 1994/11/21 19:35:30 john - * Replaced calls to joy_init with if (joy_present) - * - * Revision 1.24 1994/11/21 17:29:34 matt - * Cleaned up sequencing & game saving for secret levels - * - * Revision 1.23 1994/11/21 11:10:01 john - * Fixed bug with read-only .plr file making the config file - * not update. - * - * Revision 1.22 1994/11/20 19:03:08 john - * Fixed bug with if not having a joystick, default - * player input device is cyberman. - * - * Revision 1.21 1994/11/17 12:24:07 matt - * Made an array the right size, to fix error loading games - * - * Revision 1.20 1994/11/14 17:52:54 allender - * add call to WriteConfigFile when player files gets written - * - * Revision 1.19 1994/11/14 17:19:23 rob - * Removed gamma, joystick calibration, and sound settings from player file. - * Added default difficulty and multi macros. - * - * Revision 1.18 1994/11/07 14:01:23 john - * Changed the gamma correction sequencing. - * - * Revision 1.17 1994/11/05 17:22:49 john - * Fixed lots of sequencing problems with newdemo stuff. - * - * Revision 1.16 1994/11/01 16:40:11 john - * Added Gamma correction. - * - * Revision 1.15 1994/10/24 19:56:50 john - * Made the new user setup prompt for config options. - * - * Revision 1.14 1994/10/24 17:44:21 john - * Added stereo channel reversing. - * - * Revision 1.13 1994/10/24 16:05:12 matt - * Improved handling of player names that are the names of DOS devices - * - * Revision 1.12 1994/10/22 00:08:51 matt - * Fixed up problems with bonus & game sequencing - * Player doesn't get credit for hostages unless he gets them out alive - * - * Revision 1.11 1994/10/19 19:59:57 john - * Added bonus points at the end of level based on skill level. - * - * Revision 1.10 1994/10/19 15:14:34 john - * Took % hits out of player structure, made %kills work properly. - * - * Revision 1.9 1994/10/19 12:44:26 john - * Added hours field to player structure. - * - * Revision 1.8 1994/10/17 17:24:34 john - * Added starting_level to player struct. - * - * Revision 1.7 1994/10/17 13:07:15 john - * Moved the descent.cfg info into the player config file. - * - * Revision 1.6 1994/10/09 14:54:31 matt - * Made player cockpit state & window size save/restore with saved games & automap - * - * Revision 1.5 1994/10/08 23:08:09 matt - * Added error check & handling for game load/save disk io - * - * Revision 1.4 1994/10/05 17:40:54 rob - * Bumped save_file_version to 5 due to change in player.h - * - * Revision 1.3 1994/10/03 23:00:54 matt - * New file version for shorter callsigns - * - * Revision 1.2 1994/09/28 17:25:05 matt - * Added first draft of game save/load system - * - * Revision 1.1 1994/09/27 14:39:12 matt - * Initial revision * */ @@ -288,8 +65,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "powerup.h" #include "makesig.h" #include "byteswap.h" -#include "fileutil.h" -#include "escort.h" #define SAVE_FILE_ID MAKE_SIG('D','P','L','R') @@ -316,7 +91,7 @@ int n_highest_levels; hli highest_levels[MAX_MISSIONS]; -#define PLAYER_FILE_VERSION 25 //increment this every time the player file changes +#define PLAYER_FILE_VERSION 24 //increment this every time the player file changes //version 5 -> 6: added new highest level information //version 6 -> 7: stripped out the old saved_game array. @@ -337,7 +112,6 @@ hli highest_levels[MAX_MISSIONS]; //version 21 -> 22: save lifetime netstats //version 22 -> 23: ?? //version 23 -> 24: add name of joystick for windows version. -//version 24 -> 25: add d2x keys array #define COMPATIBLE_PLAYER_FILE_VERSION 17 @@ -418,10 +192,6 @@ RetrySelection: for (i=0;i=0 && Player_num 255) // bigendian file? - swap = 1; - - if (swap) - player_file_version = SWAPSHORT(player_file_version); + player_file_version = read_short(file); if (player_file_version= 19) - Automap_always_hires = file_read_byte(file); + Automap_always_hires = read_byte(file); Auto_leveling_on = Default_leveling_on; //read new highest level info - n_highest_levels = file_read_short(file); - if (swap) - n_highest_levels = SWAPSHORT(n_highest_levels); - + n_highest_levels = read_short(file); if (fread(highest_levels,sizeof(hli),n_highest_levels,file) != n_highest_levels) { errno_ret = errno; fclose(file); @@ -671,18 +494,14 @@ int read_player_file() for (i=0;i<11;i++) { - PrimaryOrder[i]=file_read_byte (file); - SecondaryOrder[i]=file_read_byte(file); + PrimaryOrder[i]=read_byte (file); + SecondaryOrder[i]=read_byte(file); } - + if (player_file_version>=16) { - Cockpit_3d_view[0]=file_read_int(file); - Cockpit_3d_view[1]=file_read_int(file); - if (swap) { - Cockpit_3d_view[0] = SWAPINT(Cockpit_3d_view[0]); - Cockpit_3d_view[1] = SWAPINT(Cockpit_3d_view[1]); - } + Cockpit_3d_view[0]=read_int(file); + Cockpit_3d_view[1]=read_int(file); } @@ -695,14 +514,10 @@ int read_player_file() if (player_file_version>=22) { #ifdef NETWORK - Netlife_kills=file_read_int (file); - Netlife_killed=file_read_int (file); - if (swap) { - Netlife_kills = SWAPINT(Netlife_kills); - Netlife_killed = SWAPINT(Netlife_killed); - } + Netlife_kills=read_int (file); + Netlife_killed=read_int (file); #else - file_read_int(file); file_read_int(file); + read_int(file); read_int(file); #endif } #ifdef NETWORK @@ -714,9 +529,7 @@ int read_player_file() if (player_file_version>=23) { - i=file_read_int (file); - if (swap) - i = SWAPINT(i); + i=read_int (file); #ifdef NETWORK mprintf ((0,"Reading: lifetime checksum is %d\n",i)); if (i!=get_lifetime_checksum (Netlife_kills,Netlife_killed)) @@ -730,7 +543,7 @@ int read_player_file() //read guidebot name if (player_file_version >= 18) - file_read_string(guidebot_name,file); + read_string(guidebot_name,file); else strcpy(guidebot_name,"GUIDE-BOT"); @@ -742,7 +555,7 @@ int read_player_file() #ifdef WINDOWS joy95_get_name(JOYSTICKID1, buf, 127); if (player_file_version >= 24) - file_read_string(win95_current_joyname, file); + read_string(win95_current_joyname, file); else strcpy(win95_current_joyname, "Old Player File"); @@ -756,16 +569,10 @@ int read_player_file() } #else if (player_file_version >= 24) - file_read_string(buf, file); // Just read it in fpr DPS. + read_string(buf, file); // Just read it in fpr DPS. #endif } - if (player_file_version >= 25) - fread(kconfig_d2x_settings, MAX_D2X_CONTROLS, 1, file); - else - for(i=0; i < MAX_D2X_CONTROLS; i++) - kconfig_d2x_settings[i] = default_kconfig_d2x_settings[i]; - if (fclose(file) && errno_ret==EZERO) errno_ret = errno; @@ -881,24 +688,24 @@ int write_player_file() errno_ret = EZERO; //Write out player's info - file_write_int(SAVE_FILE_ID,file); - file_write_short(PLAYER_FILE_VERSION,file); - - file_write_short(Game_window_w,file); - file_write_short(Game_window_h,file); - - file_write_byte(Player_default_difficulty,file); - file_write_byte(Auto_leveling_on,file); - file_write_byte(Reticle_on,file); - file_write_byte((Cockpit_mode_save!=-1)?Cockpit_mode_save:Cockpit_mode,file); //if have saved mode, write it instead of letterbox/rear view - file_write_byte(Default_display_mode,file); - file_write_byte(Missile_view_enabled,file); - file_write_byte(Headlight_active_default,file); - file_write_byte(Guided_in_big_window,file); - file_write_byte(Automap_always_hires,file); + write_int(SAVE_FILE_ID,file); + write_short(PLAYER_FILE_VERSION,file); + + write_short(Game_window_w,file); + write_short(Game_window_h,file); + + write_byte(Player_default_difficulty,file); + write_byte(Auto_leveling_on,file); + write_byte(Reticle_on,file); + write_byte((Cockpit_mode_save!=-1)?Cockpit_mode_save:Cockpit_mode,file); //if have saved mode, write it instead of letterbox/rear view + write_byte(Default_display_mode,file); + write_byte(Missile_view_enabled,file); + write_byte(Headlight_active_default,file); + write_byte(Guided_in_big_window,file); + write_byte(Automap_always_hires,file); //write higest level info - file_write_short(n_highest_levels,file); + write_short(n_highest_levels,file); if ((fwrite(highest_levels, sizeof(hli), n_highest_levels, file) != n_highest_levels)) { errno_ret = errno; fclose(file); @@ -938,25 +745,24 @@ int write_player_file() fwrite (&PrimaryOrder[i],sizeof(ubyte),1,file); fwrite (&SecondaryOrder[i],sizeof(ubyte),1,file); } - - file_write_int (Cockpit_3d_view[0],file); - file_write_int (Cockpit_3d_view[1],file); + write_int (Cockpit_3d_view[0],file); + write_int (Cockpit_3d_view[1],file); #ifdef NETWORK - file_write_int (Netlife_kills,file); - file_write_int (Netlife_killed,file); + write_int (Netlife_kills,file); + write_int (Netlife_killed,file); i=get_lifetime_checksum (Netlife_kills,Netlife_killed); mprintf ((0,"Writing: Lifetime checksum is %d\n",i)); #else - file_write_int(0, file); - file_write_int(0, file); + write_int(0, file); + write_int(0, file); i = get_lifetime_checksum (0, 0); #endif - file_write_int (i,file); + write_int (i,file); } //write guidebot name - file_write_string(real_guidebot_name,file); + write_string(real_guidebot_name,file); { char buf[128]; @@ -965,11 +771,9 @@ int write_player_file() #else strcpy(buf, "DOS joystick"); #endif - file_write_string(buf, file); // Write out current joystick for player. + write_string(buf, file); // Write out current joystick for player. } - fwrite(kconfig_d2x_settings, MAX_D2X_CONTROLS, 1, file); - if (fclose(file)) errno_ret = errno; diff --git a/main/polyobj.c b/main/polyobj.c index 8e11e787..c83aaeb0 100644 --- a/main/polyobj.c +++ b/main/polyobj.c @@ -1,4 +1,3 @@ -/* $Id: polyobj.c,v 1.14 2003-03-29 22:35:00 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: polyobj.c,v 1.14 2003-03-29 22:35:00 btb Exp $"; +static char rcsid[] = "$Id: polyobj.c,v 1.5 2001-01-31 15:34:40 bradleyb Exp $"; #endif #include @@ -33,12 +32,11 @@ static char rcsid[] = "$Id: polyobj.c,v 1.14 2003-03-29 22:35:00 btb Exp $"; #include "polyobj.h" #include "vecmat.h" -#include "interp.h" +#include "3d.h" #include "error.h" #include "mono.h" #include "u_mem.h" #include "args.h" -#include "byteswap.h" #ifndef DRIVE #include "texmap.h" @@ -94,7 +92,7 @@ int pof_read_int(ubyte *bufp) i = *((int *) &bufp[Pof_addr]); Pof_addr += 4; - return INTEL_INT(i); + return i; // if (cfread(&i,sizeof(i),1,f) != 1) // Error("Unexpected end-of-file while reading object"); @@ -126,7 +124,7 @@ short pof_read_short(ubyte *bufp) s = *((short *) &bufp[Pof_addr]); Pof_addr += 2; - return INTEL_SHORT(s); + return s; // if (cfread(&s,sizeof(s),1,f) != 1) // Error("Unexpected end-of-file while reading object"); // @@ -152,26 +150,7 @@ void pof_read_vecs(vms_vector *vecs,int n,ubyte *bufp) memcpy(vecs, &bufp[Pof_addr], n*sizeof(*vecs)); Pof_addr += n*sizeof(*vecs); - -#ifdef WORDS_BIGENDIAN - while (n > 0) - vms_vector_swap(&vecs[--n]); -#endif - - if (Pof_addr > MODEL_BUF_SIZE) - Int3(); -} - -void pof_read_angs(vms_angvec *angs,int n,ubyte *bufp) -{ - memcpy(angs, &bufp[Pof_addr], n*sizeof(*angs)); - Pof_addr += n*sizeof(*angs); - -#ifdef WORDS_BIGENDIAN - while (n > 0) - vms_angvec_swap(&angs[--n]); -#endif - + if (Pof_addr > MODEL_BUF_SIZE) Int3(); } @@ -193,91 +172,6 @@ vms_angvec anim_angs[N_ANIM_STATES][MAX_SUBMODELS]; void robot_set_angles(robot_info *r,polymodel *pm,vms_angvec angs[N_ANIM_STATES][MAX_SUBMODELS]); #endif -#define DEBUG_LEVEL CON_NORMAL - -#ifdef WORDS_NEED_ALIGNMENT -ubyte * old_dest(chunk o) // return where chunk is (in unaligned struct) -{ - return o.old_base + INTEL_SHORT(*((short *)(o.old_base + o.offset))); -} -ubyte * new_dest(chunk o) // return where chunk is (in aligned struct) -{ - return o.new_base + INTEL_SHORT(*((short *)(o.old_base + o.offset))) + o.correction; -} -/* - * find chunk with smallest address - */ -int get_first_chunks_index(chunk *chunk_list, int no_chunks) -{ - int i, first_index = 0; - Assert(no_chunks >= 1); - for (i = 1; i < no_chunks; i++) - if (old_dest(chunk_list[i]) < old_dest(chunk_list[first_index])) - first_index = i; - return first_index; -} -#define SHIFT_SPACE 500 // increase if insufficent - -void align_polygon_model_data(polymodel *pm) -{ - int i, chunk_len; - int total_correction = 0; - ubyte *cur_old, *cur_new; - chunk cur_ch; - chunk ch_list[MAX_CHUNKS]; - int no_chunks = 0; - int tmp_size = pm->model_data_size + SHIFT_SPACE; - ubyte *tmp = d_malloc(tmp_size); // where we build the aligned version of pm->model_data - - Assert(tmp != NULL); - //start with first chunk (is always aligned!) - cur_old = pm->model_data; - cur_new = tmp; - chunk_len = get_chunks(cur_old, cur_new, ch_list, &no_chunks); - memcpy(cur_new, cur_old, chunk_len); - while (no_chunks > 0) { - int first_index = get_first_chunks_index(ch_list, no_chunks); - cur_ch = ch_list[first_index]; - // remove first chunk from array: - no_chunks--; - for (i = first_index; i < no_chunks; i++) - ch_list[i] = ch_list[i + 1]; - // if (new) address unaligned: - if ((u_int32_t)new_dest(cur_ch) % 4L != 0) { - // calculate how much to move to be aligned - short to_shift = 4 - (u_int32_t)new_dest(cur_ch) % 4L; - // correct chunks' addresses - cur_ch.correction += to_shift; - for (i = 0; i < no_chunks; i++) - ch_list[i].correction += to_shift; - total_correction += to_shift; - Assert((u_int32_t)new_dest(cur_ch) % 4L == 0); - Assert(total_correction <= SHIFT_SPACE); // if you get this, increase SHIFT_SPACE - } - //write (corrected) chunk for current chunk: - *((short *)(cur_ch.new_base + cur_ch.offset)) - = INTEL_SHORT(cur_ch.correction - + INTEL_SHORT(*((short *)(cur_ch.old_base + cur_ch.offset)))); - //write (correctly aligned) chunk: - cur_old = old_dest(cur_ch); - cur_new = new_dest(cur_ch); - chunk_len = get_chunks(cur_old, cur_new, ch_list, &no_chunks); - memcpy(cur_new, cur_old, chunk_len); - //correct submodel_ptr's for pm, too - for (i = 0; i < MAX_SUBMODELS; i++) - if (pm->model_data + pm->submodel_ptrs[i] >= cur_old - && pm->model_data + pm->submodel_ptrs[i] < cur_old + chunk_len) - pm->submodel_ptrs[i] += (cur_new - tmp) - (cur_old - pm->model_data); - } - d_free(pm->model_data); - pm->model_data_size += total_correction; - pm->model_data = d_malloc(pm->model_data_size); - Assert(pm->model_data != NULL); - memcpy(pm->model_data, tmp, pm->model_data_size); - d_free(tmp); -} -#endif //def WORDS_NEED_ALIGNMENT - //reads a binary file containing a 3d model polymodel *read_model_file(polymodel *pm,char *filename,robot_info *r) { @@ -286,7 +180,7 @@ polymodel *read_model_file(polymodel *pm,char *filename,robot_info *r) int id,len, next_chunk; int anim_flag = 0; ubyte *model_buf; - + model_buf = (ubyte *)d_malloc( MODEL_BUF_SIZE * sizeof(ubyte) ); if (!model_buf) Error("Can't allocate space to read model %s\n", filename); @@ -314,7 +208,7 @@ polymodel *read_model_file(polymodel *pm,char *filename,robot_info *r) printf( "bspgen -c1" ); while (new_pof_read_int(id,model_buf) == 1) { - id = INTEL_INT(id); + //id = pof_read_int(model_buf); len = pof_read_int(model_buf); next_chunk = Pof_addr + len; @@ -324,7 +218,7 @@ polymodel *read_model_file(polymodel *pm,char *filename,robot_info *r) case ID_OHDR: { //Object header vms_vector pmmin,pmmax; - //con_printf(DEBUG_LEVEL, "Got chunk OHDR, len=%d\n",len); + //mprintf(0,"Got chunk OHDR, len=%d\n",len); pm->n_models = pof_read_int(model_buf); pm->rad = pof_read_int(model_buf); @@ -354,7 +248,7 @@ polymodel *read_model_file(polymodel *pm,char *filename,robot_info *r) anim_flag++; - //con_printf(DEBUG_LEVEL, "Got chunk SOBJ, len=%d\n",len); + //mprintf(0,"Got chunk SOBJ, len=%d\n",len); n = pof_read_short(model_buf); @@ -377,7 +271,7 @@ polymodel *read_model_file(polymodel *pm,char *filename,robot_info *r) #ifndef DRIVE case ID_GUNS: { //List of guns on this object - //con_printf(DEBUG_LEVEL, "Got chunk GUNS, len=%d\n",len); + //mprintf(0,"Got chunk GUNS, len=%d\n",len); if (r) { int i; @@ -416,7 +310,7 @@ polymodel *read_model_file(polymodel *pm,char *filename,robot_info *r) } case ID_ANIM: //Animation data - //con_printf(DEBUG_LEVEL, "Got chunk ANIM, len=%d\n",len); + //mprintf(0,"Got chunk ANIM, len=%d\n",len); anim_flag++; @@ -429,8 +323,7 @@ polymodel *read_model_file(polymodel *pm,char *filename,robot_info *r) for (m=0;mn_models;m++) for (f=0;f\n",name_buf); + //mprintf(0,"<%s>\n",name_buf); } break; } case ID_IDTA: //Interpreter data - //con_printf(DEBUG_LEVEL, "Got chunk IDTA, len=%d\n",len); + //mprintf(0,"Got chunk IDTA, len=%d\n",len); pm->model_data = d_malloc(len); pm->model_data_size = len; - + pof_cfread(pm->model_data,1,len,model_buf); - + break; default: - //con_printf(DEBUG_LEVEL, "Unknown chunk <%c%c%c%c>, len = %d\n",id,id>>8,id>>16,id>>24,len); + //mprintf(0,"Unknown chunk <%c%c%c%c>, len = %d\n",id,id>>8,id>>16,id>>24,len); pof_cfseek(model_buf,len,SEEK_CUR); break; @@ -493,14 +386,6 @@ polymodel *read_model_file(polymodel *pm,char *filename,robot_info *r) d_free(model_buf); -#ifdef WORDS_NEED_ALIGNMENT - align_polygon_model_data(pm); -#endif -#ifdef WORDS_BIGENDIAN - swap_polygon_model_data(pm->model_data); -#endif - //verify(pm->model_data); - return pm; } @@ -540,13 +425,13 @@ int read_model_guns(char *filename,vms_vector *gun_points, vms_vector *gun_dirs, Error("Bad version (%d) in model file <%s>",version,filename); while (new_pof_read_int(id,model_buf) == 1) { - id = INTEL_INT(id); + //id = pof_read_int(model_buf); len = pof_read_int(model_buf); if (id == ID_GUNS) { //List of guns on this object - //con_printf(DEBUG_LEVEL, "Got chunk GUNS, len=%d\n",len); + //mprintf(0,"Got chunk GUNS, len=%d\n",len); int i; @@ -595,7 +480,7 @@ void draw_polygon_model(vms_vector *pos,vms_matrix *orient,vms_angvec *anim_angl { polymodel *po; int i; - PA_DFX (int save_light); + PA_DFX (int save_light); Assert(model_num < N_polygon_models); @@ -873,92 +758,3 @@ void draw_model_picture(int mn,vms_angvec *orient_angles) gr_free_canvas(temp_canv); } -#ifndef FAST_FILE_IO -/* - * reads a polymodel structure from a CFILE - */ -extern void polymodel_read(polymodel *pm, CFILE *fp) -{ - int i; - - pm->n_models = cfile_read_int(fp); - pm->model_data_size = cfile_read_int(fp); - pm->model_data = (ubyte *) cfile_read_int(fp); - for (i = 0; i < MAX_SUBMODELS; i++) - pm->submodel_ptrs[i] = cfile_read_int(fp); - for (i = 0; i < MAX_SUBMODELS; i++) - cfile_read_vector(&(pm->submodel_offsets[i]), fp); - for (i = 0; i < MAX_SUBMODELS; i++) - cfile_read_vector(&(pm->submodel_norms[i]), fp); - for (i = 0; i < MAX_SUBMODELS; i++) - cfile_read_vector(&(pm->submodel_pnts[i]), fp); - for (i = 0; i < MAX_SUBMODELS; i++) - pm->submodel_rads[i] = cfile_read_fix(fp); - cfread(pm->submodel_parents, MAX_SUBMODELS, 1, fp); - for (i = 0; i < MAX_SUBMODELS; i++) - cfile_read_vector(&(pm->submodel_mins[i]), fp); - for (i = 0; i < MAX_SUBMODELS; i++) - cfile_read_vector(&(pm->submodel_maxs[i]), fp); - cfile_read_vector(&(pm->mins), fp); - cfile_read_vector(&(pm->maxs), fp); - pm->rad = cfile_read_fix(fp); - pm->n_textures = cfile_read_byte(fp); - pm->first_texture = cfile_read_short(fp); - pm->simpler_model = cfile_read_byte(fp); -} - -/* - * reads n polymodel structs from a CFILE - */ -extern int polymodel_read_n(polymodel *pm, int n, CFILE *fp) -{ - int i, j; - - for (i = 0; i < n; i++) { - pm[i].n_models = cfile_read_int(fp); - pm[i].model_data_size = cfile_read_int(fp); - pm[i].model_data = (ubyte *) cfile_read_int(fp); - for (j = 0; j < MAX_SUBMODELS; j++) - pm[i].submodel_ptrs[j] = cfile_read_int(fp); - for (j = 0; j < MAX_SUBMODELS; j++) - cfile_read_vector(&(pm[i].submodel_offsets[j]), fp); - for (j = 0; j < MAX_SUBMODELS; j++) - cfile_read_vector(&(pm[i].submodel_norms[j]), fp); - for (j = 0; j < MAX_SUBMODELS; j++) - cfile_read_vector(&(pm[i].submodel_pnts[j]), fp); - for (j = 0; j < MAX_SUBMODELS; j++) - pm[i].submodel_rads[j] = cfile_read_fix(fp); - cfread(pm[i].submodel_parents, MAX_SUBMODELS, 1, fp); - for (j = 0; j < MAX_SUBMODELS; j++) - cfile_read_vector(&(pm[i].submodel_mins[j]), fp); - for (j = 0; j < MAX_SUBMODELS; j++) - cfile_read_vector(&(pm[i].submodel_maxs[j]), fp); - cfile_read_vector(&(pm[i].mins), fp); - cfile_read_vector(&(pm[i].maxs), fp); - pm[i].rad = cfile_read_fix(fp); - pm[i].n_textures = cfile_read_byte(fp); - pm[i].first_texture = cfile_read_short(fp); - pm[i].simpler_model = cfile_read_byte(fp); - } - return i; -} -#endif - - -/* - * routine which allocates, reads, and inits a polymodel's model_data - */ -void polygon_model_data_read(polymodel *pm, CFILE *fp) -{ - pm->model_data = d_malloc(pm->model_data_size); - Assert(pm->model_data != NULL); - cfread(pm->model_data, sizeof(ubyte), pm->model_data_size, fp ); -#ifdef WORDS_NEED_ALIGNMENT - align_polygon_model_data(pm); -#endif -#ifdef WORDS_BIGENDIAN - swap_polygon_model_data(pm->model_data); -#endif - //verify(pm->model_data); - g3_init_polygon_model(pm->model_data); -} diff --git a/main/polyobj.h b/main/polyobj.h index f3529427..367dbf26 100644 --- a/main/polyobj.h +++ b/main/polyobj.h @@ -1,4 +1,3 @@ -/* $Id: polyobj.h,v 1.6 2003-03-24 00:14:07 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -30,30 +29,30 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //used to describe a polygon model typedef struct polymodel { - int n_models; - int model_data_size; - ubyte *model_data; - int submodel_ptrs[MAX_SUBMODELS]; + int n_models; + int model_data_size; + ubyte *model_data; + int submodel_ptrs[MAX_SUBMODELS]; vms_vector submodel_offsets[MAX_SUBMODELS]; - vms_vector submodel_norms[MAX_SUBMODELS]; //norm for sep plane - vms_vector submodel_pnts[MAX_SUBMODELS]; //point on sep plane - fix submodel_rads[MAX_SUBMODELS]; //radius for each submodel - ubyte submodel_parents[MAX_SUBMODELS]; //what is parent for each submodel + vms_vector submodel_norms[MAX_SUBMODELS]; //norm for sep plane + vms_vector submodel_pnts[MAX_SUBMODELS]; //point on sep plane + fix submodel_rads[MAX_SUBMODELS]; //radius for each submodel + ubyte submodel_parents[MAX_SUBMODELS]; //what is parent for each submodel vms_vector submodel_mins[MAX_SUBMODELS]; vms_vector submodel_maxs[MAX_SUBMODELS]; - vms_vector mins,maxs; //min,max for whole model - fix rad; - ubyte n_textures; + vms_vector mins,maxs; //min,max for whole model + fix rad; + ubyte n_textures; ushort first_texture; - ubyte simpler_model; //alternate model with less detail (0 if none, model_num+1 else) + ubyte simpler_model; //alternate model with less detail (0 if none, model_num+1 else) // vms_vector min,max; } __pack__ polymodel; //array of pointers to polygon objects extern polymodel Polygon_models[]; -//switch to simpler model when the object has depth -//greater than this value times its radius. +//switch to simpler model when the object has depth +//greater than this value times its radius. extern int Simple_model_threshhold_scale; //how many polygon objects there are @@ -83,32 +82,10 @@ int read_model_guns(char *filename,vms_vector *gun_points, vms_vector *gun_dirs, //canvas. void draw_model_picture(int mn,vms_angvec *orient_angles); -//free up a model, getting rid of all its memory -void free_model(polymodel *po); - #define MAX_POLYOBJ_TEXTURES 100 extern grs_bitmap *texture_list[MAX_POLYOBJ_TEXTURES]; extern bitmap_index texture_list_index[MAX_POLYOBJ_TEXTURES]; extern g3s_point robot_points[]; -#ifdef FAST_FILE_IO -#define polymodel_read(pm, fp) cfread(pm, sizeof(polymodel), 1, fp) -#define polymodel_read_n(pm, n, fp) cfread(pm, sizeof(polymodel), n, fp) -#else -/* - * reads a polymodel structure from a CFILE - */ -extern void polymodel_read(polymodel *pm, CFILE *fp); - -/* - * reads n polymodel structs from a CFILE - */ -extern int polymodel_read_n(polymodel *pm, int n, CFILE *fp); #endif -/* - * routine which allocates, reads, and inits a polymodel's model_data - */ -void polygon_model_data_read(polymodel *pm, CFILE *fp); - -#endif diff --git a/main/powerup.c b/main/powerup.c index 3cef8c38..64479c23 100644 --- a/main/powerup.c +++ b/main/powerup.c @@ -49,7 +49,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "kconfig.h" #include "newdemo.h" -#include "escort.h" +#include "ai.h" #ifdef EDITOR #include "gr.h" // for powerup outline drawing @@ -700,21 +700,3 @@ int do_powerup(object *obj) return used; } - -#ifndef FAST_FILE_IO -/* - * reads n powerup_type_info structs from a CFILE - */ -extern int powerup_type_info_read_n(powerup_type_info *pti, int n, CFILE *fp) -{ - int i; - - for (i = 0; i < n; i++) { - pti[i].vclip_num = cfile_read_int(fp); - pti[i].hit_sound = cfile_read_int(fp); - pti[i].size = cfile_read_fix(fp); - pti[i].light = cfile_read_fix(fp); - } - return i; -} -#endif diff --git a/main/powerup.h b/main/powerup.h index 01661653..ff883eff 100644 --- a/main/powerup.h +++ b/main/powerup.h @@ -1,4 +1,3 @@ -/* $Id: powerup.h,v 1.3 2002-08-02 04:57:19 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -19,83 +18,83 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "vclip.h" -#define POW_EXTRA_LIFE 0 -#define POW_ENERGY 1 -#define POW_SHIELD_BOOST 2 -#define POW_LASER 3 +#define POW_EXTRA_LIFE 0 +#define POW_ENERGY 1 +#define POW_SHIELD_BOOST 2 +#define POW_LASER 3 -#define POW_KEY_BLUE 4 -#define POW_KEY_RED 5 -#define POW_KEY_GOLD 6 +#define POW_KEY_BLUE 4 +#define POW_KEY_RED 5 +#define POW_KEY_GOLD 6 -//#define POW_RADAR_ROBOTS 7 -//#define POW_RADAR_POWERUPS 8 +//#define POW_RADAR_ROBOTS 7 +//#define POW_RADAR_POWERUPS 8 -#define POW_MISSILE_1 10 -#define POW_MISSILE_4 11 //4-pack MUST follow single missile +#define POW_MISSILE_1 10 +#define POW_MISSILE_4 11 //4-pack MUST follow single missile -#define POW_QUAD_FIRE 12 +#define POW_QUAD_FIRE 12 -#define POW_VULCAN_WEAPON 13 -#define POW_SPREADFIRE_WEAPON 14 -#define POW_PLASMA_WEAPON 15 -#define POW_FUSION_WEAPON 16 -#define POW_PROXIMITY_WEAPON 17 -#define POW_SMARTBOMB_WEAPON 20 -#define POW_MEGA_WEAPON 21 -#define POW_VULCAN_AMMO 22 -#define POW_HOMING_AMMO_1 18 -#define POW_HOMING_AMMO_4 19 //4-pack MUST follow single missile -#define POW_CLOAK 23 -#define POW_TURBO 24 -#define POW_INVULNERABILITY 25 -#define POW_MEGAWOW 27 +#define POW_VULCAN_WEAPON 13 +#define POW_SPREADFIRE_WEAPON 14 +#define POW_PLASMA_WEAPON 15 +#define POW_FUSION_WEAPON 16 +#define POW_PROXIMITY_WEAPON 17 +#define POW_SMARTBOMB_WEAPON 20 +#define POW_MEGA_WEAPON 21 +#define POW_VULCAN_AMMO 22 +#define POW_HOMING_AMMO_1 18 +#define POW_HOMING_AMMO_4 19 //4-pack MUST follow single missile +#define POW_CLOAK 23 +#define POW_TURBO 24 +#define POW_INVULNERABILITY 25 +#define POW_MEGAWOW 27 -#define POW_GAUSS_WEAPON 28 -#define POW_HELIX_WEAPON 29 -#define POW_PHOENIX_WEAPON 30 -#define POW_OMEGA_WEAPON 31 +#define POW_GAUSS_WEAPON 28 +#define POW_HELIX_WEAPON 29 +#define POW_PHOENIX_WEAPON 30 +#define POW_OMEGA_WEAPON 31 -#define POW_SUPER_LASER 32 -#define POW_FULL_MAP 33 -#define POW_CONVERTER 34 -#define POW_AMMO_RACK 35 -#define POW_AFTERBURNER 36 -#define POW_HEADLIGHT 37 +#define POW_SUPER_LASER 32 +#define POW_FULL_MAP 33 +#define POW_CONVERTER 34 +#define POW_AMMO_RACK 35 +#define POW_AFTERBURNER 36 +#define POW_HEADLIGHT 37 -#define POW_SMISSILE1_1 38 -#define POW_SMISSILE1_4 39 //4-pack MUST follow single missile -#define POW_GUIDED_MISSILE_1 40 -#define POW_GUIDED_MISSILE_4 41 //4-pack MUST follow single missile -#define POW_SMART_MINE 42 -#define POW_MERCURY_MISSILE_1 43 -#define POW_MERCURY_MISSILE_4 44 //4-pack MUST follow single missile -#define POW_EARTHSHAKER_MISSILE 45 +#define POW_SMISSILE1_1 38 +#define POW_SMISSILE1_4 39 //4-pack MUST follow single missile +#define POW_GUIDED_MISSILE_1 40 +#define POW_GUIDED_MISSILE_4 41 //4-pack MUST follow single missile +#define POW_SMART_MINE 42 +#define POW_MERCURY_MISSILE_1 43 +#define POW_MERCURY_MISSILE_4 44 //4-pack MUST follow single missile +#define POW_EARTHSHAKER_MISSILE 45 -#define POW_FLAG_BLUE 46 -#define POW_FLAG_RED 47 +#define POW_FLAG_BLUE 46 +#define POW_FLAG_RED 47 -#define POW_HOARD_ORB 7 //use unused slot +#define POW_HOARD_ORB 7 //use unused slot -#define VULCAN_AMMO_MAX (392*4) -#define VULCAN_WEAPON_AMMO_AMOUNT 196 -#define VULCAN_AMMO_AMOUNT (49*2) +#define VULCAN_AMMO_MAX (392*4) +#define VULCAN_WEAPON_AMMO_AMOUNT 196 +#define VULCAN_AMMO_AMOUNT (49*2) -#define GAUSS_WEAPON_AMMO_AMOUNT 392 +#define GAUSS_WEAPON_AMMO_AMOUNT 392 -#define MAX_POWERUP_TYPES 50 +#define MAX_POWERUP_TYPES 50 -#define POWERUP_NAME_LENGTH 16 // Length of a robot or powerup name. -extern char Powerup_names[MAX_POWERUP_TYPES][POWERUP_NAME_LENGTH]; +#define POWERUP_NAME_LENGTH 16 // Length of a robot or powerup name. +extern char Powerup_names[MAX_POWERUP_TYPES][POWERUP_NAME_LENGTH]; -extern int Headlight_active_default; //is headlight on when picked up? +extern int Headlight_active_default; //is headlight on when picked up? typedef struct powerup_type_info { - int vclip_num; - int hit_sound; - fix size; // 3d size of longest dimension - fix light; // amount of light cast by this powerup, set in bitmaps.tbl + int vclip_num; + int hit_sound; + fix size; //3d size of longest dimension + fix light; // amount of light cast by this powerup, set in bitmaps.tbl } __pack__ powerup_type_info; extern int N_powerup_types; @@ -109,20 +108,11 @@ int do_powerup(object *obj); //process (animate) a powerup for one frame void do_powerup_frame(object *obj); -// Diminish shields and energy towards max in case they exceeded it. +// Diminish shields and energy towards max in case they exceeded it. extern void diminish_towards_max(void); extern void do_megawow_powerup(int quantity); extern void powerup_basic(int redadd, int greenadd, int blueadd, int score, char *format, ...); -#ifdef FAST_FILE_IO -#define powerup_type_info_read_n(pti, n, fp) cfread(pti, sizeof(powerup_type_info), n, fp) -#else -/* - * reads n powerup_type_info structs from a CFILE - */ -extern int powerup_type_info_read_n(powerup_type_info *pti, int n, CFILE *fp); -#endif - #endif diff --git a/main/render.c b/main/render.c index e6ef8fcf..33209a86 100644 --- a/main/render.c +++ b/main/render.c @@ -1,4 +1,3 @@ -/* $Id: render.c,v 1.16 2003-04-24 18:15:36 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,313 +7,21 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/render.c,v $ + * $Revision: 1.7 $ + * $Author: bradleyb $ + * $Date: 2001-10-25 02:19:31 $ * * FIXME: put description here * - * Old Log: - * Revision 1.9 1995/11/20 17:17:48 allender - * *** empty log message *** - * - * Revision 1.8 1995/10/26 14:08:35 allender - * added assigment for physics optimization - * - * Revision 1.7 1995/09/22 14:28:46 allender - * changed render_zoom to make game match PC aspect - * - * Revision 1.6 1995/08/14 14:35:54 allender - * change transparency to 0 - * - * Revision 1.5 1995/08/12 11:32:02 allender - * removed #ifdef NEWDEMO -- always in - * - * Revision 1.4 1995/07/05 16:48:31 allender - * kitchen stuff - * - * Revision 1.3 1995/06/23 10:22:54 allender - * fix outline mode - * - * Revision 1.2 1995/06/16 16:11:18 allender - * changed sort func to accept const parameters - * - * Revision 1.1 1995/05/16 15:30:24 allender - * Initial revision - * - * Revision 2.5 1995/12/19 15:31:36 john - * Made stereo mode only record 1 eye in demo. - * - * Revision 2.4 1995/03/20 18:15:53 john - * Added code to not store the normals in the segment structure. - * - * Revision 2.3 1995/03/13 16:11:05 john - * Maybe fixed bug that lighting didn't work with vr helmets. - * - * Revision 2.2 1995/03/09 15:33:49 john - * Fixed bug with iglasses timeout too long, and objects - * disappearing from left eye. - * - * Revision 2.1 1995/03/06 15:23:59 john - * New screen techniques. - * - * Revision 2.0 1995/02/27 11:31:01 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.252 1995/02/22 13:49:38 allender - * remove anonymous unions from object structure - * - * Revision 1.251 1995/02/11 15:07:26 matt - * Took out code which was mostly intended as part of a larger renderer - * change which never happened. This new code was causing problems with - * the level 4 control center. - * - * Revision 1.250 1995/02/07 16:28:53 matt - * Fixed problem with new code - * - * Revision 1.249 1995/02/06 14:38:58 matt - * Took out some code that didn't compile when editor in - * - * Revision 1.248 1995/02/06 13:45:25 matt - * Structural changes, plus small sorting improvements - * - * Revision 1.247 1995/02/02 15:59:26 matt - * Changed assert to int3. - * - * Revision 1.246 1995/02/01 21:02:27 matt - * Added partial fix for rendering bugs - * Ripped out laser hack system - * - * Revision 1.245 1995/01/20 15:14:30 matt - * Added parens to fix precedence bug - * - * Revision 1.244 1995/01/14 19:16:59 john - * First version of new bitmap paging code. - * - * Revision 1.243 1995/01/03 20:19:25 john - * Pretty good working version of game save. - * - * Revision 1.242 1994/12/29 13:51:05 john - * Made the floating reticle draw in the spot - * regardless of the eye offset. - * - * Revision 1.241 1994/12/23 15:02:55 john - * Tweaked floating reticle. - * - * Revision 1.240 1994/12/23 14:27:45 john - * Changed offset of floating reticle to line up with - * lasers a bit better. - * - * Revision 1.239 1994/12/23 14:22:50 john - * Added floating reticle for VR helments. - * - * Revision 1.238 1994/12/13 14:07:50 matt - * Fixed tmap_num2 bug in search mode - * - * Revision 1.237 1994/12/11 00:45:53 matt - * Fixed problem when object sort buffer got full - * - * Revision 1.236 1994/12/09 18:46:06 matt - * Added a little debugging - * - * Revision 1.235 1994/12/09 14:59:16 matt - * Added system to attach a fireball to another object for rendering purposes, - * so the fireball always renders on top of (after) the object. - * - * Revision 1.234 1994/12/08 15:46:54 matt - * Fixed buffer overflow that caused seg depth screwup - * - * Revision 1.233 1994/12/08 11:51:53 matt - * Took out some unused stuff - * - * Revision 1.232 1994/12/06 16:31:48 mike - * fix detriangulation problems. - * - * Revision 1.231 1994/12/05 15:32:51 matt - * Changed an assert to an int3 & return - * - * Revision 1.230 1994/12/04 17:28:04 matt - * Got rid of unused no_render_flag array, and took out box clear when searching - * - * Revision 1.229 1994/12/04 15:51:14 matt - * Fixed linear tmap transition for objects - * - * Revision 1.228 1994/12/03 20:16:50 matt - * Turn off window clip for objects - * - * Revision 1.227 1994/12/03 14:48:00 matt - * Restored some default settings - * - * Revision 1.226 1994/12/03 14:44:32 matt - * Fixed another difficult bug in the window clip system - * - * Revision 1.225 1994/12/02 13:19:56 matt - * Fixed rect clears at terminus of rendering - * Made a bunch of debug code compile out - * - * Revision 1.224 1994/12/02 11:58:21 matt - * Fixed window clip bug - * - * Revision 1.223 1994/11/28 21:50:42 mike - * optimizations. - * - * Revision 1.222 1994/11/28 01:32:15 mike - * turn off window clearing. - * - * Revision 1.221 1994/11/27 23:11:52 matt - * Made changes for new mprintf calling convention - * - * Revision 1.220 1994/11/20 15:58:55 matt - * Don't migrate the control center, since it doesn't move out of its segment - * - * Revision 1.219 1994/11/19 23:54:36 mike - * change window colors. - * - * Revision 1.218 1994/11/19 15:20:25 mike - * rip out unused code and data - * - * Revision 1.217 1994/11/18 13:21:24 mike - * Clear only view portals into rest of world based on value of Clear_window. - * - * Revision 1.216 1994/11/15 17:02:10 matt - * Re-added accidentally deleted variable - * - * Revision 1.215 1994/11/15 16:51:50 matt - * Made rear view only switch to rear cockpit if cockpit on in front view - * - * Revision 1.214 1994/11/14 20:47:57 john - * Attempted to strip out all the code in the game - * directory that uses any ui code. - * - * Revision 1.213 1994/11/11 15:37:07 mike - * write orange for background to show render bugs. - * - * Revision 1.212 1994/11/09 22:57:18 matt - * Keep tract of depth of segments rendered, for detail level optimization - * - * Revision 1.211 1994/11/01 23:40:14 matt - * Elegantly handler buffer getting full - * - * Revision 1.210 1994/10/31 22:28:13 mike - * Fix detriangulation bug. - * - * Revision 1.209 1994/10/31 11:48:56 mike - * Optimize detriangulation, speedup of about 4% in many cases, 0% in many. - * - * Revision 1.208 1994/10/30 20:08:34 matt - * For endlevel: added big explosion at tunnel exit; made lights in tunnel - * go out; made more explosions on walls. - * - * Revision 1.207 1994/10/27 14:14:35 matt - * Don't do light flash during endlevel sequence - * - * Revision 1.206 1994/10/11 12:05:42 mike - * Improve detriangulation. - * - * Revision 1.205 1994/10/07 15:27:00 john - * Commented out the code that moves your eye - * forward. - * - * Revision 1.204 1994/10/05 16:07:38 mike - * Don't detriangulate sides if in player's segment. Prevents player going behind a wall, - * though there are cases in which it would be ok to detriangulate these. - * - * Revision 1.203 1994/10/03 12:44:05 matt - * Took out unreferenced code - * - * Revision 1.202 1994/09/28 14:08:45 john - * Added Zoom stuff back in, but ifdef'd it out. - * - * Revision 1.201 1994/09/25 23:41:49 matt - * Changed the object load & save code to read/write the structure fields one - * at a time (rather than the whole structure at once). This mean that the - * object structure can be changed without breaking the load/save functions. - * As a result of this change, the local_object data can be and has been - * incorporated into the object array. Also, timeleft is now a property - * of all objects, and the object structure has been otherwise cleaned up. - * - * Revision 1.200 1994/09/25 15:50:10 mike - * Integrate my debug changes which shows how many textures were rendered - * this frame. - * - * Revision 1.199 1994/09/25 15:45:22 matt - * Added OBJ_LIGHT, a type of object that casts light - * Added generalized lifeleft, and moved it to local_object - * - * Revision 1.198 1994/09/15 21:23:32 matt - * Changed system to keep track of whether & what cockpit is up - * - * Revision 1.197 1994/09/15 16:30:12 mike - * Comment out call to object_render_targets, which did nothing. - * - * Revision 1.196 1994/09/07 22:25:51 matt - * Don't migrate through semi-transparent walls - * - * Revision 1.195 1994/09/07 19:16:21 mike - * Homing missile. - * - * Revision 1.194 1994/08/31 20:54:17 matt - * Don't do flash effect while whiting out - * - * Revision 1.193 1994/08/23 17:20:12 john - * Added rear-view cockpit. - * - * Revision 1.192 1994/08/22 14:36:35 john - * Made R key make a "reverse" view render. - * - * Revision 1.191 1994/08/19 20:09:26 matt - * Added end-of-level cut scene with external scene - * - * Revision 1.190 1994/08/10 19:56:17 john - * Changed font stuff; Took out old menu; messed up lots of - * other stuff like game sequencing messages, etc. - * - * Revision 1.189 1994/08/10 14:45:05 john - * *** empty log message *** - * - * Revision 1.188 1994/08/09 16:04:06 john - * Added network players to editor. - * - * Revision 1.187 1994/08/05 17:07:05 john - * Made lasers be two objects, one drawing after the other - * all the time. - * - * Revision 1.186 1994/08/05 10:07:57 matt - * Disable window check checking (i.e., always use window check) - * - * Revision 1.185 1994/08/04 19:11:30 matt - * Changed a bunch of vecmat calls to use multiple-function routines, and to - * allow the use of C macros for some functions - * - * Revision 1.184 1994/08/04 00:21:14 matt - * Cleaned up fvi & physics error handling; put in code to make sure objects - * are in correct segment; simplified segment finding for objects and points - * - * Revision 1.183 1994/08/02 19:04:28 matt - * Cleaned up vertex list functions - * - * Revision 1.182 1994/07/29 15:13:33 matt - * When window check turned off, cut render depth in half - * - * Revision 1.181 1994/07/29 11:03:50 matt - * Use highest_segment_index instead of num_segments so render works from - * the editor - * - * Revision 1.180 1994/07/29 10:04:34 mike - * Update Cursegp when an object is selected. - * - * Revision 1.179 1994/07/25 00:02:50 matt - * Various changes to accomodate new 3d, which no longer takes point numbers - * as parms, and now only takes pointers to points. - * - * Revision 1.178 1994/07/24 14:37:49 matt - * Added angles for player head - * - * Revision 1.177 1994/07/20 19:08:07 matt - * If in editor, don't move eye from center of viewer object + * $Log: not supported by cvs2svn $ + * Revision 1.6 2001/10/18 00:01:01 bradleyb + * RCS headers added/changed * * */ @@ -348,7 +55,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gameseg.h" #include "vclip.h" #include "lighting.h" -#include "cntrlcen.h" +#include "cntrlcen.h" #include "newdemo.h" #include "automap.h" #include "endlevel.h" @@ -361,7 +68,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "ogl_init.h" #endif -#define INITIAL_LOCAL_LIGHT (F1_0/4) // local light value in segment of occurence (of light emission) +#define INITIAL_LOCAL_LIGHT (F1_0/4) // local light value in segment of occurence (of light emission) #ifdef EDITOR #include "editor/editor.h" @@ -373,7 +80,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //used for checking if points have been rotated int Clear_window_color=-1; -int Clear_window=2; // 1 = Clear whole background window, 2 = clear view portals into rest of world, 0 = no clear +int Clear_window=2; // 1 = Clear whole background window, 2 = clear view portals into rest of world, 0 = no clear int RL_framecount=-1; short Rotated_last[MAX_VERTICES]; @@ -382,12 +89,12 @@ short Rotated_last[MAX_VERTICES]; // access Viewer members. object * Viewer = NULL; -vms_vector Viewer_eye; //valid during render +vms_vector Viewer_eye; //valid during render int N_render_segs; #ifndef MACINTOSH -fix Render_zoom = 0x9000; //the player's zoom factor +fix Render_zoom = 0x9000; //the player's zoom factor #else fix Render_zoom = 0xB000; #endif @@ -397,7 +104,7 @@ ubyte object_rendered[MAX_OBJECTS]; #endif #define DEFAULT_RENDER_DEPTH 16 -int Render_depth=DEFAULT_RENDER_DEPTH; //how many segments deep to render +int Render_depth=DEFAULT_RENDER_DEPTH; //how many segments deep to render int Detriangulation_on = 1; // 1 = allow rendering of triangulated side as a quad, 0 = don't allow @@ -588,18 +295,18 @@ void flash_frame() } -// ---------------------------------------------------------------------------- +// ----------------------------------------------------------------------------------- // Render a face. -// It would be nice to not have to pass in segnum and sidenum, but -// they are used for our hideously hacked in headlight system. +// It would be nice to not have to pass in segnum and sidenum, but they are used for our +// hideously hacked in headlight system. // vp is a pointer to vertex ids. // tmap1, tmap2 are texture map ids. tmap2 is the pasty one. void render_face(int segnum, int sidenum, int nv, short *vp, int tmap1, int tmap2, uvl *uvlp, int wid_flags) { // -- Using new headlight system...fix face_light; - grs_bitmap *bm; + grs_bitmap *bm; #ifdef OGL - grs_bitmap *bm2 = NULL; + grs_bitmap *bm2=NULL; #endif fix reflect; @@ -641,27 +348,29 @@ void render_face(int segnum, int sidenum, int nv, short *vp, int tmap1, int tmap } #ifdef OGL - if (ogl_alttexmerge){ - PIGGY_PAGE_IN(Textures[tmap1]); - bm = &GameBitmaps[Textures[tmap1].index]; - if (tmap2){ - PIGGY_PAGE_IN(Textures[tmap2&0x3FFF]); - bm2 = &GameBitmaps[Textures[tmap2&0x3FFF].index]; - } - if (bm2 && (bm2->bm_flags&BM_FLAG_SUPER_TRANSPARENT)){ - bm = texmerge_get_cached_bitmap( tmap1, tmap2 ); - bm2 = NULL; - } - } else + if (ogl_alttexmerge){ + PIGGY_PAGE_IN(Textures[tmap1]); + bm = &GameBitmaps[Textures[tmap1].index]; + if (tmap2){ + PIGGY_PAGE_IN(Textures[tmap2&0x3FFF]); + bm2 = &GameBitmaps[Textures[tmap2&0x3FFF].index]; + } + if (bm2 && (bm2->bm_flags&BM_FLAG_SUPER_TRANSPARENT)){ + bm = texmerge_get_cached_bitmap( tmap1, tmap2 ); + bm2 = NULL; + } + }else #endif - // New code for overlapping textures... - if (tmap2 != 0) { - bm = texmerge_get_cached_bitmap( tmap1, tmap2 ); - } else { - bm = &GameBitmaps[Textures[tmap1].index]; - PIGGY_PAGE_IN(Textures[tmap1]); - } + // New code for overlapping textures... + if (tmap2 != 0) + { + bm = texmerge_get_cached_bitmap( tmap1, tmap2 ); + } + else { + bm = &GameBitmaps[Textures[tmap1].index]; + PIGGY_PAGE_IN(Textures[tmap1]); + } Assert( !(bm->bm_flags & BM_FLAG_PAGED_OUT) ); @@ -704,19 +413,19 @@ void render_face(int segnum, int sidenum, int nv, short *vp, int tmap1, int tmap #endif #ifdef OGL - if (bm2){ - g3_draw_tmap_2(nv,pointlist,(g3s_uvl *) uvl_copy,bm,bm2,((tmap2&0xC000)>>14) & 3); - }else + if (bm2){ + g3_draw_tmap_2(nv,pointlist,(g3s_uvl *) uvl_copy,bm,bm2,((tmap2&0xC000)>>14) & 3); + }else #endif - g3_draw_tmap(nv,pointlist,(g3s_uvl *) uvl_copy,bm); + g3_draw_tmap(nv,pointlist,(g3s_uvl *) uvl_copy,bm); -#ifndef NDEBUG + #ifndef NDEBUG if (Outline_mode) draw_outline(nv, pointlist); -#endif + #endif } #ifdef EDITOR -// ---------------------------------------------------------------------------- +// ----------------------------------------------------------------------------------- // Only called if editor active. // Used to determine which face was clicked on. void check_face(int segnum, int sidenum, int facenum, int nv, short *vp, int tmap1, int tmap2, uvl *uvlp) @@ -753,6 +462,7 @@ void check_face(int segnum, int sidenum, int facenum, int nv, short *vp, int tma found_side = sidenum; found_face = facenum; } + } } #endif @@ -784,12 +494,12 @@ void render_side(segment *segp, int sidenum) if (!(wid_flags & WID_RENDER_FLAG)) //if (WALL_IS_DOORWAY(segp, sidenum) == WID_NO_WALL) return; -#ifdef COMPACT_SEGS - get_side_normals(segp, sidenum, &normals[0], &normals[1] ); -#else - normals[0] = segp->sides[sidenum].normals[0]; - normals[1] = segp->sides[sidenum].normals[1]; -#endif + #ifdef COMPACT_SEGS + get_side_normals(segp, sidenum, &normals[0], &normals[1] ); + #else + normals[0] = segp->sides[sidenum].normals[0]; + normals[1] = segp->sides[sidenum].normals[1]; + #endif // ========== Mark: Here is the change...beginning here: ========== @@ -1335,7 +1045,7 @@ int matt_find_connect_side(int seg0,int seg1); char visited2[MAX_SEGMENTS]; #endif -unsigned char visited[MAX_SEGMENTS]; +char visited[MAX_SEGMENTS]; short Render_list[MAX_RENDER_SEGS]; short Seg_depth[MAX_RENDER_SEGS]; //depth for each seg in Render_list ubyte processed[MAX_RENDER_SEGS]; //whether each entry has been processed @@ -1676,90 +1386,6 @@ void add_obj_to_seglist(int objnum,int listnum) //mprintf((0," added!\n")); } -#ifdef __sun__ -// the following is a drop-in replacement for the broken libc qsort on solaris -// taken from http://www.snippets.org/snippets/portable/RG_QSORT+C.php3 - -#define qsort qsort_dropin - -/******************************************************************/ -/* qsort.c -- Non-Recursive ANSI Quicksort function */ -/* Public domain by Raymond Gardner, Englewood CO February 1991 */ -/******************************************************************/ -#define COMP(a, b) ((*comp)((void *)(a), (void *)(b))) -#define T 7 // subfiles of <= T elements will be insertion sorteded (T >= 3) -#define SWAP(a, b) (swap_bytes((char *)(a), (char *)(b), size)) - -static void swap_bytes(char *a, char *b, size_t nbytes) -{ - char tmp; - do { - tmp = *a; *a++ = *b; *b++ = tmp; - } while ( --nbytes ); -} - -void qsort(void *basep, size_t nelems, size_t size, - int (*comp)(const void *, const void *)) -{ - char *stack[40], **sp; /* stack and stack pointer */ - char *i, *j, *limit; /* scan and limit pointers */ - size_t thresh; /* size of T elements in bytes */ - char *base; /* base pointer as char * */ - base = (char *)basep; /* set up char * base pointer */ - thresh = T * size; /* init threshold */ - sp = stack; /* init stack pointer */ - limit = base + nelems * size;/* pointer past end of array */ - for ( ;; ) { /* repeat until break... */ - if ( limit - base > thresh ) { /* if more than T elements */ - /* swap base with middle */ - SWAP((((limit-base)/size)/2)*size+base, base); - i = base + size; /* i scans left to right */ - j = limit - size; /* j scans right to left */ - if ( COMP(i, j) > 0 ) /* Sedgewick's */ - SWAP(i, j); /* three-element sort */ - if ( COMP(base, j) > 0 ) /* sets things up */ - SWAP(base, j); /* so that */ - if ( COMP(i, base) > 0 ) /* *i <= *base <= *j */ - SWAP(i, base); /* *base is pivot element */ - for ( ;; ) { /* loop until break */ - do /* move i right */ - i += size; /* until *i >= pivot */ - while ( COMP(i, base) < 0 ); - do /* move j left */ - j -= size; /* until *j <= pivot */ - while ( COMP(j, base) > 0 ); - if ( i > j ) /* if pointers crossed */ - break; /* break loop */ - SWAP(i, j); /* else swap elements, keep scanning*/ - } - SWAP(base, j); /* move pivot into correct place */ - if ( j - base > limit - i ) { /* if left subfile larger */ - sp[0] = base; /* stack left subfile base */ - sp[1] = j; /* and limit */ - base = i; /* sort the right subfile */ - } else { /* else right subfile larger*/ - sp[0] = i; /* stack right subfile base */ - sp[1] = limit; /* and limit */ - limit = j; /* sort the left subfile */ - } - sp += 2; /* increment stack pointer */ - } else { /* else subfile is small, use insertion sort */ - for ( j = base, i = j+size; i < limit; j = i, i += size ) - for ( ; COMP(j, j+size) > 0; j -= size ) { - SWAP(j, j+size); - if ( j == base ) - break; - } - if ( sp != stack ) { /* if any entries on stack */ - sp -= 2; /* pop the base and limit */ - base = sp[0]; - limit = sp[1]; - } else /* else stack empty, done */ - break; - } - } -} -#endif // __sun__ qsort drop-in replacement #define SORT_LIST_SIZE 100 @@ -2084,7 +1710,7 @@ void render_frame(fix eye_offset, int window_num) gr_clear_canvas(Clear_window_color); #endif - render_mine(start_seg_num, eye_offset, window_num); + render_mine(start_seg_num,eye_offset, window_num); if (Use_player_head_angles ) draw_3d_reticle(eye_offset); @@ -2373,7 +1999,7 @@ void render_mine(int start_seg_num,fix eye_offset, int window_num) render_start_frame(); - #if defined(EDITOR) && !defined(NDEBUG) + #if defined(EDITOR) && !defined(NDEUBG) if (Show_only_curside) { rotate_list(8,Cursegp->verts); render_side(Cursegp,Curside); @@ -2460,7 +2086,7 @@ void render_mine(int start_seg_num,fix eye_offset, int window_num) Current_seg_depth = Seg_depth[nn]; //if (!no_render_flag[nn]) - if (segnum!=-1 && (_search_mode || visited[segnum]!=255)) { + if (segnum!=-1 && (_search_mode || visited[segnum]!=-1)) { //set global render window vars if (window_check) { @@ -2552,7 +2178,7 @@ void render_mine(int start_seg_num,fix eye_offset, int window_num) // -- commented out by mk on 09/14/94...did i do a good thing?? object_render_targets(); #ifdef EDITOR - #ifndef NDEBUG + #ifndef NDEUBG //draw curedge stuff if (Outline_mode) outline_seg_side(Cursegp,Curside,Curedge,Curvert); #endif diff --git a/main/render.h b/main/render.h index 3cb50347..c634b08f 100644 --- a/main/render.h +++ b/main/render.h @@ -18,13 +18,13 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "object.h" -#define MAX_RENDER_SEGS 500 -#define OBJS_PER_SEG 5 -#define N_EXTRA_OBJ_LISTS 50 +#define MAX_RENDER_SEGS 500 +#define OBJS_PER_SEG 5 +#define N_EXTRA_OBJ_LISTS 50 -extern int Clear_window; // 1 = Clear whole background window, 2 = clear view portals into rest of world, 0 = no clear +extern int Clear_window; // 1 = Clear whole background window, 2 = clear view portals into rest of world, 0 = no clear -void render_frame(fix eye_offset, int window_num); //draws the world into the current canvas +void render_frame(fix eye_offset, int window_num); //draws the world into the current canvas //cycle the flashing light for when mine destroyed void flash_frame(); @@ -54,7 +54,7 @@ extern fix Render_zoom; //the player's zoom factor //This is used internally to render_frame(), but is included here so AI //can use it for its own purposes. -extern unsigned char visited[MAX_SEGMENTS]; +extern char visited[MAX_SEGMENTS]; extern int N_render_segs; extern short Render_list[MAX_RENDER_SEGS]; @@ -71,7 +71,7 @@ extern int Use_player_head_angles; extern vms_angvec Player_head_angles; // -// Routines for conditionally rotating & projecting points +// Routines for conditionally rotating & projecting points // //This must be called at the start of the frame if rotate_list() will be used @@ -88,3 +88,4 @@ extern void render_mine(int start_seg_num,fix eye_offset, int window_num); extern void update_rendered_data(int window_num, object *viewer, int rear_view_flag, int user); #endif + diff --git a/main/reorder.h b/main/reorder.h deleted file mode 100644 index 80e9b8e3..00000000 --- a/main/reorder.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * $Source: /cvs/cvsroot/d2x/main/reorder.h,v $ - * $Revision: 1.1 $ - * $Author: bradleyb $ - * $Date: 2002-02-14 09:05:33 $ - * - * User interface+data for weapon autoselect order selection - * - * $Log: not supported by cvs2svn $ - * - */ - -#ifndef _REORDER_H -#define _REORDER_H - -/* These are defined in weapon.c */ -extern void ReorderPrimary(); -extern void ReorderSecondary(); - -#endif diff --git a/main/robot.c b/main/robot.c index 073ef013..8c662f62 100644 --- a/main/robot.c +++ b/main/robot.c @@ -1,4 +1,3 @@ -/* $Id: robot.c,v 1.4 2002-08-02 04:57:19 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -41,48 +40,49 @@ robot_info Robot_info[MAX_ROBOT_TYPES]; jointpos Robot_joints[MAX_ROBOT_JOINTS] = { //gun 0 - {2,{deg(-30),0,0}}, //rest (2 joints) - {3,{deg(-40),0,0}}, - - {2,{deg(0),0,0}}, //alert - {3,{deg(0),0,0}}, - - {2,{deg(0),0,0}}, //fire - {3,{deg(0),0,0}}, - - {2,{deg(50),0,0}}, //recoil - {3,{deg(-50),0,0}}, - - {2,{deg(10),0,deg(70)}}, //flinch - {3,{deg(0),deg(20),0}}, - + {2,{deg(-30),0,0}}, //rest (2 joints) + {3,{deg(-40),0,0}}, + + {2,{deg(0),0,0}}, //alert + {3,{deg(0),0,0}}, + + {2,{deg(0),0,0}}, //fire + {3,{deg(0),0,0}}, + + {2,{deg(50),0,0}}, //recoil + {3,{deg(-50),0,0}}, + + {2,{deg(10),0,deg(70)}}, //flinch + {3,{deg(0),deg(20),0}}, + //gun 1 - {4,{deg(-30),0,0}}, //rest (2 joints) - {5,{deg(-40),0,0}}, - - {4,{deg(0),0,0}}, //alert - {5,{deg(0),0,0}}, - - {4,{deg(0),0,0}}, //fire - {5,{deg(0),0,0}}, - - {4,{deg(50),0,0}}, //recoil - {5,{deg(-50),0,0}}, - - {4,{deg(20),0,deg(-50)}}, //flinch - {5,{deg(0),0,deg(20)}}, - + {4,{deg(-30),0,0}}, //rest (2 joints) + {5,{deg(-40),0,0}}, + + {4,{deg(0),0,0}}, //alert + {5,{deg(0),0,0}}, + + {4,{deg(0),0,0}}, //fire + {5,{deg(0),0,0}}, + + {4,{deg(50),0,0}}, //recoil + {5,{deg(-50),0,0}}, + + {4,{deg(20),0,deg(-50)}}, //flinch + {5,{deg(0),0,deg(20)}}, + //rest of body (the head) - {1,{deg(70),0,0}}, //rest (1 joint, head) - - {1,{deg(0),0,0}}, //alert + {1,{deg(70),0,0}}, //rest (1 joint, head) - {1,{deg(0),0,0}}, //fire + {1,{deg(0),0,0}}, //alert + + {1,{deg(0),0,0}}, //fire + + {1,{deg(0),0,0}}, //recoil - {1,{deg(0),0,0}}, //recoil + {1,{deg(-20),deg(15),0}}, //flinch - {1,{deg(-20),deg(15),0}}, //flinch }; @@ -132,7 +132,7 @@ void calc_gun_point(vms_vector *gun_point,object *obj,int gun_num) vm_copy_transpose_matrix(&m,&obj->orient); vm_vec_rotate(gun_point,&pnt,&m); vm_vec_add2(gun_point,&obj->pos); - + } //fills in ptr to list of joints, and returns the number of joints in list @@ -184,11 +184,11 @@ void set_robot_state(object *obj,int state) //--unused-- test_anim_states() //--unused-- { //--unused-- set_robot_state(&Objects[1],cur_state); -//--unused-- +//--unused-- //--unused-- mprintf(0,"Robot in state %d\n",cur_state); -//--unused-- +//--unused-- //--unused-- cur_state = (cur_state+1)%N_ANIM_STATES; -//--unused-- +//--unused-- //--unused-- } //set the animation angles for this robot. Gun fields of robot info must @@ -238,121 +238,4 @@ void robot_set_angles(robot_info *r,polymodel *pm,vms_angvec angs[N_ANIM_STATES] } -#ifndef FAST_FILE_IO -/* - * reads n jointlist structs from a CFILE - */ -static int jointlist_read_n(jointlist *jl, int n, CFILE *fp) -{ - int i; - - for (i = 0; i < n; i++) { - jl[i].n_joints = cfile_read_short(fp); - jl[i].offset = cfile_read_short(fp); - } - return i; -} - -/* - * reads n robot_info structs from a CFILE - */ -int robot_info_read_n(robot_info *ri, int n, CFILE *fp) -{ - int i, j; - - for (i = 0; i < n; i++) { - ri[i].model_num = cfile_read_int(fp); - for (j = 0; j < MAX_GUNS; j++) - cfile_read_vector(&(ri[i].gun_points[j]), fp); - cfread(ri[i].gun_submodels, MAX_GUNS, 1, fp); - - ri[i].exp1_vclip_num = cfile_read_short(fp); - ri[i].exp1_sound_num = cfile_read_short(fp); - - ri[i].exp2_vclip_num = cfile_read_short(fp); - ri[i].exp2_sound_num = cfile_read_short(fp); - - ri[i].weapon_type = cfile_read_byte(fp); - ri[i].weapon_type2 = cfile_read_byte(fp); - ri[i].n_guns = cfile_read_byte(fp); - ri[i].contains_id = cfile_read_byte(fp); - - ri[i].contains_count = cfile_read_byte(fp); - ri[i].contains_prob = cfile_read_byte(fp); - ri[i].contains_type = cfile_read_byte(fp); - ri[i].kamikaze = cfile_read_byte(fp); - - ri[i].score_value = cfile_read_short(fp); - ri[i].badass = cfile_read_byte(fp); - ri[i].energy_drain = cfile_read_byte(fp); - - ri[i].lighting = cfile_read_fix(fp); - ri[i].strength = cfile_read_fix(fp); - - ri[i].mass = cfile_read_fix(fp); - ri[i].drag = cfile_read_fix(fp); - - for (j = 0; j < NDL; j++) - ri[i].field_of_view[j] = cfile_read_fix(fp); - for (j = 0; j < NDL; j++) - ri[i].firing_wait[j] = cfile_read_fix(fp); - for (j = 0; j < NDL; j++) - ri[i].firing_wait2[j] = cfile_read_fix(fp); - for (j = 0; j < NDL; j++) - ri[i].turn_time[j] = cfile_read_fix(fp); - for (j = 0; j < NDL; j++) - ri[i].max_speed[j] = cfile_read_fix(fp); - for (j = 0; j < NDL; j++) - ri[i].circle_distance[i] = cfile_read_fix(fp); - cfread(ri[i].rapidfire_count, NDL, 1, fp); - - cfread(ri[i].evade_speed, NDL, 1, fp); - - ri[i].cloak_type = cfile_read_byte(fp); - ri[i].attack_type = cfile_read_byte(fp); - - ri[i].see_sound = cfile_read_byte(fp); - ri[i].attack_sound = cfile_read_byte(fp); - ri[i].claw_sound = cfile_read_byte(fp); - ri[i].taunt_sound = cfile_read_byte(fp); - - ri[i].boss_flag = cfile_read_byte(fp); - ri[i].companion = cfile_read_byte(fp); - ri[i].smart_blobs = cfile_read_byte(fp); - ri[i].energy_blobs = cfile_read_byte(fp); - - ri[i].thief = cfile_read_byte(fp); - ri[i].pursuit = cfile_read_byte(fp); - ri[i].lightcast = cfile_read_byte(fp); - ri[i].death_roll = cfile_read_byte(fp); - - ri[i].flags = cfile_read_byte(fp); - cfread(ri[i].pad, 3, 1, fp); - - ri[i].deathroll_sound = cfile_read_byte(fp); - ri[i].glow = cfile_read_byte(fp); - ri[i].behavior = cfile_read_byte(fp); - ri[i].aim = cfile_read_byte(fp); - - for (j = 0; j < MAX_GUNS + 1; j++) - jointlist_read_n(ri[i].anim_states[j], N_ANIM_STATES, fp); - - ri[i].always_0xabcd = cfile_read_int(fp); - } - return i; -} - -/* - * reads n jointpos structs from a CFILE - */ -int jointpos_read_n(jointpos *jp, int n, CFILE *fp) -{ - int i; - for (i = 0; i < n; i++) { - jp[i].jointnum = cfile_read_short(fp); - cfile_read_angvec(&jp[i].angles, fp); - } - return i; -} -#endif diff --git a/main/robot.h b/main/robot.h index 1f0a6ac2..51122d90 100644 --- a/main/robot.h +++ b/main/robot.h @@ -1,4 +1,3 @@ -/* $Id: robot.h,v 1.3 2002-08-02 04:57:19 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -20,21 +19,20 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "vecmat.h" #include "object.h" #include "game.h" -#include "cfile.h" -#define MAX_GUNS 8 //should be multiple of 4 for ubyte array +#define MAX_GUNS 8 //should be multiple of 4 for ubyte array //Animation states -#define AS_REST 0 -#define AS_ALERT 1 -#define AS_FIRE 2 -#define AS_RECOIL 3 -#define AS_FLINCH 4 -#define N_ANIM_STATES 5 +#define AS_REST 0 +#define AS_ALERT 1 +#define AS_FIRE 2 +#define AS_RECOIL 3 +#define AS_FLINCH 4 +#define N_ANIM_STATES 5 -#define RI_CLOAKED_NEVER 0 -#define RI_CLOAKED_ALWAYS 1 -#define RI_CLOAKED_EXCEPT_FIRING 2 +#define RI_CLOAKED_NEVER 0 +#define RI_CLOAKED_ALWAYS 1 +#define RI_CLOAKED_EXCEPT_FIRING 2 //describes the position of a certain joint typedef struct jointpos { @@ -49,142 +47,127 @@ typedef struct jointlist { } jointlist; //robot info flags -#define RIF_BIG_RADIUS 1 //pad the radius to fix robots firing through walls -#define RIF_THIEF 2 //this guy steals! +#define RIF_BIG_RADIUS 1 //pad the radius to fix robots firing through walls +#define RIF_THIEF 2 //this guy steals! -// Robot information +// Robot information typedef struct robot_info { - int model_num; // which polygon model? - vms_vector gun_points[MAX_GUNS]; // where each gun model is - ubyte gun_submodels[MAX_GUNS]; // which submodel is each gun in? - - short exp1_vclip_num; - short exp1_sound_num; - - short exp2_vclip_num; - short exp2_sound_num; - - byte weapon_type; - byte weapon_type2; // Secondary weapon number, -1 means none, otherwise gun #0 fires this weapon. - byte n_guns; // how many different gun positions - byte contains_id; // ID of powerup this robot can contain. - - byte contains_count; // Max number of things this instance can contain. - byte contains_prob; // Probability that this instance will contain something in N/16 - byte contains_type; // Type of thing contained, robot or powerup, in bitmaps.tbl, !0=robot, 0=powerup - byte kamikaze; // !0 means commits suicide when hits you, strength thereof. 0 means no. - - short score_value; // Score from this robot. - byte badass; // Dies with badass explosion, and strength thereof, 0 means NO. - byte energy_drain; // Points of energy drained at each collision. - - fix lighting; // should this be here or with polygon model? - fix strength; // Initial shields of robot - - fix mass; // how heavy is this thing? - fix drag; // how much drag does it have? - - fix field_of_view[NDL]; // compare this value with forward_vector.dot.vector_to_player, if field_of_view <, then robot can see player - fix firing_wait[NDL]; // time in seconds between shots - fix firing_wait2[NDL]; // time in seconds between shots - fix turn_time[NDL]; // time in seconds to rotate 360 degrees in a dimension -// -- unused, mk, 05/25/95 fix fire_power[NDL]; // damage done by a hit from this robot -// -- unused, mk, 05/25/95 fix shield[NDL]; // shield strength of this robot - fix max_speed[NDL]; // maximum speed attainable by this robot - fix circle_distance[NDL]; // distance at which robot circles player - - byte rapidfire_count[NDL]; // number of shots fired rapidly - byte evade_speed[NDL]; // rate at which robot can evade shots, 0=none, 4=very fast - byte cloak_type; // 0=never, 1=always, 2=except-when-firing - byte attack_type; // 0=firing, 1=charge (like green guy) - - ubyte see_sound; // sound robot makes when it first sees the player - ubyte attack_sound; // sound robot makes when it attacks the player - ubyte claw_sound; // sound robot makes as it claws you (attack_type should be 1) - ubyte taunt_sound; // sound robot makes after you die - - byte boss_flag; // 0 = not boss, 1 = boss. Is that surprising? - byte companion; // Companion robot, leads you to things. - byte smart_blobs; // how many smart blobs are emitted when this guy dies! - byte energy_blobs; // how many smart blobs are emitted when this guy gets hit by energy weapon! - - byte thief; // !0 means this guy can steal when he collides with you! - byte pursuit; // !0 means pursues player after he goes around a corner. 4 = 4/2 pursue up to 4/2 seconds after becoming invisible if up to 4 segments away - byte lightcast; // Amount of light cast. 1 is default. 10 is very large. - byte death_roll; // 0 = dies without death roll. !0 means does death roll, larger = faster and louder + int model_num; // which polygon model? + vms_vector gun_points[MAX_GUNS]; // where each gun model is + ubyte gun_submodels[MAX_GUNS]; // which submodel is each gun in? + + short exp1_vclip_num; + short exp1_sound_num; + + short exp2_vclip_num; + short exp2_sound_num; + + byte weapon_type; + byte weapon_type2; // Secondary weapon number, -1 means none, otherwise gun #0 fires this weapon. + byte n_guns; // how many different gun positions + byte contains_id; // ID of powerup this robot can contain. + + byte contains_count; // Max number of things this instance can contain. + byte contains_prob; // Probability that this instance will contain something in N/16 + byte contains_type; // Type of thing contained, robot or powerup, in bitmaps.tbl, !0=robot, 0=powerup + byte kamikaze; // !0 means commits suicide when hits you, strength thereof. 0 means no. + + short score_value; // Score from this robot. + byte badass; // Dies with badass explosion, and strength thereof, 0 means NO. + byte energy_drain; // Points of energy drained at each collision. + + fix lighting; // should this be here or with polygon model? + fix strength; // Initial shields of robot + + fix mass; // how heavy is this thing? + fix drag; // how much drag does it have? + + fix field_of_view[NDL]; // compare this value with forward_vector.dot.vector_to_player, if field_of_view <, then robot can see player + fix firing_wait[NDL]; // time in seconds between shots + fix firing_wait2[NDL]; // time in seconds between shots + fix turn_time[NDL]; // time in seconds to rotate 360 degrees in a dimension +// -- unused, mk, 05/25/95 fix fire_power[NDL]; // damage done by a hit from this robot +// -- unused, mk, 05/25/95 fix shield[NDL]; // shield strength of this robot + fix max_speed[NDL]; // maximum speed attainable by this robot + fix circle_distance[NDL]; // distance at which robot circles player + + byte rapidfire_count[NDL]; // number of shots fired rapidly + byte evade_speed[NDL]; // rate at which robot can evade shots, 0=none, 4=very fast + byte cloak_type; // 0=never, 1=always, 2=except-when-firing + byte attack_type; // 0=firing, 1=charge (like green guy) + + ubyte see_sound; // sound robot makes when it first sees the player + ubyte attack_sound; // sound robot makes when it attacks the player + ubyte claw_sound; // sound robot makes as it claws you (attack_type should be 1) + ubyte taunt_sound; // sound robot makes after you die + + byte boss_flag; // 0 = not boss, 1 = boss. Is that surprising? + byte companion; // Companion robot, leads you to things. + byte smart_blobs; // how many smart blobs are emitted when this guy dies! + byte energy_blobs; // how many smart blobs are emitted when this guy gets hit by energy weapon! + + byte thief; // !0 means this guy can steal when he collides with you! + byte pursuit; // !0 means pursues player after he goes around a corner. 4 = 4/2 pursue up to 4/2 seconds after becoming invisible if up to 4 segments away + byte lightcast; // Amount of light cast. 1 is default. 10 is very large. + byte death_roll; // 0 = dies without death roll. !0 means does death roll, larger = faster and louder //boss_flag, companion, thief, & pursuit probably should also be bits in the flags byte. - ubyte flags; // misc properties - ubyte pad[3]; // alignment + ubyte flags; // misc properties + ubyte pad[3]; // alignment - ubyte deathroll_sound; // if has deathroll, what sound? - ubyte glow; // apply this light to robot itself. stored as 4:4 fixed-point - ubyte behavior; // Default behavior. - ubyte aim; // 255 = perfect, less = more likely to miss. 0 != random, would look stupid. 0=45 degree spread. Specify in bitmaps.tbl in range 0.0..1.0 + ubyte deathroll_sound; // if has deathroll, what sound? + ubyte glow; // apply this light to robot itself. stored as 4:4 fixed-point + ubyte behavior; // Default behavior. + ubyte aim; // 255 = perfect, less = more likely to miss. 0 != random, would look stupid. 0=45 degree spread. Specify in bitmaps.tbl in range 0.0..1.0 //animation info jointlist anim_states[MAX_GUNS+1][N_ANIM_STATES]; - int always_0xabcd; // debugging + int always_0xabcd; // debugging } __pack__ robot_info; -#define MAX_ROBOT_TYPES 85 // maximum number of robot types +#define MAX_ROBOT_TYPES 85 // maximum number of robot types -#define ROBOT_NAME_LENGTH 16 -extern char Robot_names[MAX_ROBOT_TYPES][ROBOT_NAME_LENGTH]; +#define ROBOT_NAME_LENGTH 16 +extern char Robot_names[MAX_ROBOT_TYPES][ROBOT_NAME_LENGTH]; //the array of robots types -extern robot_info Robot_info[]; // Robot info for AI system, loaded from bitmaps.tbl. +extern robot_info Robot_info[]; // Robot info for AI system, loaded from bitmaps.tbl. //how many kinds of robots -extern int N_robot_types; // Number of robot types. We used to assume this was the same as N_polygon_models. +extern int N_robot_types; // Number of robot types. We used to assume this was the same as N_polygon_models. //test data for one robot #define MAX_ROBOT_JOINTS 1600 extern jointpos Robot_joints[MAX_ROBOT_JOINTS]; -extern int N_robot_joints; +extern int N_robot_joints; //given an object and a gun number, return position in 3-space of gun //fills in gun_point void calc_gun_point(vms_vector *gun_point,object *obj,int gun_num); //void calc_gun_point(vms_vector *gun_point,int objnum,int gun_num); -// Tells joint positions for a gun to be in a specified state. -// A gun can have associated with it any number of joints. In order to tell whether a gun is a certain -// state (such as FIRE or ALERT), you should call this function and check the returned joint positions -// against the robot's gun's joint positions. This function should also be called to determine how to -// move a gun into a desired position. -// For now (May 30, 1994), it is assumed that guns will linearly interpolate from one joint position to another. -// There is no ordering of joint movement, so it's impossible to guarantee that a strange starting position won't -// cause a gun to move through a robot's body, for example. - -// Given: -// jp_list_ptr pointer to list of joint angles, on exit, this is pointing at a static array -// robot_type type of robot for which to get joint information. A particular type, not an instance of a robot. -// gun_num gun number. If in 0..Robot_info[robot_type].n_guns-1, then it is a gun, else it refers to non-animating parts of robot. -// state state about which to get information. Legal states in range 0..N_ANIM_STATES-1, defined in robot.h, are: -// AS_REST, AS_ALERT, AS_FIRE, AS_RECOIL, AS_FLINCH - -// On exit: -// Returns number of joints in list. -// jp_list_ptr is stuffed with a pointer to a static array of joint positions. This pointer is valid forever. +// Tells joint positions for a gun to be in a specified state. +// A gun can have associated with it any number of joints. In order to tell whether a gun is a certain +// state (such as FIRE or ALERT), you should call this function and check the returned joint positions +// against the robot's gun's joint positions. This function should also be called to determine how to +// move a gun into a desired position. +// For now (May 30, 1994), it is assumed that guns will linearly interpolate from one joint position to another. +// There is no ordering of joint movement, so it's impossible to guarantee that a strange starting position won't +// cause a gun to move through a robot's body, for example. + +// Given: +// jp_list_ptr pointer to list of joint angles, on exit, this is pointing at a static array +// robot_type type of robot for which to get joint information. A particular type, not an instance of a robot. +// gun_num gun number. If in 0..Robot_info[robot_type].n_guns-1, then it is a gun, else it refers to non-animating parts of robot. +// state state about which to get information. Legal states in range 0..N_ANIM_STATES-1, defined in robot.h, are: +// AS_REST, AS_ALERT, AS_FIRE, AS_RECOIL, AS_FLINCH + +// On exit: +// Returns number of joints in list. +// jp_list_ptr is stuffed with a pointer to a static array of joint positions. This pointer is valid forever. extern int robot_get_anim_state(jointpos **jp_list_ptr,int robot_type,int gun_num,int state); -#ifdef FAST_FILE_IO -#define robot_info_read_n(ri, n, fp) cfread(ri, sizeof(robot_info), n, fp) -#define jointpos_read_n(jp, n, fp) cfread(jp, sizeof(jointpos), n, fp) -#else -/* - * reads n robot_info structs from a CFILE - */ -extern int robot_info_read_n(robot_info *ri, int n, CFILE *fp); - -/* - * reads n jointpos structs from a CFILE - */ -extern int jointpos_read_n(jointpos *jp, int n, CFILE *fp); -#endif - #endif diff --git a/main/scores.c b/main/scores.c index 163e75c4..4d334661 100644 --- a/main/scores.c +++ b/main/scores.c @@ -1,4 +1,3 @@ -/* $Id: scores.c,v 1.3 2003-03-15 14:17:52 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,251 +7,17 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Inferno High Scores and Statistics System - * - * Old Log: - * Revision 1.1 1995/12/05 16:06:29 allender - * Initial revision - * - * Revision 1.3 1995/08/14 09:25:16 allender - * add byteswap header - * - * Revision 1.2 1995/07/14 13:45:17 allender - * fixed up high score code to work and look pretty good - * needs some work tho' - * - * Revision 1.1 1995/05/16 15:30:42 allender - * Initial revision - * - * Revision 2.2 1995/06/15 12:13:54 john - * Made end game, win game and title sequences all go - * on after 5 minutes automatically. - * - * Revision 2.1 1995/03/06 15:23:57 john - * New screen techniques. - * - * Revision 2.0 1995/02/27 11:30:53 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.109 1995/02/09 12:23:19 rob - * Added assert for length of filename. - * - * Revision 1.108 1995/01/03 17:33:24 john - * Made scrolling textbox. Used it for scores cool saying. - * - * Revision 1.107 1994/12/28 10:42:51 john - * More VFX tweaking. - * - * Revision 1.106 1994/12/28 10:26:19 john - * Fixed some VFX problems. - * - * Revision 1.105 1994/12/15 16:42:12 adam - * some fix - * - * Revision 1.104 1994/12/14 11:59:19 john - * Changed the default high scores. - * - * Revision 1.103 1994/12/09 00:41:12 mike - * fix hang in automap print screen - * - * Revision 1.102 1994/12/07 00:36:26 mike - * scores sequencing stuff. - * - * Revision 1.101 1994/12/06 15:14:21 yuan - * Localization - * - * Revision 1.100 1994/12/03 17:07:52 yuan - * Localization 368 - * - * Revision 1.99 1994/12/03 14:49:27 mark - * Fixed john's bug with previous. - * - * Revision 1.98 1994/12/03 14:43:54 john - * Added enter, space to exit scores. - * - * Revision 1.97 1994/12/03 14:32:34 john - * Added integrated-super-deluxe-ctrl-r to reset high scores. - * - * Revision 1.96 1994/12/01 20:15:20 yuan - * Localization - * - * Revision 1.95 1994/11/30 19:36:36 john - * Made Gravis Ultrasound work again. Made the scores blink - * at a constant rate. Revamped the newmenu background storage, - * which hopefully fixed some bugs. Made menus in ame not pause - * sound, except for the pause key. ^== Game! - * - * Revision 1.94 1994/11/30 12:32:08 john - * Made secret levels print correctly. - * - * Revision 1.93 1994/11/30 12:06:47 mike - * fix bug: looper not initialized. - * - * Revision 1.92 1994/11/29 13:20:04 john - * changed the "Wow! You placed .." to something better. - * - * Revision 1.91 1994/11/29 01:35:38 john - * Made it so that even if you don't get a high score, you still show - * up on the chart.. - * - * Revision 1.90 1994/11/23 17:29:29 mike - * fix xx-xx level bug in high scores. - * - * Revision 1.89 1994/11/22 16:55:27 mike - * allow high scores even in pudly trainee level. - * - * Revision 1.88 1994/11/21 17:28:33 john - * Changed default score values. - * - * Revision 1.87 1994/11/18 23:37:53 john - * Changed some shorts to ints. - * - * Revision 1.86 1994/11/13 15:39:24 john - * Added critical error handler to game. Took out -editor command line - * option because it didn't work anymore and wasn't worth fixing. Made scores - * not use MINER enviroment variable on release version, and made scores - * not print an error if there is no descent.hi. - * - * Revision 1.85 1994/11/06 10:15:58 john - * Took out kill % and hostage % - * - * Revision 1.84 1994/11/05 15:03:39 john - * Added non-popup menu for the main menu, so that scores and credits don't have to save - * the background. - * - * Revision 1.83 1994/11/05 14:05:57 john - * Fixed fade transitions between all screens by making gr_palette_fade_in and out keep - * track of whether the palette is faded in or not. Then, wherever the code needs to fade out, - * it just calls gr_palette_fade_out and it will fade out if it isn't already. The same with fade_in. - * This eliminates the need for all the flags like Menu_fade_out, game_fade_in palette, etc. - * - * Revision 1.82 1994/11/04 20:11:41 john - * Neatening up palette stuff with demos. - * - * Revision 1.81 1994/11/04 12:02:34 john - * Fixed fading transitions a bit more. - * - * Revision 1.80 1994/10/27 12:10:39 john - * Moved kill % a little to the right. - * - * Revision 1.79 1994/10/24 20:25:03 john - * Fixed bug with space at end of 1 line message. - * Made Enter go between the two input lines. - * - * Revision 1.78 1994/10/24 18:20:18 john - * Made the current high score flash. - * - * Revision 1.77 1994/10/24 13:37:22 mike - * Fix grammar error. --anal Mike. - * - * Revision 1.76 1994/10/22 13:19:19 john - * Made joy/mouse buttons leave score screen. - * - * Revision 1.75 1994/10/21 15:26:57 john - * Used PrtScr instead of F2. - * - * Revision 1.74 1994/10/21 13:54:21 matt - * Replace '1' with special wide '1' to make numbers line up - * - * Revision 1.73 1994/10/19 20:48:01 john - * Made so that people playing on wimp level - * can't get high scores. - * - * Revision 1.72 1994/10/19 15:14:05 john - * Took % hits out of player structure, made %kills work properly. - * - * Revision 1.71 1994/10/19 14:39:27 john - * Finished up; added keys to prtscr, int3. - * - * Revision 1.70 1994/10/19 12:44:09 john - * Added hours field to player structure. - * - * Revision 1.69 1994/10/19 11:25:21 john - * Looking good. - * - * Revision 1.68 1994/10/19 10:54:12 john - * Test version. - * - * Revision 1.67 1994/10/19 10:00:27 john - * *** empty log message *** - * - * Revision 1.66 1994/10/19 09:59:03 john - * Made cool saying have the potential to be up to 50 chars - * - * Revision 1.65 1994/10/19 09:53:30 john - * Working version of scores. - * - * Revision 1.64 1994/10/18 21:07:46 john - * Fixed bug that didn't print name correctly. - * - * Revision 1.63 1994/10/18 18:21:46 john - * NEw score system. - * - * Revision 1.62 1994/10/17 20:31:42 john - * Made the text for the difficulty labels global so that - * the high score screen can print "rookie" or whatever. - * - * Revision 1.61 1994/10/17 17:27:44 john - * Added starting_level to high score system. - * - * Revision 1.60 1994/10/17 16:56:35 john - * Added starting level to stats menu. - * - * Revision 1.59 1994/10/17 16:55:25 john - * Added starting level, but didn't hook it to anything. - * - * Revision 1.58 1994/10/17 16:47:17 john - * Added diff. level. - * - * Revision 1.57 1994/10/17 15:49:53 john - * Added stats screen. - * - * Revision 1.56 1994/10/03 23:02:29 matt - * After player added or not to scores, scores are now displayed - * - * Revision 1.55 1994/09/01 18:09:38 john - * Made commas in scores work correctly . - * - * - * Revision 1.54 1994/09/01 18:03:57 john - * Neatened up scores a bit. - * - * Revision 1.53 1994/08/26 14:27:37 john - * Made it prompt for name - * - * Revision 1.52 1994/08/26 13:03:17 john - * *** empty log message *** - * - * Revision 1.51 1994/08/26 13:01:52 john - * Put high score system in. - * - * Revision 1.50 1994/08/10 19:57:01 john - * Changed font stuff; Took out old menu; messed up lots of - * other stuff like game sequencing messages, etc. - * - * Revision 1.49 1994/07/25 15:40:27 matt - * Took out debugging code accidentally left in. - * - * - */ - -#ifdef HAVE_CONFIG_H #include -#endif #include #include #include #include -#include "scores.h" #include "error.h" #include "pstypes.h" #include "gr.h" @@ -281,19 +46,19 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define MAX_HIGH_SCORES 10 typedef struct stats_info { - char name[CALLSIGN_LEN+1]; + char name[CALLSIGN_LEN+1]; int score; - byte starting_level; - byte ending_level; + byte starting_level; + byte ending_level; byte diff_level; - short kill_ratio; // 0-100 - short hostage_ratio; // - int seconds; // How long it took in seconds... + short kill_ratio; // 0-100 + short hostage_ratio; // + int seconds; // How long it took in seconds... } stats_info; typedef struct all_scores { char signature[3]; // DHS - byte version; // version + byte version; // version char cool_saying[COOL_MESSAGE_LEN]; stats_info stats[MAX_HIGH_SCORES]; } all_scores; @@ -310,6 +75,8 @@ char scores_filename[128]; #define LHX(x) ((x)*(MenuHires?2:1)) #define LHY(y) ((y)*(MenuHires?2.4:1)) +void scores_view(int citem); + char * get_scores_filename() { @@ -635,10 +402,6 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); gr_palette_fade_in( gr_palette,32, 0); -#ifdef OGL - gr_update(); -#endif - game_flush_inputs(); done = 0; @@ -658,7 +421,6 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); scores_draw_item( MAX_HIGH_SCORES, &Last_game ); else scores_draw_item( citem, &Scores.stats[citem] ); - gr_update(); } for (i=0; i<4; i++ ) diff --git a/main/scores.h b/main/scores.h index aaf20533..1c19bd6e 100644 --- a/main/scores.h +++ b/main/scores.h @@ -1,4 +1,3 @@ -/* $Id: scores.h,v 1.2 2002-08-02 10:57:12 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -23,23 +22,23 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define ENERGY_SCORE 0 #define SHIELD_SCORE 0 #define LASER_SCORE 0 -#define DEBRIS_SCORE 0 -#define CLUTTER_SCORE 0 -#define MISSILE1_SCORE 0 -#define MISSILE4_SCORE 0 -#define KEY_SCORE 0 -#define QUAD_FIRE_SCORE 0 - -#define VULCAN_AMMO_SCORE 0 -#define CLOAK_SCORE 0 -#define TURBO_SCORE 0 -#define INVULNERABILITY_SCORE 0 -#define HEADLIGHT_SCORE 0 +#define DEBRIS_SCORE 0 +#define CLUTTER_SCORE 0 +#define MISSILE1_SCORE 0 +#define MISSILE4_SCORE 0 +#define KEY_SCORE 0 +#define QUAD_FIRE_SCORE 0 + +#define VULCAN_AMMO_SCORE 0 +#define CLOAK_SCORE 0 +#define TURBO_SCORE 0 +#define INVULNERABILITY_SCORE 0 +#define HEADLIGHT_SCORE 0 extern void scores_view(int citem); // If player has a high score, adds you to file and returns. -// If abort_flag set, only show if player has gotten a high score. +// If abort_flag set, only show if player has gotten a high score. extern void scores_maybe_add_player(int abort_flag); #endif diff --git a/main/segment.c b/main/segment.c deleted file mode 100644 index 89769813..00000000 --- a/main/segment.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $Id: segment.c,v 1.2 2002-08-06 01:31:07 btb Exp $ */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "segment.h" -#include "cfile.h" - -#ifdef RCS -static char rcsid[] = "$Id: segment.c,v 1.2 2002-08-06 01:31:07 btb Exp $"; -#endif - -#ifndef FAST_FILE_IO -/* - * reads a segment2 structure from a CFILE - */ -void segment2_read(segment2 *s2, CFILE *fp) -{ - s2->special = cfile_read_byte(fp); - s2->matcen_num = cfile_read_byte(fp); - s2->value = cfile_read_byte(fp); - s2->s2_flags = cfile_read_byte(fp); - s2->static_light = cfile_read_fix(fp); -} - -/* - * reads a delta_light structure from a CFILE - */ -void delta_light_read(delta_light *dl, CFILE *fp) -{ - dl->segnum = cfile_read_short(fp); - dl->sidenum = cfile_read_byte(fp); - dl->dummy = cfile_read_byte(fp); - dl->vert_light[0] = cfile_read_byte(fp); - dl->vert_light[1] = cfile_read_byte(fp); - dl->vert_light[2] = cfile_read_byte(fp); - dl->vert_light[3] = cfile_read_byte(fp); -} - - -/* - * reads a dl_index structure from a CFILE - */ -void dl_index_read(dl_index *di, CFILE *fp) -{ - di->segnum = cfile_read_short(fp); - di->sidenum = cfile_read_byte(fp); - di->count = cfile_read_byte(fp); - di->index = cfile_read_short(fp); -} -#endif diff --git a/main/segment.h b/main/segment.h index ed60cbd6..ca400f94 100644 --- a/main/segment.h +++ b/main/segment.h @@ -19,7 +19,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "vecmat.h" //#include "3d.h" //#include "inferno.h" -#include "cfile.h" // Version 1 - Initial version // Version 2 - Mike changed some shorts to bytes in segments, so incompatible! @@ -235,25 +234,5 @@ extern void add_segment_to_group(int segment_num, int group_num); // Verify that all vertices are legal. extern void med_check_all_vertices(); -#ifdef FAST_FILE_IO -#define segment2_read(s2, fp) cfread(s2, sizeof(segment2), 1, fp) -#define delta_light_read(dl, fp) cfread(dl, sizeof(delta_light), 1, fp) -#define dl_index_read(di, fp) cfread(di, sizeof(dl_index), 1, fp) -#else -/* - * reads a segment2 structure from a CFILE - */ -void segment2_read(segment2 *s2, CFILE *fp); - -/* - * reads a delta_light structure from a CFILE - */ -void delta_light_read(delta_light *dl, CFILE *fp); - -/* - * reads a dl_index structure from a CFILE - */ -void dl_index_read(dl_index *di, CFILE *fp); #endif -#endif diff --git a/main/songs.c b/main/songs.c index 6f09b9ad..0e700acf 100644 --- a/main/songs.c +++ b/main/songs.c @@ -7,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -29,9 +29,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "mono.h" #include "cfile.h" #include "digi.h" -#include "rbaudio.h" #include "kconfig.h" #include "timer.h" +#include "cdrom.h" song_info Songs[MAX_NUM_SONGS]; int Songs_initialized = 0; @@ -83,7 +83,7 @@ void songs_init() #endif - if (cfexist("descent.sng")) { // mac (demo?) datafiles don't have the .sng file + #ifndef MACINTOSH // macs don't use the .sng file fp = cfopen( "descent.sng", "rb" ); if ( fp == NULL ) { @@ -109,7 +109,7 @@ void songs_init() if (Num_songs <= SONG_FIRST_LEVEL_SONG) Error("Must have at least %d songs",SONG_FIRST_LEVEL_SONG+1); cfclose(fp); - } + #endif // endof ifdef macintosh for dealing with the .sng file Songs_initialized = 1; @@ -121,7 +121,7 @@ void songs_init() } else // use redbook { - #ifndef __MSDOS__ // defined(WINDOWS) || defined(MACINTOSH) + #if defined(WINDOWS) || defined(MACINTOSH) RBAInit(); #else RBAInit(toupper(CDROM_dir[0]) - 'A'); @@ -180,7 +180,7 @@ int force_rb_register=0; void reinit_redbook() { - #ifndef __MSDOS__ // defined(WINDOWS) || defined(MACINTOSH) + #if defined(WINDOWS) || defined(MACINTOSH) RBAInit(); #else RBAInit(toupper(CDROM_dir[0]) - 'A'); @@ -221,59 +221,13 @@ int play_redbook_track(int tracknum,int keep_playing) return (Redbook_playing != 0); } -/* - * Some of these have different Track listings! - * Which one is the "correct" order? - */ -#define D2_1_DISCID 0x7d0ff809 // Descent II -#define D2_2_DISCID 0xe010a30e // Descent II -#define D2_3_DISCID 0xd410070d // Descent II -#define D2_4_DISCID 0xc610080d // Descent II -#define D2_DEF_DISCID 0x87102209 // Definitive collection Disc 2 -#define D2_OEM_DISCID 0xac0bc30d // Destination: Quartzon -#define D2_OEM2_DISCID 0xc40c0a0d // Destination: Quartzon -#define D2_VERTIGO_DISCID 0x53078208 // Vertigo -#define D2_VERTIGO2_DISCID 0x64071408 // Vertigo + DMB -#define D2_MAC_DISCID 0xb70ee40e // Macintosh -#define D2_IPLAY_DISCID 0x22115710 // iPlay for Macintosh - -#define REDBOOK_TITLE_TRACK 2 -#define REDBOOK_CREDITS_TRACK 3 -#define REDBOOK_FIRST_LEVEL_TRACK (songs_haved2_cd()?4:1) +#define REDBOOK_TITLE_TRACK 2 +#define REDBOOK_CREDITS_TRACK 3 +#define REDBOOK_FIRST_LEVEL_TRACK (songs_haved2_cd()?4:1) // songs_haved2_cd returns 1 if the descent 2 CD is in the drive and // 0 otherwise -#if 1 -int songs_haved2_cd() -{ - int discid; - - if (!Redbook_enabled) - return 0; - - discid = RBAGetDiscID(); - - switch (discid) { - case D2_1_DISCID: - case D2_2_DISCID: - case D2_3_DISCID: - case D2_4_DISCID: - case D2_DEF_DISCID: - case D2_OEM_DISCID: - case D2_OEM2_DISCID: - case D2_VERTIGO_DISCID: - case D2_VERTIGO2_DISCID: - case D2_MAC_DISCID: - case D2_IPLAY_DISCID: - printf("Found D2 CD! discid: %x\n", discid); - return 1; - default: - printf("Unknown CD! discid: %x\n", discid); - return 0; - } -} -#else int songs_haved2_cd() { char temp[128],cwd[128]; @@ -294,13 +248,12 @@ int songs_haved2_cd() return 0; } -#endif - + void songs_play_song( int songnum, int repeat ) { #ifndef SHAREWARE - //Assert(songnum != SONG_ENDLEVEL && songnum != SONG_ENDGAME); //not in full version + Assert(songnum != SONG_ENDLEVEL && songnum != SONG_ENDGAME); //not in full version #endif if ( !Songs_initialized ) @@ -349,7 +302,7 @@ void songs_play_level_song( int levelnum ) current_song_level = levelnum; songnum = (levelnum>0)?(levelnum-1):(-levelnum); - + if (!RBAEnabled() && Redbook_enabled && !FindArg("-noredbook")) reinit_redbook(); diff --git a/main/sounds.h b/main/sounds.h index 31df257a..f39d58fd 100644 --- a/main/sounds.h +++ b/main/sounds.h @@ -1,4 +1,3 @@ -/* $ Id: $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -20,127 +19,130 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //------------------- List of sound effects -------------------- -#define SOUND_LASER_FIRED 10 +#define SOUND_LASER_FIRED 10 -#define SOUND_WEAPON_HIT_DOOR 27 -#define SOUND_WEAPON_HIT_BLASTABLE 11 -#define SOUND_BADASS_EXPLOSION 11 // need something different for this if possible +#define SOUND_WEAPON_HIT_DOOR 27 +#define SOUND_WEAPON_HIT_BLASTABLE 11 +#define SOUND_BADASS_EXPLOSION 11 // need something different for this if possible -#define SOUND_ROBOT_HIT_PLAYER 17 -#define SOUND_ROBOT_SUCKED_PLAYER SOUND_ROBOT_HIT_PLAYER // Robot sucked energy from player. +#define SOUND_ROBOT_HIT_PLAYER 17 +#define SOUND_ROBOT_SUCKED_PLAYER SOUND_ROBOT_HIT_PLAYER // Robot sucked energy from player. -#define SOUND_ROBOT_HIT 20 -#define SOUND_ROBOT_DESTROYED 21 -#define SOUND_VOLATILE_WALL_HIT 21 -#define SOUND_LASER_HIT_WATER 232 -#define SOUND_MISSILE_HIT_WATER 233 +#define SOUND_ROBOT_HIT 20 +#define SOUND_ROBOT_DESTROYED 21 +#define SOUND_VOLATILE_WALL_HIT 21 +#define SOUND_LASER_HIT_WATER 232 +#define SOUND_MISSILE_HIT_WATER 233 -#define SOUND_LASER_HIT_CLUTTER 30 -#define SOUND_CONTROL_CENTER_HIT 30 -#define SOUND_EXPLODING_WALL 31 // one long sound -#define SOUND_CONTROL_CENTER_DESTROYED 31 +#define SOUND_LASER_HIT_CLUTTER 30 +#define SOUND_CONTROL_CENTER_HIT 30 +#define SOUND_EXPLODING_WALL 31 //one long sound +#define SOUND_CONTROL_CENTER_DESTROYED 31 -#define SOUND_CONTROL_CENTER_WARNING_SIREN 32 -#define SOUND_MINE_BLEW_UP 33 +#define SOUND_CONTROL_CENTER_WARNING_SIREN 32 +#define SOUND_MINE_BLEW_UP 33 -#define SOUND_FUSION_WARMUP 34 -#define SOUND_DROP_WEAPON 39 +#define SOUND_FUSION_WARMUP 34 +#define SOUND_DROP_WEAPON 39 -#define SOUND_FORCEFIELD_BOUNCE_PLAYER 40 -#define SOUND_FORCEFIELD_BOUNCE_WEAPON 41 -#define SOUND_FORCEFIELD_HUM 42 -#define SOUND_FORCEFIELD_OFF 43 +#define SOUND_FORCEFIELD_BOUNCE_PLAYER 40 +#define SOUND_FORCEFIELD_BOUNCE_WEAPON 41 +#define SOUND_FORCEFIELD_HUM 42 +#define SOUND_FORCEFIELD_OFF 43 -#define SOUND_MARKER_HIT 50 -#define SOUND_BUDDY_MET_GOAL 51 +#define SOUND_MARKER_HIT 50 +#define SOUND_BUDDY_MET_GOAL 51 -#define SOUND_REFUEL_STATION_GIVING_FUEL 62 +#define SOUND_REFUEL_STATION_GIVING_FUEL 62 -#define SOUND_PLAYER_HIT_WALL 70 -#define SOUND_PLAYER_GOT_HIT 71 +#define SOUND_PLAYER_HIT_WALL 70 +#define SOUND_PLAYER_GOT_HIT 71 -#define SOUND_HOSTAGE_RESCUED 91 +#define SOUND_HOSTAGE_RESCUED 91 -#define SOUND_BRIEFING_HUM 94 -#define SOUND_BRIEFING_PRINTING 95 +#define SOUND_BRIEFING_HUM 94 +#define SOUND_BRIEFING_PRINTING 95 -#define SOUND_COUNTDOWN_0_SECS 100 // countdown 100..114 -#define SOUND_COUNTDOWN_13_SECS 113 -#define SOUND_COUNTDOWN_29_SECS 114 +#define SOUND_COUNTDOWN_0_SECS 100 //countdown 100..114 +#define SOUND_COUNTDOWN_13_SECS 113 +#define SOUND_COUNTDOWN_29_SECS 114 -#define SOUND_HUD_MESSAGE 117 -#define SOUND_HUD_KILL 118 +#define SOUND_HUD_MESSAGE 117 +#define SOUND_HUD_KILL 118 -#define SOUND_HOMING_WARNING 122 // Warning beep: You are being tracked by a missile! Borrowed from old repair center sounds. +#define SOUND_HOMING_WARNING 122 // Warning beep: You are being tracked by a missile! Borrowed from old repair center sounds. -#define SOUND_HUD_JOIN_REQUEST 123 -#define SOUND_HUD_BLUE_GOT_FLAG 124 -#define SOUND_HUD_RED_GOT_FLAG 125 -#define SOUND_HUD_YOU_GOT_FLAG 126 -#define SOUND_HUD_BLUE_GOT_GOAL 127 -#define SOUND_HUD_RED_GOT_GOAL 128 -#define SOUND_HUD_YOU_GOT_GOAL 129 +#define SOUND_HUD_JOIN_REQUEST 123 +#define SOUND_HUD_BLUE_GOT_FLAG 124 +#define SOUND_HUD_RED_GOT_FLAG 125 +#define SOUND_HUD_YOU_GOT_FLAG 126 +#define SOUND_HUD_BLUE_GOT_GOAL 127 +#define SOUND_HUD_RED_GOT_GOAL 128 +#define SOUND_HUD_YOU_GOT_GOAL 129 -#define SOUND_LAVAFALL_HISS 150 // under a lavafall -#define SOUND_VOLATILE_WALL_HISS 151 // need a hiss sound here. -#define SOUND_SHIP_IN_WATER 152 // sitting (or moving though) water -#define SOUND_SHIP_IN_WATERFALL 158 // under a waterfall +#define SOUND_LAVAFALL_HISS 150 // under a lavafall +#define SOUND_VOLATILE_WALL_HISS 151 // need a hiss sound here. +#define SOUND_SHIP_IN_WATER 152 // sitting (or moving though) water +#define SOUND_SHIP_IN_WATERFALL 158 // under a waterfall -#define SOUND_GOOD_SELECTION_PRIMARY 153 -#define SOUND_BAD_SELECTION 156 +#define SOUND_GOOD_SELECTION_PRIMARY 153 +#define SOUND_BAD_SELECTION 156 -#define SOUND_GOOD_SELECTION_SECONDARY 154 // Adam: New sound number here! MK, 01/30/95 -#define SOUND_ALREADY_SELECTED 155 // Adam: New sound number here! MK, 01/30/95 +#define SOUND_GOOD_SELECTION_SECONDARY 154 // Adam: New sound number here! MK, 01/30/95 +#define SOUND_ALREADY_SELECTED 155 // Adam: New sound number here! MK, 01/30/95 -#define SOUND_CLOAK_ON 160 //USED FOR WALL CLOAK -#define SOUND_CLOAK_OFF 161 //sound when cloak goes away -#define SOUND_INVULNERABILITY_OFF 163 //sound when invulnerability goes away +#define SOUND_CLOAK_ON 160 //USED FOR WALL CLOAK +#define SOUND_CLOAK_OFF 161 //sound when cloak goes away +#define SOUND_INVULNERABILITY_OFF 163 //sound when invulnerability goes away -#define SOUND_BOSS_SHARE_SEE 183 -#define SOUND_BOSS_SHARE_DIE 185 +#define SOUND_BOSS_SHARE_SEE 183 +#define SOUND_BOSS_SHARE_DIE 185 -#define ROBOT_SEE_SOUND_DEFAULT 170 -#define ROBOT_ATTACK_SOUND_DEFAULT 171 -#define ROBOT_CLAW_SOUND_DEFAULT 190 +#define ROBOT_SEE_SOUND_DEFAULT 170 +#define ROBOT_ATTACK_SOUND_DEFAULT 171 +#define ROBOT_CLAW_SOUND_DEFAULT 190 -#define SOUND_BIG_ENDLEVEL_EXPLOSION SOUND_EXPLODING_WALL -#define SOUND_TUNNEL_EXPLOSION SOUND_EXPLODING_WALL +#if defined(SHAREWARE) || defined(NMOVIES) +#define SOUND_BIG_ENDLEVEL_EXPLOSION SOUND_EXPLODING_WALL +#define SOUND_TUNNEL_EXPLOSION SOUND_EXPLODING_WALL +#endif -#define SOUND_DROP_BOMB 26 +#define SOUND_DROP_BOMB 26 -#define SOUND_CHEATER 200 +#define SOUND_CHEATER 200 -#define SOUND_AMBIENT_LAVA 222 -#define SOUND_AMBIENT_WATER 223 +#define SOUND_AMBIENT_LAVA 222 +#define SOUND_AMBIENT_WATER 223 -#define SOUND_CONVERT_ENERGY 241 -#define SOUND_WEAPON_STOLEN 244 +#define SOUND_CONVERT_ENERGY 241 +#define SOUND_WEAPON_STOLEN 244 -#define SOUND_LIGHT_BLOWNUP 157 +#define SOUND_LIGHT_BLOWNUP 157 -#define SOUND_WALL_REMOVED 246 // Wall removed, probably due to a wall switch. -#define SOUND_AFTERBURNER_IGNITE 247 -#define SOUND_AFTERBURNER_PLAY 248 +#define SOUND_WALL_REMOVED 246 // Wall removed, probably due to a wall switch. +#define SOUND_AFTERBURNER_IGNITE 247 +#define SOUND_AFTERBURNER_PLAY 248 -#define SOUND_SECRET_EXIT 249 +#define SOUND_SECRET_EXIT 249 -#define SOUND_WALL_CLOAK_ON SOUND_CLOAK_ON -#define SOUND_WALL_CLOAK_OFF SOUND_CLOAK_OFF +#define SOUND_WALL_CLOAK_ON SOUND_CLOAK_ON +#define SOUND_WALL_CLOAK_OFF SOUND_CLOAK_OFF -#define SOUND_SEISMIC_DISTURBANCE_START 251 +#define SOUND_SEISMIC_DISTURBANCE_START 251 -#define SOUND_YOU_GOT_ORB 84 -#define SOUND_FRIEND_GOT_ORB 85 -#define SOUND_OPPONENT_GOT_ORB 86 -#define SOUND_OPPONENT_HAS_SCORED 87 +#define SOUND_YOU_GOT_ORB 84 +#define SOUND_FRIEND_GOT_ORB 85 +#define SOUND_OPPONENT_GOT_ORB 86 +#define SOUND_OPPONENT_HAS_SCORED 87 //-------------------------------------------------------------- -#define MAX_SOUNDS 254 //bad to have sound 255! +#define MAX_SOUNDS 254 //bad to have sound 255! -//I think it would be nice to have a scrape sound... -//#define SOUND_PLAYER_SCRAPE_WALL 72 +//I think it would be nice to have a scrape sound... +//#define SOUND_PLAYER_SCRAPE_WALL 72 extern ubyte Sounds[MAX_SOUNDS]; extern ubyte AltSounds[MAX_SOUNDS]; #endif + diff --git a/main/state.c b/main/state.c index c084a8dc..b4c70e0b 100644 --- a/main/state.c +++ b/main/state.c @@ -1,4 +1,3 @@ -/* $Id: state.c,v 1.8 2003-04-11 23:51:48 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,14 +7,20 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/state.c,v $ + * $Revision: 1.5 $ + * $Author: bradleyb $ + * $Date: 2001-11-09 11:40:25 $ * * Game save/restore functions * + * $Log: not supported by cvs2svn $ + * */ #ifdef HAVE_CONFIG_H @@ -26,6 +31,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "desw.h" #endif + #include #include #include @@ -37,12 +43,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef OGL -#if defined(__APPLE__) && defined(__MACH__) -#include -#else #include #endif -#endif #include "pstypes.h" #include "pa_enabl.h" //$$POLY_ACC @@ -61,7 +63,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "game.h" #include "screens.h" #include "newmenu.h" -#include "cfile.h" +#include "cfile.h" #include "fuelcen.h" #include "hash.h" #include "key.h" @@ -138,7 +140,7 @@ extern fix Fusion_next_sound_time; extern int Laser_rapid_fire; extern int Physics_cheat_flag; -extern int Lunacy; +extern int Lunacy; extern void do_lunacy_on(void); extern void do_lunacy_off(void); extern int First_secret_visit; @@ -1066,7 +1068,7 @@ int state_restore_all_sub(char *filename, int multi, int secret_restore) player restore_players[MAX_PLAYERS]; #endif fix old_gametime = GameTime; - + #if defined(MACINTOSH) && !defined(NDEBUG) if ( strncmp(filename, ":Players:", 9) ) Int3(); @@ -1099,7 +1101,7 @@ int state_restore_all_sub(char *filename, int multi, int secret_restore) fseek( fp, 768, SEEK_CUR ); // Read the Between levels flag... - fread( &between_levels, sizeof(int), 1, fp ); + fread( &between_levels, sizeof(int), 1, fp ); Assert(between_levels == 0); //between levels save ripped out diff --git a/main/switch.c b/main/switch.c index 38ec07ab..bfd9e88e 100644 --- a/main/switch.c +++ b/main/switch.c @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: switch.c,v 1.8 2002-10-03 03:46:35 btb Exp $"; +static char rcsid[] = "$Id: switch.c,v 1.5 2001-11-08 10:30:28 bradleyb Exp $"; #endif #include @@ -471,7 +471,7 @@ int check_trigger_sub(int trigger_num, int pnum,int shot) digi_play_sample( SOUND_BAD_SELECTION, F1_0 ); break; #endif - + if (Newdemo_state == ND_STATE_RECORDING) // stop demo recording Newdemo_state = ND_STATE_PAUSED; @@ -635,7 +635,7 @@ void check_trigger(segment *seg, short side, short objnum,int shot) #endif } } - + void triggers_frame_process() { int i; @@ -645,60 +645,3 @@ void triggers_frame_process() Triggers[i].time -= FrameTime; } -#ifndef FAST_FILE_IO -/* - * reads a v29_trigger structure from a CFILE - */ -extern void v29_trigger_read(v29_trigger *t, CFILE *fp) -{ - int i; - - t->type = cfile_read_byte(fp); - t->flags = cfile_read_short(fp); - t->value = cfile_read_fix(fp); - t->time = cfile_read_fix(fp); - t->link_num = cfile_read_byte(fp); - t->num_links = cfile_read_short(fp); - for (i=0; iseg[i] = cfile_read_short(fp); - for (i=0; iside[i] = cfile_read_short(fp); -} - -/* - * reads a v30_trigger structure from a CFILE - */ -extern void v30_trigger_read(v30_trigger *t, CFILE *fp) -{ - int i; - - t->flags = cfile_read_short(fp); - t->num_links = cfile_read_byte(fp); - t->pad = cfile_read_byte(fp); - t->value = cfile_read_fix(fp); - t->time = cfile_read_fix(fp); - for (i=0; iseg[i] = cfile_read_short(fp); - for (i=0; iside[i] = cfile_read_short(fp); -} - -/* - * reads a trigger structure from a CFILE - */ -extern void trigger_read(trigger *t, CFILE *fp) -{ - int i; - - t->type = cfile_read_byte(fp); - t->flags = cfile_read_byte(fp); - t->num_links = cfile_read_byte(fp); - t->pad = cfile_read_byte(fp); - t->value = cfile_read_fix(fp); - t->time = cfile_read_fix(fp); - for (i=0; iseg[i] = cfile_read_short(fp); - for (i=0; iside[i] = cfile_read_short(fp); -} -#endif diff --git a/main/switch.h b/main/switch.h index 7aebc5c6..97d30880 100644 --- a/main/switch.h +++ b/main/switch.h @@ -46,44 +46,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define TF_ONE_SHOT 2 // Only trigger once #define TF_DISABLED 4 // Set after one-shot fires -//old trigger structs - -typedef struct v29_trigger { - byte type; - short flags; - fix value; - fix time; - byte link_num; - short num_links; - short seg[MAX_WALLS_PER_LINK]; - short side[MAX_WALLS_PER_LINK]; -} __pack__ v29_trigger; - -typedef struct v30_trigger { - short flags; - byte num_links; - byte pad; //keep alignment - fix value; - fix time; - short seg[MAX_WALLS_PER_LINK]; - short side[MAX_WALLS_PER_LINK]; -} __pack__ v30_trigger; - -//flags for V30 & below triggers -#define TRIGGER_CONTROL_DOORS 1 // Control Trigger -#define TRIGGER_SHIELD_DAMAGE 2 // Shield Damage Trigger -#define TRIGGER_ENERGY_DRAIN 4 // Energy Drain Trigger -#define TRIGGER_EXIT 8 // End of level Trigger -#define TRIGGER_ON 16 // Whether Trigger is active -#define TRIGGER_ONE_SHOT 32 // If Trigger can only be triggered once -#define TRIGGER_MATCEN 64 // Trigger for materialization centers -#define TRIGGER_ILLUSION_OFF 128 // Switch Illusion OFF trigger -#define TRIGGER_SECRET_EXIT 256 // Exit to secret level -#define TRIGGER_ILLUSION_ON 512 // Switch Illusion ON trigger -#define TRIGGER_UNLOCK_DOORS 1024 // Unlocks a door -#define TRIGGER_OPEN_WALL 2048 // Makes a wall open -#define TRIGGER_CLOSE_WALL 4096 // Makes a wall closed -#define TRIGGER_ILLUSORY_WALL 8192 // Makes a wall illusory //the trigger really should have both a type & a flags, since most of the //flags bits are exclusive of the others. @@ -96,7 +58,7 @@ typedef struct trigger { fix time; short seg[MAX_WALLS_PER_LINK]; short side[MAX_WALLS_PER_LINK]; -} __pack__ trigger; + } __pack__ trigger; extern trigger Triggers[MAX_TRIGGERS]; @@ -107,25 +69,4 @@ extern void check_trigger(segment *seg, short side, short objnum,int shot); extern int check_trigger_sub(int trigger_num, int player_num,int shot); extern void triggers_frame_process(); -#ifdef FAST_FILE_IO -#define v29_trigger_read(t, fp) cfread(t, sizeof(v29_trigger), 1, fp) -#define v30_trigger_read(t, fp) cfread(t, sizeof(v30_trigger), 1, fp) -#define trigger_read(t, fp) cfread(t, sizeof(trigger), 1, fp) -#else -/* - * reads a v29_trigger structure from a CFILE - */ -extern void v29_trigger_read(v29_trigger *t, CFILE *fp); - -/* - * reads a v30_trigger structure from a CFILE - */ -extern void v30_trigger_read(v30_trigger *t, CFILE *fp); - -/* - * reads a trigger structure from a CFILE - */ -extern void trigger_read(trigger *t, CFILE *fp); -#endif - #endif diff --git a/main/terrain.c b/main/terrain.c index 52ed61ce..8903c75e 100644 --- a/main/terrain.c +++ b/main/terrain.c @@ -1,4 +1,3 @@ -/* $Id: terrain.c,v 1.3 2002-10-03 03:46:35 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -13,9 +12,14 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/main/terrain.c,v $ + * $Revision: 1.1 $ + * $Author: bradleyb $ + * $Date: 2001-11-08 10:21:36 $ * * FIXME: put description here * + * $Log: not supported by cvs2svn $ * */ @@ -40,11 +44,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "object.h" #include "endlevel.h" #include "fireball.h" -#include "render.h" -#define GRID_MAX_SIZE 64 -#define GRID_SCALE i2f(2*20) -#define HEIGHT_SCALE f1_0 +#define GRID_MAX_SIZE 64 +#define GRID_SCALE i2f(2*20) +#define HEIGHT_SCALE f1_0 int grid_w,grid_h; @@ -57,8 +60,8 @@ ubyte *light_array; #define HEIGHT(_i,_j) (height_array[(_i)*grid_w+(_j)]) #define LIGHT(_i,_j) light_array[(_i)*grid_w+(_j)] -//!!#define HEIGHT(_i,_j) height_array[(grid_h-1-j)*grid_w+(_i)] -//!!#define LIGHT(_i,_j) light_array[(grid_h-1-j)*grid_w+(_i)] +//!!#define HEIGHT(_i,_j) height_array[(grid_h-1-j)*grid_w+(_i)] +//!!#define LIGHT(_i,_j) light_array[(grid_h-1-j)*grid_w+(_i)] #define LIGHTVAL(_i,_j) (((fix) LIGHT(_i,_j))<<8) @@ -70,15 +73,18 @@ grs_bitmap *terrain_bm; int terrain_outline=0; +void render_mine(int start_seg_num,fix eye_offset); + int org_i,org_j; -int mine_tiles_drawn; //flags to tell if all 4 tiles under mine have drawn +int mine_tiles_drawn; //flags to tell if all 4 tiles under mine have drawn -// LINT: adding function prototypes +// LINT: adding function prototypes void build_light_table(void); void free_light_table(void); + // ------------------------------------------------------------------------ void draw_cell(int i,int j,g3s_point *p0,g3s_point *p1,g3s_point *p2,g3s_point *p3) { @@ -134,9 +140,9 @@ void draw_cell(int i,int j,g3s_point *p0,g3s_point *p1,g3s_point *p2,g3s_point * mine_tiles_drawn |= 4; if (i==org_i-1 && j==org_j-1) mine_tiles_drawn |= 8; - + if (mine_tiles_drawn == 0xf) { - render_mine(exit_segnum, 0, 0); + render_mine(exit_segnum,0); //draw_exit_model(); mine_tiles_drawn=-1; //if (ext_expl_playing) @@ -474,7 +480,7 @@ void build_light_table() if (min_l == max_l) { LIGHT(i,j) = l>>8; continue; - } + } l2 = fixdiv((l-min_l),(max_l-min_l)); diff --git a/main/texmerge.c b/main/texmerge.c index f99105d7..17a2be53 100644 --- a/main/texmerge.c +++ b/main/texmerge.c @@ -1,4 +1,3 @@ -/* $Id: texmerge.c,v 1.3 2002-09-04 22:47:25 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,114 +7,10 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Routines to cache merged textures. - * - * Old Log: - * Revision 1.1 1995/05/16 15:31:36 allender - * Initial revision - * - * Revision 2.0 1995/02/27 11:31:08 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.28 1995/01/14 19:16:56 john - * First version of new bitmap paging code. - * - * Revision 1.27 1994/12/14 18:21:58 yuan - * *** empty log message *** - * - * Revision 1.26 1994/12/13 09:50:08 john - * Added Asserts to stop if wall looks like door. - * - * Revision 1.25 1994/12/07 00:35:24 mike - * change how flat shading average color is computed for paste-ons. - * - * Revision 1.24 1994/11/19 15:20:29 mike - * rip out unused code and data - * - * Revision 1.23 1994/11/12 16:38:51 mike - * deal with avg_color in texture merging. - * - * Revision 1.22 1994/11/09 19:55:39 john - * Added full rle support with texture rle caching. - * - * Revision 1.21 1994/10/20 15:21:16 john - * Took out the texmerge caching. - * - * Revision 1.20 1994/10/10 19:00:57 john - * Made caching info print every 1000 frames. - * - * Revision 1.19 1994/10/10 18:41:21 john - * Printed out texture caching info. - * - * Revision 1.18 1994/08/11 18:59:02 mike - * Use new assembler version of merge functions. - * - * Revision 1.17 1994/06/09 12:13:14 john - * Changed selectors so that all bitmaps have a selector of - * 0, but inside the texture mapper they get a selector set. - * - * Revision 1.16 1994/05/14 17:15:15 matt - * Got rid of externs in source (non-header) files - * - * Revision 1.15 1994/05/09 17:21:09 john - * Took out mprintf with cache hits/misses. - * - * Revision 1.14 1994/05/05 12:55:07 john - * Made SuperTransparency work. - * - * Revision 1.13 1994/05/04 11:15:37 john - * Added Super Transparency - * - * Revision 1.12 1994/04/28 23:36:04 john - * Took out a debugging mprintf. - * - * Revision 1.11 1994/04/22 17:44:48 john - * Made top 2 bits of paste-ons pick the - * orientation of the bitmap. - * - * Revision 1.10 1994/03/31 12:05:51 matt - * Cleaned up includes - * - * Revision 1.9 1994/03/15 16:31:52 yuan - * Cleaned up bm-loading code. - * (And structures) - * - * Revision 1.8 1994/01/24 13:15:19 john - * Made caching work with pointers, not texture numbers, - * that way, the animated textures cache. - * - * Revision 1.7 1994/01/21 16:38:10 john - * Took out debug info. - * - * Revision 1.6 1994/01/21 16:28:43 john - * added warning to print cache hit/miss. - * - * Revision 1.5 1994/01/21 16:22:30 john - * Put in caching/ - * - * Revision 1.4 1994/01/21 15:34:49 john - * *** empty log message *** - * - * Revision 1.3 1994/01/21 15:33:08 john - * *** empty log message *** - * - * Revision 1.2 1994/01/21 15:15:35 john - * Created new module texmerge, that merges textures together and - * caches the results. - * - * Revision 1.1 1994/01/21 14:55:29 john - * Initial revision - * - * - */ - #ifdef HAVE_CONFIG_H #include #endif @@ -315,7 +210,7 @@ grs_bitmap * texmerge_get_cached_bitmap( int tmap_bottom, int tmap_top ) Cache[least_recently_used].bitmap->bm_flags = bitmap_bottom->bm_flags & (~BM_FLAG_RLE); Cache[least_recently_used].bitmap->avg_color = bitmap_bottom->avg_color; } - + Cache[least_recently_used].top_bmp = bitmap_top; Cache[least_recently_used].bottom_bmp = bitmap_bottom; Cache[least_recently_used].last_frame_used = FrameCount; @@ -326,6 +221,10 @@ grs_bitmap * texmerge_get_cached_bitmap( int tmap_bottom, int tmap_top ) void merge_textures_new( int type, grs_bitmap * bottom_bmp, grs_bitmap * top_bmp, ubyte * dest_data ) { +#ifdef MACINTOSH + ubyte c; + int x,y; +#endif ubyte * top_data, *bottom_data; if ( top_bmp->bm_flags & BM_FLAG_RLE ) @@ -344,20 +243,60 @@ void merge_textures_new( int type, grs_bitmap * bottom_bmp, grs_bitmap * top_bmp // mprintf( 0, "Type=%d\n", type ); switch( type ) { - case 0: - // Normal - - gr_merge_textures( bottom_data, top_data, dest_data ); - break; - case 1: - gr_merge_textures_1( bottom_data, top_data, dest_data ); - break; - case 2: - gr_merge_textures_2( bottom_data, top_data, dest_data ); - break; - case 3: - gr_merge_textures_3( bottom_data, top_data, dest_data ); - break; + case 0: + // Normal + +#ifndef MACINTOSH + gr_merge_textures( bottom_data, top_data, dest_data ); +#else + for (y=0; y<64; y++ ) + for (x=0; x<64; x++ ) { + c = top_data[ 64*y+x ]; + if (c==TRANSPARENCY_COLOR) + c = bottom_data[ 64*y+x ]; + *dest_data++ = c; + } +#endif + break; + case 1: +#ifndef MACINTOSH + gr_merge_textures_1( bottom_data, top_data, dest_data ); +#else + for (y=0; y<64; y++ ) + for (x=0; x<64; x++ ) { + c = top_data[ 64*x+(63-y) ]; + if (c==TRANSPARENCY_COLOR) + c = bottom_data[ 64*y+x ]; + *dest_data++ = c; + } +#endif + break; + case 2: +#ifndef MACINTOSH + gr_merge_textures_2( bottom_data, top_data, dest_data ); +#else + for (y=0; y<64; y++ ) + for (x=0; x<64; x++ ) { + c = top_data[ 64*(63-y)+(63-x) ]; + if (c==TRANSPARENCY_COLOR) + c = bottom_data[ 64*y+x ]; + *dest_data++ = c; + } +#endif + break; + case 3: +#ifndef MACINTOSH + gr_merge_textures_3( bottom_data, top_data, dest_data ); +#else + for (y=0; y<64; y++ ) + for (x=0; x<64; x++ ) { + c = top_data[ 64*(63-x)+y ]; + if (c==TRANSPARENCY_COLOR) + c = bottom_data[ 64*y+x ]; + *dest_data++ = c; + } +#endif + break; } } diff --git a/main/text.c b/main/text.c index ac632150..aac91b5f 100644 --- a/main/text.c +++ b/main/text.c @@ -1,4 +1,3 @@ -/* $Id: text.c,v 1.8 2003-04-07 23:36:34 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,64 +7,16 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * Code for localizable text - * - * Old Log: - * Revision 1.1 1995/05/16 15:31:44 allender - * Initial revision - * - * Revision 2.0 1995/02/27 11:33:09 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.11 1994/12/14 12:53:23 matt - * Improved error handling - * - * Revision 1.10 1994/12/09 18:36:44 john - * Added code to make text read from hogfile. - * - * Revision 1.9 1994/12/08 20:56:34 john - * More cfile stuff. - * - * Revision 1.8 1994/12/08 17:20:06 yuan - * Cfiling stuff. - * - * Revision 1.7 1994/12/05 15:10:36 allender - * support encoded descent.tex file (descent.txb) - * - * Revision 1.6 1994/12/01 14:18:34 matt - * Now support backslash chars in descent.tex file - * - * Revision 1.5 1994/10/27 00:13:10 john - * Took out cfile. - * - * Revision 1.4 1994/07/11 15:33:49 matt - * Put in command-line switch to load different text files - * - * Revision 1.3 1994/07/10 09:56:25 yuan - * #include added for FILE type. - * - * Revision 1.2 1994/07/09 22:48:14 matt - * Added localizable text - * - * Revision 1.1 1994/07/09 21:30:46 matt - * Initial revision - * - * - */ - #ifdef HAVE_CONFIG_H #include #endif #ifdef RCS -static char rcsid[] = "$Id: text.c,v 1.8 2003-04-07 23:36:34 btb Exp $"; +static char rcsid[] = "$Id: text.c,v 1.3 2001-01-31 15:17:59 bradleyb Exp $"; #endif #include @@ -115,7 +66,6 @@ void decode_text_line(char *p) } } -#include //load all the text strings for Descent void load_text() { @@ -130,10 +80,8 @@ void load_text() if ((tfile = cfopen(filename,"rb")) == NULL) { filename="descent.txb"; - if ((ifile = cfopen(filename, "rb")) == NULL) { - Warning("Cannot open file DESCENT.TEX or DESCENT.TXB"); - return; - } + if ((ifile = cfopen(filename, "rb")) == NULL) + Error("Cannot open file DESCENT.TEX or DESCENT.TXB\nIs descent2.hog in your current directory?"); have_binary = 1; len = cfilelength(ifile); @@ -174,16 +122,16 @@ void load_text() tptr = strchr(tptr,'\n'); -#ifdef MACINTOSH // total hack for mac patch since they don't want to patch data. + #ifdef MACINTOSH // total hack for mac patch since they don't want to patch data. if (!tptr && (i == 644) ) break; -#else + #else if (!tptr) { Warning("Not enough strings in text file - expecting %d, found %d\nThis probably means you have the wrong version of the descent 2 datafiles. You need version 1.2\n",N_TEXT_STRINGS,i); if (i == 644) break; } -#endif + #endif if ( tptr ) *tptr++ = 0; @@ -198,17 +146,17 @@ void load_text() else if (p[1] == 't') newchar = '\t'; else if (p[1] == '\\') newchar = '\\'; else - Error("Unsupported key sequence <\\%c> on line %d of file <%s>",p[1],i+1,filename); + Error("Unsupported key sequence <\\%c> on line %d of file <%s>",p[1],i+1,filename); p[0] = newchar; strcpy(p+1,p+2); p++; } - + } - //Assert(tptr==text+len || tptr==text+len-2); - +// Assert(tptr==text+len || tptr==text+len-2); + } diff --git a/main/text.h b/main/text.h index 8284572c..f2e39c16 100644 --- a/main/text.h +++ b/main/text.h @@ -1,4 +1,3 @@ -/* $Id: text.h,v 1.3 2003-03-28 07:54:44 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -22,704 +21,706 @@ extern char *Text_string[]; //Symbolic constants for all the strings -#define TXT_NEW_GAME Text_string[ 0] -#define TXT_VIEW_SCORES Text_string[ 1] -#define TXT_QUIT Text_string[ 2] -#define TXT_CANNOT_SET_SCREEN Text_string[ 3] -#define TXT_NO_JOYSTICK Text_string[ 4] -#define TXT_REQUIRES_VGA Text_string[ 5] -#define TXT_HELP Text_string[ 6] -#define TXT_THANKS Text_string[ 7] -#define TXT_SOUND_DISABLED Text_string[ 8] -#define TXT_CANT_INIT_GFX Text_string[ 9] -#define TXT_EXTRA_LIFE Text_string[10] -#define TXT_COPYRIGHT Text_string[11] -#define TXT_BLUE Text_string[12] -#define TXT_RED Text_string[13] -#define TXT_YELLOW Text_string[14] -#define TXT_ACCESS_DENIED Text_string[15] -#define TXT_ACCESS_GRANTED Text_string[16] -#define TXT_BOOSTED_TO Text_string[17] -#define TXT_ENERGY Text_string[18] -#define TXT_SHIELD Text_string[19] -#define TXT_LASER Text_string[20] -#define TXT_MAXED_OUT Text_string[21] -#define TXT_QUAD_LASERS Text_string[22] -#define TXT_ALREADY_HAVE Text_string[23] -#define TXT_VULCAN_AMMO Text_string[24] -#define TXT_VULCAN_ROUNDS Text_string[25] -#define TXT_ALREADY_ARE Text_string[26] -#define TXT_CLOAKED Text_string[27] -#define TXT_CLOAKING_DEVICE Text_string[28] -#define TXT_INVULNERABLE Text_string[29] -#define TXT_INVULNERABILITY Text_string[30] -#define TXT_CREATE_NEW Text_string[31] -#define TXT_YES Text_string[32] -#define TXT_NO Text_string[33] -#define TXT_OK Text_string[34] -#define TXT_NO_DEMO_FILES Text_string[35] -#define TXT_USE_F5 Text_string[36] -#define TXT_TO_CREATE_ONE Text_string[37] -#define TXT_NO_FILES_MATCHING Text_string[38] -#define TXT_WERE_FOUND Text_string[39] -#define TXT_DELETE_PILOT Text_string[40] -#define TXT_DELETE_DEMO Text_string[41] -#define TXT_COULDNT Text_string[42] -#define TXT_EXIT_SEQUENCE Text_string[43] -#define TXT_WARNING Text_string[44] -#define TXT_UNABLE_TO_OPEN Text_string[45] -#define TXT_COOL_SAYING Text_string[46] -#define TXT_HIGH_SCORE Text_string[47] -#define TXT_YOU_PLACED Text_string[48] -#define TXT_YOU_PLACED_1ST Text_string[49] -#define TXT_HIGH_SCORES Text_string[50] -#define TXT_NAME Text_string[51] -#define TXT_SCORE Text_string[52] -#define TXT_SKILL Text_string[53] -#define TXT_LEVELS Text_string[54] -#define TXT_TIME Text_string[55] -#define TXT_REGISTER_DESCENT Text_string[56] -#define TXT_1ST Text_string[57] -#define TXT_2ND Text_string[58] -#define TXT_3RD Text_string[59] -#define TXT_4TH Text_string[60] -#define TXT_5TH Text_string[61] -#define TXT_6TH Text_string[62] -#define TXT_7TH Text_string[63] -#define TXT_8TH Text_string[64] -#define TXT_9TH Text_string[65] -#define TXT_10TH Text_string[66] -#define TXT_EMPTY Text_string[67] -#define TXT_KILLED Text_string[68] -#define TXT_SUICIDE Text_string[69] -#define TXT_YOU Text_string[70] -#define TXT_YOURSELF Text_string[71] -#define TXT_NO_MACRO Text_string[72] -#define TXT_SENDING Text_string[73] -#define TXT_SEND_MESSAGE Text_string[74] -#define TXT_SAYS Text_string[75] -#define TXT_TELLS_YOU Text_string[76] -#define TXT_HAS_DEST_CONTROL Text_string[77] -#define TXT_CONTROL_DESTROYED Text_string[78] -#define TXT_HAS_ESCAPED Text_string[79] -#define TXT_HAS_FOUND_SECRET Text_string[80] -#define TXT_HAS_LEFT_THE_GAME Text_string[81] -#define TXT_YOU_ARE_ONLY Text_string[82] -#define TXT_OPPONENT_LEFT Text_string[83] -#define TXT_YOU_DEST_CONTROL Text_string[84] -#define TXT_DEFINE_MACRO Text_string[85] -#define TXT_MESSAGE_SENT_TO Text_string[86] -#define TXT_NOBODY Text_string[87] -#define TXT_PAUSE Text_string[88] -#define TXT_CANT_PAUSE Text_string[89] -#define TXT_HELP_ESC Text_string[90] -#define TXT_HELP_F2 Text_string[91] -#define TXT_HELP_F3 Text_string[92] -#define TXT_HELP_F4 Text_string[93] -#define TXT_HELP_F5 Text_string[94] -#define TXT_HELP_PAUSE Text_string[95] -#define TXT_HELP_MINUSPLUS Text_string[96] -#define TXT_HELP_PRTSCN Text_string[97] -#define TXT_HELP_1TO5 Text_string[98] -#define TXT_HELP_6TO10 Text_string[99] -#define TXT_HELP_TO_VIEW Text_string[100] -#define TXT_KEYS Text_string[101] -#define TXT_ABORT_AUTODEMO Text_string[102] -#define TXT_ABORT_GAME Text_string[103] -#define TXT_W_LASER Text_string[104] -#define TXT_W_VULCAN Text_string[105] -#define TXT_W_SPREADFIRE Text_string[106] -#define TXT_W_PLASMA Text_string[107] -#define TXT_W_FUSION Text_string[108] -#define TXT_W_SLASER Text_string[109] -#define TXT_W_SVULCAN Text_string[110] -#define TXT_W_SSPREADFIRE Text_string[111] -#define TXT_W_SPLASMA Text_string[112] -#define TXT_W_SFUSION Text_string[113] -#define TXT_W_C_MISSILE Text_string[114] -#define TXT_W_H_MISSILE Text_string[115] -#define TXT_W_P_BOMB Text_string[116] -#define TXT_W_S_MISSILE Text_string[117] -#define TXT_W_M_MISSILE Text_string[118] -#define TXT_W_SMISSILE1 Text_string[119] -#define TXT_W_SMISSILE2 Text_string[120] -#define TXT_W_SMISSILE3 Text_string[121] -#define TXT_W_SMISSILE4 Text_string[122] -#define TXT_W_SMISSILE5 Text_string[123] -#define TXT_W_LASER_S Text_string[124] -#define TXT_W_VULCAN_S Text_string[125] -#define TXT_W_SPREADFIRE_S Text_string[126] -#define TXT_W_PLASMA_S Text_string[127] -#define TXT_W_FUSION_S Text_string[128] -#define TXT_W_SLASER_S Text_string[129] -#define TXT_W_SVULCAN_S Text_string[130] -#define TXT_W_SSPREADFIRE_S Text_string[131] -#define TXT_W_SPLASMA_S Text_string[132] -#define TXT_W_SFUSION_S Text_string[133] -#define TXT_W_C_MISSILE_S Text_string[134] -#define TXT_W_H_MISSILE_S Text_string[135] -#define TXT_W_P_BOMB_S Text_string[136] -#define TXT_W_S_MISSILE_S Text_string[137] -#define TXT_W_M_MISSILE_S Text_string[138] -#define TXT_W_SMISSILE1_S Text_string[139] -#define TXT_W_SMISSILE2_S Text_string[140] -#define TXT_W_SMISSILE3_S Text_string[141] -#define TXT_W_SMISSILE4_S Text_string[142] -#define TXT_W_SMISSILE5_S Text_string[143] -#define TXT_SELECTED Text_string[144] -#define TXT_DONT_HAVE Text_string[145] -#define TXT_DONT_HAVE_AMMO Text_string[146] -#define TXT_HAVE_NO Text_string[147] -#define TXT_S Text_string[148] -#define TXT_SX Text_string[149] -#define TXT_NO_PRIMARY Text_string[150] -#define TXT_ALREADY_HAVE_THE Text_string[151] -#define TXT_CANT_OPEN_DOOR Text_string[152] -#define TXT_MOVE_JOYSTICK Text_string[153] -#define TXT_TO_UL Text_string[154] -#define TXT_ANY_BUTTON Text_string[155] -#define TXT_JOYSTICK Text_string[156] -#define TXT_UPPER_LEFT Text_string[157] -#define TXT_TO_LR Text_string[158] -#define TXT_LOWER_RIGHT Text_string[159] -#define TXT_TO_C Text_string[160] -#define TXT_CENTER Text_string[161] -#define TXT_CONTROL_KEYBOARD Text_string[162] -#define TXT_CONTROL_JOYSTICK Text_string[163] -#define TXT_CONTROL_FSTICKPRO Text_string[164] -#define TXT_CONTROL_THRUSTFCS Text_string[165] -#define TXT_CONTROL_GGAMEPAD Text_string[166] -#define TXT_CONTROL_MOUSE Text_string[167] -#define TXT_CONTROL_CYBERMAN Text_string[168] -#define TXT_CONTROL_WINJOY Text_string[169] -#define TXT_CUST_ABOVE Text_string[170] -#define TXT_CUST_KEYBOARD Text_string[171] -#define TXT_CONTROLS Text_string[172] -#define TXT_KEYBOARD Text_string[173] +#define TXT_NEW_GAME Text_string[ 0] +#define TXT_VIEW_SCORES Text_string[ 1] +#define TXT_QUIT Text_string[ 2] +#define TXT_CANNOT_SET_SCREEN Text_string[ 3] +#define TXT_NO_JOYSTICK Text_string[ 4] +#define TXT_REQUIRES_VGA Text_string[ 5] +#define TXT_HELP Text_string[ 6] +#define TXT_THANKS Text_string[ 7] +#define TXT_SOUND_DISABLED Text_string[ 8] +#define TXT_CANT_INIT_GFX Text_string[ 9] +#define TXT_EXTRA_LIFE Text_string[10] +#define TXT_COPYRIGHT Text_string[11] +#define TXT_BLUE Text_string[12] +#define TXT_RED Text_string[13] +#define TXT_YELLOW Text_string[14] +#define TXT_ACCESS_DENIED Text_string[15] +#define TXT_ACCESS_GRANTED Text_string[16] +#define TXT_BOOSTED_TO Text_string[17] +#define TXT_ENERGY Text_string[18] +#define TXT_SHIELD Text_string[19] +#define TXT_LASER Text_string[20] +#define TXT_MAXED_OUT Text_string[21] +#define TXT_QUAD_LASERS Text_string[22] +#define TXT_ALREADY_HAVE Text_string[23] +#define TXT_VULCAN_AMMO Text_string[24] +#define TXT_VULCAN_ROUNDS Text_string[25] +#define TXT_ALREADY_ARE Text_string[26] +#define TXT_CLOAKED Text_string[27] +#define TXT_CLOAKING_DEVICE Text_string[28] +#define TXT_INVULNERABLE Text_string[29] +#define TXT_INVULNERABILITY Text_string[30] +#define TXT_CREATE_NEW Text_string[31] +#define TXT_YES Text_string[32] +#define TXT_NO Text_string[33] +#define TXT_OK Text_string[34] +#define TXT_NO_DEMO_FILES Text_string[35] +#define TXT_USE_F5 Text_string[36] +#define TXT_TO_CREATE_ONE Text_string[37] +#define TXT_NO_FILES_MATCHING Text_string[38] +#define TXT_WERE_FOUND Text_string[39] +#define TXT_DELETE_PILOT Text_string[40] +#define TXT_DELETE_DEMO Text_string[41] +#define TXT_COULDNT Text_string[42] +#define TXT_EXIT_SEQUENCE Text_string[43] +#define TXT_WARNING Text_string[44] +#define TXT_UNABLE_TO_OPEN Text_string[45] +#define TXT_COOL_SAYING Text_string[46] +#define TXT_HIGH_SCORE Text_string[47] +#define TXT_YOU_PLACED Text_string[48] +#define TXT_YOU_PLACED_1ST Text_string[49] +#define TXT_HIGH_SCORES Text_string[50] +#define TXT_NAME Text_string[51] +#define TXT_SCORE Text_string[52] +#define TXT_SKILL Text_string[53] +#define TXT_LEVELS Text_string[54] +#define TXT_TIME Text_string[55] +#define TXT_REGISTER_DESCENT Text_string[56] +#define TXT_1ST Text_string[57] +#define TXT_2ND Text_string[58] +#define TXT_3RD Text_string[59] +#define TXT_4TH Text_string[60] +#define TXT_5TH Text_string[61] +#define TXT_6TH Text_string[62] +#define TXT_7TH Text_string[63] +#define TXT_8TH Text_string[64] +#define TXT_9TH Text_string[65] +#define TXT_10TH Text_string[66] +#define TXT_EMPTY Text_string[67] +#define TXT_KILLED Text_string[68] +#define TXT_SUICIDE Text_string[69] +#define TXT_YOU Text_string[70] +#define TXT_YOURSELF Text_string[71] +#define TXT_NO_MACRO Text_string[72] +#define TXT_SENDING Text_string[73] +#define TXT_SEND_MESSAGE Text_string[74] +#define TXT_SAYS Text_string[75] +#define TXT_TELLS_YOU Text_string[76] +#define TXT_HAS_DEST_CONTROL Text_string[77] +#define TXT_CONTROL_DESTROYED Text_string[78] +#define TXT_HAS_ESCAPED Text_string[79] +#define TXT_HAS_FOUND_SECRET Text_string[80] +#define TXT_HAS_LEFT_THE_GAME Text_string[81] +#define TXT_YOU_ARE_ONLY Text_string[82] +#define TXT_OPPONENT_LEFT Text_string[83] +#define TXT_YOU_DEST_CONTROL Text_string[84] +#define TXT_DEFINE_MACRO Text_string[85] +#define TXT_MESSAGE_SENT_TO Text_string[86] +#define TXT_NOBODY Text_string[87] +#define TXT_PAUSE Text_string[88] +#define TXT_CANT_PAUSE Text_string[89] +#define TXT_HELP_ESC Text_string[90] +#define TXT_HELP_F2 Text_string[91] +#define TXT_HELP_F3 Text_string[92] +#define TXT_HELP_F4 Text_string[93] +#define TXT_HELP_F5 Text_string[94] +#define TXT_HELP_PAUSE Text_string[95] +#define TXT_HELP_MINUSPLUS Text_string[96] +#define TXT_HELP_PRTSCN Text_string[97] +#define TXT_HELP_1TO5 Text_string[98] +#define TXT_HELP_6TO10 Text_string[99] +#define TXT_HELP_TO_VIEW Text_string[100] +#define TXT_KEYS Text_string[101] +#define TXT_ABORT_AUTODEMO Text_string[102] +#define TXT_ABORT_GAME Text_string[103] +#define TXT_W_LASER Text_string[104] +#define TXT_W_VULCAN Text_string[105] +#define TXT_W_SPREADFIRE Text_string[106] +#define TXT_W_PLASMA Text_string[107] +#define TXT_W_FUSION Text_string[108] +#define TXT_W_SLASER Text_string[109] +#define TXT_W_SVULCAN Text_string[110] +#define TXT_W_SSPREADFIRE Text_string[111] +#define TXT_W_SPLASMA Text_string[112] +#define TXT_W_SFUSION Text_string[113] +#define TXT_W_C_MISSILE Text_string[114] +#define TXT_W_H_MISSILE Text_string[115] +#define TXT_W_P_BOMB Text_string[116] +#define TXT_W_S_MISSILE Text_string[117] +#define TXT_W_M_MISSILE Text_string[118] +#define TXT_W_SMISSILE1 Text_string[119] +#define TXT_W_SMISSILE2 Text_string[120] +#define TXT_W_SMISSILE3 Text_string[121] +#define TXT_W_SMISSILE4 Text_string[122] +#define TXT_W_SMISSILE5 Text_string[123] +#define TXT_W_LASER_S Text_string[124] +#define TXT_W_VULCAN_S Text_string[125] +#define TXT_W_SPREADFIRE_S Text_string[126] +#define TXT_W_PLASMA_S Text_string[127] +#define TXT_W_FUSION_S Text_string[128] +#define TXT_W_SLASER_S Text_string[129] +#define TXT_W_SVULCAN_S Text_string[130] +#define TXT_W_SSPREADFIRE_S Text_string[131] +#define TXT_W_SPLASMA_S Text_string[132] +#define TXT_W_SFUSION_S Text_string[133] +#define TXT_W_C_MISSILE_S Text_string[134] +#define TXT_W_H_MISSILE_S Text_string[135] +#define TXT_W_P_BOMB_S Text_string[136] +#define TXT_W_S_MISSILE_S Text_string[137] +#define TXT_W_M_MISSILE_S Text_string[138] +#define TXT_W_SMISSILE1_S Text_string[139] +#define TXT_W_SMISSILE2_S Text_string[140] +#define TXT_W_SMISSILE3_S Text_string[141] +#define TXT_W_SMISSILE4_S Text_string[142] +#define TXT_W_SMISSILE5_S Text_string[143] +#define TXT_SELECTED Text_string[144] +#define TXT_DONT_HAVE Text_string[145] +#define TXT_DONT_HAVE_AMMO Text_string[146] +#define TXT_HAVE_NO Text_string[147] +#define TXT_S Text_string[148] +#define TXT_SX Text_string[149] +#define TXT_NO_PRIMARY Text_string[150] +#define TXT_ALREADY_HAVE_THE Text_string[151] +#define TXT_CANT_OPEN_DOOR Text_string[152] +#define TXT_MOVE_JOYSTICK Text_string[153] +#define TXT_TO_UL Text_string[154] +#define TXT_ANY_BUTTON Text_string[155] +#define TXT_JOYSTICK Text_string[156] +#define TXT_UPPER_LEFT Text_string[157] +#define TXT_TO_LR Text_string[158] +#define TXT_LOWER_RIGHT Text_string[159] +#define TXT_TO_C Text_string[160] +#define TXT_CENTER Text_string[161] +#define TXT_CONTROL_KEYBOARD Text_string[162] +#define TXT_CONTROL_JOYSTICK Text_string[163] +#define TXT_CONTROL_FSTICKPRO Text_string[164] +#define TXT_CONTROL_THRUSTFCS Text_string[165] +#define TXT_CONTROL_GGAMEPAD Text_string[166] +#define TXT_CONTROL_MOUSE Text_string[167] +#define TXT_CONTROL_CYBERMAN Text_string[168] +#define TXT_CONTROL_WINJOY Text_string[169] +#define TXT_CUST_ABOVE Text_string[170] +#define TXT_CUST_KEYBOARD Text_string[171] +#define TXT_CONTROLS Text_string[172] +#define TXT_KEYBOARD Text_string[173] //This is where the command-line help text used to be -#define TXT_REGISTRATION Text_string[192] -#define TXT_ERROR_SELECTOR Text_string[193] -#define TXT_ERROR_GRAPHICS Text_string[194] -#define TXT_CALIBRATE Text_string[195] -#define TXT_SKIP Text_string[196] -#define TXT_JOYSTICK_NOT_CEN Text_string[197] -#define TXT_CHOOSE_INPUT Text_string[198] -#define TXT_ERROR Text_string[199] -#define TXT_ERROR_PLR_VERSION Text_string[200] -#define TXT_DEMO_PLAYBACK Text_string[201] -#define TXT_DEMO_RECORDING Text_string[202] -#define TXT_CRUISE Text_string[203] -#define TXT_DUMPING_SCREEN Text_string[204] -#define TXT_CHEATS_ENABLED Text_string[205] -#define TXT_NET_GAME_CLOSED Text_string[206] -#define TXT_NET_GAME_FULL Text_string[207] -#define TXT_NET_GAME_BETWEEN Text_string[208] -#define TXT_NET_GAME_NSELECT Text_string[209] -#define TXT_NET_GAME_NSTART Text_string[210] -#define TXT_NET_GAME_CONNECT Text_string[211] -#define TXT_NET_GAME_WRONGLEV Text_string[212] -#define TXT_KILLS Text_string[213] -#define TXT_WAITING Text_string[214] -#define TXT_SURE_LEAVE_GAME Text_string[215] -#define TXT_JOINING Text_string[216] -#define TXT_REJOIN Text_string[217] -#define TXT_SORRY_ONLY Text_string[218] -#define TXT_NETPLAYERS_IN Text_string[219] -#define TXT_S_GAME Text_string[220] -#define TXT_DESCRIPTION Text_string[221] -#define TXT_LEVEL_ Text_string[222] -#define TXT_MODE Text_string[223] -#define TXT_ANARCHY Text_string[224] -#define TXT_TEAM_ANARCHY Text_string[225] -#define TXT_ANARCHY_W_ROBOTS Text_string[226] -#define TXT_COOPERATIVE Text_string[227] -#define TXT_OPTIONS Text_string[228] -#define TXT_CLOSED_GAME Text_string[229] -#define TXT_NETGAME_SETUP Text_string[230] -#define TXT_LEVEL_OUT_RANGE Text_string[231] -#define TXT_SORRY Text_string[232] -#define TXT_REGISTERED_ONLY Text_string[233] -#define TXT_WAIT Text_string[234] -#define TXT_FOUND Text_string[235] -#define TXT_ACTIVE_GAMES Text_string[236] -#define TXT_STARTING_NETGAME Text_string[237] -#define TXT_NETLEVEL_NMATCH Text_string[238] -#define TXT_TEAM Text_string[239] -#define TXT_TEAM_SELECTION Text_string[240] -#define TXT_TEAM_MUST_ONE Text_string[241] -#define TXT_TEAM_SELECT Text_string[242] -#define TXT_TEAM_PRESS_ENTER Text_string[243] -#define TXT_TEAM_ATLEAST_TWO Text_string[244] -#define TXT_IPX_NOT_FOUND Text_string[245] -#define TXT_NET_FORMING Text_string[246] -#define TXT_NET_PLAYERS Text_string[247] -#define TXT_NET_JOIN Text_string[248] -#define TXT_NET_CLOSED Text_string[249] -#define TXT_NET_BETWEEN Text_string[250] -#define TXT_NET_LEAVE Text_string[251] -#define TXT_NET_WAITING Text_string[252] -#define TXT_NET_TO_ENTER Text_string[253] -#define TXT_NET_SEARCHING Text_string[254] -#define TXT_INVALID_CHOICE Text_string[255] -#define TXT_NET_GAME_BETWEEN2 Text_string[256] -#define TXT_VERSION_MISMATCH Text_string[257] -#define TXT_GAME_FULL Text_string[258] -#define TXT_IN_PROGRESS Text_string[259] -#define TXT_DISCONNECTING Text_string[260] -#define TXT_SERIAL_OPEN_ERROR Text_string[261] -#define TXT_CARRIER_LOST Text_string[262] -#define TXT_ERROR_SERIAL_CFG Text_string[263] -#define TXT_ERR_SER_SETTINGS Text_string[264] -#define TXT_CONNECT_LOST Text_string[265] -#define TXT_READY_DESCENT Text_string[266] -#define TXT_CLOSED_LINK Text_string[267] -#define TXT_DIAL_MODEM Text_string[268] -#define TXT_ANSWER_MODEM Text_string[269] -#define TXT_NULL_MODEM Text_string[270] -#define TXT_COM_SETTINGS Text_string[271] -#define TXT_START_GAME Text_string[272] -#define TXT_SEND_MESSAGEP Text_string[273] -#define TXT_HANGUP_MODEM Text_string[274] -#define TXT_CLOSE_LINK Text_string[275] -#define TXT_SERIAL Text_string[276] -#define TXT_LINK_ACTIVE Text_string[277] -#define TXT_MODEM Text_string[278] -#define TXT_NOT_CONNECTED Text_string[279] -#define TXT_SERIAL_GAME Text_string[280] -#define TXT_EXIT_WILL_CLOSE Text_string[281] -#define TXT_BAUD_RATE Text_string[282] -#define TXT_MODEM_INIT_STRING Text_string[283] -#define TXT_ACCEPT_SAVE Text_string[284] -#define TXT_SERIAL_SETTINGS Text_string[285] -#define TXT_WARNING_16550 Text_string[286] -#define TXT_DIFFICULTY Text_string[287] -#define TXT_SERIAL_GAME_SETUP Text_string[288] -#define TXT_ONLY_ANARCHY Text_string[289] -#define TXT_SAVE Text_string[290] -#define TXT_ACCEPT Text_string[291] -#define TXT_SEL_NUMBER_EDIT Text_string[292] -#define TXT_EDIT_PHONE_ENTRY Text_string[293] -#define TXT_MANUAL_ENTRY Text_string[294] -#define TXT_EDIT_PHONEBOOK Text_string[295] -#define TXT_SEL_NUMBER_DIAL Text_string[296] -#define TXT_ENTER_NUMBER_DIAL Text_string[297] -#define TXT_NO_DIAL_TONE Text_string[298] -#define TXT_BUSY Text_string[299] -#define TXT_NO_ANSWER Text_string[300] -#define TXT_NO_CARRIER Text_string[301] -#define TXT_VOICE Text_string[302] -#define TXT_ERR_MODEM_RETURN Text_string[303] -#define TXT_CONNECT Text_string[304] -#define TXT_BAUD_GREATER_9600 Text_string[305] -#define TXT_RING Text_string[306] -#define TXT_NO_SERIAL_OPT Text_string[307] -#define TXT_RESET_MODEM Text_string[308] -#define TXT_NO_MODEM Text_string[309] -#define TXT_NO_PHONENUM Text_string[310] -#define TXT_DIALING Text_string[311] -#define TXT_ESC_ABORT Text_string[312] -#define TXT_WAITING_FOR_ANS Text_string[313] -#define TXT_WAITING_FOR_CALL Text_string[314] -#define TXT_WAITING_FOR_CARR Text_string[315] -#define TXT_FAILED_TO_NEGOT Text_string[316] -#define TXT_NEGOTIATION_FAIL Text_string[317] -#define TXT_FATAL_ERROR_LEVEL Text_string[318] -#define TXT_OTHER_LEVEL Text_string[319] -#define TXT_YOUR_LEVEL Text_string[320] -#define TXT_LVL_NO_MATCH Text_string[321] -#define TXT_CHECK_VERSION Text_string[322] -#define TXT_DESCENT_NO_MATCH Text_string[323] -#define TXT_OPPONENT_NO_READY Text_string[324] -#define TXT_WAIT_OPPONENT Text_string[325] -#define TXT_LOCK Text_string[326] -#define TXT_DEATHS Text_string[327] -#define TXT_LIVES Text_string[328] -#define TXT_LVL Text_string[329] -#define TXT_QUAD Text_string[330] -#define TXT_REAR_VIEW Text_string[331] -#define TXT_DIFFICULTY_1 Text_string[332] -#define TXT_DIFFICULTY_2 Text_string[333] -#define TXT_DIFFICULTY_3 Text_string[334] -#define TXT_DIFFICULTY_4 Text_string[335] -#define TXT_DIFFICULTY_5 Text_string[336] -#define TXT_DETAIL_1 Text_string[337] -#define TXT_DETAIL_2 Text_string[338] -#define TXT_DETAIL_3 Text_string[339] -#define TXT_DETAIL_4 Text_string[340] -#define TXT_DETAIL_5 Text_string[341] -#define TXT_DETAIL_CUSTOM_ Text_string[342] -#define TXT_LOAD_GAME Text_string[343] -#define TXT_MULTIPLAYER_ Text_string[344] -#define TXT_OPTIONS_ Text_string[345] -#define TXT_CHANGE_PILOTS Text_string[346] -#define TXT_VIEW_DEMO Text_string[347] -#define TXT_CREDITS Text_string[348] -#define TXT_ORDERING_INFO Text_string[349] -#define TXT_SELECT_DEMO Text_string[350] -#define TXT_DIFFICULTY_LEVEL Text_string[351] -#define TXT_SET_TO Text_string[352] -#define TXT_DETAIL_LEVEL Text_string[353] -#define TXT_OBJ_COMPLEXITY Text_string[354] -#define TXT_OBJ_DETAIL Text_string[355] -#define TXT_WALL_DETAIL Text_string[356] -#define TXT_WALL_RENDER_DEPTH Text_string[357] -#define TXT_DEBRIS_AMOUNT Text_string[358] -#define TXT_SOUND_CHANNELS Text_string[359] -#define TXT_LO_HI Text_string[360] -#define TXT_DETAIL_CUSTOM Text_string[361] -#define TXT_START_ANY_LEVEL Text_string[362] -#define TXT_SELECT_START_LEV Text_string[363] -#define TXT_ENTER_TO_CONT Text_string[364] -#define TXT_INVALID_LEVEL Text_string[365] -#define TXT_ERR_LOADING_GAME Text_string[366] -#define TXT_SAVE_GAME_SLOTS Text_string[367] -#define TXT_SAVE_ERROR Text_string[368] -#define TXT_FX_VOLUME Text_string[369] -#define TXT_MUSIC_VOLUME Text_string[370] -#define TXT_REVERSE_STEREO Text_string[371] -#define TXT_BRIGHTNESS Text_string[372] -#define TXT_CONTROLS_ Text_string[373] -#define TXT_DETAIL_LEVELS Text_string[374] -#define TXT_CAL_JOYSTICK Text_string[375] -#define TXT_JOYS_SENSITIVITY Text_string[376] -#define TXT_START_IPX_NET_GAME Text_string[377] -#define TXT_JOIN_IPX_NET_GAME Text_string[378] -#define TXT_MODEM_GAME Text_string[379] -#define TXT_MULTIPLAYER Text_string[380] -#define TXT_CONTINUE Text_string[381] -#define TXT_CANT_PLAYBACK Text_string[382] -#define TXT_DEMO_CORRUPT Text_string[383] -#define TXT_DEMO_OLD Text_string[384] -#define TXT_RECORDED Text_string[385] -#define TXT_WITH_REGISTERED Text_string[386] -#define TXT_WITH_SHAREWARE Text_string[387] -#define TXT_OF_DESCENT Text_string[388] -#define TXT_LEVEL_CANT_LOAD Text_string[389] -#define TXT_DEMO_OLD_CORRUPT Text_string[390] -#define TXT_DEMO_ERR_READING Text_string[391] -#define TXT_SAVE_DEMO_AS Text_string[392] -#define TXT_DEMO_USE_LETTERS Text_string[393] -#define TXT_AUTOMAP Text_string[394] -#define TXT_TURN_SHIP Text_string[395] -#define TXT_SLIDE_UPDOWN Text_string[396] -#define TXT_LEVEL Text_string[397] -#define TXT_PITCH_FORWARD Text_string[398] -#define TXT_PITCH_BACKWARD Text_string[399] -#define TXT_TURN_LEFT Text_string[400] -#define TXT_TURN_RIGHT Text_string[401] -#define TXT_SLIDE_ON Text_string[402] -#define TXT_SLIDE_LEFT Text_string[403] -#define TXT_SLIDE_RIGHT Text_string[404] -#define TXT_SLIDE_UP Text_string[405] -#define TXT_SLIDE_DOWN Text_string[406] -#define TXT_BANK_ON Text_string[407] -#define TXT_BANK_LEFT Text_string[408] -#define TXT_BANK_RIGHT Text_string[409] -#define TXT_FIRE_PRIMARY Text_string[410] -#define TXT_FIRE_SECONDARY Text_string[411] -#define TXT_FIRE_FLARE Text_string[412] -#define TXT_ACCELERATE Text_string[413] -#define TXT_REVERSE Text_string[414] -#define TXT_DROP_BOMB Text_string[415] -#define TXT_CRUISE_FASTER Text_string[416] -#define TXT_CRUISE_SLOWER Text_string[417] -#define TXT_CRUISE_OFF Text_string[418] -#define TXT_PITCH_UD Text_string[419] -#define TXT_TURN_LR Text_string[420] -#define TXT_SLIDE_LR Text_string[421] -#define TXT_SLIDE_UD Text_string[422] -#define TXT_BANK_LR Text_string[423] -#define TXT_THROTTLE Text_string[424] -#define TXT_TEAM_ATLEAST_THREE Text_string[425] -#define TXT_NET_DISCONNECTED Text_string[426] -#define TXT_NET_PLAYING Text_string[427] -#define TXT_NET_ESCAPED Text_string[428] -#define TXT_NET_DIED Text_string[429] -#define TXT_NET_FOUND_SECRET Text_string[430] -#define TXT_NET_ESCAPE_TUNNEL Text_string[431] -#define TXT_NET_RESERVED Text_string[432] -#define TXT_WOWIE_ZOWIE Text_string[433] -#define TXT_ALL_KEYS Text_string[434] -#define TXT_CLOAK Text_string[435] -#define TXT_FULL_SHIELDS Text_string[436] -#define TXT_ON Text_string[437] -#define TXT_OFF Text_string[438] -#define TXT_NOT_IN_SHAREWARE Text_string[439] -#define TXT_GAME_OVER Text_string[440] -#define TXT_SELECT_PILOT Text_string[441] -#define TXT_ENTER_PILOT_NAME Text_string[442] -#define TXT_PLAYER Text_string[443] -#define TXT_ALREADY_EXISTS Text_string[444] -#define TXT_LOADING Text_string[445] -#define TXT_FULL_RESCUE_BONUS Text_string[446] -#define TXT_SHIELD_BONUS Text_string[447] -#define TXT_ENERGY_BONUS Text_string[448] -#define TXT_HOSTAGE_BONUS Text_string[449] -#define TXT_SKILL_BONUS Text_string[450] -#define TXT_TOTAL_BONUS Text_string[451] -#define TXT_TOTAL_SCORE Text_string[452] -#define TXT_SECRET_LEVEL Text_string[453] -#define TXT_COMPLETE Text_string[454] -#define TXT_DESTROYED Text_string[455] -#define TXT_SAVE_GAME Text_string[456] -#define TXT_PRESS_CTRL_R Text_string[457] -#define TXT_RESET_HIGH_SCORES Text_string[458] -#define TXT_YOU_WERE Text_string[459] -#define TXT_WAS Text_string[460] -#define TXT_KILLED_BY_NONPLAY Text_string[461] -#define TXT_IMPORTANT_NOTE Text_string[462] -#define TXT_FCS Text_string[463] -#define TXT_PRESS_ANY_KEY Text_string[464] -#define TXT_HOSTAGE_RESCUED Text_string[465] -#define TXT_INIT_VICTOR Text_string[466] -#define TXT_N Text_string[467] -#define TXT_Y Text_string[468] -#define TXT_ANY_LEVEL Text_string[469] -#define TXT_SHAREWARE_DONE Text_string[470] -#define TXT_PRESS_NEW_KEY Text_string[471] -#define TXT_PRESS_NEW_JBUTTON Text_string[472] -#define TXT_PRESS_NEW_MBUTTON Text_string[473] -#define TXT_MOVE_NEW_JOY_AXIS Text_string[474] -#define TXT_MOVE_NEW_MSE_AXIS Text_string[475] -#define TXT_USING_VFX1 Text_string[476] -#define TXT_VFX1_ERROR1 Text_string[477] -#define TXT_VFX1_ERROR2 Text_string[478] -#define TXT_KCONFIG_STRING_1 Text_string[479] -#define TXT_BUTTONS Text_string[480] -#define TXT_AXES Text_string[481] -#define TXT_AXIS Text_string[482] -#define TXT_INVERT Text_string[483] -#define TXT_BTN_1 Text_string[484] -#define TXT_BTN_2 Text_string[485] -#define TXT_BTN_3 Text_string[486] -#define TXT_BTN_4 Text_string[487] -#define TXT_TRIG Text_string[488] -#define TXT_HAT_L Text_string[489] -#define TXT_HAT_D Text_string[490] -#define TXT_HAT_R Text_string[491] -#define TXT_HAT_U Text_string[492] -#define TXT_LEFT Text_string[493] -#define TXT_RIGHT Text_string[494] -#define TXT_MID Text_string[495] -#define TXT_UP Text_string[496] -#define TXT_DOWN Text_string[497] -#define TXT_X1 Text_string[498] -#define TXT_Y1 Text_string[499] -#define TXT_X2 Text_string[500] -#define TXT_Y2 Text_string[501] -#define TXT_L_R Text_string[502] -#define TXT_F_B Text_string[503] -#define TXT_FORWARD Text_string[504] -#define TXT_MOVE_THROTTLE_F Text_string[505] -#define TXT_MOVE_THROTTLE_R Text_string[506] -#define TXT_MOVE_THROTTLE_C Text_string[507] -#define TXT_REACTOR_EXPLODED Text_string[508] -#define TXT_TIME_REMAINING Text_string[509] -#define TXT_SECONDS Text_string[510] -#define TXT_DEMO_WRITE_ERROR Text_string[511] -#define TXT_DEMO_SIZE Text_string[512] -#define TXT_DEMO_SAVE_BAD Text_string[513] -#define TXT_BYTE_STR Text_string[514] -#define TXT_DIED_IN_MINE Text_string[515] -#define TXT_SHIP_BONUS Text_string[516] -#define TXT_PHONE_NUM Text_string[517] -#define TXT_KILL_MATRIX_TITLE Text_string[518] -#define TXT_WAIT_FOR_OK Text_string[519] -#define TXT_SURE_ABORT_SYNC Text_string[520] -#define TXT_ERROR_WRITING_PLR Text_string[521] -#define TXT_SHIP_DESTROYED_0 Text_string[522] -#define TXT_SHIP_DESTROYED_1 Text_string[523] -#define TXT_SHIP_DESTROYED_2 Text_string[524] -#define TXT_NET_FULL Text_string[525] -#define TXT_DEMO_NO_SPACE Text_string[526] -#define TXT_HAT2_L Text_string[527] -#define TXT_HAT2_R Text_string[528] -#define TXT_HAT2_U Text_string[529] -#define TXT_HAT2_D Text_string[530] -#define TXT_WARP_TO_LEVEL Text_string[531] -#define TXT_TRADEMARK Text_string[532] -#define TXT_NET_SYNC_FAILED Text_string[533] -#define TXT_DONE Text_string[534] -#define TXT_I_AM_A Text_string[535] -#define TXT_CHEATER Text_string[536] -#define TXT_LOADING_DATA Text_string[537] -#define TXT_HELP_ALT_F2 Text_string[538] -#define TXT_HELP_ALT_F3 Text_string[539] -#define TXT_ONLY_REGISTERED Text_string[540] -#define TXT_CONCUSSION Text_string[541] -#define TXT_HOMING Text_string[542] -#define TXT_PROXBOMB Text_string[543] -#define TXT_SMART Text_string[544] -#define TXT_MEGA Text_string[545] -#define TXT_NOMISSION4DEMO Text_string[546] -#define TXT_SHOW_IDS Text_string[547] -#define TXT_DUPLICATE_NAME Text_string[548] -#define TXT_ANARCHY_ONLY_MISSION Text_string[549] -#define TXT_START_NOWAIT Text_string[550] -#define TXT_QUITTING_NOW Text_string[551] -#define TXT_MISSION_NOT_FOUND Text_string[552] -#define TXT_MULTI_MISSION Text_string[553] -#define TXT_MISSION_ERROR Text_string[554] -#define TXT_COM_CUSTOM_SETTINGS Text_string[555] -#define TXT_COM_BASE Text_string[556] -#define TXT_COM_IRQ Text_string[557] -#define TXT_RESET_DEFAULTS Text_string[558] -#define TXT_VALID_IRQS Text_string[559] -#define TXT_NO_UART Text_string[560] -#define TXT_DEF_MACRO_1 Text_string[561] -#define TXT_DEF_MACRO_2 Text_string[562] -#define TXT_DEF_MACRO_3 Text_string[563] -#define TXT_DEF_MACRO_4 Text_string[564] -#define TXT_MISSION Text_string[565] -#define TXT_VIEWING_DISTANCE Text_string[566] -#define TXT_SECRET_EXIT Text_string[567] -#define TXT_SHOW_ON_MAP Text_string[568] -#define TXT_KILLED_BY_ROBOT Text_string[569] -#define TXT_BAUD Text_string[570] -#define TXT_CONSISTENCY_ERROR Text_string[571] -#define TXT_PRESS_ANY_KEY2 Text_string[572] -#define TXT_DEMO_SAVE_NOSPACE Text_string[573] -#define TXT_CNTRLCEN_INVUL Text_string[574] -#define TXT_NO_DESTSAT_LVL Text_string[575] -#define TXT_REACTOR_LIFE Text_string[576] -#define TXT_MINUTES_ABBREV Text_string[577] -#define TXT_CURRENT_IPX_SOCKET Text_string[578] -#define TXT_DOS_VERSION_1 Text_string[579] -#define TXT_DOS_VERSION_2 Text_string[580] -#define TXT_NOT_ENOUGH_HANDLES Text_string[581] -#define TXT_HANDLES_1 Text_string[582] -#define TXT_HANDLES_2 Text_string[583] -#define TXT_HANDLES_3 Text_string[584] -#define TXT_AVAILABLE_MEMORY Text_string[585] -#define TXT_MEMORY_CONFIG Text_string[586] -#define TXT_RECONFIGURE_VMM Text_string[587] -#define TXT_MORE_MEMORY Text_string[588] -#define TXT_MORE_MEMORY_2 Text_string[589] -#define TXT_PHYSICAL_MEMORY Text_string[590] -#define TXT_PHYSICAL_MEMORY_2 Text_string[591] -#define TXT_INITIALIZING_DPMI Text_string[592] -#define TXT_INITIALIZING_CRIT Text_string[593] -#define TXT_IGLASSES Text_string[594] -#define TXT_VIOTRACK Text_string[595] -#define TXT_KASAN Text_string[596] -#define TXT_KASAN_2 Text_string[597] -#define TXT_3DMAX Text_string[598] -#define TXT_PRESS_ANY_KEY3 Text_string[599] -#define TXT_SOCKET Text_string[600] -#define TXT_NOFILECHECK Text_string[601] -#define TXT_VERBOSE_1 Text_string[602] -#define TXT_VERBOSE_2 Text_string[603] -#define TXT_VERBOSE_3 Text_string[604] -#define TXT_VERBOSE_4 Text_string[605] -#define TXT_VERBOSE_5 Text_string[606] -#define TXT_VERBOSE_6 Text_string[607] -#define TXT_VERBOSE_7 Text_string[608] -#define TXT_VERBOSE_8 Text_string[609] -#define TXT_VERBOSE_9 Text_string[610] -#define TXT_VERBOSE_10 Text_string[611] -#define TXT_VERBOSE_11 Text_string[612] +#define TXT_REGISTRATION Text_string[192] +#define TXT_ERROR_SELECTOR Text_string[193] +#define TXT_ERROR_GRAPHICS Text_string[194] +#define TXT_CALIBRATE Text_string[195] +#define TXT_SKIP Text_string[196] +#define TXT_JOYSTICK_NOT_CEN Text_string[197] +#define TXT_CHOOSE_INPUT Text_string[198] +#define TXT_ERROR Text_string[199] +#define TXT_ERROR_PLR_VERSION Text_string[200] +#define TXT_DEMO_PLAYBACK Text_string[201] +#define TXT_DEMO_RECORDING Text_string[202] +#define TXT_CRUISE Text_string[203] +#define TXT_DUMPING_SCREEN Text_string[204] +#define TXT_CHEATS_ENABLED Text_string[205] +#define TXT_NET_GAME_CLOSED Text_string[206] +#define TXT_NET_GAME_FULL Text_string[207] +#define TXT_NET_GAME_BETWEEN Text_string[208] +#define TXT_NET_GAME_NSELECT Text_string[209] +#define TXT_NET_GAME_NSTART Text_string[210] +#define TXT_NET_GAME_CONNECT Text_string[211] +#define TXT_NET_GAME_WRONGLEV Text_string[212] +#define TXT_KILLS Text_string[213] +#define TXT_WAITING Text_string[214] +#define TXT_SURE_LEAVE_GAME Text_string[215] +#define TXT_JOINING Text_string[216] +#define TXT_REJOIN Text_string[217] +#define TXT_SORRY_ONLY Text_string[218] +#define TXT_NETPLAYERS_IN Text_string[219] +#define TXT_S_GAME Text_string[220] +#define TXT_DESCRIPTION Text_string[221] +#define TXT_LEVEL_ Text_string[222] +#define TXT_MODE Text_string[223] +#define TXT_ANARCHY Text_string[224] +#define TXT_TEAM_ANARCHY Text_string[225] +#define TXT_ANARCHY_W_ROBOTS Text_string[226] +#define TXT_COOPERATIVE Text_string[227] +#define TXT_OPTIONS Text_string[228] +#define TXT_CLOSED_GAME Text_string[229] +#define TXT_NETGAME_SETUP Text_string[230] +#define TXT_LEVEL_OUT_RANGE Text_string[231] +#define TXT_SORRY Text_string[232] +#define TXT_REGISTERED_ONLY Text_string[233] +#define TXT_WAIT Text_string[234] +#define TXT_FOUND Text_string[235] +#define TXT_ACTIVE_GAMES Text_string[236] +#define TXT_STARTING_NETGAME Text_string[237] +#define TXT_NETLEVEL_NMATCH Text_string[238] +#define TXT_TEAM Text_string[239] +#define TXT_TEAM_SELECTION Text_string[240] +#define TXT_TEAM_MUST_ONE Text_string[241] +#define TXT_TEAM_SELECT Text_string[242] +#define TXT_TEAM_PRESS_ENTER Text_string[243] +#define TXT_TEAM_ATLEAST_TWO Text_string[244] +#define TXT_IPX_NOT_FOUND Text_string[245] +#define TXT_NET_FORMING Text_string[246] +#define TXT_NET_PLAYERS Text_string[247] +#define TXT_NET_JOIN Text_string[248] +#define TXT_NET_CLOSED Text_string[249] +#define TXT_NET_BETWEEN Text_string[250] +#define TXT_NET_LEAVE Text_string[251] +#define TXT_NET_WAITING Text_string[252] +#define TXT_NET_TO_ENTER Text_string[253] +#define TXT_NET_SEARCHING Text_string[254] +#define TXT_INVALID_CHOICE Text_string[255] +#define TXT_NET_GAME_BETWEEN2 Text_string[256] +#define TXT_VERSION_MISMATCH Text_string[257] +#define TXT_GAME_FULL Text_string[258] +#define TXT_IN_PROGRESS Text_string[259] +#define TXT_DISCONNECTING Text_string[260] +#define TXT_SERIAL_OPEN_ERROR Text_string[261] +#define TXT_CARRIER_LOST Text_string[262] +#define TXT_ERROR_SERIAL_CFG Text_string[263] +#define TXT_ERR_SER_SETTINGS Text_string[264] +#define TXT_CONNECT_LOST Text_string[265] +#define TXT_READY_DESCENT Text_string[266] +#define TXT_CLOSED_LINK Text_string[267] +#define TXT_DIAL_MODEM Text_string[268] +#define TXT_ANSWER_MODEM Text_string[269] +#define TXT_NULL_MODEM Text_string[270] +#define TXT_COM_SETTINGS Text_string[271] +#define TXT_START_GAME Text_string[272] +#define TXT_SEND_MESSAGEP Text_string[273] +#define TXT_HANGUP_MODEM Text_string[274] +#define TXT_CLOSE_LINK Text_string[275] +#define TXT_SERIAL Text_string[276] +#define TXT_LINK_ACTIVE Text_string[277] +#define TXT_MODEM Text_string[278] +#define TXT_NOT_CONNECTED Text_string[279] +#define TXT_SERIAL_GAME Text_string[280] +#define TXT_EXIT_WILL_CLOSE Text_string[281] +#define TXT_BAUD_RATE Text_string[282] +#define TXT_MODEM_INIT_STRING Text_string[283] +#define TXT_ACCEPT_SAVE Text_string[284] +#define TXT_SERIAL_SETTINGS Text_string[285] +#define TXT_WARNING_16550 Text_string[286] +#define TXT_DIFFICULTY Text_string[287] +#define TXT_SERIAL_GAME_SETUP Text_string[288] +#define TXT_ONLY_ANARCHY Text_string[289] +#define TXT_SAVE Text_string[290] +#define TXT_ACCEPT Text_string[291] +#define TXT_SEL_NUMBER_EDIT Text_string[292] +#define TXT_EDIT_PHONE_ENTRY Text_string[293] +#define TXT_MANUAL_ENTRY Text_string[294] +#define TXT_EDIT_PHONEBOOK Text_string[295] +#define TXT_SEL_NUMBER_DIAL Text_string[296] +#define TXT_ENTER_NUMBER_DIAL Text_string[297] +#define TXT_NO_DIAL_TONE Text_string[298] +#define TXT_BUSY Text_string[299] +#define TXT_NO_ANSWER Text_string[300] +#define TXT_NO_CARRIER Text_string[301] +#define TXT_VOICE Text_string[302] +#define TXT_ERR_MODEM_RETURN Text_string[303] +#define TXT_CONNECT Text_string[304] +#define TXT_BAUD_GREATER_9600 Text_string[305] +#define TXT_RING Text_string[306] +#define TXT_NO_SERIAL_OPT Text_string[307] +#define TXT_RESET_MODEM Text_string[308] +#define TXT_NO_MODEM Text_string[309] +#define TXT_NO_PHONENUM Text_string[310] +#define TXT_DIALING Text_string[311] +#define TXT_ESC_ABORT Text_string[312] +#define TXT_WAITING_FOR_ANS Text_string[313] +#define TXT_WAITING_FOR_CALL Text_string[314] +#define TXT_WAITING_FOR_CARR Text_string[315] +#define TXT_FAILED_TO_NEGOT Text_string[316] +#define TXT_NEGOTIATION_FAIL Text_string[317] +#define TXT_FATAL_ERROR_LEVEL Text_string[318] +#define TXT_OTHER_LEVEL Text_string[319] +#define TXT_YOUR_LEVEL Text_string[320] +#define TXT_LVL_NO_MATCH Text_string[321] +#define TXT_CHECK_VERSION Text_string[322] +#define TXT_DESCENT_NO_MATCH Text_string[323] +#define TXT_OPPONENT_NO_READY Text_string[324] +#define TXT_WAIT_OPPONENT Text_string[325] +#define TXT_LOCK Text_string[326] +#define TXT_DEATHS Text_string[327] +#define TXT_LIVES Text_string[328] +#define TXT_LVL Text_string[329] +#define TXT_QUAD Text_string[330] +#define TXT_REAR_VIEW Text_string[331] +#define TXT_DIFFICULTY_1 Text_string[332] +#define TXT_DIFFICULTY_2 Text_string[333] +#define TXT_DIFFICULTY_3 Text_string[334] +#define TXT_DIFFICULTY_4 Text_string[335] +#define TXT_DIFFICULTY_5 Text_string[336] +#define TXT_DETAIL_1 Text_string[337] +#define TXT_DETAIL_2 Text_string[338] +#define TXT_DETAIL_3 Text_string[339] +#define TXT_DETAIL_4 Text_string[340] +#define TXT_DETAIL_5 Text_string[341] +#define TXT_DETAIL_CUSTOM_ Text_string[342] +#define TXT_LOAD_GAME Text_string[343] +#define TXT_MULTIPLAYER_ Text_string[344] +#define TXT_OPTIONS_ Text_string[345] +#define TXT_CHANGE_PILOTS Text_string[346] +#define TXT_VIEW_DEMO Text_string[347] +#define TXT_CREDITS Text_string[348] +#define TXT_ORDERING_INFO Text_string[349] +#define TXT_SELECT_DEMO Text_string[350] +#define TXT_DIFFICULTY_LEVEL Text_string[351] +#define TXT_SET_TO Text_string[352] +#define TXT_DETAIL_LEVEL Text_string[353] +#define TXT_OBJ_COMPLEXITY Text_string[354] +#define TXT_OBJ_DETAIL Text_string[355] +#define TXT_WALL_DETAIL Text_string[356] +#define TXT_WALL_RENDER_DEPTH Text_string[357] +#define TXT_DEBRIS_AMOUNT Text_string[358] +#define TXT_SOUND_CHANNELS Text_string[359] +#define TXT_LO_HI Text_string[360] +#define TXT_DETAIL_CUSTOM Text_string[361] +#define TXT_START_ANY_LEVEL Text_string[362] +#define TXT_SELECT_START_LEV Text_string[363] +#define TXT_ENTER_TO_CONT Text_string[364] +#define TXT_INVALID_LEVEL Text_string[365] +#define TXT_ERR_LOADING_GAME Text_string[366] +#define TXT_SAVE_GAME_SLOTS Text_string[367] +#define TXT_SAVE_ERROR Text_string[368] +#define TXT_FX_VOLUME Text_string[369] +#define TXT_MUSIC_VOLUME Text_string[370] +#define TXT_REVERSE_STEREO Text_string[371] +#define TXT_BRIGHTNESS Text_string[372] +#define TXT_CONTROLS_ Text_string[373] +#define TXT_DETAIL_LEVELS Text_string[374] +#define TXT_CAL_JOYSTICK Text_string[375] +#define TXT_JOYS_SENSITIVITY Text_string[376] +#define TXT_START_IPX_NET_GAME Text_string[377] +#define TXT_JOIN_IPX_NET_GAME Text_string[378] +#define TXT_MODEM_GAME Text_string[379] +#define TXT_MULTIPLAYER Text_string[380] +#define TXT_CONTINUE Text_string[381] +#define TXT_CANT_PLAYBACK Text_string[382] +#define TXT_DEMO_CORRUPT Text_string[383] +#define TXT_DEMO_OLD Text_string[384] +#define TXT_RECORDED Text_string[385] +#define TXT_WITH_REGISTERED Text_string[386] +#define TXT_WITH_SHAREWARE Text_string[387] +#define TXT_OF_DESCENT Text_string[388] +#define TXT_LEVEL_CANT_LOAD Text_string[389] +#define TXT_DEMO_OLD_CORRUPT Text_string[390] +#define TXT_DEMO_ERR_READING Text_string[391] +#define TXT_SAVE_DEMO_AS Text_string[392] +#define TXT_DEMO_USE_LETTERS Text_string[393] +#define TXT_AUTOMAP Text_string[394] +#define TXT_TURN_SHIP Text_string[395] +#define TXT_SLIDE_UPDOWN Text_string[396] +#define TXT_LEVEL Text_string[397] +#define TXT_PITCH_FORWARD Text_string[398] +#define TXT_PITCH_BACKWARD Text_string[399] +#define TXT_TURN_LEFT Text_string[400] +#define TXT_TURN_RIGHT Text_string[401] +#define TXT_SLIDE_ON Text_string[402] +#define TXT_SLIDE_LEFT Text_string[403] +#define TXT_SLIDE_RIGHT Text_string[404] +#define TXT_SLIDE_UP Text_string[405] +#define TXT_SLIDE_DOWN Text_string[406] +#define TXT_BANK_ON Text_string[407] +#define TXT_BANK_LEFT Text_string[408] +#define TXT_BANK_RIGHT Text_string[409] +#define TXT_FIRE_PRIMARY Text_string[410] +#define TXT_FIRE_SECONDARY Text_string[411] +#define TXT_FIRE_FLARE Text_string[412] +#define TXT_ACCELERATE Text_string[413] +#define TXT_REVERSE Text_string[414] +#define TXT_DROP_BOMB Text_string[415] +#define TXT_CRUISE_FASTER Text_string[416] +#define TXT_CRUISE_SLOWER Text_string[417] +#define TXT_CRUISE_OFF Text_string[418] +#define TXT_PITCH_UD Text_string[419] +#define TXT_TURN_LR Text_string[420] +#define TXT_SLIDE_LR Text_string[421] +#define TXT_SLIDE_UD Text_string[422] +#define TXT_BANK_LR Text_string[423] +#define TXT_THROTTLE Text_string[424] +#define TXT_TEAM_ATLEAST_THREE Text_string[425] +#define TXT_NET_DISCONNECTED Text_string[426] +#define TXT_NET_PLAYING Text_string[427] +#define TXT_NET_ESCAPED Text_string[428] +#define TXT_NET_DIED Text_string[429] +#define TXT_NET_FOUND_SECRET Text_string[430] +#define TXT_NET_ESCAPE_TUNNEL Text_string[431] +#define TXT_NET_RESERVED Text_string[432] +#define TXT_WOWIE_ZOWIE Text_string[433] +#define TXT_ALL_KEYS Text_string[434] +#define TXT_CLOAK Text_string[435] +#define TXT_FULL_SHIELDS Text_string[436] +#define TXT_ON Text_string[437] +#define TXT_OFF Text_string[438] +#define TXT_NOT_IN_SHAREWARE Text_string[439] +#define TXT_GAME_OVER Text_string[440] +#define TXT_SELECT_PILOT Text_string[441] +#define TXT_ENTER_PILOT_NAME Text_string[442] +#define TXT_PLAYER Text_string[443] +#define TXT_ALREADY_EXISTS Text_string[444] +#define TXT_LOADING Text_string[445] +#define TXT_FULL_RESCUE_BONUS Text_string[446] +#define TXT_SHIELD_BONUS Text_string[447] +#define TXT_ENERGY_BONUS Text_string[448] +#define TXT_HOSTAGE_BONUS Text_string[449] +#define TXT_SKILL_BONUS Text_string[450] +#define TXT_TOTAL_BONUS Text_string[451] +#define TXT_TOTAL_SCORE Text_string[452] +#define TXT_SECRET_LEVEL Text_string[453] +#define TXT_COMPLETE Text_string[454] +#define TXT_DESTROYED Text_string[455] +#define TXT_SAVE_GAME Text_string[456] +#define TXT_PRESS_CTRL_R Text_string[457] +#define TXT_RESET_HIGH_SCORES Text_string[458] +#define TXT_YOU_WERE Text_string[459] +#define TXT_WAS Text_string[460] +#define TXT_KILLED_BY_NONPLAY Text_string[461] +#define TXT_IMPORTANT_NOTE Text_string[462] +#define TXT_FCS Text_string[463] +#define TXT_PRESS_ANY_KEY Text_string[464] +#define TXT_HOSTAGE_RESCUED Text_string[465] +#define TXT_INIT_VICTOR Text_string[466] +#define TXT_N Text_string[467] +#define TXT_Y Text_string[468] +#define TXT_ANY_LEVEL Text_string[469] +#define TXT_SHAREWARE_DONE Text_string[470] +#define TXT_PRESS_NEW_KEY Text_string[471] +#define TXT_PRESS_NEW_JBUTTON Text_string[472] +#define TXT_PRESS_NEW_MBUTTON Text_string[473] +#define TXT_MOVE_NEW_JOY_AXIS Text_string[474] +#define TXT_MOVE_NEW_MSE_AXIS Text_string[475] +#define TXT_USING_VFX1 Text_string[476] +#define TXT_VFX1_ERROR1 Text_string[477] +#define TXT_VFX1_ERROR2 Text_string[478] +#define TXT_KCONFIG_STRING_1 Text_string[479] +#define TXT_BUTTONS Text_string[480] +#define TXT_AXES Text_string[481] +#define TXT_AXIS Text_string[482] +#define TXT_INVERT Text_string[483] +#define TXT_BTN_1 Text_string[484] +#define TXT_BTN_2 Text_string[485] +#define TXT_BTN_3 Text_string[486] +#define TXT_BTN_4 Text_string[487] +#define TXT_TRIG Text_string[488] +#define TXT_HAT_L Text_string[489] +#define TXT_HAT_R Text_string[490] +#define TXT_HAT_U Text_string[491] +#define TXT_HAT_D Text_string[492] +#define TXT_LEFT Text_string[493] +#define TXT_RIGHT Text_string[494] +#define TXT_MID Text_string[495] +#define TXT_UP Text_string[496] +#define TXT_DOWN Text_string[497] +#define TXT_X1 Text_string[498] +#define TXT_Y1 Text_string[499] +#define TXT_X2 Text_string[500] +#define TXT_Y2 Text_string[501] +#define TXT_L_R Text_string[502] +#define TXT_F_B Text_string[503] +#define TXT_FORWARD Text_string[504] +#define TXT_MOVE_THROTTLE_F Text_string[505] +#define TXT_MOVE_THROTTLE_R Text_string[506] +#define TXT_MOVE_THROTTLE_C Text_string[507] +#define TXT_REACTOR_EXPLODED Text_string[508] +#define TXT_TIME_REMAINING Text_string[509] +#define TXT_SECONDS Text_string[510] +#define TXT_DEMO_WRITE_ERROR Text_string[511] +#define TXT_DEMO_SIZE Text_string[512] +#define TXT_DEMO_SAVE_BAD Text_string[513] +#define TXT_BYTE_STR Text_string[514] +#define TXT_DIED_IN_MINE Text_string[515] +#define TXT_SHIP_BONUS Text_string[516] +#define TXT_PHONE_NUM Text_string[517] +#define TXT_KILL_MATRIX_TITLE Text_string[518] +#define TXT_WAIT_FOR_OK Text_string[519] +#define TXT_SURE_ABORT_SYNC Text_string[520] +#define TXT_ERROR_WRITING_PLR Text_string[521] +#define TXT_SHIP_DESTROYED_0 Text_string[522] +#define TXT_SHIP_DESTROYED_1 Text_string[523] +#define TXT_SHIP_DESTROYED_2 Text_string[524] +#define TXT_NET_FULL Text_string[525] +#define TXT_DEMO_NO_SPACE Text_string[526] +#define TXT_HAT2_L Text_string[527] +#define TXT_HAT2_R Text_string[528] +#define TXT_HAT2_U Text_string[529] +#define TXT_HAT2_D Text_string[530] +#define TXT_WARP_TO_LEVEL Text_string[531] +#define TXT_TRADEMARK Text_string[532] +#define TXT_NET_SYNC_FAILED Text_string[533] +#define TXT_DONE Text_string[534] +#define TXT_I_AM_A Text_string[535] +#define TXT_CHEATER Text_string[536] +#define TXT_LOADING_DATA Text_string[537] +#define TXT_HELP_ALT_F2 Text_string[538] +#define TXT_HELP_ALT_F3 Text_string[539] +#define TXT_ONLY_REGISTERED Text_string[540] +#define TXT_CONCUSSION Text_string[541] +#define TXT_HOMING Text_string[542] +#define TXT_PROXBOMB Text_string[543] +#define TXT_SMART Text_string[544] +#define TXT_MEGA Text_string[545] +#define TXT_NOMISSION4DEMO Text_string[546] +#define TXT_SHOW_IDS Text_string[547] +#define TXT_DUPLICATE_NAME Text_string[548] +#define TXT_ANARCHY_ONLY_MISSION Text_string[549] +#define TXT_START_NOWAIT Text_string[550] +#define TXT_QUITTING_NOW Text_string[551] +#define TXT_MISSION_NOT_FOUND Text_string[552] +#define TXT_MULTI_MISSION Text_string[553] +#define TXT_MISSION_ERROR Text_string[554] +#define TXT_COM_CUSTOM_SETTINGS Text_string[555] +#define TXT_COM_BASE Text_string[556] +#define TXT_COM_IRQ Text_string[557] +#define TXT_RESET_DEFAULTS Text_string[558] +#define TXT_VALID_IRQS Text_string[559] +#define TXT_NO_UART Text_string[560] +#define TXT_DEF_MACRO_1 Text_string[561] +#define TXT_DEF_MACRO_2 Text_string[562] +#define TXT_DEF_MACRO_3 Text_string[563] +#define TXT_DEF_MACRO_4 Text_string[564] +#define TXT_MISSION Text_string[565] +#define TXT_VIEWING_DISTANCE Text_string[566] +#define TXT_SECRET_EXIT Text_string[567] +#define TXT_SHOW_ON_MAP Text_string[568] +#define TXT_KILLED_BY_ROBOT Text_string[569] +#define TXT_BAUD Text_string[570] +#define TXT_CONSISTENCY_ERROR Text_string[571] +#define TXT_PRESS_ANY_KEY2 Text_string[572] +#define TXT_DEMO_SAVE_NOSPACE Text_string[573] +#define TXT_CNTRLCEN_INVUL Text_string[574] +#define TXT_NO_DESTSAT_LVL Text_string[575] +#define TXT_REACTOR_LIFE Text_string[576] +#define TXT_MINUTES_ABBREV Text_string[577] +#define TXT_CURRENT_IPX_SOCKET Text_string[578] +#define TXT_DOS_VERSION_1 Text_string[579] +#define TXT_DOS_VERSION_2 Text_string[580] +#define TXT_NOT_ENOUGH_HANDLES Text_string[581] +#define TXT_HANDLES_1 Text_string[582] +#define TXT_HANDLES_2 Text_string[583] +#define TXT_HANDLES_3 Text_string[584] +#define TXT_AVAILABLE_MEMORY Text_string[585] +#define TXT_MEMORY_CONFIG Text_string[586] +#define TXT_RECONFIGURE_VMM Text_string[587] +#define TXT_MORE_MEMORY Text_string[588] +#define TXT_MORE_MEMORY_2 Text_string[589] +#define TXT_PHYSICAL_MEMORY Text_string[590] +#define TXT_PHYSICAL_MEMORY_2 Text_string[591] +#define TXT_INITIALIZING_DPMI Text_string[592] +#define TXT_INITIALIZING_CRIT Text_string[593] +#define TXT_IGLASSES Text_string[594] +#define TXT_VIOTRACK Text_string[595] +#define TXT_KASAN Text_string[596] +#define TXT_KASAN_2 Text_string[597] +#define TXT_3DMAX Text_string[598] +#define TXT_PRESS_ANY_KEY3 Text_string[599] +#define TXT_SOCKET Text_string[600] +#define TXT_NOFILECHECK Text_string[601] +#define TXT_VERBOSE_1 Text_string[602] +#define TXT_VERBOSE_2 Text_string[603] +#define TXT_VERBOSE_3 Text_string[604] +#define TXT_VERBOSE_4 Text_string[605] +#define TXT_VERBOSE_5 Text_string[606] +#define TXT_VERBOSE_6 Text_string[607] +#define TXT_VERBOSE_7 Text_string[608] +#define TXT_VERBOSE_8 Text_string[609] +#define TXT_VERBOSE_9 Text_string[610] +#define TXT_VERBOSE_10 Text_string[611] +#define TXT_VERBOSE_11 Text_string[612] #define TXT_INITIALIZING_NETWORK Text_string[613] -#define TXT_IPX_CHANNEL Text_string[614] -#define TXT_NO_NETWORK Text_string[615] -#define TXT_SOCKET_ERROR Text_string[616] -#define TXT_MEMORY_IPX Text_string[617] -#define TXT_ERROR_IPX Text_string[618] -#define TXT_NETWORK_DISABLED Text_string[619] +#define TXT_IPX_CHANNEL Text_string[614] +#define TXT_NO_NETWORK Text_string[615] +#define TXT_SOCKET_ERROR Text_string[616] +#define TXT_MEMORY_IPX Text_string[617] +#define TXT_ERROR_IPX Text_string[618] +#define TXT_NETWORK_DISABLED Text_string[619] #define TXT_INITIALIZING_GRAPHICS Text_string[620] -#define TXT_SOUND_ERROR_OPEN Text_string[621] -#define TXT_SOUND_ERROR_LOCK Text_string[622] -#define TXT_SOUND_ERROR_HMI Text_string[623] +#define TXT_SOUND_ERROR_OPEN Text_string[621] +#define TXT_SOUND_ERROR_LOCK Text_string[622] +#define TXT_SOUND_ERROR_HMI Text_string[623] #define TXT_SOUND_ERROR_LOCK_DRUMS Text_string[624] -#define TXT_SOUND_ERROR_MIDI Text_string[625] +#define TXT_SOUND_ERROR_MIDI Text_string[625] #define TXT_SOUND_ERROR_MIDI_CALLBACK Text_string[626] -#define TXT_EXTERNAL_CONTROL Text_string[627] -#define TXT_IGLASSES_ERROR_1 Text_string[628] -#define TXT_IGLASSES_INIT Text_string[629] -#define TXT_IGLASSES_ON Text_string[630] -#define TXT_PRESS_ESC_TO_ABORT Text_string[631] -#define TXT_SERIAL_FAILURE Text_string[632] -#define TXT_MESSAGE Text_string[633] -#define TXT_MACRO Text_string[634] -#define TXT_ERROR_SERIAL_LOCK Text_string[635] -#define TXT_ERROR_SERIAL_LOCK_2 Text_string[636] -#define TXT_NO_LUNACY Text_string[637] -#define TXT_LUNACY Text_string[638] -#define TXT_ROBOT_PAINTING_OFF Text_string[639] -#define TXT_ROBOT_PAINTING_ON Text_string[640] -#define TXT_START_TCP_NET_GAME Text_string[641] -#define TXT_JOIN_TCP_NET_GAME Text_string[642] -#define TXT_AFTERBURNER Text_string[643] +#define TXT_EXTERNAL_CONTROL Text_string[627] +#define TXT_IGLASSES_ERROR_1 Text_string[628] +#define TXT_IGLASSES_INIT Text_string[629] +#define TXT_IGLASSES_ON Text_string[630] +#define TXT_PRESS_ESC_TO_ABORT Text_string[631] +#define TXT_SERIAL_FAILURE Text_string[632] +#define TXT_MESSAGE Text_string[633] +#define TXT_MACRO Text_string[634] +#define TXT_ERROR_SERIAL_LOCK Text_string[635] +#define TXT_ERROR_SERIAL_LOCK_2 Text_string[636] +#define TXT_NO_LUNACY Text_string[637] +#define TXT_LUNACY Text_string[638] +#define TXT_ROBOT_PAINTING_OFF Text_string[639] +#define TXT_ROBOT_PAINTING_ON Text_string[640] +#define TXT_START_TCP_NET_GAME Text_string[641] +#define TXT_JOIN_TCP_NET_GAME Text_string[642] +#define TXT_AFTERBURNER Text_string[643] //hey: there's a lot of empty slots up from 173-192, where //the commandline help used to be. Add new things there -#define N_TEXT_STRINGS 649 +#define N_TEXT_STRINGS 649 // Constants for keyboard configuration -#define TNUM_REAR_VIEW (319+2+10) -#define TNUM_AUTOMAP (382+2+10) -#define TNUM_PITCH_FORWARD (386+2+10) -#define TNUM_PITCH_BACKWARD (387+2+10) -#define TNUM_TURN_LEFT (388+2+10) -#define TNUM_TURN_RIGHT (389+2+10) -#define TNUM_SLIDE_ON (390+2+10) -#define TNUM_SLIDE_LEFT (391+2+10) -#define TNUM_SLIDE_RIGHT (392+2+10) -#define TNUM_SLIDE_UP (393+2+10) -#define TNUM_SLIDE_DOWN (394+2+10) -#define TNUM_BANK_ON (395+2+10) -#define TNUM_BANK_LEFT (396+2+10) -#define TNUM_BANK_RIGHT (397+2+10) -#define TNUM_FIRE_PRIMARY (398+2+10) -#define TNUM_FIRE_SECONDARY (399+2+10) -#define TNUM_FIRE_FLARE (400+2+10) -#define TNUM_ACCELERATE (401+2+10) -#define TNUM_REVERSE (402+2+10) -#define TNUM_DROP_BOMB (403+2+10) -#define TNUM_CRUISE_FASTER (404+2+10) -#define TNUM_CRUISE_SLOWER (405+2+10) -#define TNUM_CRUISE_OFF (406+2+10) -#define TNUM_PITCH_UD (407+2+10) -#define TNUM_TURN_LR (408+2+10) -#define TNUM_SLIDE_LR (409+2+10) -#define TNUM_SLIDE_UD (410+2+10) -#define TNUM_BANK_LR (411+2+10) -#define TNUM_THROTTLE (412+2+10) -#define TNUM_AFTERBURNER 643 +#define TNUM_REAR_VIEW (319+2+10) +#define TNUM_AUTOMAP (382+2+10) +#define TNUM_PITCH_FORWARD (386+2+10) +#define TNUM_PITCH_BACKWARD (387+2+10) +#define TNUM_TURN_LEFT (388+2+10) +#define TNUM_TURN_RIGHT (389+2+10) +#define TNUM_SLIDE_ON (390+2+10) +#define TNUM_SLIDE_LEFT (391+2+10) +#define TNUM_SLIDE_RIGHT (392+2+10) +#define TNUM_SLIDE_UP (393+2+10) +#define TNUM_SLIDE_DOWN (394+2+10) +#define TNUM_BANK_ON (395+2+10) +#define TNUM_BANK_LEFT (396+2+10) +#define TNUM_BANK_RIGHT (397+2+10) +#define TNUM_FIRE_PRIMARY (398+2+10) +#define TNUM_FIRE_SECONDARY (399+2+10) +#define TNUM_FIRE_FLARE (400+2+10) +#define TNUM_ACCELERATE (401+2+10) +#define TNUM_REVERSE (402+2+10) +#define TNUM_DROP_BOMB (403+2+10) +#define TNUM_CRUISE_FASTER (404+2+10) +#define TNUM_CRUISE_SLOWER (405+2+10) +#define TNUM_CRUISE_OFF (406+2+10) +#define TNUM_PITCH_UD (407+2+10) +#define TNUM_TURN_LR (408+2+10) +#define TNUM_SLIDE_LR (409+2+10) +#define TNUM_SLIDE_UD (410+2+10) +#define TNUM_BANK_LR (411+2+10) +#define TNUM_THROTTLE (412+2+10) +#define TNUM_AFTERBURNER 643 + +#define TNUM_N (455+2+10) +#define TNUM_Y (456+2+10) +#define TNUM_BTN_1 (472+2+10) +#define TNUM_BTN_2 (473+2+10) +#define TNUM_BTN_3 (474+2+10) +#define TNUM_BTN_4 (475+2+10) +#define TNUM_TRIG (476+2+10) +#define TNUM_HAT_L (477+2+10) +#define TNUM_HAT_R (478+2+10) +#define TNUM_HAT_U (479+2+10) +#define TNUM_HAT_D (480+2+10) +#define TNUM_LEFT (481+2+10) +#define TNUM_RIGHT (482+2+10) +#define TNUM_MID (483+2+10) +#define TNUM_UP (484+2+10) +#define TNUM_DOWN (485+2+10) +#define TNUM_X1 (486+2+10) +#define TNUM_Y1 (487+2+10) +#define TNUM_X2 (488+2+10) +#define TNUM_Y2 (489+2+10) +#define TNUM_L_R (490+2+10) +#define TNUM_F_B (491+2+10) +#define TNUM_HAT2_L (517+10) +#define TNUM_HAT2_R (518+10) +#define TNUM_HAT2_U (519+10) +#define TNUM_HAT2_D (520+10) +#define TNUM_Z1 (644) +#define TNUM_UN (645) +#define TNUM_P1 (646) +#define TNUM_R1 (647) +#define TNUM_YA1 (648) + -#define TNUM_N (455+2+10) -#define TNUM_Y (456+2+10) -#define TNUM_BTN_1 (472+2+10) -#define TNUM_BTN_2 (473+2+10) -#define TNUM_BTN_3 (474+2+10) -#define TNUM_BTN_4 (475+2+10) -#define TNUM_TRIG (476+2+10) -#define TNUM_HAT_L (477+2+10) -#define TNUM_HAT_D (478+2+10) -#define TNUM_HAT_R (479+2+10) -#define TNUM_HAT_U (480+2+10) -#define TNUM_LEFT (481+2+10) -#define TNUM_RIGHT (482+2+10) -#define TNUM_MID (483+2+10) -#define TNUM_UP (484+2+10) -#define TNUM_DOWN (485+2+10) -#define TNUM_X1 (486+2+10) -#define TNUM_Y1 (487+2+10) -#define TNUM_X2 (488+2+10) -#define TNUM_Y2 (489+2+10) -#define TNUM_L_R (490+2+10) -#define TNUM_F_B (491+2+10) -#define TNUM_HAT2_L (517+10) -#define TNUM_HAT2_R (518+10) -#define TNUM_HAT2_U (519+10) -#define TNUM_HAT2_D (520+10) -#define TNUM_Z1 (644) -#define TNUM_UN (645) -#define TNUM_P1 (646) -#define TNUM_R1 (647) -#define TNUM_YA1 (648) // Weapon names. @@ -728,7 +729,7 @@ extern char *Text_string[]; #define PRIMARY_WEAPON_NAMES_SHORT(weapon_num) (*(&TXT_W_LASER_S + (weapon_num))) #define SECONDARY_WEAPON_NAMES_SHORT(weapon_num) (*(&TXT_W_C_MISSILE_S + (weapon_num))) -// Control configuration strings. +// Control configuration strings. #define CONTROL_TEXT(control_type) (*(&TXT_CONTROL_KEYBOARD + (control_type))) // Network connect states diff --git a/main/titles.c b/main/titles.c index d27eff7f..dca63d33 100644 --- a/main/titles.c +++ b/main/titles.c @@ -1,4 +1,3 @@ -/* $Id: titles.c,v 1.25 2003-05-12 22:45:10 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -16,6 +15,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #endif +#define ROBOT_MOVIES + #ifdef WINDOWS #include "desw.h" #endif @@ -55,13 +56,18 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "songs.h" #include "newmenu.h" #include "state.h" +#ifdef ROBOT_MOVIES #include "movie.h" +#endif #include "menu.h" #if defined(POLY_ACC) #include "poly_acc.h" #endif +#ifdef ROBOT_MOVIES +extern void RotateRobot(); +#endif void DoBriefingColorStuff (); int get_new_message_num(char **message); @@ -69,20 +75,18 @@ int DefineBriefingBox (char **buf); extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords +extern int MVEPaletteCalls; + ubyte New_pal[768]; int New_pal_254_bash; char CurBriefScreenName[15]="brief03.pcx"; char * Briefing_text; +#ifdef ROBOT_MOVIES char RobotPlaying=0; +#endif -//Begin D1X modification -#define MAX_BRIEFING_COLORS 7 -//End D1X modification - -// Descent 1 briefings -char Ending_text_filename[13] = "endreg.txt"; -char Briefing_text_filename[13] = "briefing.txt"; +#define MAX_BRIEFING_COLORS 3 #define SHAREWARE_ENDING_FILENAME "ending.tex" @@ -98,7 +102,7 @@ extern int check_button_press(); extern void macintosh_quit(void); #endif -// added by Jan Bobrowski for variable-size menu screen +#ifndef ROBOT_MOVIES static int rescale_x(int x) { return x * GWIDTH / 320; @@ -108,6 +112,7 @@ static int rescale_y(int y) { return y * GHEIGHT / 200; } +#endif #ifndef MACINTOSH int local_key_inkey(void) @@ -116,7 +121,7 @@ int local_key_inkey(void) #ifdef WINDOWS MSG msg; - + DoMessageStuff(&msg); #endif @@ -124,10 +129,12 @@ int local_key_inkey(void) if (rval == KEY_PRINT_SCREEN) { #ifdef POLY_ACC +#ifdef ROBOT_MOVIES if (RobotPlaying) { gr_palette_read(gr_palette); gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache } +#endif #endif save_screen_shot(0); return 0; //say no key pressed @@ -154,7 +161,7 @@ int local_key_inkey(void) if (event.what != keyDown) return 0; - + rval = (int)((event.message & keyCodeMask) >> 8); if (rval == KEY_PRINT_SCREEN) { @@ -206,17 +213,17 @@ int show_title_screen( char * filename, int allow_keys, int from_hog_only ) //vfx_set_palette_sub( New_pal ); #ifdef OGL - gr_palette_load( New_pal ); + gr_palette_load( New_pal ); #else - gr_palette_clear(); + gr_palette_clear(); #endif - WINDOS( + WINDOS( dd_gr_set_current_canvas(NULL), gr_set_current_canvas( NULL ) ); WIN(DDGRLOCK(dd_grd_curcanv)); - show_fullscr(&title_bm); + gr_bitmap( 0, 0, &title_bm ); WIN(DDGRUNLOCK(dd_grd_curcanv)); WIN(DDGRRESTORE); @@ -225,16 +232,16 @@ int show_title_screen( char * filename, int allow_keys, int from_hog_only ) pa_restore_clut(); #endif - if (gr_palette_fade_in( New_pal, 32, allow_keys )) + if (gr_palette_fade_in( New_pal, 32, allow_keys )) return 1; gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette)); gr_palette_load( New_pal ); timer = timer_get_fixed_seconds() + i2f(3); - while (1) { + while (1) { if ( local_key_inkey() && allow_keys ) break; if ( timer_get_fixed_seconds() > timer ) break; - } + } if (gr_palette_fade_out( New_pal, 32, allow_keys )) return 1; gr_copy_palette(gr_palette, palette_save, sizeof(palette_save)); @@ -243,18 +250,18 @@ int show_title_screen( char * filename, int allow_keys, int from_hog_only ) } typedef struct { - char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix. - byte level_num; - byte message_num; - short text_ulx, text_uly; // upper left x,y of text window - short text_width, text_height; // width and height of text window + char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix. + byte level_num; + byte message_num; + short text_ulx, text_uly; // upper left x,y of text window + short text_width, text_height; // width and height of text window } briefing_screen; -#define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list. -#define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens) +#define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list. +#define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens) -#define SHAREWARE_ENDING_LEVEL_NUM 0x7f -#define REGISTERED_ENDING_LEVEL_NUM 0x7e +#define SHAREWARE_ENDING_LEVEL_NUM 0x7f +#define REGISTERED_ENDING_LEVEL_NUM 0x7e #ifdef SHAREWARE #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM @@ -264,74 +271,8 @@ typedef struct { #define MAX_BRIEFING_SCREENS 60 -#if 0 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]= {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!! -#else -briefing_screen Briefing_screens[] = { - { "brief01.pcx", 0, 1, 13, 140, 290, 59 }, - { "brief02.pcx", 0, 2, 27, 34, 257, 177 }, - { "brief03.pcx", 0, 3, 20, 22, 257, 177 }, - { "brief02.pcx", 0, 4, 27, 34, 257, 177 }, - - { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1 - { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2 - { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3 - - { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4 - { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5 - - { "brief03.pcx", 6, 10, 20, 22, 257, 177 }, - { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6 - { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7 - -#ifndef SHAREWARE - { "brief03.pcx", 8, 13, 20, 22, 257, 177 }, - { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8 - { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9 - { "brief03.pcx", 10, 16, 20, 22, 257, 177 }, - { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10 - - { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11 - { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12 - { "brief03.pcx", 13, 20, 20, 22, 257, 177 }, - { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13 - { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14 - - { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15 - { "brief03.pcx", 16, 24, 20, 22, 257, 177 }, - { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16 - { "brief03.pcx", 17, 26, 20, 22, 257, 177 }, - { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17 - - { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18 - { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19 - { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20 - { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21 - - { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22 - { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23 - { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24 - - { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25 - { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26 - { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27 - - { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1 - { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2 - { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3 -#endif - - { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end -#ifndef SHAREWARE - { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end - { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end - { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end -#endif - -}; - -#endif int Briefing_text_x, Briefing_text_y; @@ -339,28 +280,28 @@ void init_char_pos(int x, int y) { Briefing_text_x = x; Briefing_text_y = y; - mprintf ((0,"Setting init x=%d y=%d\n",x,y)); + mprintf ((0,"Setting init x=%d y=%d\n",x,y)); } grs_canvas *Robot_canv = NULL; vms_angvec Robot_angles; -char Bitmap_name[32] = ""; -#define EXIT_DOOR_MAX 14 -#define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing. -#define DOOR_DIV_INIT 6 -byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0; +char Bitmap_name[32] = ""; +#define EXIT_DOOR_MAX 14 +#define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing. +#define DOOR_DIV_INIT 6 +byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0; -//----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- void show_bitmap_frame(void) { #ifdef WINDOWS dd_grs_canvas *curcanv_save, *bitmap_canv=0; #else - grs_canvas *curcanv_save, *bitmap_canv=0; + grs_canvas *curcanv_save, *bitmap_canv=0; #endif - grs_bitmap *bitmap_ptr; + grs_bitmap *bitmap_ptr; // Only plot every nth frame. if (Door_div_count) { @@ -384,19 +325,19 @@ void show_bitmap_frame(void) } switch (Animating_bitmap_type) { - case 0: WINDOS( - bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break, - bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break + case 0: + WINDOS( + bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break, + bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64); break ); - case 1: + case 1: WINDOS( - bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break, - bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break - ); - - // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size. - default: - Int3(); // Impossible, illegal value for Animating_bitmap_type + bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break, + bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94); break + ); + + // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size. + default: Int3(); // Impossible, illegal value for Animating_bitmap_type } WINDOS( @@ -415,21 +356,21 @@ void show_bitmap_frame(void) num = (dig1-'0')*10 + (dig2-'0'); switch (Animating_bitmap_type) { - case 0: - num += Door_dir; - if (num > EXIT_DOOR_MAX) { - num = EXIT_DOOR_MAX; - Door_dir = -1; - } else if (num < 0) { - num = 0; - Door_dir = 1; - } - break; - case 1: - num++; - if (num > OTHER_THING_MAX) - num = 0; - break; + case 0: + num += Door_dir; + if (num > EXIT_DOOR_MAX) { + num = EXIT_DOOR_MAX; + Door_dir = -1; + } else if (num < 0) { + num = 0; + Door_dir = 1; + } + break; + case 1: + num++; + if (num > OTHER_THING_MAX) + num = 0; + break; } Assert(num < 100); @@ -450,7 +391,7 @@ void show_bitmap_frame(void) } WIN(DDGRLOCK(dd_grd_curcanv)); - gr_bitmapm(0, 0, bitmap_ptr); + gr_bitmapm(0, 0, bitmap_ptr); WIN(DDGRUNLOCK(dd_grd_curcanv)); WINDOS( @@ -460,29 +401,29 @@ void show_bitmap_frame(void) d_free(bitmap_canv); switch (Animating_bitmap_type) { - case 0: - if (num == EXIT_DOOR_MAX) { - Door_dir = -1; - Door_div_count = 64; - } else if (num == 0) { - Door_dir = 1; - Door_div_count = 64; - } - break; - case 1: - break; + case 0: + if (num == EXIT_DOOR_MAX) { + Door_dir = -1; + Door_div_count = 64; + } else if (num == 0) { + Door_dir = 1; + Door_div_count = 64; + } + break; + case 1: + break; } } } -//----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- void show_briefing_bitmap(grs_bitmap *bmp) { #ifdef WINDOWS dd_grs_canvas *bitmap_canv, *curcanv_save; - - bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h); + + bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h); curcanv_save = dd_grd_curcanv; dd_gr_set_current_canvas(bitmap_canv); DDGRLOCK(dd_grd_curcanv); @@ -502,8 +443,8 @@ void show_briefing_bitmap(grs_bitmap *bmp) d_free(bitmap_canv); } -#ifndef WINDOWS -//----------------------------------------------------------------------------- +#ifndef ROBOT_MOVIES //WINDOWS +// ----------------------------------------------------------------------------- void show_spinning_robot_frame(int robot_num) { grs_canvas *curcanv_save; @@ -520,70 +461,76 @@ void show_spinning_robot_frame(int robot_num) } -//----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- void init_spinning_robot(void) //(int x,int y,int w,int h) -{ - //Robot_angles.p += 0; - //Robot_angles.b += 0; - //Robot_angles.h += 0; + { +#if 0 + Robot_angles.p += 0; + Robot_angles.b += 0; + Robot_angles.h += 0; +#else int x = rescale_x(138); int y = rescale_y(55); int w = rescale_x(166); int h = rescale_y(138); +#endif - Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h); - // 138, 55, 166, 138 -} + Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h); + // 138, 55, 166, 138 + } #endif -//--------------------------------------------------------------------------- -// Returns char width. -// If show_robot_flag set, then show a frame of the spinning robot. +// ----------------------------------------------------------------------------- +// Returns char width. +// If show_robot_flag set, then show a frame of the spinning robot. int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag) { - int w, h, aw; - char message[2]; + int w, h, aw; + char message[2]; static fix start_time=0; + robot_num=0; message[0] = the_char; message[1] = 0; - if (start_time==0 && timer_get_fixed_seconds()<0) - start_time=timer_get_fixed_seconds(); - + if (start_time==0 && timer_get_fixed_seconds()<0) + start_time=timer_get_fixed_seconds(); + gr_get_string_size(message, &w, &h, &aw ); Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS)); // Draw cursor if there is some delay and caller says to draw cursor if (cursor_flag && delay) { - WIN(DDGRLOCK(dd_grd_curcanv)); + WIN(DDGRLOCK(dd_grd_curcanv)); gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1); gr_printf(Briefing_text_x+1, Briefing_text_y, "_" ); - WIN(DDGRUNLOCK(dd_grd_curcanv)); - gr_update(); + WIN(DDGRUNLOCK(dd_grd_curcanv)); } - if (delay) - delay=fixdiv (F1_0,i2f(15)); - - if ((Bitmap_name[0] != 0) && (delay != 0)) - show_bitmap_frame(); + if (delay) + delay=fixdiv (F1_0,i2f(15)); - if (RobotPlaying && (delay != 0)) - RotateRobot(); + if (delay != 0) + show_bitmap_frame(); - while (timer_get_fixed_seconds() < (start_time + delay)) { - if (RobotPlaying && delay != 0) +#ifdef ROBOT_MOVIES + if (RobotPlaying && (delay != 0)) RotateRobot(); - } - if (robot_num != -1) - show_spinning_robot_frame(robot_num); - - start_time = timer_get_fixed_seconds(); + + + while (timer_get_fixed_seconds() < (start_time + delay)) { + if (RobotPlaying && delay != 0) + RotateRobot(); + } +#else + if (robot_num != -1) + show_spinning_robot_frame(robot_num); +#endif + start_time = timer_get_fixed_seconds(); - WIN(DDGRLOCK(dd_grd_curcanv)); +WIN(DDGRLOCK(dd_grd_curcanv)); // Erase cursor if (cursor_flag && delay) { gr_set_fontcolor(Erase_color, -1); @@ -596,9 +543,7 @@ int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag) gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1); gr_printf(Briefing_text_x+1, Briefing_text_y, message ); - WIN(DDGRUNLOCK(dd_grd_curcanv)); - - if (delay) gr_update(); +WIN(DDGRUNLOCK(dd_grd_curcanv)); // if (the_char != ' ') // if (!digi_is_sound_playing(SOUND_MARKER_HIT)) @@ -607,23 +552,17 @@ int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag) return w; } -//----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- int load_briefing_screen( int screen_num ) { int pcx_error; - char *fname; - - if (Mission_list[Current_mission_num].descent_version == 1) - fname = Briefing_screens[screen_num].bs_name; - else - fname = CurBriefScreenName; WIN(DDGRLOCK(dd_grd_curcanv)); - if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) { - printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error)); - printf( "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error), pcx_error); + if ((pcx_error=pcx_read_bitmap( CurBriefScreenName, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) { + printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error)); + printf( "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error); WIN(DDGRUNLOCK(dd_grd_curcanv)); - Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error); + Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error); } WIN(DDGRUNLOCK(dd_grd_curcanv)); @@ -634,32 +573,31 @@ int load_briefing_screen( int screen_num ) int load_new_briefing_screen( char *fname ) { - int pcx_error; + int pcx_error; - mprintf ((0,"Loading new briefing <%s>\n",fname)); - strcpy (CurBriefScreenName,fname); + mprintf ((0,"Loading new briefing %s!\n",fname)); + strcpy (CurBriefScreenName,fname); - //WIN(DEFINE_SCREEN(CurBriefScreenName)); +// WIN(DEFINE_SCREEN(CurBriefScreenName)); - if (gr_palette_fade_out( New_pal, 32, 0 )) + if (gr_palette_fade_out( New_pal, 32, 0 )) return 0; - WIN(DDGRLOCK(dd_grd_curcanv)); - if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) { - //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) { - printf( "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n",fname, pcx_errormsg(pcx_error), pcx_error); - WIN(DDGRUNLOCK(dd_grd_curcanv)); +WIN(DDGRLOCK(dd_grd_curcanv)); + if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) { + printf( "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n",fname, pcx_errormsg(pcx_error), pcx_error); + WIN(DDGRUNLOCK(dd_grd_curcanv)); Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error); } - WIN(DDGRUNLOCK(dd_grd_curcanv)); +WIN(DDGRUNLOCK(dd_grd_curcanv)); - WIN(DDGRRESTORE); +WIN(DDGRRESTORE); gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette)); - if (gr_palette_fade_in( New_pal, 32, 0 )) + if (gr_palette_fade_in( New_pal, 32, 0 )) return 0; - DoBriefingColorStuff(); + DoBriefingColorStuff(); return 1; } @@ -668,7 +606,7 @@ int load_new_briefing_screen( char *fname ) #define KEY_DELAY_DEFAULT ((F1_0*20)/1000) -//----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- int get_message_num(char **message) { int num=0; @@ -687,7 +625,7 @@ int get_message_num(char **message) return num; } -//----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- void get_message_name(char **message, char *result) { while (**message == ' ') @@ -706,7 +644,7 @@ void get_message_name(char **message, char *result) *result = 0; } -//----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- void flash_cursor(int cursor_flag) { if (cursor_flag == 0) @@ -720,19 +658,17 @@ WIN(DDGRLOCK(dd_grd_curcanv)); gr_printf(Briefing_text_x+1, Briefing_text_y, "_" ); WIN(DDGRUNLOCK(dd_grd_curcanv)); - gr_update(); } extern int InitMovieBriefing(); - -//----------------------------------------------------------------------------- -// Return true if message got aborted by user (pressed ESC), else return false. +// ----------------------------------------------------------------------------- +// Return true if message got aborted by user (pressed ESC), else return false. int show_briefing_message(int screen_num, char *message) { int prev_ch=-1; int ch, done=0,i; - briefing_screen *bsp; + briefing_screen *bsp = &Briefing_screens[screen_num]; int delay_count = KEY_DELAY_DEFAULT; int key_check; int robot_num=-1; @@ -740,63 +676,61 @@ int show_briefing_message(int screen_num, char *message) static int tab_stop=0; int flashing_cursor=0; int new_page=0,GotZ=0; - char spinRobotName[]="rba.mve",kludge; // matt don't change this! +#ifdef ROBOT_MOVIES + char *spinRobotName="rba.mve",kludge; // matt don't change this! +#endif char fname[15]; - char DumbAdjust=0; + char DumbAdjust=0; char chattering=0; int hum_channel=-1,printing_channel=-1; - int LineAdjustment=1; + int LineAdjustment=0; WIN(int wpage_done=0); Bitmap_name[0] = 0; Current_color = 0; +#ifdef ROBOT_MOVIES RobotPlaying=0; InitMovieBriefing(); +#endif #ifndef SHAREWARE hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 ); #endif - + // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y)); gr_set_curfont( GAME_FONT ); - if (Mission_list[Current_mission_num].descent_version == 1) { - GotZ = 1; - MALLOC(bsp, briefing_screen, 1); - memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen)); - bsp->text_ulx = rescale_x(bsp->text_ulx); - bsp->text_uly = rescale_y(bsp->text_uly); - bsp->text_width = rescale_x(bsp->text_width); - bsp->text_height = rescale_y(bsp->text_height); - init_char_pos(bsp->text_ulx, bsp->text_uly); - } else { - bsp=&Briefing_screens[0]; - init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires))); - } + bsp=&Briefing_screens[0]; + init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires))); while (!done) { ch = *message++; if (ch == '$') { ch = *message++; - if (ch=='D') { - screen_num=DefineBriefingBox (&message); + if (ch=='D') + { + screen_num=DefineBriefingBox (&message); //load_new_briefing_screen (Briefing_screens[screen_num].bs_name); - - bsp = &Briefing_screens[screen_num]; - init_char_pos(bsp->text_ulx, bsp->text_uly); + + bsp = &Briefing_screens[screen_num]; + init_char_pos(bsp->text_ulx, bsp->text_uly); LineAdjustment=0; - prev_ch = 10; // read to eoln - } else if (ch=='U') { - screen_num=get_message_num(&message); - bsp = &Briefing_screens[screen_num]; - init_char_pos(bsp->text_ulx, bsp->text_uly); - prev_ch = 10; // read to eoln - } else if (ch == 'C') { + prev_ch = 10; // read to eoln + } + else if (ch=='U') + { + screen_num=get_message_num(&message); + bsp = &Briefing_screens[screen_num]; + init_char_pos(bsp->text_ulx, bsp->text_uly); + prev_ch = 10; // read to eoln + } + + else if (ch == 'C') { Current_color = get_message_num(&message)-1; Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS)); prev_ch = 10; - } else if (ch == 'F') { // toggle flashing cursor + } else if (ch == 'F') { // toggle flashing cursor flashing_cursor = !flashing_cursor; prev_ch = 10; while (*message++ != 10) @@ -807,50 +741,43 @@ int show_briefing_message(int screen_num, char *message) prev_ch = 10; // read to eoln } else if (ch == 'R') { if (Robot_canv != NULL) { - d_free(Robot_canv); + d_free(Robot_canv); Robot_canv=NULL; } +#ifdef ROBOT_MOVIES if (RobotPlaying) { DeInitRobotMovie(); RobotPlaying=0; } + + kludge=*message++; + spinRobotName[2]=kludge; // ugly but proud - if (Mission_list[Current_mission_num].descent_version == 1) { - init_spinning_robot(); - robot_num = get_message_num(&message); - while (*message++ != 10) - ; - } else { - kludge=*message++; - spinRobotName[2]=kludge; // ugly but proud - - RobotPlaying=InitRobotMovie(spinRobotName); + RobotPlaying=InitRobotMovie(spinRobotName); - // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 ); + // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 ); - if (RobotPlaying) { - RotateRobot(); - DoBriefingColorStuff (); - mprintf ((0,"Robot playing is %d!!!",RobotPlaying)); - } + if (RobotPlaying) { + DoBriefingColorStuff (); + mprintf ((0,"Robot playing is %d!!!",RobotPlaying)); } - prev_ch = 10; // read to eoln +#else + init_spinning_robot(); + robot_num = get_message_num(&message); +#endif + prev_ch = 10; // read to eoln } else if (ch == 'N') { - //--grs_bitmap *bitmap_ptr; - if (Robot_canv != NULL) { - d_free(Robot_canv); - Robot_canv=NULL; - } + //--grs_bitmap *bitmap_ptr; + if (Robot_canv != NULL) + {d_free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, Bitmap_name); strcat(Bitmap_name, "#0"); Animating_bitmap_type = 0; prev_ch = 10; } else if (ch == 'O') { - if (Robot_canv != NULL) { - d_free(Robot_canv); - Robot_canv=NULL; - } + if (Robot_canv != NULL) + {d_free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, Bitmap_name); strcat(Bitmap_name, "#0"); @@ -859,60 +786,53 @@ int show_briefing_message(int screen_num, char *message) } else if (ch=='A') { LineAdjustment=1-LineAdjustment; } else if (ch=='Z') { - //mprintf ((0,"Got a Z!\n")); + mprintf ((0,"Got a Z!\n")); GotZ=1; -#if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE)) - DumbAdjust=1; -#else - if (LineAdjustment==1) + #if defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE)) DumbAdjust=1; - else - DumbAdjust=2; -#endif - + #else + if (LineAdjustment==1) + DumbAdjust=1; + else + DumbAdjust=2; + #endif + i=0; while ((fname[i]=*message) != '\n') { i++; message++; } fname[i]=0; - if (*message != 10) - while (*message++ != 10) // Get and drop eoln - ; - - { - char fname2[15]; - - i=0; - while (fname[i]!='.') { - fname2[i] = fname[i]; - i++; - } - fname2[i++]='b'; - fname2[i++]='.'; - fname2[i++]='p'; - fname2[i++]='c'; - fname2[i++]='x'; - fname2[i++]=0; - - if ((MenuHires && cfexist(fname2)) || !cfexist(fname)) - load_new_briefing_screen (fname2); - else - load_new_briefing_screen (fname); - } + + if (MenuHires) + { + i=0; + while (fname[i]!='.') + i++; +#ifndef SHAREWARE + fname[i++]='b'; +#endif + fname[i++]='.'; + fname[i++]='p'; + fname[i++]='c'; + fname[i++]='x'; + fname[i++]=0; + + load_new_briefing_screen (fname); + } + else + load_new_briefing_screen (fname); - //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx"); + //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx"); } else if (ch == 'B') { - char bitmap_name[32]; - grs_bitmap guy_bitmap; - ubyte temp_palette[768]; - int iff_error; + char bitmap_name[32]; + grs_bitmap guy_bitmap; + ubyte temp_palette[768]; + int iff_error; - if (Robot_canv != NULL) { - d_free(Robot_canv); - Robot_canv=NULL; - } + if (Robot_canv != NULL) + {d_free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, bitmap_name); strcat(bitmap_name, ".bbm"); @@ -924,58 +844,54 @@ int show_briefing_message(int screen_num, char *message) show_briefing_bitmap(&guy_bitmap); d_free(guy_bitmap.bm_data); prev_ch = 10; -// } else if (ch==EOF) { +// } else if (ch==EOF) { // done=1; // } else if (ch == 'B') { -// if (Robot_canv != NULL) { -// d_free(Robot_canv); -// Robot_canv=NULL; -// } +// if (Robot_canv != NULL) +// {d_free(Robot_canv); Robot_canv=NULL;} // // bitmap_num = get_message_num(&message); // if (bitmap_num != -1) // show_briefing_bitmap(Textures[bitmap_num]); -// prev_ch = 10; // read to eoln +// prev_ch = 10; // read to eoln } else if (ch == 'S') { - int keypress; - fix start_time; - + int keypress; + fix start_time; + chattering=0; if (printing_channel>-1) - digi_stop_sound( printing_channel ); + digi_stop_sound( printing_channel ); printing_channel=-1; -#ifdef WINDOWS + #ifdef WINDOWS if (!wpage_done) { DDGRRESTORE; wpage_done =1; } -#endif - - gr_update(); + #endif start_time = timer_get_fixed_seconds(); while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key -#ifdef WINDOWS + #ifdef WINDOWS if (_RedrawScreen) { _RedrawScreen = FALSE; hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 ); keypress = KEY_ESC; break; } -#endif + #endif while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; flash_cursor(flashing_cursor); - if (RobotPlaying) - RotateRobot (); - if (robot_num != -1) - show_spinning_robot_frame(robot_num); +#ifdef ROBOT_MOVIES + if (RobotPlaying) RotateRobot (); +#else + show_spinning_robot_frame(robot_num); +#endif - if (Bitmap_name[0] != 0) - show_bitmap_frame(); + show_bitmap_frame(); start_time += KEY_DELAY_DEFAULT/2; } @@ -990,19 +906,20 @@ int show_briefing_message(int screen_num, char *message) done = 1; WIN(wpage_done = 0); } else if (ch == 'P') { // New page. - if (!GotZ) { - Int3(); // Hey ryan!!!! You gotta load a screen before you start - // printing to it! You know, $Z !!! + if (!GotZ) + { + Int3(); // Hey ryan!!!! You gotta load a screen before you start + // printing to it! You know, $Z !!! load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx"); - } - + } + + new_page = 1; while (*message != 10) { message++; // drop carriage return after special escape sequence } message++; prev_ch = 10; - gr_update(); } } else if (ch == '\t') { // Tab if (Briefing_text_x - bsp->text_ulx < tab_stop) @@ -1033,19 +950,21 @@ int show_briefing_message(int screen_num, char *message) } } else { - if (!GotZ) { - Int3(); // Hey ryan!!!! You gotta load a screen before you start - // printing to it! You know, $Z !!! - load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx"); - } - + if (!GotZ) + { + Int3(); // Hey ryan!!!! You gotta load a screen before you start + // printing to it! You know, $Z !!! + load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx"); + } + prev_ch = ch; - if (!chattering) { + if (!chattering) + { printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 ); - chattering=1; - } - + chattering=1; + } + WIN(if (GRMODEINFO(emul)) delay_count = 0); Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor); @@ -1053,18 +972,15 @@ int show_briefing_message(int screen_num, char *message) } // Check for Esc -> abort. - if(delay_count) - key_check=local_key_inkey(); - else - key_check=0; + key_check = local_key_inkey(); -#ifdef WINDOWS + #ifdef WINDOWS if (_RedrawScreen) { _RedrawScreen = FALSE; hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 ); key_check = KEY_ESC; } -#endif + #endif if ( key_check == KEY_ESC ) { rval = 1; done = 1; @@ -1073,13 +989,6 @@ int show_briefing_message(int screen_num, char *message) if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER)) delay_count = 0; -#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE - if ((key_check == KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER) || - (key_check == KEY_ALTED+KEY_CTRLED+KEY_PADENTER) || - (key_check == KEY_ALTED+KEY_SHIFTED+KEY_PADENTER)) - gr_toggle_fullscreen(); -#endif - if (Briefing_text_x > bsp->text_ulx + bsp->text_width) { Briefing_text_x = bsp->text_ulx; Briefing_text_y += bsp->text_uly; @@ -1092,44 +1001,45 @@ int show_briefing_message(int screen_num, char *message) new_page = 0; if (printing_channel>-1) - digi_stop_sound( printing_channel ); + digi_stop_sound( printing_channel ); printing_channel=-1; - + chattering=0; -#ifdef WINDOWS - if (!wpage_done) { - DDGRRESTORE; - wpage_done =1; - } -#endif + #ifdef WINDOWS + if (!wpage_done) { + DDGRRESTORE; + wpage_done =1; + } + #endif start_time = timer_get_fixed_seconds(); while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key -#ifdef WINDOWS + #ifdef WINDOWS if (_RedrawScreen) { _RedrawScreen = FALSE; hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 ); keypress = KEY_ESC; break; } -#endif + #endif while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; flash_cursor(flashing_cursor); - if (RobotPlaying) - RotateRobot(); - if (robot_num != -1) - show_spinning_robot_frame(robot_num); - if (Bitmap_name[0] != 0) - show_bitmap_frame(); +#ifdef ROBOT_MOVIES + if (RobotPlaying) RotateRobot(); +#else + show_spinning_robot_frame(robot_num); +#endif + show_bitmap_frame(); start_time += KEY_DELAY_DEFAULT/2; } - if (RobotPlaying) - DeInitRobotMovie(); +#ifdef ROBOT_MOVIES + if (RobotPlaying) DeInitRobotMovie(); RobotPlaying=0; +#endif robot_num = -1; #ifndef NDEBUG @@ -1144,16 +1054,18 @@ int show_briefing_message(int screen_num, char *message) load_briefing_screen(screen_num); Briefing_text_x = bsp->text_ulx; Briefing_text_y = bsp->text_uly; - delay_count = KEY_DELAY_DEFAULT; + delay_count = KEY_DELAY_DEFAULT; WIN(wpage_done = 0); } } +#ifdef ROBOT_MOVIES if (RobotPlaying) { DeInitRobotMovie(); RobotPlaying=0; } +#endif if (Robot_canv != NULL) {d_free(Robot_canv); Robot_canv=NULL;} @@ -1161,19 +1073,16 @@ int show_briefing_message(int screen_num, char *message) if (hum_channel>-1) digi_stop_sound( hum_channel ); if (printing_channel>-1) - digi_stop_sound( printing_channel ); - - if (Mission_list[Current_mission_num].descent_version == 1) - d_free(bsp); + digi_stop_sound( printing_channel ); return rval; } -//----------------------------------------------------------------------------- -// Return a pointer to the start of text for screen #screen_num. +// ----------------------------------------------------------------------------- +// Return a pointer to the start of text for screen #screen_num. char * get_briefing_message(int screen_num) { - char *tptr = Briefing_text; + char *tptr = Briefing_text; int cur_screen=0; int ch; @@ -1188,17 +1097,17 @@ char * get_briefing_message(int screen_num) } } - if (screen_num!=cur_screen) - return (NULL); - + if (screen_num!=cur_screen) + return (NULL); + return tptr; } -//----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // Load Descent briefing text. int load_screen_text(char *filename, char **buf) { - CFILE *tfile; + CFILE *tfile; CFILE *ifile; int len, i,x; int have_binary = 0; @@ -1207,40 +1116,43 @@ int load_screen_text(char *filename, char **buf) char nfilename[30], *ptr; strcpy(nfilename, filename); - if ((ptr = strrchr(nfilename, '.'))) - *ptr = '\0'; + ptr = strrchr(nfilename, '.'); + *ptr = '\0'; strcat(nfilename, ".txb"); - if ((ifile = cfopen(nfilename, "rb")) == NULL) { + if ((ifile = cfopen(nfilename, "rb")) == NULL) + { mprintf ((0,"can't open %s!\n",nfilename)); - return (0); - //Error("Cannot open file %s or %s", filename, nfilename); - } - + return (0); + //Error("Cannot open file %s or %s", filename, nfilename); + } + mprintf ((0,"reading...\n")); have_binary = 1; len = cfilelength(ifile); - MALLOC(*buf, char, len+500); - mprintf ((0,"len=%d\n",len)); - for (x=0, i=0; i < len; i++, x++) { - cfread (*buf+x,1,1,ifile); - // mprintf ((0,"%c",*(*buf+x))); - if (*(*buf+x)==13) - x--; - } - + MALLOC(*buf, char, len+500); + mprintf ((0,"len=%d\n",len)); + for (x=0,i=0;i\n",filename)); + mprintf ((0,"Trying briefing screen! %s\n",filename)); if (!filename) return; if (!load_screen_text(filename, &Briefing_text)) - return; + return; #ifdef SHAREWARE songs_play_song( SONG_BRIEFING, 1 ); @@ -1442,33 +1299,17 @@ void do_briefing_screens(char *filename,int level_num) #endif set_screen_mode( SCREEN_MENU ); - + WINDOS( dd_gr_set_current_canvas(NULL), gr_set_current_canvas(NULL) ); - mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num)); + mprintf ((0,"Playing briefing screen! %s %d\n",filename,level_num)); key_flush(); - - if (Mission_list[Current_mission_num].descent_version == 1) { - if (level_num == 1) { - while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) { - abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0); - cur_briefing_screen++; - } - } - - if (!abort_briefing_screens) { - for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++) - if (Briefing_screens[cur_briefing_screen].level_num == level_num) - if (show_briefing_screen(cur_briefing_screen, 0)) - break; - } - - } else - show_briefing_screen(level_num,0); + + show_briefing_screen(level_num,0); d_free (Briefing_text); key_flush(); @@ -1478,36 +1319,40 @@ void do_briefing_screens(char *filename,int level_num) } int DefineBriefingBox (char **buf) -{ - int n,i=0; - char name[20]; + { + int n,i=0; + char name[20]; - n=get_new_message_num (buf); + n=get_new_message_num (buf); Assert(n < MAX_BRIEFING_SCREENS); - while (**buf!=' ') { - name[i++]=**buf; - (*buf)++; + while (**buf!=' ') + { + name[i++]=**buf; + (*buf)++; + } + + name[i]='\0'; // slap a delimiter on this guy + + strcpy (Briefing_screens[n].bs_name,name); + Briefing_screens[n].level_num=get_new_message_num (buf); + Briefing_screens[n].message_num=get_new_message_num (buf); + Briefing_screens[n].text_ulx=get_new_message_num (buf); + Briefing_screens[n].text_uly=get_new_message_num (buf); + Briefing_screens[n].text_width=get_new_message_num (buf); + Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!! + + if (MenuHires) + { + Briefing_screens[n].text_ulx*=2; + Briefing_screens[n].text_uly*=2.4; + Briefing_screens[n].text_width*=2; + Briefing_screens[n].text_height*=2.4; } - - name[i]='\0'; // slap a delimiter on this guy - - strcpy (Briefing_screens[n].bs_name,name); - Briefing_screens[n].level_num=get_new_message_num (buf); - Briefing_screens[n].message_num=get_new_message_num (buf); - Briefing_screens[n].text_ulx=get_new_message_num (buf); - Briefing_screens[n].text_uly=get_new_message_num (buf); - Briefing_screens[n].text_width=get_new_message_num (buf); - Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!! - - Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx); - Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly); - Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width); - Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height); - - return (n); -} + + return (n); + } int get_new_message_num(char **message) { diff --git a/main/titles.h b/main/titles.h index 23e65cd6..de842f68 100644 --- a/main/titles.h +++ b/main/titles.h @@ -1,4 +1,3 @@ -/* $Id: titles.h,v 1.2 2002-08-27 04:15:38 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,60 +7,11 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -/* - * - * . - * - * Old Log: - * Revision 2.0 1995/02/27 11:27:40 john - * New version 2.0, which has no anonymous unions, builds with - * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * - * Revision 1.12 1995/02/02 12:23:29 john - * Made between level saves have picture. - * - * Revision 1.11 1995/01/21 16:27:11 matt - * Made endlevel briefing work with missions - * - * Revision 1.10 1995/01/20 22:48:02 matt - * Mission system implemented, though imcompletely - * - * Revision 1.9 1994/12/07 19:14:07 matt - * Kill briefing screen disable switch for release version - * - * Revision 1.8 1994/11/21 16:40:24 matt - * Added prototype - * - * Revision 1.7 1994/11/05 14:05:54 john - * Fixed fade transitions between all screens by making gr_palette_fade_in and out keep - * track of whether the palette is faded in or not. Then, wherever the code needs to fade out, - * it just calls gr_palette_fade_out and it will fade out if it isn't already. The same with fade_in. - * This eliminates the need for all the flags like Menu_fade_out, game_fade_in palette, etc. - * - * Revision 1.6 1994/11/01 17:57:48 mike - * Briefing screens. - * - * Revision 1.5 1994/10/31 22:28:04 mike - * briefing screens - * - * Revision 1.4 1994/09/16 16:14:31 john - * Added acrade sequencing. - * - * Revision 1.3 1994/06/22 00:26:53 matt - * Added support for Interplay's animating title sequence - * - * Revision 1.2 1994/06/17 12:13:36 john - * More newdemo stuff; made editor->game transition start in slew mode. - * - * Revision 1.1 1994/06/17 10:50:12 john - * Initial revision - * - * - */ + #ifndef _TITLES_H #define _TITLES_H @@ -72,10 +22,6 @@ extern int Skip_briefing_screens; #define Skip_briefing_screens 0 #endif -// Descent 1 briefings -extern char Briefing_text_filename[13]; -extern char Ending_text_filename[13]; - extern int show_title_screen( char * filename, int allow_keys, int from_hog_only ); extern int show_briefing_screen( char * filename, int allow_keys ); extern void show_title_flick(char *name, int allow_keys ); diff --git a/main/vclip.c b/main/vclip.c index ae728d2f..2e96b691 100644 --- a/main/vclip.c +++ b/main/vclip.c @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: vclip.c,v 1.4 2002-08-02 04:57:19 btb Exp $"; +static char rcsid[] = "$Id: vclip.c,v 1.2 2001-01-31 15:17:59 bradleyb Exp $"; #endif #include @@ -101,24 +101,3 @@ void draw_weapon_vclip(object *obj) } -#ifndef FAST_FILE_IO -/* - * reads n vclip structs from a CFILE - */ -int vclip_read_n(vclip *vc, int n, CFILE *fp) -{ - int i, j; - - for (i = 0; i < n; i++) { - vc[i].play_time = cfile_read_fix(fp); - vc[i].num_frames = cfile_read_int(fp); - vc[i].frame_time = cfile_read_fix(fp); - vc[i].flags = cfile_read_int(fp); - vc[i].sound_num = cfile_read_short(fp); - for (j = 0; j < VCLIP_MAX_FRAMES; j++) - vc[i].frames[j].index = cfile_read_short(fp); - vc[i].light_value = cfile_read_fix(fp); - } - return i; -} -#endif diff --git a/main/vclip.h b/main/vclip.h index 01fa19c6..871f1021 100644 --- a/main/vclip.h +++ b/main/vclip.h @@ -7,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,32 +17,31 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gr.h" #include "object.h" #include "piggy.h" -#include "cfile.h" -#define VCLIP_SMALL_EXPLOSION 2 -#define VCLIP_PLAYER_HIT 1 -#define VCLIP_MORPHING_ROBOT 10 -#define VCLIP_PLAYER_APPEARANCE 61 -#define VCLIP_POWERUP_DISAPPEARANCE 62 -#define VCLIP_VOLATILE_WALL_HIT 5 -#define VCLIP_WATER_HIT 84 -#define VCLIP_AFTERBURNER_BLOB 95 -#define VCLIP_MONITOR_STATIC 99 +#define VCLIP_SMALL_EXPLOSION 2 +#define VCLIP_PLAYER_HIT 1 +#define VCLIP_MORPHING_ROBOT 10 +#define VCLIP_PLAYER_APPEARANCE 61 +#define VCLIP_POWERUP_DISAPPEARANCE 62 +#define VCLIP_VOLATILE_WALL_HIT 5 +#define VCLIP_WATER_HIT 84 +#define VCLIP_AFTERBURNER_BLOB 95 +#define VCLIP_MONITOR_STATIC 99 -#define VCLIP_MAXNUM 110 -#define VCLIP_MAX_FRAMES 30 +#define VCLIP_MAXNUM 110 +#define VCLIP_MAX_FRAMES 30 //vclip flags -#define VF_ROD 1 //draw as a rod, not a blob +#define VF_ROD 1 //draw as a rod, not a blob typedef struct { - fix play_time; //total time (in seconds) of clip - int num_frames; - fix frame_time; //time (in seconds) of each frame - int flags; - short sound_num; - bitmap_index frames[VCLIP_MAX_FRAMES]; - fix light_value; + fix play_time; //total time (in seconds) of clip + int num_frames; + fix frame_time; //time (in seconds) of each frame + int flags; + short sound_num; + bitmap_index frames[VCLIP_MAX_FRAMES]; + fix light_value; } __pack__ vclip; extern int Num_vclips; @@ -52,13 +51,4 @@ extern vclip Vclip[VCLIP_MAXNUM]; void draw_vclip_object(object *obj,fix timeleft,int lighted, int vclip_num); extern void draw_weapon_vclip(object *obj); -#ifdef FAST_FILE_IO -#define vclip_read_n(vc, n, fp) cfread(vc, sizeof(vclip), n, fp) -#else -/* - * reads n vclip structs from a CFILE - */ -extern int vclip_read_n(vclip *vc, int n, CFILE *fp); -#endif - #endif diff --git a/main/vers_id.h b/main/vers_id.h index 500d6e04..be410049 100644 --- a/main/vers_id.h +++ b/main/vers_id.h @@ -1,9 +1,8 @@ // -// Auto-generated include file [used to be] +// Auto-generated include file // Generated by MAKE from INFERNO.INI settings // #define VERSION_TYPE "Full Version" #define DESCENT_VERSION "D2X " VERSION -#define D2X_IVER (D2XMAJOR*10000+D2XMINOR*100+D2XMICRO) diff --git a/main/wall.c b/main/wall.c index a3221c80..c83dac63 100644 --- a/main/wall.c +++ b/main/wall.c @@ -1,4 +1,3 @@ -/* $Id: wall.c,v 1.9 2003-04-03 07:12:46 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: wall.c,v 1.9 2003-04-03 07:12:46 btb Exp $"; +static char rcsid[] = "$Id: wall.c,v 1.4 2001-10-25 02:15:57 bradleyb Exp $"; #endif #include @@ -103,7 +102,7 @@ void kill_stuck_objects(int wallnum); // 1 = YES // 0 = NO int check_transparency( segment * seg, int side ) -{ +{ if ( (seg->sides[side].tmap_num2 & 0x3FFF) == 0) { if (GameBitmaps[Textures[seg->sides[side].tmap_num].index].bm_flags & BM_FLAG_TRANSPARENT ) return 1; @@ -1123,13 +1122,9 @@ int wall_hit_process(segment *seg, int side, fix damage, int playernum, object * // Opens doors/destroys wall/shuts off triggers. void wall_toggle(segment *seg, int side) { - int wall_num; + int wall_num; - if (seg - Segments > Highest_segment_index) - { - Warning("Can't toggle side %d of segment %d - nonexistent segment!\n", side, seg-Segments); - return; - } + Assert( seg-Segments <= Highest_segment_index); Assert( side < MAX_SIDES_PER_SEGMENT ); wall_num = seg->sides[side].wall_num; @@ -1549,124 +1544,3 @@ void blast_nearby_glass(object *objp, fix damage) } -#define MAX_CLIP_FRAMES_D1 20 - -/* - * reads a wclip structure from a CFILE - */ -int wclip_read_n_d1(wclip *wc, int n, CFILE *fp) -{ - int i, j; - - for (i = 0; i < n; i++) { - wc[i].play_time = cfile_read_fix(fp); - wc[i].num_frames = cfile_read_short(fp); - for (j = 0; j < MAX_CLIP_FRAMES_D1; j++) - wc[i].frames[j] = cfile_read_short(fp); - wc[i].open_sound = cfile_read_short(fp); - wc[i].close_sound = cfile_read_short(fp); - wc[i].flags = cfile_read_short(fp); - cfread(wc[i].filename, 13, 1, fp); - wc[i].pad = cfile_read_byte(fp); - } - return i; -} - -#ifndef FAST_FILE_IO -/* - * reads a wclip structure from a CFILE - */ -int wclip_read_n(wclip *wc, int n, CFILE *fp) -{ - int i, j; - - for (i = 0; i < n; i++) { - wc[i].play_time = cfile_read_fix(fp); - wc[i].num_frames = cfile_read_short(fp); - for (j = 0; j < MAX_CLIP_FRAMES; j++) - wc[i].frames[j] = cfile_read_short(fp); - wc[i].open_sound = cfile_read_short(fp); - wc[i].close_sound = cfile_read_short(fp); - wc[i].flags = cfile_read_short(fp); - cfread(wc[i].filename, 13, 1, fp); - wc[i].pad = cfile_read_byte(fp); - } - return i; -} - -/* - * reads a v16_wall structure from a CFILE - */ -extern void v16_wall_read(v16_wall *w, CFILE *fp) -{ - w->type = cfile_read_byte(fp); - w->flags = cfile_read_byte(fp); - w->hps = cfile_read_fix(fp); - w->trigger = cfile_read_byte(fp); - w->clip_num = cfile_read_byte(fp); - w->keys = cfile_read_byte(fp); -} - -/* - * reads a v19_wall structure from a CFILE - */ -extern void v19_wall_read(v19_wall *w, CFILE *fp) -{ - w->segnum = cfile_read_int(fp); - w->sidenum = cfile_read_int(fp); - w->type = cfile_read_byte(fp); - w->flags = cfile_read_byte(fp); - w->hps = cfile_read_fix(fp); - w->trigger = cfile_read_byte(fp); - w->clip_num = cfile_read_byte(fp); - w->keys = cfile_read_byte(fp); - w->linked_wall = cfile_read_int(fp); -} - -/* - * reads a wall structure from a CFILE - */ -extern void wall_read(wall *w, CFILE *fp) -{ - w->segnum = cfile_read_int(fp); - w->sidenum = cfile_read_int(fp); - w->hps = cfile_read_fix(fp); - w->linked_wall = cfile_read_int(fp); - w->type = cfile_read_byte(fp); - w->flags = cfile_read_byte(fp); - w->state = cfile_read_byte(fp); - w->trigger = cfile_read_byte(fp); - w->clip_num = cfile_read_byte(fp); - w->keys = cfile_read_byte(fp); - w->controlling_trigger = cfile_read_byte(fp); - w->cloak_value = cfile_read_byte(fp); -} - -/* - * reads a v19_door structure from a CFILE - */ -extern void v19_door_read(v19_door *d, CFILE *fp) -{ - d->n_parts = cfile_read_int(fp); - d->seg[0] = cfile_read_short(fp); - d->seg[1] = cfile_read_short(fp); - d->side[0] = cfile_read_short(fp); - d->side[1] = cfile_read_short(fp); - d->type[0] = cfile_read_short(fp); - d->type[1] = cfile_read_short(fp); - d->open = cfile_read_fix(fp); -} - -/* - * reads an active_door structure from a CFILE - */ -extern void active_door_read(active_door *ad, CFILE *fp) -{ - ad->n_parts = cfile_read_int(fp); - ad->front_wallnum[0] = cfile_read_short(fp); - ad->front_wallnum[1] = cfile_read_short(fp); - ad->back_wallnum[0] = cfile_read_short(fp); - ad->back_wallnum[1] = cfile_read_short(fp); - ad->time = cfile_read_fix(fp); -} -#endif diff --git a/main/wall.h b/main/wall.h index 987706a4..33a70629 100644 --- a/main/wall.h +++ b/main/wall.h @@ -1,4 +1,3 @@ -/* $Id: */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -18,171 +17,138 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "inferno.h" #include "segment.h" #include "object.h" -#include "cfile.h" //#include "vclip.h" -#define MAX_WALLS 254 // Maximum number of walls -#define MAX_WALL_ANIMS 60 // Maximum different types of doors -#define MAX_DOORS 90 // Maximum number of open doors +#define MAX_WALLS 254 // Maximum number of walls +#define MAX_WALL_ANIMS 60 // Maximum different types of doors +#define MAX_DOORS 90 // Maximum number of open doors // Various wall types. -#define WALL_NORMAL 0 // Normal wall -#define WALL_BLASTABLE 1 // Removable (by shooting) wall -#define WALL_DOOR 2 // Door -#define WALL_ILLUSION 3 // Wall that appears to be there, but you can fly thru -#define WALL_OPEN 4 // Just an open side. (Trigger) -#define WALL_CLOSED 5 // Wall. Used for transparent walls. -#define WALL_OVERLAY 6 // Goes over an actual solid side. For triggers -#define WALL_CLOAKED 7 // Can see it, and see through it +#define WALL_NORMAL 0 // Normal wall +#define WALL_BLASTABLE 1 // Removable (by shooting) wall +#define WALL_DOOR 2 // Door +#define WALL_ILLUSION 3 // Wall that appears to be there, but you can fly thru +#define WALL_OPEN 4 // Just an open side. (Trigger) +#define WALL_CLOSED 5 // Wall. Used for transparent walls. +#define WALL_OVERLAY 6 // Goes over an actual solid side. For triggers +#define WALL_CLOAKED 7 // Can see it, and see through it // Various wall flags. -#define WALL_BLASTED 1 // Blasted out wall. -#define WALL_DOOR_OPENED 2 // Open door. -#define WALL_DOOR_LOCKED 8 // Door is locked. -#define WALL_DOOR_AUTO 16 // Door automatically closes after time. -#define WALL_ILLUSION_OFF 32 // Illusionary wall is shut off. -#define WALL_WALL_SWITCH 64 // This wall is openable by a wall switch. -#define WALL_BUDDY_PROOF 128 // Buddy assumes he cannot get through this wall. +#define WALL_BLASTED 1 // Blasted out wall. +#define WALL_DOOR_OPENED 2 // Open door. +#define WALL_DOOR_LOCKED 8 // Door is locked. +#define WALL_DOOR_AUTO 16 // Door automatically closes after time. +#define WALL_ILLUSION_OFF 32 // Illusionary wall is shut off. +#define WALL_WALL_SWITCH 64 // This wall is openable by a wall switch. +#define WALL_BUDDY_PROOF 128 // Buddy assumes he cannot get through this wall. // Wall states -#define WALL_DOOR_CLOSED 0 // Door is closed -#define WALL_DOOR_OPENING 1 // Door is opening. -#define WALL_DOOR_WAITING 2 // Waiting to close -#define WALL_DOOR_CLOSING 3 // Door is closing -#define WALL_DOOR_OPEN 4 // Door is open, and staying open -#define WALL_DOOR_CLOAKING 5 // Wall is going from closed -> open -#define WALL_DOOR_DECLOAKING 6 // Wall is going from open -> closed - -//note: a door is considered opened (i.e., it has WALL_OPENED set) when it -//is more than half way open. Thus, it can have any of OPENING, CLOSING, +#define WALL_DOOR_CLOSED 0 // Door is closed +#define WALL_DOOR_OPENING 1 // Door is opening. +#define WALL_DOOR_WAITING 2 // Waiting to close +#define WALL_DOOR_CLOSING 3 // Door is closing +#define WALL_DOOR_OPEN 4 // Door is open, and staying open +#define WALL_DOOR_CLOAKING 5 // Wall is going from closed -> open +#define WALL_DOOR_DECLOAKING 6 // Wall is going from open -> closed + +//note: a door is considered opened (i.e., it has WALL_OPENED set) when it +//is more than half way open. Thus, it can have any of OPENING, CLOSING, //or WAITING bits set when OPENED is set. -#define KEY_NONE 1 -#define KEY_BLUE 2 -#define KEY_RED 4 -#define KEY_GOLD 8 +#define KEY_NONE 1 +#define KEY_BLUE 2 +#define KEY_RED 4 +#define KEY_GOLD 8 -#define WALL_HPS 100*F1_0 // Normal wall's hp -#define WALL_DOOR_INTERVAL 5*F1_0 // How many seconds a door is open +#define WALL_HPS 100*F1_0 // Normal wall's hp +#define WALL_DOOR_INTERVAL 5*F1_0 // How many seconds a door is open -#define DOOR_OPEN_TIME i2f(2) // How long takes to open -#define DOOR_WAIT_TIME i2f(5) // How long before auto door closes +#define DOOR_OPEN_TIME i2f(2) // How long takes to open +#define DOOR_WAIT_TIME i2f(5) // How long before auto door closes -#define MAX_CLIP_FRAMES 50 +#define MAX_CLIP_FRAMES 50 // WALL_IS_DOORWAY flags. -#define WID_FLY_FLAG 1 -#define WID_RENDER_FLAG 2 -#define WID_RENDPAST_FLAG 4 -#define WID_EXTERNAL_FLAG 8 -#define WID_CLOAKED_FLAG 16 - -//@@// WALL_IS_DOORWAY return values F/R/RP -//@@#define WID_WALL 2 // 0/1/0 wall -//@@#define WID_TRANSPARENT_WALL 6 // 0/1/1 transparent wall -//@@#define WID_ILLUSORY_WALL 3 // 1/1/0 illusory wall -//@@#define WID_TRANSILLUSORY_WALL 7 // 1/1/1 transparent illusory wall -//@@#define WID_NO_WALL 5 // 1/0/1 no wall, can fly through -//@@#define WID_EXTERNAL 8 // 0/0/0/1 don't see it, dont fly through it - -#define MAX_STUCK_OBJECTS 32 +#define WID_FLY_FLAG 1 +#define WID_RENDER_FLAG 2 +#define WID_RENDPAST_FLAG 4 +#define WID_EXTERNAL_FLAG 8 +#define WID_CLOAKED_FLAG 16 + +//@@// WALL_IS_DOORWAY return values F/R/RP +//@@#define WID_WALL 2 // 0/1/0 wall +//@@#define WID_TRANSPARENT_WALL 6 // 0/1/1 transparent wall +//@@#define WID_ILLUSORY_WALL 3 // 1/1/0 illusory wall +//@@#define WID_TRANSILLUSORY_WALL 7 // 1/1/1 transparent illusory wall +//@@#define WID_NO_WALL 5 // 1/0/1 no wall, can fly through +//@@#define WID_EXTERNAL 8 // 0/0/0/1 don't see it, dont fly through it + +#define MAX_STUCK_OBJECTS 32 typedef struct stuckobj { - short objnum, wallnum; - int signature; + short objnum, wallnum; + int signature; } stuckobj; -//Start old wall structures - -typedef struct v16_wall { - byte type; // What kind of special wall. - byte flags; // Flags for the wall. - fix hps; // "Hit points" of the wall. - byte trigger; // Which trigger is associated with the wall. - byte clip_num; // Which animation associated with the wall. - byte keys; -} __pack__ v16_wall; - -typedef struct v19_wall { - int segnum,sidenum; // Seg & side for this wall - byte type; // What kind of special wall. - byte flags; // Flags for the wall. - fix hps; // "Hit points" of the wall. - byte trigger; // Which trigger is associated with the wall. - byte clip_num; // Which animation associated with the wall. - byte keys; - int linked_wall; // number of linked wall -} __pack__ v19_wall; - -typedef struct v19_door { - int n_parts; // for linked walls - short seg[2]; // Segment pointer of door. - short side[2]; // Side number of door. - short type[2]; // What kind of door animation. - fix open; // How long it has been open. -} __pack__ v19_door; - -//End old wall structures - typedef struct wall { - int segnum,sidenum; // Seg & side for this wall - fix hps; // "Hit points" of the wall. - int linked_wall; // number of linked wall - ubyte type; // What kind of special wall. - ubyte flags; // Flags for the wall. - ubyte state; // Opening, closing, etc. - byte trigger; // Which trigger is associated with the wall. - byte clip_num; // Which animation associated with the wall. - ubyte keys; // which keys are required - byte controlling_trigger;// which trigger causes something to happen here. Not like "trigger" above, which is the trigger on this wall. - // Note: This gets stuffed at load time in gamemine.c. Don't try to use it in the editor. You will be sorry! - byte cloak_value; // if this wall is cloaked, the fade value -} __pack__ wall; + int segnum,sidenum; // Seg & side for this wall + fix hps; // "Hit points" of the wall. + int linked_wall; // number of linked wall + ubyte type; // What kind of special wall. + ubyte flags; // Flags for the wall. + ubyte state; // Opening, closing, etc. + byte trigger; // Which trigger is associated with the wall. + byte clip_num; // Which animation associated with the wall. + ubyte keys; // which keys are required + byte controlling_trigger; // which trigger causes something to happen here. Not like "trigger" above, which is the trigger on this wall. + // Note: This gets stuffed at load time in gamemine.c. Don't try to use it in the editor. You will be sorry! + byte cloak_value; // if this wall is cloaked, the fade value + } __pack__ wall; typedef struct active_door { - int n_parts; // for linked walls - short front_wallnum[2]; // front wall numbers for this door - short back_wallnum[2]; // back wall numbers for this door - fix time; // how long been opening, closing, waiting + int n_parts; // for linked walls + short front_wallnum[2]; // front wall numbers for this door + short back_wallnum[2]; // back wall numbers for this door + fix time; // how long been opening, closing, waiting } __pack__ active_door; typedef struct cloaking_wall { - short front_wallnum; // front wall numbers for this door - short back_wallnum; // back wall numbers for this door - fix front_ls[4]; // front wall saved light values - fix back_ls[4]; // back wall saved light values - fix time; // how long been cloaking or decloaking + short front_wallnum; // front wall numbers for this door + short back_wallnum; // back wall numbers for this door + fix front_ls[4]; // front wall saved light values + fix back_ls[4]; // back wall saved light values + fix time; // how long been cloaking or decloaking } __pack__ cloaking_wall; //wall clip flags -#define WCF_EXPLODES 1 //door explodes when opening -#define WCF_BLASTABLE 2 //this is a blastable wall -#define WCF_TMAP1 4 //this uses primary tmap, not tmap2 -#define WCF_HIDDEN 8 //this uses primary tmap, not tmap2 +#define WCF_EXPLODES 1 //door explodes when opening +#define WCF_BLASTABLE 2 //this is a blastable wall +#define WCF_TMAP1 4 //this uses primary tmap, not tmap2 +#define WCF_HIDDEN 8 //this uses primary tmap, not tmap2 typedef struct { - fix play_time; - short num_frames; - short frames[MAX_CLIP_FRAMES]; - short open_sound; - short close_sound; - short flags; - char filename[13]; - char pad; + fix play_time; + short num_frames; + short frames[MAX_CLIP_FRAMES]; + short open_sound; + short close_sound; + short flags; + char filename[13]; + char pad; } __pack__ wclip; -extern char Wall_names[7][10]; +extern char Wall_names[7][10]; //#define WALL_IS_DOORWAY(seg,side) wall_is_doorway(seg, side) #define WALL_IS_DOORWAY(seg,side) (((seg)->children[(side)] == -1) ? WID_RENDER_FLAG : ((seg)->children[(side)] == -2) ? WID_EXTERNAL_FLAG : ((seg)->sides[(side)].wall_num == -1) ? (WID_FLY_FLAG|WID_RENDPAST_FLAG) : wall_is_doorway((seg), (side))) -extern wall Walls[MAX_WALLS]; // Master walls array -extern int Num_walls; // Number of walls +extern wall Walls[MAX_WALLS]; // Master walls array +extern int Num_walls; // Number of walls -extern active_door ActiveDoors[MAX_DOORS]; // Master doors array -extern int Num_open_doors; // Number of open doors +extern active_door ActiveDoors[MAX_DOORS]; // Master doors array +extern int Num_open_doors; // Number of open doors extern cloaking_wall CloakingWalls[]; extern int Num_cloaking_walls; @@ -194,11 +160,11 @@ extern int walls_bm_num[MAX_WALL_ANIMS]; // Initializes all walls (i.e. no special walls.) extern void wall_init(); - + // Automatically checks if a there is a doorway (i.e. can fly through) extern int wall_is_doorway ( segment *seg, int side ); -// Deteriorate appearance of wall. (Changes bitmap (paste-ons)) +// Deteriorate appearance of wall. (Changes bitmap (paste-ons)) extern void wall_damage(segment *seg, int side, fix damage); // Destroys a blastable wall. (So it is an opening afterwards) @@ -214,17 +180,17 @@ void do_door_open(int door_num); // Closes a door, including animation and other processing. void do_door_close(int door_num); -// Opens a door +// Opens a door extern void wall_open_door(segment *seg, int side); -// Closes a door +// Closes a door extern void wall_close_door(segment *seg, int side); //return codes for wall_hit_process() -#define WHP_NOT_SPECIAL 0 //wasn't a quote-wall-unquote -#define WHP_NO_KEY 1 //hit door, but didn't have key -#define WHP_BLASTABLE 2 //hit blastable wall -#define WHP_DOOR 3 //a door (which will now be opening) +#define WHP_NOT_SPECIAL 0 //wasn't a quote-wall-unquote +#define WHP_NO_KEY 1 //hit door, but didn't have key +#define WHP_BLASTABLE 2 //hit blastable wall +#define WHP_DOOR 3 //a door (which will now be opening) // Determines what happens when a wall is shot //obj is the object that hit...either a weapon or the player himself @@ -239,10 +205,10 @@ extern void reset_walls(); // Called once per frame.. void wall_frame_process(); -extern stuckobj Stuck_objects[MAX_STUCK_OBJECTS]; +extern stuckobj Stuck_objects[MAX_STUCK_OBJECTS]; -// An object got stuck in a door (like a flare). -// Add global entry. +// An object got stuck in a door (like a flare). +// Add global entry. extern void add_stuck_object(object *objp, int segnum, int sidenum); extern void remove_obsolete_stuck_objects(void); @@ -256,44 +222,4 @@ void kill_stuck_objects(int wallnum); void start_wall_cloak(segment *seg, int side); void start_wall_decloak(segment *seg, int side); -extern int wclip_read_n_d1(wclip *wc, int n, CFILE *fp); -#ifdef FAST_FILE_IO -#define wclip_read_n(wc, n, fp) cfread(wc, sizeof(wclip), n, fp) -#define v16_wall_read(w, fp) cfread(w, sizeof(v16_wall), 1, fp) -#define v19_wall_read(w, fp) cfread(w, sizeof(v19_wall), 1, fp) -#define wall_read(w, fp) cfread(w, sizeof(wall), 1, fp) -#define v19_door_read(d, fp) cfread(d, sizeof(v19_door), 1, fp) -#define active_door_read(d, fp) cfread(d, sizeof(active_door), 1, fp) -#else -/* - * reads n wclip structs from a CFILE - */ -extern int wclip_read_n(wclip *wc, int n, CFILE *fp); - -/* - * reads a v16_wall structure from a CFILE - */ -extern void v16_wall_read(v16_wall *w, CFILE *fp); - -/* - * reads a v19_wall structure from a CFILE - */ -extern void v19_wall_read(v19_wall *w, CFILE *fp); - -/* - * reads a wall structure from a CFILE - */ -extern void wall_read(wall *w, CFILE *fp); - -/* - * reads a v19_door structure from a CFILE - */ -extern void v19_door_read(v19_door *d, CFILE *fp); - -/* - * reads an active_door structure from a CFILE - */ -extern void active_door_read(active_door *ad, CFILE *fp); -#endif - #endif diff --git a/main/weapon.c b/main/weapon.c index adbdbd57..ee5e7892 100644 --- a/main/weapon.c +++ b/main/weapon.c @@ -1,4 +1,3 @@ -/* $Id: weapon.c,v 1.6 2002-08-06 05:21:33 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: weapon.c,v 1.6 2002-08-06 05:21:33 btb Exp $"; +static char rcsid[] = "$Id: weapon.c,v 1.2 2001-01-31 15:17:59 bradleyb Exp $"; #endif #include @@ -1300,76 +1299,3 @@ void tactile_set_button_jolt () } #endif } - -/* - * reads n weapon_info structs from a CFILE - */ -extern int weapon_info_read_n(weapon_info *wi, int n, CFILE *fp, int file_version) -{ - int i, j; - - for (i = 0; i < n; i++) { - wi[i].render_type = cfile_read_byte(fp); - wi[i].persistent = cfile_read_byte(fp); - wi[i].model_num = cfile_read_short(fp); - wi[i].model_num_inner = cfile_read_short(fp); - - wi[i].flash_vclip = cfile_read_byte(fp); - wi[i].robot_hit_vclip = cfile_read_byte(fp); - wi[i].flash_sound = cfile_read_short(fp); - - wi[i].wall_hit_vclip = cfile_read_byte(fp); - wi[i].fire_count = cfile_read_byte(fp); - wi[i].robot_hit_sound = cfile_read_short(fp); - - wi[i].ammo_usage = cfile_read_byte(fp); - wi[i].weapon_vclip = cfile_read_byte(fp); - wi[i].wall_hit_sound = cfile_read_short(fp); - - wi[i].destroyable = cfile_read_byte(fp); - wi[i].matter = cfile_read_byte(fp); - wi[i].bounce = cfile_read_byte(fp); - wi[i].homing_flag = cfile_read_byte(fp); - - wi[i].speedvar = cfile_read_byte(fp); - wi[i].flags = cfile_read_byte(fp); - wi[i].flash = cfile_read_byte(fp); - wi[i].afterburner_size = cfile_read_byte(fp); - - if (file_version >= 3) - wi[i].children = cfile_read_byte(fp); - else - wi[i].children = -1; - - wi[i].energy_usage = cfile_read_fix(fp); - wi[i].fire_wait = cfile_read_fix(fp); - - if (file_version >= 3) - wi[i].multi_damage_scale = cfile_read_fix(fp); - else - wi[i].multi_damage_scale = F1_0; - - bitmap_index_read(&wi[i].bitmap, fp); - - wi[i].blob_size = cfile_read_fix(fp); - wi[i].flash_size = cfile_read_fix(fp); - wi[i].impact_size = cfile_read_fix(fp); - for (j = 0; j < NDL; j++) - wi[i].strength[j] = cfile_read_fix(fp); - for (j = 0; j < NDL; j++) - wi[i].speed[j] = cfile_read_fix(fp); - wi[i].mass = cfile_read_fix(fp); - wi[i].drag = cfile_read_fix(fp); - wi[i].thrust = cfile_read_fix(fp); - wi[i].po_len_to_width_ratio = cfile_read_fix(fp); - wi[i].light = cfile_read_fix(fp); - wi[i].lifetime = cfile_read_fix(fp); - wi[i].damage_radius = cfile_read_fix(fp); - bitmap_index_read(&wi[i].picture, fp); - if (file_version >= 3) - bitmap_index_read(&wi[i].hires_picture, fp); - else - wi[i].hires_picture.index = wi[i].picture.index; - } - return i; -} diff --git a/main/weapon.h b/main/weapon.h index a68024ee..0573dc90 100644 --- a/main/weapon.h +++ b/main/weapon.h @@ -1,4 +1,3 @@ -/* $Id: weapon.h,v 1.4 2002-08-02 04:57:19 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -19,196 +18,146 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gr.h" #include "game.h" #include "piggy.h" -#include "cfile.h" //weapon info flags -#define WIF_PLACABLE 1 //can be placed by level designer - -typedef struct v2_weapon_info { - byte render_type; // How to draw 0=laser, 1=blob, 2=object - byte persistent; // 0 = dies when it hits something, 1 = continues (eg, fusion cannon) - short model_num; // Model num if rendertype==2. - short model_num_inner; // Model num of inner part if rendertype==2. - - byte flash_vclip; // What vclip to use for muzzle flash - byte robot_hit_vclip; // What vclip for impact with robot - short flash_sound; // What sound to play when fired - - byte wall_hit_vclip; // What vclip for impact with wall - byte fire_count; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. - short robot_hit_sound; // What sound for impact with robot - - byte ammo_usage; // How many units of ammunition it uses. - byte weapon_vclip; // Vclip to render for the weapon, itself. - short wall_hit_sound; // What sound for impact with wall - - byte destroyable; // If !0, this weapon can be destroyed by another weapon. - byte matter; // Flag: set if this object is matter (as opposed to energy) - byte bounce; // 1==always bounces, 2=bounces twice - byte homing_flag; // Set if this weapon can home in on a target. - - ubyte speedvar; // allowed variance in speed below average, /128: 64 = 50% meaning if speed = 100, can be 50..100 - - ubyte flags; // see values above - - byte flash; // Flash effect - byte afterburner_size; // Size of blobs in F1_0/16 units, specify in bitmaps.tbl as floating point. Player afterburner size = 2.5. - - fix energy_usage; // How much fuel is consumed to fire this weapon. - fix fire_wait; // Time until this weapon can be fired again. - - bitmap_index bitmap; // Pointer to bitmap if rendertype==0 or 1. - - fix blob_size; // Size of blob if blob type - fix flash_size; // How big to draw the flash - fix impact_size; // How big of an impact - fix strength[NDL]; // How much damage it can inflict - fix speed[NDL]; // How fast it can move, difficulty level based. - fix mass; // How much mass it has - fix drag; // How much drag it has - fix thrust; // How much thrust it has - fix po_len_to_width_ratio; // For polyobjects, the ratio of len/width. (10 maybe?) - fix light; // Amount of light this weapon casts. - fix lifetime; // Lifetime in seconds of this weapon. - fix damage_radius; // Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit -//-- unused-- fix damage_force; // Force of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit -// damage_force was a real mess. Wasn't Difficulty_level based, and was being applied instead of weapon's actual strength. Now use 2*strength instead. --MK, 01/19/95 - bitmap_index picture; // a picture of the weapon for the cockpit -} v2_weapon_info; +#define WIF_PLACABLE 1 //can be placed by level designer typedef struct weapon_info { - byte render_type; // How to draw 0=laser, 1=blob, 2=object - byte persistent; // 0 = dies when it hits something, 1 = continues (eg, fusion cannon) - short model_num; // Model num if rendertype==2. - short model_num_inner; // Model num of inner part if rendertype==2. - - byte flash_vclip; // What vclip to use for muzzle flash - byte robot_hit_vclip; // What vclip for impact with robot - short flash_sound; // What sound to play when fired - - byte wall_hit_vclip; // What vclip for impact with wall - byte fire_count; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. - short robot_hit_sound; // What sound for impact with robot - - byte ammo_usage; // How many units of ammunition it uses. - byte weapon_vclip; // Vclip to render for the weapon, itself. - short wall_hit_sound; // What sound for impact with wall - - byte destroyable; // If !0, this weapon can be destroyed by another weapon. - byte matter; // Flag: set if this object is matter (as opposed to energy) - byte bounce; // 1==always bounces, 2=bounces twice - byte homing_flag; // Set if this weapon can home in on a target. - - ubyte speedvar; // allowed variance in speed below average, /128: 64 = 50% meaning if speed = 100, can be 50..100 - - ubyte flags; // see values above - - byte flash; // Flash effect - byte afterburner_size; // Size of blobs in F1_0/16 units, specify in bitmaps.tbl as floating point. Player afterburner size = 2.5. - - /* not present in shareware datafiles */ - byte children; // ID of weapon to drop if this contains children. -1 means no children. - - fix energy_usage; // How much fuel is consumed to fire this weapon. - fix fire_wait; // Time until this weapon can be fired again. - - /* not present in shareware datafiles */ - fix multi_damage_scale; // Scale damage by this amount when applying to player in multiplayer. F1_0 means no change. - - bitmap_index bitmap; // Pointer to bitmap if rendertype==0 or 1. - - fix blob_size; // Size of blob if blob type - fix flash_size; // How big to draw the flash - fix impact_size; // How big of an impact - fix strength[NDL]; // How much damage it can inflict - fix speed[NDL]; // How fast it can move, difficulty level based. - fix mass; // How much mass it has - fix drag; // How much drag it has - fix thrust; // How much thrust it has - fix po_len_to_width_ratio; // For polyobjects, the ratio of len/width. (10 maybe?) - fix light; // Amount of light this weapon casts. - fix lifetime; // Lifetime in seconds of this weapon. - fix damage_radius; // Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit -//-- unused-- fix damage_force; // Force of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit + byte render_type; // How to draw 0=laser, 1=blob, 2=object + byte persistent; // 0 = dies when it hits something, 1 = continues (eg, fusion cannon) + short model_num; // Model num if rendertype==2. + short model_num_inner; // Model num of inner part if rendertype==2. + + byte flash_vclip; // What vclip to use for muzzle flash + byte robot_hit_vclip; // What vclip for impact with robot + short flash_sound; // What sound to play when fired + + byte wall_hit_vclip; // What vclip for impact with wall + byte fire_count; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. + short robot_hit_sound; // What sound for impact with robot + + byte ammo_usage; // How many units of ammunition it uses. + byte weapon_vclip; // Vclip to render for the weapon, itself. + short wall_hit_sound; // What sound for impact with wall + + byte destroyable; // If !0, this weapon can be destroyed by another weapon. + byte matter; // Flag: set if this object is matter (as opposed to energy) + byte bounce; // 1==always bounces, 2=bounces twice + byte homing_flag; // Set if this weapon can home in on a target. + + ubyte speedvar; // allowed variance in speed below average, /128: 64 = 50% meaning if speed = 100, can be 50..100 + + ubyte flags; // see values above + + byte flash; // Flash effect + byte afterburner_size; // Size of blobs in F1_0/16 units, specify in bitmaps.tbl as floating point. Player afterburner size = 2.5. + +#ifndef SHAREWARE + byte children; // ID of weapon to drop if this contains children. -1 means no children. +#endif + + fix energy_usage; // How much fuel is consumed to fire this weapon. + fix fire_wait; // Time until this weapon can be fired again. + +#ifndef SHAREWARE + fix multi_damage_scale; // Scale damage by this amount when applying to player in multiplayer. F1_0 means no change. +#endif + + bitmap_index bitmap; // Pointer to bitmap if rendertype==0 or 1. + + fix blob_size; // Size of blob if blob type + fix flash_size; // How big to draw the flash + fix impact_size; // How big of an impact + fix strength[NDL]; // How much damage it can inflict + fix speed[NDL]; // How fast it can move, difficulty level based. + fix mass; // How much mass it has + fix drag; // How much drag it has + fix thrust; // How much thrust it has + fix po_len_to_width_ratio; // For polyobjects, the ratio of len/width. (10 maybe?) + fix light; // Amount of light this weapon casts. + fix lifetime; // Lifetime in seconds of this weapon. + fix damage_radius; // Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit +//-- unused-- fix damage_force; // Force of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit // damage_force was a real mess. Wasn't Difficulty_level based, and was being applied instead of weapon's actual strength. Now use 2*strength instead. --MK, 01/19/95 - bitmap_index picture; // a picture of the weapon for the cockpit - /* not present in shareware datafiles */ - bitmap_index hires_picture; // a hires picture of the above + bitmap_index picture; // a picture of the weapon for the cockpit +#ifndef SHAREWARE + bitmap_index hires_picture; // a hires picture of the above +#endif } __pack__ weapon_info; -#define REARM_TIME (F1_0) +#define REARM_TIME (F1_0) -#define WEAPON_DEFAULT_LIFETIME (F1_0*12) // Lifetime of an object if a bozo forgets to define it. +#define WEAPON_DEFAULT_LIFETIME (F1_0*12) // Lifetime of an object if a bozo forgets to define it. -#define WEAPON_TYPE_WEAK_LASER 0 -#define WEAPON_TYPE_STRONG_LASER 1 -#define WEAPON_TYPE_CANNON_BALL 2 -#define WEAPON_TYPE_MISSILE 3 +#define WEAPON_TYPE_WEAK_LASER 0 +#define WEAPON_TYPE_STRONG_LASER 1 +#define WEAPON_TYPE_CANNON_BALL 2 +#define WEAPON_TYPE_MISSILE 3 -#define MAX_WEAPON_TYPES 70 +#define MAX_WEAPON_TYPES 70 -#define WEAPON_RENDER_NONE -1 -#define WEAPON_RENDER_LASER 0 -#define WEAPON_RENDER_BLOB 1 -#define WEAPON_RENDER_POLYMODEL 2 -#define WEAPON_RENDER_VCLIP 3 +#define WEAPON_RENDER_NONE -1 +#define WEAPON_RENDER_LASER 0 +#define WEAPON_RENDER_BLOB 1 +#define WEAPON_RENDER_POLYMODEL 2 +#define WEAPON_RENDER_VCLIP 3 -#define MAX_PRIMARY_WEAPONS 10 -#define MAX_SECONDARY_WEAPONS 10 +#define MAX_PRIMARY_WEAPONS 10 +#define MAX_SECONDARY_WEAPONS 10 //given a weapon index, return the flag value #define HAS_FLAG(index) (1<<(index)) -// Weapon flags, if player->weapon_flags & WEAPON_FLAG is set, then the player has this weapon -#define HAS_LASER_FLAG HAS_FLAG(LASER_INDEX) -#define HAS_VULCAN_FLAG HAS_FLAG(VULCAN_INDEX) -#define HAS_SPREADFIRE_FLAG HAS_FLAG(SPREADFIRE_INDEX) -#define HAS_PLASMA_FLAG HAS_FLAG(PLASMA_INDEX) -#define HAS_FUSION_FLAG HAS_FLAG(FUSION_INDEX) - -#define HAS_CONCUSSION_FLAG HAS_FLAG(CONCUSSION_INDEX) -#define HAS_HOMING_FLAG HAS_FLAG(HOMING_INDEX) -#define HAS_PROXIMITY_FLAG HAS_FLAG(PROXIMITY_INDEX) -#define HAS_SMART_FLAG HAS_FLAG(SMART_INDEX) -#define HAS_MEGA_FLAG HAS_FLAG(MEGA_INDEX) - -#define CLASS_PRIMARY 0 -#define CLASS_SECONDARY 1 - -#define LASER_INDEX 0 -#define VULCAN_INDEX 1 -#define SPREADFIRE_INDEX 2 -#define PLASMA_INDEX 3 -#define FUSION_INDEX 4 -#define SUPER_LASER_INDEX 5 -#define GAUSS_INDEX 6 -#define HELIX_INDEX 7 -#define PHOENIX_INDEX 8 -#define OMEGA_INDEX 9 - -#define CONCUSSION_INDEX 0 -#define HOMING_INDEX 1 -#define PROXIMITY_INDEX 2 -#define SMART_INDEX 3 -#define MEGA_INDEX 4 -#define SMISSILE1_INDEX 5 -#define GUIDED_INDEX 6 -#define SMART_MINE_INDEX 7 -#define SMISSILE4_INDEX 8 -#define SMISSILE5_INDEX 9 - -#define SUPER_WEAPON 5 - -#define VULCAN_AMMO_SCALE 0xcc163 //(0x198300/2) //multiply ammo by this before displaying - -#define NUM_SMART_CHILDREN 6 // Number of smart children created by default. +// Weapon flags, if player->weapon_flags & WEAPON_FLAG is set, then the player has this weapon +#define HAS_LASER_FLAG HAS_FLAG(LASER_INDEX) +#define HAS_VULCAN_FLAG HAS_FLAG(VULCAN_INDEX) +#define HAS_SPREADFIRE_FLAG HAS_FLAG(SPREADFIRE_INDEX) +#define HAS_PLASMA_FLAG HAS_FLAG(PLASMA_INDEX) +#define HAS_FUSION_FLAG HAS_FLAG(FUSION_INDEX) + +#define HAS_CONCUSSION_FLAG HAS_FLAG(CONCUSSION_INDEX) +#define HAS_HOMING_FLAG HAS_FLAG(HOMING_INDEX) +#define HAS_PROXIMITY_FLAG HAS_FLAG(PROXIMITY_INDEX) +#define HAS_SMART_FLAG HAS_FLAG(SMART_INDEX) +#define HAS_MEGA_FLAG HAS_FLAG(MEGA_INDEX) + +#define CLASS_PRIMARY 0 +#define CLASS_SECONDARY 1 + +#define LASER_INDEX 0 +#define VULCAN_INDEX 1 +#define SPREADFIRE_INDEX 2 +#define PLASMA_INDEX 3 +#define FUSION_INDEX 4 +#define SUPER_LASER_INDEX 5 +#define GAUSS_INDEX 6 +#define HELIX_INDEX 7 +#define PHOENIX_INDEX 8 +#define OMEGA_INDEX 9 + +#define CONCUSSION_INDEX 0 +#define HOMING_INDEX 1 +#define PROXIMITY_INDEX 2 +#define SMART_INDEX 3 +#define MEGA_INDEX 4 +#define SMISSILE1_INDEX 5 +#define GUIDED_INDEX 6 +#define SMART_MINE_INDEX 7 +#define SMISSILE4_INDEX 8 +#define SMISSILE5_INDEX 9 + +#define SUPER_WEAPON 5 + +#define VULCAN_AMMO_SCALE 0xcc163 //(0x198300/2) //multiply ammo by this before displaying + +#define NUM_SMART_CHILDREN 6 // Number of smart children created by default. extern weapon_info Weapon_info[]; extern int N_weapon_types; extern void do_weapon_select(int weapon_num, int secondary_flag); extern void show_weapon_status(void); -extern byte Primary_weapon, Secondary_weapon; +extern byte Primary_weapon, Secondary_weapon; extern ubyte Primary_weapon_to_weapon_info[MAX_PRIMARY_WEAPONS]; extern ubyte Secondary_weapon_to_weapon_info[MAX_SECONDARY_WEAPONS]; @@ -226,29 +175,29 @@ extern ubyte Secondary_weapon_to_powerup[MAX_SECONDARY_WEAPONS]; extern ubyte Primary_last_was_super[MAX_PRIMARY_WEAPONS]; extern ubyte Secondary_last_was_super[MAX_SECONDARY_WEAPONS]; -extern void auto_select_weapon(int weapon_type); //parm is primary or secondary +extern void auto_select_weapon(int weapon_type); //parm is primary or secondary extern void select_weapon(int weapon_num, int secondary_flag, int print_message,int wait_for_rearm); -extern char *Primary_weapon_names_short[]; -extern char *Secondary_weapon_names_short[]; -extern char *Primary_weapon_names[]; -extern char *Secondary_weapon_names[]; -extern int Primary_ammo_max[MAX_PRIMARY_WEAPONS]; -extern ubyte Secondary_ammo_max[MAX_SECONDARY_WEAPONS]; -extern byte Weapon_is_energy[MAX_WEAPON_TYPES]; - -#define HAS_WEAPON_FLAG 1 -#define HAS_ENERGY_FLAG 2 -#define HAS_AMMO_FLAG 4 +extern char *Primary_weapon_names_short[]; +extern char *Secondary_weapon_names_short[]; +extern char *Primary_weapon_names[]; +extern char *Secondary_weapon_names[]; +extern int Primary_ammo_max[MAX_PRIMARY_WEAPONS]; +extern ubyte Secondary_ammo_max[MAX_SECONDARY_WEAPONS]; +extern byte Weapon_is_energy[MAX_WEAPON_TYPES]; + +#define HAS_WEAPON_FLAG 1 +#define HAS_ENERGY_FLAG 2 +#define HAS_AMMO_FLAG 4 #define HAS_ALL (HAS_WEAPON_FLAG|HAS_ENERGY_FLAG|HAS_AMMO_FLAG) -//----------------------------------------------------------------------------- -// Return: +// ------------------------------------------------------------------------------------ +// Return: // Bits set: -// HAS_WEAPON_FLAG -// HAS_ENERGY_FLAG -// HAS_AMMO_FLAG -// HAS_SUPER_FLAG +// HAS_WEAPON_FLAG +// HAS_ENERGY_FLAG +// HAS_AMMO_FLAG +// HAS_SUPER_FLAG extern int player_has_weapon(int weapon_num, int secondary_flag); //called when one of these weapons is picked up @@ -267,16 +216,11 @@ extern int attempt_to_steal_item(object *objp, int player_num); //this function is for when the player intentionally drops a powerup extern int spit_powerup(object *spitter, int id, int seed); -#define SMEGA_ID 40 +#define SMEGA_ID 40 extern void rock_the_mine_frame(void); extern void smega_rock_stuff(void); extern void init_smega_detonates(void); extern void tactile_set_button_jolt (void); -/* - * reads n weapon_info structs from a CFILE - */ -extern int weapon_info_read_n(weapon_info *wi, int n, CFILE *fp, int file_version); - #endif diff --git a/maths/.cvsignore b/maths/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/maths/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/maths/Makefile.am b/maths/Makefile.am index b6a2a207..d2530d25 100644 --- a/maths/Makefile.am +++ b/maths/Makefile.am @@ -1,5 +1,5 @@ noinst_LIBRARIES = libmaths.a -INCLUDES = -I $(top_srcdir)/include +INCLUDES = -I $(top_srcdir)/includes if USE_ASM libmaths_a_SOURCES = vecmat.c rand.c tables.c diff --git a/maths/fix.asm b/maths/fix.asm index 6eca69b1..77cb1c7b 100644 --- a/maths/fix.asm +++ b/maths/fix.asm @@ -1,4 +1,3 @@ -; $Id: fix.asm,v 1.3 2003-02-18 20:23:22 btb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -7,7 +6,7 @@ ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE ;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. [BITS 32] diff --git a/maths/fixc.c b/maths/fixc.c index c121fcf6..9ebcad73 100644 --- a/maths/fixc.c +++ b/maths/fixc.c @@ -1,4 +1,3 @@ -/* $Id: fixc.c,v 1.5 2002-10-28 20:12:48 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,15 +7,34 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * + * $Source: /cvs/cvsroot/d2x/maths/fixc.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $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 + * + * Revision 1.3 1999/10/18 00:31:01 donut + * more alpha fixes from Falk Hueffner + * + * Revision 1.2 1999/08/05 22:53:41 sekmu + * + * D3D patch(es) from ADB + * + * Revision 1.1.1.1 1999/06/14 22:13:35 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.7 1995/09/22 14:08:16 allender * fixed fix_atan2 to work correctly with doubles * @@ -42,8 +60,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. * --- PC RCS Info --- * Revision 1.1 1995/03/08 18:55:09 matt * Initial revision - * - * + * + * */ #ifdef HAVE_CONFIG_H @@ -51,7 +69,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: fixc.c,v 1.5 2002-10-28 20:12:48 btb Exp $"; +static char rcsid[] = "$Id: fixc.c,v 1.3 2001-10-31 07:41:54 bradleyb Exp $"; #endif #include @@ -75,14 +93,14 @@ extern ushort acos_table[]; extern fix isqrt_guess_table[]; //negate a quad -void fixquadnegate(quadint *q) +void fixquadnegate(quad *q) { q->low = 0 - q->low; q->high = 0 - q->high - (q->low != 0); } //multiply two ints & add 64-bit result to 64-bit sum -void fixmulaccum(quadint *q,fix a,fix b) +void fixmulaccum(quad *q,fix a,fix b) { u_int32_t aa,bb; u_int32_t ah,al,bh,bl; @@ -117,7 +135,7 @@ void fixmulaccum(quadint *q,fix a,fix b) } //extract a fix from a quad product -fix fixquadadjust(quadint *q) +fix fixquadadjust(quad *q) { return (q->high<<16) + (q->low>>16); } @@ -201,7 +219,7 @@ fixang fix_atan2(fix cos,fix sin) } #ifdef NO_FIX_INLINE -//divide a quadint by a fix, returning a fix +//divide a quad by a fix, returning a fix int32_t fixdivquadlong(u_int32_t nl,u_int32_t nh,u_int32_t d) { int i; @@ -300,23 +318,11 @@ int32_t fixdivquadlong(u_int32_t nl,u_int32_t nh,u_int32_t d) return r; } -#if 0 -// this version caused inf loop with: -// quad_sqrt(0x27eb7121/*low=669741345*/, -// 0x4cd40ad8/*high=1288964824*/); unsigned int fixdivquadlongu(uint nl, uint nh, uint d) { return fixdivquadlong((u_int32_t) nl,(u_int32_t) nh,(u_int32_t) d); } -#endif - -unsigned int fixdivquadlongu(uint nl, uint nh, uint d) -{ - u_int64_t n = (u_int64_t)nl | (((u_int64_t)nh) << 32 ); - return n / ((u_int64_t)d); -} - -#else //of ifdef NO_FIX_INLINE +#else int32_t fixdivquadlong(u_int32_t nl,u_int32_t nh,u_int32_t d) { int32_t a; __asm__("idivl %3" @@ -335,13 +341,13 @@ __asm__("divl %3" ); return (a); } -#endif //def NO_FIX_INLINE +#endif u_int32_t quad_sqrt(u_int32_t low,int32_t high) { int i, cnt; u_int32_t r,old_r,t; - quadint tq; + quad tq; if (high<0) return 0; @@ -363,9 +369,9 @@ u_int32_t quad_sqrt(u_int32_t low,int32_t high) //quad loop usually executed 4 times - r = fixdivquadlongu(low,high,r)/2 + r/2; - r = fixdivquadlongu(low,high,r)/2 + r/2; - r = fixdivquadlongu(low,high,r)/2 + r/2; + r = (fixdivquadlongu(low,high,r)+r)/2; + r = (fixdivquadlongu(low,high,r)+r)/2; + r = (fixdivquadlongu(low,high,r)+r)/2; do { @@ -375,7 +381,7 @@ u_int32_t quad_sqrt(u_int32_t low,int32_t high) if (t==r) //got it! return r; - r = t/2 + r/2; + r = (t+r)/2; } while (!(r==t || r==old_r)); diff --git a/maths/rand.c b/maths/rand.c index 46f1819f..69a0b562 100644 --- a/maths/rand.c +++ b/maths/rand.c @@ -1,8 +1,5 @@ -/* $Id: */ -/* - * Descent random number stuff... - * rand has different ranges on different machines... - */ +// Descent random number stuff... +// rand has different ranges on different machines... #ifdef HAVE_CONFIG_H #include diff --git a/maths/tables.c b/maths/tables.c index 9b24bdee..b278adc6 100644 --- a/maths/tables.c +++ b/maths/tables.c @@ -1,4 +1,3 @@ -/* $Id: tables.c,v 1.3 2003-02-18 20:23:22 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,15 +7,24 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * + * $Source: /cvs/cvsroot/d2x/maths/tables.c,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-01-31 15:18:04 $ + * * C version of fixed point library + * + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 2001/01/19 03:29:58 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 22:13:38 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.2 1995/08/31 15:44:36 allender * .. * diff --git a/maths/vecmat.c b/maths/vecmat.c index fc639024..14d97da5 100644 --- a/maths/vecmat.c +++ b/maths/vecmat.c @@ -1,4 +1,3 @@ -/* $Id: vecmat.c,v 1.5 2003-02-18 20:23:22 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,15 +7,27 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * + * $Source: /cvs/cvsroot/d2x/maths/vecmat.c,v $ + * $Revision: 1.3 $ + * $Author: bradleyb $ + * $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 + * + * Revision 1.1.1.1 1999/06/14 22:13:42 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.5 1995/10/30 11:08:16 allender * fix check_vec to return if vector is the NULL vector * @@ -37,8 +48,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. * --- PC RCS Information --- * Revision 1.1 1995/03/08 15:56:50 matt * Initial revision - * - * + * + * */ #ifdef HAVE_CONFIG_H @@ -46,7 +57,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: vecmat.c,v 1.5 2003-02-18 20:23:22 btb Exp $"; +static char rcsid[] = "$Id: vecmat.c,v 1.3 2001-10-31 07:41:54 bradleyb Exp $"; #endif #include @@ -197,7 +208,7 @@ vms_vector *vm_vec_scale2(vms_vector *dest,fix n,fix d) fix vm_vec_dotprod(vms_vector *v0,vms_vector *v1) { - quadint q; + quad q; q.low = q.high = 0; @@ -210,7 +221,7 @@ fix vm_vec_dotprod(vms_vector *v0,vms_vector *v1) fix vm_vec_dot3(fix x,fix y,fix z,vms_vector *v) { - quadint q; + quad q; q.low = q.high = 0; @@ -224,7 +235,7 @@ fix vm_vec_dot3(fix x,fix y,fix z,vms_vector *v) //returns magnitude of a vector fix vm_vec_mag(vms_vector *v) { - quadint q; + quad q; q.low = q.high = 0; @@ -330,7 +341,7 @@ fix vm_vec_copy_normalize_quick(vms_vector *dest,vms_vector *src) //returns approximation of 1/magnitude of a vector fix vm_vec_imag(vms_vector *v) { - quadint q; + quad q; q.low = q.high = 0; @@ -486,7 +497,7 @@ vms_vector *vm_vec_crossprod(vms_vector *dest,vms_vector *src0,vms_vector *src1) vms_vector *vm_vec_crossprod(vms_vector *dest,vms_vector *src0,vms_vector *src1) { - quadint q; + quad q; Assert(dest!=src0 && dest!=src1); diff --git a/maths/vecmata.asm b/maths/vecmata.asm index d93ec313..8b005114 100644 --- a/maths/vecmata.asm +++ b/maths/vecmata.asm @@ -1,4 +1,3 @@ -; $Id: vecmata.asm,v 1.4 2003-02-18 20:23:22 btb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -7,184 +6,197 @@ ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE ;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; +; $Source: /cvs/cvsroot/d2x/maths/vecmata.asm,v $ +; $Revision: 1.3 $ +; $Author: bradleyb $ +; $Date: 2001-10-31 07:41:54 $ ; ; Source for vector/matrix library ; -; Old Log: +; $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 +; +; Revision 1.1.1.1 1999/06/14 22:13:33 donut +; Import of d1x 1.37 source. +; ; Revision 1.54 1995/01/31 00:14:50 matt ; Took out int3 from dotprod overflow, since it saturates now -; +; ; Revision 1.53 1994/12/14 18:29:33 matt ; Made dotprod overflow check stay in, and return saturated value -; +; ; Revision 1.52 1994/12/14 12:34:13 matt ; Disabled now-unused vector_2_matrix_norm() -; +; ; Revision 1.51 1994/12/13 16:55:13 matt ; Ripped out optimization from last version, which was bogus -; +; ; Revision 1.50 1994/12/13 14:55:18 matt ; Use quick normalize in a couple of places where it was safe to do so -; +; ; Revision 1.49 1994/12/13 14:44:12 matt ; Added vm_vector_2_matrix_norm() -; +; ; Revision 1.48 1994/12/13 13:26:49 matt ; Fixed overflow check -; +; ; Revision 1.47 1994/12/03 15:39:54 matt ; Gracefully handle some vector_2_matrix problems -; +; ; Revision 1.46 1994/11/19 17:15:05 matt ; Assemble out some code not used in DESCENT -; +; ; Revision 1.45 1994/11/17 11:41:05 matt ; Put handling in extract_angles_from_matrix to deal with bad matrices -; +; ; Revision 1.44 1994/11/16 11:48:10 matt ; Added error checking to vm_extract_angles_matrix() -; +; ; Revision 1.43 1994/09/19 22:00:10 matt ; Fixed register trash -; +; ; Revision 1.42 1994/09/11 19:23:05 matt ; Added vm_vec_normalized_dir_quick() -; +; ; Revision 1.41 1994/08/14 13:28:38 matt ; Put in check for zero-length vector in extract angles -; +; ; Revision 1.40 1994/07/19 18:52:53 matt ; Added vm_vec_normalize_quick() and vm_vec_copy_normalize_quick() -; +; ; Revision 1.39 1994/06/16 18:24:22 matt ; Added vm_vec_mag_quick() -; +; ; Revision 1.38 1994/06/10 23:18:38 matt ; Added new code for vm_vec_ang_2_matrix() which may be better, but may ; not be. -; +; ; Revision 1.37 1994/05/22 18:17:29 mike ; Optimize vm_vec_dist_quick, using jns in place of abs_eax. -; +; ; Revision 1.36 1994/05/19 12:07:04 matt ; Fixed globals and macros and added a constant -; +; ; Revision 1.35 1994/05/19 09:19:00 matt ; Made vm_vec_normalized_dir() return mag of vector -; +; ; Revision 1.34 1994/05/18 22:28:01 matt ; Added function vm_vec_normalized_dir() ; Added C macros IS_ZERO_VEC(), vm_vec_zero(), and vm_set_identity() ; Added C global static vars vmd_zero_vector & vmd_identity_matrix -; +; ; Revision 1.33 1994/05/18 21:44:16 matt ; Added functions: ; vm_extract_angles_vector() ; vm_extract_angles_vector_normalized() ; vm_vec_copy_normalize() -; +; ; Revision 1.32 1994/05/13 12:41:51 matt ; Added new function, vm_vec_dist_quick(), which does an approximation. -; +; ; Revision 1.31 1994/05/04 17:41:31 mike ; Comment out debug_brk on null vector. -; +; ; Revision 1.30 1994/04/15 21:41:31 matt ; Check for foward vector straigt up in extract angles routine -; +; ; Revision 1.29 1994/03/30 15:45:05 matt ; Added two functions, vm_vec_scale_add() & vm_vec_scale_add2() -; +; ; Revision 1.28 1994/02/26 19:23:35 matt ; Do an int3 when we get a null vector when computing surface normal -; +; ; Revision 1.27 1994/02/10 18:29:45 matt ; Changed 'if DEBUG_ON' to 'ifndef NDEBUG' -; +; ; Revision 1.26 1994/02/10 18:28:55 matt ; Fixed bugs in extract angles function -; +; ; Revision 1.25 1994/01/31 22:46:07 matt ; Added vm_extract_angles_matrix() function -; +; ; Revision 1.24 1994/01/30 19:29:55 matt ; Put in debug_brk when vm_vec_2_matrix got zero-length vector -; +; ; Revision 1.23 1994/01/25 15:27:59 matt ; Added debugging check for dotprod overflow -; +; ; Revision 1.22 1994/01/24 11:52:59 matt ; Added checking for dest==src for several functions where this is not allowed -; +; ; Revision 1.21 1994/01/19 23:13:02 matt ; Fixed bug in vm_vec_ang_2_matrix() -; +; ; Revision 1.20 1994/01/04 12:33:43 mike ; Prevent divide overflow in vm_vec_scale2 -; +; ; Revision 1.19 1993/12/21 19:46:26 matt ; Added function vm_dist_to_plane() -; +; ; Revision 1.18 1993/12/13 17:26:23 matt ; Added vm_vec_dist() -; +; ; Revision 1.17 1993/12/02 12:43:39 matt ; New functions: vm_vec_copy_scale(), vm_vec_scale2() -; +; ; Revision 1.16 1993/10/29 22:39:29 matt ; Changed matrix order, making direction vectors the rows -; +; ; Revision 1.15 1993/10/29 18:06:01 matt ; Fixed vm_vector_2_matrix() bug when forward vector was straight down -; +; ; Revision 1.14 1993/10/26 18:51:26 matt ; Fixed some register trashes in vm_vec_ang_2_matrix() -; +; ; Revision 1.13 1993/10/25 11:49:37 matt ; Made vm_vec_delta_ang() take optional forward vector to return signed delta -; +; ; Revision 1.12 1993/10/20 01:09:42 matt ; Added vm_vec_delta_ang(), vm_vec_delta_ang_norm(), and vm_vec_ang_2_matrix() -; +; ; Revision 1.11 1993/10/17 17:03:08 matt ; vm_vector_2_matrix() now takes optional right vector -; +; ; Revision 1.10 1993/10/10 18:11:42 matt -; Changed angles_2_matrix so that heading & bank rotate in the +; Changed angles_2_matrix so that heading & bank rotate in the ; correct directions. -; +; ; Revision 1.9 1993/09/30 16:17:59 matt ; Fixed bug in vector_2_matrix() by adding another normalize -; +; ; Revision 1.8 1993/09/29 10:51:58 matt ; Fixed bad register trashes in crossprod, perp, & normal -; +; ; Revision 1.7 1993/09/28 12:16:46 matt ; Fixed bugs in cross product ; Added func vm_vector_2_matrix() -; +; ; Revision 1.6 1993/09/24 21:19:37 matt ; Added vm_vec_avg() and vm_vec_avg4() -; +; ; Revision 1.5 1993/09/20 18:15:07 matt ; Trap zero-length vectors in vm_vec_normalize(), vm_vec_perp(), and vm_vec_normal() -; +; ; Revision 1.4 1993/09/20 14:56:43 matt ; Fixed bug in vm_vec_normal(), made that routine normalize the results, ; and added new function vm_vec_perp(). -; +; ; Revision 1.3 1993/09/20 10:12:06 mike ; no changes -; +; ; Revision 1.2 1993/09/17 11:10:33 matt ; Added vm_vec_add2() and vm_vec_sub2(), which take 2 args (dest==src0) -; +; ; Revision 1.1 1993/09/16 20:10:24 matt ; Initial revision -; +; ; ; diff --git a/mem/.cvsignore b/mem/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/mem/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/mem/Makefile.am b/mem/Makefile.am index 1e77aa62..4680aae2 100644 --- a/mem/Makefile.am +++ b/mem/Makefile.am @@ -1,4 +1,4 @@ noinst_LIBRARIES = libmem.a -INCLUDES = -I $(top_srcdir)/include +INCLUDES = -I $(top_srcdir)/includes libmem_a_SOURCES = mem.c diff --git a/mem/mem.c b/mem/mem.c index d5009925..52a0c31b 100644 --- a/mem/mem.c +++ b/mem/mem.c @@ -1,4 +1,3 @@ -/* $Id: mem.c,v 1.11 2003-04-11 23:51:48 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,14 +7,24 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/mem/mem.c,v $ + * $Revision: 1.7 $ + * $Author: bradleyb $ + * $Date: 2001-11-09 06:56:41 $ * * Files for debugging memory allocator * + * $Log: not supported by cvs2svn $ + * Revision 1.6 2001/11/08 10:17:40 bradleyb + * added d_realloc/mem_realloc functions + * + * Revision 1.5 2001/10/19 08:06:20 bradleyb + * Partial application of linux/alpha patch. Courtesy of Falk Hueffner * */ @@ -34,11 +43,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #include #include -#if defined(__APPLE__) && defined(__MACH__) -#include -#else #include -#endif + #include "pstypes.h" #include "mono.h" #include "error.h" @@ -380,16 +386,6 @@ void *mem_realloc(void * buffer, unsigned int size, char * var, char * filename, return newbuffer; } -char *mem_strdup(char *str, char *var, char *filename, int line) -{ - char *newstr; - - newstr = mem_malloc(strlen(str) + 1, var, filename, line, 0); - strcpy(newstr, str); - - return newstr; -} - void mem_display_blocks() { int i, numleft; @@ -428,7 +424,7 @@ void mem_display_blocks() if (numleft && (!out_of_memory)) { - Warning( "MEM: %d blocks were left allocated!\n", numleft ); + Warning( "MEM: %d blocks were left allocated!", numleft ); } } diff --git a/mingw32.txt b/mingw32.txt new file mode 100644 index 00000000..c0ebed65 --- /dev/null +++ b/mingw32.txt @@ -0,0 +1,56 @@ +Instructions for building D2X for MinGW32 +----------------------------------------- + +Using Cygwin +------------ +First you will need SDL. +Download the source code tarball from http://www.libsdl.org/ +Currently, it is SDL-1.2.3.tar.gz. + +tar zxf SDL-1.2.3.tar.gz +cd SDL-1.2.3 +./configure +make +make install + +Note that SDL.dll needs to be in your executable PATH, since that is +where windows looks for dlls. +I recommend copying it to /usr/local/bin: +cp /usr/local/lib/SDL.dll /usr/local/bin + +If you need to run autogen.sh (e.g. to rebuild the configure scripts, +or to build from cvs) sdl.m4 will have to be somewhere where aclocal +can find it. +You can fix this by setting the ACLOCAL_FLAGS variable like this: +export ACLOCAL_FLAGS=/usr/local/share/aclocal + +You should also install NASM, for compiling assembler files. Download +it from http://www.web-sites.co.uk/nasm/where.html and place nasmw.exe +somewhere in your path (e.g. /usr/local/bin): +unzip nasm-0.98-win32.zip +mv nasmw.exe /usr/local/bin + +Now you can configure d2x as normal. i.e. +./configure +or +./configure --with-opengl + +automake/autoconf in cygwin has a problem with not always putting the +.exe extentions where they need to be. So you may have to run make +twice, like so: +make && make d2x-sdl.exe +or +make && make d2x-ogl.exe + + +Using MinGW32 +------------- +to be added + + +Using Linux +----------- +to be added + + +-Bradley Bell diff --git a/misc/.cvsignore b/misc/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/misc/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/misc/Makefile.am b/misc/Makefile.am index b3b65db9..20713c34 100644 --- a/misc/Makefile.am +++ b/misc/Makefile.am @@ -1,9 +1,9 @@ noinst_LIBRARIES = libmisc.a -INCLUDES = -I $(top_srcdir)/include +INCLUDES = -I $(top_srcdir)/includes libmisc_a_SOURCES = \ -args.c error.c strio.c \ -d_io.c hash.c strutil.c fileutil.c +args.c d_delay.c error.c strio.c \ +d_io.c hash.c strutil.c # checker.c @@ -11,5 +11,5 @@ d_io.c hash.c strutil.c fileutil.c # gcc -c -g $< -o $@ $(INCLUDES) $(CFLAGS) -I/usr/lib/checker/i686-pc-linux-gnu/include -I.. -I. EXTRA_DIST = \ -dos_disk.h parsarg.h \ -byteswap.c errtest.c parsarg.c parstest.c +dos_disk.h fileutil.h parsarg.h \ +byteswap.c d_glob.c errtest.c fileutil.c parsarg.c parstest.c diff --git a/misc/args.c b/misc/args.c index 8a91a44e..96c4bc8e 100644 --- a/misc/args.c +++ b/misc/args.c @@ -1,4 +1,3 @@ -/* $Id: args.c,v 1.8 2003-02-18 20:35:35 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,48 +7,76 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * + * $Source: /cvs/cvsroot/d2x/misc/args.c,v $ + * $Revision: 1.6 $ + * $Author: bradleyb $ + * $Date: 2002-01-18 07:02:23 $ + * * Functions for accessing arguments. + * + * $Log: not supported by cvs2svn $ + * Revision 1.5 2001/11/09 06:57:27 bradleyb + * use d2x.ini for option file + * + * Revision 1.4 2001/11/05 07:39:26 bradleyb + * Change args_init back to InitArgs + * + * Revision 1.3 2001/01/31 15:18:04 bradleyb + * Makefile and conf.h fixes + * + * Revision 1.2 2001/01/24 04:29:48 bradleyb + * changed args_find to FindArg + * + * Revision 1.1.1.1 2001/01/19 03:30:14 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.3 1999/08/05 22:53:41 sekmu + * + * D3D patch(es) from ADB + * + * Revision 1.2 1999/06/14 23:44:11 donut + * Orulz' svgalib/ggi/noerror patches. + * + * Revision 1.1.1.1 1999/06/14 22:05:15 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 2.0 1995/02/27 11:31:22 john * New version 2.0, which has no anonymous unions, builds with * Watcom 10.0, and doesn't require parsing BITMAPS.TBL. - * + * * Revision 1.9 1994/11/29 01:07:57 john * Took out some unused vars. - * + * * Revision 1.8 1994/11/29 01:04:30 john * Took out descent.ini stuff. - * + * * Revision 1.7 1994/09/20 19:29:15 matt * Made args require exact (not substring), though still case insensitive. - * + * * Revision 1.6 1994/07/25 12:33:11 john * Network "pinging" in. - * + * * Revision 1.5 1994/06/17 18:07:50 matt * Took out printf - * + * * Revision 1.4 1994/05/11 19:45:33 john * *** empty log message *** - * + * * Revision 1.3 1994/05/11 18:42:11 john * Added Descent.ini config file. - * + * * Revision 1.2 1994/05/09 17:03:30 john * Split command line parameters into arg.c and arg.h. * Also added /dma, /port, /irq to digi.c - * + * * Revision 1.1 1994/05/09 16:49:11 john * Initial revision - * - * + * + * */ #ifdef HAVE_CONFIG_H @@ -57,7 +84,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: args.c,v 1.8 2003-02-18 20:35:35 btb Exp $"; +static char rcsid[] = "$Id: args.c,v 1.6 2002-01-18 07:02:23 bradleyb Exp $"; #endif #include @@ -105,8 +132,11 @@ void InitArgs( int argc,char **argv ) } if((i=FindArg("-ini"))) f=fopen(Args[i+1],"rt"); - else + else { f=fopen("d2x.ini","rt"); + if (!f) + f=fopen("d1x.ini","rt"); + } if(f) { while(!feof(f)) { diff --git a/misc/byteswap.c b/misc/byteswap.c index 499332b0..8cc69e95 100644 --- a/misc/byteswap.c +++ b/misc/byteswap.c @@ -1,4 +1,3 @@ -/* $Id: byteswap.c,v 1.3 2003-02-18 20:35:35 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ diff --git a/misc/d_delay.c b/misc/d_delay.c new file mode 100644 index 00000000..44bf1523 --- /dev/null +++ b/misc/d_delay.c @@ -0,0 +1,45 @@ +//added on 9/2/98 by Matt Mueller + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "d_delay.h" + +#ifndef d_delay + +#if defined(__WINDOWS__) || defined(__MINGW32__) + +#include + +void d_delay (int ms) { + Sleep(ms); +} + +#else + +#include +#include +#include +#include + +void d_delay (int ms) { +#if 0 + struct timeval tv; + tv.tv_sec=ms/1000; +//edited 02/06/99 Matt Mueller - microseconds, not milliseconds + tv.tv_usec=(ms%1000)*1000; +//end edit -MM + select(0,NULL,NULL,NULL,&tv); +#elif 0 + struct timespec tv; + tv.tv_sec=ms/1000; + tv.tv_nsec=(ms%1000)*1000000;//nanoseconds + nanosleep(&tv,NULL); +#else + usleep(ms*1000); +#endif +} + +#endif +#endif diff --git a/misc/d_glob.c b/misc/d_glob.c new file mode 100644 index 00000000..5676024b --- /dev/null +++ b/misc/d_glob.c @@ -0,0 +1,97 @@ +/* Globbing functions for descent. Calls the relevant system handlers... */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "d_glob.h" +#include "error.h" +#include +//added 05/17/99 Matt Mueller +#include "u_mem.h" +//end addition -MM + +#if defined(__DJGPP__) || defined(__linux__) +#include + +int d_glob(const char *pattern, d_glob_t *g) +{ + glob_t a; + int r; + + Assert(g!=NULL); + + a.gl_offs=0; + + r=glob(pattern,0,NULL,&a); + g->gl_pathc=a.gl_pathc; + g->gl_pathv=a.gl_pathv; + return r; +} + +void d_globfree(d_glob_t *g) +{ +#ifndef __linux__ // Linux doesn't believe in freeing glob structures... :-) + glob_t a; + + Assert (g!=NULL); + + a.gl_offs=0; + a.gl_pathc=g->gl_pathc; + a.gl_pathv=g->gl_pathv; + + globfree(&a); +#endif +} + +#elif defined(__WINDOWS__) + +#include + +#define MAX_GLOB_FILES 500 + +/* Using a global variable stops this from being reentrant, but in descent, + who cares? */ +static char *globfiles[MAX_GLOB_FILES]; + +int d_glob(const char *pattern, d_glob_t *g) +{ + WIN32_FIND_DATA wfd; + HANDLE wfh; + int c; + + Assert (g!=NULL); + c=0; + if ((wfh=FindFirstFile(pattern,&wfd))!=INVALID_HANDLE_VALUE) + { + do { + LPSTR sz = wfd.cAlternateFileName; + if (sz == NULL || sz [0] == '\0') + sz = wfd.cFileName; + globfiles[c] = d_strdup (*wfd.cAlternateFileName ? + wfd.cAlternateFileName : wfd.cFileName); + + c++; // Ho ho ho... :-) + if (c>=MAX_GLOB_FILES) return 0; + } while (FindNextFile(wfh,&wfd)); + FindClose(wfh); + } + + g->gl_pathc = c; + g->gl_pathv = globfiles; + return (!c)?-1:0; +} + +void d_globfree(d_glob_t *g) +{ + unsigned int i; + Assert (g!=NULL); + for (i=0; i < g->gl_pathc; i++) { + if (globfiles[i]) d_free(globfiles[i]); + } +} + +#else // Must be good old Watcom C. +#error "FIXME: Globbing isn't yet supported under Watcom C. Look at misc/d_glob.c" +#endif + diff --git a/misc/d_io.c b/misc/d_io.c index cfa61974..81771375 100644 --- a/misc/d_io.c +++ b/misc/d_io.c @@ -1,8 +1,5 @@ -/* $Id: d_io.c,v 1.5 2003-02-18 20:35:35 btb Exp $ */ -/* - * some misc. file/disk routines - * Arne de Bruijn, 1998 - */ +// some misc. file/disk routines +// Arne de Bruijn, 1998 #ifdef HAVE_CONFIG_H #include diff --git a/misc/dos_disk.h b/misc/dos_disk.h index 880e8c64..c983fce4 100644 --- a/misc/dos_disk.h +++ b/misc/dos_disk.h @@ -1,4 +1,3 @@ -/* $Id: dos_disk.h,v 1.2 2003-02-18 20:35:35 btb Exp $ */ #ifndef _DISK_H #define _DISK_H diff --git a/misc/error.c b/misc/error.c index 09967b5e..33336c2f 100644 --- a/misc/error.c +++ b/misc/error.c @@ -1,4 +1,3 @@ -/* $Id: error.c,v 1.6 2003-04-08 00:59:17 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,51 +7,61 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* + * $Source: /cvs/cvsroot/d2x/misc/error.c,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-01-31 15:18:04 $ * * Error handling/printing/exiting code * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 2001/01/19 03:30:14 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 22:13:48 donut + * Import of d1x 1.37 source. + * * Revision 1.12 1994/12/07 18:49:39 matt * error_init() can now take NULL as parm - * + * * Revision 1.11 1994/11/29 15:42:07 matt * Added newline before error message - * + * * Revision 1.10 1994/11/27 23:20:39 matt * Made changes for new mprintf calling convention - * + * * Revision 1.9 1994/06/20 21:20:56 matt * Allow NULL for warn func, to kill warnings - * + * * Revision 1.8 1994/05/20 15:11:35 mike * mprintf Warning message so you can actually see it. - * + * * Revision 1.7 1994/02/10 18:02:38 matt * Changed 'if DEBUG_ON' to 'ifndef NDEBUG' - * + * * Revision 1.6 1993/10/17 18:19:10 matt * If error_init() not called, Error() now prints the error message before * calling exit() - * + * * Revision 1.5 1993/10/14 15:29:11 matt * Added new function clear_warn_func() - * + * * Revision 1.4 1993/10/08 16:17:19 matt * Made Assert() call function _Assert(), rather to do 'if...' inline. - * + * * Revision 1.3 1993/09/28 12:45:25 matt * Fixed wrong print call, and made Warning() not append a CR to string - * + * * Revision 1.2 1993/09/27 11:46:35 matt * Added function set_warn_func() - * + * * Revision 1.1 1993/09/23 20:17:33 matt * Initial revision - * + * * */ @@ -61,7 +70,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: error.c,v 1.6 2003-04-08 00:59:17 btb Exp $"; +static char rcsid[] = "$Id: error.c,v 1.2 2001-01-31 15:18:04 bradleyb Exp $"; #endif #include @@ -71,7 +80,6 @@ static char rcsid[] = "$Id: error.c,v 1.6 2003-04-08 00:59:17 btb Exp $"; #include "pstypes.h" #include "console.h" -#include "mono.h" #include "error.h" #define MAX_MSG_LEN 256 @@ -80,15 +88,13 @@ static char rcsid[] = "$Id: error.c,v 1.6 2003-04-08 00:59:17 btb Exp $"; int err_initialized=0; //end edit -MM -static void (*ErrorPrintFunc)(char *); - char exit_message[MAX_MSG_LEN]=""; char warn_message[MAX_MSG_LEN]; //takes string in register, calls printf with string on stack void warn_printf(char *s) { - con_printf(CON_URGENT, "%s\n",s); + printf("%s\n",s); } void (*warn_func)(char *s)=warn_printf; @@ -120,30 +126,14 @@ void set_exit_message(char *fmt,...) void _Assert(int expr,char *expr_text,char *filename,int linenum) { - Int3(); if (!(expr)) Error("Assertion failed: %s, file %s, line %d",expr_text,filename,linenum); + } void print_exit_message(void) { if (*exit_message) - { - if (ErrorPrintFunc) - { - (*ErrorPrintFunc)(exit_message); - } - else - { -#if (defined(MACINTOSH) && defined(NDEBUG) && defined(RELEASE)) - c2pstr(exit_message); - ShowCursor(); - ParamText(exit_message, "\p", "\p", "\p"); - StopAlert(ERROR_ALERT, nil); -#else - con_printf(CON_CRITICAL, "%s\n",exit_message); -#endif - } - } + con_printf(CON_CRITICAL, "%s\n",exit_message); } //terminates with error code 1, printing message @@ -151,18 +141,13 @@ void Error(char *fmt,...) { va_list arglist; -#if (defined(MACINTOSH) && defined(NDEBUG) && defined(RELEASE)) - strcpy(exit_message,"Error: "); // don't put the new line in for dialog output -#else strcpy(exit_message,"\nError: "); -#endif + va_start(arglist,fmt); vsprintf(exit_message+strlen(exit_message),fmt,arglist); va_end(arglist); - Int3(); - - if (!err_initialized) print_exit_message(); + con_printf(CON_CRITICAL, exit_message); exit(1); } @@ -181,21 +166,18 @@ void Warning(char *fmt,...) vsprintf(warn_message+strlen(warn_message),fmt,arglist); va_end(arglist); - mprintf((0, "%s\n", warn_message)); - (*warn_func)(warn_message); + con_printf(CON_URGENT, warn_message); } //initialize error handling system, and set default message. returns 0=ok -int error_init(void (*func)(char *), char *fmt, ...) +int error_init(char *fmt,...) { va_list arglist; int len; atexit(print_exit_message); //last thing at exit is print message - ErrorPrintFunc = func; // Set Error Print Functions - if (fmt != NULL) { va_start(arglist,fmt); len = vsprintf(exit_message,fmt,arglist); diff --git a/misc/fileutil.c b/misc/fileutil.c index aef611b8..e6c39c75 100644 --- a/misc/fileutil.c +++ b/misc/fileutil.c @@ -1,4 +1,3 @@ -/* $Id: fileutil.c,v 1.7 2003-04-12 00:11:46 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,117 +7,106 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - -/* - * - * utilities for file manipulation - * - * Old Log: - * Revision 1.6 1995/10/30 11:09:51 allender - * use FILE, not CFILE on the write* routines - * - * Revision 1.5 1995/05/11 13:00:34 allender - * added write functions which swap bytes - * - * Revision 1.4 1995/05/04 20:10:38 allender - * remove include for fcntl - * - * Revision 1.3 1995/04/26 10:14:39 allender - * added byteswap header file - * - * Revision 1.2 1995/04/26 10:13:21 allender - * - * Revision 1.1 1995/03/30 15:02:34 allender - * Initial revision - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - + #include +#include +#include "pstypes.h" #include "fileutil.h" +#include "cfile.h" #include "fix.h" #include "byteswap.h" -#include "error.h" -byte file_read_byte(FILE *fp) +int filelength(int fd) +{ + int cur_pos, end_pos; + + cur_pos = lseek(fd, 0, SEEK_CUR); + lseek(fd, 0, SEEK_END); + end_pos = lseek(fd, 0, SEEK_CUR); + lseek(fd, cur_pos, SEEK_SET); + return end_pos; +} +#if 0 +byte read_byte(CFILE *fp) { byte b; - - if (fread(&b, 1, 1, fp) != 1) - Error("Error reading byte in file_read_byte()"); + + cfread(&b, sizeof(byte), 1, fp); return b; } -short file_read_short(FILE *fp) +short read_short(CFILE *fp) { short s; + + cfread(&s, sizeof(short), 1, fp); + return (s); +} - if (fread(&s, 2, 1, fp) != 1) - Error("Error reading short in file_read_short()"); - return INTEL_SHORT(s); +short read_short_swap(CFILE *fp) +{ + short s; + + cfread(&s, sizeof(short), 1, fp); + return swapshort(s); } -int file_read_int(FILE *fp) +int read_int(CFILE *fp) { uint i; - - if (fread(&i, 4, 1, fp) != 1) - Error("Error reading int in file_read_int()"); - return INTEL_INT(i); + + cfread(&i, sizeof(uint), 1, fp); + return i; } -fix file_read_fix(FILE *fp) +fix read_fix(CFILE *fp) { fix f; + + cfread(&f, sizeof(fix), 1, fp); + return f; +} - if (fread(&f, 4, 1, fp) != 1) - Error("Error reading fix in file_read_fix()"); - return INTEL_INT(f); +int write_byte(FILE *fp, byte b) +{ + return (fwrite(&b, sizeof(byte), 1, fp)); } -void file_read_string(char *s, FILE *f) +int write_short(FILE *fp, short s) { - if (feof(f)) - *s = 0; - else - do - *s = fgetc(f); - while (!feof(f) && *s++!=0); + return (fwrite(&s, sizeof(short), 1, fp)); } -int file_write_byte(byte b, FILE *fp) +int write_short_swap(FILE *fp, short s) { - return (fwrite(&b, 1, 1, fp)); + s = swapshort(s); + return (fwrite(&s, sizeof(short), 1, fp)); } -int file_write_short(short s, FILE *fp) +int write_int(FILE *fp, int i) { - s = INTEL_SHORT(s); - return (fwrite(&s, 2, 1, fp)); + return (fwrite(&i,sizeof(int), 1, fp)); } -int file_write_int(int i, FILE *fp) +int write_int_swap(FILE *fp, int i) { - i = INTEL_INT(i); - return (fwrite(&i, 4, 1, fp)); + i = swapint(i); + return (fwrite(&i,sizeof(int), 1, fp)); } -int file_write_fix(fix f, FILE *fp) +int write_fix(FILE *fp, fix f) { - f = (fix)INTEL_INT((int)f); - return (fwrite(&f, 4, 1, fp)); + return (fwrite(&f, sizeof(fix), 1, fp)); } -void file_write_string(char *s, FILE *f) +int write_fix_swap(FILE *fp, fix f) { - do - fputc(*s,f); - while (*s++!=0); + f = (fix)swapint((int)f); + return (fwrite(&f, sizeof(fix), 1, fp)); } + +#endif diff --git a/include/fileutil.h b/misc/fileutil.h similarity index 54% rename from include/fileutil.h rename to misc/fileutil.h index ae94106c..da8110cc 100644 --- a/include/fileutil.h +++ b/misc/fileutil.h @@ -7,29 +7,39 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - + #ifndef _FILEUTIL_ #define _FILEUTIL_ -#include - +#include "pstypes.h" +#include "cfile.h" #include "fix.h" + +extern int filelength(int fd); // routines which read basic data types -extern byte file_read_byte(FILE *fp); -extern short file_read_short(FILE *fp); -extern int file_read_int(FILE *fp); -extern fix file_read_fix(FILE *fp); -extern void file_read_string(char *s, FILE *f); +extern byte read_byte(CFILE *fp); +extern short read_short(CFILE *fp); +extern int read_int(CFILE *fp); +extern fix read_fix(CFILE *fp); + +// versions which swap bytes +#define read_byte_swap(fp) read_byte(fp) +extern short read_short_swap(CFILE *fp); // routines which write basic data types -extern int file_write_byte(byte b, FILE *fp); -extern int file_write_short(short s, FILE *fp); -extern int file_write_int(int i, FILE *fp); -extern int file_write_fix(fix f, FILE *fp); -extern void file_write_string(char *s, FILE *f); +extern int write_byte(FILE *fp, byte b); +extern int write_short(FILE *fp, short s); +extern int write_int(FILE *fp, int i); +extern int write_fix(FILE *fp, fix f); + +// routines which write swapped bytes +#define write_byte_swap(fp, b) write_byte(fp, b) +extern int write_short_swap(FILE *fp, short s); +extern int write_int_swap(FILE *fp, int i); +extern int write_fix_swap(FILE *fp, fix f); #endif diff --git a/misc/hash.c b/misc/hash.c index e7f059cb..1608a1aa 100644 --- a/misc/hash.c +++ b/misc/hash.c @@ -1,4 +1,3 @@ -/* $Id: hash.c,v 1.3 2003-02-18 20:35:35 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,7 +7,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -17,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: hash.c,v 1.3 2003-02-18 20:35:35 btb Exp $"; +static char rcsid[] = "$Id: hash.c,v 1.2 2001-01-31 15:18:04 bradleyb Exp $"; #endif #include diff --git a/misc/parsarg.c b/misc/parsarg.c index 05afdc64..f53cd56f 100644 --- a/misc/parsarg.c +++ b/misc/parsarg.c @@ -1,4 +1,3 @@ -/* $Id: parsarg.c,v 1.2 2003-02-18 20:35:35 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,12 +7,12 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #pragma off (unreferenced) -static char rcsid[] = "$Id: parsarg.c,v 1.2 2003-02-18 20:35:35 btb Exp $"; +static char rcsid[] = "$Id: parsarg.c,v 1.1.1.1 2001-01-19 03:30:14 bradleyb Exp $"; #pragma on (unreferenced) #include diff --git a/misc/parsarg.h b/misc/parsarg.h index af639aaf..55ae878b 100644 --- a/misc/parsarg.h +++ b/misc/parsarg.h @@ -1,4 +1,3 @@ -/* $Id: parsarg.h,v 1.2 2003-02-18 20:35:35 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,35 +7,35 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* - * - * Routine to parse the command line. Will also read and parse args - * from a file. - * - * parse_args() is called with argc & argv from main(), the function - * to be called with each argument, and flags. argc & argv are usually - * adjusted to not pass the first parameter (the program file name). - * Thus the general method of calling is: - * - * parse_args(argc-1,argv+1,hander_func,flags); - * - * handler_func() is then called with each parameter. - * - * If the PA_EXPAND flag is passed, all arguments which do not start - * with '-' are assumed to be filenames and are expanded for wildcards, - * with the handler function called for each match. If a spec matches - * nothing, the spec itself is passed to the handler func. - * - * Args that start with '@' are assumed to be argument files. These - * files are opened, and arguments are read from them just as if they - * were specified on the command line. Arg files can be nested. - * - */ + + Routine to parse the command line. Will also read and parse args + from a file. + + parse_args() is called with argc & argv from main(), the function + to be called with each argument, and flags. argc & argv are usually + adjusted to not pass the first parameter (the program file name). + Thus the general method of calling is: + + parse_args(argc-1,argv+1,hander_func,flags); + + handler_func() is then called with each parameter. + + If the PA_EXPAND flag is passed, all arguments which do not start + with '-' are assumed to be filenames and are expanded for wildcards, + with the handler function called for each match. If a spec matches + nothing, the spec itself is passed to the handler func. + + Args that start with '@' are assumed to be argument files. These + files are opened, and arguments are read from them just as if they + were specified on the command line. Arg files can be nested. + +*/ //Flags diff --git a/misc/strio.c b/misc/strio.c index 0326ca24..93173825 100644 --- a/misc/strio.c +++ b/misc/strio.c @@ -1,7 +1,4 @@ -/* $Id: strio.c,v 1.3 2003-02-18 20:35:35 btb Exp $ */ -/* - * strio.c: string/file manipulation functions by Victor Rachels - */ +/**strio.c: string/file manipulation functions by Victor Rachels **/ #ifdef HAVE_CONFIG_H #include diff --git a/misc/strutil.c b/misc/strutil.c index 2378e55c..c523b935 100644 --- a/misc/strutil.c +++ b/misc/strutil.c @@ -1,4 +1,3 @@ -/* $Id: strutil.c,v 1.8 2003-02-18 20:35:35 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,10 +7,10 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - + #ifdef HAVE_CONFIG_H #include #endif @@ -24,6 +23,17 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "u_mem.h" #include "error.h" +char *d_strdup(char *str) +{ + char *a; + + a = d_malloc(strlen(str) + 1); + strcpy(a, str); + + return a; +} + + #if 0 // string compare without regard to case @@ -73,15 +83,15 @@ void strupr( char *s1 ) void strrev( char *s1 ) { - char *h, *t; - h = s1; - t = s1 + strlen(s1) - 1; - while (h < t) { - char c; - c = *h; - *h++ = *t; - *t-- = c; - } + int i,l; + char *s2; + + s2 = (char *)d_malloc(strlen(s1) + 1); + strcpy(s2, s1); + l = strlen(s2); + for (i = 0; i < l; i++) + s1[l-1-i] = s2[i]; + d_free(s2); } void _splitpath(char *name, char *drive, char *path, char *base, char *ext) diff --git a/readme.txt b/readme.txt index 5a816424..c058eb6c 100644 --- a/readme.txt +++ b/readme.txt @@ -1,3 +1,6 @@ +Please view the file README before this file. + + Legal Stuff: THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX @@ -8,7 +11,7 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. We make no warranties as to the usability or correctness of this code. @@ -18,15 +21,15 @@ Message from Matt Toschlog & Mike Kulas: Descent fans: -Here, finally, is the source for Descent II. We've been so busy with -Descent 3, Mercenary, FreeSpace, FreeSpace 2, and several other -projects that we haven't given much thought to this old code. But we +Here, finally, is the source for Descent II. We've been so busy with +Descent 3, Mercenary, FreeSpace, FreeSpace 2, and several other +projects that we haven't given much thought to this old code. But we know that many of you are eager to get it, so here you go. -We were amazed and impressed at the cool things people did with -the Descent source we released a few years ago. It touches us -deeply how devoted some people are to the Descent series, and we -look forward to seeing what people can do with this Descent II +We were amazed and impressed at the cool things people did with +the Descent source we released a few years ago. It touches us +deeply how devoted some people are to the Descent series, and we +look forward to seeing what people can do with this Descent II source. Matt Toschlog Mike Kulas @@ -38,9 +41,9 @@ About the Source Code: Included is almost all the source code to Descent 2, ver. 1.2. We removed all code to which we did not own the copyright. This mainly involved low- -level sound and modem code and the movie code. +level sound and modem code and the movie code. -The Descent Network has agreed to provide a list of mirror locations where +The Descent Network has agreed to provide a list of mirror locations where this code can be downloaded. The location is: http://www.descent2.com/ddn/sources/descent2 diff --git a/rpm/.cvsignore b/rpm/.cvsignore deleted file mode 100644 index fc9b8218..00000000 --- a/rpm/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -d2x.spec diff --git a/rpm/d2x.spec.in b/rpm/d2x.spec.in deleted file mode 100644 index c66918ef..00000000 --- a/rpm/d2x.spec.in +++ /dev/null @@ -1,118 +0,0 @@ -# -# Spec file for package d2x. -# -Name: d2x -Version: @VERSION@ -Release: 1 -Copyright: Freely Redistributable -Packager: bradleyb@u.washington.edu - -Group: Contrib/Games -Summary: The port of Descent 2 Version 1.2 for Linux. -Provides: d2x, descent2 - -URL: http://shelob.classrooms.washington.edu/d2x/ -Source: d2x-%{version}.tar.gz -BuildRoot: /var/tmp/%name-buildroot - -%description -This is the port of Descent 2 Version 1.2, the famous 3D game for PC. - -D2X is based on source code that was released the 14 December 1999 by -Parallax Software Corporation. - -To use this package you'll need the datafiles from the Retail version -of Descent 2 Version 1.2 installed in /usr/share/games/descent2. - -%package -n d2x-sdl -Group: Contrib/Games -Summary: Descent 2 Version 1.2 for Linux, SDL version. -Provides: d2x-sdl -Requires: d2x - -%description -n d2x-sdl -This is the port of Descent 2 Version 1.2, the famous 3D game for PC. - -D2X is based on source code that was released the 14 December 1999 by -Parallax Software Corporation. - -To use this package you'll need the datafiles from the Retail version -of Descent 2 Version 1.2 installed in /usr/share/games/descent2. - -This version uses SDL for Audio, Input/Output and graphics rendering. - -%package -n d2x-gl -Group: Contrib/Games -Summary: Descent 2 Version 1.2 for Linux, OpenGL version. -Provides: d2x-gl -Requires: d2x - -%description -n d2x-gl -This is the port of Descent 2 Version 1.2, the famous 3D game for PC. - -D2X is based on source code that was released the 14 December 1999 by -Parallax Software Corporation. - -To use this package you'll need the datafiles from the Retail version -of Descent 2 Version 1.2 installed in /usr/share/games/descent2. - -This version uses SDL for Audio and Input/Output and OpenGL for graphics -rendering. - -%prep -%setup -q -n d2x* -#./autogen.sh - -%build -# d2x-sdl -%configure --with-sharepath=/usr/share/games/descent2 --disable-debug -make -mv d2x-sdl d2x-sdl.real -# d2x-gl -make clean -rm -f config.cache -# Tell configure where to find libGLU (nonstandard location). -export LDFLAGS="${LDFLAGS} -L/usr/X11R6/lib" -%configure --with-sharepath=/usr/share/games/descent2 --with-opengl \ - --disable-debug -# Tell make where to link libGLU (nonstandard location). -make LDFLAGS="${LDFLAGS} -L /usr/X11R6/lib" -mv d2x-gl d2x-gl.real - -%install -rm -rf $RPM_BUILD_ROOT -mkdir -p $RPM_BUILD_ROOT/usr/games/ -mkdir -p $RPM_BUILD_ROOT/usr/share/games/descent2/missions/ -install -m 755 d2x-sdl.sh $RPM_BUILD_ROOT/usr/games/d2x-sdl -install -m 755 d2x-gl.sh $RPM_BUILD_ROOT/usr/games/d2x-gl -install d2x-sdl.real $RPM_BUILD_ROOT/usr/games/ -install d2x-gl.real $RPM_BUILD_ROOT/usr/games/ - -%clean -rm -rf $RPM_BUILD_ROOT - -%files -%defattr(-,root,root) -%doc README NEWS INSTALL COPYING AUTHORS -%doc readme.txt cvshowto.txt license.txt compilerdefs.txt -%doc installation.txt mingw32.txt -%dir /usr/share/games/descent2 -%dir /usr/share/games/descent2/missions - -%files -n d2x-sdl -%defattr(-,root,root) -/usr/games/d2x-sdl -/usr/games/d2x-sdl.real - -%files -n d2x-gl -%defattr(-,root,root) -/usr/games/d2x-gl -/usr/games/d2x-gl.real - -%changelog -* Tue Feb 7 2002 - Paolo Ulivi -- New SPEC version for inclusion in d2x/rpm (CVS) -* Wed Nov 14 2001 - Paolo Ulivi -- New upstream version 0.1.2 (CVS) dated 11 Nov 2001 -* Sat Oct 13 2001 - Paolo Ulivi -- Release 1mdk of D2X Version 0.1.0 for Mandrake 8.0 diff --git a/texmap/.cvsignore b/texmap/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/texmap/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/texmap/Makefile.am b/texmap/Makefile.am index 1b979eef..00efedbd 100644 --- a/texmap/Makefile.am +++ b/texmap/Makefile.am @@ -1,5 +1,5 @@ noinst_LIBRARIES = libtexmap.a -INCLUDES = -I $(top_srcdir)/include -DFL1_WITH_FLAT +INCLUDES = -I $(top_srcdir)/includes -DFL1_WITH_FLAT if USE_ASM libtexmap_a_SOURCES = ntmap.c scanline.c tmapflat.c tmappent.S tmapppro.S diff --git a/texmap/ntmap.c b/texmap/ntmap.c index 54b217fd..338cbaa4 100644 --- a/texmap/ntmap.c +++ b/texmap/ntmap.c @@ -1,4 +1,3 @@ -/* $Id: ntmap.c,v 1.8 2003-03-19 19:21:34 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,114 +7,142 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * + * $Source: /cvs/cvsroot/d2x/texmap/ntmap.c,v $ + * $Revision: 1.5 $ + * $Author: bradleyb $ + * $Date: 2001-10-25 09:12:16 $ + * * Start of conversion to new texture mapper. + * + * $Log: not supported by cvs2svn $ + * Revision 1.4 2001/10/25 02:22:46 bradleyb + * adding support for runtime selection of tmap funcs + * + * Revision 1.3 2001/01/31 15:18:04 bradleyb + * Makefile and conf.h fixes + * + * Revision 1.2 2001/01/31 14:04:46 bradleyb + * Fix compiler warnings + * + * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.4 1999/10/18 00:31:55 donut + * allow FP_TMAP to be used without NO_ASM + * + * Revision 1.3 1999/08/05 22:53:41 sekmu + * + * D3D patch(es) from ADB + * + * Revision 1.2 1999/07/07 21:31:09 donut + * removed unused vars from ntmap_scanline_lighted and slightly optomized it + * + * Revision 1.1.1.1 1999/06/14 22:14:06 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.52 1995/03/14 15:13:06 john * Increased MAX_Y_Pointers to 480. - * + * * Revision 1.51 1995/02/23 14:25:09 john * Added editor tmap. - * + * * Revision 1.50 1995/02/20 18:22:58 john * Put all the externs in the assembly modules into tmap_inc.asm. - * Also, moved all the C versions of the inner loops into a new module, + * Also, moved all the C versions of the inner loops into a new module, * scanline.c. - * + * * Revision 1.49 1995/02/20 17:09:11 john * Added code so that you can build the tmapper with no assembly! - * + * * Revision 1.48 1995/01/06 11:11:30 mike * even when not in editor, have 400 lines in texture map scanline table. - * + * * Revision 1.47 1994/12/15 16:43:25 matt * Took out code only needed by editor - * + * * Revision 1.46 1994/12/09 22:35:37 mike * fix bug in before call to asm_tmap_scanline_per causing write of pixel onto past right border onto left. - * + * * Revision 1.45 1994/12/06 16:31:06 mike * fix bug in asm_tmap_scanline_matt interface. - * + * * Revision 1.44 1994/12/04 20:37:18 mike * *** empty log message *** - * + * * Revision 1.43 1994/12/02 23:30:04 mike * optimizations. - * + * * Revision 1.42 1994/11/30 00:57:43 mike * optimizations. - * + * * Revision 1.41 1994/11/28 13:34:27 mike * optimizations. - * + * * Revision 1.40 1994/11/28 01:30:01 mike * kill warning. - * + * * Revision 1.39 1994/11/28 01:28:59 mike * optimizations. - * + * * Revision 1.38 1994/11/21 14:08:07 john * Took out all multiple instead of divide code. - * + * * Revision 1.37 1994/11/19 15:21:52 mike * rip out unused code. - * + * * Revision 1.36 1994/11/14 11:42:51 mike * optimization. - * + * * Revision 1.35 1994/11/12 16:41:36 mike * *** empty log message *** - * + * * Revision 1.34 1994/11/10 21:28:41 mike * remove call to init_interface_vars_to_assembler. - * + * * Revision 1.33 1994/11/10 11:08:59 mike * detail level stuff. - * + * * Revision 1.32 1994/11/09 22:55:52 matt * Added variable Current_seg_depth for detail level optimization - * + * * Revision 1.31 1994/11/09 19:57:31 john * Added texture rle caching. - * + * * Revision 1.30 1994/11/09 19:54:48 mike * Call flat shader if Tmap_flat_flag set. - * + * * Revision 1.29 1994/11/02 21:33:31 john * Added Burger Bill's optimization, ie.. 2 muls per 8 pixels. - * + * * Revision 1.28 1994/11/02 11:32:16 john - * Added code for c callable inner loop and code to + * Added code for c callable inner loop and code to * test dividing out z0. - * + * * Revision 1.27 1994/10/28 20:54:32 matt * Added error checking - * + * * Revision 1.26 1994/10/25 11:20:20 mike * fix bug in lighting overflow checking for one scanline tall linear texture maps. - * + * * Revision 1.25 1994/08/03 15:40:33 mike * Prevent divide overflows, decrease occurrence of precision-caused glitches. - * + * * Revision 1.24 1994/07/27 09:31:16 mike * Fix concave texture map problem, decrease occurrence of unimportant int 3. - * + * * Revision 1.23 1994/06/17 12:23:31 mike * Support non-lighted texture maps. - * + * * Revision 1.22 1994/06/11 08:10:24 mike * Fix mysterious hang bug, lighting value was out of range. - * + * * Revision 1.21 1994/06/09 16:10:16 mike * Change SC2000 from constant to variable. - * + * */ #ifdef HAVE_CONFIG_H @@ -123,7 +150,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: ntmap.c,v 1.8 2003-03-19 19:21:34 btb Exp $"; +static char rcsid[] = "$Id: ntmap.c,v 1.5 2001-10-25 09:12:16 bradleyb Exp $"; #endif #define VESA 0 @@ -146,6 +173,8 @@ static char rcsid[] = "$Id: ntmap.c,v 1.8 2003-03-19 19:21:34 btb Exp $"; #include "rle.h" #include "scanline.h" +//#include "../main/textures.h" + #ifdef EDITOR #define EDITOR_TMAP 1 //if in, include extra stuff #endif @@ -182,8 +211,11 @@ int window_bottom; int window_width; int window_height; -#define MAX_Y_POINTERS 1024 - +#ifdef EDITOR_TMAP +#define MAX_Y_POINTERS 600 +#else +#define MAX_Y_POINTERS 600 +#endif int y_pointers[MAX_Y_POINTERS]; fix fix_recip[FIX_RECIP_TABLE_SIZE]; @@ -1126,3 +1158,4 @@ void draw_tmap(grs_bitmap *bp,int nverts,g3s_point **vertbuf) Lighting_on = lighting_on_save; } + diff --git a/texmap/scanline.c b/texmap/scanline.c index 46a1f22f..4a3e60eb 100644 --- a/texmap/scanline.c +++ b/texmap/scanline.c @@ -1,4 +1,3 @@ -/* $Id: scanline.c,v 1.6 2003-02-18 20:15:48 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,22 +7,49 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * + * $Source: /cvs/cvsroot/d2x/texmap/scanline.c,v $ + * $Revision: 1.5 $ + * $Author: bradleyb $ + * $Date: 2001-11-14 20:13:19 $ + * * Routines to draw the texture mapped scanlines. + * + * $Log: not supported by cvs2svn $ + * Revision 1.4 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.3 2001/10/25 02:22:46 bradleyb + * adding support for runtime selection of tmap funcs + * + * Revision 1.2 2001/01/31 15:18:04 bradleyb + * Makefile and conf.h fixes + * + * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.4 1999/10/18 00:31:01 donut + * more alpha fixes from Falk Hueffner + * + * Revision 1.3 1999/10/14 04:48:21 donut + * alpha fixes, and gl_font args + * + * Revision 1.2 1999/09/21 07:22:40 sekmu + * remove unused var warning + * + * Revision 1.1.1.1 1999/06/14 22:14:08 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.2 1995/02/20 18:23:39 john * Added new module for C versions of inner loops. - * + * * Revision 1.1 1995/02/20 17:42:27 john * Initial revision - * - * + * + * */ #ifdef HAVE_CONFIG_H @@ -31,7 +57,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: scanline.c,v 1.6 2003-02-18 20:15:48 btb Exp $"; +static char rcsid[] = "$Id: scanline.c,v 1.5 2001-11-14 20:13:19 bradleyb Exp $"; #endif #include diff --git a/texmap/scanline.h b/texmap/scanline.h index dc0d6bc9..006b9c45 100644 --- a/texmap/scanline.h +++ b/texmap/scanline.h @@ -1,4 +1,3 @@ -/* $Id: scanline.h,v 1.3 2003-02-18 20:15:48 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,22 +7,31 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* - * + * $Source: /cvs/cvsroot/d2x/texmap/scanline.h,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-10-25 02:22:46 $ + * * Prototypes for C versions of texture mapped scanlines. + * + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 22:14:10 donut + * Import of d1x 1.37 source. * - * Old Log: * Revision 1.2 1995/02/20 18:23:40 john * Added new module for C versions of inner loops. - * + * * Revision 1.1 1995/02/20 17:44:16 john * Initial revision - * - * + * + * */ diff --git a/texmap/texmapl.h b/texmap/texmapl.h index 9bc83cc5..f3f000b9 100644 --- a/texmap/texmapl.h +++ b/texmap/texmapl.h @@ -1,4 +1,3 @@ -/* $Id: texmapl.h,v 1.4 2003-03-19 19:21:34 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,59 +7,68 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* + * $Source: /cvs/cvsroot/d2x/texmap/texmapl.h,v $ + * $Revision: 1.2 $ + * $Author: bradleyb $ + * $Date: 2001-10-25 02:22:46 $ * * Local include file for texture mapper library -- NOT to be included by users. * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.1.1.1 1999/06/14 22:14:11 donut + * Import of d1x 1.37 source. + * * Revision 1.14 1995/02/20 18:23:02 john * Put all the externs in the assembly modules into tmap_inc.asm. - * Also, moved all the C versions of the inner loops into a new module, + * Also, moved all the C versions of the inner loops into a new module, * scanline.c. - * + * * Revision 1.13 1995/02/20 17:09:16 john * Added code so that you can build the tmapper with no assembly! - * + * * Revision 1.12 1994/11/28 13:34:34 mike * optimizations. - * + * * Revision 1.11 1994/11/12 16:41:27 mike * function prototype. - * + * * Revision 1.10 1994/05/24 17:30:00 mike * Prototype fix_recip, asm_tmap_scanline_lin_v. - * + * * Revision 1.9 1994/04/21 15:04:26 mike * Add prototype for texmapl.h - * + * * Revision 1.8 1994/03/31 08:34:53 mike * *** empty log message *** - * + * * Revision 1.7 1994/03/22 20:37:04 mike * *** empty log message *** - * + * * Revision 1.6 1994/03/14 15:43:03 mike * streamline code. - * + * * Revision 1.5 1994/01/31 15:43:18 mike * window_height, asm_tmap_scanline_lin_sky_v - * + * * Revision 1.4 1994/01/21 21:12:27 mike * Prototype asm_tmap_scanline_lin_sky - * + * * Revision 1.3 1994/01/14 14:01:45 mike * Add a bunch of variables. - * + * * Revision 1.2 1993/11/22 10:25:11 mike * *** empty log message *** - * + * * Revision 1.1 1993/09/08 17:29:13 mike * Initial revision - * + * * */ @@ -131,5 +139,6 @@ extern ubyte tmap_flat_shade_value; extern fix fix_recip[]; +extern void init_interface_vars_to_assembler(void); extern int prevmod(int val,int modulus); diff --git a/texmap/tmap_flt.asm b/texmap/tmap_flt.asm index b94fc531..cf45ef45 100644 --- a/texmap/tmap_flt.asm +++ b/texmap/tmap_flt.asm @@ -1,4 +1,3 @@ -; $Id: tmap_flt.asm,v 1.2 2003-02-18 20:15:48 btb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -10,10 +9,17 @@ ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; +; $Source: /cvs/cvsroot/d2x/texmap/tmap_flt.asm,v $ +; $Revision: 1.1.1.1 $ +; $Author: bradleyb $ +; $Date: 2001-01-19 03:30:16 $ ; ; Flat shader derived from texture mapper (kind of slow) ; -; Old Log: +; $Log: not supported by cvs2svn $ +; Revision 1.1.1.1 1999/06/14 22:13:53 donut +; Import of d1x 1.37 source. +; ; Revision 1.10 1995/02/20 18:22:53 john ; Put all the externs in the assembly modules into tmap_inc.asm. ; Also, moved all the C versions of the inner loops into a new module, diff --git a/texmap/tmap_inc.asm b/texmap/tmap_inc.asm index 4a9e27fe..c1ffaf27 100644 --- a/texmap/tmap_inc.asm +++ b/texmap/tmap_inc.asm @@ -1,4 +1,3 @@ -; $Id: tmap_inc.asm,v 1.3 2003-02-18 20:15:48 btb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -10,10 +9,20 @@ ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; +; $Source: /cvs/cvsroot/d2x/texmap/tmap_inc.asm,v $ +; $Revision: 1.2 $ +; $Author: bradleyb $ +; $Date: 2001-10-18 23:59:23 $ ; ; Mike's include file for the texture mapper library. ; -; Old Log: +; $Log: not supported by cvs2svn $ +; Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb +; Import of d2x-0.0.8 +; +; Revision 1.1.1.1 1999/06/14 22:13:53 donut +; Import of d1x 1.37 source. +; ; Revision 1.10 1995/02/20 18:22:52 john ; Put all the externs in the assembly modules into tmap_inc.asm. ; Also, moved all the C versions of the inner loops into a new module, diff --git a/texmap/tmap_lin.asm b/texmap/tmap_lin.asm index 152b7406..d6cfa3b1 100644 --- a/texmap/tmap_lin.asm +++ b/texmap/tmap_lin.asm @@ -1,4 +1,3 @@ -; $Id: tmap_lin.asm,v 1.2 2003-02-18 20:15:48 btb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -7,42 +6,49 @@ ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE ;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; +; $Source: /cvs/cvsroot/d2x/texmap/tmap_lin.asm,v $ +; $Revision: 1.1.1.1 $ +; $Author: bradleyb $ +; $Date: 2001-01-19 03:30:16 $ ; ; Linearly interpolating texture mapper inner loop ; -; Old Log: +; $Log: not supported by cvs2svn $ +; Revision 1.1.1.1 1999/06/14 22:13:53 donut +; Import of d1x 1.37 source. +; ; Revision 1.3 1995/02/20 18:22:57 john ; Put all the externs in the assembly modules into tmap_inc.asm. -; Also, moved all the C versions of the inner loops into a new module, +; Also, moved all the C versions of the inner loops into a new module, ; scanline.c. -; +; ; Revision 1.2 1995/02/20 17:09:10 john ; Added code so that you can build the tmapper with no assembly! -; +; ; Revision 1.1 1994/11/30 12:24:04 mike ; Initial revision -; +; ; Revision 1.6 1994/11/12 16:39:40 mike ; jae to ja. -; +; ; Revision 1.5 1994/02/10 21:24:43 matt ; Got rid of debug_on set -; +; ; Revision 1.4 1994/01/31 15:39:53 mike ; Write additional inner loop for transparency. -; +; ; Revision 1.3 1994/01/26 11:50:04 john ; Added transparency to linear unlighted texture mapper. -; +; ; Revision 1.2 1993/11/22 10:24:36 mike ; *** empty log message *** -; +; ; Revision 1.1 1993/09/08 17:29:50 mike ; Initial revision -; +; ; ; diff --git a/texmap/tmap_ll.asm b/texmap/tmap_ll.asm index 018a4ca3..45afe9c6 100644 --- a/texmap/tmap_ll.asm +++ b/texmap/tmap_ll.asm @@ -1,4 +1,3 @@ -; $Id: tmap_ll.asm,v 1.2 2003-02-18 20:15:48 btb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -10,10 +9,17 @@ ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; +; $Source: /cvs/cvsroot/d2x/texmap/tmap_ll.asm,v $ +; $Revision: 1.1.1.1 $ +; $Author: bradleyb $ +; $Date: 2001-01-19 03:30:16 $ ; ; Linear, lighted texture mapper inner loop. ; -; Old Log: +; $Log: not supported by cvs2svn $ +; Revision 1.1.1.1 1999/06/14 22:13:55 donut +; Import of d1x 1.37 source. +; ; Revision 1.10 1995/02/20 18:22:54 john ; Put all the externs in the assembly modules into tmap_inc.asm. ; Also, moved all the C versions of the inner loops into a new module, diff --git a/texmap/tmap_per.asm b/texmap/tmap_per.asm index 89f7eae7..16d127f0 100644 --- a/texmap/tmap_per.asm +++ b/texmap/tmap_per.asm @@ -1,4 +1,3 @@ -; $Id: tmap_per.asm,v 1.3 2003-02-18 20:15:48 btb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -10,10 +9,20 @@ ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; +; $Source: /cvs/cvsroot/d2x/texmap/tmap_per.asm,v $ +; $Revision: 1.2 $ +; $Author: bradleyb $ +; $Date: 2001-10-18 23:59:23 $ ; ; Perspective texture mapper inner loop. ; -; Old Log: +; $Log: not supported by cvs2svn $ +; Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb +; Import of d2x-0.0.8 +; +; Revision 1.1.1.1 1999/06/14 22:14:01 donut +; Import of d1x 1.37 source. +; ; Revision 1.26 1995/02/20 18:22:55 john ; Put all the externs in the assembly modules into tmap_inc.asm. ; Also, moved all the C versions of the inner loops into a new module, diff --git a/texmap/tmapfade.asm b/texmap/tmapfade.asm index 840b0ded..a00ee621 100644 --- a/texmap/tmapfade.asm +++ b/texmap/tmapfade.asm @@ -1,4 +1,3 @@ -; $Id: tmapfade.asm,v 1.2 2003-02-18 20:15:48 btb Exp $ ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A @@ -10,10 +9,17 @@ ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. ; +; $Source: /cvs/cvsroot/d2x/texmap/tmapfade.asm,v $ +; $Revision: 1.1.1.1 $ +; $Author: bradleyb $ +; $Date: 2001-01-19 03:30:16 $ ; ; . ; -; Old Log: +; $Log: not supported by cvs2svn $ +; Revision 1.1.1.1 1999/06/14 22:13:53 donut +; Import of d1x 1.37 source. +; ; Revision 1.6 1995/02/20 18:23:01 john ; Put all the externs in the assembly modules into tmap_inc.asm. ; Also, moved all the C versions of the inner loops into a new module, diff --git a/texmap/tmapflat.c b/texmap/tmapflat.c index 3f8a771c..312ded21 100644 --- a/texmap/tmapflat.c +++ b/texmap/tmapflat.c @@ -1,4 +1,3 @@ -/* $Id: tmapflat.c,v 1.5 2003-02-18 20:15:48 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -8,57 +7,75 @@ IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ - /* + * $Source: /cvs/cvsroot/d2x/texmap/tmapflat.c,v $ + * $Revision: 1.4 $ + * $Author: bradleyb $ + * $Date: 2001-10-25 09:12:16 $ * * Flat shader derived from texture mapper (a little slow) * - * Old Log: + * $Log: not supported by cvs2svn $ + * Revision 1.3 2001/01/31 15:18:05 bradleyb + * Makefile and conf.h fixes + * + * Revision 1.2 2001/01/31 14:04:46 bradleyb + * Fix compiler warnings + * + * Revision 1.1.1.1 2001/01/19 03:30:16 bradleyb + * Import of d2x-0.0.8 + * + * Revision 1.2 1999/10/07 21:03:29 donut + * OGL rendering of cloaked stuff + * + * Revision 1.1.1.1 1999/06/14 22:14:10 donut + * Import of d1x 1.37 source. + * * Revision 1.13 1995/02/20 18:23:24 john * Added new module for C versions of inner loops. - * + * * Revision 1.12 1995/02/20 17:09:17 john * Added code so that you can build the tmapper with no assembly! - * + * * Revision 1.11 1994/11/30 00:58:01 mike * optimizations. - * + * * Revision 1.10 1994/11/28 13:34:32 mike * optimizations. - * + * * Revision 1.9 1994/11/19 15:21:46 mike * rip out unused code. - * + * * Revision 1.8 1994/11/12 16:41:41 mike * *** empty log message *** - * + * * Revision 1.7 1994/11/09 23:05:12 mike * do lighting on texture maps which get flat shaded instead. - * + * * Revision 1.6 1994/10/06 19:53:07 matt * Added function that takes same parms as draw_tmap(), but renders flat - * + * * Revision 1.5 1994/10/06 18:38:12 john * Added the ability to fade a scanline by calling gr_upoly_tmap * with Gr_scanline_darkening_level with a value < MAX_FADE_LEVELS. - * + * * Revision 1.4 1994/05/25 18:46:32 matt * Added gr_upoly_tmap_ylr(), which generates ylr's for a polygon - * + * * Revision 1.3 1994/04/08 16:25:58 mike * Comment out some includes (of header files) * call init_interface_vars_to_assembler. - * + * * Revision 1.2 1994/03/31 08:33:44 mike * Fixup flat shading version of texture mapper (get it?) * (Or maybe not, I admit to not testing my code...hahahah!) - * + * * Revision 1.1 1993/09/08 17:29:10 mike * Initial revision - * + * * */ diff --git a/texmap/tmappent.S b/texmap/tmappent.S index 386433bb..9c5ac6b7 100644 --- a/texmap/tmappent.S +++ b/texmap/tmappent.S @@ -1,4 +1,3 @@ -/// $Id: tmappent.S,v 1.4 2003-02-18 20:15:48 btb Exp $ /// tmap_scanline_per - Pentium-optimized assembly version /// written by Brian Raiter, Mar 1998. /// lighting roundoff error fixed by Matt Mueller, July 1999 diff --git a/texmap/tmapppro.S b/texmap/tmapppro.S index 6efeafe4..f7b865b7 100644 --- a/texmap/tmapppro.S +++ b/texmap/tmapppro.S @@ -1,4 +1,3 @@ -/// $Id: tmapppro.S,v 1.5 2003-02-18 20:15:48 btb Exp $ /// tmap_scanline_per - Pentium-Pro-optimized assembly version /// written by Brian Raiter, Mar 1998. /// lighting roundoff error fixed by Matt Mueller, July 1999 diff --git a/tools/cvs2cl/cvs2cl.pl b/tools/cvs2cl/cvs2cl.pl new file mode 100644 index 00000000..820b5ece --- /dev/null +++ b/tools/cvs2cl/cvs2cl.pl @@ -0,0 +1,1787 @@ +#!/bin/sh +exec perl -w -x $0 ${1+"$@"} # -*- mode: perl; perl-indent-level: 2; -*- +#!perl -w + +############################################################## +### ### +### cvs2cl.pl: produce ChangeLog(s) from `cvs log` output. ### +### ### +############################################################## + +## $Revision: 1.1 $ +## $Date: 2001-01-24 11:20:22 $ +## $Author: bradleyb $ +## +## (C) 1999 Karl Fogel , under the GNU GPL. +## +## (Extensively hacked on by Melissa O'Neill .) +## +## cvs2cl.pl is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## cvs2cl.pl is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You may have received a copy of the GNU General Public License +## along with cvs2cl.pl; see the file COPYING. If not, write to the +## Free Software Foundation, Inc., 59 Temple Place - Suite 330, +## Boston, MA 02111-1307, USA. + + + +use strict; +use Text::Wrap; +use Time::Local; +use File::Basename; + + +# The Plan: +# +# Read in the logs for multiple files, spit out a nice ChangeLog that +# mirrors the information entered during `cvs commit'. +# +# The problem presents some challenges. In an ideal world, we could +# detect files with the same author, log message, and checkin time -- +# each would be a changelog entry. +# We'd sort them; and spit them out. Unfortunately, CVS is *not atomic* +# so checkins can span a range of times. Also, the directory structure +# could be hierarchical. +# +# Another question is whether we really want to have the ChangeLog +# exactly reflect commits. An author could issue two related commits, +# with different log entries, reflecting a single logical change to the +# source. GNU style ChangeLogs group these under a single author/date. +# We try to do the same. +# +# So, we parse the output of `cvs log', storing log messages in a +# multilevel hash that stores the mapping: +# directory => author => time => message => filelist +# As we go, we notice "nearby" commit times and store them together +# (i.e., under the same timestamp), so they appear in the same log +# entry. +# +# When we've read all the logs, we twist this mapping into +# a time => author => message => filelist mapping for each directory. +# +# If we're not using the `--distributed' flag, the directory is always +# considered to be `./', even as descend into subdirectories. + + +############### Globals ################ + + +# What we run to generate it: +my $Log_Source_Command = "cvs log"; + +# In case we have to print it out: +my $VERSION = '$Revision: 1.1 $'; +$VERSION =~ s/\S+\s+(\S+)\s+\S+/$1/; + +## Vars set by options: + +# Print debugging messages? +my $Debug = 0; + +# Just show version and exit? +my $Print_Version = 0; + +# Just print usage message and exit? +my $Print_Usage = 0; + +# Single top-level ChangeLog, or one per subdirectory? +my $Distributed = 0; + +# What file should we generate (defaults to "ChangeLog")? +my $Log_File_Name = "ChangeLog"; + +# Expand usernames to email addresses based on a map file? +my $User_Map_File = ""; + +# Output to a file or to stdout? +my $Output_To_Stdout = 0; + +# Eliminate empty log messages? +my $Prune_Empty_Msgs = 0; + +# Don't call Text::Wrap on the body of the message +my $No_Wrap = 0; + +# Separates header from log message. Code assumes it is either " " or +# "\n\n", so if there's ever an option to set it to something else, +# make sure to go through all conditionals that use this var. +my $After_Header = " "; + +# Format more for programs than for humans. +my $XML_Output = 0; + +# Do some special tweaks for log data that was written in FSF +# ChangeLog style. +my $FSF_Style = 0; + +# Show times in UTC instead of local time +my $UTC_Times = 0; + +# Show day of week in output? +my $Show_Day_Of_Week = 0; + +# Show revision numbers in output? +my $Show_Revisions = 0; + +# Show tags (symbolic names) in output? +my $Show_Tags = 0; + +# Show branches by symbolic name in output? +my $Show_Branches = 0; + +# Show only revisions on these branches or their ancestors. +my @Follow_Branches; + +# Don't bother with files matching this regexp. +my @Ignore_Files; + +# How exactly we match entries. We definitely want "o", +# and user might add "i" by using --case-insensitive option. +my $Case_Insensitive = 0; + +# Maybe only show log messages matching a certain regular expression. +my $Regexp_Gate = ""; + +# Pass this global option string along to cvs, to the left of `log': +my $Global_Opts = ""; + +# Pass this option string along to the cvs log subcommand: +my $Command_Opts = ""; + +# Read log output from stdin instead of invoking cvs log? +my $Input_From_Stdin = 0; + +# Don't show filenames in output. +my $Hide_Filenames = 0; + +# Max checkin duration. CVS checkin is not atomic, so we may have checkin +# times that span a range of time. We assume that checkins will last no +# longer than $Max_Checkin_Duration seconds, and that similarly, no +# checkins will happen from the same users with the same message less +# than $Max_Checkin_Duration seconds apart. +my $Max_Checkin_Duration = 180; + +# What to put at the front of [each] ChangeLog. +my $ChangeLog_Header = ""; + +## end vars set by options. + +# In 'cvs log' output, one long unbroken line of equal signs separates +# files: +my $file_separator = "=======================================" + . "======================================"; + +# In 'cvs log' output, a shorter line of dashes separates log messages +# within a file: +my $logmsg_separator = "----------------------------"; + + +############### End globals ############ + + + + +&parse_options (); +&derive_change_log (); + + + +### Everything below is subroutine definitions. ### + +# Fills up a ChangeLog structure in the current directory. +sub derive_change_log () +{ + # See "The Plan" above for a full explanation. + + my %grand_poobah; + + my $file_full_path; + my $time; + my $revision; + my $author; + my $msg_txt; + my $detected_file_separator; + + # We might be expanding usernames + my %usermap; + + # In general, it's probably not very maintainable to use state + # variables like this to tell the loop what it's doing at any given + # moment, but this is only the first one, and if we never have more + # than a few of these, it's okay. + my $collecting_symbolic_names = 0; + my %symbolic_names; # Where tag names get stored. + my %branch_names; # We'll grab branch names while we're at it. + my %branch_numbers; # Save some revisions for @Follow_Branches + my @branch_roots; # For showing which files are branch ancestors. + + # Bleargh. Compensate for a deficiency of custom wrapping. + if (($After_Header ne " ") and $FSF_Style) + { + $After_Header .= "\t"; + } + + if (! $Input_From_Stdin) { + open (LOG_SOURCE, "$Log_Source_Command |") + or die "unable to run \"${Log_Source_Command}\""; + } + else { + open (LOG_SOURCE, "-") or die "unable to open stdin for reading"; + } + + %usermap = &maybe_read_user_map_file (); + + while () + { + # If on a new file and don't see filename, skip until we find it, and + # when we find it, grab it. + if ((! (defined $file_full_path)) and /^Working file: (.*)/) + { + $file_full_path = $1; + if (@Ignore_Files) + { + my $base; + ($base, undef, undef) = fileparse ($file_full_path); + # Ouch, I wish trailing operators in regexps could be + # evaluated on the fly! + if ($Case_Insensitive) { + if (grep ($file_full_path =~ m|$_|i, @Ignore_Files)) { + undef $file_full_path; + } + } + elsif (grep ($file_full_path =~ m|$_|, @Ignore_Files)) { + undef $file_full_path; + } + } + next; + } + + # Just spin wheels if no file defined yet. + next if (! $file_full_path); + + # Collect tag names in case we're asked to print them in the output. + if (/^symbolic names:$/) { + $collecting_symbolic_names = 1; + next; # There's no more info on this line, so skip to next + } + if ($collecting_symbolic_names) + { + # All tag names are listed with whitespace in front in cvs log + # output; so if see non-whitespace, then we're done collecting. + if (/^\S/) { + $collecting_symbolic_names = 0; + } + else # we're looking at a tag name, so parse & store it + { + # According to the Cederqvist manual, in node "Tags", tag + # names must start with an uppercase or lowercase letter and + # can contain uppercase and lowercase letters, digits, `-', + # and `_'. However, it's not our place to enforce that, so + # we'll allow anything CVS hands us to be a tag: + /^\s+([^:]+): ([\d.]+)$/; + my $tag_name = $1; + my $tag_rev = $2; + + # A branch number either has an odd number of digit sections + # (and hence an even number of dots), or has ".0." as the + # second-to-last digit section. Test for these conditions. + my $real_branch_rev = ""; + if (($tag_rev =~ /^(\d+\.\d+\.)+\d+$/) # Even number of dots... + and (! ($tag_rev =~ /^(1\.)+1$/))) # ...but not "1.[1.]1" + { + $real_branch_rev = $tag_rev; + } + elsif ($tag_rev =~ /(\d+\.(\d+\.)+)0.(\d+)/) # Has ".0." + { + $real_branch_rev = $1 . $3; + } + # If we got a branch, record its number. + if ($real_branch_rev) + { + $branch_names{$real_branch_rev} = $tag_name; + if (@Follow_Branches) { + if (grep ($_ eq $tag_name, @Follow_Branches)) { + $branch_numbers{$tag_name} = $real_branch_rev; + } + } + } + else { + # Else it's just a regular (non-branch) tag. + push (@{$symbolic_names{$tag_rev}}, $tag_name); + } + } + } + # End of code for collecting tag names. + + # If have file name, but not revision, and see revision, then grab + # it. (We collect unconditionally, even though we may or may not + # ever use it.) + if ((! (defined $revision)) and (/^revision (\d+\.[\d.]+)/)) + { + $revision = $1; + + if (@Follow_Branches) + { + foreach my $branch (@Follow_Branches) + { + # Special case for following trunk revisions + if (($branch =~ /^trunk$/i) and ($revision =~ /^[0-9]+\.[0-9]+$/)) + { + goto dengo; + } + + my $branch_number = $branch_numbers{$branch}; + if ($branch_number) + { + # Are we on one of the follow branches or an ancestor of + # same? + # + # If this revision is a prefix of the branch number, or + # possibly is less in the minormost number, OR if this + # branch number is a prefix of the revision, then yes. + # Otherwise, no. + # + # So below, we determine if any of those conditions are + # met. + + # Trivial case: is this revision on the branch? + # (Compare this way to avoid regexps that screw up Emacs + # indentation, argh.) + if ((substr ($revision, 0, ((length ($branch_number)) + 1))) + eq ($branch_number . ".")) + { + goto dengo; + } + # Non-trivial case: check if rev is ancestral to branch + elsif ((length ($branch_number)) > (length ($revision))) + { + $revision =~ /^((?:\d+\.)+)(\d+)$/; + my $r_left = $1; # still has the trailing "." + my $r_end = $2; + + $branch_number =~ /^((?:\d+\.)+)(\d+)\.\d+$/; + my $b_left = $1; # still has trailing "." + my $b_mid = $2; # has no trailing "." + + if (($r_left eq $b_left) + && ($r_end <= $b_mid)) + { + goto dengo; + } + } + } + } + } + else # (! @Follow_Branches) + { + next; + } + + # Else we are following branches, but this revision isn't on the + # path. So skip it. + undef $revision; + dengo: + next; + } + + # If we don't have a revision right now, we couldn't possibly + # be looking at anything useful. + if (! (defined ($revision))) { + $detected_file_separator = /^$file_separator$/o; + if ($detected_file_separator) { + # No revisions for this file; can happen, e.g. "cvs log -d DATE" + goto CLEAR; + } + else { + next; + } + } + + # If have file name but not date and author, and see date or + # author, then grab them: + unless (defined $time) + { + if (/^date: .*/) + { + ($time, $author) = &parse_date_and_author ($_); + if (defined ($usermap{$author}) and $usermap{$author}) { + $author = $usermap{$author}; + } + } + else { + $detected_file_separator = /^$file_separator$/o; + if ($detected_file_separator) { + # No revisions for this file; can happen, e.g. "cvs log -d DATE" + goto CLEAR; + } + } + # If the date/time/author hasn't been found yet, we couldn't + # possibly care about anything we see. So skip: + next; + } + + # A "branches: ..." line here indicates that one or more branches + # are rooted at this revision. If we're showing branches, then we + # want to show that fact as well, so we collect all the branches + # that this is the latest ancestor of and store them in + # @branch_roots. Just for reference, the format of the line we're + # seeing at this point is: + # + # branches: 1.5.2; 1.5.4; ...; + # + # Okay, here goes: + + if (/^branches:\s+(.*);$/) + { + if ($Show_Branches) + { + my $lst = $1; + $lst =~ s/(1\.)+1;|(1\.)+1$//; # ignore the trivial branch 1.1.1 + if ($lst) { + @branch_roots = split (/;\s+/, $lst); + } + else { + undef @branch_roots; + } + next; + } + else + { + # Ugh. This really bothers me. Suppose we see a log entry + # like this: + # + # ---------------------------- + # revision 1.1 + # date: 1999/10/17 03:07:38; author: jrandom; state: Exp; + # branches: 1.1.2; + # Intended first line of log message begins here. + # ---------------------------- + # + # The question is, how we can tell the difference between that + # log message and a *two*-line log message whose first line is + # + # "branches: 1.1.2;" + # + # See the problem? The output of "cvs log" is inherently + # ambiguous. + # + # For now, we punt: we liberally assume that people don't + # write log messages like that, and just toss a "branches:" + # line if we see it but are not showing branches. I hope no + # one ever loses real log data because of this. + next; + } + } + + # If have file name, time, and author, then we're just grabbing + # log message texts: + $detected_file_separator = /^$file_separator$/o; + if ($detected_file_separator && ! (defined $revision)) { + # No revisions for this file; can happen, e.g. "cvs log -d DATE" + goto CLEAR; + } + unless ($detected_file_separator || /^$logmsg_separator$/o) + { + $msg_txt .= $_; # Normally, just accumulate the message... + next; + } + # ... until a msg separator is encountered: + # Ensure the message contains something: + if ((! $msg_txt) + || ($msg_txt =~ /^\s*\.\s*$|^\s*$/) + || ($msg_txt =~ /\*\*\* empty log message \*\*\*/)) + { + if ($Prune_Empty_Msgs) { + goto CLEAR; + } + # else + $msg_txt = "[no log message]\n"; + } + + ### Store it all in the Grand Poobah: + { + my $dir_key; # key into %grand_poobah + my %qunk; # complicated little jobbie, see below + + # Each revision of a file has a little data structure (a `qunk') + # associated with it. That data structure holds not only the + # file's name, but any additional information about the file + # that might be needed in the output, such as the revision + # number, tags, branches, etc. The reason to have these things + # arranged in a data structure, instead of just appending them + # textually to the file's name, is that we may want to do a + # little rearranging later as we write the output. For example, + # all the files on a given tag/branch will go together, followed + # by the tag in parentheses (so trunk or otherwise non-tagged + # files would go at the end of the file list for a given log + # message). This rearrangement is a lot easier to do if we + # don't have to reparse the text. + # + # A qunk looks like this: + # + # { + # filename => "hello.c", + # revision => "1.4.3.2", + # time => a timegm() return value (moment of commit) + # tags => [ "tag1", "tag2", ... ], + # branch => "branchname" # There should be only one, right? + # branchroots => [ "branchtag1", "branchtag2", ... ] + # } + + if ($Distributed) { + # Just the basename, don't include the path. + ($qunk{'filename'}, $dir_key, undef) = fileparse ($file_full_path); + } + else { + $dir_key = "./"; + $qunk{'filename'} = $file_full_path; + } + + # This may someday be used in a more sophisticated calculation + # of what other files are involved in this commit. For now, we + # don't use it, because the common-commit-detection algorithm is + # hypothesized to be "good enough" as it stands. + $qunk{'time'} = $time; + + # We might be including revision numbers and/or tags and/or + # branch names in the output. Most of the code from here to + # loop-end deals with organizing these in qunk. + + $qunk{'revision'} = $revision; + + # Grab the branch, even though we may or may not need it: + $qunk{'revision'} =~ /((?:\d+\.)+)\d+/; + my $branch_prefix = $1; + $branch_prefix =~ s/\.$//; # strip off final dot + if ($branch_names{$branch_prefix}) { + $qunk{'branch'} = $branch_names{$branch_prefix}; + } + + # If there's anything in the @branch_roots array, then this + # revision is the root of at least one branch. We'll display + # them as branch names instead of revision numbers, the + # substitution for which is done directly in the array: + if (@branch_roots) { + my @roots = map { $branch_names{$_} } @branch_roots; + $qunk{'branchroots'} = \@roots; + } + + # Save tags too. + if (defined ($symbolic_names{$revision})) { + $qunk{'tags'} = $symbolic_names{$revision}; + delete $symbolic_names{$revision}; + } + + # Add this file to the list + # (We use many spoonfuls of autovivication magic. Hashes and arrays + # will spring into existence if they aren't there already.) + + &debug ("(pushing log msg for ${dir_key}$qunk{'filename'})\n"); + + # Store with the files in this commit. Later we'll loop through + # again, making sure that revisions with the same log message + # and nearby commit times are grouped together as one commit. + push (@{$grand_poobah{$dir_key}{$author}{$time}{$msg_txt}}, \%qunk); + } + + CLEAR: + # Make way for the next message + undef $msg_txt; + undef $time; + undef $revision; + undef $author; + undef @branch_roots; + + # Maybe even make way for the next file: + if ($detected_file_separator) { + undef $file_full_path; + undef %branch_names; + undef %branch_numbers; + undef %symbolic_names; + } + } + + close (LOG_SOURCE); + + ### Process each ChangeLog + + while (my ($dir,$authorhash) = each %grand_poobah) + { + &debug ("DOING DIR: $dir\n"); + + # Here we twist our hash around, from being + # author => time => message => filelist + # in %$authorhash to + # time => author => message => filelist + # in %changelog. + # + # This is also where we merge entries. The algorithm proceeds + # through the timeline of the changelog with a sliding window of + # $Max_Checkin_Duration seconds; within that window, entries that + # have the same log message are merged. + # + # (To save space, we zap %$authorhash after we've copied + # everything out of it.) + + my %changelog; + while (my ($author,$timehash) = each %$authorhash) + { + my $lasttime; + my %stamptime; + foreach my $time (sort {$main::a <=> $main::b} (keys %$timehash)) + { + my $msghash = $timehash->{$time}; + while (my ($msg,$qunklist) = each %$msghash) + { + my $stamptime = $stamptime{$msg}; + if ((defined $stamptime) + and (($time - $stamptime) < $Max_Checkin_Duration) + and (defined $changelog{$stamptime}{$author}{$msg})) + { + push(@{$changelog{$stamptime}{$author}{$msg}}, @$qunklist); + } + else { + $changelog{$time}{$author}{$msg} = $qunklist; + $stamptime{$msg} = $time; + } + } + } + } + undef (%$authorhash); + + ### Now we can write out the ChangeLog! + + my ($logfile_here, $logfile_bak, $tmpfile); + + if (! $Output_To_Stdout) { + $logfile_here = $dir . $Log_File_Name; + $logfile_here =~ s/^\.\/\//\//; # fix any leading ".//" problem + $tmpfile = "${logfile_here}.cvs2cl$$.tmp"; + $logfile_bak = "${logfile_here}.bak"; + + open (LOG_OUT, ">$tmpfile") or die "Unable to open \"$tmpfile\""; + } + else { + open (LOG_OUT, ">-") or die "Unable to open stdout for writing"; + } + + print LOG_OUT $ChangeLog_Header; + + if ($XML_Output) { + print LOG_OUT "\n\n" + . "\n\n"; + } + + foreach my $time (sort {$main::b <=> $main::a} (keys %changelog)) + { + my $authorhash = $changelog{$time}; + while (my ($author,$mesghash) = each %$authorhash) + { + # If XML, escape in outer loop to avoid compound quoting: + if ($XML_Output) { + $author = &xml_escape ($author); + } + + while (my ($msg,$qunklist) = each %$mesghash) + { + my $files = &pretty_file_list ($qunklist); + my $header_line; # date and author + my $body; # see below + my $wholething; # $header_line + $body + + # Set up the date/author line. + # kff todo: do some more XML munging here, on the header + # part of the entry: + my ($ignore,$min,$hour,$mday,$mon,$year,$wday) + = $UTC_Times ? gmtime($time) : localtime($time); + + # XML output includes everything else, we might as well make + # it always include Day Of Week too, for consistency. + if ($Show_Day_Of_Week or $XML_Output) { + $wday = ("Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday")[$wday]; + $wday = ($XML_Output) ? "${wday}\n" : " $wday"; + } + else { + $wday = ""; + } + + if ($XML_Output) { + $header_line = + sprintf ("%4u-%02u-%02u\n" + . "${wday}" + . "\n" + . "%s\n", + $year+1900, $mon+1, $mday, $hour, $min, $author); + } + else { + $header_line = + sprintf ("%4u-%02u-%02u${wday} %02u:%02u %s\n\n", + $year+1900, $mon+1, $mday, $hour, $min, $author); + } + + # Reshape the body according to user preferences. + if ($XML_Output) + { + $msg = &preprocess_msg_text ($msg); + $body = $files . $msg; + } + elsif ($No_Wrap) + { + $msg = &preprocess_msg_text ($msg); + $files = wrap ("\t", " ", "$files"); + $msg =~ s/\n(.*)/\n\t$1/g; + unless ($After_Header eq " ") { + $msg =~ s/^(.*)/\t$1/g; + } + $body = $files . $After_Header . $msg; + } + else # do wrapping, either FSF-style or regular + { + if ($FSF_Style) + { + $files = wrap ("\t", " ", "$files"); + + my $files_last_line_len = 0; + if ($After_Header eq " ") + { + $files_last_line_len = &last_line_len ($files); + $files_last_line_len += 1; # for $After_Header + } + + $msg = &wrap_log_entry + ($msg, "\t", 69 - $files_last_line_len, 69); + $body = $files . $After_Header . $msg; + } + else # not FSF-style + { + $msg = &preprocess_msg_text ($msg); + $body = $files . $After_Header . $msg; + $body = wrap ("\t", " ", "$body"); + } + } + + $wholething = $header_line . $body; + + if ($XML_Output) { + $wholething = "\n${wholething}\n"; + } + + # One last check: make sure it passes the regexp test, if the + # user asked for that. We have to do it here, so that the + # test can match against information in the header as well + # as in the text of the log message. + + # How annoying to duplicate so much code just because I + # can't figure out a way to evaluate scalars on the trailing + # operator portion of a regular expression. Grrr. + if ($Case_Insensitive) { + unless ($Regexp_Gate && ($wholething !~ /$Regexp_Gate/oi)) { + print LOG_OUT "${wholething}\n"; + } + } + else { + unless ($Regexp_Gate && ($wholething !~ /$Regexp_Gate/o)) { + print LOG_OUT "${wholething}\n"; + } + } + } + } + } + + if ($XML_Output) { + print LOG_OUT "\n"; + } + + close (LOG_OUT); + + if (! $Output_To_Stdout) + { + if (-f $logfile_here) { + rename ($logfile_here, $logfile_bak); + } + rename ($tmpfile, $logfile_here); + } + } +} + + +sub parse_date_and_author () +{ + # Parses the date/time and author out of a line like: + # + # date: 1999/02/19 23:29:05; author: apharris; state: Exp; + + my $line = shift; + + my ($year, $mon, $mday, $hours, $min, $secs, $author) = $line =~ + m#(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);\s+author:\s+([^;]+);# + or die "Couldn't parse date ``$line''"; + die "Bad date or Y2K issues" unless ($year > 1969 and $year < 2258); + # Kinda arbitrary, but useful as a sanity check + my $time = timegm($secs,$min,$hours,$mday,$mon-1,$year-1900); + + return ($time, $author); +} + + +# Here we take a bunch of qunks and convert them into printed +# summary that will include all the information the user asked for. +sub pretty_file_list () +{ + if ($Hide_Filenames and (! $XML_Output)) { + return ""; + } + + my $qunksref = shift; + my @qunkrefs = @$qunksref; + my @filenames; + my $beauty = ""; # The accumulating header string for this entry. + my %non_unanimous_tags; # Tags found in a proper subset of qunks + my %unanimous_tags; # Tags found in all qunks + my %all_branches; # Branches found in any qunk + my $common_dir = undef; # Dir prefix common to all files ("" if none) + my $fbegun = 0; # Did we begin printing filenames yet? + + # First, loop over the qunks gathering all the tag/branch names. + # We'll put them all in non_unanimous_tags, and take out the + # unanimous ones later. + foreach my $qunkref (@qunkrefs) + { + # Keep track of whether all the files in this commit were in the + # same directory, and memorize it if so. We can make the output a + # little more compact by mentioning the directory only once. + if ((scalar (@qunkrefs)) > 1) + { + if (! (defined ($common_dir))) + { + my ($base, $dir); + ($base, $dir, undef) = fileparse ($$qunkref{'filename'}); + + if ((! (defined ($dir))) # this first case is sheer paranoia + or ($dir eq "") + or ($dir eq "./") + or ($dir eq ".\\")) + { + $common_dir = ""; + } + else + { + $common_dir = $dir; + } + } + elsif ($common_dir ne "") + { + # Already have a common dir prefix, so how much of it can we preserve? + $common_dir = &common_path_prefix ($$qunkref{'filename'}, $common_dir); + } + } + else # only one file in this entry anyway, so common dir not an issue + { + $common_dir = ""; + } + + if (defined ($$qunkref{'branch'})) { + $all_branches{$$qunkref{'branch'}} = 1; + } + if (defined ($$qunkref{'tags'})) { + foreach my $tag (@{$$qunkref{'tags'}}) { + $non_unanimous_tags{$tag} = 1; + } + } + } + + # Any tag held by all qunks will be printed specially... but only if + # there are multiple qunks in the first place! + if ((scalar (@qunkrefs)) > 1) { + foreach my $tag (keys (%non_unanimous_tags)) { + my $everyone_has_this_tag = 1; + foreach my $qunkref (@qunkrefs) { + if ((! (defined ($$qunkref{'tags'}))) + or (! (grep ($_ eq $tag, @{$$qunkref{'tags'}})))) { + $everyone_has_this_tag = 0; + } + } + if ($everyone_has_this_tag) { + $unanimous_tags{$tag} = 1; + delete $non_unanimous_tags{$tag}; + } + } + } + + if ($XML_Output) + { + # If outputting XML, then our task is pretty simple, because we + # don't have to detect common dir, common tags, branch prefixing, + # etc. We just output exactly what we have, and don't worry about + # redundancy or readability. + + foreach my $qunkref (@qunkrefs) + { + my $filename = $$qunkref{'filename'}; + my $revision = $$qunkref{'revision'}; + my $tags = $$qunkref{'tags'}; + my $branch = $$qunkref{'branch'}; + my $branchroots = $$qunkref{'branchroots'}; + + $filename = &xml_escape ($filename); # probably paranoia + $revision = &xml_escape ($revision); # definitely paranoia + + $beauty .= "\n"; + $beauty .= "${filename}\n"; + $beauty .= "${revision}\n"; + if ($branch) { + $branch = &xml_escape ($branch); # more paranoia + $beauty .= "${branch}\n"; + } + foreach my $tag (@$tags) { + $tag = &xml_escape ($tag); # by now you're used to the paranoia + $beauty .= "${tag}\n"; + } + foreach my $root (@$branchroots) { + $root = &xml_escape ($root); # which is good, because it will continue + $beauty .= "${root}\n"; + } + $beauty .= "\n"; + } + + # Theoretically, we could go home now. But as long as we're here, + # let's print out the common_dir and utags, as a convenience to + # the receiver (after all, earlier code calculated that stuff + # anyway, so we might as well take advantage of it). + + if ((scalar (keys (%unanimous_tags))) > 1) { + foreach my $utag ((keys (%unanimous_tags))) { + $utag = &xml_escape ($utag); # the usual paranoia + $beauty .= "${utag}\n"; + } + } + if ($common_dir) { + $common_dir = &xml_escape ($common_dir); + $beauty .= "${common_dir}\n"; + } + + # That's enough for XML, time to go home: + return $beauty; + } + + # Else not XML output, so complexly compactify for chordate + # consumption. At this point we have enough global information + # about all the qunks to organize them non-redundantly for output. + + if ($common_dir) { + # Note that $common_dir still has its trailing slash + $beauty .= "$common_dir: "; + } + + if ($Show_Branches) + { + # For trailing revision numbers. + my @brevisions; + + foreach my $branch (keys (%all_branches)) + { + foreach my $qunkref (@qunkrefs) + { + if ((defined ($$qunkref{'branch'})) + and ($$qunkref{'branch'} eq $branch)) + { + if ($fbegun) { + # kff todo: comma-delimited in XML too? Sure. + $beauty .= ", "; + } + else { + $fbegun = 1; + } + my $fname = substr ($$qunkref{'filename'}, length ($common_dir)); + $beauty .= $fname; + $$qunkref{'printed'} = 1; # Just setting a mark bit, basically + + if ($Show_Tags && (defined @{$$qunkref{'tags'}})) { + my @tags = grep ($non_unanimous_tags{$_}, @{$$qunkref{'tags'}}); + if (@tags) { + $beauty .= " (tags: "; + $beauty .= join (', ', @tags); + $beauty .= ")"; + } + } + + if ($Show_Revisions) { + # Collect the revision numbers' last components, but don't + # print them -- they'll get printed with the branch name + # later. + $$qunkref{'revision'} =~ /.+\.([\d]+)$/; + push (@brevisions, $1); + + # todo: we're still collecting branch roots, but we're not + # showing them anywhere. If we do show them, it would be + # nifty to just call them revision "0" on a the branch. + # Yeah, that's the ticket. + } + } + } + $beauty .= " ($branch"; + if (@brevisions) { + if ((scalar (@brevisions)) > 1) { + $beauty .= ".["; + $beauty .= (join (',', @brevisions)); + $beauty .= "]"; + } + else { + $beauty .= ".$brevisions[0]"; + } + } + $beauty .= ")"; + } + } + + # Okay; any qunks that were done according to branch are taken care + # of, and marked as printed. Now print everyone else. + + foreach my $qunkref (@qunkrefs) + { + next if (defined ($$qunkref{'printed'})); # skip if already printed + + if ($fbegun) { + $beauty .= ", "; + } + else { + $fbegun = 1; + } + $beauty .= substr ($$qunkref{'filename'}, length ($common_dir)); + # todo: Shlomo's change was this: + # $beauty .= substr ($$qunkref{'filename'}, + # (($common_dir eq "./") ? "" : length ($common_dir))); + $$qunkref{'printed'} = 1; # Set a mark bit. + + if ($Show_Revisions || $Show_Tags) + { + my $started_addendum = 0; + + if ($Show_Revisions) { + $started_addendum = 1; + $beauty .= " ("; + $beauty .= "$$qunkref{'revision'}"; + } + if ($Show_Tags && (defined $$qunkref{'tags'})) { + my @tags = grep ($non_unanimous_tags{$_}, @{$$qunkref{'tags'}}); + if ((scalar (@tags)) > 0) { + if ($started_addendum) { + $beauty .= ", "; + } + else { + $beauty .= " (tags: "; + } + $beauty .= join (', ', @tags); + $started_addendum = 1; + } + } + if ($started_addendum) { + $beauty .= ")"; + } + } + } + + # Unanimous tags always come last. + if ($Show_Tags && %unanimous_tags) + { + $beauty .= " (utags: "; + $beauty .= join (', ', keys (%unanimous_tags)); + $beauty .= ")"; + } + + # todo: still have to take care of branch_roots? + + $beauty = "* $beauty:"; + + return $beauty; +} + + +sub common_path_prefix () +{ + my $path1 = shift; + my $path2 = shift; + + my ($dir1, $dir2); + (undef, $dir1, undef) = fileparse ($path1); + (undef, $dir2, undef) = fileparse ($path2); + + # Transmogrify Windows filenames to look like Unix. + # (It is far more likely that someone is running cvs2cl.pl under + # Windows than that they would genuinely have backslashes in their + # filenames.) + $dir1 =~ tr#\\#/#; + $dir2 =~ tr#\\#/#; + + my $accum1 = ""; + my $accum2 = ""; + my $last_common_prefix = ""; + + while ($accum1 eq $accum2) + { + $last_common_prefix = $accum1; + last if ($accum1 eq $dir1); + my ($tmp1) = split (/\//, (substr ($dir1, length ($accum1)))); + my ($tmp2) = split (/\//, (substr ($dir2, length ($accum2)))); + $accum1 .= "$tmp1/" if ((defined ($tmp1)) and $tmp1); + $accum2 .= "$tmp2/" if ((defined ($tmp2)) and $tmp2); + } + + return $last_common_prefix; +} + + +sub preprocess_msg_text () +{ + my $text = shift; + + # Strip out carriage returns (as they probably result from DOSsy editors). + $text =~ s/\r\n/\n/g; + + # If it *looks* like two newlines, make it *be* two newlines: + $text =~ s/\n\s*\n/\n\n/g; + + if ($XML_Output) + { + $text = &xml_escape ($text); + $text = "${text}\n"; + } + elsif (! $No_Wrap) + { + # Strip off lone newlines, but only for lines that don't begin with + # whitespace or a mail-quoting character, since we want to preserve + # that kind of formatting. Also don't strip newlines that follow a + # period; we handle those specially next. And don't strip + # newlines that precede an open paren. + 1 while ($text =~ s/(^|\n)([^>\s].*[^.\n])\n([^>\n])/$1$2 $3/g); + + # If a newline follows a period, make sure that when we bring up the + # bottom sentence, it begins with two spaces. + 1 while ($text =~ s/(^|\n)([^>\s].*)\n([^>\n])/$1$2 $3/g); + } + + return $text; +} + + +sub last_line_len () +{ + my $files_list = shift; + my @lines = split (/\n/, $files_list); + my $last_line = pop (@lines); + return length ($last_line); +} + + +# A custom wrap function, sensitive to some common constructs used in +# log entries. +sub wrap_log_entry () +{ + my $text = shift; # The text to wrap. + my $left_pad_str = shift; # String to pad with on the left. + + # These do NOT take left_pad_str into account: + my $length_remaining = shift; # Amount left on current line. + my $max_line_length = shift; # Amount left for a blank line. + + my $wrapped_text = ""; # The accumulating wrapped entry. + my $user_indent = ""; # Inherited user_indent from prev line. + + my $first_time = 1; # First iteration of the loop? + my $suppress_line_start_match = 0; # Set to disable line start checks. + + my @lines = split (/\n/, $text); + while (@lines) # Don't use `foreach' here, it won't work. + { + my $this_line = shift (@lines); + chomp $this_line; + + if ($this_line =~ /^(\s+)/) { + $user_indent = $1; + } + else { + $user_indent = ""; + } + + # If it matches any of the line-start regexps, print a newline now... + if ($suppress_line_start_match) + { + $suppress_line_start_match = 0; + } + elsif (($this_line =~ /^(\s*)\*\s+[a-zA-Z0-9]/) + || ($this_line =~ /^(\s*)\* [a-zA-Z0-9_\.\/\+-]+/) + || ($this_line =~ /^(\s*)\([a-zA-Z0-9_\.\/\+-]+(\)|,\s*)/) + || ($this_line =~ /^(\s+)(\S+)/) + || ($this_line =~ /^(\s*)- +/) + || ($this_line =~ /^()\s*$/) + || ($this_line =~ /^(\s*)\*\) +/) + || ($this_line =~ /^(\s*)[a-zA-Z0-9](\)|\.|\:) +/)) + { + # Make a line break immediately, unless header separator is set + # and this line is the first line in the entry, in which case + # we're getting the blank line for free already and shouldn't + # add an extra one. + unless (($After_Header ne " ") and ($first_time)) + { + if ($this_line =~ /^()\s*$/) { + $suppress_line_start_match = 1; + $wrapped_text .= "\n${left_pad_str}"; + } + + $wrapped_text .= "\n${left_pad_str}"; + } + + $length_remaining = $max_line_length - (length ($user_indent)); + } + + # Now that any user_indent has been preserved, strip off leading + # whitespace, so up-folding has no ugly side-effects. + $this_line =~ s/^\s*//; + + # Accumulate the line, and adjust parameters for next line. + my $this_len = length ($this_line); + if ($this_len == 0) + { + # Blank lines should cancel any user_indent level. + $user_indent = ""; + $length_remaining = $max_line_length; + } + elsif ($this_len >= $length_remaining) # Line too long, try breaking it. + { + # Walk backwards from the end. At first acceptable spot, break + # a new line. + my $idx = $length_remaining - 1; + if ($idx < 0) { $idx = 0 }; + while ($idx > 0) + { + if (substr ($this_line, $idx, 1) =~ /\s/) + { + my $line_now = substr ($this_line, 0, $idx); + my $next_line = substr ($this_line, $idx); + $this_line = $line_now; + + # Clean whitespace off the end. + chomp $this_line; + + # The current line is ready to be printed. + $this_line .= "\n${left_pad_str}"; + + # Make sure the next line is allowed full room. + $length_remaining = $max_line_length - (length ($user_indent)); + + # Strip next_line, but then preserve any user_indent. + $next_line =~ s/^\s*//; + + # Sneak a peek at the user_indent of the upcoming line, so + # $next_line (which will now precede it) can inherit that + # indent level. Otherwise, use whatever user_indent level + # we currently have, which might be none. + my $next_next_line = shift (@lines); + if ((defined ($next_next_line)) && ($next_next_line =~ /^(\s+)/)) { + $next_line = $1 . $next_line if (defined ($1)); + # $length_remaining = $max_line_length - (length ($1)); + $next_next_line =~ s/^\s*//; + } + else { + $next_line = $user_indent . $next_line; + } + if (defined ($next_next_line)) { + unshift (@lines, $next_next_line); + } + unshift (@lines, $next_line); + + # Our new next line might, coincidentally, begin with one of + # the line-start regexps, so we temporarily turn off + # sensitivity to that until we're past the line. + $suppress_line_start_match = 1; + + last; + } + else + { + $idx--; + } + } + + if ($idx == 0) + { + # We bottomed out because the line is longer than the + # available space. But that could be because the space is + # small, or because the line is longer than even the maximum + # possible space. Handle both cases below. + + if ($length_remaining == ($max_line_length - (length ($user_indent)))) + { + # The line is simply too long -- there is no hope of ever + # breaking it nicely, so just insert it verbatim, with + # appropriate padding. + $this_line = "\n${left_pad_str}${this_line}"; + } + else + { + # Can't break it here, but may be able to on the next round... + unshift (@lines, $this_line); + $length_remaining = $max_line_length - (length ($user_indent)); + $this_line = "\n${left_pad_str}"; + } + } + } + else # $this_len < $length_remaining, so tack on what we can. + { + # Leave a note for the next iteration. + $length_remaining = $length_remaining - $this_len; + + if ($this_line =~ /\.$/) + { + $this_line .= " "; + $length_remaining -= 2; + } + else # not a sentence end + { + $this_line .= " "; + $length_remaining -= 1; + } + } + + # Unconditionally indicate that loop has run at least once. + $first_time = 0; + + $wrapped_text .= "${user_indent}${this_line}"; + } + + # One last bit of padding. + $wrapped_text .= "\n"; + + return $wrapped_text; +} + + +sub xml_escape () +{ + my $txt = shift; + $txt =~ s/&/&/g; + $txt =~ s//>/g; + return $txt; +} + + +sub maybe_read_user_map_file () +{ + my %expansions; + + if ($User_Map_File) + { + open (MAPFILE, "<$User_Map_File") + or die ("Unable to open $User_Map_File ($!)"); + + while () + { + next if /^\s*#/; # Skip comment lines. + next if not /:/; # Skip lines without colons. + + # It is now safe to split on ':'. + my ($username, $expansion) = split ':'; + chomp $expansion; + $expansion =~ s/^'(.*)'$/$1/; + $expansion =~ s/^"(.*)"$/$1/; + + # If it looks like the expansion has a real name already, then + # we toss the username we got from CVS log. Otherwise, keep + # it to use in combination with the email address. + + if ($expansion =~ /^\s*<{0,1}\S+@.*/) { + # Also, add angle brackets if none present + if (! ($expansion =~ /<\S+@\S+>/)) { + $expansions{$username} = "$username <$expansion>"; + } + else { + $expansions{$username} = "$username $expansion"; + } + } + else { + $expansions{$username} = $expansion; + } + } + + close (MAPFILE); + } + + return %expansions; +} + + +sub parse_options () +{ + # Check this internally before setting the global variable. + my $output_file; + + # If this gets set, we encountered unknown options and will exit at + # the end of this subroutine. + my $exit_with_admonishment = 0; + + while (my $arg = shift (@ARGV)) + { + if ($arg =~ /^-h$|^-help$|^--help$|^--usage$|^-?$/) { + $Print_Usage = 1; + } + elsif ($arg =~ /^--debug$/) { # unadvertised option, heh + $Debug = 1; + } + elsif ($arg =~ /^--version$/) { + $Print_Version = 1; + } + elsif ($arg =~ /^-g$|^--global-opts$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + # Don't assume CVS is called "cvs" on the user's system: + $Log_Source_Command =~ s/(^\S*)/$1 $narg/; + } + elsif ($arg =~ /^-l$|^--log-opts$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + $Log_Source_Command .= " $narg"; + } + elsif ($arg =~ /^-f$|^--file$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + $output_file = $narg; + } + elsif ($arg =~ /^--fsf$/) { + $FSF_Style = 1; + } + elsif ($arg =~ /^-U$|^--usermap$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + $User_Map_File = $narg; + } + elsif ($arg =~ /^-W$|^--window$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + $Max_Checkin_Duration = $narg; + } + elsif ($arg =~ /^-I$|^--ignore$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + push (@Ignore_Files, $narg); + } + elsif ($arg =~ /^-C$|^--case-insensitive$/) { + $Case_Insensitive = 1; + } + elsif ($arg =~ /^-R$|^--regexp$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + $Regexp_Gate = $narg; + } + elsif ($arg =~ /^--stdout$/) { + $Output_To_Stdout = 1; + } + elsif ($arg =~ /^--version$/) { + $Print_Version = 1; + } + elsif ($arg =~ /^-d$|^--distributed$/) { + $Distributed = 1; + } + elsif ($arg =~ /^-P$|^--prune$/) { + $Prune_Empty_Msgs = 1; + } + elsif ($arg =~ /^-S$|^--separate-header$/) { + $After_Header = "\n\n"; + } + elsif ($arg =~ /^--no-wrap$/) { + $No_Wrap = 1; + } + elsif ($arg =~ /^--gmt$|^--utc$/) { + $UTC_Times = 1; + } + elsif ($arg =~ /^-w$|^--day-of-week$/) { + $Show_Day_Of_Week = 1; + } + elsif ($arg =~ /^-r$|^--revisions$/) { + $Show_Revisions = 1; + } + elsif ($arg =~ /^-t$|^--tags$/) { + $Show_Tags = 1; + } + elsif ($arg =~ /^-b$|^--branches$/) { + $Show_Branches = 1; + } + elsif ($arg =~ /^-F$|^--follow$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + push (@Follow_Branches, $narg); + } + elsif ($arg =~ /^--stdin$/) { + $Input_From_Stdin = 1; + } + elsif ($arg =~ /^--header$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + $ChangeLog_Header = &slurp_file ($narg); + if (! defined ($ChangeLog_Header)) { + $ChangeLog_Header = ""; + } + } + elsif ($arg =~ /^--xml$/) { + $XML_Output = 1; + } + elsif ($arg =~ /^--hide-filenames$/) { + $Hide_Filenames = 1; + $After_Header = ""; + } + else { + # Just add a filename as argument to the log command + $Log_Source_Command .= " $arg"; + } + } + + ## Check for contradictions... + + if ($Output_To_Stdout && $Distributed) { + print STDERR "cannot pass both --stdout and --distributed\n"; + $exit_with_admonishment = 1; + } + + if ($Output_To_Stdout && $output_file) { + print STDERR "cannot pass both --stdout and --file\n"; + $exit_with_admonishment = 1; + } + + # Or if any other error message has already been printed out, we + # just leave now: + if ($exit_with_admonishment) { + &usage (); + exit (1); + } + elsif ($Print_Usage) { + &usage (); + exit (0); + } + elsif ($Print_Version) { + &version (); + exit (0); + } + + ## Else no problems, so proceed. + + if ($Output_To_Stdout) { + undef $Log_File_Name; # not actually necessary + } + elsif ($output_file) { + $Log_File_Name = $output_file; + } +} + + +sub slurp_file () +{ + my $filename = shift || die ("no filename passed to slurp_file()"); + my $retstr; + + open (SLURPEE, "<${filename}") or die ("unable to open $filename ($!)"); + my $saved_sep = $/; + undef $/; + $retstr = ; + $/ = $saved_sep; + close (SLURPEE); + return $retstr; +} + + +sub debug () +{ + if ($Debug) { + my $msg = shift; + print STDERR $msg; + } +} + + +sub version () +{ + print "cvs2cl.pl version ${VERSION}; distributed under the GNU GPL.\n"; +} + + +sub usage () +{ + &version (); + print <<'END_OF_INFO'; +Generate GNU-style ChangeLogs in CVS working copies. + +Notes about the output format(s): + + The default output of cvs2cl.pl is designed to be compact, formally + unambiguous, but still easy for humans to read. It is largely + self-explanatory, I hope; the one abbreviation that might not be + obvious is "utags". That stands for "universal tags" -- a + universal tag is one held by all the files in a given change entry. + + If you need output that's easy for a program to parse, use the + --xml option. Note that with XML output, just about all available + information is included with each change entry, whether you asked + for it or not, on the theory that your parser can ignore anything + it's not looking for. + +Notes about the options and arguments (the actual options are listed +last in this usage message): + + * The -I and -F options may appear multiple times. + + * To follow trunk revisions, use "-F trunk" ("-F TRUNK" also works). + This is okay because no would ever, ever be crazy enough to name a + branch "trunk", right? Right. + + * For the -U option, the UFILE should be formatted like + CVSROOT/users. That is, each line of UFILE looks like this + jrandom:jrandom@red-bean.com + or maybe even like this + jrandom:'Jesse Q. Random ' + Don't forget to quote the portion after the colon if necessary. + + * Many people want to filter by date. To do so, invoke cvs2cl.pl + like this: + cvs2cl.pl -l "-d'DATESPEC'" + where DATESPEC is any date specification valid for "cvs log -d". + (Note that CVS 1.10.7 and below requires there be no space between + -d and its argument). + +Options/Arguments: + + -h, -help, --help, or -? Show this usage and exit + --version Show version and exit + -r, --revisions Show revision numbers in output + -b, --branches Show branch names in revisions when possible + -t, --tags Show tags (symbolic names) in output + --stdin Read from stdin, don't run cvs log + --stdout Output to stdout not to ChangeLog + -d, --distributed Put ChangeLogs in subdirs + -f FILE, --file FILE Write to FILE instead of "ChangeLog" + --fsf Use this if log data is in FSF ChangeLog style + -W SECS, --window SECS Window of time within which log entries unify + -U UFILE, --usermap UFILE Expand usernames to email addresses from UFILE + -R REGEXP, --regexp REGEXP Include only entries that match REGEXP + -I REGEXP, --ignore REGEXP Ignore files whose names match REGEXP + -C, --case-insensitive Any regexp matching is done case-insensitively + -F BRANCH, --follow BRANCH Show only revisions on or ancestral to BRANCH + -S, --separate-header Blank line between each header and log message + --no-wrap Don't auto-wrap log message (recommend -S also) + --gmt, --utc Show times in GMT/UTC instead of local time + -w, --day-of-week Show day of week + --header FILE Get ChangeLog header from FILE ("-" means stdin) + --xml Output XML instead of ChangeLog format + --hide-filenames Don't show filenames (ignored for XML output) + -P, --prune Don't show empty log messages + -g OPTS, --global-opts OPTS Invoke like this "cvs OPTS log ..." + -l OPTS, --log-opts OPTS Invoke like this "cvs ... log OPTS" + FILE1 [FILE2 ...] Show only log information for the named FILE(s) + +See http://www.red-bean.com/cvs2cl for maintenance and bug info. +END_OF_INFO +} + +__END__ + +=head1 NAME + +cvs2cl.pl - produces GNU-style ChangeLogs in CVS working copies, by + running "cvs log" and parsing the output. Shared log entries are + unified in an intuitive way. + +=head1 DESCRIPTION + +This script generates GNU-style ChangeLog files from CVS log +information. Basic usage: just run it inside a working copy and a +ChangeLog will appear. It requires repository access (i.e., 'cvs log' +must work). Run "cvs2cl.pl --help" to see more advanced options. + +See http://www.red-bean.com/cvs2cl for updates, and for instructions +on getting anonymous CVS access to this script. + +Maintainer: Karl Fogel +Please report bugs to . + +=head1 README + +This script generates GNU-style ChangeLog files from CVS log +information. Basic usage: just run it inside a working copy and a +ChangeLog will appear. It requires repository access (i.e., 'cvs log' +must work). Run "cvs2cl.pl --help" to see more advanced options. + +See http://www.red-bean.com/cvs2cl for updates, and for instructions +on getting anonymous CVS access to this script. + +Maintainer: Karl Fogel +Please report bugs to . + +=head1 PREREQUISITES + +This script requires C, C, and +C. +It also seems to require C or higher. + +=pod OSNAMES + +any + +=pod SCRIPT CATEGORIES + +Version_Control/CVS + +=cut + + +-*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- + +Note about a bug-slash-opportunity: +----------------------------------- + +There's a bug in Text::Wrap, which affects cvs2cl. This script +reveals it: + + #!/usr/bin/perl -w + + use Text::Wrap; + + my $test_text = + "This script demonstrates a bug in Text::Wrap. The very long line + following this paragraph will be relocated relative to the surrounding + text: + + ==================================================================== + + See? When the bug happens, we'll get the line of equal signs below + this paragraph, even though it should be above."; + + + # Print out the test text with no wrapping: + print "$test_text"; + print "\n"; + print "\n"; + + # Now print it out wrapped, and see the bug: + print wrap ("\t", " ", "$test_text"); + print "\n"; + print "\n"; + +If the line of equal signs were one shorter, then the bug doesn't +happen. Interesting. + +Anyway, rather than fix this in Text::Wrap, we might as well write a +new wrap() which has the following much-needed features: + +* initial indentation, like current Text::Wrap() +* subsequent line indentation, like current Text::Wrap() +* user chooses among: force-break long words, leave them alone, or die()? +* preserve existing indentation: chopped chunks from an indented line + are indented by same (like this line, not counting the asterisk!) +* optional list of things to preserve on line starts, default ">" + +Note that the last two are essentially the same concept, so unify in +implementation and give a good interface to controlling them. + +And how about: + +Optionally, when encounter a line pre-indented by same as previous +line, then strip the newline and refill, but indent by the same. +Yeah... diff --git a/include/rbaudio.h b/unused/bios/rbaudio.h similarity index 94% rename from include/rbaudio.h rename to unused/bios/rbaudio.h index 216a61f2..9692f147 100644 --- a/include/rbaudio.h +++ b/unused/bios/rbaudio.h @@ -25,7 +25,8 @@ typedef struct _RBACHANNELCTL { unsigned int out3in, out3vol; } RBACHANNELCTL; -#ifndef __MSDOS__ //defined(__NT__) + +#if defined(__NT__) extern void RBAInit(void); //drive a == 0, drive b == 1 #else extern void RBAInit(ubyte cd_drive_num); //drive a == 0, drive b == 1 @@ -54,7 +55,4 @@ extern int RBAResume(); //is called. Returns 0 if no track playing, else track number int RBAGetTrackNum(); -// get the cddb discid for the current cd. -unsigned long RBAGetDiscID(); - #endif diff --git a/unused/lib/fix.h b/unused/lib/fix.h new file mode 100644 index 00000000..5ff9d2ff --- /dev/null +++ b/unused/lib/fix.h @@ -0,0 +1,147 @@ +/* +THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX +SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO +END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A +ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS +IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS +SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE +FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE +CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. +*/ + +#ifndef _FIX_H +#define _FIX_H + +#include "pstypes.h" + +typedef long fix; //16 bits int, 16 bits frac +typedef short fixang; //angles + +typedef struct quad { + ulong low; + long high; +} quad; + +//Convert an int to a fix +#define i2f(i) ((i)<<16) + +//Get the int part of a fix +#define f2i(f) ((f)>>16) + +//Get the int part of a fix, with rounding +#define f2ir(f) (((f)+f0_5)>>16) + +//Convert fix to float and float to fix +#define f2fl(f) (((float) (f)) / 65536.0) +#define fl2f(f) ((fix) ((f) * 65536)) + +//Some handy constants +#define f0_0 0 +#define f1_0 0x10000 +#define f2_0 0x20000 +#define f3_0 0x30000 +#define f10_0 0xa0000 + +#define f0_5 0x8000 +#define f0_1 0x199a + +#define F0_0 f0_0 +#define F1_0 f1_0 +#define F2_0 f2_0 +#define F3_0 f3_0 +#define F10_0 f10_0 + +#define F0_5 f0_5 +#define F0_1 f0_1 + +fix fixmul(fix a,fix b); +#pragma aux fixmul parm [eax] [edx] = \ + "imul edx" \ + "shrd eax,edx,16"; + + +fix fixdiv(fix a,fix b); +#pragma aux fixdiv parm [eax] [ebx] modify exact [eax edx] = \ + "mov edx,eax" \ + "sar edx,16" \ + "shl eax,16" \ + "idiv ebx"; + +fix fixmuldiv(fix a,fix b,fix c); +#pragma aux fixmuldiv parm [eax] [edx] [ebx] modify exact [eax edx] = \ + "imul edx" \ + "idiv ebx"; + +#pragma aux fixmulaccum parm [esi] [eax] [edx] modify exact [eax edx] = \ + "imul edx" \ + "add [esi],eax" \ + "adc 4[esi],edx"; + +#pragma aux fixquadadjust parm [esi] modify exact [eax edx] = \ + "mov eax,[esi]" \ + "mov edx,4[esi]" \ + "shrd eax,edx,16"; + +#pragma aux fixquadnegate parm [eax] modify exact [ebx] = \ + "mov ebx,[eax]" \ + "neg ebx" \ + "mov [eax],ebx" \ + "mov ebx,4[eax]" \ + "not ebx" \ + "sbb ebx,-1" \ + "mov 4[eax],ebx"; + +#pragma aux fixdivquadlong parm [eax] [edx] [ebx] modify exact [eax edx] = \ + "idiv ebx"; + +//computes the square root of a long, returning a short +ushort long_sqrt(long a); + +//computes the square root of a quad, returning a long +ulong quad_sqrt(long low,long high); + +//computes the square root of a fix, returning a fix +fix fix_sqrt(fix a); + +//multiply two fixes, and add 64-bit product to a quad +void fixmulaccum(quad *q,fix a,fix b); + +//extract a fix from a quad product +fix fixquadadjust(quad *q); + +//divide a quad by a long +long fixdivquadlong(ulong qlow,long qhigh,long d); + +//negate a quad +void fixquadnegate(quad *q); + +//compute sine and cosine of an angle, filling in the variables +//either of the pointers can be NULL +void fix_sincos(fix a,fix *s,fix *c); //with interpolation +void fix_fastsincos(fix a,fix *s,fix *c); //no interpolation + +//compute inverse sine & cosine +fixang fix_asin(fix v); +fixang fix_acos(fix v); + +//given cos & sin of an angle, return that angle. +//parms need not be normalized, that is, the ratio of the parms cos/sin must +//equal the ratio of the actual cos & sin for the result angle, but the parms +//need not be the actual cos & sin. +//NOTE: this is different from the standard C atan2, since it is left-handed. +fixang fix_atan2(fix cos,fix sin); + +#pragma aux fix_fastsincos parm [eax] [esi] [edi] modify exact [eax ebx]; +#pragma aux fix_sincos parm [eax] [esi] [edi] modify exact [eax ebx]; + +#pragma aux fix_asin "*" parm [eax] value [ax] modify exact [eax]; +#pragma aux fix_acos "*" parm [eax] value [ax] modify exact [eax]; +#pragma aux fix_atan2 "*" parm [eax] [ebx] value [ax] modify exact [eax ebx]; + +#pragma aux long_sqrt "*" parm [eax] value [ax] modify []; +#pragma aux fix_sqrt "*" parm [eax] value [eax] modify []; +#pragma aux quad_sqrt "*" parm [eax] [edx] value [eax] modify []; + +#endif diff --git a/unused/lib/rbaudio.h b/unused/lib/rbaudio.h new file mode 100644 index 00000000..9692f147 --- /dev/null +++ b/unused/lib/rbaudio.h @@ -0,0 +1,58 @@ +/* +THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX +SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO +END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A +ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS +IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS +SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE +FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE +CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. +*/ + + + +#ifndef _RBAUDIO_H +#define _RBAUDIO_H + +#define RBA_MEDIA_CHANGED -1 + +typedef struct _RBACHANNELCTL { + unsigned int out0in, out0vol; + unsigned int out1in, out1vol; + unsigned int out2in, out2vol; + unsigned int out3in, out3vol; +} RBACHANNELCTL; + + +#if defined(__NT__) + extern void RBAInit(void); //drive a == 0, drive b == 1 +#else + extern void RBAInit(ubyte cd_drive_num); //drive a == 0, drive b == 1 +#endif +extern void RBARegisterCD(void); +extern long RBAGetDeviceStatus(void); +extern int RBAPlayTrack(int track); +extern int RBAPlayTracks(int first, int last); //plays tracks first through last, inclusive +extern int RBACheckMediaChange(); +extern long RBAGetHeadLoc(int *min, int *sec, int *frame); +extern int RBAPeekPlayStatus(void); +extern void RBAStop(void); +extern void RBASetStereoAudio(RBACHANNELCTL *channels); +extern void RBASetQuadAudio(RBACHANNELCTL *channels); +extern void RBAGetAudioInfo(RBACHANNELCTL *channels); +extern void RBASetChannelVolume(int channel, int volume); +extern void RBASetVolume(int volume); +extern int RBAEnabled(void); +extern void RBADisable(void); +extern void RBAEnable(void); +extern int RBAGetNumberOfTracks(void); +extern void RBAPause(); +extern int RBAResume(); + +//return the track number currently playing. Useful if RBAPlayTracks() +//is called. Returns 0 if no track playing, else track number +int RBAGetTrackNum(); + +#endif diff --git a/unused/novga/files.rc b/unused/novga/files.rc new file mode 100644 index 00000000..e69de29b diff --git a/unused/novga/novesa.c b/unused/novga/novesa.c new file mode 100644 index 00000000..646ba3ab --- /dev/null +++ b/unused/novga/novesa.c @@ -0,0 +1,117 @@ +/* +THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX +SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO +END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A +ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS +IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS +SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE +FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE +CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. +COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. +*/ + + +#pragma off (unreferenced) +static char rcsid[] = "$Id: novesa.c,v 1.1.1.1 2001-01-19 03:30:15 bradleyb Exp $"; +#pragma on (unreferenced) + +#include "pstypes.h" + +#include "gr.h" + + +void gr_vesa_update( grs_bitmap * source1, grs_bitmap * dest, grs_bitmap * source2 ) +{ + +} + + +int gr_modex_setmode(short mode) +{ + return 0; +} + + +void gr_modex_setplane(short plane) +{ + +} + + +void gr_modex_setstart(short x, short y, int wait_for_retrace) +{ + +} + + +void gr_modex_uscanline( short x1, short x2, short y, unsigned char color ) +{ + +} + + +int gr_vesa_setmodea(int mode) +{ + +} + + +int gr_vesa_checkmode(int mode) +{ + +} + + +void gr_vesa_setstart(short x, short y ) +{ + +} + + +void gr_vesa_setpage(int page) +{ + +} + + +void gr_vesa_incpage() +{ + +} + + +void gr_vesa_scanline(short x1, short x2, short y, unsigned char color ) +{ + +} + + +int gr_vesa_setlogical(int pixels_per_scanline) +{ + +} + + +void gr_vesa_bitblt( unsigned char * source_ptr, unsigned int vesa_address, int height, int width ) +{ + +} + + +void gr_vesa_pixel( unsigned char color, unsigned int offset ) +{ + +} + + +void gr_vesa_bitmap( grs_bitmap * source, grs_bitmap * dest, int x, int y ) +{ + +} + + +void gr_modex_line() +{ + +} diff --git a/utilities/.cvsignore b/utilities/.cvsignore deleted file mode 100644 index 70845e08..00000000 --- a/utilities/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile.in diff --git a/utilities/Makefile.am b/utilities/Makefile.am deleted file mode 100644 index 50b24b9e..00000000 --- a/utilities/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -EXTRA_PROGRAMS = hogcreate hogextract mvlcreate mvlextract txb2tex tex2txb - -hogcreate_SOURCES = hogcreate.c - -hogextract_SOURCES = hogextract.c - -mvlcreate_SOURCES = mvlcreate.c - -mvlextract_SOURCES = mvlextract.c - -txb2tex_SOURCES = txb2tex.c - -tex2txb_SOURCES = tex2txb.c - -utils: $(EXTRA_PROGRAMS) - -.PHONY: utils diff --git a/utilities/hogcreate.c b/utilities/hogcreate.c deleted file mode 100644 index c9ff134f..00000000 --- a/utilities/hogcreate.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Written 1999 Jan 29 by Josh Cogliati - * Modified by Bradley Bell, 2002, 2003 - * This program is licensed under the terms of the GPL, version 2 or later - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#define SWAPINT(x) (((x)<<24) | (((uint)(x)) >> 24) | (((x) &0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8)) - -int -main(int argc, char *argv[]) -{ - FILE *hogfile, *readfile; - DIR *dp; - struct dirent *ep; - char filename[13]; - char *buf; - struct stat statbuf; - int tmp; - - if (argc != 2) { - printf("Usage: hogcreate hogfile\n" - "creates hogfile using all the files in the current directory\n"); - exit(0); - } - hogfile = fopen(argv[1], "w"); - buf = (char *)malloc(3); - strncpy(buf, "DHF", 3); - fwrite(buf, 3, 1, hogfile); - printf("Creating: %s\n", argv[1]); - free(buf); - dp = opendir("./"); - if (dp != NULL) { - while ((ep = readdir(dp))) { - if (strlen(ep->d_name) > 12) { - fprintf(stderr, "error: filename %s too long! (12 chars max!)\n", ep->d_name); - return 1; - } - memset(filename, 0, 13); - strcpy(filename, ep->d_name); - stat(filename, &statbuf); - if(! S_ISDIR(statbuf.st_mode)) { - printf("Filename: %s \tLength: %i\n", filename, (int)statbuf.st_size); - readfile = fopen(filename, "r"); - buf = (char *)malloc(statbuf.st_size); - if (buf == NULL) { - printf("Unable to allocate memery\n"); - } else { - fwrite(filename, 13, 1, hogfile); - tmp = (int)statbuf.st_size; -#ifdef WORDS_BIGENDIAN - tmp = SWAPINT(tmp); -#endif - fwrite(&tmp, 4, 1, hogfile); - fread(buf, statbuf.st_size, 1, readfile); - fwrite(buf, statbuf.st_size, 1, hogfile); - } - fclose(readfile); - - } - } - closedir(dp); - } - fclose(hogfile); - - return 0; -} diff --git a/utilities/hogextract.c b/utilities/hogextract.c deleted file mode 100644 index 596ba828..00000000 --- a/utilities/hogextract.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Written 1999 Jan 29 by Josh Cogliati - * Modified by Bradley Bell, 2002, 2003 - * This program is licensed under the terms of the GPL, version 2 or later - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#define SWAPINT(x) (((x)<<24) | (((uint)(x)) >> 24) | (((x) &0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8)) - -int -main(int argc, char *argv[]) -{ - FILE *hogfile, *writefile; - int len; - char filename[13]; - char *buf; - struct stat statbuf; - int v = 0; - - if (argc > 1 && !strcmp(argv[1], "v")) { - v = 1; - argc--; - argv++; - } - - if (argc < 2) { - printf("Usage: hogextract [v] hogfile [filename]\n" - "extracts all the files in hogfile into the current directory\n" - "Options:\n" - " v View files, don't extract\n"); - exit(0); - } - hogfile = fopen(argv[1], "r"); - stat(argv[1], &statbuf); - printf("%i\n", (int)statbuf.st_size); - buf = (char *)malloc(3); - fread(buf, 3, 1, hogfile); - printf("Extracting from: %s\n", argv[1]); - free(buf); - while(ftell(hogfile) 2 && strcmp(argv[2], filename)) - fseek(hogfile, len, SEEK_CUR); - else { - printf("Filename: %s \tLength: %i\n", filename, len); - if (v) - fseek(hogfile, len, SEEK_CUR); - else { - buf = (char *)malloc(len); - if (buf == NULL) { - printf("Unable to allocate memory\n"); - } else { - fread(buf, len, 1, hogfile); - writefile = fopen(filename, "w"); - fwrite(buf, len, 1, writefile); - fclose(writefile); - free(buf); - } - } - } - } - fclose(hogfile); - - return 0; -} diff --git a/utilities/mvlcreate.c b/utilities/mvlcreate.c deleted file mode 100644 index 0a89b798..00000000 --- a/utilities/mvlcreate.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Written 1999 Jan 29 by Josh Cogliati - * Modified by Bradley Bell, 2002, 2003 - * This program is licensed under the terms of the GPL, version 2 or later - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#define MAX_FILES 256 - -#define SWAPINT(x) (((x)<<24) | (((uint)(x)) >> 24) | (((x) &0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8)) - -int -main(int argc, char *argv[]) -{ - FILE *mvlfile, *readfile; - DIR *dp; - struct dirent *ep; - int i, nfiles = 0, len[MAX_FILES], tmp; - char filename[MAX_FILES][13]; - char *buf; - struct stat statbuf; - - if (argc != 2) { - printf("Usage: mvlcreate mvlfile\n" - "creates mvlfile using all the files in the current directory\n"); - exit(0); - } - - dp = opendir("./"); - if (dp != NULL) { - while ((ep = readdir(dp))) { - if (strlen(ep->d_name) > 12) { - fprintf(stderr, "error: filename %s too long! (12 chars max!)\n", ep->d_name); - return 1; - } - memset(filename[nfiles], 0, 13); - strcpy(filename[nfiles], ep->d_name); - stat(filename[nfiles], &statbuf); - if(! S_ISDIR(statbuf.st_mode)) { - len[nfiles] = (int)statbuf.st_size; - printf("Filename: %s \tLength: %i\n", filename[nfiles], len[nfiles]); - nfiles++; - } - } - } - closedir(dp); - - printf("Creating: %s\n", argv[1]); - mvlfile = fopen(argv[1], "w"); - buf = (char *)malloc(4); - strncpy(buf, "DMVL", 4); - fwrite(buf, 4, 1, mvlfile); - free(buf); - - tmp = nfiles; -#ifdef WORDS_BIGENDIAN - tmp = SWAPINT(tmp); -#endif - fwrite(&tmp, 4, 1, mvlfile); - - for (i = 0; i < nfiles; i++) { - fwrite(filename[i], 13, 1, mvlfile); - tmp = len[i]; -#ifdef WORDS_BIGENDIAN - tmp = SWAPINT(tmp); -#endif - fwrite(&tmp, 4, 1, mvlfile); - } - - for (i = 0; i < nfiles; i++) { - readfile = fopen(filename[i], "r"); - buf = (char *)malloc(len[i]); - if (buf == NULL) { - printf("Unable to allocate memory\n"); - } else { - fread(buf, len[i], 1, readfile); - fwrite(buf, len[i], 1, mvlfile); - } - fclose(readfile); - } - - fclose(mvlfile); - - return 0; -} diff --git a/utilities/mvlextract.c b/utilities/mvlextract.c deleted file mode 100644 index c1fff7fd..00000000 --- a/utilities/mvlextract.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Written 1999 Jan 29 by Josh Cogliati - * Modified for mvl by Bradley Bell, 2002, 2003 - * This program is licensed under the terms of the GPL, version 2 or later - */ - -#include -#include -#include -#include -#include -#include - -#define SWAPINT(x) (((x)<<24) | (((unsigned int)(x)) >> 24) | (((x) &0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8)) - -#define MAX_FILES 256 - -int -main(int argc, char *argv[]) -{ - FILE *mvlfile, *writefile; - int i, nfiles, len[MAX_FILES]; - char filename[MAX_FILES][13]; - char *buf; - struct stat statbuf; - int v = 0; - int bigendian = 0; - - if (argc > 1 && !strcmp(argv[1], "v")) { - v = 1; - argc--; - argv++; - } - - if (argc < 2) { - printf("Usage: mvlextract [v] mvlfile [filename]\n" - "extracts all the files in mvlfile into the current directory\n" - "Options:\n" - " v View files, don't extract\n"); - exit(0); - } - mvlfile = fopen(argv[1], "r"); - stat(argv[1], &statbuf); - printf("%i\n", (int)statbuf.st_size); - buf = (char *)malloc(4); - fread(buf, 4, 1, mvlfile); - fread(&nfiles, 4, 1, mvlfile); - printf("%d files\n", nfiles); - if (nfiles > MAX_FILES) { // must be a bigendian mvl - fprintf(stderr, "warning: nfiles>%d, trying reverse byte order...", - MAX_FILES); - bigendian = 1; - } - if (bigendian) - nfiles = SWAPINT(nfiles); - printf("Extracting from: %s\n", argv[1]); - free(buf); - for (i = 0; i < nfiles; i++) { - fread(filename[i], 13, 1, mvlfile); - fread(&len[i], 4, 1, mvlfile); - if (bigendian) - len[i] = SWAPINT(len[i]); - if (argc == 2 || !strcmp(argv[2], filename[i])) - printf("Filename: %s \tLength: %i\n", filename[i], len[i]); - } - - if (!v) { - for (i = 0; i < nfiles; i++) { - if (argc > 2 && strcmp(argv[2], filename[i])) - fseek(mvlfile, len[i], SEEK_CUR); - else { - if (ftell(mvlfile) > statbuf.st_size) { - printf("Error, end of file\n"); - exit(1); - } - buf = (char *)malloc(len[i]); - if (buf == NULL) { - printf("Unable to allocate memory\n"); - } else { - fread(buf, len[i], 1, mvlfile); - writefile = fopen(filename[i], "w"); - fwrite(buf, len[i], 1, writefile); - fclose(writefile); - free(buf); - } - } - } - } - fclose(mvlfile); - - return 0; -} diff --git a/utilities/tex2txb.c b/utilities/tex2txb.c deleted file mode 100755 index c9c7a767..00000000 --- a/utilities/tex2txb.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Modified by Bradley Bell, 2002, 2003 - * This program is licensed under the terms of the GPL, version 2 or later - */ - -#include -#include - -int -main(int argc, char *argv[]) -{ - FILE *file, *outfile; - char outfilename[64]; - char ch; - int code; - - if (argc < 2) { - printf("TEX2TXB V1.0 Copyright (c) Bryan Aamot, 1995\n" - "Modified by Bradley Bell, 2002, 2003\n" - "Text to TXB converter for Descent HOG files.\n" - "Converts an ascii text file to *.txb descent hog file.\n" - "Usage: TEX2TXB \n" - "Example: TEX2TXB briefing.tex briefing.txb\n"); - return 1; - } - file = fopen(argv[1], "rb"); - if (!file) { - printf("Can't open file (%s)\n", argv[1]); - return 2; - } - - if (argc > 2) - strcpy(outfilename, argv[2]); - else { - strcpy(outfilename, argv[1]); - strcpy(strrchr(outfilename, '.'), ".txb"); - } - - outfile = fopen(outfilename, "wb"); - if (!outfile) { - printf("Can't open file (%s)\n", outfilename); - fclose(file); - return 2; - } - - for (;;) { - ch = getc(file); - if (feof(file)) break; - if (ch!=0x0d) { - if (ch==0x0a) { - fprintf(outfile, "\x0a"); - } else { - code = ( ( (ch &0xfC) >> 2) + ( (ch &0x03) << 6 ) ) ^ 0xe9; - fprintf(outfile, "%c", code); - } - } - } - - fclose(outfile); - fclose(file); - - return 0; -} diff --git a/utilities/txb2tex.c b/utilities/txb2tex.c deleted file mode 100755 index e528193c..00000000 --- a/utilities/txb2tex.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Modified by Bradley Bell, 2002, 2003 - * This program is licensed under the terms of the GPL, version 2 or later - */ - -#include -#include - -int -main(int argc, char *argv[]) -{ - FILE *file, *outfile; - char outfilename[64]; - char ch; - int code; - - if (argc < 2) { - printf("TXB2TEX V1.0 Copyright (c) Bryan Aamot, 1995\n" - "Modified by Bradley Bell, 2002, 2003\n" - "TXB to Text converter for Descent HOG files.\n" - "Converts a *.txb descent hog file to an ascii file.\n" - "Usage: TXB2TEX \n" - "Example: TXB2TEX briefing.txb briefing.tex\n"); - return 1; - } - file = fopen(argv[1], "rb"); - if (!file) { - printf("Can't open txb file (%s)\n", argv[1]); - return 2; - } - - if (argc > 2) - strcpy(outfilename, argv[2]); - else { - strcpy(outfilename, argv[1]); - strcpy(strrchr(outfilename, '.'), ".tex"); - } - - outfile = fopen(outfilename, "wb"); - if (!outfile) { - printf("Can't open file (%s)\n", outfilename); - fclose(file); - return 2; - } - for (;;) { - code = getc(file); - if (feof(file)) break; - if (code == 0x0a) { - fprintf(outfile, "\x0d\x0a"); - } else { - ch = ( ( (code&0x3f) << 2 ) + ( (code&0xc0) >> 6 ) ) ^ 0xa7; - fprintf(outfile, "%c", ch); - } - } - - fclose(outfile); - fclose(file); - - return 0; -} -- 2.39.2