From 6a8346ddab93cc5b3c2b3ebd5cdac25aa8965352 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 5 Sep 2007 21:56:58 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@573 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/include/build.h | 1106 +++++++++++------------ polymer/build/src/engine.c | 48 +- polymer/eduke32/source/game.c | 67 -- polymer/eduke32/source/jfaud_sounds.cpp | 768 ---------------- 4 files changed, 600 insertions(+), 1389 deletions(-) delete mode 100644 polymer/eduke32/source/jfaud_sounds.cpp diff --git a/polymer/build/include/build.h b/polymer/build/include/build.h index 8215b32ff..34aa99890 100644 --- a/polymer/build/include/build.h +++ b/polymer/build/include/build.h @@ -1,555 +1,555 @@ -// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman -// Ken Silverman's official web site: "http://www.advsys.net/ken" -// See the included license file "BUILDLIC.TXT" for license info. -// -// This file has been modified from Ken Silverman's original release -// by Jonathon Fowler (jonof@edgenetwk.com) - - -#ifndef __build_h__ -#define __build_h__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAXSECTORSV8 4096 -#define MAXWALLSV8 16384 -#define MAXSPRITESV8 16384 - -#define MAXSECTORSV7 1024 -#define MAXWALLSV7 8192 -#define MAXSPRITESV7 4096 - -#define MAXSECTORS MAXSECTORSV8 -#define MAXWALLS MAXWALLSV8 -#define MAXSPRITES MAXSPRITESV8 - -#define MAXTILES 15360 -#define MAXVOXELS 4096 -#define MAXSTATUS 1024 -#define MAXPLAYERS 16 -#define MAXXDIM 2048 -#define MAXYDIM 1536 -#define MAXPALOOKUPS 256 -#define MAXPSKYTILES 256 -#define MAXSPRITESONSCREEN 4096 -#define MAXUNIQHUDID 256 //Extra slots so HUD models can store animation state without messing game sprites - -#define RESERVEDPALS 2 // don't forget to increment this when adding reserved pals -#define DETAILPAL (MAXPALOOKUPS - 1) -#define GLOWPAL (MAXPALOOKUPS - 2) - -#define CLIPMASK0 (((1L)<<16)+1L) -#define CLIPMASK1 (((256L)<<16)+64L) - - //Make all variables in BUILD.H defined in the ENGINE, - //and externed in GAME -#ifdef ENGINE -# define EXTERN -#else -# define EXTERN extern -#endif - -#ifdef __GNUC__ -#define BPACK __attribute__ ((packed)) -#else -#define BPACK -#endif - -#ifdef _MSC_VER -#pragma pack(1) -#endif - -#ifdef __WATCOMC__ -#pragma pack(push,1); -#endif - - -//ceilingstat/floorstat: -// bit 0: 1 = parallaxing, 0 = not "P" -// bit 1: 1 = groudraw, 0 = not -// bit 2: 1 = swap x&y, 0 = not "F" -// bit 3: 1 = double smooshiness "E" -// bit 4: 1 = x-flip "F" -// bit 5: 1 = y-flip "F" -// bit 6: 1 = Align texture to first wall of sector "R" -// bits 7-8: "T" -// 00 = normal floors -// 01 = masked floors -// 10 = transluscent masked floors -// 11 = reverse transluscent masked floors -// bits 9-15: reserved - - //40 bytes -typedef struct BPACK -{ - short wallptr, wallnum; - long ceilingz, floorz; - short ceilingstat, floorstat; - short ceilingpicnum, ceilingheinum; - signed char ceilingshade; - char ceilingpal, ceilingxpanning, ceilingypanning; - short floorpicnum, floorheinum; - signed char floorshade; - char floorpal, floorxpanning, floorypanning; - char visibility, filler; - short lotag, hitag, extra; -} sectortype; - -//cstat: -// bit 0: 1 = Blocking wall (use with clipmove, getzrange) "B" -// bit 1: 1 = bottoms of invisible walls swapped, 0 = not "2" -// bit 2: 1 = align picture on bottom (for doors), 0 = top "O" -// bit 3: 1 = x-flipped, 0 = normal "F" -// bit 4: 1 = masking wall, 0 = not "M" -// bit 5: 1 = 1-way wall, 0 = not "1" -// bit 6: 1 = Blocking wall (use with hitscan / cliptype 1) "H" -// bit 7: 1 = Transluscence, 0 = not "T" -// bit 8: 1 = y-flipped, 0 = normal "F" -// bit 9: 1 = Transluscence reversing, 0 = normal "T" -// bits 10-15: reserved - - //32 bytes -typedef struct BPACK -{ - long x, y; - short point2, nextwall, nextsector, cstat; - short picnum, overpicnum; - signed char shade; - char pal, xrepeat, yrepeat, xpanning, ypanning; - short lotag, hitag, extra; -} walltype; - -//cstat: -// bit 0: 1 = Blocking sprite (use with clipmove, getzrange) "B" -// bit 1: 1 = transluscence, 0 = normal "T" -// bit 2: 1 = x-flipped, 0 = normal "F" -// bit 3: 1 = y-flipped, 0 = normal "F" -// bits 5-4: 00 = FACE sprite (default) "R" -// 01 = WALL sprite (like masked walls) -// 10 = FLOOR sprite (parallel to ceilings&floors) -// bit 6: 1 = 1-sided sprite, 0 = normal "1" -// bit 7: 1 = Real centered centering, 0 = foot center "C" -// bit 8: 1 = Blocking sprite (use with hitscan / cliptype 1) "H" -// bit 9: 1 = Transluscence reversing, 0 = normal "T" -// bits 10-14: reserved -// bit 15: 1 = Invisible sprite, 0 = not invisible - - //44 bytes -typedef struct BPACK -{ - long x, y, z; - short cstat, picnum; - signed char shade; - char pal, clipdist, filler; - unsigned char xrepeat, yrepeat; - signed char xoffset, yoffset; - short sectnum, statnum; - short ang, owner, xvel, yvel, zvel; - short lotag, hitag, extra; -} spritetype; - -typedef struct BPACK { - unsigned long mdanimtims; - short mdanimcur; - short angoff; - short pitch, roll; - long xoff, yoff, zoff; - unsigned char flags; - char filler[3]; -} spriteexttype; - -typedef struct BPACK { - short mdcurframe, mdoldframe; - short mdsmooth; - float smoothduration; -} spritesmoothtype; - -#define SPREXT_NOTMD 1 -#define SPREXT_NOMDANIM 2 -EXTERN spriteexttype spriteext[MAXSPRITES+MAXUNIQHUDID]; -EXTERN spritesmoothtype spritesmooth[MAXSPRITES+MAXUNIQHUDID]; -EXTERN long guniqhudid; - -EXTERN sectortype sector[MAXSECTORS]; -EXTERN walltype wall[MAXWALLS]; -EXTERN spritetype sprite[MAXSPRITES]; - -EXTERN long spritesortcnt; -EXTERN spritetype tsprite[MAXSPRITESONSCREEN]; - -EXTERN long xdim, ydim, ylookup[MAXYDIM+1], numpages; -EXTERN long yxaspect, viewingrange; - -#define MAXVALIDMODES 256 -EXTERN long validmodecnt; -struct validmode_t { - long xdim,ydim; - char bpp; - char fs; // bit 0 = fullscreen flag - char filler[2]; - long extra; // internal use -}; -EXTERN struct validmode_t validmode[MAXVALIDMODES]; - -EXTERN short numsectors, numwalls; -EXTERN /*volatile*/ long totalclock; -EXTERN long numframes, randomseed; -EXTERN short sintable[2048]; -EXTERN char palette[768]; -EXTERN short numpalookups; -EXTERN char *palookup[MAXPALOOKUPS]; -EXTERN char parallaxtype, showinvisibility; -EXTERN long parallaxyoffs, parallaxyscale; -EXTERN long visibility, parallaxvisibility; - -EXTERN long windowx1, windowy1, windowx2, windowy2; -EXTERN short startumost[MAXXDIM], startdmost[MAXXDIM]; - -EXTERN short pskyoff[MAXPSKYTILES], pskybits; - -EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; -EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; -EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; - -EXTERN short tilesizx[MAXTILES], tilesizy[MAXTILES]; -EXTERN char picsiz[MAXTILES]; -EXTERN char walock[MAXTILES]; -EXTERN long pow2long[32]; -EXTERN long numtiles, picanm[MAXTILES], waloff[MAXTILES]; +// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman +// Ken Silverman's official web site: "http://www.advsys.net/ken" +// See the included license file "BUILDLIC.TXT" for license info. +// +// This file has been modified from Ken Silverman's original release +// by Jonathon Fowler (jonof@edgenetwk.com) + + +#ifndef __build_h__ +#define __build_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAXSECTORSV8 4096 +#define MAXWALLSV8 16384 +#define MAXSPRITESV8 16384 + +#define MAXSECTORSV7 1024 +#define MAXWALLSV7 8192 +#define MAXSPRITESV7 4096 + +#define MAXSECTORS MAXSECTORSV8 +#define MAXWALLS MAXWALLSV8 +#define MAXSPRITES MAXSPRITESV8 + +#define MAXTILES 15360 +#define MAXVOXELS 4096 +#define MAXSTATUS 1024 +#define MAXPLAYERS 16 +#define MAXXDIM 2048 +#define MAXYDIM 1536 +#define MAXPALOOKUPS 256 +#define MAXPSKYTILES 256 +#define MAXSPRITESONSCREEN 4096 +#define MAXUNIQHUDID 256 //Extra slots so HUD models can store animation state without messing game sprites + +#define RESERVEDPALS 2 // don't forget to increment this when adding reserved pals +#define DETAILPAL (MAXPALOOKUPS - 1) +#define GLOWPAL (MAXPALOOKUPS - 2) + +#define CLIPMASK0 (((1L)<<16)+1L) +#define CLIPMASK1 (((256L)<<16)+64L) + + //Make all variables in BUILD.H defined in the ENGINE, + //and externed in GAME +#ifdef ENGINE +# define EXTERN +#else +# define EXTERN extern +#endif + +#ifdef __GNUC__ +#define BPACK __attribute__ ((packed)) +#else +#define BPACK +#endif + +#ifdef _MSC_VER +#pragma pack(1) +#endif + +#ifdef __WATCOMC__ +#pragma pack(push,1); +#endif + + +//ceilingstat/floorstat: +// bit 0: 1 = parallaxing, 0 = not "P" +// bit 1: 1 = groudraw, 0 = not +// bit 2: 1 = swap x&y, 0 = not "F" +// bit 3: 1 = double smooshiness "E" +// bit 4: 1 = x-flip "F" +// bit 5: 1 = y-flip "F" +// bit 6: 1 = Align texture to first wall of sector "R" +// bits 7-8: "T" +// 00 = normal floors +// 01 = masked floors +// 10 = transluscent masked floors +// 11 = reverse transluscent masked floors +// bits 9-15: reserved + + //40 bytes +typedef struct BPACK +{ + short wallptr, wallnum; + long ceilingz, floorz; + short ceilingstat, floorstat; + short ceilingpicnum, ceilingheinum; + signed char ceilingshade; + char ceilingpal, ceilingxpanning, ceilingypanning; + short floorpicnum, floorheinum; + signed char floorshade; + char floorpal, floorxpanning, floorypanning; + char visibility, filler; + short lotag, hitag, extra; +} sectortype; + +//cstat: +// bit 0: 1 = Blocking wall (use with clipmove, getzrange) "B" +// bit 1: 1 = bottoms of invisible walls swapped, 0 = not "2" +// bit 2: 1 = align picture on bottom (for doors), 0 = top "O" +// bit 3: 1 = x-flipped, 0 = normal "F" +// bit 4: 1 = masking wall, 0 = not "M" +// bit 5: 1 = 1-way wall, 0 = not "1" +// bit 6: 1 = Blocking wall (use with hitscan / cliptype 1) "H" +// bit 7: 1 = Transluscence, 0 = not "T" +// bit 8: 1 = y-flipped, 0 = normal "F" +// bit 9: 1 = Transluscence reversing, 0 = normal "T" +// bits 10-15: reserved + + //32 bytes +typedef struct BPACK +{ + long x, y; + short point2, nextwall, nextsector, cstat; + short picnum, overpicnum; + signed char shade; + char pal, xrepeat, yrepeat, xpanning, ypanning; + short lotag, hitag, extra; +} walltype; + +//cstat: +// bit 0: 1 = Blocking sprite (use with clipmove, getzrange) "B" +// bit 1: 1 = transluscence, 0 = normal "T" +// bit 2: 1 = x-flipped, 0 = normal "F" +// bit 3: 1 = y-flipped, 0 = normal "F" +// bits 5-4: 00 = FACE sprite (default) "R" +// 01 = WALL sprite (like masked walls) +// 10 = FLOOR sprite (parallel to ceilings&floors) +// bit 6: 1 = 1-sided sprite, 0 = normal "1" +// bit 7: 1 = Real centered centering, 0 = foot center "C" +// bit 8: 1 = Blocking sprite (use with hitscan / cliptype 1) "H" +// bit 9: 1 = Transluscence reversing, 0 = normal "T" +// bits 10-14: reserved +// bit 15: 1 = Invisible sprite, 0 = not invisible + + //44 bytes +typedef struct BPACK +{ + long x, y, z; + short cstat, picnum; + signed char shade; + char pal, clipdist, filler; + unsigned char xrepeat, yrepeat; + signed char xoffset, yoffset; + short sectnum, statnum; + short ang, owner, xvel, yvel, zvel; + short lotag, hitag, extra; +} spritetype; + +typedef struct BPACK { + unsigned long mdanimtims; + short mdanimcur; + short angoff; + short pitch, roll; + long xoff, yoff, zoff; + unsigned char flags; + char filler[3]; +} spriteexttype; + +typedef struct BPACK { + short mdcurframe, mdoldframe; + short mdsmooth; + float smoothduration; +} spritesmoothtype; + +#define SPREXT_NOTMD 1 +#define SPREXT_NOMDANIM 2 +EXTERN spriteexttype spriteext[MAXSPRITES+MAXUNIQHUDID]; +EXTERN spritesmoothtype spritesmooth[MAXSPRITES+MAXUNIQHUDID]; +EXTERN long guniqhudid; + +EXTERN sectortype sector[MAXSECTORS]; +EXTERN walltype wall[MAXWALLS]; +EXTERN spritetype sprite[MAXSPRITES]; + +EXTERN long spritesortcnt; +EXTERN spritetype tsprite[MAXSPRITESONSCREEN]; + +EXTERN long xdim, ydim, ylookup[MAXYDIM+1], numpages; +EXTERN long yxaspect, viewingrange; + +#define MAXVALIDMODES 256 +EXTERN long validmodecnt; +struct validmode_t { + long xdim,ydim; + char bpp; + char fs; // bit 0 = fullscreen flag + char filler[2]; + long extra; // internal use +}; +EXTERN struct validmode_t validmode[MAXVALIDMODES]; + +EXTERN short numsectors, numwalls; +EXTERN /*volatile*/ long totalclock; +EXTERN long numframes, randomseed; +EXTERN short sintable[2048]; +EXTERN char palette[768]; +EXTERN short numpalookups; +EXTERN char *palookup[MAXPALOOKUPS]; +EXTERN char parallaxtype, showinvisibility; +EXTERN long parallaxyoffs, parallaxyscale; +EXTERN long visibility, parallaxvisibility; + +EXTERN long windowx1, windowy1, windowx2, windowy2; +EXTERN short startumost[MAXXDIM], startdmost[MAXXDIM]; + +EXTERN short pskyoff[MAXPSKYTILES], pskybits; + +EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; +EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; +EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; + +EXTERN short tilesizx[MAXTILES], tilesizy[MAXTILES]; +EXTERN char picsiz[MAXTILES]; +EXTERN char walock[MAXTILES]; +EXTERN long pow2long[32]; +EXTERN long numtiles, picanm[MAXTILES], waloff[MAXTILES]; EXTERN int windowpos, windowx, windowy; - - //These variables are for auto-mapping with the draw2dscreen function. - //When you load a new board, these bits are all set to 0 - since - //you haven't mapped out anything yet. Note that these arrays are - //bit-mapped. - //If you want draw2dscreen() to show sprite #54 then you say: - // spritenum = 54; - // show2dsprite[spritenum>>3] |= (1<<(spritenum&7)); - //And if you want draw2dscreen() to not show sprite #54 then you say: - // spritenum = 54; - // show2dsprite[spritenum>>3] &= ~(1<<(spritenum&7)); - //Automapping defaults to 0 (do nothing). If you set automapping to 1, - // then in 3D mode, the walls and sprites that you see will show up the - // next time you flip to 2D mode. - -EXTERN char show2dsector[(MAXSECTORS+7)>>3]; -EXTERN char show2dwall[(MAXWALLS+7)>>3]; -EXTERN char show2dsprite[(MAXSPRITES+7)>>3]; -EXTERN char automapping; - -EXTERN char gotpic[(MAXTILES+7)>>3]; -EXTERN char gotsector[(MAXSECTORS+7)>>3]; - -EXTERN char captureformat; -extern char vgapalette[5*256]; -extern unsigned long drawlinepat; - -extern void faketimerhandler(void); - -extern char apptitle[256]; -typedef struct { - unsigned char r,g,b,f; -} palette_t; -extern palette_t curpalette[256], curpalettefaded[256], palfadergb; -extern char palfadedelta; - -extern long dommxoverlay, novoxmips; - -#ifdef SUPERBUILD -extern long tiletovox[MAXTILES]; -extern long usevoxels, voxscale[MAXVOXELS]; -#endif -#ifdef POLYMOST -extern long usemodels, usehightile; -#endif - -extern char *engineerrstr; -extern char noclip; - -/************************************************************************* -POSITION VARIABLES: - - POSX is your x - position ranging from 0 to 65535 - POSY is your y - position ranging from 0 to 65535 - (the length of a side of the grid in EDITBORD would be 1024) - POSZ is your z - position (height) ranging from 0 to 65535, 0 highest. - ANG is your angle ranging from 0 to 2047. Instead of 360 degrees, or - 2 * PI radians, I use 2048 different angles, so 90 degrees would - be 512 in my system. - -SPRITE VARIABLES: - - EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; - EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; - EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; - - Example: if the linked lists look like the following: - ???????????????????????????????? - Sector lists: Status lists: - ???????????????????????????????J - Sector0: 4, 5, 8 Status0: 2, 0, 8 - Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9 - Sector2: 3, 9 - ???????????????????????????????? - Notice that each number listed above is shown exactly once on both the - left and right side. This is because any sprite that exists must - be in some sector, and must have some kind of status that you define. - - -Coding example #1: - To go through all the sprites in sector 1, the code can look like this: - - sectnum = 1; - i = headspritesect[sectnum]; - while (i != -1) - { - nexti = nextspritesect[i]; - - //your code goes here - //ex: printf("Sprite %d is in sector %d\n",i,sectnum); - - i = nexti; - } - -Coding example #2: - To go through all sprites with status = 1, the code can look like this: - - statnum = 1; //status 1 - i = headspritestat[statnum]; - while (i != -1) - { - nexti = nextspritestat[i]; - - //your code goes here - //ex: printf("Sprite %d has a status of 1 (active)\n",i,statnum); - - i = nexti; - } - - insertsprite(short sectnum, short statnum); - deletesprite(short spritenum); - changespritesect(short spritenum, short newsectnum); - changespritestat(short spritenum, short newstatnum); - -TILE VARIABLES: - NUMTILES - the number of tiles found TILES.DAT. - TILESIZX[MAXTILES] - simply the x-dimension of the tile number. - TILESIZY[MAXTILES] - simply the y-dimension of the tile number. - WALOFF[MAXTILES] - the actual 32-bit offset pointing to the top-left - corner of the tile. - PICANM[MAXTILES] - flags for animating the tile. - -TIMING VARIABLES: - TOTALCLOCK - When the engine is initialized, TOTALCLOCK is set to zero. - From then on, it is incremented 120 times a second by 1. That - means that the number of seconds elapsed is totalclock / 120. - NUMFRAMES - The number of times the draw3dscreen function was called - since the engine was initialized. This helps to determine frame - rate. (Frame rate = numframes * 120 / totalclock.) - -OTHER VARIABLES: - - STARTUMOST[320] is an array of the highest y-coordinates on each column - that my engine is allowed to write to. You need to set it only - once. - STARTDMOST[320] is an array of the lowest y-coordinates on each column - that my engine is allowed to write to. You need to set it only - once. - SINTABLE[2048] is a sin table with 2048 angles rather than the - normal 360 angles for higher precision. Also since SINTABLE is in - all integers, the range is multiplied by 16383, so instead of the - normal -1=0 for a particular palette -// how: pass -1 to invalidate all instances of the tile in texture memory, or a bitfield -// bit 0: opaque or masked (non-translucent) texture, using repeating -// bit 1: ignored -// bit 2: 33% translucence, using repeating -// bit 3: 67% translucence, using repeating -// bit 4: opaque or masked (non-translucent) texture, using clamping -// bit 5: ignored -// bit 6: 33% translucence, using clamping -// bit 7: 67% translucence, using clamping -// clamping is for sprites, repeating is for walls -void invalidatetile(short tilenume, long pal, long how); - -long animateoffs(short tilenum, short fakevar); - -void setpolymost2dview(void); // sets up GL for 2D drawing - -long polymost_drawtilescreen(long tilex, long tiley, long wallnum, long dimen, int tilezoom); -void polymost_glreset(void); -void polymost_precache(long dapicnum, long dapalnum, long datype); - -#if defined(POLYMOST) && defined(USE_OPENGL) -extern long glanisotropy; -extern long glusetexcompr; -extern long gltexfiltermode; -extern long glredbluemode; -extern long glusetexcache, glusetexcachecompression; -extern long glmultisample, glnvmultisamplehint; -extern long glwidescreen, glprojectionhacks; -void gltexapplyprops (void); - -extern long r_depthpeeling, r_peelscount; -extern long r_detailmapping; -extern long r_glowmapping; -extern long r_vertexarrays; -extern long r_vbos; -extern long r_vbocount; -extern long r_animsmoothing; -#endif - -void hicinit(void); -// effect bitset: 1 = greyscale, 2 = invert -void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect); -// flags bitset: 1 = don't compress -int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags); -int hicsetskybox(long picnum, long palnum, char *faces[6]); -int hicclearsubst(long picnum, long palnum); - -int md_loadmodel(const char *fn); -int md_setmisc(int modelid, float scale, int shadeoff, float zadd); -int md_tilehasmodel(int tilenume); -int md_defineframe(int modelid, const char *framename, int tilenume, int skinnum, float smoothduration); -int md_defineanimation(int modelid, const char *framestart, const char *frameend, int fps, int flags); -int md_defineskin(int modelid, const char *skinfn, int palnum, int skinnum, int surfnum, float param); -int md_definehud (int modelid, int tilex, double xadd, double yadd, double zadd, double angadd, int flags); -int md_undefinetile(int tile); -int md_undefinemodel(int modelid); - -int loaddefinitionsfile(char *fn); - -extern long mapversion; // if loadboard() fails with -2 return, try loadoldboard(). if it fails with -2, board is dodgy -long loadoldboard(char *filename, char fromwhere, long *daposx, long *daposy, long *daposz, short *daang, short *dacursectnum); - -#ifdef _MSC_VER -#pragma pack() -#endif - -#ifdef __WATCOMC__ -#pragma pack(pop) -#endif - -#undef BPACK - -#ifdef __cplusplus -} -#endif - -#endif // __build_h__ + + //These variables are for auto-mapping with the draw2dscreen function. + //When you load a new board, these bits are all set to 0 - since + //you haven't mapped out anything yet. Note that these arrays are + //bit-mapped. + //If you want draw2dscreen() to show sprite #54 then you say: + // spritenum = 54; + // show2dsprite[spritenum>>3] |= (1<<(spritenum&7)); + //And if you want draw2dscreen() to not show sprite #54 then you say: + // spritenum = 54; + // show2dsprite[spritenum>>3] &= ~(1<<(spritenum&7)); + //Automapping defaults to 0 (do nothing). If you set automapping to 1, + // then in 3D mode, the walls and sprites that you see will show up the + // next time you flip to 2D mode. + +EXTERN char show2dsector[(MAXSECTORS+7)>>3]; +EXTERN char show2dwall[(MAXWALLS+7)>>3]; +EXTERN char show2dsprite[(MAXSPRITES+7)>>3]; +EXTERN char automapping; + +EXTERN char gotpic[(MAXTILES+7)>>3]; +EXTERN char gotsector[(MAXSECTORS+7)>>3]; + +EXTERN char captureformat; +extern char vgapalette[5*256]; +extern unsigned long drawlinepat; + +extern void faketimerhandler(void); + +extern char apptitle[256]; +typedef struct { + unsigned char r,g,b,f; +} palette_t; +extern palette_t curpalette[256], curpalettefaded[256], palfadergb; +extern char palfadedelta; + +extern long dommxoverlay, novoxmips; + +#ifdef SUPERBUILD +extern long tiletovox[MAXTILES]; +extern long usevoxels, voxscale[MAXVOXELS]; +#endif +#ifdef POLYMOST +extern long usemodels, usehightile; +#endif + +extern char *engineerrstr; +extern char noclip; + +/************************************************************************* +POSITION VARIABLES: + + POSX is your x - position ranging from 0 to 65535 + POSY is your y - position ranging from 0 to 65535 + (the length of a side of the grid in EDITBORD would be 1024) + POSZ is your z - position (height) ranging from 0 to 65535, 0 highest. + ANG is your angle ranging from 0 to 2047. Instead of 360 degrees, or + 2 * PI radians, I use 2048 different angles, so 90 degrees would + be 512 in my system. + +SPRITE VARIABLES: + + EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; + EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; + EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; + + Example: if the linked lists look like the following: + ???????????????????????????????? + Sector lists: Status lists: + ???????????????????????????????J + Sector0: 4, 5, 8 Status0: 2, 0, 8 + Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9 + Sector2: 3, 9 + ???????????????????????????????? + Notice that each number listed above is shown exactly once on both the + left and right side. This is because any sprite that exists must + be in some sector, and must have some kind of status that you define. + + +Coding example #1: + To go through all the sprites in sector 1, the code can look like this: + + sectnum = 1; + i = headspritesect[sectnum]; + while (i != -1) + { + nexti = nextspritesect[i]; + + //your code goes here + //ex: printf("Sprite %d is in sector %d\n",i,sectnum); + + i = nexti; + } + +Coding example #2: + To go through all sprites with status = 1, the code can look like this: + + statnum = 1; //status 1 + i = headspritestat[statnum]; + while (i != -1) + { + nexti = nextspritestat[i]; + + //your code goes here + //ex: printf("Sprite %d has a status of 1 (active)\n",i,statnum); + + i = nexti; + } + + insertsprite(short sectnum, short statnum); + deletesprite(short spritenum); + changespritesect(short spritenum, short newsectnum); + changespritestat(short spritenum, short newstatnum); + +TILE VARIABLES: + NUMTILES - the number of tiles found TILES.DAT. + TILESIZX[MAXTILES] - simply the x-dimension of the tile number. + TILESIZY[MAXTILES] - simply the y-dimension of the tile number. + WALOFF[MAXTILES] - the actual 32-bit offset pointing to the top-left + corner of the tile. + PICANM[MAXTILES] - flags for animating the tile. + +TIMING VARIABLES: + TOTALCLOCK - When the engine is initialized, TOTALCLOCK is set to zero. + From then on, it is incremented 120 times a second by 1. That + means that the number of seconds elapsed is totalclock / 120. + NUMFRAMES - The number of times the draw3dscreen function was called + since the engine was initialized. This helps to determine frame + rate. (Frame rate = numframes * 120 / totalclock.) + +OTHER VARIABLES: + + STARTUMOST[320] is an array of the highest y-coordinates on each column + that my engine is allowed to write to. You need to set it only + once. + STARTDMOST[320] is an array of the lowest y-coordinates on each column + that my engine is allowed to write to. You need to set it only + once. + SINTABLE[2048] is a sin table with 2048 angles rather than the + normal 360 angles for higher precision. Also since SINTABLE is in + all integers, the range is multiplied by 16383, so instead of the + normal -1=0 for a particular palette +// how: pass -1 to invalidate all instances of the tile in texture memory, or a bitfield +// bit 0: opaque or masked (non-translucent) texture, using repeating +// bit 1: ignored +// bit 2: 33% translucence, using repeating +// bit 3: 67% translucence, using repeating +// bit 4: opaque or masked (non-translucent) texture, using clamping +// bit 5: ignored +// bit 6: 33% translucence, using clamping +// bit 7: 67% translucence, using clamping +// clamping is for sprites, repeating is for walls +void invalidatetile(short tilenume, long pal, long how); + +long animateoffs(short tilenum, short fakevar); + +void setpolymost2dview(void); // sets up GL for 2D drawing + +long polymost_drawtilescreen(long tilex, long tiley, long wallnum, long dimen, int tilezoom); +void polymost_glreset(void); +void polymost_precache(long dapicnum, long dapalnum, long datype); + +#if defined(POLYMOST) && defined(USE_OPENGL) +extern long glanisotropy; +extern long glusetexcompr; +extern long gltexfiltermode; +extern long glredbluemode; +extern long glusetexcache, glusetexcachecompression; +extern long glmultisample, glnvmultisamplehint; +extern long glwidescreen, glprojectionhacks; +void gltexapplyprops (void); + +extern long r_depthpeeling, r_peelscount; +extern long r_detailmapping; +extern long r_glowmapping; +extern long r_vertexarrays; +extern long r_vbos; +extern long r_vbocount; +extern long r_animsmoothing; +#endif + +void hicinit(void); +// effect bitset: 1 = greyscale, 2 = invert +void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect); +// flags bitset: 1 = don't compress +int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags); +int hicsetskybox(long picnum, long palnum, char *faces[6]); +int hicclearsubst(long picnum, long palnum); + +int md_loadmodel(const char *fn); +int md_setmisc(int modelid, float scale, int shadeoff, float zadd); +int md_tilehasmodel(int tilenume); +int md_defineframe(int modelid, const char *framename, int tilenume, int skinnum, float smoothduration); +int md_defineanimation(int modelid, const char *framestart, const char *frameend, int fps, int flags); +int md_defineskin(int modelid, const char *skinfn, int palnum, int skinnum, int surfnum, float param); +int md_definehud (int modelid, int tilex, double xadd, double yadd, double zadd, double angadd, int flags); +int md_undefinetile(int tile); +int md_undefinemodel(int modelid); + +int loaddefinitionsfile(char *fn); + +extern long mapversion; // if loadboard() fails with -2 return, try loadoldboard(). if it fails with -2, board is dodgy +long loadoldboard(char *filename, char fromwhere, long *daposx, long *daposy, long *daposz, short *daang, short *dacursectnum); + +#ifdef _MSC_VER +#pragma pack() +#endif + +#ifdef __WATCOMC__ +#pragma pack(pop) +#endif + +#undef BPACK + +#ifdef __cplusplus +} +#endif + +#endif // __build_h__ diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c index 988d3dfb5..670a1f7bf 100644 --- a/polymer/build/src/engine.c +++ b/polymer/build/src/engine.c @@ -7172,7 +7172,10 @@ long loadmaphack(char *filename) T_NOMODEL, T_NOANIM, T_PITCH, - T_ROLL + T_ROLL, + T_MDXOFF, + T_MDYOFF, + T_MDZOFF }; static struct { char *text; int tokenid; } legaltokens[] = { @@ -7187,6 +7190,9 @@ long loadmaphack(char *filename) { "nomdanim", T_NOANIM }, { "pitch", T_PITCH }, { "roll", T_ROLL }, + { "mdxoff", T_MDXOFF }, + { "mdyoff", T_MDYOFF }, + { "mdzoff", T_MDZOFF }, { NULL, -1 } }; @@ -7277,6 +7283,46 @@ long loadmaphack(char *filename) } spriteext[whichsprite].roll = (short)roll; } + case T_MDXOFF: // mdxoff + { + int i; + if (scriptfile_getnumber(script, &i)) break; + + if (whichsprite < 0) { + // no sprite directive preceeding + initprintf("Ignoring mdxoff directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + spriteext[whichsprite].xoff = i; + } + case T_MDYOFF: // mdyoff + { + int i; + if (scriptfile_getnumber(script, &i)) break; + + if (whichsprite < 0) { + // no sprite directive preceeding + initprintf("Ignoring mdyoff directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + spriteext[whichsprite].yoff = i; + } + case T_MDZOFF: // mdzoff + { + int i; + if (scriptfile_getnumber(script, &i)) break; + + if (whichsprite < 0) { + // no sprite directive preceeding + initprintf("Ignoring mdzoff directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + spriteext[whichsprite].zoff = i; + } + break; default: diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 8c0be74c0..6e2b7094d 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -12567,70 +12567,3 @@ long GetTime(void) { return totalclock; } - -#if 0 -/* -=================== -= -= CenterCenter -= -=================== -*/ - -void CenterCenter(void) -{ - initprintf("Center the joystick and press a button\n"); -} - -/* -=================== -= -= UpperLeft -= -=================== -*/ - -void UpperLeft(void) -{ - initprintf("Move joystick to upper-left corner and press a button\n"); -} - -/* -=================== -= -= LowerRight -= -=================== -*/ - -void LowerRight(void) -{ - initprintf("Move joystick to lower-right corner and press a button\n"); -} - -/* -=================== -= -= CenterThrottle -= -=================== -*/ - -void CenterThrottle(void) -{ - initprintf("Center the throttle control and press a button\n"); -} - -/* -=================== -= -= CenterRudder -= -=================== -*/ - -void CenterRudder(void) -{ - initprintf("Center the rudder control and press a button\n"); -} -#endif diff --git a/polymer/eduke32/source/jfaud_sounds.cpp b/polymer/eduke32/source/jfaud_sounds.cpp deleted file mode 100644 index d6a9e9339..000000000 --- a/polymer/eduke32/source/jfaud_sounds.cpp +++ /dev/null @@ -1,768 +0,0 @@ -/* - * Audio support for JFDuke3D using JFAud - * by Jonathon Fowler (jonof@edgenetwork.org) - * - * Duke Nukem 3D 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 - * of the License, or (at your option) any later version. - * - * This program 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 should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Original Source: 1996 - Todd Replogle - * Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms - */ - -#include "types.h" -#include "duke3d.h" -extern "C" { -#ifdef RENDERTYPEWIN -# include "winlayer.h" -#endif -#include "osd.h" -long numenvsnds; -} - -typedef uint64 uint64_t; -#ifdef __APPLE__ -# include -#else -# include "jfaud.hpp" -#endif - -#define SOUNDM_LOOP 1 -#define SOUNDM_MSFX 2 -#define SOUNDM_DUKE 4 -#define SOUNDM_PARENT 8 -#define SOUNDM_GLOBAL 16 -#define SOUNDM_NICE 64 // Added for JFDuke3D so JFAud doesn't use nearest filtering for the sound -#define SOUNDM_PLAYER 128 - -#define UNITSPERMETRE 1024.0 -#define DEFAULTREFDIST (6720.0/1024.0) // in the original code, ((255-150)<<6) == 6720 -#define DEFAULTMAXDIST (31444.0/1024.0) // in the original code, 31444 -#define DEFAULTROLLOFF 1.0//0.75 -#define OCCLUDEDFACTOR 0.8 - -static JFAudMixerChannel::Filter DefaultFilter = JFAudMixerChannel::FilterNearest; -static int osdcmd_setsoundfilter(const osdfuncparm_t *parm); - -#ifdef SCREWED_UP_CPP -# include "watcomhax/cmath" -#else -# include -#endif - -#define MAXCACHE1DSIZE (16*1048576) - -class KenFile : public JFAudFile { -private: - int fh; -public: - KenFile(const char *filename, const char *subfilename) - : JFAudFile(filename, subfilename) - { - fh = kopen4load(const_cast(filename), 0); - } - - virtual ~KenFile() - { - if (fh >= 0) kclose(fh); - } - - virtual bool IsOpen(void) const { return fh >= 0; } - - virtual long Read(long nbytes, void *buf) - { - if (fh < 0) return -1; - return kread(fh, buf, nbytes); - } - virtual long Seek(long pos, SeekFrom where) - { - int when; - if (fh < 0) return -1; - switch (where) { - case JFAudFile::Set: when = SEEK_SET; break; - case JFAudFile::Cur: when = SEEK_CUR; break; - case JFAudFile::End: when = SEEK_END; break; - default: return -1; - } - return klseek(fh, pos, when); - } - virtual long Tell(void) const - { - if (fh < 0) return -1; - return klseek(fh, 0, SEEK_CUR); - } - virtual long Length(void) const - { - if (fh < 0) return -1; - return kfilelength(fh); - } -}; - -static JFAudFile *openfile(const char *fn, const char *subfn) -{ - return static_cast(new KenFile(fn,subfn)); -} - -static void logfunc(const char *s) { initprintf("jfaud: %s", s); } - -#define PITCHRANGE 2 // octave range in each direction -#define PITCHSTEPS 24 // pitch points per octave -static float pitchtable[PITCHRANGE*PITCHSTEPS*2+1]; -static void buildpitchtable(void) -{ - int i,j; - - for (i=-PITCHRANGE*PITCHSTEPS; i<=PITCHRANGE*PITCHSTEPS; i++) { - pitchtable[i+PITCHRANGE*PITCHSTEPS] = pow(1.0005777895, (1200.0/PITCHSTEPS)*(float)i); - } -} -static float translatepitch(int p) -{ - float t; - int x; - x = (p * PITCHSTEPS / 1200) + PITCHRANGE*PITCHSTEPS; - if (x < 0) x = 0; - else if (x > (int)(sizeof(pitchtable)/sizeof(float))) x = sizeof(pitchtable)/sizeof(float); - t = pitchtable[x]; - /*if (t > 2.0) { - initprintf("translatepitch(%d) > 2.0\n", p); - t = 2.0; - }*/ - return t; -} - -class SoundChannel { -public: - JFAudMixerChannel *chan; - int owner; // sprite number - int soundnum; // sound number - bool done; - - SoundChannel() - { - chan = NULL; - owner = -1; - soundnum = -1; - done = false; - } -}; - -static SoundChannel *chans = NULL; -static JFAud *jfaud = NULL; - -static bool havemidi = false, havewave = false; - - -static void stopcallback(int r) -{ - chans[r].done = true; -} - -void testcallback(unsigned long num) -{ -} - -static int keephandle(JFAudMixerChannel *handle, int soundnum, int owner) -{ - int i, freeh=-1; - for (i=NumVoices-1;i>=0;i--) { - if (!chans[i].chan && freeh<0) freeh=i; - else if (chans[i].chan == handle) { freeh=i; break; } - } - if (freeh<0) { - initprintf("Warning: keephandle() exhausted handle space!\n"); - return -1; - } - - chans[freeh].chan = handle; - chans[freeh].soundnum = soundnum; - chans[freeh].owner = owner; - chans[freeh].done = false; - - return freeh; -} - -void SoundStartup(void) -{ - int i; - - if (FXDevice < 0) return; - - if (jfaud) return; - buildpitchtable(); - - JFAud_SetLogFunc(logfunc); - - jfaud = new JFAud(); - if (!jfaud) return; - - jfaud->SetUserOpenFunc(openfile); -#ifdef _WIN32 - jfaud->SetWindowHandle((void*)win_gethwnd()); -#endif - - havewave = havemidi = false; - if (!jfaud->InitWave("software", NumVoices, MixRate)) { - delete jfaud; - jfaud = NULL; - return; - } - - { - // the engine will take 60% of the system memory size for cache1d if there - // is less than the 16MB asked for in loadpics(), so we'll - // take 30% of what's left for the sound cache if that happened, or - // 50% of the system memory sans the 16MB maximum otherwise - unsigned k; - if (Bgetsysmemsize() <= MAXCACHE1DSIZE) - k = Bgetsysmemsize()/100*30; - else - k = Bgetsysmemsize()/100*50 - MAXCACHE1DSIZE; - jfaud->SetCacheSize(k,k/2); - jfaud->SetCacheItemAge(24*120); // 24 movements per second, 120 seconds max lifetime - } - - chans = new SoundChannel[NumVoices]; - if (!chans) { - delete jfaud; - jfaud = NULL; - return; - } - - havewave = true; - - if (jfaud->InitMIDI(NULL)) havemidi = true; - - OSD_RegisterFunction("setsoundfilter","setsoundfilter: 0=nearest 1=linear 2=4point",osdcmd_setsoundfilter); -} - -void SoundShutdown(void) -{ - if (jfaud) delete jfaud; - if (chans) delete [] chans; - jfaud = NULL; - chans = NULL; - havewave = havemidi = false; -} - -void MusicStartup(void) -{ -} - -void MusicShutdown(void) -{ -} - -void AudioUpdate(void) -{ - int i; - - if (!jfaud) return; - if (havewave) - for (i=NumVoices-1; i>=0; i--) { - if (!chans[i].done) continue; - if (chans[i].chan) jfaud->FreeSound(chans[i].chan); - chans[i].chan = NULL; - chans[i].done = false; - - if (chans[i].owner >= 0 && - sprite[chans[i].owner].picnum == MUSICANDSFX && - sector[sprite[chans[i].owner].sectnum].lotag < 3 && - sprite[chans[i].owner].lotag < 999) - hittype[chans[i].owner].temp_data[0] = 0; - } - jfaud->Update(false); // don't age the cache here -} - - -static char menunum = 0; -void intomenusounds(void) -{ - short i; - short menusnds[] = { - LASERTRIP_EXPLODE, DUKE_GRUNT, DUKE_LAND_HURT, - CHAINGUN_FIRE, SQUISHED, KICK_HIT, - PISTOL_RICOCHET, PISTOL_BODYHIT, PISTOL_FIRE, - SHOTGUN_FIRE, BOS1_WALK, RPG_EXPLODE, - PIPEBOMB_BOUNCE, PIPEBOMB_EXPLODE, NITEVISION_ONOFF, - RPG_SHOOT, SELECT_WEAPON - }; - sound(menusnds[menunum++]); - menunum %= sizeof(menusnds)/sizeof(menusnds[0]); -} - -void playmusic(const char *fn) -{ - char dafn[BMAX_PATH], *dotpos; - int i; - const char *extns[] = { ".ogg",".mp3",".mid", NULL }; - - if (!MusicToggle) return; - if (!jfaud) return; - - dotpos = Bstrrchr((char *)fn,'.'); - if (dotpos && Bstrcasecmp(dotpos,".mid")) { - // has extension but isn't midi - jfaud->PlayMusic(fn, NULL); - } else { - Bstrcpy(dafn,fn); - dotpos = Bstrrchr(dafn,'.'); - if (!dotpos) dotpos = dafn+strlen(dafn); - - for (i=0; extns[i]; i++) { - Bstrcpy(dotpos, extns[i]); - if (jfaud->PlayMusic(dafn, NULL)) return; - } - } -} - -int loadsound(unsigned short num) { return 1; } - -int isspritemakingsound(short i, int num) // if num<0, check if making any sound at all -{ - int j,n=0; - - if (!jfaud || !havewave) return 0; - for (j=NumVoices-1; j>=0; j--) { - if (chans[j].done || !chans[j].chan) continue; - if (chans[j].owner != i) continue; - if (num < 0 || chans[j].soundnum == num) n++; - } - return n; -} - -int issoundplaying(short i, int num) -{ - int j,n=0; - - if (!jfaud || !havewave) return 0; - for (j=NumVoices-1; j>=0; j--) { - if (chans[j].done || !chans[j].chan) continue; - if (chans[j].soundnum == num) n++; - } - - return n; -} - -int xyzsound(short num, short i, long x, long y, long z) -{ - JFAudMixerChannel *chan; - int r, global = 0; - float gain = 1.0, pitch = 1.0, refdist = DEFAULTREFDIST, maxdist = DEFAULTMAXDIST, rolloff = DEFAULTROLLOFF; - - if (!jfaud || !havewave || - num >= NUM_SOUNDS || - ((soundm[num] & SOUNDM_PARENT) && ud.lockout) || // parental mode - SoundToggle == 0 || - (g_player[myconnectindex].ps->timebeforeexit > 0 && g_player[myconnectindex].ps->timebeforeexit <= 26*3) || - (g_player[myconnectindex].ps->gm & MODE_MENU) - ) return -1; - - if (soundm[num] & SOUNDM_PLAYER) { - sound(num); - return 0; - } - - if (soundm[num] & SOUNDM_DUKE) { - // Duke speech, one at a time only - int j; - - if (VoiceToggle == 0 || - (ud.multimode > 1 && PN == APLAYER && sprite[i].yvel != screenpeek && ud.coop != 1) - ) return -1; - - for (j=NumVoices-1; j>=0; j--) { - if (chans[j].done || !chans[j].chan || chans[j].owner < 0) continue; - if (soundm[ chans[j].soundnum ] & SOUNDM_DUKE) return -1; - } - } - - if( i >= 0 && !(soundm[num] & SOUNDM_GLOBAL) && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9) { - float d = (float)SHT/UNITSPERMETRE; - refdist = d / 2.0; - maxdist = d; - rolloff = 1.0; - } - - { - int ps = soundps[num], pe = soundpe[num], cx; - cx = labs(pe-ps); - if (cx) { - if (ps < pe) pitch = translatepitch(ps + rand()%cx); - else pitch = translatepitch(pe + rand()%cx); - } else pitch = translatepitch(ps); - } - - { - float d = 1.0-(float)soundvo[num]/(12.0*1024.0); - maxdist *= d; - refdist *= d; - } - if (PN != MUSICANDSFX && - !cansee(g_player[screenpeek].ps->oposx,g_player[screenpeek].ps->oposy,g_player[screenpeek].ps->oposz-(24<<8), - g_player[screenpeek].ps->cursectnum,SX,SY,SZ-(24<<8),SECT) ) - gain *= OCCLUDEDFACTOR; - - switch(num) - { - case PIPEBOMB_EXPLODE: - case LASERTRIP_EXPLODE: - case RPG_EXPLODE: - gain = 1.0; - global = 1; - if (sector[g_player[screenpeek].ps->cursectnum].lotag == 2) pitch -= translatepitch(1024); - break; - default: - if(sector[g_player[screenpeek].ps->cursectnum].lotag == 2 && (soundm[num]&SOUNDM_DUKE) == 0) - pitch = translatepitch(-768); - //if( sndist > 31444 && PN != MUSICANDSFX) - // return -1; - break; - } - -/* - // XXX: this is shit - if( Sound[num].num > 0 && PN != MUSICANDSFX ) - { - if( SoundOwner[num][0].i == i ) stopsound(num); - else if( Sound[num].num > 1 ) stopsound(num); - else if( badguy(&sprite[i]) && sprite[i].extra <= 0 ) stopsound(num); - } -*/ - - chan = jfaud->PlaySound(sounds[num], NULL, soundpr[num]); - if (!chan) return -1; - - chan->SetGain(gain); - chan->SetPitch(pitch); - chan->SetLoop((soundm[num] & SOUNDM_LOOP) == SOUNDM_LOOP); - if (soundm[num] & SOUNDM_GLOBAL) global = 1; - chan->SetRefDist(refdist); - chan->SetMaxDist(maxdist); - chan->SetFilter((soundm[num]&SOUNDM_NICE) ? JFAudMixerChannel::Filter4Point : DefaultFilter); - chan->SetDistanceModel(JFAudMixerChannel::DistanceModelLinear); - - if (PN == APLAYER && sprite[i].yvel == screenpeek) { - chan->SetRolloff(0.0); - chan->SetFollowListener(true); - chan->SetPosition(0.0, 0.0, 0.0); - } else { - chan->SetRolloff(global ? 0.0 : rolloff); - chan->SetFollowListener(false); - chan->SetPosition((float)x/UNITSPERMETRE, (float)(-z>>4)/UNITSPERMETRE, (float)y/UNITSPERMETRE); - } - r = keephandle(chan, num, i); - if (r >= 0) chan->SetStopCallback(stopcallback, r); - chan->Play(); - - return 0; -} - -void sound(short num) -{ - JFAudMixerChannel *chan; - int r; - float pitch = 1.0; - - if (!jfaud || !havewave || - num >= NUM_SOUNDS || - SoundToggle == 0 || - ((soundm[num] & SOUNDM_DUKE) && VoiceToggle == 0) || - ((soundm[num] & SOUNDM_PARENT) && ud.lockout) // parental mode - ) return; - - { - int ps = soundps[num], pe = soundpe[num], cx; - cx = labs(pe-ps); - if (cx) { - if (ps < pe) pitch = translatepitch(ps + rand()%cx); - else pitch = translatepitch(pe + rand()%cx); - } else pitch = translatepitch(ps); - } - - chan = jfaud->PlaySound(sounds[num], NULL, soundpr[num]); - if (!chan) return; - - chan->SetGain(1.0); - chan->SetPitch(pitch); - chan->SetLoop((soundm[num] & SOUNDM_LOOP) == SOUNDM_LOOP); - chan->SetRolloff(0.0); - chan->SetRefDist(DEFAULTREFDIST); - chan->SetFollowListener(true); - chan->SetPosition(0.0, 0.0, 0.0); - chan->SetFilter((soundm[num]&SOUNDM_NICE) ? JFAudMixerChannel::Filter4Point : DefaultFilter); - chan->SetDistanceModel(JFAudMixerChannel::DistanceModelLinear); - - r = keephandle(chan, num, -1); - if (r >= 0) chan->SetStopCallback(stopcallback, r); - chan->Play(); -} - -int spritesound(unsigned short num, short i) -{ - if (num >= NUM_SOUNDS) return -1; - return xyzsound(num,i,SX,SY,SZ); -} - -void stopsound(short num) -{ - int j; - - if (!jfaud || !havewave) return; - for (j=NumVoices-1;j>=0;j--) { - if (chans[j].done || !chans[j].chan || chans[j].soundnum != num) continue; - - jfaud->FreeSound(chans[j].chan); - chans[j].chan = NULL; - chans[j].done = false; - } -} - -void stopspritesound(short num, short i) -{ - int j; - - if (!jfaud || !havewave) return; - for (j=NumVoices-1;j>=0;j--) { - if (chans[j].done || !chans[j].chan || chans[j].owner != i || chans[j].soundnum != num) continue; - - jfaud->FreeSound(chans[j].chan); - chans[j].chan = NULL; - chans[j].done = false; - return; - } -} - -void stopenvsound(short num, short i) -{ - int j; - - if (!jfaud || !havewave) return; - for (j=NumVoices-1;j>=0;j--) { - if (chans[j].done || !chans[j].chan || chans[j].owner != i) continue; - - jfaud->FreeSound(chans[j].chan); - chans[j].chan = NULL; - chans[j].done = false; - } -} - -void pan3dsound(void) -{ - JFAudMixer *mix; - int j, global; - short i; - long cx, cy, cz, sx,sy,sz; - short ca,cs; - float gain, rolloff; - - numenvsnds = 0; - if (!jfaud || !havewave) return; - mix = jfaud->GetWave(); - if (!mix) return; - - jfaud->AgeCache(); - - if(ud.camerasprite == -1) { - cx = g_player[screenpeek].ps->oposx; - cy = g_player[screenpeek].ps->oposy; - cz = g_player[screenpeek].ps->oposz; - cs = g_player[screenpeek].ps->cursectnum; - ca = g_player[screenpeek].ps->ang+g_player[screenpeek].ps->look_ang; - } else { - cx = sprite[ud.camerasprite].x; - cy = sprite[ud.camerasprite].y; - cz = sprite[ud.camerasprite].z; - cs = sprite[ud.camerasprite].sectnum; - ca = sprite[ud.camerasprite].ang; - } - - mix->SetListenerPosition((float)cx/UNITSPERMETRE, (float)(-cz>>4)/UNITSPERMETRE, (float)cy/UNITSPERMETRE); - mix->SetListenerOrientation((float)sintable[(ca+512)&2047]/16384.0, 0.0, (float)sintable[ca&2047]/16384.0, - 0.0, 1.0, 0.0); - - for (j=NumVoices-1; j>=0; j--) { - if (chans[j].done || !chans[j].chan || chans[j].owner < 0) continue; - - global = 0; - gain = 1.0; - rolloff = DEFAULTROLLOFF; - i = chans[j].owner; - - sx = sprite[i].x; - sy = sprite[i].y; - sz = sprite[i].z; - - if (PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,sx,sy,sz-(24<<8),SECT) ) - gain *= OCCLUDEDFACTOR; - - if(PN == MUSICANDSFX && SLT < 999) rolloff = 1.0; - if( soundm[ chans[j].soundnum ]&SOUNDM_GLOBAL ) global = 1; - - switch(chans[j].soundnum) { - case PIPEBOMB_EXPLODE: - case LASERTRIP_EXPLODE: - case RPG_EXPLODE: - gain = 1.0; - global = 1; - break; - default: - //if( sndist > 31444 && PN != MUSICANDSFX) { - // stopsound(j); - // continue; - //} - break; - } - - // A sound may move from player-relative 3D if the viewpoint shifts from the player - // through a viewscreen or viewpoint switching - chans[j].chan->SetGain(gain); - if (PN == APLAYER && sprite[i].yvel == screenpeek) { - chans[j].chan->SetRolloff(0.0); - chans[j].chan->SetFollowListener(true); - chans[j].chan->SetPosition(0.0, 0.0, 0.0); - } else { - chans[j].chan->SetRolloff(global ? 0.0 : rolloff); - chans[j].chan->SetFollowListener(false); - chans[j].chan->SetPosition((float)sx/UNITSPERMETRE, (float)(-sz>>4)/UNITSPERMETRE, (float)sy/UNITSPERMETRE); - } - } -} - -void clearsoundlocks(void) -{ -} - -void FX_SetVolume( int volume ) -{ -} - -void FX_SetReverseStereo( int setting ) -{ -} - -void FX_SetReverb( int reverb ) -{ -} - -void FX_SetReverbDelay( int delay ) -{ -} - -int FX_VoiceAvailable( int priority ) -{ - if (!jfaud) return 0; - return 1; -} - -int FX_PlayVOC3D( char *ptr, int pitchoffset, int angle, int distance, - int priority, unsigned long callbackval ) -{ - printf("FX_PlayVOC3D()\n"); - return 0; -} - -int FX_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance, - int priority, unsigned long callbackval ) -{ - printf("FX_PlayWAV3D()\n"); - return 0; -} - -int FX_StopSound( int handle ) -{ - printf("FX_StopSound()\n"); - return 0; -} - -int FX_StopAllSounds( void ) -{ - int j; - - if (!jfaud || !havewave) return 0; - for (j=NumVoices-1; j>=0; j--) { - if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan)) continue; - - jfaud->FreeSound(chans[j].chan); - chans[j].chan = NULL; - chans[j].owner = -1; - } - - return 0; -} - -void MUSIC_SetVolume( int volume ) -{ -} - -void MUSIC_Pause( void ) -{ - if (jfaud) jfaud->PauseMusic(true); -} - -void MUSIC_Continue( void ) -{ - if (jfaud) jfaud->PauseMusic(false); -} - -int MUSIC_StopSong( void ) -{ - if (jfaud) jfaud->StopMusic(); - return 0; -} - -void MUSIC_RegisterTimbreBank( unsigned char *timbres ) -{ -} - -static int osdcmd_setsoundfilter(const osdfuncparm_t *parm) -{ - int filt = 0; - if (parm->numparms < 1) return OSDCMD_SHOWHELP; - - filt = Batol(parm->parms[0]); - if (filt < JFAudMixerChannel::FilterNearest) filt = JFAudMixerChannel::FilterNearest; - else if (filt > JFAudMixerChannel::Filter4Point) filt = JFAudMixerChannel::Filter4Point; - DefaultFilter = (JFAudMixerChannel::Filter)filt; - return OSDCMD_OK; -} - -int EnumAudioDevs(struct audioenumdrv **wave, struct audioenumdev **midi, struct audioenumdev **cda) -{ - char **enumerdrv, *defdrv; - int i; - bool isdefdrv, isdefdev; - struct audioenumdev **d; - - *wave = NULL; - //*midi = *cda = NULL; - - enumerdrv = JFAud::EnumerateWaveDevices(NULL, &defdrv); - if (enumerdrv) { - *wave = (struct audioenumdrv *)calloc(1,sizeof(struct audioenumdrv)); - (*wave)->def = defdrv; - (*wave)->drvs = enumerdrv; - (*wave)->devs = NULL; - d = &(*wave)->devs; - for (i=0; enumerdrv[i]; i++) { - *d = (struct audioenumdev *)calloc(1,sizeof(struct audioenumdev)); - (*d)->devs = JFAud::EnumerateWaveDevices(enumerdrv[i], &(*d)->def); - (*d)->next = NULL; - d = &(*d)->next; - } - } - - return 0; -} -