diff --git a/polymer/build/ChangeLog b/polymer/build/ChangeLog new file mode 100644 index 000000000..d04af939e --- /dev/null +++ b/polymer/build/ChangeLog @@ -0,0 +1,495 @@ +8 Jun 2004 + + * Transparency bug noticed by Usurper should now be fixed. + * MD2 definition problem noticed by Parkar should also be fixed too. + + +5 Jun 2004 + + * Some foolish bugs in my (JonoF) code in the MD2 stuff now fixed. + * Linux should be fine now. At least, it worked on my machine. + + +3 Jun 2004 + + * MD2 model support is official now. We've also added a script reader + for the new .DEF format. KenBuild uses KENBUILD.DEF for its stuff. + + +26 May 2004 + + * glusecds is set to 0 by default now. The glusecds console variable + can be set to 1 to enable the use of the ChangeDisplaySettings() + function which works better for Intel video chipsets. + + +22 May 2004 + + * Gave things a nice overhaul to cut back the insanity of the + classic/softpolymost/glpolymost stuff. It was beginning to scare + me. The underhanded and behind-the-back tricks are banished. + + The whole rendermethod thing is gone. Now, setgamemode() and + related paraphenalia all accept a 'bits-per-pixel' parameter. + Colour depths > 8 are forced to use GL polymost (naturally). + 8bpp modes can use the regular renderer, and the software polymost + stuff. This means switchrendermethod() is removed from the layers. + + SDLayer.c is back in sync too, so Build on Linux works again. + + +8 May 2004 + + * Finally remembered to add 33%/66% translucency support to hightile + tiles. + + +8 Mar 2004 + + * Added setpalettefadeclamps() to allow continual palette tinting + effects. + * Added back PCX format screenshot saving. The new screenshotformat + console variable selects whether to take PCX format (= 0, default) + or TGA format (= 1). + + +12 Feb 2004 + + * Greyscaling and inverting of tiles in hightile/polymost added. + This makes Duke's nightvision work better for Hightile textures + that use palette 6. + + +11 Feb 2004 + + * Broke out the non-OSD related commands from osd.c into baselayer.c. + * Added alternative display mode setting method using + ChangeDisplayMode() which can optionally be used for OpenGL mode + changes. Set the environment variable BUILD_USEGLCDS=TRUE to use. + * Added the glcolourdepth variable for selection of fullscreen GL + colour depth. + * Changed OSD_HandleKey() to not ignore releases, otherwise the game + world will always think its keys are held down. It ignores presses + though, which we want. + + +10 Feb 2004 + + * Added some protection to [k]?dfread() to indicate whether they + have failed to decompress some bytes so that the game doesn't + crash if a demo or savegame is fragged. + + +7 Feb 2004 + + * Hightile integration seems fine now. New functions to specify + replacement textures and palette tints can be seen in build.h. + * Joystick support is added. Seems to work. + * Hopefully a change I've made to the tile selector in Build when + using OpenGL mode has fixed the problem of the edges being + clipped off the screen... + + +22 Jan 2004 + + * Modified screencapture() to not overwrite existing screenshots. + + +19 Jan 2004 + + * loadboard() got a new second parameter inserted. This tells + kopen4load() where to seek out the map file. The values are: + 0 - anywhere + 1 - the first GRP file (same as setting strlen(fn)-1 to 0xff) + 2 - any grp file + + +17 Jan 2004 + + * Fixed Bcorrectfilename() to handle Win98's different operation + of GetFullPathName() when compared to Win2k. Now Build doesn't + ascend 2 directories at once when running on 98. + + +16 Jan 2004 + + * Undid some stuff which was a little braindamaged in winlayer.c. + I can't for the life of me remember why I was destroying the + window and recreating it when switching rendering modes when it + was entirely unnecessary and could potentially piss off other + services which aren't expecting their window handle to suddenly + be invalid, like DirectSound. + * In typical JonoF style of a couple of years ago, I made an error + when I did the gruntwork to port Build to Windows and as a + sideeffect of my unchecked amateurness I bent the point + highlighting in the editor. It's straightened now. :-( + + +12 Jan 2004 + + * sdlayer.c has been brought into line with winlayer.c. Now + everything that winlayer.c also works in SDL. + + +10 Jan 2004 + + * Added uninitsinglegroupfile() to unload a particular group file. + * Added a mechanism to do a "findfirst/next" over the group files. + * Modified Build.c to include maps inside the GRPs in the file + list. + + +2 Jan 2004 + + * Crash bug on starting Build editor fixed. See list of original + bugs for information. + + +1 Jan 2004 + + * Many Polymost bugs fixed. Mirrors now work. All kinds of funky + stuff. + + +29 Dec 2003 + + * Updated screencapture() to support GL modes. + * Modified 2D mode editor screen capture to keep the status bar + visible. Done with Ken's blessing. + + +23 Dec 2003 + + * Build mouse sensitivity has changed to use a floating point value + in the configuration file to specify the sen + * First public release of Ken's new "Polymost" renderer. 6 degrees + of freedom and full 3D rendering, including OpenGL. + * Palette handling has changed somewhat drastically. The engine now + supports palette fading natively, which means where games used + to manipulate a copy of the palette and send it to the video card, + this manipulation is now done by the engine via a function named + setpalettefade(). See the header for details. In adding this, + setbrightness() gained a third parameter, which is almost always + passed as 0 unless doing a palette fade and adjusting the game + palette immediately before it, in which case pass 1 so that + setbrightness() doesn't apply its base palette, otherwise weird + palette flashes will happen and we don't want that. + This was all necessary in order to let Ken's Polymost code have + access to the basic, unmodified palette for its own purposes. + + +20 Dec 2003 + + * Dynamic player collection has been cleaned up ever so slightly and + seems to work pretty well so far on just my LAN. No internet test + has been performed yet. + * Screen tilting in game.c now uses polymost's tilting abilities if + rendmode > 0 is used. + + +10 Dec 2003 + + * Dynamic player collection works at this stage. It's all implemented + in game-land because it's easier to do at this stage, but I + anticipate moving most of the general stuff into the engine if I + find it necessary. + + +6 Dec 2003 + + * Modified the checkvideomodes() function in winlayer.c to behave + slightly different and return 0x7fffffffl if the video mode passed + is not a recognized mode in windowed operation, otherwise it + returns the video mode index in validmode*[]. Sdlayer.c isn't + modified to do this yet. + * Applied Ken's fix for crashes which ensue when calling rotatesprite + inside drawrooms. See details in bug fixes list below. + + +5 Dec 2003 + + * At 2.50pm today jmulti.c achieved operational capacity and survived + a 15 minute 2-player network game with my father on our LAN. + + +25 Nov 2003 + + * Added a missing "CDECLENDSET 6" on line 504 of a.nasm. Without it + the registers are trashed upon return which made Win98 crash when + running GCC-built executables. + + +24 Nov 2003 + + * Silly typo fixed in winlayer.c. + + +23 Nov 2003 + + * Modified build.c and config.c to use integer arithmetic for mouse + sensitivity stuff. I don't like floating-point all that much out of + a general sense of prejudice. + + +19 Nov 2003 + + * Modified the Build editor such that it no longer is constrained to + 640x480 in 2D mode. It now defaults to using the same resolution + that is selected in 3D mode, but may be overridden by using a + new setting named '2dresolution' in the build.cfg file. It uses the + same mode numbers as the existing 'resolution' setting. + * Ctrl+A, Ctrl+Z, KP2, KP4, KP6, and KP8 in 3D mode, plus A and Z in + 2D mode are now speed limited. + + +19 Oct 2003 + + * Fixed some brain damaged error causing crashes when hitting enter + after entering a filename for Save As. I really am dumb sometimes. + * Added mouse sensitivity to Build editor. Add this to your build.cfg + ; Mouse sensitivity + ; 128 = 1:2 + ; 256 = 1:1 + ; 512 = 2:1 + mousesensitivity = 256 + + +4 Oct 2003 + + * Modified things to allow compilation with Microsoft C. Building + with MSC requires using the C-only configuration, which is how + the makefile is currently configured. + + +13 Sep 2003 + + * Added tab-completion of symbols into the OSD. + * Moved the "dumpbuildinfo" console function from the Duke source + into the OSD as a basic function. + + +11 Sep 2003 + + * Engine now able to build entirely from C source. Assembly + is entirely optional now. + * Engine now compiles with OpenWatcom 1.0. + + +22 May 2003 + + * Fixed a bug where the movement clipping lines array was being + overrun in extreme circumstances. Thanks to BlasterDRP for + pointing this out. See the epilogue for more details. + + +17 May 2003 + + * With Ken's help the rendering performance in 1024x768 is now + dramatically improved. By making scanlines odd lengths the CPU + cache issues associated with multiples of 4096 are now eliminated. + * Modified the 16-colour emulation functions since 640 bytes is no + longer the pitch of one line. + * Added auto-repainting of the frame if WM_PAINT is posted in the + winlayer. The repaint happens on a call to handleevents(); + + +15 May 2003 + + * Rewrote the map menu. + + +11 May 2003 + + * Rewrote the onscreen display. It's now a lot like Quake's console. + + +7 May 2003 + + * Changed CACHE1D.C to open the group file in read-only mode. Why it + was being opened in random-access is a mystery to me. This fixes + problems where the GRP file was read-only and the games would not + start. Thanks to Sean Magiera for this one. + * Added detection of input devices to winlayer.c (and made sdlayer.c + currently enable only keyboard and mouse without testing). Now the + Duke input code can grow a little more intelligent. + + +1 May 2003 + + * Made Ctrl+Tab show sprite stats in the way Alt+Tab does. + * Added task switching disabling to winlayer.c. + + +25 Apr 2003 + + * Modifications here and there, plus I've adjusted the Makefile to + allow code which links against the engine to compile its own copy + in its development tree. Duke uses this to compile the engine + without voxel support. + + +17 Apr 2003 + + * Various changes have been made in order to fully support my Duke3D + port. + + +7 Apr 2003 + + * Quite a few minor changes have been made here and there. + * Added support to the interface layers for game-defined input event + callbacks which are used with the jMACT library I have written for + Duke. + * Fixed a bug which was preventing screen-tilting and savegame screen- + shots from being drawn in Duke3D. Side-effect being windowed render + mode is now more similar to fullscreen in its behaviour, ie. the + frameplace variable is set to NULL when unlocked. + + +1 Apr 2003 + + * Thanks to a report by admin@combatgold1.co.uk these bugs are fixed: + - Alt-key combinations broken. Thankyou for nothing, DirectInput. + - Prompts for menu, 3d-mode quit, etc not being displayed. A little + short-sightedness on my part to blame here. + - Crash on changing palette to a palette mapping that is NULL. + This has been a bug from the very beginning in Ken's original DOS + version too, benign back then but turned malignant now thanks to + the great debugging tool known as the segmentation fault. Fixed now. + * Took a leaf from SDL's book and made the input code not suck anymore + by having buffered keyboard and mouse with event objects to tell when + there's data available. Very nice. Something I should have done from + the start had I had a brain. Mouse is now perfectly smooth. + * Made the flash speed of highlighted sprites and lines in Build derive + from the clock and not the speed at which the frames can be drawn to + the display. In DOS, locking to the display refresh worked fine, but + my haste in porting originally did not take this into account. Fixed + now. + * Fixed a problem in my very amateur DirectDraw code where I wasn't + restoring surfaces once they'd been lost (d'uh). We now have a picture + when Alt-tabbing back to the game/editor. + * Made operation on 8-bit desktops much more sane. It actually kinda + works reliably now. + + +Bugs present in Ken's original source +------------------------------------- + +This epilogue is here for those people wishing to do their own port of +the Build source and wish to save time tracking down bugs in Ken's source. +The bugs here are the ones I found during my travels and the list should +not be considered complete. Thankfully, Ken's code is very solid and the +bugs that do exist did not pose a serious threat under DOS, but they do +make life very interesting these days. + +(Line numbers refer to Ken's original source distribution) + +ENGINE.C (various locations): + Before this fix is applied you may notice crashes in game.exe + if you press Enter (main keyboard). In Ken's words: + + | It crashes in dorotatesprite because it accesses rx1[], ry1[], + | rx2[], and ry2[] - global arrays which were originally intended + | to be used only by drawrooms! When I wrote that code, I must have + | assumed rotatesprite would never be called INSIDE drawrooms... + | which makes sense because I wrote rotatesprite before I wrote + | all that faketimerhandler stuff. + + The solution is to place this line below somewhere, Ken suggests + immediately before clippoly4, but I chose to keep it with the rest + of static variables in ENGINE.C and put it on line 156: + + static long nrx1[8], nry1[8], nrx2[8], nry2[8]; + + Then, all references to rx1[], ry1[], rx2[], and ry2[] in + clippoly4 and dorotatesprite *ONLY* need to be prefixed with an + 'n'. Only those functions need patching, and nothing else. + + +ENGINE.C l1222, l1388, l7225: + palookup[] is accessed from the assembly functions to translate + palette indexes to alternate indexes for palette-shifting of + images. It contains pointers to tables which map the original + palette index to the new index. Unused lookup entries have their + pointer set to NULL. If a NULL palette lookup is referenced then + a null-pointer exception is raised. In DOS this just caused + garbage palette mappings. In Windows/Linux it causes segfaults. + A fix for this is to add a line after the specified ones like: + + if (!globalpalwritten) globalpalwritten = palookup[globalpal]; + + This remaps the NULL palette to the default one. + +ENGINE.C l5691, l5692, l5697, l5698: + drawline16() is used for the 2D map view in the BUILD editor. + In the clipping calculations it sometimes happens that the x- + coordinates are not properly clipped to the left or right of the + video memory and are offscreen by one or two pixels when clipping + against the very top or very bottom rows of video memory. Adding + these checks before the closing braces of the specified lines + makes sure the coordinate does not go negative and segfault. + + Line 5691 and 5698: if (x1 < 0) x1 = 0; + Line 5692 and 5697: if (x2 < 0) x2 = 0; + +ENGINE.C l88, l8326: + slopalookup[] is a table used for drawing sloped sector floors + and ceilings. It holds the palette shading indicies for each + scanline. Problem is, in high resolutions somewhere around + 1024x768, this array is too small and memory corruption happens + when the code writes past the end of this array. The way to fix + it is to rewrite the algorithm. Since that's an unattractive + proposition, increasing the size of this array will hold the + problem off for more typical cases. + + Line 88: long slopalookup[16384]; + Line 8326: ... else shoffs = ((16380-ydimen)<<15); + +ENGINE.C l6773: + The addclipline() macro appends a clipping line for the movement + clipping code to test, but it doesn't attempt to see if adding + the new line would overrun the buffer. Extreme cases exist where + the buffer overruns and the game crashes. The problem can be fixed + by testing if clipnum is less than MAXCLIPNUM before adding the + new line. + + #define addclipline(dax1, day1, dax2, day2, daoval) \ + { \ + if (clipnum < MAXCLIPNUM) { \ + clipit[clipnum].x1 = dax1; clipit[clipnum].y1 = day1; \ + clipit[clipnum].x2 = dax2; clipit[clipnum].y2 = day2; \ + clipobjectval[clipnum] = daoval; \ + clipnum++; \ + } \ + } \ + + This change will increase the possibility of clipping bugs though + because not all possible sprites may being included in the test, + so increasing the MAXCLIPNUM constant on line 31 to 1024 will + decrease the chance of this happening. + +ENGINE.C l7880: + The for loop that reverses the rendered image of a mirror is + iterating one too many times. Change the for loop to read: + + for(dy=mirrorsy2-mirrorsy1-1;dy>=0;dy--) + +BUILD.C l2137: + gettile() sometimes gets handed a tile with an index of -1, and + doesn't adjust this to something safe before it tries to draw the + cursor for the selected tile. This is demonstrated by loading + nukeland.map in Build.exe, and making a 1-way wall on the ledge + to the left of the starting point, and then pressing 'V' on the + now grey-stone wall. Adding this line fixes the crash that ensues. + + Line 2137: if (tilenum < 0) tilenum = 0; + +BUILD.C l2495, l3444: + bstatus, local to overheadeditor() is not initialized to 0 on entry + to the function, which sometimes causes the sprite dragging code to + misfire resulting in a crash immediately on starting the editor. The + following changes will prevent this happening. + + Line 2495: "oldmousebstatus = 0;" should be changed to "bstatus = 0;" + Line 3444: append "if ((pointhighlight&0xc000) == 16384)" to "else" + diff --git a/polymer/build/LICENSE b/polymer/build/LICENSE new file mode 100644 index 000000000..8b16ceee0 --- /dev/null +++ b/polymer/build/LICENSE @@ -0,0 +1,7 @@ +The source code is covered by the terms of Ken's original license +which can be found in the file "buildlic.txt" or at +http://jonof.edgenetwk.com/buildport/buildlic.txt + +My additions and modifications are covered by the same license. + + -- Jonathon Fowler (10 March 2003) diff --git a/polymer/build/MakeDistributions b/polymer/build/MakeDistributions new file mode 100644 index 000000000..5b2d3a41c --- /dev/null +++ b/polymer/build/MakeDistributions @@ -0,0 +1,47 @@ +# GNU Makefile to prepare source and binary distributions. +# make -f MakeDistributions [source|binary] + +SOURCEFILES=build.cfg buildlic.txt ChangeLog game.cfg LICENSE \ + Makefile Makefile.deps Makefile.shared Makefile.msvc Makefile.watcom \ + MakeDistributions makegnu.bat makemsc.bat makew.bat NAMES.H README + +BINARYFILES=build.cfg build.exe buildlic.txt ChangeLog fmod.dll \ + game.cfg game.exe LICENSE NAMES.H neatsong.ogg README + +BINARYCHECKS=checkfmoddll checkneatsongogg + +.PHONY: source binary $(BINARYCHECKS) + +datenow=$(shell date +%Y%m%d) + +sourcedir=txbuild_src_$(datenow) +binarydir=txbuild_$(datenow) + +all: source binary + +source: + rm -rf $(sourcedir) $(sourcedir).zip + mkdir $(sourcedir) $(sourcedir)/obj.gnu $(sourcedir)/obj.watcom $(sourcedir)/obj.msc + touch $(sourcedir)/obj.gnu/keep.me $(sourcedir)/obj.watcom/keep.me $(sourcedir)/obj.msc/keep.me + cp $(SOURCEFILES) $(sourcedir) + find . -name "*~" -exec rm -rf '{}' ';'; + find . -name "*.orig" -exec rm -rf '{}' ';'; + find . -name "*.rej" -exec rm -rf '{}' ';'; + find . -name "*.mine" -exec rm -rf '{}' ';'; + find . -name "*.c.r*" -exec rm -rf '{}' ';'; + cp -R src rsrc include devcpp osx $(sourcedir) + find $(sourcedir) | grep -i svn | xargs rm -rf + rm -f $(sourcedir)/src/tmp/* + touch $(sourcedir)/src/tmp/keep.me + kzip -r $(sourcedir).zip $(sourcedir) + +binary: $(BINARYCHECKS) + make RELEASE=1 + upx --best build.exe game.exe + mkdir $(binarydir) + cp $(BINARYFILES) $(binarydir) + kzip -r $(binarydir).zip $(binarydir) + +# Binary checks +checkfmoddll: fmod.dll +checkneatsongogg: neatsong.ogg diff --git a/polymer/build/Makefile b/polymer/build/Makefile new file mode 100644 index 000000000..8bd6cb804 --- /dev/null +++ b/polymer/build/Makefile @@ -0,0 +1,285 @@ +# Build Makefile for GNU Make + +# Notes: +# As of 6 July 2005, the engine should handle optimisations being enabled. +# If things seem to be going wrong, lower or disable optimisations, then +# try again. If things are still going wrong, call me. +# + +# Engine options - these may be overridden by game makefiles +# SUPERBUILD - enables voxels +# POLYMOST - enables Polymost renderer +# USE_OPENGL - enables OpenGL support in Polymost +# DYNAMIC_OPENGL - enables run-time loading of OpenGL library +# USE_A_C - enables use of C version of classic renderer +# NOASM - disables the use of inline assembly pragmas +# +# SETSPRITEZ - set to 1 for Shadow Warrior +SUPERBUILD ?= 1 +POLYMOST ?= 1 +USE_OPENGL ?= 1 +DYNAMIC_OPENGL ?= 1 +USE_A_C ?= 0 +NOASM ?= 0 + +SETSPRITEZ ?= 0 + +# Debugging options +# RELEASE - 1 = no debugging +# EFENCE - 1 = compile with Electric Fence for malloc() debugging +RELEASE?=1 +EFENCE?=0 + +# SDK locations - adjust to match your setup +DXROOT=c:/sdks/msc/dx61 +FMODROOTWIN=c:/sdks/fmodapi374win/api + +# build locations - OBJ gets overridden to the game-specific objects dir +OBJ?=obj.gnu/ +SRC=src/ +RSRC=rsrc/ +INC=include/ + +# filename extensions - these won't need to change +o=o +res=o +asm=nasm + +# debugging and release +ifneq ($(RELEASE),0) + # debugging disabled + debug=-fomit-frame-pointer -O2 +else + # debugging enabled + debug=-ggdb -O0 -DDEBUGGINGAIDS -DNOSDLPARACHUTE +endif + +CC=gcc +CXX=gcc +AS=nasm +RC=windres +AR=ar +RANLIB=ranlib +OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-char-subscripts -Wno-unused \ + -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS \ + -DKSFORBUILD -I$(INC:/=) -I../jfaud/src +OURCXXFLAGS=-fno-exceptions -fno-rtti +LIBS= +GAMELIBS=../jfaud/libjfaud.a #../jfaud/mpadec/libmpadec/libmpadec.a +ASFLAGS=-s #-g +EXESUFFIX= + +include Makefile.shared + +ifneq (0,$(USE_A_C)) + ENGINEOBJS=$(OBJ)a-c.$o +else + ENGINEOBJS=$(OBJ)a.$o +endif + +ENGINEOBJS+= \ + $(OBJ)baselayer.$o \ + $(OBJ)cache1d.$o \ + $(OBJ)compat.$o \ + $(OBJ)crc32.$o \ + $(OBJ)defs.$o \ + $(OBJ)engine.$o \ + $(OBJ)engineinfo.$o \ + $(OBJ)glbuild.$o \ + $(OBJ)kplib.$o \ + $(OBJ)lzf_c.$o \ + $(OBJ)lzf_d.$o \ + $(OBJ)md4.$o \ + $(OBJ)mmulti.$o \ + $(OBJ)osd.$o \ + $(OBJ)pragmas.$o \ + $(OBJ)scriptfile.$o + +EDITOROBJS=$(OBJ)build.$o \ + $(OBJ)config.$o + +GAMEEXEOBJS=$(OBJ)game.$o \ + $(OBJ)jfaud_sound.$o \ + $(OBJ)config.$o \ + $(OBJ)$(ENGINELIB) + +EDITOREXEOBJS=$(OBJ)bstub.$o \ + $(OBJ)$(EDITORLIB) \ + $(OBJ)$(ENGINELIB) + +# detect the platform +ifeq ($(PLATFORM),LINUX) + ASFLAGS+= -f elf + LIBS+= -lm +endif +ifeq ($(PLATFORM),BSD) + ASFLAGS+= -f elf + OURCFLAGS+= -I/usr/X11R6/include + LIBS+= -lm +endif +ifeq ($(PLATFORM),WINDOWS) + OURCFLAGS+= -DUNDERSCORES -I$(DXROOT)/include -I$(FMODROOTWIN)/inc + LIBS+= -lm + GAMELIBS+= -L$(FMODROOTWIN)/lib + ASFLAGS+= -DUNDERSCORES -f win32 +endif +ifeq ($(PLATFORM),BEOS) + ASFLAGS+= -f elf + TARGETOPTS+= -DNOASM +endif +ifeq ($(PLATFORM),SUNOS) + LIBS+= -lm +endif +ifeq ($(PLATFORM),SYLLABLE) + ASFLAGS+= -f elf +endif + +ifeq ($(RENDERTYPE),SDL) + ENGINEOBJS+= $(OBJ)sdlayer.$o + OURCFLAGS+= $(subst -Dmain=SDL_main,,$(SDLCONFIG_CFLAGS)) + + ifeq (1,$(HAVE_GTK2)) + OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0) + ENGINEOBJS+= $(OBJ)gtkbits.$o + GAMEEXEOBJS+= $(OBJ)game_banner.$o + EDITOREXEOBJS+= $(OBJ)editor_banner.$o + endif + + GAMEEXEOBJS+= $(OBJ)game_icon.$o + EDITOREXEOBJS+= $(OBJ)build_icon.$o +endif +ifeq ($(RENDERTYPE),WIN) + ENGINEOBJS+= $(OBJ)winlayer.$o + EDITOROBJS+= $(OBJ)buildstartwin.$o + GAMEEXEOBJS+= $(OBJ)gameres.$(res) $(OBJ)gamestartwin.$o + EDITOREXEOBJS+= $(OBJ)buildres.$(res) +endif + +ifneq (0,$(EFENCE)) + LIBS+= -lefence + OURCFLAGS+= -DEFENCE +endif + +OURCFLAGS+= $(BUILDCFLAGS) + +.PHONY: clean veryclean all utils writeengineinfo enginelib editorlib + +# TARGETS + +# Invoking Make from the terminal in OSX just chains the build on to xcode +ifeq ($(PLATFORM),DARWIN) +ifeq ($(RELEASE),0) +style=Development +else +style=Deployment +endif +.PHONY: alldarwin +alldarwin: + cd osx/engine && xcodebuild -target All -buildstyle $(style) + cd osx/game && xcodebuild -target All -buildstyle $(style) +endif + +UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) + +all: game$(EXESUFFIX) build$(EXESUFFIX) $(OBJ)$(ENGINELIB) $(OBJ)$(EDITORLIB) +utils: $(UTILS) + +enginelib: $(OBJ)$(ENGINELIB) +$(OBJ)$(ENGINELIB): $(ENGINEOBJS) + $(AR) rc $@ $^ + $(RANLIB) $@ + +editorlib: $(OBJ)$(EDITORLIB) +$(OBJ)$(EDITORLIB): $(EDITOROBJS) + $(AR) rc $@ $^ + $(RANLIB) $@ + +game$(EXESUFFIX): $(GAMEEXEOBJS) + $(CC) $(CFLAGS) $(OURCFLAGS) -o $@ $^ $(LIBS) $(GAMELIBS) $(STDCPPLIB) + +build$(EXESUFFIX): $(EDITOREXEOBJS) + $(CC) $(CFLAGS) $(OURCFLAGS) -o $@ $^ $(LIBS) + +pragmacheck$(EXESUFFIX): $(OBJ)pragmacheck.$o $(OBJ)pragmas.$o + $(CC) $(subst -Dmain=app_main,,$(OURCFLAGS)) -o $@ $^ + +kextract$(EXESUFFIX): $(OBJ)kextract.$o $(OBJ)compat.$o + $(CC) -o $@ $^ +kgroup$(EXESUFFIX): $(OBJ)kgroup.$o $(OBJ)compat.$o + $(CC) -o $@ $^ +transpal$(EXESUFFIX): $(OBJ)transpal.$o $(OBJ)pragmas.$o $(OBJ)compat.$o + $(CC) -o $@ $^ +wad2art$(EXESUFFIX): $(OBJ)wad2art.$o $(OBJ)pragmas.$o $(OBJ)compat.$o + $(CC) -o $@ $^ +wad2map$(EXESUFFIX): $(OBJ)wad2map.$o $(OBJ)pragmas.$o $(OBJ)compat.$o + $(CC) -o $@ $^ +generateicon$(EXESUFFIX): $(OBJ)generateicon.$o $(OBJ)kplib.$o + $(CC) -o $@ $^ +cacheinfo$(EXESUFFIX): $(OBJ)cacheinfo.$o $(OBJ)compat.$o + $(CC) -o $@ $^ +enumdisplay$(EXESUFFIX): src/misc/enumdisplay.c + $(CC) -g -Os -o $@ $^ -I$(DXROOT)/include -lgdi32 + +# DEPENDENCIES +include Makefile.deps + +.PHONY: $(OBJ)engineinfo.$o +$(OBJ)engineinfo.$o: + echo "const char _engine_cflags[] = \"$(CFLAGS) $(OURCFLAGS)\";" > $(SRC)tmp/engineinfo.c + echo "const char _engine_libs[] = \"$(LIBS)\";" >> $(SRC)tmp/engineinfo.c + echo "const char _engine_uname[] = \"$(shell uname -a)\";" >> $(SRC)tmp/engineinfo.c + echo "const char _engine_compiler[] = \"$(CC) $(shell $(CC) -dumpversion) $(shell $(CC) -dumpmachine)\";" >> $(SRC)tmp/engineinfo.c + echo "const char _engine_date[] = __DATE__ \" \" __TIME__;" >> $(SRC)tmp/engineinfo.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $(SRC)tmp/engineinfo.c -o $@ 2>&1 + +# RULES +$(OBJ)%.$o: $(SRC)%.nasm + $(AS) $(ASFLAGS) $< -o $@ + +$(OBJ)%.$o: $(SRC)%.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 + +$(OBJ)%.$o: $(SRC)%.cpp + $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 + +$(OBJ)%.$o: $(SRC)tmp/%.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 + +$(OBJ)%.$o: $(SRC)misc/%.rc + $(RC) -i $^ -o $@ + +$(OBJ)%.$o: $(SRC)util/%.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 + +$(OBJ)%.$o: $(RSRC)%.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 + +$(OBJ)game_banner.$o: $(RSRC)game_banner.c +$(OBJ)editor_banner.$o: $(RSRC)editor_banner.c +$(RSRC)game_banner.c: $(RSRC)game.bmp + echo "#include " > $@ + gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@ +$(RSRC)editor_banner.c: $(RSRC)build.bmp + echo "#include " > $@ + gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@ + +# PHONIES +clean: +ifeq ($(PLATFORM),DARWIN) + cd osx/engine && xcodebuild -target All clean + cd osx/game && xcodebuild -target All clean +else + -rm -f $(OBJ)* +endif + +veryclean: clean +ifeq ($(PLATFORM),DARWIN) +else + -rm -f $(ENGINELIB) $(EDITORLIB) game$(EXESUFFIX) build$(EXESUFFIX) $(UTILS) +endif + +.PHONY: fixlineends +fixlineends: + for a in `find . -type f \( -name '*.c' -o -name '*.h' -o -name 'Makefile*' \) \! -path '*/.svn/*'`; do \ + echo Fixing $$a && tr -d "\015" < $$a > $$a.fix && mv $$a.fix $$a; \ + done diff --git a/polymer/build/Makefile.deps b/polymer/build/Makefile.deps new file mode 100644 index 000000000..6e93bfd35 --- /dev/null +++ b/polymer/build/Makefile.deps @@ -0,0 +1,46 @@ +# Build Engine dependencies +# +$(OBJ)a-c.$o: $(SRC)a-c.c $(INC)a.h +$(OBJ)a.$o: $(SRC)a.$(asm) +$(OBJ)baselayer.$o: $(SRC)baselayer.c $(INC)compat.h $(INC)baselayer.h $(INC)build.h $(INC)osd.h +$(OBJ)bstub.$o: $(SRC)bstub.c $(INC)compat.h $(INC)a.h $(INC)build.h $(INC)pragmas.h $(INC)baselayer.h $(INC)names.h $(INC)osd.h $(INC)cache1d.h $(INC)editor.h +$(OBJ)build.$o: $(SRC)build.c $(INC)build.h $(INC)pragmas.h $(INC)compat.h $(INC)baselayer.h $(INC)editor.h +$(OBJ)cache1d.$o: $(SRC)cache1d.c $(INC)compat.h $(INC)cache1d.h $(INC)pragmas.h $(INC)baselayer.h +$(OBJ)compat.$o: $(SRC)compat.c $(INC)compat.h +$(OBJ)config.$o: $(SRC)config.c $(INC)compat.h $(INC)osd.h $(INC)editor.h +$(OBJ)crc32.$o: $(SRC)crc32.c $(INC)crc32.h +$(OBJ)defs.$o: $(SRC)defs.c $(INC)build.h $(INC)baselayer.h $(INC)scriptfile.h $(INC)compat.h +$(OBJ)engine.$o: $(SRC)engine.c $(SRC)polymost.c $(INC)kplib.h $(SRC)hightile.c $(SRC)mdsprite.c $(INC)md4.h $(INC)lzf.h $(INC)lzwnew.h $(INC)compat.h $(INC)build.h $(INC)pragmas.h $(INC)cache1d.h $(INC)a.h $(INC)osd.h $(INC)baselayer.h +$(OBJ)game.$o: $(SRC)game.c $(INC)compat.h $(INC)build.h $(INC)names.h $(INC)pragmas.h $(INC)cache1d.h $(INC)game.h $(INC)osd.h $(INC)baselayer.h +$(OBJ)glbuild.$o: $(SRC)glbuild.c $(INC)glbuild.h $(INC)baselayer.h +$(OBJ)jfaud_sound.$o: $(SRC)jfaud_sound.cpp $(INC)osd.h $(INC)compat.h $(INC)cache1d.h +$(OBJ)kplib.$o: $(SRC)kplib.c $(INC)compat.h +$(OBJ)lzf_c.$o: $(SRC)lzf_c.c $(SRC)lzfP.h +$(OBJ)lzf_d.$o: $(SRC)lzf_d.c $(SRC)lzfP.h +$(OBJ)lzwnew.$o: $(SRC)lzwnew.c +$(OBJ)md4.$o: $(SRC)md4.c $(INC)md4.h $(INC)compat.h +$(OBJ)mmulti_null.$o: $(SRC)mmulti_null.c $(INC)mmulti.h +$(OBJ)mmulti.$o: $(SRC)mmulti.c +$(OBJ)osd.$o: $(SRC)osd.c $(INC)build.h $(INC)osd.h $(INC)compat.h $(INC)engineinfo.h $(INC)baselayer.h +$(OBJ)pragmas.$o: $(SRC)pragmas.c $(INC)compat.h +$(OBJ)scriptfile.$o: $(SRC)scriptfile.c $(INC)scriptfile.h $(INC)cache1d.h $(INC)compat.h +$(OBJ)sdlayer.$o: $(SRC)sdlayer.c $(INC)compat.h $(INC)sdlayer.h $(INC)baselayer.h $(INC)cache1d.h $(INC)pragmas.h $(INC)a.h $(INC)build.h $(INC)osd.h $(INC)glbuild.h +$(OBJ)sound.$o: $(SRC)sound.c $(INC)osd.h $(INC)compat.h $(INC)cache1d.h +$(OBJ)winlayer.$o: $(SRC)winlayer.c $(INC)compat.h $(INC)winlayer.h $(INC)baselayer.h $(INC)pragmas.h $(INC)build.h $(INC)a.h $(INC)osd.h $(INC)dxdidf.h $(INC)glbuild.h +$(OBJ)gtkbits.$o: $(SRC)gtkbits.c $(INC)baselayer.h $(INC)build.h + +$(OBJ)gameres.$(res): $(SRC)misc/gameres.rc +$(OBJ)buildres.$(res): $(SRC)misc/buildres.rc +$(OBJ)gamestartwin.$o: $(SRC)gamestartwin.c $(INC)winlayer.h $(INC)build.h $(INC)compat.h +$(OBJ)buildstartwin.$o: $(SRC)buildstartwin.c $(INC)winlayer.h $(INC)build.h $(INC)compat.h + +$(OBJ)game_icon.$o: $(RSRC)game_icon.c +$(OBJ)build_icon.$o: $(RSRC)build_icon.c + +$(OBJ)kextract.$o: $(SRC)util/kextract.c $(INC)compat.h +$(OBJ)kgroup.$o: $(SRC)util/kgroup.c $(INC)compat.h +$(OBJ)transpal.$o: $(SRC)util/transpal.c $(INC)compat.h $(INC)pragmas.h +$(OBJ)wad2art.$o: $(SRC)util/wad2art.c $(INC)compat.h $(INC)pragmas.h +$(OBJ)wad2map.$o: $(SRC)util/wad2map.c $(INC)compat.h $(INC)pragmas.h +$(OBJ)generateicon.$o: $(SRC)util/generateicon.c +$(OBJ)cacheinfo.$o: $(SRC)util/cacheinfo.c $(INC)compat.h diff --git a/polymer/build/Makefile.msvc b/polymer/build/Makefile.msvc new file mode 100644 index 000000000..49f882932 --- /dev/null +++ b/polymer/build/Makefile.msvc @@ -0,0 +1,166 @@ +# Build Makefile for Microsoft NMake +!ifdef OVERRIDES +!include $(OVERRIDES) +!endif + +SRC=src\ # +!ifndef OBJ +OBJ=obj.msc\ # +!endif +INC=include\ # +!ifndef CFLAGS +CFLAGS=/DSUPERBUILD /DPOLYMOST /DUSE_OPENGL /DDYNAMIC_OPENGL /DKSFORBUILD +!endif + +o=obj +res=res +asm=masm + +ENGINELIB=engine.lib +EDITORLIB=build.lib + +DXROOT=c:\sdks\msc\dx7 +FMODROOT=c:\sdks\fmodapi374win\api + +# /D these to enable certain features of the port's compile process +# USE_A_C This uses a C version of the classic renderer code rather +# than the assembly version in A.ASM. +# If this is defined, alter the $(OBJ)a.$o in the +# ENGINEOBJS declaration to be $(OBJ)a-c.$o +# NOASM When defined, uses C instead of Microsoft inline +# assembly for the features in PRAGMAS.H +TARGETOPTS=#/DUSE_A_C #/DNOASM + +!ifdef DEBUG +# debugging options +flags_cl=/G6 /Ot /Z7 +flags_link=/DEBUG +!else +# release options +#flags_cl=/G6Fy /Ox +flags_cl=/G6 /O2 +flags_link=/RELEASE +!endif + +CC=cl +AS=ml +RC=rc +LINK=link /opt:nowin98 /opt:ref /nologo +CFLAGS=$(CFLAGS) /nologo /MD /J $(flags_cl) $(TARGETOPTS) /I$(INC) /I$(DXROOT)\include /I$(FMODROOT)\inc +LIBS=fmodvc.lib #opengl32.lib +ASFLAGS=/nologo /coff +EXESUFFIX=.exe + +ENGINEOBJS=$(OBJ)a.$o \ + $(OBJ)baselayer.$o \ + $(OBJ)cache1d.$o \ + $(OBJ)compat.$o \ + $(OBJ)crc32.$o \ + $(OBJ)defs.$o \ + $(OBJ)engine.$o \ + $(OBJ)engineinfo.$o \ + $(OBJ)glbuild.$o \ + $(OBJ)kplib.$o \ + $(OBJ)lzf_c.$o \ + $(OBJ)lzf_d.$o \ + $(OBJ)lzwnew.$o \ + $(OBJ)md4.$o \ + $(OBJ)mmulti.$o \ + $(OBJ)osd.$o \ + $(OBJ)pragmas.$o \ + $(OBJ)scriptfile.$o \ + $(OBJ)winlayer.$o + +EDITOROBJS=$(OBJ)build.$o \ + $(OBJ)buildstartwin.$o \ + $(OBJ)config.$o + +GAMEEXEOBJS=$(OBJ)config.$o \ + $(OBJ)game.$o \ + $(OBJ)gameres.$(res) \ + $(OBJ)gamestartwin.$o \ + $(OBJ)sound.$o \ + $(OBJ)$(ENGINELIB) + +EDITOREXEOBJS=$(OBJ)bstub.$o \ + $(OBJ)buildres.$(res) \ + $(OBJ)$(EDITORLIB) \ + $(OBJ)$(ENGINELIB) + +RENDERTYPE=WIN +LIBS=$(LIBS) user32.lib gdi32.lib shell32.lib dxguid.lib wsock32.lib +CFLAGS=$(CFLAGS) /DRENDERTYPE$(RENDERTYPE)=1 + +# RULES +.SUFFIXES: .masm + +{$(SRC)}.masm{$(OBJ)}.$o: + $(AS) /c $(ASFLAGS) /Fo$@ $< + +{$(SRC)tmp}.c{$(OBJ)}.$o: + $(CC) /c $(CFLAGS) /Fo$@ $< + +{$(SRC)util}.c{$(OBJ)}.$o: + $(CC) /c $(CFLAGS) /Fo$@ $< + +{$(SRC)misc}.rc{$(OBJ)}.$(res): + $(RC) /fo$@ /r $< + +{$(SRC)}.c{$(OBJ)}.$o: + $(CC) /c $(CFLAGS) /Fo$@ $< + +# TARGETS +UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2map$(EXESUFFIX) wad2map$(EXESUFFIX) + +all: game$(EXESUFFIX) build$(EXESUFFIX) $(OBJ)$(ENGINELIB) $(OBJ)$(EDITORLIB) ; +utils: $(UTILS) ; + +enginelib: $(OBJ)$(ENGINELIB) ; +$(OBJ)$(ENGINELIB): $(ENGINEOBJS) + lib /out:$@ /nologo $** + +editorlib: $(OBJ)$(EDITORLIB) ; +$(OBJ)$(EDITORLIB): $(EDITOROBJS) + lib /out:$@ /nologo $** + + +game$(EXESUFFIX): $(GAMEEXEOBJS) + $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib /LIBPATH:$(FMODROOT)\lib $(flags_link) /MAP $** $(LIBS) msvcrt.lib + +build$(EXESUFFIX): $(EDITOREXEOBJS) + $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib /LIBPATH:$(FMODROOT)\lib $(flags_link) /MAP $** $(LIBS) msvcrt.lib + +# the tools +kextract$(EXESUFFIX): $(OBJ)kextract.$o $(OBJ)compat.$o + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** msvcrt.lib + +kgroup$(EXESUFFIX): $(OBJ)kgroup.$o $(OBJ)compat.$o + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** msvcrt.lib + +transpal$(EXESUFFIX): $(OBJ)transpal.$o $(OBJ)pragmas.$o $(OBJ)compat.$o + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** msvcrt.lib + +wad2map$(EXESUFFIX): $(OBJ)wad2map.$o $(OBJ)pragmas.$o $(OBJ)compat.$o + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** msvcrt.lib + +wad2art$(EXESUFFIX): $(OBJ)wad2art.$o $(OBJ)pragmas.$o $(OBJ)compat.$o + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** msvcrt.lib + +# DEPENDENCIES +!include Makefile.deps + +$(OBJ)engineinfo.$o: writeengineinfo $(SRC)tmp\engineinfo.c + +writeengineinfo: + echo const char _engine_cflags[] = "$(CFLAGS:\=\\)"; > $(SRC)tmp\engineinfo.c + echo const char _engine_libs[] = "$(LIBS)"; >> $(SRC)tmp\engineinfo.c + echo const char _engine_uname[] = "unknown"; >> $(SRC)tmp\engineinfo.c + echo const char _engine_compiler[] = "$(CC)"; >> $(SRC)tmp\engineinfo.c + echo const char _engine_date[] = __DATE__ " " __TIME__; >> $(SRC)tmp\engineinfo.c + +# PHONIES +clean: + -del $(ENGINEOBJS) $(EDITOROBJS) $(GAMEEXEOBJS) $(EDITOREXEOBJS) +veryclean: clean + -del $(OBJ)$(ENGINELIB) $(OBJ)$(EDITORLIB) game$(EXESUFFIX) build$(EXESUFFIX) $(UTILS) + diff --git a/polymer/build/Makefile.shared b/polymer/build/Makefile.shared new file mode 100644 index 000000000..268e99b59 --- /dev/null +++ b/polymer/build/Makefile.shared @@ -0,0 +1,160 @@ +# Shared make information between Build engine and games + +ENGINELIB=libengine.a +EDITORLIB=libbuild.a + +# These are used when DYNAMIC_OPENGL is false +GLLIBWIN=-lopengl32 +GLLIBBSD=-lopengl32 +GLLIBLIN=-lGL + +SDLCONFIG=sdl-config +#SDLCONFIG=/usr/local/bin/sdl11-config + +# overridden for OSes that don't have the cutdown stdc++ that is supc++ +STDCPPLIB=-lsupc++ + +BUILDCFLAGS= + +# Detect the platform if it wasn't explicitly given to us from +# the outside world. This allows cross-compilation by overriding +# CC and giving us PLATFORM specifically. +ifndef PLATFORM + uname=$(strip $(shell uname -s)) + PLATFORM=UNKNOWN + ifeq ($(findstring Linux,$(uname)),Linux) + PLATFORM=LINUX + endif + ifeq ($(findstring BSD,$(uname)),BSD) + PLATFORM=BSD + endif + ifeq ($(findstring MINGW,$(uname)),MINGW) + PLATFORM=WINDOWS + endif + ifeq ($(findstring Darwin,$(uname)),Darwin) + PLATFORM=DARWIN + endif + ifeq ($(findstring BeOS,$(uname)),BeOS) + PLATFORM=BEOS + endif + ifeq ($(findstring skyos,$(uname)),skyos) + PLATFORM=SKYOS + endif + ifeq ($(findstring QNX,$(uname)),QNX) + PLATFORM=QNX + endif + ifeq ($(findstring SunOS,$(uname)),SunOS) + PLATFORM=SUNOS + endif + ifeq ($(findstring syllable,$(uname)),syllable) + PLATFORM=SYLLABLE + endif +endif + +ifeq ($(PLATFORM),LINUX) + RENDERTYPE=SDL + ifneq ($(DYNAMIC_OPENGL),1) + LIBS+= $(GLLIBLIN) + endif + ifeq ($(findstring x86_64,$(shell uname -m)),x86_64) + # on my 64bit Gentoo these are the 32bit emulation libs + LIBS+= -m32 -L/emul/linux/x86/usr/lib + BUILDCFLAGS+= -m32 + override WITHOUT_GTK=1 + endif +endif +ifeq ($(PLATFORM),WINDOWS) + RENDERTYPE ?= WIN + EXESUFFIX=.exe + LIBS+= -lmingwex -lwinmm -L$(DXROOT)/lib -lwsock32 #-lshfolder + ifneq ($(DYNAMIC_OPENGL),1) + LIBS+= $(GLLIBWIN) + endif +endif +ifeq ($(PLATFORM),BSD) + RENDERTYPE=SDL + ifneq ($(DYNAMIC_OPENGL),1) + LIBS+= $(GLLIBBSD) + endif +endif +ifeq ($(PLATFORM),BEOS) + RENDERTYPE=SDL + STDCPPLIB=-lstdc++ +endif +ifeq ($(PLATFORM),SKYOS) + RENDERTYPE=SDL + EXESUFFIX=.app + override USE_A_C=1 + BUILDCFLAGS+= -DUNDERSCORES + SDLCONFIG= + SDLCONFIG_CFLAGS=-I/boot/programs/sdk/include/sdl + LIBS+= -lSDL -lnet +endif +ifeq ($(PLATFORM),QNX) + RENDERTYPE=SDL + override USE_OPENGL=0 + override USE_A_C=1 + STDCPPLIB=-lstdc++ + LIBS+= -lsocket +endif +ifeq ($(PLATFORM),SUNOS) + RENDERTYPE=SDL + override USE_OPENGL=0 + override NOASM=1 + override USE_A_C=1 + STDCPPLIB=-lstdc++ + LIBS+= -lsocket -lnsl +endif +ifeq ($(PLATFORM),SYLLABLE) + RENDERTYPE=SDL + override USE_OPENGL=0 + override NOASM=1 +endif + +ifeq ($(RENDERTYPE),SDL) + ifneq ($(SDLCONFIG),) + LIBS+= $(shell $(SDLCONFIG) --libs) + SDLCONFIG_CFLAGS+=$(shell $(SDLCONFIG) --cflags) + endif + + ifeq (1,$(WITHOUT_GTK)) + HAVE_GTK2=0 + else + ifneq (No,$(shell pkg-config --exists gtk+-2.0 || echo No)) + HAVE_GTK2=1 + LIBS+= $(shell pkg-config --libs gtk+-2.0) + else + HAVE_GTK2=0 + endif + endif +else + ifeq ($(RENDERTYPE),WIN) + LIBS+= -mwindows -ldxguid + endif +endif + +BUILDCFLAGS+= -DRENDERTYPE$(RENDERTYPE)=1 + +ifneq (0,$(SUPERBUILD)) + BUILDCFLAGS+= -DSUPERBUILD +endif +ifneq (0,$(POLYMOST)) + BUILDCFLAGS+= -DPOLYMOST +endif +ifneq (0,$(USE_OPENGL)) + BUILDCFLAGS+= -DUSE_OPENGL + ifneq (0,$(DYNAMIC_OPENGL)) + BUILDCFLAGS+= -DDYNAMIC_OPENGL + endif +endif +ifneq (0,$(USE_A_C)) + BUILDCFLAGS+= -DUSE_A_C +endif +ifneq (0,$(NOASM)) + BUILDCFLAGS+= -DNOASM +endif +ifneq (0,$(SETSPRITEZ)) + BUILDCFLAGS+= -DSETSPRITEZ +endif + + diff --git a/polymer/build/Makefile.watcom b/polymer/build/Makefile.watcom new file mode 100644 index 000000000..ec7ed5e78 --- /dev/null +++ b/polymer/build/Makefile.watcom @@ -0,0 +1,174 @@ +# Build Makefile for Watcom Make + +!ifdef OVERRIDES +!include $(OVERRIDES) +!endif + +SRC=src\ +!ifndef OBJ +OBJ=obj.watcom\ +!endif +INC=include\ +!ifndef CFLAGS +CFLAGS=-dSUPERBUILD -dPOLYMOST -dUSE_OPENGL -dDYNAMIC_OPENGL -dKSFORBUILD +!endif + +o=obj +res=res +asm=wasm + +ENGINELIB=engine.lib +EDITORLIB=build.lib + +DXROOT=c:\sdks\msc\dx7 +FMODROOT=c:\sdks\fmodapi374win\api + +!ifdef __LOADDLL__ +! loaddll wcc386 wccd386 +!endif + +# -d these to enable certain features of the port's compile process +# USE_A_C This uses a C version of the classic renderer code rather +# than the assembly version in A.ASM. +# If this is defined, alter the $(OBJ)a.$o in the +# ENGINEOBJS declaration to be $(OBJ)a-c.$o +# NOASM When defined, uses C code instead of Watcom inline +# assembly for the features in PRAGMAS.H +TARGETOPTS=#-dUSE_A_C #-dNOASM + +CC=wcc386 +AS=wasm +RC=wrc +CFLAGS+= -5r -s -orb -fp5 $(TARGETOPTS) -d2 -dRENDERTYPEWIN=1 & + -i=$(INC) -i=$(DXROOT)\include -i=$(FMODROOT)\inc +LIBS=dxguid.lib wsock32.lib fmodwc.lib #opengl32.lib +ASFLAGS=# -d1 +EXESUFFIX=.exe + +ENGINEOBJS=$(OBJ)a.$o & + $(OBJ)baselayer.$o & + $(OBJ)cache1d.$o & + $(OBJ)compat.$o & + $(OBJ)crc32.$o & + $(OBJ)defs.$o & + $(OBJ)engine.$o & + $(OBJ)engineinfo.$o & + $(OBJ)glbuild.$o & + $(OBJ)kplib.$o & + $(OBJ)lzf_c.$o & + $(OBJ)lzf_d.$o & + $(OBJ)lzwnew.$o & + $(OBJ)md4.$o & + $(OBJ)mmulti.$o & + $(OBJ)osd.$o & + $(OBJ)pragmas.$o & + $(OBJ)scriptfile.$o & + $(OBJ)winlayer.$o + +EDITOROBJS=$(OBJ)build.$o & + $(OBJ)config.$o & + $(OBJ)buildstartwin.$o + +GAMEEXEOBJS=$(OBJ)game.$o & + $(OBJ)sound.$o & + $(OBJ)config.$o & + $(OBJ)gamestartwin.$o + +EDITOREXEOBJS=$(OBJ)bstub.$o + +# RULES +.EXTENSIONS: .wasm .res .rc + +.wasm: $(SRC) +.c: $(SRC) +.c: $(SRC)tmp/ +.c: $(SRC)util/ +.rc: $(SRC)misc/ + +.wasm.$o: + $(AS) $(ASFLAGS) -fo=$(OBJ).$o $[@ + +.c.$o: + $(CC) $(CFLAGS) -fo=$(OBJ).$o $[@ + +.rc.$(res): + $(RC) -fo=$^*.$(res) -r $[@ + +# TARGETS +UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) + +all: game$(EXESUFFIX) build$(EXESUFFIX) $(OBJ)$(ENGINELIB) $(OBJ)$(EDITORLIB) .SYMBOLIC + %null + +utils: $(UTILS) .SYMBOLIC + %null + +enginelib: $(OBJ)$(ENGINELIB) .SYMBOLIC + %null + +$(OBJ)$(ENGINELIB): $(ENGINEOBJS) + %create $(OBJ)$(ENGINELIB).tmp + for %i in ($(ENGINEOBJS)) do %append $(OBJ)$(ENGINELIB).tmp +%i + wlib -b -n $^* @$(OBJ)$(ENGINELIB).tmp + erase $(OBJ)$(ENGINELIB).tmp + +editorlib: $(OBJ)$(EDITORLIB) .SYMBOLIC + %null + +$(OBJ)$(EDITORLIB): $(EDITOROBJS) + %create $(OBJ)$(EDITORLIB).tmp + for %i in ($(EDITOROBJS)) do %append $(OBJ)$(EDITORLIB).tmp +%i + wlib -b -n $^* @$(OBJ)$(EDITORLIB).tmp + erase $(OBJ)$(EDITORLIB).tmp + +game$(EXESUFFIX): $(GAMEEXEOBJS) $(OBJ)gameres.$(res) $(OBJ)$(ENGINELIB) + wlink NAME $@ & + SYSTEM WIN95 & + DEBUG ALL & + OPTION MAP & + FILE { $(GAMEEXEOBJS) } & + RESOURCE $(OBJ)gameres.$(res) & + LIBPATH $(DXROOT)\lib & + LIBPATH $(FMODROOT)\lib & + LIBPATH $(OBJ) & + LIBRARY { $(ENGINELIB) $(LIBS) } + +build$(EXESUFFIX): $(EDITOREXEOBJS) $(OBJ)buildres.$(res) $(OBJ)$(ENGINELIB) $(OBJ)$(EDITORLIB) + wlink NAME $@ & + SYSTEM WIN95 & + DEBUG ALL & + OPTION MAP & + FILE { $(EDITOREXEOBJS) } & + RESOURCE $(OBJ)buildres.$(res) & + LIBPATH $(DXROOT)\lib & + LIBPATH $(FMODROOT)\lib & + LIBPATH $(OBJ) & + LIBRARY { $(ENGINELIB) $(EDITORLIB) $(LIBS) } + +kextract$(EXESUFFIX): $(OBJ)kextract.$o $(OBJ)compat.$o + wlink NAME $@ SYSTEM 386 DEBUG ALL FILE { $< } +kgroup$(EXESUFFIX): $(OBJ)kgroup.$o $(OBJ)compat.$o + wlink NAME $@ SYSTEM 386 DEBUG ALL FILE { $< } +transpal$(EXESUFFIX): $(OBJ)transpal.$o $(OBJ)pragmas.$o $(OBJ)compat.$o + wlink NAME $@ SYSTEM 386 DEBUG ALL FILE { $< } +wad2art$(EXESUFFIX): $(OBJ)wad2art.$o $(OBJ)pragmas.$o $(OBJ)compat.$o + wlink NAME $@ SYSTEM 386 DEBUG ALL FILE { $< } +wad2map$(EXESUFFIX): $(OBJ)wad2map.$o $(OBJ)pragmas.$o $(OBJ)compat.$o + wlink NAME $@ SYSTEM 386 DEBUG ALL FILE { $< } + +# DEPENDENCIES +!include Makefile.deps + +$(OBJ)engineinfo.$o: writeengineinfo $(SRC)tmp\engineinfo.c + +writeengineinfo: .SYMBOLIC + echo const char _engine_cflags[] = "$(CFLAGS:\=\\)"; > $(SRC)tmp\engineinfo.c + echo const char _engine_libs[] = "$(LIBS:\=\\)"; >> $(SRC)tmp\engineinfo.c + echo const char _engine_uname[] = "unknown"; >> $(SRC)tmp\engineinfo.c + echo const char _engine_compiler[] = "$(CC)"; >> $(SRC)tmp\engineinfo.c + echo const char _engine_date[] = __DATE__ " " __TIME__; >> $(SRC)tmp\engineinfo.c + +# PHONIES +clean: .SYMBOLIC + -erase /q $(OBJ)* game$(EXESUFFIX) build$(EXESUFFIX) $(UTILS) *.err + diff --git a/polymer/build/NAMES.H b/polymer/build/NAMES.H new file mode 100644 index 000000000..d22fdaecd --- /dev/null +++ b/polymer/build/NAMES.H @@ -0,0 +1,49 @@ +//Be careful when changing this file - it is parsed by Editart and Build. +#define SWITCH1ON 15 +#define SLIME 34 +#define BACKGROUND 37 +#define KENPICTURE 48 +#define BUILDDISK 49 +#define SWITCH2ON 66 +#define SWITCH2OFF 69 +#define ALPHABET 73 +#define NO 74 +#define DEMOSIGN 75 +#define COIN 76 +#define COINSTACK 77 +#define GIFTBOX 78 +#define DIAMONDS 79 +#define EVILALGRAVE 83 +#define STATUSBAR 87 +#define DAYSKY 89 +#define WATERFOUNTAIN 90 +#define USEWATERFOUNTAIN 91 +#define NIGHTSKY 93 +#define BULLET 98 +#define BOMB 100 +#define CANNON 101 +#define GUNONBOTTOM 102 +#define BOMBEMITTER 103 +#define EXPLOSION 105 +#define SPLASH 106 +#define BROWNMONSTER 110 +#define SKELETON 113 +#define AL 114 +#define EVILAL 115 +#define PLAYER 120 +#define SWITCH3OFF 146 +#define SWITCH3ON 147 +#define AIRPLANE 148 +#define SPIRAL 149 +#define COMPASS 150 +#define FOOTPRINT 156 +#define STATUSBARFILL8 160 +#define STATUSBARFILL4 161 +#define BOUNCYMAT 162 +#define MIRROR 165 +#define FLOORMIRROR 166 +#define GRABBER 167 +#define GRABCANNON 168 +#define MISSILE 169 +#define LAUNCHER 171 +#define MIRRORLABEL 4000 diff --git a/polymer/build/README b/polymer/build/README new file mode 100644 index 000000000..fb7cac057 --- /dev/null +++ b/polymer/build/README @@ -0,0 +1,141 @@ +Build Source Port by Jonathon Fowler +With contributions by Ken Silverman + +ReadMe Information + + +First Source Release: 9 March 2003 +This Release: 9 October 2005 + + + +A Few Notes and Words +--------------------- + This is a release of the source code to my port of Ken +Silverman's Build game engine [1]. The port intends to bring the engine +source up to speed so that it may be used more easily with modern +operating systems on the x86 platform, like Microsoft Windows and *nix- +like ones such as Linux and BSD. + WinBuild is the name I give to the Windows target of this port. +It uses native Windows APIs like DirectX and the GDI to provide close +interaction with Windows for the sake of performance. + I have also developed a more platform-independant layer for +use on systems other than Windows by way of the Simple Direct-media +Layer (SDL) [2]. This layer should assist as a basis for further system +ports or for easier implementation on the platforms SDL supports. + Work on this port is a continuing process. I welcome the +contributions of programmers who have something they'd like to add (or +fix). + + +Configuration +------------- + Runtime settings for BUILD.EXE and GAME.EXE are set in build.cfg +and game.cfg respectively. These files are normal text files. The +original SETUP.DAT that is used in Ken's original code is not used in +this port. The config files are automatically created on the first run of +the game or editor. + + +Building the Source +------------------- + I build the Windows binaries using the following tools and libraries: + * MSYS ('Current' version) (http://www.mingw.org) + * MinGW ('Current' version) (http://www.mingw.org) + * NASM (http://nasm.sourceforge.net/) + * DirectX 6 or above headers and import libraries + DX6: (http://www.libsdl.org/extras/win32/common/directx-devel.tar.gz) + DX9: (http://www.microsoft.com/downloads/details.aspx?FamilyID=afc15f29-d7c9-4cf7-a8d5-8ab81f14ae1b&DisplayLang=en) + * SDL 1.2 (http://www.libsdl.org/download-1.2.php) + SDL is only used for the SDL interface layer and may be + omitted if building the DirectX version. + * FMOD (http://www.fmod.org) + + Some good MinGW guides and whatnot: + - http://www.libsdl.org/extras/win32/mingw32/README.txt + - http://www.spacejack.org/games/mingw/ + + The engine compiles under Linux, FreeBSD, and NetBSD with minimal/no +modification. + + Building the source involves just typing "make" in the directory +where you have unpacked the source. Windows users should make sure the +directory structure in the ZIP is maintained on extraction. The default +interface layer on Windows is the DirectX interface. This can be overriden +to the SDL one by using the command "make RENDERTYPE=SDL" instead. Linux +builds will always use SDL. + +For compilation on other operating systems, see the addendum "Other OSes". + + +Things Missing +-------------- + Nothing much is missing anymore. Networking is being improved as +time passes. + + +Bugs and Whatnot +---------------- + I'm sure during my hacking I've perhaps introduced a bug here or +there. I want to try and nail these as I can. If you think you've found +a bug I would certainly like to hear about it. If you get it to crash, +a crash dump would be extremely helpful. Contact me using the details +found below. + + +Points of Contact +----------------- + The official location for this port on the WWW is at +http://jonof.edgenetwork.org/?p=jfbuild where the latest binaries and +source may be found. You can contact me via email at jonof@edgenetwork.org + + +Credits and Thanks +------------------ +* Ken Silverman for his patience, help, and guidance in this. I +realise my rambling is taxing but your wisdom is invaluable. +* The folks at icculus.org for inspiring me to try and equal their +work done in the first public port of the engine. +* Do I dare mention myself? +* Pimping the edgenetwork (http://www.edgenetwk.com) who host my +site wouldn't go astray. +* Pär Karlsson for his contributions + + +Can't think of anything else at the moment, so, enjoy! + +Jonathon Fowler + + +[1] http://www.advsys.net/ken/buildsrc +[2] http://www.libsdl.org + + +Addendum: Other OSes +-------------------- + +QNX 6.2.1: + I got the engine compiling and running on QNX 6.2.1 on the + 23rd November 2005. The QNX 6.2.1 Non-commercial CDROM includes + the GCC 2.95-series compiler (though you do have to install the + package), and the only extra library you need to obtain and + install (probably from source like I did) is SDL 1.2.9 or newer. + You also have to disable linking to fmod and use the + sound_stub.$o in the Makefile. + +SkyOS 5 beta 8.5: + Disabling fmod and using sound_stub.$o in the Makefile will get + it running. + +Solaris 9: + Because of how Solaris seems to set itself up, you need to: + 1. Edit Makefile and change AR to be 'gar' and RANLIB to be + 'granlib' + 2. Edit Makefile.shared and add (I think) /opt/sfw/bin/ + to the start of SDLCONFIG's value + 3. Disable fmod and use sound_stub.$o in Makefile + +BSD: + Disable fmod and use sound_stub.$o in the Makefile. Use 'gmake' + to build. + diff --git a/polymer/build/build.cfg b/polymer/build/build.cfg new file mode 100644 index 000000000..fd0ff4ec4 --- /dev/null +++ b/polymer/build/build.cfg @@ -0,0 +1,104 @@ +; Build editor configuration + +; Video mode selection +; 0 - Windowed +; 1 - Fullscreen +fullscreen = 0 + +; Video resolution selection +; 0 - 320 x 200 +; 1 - 360 x 200 +; 2 - 320 x 240 +; 3 - 360 x 240 +; 4 - 320 x 400 +; 5 - 360 x 400 +; 6 - 640 x 350 +; 7 - 640 x 400 +; 8 - 640 x 480 +; 9 - 800 x 600 +; 10 - 1024 x 768 +; 11 - 1280 x 1024 +; 12 - 1600 x 1200 +; You can select a seperate 2D editor resolution by +; removing the semicolon from the second line below +; and selecting a mode number. The minimum 2D mode +; is 640x480 (mode #8) +resolution = 8 +;2dresolution = 8 + +; 3D-mode colour depth +bpp = 8 + +; Maximum OpenGL mode refresh rate (Windows only, in Hertz) +maxrefreshfreq = 60 + +; 3D mode brightness setting +; 0 - lowest +; 15 - highest +brightness = 0 + +; Sound sample frequency +; 0 - 6 KHz +; 1 - 8 KHz +; 2 - 11.025 KHz +; 3 - 16 KHz +; 4 - 22.05 KHz +; 5 - 32 KHz +; 6 - 44.1 KHz +samplerate = 4 + +; Music playback +; 0 - Off +; 1 - On +music = 1 + +; Enable mouse +; 0 - No +; 1 - Yes +mouse = 1 + +; Mouse sensitivity +mousesensitivity = 1.0 + +; Key Settings +; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex! +; +---------------------------------------------------------------------------------------------+ +; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 | +; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL | +; | | +; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A | +; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- | +; | | +; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E | +; |TAB Q W E R T Y U I O P [ ] \ DEL END PGDN KP7 KP8 KP9 KP+ | +; | | +; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D | +; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C | +; | KPENTER| +; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 | +; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 | +; | | +; | 1D 38 39 B8 9D CB D0 CD 52 53 | +; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. | +; +---------------------------------------------------------------------------------------------+ + +keyforward = C8 +keybackward = D0 +keyturnleft = CB +keyturnright = CD +keyrun = 2A +keystrafe = 9D +keyfire = 1D +keyuse = 39 +keystandhigh = 1E +keystandlow = 2C +keylookup = D1 +keylookdown = C9 +keystrafeleft = 33 +keystraferight = 34 +key2dmode = 9C +keyviewcycle = 1C +key2dzoomin = D +key2dzoomout = C +keychat = F + diff --git a/polymer/build/buildlic.txt b/polymer/build/buildlic.txt new file mode 100644 index 000000000..3a3985bb6 --- /dev/null +++ b/polymer/build/buildlic.txt @@ -0,0 +1,71 @@ +BUILD SOURCE CODE LICENSE TERMS: 06/20/2000 + +[1] I give you permission to make modifications to my Build source and + distribute it, BUT: + +[2] Any derivative works based on my Build source may be distributed ONLY + through the INTERNET. + +[3] Distribution of any derivative works MUST be done completely FREE of + charge - no commercial exploitation whatsoever. + +[4] Anything you distribute which uses a part of my Build Engine source + code MUST include: + + [A] The following message somewhere in the archive: + + // "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. + + [B] This text file "BUILDLIC.TXT" along with it. + + [C] Any source files that you modify must include this message as well: + + // This file has been modified from Ken Silverman's original release + +[5] The use of the Build Engine for commercial purposes will require an + appropriate license arrangement with me. Contact information is + on my web site. + +[6] I take no responsibility for damage to your system. + +[7] Technical support: Before contacting me with questions, please read + and do ALL of the following! + + [A] Look through ALL of my text files. There are 7 of them (including this + one). I like to think that I wrote them for a reason. You will find + many of your answers in the history section of BUILD.TXT and + BUILD2.TXT (they're located inside SRC.ZIP). + + [B] If that doesn't satisfy you, then try going to: + + "http://www.advsys.net/ken/buildsrc" + + where I will maintain a Build Source Code FAQ (or perhaps I might + just provide a link to a good FAQ). + + [C] I am willing to respond to questions, but ONLY if they come at a rate + that I can handle. + + PLEASE TRY TO AVOID ASKING DUPLICATE QUESTIONS! + + As my line of defense, I will post my current policy about + answering Build source questions (right below the E-mail address + on my web site.) You can check there to see if I'm getting + overloaded with questions or not. + + If I'm too busy, it might say something like this: + + I'm too busy to answer Build source questions right now. + Sorry, but don't expect a reply from me any time soon. + + If I'm open for Build source questions, please state your question + clearly and don't include any unsolicited attachments unless + they're really small (like less than 50k). Assume that I have + a 28.8k modem. Also, don't leave out important details just + to make your question appear shorter - making me guess what + you're asking doesn't save me time! + +---------------------------------------------------------------------------- +-Ken S. (official web site: http://www.advsys.net/ken) diff --git a/polymer/build/devcpp/Build.dev b/polymer/build/devcpp/Build.dev new file mode 100644 index 000000000..6c9c7e729 --- /dev/null +++ b/polymer/build/devcpp/Build.dev @@ -0,0 +1,68 @@ +[Project] +FileName=Build.dev +Name=KenBuild Editor +UnitCount=2 +Type=0 +Ver=1 +ObjFiles= +Includes=..\include +Libs=C:\sdks\msc\dx7\include +PrivateResource=Build_private.rc +ResourceIncludes=..\ +MakeIncludes= +Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-funsigned-char_@@_ +CppCompiler= +Linker=libeditor.a_@@_libengine.a_@@_-ldxguid_@@_-lws2_32_@@_ +IsCpp=0 +Icon= +ExeOutput=..\devcpp +ObjectOutput=..\devcpp +OverrideOutput=0 +OverrideOutputName=libengine.a +HostApplication= +Folders= +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000100010000d0 + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + +[Unit1] +FileName=..\src\bstub.c +CompileCpp=0 +Folder=KenBuild Editor +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=..\src\misc\buildres.rc +Folder=KenBuild Editor +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/polymer/build/devcpp/Game.dev b/polymer/build/devcpp/Game.dev new file mode 100644 index 000000000..b4b498a11 --- /dev/null +++ b/polymer/build/devcpp/Game.dev @@ -0,0 +1,98 @@ +[Project] +FileName=Game.dev +Name=KenBuild Game +UnitCount=5 +Type=0 +Ver=1 +ObjFiles= +Includes=..\include;C:\sdks\fmodapi373win\api\inc +Libs=C:\sdks\msc\dx7\include;C:\sdks\fmodapi373win\api\lib +PrivateResource=Game_private.rc +ResourceIncludes=..\ +MakeIncludes= +Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-funsigned-char_@@_ +CppCompiler= +Linker=libeditor.a_@@_libengine.a_@@_-ldxguid_@@_-lws2_32_@@_-lfmod_@@_ +IsCpp=0 +Icon= +ExeOutput=..\devcpp +ObjectOutput=..\devcpp +OverrideOutput=0 +OverrideOutputName=libengine.a +HostApplication= +Folders= +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000100010000d0 + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + +[Unit3] +FileName=..\src\sound.c +CompileCpp=0 +Folder=KenBuild Editor +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit4] +FileName=..\src\misc\gameres.rc +Folder=KenBuild Game +Compile=1 +Link=0 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit1] +FileName=..\src\config.c +CompileCpp=0 +Folder=KenBuild Editor +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=..\src\game.c +CompileCpp=0 +Folder=KenBuild Editor +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit5] +FileName=..\src\gamestartwin.c +CompileCpp=0 +Folder=KenBuild Game +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/polymer/build/devcpp/engineinfo.c b/polymer/build/devcpp/engineinfo.c new file mode 100644 index 000000000..71cd27509 --- /dev/null +++ b/polymer/build/devcpp/engineinfo.c @@ -0,0 +1,5 @@ +const char _engine_cflags[] = "Dev-C++ made this"; +const char _engine_libs[] = "Dev-C++ made this"; +const char _engine_uname[] = "Dev-C++"; +const char _engine_compiler[] = "Dev-C++"; +const char _engine_date[] = __DATE__ " " __TIME__; diff --git a/polymer/build/devcpp/libEditor.dev b/polymer/build/devcpp/libEditor.dev new file mode 100644 index 000000000..c297369be --- /dev/null +++ b/polymer/build/devcpp/libEditor.dev @@ -0,0 +1,79 @@ +[Project] +FileName=libEditor.dev +Name=Build Editor library +UnitCount=3 +Type=2 +Ver=1 +ObjFiles= +Includes=..\include;..\src +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-funsigned-char_@@_ +CppCompiler= +Linker= +IsCpp=0 +Icon= +ExeOutput=..\devcpp +ObjectOutput=..\devcpp +OverrideOutput=1 +OverrideOutputName=libeditor.a +HostApplication= +Folders= +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000100010000d0 + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + +[Unit3] +FileName=..\src\buildstartwin.c +CompileCpp=0 +Folder=KenBuild Editor +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit1] +FileName=..\src\build.c +CompileCpp=0 +Folder=Build Editor library +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=..\src\config.c +CompileCpp=0 +Folder=Build Editor library +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/polymer/build/devcpp/libEngine.dev b/polymer/build/devcpp/libEngine.dev new file mode 100644 index 000000000..2e9adace8 --- /dev/null +++ b/polymer/build/devcpp/libEngine.dev @@ -0,0 +1,198 @@ +[Project] +FileName=libEngine.dev +Name=Build Engine library +UnitCount=15 +Type=2 +Ver=1 +ObjFiles= +Includes=..\include;..\src;C:\sdks\msc\dx7\include +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler=-DRENDERTYPEWIN=1_@@_-DSUPERBUILD_@@_-DPOLYMOST_@@_-DUSE_OPENGL_@@_-DDYNAMIC_OPENGL_@@_-DNO_GCC_BUILTINS_@@_-DUNDERSCORES_@@_-DKSFORBUILD_@@_-funsigned-char_@@_ +CppCompiler= +Linker= +IsCpp=0 +Icon= +ExeOutput=..\devcpp +ObjectOutput=..\devcpp +OverrideOutput=1 +OverrideOutputName=libengine.a +HostApplication= +Folders= +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000100010000d0 + +[Unit1] +FileName=..\src\cache1d.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=..\src\engine.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit3] +FileName=..\src\crc32.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit4] +FileName=..\src\osd.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit5] +FileName=..\src\pragmas.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit6] +FileName=..\src\a.nasm +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=1 +BuildCmd=nasm -s -DUNDERSCORES -f win32 ../src/a.nasm -o ../devcpp/a.o + +[Unit7] +FileName=engineinfo.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit8] +FileName=..\src\defs.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit9] +FileName=..\src\compat.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit10] +FileName=..\src\baselayer.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit11] +FileName=..\src\glbuild.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit12] +FileName=..\src\kplib.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit13] +FileName=..\src\mmulti.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit14] +FileName=..\src\scriptfile.c +CompileCpp=0 +Folder=Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + +[Unit15] +FileName=..\src\winlayer.c +CompileCpp=0 +Folder=Build Engine +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/polymer/build/game.cfg b/polymer/build/game.cfg new file mode 100644 index 000000000..5dc3bf6cd --- /dev/null +++ b/polymer/build/game.cfg @@ -0,0 +1,97 @@ +; KenBuild configuration + +; Video mode selection +; 0 - Windowed +; 1 - Fullscreen +fullscreen = 0 + +; Video resolution selection +; 0 - 320 x 200 +; 1 - 360 x 200 +; 2 - 320 x 240 +; 3 - 360 x 240 +; 4 - 320 x 400 +; 5 - 360 x 400 +; 6 - 640 x 350 +; 7 - 640 x 400 +; 8 - 640 x 480 +; 9 - 800 x 600 +; 10 - 1024 x 768 +; 11 - 1280 x 1024 +; 12 - 1600 x 1200 +resolution = 8 + +; 3D-mode colour depth +bpp = 8 + +; 3D mode brightness setting +; 0 - lowest +; 15 - highest +brightness = 0 + +; Maximum OpenGL mode refresh rate (Windows only, in Hertz) +maxrefreshfreq = 60 + +; Sound sample frequency +; 0 - 6 KHz +; 1 - 8 KHz +; 2 - 11.025 KHz +; 3 - 16 KHz +; 4 - 22.05 KHz +; 5 - 32 KHz +; 6 - 44.1 KHz +samplerate = 4 + +; Music playback +; 0 - Off +; 1 - On +music = 1 + +; Enable mouse +; 0 - No +; 1 - Yes +mouse = 1 + +; Key Settings +; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex! +; +---------------------------------------------------------------------------------------------+ +; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 | +; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL | +; | | +; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A | +; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- | +; | | +; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E | +; |TAB Q W E R T Y U I O P [ ] \ DEL END PGDN KP7 KP8 KP9 KP+ | +; | | +; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D | +; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C | +; | KPENTER| +; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 | +; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 | +; | | +; | 1D 38 39 B8 9D CB D0 CD 52 53 | +; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. | +; +---------------------------------------------------------------------------------------------+ + +keyforward = C8 +keybackward = D0 +keyturnleft = CB +keyturnright = CD +keyrun = 2A +keystrafe = 9D +keyfire = 1D +keyuse = 39 +keystandhigh = 1E +keystandlow = 2C +keylookup = D1 +keylookdown = C9 +keystrafeleft = 33 +keystraferight = 34 +key2dmode = 9C +keyviewcycle = 1C +key2dzoomin = D +key2dzoomout = C +keychat = F +keyconsole = 29 + diff --git a/polymer/build/include/a.h b/polymer/build/include/a.h new file mode 100644 index 000000000..eb174e79f --- /dev/null +++ b/polymer/build/include/a.h @@ -0,0 +1,245 @@ +// Assembly-language function wrappers for a.asm functions +// for the Build Engine +// by Jonathon Fowler (jonof@edgenetwk.com) + + +#ifndef __a_h__ +#define __a_h__ + +#if defined(USE_A_C) + +#define ENGINE_USING_A_C + +void setvlinebpl(long dabpl); +void fixtransluscence(long datransoff); +void settransnormal(void); +void settransreverse(void); + +void sethlinesizes(long logx, long logy, long bufplc); +void setpalookupaddress(char *paladdr); +void setuphlineasm4(long bxinc, long byinc); +void hlineasm4(long cnt, long skiploadincs, long paloffs, unsigned long by, unsigned long bx, long p); + +void setupslopevlin(long logylogx, long bufplc, long pinc); +void slopevlin(long p, long i, long slopaloffs, long cnt, long bx, long by); + +void setupvlineasm(long neglogy); +void vlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p); + +void setupmvlineasm(long neglogy); +void mvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p); + +void setuptvlineasm(long neglogy); +void tvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p); + +void msethlineshift(long logx, long logy); +void mhline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned long by, long p); + +void tsethlineshift(long logx, long logy); +void thline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned long by, long p); + +void setupspritevline(long paloffs, long bxinc, long byinc, long ysiz); +void spritevline(long bx, long by, long cnt, long bufplc, long p); + +void msetupspritevline(long paloffs, long bxinc, long byinc, long ysiz); +void mspritevline(long bx, long by, long cnt, long bufplc, long p); + +void tsetupspritevline(long paloffs, long bxinc, long byinc, long ysiz); +void tspritevline(long bx, long by, long cnt, long bufplc, long p); + +void setupdrawslab (long dabpl, long pal); +void drawslab (long dx, long v, long dy, long vi, long vptr, long p); +void stretchhline (long p0, long u, long cnt, long uinc, long rptr, long p); + +void mmxoverlay(); + +#elif defined(__WATCOMC__) // USE_A_C + +extern long mmxoverlay(); +#pragma aux mmxoverlay modify [eax ebx ecx edx]; +extern long sethlinesizes(long,long,long); +#pragma aux sethlinesizes parm [eax][ebx][ecx]; +extern long setpalookupaddress(char *); +#pragma aux setpalookupaddress parm [eax]; +extern long setuphlineasm4(long,long); +#pragma aux setuphlineasm4 parm [eax][ebx]; +extern long hlineasm4(long,long,long,long,long,long); +#pragma aux hlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; +extern long setuprhlineasm4(long,long,long,long,long,long); +#pragma aux setuprhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; +extern long rhlineasm4(long,long,long,long,long,long); +#pragma aux rhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; +extern long setuprmhlineasm4(long,long,long,long,long,long); +#pragma aux setuprmhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; +extern long rmhlineasm4(long,long,long,long,long,long); +#pragma aux rmhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; +extern long setupqrhlineasm4(long,long,long,long,long,long); +#pragma aux setupqrhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; +extern long qrhlineasm4(long,long,long,long,long,long); +#pragma aux qrhlineasm4 parm [eax][ebx][ecx][edx][esi][edi]; +extern long setvlinebpl(long); +#pragma aux setvlinebpl parm [eax]; +extern long fixtransluscence(long); +#pragma aux fixtransluscence parm [eax]; +extern long prevlineasm1(long,long,long,long,long,long); +#pragma aux prevlineasm1 parm [eax][ebx][ecx][edx][esi][edi]; +extern long vlineasm1(long,long,long,long,long,long); +#pragma aux vlineasm1 parm [eax][ebx][ecx][edx][esi][edi]; +extern long setuptvlineasm(long); +#pragma aux setuptvlineasm parm [eax]; +extern long tvlineasm1(long,long,long,long,long,long); +#pragma aux tvlineasm1 parm [eax][ebx][ecx][edx][esi][edi]; +extern long setuptvlineasm2(long,long,long); +#pragma aux setuptvlineasm2 parm [eax][ebx][ecx]; +extern long tvlineasm2(long,long,long,long,long,long); +#pragma aux tvlineasm2 parm [eax][ebx][ecx][edx][esi][edi]; +extern long mvlineasm1(long,long,long,long,long,long); +#pragma aux mvlineasm1 parm [eax][ebx][ecx][edx][esi][edi]; +extern long setupvlineasm(long); +#pragma aux setupvlineasm parm [eax]; +extern long vlineasm4(long,long); +#pragma aux vlineasm4 parm [ecx][edi] modify [eax ebx ecx edx esi edi]; +extern long setupmvlineasm(long); +#pragma aux setupmvlineasm parm [eax]; +extern long mvlineasm4(long,long); +#pragma aux mvlineasm4 parm [ecx][edi] modify [eax ebx ecx edx esi edi]; +extern void setupspritevline(long,long,long,long,long,long); +#pragma aux setupspritevline parm [eax][ebx][ecx][edx][esi][edi]; +extern void spritevline(long,long,long,long,long,long); +#pragma aux spritevline parm [eax][ebx][ecx][edx][esi][edi]; +extern void msetupspritevline(long,long,long,long,long,long); +#pragma aux msetupspritevline parm [eax][ebx][ecx][edx][esi][edi]; +extern void mspritevline(long,long,long,long,long,long); +#pragma aux mspritevline parm [eax][ebx][ecx][edx][esi][edi]; +extern void tsetupspritevline(long,long,long,long,long,long); +#pragma aux tsetupspritevline parm [eax][ebx][ecx][edx][esi][edi]; +extern void tspritevline(long,long,long,long,long,long); +#pragma aux tspritevline parm [eax][ebx][ecx][edx][esi][edi]; +extern long mhline(long,long,long,long,long,long); +#pragma aux mhline parm [eax][ebx][ecx][edx][esi][edi]; +extern long mhlineskipmodify(long,long,long,long,long,long); +#pragma aux mhlineskipmodify parm [eax][ebx][ecx][edx][esi][edi]; +extern long msethlineshift(long,long); +#pragma aux msethlineshift parm [eax][ebx]; +extern long thline(long,long,long,long,long,long); +#pragma aux thline parm [eax][ebx][ecx][edx][esi][edi]; +extern long thlineskipmodify(long,long,long,long,long,long); +#pragma aux thlineskipmodify parm [eax][ebx][ecx][edx][esi][edi]; +extern long tsethlineshift(long,long); +#pragma aux tsethlineshift parm [eax][ebx]; +extern long setupslopevlin(long,long,long); +#pragma aux setupslopevlin parm [eax][ebx][ecx] modify [edx]; +extern long slopevlin(long,long,long,long,long,long); +#pragma aux slopevlin parm [eax][ebx][ecx][edx][esi][edi]; +extern long settransnormal(); +#pragma aux settransnormal parm; +extern long settransreverse(); +#pragma aux settransreverse parm; +extern long setupdrawslab(long,long); +#pragma aux setupdrawslab parm [eax][ebx]; +extern long drawslab(long,long,long,long,long,long); +#pragma aux drawslab parm [eax][ebx][ecx][edx][esi][edi]; + +#elif defined(__GNUC__) && defined(__i386__) // __WATCOMC__ + +#if defined(__linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__SYLLABLE__) +#define __cdecl +#endif + +extern long __cdecl mmxoverlay(); +extern long __cdecl sethlinesizes(long,long,long); +extern long __cdecl setpalookupaddress(char *); +extern long __cdecl setuphlineasm4(long,long); +extern long __cdecl hlineasm4(long,long,long,long,long,long); +extern long __cdecl setuprhlineasm4(long,long,long,long,long,long); +extern long __cdecl rhlineasm4(long,long,long,long,long,long); +extern long __cdecl setuprmhlineasm4(long,long,long,long,long,long); +extern long __cdecl rmhlineasm4(long,long,long,long,long,long); +extern long __cdecl setupqrhlineasm4(long,long,long,long,long,long); +extern long __cdecl qrhlineasm4(long,long,long,long,long,long); +extern long __cdecl setvlinebpl(long); +extern long __cdecl fixtransluscence(long); +extern long __cdecl prevlineasm1(long,long,long,long,long,long); +extern long __cdecl vlineasm1(long,long,long,long,long,long); +extern long __cdecl setuptvlineasm(long); +extern long __cdecl tvlineasm1(long,long,long,long,long,long); +extern long __cdecl setuptvlineasm2(long,long,long); +extern long __cdecl tvlineasm2(long,long,long,long,long,long); +extern long __cdecl mvlineasm1(long,long,long,long,long,long); +extern long __cdecl setupvlineasm(long); +extern long __cdecl vlineasm4(long,long); +extern long __cdecl setupmvlineasm(long); +extern long __cdecl mvlineasm4(long,long); +extern long __cdecl setupspritevline(long,long,long,long,long,long); +extern long __cdecl spritevline(long,long,long,long,long,long); +extern long __cdecl msetupspritevline(long,long,long,long,long,long); +extern long __cdecl mspritevline(long,long,long,long,long,long); +extern long __cdecl tsetupspritevline(long,long,long,long,long,long); +extern long __cdecl tspritevline(long,long,long,long,long,long); +extern long __cdecl mhline(long,long,long,long,long,long); +extern long __cdecl mhlineskipmodify(long,long,long,long,long,long); +extern long __cdecl msethlineshift(long,long); +extern long __cdecl thline(long,long,long,long,long,long); +extern long __cdecl thlineskipmodify(long,long,long,long,long,long); +extern long __cdecl tsethlineshift(long,long); +extern long __cdecl setupslopevlin(long,long,long); +extern long __cdecl slopevlin(long,long,long,long,long,long); +extern long __cdecl settransnormal(); +extern long __cdecl settransreverse(); +extern long __cdecl setupdrawslab(long,long); +extern long __cdecl drawslab(long,long,long,long,long,long); +extern void __cdecl stretchhline(long,long,long,long,long,long); + +#elif defined(_MSC_VER) // __GNUC__ && __i386__ + +extern long _cdecl mmxoverlay(); +extern long _cdecl sethlinesizes(long,long,long); +extern long _cdecl setpalookupaddress(char *); +extern long _cdecl setuphlineasm4(long,long); +extern long _cdecl hlineasm4(long,long,long,long,long,long); +extern long _cdecl setuprhlineasm4(long,long,long,long,long,long); +extern long _cdecl rhlineasm4(long,long,long,long,long,long); +extern long _cdecl setuprmhlineasm4(long,long,long,long,long,long); +extern long _cdecl rmhlineasm4(long,long,long,long,long,long); +extern long _cdecl setupqrhlineasm4(long,long,long,long,long,long); +extern long _cdecl qrhlineasm4(long,long,long,long,long,long); +extern long _cdecl setvlinebpl(long); +extern long _cdecl fixtransluscence(long); +extern long _cdecl prevlineasm1(long,long,long,long,long,long); +extern long _cdecl vlineasm1(long,long,long,long,long,long); +extern long _cdecl setuptvlineasm(long); +extern long _cdecl tvlineasm1(long,long,long,long,long,long); +extern long _cdecl setuptvlineasm2(long,long,long); +extern long _cdecl tvlineasm2(long,long,long,long,long,long); +extern long _cdecl mvlineasm1(long,long,long,long,long,long); +extern long _cdecl setupvlineasm(long); +extern long _cdecl vlineasm4(long,long); +extern long _cdecl setupmvlineasm(long); +extern long _cdecl mvlineasm4(long,long); +extern long _cdecl setupspritevline(long,long,long,long,long,long); +extern long _cdecl spritevline(long,long,long,long,long,long); +extern long _cdecl msetupspritevline(long,long,long,long,long,long); +extern long _cdecl mspritevline(long,long,long,long,long,long); +extern long _cdecl tsetupspritevline(long,long,long,long,long,long); +extern long _cdecl tspritevline(long,long,long,long,long,long); +extern long _cdecl mhline(long,long,long,long,long,long); +extern long _cdecl mhlineskipmodify(long,long,long,long,long,long); +extern long _cdecl msethlineshift(long,long); +extern long _cdecl thline(long,long,long,long,long,long); +extern long _cdecl thlineskipmodify(long,long,long,long,long,long); +extern long _cdecl tsethlineshift(long,long); +extern long _cdecl setupslopevlin(long,long,long); +extern long _cdecl slopevlin(long,long,long,long,long,long); +extern long _cdecl settransnormal(); +extern long _cdecl settransreverse(); +extern long _cdecl setupdrawslab(long,long); +extern long _cdecl drawslab(long,long,long,long,long,long); +extern void _cdecl stretchhline(long,long,long,long,long,long); + +#else // _MSC_VER + +#error Unsupported compiler or architecture. + +#endif // else + +#endif // __a_h__ diff --git a/polymer/build/include/baselayer.h b/polymer/build/include/baselayer.h new file mode 100644 index 000000000..d4d47cf41 --- /dev/null +++ b/polymer/build/include/baselayer.h @@ -0,0 +1,126 @@ +// Base services interface declaration +// for the Build Engine +// by Jonathon Fowler (jonof@edgenetwk.com) + +#ifndef __baselayer_h__ +#define __baselayer_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int _buildargc; +extern char **_buildargv; + +extern char quitevent, appactive; + +extern char *startwin_labeltext; + +// video +extern long xres, yres, bpp, fullscreen, bytesperline, imageSize, frameplace; +extern char offscreenrendering; + +extern void (*baselayer_onvideomodechange)(int); + +#ifdef USE_OPENGL +struct glinfo { + const char *vendor; + const char *renderer; + const char *version; + const char *extensions; + + float maxanisotropy; + char bgra; + char clamptoedge; + char texcompr; + char texnpot; + char multisample; + char nvmultisamplehint; +}; +extern struct glinfo glinfo; +#endif + +extern char inputdevices; + +// keys +#define KEYFIFOSIZ 64 +extern char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; +extern unsigned char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; + +// mouse +extern long mousex, mousey, mouseb; + +// joystick +extern long *joyaxis, *joyhat, joyb; +extern char joyisgamepad, joynumaxes, joynumbuttons, joynumhats; +extern long joyaxespresent; + + + +int initsystem(void); +void uninitsystem(void); + +void initprintf(const char *, ...); +void debugprintf(const char *,...); + +int handleevents(void); + +typedef void (*KeyPressCallback)(long,long); +typedef void (*MousePressCallback)(long,long); +typedef void (*JoyPressCallback)(long,long); +int initinput(void); +void uninitinput(void); +void releaseallbuttons(void); +void setkeypresscallback(void (*callback)(long,long)); +void setmousepresscallback(void (*callback)(long,long)); +void setjoypresscallback(void (*callback)(long,long)); +const unsigned char *getkeyname(int num); +const unsigned char *getjoyname(int what, int num); // what: 0=axis, 1=button, 2=hat + +unsigned char bgetchar(void); +int bkbhit(void); +void bflushchars(void); + +int initmouse(void); +void uninitmouse(void); +void grabmouse(char a); +void readmousexy(long *x, long *y); +void readmousebstatus(long *b); +void setjoydeadzone(int axis, unsigned short dead, unsigned short satur); +void getjoydeadzone(int axis, unsigned short *dead, unsigned short *satur); + +int inittimer(int); +void uninittimer(void); +void sampletimer(void); +unsigned long getticks(void); +int gettimerfreq(void); +void (*installusertimercallback(void (*callback)(void)))(void); + +int checkvideomode(int *x, int *y, int c, int fs); +int setvideomode(int x, int y, int c, int fs); +void getvalidmodes(void); +void resetvideomode(void); + +void begindrawing(void); +void enddrawing(void); +void showframe(int); + +int setpalette(int start, int num, char *dapal); +//int getpalette(int start, int num, char *dapal); +int setgamma(float ro, float go, float bo); + +int switchrendermethod(int,int); // 0 = software, 1 = opengl | bool = reinit + +int wm_msgbox(char *name, char *fmt, ...); +int wm_ynbox(char *name, char *fmt, ...); +void wm_setapptitle(char *name); + +// baselayer.c +int baselayer_init(); + +#ifdef __cplusplus +} +#endif + +#endif // __baselayer_h__ + diff --git a/polymer/build/include/baselayer.h.r276 b/polymer/build/include/baselayer.h.r276 new file mode 100644 index 000000000..2cb503c9c --- /dev/null +++ b/polymer/build/include/baselayer.h.r276 @@ -0,0 +1,121 @@ +// Base services interface declaration +// for the Build Engine +// by Jonathon Fowler (jonof@edgenetwk.com) + +#ifndef __baselayer_h__ +#define __baselayer_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int _buildargc; +extern char **_buildargv; + +extern char quitevent, appactive; + +extern char *startwin_labeltext; + +// video +extern long xres, yres, bpp, fullscreen, bytesperline, imageSize, frameplace; +extern char offscreenrendering; + +extern void (*baselayer_onvideomodechange)(int); + +#ifdef USE_OPENGL +struct glinfo { + const char *vendor; + const char *renderer; + const char *version; + const char *extensions; + + float maxanisotropy; + char bgra, clamptoedge, texcompr, texnpot; +}; +extern struct glinfo glinfo; +#endif + +extern char inputdevices; + +// keys +#define KEYFIFOSIZ 64 +extern char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; +extern unsigned char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; + +// mouse +extern long mousex, mousey, mouseb; + +// joystick +extern long *joyaxis, *joyhat, joyb; +extern char joyisgamepad, joynumaxes, joynumbuttons, joynumhats; +extern long joyaxespresent; + + + +int initsystem(void); +void uninitsystem(void); + +void initprintf(const char *, ...); +void debugprintf(const char *,...); + +int handleevents(void); + +typedef void (*KeyPressCallback)(long,long); +typedef void (*MousePressCallback)(long,long); +typedef void (*JoyPressCallback)(long,long); +int initinput(void); +void uninitinput(void); +void releaseallbuttons(void); +void setkeypresscallback(void (*callback)(long,long)); +void setmousepresscallback(void (*callback)(long,long)); +void setjoypresscallback(void (*callback)(long,long)); +const unsigned char *getkeyname(int num); +const unsigned char *getjoyname(int what, int num); // what: 0=axis, 1=button, 2=hat + +unsigned char bgetchar(void); +int bkbhit(void); +void bflushchars(void); + +int initmouse(void); +void uninitmouse(void); +void grabmouse(char a); +void readmousexy(long *x, long *y); +void readmousebstatus(long *b); +void setjoydeadzone(int axis, unsigned short dead, unsigned short satur); +void getjoydeadzone(int axis, unsigned short *dead, unsigned short *satur); + +int inittimer(int); +void uninittimer(void); +void sampletimer(void); +unsigned long getticks(void); +int gettimerfreq(void); +void (*installusertimercallback(void (*callback)(void)))(void); + +int checkvideomode(int *x, int *y, int c, int fs); +int setvideomode(int x, int y, int c, int fs); +void getvalidmodes(void); +void resetvideomode(void); + +void begindrawing(void); +void enddrawing(void); +void showframe(int); + +int setpalette(int start, int num, char *dapal); +//int getpalette(int start, int num, char *dapal); +int setgamma(float ro, float go, float bo); + +int switchrendermethod(int,int); // 0 = software, 1 = opengl | bool = reinit + +int wm_msgbox(char *name, char *fmt, ...); +int wm_ynbox(char *name, char *fmt, ...); +void wm_setapptitle(char *name); + +// baselayer.c +int baselayer_init(); + +#ifdef __cplusplus +} +#endif + +#endif // __baselayer_h__ + diff --git a/polymer/build/include/baselayer.h.r277 b/polymer/build/include/baselayer.h.r277 new file mode 100644 index 000000000..45d0c78ba --- /dev/null +++ b/polymer/build/include/baselayer.h.r277 @@ -0,0 +1,126 @@ +// Base services interface declaration +// for the Build Engine +// by Jonathon Fowler (jonof@edgenetwk.com) + +#ifndef __baselayer_h__ +#define __baselayer_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int _buildargc; +extern char **_buildargv; + +extern char quitevent, appactive; + +extern char *startwin_labeltext; + +// video +extern long xres, yres, bpp, fullscreen, bytesperline, imageSize, frameplace; +extern char offscreenrendering; + +extern void (*baselayer_onvideomodechange)(int); + +#ifdef USE_OPENGL +struct glinfo { + const char *vendor; + const char *renderer; + const char *version; + const char *extensions; + + float maxanisotropy; + char bgra; + char clamptoedge; + char texcompr; + char texnpot; + char multisample; + char nvmultisamplehint; +}; +extern struct glinfo glinfo; +#endif + +extern char inputdevices; + +// keys +#define KEYFIFOSIZ 64 +extern char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; +extern unsigned char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; + +// mouse +extern long mousex, mousey, mouseb; + +// joystick +extern long *joyaxis, *joyhat, joyb; +extern char joyisgamepad, joynumaxes, joynumbuttons, joynumhats; +extern long joyaxespresent; + + + +int initsystem(void); +void uninitsystem(void); + +void initprintf(const char *, ...); +void debugprintf(const char *,...); + +int handleevents(void); + +typedef void (*KeyPressCallback)(long,long); +typedef void (*MousePressCallback)(long,long); +typedef void (*JoyPressCallback)(long,long); +int initinput(void); +void uninitinput(void); +void releaseallbuttons(void); +void setkeypresscallback(void (*callback)(long,long)); +void setmousepresscallback(void (*callback)(long,long)); +void setjoypresscallback(void (*callback)(long,long)); +const unsigned char *getkeyname(int num); +const unsigned char *getjoyname(int what, int num); // what: 0=axis, 1=button, 2=hat + +unsigned char bgetchar(void); +int bkbhit(void); +void bflushchars(void); + +int initmouse(void); +void uninitmouse(void); +void grabmouse(char a); +void readmousexy(long *x, long *y); +void readmousebstatus(long *b); +void setjoydeadzone(int axis, unsigned short dead, unsigned short satur); +void getjoydeadzone(int axis, unsigned short *dead, unsigned short *satur); + +int inittimer(int); +void uninittimer(void); +void sampletimer(void); +unsigned long getticks(void); +int gettimerfreq(void); +void (*installusertimercallback(void (*callback)(void)))(void); + +int checkvideomode(int *x, int *y, int c, int fs); +int setvideomode(int x, int y, int c, int fs); +void getvalidmodes(void); +void resetvideomode(void); + +void begindrawing(void); +void enddrawing(void); +void showframe(int); + +int setpalette(int start, int num, char *dapal); +//int getpalette(int start, int num, char *dapal); +int setgamma(float ro, float go, float bo); + +int switchrendermethod(int,int); // 0 = software, 1 = opengl | bool = reinit + +int wm_msgbox(char *name, char *fmt, ...); +int wm_ynbox(char *name, char *fmt, ...); +void wm_setapptitle(char *name); + +// baselayer.c +int baselayer_init(); + +#ifdef __cplusplus +} +#endif + +#endif // __baselayer_h__ + diff --git a/polymer/build/include/build.h b/polymer/build/include/build.h new file mode 100644 index 000000000..79d16fb25 --- /dev/null +++ b/polymer/build/include/build.h @@ -0,0 +1,516 @@ +// "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 1600 +#define MAXYDIM 1200 +#define MAXPALOOKUPS 256 +#define MAXPSKYTILES 256 +#define MAXSPRITESONSCREEN 2048 +#define MAXUNIQHUDID 256 //Extra slots so HUD models can store animation state without messing game sprites + +#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; + short xoff, yoff, zoff; + unsigned char flags; + char filler[3]; +} spriteexttype; +#define SPREXT_NOTMD 1 +#define SPREXT_NOMDANIM 2 +EXTERN spriteexttype spriteext[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 walock[MAXTILES]; +EXTERN long numtiles, picanm[MAXTILES], waloff[MAXTILES]; + + //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: + �������������������������������Ĵ + 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); + +void setpolymost2dview(void); // sets up GL for 2D drawing + +long polymost_drawtilescreen(long tilex, long tiley, long wallnum, long dimen); +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; +void gltexapplyprops (void); +#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, 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); +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); +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/include/cache1d.h b/polymer/build/include/cache1d.h new file mode 100644 index 000000000..03c2e3f70 --- /dev/null +++ b/polymer/build/include/cache1d.h @@ -0,0 +1,63 @@ +// cache1d.h + +#ifndef __cache1d_h__ +#define __cache1d_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +void initcache(long dacachestart, long dacachesize); +void allocache(long *newhandle, long newbytes, char *newlockptr); +void suckcache(long *suckptr); +void agecache(void); + +extern int pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode) +int addsearchpath(const char *p); +int findfrompath(const char *fn, char **where); +int openfrompath(const char *fn, int flags, int mode); +BFILE *fopenfrompath(const char *fn, const char *mode); + +long initgroupfile(char *filename); +void uninitsinglegroupfile(long grphandle); +void uninitgroupfile(void); +long kopen4load(char *filename, char searchfirst); // searchfirst: 0 = anywhere, 1 = first group, 2 = any group +long kread(long handle, void *buffer, long leng); +long klseek(long handle, long offset, long whence); +long kfilelength(long handle); +long ktell(long handle); +void kclose(long handle); + +enum { + CACHE1D_FIND_FILE = 1, + CACHE1D_FIND_DIR = 2, + CACHE1D_FIND_DRIVE = 4, + + CACHE1D_OPT_NOSTACK = 0x100, + + // the lower the number, the higher the priority + CACHE1D_SOURCE_DRIVE = 0, + CACHE1D_SOURCE_CURDIR = 1, + CACHE1D_SOURCE_PATH = 2, // + path stack depth + CACHE1D_SOURCE_ZIP = 0x7ffffffe, + CACHE1D_SOURCE_GRP = 0x7fffffff, +}; +typedef struct _CACHE1D_FIND_REC { + char *name; + int type, source; + struct _CACHE1D_FIND_REC *next, *prev, *usera, *userb; +} CACHE1D_FIND_REC; +void klistfree(CACHE1D_FIND_REC *rec); +CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int type); + +int kdfread(void *buffer, bsize_t dasizeof, bsize_t count, long fil); +int dfread(void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil); +void kdfwrite(void *buffer, bsize_t dasizeof, bsize_t count, long fil); +void dfwrite(void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil); + +#ifdef __cplusplus +} +#endif + +#endif // __cache1d_h__ + diff --git a/polymer/build/include/compat.h b/polymer/build/include/compat.h new file mode 100644 index 000000000..9d9e82d87 --- /dev/null +++ b/polymer/build/include/compat.h @@ -0,0 +1,432 @@ +// Compatibility declarations for things which might not be present in +// certain build environments. It also levels the playing field caused +// by different platforms. + +#ifndef __compat_h__ +#define __compat_h__ + +// Define this to rewrite all 'B' versions to library functions. This +// is for platforms which give us a standard sort of C library so we +// link directly. Platforms like PalmOS which don't have a standard C +// library will need to wrap these functions with suitable emulations. +#define __compat_h_macrodef__ + +#ifdef __cplusplus +# include +#else +# include +#endif + +#ifdef __compat_h_macrodef__ +# ifdef __cplusplus +# include +# include +# include +# include +# else +# include +# include +# include +# include +# endif +# include +# include +# include +# include +# include +# if defined(_WIN32) +# include +# else +# include +# endif +#endif + +#ifdef EFENCE +# include +#endif + +#if defined(__WATCOMC__) +# define inline __inline +# define int64 __int64 +# define uint64 unsigned __int64 +# define longlong(x) x##i64 +#elif defined(_MSC_VER) +# define inline __inline +# define int64 __int64 +# define uint64 unsigned __int64 +# define longlong(x) x##i64 +#else +# define longlong(x) x##ll +typedef long long int64; +typedef unsigned long long uint64; +#endif + +#ifndef NULL +# define NULL ((void *)0) +#endif + +#if defined(__linux) +# include +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define B_LITTLE_ENDIAN 1 +# define B_BIG_ENDIAN 0 +# elif __BYTE_ORDER == __BIG_ENDIAN +# define B_LITTLE_ENDIAN 0 +# define B_BIG_ENDIAN 1 +# endif +# define B_ENDIAN_C_INLINE 1 + +#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) +# include +# if _BYTE_ORDER == _LITTLE_ENDIAN +# define B_LITTLE_ENDIAN 1 +# define B_BIG_ENDIAN 0 +# elif _BYTE_ORDER == _BIG_ENDIAN +# define B_LITTLE_ENDIAN 0 +# define B_BIG_ENDIAN 1 +# endif +# define B_SWAP64(x) __bswap64(x) +# define B_SWAP32(x) __bswap32(x) +# define B_SWAP16(x) __bswap16(x) + +#elif defined(__APPLE__) +# if defined(__LITTLE_ENDIAN__) +# define B_LITTLE_ENDIAN 1 +# define B_BIG_ENDIAN 0 +# elif defined(__BIG_ENDIAN__) +# define B_LITTLE_ENDIAN 0 +# define B_BIG_ENDIAN 1 +# endif +# include +# define B_SWAP64(x) OSSwapConstInt64(x) +# define B_SWAP32(x) OSSwapConstInt32(x) +# define B_SWAP16(x) OSSwapConstInt16(x) + +#elif defined(__BEOS__) +# include +# if LITTLE_ENDIAN != 0 +# define B_LITTLE_ENDIAN 1 +# define B_BIG_ENDIAN 0 +# elif BIG_ENDIAN != 0 +# define B_LITTLE_ENDIAN 0 +# define B_BIG_ENDIAN 1 +# endif +# define B_ENDIAN_C_INLINE 1 + +#elif defined(__QNX__) +# if defined __LITTLEENDIAN__ +# define B_LITTLE_ENDIAN 1 +# define B_BIG_ENDIAN 0 +# elif defined __BIGENDIAN__ +# define B_LITTLE_ENDIAN 0 +# define B_BIG_ENDIAN 1 +# endif +# define B_ENDIAN_C_INLINE 1 + +#elif defined(__sun) +# if defined _LITTLE_ENDIAN +# define B_LITTLE_ENDIAN 1 +# define B_BIG_ENDIAN 0 +# elif defined _BIG_ENDIAN +# define B_LITTLE_ENDIAN 0 +# define B_BIG_ENDIAN 1 +# endif +# define B_ENDIAN_C_INLINE 1 + +#elif defined(_WIN32) || defined(SKYOS) || defined(__SYLLABLE__) +# define B_LITTLE_ENDIAN 1 +# define B_BIG_ENDIAN 0 +# define B_ENDIAN_C_INLINE 1 +#endif + +#if !defined(B_LITTLE_ENDIAN) || !defined(B_BIG_ENDIAN) +# error Unknown endianness +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined B_ENDIAN_X86_INLINE +# if defined(_MSC_VER) + // inline asm using bswap/xchg +# elif defined(__GNUC__) + // inline asm using bswap/xchg +# elif defined(__WATCOMC__) + // inline asm using bswap/xchg +# endif +#elif defined B_ENDIAN_C_INLINE +static inline unsigned short B_SWAP16(unsigned short s) { return (s>>8)|(s<<8); } +static inline unsigned long B_SWAP32(unsigned long l) { return ((l>>8)&0xff00)|((l&0xff00)<<8)|(l<<24)|(l>>24); } +static inline uint64 B_SWAP64(uint64 l) { return (l>>56)|((l>>40)&0xff00)|((l>>24)&0xff0000)|((l>>8)&0xff000000)|((l&255)<<56)|((l&0xff00)<<40)|((l&0xff0000)<<24)|((l&0xff000000)<<8); } +#endif + +#if B_LITTLE_ENDIAN == 1 +# define B_LITTLE64(x) (x) +# define B_BIG64(x) B_SWAP64(x) +# define B_LITTLE32(x) (x) +# define B_BIG32(x) B_SWAP32(x) +# define B_LITTLE16(x) (x) +# define B_BIG16(x) B_SWAP16(x) +#elif B_BIG_ENDIAN == 1 +# define B_LITTLE64(x) B_SWAP64(x) +# define B_BIG64(x) (x) +# define B_LITTLE32(x) B_SWAP32(x) +# define B_BIG32(x) (x) +# define B_LITTLE16(x) B_SWAP16(x) +# define B_BIG16(x) (x) +#endif + +#ifndef FP_OFF +# define FP_OFF(__p) ((unsigned)(__p)) +#endif + +#ifdef __compat_h_macrodef__ + +# ifndef O_BINARY +# define O_BINARY 0 +# endif +# ifndef O_TEXT +# define O_TEXT 0 +# endif + +# ifndef F_OK +# define F_OK 0 +# endif + +# define BO_BINARY O_BINARY +# define BO_TEXT O_TEXT +# define BO_RDONLY O_RDONLY +# define BO_WRONLY O_WRONLY +# define BO_RDWR O_RDWR +# define BO_APPEND O_APPEND +# define BO_CREAT O_CREAT +# define BO_TRUNC O_TRUNC +# define BS_IRGRP S_IRGRP +# define BS_IWGRP S_IWGRP +# define BS_IEXEC S_IEXEC +# define BS_IWRITE S_IWRITE +# define BS_IREAD S_IREAD +# define BS_IFIFO S_IFIFO +# define BS_IFCHR S_IFCHR +# define BS_IFBLK S_IFBLK +# define BS_IFDIR S_IFDIR +# define BS_IFREG S_IFREG +# define BSEEK_SET SEEK_SET +# define BSEEK_CUR SEEK_CUR +# define BSEEK_END SEEK_END +#else +# define BO_BINARY 0 +# define BO_TEXT 1 +# define BO_RDONLY 2 +# define BO_WRONLY 4 +# define BO_RDWR 6 +# define BO_APPEND 8 +# define BO_CREAT 16 +# define BO_TRUNC 32 +# define BS_IRGRP 0 +# define BS_IWGRP 0 +# define BS_IEXEC 1 +# define BS_IWRITE 2 +# define BS_IREAD 4 +# define BS_IFIFO 0x1000 +# define BS_IFCHR 0x2000 +# define BS_IFBLK 0x3000 +# define BS_IFDIR 0x4000 +# define BS_IFREG 0x8000 +# define BSEEK_SET 0 +# define BSEEK_CUR 1 +# define BSEEK_END 2 +#endif + +#ifdef UNDERSCORES +# define ASMSYM(x) "_" x +#else +# define ASMSYM(x) x +#endif + +#ifndef min +# define min(a,b) ( ((a) < (b)) ? (a) : (b) ) +#endif + +#ifndef max +# define max(a,b) ( ((a) > (b)) ? (a) : (b) ) +#endif + + +#define BMAX_PATH 260 + + +struct Bdirent { + unsigned short namlen; + char *name; + unsigned mode; + unsigned size; + unsigned mtime; +}; +typedef void BDIR; + +BDIR* Bopendir(const char *name); +struct Bdirent* Breaddir(BDIR *dir); +int Bclosedir(BDIR *dir); + + +#ifdef __compat_h_macrodef__ +# define BFILE FILE +# define bsize_t size_t +# define bssize_t ssize_t +#else +typedef void BFILE; +typedef unsigned long bsize_t; +typedef signed long bssize_t; +#endif + + +#ifdef __compat_h_macrodef__ +# define Brand rand +# define Balloca alloca +# define Bmalloc malloc +# define Bcalloc calloc +# define Brealloc realloc +# define Bfree free +# define Bopen open +# define Bclose close +# define Bwrite write +# define Bread read +# define Blseek lseek +# if defined(__GNUC__) +# define Btell(h) lseek(h,0,SEEK_CUR) +# else +# define Btell tell +# endif +# define Bstat stat +# define Bfopen fopen +# define Bfclose fclose +# define Bfeof feof +# define Bfgetc fgetc +# define Brewind rewind +# define Bfgets fgets +# define Bfputc fputc +# define Bfputs fputs +# define Bfread fread +# define Bfwrite fwrite +# define Bfprintf fprintf +# define Bstrdup strdup +# define Bstrcpy strcpy +# define Bstrncpy strncpy +# define Bstrcmp strcmp +# define Bstrncmp strncmp +# if defined(__WATCOMC__) || defined(_MSC_VER) || defined(__QNX__) +# define Bstrcasecmp stricmp +# define Bstrncasecmp strnicmp +# else +# define Bstrcasecmp strcasecmp +# define Bstrncasecmp strncasecmp +# endif +# if defined(_WIN32) +# define Bstrlwr strlwr +# define Bstrupr strupr +# define Bmkdir(s,x) mkdir(s) +# else +# define Bmkdir mkdir +# endif +# define Bstrcat strcat +# define Bstrncat strncat +# define Bstrlen strlen +# define Bstrchr strchr +# define Bstrrchr strrchr +# define Batoi atoi +# define Batol atol +# define Bstrtol strtol +# define Bstrtoul strtoul +# define Bstrtod strtod +# define Btoupper toupper +# define Btolower tolower +# define Bmemcpy memcpy +# define Bmemmove memmove +# define Bmemchr memchr +# define Bmemset memset +# define Bmemcmp memcmp +# define Bprintf printf +# define Bsprintf sprintf +# ifdef _MSC_VER +# define Bsnprintf _snprintf +# define Bvsnprintf _vsnprintf +# else +# define Bsnprintf snprintf +# define Bvsnprintf vsnprintf +# endif +# define Bvfprintf vfprintf +# define Bgetcwd getcwd +# define Bgetenv getenv +# define Btime() time(NULL) + +#else + +int Brand(void); +void *Bmalloc(bsize_t size); +void Bfree(void *ptr); +int Bopen(const char *pathname, int flags, unsigned mode); +int Bclose(int fd); +bssize_t Bwrite(int fd, const void *buf, bsize_t count); +bssize_t Bread(int fd, void *buf, bsize_t count); +int Blseek(int fildes, int offset, int whence); +BFILE *Bfopen(const char *path, const char *mode); +int Bfclose(BFILE *stream); +int Bfeof(BFILE *stream); +int Bfgetc(BFILE *stream); +void Brewind(BFILE *stream); +char *Bfgets(char *s, int size, BFILE *stream); +int Bfputc(int c, BFILE *stream); +int Bfputs(const char *s, BFILE *stream); +bsize_t Bfread(void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream); +bsize_t Bfwrite(const void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream); +char *Bstrdup(const char *s); +char *Bstrcpy(char *dest, const char *src); +char *Bstrncpy(char *dest, const char *src, bsize_t n); +int Bstrcmp(const char *s1, const char *s2); +int Bstrncmp(const char *s1, const char *s2, bsize_t n); +int Bstrcasecmp(const char *s1, const char *s2); +int Bstrncasecmp(const char *s1, const char *s2, bsize_t n); +char *Bstrcat(char *dest, const char *src); +char *Bstrncat(char *dest, const char *src, bsize_t n); +bsize_t Bstrlen(const char *s); +char *Bstrchr(const char *s, int c); +char *Bstrrchr(const char *s, int c); +int Batoi(const char *nptr); +long Batol(const char *nptr); +long int Bstrtol(const char *nptr, char **endptr, int base); +unsigned long int Bstrtoul(const char *nptr, char **endptr, int base); +void *Bmemcpy(void *dest, const void *src, bsize_t n); +void *Bmemmove(void *dest, const void *src, bsize_t n); +void *Bmemchr(const void *s, int c, bsize_t n); +void *Bmemset(void *s, int c, bsize_t n); +int Bmemcmp(const void *s1, const void *s2, bsize_t n); +int Bprintf(const char *format, ...); +int Bsprintf(char *str, const char *format, ...); +int Bsnprintf(char *str, bsize_t size, const char *format, ...); +int Bvsnprintf(char *str, bsize_t size, const char *format, va_list ap); +char *Bgetcwd(char *buf, bsize_t size); +char *Bgetenv(const char *name); +#endif + +char *Bgethomedir(void); +unsigned int Bgetsysmemsize(void); +int Bcorrectfilename(char *filename, int removefn); +int Bcanonicalisefilename(char *filename, int removefn); +char *Bgetsystemdrives(void); +long Bfilelength(int fd); +char *Bstrtoken(char *s, char *delim, char **ptrptr, int chop); +long Bwildmatch (const char *i, const char *j); + +#if !defined(_WIN32) +char *Bstrlwr(char *); +char *Bstrupr(char *); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // __compat_h__ + diff --git a/polymer/build/include/crc32.h b/polymer/build/include/crc32.h new file mode 100644 index 000000000..d05dc5c0f --- /dev/null +++ b/polymer/build/include/crc32.h @@ -0,0 +1,20 @@ +#ifndef __crc32_h__ +#define __crc32_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +void initcrc32table(void); + +unsigned long crc32once(unsigned char *blk, unsigned long len); + +void crc32init(unsigned long *crcvar); +void crc32block(unsigned long *crcvar, unsigned char *blk, unsigned long len); +unsigned long crc32finish(unsigned long *crcvar); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/polymer/build/include/dxdidf.h b/polymer/build/include/dxdidf.h new file mode 100644 index 000000000..b4de78a1d --- /dev/null +++ b/polymer/build/include/dxdidf.h @@ -0,0 +1,332 @@ +#ifndef __dxdidf_h__ +#define __dxdidf_h__ + +// Keyboard + +static DIOBJECTDATAFORMAT c_dfDIKeyboard_odf[] = { + { &GUID_Key, 0, 0x8000000C, 0x00000000 }, + { &GUID_Key, 1, 0x8000010C, 0x00000000 }, + { &GUID_Key, 2, 0x8000020C, 0x00000000 }, + { &GUID_Key, 3, 0x8000030C, 0x00000000 }, + { &GUID_Key, 4, 0x8000040C, 0x00000000 }, + { &GUID_Key, 5, 0x8000050C, 0x00000000 }, + { &GUID_Key, 6, 0x8000060C, 0x00000000 }, + { &GUID_Key, 7, 0x8000070C, 0x00000000 }, + { &GUID_Key, 8, 0x8000080C, 0x00000000 }, + { &GUID_Key, 9, 0x8000090C, 0x00000000 }, + { &GUID_Key, 10, 0x80000A0C, 0x00000000 }, + { &GUID_Key, 11, 0x80000B0C, 0x00000000 }, + { &GUID_Key, 12, 0x80000C0C, 0x00000000 }, + { &GUID_Key, 13, 0x80000D0C, 0x00000000 }, + { &GUID_Key, 14, 0x80000E0C, 0x00000000 }, + { &GUID_Key, 15, 0x80000F0C, 0x00000000 }, + { &GUID_Key, 16, 0x8000100C, 0x00000000 }, + { &GUID_Key, 17, 0x8000110C, 0x00000000 }, + { &GUID_Key, 18, 0x8000120C, 0x00000000 }, + { &GUID_Key, 19, 0x8000130C, 0x00000000 }, + { &GUID_Key, 20, 0x8000140C, 0x00000000 }, + { &GUID_Key, 21, 0x8000150C, 0x00000000 }, + { &GUID_Key, 22, 0x8000160C, 0x00000000 }, + { &GUID_Key, 23, 0x8000170C, 0x00000000 }, + { &GUID_Key, 24, 0x8000180C, 0x00000000 }, + { &GUID_Key, 25, 0x8000190C, 0x00000000 }, + { &GUID_Key, 26, 0x80001A0C, 0x00000000 }, + { &GUID_Key, 27, 0x80001B0C, 0x00000000 }, + { &GUID_Key, 28, 0x80001C0C, 0x00000000 }, + { &GUID_Key, 29, 0x80001D0C, 0x00000000 }, + { &GUID_Key, 30, 0x80001E0C, 0x00000000 }, + { &GUID_Key, 31, 0x80001F0C, 0x00000000 }, + { &GUID_Key, 32, 0x8000200C, 0x00000000 }, + { &GUID_Key, 33, 0x8000210C, 0x00000000 }, + { &GUID_Key, 34, 0x8000220C, 0x00000000 }, + { &GUID_Key, 35, 0x8000230C, 0x00000000 }, + { &GUID_Key, 36, 0x8000240C, 0x00000000 }, + { &GUID_Key, 37, 0x8000250C, 0x00000000 }, + { &GUID_Key, 38, 0x8000260C, 0x00000000 }, + { &GUID_Key, 39, 0x8000270C, 0x00000000 }, + { &GUID_Key, 40, 0x8000280C, 0x00000000 }, + { &GUID_Key, 41, 0x8000290C, 0x00000000 }, + { &GUID_Key, 42, 0x80002A0C, 0x00000000 }, + { &GUID_Key, 43, 0x80002B0C, 0x00000000 }, + { &GUID_Key, 44, 0x80002C0C, 0x00000000 }, + { &GUID_Key, 45, 0x80002D0C, 0x00000000 }, + { &GUID_Key, 46, 0x80002E0C, 0x00000000 }, + { &GUID_Key, 47, 0x80002F0C, 0x00000000 }, + { &GUID_Key, 48, 0x8000300C, 0x00000000 }, + { &GUID_Key, 49, 0x8000310C, 0x00000000 }, + { &GUID_Key, 50, 0x8000320C, 0x00000000 }, + { &GUID_Key, 51, 0x8000330C, 0x00000000 }, + { &GUID_Key, 52, 0x8000340C, 0x00000000 }, + { &GUID_Key, 53, 0x8000350C, 0x00000000 }, + { &GUID_Key, 54, 0x8000360C, 0x00000000 }, + { &GUID_Key, 55, 0x8000370C, 0x00000000 }, + { &GUID_Key, 56, 0x8000380C, 0x00000000 }, + { &GUID_Key, 57, 0x8000390C, 0x00000000 }, + { &GUID_Key, 58, 0x80003A0C, 0x00000000 }, + { &GUID_Key, 59, 0x80003B0C, 0x00000000 }, + { &GUID_Key, 60, 0x80003C0C, 0x00000000 }, + { &GUID_Key, 61, 0x80003D0C, 0x00000000 }, + { &GUID_Key, 62, 0x80003E0C, 0x00000000 }, + { &GUID_Key, 63, 0x80003F0C, 0x00000000 }, + { &GUID_Key, 64, 0x8000400C, 0x00000000 }, + { &GUID_Key, 65, 0x8000410C, 0x00000000 }, + { &GUID_Key, 66, 0x8000420C, 0x00000000 }, + { &GUID_Key, 67, 0x8000430C, 0x00000000 }, + { &GUID_Key, 68, 0x8000440C, 0x00000000 }, + { &GUID_Key, 69, 0x8000450C, 0x00000000 }, + { &GUID_Key, 70, 0x8000460C, 0x00000000 }, + { &GUID_Key, 71, 0x8000470C, 0x00000000 }, + { &GUID_Key, 72, 0x8000480C, 0x00000000 }, + { &GUID_Key, 73, 0x8000490C, 0x00000000 }, + { &GUID_Key, 74, 0x80004A0C, 0x00000000 }, + { &GUID_Key, 75, 0x80004B0C, 0x00000000 }, + { &GUID_Key, 76, 0x80004C0C, 0x00000000 }, + { &GUID_Key, 77, 0x80004D0C, 0x00000000 }, + { &GUID_Key, 78, 0x80004E0C, 0x00000000 }, + { &GUID_Key, 79, 0x80004F0C, 0x00000000 }, + { &GUID_Key, 80, 0x8000500C, 0x00000000 }, + { &GUID_Key, 81, 0x8000510C, 0x00000000 }, + { &GUID_Key, 82, 0x8000520C, 0x00000000 }, + { &GUID_Key, 83, 0x8000530C, 0x00000000 }, + { &GUID_Key, 84, 0x8000540C, 0x00000000 }, + { &GUID_Key, 85, 0x8000550C, 0x00000000 }, + { &GUID_Key, 86, 0x8000560C, 0x00000000 }, + { &GUID_Key, 87, 0x8000570C, 0x00000000 }, + { &GUID_Key, 88, 0x8000580C, 0x00000000 }, + { &GUID_Key, 89, 0x8000590C, 0x00000000 }, + { &GUID_Key, 90, 0x80005A0C, 0x00000000 }, + { &GUID_Key, 91, 0x80005B0C, 0x00000000 }, + { &GUID_Key, 92, 0x80005C0C, 0x00000000 }, + { &GUID_Key, 93, 0x80005D0C, 0x00000000 }, + { &GUID_Key, 94, 0x80005E0C, 0x00000000 }, + { &GUID_Key, 95, 0x80005F0C, 0x00000000 }, + { &GUID_Key, 96, 0x8000600C, 0x00000000 }, + { &GUID_Key, 97, 0x8000610C, 0x00000000 }, + { &GUID_Key, 98, 0x8000620C, 0x00000000 }, + { &GUID_Key, 99, 0x8000630C, 0x00000000 }, + { &GUID_Key, 100, 0x8000640C, 0x00000000 }, + { &GUID_Key, 101, 0x8000650C, 0x00000000 }, + { &GUID_Key, 102, 0x8000660C, 0x00000000 }, + { &GUID_Key, 103, 0x8000670C, 0x00000000 }, + { &GUID_Key, 104, 0x8000680C, 0x00000000 }, + { &GUID_Key, 105, 0x8000690C, 0x00000000 }, + { &GUID_Key, 106, 0x80006A0C, 0x00000000 }, + { &GUID_Key, 107, 0x80006B0C, 0x00000000 }, + { &GUID_Key, 108, 0x80006C0C, 0x00000000 }, + { &GUID_Key, 109, 0x80006D0C, 0x00000000 }, + { &GUID_Key, 110, 0x80006E0C, 0x00000000 }, + { &GUID_Key, 111, 0x80006F0C, 0x00000000 }, + { &GUID_Key, 112, 0x8000700C, 0x00000000 }, + { &GUID_Key, 113, 0x8000710C, 0x00000000 }, + { &GUID_Key, 114, 0x8000720C, 0x00000000 }, + { &GUID_Key, 115, 0x8000730C, 0x00000000 }, + { &GUID_Key, 116, 0x8000740C, 0x00000000 }, + { &GUID_Key, 117, 0x8000750C, 0x00000000 }, + { &GUID_Key, 118, 0x8000760C, 0x00000000 }, + { &GUID_Key, 119, 0x8000770C, 0x00000000 }, + { &GUID_Key, 120, 0x8000780C, 0x00000000 }, + { &GUID_Key, 121, 0x8000790C, 0x00000000 }, + { &GUID_Key, 122, 0x80007A0C, 0x00000000 }, + { &GUID_Key, 123, 0x80007B0C, 0x00000000 }, + { &GUID_Key, 124, 0x80007C0C, 0x00000000 }, + { &GUID_Key, 125, 0x80007D0C, 0x00000000 }, + { &GUID_Key, 126, 0x80007E0C, 0x00000000 }, + { &GUID_Key, 127, 0x80007F0C, 0x00000000 }, + { &GUID_Key, 128, 0x8000800C, 0x00000000 }, + { &GUID_Key, 129, 0x8000810C, 0x00000000 }, + { &GUID_Key, 130, 0x8000820C, 0x00000000 }, + { &GUID_Key, 131, 0x8000830C, 0x00000000 }, + { &GUID_Key, 132, 0x8000840C, 0x00000000 }, + { &GUID_Key, 133, 0x8000850C, 0x00000000 }, + { &GUID_Key, 134, 0x8000860C, 0x00000000 }, + { &GUID_Key, 135, 0x8000870C, 0x00000000 }, + { &GUID_Key, 136, 0x8000880C, 0x00000000 }, + { &GUID_Key, 137, 0x8000890C, 0x00000000 }, + { &GUID_Key, 138, 0x80008A0C, 0x00000000 }, + { &GUID_Key, 139, 0x80008B0C, 0x00000000 }, + { &GUID_Key, 140, 0x80008C0C, 0x00000000 }, + { &GUID_Key, 141, 0x80008D0C, 0x00000000 }, + { &GUID_Key, 142, 0x80008E0C, 0x00000000 }, + { &GUID_Key, 143, 0x80008F0C, 0x00000000 }, + { &GUID_Key, 144, 0x8000900C, 0x00000000 }, + { &GUID_Key, 145, 0x8000910C, 0x00000000 }, + { &GUID_Key, 146, 0x8000920C, 0x00000000 }, + { &GUID_Key, 147, 0x8000930C, 0x00000000 }, + { &GUID_Key, 148, 0x8000940C, 0x00000000 }, + { &GUID_Key, 149, 0x8000950C, 0x00000000 }, + { &GUID_Key, 150, 0x8000960C, 0x00000000 }, + { &GUID_Key, 151, 0x8000970C, 0x00000000 }, + { &GUID_Key, 152, 0x8000980C, 0x00000000 }, + { &GUID_Key, 153, 0x8000990C, 0x00000000 }, + { &GUID_Key, 154, 0x80009A0C, 0x00000000 }, + { &GUID_Key, 155, 0x80009B0C, 0x00000000 }, + { &GUID_Key, 156, 0x80009C0C, 0x00000000 }, + { &GUID_Key, 157, 0x80009D0C, 0x00000000 }, + { &GUID_Key, 158, 0x80009E0C, 0x00000000 }, + { &GUID_Key, 159, 0x80009F0C, 0x00000000 }, + { &GUID_Key, 160, 0x8000A00C, 0x00000000 }, + { &GUID_Key, 161, 0x8000A10C, 0x00000000 }, + { &GUID_Key, 162, 0x8000A20C, 0x00000000 }, + { &GUID_Key, 163, 0x8000A30C, 0x00000000 }, + { &GUID_Key, 164, 0x8000A40C, 0x00000000 }, + { &GUID_Key, 165, 0x8000A50C, 0x00000000 }, + { &GUID_Key, 166, 0x8000A60C, 0x00000000 }, + { &GUID_Key, 167, 0x8000A70C, 0x00000000 }, + { &GUID_Key, 168, 0x8000A80C, 0x00000000 }, + { &GUID_Key, 169, 0x8000A90C, 0x00000000 }, + { &GUID_Key, 170, 0x8000AA0C, 0x00000000 }, + { &GUID_Key, 171, 0x8000AB0C, 0x00000000 }, + { &GUID_Key, 172, 0x8000AC0C, 0x00000000 }, + { &GUID_Key, 173, 0x8000AD0C, 0x00000000 }, + { &GUID_Key, 174, 0x8000AE0C, 0x00000000 }, + { &GUID_Key, 175, 0x8000AF0C, 0x00000000 }, + { &GUID_Key, 176, 0x8000B00C, 0x00000000 }, + { &GUID_Key, 177, 0x8000B10C, 0x00000000 }, + { &GUID_Key, 178, 0x8000B20C, 0x00000000 }, + { &GUID_Key, 179, 0x8000B30C, 0x00000000 }, + { &GUID_Key, 180, 0x8000B40C, 0x00000000 }, + { &GUID_Key, 181, 0x8000B50C, 0x00000000 }, + { &GUID_Key, 182, 0x8000B60C, 0x00000000 }, + { &GUID_Key, 183, 0x8000B70C, 0x00000000 }, + { &GUID_Key, 184, 0x8000B80C, 0x00000000 }, + { &GUID_Key, 185, 0x8000B90C, 0x00000000 }, + { &GUID_Key, 186, 0x8000BA0C, 0x00000000 }, + { &GUID_Key, 187, 0x8000BB0C, 0x00000000 }, + { &GUID_Key, 188, 0x8000BC0C, 0x00000000 }, + { &GUID_Key, 189, 0x8000BD0C, 0x00000000 }, + { &GUID_Key, 190, 0x8000BE0C, 0x00000000 }, + { &GUID_Key, 191, 0x8000BF0C, 0x00000000 }, + { &GUID_Key, 192, 0x8000C00C, 0x00000000 }, + { &GUID_Key, 193, 0x8000C10C, 0x00000000 }, + { &GUID_Key, 194, 0x8000C20C, 0x00000000 }, + { &GUID_Key, 195, 0x8000C30C, 0x00000000 }, + { &GUID_Key, 196, 0x8000C40C, 0x00000000 }, + { &GUID_Key, 197, 0x8000C50C, 0x00000000 }, + { &GUID_Key, 198, 0x8000C60C, 0x00000000 }, + { &GUID_Key, 199, 0x8000C70C, 0x00000000 }, + { &GUID_Key, 200, 0x8000C80C, 0x00000000 }, + { &GUID_Key, 201, 0x8000C90C, 0x00000000 }, + { &GUID_Key, 202, 0x8000CA0C, 0x00000000 }, + { &GUID_Key, 203, 0x8000CB0C, 0x00000000 }, + { &GUID_Key, 204, 0x8000CC0C, 0x00000000 }, + { &GUID_Key, 205, 0x8000CD0C, 0x00000000 }, + { &GUID_Key, 206, 0x8000CE0C, 0x00000000 }, + { &GUID_Key, 207, 0x8000CF0C, 0x00000000 }, + { &GUID_Key, 208, 0x8000D00C, 0x00000000 }, + { &GUID_Key, 209, 0x8000D10C, 0x00000000 }, + { &GUID_Key, 210, 0x8000D20C, 0x00000000 }, + { &GUID_Key, 211, 0x8000D30C, 0x00000000 }, + { &GUID_Key, 212, 0x8000D40C, 0x00000000 }, + { &GUID_Key, 213, 0x8000D50C, 0x00000000 }, + { &GUID_Key, 214, 0x8000D60C, 0x00000000 }, + { &GUID_Key, 215, 0x8000D70C, 0x00000000 }, + { &GUID_Key, 216, 0x8000D80C, 0x00000000 }, + { &GUID_Key, 217, 0x8000D90C, 0x00000000 }, + { &GUID_Key, 218, 0x8000DA0C, 0x00000000 }, + { &GUID_Key, 219, 0x8000DB0C, 0x00000000 }, + { &GUID_Key, 220, 0x8000DC0C, 0x00000000 }, + { &GUID_Key, 221, 0x8000DD0C, 0x00000000 }, + { &GUID_Key, 222, 0x8000DE0C, 0x00000000 }, + { &GUID_Key, 223, 0x8000DF0C, 0x00000000 }, + { &GUID_Key, 224, 0x8000E00C, 0x00000000 }, + { &GUID_Key, 225, 0x8000E10C, 0x00000000 }, + { &GUID_Key, 226, 0x8000E20C, 0x00000000 }, + { &GUID_Key, 227, 0x8000E30C, 0x00000000 }, + { &GUID_Key, 228, 0x8000E40C, 0x00000000 }, + { &GUID_Key, 229, 0x8000E50C, 0x00000000 }, + { &GUID_Key, 230, 0x8000E60C, 0x00000000 }, + { &GUID_Key, 231, 0x8000E70C, 0x00000000 }, + { &GUID_Key, 232, 0x8000E80C, 0x00000000 }, + { &GUID_Key, 233, 0x8000E90C, 0x00000000 }, + { &GUID_Key, 234, 0x8000EA0C, 0x00000000 }, + { &GUID_Key, 235, 0x8000EB0C, 0x00000000 }, + { &GUID_Key, 236, 0x8000EC0C, 0x00000000 }, + { &GUID_Key, 237, 0x8000ED0C, 0x00000000 }, + { &GUID_Key, 238, 0x8000EE0C, 0x00000000 }, + { &GUID_Key, 239, 0x8000EF0C, 0x00000000 }, + { &GUID_Key, 240, 0x8000F00C, 0x00000000 }, + { &GUID_Key, 241, 0x8000F10C, 0x00000000 }, + { &GUID_Key, 242, 0x8000F20C, 0x00000000 }, + { &GUID_Key, 243, 0x8000F30C, 0x00000000 }, + { &GUID_Key, 244, 0x8000F40C, 0x00000000 }, + { &GUID_Key, 245, 0x8000F50C, 0x00000000 }, + { &GUID_Key, 246, 0x8000F60C, 0x00000000 }, + { &GUID_Key, 247, 0x8000F70C, 0x00000000 }, + { &GUID_Key, 248, 0x8000F80C, 0x00000000 }, + { &GUID_Key, 249, 0x8000F90C, 0x00000000 }, + { &GUID_Key, 250, 0x8000FA0C, 0x00000000 }, + { &GUID_Key, 251, 0x8000FB0C, 0x00000000 }, + { &GUID_Key, 252, 0x8000FC0C, 0x00000000 }, + { &GUID_Key, 253, 0x8000FD0C, 0x00000000 }, + { &GUID_Key, 254, 0x8000FE0C, 0x00000000 }, + { &GUID_Key, 255, 0x8000FF0C, 0x00000000 } +}; + +const DIDATAFORMAT c_dfDIKeyboard = { 24, 16, 0x00000002, 256, 256, c_dfDIKeyboard_odf }; + +// Mouse + +static DIOBJECTDATAFORMAT c_dfDIMouse_odf[] = { + { &GUID_XAxis, 0, 0x00FFFF03, 0x00000000 }, + { &GUID_YAxis, 4, 0x00FFFF03, 0x00000000 }, + { &GUID_ZAxis, 8, 0x80FFFF03, 0x00000000 }, + { NULL, 12, 0x00FFFF0C, 0x00000000 }, + { NULL, 13, 0x00FFFF0C, 0x00000000 }, + { NULL, 14, 0x80FFFF0C, 0x00000000 }, + { NULL, 15, 0x80FFFF0C, 0x00000000 } +}; + +const DIDATAFORMAT c_dfDIMouse = { 24, 16, 0x00000002, 16, 7, c_dfDIMouse_odf }; + +// Joystick + +static DIOBJECTDATAFORMAT c_dfDIJoystick_odf[] = { + { &GUID_XAxis, 0, 0x80FFFF03, 0x00000100 }, + { &GUID_YAxis, 4, 0x80FFFF03, 0x00000100 }, + { &GUID_ZAxis, 8, 0x80FFFF03, 0x00000100 }, + { &GUID_RxAxis, 12, 0x80FFFF03, 0x00000100 }, + { &GUID_RyAxis, 16, 0x80FFFF03, 0x00000100 }, + { &GUID_RzAxis, 20, 0x80FFFF03, 0x00000100 }, + { &GUID_Slider, 24, 0x80FFFF03, 0x00000100 }, + { &GUID_Slider, 28, 0x80FFFF03, 0x00000100 }, + { &GUID_POV, 32, 0x80FFFF10, 0x00000000 }, + { &GUID_POV, 36, 0x80FFFF10, 0x00000000 }, + { &GUID_POV, 40, 0x80FFFF10, 0x00000000 }, + { &GUID_POV, 44, 0x80FFFF10, 0x00000000 }, + { NULL, 48, 0x80FFFF0C, 0x00000000 }, + { NULL, 49, 0x80FFFF0C, 0x00000000 }, + { NULL, 50, 0x80FFFF0C, 0x00000000 }, + { NULL, 51, 0x80FFFF0C, 0x00000000 }, + { NULL, 52, 0x80FFFF0C, 0x00000000 }, + { NULL, 53, 0x80FFFF0C, 0x00000000 }, + { NULL, 54, 0x80FFFF0C, 0x00000000 }, + { NULL, 55, 0x80FFFF0C, 0x00000000 }, + { NULL, 56, 0x80FFFF0C, 0x00000000 }, + { NULL, 57, 0x80FFFF0C, 0x00000000 }, + { NULL, 58, 0x80FFFF0C, 0x00000000 }, + { NULL, 59, 0x80FFFF0C, 0x00000000 }, + { NULL, 60, 0x80FFFF0C, 0x00000000 }, + { NULL, 61, 0x80FFFF0C, 0x00000000 }, + { NULL, 62, 0x80FFFF0C, 0x00000000 }, + { NULL, 63, 0x80FFFF0C, 0x00000000 }, + { NULL, 64, 0x80FFFF0C, 0x00000000 }, + { NULL, 65, 0x80FFFF0C, 0x00000000 }, + { NULL, 66, 0x80FFFF0C, 0x00000000 }, + { NULL, 67, 0x80FFFF0C, 0x00000000 }, + { NULL, 68, 0x80FFFF0C, 0x00000000 }, + { NULL, 69, 0x80FFFF0C, 0x00000000 }, + { NULL, 70, 0x80FFFF0C, 0x00000000 }, + { NULL, 71, 0x80FFFF0C, 0x00000000 }, + { NULL, 72, 0x80FFFF0C, 0x00000000 }, + { NULL, 73, 0x80FFFF0C, 0x00000000 }, + { NULL, 74, 0x80FFFF0C, 0x00000000 }, + { NULL, 75, 0x80FFFF0C, 0x00000000 }, + { NULL, 76, 0x80FFFF0C, 0x00000000 }, + { NULL, 77, 0x80FFFF0C, 0x00000000 }, + { NULL, 78, 0x80FFFF0C, 0x00000000 }, + { NULL, 79, 0x80FFFF0C, 0x00000000 } +}; + +const DIDATAFORMAT c_dfDIJoystick = { 24, 16, 0x00000001, 80, 44, c_dfDIJoystick_odf }; + +#endif // __dxdidf_h__ diff --git a/polymer/build/include/editor.h b/polymer/build/include/editor.h new file mode 100644 index 000000000..130dfa3a2 --- /dev/null +++ b/polymer/build/include/editor.h @@ -0,0 +1,68 @@ +// "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. + +#ifndef __editor_h__ +#define __editor_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NUMBUILDKEYS 20 + +extern long qsetmode; +extern short searchsector, searchwall, searchstat; +extern long zmode, kensplayerheight; +extern short defaultspritecstat; + +extern short temppicnum, tempcstat, templotag, temphitag, tempextra; +extern char tempshade, temppal, tempxrepeat, tempyrepeat; +extern char somethingintab; + +extern char buildkeys[NUMBUILDKEYS]; + +extern long ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d; + + +extern int ExtInit(void); +extern void ExtUnInit(void); +extern void ExtPreCheckKeys(void); +#ifdef SUPERBUILD +extern void ExtAnalyzeSprites(void); +#endif +extern void ExtCheckKeys(void); +extern void ExtPreLoadMap(void); +extern void ExtLoadMap(const char *mapname); +extern void ExtPreSaveMap(void); +extern void ExtSaveMap(const char *mapname); +extern const char *ExtGetSectorCaption(short sectnum); +extern const char *ExtGetWallCaption(short wallnum); +extern const char *ExtGetSpriteCaption(short spritenum); +extern void ExtShowSectorData(short sectnum); +extern void ExtShowWallData(short wallnum); +extern void ExtShowSpriteData(short spritenum); +extern void ExtEditSectorData(short sectnum); +extern void ExtEditWallData(short wallnum); +extern void ExtEditSpriteData(short spritenum); + + +int loadsetup(const char *fn); // from config.c +int writesetup(const char *fn); // from config.c + +void editinput(void); +void clearmidstatbar16(void); + +long getnumber256(char namestart[80], long num, long maxnumber, char sign); +long getnumber16(char namestart[80], long num, long maxnumber, char sign); +void printmessage256(char name[82]); +void printmessage16(char name[82]); + +void getpoint(long searchxe, long searchye, long *x, long *y); +long getpointhighlight(long xplc, long yplc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/polymer/build/include/engineinfo.h b/polymer/build/include/engineinfo.h new file mode 100644 index 000000000..75adc1b4f --- /dev/null +++ b/polymer/build/include/engineinfo.h @@ -0,0 +1,6 @@ +extern const char _engine_cflags[]; +extern const char _engine_libs[]; +extern const char _engine_uname[]; +extern const char _engine_compiler[]; +extern const char _engine_date[]; + diff --git a/polymer/build/include/game.h b/polymer/build/include/game.h new file mode 100644 index 000000000..e121c4ff0 --- /dev/null +++ b/polymer/build/include/game.h @@ -0,0 +1,56 @@ +// game.h + +void operatesector(short dasector); +void operatesprite(short dasprite); +long changehealth(short snum, short deltahealth); +void changenumbombs(short snum, short deltanumbombs); +void changenummissiles(short snum, short deltanummissiles); +void changenumgrabbers(short snum, short deltanumgrabbers); +void drawstatusflytime(short snum); +void drawstatusbar(short snum); +void prepareboard(char *daboardfilename); +void checktouchsprite(short snum, short sectnum); +void checkgrabbertouchsprite(short snum, short sectnum); +void shootgun(short snum, long x, long y, long z, short daang, long dahoriz, short dasectnum, char guntype); +void analyzesprites(long dax, long day); +void tagcode(void); +void statuslistcode(void); +void activatehitag(short dahitag); +void bombexplode(long i); +void processinput(short snum); +void view(short snum, long *vx, long *vy, long *vz, short *vsectnum, short ang, long horiz); +void updatesectorz(long x, long y, long z, short *sectnum); +void drawscreen(short snum, long dasmoothratio); +void movethings(void); +void fakedomovethings(void); +void fakedomovethingscorrect(void); +void domovethings(void); +void getinput(void); +void initplayersprite(short snum); +void playback(void); +void setup3dscreen(void); +void findrandomspot(long *x, long *y, short *sectnum); +void warp(long *x, long *y, long *z, short *daang, short *dasector); +void warpsprite(short spritenum); +void initlava(void); +void movelava(char *dapic); +void doanimations(void); +long getanimationgoal(long animptr); +long setanimation(long *animptr, long thegoal, long thevel, long theacc); +void checkmasterslaveswitch(void); +long testneighborsectors(short sect1, short sect2); +long loadgame(void); +long savegame(void); +void faketimerhandler(void); +void getpackets(void); +void drawoverheadmap(long cposx, long cposy, long czoom, short cang); +long movesprite(short spritenum, long dx, long dy, long dz, long ceildist, long flordist, long clipmask); +void waitforeverybody(void); +void searchmap(short startsector); +void setinterpolation(long *posptr); +void stopinterpolation(long *posptr); +void updateinterpolations(void); +void dointerpolations(void); +void restoreinterpolations(void); +void printext(long x, long y, char *buffer, short tilenum, char invisiblecol); +void drawtilebackground (long thex, long they, short tilenum, signed char shade, long cx1, long cy1, long cx2, long cy2, char dapalnum); diff --git a/polymer/build/include/glbuild.h b/polymer/build/include/glbuild.h new file mode 100644 index 000000000..0b066a14a --- /dev/null +++ b/polymer/build/include/glbuild.h @@ -0,0 +1,211 @@ +#ifdef USE_OPENGL + +#ifdef RENDERTYPEWIN +#define WIN32_LEAN_AND_MEAN +#include +#endif + +#if defined(__APPLE__) +# include +#else +# include +#endif + +// get this header from http://oss.sgi.com/projects/ogl-sample/registry/ +// if you are missing it +//#include +#if defined(__APPLE__) +# include +#else +# include "glext.h" +#endif + +#ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT +#error You should get an updated copy of glext.h from http://oss.sgi.com/projects/ogl-sample/registry/ +#endif + +#ifdef DYNAMIC_OPENGL + +#ifndef APIENTRY +# define APIENTRY +#endif + +extern void (APIENTRY * bglClearColor)( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); +extern void (APIENTRY * bglClear)( GLbitfield mask ); +extern void (APIENTRY * bglColorMask)( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); +extern void (APIENTRY * bglAlphaFunc)( GLenum func, GLclampf ref ); +extern void (APIENTRY * bglBlendFunc)( GLenum sfactor, GLenum dfactor ); +extern void (APIENTRY * bglCullFace)( GLenum mode ); +extern void (APIENTRY * bglFrontFace)( GLenum mode ); +extern void (APIENTRY * bglPolygonOffset)( GLfloat factor, GLfloat units ); +extern void (APIENTRY * bglPolygonMode)( GLenum face, GLenum mode ); +extern void (APIENTRY * bglEnable)( GLenum cap ); +extern void (APIENTRY * bglDisable)( GLenum cap ); +extern void (APIENTRY * bglGetFloatv)( GLenum pname, GLfloat *params ); +extern void (APIENTRY * bglGetIntegerv)( GLenum pname, GLint *params ); +extern void (APIENTRY * bglPushAttrib)( GLbitfield mask ); +extern void (APIENTRY * bglPopAttrib)( void ); +extern GLenum (APIENTRY * bglGetError)( void ); +extern const GLubyte* (APIENTRY * bglGetString)( GLenum name ); +extern void (APIENTRY * bglHint)( GLenum target, GLenum mode ); + +// Depth +extern void (APIENTRY * bglDepthFunc)( GLenum func ); +extern void (APIENTRY * bglDepthMask)( GLboolean flag ); +extern void (APIENTRY * bglDepthRange)( GLclampd near_val, GLclampd far_val ); + +// Matrix +extern void (APIENTRY * bglMatrixMode)( GLenum mode ); +extern void (APIENTRY * bglOrtho)( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); +extern void (APIENTRY * bglFrustum)( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); +extern void (APIENTRY * bglViewport)( GLint x, GLint y, GLsizei width, GLsizei height ); +extern void (APIENTRY * bglPushMatrix)( void ); +extern void (APIENTRY * bglPopMatrix)( void ); +extern void (APIENTRY * bglLoadIdentity)( void ); +extern void (APIENTRY * bglLoadMatrixf)( const GLfloat *m ); + +// Drawing +extern void (APIENTRY * bglBegin)( GLenum mode ); +extern void (APIENTRY * bglEnd)( void ); +extern void (APIENTRY * bglVertex2f)( GLfloat x, GLfloat y ); +extern void (APIENTRY * bglVertex2i)( GLint x, GLint y ); +extern void (APIENTRY * bglVertex3d)( GLdouble x, GLdouble y, GLdouble z ); +extern void (APIENTRY * bglVertex3fv)( const GLfloat *v ); +extern void (APIENTRY * bglColor4f)( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); +extern void (APIENTRY * bglColor4ub)( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ); +extern void (APIENTRY * bglTexCoord2d)( GLdouble s, GLdouble t ); +extern void (APIENTRY * bglTexCoord2f)( GLfloat s, GLfloat t ); + +// Lighting +extern void (APIENTRY * bglShadeModel)( GLenum mode ); + +// Raster funcs +extern void (APIENTRY * bglReadPixels)( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ); + +// Texture mapping +extern void (APIENTRY * bglTexEnvf)( GLenum target, GLenum pname, GLfloat param ); +extern void (APIENTRY * bglGenTextures)( GLsizei n, GLuint *textures ); // 1.1 +extern void (APIENTRY * bglDeleteTextures)( GLsizei n, const GLuint *textures); // 1.1 +extern void (APIENTRY * bglBindTexture)( GLenum target, GLuint texture ); // 1.1 +extern void (APIENTRY * bglTexImage2D)( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); +extern void (APIENTRY * bglTexSubImage2D)( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); // 1.1 +extern void (APIENTRY * bglTexParameterf)( GLenum target, GLenum pname, GLfloat param ); +extern void (APIENTRY * bglTexParameteri)( GLenum target, GLenum pname, GLint param ); +extern void (APIENTRY * bglGetTexLevelParameteriv)( GLenum target, GLint level, GLenum pname, GLint *params ); +extern void (APIENTRY * bglCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +extern void (APIENTRY * bglGetCompressedTexImageARB)(GLenum, GLint, GLvoid *); + +// Fog +extern void (APIENTRY * bglFogf)( GLenum pname, GLfloat param ); +extern void (APIENTRY * bglFogi)( GLenum pname, GLint param ); +extern void (APIENTRY * bglFogfv)( GLenum pname, const GLfloat *params ); + +#ifdef RENDERTYPEWIN +// Windows +extern HGLRC (WINAPI * bwglCreateContext)(HDC); +extern BOOL (WINAPI * bwglDeleteContext)(HGLRC); +extern PROC (WINAPI * bwglGetProcAddress)(LPCSTR); +extern BOOL (WINAPI * bwglMakeCurrent)(HDC,HGLRC); + +extern BOOL (WINAPI * bwglSwapBuffers)(HDC); +extern int (WINAPI * bwglChoosePixelFormat)(HDC,CONST PIXELFORMATDESCRIPTOR*); +extern int (WINAPI * bwglDescribePixelFormat)(HDC,int,UINT,LPPIXELFORMATDESCRIPTOR); +extern int (WINAPI * bwglGetPixelFormat)(HDC); +extern BOOL (WINAPI * bwglSetPixelFormat)(HDC,int,const PIXELFORMATDESCRIPTOR*); +#endif + +#else // DYNAMIC_OPENGL + +#define bglClearColor glClearColor +#define bglClear glClear +#define bglColorMask glColorMask +#define bglAlphaFunc glAlphaFunc +#define bglBlendFunc glBlendFunc +#define bglCullFace glCullFace +#define bglFrontFace glFrontFace +#define bglPolygonOffset glPolygonOffset +#define bglPolygonMode glPolygonMode +#define bglEnable glEnable +#define bglDisable glDisable +#define bglGetFloatv glGetFloatv +#define bglGetIntegerv glGetIntegerv +#define bglPushAttrib glPushAttrib +#define bglPopAttrib glPopAttrib +#define bglGetError glGetError +#define bglGetString glGetString +#define bglHint glHint + +// Depth +#define bglDepthFunc glDepthFunc +#define bglDepthMask glDepthMask +#define bglDepthRange glDepthRange + +// Matrix +#define bglMatrixMode glMatrixMode +#define bglOrtho glOrtho +#define bglFrustum glFrustum +#define bglViewport glViewport +#define bglPushMatrix glPushMatrix +#define bglPopMatrix glPopMatrix +#define bglLoadIdentity glLoadIdentity +#define bglLoadMatrixf glLoadMatrixf + +// Drawing +#define bglBegin glBegin +#define bglEnd glEnd +#define bglVertex2f glVertex2f +#define bglVertex2i glVertex2i +#define bglVertex3d glVertex3d +#define bglVertex3fv glVertex3fv +#define bglColor4f glColor4f +#define bglColor4ub glColor4ub +#define bglTexCoord2d glTexCoord2d +#define bglTexCoord2f glTexCoord2f + +// Lighting +#define bglShadeModel glShadeModel + +// Raster funcs +#define bglReadPixels glReadPixels + +// Texture mapping +#define bglTexEnvf glTexEnvf +#define bglGenTextures glGenTextures +#define bglDeleteTextures glDeleteTextures +#define bglBindTexture glBindTexture +#define bglTexImage2D glTexImage2D +#define bglTexSubImage2D glTexSubImage2D +#define bglTexParameterf glTexParameterf +#define bglTexParameteri glTexParameteri +#define bglGetTexLevelParameteriv glGetTexLevelParameteriv +#define bglCompressedTexImage2DARB glCompressedTexImage2DARB +#define bglGetCompressedTexImageARB glGetCompressedTexImageARB + +// Fog +#define bglFogf glFogf +#define bglFogi glFogi +#define bglFogfv glFogfv + +#ifdef RENDERTYPEWIN +#define bwglCreateContext wglCreateContext +#define bwglDeleteContext wglDeleteContext +#define bwglGetProcAddress wglGetProcAddress +#define bwglMakeCurrent wglMakeCurrent + +#define bwglSwapBuffers SwapBuffers +#define bwglChoosePixelFormat ChoosePixelFormat +#define bwglDescribePixelFormat DescribePixelFormat +#define bwglGetPixelFormat GetPixelFormat +#define bwglSetPixelFormat SetPixelFormat +#endif + +#endif + +#endif //USE_OPENGL + +extern char *gldriver; + +int loadgldriver(const char *driver); +int loadglextensions(void); +int unloadgldriver(void); + diff --git a/polymer/build/include/glext.h b/polymer/build/include/glext.h new file mode 100644 index 000000000..f8b6cbc61 --- /dev/null +++ b/polymer/build/include/glext.h @@ -0,0 +1,5545 @@ +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2002 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated 2003/5/9 */ +/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ +#define GL_GLEXT_VERSION 18 + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + + +/*************************************************************/ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirror_repeat +#define GL_ARB_texture_mirror_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +/* GL types for handling large vertex buffer objects */ +/* Only used by this extension for now; later needs to be moved earlier in glext.h */ +#include +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_EXT_color_matrix +#define GL_EXT_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRY * PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRY * PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRY * PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRY * PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRY * PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRY * PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRY * PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRY * PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRY * PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRY * PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRY * PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRY * PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRY * PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRY * PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRY * PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRY * PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRY * PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRY * PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRY * PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRY * PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRY * PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRY * PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRY * PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (GLenum, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* *, GLsizei, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRY * PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRY * PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRY * PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRY * PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRY * PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef GLboolean (APIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +/* GL type for representing NVIDIA "half" floating point type in host memory */ +/* Only used by this extension for now; later needs to be moved earlier in glext.h */ +typedef unsigned short GLhalfNV; +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/polymer/build/include/gtkbits.h b/polymer/build/include/gtkbits.h new file mode 100644 index 000000000..08581b9c3 --- /dev/null +++ b/polymer/build/include/gtkbits.h @@ -0,0 +1,15 @@ +#ifndef __gtkbits_h__ +#define __gtkbits_h__ + +extern void gtkbuild_init(int *argc, char ***argv); +extern void gtkbuild_exit(int r); +extern int gtkbuild_msgbox(char *name, char *msg); +extern int gtkbuild_ynbox(char *name, char *msg); +extern void gtkbuild_create_startwin(void); +extern void gtkbuild_settitle_startwin(const char *title); +extern void gtkbuild_puts_startwin(const char *str); +extern void gtkbuild_close_startwin(void); +extern void gtkbuild_update_startwin(void); +extern void *gtkbuild_get_app_icon(void); + +#endif diff --git a/polymer/build/include/kplib.h b/polymer/build/include/kplib.h new file mode 100644 index 000000000..20aaa6b6e --- /dev/null +++ b/polymer/build/include/kplib.h @@ -0,0 +1,21 @@ + //High-level (easy) picture loading function: +extern void kpzload (const char *, long *, long *, long *, long *); + //Low-level PNG/JPG functions: +extern void kpgetdim (const char *, long, long *, long *); +extern long kprender (const char *, long, long, long, long, long, long, long); + + //ZIP functions: +extern long kzaddstack (const char *); +extern void kzuninit (); +extern long kzopen (const char *); +extern long kzread (void *, long); +extern long kzfilelength (); +extern long kzseek (long, long); +extern long kztell (); +extern long kzgetc (); +extern long kzeof (); +extern void kzclose (); + +extern void kzfindfilestart (const char *); //pass wildcard string +extern long kzfindfile (char *); //you alloc buf, returns 1:found,0:~found + diff --git a/polymer/build/include/lzf.h b/polymer/build/include/lzf.h new file mode 100644 index 000000000..8538609ab --- /dev/null +++ b/polymer/build/include/lzf.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2000-2005 Marc Alexander Lehmann + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- + * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- + * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Alternatively, the contents of this file may be used under the terms of + * the GNU General Public License version 2 (the "GPL"), in which case the + * provisions of the GPL are applicable instead of the above. If you wish to + * allow the use of your version of this file only under the terms of the + * GPL and not to allow others to use your version of this file under the + * BSD license, indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by the GPL. If + * you do not delete the provisions above, a recipient may use your version + * of this file under either the BSD or the GPL. + */ + +#ifndef LZF_H +#define LZF_H + +/*********************************************************************** +** +** lzf -- an extremely fast/free compression/decompression-method +** http://liblzf.plan9.de/ +** +** This algorithm is believed to be patent-free. +** +***********************************************************************/ + +#define LZF_VERSION 0x0105 /* 1.5 */ + +/* + * Compress in_len bytes stored at the memory block starting at + * in_data and write the result to out_data, up to a maximum length + * of out_len bytes. + * + * If the output buffer is not large enough or any error occurs + * return 0, otherwise return the number of bytes used (which might + * be considerably larger than in_len, so it makes sense to always + * use out_len == in_len - 1), to ensure _some_ compression, and store + * the data uncompressed otherwise. + * + * lzf_compress might use different algorithms on different systems and + * even diferent runs, thus might result in different compressed strings + * depending on the phase of the moon or similar factors. However, all + * these strings are architecture-independent and will result in the + * original data when decompressed using lzf_decompress. + * + * The buffers must not be overlapping. + * + * If the option LZF_STATE_ARG is enabled, an extra argument must be + * supplied which is not reflected in this header file. Refer to lzfP.h + * and lzf_c.c. + * + */ +unsigned int +lzf_compress (const void *const in_data, unsigned int in_len, + void *out_data, unsigned int out_len); + +/* + * Decompress data compressed with some version of the lzf_compress + * function and stored at location in_data and length in_len. The result + * will be stored at out_data up to a maximum of out_len characters. + * + * If the output buffer is not large enough to hold the decompressed + * data, a 0 is returned and errno is set to E2BIG. Otherwise the number + * of decompressed bytes (i.e. the original length of the data) is + * returned. + * + * If an error in the compressed data is detected, a zero is returned and + * errno is set to EINVAL. + * + * This function is very fast, about as fast as a copying loop. + */ +unsigned int +lzf_decompress (const void *const in_data, unsigned int in_len, + void *out_data, unsigned int out_len); + +#endif + diff --git a/polymer/build/include/lzwnew.h b/polymer/build/include/lzwnew.h new file mode 100644 index 000000000..6606bb3a5 --- /dev/null +++ b/polymer/build/include/lzwnew.h @@ -0,0 +1,2 @@ +long lzwcompress (unsigned char *ucompbuf, long ucompleng, unsigned char *compbuf); +long lzwuncompress (unsigned char *compbuf, long compleng, unsigned char *ucompbuf, long ucompleng); diff --git a/polymer/build/include/md4.h b/polymer/build/include/md4.h new file mode 100644 index 000000000..27c2e3611 --- /dev/null +++ b/polymer/build/include/md4.h @@ -0,0 +1,38 @@ +/* MD4.H - header file for MD4C.C + Modified from original version published in RFC1320 by + Jonathon Fowler (jonof@edgenetwork.org) + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD4 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD4 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +/* MD4 context. */ +typedef struct { + unsigned long state[4]; /* state (ABCD) */ + unsigned long count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} MD4_CTX; + +void md4once(unsigned char *block, unsigned int len, unsigned char digest[16]); +void md4init(MD4_CTX *); +void md4block(MD4_CTX *, unsigned char *, unsigned int); +void md4finish(unsigned char [16], MD4_CTX *); diff --git a/polymer/build/include/mmulti.h b/polymer/build/include/mmulti.h new file mode 100644 index 000000000..1d3cb5bfe --- /dev/null +++ b/polymer/build/include/mmulti.h @@ -0,0 +1,29 @@ +// mmulti.h + +#ifndef __mmulti_h__ +#define __mmulti_h__ + +#define MAXMULTIPLAYERS 16 + +extern long myconnectindex, numplayers; +extern long connecthead, connectpoint2[MAXMULTIPLAYERS]; +extern char syncstate; + +long initmultiplayersparms(long argc, char **argv); +long initmultiplayerscycle(void); + +void initmultiplayers(long argc, char **argv, char damultioption, char dacomrateoption, char dapriority); +void setpackettimeout(long datimeoutcount, long daresendagaincount); +void uninitmultiplayers(void); +void sendlogon(void); +void sendlogoff(void); +long getoutputcirclesize(void); +void setsocket(short newsocket); +void sendpacket(long other, char *bufptr, long messleng); +long getpacket(long *other, char *bufptr); +void flushpackets(void); +void genericmultifunction(long other, char *bufptr, long messleng, long command); +long isvalidipaddress(char *st); + +#endif // __mmulti_h__ + diff --git a/polymer/build/include/mmultimsgs.h b/polymer/build/include/mmultimsgs.h new file mode 100644 index 000000000..350ac2ce1 --- /dev/null +++ b/polymer/build/include/mmultimsgs.h @@ -0,0 +1,65 @@ +#ifndef __MMULTIMSGS_H__ +#define __MMULTIMSGS_H__ + +/* + * Ok, so this header file defines the message bytes and outlines the basic + * message descriptions for out-of-band messages that are common to all games + * that utilize my net code. Once a game determines that it is indeed talking + * to another peer of the same genus, the rest is up to the game itself to + * decide, but for basic stuff, the interfaces will be identical. + * + * Why am I not choosing to implement all this engine-side? Because all the + * games are different and about the only thing they are guaranteed to use in + * common that I can be certain of is the services my net code will provide. + * So, since I can't code anything in particular with every Build game in mind, + * I'm putting handling all the game-visible messages into the game's domain. + * The engine will still handle its own internal messages because the game + * never sees them. Ever. + * + * CMDs are messages sent by a peer to another, and RSPs are the replies. + * + * The master of the network game, regardless if the eventual game is talking + * with a peer-to-peer design or not, shall enumerate each peer as it joins + * and the master will always assign itself peer number 0. This simplifies + * things all-round because each peer that joins automatically knows that + * id 0 is its master and it already knows the master's address. Technically + * every other peer who joins may get a sequential number for its id so maybe + * even transmitting the peer unique ids is unnecessary and we'd be easier + * just sending a number of players, but the less craftiness at this point + * in time, the better. + * + * -- Jonathon + */ + +#define MSGPROTOVER 0x00 + // 0x00 20031209 + + +#define MSG_CMD_GETGAMEINFO 0x10 + // char MSG_CMD_GETGAMEINFO + // char MSGPROTOVER +#define MSG_RSP_BADPROTO 0x11 + // char MSG_RSP_BADPROTO +#define MSG_RSP_NOGAME 0x12 + // char MSG_RSP_NOGAME + // char[8] gamename +#define MSG_RSP_GAMEINFO 0x13 + // char MSG_RSP_GAMEINFO + // char[8] gamename eg. DUKE3DSW/DUKE3D\x00\x00/DUKE3DAT + // ... other information particular to the game + + +#define MSG_CMD_JOINGAME 0x20 + // char MSG_CMD_JOINGAME +#define MSG_RSP_GAMEINPROG 0x21 + // char MSG_RSP_GAMEINPROG +#define MSG_RSP_JOINACCEPTED 0x22 + // char MSG_RSP_JOINACCEPTED + // short uniqueid + // char numtofollow + // short[numtofollow] peeruid + // ... other information particular to the game +#define MSG_RSP_GAMEFULL 0x23 + // char MSG_RSP_GAMEFULL + +#endif diff --git a/polymer/build/include/names.h b/polymer/build/include/names.h new file mode 100644 index 000000000..6373be4d8 --- /dev/null +++ b/polymer/build/include/names.h @@ -0,0 +1,49 @@ +//Be careful when changing this file - it is parsed by Editart and Build. +#define SWITCH1ON 15 +#define SLIME 34 +#define BACKGROUND 37 +#define KENPICTURE 48 +#define BUILDDISK 49 +#define SWITCH2ON 66 +#define SWITCH2OFF 69 +#define ALPHABET 73 +#define NO 74 +#define DEMOSIGN 75 +#define COIN 76 +#define COINSTACK 77 +#define GIFTBOX 78 +#define DIAMONDS 79 +#define EVILALGRAVE 83 +#define STATUSBAR 87 +#define DAYSKY 89 +#define WATERFOUNTAIN 90 +#define USEWATERFOUNTAIN 91 +#define NIGHTSKY 93 +#define BULLET 98 +#define BOMB 100 +#define CANNON 101 +#define GUNONBOTTOM 102 +#define BOMBEMITTER 103 +#define EXPLOSION 105 +#define SPLASH 106 +#define BROWNMONSTER 110 +#define SKELETON 113 +#define AL 114 +#define EVILAL 115 +#define PLAYER 120 +#define SWITCH3OFF 146 +#define SWITCH3ON 147 +#define AIRPLANE 148 +#define SPIRAL 149 +#define COMPASS 150 +#define FOOTPRINT 156 +#define STATUSBARFILL8 160 +#define STATUSBARFILL4 161 +#define BOUNCYMAT 162 +#define MIRROR 165 +#define FLOORMIRROR 166 +#define GRABBER 167 +#define GRABCANNON 168 +#define MISSILE 169 +#define LAUNCHER 171 +#define MIRRORLABEL 4000 diff --git a/polymer/build/include/osd.h b/polymer/build/include/osd.h new file mode 100644 index 000000000..58a2b15c8 --- /dev/null +++ b/polymer/build/include/osd.h @@ -0,0 +1,77 @@ +// On-screen display (ie. console) +// for the Build Engine +// by Jonathon Fowler (jonof@edgenetwk.com) + +#ifndef __osd_h__ +#define __osd_h__ + + +typedef struct { + int numparms; + const char *name; + const char **parms; + const char *raw; +} osdfuncparm_t; + +#define OSDCMD_OK 0 +#define OSDCMD_SHOWHELP 1 + +// initializes things +void OSD_Init(void); + +// sets the file to echo output to +void OSD_SetLogFile(char *fn); + +// sets the functions the OSD will call to interrogate the environment +void OSD_SetFunctions( + void (*drawchar)(int,int,char,int,int), + void (*drawstr)(int,int,char*,int,int,int), + void (*drawcursor)(int,int,int,int), + int (*colwidth)(int), + int (*rowheight)(int), + void (*clearbg)(int,int), + int (*gettime)(void), + void (*onshow)(int) + ); + +// sets the parameters for presenting the text +void OSD_SetParameters( + int promptshade, int promptpal, + int editshade, int editpal, + int textshade, int textpal + ); + +// sets the scancode for the key which activates the onscreen display +void OSD_CaptureKey(int sc); + +// handles keyboard input when capturing input. returns 0 if key was handled +// or the scancode if it should be handled by the game. +int OSD_HandleKey(int sc, int press); + +// handles the readjustment when screen resolution changes +void OSD_ResizeDisplay(int w,int h); + +// shows or hides the onscreen display +void OSD_ShowDisplay(int onf); + +// draw the osd to the screen +void OSD_Draw(void); + +// just like printf +void OSD_Printf(const char *fmt, ...); +#define printOSD OSD_Printf + +// executes buffered commands +void OSD_DispatchQueued(void); + +// executes a string +int OSD_Dispatch(const char *cmd); + +// registers a function +// name = name of the function +// help = a short help string +// func = the entry point to the function +int OSD_RegisterFunction(const char *name, const char *help, int (*func)(const osdfuncparm_t*)); + +#endif // __osd_h__ + diff --git a/polymer/build/include/osxbits.h b/polymer/build/include/osxbits.h new file mode 100644 index 000000000..e990e5404 --- /dev/null +++ b/polymer/build/include/osxbits.h @@ -0,0 +1,7 @@ +#ifndef __osxbits_h__ +#define __osxbits_h__ + +int osx_msgbox(char *name, char *msg); +int osx_ynbox(char *name, char *msg); + +#endif \ No newline at end of file diff --git a/polymer/build/include/pragmas.h b/polymer/build/include/pragmas.h new file mode 100644 index 000000000..df51e0f0c --- /dev/null +++ b/polymer/build/include/pragmas.h @@ -0,0 +1,3704 @@ +// This file has been modified from Ken Silverman's original release +// by Jonathon Fowler (jonof@edgenetwk.com) + + +#ifndef __pragmas_h__ +#define __pragmas_h__ + +extern long dmval; + +#if defined(NOASM) + +// +// Generic C +// + +#define qw(x) ((int64)(x)) // quadword cast +#define dw(x) ((long)(x)) // doubleword cast +#define wo(x) ((short)(x)) // word cast +#define by(x) ((char)(x)) // byte cast + +#define _scaler(a) \ +static inline long mulscale##a(long eax, long edx) \ +{ \ + return dw((qw(eax) * qw(edx)) >> a); \ +} \ +\ +static inline long divscale##a(long eax, long ebx) \ +{ \ + return dw((qw(eax) << a) / qw(ebx)); \ +} \ +\ +static inline long dmulscale##a(long eax, long edx, long esi, long edi) \ +{ \ + return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> a); \ +} \ +\ +static inline long tmulscale##a(long eax, long edx, long ebx, long ecx, long esi, long edi) \ +{ \ + return dw(((qw(eax) * qw(edx)) + (qw(ebx) * qw(ecx)) + (qw(esi) * qw(edi))) >> a); \ +} \ + +_scaler(1) _scaler(2) _scaler(3) _scaler(4) +_scaler(5) _scaler(6) _scaler(7) _scaler(8) +_scaler(9) _scaler(10) _scaler(11) _scaler(12) +_scaler(13) _scaler(14) _scaler(15) _scaler(16) +_scaler(17) _scaler(18) _scaler(19) _scaler(20) +_scaler(21) _scaler(22) _scaler(23) _scaler(24) +_scaler(25) _scaler(26) _scaler(27) _scaler(28) +_scaler(29) _scaler(30) _scaler(31) _scaler(32) + +static inline void swapchar(void* a, void* b) { char t = *((char*)b); *((char*)b) = *((char*)a); *((char*)a) = t; } +static inline void swapchar2(void* a, void* b, long s) { swapchar(a,b); swapchar((char*)a+1,(char*)b+s); } +static inline void swapshort(void* a, void* b) { short t = *((short*)b); *((short*)b) = *((short*)a); *((short*)a) = t; } +static inline void swaplong(void* a, void* b) { long t = *((long*)b); *((long*)b) = *((long*)a); *((long*)a) = t; } +static inline void swap64bit(void* a, void* b) { int64 t = *((int64*)b); *((int64*)b) = *((int64*)a); *((int64*)a) = t; } + +static inline char readpixel(void* s) { return (*((char*)(s))); } +static inline void drawpixel(void* s, char a) { *((char*)(s)) = a; } +static inline void drawpixels(void* s, short a) { *((short*)(s)) = a; } +static inline void drawpixelses(void* s, long a) { *((long*)(s)) = a; } + +static inline long mul3(long a) { return (a<<1)+a; } +static inline long mul5(long a) { return (a<<2)+a; } +static inline long mul9(long a) { return (a<<3)+a; } + +static inline long divmod(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a%_b; return _a/_b; } +static inline long moddiv(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a/_b; return _a%_b; } + +static inline long klabs(long a) { if (a < 0) return -a; return a; } +static inline long ksgn(long a) { if (a > 0) return 1; if (a < 0) return -1; return 0; } + +static inline long umin(long a, long b) { if ((unsigned long)a < (unsigned long)b) return a; return b; } +static inline long umax(long a, long b) { if ((unsigned long)a < (unsigned long)b) return b; return a; } +static inline long kmin(long a, long b) { if ((signed long)a < (signed long)b) return a; return b; } +static inline long kmax(long a, long b) { if ((signed long)a < (signed long)b) return b; return a; } + +static inline long sqr(long eax) { return (eax) * (eax); } +static inline long scale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) / qw(ecx)); } +static inline long mulscale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) >> by(ecx)); } +static inline long divscale(long eax, long ebx, long ecx) { return dw((qw(eax) << by(ecx)) / qw(ebx)); } +static inline long dmulscale(long eax, long edx, long esi, long edi, long ecx) { return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(ecx)); } + +static inline long boundmulscale(long a, long d, long c) +{ // courtesy of Ken + int64 p; + p = (((int64)a)*((int64)d))>>c; + if (p >= longlong(2147483647)) p = longlong(2147483647); + if (p < longlong(-2147483648)) p = longlong(-2147483648); + return((long)p); +} + +#undef qw +#undef dw +#undef wo +#undef by +#undef _scaler + +void qinterpolatedown16 (long bufptr, long num, long val, long add); +void qinterpolatedown16short (long bufptr, long num, long val, long add); + +void clearbuf(void* d, long c, long a); +void copybuf(void* s, void* d, long c); +void swapbuf4(void* a, void* b, long c); + +void clearbufbyte(void *D, long c, long a); +void copybufbyte(void *S, void *D, long c); +void copybufreverse(void *S, void *D, long c); + + +#elif defined(__GNUC__) && defined(__i386__) // NOASM + +// +// GCC Inline Assembler version +// + +//{{{ + +#ifndef UNDERSCORES +#define _DMVAL "dmval" +#else +#define _DMVAL "_dmval" +#endif + + +// maybe one day I'll make these into macros +long boundmulscale(long a, long b, long c); +void clearbufbyte(void *D, long c, long a); +void copybufbyte(void *S, void *D, long c); +void copybufreverse(void *S, void *D, long c); + + +#ifdef NO_GCC_BUILTINS +#define sqr(a) \ + ({ long __a=(a); \ + __asm__ __volatile__ ("imull %0, %0" \ + : "=q" (__a) \ + : "0" (__a) \ + : "cc"); \ + __a; }) +#else +#define sqr(a) __builtin_sqr(a) +#endif + +#define scale(a,d,c) \ + ({ long __a=(a), __d=(d), __c=(c); \ + __asm__ __volatile__ ("imull %%edx; idivl %%ecx" \ + : "=a" (__a), "=d" (__d) \ + : "0" (__a), "1" (__d), "c" (__c) : "cc"); \ + __a; }) + +#define mulscale(a,d,c) \ + ({ long __a=(a), __d=(d), __c=(c); \ + __asm__ __volatile__ ("imull %%edx; shrdl %%cl, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d), "c" (__c) : "cc"); \ + __a; }) +#define mulscale1(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $1, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale2(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $2, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale3(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $3, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale4(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $4, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale5(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $5, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale6(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $6, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale7(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $7, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale8(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $8, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale9(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $9, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale10(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $10, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale11(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $11, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale12(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $12, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale13(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $13, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale14(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $14, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale15(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $15, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale16(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $16, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale17(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $17, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale18(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $18, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale19(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $19, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale20(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $20, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale21(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $21, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale22(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $22, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale23(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $23, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale24(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $24, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale25(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $25, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale26(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $26, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale27(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $27, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale28(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $28, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale29(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $29, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale30(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $30, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale31(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $31, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __a; }) +#define mulscale32(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx" \ + : "=a" (__a), "=d" (__d) \ + : "a" (__a), "d" (__d) : "cc"); \ + __d; }) + +#define dmulscale(a,d,S,D,c) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D), __c=(c); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl %%cl, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D), "c" (__c) : "ebx", "cc"); \ + __a; }) +#define dmulscale1(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $1, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale2(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $2, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale3(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $3, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale4(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $4, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale5(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $5, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale6(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $6, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale7(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $7, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale8(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $8, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale9(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $9, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale10(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $10, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale11(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $11, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale12(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $12, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale13(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $13, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale14(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $14, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale15(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $15, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale16(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $16, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale17(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $17, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale18(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $18, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale19(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $19, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale20(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $20, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale21(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $21, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale22(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $22, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale23(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $23, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale24(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $24, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale25(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $25, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale26(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $26, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale27(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $27, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale28(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $28, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale29(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $29, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale30(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $30, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale31(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx; shrdl $31, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __a; }) +#define dmulscale32(a,d,S,D) \ + ({ long __a=(a), __d=(d), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; movl %%eax, %%ebx; movl %%esi, %%eax; movl %%edx, %%esi; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%esi, %%edx" \ + : "=a" (__a), "=d" (__d), "=S" (__S) \ + : "a" (__a), "d" (__d), "S" (__S), "D" (__D) : "ebx", "cc"); \ + __d; }) + +#define tmulscale1(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $1, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale2(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $2, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale3(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $3, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale4(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $4, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale5(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $5, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale6(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $6, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale7(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $7, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale8(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $8, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale9(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $9, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale10(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $10, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale11(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $11, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale12(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $12, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale13(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $13, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale14(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $14, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale15(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $15, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale16(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $16, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale17(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $17, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale18(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $18, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale19(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $19, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale20(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $20, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale21(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $21, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale22(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $22, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale23(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $23, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale24(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $24, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale25(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $25, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale26(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $26, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale27(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $27, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale28(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $28, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale29(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $29, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale30(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $30, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale31(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx; shrdl $31, %%edx, %%eax" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __a; }) +#define tmulscale32(a,d,b,c,S,D) \ + ({ long __a=(a), __d=(d), __b=(b), __c=(c), __S=(S), __D=(D); \ + __asm__ __volatile__ ("imull %%edx; xchgl %%ebx, %%eax; xchgl %%ecx, %%edx; " \ + "imull %%edx; addl %%eax, %%ebx; adcl %%edx, %%ecx; movl %%esi, %%eax; " \ + "imull %%edi; addl %%ebx, %%eax; adcl %%ecx, %%edx" \ + : "=a" (__a), "=d" (__d), "=b" (__b), "=c" (__c) \ + : "a" (__a), "d" (__d), "b" (__b), "c" (__c), "S" (__S), "D" (__D) : "cc"); \ + __d; }) + +#define divscale(a,b,c) \ + ({ long __a=(a), __b=(b), __c=(c); \ + __asm__ __volatile__ ("movl %%eax, %%edx; shll %%cl, %%eax; negb %%cl; sarl %%cl, %%edx; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "c" (__c), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale1(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("addl %%eax, %%eax; sbbl %%edx, %%edx; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale2(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $30, %%edx; leal (,%%eax,4), %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale3(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $29, %%edx; leal (,%%eax,8), %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale4(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $28, %%edx; shll $4, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale5(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $27, %%edx; shll $5, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale6(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $26, %%edx; shll $6, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale7(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $25, %%edx; shll $7, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale8(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $24, %%edx; shll $8, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale9(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $23, %%edx; shll $9, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale10(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $22, %%edx; shll $10, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale11(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $21, %%edx; shll $11, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale12(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $20, %%edx; shll $12, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale13(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $19, %%edx; shll $13, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale14(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $18, %%edx; shll $14, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale15(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $17, %%edx; shll $15, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale16(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $16, %%edx; shll $16, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale17(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $15, %%edx; shll $17, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale18(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $14, %%edx; shll $18, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale19(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $13, %%edx; shll $19, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale20(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $12, %%edx; shll $20, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale21(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $11, %%edx; shll $21, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale22(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $10, %%edx; shll $22, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale23(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $9, %%edx; shll $23, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale24(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $8, %%edx; shll $24, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale25(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $7, %%edx; shll $25, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale26(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $6, %%edx; shll $26, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale27(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $5, %%edx; shll $27, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale28(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $4, %%edx; shll $28, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale29(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $3, %%edx; shll $29, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale30(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $2, %%edx; shll $30, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale31(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("movl %%eax, %%edx; sarl $1, %%edx; shll $31, %%eax; idivl %%ebx" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "edx", "cc"); \ + __a; }) +#define divscale32(d,b) \ + ({ long __d=(d), __b=(b), __r; \ + __asm__ __volatile__ ("xorl %%eax, %%eax; idivl %%ebx" \ + : "=a" (__r), "=d" (__d) : "d" (__d), "b" (__b) : "cc"); \ + __r; }) + +#define readpixel(D) \ + ({ void *__D=(D); long __a; \ + __asm__ __volatile__ ("movb (%%edi), %%al" \ + : "=a" (__a): "D" (__D) : "cc"); \ + __a; }) +#define drawpixel(D,a) \ + ({ void *__D=(D); long __a=(a); \ + __asm__ __volatile__ ("movb %%al, (%%edi)" \ + : : "D" (__D), "a" (__a) : "memory", "cc"); \ + 0; }) +#define drawpixels(D,a) \ + ({ void *__D=(D); long __a=(a); \ + __asm__ __volatile__ ("movw %%ax, (%%edi)" \ + : : "D" (__D), "a" (__a) : "memory", "cc"); \ + 0; }) +#define drawpixelses(D,a) \ + ({ void *__D=(D); long __a=(a); \ + __asm__ __volatile__ ("movl %%eax, (%%edi)" \ + : : "D" (__D), "a" (__a) : "memory", "cc"); \ + 0; }) +#define clearbuf(D,c,a) \ + ({ void *__D=(D); long __c=(c), __a=(a); \ + __asm__ __volatile__ ("rep; stosl" \ + : "=&D" (__D), "=&c" (__c) : "0" (__D), "1" (__c), "a" (__a) : "memory", "cc"); \ + 0; }) +#define copybuf(S,D,c) \ + ({ void *__S=(S), *__D=(D); long __c=(c); \ + __asm__ __volatile__ ("rep; movsl" \ + : "=&S" (__S), "=&D" (__D), "=&c" (__c) : "0" (__S), "1" (__D), "2" (__c) : "memory", "cc"); \ + 0; }) + +#define mul3(a) \ + ({ long __a=(a), __r; \ + __asm__ __volatile__ ("lea (%1,%1,2), %0" \ + : "=r" (__r) : "0" (__a) : "cc"); \ + __r; }) +#define mul5(a) \ + ({ long __a=(a), __r; \ + __asm__ __volatile__ ("lea (%1,%1,4), %0" \ + : "=r" (__r) : "0" (__a) : "cc"); \ + __r; }) +#define mul9(a) \ + ({ long __a=(a), __r; \ + __asm__ __volatile__ ("lea (%1,%1,8), %0" \ + : "=r" (__r) : "0" (__a) : "cc"); \ + __r; }) + +//returns eax/ebx, dmval = eax%edx; +#define divmod(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("xorl %%edx, %%edx; divl %%ebx; movl %%edx, "_DMVAL \ + : "+a" (__a) : "b" (__b) : "edx", "memory", "cc"); \ + __a; }) +//returns eax%ebx, dmval = eax/edx; +#define moddiv(a,b) \ + ({ long __a=(a), __b=(b), __d; \ + __asm__ __volatile__ ("xorl %%edx, %%edx; divl %%ebx; movl %%eax, "_DMVAL \ + : "=d" (__d) : "a" (__a), "b" (__b) : "eax", "memory", "cc"); \ + __d; }) + +#define klabs(a) \ + ({ long __a=(a); \ + __asm__ __volatile__ ("testl %%eax, %%eax; jns 0f; negl %%eax; 0:" \ + : "=a" (__a) : "a" (__a) : "cc"); \ + __a; }) +#define ksgn(b) \ + ({ long __b=(b), __r; \ + __asm__ __volatile__ ("addl %%ebx, %%ebx; sbbl %%eax, %%eax; cmpl %%ebx, %%eax; adcb $0, %%al" \ + : "=a" (__r) : "b" (__b) : "cc"); \ + __r; }) + +#define umin(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("subl %%ebx, %%eax; sbbl %%ecx, %%ecx; andl %%ecx, %%eax; addl %%ebx, %%eax" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "ecx", "cc"); \ + __a; }) +#define umax(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("subl %%ebx, %%eax; sbbl %%ecx, %%ecx; xorl $0xffffffff, %%ecx; andl %%ecx, %%eax; addl %%ebx, %%eax" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "ecx", "cc"); \ + __a; }) + +#define kmin(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("cmpl %%ebx, %%eax; jl 0f; movl %%ebx, %%eax; 0:" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "cc"); \ + __a; }) +#define kmax(a,b) \ + ({ long __a=(a), __b=(b); \ + __asm__ __volatile__ ("cmpl %%ebx, %%eax; jg 0f; movl %%ebx, %%eax; 0:" \ + : "=a" (__a) : "a" (__a), "b" (__b) : "cc"); \ + __a; }) + +#define swapchar(a,b) \ + ({ void *__a=(a), *__b=(b); \ + __asm__ __volatile__ ("movb (%%eax), %%cl; movb (%%ebx), %%ch; movb %%cl, (%%ebx); movb %%ch, (%%eax)" \ + : : "a" (__a), "b" (__b) : "ecx", "memory", "cc"); \ + 0; }) +#define swapshort(a,b) \ + ({ void *__a=(a), *__b=(b); \ + __asm__ __volatile__ ("movw (%%eax), %%cx; movw (%%ebx), %%dx; movw %%cx, (%%ebx); movw %%dx, (%%eax)" \ + : : "a" (__a), "b" (__b) : "ecx", "edx", "memory", "cc"); \ + 0; }) +#define swaplong(a,b) \ + ({ void *__a=(a), *__b=(b); \ + __asm__ __volatile__ ("movl (%%eax), %%ecx; movl (%%ebx), %%edx; movl %%ecx, (%%ebx); movl %%edx, (%%eax)" \ + : : "a" (__a), "b" (__b) : "ecx", "edx", "memory", "cc"); \ + 0; }) +#define swapbuf4(a,b,c) \ + ({ void *__a=(a), *__b=(b); long __c=(c); \ + __asm__ __volatile__ ("0: movl (%%eax), %%esi; movl (%%ebx), %%edi; movl %%esi, (%%ebx); " \ + "movl %%edi, (%%eax); addl $4, %%eax; addl $4, %%ebx; decl %%ecx; jnz 0b" \ + : : "a" (__a), "b" (__b), "c" (__c) : "esi", "edi", "memory", "cc"); \ + 0; }) +#define swap64bit(a,b) \ + ({ void *__a=(a), *__b=(b); \ + __asm__ __volatile__ ("movl (%%eax), %%ecx; movl (%%ebx), %%edx; movl %%ecx, (%%ebx); " \ + "movl 4(%%eax), %%ecx; movl %%edx, (%%eax); movl 4(%%ebx), %%edx; " \ + "movl %%ecx, 4(%%ebx); movl %%edx, 4(%%eax)" \ + : : "a" (__a), "b" (__b) : "ecx", "edx", "memory", "cc"); \ + 0; }) + +//swapchar2(ptr1,ptr2,xsiz); is the same as: +//swapchar(ptr1,ptr2); swapchar(ptr1+1,ptr2+xsiz); +#define swapchar2(a,b,S) \ + ({ void *__a=(a), *__b=(b); long __S=(S); \ + __asm__ __volatile__ ("addl %%ebx, %%esi; movw (%%eax), %%cx; movb (%%ebx), %%dl; " \ + "movb %%cl, (%%ebx); movb (%%esi), %%dh; movb %%ch, (%%esi); " \ + "movw %%dx, (%%eax)" \ + : : "a" (__a), "b" (__b), "S" (__S) : "ecx", "edx", "memory", "cc"); \ + 0; }) + + +#define qinterpolatedown16(a,c,d,S) \ + ({ void *__a=(void*)(a); long __c=(c), __d=(d), __S=(S); \ + __asm__ __volatile__ ("movl %%ecx, %%ebx; shrl $1, %%ecx; jz 1f; " \ + "0: leal (%%edx,%%esi,), %%edi; sarl $16, %%edx; movl %%edx, (%%eax); " \ + "leal (%%edi,%%esi,), %%edx; sarl $16, %%edi; movl %%edi, 4(%%eax); " \ + "addl $8, %%eax; decl %%ecx; jnz 0b; testl $1, %%ebx; jz 2f; " \ + "1: sarl $16, %%edx; movl %%edx, (%%eax); 2:" \ + : "=a" (__a), "=c" (__c), "=d" (__d) : "a" (__a), "c" (__c), "d" (__d), "S" (__S) \ + : "ebx", "edi", "memory", "cc"); \ + 0; }) + +#define qinterpolatedown16short(a,c,d,S) \ + ({ void *__a=(void*)(a); long __c=(c), __d=(d), __S=(S); \ + __asm__ __volatile__ ("testl %%ecx, %%ecx; jz 3f; testb $2, %%al; jz 0f; movl %%edx, %%ebx; " \ + "sarl $16, %%ebx; movw %%bx, (%%eax); addl %%esi, %%edx; addl $2, %%eax; " \ + "decl %%ecx; jz 3f; " \ + "0: subl $2, %%ecx; jc 2f; " \ + "1: movl %%edx, %%ebx; addl %%esi, %%edx; sarl $16, %%ebx; movl %%edx, %%edi; " \ + "andl $0xffff0000, %%edi; addl %%esi, %%edx; addl %%edi, %%ebx; " \ + "movl %%ebx, (%%eax); addl $4, %%eax; subl $2, %%ecx; jnc 1b; testb $1, %%cl; " \ + "jz 3f; " \ + "2: movl %%edx, %%ebx; sarl $16, %%ebx; movw %%bx, (%%eax); 3:" \ + : "=a" (__a), "=c" (__c), "=d" (__d) : "a" (__a), "c" (__c), "d" (__d), "S" (__S) \ + : "ebx", "edi", "memory", "cc"); \ + 0; }) + + +//}}} + +#elif defined(__WATCOMC__) // __GNUC__ && __i386__ + +// +// Watcom C inline assembler +// + +//{{{ +#pragma aux sqr =\ + "imul eax, eax",\ + parm nomemory [eax]\ + modify exact [eax]\ + value [eax] +long sqr(long); + +#pragma aux scale =\ + "imul edx",\ + "idiv ecx",\ + parm nomemory [eax][edx][ecx]\ + modify exact [eax edx] +long scale(long,long,long); + +#pragma aux mulscale =\ + "imul edx",\ + "shrd eax, edx, cl",\ + parm nomemory [eax][edx][ecx]\ + modify exact [eax edx] +long mulscale(long,long,long); + +#pragma aux mulscale1 =\ + "imul edx",\ + "shrd eax, edx, 1",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale1(long,long); + +#pragma aux mulscale2 =\ + "imul edx",\ + "shrd eax, edx, 2",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale2(long,long); + +#pragma aux mulscale3 =\ + "imul edx",\ + "shrd eax, edx, 3",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale3(long,long); + +#pragma aux mulscale4 =\ + "imul edx",\ + "shrd eax, edx, 4",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale4(long,long); + +#pragma aux mulscale5 =\ + "imul edx",\ + "shrd eax, edx, 5",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale5(long,long); + +#pragma aux mulscale6 =\ + "imul edx",\ + "shrd eax, edx, 6",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale6(long,long); + +#pragma aux mulscale7 =\ + "imul edx",\ + "shrd eax, edx, 7",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale7(long,long); + +#pragma aux mulscale8 =\ + "imul edx",\ + "shrd eax, edx, 8",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale8(long,long); + +#pragma aux mulscale9 =\ + "imul edx",\ + "shrd eax, edx, 9",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale9(long,long); + +#pragma aux mulscale10 =\ + "imul edx",\ + "shrd eax, edx, 10",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale10(long,long); + +#pragma aux mulscale11 =\ + "imul edx",\ + "shrd eax, edx, 11",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale11(long,long); + +#pragma aux mulscale12 =\ + "imul edx",\ + "shrd eax, edx, 12",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale12(long,long); + +#pragma aux mulscale13 =\ + "imul edx",\ + "shrd eax, edx, 13",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale13(long,long); + +#pragma aux mulscale14 =\ + "imul edx",\ + "shrd eax, edx, 14",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale14(long,long); + +#pragma aux mulscale15 =\ + "imul edx",\ + "shrd eax, edx, 15",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale15(long,long); + +#pragma aux mulscale16 =\ + "imul edx",\ + "shrd eax, edx, 16",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale16(long,long); + +#pragma aux mulscale17 =\ + "imul edx",\ + "shrd eax, edx, 17",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale17(long,long); + +#pragma aux mulscale18 =\ + "imul edx",\ + "shrd eax, edx, 18",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale18(long,long); + +#pragma aux mulscale19 =\ + "imul edx",\ + "shrd eax, edx, 19",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale19(long,long); + +#pragma aux mulscale20 =\ + "imul edx",\ + "shrd eax, edx, 20",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale20(long,long); + +#pragma aux mulscale21 =\ + "imul edx",\ + "shrd eax, edx, 21",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale21(long,long); + +#pragma aux mulscale22 =\ + "imul edx",\ + "shrd eax, edx, 22",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale22(long,long); + +#pragma aux mulscale23 =\ + "imul edx",\ + "shrd eax, edx, 23",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale23(long,long); + +#pragma aux mulscale24 =\ + "imul edx",\ + "shrd eax, edx, 24",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale24(long,long); + +#pragma aux mulscale25 =\ + "imul edx",\ + "shrd eax, edx, 25",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale25(long,long); + +#pragma aux mulscale26 =\ + "imul edx",\ + "shrd eax, edx, 26",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale26(long,long); + +#pragma aux mulscale27 =\ + "imul edx",\ + "shrd eax, edx, 27",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale27(long,long); + +#pragma aux mulscale28 =\ + "imul edx",\ + "shrd eax, edx, 28",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale28(long,long); + +#pragma aux mulscale29 =\ + "imul edx",\ + "shrd eax, edx, 29",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale29(long,long); + +#pragma aux mulscale30 =\ + "imul edx",\ + "shrd eax, edx, 30",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale30(long,long); + +#pragma aux mulscale31 =\ + "imul edx",\ + "shrd eax, edx, 31",\ + parm nomemory [eax][edx]\ + modify exact [eax edx] +long mulscale31(long,long); + +#pragma aux mulscale32 =\ + "imul edx",\ + parm nomemory [eax][edx]\ + modify exact [eax edx]\ + value [edx] +long mulscale32(long,long); + +#pragma aux dmulscale =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, cl",\ + parm nomemory [eax][edx][esi][edi][ecx]\ + modify exact [eax ebx edx esi] +long dmulscale(long,long,long,long,long); + +#pragma aux dmulscale1 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 1",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale1(long,long,long,long); + +#pragma aux dmulscale2 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 2",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale2(long,long,long,long); + +#pragma aux dmulscale3 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 3",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale3(long,long,long,long); + +#pragma aux dmulscale4 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 4",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale4(long,long,long,long); + +#pragma aux dmulscale5 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 5",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale5(long,long,long,long); + +#pragma aux dmulscale6 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 6",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale6(long,long,long,long); + +#pragma aux dmulscale7 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 7",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale7(long,long,long,long); + +#pragma aux dmulscale8 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 8",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale8(long,long,long,long); + +#pragma aux dmulscale9 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 9",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale9(long,long,long,long); + +#pragma aux dmulscale10 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 10",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale10(long,long,long,long); + +#pragma aux dmulscale11 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 11",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale11(long,long,long,long); + +#pragma aux dmulscale12 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 12",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale12(long,long,long,long); + +#pragma aux dmulscale13 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 13",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale13(long,long,long,long); + +#pragma aux dmulscale14 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 14",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale14(long,long,long,long); + +#pragma aux dmulscale15 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 15",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale15(long,long,long,long); + +#pragma aux dmulscale16 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 16",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale16(long,long,long,long); + +#pragma aux dmulscale17 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 17",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale17(long,long,long,long); + +#pragma aux dmulscale18 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 18",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale18(long,long,long,long); + +#pragma aux dmulscale19 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 19",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale19(long,long,long,long); + +#pragma aux dmulscale20 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 20",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale20(long,long,long,long); + +#pragma aux dmulscale21 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 21",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale21(long,long,long,long); + +#pragma aux dmulscale22 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 22",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale22(long,long,long,long); + +#pragma aux dmulscale23 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 23",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale23(long,long,long,long); + +#pragma aux dmulscale24 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 24",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale24(long,long,long,long); + +#pragma aux dmulscale25 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 25",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale25(long,long,long,long); + +#pragma aux dmulscale26 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 26",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale26(long,long,long,long); + +#pragma aux dmulscale27 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 27",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale27(long,long,long,long); + +#pragma aux dmulscale28 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 28",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale28(long,long,long,long); + +#pragma aux dmulscale29 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 29",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale29(long,long,long,long); + +#pragma aux dmulscale30 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 30",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale30(long,long,long,long); + +#pragma aux dmulscale31 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + "shrd eax, edx, 31",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi] +long dmulscale31(long,long,long,long); + +#pragma aux dmulscale32 =\ + "imul edx",\ + "mov ebx, eax",\ + "mov eax, esi",\ + "mov esi, edx",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, esi",\ + parm nomemory [eax][edx][esi][edi]\ + modify exact [eax ebx edx esi]\ + value [edx] +long dmulscale32(long,long,long,long); + +#pragma aux tmulscale1 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 1",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale1(long,long,long,long,long,long); + +#pragma aux tmulscale2 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 2",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale2(long,long,long,long,long,long); + +#pragma aux tmulscale3 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 3",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale3(long,long,long,long,long,long); + +#pragma aux tmulscale4 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 4",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale4(long,long,long,long,long,long); + +#pragma aux tmulscale5 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 5",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale5(long,long,long,long,long,long); + +#pragma aux tmulscale6 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 6",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale6(long,long,long,long,long,long); + +#pragma aux tmulscale7 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 7",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale7(long,long,long,long,long,long); + +#pragma aux tmulscale8 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 8",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale8(long,long,long,long,long,long); + +#pragma aux tmulscale9 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 9",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale9(long,long,long,long,long,long); + +#pragma aux tmulscale10 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 10",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale10(long,long,long,long,long,long); + +#pragma aux tmulscale11 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 11",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale11(long,long,long,long,long,long); + +#pragma aux tmulscale12 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 12",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale12(long,long,long,long,long,long); + +#pragma aux tmulscale13 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 13",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale13(long,long,long,long,long,long); + +#pragma aux tmulscale14 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 14",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale14(long,long,long,long,long,long); + +#pragma aux tmulscale15 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 15",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale15(long,long,long,long,long,long); + +#pragma aux tmulscale16 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 16",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale16(long,long,long,long,long,long); + +#pragma aux tmulscale17 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 17",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale17(long,long,long,long,long,long); + +#pragma aux tmulscale18 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 18",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale18(long,long,long,long,long,long); + +#pragma aux tmulscale19 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 19",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale19(long,long,long,long,long,long); + +#pragma aux tmulscale20 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 20",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale20(long,long,long,long,long,long); + +#pragma aux tmulscale21 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 21",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale21(long,long,long,long,long,long); + +#pragma aux tmulscale22 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 22",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale22(long,long,long,long,long,long); + +#pragma aux tmulscale23 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 23",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale23(long,long,long,long,long,long); + +#pragma aux tmulscale24 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 24",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale24(long,long,long,long,long,long); + +#pragma aux tmulscale25 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 25",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale25(long,long,long,long,long,long); + +#pragma aux tmulscale26 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 26",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale26(long,long,long,long,long,long); + +#pragma aux tmulscale27 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 27",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale27(long,long,long,long,long,long); + +#pragma aux tmulscale28 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 28",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale28(long,long,long,long,long,long); + +#pragma aux tmulscale29 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 29",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale29(long,long,long,long,long,long); + +#pragma aux tmulscale30 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 30",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale30(long,long,long,long,long,long); + +#pragma aux tmulscale31 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + "shrd eax, edx, 31",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx] +long tmulscale31(long,long,long,long,long,long); + +#pragma aux tmulscale32 =\ + "imul edx",\ + "xchg eax, ebx",\ + "xchg edx, ecx",\ + "imul edx",\ + "add ebx, eax",\ + "adc ecx, edx",\ + "mov eax, esi",\ + "imul edi",\ + "add eax, ebx",\ + "adc edx, ecx",\ + parm nomemory [eax][edx][ebx][ecx][esi][edi]\ + modify exact [eax ebx ecx edx]\ + value [edx] +long tmulscale32(long,long,long,long,long,long); + +#pragma aux boundmulscale =\ + "imul ebx",\ + "mov ebx, edx",\ + "shrd eax, edx, cl",\ + "sar edx, cl",\ + "xor edx, eax",\ + "js checkit",\ + "xor edx, eax",\ + "jz skipboundit",\ + "cmp edx, 0xffffffff",\ + "je skipboundit",\ + "checkit:",\ + "mov eax, ebx",\ + "sar eax, 31",\ + "xor eax, 0x7fffffff",\ + "skipboundit:",\ + parm nomemory [eax][ebx][ecx]\ + modify exact [eax ebx edx] +long boundmulscale(long,long,long); + +#pragma aux divscale =\ + "mov edx, eax",\ + "shl eax, cl",\ + "neg cl",\ + "sar edx, cl",\ + "idiv ebx",\ + parm nomemory [eax][ebx][ecx]\ + modify exact [eax ecx edx] +long divscale(long,long,long); + +#pragma aux divscale1 =\ + "add eax, eax",\ + "sbb edx, edx",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale1(long,long); + +#pragma aux divscale2 =\ + "mov edx, eax",\ + "sar edx, 30",\ + "lea eax, [eax*4]",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale2(long,long); + +#pragma aux divscale3 =\ + "mov edx, eax",\ + "sar edx, 29",\ + "lea eax, [eax*8]",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale3(long,long); + +#pragma aux divscale4 =\ + "mov edx, eax",\ + "sar edx, 28",\ + "shl eax, 4",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale4(long,long); + +#pragma aux divscale5 =\ + "mov edx, eax",\ + "sar edx, 27",\ + "shl eax, 5",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale5(long,long); + +#pragma aux divscale6 =\ + "mov edx, eax",\ + "sar edx, 26",\ + "shl eax, 6",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale6(long,long); + +#pragma aux divscale7 =\ + "mov edx, eax",\ + "sar edx, 25",\ + "shl eax, 7",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale7(long,long); + +#pragma aux divscale8 =\ + "mov edx, eax",\ + "sar edx, 24",\ + "shl eax, 8",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale8(long,long); + +#pragma aux divscale9 =\ + "mov edx, eax",\ + "sar edx, 23",\ + "shl eax, 9",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale9(long,long); + +#pragma aux divscale10 =\ + "mov edx, eax",\ + "sar edx, 22",\ + "shl eax, 10",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale10(long,long); + +#pragma aux divscale11 =\ + "mov edx, eax",\ + "sar edx, 21",\ + "shl eax, 11",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale11(long,long); + +#pragma aux divscale12 =\ + "mov edx, eax",\ + "sar edx, 20",\ + "shl eax, 12",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale12(long,long); + +#pragma aux divscale13 =\ + "mov edx, eax",\ + "sar edx, 19",\ + "shl eax, 13",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale13(long,long); + +#pragma aux divscale14 =\ + "mov edx, eax",\ + "sar edx, 18",\ + "shl eax, 14",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale14(long,long); + +#pragma aux divscale15 =\ + "mov edx, eax",\ + "sar edx, 17",\ + "shl eax, 15",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale15(long,long); + +#pragma aux divscale16 =\ + "mov edx, eax",\ + "sar edx, 16",\ + "shl eax, 16",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale16(long,long); + +#pragma aux divscale17 =\ + "mov edx, eax",\ + "sar edx, 15",\ + "shl eax, 17",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale17(long,long); + +#pragma aux divscale18 =\ + "mov edx, eax",\ + "sar edx, 14",\ + "shl eax, 18",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale18(long,long); + +#pragma aux divscale19 =\ + "mov edx, eax",\ + "sar edx, 13",\ + "shl eax, 19",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale19(long,long); + +#pragma aux divscale20 =\ + "mov edx, eax",\ + "sar edx, 12",\ + "shl eax, 20",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale20(long,long); + +#pragma aux divscale21 =\ + "mov edx, eax",\ + "sar edx, 11",\ + "shl eax, 21",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale21(long,long); + +#pragma aux divscale22 =\ + "mov edx, eax",\ + "sar edx, 10",\ + "shl eax, 22",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale22(long,long); + +#pragma aux divscale23 =\ + "mov edx, eax",\ + "sar edx, 9",\ + "shl eax, 23",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale23(long,long); + +#pragma aux divscale24 =\ + "mov edx, eax",\ + "sar edx, 8",\ + "shl eax, 24",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale24(long,long); + +#pragma aux divscale25 =\ + "mov edx, eax",\ + "sar edx, 7",\ + "shl eax, 25",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale25(long,long); + +#pragma aux divscale26 =\ + "mov edx, eax",\ + "sar edx, 6",\ + "shl eax, 26",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale26(long,long); + +#pragma aux divscale27 =\ + "mov edx, eax",\ + "sar edx, 5",\ + "shl eax, 27",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale27(long,long); + +#pragma aux divscale28 =\ + "mov edx, eax",\ + "sar edx, 4",\ + "shl eax, 28",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale28(long,long); + +#pragma aux divscale29 =\ + "mov edx, eax",\ + "sar edx, 3",\ + "shl eax, 29",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale29(long,long); + +#pragma aux divscale30 =\ + "mov edx, eax",\ + "sar edx, 2",\ + "shl eax, 30",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale30(long,long); + +#pragma aux divscale31 =\ + "mov edx, eax",\ + "sar edx, 1",\ + "shl eax, 31",\ + "idiv ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax edx] +long divscale31(long,long); + +#pragma aux divscale32 =\ + "xor eax, eax",\ + "idiv ebx",\ + parm nomemory [edx][ebx]\ + modify exact [eax edx] +long divscale32(long,long); + +#pragma aux readpixel =\ + "mov al, byte ptr [edi]",\ + parm nomemory [edi]\ + modify exact [eax] +long readpixel(void*); + +#pragma aux drawpixel =\ + "mov byte ptr [edi], al",\ + parm [edi][eax]\ + modify exact +long drawpixel(void*,long); + +#pragma aux drawpixels =\ + "mov word ptr [edi], ax",\ + parm [edi][eax]\ + modify exact +long drawpixels(void*,long); + +#pragma aux drawpixelses =\ + "mov dword ptr [edi], eax",\ + parm [edi][eax]\ + modify exact +long drawpixelses(void*,long); + +#pragma aux clearbuf =\ + "rep stosd",\ + parm [edi][ecx][eax]\ + modify exact [edi ecx] +long clearbuf(void*,long,long); + +#pragma aux clearbufbyte =\ + "cmp ecx, 4",\ + "jae longcopy",\ + "test cl, 1",\ + "jz preskip",\ + "stosb",\ + "preskip: shr ecx, 1",\ + "rep stosw",\ + "jmp endit",\ + "longcopy: test edi, 1",\ + "jz skip1",\ + "stosb",\ + "dec ecx",\ + "skip1: test edi, 2",\ + "jz skip2",\ + "stosw",\ + "sub ecx, 2",\ + "skip2: mov ebx, ecx",\ + "shr ecx, 2",\ + "rep stosd",\ + "test bl, 2",\ + "jz skip3",\ + "stosw",\ + "skip3: test bl, 1",\ + "jz endit",\ + "stosb",\ + "endit:",\ + parm [edi][ecx][eax]\ + modify [ebx] +long clearbufbyte(void*,long,long); + +#pragma aux copybuf =\ + "rep movsd",\ + parm [esi][edi][ecx]\ + modify exact [ecx esi edi] +long copybuf(void*,void*,long); + +#pragma aux copybufbyte =\ + "cmp ecx, 4",\ + "jae longcopy",\ + "test cl, 1",\ + "jz preskip",\ + "movsb",\ + "preskip: shr ecx, 1",\ + "rep movsw",\ + "jmp endit",\ + "longcopy: test edi, 1",\ + "jz skip1",\ + "movsb",\ + "dec ecx",\ + "skip1: test edi, 2",\ + "jz skip2",\ + "movsw",\ + "sub ecx, 2",\ + "skip2: mov ebx, ecx",\ + "shr ecx, 2",\ + "rep movsd",\ + "test bl, 2",\ + "jz skip3",\ + "movsw",\ + "skip3: test bl, 1",\ + "jz endit",\ + "movsb",\ + "endit:",\ + parm [esi][edi][ecx]\ + modify [ebx] +long copybufbyte(void*,void*,long); + +#pragma aux copybufreverse =\ + "shr ecx, 1",\ + "jnc skipit1",\ + "mov al, byte ptr [esi]",\ + "dec esi",\ + "mov byte ptr [edi], al",\ + "inc edi",\ + "skipit1: shr ecx, 1",\ + "jnc skipit2",\ + "mov ax, word ptr [esi-1]",\ + "sub esi, 2",\ + "ror ax, 8",\ + "mov word ptr [edi], ax",\ + "add edi, 2",\ + "skipit2: test ecx, ecx",\ + "jz endloop",\ + "begloop: mov eax, dword ptr [esi-3]",\ + "sub esi, 4",\ + "bswap eax",\ + "mov dword ptr [edi], eax",\ + "add edi, 4",\ + "dec ecx",\ + "jnz begloop",\ + "endloop:",\ + parm [esi][edi][ecx] +long copybufreverse(void*,void*,long); + +#pragma aux qinterpolatedown16 =\ + "mov ebx, ecx",\ + "shr ecx, 1",\ + "jz skipbegcalc",\ + "begqcalc: lea edi, [edx+esi]",\ + "sar edx, 16",\ + "mov dword ptr [eax], edx",\ + "lea edx, [edi+esi]",\ + "sar edi, 16",\ + "mov dword ptr [eax+4], edi",\ + "add eax, 8",\ + "dec ecx",\ + "jnz begqcalc",\ + "test ebx, 1",\ + "jz skipbegqcalc2",\ + "skipbegcalc: sar edx, 16",\ + "mov dword ptr [eax], edx",\ + "skipbegqcalc2:",\ + parm [eax][ecx][edx][esi]\ + modify exact [eax ebx ecx edx edi] +long qinterpolatedown16(long,long,long,long); + +#pragma aux qinterpolatedown16short =\ + "test ecx, ecx",\ + "jz endit",\ + "test al, 2",\ + "jz skipalignit",\ + "mov ebx, edx",\ + "sar ebx, 16",\ + "mov word ptr [eax], bx",\ + "add edx, esi",\ + "add eax, 2",\ + "dec ecx",\ + "jz endit",\ + "skipalignit: sub ecx, 2",\ + "jc finishit",\ + "begqcalc: mov ebx, edx",\ + "add edx, esi",\ + "sar ebx, 16",\ + "mov edi, edx",\ + "and edi, 0ffff0000h",\ + "add edx, esi",\ + "add ebx, edi",\ + "mov dword ptr [eax], ebx",\ + "add eax, 4",\ + "sub ecx, 2",\ + "jnc begqcalc",\ + "test cl, 1",\ + "jz endit",\ + "finishit: mov ebx, edx",\ + "sar ebx, 16",\ + "mov word ptr [eax], bx",\ + "endit:",\ + parm [eax][ecx][edx][esi]\ + modify exact [eax ebx ecx edx edi] +long qinterpolatedown16short(long,long,long,long); + +#pragma aux mul3 =\ + "lea eax, [eax+eax*2]",\ + parm nomemory [eax] +long mul3(long); + +#pragma aux mul5 =\ + "lea eax, [eax+eax*4]",\ + parm nomemory [eax] +long mul5(long); + +#pragma aux mul9 =\ + "lea eax, [eax+eax*8]",\ + parm nomemory [eax] +long mul9(long); + + //returns eax/ebx, dmval = eax%edx; +#pragma aux divmod =\ + "xor edx, edx",\ + "div ebx",\ + "mov dmval, edx",\ + parm [eax][ebx]\ + modify exact [eax edx]\ + value [eax] +long divmod(long,long); + + //returns eax%ebx, dmval = eax/edx; +#pragma aux moddiv =\ + "xor edx, edx",\ + "div ebx",\ + "mov dmval, eax",\ + parm [eax][ebx]\ + modify exact [eax edx]\ + value [edx] +long moddiv(long,long); + +#pragma aux klabs =\ + "test eax, eax",\ + "jns skipnegate",\ + "neg eax",\ + "skipnegate:",\ + parm nomemory [eax] +long klabs(long); + +#pragma aux ksgn =\ + "add ebx, ebx",\ + "sbb eax, eax",\ + "cmp eax, ebx",\ + "adc al, 0",\ + parm nomemory [ebx]\ + modify exact [eax ebx] +long ksgn(long); + + //eax = (unsigned min)umin(eax,ebx) +#pragma aux umin =\ + "sub eax, ebx",\ + "sbb ecx, ecx",\ + "and eax, ecx",\ + "add eax, ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax ecx] +long umin(long,long); + + //eax = (unsigned max)umax(eax,ebx) +#pragma aux umax =\ + "sub eax, ebx",\ + "sbb ecx, ecx",\ + "xor ecx, 0xffffffff",\ + "and eax, ecx",\ + "add eax, ebx",\ + parm nomemory [eax][ebx]\ + modify exact [eax ecx] +long umax(long,long); + +#pragma aux kmin =\ + "cmp eax, ebx",\ + "jl skipit",\ + "mov eax, ebx",\ + "skipit:",\ + parm nomemory [eax][ebx]\ + modify exact [eax] +long kmin(long,long); + +#pragma aux kmax =\ + "cmp eax, ebx",\ + "jg skipit",\ + "mov eax, ebx",\ + "skipit:",\ + parm nomemory [eax][ebx]\ + modify exact [eax] +long kmax(long,long); + +#pragma aux swapchar =\ + "mov cl, [eax]",\ + "mov ch, [ebx]",\ + "mov [ebx], cl",\ + "mov [eax], ch",\ + parm [eax][ebx]\ + modify exact [ecx] +long swapchar(void*,void*); + +#pragma aux swapshort =\ + "mov cx, [eax]",\ + "mov dx, [ebx]",\ + "mov [ebx], cx",\ + "mov [eax], dx",\ + parm [eax][ebx]\ + modify exact [ecx edx] +long swapshort(void*,void*); + +#pragma aux swaplong =\ + "mov ecx, [eax]",\ + "mov edx, [ebx]",\ + "mov [ebx], ecx",\ + "mov [eax], edx",\ + parm [eax][ebx]\ + modify exact [ecx edx] +long swaplong(void*,void*); + +#pragma aux swapbuf4 =\ + "begswap:",\ + "mov esi, [eax]",\ + "mov edi, [ebx]",\ + "mov [ebx], esi",\ + "mov [eax], edi",\ + "add eax, 4",\ + "add ebx, 4",\ + "dec ecx",\ + "jnz short begswap",\ + parm [eax][ebx][ecx]\ + modify exact [eax ebx ecx esi edi] +long swapbuf4(void*,void*,long); + +#pragma aux swap64bit =\ + "mov ecx, [eax]",\ + "mov edx, [ebx]",\ + "mov [ebx], ecx",\ + "mov ecx, [eax+4]",\ + "mov [eax], edx",\ + "mov edx, [ebx+4]",\ + "mov [ebx+4], ecx",\ + "mov [eax+4], edx",\ + parm [eax][ebx]\ + modify exact [ecx edx] +long swap64bit(void*,void*); + + //swapchar2(ptr1,ptr2,xsiz); is the same as: + //swapchar(ptr1,ptr2); swapchar(ptr1+1,ptr2+xsiz); +#pragma aux swapchar2 =\ + "add esi, ebx",\ + "mov cx, [eax]",\ + "mov dl, [ebx]",\ + "mov [ebx], cl",\ + "mov dh, [esi]",\ + "mov [esi], ch",\ + "mov [eax], dx",\ + parm [eax][ebx][esi]\ + modify exact [ecx edx esi] +long swapchar2(void*,void*,long); +//}}} + +#elif defined(_MSC_VER) // __WATCOMC__ + +// +// Microsoft C inline assembler +// + +//{{{ +static __inline long sqr(long a) +{ + _asm mov eax, a + _asm imul eax, eax +} + +static __inline long scale(long a, long d, long c) +{ + _asm mov eax, a + _asm imul d + _asm idiv c +} + +static __inline long mulscale(long a, long d, long c) +{ + _asm mov ecx, c + _asm mov eax, a + _asm imul d + _asm shrd eax, edx, cl +} + +#define MULSCALE(x) \ +static __inline long mulscale##x (long a, long d) \ +{ \ + _asm mov eax, a \ + _asm imul d \ + _asm shrd eax, edx, x \ +} + +MULSCALE(1) MULSCALE(2) MULSCALE(3) MULSCALE(4) +MULSCALE(5) MULSCALE(6) MULSCALE(7) MULSCALE(8) +MULSCALE(9) MULSCALE(10) MULSCALE(11) MULSCALE(12) +MULSCALE(13) MULSCALE(14) MULSCALE(15) MULSCALE(16) +MULSCALE(17) MULSCALE(18) MULSCALE(19) MULSCALE(20) +MULSCALE(21) MULSCALE(22) MULSCALE(23) MULSCALE(24) +MULSCALE(25) MULSCALE(26) MULSCALE(27) MULSCALE(28) +MULSCALE(29) MULSCALE(30) MULSCALE(31) +#undef MULSCALE +static __inline long mulscale32(long a, long d) +{ + _asm mov eax, a + _asm imul d + _asm mov eax, edx +} + +static __inline long dmulscale(long a, long d, long S, long D, long c) +{ + _asm mov ecx, c + _asm mov eax, a + _asm imul d + _asm mov ebx, eax + _asm mov eax, S + _asm mov esi, edx + _asm imul D + _asm add eax, ebx + _asm adc edx, esi + _asm shrd eax, edx, cl +} + +#define DMULSCALE(x) \ +static __inline long dmulscale##x (long a, long d, long S, long D) \ +{ \ + _asm mov eax, a \ + _asm imul d \ + _asm mov ebx, eax \ + _asm mov eax, S \ + _asm mov esi, edx \ + _asm imul D \ + _asm add eax, ebx \ + _asm adc edx, esi \ + _asm shrd eax, edx, x \ +} + +DMULSCALE(1) DMULSCALE(2) DMULSCALE(3) DMULSCALE(4) +DMULSCALE(5) DMULSCALE(6) DMULSCALE(7) DMULSCALE(8) +DMULSCALE(9) DMULSCALE(10) DMULSCALE(11) DMULSCALE(12) +DMULSCALE(13) DMULSCALE(14) DMULSCALE(15) DMULSCALE(16) +DMULSCALE(17) DMULSCALE(18) DMULSCALE(19) DMULSCALE(20) +DMULSCALE(21) DMULSCALE(22) DMULSCALE(23) DMULSCALE(24) +DMULSCALE(25) DMULSCALE(26) DMULSCALE(27) DMULSCALE(28) +DMULSCALE(29) DMULSCALE(30) DMULSCALE(31) +#undef DMULSCALE +static __inline long dmulscale32(long a, long d, long S, long D) +{ + _asm mov eax, a + _asm imul d + _asm mov ebx, eax + _asm mov eax, S + _asm mov esi, edx + _asm imul D + _asm add eax, ebx + _asm adc edx, esi + _asm mov eax, edx +} + +#define TMULSCALE(x) \ +static __inline long tmulscale##x (long a, long d, long b, long c, long S, long D) \ +{ \ + _asm mov eax, a \ + _asm mov ebx, b \ + _asm imul d \ + _asm xchg eax, ebx \ + _asm mov ecx, c \ + _asm xchg edx, ecx \ + _asm imul edx \ + _asm add ebx, eax \ + _asm adc ecx, edx \ + _asm mov eax, S \ + _asm imul D \ + _asm add eax, ebx \ + _asm adc edx, ecx \ +} + +TMULSCALE(1) TMULSCALE(2) TMULSCALE(3) TMULSCALE(4) +TMULSCALE(5) TMULSCALE(6) TMULSCALE(7) TMULSCALE(8) +TMULSCALE(9) TMULSCALE(10) TMULSCALE(11) TMULSCALE(12) +TMULSCALE(13) TMULSCALE(14) TMULSCALE(15) TMULSCALE(16) +TMULSCALE(17) TMULSCALE(18) TMULSCALE(19) TMULSCALE(20) +TMULSCALE(21) TMULSCALE(22) TMULSCALE(23) TMULSCALE(24) +TMULSCALE(25) TMULSCALE(26) TMULSCALE(27) TMULSCALE(28) +TMULSCALE(29) TMULSCALE(30) TMULSCALE(31) +#undef TMULSCALE +static __inline long tmulscale32(long a, long d, long b, long c, long S, long D) +{ + _asm mov eax, a + _asm mov ebx, b + _asm imul d + _asm xchg eax, ebx + _asm mov ecx, c + _asm xchg edx, ecx + _asm imul edx + _asm add ebx, eax + _asm adc ecx, edx + _asm mov eax, S + _asm imul D + _asm add eax, ebx + _asm adc edx, ecx + _asm mov eax, edx +} + +static __inline long boundmulscale(long a, long b, long c) +{ + _asm mov eax, a + _asm mov ecx, c + _asm imul b + _asm mov ebx, edx + _asm shrd eax, edx, cl + _asm sar edx, cl + _asm xor edx, eax + _asm js checkit + _asm xor edx, eax + _asm jz skipboundit + _asm cmp edx, 0xffffffff + _asm je skipboundit + checkit: + _asm mov eax, ebx + _asm sar eax, 31 + _asm xor eax, 0x7fffffff + skipboundit: + ; +} + +static __inline long divscale(long a, long b, long c) +{ + _asm mov eax, a + _asm mov ecx, c + _asm mov edx, eax + _asm shl eax, cl + _asm neg cl + _asm sar edx, cl + _asm idiv b +} + +static __inline long divscale1(long a, long b) +{ + _asm mov eax, a + _asm add eax, eax + _asm sbb edx, edx + _asm idiv b +} + +static __inline long divscale2(long a, long b) +{ + _asm mov eax, a + _asm mov edx, eax + _asm sar edx, 30 + _asm lea eax, [eax*4] + _asm idiv b +} + +static __inline long divscale3(long a, long b) +{ + _asm mov eax, a + _asm mov edx, eax + _asm sar edx, 29 + _asm lea eax, [eax*8] + _asm idiv b +} + +#define DIVSCALE(x,y) \ +static __inline long divscale##y(long a, long b) \ +{ \ + _asm mov eax, a \ + _asm mov edx, eax \ + _asm sar edx, x \ + _asm shl eax, y \ + _asm idiv b \ +} + +DIVSCALE(28,4) DIVSCALE(27,5) DIVSCALE(26,6) DIVSCALE(25,7) +DIVSCALE(24,8) DIVSCALE(23,9) DIVSCALE(22,10) DIVSCALE(21,11) +DIVSCALE(20,12) DIVSCALE(19,13) DIVSCALE(18,14) DIVSCALE(17,15) +DIVSCALE(16,16) DIVSCALE(15,17) DIVSCALE(14,18) DIVSCALE(13,19) +DIVSCALE(12,20) DIVSCALE(11,21) DIVSCALE(10,22) DIVSCALE(9,23) +DIVSCALE(8,24) DIVSCALE(7,25) DIVSCALE(6,26) DIVSCALE(5,27) +DIVSCALE(4,28) DIVSCALE(3,29) DIVSCALE(2,30) DIVSCALE(1,31) + +static __inline long divscale32(long d, long b) +{ + _asm mov edx, d + _asm xor eax, eax + _asm idiv b +} + +static __inline char readpixel(void *d) +{ + _asm mov edx, d + _asm mov al, byte ptr [edx] +} + +static __inline void drawpixel(void *d, char a) +{ + _asm mov edx, d + _asm mov al, a + _asm mov byte ptr [edx], al +} + +static __inline void drawpixels(void *d, short a) +{ + _asm mov edx, d + _asm mov ax, a + _asm mov word ptr [edx], ax +} + +static __inline void drawpixelses(void *d, long a) +{ + _asm mov edx, d + _asm mov eax, a + _asm mov dword ptr [edx], eax +} + +static __inline void clearbuf(void *d, long c, long a) +{ + _asm mov edi, d + _asm mov ecx, c + _asm mov eax, a + _asm rep stosd +} + +static __inline void clearbufbyte(void *d, long c, long a) +{ + _asm mov edi, d + _asm mov ecx, c + _asm mov eax, a + _asm { + cmp ecx, 4 + jae longcopy + test cl, 1 + jz preskip + stosb + } + preskip: + _asm { + shr ecx, 1 + rep stosw + jmp endit + } + longcopy: + _asm { + test edi, 1 + jz skip1 + stosb + dec ecx + } + skip1: + _asm { + test edi, 2 + jz skip2 + stosw + sub ecx, 2 + } + skip2: + _asm { + mov ebx, ecx + shr ecx, 2 + rep stosd + test bl, 2 + jz skip3 + stosw + } + skip3: + _asm { + test bl, 1 + jz endit + stosb + } + endit: + ; +} + +static __inline void copybuf(void *s, void *d, long c) +{ + _asm mov esi, s + _asm mov edi, d + _asm mov ecx, c + _asm rep movsd +} + +static __inline void copybufbyte(void *s, void *d, long c) +{ + _asm mov esi, s + _asm mov edi, d + _asm mov ecx, c + _asm { + cmp ecx, 4 + jae longcopy + test cl, 1 + jz preskip + movsb + } + preskip: + _asm { + shr ecx, 1 + rep movsw + jmp endit + } + longcopy: + _asm { + test edi, 1 + jz skip1 + movsb + dec ecx + } + skip1: + _asm { + test edi, 2 + jz skip2 + movsw + sub ecx, 2 + } + skip2: + _asm { + mov ebx, ecx + shr ecx, 2 + rep movsd + test bl, 2 + jz skip3 + movsw + } + skip3: + _asm { + test bl, 1 + jz endit + movsb + } + endit: + ; +} + +static __inline void copybufreverse(void *s, void *d, long c) +{ + _asm mov esi, s + _asm mov edi, d + _asm mov ecx, c + _asm { + shr ecx, 1 + jnc skipit1 + mov al, byte ptr [esi] + dec esi + mov byte ptr [edi], al + inc edi + } + skipit1: + _asm { + shr ecx, 1 + jnc skipit2 + mov ax, word ptr [esi-1] + sub esi, 2 + ror ax, 8 + mov word ptr [edi], ax + add edi, 2 + } + skipit2: + _asm { + test ecx, ecx + jz endloop + } + begloop: + _asm { + mov eax, dword ptr [esi-3] + sub esi, 4 + bswap eax + mov dword ptr [edi], eax + add edi, 4 + dec ecx + jnz begloop + } + endloop: + ; +} + +static __inline void qinterpolatedown16(long a, long c, long d, long s) +{ + _asm mov eax, a + _asm mov ecx, c + _asm mov edx, d + _asm mov esi, s + _asm { + mov ebx, ecx + shr ecx, 1 + jz skipbegcalc + } + begqcalc: + _asm { + lea edi, [edx+esi] + sar edx, 16 + mov dword ptr [eax], edx + lea edx, [edi+esi] + sar edi, 16 + mov dword ptr [eax+4], edi + add eax, 8 + dec ecx + jnz begqcalc + test ebx, 1 + jz skipbegqcalc2 + } + skipbegcalc: + _asm { + sar edx, 16 + mov dword ptr [eax], edx + } + skipbegqcalc2: + ; +} + +static __inline void qinterpolatedown16short(long a, long c, long d, long s) +{ + _asm mov eax, a + _asm mov ecx, c + _asm mov edx, d + _asm mov esi, s + _asm { + test ecx, ecx + jz endit + test al, 2 + jz skipalignit + mov ebx, edx + sar ebx, 16 + mov word ptr [eax], bx + add edx, esi + add eax, 2 + dec ecx + jz endit + } + skipalignit: + _asm { + sub ecx, 2 + jc finishit + } + begqcalc: + _asm { + mov ebx, edx + add edx, esi + sar ebx, 16 + mov edi, edx + and edi, 0ffff0000h + add edx, esi + add ebx, edi + mov dword ptr [eax], ebx + add eax, 4 + sub ecx, 2 + jnc begqcalc + test cl, 1 + jz endit + } + finishit: + _asm { + mov ebx, edx + sar ebx, 16 + mov word ptr [eax], bx + } + endit: + ; +} + +static __inline long mul3(long a) +{ + _asm mov eax, a + _asm lea eax, [eax+eax*2] +} + +static __inline long mul5(long a) +{ + _asm mov eax, a + _asm lea eax, [eax+eax*4] +} + +static __inline long mul9(long a) +{ + _asm mov eax, a + _asm lea eax, [eax+eax*8] +} + + //returns eax/ebx, dmval = eax%edx; +static __inline long divmod(long a, long b) +{ + _asm mov eax, a + _asm xor edx, edx + _asm div b + _asm mov dmval, edx +} + + //returns eax%ebx, dmval = eax/edx; +static __inline long moddiv(long a, long b) +{ + _asm mov eax, a + _asm xor edx, edx + _asm div b + _asm mov dmval, eax + _asm mov eax, edx +} + +static __inline long klabs(long a) +{ + _asm mov eax, a + _asm test eax, eax + _asm jns skipnegate + _asm neg eax + skipnegate: + ; +} + +static __inline long ksgn(long b) +{ + _asm mov ebx, b + _asm add ebx, ebx + _asm sbb eax, eax + _asm cmp eax, ebx + _asm adc al, 0 +} + + //eax = (unsigned min)umin(eax,ebx) +static __inline long umin(long a, long b) +{ + _asm mov eax, a + _asm sub eax, b + _asm sbb ecx, ecx + _asm and eax, ecx + _asm add eax, b +} + + //eax = (unsigned max)umax(eax,ebx) +static __inline long umax(long a, long b) +{ + _asm mov eax, a + _asm sub eax, b + _asm sbb ecx, ecx + _asm xor ecx, 0xffffffff + _asm and eax, ecx + _asm add eax, b +} + +static __inline long kmin(long a, long b) +{ + _asm mov eax, a + _asm mov ebx, b + _asm cmp eax, ebx + _asm jl skipit + _asm mov eax, ebx + skipit: + ; +} + +static __inline long kmax(long a, long b) +{ + _asm mov eax, a + _asm mov ebx, b + _asm cmp eax, ebx + _asm jg skipit + _asm mov eax, ebx + skipit: + ; +} + +static __inline void swapchar(void *a, void *b) +{ + _asm mov eax, a + _asm mov ebx, b + _asm mov cl, [eax] + _asm mov ch, [ebx] + _asm mov [ebx], cl + _asm mov [eax], ch +} + +static __inline void swapshort(void *a, void *b) +{ + _asm mov eax, a + _asm mov ebx, b + _asm mov cx, [eax] + _asm mov dx, [ebx] + _asm mov [ebx], cx + _asm mov [eax], dx +} + +static __inline void swaplong(void *a, void *b) +{ + _asm mov eax, a + _asm mov ebx, b + _asm mov ecx, [eax] + _asm mov edx, [ebx] + _asm mov [ebx], ecx + _asm mov [eax], edx +} + +static __inline void swapbuf4(void *a, void *b, long c) +{ + _asm mov eax, a + _asm mov ebx, b + _asm mov ecx, c + begswap: + _asm { + mov esi, [eax] + mov edi, [ebx] + mov [ebx], esi + mov [eax], edi + add eax, 4 + add ebx, 4 + dec ecx + jnz short begswap + } +} + +static __inline void swap64bit(void *a, void *b) +{ + _asm mov eax, a + _asm mov ebx, b + _asm mov ecx, [eax] + _asm mov edx, [ebx] + _asm mov [ebx], ecx + _asm mov ecx, [eax+4] + _asm mov [eax], edx + _asm mov edx, [ebx+4] + _asm mov [ebx+4], ecx + _asm mov [eax+4], edx +} + + //swapchar2(ptr1,ptr2,xsiz); is the same as: + //swapchar(ptr1,ptr2); swapchar(ptr1+1,ptr2+xsiz); +static __inline void swapchar2(void *a, void *b, long s) +{ + _asm mov eax, a + _asm mov ebx, b + _asm mov esi, s + _asm add esi, ebx + _asm mov cx, [eax] + _asm mov dl, [ebx] + _asm mov [ebx], cl + _asm mov dh, [esi] + _asm mov [esi], ch + _asm mov [eax], dx +} +//}}} + +#else // _MSC_VER + +#error Unsupported compiler or architecture. + +#endif + +#endif // __pragmas_h__ + diff --git a/polymer/build/include/scriptfile.h b/polymer/build/include/scriptfile.h new file mode 100644 index 000000000..01557f2f6 --- /dev/null +++ b/polymer/build/include/scriptfile.h @@ -0,0 +1,26 @@ +typedef struct { + char *textbuf; + unsigned int textlength; + char *ltextptr; // pointer to start of the last token fetched (use this for line numbers) + char *textptr; + char *eof; + char *filename; + int linenum; + long *lineoffs; +} scriptfile; + +char *scriptfile_gettoken(scriptfile *sf); +int scriptfile_getnumber(scriptfile *sf, int *num); +int scriptfile_getdouble(scriptfile *sf, double *num); +int scriptfile_getstring(scriptfile *sf, char **st); +int scriptfile_getsymbol(scriptfile *sf, int *num); +int scriptfile_getlinum(scriptfile *sf, char *ptr); +int scriptfile_getbraces(scriptfile *sf, char **braceend); + +scriptfile *scriptfile_fromfile(char *fn); +scriptfile *scriptfile_fromstring(char *string); +void scriptfile_close(scriptfile *sf); + +int scriptfile_getsymbolvalue(char *name, int *val); +int scriptfile_addsymbolvalue(char *name, int val); +void scriptfile_clearsymbols(void); diff --git a/polymer/build/include/sdlayer.h b/polymer/build/include/sdlayer.h new file mode 100644 index 000000000..85d637b8d --- /dev/null +++ b/polymer/build/include/sdlayer.h @@ -0,0 +1,21 @@ +// SDL interface layer +// for the Build Engine +// by Jonathon Fowler (jonof@edgenetwk.com) + +#ifndef __build_interface_layer__ +#define __build_interface_layer__ SDL + +#include "baselayer.h" + +struct sdlappicon { + int width,height; + unsigned int *pixels; + unsigned char *mask; +}; + +#else +#if (__build_interface_layer__ != SDL) +#error "Already using the " __build_interface_layer__ ". Can't now use SDL." +#endif +#endif // __build_interface_layer__ + diff --git a/polymer/build/include/tmp/buildsound.h b/polymer/build/include/tmp/buildsound.h new file mode 100644 index 000000000..c85922bc4 --- /dev/null +++ b/polymer/build/include/tmp/buildsound.h @@ -0,0 +1,15 @@ + +typedef struct { + unsigned long samplerate; // sample rate of the sound + unsigned short channels; // number of channels + unsigned short bitspersample; // bits per sample + unsigned short format; // 0 = pcm + unsigned long soundlength; // bytes required for sound storage +} SoundInfo; + + +int ReadVOCInfo(int fh, SoundInfo *snd); +int ReadVOCData(int fh, char *data, int bufferlen); + +int ReadWAVInfo(int fh, SoundInfo *snd); +int ReadWAVData(int fh, char *data, int bufferlen); diff --git a/polymer/build/include/tmp/pragmas-functions.h b/polymer/build/include/tmp/pragmas-functions.h new file mode 100644 index 000000000..185c60dfe --- /dev/null +++ b/polymer/build/include/tmp/pragmas-functions.h @@ -0,0 +1,159 @@ +#ifdef USE_C_FUNCTION_PRAGMAS +long sqr(long a); +long scale(long a, long d, long c); +long mulscale(long a, long d, long c); +long mulscale1(long a, long d); +long mulscale2(long a, long d); +long mulscale3(long a, long d); +long mulscale4(long a, long d); +long mulscale5(long a, long d); +long mulscale6(long a, long d); +long mulscale7(long a, long d); +long mulscale8(long a, long d); +long mulscale9(long a, long d); +long mulscale10(long a, long d); +long mulscale11(long a, long d); +long mulscale12(long a, long d); +long mulscale13(long a, long d); +long mulscale14(long a, long d); +long mulscale15(long a, long d); +long mulscale16(long a, long d); +long mulscale17(long a, long d); +long mulscale18(long a, long d); +long mulscale19(long a, long d); +long mulscale20(long a, long d); +long mulscale21(long a, long d); +long mulscale22(long a, long d); +long mulscale23(long a, long d); +long mulscale24(long a, long d); +long mulscale25(long a, long d); +long mulscale26(long a, long d); +long mulscale27(long a, long d); +long mulscale28(long a, long d); +long mulscale29(long a, long d); +long mulscale30(long a, long d); +long mulscale31(long a, long d); +long mulscale32(long a, long d); +long dmulscale(long a, long d, long S, long D, long c); +long dmulscale1(long a, long d, long S, long D); +long dmulscale2(long a, long d, long S, long D); +long dmulscale3(long a, long d, long S, long D); +long dmulscale4(long a, long d, long S, long D); +long dmulscale5(long a, long d, long S, long D); +long dmulscale6(long a, long d, long S, long D); +long dmulscale7(long a, long d, long S, long D); +long dmulscale8(long a, long d, long S, long D); +long dmulscale9(long a, long d, long S, long D); +long dmulscale10(long a, long d, long S, long D); +long dmulscale11(long a, long d, long S, long D); +long dmulscale12(long a, long d, long S, long D); +long dmulscale13(long a, long d, long S, long D); +long dmulscale14(long a, long d, long S, long D); +long dmulscale15(long a, long d, long S, long D); +long dmulscale16(long a, long d, long S, long D); +long dmulscale17(long a, long d, long S, long D); +long dmulscale18(long a, long d, long S, long D); +long dmulscale19(long a, long d, long S, long D); +long dmulscale20(long a, long d, long S, long D); +long dmulscale21(long a, long d, long S, long D); +long dmulscale22(long a, long d, long S, long D); +long dmulscale23(long a, long d, long S, long D); +long dmulscale24(long a, long d, long S, long D); +long dmulscale25(long a, long d, long S, long D); +long dmulscale26(long a, long d, long S, long D); +long dmulscale27(long a, long d, long S, long D); +long dmulscale28(long a, long d, long S, long D); +long dmulscale29(long a, long d, long S, long D); +long dmulscale30(long a, long d, long S, long D); +long dmulscale31(long a, long d, long S, long D); +long dmulscale32(long a, long d, long S, long D); +long tmulscale1(long a, long d, long b, long c, long S, long D); +long tmulscale2(long a, long d, long b, long c, long S, long D); +long tmulscale3(long a, long d, long b, long c, long S, long D); +long tmulscale4(long a, long d, long b, long c, long S, long D); +long tmulscale5(long a, long d, long b, long c, long S, long D); +long tmulscale6(long a, long d, long b, long c, long S, long D); +long tmulscale7(long a, long d, long b, long c, long S, long D); +long tmulscale8(long a, long d, long b, long c, long S, long D); +long tmulscale9(long a, long d, long b, long c, long S, long D); +long tmulscale10(long a, long d, long b, long c, long S, long D); +long tmulscale11(long a, long d, long b, long c, long S, long D); +long tmulscale12(long a, long d, long b, long c, long S, long D); +long tmulscale13(long a, long d, long b, long c, long S, long D); +long tmulscale14(long a, long d, long b, long c, long S, long D); +long tmulscale15(long a, long d, long b, long c, long S, long D); +long tmulscale16(long a, long d, long b, long c, long S, long D); +long tmulscale17(long a, long d, long b, long c, long S, long D); +long tmulscale18(long a, long d, long b, long c, long S, long D); +long tmulscale19(long a, long d, long b, long c, long S, long D); +long tmulscale20(long a, long d, long b, long c, long S, long D); +long tmulscale21(long a, long d, long b, long c, long S, long D); +long tmulscale22(long a, long d, long b, long c, long S, long D); +long tmulscale23(long a, long d, long b, long c, long S, long D); +long tmulscale24(long a, long d, long b, long c, long S, long D); +long tmulscale25(long a, long d, long b, long c, long S, long D); +long tmulscale26(long a, long d, long b, long c, long S, long D); +long tmulscale27(long a, long d, long b, long c, long S, long D); +long tmulscale28(long a, long d, long b, long c, long S, long D); +long tmulscale29(long a, long d, long b, long c, long S, long D); +long tmulscale30(long a, long d, long b, long c, long S, long D); +long tmulscale31(long a, long d, long b, long c, long S, long D); +long tmulscale32(long a, long d, long b, long c, long S, long D); +long divscale(long a, long b, long c); +long divscale1(long a, long b); +long divscale2(long a, long b); +long divscale3(long a, long b); +long divscale4(long a, long b); +long divscale5(long a, long b); +long divscale6(long a, long b); +long divscale7(long a, long b); +long divscale8(long a, long b); +long divscale9(long a, long b); +long divscale10(long a, long b); +long divscale11(long a, long b); +long divscale12(long a, long b); +long divscale13(long a, long b); +long divscale14(long a, long b); +long divscale15(long a, long b); +long divscale16(long a, long b); +long divscale17(long a, long b); +long divscale18(long a, long b); +long divscale19(long a, long b); +long divscale20(long a, long b); +long divscale21(long a, long b); +long divscale22(long a, long b); +long divscale23(long a, long b); +long divscale24(long a, long b); +long divscale25(long a, long b); +long divscale26(long a, long b); +long divscale27(long a, long b); +long divscale28(long a, long b); +long divscale29(long a, long b); +long divscale30(long a, long b); +long divscale31(long a, long b); +long divscale32(long d, long b); +long readpixel(void *D); +void drawpixel(void *D, long a); +void drawpixels(void *D, long a); +void drawpixelses(void *D, long a); +void clearbuf(void* D, long c, long a); +void copybuf(void *S, void *D, long c); +long mul3(long a); +long mul5(long a); +long mul9(long a); +long divmod(long a, long b); +long moddiv(long a, long b); +long klabs(long a); +long ksgn(long b); +long umin(long a, long b); +long umax(long a, long b); +long kmin(long a, long b); +long kmax(long a, long b); +void swapchar(void *a, void *b); +void swapshort(void *a, void *b); +void swaplong(void *a, void *b); +void swapbuf4(void *a, void *b, long c); +void swap64bit(void *a, void *b); +void swapchar2(void *a, void *b, long S); +#endif + diff --git a/polymer/build/include/winlayer.h b/polymer/build/include/winlayer.h new file mode 100644 index 000000000..415b4f74c --- /dev/null +++ b/polymer/build/include/winlayer.h @@ -0,0 +1,54 @@ +// Windows DIB/DirectDraw interface layer +// for the Build Engine +// by Jonathon Fowler (jonof@edgenetwk.com) + +#ifndef __build_interface_layer__ +#define __build_interface_layer__ WIN + +extern int backgroundidle; // set to 1 to tell winlayer to go to idle priority when inactive +extern unsigned maxrefreshfreq; + +extern int glusecds; + +long win_gethwnd(void); +long win_gethinstance(void); + +// resource ids +#define WIN_STARTWIN 1000 +#define WIN_STARTWIN_ITEMBITMAP 100 // banner bitmap +#define WIN_STARTWIN_ITEMTEXT 101 // text header +#define WIN_STARTWIN_ITEMLIST 102 // output list box +#define WIN_STARTWINBMP 200 + + // *hwnd - receives the window handle to the startup dialog box + // saferect[] - receives the safe area to draw controls over (l,t,w,h) + // onclose - called before the startup window closes + // returns 0 if successful, 1 if the window isn't open +int win_getstartupwin(long *hwnd, long saferect[4], void (*onclose)(void)); +int win_getstartupcommand(void); + +void win_allowtaskswitching(int onf); +int win_checkinstance(void); + +/* +#ifdef KENBUILD +#define DISCLAIMER "IMPORTANT:\n" \ + "\tThis is a source port by Jonathon Fowler (jonof@edgenetwk.com) of the Build Engine, " \ + "editor and test game by Ken Silverman to the Windows and Linux operating systems. It is " \ + "distributed under the terms listed in BUILDLIC.TXT included with this package." +#endif +#ifdef DUKE3D +#define DISCLAIMER "IMPORTANT:\n" \ + "\tThis port of Duke Nukem 3D was done by Jonathon Fowler (jonof@edgenetwk.com) and is not " \ + "endorsed or supported by 3D Realms or Apogee. They will not provide support for it. Visit " \ + "http://jonof.edgenetwk.com/buildport/duke3d/ for details." +#endif +*/ +#include "baselayer.h" + +#else +#if (__build_interface_layer__ != WIN) +#error "Already using the " __build_interface_layer__ ". Can't now use Windows." +#endif +#endif // __build_interface_layer__ + diff --git a/polymer/build/makegnu.bat b/polymer/build/makegnu.bat new file mode 100644 index 000000000..027d85aa6 --- /dev/null +++ b/polymer/build/makegnu.bat @@ -0,0 +1 @@ +make -f Makefile %1 %2 %3 %4 %5 diff --git a/polymer/build/makemsc.bat b/polymer/build/makemsc.bat new file mode 100644 index 000000000..19243ed20 --- /dev/null +++ b/polymer/build/makemsc.bat @@ -0,0 +1 @@ +nmake /f Makefile.msvc %1 %2 %3 %4 %5 diff --git a/polymer/build/makew.bat b/polymer/build/makew.bat new file mode 100644 index 000000000..7184b0f08 --- /dev/null +++ b/polymer/build/makew.bat @@ -0,0 +1 @@ +wmake -f Makefile.watcom %1 %2 %3 %4 %5 diff --git a/polymer/build/obj.gnu/keep.me b/polymer/build/obj.gnu/keep.me new file mode 100644 index 000000000..e69de29bb diff --git a/polymer/build/obj.msc/keep.me b/polymer/build/obj.msc/keep.me new file mode 100644 index 000000000..e69de29bb diff --git a/polymer/build/obj.watcom/keep.me b/polymer/build/obj.watcom/keep.me new file mode 100644 index 000000000..e69de29bb diff --git a/polymer/build/osx/engine/engine.xcode/project.pbxproj b/polymer/build/osx/engine/engine.xcode/project.pbxproj new file mode 100644 index 000000000..444e8d545 --- /dev/null +++ b/polymer/build/osx/engine/engine.xcode/project.pbxproj @@ -0,0 +1,1539 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 39; + objects = { + AB2B5C7308E6979600899067 = { + buildPhases = ( + AB2B5C7408E6979600899067, + AB2B5C7508E6979600899067, + AB2B5C8408E6979600899067, + AB2B5C9608E6979600899067, + ); + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_CHAR_IS_UNSIGNED_CHAR = YES; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_PREPROCESSOR_DEFINITIONS = "SETSPRITEZ SUPERBUILD POLYMOST USE_OPENGL USE_A_C NOASM RENDERTYPESDL=1 KSFORBUILD WITHKPLIB"; + HEADER_SEARCH_PATHS = "../../include ../../src"; + LIBRARY_STYLE = STATIC; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = enginez; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wno-four-char-constants -Wno-unknown-pragmas -Wno-char-subscripts"; + }; + dependencies = ( + ); + isa = PBXNativeTarget; + name = enginez; + productName = engine; + productReference = AB2B5C9708E6979600899067; + productType = "com.apple.product-type.library.static"; + }; + AB2B5C7408E6979600899067 = { + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + isa = PBXShellScriptBuildPhase; + outputPaths = ( + engineinfo.c, + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "source writeengineinfo.sh"; + }; + AB2B5C7508E6979600899067 = { + buildActionMask = 2147483647; + files = ( + AB2B5C7608E6979600899067, + AB2B5C7708E6979600899067, + AB2B5C7808E6979600899067, + AB2B5C7908E6979600899067, + AB2B5C7A08E6979600899067, + AB2B5C7B08E6979600899067, + AB2B5C7C08E6979600899067, + AB2B5C7D08E6979600899067, + AB2B5C7E08E6979600899067, + AB2B5C7F08E6979600899067, + AB2B5C8008E6979600899067, + AB2B5C8108E6979600899067, + AB2B5C8208E6979600899067, + AB2B5C8308E6979600899067, + AB8F394909545F3800B9F541, + ABD656410967A52B0066981D, + AB6F05A20983A54D00B8EBA0, + AB6F05AF0983A5DD00B8EBA0, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB2B5C7608E6979600899067 = { + fileRef = AB3AFE9308DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C7708E6979600899067 = { + fileRef = AB3AFE9408DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C7808E6979600899067 = { + fileRef = AB3AFE9508DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C7908E6979600899067 = { + fileRef = AB3AFE9608DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C7A08E6979600899067 = { + fileRef = AB3AFE9708DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C7B08E6979600899067 = { + fileRef = AB3AFE9808DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C7C08E6979600899067 = { + fileRef = AB3AFE9908DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C7D08E6979600899067 = { + fileRef = AB3AFE9A08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C7E08E6979600899067 = { + fileRef = AB3AFE9B08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C7F08E6979600899067 = { + fileRef = AB3AFE9C08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C8008E6979600899067 = { + fileRef = AB3AFE9D08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C8108E6979600899067 = { + fileRef = AB3AFE9E08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C8208E6979600899067 = { + fileRef = AB3AFE9F08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C8308E6979600899067 = { + fileRef = AB3AFEA008DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB2B5C8408E6979600899067 = { + buildActionMask = 2147483647; + files = ( + AB2B5C8508E6979600899067, + AB2B5C8608E6979600899067, + AB2B5C8708E6979600899067, + AB2B5C8808E6979600899067, + AB2B5C8908E6979600899067, + AB2B5C8A08E6979600899067, + AB2B5C8B08E6979600899067, + AB2B5C8C08E6979600899067, + AB2B5C8D08E6979600899067, + AB2B5C8E08E6979600899067, + AB2B5C8F08E6979600899067, + AB2B5C9008E6979600899067, + AB2B5C9108E6979600899067, + AB2B5C9208E6979600899067, + AB2B5C9308E6979600899067, + AB2B5D4708E69D9000899067, + AB8F394609545F2600B9F541, + ABD6563A0967A4FA0066981D, + AB6F059E0983A53200B8EBA0, + AB6F059F0983A53200B8EBA0, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB2B5C8508E6979600899067 = { + fileRef = AB3AF5F908DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8608E6979600899067 = { + fileRef = AB3AF5FA08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8708E6979600899067 = { + fileRef = AB3AF5FB08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8808E6979600899067 = { + fileRef = AB3AF5FC08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8908E6979600899067 = { + fileRef = AB3AF5FD08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8A08E6979600899067 = { + fileRef = AB3AF5FE08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8B08E6979600899067 = { + fileRef = AB3AF5FF08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8C08E6979600899067 = { + fileRef = AB3AF60008DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8D08E6979600899067 = { + fileRef = AB3AF60308DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8E08E6979600899067 = { + fileRef = AB3AF60608DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C8F08E6979600899067 = { + fileRef = AB3AF60808DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C9008E6979600899067 = { + fileRef = AB3AF60908DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C9108E6979600899067 = { + fileRef = AB3AF60A08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C9208E6979600899067 = { + fileRef = AB3AF60508DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C9308E6979600899067 = { + fileRef = AB3AF9CE08DEE17600C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5C9608E6979600899067 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB2B5C9708E6979600899067 = { + explicitFileType = archive.ar; + includeInIndex = 0; + isa = PBXFileReference; + path = libenginez.a; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; + AB2B5D4508E69D9000899067 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + name = osxbits.m; + path = ../../src/osxbits.m; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB2B5D4608E69D9000899067 = { + fileRef = AB2B5D4508E69D9000899067; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5D4708E69D9000899067 = { + fileRef = AB2B5D4508E69D9000899067; + isa = PBXBuildFile; + settings = { + }; + }; + AB2B5D4808E69DB100899067 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = osxbits.h; + path = ../../include/osxbits.h; + refType = 4; + sourceTree = ""; + }; + AB3AF5E708DEDAA700C0AA42 = { + children = ( + AB3AF9D208DEE28200C0AA42, + AB3AF5F708DEDADD00C0AA42, + AB3AF62308DEDBBA00C0AA42, + AB3AF5F608DEDABE00C0AA42, + AB3AF9D008DEE1C400C0AA42, + ); + isa = PBXGroup; + refType = 4; + sourceTree = ""; + }; + AB3AF5E908DEDAA700C0AA42 = { + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_OPTIMIZATION_LEVEL = 0; + }; + isa = PBXBuildStyle; + name = Development; + }; + AB3AF5EA08DEDAA700C0AA42 = { + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_OPTIMIZATION_LEVEL = s; + }; + isa = PBXBuildStyle; + name = Deployment; + }; + AB3AF5EB08DEDAA700C0AA42 = { + buildSettings = { + }; + buildStyles = ( + AB3AF5E908DEDAA700C0AA42, + AB3AF5EA08DEDAA700C0AA42, + ); + hasScannedForEncodings = 0; + isa = PBXProject; + mainGroup = AB3AF5E708DEDAA700C0AA42; + productRefGroup = AB3AF5F608DEDABE00C0AA42; + projectDirPath = ""; + targets = ( + AB3AFBF408DF03EE00C0AA42, + AB3AF5F408DEDABE00C0AA42, + AB3AF9DD08DEE2CF00C0AA42, + AB2B5C7308E6979600899067, + ); + }; + AB3AF5F108DEDABE00C0AA42 = { + buildActionMask = 2147483647; + files = ( + AB3AFEA108DF044D00C0AA42, + AB3AFEA208DF044D00C0AA42, + AB3AFEA308DF044D00C0AA42, + AB3AFEA408DF044D00C0AA42, + AB3AFEA508DF044D00C0AA42, + AB3AFEA608DF044D00C0AA42, + AB3AFEA708DF044D00C0AA42, + AB3AFEA808DF044D00C0AA42, + AB3AFEA908DF044D00C0AA42, + AB3AFEAA08DF044D00C0AA42, + AB3AFEAB08DF044D00C0AA42, + AB3AFEAC08DF044D00C0AA42, + AB3AFEAD08DF044D00C0AA42, + AB3AFEAE08DF044D00C0AA42, + AB8F394809545F3800B9F541, + ABD656400967A52B0066981D, + AB6F05A10983A54D00B8EBA0, + AB6F05AE0983A5DD00B8EBA0, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AF5F208DEDABE00C0AA42 = { + buildActionMask = 2147483647; + files = ( + AB3AF60D08DEDB3100C0AA42, + AB3AF60E08DEDB3100C0AA42, + AB3AF60F08DEDB3100C0AA42, + AB3AF61008DEDB3100C0AA42, + AB3AF61108DEDB3100C0AA42, + AB3AF61208DEDB3100C0AA42, + AB3AF61308DEDB3100C0AA42, + AB3AF61408DEDB3100C0AA42, + AB3AF61708DEDB3100C0AA42, + AB3AF61A08DEDB3100C0AA42, + AB3AF61C08DEDB3100C0AA42, + AB3AF61D08DEDB3100C0AA42, + AB3AF61E08DEDB3100C0AA42, + AB3AF62108DEDB4F00C0AA42, + AB3AF9CF08DEE17600C0AA42, + AB2B5D4608E69D9000899067, + AB8F394509545F2600B9F541, + ABD656390967A4FA0066981D, + AB6F059C0983A53200B8EBA0, + AB6F059D0983A53200B8EBA0, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AF5F308DEDABE00C0AA42 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AF5F408DEDABE00C0AA42 = { + buildPhases = ( + AB3AF9CC08DEE11200C0AA42, + AB3AF5F108DEDABE00C0AA42, + AB3AF5F208DEDABE00C0AA42, + AB3AF5F308DEDABE00C0AA42, + ); + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_CHAR_IS_UNSIGNED_CHAR = YES; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_PREPROCESSOR_DEFINITIONS = "SUPERBUILD POLYMOST USE_OPENGL USE_A_C NOASM RENDERTYPESDL=1 KSFORBUILD WITHKPLIB"; + HEADER_SEARCH_PATHS = "../../include ../../src"; + LIBRARY_STYLE = STATIC; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = engine; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wno-four-char-constants -Wno-unknown-pragmas -Wno-char-subscripts"; + }; + dependencies = ( + ); + isa = PBXNativeTarget; + name = engine; + productName = engine; + productReference = AB3AF5F508DEDABE00C0AA42; + productType = "com.apple.product-type.library.static"; + }; + AB3AF5F508DEDABE00C0AA42 = { + explicitFileType = archive.ar; + includeInIndex = 0; + isa = PBXFileReference; + path = libengine.a; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; + AB3AF5F608DEDABE00C0AA42 = { + children = ( + AB3AF5F508DEDABE00C0AA42, + AB3AF9DE08DEE2CF00C0AA42, + AB2B5C9708E6979600899067, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = ""; + }; + AB3AF5F708DEDADD00C0AA42 = { + children = ( + AB3AFEAF08DF046600C0AA42, + AB3AF5F808DEDAEB00C0AA42, + ); + isa = PBXGroup; + name = Engine; + refType = 4; + sourceTree = ""; + }; + AB3AF5F808DEDAEB00C0AA42 = { + children = ( + AB8F394409545F2600B9F541, + AB3AF62208DEDB5700C0AA42, + AB3AF5F908DEDB3100C0AA42, + AB3AF5FA08DEDB3100C0AA42, + AB3AF5FB08DEDB3100C0AA42, + AB3AF5FC08DEDB3100C0AA42, + AB3AF5FD08DEDB3100C0AA42, + AB3AF5FE08DEDB3100C0AA42, + AB3AF5FF08DEDB3100C0AA42, + AB3AF9CE08DEE17600C0AA42, + AB3AF60008DEDB3100C0AA42, + AB3AF60308DEDB3100C0AA42, + AB6F059A0983A53200B8EBA0, + AB6F059B0983A53200B8EBA0, + ABD656380967A4FA0066981D, + AB3AF60508DEDB3100C0AA42, + AB3AF60608DEDB3100C0AA42, + AB2B5D4508E69D9000899067, + AB3AF60808DEDB3100C0AA42, + AB3AF60908DEDB3100C0AA42, + AB3AF60A08DEDB3100C0AA42, + ); + isa = PBXGroup; + name = Sources; + refType = 4; + sourceTree = ""; + }; + AB3AF5F908DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = "a-c.c"; + path = "../../src/a-c.c"; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF5FA08DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = baselayer.c; + path = ../../src/baselayer.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF5FB08DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = cache1d.c; + path = ../../src/cache1d.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF5FC08DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = compat.c; + path = ../../src/compat.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF5FD08DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = crc32.c; + path = ../../src/crc32.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF5FE08DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = defs.c; + path = ../../src/defs.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF5FF08DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = engine.c; + path = ../../src/engine.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60008DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = glbuild.c; + path = ../../src/glbuild.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60208DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = hightile.c; + path = ../../src/hightile.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60308DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = kplib.c; + path = ../../src/kplib.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60408DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = mdsprite.c; + path = ../../src/mdsprite.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60508DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = mmulti.c; + path = ../../src/mmulti.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60608DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = osd.c; + path = ../../src/osd.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60708DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = polymost.c; + path = ../../src/polymost.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60808DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = pragmas.c; + path = ../../src/pragmas.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60908DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = scriptfile.c; + path = ../../src/scriptfile.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60A08DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = sdlayer.c; + path = ../../src/sdlayer.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60B08DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = smalltextfont.c; + path = ../../src/smalltextfont.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60C08DEDB3100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = textfont.c; + path = ../../src/textfont.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF60D08DEDB3100C0AA42 = { + fileRef = AB3AF5F908DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF60E08DEDB3100C0AA42 = { + fileRef = AB3AF5FA08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF60F08DEDB3100C0AA42 = { + fileRef = AB3AF5FB08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61008DEDB3100C0AA42 = { + fileRef = AB3AF5FC08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61108DEDB3100C0AA42 = { + fileRef = AB3AF5FD08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61208DEDB3100C0AA42 = { + fileRef = AB3AF5FE08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61308DEDB3100C0AA42 = { + fileRef = AB3AF5FF08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61408DEDB3100C0AA42 = { + fileRef = AB3AF60008DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61708DEDB3100C0AA42 = { + fileRef = AB3AF60308DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61A08DEDB3100C0AA42 = { + fileRef = AB3AF60608DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61C08DEDB3100C0AA42 = { + fileRef = AB3AF60808DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61D08DEDB3100C0AA42 = { + fileRef = AB3AF60908DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF61E08DEDB3100C0AA42 = { + fileRef = AB3AF60A08DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF62108DEDB4F00C0AA42 = { + fileRef = AB3AF60508DEDB3100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF62208DEDB5700C0AA42 = { + children = ( + AB3AF60208DEDB3100C0AA42, + AB3AF60408DEDB3100C0AA42, + AB3AF60708DEDB3100C0AA42, + AB3AF60B08DEDB3100C0AA42, + AB3AF60C08DEDB3100C0AA42, + ); + isa = PBXGroup; + name = Included; + refType = 4; + sourceTree = ""; + }; + AB3AF62308DEDBBA00C0AA42 = { + children = ( + AB3AF64A08DEDC8600C0AA42, + AB3AF62408DEDBCD00C0AA42, + ); + isa = PBXGroup; + name = Frameworks; + refType = 4; + sourceTree = ""; + }; + AB3AF62408DEDBCD00C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = SDL.framework; + path = /Library/Frameworks/SDL.framework; + refType = 0; + sourceTree = ""; + }; + AB3AF64A08DEDC8600C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = OpenGL.framework; + path = /System/Library/Frameworks/OpenGL.framework; + refType = 0; + sourceTree = ""; + }; + AB3AF9CC08DEE11200C0AA42 = { + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + isa = PBXShellScriptBuildPhase; + outputPaths = ( + engineinfo.c, + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "source writeengineinfo.sh"; + }; + AB3AF9CE08DEE17600C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = engineinfo.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF9CF08DEE17600C0AA42 = { + fileRef = AB3AF9CE08DEE17600C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF9D008DEE1C400C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.script.sh; + path = writeengineinfo.sh; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF9D208DEE28200C0AA42 = { + children = ( + AB3AFEB208DF049300C0AA42, + AB3AF9D308DEE28800C0AA42, + ); + isa = PBXGroup; + name = Editor; + refType = 4; + sourceTree = ""; + }; + AB3AF9D308DEE28800C0AA42 = { + children = ( + AB3AF9D408DEE2B000C0AA42, + AB3AF9D608DEE2B000C0AA42, + ); + isa = PBXGroup; + name = Sources; + refType = 4; + sourceTree = ""; + }; + AB3AF9D408DEE2B000C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = build.c; + path = ../../src/build.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF9D608DEE2B000C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = config.c; + path = ../../src/config.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF9DA08DEE2CF00C0AA42 = { + buildActionMask = 2147483647; + files = ( + AB3AFEB408DF04B100C0AA42, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AF9DB08DEE2CF00C0AA42 = { + buildActionMask = 2147483647; + files = ( + AB3AF9DF08DEE33C00C0AA42, + AB3AF9E108DEE33D00C0AA42, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AF9DC08DEE2CF00C0AA42 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AF9DD08DEE2CF00C0AA42 = { + buildPhases = ( + AB3AF9DA08DEE2CF00C0AA42, + AB3AF9DB08DEE2CF00C0AA42, + AB3AF9DC08DEE2CF00C0AA42, + ); + buildRules = ( + ); + buildSettings = { + GCC_CHAR_IS_UNSIGNED_CHAR = YES; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_PREPROCESSOR_DEFINITIONS = "SUPERBUILD POLYMOST USE_OPENGL USE_A_C NOASM RENDERTYPESDL=1"; + HEADER_SEARCH_PATHS = ../../include; + LIBRARY_STYLE = STATIC; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = editor; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + ); + isa = PBXNativeTarget; + name = editor; + productName = editor; + productReference = AB3AF9DE08DEE2CF00C0AA42; + productType = "com.apple.product-type.library.static"; + }; + AB3AF9DE08DEE2CF00C0AA42 = { + explicitFileType = archive.ar; + includeInIndex = 0; + isa = PBXFileReference; + path = libeditor.a; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; + AB3AF9DF08DEE33C00C0AA42 = { + fileRef = AB3AF9D408DEE2B000C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF9E108DEE33D00C0AA42 = { + fileRef = AB3AF9D608DEE2B000C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFBF408DF03EE00C0AA42 = { + buildPhases = ( + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = All; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + AB3AFE8A08DF03F400C0AA42, + AB3AFE8C08DF03F400C0AA42, + ); + isa = PBXAggregateTarget; + name = All; + productName = All; + }; + AB3AFE8908DF03F400C0AA42 = { + containerPortal = AB3AF5EB08DEDAA700C0AA42; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = AB3AF5F408DEDABE00C0AA42; + remoteInfo = engine; + }; + AB3AFE8A08DF03F400C0AA42 = { + isa = PBXTargetDependency; + target = AB3AF5F408DEDABE00C0AA42; + targetProxy = AB3AFE8908DF03F400C0AA42; + }; + AB3AFE8B08DF03F400C0AA42 = { + containerPortal = AB3AF5EB08DEDAA700C0AA42; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = AB3AF9DD08DEE2CF00C0AA42; + remoteInfo = editor; + }; + AB3AFE8C08DF03F400C0AA42 = { + isa = PBXTargetDependency; + target = AB3AF9DD08DEE2CF00C0AA42; + targetProxy = AB3AFE8B08DF03F400C0AA42; + }; + AB3AFE9308DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = a.h; + path = ../../include/a.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9408DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = baselayer.h; + path = ../../include/baselayer.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9508DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = build.h; + path = ../../include/build.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9608DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = cache1d.h; + path = ../../include/cache1d.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9708DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = compat.h; + path = ../../include/compat.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9808DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = crc32.h; + path = ../../include/crc32.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9908DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = engineinfo.h; + path = ../../include/engineinfo.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9A08DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = glbuild.h; + path = ../../include/glbuild.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9B08DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = kplib.h; + path = ../../include/kplib.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9C08DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = mmulti.h; + path = ../../include/mmulti.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9D08DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = osd.h; + path = ../../include/osd.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9E08DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = pragmas.h; + path = ../../include/pragmas.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFE9F08DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = scriptfile.h; + path = ../../include/scriptfile.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFEA008DF044D00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = sdlayer.h; + path = ../../include/sdlayer.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFEA108DF044D00C0AA42 = { + fileRef = AB3AFE9308DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + AB3AFEA208DF044D00C0AA42 = { + fileRef = AB3AFE9408DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEA308DF044D00C0AA42 = { + fileRef = AB3AFE9508DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEA408DF044D00C0AA42 = { + fileRef = AB3AFE9608DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEA508DF044D00C0AA42 = { + fileRef = AB3AFE9708DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEA608DF044D00C0AA42 = { + fileRef = AB3AFE9808DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEA708DF044D00C0AA42 = { + fileRef = AB3AFE9908DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEA808DF044D00C0AA42 = { + fileRef = AB3AFE9A08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEA908DF044D00C0AA42 = { + fileRef = AB3AFE9B08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEAA08DF044D00C0AA42 = { + fileRef = AB3AFE9C08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEAB08DF044D00C0AA42 = { + fileRef = AB3AFE9D08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEAC08DF044D00C0AA42 = { + fileRef = AB3AFE9E08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEAD08DF044D00C0AA42 = { + fileRef = AB3AFE9F08DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEAE08DF044D00C0AA42 = { + fileRef = AB3AFEA008DF044D00C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB3AFEAF08DF046600C0AA42 = { + children = ( + AB3AFE9308DF044D00C0AA42, + AB3AFE9408DF044D00C0AA42, + AB3AFE9508DF044D00C0AA42, + AB3AFE9608DF044D00C0AA42, + AB3AFE9708DF044D00C0AA42, + AB3AFE9808DF044D00C0AA42, + AB3AFE9908DF044D00C0AA42, + AB3AFE9A08DF044D00C0AA42, + AB3AFE9B08DF044D00C0AA42, + AB6F05AD0983A5DD00B8EBA0, + AB6F05A00983A54D00B8EBA0, + ABD6563F0967A52B0066981D, + AB8F394709545F3800B9F541, + AB3AFE9C08DF044D00C0AA42, + AB3AFE9D08DF044D00C0AA42, + AB2B5D4808E69DB100899067, + AB3AFE9E08DF044D00C0AA42, + AB3AFE9F08DF044D00C0AA42, + AB3AFEA008DF044D00C0AA42, + ); + isa = PBXGroup; + name = Headers; + path = ""; + refType = 4; + sourceTree = ""; + }; + AB3AFEB208DF049300C0AA42 = { + children = ( + AB3AFEB308DF04B100C0AA42, + ); + isa = PBXGroup; + name = Headers; + refType = 4; + sourceTree = ""; + }; + AB3AFEB308DF04B100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = editor.h; + path = ../../include/editor.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFEB408DF04B100C0AA42 = { + fileRef = AB3AFEB308DF04B100C0AA42; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB6F059A0983A53200B8EBA0 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = lzf_c.c; + path = ../../src/lzf_c.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB6F059B0983A53200B8EBA0 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = lzf_d.c; + path = ../../src/lzf_d.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB6F059C0983A53200B8EBA0 = { + fileRef = AB6F059A0983A53200B8EBA0; + isa = PBXBuildFile; + settings = { + }; + }; + AB6F059D0983A53200B8EBA0 = { + fileRef = AB6F059B0983A53200B8EBA0; + isa = PBXBuildFile; + settings = { + }; + }; + AB6F059E0983A53200B8EBA0 = { + fileRef = AB6F059A0983A53200B8EBA0; + isa = PBXBuildFile; + settings = { + }; + }; + AB6F059F0983A53200B8EBA0 = { + fileRef = AB6F059B0983A53200B8EBA0; + isa = PBXBuildFile; + settings = { + }; + }; + AB6F05A00983A54D00B8EBA0 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = lzfP.h; + path = ../../src/lzfP.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB6F05A10983A54D00B8EBA0 = { + fileRef = AB6F05A00983A54D00B8EBA0; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + AB6F05A20983A54D00B8EBA0 = { + fileRef = AB6F05A00983A54D00B8EBA0; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Private, + ); + }; + }; + AB6F05AD0983A5DD00B8EBA0 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = lzf.h; + path = ../../include/lzf.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB6F05AE0983A5DD00B8EBA0 = { + fileRef = AB6F05AD0983A5DD00B8EBA0; + isa = PBXBuildFile; + settings = { + }; + }; + AB6F05AF0983A5DD00B8EBA0 = { + fileRef = AB6F05AD0983A5DD00B8EBA0; + isa = PBXBuildFile; + settings = { + }; + }; + AB8F394409545F2600B9F541 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = md4.c; + path = ../../src/md4.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB8F394509545F2600B9F541 = { + fileRef = AB8F394409545F2600B9F541; + isa = PBXBuildFile; + settings = { + }; + }; + AB8F394609545F2600B9F541 = { + fileRef = AB8F394409545F2600B9F541; + isa = PBXBuildFile; + settings = { + }; + }; + AB8F394709545F3800B9F541 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = md4.h; + path = ../../include/md4.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB8F394809545F3800B9F541 = { + fileRef = AB8F394709545F3800B9F541; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + AB8F394909545F3800B9F541 = { + fileRef = AB8F394709545F3800B9F541; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + ABD656380967A4FA0066981D = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = lzwnew.c; + path = ../../src/lzwnew.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + ABD656390967A4FA0066981D = { + fileRef = ABD656380967A4FA0066981D; + isa = PBXBuildFile; + settings = { + }; + }; + ABD6563A0967A4FA0066981D = { + fileRef = ABD656380967A4FA0066981D; + isa = PBXBuildFile; + settings = { + }; + }; + ABD6563F0967A52B0066981D = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = lzwnew.h; + path = ../../include/lzwnew.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + ABD656400967A52B0066981D = { + fileRef = ABD6563F0967A52B0066981D; + isa = PBXBuildFile; + settings = { + }; + }; + ABD656410967A52B0066981D = { + fileRef = ABD6563F0967A52B0066981D; + isa = PBXBuildFile; + settings = { + }; + }; + }; + rootObject = AB3AF5EB08DEDAA700C0AA42; +} diff --git a/polymer/build/osx/engine/engineinfo.c b/polymer/build/osx/engine/engineinfo.c new file mode 100644 index 000000000..c3d9bc194 --- /dev/null +++ b/polymer/build/osx/engine/engineinfo.c @@ -0,0 +1,5 @@ +const char _engine_cflags[] = ""; +const char _engine_libs[] = ""; +const char _engine_uname[] = "Darwin megumi.fnord 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power Macintosh powerpc"; +const char _engine_compiler[] = "gcc 3.3 ppc-darwin"; +const char _engine_date[] = __DATE__ " " __TIME__; diff --git a/polymer/build/osx/engine/writeengineinfo.sh b/polymer/build/osx/engine/writeengineinfo.sh new file mode 100644 index 000000000..068c43b26 --- /dev/null +++ b/polymer/build/osx/engine/writeengineinfo.sh @@ -0,0 +1,10 @@ +#!/bin/sh +UNAME=`uname -a` +CC="gcc" +CCVERSION=`$CC -dumpversion` +CCMACHINE=`$CC -dumpmachine` +echo "const char _engine_cflags[] = \"$OTHER_CFLAGS\";" > engineinfo.c +echo "const char _engine_libs[] = \"$LIBS\";" >> engineinfo.c +echo "const char _engine_uname[] = \"$UNAME\";" >> engineinfo.c +echo "const char _engine_compiler[] = \"$CC $CCVERSION $CCMACHINE\";" >> engineinfo.c +echo "const char _engine_date[] = __DATE__ \" \" __TIME__;" >> engineinfo.c diff --git a/polymer/build/osx/game/build.osxmain.h b/polymer/build/osx/game/build.osxmain.h new file mode 100644 index 000000000..4683df57a --- /dev/null +++ b/polymer/build/osx/game/build.osxmain.h @@ -0,0 +1,11 @@ +/* SDLMain.m - main entry point for our Cocoa-ized SDL app + Initial Version: Darrell Walisser + Non-NIB-Code & other changes: Max Horn + + Feel free to customize this file to suit your needs +*/ + +#import + +@interface SDLMain : NSObject +@end diff --git a/polymer/build/osx/game/build.osxmain.m b/polymer/build/osx/game/build.osxmain.m new file mode 100644 index 000000000..881c83f3c --- /dev/null +++ b/polymer/build/osx/game/build.osxmain.m @@ -0,0 +1,179 @@ +/* SDLMain.m - main entry point for our Cocoa-ized SDL app + Initial Version: Darrell Walisser + Non-NIB-Code & other changes: Max Horn + + Feel free to customize this file to suit your needs +*/ + +#import +#import "build.osxmain.h" +#import /* for MAXPATHLEN */ +#import + +static int gArgc; +static char **gArgv; +static BOOL gFinderLaunch; + +/* A helper category for NSString */ +@interface NSString (ReplaceSubString) +- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString; +@end + +@interface SDLApplication : NSApplication +@end + +@implementation SDLApplication +/* Invoked from the Quit menu item */ +- (void)terminate:(id)sender +{ + /* Post a SDL_QUIT event */ + SDL_Event event; + event.type = SDL_QUIT; + SDL_PushEvent(&event); +} +@end + + +/* The main class of the application, the application's delegate */ +@implementation SDLMain + +/* Set the working directory to the .app's parent directory */ +- (void) setupWorkingDirectory:(BOOL)shouldChdir +{ + char parentdir[MAXPATHLEN]; + char *c; + + strncpy ( parentdir, gArgv[0], sizeof(parentdir) ); + c = (char*) parentdir; + + while (*c != '\0') /* go to end */ + c++; + + while (*c != '/') /* back up to parent */ + c--; + + *c++ = '\0'; /* cut off last part (binary name) */ + + if (shouldChdir) + { + assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */ + assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */ + } +} + +/* Fix menu to contain the real app name instead of "SDL App" */ +- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName +{ + NSRange aRange; + NSEnumerator *enumerator; + NSMenuItem *menuItem; + + aRange = [[aMenu title] rangeOfString:@"SDL App"]; + if (aRange.length != 0) + [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]]; + + enumerator = [[aMenu itemArray] objectEnumerator]; + while ((menuItem = [enumerator nextObject])) + { + aRange = [[menuItem title] rangeOfString:@"SDL App"]; + if (aRange.length != 0) + [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]]; + if ([menuItem hasSubmenu]) + [self fixMenu:[menuItem submenu] withAppName:appName]; + } + [ aMenu sizeToFit ]; +} + +/* Called when the internal event loop has just started running */ +- (void) applicationDidFinishLaunching: (NSNotification *) note +{ + int status; + + /* Set the working directory to the .app's parent directory */ + [self setupWorkingDirectory:gFinderLaunch]; + + /* Set the main menu to contain the real app name instead of "SDL App" */ + //[self fixMenu:[NSApp mainMenu] withAppName:[[NSProcessInfo processInfo] processName]]; + [self fixMenu:[NSApp mainMenu] withAppName:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]]; + + /* Hand off to main application code */ + status = SDL_main (gArgc, gArgv); + + /* We're done, thank you for playing */ + exit(status); +} +@end + + +@implementation NSString (ReplaceSubString) + +- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString +{ + unsigned int bufferSize; + unsigned int selfLen = [self length]; + unsigned int aStringLen = [aString length]; + unichar *buffer; + NSRange localRange; + NSString *result; + + bufferSize = selfLen + aStringLen - aRange.length; + buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar)); + + /* Get first part into buffer */ + localRange.location = 0; + localRange.length = aRange.location; + [self getCharacters:buffer range:localRange]; + + /* Get middle part into buffer */ + localRange.location = 0; + localRange.length = aStringLen; + [aString getCharacters:(buffer+aRange.location) range:localRange]; + + /* Get last part into buffer */ + localRange.location = aRange.location + aRange.length; + localRange.length = selfLen - localRange.location; + [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange]; + + /* Build output string */ + result = [NSString stringWithCharacters:buffer length:bufferSize]; + + NSDeallocateMemoryPages(buffer, bufferSize); + + return result; +} + +@end + + + +#ifdef main +# undef main +#endif + + +/* Main entry point to executable - should *not* be SDL_main! */ +int main (int argc, char **argv) +{ + + /* Copy the arguments into a global variable */ + int i; + + /* This is passed if we are launched by double-clicking */ + if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { + gArgc = 1; + gFinderLaunch = YES; + } else { + gArgc = argc; + gFinderLaunch = NO; + } + gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1)); + assert (gArgv != NULL); + for (i = 0; i < gArgc; i++) + gArgv[i] = argv[i]; + gArgv[i] = NULL; + + [SDLApplication poseAsClass:[NSApplication class]]; + NSApplicationMain (argc, argv); + + return 0; +} diff --git a/polymer/build/osx/game/editor-Info.plist b/polymer/build/osx/game/editor-Info.plist new file mode 100644 index 000000000..f9528ec10 --- /dev/null +++ b/polymer/build/osx/game/editor-Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + build + CFBundleIdentifier + au.id.jonof.build + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSMainNibFile + osxmain + NSPrincipalClass + NSApplication + + diff --git a/polymer/build/osx/game/game-Info.plist b/polymer/build/osx/game/game-Info.plist new file mode 100644 index 000000000..708c3b2f3 --- /dev/null +++ b/polymer/build/osx/game/game-Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + game + CFBundleIdentifier + au.id.jonof.kenbuild + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSMainNibFile + osxmain + NSPrincipalClass + NSApplication + + diff --git a/polymer/build/osx/game/game.osxmain.h b/polymer/build/osx/game/game.osxmain.h new file mode 100644 index 000000000..4683df57a --- /dev/null +++ b/polymer/build/osx/game/game.osxmain.h @@ -0,0 +1,11 @@ +/* SDLMain.m - main entry point for our Cocoa-ized SDL app + Initial Version: Darrell Walisser + Non-NIB-Code & other changes: Max Horn + + Feel free to customize this file to suit your needs +*/ + +#import + +@interface SDLMain : NSObject +@end diff --git a/polymer/build/osx/game/game.osxmain.m b/polymer/build/osx/game/game.osxmain.m new file mode 100644 index 000000000..fec706b93 --- /dev/null +++ b/polymer/build/osx/game/game.osxmain.m @@ -0,0 +1,179 @@ +/* SDLMain.m - main entry point for our Cocoa-ized SDL app + Initial Version: Darrell Walisser + Non-NIB-Code & other changes: Max Horn + + Feel free to customize this file to suit your needs +*/ + +#import +#import "game.osxmain.h" +#import /* for MAXPATHLEN */ +#import + +static int gArgc; +static char **gArgv; +static BOOL gFinderLaunch; + +/* A helper category for NSString */ +@interface NSString (ReplaceSubString) +- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString; +@end + +@interface SDLApplication : NSApplication +@end + +@implementation SDLApplication +/* Invoked from the Quit menu item */ +- (void)terminate:(id)sender +{ + /* Post a SDL_QUIT event */ + SDL_Event event; + event.type = SDL_QUIT; + SDL_PushEvent(&event); +} +@end + + +/* The main class of the application, the application's delegate */ +@implementation SDLMain + +/* Set the working directory to the .app's parent directory */ +- (void) setupWorkingDirectory:(BOOL)shouldChdir +{ + char parentdir[MAXPATHLEN]; + char *c; + + strncpy ( parentdir, gArgv[0], sizeof(parentdir) ); + c = (char*) parentdir; + + while (*c != '\0') /* go to end */ + c++; + + while (*c != '/') /* back up to parent */ + c--; + + *c++ = '\0'; /* cut off last part (binary name) */ + + if (shouldChdir) + { + assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */ + assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */ + } +} + +/* Fix menu to contain the real app name instead of "SDL App" */ +- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName +{ + NSRange aRange; + NSEnumerator *enumerator; + NSMenuItem *menuItem; + + aRange = [[aMenu title] rangeOfString:@"SDL App"]; + if (aRange.length != 0) + [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]]; + + enumerator = [[aMenu itemArray] objectEnumerator]; + while ((menuItem = [enumerator nextObject])) + { + aRange = [[menuItem title] rangeOfString:@"SDL App"]; + if (aRange.length != 0) + [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]]; + if ([menuItem hasSubmenu]) + [self fixMenu:[menuItem submenu] withAppName:appName]; + } + [ aMenu sizeToFit ]; +} + +/* Called when the internal event loop has just started running */ +- (void) applicationDidFinishLaunching: (NSNotification *) note +{ + int status; + + /* Set the working directory to the .app's parent directory */ + [self setupWorkingDirectory:gFinderLaunch]; + + /* Set the main menu to contain the real app name instead of "SDL App" */ + //[self fixMenu:[NSApp mainMenu] withAppName:[[NSProcessInfo processInfo] processName]]; + [self fixMenu:[NSApp mainMenu] withAppName:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]]; + + /* Hand off to main application code */ + status = SDL_main (gArgc, gArgv); + + /* We're done, thank you for playing */ + exit(status); +} +@end + + +@implementation NSString (ReplaceSubString) + +- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString +{ + unsigned int bufferSize; + unsigned int selfLen = [self length]; + unsigned int aStringLen = [aString length]; + unichar *buffer; + NSRange localRange; + NSString *result; + + bufferSize = selfLen + aStringLen - aRange.length; + buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar)); + + /* Get first part into buffer */ + localRange.location = 0; + localRange.length = aRange.location; + [self getCharacters:buffer range:localRange]; + + /* Get middle part into buffer */ + localRange.location = 0; + localRange.length = aStringLen; + [aString getCharacters:(buffer+aRange.location) range:localRange]; + + /* Get last part into buffer */ + localRange.location = aRange.location + aRange.length; + localRange.length = selfLen - localRange.location; + [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange]; + + /* Build output string */ + result = [NSString stringWithCharacters:buffer length:bufferSize]; + + NSDeallocateMemoryPages(buffer, bufferSize); + + return result; +} + +@end + + + +#ifdef main +# undef main +#endif + + +/* Main entry point to executable - should *not* be SDL_main! */ +int main (int argc, char **argv) +{ + + /* Copy the arguments into a global variable */ + int i; + + /* This is passed if we are launched by double-clicking */ + if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { + gArgc = 1; + gFinderLaunch = YES; + } else { + gArgc = argc; + gFinderLaunch = NO; + } + gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1)); + assert (gArgv != NULL); + for (i = 0; i < gArgc; i++) + gArgv[i] = argv[i]; + gArgv[i] = NULL; + + [SDLApplication poseAsClass:[NSApplication class]]; + NSApplicationMain (argc, argv); + + return 0; +} diff --git a/polymer/build/osx/game/game.xcode/project.pbxproj b/polymer/build/osx/game/game.xcode/project.pbxproj new file mode 100644 index 000000000..b08e004bb --- /dev/null +++ b/polymer/build/osx/game/game.xcode/project.pbxproj @@ -0,0 +1,825 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 39; + objects = { + AB2B5CB408E698F600899067 = { + fileType = archive.ar; + isa = PBXReferenceProxy; + path = libenginez.a; + refType = 3; + remoteRef = AB2B5CB808E6992B00899067; + sourceTree = BUILT_PRODUCTS_DIR; + }; + AB2B5CB808E6992B00899067 = { + containerPortal = AB3AFA5F08DEE45000C0AA42; + isa = PBXContainerItemProxy; + proxyType = 2; + remoteGlobalIDString = AB2B5C9708E6979600899067; + remoteInfo = enginez; + }; + AB2B5D3708E69B7D00899067 = { + containerPortal = AB3AF9E808DEE39200C0AA42; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = AB3AFEC008DF04E300C0AA42; + remoteInfo = editor; + }; + AB2B5D3808E69B7D00899067 = { + isa = PBXTargetDependency; + target = AB3AFEC008DF04E300C0AA42; + targetProxy = AB2B5D3708E69B7D00899067; + }; + AB3A002208DF064900C0AA42 = { + fileRef = AB3AFABF08DF035400C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3A002408DF064900C0AA42 = { + fileRef = AB3AFA6F08DEE50200C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3A002508DF064900C0AA42 = { + fileRef = AB3AFA7308DEE53C00C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3A002608DF066200C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = archive.ar; + name = libeditor.a; + path = /Users/jonof/ports/build/osx/engine/build/libeditor.a; + refType = 0; + sourceTree = ""; + }; + AB3A002708DF066200C0AA42 = { + fileRef = AB3A002608DF066200C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AF9E408DEE39200C0AA42 = { + children = ( + AB3AFA5F08DEE45000C0AA42, + ABBC7AA3099344E40064C16C, + AB3AF9EE08DEE3A100C0AA42, + AB3AF9EC08DEE39A00C0AA42, + AB3AFA7908DEFECF00C0AA42, + AB3AF9F908DEE3EE00C0AA42, + ); + isa = PBXGroup; + refType = 4; + sourceTree = ""; + }; + AB3AF9E608DEE39200C0AA42 = { + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_OPTIMIZATION_LEVEL = 0; + }; + isa = PBXBuildStyle; + name = Development; + }; + AB3AF9E708DEE39200C0AA42 = { + buildSettings = { + COPY_PHASE_STRIP = YES; + DEPLOYMENT_POSTPROCESSING = YES; + GCC_OPTIMIZATION_LEVEL = 2; + }; + isa = PBXBuildStyle; + name = Deployment; + }; + AB3AF9E808DEE39200C0AA42 = { + buildSettings = { + }; + buildStyles = ( + AB3AF9E608DEE39200C0AA42, + AB3AF9E708DEE39200C0AA42, + ); + hasScannedForEncodings = 0; + isa = PBXProject; + mainGroup = AB3AF9E408DEE39200C0AA42; + productRefGroup = AB3AF9F908DEE3EE00C0AA42; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = ABBC7AA5099344E60064C16C; + ProjectRef = ABBC7AA3099344E40064C16C; + }, + { + ProductGroup = AB3AFA6208DEE45200C0AA42; + ProjectRef = AB3AFA5F08DEE45000C0AA42; + }, + ); + targets = ( + AB3AFBF108DF03C900C0AA42, + AB3AF9F708DEE3EE00C0AA42, + AB3AFEC008DF04E300C0AA42, + ); + }; + AB3AF9EC08DEE39A00C0AA42 = { + children = ( + AB3AF9ED08DEE39E00C0AA42, + AB3AFA7708DEFEC100C0AA42, + AB3AF9FB08DEE3EE00C0AA42, + ); + isa = PBXGroup; + name = Game; + refType = 4; + sourceTree = ""; + }; + AB3AF9ED08DEE39E00C0AA42 = { + children = ( + AB3AFA6D08DEE4D700C0AA42, + AB3AF9F108DEE3DA00C0AA42, + AB3AF9F208DEE3DA00C0AA42, + AB3AF9F308DEE3DA00C0AA42, + ABBC7A9A099344CF0064C16C, + ); + isa = PBXGroup; + name = Sources; + refType = 4; + sourceTree = ""; + }; + AB3AF9EE08DEE3A100C0AA42 = { + children = ( + AB3AF9EF08DEE3AB00C0AA42, + AB3AFEC308DF04E300C0AA42, + ); + isa = PBXGroup; + name = Editor; + refType = 4; + sourceTree = ""; + }; + AB3AF9EF08DEE3AB00C0AA42 = { + children = ( + AB3AFECC08DF059E00C0AA42, + AB3AF9F008DEE3C100C0AA42, + ); + isa = PBXGroup; + name = Sources; + refType = 4; + sourceTree = ""; + }; + AB3AF9F008DEE3C100C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = bstub.c; + path = ../../src/bstub.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF9F108DEE3DA00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = config.c; + path = ../../src/config.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF9F208DEE3DA00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = game.c; + path = ../../src/game.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF9F308DEE3DA00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = sound.c; + path = ../../src/sound.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AF9F408DEE3EE00C0AA42 = { + buildActionMask = 2147483647; + files = ( + AB3AFA7808DEFEC200C0AA42, + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AF9F508DEE3EE00C0AA42 = { + buildActionMask = 2147483647; + files = ( + AB3AFA5C08DEE43500C0AA42, + AB3AFA5D08DEE43500C0AA42, + AB3AFA6E08DEE4D700C0AA42, + ABBC7A9B099344CF0064C16C, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AF9F608DEE3EE00C0AA42 = { + buildActionMask = 2147483647; + files = ( + ABBC7B6409934A410064C16C, + AB3AFAC008DF035400C0AA42, + AB3AFB5708DF037500C0AA42, + AB3AFABE08DF030B00C0AA42, + AB3AFA7008DEE50200C0AA42, + AB3AFA7408DEE53C00C0AA42, + ABBC7B6609934A5A0064C16C, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AF9F708DEE3EE00C0AA42 = { + buildPhases = ( + AB3AF9F408DEE3EE00C0AA42, + AB3AF9F508DEE3EE00C0AA42, + AB3AF9F608DEE3EE00C0AA42, + ABBC7B40099347230064C16C, + ); + buildRules = ( + ); + buildSettings = { + FRAMEWORK_SEARCH_PATHS = /Users/jonof/ports/jfaud/osx/build; + GCC_CHAR_IS_UNSIGNED_CHAR = YES; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_PREPROCESSOR_DEFINITIONS = "SUPERBUILD POLYMOST USE_OPENGL NOASM RENDERTYPESDL=1"; + HEADER_SEARCH_PATHS = "/Developer/SDKs/fmodapi3741mac/api/inc ../../include"; + INFOPLIST_FILE = "game-Info.plist"; + INSTALL_PATH = "$(USER_APPS_DIR)"; + LIBRARY_SEARCH_PATHS = "/Developer/SDKs/fmodapi3741mac/api/lib ../engine/build"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = game; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + AB3AFAB608DF00A400C0AA42, + ); + isa = PBXNativeTarget; + name = game; + productName = game; + productReference = AB3AF9F808DEE3EE00C0AA42; + productSettingsXML = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + game + CFBundleIdentifier + com.yourcompany.game + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + +"; + productType = "com.apple.product-type.application"; + }; + AB3AF9F808DEE3EE00C0AA42 = { + explicitFileType = wrapper.application; + includeInIndex = 0; + isa = PBXFileReference; + path = game.app; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; + AB3AF9F908DEE3EE00C0AA42 = { + children = ( + AB3AF9F808DEE3EE00C0AA42, + AB3AFEC108DF04E300C0AA42, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = ""; + }; + AB3AF9FB08DEE3EE00C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = text.xml; + path = "game-Info.plist"; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFA5C08DEE43500C0AA42 = { + fileRef = AB3AF9F108DEE3DA00C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFA5D08DEE43500C0AA42 = { + fileRef = AB3AF9F208DEE3DA00C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFA5F08DEE45000C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = "wrapper.pb-project"; + name = engine.xcode; + path = ../engine/engine.xcode; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFA6208DEE45200C0AA42 = { + children = ( + AB3AFA6308DEE45200C0AA42, + AB3AFA6408DEE45200C0AA42, + AB2B5CB408E698F600899067, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = ""; + }; + AB3AFA6308DEE45200C0AA42 = { + fileType = archive.ar; + isa = PBXReferenceProxy; + path = libengine.a; + refType = 3; + remoteRef = AB3AFA6708DEE46200C0AA42; + sourceTree = BUILT_PRODUCTS_DIR; + }; + AB3AFA6408DEE45200C0AA42 = { + fileType = archive.ar; + isa = PBXReferenceProxy; + path = libeditor.a; + refType = 3; + remoteRef = AB3AFA6808DEE46200C0AA42; + sourceTree = BUILT_PRODUCTS_DIR; + }; + AB3AFA6708DEE46200C0AA42 = { + containerPortal = AB3AFA5F08DEE45000C0AA42; + isa = PBXContainerItemProxy; + proxyType = 2; + remoteGlobalIDString = AB3AF5F508DEDABE00C0AA42; + remoteInfo = engine; + }; + AB3AFA6808DEE46200C0AA42 = { + containerPortal = AB3AFA5F08DEE45000C0AA42; + isa = PBXContainerItemProxy; + proxyType = 2; + remoteGlobalIDString = AB3AF9DE08DEE2CF00C0AA42; + remoteInfo = editor; + }; + AB3AFA6D08DEE4D700C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = game.osxmain.m; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFA6E08DEE4D700C0AA42 = { + fileRef = AB3AFA6D08DEE4D700C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFA6F08DEE50200C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = OpenGL.framework; + path = /System/Library/Frameworks/OpenGL.framework; + refType = 0; + sourceTree = ""; + }; + AB3AFA7008DEE50200C0AA42 = { + fileRef = AB3AFA6F08DEE50200C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFA7308DEE53C00C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = SDL.framework; + path = /Library/Frameworks/SDL.framework; + refType = 0; + sourceTree = ""; + }; + AB3AFA7408DEE53C00C0AA42 = { + fileRef = AB3AFA7308DEE53C00C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFA7708DEFEC100C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + path = osxmain.nib; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFA7808DEFEC200C0AA42 = { + fileRef = AB3AFA7708DEFEC100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFA7908DEFECF00C0AA42 = { + children = ( + AB3A002608DF066200C0AA42, + AB3AFABD08DF030B00C0AA42, + ABBC7AD6099345F70064C16C, + AB3AFABF08DF035400C0AA42, + AB3AFB5608DF037500C0AA42, + ABBC7B6509934A5A0064C16C, + AB3AFA6F08DEE50200C0AA42, + AB3AFA7308DEE53C00C0AA42, + ); + isa = PBXGroup; + name = Frameworks; + refType = 4; + sourceTree = ""; + }; + AB3AFAB508DF00A400C0AA42 = { + containerPortal = AB3AFA5F08DEE45000C0AA42; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = AB3AF5F408DEDABE00C0AA42; + remoteInfo = engine; + }; + AB3AFAB608DF00A400C0AA42 = { + isa = PBXTargetDependency; + name = "engine (from engine.xcode)"; + targetProxy = AB3AFAB508DF00A400C0AA42; + }; + AB3AFABD08DF030B00C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = archive.ar; + name = libengine.a; + path = /Users/jonof/ports/build/osx/engine/build/libengine.a; + refType = 0; + sourceTree = ""; + }; + AB3AFABE08DF030B00C0AA42 = { + fileRef = AB3AFABD08DF030B00C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFABF08DF035400C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = AppKit.framework; + path = /System/Library/Frameworks/AppKit.framework; + refType = 0; + sourceTree = ""; + }; + AB3AFAC008DF035400C0AA42 = { + fileRef = AB3AFABF08DF035400C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFB5608DF037500C0AA42 = { + comments = "Needed for fmod to link."; + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = Carbon.framework; + path = /System/Library/Frameworks/Carbon.framework; + refType = 0; + sourceTree = ""; + }; + AB3AFB5708DF037500C0AA42 = { + fileRef = AB3AFB5608DF037500C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFBF108DF03C900C0AA42 = { + buildPhases = ( + ); + buildSettings = { + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = All; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + AB3AFBF308DF03D200C0AA42, + AB2B5D3808E69B7D00899067, + ); + isa = PBXAggregateTarget; + name = All; + productName = All; + }; + AB3AFBF208DF03D200C0AA42 = { + containerPortal = AB3AF9E808DEE39200C0AA42; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = AB3AF9F708DEE3EE00C0AA42; + remoteInfo = game; + }; + AB3AFBF308DF03D200C0AA42 = { + isa = PBXTargetDependency; + target = AB3AF9F708DEE3EE00C0AA42; + targetProxy = AB3AFBF208DF03D200C0AA42; + }; + AB3AFEBD08DF04E300C0AA42 = { + buildActionMask = 2147483647; + files = ( + AB3AFECE08DF05AE00C0AA42, + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AFEBE08DF04E300C0AA42 = { + buildActionMask = 2147483647; + files = ( + AB3AFECA08DF058D00C0AA42, + AB3AFECD08DF059E00C0AA42, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AFEBF08DF04E300C0AA42 = { + buildActionMask = 2147483647; + files = ( + AB3A002208DF064900C0AA42, + AB3A002708DF066200C0AA42, + AB3AFECF08DF063D00C0AA42, + AB3A002408DF064900C0AA42, + AB3A002508DF064900C0AA42, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + AB3AFEC008DF04E300C0AA42 = { + buildPhases = ( + AB3AFEBD08DF04E300C0AA42, + AB3AFEBE08DF04E300C0AA42, + AB3AFEBF08DF04E300C0AA42, + ); + buildRules = ( + ); + buildSettings = { + GCC_CHAR_IS_UNSIGNED_CHAR = YES; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_PREPROCESSOR_DEFINITIONS = "SUPERBUILD POLYMOST USE_OPENGL NOASM USE_A_C RENDERTYPESDL=1"; + HEADER_SEARCH_PATHS = ../../include; + INFOPLIST_FILE = "editor-Info.plist"; + INSTALL_PATH = "$(USER_APPS_DIR)"; + LIBRARY_SEARCH_PATHS = ../engine/build; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = build; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wno-four-char-constants -Wno-unknown-pragmas"; + }; + dependencies = ( + AB3AFEC508DF04EB00C0AA42, + AB3AFEC708DF04EB00C0AA42, + ); + isa = PBXNativeTarget; + name = editor; + productName = editor; + productReference = AB3AFEC108DF04E300C0AA42; + productSettingsXML = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + editor + CFBundleIdentifier + com.yourcompany.editor + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + +"; + productType = "com.apple.product-type.application"; + }; + AB3AFEC108DF04E300C0AA42 = { + explicitFileType = wrapper.application; + includeInIndex = 0; + isa = PBXFileReference; + path = build.app; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; + AB3AFEC308DF04E300C0AA42 = { + isa = PBXFileReference; + lastKnownFileType = text.xml; + path = "editor-Info.plist"; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFEC408DF04EB00C0AA42 = { + containerPortal = AB3AFA5F08DEE45000C0AA42; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = AB3AF5F408DEDABE00C0AA42; + remoteInfo = engine; + }; + AB3AFEC508DF04EB00C0AA42 = { + isa = PBXTargetDependency; + name = "engine (from engine.xcode)"; + targetProxy = AB3AFEC408DF04EB00C0AA42; + }; + AB3AFEC608DF04EB00C0AA42 = { + containerPortal = AB3AFA5F08DEE45000C0AA42; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = AB3AF9DD08DEE2CF00C0AA42; + remoteInfo = editor; + }; + AB3AFEC708DF04EB00C0AA42 = { + isa = PBXTargetDependency; + name = "editor (from engine.xcode)"; + targetProxy = AB3AFEC608DF04EB00C0AA42; + }; + AB3AFECA08DF058D00C0AA42 = { + fileRef = AB3AF9F008DEE3C100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFECC08DF059E00C0AA42 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = build.osxmain.m; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + AB3AFECD08DF059E00C0AA42 = { + fileRef = AB3AFECC08DF059E00C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFECE08DF05AE00C0AA42 = { + fileRef = AB3AFA7708DEFEC100C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + AB3AFECF08DF063D00C0AA42 = { + fileRef = AB3AFABD08DF030B00C0AA42; + isa = PBXBuildFile; + settings = { + }; + }; + ABBC7A9A099344CF0064C16C = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = jfaud_sound.cpp; + path = ../../src/jfaud_sound.cpp; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + ABBC7A9B099344CF0064C16C = { + fileRef = ABBC7A9A099344CF0064C16C; + isa = PBXBuildFile; + settings = { + }; + }; + ABBC7AA3099344E40064C16C = { + isa = PBXFileReference; + lastKnownFileType = "wrapper.pb-project"; + name = jfaud.xcode; + path = ../../../jfaud/osx/jfaud.xcode; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + ABBC7AA5099344E60064C16C = { + children = ( + ABBC7AA6099344E60064C16C, + ABBC7AA7099344E60064C16C, + ABBC7AA8099344E60064C16C, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = ""; + }; + ABBC7AA6099344E60064C16C = { + fileType = wrapper.framework; + isa = PBXReferenceProxy; + path = jfaud.framework; + refType = 3; + remoteRef = ABBC7AAA099344F50064C16C; + sourceTree = BUILT_PRODUCTS_DIR; + }; + ABBC7AA7099344E60064C16C = { + fileType = archive.ar; + isa = PBXReferenceProxy; + path = libmpadec.a; + refType = 3; + remoteRef = ABBC7AAB099344F50064C16C; + sourceTree = BUILT_PRODUCTS_DIR; + }; + ABBC7AA8099344E60064C16C = { + fileType = wrapper.application; + isa = PBXReferenceProxy; + path = jfaudtest.app; + refType = 3; + remoteRef = ABBC7AAC099344F50064C16C; + sourceTree = BUILT_PRODUCTS_DIR; + }; + ABBC7AAA099344F50064C16C = { + containerPortal = ABBC7AA3099344E40064C16C; + isa = PBXContainerItemProxy; + proxyType = 2; + remoteGlobalIDString = 8DC2EF5B0486A6940098B216; + remoteInfo = jfaud; + }; + ABBC7AAB099344F50064C16C = { + containerPortal = ABBC7AA3099344E40064C16C; + isa = PBXContainerItemProxy; + proxyType = 2; + remoteGlobalIDString = ABE7399C095277C50040A74A; + remoteInfo = mpadec; + }; + ABBC7AAC099344F50064C16C = { + containerPortal = ABBC7AA3099344E40064C16C; + isa = PBXContainerItemProxy; + proxyType = 2; + remoteGlobalIDString = ABE7394E09526A5B0040A74A; + remoteInfo = jfaudtest; + }; + ABBC7AD6099345F70064C16C = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = jfaud.framework; + path = /Users/jonof/ports/jfaud/osx/build/jfaud.framework; + refType = 0; + sourceTree = ""; + }; + ABBC7B40099347230064C16C = { + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ABBC7B410993474A0064C16C, + ); + isa = PBXCopyFilesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + ABBC7B410993474A0064C16C = { + fileRef = ABBC7AD6099345F70064C16C; + isa = PBXBuildFile; + settings = { + }; + }; + ABBC7B6409934A410064C16C = { + fileRef = ABBC7AD6099345F70064C16C; + isa = PBXBuildFile; + settings = { + }; + }; + ABBC7B6509934A5A0064C16C = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = OpenAL.framework; + path = ../../../../../../Library/Frameworks/OpenAL.framework; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + ABBC7B6609934A5A0064C16C = { + fileRef = ABBC7B6509934A5A0064C16C; + isa = PBXBuildFile; + settings = { + }; + }; + }; + rootObject = AB3AF9E808DEE39200C0AA42; +} diff --git a/polymer/build/osx/game/osxmain.nib/classes.nib b/polymer/build/osx/game/osxmain.nib/classes.nib new file mode 100644 index 000000000..b014bc964 --- /dev/null +++ b/polymer/build/osx/game/osxmain.nib/classes.nib @@ -0,0 +1,7 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + {ACTIONS = {}; CLASS = SDLMain; LANGUAGE = ObjC; SUPERCLASS = NSObject; } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/polymer/build/osx/game/osxmain.nib/info.nib b/polymer/build/osx/game/osxmain.nib/info.nib new file mode 100644 index 000000000..eb4b6a84b --- /dev/null +++ b/polymer/build/osx/game/osxmain.nib/info.nib @@ -0,0 +1,21 @@ + + + + + IBDocumentLocation + 52 97 356 240 0 0 1024 746 + IBEditorPositions + + 29 + 196 422 195 44 0 0 1024 746 + + IBFramework Version + 364.0 + IBOpenObjects + + 29 + + IBSystem Version + 7W98 + + diff --git a/polymer/build/osx/game/osxmain.nib/objects.nib b/polymer/build/osx/game/osxmain.nib/objects.nib new file mode 100644 index 000000000..7cdeb7ba7 Binary files /dev/null and b/polymer/build/osx/game/osxmain.nib/objects.nib differ diff --git a/polymer/build/rsrc/build.bmp b/polymer/build/rsrc/build.bmp new file mode 100644 index 000000000..6800c5365 Binary files /dev/null and b/polymer/build/rsrc/build.bmp differ diff --git a/polymer/build/rsrc/build.xcf b/polymer/build/rsrc/build.xcf new file mode 100644 index 000000000..a1ddd6d4e Binary files /dev/null and b/polymer/build/rsrc/build.xcf differ diff --git a/polymer/build/rsrc/build_icon.bmp b/polymer/build/rsrc/build_icon.bmp new file mode 100644 index 000000000..0244f3f79 Binary files /dev/null and b/polymer/build/rsrc/build_icon.bmp differ diff --git a/polymer/build/rsrc/build_icon.c b/polymer/build/rsrc/build_icon.c new file mode 100644 index 000000000..f08f95938 --- /dev/null +++ b/polymer/build/rsrc/build_icon.c @@ -0,0 +1,192 @@ +#include "sdlayer.h" + +static unsigned int sdlappicon_pixels[] = { + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff654848, 0xffad8484, + 0xffb18888, 0xffbb8f8f, 0xff936d6d, 0xff130303, 0xff987373, 0xff936d6d, + 0xff100000, 0xff815f5f, 0xffaa8181, 0xff362020, 0xffa98080, 0xff5c3f3f, + 0xff715252, 0xffb78b8b, 0xff130202, 0xff100000, 0xff2f1a1a, 0xffa07a7a, + 0xffb78c8c, 0xffbd9090, 0xff856262, 0xff140303, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff432a2a, 0xff825f5f, 0xff190808, 0xff4c3131, 0xffd5a2a2, 0xff2c1717, + 0xff7e5b5b, 0xff543939, 0xff100000, 0xff674848, 0xff6e4f4f, 0xff100000, + 0xffb58989, 0xff1c0a0a, 0xff513535, 0xff7f5d5d, 0xff100000, 0xff100000, + 0xff100000, 0xffa97f7f, 0xff271414, 0xff220f0f, 0xffbb8d8d, 0xff442b2b, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff432a2a, 0xffba8e8e, 0xffb88d8d, 0xffc19494, + 0xff987171, 0xff110101, 0xff7e5b5b, 0xff533939, 0xff100000, 0xff694949, + 0xff6e4f4f, 0xff100000, 0xffb08585, 0xff1c0a0a, 0xff513535, 0xff7b5a5a, + 0xff100000, 0xff100000, 0xff100000, 0xffa67c7c, 0xff261212, 0xff100000, + 0xff956e6e, 0xff704f4f, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff4c3232, 0xff896565, + 0xff261212, 0xff503535, 0xffd4a2a2, 0xff351e1e, 0xff755454, 0xff835f5f, + 0xff261111, 0xff936c6c, 0xff715050, 0xff160505, 0xffb28686, 0xff241111, + 0xff573a3a, 0xff836060, 0xff251111, 0xff674949, 0xff140303, 0xffa77e7e, + 0xff392222, 0xff3a2222, 0xffbf9191, 0xff3b2424, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff725252, 0xffb78a8a, 0xffc19292, 0xffba8c8c, 0xff866161, 0xff110101, + 0xff2c1818, 0xffb28585, 0xffc49393, 0xffab8080, 0xff261313, 0xff3f2727, + 0xffb18686, 0xff644545, 0xff7c5a5a, 0xffb98c8c, 0xffc09191, 0xffba8c8c, + 0xff341e1e, 0xffa77e7e, 0xffbf9090, 0xffba8d8d, 0xff745353, 0xff110101, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff272159, 0xff383793, 0xff3e3da3, 0xff2e286b, + 0xff2e296e, 0xff2a2157, 0xff100001, 0xff37358e, 0xff140611, 0xff353286, + 0xff3d3ca0, 0xff3f3c9f, 0xff180a1a, 0xff323080, 0xff353285, 0xff261e51, + 0xff322c75, 0xff100000, 0xff322e7b, 0xff1f153a, 0xff333284, 0xff3b3a9d, + 0xff403fa8, 0xff13040b, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff2e296d, 0xff251c4b, + 0xff1a0d25, 0xff110104, 0xff353284, 0xff5453db, 0xff1a0d22, 0xff3e3da6, + 0xff231a47, 0xff332f7d, 0xff150714, 0xff2c225b, 0xff1f1333, 0xff2b2461, + 0xff281f54, 0xff2a235d, 0xff5454df, 0xff251a44, 0xff38358f, 0xff211841, + 0xff332f7e, 0xff1c0f29, 0xff140611, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff2f296f, 0xff3e3ca0, 0xff332e7d, 0xff100000, 0xff363287, 0xff2d2667, + 0xff3f3ca0, 0xff4746bc, 0xff241b4a, 0xff2a235f, 0xff1e1436, 0xff3d3b9e, + 0xff1f1231, 0xff2a225d, 0xff271f52, 0xff2a2461, 0xff30296e, 0xff4441af, + 0xff4443b2, 0xff231944, 0xff3e3ea5, 0xff3c3998, 0xff1a0e25, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff302a73, 0xff2e2768, 0xff241b48, 0xff1e1232, + 0xff39358f, 0xff190d24, 0xff35307f, 0xff5150d4, 0xff22173f, 0xff4746b9, + 0xff2a2159, 0xff4947bd, 0xff261d4d, 0xff35307f, 0xff352f7d, 0xff2d2667, + 0xff261c4c, 0xff292158, 0xff5555df, 0xff231a47, 0xff38358f, 0xff251b49, + 0xff261c4c, 0xff110205, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff221842, 0xff2f286c, + 0xff2f286b, 0xff221840, 0xff383b78, 0xff292c43, 0xff2a2c43, 0xff4650a1, + 0xff252633, 0xff424a92, 0xff4650a3, 0xff3d4587, 0xff252634, 0xff404990, + 0xff40498f, 0xff363c6e, 0xff2f3458, 0xff252633, 0xff4851a4, 0xff1a0e26, + 0xff2d2666, 0xff2f286b, 0xff2e276a, 0xff110206, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff446281, 0xff527ea5, + 0xff4f799e, 0xff537fa6, 0xff517ca3, 0xff5a88b3, 0xff45698a, 0xff537fa7, + 0xff4e779b, 0xff5480a8, 0xff5581a9, 0xff5683ac, 0xff5987b1, 0xff5887b0, + 0xff547fa7, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff241d34, 0xff251f3c, 0xff1c101d, 0xff14080c, + 0xff4d5c85, 0xff546a96, 0xff4b5f87, 0xff36475f, 0xff5b6f86, 0xff507096, + 0xff405683, 0xff394d6e, 0xff51657c, 0xff556f92, 0xff405785, 0xff394e72, + 0xff435d86, 0xff466094, 0xff466095, 0xff261c33, 0xff211b3a, 0xff221d3b, + 0xff150913, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff170b1a, 0xff505cb1, 0xff363d88, + 0xff241e3f, 0xff31305e, 0xff45498c, 0xff424381, 0xff3c3c7e, 0xff2a295d, + 0xff6b72a4, 0xff2c2d76, 0xff2e2f7e, 0xff252565, 0xff6771a5, 0xff2c2d78, + 0xff2f3180, 0xff292970, 0xff424999, 0xff313188, 0xff2d2d7b, 0xff414a9c, + 0xff343490, 0xff2f2e7f, 0xff150b1c, 0xff100000, 0xff100103, 0xff150714, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff32305e, + 0xff3a3f98, 0xff394095, 0xff1e163c, 0xff3f3c77, 0xff323388, 0xff434991, + 0xff303082, 0xff39438f, 0xff313385, 0xff323481, 0xff3e4598, 0xff2d2e7d, + 0xff454ba0, 0xff2c2c7a, 0xff3b429e, 0xff2c2c79, 0xff4249ac, 0xff323289, + 0xff191532, 0xff4c51a2, 0xff393998, 0xff211e48, 0xff100104, 0xff100000, + 0xff180b1f, 0xff251c4a, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff4751a7, 0xff3b3b9e, 0xff424ea6, 0xff1f173f, 0xff3e4293, + 0xff363694, 0xff3b4598, 0xff353592, 0xff424793, 0xff373796, 0xff3b3f8f, + 0xff393a9b, 0xff393a89, 0xff4244a1, 0xff2d2f7a, 0xff27225c, 0xff272460, + 0xff4a50b1, 0xff3e3ea5, 0xff383b95, 0xff4b53c0, 0xff4343ae, 0xff3a3c98, + 0xff100206, 0xff100000, 0xff2a225b, 0xff1d112e, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff1a0e22, 0xff545bc6, 0xff3e42a0, 0xff464db5, + 0xff231b47, 0xff4f58b7, 0xff3e3ea3, 0xff4e53ab, 0xff393998, 0xff4045a8, + 0xff4040a7, 0xff3d4798, 0xff4141ab, 0xff3d459a, 0xff4242ad, 0xff3a4094, + 0xff4444b0, 0xff3c439c, 0xff4445b1, 0xff2d2c76, 0xff1d1736, 0xff4c54bf, + 0xff36358e, 0xff11030a, 0xff0f0000, 0xff100000, 0xff4547ab, 0xff1b0f29, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff3a3671, 0xff494bb6, + 0xff4c52a4, 0xff5052b1, 0xff2b2663, 0xff4b52c0, 0xff4445b1, 0xff4344af, + 0xff2d2a70, 0xff4d58be, 0xff3e3ea2, 0xff4149a6, 0xff4040a7, 0xff464da6, + 0xff4444b1, 0xff454ca2, 0xff4444b0, 0xff414ca1, 0xff4444b3, 0xff343585, + 0xff323473, 0xff4a4cc3, 0xff3f45a1, 0xff1e182d, 0xff100000, 0xff190e26, + 0xff758bf0, 0xff21173f, 0xff100000, 0xff100000, 0xff100000, 0xff100001, + 0xff5052af, 0xff4545b8, 0xff4e51bd, 0xff4444b4, 0xff36378f, 0xff525ac3, + 0xff333284, 0xff12050e, 0xff170915, 0xff4c52c6, 0xff4343b2, 0xff5053c2, + 0xff3a3a9c, 0xff4045aa, 0xff4848be, 0xff484abf, 0xff4242b0, 0xff3f45a6, + 0xff4545b7, 0xff4343b2, 0xff474cab, 0xff4545b9, 0xff4646bd, 0xff1f1a45, + 0xff160918, 0xff5e65c0, 0xffc4d6f6, 0xff4244a4, 0xff100103, 0xff100000, + 0xff100000, 0xff1a0e23, 0xff575cd5, 0xff4140aa, 0xff34307b, 0xff4949c3, + 0xff3d439f, 0xff4b4ec4, 0xff2b2666, 0xff100000, 0xff13040a, 0xff313279, + 0xff3f3fa9, 0xff3e41a5, 0xff333681, 0xff333183, 0xff4041ad, 0xff4248ae, + 0xff4751b6, 0xff5467ca, 0xff556bcc, 0xff5870d1, 0xff7385d6, 0xff7b87d3, + 0xff9096d5, 0xff969fd7, 0xffb6bef0, 0xffebeff9, 0xfffafafa, 0xffadc5f7, + 0xff5567c8, 0xff2e2768, 0xff100000, 0xff373872, 0xff5154d4, 0xff332e7a, + 0xff33326d, 0xff4d4dcf, 0xff474fa7, 0xff4444b4, 0xff2d2761, 0xff2a2751, + 0xff3a4186, 0xff4b52bb, 0xff535ed5, 0xff5762df, 0xff5666e6, 0xff5a66ef, + 0xff5b6bee, 0xff5b73d9, 0xff5062b6, 0xff444f9c, 0xff3d4685, 0xff373b71, + 0xff373769, 0xff433b67, 0xff433c66, 0xff433e70, 0xff7179d1, 0xffccd9f6, + 0xffd1dbf4, 0xff6166bd, 0xff201639, 0xff110205, 0xff100001, 0xff525abb, + 0xff5050d7, 0xff231a45, 0xff3c3a63, 0xff3d3da4, 0xff3e46a1, 0xff404ba1, + 0xff3f47a2, 0xff3f42a7, 0xff4545b7, 0xff4c4ccb, 0xff5050d7, 0xff4e4fd1, + 0xff393792, 0xff251c4d, 0xff160a1b, 0xff100103, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff1a0f29, 0xff6d87f4, 0xff5b67d8, 0xff150712, 0xff100000, 0xff100000, + 0xff1c1227, 0xff5b66de, 0xff4646bf, 0xff261f4e, 0xff3c4389, 0xff3c4599, + 0xff2f317c, 0xff2d2d7a, 0xff303081, 0xff34348f, 0xff383898, 0xff3b3b9e, + 0xff2a2a64, 0xff150817, 0xff0f0000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100103, 0xff5863e1, 0xff2e286a, 0xff100000, + 0xff100000, 0xff100000, 0xff38386d, 0xff4143aa, 0xff3f499e, 0xff374089, + 0xff2b2b73, 0xff2b2b75, 0xff2a2a73, 0xff2b2b74, 0xff2d2d7b, 0xff303081, + 0xff2c2e75, 0xff150f1c, 0xff0f0000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff4c4bc6, + 0xff150815, 0xff100000, 0xff100000, 0xff100000, 0xff3a438e, 0xff353f84, + 0xff262766, 0xff262665, 0xff262666, 0xff272769, 0xff272769, 0xff28286d, + 0xff292970, 0xff272769, 0xff120a0f, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100001, 0xff3a358f, 0xff0f0000, 0xff100000, 0xff100000, 0xff100000, + 0xff170e10, 0xff16060e, 0xff13050e, 0xff19060e, 0xff19070e, 0xff110103, + 0xff100002, 0xff100002, 0xff100002, 0xff100001, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff13050e, 0xff28215b, 0xff100000, 0xff100000, + 0xff100000, 0xff100000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000,}; + +static unsigned char sdlappicon_mask[] = { + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255,}; + +struct sdlappicon sdlappicon = { + 32,32, // width,height + sdlappicon_pixels, + sdlappicon_mask +}; diff --git a/polymer/build/rsrc/build_icon.ico b/polymer/build/rsrc/build_icon.ico new file mode 100644 index 000000000..d585cc156 Binary files /dev/null and b/polymer/build/rsrc/build_icon.ico differ diff --git a/polymer/build/rsrc/editor_banner.c b/polymer/build/rsrc/editor_banner.c new file mode 100644 index 000000000..eecb4c98c --- /dev/null +++ b/polymer/build/rsrc/editor_banner.c @@ -0,0 +1,2267 @@ +#include + + + + + + + +/* GdkPixbuf RGB C-Source image dump */ + +const GdkPixdata startbanner_pixdata = { + 0x47646b50, /* Pixbuf magic: 'GdkP' */ + 24 + 76160, /* header length + pixel_data length */ + 0x1010001, /* pixdata_type */ + 272, /* rowstride */ + 90, /* width */ + 280, /* height */ + /* pixel_data: */ + "\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\2\36E\2\36E\5\40H\2\36E\2\36E\2" + "\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\0\"M\4\37M\4\37M\0\"M" + "\4\37M\4\37M\0\"M\0\"M\4\37M\0\"M\0#O\0#O\0$P\0#O\0$P\0$P\14#Q\0%Q\0" + "$P\0$P\14#Q\0%Q\14#Q\0%Q\14#Q\14#Q\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\2'T\2'T" + "\2'T\14#Q\2'T\2'T\2'T\2'T\2'T\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X" + "\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\0\0\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\15@s\15@s\15@s\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\24" + "Cw\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\32G{\32" + "G{\32G{\34H|\32G{\32G{\35I}\35I}\35I}\35I}\34H|\20L\177\20L\177\20L\177" + "\35I}\22M\200\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202" + "\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\27P" + "\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\0\0\2\36E\2\36E\2\36E\2\36E" + "\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5" + "\40H\5\40H\5\40H\5\40H\0\"M\4\37M\4\37M\4\37M\4\37M\4\37M\0\"M\0\"M\0" + "#O\0\"M\14#Q\0$P\0$P\0$P\0#O\14#Q\0%Q\0$P\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\14" + "#Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2" + "'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12" + "+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\0\0\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\17At\15@s\17" + "At\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30" + "Ey\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\34H|\34H|\34H|\32G{\35I}\35I}\35" + "I}\20L\177\35I}\35I}\20L\177\20L\177\20L\177\22M\200\22M\200\22M\200" + "\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\27P" + "\203\27P\203\27P\203\27P\203\35I}\27P\203\27P\203\27P\203\27P\203\33" + "Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205" + "\33Q\205\33Q\205\0\0\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\5\40H" + "\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\0\"M\4\37M\0\"M\4\37" + "M\4\37M\4\37M\0\"M\4\37M\4\37M\0\"M\0#O\0\"M\0#O\0#O\0#O\0$P\0$P\0$P" + "\0%Q\14#Q\0$P\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\14" + "#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X" + "\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,ZK\312\363K\312\363\13,Z\13,Z\13,Z\0\0" + "\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\15@s\15@s\15@s\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23" + "Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\24Cw\30Ey\30" + "Ey\30Ey\32G{\32G{\32G{\34H|\34H|\34H|\35I}\35I}\35I}\35I}\34H|\20L\177" + "\20L\177\35I}\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\26O\202" + "\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P" + "\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33" + "Q\205\0\0\2\36E\5\40H\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40" + "H\5\40H\5\40H\5\40H\5\40H\5\40H\4\37M\0\"M\4\37M\4\37M\4\37M\4\37M\0" + "\"M\0\"M\4\37M\0\"M\14#Q\0\"M\0$P\0$P\0$P\0$P\0$P\14#Q\0$P\14#Q\0$P\0" + "%Q\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2'T\2'T\2" + "'T\2'T\2'T\2'T\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X" + "\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,ZK\312\363K\312\363\13,Z\13,Z\13,Z\0\0\11>q\11>" + "q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15" + "@s\15@s\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23" + "Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\34" + "H|\32G{\20L\177\34H|\32G{\35I}\35I}\35I}\34H|\20L\177\20L\177\20L\177" + "\35I}\22M\200\22M\200\24N\201\24N\201\24N\201\26O\202\26O\202\26O\202" + "\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P" + "\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33" + "Q\205\0\0\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40" + "H\5\40H\5\40H\4\37M\4\37M\0\"M\4\37M\4\37M\4\37M\4\37M\0\"M\0\"M\4\37" + "M\0\"M\0\"M\0#O\0\"M\0$P\0$P\0#O\0$P\0%Q\0$P\14#Q\0$P\14#Q\0%Q\0%Q\14" + "#Q\14#Q\0%Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2" + "'T\2'T\10*X\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12" + "+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\13,ZK\312\363K\312\363\13,Z\13,Z\13,Z\0\0\11>q\11>q\11>" + "q\11>q\11>q\11>q\11>q\11>q\15@s\11>q\11>q\15@s\15@s\15@s\15@s\15@s\17" + "At\15@s\15@s\17At\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24" + "Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\32G{\30Ey\34H|\34H|\32" + "G{\34H|\20L\177\35I}\35I}\34H|\35I}\20L\177\20L\177\35I}\20L\177\22M" + "\200\22M\200\24N\201\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202" + "\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P" + "\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33" + "Q\205\0\0\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\4\37" + "M\0\"M\4\37M\4\37M\4\37M\4\37M\4\37M\4\37M\0\"M\0\"M\4\37M\0\"M\0\"M" + "\0\"M\14#Q\0#O\0$P\0$P\0#O\0$P\0$P\0%Q\14#Q\0$P\0%Q\0%Q\14#Q\0%Q\14#" + "Q\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12" + "+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,ZK\312\363K\312\363\13,Z\13,Z\13,Z\0\0\11>q\11>q\11>q\11>" + "q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\15@s\15@s\15@s\15@s\15@s\17" + "At\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24" + "Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\30Ey\34H|\34H|\32G{\34H|\35" + "I}\35I}\34H|\35I}\35I}\20L\177\35I}\20L\177\20L\177\22M\200\22M\200\24" + "N\201\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203" + "\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33Q\205\0" + "\0\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\4\37M\4\37M\0\"M\4\37M\4\37M\4" + "\37M\0\"M\4\37M\4\37M\4\37M\4\37M\0\"M\4\37M\0\"M\0\"M\0\"M\0#O\0$P\0" + "$P\0$P\0$P\0$P\0$P\0%Q\0$P\14#Q\0%Q\0%Q\14#Q\0%Q\14#Q\14#Q\14#Q\14#Q" + "\14#Q\0%Q\14#Q\0%Q\14#Q\2'T\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12" + "+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15" + "-[\15-[K\312\363K\312\363\15-[\15-[\15-[\0\0\11>q\11>q\11>q\11>q\15@" + "s\15@s\15@s\15@s\15@s\15@s\15@s\15@s\15@s\15@s\15@s\17At\17At\17At\23" + "Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30Ey\24" + "Cw\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\34H|\34H|\34H|\32G{\34H|\35I}\35I}\35" + "I}\35I}\35I}\20L\177\35I}\35I}\22M\200\22M\200\22M\200\24N\201\24N\201" + "\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P" + "\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33Q\205\0\0\5" + "\40H\5\40H\5\40H\5\40H\4\37M\4\37M\4\37M\4\37M\0\"M\4\37M\4\37M\4\37" + "M\5\40H\4\37M\0\"M\0\"M\4\37M\0\"M\0#O\0\"M\0#O\0#O\0$P\0#O\0$P\0$P\14" + "#Q\0%Q\0%Q\14#Q\0$P\0%Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\14#Q\14#Q\0%Q\14#" + "Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\2'T\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[K" + "\312\363K\312\363\15-[\15-[\15-[\0\0\15@s\15@s\15@s\15@s\15@s\15@s\15" + "@s\15@s\15@s\15@s\15@s\15@s\15@s\17At\17At\17At\23Bv\23Bv\23Bv\23Bv\23" + "Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30" + "Ey\30Ey\32G{\30Ey\34H|\34H|\34H|\34H|\35I}\35I}\35I}\35I}\35I}\35I}\20" + "L\177\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\35I}\26O\202\26" + "O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33Q\205\0\0\0\"M\4" + "\37M\4\37M\4\37M\4\37M\0\"M\4\37M\0\"M\4\37M\4\37M\4\37M\0\"M\4\37M\0" + "\"M\4\37M\0\"M\0\"M\0\"M\0#O\0\"M\14#Q\0#O\0$P\0$P\14#Q\0$P\0%Q\14#Q" + "\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\2'" + "T\2'T\14#Q\2'T\2'T\2'T\2'T\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[K\312\363" + "K\312\363\15-[\15-[\15-[\0\0\15@s\15@s\15@s\15@s\15@s\15@s\15@s\15@s" + "\15@s\15@s\15@s\17At\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23" + "Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32" + "G{\30Ey\34H|\32G{\34H|\34H|\35I}\35I}\34H|\35I}\20L\177\20L\177\35I}" + "\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O" + "\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33Q\205\0" + "\0\0\"M\4\37M\5\40H\4\37M\4\37M\0\"M\4\37M\0\"M\4\37M\0\"M\0\"M\0\"M" + "\4\37M\0\"M\0#O\0\"M\0\"M\0#O\0$P\0#O\0$P\0#O\14#Q\14#Q\0$P\0%Q\0$P\0" + "%Q\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2" + "'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12" + "+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[K\312\363" + "K\312\363\15-[\15-[\15-[\0\0\15@s\15@s\15@s\15@s\15@s\15@s\15@s\15@s" + "\23Bv\17At\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24" + "Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\34" + "H|\34H|\34H|\34H|\20L\177\35I}\35I}\35I}\34H|\20L\177\20L\177\20L\177" + "\20L\177\22M\200\22M\200\22M\200\24N\201\26O\202\26O\202\26O\202\26O" + "\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33" + "Q\205\0\0\4\37M\4\37M\0\"M\4\37M\0\"M\4\37M\0\"M\0\"M\0\"M\4\37M\0\"" + "M\0#O\0#O\0\"M\0\"M\0\"M\0$P\0#O\0$P\0$P\0$P\14#Q\0%Q\14#Q\0%Q\0%Q\14" + "#Q\0%Q\0%Q\0%Q\14#Q\14#Q\14#Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\2'T\2'T\2'T\2" + "'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12" + "+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[K" + "\312\363K\312\363\15-[\15-[\15-[\0\0\15@s\15@s\15@s\15@s\15@s\17At\17" + "At\17At\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24" + "Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\32G{\30Ey\34" + "H|\34H|\34H|\34H|\35I}\34H|\35I}\35I}\35I}\20L\177\20L\177\35I}\22M\200" + "\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O" + "\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33" + "Q\205\0\0\4\37M\4\37M\0\"M\4\37M\4\37M\4\37M\0\"M\0\"M\0#O\14#Q\0\"M" + "\0\"M\0\"M\0\"M\0\"M\0$P\0$P\0$P\0#O\0$P\0$P\0%Q\14#Q\0%Q\0%Q\0%Q\0%" + "Q\0%Q\0%Q\14#Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\2'T\14#Q\2'T\14#Q\2'T\2" + "'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+" + "Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[K\312\363K\312\363\15-[\15-[\15-[\0\0\15@s\17At\17At\17At\17At\17A" + "t\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24" + "Cw\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\34" + "H|\34H|\20L\177\34H|\34H|\35I}\35I}\35I}\20L\177\20L\177\20L\177\35I" + "}\22M\200\35I}\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202" + "\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\34R" + "\206\34R\206\34R\206\34R\206\34R\206\34R\206K\312\363K\312\363\33Q\205" + "\33Q\205\33Q\205\0\0\0\"M\0\"M\4\37M\0\"M\4\37M\0\"M\0\"M\0\"M\14#Q\0" + "\"M\0$P\0#O\0$P\0#O\0$P\0$P\0$P\14#Q\0$P\0%Q\0$P\0%Q\14#Q\0%Q\14#Q\0" + "%Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T" + "\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y" + "\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\15-[\15-[\15-[" + "\15-[\15-[K\312\363K\312\363\15-[\15-[\15-[\0\0\17At\17At\17At\23Bv\23" + "Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24" + "Cw\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\20L\177" + "\34H|\34H|\34H|\34H|\20L\177\35I}\35I}\35I}\35I}\20L\177\20L\177\35I" + "}\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\35I}\26O\202" + "\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\34R" + "\206\34R\206\34R\206\34R\206\34R\206\34R\206\34R\206K\312\363K\312\363" + "\33Q\205\33Q\205\33Q\205\0\0\4\37M\0\"M\14#Q\0\"M\14#Q\0\"M\0\"M\0\"" + "M\0#O\0$P\0#O\0$P\0#O\0#O\0$P\14#Q\14#Q\14#Q\0$P\14#Q\0$P\0%Q\0%Q\0%" + "Q\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'" + "T\2'T\2'T\2'T\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12" + "+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17" + ".\\\15-[\15-[\15-[K\312\363K\312\363\15-[\15-[\15-[\0\0\23Bv\23Bv\23" + "Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\23Bv\23Bv\24Cw\23Bv\24Cw\24Cw\24" + "Cw\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\34" + "H|\34H|\34H|\34H|\34H|\35I}\20L\177\35I}\35I}\20L\177\35I}\20L\177\20" + "L\177\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202" + "\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\34R\206\34R\206\34R\206\34R\206\34R\206\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\34R\206\34R\206" + "K\312\363K\312\363\34R\206\33Q\205\33Q\205\0\0\0\"M\0\"M\0#O\0\"M\0\"" + "M\0$P\0#O\0$P\0#O\0$P\0#O\0#O\0#O\14#Q\0$P\14#Q\0$P\14#Q\0$P\0%Q\14#" + "Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\2'T\2'T\2" + "'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12" + "+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[K\312\363K\312\363\15-[\15-[\15" + "-[\0\0\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24" + "Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32" + "G{\30Ey\34H|\34H|\34H|\32G{\34H|\35I}\20L\177\35I}\20L\177\35I}\20L\177" + "\35I}\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202" + "\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\34R\206\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\34R\206\34R\206\34R\206K\312\363K\312\363\34R\206\33Q\205\33Q\205\0" + "\0\0\"M\0\"M\0\"M\0\"M\0$P\0$P\0$P\0$P\0$P\0#O\0$P\0%Q\14#Q\0$P\14#Q" + "\0$P\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%" + "Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[K" + "\312\363K\312\363\15-[\15-[\15-[\0\0\23Bv\23Bv\24Cw\23Bv\23Bv\23Bv\23" + "Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30" + "Ey\30Ey\30Ey\30Ey\30Ey\32G{\30Ey\34H|\34H|\34H|\34H|\35I}\34H|\35I}\34" + "H|\35I}\20L\177\20L\177\20L\177\20L\177\22M\200\35I}\24N\201\24N\201" + "\24N\201\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P" + "\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\34R\206K\312\363K\312" + "\363\34R\206\33Q\205\33Q\205\0\0\0$P\0#O\0#O\0$P\0$P\0#O\0$P\0$P\0$P" + "\0$P\14#Q\0%Q\14#Q\0%Q\14#Q\0$P\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\0" + "%Q\14#Q\14#Q\0%Q\14#Q\0%Q\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\K\312\363K\312\363\15-[\15-[\15-[\0\0\23" + "Bv\23Bv\24Cw\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24" + "Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\34H|\32G{\34" + "H|\32G{\35I}\35I}\35I}\35I}\20L\177\20L\177\35I}\20L\177\35I}\22M\200" + "\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P" + "\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R" + "\206\34R\206\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207K\312\363K\312\363\34R\206\33Q\205\33Q\205\0\0\0" + "$P\0#O\0$P\0#O\5\40H\0$P\0%Q\14#Q\0$P\0%Q\14#Q\0%Q\0$P\14#Q\0%Q\0%Q\0" + "%Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\14#Q\2'T" + "\2'T\14#Q\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10" + "*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15" + "-[K\312\363K\312\363\15-[\15-[\15-[\0\0\23Bv\23Bv\23Bv\23Bv\23Bv\24C" + "w\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\24Cw\30Ey\30Ey\30Ey\30" + "Ey\30Ey\30Ey\32G{\30Ey\34H|\20L\177\34H|\34H|\34H|\35I}\35I}\35I}\34" + "H|\20L\177\20L\177\35I}\20L\177\22M\200\22M\200\24N\201\24N\201\24N\201" + "\26O\202\26O\202\26O\202\35I}\27P\203\27P\203\27P\203\27P\203\27P\203" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\34R\206\34R\206" + "K\312\363K\312\363\33Q\205\33Q\205\33Q\205\0\0\0$P\0$P\0$P\0#O\14#Q\0" + "%Q\14#Q\0%Q\14#Q\0$P\14#Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\14" + "#Q\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T" + "\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13," + "Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[K\312\363K\312\363" + "\15-[\15-[\15-[\0\0\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24C" + "w\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\32G{\32" + "G{\34H|\32G{\34H|\35I}\35I}\35I}\20L\177\35I}\20L\177\20L\177\20L\177" + "\22M\200\35I}\22M\200\22M\200\24N\201\26O\202\26O\202\26O\202\26O\202" + "\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\34R\206\34R\206\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\34R\206\34R\206K\312\363K\312" + "\363\33Q\205\33Q\205\33Q\205\0\0\14#Q\14#Q\0$P\14#Q\14#Q\0$P\14#Q\0$" + "P\14#Q\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\14#Q\14#Q\14#Q\0%Q\0%Q\14#Q\0%Q" + "\14#Q\0%Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*" + "X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13" + ",Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17." + "\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[K\312\363K\312\363\15-" + "[\15-[\15-[\0\0\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24" + "Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\34H|\32G{\34H|\32" + "G{\20L\177\35I}\20L\177\35I}\35I}\35I}\20L\177\20L\177\20L\177\20L\177" + "\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O" + "\202\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R" + "\206\34R\206\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\34R\206\34R\206\33Q\205K\312\363" + "K\312\363\33Q\205\33Q\205\33Q\205\0\0\0$P\14#Q\0%Q\0$P\14#Q\0$P\14#Q" + "\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\0" + "%Q\14#Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[K\312\363K\312\363\15-" + "[\15-[\13,Z\0\0\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\24" + "Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\32G{\34H|\32G{\34H|\32" + "G{\35I}\35I}\20L\177\35I}\20L\177\20L\177\20L\177\20L\177\35I}\22M\200" + "\35I}\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203" + "\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\34R\206\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\34R\206\33Q\205\33Q\205\33Q\205K\312\363K\312" + "\363\33Q\205\33Q\205\33Q\205\0\0\14#Q\14#Q\0$P\0%Q\0$P\0$P\14#Q\0%Q\0" + "%Q\0%Q\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\0%Q\0%Q\0%Q\0%Q\2'" + "T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*" + "X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[K\312\363K\312\363\15-[\13," + "Z\13,Z\0\0\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\24Cw\30Ey\30" + "Ey\30Ey\30Ey\30Ey\30Ey\32G{\30Ey\34H|\20L\177\34H|\32G{\20L\177\32G{" + "\20L\177\35I}\34H|\35I}\20L\177\20L\177\20L\177\20L\177\22M\200\22M\200" + "\22M\200\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P" + "\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\34R\206\34R\206\34R\206\33Q\205\33Q\205" + "K\312\363K\312\363\33Q\205\33Q\205\33Q\205\0\0\14#Q\14#Q\0$P\14#Q\0%" + "Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\14#Q\14#Q\14#Q\14#Q\0%Q\14#Q\0%Q\14#" + "Q\0%Q\0%Q\0%Q\2'T\2'T\2'T\2'T\14#Q\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13" + ",Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15-[\15-[K\312\363" + "K\312\363\13,Z\13,Z\13,Z\0\0\24Cw\24Cw\24Cw\30Ey\24Cw\24Cw\30Ey\24Cw" + "\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\32G{\32G{\34H|\34H|\34H|\20" + "L\177\35I}\35I}\35I}\20L\177\35I}\20L\177\20L\177\20L\177\35I}\22M\200" + "\35I}\22M\200\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203" + "\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\34R\206\34R\206\33Q\205\33Q\205\33Q" + "\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33Q\205\0\0\14#Q\0%Q\0" + "%Q\14#Q\0%Q\0%Q\14#Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\14#Q\14#Q\14#Q\0" + "%Q\14#Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13" + ",Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[K\312\363K\312\363\13,Z\13,Z\13,Z\0\0\30Ey\24Cw\24Cw\30Ey\30Ey\30E" + "y\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\30Ey\34H|\34H|\32G{\34" + "H|\20L\177\35I}\35I}\35I}\35I}\35I}\35I}\20L\177\20L\177\35I}\35I}\22" + "M\200\22M\200\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203" + "\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\34R\206\34R\206\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\27P\203\0\0\0" + "%Q\14#Q\0%Q\0%Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\14#Q\14#Q\14#Q\0%Q\14#Q\0" + "%Q\0%Q\14#Q\0%Q\14#Q\2'T\2'T\2'T\2'T\14#Q\2'T\2'T\2'T\2'T\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\13,ZK\312\363K\312\363\13,Z\12+Y\12+Y\0\0\30Ey\30Ey\24Cw\30E" + "y\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\32G{\32G{\32G{\34H|\34H|\34" + "H|\34H|\34H|\35I}\34H|\35I}\35I}\35I}\35I}\20L\177\20L\177\22M\200\35" + "I}\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\27P\203\27" + "P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\34R\206\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\27P\203\27" + "P\203\0\0\14#Q\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\14#Q\14#Q\14#Q\0%Q\14#Q\14" + "#Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X" + "\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\13,Z\13,Z\13,ZK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\30E" + "y\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\32G{\32G{\34H|\20" + "L\177\32G{\32G{\34H|\34H|\35I}\20L\177\35I}\35I}\35I}\20L\177\20L\177" + "\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O" + "\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\34R\206\34R\206\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\34R\206\34R\206" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205K\312" + "\363K\312\363\27P\203\27P\203\26O\202\0\0\0%Q\0%Q\14#Q\14#Q\0%Q\0%Q\14" + "#Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2'T\2'T\2" + "'T\2'T\2'T\2'T\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y" + "\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\15-[\15-[\15-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,ZK\312\363K\312" + "\363\12+Y\12+Y\10*X\0\0\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{" + "\30Ey\32G{\32G{\34H|\32G{\34H|\32G{\34H|\35I}\35I}\35I}\35I}\35I}\20" + "L\177\20L\177\20L\177\20L\177\22M\200\22M\200\22M\200\35I}\24N\201\26" + "O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\34R\206\34R\206\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\34R\206\34R\206\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205K\312\363K\312\363\27P\203\26O\202\26O\202\0\0\14" + "#Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q" + "\0%Q\2'T\2'T\2'T\2'T\14#Q\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13" + ",Z\13,Z\12+YK\312\363K\312\363\10*X\10*X\10*X\0\0\30Ey\30Ey\30Ey\30E" + "y\30Ey\30Ey\30Ey\32G{\30Ey\32G{\34H|\34H|\32G{\20L\177\34H|\34H|\20L" + "\177\35I}\34H|\35I}\35I}\20L\177\20L\177\20L\177\20L\177\22M\200\22M" + "\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203" + "\27P\203\27P\203\27P\203\27P\203\33Q\205\27P\203\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\34R\206" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\34R\206\34R\206\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P\203K\312\363" + "K\312\363\26O\202\26O\202\26O\202\0\0\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#" + "Q\14#Q\0%Q\14#Q\14#Q\0%Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'" + "T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+" + "Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-" + "[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+YK\312\363K\312" + "\363\10*X\10*X\10*X\0\0\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\32G{\30Ey" + "\34H|\34H|\34H|\32G{\32G{\34H|\34H|\35I}\34H|\35I}\20L\177\20L\177\20" + "L\177\35I}\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\26O\202\26" + "O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\34R\206\34R\206\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\34R\206\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\27P\203\27P\203\27P\203K\312\363K\312\363\26O\202\24N\201\24N\201" + "\0\0\14#Q\14#Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\0" + "%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X" + "\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\13" + ",Z\12+Y\12+Y\12+Y\10*XK\312\363K\312\363\10*X\10*X\10*X\0\0\30Ey\30E" + "y\30Ey\30Ey\30Ey\32G{\30Ey\30Ey\32G{\34H|\32G{\20L\177\34H|\34H|\34H" + "|\35I}\35I}\20L\177\35I}\20L\177\35I}\20L\177\20L\177\22M\200\35I}\22" + "M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203" + "\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\34R\206\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\34R\206\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\27P\203\27P\203\27P\203\26O\202\26O\202" + "K\312\363K\312\363\24N\201\22M\200\22M\200\0\0\14#Q\0%Q\14#Q\14#Q\0%" + "Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2" + "'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12" + "+Y\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15-[\15" + "-[\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\10*X\10*X\10*XK\312\363K\312" + "\363\2'T\10*X\2'T\0\0\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\32G{\32G{\34H|\34" + "H|\32G{\34H|\34H|\20L\177\35I}\20L\177\35I}\35I}\20L\177\20L\177\20L" + "\177\35I}\22M\200\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26" + "O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205" + "\33Q\205\33Q\205\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R" + "\206\34R\206\34R\206\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\34R\206\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P\203\27P" + "\203\27P\203\26O\202\26O\202\26O\202K\312\363K\312\363\22M\200\20L\177" + "\35I}\0\0\0%Q\14#Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\2" + "'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*" + "X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15" + "-[\15-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\12" + "+Y\10*X\10*X\10*X\10*XK\312\363K\312\363\2'T\2'T\2'T\0\0\30Ey\30Ey\32" + "G{\30Ey\32G{\32G{\34H|\32G{\34H|\34H|\34H|\32G{\35I}\35I}\34H|\35I}\35" + "I}\35I}\35I}\20L\177\20L\177\22M\200\35I}\22M\200\24N\201\24N\201\26" + "O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\34R\206\34R\206\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\34R\206\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P" + "\203\27P\203\27P\203\26O\202\26O\202\26O\202\24N\201\24N\201K\312\363" + "K\312\363\35I}\20L\177\35I}\0\0\14#Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\0" + "%Q\0%Q\14#Q\0%Q\2'T\2'T\2'T\2'T\14#Q\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\" + "\17.\\\15-[\15-[\15-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\12" + "+Y\12+Y\12+Y\10*X\10*X\10*X\10*X\10*X\10*XK\312\363K\312\363\2'T\2'T" + "\2'T\0\0\30Ey\32G{\32G{\32G{\32G{\32G{\34H|\20L\177\32G{\34H|\34H|\35" + "I}\20L\177\35I}\35I}\35I}\20L\177\20L\177\20L\177\20L\177\35I}\22M\200" + "\22M\200\24N\201\35I}\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203" + "\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\27P\203\27P\203\27P\203\26O\202\26O\202\26O\202\26O\202" + "\24N\201\22M\200\22M\200K\312\363K\312\363\35I}\35I}\35I}\0\0\0%Q\0%" + "Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2'T\14#Q\2'T\2'T\2'" + "T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+" + "Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15-[\15-[\15-[\13,Z\13" + ",Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\10*X\10*X\10*X\10*X\10*X\10*X\2'T\2" + "'TK\312\363K\312\363\14#Q\2'T\0%Q\0\0\30Ey\30Ey\32G{\32G{\34H|\34H|\34" + "H|\32G{\34H|\34H|\20L\177\35I}\35I}\35I}\35I}\20L\177\35I}\20L\177\20" + "L\177\35I}\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26" + "O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\34R\206\34R\206\36S\207\36S\207\36S\207\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\34R" + "\206\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\27P\203\27P\203\27P\203\26O\202\26O\202\26O" + "\202\26O\202\24N\201\22M\200\35I}\20L\177\20L\177K\312\363K\312\363\35" + "I}\34H|\20L\177\0\0\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\14#Q\2'T\2" + "'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17.\\\17" + ".\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15-[\15-" + "[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\12+Y\10*X\10*X\10*X\14" + "#Q\10*X\10*X\2'T\2'T\2'TK\312\363K\312\363\0%Q\14#Q\0%Q\0\0\30Ey\32G" + "{\32G{\32G{\34H|\34H|\32G{\20L\177\34H|\34H|\35I}\35I}\35I}\35I}\35I" + "}\35I}\20L\177\35I}\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\26" + "O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206\34R\206\36S\207\36S\207" + "\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\36S" + "\207\34R\206\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P\203\27P\203\26O" + "\202\26O\202\26O\202\24N\201\22M\200\22M\200\35I}\20L\177\20L\177\35" + "I}K\312\363K\312\363\32G{\34H|\32G{\0\0\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%" + "Q\0%Q\0%Q\2'T\2'T\14#Q\2'T\2'T\14#Q\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13" + ",Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\17.\\\17.\\" + "\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[" + "\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\10*X\10" + "*X\10*X\10*X\10*X\10*X\2'T\2'T\2'T\2'T\2'TK\312\363K\312\363\14#Q\0%" + "Q\0%Q\0\0\30Ey\32G{\20L\177\34H|\34H|\20L\177\34H|\34H|\32G{\34H|\35" + "I}\35I}\34H|\35I}\20L\177\20L\177\20L\177\35I}\22M\200\35I}\22M\200\24" + "N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203" + "\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\34R\206" + "\34R\206\34R\206\36S\207\36S\207\36S\207\36S\207\36S\207\36S\207\34R" + "\206\34R\206\34R\206\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P\203\27P" + "\203\26O\202\26O\202\26O\202\26O\202\24N\201\22M\200\22M\200\35I}\20" + "L\177\20L\177\35I}\35I}K\312\363K\312\363\32G{\30Ey\30Ey\0\0\0%Q\14#" + "Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\2'T\2'T\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\13" + ",Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\17.\\\17.\\\17.\\\17.\\\17.\\\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\10*X\10" + "*X\10*X\10*X\10*X\10*X\2'T\2'T\2'T\2'T\2'T\2'T\0%QK\312\363K\312\363" + "\14#Q\0%Q\0%Q\0\0\32G{\30Ey\34H|\32G{\34H|\20L\177\34H|\34H|\34H|\35" + "I}\35I}\35I}\35I}\20L\177\35I}\20L\177\20L\177\20L\177\35I}\22M\200\24" + "N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203" + "\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\34R\206\34R\206\34R\206\34R\206\34R\206\34R\206\34R\206\34R\206\34R" + "\206\34R\206\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P\203\35I}\26O\202" + "\26O\202\26O\202\26O\202\24N\201\22M\200\22M\200\20L\177\20L\177\35I" + "}\35I}\35I}\32G{\34H|K\312\363K\312\363\30Ey\30Ey\30Ey\0\0\14#Q\0%Q\0" + "%Q\0%Q\0%Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\14#Q\2'T\2'T\2'T\2'T\10*X\10*" + "X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\10*X\10*X\10*X\10*X\10" + "*X\10*X\10*X\2'T\2'T\2'T\2'T\2'T\14#Q\0%Q\14#QK\312\363K\312\363\0%Q" + "\0%Q\14#Q\0\0\32G{\34H|\32G{\34H|\32G{\34H|\20L\177\35I}\20L\177\35I" + "}\35I}\35I}\35I}\20L\177\35I}\20L\177\20L\177\22M\200\22M\200\22M\200" + "\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P" + "\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\34R\206\34R\206\34R\206\34R\206\34R\206\34R\206\34R\206\34R\206" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\27P\203\33Q\205\33Q\205\27P\203\27P\203\27P\203\26O\202\26O\202" + "\26O\202\26O\202\24N\201\22M\200\35I}\20L\177\20L\177\20L\177\35I}\20" + "L\177\34H|\34H|\32G{\32G{K\312\363K\312\363\30Ey\24Cw\24Cw\0\0\14#Q\0" + "%Q\14#Q\0%Q\0%Q\14#Q\0%Q\2'T\2'T\2'T\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'" + "T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\13" + ",Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\12+Y\10*X\10*X\10*X\10*X\10" + "*X\10*X\2'T\2'T\2'T\2'T\2'T\0%Q\0%Q\0%Q\0%Q\0%QK\312\363K\312\363\14" + "#Q\14#Q\0#O\0\0\32G{\34H|\34H|\34H|\34H|\34H|\34H|\35I}\34H|\35I}\35" + "I}\35I}\20L\177\35I}\20L\177\20L\177\22M\200\22M\200\22M\200\24N\201" + "\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P" + "\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\27P\203\27P\203\27P\203\26O\202\26O\202\26O\202" + "\24N\201\24N\201\22M\200\22M\200\35I}\20L\177\35I}\35I}\35I}\32G{\34" + "H|\30Ey\30Ey\30EyK\312\363K\312\363\24Cw\24Cw\24Cw\0\0\0%Q\0%Q\0%Q\14" + "#Q\0%Q\14#Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\2'T\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\12+Y\12+Y\12+Y\10*X\10*X\10*X\10*X\10*X\10*X\10*X\2'T\2" + "'T\2'T\2'T\2'T\14#Q\0%Q\14#Q\14#Q\14#Q\0%QK\312\363K\312\363\0%Q\0$P" + "\0$P\0\0\34H|\34H|\20L\177\34H|\34H|\34H|\34H|\35I}\20L\177\35I}\35I" + "}\34H|\20L\177\20L\177\35I}\20L\177\22M\200\22M\200\24N\201\24N\201\26" + "O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203" + "\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\27P\203\27P\203\27P\203\26O\202\26O\202\26O\202\24N\201\24N\201\22M" + "\200\22M\200\35I}\35I}\35I}\35I}\35I}\32G{\34H|\32G{\32G{\30Ey\24Cw\24" + "CwK\312\363K\312\363\23Bv\23Bv\23Bv\0\0\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\2'" + "T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\14#Q\10*X\10*X\10*X" + "\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12" + "+Y\12+Y\10*X\10*X\10*X\10*X\10*X\10*X\2'T\2'T\2'T\2'T\2'T\14#Q\0%Q\0" + "%Q\0%Q\0%Q\14#Q\0%Q\0%Q\0$PK\312\363K\312\363\0$P\0\"M\4\37M\0\0\34H" + "|\20L\177\34H|\32G{\34H|\20L\177\35I}\35I}\34H|\35I}\35I}\20L\177\20" + "L\177\20L\177\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\26O\202" + "\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\35I}\27P\203" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P\203\27P\203" + "\27P\203\26O\202\26O\202\35I}\24N\201\22M\200\22M\200\20L\177\20L\177" + "\35I}\35I}\34H|\34H|\32G{\34H|\30Ey\30Ey\30Ey\30Ey\24Cw\24CwK\312\363" + "K\312\363\23Bv\23Bv\17At\0\0\0%Q\0%Q\0%Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T" + "\14#Q\2'T\2'T\2'T\2'T\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12" + "+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\12+Y\10*X\10*X\10" + "*X\10*X\10*X\2'T\2'T\2'T\2'T\2'T\2'T\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\0%Q\0" + "%Q\0%Q\14#QK\312\363K\312\363\0#O\0\"M\4\37M\0\0\32G{\34H|\34H|\20L\177" + "\34H|\20L\177\35I}\35I}\34H|\35I}\35I}\35I}\20L\177\20L\177\22M\200\22" + "M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202" + "\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\27P\203\27P\203\27P\203\27P\203\26O\202\26O\202\26O\202\24N" + "\201\22M\200\22M\200\20L\177\20L\177\20L\177\35I}\35I}\32G{\34H|\34H" + "|\32G{\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23BvK\312\363K\312\363\17At\15@" + "s\15@s\0\0\0%Q\0%Q\14#Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2" + "'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12" + "+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\12+Y\12+Y\12+Y\12+Y\10*X\10*X\10*X\10*X\10*X\10*X\2'T\2'T\2'" + "T\2'T\2'T\2'T\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\14#Q\0$P\14#Q\0#O\0\"MK\312\363" + "K\312\363\0\"M\4\37M\5\40H\0\0\34H|\32G{\34H|\32G{\32G{\35I}\34H|\35" + "I}\35I}\35I}\20L\177\20L\177\20L\177\20L\177\22M\200\22M\200\24N\201" + "\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P" + "\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P\203\27P" + "\203\27P\203\26O\202\26O\202\26O\202\24N\201\24N\201\22M\200\22M\200" + "\35I}\20L\177\35I}\35I}\35I}\32G{\34H|\30Ey\30Ey\30Ey\30Ey\30Ey\24Cw" + "\24Cw\23Bv\23Bv\23BvK\312\363K\312\363\15@s\11>q\11>q\0\0\0%Q\14#Q\0" + "%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\14#Q\10*X\10" + "*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\15" + "-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\12+Y\10" + "*X\10*X\10*X\10*X\10*X\10*X\2'T\2'T\2'T\2'T\14#Q\2'T\14#Q\0%Q\0%Q\14" + "#Q\14#Q\0%Q\0%Q\14#Q\0$P\0#O\0#O\0\"M\0\"MK\312\363K\312\363\4\37M\5" + "\40H\0\"M\0\0\34H|\34H|\32G{\32G{\35I}\20L\177\35I}\20L\177\35I}\20L" + "\177\20L\177\20L\177\35I}\20L\177\22M\200\22M\200\24N\201\24N\201\26" + "O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\35I}\27P\203\27" + "P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\27P\203\27P\203\27P\203\27P\203\26O\202\26O\202\26O" + "\202\35I}\24N\201\35I}\22M\200\20L\177\20L\177\35I}\35I}\35I}\34H|\34" + "H|\34H|\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17At\15@sK\312\363" + "K\312\363\11>q\11>q\11>q\0\0\0%Q\14#Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'" + "T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12" + "+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\15-[\15" + "-[\15-[\15-[\15-[\15-[\15-[\15-[\15-[\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\12+Y\12+Y\12+Y\12+Y\10*X\10*X\10*X\10*X\10*X\10*X\10*X\2'T\2" + "'T\14#Q\2'T\2'T\0%Q\0%Q\14#Q\14#Q\14#Q\14#Q\0%Q\0$P\0%Q\14#Q\0#O\0\"" + "M\0\"M\0\"M\4\37MK\312\363K\312\363\5\40H\2\36E\5\40H\0\0\32G{\34H|\34" + "H|\20L\177\35I}\35I}\35I}\34H|\35I}\20L\177\20L\177\20L\177\20L\177\22" + "M\200\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202" + "\26O\202\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P\203\27P\203" + "\27P\203\26O\202\26O\202\26O\202\26O\202\24N\201\22M\200\22M\200\20L" + "\177\20L\177\20L\177\35I}\35I}\34H|\32G{\34H|\32G{\30Ey\30Ey\24Cw\24" + "Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17At\17At\15@sK\312\363K\312\363\11>q\11" + ">q\6=p\0\0\0%Q\0%Q\0%Q\0%Q\2'T\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10" + "*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+Y\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\12+Y\12+Y\12+Y\12+Y\10" + "*X\10*X\10*X\10*X\10*X\10*X\2'T\2'T\2'T\2'T\2'T\2'T\0%Q\0%Q\0%Q\0%Q\0" + "%Q\14#Q\0%Q\0$P\0%Q\0$P\0#O\0$P\0\"M\4\37M\4\37M\4\37M\5\40HK\312\363" + "K\312\363\5\40H\2\36E\2\36E\0\0\32G{\34H|\32G{\34H|\35I}\35I}\35I}\34" + "H|\34H|\20L\177\35I}\20L\177\20L\177\22M\200\22M\200\24N\201\24N\201" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P" + "\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\27P\203\27P\203\27P\203\27P\203\26O\202\26O\202\35I}\26O\202\24N\201" + "\24N\201\22M\200\22M\200\20L\177\20L\177\35I}\35I}\35I}\20L\177\34H|" + "\30Ey\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\23Bv\23Bv\23Bv\17At\15@s\15@s\11" + ">q\11>qK\312\363K\312\363\6=p\4q\11>q\11>qK\312\363K\312\363\4q\11>q\11>q\11>q\6=pK\312" + "\363K\312\363\2" + "\0\0\34H|\32G{\35I}\35I}\35I}\35I}\20L\177\20L\177\35I}\20L\177\20L\177" + "\22M\200\22M\200\22M\200\35I}\24N\201\26O\202\26O\202\26O\202\26O\202" + "\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203\27P" + "\203\27P\203\27P\203\27P\203\26O\202\26O\202\26O\202\26O\202\26O\202" + "\24N\201\35I}\22M\200\20L\177\35I}\20L\177\34H|\35I}\35I}\32G{\34H|\30" + "Ey\32G{\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\17At\15@s\15@s\11>q\11" + ">q\11>q\11>q\11>q\6=p\6=pK\312\363K\312\363\0:l\2\10\32=\11\33>\0\0\32G{\34H|\35I}\35I}\35I}\35I}\20L" + "\177\20L\177\35I}\20L\177\20L\177\22M\200\22M\200\35I}\24N\201\24N\201" + "\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P" + "\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\27P\203" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\27P\203\27P\203\27P\203\27P\203\27P\203\26O\202\26O\202\26O\202" + "\35I}\26O\202\24N\201\24N\201\22M\200\22M\200\20L\177\20L\177\35I}\20" + "L\177\35I}\32G{\32G{\32G{\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23" + "Bv\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\6=p\6=p\4K\312\363K\312\363\11\33>\10\32=\0" + "\34C\0\0\34H|\34H|\34H|\34H|\35I}\35I}\35I}\35I}\20L\177\20L\177\22M" + "\200\35I}\22M\200\24N\201\24N\201\24N\201\26O\202\26O\202\26O\202\26" + "O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\26O\202\26O\202\26O\202\26O\202\26O\202\24N\201\24N\201\22M\200\22M" + "\200\20L\177\20L\177\35I}\35I}\35I}\34H|\32G{\32G{\30Ey\30Ey\30Ey\24" + "Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\6" + "=p\6=p\2q\11>q\11>q\11>q\6=p\4\0\34C\10\32=\11\33>K\312\363K\312\363\10\32=\0\32:\0\32:\0\0" + "\34H|\34H|\20L\177\35I}\35I}\35I}\20L\177\20L\177\35I}\20L\177\22M\200" + "\22M\200\24N\201\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O" + "\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P" + "\203\27P\203\27P\203\27P\203\27P\203\26O\202\26O\202\26O\202\26O\202" + "\26O\202\24N\201\24N\201\22M\200\22M\200\22M\200\35I}\20L\177\35I}\34" + "H|\35I}\32G{\34H|\32G{\32G{\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23" + "Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\6=p\4\11\33>\10\32=K\312" + "\363K\312\363\0\32:\10\32=\5\30:\0\0\34H|\34H|\35I}\35I}\35I}\20L\177" + "\20L\177\20L\177\35I}\22M\200\22M\200\22M\200\24N\201\24N\201\24N\201" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P" + "\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\26O\202\26O" + "\202\26O\202\26O\202\26O\202\24N\201\24N\201\22M\200\22M\200\22M\200" + "\20L\177\20L\177\20L\177\20L\177\35I}\34H|\32G{\34H|\32G{\30Ey\30Ey\30" + "Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11>q\6" + "=p\4\10\32=\11\33>\0\34C\10\32=\10\32=K\312\363K\312\363\0\32:\5" + "\30:\5\30:\0\0\34H|\35I}\35I}\35I}\35I}\20L\177\35I}\20L\177\35I}\22" + "M\200\22M\200\24N\201\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202" + "\26O\202\26O\202\26O\202\27P\203\35I}\27P\203\27P\203\27P\203\27P\203" + "\27P\203\27P\203\35I}\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\27P\203\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\24N\201\24N" + "\201\22M\200\22M\200\20L\177\20L\177\35I}\35I}\35I}\35I}\34H|\32G{\34" + "H|\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\11" + ">q\11>q\11>q\11>q\6=p\4\0\34C\11\33>\10\32=\0\32:\10\32=\10\32=\10\32=\0\32" + ":K\312\363K\312\363\5\30:\5\30:\0\32:\0\0\35I}\34H|\35I}\35I}\20L\177" + "\35I}\20L\177\35I}\22M\200\22M\200\35I}\24N\201\24N\201\26O\202\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P" + "\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\27P\203\27P\203\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O" + "\202\35I}\24N\201\22M\200\35I}\22M\200\20L\177\35I}\35I}\20L\177\35I" + "}\34H|\34H|\34H|\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17" + "At\15@s\15@s\11>q\376\377\374\376\377\374\376\377\374^\203\243\6=p\6" + "=p\2\0\34C\0\32:\10\32=\11\33>\10\32=\10\32=\10\32=\0\32:\0\32:K" + "\312\363K\312\363\5\31""6\0\32:\0\32:\0\0\35I}\20L\177\35I}\35I}\20L" + "\177\35I}\20L\177\20L\177\22M\200\35I}\22M\200\24N\201\24N\201\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O" + "\202\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\24N" + "\201\24N\201\22M\200\22M\200\22M\200\20L\177\35I}\20L\177\20L\177\35" + "I}\34H|\34H|\32G{\32G{\32G{\30Ey\30Ey\30Ey\24Cw\24Cw\23Bv\23Bv\23Bv\23" + "Bv\17At\15@s\15@s\11>q\11>q\326\336\347\376\377\374\376\377\3745_\211" + "\2\0\34C\0\34C\0\32:\0\32:\10\32=\10\32=\10\32=\0\32:" + "\0\32:\5\30:\5\30:K\312\363K\312\363\0\32:\0\32:\5\31""6\0\0\34H|\35" + "I}\34H|\35I}\35I}\20L\177\35I}\20L\177\22M\200\22M\200\22M\200\24N\201" + "\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O" + "\202\35I}\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26" + "O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\24N\201" + "\24N\201\22M\200\22M\200\35I}\20L\177\20L\177\35I}\35I}\35I}\34H|\34" + "H|\20L\177\34H|\32G{\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17" + "At\15@s\15@s\11>q\11>q\11>q\11>q\36Ky\331\342\352\376\377\374\363\370" + "\373`|\235\0:l\0:l\0:l\21""9f\17""8e\17""8e\17""8e\17""8e\13""6c\10""4" + "a\10""4a\10""4aK\312\363K\312\363\10""4a\6""3`\4""3_\0\0\2'T\2'T\2'T" + "\2'T\2'T\2'T\2'T\10*X\2'T\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*" + "X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\2'T\2'T\2'T\2'T\2'T\14" + "#Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\14#Q\0%Q\14#Q\0%Q\0#O\0$P\0\"M\0\"M\0\"M" + "\4\37M\0\"M\5\40H\5\40H\2\36E\2\36E\213\232\255\235\251\266\367\375\377" + "\376\377\374\376\377\374\325\332\334\235\251\266\216\232\247\215\230" + "\245\215\230\245\210\227\252\215\230\245\215\230\245\215\230\245\5\30" + ":\5\30:\5\30:K\312\363K\312\363\0\32:\5\31""6\5\31""6\0\0\35I}\20L\177" + "\35I}\20L\177\20L\177\20L\177\35I}\22M\200\22M\200\22M\200\24N\201\24" + "N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O" + "\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\24N\201\24N\201" + "\22M\200\22M\200\22M\200\35I}\20L\177\20L\177\35I}\34H|\35I}\34H|\32" + "G{\34H|\30Ey\32G{\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17At\15" + "@s\15@s\11>q\11>q\11>q\11>q\6=p\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\10""4a\10" + "4a\10""4aK\312\363K\312\363\11""6]\6""3`\6""3`\0\0\2'T\2'T\2'T\2'T\2" + "'T\2'T\2'T\2'T\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X" + "\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\2'T\10*X\2'T\2'T\2'T\14#Q\2'T\2'T\2'T\14#Q\0%" + "Q\14#Q\0%Q\14#Q\0%Q\0%Q\14#Q\0$P\14#Q\0$P\0#O\0\"M\4\37M\4\37M\4\37M" + "\5\40H\0\"M\2\36E\5\40H\2\36E\2\36E\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\5\30" + ":\0\32:\0\32:K\312\363K\312\363\5\31""6\0\32:\5\31""6\0\0\34H|\35I}\35" + "I}\20L\177\20L\177\35I}\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201" + "\26O\202\26O\202\26O\202\26O\202\35I}\26O\202\26O\202\26O\202\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O" + "\202\26O\202\26O\202\26O\202\24N\201\24N\201\24N\201\22M\200\22M\200" + "\20L\177\35I}\35I}\35I}\35I}\35I}\34H|\32G{\34H|\34H|\32G{\30Ey\30Ey" + "\30Ey\30Ey\24Cw\24Cw\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11" + ">q\11>q\6=p\4q\11>q\11>q\11>q\6=" + "p\6=p\4\10\32=\0\32:\10\32=\10\32=\0\32:\0\32:\10" + "\32=\5\30:\5\30:\5\30:\0\32:\0\32:\0\32:\5\31""6K\312\363K\312\363\5" + "\31""6\5\31""6\4\30""5\0\0\34H|\20L\177\20L\177\20L\177\20L\177\20L\177" + "\22M\200\22M\200\22M\200\24N\201\24N\201\24N\201\26O\202\26O\202\26O" + "\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\24N\201\24N\201\24N" + "\201\22M\200\22M\200\22M\200\35I}\20L\177\35I}\35I}\20L\177\35I}\35I" + "}\34H|\20L\177\34H|\32G{\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23B" + "v\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\6=p\6=p\2\0\34" + "C\0\32:\11\33>6Kk\235\251\266\333\340\343\362\367\371\362\367\371\326" + "\336\347\235\251\2669Id\0\32:\0\32:\0\32:\5\31""6\5\31""6\5\31""6K\312" + "\363K\312\363\5\31""6\4\30""5\4\30""5\0\0\35I}\20L\177\35I}\20L\177\20" + "L\177\22M\200\22M\200\22M\200\22M\200\24N\201\24N\201\24N\201\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O" + "\202\26O\202\26O\202\26O\202\26O\202\26O\202\24N\201\24N\201\24N\201" + "\24N\201\22M\200\22M\200\20L\177\20L\177\20L\177\20L\177\34H|\35I}\35" + "I}\34H|\32G{\34H|\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23" + "Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\11>q\6=p\4\10\32=\205\224" + "\247\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\210\224\241" + "\0\32:\5\31""6\5\31""6\5\31""6K\312\363K\312\363\4\30""5\4\30""5\4\30" + "5\0\0\35I}\20L\177\20L\177\20L\177\22M\200\22M\200\22M\200\35I}\24N\201" + "\24N\201\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\26O" + "\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\24N\201" + "\24N\201\24N\201\24N\201\22M\200\22M\200\20L\177\35I}\20L\177\20L\177" + "\34H|\35I}\35I}\34H|\34H|\32G{\32G{\32G{\30Ey\30Ey\30Ey\24Cw\24Cw\24" + "Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\6=p\4q\11>q\11>q\11>q\6=p\4\0\34C\0\34C\0\32:\10\32=\10\32=\353\360" + "\363\376\377\374\376\377\374M_u\0\32:\5\30:\5\30:\5\30:\0\32:\0\32:M" + "_u\376\377\374\376\377\374\354\362\364\5\31""6\5\31""6\5\31""6K\312\363" + "K\312\363\4\30""5\4\30""5\4\30""5\0\0\20L\177\35I}\20L\177\22M\200\22" + "M\200\22M\200\22M\200\22M\200\24N\201\24N\201\24N\201\24N\201\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\24N" + "\201\35I}\24N\201\24N\201\22M\200\35I}\22M\200\22M\200\20L\177\35I}\20" + "L\177\35I}\20L\177\35I}\35I}\20L\177\34H|\34H|\32G{\30Ey\30Ey\30Ey\24" + "Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\11" + ">q\6=p\6=p\2q\11>q\11>q\11>q\6=p\4\0\34C\0\32:\10\32=\10\32=\10\32=\10\32=\215\230" + "\245\376\377\374\376\377\374\376\377\374\370\372\367\267\277\307\222" + "\236\253\222\236\253\267\277\307\370\372\367\376\377\374\376\377\374" + "\376\377\374\215\230\245\5\31""6\0\32:\5\31""6K\312\363K\312\363\5\31" + "6\5\31""6\0\32:\0\0\20L\177\20L\177\35I}\22M\200\22M\200\24N\201\24N" + "\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201" + "\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\22M\200\22M\200\35I" + "}\22M\200\20L\177\20L\177\20L\177\20L\177\35I}\35I}\35I}\35I}\32G{\34" + "H|\34H|\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17At\17" + "At\15@s\15@s\15@s\11>q\11>q\11>q\6=p\6=p\4\0\34C\10\32=\10\32" + "=\0\34C\10\32=\10\32=\0\32:\0\32:\201\220\242\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\206\222\237\5\31""6\5\31""6\5\31""6\5\31" + "6K\312\363K\312\363\5\31""6\5\31""6\5\31""6\0\0\20L\177\20L\177\22M\200" + "\22M\200\22M\200\24N\201\24N\201\24N\201\35I}\24N\201\24N\201\24N\201" + "\24N\201\24N\201\24N\201\24N\201\35I}\24N\201\24N\201\24N\201\22M\200" + "\22M\200\22M\200\22M\200\35I}\20L\177\20L\177\20L\177\35I}\20L\177\34" + "H|\35I}\34H|\32G{\34H|\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\24" + "Cw\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\6=p\6=p\4\11\33>\10\32=\10\32=\10\32=\0\32:\0\32:\10\32=\5\30:\0\32:9" + "Id\235\251\266\333\340\343\363\370\373\370\372\367\333\340\343\235\251" + "\2668K`\5\31""6\5\31""6\5\31""6\5\31""6\5\31""6\5\31""6K\312\363K\312" + "\363\5\31""6\5\31""6\5\31""6\0\0\22M\200\22M\200\22M\200\22M\200\35I" + "}\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24" + "N\201\24N\201\24N\201\24N\201\22M\200\22M\200\22M\200\35I}\22M\200\35" + "I}\20L\177\20L\177\20L\177\20L\177\20L\177\35I}\35I}\32G{\34H|\32G{\30" + "Ey\32G{\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15" + "@s\11>q\11>q\11>q\11>q\11>q\6=p\4\10\32=\11\33>\0\34C\10\32=\0\32:\0\32:\0\32:\10\32=\5" + "\30:\5\30:\5\30:\5\30:\0\32:\5\31""6\0\32:\0\32:\5\31""6\5\31""6\5\31" + "6\5\31""6\5\31""6\5\31""6\5\31""6\5\31""6\5\31""6K\312\363K\312\363\5" + "\31""6\5\31""6\5\31""6\0\0\22M\200\22M\200\22M\200\22M\200\24N\201\24" + "N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201" + "\24N\201\24N\201\22M\200\22M\200\22M\200\22M\200\35I}\20L\177\20L\177" + "\20L\177\20L\177\34H|\35I}\34H|\35I}\20L\177\34H|\34H|\32G{\30Ey\30E" + "y\24Cw\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\11>q\15" + "@s\11>q\11>q\11>q\4\10\32=\11\33>\0\32:\10\32=\0\34C\10\32=\10\32" + "=\0\32:\0\32:\5\30:\376\377\374\376\377\374\376\377\374%6P\0\32:\0\32" + ":\5\31""6\0\32:\5\31""6\5\31""6%6P\376\377\374\376\377\374\376\377\374" + "\5\31""6\5\31""6\5\31""6K\312\363K\312\363\5\31""6\0\32:\5\31""6\0\0" + "\22M\200\22M\200\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N" + "\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\22M\200\22M\200" + "\35I}\22M\200\35I}\20L\177\20L\177\20L\177\20L\177\20L\177\35I}\20L\177" + "\34H|\32G{\34H|\32G{\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23" + "Bv\23Bv\17At\17At\15@s\15@s\11>q\11>q\11>q\11>q\6=p\6=p\4\10" + "\32=\11\33>\0\34C\10\32=\0\34C\0\32:\0\32:\0\32:\5\30:\5\30:\376\377" + "\374\376\377\374\376\377\374%6P\5\31""6\0\32:\0\32:\0\32:\0\32:\5\31" + "6;Nc\376\377\374\376\377\374\376\377\374\5\31""6\0\32:\0\32:K\312\363" + "K\312\363\0\32:\5\31""6\0\32:\0\0\22M\200\22M\200\24N\201\24N\201\24" + "N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201" + "\24N\201\22M\200\22M\200\35I}\22M\200\20L\177\20L\177\20L\177\20L\177" + "\20L\177\35I}\34H|\35I}\20L\177\34H|\32G{\34H|\32G{\30Ey\30Ey\30Ey\24" + "Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11>q\11" + ">q\6=p\6=p\4\0\34C\11\33>\0\32:\11\33>\0\34C\10\32=\10\32=\0\32:\0\32" + ":\215\230\245\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\343\350\353\0\32:\5\31""6\0\32:K\312\363K\312\363\5\30:\5\30:\5\30:" + "\0\0\22M\200\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201" + "\35I}\24N\201\24N\201\24N\201\22M\200\22M\200\22M\200\22M\200\22M\200" + "\20L\177\20L\177\20L\177\20L\177\35I}\35I}\35I}\20L\177\34H|\32G{\34" + "H|\20L\177\32G{\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17" + "At\15@s\15@s\17At\11>q\11>q\11>q\11>q\6=p\4\0\34C\11\33>\10" + "\32=\0\32:\11\33>\10\32=\0\34C\10\32=\0\32:\10\32=\0\32:\215\230\245" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\370\372\3675Mg\0\32:\5\31" + "6\0\32:K\312\363K\312\363\5\30:\5\30:\5\30:\0\0\24N\201\24N\201\24N\201" + "\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\22M" + "\200\22M\200\35I}\22M\200\22M\200\20L\177\20L\177\35I}\20L\177\34H|\35" + "I}\35I}\35I}\34H|\20L\177\34H|\32G{\32G{\30Ey\30Ey\30Ey\30Ey\24Cw\24" + "Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\6=p\6" + "=p\4" + "\11\33>\0\32:\11\33>\10\32=\10\32=\10\32=\0\32:\10\32=\0\32:\0\32:\5" + "\30:\5\30:\5\30:\5\30:\376\377\374\376\377\374\376\377\374%6P\0\32:\4" + "\30""5\0\32:\5\31""6\0\32:\0\32:\0\32:\5\31""6\0\32:\5\31""6\0\32:\5" + "\30:\0\32:K\312\363K\312\363\5\30:\0\32:\10\32=\0\0\24N\201\24N\201\24" + "N\201\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\22M\200\22M\200" + "\35I}\22M\200\22M\200\22M\200\20L\177\20L\177\20L\177\20L\177\20L\177" + "\35I}\34H|\35I}\34H|\32G{\34H|\30Ey\32G{\30Ey\30Ey\30Ey\24Cw\24Cw\24" + "Cw\24Cw\23Bv\23Bv\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\11>q\6=p\6" + "=p\4\10\32=\11\33>\10\32=\10\32=\10\32=\0\34C\0\32:\0\32:\0\32:\5" + "\30:\5\30:\5\30:\5\30:\5\30:\5\30:\5\30:\5\30:\0\32:\0\32:\0\32:\5\31" + "6\0\32:\5\31""6\0\32:\0\32:\0\32:\5\30:\5\30:\5\30:\5\30:\5\30:K\312" + "\363K\312\363\0\32:\10\32=\0\34C\0\0\24N\201\24N\201\24N\201\24N\201" + "\24N\201\24N\201\24N\201\24N\201\24N\201\22M\200\22M\200\22M\200\22M" + "\200\35I}\20L\177\20L\177\20L\177\20L\177\20L\177\35I}\35I}\35I}\20L" + "\177\34H|\34H|\30Ey\32G{\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23B" + "v\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\11>q\6=p\4\0\34C\10\32=\10\32=\0\32:\0\32:\10\32=\10\32=\214\227\244\214\227" + "\244\214\227\244\30'F\5\30:\214\227\244\214\227\244\214\227\244\214\227" + "\244\214\227\244\214\227\244\214\227\244\214\227\244\214\227\244\214" + "\227\244\214\227\244\214\227\244\214\227\244\214\227\244\5\30:\0\32:" + "\10\32=K\312\363K\312\363\10\32=\10\32=\0\34C\0\0\35I}\24N\201\24N\201" + "\24N\201\24N\201\24N\201\24N\201\24N\201\22M\200\22M\200\22M\200\22M" + "\200\35I}\20L\177\20L\177\20L\177\20L\177\35I}\35I}\35I}\35I}\34H|\20" + "L\177\34H|\30Ey\32G{\30Ey\30Ey\24Cw\30Ey\24Cw\24Cw\23Bv\23Bv\24Cw\23" + "Bv\17At\15@s\15@s\11>q\15@s\11>q\11>q\11>q\6=p\6=p\4\10" + "\32=\11\33>\10\32=\0\34C\10\32=\10\32=\10\32=\0\32:\0\32:\0\32:\10\32" + "=\376\377\374\376\377\374\376\377\374\37""6U\5\30:\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\0\32:\10\32=\10\32=K\312\363K\312\363\10\32=\0\32:\11\33" + ">\0\0\24N\201\24N\201\24N\201\24N\201\24N\201\24N\201\22M\200\22M\200" + "\22M\200\22M\200\35I}\20L\177\20L\177\20L\177\20L\177\35I}\35I}\35I}" + "\35I}\34H|\34H|\32G{\34H|\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\24" + "Cw\23Bv\23Bv\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\11>q\6=p\4\11\33>\10\32=\10\32=\0\34C\10\32=\0\34C\10\32=\10\32=" + "\10\32=\0\32:\10\32=\0\32:\376\377\374\376\377\374\376\377\374\37""6" + "U\5\30:\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\0\32:\10\32=\0\34CK\312\363K\312" + "\363\0\32:\0\32:\0\34C\0\0\24N\201\24N\201\24N\201\24N\201\24N\201\24" + "N\201\22M\200\22M\200\35I}\22M\200\20L\177\20L\177\20L\177\35I}\20L\177" + "\35I}\20L\177\35I}\35I}\32G{\34H|\34H|\30Ey\30Ey\30Ey\30Ey\24Cw\30Ey" + "\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\11" + ">q\6=p\4\0\34C\0\34C\0\0\24N\201" + "\24N\201\24N\201\24N\201\24N\201\24N\201\22M\200\22M\200\22M\200\22M" + "\200\35I}\20L\177\35I}\20L\177\35I}\34H|\35I}\35I}\34H|\34H|\34H|\30" + "Ey\30Ey\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15" + "@s\11>q\11>q\11>q\11>q\11>q\6=p\6=p\4\10\32=\10\32" + "=\10\32=\0\34C\10\32=\10\32=\10\32=\10\32=\0\32:\0\32:\10\32=\0\32:\0" + "\32:\5\30:\5\30:\5\30:\5\30:\5\30:\5\30:\0\32:\0\32:\10\32=\0\32:\10" + "\32=\10\32=\0\32:\10\32=\10\32=\10\32=\10\32=\0\32:\11\33>\0\32:K\312" + "\363K\312\363\0\34C\0\35D\0\35D\0\0\24N\201\24N\201\24N\201\24N\201\24" + "N\201\22M\200\22M\200\22M\200\22M\200\35I}\20L\177\20L\177\20L\177\35" + "I}\35I}\35I}\35I}\34H|\32G{\34H|\30Ey\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24" + "Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\6" + "=p\6=p\4\0\32:\10\32=\0\34C\10\32" + "=\0\34C\10\32=\10\32=\10\32=\0\32:\0\32:\10\32=\10\32=\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\10\32=\11\33>\0\34CK\312\363K\312\363\0\35D\2\36E\2\36E\0\0" + "\24N\201\24N\201\24N\201\22M\200\22M\200\22M\200\22M\200\22M\200\20L" + "\177\20L\177\35I}\20L\177\35I}\35I}\35I}\34H|\34H|\32G{\34H|\30Ey\30" + "Ey\30Ey\30Ey\24Cw\30Ey\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15" + "@s\11>q\15@s\11>q\11>q\11>q\6=p\6=p\4\0\32:\11" + "\33>\11\33>\10\32=\0\34C\10\32=\10\32=\10\32=\0\32:\10\32=\10\32=\0\32" + ":\10\32=\0\32:\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\0\34C\11\33>\0\35DK\312\363K\312" + "\363\2\36E\2\36E\5\40H\0\0\24N\201\24N\201\24N\201\22M\200\22M\200\22" + "M\200\22M\200\20L\177\20L\177\20L\177\20L\177\35I}\20L\177\35I}\35I}" + "\20L\177\34H|\20L\177\30Ey\30Ey\30Ey\30Ey\24Cw\30Ey\24Cw\24Cw\23Bv\23" + "Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\6=p\4q\11>q\0\0\10*X\10*X\10*X\10" + "*X\2'T\10*X\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\0%Q\0%Q\0%Q\0%Q\0%Q\0%Q\14" + "#Q\0%Q\0%Q\14#Q\0$P\0%Q\0$P\0#O\0\"M\0\"M\4\37M\4\37M\0\"M\4\37M\5\40" + "H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\11\33>\0\34C" + "\0\34C\11\33>\11\33>\11\33>\10\32=\10\32=\10\32=\0\34C\10\32=\10\32=" + "\10\32=\0\32:\10\32=\10\32=\0\32:\10\32=\0\32:\10\32=\0\32:\0\32:\0\32" + ":\0\32:\10\32=Pcy\370\372\367\367\375\377\200\217\241*\77_\5\40H\5!C" + "-Cb\201\220\242\370\372\367\367\375\377w\206\231\0\34C\0\35D\0\35D\0" + "\35DK\312\363K\312\363\5\40H\2\36E\2\36E\0\0\24N\201\24N\201\24N\201" + "\22M\200\22M\200\22M\200\20L\177\20L\177\20L\177\20L\177\34H|\35I}\35" + "I}\35I}\32G{\34H|\34H|\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23" + "Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=" + "p\2q\11>q\11>q\0\0\10*X\10*" + "X\10*X\10*X\10*X\10*X\2'T\2'T\2'T\2'T\2'T\2'T\2'T\0%Q\0%Q\14#Q\0%Q\0" + "%Q\14#Q\14#Q\14#Q\0%Q\0$P\0%Q\0$P\0$P\0\"M\0\"M\0\"M\4\37M\4\37M\0\"" + "M\4\37M\5\40H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0" + "\35D\0\34C\0\34C\0\34C\10\32=\0\32:\0\32:\11\33>\0\32:\10\32=\10\32=" + "\10\32=\10\32=\10\32=\0\34C\0\32:\10\32=\10\32=\0\32:\10\32=\10\32=\0" + "\32:\10\32=\10\32=\0\34C\247\262\300\376\377\374\376\377\374*\77_\10" + "\32=\11\33>\11\33>\10\32=\0\32:\0\34C*\77_\376\377\374\376\377\374\275" + "\305\315\0\35D\2\36E\2\36EK\312\363K\312\363\2\36E\5\40H\5\40H\0\0\24" + "N\201\24N\201\22M\200\22M\200\22M\200\20L\177\20L\177\35I}\20L\177\34" + "H|\35I}\35I}\35I}\20L\177\32G{\34H|\32G{\30Ey\30Ey\30Ey\30Ey\24Cw\24" + "Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11" + ">q\6=p\6=p\4q\11>q\15@s\0\0" + "\10*X\10*X\10*X\2'T\10*X\2'T\2'T\2'T\2'T\2'T\14#Q\2'T\2'T\0%Q\0%Q\14" + "#Q\0%Q\0%Q\14#Q\0%Q\0%Q\0%Q\0$P\0%Q\0$P\0#O\0\"M\14#Q\0\"M\0\"M\4\37" + "M\4\37M\5\40H\5\40H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0" + "\35D\0\34C\0\34C\0\34C\11\33>\10\32=\0\32:\10\32=\0\32:\10\32=\0\34C" + "\10\32=\10\32=\10\32=\10\32=\10\32=\10\32=\0\34C\10\32=\0\34C\10\32=" + "\10\32=\0\34C\10\32=\10\32=\10\32=\365\372\375\376\377\374\376\377\374" + "\307\317\330\30""0N\0\32:\11\33>\11\33>\0\34C\30""0N\307\317\330\376" + "\377\374\376\377\374\370\372\367\2\36E\2\36E\2\36EK\312\363K\312\363" + "\5\40H\0\"M\4\37M\0\0\24N\201\22M\200\22M\200\22M\200\22M\200\35I}\20" + "L\177\35I}\35I}\35I}\35I}\35I}\20L\177\34H|\32G{\32G{\32G{\30Ey\30Ey" + "\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\17At\17At\15@s\15@s\11>q\11" + ">q\11>q\11>q\11>q\11>q\6=p\4q\11>qK\312\363K\312\363\15@s\15" + "@s\15@s\0\0\10*X\10*X\10*X\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\14#Q\0" + "%Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\0$P\14#Q\0#O\0#O\0\"M\0#O\4\37M\4\37" + "M\4\37M\4\37M\5\40H\5\40H\5\40H\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\0" + "\35D\0\35D\0\35D\0\34C\11\33>\0\34C\11\33>\0\32:\11\33>\0\32:\10\32=" + "\0\32:\10\32=\10\32=\10\32=\10\32=\10\32=\10\32=\0\34C\10\32=\10\32=" + "\0\34C\10\32=\0\34C\0\34C\10\32=\10\32=\10\32=\205\224\247\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\210" + "\227\252\2\36E\2\36E\2\36EK\312\363K\312\363\4\37M\4\37M\4\37M\0\0\22" + "M\200\22M\200\22M\200\22M\200\20L\177\20L\177\20L\177\35I}\35I}\35I}" + "\35I}\34H|\34H|\32G{\32G{\30Ey\30Ey\30Ey\24Cw\30Ey\24Cw\24Cw\23Bv\23" + "Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6" + "=p\4q\11" + ">q\11>qK\312\363K\312\363\15@s\17At\23Bv\0\0\10*X\2'T\10*X\10*X\2'T\2" + "'T\2'T\2'T\14#Q\2'T\2'T\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\0%Q\0%Q\0%Q\0$P\14" + "#Q\0$P\0$P\14#Q\0\"M\0\"M\0\"M\4\37M\4\37M\5\40H\5\40H\5\40H\5\40H\2" + "\36E\5\40H\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\11\33>\0\34C\0\34C\0\34" + "C\0\32:\11\33>\0\32:\10\32=\0\32:\11\33>\10\32=\0\34C\10\32=\10\32=\0" + "\34C\10\32=\0\34C\10\32=\10\32=\0\34C\10\32=\10\32=\10\32=\11\33>\0\32" + ":\10\32=\11\33>\34""4R\307\317\330\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\307\317" + "\330\33""9]\2\36E\2\36E\5\40H\5\40HK\312\363K\312\363\4\37M\0\"M\0\"" + "M\0\0\22M\200\22M\200\22M\200\20L\177\20L\177\35I}\20L\177\34H|\35I}" + "\35I}\32G{\34H|\34H|\32G{\30Ey\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23" + "Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\6=p\6" + "=p\6=p\4q\11>q\11>q\11>q\15@sK\312\363K\312\363\23Bv\23Bv\23Bv\0\0\2" + "'T\10*X\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\14" + "#Q\0%Q\0%Q\14#Q\0$P\0$P\0$P\0$P\0\"M\4\37M\0\"M\0\"M\4\37M\5\40H\5\40" + "H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\11\33>" + "\0\34C\0\34C\0\34C\0\34C\0\32:\11\33>\11\33>\10\32=\0\32:\10\32=\11\33" + ">\0\32:\10\32=\10\32=\0\34C\0\34C\10\32=\10\32=\10\32=\0\32:\10\32=\10" + "\32=\10\32=\11\33>\0\32:\0\32:\10\32=\0\34C\0\34C\0\34C\0\34C\0\35D\0" + "\35D\0\35D\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\5\40H\5\40H\4\37MK\312" + "\363K\312\363\14#Q\0$P\0$P\0\0\22M\200\22M\200\22M\200\35I}\20L\177\20" + "L\177\35I}\20L\177\35I}\32G{\34H|\34H|\34H|\32G{\30Ey\30Ey\30Ey\30Ey" + "\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11" + ">q\11>q\11>q\11>q\6=p\6=p\4q\11>q\11>q\11>q\15@s\15@s\15@s" + "K\312\363K\312\363\23Bv\23Bv\24Cw\0\0\10*X\2'T\2'T\2'T\2'T\2'T\2'T\2" + "'T\2'T\0%Q\0%Q\14#Q\0%Q\14#Q\14#Q\14#Q\0%Q\14#Q\0%Q\14#Q\0#O\0#O\0$P" + "\0\"M\0#O\4\37M\4\37M\0\"M\5\40H\5\40H\5\40H\2\36E\5\40H\2\36E\5\40H" + "\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\11\33>\0\34C\0\34C\11\33>\0\34C" + "\11\33>\10\32=\11\33>\10\32=\0\32:\11\33>\0\32:\10\32=\10\32=\11\33>" + "\11\33>\0\32:\10\32=\11\33>\10\32=\0\32:\10\32=\0\32:\10\32=\11\33>\0" + "\34C\11\33>\0\34C\11\33>\0\34C\0\35D\0\35D\0\35D\2\36E\2\36E\2\36E\2" + "\36E\2\36E\5\40H\5\40H\4\37M\4\37M\4\37M\0\"MK\312\363K\312\363\0$P\14" + "#Q\14#Q\0\0\22M\200\20L\177\35I}\20L\177\20L\177\35I}\35I}\20L\177\35" + "I}\32G{\34H|\32G{\32G{\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23" + "Bv\23Bv\17At\15@s\15@s\15@s\11>q\15@s\11>q\11>q\11>q\11>q\6=p\4q\6=p\11>q\11>q%P\177\313\327\345\320\331\341\313\327\345\15@s" + "\17At\23BvK\312\363K\312\363\23Bv\24Cw\24Cw\0\0\10*X\2'T\2'T\2'T\2'T" + "\14#Q\2'T\2'T\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\0$P\14#Q\0" + "$P\0$P\0\"M\14#Q\0\"M\0\"M\4\37M\4\37M\5\40H\5\40H\2\36E\2\36E\5\40H" + "\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\11\33>\0\34C\0\34C\0\34C\0" + "\34C\11\33>\11\33>\10\32=\11\33>\10\32=\0\32:\11\33>\10\32=\11\33>\11" + "\33>\10\32=\0\32:\11\33>\10\32=\0\32:\11\33>\10\32=\0\32:\0\32:\376\377" + "\374\376\377\374\376\377\374\"9X\11\33>\0\35D\0\35D\376\377\374\376\377" + "\374\376\377\374\37<`\2\36E\2\36E\5\40H\37<`\376\377\374\376\377\374" + "\376\377\374\0\"M\14#Q\0#OK\312\363K\312\363\0$P\0%Q\14#Q\0\0\20L\177" + "\20L\177\20L\177\20L\177\34H|\35I}\35I}\35I}\32G{\34H|\34H|\30Ey\30E" + "y\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15" + "@s\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\4q\11>q\11>q\40W\204\376\377\374\376\377\374\376\377" + "\374\23Bv\23Bv\23BvK\312\363K\312\363\24Cw\24Cw\30Ey\0\0\2'T\2'T\2'T" + "\2'T\2'T\2'T\2'T\14#Q\0%Q\0%Q\14#Q\14#Q\14#Q\14#Q\14#Q\0%Q\0%Q\0$P\0" + "$P\0$P\0$P\0#O\0\"M\4\37M\0\"M\4\37M\4\37M\5\40H\5\40H\5\40H\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\0\35D\0\34C\0\34C\0\34" + "C\0\34C\0\34C\0\34C\0\32:\10\32=\0\32:\10\32=\10\32=\0\32:\11\33>\10" + "\32=\0\32:\11\33>\10\32=\0\32:\11\33>\10\32=\11\33>\0\34C\0\34C\11\33" + ">\376\377\374\376\377\374\376\377\374\37""6U\0\35D\0\35D\2\36E\376\377" + "\374\376\377\374\376\377\374\37<`\2\36E\5\40H\5\40H(q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\4q\11>q\11>q\40W\204\376\377\374\376\377\374\376" + "\377\374\23Bv\23Bv\23BvK\312\363K\312\363\24Cw\30Ey\30Ey\0\0\2'T\2'T" + "\2'T\14#Q\2'T\2'T\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\14#Q\14#Q\0%Q\0%Q\14#Q\0" + "$P\0$P\0$P\0\"M\0#O\0\"M\0\"M\4\37M\4\37M\5\40H\5\40H\5\40H\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\0\35D\0\34C\0\34C\0" + "\34C\0\34C\0\34C\0\34C\11\33>\10\32=\11\33>\11\33>\0\32:\11\33>\0\32" + ":\0\32:\0\32:\11\33>\0\32:\10\32=\0\34C\0\34C\0\34C\0\34C\0\34C\11\33" + ">\376\377\374\376\377\374\376\377\374(q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\4q\376\377\374\376\377" + "\374\376\377\374\40W\204\11>q\15@s\15@s\40W\204\376\377\374\376\377\374" + "\376\377\374\23Bv\24Cw\24CwK\312\363K\312\363\24Cw\30Ey\32G{\0\0\2'T" + "\2'T\2'T\2'T\2'T\2'T\0%Q\0%Q\0%Q\14#Q\14#Q\14#Q\0%Q\0%Q\0%Q\0$P\14#Q" + "\0$P\0#O\14#Q\0\"M\0\"M\0\"M\4\37M\4\37M\4\37M\5\40H\5\40H\2\36E\5\40" + "H\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\0\35D\0\34C\0" + "\34C\0\34C\0\34C\11\33>\0\34C\0\34C\11\33>\10\32=\10\32=\0\32:\0\32:" + "\0\32:\10\32=\0\32:\0\34C\0\34C\0\34C\0\34C\0\34C\0\34C\0\34C\0\35D\0" + "\35D\376\377\374\376\377\374\376\377\374\"9X\2\36E\2\36E\2\36E\376\377" + "\374\376\377\374\376\377\374(q\11>q\11" + ">q\11>q\11>q\11>q\6=p\6=p\4\0\34C\0\34C\0\34" + "C\0\34C\0\34C\11\33>\0\34C\11\33>\0\34C\11\33>\0\34C\0\34C\11\33>\0\34" + "C\0\35D\0\35D\0\35D\0\35D\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\0$P\0%Q\14#QK\312\363K\312\363\0" + "%Q\0%Q\0%Q\0\0\20L\177\34H|\35I}\35I}\34H|\32G{\34H|\30Ey\32G{\30Ey\30" + "Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\4\0\34C\0\34C\0\34C\0\34C\0\34C\0\34C\11\33>\0\34C\0\34C\0\34C\11\33" + ">\0\34C\11\33>\0\35D\0\35D\0\35D\0\35D\2\36E\2\36E\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\0%Q\14#" + "Q\0%QK\312\363K\312\363\0%Q\0%Q\2'T\0\0\20L\177\35I}\35I}\32G{\34H|\32" + "G{\32G{\30Ey\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17" + "At\15@s\15@s\15@s\11>q\15@s\11>q\11>q\11>q\11>q\11>q\6=p\6=p\4\0\34C\0\34C\0\34C\0\34C\11\33>\0\34" + "C\11\33>\0\34C\0\34C\0\34C\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\2\36E" + "\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\5\40H\4\37M\4\37M\4\37M\0" + "\"M\0\"M\0\"M\0#O\0#O\0$P\0$P\0$P\0%Q\0%Q\0%Q\0%QK\312\363K\312\363\14" + "#Q\2'T\2'T\0\0\34H|\35I}\34H|\34H|\34H|\34H|\32G{\30Ey\30Ey\30Ey\24C" + "w\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\17At\17At\15@s\15@s\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\15" + "@s\15@s\15@s\15@s\17At\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30Ey\30" + "Ey\34H|K\312\363K\312\363\35I}\35I}\35I}\0\0\2'T\2'T\14#Q\0%Q\14#Q\14" + "#Q\14#Q\14#Q\0%Q\14#Q\0%Q\14#Q\14#Q\0#O\0$P\0\"M\0#O\0\"M\4\37M\4\37" + "M\4\37M\4\37M\5\40H\5\40H\5\40H\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2" + "\36E\2\36E\2\36E\0\35D\0\35D\0\35D\0\35D\0\35D\0\34C\0\34C\11\33>\0\34" + "C\0\34C\0\34C\11\33>\0\34C\0\34C\0\34C\0\34C\0\34C\0\34C\0\35D\0\35D" + "\0\35D\0\35D\0\35D\0\35D\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2" + "\36E\5\40H\5\40H\5\40H\0\"M\4\37M\4\37M\0\"M\14#Q\0\"M\0$P\0$P\0%Q\0" + "$P\14#Q\0%Q\14#Q\14#Q\14#Q\0%QK\312\363K\312\363\2'T\2'T\2'T\0\0\20L" + "\177\35I}\34H|\32G{\34H|\32G{\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23B" + "v\23Bv\23Bv\23Bv\17At\17At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\17At\23Bv" + "\23Bv\24Cw\23Bv\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\32G{\34H|\32G{K\312\363" + "K\312\363\35I}\20L\177\20L\177\0\0\2'T\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\14#" + "Q\0%Q\0%Q\0%Q\14#Q\0$P\0$P\5\40H\0\"M\0\"M\0\"M\4\37M\4\37M\4\37M\5\40" + "H\5\40H\5\40H\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\34C\0\34C\11\33>\11\33>\0" + "\34C\0\34C\0\34C\0\34C\0\34C\11\33>\0\35D\0\35D\0\35D\0\35D\0\35D\0\35" + "D\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\5\40H\5\40H\0" + "\"M\4\37M\4\37M\4\37M\0\"M\0#O\0\"M\0$P\14#Q\0%Q\0$P\0%Q\0%Q\14#Q\0%" + "Q\0%Q\0%Q\14#QK\312\363K\312\363\2'T\2'T\2'T\0\0\35I}\34H|\20L\177\34" + "H|\32G{\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\23Bv\17" + "At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\4q\11>q\11>q\11>q" + "\11>q\11>q\11>q\15@s\15@s\15@s\17At\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24" + "Cw\30Ey\30Ey\30Ey\32G{\20L\177\34H|\35I}K\312\363K\312\363\20L\177\20" + "L\177\22M\200\0\0\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\14#Q\0$P" + "\0$P\0#O\0#O\0\"M\4\37M\4\37M\4\37M\4\37M\4\37M\5\40H\5\40H\5\40H\2\36" + "E\5\40H\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\0" + "\35D\0\35D\0\35D\0\35D\0\34C\11\33>\0\34C\11\33>\0\34C\0\34C\11\33>\0" + "\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\2\36E\2\36E\2\36E\2\36E\2\36" + "E\5\40H\5\40H\2\36E\2\36E\5\40H\5\40H\5\40H\4\37M\0\"M\4\37M\0\"M\0\"" + "M\0\"M\0$P\0#O\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\14#Q\0%Q\0%Q\14#Q\2'TK\312\363" + "K\312\363\2'T\2'T\10*X\0\0\34H|\32G{\34H|\30Ey\30Ey\30Ey\30Ey\30Ey\24" + "Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\17At\23" + "Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\32G{\34H|\32G{\34H|\35" + "I}\35I}K\312\363K\312\363\20L\177\22M\200\22M\200\0\0\14#Q\0%Q\0%Q\0" + "%Q\14#Q\14#Q\14#Q\0%Q\0$P\0%Q\0$P\0#O\5\40H\0\"M\0\"M\0\"M\0\"M\4\37" + "M\4\37M\4\37M\5\40H\5\40H\0\"M\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35" + "D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0" + "\35D\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\2\36E\5\40H\5\40H\5\40" + "H\0\"M\4\37M\0\"M\0\"M\0\"M\14#Q\0$P\0#O\0$P\0$P\14#Q\0%Q\0%Q\0%Q\14" + "#Q\14#Q\0%Q\0%Q\2'T\2'T\2'TK\312\363K\312\363\2'T\10*X\10*X\0\0\34H|" + "\34H|\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\23" + "Bv\17At\15@s\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6" + "=p\4q\11>q\11>q\11>q" + "\11>q\11>q\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24" + "Cw\24Cw\30Ey\30Ey\30Ey\32G{\20L\177\34H|\35I}\34H|\20L\177K\312\363K" + "\312\363\22M\200\22M\200\24N\201\0\0\0%Q\0%Q\0%Q\14#Q\0%Q\0%Q\0%Q\14" + "#Q\0%Q\14#Q\0$P\0$P\14#Q\0\"M\0\"M\4\37M\4\37M\0\"M\4\37M\5\40H\5\40" + "H\5\40H\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\0" + "\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35" + "D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\5\40H\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\4\37M\4\37M\0\"M\0\"M" + "\14#Q\0\"M\0$P\0#O\14#Q\0%Q\0$P\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\2'T\2'T" + "\2'T\2'TK\312\363K\312\363\2'T\10*X\10*X\0\0\32G{\32G{\30Ey\30Ey\30E" + "y\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\15" + "@s\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15" + "@s\17At\17At\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\32G{\32" + "G{\34H|\32G{\35I}\34H|\35I}\35I}K\312\363K\312\363\22M\200\24N\201\35" + "I}\0\0\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\14#Q\0$P\0$P\0$P\0#O\0#O\0\"M\0" + "\"M\4\37M\4\37M\0\"M\5\40H\5\40H\5\40H\2\36E\2\36E\5\40H\2\36E\5\40H" + "\2\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0" + "\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\5\40H\5" + "\40H\5\40H\0\"M\4\37M\0\"M\0\"M\14#Q\0\"M\0$P\0$P\0$P\14#Q\0$P\0%Q\14" + "#Q\14#Q\0%Q\14#Q\0%Q\14#Q\2'T\14#Q\2'T\2'T\2'TK\312\363K\312\363\10*" + "X\10*X\10*X\0\0\32G{\30Ey\30Ey\30Ey\30Ey\24Cw\24Cw\24Cw\23Bv\23Bv\23" + "Bv\23Bv\23Bv\17At\15@s\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\6=p\6=p\6=p\4q\11>q\11>q\11" + ">q\11>q\11>q\11>q\15@s\15@s\220\253\302\220\253\302\220\253\302\220\253" + "\302\220\253\302\230\253\304\221\254\303\230\253\304\221\254\303\221" + "\254\303\222\255\304\222\255\304\222\255\304\222\255\304\230\253\304" + "\222\255\304\230\253\304\223\256\305\223\256\305\34H|\20L\177\35I}K\312" + "\363K\312\363\24N\201\26O\202\26O\202\0\0\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0" + "$P\0$P\0#O\0$P\0#O\0\"M\4\37M\4\37M\0\"M\4\37M\4\37M\5\40H\0\"M\5\40" + "H\5\40H\5\40H\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\0" + "\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35" + "D\0\35D\0\35D\0\35D\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\5\40H\5\40H\5\40H\5\40H\4\37M\4\37M\0\"M\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\2'T\2'T\10*XK\312\363K\312\363\10*X\10*X\10*X\0\0\30Ey\30Ey\30E" + "y\24Cw\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\15" + "@s\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s" + "\15@s\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\20L\177\35I}\22M\200K\312\363K\312\363\26" + "O\202\26O\202\26O\202\0\0\14#Q\14#Q\0%Q\0%Q\0%Q\0$P\0%Q\0$P\0#O\0$P\14" + "#Q\0\"M\4\37M\4\37M\0\"M\4\37M\5\40H\5\40H\5\40H\5\40H\2\36E\2\36E\2" + "\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35" + "D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\0\35D\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\5\40" + "H\5\40H\5\40H\0\"M\4\37M\4\37M\0\"M\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\2'T\2'T\10*" + "XK\312\363K\312\363\10*X\10*X\10*X\0\0\30Ey\30Ey\24Cw\24Cw\24Cw\24Cw" + "\23Bv\23Bv\24Cw\23Bv\23Bv\17At\15@s\15@s\15@s\15@s\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\4q\11>q" + "\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\17At\17At\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\35I}\22M\200\22M\200K\312\363K\312\363\26O\202\26O\202\26O\202" + "\0\0\0%Q\0%Q\0%Q\0%Q\0$P\0$P\0#O\0$P\0#O\0\"M\4\37M\0\"M\0\"M\4\37M\0" + "\"M\4\37M\5\40H\5\40H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\0\35D\0\35D\0" + "\35D\0\35D\0\35D\0\35D\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\5\40H\5\40H\4\37M\4\37M\0\"M\4" + "\37M\0\"M\0\"M\0\"M\14#Q\0$P\0$P\0$P\0$POk\214\363\370\373\367\375\377" + "\204\230\257,Gl\10*X\12+Y,Gl\205\224\247\367\375\377\367\375\377x\213" + "\243\2'T\2'T\10*X\10*XK\312\363K\312\363\10*X\10*X\10*X\0\0\30Ey\24C" + "w\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\15@s\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\17At\23" + "Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw3e\224\365\372\375\376\377\374y\231\265" + "\30Ey\30Ey\34H|\32G{\34H|\35I}r\227\267\376\377\374\376\377\374c\207" + "\250\22M\200\22M\200\24N\201K\312\363K\312\363\26O\202\26O\202\27P\203" + "\0\0\0%Q\14#Q\0$P\0%Q\0$P\0#O\0$P\0\"M\0\"M\0\"M\4\37M\4\37M\4\37M\4" + "\37M\5\40H\5\40H\0\"M\5\40H\5\40H\2\36E\2\36E\5\40H\5\40H\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\0\35D\0\35D\0\35D\0\35D\0" + "\35D\0\35D\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40" + "H\2\36E\5\40H\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\4\37M\0\"M\4\37M\4" + "\37M\0\"M\0#O\0\"M\0$P\0#O\14#Q\14#Q\14#Q\252\265\303\376\377\374\376" + "\377\374,Gl\14#Q\0%Q\0%Q\14#Q\2'T\2'T.In\376\377\374\376\377\374\274" + "\310\326\2'T\10*X\10*XK\312\363K\312\363\10*X\10*X\12+Y\0\0\24Cw\24C" + "w\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\15@s\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\4q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\17At\23Bv\23" + "Bv\24Cw\23Bv\23Bv\24Cw\24Cw\24Cw\354\362\364\376\377\374\376\377\374" + "Ks\237\32G{\34H|\32G{\34H|\20L\177\34H|Tv\234\376\377\374\376\377\374" + "\354\362\364\22M\200\24N\201\24N\201K\312\363K\312\363\26O\202\26O\202" + "\27P\203\0\0\0$P\14#Q\0$P\0%Q\0$P\0$P\0\"M\0\"M\4\37M\4\37M\4\37M\0\"" + "M\4\37M\5\40H\5\40H\5\40H\5\40H\2\36E\2\36E\5\40H\2\36E\5\40H\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\5\40H\2\36E\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\0\"M\4\37M\4\37" + "M\4\37M\0\"M\0\"M\0$P\0#O\0#O\14#Q\0%Q\14#Q\14#Q\365\372\375\376\377" + "\374\376\377\374\312\322\333\34""8a\14#Q\0%Q\2'T\2'T\37:d\312\322\333" + "\376\377\374\376\377\374\365\372\375\10*X\10*X\10*XK\312\363K\312\363" + "\10*X\12+Y\12+Y\0\0\24Cw\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\23Bv\17At\15@" + "s\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=" + "p\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15" + "@s\15@s\15@s\17At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\30Ey\333\344" + "\354\376\377\374\376\377\374\376\377\374\363\370\373\274\310\326\225" + "\260\307\225\260\307\274\310\326\364\371\374\376\377\374\376\377\374" + "\376\377\374\336\347\357\22M\200\35I}\26O\202K\312\363K\312\363\26O\202" + "\27P\203\27P\203\0\0\0%Q\14#Q\0#O\0#O\0$P\14#Q\0\"M\0\"M\4\37M\4\37M" + "\4\37M\0\"M\4\37M\5\40H\5\40H\5\40H\2\36E\2\36E\2\36E\5\40H\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\5\40H\5\40H\4\37M\4\37M\4\37M\4" + "\37M\0\"M\0\"M\0\"M\0$P\0#O\0$P\0$P\14#Q\14#Q\0%Q\0%Q\210\227\252\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\213\232\255\10*X\10*X\10*XK\312\363K\312\363\10*X\12+Y\12+Y\0\0" + "\24Cw\24Cw\23Bv\23Bv\23Bv\23Bv\23Bv\17At\17At\15@s\15@s\15@s\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\4q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\23Bv\23Bv\23" + "Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30Ey\27P\203\333\344\354\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\336\347\357\"V\212\24N\201" + "\26O\202\26O\202K\312\363K\312\363\26O\202\27P\203\27P\203\0\0\0%Q\0" + "$P\0$P\0$P\0\"M\0#O\4\37M\4\37M\4\37M\4\37M\4\37M\5\40H\5\40H\5\40H\5" + "\40H\5\40H\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40" + "H\5\40H\5\40H\5\40H\4\37M\4\37M\4\37M\4\37M\4\37M\0\"M\0#O\0\"M\0$P\0" + "#O\14#Q\0%Q\14#Q\0%Q\0%Q\14#Q\14#Q\37:d\303\314\324\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\307\317\330&@k\10*X\10*X\10*X\10*XK\312\363K\312\363\10*X\12" + "+Y\12+Y\0\0\23Bv\23Bv\24Cw\23Bv\23Bv\23Bv\17At\15@s\15@s\15@s\15@s\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\6" + "=p\4q\11" + ">q\11>q\11>q\11>q\11>q\15@s\11>q\11>q\11>q\15@s\15@s\15@s\17At\17At\23" + "Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\35I}X" + "\203\250\263\303\326\341\352\362\365\372\375\365\372\375\343\350\353" + "\264\304\327o\206\243\24N\201\22M\200\24N\201\24N\201\26O\202\26O\202" + "K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\0$P\0$P\0\"M\0\"M\0\"" + "M\4\37M\0\"M\0\"M\4\37M\4\37M\5\40H\5\40H\5\40H\5\40H\5\40H\2\36E\2\36" + "E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\4" + "\37M\4\37M\0\"M\4\37M\4\37M\0\"M\0#O\0$P\0#O\0#O\14#Q\0%Q\0$P\0%Q\0%" + "Q\0%Q\14#Q\14#Q\14#Q\0%Q\0%Q\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10" + "*X\10*X\10*X\10*XK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\23Bv\23Bv\23B" + "v\23Bv\17At\17At\15@s\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\11>q" + "\11>q\11>q\15@s\15@s\15@s\15@s\17At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24" + "Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\32G{\34H|\32G{\34H|\35I}\35I}\34H|\35" + "I}\20L\177\20L\177\22M\200\22M\200\22M\200\24N\201\26O\202\26O\202\26" + "O\202K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\0$P\0\"M\14#Q\0\"" + "M\0\"M\4\37M\0\"M\4\37M\4\37M\4\37M\5\40H\5\40H\5\40H\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\0" + "\"M\4\37M\4\37M\4\37M\4\37M\0\"M\0\"M\0$P\0#O\0$P\0$P\14#Q\0$P\0%Q\14" + "#Q\0%Q\14#Q\14#Q\14#Q\0%Q\14#Q\0%Q\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\10*X" + "\10*X\10*X\10*X\10*X\10*XK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\23Bv\23" + "Bv\23Bv\17At\15@s\15@s\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\11>q\11>q" + "\11>q\11>q\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\24Cw\24" + "Cw\24Cw\24Cw\230\253\304\222\255\304\222\255\304\222\255\304\230\253" + "\304\230\253\304\230\253\304\230\253\304\230\253\304\230\253\304\223" + "\256\305\223\256\305\224\257\306\224\257\306\224\257\306\224\257\306" + "\224\257\306\225\260\307\225\260\307\26O\202\26O\202\26O\202K\312\363" + "K\312\363\27P\203\27P\203\27P\203\0\0\0$P\14#Q\0\"M\0\"M\0\"M\4\37M\4" + "\37M\4\37M\5\40H\5\40H\5\40H\5\40H\5\40H\2\36E\2\36E\2\36E\5\40H\2\36" + "E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\4\37M\4\37M\0\"M\0" + "\"M\0\"M\0#O\0\"M\0\"M\0$P\0$P\0$P\0$P\14#Q\0%Q\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\10*X\10*X\10*XK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\23Bv\23Bv\17At\17" + "At\15@s\15@s\15@s\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6" + "=p\6=p\6=p\6=p\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@" + "s\15@s\17At\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24" + "Cw\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\26O\202\26O\202\26O\202K\312\363K\312\363\27" + "P\203\27P\203\27P\203\0\0\0\"M\4\37M\0\"M\4\37M\0\"M\4\37M\4\37M\5\40" + "H\5\40H\5\40H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2" + "\36E\5\40H\5\40H\5\40H\5\40H\4\37M\0\"M\4\37M\4\37M\0\"M\4\37M\14#Q\0" + "\"M\0$P\0#O\0$P\0$P\14#Q\0$P\0%Q\0%Q\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\10*X\10" + "*X\10*XK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\23Bv\17At\23Bv\15@s\15@" + "s\15@s\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=" + "p\6=p\6=p\6=p\6=p\6=p\4q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15" + "@s\15@s\17At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\26O\202\26O\202\26O\202K\312\363K\312\363\27P\203" + "\27P\203\27P\203\0\0\0\"M\4\37M\4\37M\4\37M\4\37M\0\"M\5\40H\5\40H\5" + "\40H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\5\40" + "H\5\40H\5\40H\5\40H\4\37M\4\37M\0\"M\4\37M\4\37M\0\"M\0\"M\0#O\0\"M\0" + "$P\0$P\0$P\14#Q\14#Q\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\2'T" + "\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*XK\312" + "\363K\312\363\12+Y\12+Y\12+Y\0\0\17At\15@s\15@s\15@s\15@s\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\6" + "=p\6=p\4q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\17At\17At\23Bv\23" + "Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\34" + "H|\34H|\32G{\35I}\35I}\35I}\20L\177\20L\177\20L\177\20L\177\22M\200\35" + "I}\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202K\312\363K" + "\312\363\27P\203\27P\203\27P\203\0\0\0\"M\4\37M\4\37M\4\37M\4\37M\5\40" + "H\5\40H\5\40H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\5" + "\40H\5\40H\5\40H\5\40H\0\"M\4\37M\0\"M\0\"M\4\37M\4\37M\4\37M\0\"M\0" + "#O\0#O\0#O\0#O\14#Q\0%Q\0%Q\14#Q\14#Q\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\2" + "'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*XK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\15@s\15@s\15@s\15@s\11>" + "q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6" + "=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q" + "\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\17" + "At\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30" + "Ey\32G{\20L\177\34H|\34H|\35I}\35I}\35I}\35I}\20L\177\20L\177\20L\177" + "\22M\200\22M\200\22M\200\24N\201\26O\202\26O\202\26O\202\26O\202\26O" + "\202\26O\202K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\0\"M\4\37" + "M\4\37M\5\40H\5\40H\5\40H\5\40H\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2" + "\36E\5\40H\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\4\37M\4\37M\0\"M\4\37" + "M\0\"M\14#Q\0\"M\0#O\0$P\0$P\0$P\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\14#Q" + "\217\236\261\217\236\261\217\236\261\27""5]\0%Q\217\236\261\217\236\261" + "\217\236\261\217\236\261\217\236\261\217\236\261\217\236\261\217\236" + "\261\217\236\261\217\236\261\217\236\261\220\240\262\220\240\262\220" + "\240\262\10*X\10*X\10*XK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\15@s\15" + "@s\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6" + "=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6" + "=p\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15" + "@s\15@s\17At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30" + "Ey\30Ey\30Ey\376\377\374\376\377\374\376\377\374-`\217\35I}\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\26O\202\26O\202\26O\202K\312\363K\312\363\27P\203" + "\27P\203\27P\203\0\0\4\37M\4\37M\5\40H\5\40H\5\40H\0\"M\2\36E\2\36E\2" + "\36E\2\36E\5\40H\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\5\40" + "H\4\37M\4\37M\4\37M\4\37M\0\"M\4\37M\0\"M\0\"M\14#Q\0#O\0#O\14#Q\0%Q" + "\0$P\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\376\377\374\376\377\374\376\377\374&@k" + "\2'T\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\10*X\10*X\10*XK\312\363K\312\363" + "\12+Y\12+Y\12+Y\0\0\15@s\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>" + "q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p" + "\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24" + "Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\376\377\374\376\377\374\376" + "\377\374-`\217\34H|\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\26O\202\26O\202\26O" + "\202K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\0\"M\5\40H\5\40H\5" + "\40H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\5\40" + "H\5\40H\5\40H\5\40H\5\40H\0\"M\4\37M\4\37M\4\37M\0\"M\0\"M\0#O\0\"M\0" + "#O\5\40H\0$P\14#Q\0$P\14#Q\0%Q\0%Q\0%Q\0%Q\14#Q\14#Q\0%Q\376\377\374" + "\376\377\374\376\377\374(q\11>q\11>q\11>q\11>" + "q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p" + "\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\17At\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23" + "Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\32G{\34H|\32" + "G{\34H|\20L\177\35I}\35I}\34H|\35I}\20L\177\20L\177\20L\177\22M\200\22" + "M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202" + "\26O\202\26O\202K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\5\40H" + "\5\40H\5\40H\5\40H\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2" + "\36E\5\40H\5\40H\5\40H\5\40H\5\40H\4\37M\4\37M\4\37M\0\"M\0\"M\0\"M\0" + "\"M\0\"M\0#O\0#O\0$P\0$P\14#Q\0$P\0%Q\14#Q\14#Q\0%Q\14#Q\14#Q\0%Q\14" + "#Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\2'T\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\12+YK\312\363K\312\363\12+Y\12+Y\12+Y\0\0" + "\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6" + "=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11>" + "q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\17" + "At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30" + "Ey\30Ey\30Ey\32G{\34H|\32G{\34H|\35I}\20L\177\35I}\35I}\35I}\20L\177" + "\20L\177\20L\177\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O" + "\202\26O\202\26O\202\26O\202\26O\202\27P\203K\312\363K\312\363\27P\203" + "\27P\203\27P\203\0\0\5\40H\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H" + "\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\4\37M\4\37M\4" + "\37M\0\"M\0\"M\4\37M\0#O\0\"M\0\"M\0$P\0#O\14#Q\0%Q\14#Q\0%Q\0%Q\14#" + "Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2'T\14#Q\2'T\2'T\2'T\10" + "*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*XK\312\363" + "K\312\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q" + "\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6" + "=p\6=p\6=p\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24" + "Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\34H|\32G{\34H|\35I}\35I}\34" + "H|\35I}\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\26O\202\26O\202\26O\202K\312\363" + "K\312\363\27P\203\27P\203\27P\203\0\0\5\40H\5\40H\2\36E\5\40H\2\36E\2" + "\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\5" + "\40H\2\36E\2\36E\2\36E\2\36E\2\36E\0\"M\5\40H\5\40H\5\40H\5\40H\4\37" + "M\4\37M\4\37M\4\37M\4\37M\0\"M\0\"M\14#Q\0#O\0#O\0$P\0$P\14#Q\0%Q\0%" + "Q\0%Q\0%Q\14#Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\2'T\14#Q\2'T\2'T\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\10*X\10*X\10*XK\312\363K\312\363\12+Y\12+Y\12" + "+Y\0\0\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6" + "=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\17At\17" + "At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30" + "Ey\32G{\30Ey\32G{\34H|\34H|\35I}\35I}\35I}\35I}\20L\177\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\26O\202\26O\202\26O\202K\312\363K\312\363\27P\203\27" + "P\203\27P\203\0\0\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\5\40H\2\36" + "E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\2\36E\5\40H\2\36" + "E\2\36E\5\40H\5\40H\5\40H\5\40H\0\"M\4\37M\4\37M\4\37M\4\37M\4\37M\0" + "\"M\0\"M\0\"M\5\40H\0$P\0$P\0%Q\0$P\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0" + "%Q\14#Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2'T\2'T\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\10*X\10*X\10*XK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6" + "=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23" + "Bv\23Bv\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\32G{\30Ey\34H|\32G{\34" + "H|\32G{\35I}\35I}\35I}\35I}\20L\177\224\257\306\224\257\306\224\257\306" + "\224\257\306\230\253\304\224\257\306\230\253\304\233\267\316\310\324" + "\342\367\375\377\376\377\374\376\377\374\246\276\317\225\260\307\26O" + "\202\26O\202\26O\202K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\2" + "\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5" + "\40H\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\5\40H\5\40H\5\40H\5\40" + "H\5\40H\4\37M\0\"M\4\37M\4\37M\4\37M\4\37M\0\"M\14#Q\0\"M\0\"M\0$P\0" + "$P\0$P\14#Q\0%Q\0$P\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\2" + "'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X1Lq\337\344" + "\347\376\377\374\325\332\334\13""6c\10*X\10*X\10*XK\312\363K\312\363" + "\12+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6" + "=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\15@s\23" + "Bv\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30" + "Ey\30Ey\30Ey\32G{\34H|\32G{\34H|\20L\177\35I}\35I}\35I}\34H|\20L\177" + "\20L\177\20L\177\35I}\22M\200\22M\200\22M\200\24N\201\24N\201\24N\201" + "\26O\202\26O\202_\200\247\376\377\374\376\377\374\215\250\277\26O\202" + "\26O\202\27P\203K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\2\36E" + "\2\36E\5\40H\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40" + "H\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\4" + "\37M\4\37M\4\37M\4\37M\4\37M\4\37M\0\"M\14#Q\0\"M\0#O\0$P\0#O\0%Q\14" + "#Q\0$P\0$P\0%Q\0%Q\14#Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\2'T\14#Q\2" + "'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X/Jo\376" + "\377\374\376\377\374\320\331\341\10*X\12+Y\12+YK\312\363K\312\363\12" + "+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6" + "=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11>q\11>q\11>q\11>q" + "\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\15@s\17At\17" + "At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30" + "Ey\30Ey\30Ey\34H|\32G{\34H|\32G{\35I}\35I}\35I}\35I}\35I}\20L\177\20" + "L\177\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\24N\201\26O\202" + "\26O\202\26O\202\202\231\266\376\377\374\376\377\374\363\370\373\26O" + "\202\27P\203\27P\203K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\2" + "\36E\5\40H\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5" + "\40H\2\36E\2\36E\5\40H\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\0\"" + "M\4\37M\4\37M\4\37M\4\37M\0\"M\4\37M\0\"M\0#O\0$P\0#O\0$P\0$P\14#Q\0" + "%Q\14#Q\0%Q\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\2'T\2'T\14#Q" + "\2'T\2'T\2'T\2'T\217\236\261\221\244\274\217\236\261\221\244\274\217" + "\236\261\217\236\261\217\236\261\222\242\264\232\251\274\303\314\324" + "\376\377\374\376\377\374\376\377\374\364\371\374\10*X\12+Y\12+YK\312" + "\363K\312\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\11>q\6=p\6=p\6=" + "p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\15" + "@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30" + "Ey\30Ey\30Ey\30Ey\32G{\34H|\32G{\34H|\34H|\34H|\34H|\35I}\35I}\35I}\35" + "I}\20L\177\20L\177\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\330\341\351\26O\202\27P\203\27P" + "\203K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\2\36E\2\36E\2\36E" + "\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2" + "\36E\5\40H\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40" + "H\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\4\37M\0\"M\4\37M\0\"M\4\37" + "M\0\"M\4\37M\0\"M\0\"M\14#Q\0#O\0$P\14#Q\0%Q\0%Q\0$P\14#Q\0%Q\0%Q\14" + "#Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374|\217\247\10*X\12+Y\12+YK\312\363K\312\363\12+Y\12+Y\12+" + "Y\0\0\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=" + "p\6=p\6=p\6=p\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q" + "\11>q\11>q\11>q\15@s\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\24Cw\23" + "Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\32G{\30Ey\20" + "L\177\34H|\34H|\34H|\35I}\35I}\35I}\35I}\35I}\20L\177\35I}\20L\177\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\303\317\335\36S\207\26O\202\27P\203\27P\203K\312\363K\312\363\27" + "P\203\27P\203\27P\203\0\0\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\5\40H\2\36E\2\36E\5\40H\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5" + "\40H\4\37M\4\37M\4\37M\4\37M\4\37M\0\"M\0\"M\0\"M\14#Q\0\"M\0#O\0$P\0" + "$P\0$P\14#Q\0$P\0$P\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q" + "\2'T\2'T\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\367" + "\375\377\353\360\363\275\305\315e|\231\13,Z\10*X\12+Y\12+Y\12+YK\312" + "\363K\312\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p" + "\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\17At\15@s\15@s\15@s\17At\17" + "At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30" + "Ey\30Ey\32G{\30Ey\32G{\34H|\34H|\34H|\34H|\35I}\35I}\35I}\20L\177\35" + "I}\20L\177\20L\177\35I}\22M\200\22M\200\24N\201\24N\201\24N\201\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\27P" + "\203\27P\203\27P\203K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2" + "\36E\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\4\37M\0\"M\4\37M\4\37M\0\"M" + "\0\"M\0\"M\0\"M\14#Q\0#O\0$P\0#O\0$P\0%Q\0$P\14#Q\0$P\14#Q\0%Q\14#Q\14" + "#Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\2'T\2'T\2'T\2'T\14#Q\2'T\2'T\10*X\2'" + "T\10*X\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*X\12+Y\12+Y\12+YK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\11>q\11>" + "q\11>q\11>q\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\6=p\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15" + "@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24" + "Cw\30Ey\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\20L\177\34H|\32G{\34H|\34H|\35" + "I}\20L\177\35I}\34H|\20L\177\20L\177\20L\177\20L\177\20L\177\22M\200" + "\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\35I}\26O\202\26O\202" + "\26O\202\26O\202\26O\202\26O\202\26O\202\27P\203\27P\203\27P\203K\312" + "\363K\312\363\27P\203\27P\203\27P\203\0\0\2\36E\2\36E\2\36E\2\36E\2\36" + "E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5" + "\40H\2\36E\5\40H\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\5\40H\5\40H\5\40" + "H\5\40H\4\37M\4\37M\4\37M\4\37M\4\37M\0\"M\4\37M\0\"M\0#O\0$P\0#O\0$" + "P\0$P\14#Q\0$P\0$P\0$P\0%Q\14#Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\0%" + "Q\2'T\14#Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12+Y\12+YK\312\363" + "K\312\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\6=p\6=p\6=p\6=p\6=p" + "\6=p\6=p\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q" + "\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\15@s\17At\17At\23Bv\23" + "Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30" + "Ey\32G{\32G{\32G{\34H|\34H|\32G{\35I}\35I}\35I}\34H|\20L\177\35I}\20" + "L\177\20L\177\22M\200\22M\200\22M\200\22M\200\24N\201\24N\201\26O\202" + "\26O\202\33Q\205\177\237\272\331\342\352\366\373\376\357\364\367\303" + "\317\335_\200\247\26O\202\27P\203\27P\203\27P\203\27P\203K\312\363K\312" + "\363\27P\203\27P\203\27P\203\0\0\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E" + "\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\2" + "\36E\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\5\40H\5\40H\5\40H\0\"M\4\37" + "M\4\37M\0\"M\4\37M\4\37M\0\"M\14#Q\0\"M\0\"M\0\"M\0$P\0#O\0#O\0$P\0$" + "P\14#Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\2'T\14#Q\2" + "'T\2'T\2'T\2'T\2'T\2'T\2'T\27""5]\204\230\257\333\340\343\370\372\367" + "\353\360\363\242\261\305#=g\15-[\270\303\321\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374o\206\243\12+Y\12+Y\12" + "+Y\12+YK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\11>" + "q\6=p\6=p\6=p\6=p\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\15@s\17At\17" + "At\23Bv\23Bv\23Bv\24Cw\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30" + "Ey\30Ey\30Ey\32G{\32G{\34H|\34H|\34H|\32G{\35I}\35I}\35I}\34H|\20L\177" + "\20L\177\20L\177\20L\177\24N\201\276\312\330\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\333\344\354\202\242\276\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\366\373\3763e\224\27P\203\27P\203\27P\203K\312\363K\312\363" + "\27P\203\27P\203\27P\203\0\0\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36" + "E\5\40H\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2" + "\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\0\"M\0\"M\4\37M\4\37M" + "\4\37M\0\"M\4\37M\0\"M\14#Q\0\"M\0#O\0$P\0$P\0$P\0$P\14#Q\0%Q\14#Q\0" + "%Q\0%Q\14#Q\14#Q\0%Q\0%Q\0%Q\0%Q\14#Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'" + "T\2'T\2'T\2'TRj\205\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\367\375\377\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\204\230\257\12+Y\12+Y\12+YK\312\363K\312\363\12+Y\12+Y\12+Y\0\0" + "\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15" + "@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24" + "Cw\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\20L\177\34H|\34H|\20L\177" + "\34H|\34H|\35I}\35I}\35I}\35I}\20L\177\20L\177\35I}\35I}\246\276\317" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\300\314\332\231" + "\264\313\313\327\345\376\377\374\376\377\374\376\377\374\310\324\342" + "\27P\203\27P\203\27P\203K\312\363K\312\363\27P\203\27P\203\27P\203\0" + "\0\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H" + "\2\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\5\40H\5\40H\5\40H\5" + "\40H\0\"M\5\40H\0\"M\4\37M\4\37M\0\"M\4\37M\0\"M\4\37M\0\"M\0\"M\14#" + "Q\0#O\0$P\0#O\0$P\0$P\0$P\14#Q\0%Q\14#Q\0%Q\0%Q\14#Q\14#Q\0%Q\0%Q\0%" + "Q\0%Q\0%Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\320\331\341\376" + "\377\374\376\377\374\365\372\375\247\262\300\242\261\305\370\372\367" + "\376\377\374\376\377\374\376\377\374\204\230\257\10*X\10*X\12+Y\242\261" + "\305\376\377\374\376\377\374\350\355\360\12+Y\12+Y\12+YK\312\363K\312" + "\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q" + "\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\15@s\15@s\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23" + "Bv\23Bv\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\32G{\30Ey\34" + "H|\32G{\34H|\34H|\34H|\35I}\20L\177\35I}\35I}\35I}\20L\177\35I}\22M\200" + "\22M\200\357\364\367\376\377\374\376\377\374y\231\265\24N\201\26O\202" + "r\227\267\376\377\374\376\377\374\376\377\374-`\217\26O\202\27P\203\27" + "P\203Tv\234\376\377\374\376\377\374\366\373\376\27P\203\27P\203\27P\203" + "K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\2\36E\2\36E\5\40H\2\36" + "E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2" + "\36E\5\40H\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\0\"M\4\37M\4\37M\4\37" + "M\4\37M\4\37M\0\"M\0\"M\14#Q\0\"M\0\"M\0\"M\0$P\0#O\0%Q\14#Q\0$P\14#" + "Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\0%Q\0%Q\14#Q\2'T\2'T\2'T" + "\2'T\2'T\2'T\2'T\2'T\2'T\10*X\372\374\371\376\377\374\376\377\374#Gp" + "\10*X\10*X/Jo\376\377\374\376\377\374\376\377\374\13,Z\10*X\12+Y\12+" + "Y,Ep\376\377\374\376\377\374\376\377\374\12+Y\12+Y\12+YK\312\363K\312" + "\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q" + "\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\15@s\15@s\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23" + "Bv\24Cw\24Cw\24Cw\24Cw\30Ey\24Cw\30Ey\30Ey\30Ey\30Ey\32G{\32G{\34H|\32" + "G{\20L\177\34H|\35I}\35I}\34H|\35I}\20L\177\20L\177\20L\177\35I}\22M" + "\200\22M\200\22M\200\376\377\374\376\377\374\376\377\3743e\224\26O\202" + "\26O\2023e\224\376\377\374\376\377\374\376\377\374\26O\202\27P\203\27" + "P\203\27P\2033e\224\376\377\374\376\377\374\376\377\374\27P\203\27P\203" + "\27P\203K\312\363K\312\363\27P\203\27P\203\27P\203\0\0\2\36E\5\40H\2" + "\36E\2\36E\2\36E\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\2\36E\5\40H\2\36" + "E\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\0\"M\4\37M\4\37M\4" + "\37M\4\37M\4\37M\0\"M\4\37M\0\"M\0\"M\0$P\0#O\0$P\0#O\14#Q\0%Q\14#Q\14" + "#Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\14#Q\0%Q\0%Q\0%Q\0%Q\0%Q\2'T\14#Q\2'T\2" + "'T\2'T\2'T\2'T\2'T\2'T\10*X\2'T\10*X\376\377\374\376\377\374\376\377" + "\374,Ep\10*X\10*X\"Fo\376\377\374\376\377\374\376\377\374\12+Y\12+Y\12" + "+Y\12+Y,Ep\376\377\374\376\377\374\376\377\374\12+Y\12+Y\12+YK\312\363" + "K\312\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q" + "\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15" + "@s\15@s\15@s\15@s\15@s\15@s\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24" + "Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\32G{\32G{\34H|\34" + "H|\32G{\34H|\35I}\35I}\35I}\34H|\20L\177\20L\177\35I}\20L\177\20L\177" + "\22M\200\22M\200\22M\200\376\377\374\376\377\374\376\377\374\242\271" + "\313\225\260\307\225\260\307\242\271\313\376\377\374\376\377\374\376" + "\377\374\225\260\307\225\260\307\225\260\307\235\261\311\242\271\313" + "\376\377\374\376\377\374\376\377\374\27P\203\27P\203\27P\203K\312\363" + "K\312\363\35I}\27P\203\27P\203\0\0\5\40H\2\36E\2\36E\2\36E\2\36E\5\40" + "H\2\36E\5\40H\2\36E\2\36E\2\36E\5\40H\2\36E\2\36E\5\40H\5\40H\5\40H\5" + "\40H\5\40H\5\40H\5\40H\4\37M\0\"M\4\37M\4\37M\4\37M\0\"M\4\37M\0\"M\14" + "#Q\0\"M\0#O\0$P\0$P\0#O\14#Q\0$P\0%Q\14#Q\0%Q\14#Q\14#Q\0%Q\14#Q\14#" + "Q\14#Q\14#Q\0%Q\0%Q\14#Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T" + "\10*X\2'T\10*X\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\12+Y\12+Y\12+YK\312\363K\312\363\12+Y\12+Y\12" + "+Y\0\0\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\15@s\15@s\17At\17" + "At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30" + "Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\32G{\34H|\32G{\34H|\35I}\35I}\35I}\35" + "I}\20L\177\35I}\20L\177\35I}\22M\200\22M\200\22M\200\24N\201\24N\201" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\27P\203\27P\203\27P\203K\312\363K\312\363\27P\203\27P\203" + "\27P\203\0\0\5\40H\2\36E\5\40H\2\36E\2\36E\5\40H\2\36E\5\40H\2\36E\2" + "\36E\2\36E\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\4\37M\0\"" + "M\4\37M\0\"M\4\37M\4\37M\0\"M\0\"M\0#O\0\"M\0\"M\5\40H\0$P\0#O\0$P\0" + "%Q\0$P\14#Q\0$P\0%Q\0%Q\0%Q\14#Q\14#Q\14#Q\14#Q\14#Q\0%Q\0%Q\14#Q\0%" + "Q\2'T\2'T\2'T\2'T\14#Q\2'T\2'T\2'T\10*X\2'T\10*X\10*X\10*X\10*X\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\12+Y\12+Y\12+YK\312\363K\312\363\12+Y\12+Y\12+Y\0\0\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\15@s\15@s\15@s\15@s\15@s\15@s\17At\17At\17At\23Bv\23Bv\23Bv\24" + "Cw\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32" + "G{\34H|\32G{\34H|\34H|\32G{\35I}\35I}\35I}\35I}\20L\177\20L\177\20L\177" + "\20L\177\22M\200\22M\200\22M\200\24N\201\24N\201\24N\201\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\33Q\205\33Q\205\33Q\205K\312\363K\312\363\33Q\205\33Q\205\33Q\205\0" + "\0\2\36E\2\36E\5\40H\2\36E\5\40H\2\36E\5\40H\2\36E\2\36E\5\40H\5\40H" + "\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\4\37M\4\37M\4\37M\4\37M\0\"M\4\37" + "M\0\"M\0\"M\0\"M\14#Q\0\"M\0#O\0$P\0#O\0$P\0$P\0$P\0%Q\14#Q\14#Q\14#" + "Q\0%Q\0%Q\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\0%Q\14#Q\0%Q\2'T\14#Q\2'T\2'T\2'" + "T\2'T\2'T\2'T\10*X\10*X\2'T\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10" + "*X\10*X\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\0\0\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\17At\15" + "@s\15@s\15@s\17At\17At\17At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24" + "Cw\24Cw\24Cw\30Ey\30Ey\30Ey\30Ey\30Ey\30Ey\32G{\30Ey\34H|\20L\177\34" + "H|\34H|\35I}\35I}\35I}\34H|\35I}\20L\177\20L\177\20L\177\20L\177\35I" + "}\22M\200\22M\200\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26" + "O\202\26O\202\26O\202\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\27P\203\27P\203\27P\203\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\0\0\2\36E\2\36E" + "\5\40H\2\36E\2\36E\5\40H\2\36E\5\40H\5\40H\5\40H\5\40H\5\40H\5\40H\5" + "\40H\5\40H\0\"M\4\37M\0\"M\4\37M\4\37M\4\37M\4\37M\4\37M\0\"M\0#O\0\"" + "M\0\"M\0$P\0$P\0#O\0#O\14#Q\0%Q\14#Q\0$P\14#Q\0%Q\0%Q\0%Q\14#Q\0%Q\14" + "#Q\14#Q\0%Q\0%Q\14#Q\0%Q\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\2'T\10*X\10" + "*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\10*X\12+Y\12+Y\12" + "+Y\12+Y\12+Y\12+Y\12+Y\12+Y\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13,Z\13" + ",Z\13,Z\13,Z\13,Z\13,Z\0\0\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11>q\11" + ">q\11>q\11>q\11>q\11>q\11>q\15@s\15@s\15@s\15@s\15@s\15@s\15@s\17At\17" + "At\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\23Bv\24Cw\24Cw\24Cw\24Cw\24Cw\24Cw\30" + "Ey\24Cw\30Ey\30Ey\30Ey\30Ey\32G{\34H|\32G{\34H|\20L\177\35I}\35I}\20" + "L\177\35I}\34H|\20L\177\20L\177\20L\177\35I}\22M\200\22M\200\22M\200" + "\24N\201\24N\201\26O\202\26O\202\26O\202\26O\202\26O\202\26O\202\26O" + "\202\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203\27P\203" + "\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q" + "\205\33Q\205\33Q\205\33Q\205\33Q\205\33Q\205\0\0", +}; + + diff --git a/polymer/build/rsrc/game.bmp b/polymer/build/rsrc/game.bmp new file mode 100644 index 000000000..1b00a3ad0 Binary files /dev/null and b/polymer/build/rsrc/game.bmp differ diff --git a/polymer/build/rsrc/game.xcf b/polymer/build/rsrc/game.xcf new file mode 100644 index 000000000..fadc54b2d Binary files /dev/null and b/polymer/build/rsrc/game.xcf differ diff --git a/polymer/build/rsrc/game_banner.c b/polymer/build/rsrc/game_banner.c new file mode 100644 index 000000000..8ecff2fca --- /dev/null +++ b/polymer/build/rsrc/game_banner.c @@ -0,0 +1,2691 @@ +#include + + + + + + + +/* GdkPixbuf RGB C-Source image dump */ + +const GdkPixdata startbanner_pixdata = { + 0x47646b50, /* Pixbuf magic: 'GdkP' */ + 24 + 76160, /* header length + pixel_data length */ + 0x1010001, /* pixdata_type */ + 272, /* rowstride */ + 90, /* width */ + 280, /* height */ + /* pixel_data: */ + "\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\30""1\1\25" + "0\10\30""1\1\25""0\10\30""1\1\30""1\1\23""3\3\27""1\12\23""3\3\23""3" + "\3\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3" + "\30""1\1\23""3\3\27""1\12\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25" + "5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\31""9\13\32" + "8\2\32""8\2\27""8\11\34:\5\34:\5\27""8\11\34:\5\27=\7\27=\7\27=\7\27" + "=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32" + "\77\12\32\77\12\36B\5\32\77\12\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5" + "\33A\14\36B\5\33A\14\33A\14\0\0.W\23.W\23.W\23.W\23.W\23.W\23.W\23""2" + "Z\15.W\23.W\23.W\23.W\23""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""2Z\15""0" + "Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0" + "Y\24""2Z\15-\\\16-\\\16""0Y\24-\\\16-\\\16""3[\16/^\20""3[\16/^\20/^" + "\20/^\20""3[\16""0_\21""3[\16""0_\21""0_\21""0_\21""2a\23""2a\23""2a" + "\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""7" + "e\17""7e\17""7e\17""7e\17""9g\21""7f\30""4j\23""4j\23""9g\21""4j\23""5" + "k\24""4j\23""9g\21""5k\24""9g\21""5k\24""4j\23""5k\24""9g\21""4j\23""5" + "k\24""5k\24""5k\24""6l\25""9g\21""5k\24""5k\24""5k\24""5k\24""6l\25""9" + "g\21\0\0\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\25" + "0\10\30""1\1\25""0\10\25""0\10\23""3\3\23""3\3\27""1\12\23""3\3\27""1" + "\12\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3\23""3\3\23""3\3\30" + "1\1\23""3\3\23""3\3\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25" + "5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\32" + "8\2\32""8\2\27""8\11\34:\5\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\27=\7" + "\30>\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32" + "\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36" + "B\5\33A\14\36B\5\33A\14\0\0.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23." + "W\23""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0" + "Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""2Z\15""2" + "Z\15""2Z\15""3[\16-\\\16""3[\16""0Y\24/^\20/^\20""3[\16/^\20/^\20/^\20" + "3[\16""0_\21""0_\21""3[\16""0_\21""3[\16""2a\23""2a\23""2a\23""2a\23" + "3b\24""3b\24""3b\24""3b\24""3b\24""7e\17""5d\26""5d\26""5d\26""5d\26" + "7e\17""5d\26""9g\21""9g\21""9g\21""4j\23""4j\23""4j\23""9g\21""4j\23" + "9g\21""4j\23""9g\21""5k\24""9g\21""5k\24""9g\21""4j\23""9g\21""5k\24" + "9g\21""6l\25""9g\21""5k\24""5k\24\202\320q\202\320q9g\21""6l\25""9g\21" + "\0\0\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\30""1\1\25""0\10\25""0" + "\10\23""3\3\27""1\12\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3" + "\27""1\12\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\27" + "1\12\23""3\3\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\31""9\13\31""9\13\32" + "8\2\27""8\11\34:\5\31""9\13\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\35;\6" + "\30>\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\32\77\12\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\36B\5" + "\202\320q\202\320q\33A\14\36B\5\33A\14\0\0.W\23.W\23.W\23""2Z\15.W\23" + "0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24" + "0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24" + "2Z\15""2Z\15""2Z\15""0Y\24-\\\16-\\\16""0Y\24/^\20/^\20/^\20/^\20""3" + "[\16/^\20/^\20""3[\16""3[\16""0_\21""3[\16""0_\21""2a\23""2a\23""2a\23" + "2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""7e\17" + "5d\26""5d\26""7e\17""5d\26""9g\21""7f\30""4j\23""4j\23""4j\23""9g\21" + "4j\23""9g\21""9g\21""4j\23""9g\21""5k\24""9g\21""5k\24""9g\21""6l\25" + "9g\21""5k\24""9g\21""5k\24""6l\25""9g\21""6l\25""5k\24\202\320q\202\320" + "q5k\24""6l\25""5k\24\0\0\30""1\1\25""0\10\30""1\1\23""3\3\27""1\12\23" + "3\3\23""3\3\27""1\12\30""1\1\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3" + "\27""1\12\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\30""1\1\23" + "3\3\30""1\1\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\32""8\2\32""8\2\31""9" + "\13\34:\5\27""8\11\31""9\13\34:\5\31""9\13\27=\7\27=\7\27=\7\30>\10\30" + ">\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\36" + "B\5\33A\14\202\320q\202\320q\36B\5\33A\14\36B\5\0\0.W\23""0Y\24""2Z\15" + "0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15" + "0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24" + "0Y\24""2Z\15""0Y\24-\\\16-\\\16""3[\16-\\\16""3[\16/^\20/^\20""3[\16" + "/^\20/^\20""3[\16""3[\16""0_\21""0_\21""3[\16""0_\21""0_\21""2a\23""2" + "a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5" + "d\26""7e\17""7e\17""7e\17""9g\21""7f\30""9g\21""4j\23""4j\23""4j\23""9" + "g\21""4j\23""9g\21""4j\23""4j\23""4j\23""9g\21""5k\24""9g\21""9g\21""5" + "k\24""9g\21""5k\24""9g\21""5k\24""9g\21""5k\24""9g\21""6l\25""5k\24""5" + "k\24\202\320q\202\320q9g\21""6l\25""6l\25\0\0\27""1\12\30""1\1\23""3" + "\3\23""3\3\30""1\1\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3\27""1\12\23" + "3\3\23""3\3\30""1\1\30""1\1\23""3\3\23""3\3\23""3\3\23""3\3\27""1\12" + "\23""3\3\27""1\12\23""3\3\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25" + "5\6\25""5\6\27""7\10\27""7\10\25""5\6\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\32" + "8\2\32""8\2\32""8\2\34:\5\27""8\11\34:\5\34:\5\27=\7\27=\7\27=\7\27=" + "\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32" + "\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\32\77\12\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\33" + "A\14\36B\5\33A\14\36B\5\202\320q\202\320q\33A\14\33A\14\36B\5\0\0""0" + "Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0" + "Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0" + "Y\24""0Y\24""0Y\24""2Z\15""0Y\24-\\\16-\\\16-\\\16-\\\16""3[\16""3[\16" + "/^\20/^\20/^\20/^\20""3[\16""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21" + "2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""7e\17""5d\26" + "5d\26""7e\17""5d\26""5d\26""7e\17""9g\21""9g\21""7f\30""5k\24""9g\21" + "9g\21""9g\21""4j\23""9g\21""4j\23""9g\21""4j\23""9g\21""5k\24""9g\21" + "4j\23""9g\21""6l\25""5k\24""6l\25""5k\24""6l\25""5k\24""9g\21""5k\24" + "9g\21""6l\25""5k\24\202\320q\202\320q5k\24""9g\21""5k\24\0\0\23""3\3" + "\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\23" + "3\3\27""1\12\30""1\1\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\30""1\1" + "\23""3\3\27""1\12\23""3\3\24""4\5\24""4\5\30""1\1\25""5\6\25""5\6\25" + "5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\32" + "8\2\31""9\13\32""8\2\31""9\13\34:\5\34:\5\34:\5\34:\5\27=\7\27=\7\27" + "=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32" + "\77\12\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14\36" + "B\5\33A\14\33A\14\36B\5\33A\14\36B\5\202\320q\202\320q\36B\5\33A\14\36" + "B\5\0\0""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24" + "0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24" + "0Y\24""0Y\24""2Z\15""0Y\24-\\\16-\\\16-\\\16-\\\16""0Y\24/^\20""3[\16" + "/^\20/^\20""3[\16""3[\16""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""0" + "_\21""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""7e\17""5" + "d\26""7e\17""5d\26""5d\26""5d\26""7e\17""7f\30""9g\21""7f\30""9g\21""5" + "k\24""9g\21""4j\23""9g\21""4j\23""4j\23""9g\21""4j\23""4j\23""5k\24""6" + "l\25""9g\21""5k\24""5k\24""9g\21""6l\25""5k\24""9g\21""9g\21""5k\24""9" + "g\21""6l\25""9g\21""5k\24""5k\24\202\320q\202\320q5k\24""9g\21""5k\24" + "\0\0\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3" + "\27""1\12\23""3\3\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\27" + "1\12\23""3\3\30""1\1\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6" + "\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9" + "\13\32""8\2\31""9\13\32""8\2\27""8\11\34:\5\27""8\11\34:\5\34:\5\27=" + "\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\36" + "B\5\32\77\12\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33" + "A\14\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\202\320q\202\320" + "q\36B\5\33A\14\36B\5\0\0""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2" + "Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0" + "Y\24""0Y\24""2Z\15""2Z\15""0Y\24""3[\16-\\\16-\\\16-\\\16""3[\16-\\\16" + "3[\16/^\20""3[\16/^\20/^\20/^\20""0_\21""0_\21""3[\16""0_\21""3[\16""0" + "_\21""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""7" + "e\17""5d\26""7e\17""7e\17""7e\17""7e\17""7e\17""7f\30""9g\21""4j\23""9" + "g\21""5k\24""9g\21""5k\24""4j\23""9g\21""5k\24""4j\23""9g\21""4j\23""9" + "g\21""6l\25""9g\21""5k\24""9g\21""6l\25""5k\24""9g\21""5k\24""5k\24""5" + "k\24""9g\21""5k\24""6l\25""9g\21""5k\24""9g\21\202\320q\202\320q5k\24" + "5k\24""9g\21\0\0\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\23" + "3\3\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3" + "\23""3\3\27""1\12\24""4\5\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25" + "5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31" + "9\13\32""8\2\31""9\13\32""8\2\31""9\13\34:\5\27""8\11\34:\5\27=\7\27" + "=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5" + "\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32" + "\77\12\32\77\12\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14" + "\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\36B\5\33A\14\33A\14\202\320q" + "\202\320q\33A\14\33A\14\36B\5\0\0""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24" + "2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24" + "0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15-\\\16-\\\16-\\\16""0Y\24/^\20" + "3[\16/^\20""3[\16/^\20""3[\16""3[\16""0_\21""0_\21""0_\21""0_\21""0_" + "\21""3[\16""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3" + "b\24""7e\17""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21""9g\21""9g\21""5" + "k\24""9g\21""9g\21""4j\23""5k\24""4j\23""5k\24""9g\21""9g\21""4j\23""9" + "g\21""6l\25""5k\24""6l\25""6l\25""9g\21""6l\25""9g\21""6l\25""9g\21""6" + "l\25""9g\21""5k\24""9g\21""5k\24""6l\25""5k\24""9g\21""5k\24\202\320" + "q\202\320q9g\21""5k\24""5k\24\0\0\27""1\12\30""1\1\23""3\3\23""3\3\23" + "3\3\27""1\12\23""3\3\27""1\12\30""1\1\23""3\3\23""3\3\27""1\12\23""3" + "\3\23""3\3\30""1\1\24""4\5\24""4\5\24""4\5\24""4\5\24""4\5\30""1\1\25" + "5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\31""9\13\32""8\2\31""9\13\32""8\2\27""8\11\34:\5\34:\5\27""8\11" + "\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\36B\5\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12" + "\32\77\12\32\77\12\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A" + "\14\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\33" + "A\14\33A\14\202\320q\202\320q\33A\14\36B\5\33A\14\0\0""0Y\24""0Y\24""0" + "Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0" + "Y\24""2Z\15""2Z\15""0Y\24""0Y\24""2Z\15""2Z\15-\\\16-\\\16""3[\16-\\" + "\16/^\20""3[\16/^\20""3[\16/^\20""3[\16/^\20""0_\21""3[\16""0_\21""0" + "_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3" + "b\24""3b\24""5d\26""5d\26""7e\17""5d\26""5d\26""7e\17""5d\26""9g\21""9" + "g\21""4j\23""5k\24""9g\21""5k\24""9g\21""4j\23""9g\21""9g\21""5k\24""9" + "g\21""5k\24""9g\21""5k\24""9g\21""6l\25""9g\21""6l\25""5k\24""6l\25""9" + "g\21""9g\21""9g\21""6l\25""9g\21""9g\21""9g\21""9g\21""5k\24""9g\21""5" + "k\24""9g\21\202\320q\202\320q9g\21""5k\24""9g\21\0\0\27""1\12\23""3\3" + "\27""1\12\23""3\3\30""1\1\27""1\12\23""3\3\27""1\12\23""3\3\23""3\3\23" + "3\3\23""3\3\27""1\12\24""4\5\24""4\5\24""4\5\24""4\5\24""4\5\25""5\6" + "\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\31""9\13\32""8\2\31""9\13\32""8\2\31""9\13\34:\5\34:\5\34" + ":\5\31""9\13\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12" + "\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77" + "\12\36B\5\32\77\12\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\33" + "A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\33" + "A\14\33A\14\36B\5\33A\14\202\320q\202\320q\33A\14\36B\5\33A\14\0\0""0" + "Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2" + "Z\15""0Y\24""2Z\15""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15-\\\16""3[\16-\\" + "\16/^\20/^\20/^\20""3[\16/^\20""3[\16/^\20""3[\16""0_\21""0_\21""0_\21" + "0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24" + "3b\24""3b\24""5d\26""5d\26""5d\26""5d\26""7e\17""5d\26""7e\17""9g\21" + "4j\23""4j\23""4j\23""9g\21""5k\24""9g\21""5k\24""4j\23""4j\23""5k\24" + "4j\23""5k\24""9g\21""5k\24""9g\21""5k\24""6l\25""9g\21""6l\25""9g\21" + "5k\24""9g\21""6l\25""9g\21""5k\24""5k\24""9g\21""5k\24""5k\24""9g\21" + "9g\21""5k\24""6l\25\202\320q\202\320q5k\24""6l\25""9g\21\0\0\23""3\3" + "\23""3\3\27""1\12\23""3\3\30""1\1\30""1\1\27""1\12\23""3\3\23""3\3\30" + "1\1\23""3\3\24""4\5\24""4\5\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25" + "5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32" + "8\2\31""9\13\31""9\13\31""9\13\32""8\2\34:\5\34:\5\31""9\13\34:\5\34" + ":\5\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\36B\5\32" + "\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\36B\5\36" + "B\5\33A\14\33A\14\33A\14\33A\14\36B\5\36B\5\33A\14\33A\14\33A\14\33A" + "\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14" + "\36B\5\33A\14\202\320q\202\320q\33A\14\36B\5\33A\14\0\0""2Z\15""0Y\24" + "0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24" + "2Z\15""0Y\24""0Y\24-\\\16""3[\16-\\\16""0Y\24/^\20""3[\16/^\20/^\20/" + "^\20/^\20""3[\16/^\20/^\20""0_\21""0_\21""3[\16""0_\21""0_\21""0_\21" + "2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26" + "5d\26""7e\17""7e\17""7e\17""5d\26""9g\21""9g\21""9g\21""4j\23""5k\24" + "9g\21""5k\24""5k\24""9g\21""5k\24""9g\21""4j\23""6l\25""5k\24""9g\21" + "5k\24""9g\21""6l\25""5k\24""5k\24""9g\21""5k\24""9g\21""5k\24""6l\25" + "9g\21""6l\25""9g\21""6l\25""6l\25""9g\21""5k\24""6l\25""9g\21""6l\25" + "6l\25\202\320q\202\320q9g\21""6l\25""5k\24\0\0\23""3\3\30""1\1\27""1" + "\12\23""3\3\30""1\1\27""1\12\23""3\3\23""3\3\24""4\5\24""4\5\24""4\5" + "\24""4\5\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\31" + "9\13\31""9\13\34:\5\27""8\11\34:\5\27""8\11\34:\5\27=\7\27=\7\27=\7\27" + "=\7\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5" + "\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36" + "B\5\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14" + "\36B\5\36B\5\202\320q\202\320q\33A\14\33A\14\36B\5\0\0""2Z\15""0Y\24" + "0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""2Z\15""0Y\24""2Z\15""0Y\24" + "-\\\16""3[\16-\\\16-\\\16-\\\16-\\\16""3[\16""3[\16/^\20""3[\16/^\20" + "/^\20""3[\16/^\20""3[\16""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""2" + "a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5" + "d\26""7e\17""7e\17""5d\26""7e\17""9g\21""7f\30""4j\23""9g\21""4j\23""4" + "j\23""5k\24""9g\21""9g\21""5k\24""9g\21""4j\23""9g\21""5k\24""9g\21""5" + "k\24""6l\25""9g\21""6l\25""5k\24""9g\21""5k\24""5k\24""9g\21""6l\25""6" + "l\25""5k\24""5k\24""6l\25@m\30""6l\25""6l\25""6l\25""6l\25@m\30""6l\25" + "6l\25\202\320q\202\320q9g\21""9g\21""5k\24\0\0\23""3\3\23""3\3\27""1" + "\12\23""3\3\30""1\1\24""4\5\24""4\5\24""4\5\24""4\5\24""4\5\25""5\6\25" + "5\6\25""5\6\25""5\6\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\31""9\13\31""9\13\32" + "8\2\34:\5\34:\5\31""9\13\34:\5\34:\5\27=\7\27=\7\27=\7\30>\10\30>\10" + "\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\33A\14\33A\14\33A\14" + "\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\33" + "A\14\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14\33A\14\33A\14\36B\5\36B\5" + "\33A\14\202\320q\202\320q\33A\14\33A\14\36B\5\0\0""0Y\24""0Y\24""0Y\24" + "0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15-\\\16-\\\16""3[\16""3[\16""3" + "[\16-\\\16-\\\16/^\20/^\20""3[\16/^\20""3[\16/^\20""3[\16/^\20/^\20/" + "^\20""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2" + "a\23""3b\24""3b\24""3b\24""3b\24""7e\17""5d\26""5d\26""7e\17""7e\17""7" + "e\17""9g\21""7f\30""4j\23""9g\21""4j\23""9g\21""9g\21""4j\23""4j\23""9" + "g\21""4j\23""9g\21""9g\21""6l\25""5k\24""5k\24""5k\24""9g\21""6l\25""9" + "g\21""5k\24""5k\24""5k\24""5k\24""5k\24""9g\21""6l\25""9g\21""6l\25""9" + "g\21""6l\25""6l\25@m\30""6l\25""6l\25""6l\25""6l\25@m\30""6l\25\202\320" + "q\202\320q9g\21""5k\24""5k\24\0\0\23""3\3\24""4\5\24""4\5\24""4\5\24" + "4\5\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\25""5\6\25" + "5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\32""8\2\31""9\13\31""9\13\32""8\2\31""9\13\34:\5\34:\5" + "\27""8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32" + "\77\12\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14\33" + "A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\36B\5\36B\5" + "\33A\14\36B\5\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\202\320q" + "\202\320q\36B\5\33A\14\36B\5\0\0""0Y\24""2Z\15""2Z\15""0Y\24""2Z\15""2" + "Z\15""0Y\24""0Y\24-\\\16""3[\16-\\\16""3[\16""0Y\24-\\\16""3[\16/^\20" + "/^\20/^\20""3[\16/^\20/^\20/^\20""3[\16""0_\21""3[\16""0_\21""0_\21""0" + "_\21""3[\16""0_\21""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3" + "b\24""3b\24""5d\26""7e\17""5d\26""5d\26""5d\26""7e\17""9g\21""9g\21""5" + "k\24""9g\21""5k\24""9g\21""4j\23""9g\21""5k\24""9g\21""4j\23""9g\21""6" + "l\25""9g\21""5k\24""9g\21""5k\24""6l\25""6l\25""9g\21""9g\21""6l\25""9" + "g\21""5k\24""9g\21""5k\24""6l\25""6l\25""6l\25@m\30@m\30""6l\25@m\30" + "6l\25""6l\25""6l\25""6l\25""6l\25""6l\25""6l\25\202\320q\202\320q@m\30" + "6l\25""5k\24\0\0\24""4\5\24""4\5\24""4\5\24""4\5\24""4\5\25""5\6\25""5" + "\6\25""5\6\25""5\6\25""5\6\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\31" + "9\13\32""8\2\31""9\13\32""8\2\34:\5\34:\5\34:\5\31""9\13\27=\7\27=\7" + "\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\36B\5\32\77\12\32\77\12" + "\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\33A\14\33A" + "\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14" + "\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\36B\5\36B\5\33A\14" + "\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\202\320q\202\320q\36B\5\36B" + "\5\33A\14\0\0""2Z\15""0Y\24""2Z\15""0Y\24-\\\16""3[\16-\\\16-\\\16""3" + "[\16-\\\16""0Y\24-\\\16/^\20/^\20/^\20""3[\16/^\20""3[\16/^\20""3[\16" + "/^\20""0_\21""0_\21""3[\16""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23" + "2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""7e\17" + "5d\26""5d\26""7e\17""7e\17""7f\30""9g\21""4j\23""9g\21""5k\24""9g\21" + "5k\24""4j\23""4j\23""9g\21""4j\23""5k\24""9g\21""5k\24""9g\21""5k\24" + "9g\21""5k\24""6l\25""9g\21""6l\25""6l\25""9g\21""9g\21""6l\25@m\30""6" + "l\25""6l\25""6l\25@m\30""6l\25@m\30@m\30""6l\25""6l\25""6l\25""6l\25" + "6l\25@m\30""6l\25""6l\25\202\320q\202\320q6l\25""6l\25""9g\21\0\0\24" + "4\5\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\25""5\6\25" + "5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\32""8\2\31""9\13\31""9\13\31""9\13\32""8\2\34:\5\34:\5" + "\34:\5\34:\5\34:\5\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32" + "\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\32\77\12\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\33" + "A\14\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\36B\5\33A\14\33A\14\36B" + "\5\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\36" + "B\5\33A\14\202\320q\202\320q\33A\14\36B\5\33A\14\0\0""3[\16""0Y\24""3" + "[\16-\\\16-\\\16-\\\16-\\\16-\\\16""0Y\24-\\\16/^\20/^\20/^\20""3[\16" + "/^\20/^\20""3[\16/^\20/^\20""0_\21""0_\21""0_\21""0_\21""0_\21""3[\16" + "0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24" + "3b\24""5d\26""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21""9g\21""7f\30" + "4j\23""5k\24""9g\21""4j\23""9g\21""5k\24""4j\23""9g\21""4j\23""9g\21" + "5k\24""6l\25""5k\24""9g\21""6l\25""9g\21""5k\24""6l\25""9g\21""5k\24" + "6l\25""9g\21@m\30@m\30""6l\25""6l\25""6l\25@m\30""6l\25""6l\25""6l\25" + "@m\30""6l\25""6l\25@m\30""6l\25""6l\25""6l\25@m\30""6l\25\202\320q\202" + "\320q6l\25""5k\24""9g\21\0\0\25""5\6\25""5\6\25""5\6\25""5\6\25""5\6" + "\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\31" + "9\13\32""8\2\31""9\13\34:\5\34:\5\27""8\11\34:\5\27=\7\27=\7\27=\7\27" + "=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\33A\14\33A" + "\14\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5" + "\36B\5\36B\5\36B\5\36B\5\33A\14\33A\14\36B\5\36B\5\33A\14\33A\14\36B" + "\5\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\202\320q\202\320" + "q\33A\14\33A\14\33A\14\0\0""0Y\24-\\\16""3[\16-\\\16-\\\16-\\\16-\\\16" + "/^\20""3[\16/^\20""3[\16/^\20""3[\16/^\20/^\20""0Y\24/^\20/^\20""0_\21" + "0_\21""0_\21""0_\21""3[\16""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23" + "2a\23""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""7e\17""5d\26""5d\26" + "7e\17""5d\26""9g\21""9g\21""9g\21""9g\21""5k\24""5k\24""9g\21""5k\24" + "9g\21""4j\23""9g\21""5k\24""5k\24""9g\21""5k\24""9g\21""5k\24""9g\21" + "6l\25""9g\21""9g\21""6l\25""6l\25""9g\21""6l\25""6l\25@m\30""6l\25""6" + "l\25@m\30""6l\25@m\30""6l\25""6l\25""6l\25""6l\25""6l\25""6l\25@m\30" + "6l\25""6l\25""6l\25@m\30""6l\25\202\320q\202\320q6l\25""9g\21""5k\24" + "\0\0\25""5\6\25""5\6\25""5\6\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\31""9\13\32""8\2\32""8\2\31""9\13\32""8\2\27""8\11\34:" + "\5\34:\5\27""8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\32\77\12\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14" + "\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\33" + "A\14\36B\5\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5" + "\36B\5\36B\5\33A\14\36B\5\33A\14\202\320q\202\320q\36B\5\33A\14\33A\14" + "\0\0-\\\16-\\\16""3[\16-\\\16""3[\16/^\20/^\20""3[\16/^\20""3[\16/^\20" + "/^\20""3[\16/^\20/^\20""3[\16""0_\21""0_\21""0_\21""0_\21""3[\16""0_" + "\21""0_\21""3[\16""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3" + "b\24""3b\24""5d\26""5d\26""7e\17""5d\26""5d\26""7e\17""7f\30""7f\30""9" + "g\21""5k\24""9g\21""4j\23""9g\21""4j\23""9g\21""4j\23""9g\21""9g\21""6" + "l\25""9g\21""9g\21""6l\25""5k\24""9g\21""9g\21""9g\21""5k\24""9g\21""5" + "k\24""6l\25@m\30""6l\25@m\30""6l\25""6l\25""6l\25""6l\25@m\30""6l\25" + "@m\30""6l\25@m\30""6l\25@m\30""6l\25""6l\25@m\30""6l\25@m\30""6l\25""6" + "l\25""6l\25\202\320q\202\320q5k\24""9g\21""5k\24\0\0\25""5\6\25""5\6" + "\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\31""9\13\32" + "8\2\31""9\13\27""8\11\31""9\13\34:\5\34:\5\31""9\13\34:\5\27=\7\27=\7" + "\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\33A\14\36B\5\33" + "A\14\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A" + "\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\36" + "B\5\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36" + "B\5\202\320q\202\320q\36B\5\33A\14\33A\14\0\0""3[\16-\\\16-\\\16""3[" + "\16/^\20/^\20/^\20/^\20/^\20/^\20""3[\16/^\20""3[\16/^\20""0_\21""0_" + "\21""0_\21""0_\21""0_\21""3[\16""0_\21""0_\21""0_\21""2a\23""2a\23""2" + "a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""7" + "e\17""5d\26""7e\17""7e\17""9g\21""4j\23""9g\21""4j\23""4j\23""5k\24""4" + "j\23""9g\21""5k\24""9g\21""4j\23""9g\21""6l\25""5k\24""5k\24""5k\24""6" + "l\25""9g\21""6l\25""9g\21""5k\24""9g\21""6l\25""6l\25""6l\25""6l\25@" + "m\30""6l\25@m\30""6l\25@m\30""6l\25""6l\25@m\30""6l\25""6l\25""6l\25" + "6l\25@m\30""6l\25""6l\25""6l\25@m\30""6l\25""6l\25@m\30\202\320q\202" + "\320q5k\24""5k\24""5k\24\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\32""8\2\31""9\13\32""8\2\32""8\2\32""8\2\31""9\13\34:\5" + "\34:\5\34:\5\27""8\11\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12" + "\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32" + "\77\12\32\77\12\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14" + "\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\36B\5\36" + "B\5\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5" + "\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\202\320q\202\320q\36B\5" + "\33A\14\36B\5\0\0/^\20/^\20""3[\16/^\20/^\20""3[\16/^\20/^\20/^\20/^" + "\20/^\20/^\20""3[\16""0_\21""0_\21""3[\16""0_\21""3[\16""0_\21""3[\16" + "0_\21""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24" + "3b\24""5d\26""5d\26""5d\26""5d\26""5d\26""7e\17""7f\30""9g\21""9g\21" + "9g\21""5k\24""9g\21""4j\23""4j\23""9g\21""9g\21""5k\24""9g\21""6l\25" + "9g\21""9g\21""5k\24""6l\25""9g\21""6l\25""9g\21""6l\25""9g\21@m\30""6" + "l\25@m\30""6l\25""6l\25""6l\25@m\30@m\30""6l\25""6l\25""6l\25@m\30""6" + "l\25@m\30""6l\25""6l\25@m\30""6l\25""6l\25""6l\25@m\30@m\30""6l\25@m" + "\30""6l\25""5k\24\202\320q\202\320q5k\24""9g\21""5k\24\0\0\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\32""8\2\31""9\13\32""8\2\31""9\13\32""8\2\34:" + "\5\31""9\13\34:\5\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\36" + "B\5\32\77\12\32\77\12\36B\5\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5" + "\33A\14\33A\14\33A\14\36B\5\36B\5\36B\5\33A\14\36B\5\36B\5\33A\14\36" + "B\5\36B\5\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14\36" + "B\5\33A\14\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14\33A\14\36B\5\202\320" + "q\202\320q\36B\5\33A\14\33A\14\0\0/^\20/^\20""3[\16""3[\16/^\20""3[\16" + "/^\20/^\20/^\20/^\20""0Y\24/^\20""0_\21""0_\21""0_\21""0_\21""0_\21""3" + "[\16""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3" + "b\24""3b\24""5d\26""5d\26""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21""9" + "g\21""9g\21""9g\21""4j\23""4j\23""9g\21""4j\23""4j\23""9g\21""5k\24""5" + "k\24""9g\21""6l\25""9g\21""6l\25""9g\21""5k\24""9g\21""9g\21""5k\24""6" + "l\25""6l\25""6l\25@m\30""6l\25@m\30""6l\25@m\30@m\30""6l\25""6l\25@m" + "\30@m\30""6l\25@m\30""6l\25@m\30""6l\25@m\30""6l\25@m\30""6l\25""6l\25" + "@m\30""6l\25""5k\24""9g\21""5k\24\202\320q\202\320q5k\24""9g\21""5k\24" + "\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\32""8\2\32""8\2\32""8\2\32""8\2\32""8" + "\2\34:\5\31""9\13\34:\5\34:\5\34:\5\27=\7\27=\7\27=\7\30>\10\30>\10\30" + ">\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5" + "\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\36B\5\33A\14" + "\36B\5\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\36B\5\33A\14" + "\36B\5\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14\36B" + "\5\33A\14\202\320q\202\320q\33A\14\33A\14\33A\14\0\0/^\20/^\20""3[\16" + "/^\20""3[\16/^\20/^\20""3[\16/^\20""3[\16""0_\21""0_\21""0_\21""3[\16" + "0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2a\23""2a\23" + "3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""5d\26""5d\26""7e\17" + "5d\26""9g\21""9g\21""5k\24""4j\23""9g\21""5k\24""9g\21""5k\24""9g\21" + "4j\23""9g\21""6l\25""5k\24""5k\24""5k\24""6l\25""5k\24""5k\24""9g\21" + "9g\21""9g\21""9g\21""6l\25""6l\25@m\30@m\30""6l\25""6l\25@m\30""6l\25" + "6l\25@m\30""6l\25@m\30""6l\25@m\30""6l\25@m\30""6l\25@m\30""6l\25""6" + "l\25@m\30""6l\25@m\30@m\30""6l\25""6l\25""5k\24""9g\21\202\320q\202\320" + "q9g\21""5k\24""9g\21\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\31""9\13\31" + "9\13\32""8\2\32""8\2\34:\5\34:\5\34:\5\34:\5\27""8\11\27=\7\27=\7\27" + "=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32" + "\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\33A\14\36B\5\33A\14" + "\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\36" + "B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14\36" + "B\5\36B\5\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\36" + "B\5\33A\14\33A\14\36B\5\33A\14\202\320q\202\320q\33A\14\36B\5\33A\14" + "\0\0/^\20/^\20/^\20/^\20/^\20""3[\16/^\20""3[\16""0_\21""0_\21""0_\21" + "0_\21""3[\16""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23" + "2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""7e\17" + "5d\26""5d\26""7e\17""9g\21""5k\24""4j\23""4j\23""5k\24""9g\21""4j\23" + "5k\24""9g\21""9g\21""6l\25""9g\21""6l\25""6l\25""9g\21""5k\24""9g\21" + "6l\25""5k\24""9g\21""5k\24@m\30""6l\25@m\30""6l\25""6l\25""6l\25""6l" + "\25@m\30""6l\25""6l\25""6l\25@m\30@m\30""6l\25""6l\25@m\30@m\30""6l\25" + "6l\25@m\30""6l\25""6l\25""6l\25@m\30""6l\25@m\30""5k\24""9g\21""6l\25" + "5k\24\202\320q\202\320q6l\25""6l\25""9g\21\0\0\27""7\10\27""7\10\27""7" + "\10\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\31" + "9\13\32""8\2\31""9\13\34:\5\27""8\11\34:\5\31""9\13\34:\5\27=\7\27=\7" + "\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\36B\5\32\77\12\36" + "B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\33A\14" + "\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\36B\5\33" + "A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\36B\5" + "\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14\36B\5\33A\14\33A\14\36B" + "\5\36B\5\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\202\320q\202\320q\33" + "A\14\33A\14\36B\5\0\0/^\20/^\20""3[\16/^\20/^\20/^\20""0_\21""0_\21""0" + "_\21""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2" + "a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""7e\17""5d\26""5" + "d\26""7e\17""5d\26""7e\17""5d\26""9g\21""9g\21""5k\24""9g\21""5k\24""4" + "j\23""9g\21""4j\23""4j\23""5k\24""9g\21""5k\24""9g\21""5k\24""6l\25""6" + "l\25""5k\24""6l\25""5k\24""9g\21""5k\24@m\30""6l\25""6l\25""6l\25""6" + "l\25@m\30""6l\25""6l\25@m\30""6l\25""6l\25@m\30""6l\25@m\30""6l\25@m" + "\30""6l\25@m\30@m\30""6l\25""6l\25""6l\25""6l\25@m\30""6l\25""9g\21""6" + "l\25""9g\21""5k\24""9g\21""5k\24\202\320q\202\320q5k\24""9g\21""4j\23" + "\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\32" + "8\2\31""9\13\31""9\13\32""8\2\31""9\13\34:\5\34:\5\31""9\13\31""9\13" + "\27""8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77" + "\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\36" + "B\5\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5" + "\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\36B" + "\5\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\33A" + "\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14" + "\202\320q\202\320q\36B\5\32\77\12\32\77\12\0\0/^\20/^\20/^\20/^\20""0" + "_\21""3[\16""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""2" + "a\23""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3" + "b\24""7e\17""5d\26""5d\26""7e\17""5d\26""7e\17""7f\30""9g\21""4j\23""9" + "g\21""4j\23""4j\23""4j\23""9g\21""4j\23""5k\24""5k\24""5k\24""9g\21""9" + "g\21""5k\24""6l\25""9g\21""6l\25""9g\21""5k\24""9g\21@m\30""6l\25""6" + "l\25@m\30""6l\25""6l\25@m\30@m\30""6l\25""6l\25@m\30@m\30@m\30""6l\25" + "6l\25""6l\25@m\30@m\30""6l\25""6l\25@m\30""6l\25@m\30""6l\25""6l\25""6" + "l\25""9g\21""6l\25""9g\21""5k\24""9g\21""9g\21""9g\21\202\320q\202\320" + "q5k\24""9g\21""5k\24\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\32""8\2\32""8\2\32""8\2\32""8\2\31""9\13\31""9\13\31""9\13\34:\5" + "\34:\5\34:\5\27""8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77" + "\12\36B\5\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14" + "\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14\36B\5\36B\5\36B" + "\5\33A\14\36B\5\36B\5\36B\5\36B\5\33A\14\33A\14\36B\5\36B\5\33A\14\36" + "B\5\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5" + "\33A\14\33A\14\33A\14\202\320q\202\320q\36B\5\32\77\12\32\77\12\0\0/" + "^\20/^\20""0_\21""3[\16""0_\21""0_\21""0_\21""3[\16""0_\21""3[\16""0" + "_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3" + "b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""7e\17""7e\17""5d\26""9" + "g\21""7f\30""5k\24""9g\21""4j\23""9g\21""5k\24""4j\23""5k\24""5k\24""4" + "j\23""6l\25""9g\21""9g\21""6l\25""9g\21""6l\25""9g\21""5k\24""9g\21""5" + "k\24""9g\21""6l\25""6l\25@m\30@m\30""6l\25""6l\25""6l\25@m\30@m\30""6" + "l\25""6l\25""6l\25@m\30@m\30""6l\25""6l\25""6l\25@m\30""6l\25@m\30""6" + "l\25@m\30""6l\25@m\30""6l\25""6l\25""9g\21""5k\24""6l\25""5k\24""9g\21" + "5k\24""9g\21\202\320q\202\320q4j\23""4j\23""5k\24\0\0\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\32""8\2\31""9\13\32""8\2\32""8\2\32""8\2\31""9" + "\13\34:\5\31""9\13\34:\5\34:\5\27""8\11\27=\7\27=\7\27=\7\30>\10\30>" + "\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\36" + "B\5\32\77\12\32\77\12\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\33" + "A\14\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\36B\5\36B\5\36B\5" + "\33A\14\36B\5\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14" + "\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\36B\5\36B\5\33A\14\33A\14\33A" + "\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\202\320q\202\320q\32\77\12" + "\36B\5\32\77\12\0\0""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21" + "3[\16""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2a\23" + "3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""5d\26""7e\17" + "5d\26""7e\17""7f\30""9g\21""9g\21""4j\23""4j\23""5k\24""9g\21""5k\24" + "9g\21""4j\23""4j\23""6l\25""5k\24""9g\21""5k\24""5k\24""6l\25""9g\21" + "9g\21""5k\24""9g\21""5k\24""6l\25@m\30""6l\25@m\30@m\30""6l\25""6l\25" + "@m\30""6l\25@m\30""6l\25""6l\25""6l\25@m\30""6l\25@m\30""6l\25""6l\25" + "6l\25""6l\25""6l\25@m\30@m\30""6l\25@m\30""5k\24""6l\25""9g\21""9g\21" + "6l\25""9g\21""6l\25""5k\24""5k\24\202\320q\202\320q5k\24""4j\23""4j\23" + "\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\32""8\2\31""9\13\32" + "8\2\32""8\2\31""9\13\34:\5\27""8\11\34:\5\27""8\11\27=\7\27=\7\27=\7" + "\27=\7\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77" + "\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5\33A\14\36B\5\33A\14\33A\14" + "\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\36B\5\36" + "B\5\36B\5\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14\36" + "B\5\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\36B\5\36B\5\33A\14" + "\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\36B\5\202" + "\320q\202\320q\32\77\12\32\77\12\36B\5\0\0""0_\21""0_\21""0_\21""0_\21" + "0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23" + "2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26" + "5d\26""7e\17""5d\26""9g\21""7f\30""4j\23""5k\24""9g\21""5k\24""4j\23" + "9g\21""4j\23""9g\21""4j\23""5k\24""5k\24""9g\21""5k\24""9g\21""5k\24" + "9g\21""5k\24""6l\25""9g\21""5k\24@m\30""6l\25@m\30""6l\25@m\30""6l\25" + "@m\30""6l\25@m\30""6l\25@m\30""6l\25@m\30""6l\25""6l\25""6l\25@m\30""6" + "l\25""6l\25""6l\25""6l\25""6l\25@m\30""6l\25@m\30""5k\24""9g\21""9g\21" + "5k\24""6l\25""9g\21""5k\24""9g\21""5k\24""9g\21""4j\23\202\320q\202\320" + "q9g\21""9g\21""4j\23\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\31""9\13\32""8" + "\2\32""8\2\32""8\2\31""9\13\34:\5\34:\5\34:\5\34:\5\34:\5\27=\7\27=\7" + "\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\36B\5\32\77\12\32\77\12" + "\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\36B\5\33A\14\33A\14" + "\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\36B\5\36B\5\33" + "A\14\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\36B\5\36" + "B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14" + "\33A\14\33A\14\33A\14\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\32" + "\77\12\36B\5\202\320q\202\320q\32\77\12\32\77\12\32\77\12\0\0""3[\16" + "0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23" + "2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26" + "5d\26""7e\17""5d\26""7e\17""5d\26""7e\17""9g\21""9g\21""4j\23""9g\21" + "5k\24""9g\21""4j\23""9g\21""4j\23""5k\24""9g\21""6l\25""6l\25""9g\21" + "5k\24""9g\21""6l\25""9g\21""5k\24""5k\24""9g\21""5k\24@m\30""6l\25""6" + "l\25""6l\25""6l\25""6l\25@m\30""6l\25""6l\25@m\30""6l\25@m\30""6l\25" + "@m\30""6l\25@m\30""6l\25""6l\25""6l\25@m\30""6l\25""6l\25@m\30""6l\25" + "5k\24""9g\21""9g\21""6l\25""5k\24""5k\24""6l\25""5k\24""9g\21""4j\23" + "4j\23""5k\24\202\320q\202\320q9g\21""9g\21""7f\30\0\0\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31" + "9\13\32""8\2\32""8\2\32""8\2\31""9\13\32""8\2\34:\5\31""9\13\34:\5\31" + "9\13\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5" + "\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\36" + "B\5\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14" + "\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\33" + "A\14\36B\5\33A\14\32\77\12\32\77\12\32\77\12\32\77\12\202\320q\202\320" + "q\32\77\12\32\77\12\30>\10\0\0""0_\21""0_\21""3[\16""0_\21""0_\21""0" + "_\21""0_\21""3[\16""2a\23""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3" + "b\24""3b\24""3b\24""3b\24""5d\26""7e\17""5d\26""5d\26""7e\17""5d\26""7" + "e\17""9g\21""9g\21""9g\21""4j\23""9g\21""4j\23""9g\21""9g\21""4j\23""9" + "g\21""4j\23""6l\25""5k\24""9g\21""5k\24""9g\21""5k\24""9g\21""6l\25""9" + "g\21""5k\24""6l\25@m\30""6l\25""6l\25""6l\25""6l\25""6l\25""6l\25""6" + "l\25""6l\25@m\30""6l\25@m\30""6l\25@m\30""6l\25""6l\25""6l\25""6l\25" + "@m\30""6l\25@m\30""6l\25""9g\21""5k\24""9g\21""9g\21""6l\25""5k\24""6" + "l\25""9g\21""6l\25""5k\24""9g\21""4j\23""9g\21""5k\24""4j\23\202\320" + "q\202\320q9g\21""5d\26""7e\17\0\0\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\31""9\13\32""8\2\32""8\2" + "\31""9\13\32""8\2\34:\5\34:\5\31""9\13\34:\5\34:\5\27=\7\27=\7\27=\7" + "\27=\7\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77" + "\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\33A\14\36B\5\33A\14\33" + "A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B" + "\5\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\36B\5\36B\5\33A\14" + "\36B\5\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14\36B\5\33A\14\33A\14" + "\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\32\77\12" + "\36B\5\32\77\12\32\77\12\36B\5\202\320q\202\320q\35;\6\30>\10\27=\7\0" + "\0""3[\16""0_\21""0_\21""0_\21""3[\16""0_\21""0_\21""2a\23""2a\23""2" + "a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5" + "d\26""5d\26""7e\17""7e\17""7e\17""5d\26""9g\21""9g\21""9g\21""9g\21""4" + "j\23""4j\23""4j\23""5k\24""9g\21""9g\21""5k\24""9g\21""9g\21""5k\24""9" + "g\21""9g\21""5k\24""9g\21""9g\21""5k\24""5k\24@m\30""6l\25@m\30@m\30" + "6l\25""6l\25""6l\25""6l\25""6l\25""6l\25@m\30""6l\25""6l\25""6l\25@m" + "\30""6l\25@m\30""6l\25@m\30@m\30""6l\25""6l\25""9g\21""9g\21""5k\24""5" + "k\24""9g\21""5k\24""6l\25""9g\21""5k\24""9g\21""5k\24""4j\23""9g\21""5" + "k\24""9g\21""5k\24""4j\23\202\320q\202\320q7e\17""5d\26""7e\17\0\0\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\31" + "9\13\32""8\2\31""9\13\32""8\2\31""9\13\34:\5\34:\5\34:\5\34:\5\27""8" + "\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32" + "\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\36B\5\33A\14\33" + "A\14\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\36" + "B\5\36B\5\36B\5\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33" + "A\14\33A\14\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\36B\5\36B\5\33A\14\33" + "A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\32\77\12\32" + "\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\202\320q\202\320" + "q\27=\7\27=\7\27=\7\0\0""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2" + "a\23""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3" + "b\24""3b\24""7e\17""5d\26""5d\26""7e\17""5d\26""7e\17""7f\30""9g\21""5" + "k\24""4j\23""9g\21""5k\24""4j\23""9g\21""5k\24""5k\24""4j\23""9g\21""5" + "k\24""9g\21""6l\25""5k\24""9g\21""9g\21""5k\24""9g\21""6l\25""5k\24@" + "m\30@m\30""6l\25@m\30""6l\25""6l\25""6l\25@m\30""6l\25""6l\25""6l\25" + "6l\25""6l\25@m\30""6l\25""6l\25@m\30@m\30@m\30""6l\25""5k\24""9g\21""9" + "g\21""5k\24""5k\24""6l\25""9g\21""5k\24""5k\24""6l\25""4j\23""9g\21""4" + "j\23""9g\21""4j\23""9g\21""9g\21""9g\21""9g\21\202\320q\202\320q7e\17" + "5d\26""3b\24\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2" + "\31""9\13\32""8\2\32""8\2\31""9\13\31""9\13\32""8\2\34:\5\34:\5\31""9" + "\13\34:\5\27""8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32" + "\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5" + "\32\77\12\32\77\12\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\33" + "A\14\33A\14\36B\5\33A\14\36B\5\36B\5\36B\5\36B\5\33A\14\33A\14\36B\5" + "\36B\5\36B\5\33A\14\33A\14\33A\14\36B\5\36B\5\33A\14\36B\5\36B\5\36B" + "\5\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\36B\5\33A\14\33A\14\36B\5" + "\33A\14\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\30>\10\202\320q\202\320q\27=\7\34:\5\31""9\13\0\0""3[\16" + "0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2a\23""2a\23" + "3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""5d\26""5d\26" + "5d\26""7e\17""7f\30""7f\30""4j\23""4j\23""4j\23""9g\21""4j\23""5k\24" + "9g\21""5k\24""4j\23""6l\25""9g\21""6l\25""9g\21""6l\25""9g\21""5k\24" + "9g\21""5k\24""9g\21""5k\24""9g\21@m\30""6l\25@m\30""6l\25""6l\25""6l" + "\25@m\30@m\30""6l\25""6l\25""6l\25""6l\25@m\30@m\30""6l\25@m\30""6l\25" + "9g\21""6l\25""9g\21""9g\21""5k\24""9g\21""5k\24""6l\25""9g\21""5k\24" + "5k\24""9g\21""4j\23""9g\21""5k\24""5k\24""9g\21""9g\21""9g\21""9g\21" + "5d\26""7e\17\202\320q\202\320q3b\24""3b\24""3b\24\0\0\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\32""8\2\31""9\13\32""8\2\32""8\2\32""8" + "\2\31""9\13\34:\5\31""9\13\31""9\13\27""8\11\34:\5\27=\7\27=\7\27=\7" + "\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77\12" + "\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\33A\14\36B" + "\5\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5" + "\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14\33A\14\36B" + "\5\36B\5\36B\5\33A\14\36B\5\36B\5\36B\5\33A\14\33A\14\33A\14\33A\14\33" + "A\14\36B\5\33A\14\33A\14\36B\5\33A\14\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\27=\7\202\320q" + "\202\320q\27""8\11\34:\5\31""9\13\0\0""3[\16""0_\21""0_\21""0_\21""2" + "a\23""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3" + "b\24""5d\26""7e\17""5d\26""5d\26""5d\26""7e\17""5d\26""7f\30""9g\21""9" + "g\21""9g\21""4j\23""9g\21""5k\24""9g\21""4j\23""9g\21""4j\23""9g\21""5" + "k\24""5k\24""6l\25""5k\24""9g\21""9g\21""6l\25""6l\25""9g\21""5k\24""6" + "l\25""5k\24@m\30""6l\25@m\30""6l\25""6l\25""6l\25@m\30""6l\25@m\30""6" + "l\25""6l\25@m\30""6l\25@m\30""6l\25""6l\25""9g\21""6l\25""9g\21""5k\24" + "9g\21""9g\21""5k\24""6l\25""9g\21""5k\24""9g\21""4j\23""9g\21""5k\24" + "4j\23""4j\23""9g\21""5k\24""9g\21""7e\17""5d\26""5d\26""5d\26\202\320" + "q\202\320q3b\24""2a\23""2a\23\0\0\27""7\10\27""7\10\27""7\10\32""8\2" + "\31""9\13\31""9\13\32""8\2\32""8\2\31""9\13\31""9\13\34:\5\34:\5\27""8" + "\11\34:\5\27""8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\32\77\12\32\77\12\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\33A\14\33" + "A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\36B\5\36B\5\33A\14\36B\5\33" + "A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5" + "\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14" + "\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5\30>\10" + "\30>\10\27=\7\27=\7\27=\7\202\320q\202\320q\32""8\2\31""9\13\31""9\13" + "\0\0""3[\16""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2a\23""2a\23""2" + "a\23""3b\24""3b\24""3b\24""3b\24""3b\24""7e\17""5d\26""7e\17""5d\26""5" + "d\26""5d\26""7e\17""7f\30""9g\21""4j\23""9g\21""5k\24""9g\21""5k\24""9" + "g\21""5k\24""9g\21""9g\21""5k\24""6l\25""5k\24""9g\21""5k\24""6l\25""9" + "g\21""5k\24""6l\25""5k\24""5k\24""9g\21""5k\24@m\30@m\30""6l\25""6l\25" + "@m\30""6l\25""6l\25""6l\25@m\30""6l\25@m\30""6l\25""6l\25@m\30""5k\24" + "6l\25""9g\21""9g\21""6l\25""9g\21""5k\24""9g\21""5k\24""5k\24""5k\24" + "9g\21""5k\24""4j\23""9g\21""4j\23""4j\23""9g\21""9g\21""7e\17""5d\26" + "7e\17""5d\26""5d\26""3b\24\202\320q\202\320q2a\23""2a\23""0_\21\0\0\27" + "7\10\27""7\10\27""7\10\31""9\13\32""8\2\31""9\13\32""8\2\32""8\2\31""9" + "\13\34:\5\34:\5\27""8\11\34:\5\34:\5\27""8\11\27=\7\27=\7\27=\7\27=\7" + "\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\33A\14\36B\5\33A" + "\14\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14" + "\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\36B" + "\5\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14" + "\36B\5\33A\14\33A\14\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\36B\5" + "\32\77\12\32\77\12\32\77\12\30>\10\27=\7\27=\7\27=\7\34:\5\27""8\11\202" + "\320q\202\320q\31""9\13\27""7\10\27""7\10\0\0""0_\21""0_\21""2a\23""2" + "a\23""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3" + "b\24""5d\26""5d\26""5d\26""7e\17""7e\17""5d\26""7e\17""7f\30""9g\21""9" + "g\21""5k\24""4j\23""5k\24""9g\21""4j\23""9g\21""5k\24""9g\21""6l\25""9" + "g\21""5k\24""5k\24""9g\21""5k\24""5k\24""9g\21""6l\25""9g\21""6l\25""5" + "k\24""6l\25""9g\21""6l\25""6l\25""6l\25""6l\25""6l\25""6l\25@m\30""6" + "l\25""6l\25@m\30""6l\25@m\30""5k\24""9g\21""5k\24""6l\25""9g\21""6l\25" + "9g\21""6l\25""6l\25""5k\24""9g\21""9g\21""4j\23""9g\21""5k\24""9g\21" + "4j\23""4j\23""9g\21""9g\21""7e\17""7e\17""7e\17""5d\26""3b\24""3b\24" + "3b\24\202\320q\202\320q0_\21""0_\21""0_\21\0\0\27""7\10\27""7\10\32""8" + "\2\32""8\2\31""9\13\32""8\2\31""9\13\31""9\13\34:\5\34:\5\27""8\11\34" + ":\5\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12" + "\32\77\12\32\77\12\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36" + "B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14" + "\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\36" + "B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\32\77\12\32" + "\77\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\30>\10\30>\10" + "\27=\7\27=\7\34:\5\34:\5\31""9\13\32""8\2\202\320q\202\320q\27""7\10" + "\27""7\10\27""7\10\0\0""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2a" + "\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""7e\17""5d\26""5" + "d\26""5d\26""5d\26""5d\26""9g\21""7f\30""4j\23""9g\21""4j\23""4j\23""9" + "g\21""9g\21""4j\23""4j\23""5k\24""6l\25""9g\21""6l\25""6l\25""9g\21""5" + "k\24""6l\25""9g\21""6l\25""5k\24""6l\25""6l\25""5k\24""5k\24""5k\24""6" + "l\25""6l\25@m\30""6l\25""6l\25""6l\25""6l\25@m\30""6l\25@m\30""5k\24" + "6l\25""9g\21""5k\24""5k\24""6l\25""5k\24""6l\25""9g\21""5k\24""6l\25" + "5k\24""9g\21""4j\23""9g\21""4j\23""5k\24""9g\21""5k\24""9g\21""5d\26" + "7e\17""5d\26""5d\26""3b\24""3b\24""3b\24""2a\23""2a\23\202\320q\202\320" + "q0_\21""0_\21/^\20\0\0\27""7\10\32""8\2\32""8\2\31""9\13\32""8\2\32""8" + "\2\32""8\2\31""9\13\34:\5\34:\5\31""9\13\34:\5\27""8\11\27=\7\27=\7\27" + "=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\36B\5\32\77\12\36B\5" + "\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\36B\5\33A\14\36B\5\33" + "A\14\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\36B\5\33A\14\36B" + "\5\33A\14\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\36B\5\33" + "A\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14" + "\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\30>\10\30>\10\27=\7\27=\7\27""8\11\34:\5\34:\5\31""9\13\32""8\2\31" + "9\13\202\320q\202\320q\27""7\10\27""7\10\27""7\10\0\0""0_\21""2a\23""2" + "a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""3" + "b\24""5d\26""7e\17""5d\26""5d\26""7e\17""5d\26""7e\17""7f\30""9g\21""4" + "j\23""5k\24""4j\23""9g\21""4j\23""4j\23""5k\24""9g\21""4j\23""5k\24""6" + "l\25""9g\21""9g\21""6l\25""5k\24""6l\25""9g\21""5k\24""9g\21""5k\24""6" + "l\25""5k\24""9g\21""5k\24""6l\25@m\30@m\30""6l\25""6l\25@m\30@m\30""6" + "l\25""9g\21""5k\24""9g\21""5k\24""9g\21""6l\25""9g\21""6l\25""5k\24""9" + "g\21""5k\24""9g\21""4j\23""5k\24""9g\21""5k\24""9g\21""4j\23""4j\23""7" + "f\30""7e\17""5d\26""5d\26""5d\26""5d\26""3b\24""3b\24""2a\23""2a\23""2" + "a\23""0_\21\202\320q\202\320q/^\20""3[\16/^\20\0\0\27""7\10\32""8\2\31" + "9\13\32""8\2\31""9\13\31""9\13\32""8\2\34:\5\34:\5\31""9\13\27""8\11" + "\34:\5\27=\7\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12" + "\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36" + "B\5\32\77\12\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\33" + "A\14\33A\14\36B\5\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\33A" + "\14\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\36" + "B\5\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\32\77\12\36B\5\32\77\12\36" + "B\5\32\77\12\36B\5\32\77\12\32\77\12\30>\10\27=\7\27=\7\27=\7\34:\5\31" + "9\13\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10\202\320q\202\320q\27" + "7\10\27""7\10\25""5\6\0\0""2a\23""2a\23""2a\23""2a\23""2a\23""2a\23""2" + "a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""7e\17""5d\26""5d\26""7" + "e\17""7e\17""7e\17""7f\30""9g\21""9g\21""5k\24""4j\23""4j\23""9g\21""5" + "k\24""5k\24""9g\21""4j\23""5k\24""9g\21""6l\25""5k\24""9g\21""9g\21""5" + "k\24""5k\24""6l\25""9g\21""5k\24""5k\24""9g\21""6l\25""9g\21""5k\24""9" + "g\21""5k\24""9g\21""6l\25""9g\21""6l\25""9g\21""6l\25""9g\21""6l\25""9" + "g\21""5k\24""5k\24""5k\24""5k\24""9g\21""5k\24""5k\24""5k\24""9g\21""5" + "k\24""4j\23""9g\21""5k\24""4j\23""9g\21""9g\21""5d\26""5d\26""7e\17""5" + "d\26""3b\24""3b\24""3b\24""2a\23""2a\23""0_\21""0_\21""3[\16\202\320" + "q\202\320q/^\20/^\20""0Y\24\0\0\32""8\2\31""9\13\32""8\2\31""9\13\32" + "8\2\31""9\13\32""8\2\31""9\13\34:\5\34:\5\27""8\11\34:\5\27=\7\27=\7" + "\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12" + "\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\33A\14\33A" + "\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5" + "\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14" + "\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\36B\5\33A\14\33A\14\36" + "B\5\33A\14\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\30>\10\30>\10\27=\7\27=\7\31""9\13\27""8\11\34:\5\31""9\13\32" + "8\2\27""7\10\27""7\10\27""7\10\27""7\10\202\320q\202\320q\27""7\10\25" + "5\6\25""5\6\0\0""2a\23""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b" + "\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""7e\17""5d\26""5d\26""7" + "e\17""9g\21""7f\30""9g\21""4j\23""9g\21""4j\23""4j\23""4j\23""4j\23""9" + "g\21""5k\24""9g\21""9g\21""9g\21""6l\25""9g\21""9g\21""6l\25""9g\21""6" + "l\25""9g\21""6l\25""5k\24""6l\25""9g\21""6l\25""9g\21""6l\25""6l\25""9" + "g\21""5k\24""9g\21""5k\24""9g\21""6l\25""5k\24""9g\21""9g\21""6l\25""9" + "g\21""6l\25""6l\25""9g\21""5k\24""5k\24""9g\21""5k\24""4j\23""4j\23""4" + "j\23""9g\21""9g\21""7f\30""7e\17""5d\26""7e\17""7e\17""3b\24""3b\24""3" + "b\24""2a\23""2a\23""2a\23""0_\21""0_\21/^\20""3[\16\202\320q\202\320" + "q3[\16-\\\16""2Z\15\0\0\31""9\13\31""9\13\32""8\2\31""9\13\32""8\2\31" + "9\13\34:\5\34:\5\34:\5\34:\5\31""9\13\27=\7\27=\7\27=\7\27=\7\30>\10" + "\30>\10\30>\10\36B\5\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12" + "\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\33A\14\33A\14\33A\14\33A\14" + "\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\33A\14\33A\14\36" + "B\5\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\33A" + "\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\32\77\12\36" + "B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\30>\10\30>\10\27=\7\27" + "=\7\34:\5\34:\5\27""8\11\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\202\320q\202\320q\25""5\6\24""4\5\27""1\12\0\0" + "2a\23""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24" + "3b\24""5d\26""5d\26""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21""9g\21" + "4j\23""5k\24""4j\23""5k\24""9g\21""4j\23""9g\21""4j\23""9g\21""5k\24" + "9g\21""9g\21""9g\21""9g\21""6l\25""6l\25""9g\21""5k\24""5k\24""5k\24" + "5k\24""9g\21""5k\24""9g\21""5k\24""9g\21""6l\25""9g\21""6l\25""9g\21" + "6l\25""9g\21""5k\24""9g\21""9g\21""5k\24""6l\25""9g\21""6l\25""5k\24" + "9g\21""9g\21""5k\24""9g\21""5k\24""4j\23""4j\23""9g\21""9g\21""5d\26" + "7e\17""5d\26""5d\26""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""3[\16" + "0_\21""3[\16/^\20""3[\16/^\20\202\320q\202\320q2Z\15""0Y\24""0Y\24\0" + "\0\32""8\2\32""8\2\31""9\13\32""8\2\32""8\2\34:\5\34:\5\31""9\13\34:" + "\5\34:\5\27""8\11\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32" + "\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14" + "\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33" + "A\14\36B\5\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\36" + "B\5\33A\14\33A\14\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36" + "B\5\32\77\12\32\77\12\30>\10\30>\10\27=\7\27=\7\27=\7\34:\5\27""8\11" + "\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\202\320q\202\320q\24""4\5\23""3\3\23""3\3\0\0""2a" + "\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""3" + "b\24""7e\17""5d\26""5d\26""7e\17""7e\17""5d\26""9g\21""9g\21""4j\23""9" + "g\21""4j\23""9g\21""4j\23""5k\24""9g\21""5k\24""4j\23""9g\21""5k\24""5" + "k\24""9g\21""5k\24""6l\25""9g\21""6l\25""9g\21""6l\25""9g\21""5k\24""9" + "g\21""5k\24""5k\24""9g\21""5k\24""6l\25""9g\21""6l\25""6l\25""9g\21""9" + "g\21""9g\21""6l\25""5k\24""9g\21""5k\24""6l\25""9g\21""5k\24""5k\24""4" + "j\23""9g\21""9g\21""5k\24""9g\21""4j\23""9g\21""5d\26""5d\26""5d\26""5" + "d\26""5d\26""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21/" + "^\20/^\20""3[\16/^\20-\\\16\202\320q\202\320q0Y\24""2Z\15""0Y\24\0\0" + "\32""8\2\32""8\2\31""9\13\32""8\2\32""8\2\34:\5\34:\5\31""9\13\34:\5" + "\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12" + "\36B\5\32\77\12\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14" + "\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\33" + "A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A" + "\14\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12" + "\32\77\12\30>\10\27=\7\27=\7\27=\7\31""9\13\34:\5\27""8\11\32""8\2\31" + "9\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\24""4\5\202\320q\202\320q\27""1\12\23""3\3\27""1\12\0\0""2a\23""2" + "a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""7e\17""5d\26""5" + "d\26""5d\26""5d\26""7e\17""5d\26""9g\21""9g\21""9g\21""4j\23""9g\21""4" + "j\23""5k\24""5k\24""9g\21""4j\23""4j\23""5k\24""9g\21""6l\25""9g\21""9" + "g\21""5k\24""9g\21""6l\25""5k\24""6l\25""9g\21""6l\25""6l\25""5k\24""9" + "g\21""6l\25""9g\21""5k\24""6l\25""9g\21""5k\24""5k\24""6l\25""9g\21""5" + "k\24""5k\24""9g\21""6l\25""9g\21""5k\24""9g\21""4j\23""9g\21""5k\24""9" + "g\21""9g\21""4j\23""9g\21""9g\21""7e\17""7e\17""7e\17""5d\26""3b\24""3" + "b\24""3b\24""2a\23""2a\23""0_\21""0_\21""0_\21""3[\16/^\20/^\20/^\20" + "-\\\16""0Y\24""0Y\24\202\320q\202\320q0Y\24""0Y\24""0Y\24\0\0\32""8\2" + "\31""9\13\32""8\2\32""8\2\34:\5\34:\5\31""9\13\34:\5\34:\5\27=\7\27=" + "\7\27=\7\27=\7\27=\7\30>\10\30>\10\36B\5\32\77\12\36B\5\32\77\12\32\77" + "\12\36B\5\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\33A\14\36" + "B\5\33A\14\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\36B" + "\5\33A\14\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5" + "\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\32\77\12\36B\5\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\30>\10\30>\10\27=\7\27" + "=\7\31""9\13\27""8\11\34:\5\27""8\11\32""8\2\32""8\2\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\24""4\5\24""4\5\23""3\3" + "\202\320q\202\320q\30""1\1\23""3\3\27""1\12\0\0""2a\23""2a\23""2a\23" + "2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""7e\17" + "5d\26""7e\17""5d\26""9g\21""9g\21""5k\24""4j\23""4j\23""5k\24""4j\23" + "4j\23""4j\23""9g\21""5k\24""9g\21""5k\24""5k\24""9g\21""6l\25""9g\21" + "5k\24""9g\21""5k\24""9g\21""6l\25""6l\25""5k\24""5k\24""9g\21""6l\25" + "5k\24""9g\21""5k\24""9g\21""6l\25""5k\24""6l\25""9g\21""6l\25""9g\21" + "6l\25""9g\21""4j\23""4j\23""5k\24""9g\21""9g\21""9g\21""4j\23""9g\21" + "9g\21""5d\26""7e\17""5d\26""5d\26""3b\24""3b\24""3b\24""2a\23""2a\23" + "2a\23""0_\21""0_\21""3[\16""3[\16/^\20/^\20""3[\16""0Y\24""2Z\15""2Z" + "\15""0Y\24\202\320q\202\320q0Y\24""0Y\24.W\23\0\0\32""8\2\31""9\13\32" + "8\2\32""8\2\31""9\13\34:\5\34:\5\34:\5\31""9\13\27=\7\27=\7\27=\7\27" + "=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36" + "B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\33A\14\33" + "A\14\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5" + "\33A\14\36B\5\36B\5\33A\14\33A\14\33A\14\36B\5\36B\5\33A\14\33A\14\33" + "A\14\33A\14\33A\14\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\30>\10\30>\10\27=\7\27=\7\27""8\11\34:\5" + "\27""8\11\32""8\2\31""9\13\31""9\13\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\25""5\6\24""4\5\24""4\5\23""3\3\23""3" + "\3\202\320q\202\320q\30""1\1\30""1\1\25""0\10\0\0""2a\23""2a\23""2a\23" + "2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""5d\26" + "7e\17""5d\26""7e\17""9g\21""7f\30""4j\23""4j\23""9g\21""5k\24""9g\21" + "5k\24""4j\23""5k\24""9g\21""6l\25""6l\25""5k\24""9g\21""5k\24""9g\21" + "5k\24""5k\24""5k\24""5k\24""5k\24""6l\25""5k\24""9g\21""5k\24""5k\24" + "5k\24""9g\21""6l\25""9g\21""5k\24""6l\25""9g\21""5k\24""9g\21""6l\25" + "9g\21""9g\21""4j\23""9g\21""4j\23""9g\21""9g\21""4j\23""9g\21""7e\17" + "5d\26""5d\26""5d\26""5d\26""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21" + "0_\21""0_\21""3[\16/^\20""3[\16""3[\16-\\\16-\\\16""0Y\24""0Y\24""2Z" + "\15""0Y\24\202\320q\202\320q.W\23.W\23-V\22\0\0\32""8\2\31""9\13\32""8" + "\2\32""8\2\34:\5\27""8\11\34:\5\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\30" + ">\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\33A\14\36B\5\33A\14\36B\5" + "\33A\14\33A\14\33A\14\36B\5\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36" + "B\5\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\30>\10\30>\10\27=\7\27=\7\27=\7\34:\5\31""9\13\32""8\2\31" + "9\13\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\25""5\6\25""5\6\24""4\5\30""1\1\23""3\3\23""3\3\23""3\3\202\320" + "q\202\320q\25""0\10\25""0\10\25""0\10\0\0""2a\23""2a\23""2a\23""2a\23" + "3b\24""3b\24""3b\24""3b\24""3b\24""5d\26""7e\17""5d\26""5d\26""5d\26" + "7e\17""9g\21""7f\30""4j\23""5k\24""9g\21""4j\23""9g\21""4j\23""5k\24" + "9g\21""4j\23""9g\21""6l\25""5k\24""6l\25""6l\25""9g\21""5k\24""9g\21" + "5k\24""6l\25""9g\21""6l\25""9g\21""5k\24""5k\24""5k\24""5k\24""9g\21" + "5k\24""9g\21""5k\24""9g\21""5k\24""9g\21""6l\25""9g\21""9g\21""4j\23" + "9g\21""9g\21""4j\23""9g\21""4j\23""7f\30""9g\21""5d\26""7e\17""5d\26" + "5d\26""3b\24""3b\24""3b\24""2a\23""2a\23""3[\16""0_\21""0_\21""0_\21" + "/^\20""3[\16/^\20""0Y\24""3[\16""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24""2" + "Z\15\202\320q\202\320q-V\22-V\22-V\22\0\0\32""8\2\31""9\13\32""8\2\27" + "8\11\34:\5\34:\5\27""8\11\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10" + "\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36" + "B\5\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\33A\14\36B\5\36B\5\33A" + "\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14" + "\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\30>\10\30>\10\27=\7\27=\7\27""8\11\34:\5\27""8\11\32""8\2\32""8" + "\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\25""5\6\24""4\5\30""1\1\30""1\1\23""3\3\23""3\3\27""1\12\30""1\1" + "\202\320q\202\320q\25""0\10\25""0\10\25/\7\0\0""2a\23""2a\23""2a\23""3" + "b\24""3b\24""3b\24""3b\24""3b\24""5d\26""7e\17""5d\26""5d\26""5d\26""7" + "e\17""7e\17""7f\30""9g\21""5k\24""4j\23""9g\21""4j\23""9g\21""4j\23""5" + "k\24""9g\21""4j\23""9g\21""5k\24""9g\21""5k\24""6l\25""9g\21""6l\25""5" + "k\24""9g\21""5k\24""9g\21""6l\25""9g\21""9g\21""5k\24""6l\25""9g\21""5" + "k\24""9g\21""5k\24""9g\21""5k\24""9g\21""9g\21""5k\24""9g\21""9g\21""4" + "j\23""9g\21""4j\23""9g\21""9g\21""9g\21""5d\26""7e\17""7e\17""5d\26""3" + "b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""3[\16/^\20/^\20" + "3[\16-\\\16""3[\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15.W\23.W\23" + "\202\320q\202\320q-V\22""0R\16*T\16\0\0\31""9\13\31""9\13\32""8\2\34" + ":\5\34:\5\27""8\11\34:\5\27""8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>" + "\10\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12" + "\36B\5\32\77\12\32\77\12\36B\5\32\77\12\33A\14\36B\5\33A\14\33A\14\36" + "B\5\33A\14\33A\14\36B\5\33A\14\33A\14\33A\14\33A\14\33A\14\36B\5\33A" + "\14\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\32\77\12\32\77\12\36B\5\32" + "\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>" + "\10\27=\7\27=\7\34:\5\34:\5\31""9\13\32""8\2\31""9\13\32""8\2\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5" + "\24""4\5\23""3\3\27""1\12\23""3\3\27""1\12\23""3\3\30""1\1\30""1\1\202" + "\320q\202\320q\25/\7\25/\7\25/\7\0\0""2a\23""2a\23""2a\23""3b\24""3b" + "\24""3b\24""3b\24""3b\24""5d\26""7e\17""5d\26""5d\26""7e\17""5d\26""9" + "g\21""9g\21""9g\21""9g\21""4j\23""4j\23""4j\23""4j\23""5k\24""4j\23""9" + "g\21""5k\24""9g\21""5k\24""6l\25""9g\21""5k\24""6l\25""9g\21""6l\25""9" + "g\21""5k\24""9g\21""5k\24""9g\21""6l\25""6l\25""9g\21""9g\21""5k\24""9" + "g\21""5k\24""9g\21""4j\23""9g\21""9g\21""5k\24""4j\23""9g\21""5k\24""4" + "j\23""9g\21""9g\21""7e\17""5d\26""5d\26""7e\17""3b\24""3b\24""3b\24""2" + "a\23""2a\23""2a\23""3[\16""0_\21""0_\21""3[\16/^\20/^\20/^\20""3[\16" + "-\\\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24.W\23.W\23-V\22\202\320" + "q\202\320q*T\16""0R\16*T\16\0\0\31""9\13\32""8\2\27""8\11\34:\5\34:\5" + "\34:\5\31""9\13\27=\7\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32" + "\77\12\32\77\12\32\77\12\36B\5\36B\5\33A\14\33A\14\36B\5\33A\14\36B\5" + "\33A\14\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\33" + "A\14\33A\14\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77" + "\12\32\77\12\32\77\12\36B\5\32\77\12\30>\10\30>\10\27=\7\27=\7\27=\7" + "\27""8\11\34:\5\32""8\2\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\25""5\6\24""4\5\24""4\5\27""1\12\23""3" + "\3\27""1\12\23""3\3\23""3\3\25""0\10\30""1\1\25""0\10\25""0\10\202\320" + "q\202\320q\25/\7\25/\7\25/\7\0\0""2a\23""2a\23""3b\24""3b\24""3b\24""3" + "b\24""3b\24""5d\26""7e\17""5d\26""5d\26""5d\26""5d\26""7e\17""7f\30""9" + "g\21""4j\23""4j\23""5k\24""9g\21""4j\23""4j\23""5k\24""9g\21""4j\23""4" + "j\23""5k\24""5k\24""6l\25""9g\21""6l\25""9g\21""6l\25""5k\24""9g\21""5" + "k\24""5k\24""6l\25""9g\21""9g\21""5k\24""5k\24""9g\21""5k\24""9g\21""5" + "k\24""5k\24""9g\21""9g\21""5k\24""4j\23""5k\24""9g\21""9g\21""9g\21""5" + "d\26""5d\26""5d\26""7e\17""5d\26""3b\24""3b\24""3b\24""2a\23""2a\23""3" + "[\16""0_\21""0_\21/^\20/^\20/^\20/^\20""3[\16-\\\16""2Z\15""0Y\24""0" + "Y\24""0Y\24""0Y\24""0Y\24.W\23.W\23.W\23-V\22-V\22\202\320q\202\320q" + "*T\16*T\16*T\16\0\0\32""8\2\31""9\13\34:\5\34:\5\27""8\11\34:\5\34:\5" + "\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\36B\5" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32" + "\77\12\36B\5\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\33" + "A\14\33A\14\36B\5\33A\14\33A\14\33A\14\36B\5\33A\14\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12" + "\32\77\12\30>\10\30>\10\27=\7\27=\7\27=\7\34:\5\34:\5\34:\5\32""8\2\32" + "8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\25""5\6\24""4\5\30""1\1\23""3\3\27""1\12\23""3\3\27""1\12\25""0\10" + "\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\202\320q\202\320q\25/\7\24" + ".\5\24.\5\0\0""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""5d\26" + "7e\17""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21""7f\30""4j\23""9g\21" + "5k\24""9g\21""5k\24""4j\23""4j\23""4j\23""9g\21""5k\24""4j\23""5k\24" + "5k\24""6l\25""9g\21""6l\25""9g\21""5k\24""9g\21""5k\24""9g\21""6l\25" + "6l\25""9g\21""5k\24""6l\25""9g\21""4j\23""5k\24""9g\21""5k\24""9g\21" + "5k\24""9g\21""9g\21""5k\24""9g\21""9g\21""7e\17""7e\17""5d\26""5d\26" + "3b\24""3b\24""3b\24""2a\23""2a\23""0_\21""3[\16""0_\21/^\20""3[\16/^" + "\20""3[\16-\\\16-\\\16""0Y\24""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24.W\23" + ".W\23.W\23-V\22-V\22*T\16*T\16\202\320q\202\320q*T\16*T\16*T\16\0\0\32" + "8\2\31""9\13\34:\5\34:\5\27""8\11\34:\5\27=\7\27=\7\27=\7\27=\7\27=\7" + "\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\36B\5" + "\33A\14\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\33A\14\36B\5\33" + "A\14\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12" + "\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\27" + "=\7\27=\7\27""8\11\34:\5\31""9\13\32""8\2\32""8\2\32""8\2\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\24""4\5\24" + "4\5\23""3\3\30""1\1\23""3\3\27""1\12\23""3\3\30""1\1\25""0\10\25""0\10" + "\25""0\10\25/\7\25/\7\25/\7\202\320q\202\320q\24.\5\24.\5\24.\5\0\0""2" + "a\23""2a\23""3b\24""3b\24""3b\24""3b\24""3b\24""7e\17""5d\26""5d\26""7" + "e\17""5d\26""7e\17""7f\30""9g\21""9g\21""9g\21""9g\21""4j\23""5k\24""9" + "g\21""4j\23""4j\23""9g\21""5k\24""9g\21""4j\23""5k\24""6l\25""9g\21""6" + "l\25""5k\24""5k\24""9g\21""6l\25""6l\25""9g\21""5k\24""4j\23""9g\21""4" + "j\23""9g\21""4j\23""5k\24""4j\23""9g\21""4j\23""9g\21""5k\24""9g\21""9" + "g\21""9g\21""7e\17""7e\17""5d\26""5d\26""3b\24""3b\24""3b\24""2a\23""2" + "a\23""2a\23""0_\21""3[\16""0_\21""3[\16/^\20/^\20""3[\16-\\\16""2Z\15" + "0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24.W\23.W\23-V\22-V\22*T\16*T\16" + "*T\16*T\16\202\320q\202\320q*T\16*T\16*T\16\0\0\32""8\2\31""9\13\34:" + "\5\34:\5\34:\5\31""9\13\34:\5\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10" + "\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32" + "\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\33A\14\33" + "A\14\36B\5\33A\14\36B\5\33A\14\33A\14\33A\14\32\77\12\36B\5\32\77\12" + "\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36" + "B\5\32\77\12\32\77\12\30>\10\30>\10\27=\7\27=\7\31""9\13\34:\5\34:\5" + "\31""9\13\31""9\13\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\25""5\6\24""4\5\24""4\5\23""3\3\30""1\1\23""3\3" + "\27""1\12\23""3\3\25""0\10\30""1\1\25""0\10\25""0\10\25/\7\25/\7\25/" + "\7\25/\7\25/\7\202\320q\202\320q\24.\5\24.\5\23,\3\0\0""2a\23""2a\23" + "3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""7e\17""5d\26""5d\26""7e\17" + "5d\26""9g\21""7f\30""4j\23""9g\21""4j\23""9g\21""5k\24""4j\23""9g\21" + "4j\23""4j\23""9g\21""4j\23""4j\23""5k\24""4j\23""9g\21""5k\24""6l\25" + "9g\21""6l\25""9g\21""5k\24""9g\21""9g\21""5k\24""9g\21""4j\23""5k\24" + "9g\21""4j\23""5k\24""4j\23""4j\23""4j\23""9g\21""9g\21""7e\17""5d\26" + "5d\26""5d\26""7e\17""3b\24""3b\24""3b\24""2a\23""2a\23""0_\21""3[\16" + "0_\21""0_\21/^\20""3[\16/^\20-\\\16""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24" + "0Y\24""0Y\24""0Y\24.W\23.W\23-V\22-V\22*T\16*T\16*T\16""0R\16*T\16\202" + "\320q\202\320q*T\16*T\16*N\22\0\0\31""9\13\32""8\2\31""9\13\34:\5\34" + ":\5\31""9\13\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32" + "\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32" + "\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12" + "\32\77\12\30>\10\30>\10\27=\7\27=\7\27=\7\34:\5\34:\5\31""9\13\32""8" + "\2\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\25""5\6\25""5\6\24""4\5\24""4\5\30""1\1\23""3\3\27""1\12\23""3\3" + "\27""1\12\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7" + "\24.\5\24.\5\202\320q\202\320q\24.\5\23,\3\23,\3\0\0""2a\23""2a\23""3" + "b\24""3b\24""3b\24""3b\24""5d\26""5d\26""7e\17""5d\26""5d\26""7e\17""9" + "g\21""7f\30""9g\21""4j\23""9g\21""5k\24""9g\21""9g\21""5k\24""9g\21""5" + "k\24""9g\21""5k\24""4j\23""5k\24""9g\21""5k\24""4j\23""9g\21""4j\23""4" + "j\23""5k\24""9g\21""5k\24""4j\23""4j\23""9g\21""4j\23""4j\23""5k\24""9" + "g\21""4j\23""9g\21""4j\23""9g\21""9g\21""5d\26""7e\17""7e\17""7e\17""5" + "d\26""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""3[\16/" + "^\20/^\20/^\20""3[\16-\\\16-\\\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24" + "0Y\24.W\23.W\23-V\22-V\22*T\16""0R\16*T\16*T\16""0R\16*T\16*T\16\202" + "\320q\202\320q(R\14*N\22.P\14\0\0\31""9\13\34:\5\34:\5\31""9\13\34:\5" + "\27""8\11\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32" + "\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\36" + "B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\30>\10" + "\30>\10\30>\10\27=\7\27=\7\34:\5\31""9\13\34:\5\31""9\13\32""8\2\31""9" + "\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\25""5\6\24""4\5\27""1\12\27""1\12\23""3\3\23""3\3\27""1\12\30""1" + "\1\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\24.\5\24" + ".\5\24.\5\202\320q\202\320q\23,\3\17+\10\23,\3\0\0""2a\23""3b\24""3b" + "\24""3b\24""3b\24""5d\26""5d\26""5d\26""7e\17""7e\17""7e\17""5d\26""9" + "g\21""7f\30""9g\21""9g\21""4j\23""5k\24""4j\23""9g\21""4j\23""9g\21""9" + "g\21""4j\23""5k\24""9g\21""4j\23""9g\21""9g\21""4j\23""9g\21""4j\23""5" + "k\24""9g\21""9g\21""4j\23""9g\21""4j\23""4j\23""5k\24""9g\21""4j\23""5" + "k\24""9g\21""9g\21""7f\30""7e\17""5d\26""7e\17""5d\26""5d\26""5d\26""3" + "b\24""3b\24""2a\23""2a\23""2a\23""0_\21""3[\16""0_\21""0_\21""3[\16""3" + "[\16/^\20-\\\16""3[\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15.W\23" + ".W\23-V\22-V\22-V\22""0R\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16\202" + "\320q\202\320q*N\22.P\14.P\14\0\0\32""8\2\31""9\13\27""8\11\34:\5\34" + ":\5\35;\6\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36" + "B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\30>\10\30>\10" + "\30>\10\27=\7\27=\7\27=\7\31""9\13\34:\5\34:\5\31""9\13\32""8\2\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25" + "5\6\24""4\5\27""1\12\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3\25""0\10" + "\30""1\1\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5" + "\24.\5\24.\5\202\320q\202\320q\23,\3\23,\3\17+\10\0\0""2a\23""3b\24""3" + "b\24""3b\24""3b\24""5d\26""7e\17""5d\26""5d\26""7e\17""5d\26""9g\21""9" + "g\21""9g\21""9g\21""9g\21""5k\24""4j\23""5k\24""9g\21""4j\23""5k\24""9" + "g\21""4j\23""4j\23""5k\24""9g\21""5k\24""9g\21""9g\21""4j\23""4j\23""9" + "g\21""5k\24""9g\21""9g\21""5k\24""9g\21""4j\23""9g\21""5k\24""9g\21""4" + "j\23""9g\21""7f\30""7e\17""5d\26""5d\26""5d\26""7e\17""3b\24""3b\24""3" + "b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21""3[\16/^\20/^\20""0Y\24" + "3[\16""2Z\15""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24.W\23.W\23-V\22" + "-V\22*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*N\22\202\320q\202" + "\320q.P\14*N\22.P\14\0\0\27""8\11\34:\5\27""8\11\34:\5\31""9\13\27=\7" + "\27=\7\27=\7\30>\10\30>\10\30>\10\30>\10\32\77\12\36B\5\32\77\12\32\77" + "\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32" + "\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5" + "\32\77\12\32\77\12\32\77\12\30>\10\30>\10\27=\7\27=\7\27=\7\34:\5\34" + ":\5\27""8\11\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\25""5\6\24""4\5\24""4\5\23""3\3\30""1" + "\1\23""3\3\23""3\3\23""3\3\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10" + "\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\17+\10\23,\3\202\320" + "q\202\320q\23,\3\23,\3\23,\3\0\0""3b\24""3b\24""3b\24""3b\24""5d\26""7" + "e\17""5d\26""7e\17""7e\17""7e\17""5d\26""9g\21""7f\30""4j\23""4j\23""9" + "g\21""9g\21""5k\24""9g\21""4j\23""4j\23""5k\24""9g\21""4j\23""4j\23""4" + "j\23""9g\21""4j\23""9g\21""5k\24""4j\23""9g\21""4j\23""5k\24""9g\21""5" + "k\24""9g\21""5k\24""9g\21""4j\23""5k\24""7f\30""9g\21""5d\26""5d\26""7" + "e\17""5d\26""7e\17""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0" + "_\21""0_\21""3[\16/^\20/^\20""3[\16-\\\16-\\\16""0Y\24""0Y\24""2Z\15" + "0Y\24""0Y\24""2Z\15.W\23.W\23-V\22-V\22-V\22*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16(R\14.P\14*N\22\202\320q\202\320q.P\14*N\22.P\14\0\0\34" + ":\5\34:\5\34:\5\27""8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\30>\10\30" + ">\10\30>\10\27=\7\27=\7\27=\7\34:\5\34:\5\32""8\2\31""9\13\32""8\2\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\27""7\10\25""5\6\25" + "5\6\24""4\5\23""3\3\23""3\3\23""3\3\23""3\3\27""1\12\30""1\1\25""0\10" + "\30""1\1\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5" + "\24.\5\24.\5\23,\3\23,\3\23,\3\202\320q\202\320q\17+\10\23,\3\23,\3\0" + "\0""3b\24""3b\24""3b\24""3b\24""5d\26""7e\17""5d\26""5d\26""7e\17""5" + "d\26""7e\17""9g\21""7f\30""4j\23""9g\21""4j\23""5k\24""9g\21""4j\23""9" + "g\21""5k\24""9g\21""5k\24""9g\21""5k\24""9g\21""5k\24""4j\23""4j\23""9" + "g\21""9g\21""9g\21""5k\24""9g\21""4j\23""9g\21""5k\24""9g\21""4j\23""9" + "g\21""9g\21""5d\26""7e\17""7e\17""5d\26""7e\17""5d\26""3b\24""3b\24""3" + "b\24""2a\23""2a\23""0_\21""0_\21""3[\16/^\20/^\20""3[\16/^\20-\\\16""0" + "Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24.W\23.W\23-V\22" + "-V\22*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16(R\14.P\14.P\14*N\22" + "\202\320q\202\320q.P\14.P\14.P\14\0\0\34:\5\31""9\13\34:\5\31""9\13\27" + "=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12" + "\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32" + "\77\12\32\77\12\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\31""9\13\34:\5" + "\34:\5\32""8\2\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\25""5\6\24""4\5\24""4\5\23""3\3\23""3\3\27""1" + "\12\30""1\1\23""3\3\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25/\7" + "\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3\17+\10\23" + ",\3\202\320q\202\320q\23,\3\23,\3\23,\3\0\0""3b\24""3b\24""3b\24""3b" + "\24""7e\17""5d\26""7e\17""5d\26""7e\17""7e\17""5d\26""9g\21""7f\30""4" + "j\23""4j\23""5k\24""9g\21""5k\24""9g\21""4j\23""5k\24""9g\21""4j\23""9" + "g\21""5k\24""9g\21""5k\24""9g\21""5k\24""9g\21""5k\24""9g\21""9g\21""5" + "k\24""4j\23""9g\21""4j\23""9g\21""9g\21""5d\26""7e\17""5d\26""5d\26""5" + "d\26""7e\17""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""3[\16""0" + "_\21""0_\21/^\20/^\20""3[\16-\\\16""3[\16""0Y\24""0Y\24""2Z\15""0Y\24" + "0Y\24""0Y\24.W\23.W\23.W\23-V\22-V\22*T\16*T\16*T\16*T\16*T\16*T\16*" + "T\16*T\16*T\16*N\22.P\14.P\14.P\14.P\14\202\320q\202\320q*N\22*N\22*" + "N\22\0\0\34:\5\34:\5\34:\5\31""9\13\27=\7\27=\7\27=\7\30>\10\30>\10\30" + ">\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77" + "\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\36B\5\32\77\12\32\77\12\32\77\12\30>\10\30>\10\30>\10\27=\7\27=\7\27" + "=\7\34:\5\34:\5\27""8\11\32""8\2\32""8\2\31""9\13\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\24""4" + "\5\30""1\1\23""3\3\27""1\12\23""3\3\27""1\12\30""1\1\30""1\1\25""0\10" + "\25""0\10\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3" + "\17+\10\23,\3\23,\3\17+\10\23,\3\202\320q\202\320q\23,\3\17+\10\23,\3" + "\0\0""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""7e\17""7e\17""7e\17""7" + "e\17""9g\21""7f\30""9g\21""9g\21""4j\23""5k\24""9g\21""5k\24""9g\21""5" + "k\24""5k\24""9g\21""4j\23""9g\21""4j\23""9g\21""4j\23""4j\23""5k\24""9" + "g\21""5k\24""9g\21""4j\23""9g\21""4j\23""9g\21""9g\21""7e\17""5d\26""5" + "d\26""7e\17""5d\26""5d\26""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""3" + "[\16""0_\21""3[\16""0_\21""3[\16/^\20/^\20/^\20""3[\16-\\\16""2Z\15""0" + "Y\24""0Y\24""0Y\24""0Y\24""0Y\24.W\23.W\23-V\22-V\22""0R\16*T\16*T\16" + "*T\16""0R\16*T\16*T\16*T\16*T\16(R\14.P\14.P\14*N\22.P\14.P\14*N\22\202" + "\320q\202\320q*N\22*N\22*N\22\0\0\34:\5\34:\5\31""9\13\27=\7\27=\7\27" + "=\7\27=\7\30>\10\30>\10\35;\6\32\77\12\32\77\12\32\77\12\32\77\12\36" + "B\5\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12" + "\36B\5\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\36B\5\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\27=\7\27" + "=\7\27=\7\27""8\11\34:\5\34:\5\34:\5\27""8\11\32""8\2\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25" + "5\6\24""4\5\27""1\12\23""3\3\23""3\3\23""3\3\27""1\12\30""1\1\25""0\10" + "\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5" + "\24.\5\23,\3\17+\10\23,\3\17+\10\23,\3\23,\3\23,\3\23,\3\202\320q\202" + "\320q\17+\10\23,\3\17+\10\0\0""3b\24""3b\24""7e\17""5d\26""5d\26""7e" + "\17""5d\26""7e\17""5d\26""7e\17""9g\21""9g\21""5k\24""4j\23""5k\24""9" + "g\21""9g\21""5k\24""4j\23""5k\24""9g\21""9g\21""5k\24""4j\23""4j\23""9" + "g\21""4j\23""5k\24""4j\23""9g\21""4j\23""5k\24""4j\23""7f\30""9g\21""9" + "g\21""7e\17""7e\17""5d\26""7e\17""7e\17""3b\24""3b\24""3b\24""3b\24""2" + "a\23""2a\23""2a\23""0_\21""0_\21""0_\21""3[\16/^\20/^\20/^\20-\\\16-" + "\\\16""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24.W\23.W\23-V\22" + "-V\22*T\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16*N\22.P\14*N\22." + "P\14.P\14*N\22.P\14*N\22\202\320q\202\320q*N\22*N\22*N\22\0\0\34:\5\27" + "8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32" + "\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12" + "\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30" + ">\10\30>\10\27=\7\27=\7\27=\7\34:\5\34:\5\27""8\11\32""8\2\32""8\2\31" + "9\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\25""5\6\24""4\5\24""4\5\30""1\1\23""3\3\23""3\3\23""3\3\23""3\3\30" + "1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24" + ".\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\17+\10\23,\3\23" + ",\3\202\320q\202\320q\17+\10\23,\3\17+\10\0\0""3b\24""3b\24""5d\26""5" + "d\26""7e\17""5d\26""5d\26""7e\17""5d\26""9g\21""7f\30""9g\21""9g\21""4" + "j\23""9g\21""5k\24""4j\23""9g\21""5k\24""9g\21""9g\21""4j\23""4j\23""5" + "k\24""4j\23""9g\21""9g\21""4j\23""5k\24""9g\21""4j\23""9g\21""9g\21""7" + "f\30""7e\17""7e\17""5d\26""5d\26""5d\26""5d\26""3b\24""3b\24""3b\24""2" + "a\23""2a\23""2a\23""0_\21""0_\21""0_\21/^\20""3[\16/^\20/^\20/^\20""3" + "[\16""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15.W\23.W\23-V\22" + "-V\22-V\22*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16(R\14*N\22.P\14*" + "N\22.P\14.P\14*N\22.P\14*N\22.P\14\202\320q\202\320q*N\22*N\22*N\22\0" + "\0\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12" + "\36B\5\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77" + "\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10" + "\30>\10\27=\7\27=\7\27=\7\34:\5\31""9\13\34:\5\31""9\13\32""8\2\32""8" + "\2\31""9\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\25""5\6\24""4\5\24""4\5\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3" + "\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7" + "\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23" + ",\3\23,\3\23,\3\23,\3\202\320q\202\320q\17+\10\17+\10\17+\10\0\0""3b" + "\24""5d\26""5d\26""5d\26""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21""7" + "f\30""9g\21""9g\21""5k\24""4j\23""5k\24""9g\21""9g\21""4j\23""4j\23""4" + "j\23""4j\23""9g\21""4j\23""5k\24""9g\21""4j\23""9g\21""4j\23""9g\21""7" + "f\30""9g\21""7e\17""5d\26""7e\17""7e\17""5d\26""7e\17""3b\24""3b\24""3" + "b\24""3b\24""2a\23""2a\23""2a\23""0_\21""3[\16""0_\21/^\20/^\20""3[\16" + "3[\16-\\\16""3[\16""2Z\15""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24." + "W\23.W\23-V\22-V\22*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*N\22" + "(R\14.P\14.P\14*N\22*N\22.P\14*N\22.P\14*N\22*N\22\202\320q\202\320q" + "*N\22*N\22*N\22\0\0\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10" + "\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77" + "\12\32\77\12\32\77\12\36B\5\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32" + "\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>" + "\10\27=\7\27=\7\27=\7\34:\5\31""9\13\34:\5\27""8\11\32""8\2\31""9\13" + "\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\25""5\6\24""4\5\30""1\1\24""4\5\27""1\12\23""3\3\30""1\1\23""3\3" + "\27""1\12\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/" + "\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\17+\10\23,\3\23,\3" + "\23,\3\23,\3\23,\3\17+\10\17+\10\17+\10\202\320q\202\320q\17+\10\17+" + "\10\17+\10\0\0""3b\24""5d\26""7e\17""5d\26""5d\26""7e\17""5d\26""7e\17" + "5d\26""9g\21""9g\21""9g\21""9g\21""4j\23""9g\21""4j\23""4j\23""9g\21" + "5k\24""4j\23""5k\24""9g\21""4j\23""4j\23""9g\21""4j\23""5k\24""9g\21" + "9g\21""9g\21""9g\21""7e\17""5d\26""5d\26""5d\26""5d\26""5d\26""3b\24" + "3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""3[\16""0_\21/^\20/^\20""3[" + "\16/^\20""3[\16-\\\16""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24" + ".W\23.W\23.W\23-V\22-V\22*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*" + "T\16*N\22.P\14*N\22.P\14.P\14*N\22.P\14*N\22*N\22*N\22*N\22*N\22\202" + "\320q\202\320q*N\22*N\22*N\22\0\0\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10" + "\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32" + "\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\30>\10\30>" + "\10\30>\10\30>\10\27=\7\27=\7\27=\7\27""8\11\34:\5\34:\5\31""9\13\32" + "8\2\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\25""5\6\25""5\6\24""4\5\23""3\3\23""3\3\23""3\3\23""3\3" + "\23""3\3\27""1\12\25""0\10\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25" + "/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\23,\3" + "\23,\3\23,\3\17+\10\23,\3\23,\3\17+\10\17+\10\17+\10\202\320q\202\320" + "q\17+\10\17+\10\17+\10\0\0""7e\17""5d\26""5d\26""5d\26""7e\17""7e\17" + "5d\26""5d\26""9g\21""7f\30""9g\21""9g\21""5k\24""9g\21""4j\23""5k\24" + "9g\21""4j\23""4j\23""5k\24""9g\21""5k\24""5k\24""9g\21""5k\24""9g\21" + "9g\21""9g\21""9g\21""7e\17""5d\26""5d\26""7e\17""5d\26""5d\26""3b\24" + "3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""3[\16""0_\21" + "0Y\24""3[\16/^\20-\\\16-\\\16""2Z\15""2Z\15""2Z\15""0Y\24""0Y\24""2Z" + "\15""0Y\24.W\23.W\23-V\22-V\22-V\22*T\16""0R\16*T\16*T\16*T\16*T\16*" + "T\16*T\16(R\14.P\14*N\22.P\14.P\14*N\22.P\14.P\14*N\22.P\14*N\22*N\22" + "*N\22*N\22\202\320q\202\320q*N\22*N\22*N\22\0\0\27=\7\27=\7\27=\7\27" + "=\7\30>\10\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\36" + "B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12" + "\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30" + ">\10\30>\10\27=\7\27=\7\27=\7\34:\5\31""9\13\34:\5\34:\5\32""8\2\27""8" + "\11\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\25""5\6\25""5\6\24""4\5\23""3\3\23""3\3\27""1\12\23""3" + "\3\23""3\3\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25" + "/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\23,\3" + "\23,\3\23,\3\17+\10\23,\3\17+\10\17+\10\17+\10\23,\3\17+\10\202\320q" + "\202\320q\23,\3\17+\10\17+\10\0\0""5d\26""7e\17""5d\26""7e\17""7e\17" + "5d\26""7e\17""5d\26""9g\21""9g\21""9g\21""7f\30""4j\23""4j\23""4j\23" + "4j\23""9g\21""9g\21""5k\24""5k\24""9g\21""4j\23""9g\21""9g\21""7f\30" + "9g\21""9g\21""7e\17""5d\26""7e\17""5d\26""5d\26""7e\17""5d\26""3b\24" + "3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""3[\16""0_\21""3[\16""3[\16" + "/^\20/^\20""3[\16-\\\16""3[\16""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2" + "Z\15""0Y\24.W\23.W\23-V\22-V\22*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T" + "\16*T\16*T\16*N\22.P\14*N\22.P\14.P\14.P\14*N\22.P\14.P\14*N\22*N\22" + "*N\22*N\22*N\22\202\320q\202\320q*N\22*N\22*N\22\0\0\27=\7\27=\7\27=" + "\7\30>\10\30>\10\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\30" + ">\10\27=\7\27=\7\27=\7\27=\7\34:\5\31""9\13\34:\5\34:\5\32""8\2\31""9" + "\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\25""5\6\25""5\6\24""4\5\24""4\5\27""1\12\23""3\3\23""3\3\23""3\3" + "\23""3\3\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/" + "\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\23,\3" + "\23,\3\23,\3\23,\3\23,\3\17+\10\17+\10\17+\10\17+\10\23,\3\17+\10\202" + "\320q\202\320q\17+\10\23,\3\17+\10\0\0""5d\26""7e\17""5d\26""7e\17""5" + "d\26""7e\17""7e\17""7e\17""9g\21""9g\21""9g\21""7f\30""4j\23""9g\21""4" + "j\23""5k\24""9g\21""4j\23""4j\23""5k\24""9g\21""9g\21""7f\30""9g\21""9" + "g\21""7e\17""5d\26""7e\17""7e\17""5d\26""7e\17""5d\26""3b\24""3b\24""3" + "b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21""0_\21""3[\16/" + "^\20""3[\16/^\20-\\\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y" + "\24.W\23.W\23.W\23-V\22-V\22*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16(R\14.P\14.P\14*N\22.P\14*N\22.P\14*N\22.P\14*N\22.P\14*N\22*N\22" + "*N\22*N\22*N\22\202\320q\202\320q*N\22*N\22*N\22\0\0\27=\7\27=\7\30>" + "\10\30>\10\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\30>\10\30>\10\27=" + "\7\27=\7\27=\7\34:\5\31""9\13\34:\5\34:\5\31""9\13\32""8\2\31""9\13\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\24""4\5\24""4\5\27""1\12\23""3\3\27""1\12\23""3\3\23""3\3\30""1\1" + "\25""0\10\30""1\1\25""0\10\30""1\1\25/\7\25/\7\25/\7\25/\7\25/\7\24." + "\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3" + "\23,\3\23,\3\23,\3\17+\10\17+\10\17+\10\17+\10\17+\10\23,\3\202\320q" + "\202\320q\17+\10\17+\10\17+\10\0\0""5d\26""5d\26""7e\17""5d\26""7e\17" + "5d\26""7e\17""9g\21""9g\21""9g\21""7f\30""9g\21""4j\23""9g\21""9g\21" + "5k\24""4j\23""9g\21""9g\21""7f\30""9g\21""9g\21""9g\21""5d\26""7e\17" + "7e\17""7e\17""5d\26""7e\17""5d\26""3b\24""3b\24""3b\24""3b\24""2a\23" + "2a\23""2a\23""2a\23""0_\21""0_\21""3[\16/^\20""3[\16/^\20""0Y\24""3[" + "\16""2Z\15""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15.W\23.W\23" + "-V\22-V\22-V\22*T\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16.P\14*" + "N\22.P\14*N\22.P\14*N\22.P\14*N\22.P\14*N\22.P\14*N\22*N\22*N\22*N\22" + "*N\22*N\22\202\320q\202\320q*N\22*N\22*N\22\0\0\27=\7\27=\7\30>\10\30" + ">\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\30>\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=" + "\7\27""8\11\34:\5\31""9\13\34:\5\31""9\13\32""8\2\32""8\2\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\24" + "4\5\24""4\5\23""3\3\27""1\12\30""1\1\23""3\3\30""1\1\30""1\1\25""0\10" + "\30""1\1\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5" + "\24.\5\24.\5\23,\3\17+\10\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23" + ",\3\23,\3\17+\10\17+\10\17+\10\17+\10\17+\10\23,\3\17+\10\202\320q\202" + "\320q\23,\3\17+\10\23,\3\0\0""5d\26""5d\26""5d\26""7e\17""7e\17""7f\30" + "9g\21""9g\21""9g\21""7f\30""9g\21""9g\21""7f\30""9g\21""9g\21""9g\21" + "7f\30""9g\21""7f\30""9g\21""9g\21""7e\17""7e\17""5d\26""7e\17""5d\26" + "5d\26""5d\26""5d\26""3b\24""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23" + "3[\16""0_\21""0_\21""0_\21""3[\16/^\20""3[\16/^\20""3[\16""0Y\24""2Z" + "\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24.W\23.W\23-V\22-V\22-V\22" + "*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16(R\14(R\14.P\14*N\22." + "P\14*N\22*N\22.P\14*N\22.P\14*N\22*N\22*N\22*N\22*N\22*N\22*N\22*N\22" + "\202\320q\202\320q*N\22*N\22*N\22\0\0\27=\7\27=\7\30>\10\30>\10\30>\10" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30" + ">\10\30>\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7\34:\5\34:\5" + "\34:\5\27""8\11\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\24""4\5" + "\23""3\3\30""1\1\23""3\3\23""3\3\23""3\3\25""0\10\30""1\1\25""0\10\25" + "0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\23" + ",\3\23,\3\23,\3\17+\10\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\17+\10\17" + "+\10\23,\3\17+\10\17+\10\17+\10\23,\3\17+\10\23,\3\202\320q\202\320q" + "\17+\10\17+\10\23,\3\0\0""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21""7" + "f\30""9g\21""7f\30""9g\21""9g\21""9g\21""7f\30""9g\21""9g\21""9g\21""7" + "f\30""9g\21""9g\21""9g\21""7e\17""5d\26""5d\26""7e\17""7e\17""5d\26""5" + "d\26""5d\26""3b\24""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0" + "_\21""0_\21""0_\21/^\20/^\20""3[\16/^\20-\\\16""3[\16""2Z\15""2Z\15""0" + "Y\24""0Y\24""2Z\15""2Z\15""0Y\24.W\23.W\23-V\22-V\22*T\16*T\16*T\16*" + "T\16*T\16*T\16*T\16*T\16*T\16*T\16(R\14*N\22.P\14*N\22.P\14*N\22.P\14" + "*N\22.P\14.P\14.P\14*N\22*N\22*N\22*N\22*N\22*N\22*N\22*N\22\202\320" + "q\202\320q*N\22*N\22*N\22\0\0\27=\7\30>\10\30>\10\30>\10\30>\10\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\30" + ">\10\30>\10\35;\6\27=\7\27=\7\27=\7\34:\5\31""9\13\34:\5\34:\5\31""9" + "\13\32""8\2\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\24""4\5\23""3\3\23""3\3" + "\23""3\3\23""3\3\23""3\3\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10" + "\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23" + ",\3\23,\3\23,\3\17+\10\23,\3\23,\3\17+\10\23,\3\23,\3\17+\10\17+\10\17" + "+\10\23,\3\17+\10\17+\10\23,\3\17+\10\17+\10\202\320q\202\320q\17+\10" + "\17+\10\23,\3\0\0""5d\26""7e\17""5d\26""7e\17""5d\26""9g\21""7f\30""9" + "g\21""9g\21""9g\21""7f\30""9g\21""9g\21""7f\30""7f\30""9g\21""9g\21""7" + "e\17""5d\26""7e\17""5d\26""7e\17""7e\17""5d\26""5d\26""5d\26""5d\26""3" + "b\24""3b\24""3b\24""2a\23""2a\23""2a\23""3[\16""0_\21""0_\21""0_\21""3" + "[\16/^\20/^\20""3[\16-\\\16-\\\16""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15" + "0Y\24""2Z\15""0Y\24.W\23.W\23-V\22-V\22*T\16""0R\16*T\16""0R\16*T\16" + "*T\16*T\16*T\16*T\16*T\16(R\14*N\22.P\14.P\14.P\14.P\14*N\22.P\14.P\14" + "*N\22.P\14.P\14*N\22*N\22*N\22*N\22*N\22*N\22*N\22*N\22\202\320q\202" + "\320q*N\22*N\22*N\22\0\0\30>\10\30>\10\30>\10\30>\10\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\30>\10\30>\10\27=\7\27=" + "\7\27=\7\27=\7\27=\7\31""9\13\34:\5\34:\5\34:\5\32""8\2\31""9\13\32""8" + "\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\25""5\6\25""5\6\24""4\5\27""1\12\23""3\3\27""1\12\23""3\3\23""3" + "\3\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25" + "/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\17+\10\23," + "\3\17+\10\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\23,\3\17+\10\17+\10\17" + "+\10\23,\3\17+\10\17+\10\23,\3\17+\10\202\320q\202\320q\17+\10\17+\10" + "\23,\3\0\0""5d\26""7e\17""7e\17""5d\26""7f\30""9g\21""7f\30""9g\21""9" + "g\21""9g\21""7f\30""9g\21""9g\21""9g\21""7f\30""9g\21""7e\17""7e\17""7" + "e\17""7e\17""7e\17""5d\26""5d\26""5d\26""5d\26""3b\24""3b\24""3b\24""3" + "b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21""3[\16/^\20""3[\16/^\20" + "/^\20-\\\16-\\\16""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15.W" + "\23.W\23.W\23-V\22-V\22*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16(R\14(R\14*N\22.P\14*N\22.P\14*N\22.P\14*N\22.P\14.P\14*N\22*N\22" + "*N\22*N\22*N\22*N\22*N\22*N\22*N\22*N\22\202\320q\202\320q*N\22*N\22" + "*N\22\0\0\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\30" + ">\10\30>\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7\31""9\13\34" + ":\5\34:\5\34:\5\32""8\2\31""9\13\32""8\2\32""8\2\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24" + "4\5\27""1\12\23""3\3\30""1\1\23""3\3\23""3\3\30""1\1\30""1\1\30""1\1" + "\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24" + ".\5\24.\5\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3" + "\23,\3\17+\10\23,\3\23,\3\17+\10\17+\10\17+\10\17+\10\23,\3\17+\10\17" + "+\10\17+\10\202\320q\202\320q\17+\10\23,\3\23,\3\0\0""7e\17""7e\17""9" + "g\21""7f\30""9g\21""7f\30""9g\21""9g\21""9g\21""9g\21""7f\30""9g\21""9" + "g\21""7f\30""9g\21""5d\26""7e\17""5d\26""7e\17""7e\17""5d\26""5d\26""5" + "d\26""5d\26""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""2a\23""0_\21""0" + "_\21""0_\21""0_\21/^\20/^\20""0Y\24/^\20-\\\16-\\\16""2Z\15""0Y\24""0" + "Y\24""0Y\24""0Y\24""0Y\24""2Z\15.W\23.W\23-V\22-V\22-V\22*T\16*T\16""0" + "R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16.P\14*N\22.P\14*N\22.P\14.P\14" + ".P\14.P\14*N\22.P\14*N\22.P\14*N\22.P\14*N\22*N\22*N\22*N\22*N\22*N\22" + "*N\22*N\22\202\320q\202\320q*N\22.P\14.P\14\0\0\30>\10\30>\10\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\30>\10\30>\10\27" + "=\7\35;\6\27=\7\27=\7\34:\5\34:\5\34:\5\34:\5\31""9\13\32""8\2\31""9" + "\13\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\25""5\6\25""5\6\24""4\5\24""4\5\27""1\12\23""3\3\23""3\3\27""1\12" + "\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7" + "\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3\23" + ",\3\23,\3\17+\10\23,\3\17+\10\23,\3\17+\10\23,\3\23,\3\23,\3\23,\3\17" + "+\10\17+\10\17+\10\17+\10\23,\3\17+\10\23,\3\23,\3\202\320q\202\320q" + "\23,\3\23,\3\23,\3\0\0""7e\17""7e\17""9g\21""7f\30""9g\21""9g\21""9g" + "\21""9g\21""9g\21""7f\30""9g\21""9g\21""9g\21""7f\30""7e\17""5d\26""5" + "d\26""7e\17""5d\26""5d\26""5d\26""5d\26""5d\26""3b\24""3b\24""3b\24""2" + "a\23""2a\23""2a\23""2a\23""0_\21""3[\16""0_\21""0_\21""3[\16/^\20""3" + "[\16/^\20""3[\16-\\\16""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y" + "\24.W\23.W\23-V\22-V\22-V\22*T\16*T\16*T\16*T\16""0R\16*T\16*T\16*T\16" + "*T\16*T\16(R\14*N\22.P\14*N\22.P\14*N\22.P\14*N\22.P\14.P\14.P\14*N\22" + "*N\22*N\22.P\14*N\22*N\22*N\22*N\22.P\14*N\22.P\14*N\22\202\320q\202" + "\320q*N\22.P\14*N\22\0\0\30>\10\30>\10\36B\5\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>" + "\10\30>\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7\27""8\11\31""9" + "\13\34:\5\34:\5\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\24""4\5\24""4\5\24""4" + "\5\23""3\3\23""3\3\23""3\3\30""1\1\27""1\12\30""1\1\30""1\1\25""0\10" + "\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24" + ".\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3" + "\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23" + ",\3\17+\10\23,\3\202\320q\202\320q\23,\3\17+\10\23,\3\0\0""7e\17""7f" + "\30""9g\21""9g\21""9g\21""9g\21""9g\21""9g\21""7f\30""9g\21""7f\30""9" + "g\21""7e\17""7e\17""5d\26""7e\17""5d\26""5d\26""5d\26""5d\26""5d\26""3" + "b\24""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""2a\23""0_\21""0_\21""0" + "_\21/^\20/^\20""3[\16/^\20-\\\16-\\\16""2Z\15""0Y\24""0Y\24""0Y\24""0" + "Y\24""2Z\15""0Y\24""0Y\24.W\23.W\23-V\22-V\22-V\22*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16*T\16*T\16(R\14(R\14.P\14*N\22.P\14*N\22.P\14.P\14" + "*N\22.P\14*N\22.P\14*N\22.P\14*N\22.P\14.P\14*N\22.P\14.P\14*N\22*N\22" + ".P\14.P\14\202\320q\202\320q.P\14.P\14*N\22\0\0\32\77\12\32\77\12\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\30>\10\30>\10\30>\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7" + "\27=\7\31""9\13\34:\5\31""9\13\34:\5\32""8\2\31""9\13\32""8\2\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5" + "\6\25""5\6\24""4\5\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\27""1\12" + "\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7" + "\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\23" + ",\3\23,\3\17+\10\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\17+" + "\10\23,\3\17+\10\23,\3\17+\10\23,\3\23,\3\17+\10\23,\3\202\320q\202\320" + "q\23,\3\23,\3\23,\3\0\0""7f\30""9g\21""9g\21""9g\21""9g\21""9g\21""9" + "g\21""7f\30""9g\21""9g\21""9g\21""5d\26""7e\17""5d\26""5d\26""7e\17""5" + "d\26""5d\26""7e\17""5d\26""3b\24""3b\24""3b\24""3b\24""2a\23""2a\23""2" + "a\23""0_\21""0_\21""0_\21""3[\16""0_\21/^\20""3[\16/^\20-\\\16-\\\16" + "-\\\16""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24.W\23.W\23-V\22" + "-V\22-V\22*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16(R\14.P\14" + ".P\14*N\22.P\14*N\22.P\14.P\14.P\14*N\22.P\14*N\22.P\14.P\14*N\22.P\14" + "*N\22.P\14.P\14*N\22.P\14.P\14*N\22.P\14.P\14\202\320q\202\320q*N\22" + ".P\14.P\14\0\0\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\30>\10\30>\10\30>" + "\10\27=\7\27=\7\27=\7\27=\7\27=\7\34:\5\34:\5\27""8\11\34:\5\31""9\13" + "\32""8\2\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\27""1\12\23""3\3\27""1\12" + "\23""3\3\27""1\12\23""3\3\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10" + "\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\23" + ",\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\23,\3\23," + "\3\23,\3\17+\10\23,\3\17+\10\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\23" + ",\3\23,\3\17+\10\202\320q\202\320q\23,\3\23,\3\23,\3\0\0""7f\30""9g\21" + "9g\21""9g\21""9g\21""9g\21""7f\30""9g\21""9g\21""5d\26""7e\17""5d\26" + "5d\26""5d\26""7e\17""5d\26""5d\26""5d\26""5d\26""3b\24""3b\24""3b\24" + "3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21""0_\21""0_\21""3[\16" + "/^\20/^\20/^\20""0Y\24-\\\16""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24" + "0Y\24.W\23.W\23-V\22-V\22-V\22""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*" + "T\16*T\16*T\16*T\16*N\22.P\14*N\22.P\14.P\14*N\22.P\14.P\14*N\22.P\14" + ".P\14*N\22.P\14.P\14.P\14.P\14.P\14*N\22.P\14.P\14.P\14.P\14*N\22.P\14" + ".P\14\202\320q\202\320q*N\22*N\22.P\14\0\0\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10" + "\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7\34:\5\34:\5\34:\5\34:\5" + "\31""9\13\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\24""4\5\24""4\5\23""3\3" + "\27""1\12\23""3\3\23""3\3\23""3\3\30""1\1\30""1\1\25""0\10\30""1\1\25" + "0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24" + ".\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\17+\10\23" + ",\3\17+\10\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\17" + "+\10\23,\3\17+\10\23,\3\23,\3\17+\10\202\320q\202\320q\23,\3\23,\3\24" + ".\5\0\0""9g\21""9g\21""9g\21""9g\21""9g\21""9g\21""7f\30""9g\21""9g\21" + "7e\17""7e\17""5d\26""5d\26""7e\17""5d\26""5d\26""5d\26""5d\26""3b\24" + "3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21""0_\21" + "/^\20/^\20""3[\16/^\20-\\\16-\\\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24" + "2Z\15""0Y\24""0Y\24.W\23.W\23-V\22-V\22-V\22*T\16*T\16*T\16""0R\16*T" + "\16*T\16*T\16*T\16*T\16*T\16*T\16(R\14.P\14.P\14.P\14\242\261\230\236" + "\262\222\242\261\230\235\261\220\235\261\220\235\261\220\235\261\220" + "\235\261\220\242\261\230\236\262\222\242\261\230\236\262\222\242\261" + "\230\236\262\222\235\261\220\242\261\230\235\261\220\236\262\222\235" + "\261\220.P\14*N\22.P\14\202\320q\202\320q*N\22*T\16*T\16\0\0\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10" + "\30>\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7\34:\5\34:\5\27""8" + "\11\34:\5\31""9\13\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5" + "\23""3\3\23""3\3\30""1\1\30""1\1\23""3\3\23""3\3\25""0\10\30""1\1\25" + "0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24." + "\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\17+\10\23,\3\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\17+\10\23,\3\17+\10\202\320q\202\320q\24.\5\24.\5\24.\5\0\0""7f" + "\30""9g\21""9g\21""7f\30""9g\21""9g\21""9g\21""7f\30""7e\17""5d\26""7" + "e\17""5d\26""7e\17""5d\26""5d\26""5d\26""5d\26""3b\24""3b\24""3b\24""3" + "b\24""2a\23""2a\23""2a\23""3[\16""0_\21""0_\21""0_\21""3[\16/^\20/^\20" + "/^\20-\\\16-\\\16""3[\16""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0" + "Y\24.W\23.W\23-V\22-V\22-V\22*T\16""0R\16*T\16""0R\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16*T\16(R\14*N\22.P\14.P\14\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + ".P\14.P\14.P\14\202\320q\202\320q*T\16*T\16*T\16\0\0\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\30>\10\30>\10\30>\10\30" + ">\10\27=\7\27=\7\27=\7\27=\7\27=\7\34:\5\27""8\11\34:\5\34:\5\31""9\13" + "\32""8\2\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\23""3\3\23""3\3\30" + "1\1\23""3\3\23""3\3\30""1\1\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24" + ".\5\23,\3\23,\3\23,\3\23,\3\17+\10\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\23,\3\23,\3" + "\17+\10\202\320q\202\320q\24.\5\24.\5\24.\5\0\0""9g\21""7f\30""9g\21" + "7f\30""9g\21""9g\21""7e\17""7e\17""5d\26""7e\17""5d\26""5d\26""5d\26" + "5d\26""5d\26""7e\17""3b\24""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23" + "3[\16""0_\21""0_\21""0_\21""3[\16/^\20/^\20/^\20""3[\16-\\\16""0Y\24" + "0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24.W\23.W\23-V\22-V\22-" + "V\22*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*N\22" + "(R\14*N\22.P\14.P\14\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374*N\22(R\14*T\16\202\320q" + "\202\320q*T\16*T\16*T\16\0\0\32\77\12\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\30>\10\30>\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27" + "=\7\34:\5\34:\5\34:\5\31""9\13\32""8\2\32""8\2\31""9\13\32""8\2\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\24""4\5\24""4\5\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\27""1\12" + "\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3" + "\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\23,\3[mP\367\371\366\372" + "\374\371\214\227\2067M+\27""1\12\27""1\12""7M+\214\227\206\372\374\371" + "\373\375\372\177\216v\23,\3\23,\3\24.\5\24.\5\202\320q\202\320q\24.\5" + "\24.\5\25/\7\0\0""9g\21""7f\30""7f\30""9g\21""9g\21""9g\21""7e\17""7" + "e\17""5d\26""7e\17""5d\26""5d\26""5d\26""7e\17""5d\26""3b\24""3b\24""3" + "b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""3[\16""0_\21/^\20/^\20" + "/^\20/^\20-\\\16""3[\16""0Y\24""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""0" + "Y\24""0Y\24.W\23.W\23-V\22-V\22-V\22*T\16*T\16""0R\16*T\16""0R\16*T\16" + "*T\16*T\16*T\16*T\16*T\16*T\16*T\16*N\22(R\14*N\22.P\14.P\14*N\22.P\14" + ".P\14*N\22*N\22Po7\370\372\367\376\377\374\215\236y*N\22.P\14.P\14.P" + "\14*N\22.P\14\215\236y\376\377\374\376\377\374t\211^*T\16*T\16*T\16\202" + "\320q\202\320q*T\16*T\16""0R\16\0\0\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\30>\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27" + "=\7\31""9\13\34:\5\31""9\13\34:\5\31""9\13\32""8\2\31""9\13\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\25""5\6\25""5\6\24""4\5\30""1\1\23""3\3\27""1\12\23""3\3\23""3\3" + "\23""3\3\25""0\10\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25" + "/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5" + "\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\23,\3\23,\3\23,\3\253\271" + "\255\376\377\374\376\377\3747M+\23,\3\23,\3\17+\10\23,\3\23,\3\23,\3" + "8N,\376\377\374\376\377\374\302\311\276\24.\5\24.\5\24.\5\202\320q\202" + "\320q\25/\7\25/\7\25/\7\0\0""7f\30""9g\21""7f\30""9g\21""9g\21""9g\21" + "7e\17""7e\17""5d\26""7e\17""7e\17""5d\26""7e\17""5d\26""3b\24""3b\24" + "3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""3[\16""0_\21""0_\21/^\20/^" + "\20""3[\16/^\20""3[\16-\\\16""3[\16""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15" + "0Y\24""2Z\15.W\23.W\23-V\22-V\22-V\22*T\16*T\16*T\16""0R\16*T\16*T\16" + "*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*N\22(R\14*N\22*N\22.P\14.P\14" + "*N\22.P\14.P\14*N\22\360\362\357\376\377\374\376\377\374b|K*N\22.P\14" + ".P\14.P\14.P\14(R\14b|K\376\377\374\376\377\374\361\363\360*T\16*T\16" + "*T\16\202\320q\202\320q*T\16*T\16*T\16\0\0\32\77\12\32\77\12\32\77\12" + "\32\77\12\36B\5\32\77\12\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7" + "\27""8\11\34:\5\34:\5\31""9\13\31""9\13\32""8\2\31""9\13\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\25""5\6\24""4\5\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3" + "\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/" + "\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5" + "\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\23,\3\17+\10\23,\3\370\372" + "\367\376\377\374\376\377\374\315\324\311(>\35\23,\3\23,\3\17+\10\23," + "\3(>\35\321\327\314\376\377\374\376\377\374\370\372\367\24.\5\24.\5\24" + ".\5\202\320q\202\320q\25/\7\25/\7\25/\7\0\0""9g\21""9g\21""7f\30""9g" + "\21""9g\21""7e\17""7e\17""5d\26""7e\17""7e\17""5d\26""5d\26""5d\26""3" + "b\24""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""3[\16""0_\21""0_\21""3" + "[\16/^\20""3[\16/^\20/^\20-\\\16-\\\16""2Z\15""2Z\15""2Z\15""0Y\24""0" + "Y\24""2Z\15""0Y\24""2Z\15.W\23.W\23.W\23-V\22-V\22-V\22*T\16""0R\16*" + "T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16.P\14*N\22(R" + "\14*N\22.P\14.P\14*N\22.P\14*N\22.P\14.P\14\341\347\334\376\377\374\376" + "\377\374\376\377\374\366\370\364\277\313\270\245\264\233\245\264\233" + "\277\313\270\367\371\366\376\377\374\376\377\374\376\377\374\341\347" + "\334*T\16*T\16*T\16\202\320q\202\320q*T\16""0R\16-V\22\0\0\32\77\12\32" + "\77\12\32\77\12\32\77\12\30>\10\30>\10\30>\10\30>\10\30>\10\27=\7\27" + "=\7\27=\7\34:\5\27""8\11\34:\5\34:\5\31""9\13\32""8\2\31""9\13\32""8" + "\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\25""5\6\24""4\5\24""4\5\27""1\12\23""3\3\30""1\1\23""3\3\23""3\3" + "\30""1\1\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25" + "/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5" + "\24.\5\23,\3\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\23,\3\23,\3\23" + ",\3\221\234\213\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\221\234\213\24.\5\25/\7\25/\7\202\320q\202\320q" + "\25/\7\25""0\10\25""0\10\0\0""9g\21""9g\21""9g\21""5d\26""7e\17""7e\17" + "5d\26""7e\17""5d\26""5d\26""7e\17""5d\26""3b\24""3b\24""3b\24""3b\24" + "2a\23""2a\23""2a\23""3[\16""0_\21""0_\21""0_\21""3[\16/^\20""3[\16/^" + "\20-\\\16-\\\16""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z" + "\15.W\23.W\23.W\23-V\22-V\22-V\22*T\16*T\16*T\16""0R\16*T\16""0R\16*" + "T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16(R\14*N\22(R\14*N\22.P\14.P\14" + ".P\14.P\14*N\22.P\14*N\22""6Y\35\341\347\334\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\341\347\3349\\\37*T\16*T\16*T\16\202\320" + "q\202\320q*T\16-V\22-V\22\0\0\32\77\12\32\77\12\32\77\12\30>\10\30>\10" + "\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7\27=\7\34:\5\27""8\11\34:\5\32" + "8\2\32""8\2\32""8\2\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\23""3\3\30""1" + "\1\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3\30""1\1\25""0\10\25""0\10" + "\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24" + ".\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\23,\3\23,\3\23,\3\23,\3\23,\3" + "\23,\3\17+\10\23,\3\23,\3\23,\3\23,\3\17+\10+A\40\307\316\303\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\313\321\3061E\36\25/\7\25/\7\25/\7\25/\7\202\320" + "q\202\320q\25""0\10\25""0\10\25""0\10\0\0""9g\21""9g\21""7f\30""7e\17" + "7e\17""5d\26""7e\17""5d\26""5d\26""5d\26""5d\26""3b\24""3b\24""3b\24" + "3b\24""2a\23""2a\23""2a\23""0_\21""3[\16""0_\21""0_\21""3[\16/^\20/^" + "\20""3[\16-\\\16""0Y\24-\\\16""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y" + "\24""2Z\15.W\23.W\23.W\23-V\22-V\22-V\22*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16(R\14.P\14*N\22.P\14*N\22" + ".P\14.P\14.P\14*N\22*N\22.P\14(R\14(R\14*N\22m\212^\270\303\261\344\353" + "\340\370\372\367\370\372\367\345\354\341\267\307\255m\212^0R\16""0R\16" + "*T\16*T\16*T\16*T\16\202\320q\202\320q-V\22.W\23.W\23\0\0\32\77\12\32" + "\77\12\32\77\12\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7\27=\7\31" + "9\13\34:\5\34:\5\31""9\13\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5" + "\6\24""4\5\24""4\5\27""1\12\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3" + "\25""0\10\30""1\1\30""1\1\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5" + "\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\17+\10\23,\3\23,\3\23,\3\23,\3\23" + ",\3\23,\3\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\202\320q\202\320q\25""0\10\30""1\1\30" + "1\1\0\0""9g\21""9g\21""7f\30""5d\26""7e\17""5d\26""5d\26""5d\26""5d\26" + "5d\26""3b\24""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""3[\16""0_\21" + "0_\21""3[\16/^\20/^\20/^\20""3[\16-\\\16-\\\16""0Y\24""0Y\24""0Y\24""0" + "Y\24""0Y\24""0Y\24""2Z\15""0Y\24.W\23.W\23.W\23-V\22-V\22-V\22*T\16*" + "T\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0" + "R\16*T\16*T\16(R\14(R\14.P\14(R\14*N\22(R\14(R\14.P\14(R\14(R\14.P\14" + "*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*" + "T\16*T\16-V\22\202\320q\202\320q.W\23.W\23""0Y\24\0\0\32\77\12\32\77" + "\12\32\77\12\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7\34:\5\34:\5" + "\27""8\11\32""8\2\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\24""4\5\24""4\5" + "\24""4\5\30""1\1\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3\30""1\1\30" + "1\1\25""0\10\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24" + ".\5\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\23,\3\24.\5\24.\5" + "\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\25""0\10\25""0\10\202\320q\202\320q\30""1\1\23""3\3\23" + "3\3\0\0""9g\21""9g\21""5d\26""7e\17""5d\26""5d\26""5d\26""7e\17""5d\26" + "3b\24""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21" + "3[\16""0_\21""3[\16""3[\16""3[\16""0Y\24-\\\16""3[\16""2Z\15""0Y\24""0" + "Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15.W\23.W\23-V\22-V\22-V\22*T\16" + "*T\16*T\16""0R\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16*T\16*T\16(R\14(R\14(R\14\236\262\222\236\262\222" + "\236\262\222\242\261\230\236\262\222\242\261\230\236\262\222\242\261" + "\230\236\262\222\242\261\230\236\262\222\236\262\222\236\262\222\237" + "\263\223\237\263\223\237\263\223\237\263\223\237\263\223\237\263\223" + "-V\22-V\22-V\22\202\320q\202\320q2Z\15""0Y\24""2Z\15\0\0\32\77\12\30" + ">\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\27=\7\34:\5\27""8\11\34:" + "\5\34:\5\32""8\2\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\30""1\1" + "\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\25""0\10\25""0\10\30" + "1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5" + "\24.\5\24.\5\24.\5\24.\5\24.\5\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\25""0\10\25""0\10" + "\30""1\1\202\320q\202\320q\23""3\3\27""1\12\23""3\3\0\0""9g\21""7e\17" + "7e\17""7e\17""5d\26""7e\17""5d\26""7e\17""3b\24""3b\24""3b\24""3b\24" + "2a\23""2a\23""2a\23""0_\21""0_\21""0_\21""0_\21""0_\21/^\20""3[\16/^" + "\20""3[\16-\\\16""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2" + "Z\15""0Y\24.W\23.W\23.W\23-V\22-V\22-V\22*T\16*T\16""0R\16*T\16*T\16" + "0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374-V\22.W\23.W\23\202\320q" + "\202\320q0Y\24""0Y\24""0Y\24\0\0\32\77\12\30>\10\30>\10\35;\6\27=\7\27" + "=\7\27=\7\27=\7\27""8\11\34:\5\27""8\11\34:\5\31""9\13\32""8\2\31""9" + "\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\25""5\6\24""4\5\24""4\5\24""4\5\23""3\3\23""3\3\23""3\3\23""3\3" + "\23""3\3\23""3\3\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10" + "\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5" + "\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24" + ".\5\24.\5\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\30""1\1\25""0\10\25""0\10\202\320q\202" + "\320q\23""3\3\23""3\3\30""1\1\0\0""7e\17""7e\17""5d\26""7e\17""5d\26" + "5d\26""5d\26""3b\24""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21" + "0_\21""0_\21""0_\21""3[\16/^\20""3[\16/^\20-\\\16-\\\16""2Z\15""2Z\15" + "0Y\24""0Y\24""0Y\24""2Z\15""2Z\15""0Y\24""0Y\24.W\23.W\23.W\23-V\22-" + "V\22-V\22""0R\16*T\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374.W\23.W\23""0Y\24\202\320q\202\320q0Y\24""2Z\15""2" + "Z\15\0\0\30>\10\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\34:\5\27""8\11" + "\31""9\13\34:\5\32""8\2\27""8\11\32""8\2\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\24""4" + "\5\23""3\3\30""1\1\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\25""0\10\30" + "1\1\25""0\10\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24" + ".\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5" + "\24.\5\24.\5\24.\5\24.\5\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25""0\10" + "\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\23""3\3\23""3\3\202\320q" + "\202\320q\30""1\1\24""4\5\24""4\5\0\0""7e\17""7e\17""7e\17""5d\26""5" + "d\26""7e\17""5d\26""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""3" + "[\16""0_\21""0_\21""0_\21/^\20/^\20/^\20""0Y\24-\\\16-\\\16""2Z\15""0" + "Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15.W\23.W\23.W\23-V\22-V" + "\22-V\22-V\22*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*" + "T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16""0R\16*T\16" + "*T\16-V\22-V\22.W\23.W\23.W\23""0Y\24""0Y\24""2Z\15\202\320q\202\320" + "q2Z\15""0Y\24-\\\16\0\0\30>\10\30>\10\30>\10\27=\7\27=\7\27=\7\31""9" + "\13\34:\5\34:\5\34:\5\31""9\13\31""9\13\31""9\13\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\25" + "5\6\24""4\5\30""1\1\23""3\3\27""1\12\23""3\3\23""3\3\30""1\1\23""3\3" + "\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24" + ".\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5" + "\24.\5\24.\5\24.\5\24.\5\24.\5\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\23""3\3\23""3" + "\3\23""3\3\202\320q\202\320q\24""4\5\25""5\6\25""5\6\0\0""7e\17""5d\26" + "7e\17""7e\17""5d\26""5d\26""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23" + "2a\23""0_\21""3[\16""0_\21""0_\21/^\20/^\20/^\20""3[\16""3[\16-\\\16" + "2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24.W\23.W\23.W\23" + ".W\23-V\22-V\22-V\22*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*" + "T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16""0R\16*T\16""0R" + "\16*T\16-V\22-V\22-V\22""2Z\15.W\23""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15" + "\202\320q\202\320q-\\\16-\\\16/^\20\0\0\30>\10\30>\10\27=\7\27=\7\27" + "=\7\27""8\11\34:\5\34:\5\31""9\13\32""8\2\32""8\2\31""9\13\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25" + "5\6\25""5\6\24""4\5\24""4\5\27""1\12\23""3\3\27""1\12\23""3\3\23""3\3" + "\23""3\3\30""1\1\25""0\10\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24" + ".\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5" + "\24.\5\24.\5\226\240\217\226\240\217\226\240\217#>\27\25/\7\226\240\217" + "\226\240\217\226\240\217\226\240\217\226\240\217\226\240\217\227\241" + "\220\227\241\220\227\241\220\227\241\220\227\241\220\230\242\221\225" + "\245\214\230\242\221\23""3\3\30""1\1\23""3\3\202\320q\202\320q\25""5" + "\6\27""7\10\27""7\10\0\0""5d\26""5d\26""7e\17""5d\26""5d\26""3b\24""3" + "b\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21""3[\16/" + "^\20/^\20""3[\16/^\20-\\\16""3[\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24" + "2Z\15""0Y\24""2Z\15""0Y\24.W\23.W\23.W\23-V\22-V\22-V\22*T\16*T\16*T" + "\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0R\16" + "*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16\376\377\374\376\377" + "\374\376\377\374Po7*T\16\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\3740Y\24""0Y\24" + "2Z\15\202\320q\202\320q-\\\16/^\20/^\20\0\0\30>\10\27=\7\27=\7\27=\7" + "\27=\7\27""8\11\34:\5\34:\5\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5" + "\6\25""5\6\24""4\5\24""4\5\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\30" + "1\1\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25/" + "\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5" + "\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24" + ".\5\24.\5\24.\5\376\377\374\376\377\374\376\377\3744H\"\25/\7\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\23""3\3\24""4\5\24""4\5\202\320q\202\320q\27" + "7\10\27""7\10\25""5\6\0\0""5d\26""5d\26""5d\26""5d\26""3b\24""3b\24""3" + "b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""3[\16""0_\21/^\20""3" + "[\16/^\20""3[\16-\\\16-\\\16""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24" + "0Y\24""2Z\15""0Y\24.W\23.W\23.W\23-V\22-V\22-V\22-V\22*T\16*T\16*T\16" + "0R\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*" + "T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16\376\377\374\376\377" + "\374\376\377\374Fj,*T\16\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\3742Z\15""0Y\24" + "-\\\16\202\320q\202\320q3[\16""3[\16""0_\21\0\0\27=\7\27=\7\27=\7\27" + "=\7\34:\5\31""9\13\34:\5\31""9\13\32""8\2\31""9\13\31""9\13\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5" + "\6\25""5\6\24""4\5\24""4\5\30""1\1\27""1\12\23""3\3\23""3\3\27""1\12" + "\23""3\3\27""1\12\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24" + ".\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5" + "\24.\5\24.\5\25/\7\25/\7\376\377\374\376\377\374\376\377\3744H\"\25/" + "\7\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\24""4\5\25""5\6\25""5\6\202\320q\202" + "\320q\27""7\10\27""7\10\27""7\10\0\0""7e\17""5d\26""5d\26""3b\24""3b" + "\24""3b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21/^\20/^\20" + "0Y\24/^\20""3[\16/^\20""0Y\24-\\\16""2Z\15""2Z\15""0Y\24""0Y\24""2Z\15" + "0Y\24""0Y\24""0Y\24.W\23.W\23.W\23-V\22-V\22-V\22-V\22*T\16""0R\16*T" + "\16*T\16""0R\16*T\16""0R\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16*T\16*" + "T\16*T\16*T\16*T\16""0R\16-V\22-V\22-V\22.W\23.W\23.W\23""2Z\15""0Y\24" + "0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15-\\\16-\\\16\202\320q\202\320" + "q3[\16""0_\21""0_\21\0\0\27=\7\27=\7\27=\7\27""8\11\34:\5\27""8\11\31" + "9\13\32""8\2\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\24""4\5\23""3" + "\3\27""1\12\23""3\3\23""3\3\30""1\1\27""1\12\23""3\3\25""0\10\30""1\1" + "\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24" + ".\5\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25""0\10\25""0\10\25""0\10\30""1\1\30" + "1\1\25""0\10\30""1\1\23""3\3\27""1\12\23""3\3\23""3\3\27""1\12\24""4" + "\5\24""4\5\24""4\5\25""5\6\27""7\10\202\320q\202\320q\27""7\10\27""7" + "\10\27""7\10\0\0""5d\26""5d\26""7e\17""3b\24""3b\24""3b\24""2a\23""2" + "a\23""2a\23""0_\21""0_\21""3[\16/^\20/^\20""3[\16/^\20/^\20""3[\16-\\" + "\16-\\\16""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0" + "Y\24.W\23.W\23.W\23-V\22-V\22-V\22-V\22*T\16*T\16*T\16""0R\16*T\16*T" + "\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16""0R\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16-V\22" + "-V\22-V\22.W\23.W\23.W\23.W\23""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0" + "Y\24""0Y\24""2Z\15""3[\16/^\20/^\20\202\320q\202\320q3[\16""3[\16""0" + "_\21\0\0\27=\7\27=\7\34:\5\34:\5\34:\5\31""9\13\32""8\2\32""8\2\32""8" + "\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\25""5\6\25""5\6\24""4\5\24""4\5\23""3\3\27""1\12\23""3\3\23""3\3" + "\23""3\3\27""1\12\23""3\3\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\24.\5\24.\5\24.\5\24.\5\24.\5\24.\5\24" + ".\5\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\25""0\10\30""1\1\23""3\3" + "\30""1\1\23""3\3\27""1\12\23""3\3\23""3\3\24""4\5\25""5\6\25""5\6\27" + "7\10\27""7\10\27""7\10\202\320q\202\320q\27""7\10\27""7\10\32""8\2\0" + "\0""7e\17""5d\26""3b\24""3b\24""3b\24""2a\23""2a\23""2a\23""2a\23""0" + "_\21""3[\16""0_\21/^\20""3[\16""3[\16""3[\16/^\20-\\\16""0Y\24""2Z\15" + "2Z\15""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15.W\23.W\23.W\23" + "-V\22-V\22-V\22-V\22*T\16""0R\16*T\16*T\16*T\16""0R\16*T\16""0R\16*T" + "\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16""0" + "R\16*T\16*T\16*T\16""0R\16*T\16*T\16*T\16""0R\16-V\22-V\22-V\22\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374/^\20/^\20/^\20\202\320q\202\320q0_\21""2a\23" + "2a\23\0\0\27=\7\34:\5\27""8\11\34:\5\34:\5\32""8\2\31""9\13\32""8\2\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25" + "5\6\25""5\6\24""4\5\24""4\5\23""3\3\30""1\1\23""3\3\30""1\1\23""3\3\23" + "3\3\27""1\12\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\30""1\1\25""0" + "\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25""0\10\25""0\10\25" + "0\10\25""0\10\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\27""7\10\27""7\10\27""7" + "\10\202\320q\202\320q\27""7\10\31""9\13\32""8\2\0\0""5d\26""3b\24""3" + "b\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""0_\21""0_\21""3[\16/" + "^\20/^\20""3[\16/^\20-\\\16-\\\16""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15" + "0Y\24""2Z\15""0Y\24""0Y\24.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22""0" + "R\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16""0R\16*T\16*T\16*T\16""0R\16" + "*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16" + "*T\16""0R\16-V\22-V\22-V\22-V\22.W\23\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "3[\16/^\20""0_\21\202\320q\202\320q2a\23""2a\23""3b\24\0\0\27=\7\34:" + "\5\27""8\11\34:\5\31""9\13\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\25""5\6" + "\24""4\5\24""4\5\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\27""1" + "\12\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25""0\10\25""0\10\25""0\10\25""0\10\30""1" + "\1\30""1\1\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\27""7\10\27""7\10\27""7\10\202" + "\320q\202\320q\32""8\2\32""8\2\31""9\13\0\0""3b\24""3b\24""3b\24""2a" + "\23""2a\23""2a\23""0_\21""3[\16""0_\21""0_\21""0_\21/^\20""3[\16/^\20" + "/^\20-\\\16""3[\16""2Z\15""0Y\24""0Y\24""2Z\15""2Z\15""0Y\24""2Z\15""2" + "Z\15""0Y\24.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22*T\16*T\16*T\16*T" + "\16*T\16""0R\16*T\16""0R\16*T\16*T\16*T\16*T\16""0R\16*T\16""0R\16*T" + "\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16-V\22-V\22" + "-V\22-V\22.W\23.W\23.W\23\240\264\224\240\264\224\240\264\224\240\264" + "\224\240\264\224\240\264\224\240\264\224\247\273\233\313\326\304\373" + "\375\372\376\377\374\376\377\374\263\303\251\242\266\226/^\20""0_\21" + "0_\21\202\320q\202\320q2a\23""3b\24""3b\24\0\0\34:\5\34:\5\31""9\13\32" + "8\2\31""9\13\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\24""4\5\24""4\5\23""3" + "\3\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\25""0\10\30""1\1\30" + "1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\30""1\1\30""1\1\23""3" + "\3\30""1\1\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3\24""4\5\24""4\5:U" + ",\341\344\340\376\377\374\327\336\323&\77\23\27""7\10\27""7\10\27""7" + "\10\202\320q\202\320q\31""9\13\34:\5\34:\5\0\0""3b\24""3b\24""2a\23""2" + "a\23""2a\23""2a\23""0_\21""0_\21""0_\21""0_\21""3[\16/^\20/^\20/^\20" + "-\\\16""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24" + "2Z\15""0Y\24.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22*T\16*T\16*T\16*" + "T\16*T\16""0R\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16" + "*T\16*T\16""0R\16*T\16*T\16*T\16*T\16""0R\16*T\16-V\22-V\22-V\22-V\22" + ".W\23.W\23.W\23.W\23""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24" + "0Y\24""2Z\15-\\\16-\\\16m\217[\376\377\374\376\377\374\236\257\2123[" + "\16""0_\21""2a\23\202\320q\202\320q3b\24""3b\24""7e\17\0\0\34:\5\34:" + "\5\31""9\13\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\24""4\5\24""4\5\24""4" + "\5\30""1\1\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\30""1\1\30" + "1\1\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25""0\10\25""0\10\25""0\10\30""1\1\25""0\10\30""1\1\25""0\10\30""1" + "\1\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3\23""3\3\24""4\5\24" + "4\5\25""5\6\25""5\6\27""7\10:U,\376\377\374\376\377\374\324\332\317\27" + "7\10\27""7\10\32""8\2\202\320q\202\320q\34:\5\31""9\13\27=\7\0\0""3b" + "\24""3b\24""2a\23""2a\23""2a\23""0_\21""0_\21""3[\16""0_\21/^\20""3[" + "\16/^\20/^\20""3[\16-\\\16""0Y\24""2Z\15""2Z\15""0Y\24""2Z\15""2Z\15" + "0Y\24""2Z\15""0Y\24.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22" + "*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16" + "0R\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16-V\22-V\22-V\22-" + "V\22-V\22.W\23.W\23.W\23""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2" + "Z\15""2Z\15""2Z\15""3[\16-\\\16/^\20""3[\16\222\253\204\376\377\374\376" + "\377\374\366\370\3640_\21""2a\23""2a\23\202\320q\202\320q3b\24""5d\26" + "5d\26\0\0\34:\5\31""9\13\32""8\2\31""9\13\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5" + "\6\24""4\5\24""4\5\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\30" + "1\1\25""0\10\30""1\1\25""0\10\30""1\1\30""1\1\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10" + "\30""1\1\30""1\1\30""1\1\30""1\1\23""3\3\27""1\12\230\242\221\230\242" + "\221\225\245\214\230\242\221\230\242\221\230\242\221\225\245\214\230" + "\242\221\243\256\234\310\317\304\376\377\374\376\377\374\376\377\374" + "\367\371\366\31""9\13\32""8\2\31""9\13\202\320q\202\320q\27""8\11\27" + "=\7\27=\7\0\0""3b\24""2a\23""2a\23""2a\23""0_\21""3[\16""0_\21""0_\21" + "3[\16""3[\16/^\20/^\20""3[\16-\\\16-\\\16""0Y\24""2Z\15""2Z\15""0Y\24" + "2Z\15""0Y\24""2Z\15""0Y\24""2Z\15.W\23.W\23.W\23.W\23-V\22-V\22-V\22" + "-V\22-V\22*T\16*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*" + "T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16-V\22-V\22-V" + "\22-V\22-V\22.W\23.W\23.W\23.W\23""2Z\15""0Y\24""0Y\24""0Y\24\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\336\344\3312a\23""2a\23""3b\24\202\320q\202\320q5d\26""5" + "d\26""7e\17\0\0\32""8\2\31""9\13\32""8\2\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\25""5\6\24""4" + "\5\24""4\5\27""1\12\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3\23" + "3\3\30""1\1\25""0\10\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\25""0" + "\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1" + "\1\25""0\10\23""3\3\23""3\3\30""1\1\23""3\3\27""1\12\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\207\226~\32""8\2\31""9\13\34:\5\202\320q\202\320q\27=\7\30>\10\30" + ">\10\0\0""2a\23""2a\23""2a\23""0_\21""0_\21""3[\16""0_\21/^\20""3[\16" + "/^\20/^\20-\\\16""3[\16-\\\16""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y" + "\24""0Y\24""2Z\15""0Y\24.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22" + "-V\22*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16*" + "T\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0R\16-V\22-V\22-V\22-V\22.W" + "\23.W\23.W\23.W\23""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\311\324\3025d\26""2a\23""3b\24""3b\24\202\320q\202\320q5d\26""7e\17" + "7e\17\0\0\27""8\11\32""8\2\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\25""5\6\24""4\5\24""4" + "\5\23""3\3\30""1\1\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\27""1\12\30" + "1\1\25""0\10\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\25""0\10\30""1\1\23""3" + "\3\30""1\1\23""3\3\27""1\12\23""3\3\27""1\12\23""3\3\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\373\375\372\355\357\353\302\311\276q\204f\35;\6\32""8\2" + "\27""8\11\34:\5\31""9\13\202\320q\202\320q\30>\10\30>\10\32\77\12\0\0" + "2a\23""2a\23""0_\21""0_\21""3[\16""0_\21""3[\16/^\20""3[\16/^\20-\\\16" + "3[\16-\\\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0" + "Y\24""0Y\24.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22*T\16""0" + "R\16*T\16*T\16*T\16""0R\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16" + "*T\16*T\16*T\16*T\16-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23" + "0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""3[\16" + "-\\\16/^\20""3[\16/^\20""3[\16/^\20""0_\21""0_\21""0_\21""2a\23""2a\23" + "3b\24""3b\24""5d\26\202\320q\202\320q7e\17""5d\26""9g\21\0\0\31""9\13" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\25""5\6\25""5\6\24""4\5\24""4\5\23""3\3\27""1\12\30""1\1" + "\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\25""0\10\25""0\10\30""1\1\30" + "1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\30""1\1\30""1\1\25""0\10\23""3\3\23""3\3\30""1" + "\1\23""3\3\23""3\3\30""1\1\23""3\3\24""4\5\24""4\5\25""5\6\25""5\6\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31" + "9\13\32""8\2\31""9\13\34:\5\34:\5\27=\7\202\320q\202\320q\30>\10\32\77" + "\12\32\77\12\0\0""2a\23""0_\21""0_\21""0_\21""0_\21/^\20/^\20/^\20""3" + "[\16-\\\16-\\\16-\\\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y" + "\24""2Z\15""0Y\24""2Z\15.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22" + "-V\22*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16" + "*T\16*T\16""0R\16*T\16""0R\16-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23" + ".W\23.W\23""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2" + "Z\15""0Y\24-\\\16-\\\16/^\20/^\20""3[\16""3[\16""3[\16""0_\21""0_\21" + "0_\21""2a\23""2a\23""3b\24""3b\24""3b\24""7e\17\202\320q\202\320q7e\17" + "9g\21""9g\21\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\25""5\6\24""4\5\23""3\3\23" + "3\3\23""3\3\23""3\3\27""1\12\30""1\1\23""3\3\23""3\3\25""0\10\30""1\1" + "\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\30""1\1\30""1\1\30""1\1\30""1\1\30""1\1\27""1\12" + "\23""3\3\23""3\3\27""1\12\23""3\3\27""1\12\23""3\3\24""4\5\24""4\5\25" + "5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\32""8\2\31""9\13\34:\5\27""8\11\34:\5\27=\7\27=\7\202\320" + "q\202\320q\32\77\12\32\77\12\32\77\12\0\0""0_\21""0_\21""3[\16""0_\21" + "/^\20/^\20""3[\16/^\20""0Y\24-\\\16-\\\16""0Y\24""2Z\15""0Y\24""2Z\15" + "0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24.W\23.W\23.W\23.W\23.W\23-V\22" + "-V\22-V\22-V\22-V\22*T\16*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16*" + "T\16*T\16*T\16*T\16""0R\16*T\16*T\16-V\22-V\22-V\22-V\22-V\22-V\22-V" + "\22.W\23.W\23.W\23.W\23""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0" + "Y\24""2Z\15""0Y\24""2Z\15""3[\16/^\20""3[\16/^\20""3[\16""4c\25\221\252" + "\202\336\344\331\371\373\370\361\363\360\316\327\277p\217V3b\24""3b\24" + "3b\24""5d\26""7e\17\202\320q\202\320q9g\21""5k\24""4j\23\0\0\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5" + "\6\25""5\6\24""4\5\24""4\5\27""1\12\23""3\3\27""1\12\23""3\3\23""3\3" + "\23""3\3\27""1\12\23""3\3\23""3\3\25""0\10\30""1\1\25""0\10\30""1\1\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25/\7\25/\7\25/\7\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1" + "\1\30""1\1\30""1\1\25""0\10\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3" + "\27""1\12\23""3\3\30""1\1\33;\15\216\235\205\331\343\336\371\373\370" + "\356\360\355\252\265\2434H\"\31""9\13\270\306\271\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374|\217p\34:\5\27=" + "\7\27=\7\30>\10\202\320q\202\320q\32\77\12\32\77\12\36B\5\0\0""0_\21" + "3[\16""0_\21""3[\16/^\20""3[\16/^\20-\\\16""3[\16""3[\16""2Z\15""0Y\24" + "0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24.W\23.W\23.W\23" + ".W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22""0R\16*T\16*T\16*T\16*T\16*" + "T\16*T\16*T\16*T\16*T\16""0R\16*T\16""0R\16*T\16-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23""0Y\24""0Y\24""0Y\24""2Z\15" + "0Y\24""0Y\24""0Y\24""3[\16\305\320\276\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\341\347\334\221\252\202\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\371\373\370Nw15d\26""7e\17""7e\17\202\320q\202\320q4j\23""9g\21""4j" + "\23\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10" + "\25""5\6\25""5\6\25""5\6\24""4\5\23""3\3\30""1\1\23""3\3\27""1\12\23" + "3\3\27""1\12\23""3\3\23""3\3\27""1\12\30""1\1\25""0\10\30""1\1\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7" + "\25/\7\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10" + "\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\27""1\12\23""3\3\23""3\3\27" + "1\12\23""3\3\23""3\3\23""3\3\24""4\5]pS\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\373\375\372\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\212\240\206\27=\7\27=\7\30>\10\202\320q\202" + "\320q\32\77\12\32\77\12\32\77\12\0\0""3[\16/^\20/^\20""3[\16/^\20""3" + "[\16-\\\16-\\\16""0Y\24""2Z\15""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""0" + "Y\24""0Y\24""0Y\24""0Y\24.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22*T\16*T\16*T\16*T\16*T\16*T\16""0R\16*T\16*T\16*" + "T\16-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23" + "0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""2Z\15""2Z\15\263\303" + "\251\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\311\321\271" + "\247\273\233\321\334\312\376\377\374\376\377\374\376\377\374\316\331" + "\3077e\17""7e\17""7e\17\202\320q\202\320q5k\24""9g\21""5k\24\0\0\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5\6\25""5\6\25""5" + "\6\24""4\5\30""1\1\23""3\3\27""1\12\23""3\3\27""1\12\23""3\3\23""3\3" + "\27""1\12\27""1\12\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25/\7" + "\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\30" + "1\1\25""0\10\30""1\1\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\27""1\12" + "\23""3\3\23""3\3\24""4\5\24""4\5\341\344\340\376\377\374\376\377\374" + "\371\373\370\252\265\243\252\265\243\370\372\367\376\377\374\376\377" + "\374\376\377\374\216\235\205\31""9\13\32""8\2\31""9\13\252\265\243\376" + "\377\374\376\377\374\352\354\351\30>\10\30>\10\30>\10\202\320q\202\320" + "q\36B\5\32\77\12\36B\5\0\0""0_\21""3[\16/^\20""3[\16""3[\16-\\\16""3" + "[\16""3[\16""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0" + "Y\24""0Y\24""0Y\24.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22*T\16""0R\16*T\16*T\16*T\16*T\16*T\16*T\16-V\22-V\22-" + "V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23""2Z\15""0Y\24" + "2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15\361\363" + "\360\376\377\374\376\377\374\213\241u3[\16/^\20\203\240s\376\377\374" + "\376\377\374\376\377\374Jt.2a\23""2a\23""3b\24b\207G\376\377\374\376" + "\377\374\371\373\3707e\17""5d\26""7f\30\202\320q\202\320q5k\24""9g\21" + "5k\24\0\0\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\25""5\6\25""5" + "\6\24""4\5\24""4\5\24""4\5\27""1\12\23""3\3\23""3\3\23""3\3\30""1\1\23" + "3\3\27""1\12\23""3\3\25""0\10\25""0\10\30""1\1\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25/\7\25/\7\25/\7\25/\7\25/\7\25/\7\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\25" + "0\10\30""1\1\25""0\10\23""3\3\30""1\1\23""3\3\30""1\1\23""3\3\30""1\1" + "\23""3\3\23""3\3\23""3\3\24""4\5\24""4\5\25""5\6\373\375\372\376\377" + "\374\376\377\374:U,\27""7\10\27""7\10:U,\376\377\374\376\377\374\376" + "\377\374\35;\6\31""9\13\34:\5\34:\5""8S*\376\377\374\376\377\374\376" + "\377\374\30>\10\30>\10\32\77\12\202\320q\202\320q\32\77\12\32\77\12\36" + "B\5\0\0/^\20/^\20/^\20""3[\16-\\\16""0Y\24-\\\16""0Y\24""2Z\15""0Y\24" + "0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24.W\23.W\23.W\23" + ".W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22""0R\16*T\16*" + "T\16*T\16*T\16-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23" + ".W\23.W\23.W\23.W\23""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24" + "2Z\15""0Y\24""2Z\15""0Y\24-\\\16\376\377\374\376\377\374\376\377\374" + "Mq23[\16""0_\21Jt.\376\377\374\376\377\374\376\377\3742a\23""2a\23""3" + "b\24""3b\24Nw1\376\377\374\376\377\374\376\377\3747e\17""7f\30""9g\21" + "\202\320q\202\320q5k\24""9g\21""5k\24\0\0\27""7\10\27""7\10\27""7\10" + "\27""7\10\25""5\6\25""5\6\24""4\5\24""4\5\30""1\1\27""1\12\23""3\3\27" + "1\12\23""3\3\27""1\12\23""3\3\23""3\3\27""1\12\30""1\1\25""0\10\25""0" + "\10\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\30""1\1\25""0\10\25""0\10\30""1\1\30""1\1\23""3" + "\3\23""3\3\23""3\3\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3\23""3\3\24" + "4\5\25""5\6\25""5\6\25""5\6\376\377\374\376\377\374\376\377\3744O'\27" + "7\10\27""7\10""5P(\376\377\374\376\377\374\376\377\374\32""8\2\34:\5" + "\34:\5\34:\5""5U%\376\377\374\376\377\374\376\377\374\30>\10\32\77\12" + "\32\77\12\202\320q\202\320q\36B\5\32\77\12\36B\5\0\0""3[\16/^\20/^\20" + "0Y\24-\\\16-\\\16""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0" + "Y\24""0Y\24""0Y\24.W\23.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23""2Z\15""0Y\24" + "2Z\15""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15""3[\16-\\\16""3" + "[\16\376\377\374\376\377\374\376\377\374\261\276\237\242\266\226\242" + "\266\226\261\276\237\376\377\374\376\377\374\376\377\374\244\270\230" + "\247\271\223\244\270\230\247\271\223\255\302\241\376\377\374\376\377" + "\374\376\377\3745d\26""7f\30""5k\24\202\320q\202\320q4j\23""4j\23""5" + "k\24\0\0\27""7\10\27""7\10\25""5\6\25""5\6\25""5\6\24""4\5\24""4\5\23" + "3\3\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\27""1\12\23""3\3\27""1\12" + "\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\25""0\10\30" + "1\1\25""0\10\30""1\1\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3" + "\23""3\3\23""3\3\23""3\3\24""4\5\25""5\6\25""5\6\25""5\6\27""7\10\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\32\77\12\32\77\12\32\77\12\202\320q\202\320q\36B\5\32\77\12" + "\36B\5\0\0""0Y\24/^\20""3[\16-\\\16""3[\16""2Z\15""2Z\15""2Z\15""2Z\15" + "0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24.W\23.W\23.W\23.W\23." + "W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23" + ".W\23""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15" + "2Z\15""0Y\24-\\\16""3[\16-\\\16/^\20\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\3747f\30""5k\24""9g\21\202" + "\320q\202\320q5k\24""4j\23""9g\21\0\0\27""7\10\25""5\6\25""5\6\25""5" + "\6\24""4\5\24""4\5\30""1\1\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\30" + "1\1\23""3\3\27""1\12\23""3\3\30""1\1\25""0\10\25""0\10\30""1\1\30""1" + "\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\30" + "1\1\25""0\10\30""1\1\30""1\1\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3" + "\23""3\3\23""3\3\23""3\3\30""1\1\24""4\5\24""4\5\24""4\5\25""5\6\25""5" + "\6\27""7\10\27""7\10\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\32\77\12\36B\5\32\77\12\202\320q\202" + "\320q\36B\5\32\77\12\32\77\12\0\0-\\\16-\\\16""3[\16""2Z\15""0Y\24""2" + "Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24." + "W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23" + ".W\23.W\23.W\23.W\23.W\23""2Z\15""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2" + "Z\15""0Y\24""2Z\15""2Z\15""2Z\15""0Y\24-\\\16""3[\16/^\20""3[\16\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\3747f\30""4j\23""9g\21\202\320q\202\320q9g\21""9g\21""9g\21\0\0" + "\25""5\6\25""5\6\24""4\5\24""4\5\24""4\5\27""1\12\23""3\3\27""1\12\30" + "1\1\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\25""0\10\30""1\1\25""0\10" + "\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\30""1\1\30""1\1\23""3\3" + "\23""3\3\27""1\12\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\24""4\5\24" + "4\5\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\32""8\2\31""9\13\34:" + "\5\34:\5\27""8\11\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\32" + "\77\12\32\77\12\202\320q\202\320q\32\77\12\32\77\12\32\77\12\0\0-\\\16" + "2Z\15""0Y\24""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24" + "0Y\24""0Y\24.W\23.W\23.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-" + "V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22.W\23""2Z\15.W\23.W\23.W\23""2Z\15""0Y\24""2Z\15""0Y\24" + "0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15-\\\16""0Y\24-\\\16""3" + "[\16/^\20/^\20""3[\16/^\20""3[\16""0_\21""3[\16""0_\21""2a\23""2a\23" + "2a\23""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""7e\17""7e\17""5d\26" + "9g\21""4j\23""5k\24""9g\21\202\320q\202\320q4j\23""9g\21""5k\24\0\0\25" + "5\6\24""4\5\24""4\5\24""4\5\23""3\3\23""3\3\27""1\12\30""1\1\23""3\3" + "\23""3\3\27""1\12\23""3\3\23""3\3\25""0\10\30""1\1\30""1\1\30""1\1\30" + "1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30" + "1\1\30""1\1\30""1\1\30""1\1\30""1\1\30""1\1\23""3\3\23""3\3\23""3\3\27" + "1\12\30""1\1\23""3\3\23""3\3\27""1\12\24""4\5\24""4\5\25""5\6\25""5\6" + "\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\31""9\13\31""9\13\32""8\2\27""8\11\34:\5\31""9" + "\13\27=\7\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5" + "\32\77\12\202\320q\202\320q\32\77\12\32\77\12\36B\5\0\0-\\\16""0Y\24" + "2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24" + "2Z\15.W\23""2Z\15.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-" + "V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + ".W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""0Y\24""2Z\15""2Z\15""0Y\24""0" + "Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24-\\\16""3[\16/^\20""3[" + "\16/^\20""3[\16""3[\16""0_\21""3[\16""0_\21""0_\21""2a\23""2a\23""2a" + "\23""2a\23""3b\24""3b\24""3b\24""5d\26""5d\26""7e\17""7e\17""7e\17""7" + "f\30""9g\21""9g\21""5k\24""9g\21\202\320q\202\320q4j\23""9g\21""5k\24" + "\0\0\25""5\6\24""4\5\24""4\5\23""3\3\30""1\1\23""3\3\23""3\3\23""3\3" + "\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\25""0\10\30""1\1\30""1\1\25" + "0\10\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\25" + "0\10\25""0\10\30""1\1\25""0\10\25""0\10\23""3\3\30""1\1\23""3\3\23""3" + "\3\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3\24""4\5\24""4\5\24""4\5\25" + "5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\32""8\2\27""8\11q\204f\304\313\300\356\360\355" + "\373\375\372\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\32\77\12\32\77\12\36B\5\202" + "\320q\202\320q\36B\5\32\77\12\32\77\12\0\0""0Y\24""2Z\15""0Y\24""0Y\24" + "0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15.W\23.W\23.W\23" + ".W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23" + ".W\23""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24" + "0Y\24""2Z\15""2Z\15""3[\16-\\\16/^\20""3[\16/^\20""0Y\24""3[\16""0_\21" + "3[\16""0_\21""0_\21""2a\23""5d\26\311\321\271\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\3749g\21""5k\24""4j" + "\23\202\320q\202\320q4j\23""9g\21""4j\23\0\0\24""4\5\27""1\12\23""3\3" + "\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3\23""3\3\30""1\1\23""3\3\30" + "1\1\25""0\10\30""1\1\25""0\10\30""1\1\30""1\1\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\27""1" + "\12\23""3\3\23""3\3\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3" + "\27""1\12\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\210" + "\227\177\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\32\77\12\32\77\12\36B\5\202\320q\202\320" + "q\32\77\12\32\77\12\36B\5\0\0""2Z\15""0Y\24""2Z\15""2Z\15""0Y\24""0Y" + "\24""0Y\24""2Z\15""0Y\24""0Y\24.W\23.W\23.W\23.W\23.W\23.W\23.W\23-V" + "\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""0" + "Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""2Z\15""3" + "[\16-\\\16-\\\16/^\20/^\20/^\20/^\20""3[\16""0_\21""3[\16""0_\21""3[" + "\16""2a\23""2a\23\336\344\331\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\3744j\23""9g\21""4j\23\202" + "\320q\202\320q9g\21""4j\23""4j\23\0\0\23""3\3\30""1\1\23""3\3\23""3\3" + "\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\25""0\10\30""1\1\25" + "0\10\30""1\1\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\30" + "1\1\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\27""1\12\23""3\3\30""1" + "\1\23""3\3\30""1\1\23""3\3\27""1\12\23""3\3\27""1\12\23""3\3\24""4\5" + "\24""4\5\24""4\5\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\367\371" + "\366\376\377\374\376\377\374\376\377\374\306\315\302\236\261\235\236" + "\261\235\230\247\216\231\250\217\231\250\217\231\250\217\231\250\217" + "\232\251\220\231\250\217\32\77\12\32\77\12\32\77\12\202\320q\202\320" + "q\32\77\12\32\77\12\32\77\12\0\0""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0" + "Y\24""0Y\24""0Y\24""2Z\15""0Y\24.W\23.W\23""2Z\15.W\23.W\23.W\23-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""2Z\15""0Y" + "\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""2" + "Z\15""0Y\24-\\\16/^\20""3[\16/^\20/^\20/^\20""3[\16""0_\21""0_\21""0" + "_\21""0_\21""2a\23""2a\23\366\370\364\376\377\374\376\377\374\222\253" + "\2045d\26""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21""7f\30""4j\23""9" + "g\21""5k\24""9g\21""4j\23\202\320q\202\320q9g\21""4j\23""9g\21\0\0\27" + "1\12\23""3\3\30""1\1\23""3\3\23""3\3\27""1\12\27""1\12\23""3\3\23""3" + "\3\25""0\10\30""1\1\30""1\1\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\30""1\1\25""0\10\25""0\10\30""1\1\30""1\1\30""1\1\25""0" + "\10\23""3\3\23""3\3\23""3\3\27""1\12\23""3\3\27""1\12\27""1\12\23""3" + "\3\30""1\1\30""1\1\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32" + "8\2\32""8\2\31""9\13\321\327\314\376\377\374\376\377\374\10\30>\10\32\77\12\32\77\12\32\77\12\36B\5\32\77" + "\12\32\77\12\32\77\12\202\320q\202\320q\32\77\12\32\77\12\32\77\12\0" + "\0""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24.W\23.W\23" + ".W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23" + ".W\23.W\23.W\23""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y" + "\24""0Y\24""2Z\15""0Y\24-\\\16-\\\16""0Y\24/^\20""3[\16/^\20""3[\16/" + "^\20""0_\21""3[\16""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23\227\260" + "\210\376\377\374\376\377\374r\224`5d\26""5d\26""5d\26""5d\26""7e\17""5" + "d\26""9g\21""9g\21""4j\23""4j\23""9g\21""5k\24""9g\21\202\320q\202\320" + "q5k\24""9g\21""5k\24\0\0\27""1\12\23""3\3\23""3\3\27""1\12\23""3\3\27" + "1\12\23""3\3\30""1\1\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\25""0\10\30""1\1\25""0" + "\10\30""1\1\25""0\10\23""3\3\30""1\1\23""3\3\27""1\12\23""3\3\23""3\3" + "\27""1\12\23""3\3\23""3\3\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25" + "5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\32""8\2\32""8\2\31""9\13\31""9\13\"B\24\327\336\323\376" + "\377\374\345\347\344@[2\27=\7\27=\7\30>\10\30>\10\32\77\12\32\77\12\32" + "\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\202\320q\202\320" + "q\32\77\12\36B\5\32\77\12\0\0""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y" + "\24""0Y\24.W\23.W\23.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + ".W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0" + "Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""2Z\15""0Y\24-\\\16/^" + "\20""3[\16/^\20/^\20""3[\16""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23" + "2a\23""2a\23""3b\24\244\270\230\266\304\244\376\377\374\376\377\374\373" + "\375\372\316\331\307\254\300\237\244\270\230\242\273\223\247\271\223" + "\247\271\223\243\274\224\247\271\223\243\274\2244j\23""9g\21""9g\21\202" + "\320q\202\320q9g\21""4j\23""4j\23\0\0\23""3\3\30""1\1\27""1\12\23""3" + "\3\23""3\3\27""1\12\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\30""1\1" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\30""1\1\30""1" + "\1\30""1\1\30""1\1\27""1\12\23""3\3\23""3\3\23""3\3\27""1\12\23""3\3" + "\23""3\3\23""3\3\23""3\3\23""3\3\27""1\12\24""4\5\24""4\5\24""4\5\25" + "5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\31""9\13\34:\5\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\36B\5\32\77\12\32\77\12\202\320q\202\320q\32" + "\77\12\32\77\12\36B\5\0\0""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24." + "W\23.W\23.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23" + ".W\23.W\23.W\23""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z" + "\15""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""3[\16/^\20/^\20" + "/^\20""3[\16/^\20""0_\21""3[\16""0_\21""0_\21""3[\16""2a\23""2a\23""2" + "a\23""2a\23""3b\24\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\3744j\23""5k\24""9g\21\202" + "\320q\202\320q5k\24""9g\21""4j\23\0\0\27""1\12\23""3\3\30""1\1\23""3" + "\3\27""1\12\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\25""0\10" + "\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\25""0\10\30""1\1\30""1" + "\1\30""1\1\27""1\12\23""3\3\23""3\3\27""1\12\23""3\3\27""1\12\23""3\3" + "\23""3\3\30""1\1\23""3\3\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5" + "\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\32""8\2\31""9\13\32""8\2\31""9\13\34:\5\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\32\77\12\36B\5\32\77\12\202\320q\202\320q\32" + "\77\12\32\77\12\32\77\12\0\0""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24.W\23" + ".W\23.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23" + ".W\23.W\23.W\23""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z" + "\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""3[\16-\\\16/^\20/^\20""3[\16" + "/^\20/^\20""3[\16""0_\21""0_\21""3[\16""0_\21""2a\23""2a\23""2a\23""2" + "a\23""3b\24""3b\24\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\3744j\23""5k\24""9g\21\202" + "\320q\202\320q4j\23""9g\21""5k\24\0\0\23""3\3\23""3\3\23""3\3\27""1\12" + "\25""0\10\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\25""0" + "\10\23""3\3\23""3\3\30""1\1\23""3\3\30""1\1\23""3\3\23""3\3\23""3\3\27" + "1\12\23""3\3\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\31""9\13\32""8\2\32""8\2\34:\5\34:\5\31""9\13\34:\5\27=" + "\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\202\320q\202\320" + "q\36B\5\32\77\12\32\77\12\0\0""0Y\24""2Z\15""0Y\24.W\23.W\23.W\23.W\23" + ".W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23.W\23" + "0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24" + "2Z\15""2Z\15""0Y\24""0Y\24""3[\16-\\\16/^\20/^\20/^\20""3[\16/^\20/^" + "\20""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""3b\24""3" + "b\24""3b\24""3b\24""7e\17""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21""9" + "g\21""4j\23""9g\21""9g\21""5k\24""5k\24""9g\21""4j\23""9g\21\202\320" + "q\202\320q4j\23""5k\24""4j\23\0\0\23""3\3\30""1\1\30""1\1\25""0\10\30" + "1\1\25""0\10\30""1\1\25""0\10\25""0\10\30""1\1\30""1\1\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\25" + "0\10\30""1\1\30""1\1\30""1\1\30""1\1\30""1\1\25""0\10\23""3\3\27""1\12" + "\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3\30""1\1\27""1\12\23""3\3\23" + "3\3\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31""9" + "\13\32""8\2\32""8\2\31""9\13\31""9\13\34:\5\34:\5\27""8\11\27=\7\27=" + "\7\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\32\77\12\36B\5\32\77\12\36B\5\32\77\12\202\320q\202\320q\32\77\12" + "\32\77\12\36B\5\0\0""2Z\15""0Y\24.W\23.W\23.W\23.W\23.W\23.W\23.W\23" + ".W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""0Y\24" + "0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""2Z\15" + "2Z\15""0Y\24-\\\16""0Y\24/^\20/^\20""3[\16/^\20""3[\16/^\20/^\20""0_" + "\21""0_\21""0_\21""3[\16""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3" + "b\24""5d\26""5d\26""7e\17""5d\26W\201:\210\245w\231\262\213\247\271\223" + "Cr$5k\24""4j\23""4j\23""9g\21""5k\24""5k\24""4j\23""4j\23\202\320q\202" + "\320q9g\21""4j\23""5k\24\0\0\23""3\3\23""3\3\30""1\1\25""0\10\30""1\1" + "\30""1\1\30""1\1\25""0\10\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\25" + "0\10\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\27""1\12\23""3\3\23""3" + "\3\30""1\1\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\30""1\1\24""4\5\24" + "4\5\24""4\5\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\31" + "9\13\32""8\2\31""9\13\34:\5\27""8\11\34:\5\34:\5\27=\7\27=\7C^5\313\321" + "\306\376\377\374\376\377\374\376\377\374\376\377\3747W(r\212e\376\377" + "\374\376\377\374\341\347\334\33A\14\32\77\12\36B\5\32\77\12\202\320q" + "\202\320q\32\77\12\32\77\12\36B\5\0\0""0Y\24.W\23.W\23.W\23.W\23.W\23" + ".W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23.W\23""2" + "Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""2Z\15""0Y\24""0Y\24""0" + "Y\24""0Y\24""0Y\24-\\\16""3[\16-\\\16""3[\16/^\20""3[\16/^\20""3[\16" + "/^\20""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""3b\24" + "3b\24""3b\24""3b\24""3b\24""5d\26c\210H\366\370\364\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374Nw1Cr$\364\367\363\376\377\374" + "\376\377\374h\214L4j\23""5k\24""9g\21\202\320q\202\320q9g\21""4j\23""9" + "g\21\0\0\30""1\1\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\30""1\1\25" + "0\10\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\25""0\10\30""1" + "\1\25""0\10\23""3\3\23""3\3\27""1\12\30""1\1\27""1\12\23""3\3\23""3\3" + "\23""3\3\23""3\3\27""1\12\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25" + "5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\31""9\13\32""8\2\31""9\13\32""8\2\27""8\11\34" + ":\5\27""8\11\34:\5\34:\5'E\20\350\352\347\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\3747W(\32\77\12\262\275\253" + "\376\377\374\376\377\374\217\245\213\36B\5\32\77\12\32\77\12\202\320" + "q\202\320q\32\77\12\36B\5\32\77\12\0\0.W\23.W\23.W\23.W\23.W\23.W\23" + ".W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""2" + "Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""2Z\15""0Y\24""0Y\24""2" + "Z\15""0Y\24""0Y\24-\\\16-\\\16-\\\16""3[\16/^\20""3[\16/^\20/^\20/^\20" + "0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24" + "3b\24""3b\24""5d\26\221\247{\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374N}/9g\21\210\243p\376\377" + "\374\376\377\374\316\327\2779g\21""4j\23""9g\21\202\320q\202\320q5k\24" + "5k\24""4j\23\0\0\30""1\1\25""0\10\30""1\1\30""1\1\30""1\1\25""0\10\30" + "1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\30""1\1\25""0" + "\10\25""0\10\23""3\3\23""3\3\23""3\3\27""1\12\23""3\3\27""1\12\30""1" + "\1\23""3\3\23""3\3\23""3\3\23""3\3\24""4\5\24""4\5\24""4\5\25""5\6\25" + "5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\31""9\13\32""8\2\31""9\13\32""8\2\32""8\2\34:" + "\5\27""8\11\34:\5\34:\5\27=\7\310\317\304\376\377\374\376\377\374\324" + "\332\3173S$\376\377\374\376\377\374\376\377\3747W(\36B\5Ok@\376\377\374" + "\376\377\374\347\351\346\36B\5\32\77\12\32\77\12\202\320q\202\320q\32" + "\77\12\36B\5\32\77\12\0\0.W\23.W\23.W\23.W\23.W\23.W\23.W\23-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23" + ".W\23.W\23.W\23.W\23.W\23.W\23""2Z\15.W\23""0Y\24""0Y\24""2Z\15""0Y\24" + "0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15" + "3[\16-\\\16-\\\16""3[\16/^\20""3[\16/^\20/^\20/^\20""0_\21""0_\21""0" + "_\21""0_\21""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""5" + "d\26""5d\26\360\362\357\376\377\374\376\377\374s\222Y7e\17\376\377\374" + "\376\377\374\376\377\374V\17794j\23V\1779\376\377\374\376\377\374\370" + "\372\3675k\24""9g\21""5k\24\202\320q\202\320q9g\21""5k\24""9g\21\0\0" + "\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\25""0\10\25" + "0\10\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\23""3\3\23""3\3\23""3\3" + "\23""3\3\30""1\1\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3\30""1\1\24""4" + "\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\31""9\13\32""8\2\32""8\2\31""9\13\34:\5\27""8\11\34:\5\34:\5\27=" + "\7\27=\7\372\374\371\376\377\374\376\377\3749Y)\32\77\12\376\377\374" + "\376\377\374\376\377\3747W(\32\77\12\77_/\376\377\374\376\377\374\371" + "\373\370\32\77\12\32\77\12\36B\5\202\320q\202\320q\32\77\12\32\77\12" + "\32\77\12\0\0.W\23.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23" + ".W\23.W\23.W\23.W\23""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15" + "0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15""2Z\15""0Y\24-\\\16-\\\16""3" + "[\16/^\20/^\20/^\20""3[\16""3[\16""0_\21""0_\21""0_\21""0_\21""3[\16" + "2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""7e\17""5d\26" + "5d\26\361\363\360\376\377\374\376\377\374d\211I9g\21\376\377\374\376" + "\377\374\376\377\374N}/4j\23|\234b\376\377\374\376\377\374\355\357\353" + "5k\24""9g\21""4j\23\202\320q\202\320q5k\24""9g\21""5k\24\0\0\30""1\1" + "\25""0\10\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\25""0\10\30""1" + "\1\30""1\1\25""0\10\30""1\1\25""0\10\27""1\12\23""3\3\27""1\12\23""3" + "\3\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\30""1\1\24" + "4\5\24""4\5\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\31" + "9\13\32""8\2\27""8\11\32""8\2\34:\5\31""9\13\27""8\11\34:\5\27=\7\27" + "=\7\27=\7\321\327\314\376\377\374\376\377\374\236\261\235\32\77\12\376" + "\377\374\376\377\374\376\377\3747V\40\40E\20\324\332\317\376\377\374" + "\376\377\374\313\321\306\36B\5\32\77\12\32\77\12\202\320q\202\320q\32" + "\77\12\32\77\12\32\77\12\0\0.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23" + ".W\23.W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24" + "0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""3[\16" + "0Y\24-\\\16/^\20/^\20""3[\16/^\20""3[\16/^\20""0_\21""0_\21""0_\21""0" + "_\21""2a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""7" + "e\17""5d\26""5d\26\240\271\221\376\377\374\376\377\374\376\377\374\261" + "\306\245\376\377\374\376\377\374\376\377\374\240\271\221\341\347\334" + "\376\377\374\376\377\374\376\377\374\233\264\2155k\24""4j\23""9g\21\202" + "\320q\202\320q4j\23""9g\21""4j\23\0\0\30""1\1\30""1\1\30""1\1\25""0\10" + "\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\25" + "0\10\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\25""0" + "\10\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\27""1\12\23""3\3" + "\27""1\12\23""3\3\23""3\3\27""1\12\24""4\5\24""4\5\24""4\5\25""5\6\25" + "5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\31""9\13\31""9\13\31" + "9\13\34:\5\34:\5\27""8\11\27=\7\27=\7\27=\7\27=\7""9Y)\373\375\372\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\372\374\3717V\40\32" + "\77\12\32\77\12\32\77\12\202\320q\202\320q\32\77\12\32\77\12\32\77\12" + "\0\0.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23" + "0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24" + "0Y\24""2Z\15""2Z\15""0Y\24""3[\16-\\\16-\\\16""3[\16/^\20""0Y\24""3[" + "\16/^\20/^\20""0_\21""0_\21""0_\21""3[\16""0_\21""0_\21""2a\23""2a\23" + "2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""7e\17""5d\26""7e\17""5d\26" + "5d\26\231\262\213\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\232\261\2049g\21""9g\21""4j\23""9g\21\202\320q\202\320q5k\24""9g\21" + "9g\21\0\0\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1\1\30""1\1\25""0" + "\10\30""1\1\30""1\1\25""0\10\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3" + "\30""1\1\23""3\3\30""1\1\23""3\3\30""1\1\23""3\3\23""3\3\24""4\5\30""1" + "\1\24""4\5\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8" + "\2\32""8\2\31""9\13\32""8\2\27""8\11\34:\5\27""8\11\34:\5\27=\7\27=\7" + "\27=\7\27=\7\27=\7\30>\10\32\77\12\234\253\222\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\234\253\222\36B\5\32\77\12\32\77\12\36B\5\32\77\12\202\320q\202" + "\320q\36B\5\32\77\12\32\77\12\0\0.W\23.W\23.W\23.W\23-V\22-V\22-V\22" + "-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22.W\23.W\23.W\23.W\23" + ".W\23.W\23.W\23.W\23.W\23""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""2" + "Z\15""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""2Z\15-\\\16""0Y\24-\\" + "\16""3[\16""3[\16/^\20/^\20""3[\16/^\20""0_\21""0_\21""0_\21""0_\21""0" + "_\21""0_\21""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""5" + "d\26""7e\17""5d\26""5d\26""5d\26""5d\26""7e\17""9g\21c\210H\264\310\247" + "\345\354\341\372\374\371\372\374\371\345\354\341\266\304\244`\214J5k" + "\24""4j\23""4j\23""5k\24""9g\21""4j\23\202\320q\202\320q4j\23""5k\24" + "9g\21\0\0\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10" + "\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\25""0\10\30""1" + "\1\30""1\1\25""0\10\23""3\3\23""3\3\30""1\1\23""3\3\27""1\12\23""3\3" + "\27""1\12\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\24""4\5\24""4\5\25" + "5\6\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\32" + "8\2\31""9\13\32""8\2\31""9\13\34:\5\31""9\13\34:\5\27""8\11\27=\7\27" + "=\7\35;\6\27=\7\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12Nj\77" + "\32\77\12\36B\5\32\77\12\202\320q\202\320q\32\77\12\36B\5\32\77\12\0" + "\0.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-V\22-" + "V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23.W\23""2Z\15.W\23""0Y\24""0Y\24" + "2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24" + "2Z\15""2Z\15""2Z\15-\\\16""3[\16-\\\16/^\20""3[\16/^\20""3[\16/^\20/" + "^\20/^\20""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2" + "a\23""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26p\217V5d\26""5d\26""7e" + "\17""5d\26""7e\17""9g\21""9g\21""9g\21""5k\24""9g\21""5k\24""9g\21""4" + "j\23""9g\21""4j\23c\210H\363\365\3629g\21""4j\23""4j\23\202\320q\202" + "\320q9g\21""5k\24""9g\21\0\0\30""1\1\25""0\10\30""1\1\25""0\10\25""0" + "\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\25" + "0\10\25""0\10\30""1\1\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\30""1" + "\1\30""1\1\25""0\10\30""1\1\27""1\12\23""3\3\27""1\12\23""3\3\30""1\1" + "\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\23""3\3\30""1\1\24""4\5\24""4" + "\5\25""5\6\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8" + "\2\31""9\13\31""9\13\32""8\2\31""9\13\27""8\11\34:\5\34:\5\34:\5\27=" + "\7\27=\7\367\371\366QpJ\30>\10\30>\10\30>\10\32\77\12\32\77\12\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12Ef" + "5\360\362\357\376\377\374\32\77\12\32\77\12\36B\5\202\320q\202\320q\32" + "\77\12\32\77\12\32\77\12\0\0.W\23.W\23.W\23""2Z\15-V\22-V\22-V\22-V\22" + "-V\22-V\22-V\22.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23" + ".W\23""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15" + "0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15-\\\16""3[\16""0Y\24/^\20""3" + "[\16/^\20""0Y\24""3[\16/^\20""0_\21""0_\21""0_\21""0_\21""0_\21""0_\21" + "2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""5d\26""7e\17" + "5d\26\376\377\374\367\371\366d\211I7e\17""5d\26""7f\30""9g\21""9g\21" + "5k\24""9g\21""5k\24""9g\21""5k\24""9g\21[\205>\363\362\351\376\377\374" + "\376\377\3749g\21""5k\24""4j\23\202\320q\202\320q4j\23""5k\24""4j\23" + "\0\0\30""1\1\25""0\10\30""1\1\30""1\1\25""0\10\25""0\10\25""0\10\25""0" + "\10\25""0\10\25""0\10\30""1\1\30""1\1\30""1\1\30""1\1\25""0\10\30""1" + "\1\25""0\10\30""1\1\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1" + "\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3\23""3\3\27""1\12\23""3\3\27" + "1\12\23""3\3\24""4\5\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\31""9\13\32""8\2\34:" + "\5\27""8\11\34:\5\34:\5\34:\5\27=\7\27=\7\27=\7\376\377\374\376\377\374" + "\363\365\362Lh=\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12" + "\32\77\12\32\77\12\32\77\12\77_/\355\357\353\376\377\374\376\377\374" + "\376\377\374\32\77\12\36B\5\32\77\12\202\320q\202\320q\36B\5\32\77\12" + "\36B\5\0\0.W\23.W\23.W\23.W\23.W\23-V\22-V\22-V\22-V\22.W\23.W\23.W\23" + ".W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""2Z\15""0Y" + "\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2" + "Z\15""2Z\15""0Y\24""3[\16""3[\16-\\\16""3[\16/^\20""3[\16/^\20""3[\16" + "3[\16""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23" + "2a\23""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""5d\26\376\377" + "\374\376\377\374\376\377\374\364\367\363b\207G9g\21""7f\30""5k\24""9" + "g\21""9g\21""4j\23""9g\21V\1779\355\357\353\376\377\374\376\377\374\376" + "\377\374\376\377\3745k\24""4j\23""4j\23\202\320q\202\320q9g\21""5k\24" + "5k\24\0\0\25""0\10\25""0\10\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1" + "\25""0\10\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\25""0\10\25""0\10" + "\30""1\1\30""1\1\30""1\1\30""1\1\25""0\10\23""3\3\27""1\12\23""3\3\23" + "3\3\23""3\3\23""3\3\27""1\12\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3" + "\27""1\12\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\32""8\2\31""9\13\32""8\2\31""9\13\34:\5\34:\5" + "\27""8\11\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\363\365\362\376\377\374" + "\376\377\374\376\377\374\360\362\357C^5\32\77\12\32\77\12\32\77\12\32" + "\77\12\36B\5;[+\337\351\344\376\377\374\376\377\374\376\377\374\376\377" + "\374\270\303\261\36B\5\32\77\12\36B\5\202\320q\202\320q\32\77\12\32\77" + "\12\36B\5\0\0.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23""2Z\15.W\23.W\23" + ".W\23.W\23.W\23.W\23.W\23""2Z\15.W\23.W\23.W\23""0Y\24""0Y\24""0Y\24" + "0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""2Z\15""0Y\24""0Y\24" + "0Y\24""2Z\15""0Y\24-\\\16""3[\16-\\\16/^\20/^\20""3[\16/^\20/^\20""3" + "[\16/^\20""3[\16""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""2" + "a\23""3b\24""3b\24""3b\24""3b\24""7e\17""5d\26""5d\26""7e\17""7e\17h" + "\214L\370\372\367\376\377\374\376\377\374\376\377\374\360\362\357Y\203" + "<9g\21""4j\23""9g\21T{/\347\356\343\376\377\374\376\377\374\376\377\374" + "\376\377\374\303\323\271@m\30""9g\21""5k\24""4j\23\202\320q\202\320q" + "4j\23""9g\21""4j\23\0\0\25""0\10\30""1\1\25""0\10\30""1\1\30""1\1\25" + "0\10\30""1\1\30""1\1\30""1\1\30""1\1\25""0\10\25""0\10\30""1\1\30""1" + "\1\30""1\1\25""0\10\30""1\1\25""0\10\30""1\1\27""1\12\23""3\3\23""3\3" + "\23""3\3\27""1\12\23""3\3\27""1\12\23""3\3\23""3\3\27""1\12\23""3\3\23" + "3\3\30""1\1\23""3\3\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\32""8\2\32""8\2\31""9\13\32""8\2\34:\5\34:\5\34" + ":\5\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10YpL\367\371\366" + "\376\377\374\376\377\374\376\377\374\355\357\353\77_/\32\77\12""7V\40" + "\337\351\344\376\377\374\376\377\374\376\377\374\376\377\374\277\313" + "\270\40E\20\32\77\12\36B\5\32\77\12\32\77\12\202\320q\202\320q\32\77" + "\12\32\77\12\36B\5\0\0.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23." + "W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""0Y\24""2Z\15""0" + "Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0" + "Y\24""0Y\24""0Y\24""2Z\15-\\\16-\\\16""3[\16/^\20/^\20""3[\16/^\20/^" + "\20/^\20""0_\21""0_\21""0_\21""0_\21""0_\21""3[\16""2a\23""2a\23""2a" + "\23""2a\23""3b\24""3b\24""3b\24""3b\24""7e\17""7e\17""5d\26""7e\17""7" + "e\17""5d\26""7e\17""7e\17s\222Y\371\373\370\376\377\374\376\377\374\376" + "\377\374\352\361\346j\217N\344\353\340\376\377\374\376\377\374\376\377" + "\374\376\377\374\313\326\304@m\30""9g\21""5k\24""9g\21""4j\23""4j\23" + "\202\320q\202\320q4j\23""9g\21""4j\23\0\0\30""1\1\30""1\1\25""0\10\30" + "1\1\30""1\1\25""0\10\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\30""1\1" + "\25""0\10\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\23""3\3\23" + "3\3\23""3\3\23""3\3\30""1\1\30""1\1\23""3\3\30""1\1\23""3\3\23""3\3\23" + "3\3\23""3\3\24""4\5\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\32""8\2\31""9\13\31""9" + "\13\34:\5\31""9\13\34:\5\31""9\13\27=\7\27=\7\27=\7\27=\7\30>\10\30>" + "\10\35;\6\32\77\12\32\77\12d{V\372\374\371\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\304\322\305\"H\22\32\77\12\36B\5\32\77\12\32\77\12\36B\5\32\77\12\202" + "\320q\202\320q\32\77\12\32\77\12\36B\5\0\0.W\23.W\23.W\23.W\23.W\23." + "W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""0Y\24" + "0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15" + "0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""3[\16-\\\16""3[\16-\\\16""3[\16/^" + "\20/^\20/^\20/^\20""3[\16""0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2" + "a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5" + "d\26""7e\17""7e\17""7e\17""5d\26""7e\17""9g\21""7f\30""4j\23|\234b\373" + "\375\372\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\321\334\312Cr$4j\23""9g\21""4j\23""5k\24""9g\21""4j\23""9" + "g\21\202\320q\202\320q4j\23""4j\23""9g\21\0\0\30""1\1\25""0\10\30""1" + "\1\30""1\1\30""1\1\30""1\1\30""1\1\30""1\1\25""0\10\30""1\1\30""1\1\30" + "1\1\25""0\10\30""1\1\30""1\1\23""3\3\27""1\12\23""3\3\27""1\12\23""3" + "\3\23""3\3\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3\23""3\3\23""3\3\23" + "3\3\27""1\12\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\31""9\13\32""8\2\32""8\2\32""8\2\34:\5" + "\27""8\11\34:\5\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30" + ">\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12m\204_\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\321\327\314'E\20\32\77\12" + "\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\202\320" + "q\202\320q\32\77\12\32\77\12\36B\5\0\0.W\23.W\23.W\23.W\23.W\23.W\23" + ".W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23""0Y\24""0Y\24""2Z\15""0" + "Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0" + "Y\24""2Z\15""0Y\24""0Y\24-\\\16-\\\16-\\\16/^\20/^\20""0Y\24/^\20/^\20" + "/^\20/^\20/^\20""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a" + "\23""2a\23""3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""7e\17""5d\26""5" + "d\26""7e\17""7e\17""5d\26\247\271\223\247\271\223\247\271\223\243\274" + "\224\243\274\224\243\274\224\341\347\334\376\377\374\376\377\374\376" + "\377\374\376\377\374\261\306\245\243\274\224\247\271\223\243\274\224" + "\247\271\223\243\274\224\243\274\2244j\23""9g\21""4j\23\202\320q\202" + "\320q9g\21""4j\23""4j\23\0\0\25""0\10\25""0\10\30""1\1\30""1\1\30""1" + "\1\25""0\10\30""1\1\25""0\10\25""0\10\30""1\1\30""1\1\25""0\10\25""0" + "\10\30""1\1\30""1\1\23""3\3\23""3\3\23""3\3\30""1\1\23""3\3\27""1\12" + "\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\27""1\12\24""4\5\24" + "4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\27""7\10\27""7\10\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\32""8\2\32""8\2\31""9\13\32""8\2\27""8\11\34:\5\34:\5\31" + "9\13\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77\12\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\32\77\12\32\77\12\32\77\12\202\320q\202\320q\32\77\12\36B\5" + "\32\77\12\0\0.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23.W\23" + ".W\23.W\23""2Z\15""0Y\24""2Z\15""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0" + "Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""2Z\15-\\\16""3" + "[\16-\\\16-\\\16""3[\16/^\20""3[\16/^\20/^\20/^\20/^\20""0_\21""0_\21" + "0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24" + "3b\24""3b\24""5d\26""7e\17""5d\26""7e\17""7e\17""5d\26""5d\26""9g\21" + "7f\30\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\3749g\21""4j\23""9g\21\202\320q\202\320q9g\21""4j\23""9" + "g\21\0\0\25""0\10\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\30""1\1" + "\25""0\10\30""1\1\30""1\1\30""1\1\30""1\1\27""1\12\23""3\3\23""3\3\23" + "3\3\23""3\3\23""3\3\27""1\12\23""3\3\30""1\1\23""3\3\27""1\12\30""1\1" + "\23""3\3\23""3\3\23""3\3\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5" + "\6\25""5\6\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\32""8\2\32""8\2\31""9" + "\13\32""8\2\31""9\13\34:\5\27""8\11\34:\5\27""8\11\27=\7\27=\7\27=\7" + "\30>\10\35;\6\30>\10\30>\10\32\77\12\32\77\12\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\32\77\12\36" + "B\5\32\77\12\202\320q\202\320q\32\77\12\36B\5\32\77\12\0\0.W\23.W\23" + ".W\23.W\23.W\23.W\23.W\23.W\23""2Z\15.W\23""2Z\15""0Y\24""0Y\24""0Y\24" + "2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24" + "2Z\15""0Y\24""0Y\24""2Z\15""0Y\24-\\\16""3[\16-\\\16""3[\16/^\20""3[" + "\16/^\20/^\20/^\20/^\20""3[\16""0_\21""0_\21""0_\21""3[\16""0_\21""2" + "a\23""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24""3b\24""5d\26""5" + "d\26""5d\26""5d\26""7e\17""7e\17""5d\26""9g\21""9g\21""9g\21\376\377" + "\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376" + "\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374" + "\376\377\374\376\377\374\376\377\374\376\377\374\376\377\374\376\377" + "\3749g\21""5k\24""6l\25\202\320q\202\320q5k\24""6l\25""9g\21\0\0\30""1" + "\1\30""1\1\25""0\10\30""1\1\25""0\10\25""0\10\25""0\10\30""1\1\30""1" + "\1\30""1\1\23""3\3\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\27""1\12" + "\23""3\3\23""3\3\30""1\1\23""3\3\27""1\12\23""3\3\27""1\12\23""3\3\23" + "3\3\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\27""7\10" + "\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7" + "\10\27""7\10\27""7\10\31""9\13\32""8\2\31""9\13\31""9\13\32""8\2\34:" + "\5\27""8\11\34:\5\27""8\11\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>" + "\10\30>\10\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B" + "\5\32\77\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77" + "\12\36B\5\32\77\12\36B\5\33A\14\36B\5\33A\14\33A\14\36B\5\33A\14\36B" + "\5\33A\14\33A\14\36B\5\33A\14\0\0.W\23.W\23.W\23.W\23.W\23.W\23.W\23" + "2Z\15""0Y\24""0Y\24""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24" + "0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""2Z\15" + "2Z\15-\\\16-\\\16""0Y\24-\\\16/^\20""3[\16/^\20/^\20/^\20/^\20""0_\21" + "0_\21""0_\21""0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""3b\24" + "3b\24""3b\24""3b\24""3b\24""5d\26""5d\26""5d\26""5d\26""5d\26""7e\17" + "5d\26""9g\21""9g\21""4j\23""9g\21""4j\23""9g\21""5k\24""4j\23""4j\23" + "9g\21""4j\23""9g\21""4j\23""5k\24""9g\21""5k\24""9g\21""5k\24""6l\25" + "9g\21""5k\24""6l\25""9g\21""6l\25""6l\25""5k\24""5k\24""9g\21""6l\25" + "5k\24\0\0\30""1\1\25""0\10\25""0\10\25""0\10\25""0\10\25""0\10\30""1" + "\1\23""3\3\30""1\1\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\23""3\3\30" + "1\1\23""3\3\27""1\12\23""3\3\23""3\3\23""3\3\23""3\3\27""1\12\23""3\3" + "\24""4\5\24""4\5\24""4\5\25""5\6\25""5\6\25""5\6\25""5\6\27""7\10\27" + "7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27""7\10\27" + "7\10\27""7\10\27""7\10\32""8\2\32""8\2\31""9\13\32""8\2\34:\5\27""8\11" + "\34:\5\34:\5\34:\5\27=\7\27=\7\27=\7\27=\7\30>\10\30>\10\30>\10\32\77" + "\12\32\77\12\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\32\77\12\36B\5" + "\32\77\12\36B\5\32\77\12\32\77\12\32\77\12\36B\5\32\77\12\36B\5\32\77" + "\12\36B\5\33A\14\36B\5\33A\14\36B\5\33A\14\36B\5\36B\5\33A\14\36B\5\33" + "A\14\33A\14\36B\5\0\0.W\23.W\23.W\23.W\23.W\23.W\23""2Z\15""0Y\24""0" + "Y\24""0Y\24""0Y\24""2Z\15""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0Y\24""0" + "Y\24""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15""0Y\24""2Z\15""3[\16-\\\16-\\" + "\16""3[\16/^\20""3[\16/^\20/^\20/^\20""3[\16/^\20""3[\16""0_\21""0_\21" + "0_\21""0_\21""0_\21""2a\23""2a\23""2a\23""2a\23""3b\24""3b\24""3b\24" + "3b\24""3b\24""5d\26""5d\26""5d\26""5d\26""5d\26""7e\17""5d\26""9g\21" + "7f\30""4j\23""9g\21""4j\23""5k\24""9g\21""5k\24""4j\23""9g\21""4j\23" + "4j\23""9g\21""5k\24""5k\24""4j\23""4j\23""6l\25""9g\21""5k\24""5k\24" + "5k\24""5k\24""9g\21""6l\25""5k\24""9g\21""5k\24""9g\21""9g\21""5k\24" + "\0\0", +}; + + diff --git a/polymer/build/rsrc/game_icon.bmp b/polymer/build/rsrc/game_icon.bmp new file mode 100644 index 000000000..b921dcd03 Binary files /dev/null and b/polymer/build/rsrc/game_icon.bmp differ diff --git a/polymer/build/rsrc/game_icon.c b/polymer/build/rsrc/game_icon.c new file mode 100644 index 000000000..82d833ac8 --- /dev/null +++ b/polymer/build/rsrc/game_icon.c @@ -0,0 +1,192 @@ +#include "sdlayer.h" + +static unsigned int sdlappicon_pixels[] = { + 0xff415f7a, 0xff364a5c, 0xff364a5c, 0xff607486, 0xff667a8c, 0xff667a8c, + 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, + 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, + 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, + 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff667a8c, 0xff607486, 0xff364a5c, + 0xff364a5c, 0xff415f7a, 0xff364a5c, 0xff202020, 0xff202020, 0xff747474, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff747474, 0xff202020, 0xff202020, 0xff364a5c, 0xff364a5c, 0xff334d66, + 0xff334d66, 0xff747474, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff747474, 0xff334d66, 0xff334d66, 0xff364a5c, + 0xff364a5c, 0xff334d66, 0xff334d66, 0xff747474, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff747474, 0xff334d66, + 0xff334d66, 0xff364a5c, 0xff364a5c, 0xff202020, 0xff202020, 0xff5c5c5c, + 0xff404040, 0xff808080, 0xff646464, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff646464, 0xff7c7c7c, 0xff404040, + 0xff5c5c5c, 0xff202020, 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, + 0xff202020, 0xff6c6c6c, 0xff686868, 0xff808080, 0xff686868, 0xff808080, + 0xff808080, 0xff808080, 0xff6c6c6c, 0xff6a6a6a, 0xff727272, 0xff6c6c6c, + 0xff6c6c6c, 0xff767676, 0xff626262, 0xff6c6c6c, 0xff808080, 0xff6c6c6c, + 0xff686868, 0xff747474, 0xff808080, 0xff808080, 0xff808080, 0xff707070, + 0xff787878, 0xff686868, 0xff6c6c6c, 0xff202020, 0xff202020, 0xff364a5c, + 0xff364a5c, 0xff202020, 0xff202020, 0xff747474, 0xff808080, 0xff808080, + 0xff686868, 0xff808080, 0xff808080, 0xff808080, 0xff6c6c6c, 0xff6a6a6a, + 0xff727272, 0xff6a6a6a, 0xff6a6a6a, 0xff808080, 0xff6c6c6c, 0xff6c6c6c, + 0xff808080, 0xff6c6c6c, 0xff7c7c7c, 0xff6c6c6c, 0xff808080, 0xff808080, + 0xff808080, 0xff707070, 0xff787878, 0xff808080, 0xff747474, 0xff202020, + 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, 0xff202020, 0xff747474, + 0xff808080, 0xff808080, 0xff686868, 0xff808080, 0xff808080, 0xff808080, + 0xff767676, 0xff6c6c6c, 0xff7c7c7c, 0xff707070, 0xff707070, 0xff767676, + 0xff6c6c6c, 0xff767676, 0xff6c6c6c, 0xff767676, 0xff6c6c6c, 0xff7e7e7e, + 0xff808080, 0xff808080, 0xff808080, 0xff707070, 0xff787878, 0xff808080, + 0xff747474, 0xff202020, 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, + 0xff202020, 0xff747474, 0xff808080, 0xff808080, 0xff646464, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff646464, + 0xff787878, 0xff808080, 0xff747474, 0xff202020, 0xff202020, 0xff364a5c, + 0xff364a5c, 0xff202020, 0xff202020, 0xff747474, 0xff808080, 0xff808080, + 0xff686868, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff707070, 0xff787878, 0xff808080, 0xff747474, 0xff202020, + 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, 0xff202020, 0xff747474, + 0xff808080, 0xff808080, 0xff686868, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff707070, 0xff787878, 0xff808080, + 0xff747474, 0xff202020, 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, + 0xff202020, 0xff747474, 0xff808080, 0xff808080, 0xff686868, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff707070, + 0xff787878, 0xff808080, 0xff747474, 0xff202020, 0xff202020, 0xff364a5c, + 0xff364a5c, 0xff202020, 0xff202020, 0xff747474, 0xff808080, 0xff808080, + 0xff646464, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff646464, 0xff787878, 0xff808080, 0xff747474, 0xff202020, + 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, 0xff202020, 0xff747474, + 0xff808080, 0xff808080, 0xff686868, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff707070, 0xff787878, 0xff808080, + 0xff747474, 0xff202020, 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, + 0xff202020, 0xff747474, 0xff808080, 0xff808080, 0xff686868, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff707070, + 0xff787878, 0xff808080, 0xff747474, 0xff202020, 0xff202020, 0xff364a5c, + 0xff364a5c, 0xff202020, 0xff202020, 0xff747474, 0xff808080, 0xff808080, + 0xff686868, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff707070, 0xff787878, 0xff808080, 0xff747474, 0xff202020, + 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, 0xff202020, 0xff747474, + 0xff808080, 0xff808080, 0xff6c6c6c, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff686868, + 0xff686868, 0xff686868, 0xff686868, 0xff686868, 0xff787878, 0xff808080, + 0xff747474, 0xff202020, 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, + 0xff202020, 0xff747474, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff747474, 0xff202020, 0xff202020, 0xff364a5c, + 0xff364a5c, 0xff202020, 0xff202020, 0xff666666, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff808080, + 0xff808080, 0xff808080, 0xff808080, 0xff808080, 0xff666666, 0xff202020, + 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, 0xff202020, 0xff3c3c3c, + 0xff666666, 0xff747474, 0xff747474, 0xff747474, 0xff747474, 0xff747474, + 0xff747474, 0xff747474, 0xff747474, 0xff747474, 0xff747474, 0xff747474, + 0xff747474, 0xff747474, 0xff747474, 0xff747474, 0xff747474, 0xff747474, + 0xff747474, 0xff747474, 0xff747474, 0xff747474, 0xff747474, 0xff666666, + 0xff3c3c3c, 0xff202020, 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff364a5c, + 0xff364a5c, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff302424, 0xff3e3e3e, + 0xff484848, 0xff444444, 0xff444444, 0xff464646, 0xff4c4c4c, 0xff484848, + 0xff484848, 0xff4a4a4a, 0xff4c4c4c, 0xff4c4c4c, 0xff4c4c4c, 0xff4c4c4c, + 0xff4a4a4a, 0xff404040, 0xff343434, 0xff343434, 0xff343434, 0xff343434, + 0xff2c2c2c, 0xff202020, 0xff202020, 0xff364a5c, 0xff364a5c, 0xff202020, + 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff3c3c3c, 0xff727272, 0xff707070, 0xff565656, 0xff505050, 0xff525252, + 0xff6a6a6a, 0xff787878, 0xff767676, 0xff747474, 0xff7a7a7a, 0xff7c7c7c, + 0xff787878, 0xff787878, 0xff7a7a7a, 0xff727272, 0xff505050, 0xff484848, + 0xff484848, 0xff484848, 0xff464646, 0xff202020, 0xff202020, 0xff364a5c, + 0xff364a5c, 0xff202020, 0xff202020, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202020, 0xff444444, 0xff6c6c6c, 0xff6c6c6c, 0xff303030, + 0xff202020, 0xff202020, 0xff545454, 0xff787878, 0xff747474, 0xff747474, + 0xff787878, 0xff7c7c7c, 0xff808080, 0xff808080, 0xff7a7a7a, 0xff747474, + 0xff505050, 0xff484848, 0xff484848, 0xff484848, 0xff484848, 0xff202020, + 0xff202020, 0xff364a5c, 0xff364a5c, 0xff282828, 0xff606060, 0xff686868, + 0xff747474, 0xff4e4e4e, 0xff565656, 0xff202020, 0xff444444, 0xff686868, + 0xff6c6c6c, 0xff303030, 0xff202020, 0xff202020, 0xff545454, 0xff767676, + 0xff767676, 0xff767676, 0xff7c7c7c, 0xff787878, 0xff7c7c7c, 0xff7c7c7c, + 0xff7e7e7e, 0xff767676, 0xff505050, 0xff484848, 0xff484848, 0xff484848, + 0xff484848, 0xff202020, 0xff202020, 0xff364a5c, 0xff364a5c, 0xff606060, + 0xffa8a8a8, 0xff7e7e7e, 0xffa8a8a8, 0xff6c6c6c, 0xff7c7c7c, 0xff202020, + 0xff444444, 0xff6a6a6a, 0xff6c6c6c, 0xff303030, 0xff202020, 0xff202020, + 0xff545454, 0xff747474, 0xff787878, 0xff787878, 0xff7e7e7e, 0xff7c7c7c, + 0xff787878, 0xff787878, 0xff828282, 0xff7c7c7c, 0xff505050, 0xff484848, + 0xff484848, 0xff484848, 0xff484848, 0xff202020, 0xff202020, 0xff364a5c, + 0xff364a5c, 0xff7c7c7c, 0xff808080, 0xff404040, 0xffa8a8a8, 0xffa0a0a0, + 0xff7c7c7c, 0xff202020, 0xff464646, 0xff767676, 0xff727272, 0xff303030, + 0xff202020, 0xff202020, 0xff545454, 0xff767676, 0xff7a7a7a, 0xff787878, + 0xff7e7e7e, 0xff7c7c7c, 0xff787878, 0xff7c7c7c, 0xff8c8c8c, 0xff7e7e7e, + 0xff505050, 0xff484848, 0xff484848, 0xff484848, 0xff484848, 0xff222222, + 0xff25303a, 0xff364a5c, 0xff364a5c, 0xff606060, 0xffa8a8a8, 0xff7e7e7e, + 0xffa8a8a8, 0xff6c6c6c, 0xff7c7c7c, 0xff202020, 0xff484848, 0xff787878, + 0xff727272, 0xff303030, 0xff202020, 0xff202020, 0xff585858, 0xff808080, + 0xff808080, 0xff808080, 0xff888888, 0xff868686, 0xff7e7e7e, 0xff7a7a7a, + 0xff848484, 0xff747474, 0xff505050, 0xff484848, 0xff484848, 0xff484848, + 0xff484848, 0xff252b30, 0xff2a4054, 0xff385168, 0xff3a5874, 0xff282c30, + 0xff606060, 0xff686868, 0xff747474, 0xff4e4e4e, 0xff565656, 0xff202020, + 0xff484848, 0xff787878, 0xff707070, 0xff303030, 0xff202020, 0xff202020, + 0xff585858, 0xff7c7c7c, 0xff7a7a7a, 0xff787878, 0xff828282, 0xff808080, + 0xff808080, 0xff7c7c7c, 0xff828282, 0xff747474, 0xff505050, 0xff484848, + 0xff484848, 0xff484848, 0xff484848, 0xff242424, 0xff26394c, 0xff364a5c, + 0xff4c7498, 0xff334d66, 0xff202428, 0xff202020, 0xff202020, 0xff202020, + 0xff202020, 0xff202428, 0xff4c5660, 0xff747474, 0xff707070, 0xff585858, + 0xff585858, 0xff5c5c5c, 0xff747474, 0xff7c7c7c, 0xff707070, 0xff787878, + 0xff7c7c7c, 0xff787878, 0xff7c7c7c, 0xff868686, 0xff828282, 0xff787878, + 0xff505050, 0xff484848, 0xff484848, 0xff484848, 0xff464646, 0xff202020, + 0xff202020, 0xff364a5c, 0xff4c7498, 0xff4c7498, 0xff3a5874, 0xff364a5c, + 0xff364a5c, 0xff364a5c, 0xff364a5c, 0xff3a5874, 0xff55738e, 0xff5a6e80, + 0xff5e7284, 0xff5e7284, 0xff64788a, 0xff687c8e, 0xff6c8092, 0xff667a8c, + 0xff627688, 0xff627688, 0xff627688, 0xff627688, 0xff64788a, 0xff6a7e90, + 0xff667a8c, 0xff627688, 0xff4e6274, 0xff4a5e70, 0xff4a5e70, 0xff4a5e70, + 0xff44586a, 0xff364a5c, 0xff364a5c, 0xff415f7a,}; + +static unsigned char sdlappicon_mask[] = { + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255,}; + +struct sdlappicon sdlappicon = { + 32,32, // width,height + sdlappicon_pixels, + sdlappicon_mask +}; diff --git a/polymer/build/rsrc/game_icon.ico b/polymer/build/rsrc/game_icon.ico new file mode 100644 index 000000000..b6868267f Binary files /dev/null and b/polymer/build/rsrc/game_icon.ico differ diff --git a/polymer/build/src/a-c.c b/polymer/build/src/a-c.c new file mode 100644 index 000000000..bd59fca92 --- /dev/null +++ b/polymer/build/src/a-c.c @@ -0,0 +1,298 @@ +// A.ASM replacement using C +// Mainly by Ken Silverman, with things melded with my port by +// Jonathon Fowler (jonof@edgenetwork.org) +// +// "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. + +#include "a.h" + +#ifndef ENGINE_USING_A_C +# error A.H has indicated that optimized code has been requested. This means a-c.c is being compiled \ + when USE_A_C has not been defined. +#endif + +long krecip(long num); // from engine.c + +#define BITSOFPRECISION 3 +#define BITSOFPRECISIONPOW 8 + +extern long asm1, asm2, asm3, asm4, fpuasm, globalx3, globaly3; +extern void *reciptable; + +static long bpl, transmode = 0; +static long glogx, glogy, gbxinc, gbyinc, gpinc; +static char *gbuf, *gpal, *ghlinepal, *gtrans; + + //Global variable functions +void setvlinebpl(long dabpl) { bpl = dabpl; } +void fixtransluscence(long datransoff) { gtrans = (char *)datransoff; } +void settransnormal(void) { transmode = 0; } +void settransreverse(void) { transmode = 1; } + + + //Ceiling/floor horizontal line functions +void sethlinesizes(long logx, long logy, long bufplc) + { glogx = logx; glogy = logy; gbuf = (char *)bufplc; } +void setpalookupaddress(char *paladdr) { ghlinepal = paladdr; } +void setuphlineasm4(long bxinc, long byinc) { gbxinc = bxinc; gbyinc = byinc; } +void hlineasm4(long cnt, long skiploadincs, long paloffs, unsigned long by, unsigned long bx, long p) +{ + char *palptr; + + palptr = (char *)&ghlinepal[paloffs]; + if (!skiploadincs) { gbxinc = asm1; gbyinc = asm2; } + for(;cnt>=0;cnt--) + { + *((char *)p) = palptr[gbuf[((bx>>(32-glogx))<>(32-glogy))]]; + bx -= gbxinc; + by -= gbyinc; + p--; + } +} + + + //Sloped ceiling/floor vertical line functions +void setupslopevlin(long logylogx, long bufplc, long pinc) +{ + glogx = (logylogx&255); glogy = (logylogx>>8); + gbuf = (char *)bufplc; gpinc = pinc; +} +void slopevlin(long p, long i, long slopaloffs, long cnt, long bx, long by) +{ + long *slopalptr, bz, bzinc; + unsigned long u, v; + + bz = asm3; bzinc = (asm1>>3); + slopalptr = (long *)slopaloffs; + for(;cnt>0;cnt--) + { + i = krecip(bz>>6); bz += bzinc; + u = bx+globalx3*i; + v = by+globaly3*i; + (*(char *)p) = *(char *)(slopalptr[0]+gbuf[((u>>(32-glogx))<>(32-glogy))]); + slopalptr--; + p += gpinc; + } +} + + + //Wall,face sprite/wall sprite vertical line functions +void setupvlineasm(long neglogy) { glogy = neglogy; } +void vlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p) +{ + gbuf = (char *)bufplc; + gpal = (char *)paloffs; + for(;cnt>=0;cnt--) + { + *((char *)p) = gpal[gbuf[vplc>>glogy]]; + p += bpl; + vplc += vinc; + } +} + +void setupmvlineasm(long neglogy) { glogy = neglogy; } +void mvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p) +{ + char ch; + + gbuf = (char *)bufplc; + gpal = (char *)paloffs; + for(;cnt>=0;cnt--) + { + ch = gbuf[vplc>>glogy]; if (ch != 255) *((char *)p) = gpal[ch]; + p += bpl; + vplc += vinc; + } +} + +void setuptvlineasm(long neglogy) { glogy = neglogy; } +void tvlineasm1(long vinc, long paloffs, long cnt, unsigned long vplc, long bufplc, long p) +{ + char ch; + + gbuf = (char *)bufplc; + gpal = (char *)paloffs; + if (transmode) + { + for(;cnt>=0;cnt--) + { + ch = gbuf[vplc>>glogy]; + if (ch != 255) *((char *)p) = gtrans[(*((char *)p))+(gpal[ch]<<8)]; + p += bpl; + vplc += vinc; + } + } + else + { + for(;cnt>=0;cnt--) + { + ch = gbuf[vplc>>glogy]; + if (ch != 255) *((char *)p) = gtrans[((*((char *)p))<<8)+gpal[ch]]; + p += bpl; + vplc += vinc; + } + } +} + + //Floor sprite horizontal line functions +void msethlineshift(long logx, long logy) { glogx = logx; glogy = logy; } +void mhline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned long by, long p) +{ + char ch; + + gbuf = (char *)bufplc; + gpal = (char *)asm3; + for(cntup16>>=16;cntup16>0;cntup16--) + { + ch = gbuf[((bx>>(32-glogx))<>(32-glogy))]; + if (ch != 255) *((char *)p) = gpal[ch]; + bx += asm1; + by += asm2; + p++; + } +} + +void tsethlineshift(long logx, long logy) { glogx = logx; glogy = logy; } +void thline(long bufplc, unsigned long bx, long cntup16, long junk, unsigned long by, long p) +{ + char ch; + + gbuf = (char *)bufplc; + gpal = (char *)asm3; + if (transmode) + { + for(cntup16>>=16;cntup16>0;cntup16--) + { + ch = gbuf[((bx>>(32-glogx))<>(32-glogy))]; + if (ch != 255) *((char *)p) = gtrans[(*((char *)p))+(gpal[ch]<<8)]; + bx += asm1; + by += asm2; + p++; + } + } + else + { + for(cntup16>>=16;cntup16>0;cntup16--) + { + ch = gbuf[((bx>>(32-glogx))<>(32-glogy))]; + if (ch != 255) *((char *)p) = gtrans[((*((char *)p))<<8)+gpal[ch]]; + bx += asm1; + by += asm2; + p++; + } + } +} + + + //Rotatesprite vertical line functions +void setupspritevline(long paloffs, long bxinc, long byinc, long ysiz) +{ + gpal = (char *)paloffs; + gbxinc = bxinc; + gbyinc = byinc; + glogy = ysiz; +} +void spritevline(long bx, long by, long cnt, long bufplc, long p) +{ + gbuf = (char *)bufplc; + for(;cnt>1;cnt--) + { + (*(char *)p) = gpal[gbuf[(bx>>16)*glogy+(by>>16)]]; + bx += gbxinc; + by += gbyinc; + p += bpl; + } +} + + //Rotatesprite vertical line functions +void msetupspritevline(long paloffs, long bxinc, long byinc, long ysiz) +{ + gpal = (char *)paloffs; + gbxinc = bxinc; + gbyinc = byinc; + glogy = ysiz; +} +void mspritevline(long bx, long by, long cnt, long bufplc, long p) +{ + char ch; + + gbuf = (char *)bufplc; + for(;cnt>1;cnt--) + { + ch = gbuf[(bx>>16)*glogy+(by>>16)]; + if (ch != 255) (*(char *)p) = gpal[ch]; + bx += gbxinc; + by += gbyinc; + p += bpl; + } +} + +void tsetupspritevline(long paloffs, long bxinc, long byinc, long ysiz) +{ + gpal = (char *)paloffs; + gbxinc = bxinc; + gbyinc = byinc; + glogy = ysiz; +} +void tspritevline(long bx, long by, long cnt, long bufplc, long p) +{ + char ch; + + gbuf = (char *)bufplc; + if (transmode) + { + for(;cnt>1;cnt--) + { + ch = gbuf[(bx>>16)*glogy+(by>>16)]; + if (ch != 255) *((char *)p) = gtrans[(*((char *)p))+(gpal[ch]<<8)]; + bx += gbxinc; + by += gbyinc; + p += bpl; + } + } + else + { + for(;cnt>1;cnt--) + { + ch = gbuf[(bx>>16)*glogy+(by>>16)]; + if (ch != 255) *((char *)p) = gtrans[((*((char *)p))<<8)+gpal[ch]]; + bx += gbxinc; + by += gbyinc; + p += bpl; + } + } +} + +void setupdrawslab (long dabpl, long pal) + { bpl = dabpl; gpal = (char *)pal; } + +void drawslab (long dx, long v, long dy, long vi, long vptr, long p) +{ + long x; + + while (dy > 0) + { + for(x=0;x>16)+vptr))]; + p += bpl; v += vi; dy--; + } +} + +void stretchhline (long p0, long u, long cnt, long uinc, long rptr, long p) +{ + p0 = p-(cnt<<2); + do + { + p--; + *(char *)p = *(char *)((u>>16)+rptr); u -= uinc; + } while (p > p0); +} + + +void mmxoverlay() { } + +/* + * vim:ts=4: + */ + diff --git a/polymer/build/src/a.masm b/polymer/build/src/a.masm new file mode 100644 index 000000000..bd9ece295 --- /dev/null +++ b/polymer/build/src/a.masm @@ -0,0 +1,2664 @@ +; "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. + +.586P +.8087 +;include mmx.inc ;Include this if using < WATCOM 11.0 WASM + +;Warning: IN THIS FILE, ALL SEGMENTS ARE REMOVED. THIS MEANS THAT DS:[] +;MUST BE ADDED FOR ALL SELF-MODIFIES FOR MASM TO WORK. +; +;WASM PROBLEMS: +; 1. Requires all scaled registers (*1,*2,*4,*8) to be last thing on line +; 2. Using 'DATA' is nice for self-mod. code, but WDIS only works with 'CODE' +; +;MASM PROBLEMS: +; 1. Requires DS: to be written out for self-modifying code to work +; 2. Doesn't encode short jumps automatically like WASM +; 3. Stupidly adds wait prefix to ffree's + +EXTRN _asm1 : dword +EXTRN _asm2 : dword +EXTRN _asm3 : dword +EXTRN _asm4 : dword +EXTRN _reciptable : near +EXTRN _fpuasm : dword +EXTRN _globalx3 : dword +EXTRN _globaly3 : dword +EXTRN _ylookup : near + +EXTRN _vplce : near +EXTRN _vince : near +EXTRN _palookupoffse : near +EXTRN _bufplce : near + +EXTRN _ebpbak : dword +EXTRN _espbak : dword + +EXTRN _pow2char : near +EXTRN _pow2long : near + + +; Some macros to help make cdecl calling easier to manage +CDECLBEGIN MACRO noi:=<0> + IF noi GE 2 + push ebx + ENDIF + IF noi GE 3 + push ecx + ENDIF + IF noi GE 4 + push edx + ENDIF + IF noi GE 5 + push esi + ENDIF + IF noi GE 6 + push edi + ENDIF +ENDM + +CDECLEND MACRO noi:=<0> + IF noi GE 6 + pop edi + ENDIF + IF noi GE 5 + pop esi + ENDIF + IF noi GE 4 + pop edx + ENDIF + IF noi GE 3 + pop ecx + ENDIF + IF noi GE 2 + pop ebx + ENDIF +ENDM + +CDECLPARAM MACRO registername:REQ,paramnumber:REQ,offsetted:REQ +; mov registername, dword ptr [esp + (paramnumber*4+16)] + mov registername, dword ptr [esp + ((paramnumber+offsetted)*4+4)] +ENDM + +CDECLBEGINSET MACRO numparams:REQ + CDECLBEGIN numparams + +% _offsetted = numparams - 1 + + IF numparams GE 1 + CDECLPARAM eax,0,%_offsetted + ENDIF + IF numparams GE 2 + CDECLPARAM ebx,1,%_offsetted + ENDIF + IF numparams GE 3 + CDECLPARAM ecx,2,%_offsetted + ENDIF + IF numparams GE 4 + CDECLPARAM edx,3,%_offsetted + ENDIF + IF numparams GE 5 + CDECLPARAM esi,4,%_offsetted + ENDIF + IF numparams GE 6 + CDECLPARAM edi,5,%_offsetted + ENDIF +ENDM + +CDECLENDSET MACRO numparams:REQ + CDECLEND numparams +ENDM + +CODE SEGMENT PUBLIC USE32 'DATA' +ASSUME cs:CODE,ds:CODE + +ALIGN 16 +PUBLIC _sethlinesizes +_sethlinesizes: +CDECLBEGINSET 3 + + mov byte ptr [machxbits1+2], al + mov byte ptr [machxbits2+2], al + mov byte ptr [machxbits3+2], al + neg al + mov byte ptr [hxsiz1+2], al + mov byte ptr [hxsiz2+2], al + mov byte ptr [hxsiz3+2], al + mov byte ptr [hxsiz4+2], al + mov byte ptr [machnegxbits1+2], al + + mov byte ptr [hysiz1+3], bl + mov byte ptr [hysiz2+3], bl + mov byte ptr [hysiz3+3], bl + mov byte ptr [hysiz4+3], bl + mov byte ptr [hmach3a+2], bl + mov byte ptr [hmach3b+2], bl + mov byte ptr [hmach3c+2], bl + mov byte ptr [hmach3d+2], bl + + mov dword ptr [hoffs1+2], ecx + mov dword ptr [hoffs2+2], ecx + mov dword ptr [hoffs3+2], ecx + mov dword ptr [hoffs4+2], ecx + mov dword ptr [hoffs5+2], ecx + mov dword ptr [hoffs6+2], ecx + mov dword ptr [hoffs7+2], ecx + mov dword ptr [hoffs8+2], ecx + + push edx ;JBF + mov edx, -1 + mov cl, al + sub cl, bl + shr edx, cl + mov dword ptr [hmach2a+1], edx + mov dword ptr [hmach2b+1], edx + mov dword ptr [hmach2c+1], edx + mov dword ptr [hmach2d+1], edx + pop edx ;JBF + +CDECLENDSET 3 + ret + +ALIGN 16 +PUBLIC _prosethlinesizes +_prosethlinesizes: +CDECLBEGINSET 3 + + mov dword ptr [prohbuf-4], ecx + neg eax + mov ecx, eax + sub eax, ebx + mov byte ptr [prohshru-1], al ;bl = 32-al-bl + mov eax, -1 + shr eax, cl + mov ecx, ebx + shl eax, cl + mov dword ptr [prohand-4], eax ;((-1>>(-oal))<>(32-xbits) adc al, 88h 1 1/2 + ;bufplc mov cl, byte ptr [edx+88888888h] 1 1/2 + ;paloffs&255 mov bl, byte ptr [ecx+88888888h] 1 1/2 +ALIGN 16 +PUBLIC _hlineasm4 +_hlineasm4: +CDECLBEGINSET 6 + + push ebp + + lea ebp, [eax+1] + + cmp ebp, 8 + jle shorthline + + test edi, 1 + jnz short skipthe1byte + + mov eax, esi +hxsiz1: shr eax, 26 +hysiz1: shld eax, edx, 6 +hoffs1: mov cl, byte ptr [eax+88888888h] +pal1: mov bl, byte ptr [ecx+88888888h] + sub esi, _asm1 + sub edx, _asm2 + mov byte ptr [edi], bl + dec edi + dec ebp + +skipthe1byte: + test edi, 2 + jnz short skipthe2byte + + mov eax, esi +hxsiz2: shr eax, 26 +hysiz2: shld eax, edx, 6 +hoffs2: mov cl, byte ptr [eax+88888888h] +pal2: mov bh, byte ptr [ecx+88888888h] + sub esi, _asm1 + sub edx, _asm2 + + mov eax, esi +hxsiz3: shr eax, 26 +hysiz3: shld eax, edx, 6 +hoffs3: mov cl, byte ptr [eax+88888888h] +pal3: mov bl, byte ptr [ecx+88888888h] + sub esi, _asm1 + sub edx, _asm2 + mov word ptr [edi-1], bx + sub edi, 2 + sub ebp, 2 + +skipthe2byte: + + mov eax, esi +machxbits1: shl esi, 6 ;xbits +machnegxbits1: shr eax, 32-6 ;32-xbits + mov dl, al + + inc edi + + add ebx, ebx + mov eax, edx + jc beginhline64 + + mov eax, _asm1 +machxbits2: rol eax, 6 ;xbits + mov dword ptr [hmach4a+2], eax + mov dword ptr [hmach4b+2], eax + mov dword ptr [hmach4c+2], eax + mov dword ptr [hmach4d+2], eax + mov ebx, eax + mov eax, _asm2 + mov al, bl + mov dword ptr [hmach1a+2], eax + mov dword ptr [hmach1b+2], eax + mov dword ptr [hmach1c+2], eax + mov dword ptr [hmach1d+2], eax + + mov eax, edx + jmp beginhline64 +ALIGN 16 +prebeginhline64: + mov dword ptr [edi], ebx +beginhline64: + +hmach3a: rol eax, 6 +hmach2a: and eax, 00008888h +hmach4a: sub esi, 88888888h +hmach1a: sbb edx, 88888888h + sub edi, 4 +hoffs4: mov cl, byte ptr [eax+88888888h] + mov eax, edx + +hmach3b: rol eax, 6 +hmach2b: and eax, 00008888h +hmach4b: sub esi, 88888888h +hmach1b: sbb edx, 88888888h +pal4: mov bh, byte ptr [ecx+88888888h] +hoffs5: mov cl, byte ptr [eax+88888888h] + mov eax, edx + +hmach3c: rol eax, 6 +pal5: mov bl, byte ptr [ecx+88888888h] +hmach2c: and eax, 00008888h + shl ebx, 16 +hmach4c: sub esi, 88888888h +hmach1c: sbb edx, 88888888h +hoffs6: mov cl, byte ptr [eax+88888888h] + + mov eax, edx + ;( + +hmach3d: rol eax, 6 +hmach2d: and eax, 00008888h +hmach4d: sub esi, 88888888h +hmach1d: sbb edx, 88888888h +pal6: mov bh, byte ptr [ecx+88888888h] +hoffs7: mov cl, byte ptr [eax+88888888h] + mov eax, edx + sub ebp, 4 + nop +pal7: mov bl, byte ptr [ecx+88888888h] + jnc prebeginhline64 +skipthe4byte: + + test ebp, 2 + jz skipdrawthe2 + rol ebx, 16 + mov word ptr [edi+2], bx + sub edi, 2 +skipdrawthe2: + test ebp, 1 + jz skipdrawthe1 + shr ebx, 24 + mov byte ptr [edi+3], bl +skipdrawthe1: + + pop ebp +CDECLENDSET 6 + ret + +shorthline: + test ebp, ebp + jz endshorthline +begshorthline: + mov eax, esi +hxsiz4: shr eax, 26 +hysiz4: shld eax, edx, 6 +hoffs8: mov cl, byte ptr [eax+88888888h] +pal8: mov bl, byte ptr [ecx+88888888h] + sub esi, _asm1 + sub edx, _asm2 + mov byte ptr [edi], bl + dec edi + dec ebp + jnz begshorthline +endshorthline: + pop ebp +CDECLENDSET 6 + ret + + + ;eax: 00000000 00000000 00000000 temp---- + ;ebx: 00000000 00000000 00000000 temp---- + ;ecx: UUUUUUuu uuuuuuuu uuuuuuuu uuuuuuuu + ;edx: VVVVVVvv vvvvvvvv vvvvvvvv vvvvvvvv + ;esi: cnt----- -------- -------- -------- + ;edi: vid----- -------- -------- -------- + ;ebp: paloffs- -------- -------- -------- + ;esp: ???????? ???????? ???????? ???????? +ALIGN 16 +PUBLIC _prohlineasm4 +_prohlineasm4: +CDECLBEGINSET 6 + + push ebp + + lea ebp, [ecx+88888888h] +prohpala: + mov ecx, esi + lea esi, [eax+1] + sub edi, esi + +prohbeg: + mov eax, ecx + shr eax, 20 +prohshru: + mov ebx, edx + shr ebx, 26 +prohshrv: + and eax, 88888888h +prohand: + movzx eax, byte ptr [eax+ebx+88888888h] +prohbuf: + mov al, [eax+ebp] + sub ecx, _asm1 + sub edx, _asm2 + mov [edi+esi], al + dec esi + jnz prohbeg + + pop ebp +CDECLENDSET 6 + ret + + + +ALIGN 16 +PUBLIC _setupvlineasm +_setupvlineasm: +CDECLBEGINSET 1 + ;First 2 lines for VLINEASM1, rest for VLINEASM4 + mov byte ptr [premach3a+2], al + mov byte ptr [mach3a+2], al + + push ecx + mov byte ptr [machvsh1+2], al ;32-shy + mov byte ptr [machvsh3+2], al ;32-shy + mov byte ptr [machvsh5+2], al ;32-shy + mov byte ptr [machvsh6+2], al ;32-shy + mov ah, al + sub ah, 16 + mov byte ptr [machvsh8+2], ah ;16-shy + neg al + mov byte ptr [machvsh7+2], al ;shy + mov byte ptr [machvsh9+2], al ;shy + mov byte ptr [machvsh10+2], al ;shy + mov byte ptr [machvsh11+2], al ;shy + mov byte ptr [machvsh12+2], al ;shy + mov cl, al + mov eax, 1 + shl eax, cl + dec eax + mov dword ptr [machvsh2+2], eax ;(1<>sh) + ;vplc3 = (ebp<<(32-sh))+((edx&65535)<<(16-sh)) +machvsh5: shl esi, 88h ;32-sh + mov eax, edx +machvsh6: shl ebp, 88h ;32-sh + and edx, 0000ffffh +machvsh7: shr eax, 88h ;sh + add esi, eax +machvsh8: shl edx, 88h ;16-sh + add ebp, edx + mov dword ptr _vplce[12], esi + mov dword ptr _vplce[4], ebp + + pop ebp + +CDECLEND 6 + ret + + ;eax: -------temp1------- + ;ebx: -------temp2------- + ;ecx: ylo4 --------- + ;edx: ylo2 --------- + ;esi: yhi1 yhi2 + ;edi: ---videoplc/cnt---- + ;ebp: yhi3 yhi4 + ;esp: +ALIGN 16 +PUBLIC _provlineasm4 +_provlineasm4: +CDECLBEGIN 6 +CDECLPARAM ecx,0,5 +CDECLPARAM edi,1,5 + + push ebp + + mov eax, dword ptr _ylookup[ecx*4] + add eax, edi + mov dword ptr [promachvline4end1+2], eax + inc eax + mov dword ptr [promachvline4end2+2], eax + inc eax + mov dword ptr [promachvline4end3+2], eax + inc eax + mov dword ptr [promachvline4end4+2], eax + sub eax, 3 + sub edi, eax + + mov eax, dword ptr _bufplce[0] + mov ebx, dword ptr _bufplce[4] + mov ecx, dword ptr _bufplce[8] + mov edx, dword ptr _bufplce[12] + mov dword ptr [promachvbuf1+3], ecx + mov dword ptr [promachvbuf2+3], edx + mov dword ptr [promachvbuf3+3], eax + mov dword ptr [promachvbuf4+3], ebx + + mov eax, dword ptr _palookupoffse[0] + mov ebx, dword ptr _palookupoffse[4] + mov ecx, dword ptr _palookupoffse[8] + mov edx, dword ptr _palookupoffse[12] + mov dword ptr [promachvpal1+2], ecx + mov dword ptr [promachvpal2+2], edx + mov dword ptr [promachvpal3+2], eax + mov dword ptr [promachvpal4+2], ebx + + ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + ;edx: ³v3lo ³v1lo ³ + ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄ´ + ;esi: ³v2hi v2lo ³ v3hi³ + ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ´ + ;ebp: ³v0hi v0lo ³ v1hi³ + ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ + + mov ebp, dword ptr _vince[0] + mov ebx, dword ptr _vince[4] + mov esi, dword ptr _vince[8] + mov eax, dword ptr _vince[12] + and esi, 0fffffe00h + and ebp, 0fffffe00h +promachvsh9: rol eax, 88h ;sh +promachvsh10: rol ebx, 88h ;sh + mov edx, eax + mov ecx, ebx + shr ecx, 16 + and edx, 0ffff0000h + add edx, ecx + and eax, 000001ffh + and ebx, 000001ffh + add esi, eax + add ebp, ebx + ; + mov eax, edx + and eax, 0ffff0000h + mov dword ptr [promachvinc1+2], eax + mov dword ptr [promachvinc2+2], esi + shl edx, 16 + mov dword ptr [promachvinc3+2], edx + mov dword ptr [promachvinc5+2], ebp + + mov ebp, dword ptr _vplce[0] + mov ebx, dword ptr _vplce[4] + mov esi, dword ptr _vplce[8] + mov eax, dword ptr _vplce[12] + and esi, 0fffffe00h + and ebp, 0fffffe00h +promachvsh11: rol eax, 88h ;sh +promachvsh12: rol ebx, 88h ;sh + mov edx, eax + mov ecx, ebx + shr ecx, 16 + and edx, 0ffff0000h + add edx, ecx + and eax, 000001ffh + and ebx, 000001ffh + add esi, eax + add ebp, ebx + + mov eax, esi + mov ecx, edx + shl ecx, 16 + jmp short probeginvlineasm4 +ALIGN 16 + nop + nop + nop +probeginvlineasm4: +promachvsh1: shr eax, 88h ;32-sh + mov ebx, esi +promachvsh2: and ebx, 00000088h ;(1<>sh) + ;vplc3 = (ebp<<(32-sh))+((edx&65535)<<(16-sh)) +promachvsh5: shl esi, 88h ;32-sh + mov eax, edx +promachvsh6: shl ebp, 88h ;32-sh + and edx, 0000ffffh +promachvsh7: shr eax, 88h ;sh + add esi, eax +promachvsh8: shl edx, 88h ;16-sh + add ebp, edx + mov dword ptr _vplce[12], esi + mov dword ptr _vplce[4], ebp + + pop ebp + +CDECLEND 6 + ret + + +ALIGN 16 +PUBLIC _mvlineasm4 +_mvlineasm4: +CDECLBEGIN 6 +CDECLPARAM ecx,0,5 +CDECLPARAM edi,1,5 + + push ebp + + mov eax, dword ptr _bufplce[0] + mov ebx, dword ptr _bufplce[4] + mov dword ptr [machmv1+2], eax + mov dword ptr [machmv4+2], ebx + mov eax, dword ptr _bufplce[8] + mov ebx, dword ptr _bufplce[12] + mov dword ptr [machmv7+2], eax + mov dword ptr [machmv10+2], ebx + + mov eax, dword ptr _palookupoffse[0] + mov ebx, dword ptr _palookupoffse[4] + mov dword ptr [machmv2+2], eax + mov dword ptr [machmv5+2], ebx + mov eax, dword ptr _palookupoffse[8] + mov ebx, dword ptr _palookupoffse[12] + mov dword ptr [machmv8+2], eax + mov dword ptr [machmv11+2], ebx + + mov eax, dword ptr _vince[0] ;vince + mov ebx, dword ptr _vince[4] + xor al, al + xor bl, bl + mov dword ptr [machmv3+2], eax + mov dword ptr [machmv6+2], ebx + mov eax, dword ptr _vince[8] + mov ebx, dword ptr _vince[12] + mov dword ptr [machmv9+2], eax + mov dword ptr [machmv12+2], ebx + + mov ebx, ecx + mov ecx, dword ptr _vplce[0] + mov edx, dword ptr _vplce[4] + mov esi, dword ptr _vplce[8] + mov ebp, dword ptr _vplce[12] + mov cl, bl + inc cl + inc bh + mov byte ptr _asm3[0], bh +fixchain2ma: sub edi, 320 + + jmp short beginmvlineasm4 +ALIGN 16 +beginmvlineasm4: + dec cl + jz endmvlineasm4 +beginmvlineasm42: + mov eax, ebp + mov ebx, esi +machmv16: shr eax, 32 +machmv15: shr ebx, 32 +machmv12: add ebp, 88888888h ;vince[3] +machmv9: add esi, 88888888h ;vince[2] +machmv10: mov al, byte ptr [eax+88888888h] ;bufplce[3] +machmv7: mov bl, byte ptr [ebx+88888888h] ;bufplce[2] + cmp al, 255 + adc dl, dl + cmp bl, 255 + adc dl, dl +machmv8: mov bl, byte ptr [ebx+88888888h] ;palookupoffs[2] +machmv11: mov bh, byte ptr [eax+88888888h] ;palookupoffs[3] + + mov eax, edx +machmv14: shr eax, 32 + shl ebx, 16 +machmv4: mov al, byte ptr [eax+88888888h] ;bufplce[1] + cmp al, 255 + adc dl, dl +machmv6: add edx, 88888888h ;vince[1] +machmv5: mov bh, byte ptr [eax+88888888h] ;palookupoffs[1] + + mov eax, ecx +machmv13: shr eax, 32 +machmv3: add ecx, 88888888h ;vince[0] +machmv1: mov al, byte ptr [eax+88888888h] ;bufplce[0] + cmp al, 255 + adc dl, dl +machmv2: mov bl, byte ptr [eax+88888888h] ;palookupoffs[0] + + shl dl, 4 + xor eax, eax +fixchain2mb: add edi, 320 + mov al, dl + add eax, offset mvcase0 + jmp eax ;16 byte cases + +ALIGN 16 +endmvlineasm4: + dec byte ptr _asm3[0] + jnz beginmvlineasm42 + + mov dword ptr _vplce[0], ecx + mov dword ptr _vplce[4], edx + mov dword ptr _vplce[8], esi + mov dword ptr _vplce[12], ebp + pop ebp +CDECLEND 6 + ret + + ;5,7,8,8,11,13,12,14,11,13,14,14,12,14,15,7 +ALIGN 16 +mvcase0: + jmp beginmvlineasm4 +ALIGN 16 +mvcase1: + mov byte ptr [edi], bl + jmp beginmvlineasm4 +ALIGN 16 +mvcase2: + mov byte ptr [edi+1], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase3: + mov word ptr [edi], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase4: + shr ebx, 16 + mov byte ptr [edi+2], bl + jmp beginmvlineasm4 +ALIGN 16 +mvcase5: + mov byte ptr [edi], bl + shr ebx, 16 + mov byte ptr [edi+2], bl + jmp beginmvlineasm4 +ALIGN 16 + mvcase6: + shr ebx, 8 + mov word ptr [edi+1], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase7: + mov word ptr [edi], bx + shr ebx, 16 + mov byte ptr [edi+2], bl + jmp beginmvlineasm4 +ALIGN 16 +mvcase8: + shr ebx, 16 + mov byte ptr [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase9: + mov byte ptr [edi], bl + shr ebx, 16 + mov byte ptr [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase10: + mov byte ptr [edi+1], bh + shr ebx, 16 + mov byte ptr [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase11: + mov word ptr [edi], bx + shr ebx, 16 + mov byte ptr [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase12: + shr ebx, 16 + mov word ptr [edi+2], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase13: + mov byte ptr [edi], bl + shr ebx, 16 + mov word ptr [edi+2], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase14: + mov byte ptr [edi+1], bh + shr ebx, 16 + mov word ptr [edi+2], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase15: + mov dword ptr [edi], ebx + jmp beginmvlineasm4 + +ALIGN 16 +PUBLIC _setupspritevline +_setupspritevline: +CDECLBEGINSET 6 + + mov dword ptr [spal+2], eax + + mov eax, esi ;xinc's + shl eax, 16 + mov dword ptr [smach1+2], eax + mov dword ptr [smach4+2], eax + mov eax, esi + sar eax, 16 + add eax, ebx ;watch out with ebx - it's passed + mov dword ptr [smach2+2], eax + add eax, edx + mov dword ptr [smach5+2], eax + + mov dword ptr [smach3+2], ecx ;yinc's + +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _spritevline +_spritevline: +CDECLBEGINSET 6 + jmp short _spritevline_start + ;eax = 0, ebx = x, ecx = cnt, edx = y, esi = yplc, edi = p +prestartsvline: +smach1: add ebx, 88888888h ;xincshl16 + mov al, byte ptr [esi] +smach2: adc esi, 88888888h ;xincshr16+yalwaysinc + +startsvline: +spal: mov al, [eax+88888888h] ;palookup + mov byte ptr [edi], al +fixchain1s: add edi, 320 + +_spritevline_start: +smach3: add edx, 88888888h ;dayinc + dec ecx + ja short prestartsvline ;jump if (no carry (add)) and (not zero (dec))! + jz short endsvline +smach4: add ebx, 88888888h ;xincshl16 + mov al, byte ptr [esi] +smach5: adc esi, 88888888h ;xincshr16+yalwaysinc+daydime + jmp short startsvline +endsvline: +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _msetupspritevline +_msetupspritevline: +CDECLBEGINSET 6 + + mov dword ptr [mspal+2], eax + + mov eax, esi ;xinc's + shl eax, 16 + mov dword ptr [msmach1+2], eax + mov dword ptr [msmach4+2], eax + mov eax, esi + sar eax, 16 + add eax, ebx ;watch out with ebx - it's passed + mov dword ptr [msmach2+2], eax + add eax, edx + mov dword ptr [msmach5+2], eax + + mov dword ptr [msmach3+2], ecx ;yinc's + +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _mspritevline +_mspritevline: +CDECLBEGINSET 6 + jmp short _mspritevline_start + ;eax = 0, ebx = x, ecx = cnt, edx = y, esi = yplc, edi = p +mprestartsvline: +msmach1: add ebx, 88888888h ;xincshl16 + mov al, byte ptr [esi] +msmach2: adc esi, 88888888h ;xincshr16+yalwaysinc + +mstartsvline: + cmp al, 255 + je short mskipsvline +mspal: mov al, [eax+88888888h] ;palookup + mov byte ptr [edi], al +mskipsvline: +mfixchain1s: add edi, 320 + +_mspritevline_start: +msmach3: add edx, 88888888h ;dayinc + dec ecx + ja short mprestartsvline ;jump if (no carry (add)) and (not zero (dec))! + jz short mendsvline +msmach4: add ebx, 88888888h ;xincshl16 + mov al, byte ptr [esi] +msmach5: adc esi, 88888888h ;xincshr16+yalwaysinc+daydime + jmp short mstartsvline +mendsvline: +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _tsetupspritevline +_tsetupspritevline: +CDECLBEGINSET 6 + mov dword ptr [tspal+2], eax + + mov eax, esi ;xinc's + shl eax, 16 + mov dword ptr [tsmach1+2], eax + mov dword ptr [tsmach4+2], eax + mov eax, esi + sar eax, 16 + add eax, ebx ;watch out with ebx - it's passed + mov dword ptr [tsmach2+2], eax + add eax, edx + mov dword ptr [tsmach5+2], eax + + mov dword ptr [tsmach3+2], ecx ;yinc's +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _tspritevline +_tspritevline: +CDECLBEGINSET 6 + ;eax = 0, ebx = x, ecx = cnt, edx = y, esi = yplc, edi = p + push ebp + mov ebp, ebx + xor ebx, ebx + jmp tenterspritevline +ALIGN 16 +tprestartsvline: +tsmach1: add ebp, 88888888h ;xincshl16 + mov al, byte ptr [esi] +tsmach2: adc esi, 88888888h ;xincshr16+yalwaysinc + +tstartsvline: + cmp al, 255 + je short tskipsvline +transrev2: + mov bh, byte ptr [edi] +transrev3: +tspal: mov bl, [eax+88888888h] ;palookup +tmach4: mov al, byte ptr [ebx+88888888h] ;_transluc + mov byte ptr [edi], al +tskipsvline: +tfixchain1s: add edi, 320 + +tenterspritevline: +tsmach3: add edx, 88888888h ;dayinc + dec ecx + ja short tprestartsvline ;jump if (no carry (add)) and (not zero (dec))! + jz short tendsvline +tsmach4: add ebp, 88888888h ;xincshl16 + mov al, byte ptr [esi] +tsmach5: adc esi, 88888888h ;xincshr16+yalwaysinc+daydime + jmp short tstartsvline +tendsvline: + pop ebp +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _msethlineshift +_msethlineshift: +CDECLBEGINSET 2 + neg al + mov byte ptr [msh1d+2], al + mov byte ptr [msh2d+3], bl + mov byte ptr [msh3d+2], al + mov byte ptr [msh4d+3], bl + mov byte ptr [msh5d+2], al + mov byte ptr [msh6d+3], bl +CDECLENDSET 2 + ret + +ALIGN 16 +PUBLIC _mhline +_mhline: +CDECLBEGINSET 6 + ;_asm1 = bxinc + ;_asm2 = byinc + ;_asm3 = shadeoffs + ;eax = picoffs + ;ebx = bx + ;ecx = cnt + ;edx = ? + ;esi = by + ;edi = p + + mov dword ptr [mmach1d+2], eax + mov dword ptr [mmach5d+2], eax + mov dword ptr [mmach9d+2], eax + mov eax, _asm3 + mov dword ptr [mmach2d+2], eax + mov dword ptr [mmach2da+2], eax + mov dword ptr [mmach2db+2], eax + mov dword ptr [mmach6d+2], eax + mov dword ptr [mmach10d+2], eax + mov eax, _asm1 + mov dword ptr [mmach3d+2], eax + mov dword ptr [mmach7d+2], eax + mov eax, _asm2 + mov dword ptr [mmach4d+2], eax + mov dword ptr [mmach8d+2], eax + jmp short _mhlineskipmodify_nosetup + +ALIGN 16 +PUBLIC _mhlineskipmodify +_mhlineskipmodify: +CDECLBEGINSET 6 +_mhlineskipmodify_nosetup: + + push ebp + + xor eax, eax + mov ebp, ebx + + test ecx, 00010000h + jnz short mbeghline + +msh1d: shr ebx, 26 +msh2d: shld ebx, esi, 6 + add ebp, _asm1 +mmach9d: mov al, byte ptr [ebx+88888888h] ;picoffs + add esi, _asm2 + cmp al, 255 + je mskip5 + + mmach10d: mov cl, byte ptr [eax+88888888h] ;shadeoffs + mov byte ptr [edi], cl +mskip5: + inc edi + sub ecx, 65536 + jc mendhline + jmp short mbeghline + +ALIGN 16 +mpreprebeghline: ;1st only + mov al, cl +mmach2d: mov al, byte ptr [eax+88888888h] ;shadeoffs + mov byte ptr [edi], al + +mprebeghline: + add edi, 2 + sub ecx, 131072 + jc short mendhline +mbeghline: +mmach3d: lea ebx, [ebp+88888888h] ;bxinc +msh3d: shr ebp, 26 +msh4d: shld ebp, esi, 6 +mmach4d: add esi, 88888888h ;byinc +mmach1d: mov cl, byte ptr [ebp+88888888h] ;picoffs +mmach7d: lea ebp, [ebx+88888888h] ;bxinc + +msh5d: shr ebx, 26 +msh6d: shld ebx, esi, 6 +mmach8d: add esi, 88888888h ;byinc +mmach5d: mov ch, byte ptr [ebx+88888888h] ;picoffs + + cmp cl, 255 + je short mskip1 + cmp ch, 255 + je short mpreprebeghline + + mov al, cl ;BOTH +mmach2da: mov bl, byte ptr [eax+88888888h] ;shadeoffs + mov al, ch +mmach2db: mov bh, byte ptr [eax+88888888h] ;shadeoffs + mov word ptr [edi], bx + add edi, 2 + sub ecx, 131072 + jnc short mbeghline + jmp mendhline +mskip1: ;2nd only + cmp ch, 255 + je short mprebeghline + + mov al, ch +mmach6d: mov al, byte ptr [eax+88888888h] ;shadeoffs + mov byte ptr [edi+1], al + add edi, 2 + sub ecx, 131072 + jnc short mbeghline +mendhline: + + pop ebp +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _tsethlineshift +_tsethlineshift: +CDECLBEGINSET 2 + neg al + mov byte ptr [tsh1d+2], al + mov byte ptr [tsh2d+3], bl + mov byte ptr [tsh3d+2], al + mov byte ptr [tsh4d+3], bl + mov byte ptr [tsh5d+2], al + mov byte ptr [tsh6d+3], bl +CDECLENDSET 2 + ret + +ALIGN 16 +PUBLIC _thline +_thline: +CDECLBEGINSET 6 + ;_asm1 = bxinc + ;_asm2 = byinc + ;_asm3 = shadeoffs + ;eax = picoffs + ;ebx = bx + ;ecx = cnt + ;edx = ? + ;esi = by + ;edi = p + + mov dword ptr [tmach1d+2], eax + mov dword ptr [tmach5d+2], eax + mov dword ptr [tmach9d+2], eax + mov eax, _asm3 + mov dword ptr [tmach2d+2], eax + mov dword ptr [tmach6d+2], eax + mov dword ptr [tmach10d+2], eax + mov eax, _asm1 + mov dword ptr [tmach3d+2], eax + mov dword ptr [tmach7d+2], eax + mov eax, _asm2 + mov dword ptr [tmach4d+2], eax + mov dword ptr [tmach8d+2], eax + jmp short _thlineskipmodify_nosetup + +ALIGN 16 +PUBLIC _thlineskipmodify +_thlineskipmodify: +CDECLBEGINSET 6 +_thlineskipmodify_nosetup: + + push ebp + + xor eax, eax + xor edx, edx + mov ebp, ebx + + test ecx, 00010000h + jnz short tbeghline + +tsh1d: shr ebx, 26 +tsh2d: shld ebx, esi, 6 + add ebp, _asm1 +tmach9d: mov al, byte ptr [ebx+88888888h] ;picoffs + add esi, _asm2 + cmp al, 255 + je tskip5 + +transrev4: +tmach10d: mov dl, byte ptr [eax+88888888h] ;shadeoffs +transrev5: + mov dh, byte ptr [edi] +tmach1: mov al, byte ptr [edx+88888888h] ;_transluc + mov byte ptr [edi], al +tskip5: + inc edi + sub ecx, 65536 + jc tendhline + jmp short tbeghline + +ALIGN 16 +tprebeghline: + add edi, 2 + sub ecx, 131072 + jc short tendhline +tbeghline: +tmach3d: lea ebx, [ebp+88888888h] ;bxinc +tsh3d: shr ebp, 26 +tsh4d: shld ebp, esi, 6 +tmach4d: add esi, 88888888h ;byinc +tmach1d: mov cl, byte ptr [ebp+88888888h] ;picoffs +tmach7d: lea ebp, [ebx+88888888h] ;bxinc + +tsh5d: shr ebx, 26 +tsh6d: shld ebx, esi, 6 +tmach8d: add esi, 88888888h ;byinc +tmach5d: mov ch, byte ptr [ebx+88888888h] ;picoffs + + cmp cx, 0ffffh + je short tprebeghline + + mov bx, word ptr [edi] + + cmp cl, 255 + je short tskip1 + mov al, cl +transrev6: +tmach2d: mov dl, byte ptr [eax+88888888h] ;shadeoffs +transrev7: + mov dh, bl +tmach2: mov al, byte ptr [edx+88888888h] ;_transluc + mov byte ptr [edi], al + + cmp ch, 255 + je short tskip2 +tskip1: + mov al, ch +transrev8: +tmach6d: mov dl, byte ptr [eax+88888888h] ;shadeoffs +transrev9: + mov dh, bh +tmach3: mov al, byte ptr [edx+88888888h] ;_transluc + mov byte ptr [edi+1], al +tskip2: + + add edi, 2 + sub ecx, 131072 + jnc tbeghline +tendhline: + + pop ebp +CDECLENDSET 6 + ret + + + ;eax=shiftval, ebx=palookup1, ecx=palookup2 +ALIGN 16 +PUBLIC _setuptvlineasm2 +_setuptvlineasm2: +CDECLBEGINSET 3 + mov byte ptr [tran2shra+2], al + mov byte ptr [tran2shrb+2], al + mov dword ptr [tran2pala+2], ebx + mov dword ptr [tran2palb+2], ecx + mov dword ptr [tran2palc+2], ebx + mov dword ptr [tran2pald+2], ecx +CDECLENDSET 3 + ret + + ;Pass: eax=vplc2, ebx=vinc1, ecx=bufplc1, edx=bufplc2, esi=vplc1, edi=p + ; _asm1=vinc2, _asm2=pend + ;Return: _asm1=vplc1, _asm2=vplc2 +ALIGN 16 +PUBLIC _tvlineasm2 +_tvlineasm2: +CDECLBEGINSET 6 + + push ebp + + mov ebp, eax + + mov dword ptr [tran2inca+2], ebx + mov eax, _asm1 + mov dword ptr [tran2incb+2], eax + + mov dword ptr [tran2bufa+2], ecx ;bufplc1 + mov dword ptr [tran2bufb+2], edx ;bufplc2 + + mov eax, _asm2 + sub edi, eax + mov dword ptr [tran2edia+3], eax + mov dword ptr [tran2edic+2], eax + inc eax + mov dword ptr [tran2edie+2], eax +fixchaint2a: sub eax, 320 + mov dword ptr [tran2edif+2], eax + dec eax + mov dword ptr [tran2edib+3], eax + mov dword ptr [tran2edid+2], eax + + xor ecx, ecx + xor edx, edx + jmp short begintvline2 + + ;eax 0000000000 temp temp + ;ebx 0000000000 odat2 odat1 + ;ecx 0000000000000000 ndat1 + ;edx 0000000000000000 ndat2 + ;esi vplc1 + ;edi videoplc-------------- + ;ebp vplc2 + +ALIGN 16 + ;LEFT ONLY +skipdraw2: +transrev10: +tran2edic: mov ah, byte ptr [edi+88888888h] ;getpixel +transrev11: +tran2palc: mov al, byte ptr [ecx+88888888h] ;palookup1 +fixchaint2d: add edi, 320 +tran2trac: mov bl, byte ptr [eax+88888888h] ;_transluc +tran2edid: mov byte ptr [edi+88888888h-320], bl ;drawpixel + jnc short begintvline2 + jmp endtvline2 + +skipdraw1: + cmp dl, 255 + jne short skipdraw3 +fixchaint2b: add edi, 320 + jc short endtvline2 + +begintvline2: + mov eax, esi +tran2shra: shr eax, 88h ;globalshift + mov ebx, ebp +tran2shrb: shr ebx, 88h ;globalshift +tran2inca: add esi, 88888888h ;vinc1 +tran2incb: add ebp, 88888888h ;vinc2 +tran2bufa: mov cl, byte ptr [eax+88888888h] ;bufplc1 + cmp cl, 255 +tran2bufb: mov dl, byte ptr [ebx+88888888h] ;bufplc2 + je short skipdraw1 + cmp dl, 255 + je short skipdraw2 + + ;mov ax The transluscent reverse of both! + ;mov bl, ah + ;mov ah + ;mov bh + + ;BOTH +transrev12: +tran2edia: mov bx, word ptr [edi+88888888h] ;getpixels +transrev13: + mov ah, bl +transrev14: +tran2pala: mov al, byte ptr [ecx+88888888h] ;palookup1 +transrev15: +tran2palb: mov bl, byte ptr [edx+88888888h] ;palookup2 +fixchaint2c: add edi, 320 +tran2traa: mov al, byte ptr [eax+88888888h] ;_transluc +tran2trab: mov ah, byte ptr [ebx+88888888h] ;_transluc +tran2edib: mov word ptr [edi+88888888h-320], ax ;drawpixels + jnc short begintvline2 + jmp short endtvline2 + + ;RIGHT ONLY +skipdraw3: +transrev16: +tran2edie: mov ah, byte ptr [edi+88888889h] ;getpixel +transrev17: +tran2pald: mov al, byte ptr [edx+88888888h] ;palookup2 +fixchaint2e: add edi, 320 +tran2trad: mov bl, byte ptr [eax+88888888h] ;_transluc +tran2edif: mov byte ptr [edi+88888889h-320], bl ;drawpixel + jnc short begintvline2 + +endtvline2: + mov _asm1, esi + mov _asm2, ebp + + pop ebp + +CDECLENDSET 6 + ret + + +BITSOFPRECISION equ 3 +BITSOFPRECISIONPOW equ 8 + +;Double-texture mapping with palette lookup +;eax: ylo1------------|----dat|----dat +;ebx: ylo2--------------------|----cnt +;ecx: 000000000000000000000000|---temp +;edx: xhi1-xlo1---------------|---yhi1 +;esi: xhi2-xlo2---------------|---yhi2 +;edi: ------------------------videopos +;ebp: ----------------------------temp + +ALIGN 16 +PUBLIC _setupslopevlin2 +_setupslopevlin2: +CDECLBEGINSET 6 + + mov dword ptr [slop3+2], edx ;ptr + mov dword ptr [slop7+2], edx ;ptr + mov dword ptr [slop4+2], esi ;tptr + mov dword ptr [slop8+2], esi ;tptr + mov byte ptr [slop2+2], ah ;ybits + mov byte ptr [slop6+2], ah ;ybits + mov dword ptr [slop9+2], edi ;pinc + + mov edx, 1 + mov cl, al + add cl, ah + shl edx, cl + dec edx + mov cl, ah + ror edx, cl + + mov dword ptr [slop1+2], edx ;ybits...xbits + mov dword ptr [slop5+2], edx ;ybits...xbits + +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _slopevlin2 +_slopevlin2: +CDECLBEGINSET 6 + + push ebp + xor ecx, ecx + +slopevlin2begin: + mov ebp, edx +slop1: and ebp, 88000088h ;ybits...xbits +slop2: rol ebp, 6 ;ybits + add eax, _asm1 ;xinc1<>(32-xbits)) +slop3: mov cl, byte ptr [ebp+88888888h] ;bufplc + + mov ebp, esi +slop4: mov al, byte ptr [ecx+88888888h] ;paloffs +slop5: and ebp, 88000088h ;ybits...xbits +slop6: rol ebp, 6 ;ybits + add ebx, _asm3 ;xinc2<>(32-xbits)) +slop8: mov ah, byte ptr [ecx+88888888h] ;paloffs + + dec bl + mov word ptr [edi], ax +slop9: lea edi, [edi+88888888h] ;pinc + jnz short slopevlin2begin + + pop ebp + mov eax, edi + +CDECLENDSET 6 + ret + + +ALIGN 16 +PUBLIC _setupslopevlin +_setupslopevlin: +CDECLBEGINSET 3 + + mov dword ptr [slopmach3+3], ebx ;ptr + mov dword ptr [slopmach5+2], ecx ;pinc + neg ecx + mov dword ptr [slopmach6+2], ecx ;-pinc + + mov edx, 1 + mov cl, al + shl edx, cl + dec edx + mov cl, ah + shl edx, cl + mov dword ptr [slopmach7+2], edx + + neg ah + mov byte ptr [slopmach2+2], ah + + sub ah, al + mov byte ptr [slopmach1+2], ah + + fild dword ptr _asm1 + fstp dword ptr _asm2 + +CDECLENDSET 3 + ret + +ALIGN 16 +PUBLIC _slopevlin +_slopevlin: +CDECLBEGINSET 6 + + mov _ebpbak, ebp + mov _espbak, esp + + sub ecx, esp + mov dword ptr [slopmach4+3], ecx + + fild dword ptr _asm3 +slopmach6: lea ebp, [eax+88888888h] + fadd dword ptr _asm2 + + mov _asm1, ebx + shl ebx, 3 + + mov eax, _globalx3 + mov ecx, _globaly3 + imul eax, ebx + imul ecx, ebx + add esi, eax + add edi, ecx + + mov ebx, edx + jmp short bigslopeloop +ALIGN 16 +bigslopeloop: + fst dword ptr _fpuasm + + mov eax, _fpuasm + add eax, eax + sbb edx, edx + mov ecx, eax + shr ecx, 24 + and eax, 00ffe000h + shr eax, 11 + sub cl, 2 + mov eax, dword ptr _reciptable[eax] + shr eax, cl + xor eax, edx + mov edx, _asm1 + mov ecx, _globalx3 + mov _asm1, eax + sub eax, edx + mov edx, _globaly3 + imul ecx, eax + imul eax, edx + + fadd dword ptr _asm2 + + cmp ebx, BITSOFPRECISIONPOW + mov _asm4, ebx + mov cl, bl + jl short slopeskipmin + mov cl, BITSOFPRECISIONPOW +slopeskipmin: + +;eax: yinc............. +;ebx: 0 0 0 ? +;ecx: xinc......... cnt +;edx: ? +;esi: xplc............. +;edi: yplc............. +;ebp: videopos + + mov ebx, esi + mov edx, edi + +beginnerslopeloop: +slopmach1: shr ebx, 20 + add esi, ecx +slopmach2: shr edx, 26 +slopmach7: and ebx, 88888888h + add edi, eax +slopmach5: add ebp, 88888888h ;pinc +slopmach3: mov dl, byte ptr [ebx+edx+88888888h] ;ptr +slopmach4: mov ebx, dword ptr [esp+88888888h] + sub esp, 4 + dec cl + mov al, byte ptr [ebx+edx] ;tptr + mov ebx, esi + mov [ebp], al + mov edx, edi + jnz short beginnerslopeloop + + mov ebx, _asm4 + sub ebx, BITSOFPRECISIONPOW + jg bigslopeloop + + ffree st(0) + + mov esp, _espbak + mov ebp, _ebpbak + +CDECLENDSET 6 + ret + + +ALIGN 16 +PUBLIC _setuprhlineasm4 +_setuprhlineasm4: +CDECLBEGINSET 6 + + mov dword ptr [rmach1a+2], eax + mov dword ptr [rmach1b+2], eax + mov dword ptr [rmach1c+2], eax + mov dword ptr [rmach1d+2], eax + mov dword ptr [rmach1e+2], eax + + mov dword ptr [rmach2a+2], ebx + mov dword ptr [rmach2b+2], ebx + mov dword ptr [rmach2c+2], ebx + mov dword ptr [rmach2d+2], ebx + mov dword ptr [rmach2e+2], ebx + + mov dword ptr [rmach3a+2], ecx + mov dword ptr [rmach3b+2], ecx + mov dword ptr [rmach3c+2], ecx + mov dword ptr [rmach3d+2], ecx + mov dword ptr [rmach3e+2], ecx + + mov dword ptr [rmach4a+2], edx + mov dword ptr [rmach4b+2], edx + mov dword ptr [rmach4c+2], edx + mov dword ptr [rmach4d+2], edx + mov dword ptr [rmach4e+2], edx + + mov dword ptr [rmach5a+2], esi + mov dword ptr [rmach5b+2], esi + mov dword ptr [rmach5c+2], esi + mov dword ptr [rmach5d+2], esi + mov dword ptr [rmach5e+2], esi + +CDECLENDSET 6 + ret + + ;Non power of 2, non masking, with palookup method #1 (6 clock cycles) + ;eax: dat dat dat dat + ;ebx: bufplc + ;ecx: 0 dat + ;edx: xlo + ;esi: ylo + ;edi: videopos/cnt + ;ebp: tempvar + ;esp: +ALIGN 16 +PUBLIC _rhlineasm4 +_rhlineasm4: +CDECLBEGINSET 6 + + push ebp + + cmp eax, 0 + jle endrhline + + lea ebp, [edi-4] + sub ebp, eax + mov dword ptr [rmach6a+2], ebp + add ebp, 3 + mov dword ptr [rmach6b+2], ebp + mov edi, eax + test edi, 3 + jz short begrhline + jmp short startrhline1 + +ALIGN 16 +startrhline1: + mov cl, byte ptr [ebx] ;bufplc +rmach1e: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach2e: sub esi, 88888888h ;ylo +rmach3e: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach4e: mov al, byte ptr [ecx+88888888h] ;palookup +rmach5e: and ebp, 88888888h ;tilesizy +rmach6b: mov byte ptr [edi+88888888h], al ;vidcntoffs + sub ebx, ebp + dec edi + test edi, 3 + jnz short startrhline1 + test edi, edi + jz endrhline + +begrhline: + mov cl, byte ptr [ebx] ;bufplc +rmach1a: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach2a: sub esi, 88888888h ;ylo +rmach3a: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5a: and ebp, 88888888h ;tilesizy + sub ebx, ebp + +rmach1b: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach4a: mov ah, byte ptr [ecx+88888888h] ;palookup + mov cl, byte ptr [ebx] ;bufplc +rmach2b: sub esi, 88888888h ;ylo +rmach3b: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5b: and ebp, 88888888h ;tilesizy +rmach4b: mov al, byte ptr [ecx+88888888h] ;palookup + sub ebx, ebp + + shl eax, 16 + + mov cl, byte ptr [ebx] ;bufplc +rmach1c: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach2c: sub esi, 88888888h ;ylo +rmach3c: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5c: and ebp, 88888888h ;tilesizy + sub ebx, ebp + +rmach1d: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach4c: mov ah, byte ptr [ecx+88888888h] ;palookup + mov cl, byte ptr [ebx] ;bufplc +rmach2d: sub esi, 88888888h ;ylo +rmach3d: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5d: and ebp, 88888888h ;tilesizy +rmach4d: mov al, byte ptr [ecx+88888888h] ;palookup + sub ebx, ebp + +rmach6a: mov dword ptr [edi+88888888h], eax ;vidcntoffs + sub edi, 4 + jnz begrhline +endrhline: + pop ebp + +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _setuprmhlineasm4 +_setuprmhlineasm4: +CDECLBEGINSET 6 + mov dword ptr [rmmach1+2], eax + mov dword ptr [rmmach2+2], ebx + mov dword ptr [rmmach3+2], ecx + mov dword ptr [rmmach4+2], edx + mov dword ptr [rmmach5+2], esi +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _rmhlineasm4 +_rmhlineasm4: +CDECLBEGINSET 6 + + push ebp + + cmp eax, 0 + jle short endrmhline + + lea ebp, [edi-1] + sub ebp, eax + mov dword ptr [rmmach6+2], ebp + mov edi, eax + jmp short begrmhline + +ALIGN 16 +begrmhline: + mov cl, byte ptr [ebx] ;bufplc +rmmach1: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmmach2: sub esi, 88888888h ;ylo +rmmach3: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmmach5: and ebp, 88888888h ;tilesizy + cmp cl, 255 + je short rmskip +rmmach4: mov al, byte ptr [ecx+88888888h] ;palookup +rmmach6: mov byte ptr [edi+88888888h], al ;vidcntoffs +rmskip: + sub ebx, ebp + dec edi + jnz short begrmhline +endrmhline: + pop ebp + +CDECLENDSET 6 + ret + +ALIGN 16 +PUBLIC _setupqrhlineasm4 +_setupqrhlineasm4: +CDECLBEGINSET 6 + + mov dword ptr [qrmach2e+2], ebx + mov dword ptr [qrmach3e+2], ecx + xor edi, edi + sub edi, ecx + mov dword ptr [qrmach7a+2], edi + mov dword ptr [qrmach7b+2], edi + + add ebx, ebx + adc ecx, ecx + mov dword ptr [qrmach2a+2], ebx + mov dword ptr [qrmach2b+2], ebx + mov dword ptr [qrmach3a+2], ecx + mov dword ptr [qrmach3b+2], ecx + + mov dword ptr [qrmach4a+2], edx + mov dword ptr [qrmach4b+2], edx + mov dword ptr [qrmach4c+2], edx + mov dword ptr [qrmach4d+2], edx + mov dword ptr [qrmach4e+2], edx + +CDECLENDSET 6 + ret + + ;Non power of 2, non masking, with palookup method (FASTER BUT NO SBB'S) + ;eax: dat dat dat dat + ;ebx: bufplc + ;ecx: 0 dat + ;edx: 0 dat + ;esi: ylo + ;edi: videopos/cnt + ;ebp: ? + ;esp: +ALIGN 16 +PUBLIC _qrhlineasm4 ;4 pixels in 9 cycles! 2.25 cycles/pixel +_qrhlineasm4: +CDECLBEGINSET 6 + + push ebp + + cmp eax, 0 + jle endqrhline + + mov ebp, eax + test ebp, 3 + jz short skipqrhline1 + jmp short startqrhline1 + +ALIGN 16 +startqrhline1: + mov cl, byte ptr [ebx] ;bufplc + dec edi +qrmach2e: sub esi, 88888888h ;ylo + dec ebp +qrmach3e: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +qrmach4e: mov al, byte ptr [ecx+88888888h] ;palookup + mov byte ptr [edi], al ;vidcntoffs + test ebp, 3 + jnz short startqrhline1 + test ebp, ebp + jz short endqrhline + +skipqrhline1: + mov cl, byte ptr [ebx] ;bufplc + jmp short begqrhline +ALIGN 16 +begqrhline: +qrmach7a: mov dl, byte ptr [ebx+88888888h] ;bufplc +qrmach2a: sub esi, 88888888h ;ylo +qrmach3a: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +qrmach4a: mov ah, byte ptr [ecx+88888888h] ;palookup +qrmach4b: mov al, byte ptr [edx+88888888h] ;palookup + sub edi, 4 + shl eax, 16 + mov cl, byte ptr [ebx] ;bufplc +qrmach7b: mov dl, byte ptr [ebx+88888888h] ;bufplc +qrmach2b: sub esi, 88888888h ;ylo +qrmach3b: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +qrmach4c: mov ah, byte ptr [ecx+88888888h] ;palookup +qrmach4d: mov al, byte ptr [edx+88888888h] ;palookup + mov cl, byte ptr [ebx] ;bufplc + mov dword ptr [edi], eax + sub ebp, 4 + jnz short begqrhline + +endqrhline: + pop ebp + +CDECLENDSET 6 + ret + + +PUBLIC _setupdrawslab +_setupdrawslab: +CDECLBEGINSET 2 + + mov dword ptr [voxbpl1+2], eax + mov dword ptr [voxbpl2+2], eax + mov dword ptr [voxbpl3+2], eax + mov dword ptr [voxbpl4+2], eax + mov dword ptr [voxbpl5+2], eax + mov dword ptr [voxbpl6+2], eax + mov dword ptr [voxbpl7+2], eax + mov dword ptr [voxbpl8+2], eax + + mov dword ptr [voxpal1+2], ebx + mov dword ptr [voxpal2+2], ebx + mov dword ptr [voxpal3+2], ebx + mov dword ptr [voxpal4+2], ebx + mov dword ptr [voxpal5+2], ebx + mov dword ptr [voxpal6+2], ebx + mov dword ptr [voxpal7+2], ebx + mov dword ptr [voxpal8+2], ebx + +CDECLENDSET 2 + ret + +ALIGN 16 +PUBLIC _drawslab +_drawslab: +CDECLBEGINSET 6 + + push ebp + cmp eax, 2 + je voxbegdraw2 + ja voxskip2 + xor eax, eax +voxbegdraw1: + mov ebp, ebx + shr ebp, 16 + add ebx, edx + dec ecx + mov al, byte ptr [esi+ebp] +voxpal1: mov al, byte ptr [eax+88888888h] + mov byte ptr [edi], al +voxbpl1: lea edi, [edi+88888888h] + jnz voxbegdraw1 + pop ebp + +CDECLENDSET 6 + ret + +voxbegdraw2: + mov ebp, ebx + shr ebp, 16 + add ebx, edx + xor eax, eax + dec ecx + mov al, byte ptr [esi+ebp] +voxpal2: mov al, byte ptr [eax+88888888h] + mov ah, al + mov word ptr [edi], ax +voxbpl2: lea edi, [edi+88888888h] + jnz voxbegdraw2 + pop ebp + +CDECLENDSET 6 + ret + +voxskip2: + cmp eax, 4 + jne voxskip4 + xor eax, eax +voxbegdraw4: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal3: mov al, byte ptr [eax+88888888h] + mov ah, al + shl eax, 8 + mov al, ah + shl eax, 8 + mov al, ah + mov dword ptr [edi], eax +voxbpl3: add edi, 88888888h + dec ecx + jnz voxbegdraw4 + pop ebp + +CDECLENDSET 6 + ret + +voxskip4: + add eax, edi + + test edi, 1 + jz voxskipslab1 + cmp edi, eax + je voxskipslab1 + + push eax + push ebx + push ecx + push edi +voxbegslab1: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal4: mov al, byte ptr [eax+88888888h] + mov byte ptr [edi], al +voxbpl4: add edi, 88888888h + dec ecx + jnz voxbegslab1 + pop edi + pop ecx + pop ebx + pop eax + inc edi + +voxskipslab1: + push eax + test edi, 2 + jz voxskipslab2 + dec eax + cmp edi, eax + jge voxskipslab2 + + push ebx + push ecx + push edi +voxbegslab2: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal5: mov al, byte ptr [eax+88888888h] + mov ah, al + mov word ptr [edi], ax +voxbpl5: add edi, 88888888h + dec ecx + jnz voxbegslab2 + pop edi + pop ecx + pop ebx + add edi, 2 + +voxskipslab2: + mov eax, [esp] + + sub eax, 3 + cmp edi, eax + jge voxskipslab3 + +voxprebegslab3: + push ebx + push ecx + push edi +voxbegslab3: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal6: mov al, byte ptr [eax+88888888h] + mov ah, al + shl eax, 8 + mov al, ah + shl eax, 8 + mov al, ah + mov dword ptr [edi], eax +voxbpl6: add edi, 88888888h + dec ecx + jnz voxbegslab3 + pop edi + pop ecx + pop ebx + add edi, 4 + + mov eax, [esp] + + sub eax, 3 + cmp edi, eax + jl voxprebegslab3 + +voxskipslab3: + mov eax, [esp] + + dec eax + cmp edi, eax + jge voxskipslab4 + + push ebx + push ecx + push edi +voxbegslab4: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal7: mov al, byte ptr [eax+88888888h] + mov ah, al + mov word ptr [edi], ax +voxbpl7: add edi, 88888888h + dec ecx + jnz voxbegslab4 + pop edi + pop ecx + pop ebx + add edi, 2 + +voxskipslab4: + pop eax + + cmp edi, eax + je voxskipslab5 + +voxbegslab5: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal8: mov al, byte ptr [eax+88888888h] + mov byte ptr [edi], al +voxbpl8: add edi, 88888888h + dec ecx + jnz voxbegslab5 + +voxskipslab5: + pop ebp + +CDECLENDSET 6 + ret + +;modify: loinc +;eax: | dat | dat | dat | dat | +;ebx: | loplc1 | +;ecx: | loplc2 | cnthi | cntlo | +;edx: |--------|--------|--------| hiplc1 | +;esi: |--------|--------|--------| hiplc2 | +;edi: |--------|--------|--------| vidplc | +;ebp: |--------|--------|--------| hiinc | + +PUBLIC _stretchhline +_stretchhline: +CDECLBEGINSET 6 + + push ebp + + mov eax, ebx + shl ebx, 16 + sar eax, 16 + and ecx, 0000ffffh + or ecx, ebx + + add esi, eax + mov eax, edx + mov edx, esi + + mov ebp, eax + shl eax, 16 + sar ebp, 16 + + add ecx, eax + adc esi, ebp + + add eax, eax + adc ebp, ebp + mov dword ptr [loinc1+2], eax + mov dword ptr [loinc2+2], eax + mov dword ptr [loinc3+2], eax + mov dword ptr [loinc4+2], eax + + inc ch + + jmp begloop + +begloop: + mov al, [edx] +loinc1: sub ebx, 88888888h + sbb edx, ebp + mov ah, [esi] +loinc2: sub ecx, 88888888h + sbb esi, ebp + sub edi, 4 + shl eax, 16 +loinc3: sub ebx, 88888888h + mov al, [edx] + sbb edx, ebp + mov ah, [esi] +loinc4: sub ecx, 88888888h + sbb esi, ebp + mov [edi], eax + dec cl + jnz begloop + dec ch + jnz begloop + + pop ebp + +CDECLENDSET 6 + ret + + +PUBLIC _mmxoverlay +_mmxoverlay: + push ebx ;JBF + push ecx ;JBF + push edx ;JBF + + pushfd ;Check if CPUID is available + pop eax + mov ebx, eax + xor eax, 00200000h + push eax + popfd + pushfd + pop eax + cmp eax, ebx + je pentium + xor eax, eax + dw 0a20fh + test eax, eax + jz pentium + mov eax, 1 + dw 0a20fh + and eax, 00000f00h + test edx, 00800000h ;Check if MMX is available + jz nommx + cmp eax, 00000600h ;Check if P6 Family or not + jae pentiumii + jmp pentiummmx +nommx: + cmp eax, 00000600h ;Check if P6 Family or not + jae pentiumpro +pentium: + + pop edx ;JBF + pop ecx ;JBF + pop ebx ;JBF + ret + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PENTIUM II Overlays ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +pentiumii: + ;Hline overlay (MMX doens't help) + mov byte ptr [_sethlinesizes], 0e9h + mov dword ptr [_sethlinesizes+1], (offset _prosethlinesizes)-(offset _sethlinesizes)-5 + mov byte ptr [_setpalookupaddress], 0e9h + mov dword ptr [_setpalookupaddress+1], (offset _prosetpalookupaddress)-(offset _setpalookupaddress)-5 + mov byte ptr [_setuphlineasm4], 0c3h ;ret (no code required) + mov byte ptr [_hlineasm4], 0e9h + mov dword ptr [_hlineasm4+1], (offset _prohlineasm4)-(offset _hlineasm4)-5 + + ;Vline overlay + mov byte ptr [_setupvlineasm], 0e9h + mov dword ptr [_setupvlineasm+1], (offset _prosetupvlineasm)-(offset _setupvlineasm)-5 + mov byte ptr [_vlineasm4], 0e9h + mov dword ptr [_vlineasm4+1], (offset _provlineasm4)-(offset _vlineasm4)-5 + + pop edx ;JBF + pop ecx ;JBF + pop ebx ;JBF + ret + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PENTIUM MMX Overlays ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +pentiummmx: + pop edx ;JBF + pop ecx ;JBF + pop ebx ;JBF + ret + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PENTIUM PRO Overlays ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +pentiumpro: + ;Hline overlay (MMX doens't help) + mov byte ptr [_sethlinesizes], 0e9h + mov dword ptr [_sethlinesizes+1], (offset _prosethlinesizes)-(offset _sethlinesizes)-5 + mov byte ptr [_setpalookupaddress], 0e9h + mov dword ptr [_setpalookupaddress+1], (offset _prosetpalookupaddress)-(offset _setpalookupaddress)-5 + mov byte ptr [_setuphlineasm4], 0c3h ;ret (no code required) + mov byte ptr [_hlineasm4], 0e9h + mov dword ptr [_hlineasm4+1], (offset _prohlineasm4)-(offset _hlineasm4)-5 + + ;Vline overlay + mov byte ptr [_setupvlineasm], 0e9h + mov dword ptr [_setupvlineasm+1], (offset _prosetupvlineasm)-(offset _setupvlineasm)-5 + mov byte ptr [_vlineasm4], 0e9h + mov dword ptr [_vlineasm4+1], (offset _provlineasm4)-(offset _vlineasm4)-5 + + pop edx ;JBF + pop ecx ;JBF + pop ebx ;JBF + ret + +CODE ENDS +END diff --git a/polymer/build/src/a.nasm b/polymer/build/src/a.nasm new file mode 100644 index 000000000..9ac5dbb21 --- /dev/null +++ b/polymer/build/src/a.nasm @@ -0,0 +1,2751 @@ +; "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) + +;CPU 586 + +SECTION .data + +%ifdef UNDERSCORES +%define asm1 _asm1 +%define asm2 _asm2 +%define asm3 _asm3 +%define asm4 _asm4 +%define reciptable _reciptable +%define fpuasm _fpuasm +%define globalx3 _globalx3 +%define globaly3 _globaly3 +%define ylookup _ylookup +%define vplce _vplce +%define vince _vince +%define palookupoffse _palookupoffse +%define bufplce _bufplce +%define ebpbak _ebpbak +%define espbak _espbak +%define pow2char _pow2char +%define pow2long _pow2long + +%define sethlinesizes _sethlinesizes +%define prosethlinesizes _prosethlinesizes +%define setvlinebpl _setvlinebpl +%define setpalookupaddress _setpalookupaddress +%define prosetpalookupaddress _prosetpalookupaddress +%define setuphlineasm4 _setuphlineasm4 +%define hlineasm4 _hlineasm4 +%define prohlineasm4 _prohlineasm4 +%define prosetuphlineasm4 _prosetupvlineasm +%define setupmvlineasm _setupmvlineasm +%define setuptvlineasm _setuptvlineasm +%define prevlineasm1 _prevlineasm1 +%define vlineasm1 _vlineasm1 +%define mvlineasm1 _mvlineasm1 +%define fixtransluscence _fixtransluscence +%define settransnormal _settransnormal +%define settransreverse _settransreverse +%define tvlineasm1 _tvlineasm1 +%define vlineasm4 _vlineasm4 +%define provlineasm4 _provlineasm4 +%define setupvlineasm _setupvlineasm +%define mvlineasm4 _mvlineasm4 +%define setupspritevline _setupspritevline +%define spritevline _spritevline +%define msetupspritevline _msetupspritevline +%define mspritevline _mspritevline +%define tsetupspritevline _tsetupspritevline +%define tspritevline _tspritevline +%define msethlineshift _msethlineshift +%define mhline _mhline +%define mhlineskipmodify _mhlineskipmodify +%define tsethlineshift _tsethlineshift +%define thline _thline +%define thlineskipmodify _thlineskipmodify +%define setuptvlineasm2 _setuptvlineasm2 +%define tvlineasm2 _tvlineasm2 +%define setupslopevlin2 _setupslopevlin2 +%define slopevlin2 _slopevlin2 +%define setupslopevlin _setupslopevlin +%define slopevlin _slopevlin +%define setuprhlineasm4 _setuprhlineasm4 +%define rhlineasm4 _rhlineasm4 +%define setuprmhlineasm4 _setuprmhlineasm4 +%define rmhlineasm4 _rmhlineasm4 +%define setupqrhlineasm4 _setupqrhlineasm4 +%define qrhlineasm4 _qrhlineasm4 +%define setupdrawslab _setupdrawslab +%define drawslab _drawslab +%define stretchhline _stretchhline +%define mmxoverlay _mmxoverlay + +%endif + +; Some macros to help make cdecl calling easier to manage +%macro CDECLBEGIN 1 +%if %1 >= 2 + push ebx +%endif +%if %1 >= 3 + push ecx +%endif +%if %1 >= 4 + push edx +%endif +%if %1 >= 5 + push esi +%endif +%if %1 >= 6 + push edi +%endif +%endmacro + +%macro CDECLEND 1 +%if %1 >= 6 + pop edi +%endif +%if %1 >= 5 + pop esi +%endif +%if %1 >= 4 + pop edx +%endif +%if %1 >= 3 + pop ecx +%endif +%if %1 >= 2 + pop ebx +%endif +%endmacro + +%macro CDECLPARAM 3 +; mov %1, dword [esp + (%2*4+16)] + mov %1, dword [esp + ((%2+%3)*4+4)] +%endmacro + +%macro CDECLBEGINSET 1 + CDECLBEGIN %1 + +%assign _offsetted %1-1 + +%if %1 >= 1 + CDECLPARAM eax,0,_offsetted +%endif +%if %1 >= 2 + CDECLPARAM ebx,1,_offsetted +%endif +%if %1 >= 3 + CDECLPARAM ecx,2,_offsetted +%endif +%if %1 >= 4 + CDECLPARAM edx,3,_offsetted +%endif +%if %1 >= 5 + CDECLPARAM esi,4,_offsetted +%endif +%if %1 >= 6 + CDECLPARAM edi,5,_offsetted +%endif +%endmacro + +%macro CDECLENDSET 1 + CDECLEND %1 +%endmacro + + + EXTERN asm1 + EXTERN asm2 + EXTERN asm3 + EXTERN asm4 + EXTERN reciptable + EXTERN fpuasm + EXTERN globalx3 + EXTERN globaly3 + EXTERN ylookup + + EXTERN vplce + EXTERN vince + EXTERN palookupoffse + EXTERN bufplce + + EXTERN ebpbak + EXTERN espbak + + EXTERN pow2char + EXTERN pow2long + + GLOBAL sethlinesizes + GLOBAL prosethlinesizes + GLOBAL setvlinebpl + GLOBAL setpalookupaddress + GLOBAL prosetpalookupaddress + GLOBAL setuphlineasm4 + GLOBAL hlineasm4 + GLOBAL prohlineasm4 + GLOBAL prosetupvlineasm + GLOBAL setupmvlineasm + GLOBAL setuptvlineasm + GLOBAL prevlineasm1 + GLOBAL vlineasm1 + GLOBAL mvlineasm1 ;Masked vline + GLOBAL fixtransluscence + GLOBAL settransnormal + GLOBAL settransreverse + GLOBAL tvlineasm1 ;Masked & transluscent vline + GLOBAL vlineasm4 + GLOBAL provlineasm4 + GLOBAL setupvlineasm + GLOBAL mvlineasm4 + GLOBAL setupspritevline + GLOBAL spritevline + GLOBAL msetupspritevline + GLOBAL mspritevline + GLOBAL tsetupspritevline + GLOBAL tspritevline + GLOBAL msethlineshift + GLOBAL mhline + GLOBAL mhlineskipmodify + GLOBAL tsethlineshift + GLOBAL thline + GLOBAL thlineskipmodify + GLOBAL setuptvlineasm2 + GLOBAL tvlineasm2 + GLOBAL setupslopevlin2 + GLOBAL slopevlin2 + GLOBAL setupslopevlin + GLOBAL slopevlin + GLOBAL setuprhlineasm4 + GLOBAL rhlineasm4 + GLOBAL setuprmhlineasm4 + GLOBAL rmhlineasm4 + GLOBAL setupqrhlineasm4 + GLOBAL qrhlineasm4 ;4 pixels in 9 cycles! 2.25 cycles/pixel + GLOBAL setupdrawslab + GLOBAL drawslab + GLOBAL stretchhline + GLOBAL mmxoverlay + + + ALIGN 16 +sethlinesizes: +CDECLBEGINSET 3 + + mov byte [machxbits1+2], al + mov byte [machxbits2+2], al + mov byte [machxbits3+2], al + neg al + mov byte [hxsiz1+2], al + mov byte [hxsiz2+2], al + mov byte [hxsiz3+2], al + mov byte [hxsiz4+2], al + mov byte [machnegxbits1+2], al + + mov byte [hysiz1+3], bl + mov byte [hysiz2+3], bl + mov byte [hysiz3+3], bl + mov byte [hysiz4+3], bl + mov byte [hmach3a+2], bl + mov byte [hmach3b+2], bl + mov byte [hmach3c+2], bl + mov byte [hmach3d+2], bl + + mov dword [hoffs1+2], ecx + mov dword [hoffs2+2], ecx + mov dword [hoffs3+2], ecx + mov dword [hoffs4+2], ecx + mov dword [hoffs5+2], ecx + mov dword [hoffs6+2], ecx + mov dword [hoffs7+2], ecx + mov dword [hoffs8+2], ecx + + push edx ;JBF + mov edx, -1 + mov cl, al + sub cl, bl + shr edx, cl + mov dword [hmach2a+1], edx + mov dword [hmach2b+1], edx + mov dword [hmach2c+1], edx + mov dword [hmach2d+1], edx + pop edx ;JBF + +CDECLENDSET 3 + ret + + + ALIGN 16 +prosethlinesizes: +CDECLBEGINSET 3 + + mov dword [prohbuf-4], ecx + neg eax + mov ecx, eax + sub eax, ebx + mov byte [prohshru-1], al ;bl = 32-al-bl + mov eax, -1 + shr eax, cl + mov ecx, ebx + shl eax, cl + mov dword [prohand-4], eax ;((-1>>(-oal))<>(32-xbits) adc al, 88h 1 1/2 + ;bufplc mov cl, byte [edx+88888888h] 1 1/2 + ;paloffs&255 mov bl, byte [ecx+88888888h] 1 1/2 + ALIGN 16 +hlineasm4: +CDECLBEGINSET 6 + + push ebp + + lea ebp, [eax+1] + + cmp ebp, 8 + jle near shorthline + + test edi, 1 + jnz short skipthe1byte + + mov eax, esi +hxsiz1: shr eax, 26 +hysiz1: shld eax, edx, 6 +hoffs1: mov cl, byte [eax+88888888h] +pal1: mov bl, byte [ecx+88888888h] + sub esi, dword [asm1] + sub edx, dword [asm2] + mov byte [edi], bl + dec edi + dec ebp + +skipthe1byte: + test edi, 2 + jnz short skipthe2byte + + mov eax, esi +hxsiz2: shr eax, 26 +hysiz2: shld eax, edx, 6 +hoffs2: mov cl, byte [eax+88888888h] +pal2: mov bh, byte [ecx+88888888h] + sub esi, dword [asm1] + sub edx, dword [asm2] + + mov eax, esi +hxsiz3: shr eax, 26 +hysiz3: shld eax, edx, 6 +hoffs3: mov cl, byte [eax+88888888h] +pal3: mov bl, byte [ecx+88888888h] + sub esi, dword [asm1] + sub edx, dword [asm2] + mov word [edi-1], bx + sub edi, 2 + sub ebp, 2 + +skipthe2byte: + + mov eax, esi +machxbits1: shl esi, 6 ;xbits +machnegxbits1: shr eax, 32-6 ;32-xbits + mov dl, al + + inc edi + + add ebx, ebx + mov eax, edx + jc beginhline64 + + mov eax, dword [asm1] +machxbits2: rol eax, 6 ;xbits + mov dword [hmach4a+2], eax + mov dword [hmach4b+2], eax + mov dword [hmach4c+2], eax + mov dword [hmach4d+2], eax + mov ebx, eax + mov eax, dword [asm2] + mov al, bl + mov dword [hmach1a+2], eax + mov dword [hmach1b+2], eax + mov dword [hmach1c+2], eax + mov dword [hmach1d+2], eax + + mov eax, edx + jmp beginhline64 +ALIGN 16 +prebeginhline64: + mov dword [edi], ebx +beginhline64: + +hmach3a: rol eax, 6 +hmach2a: and eax, 00008888h +hmach4a: sub esi, 88888888h +hmach1a: sbb edx, 88888888h + sub edi, 4 +hoffs4: mov cl, byte [eax+88888888h] + mov eax, edx + +hmach3b: rol eax, 6 +hmach2b: and eax, 00008888h +hmach4b: sub esi, 88888888h +hmach1b: sbb edx, 88888888h +pal4: mov bh, byte [ecx+88888888h] +hoffs5: mov cl, byte [eax+88888888h] + mov eax, edx + +hmach3c: rol eax, 6 +pal5: mov bl, byte [ecx+88888888h] +hmach2c: and eax, 00008888h + shl ebx, 16 +hmach4c: sub esi, 88888888h +hmach1c: sbb edx, 88888888h +hoffs6: mov cl, byte [eax+88888888h] + + mov eax, edx + ;( + +hmach3d: rol eax, 6 +hmach2d: and eax, 00008888h +hmach4d: sub esi, 88888888h +hmach1d: sbb edx, 88888888h +pal6: mov bh, byte [ecx+88888888h] +hoffs7: mov cl, byte [eax+88888888h] + mov eax, edx + sub ebp, 4 + nop +pal7: mov bl, byte [ecx+88888888h] + jnc near prebeginhline64 +skipthe4byte: + + test ebp, 2 + jz skipdrawthe2 + rol ebx, 16 + mov word [edi+2], bx + sub edi, 2 +skipdrawthe2: + test ebp, 1 + jz skipdrawthe1 + shr ebx, 24 + mov byte [edi+3], bl +skipdrawthe1: + + pop ebp +CDECLENDSET 6 + ret + +shorthline: + test ebp, ebp + jz endshorthline +begshorthline: + mov eax, esi +hxsiz4: shr eax, 26 +hysiz4: shld eax, edx, 6 +hoffs8: mov cl, byte [eax+88888888h] +pal8: mov bl, byte [ecx+88888888h] + sub esi, dword [asm1] + sub edx, dword [asm2] + mov byte [edi], bl + dec edi + dec ebp + jnz near begshorthline +endshorthline: + pop ebp +CDECLENDSET 6 + ret + + + ;eax: 00000000 00000000 00000000 temp---- + ;ebx: 00000000 00000000 00000000 temp---- + ;ecx: UUUUUUuu uuuuuuuu uuuuuuuu uuuuuuuu + ;edx: VVVVVVvv vvvvvvvv vvvvvvvv vvvvvvvv + ;esi: cnt----- -------- -------- -------- + ;edi: vid----- -------- -------- -------- + ;ebp: paloffs- -------- -------- -------- + ;esp: ???????? ???????? ???????? ???????? + ALIGN 16 +prohlineasm4: +CDECLBEGINSET 6 + + push ebp + + lea ebp, [ecx+88888888h] +prohpala: + mov ecx, esi + lea esi, [eax+1] + sub edi, esi + +prohbeg: + mov eax, ecx + shr eax, 20 +prohshru: + mov ebx, edx + shr ebx, 26 +prohshrv: + and eax, 88888888h +prohand: + movzx eax, byte [eax+ebx+88888888h] +prohbuf: + mov al, [eax+ebp] + sub ecx, dword [asm1] + sub edx, dword [asm2] + mov [edi+esi], al + dec esi + jnz prohbeg + + pop ebp +CDECLENDSET 6 + ret + + + + ALIGN 16 +setupvlineasm: +CDECLBEGINSET 1 + ;First 2 lines for VLINEASM1, rest for VLINEASM4 + mov byte [premach3a+2], al + mov byte [mach3a+2], al + + push ecx + mov byte [machvsh1+2], al ;32-shy + mov byte [machvsh3+2], al ;32-shy + mov byte [machvsh5+2], al ;32-shy + mov byte [machvsh6+2], al ;32-shy + mov ah, al + sub ah, 16 + mov byte [machvsh8+2], ah ;16-shy + neg al + mov byte [machvsh7+2], al ;shy + mov byte [machvsh9+2], al ;shy + mov byte [machvsh10+2], al ;shy + mov byte [machvsh11+2], al ;shy + mov byte [machvsh12+2], al ;shy + mov cl, al + mov eax, 1 + shl eax, cl + dec eax + mov dword [machvsh2+2], eax ;(1<>sh) + ;vplc3 = (ebp<<(32-sh))+((edx&65535)<<(16-sh)) +machvsh5: shl esi, 88h ;32-sh + mov eax, edx +machvsh6: shl ebp, 88h ;32-sh + and edx, 0000ffffh +machvsh7: shr eax, 88h ;sh + add esi, eax +machvsh8: shl edx, 88h ;16-sh + add ebp, edx + mov dword [vplce+12], esi + mov dword [vplce+4], ebp + + pop ebp +CDECLEND 6 + ret + + ;eax: -------temp1------- + ;ebx: -------temp2------- + ;ecx: ylo4 --------- + ;edx: ylo2 --------- + ;esi: yhi1 yhi2 + ;edi: ---videoplc/cnt---- + ;ebp: yhi3 yhi4 + ;esp: + ALIGN 16 +provlineasm4: +CDECLBEGIN 6 +CDECLPARAM ecx,0,5 +CDECLPARAM edi,1,5 + push ebp + + mov eax, dword [ylookup+ecx*4] + add eax, edi + mov dword [promachvline4end1+2], eax + inc eax + mov dword [promachvline4end2+2], eax + inc eax + mov dword [promachvline4end3+2], eax + inc eax + mov dword [promachvline4end4+2], eax + sub eax, 3 + sub edi, eax + + mov eax, dword [bufplce] + mov ebx, dword [bufplce+4] + mov ecx, dword [bufplce+8] + mov edx, dword [bufplce+12] + mov dword [promachvbuf1+3], ecx + mov dword [promachvbuf2+3], edx + mov dword [promachvbuf3+3], eax + mov dword [promachvbuf4+3], ebx + + mov eax, dword [palookupoffse] + mov ebx, dword [palookupoffse+4] + mov ecx, dword [palookupoffse+8] + mov edx, dword [palookupoffse+12] + mov dword [promachvpal1+2], ecx + mov dword [promachvpal2+2], edx + mov dword [promachvpal3+2], eax + mov dword [promachvpal4+2], ebx + + ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + ;edx: ³v3lo ³v1lo ³ + ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄ´ + ;esi: ³v2hi v2lo ³ v3hi³ + ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ´ + ;ebp: ³v0hi v0lo ³ v1hi³ + ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ + + mov ebp, dword [vince] + mov ebx, dword [vince+4] + mov esi, dword [vince+8] + mov eax, dword [vince+12] + and esi, 0fffffe00h + and ebp, 0fffffe00h +promachvsh9: rol eax, 88h ;sh +promachvsh10: rol ebx, 88h ;sh + mov edx, eax + mov ecx, ebx + shr ecx, 16 + and edx, 0ffff0000h + add edx, ecx + and eax, 000001ffh + and ebx, 000001ffh + add esi, eax + add ebp, ebx + ; + mov eax, edx + and eax, 0ffff0000h + mov dword [promachvinc1+2], eax + mov dword [promachvinc2+2], esi + shl edx, 16 + mov dword [promachvinc3+2], edx + mov dword [promachvinc5+2], ebp + + mov ebp, dword [vplce] + mov ebx, dword [vplce+4] + mov esi, dword [vplce+8] + mov eax, dword [vplce+12] + and esi, 0fffffe00h + and ebp, 0fffffe00h +promachvsh11: rol eax, 88h ;sh +promachvsh12: rol ebx, 88h ;sh + mov edx, eax + mov ecx, ebx + shr ecx, 16 + and edx, 0ffff0000h + add edx, ecx + and eax, 000001ffh + and ebx, 000001ffh + add esi, eax + add ebp, ebx + + mov eax, esi + mov ecx, edx + shl ecx, 16 + jmp short probeginvlineasm4 +ALIGN 16 + nop + nop + nop +probeginvlineasm4: +promachvsh1: shr eax, 88h ;32-sh + mov ebx, esi +promachvsh2: and ebx, 00000088h ;(1<>sh) + ;vplc3 = (ebp<<(32-sh))+((edx&65535)<<(16-sh)) +promachvsh5: shl esi, 88h ;32-sh + mov eax, edx +promachvsh6: shl ebp, 88h ;32-sh + and edx, 0000ffffh +promachvsh7: shr eax, 88h ;sh + add esi, eax +promachvsh8: shl edx, 88h ;16-sh + add ebp, edx + mov dword [vplce+12], esi + mov dword [vplce+4], ebp + + pop ebp +CDECLEND 6 + ret + + + ALIGN 16 +mvlineasm4: +CDECLBEGIN 6 +CDECLPARAM ecx,0,5 +CDECLPARAM edi,1,5 + + push ebp + + mov eax, dword [bufplce] + mov ebx, dword [bufplce+4] + mov dword [machmv1+2], eax + mov dword [machmv4+2], ebx + mov eax, dword [bufplce+8] + mov ebx, dword [bufplce+12] + mov dword [machmv7+2], eax + mov dword [machmv10+2], ebx + + mov eax, dword [palookupoffse] + mov ebx, dword [palookupoffse+4] + mov dword [machmv2+2], eax + mov dword [machmv5+2], ebx + mov eax, dword [palookupoffse+8] + mov ebx, dword [palookupoffse+12] + mov dword [machmv8+2], eax + mov dword [machmv11+2], ebx + + mov eax, dword [vince] + mov ebx, dword [vince+4] + xor al, al + xor bl, bl + mov dword [machmv3+2], eax + mov dword [machmv6+2], ebx + mov eax, dword [vince+8] + mov ebx, dword [vince+12] + mov dword [machmv9+2], eax + mov dword [machmv12+2], ebx + + mov ebx, ecx + mov ecx, dword [vplce] + mov edx, dword [vplce+4] + mov esi, dword [vplce+8] + mov ebp, dword [vplce+12] + mov cl, bl + inc cl + inc bh + mov byte [asm3], bh +fixchain2ma: sub edi, 320 + + jmp short beginmvlineasm4 +ALIGN 16 +beginmvlineasm4: + dec cl + jz near endmvlineasm4 +beginmvlineasm42: + mov eax, ebp + mov ebx, esi +machmv16: shr eax, 32 +machmv15: shr ebx, 32 +machmv12: add ebp, 88888888h ;vince[3] +machmv9: add esi, 88888888h ;vince[2] +machmv10: mov al, byte [eax+88888888h] ;bufplce[3] +machmv7: mov bl, byte [ebx+88888888h] ;bufplce[2] + cmp al, 255 + adc dl, dl + cmp bl, 255 + adc dl, dl +machmv8: mov bl, byte [ebx+88888888h] ;palookupoffs[2] +machmv11: mov bh, byte [eax+88888888h] ;palookupoffs[3] + + mov eax, edx +machmv14: shr eax, 32 + shl ebx, 16 +machmv4: mov al, byte [eax+88888888h] ;bufplce[1] + cmp al, 255 + adc dl, dl +machmv6: add edx, 88888888h ;vince[1] +machmv5: mov bh, byte [eax+88888888h] ;palookupoffs[1] + + mov eax, ecx +machmv13: shr eax, 32 +machmv3: add ecx, 88888888h ;vince[0] +machmv1: mov al, byte [eax+88888888h] ;bufplce[0] + cmp al, 255 + adc dl, dl +machmv2: mov bl, byte [eax+88888888h] ;palookupoffs[0] + + shl dl, 4 + xor eax, eax +fixchain2mb: add edi, 320 + mov al, dl + add eax, mvcase0 + jmp eax ;16 byte cases + +ALIGN 16 +endmvlineasm4: + dec byte [asm3] + jnz near beginmvlineasm42 ;near + + mov dword [vplce], ecx + mov dword [vplce+4], edx + mov dword [vplce+8], esi + mov dword [vplce+12], ebp + pop ebp +CDECLEND 6 + ret + + ;5,7,8,8,11,13,12,14,11,13,14,14,12,14,15,7 +ALIGN 16 +mvcase0: + jmp beginmvlineasm4 +ALIGN 16 +mvcase1: + mov byte [edi], bl + jmp beginmvlineasm4 +ALIGN 16 +mvcase2: + mov byte [edi+1], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase3: + mov word [edi], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase4: + shr ebx, 16 + mov byte [edi+2], bl + jmp beginmvlineasm4 +ALIGN 16 +mvcase5: + mov byte [edi], bl + shr ebx, 16 + mov byte [edi+2], bl + jmp beginmvlineasm4 +ALIGN 16 + mvcase6: + shr ebx, 8 + mov word [edi+1], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase7: + mov word [edi], bx + shr ebx, 16 + mov byte [edi+2], bl + jmp beginmvlineasm4 +ALIGN 16 +mvcase8: + shr ebx, 16 + mov byte [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase9: + mov byte [edi], bl + shr ebx, 16 + mov byte [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase10: + mov byte [edi+1], bh + shr ebx, 16 + mov byte [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase11: + mov word [edi], bx + shr ebx, 16 + mov byte [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase12: + shr ebx, 16 + mov word [edi+2], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase13: + mov byte [edi], bl + shr ebx, 16 + mov word [edi+2], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase14: + mov byte [edi+1], bh + shr ebx, 16 + mov word [edi+2], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase15: + mov dword [edi], ebx + jmp beginmvlineasm4 + + + ALIGN 16 +setupspritevline: +CDECLBEGINSET 6 + + mov dword [spal+2], eax + + mov eax, esi ;xinc's + shl eax, 16 + mov dword [smach1+2], eax + mov dword [smach4+2], eax + mov eax, esi + sar eax, 16 + add eax, ebx ;watch out with ebx - it's passed + mov dword [smach2+2], eax + add eax, edx + mov dword [smach5+2], eax + + mov dword [smach3+2], ecx ;yinc's + +CDECLENDSET 6 + ret + + + ALIGN 16 +spritevline: +CDECLBEGINSET 6 + jmp short spritevline_start + ;eax = 0, ebx = x, ecx = cnt, edx = y, esi = yplc, edi = p +prestartsvline: +smach1: add ebx, 88888888h ;xincshl16 + mov al, byte [esi] +smach2: adc esi, 88888888h ;xincshr16+yalwaysinc + +startsvline: +spal: mov al, [eax+88888888h] ;palookup + mov byte [edi], al +fixchain1s: add edi, 320 + +spritevline_start: +smach3: add edx, 88888888h ;dayinc + dec ecx + ja short prestartsvline ;jump if (no carry (add)) and (not zero (dec))! + jz short endsvline +smach4: add ebx, 88888888h ;xincshl16 + mov al, byte [esi] +smach5: adc esi, 88888888h ;xincshr16+yalwaysinc+daydime + jmp short startsvline +endsvline: +CDECLENDSET 6 + ret + + + ALIGN 16 +msetupspritevline: +CDECLBEGINSET 6 + + mov dword [mspal+2], eax + + mov eax, esi ;xinc's + shl eax, 16 + mov dword [msmach1+2], eax + mov dword [msmach4+2], eax + mov eax, esi + sar eax, 16 + add eax, ebx ;watch out with ebx - it's passed + mov dword [msmach2+2], eax + add eax, edx + mov dword [msmach5+2], eax + + mov dword [msmach3+2], ecx ;yinc's + +CDECLENDSET 6 + ret + + + ALIGN 16 +mspritevline: +CDECLBEGINSET 6 + jmp short mspritevline_start + ;eax = 0, ebx = x, ecx = cnt, edx = y, esi = yplc, edi = p +mprestartsvline: +msmach1: add ebx, 88888888h ;xincshl16 + mov al, byte [esi] +msmach2: adc esi, 88888888h ;xincshr16+yalwaysinc + +mstartsvline: + cmp al, 255 + je short mskipsvline +mspal: mov al, [eax+88888888h] ;palookup + mov byte [edi], al +mskipsvline: +mfixchain1s: add edi, 320 + +mspritevline_start: +msmach3: add edx, 88888888h ;dayinc + dec ecx + ja short mprestartsvline ;jump if (no carry (add)) and (not zero (dec))! + jz short mendsvline +msmach4: add ebx, 88888888h ;xincshl16 + mov al, byte [esi] +msmach5: adc esi, 88888888h ;xincshr16+yalwaysinc+daydime + jmp short mstartsvline +mendsvline: +CDECLENDSET 6 + ret + + + ALIGN 16 +tsetupspritevline: +CDECLBEGINSET 6 + mov dword [tspal+2], eax + + mov eax, esi ;xinc's + shl eax, 16 + mov dword [tsmach1+2], eax + mov dword [tsmach4+2], eax + mov eax, esi + sar eax, 16 + add eax, ebx ;watch out with ebx - it's passed + mov dword [tsmach2+2], eax + add eax, edx + mov dword [tsmach5+2], eax + + mov dword [tsmach3+2], ecx ;yinc's +CDECLENDSET 6 + ret + + + ALIGN 16 +tspritevline: +CDECLBEGINSET 6 + ;eax = 0, ebx = x, ecx = cnt, edx = y, esi = yplc, edi = p + push ebp + mov ebp, ebx + xor ebx, ebx + jmp tenterspritevline +ALIGN 16 +tprestartsvline: +tsmach1: add ebp, 88888888h ;xincshl16 + mov al, byte [esi] +tsmach2: adc esi, 88888888h ;xincshr16+yalwaysinc + +tstartsvline: + cmp al, 255 + je short tskipsvline +transrev2: + mov bh, byte [edi] +transrev3: +tspal: mov bl, [eax+88888888h] ;palookup +tmach4: mov al, byte [ebx+88888888h] ;_transluc + mov byte [edi], al +tskipsvline: +tfixchain1s: add edi, 320 + +tenterspritevline: +tsmach3: add edx, 88888888h ;dayinc + dec ecx + ja short tprestartsvline ;jump if (no carry (add)) and (not zero (dec))! + jz short tendsvline +tsmach4: add ebp, 88888888h ;xincshl16 + mov al, byte [esi] +tsmach5: adc esi, 88888888h ;xincshr16+yalwaysinc+daydime + jmp short tstartsvline +tendsvline: + pop ebp +CDECLENDSET 6 + ret + + + ALIGN 16 +msethlineshift: +CDECLBEGINSET 2 + neg al + mov byte [msh1d+2], al + mov byte [msh2d+3], bl + mov byte [msh3d+2], al + mov byte [msh4d+3], bl + mov byte [msh5d+2], al + mov byte [msh6d+3], bl +CDECLENDSET 2 + ret + + + ALIGN 16 +mhline: +CDECLBEGINSET 6 + ;asm1 = bxinc + ;asm2 = byinc + ;asm3 = shadeoffs + ;eax = picoffs + ;ebx = bx + ;ecx = cnt + ;edx = ? + ;esi = by + ;edi = p + + mov dword [mmach1d+2], eax + mov dword [mmach5d+2], eax + mov dword [mmach9d+2], eax + mov eax, dword [asm3] + mov dword [mmach2d+2], eax + mov dword [mmach2da+2], eax + mov dword [mmach2db+2], eax + mov dword [mmach6d+2], eax + mov dword [mmach10d+2], eax + mov eax, dword [asm1] + mov dword [mmach3d+2], eax + mov dword [mmach7d+2], eax + mov eax, dword [asm2] + mov dword [mmach4d+2], eax + mov dword [mmach8d+2], eax + jmp short mhlineskipmodify_nosetup + + + ALIGN 16 +mhlineskipmodify: +CDECLBEGINSET 6 +mhlineskipmodify_nosetup: + + push ebp + + xor eax, eax + mov ebp, ebx + + test ecx, 00010000h + jnz short mbeghline + +msh1d: shr ebx, 26 +msh2d: shld ebx, esi, 6 + add ebp, dword [asm1] +mmach9d: mov al, byte [ebx+88888888h] ;picoffs + add esi, dword [asm2] + cmp al, 255 + je mskip5 + +mmach10d: mov cl, byte [eax+88888888h] ;shadeoffs + mov byte [edi], cl +mskip5: + inc edi + sub ecx, 65536 + jc near mendhline + jmp short mbeghline + +ALIGN 16 +mpreprebeghline: ;1st only + mov al, cl +mmach2d: mov al, byte [eax+88888888h] ;shadeoffs + mov byte [edi], al + +mprebeghline: + add edi, 2 + sub ecx, 131072 + jc near mendhline +mbeghline: +mmach3d: lea ebx, [ebp+88888888h] ;bxinc +msh3d: shr ebp, 26 +msh4d: shld ebp, esi, 6 +mmach4d: add esi, 88888888h ;byinc +mmach1d: mov cl, byte [ebp+88888888h] ;picoffs +mmach7d: lea ebp, [ebx+88888888h] ;bxinc + +msh5d: shr ebx, 26 +msh6d: shld ebx, esi, 6 +mmach8d: add esi, 88888888h ;byinc +mmach5d: mov ch, byte [ebx+88888888h] ;picoffs + + cmp cl, 255 + je short mskip1 + cmp ch, 255 + je short mpreprebeghline + + mov al, cl ;BOTH +mmach2da: mov bl, byte [eax+88888888h] ;shadeoffs + mov al, ch +mmach2db: mov bh, byte [eax+88888888h] ;shadeoffs + mov word [edi], bx + add edi, 2 + sub ecx, 131072 + jnc short mbeghline + jmp mendhline +mskip1: ;2nd only + cmp ch, 255 + je short mprebeghline + + mov al, ch +mmach6d: mov al, byte [eax+88888888h] ;shadeoffs + mov byte [edi+1], al + add edi, 2 + sub ecx, 131072 + jnc short mbeghline +mendhline: + + pop ebp +CDECLENDSET 6 + ret + + + ALIGN 16 +tsethlineshift: +CDECLBEGINSET 2 + neg al + mov byte [tsh1d+2], al + mov byte [tsh2d+3], bl + mov byte [tsh3d+2], al + mov byte [tsh4d+3], bl + mov byte [tsh5d+2], al + mov byte [tsh6d+3], bl +CDECLENDSET 2 + ret + + + ALIGN 16 +thline: +CDECLBEGINSET 6 + ;asm1 = bxinc + ;asm2 = byinc + ;asm3 = shadeoffs + ;eax = picoffs + ;ebx = bx + ;ecx = cnt + ;edx = ? + ;esi = by + ;edi = p + + mov dword [tmach1d+2], eax + mov dword [tmach5d+2], eax + mov dword [tmach9d+2], eax + mov eax, dword [asm3] + mov dword [tmach2d+2], eax + mov dword [tmach6d+2], eax + mov dword [tmach10d+2], eax + mov eax, dword [asm1] + mov dword [tmach3d+2], eax + mov dword [tmach7d+2], eax + mov eax, dword [asm2] + mov dword [tmach4d+2], eax + mov dword [tmach8d+2], eax + jmp thlineskipmodify_nosetup + + + ALIGN 16 +thlineskipmodify: +CDECLBEGINSET 6 +thlineskipmodify_nosetup: + + push ebp + + xor eax, eax + xor edx, edx + mov ebp, ebx + + test ecx, 00010000h + jnz short tbeghline + +tsh1d: shr ebx, 26 +tsh2d: shld ebx, esi, 6 + add ebp, dword [asm1] +tmach9d: mov al, byte [ebx+88888888h] ;picoffs + add esi, dword [asm2] + cmp al, 255 + je tskip5 + +transrev4: +tmach10d: mov dl, byte [eax+88888888h] ;shadeoffs +transrev5: + mov dh, byte [edi] +tmach1: mov al, byte [edx+88888888h] ;_transluc + mov byte [edi], al +tskip5: + inc edi + sub ecx, 65536 + jc near tendhline + jmp short tbeghline + +ALIGN 16 +tprebeghline: + add edi, 2 + sub ecx, 131072 + jc short tendhline +tbeghline: +tmach3d: lea ebx, [ebp+88888888h] ;bxinc +tsh3d: shr ebp, 26 +tsh4d: shld ebp, esi, 6 +tmach4d: add esi, 88888888h ;byinc +tmach1d: mov cl, byte [ebp+88888888h] ;picoffs +tmach7d: lea ebp, [ebx+88888888h] ;bxinc + +tsh5d: shr ebx, 26 +tsh6d: shld ebx, esi, 6 +tmach8d: add esi, 88888888h ;byinc +tmach5d: mov ch, byte [ebx+88888888h] ;picoffs + + cmp cx, 0ffffh + je short tprebeghline + + mov bx, word [edi] + + cmp cl, 255 + je short tskip1 + mov al, cl +transrev6: +tmach2d: mov dl, byte [eax+88888888h] ;shadeoffs +transrev7: + mov dh, bl +tmach2: mov al, byte [edx+88888888h] ;_transluc + mov byte [edi], al + + cmp ch, 255 + je short tskip2 +tskip1: + mov al, ch +transrev8: +tmach6d: mov dl, byte [eax+88888888h] ;shadeoffs +transrev9: + mov dh, bh +tmach3: mov al, byte [edx+88888888h] ;_transluc + mov byte [edi+1], al +tskip2: + + add edi, 2 + sub ecx, 131072 + jnc tbeghline +tendhline: + + pop ebp +CDECLENDSET 6 + ret + + + ;eax=shiftval, ebx=palookup1, ecx=palookup2 + ALIGN 16 +setuptvlineasm2: +CDECLBEGINSET 3 + mov byte [tran2shra+2], al + mov byte [tran2shrb+2], al + mov dword [tran2pala+2], ebx + mov dword [tran2palb+2], ecx + mov dword [tran2palc+2], ebx + mov dword [tran2pald+2], ecx +CDECLENDSET 3 + ret + + ;Pass: eax=vplc2, ebx=vinc1, ecx=bufplc1, edx=bufplc2, esi=vplc1, edi=p + ; asm1=vinc2, asm2=pend + ;Return: asm1=vplc1, asm2=vplc2 + ALIGN 16 +tvlineasm2: +CDECLBEGINSET 6 + + push ebp + + mov ebp, eax + + mov dword [tran2inca+2], ebx + mov eax, dword [asm1] + mov dword [tran2incb+2], eax + + mov dword [tran2bufa+2], ecx ;bufplc1 + mov dword [tran2bufb+2], edx ;bufplc2 + + mov eax, dword [asm2] + sub edi, eax + mov dword [tran2edia+3], eax + mov dword [tran2edic+2], eax + inc eax + mov dword [tran2edie+2], eax +fixchaint2a: sub eax, 320 + mov dword [tran2edif+2], eax + dec eax + mov dword [tran2edib+3], eax + mov dword [tran2edid+2], eax + + xor ecx, ecx + xor edx, edx + jmp short begintvline2 + + ;eax 0000000000 temp temp + ;ebx 0000000000 odat2 odat1 + ;ecx 0000000000000000 ndat1 + ;edx 0000000000000000 ndat2 + ;esi vplc1 + ;edi videoplc-------------- + ;ebp vplc2 + +ALIGN 16 + ;LEFT ONLY +skipdraw2: +transrev10: +tran2edic: mov ah, byte [edi+88888888h] ;getpixel +transrev11: +tran2palc: mov al, byte [ecx+88888888h] ;palookup1 +fixchaint2d: add edi, 320 +tran2trac: mov bl, byte [eax+88888888h] ;_transluc +tran2edid: mov byte [edi+88888888h-320], bl ;drawpixel + jnc short begintvline2 + jmp endtvline2 + +skipdraw1: + cmp dl, 255 + jne short skipdraw3 +fixchaint2b: add edi, 320 + jc short endtvline2 + +begintvline2: + mov eax, esi +tran2shra: shr eax, 88h ;globalshift + mov ebx, ebp +tran2shrb: shr ebx, 88h ;globalshift +tran2inca: add esi, 88888888h ;vinc1 +tran2incb: add ebp, 88888888h ;vinc2 +tran2bufa: mov cl, byte [eax+88888888h] ;bufplc1 + cmp cl, 255 +tran2bufb: mov dl, byte [ebx+88888888h] ;bufplc2 + je short skipdraw1 + cmp dl, 255 + je short skipdraw2 + + ;mov ax The transluscent reverse of both! + ;mov bl, ah + ;mov ah + ;mov bh + + ;BOTH +transrev12: +tran2edia: mov bx, word [edi+88888888h] ;getpixels +transrev13: + mov ah, bl +transrev14: +tran2pala: mov al, byte [ecx+88888888h] ;palookup1 +transrev15: +tran2palb: mov bl, byte [edx+88888888h] ;palookup2 +fixchaint2c: add edi, 320 +tran2traa: mov al, byte [eax+88888888h] ;_transluc +tran2trab: mov ah, byte [ebx+88888888h] ;_transluc +tran2edib: mov word [edi+88888888h-320], ax ;drawpixels + jnc short begintvline2 + jmp short endtvline2 + + ;RIGHT ONLY +skipdraw3: +transrev16: +tran2edie: mov ah, byte [edi+88888889h] ;getpixel +transrev17: +tran2pald: mov al, byte [edx+88888888h] ;palookup2 +fixchaint2e: add edi, 320 +tran2trad: mov bl, byte [eax+88888888h] ;_transluc +tran2edif: mov byte [edi+88888889h-320], bl ;drawpixel + jnc short begintvline2 + +endtvline2: + mov dword [asm1], esi + mov dword [asm2], ebp + + pop ebp +CDECLENDSET 6 + ret + + +BITSOFPRECISION equ 3 +BITSOFPRECISIONPOW equ 8 + +;Double-texture mapping with palette lookup +;eax: ylo1------------|----dat|----dat +;ebx: ylo2--------------------|----cnt +;ecx: 000000000000000000000000|---temp +;edx: xhi1-xlo1---------------|---yhi1 +;esi: xhi2-xlo2---------------|---yhi2 +;edi: ------------------------videopos +;ebp: ----------------------------temp + + ALIGN 16 +setupslopevlin2: +CDECLBEGINSET 6 + + mov dword [slop3+2], edx ;ptr + mov dword [slop7+2], edx ;ptr + mov dword [slop4+2], esi ;tptr + mov dword [slop8+2], esi ;tptr + mov byte [slop2+2], ah ;ybits + mov byte [slop6+2], ah ;ybits + mov dword [slop9+2], edi ;pinc + + mov edx, 1 + mov cl, al + add cl, ah + shl edx, cl + dec edx + mov cl, ah + ror edx, cl + + mov dword [slop1+2], edx ;ybits...xbits + mov dword [slop5+2], edx ;ybits...xbits + +CDECLENDSET 6 + ret + + ALIGN 16 +slopevlin2: +CDECLBEGINSET 6 + + push ebp + xor ecx, ecx + +slopevlin2begin: + mov ebp, edx +slop1: and ebp, 88000088h ;ybits...xbits +slop2: rol ebp, 6 ;ybits + add eax, dword [asm1] ;xinc1<>(32-xbits)) +slop3: mov cl, byte [ebp+88888888h] ;bufplc + + mov ebp, esi +slop4: mov al, byte [ecx+88888888h] ;paloffs +slop5: and ebp, 88000088h ;ybits...xbits +slop6: rol ebp, 6 ;ybits + add ebx, dword [asm3] ;xinc2<>(32-xbits)) +slop8: mov ah, byte [ecx+88888888h] ;paloffs + + dec bl + mov word [edi], ax +slop9: lea edi, [edi+88888888h] ;pinc + jnz short slopevlin2begin + + pop ebp + mov eax, edi + +CDECLENDSET 6 + ret + + + ALIGN 16 +setupslopevlin: +CDECLBEGINSET 3 + + mov dword [slopmach3+3], ebx ;ptr + mov dword [slopmach5+2], ecx ;pinc + neg ecx + mov dword [slopmach6+2], ecx ;-pinc + + mov edx, 1 + mov cl, al + shl edx, cl + dec edx + mov cl, ah + shl edx, cl + mov dword [slopmach7+2], edx + + neg ah + mov byte [slopmach2+2], ah + + sub ah, al + mov byte [slopmach1+2], ah + + fild dword [asm1] + fstp dword [asm2] + +CDECLENDSET 3 + ret + + + ALIGN 16 +slopevlin: +CDECLBEGINSET 6 + + mov dword [ebpbak], ebp + mov dword [espbak], esp + + sub ecx, esp + mov dword [slopmach4+3], ecx + + fild dword [asm3] +slopmach6: lea ebp, [eax+88888888h] + fadd dword [asm2] + + mov dword [asm1], ebx + shl ebx, 3 + + mov eax, dword [globalx3] + mov ecx, dword [globaly3] + imul eax, ebx + imul ecx, ebx + add esi, eax + add edi, ecx + + mov ebx, edx + jmp short bigslopeloop +ALIGN 16 +bigslopeloop: + fst dword [fpuasm] + + mov eax, dword [fpuasm] + add eax, eax + sbb edx, edx + mov ecx, eax + shr ecx, 24 + and eax, 00ffe000h + shr eax, 11 + sub cl, 2 + mov eax, dword [reciptable+eax] + shr eax, cl + xor eax, edx + mov edx, dword [asm1] + mov ecx, dword [globalx3] + mov dword [asm1], eax + sub eax, edx + mov edx, dword [globaly3] + imul ecx, eax + imul eax, edx + + fadd dword [asm2] + + cmp ebx, BITSOFPRECISIONPOW + mov dword [asm4], ebx + mov cl, bl + jl short slopeskipmin + mov cl, BITSOFPRECISIONPOW +slopeskipmin: + +;eax: yinc............. +;ebx: 0 0 0 ? +;ecx: xinc......... cnt +;edx: ? +;esi: xplc............. +;edi: yplc............. +;ebp: videopos + + mov ebx, esi + mov edx, edi + +beginnerslopeloop: +slopmach1: shr ebx, 20 + add esi, ecx +slopmach2: shr edx, 26 +slopmach7: and ebx, 88888888h + add edi, eax +slopmach5: add ebp, 88888888h ;pinc +slopmach3: mov dl, byte [ebx+edx+88888888h] ;ptr +slopmach4: mov ebx, dword [esp+88888888h] + sub esp, 4 + dec cl + mov al, byte [ebx+edx] ;tptr + mov ebx, esi + mov [ebp], al + mov edx, edi + jnz short beginnerslopeloop + + mov ebx, dword [asm4] + sub ebx, BITSOFPRECISIONPOW + jg near bigslopeloop + + ffree st0 + + mov esp, dword [espbak] + mov ebp, dword [ebpbak] + +CDECLENDSET 6 + ret + + + ALIGN 16 +setuprhlineasm4: +CDECLBEGINSET 6 + + mov dword [rmach1a+2], eax + mov dword [rmach1b+2], eax + mov dword [rmach1c+2], eax + mov dword [rmach1d+2], eax + mov dword [rmach1e+2], eax + + mov dword [rmach2a+2], ebx + mov dword [rmach2b+2], ebx + mov dword [rmach2c+2], ebx + mov dword [rmach2d+2], ebx + mov dword [rmach2e+2], ebx + + mov dword [rmach3a+2], ecx + mov dword [rmach3b+2], ecx + mov dword [rmach3c+2], ecx + mov dword [rmach3d+2], ecx + mov dword [rmach3e+2], ecx + + mov dword [rmach4a+2], edx + mov dword [rmach4b+2], edx + mov dword [rmach4c+2], edx + mov dword [rmach4d+2], edx + mov dword [rmach4e+2], edx + + mov dword [rmach5a+2], esi + mov dword [rmach5b+2], esi + mov dword [rmach5c+2], esi + mov dword [rmach5d+2], esi + mov dword [rmach5e+2], esi + +CDECLENDSET 6 + ret + + ;Non power of 2, non masking, with palookup method #1 (6 clock cycles) + ;eax: dat dat dat dat + ;ebx: bufplc + ;ecx: 0 dat + ;edx: xlo + ;esi: ylo + ;edi: videopos/cnt + ;ebp: tempvar + ;esp: + ALIGN 16 +rhlineasm4: +CDECLBEGINSET 6 + + push ebp + + cmp eax, 0 + jle near endrhline + + lea ebp, [edi-4] + sub ebp, eax + mov dword [rmach6a+2], ebp + add ebp, 3 + mov dword [rmach6b+2], ebp + mov edi, eax + test edi, 3 + jz short begrhline + jmp short startrhline1 + +ALIGN 16 +startrhline1: + mov cl, byte [ebx] ;bufplc +rmach1e: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach2e: sub esi, 88888888h ;ylo +rmach3e: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach4e: mov al, byte [ecx+88888888h] ;palookup +rmach5e: and ebp, 88888888h ;tilesizy +rmach6b: mov byte [edi+88888888h], al ;vidcntoffs + sub ebx, ebp + dec edi + test edi, 3 + jnz short startrhline1 + test edi, edi + jz near endrhline + +begrhline: + mov cl, byte [ebx] ;bufplc +rmach1a: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach2a: sub esi, 88888888h ;ylo +rmach3a: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5a: and ebp, 88888888h ;tilesizy + sub ebx, ebp + +rmach1b: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach4a: mov ah, byte [ecx+88888888h] ;palookup + mov cl, byte [ebx] ;bufplc +rmach2b: sub esi, 88888888h ;ylo +rmach3b: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5b: and ebp, 88888888h ;tilesizy +rmach4b: mov al, byte [ecx+88888888h] ;palookup + sub ebx, ebp + + shl eax, 16 + + mov cl, byte [ebx] ;bufplc +rmach1c: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach2c: sub esi, 88888888h ;ylo +rmach3c: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5c: and ebp, 88888888h ;tilesizy + sub ebx, ebp + +rmach1d: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach4c: mov ah, byte [ecx+88888888h] ;palookup + mov cl, byte [ebx] ;bufplc +rmach2d: sub esi, 88888888h ;ylo +rmach3d: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5d: and ebp, 88888888h ;tilesizy +rmach4d: mov al, byte [ecx+88888888h] ;palookup + sub ebx, ebp + +rmach6a: mov dword [edi+88888888h], eax ;vidcntoffs + sub edi, 4 + jnz near begrhline +endrhline: + pop ebp + +CDECLENDSET 6 + ret + + + ALIGN 16 +setuprmhlineasm4: +CDECLBEGINSET 6 + mov dword [rmmach1+2], eax + mov dword [rmmach2+2], ebx + mov dword [rmmach3+2], ecx + mov dword [rmmach4+2], edx + mov dword [rmmach5+2], esi +CDECLENDSET 6 + ret + + + ALIGN 16 +rmhlineasm4: +CDECLBEGINSET 6 + + push ebp + + cmp eax, 0 + jle short endrmhline + + lea ebp, [edi-1] + sub ebp, eax + mov dword [rmmach6+2], ebp + mov edi, eax + jmp short begrmhline + +ALIGN 16 +begrmhline: + mov cl, byte [ebx] ;bufplc +rmmach1: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmmach2: sub esi, 88888888h ;ylo +rmmach3: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmmach5: and ebp, 88888888h ;tilesizy + cmp cl, 255 + je short rmskip +rmmach4: mov al, byte [ecx+88888888h] ;palookup +rmmach6: mov byte [edi+88888888h], al ;vidcntoffs +rmskip: + sub ebx, ebp + dec edi + jnz short begrmhline +endrmhline: + pop ebp + +CDECLENDSET 6 + ret + + + ALIGN 16 +setupqrhlineasm4: +CDECLBEGINSET 6 + + mov dword [qrmach2e+2], ebx + mov dword [qrmach3e+2], ecx + xor edi, edi + sub edi, ecx + mov dword [qrmach7a+2], edi + mov dword [qrmach7b+2], edi + + add ebx, ebx + adc ecx, ecx + mov dword [qrmach2a+2], ebx + mov dword [qrmach2b+2], ebx + mov dword [qrmach3a+2], ecx + mov dword [qrmach3b+2], ecx + + mov dword [qrmach4a+2], edx + mov dword [qrmach4b+2], edx + mov dword [qrmach4c+2], edx + mov dword [qrmach4d+2], edx + mov dword [qrmach4e+2], edx + +CDECLENDSET 6 + ret + + ;Non power of 2, non masking, with palookup method (FASTER BUT NO SBB'S) + ;eax: dat dat dat dat + ;ebx: bufplc + ;ecx: 0 dat + ;edx: 0 dat + ;esi: ylo + ;edi: videopos/cnt + ;ebp: ? + ;esp: + ALIGN 16 +qrhlineasm4: +CDECLBEGINSET 6 + + push ebp + + cmp eax, 0 + jle near endqrhline + + mov ebp, eax + test ebp, 3 + jz short skipqrhline1 + jmp short startqrhline1 + +ALIGN 16 +startqrhline1: + mov cl, byte [ebx] ;bufplc + dec edi +qrmach2e: sub esi, 88888888h ;ylo + dec ebp +qrmach3e: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +qrmach4e: mov al, byte [ecx+88888888h] ;palookup + mov byte [edi], al ;vidcntoffs + test ebp, 3 + jnz short startqrhline1 + test ebp, ebp + jz short endqrhline + +skipqrhline1: + mov cl, byte [ebx] ;bufplc + jmp short begqrhline +ALIGN 16 +begqrhline: +qrmach7a: mov dl, byte [ebx+88888888h] ;bufplc +qrmach2a: sub esi, 88888888h ;ylo +qrmach3a: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +qrmach4a: mov ah, byte [ecx+88888888h] ;palookup +qrmach4b: mov al, byte [edx+88888888h] ;palookup + sub edi, 4 + shl eax, 16 + mov cl, byte [ebx] ;bufplc +qrmach7b: mov dl, byte [ebx+88888888h] ;bufplc +qrmach2b: sub esi, 88888888h ;ylo +qrmach3b: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +qrmach4c: mov ah, byte [ecx+88888888h] ;palookup +qrmach4d: mov al, byte [edx+88888888h] ;palookup + mov cl, byte [ebx] ;bufplc + mov dword [edi], eax + sub ebp, 4 + jnz short begqrhline + +endqrhline: + pop ebp + +CDECLENDSET 6 + ret + + +setupdrawslab: +CDECLBEGINSET 2 + + mov dword [voxbpl1+2], eax + mov dword [voxbpl2+2], eax + mov dword [voxbpl3+2], eax + mov dword [voxbpl4+2], eax + mov dword [voxbpl5+2], eax + mov dword [voxbpl6+2], eax + mov dword [voxbpl7+2], eax + mov dword [voxbpl8+2], eax + + mov dword [voxpal1+2], ebx + mov dword [voxpal2+2], ebx + mov dword [voxpal3+2], ebx + mov dword [voxpal4+2], ebx + mov dword [voxpal5+2], ebx + mov dword [voxpal6+2], ebx + mov dword [voxpal7+2], ebx + mov dword [voxpal8+2], ebx + +CDECLENDSET 2 + ret + + + ALIGN 16 +drawslab: +CDECLBEGINSET 6 + + push ebp + cmp eax, 2 + je near voxbegdraw2 + ja near voxskip2 + xor eax, eax +voxbegdraw1: + mov ebp, ebx + shr ebp, 16 + add ebx, edx + dec ecx + mov al, byte [esi+ebp] +voxpal1: mov al, byte [eax+88888888h] + mov byte [edi], al +voxbpl1: lea edi, [edi+88888888h] + jnz near voxbegdraw1 + pop ebp + +CDECLENDSET 6 + ret + +voxbegdraw2: + mov ebp, ebx + shr ebp, 16 + add ebx, edx + xor eax, eax + dec ecx + mov al, byte [esi+ebp] +voxpal2: mov al, byte [eax+88888888h] + mov ah, al + mov word [edi], ax +voxbpl2: lea edi, [edi+88888888h] + jnz near voxbegdraw2 + pop ebp + +CDECLENDSET 6 + ret + +voxskip2: + cmp eax, 4 + jne near voxskip4 + xor eax, eax +voxbegdraw4: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte [esi+ebp] +voxpal3: mov al, byte [eax+88888888h] + mov ah, al + shl eax, 8 + mov al, ah + shl eax, 8 + mov al, ah + mov dword [edi], eax +voxbpl3: add edi, 88888888h + dec ecx + jnz near voxbegdraw4 + pop ebp + +CDECLENDSET 6 + ret + +voxskip4: + add eax, edi + + test edi, 1 + jz near voxskipslab1 + cmp edi, eax + je near voxskipslab1 + + push eax + push ebx + push ecx + push edi +voxbegslab1: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte [esi+ebp] +voxpal4: mov al, byte [eax+88888888h] + mov byte [edi], al +voxbpl4: add edi, 88888888h + dec ecx + jnz near voxbegslab1 + pop edi + pop ecx + pop ebx + pop eax + inc edi + +voxskipslab1: + push eax + test edi, 2 + jz near voxskipslab2 + dec eax + cmp edi, eax + jge near voxskipslab2 + + push ebx + push ecx + push edi +voxbegslab2: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte [esi+ebp] +voxpal5: mov al, byte [eax+88888888h] + mov ah, al + mov word [edi], ax +voxbpl5: add edi, 88888888h + dec ecx + jnz near voxbegslab2 + pop edi + pop ecx + pop ebx + add edi, 2 + +voxskipslab2: + mov eax, dword [esp] + + sub eax, 3 + cmp edi, eax + jge near voxskipslab3 + +voxprebegslab3: + push ebx + push ecx + push edi +voxbegslab3: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte [esi+ebp] +voxpal6: mov al, byte [eax+88888888h] + mov ah, al + shl eax, 8 + mov al, ah + shl eax, 8 + mov al, ah + mov dword [edi], eax +voxbpl6: add edi, 88888888h + dec ecx + jnz near voxbegslab3 + pop edi + pop ecx + pop ebx + add edi, 4 + + mov eax, dword [esp] + + sub eax, 3 + cmp edi, eax + jl near voxprebegslab3 + +voxskipslab3: + mov eax, dword [esp] + + dec eax + cmp edi, eax + jge near voxskipslab4 + + push ebx + push ecx + push edi +voxbegslab4: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte [esi+ebp] +voxpal7: mov al, byte [eax+88888888h] + mov ah, al + mov word [edi], ax +voxbpl7: add edi, 88888888h + dec ecx + jnz near voxbegslab4 + pop edi + pop ecx + pop ebx + add edi, 2 + +voxskipslab4: + pop eax + + cmp edi, eax + je near voxskipslab5 + +voxbegslab5: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte [esi+ebp] +voxpal8: mov al, byte [eax+88888888h] + mov byte [edi], al +voxbpl8: add edi, 88888888h + dec ecx + jnz near voxbegslab5 + +voxskipslab5: + pop ebp + +CDECLENDSET 6 + ret + +;modify: loinc +;eax: | dat | dat | dat | dat | +;ebx: | loplc1 | +;ecx: | loplc2 | cnthi | cntlo | +;edx: |--------|--------|--------| hiplc1 | +;esi: |--------|--------|--------| hiplc2 | +;edi: |--------|--------|--------| vidplc | +;ebp: |--------|--------|--------| hiinc | + +stretchhline: +CDECLBEGINSET 6 + + push ebp + + mov eax, ebx + shl ebx, 16 + sar eax, 16 + and ecx, 0000ffffh + or ecx, ebx + + add esi, eax + mov eax, edx + mov edx, esi + + mov ebp, eax + shl eax, 16 + sar ebp, 16 + + add ecx, eax + adc esi, ebp + + add eax, eax + adc ebp, ebp + mov dword [loinc1+2], eax + mov dword [loinc2+2], eax + mov dword [loinc3+2], eax + mov dword [loinc4+2], eax + + inc ch + + jmp begloop + +begloop: + mov al, [edx] +loinc1: sub ebx, 88888888h + sbb edx, ebp + mov ah, [esi] +loinc2: sub ecx, 88888888h + sbb esi, ebp + sub edi, 4 + shl eax, 16 +loinc3: sub ebx, 88888888h + mov al, [edx] + sbb edx, ebp + mov ah, [esi] +loinc4: sub ecx, 88888888h + sbb esi, ebp + mov [edi], eax + dec cl + jnz begloop + dec ch + jnz begloop + + pop ebp + +CDECLENDSET 6 + ret + + +mmxoverlay: + push ebx ;JBF + push ecx ;JBF + push edx ;JBF + + pushfd ;Check if CPUID is available + pop eax + mov ebx, eax + xor eax, 00200000h + push eax + popfd + pushfd + pop eax + cmp eax, ebx + je pentium + xor eax, eax + dw 0a20fh + test eax, eax + jz pentium + mov eax, 1 + dw 0a20fh + and eax, 00000f00h + test edx, 00800000h ;Check if MMX is available + jz nommx + cmp eax, 00000600h ;Check if P6 Family or not + jae pentiumii + jmp pentiummmx +nommx: + cmp eax, 00000600h ;Check if P6 Family or not + jae pentiumpro +pentium: + + pop edx ;JBF + pop ecx ;JBF + pop ebx ;JBF + ret + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PENTIUM II Overlays ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +pentiumii: + ;Hline overlay (MMX doens't help) + mov byte [sethlinesizes], 0xe9 + mov dword [sethlinesizes+1], (prosethlinesizes-sethlinesizes-5) + mov byte [setpalookupaddress], 0xe9 + mov dword [setpalookupaddress+1], (prosetpalookupaddress-setpalookupaddress-5) + mov byte [setuphlineasm4], 0xc3 ;ret (no code required) + mov byte [hlineasm4], 0xe9 + mov dword [hlineasm4+1], (prohlineasm4-hlineasm4-5) + + ;Vline overlay + mov byte [setupvlineasm], 0xe9 + mov dword [setupvlineasm+1], (prosetupvlineasm-setupvlineasm-5) + mov byte [vlineasm4], 0xe9 + mov dword [vlineasm4+1], (provlineasm4-vlineasm4-5) + + pop edx ;JBF + pop ecx ;JBF + pop ebx ;JBF + ret + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PENTIUM MMX Overlays ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +pentiummmx: + pop edx ;JBF + pop ecx ;JBF + pop ebx ;JBF + ret + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PENTIUM PRO Overlays ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +pentiumpro: + ;Hline overlay (MMX doens't help) + mov byte [sethlinesizes], 0xe9 + mov dword [sethlinesizes+1], (prosethlinesizes-sethlinesizes-5) + mov byte [setpalookupaddress], 0xe9 + mov dword [setpalookupaddress+1], (prosetpalookupaddress-setpalookupaddress-5) + mov byte [setuphlineasm4], 0xc3 ;ret (no code required) + mov byte [hlineasm4], 0xe9 + mov dword [hlineasm4+1], (prohlineasm4-hlineasm4-5) + + ;Vline overlay + mov byte [setupvlineasm], 0xe9 + mov dword [setupvlineasm+1], (prosetupvlineasm-setupvlineasm-5) + mov byte [vlineasm4], 0xe9 + mov dword [vlineasm4+1], (provlineasm4-vlineasm4-5) + + pop edx ;JBF + pop ecx ;JBF + pop ebx ;JBF + ret + diff --git a/polymer/build/src/a.wasm b/polymer/build/src/a.wasm new file mode 100644 index 000000000..6b68da6d2 --- /dev/null +++ b/polymer/build/src/a.wasm @@ -0,0 +1,2420 @@ +; "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. + +.586P +.8087 +;include mmx.inc ;Include this if using < WATCOM 11.0 WASM + +;Warning: IN THIS FILE, ALL SEGMENTS ARE REMOVED. THIS MEANS THAT DS:[] +;MUST BE ADDED FOR ALL SELF-MODIFIES FOR MASM TO WORK. +; +;WASM PROBLEMS: +; 1. Requires all scaled registers (*1,*2,*4,*8) to be last thing on line +; 2. Using 'DATA' is nice for self-mod. code, but WDIS only works with 'CODE' +; +;MASM PROBLEMS: +; 1. Requires DS: to be written out for self-modifying code to work +; 2. Doesn't encode short jumps automatically like WASM +; 3. Stupidly adds wait prefix to ffree's + +EXTRN _asm1 : dword +EXTRN _asm2 : dword +EXTRN _asm3 : dword +EXTRN _asm4 : dword +EXTRN _reciptable : near +EXTRN _fpuasm : dword +EXTRN _globalx3 : dword +EXTRN _globaly3 : dword +EXTRN _ylookup : near + +EXTRN _vplce : near +EXTRN _vince : near +EXTRN _palookupoffse : near +EXTRN _bufplce : near + +EXTRN _ebpbak : dword +EXTRN _espbak : dword + +EXTRN _pow2char : near +EXTRN _pow2long : near + +CODE SEGMENT PUBLIC USE32 'DATA' +ASSUME cs:CODE,ds:CODE + +ALIGN 16 +PUBLIC sethlinesizes_ +sethlinesizes_: + mov byte ptr [machxbits1+2], al + mov byte ptr [machxbits2+2], al + mov byte ptr [machxbits3+2], al + neg al + mov byte ptr [hxsiz1+2], al + mov byte ptr [hxsiz2+2], al + mov byte ptr [hxsiz3+2], al + mov byte ptr [hxsiz4+2], al + mov byte ptr [machnegxbits1+2], al + + mov byte ptr [hysiz1+3], bl + mov byte ptr [hysiz2+3], bl + mov byte ptr [hysiz3+3], bl + mov byte ptr [hysiz4+3], bl + mov byte ptr [hmach3a+2], bl + mov byte ptr [hmach3b+2], bl + mov byte ptr [hmach3c+2], bl + mov byte ptr [hmach3d+2], bl + + mov dword ptr [hoffs1+2], ecx + mov dword ptr [hoffs2+2], ecx + mov dword ptr [hoffs3+2], ecx + mov dword ptr [hoffs4+2], ecx + mov dword ptr [hoffs5+2], ecx + mov dword ptr [hoffs6+2], ecx + mov dword ptr [hoffs7+2], ecx + mov dword ptr [hoffs8+2], ecx + + mov edx, -1 + mov cl, al + sub cl, bl + shr edx, cl + mov dword ptr [hmach2a+1], edx + mov dword ptr [hmach2b+1], edx + mov dword ptr [hmach2c+1], edx + mov dword ptr [hmach2d+1], edx + + ret + +ALIGN 16 +PUBLIC prosethlinesizes_ +prosethlinesizes_: + mov dword ptr [prohbuf-4], ecx + neg eax + mov ecx, eax + sub eax, ebx + mov byte ptr [prohshru-1], al ;bl = 32-al-bl + mov eax, -1 + shr eax, cl + mov ecx, ebx + shl eax, cl + mov dword ptr [prohand-4], eax ;((-1>>(-oal))<>(32-xbits) adc al, 88h 1 1/2 + ;bufplc mov cl, byte ptr [edx+88888888h] 1 1/2 + ;paloffs&255 mov bl, byte ptr [ecx+88888888h] 1 1/2 +ALIGN 16 +PUBLIC hlineasm4_ +hlineasm4_: + push ebp + + lea ebp, [eax+1] + + cmp ebp, 8 + jle shorthline + + test edi, 1 + jnz short skipthe1byte + + mov eax, esi +hxsiz1: shr eax, 26 +hysiz1: shld eax, edx, 6 +hoffs1: mov cl, byte ptr [eax+88888888h] +pal1: mov bl, byte ptr [ecx+88888888h] + sub esi, _asm1 + sub edx, _asm2 + mov byte ptr [edi], bl + dec edi + dec ebp + +skipthe1byte: + test edi, 2 + jnz short skipthe2byte + + mov eax, esi +hxsiz2: shr eax, 26 +hysiz2: shld eax, edx, 6 +hoffs2: mov cl, byte ptr [eax+88888888h] +pal2: mov bh, byte ptr [ecx+88888888h] + sub esi, _asm1 + sub edx, _asm2 + + mov eax, esi +hxsiz3: shr eax, 26 +hysiz3: shld eax, edx, 6 +hoffs3: mov cl, byte ptr [eax+88888888h] +pal3: mov bl, byte ptr [ecx+88888888h] + sub esi, _asm1 + sub edx, _asm2 + mov word ptr [edi-1], bx + sub edi, 2 + sub ebp, 2 + +skipthe2byte: + + mov eax, esi +machxbits1: shl esi, 6 ;xbits +machnegxbits1: shr eax, 32-6 ;32-xbits + mov dl, al + + inc edi + + add ebx, ebx + mov eax, edx + jc beginhline64 + + mov eax, _asm1 +machxbits2: rol eax, 6 ;xbits + mov dword ptr [hmach4a+2], eax + mov dword ptr [hmach4b+2], eax + mov dword ptr [hmach4c+2], eax + mov dword ptr [hmach4d+2], eax + mov ebx, eax + mov eax, _asm2 + mov al, bl + mov dword ptr [hmach1a+2], eax + mov dword ptr [hmach1b+2], eax + mov dword ptr [hmach1c+2], eax + mov dword ptr [hmach1d+2], eax + + mov eax, edx + jmp beginhline64 +ALIGN 16 +prebeginhline64: + mov dword ptr [edi], ebx +beginhline64: + +hmach3a: rol eax, 6 +hmach2a: and eax, 00008888h +hmach4a: sub esi, 88888888h +hmach1a: sbb edx, 88888888h + sub edi, 4 +hoffs4: mov cl, byte ptr [eax+88888888h] + mov eax, edx + +hmach3b: rol eax, 6 +hmach2b: and eax, 00008888h +hmach4b: sub esi, 88888888h +hmach1b: sbb edx, 88888888h +pal4: mov bh, byte ptr [ecx+88888888h] +hoffs5: mov cl, byte ptr [eax+88888888h] + mov eax, edx + +hmach3c: rol eax, 6 +pal5: mov bl, byte ptr [ecx+88888888h] +hmach2c: and eax, 00008888h + shl ebx, 16 +hmach4c: sub esi, 88888888h +hmach1c: sbb edx, 88888888h +hoffs6: mov cl, byte ptr [eax+88888888h] + + mov eax, edx + ;( + +hmach3d: rol eax, 6 +hmach2d: and eax, 00008888h +hmach4d: sub esi, 88888888h +hmach1d: sbb edx, 88888888h +pal6: mov bh, byte ptr [ecx+88888888h] +hoffs7: mov cl, byte ptr [eax+88888888h] + mov eax, edx + sub ebp, 4 + nop +pal7: mov bl, byte ptr [ecx+88888888h] + jnc prebeginhline64 +skipthe4byte: + + test ebp, 2 + jz skipdrawthe2 + rol ebx, 16 + mov word ptr [edi+2], bx + sub edi, 2 +skipdrawthe2: + test ebp, 1 + jz skipdrawthe1 + shr ebx, 24 + mov byte ptr [edi+3], bl +skipdrawthe1: + + pop ebp + ret + +shorthline: + test ebp, ebp + jz endshorthline +begshorthline: + mov eax, esi +hxsiz4: shr eax, 26 +hysiz4: shld eax, edx, 6 +hoffs8: mov cl, byte ptr [eax+88888888h] +pal8: mov bl, byte ptr [ecx+88888888h] + sub esi, _asm1 + sub edx, _asm2 + mov byte ptr [edi], bl + dec edi + dec ebp + jnz begshorthline +endshorthline: + pop ebp + ret + + + ;eax: 00000000 00000000 00000000 temp---- + ;ebx: 00000000 00000000 00000000 temp---- + ;ecx: UUUUUUuu uuuuuuuu uuuuuuuu uuuuuuuu + ;edx: VVVVVVvv vvvvvvvv vvvvvvvv vvvvvvvv + ;esi: cnt----- -------- -------- -------- + ;edi: vid----- -------- -------- -------- + ;ebp: paloffs- -------- -------- -------- + ;esp: ???????? ???????? ???????? ???????? +ALIGN 16 +PUBLIC prohlineasm4_ +prohlineasm4_: + push ebp + + lea ebp, [ecx+88888888h] +prohpala: + mov ecx, esi + lea esi, [eax+1] + sub edi, esi + +prohbeg: + mov eax, ecx + shr eax, 20 +prohshru: + mov ebx, edx + shr ebx, 26 +prohshrv: + and eax, 88888888h +prohand: + movzx eax, byte ptr [eax+ebx+88888888h] +prohbuf: + mov al, [eax+ebp] + sub ecx, _asm1 + sub edx, _asm2 + mov [edi+esi], al + dec esi + jnz prohbeg + + pop ebp + ret + + + +ALIGN 16 +PUBLIC setupvlineasm_ +setupvlineasm_: + ;First 2 lines for VLINEASM1, rest for VLINEASM4 + mov byte ptr [premach3a+2], al + mov byte ptr [mach3a+2], al + + push ecx + mov byte ptr [machvsh1+2], al ;32-shy + mov byte ptr [machvsh3+2], al ;32-shy + mov byte ptr [machvsh5+2], al ;32-shy + mov byte ptr [machvsh6+2], al ;32-shy + mov ah, al + sub ah, 16 + mov byte ptr [machvsh8+2], ah ;16-shy + neg al + mov byte ptr [machvsh7+2], al ;shy + mov byte ptr [machvsh9+2], al ;shy + mov byte ptr [machvsh10+2], al ;shy + mov byte ptr [machvsh11+2], al ;shy + mov byte ptr [machvsh12+2], al ;shy + mov cl, al + mov eax, 1 + shl eax, cl + dec eax + mov dword ptr [machvsh2+2], eax ;(1<>sh) + ;vplc3 = (ebp<<(32-sh))+((edx&65535)<<(16-sh)) +machvsh5: shl esi, 88h ;32-sh + mov eax, edx +machvsh6: shl ebp, 88h ;32-sh + and edx, 0000ffffh +machvsh7: shr eax, 88h ;sh + add esi, eax +machvsh8: shl edx, 88h ;16-sh + add ebp, edx + mov dword ptr _vplce[12], esi + mov dword ptr _vplce[4], ebp + + pop ebp + ret + + ;eax: -------temp1------- + ;ebx: -------temp2------- + ;ecx: ylo4 --------- + ;edx: ylo2 --------- + ;esi: yhi1 yhi2 + ;edi: ---videoplc/cnt---- + ;ebp: yhi3 yhi4 + ;esp: +ALIGN 16 +PUBLIC provlineasm4_ +provlineasm4_: + push ebp + + mov eax, dword ptr _ylookup[ecx*4] + add eax, edi + mov dword ptr [promachvline4end1+2], eax + inc eax + mov dword ptr [promachvline4end2+2], eax + inc eax + mov dword ptr [promachvline4end3+2], eax + inc eax + mov dword ptr [promachvline4end4+2], eax + sub eax, 3 + sub edi, eax + + mov eax, dword ptr _bufplce[0] + mov ebx, dword ptr _bufplce[4] + mov ecx, dword ptr _bufplce[8] + mov edx, dword ptr _bufplce[12] + mov dword ptr [promachvbuf1+3], ecx + mov dword ptr [promachvbuf2+3], edx + mov dword ptr [promachvbuf3+3], eax + mov dword ptr [promachvbuf4+3], ebx + + mov eax, dword ptr _palookupoffse[0] + mov ebx, dword ptr _palookupoffse[4] + mov ecx, dword ptr _palookupoffse[8] + mov edx, dword ptr _palookupoffse[12] + mov dword ptr [promachvpal1+2], ecx + mov dword ptr [promachvpal2+2], edx + mov dword ptr [promachvpal3+2], eax + mov dword ptr [promachvpal4+2], ebx + + ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + ;edx: ³v3lo ³v1lo ³ + ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄ´ + ;esi: ³v2hi v2lo ³ v3hi³ + ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄ´ + ;ebp: ³v0hi v0lo ³ v1hi³ + ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ + + mov ebp, dword ptr _vince[0] + mov ebx, dword ptr _vince[4] + mov esi, dword ptr _vince[8] + mov eax, dword ptr _vince[12] + and esi, 0fffffe00h + and ebp, 0fffffe00h +promachvsh9: rol eax, 88h ;sh +promachvsh10: rol ebx, 88h ;sh + mov edx, eax + mov ecx, ebx + shr ecx, 16 + and edx, 0ffff0000h + add edx, ecx + and eax, 000001ffh + and ebx, 000001ffh + add esi, eax + add ebp, ebx + ; + mov eax, edx + and eax, 0ffff0000h + mov dword ptr [promachvinc1+2], eax + mov dword ptr [promachvinc2+2], esi + shl edx, 16 + mov dword ptr [promachvinc3+2], edx + mov dword ptr [promachvinc5+2], ebp + + mov ebp, dword ptr _vplce[0] + mov ebx, dword ptr _vplce[4] + mov esi, dword ptr _vplce[8] + mov eax, dword ptr _vplce[12] + and esi, 0fffffe00h + and ebp, 0fffffe00h +promachvsh11: rol eax, 88h ;sh +promachvsh12: rol ebx, 88h ;sh + mov edx, eax + mov ecx, ebx + shr ecx, 16 + and edx, 0ffff0000h + add edx, ecx + and eax, 000001ffh + and ebx, 000001ffh + add esi, eax + add ebp, ebx + + mov eax, esi + mov ecx, edx + shl ecx, 16 + jmp short probeginvlineasm4 +ALIGN 16 + nop + nop + nop +probeginvlineasm4: +promachvsh1: shr eax, 88h ;32-sh + mov ebx, esi +promachvsh2: and ebx, 00000088h ;(1<>sh) + ;vplc3 = (ebp<<(32-sh))+((edx&65535)<<(16-sh)) +promachvsh5: shl esi, 88h ;32-sh + mov eax, edx +promachvsh6: shl ebp, 88h ;32-sh + and edx, 0000ffffh +promachvsh7: shr eax, 88h ;sh + add esi, eax +promachvsh8: shl edx, 88h ;16-sh + add ebp, edx + mov dword ptr _vplce[12], esi + mov dword ptr _vplce[4], ebp + + pop ebp + ret + + +ALIGN 16 +PUBLIC mvlineasm4_ +mvlineasm4_: + push ebp + + mov eax, dword ptr _bufplce[0] + mov ebx, dword ptr _bufplce[4] + mov dword ptr [machmv1+2], eax + mov dword ptr [machmv4+2], ebx + mov eax, dword ptr _bufplce[8] + mov ebx, dword ptr _bufplce[12] + mov dword ptr [machmv7+2], eax + mov dword ptr [machmv10+2], ebx + + mov eax, dword ptr _palookupoffse[0] + mov ebx, dword ptr _palookupoffse[4] + mov dword ptr [machmv2+2], eax + mov dword ptr [machmv5+2], ebx + mov eax, dword ptr _palookupoffse[8] + mov ebx, dword ptr _palookupoffse[12] + mov dword ptr [machmv8+2], eax + mov dword ptr [machmv11+2], ebx + + mov eax, dword ptr _vince[0] ;vince + mov ebx, dword ptr _vince[4] + xor al, al + xor bl, bl + mov dword ptr [machmv3+2], eax + mov dword ptr [machmv6+2], ebx + mov eax, dword ptr _vince[8] + mov ebx, dword ptr _vince[12] + mov dword ptr [machmv9+2], eax + mov dword ptr [machmv12+2], ebx + + mov ebx, ecx + mov ecx, dword ptr _vplce[0] + mov edx, dword ptr _vplce[4] + mov esi, dword ptr _vplce[8] + mov ebp, dword ptr _vplce[12] + mov cl, bl + inc cl + inc bh + mov byte ptr _asm3[0], bh +fixchain2ma: sub edi, 320 + + jmp short beginmvlineasm4 +ALIGN 16 +beginmvlineasm4: + dec cl + jz endmvlineasm4 +beginmvlineasm42: + mov eax, ebp + mov ebx, esi +machmv16: shr eax, 32 +machmv15: shr ebx, 32 +machmv12: add ebp, 88888888h ;vince[3] +machmv9: add esi, 88888888h ;vince[2] +machmv10: mov al, byte ptr [eax+88888888h] ;bufplce[3] +machmv7: mov bl, byte ptr [ebx+88888888h] ;bufplce[2] + cmp al, 255 + adc dl, dl + cmp bl, 255 + adc dl, dl +machmv8: mov bl, byte ptr [ebx+88888888h] ;palookupoffs[2] +machmv11: mov bh, byte ptr [eax+88888888h] ;palookupoffs[3] + + mov eax, edx +machmv14: shr eax, 32 + shl ebx, 16 +machmv4: mov al, byte ptr [eax+88888888h] ;bufplce[1] + cmp al, 255 + adc dl, dl +machmv6: add edx, 88888888h ;vince[1] +machmv5: mov bh, byte ptr [eax+88888888h] ;palookupoffs[1] + + mov eax, ecx +machmv13: shr eax, 32 +machmv3: add ecx, 88888888h ;vince[0] +machmv1: mov al, byte ptr [eax+88888888h] ;bufplce[0] + cmp al, 255 + adc dl, dl +machmv2: mov bl, byte ptr [eax+88888888h] ;palookupoffs[0] + + shl dl, 4 + xor eax, eax +fixchain2mb: add edi, 320 + mov al, dl + add eax, offset mvcase0 + jmp eax ;16 byte cases + +ALIGN 16 +endmvlineasm4: + dec byte ptr _asm3[0] + jnz beginmvlineasm42 + + mov dword ptr _vplce[0], ecx + mov dword ptr _vplce[4], edx + mov dword ptr _vplce[8], esi + mov dword ptr _vplce[12], ebp + pop ebp + ret + + ;5,7,8,8,11,13,12,14,11,13,14,14,12,14,15,7 +ALIGN 16 +mvcase0: + jmp beginmvlineasm4 +ALIGN 16 +mvcase1: + mov byte ptr [edi], bl + jmp beginmvlineasm4 +ALIGN 16 +mvcase2: + mov byte ptr [edi+1], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase3: + mov word ptr [edi], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase4: + shr ebx, 16 + mov byte ptr [edi+2], bl + jmp beginmvlineasm4 +ALIGN 16 +mvcase5: + mov byte ptr [edi], bl + shr ebx, 16 + mov byte ptr [edi+2], bl + jmp beginmvlineasm4 +ALIGN 16 + mvcase6: + shr ebx, 8 + mov word ptr [edi+1], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase7: + mov word ptr [edi], bx + shr ebx, 16 + mov byte ptr [edi+2], bl + jmp beginmvlineasm4 +ALIGN 16 +mvcase8: + shr ebx, 16 + mov byte ptr [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase9: + mov byte ptr [edi], bl + shr ebx, 16 + mov byte ptr [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase10: + mov byte ptr [edi+1], bh + shr ebx, 16 + mov byte ptr [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase11: + mov word ptr [edi], bx + shr ebx, 16 + mov byte ptr [edi+3], bh + jmp beginmvlineasm4 +ALIGN 16 +mvcase12: + shr ebx, 16 + mov word ptr [edi+2], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase13: + mov byte ptr [edi], bl + shr ebx, 16 + mov word ptr [edi+2], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase14: + mov byte ptr [edi+1], bh + shr ebx, 16 + mov word ptr [edi+2], bx + jmp beginmvlineasm4 +ALIGN 16 +mvcase15: + mov dword ptr [edi], ebx + jmp beginmvlineasm4 + +ALIGN 16 +PUBLIC setupspritevline_ +setupspritevline_: + mov dword ptr [spal+2], eax + + mov eax, esi ;xinc's + shl eax, 16 + mov dword ptr [smach1+2], eax + mov dword ptr [smach4+2], eax + mov eax, esi + sar eax, 16 + add eax, ebx ;watch out with ebx - it's passed + mov dword ptr [smach2+2], eax + add eax, edx + mov dword ptr [smach5+2], eax + + mov dword ptr [smach3+2], ecx ;yinc's + ret + +ALIGN 16 +PUBLIC spritevline_ + ;eax = 0, ebx = x, ecx = cnt, edx = y, esi = yplc, edi = p +prestartsvline: +smach1: add ebx, 88888888h ;xincshl16 + mov al, byte ptr [esi] +smach2: adc esi, 88888888h ;xincshr16+yalwaysinc + +startsvline: +spal: mov al, [eax+88888888h] ;palookup + mov byte ptr [edi], al +fixchain1s: add edi, 320 + +spritevline_: +smach3: add edx, 88888888h ;dayinc + dec ecx + ja short prestartsvline ;jump if (no carry (add)) and (not zero (dec))! + jz short endsvline +smach4: add ebx, 88888888h ;xincshl16 + mov al, byte ptr [esi] +smach5: adc esi, 88888888h ;xincshr16+yalwaysinc+daydime + jmp short startsvline +endsvline: + ret + +ALIGN 16 +PUBLIC msetupspritevline_ +msetupspritevline_: + mov dword ptr [mspal+2], eax + + mov eax, esi ;xinc's + shl eax, 16 + mov dword ptr [msmach1+2], eax + mov dword ptr [msmach4+2], eax + mov eax, esi + sar eax, 16 + add eax, ebx ;watch out with ebx - it's passed + mov dword ptr [msmach2+2], eax + add eax, edx + mov dword ptr [msmach5+2], eax + + mov dword ptr [msmach3+2], ecx ;yinc's + ret + +ALIGN 16 +PUBLIC mspritevline_ + ;eax = 0, ebx = x, ecx = cnt, edx = y, esi = yplc, edi = p +mprestartsvline: +msmach1: add ebx, 88888888h ;xincshl16 + mov al, byte ptr [esi] +msmach2: adc esi, 88888888h ;xincshr16+yalwaysinc + +mstartsvline: + cmp al, 255 + je short mskipsvline +mspal: mov al, [eax+88888888h] ;palookup + mov byte ptr [edi], al +mskipsvline: +mfixchain1s: add edi, 320 + +mspritevline_: +msmach3: add edx, 88888888h ;dayinc + dec ecx + ja short mprestartsvline ;jump if (no carry (add)) and (not zero (dec))! + jz short mendsvline +msmach4: add ebx, 88888888h ;xincshl16 + mov al, byte ptr [esi] +msmach5: adc esi, 88888888h ;xincshr16+yalwaysinc+daydime + jmp short mstartsvline +mendsvline: + ret + +ALIGN 16 +PUBLIC tsetupspritevline_ +tsetupspritevline_: + mov dword ptr [tspal+2], eax + + mov eax, esi ;xinc's + shl eax, 16 + mov dword ptr [tsmach1+2], eax + mov dword ptr [tsmach4+2], eax + mov eax, esi + sar eax, 16 + add eax, ebx ;watch out with ebx - it's passed + mov dword ptr [tsmach2+2], eax + add eax, edx + mov dword ptr [tsmach5+2], eax + + mov dword ptr [tsmach3+2], ecx ;yinc's + ret + +ALIGN 16 +PUBLIC tspritevline_ +tspritevline_: + ;eax = 0, ebx = x, ecx = cnt, edx = y, esi = yplc, edi = p + push ebp + mov ebp, ebx + xor ebx, ebx + jmp tenterspritevline +ALIGN 16 +tprestartsvline: +tsmach1: add ebp, 88888888h ;xincshl16 + mov al, byte ptr [esi] +tsmach2: adc esi, 88888888h ;xincshr16+yalwaysinc + +tstartsvline: + cmp al, 255 + je short tskipsvline +transrev2: + mov bh, byte ptr [edi] +transrev3: +tspal: mov bl, [eax+88888888h] ;palookup +tmach4: mov al, byte ptr [ebx+88888888h] ;_transluc + mov byte ptr [edi], al +tskipsvline: +tfixchain1s: add edi, 320 + +tenterspritevline: +tsmach3: add edx, 88888888h ;dayinc + dec ecx + ja short tprestartsvline ;jump if (no carry (add)) and (not zero (dec))! + jz short tendsvline +tsmach4: add ebp, 88888888h ;xincshl16 + mov al, byte ptr [esi] +tsmach5: adc esi, 88888888h ;xincshr16+yalwaysinc+daydime + jmp short tstartsvline +tendsvline: + pop ebp + ret + +ALIGN 16 +PUBLIC msethlineshift_ +msethlineshift_: + neg al + mov byte ptr [msh1d+2], al + mov byte ptr [msh2d+3], bl + mov byte ptr [msh3d+2], al + mov byte ptr [msh4d+3], bl + mov byte ptr [msh5d+2], al + mov byte ptr [msh6d+3], bl + ret + +ALIGN 16 +PUBLIC mhline_ +mhline_: + ;_asm1 = bxinc + ;_asm2 = byinc + ;_asm3 = shadeoffs + ;eax = picoffs + ;ebx = bx + ;ecx = cnt + ;edx = ? + ;esi = by + ;edi = p + + mov dword ptr [mmach1d+2], eax + mov dword ptr [mmach5d+2], eax + mov dword ptr [mmach9d+2], eax + mov eax, _asm3 + mov dword ptr [mmach2d+2], eax + mov dword ptr [mmach2da+2], eax + mov dword ptr [mmach2db+2], eax + mov dword ptr [mmach6d+2], eax + mov dword ptr [mmach10d+2], eax + mov eax, _asm1 + mov dword ptr [mmach3d+2], eax + mov dword ptr [mmach7d+2], eax + mov eax, _asm2 + mov dword ptr [mmach4d+2], eax + mov dword ptr [mmach8d+2], eax + jmp short mhlineskipmodify_ + +ALIGN 16 +PUBLIC mhlineskipmodify_ +mhlineskipmodify_: + + push ebp + + xor eax, eax + mov ebp, ebx + + test ecx, 00010000h + jnz short mbeghline + +msh1d: shr ebx, 26 +msh2d: shld ebx, esi, 6 + add ebp, _asm1 +mmach9d: mov al, byte ptr [ebx+88888888h] ;picoffs + add esi, _asm2 + cmp al, 255 + je mskip5 + + mmach10d: mov cl, byte ptr [eax+88888888h] ;shadeoffs + mov byte ptr [edi], cl +mskip5: + inc edi + sub ecx, 65536 + jc mendhline + jmp short mbeghline + +ALIGN 16 +mpreprebeghline: ;1st only + mov al, cl +mmach2d: mov al, byte ptr [eax+88888888h] ;shadeoffs + mov byte ptr [edi], al + +mprebeghline: + add edi, 2 + sub ecx, 131072 + jc short mendhline +mbeghline: +mmach3d: lea ebx, [ebp+88888888h] ;bxinc +msh3d: shr ebp, 26 +msh4d: shld ebp, esi, 6 +mmach4d: add esi, 88888888h ;byinc +mmach1d: mov cl, byte ptr [ebp+88888888h] ;picoffs +mmach7d: lea ebp, [ebx+88888888h] ;bxinc + +msh5d: shr ebx, 26 +msh6d: shld ebx, esi, 6 +mmach8d: add esi, 88888888h ;byinc +mmach5d: mov ch, byte ptr [ebx+88888888h] ;picoffs + + cmp cl, 255 + je short mskip1 + cmp ch, 255 + je short mpreprebeghline + + mov al, cl ;BOTH +mmach2da: mov bl, byte ptr [eax+88888888h] ;shadeoffs + mov al, ch +mmach2db: mov bh, byte ptr [eax+88888888h] ;shadeoffs + mov word ptr [edi], bx + add edi, 2 + sub ecx, 131072 + jnc short mbeghline + jmp mendhline +mskip1: ;2nd only + cmp ch, 255 + je short mprebeghline + + mov al, ch +mmach6d: mov al, byte ptr [eax+88888888h] ;shadeoffs + mov byte ptr [edi+1], al + add edi, 2 + sub ecx, 131072 + jnc short mbeghline +mendhline: + + pop ebp + ret + +ALIGN 16 +PUBLIC tsethlineshift_ +tsethlineshift_: + neg al + mov byte ptr [tsh1d+2], al + mov byte ptr [tsh2d+3], bl + mov byte ptr [tsh3d+2], al + mov byte ptr [tsh4d+3], bl + mov byte ptr [tsh5d+2], al + mov byte ptr [tsh6d+3], bl + ret + +ALIGN 16 +PUBLIC thline_ +thline_: + ;_asm1 = bxinc + ;_asm2 = byinc + ;_asm3 = shadeoffs + ;eax = picoffs + ;ebx = bx + ;ecx = cnt + ;edx = ? + ;esi = by + ;edi = p + + mov dword ptr [tmach1d+2], eax + mov dword ptr [tmach5d+2], eax + mov dword ptr [tmach9d+2], eax + mov eax, _asm3 + mov dword ptr [tmach2d+2], eax + mov dword ptr [tmach6d+2], eax + mov dword ptr [tmach10d+2], eax + mov eax, _asm1 + mov dword ptr [tmach3d+2], eax + mov dword ptr [tmach7d+2], eax + mov eax, _asm2 + mov dword ptr [tmach4d+2], eax + mov dword ptr [tmach8d+2], eax + jmp thlineskipmodify_ + +ALIGN 16 +PUBLIC thlineskipmodify_ +thlineskipmodify_: + + push ebp + + xor eax, eax + xor edx, edx + mov ebp, ebx + + test ecx, 00010000h + jnz short tbeghline + +tsh1d: shr ebx, 26 +tsh2d: shld ebx, esi, 6 + add ebp, _asm1 +tmach9d: mov al, byte ptr [ebx+88888888h] ;picoffs + add esi, _asm2 + cmp al, 255 + je tskip5 + +transrev4: +tmach10d: mov dl, byte ptr [eax+88888888h] ;shadeoffs +transrev5: + mov dh, byte ptr [edi] +tmach1: mov al, byte ptr [edx+88888888h] ;_transluc + mov byte ptr [edi], al +tskip5: + inc edi + sub ecx, 65536 + jc tendhline + jmp short tbeghline + +ALIGN 16 +tprebeghline: + add edi, 2 + sub ecx, 131072 + jc short tendhline +tbeghline: +tmach3d: lea ebx, [ebp+88888888h] ;bxinc +tsh3d: shr ebp, 26 +tsh4d: shld ebp, esi, 6 +tmach4d: add esi, 88888888h ;byinc +tmach1d: mov cl, byte ptr [ebp+88888888h] ;picoffs +tmach7d: lea ebp, [ebx+88888888h] ;bxinc + +tsh5d: shr ebx, 26 +tsh6d: shld ebx, esi, 6 +tmach8d: add esi, 88888888h ;byinc +tmach5d: mov ch, byte ptr [ebx+88888888h] ;picoffs + + cmp cx, 0ffffh + je short tprebeghline + + mov bx, word ptr [edi] + + cmp cl, 255 + je short tskip1 + mov al, cl +transrev6: +tmach2d: mov dl, byte ptr [eax+88888888h] ;shadeoffs +transrev7: + mov dh, bl +tmach2: mov al, byte ptr [edx+88888888h] ;_transluc + mov byte ptr [edi], al + + cmp ch, 255 + je short tskip2 +tskip1: + mov al, ch +transrev8: +tmach6d: mov dl, byte ptr [eax+88888888h] ;shadeoffs +transrev9: + mov dh, bh +tmach3: mov al, byte ptr [edx+88888888h] ;_transluc + mov byte ptr [edi+1], al +tskip2: + + add edi, 2 + sub ecx, 131072 + jnc tbeghline +tendhline: + + pop ebp + ret + + + ;eax=shiftval, ebx=palookup1, ecx=palookup2 +ALIGN 16 +PUBLIC setuptvlineasm2_ +setuptvlineasm2_: + mov byte ptr [tran2shra+2], al + mov byte ptr [tran2shrb+2], al + mov dword ptr [tran2pala+2], ebx + mov dword ptr [tran2palb+2], ecx + mov dword ptr [tran2palc+2], ebx + mov dword ptr [tran2pald+2], ecx + ret + + ;Pass: eax=vplc2, ebx=vinc1, ecx=bufplc1, edx=bufplc2, esi=vplc1, edi=p + ; _asm1=vinc2, _asm2=pend + ;Return: _asm1=vplc1, _asm2=vplc2 +ALIGN 16 +PUBLIC tvlineasm2_ +tvlineasm2_: + push ebp + + mov ebp, eax + + mov dword ptr [tran2inca+2], ebx + mov eax, _asm1 + mov dword ptr [tran2incb+2], eax + + mov dword ptr [tran2bufa+2], ecx ;bufplc1 + mov dword ptr [tran2bufb+2], edx ;bufplc2 + + mov eax, _asm2 + sub edi, eax + mov dword ptr [tran2edia+3], eax + mov dword ptr [tran2edic+2], eax + inc eax + mov dword ptr [tran2edie+2], eax +fixchaint2a: sub eax, 320 + mov dword ptr [tran2edif+2], eax + dec eax + mov dword ptr [tran2edib+3], eax + mov dword ptr [tran2edid+2], eax + + xor ecx, ecx + xor edx, edx + jmp short begintvline2 + + ;eax 0000000000 temp temp + ;ebx 0000000000 odat2 odat1 + ;ecx 0000000000000000 ndat1 + ;edx 0000000000000000 ndat2 + ;esi vplc1 + ;edi videoplc-------------- + ;ebp vplc2 + +ALIGN 16 + ;LEFT ONLY +skipdraw2: +transrev10: +tran2edic: mov ah, byte ptr [edi+88888888h] ;getpixel +transrev11: +tran2palc: mov al, byte ptr [ecx+88888888h] ;palookup1 +fixchaint2d: add edi, 320 +tran2trac: mov bl, byte ptr [eax+88888888h] ;_transluc +tran2edid: mov byte ptr [edi+88888888h-320], bl ;drawpixel + jnc short begintvline2 + jmp endtvline2 + +skipdraw1: + cmp dl, 255 + jne short skipdraw3 +fixchaint2b: add edi, 320 + jc short endtvline2 + +begintvline2: + mov eax, esi +tran2shra: shr eax, 88h ;globalshift + mov ebx, ebp +tran2shrb: shr ebx, 88h ;globalshift +tran2inca: add esi, 88888888h ;vinc1 +tran2incb: add ebp, 88888888h ;vinc2 +tran2bufa: mov cl, byte ptr [eax+88888888h] ;bufplc1 + cmp cl, 255 +tran2bufb: mov dl, byte ptr [ebx+88888888h] ;bufplc2 + je short skipdraw1 + cmp dl, 255 + je short skipdraw2 + + ;mov ax The transluscent reverse of both! + ;mov bl, ah + ;mov ah + ;mov bh + + ;BOTH +transrev12: +tran2edia: mov bx, word ptr [edi+88888888h] ;getpixels +transrev13: + mov ah, bl +transrev14: +tran2pala: mov al, byte ptr [ecx+88888888h] ;palookup1 +transrev15: +tran2palb: mov bl, byte ptr [edx+88888888h] ;palookup2 +fixchaint2c: add edi, 320 +tran2traa: mov al, byte ptr [eax+88888888h] ;_transluc +tran2trab: mov ah, byte ptr [ebx+88888888h] ;_transluc +tran2edib: mov word ptr [edi+88888888h-320], ax ;drawpixels + jnc short begintvline2 + jmp short endtvline2 + + ;RIGHT ONLY +skipdraw3: +transrev16: +tran2edie: mov ah, byte ptr [edi+88888889h] ;getpixel +transrev17: +tran2pald: mov al, byte ptr [edx+88888888h] ;palookup2 +fixchaint2e: add edi, 320 +tran2trad: mov bl, byte ptr [eax+88888888h] ;_transluc +tran2edif: mov byte ptr [edi+88888889h-320], bl ;drawpixel + jnc short begintvline2 + +endtvline2: + mov _asm1, esi + mov _asm2, ebp + + pop ebp + ret + + +BITSOFPRECISION equ 3 +BITSOFPRECISIONPOW equ 8 + +;Double-texture mapping with palette lookup +;eax: ylo1------------|----dat|----dat +;ebx: ylo2--------------------|----cnt +;ecx: 000000000000000000000000|---temp +;edx: xhi1-xlo1---------------|---yhi1 +;esi: xhi2-xlo2---------------|---yhi2 +;edi: ------------------------videopos +;ebp: ----------------------------temp + +ALIGN 16 +PUBLIC setupslopevlin2_ +setupslopevlin2_: + mov dword ptr [slop3+2], edx ;ptr + mov dword ptr [slop7+2], edx ;ptr + mov dword ptr [slop4+2], esi ;tptr + mov dword ptr [slop8+2], esi ;tptr + mov byte ptr [slop2+2], ah ;ybits + mov byte ptr [slop6+2], ah ;ybits + mov dword ptr [slop9+2], edi ;pinc + + mov edx, 1 + mov cl, al + add cl, ah + shl edx, cl + dec edx + mov cl, ah + ror edx, cl + + mov dword ptr [slop1+2], edx ;ybits...xbits + mov dword ptr [slop5+2], edx ;ybits...xbits + + ret + +ALIGN 16 +PUBLIC slopevlin2_ +slopevlin2_: + push ebp + xor ecx, ecx + +slopevlin2begin: + mov ebp, edx +slop1: and ebp, 88000088h ;ybits...xbits +slop2: rol ebp, 6 ;ybits + add eax, _asm1 ;xinc1<>(32-xbits)) +slop3: mov cl, byte ptr [ebp+88888888h] ;bufplc + + mov ebp, esi +slop4: mov al, byte ptr [ecx+88888888h] ;paloffs +slop5: and ebp, 88000088h ;ybits...xbits +slop6: rol ebp, 6 ;ybits + add ebx, _asm3 ;xinc2<>(32-xbits)) +slop8: mov ah, byte ptr [ecx+88888888h] ;paloffs + + dec bl + mov word ptr [edi], ax +slop9: lea edi, [edi+88888888h] ;pinc + jnz short slopevlin2begin + + pop ebp + mov eax, edi + ret + + +ALIGN 16 +PUBLIC setupslopevlin_ +setupslopevlin_: + mov dword ptr [slopmach3+3], ebx ;ptr + mov dword ptr [slopmach5+2], ecx ;pinc + neg ecx + mov dword ptr [slopmach6+2], ecx ;-pinc + + mov edx, 1 + mov cl, al + shl edx, cl + dec edx + mov cl, ah + shl edx, cl + mov dword ptr [slopmach7+2], edx + + neg ah + mov byte ptr [slopmach2+2], ah + + sub ah, al + mov byte ptr [slopmach1+2], ah + + fild dword ptr _asm1 + fstp dword ptr _asm2 + ret + +ALIGN 16 +PUBLIC slopevlin_ +slopevlin_: + mov _ebpbak, ebp + mov _espbak, esp + + sub ecx, esp + mov dword ptr [slopmach4+3], ecx + + fild dword ptr _asm3 +slopmach6: lea ebp, [eax+88888888h] + fadd dword ptr _asm2 + + mov _asm1, ebx + shl ebx, 3 + + mov eax, _globalx3 + mov ecx, _globaly3 + imul eax, ebx + imul ecx, ebx + add esi, eax + add edi, ecx + + mov ebx, edx + jmp short bigslopeloop +ALIGN 16 +bigslopeloop: + fst dword ptr _fpuasm + + mov eax, _fpuasm + add eax, eax + sbb edx, edx + mov ecx, eax + shr ecx, 24 + and eax, 00ffe000h + shr eax, 11 + sub cl, 2 + mov eax, dword ptr _reciptable[eax] + shr eax, cl + xor eax, edx + mov edx, _asm1 + mov ecx, _globalx3 + mov _asm1, eax + sub eax, edx + mov edx, _globaly3 + imul ecx, eax + imul eax, edx + + fadd dword ptr _asm2 + + cmp ebx, BITSOFPRECISIONPOW + mov _asm4, ebx + mov cl, bl + jl short slopeskipmin + mov cl, BITSOFPRECISIONPOW +slopeskipmin: + +;eax: yinc............. +;ebx: 0 0 0 ? +;ecx: xinc......... cnt +;edx: ? +;esi: xplc............. +;edi: yplc............. +;ebp: videopos + + mov ebx, esi + mov edx, edi + +beginnerslopeloop: +slopmach1: shr ebx, 20 + add esi, ecx +slopmach2: shr edx, 26 +slopmach7: and ebx, 88888888h + add edi, eax +slopmach5: add ebp, 88888888h ;pinc +slopmach3: mov dl, byte ptr [ebx+edx+88888888h] ;ptr +slopmach4: mov ebx, dword ptr [esp+88888888h] + sub esp, 4 + dec cl + mov al, byte ptr [ebx+edx] ;tptr + mov ebx, esi + mov [ebp], al + mov edx, edi + jnz short beginnerslopeloop + + mov ebx, _asm4 + sub ebx, BITSOFPRECISIONPOW + jg bigslopeloop + + ffree st(0) + + mov esp, _espbak + mov ebp, _ebpbak + ret + + +ALIGN 16 +PUBLIC setuprhlineasm4_ +setuprhlineasm4_: + mov dword ptr [rmach1a+2], eax + mov dword ptr [rmach1b+2], eax + mov dword ptr [rmach1c+2], eax + mov dword ptr [rmach1d+2], eax + mov dword ptr [rmach1e+2], eax + + mov dword ptr [rmach2a+2], ebx + mov dword ptr [rmach2b+2], ebx + mov dword ptr [rmach2c+2], ebx + mov dword ptr [rmach2d+2], ebx + mov dword ptr [rmach2e+2], ebx + + mov dword ptr [rmach3a+2], ecx + mov dword ptr [rmach3b+2], ecx + mov dword ptr [rmach3c+2], ecx + mov dword ptr [rmach3d+2], ecx + mov dword ptr [rmach3e+2], ecx + + mov dword ptr [rmach4a+2], edx + mov dword ptr [rmach4b+2], edx + mov dword ptr [rmach4c+2], edx + mov dword ptr [rmach4d+2], edx + mov dword ptr [rmach4e+2], edx + + mov dword ptr [rmach5a+2], esi + mov dword ptr [rmach5b+2], esi + mov dword ptr [rmach5c+2], esi + mov dword ptr [rmach5d+2], esi + mov dword ptr [rmach5e+2], esi + ret + + ;Non power of 2, non masking, with palookup method #1 (6 clock cycles) + ;eax: dat dat dat dat + ;ebx: bufplc + ;ecx: 0 dat + ;edx: xlo + ;esi: ylo + ;edi: videopos/cnt + ;ebp: tempvar + ;esp: +ALIGN 16 +PUBLIC rhlineasm4_ +rhlineasm4_: + push ebp + + cmp eax, 0 + jle endrhline + + lea ebp, [edi-4] + sub ebp, eax + mov dword ptr [rmach6a+2], ebp + add ebp, 3 + mov dword ptr [rmach6b+2], ebp + mov edi, eax + test edi, 3 + jz short begrhline + jmp short startrhline1 + +ALIGN 16 +startrhline1: + mov cl, byte ptr [ebx] ;bufplc +rmach1e: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach2e: sub esi, 88888888h ;ylo +rmach3e: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach4e: mov al, byte ptr [ecx+88888888h] ;palookup +rmach5e: and ebp, 88888888h ;tilesizy +rmach6b: mov byte ptr [edi+88888888h], al ;vidcntoffs + sub ebx, ebp + dec edi + test edi, 3 + jnz short startrhline1 + test edi, edi + jz endrhline + +begrhline: + mov cl, byte ptr [ebx] ;bufplc +rmach1a: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach2a: sub esi, 88888888h ;ylo +rmach3a: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5a: and ebp, 88888888h ;tilesizy + sub ebx, ebp + +rmach1b: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach4a: mov ah, byte ptr [ecx+88888888h] ;palookup + mov cl, byte ptr [ebx] ;bufplc +rmach2b: sub esi, 88888888h ;ylo +rmach3b: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5b: and ebp, 88888888h ;tilesizy +rmach4b: mov al, byte ptr [ecx+88888888h] ;palookup + sub ebx, ebp + + shl eax, 16 + + mov cl, byte ptr [ebx] ;bufplc +rmach1c: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach2c: sub esi, 88888888h ;ylo +rmach3c: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5c: and ebp, 88888888h ;tilesizy + sub ebx, ebp + +rmach1d: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmach4c: mov ah, byte ptr [ecx+88888888h] ;palookup + mov cl, byte ptr [ebx] ;bufplc +rmach2d: sub esi, 88888888h ;ylo +rmach3d: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmach5d: and ebp, 88888888h ;tilesizy +rmach4d: mov al, byte ptr [ecx+88888888h] ;palookup + sub ebx, ebp + +rmach6a: mov dword ptr [edi+88888888h], eax ;vidcntoffs + sub edi, 4 + jnz begrhline +endrhline: + pop ebp + ret + +ALIGN 16 +PUBLIC setuprmhlineasm4_ +setuprmhlineasm4_: + mov dword ptr [rmmach1+2], eax + mov dword ptr [rmmach2+2], ebx + mov dword ptr [rmmach3+2], ecx + mov dword ptr [rmmach4+2], edx + mov dword ptr [rmmach5+2], esi + ret + +ALIGN 16 +PUBLIC rmhlineasm4_ +rmhlineasm4_: + push ebp + + cmp eax, 0 + jle short endrmhline + + lea ebp, [edi-1] + sub ebp, eax + mov dword ptr [rmmach6+2], ebp + mov edi, eax + jmp short begrmhline + +ALIGN 16 +begrmhline: + mov cl, byte ptr [ebx] ;bufplc +rmmach1: sub edx, 88888888h ;xlo + sbb ebp, ebp +rmmach2: sub esi, 88888888h ;ylo +rmmach3: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +rmmach5: and ebp, 88888888h ;tilesizy + cmp cl, 255 + je short rmskip +rmmach4: mov al, byte ptr [ecx+88888888h] ;palookup +rmmach6: mov byte ptr [edi+88888888h], al ;vidcntoffs +rmskip: + sub ebx, ebp + dec edi + jnz short begrmhline +endrmhline: + pop ebp + ret + +ALIGN 16 +PUBLIC setupqrhlineasm4_ +setupqrhlineasm4_: + mov dword ptr [qrmach2e+2], ebx + mov dword ptr [qrmach3e+2], ecx + xor edi, edi + sub edi, ecx + mov dword ptr [qrmach7a+2], edi + mov dword ptr [qrmach7b+2], edi + + add ebx, ebx + adc ecx, ecx + mov dword ptr [qrmach2a+2], ebx + mov dword ptr [qrmach2b+2], ebx + mov dword ptr [qrmach3a+2], ecx + mov dword ptr [qrmach3b+2], ecx + + mov dword ptr [qrmach4a+2], edx + mov dword ptr [qrmach4b+2], edx + mov dword ptr [qrmach4c+2], edx + mov dword ptr [qrmach4d+2], edx + mov dword ptr [qrmach4e+2], edx + ret + + ;Non power of 2, non masking, with palookup method (FASTER BUT NO SBB'S) + ;eax: dat dat dat dat + ;ebx: bufplc + ;ecx: 0 dat + ;edx: 0 dat + ;esi: ylo + ;edi: videopos/cnt + ;ebp: ? + ;esp: +ALIGN 16 +PUBLIC qrhlineasm4_ ;4 pixels in 9 cycles! 2.25 cycles/pixel +qrhlineasm4_: + push ebp + + cmp eax, 0 + jle endqrhline + + mov ebp, eax + test ebp, 3 + jz short skipqrhline1 + jmp short startqrhline1 + +ALIGN 16 +startqrhline1: + mov cl, byte ptr [ebx] ;bufplc + dec edi +qrmach2e: sub esi, 88888888h ;ylo + dec ebp +qrmach3e: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +qrmach4e: mov al, byte ptr [ecx+88888888h] ;palookup + mov byte ptr [edi], al ;vidcntoffs + test ebp, 3 + jnz short startqrhline1 + test ebp, ebp + jz short endqrhline + +skipqrhline1: + mov cl, byte ptr [ebx] ;bufplc + jmp short begqrhline +ALIGN 16 +begqrhline: +qrmach7a: mov dl, byte ptr [ebx+88888888h] ;bufplc +qrmach2a: sub esi, 88888888h ;ylo +qrmach3a: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +qrmach4a: mov ah, byte ptr [ecx+88888888h] ;palookup +qrmach4b: mov al, byte ptr [edx+88888888h] ;palookup + sub edi, 4 + shl eax, 16 + mov cl, byte ptr [ebx] ;bufplc +qrmach7b: mov dl, byte ptr [ebx+88888888h] ;bufplc +qrmach2b: sub esi, 88888888h ;ylo +qrmach3b: sbb ebx, 88888888h ;xhi*tilesizy + yhi+ycarry +qrmach4c: mov ah, byte ptr [ecx+88888888h] ;palookup +qrmach4d: mov al, byte ptr [edx+88888888h] ;palookup + mov cl, byte ptr [ebx] ;bufplc + mov dword ptr [edi], eax + sub ebp, 4 + jnz short begqrhline + +endqrhline: + pop ebp + ret + + +PUBLIC setupdrawslab_ +setupdrawslab_: + mov dword ptr [voxbpl1+2], eax + mov dword ptr [voxbpl2+2], eax + mov dword ptr [voxbpl3+2], eax + mov dword ptr [voxbpl4+2], eax + mov dword ptr [voxbpl5+2], eax + mov dword ptr [voxbpl6+2], eax + mov dword ptr [voxbpl7+2], eax + mov dword ptr [voxbpl8+2], eax + + mov dword ptr [voxpal1+2], ebx + mov dword ptr [voxpal2+2], ebx + mov dword ptr [voxpal3+2], ebx + mov dword ptr [voxpal4+2], ebx + mov dword ptr [voxpal5+2], ebx + mov dword ptr [voxpal6+2], ebx + mov dword ptr [voxpal7+2], ebx + mov dword ptr [voxpal8+2], ebx + ret + +ALIGN 16 +PUBLIC drawslab_ +drawslab_: + push ebp + cmp eax, 2 + je voxbegdraw2 + ja voxskip2 + xor eax, eax +voxbegdraw1: + mov ebp, ebx + shr ebp, 16 + add ebx, edx + dec ecx + mov al, byte ptr [esi+ebp] +voxpal1: mov al, byte ptr [eax+88888888h] + mov byte ptr [edi], al +voxbpl1: lea edi, [edi+88888888h] + jnz voxbegdraw1 + pop ebp + ret + +voxbegdraw2: + mov ebp, ebx + shr ebp, 16 + add ebx, edx + xor eax, eax + dec ecx + mov al, byte ptr [esi+ebp] +voxpal2: mov al, byte ptr [eax+88888888h] + mov ah, al + mov word ptr [edi], ax +voxbpl2: lea edi, [edi+88888888h] + jnz voxbegdraw2 + pop ebp + ret + +voxskip2: + cmp eax, 4 + jne voxskip4 + xor eax, eax +voxbegdraw4: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal3: mov al, byte ptr [eax+88888888h] + mov ah, al + shl eax, 8 + mov al, ah + shl eax, 8 + mov al, ah + mov dword ptr [edi], eax +voxbpl3: add edi, 88888888h + dec ecx + jnz voxbegdraw4 + pop ebp + ret + +voxskip4: + add eax, edi + + test edi, 1 + jz voxskipslab1 + cmp edi, eax + je voxskipslab1 + + push eax + push ebx + push ecx + push edi +voxbegslab1: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal4: mov al, byte ptr [eax+88888888h] + mov byte ptr [edi], al +voxbpl4: add edi, 88888888h + dec ecx + jnz voxbegslab1 + pop edi + pop ecx + pop ebx + pop eax + inc edi + +voxskipslab1: + push eax + test edi, 2 + jz voxskipslab2 + dec eax + cmp edi, eax + jge voxskipslab2 + + push ebx + push ecx + push edi +voxbegslab2: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal5: mov al, byte ptr [eax+88888888h] + mov ah, al + mov word ptr [edi], ax +voxbpl5: add edi, 88888888h + dec ecx + jnz voxbegslab2 + pop edi + pop ecx + pop ebx + add edi, 2 + +voxskipslab2: + mov eax, [esp] + + sub eax, 3 + cmp edi, eax + jge voxskipslab3 + +voxprebegslab3: + push ebx + push ecx + push edi +voxbegslab3: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal6: mov al, byte ptr [eax+88888888h] + mov ah, al + shl eax, 8 + mov al, ah + shl eax, 8 + mov al, ah + mov dword ptr [edi], eax +voxbpl6: add edi, 88888888h + dec ecx + jnz voxbegslab3 + pop edi + pop ecx + pop ebx + add edi, 4 + + mov eax, [esp] + + sub eax, 3 + cmp edi, eax + jl voxprebegslab3 + +voxskipslab3: + mov eax, [esp] + + dec eax + cmp edi, eax + jge voxskipslab4 + + push ebx + push ecx + push edi +voxbegslab4: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal7: mov al, byte ptr [eax+88888888h] + mov ah, al + mov word ptr [edi], ax +voxbpl7: add edi, 88888888h + dec ecx + jnz voxbegslab4 + pop edi + pop ecx + pop ebx + add edi, 2 + +voxskipslab4: + pop eax + + cmp edi, eax + je voxskipslab5 + +voxbegslab5: + mov ebp, ebx + add ebx, edx + shr ebp, 16 + xor eax, eax + mov al, byte ptr [esi+ebp] +voxpal8: mov al, byte ptr [eax+88888888h] + mov byte ptr [edi], al +voxbpl8: add edi, 88888888h + dec ecx + jnz voxbegslab5 + +voxskipslab5: + pop ebp + ret + +;modify: loinc +;eax: | dat | dat | dat | dat | +;ebx: | loplc1 | +;ecx: | loplc2 | cnthi | cntlo | +;edx: |--------|--------|--------| hiplc1 | +;esi: |--------|--------|--------| hiplc2 | +;edi: |--------|--------|--------| vidplc | +;ebp: |--------|--------|--------| hiinc | + +PUBLIC stretchhline_ +stretchhline_: + push ebp + + mov eax, ebx + shl ebx, 16 + sar eax, 16 + and ecx, 0000ffffh + or ecx, ebx + + add esi, eax + mov eax, edx + mov edx, esi + + mov ebp, eax + shl eax, 16 + sar ebp, 16 + + add ecx, eax + adc esi, ebp + + add eax, eax + adc ebp, ebp + mov dword ptr [loinc1+2], eax + mov dword ptr [loinc2+2], eax + mov dword ptr [loinc3+2], eax + mov dword ptr [loinc4+2], eax + + inc ch + + jmp begloop + +begloop: + mov al, [edx] +loinc1: sub ebx, 88888888h + sbb edx, ebp + mov ah, [esi] +loinc2: sub ecx, 88888888h + sbb esi, ebp + sub edi, 4 + shl eax, 16 +loinc3: sub ebx, 88888888h + mov al, [edx] + sbb edx, ebp + mov ah, [esi] +loinc4: sub ecx, 88888888h + sbb esi, ebp + mov [edi], eax + dec cl + jnz begloop + dec ch + jnz begloop + + pop ebp + ret + + +PUBLIC mmxoverlay_ +mmxoverlay_: + pushfd ;Check if CPUID is available + pop eax + mov ebx, eax + xor eax, 00200000h + push eax + popfd + pushfd + pop eax + cmp eax, ebx + je pentium + xor eax, eax + dw 0a20fh + test eax, eax + jz pentium + mov eax, 1 + dw 0a20fh + and eax, 00000f00h + test edx, 00800000h ;Check if MMX is available + jz nommx + cmp eax, 00000600h ;Check if P6 Family or not + jae pentiumii + jmp pentiummmx +nommx: + cmp eax, 00000600h ;Check if P6 Family or not + jae pentiumpro +pentium: + ret + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PENTIUM II Overlays ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +pentiumii: + ;Hline overlay (MMX doens't help) + mov byte ptr [sethlinesizes_], 0xe9 + mov dword ptr [sethlinesizes_+1], (offset prosethlinesizes_)-(offset sethlinesizes_)-5 + mov byte ptr [setpalookupaddress_], 0xe9 + mov dword ptr [setpalookupaddress_+1], (offset prosetpalookupaddress_)-(offset setpalookupaddress_)-5 + mov byte ptr [setuphlineasm4_], 0xc3 ;ret (no code required) + mov byte ptr [hlineasm4_], 0xe9 + mov dword ptr [hlineasm4_+1], (offset prohlineasm4_)-(offset hlineasm4_)-5 + + ;Vline overlay + mov byte ptr [setupvlineasm_], 0xe9 + mov dword ptr [setupvlineasm_+1], (offset prosetupvlineasm_)-(offset setupvlineasm_)-5 + mov byte ptr [vlineasm4_], 0xe9 + mov dword ptr [vlineasm4_+1], (offset provlineasm4_)-(offset vlineasm4_)-5 + + ret + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PENTIUM MMX Overlays ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +pentiummmx: + ret + +;ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +;³ PENTIUM PRO Overlays ³ +;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +pentiumpro: + ;Hline overlay (MMX doens't help) + mov byte ptr [sethlinesizes_], 0xe9 + mov dword ptr [sethlinesizes_+1], (offset prosethlinesizes_)-(offset sethlinesizes_)-5 + mov byte ptr [setpalookupaddress_], 0xe9 + mov dword ptr [setpalookupaddress_+1], (offset prosetpalookupaddress_)-(offset setpalookupaddress_)-5 + mov byte ptr [setuphlineasm4_], 0xc3 ;ret (no code required) + mov byte ptr [hlineasm4_], 0xe9 + mov dword ptr [hlineasm4_+1], (offset prohlineasm4_)-(offset hlineasm4_)-5 + + ;Vline overlay + mov byte ptr [setupvlineasm_], 0xe9 + mov dword ptr [setupvlineasm_+1], (offset prosetupvlineasm_)-(offset setupvlineasm_)-5 + mov byte ptr [vlineasm4_], 0xe9 + mov dword ptr [vlineasm4_+1], (offset provlineasm4_)-(offset vlineasm4_)-5 + + ret + +CODE ENDS +END diff --git a/polymer/build/src/baselayer.c b/polymer/build/src/baselayer.c new file mode 100644 index 000000000..66e567bf1 --- /dev/null +++ b/polymer/build/src/baselayer.c @@ -0,0 +1,206 @@ +#include "compat.h" +#include "osd.h" +#include "build.h" +#include "engineinfo.h" +#include "baselayer.h" + +#ifdef RENDERTYPEWIN +#include "winlayer.h" +#endif + +#ifdef USE_OPENGL +struct glinfo glinfo = { + "Unknown", // vendor + "Unknown", // renderer + "0.0.0", // version + "", // extensions + + 1.0, // max anisotropy + 0, // brga texture format + 0, // clamp-to-edge support + 0, // texture compression + 0, // non-power-of-two textures + 0, // multisampling + 0, // nvidia multisampling hint +}; +#endif + +static int osdfunc_dumpbuildinfo(const osdfuncparm_t *parm) +{ + OSD_Printf( + "Build engine compilation:\n" + " CFLAGS: %s\n" + " LIBS: %s\n" + " Host: %s\n" + " Compiler: %s\n" + " Built: %s\n", + _engine_cflags, + _engine_libs, + _engine_uname, + _engine_compiler, + _engine_date); + + return OSDCMD_OK; +} + +static void onvideomodechange(int newmode) { } +void (*baselayer_onvideomodechange)(int) = onvideomodechange; + +static int osdfunc_setrendermode(const osdfuncparm_t *parm) +{ + int m; + char *p; + + char *modestrs[] = { + "classic software", "polygonal flat-shaded software", + "polygonal textured software", "polygonal OpenGL" + }; + + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + m = Bstrtol(parm->parms[0], &p, 10); + + if (m < 0 || m > 3) return OSDCMD_SHOWHELP; + + setrendermode(m); + OSD_Printf("Rendering method changed to %s\n", modestrs[ getrendermode() ] ); + + return OSDCMD_OK; +} + +#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef DEBUGGINGAIDS +static int osdcmd_hicsetpalettetint(const osdfuncparm_t *parm) +{ + long pal, cols[3], eff; + char *p; + + if (parm->numparms != 5) return OSDCMD_SHOWHELP; + + pal = Batol(parm->parms[0]); + cols[0] = Batol(parm->parms[1]); + cols[1] = Batol(parm->parms[2]); + cols[2] = Batol(parm->parms[3]); + eff = Batol(parm->parms[4]); + + hicsetpalettetint(pal,cols[0],cols[1],cols[2],eff); + + return OSDCMD_OK; +} +#endif + +static int osdcmd_glinfo(const osdfuncparm_t *parm) +{ + char *s,*t,*u,i; + + if (bpp == 8) { + OSD_Printf("glinfo: Not in OpenGL mode.\n"); + return OSDCMD_OK; + } + + OSD_Printf("OpenGL Information:\n" + " Version: %s\n" + " Vendor: %s\n" + " Renderer: %s\n" + " Maximum anisotropy: %.1f%s\n" + " BGRA textures: %s\n" + " Non-x^2 textures: %s\n" + " Texure compression: %s\n" + " Clamp-to-edge: %s\n" + " Multisampling: %s\n" + " Nvidia multisample hint: %s\n" + " Extensions:\n", + glinfo.version, + glinfo.vendor, + glinfo.renderer, + glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)", + glinfo.bgra ? "supported": "not supported", + glinfo.texnpot ? "supported": "not supported", + glinfo.texcompr ? "supported": "not supported", + glinfo.clamptoedge ? "supported": "not supported", + glinfo.multisample ? "supported": "not supported", + glinfo.nvmultisamplehint ? "supported": "not supported" + ); + + s = Bstrdup(glinfo.extensions); + if (!s) OSD_Printf(glinfo.extensions); + else { + i = 0; t = u = s; + while (*t) { + if (*t == ' ') { + if (i&1) { + *t = 0; + OSD_Printf(" %s\n",u); + u = t+1; + } + i++; + } + t++; + } + if (i&1) OSD_Printf(" %s\n",u); + Bfree(s); + } + + return OSDCMD_OK; +} +#endif + +static int osdcmd_vars(const osdfuncparm_t *parm) +{ + int showval = (parm->numparms < 1); + + if (!Bstrcasecmp(parm->name, "screencaptureformat")) { + const char *fmts[2][2] = { {"TGA", "PCX"}, {"0", "1"} }; + if (showval) { OSD_Printf("captureformat is %s\n", fmts[captureformat]); } + else { + int i,j; + for (j=0; j<2; j++) + for (i=0; i<2; i++) + if (!Bstrcasecmp(parm->parms[0], fmts[j][i])) break; + if (j == 2) return OSDCMD_SHOWHELP; + captureformat = i; + } + return OSDCMD_OK; + } +#ifdef SUPERBUILD + else if (!Bstrcasecmp(parm->name, "novoxmips")) { + if (showval) { OSD_Printf("novoxmips is %d\n", novoxmips); } + else { novoxmips = (atoi(parm->parms[0]) != 0); } + } + else if (!Bstrcasecmp(parm->name, "usevoxels")) { + if (showval) { OSD_Printf("usevoxels is %d\n", usevoxels); } + else { usevoxels = (atoi(parm->parms[0]) != 0); } + } +#endif + return OSDCMD_SHOWHELP; +} + +int baselayer_init(void) +{ +#ifdef POLYMOST + OSD_RegisterFunction("setrendermode","setrendermode : sets the engine's rendering mode.\n" + "Mode numbers are:\n" + " 0 - Classic Build software\n" + " 1 - Polygonal flat-shaded software\n" + " 2 - Polygonal textured software\n" +#ifdef USE_OPENGL + " 3 - Polygonal OpenGL\n" +#endif + , + osdfunc_setrendermode); +#endif + OSD_RegisterFunction("dumpbuildinfo","dumpbuildinfo: outputs engine compilation information",osdfunc_dumpbuildinfo); + OSD_RegisterFunction("screencaptureformat","screencaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars); +#ifdef SUPERBUILD + OSD_RegisterFunction("novoxmips","novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",osdcmd_vars); + OSD_RegisterFunction("usevoxels","usevoxels: enable/disable automatic sprite->voxel rendering",osdcmd_vars); +#endif +#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef DEBUGGINGAIDS + OSD_RegisterFunction("hicsetpalettetint","hicsetpalettetint: sets palette tinting values",osdcmd_hicsetpalettetint); +#endif + OSD_RegisterFunction("glinfo","glinfo: shows OpenGL information about the current OpenGL mode",osdcmd_glinfo); +#endif + + return 0; +} + diff --git a/polymer/build/src/bstub.c b/polymer/build/src/bstub.c new file mode 100644 index 000000000..41c89f872 --- /dev/null +++ b/polymer/build/src/bstub.c @@ -0,0 +1,574 @@ +// "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) + +#include "compat.h" +#include "a.h" +#include "build.h" +#include "editor.h" +#include "pragmas.h" +#include "baselayer.h" +#include "names.h" +#include "osd.h" +#include "cache1d.h" + + +static char tempbuf[256]; + +#define NUMOPTIONS 9 +char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0,0}; +char keys[NUMBUILDKEYS] = +{ + 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, + 0x1e,0x2c,0xd1,0xc9,0x33,0x34, + 0x9c,0x1c,0xd,0xc,0xf,0x45 +}; + + + +//static long hang = 0; +//static long rollangle = 0; + +//Detecting 2D / 3D mode: +// qsetmode is 200 in 3D mode +// qsetmode is 350/480 in 2D mode +// +//You can read these variables when F5-F8 is pressed in 3D mode only: +// +// If (searchstat == 0) WALL searchsector=sector, searchwall=wall +// If (searchstat == 1) CEILING searchsector=sector +// If (searchstat == 2) FLOOR searchsector=sector +// If (searchstat == 3) SPRITE searchsector=sector, searchwall=sprite +// If (searchstat == 4) MASKED WALL searchsector=sector, searchwall=wall +// +// searchsector is the sector of the selected item for all 5 searchstat's +// +// searchwall is undefined if searchstat is 1 or 2 +// searchwall is the wall if searchstat = 0 or 4 +// searchwall is the sprite if searchstat = 3 (Yeah, I know - it says wall, +// but trust me, it's the sprite number) + +long averagefps; +#define AVERAGEFRAMES 32 +static unsigned long frameval[AVERAGEFRAMES]; +static long framecnt = 0; + +char *defsfilename = "kenbuild.def"; +char *startwin_labeltext = "Starting Build Editor..."; +int nextvoxid = 0; + +int ExtPreInit(int *argc,char ***argv) +{ + return 0; +} + +int ExtInit(void) +{ + long i, rv = 0; + + /*printf("------------------------------------------------------------------------------\n"); + printf(" BUILD.EXE copyright(c) 1996 by Ken Silverman. You are granted the\n"); + printf(" right to use this software for your personal use only. This is a\n"); + printf(" special version to be used with \"Happy Fun KenBuild\" and may not work\n"); + printf(" properly with other Build engine games. Please refer to license.doc\n"); + printf(" for distribution rights\n"); + printf("------------------------------------------------------------------------------\n"); + getch(); + */ + + initgroupfile("stuff.dat"); + bpp = 8; + if (loadsetup("build.cfg") < 0) initprintf("Configuration file not found, using defaults.\n"), rv = 1; + Bmemcpy((void *)buildkeys,(void *)keys,NUMBUILDKEYS); //Trick to make build use setup.dat keys + if (option[4] > 0) option[4] = 0; + if (initengine()) { + wm_msgbox("Build Engine Initialisation Error", + "There was a problem initialising the Build engine: %s", engineerrstr); + return -1; + } + initinput(); + initmouse(); + + //You can load your own palette lookup tables here if you just + //copy the right code! + for(i=0;i<256;i++) + tempbuf[i] = ((i+32)&255); //remap colors for screwy palette sectors + makepalookup(16,tempbuf,0,0,0,1); + + kensplayerheight = 32; + zmode = 0; + defaultspritecstat = 0; + pskyoff[0] = 0; pskyoff[1] = 0; pskybits = 1; + +#ifdef SUPERBUILD + tiletovox[PLAYER] = nextvoxid++; + tiletovox[BROWNMONSTER] = nextvoxid++; +#endif + +#ifdef _WIN32 +// allowtaskswitching(0); +#endif + return rv; +} + +void ExtUnInit(void) +{ + uninitgroupfile(); + writesetup("build.cfg"); +} + +void ExtSetupSpecialSpriteCols(void) +{ + return; +} + +//static long daviewingrange, daaspect, horizval1, horizval2; +void ExtPreCheckKeys(void) +{ + long /*cosang, sinang, dx, dy, mindx,*/ i, j, k; + + if (keystatus[0x3e]) //F4 - screen re-size + { + keystatus[0x3e] = 0; + + //cycle through all vesa modes, then screen-buffer mode + if (keystatus[0x2a]|keystatus[0x36]) { + setgamemode(!fullscreen, xdim, ydim, bpp); + } else { + + //cycle through all modes + j=-1; + + // work out a mask to select the mode + for (i=0; i> 3) + (xdim >> 4) + (xdim >> 6)) & (~7); + dy = (ydim + (ydim >> 3) + (ydim >> 4) + (ydim >> 6)) & (~7); + i = scale(320,ydim,xdim); + + if (waloff[4094] == 0) allocache(&waloff[4094],/*240L*384L*/dx*dy,&walock[4094]); + setviewtotile(4094,/*240L,384L*/dy,dx); + + cosang = sintable[(hang+512)&2047]; + sinang = sintable[hang&2047]; + + dx = dmulscale1(320,cosang,i,sinang); mindx = dx; + dy = dmulscale1(-i,cosang,320,sinang); + horizval1 = dy*(320>>1)/dx-1; + + dx = dmulscale1(320,cosang,-i,sinang); mindx = min(dx,mindx); + dy = dmulscale1(i,cosang,320,sinang); + horizval2 = dy*(320>>1)/dx+1; + + daviewingrange = scale(65536,16384*(xdim>>1),mindx-16); + daaspect = scale(daviewingrange,scale(320,tilesizx[4094],tilesizy[4094]),horizval2+6-horizval1); + setaspect(daviewingrange,scale(daaspect,ydim*320,xdim*i)); + horiz = 100-divscale15(horizval1+horizval2,daviewingrange); + } +#endif +} + +#ifdef SUPERBUILD +#define MAXVOXMIPS 5 +extern char *voxoff[][MAXVOXMIPS]; +void ExtAnalyzeSprites(void) +{ + long i, *longptr; + spritetype *tspr; + + for(i=0,tspr=&tsprite[0];ipicnum] >= 0) + { + switch(tspr->picnum) + { + case PLAYER: + if (!voxoff[ tiletovox[PLAYER] ][0]) { + if (qloadkvx(tiletovox[PLAYER],"voxel000.kvx")) { + tiletovox[PLAYER] = -1; + break; + } + } + //tspr->cstat |= 48; tspr->picnum = tiletovox[tspr->picnum]; + longptr = (long *)voxoff[ tiletovox[PLAYER] ][0]; + tspr->xrepeat = scale(tspr->xrepeat,56,longptr[2]); + tspr->yrepeat = scale(tspr->yrepeat,56,longptr[2]); + tspr->shade -= 6; + break; + case BROWNMONSTER: + if (!voxoff[ tiletovox[BROWNMONSTER] ][0]) { + if (qloadkvx(tiletovox[BROWNMONSTER],"voxel001.kvx")) { + tiletovox[BROWNMONSTER] = -1; + break; + } + } + //tspr->cstat |= 48; tspr->picnum = tiletovox[tspr->picnum]; + break; + } + } + + tspr->shade += 6; + if (sector[tspr->sectnum].ceilingstat&1) + tspr->shade += sector[tspr->sectnum].ceilingshade; + else + tspr->shade += sector[tspr->sectnum].floorshade; + } +} +#endif + +void ExtCheckKeys(void) +{ + long i;//, p, y, dx, dy, cosang, sinang, bufplc, tsizy, tsizyup15; + long j; + + if (qsetmode == 200) //In 3D mode + { +#if 0 + if (hang != 0) + { + bufplc = waloff[4094]+(mulscale16(horiz-100,xdimenscale)+(tilesizx[4094]>>1))*tilesizy[4094]; + setviewback(); + cosang = sintable[(hang+512)&2047]; + sinang = sintable[hang&2047]; + dx = dmulscale1(xdim,cosang,ydim,sinang); + dy = dmulscale1(-ydim,cosang,xdim,sinang); + + begindrawing(); + tsizy = tilesizy[4094]; + tsizyup15 = (tsizy<<15); + dx = mulscale14(dx,daviewingrange); + dy = mulscale14(dy,daaspect); + sinang = mulscale14(sinang,daviewingrange); + cosang = mulscale14(cosang,daaspect); + p = ylookup[windowy1]+frameplace+windowx2+1; + for(y=windowy1;y<=windowy2;y++) + { + i = divscale16(tsizyup15,dx); + stretchhline(0,(xdim>>1)*i+tsizyup15,xdim>>2,i,mulscale32(i,dy)*tsizy+bufplc,p); + dx -= sinang; dy += cosang; p += ylookup[1]; + } + walock[4094] = 1; + + Bsprintf(tempbuf,"%d",(hang*180)>>10); + printext256(0L,8L,31,-1,tempbuf,1); + enddrawing(); + } +#endif + if (keystatus[0xa]) setaspect(viewingrange+(viewingrange>>8),yxaspect+(yxaspect>>8)); + if (keystatus[0xb]) setaspect(viewingrange-(viewingrange>>8),yxaspect-(yxaspect>>8)); + if (keystatus[0xc]) setaspect(viewingrange,yxaspect-(yxaspect>>8)); + if (keystatus[0xd]) setaspect(viewingrange,yxaspect+(yxaspect>>8)); + //if (keystatus[0x38]) setrollangle(rollangle+=((keystatus[0x2a]|keystatus[0x36])*6+2)); + //if (keystatus[0xb8]) setrollangle(rollangle-=((keystatus[0x2a]|keystatus[0x36])*6+2)); + //if (keystatus[0x1d]|keystatus[0x9d]) setrollangle(rollangle=0); + + begindrawing(); + + i = frameval[framecnt&(AVERAGEFRAMES-1)]; + j = frameval[framecnt&(AVERAGEFRAMES-1)] = getticks(); framecnt++; + if (i != j) averagefps = ((mul3(averagefps)+((AVERAGEFRAMES*1000)/(j-i)) )>>2); + Bsprintf(tempbuf,"%ld",averagefps); + printext256(0L,0L,31,-1,tempbuf,1); + + enddrawing(); + editinput(); + } + else + { + } +} + +void ExtCleanUp(void) +{ +} + +void ExtPreLoadMap(void) +{ +} + +void ExtLoadMap(const char *mapname) +{ + char title[256]; + Bsprintf(title, "BUILD by Ken Silverman - %s", mapname); + wm_setapptitle(title); +} + +void ExtPreSaveMap(void) +{ +} + +void ExtSaveMap(const char *mapname) +{ +} + +const char *ExtGetSectorCaption(short sectnum) +{ + if ((sector[sectnum].lotag|sector[sectnum].hitag) == 0) + { + tempbuf[0] = 0; + } + else + { + Bsprintf(tempbuf,"%hu,%hu",(unsigned short)sector[sectnum].hitag, + (unsigned short)sector[sectnum].lotag); + } + return(tempbuf); +} + +const char *ExtGetWallCaption(short wallnum) +{ + if ((wall[wallnum].lotag|wall[wallnum].hitag) == 0) + { + tempbuf[0] = 0; + } + else + { + Bsprintf(tempbuf,"%hu,%hu",(unsigned short)wall[wallnum].hitag, + (unsigned short)wall[wallnum].lotag); + } + return(tempbuf); +} + +const char *ExtGetSpriteCaption(short spritenum) +{ + if ((sprite[spritenum].lotag|sprite[spritenum].hitag) == 0) + { + tempbuf[0] = 0; + } + else + { + Bsprintf(tempbuf,"%hu,%hu",(unsigned short)sprite[spritenum].hitag, + (unsigned short)sprite[spritenum].lotag); + } + return(tempbuf); +} + +//printext16 parameters: +//printext16(long xpos, long ypos, short col, short backcol, +// char name[82], char fontsize) +// xpos 0-639 (top left) +// ypos 0-479 (top left) +// col 0-15 +// backcol 0-15, -1 is transparent background +// name +// fontsize 0=8*8, 1=3*5 + +//drawline16 parameters: +// drawline16(long x1, long y1, long x2, long y2, char col) +// x1, x2 0-639 +// y1, y2 0-143 (status bar is 144 high, origin is top-left of STATUS BAR) +// col 0-15 + +void ExtShowSectorData(short sectnum) //F5 +{ + int i; + if (qsetmode == 200) //In 3D mode + { + } + else + { + begindrawing(); + clearmidstatbar16(); //Clear middle of status bar + + Bsprintf(tempbuf,"Sector %d",sectnum); + printext16(8,ydim16+32,11,-1,tempbuf,0); + + printext16(8,ydim16+48,11,-1,"8*8 font: ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789",0); + printext16(8,ydim16+56,11,-1,"3*5 font: ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789",1); + + i=ydim16; ydim16=ydim; + drawline16(320,i+68,344,i+80,4); //Draw house + drawline16(344,i+80,344,i+116,4); + drawline16(344,i+116,296,i+116,4); + drawline16(296,i+116,296,i+80,4); + drawline16(296,i+80,320,i+68,4); + ydim16=i; + enddrawing(); + } +} + +void ExtShowWallData(short wallnum) //F6 +{ + if (qsetmode == 200) //In 3D mode + { + } + else + { + begindrawing(); + clearmidstatbar16(); //Clear middle of status bar + + Bsprintf(tempbuf,"Wall %d",wallnum); + printext16(8,ydim16+32,11,-1,tempbuf,0); + enddrawing(); + } +} + +void ExtShowSpriteData(short spritenum) //F6 +{ + if (qsetmode == 200) //In 3D mode + { + } + else + { + begindrawing(); + clearmidstatbar16(); //Clear middle of status bar + + Bsprintf(tempbuf,"Sprite %d",spritenum); + printext16(8,ydim16+32,11,-1,tempbuf,0); + enddrawing(); + } +} + +void ExtEditSectorData(short sectnum) //F7 +{ + short nickdata; + + if (qsetmode == 200) //In 3D mode + { + //Ceiling + if (searchstat == 1) + sector[searchsector].ceilingpicnum++; //Just a stupid example + + //Floor + if (searchstat == 2) + sector[searchsector].floorshade++; //Just a stupid example + } + else //In 2D mode + { + Bsprintf(tempbuf,"Sector (%d) Nick's variable: ",sectnum); + nickdata = 0; + nickdata = getnumber16(tempbuf,nickdata,65536L,0); + + printmessage16(""); //Clear message box (top right of status bar) + ExtShowSectorData(sectnum); + } +} + +void ExtEditWallData(short wallnum) //F8 +{ + short nickdata; + + if (qsetmode == 200) //In 3D mode + { + } + else + { + Bsprintf(tempbuf,"Wall (%d) Nick's variable: ",wallnum); + nickdata = 0; + nickdata = getnumber16(tempbuf,nickdata,65536L,0); + + printmessage16(""); //Clear message box (top right of status bar) + ExtShowWallData(wallnum); + } +} + +void ExtEditSpriteData(short spritenum) //F8 +{ + short nickdata; + + if (qsetmode == 200) //In 3D mode + { + } + else + { + Bsprintf(tempbuf,"Sprite (%d) Nick's variable: ",spritenum); + nickdata = 0; + nickdata = getnumber16(tempbuf,nickdata,65536L,0); + printmessage16(""); + + printmessage16(""); //Clear message box (top right of status bar) + ExtShowSpriteData(spritenum); + } +} + +void faketimerhandler(void) +{ + sampletimer(); +} + + //Just thought you might want my getnumber16 code +/* +getnumber16(char namestart[80], short num, long maxnumber) +{ + char buffer[80]; + long j, k, n, danum, oldnum; + + danum = (long)num; + oldnum = danum; + while ((keystatus[0x1c] != 2) && (keystatus[0x1] == 0)) //Enter, ESC + { + sprintf(&buffer,"%s%ld_ ",namestart,danum); + printmessage16(buffer); + + for(j=2;j<=11;j++) //Scan numbers 0-9 + if (keystatus[j] > 0) + { + keystatus[j] = 0; + k = j-1; + if (k == 10) k = 0; + n = (danum*10)+k; + if (n < maxnumber) danum = n; + } + if (keystatus[0xe] > 0) // backspace + { + danum /= 10; + keystatus[0xe] = 0; + } + if (keystatus[0x1c] == 1) //L. enter + { + oldnum = danum; + keystatus[0x1c] = 2; + asksave = 1; + } + } + keystatus[0x1c] = 0; + keystatus[0x1] = 0; + return((short)oldnum); +} +*/ + +/* + * vim:ts=4: + */ + diff --git a/polymer/build/src/build.c b/polymer/build/src/build.c new file mode 100644 index 000000000..99d54b40a --- /dev/null +++ b/polymer/build/src/build.c @@ -0,0 +1,7422 @@ +// "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) + +#include "build.h" +#include "compat.h" +#include "pragmas.h" +#include "osd.h" +#include "cache1d.h" +#include "editor.h" + +#define VERSION "("__DATE__" "__TIME__")" + +#include "baselayer.h" +#ifdef RENDERTYPEWIN +#include "winlayer.h" +#endif + + +#define TIMERINTSPERSECOND 120 + +#define updatecrc16(crc,dat) (crc = (((crc<<8)&65535)^crctable[((((unsigned short)crc)>>8)&65535)^dat])) +static long crctable[256]; +static char kensig[24]; + +extern int ExtInit(void); +extern int ExtPreInit(int *argc,char ***argv); +extern void ExtUnInit(void); +extern void ExtPreCheckKeys(void); +#ifdef SUPERBUILD +extern void ExtAnalyzeSprites(void); +#endif +extern void ExtCheckKeys(void); +extern void ExtLoadMap(const char *mapname); +extern void ExtSaveMap(const char *mapname); +extern const char *ExtGetSectorCaption(short sectnum); +extern const char *ExtGetWallCaption(short wallnum); +extern const char *ExtGetSpriteCaption(short spritenum); +extern void ExtShowSectorData(short sectnum); +extern void ExtShowWallData(short wallnum); +extern void ExtShowSpriteData(short spritenum); +extern void ExtEditSectorData(short sectnum); +extern void ExtEditWallData(short wallnum); +extern void ExtEditSpriteData(short spritenum); +extern char ExtCustomSpriteColor(short picnum); +extern void ExtSetupSpecialSpriteCols(void); + +extern char spritecol2d[MAXTILES][2]; + +char noclip=0; + +void _printmessage16(char name[82]); + +long vel, svel, angvel; + +char buildkeys[NUMBUILDKEYS] = +{ + 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, + 0x1e,0x2c,0xd1,0xc9,0x33,0x34, + 0x9c,0x1c,0xd,0xc,0xf,0x45 +}; + +long posx, posy, posz, horiz = 100; +long mousexsurp = 0, mouseysurp = 0; +short ang, cursectnum; +long hvel; + +long grponlymode = 0; +extern long editorgridextent; // in engine.c +extern double msens; + +long synctics = 0, lockclock = 0; + +extern char vgacompatible; + +extern char picsiz[MAXTILES]; +extern long startposx, startposy, startposz; +extern short startang, startsectnum; +extern long frameplace, ydim16, halfxdim16, midydim16; +long xdim2d = 640, ydim2d = 480, xdimgame = 640, ydimgame = 480, bppgame = 8; + +extern long cachesize, artsize; + +static short oldmousebstatus = 0; +short brightness = 0; +long zlock = 0x7fffffff, zmode = 0, whitecol, kensplayerheight = 32; +short defaultspritecstat = 0; + +static short localartfreq[MAXTILES]; +static short localartlookup[MAXTILES], localartlookupnum; + +char tempbuf[4096]; + +char names[MAXTILES][25]; + +short asksave = 0; +extern short editstatus, searchit; +extern long searchx, searchy; //search input +extern short searchsector, searchwall, searchstat; //search output +long osearchx, osearchy; //old search input + +extern long pointhighlight, linehighlight, highlightcnt; +short grid = 3, gridlock = 1, showtags = 1; +long zoom = 768, gettilezoom = 1; +long lastpm16time; + +long numsprites; +extern long mapversion; + +short highlight[MAXWALLS]; +short highlightsector[MAXSECTORS], highlightsectorcnt = -1; +extern char textfont[128][8]; + +static char pskysearch[MAXSECTORS]; + +short temppicnum, tempcstat, templotag, temphitag, tempextra; +char tempshade, temppal, tempvis, tempxrepeat, tempyrepeat; +char somethingintab = 255; + +char mlook = 0; + +static char boardfilename[BMAX_PATH], selectedboardfilename[BMAX_PATH]; + +static CACHE1D_FIND_REC *finddirs=NULL, *findfiles=NULL, *finddirshigh=NULL, *findfileshigh=NULL; +static int numdirs=0, numfiles=0; +static int currentlist=0; + +static long repeatcountx, repeatcounty; + +static long fillist[640]; + +long mousx, mousy; + +static char scantoasc[128] = +{ + 0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0, + 'q','w','e','r','t','y','u','i','o','p','[',']',0,0,'a','s', + 'd','f','g','h','j','k','l',';',39,'`',0,92,'z','x','c','v', + 'b','n','m',',','.','/',0,'*',0,32,0,0,0,0,0,0, + 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1', + '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; +static char scantoascwithshift[128] = +{ + 0,0,'!','@','#','$','%','^','&','*','(',')','_','+',0,0, + 'Q','W','E','R','T','Y','U','I','O','P','{','}',0,0,'A','S', + 'D','F','G','H','J','K','L',':',34,'~',0,'|','Z','X','C','V', + 'B','N','M','<','>','?',0,'*',0,32,0,0,0,0,0,0, + 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1', + '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + + + +char changechar(char dachar, long dadir, char smooshyalign, char boundcheck); +long adjustmark(long *xplc, long *yplc, short danumwalls); +long checkautoinsert(long dax, long day, short danumwalls); +void keytimerstuff(void); +long clockdir(short wallstart); +void flipwalls(short numwalls, short newnumwalls); +void insertpoint(short linehighlight, long dax, long day); +void deletepoint(short point); +long deletesector(short sucksect); +long checksectorpointer(short i, short sectnum); +void fixrepeats(short i); +short loopinside(long x, long y, short startwall); +long fillsector(short sectnum, char fillcolor); +short whitelinescan(short dalinehighlight); +void printcoords16(long posxe, long posye, short ange); +void copysector(short soursector, short destsector, short deststartwall, char copystat); +void showsectordata(short sectnum); +void showwalldata(short wallnum); +void showspritedata(short spritenum); +long drawtilescreen(long pictopleft, long picbox); +void overheadeditor(void); +long getlinehighlight(long xplc, long yplc); +void fixspritesectors(void); +long movewalls(long start, long offs); +long loadnames(void); +void updatenumsprites(void); +void getclosestpointonwall(long x, long y, long dawall, long *nx, long *ny); +void initcrc(void); +void AutoAlignWalls(long nWall0, long ply); +long gettile(long tilenum); + +long menuselect(void); +long getfilenames(char *path, char kind[6]); +void clearfilenames(void); + +void clearkeys(void) { memset(keystatus,0,sizeof(keystatus)); } + +static int osdcmd_restartvid(const osdfuncparm_t *parm) +{ + extern long qsetmode; + + if (qsetmode != 200) return OSDCMD_OK; + + resetvideomode(); + if (setgamemode(fullscreen,xdim,ydim,bpp)) + OSD_Printf("restartvid: Reset failed...\n"); + + return OSDCMD_OK; +} + +static int osdcmd_vidmode(const osdfuncparm_t *parm) +{ + long newx = xdim, newy = ydim, newbpp = bpp, newfullscreen = fullscreen; + extern long qsetmode; + + if (qsetmode != 200) return OSDCMD_OK; + + switch (parm->numparms) { + case 1: // bpp switch + newbpp = Batol(parm->parms[0]); + break; + case 4: // fs, res, bpp switch + newfullscreen = (Batol(parm->parms[3]) != 0); + case 3: // res & bpp switch + newbpp = Batol(parm->parms[2]); + case 2: // res switch + newx = Batol(parm->parms[0]); + newy = Batol(parm->parms[1]); + break; + default: return OSDCMD_SHOWHELP; + } + + if (setgamemode(newfullscreen,newx,newy,newbpp)) + OSD_Printf("vidmode: Mode change failed!\n"); + xdimgame = newx; ydimgame = newy; bppgame = newbpp; fullscreen = newfullscreen; + return OSDCMD_OK; +} + +#ifdef RENDERTYPEWIN +int DoLaunchWindow(int initval); // buildstartwin.c +#endif + +extern char *defsfilename; // set in bstub.c +int app_main(int argc, char **argv) +{ + char ch, quitflag, forcesetup = 0, grpstoadd = 0; + char **grps = NULL; + long i, j, k; + + pathsearchmode = 1; // unrestrict findfrompath so that full access to the filesystem can be had + +#ifdef USE_OPENGL + OSD_RegisterFunction("restartvid","restartvid: reinitialise the video mode",osdcmd_restartvid); + OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: immediately change the video mode",osdcmd_vidmode); +#endif + + wm_setapptitle("Mapster32"); + + if ((i = ExtPreInit(&argc,&argv)) < 0) return -1; + +#ifdef RENDERTYPEWIN + backgroundidle = 1; +#endif + + editstatus = 1; + boardfilename[0] = 0; + for (i=1; i 0) { + for (i=0;i k) { k = j; whitecol = i; } + } + + for(i=0;i 0) + { + keystatus[1] = 0; + begindrawing(); //{{{ + printext256(0,0,whitecol,0,"Are you sure you want to quit?",0); + enddrawing(); //}}} + + showframe(1); + synctics = totalclock-lockclock; + lockclock += synctics; + + while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]) == 0) + { + if (handleevents()) { + if (quitevent) { + quitflag = 1; + break; + } + } + + if (keystatus[0x15] != 0) { + keystatus[0x15] = 0; + quitflag = 1; break; + } + } + while(keystatus[1]) + { + keystatus[1] = 0; + quitevent = 0; + goto CANCEL; + } + } + } + + if (asksave) + { + begindrawing(); //{{{ + printext256(0,8,whitecol,0,"Save changes?",0); + showframe(1); //}}} + + while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]|keystatus[0x2e]) == 0) + { + if (handleevents()) if (quitevent) break; // like saying no + + if (keystatus[0x15] != 0) { + keystatus[0x15] = 0; + + updatesector(startposx,startposy,&startsectnum); + ExtPreSaveMap(); + saveboard(boardfilename,&startposx,&startposy,&startposz,&startang,&startsectnum); + ExtSaveMap(boardfilename); + break; + } + } + while(keystatus[1]||keystatus[0x2e]) + { + keystatus[1] = 0; + keystatus[0x2e] = 0; + quitevent = 0; + goto CANCEL; + } + } + + + clearfilenames(); + ExtUnInit(); + uninitengine(); + + Bprintf("Memory status: %ld(%ld) bytes\n",cachesize,artsize); + Bprintf("%s\n",kensig); + return(0); +} + +void showmouse(void) +{ + int i; + + for(i=1;i<=4;i++) + { + plotpixel(searchx+i,searchy,whitecol); + plotpixel(searchx-i,searchy,whitecol); + plotpixel(searchx,searchy-i,whitecol); + plotpixel(searchx,searchy+i,whitecol); + } +} + +void editinput(void) +{ + char smooshyalign, repeatpanalign, *ptr, buffer[80]; + short sectnum, nextsectnum, startwall, endwall, dasector, daang; + long mousz, bstatus; + long i, j, k, cnt, templong=0, doubvel, changedir, wallfind[2], daz[2]; + long dashade[2], goalz, xvect, yvect, hiz, loz; + short hitsect, hitwall, hitsprite; + long hitx, hity, hitz, dax, day, hihit, lohit; + + if (keystatus[0x57] > 0) //F11 - brightness + { + keystatus[0x57] = 0; + brightness++; + if (brightness >= 16) brightness = 0; + setbrightness(brightness,palette,0); + } + if (keystatus[88] > 0) //F12 + { + screencapture("captxxxx.tga",keystatus[0x2a]|keystatus[0x36]); + keystatus[88] = 0; + } + + mousz = 0; + getmousevalues(&mousx,&mousy,&bstatus); + mousx = (mousx<<16)+mousexsurp; + mousy = (mousy<<16)+mouseysurp; + { + ldiv_t ld; + ld = ldiv((long)((double)mousx*msens), (1<<16)); mousx = ld.quot; mousexsurp = ld.rem; + ld = ldiv((long)((double)mousy*msens), (1<<16)); mousy = ld.quot; mouseysurp = ld.rem; + } + + if (mlook == 1) + { + ang += (mousx); + horiz -= (mousy+mouseysurp); + if (horiz > 299) + horiz = 299; + if (horiz < -99) + horiz = -99; + searchx = (xdim/2); + searchy = (ydim/2); + osearchx = searchx-mousx; + osearchy = searchy-(mousy+mouseysurp); + } + else + { + osearchx = searchx; + osearchy = searchy; + searchx += mousx; + searchy += mousy; + if (searchx < 4) searchx = 4; + if (searchy < 4) searchy = 4; + if (searchx > xdim-5) searchx = xdim-5; + if (searchy > ydim-5) searchy = ydim-5; + } + + showmouse(); + + if (keystatus[0x3b] > 0) posx--; + if (keystatus[0x3c] > 0) posx++; + if (keystatus[0x3d] > 0) posy--; + if (keystatus[0x3e] > 0) posy++; + if (keystatus[0x43] > 0) ang--; + if (keystatus[0x44] > 0) ang++; + + if (angvel != 0) //ang += angvel * constant + { //ENGINE calculates angvel for you + doubvel = synctics; + if (keystatus[buildkeys[4]] > 0) //Lt. shift makes turn velocity 50% faster + doubvel += (synctics>>1); + ang += ((angvel*doubvel)>>4); + ang = (ang+2048)&2047; + } + if ((vel|svel) != 0) + { + doubvel = synctics; + if (keystatus[buildkeys[4]] > 0) //Lt. shift doubles forward velocity + doubvel += synctics; + xvect = 0, yvect = 0; + if (vel != 0) + { + xvect += ((vel*doubvel*(long)sintable[(ang+2560)&2047])>>3); + yvect += ((vel*doubvel*(long)sintable[(ang+2048)&2047])>>3); + } + if (svel != 0) + { + xvect += ((svel*doubvel*(long)sintable[(ang+2048)&2047])>>3); + yvect += ((svel*doubvel*(long)sintable[(ang+1536)&2047])>>3); + } + if (noclip) + { + posx += xvect>>14; + posy += yvect>>14; + updatesector(posx,posy,&cursectnum); + } + else clipmove(&posx,&posy,&posz,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + } + getzrange(posx,posy,posz,cursectnum,&hiz,&hihit,&loz,&lohit,128L,CLIPMASK0); + + if (keystatus[0x3a] > 0) + { + zmode++; + if (zmode == 3) zmode = 0; + if (zmode == 1) zlock = (loz-posz)&0xfffffc00; + keystatus[0x3a] = 0; + } + + if (zmode == 0) + { + goalz = loz-(kensplayerheight<<8); //playerheight pixels above floor + if (goalz < hiz+(16<<8)) //ceiling&floor too close + goalz = ((loz+hiz)>>1); + goalz += mousz; + if (keystatus[buildkeys[8]] > 0) //A (stand high) + { + if (keystatus[0x1d] > 0) + horiz = max(-100,horiz-((keystatus[buildkeys[4]]+1)*synctics*2)); + else + { + goalz -= (16<<8); + if (keystatus[buildkeys[4]] > 0) //Either shift key + goalz -= (24<<8); + } + } + if (keystatus[buildkeys[9]] > 0) //Z (stand low) + { + if (keystatus[0x1d] > 0) + horiz = min(300,horiz+((keystatus[buildkeys[4]]+1)*synctics*2)); + else + { + goalz += (12<<8); + if (keystatus[buildkeys[4]] > 0) //Either shift key + goalz += (12<<8); + } + } + + if (goalz != posz) + { + if (posz < goalz) hvel += 32; + if (posz > goalz) hvel = ((goalz-posz)>>3); + + posz += hvel; + if (posz > loz-(4<<8)) posz = loz-(4<<8), hvel = 0; + if (posz < hiz+(4<<8)) posz = hiz+(4<<8), hvel = 0; + } + } + else + { + goalz = posz; + if (keystatus[buildkeys[8]] > 0) //A + { + if (keystatus[0x1d] > 0) { + horiz = max(-100,horiz-((keystatus[buildkeys[4]]+1)*synctics*2)); + } else { + if (zmode != 1) + goalz -= (8<<8); + else + { + zlock += (4<<8); + keystatus[buildkeys[8]] = 0; + } + } + } + if (keystatus[buildkeys[9]] > 0) //Z (stand low) + { + if (keystatus[0x1d] > 0) { + horiz = min(300,horiz+((keystatus[buildkeys[4]]+1)*synctics*2)); + } else { + if (zmode != 1) + goalz += (8<<8); + else if (zlock > 0) + { + zlock -= (4<<8); + keystatus[buildkeys[9]] = 0; + } + } + } + + if (goalz < hiz+(4<<8)) goalz = hiz+(4<<8); + if (goalz > loz-(4<<8)) goalz = loz-(4<<8); + if (zmode == 1) goalz = loz-zlock; + if (goalz < hiz+(4<<8)) goalz = ((loz+hiz)>>1); //ceiling&floor too close + if (zmode == 1) posz = goalz; + + if (goalz != posz) + { + //if (posz < goalz) hvel += (32< goalz) hvel -= (32< goalz) hvel = ((synctics*-192)< loz-(4<<8)) posz = loz-(4<<8), hvel = 0; + if (posz < hiz+(4<<8)) posz = hiz+(4<<8), hvel = 0; + } + else + hvel = 0; + } + + searchit = 2; + if (searchstat >= 0) + { + if ((bstatus&(1|2|4)) > 0) + searchit = 0; + if (keystatus[0x4a] > 0) // - + { + keystatus[0x4a] = 0; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT + { + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //CTRL + { + if (visibility < 16384) visibility += visibility; + } + else + { + if ((keystatus[0x2a]|keystatus[0x36]) == 0) + k = 16; else k = 1; + + if (highlightsectorcnt >= 0) + for(i=0;i 0) + { + for(i=0;i 0) + { + sector[searchsector].visibility++; + if (sector[searchsector].visibility == 240) + sector[searchsector].visibility = 239; + k--; + } + asksave = 1; + } + } + else + { + k = 0; + if (highlightsectorcnt >= 0) + { + for(i=0;i 0) // + + { + keystatus[0x4e] = 0; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT + { + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //CTRL + { + if (visibility > 32) visibility >>= 1; + } + else + { + if ((keystatus[0x2a]|keystatus[0x36]) == 0) + k = 16; else k = 1; + + if (highlightsectorcnt >= 0) + for(i=0;i 0) + { + for(i=0;i 0) + { + sector[searchsector].visibility--; + if (sector[searchsector].visibility == 239) + sector[searchsector].visibility = 240; + k--; + } + asksave = 1; + } + } + else + { + k = 0; + if (highlightsectorcnt >= 0) + { + for(i=0;i 0) // PGUP + { + k = 0; + if (highlightsectorcnt >= 0) + { + for(i=0;i 0) //CTRL - put sprite on ceiling + { + sprite[searchwall].z = getceilzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y); + if (sprite[searchwall].cstat&128) sprite[searchwall].z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1); + if ((sprite[searchwall].cstat&48) != 32) + sprite[searchwall].z += ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<2); + } + else + { + k = 0; + if (highlightcnt >= 0) + for(i=0;i 0) // PGDN + { + k = 0; + if (highlightsectorcnt >= 0) + { + for(i=0;i sector[searchsector].floorz) + sector[searchsector].ceilingz = sector[searchsector].floorz; + if (searchstat == 3) + { + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //CTRL - put sprite on ground + { + sprite[searchwall].z = getflorzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y); + if (sprite[searchwall].cstat&128) sprite[searchwall].z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1); + } + else + { + k = 0; + if (highlightcnt >= 0) + for(i=0;i 0) //TAB + { + if (searchstat == 0) + { + temppicnum = wall[searchwall].picnum; + tempshade = wall[searchwall].shade; + temppal = wall[searchwall].pal; + tempxrepeat = wall[searchwall].xrepeat; + tempyrepeat = wall[searchwall].yrepeat; + tempcstat = wall[searchwall].cstat; + templotag = wall[searchwall].lotag; + temphitag = wall[searchwall].hitag; + tempextra = wall[searchwall].extra; + } + if (searchstat == 1) + { + temppicnum = sector[searchsector].ceilingpicnum; + tempshade = sector[searchsector].ceilingshade; + temppal = sector[searchsector].ceilingpal; + tempvis = sector[searchsector].visibility; + tempxrepeat = sector[searchsector].ceilingxpanning; + tempyrepeat = sector[searchsector].ceilingypanning; + tempcstat = sector[searchsector].ceilingstat; + templotag = sector[searchsector].lotag; + temphitag = sector[searchsector].hitag; + tempextra = sector[searchsector].extra; + } + if (searchstat == 2) + { + temppicnum = sector[searchsector].floorpicnum; + tempshade = sector[searchsector].floorshade; + temppal = sector[searchsector].floorpal; + tempvis = sector[searchsector].visibility; + tempxrepeat = sector[searchsector].floorxpanning; + tempyrepeat = sector[searchsector].floorypanning; + tempcstat = sector[searchsector].floorstat; + templotag = sector[searchsector].lotag; + temphitag = sector[searchsector].hitag; + tempextra = sector[searchsector].extra; + } + if (searchstat == 3) + { + temppicnum = sprite[searchwall].picnum; + tempshade = sprite[searchwall].shade; + temppal = sprite[searchwall].pal; + tempxrepeat = sprite[searchwall].xrepeat; + tempyrepeat = sprite[searchwall].yrepeat; + tempcstat = sprite[searchwall].cstat; + templotag = sprite[searchwall].lotag; + temphitag = sprite[searchwall].hitag; + tempextra = sprite[searchwall].extra; + } + if (searchstat == 4) + { + temppicnum = wall[searchwall].overpicnum; + tempshade = wall[searchwall].shade; + temppal = wall[searchwall].pal; + tempxrepeat = wall[searchwall].xrepeat; + tempyrepeat = wall[searchwall].yrepeat; + tempcstat = wall[searchwall].cstat; + templotag = wall[searchwall].lotag; + temphitag = wall[searchwall].hitag; + tempextra = wall[searchwall].extra; + } + somethingintab = searchstat; + keystatus[0x0f] = 0; + } + if (keystatus[0x1c] > 0) //Left ENTER + { + if ((keystatus[0x2a]|keystatus[0x36]) > 0) //Either shift key + { + if (((searchstat == 0) || (searchstat == 4)) && ((keystatus[0x1d]|keystatus[0x9d]) > 0)) //Ctrl-shift Enter (auto-shade) + { + dashade[0] = 127; + dashade[1] = -128; + i = searchwall; + do + { + if ((long)wall[i].shade < dashade[0]) dashade[0] = wall[i].shade; + if ((long)wall[i].shade > dashade[1]) dashade[1] = wall[i].shade; + + i = wall[i].point2; + } + while (i != searchwall); + + daang = getangle(wall[wall[searchwall].point2].x-wall[searchwall].x,wall[wall[searchwall].point2].y-wall[searchwall].y); + i = searchwall; + do + { + j = getangle(wall[wall[i].point2].x-wall[i].x,wall[wall[i].point2].y-wall[i].y); + k = ((j+2048-daang)&2047); + if (k > 1024) + k = 2048-k; + wall[i].shade = dashade[0]+mulscale10(k,dashade[1]-dashade[0]); + + i = wall[i].point2; + } + while (i != searchwall); + } + else if (somethingintab < 255) + { + if (searchstat == 0) wall[searchwall].shade = tempshade, wall[searchwall].pal = temppal; + if (searchstat == 1) + { + sector[searchsector].ceilingshade = tempshade, sector[searchsector].ceilingpal = temppal; + if ((somethingintab == 1) || (somethingintab == 2)) + sector[searchsector].visibility = tempvis; + } + if (searchstat == 2) + { + sector[searchsector].floorshade = tempshade, sector[searchsector].floorpal = temppal; + if ((somethingintab == 1) || (somethingintab == 2)) + sector[searchsector].visibility = tempvis; + } + if (searchstat == 3) sprite[searchwall].shade = tempshade, sprite[searchwall].pal = temppal; + if (searchstat == 4) wall[searchwall].shade = tempshade, wall[searchwall].pal = temppal; + } + } + else if (((searchstat == 0) || (searchstat == 4)) && ((keystatus[0x1d]|keystatus[0x9d]) > 0) && (somethingintab < 255)) //Either ctrl key + { + i = searchwall; + do + { + wall[i].picnum = temppicnum; + wall[i].shade = tempshade; + wall[i].pal = temppal; + if ((somethingintab == 0) || (somethingintab == 4)) + { + wall[i].xrepeat = tempxrepeat; + wall[i].yrepeat = tempyrepeat; + wall[i].cstat = tempcstat; + } + fixrepeats((short)i); + i = wall[i].point2; + } + while (i != searchwall); + } + else if (((searchstat == 1) || (searchstat == 2)) && ((keystatus[0x1d]|keystatus[0x9d]) > 0) && (somethingintab < 255)) //Either ctrl key + { + clearbuf(&pskysearch[0],(long)((numsectors+3)>>2),0L); + if (searchstat == 1) + { + i = searchsector; + if ((sector[i].ceilingstat&1) > 0) + pskysearch[i] = 1; + + while (pskysearch[i] == 1) + { + sector[i].ceilingpicnum = temppicnum; + sector[i].ceilingshade = tempshade; + sector[i].ceilingpal = temppal; + if ((somethingintab == 1) || (somethingintab == 2)) + { + sector[i].ceilingxpanning = tempxrepeat; + sector[i].ceilingypanning = tempyrepeat; + sector[i].ceilingstat = tempcstat; + } + pskysearch[i] = 2; + + startwall = sector[i].wallptr; + endwall = startwall + sector[i].wallnum - 1; + for(j=startwall;j<=endwall;j++) + { + k = wall[j].nextsector; + if (k >= 0) + if ((sector[k].ceilingstat&1) > 0) + if (pskysearch[k] == 0) + pskysearch[k] = 1; + } + + for(j=0;j 0) + pskysearch[i] = 1; + + while (pskysearch[i] == 1) + { + sector[i].floorpicnum = temppicnum; + sector[i].floorshade = tempshade; + sector[i].floorpal = temppal; + if ((somethingintab == 1) || (somethingintab == 2)) + { + sector[i].floorxpanning = tempxrepeat; + sector[i].floorypanning = tempyrepeat; + sector[i].floorstat = tempcstat; + } + pskysearch[i] = 2; + + startwall = sector[i].wallptr; + endwall = startwall + sector[i].wallnum - 1; + for(j=startwall;j<=endwall;j++) + { + k = wall[j].nextsector; + if (k >= 0) + if ((sector[k].floorstat&1) > 0) + if (pskysearch[k] == 0) + pskysearch[k] = 1; + } + + for(j=0;j 0) && (tilesizy[k] > 0)) + { + j = k; + break; + } + sprite[searchwall].picnum = j; + } + sprite[searchwall].shade = tempshade; + sprite[searchwall].pal = temppal; + if (somethingintab == 3) + { + sprite[searchwall].xrepeat = tempxrepeat; + sprite[searchwall].yrepeat = tempyrepeat; + if (sprite[searchwall].xrepeat < 1) sprite[searchwall].xrepeat = 1; + if (sprite[searchwall].yrepeat < 1) sprite[searchwall].yrepeat = 1; + sprite[searchwall].cstat = tempcstat; + sprite[searchwall].lotag = templotag; + sprite[searchwall].hitag = temphitag; + sprite[searchwall].extra = tempextra; + } + } + if (searchstat == 4) + { + wall[searchwall].overpicnum = temppicnum; + if (wall[searchwall].nextwall >= 0) + wall[wall[searchwall].nextwall].overpicnum = temppicnum; + wall[searchwall].shade = tempshade; + wall[searchwall].pal = temppal; + if (somethingintab == 4) + { + wall[searchwall].xrepeat = tempxrepeat; + wall[searchwall].yrepeat = tempyrepeat; + wall[searchwall].cstat = tempcstat; + wall[searchwall].lotag = templotag; + wall[searchwall].hitag = temphitag; + wall[searchwall].extra = tempextra; + } + fixrepeats(searchwall); + } + } + asksave = 1; + keystatus[0x1c] = 0; + } + if (keystatus[0x2e] > 0) //C + { + keystatus[0x2e] = 0; + if (keystatus[0x38] > 0) //Alt-C + { + if (somethingintab < 255) + { + switch(searchstat) + { + case 0: + j = wall[searchwall].picnum; + for(i=0;i 0) //V + { + if (searchstat == 0) templong = wall[searchwall].picnum; + if (searchstat == 1) templong = sector[searchsector].ceilingpicnum; + if (searchstat == 2) templong = sector[searchsector].floorpicnum; + if (searchstat == 3) templong = sprite[searchwall].picnum; + if (searchstat == 4) templong = wall[searchwall].overpicnum; + templong = gettile(templong); + if (searchstat == 0) wall[searchwall].picnum = templong; + if (searchstat == 1) sector[searchsector].ceilingpicnum = templong; + if (searchstat == 2) sector[searchsector].floorpicnum = templong; + if (searchstat == 3) sprite[searchwall].picnum = templong; + if (searchstat == 4) + { + wall[searchwall].overpicnum = templong; + if (wall[searchwall].nextwall >= 0) + wall[wall[searchwall].nextwall].overpicnum = templong; + } + asksave = 1; + keystatus[0x2f] = 0; + } + + if (keystatus[0x1a]) // [ + { + keystatus[0x1a] = 0; + if (keystatus[0x38]|keystatus[0xb8]) + { + i = wall[searchwall].nextsector; + if (i >= 0) + switch(searchstat) + { + case 0: case 1: case 4: + alignceilslope(searchsector,wall[searchwall].x,wall[searchwall].y,getceilzofslope(i,wall[searchwall].x,wall[searchwall].y)); + break; + case 2: + alignflorslope(searchsector,wall[searchwall].x,wall[searchwall].y,getflorzofslope(i,wall[searchwall].x,wall[searchwall].y)); + break; + } + } + else + { + i = 512; + if (keystatus[0x36]) i = 8; + if (keystatus[0x2a]) i = 1; + + if (searchstat == 1) + { + if (!(sector[searchsector].ceilingstat&2)) + sector[searchsector].ceilingheinum = 0; + sector[searchsector].ceilingheinum = max(sector[searchsector].ceilingheinum-i,-32768); + } + if (searchstat == 2) + { + if (!(sector[searchsector].floorstat&2)) + sector[searchsector].floorheinum = 0; + sector[searchsector].floorheinum = max(sector[searchsector].floorheinum-i,-32768); + } + } + + if (sector[searchsector].ceilingheinum == 0) + sector[searchsector].ceilingstat &= ~2; + else + sector[searchsector].ceilingstat |= 2; + + if (sector[searchsector].floorheinum == 0) + sector[searchsector].floorstat &= ~2; + else + sector[searchsector].floorstat |= 2; + asksave = 1; + } + if (keystatus[0x1b]) // ] + { + keystatus[0x1b] = 0; + if (keystatus[0x38]|keystatus[0xb8]) + { + i = wall[searchwall].nextsector; + if (i >= 0) + switch(searchstat) + { + case 1: + alignceilslope(searchsector,wall[searchwall].x,wall[searchwall].y,getceilzofslope(i,wall[searchwall].x,wall[searchwall].y)); + break; + case 0: case 2: case 4: + alignflorslope(searchsector,wall[searchwall].x,wall[searchwall].y,getflorzofslope(i,wall[searchwall].x,wall[searchwall].y)); + break; + } + } + else + { + i = 512; + if (keystatus[0x36]) i = 8; + if (keystatus[0x2a]) i = 1; + + if (searchstat == 1) + { + if (!(sector[searchsector].ceilingstat&2)) + sector[searchsector].ceilingheinum = 0; + sector[searchsector].ceilingheinum = min(sector[searchsector].ceilingheinum+i,32767); + } + if (searchstat == 2) + { + if (!(sector[searchsector].floorstat&2)) + sector[searchsector].floorheinum = 0; + sector[searchsector].floorheinum = min(sector[searchsector].floorheinum+i,32767); + } + } + + if (sector[searchsector].ceilingheinum == 0) + sector[searchsector].ceilingstat &= ~2; + else + sector[searchsector].ceilingstat |= 2; + + if (sector[searchsector].floorheinum == 0) + sector[searchsector].floorstat &= ~2; + else + sector[searchsector].floorstat |= 2; + + asksave = 1; + } + + smooshyalign = keystatus[0x4c]; + repeatpanalign = (keystatus[0x2a]|keystatus[0x36]); + if ((keystatus[0x4b]|keystatus[0x4d]) > 0) // 4 & 6 (keypad) + { + if ((repeatcountx == 0) || (repeatcountx > 16)) + { + changedir = 0; + if (keystatus[0x4b] > 0) changedir = -1; + if (keystatus[0x4d] > 0) changedir = 1; + + if ((searchstat == 0) || (searchstat == 4)) + { + if (repeatpanalign == 0) + wall[searchwall].xrepeat = changechar(wall[searchwall].xrepeat,changedir,smooshyalign,1); + else + wall[searchwall].xpanning = changechar(wall[searchwall].xpanning,changedir,smooshyalign,0); + } + if ((searchstat == 1) || (searchstat == 2)) + { + if (searchstat == 1) + sector[searchsector].ceilingxpanning = changechar(sector[searchsector].ceilingxpanning,changedir,smooshyalign,0); + else + sector[searchsector].floorxpanning = changechar(sector[searchsector].floorxpanning,changedir,smooshyalign,0); + } + if (searchstat == 3) + { + sprite[searchwall].xrepeat = changechar(sprite[searchwall].xrepeat,changedir,smooshyalign,1); + if (sprite[searchwall].xrepeat < 4) + sprite[searchwall].xrepeat = 4; + } + asksave = 1; + repeatcountx = max(1,repeatcountx); + } + repeatcountx += (synctics>>1); + } + else + repeatcountx = 0; + + if ((keystatus[0x48]|keystatus[0x50]) > 0) // 2 & 8 (keypad) + { + if ((repeatcounty == 0) || (repeatcounty > 16)) + { + changedir = 0; + if (keystatus[0x48] > 0) changedir = -1; + if (keystatus[0x50] > 0) changedir = 1; + + if ((searchstat == 0) || (searchstat == 4)) + { + if (repeatpanalign == 0) + wall[searchwall].yrepeat = changechar(wall[searchwall].yrepeat,changedir,smooshyalign,1); + else + wall[searchwall].ypanning = changechar(wall[searchwall].ypanning,changedir,smooshyalign,0); + } + if ((searchstat == 1) || (searchstat == 2)) + { + if (searchstat == 1) + sector[searchsector].ceilingypanning = changechar(sector[searchsector].ceilingypanning,changedir,smooshyalign,0); + else + sector[searchsector].floorypanning = changechar(sector[searchsector].floorypanning,changedir,smooshyalign,0); + } + if (searchstat == 3) + { + sprite[searchwall].yrepeat = changechar(sprite[searchwall].yrepeat,changedir,smooshyalign,1); + if (sprite[searchwall].yrepeat < 4) + sprite[searchwall].yrepeat = 4; + } + asksave = 1; + repeatcounty = max(1,repeatcounty); + } + repeatcounty += (synctics>>1); + //} + } + else + repeatcounty = 0; + + if (keystatus[0x33] > 0) // , Search & fix panning to the left (3D) + { + if (searchstat == 3) + { + i = searchwall; + if ((keystatus[0x2a]|keystatus[0x36]) > 0) + sprite[i].ang = ((sprite[i].ang+2048-1)&2047); + else + { + sprite[i].ang = ((sprite[i].ang+2048-128)&2047); + keystatus[0x33] = 0; + } + } + } + if (keystatus[0x34] > 0) // . Search & fix panning to the right (3D) + { + if ((searchstat == 0) || (searchstat == 4)) + { + AutoAlignWalls((long)searchwall,0L); + + /*wallfind[0] = searchwall; + cnt = 4096; + do + { + wallfind[1] = wall[wallfind[0]].point2; + j = -1; + if (wall[wallfind[1]].picnum == wall[searchwall].picnum) + j = wallfind[1]; + k = wallfind[1]; + + while ((wall[wallfind[1]].nextwall >= 0) && (wall[wall[wallfind[1]].nextwall].point2 != k)) + { + i = wall[wall[wallfind[1]].nextwall].point2; //break if going around in circles on red lines with same picture on both sides + if (wallfind[1] == wall[wall[i].nextwall].point2) + break; + + wallfind[1] = wall[wall[wallfind[1]].nextwall].point2; + if (wall[wallfind[1]].picnum == wall[searchwall].picnum) + j = wallfind[1]; + } + wallfind[1] = j; + + if ((j >= 0) && (wallfind[1] != searchwall)) + { + j = (wall[wallfind[0]].xpanning+(wall[wallfind[0]].xrepeat<<3)) % tilesizx[wall[wallfind[0]].picnum]; + wall[wallfind[1]].cstat &= ~8; //Set to non-flip + wall[wallfind[1]].cstat |= 4; //Set y-orientation + wall[wallfind[1]].xpanning = j; + + for(k=0;k<2;k++) + { + sectnum = sectorofwall((short)wallfind[k]); + nextsectnum = wall[wallfind[k]].nextsector; + + if (nextsectnum == -1) + { + if ((wall[wallfind[k]].cstat&4) == 0) + daz[k] = sector[sectnum].ceilingz; + else + daz[k] = sector[sectnum].floorz; + } + else //topstep + { + if (sector[nextsectnum].ceilingz > sector[sectnum].ceilingz) + daz[k] = sector[nextsectnum].ceilingz; + else if (sector[nextsectnum].floorz < sector[sectnum].floorz) + daz[k] = sector[nextsectnum].floorz; + } + } + + j = (picsiz[wall[searchwall].picnum]>>4); + if ((1<>(j+3)))&255); + wall[wallfind[1]].ypanning = j; + wall[wallfind[1]].yrepeat = wall[wallfind[0]].yrepeat; + if (nextsectnum >= 0) + if (sector[nextsectnum].ceilingz >= sector[sectnum].ceilingz) + if (sector[nextsectnum].floorz <= sector[sectnum].floorz) + { + if (wall[wall[wallfind[1]].nextwall].picnum == wall[searchwall].picnum) + { + wall[wall[wallfind[1]].nextwall].yrepeat = wall[wallfind[0]].yrepeat; + if ((wall[wall[wallfind[1]].nextwall].cstat&4) == 0) + daz[1] = sector[nextsectnum].floorz; + else + daz[1] = sector[sectnum].ceilingz; + wall[wall[wallfind[1]].nextwall].ypanning = j; + } + } + } + wallfind[0] = wallfind[1]; + cnt--; + } + while ((wall[wallfind[0]].picnum == wall[searchwall].picnum) && (wallfind[0] != searchwall) && (cnt > 0)); + */ + + keystatus[0x34] = 0; + } + if (searchstat == 3) + { + i = searchwall; + if ((keystatus[0x2a]|keystatus[0x36]) > 0) + sprite[i].ang = ((sprite[i].ang+2048+1)&2047); + else + { + sprite[i].ang = ((sprite[i].ang+2048+128)&2047); + keystatus[0x34] = 0; + } + } + } + if (keystatus[0x35] > 0) // /? Reset panning&repeat to 0 + { + if ((searchstat == 0) || (searchstat == 4)) + { + wall[searchwall].xpanning = 0; + wall[searchwall].ypanning = 0; + wall[searchwall].xrepeat = 8; + wall[searchwall].yrepeat = 8; + wall[searchwall].cstat = 0; + fixrepeats((short)searchwall); + } + if (searchstat == 1) + { + sector[searchsector].ceilingxpanning = 0; + sector[searchsector].ceilingypanning = 0; + sector[searchsector].ceilingstat &= ~2; + sector[searchsector].ceilingheinum = 0; + } + if (searchstat == 2) + { + sector[searchsector].floorxpanning = 0; + sector[searchsector].floorypanning = 0; + sector[searchsector].floorstat &= ~2; + sector[searchsector].floorheinum = 0; + } + if (searchstat == 3) + { + if ((keystatus[0x2a]|keystatus[0x36]) > 0) + { + sprite[searchwall].xrepeat = sprite[searchwall].yrepeat; + } + else + { + sprite[searchwall].xrepeat = 64; + sprite[searchwall].yrepeat = 64; + } + } + keystatus[0x35] = 0; + asksave = 1; + } + + if (keystatus[0x19] > 0) // P (parallaxing sky) + { + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) + { + parallaxtype++; + if (parallaxtype == 3) + parallaxtype = 0; + } + else if ((keystatus[0x38]|keystatus[0xb8]) > 0) + { + switch (searchstat) + { + case 0: case 4: + Bstrcpy(buffer,"Wall pal: "); + wall[searchwall].pal = getnumber256(buffer,wall[searchwall].pal,256L,0); + break; + case 1: + Bstrcpy(buffer,"Ceiling pal: "); + sector[searchsector].ceilingpal = getnumber256(buffer,sector[searchsector].ceilingpal,256L,0); + break; + case 2: + Bstrcpy(buffer,"Floor pal: "); + sector[searchsector].floorpal = getnumber256(buffer,sector[searchsector].floorpal,256L,0); + break; + case 3: + Bstrcpy(buffer,"Sprite pal: "); + sprite[searchwall].pal = getnumber256(buffer,sprite[searchwall].pal,256L,0); + break; + } + } + else + { + if ((searchstat == 0) || (searchstat == 1) || (searchstat == 4)) + { + sector[searchsector].ceilingstat ^= 1; + asksave = 1; + } + else if (searchstat == 2) + { + sector[searchsector].floorstat ^= 1; + asksave = 1; + } + } + keystatus[0x19] = 0; + } + + if (keystatus[0x20] != 0) //Alt-D (adjust sprite[].clipdist) + { + keystatus[0x20] = 0; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) + { + if (searchstat == 3) + { + Bstrcpy(buffer,"Sprite clipdist: "); + sprite[searchwall].clipdist = getnumber256(buffer,sprite[searchwall].clipdist,256L,0); + } + } + } + + if (keystatus[0x30] > 0) // B (clip Blocking xor) (3D) + { + if (searchstat == 3) + { + sprite[searchwall].cstat ^= 1; + sprite[searchwall].cstat &= ~256; + sprite[searchwall].cstat |= ((sprite[searchwall].cstat&1)<<8); + asksave = 1; + } + else + { + wall[searchwall].cstat ^= 1; + wall[searchwall].cstat &= ~64; + if ((wall[searchwall].nextwall >= 0) && ((keystatus[0x2a]|keystatus[0x36]) == 0)) + { + wall[wall[searchwall].nextwall].cstat &= ~(1+64); + wall[wall[searchwall].nextwall].cstat |= (wall[searchwall].cstat&1); + } + asksave = 1; + } + keystatus[0x30] = 0; + } + if (keystatus[0x14] > 0) // T (transluscence for sprites/masked walls) + { + /*if (searchstat == 1) //Set masked/transluscent ceilings/floors + { + i = (sector[searchsector].ceilingstat&(128+256)); + sector[searchsector].ceilingstat &= ~(128+256); + switch(i) + { + case 0: sector[searchsector].ceilingstat |= 128; break; + case 128: sector[searchsector].ceilingstat |= 256; break; + case 256: sector[searchsector].ceilingstat |= 384; break; + case 384: sector[searchsector].ceilingstat |= 0; break; + } + asksave = 1; + } + if (searchstat == 2) + { + i = (sector[searchsector].floorstat&(128+256)); + sector[searchsector].floorstat &= ~(128+256); + switch(i) + { + case 0: sector[searchsector].floorstat |= 128; break; + case 128: sector[searchsector].floorstat |= 256; break; + case 256: sector[searchsector].floorstat |= 384; break; + case 384: sector[searchsector].floorstat |= 0; break; + } + asksave = 1; + }*/ + if (searchstat == 3) + { + if ((sprite[searchwall].cstat&2) == 0) + sprite[searchwall].cstat |= 2; + else if ((sprite[searchwall].cstat&512) == 0) + sprite[searchwall].cstat |= 512; + else + sprite[searchwall].cstat &= ~(2+512); + asksave = 1; + } + if (searchstat == 4) + { + if ((wall[searchwall].cstat&128) == 0) + wall[searchwall].cstat |= 128; + else if ((wall[searchwall].cstat&512) == 0) + wall[searchwall].cstat |= 512; + else + wall[searchwall].cstat &= ~(128+512); + + if (wall[searchwall].nextwall >= 0) + { + wall[wall[searchwall].nextwall].cstat &= ~(128+512); + wall[wall[searchwall].nextwall].cstat |= (wall[searchwall].cstat&(128+512)); + } + asksave = 1; + } + keystatus[0x14] = 0; + } + + if (keystatus[0x2] > 0) // 1 (make 1-way wall) + { + if (searchstat != 3) + { + wall[searchwall].cstat ^= 32; + asksave = 1; + } + else + { + sprite[searchwall].cstat ^= 64; + i = sprite[searchwall].cstat; + if ((i&48) == 32) + { + sprite[searchwall].cstat &= ~8; + if ((i&64) > 0) + if (posz > sprite[searchwall].z) + sprite[searchwall].cstat |= 8; + } + asksave = 1; + } + keystatus[0x2] = 0; + } + if (keystatus[0x3] > 0) // 2 (bottom wall swapping) + { + if (searchstat != 3) + { + wall[searchwall].cstat ^= 2; + asksave = 1; + } + keystatus[0x3] = 0; + } + if (keystatus[0x18] > 0) // O (top/bottom orientation - for doors) + { + if ((searchstat == 0) || (searchstat == 4)) + { + wall[searchwall].cstat ^= 4; + asksave = 1; + } + if (searchstat == 3) // O (ornament onto wall) (2D) + { + asksave = 1; + i = searchwall; + + hitscan(sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].sectnum, + sintable[(sprite[i].ang+2560+1024)&2047], + sintable[(sprite[i].ang+2048+1024)&2047], + 0, + &hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + + sprite[i].x = hitx; + sprite[i].y = hity; + sprite[i].z = hitz; + changespritesect(i,hitsect); + if (hitwall >= 0) + sprite[i].ang = ((getangle(wall[wall[hitwall].point2].x-wall[hitwall].x,wall[wall[hitwall].point2].y-wall[hitwall].y)+512)&2047); + + //Make sure sprite's in right sector + if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) + { + j = wall[hitwall].point2; + sprite[i].x -= ksgn(wall[j].y-wall[hitwall].y); + sprite[i].y += ksgn(wall[j].x-wall[hitwall].x); + } + } + keystatus[0x18] = 0; + } + if (keystatus[0x32] > 0) // M (masking walls) + { + if (searchstat != 3) + { + i = wall[searchwall].nextwall; + templong = (keystatus[0x2a]|keystatus[0x36]); + if (i >= 0) + { + wall[searchwall].cstat ^= 16; + if ((wall[searchwall].cstat&16) > 0) + { + wall[searchwall].cstat &= ~8; + if (templong == 0) + { + wall[i].cstat |= 8; //auto other-side flip + wall[i].cstat |= 16; + wall[i].overpicnum = wall[searchwall].overpicnum; + } + } + else + { + wall[searchwall].cstat &= ~8; + if (templong == 0) + { + wall[i].cstat &= ~8; //auto other-side unflip + wall[i].cstat &= ~16; + } + } + wall[searchwall].cstat &= ~32; + if (templong == 0) wall[i].cstat &= ~32; + asksave = 1; + } + } + keystatus[0x32] = 0; + } + if (keystatus[0x23] > 0) // H (hitscan sensitivity) + { + if (searchstat == 3) + { + sprite[searchwall].cstat ^= 256; + asksave = 1; + } + else + { + wall[searchwall].cstat ^= 64; + if ((wall[searchwall].nextwall >= 0) && ((keystatus[0x2a]|keystatus[0x36]) == 0)) + { + wall[wall[searchwall].nextwall].cstat &= ~64; + wall[wall[searchwall].nextwall].cstat |= (wall[searchwall].cstat&64); + } + asksave = 1; + } + keystatus[0x23] = 0; + } + if (keystatus[0x12] > 0) // E (expand) + { + if (searchstat == 1) + { + sector[searchsector].ceilingstat ^= 8; + asksave = 1; + } + if (searchstat == 2) + { + sector[searchsector].floorstat ^= 8; + asksave = 1; + } + keystatus[0x12] = 0; + } + if (keystatus[0x13] > 0) // R (relative alignment, rotation) + { + if (searchstat == 1) + { + sector[searchsector].ceilingstat ^= 64; + asksave = 1; + } + if (searchstat == 2) + { + sector[searchsector].floorstat ^= 64; + asksave = 1; + } + if (searchstat == 3) + { + i = sprite[searchwall].cstat; + if ((i&48) < 32) i += 16; else i &= ~48; + sprite[searchwall].cstat = i; + asksave = 1; + } + keystatus[0x13] = 0; + } + if (keystatus[0x21] > 0) //F (Flip) + { + keystatus[0x21] = 0; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT-F (relative alignmment flip) + { + if (searchstat != 3) + { + setfirstwall(searchsector,searchwall); + asksave = 1; + } + } + else + { + if ((searchstat == 0) || (searchstat == 4)) + { + i = wall[searchwall].cstat; + i = ((i>>3)&1)+((i>>7)&2); //3-x,8-y + switch(i) + { + case 0: i = 1; break; + case 1: i = 3; break; + case 2: i = 0; break; + case 3: i = 2; break; + } + i = ((i&1)<<3)+((i&2)<<7); + wall[searchwall].cstat &= ~0x0108; + wall[searchwall].cstat |= i; + asksave = 1; + } + if (searchstat == 1) //8-way ceiling flipping (bits 2,4,5) + { + i = sector[searchsector].ceilingstat; + i = (i&0x4)+((i>>4)&3); + switch(i) + { + case 0: i = 6; break; + case 6: i = 3; break; + case 3: i = 5; break; + case 5: i = 1; break; + case 1: i = 7; break; + case 7: i = 2; break; + case 2: i = 4; break; + case 4: i = 0; break; + } + i = (i&0x4)+((i&3)<<4); + sector[searchsector].ceilingstat &= ~0x34; + sector[searchsector].ceilingstat |= i; + asksave = 1; + } + if (searchstat == 2) //8-way floor flipping (bits 2,4,5) + { + i = sector[searchsector].floorstat; + i = (i&0x4)+((i>>4)&3); + switch(i) + { + case 0: i = 6; break; + case 6: i = 3; break; + case 3: i = 5; break; + case 5: i = 1; break; + case 1: i = 7; break; + case 7: i = 2; break; + case 2: i = 4; break; + case 4: i = 0; break; + } + i = (i&0x4)+((i&3)<<4); + sector[searchsector].floorstat &= ~0x34; + sector[searchsector].floorstat |= i; + asksave = 1; + } + if (searchstat == 3) + { + i = sprite[searchwall].cstat; + if (((i&48) == 32) && ((i&64) == 0)) + { + sprite[searchwall].cstat &= ~0xc; + sprite[searchwall].cstat |= (i&4)^4; + } + else + { + i = ((i>>2)&3); + switch(i) + { + case 0: i = 1; break; + case 1: i = 3; break; + case 2: i = 0; break; + case 3: i = 2; break; + } + i <<= 2; + sprite[searchwall].cstat &= ~0xc; + sprite[searchwall].cstat |= i; + } + asksave = 1; + } + } + } + if (keystatus[0x1f] > 0) //S (insert sprite) (3D) + { + dax = 16384; + day = divscale14(searchx-(xdim>>1),xdim>>1); + rotatepoint(0,0,dax,day,ang,&dax,&day); + + hitscan(posx,posy,posz,cursectnum, //Start position + dax,day,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang + &hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + + if (hitsect >= 0) + { + dax = hitx; + day = hity; + if ((gridlock > 0) && (grid > 0)) + { + if ((searchstat == 0) || (searchstat == 4)) + { + hitz = (hitz&0xfffffc00); + } + else + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); + } + } + + i = insertsprite(hitsect,0); + sprite[i].x = dax, sprite[i].y = day; + sprite[i].cstat = defaultspritecstat; + sprite[i].shade = 0; + sprite[i].pal = 0; + sprite[i].xrepeat = 64, sprite[i].yrepeat = 64; + sprite[i].xoffset = 0, sprite[i].yoffset = 0; + sprite[i].ang = 1536; + sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0; + sprite[i].owner = -1; + sprite[i].clipdist = 32; + sprite[i].lotag = 0; + sprite[i].hitag = 0; + sprite[i].extra = -1; + + for(k=0;k localartfreq[j]) + j = k; + if (localartfreq[j] > 0) + sprite[i].picnum = j; + else + sprite[i].picnum = 0; + + if (somethingintab == 3) + { + sprite[i].picnum = temppicnum; + if ((tilesizx[temppicnum] <= 0) || (tilesizy[temppicnum] <= 0)) + { + j = 0; + for(k=0;k 0) && (tilesizy[k] > 0)) + { + j = k; + break; + } + sprite[i].picnum = j; + } + sprite[i].shade = tempshade; + sprite[i].pal = temppal; + sprite[i].xrepeat = tempxrepeat; + sprite[i].yrepeat = tempyrepeat; + if (sprite[i].xrepeat < 1) sprite[i].xrepeat = 1; + if (sprite[i].yrepeat < 1) sprite[i].yrepeat = 1; + sprite[i].cstat = tempcstat; + } + + j = ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + if ((sprite[i].cstat&128) == 0) + sprite[i].z = min(max(hitz,getceilzofslope(hitsect,hitx,hity)+(j<<1)),getflorzofslope(hitsect,hitx,hity)); + else + sprite[i].z = min(max(hitz,getceilzofslope(hitsect,hitx,hity)+j),getflorzofslope(hitsect,hitx,hity)-j); + + if ((searchstat == 0) || (searchstat == 4)) + { + sprite[i].cstat = (sprite[i].cstat&~48)|(16+64); + if (hitwall >= 0) + sprite[i].ang = ((getangle(wall[wall[hitwall].point2].x-wall[hitwall].x,wall[wall[hitwall].point2].y-wall[hitwall].y)+512)&2047); + + //Make sure sprite's in right sector + if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) + { + j = wall[hitwall].point2; + sprite[i].x -= ksgn(wall[j].y-wall[hitwall].y); + sprite[i].y += ksgn(wall[j].x-wall[hitwall].x); + } + } + else + { + if (tilesizy[sprite[i].picnum] >= 32) sprite[i].cstat |= 1; + } + + updatenumsprites(); + asksave = 1; + } + + keystatus[0x1f] = 0; + } + if (keystatus[0xd3] > 0) + { + if (searchstat == 3) + { + deletesprite(searchwall); + updatenumsprites(); + asksave = 1; + } + keystatus[0xd3] = 0; + } + + if ((keystatus[0x3f]|keystatus[0x40]) > 0) //F5,F6 + { + switch(searchstat) + { + case 1: case 2: ExtShowSectorData(searchsector); break; + case 0: case 4: ExtShowWallData(searchwall); break; + case 3: ExtShowSpriteData(searchwall); break; + } + keystatus[0x3f] = 0, keystatus[0x40] = 0; + } + if ((keystatus[0x41]|keystatus[0x42]) > 0) //F7,F8 + { + switch(searchstat) + { + case 1: case 2: ExtEditSectorData(searchsector); break; + case 0: case 4: ExtEditWallData(searchwall); break; + case 3: ExtEditSpriteData(searchwall); break; + } + keystatus[0x41] = 0, keystatus[0x42] = 0; + } + + } + if (keystatus[buildkeys[14]] > 0) // Enter + { + overheadeditor(); + keystatus[buildkeys[14]] = 0; + } +} + +char changechar(char dachar, long dadir, char smooshyalign, char boundcheck) +{ + if (dadir < 0) + { + if ((dachar > 0) || (boundcheck == 0)) + { + dachar--; + if (smooshyalign > 0) + dachar = (dachar&0xf8); + } + } + else if (dadir > 0) + { + if ((dachar < 255) || (boundcheck == 0)) + { + dachar++; + if (smooshyalign > 0) + { + if (dachar >= 256-8) dachar = 255; + else dachar = ((dachar+7)&0xf8); + } + } + } + return(dachar); +} + +long gettile(long tilenum) +{ + char snotbuf[80], ch; + long i, j, k, otilenum, topleft, gap, temp, templong; + long xtiles, ytiles, tottiles; + + if (tilenum < 0) tilenum = 0; + + xtiles = (xdim>>6); ytiles = (ydim>>6); tottiles = xtiles*ytiles; + otilenum = tilenum; + + keystatus[0x2f] = 0; + for(i=0;i>1); + do + { + for(i=0;i= 0)) + { + templong = localartfreq[temp]; + localartfreq[temp] = localartfreq[temp+gap]; + localartfreq[temp+gap] = templong; + templong = localartlookup[temp]; + localartlookup[temp] = localartlookup[temp+gap]; + localartlookup[temp+gap] = templong; + + if (tilenum == temp) + tilenum = temp+gap; + else if (tilenum == temp+gap) + tilenum = temp; + + temp -= gap; + } + } + gap >>= 1; + } + while (gap > 0); + localartlookupnum = 0; + while (localartfreq[localartlookupnum] > 0) + localartlookupnum++; + + if (localartfreq[0] == 0) + { + tilenum = otilenum; + localartlookupnum = MAXTILES; + for(i=0;i MAXTILES-(tottiles<<(gettilezoom<<1))) topleft = MAXTILES-(tottiles<<(gettilezoom<<1)); + while ((keystatus[0x1c]|keystatus[1]) == 0) + { + drawtilescreen(topleft,tilenum); + + if (handleevents()) { + if (quitevent) quitevent = 0; + } + + synctics = totalclock-lockclock; + lockclock += synctics; + + if ((keystatus[0x37] > 0) && (gettilezoom < 2)) + { + gettilezoom++; + topleft = ((tilenum/(xtiles< MAXTILES-(tottiles<<(gettilezoom<<1))) topleft = MAXTILES-(tottiles<<(gettilezoom<<1)); + keystatus[0x37] = 0; + } + if ((keystatus[0xb5] > 0) && (gettilezoom > 0)) + { + gettilezoom--; + topleft = ((tilenum/(xtiles< MAXTILES-(tottiles<<(gettilezoom<<1))) topleft = MAXTILES-(tottiles<<(gettilezoom<<1)); + keystatus[0xb5] = 0; + } + if ((keystatus[0xcb] > 0) && (tilenum > 0)) + tilenum--, keystatus[0xcb] = 0; + if ((keystatus[0xcd] > 0) && (tilenum < MAXTILES-1)) + tilenum++, keystatus[0xcd] = 0; + if ((keystatus[0xc8] > 0) && (tilenum >= (xtiles< 0) && (tilenum < MAXTILES-(xtiles< 0) && (tilenum >= (xtiles< 0) && (tilenum < MAXTILES-(xtiles<= MAXTILES) tilenum = MAXTILES-1; + keystatus[0xd1] = 0; + } + if (keystatus[0x2f] > 0) //V + { + keystatus[0x2f] = 0; + if (tilenum < localartlookupnum) + tilenum = localartlookup[tilenum]; + else + tilenum = 0; + localartlookupnum = MAXTILES; + for(i=0;i 0) //G (goto) + { + if (tilenum < localartlookupnum) //Automatically press 'V' + tilenum = localartlookup[tilenum]; + else + tilenum = 0; + localartlookupnum = MAXTILES; + for(i=0;i= '0' && ch <= '9') { + i = (j*10)+(ch-'0'); + if (i < MAXTILES) j = i; + } else if (ch == 8) { + j /= 10; + } else if (ch == 13) { + tilenum = j; + break; + } + } + clearkeys(); + } + while (tilenum < topleft) topleft -= (xtiles<= topleft+(tottiles<<(gettilezoom<<1))) topleft += (xtiles< MAXTILES-(tottiles<<(gettilezoom<<1))) topleft = MAXTILES-(tottiles<<(gettilezoom<<1)); + } + + if (keystatus[0x1c] == 0) + { + tilenum = otilenum; + } + else + { + if (tilenum < localartlookupnum) + { + tilenum = localartlookup[tilenum]; + if ((tilesizx[tilenum] == 0) || (tilesizy[tilenum] == 0)) + tilenum = otilenum; + } + else + tilenum = otilenum; + } + keystatus[0x1] = 0; + keystatus[0x1c] = 0; + return(tilenum); +} + +long drawtilescreen(long pictopleft, long picbox) +{ + long i, j, vidpos, vidpos2, dat, wallnum, xdime, ydime, cnt, pinc; + long dax, day, scaledown, xtiles, ytiles, tottiles; + char *picptr, snotbuf[80]; + + xtiles = (xdim>>6); ytiles = (ydim>>6); tottiles = xtiles*ytiles; + + begindrawing(); //{{{ + + setpolymost2dview(); // JBF 20040205: set to 2d rendering + + pinc = ylookup[1]; + clearview(0L); + for(cnt=0;cnt<(tottiles<<(gettilezoom<<1));cnt++) //draw the 5*3 grid of tiles + { + wallnum = cnt+pictopleft; + if (wallnum < localartlookupnum) + { + wallnum = localartlookup[wallnum]; + if ((tilesizx[wallnum] != 0) && (tilesizy[wallnum] != 0)) + { + if (waloff[wallnum] == 0) loadtile(wallnum); + picptr = (char *)(waloff[wallnum]); + xdime = tilesizx[wallnum]; + ydime = tilesizy[wallnum]; + + dax = ((cnt%(xtiles<>gettilezoom)) { + vidpos = ylookup[day]+dax+frameplace; + if ((xdime <= (64>>gettilezoom)) && (ydime <= (64>>gettilezoom))) + { + for(i=0;i 64 + { + if (xdime > ydime) + scaledown = ((xdime+(63>>gettilezoom))>>(6-gettilezoom)); + else + scaledown = ((ydime+(63>>gettilezoom))>>(6-gettilezoom)); + + for(i=0;i>gettilezoom);i++) + { + plotpixel(dax+i,day,whitecol); + plotpixel(dax+i,day+(63>>gettilezoom),whitecol); + plotpixel(dax,day+i,whitecol); + plotpixel(dax+(63>>gettilezoom),day+i,whitecol); + } + + i = localartlookup[picbox]; + Bsprintf(snotbuf,"%ld",i); + printext256(0L,ydim-8,whitecol,-1,snotbuf,0); + printext256(xdim-(Bstrlen(names[i])<<3),ydim-8,whitecol,-1,names[i],0); + + Bsprintf(snotbuf,"%dx%d",tilesizx[i],tilesizy[i]); + printext256(xdim>>2,ydim-8,whitecol,-1,snotbuf,0); + + enddrawing(); //}}} + showframe(1); + + return(0); +} + +void overheadeditor(void) +{ + char buffer[80], *dabuffer, ch; + long i, j, k, m=0, mousxplc, mousyplc, firstx=0, firsty=0, oposz, col; + long templong, templong1, templong2, doubvel; + long startwall=0, endwall, dax, day, daz, x1, y1, x2, y2, x3, y3, x4, y4; + long highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect; + short pag, suckwall=0, sucksect, newnumwalls, newnumsectors, split=0, bad; + short splitsect=0, danumwalls, secondstartwall, joinsector[2], joinsectnum; + short splitstartwall=0, splitendwall, loopnum; + long mousx, mousy, bstatus; + long centerx, centery, circlerad; + short circlewall, circlepoints, circleang1, circleang2, circleangdir; + long sectorhighlightx=0, sectorhighlighty=0; + short cursectorhighlight, sectorhighlightstat; + short hitsect, hitwall, hitsprite; + long hitx, hity, hitz; + walltype *wal; + + //qsetmode640480(); + qsetmodeany(xdim2d,ydim2d); + xdim2d = xdim; + ydim2d = ydim; + + osearchx = searchx; + osearchy = searchy; + + searchx = scale(searchx,xdim2d,xdimgame); + searchy = scale(searchy,ydim2d-STATUS2DSIZ,ydimgame); + oposz = posz; + + begindrawing(); //{{{ + clearbuf((char *)(frameplace + (ydim16*bytesperline)), (bytesperline*STATUS2DSIZ) >> 2, 0x00000000l); + clearbuf((char *)frameplace, (ydim16*bytesperline) >> 2, 0L); + + ydim16 = ydim; + drawline16(0,ydim-STATUS2DSIZ,xdim-1,ydim-STATUS2DSIZ,1); + drawline16(0,ydim-1,xdim-1,ydim-1,1); + drawline16(0,ydim-STATUS2DSIZ,0,ydim-1,1); + drawline16(xdim-1,ydim-STATUS2DSIZ,xdim-1,ydim-1,1); + drawline16(0,ydim-STATUS2DSIZ+24,xdim-1,ydim-STATUS2DSIZ+24,1); + drawline16(192,ydim-STATUS2DSIZ,192,ydim-STATUS2DSIZ+24,1); + if (totalclock < 120*5) printext16(8L,ydim-STATUS2DSIZ+32L,9,-1,kensig,0); + + Bsprintf(tempbuf,"Mapster32"); + printext16(9L,ydim-STATUS2DSIZ+9L,4,-1,tempbuf,0); + printext16(8L,ydim-STATUS2DSIZ+8L,12,-1,tempbuf,0); +// printmessage16("Version: "VERSION); + if (totalclock < 30) printmessage16("Press F1 for help"); + drawline16(0,ydim-1-20,xdim-1,ydim-1-20,1); + drawline16(256,ydim-1-20,256,ydim-1,1); + ydim16 = ydim-STATUS2DSIZ; + enddrawing(); //}}} + + pag = 0; + highlightcnt = -1; + cursectorhighlight = -1; + lastpm16time = -1; + + //White out all bordering lines of grab that are + //not highlighted on both sides + for(i=highlightsectorcnt-1;i>=0;i--) + { + startwall = sector[highlightsector[i]].wallptr; + endwall = startwall + sector[highlightsector[i]].wallnum; + for(j=startwall;j= 0) + { + for(k=highlightsectorcnt-1;k>=0;k--) + if (highlightsector[k] == wall[j].nextsector) + break; + if (k < 0) + { + wall[wall[j].nextwall].nextwall = -1; + wall[wall[j].nextwall].nextsector = -1; + wall[j].nextwall = -1; + wall[j].nextsector = -1; + } + } + } + } + + for(i=0;i<(MAXWALLS>>3);i++) //Clear all highlights + show2dwall[i] = 0; + for(i=0;i<(MAXSPRITES>>3);i++) + show2dsprite[i] = 0; + + sectorhighlightstat = -1; + newnumwalls = -1; + joinsector[0] = -1; + circlewall = -1; + circlepoints = 7; + bstatus = 0; + keystatus[buildkeys[14]] = 0; + while ((keystatus[buildkeys[14]]>>1) == 0) + { + if (handleevents()) { + if (quitevent) { + keystatus[1] = 1; + quitevent = 0; + } + } + + OSD_DispatchQueued(); + + oldmousebstatus = bstatus; + getmousevalues(&mousx,&mousy,&bstatus); + mousx = (mousx<<16)+mousexsurp; + mousy = (mousy<<16)+mouseysurp; + { + ldiv_t ld; + ld = ldiv((long)((double)mousx*msens), (1<<16)); mousx = ld.quot; mousexsurp = ld.rem; + ld = ldiv((long)((double)mousy*msens), (1<<16)); mousy = ld.quot; mouseysurp = ld.rem; + } + searchx += mousx; + searchy += mousy; + if (searchx < 8) searchx = 8; + if (searchx > xdim-8-1) searchx = xdim-8-1; + if (searchy < 8) searchy = 8; + if (searchy > ydim-8-1) searchy = ydim-8-1; + +/* if (keystatus[0x3b] > 0) posx--, keystatus[0x3b] = 0; + if (keystatus[0x3c] > 0) posx++, keystatus[0x3c] = 0; + if (keystatus[0x3d] > 0) posy--, keystatus[0x3d] = 0; + if (keystatus[0x3e] > 0) posy++, keystatus[0x3e] = 0; + if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0; + if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; */ + if (angvel != 0) //ang += angvel * constant + { //ENGINE calculates angvel for you + doubvel = synctics; + if (keystatus[buildkeys[4]] > 0) //Lt. shift makes turn velocity 50% faster + doubvel += (synctics>>1); + ang += ((angvel*doubvel)>>4); + ang = (ang+2048)&2047; + } + if ((vel|svel) != 0) + { + doubvel = synctics; + if (keystatus[buildkeys[4]] > 0) //Lt. shift doubles forward velocity + doubvel += synctics; + xvect = 0, yvect = 0; + if (vel != 0) + { + xvect += ((vel*doubvel*(long)sintable[(ang+2560)&2047])>>3); + yvect += ((vel*doubvel*(long)sintable[(ang+2048)&2047])>>3); + } + if (svel != 0) + { + xvect += ((svel*doubvel*(long)sintable[(ang+2048)&2047])>>3); + yvect += ((svel*doubvel*(long)sintable[(ang+1536)&2047])>>3); + } + if (noclip) + { + posx += xvect>>14; + posy += yvect>>14; + updatesector(posx,posy,&cursectnum); + } + else clipmove(&posx,&posy,&posz,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + } + + getpoint(searchx,searchy,&mousxplc,&mousyplc); + linehighlight = getlinehighlight(mousxplc, mousyplc); + + if (newnumwalls >= numwalls) + { + dax = mousxplc; + day = mousyplc; + adjustmark(&dax,&day,newnumwalls); + wall[newnumwalls].x = dax; + wall[newnumwalls].y = day; + } + + ydim16 = ydim - STATUS2DSIZ; + + templong = numwalls; + numwalls = newnumwalls; + if (numwalls < 0) numwalls = templong; + + clear2dscreen(); + draw2dgrid(posx,posy,ang,zoom,grid); + + x2 = mulscale14(startposx-posx,zoom); //Draw brown arrow (start) + y2 = mulscale14(startposy-posy,zoom); + if (((halfxdim16+x2) >= 2) && ((halfxdim16+x2) <= xdim-3)) + if (((midydim16+y2) >= 2) && ((midydim16+y2) <= ydim16-3)) + { + x1 = mulscale11(sintable[(startang+2560)&2047],zoom) / 768; + y1 = mulscale11(sintable[(startang+2048)&2047],zoom) / 768; + begindrawing(); //{{{ + drawline16((halfxdim16+x2)+x1,(midydim16+y2)+y1,(halfxdim16+x2)-x1,(midydim16+y2)-y1,2); + drawline16((halfxdim16+x2)+x1,(midydim16+y2)+y1,(halfxdim16+x2)+y1,(midydim16+y2)-x1,2); + drawline16((halfxdim16+x2)+x1,(midydim16+y2)+y1,(halfxdim16+x2)-y1,(midydim16+y2)+x1,2); + enddrawing(); //}}} + } + + draw2dscreen(posx,posy,ang,zoom,grid); + + begindrawing(); //{{{ + if ((showtags == 1) && (zoom >= 768)) + { + for(i=0;i startwall) + { + dax /= (endwall-startwall+1); + day /= (endwall-startwall+1); + } + + dax = mulscale14(dax-posx,zoom); + day = mulscale14(day-posy,zoom); + + x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1); + y1 = midydim16+day-4; + x2 = x1 + (Bstrlen(dabuffer)<<2)+2; + y2 = y1 + 7; + if ((x1 >= 0) && (x2 < xdim) && (y1 >= 0) && (y2 < ydim16)) + printext16(x1,y1,0,7,dabuffer,1); + } + } + + x3 = divscale14(-halfxdim16,zoom)+posx; + y3 = divscale14(-(midydim16-4),zoom)+posy; + x4 = divscale14(halfxdim16,zoom)+posx; + y4 = divscale14(ydim16-(midydim16-4),zoom)+posy; + + for(i=numwalls-1,wal=&wall[i];i>=0;i--,wal--) + { + //Get average point of wall + dax = ((wal->x+wall[wal->point2].x)>>1); + day = ((wal->y+wall[wal->point2].y)>>1); + if ((dax > x3) && (dax < x4) && (day > y3) && (day < y4)) + { + dabuffer = (char *)ExtGetWallCaption(i); + if (dabuffer[0] != 0) + { + dax = mulscale14(dax-posx,zoom); + day = mulscale14(day-posy,zoom); + x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1); + y1 = midydim16+day-4; + x2 = x1 + (Bstrlen(dabuffer)<<2)+2; + y2 = y1 + 7; + if ((x1 >= 0) && (x2 < xdim) && (y1 >= 0) && (y2 < ydim16)) + printext16(x1,y1,0,4,dabuffer,1); + } + } + } + + i = 0; j = numsprites; + while ((j > 0) && (i < MAXSPRITES)) + { + if (sprite[i].statnum < MAXSTATUS) + { + dabuffer = (char *)ExtGetSpriteCaption(i); + if (dabuffer[0] != 0) + { + //Get average point of sprite + dax = sprite[i].x; + day = sprite[i].y; + + dax = mulscale14(dax-posx,zoom); + day = mulscale14(day-posy,zoom); + + x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1); + y1 = midydim16+day-4; + x2 = x1 + (Bstrlen(dabuffer)<<2)+2; + y2 = y1 + 7; + if ((x1 >= 0) && (x2 < xdim) && (y1 >= 0) && (y2 < ydim16)) + { + col = 3; + if (spritecol2d[sprite[i].picnum][0]) + col = spritecol2d[sprite[i].picnum][0]; + if ((sprite[i].cstat&1) > 0) + { + col = 5; + if (spritecol2d[sprite[i].picnum][1]) + col = spritecol2d[sprite[i].picnum][1]; + } + + if ((i == pointhighlight-16384) && (totalclock & 32)) col += (2<<2); + + printext16(x1,y1,0,col,dabuffer,1); + } + } + j--; + } + i++; + } + } + + printcoords16(posx,posy,ang); + + numwalls = templong; + + if (highlightsectorcnt > 0) + for(i=0;i= 0) + drawline16(halfxdim16+x2,midydim16+y2,halfxdim16+x2,midydim16+y2,15); + else + drawline16(halfxdim16+x2,midydim16+y2,halfxdim16+x2,midydim16+y2,5); + enddrawing(); //}}} + + OSD_Draw(); + + ExtCheckKeys(); // TX 20050101, it makes more sense to have this here so keys can be overwritten with new functions in bstub.c + +// Flip/mirror sector Ed Coolidge + if (keystatus[0x2d] > 0) // X (2D) + { + if (highlightsectorcnt > 0) + { + k = 0; + dax = 0; + day = 0; + for(i=0;i 0) + { + dax /= k; + day /= k; + } + + k = (keystatus[0x38]|keystatus[0xb8]); //ALT-X mirror sector in x + + if ((gridlock > 0) && (grid > 0)) + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); +// dax = ((dax+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); +// day = ((day+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); + } + + for(i=0;i>1; + for(w=1;w<=numtoswap;w++) + { + Bmemcpy(&tempwall,&wall[startofloop+w],sizeof(walltype)); + Bmemcpy(&wall[startofloop+w],&wall[endofloop-w+1],sizeof(walltype)); + Bmemcpy(&wall[endofloop-w+1],&tempwall,sizeof(walltype)); + } + + //make point2 point to next wall in loop + for(w=startofloop;w 0) // Y (2D) + { + if (highlightsectorcnt > 0) + { + k = 0; + dax = 0; + day = 0; + for(i=0;i 0) + { + dax /= k; + day /= k; + } + + k = (keystatus[0x38]|keystatus[0xb8]); //ALT-Y mirror sectors in y + + if ((gridlock > 0) && (grid > 0)) + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); +// dax = ((dax+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); +// day = ((day+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); + } + + for(i=0;i>1; + for(w=1;w<=numtoswap;w++) + { + Bmemcpy(&tempwall,&wall[startofloop+w],sizeof(walltype)); + Bmemcpy(&wall[startofloop+w],&wall[endofloop-w+1],sizeof(walltype)); + Bmemcpy(&wall[endofloop-w+1],&tempwall,sizeof(walltype)); + } + + //make point2 point to next wall in loop + for(w=startofloop;w 0) //F12 + { + keystatus[88] = 0; + /* + j = ydim16; ydim16 = ydim; + clear2dscreen(); + draw2dgrid(posx,posy,ang,zoom,grid); + draw2dscreen(posx,posy,ang,zoom,grid); + */ + + screencapture("captxxxx.tga",keystatus[0x2a]|keystatus[0x36]); + + /* + ydim16 = j; + clear2dscreen(); + draw2dgrid(posx,posy,ang,zoom,grid); + draw2dscreen(posx,posy,ang,zoom,grid); + */ + showframe(1); + } + if (keystatus[0x30] > 0) // B (clip Blocking xor) (2D) + { + pointhighlight = getpointhighlight(mousxplc, mousyplc); + linehighlight = getlinehighlight(mousxplc, mousyplc); + + if ((pointhighlight&0xc000) == 16384) + { + sprite[pointhighlight&16383].cstat ^= 1; + sprite[pointhighlight&16383].cstat &= ~256; + sprite[pointhighlight&16383].cstat |= ((sprite[pointhighlight&16383].cstat&1)<<8); + asksave = 1; + } + else if (linehighlight >= 0) + { + wall[linehighlight].cstat ^= 1; + wall[linehighlight].cstat &= ~64; + if ((wall[linehighlight].nextwall >= 0) && ((keystatus[0x2a]|keystatus[0x36]) == 0)) + { + wall[wall[linehighlight].nextwall].cstat &= ~(1+64); + wall[wall[linehighlight].nextwall].cstat |= (wall[linehighlight].cstat&1); + } + asksave = 1; + } + keystatus[0x30] = 0; + } + if (keystatus[0x21] > 0) //F (F alone does nothing in 2D right now) + { + keystatus[0x21] = 0; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT-F (relative alignmment flip) + { + linehighlight = getlinehighlight(mousxplc, mousyplc); + if (linehighlight >= 0) + { + setfirstwall(sectorofwall(linehighlight),linehighlight); + asksave = 1; + printmessage16("This wall now sector's first wall (sector[].wallptr)"); + } + } + } + + if (keystatus[0x18] > 0) // O (ornament onto wall) (2D) + { + keystatus[0x18] = 0; + if ((pointhighlight&0xc000) == 16384) + { + asksave = 1; + i = (pointhighlight&16383); + + hitscan(sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].sectnum, + sintable[(sprite[i].ang+2560+1024)&2047], + sintable[(sprite[i].ang+2048+1024)&2047], + 0, + &hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + + sprite[i].x = hitx; + sprite[i].y = hity; + sprite[i].z = hitz; + changespritesect(i,hitsect); + if (hitwall >= 0) + sprite[i].ang = ((getangle(wall[wall[hitwall].point2].x-wall[hitwall].x,wall[wall[hitwall].point2].y-wall[hitwall].y)+512)&2047); + + //Make sure sprite's in right sector + if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) + { + j = wall[hitwall].point2; + sprite[i].x -= ksgn(wall[j].y-wall[hitwall].y); + sprite[i].y += ksgn(wall[j].x-wall[hitwall].x); + } + } + } + + if (keystatus[0x33] > 0) // , (2D) + { + if (highlightsectorcnt > 0) + { + k = 0; + dax = 0; + day = 0; + for(i=0;i 0) + { + dax /= k; + day /= k; + } + + k = (keystatus[0x2a]|keystatus[0x36]); + + if (k == 0) + { + if ((gridlock > 0) && (grid > 0)) + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); + } + } + + for(i=0;i= 16384) + { + i = pointhighlight-16384; + if ((keystatus[0x2a]|keystatus[0x36]) > 0) + sprite[i].ang = ((sprite[i].ang+2048-1)&2047); + else + { + sprite[i].ang = ((sprite[i].ang+2048-128)&2047); + keystatus[0x33] = 0; + } + + clearmidstatbar16(); + showspritedata((short)pointhighlight-16384); + } + } + } + if (keystatus[0x34] > 0) // . (2D) + { + if (highlightsectorcnt > 0) + { + k = 0; + dax = 0; + day = 0; + for(i=0;i 0) + { + dax /= k; + day /= k; + } + + k = (keystatus[0x2a]|keystatus[0x36]); + + if (k == 0) + { + if ((gridlock > 0) && (grid > 0)) + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); + } + } + + for(i=0;i= 16384) + { + i = pointhighlight-16384; + if ((keystatus[0x2a]|keystatus[0x36]) > 0) + sprite[i].ang = ((sprite[i].ang+2048+1)&2047); + else + { + sprite[i].ang = ((sprite[i].ang+2048+128)&2047); + keystatus[0x34] = 0; + } + + clearmidstatbar16(); + showspritedata((short)pointhighlight-16384); + } + } + } + if (keystatus[0x46] > 0) //Scroll lock (set starting position) + { + startposx = posx; + startposy = posy; + startposz = posz; + startang = ang; + startsectnum = cursectnum; + keystatus[0x46] = 0; + asksave = 1; + } + + if (keystatus[0x3f] > 0) //F5 + { + keystatus[0x3f] = 0; + + for (i=0;i 0) //F6 + { + keystatus[0x40] = 0; + + if (pointhighlight >= 16384) + { + i = pointhighlight-16384; + + ydim16 = STATUS2DSIZ; + ExtShowSpriteData((short)i); + ydim16 = ydim-STATUS2DSIZ; + } + else if (linehighlight >= 0) + { + i = linehighlight; + + ydim16 = STATUS2DSIZ; + ExtShowWallData((short)i); + ydim16 = ydim-STATUS2DSIZ; + } + } + if (keystatus[0x41] > 0) //F7 + { + keystatus[0x41] = 0; + + for (i=0;i 0) //F8 + { + keystatus[0x42] = 0; + + if (pointhighlight >= 16384) + { + i = pointhighlight-16384; + + ydim16 = STATUS2DSIZ; + ExtEditSpriteData((short)i); + ydim16 = ydim-STATUS2DSIZ; + } + else if (linehighlight >= 0) + { + i = linehighlight; + + ydim16 = STATUS2DSIZ; + ExtEditWallData((short)i); + ydim16 = ydim-STATUS2DSIZ; + } + } + + if (keystatus[0x14] > 0) // T (tag) + { + keystatus[0x14] = 0; + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //Ctrl-T + { + showtags ^= 1; + if (showtags == 0) + printmessage16("Show tags OFF"); + else + printmessage16("Show tags ON"); + } + else if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT + { + if (pointhighlight >= 16384) + { + i = pointhighlight-16384; + Bsprintf(buffer,"Sprite (%ld) Lo-tag: ",i); + sprite[i].lotag = getnumber16(buffer,sprite[i].lotag,65536L,0); + clearmidstatbar16(); + showspritedata((short)i); + } + else if (linehighlight >= 0) + { + i = linehighlight; + Bsprintf(buffer,"Wall (%ld) Lo-tag: ",i); + wall[i].lotag = getnumber16(buffer,wall[i].lotag,65536L,0); + clearmidstatbar16(); + showwalldata((short)i); + } + printmessage16(""); + } + else + { + for (i=0;i 0) //H (Hi 16 bits of tag) + { + keystatus[0x23] = 0; + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //Ctrl-H + { + pointhighlight = getpointhighlight(mousxplc, mousyplc); + linehighlight = getlinehighlight(mousxplc, mousyplc); + + if ((pointhighlight&0xc000) == 16384) + { + sprite[pointhighlight&16383].cstat ^= 256; + asksave = 1; + } + else if (linehighlight >= 0) + { + wall[linehighlight].cstat ^= 64; + if ((wall[linehighlight].nextwall >= 0) && ((keystatus[0x2a]|keystatus[0x36]) == 0)) + { + wall[wall[linehighlight].nextwall].cstat &= ~64; + wall[wall[linehighlight].nextwall].cstat |= (wall[linehighlight].cstat&64); + } + asksave = 1; + } + } + else if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT + { + if (pointhighlight >= 16384) + { + i = pointhighlight-16384; + Bsprintf(buffer,"Sprite (%ld) Hi-tag: ",i); + sprite[i].hitag = getnumber16(buffer,sprite[i].hitag,65536L,0); + clearmidstatbar16(); + showspritedata((short)i); + } + else if (linehighlight >= 0) + { + i = linehighlight; + Bsprintf(buffer,"Wall (%ld) Hi-tag: ",i); + wall[i].hitag = getnumber16(buffer,wall[i].hitag,65536L,0); + clearmidstatbar16(); + showwalldata((short)i); + } + } + else + { + for (i=0;i 0) // P (palookup #) + { + keystatus[0x19] = 0; + + for (i=0;i 0) // E (status list) + { + if (pointhighlight >= 16384) + { + i = pointhighlight-16384; + Bsprintf(buffer,"Sprite (%ld) Status list: ",i); + changespritestat(i,getnumber16(buffer,sprite[i].statnum,65536L,0)); + clearmidstatbar16(); + showspritedata((short)i); + } + + printmessage16(""); + + keystatus[0x12] = 0; + } + + if (keystatus[0x0f] > 0) //TAB + { + clearmidstatbar16(); + + if ((keystatus[0x38]|keystatus[0xb8]|keystatus[0x1d]|keystatus[0x9d]) > 0) //ALT or CTRL + { + if (pointhighlight >= 16384) + showspritedata((short)pointhighlight-16384); + else if (linehighlight >= 0) + showwalldata((short)linehighlight); + } + else + { + for (i=0;i 0) //Right shift (point highlighting) + { + if (highlightcnt == 0) + { + highlightx2 = searchx, highlighty2 = searchy; + ydim16 = ydim-STATUS2DSIZ; + drawline16(highlightx2,highlighty1,highlightx1,highlighty1,5); + drawline16(highlightx2,highlighty2,highlightx1,highlighty2,5); + drawline16(highlightx1,highlighty2,highlightx1,highlighty1,5); + drawline16(highlightx2,highlighty2,highlightx2,highlighty1,5); + } + if (highlightcnt != 0) + { + highlightx1 = searchx; + highlighty1 = searchy; + highlightx2 = searchx; + highlighty2 = searchx; + highlightcnt = 0; + + for(i=0;i<(MAXWALLS>>3);i++) //Clear all highlights + show2dwall[i] = 0; + for(i=0;i<(MAXSPRITES>>3);i++) + show2dsprite[i] = 0; + } + } + else + { + if (highlightcnt == 0) + { + getpoint(highlightx1,highlighty1,&highlightx1,&highlighty1); + getpoint(highlightx2,highlighty2,&highlightx2,&highlighty2); + if (highlightx1 > highlightx2) + { + templong = highlightx1; highlightx1 = highlightx2; highlightx2 = templong; + } + if (highlighty1 > highlighty2) + { + templong = highlighty1; highlighty1 = highlighty2; highlighty2 = templong; + } + + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) + { + if ((linehighlight >= 0) && (linehighlight < MAXWALLS)) + { + i = linehighlight; + do + { + highlight[highlightcnt++] = i; + show2dwall[i>>3] |= (1<<(i&7)); + + for(j=0;j>3] |= (1<<(j&7)); + } + + i = wall[i].point2; + } + while (i != linehighlight); + } + } + else + { + for(i=0;i= highlightx1) && (wall[i].x <= highlightx2)) + if ((wall[i].y >= highlighty1) && (wall[i].y <= highlighty2)) + { + highlight[highlightcnt++] = i; + show2dwall[i>>3] |= (1<<(i&7)); + } + for(i=0;i= highlightx1) && (sprite[i].x <= highlightx2)) + if ((sprite[i].y >= highlighty1) && (sprite[i].y <= highlighty2)) + { + highlight[highlightcnt++] = i+16384; + show2dsprite[i>>3] |= (1<<(i&7)); + } + } + + if (highlightcnt <= 0) + highlightcnt = -1; + } + } + } + if (highlightcnt < 0) + { + if (keystatus[0xb8] > 0) //Right alt (sector highlighting) + { + if (highlightsectorcnt == 0) + { + highlightx2 = searchx, highlighty2 = searchy; + ydim16 = ydim-STATUS2DSIZ; + begindrawing(); //{{{ + drawline16(highlightx2,highlighty1,highlightx1,highlighty1,10); + drawline16(highlightx2,highlighty2,highlightx1,highlighty2,10); + drawline16(highlightx1,highlighty2,highlightx1,highlighty1,10); + drawline16(highlightx2,highlighty2,highlightx2,highlighty1,10); + enddrawing(); //}}} + } + if (highlightsectorcnt != 0) + { + for(i=0;i= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer((short)j,highlightsector[i]); + } + } + highlightx1 = searchx; + highlighty1 = searchy; + highlightx2 = searchx; + highlighty2 = searchx; + highlightsectorcnt = 0; + } + } + else + { + if (highlightsectorcnt == 0) + { + getpoint(highlightx1,highlighty1,&highlightx1,&highlighty1); + getpoint(highlightx2,highlighty2,&highlightx2,&highlighty2); + if (highlightx1 > highlightx2) + { + templong = highlightx1; highlightx1 = highlightx2; highlightx2 = templong; + } + if (highlighty1 > highlighty2) + { + templong = highlighty1; highlighty1 = highlighty2; highlighty2 = templong; + } + + for(i=0;i highlightx2) bad = 1; + if (wall[j].y < highlighty1) bad = 1; + if (wall[j].y > highlighty2) bad = 1; + if (bad == 1) break; + } + if (bad == 0) + highlightsector[highlightsectorcnt++] = i; + } + if (highlightsectorcnt <= 0) + highlightsectorcnt = -1; + + //White out all bordering lines of grab that are + //not highlighted on both sides + for(i=highlightsectorcnt-1;i>=0;i--) + { + startwall = sector[highlightsector[i]].wallptr; + endwall = startwall + sector[highlightsector[i]].wallnum; + for(j=startwall;j= 0) + { + for(k=highlightsectorcnt-1;k>=0;k--) + if (highlightsector[k] == wall[j].nextsector) + break; + if (k < 0) + { + wall[wall[j].nextwall].nextwall = -1; + wall[wall[j].nextwall].nextsector = -1; + wall[j].nextwall = -1; + wall[j].nextsector = -1; + } + } + } + } + + } + } + } + + if (((bstatus&1) < (oldmousebstatus&1)) && (highlightsectorcnt < 0)) //after dragging + { + j = 1; + if (highlightcnt > 0) + for (i=0;i=0;i--) //delete points + { + if (wall[i].x == wall[wall[i].point2].x) + if (wall[i].y == wall[wall[i].point2].y) + { + deletepoint((short)i); + printmessage16("Point deleted."); + asksave = 1; + } + } + for(i=0;i 0) //drag points + { + if (highlightsectorcnt > 0) + { + if ((bstatus&1) > (oldmousebstatus&1)) + { + newnumwalls = -1; + sectorhighlightstat = -1; + updatesector(mousxplc,mousyplc,&cursectorhighlight); + + if ((cursectorhighlight >= 0) && (cursectorhighlight < numsectors)) + { + for (i=0;i 0) && (grid > 0)) + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); + } + sectorhighlightx = dax; + sectorhighlighty = day; + break; + } + } + } + else if (sectorhighlightstat == 1) + { + dax = mousxplc; + day = mousyplc; + if ((gridlock > 0) && (grid > 0)) + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); + } + + dax -= sectorhighlightx; + day -= sectorhighlighty; + sectorhighlightx += dax; + sectorhighlighty += day; + + for(i=0;i=0;j=nextspritesect[j]) + { sprite[j].x += dax; sprite[j].y += day; } + } + + //for(i=0;i= 0) + // checksectorpointer(wall[j].nextwall,wall[j].nextsector); + // checksectorpointer((short)j,highlightsector[i]); + // } + //} + asksave = 1; + } + + } + else + { + if ((bstatus&1) > (oldmousebstatus&1)) + pointhighlight = getpointhighlight(mousxplc, mousyplc); + + if (pointhighlight >= 0) + { + dax = mousxplc; + day = mousyplc; + if ((gridlock > 0) && (grid > 0)) + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); + } + + j = 1; + if (highlightcnt > 0) + for (i=0;i= getceilzofslope(i,dax,day)) + if (sprite[pointhighlight&16383].z-daz <= getflorzofslope(i,dax,day)) + { + sprite[pointhighlight&16383].x = dax; + sprite[pointhighlight&16383].y = day; + if (sprite[pointhighlight&16383].sectnum != i) + changespritesect(pointhighlight&16383,(short)i); + break; + } + } + } + asksave = 1; + } + } + } + else + { + pointhighlight = getpointhighlight(mousxplc, mousyplc); + sectorhighlightstat = -1; + } + + if ((bstatus&6) > 0) + { + searchx = halfxdim16; + searchy = midydim16; + posx = mousxplc; + posy = mousyplc; + } + + if (((keystatus[buildkeys[8]] > 0) || (bstatus&16)) && (zoom < 16384)) zoom += synctics*(zoom>>4); + if (((keystatus[buildkeys[9]] > 0) || (bstatus&32)) && (zoom > 24)) zoom -= synctics*(zoom>>4); + if (zoom < 24) zoom = 24; + if (zoom > 16384) zoom = 16384; + + if (keystatus[0x22] > 0) // G (grid on/off) + { + grid++; + if (grid == 7) grid = 0; + keystatus[0x22] = 0; + } + if (keystatus[0x26] > 0) // L (grid lock) + { + gridlock = 1-gridlock, keystatus[0x26] = 0; + if (gridlock == 0) + printmessage16("Grid locking OFF"); + else + printmessage16("Grid locking ON"); + } + + if (keystatus[0x24] > 0) // J (join sectors) + { + if (joinsector[0] >= 0) + { + joinsector[1] = -1; + for(i=0;i= 0) && (joinsector[0] != joinsector[1])) + { + newnumwalls = numwalls; + + for(k=0;k<2;k++) + { + startwall = sector[joinsector[k]].wallptr; + endwall = startwall + sector[joinsector[k]].wallnum - 1; + for(j=startwall;j<=endwall;j++) + { + if (wall[j].cstat == 255) + continue; + joinsectnum = k; + if (wall[j].nextsector == joinsector[1-joinsectnum]) + { + wall[j].cstat = 255; + continue; + } + + i = j; + m = newnumwalls; + do + { + Bmemcpy(&wall[newnumwalls],&wall[i],sizeof(walltype)); + wall[newnumwalls].point2 = newnumwalls+1; + newnumwalls++; + wall[i].cstat = 255; + + i = wall[i].point2; + if (wall[i].nextsector == joinsector[1-joinsectnum]) + { + i = wall[wall[i].nextwall].point2; + joinsectnum = 1 - joinsectnum; + } + } + while ((wall[i].cstat != 255) && (wall[i].nextsector != joinsector[1-joinsectnum])); + wall[newnumwalls-1].point2 = m; + } + } + + if (newnumwalls > numwalls) + { + Bmemcpy(§or[numsectors],§or[joinsector[0]],sizeof(sectortype)); + sector[numsectors].wallptr = numwalls; + sector[numsectors].wallnum = newnumwalls-numwalls; + + //fix sprites + for(i=0;i<2;i++) + { + j = headspritesect[joinsector[i]]; + while (j != -1) + { + k = nextspritesect[j]; + changespritesect(j,numsectors); + j = k; + } + } + + numsectors++; + + for(i=numwalls;i= 0) + { + wall[wall[i].nextwall].nextwall = i; + wall[wall[i].nextwall].nextsector = numsectors-1; + } + } + + numwalls = newnumwalls; + newnumwalls = -1; + + for(k=0;k<2;k++) + { + startwall = sector[joinsector[k]].wallptr; + endwall = startwall + sector[joinsector[k]].wallnum - 1; + for(j=startwall;j<=endwall;j++) + { + wall[j].nextwall = -1; + wall[j].nextsector = -1; + } + } + + deletesector((short)joinsector[0]); + if (joinsector[0] < joinsector[1]) + joinsector[1]--; + deletesector((short)joinsector[1]); + printmessage16("Sectors joined."); + } + } + joinsector[0] = -1; + } + else + { + joinsector[0] = -1; + for(i=0;i 0) //ALT-S + { + if ((linehighlight >= 0) && (wall[linehighlight].nextwall == -1)) + { + if ((newnumwalls = whitelinescan(linehighlight)) < numwalls) + { + printmessage16("Can't make a sector out there."); + } + else + { + for(i=numwalls;i 0) //S + { + sucksect = -1; + for(i=0;i= 0) + { + dax = mousxplc; + day = mousyplc; + if ((gridlock > 0) && (grid > 0)) + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); + } + + i = insertsprite(sucksect,0); + sprite[i].x = dax, sprite[i].y = day; + sprite[i].cstat = defaultspritecstat; + sprite[i].shade = 0; + sprite[i].pal = 0; + sprite[i].xrepeat = 64, sprite[i].yrepeat = 64; + sprite[i].xoffset = 0, sprite[i].yoffset = 0; + sprite[i].ang = 1536; + sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0; + sprite[i].owner = -1; + sprite[i].clipdist = 32; + sprite[i].lotag = 0; + sprite[i].hitag = 0; + sprite[i].extra = -1; + + sprite[i].z = getflorzofslope(sucksect,dax,day); + if ((sprite[i].cstat&128) != 0) + sprite[i].z -= ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + + for(k=0;k localartfreq[j]) + j = k; + if (localartfreq[j] > 0) + sprite[i].picnum = j; + else + sprite[i].picnum = 0; + + if (somethingintab == 3) + { + sprite[i].picnum = temppicnum; + if ((tilesizx[temppicnum] <= 0) || (tilesizy[temppicnum] <= 0)) + { + j = 0; + for(k=0;k 0) && (tilesizy[k] > 0)) + { + j = k; + break; + } + sprite[i].picnum = j; + } + sprite[i].shade = tempshade; + sprite[i].pal = temppal; + sprite[i].xrepeat = tempxrepeat; + sprite[i].yrepeat = tempyrepeat; + if (sprite[i].xrepeat < 1) sprite[i].xrepeat = 1; + if (sprite[i].yrepeat < 1) sprite[i].yrepeat = 1; + sprite[i].cstat = tempcstat; + } + + if (tilesizy[sprite[i].picnum] >= 32) + sprite[i].cstat |= 1; + + printmessage16("Sprite inserted."); + updatenumsprites(); + asksave = 1; + } + + keystatus[0x1f] = 0; + } + + if (keystatus[0x2e] > 0) // C (make circle of points) + { + if (highlightsectorcnt >= 0) + { + newnumsectors = numsectors; + newnumwalls = numwalls; + for(i=0;i= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer((short)j,highlightsector[i]); + } + highlightsector[i] = numsectors+i; + } + numsectors = newnumsectors; + numwalls = newnumwalls; + + newnumwalls = -1; + newnumsectors = -1; + + updatenumsprites(); + printmessage16("Sectors duplicated and stamped."); + asksave = 1; + } + else if (highlightcnt >= 0) + { + for(i=0;i= 0) + { + circlewall = -1; + } + else + { + if (linehighlight >= 0) + circlewall = linehighlight; + } + keystatus[0x2e] = 0; + } + if (keystatus[0x4a] > 0) // - + { + if (circlepoints > 1) + circlepoints--; + keystatus[0x4a] = 0; + } + if (keystatus[0x4e] > 0) // + + { + if (circlepoints < 63) + circlepoints++; + keystatus[0x4e] = 0; + } + + bad = (keystatus[0x39] > 0); //Gotta do this to save lots of 3 spaces! + + if (circlewall >= 0) + { + x1 = wall[circlewall].x; + y1 = wall[circlewall].y; + x2 = wall[wall[circlewall].point2].x; + y2 = wall[wall[circlewall].point2].y; + x3 = mousxplc; + y3 = mousyplc; + adjustmark(&x3,&y3,newnumwalls); + templong1 = dmulscale4(x3-x2,x1-x3,y1-y3,y3-y2); + templong2 = dmulscale4(y1-y2,x1-x3,y1-y3,x2-x1); + if (templong2 != 0) + { + centerx = (((x1+x2) + scale(y1-y2,templong1,templong2))>>1); + centery = (((y1+y2) + scale(x2-x1,templong1,templong2))>>1); + + dax = mulscale14(centerx-posx,zoom); + day = mulscale14(centery-posy,zoom); + drawline16(halfxdim16+dax-2,midydim16+day-2,halfxdim16+dax+2,midydim16+day+2,14); + drawline16(halfxdim16+dax-2,midydim16+day+2,halfxdim16+dax+2,midydim16+day-2,14); + + circleang1 = getangle(x1-centerx,y1-centery); + circleang2 = getangle(x2-centerx,y2-centery); + + circleangdir = 1; + k = ((circleang2-circleang1)&2047); + if (mulscale4(x3-x1,y2-y1) < mulscale4(x2-x1,y3-y1)) + { + circleangdir = -1; + k = -((circleang1-circleang2)&2047); + } + + circlerad = (ksqrt(dmulscale4(centerx-x1,centerx-x1,centery-y1,centery-y1))<<2); + + for(i=circlepoints;i>0;i--) + { + j = ((circleang1 + scale(i,k,circlepoints+1))&2047); + dax = centerx+mulscale14(sintable[(j+512)&2047],circlerad); + day = centery+mulscale14(sintable[j],circlerad); + + if (dax <= -editorgridextent) dax = -editorgridextent; + if (dax >= editorgridextent) dax = editorgridextent; + if (day <= -editorgridextent) day = -editorgridextent; + if (day >= editorgridextent) day = editorgridextent; + + if (bad > 0) + { + m = 0; + if (wall[circlewall].nextwall >= 0) + if (wall[circlewall].nextwall < circlewall) m = 1; + insertpoint(circlewall,dax,day); + circlewall += m; + } + dax = mulscale14(dax-posx,zoom); + day = mulscale14(day-posy,zoom); + drawline16(halfxdim16+dax-2,midydim16+day-2,halfxdim16+dax+2,midydim16+day-2,14); + drawline16(halfxdim16+dax+2,midydim16+day-2,halfxdim16+dax+2,midydim16+day+2,14); + drawline16(halfxdim16+dax+2,midydim16+day+2,halfxdim16+dax-2,midydim16+day+2,14); + drawline16(halfxdim16+dax-2,midydim16+day+2,halfxdim16+dax-2,midydim16+day-2,14); + } + if (bad > 0) + { + bad = 0; + keystatus[0x39] = 0; + asksave = 1; + printmessage16("Circle points inserted."); + circlewall = -1; + } + } + } + + if (bad > 0) //Space bar test + { + keystatus[0x39] = 0; + adjustmark(&mousxplc,&mousyplc,newnumwalls); + if (checkautoinsert(mousxplc,mousyplc,newnumwalls) == 1) + { + printmessage16("You must insert a point there first."); + bad = 0; + } + } + + if (bad > 0) //Space + { + if ((newnumwalls < numwalls) && (numwalls < MAXWALLS-1)) + { + firstx = mousxplc, firsty = mousyplc; //Make first point + newnumwalls = numwalls; + suckwall = -1; + split = 0; + + //clearbufbyte(&wall[newnumwalls],sizeof(walltype),0L); + memset(&wall[newnumwalls],0,sizeof(walltype)); + wall[newnumwalls].extra = -1; + + wall[newnumwalls].x = mousxplc; + wall[newnumwalls].y = mousyplc; + wall[newnumwalls].nextsector = -1; + wall[newnumwalls].nextwall = -1; + for(i=0;i>1); + day = ((wall[numwalls].y+mousyplc)>>1); + for(i=0;i= 0) + if ((wall[wall[k].point2].x != mousxplc) || (wall[wall[k].point2].y != mousyplc)) + if ((wall[lastwall((short)k)].x != mousxplc) || (wall[lastwall((short)k)].y != mousyplc)) + { + split = 1; + splitsect = i; + splitstartwall = m; + break; + } + } + } + + //make new point + + //make sure not drawing over old red line + bad = 0; + for(i=0;i= 0) + { + if ((wall[i].x == mousxplc) && (wall[i].y == mousyplc)) + if ((wall[wall[i].point2].x == wall[newnumwalls-1].x) && (wall[wall[i].point2].y == wall[newnumwalls-1].y)) + bad = 1; + if ((wall[i].x == wall[newnumwalls-1].x) && (wall[i].y == wall[newnumwalls-1].y)) + if ((wall[wall[i].point2].x == mousxplc) && (wall[wall[i].point2].y == mousyplc)) + bad = 1; + } + } + + if (bad == 0) + { + //clearbufbyte(&wall[newnumwalls],sizeof(walltype),0L); + memset(&wall[newnumwalls],0,sizeof(walltype)); + wall[newnumwalls].extra = -1; + + wall[newnumwalls].x = mousxplc; + wall[newnumwalls].y = mousyplc; + wall[newnumwalls].nextsector = -1; + wall[newnumwalls].nextwall = -1; + for(i=0;i= numwalls+3)) + { + wall[newnumwalls-1].point2 = numwalls; + + if (suckwall == -1) //if no connections to other sectors + { + k = -1; + for(i=0;i= suckwall) + wall[i].nextwall += j; + if (wall[i].point2 >= suckwall) + wall[i].point2 += j; + } + + for(i=newnumwalls-1;i>=suckwall;i--) + Bmemcpy(&wall[i+j],&wall[i],sizeof(walltype)); + for(i=0;inumwalls;j--) + { + Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype)); + wall[danumwalls].nextwall = -1; + wall[danumwalls].nextsector = -1; + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + } + m = splitstartwall; //copy rest of loop next + while (m != splitendwall) + { + Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + m = wall[m].point2; + } + wall[danumwalls-1].point2 = secondstartwall; + + //Add other loops for 2nd sector + loopnum = loopnumofsector(splitsect,splitstartwall); + i = loopnum; + for(j=startwall;j<=endwall;j++) + { + k = loopnumofsector(splitsect,(short)j); + if ((k != i) && (k != loopnum)) + { + i = k; + if (loopinside(wall[j].x,wall[j].y,secondstartwall) == 1) + { + m = j; //copy loop + k = danumwalls; + do + { + Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + m = wall[m].point2; + } + while (m != j); + wall[danumwalls-1].point2 = k; + } + } + } + + //fix all next pointers on old sector line + for(j=numwalls;j= 0) + { + wall[wall[j].nextwall].nextwall = j; + if (j < secondstartwall) + wall[wall[j].nextwall].nextsector = numsectors; + else + wall[wall[j].nextwall].nextsector = numsectors+1; + } + } + //set all next pointers on split + for(j=numwalls;j= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer((short)j,sectorofwall((short)j)); + } + + //k now safe to use as temp + + for(m=numsectors-2;mnumwalls;j--) + { + Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype)); + wall[danumwalls].nextwall = -1; + wall[danumwalls].nextsector = -1; + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + } + + m = splitstartwall; //copy rest of loop next + do + { + Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + m = wall[m].point2; + } while (m != splitstartwall); + wall[danumwalls-1].point2 = numwalls; + + //Add other loops to sector + loopnum = loopnumofsector(splitsect,splitstartwall); + i = loopnum; + for(j=startwall;j<=endwall;j++) + { + k = loopnumofsector(splitsect,(short)j); + if ((k != i) && (k != loopnumofsector(splitsect,splitstartwall)) && (k != loopnumofsector(splitsect,splitendwall))) + { + i = k; + m = j; k = danumwalls; //copy loop + do + { + Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + m = wall[m].point2; + } while (m != j); + wall[danumwalls-1].point2 = k; + } + } + + //fix all next pointers on old sector line + for(j=numwalls;j= 0) + { + wall[wall[j].nextwall].nextwall = j; + wall[wall[j].nextwall].nextsector = numsectors; + } + } + + //copy sector attributes & fix wall pointers + Bmemcpy(§or[numsectors],§or[splitsect],sizeof(sectortype)); + sector[numsectors].wallptr = numwalls; + sector[numsectors].wallnum = danumwalls-numwalls; + + //fix sprites + j = headspritesect[splitsect]; + while (j != -1) + { + k = nextspritesect[j]; + changespritesect(j,numsectors); + j = k; + } + + numsectors++; + + //Back of number of walls of new sector for later + k = danumwalls-numwalls; + + //clear out old sector's next pointers for clean deletesector + numwalls = danumwalls; + for(j=startwall;j<=endwall;j++) + { + wall[j].nextwall = -1; + wall[j].nextsector = -1; + } + deletesector(splitsect); + + //Check pointers + for(j=numwalls-k;j= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer((short)j,numsectors-1); + } + + newnumwalls = -1; + printmessage16("Loops joined."); + break; + } + } + } + } + } + + if (keystatus[0x1c] > 0) //Left Enter + { + keystatus[0x1c] = 0; + if (keystatus[0x2a]&keystatus[0x1d]) + { + printmessage16("CHECKING ALL POINTERS!"); + for(i=0;i=0;i--) + sector[i].wallnum = sector[i+1].wallptr-sector[i].wallptr; + sector[numsectors-1].wallnum = numwalls-sector[numsectors-1].wallptr; + + for(i=0;i= 0) + { + checksectorpointer(linehighlight,sectorofwall(linehighlight)); + printmessage16("Highlighted line pointers checked."); + asksave = 1; + } + } + } + + if ((keystatus[0x0e] > 0) && (newnumwalls >= numwalls)) //Backspace + { + if (newnumwalls > numwalls) + { + newnumwalls--; + asksave = 1; + keystatus[0x0e] = 0; + } + if (newnumwalls == numwalls) + { + newnumwalls = -1; + asksave = 1; + keystatus[0x0e] = 0; + } + } + + if ((keystatus[0xd3] > 0) && (keystatus[0x9d] > 0) && (numwalls >= 0)) + { //sector delete + keystatus[0xd3] = 0; + + sucksect = -1; + for(i=0;i= 0) + for(j=0;j=0;j--) + { + deletesector(highlightsector[j]); + for(k=j-1;k>=0;k--) + if (highlightsector[k] >= highlightsector[j]) + highlightsector[k]--; + } + printmessage16("Highlighted sectors deleted."); + newnumwalls = -1; + k = 1; + highlightsectorcnt = -1; + break; + } + if (k == 0) + { + deletesector((short)i); + highlightsectorcnt = -1; + printmessage16("Sector deleted."); + } + newnumwalls = -1; + asksave = 1; + break; + } + } + + if ((keystatus[0xd3] > 0) && (pointhighlight >= 0)) + { + if ((pointhighlight&0xc000) == 16384) //Sprite Delete + { + deletesprite(pointhighlight&16383); + printmessage16("Sprite deleted."); + updatenumsprites(); + asksave = 1; + } + keystatus[0xd3] = 0; + } + + if (keystatus[0xd2] > 0) //InsertPoint + { + if (highlightsectorcnt >= 0) + { + newnumsectors = numsectors; + newnumwalls = numwalls; + for(i=0;i= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer((short)j,highlightsector[i]); + } + highlightsector[i] = numsectors+i; + } + numsectors = newnumsectors; + numwalls = newnumwalls; + + newnumwalls = -1; + newnumsectors = -1; + + updatenumsprites(); + printmessage16("Sectors duplicated and stamped."); + asksave = 1; + } + else if (highlightcnt >= 0) + { + for(i=0;i= 0) + { + getclosestpointonwall(mousxplc,mousyplc,(long)linehighlight,&dax,&day); + adjustmark(&dax,&day,newnumwalls); + insertpoint(linehighlight,dax,day); + printmessage16("Point inserted."); + + j = 0; + //Check to see if point was inserted over another point + for(i=numwalls-1;i>=0;i--) //delete points + if (wall[i].x == wall[wall[i].point2].x) + if (wall[i].y == wall[wall[i].point2].y) + { + deletepoint((short)i); + j++; + } + for(i=0;i>1); + // day = ((wall[linehighlight].y + wall[wall[linehighlight].point2].y)>>1); + // if ((dax != wall[linehighlight].x) || (day != wall[linehighlight].y)) + // if ((dax != wall[wall[linehighlight].point2].x) || (day != wall[wall[linehighlight].point2].y)) + // { + // insertpoint(linehighlight,dax,day); + // printmessage16("Point inserted at midpoint."); + // } + //} + + asksave = 1; + } + keystatus[0xd2] = 0; + } + + /*j = 0; + for(i=22-1;i>=0;i--) updatecrc16(j,kensig[i]); + if ((j&0xffff) != 0xebf) + { + printf("Don't screw with my name.\n"); + exit(0); + }*/ + //printext16(9L,336+9L,4,-1,kensig,0); + //printext16(8L,336+8L,12,-1,kensig,0); + + showframe(1); + synctics = totalclock-lockclock; + lockclock += synctics; + + if (keystatus[buildkeys[14]] > 0) + { + updatesector(posx,posy,&cursectnum); + if (cursectnum >= 0) + keystatus[buildkeys[14]] = 2; + else + printmessage16("Arrow must be inside a sector before entering 3D mode."); + } + CANCEL: + if (keystatus[1] > 0) + { + keystatus[1] = 0; + printmessage16("(N)ew, (L)oad, (S)ave, save (A)s, (Q)uit"); + showframe(1); + bflushchars(); + bad = 1; + while (bad == 1) + { + if (handleevents()) { + if (quitevent) { + quitevent = 0; + } + } + + ch = bgetchar(); + + if (keystatus[1] > 0) + { + keystatus[1] = 0; + bad = 0; + printmessage16(""); + } + else if (ch == 'n' || ch == 'N') //N + { + bad = 0; + printmessage16("Are you sure you want to start a new board? (Y/N)"); + showframe(1); + bflushchars(); ch = 0; + while (keystatus[1] == 0) + { + if (handleevents()) { + if (quitevent) { + quitevent = 0; + } + } + + ch = bgetchar(); + + if (ch == 'Y' || ch == 'y') + { + highlightsectorcnt = -1; + highlightcnt = -1; + + for(i=0;i<(MAXWALLS>>3);i++) //Clear all highlights + show2dwall[i] = 0; + for(i=0;i<(MAXSPRITES>>3);i++) + show2dsprite[i] = 0; + + for(i=0;i= 0) + { + j = 0; k = 0; + for(i=0;i MAXSECTORS) || (numwalls+j > MAXWALLS) || (numsprites+k > MAXSPRITES)) + { + highlightsectorcnt = -1; + } + else + { + //Put sectors&walls to end of lists + j = MAXWALLS; + for(i=0;i=0;i--) + if (sprite[i].statnum < MAXSTATUS) + { + k = sprite[i].sectnum; + for(j=0;j= 0) + { + if ((numsectors+highlightsectorcnt > MAXSECTORS) || (sector[MAXSECTORS-highlightsectorcnt].wallptr < numwalls)) + { + highlightsectorcnt = -1; + } + else + { + //Re-attach sectors&walls + for(i=0;i= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer((short)j,highlightsector[i]); + } + } + + } + } + + if (mapversion < 7) printmessage16("Map loaded successfully and autoconverted to V7!"); + else printmessage16("Map loaded successfully."); + } + updatenumsprites(); + startposx = posx; //this is same + startposy = posy; + startposz = posz; + startang = ang; + startsectnum = cursectnum; + } + showframe(1); + keystatus[0x1c] = 0; + } + else if (ch == 'a' || ch == 'A') //A + { + bad = 0; + + Bstrcpy(selectedboardfilename, boardfilename); + if (Bstrrchr(boardfilename, '/')) + Bstrcpy(boardfilename, Bstrrchr(boardfilename, '/')+1); + + i = 0; + while ((boardfilename[i] != 0) && (i < 64)) + i++; + if (boardfilename[i-4] == '.') + i -= 4; + boardfilename[i] = 0; + + bflushchars(); + while (bad == 0) + { + Bsprintf(buffer,"Save as: %s_", boardfilename); + printmessage16(buffer); + showframe(1); + + if (handleevents()) { + if (quitevent) quitevent = 0; + } + + ch = bgetchar(); + + if (keystatus[1] > 0) bad = 1; + else if (ch == 13) bad = 2; + else if (ch > 0) { + if (i > 0 && (ch == 8 || ch == 127)) { + i--; + boardfilename[i] = 0; + } + else if (i < 8 && ch > 32 && ch < 128) + { + boardfilename[i++] = ch; + boardfilename[i] = 0; + } + } + } + if (bad == 1) + { + Bstrcpy(boardfilename, selectedboardfilename); + keystatus[1] = 0; + printmessage16("Operation cancelled"); + showframe(1); + } + if (bad == 2) + { + char *f; + keystatus[0x1c] = 0; + + boardfilename[i] = '.'; + boardfilename[i+1] = 'm'; + boardfilename[i+2] = 'a'; + boardfilename[i+3] = 'p'; + boardfilename[i+4] = 0; + + if (Bstrrchr(selectedboardfilename,'/')) + Bstrcpy(Bstrrchr(selectedboardfilename, '/')+1, boardfilename); + else + Bstrcpy(selectedboardfilename, boardfilename); + if (pathsearchmode) f = selectedboardfilename; + else { + // virtual filesystem mode can't save to directories so drop the file into + // the current directory + f = strrchr(selectedboardfilename, '/'); + if (!f) f = selectedboardfilename; else f++; + } + Bsprintf(buffer,"Saving to %s...",f); + printmessage16(buffer); + showframe(1); + + fixspritesectors(); //Do this before saving! + updatesector(startposx,startposy,&startsectnum); + ExtPreSaveMap(); + saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum); + ExtSaveMap(f); + printmessage16("Board saved."); + Bstrcpy(boardfilename, selectedboardfilename); + } + bad = 0; + } + else if (ch == 's' || ch == 'S') //S + { + char *f; + bad = 0; + printmessage16("Saving board..."); + showframe(1); + fixspritesectors(); //Do this before saving! + updatesector(startposx,startposy,&startsectnum); + if (pathsearchmode) f = boardfilename; + else { + // virtual filesystem mode can't save to directories so drop the file into + // the current directory + f = strrchr(boardfilename, '/'); + if (!f) f = boardfilename; else f++; + } + ExtPreSaveMap(); + saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum); + ExtSaveMap(f); + printmessage16("Board saved."); + showframe(1); + } + else if (ch == 'q' || ch == 'Q') //Q + { + bad = 0; + printmessage16("Are you sure you want to quit?"); + showframe(1); + bflushchars(); + while ((keystatus[1]|keystatus[0x2e]) == 0) + { + if (handleevents()) { + if (quitevent) quitevent = 0; + } + + ch = bgetchar(); + + if (ch == 'y' || ch == 'Y') + { + //QUIT! + + printmessage16("Save changes?"); + showframe(1); + while ((keystatus[1]|keystatus[0x2e]) == 0) + { + if (handleevents()) { + if (quitevent) break; // like saying no + } + + ch = bgetchar(); + + if (ch == 'y' || ch == 'Y') + { + char *f; + fixspritesectors(); //Do this before saving! + updatesector(startposx,startposy,&startsectnum); + ExtPreSaveMap(); + if (pathsearchmode) f = boardfilename; + else { + // virtual filesystem mode can't save to directories so drop the file into + // the current directory + f = strrchr(boardfilename, '/'); + if (!f) f = boardfilename; else f++; + } + saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum); + ExtSaveMap(f); + break; + } else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ') { + break; + } + } + while(keystatus[1] || keystatus[0x2e]) + { + keystatus[1] = 0; + keystatus[0x2e] = 0; + quitevent = 0; + printmessage16("Operation cancelled"); + showframe(1); + goto CANCEL; + } + clearfilenames(); + uninittimer(); + uninitinput(); + ExtUnInit(); + uninitengine(); + printf("Memory status: %ld(%ld) bytes\n",cachesize,artsize); + printf("%s\n",kensig); + exit(0); + } else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ') { + break; + } + } + printmessage16(""); + showframe(1); + } + } + clearkeys(); + } + + //nextpage(); + } + + for(i=0;i= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer((short)j,highlightsector[i]); + } + } + + fixspritesectors(); + + if (setgamemode(fullscreen,xdimgame,ydimgame,bppgame) < 0) + { + ExtUnInit(); + uninitinput(); + uninittimer(); + uninitsystem(); + clearfilenames(); + printf("%ld * %ld not supported in this graphics mode\n",xdim,ydim); + exit(0); + } + + posz = oposz; + searchx = scale(searchx,xdimgame,xdim2d); + searchy = scale(searchy,ydimgame,ydim2d-STATUS2DSIZ); +} + +void getpoint(long searchxe, long searchye, long *x, long *y) +{ + if (posx <= -editorgridextent) posx = -editorgridextent; + if (posx >= editorgridextent) posx = editorgridextent; + if (posy <= -editorgridextent) posy = -editorgridextent; + if (posy >= editorgridextent) posy = editorgridextent; + + *x = posx + divscale14(searchxe-halfxdim16,zoom); + *y = posy + divscale14(searchye-midydim16,zoom); + + if (*x <= -editorgridextent) *x = -editorgridextent; + if (*x >= editorgridextent) *x = editorgridextent; + if (*y <= -editorgridextent) *y = -editorgridextent; + if (*y >= editorgridextent) *y = editorgridextent; +} + +long getlinehighlight(long xplc, long yplc) +{ + long i, dst, dist, closest, x1, y1, x2, y2, nx, ny; + + if (numwalls == 0) + return(-1); + dist = 1024; + closest = numwalls-1; + for(i=0;i= 0) + { //if red line, allow highlighting of both sides + x1 = wall[closest].x; + y1 = wall[closest].y; + x2 = wall[wall[closest].point2].x; + y2 = wall[wall[closest].point2].y; + if (dmulscale32(xplc-x1,y2-y1,-(x2-x1),yplc-y1) >= 0) + closest = wall[closest].nextwall; + } + if ((pointhighlight&0xc000) == 16384) return (-1); + else return(closest); + +} + +long getpointhighlight(long xplc, long yplc) +{ + long i, dst, dist, closest; + + if (numwalls == 0) + return(-1); + + dist = 0; + if (grid > 0) + dist = 512; + + closest = -1; + for(i=0;i= 256) + for(i=0;i 0) && (gridlock > 0)) + pointlockdist = (128>>grid); + + dist = pointlockdist; + dax = *xplc; + day = *yplc; + for(i=0;i 0) && (grid > 0)) + { + dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid))); + day = ((day+(1024>>grid))&(0xffffffff<<(11-grid))); + } + + *xplc = dax; + *yplc = day; + return(0); +} + +long checkautoinsert(long dax, long day, short danumwalls) +{ + long i, x1, y1, x2, y2; + + if (danumwalls < 0) + danumwalls = numwalls; + for(i=0;i= y2) && (y1 <= y0)) return(0); + if ((y1 >= y0) && (y1 <= y2)) return(1); + + templong = (x0-x1)*(y2-y1) - (x2-x1)*(y0-y1); + if (templong < 0) + return(0); + else + return(1); +} + +void flipwalls(short numwalls, short newnumwalls) +{ + long i, j, nume, templong; + + nume = newnumwalls-numwalls; + + for(i=numwalls;i>1);i++) + { + j = numwalls+newnumwalls-i-1; + templong = wall[i].x; wall[i].x = wall[j].x; wall[j].x = templong; + templong = wall[i].y; wall[i].y = wall[j].y; wall[j].y = templong; + } +} + +void insertpoint(short linehighlight, long dax, long day) +{ + short sucksect; + long i, j, k; + + j = linehighlight; + sucksect = sectorofwall((short)j); + + sector[sucksect].wallnum++; + for(i=sucksect+1;i= 0) + { + k = wall[j].nextwall; + + sucksect = sectorofwall((short)k); + + sector[sucksect].wallnum++; + for(i=sucksect+1;i= 0) + { + wall[wall[j].nextwall].nextwall = -1; + wall[wall[j].nextwall].nextsector = -1; + } + if (wall[point].nextwall >= 0) + { + wall[wall[point].nextwall].nextwall = -1; + wall[wall[point].nextwall].nextsector = -1; + } + movewalls((long)point,-1L); + + checksectorpointer((short)j,(short)sucksect); +} + +long deletesector(short sucksect) +{ + long i, j, k, nextk, startwall, endwall; + + while (headspritesect[sucksect] >= 0) + deletesprite(headspritesect[sucksect]); + updatenumsprites(); + + startwall = sector[sucksect].wallptr; + endwall = startwall + sector[sucksect].wallnum - 1; + j = sector[sucksect].wallnum; + + for(i=sucksect;i= startwall) + wall[i].nextsector--; + return(0); +} + +void fixspritesectors(void) +{ + long i, j, dax, day, daz; + + for(i=numsectors-1;i>=0;i--) + if ((sector[i].wallnum <= 0) || (sector[i].wallptr >= numwalls)) + deletesector((short)i); + + for(i=0;i= getceilzofslope(j,dax,day)) + if (sprite[i].z-daz <= getflorzofslope(j,dax,day)) + { + changespritesect((short)i,(short)j); + break; + } + } + } +} + +long movewalls(long start, long offs) +{ + long i; + + if (offs < 0) //Delete + { + for(i=start;i 0) //Insert + { + for(i=numwalls+offs-1;i>=start+offs;i--) + Bmemcpy(&wall[i],&wall[i-offs],sizeof(walltype)); + } + numwalls += offs; + for(i=0;i= start) wall[i].nextwall += offs; + if (wall[i].point2 >= start) wall[i].point2 += offs; + } + return(0); +} + +long checksectorpointer(short i, short sectnum) +{ + long j, k, startwall, endwall, x1, y1, x2, y2; + + x1 = wall[i].x; + y1 = wall[i].y; + x2 = wall[wall[i].point2].x; + y2 = wall[wall[i].point2].y; + + if (wall[i].nextwall >= 0) //Check for early exit + { + k = wall[i].nextwall; + if ((wall[k].x == x2) && (wall[k].y == y2)) + if ((wall[wall[k].point2].x == x1) && (wall[wall[k].point2].y == y1)) + return(0); + } + + wall[i].nextsector = -1; + wall[i].nextwall = -1; + for(j=0;j> 2, 0x08080808l); + clearbuf((char *)(frameplace + (bytesperline*(ydim-STATUS2DSIZ+25L))),(bytesperline*(STATUS2DSIZ+2-(25<<1))) >> 2, 0x00000000l); + drawline16(0,ydim-STATUS2DSIZ,0,ydim-1,7); + drawline16(xdim-1,ydim-STATUS2DSIZ,xdim-1,ydim-1,7); + ydim16 = ydim-STATUS2DSIZ; + enddrawing(); +} + +short loopinside(long x, long y, short startwall) +{ + long x1, y1, x2, y2, templong; + short i, cnt; + + cnt = clockdir(startwall); + i = startwall; + do + { + x1 = wall[i].x; x2 = wall[wall[i].point2].x; + if ((x1 >= x) || (x2 >= x)) + { + y1 = wall[i].y; y2 = wall[wall[i].point2].y; + if (y1 > y2) + { + templong = x1, x1 = x2, x2 = templong; + templong = y1, y1 = y2, y2 = templong; + } + if ((y1 <= y) && (y2 > y)) + if (x1*(y-y2)+x2*(y1-y) <= x*(y1-y2)) + cnt ^= 1; + } + i = wall[i].point2; + } + while (i != startwall); + return(cnt); +} + +long numloopsofsector(short sectnum) +{ + long i, numloops, startwall, endwall; + + numloops = 0; + startwall = sector[sectnum].wallptr; + endwall = startwall + sector[sectnum].wallnum; + for(i=startwall;i= '0' && ch <= '9') { + if (danum >= 0) + { + n = (danum*10)+(ch-'0'); + if (n <= maxnumber) danum = n; + } + else if (sign) // this extra check isn't hurting anything + { + n = (danum*10)-(ch-'0'); + if (n >= -maxnumber) danum = n; + } + } else if (ch == 8 || ch == 127) { // backspace + danum /= 10; + } else if (ch == 13) { + oldnum = danum; + asksave = 1; + break; + } else if (ch == '-' && sign) { // negate + danum = -danum; + } + } + clearkeys(); + return(oldnum); +} + +long getnumber256(char namestart[80], long num, long maxnumber, char sign) +{ + char buffer[80], ch; + long j, k, n, danum, oldnum; + + danum = num; + oldnum = danum; + bflushchars(); + while (keystatus[0x1] == 0) + { + if (handleevents()) { + if (quitevent) quitevent = 0; + } + + drawrooms(posx,posy,posz,ang,horiz,cursectnum); +#ifdef SUPERBUILD + ExtAnalyzeSprites(); +#endif + drawmasks(); + + ch = bgetchar(); + + Bsprintf(buffer,"%s%ld_ ",namestart,danum); + printmessage256(buffer); + showframe(1); + + if (ch >= '0' && ch <= '9') { + if (danum >= 0) + { + n = (danum*10)+(ch-'0'); + if (n <= maxnumber) danum = n; + } + else if (sign) + { + n = (danum*10)-(ch-'0'); + if (n >= -maxnumber) danum = n; + } + } else if (ch == 8 || ch == 127) { // backspace + danum /= 10; + } else if (ch == 13) { + oldnum = danum; + asksave = 1; + break; + } else if (ch == '-' && sign) { // negate + danum = -danum; + } + } + clearkeys(); + + lockclock = totalclock; //Reset timing + + return(oldnum); +} + +void clearfilenames(void) +{ + klistfree(finddirs); + klistfree(findfiles); + finddirs = findfiles = NULL; + numfiles = numdirs = 0; +} + +long getfilenames(char *path, char kind[6]) +{ + CACHE1D_FIND_REC *r; + + clearfilenames(); + finddirs = klistpath(path,"*",CACHE1D_FIND_DIR|CACHE1D_FIND_DRIVE|(!pathsearchmode&&grponlymode?CACHE1D_OPT_NOSTACK:0)); + findfiles = klistpath(path,kind,CACHE1D_FIND_FILE|(!pathsearchmode&&grponlymode?CACHE1D_OPT_NOSTACK:0)); + for (r = finddirs; r; r=r->next) numdirs++; + for (r = findfiles; r; r=r->next) numfiles++; + + finddirshigh = finddirs; + findfileshigh = findfiles; + currentlist = 0; + if (findfileshigh) currentlist = 1; + + return(0); +} + +long menuselect(void) +{ + int listsize; + long i, j, topplc; + char ch, buffer[78], *sb; + static char oldpath[BMAX_PATH]; + CACHE1D_FIND_REC *dir; + + int bakpathsearchmode = pathsearchmode; + + listsize = (ydim16-32)/8; + + Bstrcpy(selectedboardfilename, oldpath); + if (pathsearchmode) + Bcanonicalisefilename(selectedboardfilename, 1); // clips off the last token and compresses relative path + else + Bcorrectfilename(selectedboardfilename, 1); + + getfilenames(selectedboardfilename, "*.map"); + + begindrawing(); + printmessage16("Select map file with arrow keys and enter."); + enddrawing(); + + do { + begindrawing(); + clearbuf((char *)frameplace, (bytesperline*ydim16) >> 2, 0l); + + if (pathsearchmode) { + strcpy(buffer,"Local filesystem mode; press F for game filesystem."); + } else { + sprintf(buffer,"Game filesystem %smode; press F for local filesystem or G for %s.", + grponlymode?"GRP-only ":"", grponlymode?"all files":"GRP contents only"); + } + printext16(halfxdim16-(8*strlen(buffer)/2), 4, 12,0,buffer,0); + + Bsnprintf(buffer,78,"(%d dirs, %d files) %s",numdirs,numfiles,selectedboardfilename); + buffer[sizeof(buffer)-1] = 0; + printext16(1,ydim16-8-1,8,0,buffer,0); + + if (finddirshigh) { + dir = finddirshigh; + for(i=listsize/2-1; i>=0; i--) if (!dir->prev) break; else dir=dir->prev; + for(i=0; inext) { + int c = dir->type == CACHE1D_FIND_DIR ? 4 : 3; + memset(buffer,0,sizeof(buffer)); + strncpy(buffer,dir->name,25); + if (strlen(buffer) == 25) + buffer[21] = buffer[22] = buffer[23] = '.', buffer[24] = 0; + if (dir == finddirshigh) { + if (currentlist == 0) printext16(8,16+8*i,c|8,0,"->",0); + printext16(32,16+8*i,c|8,0,buffer,0); + } else { + printext16(32,16+8*i,c,0,buffer,0); + } + } + } + + if (findfileshigh) { + dir = findfileshigh; + for(i=listsize/2-1; i>=0; i--) if (!dir->prev) break; else dir=dir->prev; + for(i=0; inext) { + if (dir == findfileshigh) { + if (currentlist == 1) printext16(240,16+8*i,7|8,0,"->",0); + printext16(240+24,16+8*i,7|8,0,dir->name,0); + } else { + printext16(240+24,16+8*i,7,0,dir->name,0); + } + } + } + enddrawing(); + showframe(1); + + keystatus[0xcb] = 0; + keystatus[0xcd] = 0; + keystatus[0xc8] = 0; + keystatus[0xd0] = 0; + keystatus[0x1c] = 0; //enter + keystatus[0xf] = 0; //tab + keystatus[1] = 0; //esc + ch = 0; //Interesting fakery of ch = getch() + while (ch == 0) + { + if (handleevents()) { + if (quitevent) { + keystatus[1] = 1; + quitevent = 0; + } + } + ch = bgetchar(); + { // JBF 20040208: seek to first name matching pressed character + CACHE1D_FIND_REC *seeker = currentlist ? findfiles : finddirs; + if((keystatus[0xc7]|keystatus[0xcf]) > 0) // home/end + { + while(keystatus[0xcf]?seeker->next:seeker->prev) + seeker = keystatus[0xcf]?seeker->next:seeker->prev; + if (seeker) { + if (currentlist) findfileshigh = seeker; + else finddirshigh = seeker; + } + ch = keystatus[0xcf]?80:72; + keystatus[0xc7] = keystatus[0xcf] = 0; + } + else if((keystatus[0xc9]|keystatus[0xd1]) > 0) // page up/down + { + seeker = currentlist?findfileshigh:finddirshigh; + i = (ydim2d-STATUS2DSIZ-48)>>3; + while(i>0) { + if(keystatus[0xd1]?seeker->next:seeker->prev) + seeker = keystatus[0xd1]?seeker->next:seeker->prev; + i--; + } + if (seeker) { + if (currentlist) findfileshigh = seeker; + else finddirshigh = seeker; + } + ch = keystatus[0xd1]?80:72; + keystatus[0xc9] = keystatus[0xd1] = 0; + } + else + { + char ch2; + if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) { + if (ch >= 'a') ch -= ('a'-'A'); + while (seeker) { + ch2 = seeker->name[0]; + if (ch2 >= 'a' && ch2 <= 'z') ch2 -= ('a'-'A'); + if (ch2 == ch) break; + seeker = seeker->next; + } + if (seeker) { + if (currentlist) findfileshigh = seeker; + else finddirshigh = seeker; + continue; + } + } + } + } + if (keystatus[0xcb] > 0) ch = 9; // left arr + if (keystatus[0xcd] > 0) ch = 9; // right arr + if (keystatus[0xc8] > 0) ch = 72; // up arr + if (keystatus[0xd0] > 0) ch = 80; // down arr + } + if (ch == 'f' || ch == 'F') { + currentlist = 0; + pathsearchmode = 1-pathsearchmode; + if (pathsearchmode) { + strcpy(selectedboardfilename, ""); + Bcanonicalisefilename(selectedboardfilename, 0); + } else strcpy(selectedboardfilename, "/"); + getfilenames(selectedboardfilename, "*.map"); + Bstrcpy(oldpath,selectedboardfilename); + } else if (ch == 'g' || ch == 'G') { + if (!pathsearchmode) { + grponlymode = 1-grponlymode; + getfilenames(selectedboardfilename, "*.map"); + Bstrcpy(oldpath,selectedboardfilename); + } + } else if (ch == 9) { + if ((currentlist == 0 && findfiles) || (currentlist == 1 && finddirs)) + currentlist = 1-currentlist; + } else if ((ch == 75) || (ch == 72)) { + if (currentlist == 0) { + if (finddirshigh && finddirshigh->prev) finddirshigh = finddirshigh->prev; + } else { + if (findfileshigh && findfileshigh->prev) findfileshigh = findfileshigh->prev; + } + } else if ((ch == 77) || (ch == 80)) { + if (currentlist == 0) { + if (finddirshigh && finddirshigh->next) finddirshigh = finddirshigh->next; + } else { + if (findfileshigh && findfileshigh->next) findfileshigh = findfileshigh->next; + } + } else if ((ch == 13) && (currentlist == 0)) { + if (finddirshigh->type == CACHE1D_FIND_DRIVE) { + strcpy(selectedboardfilename, finddirshigh->name); + } else { + strcat(selectedboardfilename, finddirshigh->name); + } + strcat(selectedboardfilename, "/"); + if (pathsearchmode) + Bcanonicalisefilename(selectedboardfilename, 1); + else + Bcorrectfilename(selectedboardfilename, 1); + + Bstrcpy(oldpath,selectedboardfilename); + //printf("Changing directories to: %s\n", selectedboardfilename); + + getfilenames(selectedboardfilename, "*.map"); + ch = 0; + + begindrawing(); + clearbuf((char *)frameplace, (bytesperline*ydim16) >> 2, 0l); + enddrawing(); + showframe(1); + } + if (ch == 13 && !findfileshigh) ch = 0; + } + while ((ch != 13) && (ch != 27)); + if (ch == 13) + { + Bstrcat(selectedboardfilename, findfileshigh->name); + //printf("Selected file: %s\n", selectedboardfilename); + + return(0); + } + pathsearchmode = bakpathsearchmode; + return(-1); +} + +long fillsector(short sectnum, char fillcolor) +{ + long x1, x2, y1, y2, sy, y, templong; + long lborder, rborder, uborder, dborder, miny, maxy, dax; + short z, zz, startwall, endwall, fillcnt; + + lborder = 0; rborder = xdim; + uborder = 0; dborder = ydim16; + + if (sectnum == -1) + return(0); + miny = dborder-1; + maxy = uborder; + startwall = sector[sectnum].wallptr; + endwall = startwall + sector[sectnum].wallnum - 1; + for(z=startwall;z<=endwall;z++) + { + y1 = (((wall[z].y-posy)*zoom)>>14)+midydim16; + y2 = (((wall[wall[z].point2].y-posy)*zoom)>>14)+midydim16; + if (y1 < miny) miny = y1; + if (y2 < miny) miny = y2; + if (y1 > maxy) maxy = y1; + if (y2 > maxy) maxy = y2; + } + if (miny < uborder) miny = uborder; + if (maxy >= dborder) maxy = dborder-1; + + for(sy=miny+((totalclock>>2)&3);sy<=maxy;sy+=3) // JBF 20040116: numframes%3 -> (totalclock>>2)&3 + { + y = posy+(((sy-midydim16)<<14)/zoom); + + fillist[0] = lborder; fillcnt = 1; + for(z=startwall;z<=endwall;z++) + { + x1 = wall[z].x; x2 = wall[wall[z].point2].x; + y1 = wall[z].y; y2 = wall[wall[z].point2].y; + if (y1 > y2) + { + templong = x1; x1 = x2; x2 = templong; + templong = y1; y1 = y2; y2 = templong; + } + if ((y1 <= y) && (y2 > y)) + //if (x1*(y-y2) + x2*(y1-y) <= 0) + { + dax = x1+scale(y-y1,x2-x1,y2-y1); + dax = (((dax-posx)*zoom)>>14)+halfxdim16; + if (dax >= lborder) + fillist[fillcnt++] = dax; + } + } + if (fillcnt > 0) + { + for(z=1;z rborder) break; + if (fillist[z+1] > rborder) + fillist[z+1] = rborder; + drawline16(fillist[z],sy,fillist[z+1],sy,fillcolor); + } + } + } + return(0); +} + +short whitelinescan(short dalinehighlight) +{ + long i, j, k; + short sucksect, newnumwalls; + + sucksect = sectorofwall(dalinehighlight); + + Bmemcpy(§or[numsectors],§or[sucksect],sizeof(sectortype)); + sector[numsectors].wallptr = numwalls; + sector[numsectors].wallnum = 0; + i = dalinehighlight; + newnumwalls = numwalls; + do + { + j = lastwall((short)i); + if (wall[j].nextwall >= 0) + { + j = wall[j].point2; + for(k=0;k 32); + + buffercnt = 0; + do + { + loadbyte(fil,tempbuf,bufplc,ch); + if (ch > 32) buffer[buffercnt++] = ch; + } + while (ch > 32); + + num = 0; + do + { + loadbyte(fil,tempbuf,bufplc,ch); + if ((ch >= 48) && (ch <= 57)) num = num*10+(ch-48); + } + while (ch != 13); + for(i=0;i= 1) { + if (a > 1) + if (buffer[a-2] == '\r') buffer[a-2] = 0; + if (buffer[a-1] == '\n') buffer[a-1] = 0; + } + + p = buffer; + line++; + while (*p == 32) p++; + if (*p == 0) continue; // blank line + + if (*p == '#') { + p++; + while (*p == 32) p++; + if (*p == 0) continue; // null directive + + if (!Bstrncmp(p, "define ", 7)) { + // #define_... + p += 7; + while (*p == 32) p++; + if (*p == 0) { + printf("Error: Malformed #define at line %d\n", line-1); + continue; + } + + name = p; + while (*p != 32 && *p != 0) p++; + if (*p == 32) { + *(p++) = 0; + while (*p == 32) p++; + if (*p == 0) { // #define_NAME with no number + printf("Error: No number given for name \"%s\" (line %d)\n", name, line-1); + continue; + } + + number = p; + while (*p != 0) p++; + if (*p != 0) *p = 0; + + // add to list + num = Bstrtol(number, &endptr, 10); + if (*endptr != 0) { + p = endptr; + goto badline; + } + //printf("Grokked \"%s\" -> \"%d\"\n", name, num); + if (num < 0 || num >= MAXTILES) { + printf("Error: Constant %d for name \"%s\" out of range (line %d)\n", num, name, line-1); + continue; + } + + if (Bstrlen(name) > 24) + printf("Warning: Name \"%s\" longer than 24 characters (line %d). Truncating.\n", name, line-1); + + Bstrncpy(names[num], name, 24); + names[num][24] = 0; + + syms++; + + continue; + + } else { // #define_NAME with no number + printf("Error: No number given for name \"%s\" (line %d)\n", name, line-1); + continue; + } + } else goto badline; + } else if (*p == '/') { + if (*(p+1) == '/') continue; // comment + } +badline: + printf("Error: Invalid statement found at character %d on line %d\n", (p-buffer), line-1); + } + printf("Read %d lines, loaded %d names.\n", line, syms); + + Bfclose(fp); + return 0; +} + +void printcoords16(long posxe, long posye, short ange) +{ + char snotbuf[80]; + long i,m; + + Bsprintf(snotbuf,"x=%ld y=%ld ang=%d",posxe,posye,ange); + i = 0; + while ((snotbuf[i] != 0) && (i < 30)) + i++; + while (i < 30) + { + snotbuf[i] = 32; + i++; + } + snotbuf[30] = 0; + + m = (numsectors > MAXSECTORSV7 || numwalls > MAXWALLSV7 || numsprites > MAXSPRITESV7); + + printext16(8, ydim-STATUS2DSIZ+128+2, 9, 0, snotbuf,0); + + Bsprintf(snotbuf,"%d/%d sect. %d/%d walls %ld/%d spri.", + numsectors,m?MAXSECTORSV8:MAXSECTORSV7, + numwalls,m?MAXWALLSV8:MAXWALLSV7, + numsprites,m?MAXSPRITESV8:MAXSPRITESV7); + i = 0; + while ((snotbuf[i] != 0) && (i < 46)) + i++; + while (i < 46) + { + snotbuf[i] = 32; + i++; + } + snotbuf[46] = 0; + + printext16(264, ydim-STATUS2DSIZ+128+2, 9+m, 0, snotbuf,0); +} + +void updatenumsprites(void) +{ + long i; + + numsprites = 0; + for(i=0;i= 0) + { + wall[newnumwalls].nextwall += deststartwall-startwall; + wall[newnumwalls].nextsector += destsector-soursector; + } + newnumwalls++; + } + + //for(j=deststartwall;j= 0) + // checksectorpointer(wall[j].nextwall,wall[j].nextsector); + // checksectorpointer((short)j,destsector); + //} + + if (newnumwalls > deststartwall) + { + //duplicate sectors + Bmemcpy(§or[destsector],§or[soursector],sizeof(sectortype)); + sector[destsector].wallptr = deststartwall; + sector[destsector].wallnum = newnumwalls-deststartwall; + + if (copystat == 1) + { + //duplicate sprites + j = headspritesect[soursector]; + while (j >= 0) + { + k = nextspritesect[j]; + + m = insertsprite(destsector,sprite[j].statnum); + Bmemcpy(&sprite[m],&sprite[j],sizeof(spritetype)); + sprite[m].sectnum = destsector; //Don't let memcpy overwrite sector! + + j = k; + } + } + + } +} + +void showsectordata(short sectnum) +{ + char snotbuf[80]; + + Bsprintf(snotbuf,"Sector %d",sectnum); + printext16(8,ydim-STATUS2DSIZ+32,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Firstwall: %d",sector[sectnum].wallptr); + printext16(8,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Numberofwalls: %d",sector[sectnum].wallnum); + printext16(8,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Firstsprite: %d",headspritesect[sectnum]); + printext16(8,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Tags: %d, %d",sector[sectnum].hitag,sector[sectnum].lotag); + printext16(8,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); + Bsprintf(snotbuf," (0x%x), (0x%x)",sector[sectnum].hitag,sector[sectnum].lotag); + printext16(8,ydim-STATUS2DSIZ+80,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Extra: %d",sector[sectnum].extra); + printext16(8,ydim-STATUS2DSIZ+88,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Visibility: %d",sector[sectnum].visibility); + printext16(8,ydim-STATUS2DSIZ+96,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Pixel height: %ld",(sector[sectnum].floorz-sector[sectnum].ceilingz)>>8); + printext16(8,ydim-STATUS2DSIZ+104,11,-1,snotbuf,0); + + printext16(200,ydim-STATUS2DSIZ+32,11,-1,"CEILINGS:",0); + Bsprintf(snotbuf,"Flags (hex): %x",sector[sectnum].ceilingstat); + printext16(200,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); + Bsprintf(snotbuf,"(X,Y)pan: %d, %d",sector[sectnum].ceilingxpanning,sector[sectnum].ceilingypanning); + printext16(200,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Shade byte: %d",sector[sectnum].ceilingshade); + printext16(200,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Z-coordinate: %ld",sector[sectnum].ceilingz); + printext16(200,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Tile number: %d",sector[sectnum].ceilingpicnum); + printext16(200,ydim-STATUS2DSIZ+80,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Ceiling heinum: %d",sector[sectnum].ceilingheinum); + printext16(200,ydim-STATUS2DSIZ+88,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Palookup number: %d",sector[sectnum].ceilingpal); + printext16(200,ydim-STATUS2DSIZ+96,11,-1,snotbuf,0); + + printext16(400,ydim-STATUS2DSIZ+32,11,-1,"FLOORS:",0); + Bsprintf(snotbuf,"Flags (hex): %x",sector[sectnum].floorstat); + printext16(400,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); + Bsprintf(snotbuf,"(X,Y)pan: %d, %d",sector[sectnum].floorxpanning,sector[sectnum].floorypanning); + printext16(400,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Shade byte: %d",sector[sectnum].floorshade); + printext16(400,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Z-coordinate: %ld",sector[sectnum].floorz); + printext16(400,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Tile number: %d",sector[sectnum].floorpicnum); + printext16(400,ydim-STATUS2DSIZ+80,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Floor heinum: %d",sector[sectnum].floorheinum); + printext16(400,ydim-STATUS2DSIZ+88,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Palookup number: %d",sector[sectnum].floorpal); + printext16(400,ydim-STATUS2DSIZ+96,11,-1,snotbuf,0); +} + +void showwalldata(short wallnum) +{ + long dax, day, dist; + char snotbuf[80]; + + Bsprintf(snotbuf,"Wall %d",wallnum); + printext16(8,ydim-STATUS2DSIZ+32,11,-1,snotbuf,0); + Bsprintf(snotbuf,"X-coordinate: %ld",wall[wallnum].x); + printext16(8,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Y-coordinate: %ld",wall[wallnum].y); + printext16(8,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Point2: %d",wall[wallnum].point2); + printext16(8,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Sector: %ld",sectorofwall(wallnum)); + printext16(8,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); + + Bsprintf(snotbuf,"Tags: %d, %d",wall[wallnum].hitag,wall[wallnum].lotag); + printext16(8,ydim-STATUS2DSIZ+88,11,-1,snotbuf,0); + Bsprintf(snotbuf," (0x%x), (0x%x)",wall[wallnum].hitag,wall[wallnum].lotag); + printext16(8,ydim-STATUS2DSIZ+96,11,-1,snotbuf,0); + + printext16(200,ydim-STATUS2DSIZ+32,11,-1,names[wall[wallnum].picnum],0); + Bsprintf(snotbuf,"Flags (hex): %x",wall[wallnum].cstat); + printext16(200,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Shade: %d",wall[wallnum].shade); + printext16(200,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Pal: %d",wall[wallnum].pal); + printext16(200,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); + Bsprintf(snotbuf,"(X,Y)repeat: %d, %d",wall[wallnum].xrepeat,wall[wallnum].yrepeat); + printext16(200,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); + Bsprintf(snotbuf,"(X,Y)pan: %d, %d",wall[wallnum].xpanning,wall[wallnum].ypanning); + printext16(200,ydim-STATUS2DSIZ+80,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Tile number: %d",wall[wallnum].picnum); + printext16(200,ydim-STATUS2DSIZ+88,11,-1,snotbuf,0); + Bsprintf(snotbuf,"OverTile number: %d",wall[wallnum].overpicnum); + printext16(200,ydim-STATUS2DSIZ+96,11,-1,snotbuf,0); + + Bsprintf(snotbuf,"nextsector: %d",wall[wallnum].nextsector); + printext16(400,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); + Bsprintf(snotbuf,"nextwall: %d",wall[wallnum].nextwall); + printext16(400,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); + + Bsprintf(snotbuf,"Extra: %d",wall[wallnum].extra); + printext16(400,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); + + dax = wall[wallnum].x-wall[wall[wallnum].point2].x; + day = wall[wallnum].y-wall[wall[wallnum].point2].y; + dist = ksqrt(dax*dax+day*day); + +// TX 20050102 I'm not sure what unit dist<<4 is supposed to be, but dist itself is correct in terms of game coordinates as one would expect + + Bsprintf(snotbuf,"Wall length: %ld",dist); + printext16(400,ydim-STATUS2DSIZ+96,11,-1,snotbuf,0); + + dax = (long)sectorofwall(wallnum); + Bsprintf(snotbuf,"Pixel height: %ld",(sector[dax].floorz-sector[dax].ceilingz)>>8); + printext16(400,ydim-STATUS2DSIZ+104,11,-1,snotbuf,0); +} + +void showspritedata(short spritenum) +{ + char snotbuf[80]; + + Bsprintf(snotbuf,"Sprite %d",spritenum); + printext16(8,ydim-STATUS2DSIZ+32,11,-1,snotbuf,0); + Bsprintf(snotbuf,"X-coordinate: %ld",sprite[spritenum].x); + printext16(8,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Y-coordinate: %ld",sprite[spritenum].y); + printext16(8,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Z-coordinate: %ld",sprite[spritenum].z); + printext16(8,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); + + Bsprintf(snotbuf,"Sectnum: %d",sprite[spritenum].sectnum); + printext16(8,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Statnum: %d",sprite[spritenum].statnum); + printext16(8,ydim-STATUS2DSIZ+80,11,-1,snotbuf,0); + + Bsprintf(snotbuf,"Tags: %d, %d",sprite[spritenum].hitag,sprite[spritenum].lotag); + printext16(8,ydim-STATUS2DSIZ+96,11,-1,snotbuf,0); + Bsprintf(snotbuf," (0x%x), (0x%x)",sprite[spritenum].hitag,sprite[spritenum].lotag); + printext16(8,ydim-STATUS2DSIZ+104,11,-1,snotbuf,0); + + printext16(200,ydim-STATUS2DSIZ+32,11,-1,names[sprite[spritenum].picnum],0); + Bsprintf(snotbuf,"Flags (hex): %x",sprite[spritenum].cstat); + printext16(200,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Shade: %d",sprite[spritenum].shade); + printext16(200,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Pal: %d",sprite[spritenum].pal); + printext16(200,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); + Bsprintf(snotbuf,"(X,Y)repeat: %d, %d",sprite[spritenum].xrepeat,sprite[spritenum].yrepeat); + printext16(200,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); + Bsprintf(snotbuf,"(X,Y)offset: %d, %d",sprite[spritenum].xoffset,sprite[spritenum].yoffset); + printext16(200,ydim-STATUS2DSIZ+80,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Tile number: %d",sprite[spritenum].picnum); + printext16(200,ydim-STATUS2DSIZ+88,11,-1,snotbuf,0); + + Bsprintf(snotbuf,"Angle (2048 degrees): %d",sprite[spritenum].ang); + printext16(400,ydim-STATUS2DSIZ+48,11,-1,snotbuf,0); + Bsprintf(snotbuf,"X-Velocity: %d",sprite[spritenum].xvel); + printext16(400,ydim-STATUS2DSIZ+56,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Y-Velocity: %d",sprite[spritenum].yvel); + printext16(400,ydim-STATUS2DSIZ+64,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Z-Velocity: %d",sprite[spritenum].zvel); + printext16(400,ydim-STATUS2DSIZ+72,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Owner: %d",sprite[spritenum].owner); + printext16(400,ydim-STATUS2DSIZ+80,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Clipdist: %d",sprite[spritenum].clipdist); + printext16(400,ydim-STATUS2DSIZ+88,11,-1,snotbuf,0); + Bsprintf(snotbuf,"Extra: %d",sprite[spritenum].extra); + printext16(400,ydim-STATUS2DSIZ+96,11,-1,snotbuf,0); +} + +void keytimerstuff(void) +{ + static long ltotalclock=0; + int i; + if (totalclock == ltotalclock) return; + ltotalclock=totalclock; + + if (keystatus[buildkeys[5]] == 0) + { + if (keystatus[buildkeys[2]] > 0) angvel = max(angvel-16,-128); + if (keystatus[buildkeys[3]] > 0) angvel = min(angvel+16,127); + } + else + { + if (keystatus[buildkeys[2]] > 0) svel = min(svel+8,127); + if (keystatus[buildkeys[3]] > 0) svel = max(svel-8,-128); + } + if (keystatus[buildkeys[0]] > 0) vel = min(vel+8,127); + if (keystatus[buildkeys[1]] > 0) vel = max(vel-8,-128); +/* if (keystatus[buildkeys[12]] > 0) svel = min(svel+8,127); + if (keystatus[buildkeys[13]] > 0) svel = max(svel-8,-128); */ + + if (angvel < 0) angvel = min(angvel+12,0); + if (angvel > 0) angvel = max(angvel-12,0); + if (svel < 0) svel = min(svel+2,0); + if (svel > 0) svel = max(svel-2,0); + if (vel < 0) vel = min(vel+2,0); + if (vel > 0) vel = max(vel-2,0); + if(mlook) + posz -= (horiz-101)*(vel/40); +} + +void _printmessage16(char name[82]) +{ + char snotbuf[60]; + long i; + + i = 0; + while ((name[i] != 0) && (i < 54)) + { + snotbuf[i] = name[i]; + i++; + } + while (i < 54) + { + snotbuf[i] = 32; + i++; + } + snotbuf[54] = 0; + begindrawing(); + printext16(200L, ydim-STATUS2DSIZ+8L, 9, 0, snotbuf, 0); + enddrawing(); +} + +void printmessage16(char name[82]) +{ + _printmessage16(name); + lastpm16time = totalclock; +} + + +void printmessage256(char name[82]) +{ + char snotbuf[40]; + long i; + + i = 0; + while ((name[i] != 0) && (i < 38)) + { + snotbuf[i] = name[i]; + i++; + } + while (i < 38) + { + snotbuf[i] = 32; + i++; + } + snotbuf[38] = 0; + printext256(2L,2L,0,-1,snotbuf,0); + printext256(0L,0L,whitecol,-1,snotbuf,0); +} + + //Find closest point (*dax, *day) on wall (dawall) to (x, y) +void getclosestpointonwall(long x, long y, long dawall, long *nx, long *ny) +{ + walltype *wal; + long i, j, dx, dy; + + wal = &wall[dawall]; + dx = wall[wal->point2].x-wal->x; + dy = wall[wal->point2].y-wal->y; + i = dx*(x-wal->x) + dy*(y-wal->y); + if (i <= 0) { *nx = wal->x; *ny = wal->y; return; } + j = dx*dx+dy*dy; + if (i >= j) { *nx = wal->x+dx; *ny = wal->y+dy; return; } + i = divscale30(i,j); + *nx = wal->x + mulscale30(dx,i); + *ny = wal->y + mulscale30(dy,i); +} + +void initcrc(void) +{ + long i, j, k, a; + + for(j=0;j<256;j++) //Calculate CRC table + { + k = (j<<8); a = 0; + for(i=7;i>=0;i--) + { + if (((k^a)&0x8000) > 0) + a = ((a<<1)&65535) ^ 0x1021; //0x1021 = genpoly + else + a = ((a<<1)&65535); + k = ((k<<1)&65535); + } + crctable[j] = (a&65535); + } +} + +static char visited[MAXWALLS]; + +long GetWallZPeg(long nWall) +{ + long z=0, nSector, nNextSector; + + nSector = sectorofwall((short)nWall); + nNextSector = wall[nWall].nextsector; + if (nNextSector == -1) + { + //1-sided wall + if (wall[nWall].cstat&4) z = sector[nSector].floorz; + else z = sector[nSector].ceilingz; + } + else + { + //2-sided wall + if (wall[nWall].cstat&4) + z = sector[nSector].ceilingz; + else + { + if (sector[nNextSector].ceilingz > sector[nSector].ceilingz) + z = sector[nNextSector].ceilingz; //top step + if (sector[nNextSector].floorz < sector[nSector].floorz) + z = sector[nNextSector].floorz; //bottom step + } + } + return(z); +} + +void AlignWalls(long nWall0, long z0, long nWall1, long z1, long nTile) +{ + long n; + + //do the x alignment + wall[nWall1].cstat &= ~0x0108; //Set to non-flip + wall[nWall1].xpanning = (char)((wall[nWall0].xpanning+(wall[nWall0].xrepeat<<3))%tilesizx[nTile]); + + z1 = GetWallZPeg(nWall1); + + for(n=(picsiz[nTile]>>4);((1<>(n+3))); +} + +void AutoAlignWalls(long nWall0, long ply) +{ + long z0, z1, nTile, nWall1, branch, visible, nNextSector, nSector; + + nTile = wall[nWall0].picnum; + branch = 0; + if (ply == 0) + { + //clear visited bits + memset(visited,0,sizeof(visited)); + visited[nWall0] = 1; + } + + z0 = GetWallZPeg(nWall0); + + nWall1 = wall[nWall0].point2; + + //loop through walls at this vertex in CCW order + while (1) + { + //break if this wall would connect us in a loop + if (visited[nWall1]) break; + + visited[nWall1] = 1; + + //break if reached back of left wall + if (wall[nWall1].nextwall == nWall0) break; + + if (wall[nWall1].picnum == nTile) + { + z1 = GetWallZPeg(nWall1); + visible = 0; + + nNextSector = wall[nWall1].nextsector; + if (nNextSector < 0) + visible = 1; + else + { + //ignore two sided walls that have no visible face + nSector = wall[wall[nWall1].nextwall].nextsector; + if (getceilzofslope((short)nSector,wall[nWall1].x,wall[nWall1].y) < + getceilzofslope((short)nNextSector,wall[nWall1].x,wall[nWall1].y)) + visible = 1; + + if (getflorzofslope((short)nSector,wall[nWall1].x,wall[nWall1].y) > + getflorzofslope((short)nNextSector,wall[nWall1].x,wall[nWall1].y)) + visible = 1; + } + + if (visible) + { + branch++; + AlignWalls(nWall0,z0,nWall1,z1,nTile); + + //if wall was 1-sided, no need to recurse + if (wall[nWall1].nextwall < 0) + { + nWall0 = nWall1; + z0 = GetWallZPeg(nWall0); + nWall1 = wall[nWall0].point2; + branch = 0; + continue; + } + else + AutoAlignWalls(nWall1,ply+1); + } + } + + if (wall[nWall1].nextwall < 0) break; + nWall1 = wall[wall[nWall1].nextwall].point2; + } +} + + +/* + * vim:ts=4: + */ + diff --git a/polymer/build/src/buildstartwin.c b/polymer/build/src/buildstartwin.c new file mode 100644 index 000000000..3df25c7b6 --- /dev/null +++ b/polymer/build/src/buildstartwin.c @@ -0,0 +1,178 @@ +#ifndef RENDERTYPEWIN +#error Only for Windows +#endif + +#include "build.h" +#include "editor.h" +#include "winlayer.h" +#include "compat.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include + + +#define IDCFULLSCREEN 100 +#define IDC2DVMODE 101 +#define IDC3DVMODE 102 + +static void PopulateVideoModeLists(int fs, HWND list2d, HWND list3d) +{ + int i,j; + char buf[64]; + + ComboBox_ResetContent(list2d); + ComboBox_ResetContent(list3d); + for (i=0; i 0) { + if (!IsWindow(hwndLaunch) || quitevent) break; + if (IsDialogMessage(hwndStart, &msg) /*|| IsDialogMessage(hwndLaunch, &msg)*/) continue; + + TranslateMessage(&msg); + DispatchMessage(&msg); + } +#else + while (IsWindow(hwndLaunch) && !quitevent) { + x = win_getstartupcommand(); + if (x != 0) LaunchWindowProc(hwndLaunch, WM_COMMAND, x, 0); + handleevents(); + } +#endif + EnableWindow(GetDlgItem(hwndStart,WIN_STARTWIN_ITEMLIST),TRUE); + } + if (quitevent) return 1; + return 0; +} + diff --git a/polymer/build/src/cache1d.c b/polymer/build/src/cache1d.c new file mode 100644 index 000000000..abe2902c2 --- /dev/null +++ b/polymer/build/src/cache1d.c @@ -0,0 +1,1301 @@ +// "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) + +#define WITHKPLIB + +#include "compat.h" +#include "cache1d.h" +#include "pragmas.h" +#include "baselayer.h" + +#ifdef WITHKPLIB +#include "kplib.h" + + //Insert '|' in front of filename + //Doing this tells kzopen to load the file only if inside a .ZIP file +static long kzipopen(char *filnam) +{ + unsigned int i; + char newst[BMAX_PATH+4]; + + newst[0] = '|'; + for(i=0;filnam[i] && (i < sizeof(newst)-2);i++) newst[i+1] = filnam[i]; + newst[i+1] = 0; + return(kzopen(newst)); +} + +#endif + + +// This module keeps track of a standard linear cacheing system. +// To use this module, here's all you need to do: +// +// Step 1: Allocate a nice BIG buffer, like from 1MB-4MB and +// Call initcache(long cachestart, long cachesize) where +// +// cachestart = (long)(pointer to start of BIG buffer) +// cachesize = length of BIG buffer +// +// Step 2: Call allocache(long *bufptr, long bufsiz, char *lockptr) +// whenever you need to allocate a buffer, where: +// +// *bufptr = pointer to 4-byte pointer to buffer +// Confused? Using this method, cache2d can remove +// previously allocated things from the cache safely by +// setting the 4-byte pointer to 0. +// bufsiz = number of bytes to allocate +// *lockptr = pointer to locking char which tells whether +// the region can be removed or not. If *lockptr = 0 then +// the region is not locked else its locked. +// +// Step 3: If you need to remove everything from the cache, or every +// unlocked item from the cache, you can call uninitcache(); +// Call uninitcache(0) to remove all unlocked items, or +// Call uninitcache(1) to remove everything. +// After calling uninitcache, it is still ok to call allocache +// without first calling initcache. + +#define MAXCACHEOBJECTS 9216 + +static long cachesize = 0; +long cachecount = 0; +char zerochar = 0; +long cachestart = 0, cacnum = 0, agecount = 0; +typedef struct { long *hand, leng; char *lock; } cactype; +cactype cac[MAXCACHEOBJECTS]; +static long lockrecip[200]; + +static char toupperlookup[256]; + +extern void *kmalloc(size_t); +extern void kfree(void *); + +static void reportandexit(char *errormessage); + +extern char pow2char[8]; + + +void initcache(long dacachestart, long dacachesize) +{ + long i; + + for(i=1;i<200;i++) lockrecip[i] = (1<<28)/(200-i); + + cachestart = dacachestart; + cachesize = dacachesize; + + cac[0].leng = cachesize; + cac[0].lock = &zerochar; + cacnum = 1; + + initprintf("initcache(): Initialised with %d bytes\n", dacachesize); +} + +void allocache(long *newhandle, long newbytes, char *newlockptr) +{ + long i, /*j,*/ z, zz, bestz=0, daval, bestval, besto=0, o1, o2, sucklen, suckz; + + newbytes = ((newbytes+15)&0xfffffff0); + + if ((unsigned)newbytes > (unsigned)cachesize) + { + Bprintf("Cachesize: %ld\n",cachesize); + Bprintf("*Newhandle: 0x%lx, Newbytes: %ld, *Newlock: %d\n",(long)newhandle,newbytes,*newlockptr); + reportandexit("BUFFER TOO BIG TO FIT IN CACHE!"); + } + + if (*newlockptr == 0) + { + reportandexit("ALLOCACHE CALLED WITH LOCK OF 0!"); + } + + //Find best place + bestval = 0x7fffffff; o1 = cachesize; + for(z=cacnum-1;z>=0;z--) + { + o1 -= cac[z].leng; + o2 = o1+newbytes; if (o2 > cachesize) continue; + + daval = 0; + for(i=o1,zz=z;i= 200) { daval = 0x7fffffff; break; } + daval += mulscale32(cac[zz].leng+65536,lockrecip[*cac[zz].lock]); + if (daval >= bestval) break; + } + if (daval < bestval) + { + bestval = daval; besto = o1; bestz = z; + if (bestval == 0) break; + } + } + + //printf("%ld %ld %ld\n",besto,newbytes,*newlockptr); + + if (bestval == 0x7fffffff) + reportandexit("CACHE SPACE ALL LOCKED UP!"); + + //Suck things out + for(sucklen=-newbytes,suckz=bestz;sucklen<0;sucklen+=cac[suckz++].leng) + if (*cac[suckz].lock) *cac[suckz].hand = 0; + + //Remove all blocks except 1 + suckz -= (bestz+1); cacnum -= suckz; + copybufbyte(&cac[bestz+suckz],&cac[bestz],(cacnum-bestz)*sizeof(cactype)); + cac[bestz].hand = newhandle; *newhandle = cachestart+besto; + cac[bestz].leng = newbytes; + cac[bestz].lock = newlockptr; + cachecount++; + + //Add new empty block if necessary + if (sucklen <= 0) return; + + bestz++; + if (bestz == cacnum) + { + cacnum++; if (cacnum > MAXCACHEOBJECTS) reportandexit("Too many objects in cache! (cacnum > MAXCACHEOBJECTS)"); + cac[bestz].leng = sucklen; + cac[bestz].lock = &zerochar; + return; + } + + if (*cac[bestz].lock == 0) { cac[bestz].leng += sucklen; return; } + + cacnum++; if (cacnum > MAXCACHEOBJECTS) reportandexit("Too many objects in cache! (cacnum > MAXCACHEOBJECTS)"); + for(z=cacnum-1;z>bestz;z--) cac[z] = cac[z-1]; + cac[bestz].leng = sucklen; + cac[bestz].lock = &zerochar; +} + +void suckcache(long *suckptr) +{ + long i; + + //Can't exit early, because invalid pointer might be same even though lock = 0 + for(i=0;i 0) && (*cac[i-1].lock == 0)) + { + cac[i-1].leng += cac[i].leng; + cacnum--; copybuf(&cac[i+1],&cac[i],(cacnum-i)*sizeof(cactype)); + } + else if ((i < cacnum-1) && (*cac[i+1].lock == 0)) + { + cac[i+1].leng += cac[i].leng; + cacnum--; copybuf(&cac[i+1],&cac[i],(cacnum-i)*sizeof(cactype)); + } + } +} + +void agecache(void) +{ + long cnt; + char ch; + + if (agecount >= cacnum) agecount = cacnum-1; + if (agecount < 0) return; + for(cnt=(cacnum>>4);cnt>=0;cnt--) + { + ch = (*cac[agecount].lock); + if (((ch-2)&255) < 198) + (*cac[agecount].lock) = ch-1; + + agecount--; if (agecount < 0) agecount = cacnum-1; + } +} + +static void reportandexit(char *errormessage) +{ + long i, j; + + //setvmode(0x3); + j = 0; + for(i=0;i + +typedef struct _searchpath { + struct _searchpath *next; + char *path; + size_t pathlen; // to save repeated calls to strlen() +} searchpath_t; +static searchpath_t *searchpathhead = NULL; +static size_t maxsearchpathlen = 0; +int pathsearchmode = 0; + +int addsearchpath(const char *p) +{ + struct stat st; + char *s; + searchpath_t *srch; + int i; + + if (Bstat(p, &st) < 0) { + if (errno == ENOENT) return -2; + return -1; + } + if (!(st.st_mode & BS_IFDIR)) return -1; + + srch = (searchpath_t*)malloc(sizeof(searchpath_t)); + if (!srch) return -1; + + srch->next = searchpathhead; + srch->pathlen = strlen(p)+1; + srch->path = (char*)malloc(srch->pathlen + 1); + if (!srch->path) { + free(srch); + return -1; + } + strcpy(srch->path, p); + for (s=srch->path; *s; s++) ; s--; if (spath || toupperlookup[*s] != '/') strcat(srch->path, "/"); + + searchpathhead = srch; + if (srch->pathlen > maxsearchpathlen) maxsearchpathlen = srch->pathlen; + initprintf("addsearchpath(): Added %s\n", srch->path); + + return 0; +} + +int findfrompath(const char *fn, char **where) +{ + searchpath_t *sp; + char *pfn, *ffn; + int allocsiz; + + // pathsearchmode == 0: tests current dir and then the dirs of the path stack + // pathsearchmode == 1: tests fn without modification, then like for pathsearchmode == 0 + + if (pathsearchmode) { + // test unmolested filename first + if (access(fn, F_OK) >= 0) { + *where = strdup(fn); + return 0; + } + } + + for (pfn = (char*)fn; toupperlookup[*pfn] == '/'; pfn++); + ffn = strdup(pfn); + if (!ffn) return -1; + Bcorrectfilename(ffn,0); // compress relative paths + + allocsiz = max(maxsearchpathlen, 2); // "./" (aka. curdir) + allocsiz += strlen(ffn); + allocsiz += 1; // a nul + + pfn = (char *)malloc(allocsiz); + if (!pfn) { free(ffn); return -1; } + + strcpy(pfn, "./"); + strcat(pfn, ffn); + if (access(pfn, F_OK) >= 0) { + *where = pfn; + free(ffn); + return 0; + } + + for (sp = searchpathhead; sp; sp = sp->next) { + strcpy(pfn, sp->path); + strcat(pfn, ffn); + //initprintf("Trying %s\n", pfn); + if (access(pfn, F_OK) >= 0) { + *where = pfn; + free(ffn); + return 0; + } + } + free(pfn); free(ffn); + return -1; +} + +int openfrompath(const char *fn, int flags, int mode) +{ + char *pfn; + int h; + + if (findfrompath(fn, &pfn) < 0) return -1; + h = Bopen(pfn, flags, mode); + free(pfn); + + return h; +} + +BFILE* fopenfrompath(const char *fn, const char *mode) +{ + int fh; + BFILE *h; + int bmode = 0, smode = 0; + const char *c; + + for (c=mode; c[0]; ) { + if (c[0] == 'r' && c[1] == '+') { bmode = BO_RDWR; smode = BS_IREAD|BS_IWRITE; c+=2; } + else if (c[0] == 'r') { bmode = BO_RDONLY; smode = BS_IREAD; c+=1; } + else if (c[0] == 'w' && c[1] == '+') { bmode = BO_RDWR|BO_CREAT|BO_TRUNC; smode = BS_IREAD|BS_IWRITE; c+=2; } + else if (c[0] == 'w') { bmode = BO_WRONLY|BO_CREAT|BO_TRUNC; smode = BS_IREAD|BS_IWRITE; c+=2; } + else if (c[0] == 'a' && c[1] == '+') { bmode = BO_RDWR|BO_CREAT; smode=BS_IREAD|BS_IWRITE; c+=2; } + else if (c[0] == 'a') { bmode = BO_WRONLY|BO_CREAT; smode=BS_IREAD|BS_IWRITE; c+=1; } + else if (c[0] == 'b') { bmode |= BO_BINARY; c+=1; } + else if (c[1] == 't') { bmode |= BO_TEXT; c+=1; } + else c++; + } + fh = openfrompath(fn,bmode,smode); + if (fh < 0) return NULL; + + h = fdopen(fh,mode); + if (!h) close(fh); + + return h; +} + + +#define MAXGROUPFILES 4 //Warning: Fix groupfil if this is changed +#define MAXOPENFILES 64 //Warning: Fix filehan if this is changed + +static char toupperlookup[256] = +{ + 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, + 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, + 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, + 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, + 0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, + 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x7b,0x7c,0x7d,0x7e,0x7f, + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, + 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, + 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, + 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf, + 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf, + 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef, + 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff +}; + +static long numgroupfiles = 0; +static long gnumfiles[MAXGROUPFILES]; +static long groupfil[MAXGROUPFILES] = {-1,-1,-1,-1}; +static long groupfilpos[MAXGROUPFILES]; +static char *gfilelist[MAXGROUPFILES]; +static long *gfileoffs[MAXGROUPFILES]; + +static char filegrp[MAXOPENFILES]; +static long filepos[MAXOPENFILES]; +static long filehan[MAXOPENFILES] = +{ + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 +}; +#ifdef WITHKPLIB +static char filenamsav[MAXOPENFILES][260]; +static long kzcurhand = -1; +#endif + +long initgroupfile(char *filename) +{ + char buf[16]; + long i, j, k; +#ifdef WITHKPLIB + char *zfn; + searchpath_t *sp = NULL; +#endif + +#ifdef _WIN32 + // on Windows, translate all backslashes (0x5c) to forward slashes (0x2f) + toupperlookup[0x5c] = 0x2f; +#endif + +#ifdef WITHKPLIB + if (findfrompath(filename, &zfn) < 0) return -1; + + // check to see if the file passed is a ZIP and pass it on to kplib if it is + i = Bopen(zfn,BO_BINARY|BO_RDONLY,BS_IREAD); + if (i < 0) { free(zfn); return -1; } + + Bread(i, buf, 4); + if (buf[0] == 0x50 && buf[1] == 0x4B && buf[2] == 0x03 && buf[3] == 0x04) { + Bclose(i); + j = kzaddstack(zfn); + free(zfn); + return j; + } + free(zfn); + + if (numgroupfiles >= MAXGROUPFILES) return(-1); + + Blseek(i,0,BSEEK_SET); + groupfil[numgroupfiles] = i; +#else + groupfil[numgroupfiles] = openfrompath(filename,BO_BINARY|BO_RDONLY,BS_IREAD); + if (groupfil[numgroupfiles] != -1) +#endif + { + groupfilpos[numgroupfiles] = 0; + Bread(groupfil[numgroupfiles],buf,16); + if ((buf[0] != 'K') || (buf[1] != 'e') || (buf[2] != 'n') || + (buf[3] != 'S') || (buf[4] != 'i') || (buf[5] != 'l') || + (buf[6] != 'v') || (buf[7] != 'e') || (buf[8] != 'r') || + (buf[9] != 'm') || (buf[10] != 'a') || (buf[11] != 'n')) + { + Bclose(groupfil[numgroupfiles]); + groupfil[numgroupfiles] = -1; + return(-1); + } + gnumfiles[numgroupfiles] = B_LITTLE32(*((long *)&buf[12])); + + if ((gfilelist[numgroupfiles] = (char *)kmalloc(gnumfiles[numgroupfiles]<<4)) == 0) + { Bprintf("Not enough memory for file grouping system\n"); exit(0); } + if ((gfileoffs[numgroupfiles] = (long *)kmalloc((gnumfiles[numgroupfiles]+1)<<2)) == 0) + { Bprintf("Not enough memory for file grouping system\n"); exit(0); } + + Bread(groupfil[numgroupfiles],gfilelist[numgroupfiles],gnumfiles[numgroupfiles]<<4); + + j = 0; + for(i=0;i=0;i--) + if (groupfil[i] != -1 && groupfil[i] == grphandle) + { + kfree(gfilelist[i]); + kfree(gfileoffs[i]); + Bclose(groupfil[i]); + groupfil[i] = -1; + grpnum = i; + break; + } + + if (grpnum == -1) return; + + // JBF 20040111 + numgroupfiles--; + + // move any group files following this one back + for (i=grpnum+1; i= 254) // external file (255) or ZIPped file (254) + continue; + else if (filegrp[i] == grpnum) // close file in group we closed + filehan[i] = -1; + else if (filegrp[i] > grpnum) // move back a file in a group after the one we closed + filegrp[i]--; + } +} + +void uninitgroupfile(void) +{ + long i; + + for(i=numgroupfiles-1;i>=0;i--) + if (groupfil[i] != -1) + { + kfree(gfilelist[i]); + kfree(gfileoffs[i]); + Bclose(groupfil[i]); + groupfil[i] = -1; + } + numgroupfiles = 0; + + // JBF 20040111: "close" any files open in groups + for(i=0;i= 0) + { + filegrp[newhandle] = 255; + filehan[newhandle] = fil; + filepos[newhandle] = 0; + return(newhandle); + } + + for (; toupperlookup[*filename] == '/'; filename++); + +#ifdef WITHKPLIB + if ((kzcurhand != newhandle) && (kztell() >= 0)) + { + if (kzcurhand >= 0) filepos[kzcurhand] = kztell(); + kzclose(); + } + if (searchfirst != 1 && (i = kzipopen(filename)) != 0) { + kzcurhand = newhandle; + filegrp[newhandle] = 254; + filehan[newhandle] = i; + filepos[newhandle] = 0; + strcpy(filenamsav[newhandle],filename); + return newhandle; + } +#endif + + for(k=numgroupfiles-1;k>=0;k--) + { + if (searchfirst == 1) k = 0; + if (groupfil[k] >= 0) + { + for(i=gnumfiles[k]-1;i>=0;i--) + { + gfileptr = (char *)&gfilelist[k][i<<4]; + + bad = 0; + for(j=0;j<13;j++) + { + if (!filename[j]) break; + if (toupperlookup[filename[j]] != toupperlookup[gfileptr[j]]) + { bad = 1; break; } + } + if (bad) continue; + if (j<13 && gfileptr[j]) continue; // JBF: because e1l1.map might exist before e1l1 + if (j==13 && filename[j]) continue; // JBF: long file name + + filegrp[newhandle] = k; + filehan[newhandle] = i; + filepos[newhandle] = 0; + return(newhandle); + } + } + } + return(-1); +} + +long kread(long handle, void *buffer, long leng) +{ + long i, filenum, groupnum; + + filenum = filehan[handle]; + groupnum = filegrp[handle]; + if (groupnum == 255) return(Bread(filenum,buffer,leng)); +#ifdef WITHKPLIB + else if (groupnum == 254) + { + if (kzcurhand != handle) + { + if (kztell() >= 0) { filepos[kzcurhand] = kztell(); kzclose(); } + kzcurhand = handle; + kzipopen(filenamsav[handle]); + kzseek(filepos[handle],SEEK_SET); + } + return(kzread(buffer,leng)); + } +#endif + + if (groupfil[groupnum] != -1) + { + i = gfileoffs[groupnum][filenum]+filepos[handle]; + if (i != groupfilpos[groupnum]) + { + Blseek(groupfil[groupnum],i+((gnumfiles[groupnum]+1)<<4),BSEEK_SET); + groupfilpos[groupnum] = i; + } + leng = min(leng,(gfileoffs[groupnum][filenum+1]-gfileoffs[groupnum][filenum])-filepos[handle]); + leng = Bread(groupfil[groupnum],buffer,leng); + filepos[handle] += leng; + groupfilpos[groupnum] += leng; + return(leng); + } + + return(0); +} + +long klseek(long handle, long offset, long whence) +{ + long i, groupnum; + + groupnum = filegrp[handle]; + + if (groupnum == 255) return(Blseek(filehan[handle],offset,whence)); +#ifdef WITHKPLIB + else if (groupnum == 254) + { + if (kzcurhand != handle) + { + if (kztell() >= 0) { filepos[kzcurhand] = kztell(); kzclose(); } + kzcurhand = handle; + kzipopen(filenamsav[handle]); + kzseek(filepos[handle],SEEK_SET); + } + return(kzseek(offset,whence)); + } +#endif + + if (groupfil[groupnum] != -1) + { + switch(whence) + { + case BSEEK_SET: filepos[handle] = offset; break; + case BSEEK_END: i = filehan[handle]; + filepos[handle] = (gfileoffs[groupnum][i+1]-gfileoffs[groupnum][i])+offset; + break; + case BSEEK_CUR: filepos[handle] += offset; break; + } + return(filepos[handle]); + } + return(-1); +} + +long kfilelength(long handle) +{ + long i, groupnum; + + groupnum = filegrp[handle]; + if (groupnum == 255) { + // return(filelength(filehan[handle])) + return Bfilelength(filehan[handle]); + } +#ifdef WITHKPLIB + else if (groupnum == 254) + { + if (kzcurhand != handle) + { + if (kztell() >= 0) { filepos[kzcurhand] = kztell(); kzclose(); } + kzcurhand = handle; + kzipopen(filenamsav[handle]); + kzseek(filepos[handle],SEEK_SET); + } + return kzfilelength(); + } +#endif + i = filehan[handle]; + return(gfileoffs[groupnum][i+1]-gfileoffs[groupnum][i]); +} + +long ktell(long handle) +{ + long i, groupnum; + + groupnum = filegrp[handle]; + + if (groupnum == 255) return(Blseek(filehan[handle],0,BSEEK_CUR)); +#ifdef WITHKPLIB + else if (groupnum == 254) + { + if (kzcurhand != handle) + { + if (kztell() >= 0) { filepos[kzcurhand] = kztell(); kzclose(); } + kzcurhand = handle; + kzipopen(filenamsav[handle]); + kzseek(filepos[handle],SEEK_SET); + } + return kztell(); + } +#endif + if (groupfil[groupnum] != -1) + return filepos[handle]; + return(-1); +} + +void kclose(long handle) +{ + if (handle < 0) return; + if (filegrp[handle] == 255) Bclose(filehan[handle]); +#ifdef WITHKPLIB + else if (filegrp[handle] == 254) + { + kzclose(); + kzcurhand = -1; + } +#endif + filehan[handle] = -1; +} + +static int klistaddentry(CACHE1D_FIND_REC **rec, char *name, int type, int source) +{ + CACHE1D_FIND_REC *r = NULL, *attach = NULL; + + if (*rec) { + int insensitive, v; + CACHE1D_FIND_REC *last = NULL; + + for (attach = *rec; attach; last = attach, attach = attach->next) { + if (type == CACHE1D_FIND_DRIVE) continue; // we just want to get to the end for drives +#ifdef _WIN32 + insensitive = 1; +#else + if (source == CACHE1D_SOURCE_GRP || attach->source == CACHE1D_SOURCE_GRP) + insensitive = 1; + else if (source == CACHE1D_SOURCE_ZIP || attach->source == CACHE1D_SOURCE_ZIP) + insensitive = 1; + else + insensitive = 0; +#endif + if (insensitive) v = Bstrcasecmp(name, attach->name); + else v = Bstrcmp(name, attach->name); + + // sorted list + if (v > 0) continue; // item to add is bigger than the current one + // so look for something bigger than us + if (v < 0) { // item to add is smaller than the current one + attach = NULL; // so wedge it between the current item and the one before + break; + } + + // matched + if (source >= attach->source) return 1; // item to add is of lower priority + r = attach; + break; + } + + // wasn't found in the list, so attach to the end + if (!attach) attach = last; + } + + if (r) { + r->type = type; + r->source = source; + return 0; + } + + r = (CACHE1D_FIND_REC *)malloc(sizeof(CACHE1D_FIND_REC)+strlen(name)+1); + if (!r) return -1; + r->name = (char*)r + sizeof(CACHE1D_FIND_REC); strcpy(r->name, name); + r->type = type; + r->source = source; + r->usera = r->userb = NULL; + + if (!attach) { // we are the first item + r->prev = NULL; + r->next = *rec; + if (*rec) (*rec)->prev = r; + *rec = r; + } else { + r->prev = attach; + r->next = attach->next; + if (attach->next) attach->next->prev = r; + attach->next = r; + } + + return 0; +} + +void klistfree(CACHE1D_FIND_REC *rec) +{ + CACHE1D_FIND_REC *n; + + while (rec) { + n = rec->next; + free(rec); + rec = n; + } +} + +CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int type) +{ + CACHE1D_FIND_REC *rec = NULL; + char *path; + + // pathsearchmode == 0: enumerates a path in the virtual filesystem + // pathsearchmode == 1: enumerates the system filesystem path passed in + + path = strdup(_path); + if (!path) return NULL; + + // we don't need any leading dots and slashes or trailing slashes either + { + int i,j; + for (i=0; path[i] == '.' || toupperlookup[path[i]] == '/'; ) i++; + for (j=0; path[j] = path[i]; j++,i++) ; + while (j>0 && toupperlookup[path[j-1]] == '/') j--; + path[j] = 0; + //initprintf("Cleaned up path = \"%s\"\n",path); + } + + if (*path && (type & CACHE1D_FIND_DIR)) { + if (klistaddentry(&rec, "..", CACHE1D_FIND_DIR, CACHE1D_SOURCE_CURDIR) < 0) goto failure; + } + + if (!(type & CACHE1D_OPT_NOSTACK)) { // current directory and paths in the search stack + searchpath_t *search = NULL; + BDIR *dir; + struct Bdirent *dirent; + const char *d = "."; + int stackdepth = CACHE1D_SOURCE_CURDIR; + char buf[BMAX_PATH]; + + if (pathsearchmode) d = _path; + + do { + if (!pathsearchmode) { + strcpy(buf, path); + if (*path) strcat(buf, "/"); + strcat(buf, d); + } else strcpy(buf, d); + dir = Bopendir(buf); + if (dir) { + while ((dirent = Breaddir(dir))) { + if ((dirent->name[0] == '.' && dirent->name[1] == 0) || + (dirent->name[0] == '.' && dirent->name[1] == '.' && dirent->name[2] == 0)) + continue; + if ((type & CACHE1D_FIND_DIR) && !(dirent->mode & BS_IFDIR)) continue; + if ((type & CACHE1D_FIND_FILE) && (dirent->mode & BS_IFDIR)) continue; + if (!Bwildmatch(dirent->name, mask)) continue; + switch (klistaddentry(&rec, dirent->name, + (dirent->mode & BS_IFDIR) ? CACHE1D_FIND_DIR : CACHE1D_FIND_FILE, + stackdepth)) { + case -1: goto failure; + //case 1: initprintf("%s:%s dropped for lower priority\n", d,dirent->name); break; + //case 0: initprintf("%s:%s accepted\n", d,dirent->name); break; + default: break; + } + } + Bclosedir(dir); + } + + if (pathsearchmode) break; + + if (!search) { + search = searchpathhead; + stackdepth = CACHE1D_SOURCE_PATH; + } else { + search = search->next; + stackdepth++; + } + if (search) d = search->path; + } while (search); + } + + if (!pathsearchmode) { // next, zip files + char buf[BMAX_PATH], *p; + int i, j, ftype; + strcpy(buf,path); + if (*path) strcat(buf,"/"); + strcat(buf,mask); + for (kzfindfilestart(buf); kzfindfile(buf); ) { + if (buf[0] != '|') continue; // local files we don't need + + // scan for the end of the string and shift + // everything left a char in the process + for (i=1; (buf[i-1]=buf[i]); i++) ; i-=2; + + // if there's a slash at the end, this is a directory entry + if (toupperlookup[buf[i]] == '/') { ftype = CACHE1D_FIND_DIR; buf[i] = 0; } + else ftype = CACHE1D_FIND_FILE; + + // skip over the common characters at the beginning of the base path and the zip entry + for (j=0; buf[j] && path[j]; j++) { + if (toupperlookup[ path[j] ] == toupperlookup[ buf[j] ]) continue; + break; + } + // we've now hopefully skipped the common path component at the beginning. + // if that's true, we should be staring at a null byte in path and either any character in buf + // if j==0, or a slash if j>0 + if ((!path[0] && buf[j]) || (!path[j] && toupperlookup[ buf[j] ] == '/')) { + if (j>0) j++; + + // yep, so now we shift what follows back to the start of buf and while we do that, + // keep an eye out for any more slashes which would mean this entry has sub-entities + // and is useless to us. + for (i = 0; (buf[i] = buf[j]) && toupperlookup[buf[j]] != '/'; i++,j++) ; + if (toupperlookup[buf[j]] == '/') continue; // damn, try next entry + } else { + // if we're here it means we have a situation where: + // path = foo + // buf = foobar... + // or + // path = foobar + // buf = foo... + // which would mean the entry is higher up in the directory tree and is also useless + continue; + } + + if ((type & CACHE1D_FIND_DIR) && ftype != CACHE1D_FIND_DIR) continue; + if ((type & CACHE1D_FIND_FILE) && ftype != CACHE1D_FIND_FILE) continue; + + // the entry is in the clear + switch (klistaddentry(&rec, buf, ftype, CACHE1D_SOURCE_ZIP)) { + case -1: goto failure; + //case 1: initprintf(":%s dropped for lower priority\n", buf); break; + //case 0: initprintf(":%s accepted\n", buf); break; + default: break; + } + } + } + + // then, grp files + if (!pathsearchmode && !*path && (type & CACHE1D_FIND_FILE)) { + char buf[13]; + int i,j; + buf[12] = 0; + for (i=0;i=0;j--) + { + Bmemcpy(buf,&gfilelist[i][j<<4],12); + if (!Bwildmatch(buf,mask)) continue; + switch (klistaddentry(&rec, buf, CACHE1D_FIND_FILE, CACHE1D_SOURCE_GRP)) { + case -1: goto failure; + //case 1: initprintf(":%s dropped for lower priority\n", workspace); break; + //case 0: initprintf(":%s accepted\n", workspace); break; + default: break; + } + } + } + } + + if (pathsearchmode && (type & CACHE1D_FIND_DRIVE)) { + char *drives, *drp; + drives = Bgetsystemdrives(); + if (drives) { + for (drp=drives; *drp; drp+=strlen(drp)+1) { + if (klistaddentry(&rec, drp, CACHE1D_FIND_DRIVE, CACHE1D_SOURCE_DRIVE) < 0) { + free(drives); + goto failure; + } + } + free(drives); + } + } + + free(path); + return rec; +failure: + free(path); + klistfree(rec); + return NULL; +} + + //Internal LZW variables +#define LZWSIZE 16384 //Watch out for shorts! +static char *lzwbuf1, *lzwbuf4, *lzwbuf5, lzwbuflock[5]; +static short *lzwbuf2, *lzwbuf3; + +static long lzwcompress(char *lzwinbuf, long uncompleng, char *lzwoutbuf); +static long lzwuncompress(char *lzwinbuf, long compleng, char *lzwoutbuf); + +int kdfread(void *buffer, bsize_t dasizeof, bsize_t count, long fil) +{ + unsigned long i, j, k, kgoal; + short leng; + char *ptr; + + lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 200; + if (lzwbuf1 == NULL) allocache((long *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); + if (lzwbuf2 == NULL) allocache((long *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); + if (lzwbuf3 == NULL) allocache((long *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); + if (lzwbuf4 == NULL) allocache((long *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); + if (lzwbuf5 == NULL) allocache((long *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); + + if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } + ptr = (char *)buffer; + + if (kread(fil,&leng,2) != 2) return -1; leng = B_LITTLE16(leng); + if (kread(fil,lzwbuf5,(long)leng) != leng) return -1; + k = 0; kgoal = lzwuncompress(lzwbuf5,(long)leng,lzwbuf4); + + copybufbyte(lzwbuf4,ptr,(long)dasizeof); + k += (long)dasizeof; + + for(i=1;i= kgoal) + { + if (kread(fil,&leng,2) != 2) return -1; leng = B_LITTLE16(leng); + if (kread(fil,lzwbuf5,(long)leng) != leng) return -1; + k = 0; kgoal = lzwuncompress(lzwbuf5,(long)leng,lzwbuf4); + } + for(j=0;j>4),&lzwbuflock[0]); + if (lzwbuf2 == NULL) allocache((long *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); + if (lzwbuf3 == NULL) allocache((long *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); + if (lzwbuf4 == NULL) allocache((long *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); + if (lzwbuf5 == NULL) allocache((long *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); + + if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } + ptr = (char *)buffer; + + if (Bfread(&leng,2,1,fil) != 1) return -1; leng = B_LITTLE16(leng); + if (Bfread(lzwbuf5,(long)leng,1,fil) != 1) return -1; + k = 0; kgoal = lzwuncompress(lzwbuf5,(long)leng,lzwbuf4); + + copybufbyte(lzwbuf4,ptr,(long)dasizeof); + k += (long)dasizeof; + + for(i=1;i= kgoal) + { + if (Bfread(&leng,2,1,fil) != 1) return -1; leng = B_LITTLE16(leng); + if (Bfread(lzwbuf5,(long)leng,1,fil) != 1) return -1; + k = 0; kgoal = lzwuncompress(lzwbuf5,(long)leng,lzwbuf4); + } + for(j=0;j>4),&lzwbuflock[0]); + if (lzwbuf2 == NULL) allocache((long *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); + if (lzwbuf3 == NULL) allocache((long *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); + if (lzwbuf4 == NULL) allocache((long *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); + if (lzwbuf5 == NULL) allocache((long *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); + + if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } + ptr = (char *)buffer; + + copybufbyte(ptr,lzwbuf4,(long)dasizeof); + k = dasizeof; + + if (k > LZWSIZE-dasizeof) + { + leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); k = 0; swleng = B_LITTLE16(leng); + Bwrite(fil,&swleng,2); Bwrite(fil,lzwbuf5,(long)leng); + } + + for(i=1;i LZWSIZE-dasizeof) + { + leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); k = 0; swleng = B_LITTLE16(leng); + Bwrite(fil,&swleng,2); Bwrite(fil,lzwbuf5,(long)leng); + } + ptr += dasizeof; + } + if (k > 0) + { + leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); swleng = B_LITTLE16(leng); + Bwrite(fil,&swleng,2); Bwrite(fil,lzwbuf5,(long)leng); + } + lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 1; +} + +void dfwrite(void *buffer, bsize_t dasizeof, bsize_t count, BFILE *fil) +{ + unsigned long i, j, k; + short leng, swleng; + char *ptr; + + lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 200; + if (lzwbuf1 == NULL) allocache((long *)&lzwbuf1,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[0]); + if (lzwbuf2 == NULL) allocache((long *)&lzwbuf2,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[1]); + if (lzwbuf3 == NULL) allocache((long *)&lzwbuf3,(LZWSIZE+(LZWSIZE>>4))*2,&lzwbuflock[2]); + if (lzwbuf4 == NULL) allocache((long *)&lzwbuf4,LZWSIZE,&lzwbuflock[3]); + if (lzwbuf5 == NULL) allocache((long *)&lzwbuf5,LZWSIZE+(LZWSIZE>>4),&lzwbuflock[4]); + + if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; } + ptr = (char *)buffer; + + copybufbyte(ptr,lzwbuf4,(long)dasizeof); + k = dasizeof; + + if (k > LZWSIZE-dasizeof) + { + leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); k = 0; swleng = B_LITTLE16(leng); + Bfwrite(&swleng,2,1,fil); Bfwrite(lzwbuf5,(long)leng,1,fil); + } + + for(i=1;i LZWSIZE-dasizeof) + { + leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); k = 0; swleng = B_LITTLE16(leng); + Bfwrite(&swleng,2,1,fil); Bfwrite(lzwbuf5,(long)leng,1,fil); + } + ptr += dasizeof; + } + if (k > 0) + { + leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); swleng = B_LITTLE16(leng); + Bfwrite(&swleng,2,1,fil); Bfwrite(lzwbuf5,(long)leng,1,fil); + } + lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 1; +} + +static long lzwcompress(char *lzwinbuf, long uncompleng, char *lzwoutbuf) +{ + long i, addr, newaddr, addrcnt, zx, *intptr; + long bytecnt1, bitcnt, numbits, oneupnumbits; + short *shortptr; + + for(i=255;i>=0;i--) { lzwbuf1[i] = i; lzwbuf3[i] = (i+1)&255; } + clearbuf(lzwbuf2,256>>1,0xffffffff); + clearbuf(lzwoutbuf,((uncompleng+15)+3)>>2,0L); + + addrcnt = 256; bytecnt1 = 0; bitcnt = (4<<3); + numbits = 8; oneupnumbits = (1<<8); + do + { + addr = lzwinbuf[bytecnt1]; + do + { + bytecnt1++; + if (bytecnt1 == uncompleng) break; + if (lzwbuf2[addr] < 0) {lzwbuf2[addr] = addrcnt; break;} + newaddr = lzwbuf2[addr]; + while (lzwbuf1[newaddr] != lzwinbuf[bytecnt1]) + { + zx = lzwbuf3[newaddr]; + if (zx < 0) {lzwbuf3[newaddr] = addrcnt; break;} + newaddr = zx; + } + if (lzwbuf3[newaddr] == addrcnt) break; + addr = newaddr; + } while (addr >= 0); + lzwbuf1[addrcnt] = lzwinbuf[bytecnt1]; + lzwbuf2[addrcnt] = -1; + lzwbuf3[addrcnt] = -1; + + intptr = (long *)&lzwoutbuf[bitcnt>>3]; + intptr[0] |= B_LITTLE32(addr<<(bitcnt&7)); + bitcnt += numbits; + if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1))) + bitcnt--; + + addrcnt++; + if (addrcnt > oneupnumbits) { numbits++; oneupnumbits <<= 1; } + } while ((bytecnt1 < uncompleng) && (bitcnt < (uncompleng<<3))); + + intptr = (long *)&lzwoutbuf[bitcnt>>3]; + intptr[0] |= B_LITTLE32(addr<<(bitcnt&7)); + bitcnt += numbits; + if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1))) + bitcnt--; + + shortptr = (short *)lzwoutbuf; + shortptr[0] = B_LITTLE16((short)uncompleng); + if (((bitcnt+7)>>3) < uncompleng) + { + shortptr[1] = B_LITTLE16((short)addrcnt); + return((bitcnt+7)>>3); + } + shortptr[1] = (short)0; + for(i=0;i>2); + return((long)B_LITTLE16(shortptr[0])); //uncompleng + } + for(i=255;i>=0;i--) { lzwbuf2[i] = i; lzwbuf3[i] = i; } + currstr = 256; bitcnt = (4<<3); outbytecnt = 0; + numbits = 8; oneupnumbits = (1<<8); + do + { + intptr = (long *)&lzwinbuf[bitcnt>>3]; + dat = ((B_LITTLE32(intptr[0])>>(bitcnt&7)) & (oneupnumbits-1)); + bitcnt += numbits; + if ((dat&((oneupnumbits>>1)-1)) > ((currstr-1)&((oneupnumbits>>1)-1))) + { dat &= ((oneupnumbits>>1)-1); bitcnt--; } + + lzwbuf3[currstr] = dat; + + for(leng=0;dat>=256;leng++,dat=lzwbuf3[dat]) + lzwbuf1[leng] = lzwbuf2[dat]; + + lzwoutbuf[outbytecnt++] = dat; + for(i=leng-1;i>=0;i--) lzwoutbuf[outbytecnt++] = lzwbuf1[i]; + + lzwbuf2[currstr-1] = dat; lzwbuf2[currstr] = dat; + currstr++; + if (currstr > oneupnumbits) { numbits++; oneupnumbits <<= 1; } + } while (currstr < strtot); + return((long)B_LITTLE16(shortptr[0])); //uncompleng +} + +/* + * vim:ts=4:sw=4: + */ diff --git a/polymer/build/src/compat.c b/polymer/build/src/compat.c new file mode 100644 index 000000000..0b9454d4d --- /dev/null +++ b/polymer/build/src/compat.c @@ -0,0 +1,716 @@ +/* + * Playing-field leveller for Build + * by Jonathon Fowler + * + * A note about this: + * 1. There is some kind of problem somewhere in the functions below because + * compiling with __compat_h_macrodef__ disabled makes stupid things happen. + * 2. The functions below, aside from the ones which aren't trivial, were never + * really intended to be used for anything except tracking anr removing ties + * to the standard C library from games. Using the Bxx versions of functions + * means we can redefine those names to link up with different runtime library + * names. + */ + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#define _WIN32_IE 0x0400 +#include +#include +#endif + +#include +#include +#include +#include +#include +#include + +#if defined(__WATCOMC__) +# include +#elif defined(_MSC_VER) +# include +#else +# include +#endif + +#include "compat.h" + + +#ifndef __compat_h_macrodef__ + +int Brand(void) +{ + return rand(); +} + +void *Bmalloc(bsize_t size) +{ + return malloc(size); +} + +void Bfree(void *ptr) +{ + free(ptr); +} + +int Bopen(const char *pathname, int flags, unsigned mode) +{ + int n=0,o=0; + + if (flags&BO_BINARY) n|=O_BINARY; else n|=O_TEXT; + if ((flags&BO_RDWR)==BO_RDWR) n|=O_RDWR; + else if ((flags&BO_RDWR)==BO_WRONLY) n|=O_WRONLY; + else if ((flags&BO_RDWR)==BO_RDONLY) n|=O_RDONLY; + if (flags&BO_APPEND) n|=O_APPEND; + if (flags&BO_CREAT) n|=O_CREAT; + if (flags&BO_TRUNC) n|=O_TRUNC; + if (mode&BS_IREAD) o|=S_IREAD; + if (mode&BS_IWRITE) o|=S_IWRITE; + if (mode&BS_IEXEC) o|=S_IEXEC; + + return open(pathname,n,o); +} + +int Bclose(int fd) +{ + return close(fd); +} + +bssize_t Bwrite(int fd, const void *buf, bsize_t count) +{ + return write(fd,buf,count); +} + +bssize_t Bread(int fd, void *buf, bsize_t count) +{ + return read(fd,buf,count); +} + +int Blseek(int fildes, int offset, int whence) +{ + switch (whence) { + case BSEEK_SET: whence=SEEK_SET; break; + case BSEEK_CUR: whence=SEEK_CUR; break; + case BSEEK_END: whence=SEEK_END; break; + } + return lseek(fildes,offset,whence); +} + +BFILE *Bfopen(const char *path, const char *mode) +{ + return (BFILE*)fopen(path,mode); +} + +int Bfclose(BFILE *stream) +{ + return fclose((FILE*)stream); +} + +void Brewind(BFILE *stream) +{ + rewind((FILE*)stream); +} + +int Bfgetc(BFILE *stream) +{ + return fgetc((FILE*)stream); +} + +char *Bfgets(char *s, int size, BFILE *stream) +{ + return fgets(s,size,(FILE*)stream); +} + +int Bfputc(int c, BFILE *stream) +{ + return fputc(c,(FILE*)stream); +} + +int Bfputs(const char *s, BFILE *stream) +{ + return fputs(s,(FILE*)stream); +} + +bsize_t Bfread(void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream) +{ + return fread(ptr,size,nmemb,(FILE*)stream); +} + +bsize_t Bfwrite(const void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream) +{ + return fwrite(ptr,size,nmemb,(FILE*)stream); +} + + +char *Bstrdup(const char *s) +{ + return strdup(s); +} + +char *Bstrcpy(char *dest, const char *src) +{ + return strcpy(dest,src); +} + +char *Bstrncpy(char *dest, const char *src, bsize_t n) +{ + return strncpy(dest,src,n); +} + +int Bstrcmp(const char *s1, const char *s2) +{ + return strcmp(s1,s2); +} + +int Bstrncmp(const char *s1, const char *s2, bsize_t n) +{ + return strncmp(s1,s2,n); +} + +int Bstrcasecmp(const char *s1, const char *s2) +{ +#ifdef _MSC_VER + return stricmp(s1,s2); +#else + return strcasecmp(s1,s2); +#endif +} + +int Bstrncasecmp(const char *s1, const char *s2, bsize_t n) +{ +#ifdef _MSC_VER + return strnicmp(s1,s2,n); +#else + return strncasecmp(s1,s2,n); +#endif +} + +char *Bstrcat(char *dest, const char *src) +{ + return strcat(dest,src); +} + +char *Bstrncat(char *dest, const char *src, bsize_t n) +{ + return strncat(dest,src,n); +} + +bsize_t Bstrlen(const char *s) +{ + return strlen(s); +} + +char *Bstrchr(const char *s, int c) +{ + return strchr(s,c); +} + +char *Bstrrchr(const char *s, int c) +{ + return strrchr(s,c); +} + +int Batoi(const char *nptr) +{ + return atoi(nptr); +} + +long Batol(const char *nptr) +{ + return atol(nptr); +} + +long int Bstrtol(const char *nptr, char **endptr, int base) +{ + return strtol(nptr,endptr,base); +} + +unsigned long int Bstrtoul(const char *nptr, char **endptr, int base) +{ + return strtoul(nptr,endptr,base); +} + +void *Bmemcpy(void *dest, const void *src, bsize_t n) +{ + return memcpy(dest,src,n); +} + +void *Bmemmove(void *dest, const void *src, bsize_t n) +{ + return memmove(dest,src,n); +} + +void *Bmemchr(const void *s, int c, bsize_t n) +{ + return memchr(s,c,n); +} + +void *Bmemset(void *s, int c, bsize_t n) +{ + return memset(s,c,n); +} + +int Bprintf(const char *format, ...) +{ + va_list ap; + int r; + + va_start(ap,format); +#ifdef _MSC_VER + r = _vprintf(format,ap); +#else + r = vprintf(format,ap); +#endif + va_end(ap); + return r; +} + +int Bsprintf(char *str, const char *format, ...) +{ + va_list ap; + int r; + + va_start(ap,format); +#ifdef _MSC_VER + r = _vsprintf(str,format,ap); +#else + r = vsprintf(str,format,ap); +#endif + va_end(ap); + return r; +} + +int Bsnprintf(char *str, bsize_t size, const char *format, ...) +{ + va_list ap; + int r; + + va_start(ap,format); +#ifdef _MSC_VER + r = _vsnprintf(str,size,format,ap); +#else + r = vsnprintf(str,size,format,ap); +#endif + va_end(ap); + return r; +} + +int Bvsnprintf(char *str, bsize_t size, const char *format, va_list ap) +{ +#ifdef _MSC_VER + return _vsnprintf(str,size,format,ap); +#else + return vsnprintf(str,size,format,ap); +#endif +} + +char *Bgetenv(const char *name) +{ + return getenv(name); +} + +char *Bgetcwd(char *buf, bsize_t size) +{ + return getcwd(buf,size); +} + +#endif // __compat_h_macrodef__ + + +// +// Stuff which must be a function +// + +char *Bgethomedir(void) +{ +#ifdef _WIN32 + TCHAR appdata[MAX_PATH]; + +//# if defined SHGetFolderPath +// if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, appdata))) +//# if defined SHGetSpecialFolderPath + if (SUCCEEDED(SHGetSpecialFolderPathA(NULL, appdata, CSIDL_APPDATA, FALSE))) +//# else +//# error Cannot find SHGetFolderPath or SHGetSpecialFolderPath. Perhaps your shlobj.h is ancient? +//# endif + return strdup(appdata); + return NULL; +#else + char *e = getenv("HOME"); + if (!e) return NULL; + return strdup(e); +#endif +} + +int Bcorrectfilename(char *filename, int removefn) +{ + char *fn; + char *tokarr[64], *first, *next, *token; + int i, ntok = 0, leadslash = 0, trailslash = 0; + + fn = strdup(filename); + if (!fn) return -1; + + for (first=fn; *first; first++) { +#ifdef _WIN32 + if (*first == '\\') *first = '/'; +#endif + } + leadslash = (*fn == '/'); + trailslash = (first>fn && first[-1] == '/'); + + first = fn; + do { + token = Bstrtoken(first, "/", &next, 1); + first = NULL; + if (!token) break; + else if (token[0] == 0) continue; + else if (token[0] == '.' && token[1] == 0) continue; + else if (token[0] == '.' && token[1] == '.' && token[2] == 0) ntok = max(0,ntok-1); + else tokarr[ntok++] = token; + } while (1); + + if (!trailslash && removefn) { ntok = max(0,ntok-1); trailslash = 1; } + if (ntok == 0 && trailslash && leadslash) trailslash = 0; + + first = filename; + if (leadslash) *(first++) = '/'; + for (i=0; i0) *(first++) = '/'; + for (token=tokarr[i]; *token; token++) + *(first++) = *token; + } + if (trailslash) *(first++) = '/'; + *(first++) = 0; + + return 0; +} + +int Bcanonicalisefilename(char *filename, int removefn) +{ + char cwd[BMAX_PATH], fn[BMAX_PATH], *p; + char *fnp = filename; +#ifdef _WIN32 + int drv = 0; +#endif + +#ifdef _WIN32 + { + if (filename[0] && filename[1] == ':') { + // filename is prefixed with a drive + drv = toupper(filename[0])-'A' + 1; + fnp += 2; + } + if (!_getdcwd(drv, cwd, sizeof(cwd))) return -1; + for (p=cwd; *p; p++) if (*p == '\\') *p = '/'; + } +#else + if (!getcwd(cwd,sizeof(cwd))) return -1; +#endif + p = strrchr(cwd,'/'); if (!p || p[1]) strcat(cwd, "/"); + + strcpy(fn, fnp); +#ifdef _WIN32 + for (p=fn; *p; p++) if (*p == '\\') *p = '/'; +#endif + + if (fn[0] != '/') { + // we are dealing with a path relative to the current directory + strcpy(filename, cwd); + strcat(filename, fn); + } else { +#ifdef _WIN32 + filename[0] = cwd[0]; + filename[1] = ':'; + filename[2] = 0; +#else + filename[0] = 0; +#endif + strcat(filename, fn); + } + fnp = filename; +#ifdef _WIN32 + fnp += 2; // skip the drive +#endif + + return Bcorrectfilename(fnp,1); +} + +char *Bgetsystemdrives(void) +{ +#ifdef _WIN32 + char *str, *p; + DWORD drv, mask; + int number=0; + + drv = GetLogicalDrives(); + if (drv == 0) return NULL; + + for (mask=1; mask<0x8000000l; mask<<=1) { + if ((drv&mask) == 0) continue; + number++; + } + + str = p = (char *)malloc(1 + (3*number)); + if (!str) return NULL; + + number = 0; + for (mask=1; mask<0x8000000l; mask<<=1, number++) { + if ((drv&mask) == 0) continue; + *(p++) = 'A' + number; + *(p++) = ':'; + *(p++) = 0; + } + *(p++) = 0; + + return str; +#else + // Perhaps have Unix OS's put /, /home/user, and /mnt/* in the "drives" list? + return NULL; +#endif +} + + +long Bfilelength(int fd) +{ + struct stat st; + if (fstat(fd, &st) < 0) return -1; + return(long)(st.st_size); +} + + +typedef struct { +#ifdef _MSC_VER + long dir; + struct _finddata_t fid; +#else + DIR *dir; +#endif + struct Bdirent info; + int status; + char name[1]; +} BDIR_real; + +BDIR* Bopendir(const char *name) +{ + BDIR_real *dirr; +#ifdef _MSC_VER + char *t,*tt; + t = (char*)malloc(strlen(name)+1+4); + if (!t) return NULL; +#endif + + dirr = (BDIR_real*)malloc(sizeof(BDIR_real) + strlen(name)); + if (!dirr) { +#ifdef _MSC_VER + free(t); +#endif + return NULL; + } + +#ifdef _MSC_VER + strcpy(t,name); + tt = t+strlen(name)-1; + while (*tt == ' ' && tt>t) tt--; + if (*tt != '/' && *tt != '\\') *(++tt) = '/'; + *(++tt) = '*'; + *(++tt) = '.'; + *(++tt) = '*'; + *(++tt) = 0; + + dirr->dir = _findfirst(t,&dirr->fid); + free(t); + if (dirr->dir == -1) { + free(dirr); + return NULL; + } +#else + dirr->dir = opendir(name); + if (dirr->dir == NULL) { + free(dirr); + return NULL; + } +#endif + + dirr->status = 0; + strcpy(dirr->name, name); + + return (BDIR*)dirr; +} + +struct Bdirent* Breaddir(BDIR *dir) +{ + BDIR_real *dirr = (BDIR_real*)dir; + struct dirent *de; + struct stat st; + char *fn; + +#ifdef _MSC_VER + if (dirr->status > 0) { + if (_findnext(dirr->dir,&dirr->fid) != 0) { + dirr->status = -1; + return NULL; + } + } + dirr->info.namlen = strlen(dirr->fid.name); + dirr->info.name = dirr->fid.name; + dirr->status++; +#else + de = readdir(dirr->dir); + if (de == NULL) { + dirr->status = -1; + return NULL; + } else { + dirr->status++; + } +//# if defined(__WATCOMC__) || defined(__linux) || defined(__BEOS__) || defined(__QNX__) || defined(SKYOS) + dirr->info.namlen = strlen(de->d_name); +//# else +// dirr->info.namlen = de->d_namlen; +//# endif + dirr->info.name = de->d_name; +#endif + dirr->info.mode = 0; + dirr->info.size = 0; + dirr->info.mtime = 0; + + fn = (char *)malloc(strlen(dirr->name) + 1 + dirr->info.namlen + 1); + if (fn) { + sprintf(fn,"%s/%s",dirr->name,dirr->info.name); + if (!stat(fn, &st)) { + dirr->info.mode = st.st_mode; + dirr->info.size = st.st_size; + dirr->info.mtime = st.st_mtime; + } + free(fn); + } + + return &dirr->info; +} + +int Bclosedir(BDIR *dir) +{ + BDIR_real *dirr = (BDIR_real*)dir; + +#ifdef _MSC_VER + _findclose(dirr->dir); +#else + closedir(dirr->dir); +#endif + free(dirr); + + return 0; +} + + +char *Bstrtoken(char *s, char *delim, char **ptrptr, int chop) +{ + char *p, *start; + + if (!ptrptr) return NULL; + + if (s) p = s; + else p = *ptrptr; + + if (!p) return NULL; + + while (*p != 0 && strchr(delim, *p)) p++; + if (*p == 0) { + *ptrptr = NULL; + return NULL; + } + start = p; + while (*p != 0 && !strchr(delim, *p)) p++; + if (*p == 0) *ptrptr = NULL; + else { + if (chop) *(p++) = 0; + *ptrptr = p; + } + + return start; +} + + + //Brute-force case-insensitive, slash-insensitive, * and ? wildcard matcher + //Given: string i and string j. string j can have wildcards + //Returns: 1:matches, 0:doesn't match +long Bwildmatch (const char *i, const char *j) +{ + const char *k; + char c0, c1; + + if (!*j) return(1); + do + { + if (*j == '*') + { + for(k=i,j++;*k;k++) if (Bwildmatch(k,j)) return(1); + continue; + } + if (!*i) return(0); + if (*j == '?') { i++; j++; continue; } + c0 = *i; if ((c0 >= 'a') && (c0 <= 'z')) c0 -= 32; + c1 = *j; if ((c1 >= 'a') && (c1 <= 'z')) c1 -= 32; +#ifdef _WIN32 + if (c0 == '/') c0 = '\\'; + if (c1 == '/') c1 = '\\'; +#endif + if (c0 != c1) return(0); + i++; j++; + } while (*j); + return(!*i); +} + +#if !defined(_WIN32) +char *Bstrlwr(char *s) +{ + char *t = s; + if (!s) return s; + while (*t) { *t = Btolower(*t); t++; } + return s; +} + +char *Bstrupr(char *s) +{ + char *t = s; + if (!s) return s; + while (*t) { *t = Btoupper(*t); t++; } + return s; +} +#endif + + +// +// getsysmemsize() -- gets the amount of system memory in the machine +// +unsigned int Bgetsysmemsize(void) +{ +#ifdef _WIN32 + MEMORYSTATUS memst; + GlobalMemoryStatus(&memst); + return (unsigned int)memst.dwTotalPhys; +#elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) + unsigned int siz = 0x7fffffff; + long scpagesiz, scphyspages; + +#ifdef _SC_PAGE_SIZE + scpagesiz = sysconf(_SC_PAGE_SIZE); +#else + scpagesiz = sysconf(_SC_PAGESIZE); +#endif + scphyspages = sysconf(_SC_PHYS_PAGES); + if (scpagesiz >= 0 && scphyspages >= 0) + siz = (unsigned int)min(longlong(0x7fffffff), (int64)scpagesiz * (int64)scphyspages); + + //initprintf("Bgetsysmemsize(): %d pages of %d bytes, %d bytes of system memory\n", + // scphyspages, scpagesiz, siz); + + return siz; +#else + return 0x7fffffff; +#endif +} + + + diff --git a/polymer/build/src/config.c b/polymer/build/src/config.c new file mode 100644 index 000000000..642f9707f --- /dev/null +++ b/polymer/build/src/config.c @@ -0,0 +1,307 @@ +// Evil and Nasty Configuration File Reader for KenBuild +// by Jonathon Fowler + +#include "compat.h" +#include "build.h" +#include "editor.h" +#include "osd.h" + +#ifdef RENDERTYPEWIN +#include "winlayer.h" +#endif +#include "baselayer.h" + +static long vesares[13][2] = {{320,200},{360,200},{320,240},{360,240},{320,400}, + {360,400},{640,350},{640,400},{640,480},{800,600}, + {1024,768},{1280,1024},{1600,1200}}; + +static int readconfig(BFILE *fp, const char *key, char *value, unsigned len) +{ + char buf[1000], *k, *v, *eq; + int x=0; + + if (len < 1) return 0; + + Brewind(fp); + + while (1) { + if (!Bfgets(buf, 1000, fp)) return 0; + + if (buf[0] == ';') continue; + + eq = Bstrchr(buf, '='); + if (!eq) continue; + + k = buf; + v = eq+1; + + while (*k == ' ' || *k == '\t') k++; + *(eq--) = 0; + while ((*eq == ' ' || *eq == '\t') && eq>=k) *(eq--) = 0; + + if (Bstrcasecmp(k, key)) continue; + + while (*v == ' ' || *k == '\t') v++; + eq = v + Bstrlen(v)-1; + + while ((*eq == ' ' || *eq == '\t' || *eq == '\r' || *eq == '\n') && eq>=v) *(eq--) = 0; + + value[--len] = 0; + do value[x] = v[x]; while (v[x++] != 0 && len-- > 0); + + return x-1; + } +} + +extern short brightness; +extern long fullscreen; +extern char option[8]; +extern char keys[NUMBUILDKEYS]; +extern double msens; + +/* + * SETUP.DAT + * 0 = video mode (0:chained 1:vesa 2:screen buffered 3/4/5:tseng/paradise/s3 6:red-blue) + * 1 = sound (0:none) + * 2 = music (0:none) + * 3 = input (0:keyboard 1:+mouse) + * 4 = multiplayer (0:single 1-4:com 5-11:ipx) + * 5&0xf0 = com speed + * 5&0x0f = com irq + * 6&0xf0 = chained y-res + * 6&0x0f = chained x-res or vesa mode + * 7&0xf0 = sound samplerate + * 7&0x01 = sound quality + * 7&0x02 = 8/16 bit + * 7&0x04 = mono/stereo + * + * bytes 8 to 26 are key settings: + * 0 = Forward (0xc8) + * 1 = Backward (0xd0) + * 2 = Turn left (0xcb) + * 3 = Turn right (0xcd) + * 4 = Run (0x2a) + * 5 = Strafe (0x9d) + * 6 = Fire (0x1d) + * 7 = Use (0x39) + * 8 = Stand high (0x1e) + * 9 = Stand low (0x2c) + * 10 = Look up (0xd1) + * 11 = Look down (0xc9) + * 12 = Strafe left (0x33) + * 13 = Strafe right (0x34) + * 14 = 2D/3D switch (0x9c) + * 15 = View cycle (0x1c) + * 16 = 2D Zoom in (0xd) + * 17 = 2D Zoom out (0xc) + * 18 = Chat (0xf) + */ + +int loadsetup(const char *fn) +{ + BFILE *fp; +#define VL 32 + char val[VL]; + int i; + + if ((fp = Bfopen(fn, "rt")) == NULL) return -1; + + if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; } + if (readconfig(fp, "resolution", val, VL) > 0) { + i = Batoi(val) & 0x0f; + if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; } + } + if (readconfig(fp, "2dresolution", val, VL) > 0) { + i = Batoi(val) & 0x0f; + if ((unsigned)i<13) { xdim2d = vesares[i][0]; ydim2d = vesares[i][1]; } + } + if (readconfig(fp, "xdim2d", val, VL) > 0) xdim2d = Batoi(val); + if (readconfig(fp, "ydim2d", val, VL) > 0) ydim2d = Batoi(val); + if (readconfig(fp, "xdim3d", val, VL) > 0) xdimgame = Batoi(val); + if (readconfig(fp, "ydim3d", val, VL) > 0) ydimgame = Batoi(val); + if (readconfig(fp, "samplerate", val, VL) > 0) option[7] = (Batoi(val) & 0x0f) << 4; + if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } + if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } + if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val); + if (readconfig(fp, "renderer", val, VL) > 0) { i = Batoi(val); setrendermode(i); } + if (readconfig(fp, "brightness", val, VL) > 0) brightness = min(max(Batoi(val),0),15); + +#ifdef RENDERTYPEWIN + if (readconfig(fp, "maxrefreshfreq", val, VL) > 0) maxrefreshfreq = Batoi(val); +#endif + glusetexcache = glusetexcachecompression = -1; + if (readconfig(fp, "glusetexcache", val, VL) > 0) { + if (Batoi(val) != 0) glusetexcache = 1; + else glusetexcache = 0; + } + if (readconfig(fp, "glusetexcachecompression", val, VL) > 0) { + if (Batoi(val) != 0) glusetexcachecompression = 1; + else glusetexcachecompression = 0; + } + if(glusetexcache == -1 && glusetexcachecompression == -1) + { + i=wm_ynbox("Texture caching", + "Would you like to enable the on-disk texture cache? " + "This feature may use up to 200 megabytes of disk " + "space if you have a great deal of high resolution " + "textures and skins, but textures will load exponentially " + "faster after the first time they are loaded."); + if (i) i = 'y'; + if(i == 'y' || i == 'Y' ) + glusetexcompr = glusetexcache = glusetexcachecompression = 1; + else glusetexcache = glusetexcachecompression = 0; + } + + option[0] = 1; // vesa all the way... + option[1] = 1; // sound all the way... + option[4] = 0; // no multiplayer + option[5] = 0; + + if (readconfig(fp, "keyforward", val, VL) > 0) keys[0] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keybackward", val, VL) > 0) keys[1] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keyturnleft", val, VL) > 0) keys[2] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keyturnright", val, VL) > 0) keys[3] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keyrun", val, VL) > 0) keys[4] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keystrafe", val, VL) > 0) keys[5] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keyfire", val, VL) > 0) keys[6] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keyuse", val, VL) > 0) keys[7] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keystandhigh", val, VL) > 0) keys[8] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keystandlow", val, VL) > 0) keys[9] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keylookup", val, VL) > 0) keys[10] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keylookdown", val, VL) > 0) keys[11] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keystrafeleft", val, VL) > 0) keys[12] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keystraferight", val, VL) > 0) keys[13] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "key2dmode", val, VL) > 0) keys[14] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keyviewcycle", val, VL) > 0) keys[15] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "key2dzoomin", val, VL) > 0) keys[16] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "key2dzoomout", val, VL) > 0) keys[17] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keychat", val, VL) > 0) keys[18] = Bstrtol(val, NULL, 16); + if (readconfig(fp, "keyconsole", val, VL) > 0) { keys[19] = Bstrtol(val, NULL, 16); OSD_CaptureKey(keys[19]); } + + if (readconfig(fp, "mousesensitivity", val, VL) > 0) msens = Bstrtod(val, NULL); + + Bfclose(fp); + + return 0; +} + +int writesetup(const char *fn) +{ + BFILE *fp; + + fp = Bfopen(fn,"wt"); + if (!fp) return -1; + + Bfprintf(fp, + "; Video mode selection\n" + "; 0 - Windowed\n" + "; 1 - Fullscreen\n" + "fullscreen = %ld\n" + "\n" + "; Video resolution\n" + "xdim2d = %ld\n" + "ydim2d = %ld\n" + "xdim3d = %ld\n" + "ydim3d = %ld\n" + "\n" + "; 3D-mode colour depth\n" + "bpp = %ld\n" + "\n" + "; OpenGL mode options\n" + "glusetexcache = %ld\n" + "glusetexcachecompression = %ld\n" + "\n" +#ifdef RENDERTYPEWIN + "; Maximum OpenGL mode refresh rate (Windows only, in Hertz)\n" + "maxrefreshfreq = %d\n" + "\n" +#endif + "; 3D mode brightness setting\n" + "; 0 - lowest\n" + "; 15 - highest\n" + "brightness = %d\n" + "\n" + "; Sound sample frequency\n" + "; 0 - 6 KHz\n" + "; 1 - 8 KHz\n" + "; 2 - 11.025 KHz\n" + "; 3 - 16 KHz\n" + "; 4 - 22.05 KHz\n" + "; 5 - 32 KHz\n" + "; 6 - 44.1 KHz\n" + "samplerate = %d\n" + "\n" + "; Music playback\n" + "; 0 - Off\n" + "; 1 - On\n" + "music = %d\n" + "\n" + "; Enable mouse\n" + "; 0 - No\n" + "; 1 - Yes\n" + "mouse = %d\n" + "\n" + "; Mouse sensitivity\n" + "mousesensitivity = %g\n" + "\n" + "; Key Settings\n" + "; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex!\n" + "; +---------------------------------------------------------------------------------------------+\n" + "; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 |\n" + "; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL |\n" + "; | |\n" + "; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A |\n" + "; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- |\n" + "; | |\n" + "; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E |\n" + "; |TAB Q W E R T Y U I O P [ ] \\ DEL END PGDN KP7 KP8 KP9 KP+ |\n" + "; | |\n" + "; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D |\n" + "; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C |\n" + "; | KPENTER|\n" + "; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 |\n" + "; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 |\n" + "; | |\n" + "; | 1D 38 39 B8 9D CB D0 CD 52 53 |\n" + "; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. |\n" + "; +---------------------------------------------------------------------------------------------+\n" + "\n" + "keyforward = %X\n" + "keybackward = %X\n" + "keyturnleft = %X\n" + "keyturnright = %X\n" + "keyrun = %X\n" + "keystrafe = %X\n" + "keyfire = %X\n" + "keyuse = %X\n" + "keystandhigh = %X\n" + "keystandlow = %X\n" + "keylookup = %X\n" + "keylookdown = %X\n" + "keystrafeleft = %X\n" + "keystraferight = %X\n" + "key2dmode = %X\n" + "keyviewcycle = %X\n" + "key2dzoomin = %X\n" + "key2dzoomout = %X\n" + "keychat = %X\n" + "keyconsole = %X\n" + "\n", + + fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame, + glusetexcache, glusetexcachecompression, +#ifdef RENDERTYPEWIN + maxrefreshfreq, +#endif + brightness, option[7]>>4, option[2], + option[3], msens, + keys[0], keys[1], keys[2], keys[3], keys[4], keys[5], + keys[6], keys[7], keys[8], keys[9], keys[10], keys[11], + keys[12], keys[13], keys[14], keys[15], keys[16], keys[17], + keys[18], keys[19] + ); + + Bfclose(fp); + + return 0; +} diff --git a/polymer/build/src/crc32.c b/polymer/build/src/crc32.c new file mode 100644 index 000000000..5966dcfd3 --- /dev/null +++ b/polymer/build/src/crc32.c @@ -0,0 +1,104 @@ +#include "crc32.h" + +/* +// this table of numbers is borrowed from the InfoZip source. +static unsigned long crc32table[256] = { + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, + 0x2d02ef8dL +}; +*/ + +static unsigned long crc32table[256]; + +void initcrc32table(void) +{ + unsigned long i,j,k; + + // algorithm and polynomial same as that used by infozip's zip + for (i=0; i<256; i++) { + j = i; + for (k=8; k; k--) + j = (j&1) ? (0xedb88320L ^ (j>>1)) : (j>>1); + crc32table[i] = j; + } +} + + +unsigned long crc32once(unsigned char *blk, unsigned long len) +{ + unsigned long crc; + + crc32init(&crc); + crc32block(&crc, blk, len); + return crc32finish(&crc); +} + +void crc32init(unsigned long *crcvar) +{ + if (!crcvar) return; + *crcvar = 0xffffffffl; +} + +void crc32block(unsigned long *crcvar, unsigned char *blk, unsigned long len) +{ + unsigned long crc = *crcvar; + while (len--) crc = crc32table[(crc ^ *(blk++)) & 0xffl] ^ (crc >> 8); + *crcvar = crc; +} + +unsigned long crc32finish(unsigned long *crcvar) +{ + *crcvar = *crcvar ^ 0xffffffffl; + return *crcvar; +} + diff --git a/polymer/build/src/defs.c b/polymer/build/src/defs.c new file mode 100644 index 000000000..171bc546f --- /dev/null +++ b/polymer/build/src/defs.c @@ -0,0 +1,1072 @@ +/* + * Definitions file parser for Build + * by Jonathon Fowler (jonof@edgenetwork.org) + * Remixed substantially by Ken Silverman + * See the included license file "BUILDLIC.TXT" for license info. + */ + +#include "build.h" +#include "compat.h" +#include "baselayer.h" +#include "scriptfile.h" +#include "cache1d.h" + +enum { + T_EOF = -2, + T_ERROR = -1, + T_INCLUDE = 0, + T_DEFINE, + T_DEFINETEXTURE, + T_DEFINESKYBOX, + T_DEFINETINT, + T_DEFINEMODEL, + T_DEFINEMODELFRAME, + T_DEFINEMODELANIM, + T_DEFINEMODELSKIN, + T_SELECTMODELSKIN, + T_DEFINEVOXEL, + T_DEFINEVOXELTILES, + T_MODEL, + T_FILE, + T_SCALE, + T_SHADE, + T_FRAME, + T_ANIM, + T_SKIN, + T_SURF, + T_TILE, + T_TILE0, + T_TILE1, + T_FRAME0, + T_FRAME1, + T_FPS, + T_FLAGS, + T_PAL, + T_HUD, + T_XADD, + T_YADD, + T_ZADD, + T_ANGADD, + T_FLIPPED, + T_HIDE, + T_NOBOB, + T_NODEPTH, + T_VOXEL, + T_SKYBOX, + T_FRONT,T_RIGHT,T_BACK,T_LEFT,T_TOP,T_BOTTOM, + T_TINT,T_RED,T_GREEN,T_BLUE, + T_TEXTURE,T_ALPHACUT,T_NOCOMPRESS, + T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE, + T_ALPHAHACK,T_ALPHAHACKRANGE, + T_SPRITECOL,T_2DCOL, + T_FOGPAL, + T_LOADGRP, +}; + +typedef struct { char *text; int tokenid; } tokenlist; +static tokenlist basetokens[] = +{ + { "include", T_INCLUDE }, + { "#include", T_INCLUDE }, + { "define", T_DEFINE }, + { "#define", T_DEFINE }, + + // deprecated style + { "definetexture", T_DEFINETEXTURE }, + { "defineskybox", T_DEFINESKYBOX }, + { "definetint", T_DEFINETINT }, + { "definemodel", T_DEFINEMODEL }, + { "definemodelframe",T_DEFINEMODELFRAME }, + { "definemodelanim", T_DEFINEMODELANIM }, + { "definemodelskin", T_DEFINEMODELSKIN }, + { "selectmodelskin", T_SELECTMODELSKIN }, + { "definevoxel", T_DEFINEVOXEL }, + { "definevoxeltiles",T_DEFINEVOXELTILES }, + + // new style + + { "model", T_MODEL }, + { "voxel", T_VOXEL }, + { "skybox", T_SKYBOX }, + { "tint", T_TINT }, + { "texture", T_TEXTURE }, + { "tile", T_TEXTURE }, + + // other stuff + { "undefmodel", T_UNDEFMODEL }, + { "undefmodelrange", T_UNDEFMODELRANGE }, + { "undefmodelof", T_UNDEFMODELOF }, + { "undeftexture", T_UNDEFTEXTURE }, + { "undeftexturerange", T_UNDEFTEXTURERANGE }, + { "alphahack", T_ALPHAHACK }, + { "alphahackrange", T_ALPHAHACKRANGE }, + { "spritecol", T_SPRITECOL }, + { "2dcol", T_2DCOL }, + { "fogpal", T_FOGPAL }, + { "loadgrp", T_LOADGRP }, +}; + +static tokenlist modeltokens[] = { + { "scale", T_SCALE }, + { "shade", T_SHADE }, + { "zadd", T_ZADD }, + { "frame", T_FRAME }, + { "anim", T_ANIM }, + { "skin", T_SKIN }, + { "hud", T_HUD }, +}; + +static tokenlist modelframetokens[] = { + { "frame", T_FRAME }, + { "name", T_FRAME }, + { "tile", T_TILE }, + { "tile0", T_TILE0 }, + { "tile1", T_TILE1 }, +}; + +static tokenlist modelanimtokens[] = { + { "frame0", T_FRAME0 }, + { "frame1", T_FRAME1 }, + { "fps", T_FPS }, + { "flags", T_FLAGS }, +}; + +static tokenlist modelskintokens[] = { + { "pal", T_PAL }, + { "file", T_FILE }, + { "surf", T_SURF }, + { "surface",T_SURF }, +}; + +static tokenlist modelhudtokens[] = { + { "tile", T_TILE }, + { "tile0", T_TILE0 }, + { "tile1", T_TILE1 }, + { "xadd", T_XADD }, + { "yadd", T_YADD }, + { "zadd", T_ZADD }, + { "angadd", T_ANGADD }, + { "hide", T_HIDE }, + { "nobob", T_NOBOB }, + { "flipped",T_FLIPPED}, + { "nodepth",T_NODEPTH}, +}; + +static tokenlist voxeltokens[] = { + { "tile", T_TILE }, + { "tile0", T_TILE0 }, + { "tile1", T_TILE1 }, + { "scale", T_SCALE }, +}; + +static tokenlist skyboxtokens[] = { + { "tile" ,T_TILE }, + { "pal" ,T_PAL }, + { "ft" ,T_FRONT },{ "front" ,T_FRONT },{ "forward",T_FRONT }, + { "rt" ,T_RIGHT },{ "right" ,T_RIGHT }, + { "bk" ,T_BACK },{ "back" ,T_BACK }, + { "lf" ,T_LEFT },{ "left" ,T_LEFT },{ "lt" ,T_LEFT }, + { "up" ,T_TOP },{ "top" ,T_TOP },{ "ceiling",T_TOP },{ "ceil" ,T_TOP }, + { "dn" ,T_BOTTOM },{ "bottom" ,T_BOTTOM },{ "floor" ,T_BOTTOM },{ "down" ,T_BOTTOM } +}; + +static tokenlist tinttokens[] = { + { "pal", T_PAL }, + { "red", T_RED },{ "r", T_RED }, + { "green", T_GREEN },{ "g", T_GREEN }, + { "blue", T_BLUE },{ "b", T_BLUE }, + { "flags", T_FLAGS } +}; + +static tokenlist texturetokens[] = { + { "pal", T_PAL }, +}; +static tokenlist texturetokens_pal[] = { + { "file", T_FILE },{ "name", T_FILE }, + { "alphacut", T_ALPHACUT }, + { "nocompress",T_NOCOMPRESS }, +}; + +static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens) +{ + char *tok; + int i; + + if (!sf) return T_ERROR; + tok = scriptfile_gettoken(sf); + if (!tok) return T_EOF; + + for(i=0;iltextptr; + switch (tokn) { + case T_ERROR: + initprintf("Error on line %s:%d.\n", script->filename,scriptfile_getlinum(script,cmdtokptr)); + break; + case T_EOF: + return(0); + case T_INCLUDE: + { + char *fn; + if (!scriptfile_getstring(script,&fn)) { + scriptfile *included; + + included = scriptfile_fromfile(fn); + if (!included) { + initprintf("Warning: Failed including %s on line %s:%d\n", + fn, script->filename,scriptfile_getlinum(script,cmdtokptr)); + } else { + defsparser(included); + scriptfile_close(included); + } + } + break; + } + case T_DEFINE: + { + char *name; + int number; + + if (scriptfile_getstring(script,&name)) break; + if (scriptfile_getsymbol(script,&number)) break; + + if (scriptfile_addsymbolvalue(name,number) < 0) + initprintf("Warning: Symbol %s was NOT redefined to %d on line %s:%d\n", + name,number,script->filename,scriptfile_getlinum(script,cmdtokptr)); + break; + } + + // OLD (DEPRECATED) DEFINITION SYNTAX + case T_DEFINETEXTURE: + { + int tile,pal,fnoo; + char *fn; + + if (scriptfile_getsymbol(script,&tile)) break; + if (scriptfile_getsymbol(script,&pal)) break; + if (scriptfile_getnumber(script,&fnoo)) break; //x-center + if (scriptfile_getnumber(script,&fnoo)) break; //y-center + if (scriptfile_getnumber(script,&fnoo)) break; //x-size + if (scriptfile_getnumber(script,&fnoo)) break; //y-size + if (scriptfile_getstring(script,&fn)) break; + hicsetsubsttex(tile,pal,fn,-1.0,0); + } + break; + case T_DEFINESKYBOX: + { + int tile,pal,i; + char *fn[6]; + + if (scriptfile_getsymbol(script,&tile)) break; + if (scriptfile_getsymbol(script,&pal)) break; + if (scriptfile_getsymbol(script,&i)) break; //future expansion + for (i=0;i<6;i++) if (scriptfile_getstring(script,&fn[i])) break; //grab the 6 faces + if (i < 6) break; + hicsetskybox(tile,pal,fn); + } + break; + case T_DEFINETINT: + { + int pal, r,g,b,f; + + if (scriptfile_getsymbol(script,&pal)) break; + if (scriptfile_getnumber(script,&r)) break; + if (scriptfile_getnumber(script,&g)) break; + if (scriptfile_getnumber(script,&b)) break; + if (scriptfile_getnumber(script,&f)) break; //effects + hicsetpalettetint(pal,r,g,b,f); + } + break; + case T_ALPHAHACK: + { + int tile; + double alpha; + + if (scriptfile_getsymbol(script,&tile)) break; + if (scriptfile_getdouble(script,&alpha)) break; + if ((unsigned long)tile < MAXTILES) alphahackarray[tile] = alpha; + } + break; + case T_ALPHAHACKRANGE: + { + int tilenume1,tilenume2,i; + double alpha; + + if (scriptfile_getsymbol(script,&tilenume1)) break; + if (scriptfile_getsymbol(script,&tilenume2)) break; + if (scriptfile_getdouble(script,&alpha)) break; + if (tilenume2 < tilenume1) { + initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); + i = tilenume2; + tilenume2 = tilenume1; + tilenume1 = i; + } + if ((tilenume1 >= 0 && tilenume1 < MAXTILES) && (tilenume2 >= 0 && tilenume2 < MAXTILES)) + { + for (i=tilenume1;i<=tilenume2;i++) + { + if ((unsigned long)i < MAXTILES) + alphahackarray[i] = alpha; + } + } + } + break; + case T_SPRITECOL: + { + int tile,col,type; + + if (scriptfile_getsymbol(script,&tile)) break; + if (scriptfile_getnumber(script,&col)) break; + if (scriptfile_getnumber(script,&type)) break; + if ((unsigned long)tile < MAXTILES) spritecol2d[tile][type] = col; + } + break; + case T_2DCOL: + { + int col,b,g,r; + + if (scriptfile_getnumber(script,&col)) break; + if (scriptfile_getnumber(script,&r)) break; + if (scriptfile_getnumber(script,&g)) break; + if (scriptfile_getnumber(script,&b)) break; + + if (col < 256) { + vgapal16[col*4+0] = b; // blue + vgapal16[col*4+1] = g; // green + vgapal16[col*4+2] = r; // red + } + } + break; + case T_FOGPAL: + { + int p,r,g,b,j; + char tempbuf[256]; + + if (scriptfile_getnumber(script,&p)) break; + if (scriptfile_getnumber(script,&r)) break; + if (scriptfile_getnumber(script,&g)) break; + if (scriptfile_getnumber(script,&b)) break; + + for (j = 0; j < 256; j++) + tempbuf[j] = j; + makepalookup(p, tempbuf, r, g, b, 1); + } + break; + case T_LOADGRP: + { + char *fn; + if (!scriptfile_getstring(script,&fn)) + { + int j = initgroupfile(fn); + + if( j == -1 ) + initprintf("Could not find GRP file %s.\n",fn); + else + initprintf("Using GRP file %s.\n",fn); + } + break; + } + case T_DEFINEMODEL: + { + char *modelfn; + double scale; + int shadeoffs; + + if (scriptfile_getstring(script,&modelfn)) break; + if (scriptfile_getdouble(script,&scale)) break; + if (scriptfile_getnumber(script,&shadeoffs)) break; + +#if defined(POLYMOST) && defined(USE_OPENGL) + lastmodelid = md_loadmodel(modelfn); + if (lastmodelid < 0) { + initprintf("Failure loading MD2/MD3 model \"%s\"\n", modelfn); + break; + } + md_setmisc(lastmodelid,(float)scale, shadeoffs,0.0); +#endif + modelskin = lastmodelskin = 0; + seenframe = 0; + } + break; + case T_DEFINEMODELFRAME: + { + char *framename, happy=1; + int ftilenume, ltilenume, tilex; + + if (scriptfile_getstring(script,&framename)) break; + if (scriptfile_getnumber(script,&ftilenume)) break; //first tile number + if (scriptfile_getnumber(script,<ilenume)) break; //last tile number (inclusive) + if (ltilenume < ftilenume) { + initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); + tilex = ftilenume; + ftilenume = ltilenume; + ltilenume = tilex; + } + + if (lastmodelid < 0) { + initprintf("Warning: Ignoring frame definition.\n"); + break; + } +#if defined(POLYMOST) && defined(USE_OPENGL) + for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { + switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin))) { + case 0: break; + case -1: happy = 0; break; // invalid model id!? + case -2: initprintf("Invalid tile number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + happy = 0; + break; + case -3: initprintf("Invalid frame name on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + happy = 0; + break; + } + } +#endif + seenframe = 1; + } + break; + case T_DEFINEMODELANIM: + { + char *startframe, *endframe; + int flags; + double dfps; + + if (scriptfile_getstring(script,&startframe)) break; + if (scriptfile_getstring(script,&endframe)) break; + if (scriptfile_getdouble(script,&dfps)) break; //animation frame rate + if (scriptfile_getnumber(script,&flags)) break; + + if (lastmodelid < 0) { + initprintf("Warning: Ignoring animation definition.\n"); + break; + } +#if defined(POLYMOST) && defined(USE_OPENGL) + switch (md_defineanimation(lastmodelid, startframe, endframe, (int)(dfps*(65536.0*.001)), flags)) { + case 0: break; + case -1: break; // invalid model id!? + case -2: initprintf("Invalid starting frame name on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + case -3: initprintf("Invalid ending frame name on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + case -4: initprintf("Out of memory on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } +#endif + } + break; + case T_DEFINEMODELSKIN: + { + int palnum, palnumer; + char *skinfn; + + if (scriptfile_getsymbol(script,&palnum)) break; + if (scriptfile_getstring(script,&skinfn)) break; //skin filename + + // if we see a sequence of definemodelskin, then a sequence of definemodelframe, + // and then a definemodelskin, we need to increment the skin counter. + // + // definemodel "mymodel.md2" 1 1 + // definemodelskin 0 "normal.png" // skin 0 + // definemodelskin 21 "normal21.png" + // definemodelframe "foo" 1000 1002 // these use skin 0 + // definemodelskin 0 "wounded.png" // skin 1 + // definemodelskin 21 "wounded21.png" + // definemodelframe "foo2" 1003 1004 // these use skin 1 + // selectmodelskin 0 // resets to skin 0 + // definemodelframe "foo3" 1005 1006 // these use skin 0 + if (seenframe) { modelskin = ++lastmodelskin; } + seenframe = 0; + +#if defined(POLYMOST) && defined(USE_OPENGL) + switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), 0)) { + case 0: break; + case -1: break; // invalid model id!? + case -2: initprintf("Invalid skin filename on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + case -3: initprintf("Invalid palette number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + case -4: initprintf("Out of memory on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } +#endif + } + break; + case T_SELECTMODELSKIN: + { + if (scriptfile_getsymbol(script,&modelskin)) break; + } + break; + case T_DEFINEVOXEL: + { + char *fn; + + if (scriptfile_getstring(script,&fn)) break; //voxel filename + + if (nextvoxid == MAXVOXELS) { + initprintf("Maximum number of voxels already defined.\n"); + break; + } + +#ifdef SUPERBUILD + if (qloadkvx(nextvoxid, fn)) { + initprintf("Failure loading voxel file \"%s\"\n",fn); + break; + } + + lastvoxid = nextvoxid++; +#endif + } + break; + case T_DEFINEVOXELTILES: + { + int ftilenume, ltilenume, tilex; + + if (scriptfile_getnumber(script,&ftilenume)) break; //1st tile # + if (scriptfile_getnumber(script,<ilenume)) break; //last tile # + + if (ltilenume < ftilenume) { + initprintf("Warning: backwards tile range on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + tilex = ftilenume; + ftilenume = ltilenume; + ltilenume = tilex; + } + if (ltilenume < 0 || ftilenume >= MAXTILES) { + initprintf("Invalid tile range on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + + if (lastvoxid < 0) { + initprintf("Warning: Ignoring voxel tiles definition.\n"); + break; + } +#ifdef SUPERBUILD + for (tilex = ftilenume; tilex <= ltilenume; tilex++) { + tiletovox[tilex] = lastvoxid; + } +#endif + } + break; + + // NEW (ENCOURAGED) DEFINITION SYNTAX + case T_MODEL: + { + char *modelend, *modelfn; + double scale=1.0, mzadd=0.0; + int shadeoffs=0; + + modelskin = lastmodelskin = 0; + seenframe = 0; + + if (scriptfile_getstring(script,&modelfn)) break; + +#if defined(POLYMOST) && defined(USE_OPENGL) + lastmodelid = md_loadmodel(modelfn); + if (lastmodelid < 0) { + initprintf("Failure loading MD2/MD3 model \"%s\"\n", modelfn); + break; + } +#endif + if (scriptfile_getbraces(script,&modelend)) break; + while (script->textptr < modelend) { + switch (getatoken(script,modeltokens,sizeof(modeltokens)/sizeof(tokenlist))) { + //case T_ERROR: initprintf("Error on line %s:%d in model tokens\n", script->filename,script->linenum); break; + case T_SCALE: scriptfile_getdouble(script,&scale); break; + case T_SHADE: scriptfile_getnumber(script,&shadeoffs); break; + case T_ZADD: scriptfile_getdouble(script,&mzadd); break; + case T_FRAME: + { + char *frametokptr = script->ltextptr; + char *frameend, *framename = 0, happy=1; + int ftilenume = -1, ltilenume = -1, tilex = 0; + + if (scriptfile_getbraces(script,&frameend)) break; + while (script->textptr < frameend) { + switch(getatoken(script,modelframetokens,sizeof(modelframetokens)/sizeof(tokenlist))) { + case T_FRAME: scriptfile_getstring(script,&framename); break; + case T_TILE: scriptfile_getsymbol(script,&ftilenume); ltilenume = ftilenume; break; + case T_TILE0: scriptfile_getsymbol(script,&ftilenume); break; //first tile number + case T_TILE1: scriptfile_getsymbol(script,<ilenume); break; //last tile number (inclusive) + } + } + + if (ftilenume < 0) initprintf("Error: missing 'first tile number' for frame definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,frametokptr)), happy = 0; + if (ltilenume < 0) initprintf("Error: missing 'last tile number' for frame definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,frametokptr)), happy = 0; + if (!happy) break; + + if (ltilenume < ftilenume) { + initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,frametokptr)); + tilex = ftilenume; + ftilenume = ltilenume; + ltilenume = tilex; + } + + if (lastmodelid < 0) { + initprintf("Warning: Ignoring frame definition.\n"); + break; + } +#if defined(POLYMOST) && defined(USE_OPENGL) + for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { + switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin))) { + case 0: break; + case -1: happy = 0; break; // invalid model id!? + case -2: initprintf("Invalid tile number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,frametokptr)); + happy = 0; + break; + case -3: initprintf("Invalid frame name on line %s:%d\n", + script->filename, scriptfile_getlinum(script,frametokptr)); + happy = 0; + break; + } + } +#endif + seenframe = 1; + } + break; + case T_ANIM: + { + char *animtokptr = script->ltextptr; + char *animend, *startframe = 0, *endframe = 0, happy=1; + int flags = 0; + double dfps = 1.0; + + if (scriptfile_getbraces(script,&animend)) break; + while (script->textptr < animend) { + switch(getatoken(script,modelanimtokens,sizeof(modelanimtokens)/sizeof(tokenlist))) { + case T_FRAME0: scriptfile_getstring(script,&startframe); break; + case T_FRAME1: scriptfile_getstring(script,&endframe); break; + case T_FPS: scriptfile_getdouble(script,&dfps); break; //animation frame rate + case T_FLAGS: scriptfile_getsymbol(script,&flags); break; + } + } + + if (!startframe) initprintf("Error: missing 'start frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0; + if (!endframe) initprintf("Error: missing 'end frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0; + if (!happy) break; + + if (lastmodelid < 0) { + initprintf("Warning: Ignoring animation definition.\n"); + break; + } +#if defined(POLYMOST) && defined(USE_OPENGL) + switch (md_defineanimation(lastmodelid, startframe, endframe, (int)(dfps*(65536.0*.001)), flags)) { + case 0: break; + case -1: break; // invalid model id!? + case -2: initprintf("Invalid starting frame name on line %s:%d\n", + script->filename, scriptfile_getlinum(script,animtokptr)); + break; + case -3: initprintf("Invalid ending frame name on line %s:%d\n", + script->filename, scriptfile_getlinum(script,animtokptr)); + break; + case -4: initprintf("Out of memory on line %s:%d\n", + script->filename, scriptfile_getlinum(script,animtokptr)); + break; + } +#endif + } break; + case T_SKIN: + { + char *skintokptr = script->ltextptr; + char *skinend, *skinfn = 0; + int palnum = 0, surfnum = 0; + + if (scriptfile_getbraces(script,&skinend)) break; + while (script->textptr < skinend) { + switch(getatoken(script,modelskintokens,sizeof(modelskintokens)/sizeof(tokenlist))) { + case T_PAL: scriptfile_getsymbol(script,&palnum); break; + case T_FILE: scriptfile_getstring(script,&skinfn); break; //skin filename + case T_SURF: scriptfile_getnumber(script,&surfnum); break; + } + } + + if (!skinfn) { + initprintf("Error: missing 'skin filename' for skin definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,skintokptr)); + break; + } + + if (seenframe) { modelskin = ++lastmodelskin; } + seenframe = 0; + +#if defined(POLYMOST) && defined(USE_OPENGL) + switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), surfnum)) { + case 0: break; + case -1: break; // invalid model id!? + case -2: initprintf("Invalid skin filename on line %s:%d\n", + script->filename, scriptfile_getlinum(script,skintokptr)); + break; + case -3: initprintf("Invalid palette number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,skintokptr)); + break; + case -4: initprintf("Out of memory on line %s:%d\n", + script->filename, scriptfile_getlinum(script,skintokptr)); + break; + } +#endif + } break; + case T_HUD: + { + char *hudtokptr = script->ltextptr; + char happy=1, *frameend; + int ftilenume = -1, ltilenume = -1, tilex = 0, flags = 0; + double xadd = 0.0, yadd = 0.0, zadd = 0.0, angadd = 0.0; + + if (scriptfile_getbraces(script,&frameend)) break; + while (script->textptr < frameend) { + switch(getatoken(script,modelhudtokens,sizeof(modelhudtokens)/sizeof(tokenlist))) { + case T_TILE: scriptfile_getsymbol(script,&ftilenume); ltilenume = ftilenume; break; + case T_TILE0: scriptfile_getsymbol(script,&ftilenume); break; //first tile number + case T_TILE1: scriptfile_getsymbol(script,<ilenume); break; //last tile number (inclusive) + case T_XADD: scriptfile_getdouble(script,&xadd); break; + case T_YADD: scriptfile_getdouble(script,&yadd); break; + case T_ZADD: scriptfile_getdouble(script,&zadd); break; + case T_ANGADD:scriptfile_getdouble(script,&angadd); break; + case T_HIDE: flags |= 1; break; + case T_NOBOB: flags |= 2; break; + case T_FLIPPED: flags |= 4; break; + case T_NODEPTH: flags |= 8; break; + } + } + + if (ftilenume < 0) initprintf("Error: missing 'first tile number' for hud definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,hudtokptr)), happy = 0; + if (ltilenume < 0) initprintf("Error: missing 'last tile number' for hud definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,hudtokptr)), happy = 0; + if (!happy) break; + + if (ltilenume < ftilenume) { + initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,hudtokptr)); + tilex = ftilenume; + ftilenume = ltilenume; + ltilenume = tilex; + } + + if (lastmodelid < 0) { + initprintf("Warning: Ignoring frame definition.\n"); + break; + } +#if defined(POLYMOST) && defined(USE_OPENGL) + for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { + switch (md_definehud(lastmodelid, tilex, xadd, yadd, zadd, angadd, flags)) { + case 0: break; + case -1: happy = 0; break; // invalid model id!? + case -2: initprintf("Invalid tile number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,hudtokptr)); + happy = 0; + break; + case -3: initprintf("Invalid frame name on line %s:%d\n", + script->filename, scriptfile_getlinum(script,hudtokptr)); + happy = 0; + break; + } + } +#endif + } break; + } + } + +#if defined(POLYMOST) && defined(USE_OPENGL) + md_setmisc(lastmodelid,(float)scale,shadeoffs,(float)mzadd); +#endif + + modelskin = lastmodelskin = 0; + seenframe = 0; + + } + break; + case T_VOXEL: + { + char *voxeltokptr = script->ltextptr; + char *fn, *modelend; + int tile0 = MAXTILES, tile1 = -1, tilex = -1; + + if (scriptfile_getstring(script,&fn)) break; //voxel filename + if (nextvoxid == MAXVOXELS) { initprintf("Maximum number of voxels already defined.\n"); break; } +#ifdef SUPERBUILD + if (qloadkvx(nextvoxid, fn)) { initprintf("Failure loading voxel file \"%s\"\n",fn); break; } + lastvoxid = nextvoxid++; +#endif + + if (scriptfile_getbraces(script,&modelend)) break; + while (script->textptr < modelend) { + switch (getatoken(script,voxeltokens,sizeof(voxeltokens)/sizeof(tokenlist))) { + //case T_ERROR: initprintf("Error on line %s:%d in voxel tokens\n", script->filename,linenum); break; + case T_TILE: + scriptfile_getsymbol(script,&tilex); +#ifdef SUPERBUILD + if ((unsigned long)tilex < MAXTILES) tiletovox[tilex] = lastvoxid; + else initprintf("Invalid tile number on line %s:%d\n",script->filename, scriptfile_getlinum(script,voxeltokptr)); +#endif + break; + case T_TILE0: + scriptfile_getsymbol(script,&tile0); break; //1st tile # + case T_TILE1: + scriptfile_getsymbol(script,&tile1); + if (tile0 > tile1) + { + initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,voxeltokptr)); + tilex = tile0; tile0 = tile1; tile1 = tilex; + } + if ((tile1 < 0) || (tile0 >= MAXTILES)) + { initprintf("Invalid tile range on line %s:%d\n",script->filename, scriptfile_getlinum(script,voxeltokptr)); break; } +#ifdef SUPERBUILD + for(tilex=tile0;tilex<=tile1;tilex++) tiletovox[tilex] = lastvoxid; +#endif + break; //last tile number (inclusive) + case T_SCALE: { + double scale=1.0; + scriptfile_getdouble(script,&scale); +#ifdef SUPERBUILD + voxscale[lastvoxid] = 65536*scale; +#endif + break; + } + } + } + lastvoxid = -1; + } + break; + case T_SKYBOX: + { + char *skyboxtokptr = script->ltextptr; + char *fn[6] = {0,0,0,0,0,0}, *modelend, happy=1; + int i, tile = -1, pal = 0; + + if (scriptfile_getbraces(script,&modelend)) break; + while (script->textptr < modelend) { + switch (getatoken(script,skyboxtokens,sizeof(skyboxtokens)/sizeof(tokenlist))) { + //case T_ERROR: initprintf("Error on line %s:%d in skybox tokens\n",script->filename,linenum); break; + case T_TILE: scriptfile_getsymbol(script,&tile ); break; + case T_PAL: scriptfile_getsymbol(script,&pal ); break; + case T_FRONT: scriptfile_getstring(script,&fn[0]); break; + case T_RIGHT: scriptfile_getstring(script,&fn[1]); break; + case T_BACK: scriptfile_getstring(script,&fn[2]); break; + case T_LEFT: scriptfile_getstring(script,&fn[3]); break; + case T_TOP: scriptfile_getstring(script,&fn[4]); break; + case T_BOTTOM:scriptfile_getstring(script,&fn[5]); break; + } + } + + if (tile < 0) initprintf("Error: missing 'tile number' for skybox definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy=0; + for (i=0;i<6;i++) { + if (!fn[i]) initprintf("Error: missing '%s filename' for skybox definition near line %s:%d\n", skyfaces[i], script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy = 0; + } + + if (!happy) break; + + hicsetskybox(tile,pal,fn); + } + break; + case T_TINT: + { + char *tinttokptr = script->ltextptr; + int red=255, green=255, blue=255, pal=-1, flags=0; + char *tintend; + + if (scriptfile_getbraces(script,&tintend)) break; + while (script->textptr < tintend) { + switch (getatoken(script,tinttokens,sizeof(tinttokens)/sizeof(tokenlist))) { + case T_PAL: scriptfile_getsymbol(script,&pal); break; + case T_RED: scriptfile_getnumber(script,&red); red = min(255,max(0,red)); break; + case T_GREEN: scriptfile_getnumber(script,&green); green = min(255,max(0,green)); break; + case T_BLUE: scriptfile_getnumber(script,&blue); blue = min(255,max(0,blue)); break; + case T_FLAGS: scriptfile_getsymbol(script,&flags); break; + } + } + + if (pal < 0) { + initprintf("Error: missing 'palette number' for tint definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); + break; + } + + hicsetpalettetint(pal,red,green,blue,flags); + } + break; + case T_TEXTURE: + { + char *texturetokptr = script->ltextptr, *textureend; + int tile=-1; + + if (scriptfile_getsymbol(script,&tile)) break; + if (scriptfile_getbraces(script,&textureend)) break; + while (script->textptr < textureend) { + switch (getatoken(script,texturetokens,sizeof(texturetokens)/sizeof(tokenlist))) { + case T_PAL: { + char *paltokptr = script->ltextptr, *palend; + int pal=-1; + char *fn = NULL; + double alphacut = -1.0; + char flags = 0; + + if (scriptfile_getsymbol(script,&pal)) break; + if (scriptfile_getbraces(script,&palend)) break; + while (script->textptr < palend) { + switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) { + case T_FILE: scriptfile_getstring(script,&fn); break; + case T_ALPHACUT: scriptfile_getdouble(script,&alphacut); break; + case T_NOCOMPRESS: flags |= 1; break; + default: break; + } + } + + if ((unsigned)tile > (unsigned)MAXTILES) break; // message is printed later + if ((unsigned)pal > (unsigned)MAXPALOOKUPS) { + initprintf("Error: missing or invalid 'palette number' for texture definition near " + "line %s:%d\n", script->filename, scriptfile_getlinum(script,paltokptr)); + break; + } + if (!fn) { + initprintf("Error: missing 'file name' for texture definition near line %s:%d\n", + script->filename, scriptfile_getlinum(script,paltokptr)); + break; + } + hicsetsubsttex(tile,pal,fn,alphacut,flags); + } break; + default: break; + } + } + + if ((unsigned)tile >= (unsigned)MAXTILES) { + initprintf("Error: missing or invalid 'tile number' for texture definition near line %s:%d\n", + script->filename, scriptfile_getlinum(script,texturetokptr)); + break; + } + } + break; + + case T_UNDEFMODEL: + case T_UNDEFMODELRANGE: + { + int r0,r1; + + if (scriptfile_getsymbol(script,&r0)) break; + if (tokn == T_UNDEFMODELRANGE) { + if (scriptfile_getsymbol(script,&r1)) break; + if (r1 < r0) { + int t = r1; + r1 = r0; + r0 = t; + initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); + } + if (r0 < 0 || r1 >= MAXTILES) { + initprintf("Error: invalid tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + } else { + r1 = r0; + if ((unsigned)r0 >= (unsigned)MAXTILES) { + initprintf("Error: invalid tile number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + } +#if defined(POLYMOST) && defined(USE_OPENGL) + for (; r0 <= r1; r0++) md_undefinetile(r0); +#endif + } + break; + + case T_UNDEFMODELOF: + { + int mid,r0; + + if (scriptfile_getsymbol(script,&r0)) break; + if ((unsigned)r0 >= (unsigned)MAXTILES) { + initprintf("Error: invalid tile number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + +#if defined(POLYMOST) && defined(USE_OPENGL) + mid = md_tilehasmodel(r0); + if (mid < 0) break; + + md_undefinemodel(mid); +#endif + } + break; + + case T_UNDEFTEXTURE: + case T_UNDEFTEXTURERANGE: + { + int r0,r1,i; + + if (scriptfile_getsymbol(script,&r0)) break; + if (tokn == T_UNDEFTEXTURERANGE) { + if (scriptfile_getsymbol(script,&r1)) break; + if (r1 < r0) { + int t = r1; + r1 = r0; + r0 = t; + initprintf("Warning: backwards tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); + } + if (r0 < 0 || r1 >= MAXTILES) { + initprintf("Error: invalid tile range on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + } else { + r1 = r0; + if ((unsigned)r0 >= (unsigned)MAXTILES) { + initprintf("Error: invalid tile number on line %s:%d\n", script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + } + + for (; r0 <= r1; r0++) + for (i=MAXPALOOKUPS-1; i>=0; i--) + hicclearsubst(r0,i); + } + break; + + default: + initprintf("Unknown token.\n"); break; + } + } + return 0; +} + + +int loaddefinitionsfile(char *fn) +{ + scriptfile *script; + + script = scriptfile_fromfile(fn); + if (!script) return -1; + + defsparser(script); + + scriptfile_close(script); + scriptfile_clearsymbols(); + + return 0; +} + +// vim:ts=4: diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c new file mode 100644 index 000000000..539b9832a --- /dev/null +++ b/polymer/build/src/engine.c @@ -0,0 +1,11240 @@ +// "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) + + +//#define POLYMOST +//#define SUPERBUILD +#define ENGINE + +#include "compat.h" +#include "build.h" +#include "pragmas.h" +#include "cache1d.h" +#include "a.h" +#include "osd.h" +#include "crc32.h" + +#include "baselayer.h" + +#ifdef POLYMOST +# ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN +# include +# endif +# ifdef USE_OPENGL +# include "glbuild.h" +# endif +#endif + +#include + +#define MAXCLIPNUM 1024 +#define MAXPERMS 512 +#define MAXTILEFILES 256 +#define MAXYSAVES ((MAXXDIM*MAXSPRITES)>>7) +#define MAXNODESPERLINE 42 //Warning: This depends on MAXYSAVES & MAXYDIM! +#define MAXWALLSB 2048 +#define MAXCLIPDIST 1024 + + +void *kmalloc(bsize_t size) { return(Bmalloc(size)); } +#define kkmalloc kmalloc + +void kfree(void *buffer) { Bfree(buffer); } +#define kkfree kfree + +#ifdef SUPERBUILD +void loadvoxel(long voxindex) { voxindex=0; } +long tiletovox[MAXTILES]; +long usevoxels = 1; +#define kloadvoxel loadvoxel + +long novoxmips = 0; +long editorgridextent = 131072; + + //These variables need to be copied into BUILD +#define MAXXSIZ 256 +#define MAXYSIZ 256 +#define MAXZSIZ 255 +#define MAXVOXMIPS 5 +long voxoff[MAXVOXELS][MAXVOXMIPS]; char voxlock[MAXVOXELS][MAXVOXMIPS]; +long voxscale[MAXVOXELS]; + +static long ggxinc[MAXXSIZ+1], ggyinc[MAXXSIZ+1]; +static long lowrecip[1024], nytooclose, nytoofar; +static unsigned long distrecip[65536]; +#endif + +static long *lookups = NULL; +static char lookupsalloctype = 255; +long dommxoverlay = 1, beforedrawrooms = 1; + +static long oxdimen = -1, oviewingrange = -1, oxyaspect = -1; + +long curbrightness = 0, gammabrightness = 0; + + //Textured Map variables +static char globalpolytype; +static short *dotp1[MAXYDIM], *dotp2[MAXYDIM]; + +static unsigned char tempbuf[MAXWALLS]; + +long ebpbak, espbak; +long slopalookup[16384]; // was 2048 +#if defined(USE_OPENGL) +static palette_t palookupfog[MAXPALOOKUPS]; +#endif + +static char permanentlock = 255; +long artversion, mapversion=7L; // JBF 20040211: default mapversion to 7 +void *pic = NULL; +char picsiz[MAXTILES], tilefilenum[MAXTILES]; +long lastageclock; +long tilefileoffs[MAXTILES]; + +long artsize = 0, cachesize = 0; + +static short radarang[1280], radarang2[MAXXDIM]; +static unsigned short sqrtable[4096], shlookup[4096+256]; +char pow2char[8] = {1,2,4,8,16,32,64,128}; +long pow2long[32] = +{ + 1L,2L,4L,8L, + 16L,32L,64L,128L, + 256L,512L,1024L,2048L, + 4096L,8192L,16384L,32768L, + 65536L,131072L,262144L,524288L, + 1048576L,2097152L,4194304L,8388608L, + 16777216L,33554432L,67108864L,134217728L, + 268435456L,536870912L,1073741824L,2147483647L +}; +long reciptable[2048], fpuasm; + +char britable[16][256]; // JBF 20040207: full 8bit precision +//char textfont[1024], smalltextfont[1024]; +#include "textfont.c" +#include "smalltextfont.c" + +static char kensmessage[128]; +char *engineerrstr = "No error"; + + +#if defined(NOASM) + +static inline unsigned long nsqrtasm(unsigned long a) +{ // JBF 20030901: This was a damn lot simpler to reverse engineer than + // msqrtasm was. Really, it was just like simplifying an algebra equation. + unsigned short c; + + if (a & 0xff000000) { // test eax, 0xff000000 / jnz short over24 + c = shlookup[(a >> 24) + 4096]; // mov ebx, eax + // over24: shr ebx, 24 + // mov cx, word ptr shlookup[ebx*2+8192] + } else { + c = shlookup[a >> 12]; // mov ebx, eax + // shr ebx, 12 + // mov cx, word ptr shlookup[ebx*2] + // jmp short under24 + } + a >>= c&0xff; // under24: shr eax, cl + a = (a&0xffff0000)|(sqrtable[a]); // mov ax, word ptr sqrtable[eax*2] + a >>= ((c&0xff00) >> 8); // mov cl, ch + // shr eax, cl + return a; +} + +static inline long msqrtasm(unsigned long c) +{ + unsigned long a,b; + + a = 0x40000000l; // mov eax, 0x40000000 + b = 0x20000000l; // mov ebx, 0x20000000 + do { // begit: + if (c >= a) { // cmp ecx, eax / jl skip + c -= a; // sub ecx, eax + a += b*4; // lea eax, [eax+ebx*4] + } // skip: + a -= b; // sub eax, ebx + a >>= 1; // shr eax, 1 + b >>= 2; // shr ebx, 2 + } while (b); // jnz begit + if (c >= a) // cmp ecx, eax + a++; // sbb eax, -1 + a >>= 1; // shr eax, 1 + return a; +} + +static inline void setgotpic(long tilenume) +{ + if (walock[tilenume] < 200) walock[tilenume] = 199; + gotpic[tilenume>>3] |= pow2char[tilenume&7]; +} + +static inline long krecipasm(long i) +{ // Ken did this + float f = (float)i; i = *(long *)&f; + return((reciptable[(i>>12)&2047]>>(((i-0x3f800000)>>23)&31))^(i>>31)); +} + + +static inline long getclipmask(long a, long b, long c, long d) +{ // Ken did this + d = ((a<0)*8) + ((b<0)*4) + ((c<0)*2) + (d<0); + return(((d<<4)^0xf0)|d); +} + +inline long getkensmessagecrc(long b) +{ + return 0x56c764d4l; + b=b; +} + +#elif defined(__WATCOMC__) + +// +// Watcom Inline Assembly Routines +// + +#pragma aux nsqrtasm =\ + "test eax, 0xff000000",\ + "mov ebx, eax",\ + "jnz short over24",\ + "shr ebx, 12",\ + "mov cx, word ptr shlookup[ebx*2]",\ + "jmp short under24",\ + "over24: shr ebx, 24",\ + "mov cx, word ptr shlookup[ebx*2+8192]",\ + "under24: shr eax, cl",\ + "mov cl, ch",\ + "mov ax, word ptr sqrtable[eax*2]",\ + "shr eax, cl",\ + parm nomemory [eax]\ + modify exact [eax ebx ecx] +unsigned long nsqrtasm(unsigned long); + +#pragma aux msqrtasm =\ + "mov eax, 0x40000000",\ + "mov ebx, 0x20000000",\ + "begit: cmp ecx, eax",\ + "jl skip",\ + "sub ecx, eax",\ + "lea eax, [eax+ebx*4]",\ + "skip: sub eax, ebx",\ + "shr eax, 1",\ + "shr ebx, 2",\ + "jnz begit",\ + "cmp ecx, eax",\ + "sbb eax, -1",\ + "shr eax, 1",\ + parm nomemory [ecx]\ + modify exact [eax ebx ecx] +long msqrtasm(unsigned long); + + //0x007ff000 is (11<<13), 0x3f800000 is (127<<23) +#pragma aux krecipasm =\ + "mov fpuasm, eax",\ + "fild dword ptr fpuasm",\ + "add eax, eax",\ + "fstp dword ptr fpuasm",\ + "sbb ebx, ebx",\ + "mov eax, fpuasm",\ + "mov ecx, eax",\ + "and eax, 0x007ff000",\ + "shr eax, 10",\ + "sub ecx, 0x3f800000",\ + "shr ecx, 23",\ + "mov eax, dword ptr reciptable[eax]",\ + "sar eax, cl",\ + "xor eax, ebx",\ + parm [eax]\ + modify exact [eax ebx ecx] +long krecipasm(long); + +#pragma aux setgotpic =\ + "mov ebx, eax",\ + "cmp byte ptr walock[eax], 200",\ + "jae skipit",\ + "mov byte ptr walock[eax], 199",\ + "skipit: shr eax, 3",\ + "and ebx, 7",\ + "mov dl, byte ptr gotpic[eax]",\ + "mov bl, byte ptr pow2char[ebx]",\ + "or dl, bl",\ + "mov byte ptr gotpic[eax], dl",\ + parm [eax]\ + modify exact [eax ebx ecx edx] +void setgotpic(long); + +#pragma aux getclipmask =\ + "sar eax, 31",\ + "add ebx, ebx",\ + "adc eax, eax",\ + "add ecx, ecx",\ + "adc eax, eax",\ + "add edx, edx",\ + "adc eax, eax",\ + "mov ebx, eax",\ + "shl ebx, 4",\ + "or al, 0xf0",\ + "xor eax, ebx",\ + parm [eax][ebx][ecx][edx]\ + modify exact [eax ebx ecx edx] +long getclipmask(long,long,long,long); + +#pragma aux getkensmessagecrc =\ + "xor eax, eax",\ + "mov ecx, 32",\ + "beg: mov edx, dword ptr [ebx+ecx*4-4]",\ + "ror edx, cl",\ + "adc eax, edx",\ + "bswap eax",\ + "loop short beg",\ + parm [ebx]\ + modify exact [eax ebx ecx edx] +long getkensmessagecrc(long); + +#elif defined(_MSC_VER) // __WATCOMC__ + +// +// Microsoft C Inline Assembly Routines +// + +static inline long nsqrtasm(long a) +{ + _asm { + push ebx + mov eax, a + test eax, 0xff000000 + mov ebx, eax + jnz short over24 + shr ebx, 12 + mov cx, word ptr shlookup[ebx*2] + jmp short under24 + over24: + shr ebx, 24 + mov cx, word ptr shlookup[ebx*2+8192] + under24: + shr eax, cl + mov cl, ch + mov ax, word ptr sqrtable[eax*2] + shr eax, cl + pop ebx + } +} + +static inline long msqrtasm(long c) +{ + _asm { + push ebx + mov ecx, c + mov eax, 0x40000000 + mov ebx, 0x20000000 + begit: + cmp ecx, eax + jl skip + sub ecx, eax + lea eax, [eax+ebx*4] + skip: + sub eax, ebx + shr eax, 1 + shr ebx, 2 + jnz begit + cmp ecx, eax + sbb eax, -1 + shr eax, 1 + pop ebx + } +} + + //0x007ff000 is (11<<13), 0x3f800000 is (127<<23) +static inline long krecipasm(long a) +{ + _asm { + push ebx + mov eax, a + mov fpuasm, eax + fild dword ptr fpuasm + add eax, eax + fstp dword ptr fpuasm + sbb ebx, ebx + mov eax, fpuasm + mov ecx, eax + and eax, 0x007ff000 + shr eax, 10 + sub ecx, 0x3f800000 + shr ecx, 23 + mov eax, dword ptr reciptable[eax] + sar eax, cl + xor eax, ebx + pop ebx + } +} + +static inline void setgotpic(long a) +{ + _asm { + push ebx + mov eax, a + mov ebx, eax + cmp byte ptr walock[eax], 200 + jae skipit + mov byte ptr walock[eax], 199 + skipit: + shr eax, 3 + and ebx, 7 + mov dl, byte ptr gotpic[eax] + mov bl, byte ptr pow2char[ebx] + or dl, bl + mov byte ptr gotpic[eax], dl + pop ebx + } +} + +static inline long getclipmask(long a, long b, long c, long d) +{ + _asm { + push ebx + mov eax, a + mov ebx, b + mov ecx, c + mov edx, d + sar eax, 31 + add ebx, ebx + adc eax, eax + add ecx, ecx + adc eax, eax + add edx, edx + adc eax, eax + mov ebx, eax + shl ebx, 4 + or al, 0xf0 + xor eax, ebx + pop ebx + } +} + +static inline long getkensmessagecrc(void *b) +{ + _asm { + push ebx + mov ebx, b + xor eax, eax + mov ecx, 32 + beg: + mov edx, dword ptr [ebx+ecx*4-4] + ror edx, cl + adc eax, edx + bswap eax + loop short beg + pop ebx + } +} + +#elif defined(__GNUC__) && defined(__i386__) // _MSC_VER + +// +// GCC "Inline" Assembly Routines +// + +#define nsqrtasm(a) \ + ({ long __r, __a=(a); \ + __asm__ __volatile__ ( \ + "testl $0xff000000, %%eax\n\t" \ + "movl %%eax, %%ebx\n\t" \ + "jnz 0f\n\t" \ + "shrl $12, %%ebx\n\t" \ + "movw "ASMSYM("shlookup")"(,%%ebx,2), %%cx\n\t" \ + "jmp 1f\n\t" \ + "0:\n\t" \ + "shrl $24, %%ebx\n\t" \ + "movw ("ASMSYM("shlookup")"+8192)(,%%ebx,2), %%cx\n\t" \ + "1:\n\t" \ + "shrl %%cl, %%eax\n\t" \ + "movb %%ch, %%cl\n\t" \ + "movw "ASMSYM("sqrtable")"(,%%eax,2), %%ax\n\t" \ + "shrl %%cl, %%eax" \ + : "=a" (__r) : "a" (__a) : "ebx", "ecx", "cc"); \ + __r; }) + + // edx is blown by this code somehow?! +#define msqrtasm(c) \ + ({ long __r, __c=(c); \ + __asm__ __volatile__ ( \ + "movl $0x40000000, %%eax\n\t" \ + "movl $0x20000000, %%ebx\n\t" \ + "0:\n\t" \ + "cmpl %%eax, %%ecx\n\t" \ + "jl 1f\n\t" \ + "subl %%eax, %%ecx\n\t" \ + "leal (%%eax,%%ebx,4), %%eax\n\t" \ + "1:\n\t" \ + "subl %%ebx, %%eax\n\t" \ + "shrl $1, %%eax\n\t" \ + "shrl $2, %%ebx\n\t" \ + "jnz 0b\n\t" \ + "cmpl %%eax, %%ecx\n\t" \ + "sbbl $-1, %%eax\n\t" \ + "shrl $1, %%eax" \ + : "=a" (__r) : "c" (__c) : "edx","ebx", "cc"); \ + __r; }) + +#define setgotpic(a) \ + ({ long __a=(a); \ + __asm__ __volatile__ ( \ + "movl %%eax, %%ebx\n\t" \ + "cmpb $200, "ASMSYM("walock")"(%%eax)\n\t" \ + "jae 0f\n\t" \ + "movb $199, "ASMSYM("walock")"(%%eax)\n\t" \ + "0:\n\t" \ + "shrl $3, %%eax\n\t" \ + "andl $7, %%ebx\n\t" \ + "movb "ASMSYM("gotpic")"(%%eax), %%dl\n\t" \ + "movb "ASMSYM("pow2char")"(%%ebx), %%bl\n\t" \ + "orb %%bl, %%dl\n\t" \ + "movb %%dl, "ASMSYM("gotpic")"(%%eax)" \ + : "=a" (__a) : "a" (__a) \ + : "ebx", "edx", "memory", "cc"); \ + __a; }) + +#define krecipasm(a) \ + ({ long __a=(a); \ + __asm__ __volatile__ ( \ + "movl %%eax, ("ASMSYM("fpuasm")"); fildl ("ASMSYM("fpuasm")"); " \ + "addl %%eax, %%eax; fstps ("ASMSYM("fpuasm")"); sbbl %%ebx, %%ebx; " \ + "movl ("ASMSYM("fpuasm")"), %%eax; movl %%eax, %%ecx; " \ + "andl $0x007ff000, %%eax; shrl $10, %%eax; subl $0x3f800000, %%ecx; " \ + "shrl $23, %%ecx; movl "ASMSYM("reciptable")"(%%eax), %%eax; " \ + "sarl %%cl, %%eax; xorl %%ebx, %%eax" \ + : "=a" (__a) : "a" (__a) : "ebx", "ecx", "memory", "cc"); \ + __a; }) + +#define getclipmask(a,b,c,d) \ + ({ long __a=(a), __b=(b), __c=(c), __d=(d); \ + __asm__ __volatile__ ("sarl $31, %%eax; addl %%ebx, %%ebx; adcl %%eax, %%eax; " \ + "addl %%ecx, %%ecx; adcl %%eax, %%eax; addl %%edx, %%edx; " \ + "adcl %%eax, %%eax; movl %%eax, %%ebx; shl $4, %%ebx; " \ + "orb $0xf0, %%al; xorl %%ebx, %%eax" \ + : "=a" (__a), "=b" (__b), "=c" (__c), "=d" (__d) \ + : "a" (__a), "b" (__b), "c" (__c), "d" (__d) : "cc"); \ + __a; }) + + +#define getkensmessagecrc(b) \ + ({ long __a, __b=(b); \ + __asm__ __volatile__ ( \ + "xorl %%eax, %%eax\n\t" \ + "movl $32, %%ecx\n\t" \ + "0:\n\t" \ + "movl -4(%%ebx,%%ecx,4), %%edx\n\t" \ + "rorl %%cl, %%edx\n\t" \ + "adcl %%edx, %%eax\n\t" \ + "bswapl %%eax\n\t" \ + "loop 0b" \ + : "=a" (__a) : "b" (__b) : "ecx", "edx" \ + __a; }) + +#else // __GNUC__ && __i386__ + +#error Unsupported compiler or architecture. + +#endif + + +static long xb1[MAXWALLSB], yb1[MAXWALLSB], xb2[MAXWALLSB], yb2[MAXWALLSB]; +static long rx1[MAXWALLSB], ry1[MAXWALLSB], rx2[MAXWALLSB], ry2[MAXWALLSB]; +static short p2[MAXWALLSB], thesector[MAXWALLSB], thewall[MAXWALLSB]; + +static short bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; + +static short smost[MAXYSAVES], smostcnt; +static short smoststart[MAXWALLSB]; +static char smostwalltype[MAXWALLSB]; +static long smostwall[MAXWALLSB], smostwallcnt = -1L; + +static short maskwall[MAXWALLSB], maskwallcnt; +static long spritesx[MAXSPRITESONSCREEN]; +static long spritesy[MAXSPRITESONSCREEN+1]; +static long spritesz[MAXSPRITESONSCREEN]; +static spritetype *tspriteptr[MAXSPRITESONSCREEN]; + +short umost[MAXXDIM], dmost[MAXXDIM]; +static short bakumost[MAXXDIM], bakdmost[MAXXDIM]; +short uplc[MAXXDIM], dplc[MAXXDIM]; +static short uwall[MAXXDIM], dwall[MAXXDIM]; +static long swplc[MAXXDIM], lplc[MAXXDIM]; +static long swall[MAXXDIM], lwall[MAXXDIM+4]; +long xdimen = -1, xdimenrecip, halfxdimen, xdimenscale, xdimscale; +long wx1, wy1, wx2, wy2, ydimen; +long /*viewoffset,*/ frameoffset; + +static long nrx1[8], nry1[8], nrx2[8], nry2[8]; // JBF 20031206: Thanks Ken + +static long rxi[8], ryi[8], rzi[8], rxi2[8], ryi2[8], rzi2[8]; +static long xsi[8], ysi[8], *horizlookup=0, *horizlookup2=0, horizycent; + +long globalposx, globalposy, globalposz, globalhoriz; +short globalang, globalcursectnum; +long globalpal, cosglobalang, singlobalang; +long cosviewingrangeglobalang, sinviewingrangeglobalang; +char *globalpalwritten; +long globaluclip, globaldclip, globvis; +long globalvisibility, globalhisibility, globalpisibility, globalcisibility; +char globparaceilclip, globparaflorclip; + +long xyaspect, viewingrangerecip; + +long asm1, asm2, asm3, asm4; +long vplce[4], vince[4], palookupoffse[4], bufplce[4]; +char globalxshift, globalyshift; +long globalxpanning, globalypanning, globalshade; +short globalpicnum, globalshiftval; +long globalzd, globalbufplc, globalyscale, globalorientation; +long globalx1, globaly1, globalx2, globaly2, globalx3, globaly3, globalzx; +long globalx, globaly, globalz; + +static short sectorborder[256], sectorbordercnt; +static char tablesloaded = 0; +long pageoffset, ydim16, qsetmode = 0; +long startposx, startposy, startposz; +short startang, startsectnum; +short pointhighlight, linehighlight, highlightcnt; +static long lastx[MAXYDIM]; +char *transluc = NULL, paletteloaded = 0; + +long halfxdim16, midydim16; + +#define FASTPALGRIDSIZ 8 +static long rdist[129], gdist[129], bdist[129]; +static char colhere[((FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2))>>3]; +static char colhead[(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)]; +static long colnext[256]; +static char coldist[8] = {0,1,2,3,4,3,2,1}; +static long colscan[27]; + +static short clipnum, hitwalls[4]; +long hitscangoalx = (1<<29)-1, hitscangoaly = (1<<29)-1; +#ifdef POLYMOST +static long hitallsprites = 0; +#endif + +typedef struct { long x1, y1, x2, y2; } linetype; +static linetype clipit[MAXCLIPNUM]; +static short clipsectorlist[MAXCLIPNUM], clipsectnum; +static short clipobjectval[MAXCLIPNUM]; + +typedef struct +{ + long sx, sy, z; + short a, picnum; + signed char dashade; + char dapalnum, dastat, pagesleft; + long cx1, cy1, cx2, cy2; + long uniqid; //JF extension +} permfifotype; +static permfifotype permfifo[MAXPERMS]; +static long permhead = 0, permtail = 0; + +short numscans, numhits, numbunches; +static short posfil, capturecount = 0, hitcnt; + +char vgapal16[4*256] = +{ + 00,00,00,00, 42,00,00,00, 00,42,00,00, 42,42,00,00, 00,00,42,00, + 42,00,42,00, 00,21,42,00, 42,42,42,00, 21,21,21,00, 63,21,21,00, + 21,63,21,00, 63,63,21,00, 21,21,63,00, 63,21,63,00, 21,63,63,00, + 63,63,63,00 +}; + +short editstatus = 0; +short searchit; +long searchx = -1, searchy; //search input +short searchsector, searchwall, searchstat; //search output +double msens = 1.0; + +static char artfilename[20]; +static long numtilefiles, artfil = -1, artfilnum, artfilplc; + +static char inpreparemirror = 0; +static long mirrorsx1, mirrorsy1, mirrorsx2, mirrorsy2; + +static long setviewcnt = 0; // interface layers use this now +static long bakframeplace[4], bakxsiz[4], bakysiz[4]; +static long bakwindowx1[4], bakwindowy1[4]; +static long bakwindowx2[4], bakwindowy2[4]; +#ifdef POLYMOST +static long bakrendmode,baktile; +#endif + +long totalclocklock; + +char apptitle[256] = "Build Engine"; +palette_t curpalette[256]; // the current palette, unadjusted for brightness or tint +palette_t curpalettefaded[256]; // the current palette, adjusted for brightness and tint (ie. what gets sent to the card) +palette_t palfadergb = { 0,0,0,0 }; +char palfadedelta = 0; + + + +// +// Internal Engine Functions +// +//long cacheresets = 0,cacheinvalidates = 0; + + +//============================================================================= //POLYMOST BEGINS +#ifdef POLYMOST +static void scansector(short sectnum); +#include "hightile.c" +#include "polymost.c" +#else +void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) { } +int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut) { return 0; } +int hicsetskybox(long picnum, long palnum, char *faces[6]) { return 0; } +int hicclearsubst(long picnum, long palnum) { return 0; } +long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen) { return -1; } +#endif +//============================================================================= //POLYMOST ENDS + + +// +// getpalookup (internal) +// +static inline long getpalookup(long davis, long dashade) +{ + return(min(max(dashade+(davis>>8),0),numpalookups-1)); +} + + +// +// scansector (internal) +// +static void scansector(short sectnum) +{ + walltype *wal, *wal2; + spritetype *spr; + long xs, ys, x1, y1, x2, y2, xp1, yp1, xp2=0, yp2=0, templong; + short z, zz, startwall, endwall, numscansbefore, scanfirst, bunchfrst; + short nextsectnum; + + if (sectnum < 0) return; + + if (automapping) show2dsector[sectnum>>3] |= pow2char[sectnum&7]; + + sectorborder[0] = sectnum, sectorbordercnt = 1; + do + { + sectnum = sectorborder[--sectorbordercnt]; + + for(z=headspritesect[sectnum];z>=0;z=nextspritesect[z]) + { + spr = &sprite[z]; + if ((((spr->cstat&0x8000) == 0) || (showinvisibility)) && + (spr->xrepeat > 0) && (spr->yrepeat > 0) && + (spritesortcnt < MAXSPRITESONSCREEN)) + { + xs = spr->x-globalposx; ys = spr->y-globalposy; + if ((spr->cstat&48) || (xs*cosglobalang+ys*singlobalang > 0)) + { + copybufbyte(spr,&tsprite[spritesortcnt],sizeof(spritetype)); + tsprite[spritesortcnt++].owner = z; + } + } + } + + gotsector[sectnum>>3] |= pow2char[sectnum&7]; + + bunchfrst = numbunches; + numscansbefore = numscans; + + startwall = sector[sectnum].wallptr; + endwall = startwall + sector[sectnum].wallnum; + scanfirst = numscans; + for(z=startwall,wal=&wall[z];znextsector; + + wal2 = &wall[wal->point2]; + x1 = wal->x-globalposx; y1 = wal->y-globalposy; + x2 = wal2->x-globalposx; y2 = wal2->y-globalposy; + + if ((nextsectnum >= 0) && ((wal->cstat&32) == 0)) + if ((gotsector[nextsectnum>>3]&pow2char[nextsectnum&7]) == 0) + { + templong = x1*y2-x2*y1; + if (((unsigned)templong+262144) < 524288) + if (mulscale5(templong,templong) <= (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) + sectorborder[sectorbordercnt++] = nextsectnum; + } + + if ((z == startwall) || (wall[z-1].point2 != z)) + { + xp1 = dmulscale6(y1,cosglobalang,-x1,singlobalang); + yp1 = dmulscale6(x1,cosviewingrangeglobalang,y1,sinviewingrangeglobalang); + } + else + { + xp1 = xp2; + yp1 = yp2; + } + xp2 = dmulscale6(y2,cosglobalang,-x2,singlobalang); + yp2 = dmulscale6(x2,cosviewingrangeglobalang,y2,sinviewingrangeglobalang); + if ((yp1 < 256) && (yp2 < 256)) goto skipitaddwall; + + //If wall's NOT facing you + if (dmulscale32(xp1,yp2,-xp2,yp1) >= 0) goto skipitaddwall; + + if (xp1 >= -yp1) + { + if ((xp1 > yp1) || (yp1 == 0)) goto skipitaddwall; + xb1[numscans] = halfxdimen + scale(xp1,halfxdimen,yp1); + if (xp1 >= 0) xb1[numscans]++; //Fix for SIGNED divide + if (xb1[numscans] >= xdimen) xb1[numscans] = xdimen-1; + yb1[numscans] = yp1; + } + else + { + if (xp2 < -yp2) goto skipitaddwall; + xb1[numscans] = 0; + templong = yp1-yp2+xp1-xp2; + if (templong == 0) goto skipitaddwall; + yb1[numscans] = yp1 + scale(yp2-yp1,xp1+yp1,templong); + } + if (yb1[numscans] < 256) goto skipitaddwall; + + if (xp2 <= yp2) + { + if ((xp2 < -yp2) || (yp2 == 0)) goto skipitaddwall; + xb2[numscans] = halfxdimen + scale(xp2,halfxdimen,yp2) - 1; + if (xp2 >= 0) xb2[numscans]++; //Fix for SIGNED divide + if (xb2[numscans] >= xdimen) xb2[numscans] = xdimen-1; + yb2[numscans] = yp2; + } + else + { + if (xp1 > yp1) goto skipitaddwall; + xb2[numscans] = xdimen-1; + templong = xp2-xp1+yp1-yp2; + if (templong == 0) goto skipitaddwall; + yb2[numscans] = yp1 + scale(yp2-yp1,yp1-xp1,templong); + } + if ((yb2[numscans] < 256) || (xb1[numscans] > xb2[numscans])) goto skipitaddwall; + + //Made it all the way! + thesector[numscans] = sectnum; thewall[numscans] = z; + rx1[numscans] = xp1; ry1[numscans] = yp1; + rx2[numscans] = xp2; ry2[numscans] = yp2; + p2[numscans] = numscans+1; + numscans++; +skipitaddwall: + + if ((wall[z].point2 < z) && (scanfirst < numscans)) + p2[numscans-1] = scanfirst, scanfirst = numscans; + } + + for(z=numscansbefore;z= xb1[p2[z]])) + bunchfirst[numbunches++] = p2[z], p2[z] = -1; + + for(z=bunchfrst;z=0;zz=p2[zz]); + bunchlast[z] = zz; + } + } while (sectorbordercnt > 0); +} + + +// +// maskwallscan (internal) +// +static void maskwallscan(long x1, long x2, short *uwal, short *dwal, long *swal, long *lwal) +{ + long i, x, startx, xnice, ynice, fpalookup; + long y1ve[4], y2ve[4], u4, d4, dax, z, p, tsizx, tsizy; + char bad; + + tsizx = tilesizx[globalpicnum]; + tsizy = tilesizy[globalpicnum]; + setgotpic(globalpicnum); + if ((tsizx <= 0) || (tsizy <= 0)) return; + if ((uwal[x1] > ydimen) && (uwal[x2] > ydimen)) return; + if ((dwal[x1] < 0) && (dwal[x2] < 0)) return; + + if (waloff[globalpicnum] == 0) loadtile(globalpicnum); + + startx = x1; + + xnice = (pow2long[picsiz[globalpicnum]&15] == tsizx); + if (xnice) tsizx = (tsizx-1); + ynice = (pow2long[picsiz[globalpicnum]>>4] == tsizy); + if (ynice) tsizy = (picsiz[globalpicnum]>>4); + + fpalookup = FP_OFF(palookup[globalpal]); + + setupmvlineasm(globalshiftval); + +#ifndef ENGINE_USING_A_C + + x = startx; + while ((startumost[x+windowx1] > startdmost[x+windowx1]) && (x <= x2)) x++; + + p = x+frameoffset; + + for(;(x<=x2)&&(p&3);x++,p++) + { + y1ve[0] = max(uwal[x],startumost[x+windowx1]-windowy1); + y2ve[0] = min(dwal[x],startdmost[x+windowx1]-windowy1); + if (y2ve[0] <= y1ve[0]) continue; + + palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + + bufplce[0] = lwal[x] + globalxpanning; + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; + + vince[0] = swal[x]*globalyscale; + vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1); + + mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],p+ylookup[y1ve[0]]); + } + for(;x<=x2-3;x+=4,p+=4) + { + bad = 0; + for(z=3,dax=x+3;z>=0;z--,dax--) + { + y1ve[z] = max(uwal[dax],startumost[dax+windowx1]-windowy1); + y2ve[z] = min(dwal[dax],startdmost[dax+windowx1]-windowy1)-1; + if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; } + + i = lwal[dax] + globalxpanning; + if (i >= tsizx) { if (xnice == 0) i %= tsizx; else i &= tsizx; } + if (ynice == 0) i *= tsizy; else i <<= tsizy; + bufplce[z] = waloff[globalpicnum]+i; + + vince[z] = swal[dax]*globalyscale; + vplce[z] = globalzd + vince[z]*(y1ve[z]-globalhoriz+1); + } + if (bad == 15) continue; + + palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[3] = fpalookup+(getpalookup((long)mulscale16(swal[x+3],globvis),globalshade)<<8); + + if ((palookupoffse[0] == palookupoffse[3]) && ((bad&0x9) == 0)) + { + palookupoffse[1] = palookupoffse[0]; + palookupoffse[2] = palookupoffse[0]; + } + else + { + palookupoffse[1] = fpalookup+(getpalookup((long)mulscale16(swal[x+1],globvis),globalshade)<<8); + palookupoffse[2] = fpalookup+(getpalookup((long)mulscale16(swal[x+2],globvis),globalshade)<<8); + } + + u4 = max(max(y1ve[0],y1ve[1]),max(y1ve[2],y1ve[3])); + d4 = min(min(y2ve[0],y2ve[1]),min(y2ve[2],y2ve[3])); + + if ((bad > 0) || (u4 >= d4)) + { + if (!(bad&1)) mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0],vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0); + if (!(bad&2)) mvlineasm1(vince[1],palookupoffse[1],y2ve[1]-y1ve[1],vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1); + if (!(bad&4)) mvlineasm1(vince[2],palookupoffse[2],y2ve[2]-y1ve[2],vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2); + if (!(bad&8)) mvlineasm1(vince[3],palookupoffse[3],y2ve[3]-y1ve[3],vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3); + continue; + } + + if (u4 > y1ve[0]) vplce[0] = mvlineasm1(vince[0],palookupoffse[0],u4-y1ve[0]-1,vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0); + if (u4 > y1ve[1]) vplce[1] = mvlineasm1(vince[1],palookupoffse[1],u4-y1ve[1]-1,vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1); + if (u4 > y1ve[2]) vplce[2] = mvlineasm1(vince[2],palookupoffse[2],u4-y1ve[2]-1,vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2); + if (u4 > y1ve[3]) vplce[3] = mvlineasm1(vince[3],palookupoffse[3],u4-y1ve[3]-1,vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3); + + if (d4 >= u4) mvlineasm4(d4-u4+1,ylookup[u4]+p); + + i = p+ylookup[d4+1]; + if (y2ve[0] > d4) mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-d4-1,vplce[0],bufplce[0],i+0); + if (y2ve[1] > d4) mvlineasm1(vince[1],palookupoffse[1],y2ve[1]-d4-1,vplce[1],bufplce[1],i+1); + if (y2ve[2] > d4) mvlineasm1(vince[2],palookupoffse[2],y2ve[2]-d4-1,vplce[2],bufplce[2],i+2); + if (y2ve[3] > d4) mvlineasm1(vince[3],palookupoffse[3],y2ve[3]-d4-1,vplce[3],bufplce[3],i+3); + } + for(;x<=x2;x++,p++) + { + y1ve[0] = max(uwal[x],startumost[x+windowx1]-windowy1); + y2ve[0] = min(dwal[x],startdmost[x+windowx1]-windowy1); + if (y2ve[0] <= y1ve[0]) continue; + + palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + + bufplce[0] = lwal[x] + globalxpanning; + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; + + vince[0] = swal[x]*globalyscale; + vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1); + + mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],p+ylookup[y1ve[0]]); + } + +#else // ENGINE_USING_A_C + + p = startx+frameoffset; + for(x=startx;x<=x2;x++,p++) + { + y1ve[0] = max(uwal[x],startumost[x+windowx1]-windowy1); + y2ve[0] = min(dwal[x],startdmost[x+windowx1]-windowy1); + if (y2ve[0] <= y1ve[0]) continue; + + palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + + bufplce[0] = lwal[x] + globalxpanning; + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; + + vince[0] = swal[x]*globalyscale; + vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1); + + mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],p+ylookup[y1ve[0]]); + } + +#endif + + faketimerhandler(); +} + + +// +// wallfront (internal) +// +static long wallfront(long l1, long l2) +{ + walltype *wal; + long x11, y11, x21, y21, x12, y12, x22, y22, dx, dy, t1, t2; + + wal = &wall[thewall[l1]]; x11 = wal->x; y11 = wal->y; + wal = &wall[wal->point2]; x21 = wal->x; y21 = wal->y; + wal = &wall[thewall[l2]]; x12 = wal->x; y12 = wal->y; + wal = &wall[wal->point2]; x22 = wal->x; y22 = wal->y; + + dx = x21-x11; dy = y21-y11; + t1 = dmulscale2(x12-x11,dy,-dx,y12-y11); //p1(l2) vs. l1 + t2 = dmulscale2(x22-x11,dy,-dx,y22-y11); //p2(l2) vs. l1 + if (t1 == 0) { t1 = t2; if (t1 == 0) return(-1); } + if (t2 == 0) t2 = t1; + if ((t1^t2) >= 0) + { + t2 = dmulscale2(globalposx-x11,dy,-dx,globalposy-y11); //pos vs. l1 + return((t2^t1) >= 0); + } + + dx = x22-x12; dy = y22-y12; + t1 = dmulscale2(x11-x12,dy,-dx,y11-y12); //p1(l1) vs. l2 + t2 = dmulscale2(x21-x12,dy,-dx,y21-y12); //p2(l1) vs. l2 + if (t1 == 0) { t1 = t2; if (t1 == 0) return(-1); } + if (t2 == 0) t2 = t1; + if ((t1^t2) >= 0) + { + t2 = dmulscale2(globalposx-x12,dy,-dx,globalposy-y12); //pos vs. l2 + return((t2^t1) < 0); + } + return(-2); +} + + +// +// spritewallfront (internal) +// +static long spritewallfront(spritetype *s, long w) +{ + walltype *wal; + long x1, y1; + + wal = &wall[w]; x1 = wal->x; y1 = wal->y; + wal = &wall[wal->point2]; + return (dmulscale32(wal->x-x1,s->y-y1,-(s->x-x1),wal->y-y1) >= 0); +} + +// +// spritebehindwall(internal) +// +static long spriteobstructswall(spritetype *s, long w) +{ + walltype *wal; + long x, y; + long x1, y1; + long x2, y2; + double a1, b1, c1; + double a2, b2, c2; + double d1, d2; + + // wall line equation + wal = &wall[w]; x1 = wal->x - globalposx; y1 = wal->y - globalposy; + wal = &wall[wal->point2]; x2 = wal->x - globalposx; y2 = wal->y - globalposy; + if ((x2 - x1) != 0) + a1 = (float)(y2 - y1)/(x2 - x1); + else + a1 = 1e+37; // not infinite, but almost ;) + b1 = -1; + c1 = (y1 - (a1 * x1)); + + // player to sprite line equation + if ((s->x - globalposx) != 0) + a2 = (float)(s->y - globalposy)/(s->x - globalposx); + else + a2 = 1e+37; + b2 = -1; + c2 = 0; + + // intersection point + d1 = (float)(1) / (a1*b2 - a2*b1); + x = ((b1*c2 - b2*c1) * d1); + y = ((a2*c1 - a1*c2) * d1); + + // distance between the sprite and the player + a1 = s->x - globalposx; + b1 = s->y - globalposy; + d1 = (a1 * a1 + b1 * b1); + + // distance between the intersection point and the player + d2 = (x * x + y * y); + + // check if the sprite obstructs the wall + if ((d1 < d2) && (min(x1, x2) <= x) && (x <= max(x1, x2)) && (min(y1, y2) <= y) && (y <= max(y1, y2))) + return (1); + else + return (0); +} + +// +// bunchfront (internal) +// +static long bunchfront(long b1, long b2) +{ + long x1b1, x2b1, x1b2, x2b2, b1f, b2f, i; + + b1f = bunchfirst[b1]; x1b1 = xb1[b1f]; x2b2 = xb2[bunchlast[b2]]+1; + if (x1b1 >= x2b2) return(-1); + b2f = bunchfirst[b2]; x1b2 = xb1[b2f]; x2b1 = xb2[bunchlast[b1]]+1; + if (x1b2 >= x2b1) return(-1); + + if (x1b1 >= x1b2) + { + for(i=b2f;xb2[i] xr) return; + r = horizlookup2[yp-globalhoriz+horizycent]; + asm1 = globalx1*r; + asm2 = globaly2*r; + s = ((long)getpalookup((long)mulscale16(r,globvis),globalshade)<<8); + + hlineasm4(xr-xl,0L,s,globalx2*r+globalypanning,globaly1*r+globalxpanning, + ylookup[yp]+xr+frameoffset); +} + + +// +// slowhline (internal) +// +static void slowhline(long xr, long yp) +{ + long xl, r; + + xl = lastx[yp]; if (xl > xr) return; + r = horizlookup2[yp-globalhoriz+horizycent]; + asm1 = globalx1*r; + asm2 = globaly2*r; + + asm3 = (long)globalpalwritten + ((long)getpalookup((long)mulscale16(r,globvis),globalshade)<<8); + if (!(globalorientation&256)) + { + mhline(globalbufplc,globaly1*r+globalxpanning-asm1*(xr-xl),(xr-xl)<<16,0L, + globalx2*r+globalypanning-asm2*(xr-xl),ylookup[yp]+xl+frameoffset); + return; + } + thline(globalbufplc,globaly1*r+globalxpanning-asm1*(xr-xl),(xr-xl)<<16,0L, + globalx2*r+globalypanning-asm2*(xr-xl),ylookup[yp]+xl+frameoffset); +} + + +// +// prepwall (internal) +// +static void prepwall(long z, walltype *wal) +{ + long i, l=0, ol=0, splc, sinc, x, topinc, top, botinc, bot, walxrepeat; + + walxrepeat = (wal->xrepeat<<3); + + //lwall calculation + i = xb1[z]-halfxdimen; + topinc = -(ry1[z]>>2); + botinc = ((ry2[z]-ry1[z])>>8); + top = mulscale5(rx1[z],xdimen)+mulscale2(topinc,i); + bot = mulscale11(rx1[z]-rx2[z],xdimen)+mulscale2(botinc,i); + + splc = mulscale19(ry1[z],xdimscale); + sinc = mulscale16(ry2[z]-ry1[z],xdimscale); + + x = xb1[z]; + if (bot != 0) + { + l = divscale12(top,bot); + swall[x] = mulscale21(l,sinc)+splc; + l *= walxrepeat; + lwall[x] = (l>>18); + } + while (x+4 <= xb2[z]) + { + top += topinc; bot += botinc; + if (bot != 0) + { + ol = l; l = divscale12(top,bot); + swall[x+4] = mulscale21(l,sinc)+splc; + l *= walxrepeat; + lwall[x+4] = (l>>18); + } + i = ((ol+l)>>1); + lwall[x+2] = (i>>18); + lwall[x+1] = ((ol+i)>>19); + lwall[x+3] = ((l+i)>>19); + swall[x+2] = ((swall[x]+swall[x+4])>>1); + swall[x+1] = ((swall[x]+swall[x+2])>>1); + swall[x+3] = ((swall[x+4]+swall[x+2])>>1); + x += 4; + } + if (x+2 <= xb2[z]) + { + top += (topinc>>1); bot += (botinc>>1); + if (bot != 0) + { + ol = l; l = divscale12(top,bot); + swall[x+2] = mulscale21(l,sinc)+splc; + l *= walxrepeat; + lwall[x+2] = (l>>18); + } + lwall[x+1] = ((l+ol)>>19); + swall[x+1] = ((swall[x]+swall[x+2])>>1); + x += 2; + } + if (x+1 <= xb2[z]) + { + bot += (botinc>>2); + if (bot != 0) + { + l = divscale12(top+(topinc>>2),bot); + swall[x+1] = mulscale21(l,sinc)+splc; + lwall[x+1] = mulscale18(l,walxrepeat); + } + } + + if (lwall[xb1[z]] < 0) lwall[xb1[z]] = 0; + if ((lwall[xb2[z]] >= walxrepeat) && (walxrepeat)) lwall[xb2[z]] = walxrepeat-1; + if (wal->cstat&8) + { + walxrepeat--; + for(x=xb1[z];x<=xb2[z];x++) lwall[x] = walxrepeat-lwall[x]; + } +} + + +// +// animateoffs (internal) +// +static long animateoffs(short tilenum, short fakevar) +{ + long i, k, offs; + + offs = 0; + i = (totalclocklock>>((picanm[tilenum]>>24)&15)); + if ((picanm[tilenum]&63) > 0) + { + switch(picanm[tilenum]&192) + { + case 64: + k = (i%((picanm[tilenum]&63)<<1)); + if (k < (picanm[tilenum]&63)) + offs = k; + else + offs = (((picanm[tilenum]&63)<<1)-k); + break; + case 128: + offs = (i%((picanm[tilenum]&63)+1)); + break; + case 192: + offs = -(i%((picanm[tilenum]&63)+1)); + } + } + return(offs); +} + + +// +// owallmost (internal) +// +static long owallmost(short *mostbuf, long w, long z) +{ + long bad, inty, xcross, y, yinc; + long s1, s2, s3, s4, ix1, ix2, iy1, iy2, t; + long i; + + z <<= 7; + s1 = mulscale20(globaluclip,yb1[w]); s2 = mulscale20(globaluclip,yb2[w]); + s3 = mulscale20(globaldclip,yb1[w]); s4 = mulscale20(globaldclip,yb2[w]); + bad = (zs3)<<2)+((z>s4)<<3); + + ix1 = xb1[w]; iy1 = yb1[w]; + ix2 = xb2[w]; iy2 = yb2[w]; + + if ((bad&3) == 3) + { + //clearbufbyte(&mostbuf[ix1],(ix2-ix1+1)*sizeof(mostbuf[0]),0L); + for (i=ix1; i<=ix2; i++) mostbuf[i] = 0; + return(bad); + } + + if ((bad&12) == 12) + { + //clearbufbyte(&mostbuf[ix1],(ix2-ix1+1)*sizeof(mostbuf[0]),ydimen+(ydimen<<16)); + for (i=ix1; i<=ix2; i++) mostbuf[i] = ydimen; + return(bad); + } + + if (bad&3) + { + t = divscale30(z-s1,s2-s1); + inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); + xcross = xb1[w] + scale(mulscale30(yb2[w],t),xb2[w]-xb1[w],inty); + + if ((bad&3) == 2) + { + if (xb1[w] <= xcross) { iy2 = inty; ix2 = xcross; } + //clearbufbyte(&mostbuf[xcross+1],(xb2[w]-xcross)*sizeof(mostbuf[0]),0L); + for (i=xcross+1; i<=xb2[w]; i++) mostbuf[i] = 0; + } + else + { + if (xcross <= xb2[w]) { iy1 = inty; ix1 = xcross; } + //clearbufbyte(&mostbuf[xb1[w]],(xcross-xb1[w]+1)*sizeof(mostbuf[0]),0L); + for (i=xb1[w]; i<=xcross; i++) mostbuf[i] = 0; + } + } + + if (bad&12) + { + t = divscale30(z-s3,s4-s3); + inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); + xcross = xb1[w] + scale(mulscale30(yb2[w],t),xb2[w]-xb1[w],inty); + + if ((bad&12) == 8) + { + if (xb1[w] <= xcross) { iy2 = inty; ix2 = xcross; } + //clearbufbyte(&mostbuf[xcross+1],(xb2[w]-xcross)*sizeof(mostbuf[0]),ydimen+(ydimen<<16)); + for (i=xcross+1; i<=xb2[w]; i++) mostbuf[i] = ydimen; + } + else + { + if (xcross <= xb2[w]) { iy1 = inty; ix1 = xcross; } + //clearbufbyte(&mostbuf[xb1[w]],(xcross-xb1[w]+1)*sizeof(mostbuf[0]),ydimen+(ydimen<<16)); + for (i=xb1[w]; i<=xcross; i++) mostbuf[i] = ydimen; + } + } + + y = (scale(z,xdimenscale,iy1)<<4); + yinc = ((scale(z,xdimenscale,iy2)<<4)-y) / (ix2-ix1+1); + qinterpolatedown16short((long)&mostbuf[ix1],ix2-ix1+1,y+(globalhoriz<<16),yinc); + + if (mostbuf[ix1] < 0) mostbuf[ix1] = 0; + if (mostbuf[ix1] > ydimen) mostbuf[ix1] = ydimen; + if (mostbuf[ix2] < 0) mostbuf[ix2] = 0; + if (mostbuf[ix2] > ydimen) mostbuf[ix2] = ydimen; + + return(bad); +} + + +// +// wallmost (internal) +// +static long wallmost(short *mostbuf, long w, long sectnum, char dastat) +{ + long bad, i, j, t, y, z, inty, intz, xcross, yinc, fw; + long x1, y1, z1, x2, y2, z2, xv, yv, dx, dy, dasqr, oz1, oz2; + long s1, s2, s3, s4, ix1, ix2, iy1, iy2; + //char datempbuf[256]; + + if (dastat == 0) + { + z = sector[sectnum].ceilingz-globalposz; + if ((sector[sectnum].ceilingstat&2) == 0) return(owallmost(mostbuf,w,z)); + } + else + { + z = sector[sectnum].floorz-globalposz; + if ((sector[sectnum].floorstat&2) == 0) return(owallmost(mostbuf,w,z)); + } + + i = thewall[w]; + if (i == sector[sectnum].wallptr) return(owallmost(mostbuf,w,z)); + + x1 = wall[i].x; x2 = wall[wall[i].point2].x-x1; + y1 = wall[i].y; y2 = wall[wall[i].point2].y-y1; + + fw = sector[sectnum].wallptr; i = wall[fw].point2; + dx = wall[i].x-wall[fw].x; dy = wall[i].y-wall[fw].y; + dasqr = krecipasm(nsqrtasm(dx*dx+dy*dy)); + + if (xb1[w] == 0) + { xv = cosglobalang+sinviewingrangeglobalang; yv = singlobalang-cosviewingrangeglobalang; } + else + { xv = x1-globalposx; yv = y1-globalposy; } + i = xv*(y1-globalposy)-yv*(x1-globalposx); j = yv*x2-xv*y2; + if (klabs(j) > klabs(i>>3)) i = divscale28(i,j); + if (dastat == 0) + { + t = mulscale15(sector[sectnum].ceilingheinum,dasqr); + z1 = sector[sectnum].ceilingz; + } + else + { + t = mulscale15(sector[sectnum].floorheinum,dasqr); + z1 = sector[sectnum].floorz; + } + z1 = dmulscale24(dx*t,mulscale20(y2,i)+((y1-wall[fw].y)<<8), + -dy*t,mulscale20(x2,i)+((x1-wall[fw].x)<<8))+((z1-globalposz)<<7); + + + if (xb2[w] == xdimen-1) + { xv = cosglobalang-sinviewingrangeglobalang; yv = singlobalang+cosviewingrangeglobalang; } + else + { xv = (x2+x1)-globalposx; yv = (y2+y1)-globalposy; } + i = xv*(y1-globalposy)-yv*(x1-globalposx); j = yv*x2-xv*y2; + if (klabs(j) > klabs(i>>3)) i = divscale28(i,j); + if (dastat == 0) + { + t = mulscale15(sector[sectnum].ceilingheinum,dasqr); + z2 = sector[sectnum].ceilingz; + } + else + { + t = mulscale15(sector[sectnum].floorheinum,dasqr); + z2 = sector[sectnum].floorz; + } + z2 = dmulscale24(dx*t,mulscale20(y2,i)+((y1-wall[fw].y)<<8), + -dy*t,mulscale20(x2,i)+((x1-wall[fw].x)<<8))+((z2-globalposz)<<7); + + + s1 = mulscale20(globaluclip,yb1[w]); s2 = mulscale20(globaluclip,yb2[w]); + s3 = mulscale20(globaldclip,yb1[w]); s4 = mulscale20(globaldclip,yb2[w]); + bad = (z1s3)<<2)+((z2>s4)<<3); + + ix1 = xb1[w]; ix2 = xb2[w]; + iy1 = yb1[w]; iy2 = yb2[w]; + oz1 = z1; oz2 = z2; + + if ((bad&3) == 3) + { + //clearbufbyte(&mostbuf[ix1],(ix2-ix1+1)*sizeof(mostbuf[0]),0L); + for (i=ix1; i<=ix2; i++) mostbuf[i] = 0; + return(bad); + } + + if ((bad&12) == 12) + { + //clearbufbyte(&mostbuf[ix1],(ix2-ix1+1)*sizeof(mostbuf[0]),ydimen+(ydimen<<16)); + for (i=ix1; i<=ix2; i++) mostbuf[i] = ydimen; + return(bad); + } + + if (bad&3) + { + //inty = intz / (globaluclip>>16) + t = divscale30(oz1-s1,s2-s1+oz1-oz2); + inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); + intz = oz1 + mulscale30(oz2-oz1,t); + xcross = xb1[w] + scale(mulscale30(yb2[w],t),xb2[w]-xb1[w],inty); + + //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); + //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); + //intz = z1 + mulscale30(z2-z1,t); + + if ((bad&3) == 2) + { + if (xb1[w] <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + //clearbufbyte(&mostbuf[xcross+1],(xb2[w]-xcross)*sizeof(mostbuf[0]),0L); + for (i=xcross+1; i<=xb2[w]; i++) mostbuf[i] = 0; + } + else + { + if (xcross <= xb2[w]) { z1 = intz; iy1 = inty; ix1 = xcross; } + //clearbufbyte(&mostbuf[xb1[w]],(xcross-xb1[w]+1)*sizeof(mostbuf[0]),0L); + for (i=xb1[w]; i<=xcross; i++) mostbuf[i] = 0; + } + } + + if (bad&12) + { + //inty = intz / (globaldclip>>16) + t = divscale30(oz1-s3,s4-s3+oz1-oz2); + inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); + intz = oz1 + mulscale30(oz2-oz1,t); + xcross = xb1[w] + scale(mulscale30(yb2[w],t),xb2[w]-xb1[w],inty); + + //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); + //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); + //intz = z1 + mulscale30(z2-z1,t); + + if ((bad&12) == 8) + { + if (xb1[w] <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + //clearbufbyte(&mostbuf[xcross+1],(xb2[w]-xcross)*sizeof(mostbuf[0]),ydimen+(ydimen<<16)); + for (i=xcross+1; i<=xb2[w]; i++) mostbuf[i] = ydimen; + } + else + { + if (xcross <= xb2[w]) { z1 = intz; iy1 = inty; ix1 = xcross; } + //clearbufbyte(&mostbuf[xb1[w]],(xcross-xb1[w]+1)*sizeof(mostbuf[0]),ydimen+(ydimen<<16)); + for (i=xb1[w]; i<=xcross; i++) mostbuf[i] = ydimen; + } + } + + y = (scale(z1,xdimenscale,iy1)<<4); + yinc = ((scale(z2,xdimenscale,iy2)<<4)-y) / (ix2-ix1+1); + qinterpolatedown16short((long)&mostbuf[ix1],ix2-ix1+1,y+(globalhoriz<<16),yinc); + + if (mostbuf[ix1] < 0) mostbuf[ix1] = 0; + if (mostbuf[ix1] > ydimen) mostbuf[ix1] = ydimen; + if (mostbuf[ix2] < 0) mostbuf[ix2] = 0; + if (mostbuf[ix2] > ydimen) mostbuf[ix2] = ydimen; + + return(bad); +} + + +// +// ceilscan (internal) +// +static void ceilscan(long x1, long x2, long sectnum) +{ + long i, j, ox, oy, x, y1, y2, twall, bwall; + sectortype *sec; + + sec = §or[sectnum]; + if (palookup[sec->ceilingpal] != globalpalwritten) + { + globalpalwritten = palookup[sec->ceilingpal]; + if (!globalpalwritten) globalpalwritten = palookup[globalpal]; // JBF: fixes null-pointer crash + setpalookupaddress(globalpalwritten); + } + + globalzd = sec->ceilingz-globalposz; + if (globalzd > 0) return; + globalpicnum = sec->ceilingpicnum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + setgotpic(globalpicnum); + if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) return; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs((short)globalpicnum,(short)sectnum); + + if (waloff[globalpicnum] == 0) loadtile(globalpicnum); + globalbufplc = waloff[globalpicnum]; + + globalshade = (long)sec->ceilingshade; + globvis = globalcisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalorientation = (long)sec->ceilingstat; + + + if ((globalorientation&64) == 0) + { + globalx1 = singlobalang; globalx2 = singlobalang; + globaly1 = cosglobalang; globaly2 = cosglobalang; + globalxpanning = (globalposx<<20); + globalypanning = -(globalposy<<20); + } + else + { + j = sec->wallptr; + ox = wall[wall[j].point2].x - wall[j].x; + oy = wall[wall[j].point2].y - wall[j].y; + i = nsqrtasm(ox*ox+oy*oy); if (i == 0) i = 1024; else i = 1048576/i; + globalx1 = mulscale10(dmulscale10(ox,singlobalang,-oy,cosglobalang),i); + globaly1 = mulscale10(dmulscale10(ox,cosglobalang,oy,singlobalang),i); + globalx2 = -globalx1; + globaly2 = -globaly1; + + ox = ((wall[j].x-globalposx)<<6); oy = ((wall[j].y-globalposy)<<6); + i = dmulscale14(oy,cosglobalang,-ox,singlobalang); + j = dmulscale14(ox,cosglobalang,oy,singlobalang); + ox = i; oy = j; + globalxpanning = globalx1*ox - globaly1*oy; + globalypanning = globaly2*ox + globalx2*oy; + } + globalx2 = mulscale16(globalx2,viewingrangerecip); + globaly1 = mulscale16(globaly1,viewingrangerecip); + globalxshift = (8-(picsiz[globalpicnum]&15)); + globalyshift = (8-(picsiz[globalpicnum]>>4)); + if (globalorientation&8) { globalxshift++; globalyshift++; } + + if ((globalorientation&0x4) > 0) + { + i = globalxpanning; globalxpanning = globalypanning; globalypanning = i; + i = globalx2; globalx2 = -globaly1; globaly1 = -i; + i = globalx1; globalx1 = globaly2; globaly2 = i; + } + if ((globalorientation&0x10) > 0) globalx1 = -globalx1, globaly1 = -globaly1, globalxpanning = -globalxpanning; + if ((globalorientation&0x20) > 0) globalx2 = -globalx2, globaly2 = -globaly2, globalypanning = -globalypanning; + globalx1 <<= globalxshift; globaly1 <<= globalxshift; + globalx2 <<= globalyshift; globaly2 <<= globalyshift; + globalxpanning <<= globalxshift; globalypanning <<= globalyshift; + globalxpanning += (((long)sec->ceilingxpanning)<<24); + globalypanning += (((long)sec->ceilingypanning)<<24); + globaly1 = (-globalx1-globaly1)*halfxdimen; + globalx2 = (globalx2-globaly2)*halfxdimen; + + sethlinesizes(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4,globalbufplc); + + globalx2 += globaly2*(x1-1); + globaly1 += globalx1*(x1-1); + globalx1 = mulscale16(globalx1,globalzd); + globalx2 = mulscale16(globalx2,globalzd); + globaly1 = mulscale16(globaly1,globalzd); + globaly2 = mulscale16(globaly2,globalzd); + globvis = klabs(mulscale10(globvis,globalzd)); + + if (!(globalorientation&0x180)) + { + y1 = umost[x1]; y2 = y1; + for(x=x1;x<=x2;x++) + { + twall = umost[x]-1; bwall = min(uplc[x],dmost[x]); + if (twall < bwall-1) + { + if (twall >= y2) + { + while (y1 < y2-1) hline(x-1,++y1); + y1 = twall; + } + else + { + while (y1 < twall) hline(x-1,++y1); + while (y1 > twall) lastx[y1--] = x; + } + while (y2 > bwall) hline(x-1,--y2); + while (y2 < bwall) lastx[y2++] = x; + } + else + { + while (y1 < y2-1) hline(x-1,++y1); + if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } + y1 = umost[x+1]; y2 = y1; + } + globalx2 += globaly2; globaly1 += globalx1; + } + while (y1 < y2-1) hline(x2,++y1); + faketimerhandler(); + return; + } + + switch(globalorientation&0x180) + { + case 128: + msethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); + break; + case 256: + settransnormal(); + tsethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); + break; + case 384: + settransreverse(); + tsethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); + break; + } + + y1 = umost[x1]; y2 = y1; + for(x=x1;x<=x2;x++) + { + twall = umost[x]-1; bwall = min(uplc[x],dmost[x]); + if (twall < bwall-1) + { + if (twall >= y2) + { + while (y1 < y2-1) slowhline(x-1,++y1); + y1 = twall; + } + else + { + while (y1 < twall) slowhline(x-1,++y1); + while (y1 > twall) lastx[y1--] = x; + } + while (y2 > bwall) slowhline(x-1,--y2); + while (y2 < bwall) lastx[y2++] = x; + } + else + { + while (y1 < y2-1) slowhline(x-1,++y1); + if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } + y1 = umost[x+1]; y2 = y1; + } + globalx2 += globaly2; globaly1 += globalx1; + } + while (y1 < y2-1) slowhline(x2,++y1); + faketimerhandler(); +} + + +// +// florscan (internal) +// +static void florscan(long x1, long x2, long sectnum) +{ + long i, j, ox, oy, x, y1, y2, twall, bwall; + sectortype *sec; + + sec = §or[sectnum]; + if (palookup[sec->floorpal] != globalpalwritten) + { + globalpalwritten = palookup[sec->floorpal]; + if (!globalpalwritten) globalpalwritten = palookup[globalpal]; // JBF: fixes null-pointer crash + setpalookupaddress(globalpalwritten); + } + + globalzd = globalposz-sec->floorz; + if (globalzd > 0) return; + globalpicnum = sec->floorpicnum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + setgotpic(globalpicnum); + if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) return; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs((short)globalpicnum,(short)sectnum); + + if (waloff[globalpicnum] == 0) loadtile(globalpicnum); + globalbufplc = waloff[globalpicnum]; + + globalshade = (long)sec->floorshade; + globvis = globalcisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalorientation = (long)sec->floorstat; + + + if ((globalorientation&64) == 0) + { + globalx1 = singlobalang; globalx2 = singlobalang; + globaly1 = cosglobalang; globaly2 = cosglobalang; + globalxpanning = (globalposx<<20); + globalypanning = -(globalposy<<20); + } + else + { + j = sec->wallptr; + ox = wall[wall[j].point2].x - wall[j].x; + oy = wall[wall[j].point2].y - wall[j].y; + i = nsqrtasm(ox*ox+oy*oy); if (i == 0) i = 1024; else i = 1048576/i; + globalx1 = mulscale10(dmulscale10(ox,singlobalang,-oy,cosglobalang),i); + globaly1 = mulscale10(dmulscale10(ox,cosglobalang,oy,singlobalang),i); + globalx2 = -globalx1; + globaly2 = -globaly1; + + ox = ((wall[j].x-globalposx)<<6); oy = ((wall[j].y-globalposy)<<6); + i = dmulscale14(oy,cosglobalang,-ox,singlobalang); + j = dmulscale14(ox,cosglobalang,oy,singlobalang); + ox = i; oy = j; + globalxpanning = globalx1*ox - globaly1*oy; + globalypanning = globaly2*ox + globalx2*oy; + } + globalx2 = mulscale16(globalx2,viewingrangerecip); + globaly1 = mulscale16(globaly1,viewingrangerecip); + globalxshift = (8-(picsiz[globalpicnum]&15)); + globalyshift = (8-(picsiz[globalpicnum]>>4)); + if (globalorientation&8) { globalxshift++; globalyshift++; } + + if ((globalorientation&0x4) > 0) + { + i = globalxpanning; globalxpanning = globalypanning; globalypanning = i; + i = globalx2; globalx2 = -globaly1; globaly1 = -i; + i = globalx1; globalx1 = globaly2; globaly2 = i; + } + if ((globalorientation&0x10) > 0) globalx1 = -globalx1, globaly1 = -globaly1, globalxpanning = -globalxpanning; + if ((globalorientation&0x20) > 0) globalx2 = -globalx2, globaly2 = -globaly2, globalypanning = -globalypanning; + globalx1 <<= globalxshift; globaly1 <<= globalxshift; + globalx2 <<= globalyshift; globaly2 <<= globalyshift; + globalxpanning <<= globalxshift; globalypanning <<= globalyshift; + globalxpanning += (((long)sec->floorxpanning)<<24); + globalypanning += (((long)sec->floorypanning)<<24); + globaly1 = (-globalx1-globaly1)*halfxdimen; + globalx2 = (globalx2-globaly2)*halfxdimen; + + sethlinesizes(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4,globalbufplc); + + globalx2 += globaly2*(x1-1); + globaly1 += globalx1*(x1-1); + globalx1 = mulscale16(globalx1,globalzd); + globalx2 = mulscale16(globalx2,globalzd); + globaly1 = mulscale16(globaly1,globalzd); + globaly2 = mulscale16(globaly2,globalzd); + globvis = klabs(mulscale10(globvis,globalzd)); + + if (!(globalorientation&0x180)) + { + y1 = max(dplc[x1],umost[x1]); y2 = y1; + for(x=x1;x<=x2;x++) + { + twall = max(dplc[x],umost[x])-1; bwall = dmost[x]; + if (twall < bwall-1) + { + if (twall >= y2) + { + while (y1 < y2-1) hline(x-1,++y1); + y1 = twall; + } + else + { + while (y1 < twall) hline(x-1,++y1); + while (y1 > twall) lastx[y1--] = x; + } + while (y2 > bwall) hline(x-1,--y2); + while (y2 < bwall) lastx[y2++] = x; + } + else + { + while (y1 < y2-1) hline(x-1,++y1); + if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } + y1 = max(dplc[x+1],umost[x+1]); y2 = y1; + } + globalx2 += globaly2; globaly1 += globalx1; + } + while (y1 < y2-1) hline(x2,++y1); + faketimerhandler(); + return; + } + + switch(globalorientation&0x180) + { + case 128: + msethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); + break; + case 256: + settransnormal(); + tsethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); + break; + case 384: + settransreverse(); + tsethlineshift(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4); + break; + } + + y1 = max(dplc[x1],umost[x1]); y2 = y1; + for(x=x1;x<=x2;x++) + { + twall = max(dplc[x],umost[x])-1; bwall = dmost[x]; + if (twall < bwall-1) + { + if (twall >= y2) + { + while (y1 < y2-1) slowhline(x-1,++y1); + y1 = twall; + } + else + { + while (y1 < twall) slowhline(x-1,++y1); + while (y1 > twall) lastx[y1--] = x; + } + while (y2 > bwall) slowhline(x-1,--y2); + while (y2 < bwall) lastx[y2++] = x; + } + else + { + while (y1 < y2-1) slowhline(x-1,++y1); + if (x == x2) { globalx2 += globaly2; globaly1 += globalx1; break; } + y1 = max(dplc[x+1],umost[x+1]); y2 = y1; + } + globalx2 += globaly2; globaly1 += globalx1; + } + while (y1 < y2-1) slowhline(x2,++y1); + faketimerhandler(); +} + + +// +// wallscan (internal) +// +static void wallscan(long x1, long x2, short *uwal, short *dwal, long *swal, long *lwal) +{ + long i, x, xnice, ynice, fpalookup; + long y1ve[4], y2ve[4], u4, d4, z, tsizx, tsizy; + char bad; + + tsizx = tilesizx[globalpicnum]; + tsizy = tilesizy[globalpicnum]; + setgotpic(globalpicnum); + if ((tsizx <= 0) || (tsizy <= 0)) return; + if ((uwal[x1] > ydimen) && (uwal[x2] > ydimen)) return; + if ((dwal[x1] < 0) && (dwal[x2] < 0)) return; + + if (waloff[globalpicnum] == 0) loadtile(globalpicnum); + + xnice = (pow2long[picsiz[globalpicnum]&15] == tsizx); + if (xnice) tsizx--; + ynice = (pow2long[picsiz[globalpicnum]>>4] == tsizy); + if (ynice) tsizy = (picsiz[globalpicnum]>>4); + + fpalookup = FP_OFF(palookup[globalpal]); + + setupvlineasm(globalshiftval); + +#ifndef ENGINE_USING_A_C + + x = x1; + while ((umost[x] > dmost[x]) && (x <= x2)) x++; + + for(;(x<=x2)&&((x+frameoffset)&3);x++) + { + y1ve[0] = max(uwal[x],umost[x]); + y2ve[0] = min(dwal[x],dmost[x]); + if (y2ve[0] <= y1ve[0]) continue; + + palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + + bufplce[0] = lwal[x] + globalxpanning; + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; + + vince[0] = swal[x]*globalyscale; + vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1); + + vlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],x+frameoffset+ylookup[y1ve[0]]); + } + for(;x<=x2-3;x+=4) + { + bad = 0; + for(z=3;z>=0;z--) + { + y1ve[z] = max(uwal[x+z],umost[x+z]); + y2ve[z] = min(dwal[x+z],dmost[x+z])-1; + if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; } + + i = lwal[x+z] + globalxpanning; + if (i >= tsizx) { if (xnice == 0) i %= tsizx; else i &= tsizx; } + if (ynice == 0) i *= tsizy; else i <<= tsizy; + bufplce[z] = waloff[globalpicnum]+i; + + vince[z] = swal[x+z]*globalyscale; + vplce[z] = globalzd + vince[z]*(y1ve[z]-globalhoriz+1); + } + if (bad == 15) continue; + + palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + palookupoffse[3] = fpalookup+(getpalookup((long)mulscale16(swal[x+3],globvis),globalshade)<<8); + + if ((palookupoffse[0] == palookupoffse[3]) && ((bad&0x9) == 0)) + { + palookupoffse[1] = palookupoffse[0]; + palookupoffse[2] = palookupoffse[0]; + } + else + { + palookupoffse[1] = fpalookup+(getpalookup((long)mulscale16(swal[x+1],globvis),globalshade)<<8); + palookupoffse[2] = fpalookup+(getpalookup((long)mulscale16(swal[x+2],globvis),globalshade)<<8); + } + + u4 = max(max(y1ve[0],y1ve[1]),max(y1ve[2],y1ve[3])); + d4 = min(min(y2ve[0],y2ve[1]),min(y2ve[2],y2ve[3])); + + if ((bad != 0) || (u4 >= d4)) + { + if (!(bad&1)) prevlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0],vplce[0],bufplce[0],ylookup[y1ve[0]]+x+frameoffset+0); + if (!(bad&2)) prevlineasm1(vince[1],palookupoffse[1],y2ve[1]-y1ve[1],vplce[1],bufplce[1],ylookup[y1ve[1]]+x+frameoffset+1); + if (!(bad&4)) prevlineasm1(vince[2],palookupoffse[2],y2ve[2]-y1ve[2],vplce[2],bufplce[2],ylookup[y1ve[2]]+x+frameoffset+2); + if (!(bad&8)) prevlineasm1(vince[3],palookupoffse[3],y2ve[3]-y1ve[3],vplce[3],bufplce[3],ylookup[y1ve[3]]+x+frameoffset+3); + continue; + } + + if (u4 > y1ve[0]) vplce[0] = prevlineasm1(vince[0],palookupoffse[0],u4-y1ve[0]-1,vplce[0],bufplce[0],ylookup[y1ve[0]]+x+frameoffset+0); + if (u4 > y1ve[1]) vplce[1] = prevlineasm1(vince[1],palookupoffse[1],u4-y1ve[1]-1,vplce[1],bufplce[1],ylookup[y1ve[1]]+x+frameoffset+1); + if (u4 > y1ve[2]) vplce[2] = prevlineasm1(vince[2],palookupoffse[2],u4-y1ve[2]-1,vplce[2],bufplce[2],ylookup[y1ve[2]]+x+frameoffset+2); + if (u4 > y1ve[3]) vplce[3] = prevlineasm1(vince[3],palookupoffse[3],u4-y1ve[3]-1,vplce[3],bufplce[3],ylookup[y1ve[3]]+x+frameoffset+3); + + if (d4 >= u4) vlineasm4(d4-u4+1,ylookup[u4]+x+frameoffset); + + i = x+frameoffset+ylookup[d4+1]; + if (y2ve[0] > d4) prevlineasm1(vince[0],palookupoffse[0],y2ve[0]-d4-1,vplce[0],bufplce[0],i+0); + if (y2ve[1] > d4) prevlineasm1(vince[1],palookupoffse[1],y2ve[1]-d4-1,vplce[1],bufplce[1],i+1); + if (y2ve[2] > d4) prevlineasm1(vince[2],palookupoffse[2],y2ve[2]-d4-1,vplce[2],bufplce[2],i+2); + if (y2ve[3] > d4) prevlineasm1(vince[3],palookupoffse[3],y2ve[3]-d4-1,vplce[3],bufplce[3],i+3); + } + for(;x<=x2;x++) + { + y1ve[0] = max(uwal[x],umost[x]); + y2ve[0] = min(dwal[x],dmost[x]); + if (y2ve[0] <= y1ve[0]) continue; + + palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + + bufplce[0] = lwal[x] + globalxpanning; + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; + + vince[0] = swal[x]*globalyscale; + vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1); + + vlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],x+frameoffset+ylookup[y1ve[0]]); + } + +#else // ENGINE_USING_A_C + + for(x=x1;x<=x2;x++) + { + y1ve[0] = max(uwal[x],umost[x]); + y2ve[0] = min(dwal[x],dmost[x]); + if (y2ve[0] <= y1ve[0]) continue; + + palookupoffse[0] = fpalookup+(getpalookup((long)mulscale16(swal[x],globvis),globalshade)<<8); + + bufplce[0] = lwal[x] + globalxpanning; + if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; } + if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy; + + vince[0] = swal[x]*globalyscale; + vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1); + + vlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],x+frameoffset+ylookup[y1ve[0]]); + } + +#endif + + faketimerhandler(); +} + + +// +// transmaskvline (internal) +// +static void transmaskvline(long x) +{ + long vplc, vinc, p, i, palookupoffs, bufplc; + short y1v, y2v; + + if ((x < 0) || (x >= xdimen)) return; + + y1v = max(uwall[x],startumost[x+windowx1]-windowy1); + y2v = min(dwall[x],startdmost[x+windowx1]-windowy1); + y2v--; + if (y2v < y1v) return; + + palookupoffs = FP_OFF(palookup[globalpal]) + (getpalookup((long)mulscale16(swall[x],globvis),globalshade)<<8); + + vinc = swall[x]*globalyscale; + vplc = globalzd + vinc*(y1v-globalhoriz+1); + + i = lwall[x]+globalxpanning; + if (i >= tilesizx[globalpicnum]) i %= tilesizx[globalpicnum]; + bufplc = waloff[globalpicnum]+i*tilesizy[globalpicnum]; + + p = ylookup[y1v]+x+frameoffset; + + tvlineasm1(vinc,palookupoffs,y2v-y1v,vplc,bufplc,p); +} + + +// +// transmaskvline2 (internal) +// +#ifndef ENGINE_USING_A_C +static void transmaskvline2(long x) +{ + long i, y1, y2, x2; + short y1ve[2], y2ve[2]; + + if ((x < 0) || (x >= xdimen)) return; + if (x == xdimen-1) { transmaskvline(x); return; } + + x2 = x+1; + + y1ve[0] = max(uwall[x],startumost[x+windowx1]-windowy1); + y2ve[0] = min(dwall[x],startdmost[x+windowx1]-windowy1)-1; + if (y2ve[0] < y1ve[0]) { transmaskvline(x2); return; } + y1ve[1] = max(uwall[x2],startumost[x2+windowx1]-windowy1); + y2ve[1] = min(dwall[x2],startdmost[x2+windowx1]-windowy1)-1; + if (y2ve[1] < y1ve[1]) { transmaskvline(x); return; } + + palookupoffse[0] = FP_OFF(palookup[globalpal]) + (getpalookup((long)mulscale16(swall[x],globvis),globalshade)<<8); + palookupoffse[1] = FP_OFF(palookup[globalpal]) + (getpalookup((long)mulscale16(swall[x2],globvis),globalshade)<<8); + + setuptvlineasm2(globalshiftval,palookupoffse[0],palookupoffse[1]); + + vince[0] = swall[x]*globalyscale; + vince[1] = swall[x2]*globalyscale; + vplce[0] = globalzd + vince[0]*(y1ve[0]-globalhoriz+1); + vplce[1] = globalzd + vince[1]*(y1ve[1]-globalhoriz+1); + + i = lwall[x] + globalxpanning; + if (i >= tilesizx[globalpicnum]) i %= tilesizx[globalpicnum]; + bufplce[0] = waloff[globalpicnum]+i*tilesizy[globalpicnum]; + + i = lwall[x2] + globalxpanning; + if (i >= tilesizx[globalpicnum]) i %= tilesizx[globalpicnum]; + bufplce[1] = waloff[globalpicnum]+i*tilesizy[globalpicnum]; + + y1 = max(y1ve[0],y1ve[1]); + y2 = min(y2ve[0],y2ve[1]); + + i = x+frameoffset; + + if (y1ve[0] != y1ve[1]) + { + if (y1ve[0] < y1) + vplce[0] = tvlineasm1(vince[0],palookupoffse[0],y1-y1ve[0]-1,vplce[0],bufplce[0],ylookup[y1ve[0]]+i); + else + vplce[1] = tvlineasm1(vince[1],palookupoffse[1],y1-y1ve[1]-1,vplce[1],bufplce[1],ylookup[y1ve[1]]+i+1); + } + + if (y2 > y1) + { + asm1 = vince[1]; + asm2 = ylookup[y2]+i+1; + tvlineasm2(vplce[1],vince[0],bufplce[0],bufplce[1],vplce[0],ylookup[y1]+i); + } + else + { + asm1 = vplce[0]; + asm2 = vplce[1]; + } + + if (y2ve[0] > y2ve[1]) + tvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y2-1,asm1,bufplce[0],ylookup[y2+1]+i); + else if (y2ve[0] < y2ve[1]) + tvlineasm1(vince[1],palookupoffse[1],y2ve[1]-y2-1,asm2,bufplce[1],ylookup[y2+1]+i+1); + + faketimerhandler(); +} +#endif + +// +// transmaskwallscan (internal) +// +static void transmaskwallscan(long x1, long x2) +{ + long x; + + setgotpic(globalpicnum); + if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) return; + + if (waloff[globalpicnum] == 0) loadtile(globalpicnum); + + setuptvlineasm(globalshiftval); + + x = x1; + while ((startumost[x+windowx1] > startdmost[x+windowx1]) && (x <= x2)) x++; +#ifndef ENGINE_USING_A_C + if ((x <= x2) && (x&1)) transmaskvline(x), x++; + while (x < x2) transmaskvline2(x), x += 2; +#endif + while (x <= x2) transmaskvline(x), x++; + faketimerhandler(); +} + + +// +// ceilspritehline (internal) +// +static void ceilspritehline(long x2, long y) +{ + long x1, v, bx, by; + + //x = x1 + (x2-x1)t + (y1-y2)u ~ x = 160v + //y = y1 + (y2-y1)t + (x2-x1)u ~ y = (scrx-160)v + //z = z1 = z2 ~ z = posz + (scry-horiz)v + + x1 = lastx[y]; if (x2 < x1) return; + + v = mulscale20(globalzd,horizlookup[y-globalhoriz+horizycent]); + bx = mulscale14(globalx2*x1+globalx1,v) + globalxpanning; + by = mulscale14(globaly2*x1+globaly1,v) + globalypanning; + asm1 = mulscale14(globalx2,v); + asm2 = mulscale14(globaly2,v); + + asm3 = FP_OFF(palookup[globalpal]) + (getpalookup((long)mulscale28(klabs(v),globvis),globalshade)<<8); + + if ((globalorientation&2) == 0) + mhline(globalbufplc,bx,(x2-x1)<<16,0L,by,ylookup[y]+x1+frameoffset); + else + { + thline(globalbufplc,bx,(x2-x1)<<16,0L,by,ylookup[y]+x1+frameoffset); + } +} + + +// +// ceilspritescan (internal) +// +static void ceilspritescan(long x1, long x2) +{ + long x, y1, y2, twall, bwall; + + y1 = uwall[x1]; y2 = y1; + for(x=x1;x<=x2;x++) + { + twall = uwall[x]-1; bwall = dwall[x]; + if (twall < bwall-1) + { + if (twall >= y2) + { + while (y1 < y2-1) ceilspritehline(x-1,++y1); + y1 = twall; + } + else + { + while (y1 < twall) ceilspritehline(x-1,++y1); + while (y1 > twall) lastx[y1--] = x; + } + while (y2 > bwall) ceilspritehline(x-1,--y2); + while (y2 < bwall) lastx[y2++] = x; + } + else + { + while (y1 < y2-1) ceilspritehline(x-1,++y1); + if (x == x2) break; + y1 = uwall[x+1]; y2 = y1; + } + } + while (y1 < y2-1) ceilspritehline(x2,++y1); + faketimerhandler(); +} + + +// +// grouscan (internal) +// +#define BITSOFPRECISION 3 //Don't forget to change this in A.ASM also! +static void grouscan(long dax1, long dax2, long sectnum, char dastat) +{ + long i, j, l, x, y, dx, dy, wx, wy, y1, y2, daz; + long daslope, dasqr; + long shoffs, shinc, m1, m2, *mptr1, *mptr2, *nptr1, *nptr2; + walltype *wal; + sectortype *sec; + + sec = §or[sectnum]; + + if (dastat == 0) + { + if (globalposz <= getceilzofslope(sectnum,globalposx,globalposy)) + return; //Back-face culling + globalorientation = sec->ceilingstat; + globalpicnum = sec->ceilingpicnum; + globalshade = sec->ceilingshade; + globalpal = sec->ceilingpal; + daslope = sec->ceilingheinum; + daz = sec->ceilingz; + } + else + { + if (globalposz >= getflorzofslope(sectnum,globalposx,globalposy)) + return; //Back-face culling + globalorientation = sec->floorstat; + globalpicnum = sec->floorpicnum; + globalshade = sec->floorshade; + globalpal = sec->floorpal; + daslope = sec->floorheinum; + daz = sec->floorz; + } + + if ((picanm[globalpicnum]&192) != 0) globalpicnum += animateoffs(globalpicnum,sectnum); + setgotpic(globalpicnum); + if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) return; + if (waloff[globalpicnum] == 0) loadtile(globalpicnum); + + wal = &wall[sec->wallptr]; + wx = wall[wal->point2].x - wal->x; + wy = wall[wal->point2].y - wal->y; + dasqr = krecipasm(nsqrtasm(wx*wx+wy*wy)); + i = mulscale21(daslope,dasqr); + wx *= i; wy *= i; + + globalx = -mulscale19(singlobalang,xdimenrecip); + globaly = mulscale19(cosglobalang,xdimenrecip); + globalx1 = (globalposx<<8); + globaly1 = -(globalposy<<8); + i = (dax1-halfxdimen)*xdimenrecip; + globalx2 = mulscale16(cosglobalang<<4,viewingrangerecip) - mulscale27(singlobalang,i); + globaly2 = mulscale16(singlobalang<<4,viewingrangerecip) + mulscale27(cosglobalang,i); + globalzd = (xdimscale<<9); + globalzx = -dmulscale17(wx,globaly2,-wy,globalx2) + mulscale10(1-globalhoriz,globalzd); + globalz = -dmulscale25(wx,globaly,-wy,globalx); + + if (globalorientation&64) //Relative alignment + { + dx = mulscale14(wall[wal->point2].x-wal->x,dasqr); + dy = mulscale14(wall[wal->point2].y-wal->y,dasqr); + + i = nsqrtasm(daslope*daslope+16777216); + + x = globalx; y = globaly; + globalx = dmulscale16(x,dx,y,dy); + globaly = mulscale12(dmulscale16(-y,dx,x,dy),i); + + x = ((wal->x-globalposx)<<8); y = ((wal->y-globalposy)<<8); + globalx1 = dmulscale16(-x,dx,-y,dy); + globaly1 = mulscale12(dmulscale16(-y,dx,x,dy),i); + + x = globalx2; y = globaly2; + globalx2 = dmulscale16(x,dx,y,dy); + globaly2 = mulscale12(dmulscale16(-y,dx,x,dy),i); + } + if (globalorientation&0x4) + { + i = globalx; globalx = -globaly; globaly = -i; + i = globalx1; globalx1 = globaly1; globaly1 = i; + i = globalx2; globalx2 = -globaly2; globaly2 = -i; + } + if (globalorientation&0x10) { globalx1 = -globalx1, globalx2 = -globalx2, globalx = -globalx; } + if (globalorientation&0x20) { globaly1 = -globaly1, globaly2 = -globaly2, globaly = -globaly; } + + daz = dmulscale9(wx,globalposy-wal->y,-wy,globalposx-wal->x) + ((daz-globalposz)<<8); + globalx2 = mulscale20(globalx2,daz); globalx = mulscale28(globalx,daz); + globaly2 = mulscale20(globaly2,-daz); globaly = mulscale28(globaly,-daz); + + i = 8-(picsiz[globalpicnum]&15); j = 8-(picsiz[globalpicnum]>>4); + if (globalorientation&8) { i++; j++; } + globalx1 <<= (i+12); globalx2 <<= i; globalx <<= i; + globaly1 <<= (j+12); globaly2 <<= j; globaly <<= j; + + if (dastat == 0) + { + globalx1 += (((long)sec->ceilingxpanning)<<24); + globaly1 += (((long)sec->ceilingypanning)<<24); + } + else + { + globalx1 += (((long)sec->floorxpanning)<<24); + globaly1 += (((long)sec->floorypanning)<<24); + } + + asm1 = -(globalzd>>(16-BITSOFPRECISION)); + + globvis = globalvisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globvis = mulscale13(globvis,daz); + globvis = mulscale16(globvis,xdimscale); + j = FP_OFF(palookup[globalpal]); + + setupslopevlin(((long)(picsiz[globalpicnum]&15))+(((long)(picsiz[globalpicnum]>>4))<<8),waloff[globalpicnum],-ylookup[1]); + + l = (globalzd>>16); + + shinc = mulscale16(globalz,xdimenscale); + if (shinc > 0) shoffs = (4<<15); else shoffs = ((16380-ydimen)<<15); // JBF: was 2044 + if (dastat == 0) y1 = umost[dax1]; else y1 = max(umost[dax1],dplc[dax1]); + m1 = mulscale16(y1,globalzd) + (globalzx>>6); + //Avoid visibility overflow by crossing horizon + if (globalzd > 0) m1 += (globalzd>>16); else m1 -= (globalzd>>16); + m2 = m1+l; + mptr1 = (long *)&slopalookup[y1+(shoffs>>15)]; mptr2 = mptr1+1; + + for(x=dax1;x<=dax2;x++) + { + if (dastat == 0) { y1 = umost[x]; y2 = min(dmost[x],uplc[x])-1; } + else { y1 = max(umost[x],dplc[x]); y2 = dmost[x]-1; } + if (y1 <= y2) + { + nptr1 = (long *)&slopalookup[y1+(shoffs>>15)]; + nptr2 = (long *)&slopalookup[y2+(shoffs>>15)]; + while (nptr1 <= mptr1) + { + *mptr1-- = j + (getpalookup((long)mulscale24(krecipasm(m1),globvis),globalshade)<<8); + m1 -= l; + } + while (nptr2 >= mptr2) + { + *mptr2++ = j + (getpalookup((long)mulscale24(krecipasm(m2),globvis),globalshade)<<8); + m2 += l; + } + + globalx3 = (globalx2>>10); + globaly3 = (globaly2>>10); + asm3 = mulscale16(y2,globalzd) + (globalzx>>6); + slopevlin(ylookup[y2]+x+frameoffset,krecipasm(asm3>>3),(long)nptr2,y2-y1+1,globalx1,globaly1); + + if ((x&15) == 0) faketimerhandler(); + } + globalx2 += globalx; + globaly2 += globaly; + globalzx += globalz; + shoffs += shinc; + } +} + + +// +// parascan (internal) +// +static void parascan(long dax1, long dax2, long sectnum, char dastat, long bunch) +{ + sectortype *sec; + long j, k, l, m, n, x, z, wallnum, nextsectnum, globalhorizbak; + short *topptr, *botptr; + + sectnum = thesector[bunchfirst[bunch]]; sec = §or[sectnum]; + + globalhorizbak = globalhoriz; + if (parallaxyscale != 65536) + globalhoriz = mulscale16(globalhoriz-(ydimen>>1),parallaxyscale) + (ydimen>>1); + globvis = globalpisibility; + //globalorientation = 0L; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + + if (dastat == 0) + { + globalpal = sec->ceilingpal; + globalpicnum = sec->ceilingpicnum; + globalshade = (long)sec->ceilingshade; + globalxpanning = (long)sec->ceilingxpanning; + globalypanning = (long)sec->ceilingypanning; + topptr = umost; + botptr = uplc; + } + else + { + globalpal = sec->floorpal; + globalpicnum = sec->floorpicnum; + globalshade = (long)sec->floorshade; + globalxpanning = (long)sec->floorxpanning; + globalypanning = (long)sec->floorypanning; + topptr = dplc; + botptr = dmost; + } + + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)sectnum); + globalshiftval = (picsiz[globalpicnum]>>4); + if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; + globalshiftval = 32-globalshiftval; + globalzd = (((tilesizy[globalpicnum]>>1)+parallaxyoffs)<=0;z=p2[z]) + { + wallnum = thewall[z]; nextsectnum = wall[wallnum].nextsector; + + if (dastat == 0) j = sector[nextsectnum].ceilingstat; + else j = sector[nextsectnum].floorstat; + + if ((nextsectnum < 0) || (wall[wallnum].cstat&32) || ((j&1) == 0)) + { + if (x == -1) x = xb1[z]; + + if (parallaxtype == 0) + { + n = mulscale16(xdimenrecip,viewingrange); + for(j=xb1[z];j<=xb2[z];j++) + lplc[j] = (((mulscale23(j-halfxdimen,n)+globalang)&2047)>>k); + } + else + { + for(j=xb1[z];j<=xb2[z];j++) + lplc[j] = ((((long)radarang2[j]+globalang)&2047)>>k); + } + if (parallaxtype == 2) + { + n = mulscale16(xdimscale,viewingrange); + for(j=xb1[z];j<=xb2[z];j++) + swplc[j] = mulscale14(sintable[((long)radarang2[j]+512)&2047],n); + } + else + clearbuf(&swplc[xb1[z]],xb2[z]-xb1[z]+1,mulscale16(xdimscale,viewingrange)); + } + else if (x >= 0) + { + l = globalpicnum; m = (picsiz[globalpicnum]&15); + globalpicnum = l+pskyoff[lplc[x]>>m]; + + if (((lplc[x]^lplc[xb1[z]-1])>>m) == 0) + wallscan(x,xb1[z]-1,topptr,botptr,swplc,lplc); + else + { + j = x; + while (x < xb1[z]) + { + n = l+pskyoff[lplc[x]>>m]; + if (n != globalpicnum) + { + wallscan(j,x-1,topptr,botptr,swplc,lplc); + j = x; + globalpicnum = n; + } + x++; + } + if (j < x) + wallscan(j,x-1,topptr,botptr,swplc,lplc); + } + + globalpicnum = l; + x = -1; + } + } + + if (x >= 0) + { + l = globalpicnum; m = (picsiz[globalpicnum]&15); + globalpicnum = l+pskyoff[lplc[x]>>m]; + + if (((lplc[x]^lplc[xb2[bunchlast[bunch]]])>>m) == 0) + wallscan(x,xb2[bunchlast[bunch]],topptr,botptr,swplc,lplc); + else + { + j = x; + while (x <= xb2[bunchlast[bunch]]) + { + n = l+pskyoff[lplc[x]>>m]; + if (n != globalpicnum) + { + wallscan(j,x-1,topptr,botptr,swplc,lplc); + j = x; + globalpicnum = n; + } + x++; + } + if (j <= x) + wallscan(j,x,topptr,botptr,swplc,lplc); + } + globalpicnum = l; + } + globalhoriz = globalhorizbak; +} + + +// +// drawalls (internal) +// +static void drawalls(long bunch) +{ + sectortype *sec, *nextsec; + walltype *wal; + long i, x, x1, x2, cz[5], fz[5]; + long z, wallnum, sectnum, nextsectnum; + long startsmostwallcnt, startsmostcnt, gotswall; + char andwstat1, andwstat2; + + z = bunchfirst[bunch]; + sectnum = thesector[z]; sec = §or[sectnum]; + + andwstat1 = 0xff; andwstat2 = 0xff; + for(;z>=0;z=p2[z]) //uplc/dplc calculation + { + andwstat1 &= wallmost(uplc,z,sectnum,(char)0); + andwstat2 &= wallmost(dplc,z,sectnum,(char)1); + } + + if ((andwstat1&3) != 3) //draw ceilings + { + if ((sec->ceilingstat&3) == 2) + grouscan(xb1[bunchfirst[bunch]],xb2[bunchlast[bunch]],sectnum,0); + else if ((sec->ceilingstat&1) == 0) + ceilscan(xb1[bunchfirst[bunch]],xb2[bunchlast[bunch]],sectnum); + else + parascan(xb1[bunchfirst[bunch]],xb2[bunchlast[bunch]],sectnum,0,bunch); + } + if ((andwstat2&12) != 12) //draw floors + { + if ((sec->floorstat&3) == 2) + grouscan(xb1[bunchfirst[bunch]],xb2[bunchlast[bunch]],sectnum,1); + else if ((sec->floorstat&1) == 0) + florscan(xb1[bunchfirst[bunch]],xb2[bunchlast[bunch]],sectnum); + else + parascan(xb1[bunchfirst[bunch]],xb2[bunchlast[bunch]],sectnum,1,bunch); + } + + //DRAW WALLS SECTION! + for(z=bunchfirst[bunch];z>=0;z=p2[z]) + { + x1 = xb1[z]; x2 = xb2[z]; + if (umost[x2] >= dmost[x2]) + { + for(x=x1;x= x2) + { + smostwall[smostwallcnt] = z; + smostwalltype[smostwallcnt] = 0; + smostwallcnt++; + continue; + } + } + + wallnum = thewall[z]; wal = &wall[wallnum]; + nextsectnum = wal->nextsector; nextsec = §or[nextsectnum]; + + gotswall = 0; + + startsmostwallcnt = smostwallcnt; + startsmostcnt = smostcnt; + + if ((searchit == 2) && (searchx >= x1) && (searchx <= x2)) + { + if (searchy <= uplc[searchx]) //ceiling + { + searchsector = sectnum; searchwall = wallnum; + searchstat = 1; searchit = 1; + } + else if (searchy >= dplc[searchx]) //floor + { + searchsector = sectnum; searchwall = wallnum; + searchstat = 2; searchit = 1; + } + } + + if (nextsectnum >= 0) + { + getzsofslope((short)sectnum,wal->x,wal->y,&cz[0],&fz[0]); + getzsofslope((short)sectnum,wall[wal->point2].x,wall[wal->point2].y,&cz[1],&fz[1]); + getzsofslope((short)nextsectnum,wal->x,wal->y,&cz[2],&fz[2]); + getzsofslope((short)nextsectnum,wall[wal->point2].x,wall[wal->point2].y,&cz[3],&fz[3]); + getzsofslope((short)nextsectnum,globalposx,globalposy,&cz[4],&fz[4]); + + if ((wal->cstat&48) == 16) maskwall[maskwallcnt++] = z; + + if (((sec->ceilingstat&1) == 0) || ((nextsec->ceilingstat&1) == 0)) + { + if ((cz[2] <= cz[0]) && (cz[3] <= cz[1])) + { + if (globparaceilclip) + for(x=x1;x<=x2;x++) + if (uplc[x] > umost[x]) + if (umost[x] <= dmost[x]) + { + umost[x] = uplc[x]; + if (umost[x] > dmost[x]) numhits--; + } + } + else + { + wallmost(dwall,z,nextsectnum,(char)0); + if ((cz[2] > fz[0]) || (cz[3] > fz[1])) + for(i=x1;i<=x2;i++) if (dwall[i] > dplc[i]) dwall[i] = dplc[i]; + + if ((searchit == 2) && (searchx >= x1) && (searchx <= x2)) + if (searchy <= dwall[searchx]) //wall + { + searchsector = sectnum; searchwall = wallnum; + searchstat = 0; searchit = 1; + } + + globalorientation = (long)wal->cstat; + globalpicnum = wal->picnum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + globalxpanning = (long)wal->xpanning; + globalypanning = (long)wal->ypanning; + globalshiftval = (picsiz[globalpicnum]>>4); + if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; + globalshiftval = 32-globalshiftval; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)wallnum+16384); + globalshade = (long)wal->shade; + globvis = globalvisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalpal = (long)wal->pal; + if (palookup[globalpal] == 0) globalpal = 0; // JBF: fixes crash + globalyscale = (wal->yrepeat<<(globalshiftval-19)); + if ((globalorientation&4) == 0) + globalzd = (((globalposz-nextsec->ceilingz)*globalyscale)<<8); + else + globalzd = (((globalposz-sec->ceilingz)*globalyscale)<<8); + globalzd += (globalypanning<<24); + if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd; + + if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } + wallscan(x1,x2,uplc,dwall,swall,lwall); + + if ((cz[2] >= cz[0]) && (cz[3] >= cz[1])) + { + for(x=x1;x<=x2;x++) + if (dwall[x] > umost[x]) + if (umost[x] <= dmost[x]) + { + umost[x] = dwall[x]; + if (umost[x] > dmost[x]) numhits--; + } + } + else + { + for(x=x1;x<=x2;x++) + if (umost[x] <= dmost[x]) + { + i = max(uplc[x],dwall[x]); + if (i > umost[x]) + { + umost[x] = i; + if (umost[x] > dmost[x]) numhits--; + } + } + } + } + if ((cz[2] < cz[0]) || (cz[3] < cz[1]) || (globalposz < cz[4])) + { + i = x2-x1+1; + if (smostcnt+i < MAXYSAVES) + { + smoststart[smostwallcnt] = smostcnt; + smostwall[smostwallcnt] = z; + smostwalltype[smostwallcnt] = 1; //1 for umost + smostwallcnt++; + copybufbyte(&umost[x1],&smost[smostcnt],i*sizeof(smost[0])); + smostcnt += i; + } + } + } + if (((sec->floorstat&1) == 0) || ((nextsec->floorstat&1) == 0)) + { + if ((fz[2] >= fz[0]) && (fz[3] >= fz[1])) + { + if (globparaflorclip) + for(x=x1;x<=x2;x++) + if (dplc[x] < dmost[x]) + if (umost[x] <= dmost[x]) + { + dmost[x] = dplc[x]; + if (umost[x] > dmost[x]) numhits--; + } + } + else + { + wallmost(uwall,z,nextsectnum,(char)1); + if ((fz[2] < cz[0]) || (fz[3] < cz[1])) + for(i=x1;i<=x2;i++) if (uwall[i] < uplc[i]) uwall[i] = uplc[i]; + + if ((searchit == 2) && (searchx >= x1) && (searchx <= x2)) + if (searchy >= uwall[searchx]) //wall + { + searchsector = sectnum; searchwall = wallnum; + if ((wal->cstat&2) > 0) searchwall = wal->nextwall; + searchstat = 0; searchit = 1; + } + + if ((wal->cstat&2) > 0) + { + wallnum = wal->nextwall; wal = &wall[wallnum]; + globalorientation = (long)wal->cstat; + globalpicnum = wal->picnum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + globalxpanning = (long)wal->xpanning; + globalypanning = (long)wal->ypanning; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)wallnum+16384); + globalshade = (long)wal->shade; + globalpal = (long)wal->pal; + wallnum = thewall[z]; wal = &wall[wallnum]; + } + else + { + globalorientation = (long)wal->cstat; + globalpicnum = wal->picnum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + globalxpanning = (long)wal->xpanning; + globalypanning = (long)wal->ypanning; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)wallnum+16384); + globalshade = (long)wal->shade; + globalpal = (long)wal->pal; + } + if (palookup[globalpal] == 0) globalpal = 0; // JBF: fixes crash + globvis = globalvisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalshiftval = (picsiz[globalpicnum]>>4); + if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; + globalshiftval = 32-globalshiftval; + globalyscale = (wal->yrepeat<<(globalshiftval-19)); + if ((globalorientation&4) == 0) + globalzd = (((globalposz-nextsec->floorz)*globalyscale)<<8); + else + globalzd = (((globalposz-sec->ceilingz)*globalyscale)<<8); + globalzd += (globalypanning<<24); + if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd; + + if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } + wallscan(x1,x2,uwall,dplc,swall,lwall); + + if ((fz[2] <= fz[0]) && (fz[3] <= fz[1])) + { + for(x=x1;x<=x2;x++) + if (uwall[x] < dmost[x]) + if (umost[x] <= dmost[x]) + { + dmost[x] = uwall[x]; + if (umost[x] > dmost[x]) numhits--; + } + } + else + { + for(x=x1;x<=x2;x++) + if (umost[x] <= dmost[x]) + { + i = min(dplc[x],uwall[x]); + if (i < dmost[x]) + { + dmost[x] = i; + if (umost[x] > dmost[x]) numhits--; + } + } + } + } + if ((fz[2] > fz[0]) || (fz[3] > fz[1]) || (globalposz > fz[4])) + { + i = x2-x1+1; + if (smostcnt+i < MAXYSAVES) + { + smoststart[smostwallcnt] = smostcnt; + smostwall[smostwallcnt] = z; + smostwalltype[smostwallcnt] = 2; //2 for dmost + smostwallcnt++; + copybufbyte(&dmost[x1],&smost[smostcnt],i*sizeof(smost[0])); + smostcnt += i; + } + } + } + if (numhits < 0) return; + if ((!(wal->cstat&32)) && ((gotsector[nextsectnum>>3]&pow2char[nextsectnum&7]) == 0)) + { + if (umost[x2] < dmost[x2]) + scansector(nextsectnum); + else + { + for(x=x1;xcstat&32)) //White/1-way wall + { + globalorientation = (long)wal->cstat; + if (nextsectnum < 0) globalpicnum = wal->picnum; + else globalpicnum = wal->overpicnum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + globalxpanning = (long)wal->xpanning; + globalypanning = (long)wal->ypanning; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)wallnum+16384); + globalshade = (long)wal->shade; + globvis = globalvisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalpal = (long)wal->pal; + if (palookup[globalpal] == 0) globalpal = 0; // JBF: fixes crash + globalshiftval = (picsiz[globalpicnum]>>4); + if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; + globalshiftval = 32-globalshiftval; + globalyscale = (wal->yrepeat<<(globalshiftval-19)); + if (nextsectnum >= 0) + { + if ((globalorientation&4) == 0) globalzd = globalposz-nextsec->ceilingz; + else globalzd = globalposz-sec->ceilingz; + } + else + { + if ((globalorientation&4) == 0) globalzd = globalposz-sec->ceilingz; + else globalzd = globalposz-sec->floorz; + } + globalzd = ((globalzd*globalyscale)<<8) + (globalypanning<<24); + if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd; + + if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } + wallscan(x1,x2,uplc,dplc,swall,lwall); + + for(x=x1;x<=x2;x++) + if (umost[x] <= dmost[x]) + { umost[x] = 1; dmost[x] = 0; numhits--; } + smostwall[smostwallcnt] = z; + smostwalltype[smostwallcnt] = 0; + smostwallcnt++; + + if ((searchit == 2) && (searchx >= x1) && (searchx <= x2)) + { + searchit = 1; searchsector = sectnum; searchwall = wallnum; + if (nextsectnum < 0) searchstat = 0; else searchstat = 4; + } + } + } +} + + +// +// drawvox +// +#ifdef SUPERBUILD +static void drawvox(long dasprx, long daspry, long dasprz, long dasprang, + long daxscale, long dayscale, char daindex, + signed char dashade, char dapal, long *daumost, long *dadmost) +{ + long i, j, k, x, y, syoff, ggxstart, ggystart, nxoff; + long cosang, sinang, sprcosang, sprsinang, backx, backy, gxinc, gyinc; + long daxsiz, daysiz, dazsiz, daxpivot, daypivot, dazpivot; + long daxscalerecip, dayscalerecip, cnt, gxstart, gystart, odayscale; + long l1, l2, slabxoffs, xyvoxoffs, *longptr; + long lx, rx, nx, ny, x1=0, y1=0, z1, x2=0, y2=0, z2, yplc, yinc=0; + long yoff, xs=0, ys=0, xe, ye, xi=0, yi=0, cbackx, cbacky, dagxinc, dagyinc; + short *shortptr; + char *voxptr, *voxend, *davoxptr, oand, oand16, oand32; + + cosang = sintable[(globalang+512)&2047]; + sinang = sintable[globalang&2047]; + sprcosang = sintable[(dasprang+512)&2047]; + sprsinang = sintable[dasprang&2047]; + + i = klabs(dmulscale6(dasprx-globalposx,cosang,daspry-globalposy,sinang)); + j = (long)(getpalookup((long)mulscale21(globvis,i),(long)dashade)<<8); + setupdrawslab(ylookup[1],FP_OFF(palookup[dapal])+j); + j = 1310720; + j *= min(daxscale,dayscale); j >>= 6; //New hacks (for sized-down voxels) + for(k=0;k= MAXVOXMIPS) i = MAXVOXMIPS-1; + + if (novoxmips) i = 0; + davoxptr = (char *)voxoff[daindex][i]; + if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } + if (!davoxptr) return; + + if (voxscale[daindex] == 65536) + { daxscale <<= (i+8); dayscale <<= (i+8); } + else + { + daxscale = mulscale8(daxscale<>8); + backy = ((dmulscale10(y,sprcosang,x,-sprsinang)+daypivot)>>8); + cbackx = min(max(backx,0),daxsiz-1); + cbacky = min(max(backy,0),daysiz-1); + + sprcosang = mulscale14(daxscale,sprcosang); + sprsinang = mulscale14(daxscale,sprsinang); + + x = (dasprx-globalposx) - dmulscale18(daxpivot,sprcosang,daypivot,-sprsinang); + y = (daspry-globalposy) - dmulscale18(daypivot,sprcosang,daxpivot,sprsinang); + + cosang = mulscale16(cosang,dayscalerecip); + sinang = mulscale16(sinang,dayscalerecip); + + gxstart = y*cosang - x*sinang; + gystart = x*cosang + y*sinang; + gxinc = dmulscale10(sprsinang,cosang,sprcosang,-sinang); + gyinc = dmulscale10(sprcosang,cosang,sprsinang,sinang); + + x = 0; y = 0; j = max(daxsiz,daysiz); + for(i=0;i<=j;i++) + { + ggxinc[i] = x; x += gxinc; + ggyinc[i] = y; y += gyinc; + } + + if ((klabs(globalposz-dasprz)>>10) >= klabs(odayscale)) return; + syoff = divscale21(globalposz-dasprz,odayscale) + (dazpivot<<7); + yoff = ((klabs(gxinc)+klabs(gyinc))>>1); + longptr = (long *)davoxptr; + xyvoxoffs = ((daxsiz+1)<<2); + + begindrawing(); //{{{ + + for(cnt=0;cnt<8;cnt++) + { + switch(cnt) + { + case 0: xs = 0; ys = 0; xi = 1; yi = 1; break; + case 1: xs = daxsiz-1; ys = 0; xi = -1; yi = 1; break; + case 2: xs = 0; ys = daysiz-1; xi = 1; yi = -1; break; + case 3: xs = daxsiz-1; ys = daysiz-1; xi = -1; yi = -1; break; + case 4: xs = 0; ys = cbacky; xi = 1; yi = 2; break; + case 5: xs = daxsiz-1; ys = cbacky; xi = -1; yi = 2; break; + case 6: xs = cbackx; ys = 0; xi = 2; yi = 1; break; + case 7: xs = cbackx; ys = daysiz-1; xi = 2; yi = -1; break; + } + xe = cbackx; ye = cbacky; + if (cnt < 4) + { + if ((xi < 0) && (xe >= xs)) continue; + if ((xi > 0) && (xe <= xs)) continue; + if ((yi < 0) && (ye >= ys)) continue; + if ((yi > 0) && (ye <= ys)) continue; + } + else + { + if ((xi < 0) && (xe > xs)) continue; + if ((xi > 0) && (xe < xs)) continue; + if ((yi < 0) && (ye > ys)) continue; + if ((yi > 0) && (ye < ys)) continue; + xe += xi; ye += yi; + } + + i = ksgn(ys-backy)+ksgn(xs-backx)*3+4; + switch(i) + { + case 6: case 7: x1 = 0; y1 = 0; break; + case 8: case 5: x1 = gxinc; y1 = gyinc; break; + case 0: case 3: x1 = gyinc; y1 = -gxinc; break; + case 2: case 1: x1 = gxinc+gyinc; y1 = gyinc-gxinc; break; + } + switch(i) + { + case 2: case 5: x2 = 0; y2 = 0; break; + case 0: case 1: x2 = gxinc; y2 = gyinc; break; + case 8: case 7: x2 = gyinc; y2 = -gxinc; break; + case 6: case 3: x2 = gxinc+gyinc; y2 = gyinc-gxinc; break; + } + oand = pow2char[(xs 0) { dagxinc = gxinc; dagyinc = mulscale16(gyinc,viewingrangerecip); } + else { dagxinc = -gxinc; dagyinc = -mulscale16(gyinc,viewingrangerecip); } + + //Fix for non 90 degree viewing ranges + nxoff = mulscale16(x2-x1,viewingrangerecip); + x1 = mulscale16(x1,viewingrangerecip); + + ggxstart = gxstart+ggyinc[ys]; + ggystart = gystart-ggxinc[ys]; + + for(x=xs;x!=xe;x+=xi) + { + slabxoffs = (long)&davoxptr[B_LITTLE32(longptr[x])]; + shortptr = (short *)&davoxptr[((x*(daysiz+1))<<1)+xyvoxoffs]; + + nx = mulscale16(ggxstart+ggxinc[x],viewingrangerecip)+x1; + ny = ggystart+ggyinc[x]; + for(y=ys;y!=ye;y+=yi,nx+=dagyinc,ny-=dagxinc) + { + if ((ny <= nytooclose) || (ny >= nytoofar)) continue; + voxptr = (char *)(B_LITTLE16(shortptr[y])+slabxoffs); + voxend = (char *)(B_LITTLE16(shortptr[y+1])+slabxoffs); + if (voxptr == voxend) continue; + + lx = mulscale32(nx>>3,distrecip[(ny+y1)>>14])+halfxdimen; + if (lx < 0) lx = 0; + rx = mulscale32((nx+nxoff)>>3,distrecip[(ny+y2)>>14])+halfxdimen; + if (rx > xdimen) rx = xdimen; + if (rx <= lx) continue; + rx -= lx; + + l1 = distrecip[(ny-yoff)>>14]; + l2 = distrecip[(ny+yoff)>>14]; + for(;voxptr= 1024) yinc = divscale16(voxptr[1],z2-z1); + else if (z2 > z1) yinc = (lowrecip[z2-z1]*voxptr[1]>>8); + if (z1 < daumost[lx]) { yplc = yinc*(daumost[lx]-z1); z1 = daumost[lx]; } else yplc = 0; + } + if (z2 > dadmost[lx]) z2 = dadmost[lx]; + z2 -= z1; if (z2 <= 0) continue; + + drawslab(rx,yplc,z2,yinc,(long)&voxptr[3],ylookup[z1]+lx+frameoffset); + } + } + } + } + + enddrawing(); //}}} +} +#endif + + +// +// drawsprite (internal) +// +static void drawsprite(long snum) +{ + spritetype *tspr; + sectortype *sec; + long startum, startdm, sectnum, xb, yp, cstat; + long siz, xsiz, ysiz, xoff, yoff, xspan, yspan; + long x1, y1, x2, y2, lx, rx, dalx2, darx2, i, j, k, x, linum, linuminc; + long yinc, z, z1, z2, xp1, yp1, xp2, yp2; + long xv, yv, top, topinc, bot, botinc, hplc, hinc; + long cosang, sinang, dax, day, lpoint, lmax, rpoint, rmax, dax1, dax2, y; + long npoints, npoints2, zz, t, zsgn, zzsgn, *longptr; + long tilenum, vtilenum = 0, spritenum; + char swapped, daclip; + + //============================================================================= //POLYMOST BEGINS +#ifdef POLYMOST + if (rendmode) { polymost_drawsprite(snum); return; } +#endif + //============================================================================= //POLYMOST ENDS + + tspr = tspriteptr[snum]; + + xb = spritesx[snum]; + yp = spritesy[snum]; + tilenum = tspr->picnum; + spritenum = tspr->owner; + cstat = tspr->cstat; + +#ifdef SUPERBUILD + if ((cstat&48)==48) vtilenum = tilenum; // if the game wants voxels, it gets voxels + else if ((cstat&48)!=48 && (usevoxels) && (tiletovox[tilenum] != -1) +#if defined(POLYMOST) && defined(USE_OPENGL) + && (!(spriteext[tspr->owner].flags&SPREXT_NOTMD)) +#endif + ) { + vtilenum = tiletovox[tilenum]; + cstat |= 48; + } +#endif + + if ((cstat&48) != 48) + { + if (picanm[tilenum]&192) tilenum += animateoffs(tilenum,spritenum+32768); + if ((tilesizx[tilenum] <= 0) || (tilesizy[tilenum] <= 0) || (spritenum < 0)) + return; + } + if ((tspr->xrepeat <= 0) || (tspr->yrepeat <= 0)) return; + + sectnum = tspr->sectnum; sec = §or[sectnum]; + globalpal = tspr->pal; + if (palookup[globalpal] == 0) globalpal = 0; // JBF: fixes null-pointer crash + globalshade = tspr->shade; + if (cstat&2) + { + if (cstat&512) settransreverse(); else settransnormal(); + } + + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)tspr->xoffset); + yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)tspr->yoffset); + + if ((cstat&48) == 0) + { + if (yp <= (4<<8)) return; + + siz = divscale19(xdimenscale,yp); + + xv = mulscale16(((long)tspr->xrepeat)<<16,xyaspect); + + xspan = tilesizx[tilenum]; + yspan = tilesizy[tilenum]; + xsiz = mulscale30(siz,xv*xspan); + ysiz = mulscale14(siz,tspr->yrepeat*yspan); + + if (((tilesizx[tilenum]>>11) >= xsiz) || (yspan >= (ysiz>>1))) + return; //Watch out for divscale overflow + + x1 = xb-(xsiz>>1); + if (xspan&1) x1 += mulscale31(siz,xv); //Odd xspans + i = mulscale30(siz,xv*xoff); + if ((cstat&4) == 0) x1 -= i; else x1 += i; + + y1 = mulscale16(tspr->z-globalposz,siz); + y1 -= mulscale14(siz,tspr->yrepeat*yoff); + y1 += (globalhoriz<<8)-ysiz; + if (cstat&128) + { + y1 += (ysiz>>1); + if (yspan&1) y1 += mulscale15(siz,tspr->yrepeat); //Odd yspans + } + + x2 = x1+xsiz-1; + y2 = y1+ysiz-1; + if ((y1|255) >= (y2|255)) return; + + lx = (x1>>8)+1; if (lx < 0) lx = 0; + rx = (x2>>8); if (rx >= xdimen) rx = xdimen-1; + if (lx > rx) return; + + yinc = divscale32(yspan,ysiz); + + if ((sec->ceilingstat&3) == 0) + startum = globalhoriz+mulscale24(siz,sec->ceilingz-globalposz)-1; + else + startum = 0; + if ((sec->floorstat&3) == 0) + startdm = globalhoriz+mulscale24(siz,sec->floorz-globalposz)+1; + else + startdm = 0x7fffffff; + if ((y1>>8) > startum) startum = (y1>>8); + if ((y2>>8) < startdm) startdm = (y2>>8); + + if (startum < -32768) startum = -32768; + if (startdm > 32767) startdm = 32767; + if (startum >= startdm) return; + + if ((cstat&4) == 0) + { + linuminc = divscale24(xspan,xsiz); + linum = mulscale8((lx<<8)-x1,linuminc); + } + else + { + linuminc = -divscale24(xspan,xsiz); + linum = mulscale8((lx<<8)-x2,linuminc); + } + if ((cstat&8) > 0) + { + yinc = -yinc; + i = y1; y1 = y2; y2 = i; + } + + for(x=lx;x<=rx;x++) + { + uwall[x] = max(startumost[x+windowx1]-windowy1,(short)startum); + dwall[x] = min(startdmost[x+windowx1]-windowy1,(short)startdm); + } + daclip = 0; + for(i=smostwallcnt-1;i>=0;i--) + { + if (smostwalltype[i]&daclip) continue; + j = smostwall[i]; + if ((xb1[j] > rx) || (xb2[j] < lx)) continue; + if ((yp <= yb1[j]) && (yp <= yb2[j])) continue; + if (spritewallfront(tspr,(long)thewall[j]) && ((yp <= yb1[j]) || (yp <= yb2[j]))) continue; + + dalx2 = max(xb1[j],lx); darx2 = min(xb2[j],rx); + + switch(smostwalltype[i]) + { + case 0: + if (dalx2 <= darx2) + { + if ((dalx2 == lx) && (darx2 == rx)) return; + //clearbufbyte(&dwall[dalx2],(darx2-dalx2+1)*sizeof(dwall[0]),0L); + for (k=dalx2; k<=darx2; k++) dwall[k] = 0; + } + break; + case 1: + k = smoststart[i] - xb1[j]; + for(x=dalx2;x<=darx2;x++) + if (smost[k+x] > uwall[x]) uwall[x] = smost[k+x]; + if ((dalx2 == lx) && (darx2 == rx)) daclip |= 1; + break; + case 2: + k = smoststart[i] - xb1[j]; + for(x=dalx2;x<=darx2;x++) + if (smost[k+x] < dwall[x]) dwall[x] = smost[k+x]; + if ((dalx2 == lx) && (darx2 == rx)) daclip |= 2; + break; + } + } + + if (uwall[rx] >= dwall[rx]) + { + for(x=lx;x= 1) && (searchx >= lx) && (searchx <= rx)) + if ((searchy >= uwall[searchx]) && (searchy < dwall[searchx])) + { + searchsector = sectnum; searchwall = spritenum; + searchstat = 3; searchit = 1; + } + + z2 = tspr->z - ((yoff*tspr->yrepeat)<<2); + if (cstat&128) + { + z2 += ((yspan*tspr->yrepeat)<<1); + if (yspan&1) z2 += (tspr->yrepeat<<1); //Odd yspans + } + z1 = z2 - ((yspan*tspr->yrepeat)<<2); + + globalorientation = 0; + globalpicnum = tilenum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + globalxpanning = 0L; + globalypanning = 0L; + globvis = globalvisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalshiftval = (picsiz[globalpicnum]>>4); + if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; + globalshiftval = 32-globalshiftval; + globalyscale = divscale(512,tspr->yrepeat,globalshiftval-19); + globalzd = (((globalposz-z1)*globalyscale)<<8); + if ((cstat&8) > 0) + { + globalyscale = -globalyscale; + globalzd = (((globalposz-z2)*globalyscale)<<8); + } + + qinterpolatedown16((long)&lwall[lx],rx-lx+1,linum,linuminc); + clearbuf(&swall[lx],rx-lx+1,mulscale19(yp,xdimscale)); + + if ((cstat&2) == 0) + maskwallscan(lx,rx,uwall,dwall,swall,lwall); + else + transmaskwallscan(lx,rx); + } + else if ((cstat&48) == 16) + { + if ((cstat&4) > 0) xoff = -xoff; + if ((cstat&8) > 0) yoff = -yoff; + + xspan = tilesizx[tilenum]; yspan = tilesizy[tilenum]; + xv = tspr->xrepeat*sintable[(tspr->ang+2560+1536)&2047]; + yv = tspr->xrepeat*sintable[(tspr->ang+2048+1536)&2047]; + i = (xspan>>1)+xoff; + x1 = tspr->x-globalposx-mulscale16(xv,i); x2 = x1+mulscale16(xv,xspan); + y1 = tspr->y-globalposy-mulscale16(yv,i); y2 = y1+mulscale16(yv,xspan); + + yp1 = dmulscale6(x1,cosviewingrangeglobalang,y1,sinviewingrangeglobalang); + yp2 = dmulscale6(x2,cosviewingrangeglobalang,y2,sinviewingrangeglobalang); + if ((yp1 <= 0) && (yp2 <= 0)) return; + xp1 = dmulscale6(y1,cosglobalang,-x1,singlobalang); + xp2 = dmulscale6(y2,cosglobalang,-x2,singlobalang); + + x1 += globalposx; y1 += globalposy; + x2 += globalposx; y2 += globalposy; + + swapped = 0; + if (dmulscale32(xp1,yp2,-xp2,yp1) >= 0) //If wall's NOT facing you + { + if ((cstat&64) != 0) return; + i = xp1, xp1 = xp2, xp2 = i; + i = yp1, yp1 = yp2, yp2 = i; + i = x1, x1 = x2, x2 = i; + i = y1, y1 = y2, y2 = i; + swapped = 1; + } + + if (xp1 >= -yp1) + { + if (xp1 > yp1) return; + + if (yp1 == 0) return; + xb1[MAXWALLSB-1] = halfxdimen + scale(xp1,halfxdimen,yp1); + if (xp1 >= 0) xb1[MAXWALLSB-1]++; //Fix for SIGNED divide + if (xb1[MAXWALLSB-1] >= xdimen) xb1[MAXWALLSB-1] = xdimen-1; + yb1[MAXWALLSB-1] = yp1; + } + else + { + if (xp2 < -yp2) return; + xb1[MAXWALLSB-1] = 0; + i = yp1-yp2+xp1-xp2; + if (i == 0) return; + yb1[MAXWALLSB-1] = yp1 + scale(yp2-yp1,xp1+yp1,i); + } + if (xp2 <= yp2) + { + if (xp2 < -yp2) return; + + if (yp2 == 0) return; + xb2[MAXWALLSB-1] = halfxdimen + scale(xp2,halfxdimen,yp2) - 1; + if (xp2 >= 0) xb2[MAXWALLSB-1]++; //Fix for SIGNED divide + if (xb2[MAXWALLSB-1] >= xdimen) xb2[MAXWALLSB-1] = xdimen-1; + yb2[MAXWALLSB-1] = yp2; + } + else + { + if (xp1 > yp1) return; + + xb2[MAXWALLSB-1] = xdimen-1; + i = xp2-xp1+yp1-yp2; + if (i == 0) return; + yb2[MAXWALLSB-1] = yp1 + scale(yp2-yp1,yp1-xp1,i); + } + + if ((yb1[MAXWALLSB-1] < 256) || (yb2[MAXWALLSB-1] < 256) || (xb1[MAXWALLSB-1] > xb2[MAXWALLSB-1])) + return; + + topinc = -mulscale10(yp1,xspan); + top = (((mulscale10(xp1,xdimen) - mulscale9(xb1[MAXWALLSB-1]-halfxdimen,yp1))*xspan)>>3); + botinc = ((yp2-yp1)>>8); + bot = mulscale11(xp1-xp2,xdimen) + mulscale2(xb1[MAXWALLSB-1]-halfxdimen,botinc); + + j = xb2[MAXWALLSB-1]+3; + z = mulscale20(top,krecipasm(bot)); + lwall[xb1[MAXWALLSB-1]] = (z>>8); + for(x=xb1[MAXWALLSB-1]+4;x<=j;x+=4) + { + top += topinc; bot += botinc; + zz = z; z = mulscale20(top,krecipasm(bot)); + lwall[x] = (z>>8); + i = ((z+zz)>>1); + lwall[x-2] = (i>>8); + lwall[x-3] = ((i+zz)>>9); + lwall[x-1] = ((i+z)>>9); + } + + if (lwall[xb1[MAXWALLSB-1]] < 0) lwall[xb1[MAXWALLSB-1]] = 0; + if (lwall[xb2[MAXWALLSB-1]] >= xspan) lwall[xb2[MAXWALLSB-1]] = xspan-1; + + if ((swapped^((cstat&4)>0)) > 0) + { + j = xspan-1; + for(x=xb1[MAXWALLSB-1];x<=xb2[MAXWALLSB-1];x++) + lwall[x] = j-lwall[x]; + } + + rx1[MAXWALLSB-1] = xp1; ry1[MAXWALLSB-1] = yp1; + rx2[MAXWALLSB-1] = xp2; ry2[MAXWALLSB-1] = yp2; + + hplc = divscale19(xdimenscale,yb1[MAXWALLSB-1]); + hinc = divscale19(xdimenscale,yb2[MAXWALLSB-1]); + hinc = (hinc-hplc)/(xb2[MAXWALLSB-1]-xb1[MAXWALLSB-1]+1); + + z2 = tspr->z - ((yoff*tspr->yrepeat)<<2); + if (cstat&128) + { + z2 += ((yspan*tspr->yrepeat)<<1); + if (yspan&1) z2 += (tspr->yrepeat<<1); //Odd yspans + } + z1 = z2 - ((yspan*tspr->yrepeat)<<2); + + globalorientation = 0; + globalpicnum = tilenum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + globalxpanning = 0L; + globalypanning = 0L; + globvis = globalvisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalshiftval = (picsiz[globalpicnum]>>4); + if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; + globalshiftval = 32-globalshiftval; + globalyscale = divscale(512,tspr->yrepeat,globalshiftval-19); + globalzd = (((globalposz-z1)*globalyscale)<<8); + if ((cstat&8) > 0) + { + globalyscale = -globalyscale; + globalzd = (((globalposz-z2)*globalyscale)<<8); + } + + if (((sec->ceilingstat&1) == 0) && (z1 < sec->ceilingz)) + z1 = sec->ceilingz; + if (((sec->floorstat&1) == 0) && (z2 > sec->floorz)) + z2 = sec->floorz; + + owallmost(uwall,(long)(MAXWALLSB-1),z1-globalposz); + owallmost(dwall,(long)(MAXWALLSB-1),z2-globalposz); + for(i=xb1[MAXWALLSB-1];i<=xb2[MAXWALLSB-1];i++) + { swall[i] = (krecipasm(hplc)<<2); hplc += hinc; } + + for(i=smostwallcnt-1;i>=0;i--) + { + j = smostwall[i]; + + if ((xb1[j] > xb2[MAXWALLSB-1]) || (xb2[j] < xb1[MAXWALLSB-1])) continue; + + dalx2 = xb1[j]; darx2 = xb2[j]; + if (max(yb1[MAXWALLSB-1],yb2[MAXWALLSB-1]) > min(yb1[j],yb2[j])) + { + if (min(yb1[MAXWALLSB-1],yb2[MAXWALLSB-1]) > max(yb1[j],yb2[j])) + { + x = 0x80000000; + } + else + { + x = thewall[j]; xp1 = wall[x].x; yp1 = wall[x].y; + x = wall[x].point2; xp2 = wall[x].x; yp2 = wall[x].y; + + z1 = (xp2-xp1)*(y1-yp1) - (yp2-yp1)*(x1-xp1); + z2 = (xp2-xp1)*(y2-yp1) - (yp2-yp1)*(x2-xp1); + if ((z1^z2) >= 0) + x = (z1+z2); + else + { + z1 = (x2-x1)*(yp1-y1) - (y2-y1)*(xp1-x1); + z2 = (x2-x1)*(yp2-y1) - (y2-y1)*(xp2-x1); + + if ((z1^z2) >= 0) + x = -(z1+z2); + else + { + if ((xp2-xp1)*(tspr->y-yp1) == (tspr->x-xp1)*(yp2-yp1)) + { + if (wall[thewall[j]].nextsector == tspr->sectnum) + x = 0x80000000; + else + x = 0x7fffffff; + } + else + { //INTERSECTION! + x = (xp1-globalposx) + scale(xp2-xp1,z1,z1-z2); + y = (yp1-globalposy) + scale(yp2-yp1,z1,z1-z2); + + yp1 = dmulscale14(x,cosglobalang,y,singlobalang); + if (yp1 > 0) + { + xp1 = dmulscale14(y,cosglobalang,-x,singlobalang); + + x = halfxdimen + scale(xp1,halfxdimen,yp1); + if (xp1 >= 0) x++; //Fix for SIGNED divide + + if (z1 < 0) + { if (dalx2 < x) dalx2 = x; } + else + { if (darx2 > x) darx2 = x; } + x = 0x80000001; + } + else + x = 0x7fffffff; + } + } + } + } + if (x < 0) + { + if (dalx2 < xb1[MAXWALLSB-1]) dalx2 = xb1[MAXWALLSB-1]; + if (darx2 > xb2[MAXWALLSB-1]) darx2 = xb2[MAXWALLSB-1]; + switch(smostwalltype[i]) + { + case 0: + if (dalx2 <= darx2) + { + if ((dalx2 == xb1[MAXWALLSB-1]) && (darx2 == xb2[MAXWALLSB-1])) return; + //clearbufbyte(&dwall[dalx2],(darx2-dalx2+1)*sizeof(dwall[0]),0L); + for (k=dalx2; k<=darx2; k++) dwall[k] = 0; + } + break; + case 1: + k = smoststart[i] - xb1[j]; + for(x=dalx2;x<=darx2;x++) + if (smost[k+x] > uwall[x]) uwall[x] = smost[k+x]; + break; + case 2: + k = smoststart[i] - xb1[j]; + for(x=dalx2;x<=darx2;x++) + if (smost[k+x] < dwall[x]) dwall[x] = smost[k+x]; + break; + } + } + } + } + + //sprite + if ((searchit >= 1) && (searchx >= xb1[MAXWALLSB-1]) && (searchx <= xb2[MAXWALLSB-1])) + if ((searchy >= uwall[searchx]) && (searchy <= dwall[searchx])) + { + searchsector = sectnum; searchwall = spritenum; + searchstat = 3; searchit = 1; + } + + if ((cstat&2) == 0) { + maskwallscan(xb1[MAXWALLSB-1],xb2[MAXWALLSB-1],uwall,dwall,swall,lwall); + } else { + transmaskwallscan(xb1[MAXWALLSB-1],xb2[MAXWALLSB-1]); + } + } + else if ((cstat&48) == 32) + { + if ((cstat&64) != 0) + if ((globalposz > tspr->z) == ((cstat&8)==0)) + return; + + if ((cstat&4) > 0) xoff = -xoff; + if ((cstat&8) > 0) yoff = -yoff; + xspan = tilesizx[tilenum]; + yspan = tilesizy[tilenum]; + + //Rotate center point + dax = tspr->x-globalposx; + day = tspr->y-globalposy; + rzi[0] = dmulscale10(cosglobalang,dax,singlobalang,day); + rxi[0] = dmulscale10(cosglobalang,day,-singlobalang,dax); + + //Get top-left corner + i = ((tspr->ang+2048-globalang)&2047); + cosang = sintable[(i+512)&2047]; sinang = sintable[i]; + dax = ((xspan>>1)+xoff)*tspr->xrepeat; + day = ((yspan>>1)+yoff)*tspr->yrepeat; + rzi[0] += dmulscale12(sinang,dax,cosang,day); + rxi[0] += dmulscale12(sinang,day,-cosang,dax); + + //Get other 3 corners + dax = xspan*tspr->xrepeat; + day = yspan*tspr->yrepeat; + rzi[1] = rzi[0]-mulscale12(sinang,dax); + rxi[1] = rxi[0]+mulscale12(cosang,dax); + dax = -mulscale12(cosang,day); + day = -mulscale12(sinang,day); + rzi[2] = rzi[1]+dax; rxi[2] = rxi[1]+day; + rzi[3] = rzi[0]+dax; rxi[3] = rxi[0]+day; + + //Put all points on same z + ryi[0] = scale((tspr->z-globalposz),yxaspect,320<<8); + if (ryi[0] == 0) return; + ryi[1] = ryi[2] = ryi[3] = ryi[0]; + + if ((cstat&4) == 0) + { z = 0; z1 = 1; z2 = 3; } + else + { z = 1; z1 = 0; z2 = 2; } + + dax = rzi[z1]-rzi[z]; day = rxi[z1]-rxi[z]; + bot = dmulscale8(dax,dax,day,day); + if (((klabs(dax)>>13) >= bot) || ((klabs(day)>>13) >= bot)) return; + globalx1 = divscale18(dax,bot); + globalx2 = divscale18(day,bot); + + dax = rzi[z2]-rzi[z]; day = rxi[z2]-rxi[z]; + bot = dmulscale8(dax,dax,day,day); + if (((klabs(dax)>>13) >= bot) || ((klabs(day)>>13) >= bot)) return; + globaly1 = divscale18(dax,bot); + globaly2 = divscale18(day,bot); + + //Calculate globals for hline texture mapping function + globalxpanning = (rxi[z]<<12); + globalypanning = (rzi[z]<<12); + globalzd = (ryi[z]<<12); + + rzi[0] = mulscale16(rzi[0],viewingrange); + rzi[1] = mulscale16(rzi[1],viewingrange); + rzi[2] = mulscale16(rzi[2],viewingrange); + rzi[3] = mulscale16(rzi[3],viewingrange); + + if (ryi[0] < 0) //If ceilsprite is above you, reverse order of points + { + i = rxi[1]; rxi[1] = rxi[3]; rxi[3] = i; + i = rzi[1]; rzi[1] = rzi[3]; rzi[3] = i; + } + + + //Clip polygon in 3-space + npoints = 4; + + //Clip edge 1 + npoints2 = 0; + zzsgn = rxi[0]+rzi[0]; + for(z=0;z= 0) + { + rxi2[npoints2] = rxi[z]; ryi2[npoints2] = ryi[z]; rzi2[npoints2] = rzi[z]; + npoints2++; + } + if ((zsgn^zzsgn) < 0) + { + t = divscale30(zsgn,zsgn-zzsgn); + rxi2[npoints2] = rxi[z] + mulscale30(t,rxi[zz]-rxi[z]); + ryi2[npoints2] = ryi[z] + mulscale30(t,ryi[zz]-ryi[z]); + rzi2[npoints2] = rzi[z] + mulscale30(t,rzi[zz]-rzi[z]); + npoints2++; + } + } + if (npoints2 <= 2) return; + + //Clip edge 2 + npoints = 0; + zzsgn = rxi2[0]-rzi2[0]; + for(z=0;z= 0) + { + rxi2[npoints2] = rxi[z]; + ryi2[npoints2] = ryi[z]; + rzi2[npoints2] = rzi[z]; + npoints2++; + } + if ((zsgn^zzsgn) < 0) + { + t = divscale30(zsgn,zsgn-zzsgn); + rxi2[npoints2] = rxi[z] + mulscale30(t,rxi[zz]-rxi[z]); + ryi2[npoints2] = ryi[z] + mulscale30(t,ryi[zz]-ryi[z]); + rzi2[npoints2] = rzi[z] + mulscale30(t,rzi[zz]-rzi[z]); + npoints2++; + } + } + if (npoints2 <= 2) return; + + //Clip edge 4 + npoints = 0; + zzsgn = ryi2[0]*halfxdimen + (rzi2[0]*(globalhoriz-ydimen)); + for(z=0;z (xdimen<<16)) xsi[z] = (xdimen<<16); + if (ysi[z] < ((long)0<<16)) ysi[z] = ((long)0<<16); + if (ysi[z] > ((long)ydimen<<16)) ysi[z] = ((long)ydimen<<16); + if (xsi[z] < lmax) lmax = xsi[z], lpoint = z; + if (xsi[z] > rmax) rmax = xsi[z], rpoint = z; + } + + //Get uwall arrays + for(z=lpoint;z!=rpoint;z=zz) + { + zz = z+1; if (zz == npoints) zz = 0; + + dax1 = ((xsi[z]+65535)>>16); + dax2 = ((xsi[zz]+65535)>>16); + if (dax2 > dax1) + { + yinc = divscale16(ysi[zz]-ysi[z],xsi[zz]-xsi[z]); + y = ysi[z] + mulscale16((dax1<<16)-xsi[z],yinc); + qinterpolatedown16short((long)(&uwall[dax1]),dax2-dax1,y,yinc); + } + } + + //Get dwall arrays + for(;z!=lpoint;z=zz) + { + zz = z+1; if (zz == npoints) zz = 0; + + dax1 = ((xsi[zz]+65535)>>16); + dax2 = ((xsi[z]+65535)>>16); + if (dax2 > dax1) + { + yinc = divscale16(ysi[zz]-ysi[z],xsi[zz]-xsi[z]); + y = ysi[zz] + mulscale16((dax1<<16)-xsi[zz],yinc); + qinterpolatedown16short((long)(&dwall[dax1]),dax2-dax1,y,yinc); + } + } + + + lx = ((lmax+65535)>>16); + rx = ((rmax+65535)>>16); + for(x=lx;x<=rx;x++) + { + uwall[x] = max(uwall[x],startumost[x+windowx1]-windowy1); + dwall[x] = min(dwall[x],startdmost[x+windowx1]-windowy1); + } + + //Additional uwall/dwall clipping goes here + for(i=smostwallcnt-1;i>=0;i--) + { + j = smostwall[i]; + if ((xb1[j] > rx) || (xb2[j] < lx)) continue; + if ((yp <= yb1[j]) && (yp <= yb2[j])) continue; + + //if (spritewallfront(tspr,thewall[j]) == 0) + x = thewall[j]; xp1 = wall[x].x; yp1 = wall[x].y; + x = wall[x].point2; xp2 = wall[x].x; yp2 = wall[x].y; + x = (xp2-xp1)*(tspr->y-yp1)-(tspr->x-xp1)*(yp2-yp1); + if ((yp > yb1[j]) && (yp > yb2[j])) x = -1; + if ((x >= 0) && ((x != 0) || (wall[thewall[j]].nextsector != tspr->sectnum))) continue; + + dalx2 = max(xb1[j],lx); darx2 = min(xb2[j],rx); + + switch(smostwalltype[i]) + { + case 0: + if (dalx2 <= darx2) + { + if ((dalx2 == lx) && (darx2 == rx)) return; + //clearbufbyte(&dwall[dalx2],(darx2-dalx2+1)*sizeof(dwall[0]),0L); + for (x=dalx2; x<=darx2; x++) dwall[x] = 0; + } + break; + case 1: + k = smoststart[i] - xb1[j]; + for(x=dalx2;x<=darx2;x++) + if (smost[k+x] > uwall[x]) uwall[x] = smost[k+x]; + break; + case 2: + k = smoststart[i] - xb1[j]; + for(x=dalx2;x<=darx2;x++) + if (smost[k+x] < dwall[x]) dwall[x] = smost[k+x]; + break; + } + } + + //sprite + if ((searchit >= 1) && (searchx >= lx) && (searchx <= rx)) + if ((searchy >= uwall[searchx]) && (searchy <= dwall[searchx])) + { + searchsector = sectnum; searchwall = spritenum; + searchstat = 3; searchit = 1; + } + + globalorientation = cstat; + globalpicnum = tilenum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + //if (picanm[globalpicnum]&192) globalpicnum += animateoffs((short)globalpicnum,spritenum+32768); + + if (waloff[globalpicnum] == 0) loadtile(globalpicnum); + setgotpic(globalpicnum); + globalbufplc = waloff[globalpicnum]; + + globvis = mulscale16(globalhisibility,viewingrange); + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + + x = picsiz[globalpicnum]; y = ((x>>4)&15); x &= 15; + if (pow2long[x] != xspan) + { + x++; + globalx1 = mulscale(globalx1,xspan,x); + globalx2 = mulscale(globalx2,xspan,x); + } + + dax = globalxpanning; day = globalypanning; + globalxpanning = -dmulscale6(globalx1,day,globalx2,dax); + globalypanning = -dmulscale6(globaly1,day,globaly2,dax); + + globalx2 = mulscale16(globalx2,viewingrange); + globaly2 = mulscale16(globaly2,viewingrange); + globalzd = mulscale16(globalzd,viewingrangerecip); + + globalx1 = (globalx1-globalx2)*halfxdimen; + globaly1 = (globaly1-globaly2)*halfxdimen; + + if ((cstat&2) == 0) + msethlineshift(x,y); + else + tsethlineshift(x,y); + + //Draw it! + ceilspritescan(lx,rx-1); + } +#ifdef SUPERBUILD + else if ((cstat&48) == 48) + { + long nxrepeat, nyrepeat; + + lx = 0; rx = xdim-1; + for(x=lx;x<=rx;x++) + { + lwall[x] = (long)startumost[x+windowx1]-windowy1; + swall[x] = (long)startdmost[x+windowx1]-windowy1; + } + for(i=smostwallcnt-1;i>=0;i--) + { + j = smostwall[i]; + if ((xb1[j] > rx) || (xb2[j] < lx)) continue; + if ((yp <= yb1[j]) && (yp <= yb2[j])) continue; + if (spritewallfront(tspr,(long)thewall[j]) && ((yp <= yb1[j]) || (yp <= yb2[j]))) continue; + + dalx2 = max(xb1[j],lx); darx2 = min(xb2[j],rx); + + switch(smostwalltype[i]) + { + case 0: + if (dalx2 <= darx2) + { + if ((dalx2 == lx) && (darx2 == rx)) return; + //clearbufbyte(&swall[dalx2],(darx2-dalx2+1)*sizeof(swall[0]),0L); + for (x=dalx2; x<=darx2; x++) swall[x] = 0; + } + break; + case 1: + k = smoststart[i] - xb1[j]; + for(x=dalx2;x<=darx2;x++) + if (smost[k+x] > lwall[x]) lwall[x] = smost[k+x]; + break; + case 2: + k = smoststart[i] - xb1[j]; + for(x=dalx2;x<=darx2;x++) + if (smost[k+x] < swall[x]) swall[x] = smost[k+x]; + break; + } + } + + if (lwall[rx] >= swall[rx]) + { + for(x=lx;xxrepeat)<<16); + nyrepeat = (((long)tspr->yrepeat)<<16); + } + else + { + nxrepeat = ((long)tspr->xrepeat)*voxscale[vtilenum]; + nyrepeat = ((long)tspr->yrepeat)*voxscale[vtilenum]; + } + + if (!(cstat&128)) tspr->z -= mulscale22(B_LITTLE32(longptr[5]),nyrepeat); + yoff = (long)((signed char)((picanm[sprite[tspr->owner].picnum]>>16)&255))+((long)tspr->yoffset); + tspr->z -= mulscale14(yoff,nyrepeat); + + globvis = globalvisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + + if ((searchit >= 1) && (yp > (4<<8)) && (searchy >= lwall[searchx]) && (searchy < swall[searchx])) + { + siz = divscale19(xdimenscale,yp); + + xv = mulscale16(nxrepeat,xyaspect); + + xspan = ((B_LITTLE32(longptr[0])+B_LITTLE32(longptr[1]))>>1); + yspan = B_LITTLE32(longptr[2]); + xsiz = mulscale30(siz,xv*xspan); + ysiz = mulscale30(siz,nyrepeat*yspan); + + //Watch out for divscale overflow + if (((xspan>>11) < xsiz) && (yspan < (ysiz>>1))) + { + x1 = xb-(xsiz>>1); + if (xspan&1) x1 += mulscale31(siz,xv); //Odd xspans + i = mulscale30(siz,xv*xoff); + if ((cstat&4) == 0) x1 -= i; else x1 += i; + + y1 = mulscale16(tspr->z-globalposz,siz); + //y1 -= mulscale30(siz,nyrepeat*yoff); + y1 += (globalhoriz<<8)-ysiz; + //if (cstat&128) //Already fixed up above + y1 += (ysiz>>1); + + x2 = x1+xsiz-1; + y2 = y1+ysiz-1; + if (((y1|255) < (y2|255)) && (searchx >= (x1>>8)+1) && (searchx <= (x2>>8))) + { + if ((sec->ceilingstat&3) == 0) + startum = globalhoriz+mulscale24(siz,sec->ceilingz-globalposz)-1; + else + startum = 0; + if ((sec->floorstat&3) == 0) + startdm = globalhoriz+mulscale24(siz,sec->floorz-globalposz)+1; + else + startdm = 0x7fffffff; + + //sprite + if ((searchy >= max(startum,(y1>>8))) && (searchy < min(startdm,(y2>>8)))) + { + searchsector = sectnum; searchwall = spritenum; + searchstat = 3; searchit = 1; + } + } + } + } + + i = (long)tspr->ang+1536; +#if defined(POLYMOST) && defined(USE_OPENGL) + i += spriteext[tspr->owner].angoff; +#endif + drawvox(tspr->x,tspr->y,tspr->z,i,(long)tspr->xrepeat,(long)tspr->yrepeat,vtilenum,tspr->shade,tspr->pal,lwall,swall); + } +#endif + if (automapping == 1) show2dsprite[spritenum>>3] |= pow2char[spritenum&7]; +} + + +// +// drawmaskwall (internal) +// +static void drawmaskwall(short damaskwallcnt) +{ + long i, j, k, x, z, sectnum, z1, z2, lx, rx; + sectortype *sec, *nsec; + walltype *wal; + + //============================================================================= //POLYMOST BEGINS +#ifdef POLYMOST + if (rendmode) { polymost_drawmaskwall(damaskwallcnt); return; } +#endif + //============================================================================= //POLYMOST ENDS + + z = maskwall[damaskwallcnt]; + wal = &wall[thewall[z]]; + sectnum = thesector[z]; sec = §or[sectnum]; + nsec = §or[wal->nextsector]; + z1 = max(nsec->ceilingz,sec->ceilingz); + z2 = min(nsec->floorz,sec->floorz); + + wallmost(uwall,z,sectnum,(char)0); + wallmost(uplc,z,(long)wal->nextsector,(char)0); + for(x=xb1[z];x<=xb2[z];x++) if (uplc[x] > uwall[x]) uwall[x] = uplc[x]; + wallmost(dwall,z,sectnum,(char)1); + wallmost(dplc,z,(long)wal->nextsector,(char)1); + for(x=xb1[z];x<=xb2[z];x++) if (dplc[x] < dwall[x]) dwall[x] = dplc[x]; + prepwall(z,wal); + + globalorientation = (long)wal->cstat; + globalpicnum = wal->overpicnum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + globalxpanning = (long)wal->xpanning; + globalypanning = (long)wal->ypanning; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)thewall[z]+16384); + globalshade = (long)wal->shade; + globvis = globalvisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalpal = (long)wal->pal; + globalshiftval = (picsiz[globalpicnum]>>4); + if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++; + globalshiftval = 32-globalshiftval; + globalyscale = (wal->yrepeat<<(globalshiftval-19)); + if ((globalorientation&4) == 0) + globalzd = (((globalposz-z1)*globalyscale)<<8); + else + globalzd = (((globalposz-z2)*globalyscale)<<8); + globalzd += (globalypanning<<24); + if (globalorientation&256) globalyscale = -globalyscale, globalzd = -globalzd; + + for(i=smostwallcnt-1;i>=0;i--) + { + j = smostwall[i]; + if ((xb1[j] > xb2[z]) || (xb2[j] < xb1[z])) continue; + if (wallfront(j,z)) continue; + + lx = max(xb1[j],xb1[z]); rx = min(xb2[j],xb2[z]); + + switch(smostwalltype[i]) + { + case 0: + if (lx <= rx) + { + if ((lx == xb1[z]) && (rx == xb2[z])) return; + //clearbufbyte(&dwall[lx],(rx-lx+1)*sizeof(dwall[0]),0L); + for (x=lx; x<=rx; x++) dwall[x] = 0; + } + break; + case 1: + k = smoststart[i] - xb1[j]; + for(x=lx;x<=rx;x++) + if (smost[k+x] > uwall[x]) uwall[x] = smost[k+x]; + break; + case 2: + k = smoststart[i] - xb1[j]; + for(x=lx;x<=rx;x++) + if (smost[k+x] < dwall[x]) dwall[x] = smost[k+x]; + break; + } + } + + //maskwall + if ((searchit >= 1) && (searchx >= xb1[z]) && (searchx <= xb2[z])) + if ((searchy >= uwall[searchx]) && (searchy <= dwall[searchx])) + { + searchsector = sectnum; searchwall = thewall[z]; + searchstat = 4; searchit = 1; + } + + if ((globalorientation&128) == 0) + maskwallscan(xb1[z],xb2[z],uwall,dwall,swall,lwall); + else + { + if (globalorientation&128) + { + if (globalorientation&512) settransreverse(); else settransnormal(); + } + transmaskwallscan(xb1[z],xb2[z]); + } +} + + +// +// fillpolygon (internal) +// +static void fillpolygon(long npoints) +{ + long z, zz, x1, y1, x2, y2, miny, maxy, y, xinc, cnt; + long ox, oy, bx, by, p, day1, day2; + short *ptr, *ptr2; + +#if defined POLYMOST && defined USE_OPENGL + if (rendmode == 3) { polymost_fillpolygon(npoints); return; } +#endif + + miny = 0x7fffffff; maxy = 0x80000000; + for(z=npoints-1;z>=0;z--) + { y = ry1[z]; miny = min(miny,y); maxy = max(maxy,y); } + miny = (miny>>12); maxy = (maxy>>12); + if (miny < 0) miny = 0; + if (maxy >= ydim) maxy = ydim-1; + ptr = smost; //They're pointers! - watch how you optimize this thing + for(y=miny;y<=maxy;y++) + { + dotp1[y] = ptr; dotp2[y] = ptr+(MAXNODESPERLINE>>1); + ptr += MAXNODESPERLINE; + } + + for(z=npoints-1;z>=0;z--) + { + zz = xb1[z]; + y1 = ry1[z]; day1 = (y1>>12); + y2 = ry1[zz]; day2 = (y2>>12); + if (day1 != day2) + { + x1 = rx1[z]; x2 = rx1[zz]; + xinc = divscale12(x2-x1,y2-y1); + if (day2 > day1) + { + x1 += mulscale12((day1<<12)+4095-y1,xinc); + for(y=day1;y>12); x1 += xinc; } + } + else + { + x2 += mulscale12((day2<<12)+4095-y2,xinc); + for(y=day2;y>12); x2 += xinc; } + } + } + } + + globalx1 = mulscale16(globalx1,xyaspect); + globaly2 = mulscale16(globaly2,xyaspect); + + oy = miny+1-(ydim>>1); + globalposx += oy*globalx1; + globalposy += oy*globaly2; + + setuphlineasm4(asm1,asm2); + + ptr = smost; + for(y=miny;y<=maxy;y++) + { + cnt = dotp1[y]-ptr; ptr2 = ptr+(MAXNODESPERLINE>>1); + for(z=cnt-1;z>=0;z--) + { + day1 = 0; day2 = 0; + for(zz=z;zz>0;zz--) + { + if (ptr[zz] < ptr[day1]) day1 = zz; + if (ptr2[zz] < ptr2[day2]) day2 = zz; + } + x1 = ptr[day1]; ptr[day1] = ptr[z]; + x2 = ptr2[day2]-1; ptr2[day2] = ptr2[z]; + if (x1 > x2) continue; + + if (globalpolytype < 1) + { + //maphline + ox = x2+1-(xdim>>1); + bx = ox*asm1 + globalposx; + by = ox*asm2 - globalposy; + + p = ylookup[y]+x2+frameplace; + hlineasm4(x2-x1,-1L,globalshade<<8,by,bx,p); + } + else + { + //maphline + ox = x1+1-(xdim>>1); + bx = ox*asm1 + globalposx; + by = ox*asm2 - globalposy; + + p = ylookup[y]+x1+frameplace; + if (globalpolytype == 1) + mhline(globalbufplc,bx,(x2-x1)<<16,0L,by,p); + else + { + thline(globalbufplc,bx,(x2-x1)<<16,0L,by,p); + } + } + } + globalposx += globalx1; + globalposy += globaly2; + ptr += MAXNODESPERLINE; + } + faketimerhandler(); +} + + +// +// clippoly (internal) +// +static long clippoly(long npoints, long clipstat) +{ + long z, zz, s1, s2, t, npoints2, start2, z1, z2, z3, z4, splitcnt; + long cx1, cy1, cx2, cy2; + + cx1 = windowx1; + cy1 = windowy1; + cx2 = windowx2+1; + cy2 = windowy2+1; + cx1 <<= 12; cy1 <<= 12; cx2 <<= 12; cy2 <<= 12; + + if (clipstat&0xa) //Need to clip top or left + { + npoints2 = 0; start2 = 0; z = 0; splitcnt = 0; + do + { + s2 = cx1-rx1[z]; + do + { + zz = xb1[z]; xb1[z] = -1; + s1 = s2; s2 = cx1-rx1[zz]; + if (s1 < 0) + { + rx2[npoints2] = rx1[z]; ry2[npoints2] = ry1[z]; + xb2[npoints2] = npoints2+1; npoints2++; + } + if ((s1^s2) < 0) + { + rx2[npoints2] = rx1[z]+scale(rx1[zz]-rx1[z],s1,s1-s2); + ry2[npoints2] = ry1[z]+scale(ry1[zz]-ry1[z],s1,s1-s2); + if (s1 < 0) p2[splitcnt++] = npoints2; + xb2[npoints2] = npoints2+1; + npoints2++; + } + z = zz; + } while (xb1[z] >= 0); + + if (npoints2 >= start2+3) + xb2[npoints2-1] = start2, start2 = npoints2; + else + npoints2 = start2; + + z = 1; + while ((z < npoints) && (xb1[z] < 0)) z++; + } while (z < npoints); + if (npoints2 <= 2) return(0); + + for(z=1;z= 0); + + if (npoints >= start2+3) + xb1[npoints-1] = start2, start2 = npoints; + else + npoints = start2; + + z = 1; + while ((z < npoints2) && (xb2[z] < 0)) z++; + } while (z < npoints2); + if (npoints <= 2) return(0); + + for(z=1;z= 0); + + if (npoints2 >= start2+3) + xb2[npoints2-1] = start2, start2 = npoints2; + else + npoints2 = start2; + + z = 1; + while ((z < npoints) && (xb1[z] < 0)) z++; + } while (z < npoints); + if (npoints2 <= 2) return(0); + + for(z=1;z= 0); + + if (npoints >= start2+3) + xb1[npoints-1] = start2, start2 = npoints; + else + npoints = start2; + + z = 1; + while ((z < npoints2) && (xb2[z] < 0)) z++; + } while (z < npoints2); + if (npoints <= 2) return(0); + + for(z=1;z xres-1) cx2 = xres-1; + if (cy2 > yres-1) cy2 = yres-1; + + xsiz = tilesizx[picnum]; ysiz = tilesizy[picnum]; + if (dastat&16) { xoff = 0; yoff = 0; } + else + { + xoff = (long)((signed char)((picanm[picnum]>>8)&255))+(xsiz>>1); + yoff = (long)((signed char)((picanm[picnum]>>16)&255))+(ysiz>>1); + } + + if (dastat&4) yoff = ysiz-yoff; + + cosang = sintable[(a+512)&2047]; sinang = sintable[a&2047]; + + if ((dastat&2) != 0) //Auto window size scaling + { + if ((dastat&8) == 0) + { + x = xdimenscale; //= scale(xdimen,yxaspect,320); + sx = ((cx1+cx2+2)<<15)+scale(sx-(320<<15),xdimen,320); + sy = ((cy1+cy2+2)<<15)+mulscale16(sy-(200<<15),x); + } + else + { + //If not clipping to startmosts, & auto-scaling on, as a + //hard-coded bonus, scale to full screen instead + x = scale(xdim,yxaspect,320); + sx = (xdim<<15)+32768+scale(sx-(320<<15),xdim,320); + sy = (ydim<<15)+32768+mulscale16(sy-(200<<15),x); + } + z = mulscale16(z,x); + } + + xv = mulscale14(cosang,z); + yv = mulscale14(sinang,z); + if (((dastat&2) != 0) || ((dastat&8) == 0)) //Don't aspect unscaled perms + { + xv2 = mulscale16(xv,xyaspect); + yv2 = mulscale16(yv,xyaspect); + } + else + { + xv2 = xv; + yv2 = yv; + } + + nry1[0] = sy - (yv*xoff + xv*yoff); + nry1[1] = nry1[0] + yv*xsiz; + nry1[3] = nry1[0] + xv*ysiz; + nry1[2] = nry1[1]+nry1[3]-nry1[0]; + i = (cy1<<16); if ((nry1[0]i) && (nry1[1]>i) && (nry1[2]>i) && (nry1[3]>i)) return; + + nrx1[0] = sx - (xv2*xoff - yv2*yoff); + nrx1[1] = nrx1[0] + xv2*xsiz; + nrx1[3] = nrx1[0] - yv2*ysiz; + nrx1[2] = nrx1[1]+nrx1[3]-nrx1[0]; + i = (cx1<<16); if ((nrx1[0]i) && (nrx1[1]>i) && (nrx1[2]>i) && (nrx1[3]>i)) return; + + gx1 = nrx1[0]; gy1 = nry1[0]; //back up these before clipping + + if ((npoints = clippoly4(cx1<<16,cy1<<16,(cx2+1)<<16,(cy2+1)<<16)) < 3) return; + + lx = nrx1[0]; rx = nrx1[0]; + + nextv = 0; + for(v=npoints-1;v>=0;v--) + { + x1 = nrx1[v]; x2 = nrx1[nextv]; + dax1 = (x1>>16); if (x1 < lx) lx = x1; + dax2 = (x2>>16); if (x1 > rx) rx = x1; + if (dax1 != dax2) + { + y1 = nry1[v]; y2 = nry1[nextv]; + yinc = divscale16(y2-y1,x2-x1); + if (dax2 > dax1) + { + yplc = y1 + mulscale16((dax1<<16)+65535-x1,yinc); + qinterpolatedown16short((long)(&uplc[dax1]),dax2-dax1,yplc,yinc); + } + else + { + yplc = y2 + mulscale16((dax2<<16)+65535-x2,yinc); + qinterpolatedown16short((long)(&dplc[dax2]),dax1-dax2,yplc,yinc); + } + } + nextv = v; + } + + if (waloff[picnum] == 0) loadtile(picnum); + setgotpic(picnum); + bufplc = waloff[picnum]; + + palookupoffs = FP_OFF(palookup[dapalnum]) + (getpalookup(0L,(long)dashade)<<8); + + i = divscale32(1L,z); + xv = mulscale14(sinang,i); + yv = mulscale14(cosang,i); + if (((dastat&2) != 0) || ((dastat&8) == 0)) //Don't aspect unscaled perms + { + yv2 = mulscale16(-xv,yxaspect); + xv2 = mulscale16(yv,yxaspect); + } + else + { + yv2 = -xv; + xv2 = yv; + } + + x1 = (lx>>16); x2 = (rx>>16); + + oy = 0; + x = (x1<<16)-1-gx1; y = (oy<<16)+65535-gy1; + bx = dmulscale16(x,xv2,y,xv); + by = dmulscale16(x,yv2,y,yv); + if (dastat&4) { yv = -yv; yv2 = -yv2; by = (ysiz<<16)-1-by; } + +/* if (origbuffermode == 0) + { + if (dastat&128) + { + obuffermode = buffermode; + buffermode = 0; + setactivepage(activepage); + } + } + else if (dastat&8) + permanentupdate = 1; */ + +#ifndef ENGINE_USING_A_C + + if ((dastat&1) == 0) + { + if (((a&1023) == 0) && (ysiz <= 256)) //vlineasm4 has 256 high limit! + { + if (dastat&64) setupvlineasm(24L); else setupmvlineasm(24L); + by <<= 8; yv <<= 8; yv2 <<= 8; + + palookupoffse[0] = palookupoffse[1] = palookupoffse[2] = palookupoffse[3] = palookupoffs; + vince[0] = vince[1] = vince[2] = vince[3] = yv; + + for(x=x1;x y1) y1 = startumost[x+xx]; + if (startdmost[x+xx] < y2) y2 = startdmost[x+xx]; + } + if (y2 <= y1) continue; + + by += yv*(y1-oy); oy = y1; + + bufplce[xx] = (bx>>16)*ysiz+bufplc; + vplce[xx] = by; + y1ve[xx] = y1; + y2ve[xx] = y2-1; + bad &= ~pow2char[xx]; + } + + p = x+frameplace; + + u4 = max(max(y1ve[0],y1ve[1]),max(y1ve[2],y1ve[3])); + d4 = min(min(y2ve[0],y2ve[1]),min(y2ve[2],y2ve[3])); + + if (dastat&64) + { + if ((bad != 0) || (u4 >= d4)) + { + if (!(bad&1)) prevlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0],vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0); + if (!(bad&2)) prevlineasm1(vince[1],palookupoffse[1],y2ve[1]-y1ve[1],vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1); + if (!(bad&4)) prevlineasm1(vince[2],palookupoffse[2],y2ve[2]-y1ve[2],vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2); + if (!(bad&8)) prevlineasm1(vince[3],palookupoffse[3],y2ve[3]-y1ve[3],vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3); + continue; + } + + if (u4 > y1ve[0]) vplce[0] = prevlineasm1(vince[0],palookupoffse[0],u4-y1ve[0]-1,vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0); + if (u4 > y1ve[1]) vplce[1] = prevlineasm1(vince[1],palookupoffse[1],u4-y1ve[1]-1,vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1); + if (u4 > y1ve[2]) vplce[2] = prevlineasm1(vince[2],palookupoffse[2],u4-y1ve[2]-1,vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2); + if (u4 > y1ve[3]) vplce[3] = prevlineasm1(vince[3],palookupoffse[3],u4-y1ve[3]-1,vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3); + + if (d4 >= u4) vlineasm4(d4-u4+1,ylookup[u4]+p); + + i = p+ylookup[d4+1]; + if (y2ve[0] > d4) prevlineasm1(vince[0],palookupoffse[0],y2ve[0]-d4-1,vplce[0],bufplce[0],i+0); + if (y2ve[1] > d4) prevlineasm1(vince[1],palookupoffse[1],y2ve[1]-d4-1,vplce[1],bufplce[1],i+1); + if (y2ve[2] > d4) prevlineasm1(vince[2],palookupoffse[2],y2ve[2]-d4-1,vplce[2],bufplce[2],i+2); + if (y2ve[3] > d4) prevlineasm1(vince[3],palookupoffse[3],y2ve[3]-d4-1,vplce[3],bufplce[3],i+3); + } + else + { + if ((bad != 0) || (u4 >= d4)) + { + if (!(bad&1)) mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0],vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0); + if (!(bad&2)) mvlineasm1(vince[1],palookupoffse[1],y2ve[1]-y1ve[1],vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1); + if (!(bad&4)) mvlineasm1(vince[2],palookupoffse[2],y2ve[2]-y1ve[2],vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2); + if (!(bad&8)) mvlineasm1(vince[3],palookupoffse[3],y2ve[3]-y1ve[3],vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3); + continue; + } + + if (u4 > y1ve[0]) vplce[0] = mvlineasm1(vince[0],palookupoffse[0],u4-y1ve[0]-1,vplce[0],bufplce[0],ylookup[y1ve[0]]+p+0); + if (u4 > y1ve[1]) vplce[1] = mvlineasm1(vince[1],palookupoffse[1],u4-y1ve[1]-1,vplce[1],bufplce[1],ylookup[y1ve[1]]+p+1); + if (u4 > y1ve[2]) vplce[2] = mvlineasm1(vince[2],palookupoffse[2],u4-y1ve[2]-1,vplce[2],bufplce[2],ylookup[y1ve[2]]+p+2); + if (u4 > y1ve[3]) vplce[3] = mvlineasm1(vince[3],palookupoffse[3],u4-y1ve[3]-1,vplce[3],bufplce[3],ylookup[y1ve[3]]+p+3); + + if (d4 >= u4) mvlineasm4(d4-u4+1,ylookup[u4]+p); + + i = p+ylookup[d4+1]; + if (y2ve[0] > d4) mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-d4-1,vplce[0],bufplce[0],i+0); + if (y2ve[1] > d4) mvlineasm1(vince[1],palookupoffse[1],y2ve[1]-d4-1,vplce[1],bufplce[1],i+1); + if (y2ve[2] > d4) mvlineasm1(vince[2],palookupoffse[2],y2ve[2]-d4-1,vplce[2],bufplce[2],i+2); + if (y2ve[3] > d4) mvlineasm1(vince[3],palookupoffse[3],y2ve[3]-d4-1,vplce[3],bufplce[3],i+3); + } + + faketimerhandler(); + } + } + else + { + if (dastat&64) + { + if ((xv2&0x0000ffff) == 0) + { + qlinemode = 1; + setupqrhlineasm4(0L,yv2<<16,(xv2>>16)*ysiz+(yv2>>16),palookupoffs,0L,0L); + } + else + { + qlinemode = 0; + setuprhlineasm4(xv2<<16,yv2<<16,(xv2>>16)*ysiz+(yv2>>16),palookupoffs,ysiz,0L); + } + } + else + setuprmhlineasm4(xv2<<16,yv2<<16,(xv2>>16)*ysiz+(yv2>>16),palookupoffs,ysiz,0L); + + y1 = uplc[x1]; + if (((dastat&8) == 0) && (startumost[x1] > y1)) y1 = startumost[x1]; + y2 = y1; + for(x=x1;x ny1) ny1 = startumost[x]-1; + if (startdmost[x] < ny2) ny2 = startdmost[x]; + } + + if (ny1 < ny2-1) + { + if (ny1 >= y2) + { + while (y1 < y2-1) + { + y1++; if ((y1&31) == 0) faketimerhandler(); + + //x,y1 + bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; + if (dastat&64) { + if (qlinemode) qrhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L ,by<<16,ylookup[y1]+x+frameplace); + else rhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); + } else rmhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); + } + y1 = ny1; + } + else + { + while (y1 < ny1) + { + y1++; if ((y1&31) == 0) faketimerhandler(); + + //x,y1 + bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; + if (dastat&64) { + if (qlinemode) qrhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L ,by<<16,ylookup[y1]+x+frameplace); + else rhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); + } else rmhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); + } + while (y1 > ny1) lastx[y1--] = x; + } + while (y2 > ny2) + { + y2--; if ((y2&31) == 0) faketimerhandler(); + + //x,y2 + bx += xv*(y2-oy); by += yv*(y2-oy); oy = y2; + if (dastat&64) { + if (qlinemode) qrhlineasm4(x-lastx[y2],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L ,by<<16,ylookup[y2]+x+frameplace); + else rhlineasm4(x-lastx[y2],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y2]+x+frameplace); + } else rmhlineasm4(x-lastx[y2],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y2]+x+frameplace); + } + while (y2 < ny2) lastx[y2++] = x; + } + else + { + while (y1 < y2-1) + { + y1++; if ((y1&31) == 0) faketimerhandler(); + + //x,y1 + bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; + if (dastat&64) { + if (qlinemode) qrhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L ,by<<16,ylookup[y1]+x+frameplace); + else rhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); + } else rmhlineasm4(x-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x+frameplace); + } + if (x == x2-1) { bx += xv2; by += yv2; break; } + y1 = uplc[x+1]; + if (((dastat&8) == 0) && (startumost[x+1] > y1)) y1 = startumost[x+1]; + y2 = y1; + } + bx += xv2; by += yv2; + } + while (y1 < y2-1) + { + y1++; if ((y1&31) == 0) faketimerhandler(); + + //x2,y1 + bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; + if (dastat&64) { + if (qlinemode) qrhlineasm4(x2-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,0L,by<<16,ylookup[y1]+x2+frameplace); + else rhlineasm4(x2-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x2+frameplace); + } else rmhlineasm4(x2-lastx[y1],(bx>>16)*ysiz+(by>>16)+bufplc,0L,bx<<16,by<<16,ylookup[y1]+x2+frameplace); + } + } + } + else + { + if ((dastat&1) == 0) + { + if (dastat&64) + setupspritevline(palookupoffs,(xv>>16)*ysiz,xv<<16,ysiz,yv,0L); + else + msetupspritevline(palookupoffs,(xv>>16)*ysiz,xv<<16,ysiz,yv,0L); + } + else + { + tsetupspritevline(palookupoffs,(xv>>16)*ysiz,xv<<16,ysiz,yv,0L); + if (dastat&32) settransreverse(); else settransnormal(); + } + for(x=x1;x y1) y1 = startumost[x]; + if (startdmost[x] < y2) y2 = startdmost[x]; + } + if (y2 <= y1) continue; + + switch(y1-oy) + { + case -1: bx -= xv; by -= yv; oy = y1; break; + case 0: break; + case 1: bx += xv; by += yv; oy = y1; break; + default: bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; break; + } + + p = ylookup[y1]+x+frameplace; + + if ((dastat&1) == 0) + { + if (dastat&64) + spritevline(0L,by<<16,y2-y1+1,bx<<16,(bx>>16)*ysiz+(by>>16)+bufplc,p); + else + mspritevline(0L,by<<16,y2-y1+1,bx<<16,(bx>>16)*ysiz+(by>>16)+bufplc,p); + } + else + { + tspritevline(0L,by<<16,y2-y1+1,bx<<16,(bx>>16)*ysiz+(by>>16)+bufplc,p); + } + faketimerhandler(); + } + } + +#else // ENGINE_USING_A_C + + if ((dastat&1) == 0) + { + if (dastat&64) + setupspritevline(palookupoffs,xv,yv,ysiz); + else + msetupspritevline(palookupoffs,xv,yv,ysiz); + } + else + { + tsetupspritevline(palookupoffs,xv,yv,ysiz); + if (dastat&32) settransreverse(); else settransnormal(); + } + for(x=x1;x y1) y1 = startumost[x]; + if (startdmost[x] < y2) y2 = startdmost[x]; + } + if (y2 <= y1) continue; + + switch(y1-oy) + { + case -1: bx -= xv; by -= yv; oy = y1; break; + case 0: break; + case 1: bx += xv; by += yv; oy = y1; break; + default: bx += xv*(y1-oy); by += yv*(y1-oy); oy = y1; break; + } + + p = ylookup[y1]+x+frameplace; + + if ((dastat&1) == 0) + { + if (dastat&64) + spritevline(bx&65535,by&65535,y2-y1+1,(bx>>16)*ysiz+(by>>16)+bufplc,p); + else + mspritevline(bx&65535,by&65535,y2-y1+1,(bx>>16)*ysiz+(by>>16)+bufplc,p); + } + else + { + tspritevline(bx&65535,by&65535,y2-y1+1,(bx>>16)*ysiz+(by>>16)+bufplc,p); + //transarea += (y2-y1); + } + faketimerhandler(); + } + +#endif + +/* if ((dastat&128) && (origbuffermode == 0)) + { + buffermode = obuffermode; + setactivepage(activepage); + }*/ +} + + +// +// initksqrt (internal) +// +static void initksqrt(void) +{ + long i, j, k; + + j = 1; k = 0; + for(i=0;i<4096;i++) + { + if (i >= j) { j <<= 2; k++; } + sqrtable[i] = (unsigned short)(msqrtasm((i<<18)+131072)<<1); + shlookup[i] = (k<<1)+((10-k)<<8); + if (i < 256) shlookup[i+4096] = ((k+6)<<1)+((10-(k+6))<<8); + } +} + + +// +// dosetaspect +// +static void dosetaspect(void) +{ + long i, j, k, x, xinc,a; + + if (xyaspect != oxyaspect) + { + oxyaspect = xyaspect; + j = xyaspect*320; + horizlookup2[horizycent-1] = divscale26(131072,j); + for(i=ydim*4-1;i>=0;i--) + if (i != (horizycent-1)) + { + horizlookup[i] = divscale28(1,i-(horizycent-1)); + horizlookup2[i] = divscale14(klabs(horizlookup[i]),j); + } + } + if ((xdimen != oxdimen) || (viewingrange != oviewingrange)) + { + oxdimen = xdimen; + oviewingrange = viewingrange; + xinc = mulscale32(viewingrange*320,xdimenrecip); + x = (640<<16)-mulscale1(xinc,xdimen); + for(i=0;i>16); x += xinc; + if (j != 0) j = mulscale16((long)radarang[k+1]-(long)radarang[k],j); + radarang2[i] = (short)(((long)radarang[k]+j)>>6); + } +#ifdef SUPERBUILD + for(i=1;i<65536;i++) distrecip[i] = divscale20(xdimen,i); + nytooclose = xdimen*2100; + nytoofar = 65536*16384-1048576; +#endif + } +} + + +// +// loadtables (internal) +// +static void calcbritable(void) +{ + int i,j; + double a,b; + for(i=0;i<16;i++) { + a = (double)8 / ((double)i+8); + b = (double)255 / pow((double)255,a); + for(j=0;j<256;j++) // JBF 20040207: full 8bit precision + britable[i][j] = (char)(pow((double)j,a)*b); + } +} + +static int loadtables(void) +{ + long i, fil; + + if (tablesloaded == 0) + { + initksqrt(); + + for(i=0;i<2048;i++) reciptable[i] = divscale30(2048L,i+2048); + + if ((fil = kopen4load("tables.dat",0)) != -1) + { + kread(fil,sintable,2048*2); for (i=2048-1; i>=0; i--) sintable[i] = B_LITTLE16(sintable[i]); + kread(fil,radarang,640*2); for (i=640-1; i>=0; i--) radarang[i] = B_LITTLE16(radarang[i]); + for(i=0;i<640;i++) radarang[1279-i] = -radarang[i]; + //kread(fil,textfont,1024); + //kread(fil,smalltextfont,1024); + //kread(fil,britable,1024); + calcbritable(); + + kclose(fil); + } else { + engineerrstr = "Failed to load TABLES.DAT!"; + initprintf("ERROR: %s\n", engineerrstr); + return 1; + } + tablesloaded = 1; + } + + return 0; +} + + +// +// initfastcolorlookup (internal) +// +static void initfastcolorlookup(long rscale, long gscale, long bscale) +{ + long i, j, x, y, z; + char *pal1; + + j = 0; + for(i=64;i>=0;i--) + { + //j = (i-64)*(i-64); + rdist[i] = rdist[128-i] = j*rscale; + gdist[i] = gdist[128-i] = j*gscale; + bdist[i] = bdist[128-i] = j*bscale; + j += 129-(i<<1); + } + + //clearbufbyte(colhere,sizeof(colhere),0L); + //clearbufbyte(colhead,sizeof(colhead),0L); + Bmemset(colhere,0,sizeof(colhere)); + Bmemset(colhead,0,sizeof(colhead)); + + pal1 = (char *)&palette[768-3]; + for(i=255;i>=0;i--,pal1-=3) + { + j = (pal1[0]>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(pal1[1]>>3)*FASTPALGRIDSIZ+(pal1[2]>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1; + if (colhere[j>>3]&pow2char[j&7]) colnext[i] = colhead[j]; else colnext[i] = -1; + colhead[j] = i; + colhere[j>>3] |= pow2char[j&7]; + } + + i = 0; + for(x=-FASTPALGRIDSIZ*FASTPALGRIDSIZ;x<=FASTPALGRIDSIZ*FASTPALGRIDSIZ;x+=FASTPALGRIDSIZ*FASTPALGRIDSIZ) + for(y=-FASTPALGRIDSIZ;y<=FASTPALGRIDSIZ;y+=FASTPALGRIDSIZ) + for(z=-1;z<=1;z++) + colscan[i++] = x+y+z; + i = colscan[13]; colscan[13] = colscan[26]; colscan[26] = i; +} + + +// +// loadpalette (internal) +// +static void loadpalette(void) +{ + long fil,i; + + if (paletteloaded != 0) return; + if ((fil = kopen4load("palette.dat",0)) == -1) return; + + kread(fil,palette,768); + kread(fil,&numpalookups,2); numpalookups = B_LITTLE16(numpalookups); + + if ((palookup[0] = (char *)kkmalloc(numpalookups<<8)) == NULL) + allocache((long*)&palookup[0],numpalookups<<8,&permanentlock); + if ((transluc = (char *)kkmalloc(65536L)) == NULL) + allocache((long*)&transluc,65536,&permanentlock); + + globalpalwritten = palookup[0]; globalpal = 0; + setpalookupaddress(globalpalwritten); + + fixtransluscence(FP_OFF(transluc)); + + kread(fil,palookup[globalpal],numpalookups<<8); + kread(fil,transluc,65536); + kclose(fil); + + initfastcolorlookup(30L,59L,11L); + + paletteloaded = 1; +} + + +// +// getclosestcol (internal) +// +static long getclosestcol(long r, long g, long b) +{ + long i, j, k, dist, mindist, retcol; + char *pal1; + + j = (r>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(g>>3)*FASTPALGRIDSIZ+(b>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1; + mindist = min(rdist[coldist[r&7]+64+8],gdist[coldist[g&7]+64+8]); + mindist = min(mindist,bdist[coldist[b&7]+64+8]); + mindist++; + + r = 64-r; g = 64-g; b = 64-b; + + retcol = -1; + for(k=26;k>=0;k--) + { + i = colscan[k]+j; if ((colhere[i>>3]&pow2char[i&7]) == 0) continue; + i = colhead[i]; + do + { + pal1 = (char *)&palette[i*3]; + dist = gdist[pal1[1]+g]; + if (dist < mindist) + { + dist += rdist[pal1[0]+r]; + if (dist < mindist) + { + dist += bdist[pal1[2]+b]; + if (dist < mindist) { mindist = dist; retcol = i; } + } + } + i = colnext[i]; + } while (i >= 0); + } + if (retcol >= 0) return(retcol); + + mindist = 0x7fffffff; + pal1 = (char *)&palette[768-3]; + for(i=255;i>=0;i--,pal1-=3) + { + dist = gdist[pal1[1]+g]; if (dist >= mindist) continue; + dist += rdist[pal1[0]+r]; if (dist >= mindist) continue; + dist += bdist[pal1[2]+b]; if (dist >= mindist) continue; + mindist = dist; retcol = i; + } + return(retcol); +} + + +// +// insertspritesect (internal) +// +static long insertspritesect(short sectnum) +{ + short blanktouse; + + if ((sectnum >= MAXSECTORS) || (headspritesect[MAXSECTORS] == -1)) + return(-1); //list full + + blanktouse = headspritesect[MAXSECTORS]; + + headspritesect[MAXSECTORS] = nextspritesect[blanktouse]; + if (headspritesect[MAXSECTORS] >= 0) + prevspritesect[headspritesect[MAXSECTORS]] = -1; + + prevspritesect[blanktouse] = -1; + nextspritesect[blanktouse] = headspritesect[sectnum]; + if (headspritesect[sectnum] >= 0) + prevspritesect[headspritesect[sectnum]] = blanktouse; + headspritesect[sectnum] = blanktouse; + + sprite[blanktouse].sectnum = sectnum; + + return(blanktouse); +} + + +// +// insertspritestat (internal) +// +static long insertspritestat(short statnum) +{ + short blanktouse; + + if ((statnum >= MAXSTATUS) || (headspritestat[MAXSTATUS] == -1)) + return(-1); //list full + + blanktouse = headspritestat[MAXSTATUS]; + + headspritestat[MAXSTATUS] = nextspritestat[blanktouse]; + if (headspritestat[MAXSTATUS] >= 0) + prevspritestat[headspritestat[MAXSTATUS]] = -1; + + prevspritestat[blanktouse] = -1; + nextspritestat[blanktouse] = headspritestat[statnum]; + if (headspritestat[statnum] >= 0) + prevspritestat[headspritestat[statnum]] = blanktouse; + headspritestat[statnum] = blanktouse; + + sprite[blanktouse].statnum = statnum; + + return(blanktouse); +} + + +// +// deletespritesect (internal) +// +static long deletespritesect(short deleteme) +{ + if (sprite[deleteme].sectnum == MAXSECTORS) + return(-1); + + if (headspritesect[sprite[deleteme].sectnum] == deleteme) + headspritesect[sprite[deleteme].sectnum] = nextspritesect[deleteme]; + + if (prevspritesect[deleteme] >= 0) nextspritesect[prevspritesect[deleteme]] = nextspritesect[deleteme]; + if (nextspritesect[deleteme] >= 0) prevspritesect[nextspritesect[deleteme]] = prevspritesect[deleteme]; + + if (headspritesect[MAXSECTORS] >= 0) prevspritesect[headspritesect[MAXSECTORS]] = deleteme; + prevspritesect[deleteme] = -1; + nextspritesect[deleteme] = headspritesect[MAXSECTORS]; + headspritesect[MAXSECTORS] = deleteme; + + sprite[deleteme].sectnum = MAXSECTORS; + return(0); +} + + +// +// deletespritestat (internal) +// +static long deletespritestat(short deleteme) +{ + if (sprite[deleteme].statnum == MAXSTATUS) + return(-1); + + if (headspritestat[sprite[deleteme].statnum] == deleteme) + headspritestat[sprite[deleteme].statnum] = nextspritestat[deleteme]; + + if (prevspritestat[deleteme] >= 0) nextspritestat[prevspritestat[deleteme]] = nextspritestat[deleteme]; + if (nextspritestat[deleteme] >= 0) prevspritestat[nextspritestat[deleteme]] = prevspritestat[deleteme]; + + if (headspritestat[MAXSTATUS] >= 0) prevspritestat[headspritestat[MAXSTATUS]] = deleteme; + prevspritestat[deleteme] = -1; + nextspritestat[deleteme] = headspritestat[MAXSTATUS]; + headspritestat[MAXSTATUS] = deleteme; + + sprite[deleteme].statnum = MAXSTATUS; + return(0); +} + + +// +// lintersect (internal) +// +static long lintersect(long x1, long y1, long z1, long x2, long y2, long z2, long x3, + long y3, long x4, long y4, long *intx, long *inty, long *intz) +{ //p1 to p2 is a line segment + long x21, y21, x34, y34, x31, y31, bot, topt, topu, t; + + x21 = x2-x1; x34 = x3-x4; + y21 = y2-y1; y34 = y3-y4; + bot = x21*y34 - y21*x34; + if (bot >= 0) + { + if (bot == 0) return(0); + x31 = x3-x1; y31 = y3-y1; + topt = x31*y34 - y31*x34; if ((topt < 0) || (topt >= bot)) return(0); + topu = x21*y31 - y21*x31; if ((topu < 0) || (topu >= bot)) return(0); + } + else + { + x31 = x3-x1; y31 = y3-y1; + topt = x31*y34 - y31*x34; if ((topt > 0) || (topt <= bot)) return(0); + topu = x21*y31 - y21*x31; if ((topu > 0) || (topu <= bot)) return(0); + } + t = divscale24(topt,bot); + *intx = x1 + mulscale24(x21,t); + *inty = y1 + mulscale24(y21,t); + *intz = z1 + mulscale24(z2-z1,t); + return(1); +} + + +// +// rintersect (internal) +// +static long rintersect(long x1, long y1, long z1, long vx, long vy, long vz, long x3, + long y3, long x4, long y4, long *intx, long *inty, long *intz) +{ //p1 towards p2 is a ray + long x34, y34, x31, y31, bot, topt, topu, t; + + x34 = x3-x4; y34 = y3-y4; + bot = vx*y34 - vy*x34; + if (bot >= 0) + { + if (bot == 0) return(0); + x31 = x3-x1; y31 = y3-y1; + topt = x31*y34 - y31*x34; if (topt < 0) return(0); + topu = vx*y31 - vy*x31; if ((topu < 0) || (topu >= bot)) return(0); + } + else + { + x31 = x3-x1; y31 = y3-y1; + topt = x31*y34 - y31*x34; if (topt > 0) return(0); + topu = vx*y31 - vy*x31; if ((topu > 0) || (topu <= bot)) return(0); + } + t = divscale16(topt,bot); + *intx = x1 + mulscale16(vx,t); + *inty = y1 + mulscale16(vy,t); + *intz = z1 + mulscale16(vz,t); + return(1); +} + + +// +// keepaway (internal) +// +static void keepaway (long *x, long *y, long w) +{ + long dx, dy, ox, oy, x1, y1; + char first; + + x1 = clipit[w].x1; dx = clipit[w].x2-x1; + y1 = clipit[w].y1; dy = clipit[w].y2-y1; + ox = ksgn(-dy); oy = ksgn(dx); + first = (klabs(dx) <= klabs(dy)); + while (1) + { + if (dx*(*y-y1) > (*x-x1)*dy) return; + if (first == 0) *x += ox; else *y += oy; + first ^= 1; + } +} + + +// +// raytrace (internal) +// +static long raytrace(long x3, long y3, long *x4, long *y4) +{ + long x1, y1, x2, y2, bot, topu, nintx, ninty, cnt, z, hitwall; + long x21, y21, x43, y43; + + hitwall = -1; + for(z=clipnum-1;z>=0;z--) + { + x1 = clipit[z].x1; x2 = clipit[z].x2; x21 = x2-x1; + y1 = clipit[z].y1; y2 = clipit[z].y2; y21 = y2-y1; + + topu = x21*(y3-y1) - (x3-x1)*y21; if (topu <= 0) continue; + if (x21*(*y4-y1) > (*x4-x1)*y21) continue; + x43 = *x4-x3; y43 = *y4-y3; + if (x43*(y1-y3) > (x1-x3)*y43) continue; + if (x43*(y2-y3) <= (x2-x3)*y43) continue; + bot = x43*y21 - x21*y43; if (bot == 0) continue; + + cnt = 256; + do + { + cnt--; if (cnt < 0) { *x4 = x3; *y4 = y3; return(z); } + nintx = x3 + scale(x43,topu,bot); + ninty = y3 + scale(y43,topu,bot); + topu--; + } while (x21*(ninty-y1) <= (nintx-x1)*y21); + + if (klabs(x3-nintx)+klabs(y3-ninty) < klabs(x3-*x4)+klabs(y3-*y4)) + { *x4 = nintx; *y4 = ninty; hitwall = z; } + } + return(hitwall); +} + + + +// +// Exported Engine Functions +// + +#if !defined _WIN32 && defined DEBUGGINGAIDS +#include +static void sighandler(int sig, const siginfo_t *info, void *ctx) +{ + const char *s; + switch (sig) { + case SIGFPE: + switch (info->si_code) { + case FPE_INTDIV: s = "FPE_INTDIV (integer divide by zero)"; break; + case FPE_INTOVF: s = "FPE_INTOVF (integer overflow)"; break; + case FPE_FLTDIV: s = "FPE_FLTDIV (floating-point divide by zero)"; break; + case FPE_FLTOVF: s = "FPE_FLTOVF (floating-point overflow)"; break; + case FPE_FLTUND: s = "FPE_FLTUND (floating-point underflow)"; break; + case FPE_FLTRES: s = "FPE_FLTRES (floating-point inexact result)"; break; + case FPE_FLTINV: s = "FPE_FLTINV (floating-point invalid operation)"; break; + case FPE_FLTSUB: s = "FPE_FLTSUB (floating-point subscript out of range)"; break; + default: s = "?! (unknown)"; break; + } + fprintf(stderr, "Caught SIGFPE at address %p, code %s. Aborting.\n", info->si_addr, s); + break; + default: break; + } + abort(); +} +#endif + +// +// initengine +// +int initengine(void) +{ + long i, j; + char *e; + +#if !defined _WIN32 && defined DEBUGGINGAIDS + struct sigaction sigact, oldact; + memset(&sigact, 0, sizeof(sigact)); + sigact.sa_sigaction = sighandler; + sigact.sa_flags = SA_SIGINFO; + sigaction(SIGFPE, &sigact, &oldact); +#endif + + if (initsystem()) exit(1); + + if ((e = Bgetenv("BUILD_NOP6")) != NULL) + if (!Bstrcasecmp(e, "TRUE")) { + Bprintf("Disabling P6 optimizations.\n"); + dommxoverlay = 0; + } + if (dommxoverlay) mmxoverlay(); + + if (loadtables()) return 1; + + xyaspect = -1; + + pskyoff[0] = 0; pskybits = 0; + + parallaxtype = 2; parallaxyoffs = 0L; parallaxyscale = 65536; + showinvisibility = 0; + +#ifdef SUPERBUILD + for(i=1;i<1024;i++) lowrecip[i] = ((1<<24)-1)/i; + for(i=0;i>2,65536L); +#endif + +#ifdef POLYMOST + polymost_initosdfuncs(); +#endif + + paletteloaded = 0; + + searchit = 0; searchstat = -1; + + for(i=0;i>5),0L); + clearbuf(&show2dsprite[0],(long)((MAXSPRITES+3)>>5),0L); + clearbuf(&show2dwall[0],(long)((MAXWALLS+3)>>5),0L); + automapping = 0; + + validmodecnt = 0; + + pointhighlight = -1; + linehighlight = -1; + highlightcnt = 0; + + totalclock = 0; + visibility = 512; + parallaxvisibility = 512; + + captureformat = 0; + + loadpalette(); + getvalidmodes(); +#if defined(POLYMOST) && defined(USE_OPENGL) + if (!hicfirstinit) hicinit(); + if (!mdinited) mdinit(); +#endif + + initcrc32table(); + + return 0; +} + + +// +// uninitengine +// +void uninitengine(void) +{ + long i; + + //OSD_Printf("cacheresets = %d, cacheinvalidates = %d\n", cacheresets, cacheinvalidates); + +#if defined(POLYMOST) && defined(USE_OPENGL) + polymost_glreset(); + hicinit(); + freeallmodels(); +#endif + + uninitsystem(); + if (artfil != -1) kclose(artfil); + + if (transluc != NULL) { kkfree(transluc); transluc = NULL; } + if (pic != NULL) { kkfree(pic); pic = NULL; } + if (lookups != NULL) + { + if (lookupsalloctype == 0) kkfree((void *)lookups); + //if (lookupsalloctype == 1) suckcache(lookups); //Cache already gone + lookups = NULL; + } + for(i=0;i>1); + + globaluclip = (0-globalhoriz)*xdimscale; + globaldclip = (ydimen-globalhoriz)*xdimscale; + + i = mulscale16(xdimenscale,viewingrangerecip); + globalpisibility = mulscale16(parallaxvisibility,i); + globalvisibility = mulscale16(visibility,i); + globalhisibility = mulscale16(globalvisibility,xyaspect); + globalcisibility = mulscale8(globalhisibility,320); + + globalcursectnum = dacursectnum; + totalclocklock = totalclock; + + cosglobalang = sintable[(globalang+512)&2047]; + singlobalang = sintable[globalang&2047]; + cosviewingrangeglobalang = mulscale16(cosglobalang,viewingrange); + sinviewingrangeglobalang = mulscale16(singlobalang,viewingrange); + + if ((xyaspect != oxyaspect) || (xdimen != oxdimen) || (viewingrange != oviewingrange)) + dosetaspect(); + + //clearbufbyte(&gotsector[0],(long)((numsectors+7)>>3),0L); + Bmemset(&gotsector[0],0,(long)((numsectors+7)>>3)); + + shortptr1 = (short *)&startumost[windowx1]; + shortptr2 = (short *)&startdmost[windowx1]; + i = xdimen-1; + do + { + umost[i] = shortptr1[i]-windowy1; + dmost[i] = shortptr2[i]-windowy1; + i--; + } while (i != 0); + umost[0] = shortptr1[0]-windowy1; + dmost[0] = shortptr2[0]-windowy1; + + //============================================================================= //POLYMOST BEGINS +#ifdef POLYMOST + polymost_drawrooms(); if (rendmode) { return; } +#endif + //============================================================================= //POLYMOST ENDS + + begindrawing(); //{{{ + + //frameoffset = frameplace + viewoffset; + frameoffset = frameplace + windowy1*bytesperline + windowx1; + + //if (smostwallcnt < 0) + // if (getkensmessagecrc(FP_OFF(kensmessage)) != 0x56c764d4) + // { /* setvmode(0x3);*/ printOSD("Nice try.\n"); exit(0); } + + numhits = xdimen; numscans = 0; numbunches = 0; + maskwallcnt = 0; smostwallcnt = 0; smostcnt = 0; spritesortcnt = 0; + + if (globalcursectnum >= MAXSECTORS) + globalcursectnum -= MAXSECTORS; + else + { + i = globalcursectnum; + updatesector(globalposx,globalposy,&globalcursectnum); + if (globalcursectnum < 0) globalcursectnum = i; + } + + globparaceilclip = 1; + globparaflorclip = 1; + getzsofslope(globalcursectnum,globalposx,globalposy,&cz,&fz); + if (globalposz < cz) globparaceilclip = 0; + if (globalposz > fz) globparaflorclip = 0; + + scansector(globalcursectnum); + + if (inpreparemirror) + { + inpreparemirror = 0; + mirrorsx1 = xdimen-1; mirrorsx2 = 0; + for(i=numscans-1;i>=0;i--) + { + if (wall[thewall[i]].nextsector < 0) continue; + if (xb1[i] < mirrorsx1) mirrorsx1 = xb1[i]; + if (xb2[i] > mirrorsx2) mirrorsx2 = xb2[i]; + } + + for(i=0;i 0) && (numhits > 0)) + { + clearbuf(&tempbuf[0],(long)((numbunches+3)>>2),0L); + tempbuf[0] = 1; + + closest = 0; //Almost works, but not quite :( + for(i=1;i=0;z=p2[z]) + show2dwall[thewall[z]>>3] |= pow2char[thewall[z]&7]; + } + + numbunches--; + bunchfirst[closest] = bunchfirst[numbunches]; + bunchlast[closest] = bunchlast[numbunches]; + } + + enddrawing(); //}}} +} + + +// +// drawmasks +// +void drawmasks(void) +{ + long i, j, k, l, gap, xs, ys, xp, yp, yoff, yspan; + // PLAG: sorting stuff + long *indexes, *wallindexes, *depths, *walldepths; + long x, y; + + for(i=spritesortcnt-1;i>=0;i--) tspriteptr[i] = &tsprite[i]; + for(i=spritesortcnt-1;i>=0;i--) + { + xs = tspriteptr[i]->x-globalposx; ys = tspriteptr[i]->y-globalposy; + yp = dmulscale6(xs,cosviewingrangeglobalang,ys,sinviewingrangeglobalang); + if (yp > (4<<8)) + { + xp = dmulscale6(ys,cosglobalang,-xs,singlobalang); + if (mulscale24(labs(xp+yp),xdimen) >= yp) goto killsprite; + spritesx[i] = scale(xp+yp,xdimen<<7,yp); + } + else if ((tspriteptr[i]->cstat&48) == 0) + { +killsprite: + spritesortcnt--; //Delete face sprite if on wrong side! + if (i != spritesortcnt) + { + tspriteptr[i] = tspriteptr[spritesortcnt]; + spritesx[i] = spritesx[spritesortcnt]; + spritesy[i] = spritesy[spritesortcnt]; + } + continue; + } + spritesy[i] = yp; + } + + gap = 1; while (gap < spritesortcnt) gap = (gap<<1)+1; + for(gap>>=1;gap>0;gap>>=1) //Sort sprite list + for(i=0;i=0;l-=gap) + { + if (spritesy[l] <= spritesy[l+gap]) break; + swaplong(&tspriteptr[l],&tspriteptr[l+gap]); + swaplong(&spritesx[l],&spritesx[l+gap]); + swaplong(&spritesy[l],&spritesy[l+gap]); + } + + if (spritesortcnt > 0) + spritesy[spritesortcnt] = (spritesy[spritesortcnt-1]^1); + + ys = spritesy[0]; i = 0; + for(j=1;j<=spritesortcnt;j++) + { + if (spritesy[j] == ys) continue; + ys = spritesy[j]; + if (j > i+1) + { + for(k=i;kz; + if ((tspriteptr[k]->cstat&48) != 32) + { + yoff = (long)((signed char)((picanm[tspriteptr[k]->picnum]>>16)&255))+((long)tspriteptr[k]->yoffset); + spritesz[k] -= ((yoff*tspriteptr[k]->yrepeat)<<2); + yspan = (tilesizy[tspriteptr[k]->picnum]*tspriteptr[k]->yrepeat<<2); + if (!(tspriteptr[k]->cstat&128)) spritesz[k] -= (yspan>>1); + if (klabs(spritesz[k]-globalposz) < (yspan>>1)) spritesz[k] = globalposz; + } + } + for(k=i+1;kstatnum < tspriteptr[l]->statnum) + { + swaplong(&tspriteptr[k],&tspriteptr[l]); + swaplong(&spritesx[k],&spritesx[l]); + swaplong(&spritesy[k],&spritesy[l]); + } + } + i = j; + } + + begindrawing(); //{{{ + + /*for(i=spritesortcnt-1;i>=0;i--) + { + xs = tspriteptr[i].x-globalposx; + ys = tspriteptr[i].y-globalposy; + zs = tspriteptr[i].z-globalposz; + + xp = ys*cosglobalang-xs*singlobalang; + yp = (zs<<1); + zp = xs*cosglobalang+ys*singlobalang; + + xs = scale(xp,halfxdimen<<12,zp)+((halfxdimen+windowx1)<<12); + ys = scale(yp,xdimenscale<<12,zp)+((globalhoriz+windowy1)<<12); + + drawline256(xs-65536,ys-65536,xs+65536,ys+65536,31); + drawline256(xs+65536,ys-65536,xs-65536,ys+65536,31); + }*/ + + +#if 0 + { // Removing previous sorting code +#ifdef POLYMOST + //Hack to make it draw all opaque quads first. This should reduce the chances of + //bad sorting causing transparent quads knocking out opaque quads behind it. + // + //Need to store alpha flag with all textures before this works right! + if (rendmode == 3) + { + for(i=spritesortcnt-1;i>=0;i--) + if ((!(tspriteptr[i]->cstat&2)) +#ifdef USE_OPENGL + && (!gltexmayhavealpha(tspriteptr[i]->picnum,tspriteptr[i]->pal)) +#endif + ) + { drawsprite(i); tspriteptr[i] = 0; } //draw only if it is fully opaque + for(i=j=0;i=0;i--) + { + k = thewall[maskwall[i]]; + if ((!(wall[k].cstat&128)) +#ifdef USE_OPENGL + && (!gltexmayhavealpha(wall[k].overpicnum,wall[k].pal)) +#endif + ) + { drawmaskwall(i); maskwall[i] = -1; } //draw only if it is fully opaque + } + for(i=j=0;i 0) && (maskwallcnt > 0)) //While BOTH > 0 + { + j = maskwall[maskwallcnt-1]; + if (spritewallfront(tspriteptr[spritesortcnt-1],(long)thewall[j]) == 0) + drawsprite(--spritesortcnt); + else + { + //Check to see if any sprites behind the masked wall... + k = -1; + gap = 0; + for(i=spritesortcnt-2;i>=0;i--) + if ((xb1[j] <= (spritesx[i]>>8)) && ((spritesx[i]>>8) <= xb2[j])) + if (spritewallfront(tspriteptr[i],(long)thewall[j]) == 0) + { + drawsprite(i); + tspriteptr[i]->owner = -1; + k = i; + gap++; + } + if (k >= 0) //remove holes in sprite list + { + for(i=k;iowner >= 0) + { + if (i > k) + { + tspriteptr[k] = tspriteptr[i]; + spritesx[k] = spritesx[i]; + spritesy[k] = spritesy[i]; + } + k++; + } + spritesortcnt -= gap; + } + + //finally safe to draw the masked wall + drawmaskwall(--maskwallcnt); + } + } + while (spritesortcnt > 0) drawsprite(--spritesortcnt); + while (maskwallcnt > 0) drawmaskwall(--maskwallcnt); + } +#else + // PLAG : The heart of good transparency -> sorted rendering on all layers. + // that's why this code interleaves the drawing of all possible transparent entities + // bubblesort is used, shouldn't cause any problems cpu-wise since the lists are small + + // SPRITES PREPROCESSING + l = spritesortcnt; + indexes = malloc(l * sizeof(long)); + depths = malloc(l * sizeof(long)); + + // first pass to set base indexes and depths + i = l; + while (i > 0) + { + i--; + indexes[i] = --spritesortcnt; + depths[i] = (tspriteptr[spritesortcnt]->x - globalposx) * (tspriteptr[spritesortcnt]->x - globalposx) + + (tspriteptr[spritesortcnt]->y - globalposy) * (tspriteptr[spritesortcnt]->y - globalposy); + } + + // second pass (and possibly more) to z-sort + j = 0; + while (j == 0) + { + j = 1; + for(i=l-1;i>0;i--) + { + if (depths[i] < depths[i-1]) + { + swaplong(&indexes[i-1], &indexes[i]); + swaplong(&depths[i-1], &depths[i]); + j = 0; + } + } + } + + // MASKS PREPROCESSING + k = maskwallcnt; + wallindexes = malloc(k * sizeof(long)); + walldepths = malloc(k * sizeof(long)); + + // first pass to set base indexes and depths + i = k; + while (i > 0) + { + i--; + wallindexes[i] = --maskwallcnt; + + xs = wall[thewall[maskwall[wallindexes[i]]]].x; + ys = wall[thewall[maskwall[wallindexes[i]]]].y; + xp = wall[wall[thewall[maskwall[wallindexes[i]]]].point2].x; + yp = wall[wall[thewall[maskwall[wallindexes[i]]]].point2].y; + + x = ((xs + xp) / 2) - globalposx; + y = ((ys + yp) / 2) - globalposy; + walldepths[i] = (x * x) + (y * y); + } + + // second pass (and possibly more) to sort + j = 0; + while (j == 0) + { + j = 1; + for(i=k-1;i>0;i--) + { + if (walldepths[i] < walldepths[i-1]) + { + swaplong(&wallindexes[i-1], &wallindexes[i]); + swaplong(&walldepths[i-1], &walldepths[i]); + j = 0; + } + } + } + + // DRAWING + // in this code all sprites are drawn, and masks are inserted when needed + i = l - 1; + while (i >= 0) + { + j = k; + while (j > 0) + { + j--; + // if a mask is farther than the sprite which is about to be drawn, we draw it before then discard it from the stack + if ((wallindexes[j] >= 0) && (spriteobstructswall(tspriteptr[indexes[i]],(long)thewall[maskwall[wallindexes[j]]]))) + { + //OSD_Printf("masked - %i\n", walldepths[j]); + drawmaskwall(wallindexes[j]); + wallindexes[j] = -1; + } + } + //OSD_Printf("sprite - %i\n", depths[i]); + drawsprite(indexes[i]); + i--; + } + + // this codes draws the remaining (if any) masked walls, meaning those that are directly before the player + while (k > 0) + { + k--; + if (wallindexes[k] >= 0) + { + //OSD_Printf("masked - %i\n", walldepths[k]); + drawmaskwall(wallindexes[k]); + } + } + free(indexes); + free(wallindexes); + free(depths); + free(walldepths); +#endif /* goodalpha */ + + enddrawing(); //}}} +} + + +// +// drawmapview +// +void drawmapview(long dax, long day, long zoome, short ang) +{ + walltype *wal; + sectortype *sec; + spritetype *spr; + long tilenum, xoff, yoff, i, j, k, l, cosang, sinang, xspan, yspan; + long xrepeat, yrepeat, x, y, x1, y1, x2, y2, x3, y3, x4, y4, bakx1, baky1; + long s, w, ox, oy, startwall, cx1, cy1, cx2, cy2; + long bakgxvect, bakgyvect, sortnum, gap, npoints; + long xvect, yvect, xvect2, yvect2, daslope; + +#ifdef POLYMOST + //if (rendmode == 3) return; +#endif + + beforedrawrooms = 0; + + clearbuf(&gotsector[0],(long)((numsectors+31)>>5),0L); + + cx1 = (windowx1<<12); cy1 = (windowy1<<12); + cx2 = ((windowx2+1)<<12)-1; cy2 = ((windowy2+1)<<12)-1; + zoome <<= 8; + bakgxvect = divscale28(sintable[(1536-ang)&2047],zoome); + bakgyvect = divscale28(sintable[(2048-ang)&2047],zoome); + xvect = mulscale8(sintable[(2048-ang)&2047],zoome); + yvect = mulscale8(sintable[(1536-ang)&2047],zoome); + xvect2 = mulscale16(xvect,yxaspect); + yvect2 = mulscale16(yvect,yxaspect); + + sortnum = 0; + + begindrawing(); //{{{ + + for(s=0,sec=§or[s];s>3]&pow2char[s&7]) + { + npoints = 0; i = 0; + startwall = sec->wallptr; +#if 0 + for(w=sec->wallnum,wal=&wall[startwall];w>0;w--,wal++) + { + ox = wal->x - dax; oy = wal->y - day; + x = dmulscale16(ox,xvect,-oy,yvect) + (xdim<<11); + y = dmulscale16(oy,xvect2,ox,yvect2) + (ydim<<11); + i |= getclipmask(x-cx1,cx2-x,y-cy1,cy2-y); + rx1[npoints] = x; + ry1[npoints] = y; + xb1[npoints] = wal->point2 - startwall; + npoints++; + } +#else + j = startwall; l = 0; + for(w=sec->wallnum,wal=&wall[startwall];w>0;w--,wal++,j++) + { + k = lastwall(j); + if ((k > j) && (npoints > 0)) { xb1[npoints-1] = l; l = npoints; } //overwrite point2 + //wall[k].x wal->x wall[wal->point2].x + //wall[k].y wal->y wall[wal->point2].y + if (!dmulscale1(wal->x-wall[k].x,wall[wal->point2].y-wal->y,-(wal->y-wall[k].y),wall[wal->point2].x-wal->x)) continue; + ox = wal->x - dax; oy = wal->y - day; + x = dmulscale16(ox,xvect,-oy,yvect) + (xdim<<11); + y = dmulscale16(oy,xvect2,ox,yvect2) + (ydim<<11); + i |= getclipmask(x-cx1,cx2-x,y-cy1,cy2-y); + rx1[npoints] = x; + ry1[npoints] = y; + xb1[npoints] = npoints+1; + npoints++; + } + if (npoints > 0) xb1[npoints-1] = l; //overwrite point2 +#endif + if ((i&0xf0) != 0xf0) continue; + bakx1 = rx1[0]; baky1 = mulscale16(ry1[0]-(ydim<<11),xyaspect)+(ydim<<11); + if (i&0x0f) + { + npoints = clippoly(npoints,i); + if (npoints < 3) continue; + } + + //Collect floor sprites to draw + for(i=headspritesect[s];i>=0;i=nextspritesect[i]) + if ((sprite[i].cstat&48) == 32) + { + if ((sprite[i].cstat&(64+8)) == (64+8)) continue; + tsprite[sortnum++].owner = i; + } + + gotsector[s>>3] |= pow2char[s&7]; + + globalorientation = (long)sec->floorstat; + if ((globalorientation&1) != 0) continue; + + if (palookup[sec->floorpal] != globalpalwritten) + { + globalpalwritten = palookup[sec->floorpal]; + if (!globalpalwritten) globalpalwritten = palookup[globalpal]; // JBF: fixes null-pointer crash + setpalookupaddress(globalpalwritten); + } + globalpicnum = sec->floorpicnum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + setgotpic(globalpicnum); + if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) continue; + if ((picanm[globalpicnum]&192) != 0) globalpicnum += animateoffs((short)globalpicnum,s); + if (waloff[globalpicnum] == 0) loadtile(globalpicnum); + globalbufplc = waloff[globalpicnum]; + globalshade = max(min(sec->floorshade,numpalookups-1),0); + globvis = globalhisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalpolytype = 0; + if ((globalorientation&64) == 0) + { + globalposx = dax; globalx1 = bakgxvect; globaly1 = bakgyvect; + globalposy = day; globalx2 = bakgxvect; globaly2 = bakgyvect; + } + else + { + ox = wall[wall[startwall].point2].x - wall[startwall].x; + oy = wall[wall[startwall].point2].y - wall[startwall].y; + i = nsqrtasm(ox*ox+oy*oy); if (i == 0) continue; + i = 1048576/i; + globalx1 = mulscale10(dmulscale10(ox,bakgxvect,oy,bakgyvect),i); + globaly1 = mulscale10(dmulscale10(ox,bakgyvect,-oy,bakgxvect),i); + ox = (bakx1>>4)-(xdim<<7); oy = (baky1>>4)-(ydim<<7); + globalposx = dmulscale28(-oy,globalx1,-ox,globaly1); + globalposy = dmulscale28(-ox,globalx1,oy,globaly1); + globalx2 = -globalx1; + globaly2 = -globaly1; + + daslope = sector[s].floorheinum; + i = nsqrtasm(daslope*daslope+16777216); + globalposy = mulscale12(globalposy,i); + globalx2 = mulscale12(globalx2,i); + globaly2 = mulscale12(globaly2,i); + } + globalxshift = (8-(picsiz[globalpicnum]&15)); + globalyshift = (8-(picsiz[globalpicnum]>>4)); + if (globalorientation&8) {globalxshift++; globalyshift++; } + + sethlinesizes(picsiz[globalpicnum]&15,picsiz[globalpicnum]>>4,globalbufplc); + + if ((globalorientation&0x4) > 0) + { + i = globalposx; globalposx = -globalposy; globalposy = -i; + i = globalx2; globalx2 = globaly1; globaly1 = i; + i = globalx1; globalx1 = -globaly2; globaly2 = -i; + } + if ((globalorientation&0x10) > 0) globalx1 = -globalx1, globaly1 = -globaly1, globalposx = -globalposx; + if ((globalorientation&0x20) > 0) globalx2 = -globalx2, globaly2 = -globaly2, globalposy = -globalposy; + asm1 = (globaly1<floorxpanning)<<24); + globalposy = (globalposy<<(20+globalyshift))-(((long)sec->floorypanning)<<24); + + fillpolygon(npoints); + } + + //Sort sprite list + gap = 1; while (gap < sortnum) gap = (gap<<1)+1; + for(gap>>=1;gap>0;gap>>=1) + for(i=0;i=0;j-=gap) + { + if (sprite[tsprite[j].owner].z <= sprite[tsprite[j+gap].owner].z) break; + swapshort(&tsprite[j].owner,&tsprite[j+gap].owner); + } + + for(s=sortnum-1;s>=0;s--) + { + spr = &sprite[tsprite[s].owner]; + if ((spr->cstat&48) == 32) + { + npoints = 0; + + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + if ((spr->cstat&4) > 0) xoff = -xoff; + if ((spr->cstat&8) > 0) yoff = -yoff; + + k = spr->ang; + cosang = sintable[(k+512)&2047]; sinang = sintable[k]; + xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; + yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; + + ox = ((xspan>>1)+xoff)*xrepeat; oy = ((yspan>>1)+yoff)*yrepeat; + x1 = spr->x + mulscale(sinang,ox,16) + mulscale(cosang,oy,16); + y1 = spr->y + mulscale(sinang,oy,16) - mulscale(cosang,ox,16); + l = xspan*xrepeat; + x2 = x1 - mulscale(sinang,l,16); + y2 = y1 + mulscale(cosang,l,16); + l = yspan*yrepeat; + k = -mulscale(cosang,l,16); x3 = x2+k; x4 = x1+k; + k = -mulscale(sinang,l,16); y3 = y2+k; y4 = y1+k; + + xb1[0] = 1; xb1[1] = 2; xb1[2] = 3; xb1[3] = 0; + npoints = 4; + + i = 0; + + ox = x1 - dax; oy = y1 - day; + x = dmulscale16(ox,xvect,-oy,yvect) + (xdim<<11); + y = dmulscale16(oy,xvect2,ox,yvect2) + (ydim<<11); + i |= getclipmask(x-cx1,cx2-x,y-cy1,cy2-y); + rx1[0] = x; ry1[0] = y; + + ox = x2 - dax; oy = y2 - day; + x = dmulscale16(ox,xvect,-oy,yvect) + (xdim<<11); + y = dmulscale16(oy,xvect2,ox,yvect2) + (ydim<<11); + i |= getclipmask(x-cx1,cx2-x,y-cy1,cy2-y); + rx1[1] = x; ry1[1] = y; + + ox = x3 - dax; oy = y3 - day; + x = dmulscale16(ox,xvect,-oy,yvect) + (xdim<<11); + y = dmulscale16(oy,xvect2,ox,yvect2) + (ydim<<11); + i |= getclipmask(x-cx1,cx2-x,y-cy1,cy2-y); + rx1[2] = x; ry1[2] = y; + + x = rx1[0]+rx1[2]-rx1[1]; + y = ry1[0]+ry1[2]-ry1[1]; + i |= getclipmask(x-cx1,cx2-x,y-cy1,cy2-y); + rx1[3] = x; ry1[3] = y; + + if ((i&0xf0) != 0xf0) continue; + bakx1 = rx1[0]; baky1 = mulscale16(ry1[0]-(ydim<<11),xyaspect)+(ydim<<11); + if (i&0x0f) + { + npoints = clippoly(npoints,i); + if (npoints < 3) continue; + } + + globalpicnum = spr->picnum; + if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; + setgotpic(globalpicnum); + if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) continue; + if ((picanm[globalpicnum]&192) != 0) globalpicnum += animateoffs((short)globalpicnum,s); + if (waloff[globalpicnum] == 0) loadtile(globalpicnum); + globalbufplc = waloff[globalpicnum]; + if ((sector[spr->sectnum].ceilingstat&1) > 0) + globalshade = ((long)sector[spr->sectnum].ceilingshade); + else + globalshade = ((long)sector[spr->sectnum].floorshade); + globalshade = max(min(globalshade+spr->shade+6,numpalookups-1),0); + asm3 = FP_OFF(palookup[spr->pal]+(globalshade<<8)); + globvis = globalhisibility; + if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16))); + globalpolytype = ((spr->cstat&2)>>1)+1; + + //relative alignment stuff + ox = x2-x1; oy = y2-y1; + i = ox*ox+oy*oy; if (i == 0) continue; i = (65536*16384)/i; + globalx1 = mulscale10(dmulscale10(ox,bakgxvect,oy,bakgyvect),i); + globaly1 = mulscale10(dmulscale10(ox,bakgyvect,-oy,bakgxvect),i); + ox = y1-y4; oy = x4-x1; + i = ox*ox+oy*oy; if (i == 0) continue; i = (65536*16384)/i; + globalx2 = mulscale10(dmulscale10(ox,bakgxvect,oy,bakgyvect),i); + globaly2 = mulscale10(dmulscale10(ox,bakgyvect,-oy,bakgxvect),i); + + ox = picsiz[globalpicnum]; oy = ((ox>>4)&15); ox &= 15; + if (pow2long[ox] != xspan) + { + ox++; + globalx1 = mulscale(globalx1,xspan,ox); + globaly1 = mulscale(globaly1,xspan,ox); + } + + bakx1 = (bakx1>>4)-(xdim<<7); baky1 = (baky1>>4)-(ydim<<7); + globalposx = dmulscale28(-baky1,globalx1,-bakx1,globaly1); + globalposy = dmulscale28(bakx1,globalx2,-baky1,globaly2); + + if ((spr->cstat&2) == 0) + msethlineshift(ox,oy); + else { + if (spr->cstat&512) settransreverse(); else settransnormal(); + tsethlineshift(ox,oy); + } + + if ((spr->cstat&0x4) > 0) globalx1 = -globalx1, globaly1 = -globaly1, globalposx = -globalposx; + asm1 = (globaly1<<2); globalx1 <<= 2; globalposx <<= (20+2); + asm2 = (globalx2<<2); globaly2 <<= 2; globalposy <<= (20+2); + + globalorientation = ((spr->cstat&2)<<7) | ((spr->cstat&512)>>2); // so polymost can get the translucency. ignored in software mode. + fillpolygon(npoints); + } + } + + enddrawing(); //}}} +} + + +// +// loadboard +// +long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long *daposz, + short *daang, short *dacursectnum) +{ + short fil, i, numsprites; + + i = strlen(filename)-1; + if (filename[i] == 255) { filename[i] = 0; fromwhere = 1; } // JBF 20040119: "compatibility" + if ((fil = kopen4load(filename,fromwhere)) == -1) + { mapversion = 7L; return(-1); } + + kread(fil,&mapversion,4); mapversion = B_LITTLE32(mapversion); + if (mapversion != 7L && mapversion != 8L) { kclose(fil); return(-2); } + + /* + // Enable this for doing map checksum tests + clearbufbyte(&wall, sizeof(wall), 0); + clearbufbyte(§or, sizeof(sector), 0); + clearbufbyte(&sprite, sizeof(sprite), 0); + */ + + initspritelists(); + +#define MYMAXSECTORS (mapversion==7l?MAXSECTORSV7:MAXSECTORSV8) +#define MYMAXWALLS (mapversion==7l?MAXWALLSV7:MAXWALLSV8) +#define MYMAXSPRITES (mapversion==7l?MAXSPRITESV7:MAXSPRITESV8) + + clearbuf(&show2dsector[0],(long)((MYMAXSECTORS+3)>>5),0L); + clearbuf(&show2dsprite[0],(long)((MYMAXSPRITES+3)>>5),0L); + clearbuf(&show2dwall[0],(long)((MYMAXWALLS+3)>>5),0L); + + kread(fil,daposx,4); *daposx = B_LITTLE32(*daposx); + kread(fil,daposy,4); *daposy = B_LITTLE32(*daposy); + kread(fil,daposz,4); *daposz = B_LITTLE32(*daposz); + kread(fil,daang,2); *daang = B_LITTLE16(*daang); + kread(fil,dacursectnum,2); *dacursectnum = B_LITTLE16(*dacursectnum); + + kread(fil,&numsectors,2); numsectors = B_LITTLE16(numsectors); + if (numsectors > MYMAXSECTORS) { kclose(fil); return(-1); } + kread(fil,§or[0],sizeof(sectortype)*numsectors); + for (i=numsectors-1; i>=0; i--) { + sector[i].wallptr = B_LITTLE16(sector[i].wallptr); + sector[i].wallnum = B_LITTLE16(sector[i].wallnum); + sector[i].ceilingz = B_LITTLE32(sector[i].ceilingz); + sector[i].floorz = B_LITTLE32(sector[i].floorz); + sector[i].ceilingstat = B_LITTLE16(sector[i].ceilingstat); + sector[i].floorstat = B_LITTLE16(sector[i].floorstat); + sector[i].ceilingpicnum = B_LITTLE16(sector[i].ceilingpicnum); + sector[i].ceilingheinum = B_LITTLE16(sector[i].ceilingheinum); + sector[i].floorpicnum = B_LITTLE16(sector[i].floorpicnum); + sector[i].floorheinum = B_LITTLE16(sector[i].floorheinum); + sector[i].lotag = B_LITTLE16(sector[i].lotag); + sector[i].hitag = B_LITTLE16(sector[i].hitag); + sector[i].extra = B_LITTLE16(sector[i].extra); + } + + kread(fil,&numwalls,2); numwalls = B_LITTLE16(numwalls); + if (numwalls > MYMAXWALLS) { kclose(fil); return(-1); } + kread(fil,&wall[0],sizeof(walltype)*numwalls); + for (i=numwalls-1; i>=0; i--) { + wall[i].x = B_LITTLE32(wall[i].x); + wall[i].y = B_LITTLE32(wall[i].y); + wall[i].point2 = B_LITTLE16(wall[i].point2); + wall[i].nextwall = B_LITTLE16(wall[i].nextwall); + wall[i].nextsector = B_LITTLE16(wall[i].nextsector); + wall[i].cstat = B_LITTLE16(wall[i].cstat); + wall[i].picnum = B_LITTLE16(wall[i].picnum); + wall[i].overpicnum = B_LITTLE16(wall[i].overpicnum); + wall[i].lotag = B_LITTLE16(wall[i].lotag); + wall[i].hitag = B_LITTLE16(wall[i].hitag); + wall[i].extra = B_LITTLE16(wall[i].extra); + } + + kread(fil,&numsprites,2); numsprites = B_LITTLE16(numsprites); + if (numsprites > MYMAXSPRITES) { kclose(fil); return(-1); } + kread(fil,&sprite[0],sizeof(spritetype)*numsprites); + for (i=numsprites-1; i>=0; i--) { + sprite[i].x = B_LITTLE32(sprite[i].x); + sprite[i].y = B_LITTLE32(sprite[i].y); + sprite[i].z = B_LITTLE32(sprite[i].z); + sprite[i].cstat = B_LITTLE16(sprite[i].cstat); + sprite[i].picnum = B_LITTLE16(sprite[i].picnum); + sprite[i].sectnum = B_LITTLE16(sprite[i].sectnum); + sprite[i].statnum = B_LITTLE16(sprite[i].statnum); + sprite[i].ang = B_LITTLE16(sprite[i].ang); + sprite[i].owner = B_LITTLE16(sprite[i].owner); + sprite[i].xvel = B_LITTLE16(sprite[i].xvel); + sprite[i].yvel = B_LITTLE16(sprite[i].yvel); + sprite[i].zvel = B_LITTLE16(sprite[i].zvel); + sprite[i].lotag = B_LITTLE16(sprite[i].lotag); + sprite[i].hitag = B_LITTLE16(sprite[i].hitag); + sprite[i].extra = B_LITTLE16(sprite[i].extra); + } + + for(i=0;i= startwall) && (theline <= endwall)) + { + sucksect = i; + break; + } + } + return(sucksect); +} + +static void convertv5sectv6(struct sectortypev5 *from, struct sectortypev6 *to) +{ + to->wallptr = from->wallptr; + to->wallnum = from->wallnum; + to->ceilingpicnum = from->ceilingpicnum; + to->floorpicnum = from->floorpicnum; + to->ceilingheinum = from->ceilingheinum; + to->floorheinum = from->floorheinum; + to->ceilingz = from->ceilingz; + to->floorz = from->floorz; + to->ceilingshade = from->ceilingshade; + to->floorshade = from->floorshade; + to->ceilingxpanning = from->ceilingxpanning; + to->floorxpanning = from->floorxpanning; + to->ceilingypanning = from->ceilingypanning; + to->floorypanning = from->floorypanning; + to->ceilingstat = from->ceilingstat; + to->floorstat = from->floorstat; + to->ceilingpal = from->ceilingpal; + to->floorpal = from->floorpal; + to->visibility = from->visibility; + to->lotag = from->lotag; + to->hitag = from->hitag; + to->extra = from->extra; +} + +static void convertv5wallv6(struct walltypev5 *from, struct walltypev6 *to, long i) +{ + to->x = from->x; + to->y = from->y; + to->point2 = from->point2; + to->nextsector = from->nextsector1; + to->nextwall = from->nextwall1; + to->picnum = from->picnum; + to->overpicnum = from->overpicnum; + to->shade = from->shade; + to->pal = sector[sectorofwallv5((short)i)].floorpal; + to->cstat = from->cstat; + to->xrepeat = from->xrepeat; + to->yrepeat = from->yrepeat; + to->xpanning = from->xpanning; + to->ypanning = from->ypanning; + to->lotag = from->lotag; + to->hitag = from->hitag; + to->extra = from->extra; +} + +static void convertv5sprv6(struct spritetypev5 *from, struct spritetypev6 *to) +{ + short j; + to->x = from->x; + to->y = from->y; + to->z = from->z; + to->cstat = from->cstat; + to->shade = from->shade; + + j = from->sectnum; + if ((sector[j].ceilingstat&1) > 0) + to->pal = sector[j].ceilingpal; + else + to->pal = sector[j].floorpal; + + to->clipdist = 32; + to->xrepeat = from->xrepeat; + to->yrepeat = from->yrepeat; + to->xoffset = 0; + to->yoffset = 0; + to->picnum = from->picnum; + to->ang = from->ang; + to->xvel = from->xvel; + to->yvel = from->yvel; + to->zvel = from->zvel; + to->owner = from->owner; + to->sectnum = from->sectnum; + to->statnum = from->statnum; + to->lotag = from->lotag; + to->hitag = from->hitag; + to->extra = from->extra; +} + +static void convertv6sectv7(struct sectortypev6 *from, sectortype *to) +{ + to->ceilingz = from->ceilingz; + to->floorz = from->floorz; + to->wallptr = from->wallptr; + to->wallnum = from->wallnum; + to->ceilingpicnum = from->ceilingpicnum; + to->ceilingheinum = max(min(((long)from->ceilingheinum)<<5,32767),-32768); + if ((from->ceilingstat&2) == 0) to->ceilingheinum = 0; + to->ceilingshade = from->ceilingshade; + to->ceilingpal = from->ceilingpal; + to->ceilingxpanning = from->ceilingxpanning; + to->ceilingypanning = from->ceilingypanning; + to->floorpicnum = from->floorpicnum; + to->floorheinum = max(min(((long)from->floorheinum)<<5,32767),-32768); + if ((from->floorstat&2) == 0) to->floorheinum = 0; + to->floorshade = from->floorshade; + to->floorpal = from->floorpal; + to->floorxpanning = from->floorxpanning; + to->floorypanning = from->floorypanning; + to->ceilingstat = from->ceilingstat; + to->floorstat = from->floorstat; + to->visibility = from->visibility; + to->filler = 0; + to->lotag = from->lotag; + to->hitag = from->hitag; + to->extra = from->extra; +} + +static void convertv6wallv7(struct walltypev6 *from, walltype *to) +{ + to->x = from->x; + to->y = from->y; + to->point2 = from->point2; + to->nextwall = from->nextwall; + to->nextsector = from->nextsector; + to->cstat = from->cstat; + to->picnum = from->picnum; + to->overpicnum = from->overpicnum; + to->shade = from->shade; + to->pal = from->pal; + to->xrepeat = from->xrepeat; + to->yrepeat = from->yrepeat; + to->xpanning = from->xpanning; + to->ypanning = from->ypanning; + to->lotag = from->lotag; + to->hitag = from->hitag; + to->extra = from->extra; +} + +static void convertv6sprv7(struct spritetypev6 *from, spritetype *to) +{ + to->x = from->x; + to->y = from->y; + to->z = from->z; + to->cstat = from->cstat; + to->picnum = from->picnum; + to->shade = from->shade; + to->pal = from->pal; + to->clipdist = from->clipdist; + to->filler = 0; + to->xrepeat = from->xrepeat; + to->yrepeat = from->yrepeat; + to->xoffset = from->xoffset; + to->yoffset = from->yoffset; + to->sectnum = from->sectnum; + to->statnum = from->statnum; + to->ang = from->ang; + to->owner = from->owner; + to->xvel = from->xvel; + to->yvel = from->yvel; + to->zvel = from->zvel; + to->lotag = from->lotag; + to->hitag = from->hitag; + to->extra = from->extra; +} + +// Powerslave uses v6 +// Witchaven 1 and TekWar use v5 +long loadoldboard(char *filename, char fromwhere, long *daposx, long *daposy, long *daposz, + short *daang, short *dacursectnum) +{ + short fil, i, numsprites; + struct sectortypev5 v5sect; + struct walltypev5 v5wall; + struct spritetypev5 v5spr; + struct sectortypev6 v6sect; + struct walltypev6 v6wall; + struct spritetypev6 v6spr; + + i = strlen(filename)-1; + if (filename[i] == 255) { filename[i] = 0; fromwhere = 1; } // JBF 20040119: "compatibility" + if ((fil = kopen4load(filename,fromwhere)) == -1) + { mapversion = 5L; return(-1); } + + kread(fil,&mapversion,4); mapversion = B_LITTLE32(mapversion); + if (mapversion != 5L && mapversion != 6L) { kclose(fil); return(-2); } + + initspritelists(); + + clearbuf(&show2dsector[0],(long)((MAXSECTORS+3)>>5),0L); + clearbuf(&show2dsprite[0],(long)((MAXSPRITES+3)>>5),0L); + clearbuf(&show2dwall[0],(long)((MAXWALLS+3)>>5),0L); + + kread(fil,daposx,4); *daposx = B_LITTLE32(*daposx); + kread(fil,daposy,4); *daposy = B_LITTLE32(*daposy); + kread(fil,daposz,4); *daposz = B_LITTLE32(*daposz); + kread(fil,daang,2); *daang = B_LITTLE16(*daang); + kread(fil,dacursectnum,2); *dacursectnum = B_LITTLE16(*dacursectnum); + + kread(fil,&numsectors,2); numsectors = B_LITTLE16(numsectors); + if (numsectors > MAXSECTORS) { kclose(fil); return(-1); } + for (i=0; i MAXWALLS) { kclose(fil); return(-1); } + for (i=0; i MAXSPRITES) { kclose(fil); return(-1); } + for (i=0; iltextptr; + switch (legaltokens[i].tokenid) { + case 0: // sprite + if (scriptfile_getnumber(script, &whichsprite)) break; + + if ((unsigned)whichsprite >= (unsigned)MAXSPRITES) { + // sprite number out of range + initprintf("Sprite number out of range 0-%d on line %s:%d\n", + MAXSPRITES-1,script->filename, scriptfile_getlinum(script,cmdtokptr)); + whichsprite = -1; + break; + } + + break; + case 1: // angoff + { + int ang; + if (scriptfile_getnumber(script, &ang)) break; + + if (whichsprite < 0) { + // no sprite directive preceeding + initprintf("Ignoring angle offset directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + spriteext[whichsprite].angoff = (short)ang; + } + break; + case 2: // notmd + if (whichsprite < 0) { + // no sprite directive preceeding + initprintf("Ignoring not-MD2/MD3 directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + spriteext[whichsprite].flags |= SPREXT_NOTMD; + break; + case 3: // nomdanim + if (whichsprite < 0) { + // no sprite directive preceeding + initprintf("Ignoring no-MD2/MD3-anim directive because of absent/invalid sprite number on line %s:%d\n", + script->filename, scriptfile_getlinum(script,cmdtokptr)); + break; + } + spriteext[whichsprite].flags |= SPREXT_NOMDANIM; + break; + default: + // unrecognised token + break; + } + } + + scriptfile_close(script); + return 0; +} +#else +long loadmaphack(char *filename) { return -1; } +#endif + + +// +// saveboard +// +long saveboard(char *filename, long *daposx, long *daposy, long *daposz, + short *daang, short *dacursectnum) +{ + short fil, i, j, numsprites, ts; + long tl; + sectortype tsect; + walltype twall; + spritetype tspri; + + if ((fil = Bopen(filename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) + return(-1); + + numsprites = 0; + for(j=0;j MAXSECTORSV7 || numwalls > MAXWALLSV7 || numsprites > MAXSPRITESV7) + mapversion = 8; + else + mapversion = 7; + tl = B_LITTLE32(mapversion); Bwrite(fil,&tl,4); + + tl = B_LITTLE32(*daposx); Bwrite(fil,&tl,4); + tl = B_LITTLE32(*daposy); Bwrite(fil,&tl,4); + tl = B_LITTLE32(*daposz); Bwrite(fil,&tl,4); + ts = B_LITTLE16(*daang); Bwrite(fil,&ts,2); + ts = B_LITTLE16(*dacursectnum); Bwrite(fil,&ts,2); + + ts = B_LITTLE16(numsectors); Bwrite(fil,&ts,2); + for (i=0; i 8) rendmode = 3; // GL renderer + else if (dabpp == 8 && j > 8) rendmode = 0; // going from GL to software activates softpolymost +#endif + + xdim = daxdim; ydim = daydim; + + j = ydim*4*sizeof(long); //Leave room for horizlookup&horizlookup2 + + if (lookups != NULL) + { + if (lookupsalloctype == 0) kkfree((void *)lookups); + if (lookupsalloctype == 1) suckcache((long *)lookups); + lookups = NULL; + } + lookupsalloctype = 0; + if ((lookups = (long *)kkmalloc(j<<1)) == NULL) + { + allocache((long *)&lookups,j<<1,&permanentlock); + lookupsalloctype = 1; + } + + horizlookup = (long *)(lookups); + horizlookup2 = (long *)(FP_OFF(lookups)+j); + horizycent = ((ydim*4)>>1); + + //Force drawrooms to call dosetaspect & recalculate stuff + oxyaspect = oxdimen = oviewingrange = -1; + + setvlinebpl(bytesperline); + j = 0; + for(i=0;i<=ydim;i++) ylookup[i] = j, j += bytesperline; + + setview(0L,0L,xdim-1,ydim-1); + clearallviews(0L); + setbrightness((char)curbrightness,(char *)&palette[0],0); + + if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); } + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode == 3) { + polymost_glinit(); + polymost_glreset(); + } +#endif + qsetmode = 200; + return(0); +} + + +// +// nextpage +// +void nextpage(void) +{ + long i; + permfifotype *per; + + //char snotbuf[32]; + //j = 0; k = 0; + //for(i=0;i<4096;i++) + // if (waloff[i] != 0) + // { + // sprintf(snotbuf,"%ld-%ld",i,tilesizx[i]*tilesizy[i]); + // printext256((j>>5)*40+32,(j&31)*6,walock[i]>>3,-1,snotbuf,1); + // k += tilesizx[i]*tilesizy[i]; + // j++; + // } + //sprintf(snotbuf,"Total: %ld",k); + //printext256((j>>5)*40+32,(j&31)*6,31,-1,snotbuf,1); + + switch(qsetmode) + { + case 200: + begindrawing(); //{{{ + for(i=permtail;i!=permhead;i=((i+1)&(MAXPERMS-1))) + { + per = &permfifo[i]; + if ((per->pagesleft > 0) && (per->pagesleft <= numpages)) + dorotatesprite(per->sx,per->sy,per->z,per->a,per->picnum, + per->dashade,per->dapalnum,per->dastat, + per->cx1,per->cy1,per->cx2,per->cy2,per->uniqid); + } + enddrawing(); //}}} + + OSD_Draw(); + showframe(0); + + begindrawing(); //{{{ + for(i=permtail;i!=permhead;i=((i+1)&(MAXPERMS-1))) + { + per = &permfifo[i]; + if (per->pagesleft >= 130) + dorotatesprite(per->sx,per->sy,per->z,per->a,per->picnum, + per->dashade,per->dapalnum,per->dastat, + per->cx1,per->cy1,per->cx2,per->cy2,per->uniqid); + + if (per->pagesleft&127) per->pagesleft--; + if (((per->pagesleft&127) == 0) && (i == permtail)) + permtail = ((permtail+1)&(MAXPERMS-1)); + } + enddrawing(); //}}} + break; + + case 350: + case 480: + break; + } + faketimerhandler(); + + if ((totalclock >= lastageclock+8) || (totalclock < lastageclock)) + { lastageclock = totalclock; agecache(); } + +#ifdef USE_OPENGL + omdtims = mdtims; mdtims = getticks(); + if (((unsigned long)(mdtims-omdtims)) > 10000) omdtims = mdtims; +#endif + + beforedrawrooms = 1; + numframes++; +} + + +// +// loadpics +// +long loadpics(char *filename, long askedsize) +{ + long offscount, localtilestart, localtileend, dasiz; + short fil, i, j, k; + + Bstrcpy(artfilename,filename); + + for(i=0;i>5),0L); + + //try dpmi_DETERMINEMAXREALALLOC! + + cachesize = min((long)((Bgetsysmemsize()/100)*60),max(artsize,askedsize)); + while ((pic = kkmalloc(cachesize)) == NULL) + { + cachesize -= 65536L; + if (cachesize < 65536) return(-1); + } + initcache((FP_OFF(pic)+15)&0xfffffff0,(cachesize-((-FP_OFF(pic))&15))&0xfffffff0); + + for(i=0;i 1) && (pow2long[j] > tilesizx[i])) j--; + picsiz[i] = ((char)j); + j = 15; + while ((j > 1) && (pow2long[j] > tilesizy[i])) j--; + picsiz[i] += ((char)(j<<4)); + } + + artfil = -1; + artfilnum = -1; + artfilplc = 0L; + + return(0); +} + + +// +// loadtile +// +char cachedebug = 0; +void loadtile(short tilenume) +{ + char *ptr; + long i, dasiz; + + if ((unsigned)tilenume >= (unsigned)MAXTILES) return; + dasiz = tilesizx[tilenume]*tilesizy[tilenume]; + if (dasiz <= 0) return; + + i = tilefilenum[tilenume]; + if (i != artfilnum) + { + if (artfil != -1) kclose(artfil); + artfilnum = i; + artfilplc = 0L; + + artfilename[7] = (i%10)+48; + artfilename[6] = ((i/10)%10)+48; + artfilename[5] = ((i/100)%10)+48; + artfil = kopen4load(artfilename,0); + faketimerhandler(); + } + + if (cachedebug) printOSD("Tile:%d\n",tilenume); + + if (waloff[tilenume] == 0) + { + walock[tilenume] = 199; + allocache(&waloff[tilenume],dasiz,&walock[tilenume]); + } + + if (artfilplc != tilefileoffs[tilenume]) + { + klseek(artfil,tilefileoffs[tilenume]-artfilplc,BSEEK_CUR); + faketimerhandler(); + } + ptr = (char *)waloff[tilenume]; + kread(artfil,ptr,dasiz); + faketimerhandler(); + artfilplc = tilefileoffs[tilenume]+dasiz; +} + + +// +// allocatepermanenttile +// +long allocatepermanenttile(short tilenume, long xsiz, long ysiz) +{ + long j, dasiz; + + if ((xsiz <= 0) || (ysiz <= 0) || ((unsigned)tilenume >= (unsigned)MAXTILES)) + return(0); + + dasiz = xsiz*ysiz; + + walock[tilenume] = 255; + allocache(&waloff[tilenume],dasiz,&walock[tilenume]); + + tilesizx[tilenume] = xsiz; + tilesizy[tilenume] = ysiz; + picanm[tilenume] = 0; + + j = 15; while ((j > 1) && (pow2long[j] > xsiz)) j--; + picsiz[tilenume] = ((char)j); + j = 15; while ((j > 1) && (pow2long[j] > ysiz)) j--; + picsiz[tilenume] += ((char)(j<<4)); + + return(waloff[tilenume]); +} + + +// +// copytilepiece +// +void copytilepiece(long tilenume1, long sx1, long sy1, long xsiz, long ysiz, + long tilenume2, long sx2, long sy2) +{ + char *ptr1, *ptr2, dat; + long xsiz1, ysiz1, xsiz2, ysiz2, i, j, x1, y1, x2, y2; + + xsiz1 = tilesizx[tilenume1]; ysiz1 = tilesizy[tilenume1]; + xsiz2 = tilesizx[tilenume2]; ysiz2 = tilesizy[tilenume2]; + if ((xsiz1 > 0) && (ysiz1 > 0) && (xsiz2 > 0) && (ysiz2 > 0)) + { + if (waloff[tilenume1] == 0) loadtile(tilenume1); + if (waloff[tilenume2] == 0) loadtile(tilenume2); + + x1 = sx1; + for(i=0;i= 0) && (y2 >= 0) && (x2 < xsiz2) && (y2 < ysiz2)) + { + ptr1 = (char *)(waloff[tilenume1] + x1*ysiz1 + y1); + ptr2 = (char *)(waloff[tilenume2] + x2*ysiz2 + y2); + dat = *ptr1; + if (dat != 255) + *ptr2 = *ptr1; + } + + y1++; if (y1 >= ysiz1) y1 = 0; + } + x1++; if (x1 >= xsiz1) x1 = 0; + } + } +} + + +// +// qloadkvx +// +#ifdef SUPERBUILD +long qloadkvx(long voxindex, char *filename) +{ + long i, fil, dasiz, lengcnt, lengtot; + char *ptr; + + if ((fil = kopen4load(filename,0)) == -1) return -1; + + lengcnt = 0; + lengtot = kfilelength(fil); + + for(i=0;i= lengtot-768) break; + } + kclose(fil); + +#if defined POLYMOST && defined USE_OPENGL + if (voxmodels[voxindex]) { + voxfree(voxmodels[voxindex]); + voxmodels[voxindex] = NULL; + } + voxmodels[voxindex] = voxload(filename); +#endif + return 0; +} +#endif + + +// +// clipinsidebox +// +long clipinsidebox(long x, long y, short wallnum, long walldist) +{ + walltype *wal; + long x1, y1, x2, y2, r; + + r = (walldist<<1); + wal = &wall[wallnum]; x1 = wal->x+walldist-x; y1 = wal->y+walldist-y; + wal = &wall[wal->point2]; x2 = wal->x+walldist-x; y2 = wal->y+walldist-y; + + if ((x1 < 0) && (x2 < 0)) return(0); + if ((y1 < 0) && (y2 < 0)) return(0); + if ((x1 >= r) && (x2 >= r)) return(0); + if ((y1 >= r) && (y2 >= r)) return(0); + + x2 -= x1; y2 -= y1; + if (x2*(walldist-y1) >= y2*(walldist-x1)) //Front + { + if (x2 > 0) x2 *= (0-y1); else x2 *= (r-y1); + if (y2 > 0) y2 *= (r-x1); else y2 *= (0-x1); + return(x2 < y2); + } + if (x2 > 0) x2 *= (r-y1); else x2 *= (0-y1); + if (y2 > 0) y2 *= (0-x1); else y2 *= (r-x1); + return((x2 >= y2)<<1); +} + + +// +// clipinsideboxline +// +long clipinsideboxline(long x, long y, long x1, long y1, long x2, long y2, long walldist) +{ + long r; + + r = (walldist<<1); + + x1 += walldist-x; x2 += walldist-x; + if ((x1 < 0) && (x2 < 0)) return(0); + if ((x1 >= r) && (x2 >= r)) return(0); + + y1 += walldist-y; y2 += walldist-y; + if ((y1 < 0) && (y2 < 0)) return(0); + if ((y1 >= r) && (y2 >= r)) return(0); + + x2 -= x1; y2 -= y1; + if (x2*(walldist-y1) >= y2*(walldist-x1)) //Front + { + if (x2 > 0) x2 *= (0-y1); else x2 *= (r-y1); + if (y2 > 0) y2 *= (r-x1); else y2 *= (0-x1); + return(x2 < y2); + } + if (x2 > 0) x2 *= (r-y1); else x2 *= (0-y1); + if (y2 > 0) y2 *= (0-x1); else y2 *= (r-x1); + return((x2 >= y2)<<1); +} + + +// +// inside +// +long inside(long x, long y, short sectnum) +{ + walltype *wal; + long i, x1, y1, x2, y2; + unsigned long cnt; + + if ((sectnum < 0) || (sectnum >= numsectors)) return(-1); + + cnt = 0; + wal = &wall[sector[sectnum].wallptr]; + i = sector[sectnum].wallnum; + do + { + y1 = wal->y-y; y2 = wall[wal->point2].y-y; + if ((y1^y2) < 0) + { + x1 = wal->x-x; x2 = wall[wal->point2].x-x; + if ((x1^x2) >= 0) cnt ^= x1; else cnt ^= (x1*y2-x2*y1)^y2; + } + wal++; i--; + } while (i); + return(cnt>>31); +} + + +// +// getangle +// +long getangle(long xvect, long yvect) +{ + if ((xvect|yvect) == 0) return(0); + if (xvect == 0) return(512+((yvect<0)<<10)); + if (yvect == 0) return(((xvect<0)<<10)); + if (xvect == yvect) return(256+((xvect<0)<<10)); + if (xvect == -yvect) return(768+((xvect>0)<<10)); + if (klabs(xvect) > klabs(yvect)) + return(((radarang[640+scale(160,yvect,xvect)]>>6)+((xvect<0)<<10))&2047); + return(((radarang[640-scale(160,xvect,yvect)]>>6)+512+((yvect<0)<<10))&2047); +} + + +// +// ksqrt +// +long ksqrt(long num) +{ + return(nsqrtasm(num)); +} + + +// +// krecip +// +long krecip(long num) +{ + return(krecipasm(num)); +} + +// +// setsprite +// +long setsprite(short spritenum, long newx, long newy, long newz) +{ + short tempsectnum; + + sprite[spritenum].x = newx; + sprite[spritenum].y = newy; + sprite[spritenum].z = newz; + + tempsectnum = sprite[spritenum].sectnum; +#ifdef SETSPRITEZ + updatesectorz(newx,newy,newz,&tempsectnum); +#else + updatesector(newx,newy,&tempsectnum); +#endif + if (tempsectnum < 0) + return(-1); + if (tempsectnum != sprite[spritenum].sectnum) + changespritesect(spritenum,tempsectnum); + + return(0); +} + + +// +// insertsprite +// +long insertsprite(short sectnum, short statnum) +{ + insertspritestat(statnum); + return(insertspritesect(sectnum)); +} + + +// +// deletesprite +// +long deletesprite(short spritenum) +{ + deletespritestat(spritenum); + return(deletespritesect(spritenum)); +} + + +// +// changespritesect +// +long changespritesect(short spritenum, short newsectnum) +{ + if ((newsectnum < 0) || (newsectnum > MAXSECTORS)) return(-1); + if (sprite[spritenum].sectnum == newsectnum) return(0); + if (sprite[spritenum].sectnum == MAXSECTORS) return(-1); + if (deletespritesect(spritenum) < 0) return(-1); + insertspritesect(newsectnum); + return(0); +} + + +// +// changespritestat +// +long changespritestat(short spritenum, short newstatnum) +{ + if ((newstatnum < 0) || (newstatnum > MAXSTATUS)) return(-1); + if (sprite[spritenum].statnum == newstatnum) return(0); + if (sprite[spritenum].statnum == MAXSTATUS) return(-1); + if (deletespritestat(spritenum) < 0) return(-1); + insertspritestat(newstatnum); + return(0); +} + + +// +// nextsectorneighborz +// +long nextsectorneighborz(short sectnum, long thez, short topbottom, short direction) +{ + walltype *wal; + long i, testz, nextz; + short sectortouse; + + if (direction == 1) nextz = 0x7fffffff; else nextz = 0x80000000; + + sectortouse = -1; + + wal = &wall[sector[sectnum].wallptr]; + i = sector[sectnum].wallnum; + do + { + if (wal->nextsector >= 0) + { + if (topbottom == 1) + { + testz = sector[wal->nextsector].floorz; + if (direction == 1) + { + if ((testz > thez) && (testz < nextz)) + { + nextz = testz; + sectortouse = wal->nextsector; + } + } + else + { + if ((testz < thez) && (testz > nextz)) + { + nextz = testz; + sectortouse = wal->nextsector; + } + } + } + else + { + testz = sector[wal->nextsector].ceilingz; + if (direction == 1) + { + if ((testz > thez) && (testz < nextz)) + { + nextz = testz; + sectortouse = wal->nextsector; + } + } + else + { + if ((testz < thez) && (testz > nextz)) + { + nextz = testz; + sectortouse = wal->nextsector; + } + } + } + } + wal++; + i--; + } while (i != 0); + + return(sectortouse); +} + + +// +// cansee +// +long cansee(long x1, long y1, long z1, short sect1, long x2, long y2, long z2, short sect2) +{ + sectortype *sec; + walltype *wal, *wal2; + long i, cnt, nexts, x, y, z, cz, fz, dasectnum, dacnt, danum; + long x21, y21, z21, x31, y31, x34, y34, bot, t; + + if ((x1 == x2) && (y1 == y2)) return(sect1 == sect2); + + x21 = x2-x1; y21 = y2-y1; z21 = z2-z1; + + clipsectorlist[0] = sect1; danum = 1; + for(dacnt=0;dacntwallnum,wal=&wall[sec->wallptr];cnt>0;cnt--,wal++) + { + wal2 = &wall[wal->point2]; + x31 = wal->x-x1; x34 = wal->x-wal2->x; + y31 = wal->y-y1; y34 = wal->y-wal2->y; + + bot = y21*x34-x21*y34; if (bot <= 0) continue; + t = y21*x31-x21*y31; if ((unsigned)t >= (unsigned)bot) continue; + t = y31*x34-x31*y34; if ((unsigned)t >= (unsigned)bot) continue; + + nexts = wal->nextsector; + if ((nexts < 0) || (wal->cstat&32)) return(0); + + t = divscale24(t,bot); + x = x1 + mulscale24(x21,t); + y = y1 + mulscale24(y21,t); + z = z1 + mulscale24(z21,t); + + getzsofslope((short)dasectnum,x,y,&cz,&fz); + if ((z <= cz) || (z >= fz)) return(0); + getzsofslope((short)nexts,x,y,&cz,&fz); + if ((z <= cz) || (z >= fz)) return(0); + + for(i=danum-1;i>=0;i--) if (clipsectorlist[i] == nexts) break; + if (i < 0) clipsectorlist[danum++] = nexts; + } + } + for(i=danum-1;i>=0;i--) if (clipsectorlist[i] == sect2) return(1); + return(0); +} + + +// +// hitscan +// +long hitscan(long xs, long ys, long zs, short sectnum, long vx, long vy, long vz, + short *hitsect, short *hitwall, short *hitsprite, + long *hitx, long *hity, long *hitz, unsigned long cliptype) +{ + sectortype *sec; + walltype *wal, *wal2; + spritetype *spr; + long z, zz, x1, y1=0, z1=0, x2, y2, x3, y3, x4, y4, intx, inty, intz; + long topt, topu, bot, dist, offx, offy, cstat; + long i, j, k, l, tilenum, xoff, yoff, dax, day, daz, daz2; + long ang, cosang, sinang, xspan, yspan, xrepeat, yrepeat; + long dawalclipmask, dasprclipmask; + short tempshortcnt, tempshortnum, dasector, startwall, endwall; + short nextsector; + char clipyou; + + *hitsect = -1; *hitwall = -1; *hitsprite = -1; + if (sectnum < 0) return(-1); + + *hitx = hitscangoalx; *hity = hitscangoaly; + + dawalclipmask = (cliptype&65535); + dasprclipmask = (cliptype>>16); + + clipsectorlist[0] = sectnum; + tempshortcnt = 0; tempshortnum = 1; + do + { + dasector = clipsectorlist[tempshortcnt]; sec = §or[dasector]; + + x1 = 0x7fffffff; + if (sec->ceilingstat&2) + { + wal = &wall[sec->wallptr]; wal2 = &wall[wal->point2]; + dax = wal2->x-wal->x; day = wal2->y-wal->y; + i = nsqrtasm(dax*dax+day*day); if (i == 0) continue; + i = divscale15(sec->ceilingheinum,i); + dax *= i; day *= i; + + j = (vz<<8)-dmulscale15(dax,vy,-day,vx); + if (j != 0) + { + i = ((sec->ceilingz-zs)<<8)+dmulscale15(dax,ys-wal->y,-day,xs-wal->x); + if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j))) + { + i = divscale30(i,j); + x1 = xs + mulscale30(vx,i); + y1 = ys + mulscale30(vy,i); + z1 = zs + mulscale30(vz,i); + } + } + } + else if ((vz < 0) && (zs >= sec->ceilingz)) + { + z1 = sec->ceilingz; i = z1-zs; + if ((klabs(i)>>1) < -vz) + { + i = divscale30(i,vz); + x1 = xs + mulscale30(vx,i); + y1 = ys + mulscale30(vy,i); + } + } + if ((x1 != 0x7fffffff) && (klabs(x1-xs)+klabs(y1-ys) < klabs((*hitx)-xs)+klabs((*hity)-ys))) + if (inside(x1,y1,dasector) != 0) + { + *hitsect = dasector; *hitwall = -1; *hitsprite = -1; + *hitx = x1; *hity = y1; *hitz = z1; + } + + x1 = 0x7fffffff; + if (sec->floorstat&2) + { + wal = &wall[sec->wallptr]; wal2 = &wall[wal->point2]; + dax = wal2->x-wal->x; day = wal2->y-wal->y; + i = nsqrtasm(dax*dax+day*day); if (i == 0) continue; + i = divscale15(sec->floorheinum,i); + dax *= i; day *= i; + + j = (vz<<8)-dmulscale15(dax,vy,-day,vx); + if (j != 0) + { + i = ((sec->floorz-zs)<<8)+dmulscale15(dax,ys-wal->y,-day,xs-wal->x); + if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j))) + { + i = divscale30(i,j); + x1 = xs + mulscale30(vx,i); + y1 = ys + mulscale30(vy,i); + z1 = zs + mulscale30(vz,i); + } + } + } + else if ((vz > 0) && (zs <= sec->floorz)) + { + z1 = sec->floorz; i = z1-zs; + if ((klabs(i)>>1) < vz) + { + i = divscale30(i,vz); + x1 = xs + mulscale30(vx,i); + y1 = ys + mulscale30(vy,i); + } + } + if ((x1 != 0x7fffffff) && (klabs(x1-xs)+klabs(y1-ys) < klabs((*hitx)-xs)+klabs((*hity)-ys))) + if (inside(x1,y1,dasector) != 0) + { + *hitsect = dasector; *hitwall = -1; *hitsprite = -1; + *hitx = x1; *hity = y1; *hitz = z1; + } + + startwall = sec->wallptr; endwall = startwall + sec->wallnum; + for(z=startwall,wal=&wall[startwall];zpoint2]; + x1 = wal->x; y1 = wal->y; x2 = wal2->x; y2 = wal2->y; + + if ((x1-xs)*(y2-ys) < (x2-xs)*(y1-ys)) continue; + if (rintersect(xs,ys,zs,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz) == 0) continue; + + if (klabs(intx-xs)+klabs(inty-ys) >= klabs((*hitx)-xs)+klabs((*hity)-ys)) continue; + + nextsector = wal->nextsector; + if ((nextsector < 0) || (wal->cstat&dawalclipmask)) + { + *hitsect = dasector; *hitwall = z; *hitsprite = -1; + *hitx = intx; *hity = inty; *hitz = intz; + continue; + } + getzsofslope(nextsector,intx,inty,&daz,&daz2); + if ((intz <= daz) || (intz >= daz2)) + { + *hitsect = dasector; *hitwall = z; *hitsprite = -1; + *hitx = intx; *hity = inty; *hitz = intz; + continue; + } + + for(zz=tempshortnum-1;zz>=0;zz--) + if (clipsectorlist[zz] == nextsector) break; + if (zz < 0) clipsectorlist[tempshortnum++] = nextsector; + } + + for(z=headspritesect[dasector];z>=0;z=nextspritesect[z]) + { + spr = &sprite[z]; + cstat = spr->cstat; +#ifdef POLYMOST + if (!hitallsprites) +#endif + if ((cstat&dasprclipmask) == 0) continue; + + x1 = spr->x; y1 = spr->y; z1 = spr->z; + switch(cstat&48) + { + case 0: + topt = vx*(x1-xs) + vy*(y1-ys); if (topt <= 0) continue; + bot = vx*vx + vy*vy; if (bot == 0) continue; + + intz = zs+scale(vz,topt,bot); + + i = (tilesizy[spr->picnum]*spr->yrepeat<<2); + if (cstat&128) z1 += (i>>1); + if (picanm[spr->picnum]&0x00ff0000) z1 -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if ((intz > z1) || (intz < z1-i)) continue; + topu = vx*(y1-ys) - vy*(x1-xs); + + offx = scale(vx,topu,bot); + offy = scale(vy,topu,bot); + dist = offx*offx + offy*offy; + i = tilesizx[spr->picnum]*spr->xrepeat; i *= i; + if (dist > (i>>7)) continue; + intx = xs + scale(vx,topt,bot); + inty = ys + scale(vy,topt,bot); + + if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue; + + *hitsect = dasector; *hitwall = -1; *hitsprite = z; + *hitx = intx; *hity = inty; *hitz = intz; + break; + case 16: + //These lines get the 2 points of the rotated sprite + //Given: (x1, y1) starts out as the center point + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + if ((cstat&4) > 0) xoff = -xoff; + k = spr->ang; l = spr->xrepeat; + dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; + l = tilesizx[tilenum]; k = (l>>1)+xoff; + x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l); + y1 -= mulscale16(day,k); y2 = y1+mulscale16(day,l); + + if ((cstat&64) != 0) //back side of 1-way sprite + if ((x1-xs)*(y2-ys) < (x2-xs)*(y1-ys)) continue; + + if (rintersect(xs,ys,zs,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz) == 0) continue; + + if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue; + + k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); + if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; + if (picanm[spr->picnum]&0x00ff0000) daz -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if ((intz < daz) && (intz > daz-k)) + { + *hitsect = dasector; *hitwall = -1; *hitsprite = z; + *hitx = intx; *hity = inty; *hitz = intz; + } + break; + case 32: + if (vz == 0) continue; + intz = z1; + if (((intz-zs)^vz) < 0) continue; + if ((cstat&64) != 0) + if ((zs > intz) == ((cstat&8)==0)) continue; + + intx = xs+scale(intz-zs,vx,vz); + inty = ys+scale(intz-zs,vy,vz); + + if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue; + + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + if ((cstat&4) > 0) xoff = -xoff; + if ((cstat&8) > 0) yoff = -yoff; + + ang = spr->ang; + cosang = sintable[(ang+512)&2047]; sinang = sintable[ang]; + xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; + yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; + + dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat; + x1 += dmulscale16(sinang,dax,cosang,day)-intx; + y1 += dmulscale16(sinang,day,-cosang,dax)-inty; + l = xspan*xrepeat; + x2 = x1 - mulscale16(sinang,l); + y2 = y1 + mulscale16(cosang,l); + l = yspan*yrepeat; + k = -mulscale16(cosang,l); x3 = x2+k; x4 = x1+k; + k = -mulscale16(sinang,l); y3 = y2+k; y4 = y1+k; + + clipyou = 0; + if ((y1^y2) < 0) + { + if ((x1^x2) < 0) clipyou ^= (x1*y2= 0) clipyou ^= 1; + } + if ((y2^y3) < 0) + { + if ((x2^x3) < 0) clipyou ^= (x2*y3= 0) clipyou ^= 1; + } + if ((y3^y4) < 0) + { + if ((x3^x4) < 0) clipyou ^= (x3*y4= 0) clipyou ^= 1; + } + if ((y4^y1) < 0) + { + if ((x4^x1) < 0) clipyou ^= (x4*y1= 0) clipyou ^= 1; + } + + if (clipyou != 0) + { + *hitsect = dasector; *hitwall = -1; *hitsprite = z; + *hitx = intx; *hity = inty; *hitz = intz; + } + break; + } + } + tempshortcnt++; + } while (tempshortcnt < tempshortnum); + return(0); +} + + +// +// neartag +// +long neartag(long xs, long ys, long zs, short sectnum, short ange, short *neartagsector, short *neartagwall, short *neartagsprite, long *neartaghitdist, long neartagrange, char tagsearch) +{ + walltype *wal, *wal2; + spritetype *spr; + long i, z, zz, xe, ye, ze, x1, y1, z1, x2, y2, intx, inty, intz; + long topt, topu, bot, dist, offx, offy, vx, vy, vz; + short tempshortcnt, tempshortnum, dasector, startwall, endwall; + short nextsector, good; + + *neartagsector = -1; *neartagwall = -1; *neartagsprite = -1; + *neartaghitdist = 0; + + if (sectnum < 0) return(0); + if ((tagsearch < 1) || (tagsearch > 3)) return(0); + + vx = mulscale14(sintable[(ange+2560)&2047],neartagrange); xe = xs+vx; + vy = mulscale14(sintable[(ange+2048)&2047],neartagrange); ye = ys+vy; + vz = 0; ze = 0; + + clipsectorlist[0] = sectnum; + tempshortcnt = 0; tempshortnum = 1; + + do + { + dasector = clipsectorlist[tempshortcnt]; + + startwall = sector[dasector].wallptr; + endwall = startwall + sector[dasector].wallnum - 1; + for(z=startwall,wal=&wall[startwall];z<=endwall;z++,wal++) + { + wal2 = &wall[wal->point2]; + x1 = wal->x; y1 = wal->y; x2 = wal2->x; y2 = wal2->y; + + nextsector = wal->nextsector; + + good = 0; + if (nextsector >= 0) + { + if ((tagsearch&1) && sector[nextsector].lotag) good |= 1; + if ((tagsearch&2) && sector[nextsector].hitag) good |= 1; + } + if ((tagsearch&1) && wal->lotag) good |= 2; + if ((tagsearch&2) && wal->hitag) good |= 2; + + if ((good == 0) && (nextsector < 0)) continue; + if ((x1-xs)*(y2-ys) < (x2-xs)*(y1-ys)) continue; + + if (lintersect(xs,ys,zs,xe,ye,ze,x1,y1,x2,y2,&intx,&inty,&intz) == 1) + { + if (good != 0) + { + if (good&1) *neartagsector = nextsector; + if (good&2) *neartagwall = z; + *neartaghitdist = dmulscale14(intx-xs,sintable[(ange+2560)&2047],inty-ys,sintable[(ange+2048)&2047]); + xe = intx; ye = inty; ze = intz; + } + if (nextsector >= 0) + { + for(zz=tempshortnum-1;zz>=0;zz--) + if (clipsectorlist[zz] == nextsector) break; + if (zz < 0) clipsectorlist[tempshortnum++] = nextsector; + } + } + } + + for(z=headspritesect[dasector];z>=0;z=nextspritesect[z]) + { + spr = &sprite[z]; + + good = 0; + if ((tagsearch&1) && spr->lotag) good |= 1; + if ((tagsearch&2) && spr->hitag) good |= 1; + if (good != 0) + { + x1 = spr->x; y1 = spr->y; z1 = spr->z; + + topt = vx*(x1-xs) + vy*(y1-ys); + if (topt > 0) + { + bot = vx*vx + vy*vy; + if (bot != 0) + { + intz = zs+scale(vz,topt,bot); + i = tilesizy[spr->picnum]*spr->yrepeat; + if (spr->cstat&128) z1 += (i<<1); + if (picanm[spr->picnum]&0x00ff0000) z1 -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if ((intz <= z1) && (intz >= z1-(i<<2))) + { + topu = vx*(y1-ys) - vy*(x1-xs); + + offx = scale(vx,topu,bot); + offy = scale(vy,topu,bot); + dist = offx*offx + offy*offy; + i = (tilesizx[spr->picnum]*spr->xrepeat); i *= i; + if (dist <= (i>>7)) + { + intx = xs + scale(vx,topt,bot); + inty = ys + scale(vy,topt,bot); + if (klabs(intx-xs)+klabs(inty-ys) < klabs(xe-xs)+klabs(ye-ys)) + { + *neartagsprite = z; + *neartaghitdist = dmulscale14(intx-xs,sintable[(ange+2560)&2047],inty-ys,sintable[(ange+2048)&2047]); + xe = intx; + ye = inty; + ze = intz; + } + } + } + } + } + } + } + + tempshortcnt++; + } while (tempshortcnt < tempshortnum); + return(0); +} + + +// +// dragpoint +// +void dragpoint(short pointhighlight, long dax, long day) +{ + short cnt, tempshort; + + wall[pointhighlight].x = dax; + wall[pointhighlight].y = day; + + cnt = MAXWALLS; + tempshort = pointhighlight; //search points CCW + do + { + if (wall[tempshort].nextwall >= 0) + { + tempshort = wall[wall[tempshort].nextwall].point2; + wall[tempshort].x = dax; + wall[tempshort].y = day; + } + else + { + tempshort = pointhighlight; //search points CW if not searched all the way around + do + { + if (wall[lastwall(tempshort)].nextwall >= 0) + { + tempshort = wall[lastwall(tempshort)].nextwall; + wall[tempshort].x = dax; + wall[tempshort].y = day; + } + else + { + break; + } + cnt--; + } + while ((tempshort != pointhighlight) && (cnt > 0)); + break; + } + cnt--; + } + while ((tempshort != pointhighlight) && (cnt > 0)); +} + + +// +// lastwall +// +long lastwall(short point) +{ + long i, j, cnt; + + if ((point > 0) && (wall[point-1].point2 == point)) return(point-1); + i = point; + cnt = MAXWALLS; + do + { + j = wall[i].point2; + if (j == point) return(i); + i = j; + cnt--; + } while (cnt > 0); + return(point); +} + + + +#define addclipline(dax1, day1, dax2, day2, daoval) \ +{ \ + if (clipnum < MAXCLIPNUM) { \ + clipit[clipnum].x1 = dax1; clipit[clipnum].y1 = day1; \ + clipit[clipnum].x2 = dax2; clipit[clipnum].y2 = day2; \ + clipobjectval[clipnum] = daoval; \ + clipnum++; \ + } \ +} \ + +long clipmoveboxtracenum = 3; + +// +// clipmove +// +long clipmove (long *x, long *y, long *z, short *sectnum, + long xvect, long yvect, + long walldist, long ceildist, long flordist, unsigned long cliptype) +{ + walltype *wal, *wal2; + spritetype *spr; + sectortype *sec, *sec2; + long i, j, templong1, templong2; + long oxvect, oyvect, goalx, goaly, intx, inty, lx, ly, retval; + long k, l, clipsectcnt, startwall, endwall, cstat, dasect; + long x1, y1, x2, y2, cx, cy, rad, xmin, ymin, xmax, ymax, daz, daz2; + long bsz, dax, day, xoff, yoff, xspan, yspan, cosang, sinang, tilenum; + long xrepeat, yrepeat, gx, gy, dx, dy, dasprclipmask, dawalclipmask; + long hitwall, cnt, clipyou; + + if (((xvect|yvect) == 0) || (*sectnum < 0)) return(0); + retval = 0; + + oxvect = xvect; + oyvect = yvect; + + goalx = (*x) + (xvect>>14); + goaly = (*y) + (yvect>>14); + + + clipnum = 0; + + cx = (((*x)+goalx)>>1); + cy = (((*y)+goaly)>>1); + //Extra walldist for sprites on sector lines + gx = goalx-(*x); gy = goaly-(*y); + rad = nsqrtasm(gx*gx + gy*gy) + MAXCLIPDIST+walldist + 8; + xmin = cx-rad; ymin = cy-rad; + xmax = cx+rad; ymax = cy+rad; + + dawalclipmask = (cliptype&65535); //CLIPMASK0 = 0x00010001 + dasprclipmask = (cliptype>>16); //CLIPMASK1 = 0x01000040 + + clipsectorlist[0] = (*sectnum); + clipsectcnt = 0; clipsectnum = 1; + do + { + dasect = clipsectorlist[clipsectcnt++]; + sec = §or[dasect]; + startwall = sec->wallptr; endwall = startwall + sec->wallnum; + for(j=startwall,wal=&wall[startwall];jpoint2]; + if ((wal->x < xmin) && (wal2->x < xmin)) continue; + if ((wal->x > xmax) && (wal2->x > xmax)) continue; + if ((wal->y < ymin) && (wal2->y < ymin)) continue; + if ((wal->y > ymax) && (wal2->y > ymax)) continue; + + x1 = wal->x; y1 = wal->y; x2 = wal2->x; y2 = wal2->y; + + dx = x2-x1; dy = y2-y1; + if (dx*((*y)-y1) < ((*x)-x1)*dy) continue; //If wall's not facing you + + if (dx > 0) dax = dx*(ymin-y1); else dax = dx*(ymax-y1); + if (dy > 0) day = dy*(xmax-x1); else day = dy*(xmin-x1); + if (dax >= day) continue; + + clipyou = 0; + if ((wal->nextsector < 0) || (wal->cstat&dawalclipmask)) clipyou = 1; + else if (editstatus == 0) + { + if (rintersect(*x,*y,0,gx,gy,0,x1,y1,x2,y2,&dax,&day,&daz) == 0) + dax = *x, day = *y; + daz = getflorzofslope((short)dasect,dax,day); + daz2 = getflorzofslope(wal->nextsector,dax,day); + + sec2 = §or[wal->nextsector]; + if (daz2 < daz-(1<<8)) + if ((sec2->floorstat&1) == 0) + if ((*z) >= daz2-(flordist-1)) clipyou = 1; + if (clipyou == 0) + { + daz = getceilzofslope((short)dasect,dax,day); + daz2 = getceilzofslope(wal->nextsector,dax,day); + if (daz2 > daz+(1<<8)) + if ((sec2->ceilingstat&1) == 0) + if ((*z) <= daz2+(ceildist-1)) clipyou = 1; + } + } + + if (clipyou) + { + //Add 2 boxes at endpoints + bsz = walldist; if (gx < 0) bsz = -bsz; + addclipline(x1-bsz,y1-bsz,x1-bsz,y1+bsz,(short)j+32768); + addclipline(x2-bsz,y2-bsz,x2-bsz,y2+bsz,(short)j+32768); + bsz = walldist; if (gy < 0) bsz = -bsz; + addclipline(x1+bsz,y1-bsz,x1-bsz,y1-bsz,(short)j+32768); + addclipline(x2+bsz,y2-bsz,x2-bsz,y2-bsz,(short)j+32768); + + dax = walldist; if (dy > 0) dax = -dax; + day = walldist; if (dx < 0) day = -day; + addclipline(x1+dax,y1+day,x2+dax,y2+day,(short)j+32768); + } + else + { + for(i=clipsectnum-1;i>=0;i--) + if (wal->nextsector == clipsectorlist[i]) break; + if (i < 0) clipsectorlist[clipsectnum++] = wal->nextsector; + } + } + + for(j=headspritesect[dasect];j>=0;j=nextspritesect[j]) + { + spr = &sprite[j]; + cstat = spr->cstat; + if ((cstat&dasprclipmask) == 0) continue; + x1 = spr->x; y1 = spr->y; + switch(cstat&48) + { + case 0: + if ((x1 >= xmin) && (x1 <= xmax) && (y1 >= ymin) && (y1 <= ymax)) + { + k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); + if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; + if (picanm[spr->picnum]&0x00ff0000) daz -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (((*z) < daz+ceildist) && ((*z) > daz-k-flordist)) + { + bsz = (spr->clipdist<<2)+walldist; if (gx < 0) bsz = -bsz; + addclipline(x1-bsz,y1-bsz,x1-bsz,y1+bsz,(short)j+49152); + bsz = (spr->clipdist<<2)+walldist; if (gy < 0) bsz = -bsz; + addclipline(x1+bsz,y1-bsz,x1-bsz,y1-bsz,(short)j+49152); + } + } + break; + case 16: + k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); + if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; + if (picanm[spr->picnum]&0x00ff0000) daz -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + daz2 = daz-k; + daz += ceildist; daz2 -= flordist; + if (((*z) < daz) && ((*z) > daz2)) + { + //These lines get the 2 points of the rotated sprite + //Given: (x1, y1) starts out as the center point + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + if ((cstat&4) > 0) xoff = -xoff; + k = spr->ang; l = spr->xrepeat; + dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; + l = tilesizx[tilenum]; k = (l>>1)+xoff; + x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l); + y1 -= mulscale16(day,k); y2 = y1+mulscale16(day,l); + if (clipinsideboxline(cx,cy,x1,y1,x2,y2,rad) != 0) + { + dax = mulscale14(sintable[(spr->ang+256+512)&2047],walldist); + day = mulscale14(sintable[(spr->ang+256)&2047],walldist); + + if ((x1-(*x))*(y2-(*y)) >= (x2-(*x))*(y1-(*y))) //Front + { + addclipline(x1+dax,y1+day,x2+day,y2-dax,(short)j+49152); + } + else + { + if ((cstat&64) != 0) continue; + addclipline(x2-dax,y2-day,x1-day,y1+dax,(short)j+49152); + } + + //Side blocker + if ((x2-x1)*((*x)-x1) + (y2-y1)*((*y)-y1) < 0) + { addclipline(x1-day,y1+dax,x1+dax,y1+day,(short)j+49152); } + else if ((x1-x2)*((*x)-x2) + (y1-y2)*((*y)-y2) < 0) + { addclipline(x2+day,y2-dax,x2-dax,y2-day,(short)j+49152); } + } + } + break; + case 32: + daz = spr->z+ceildist; + daz2 = spr->z-flordist; + if (((*z) < daz) && ((*z) > daz2)) + { + if ((cstat&64) != 0) + if (((*z) > spr->z) == ((cstat&8)==0)) continue; + + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + if ((cstat&4) > 0) xoff = -xoff; + if ((cstat&8) > 0) yoff = -yoff; + + k = spr->ang; + cosang = sintable[(k+512)&2047]; sinang = sintable[k]; + xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; + yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; + + dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat; + rxi[0] = x1 + dmulscale16(sinang,dax,cosang,day); + ryi[0] = y1 + dmulscale16(sinang,day,-cosang,dax); + l = xspan*xrepeat; + rxi[1] = rxi[0] - mulscale16(sinang,l); + ryi[1] = ryi[0] + mulscale16(cosang,l); + l = yspan*yrepeat; + k = -mulscale16(cosang,l); rxi[2] = rxi[1]+k; rxi[3] = rxi[0]+k; + k = -mulscale16(sinang,l); ryi[2] = ryi[1]+k; ryi[3] = ryi[0]+k; + + dax = mulscale14(sintable[(spr->ang-256+512)&2047],walldist); + day = mulscale14(sintable[(spr->ang-256)&2047],walldist); + + if ((rxi[0]-(*x))*(ryi[1]-(*y)) < (rxi[1]-(*x))*(ryi[0]-(*y))) + { + if (clipinsideboxline(cx,cy,rxi[1],ryi[1],rxi[0],ryi[0],rad) != 0) + addclipline(rxi[1]-day,ryi[1]+dax,rxi[0]+dax,ryi[0]+day,(short)j+49152); + } + else if ((rxi[2]-(*x))*(ryi[3]-(*y)) < (rxi[3]-(*x))*(ryi[2]-(*y))) + { + if (clipinsideboxline(cx,cy,rxi[3],ryi[3],rxi[2],ryi[2],rad) != 0) + addclipline(rxi[3]+day,ryi[3]-dax,rxi[2]-dax,ryi[2]-day,(short)j+49152); + } + + if ((rxi[1]-(*x))*(ryi[2]-(*y)) < (rxi[2]-(*x))*(ryi[1]-(*y))) + { + if (clipinsideboxline(cx,cy,rxi[2],ryi[2],rxi[1],ryi[1],rad) != 0) + addclipline(rxi[2]-dax,ryi[2]-day,rxi[1]-day,ryi[1]+dax,(short)j+49152); + } + else if ((rxi[3]-(*x))*(ryi[0]-(*y)) < (rxi[0]-(*x))*(ryi[3]-(*y))) + { + if (clipinsideboxline(cx,cy,rxi[0],ryi[0],rxi[3],ryi[3],rad) != 0) + addclipline(rxi[0]+dax,ryi[0]+day,rxi[3]+day,ryi[3]-dax,(short)j+49152); + } + } + break; + } + } + } while (clipsectcnt < clipsectnum); + + + hitwall = 0; + cnt = clipmoveboxtracenum; + do + { + intx = goalx; inty = goaly; + if ((hitwall = raytrace(*x, *y, &intx, &inty)) >= 0) + { + lx = clipit[hitwall].x2-clipit[hitwall].x1; + ly = clipit[hitwall].y2-clipit[hitwall].y1; + templong2 = lx*lx + ly*ly; + if (templong2 > 0) + { + templong1 = (goalx-intx)*lx + (goaly-inty)*ly; + + if ((klabs(templong1)>>11) < templong2) + i = divscale20(templong1,templong2); + else + i = 0; + goalx = mulscale20(lx,i)+intx; + goaly = mulscale20(ly,i)+inty; + } + + templong1 = dmulscale6(lx,oxvect,ly,oyvect); + for(i=cnt+1;i<=clipmoveboxtracenum;i++) + { + j = hitwalls[i]; + templong2 = dmulscale6(clipit[j].x2-clipit[j].x1,oxvect,clipit[j].y2-clipit[j].y1,oyvect); + if ((templong1^templong2) < 0) + { + updatesector(*x,*y,sectnum); + return(retval); + } + } + + keepaway(&goalx, &goaly, hitwall); + xvect = ((goalx-intx)<<14); + yvect = ((goaly-inty)<<14); + + if (cnt == clipmoveboxtracenum) retval = clipobjectval[hitwall]; + hitwalls[cnt] = hitwall; + } + cnt--; + + *x = intx; + *y = inty; + } while (((xvect|yvect) != 0) && (hitwall >= 0) && (cnt > 0)); + + for(j=0;j=0;j--) + if (inside(*x,*y,j) == 1) + { + if (sector[j].ceilingstat&2) + templong2 = (getceilzofslope((short)j,*x,*y)-(*z)); + else + templong2 = (sector[j].ceilingz-(*z)); + + if (templong2 > 0) + { + if (templong2 < templong1) + { *sectnum = j; templong1 = templong2; } + } + else + { + if (sector[j].floorstat&2) + templong2 = ((*z)-getflorzofslope((short)j,*x,*y)); + else + templong2 = ((*z)-sector[j].floorz); + + if (templong2 <= 0) + { + *sectnum = j; + return(retval); + } + if (templong2 < templong1) + { *sectnum = j; templong1 = templong2; } + } + } + + return(retval); +} + + +// +// pushmove +// +long pushmove (long *x, long *y, long *z, short *sectnum, + long walldist, long ceildist, long flordist, unsigned long cliptype) +{ + sectortype *sec, *sec2; + walltype *wal, *wal2; + spritetype *spr; + long i, j, k, t, dx, dy, dax, day, daz, daz2, bad, dir; + long dasprclipmask, dawalclipmask; + short startwall, endwall, clipsectcnt; + char bad2; + + if ((*sectnum) < 0) return(-1); + + dawalclipmask = (cliptype&65535); + dasprclipmask = (cliptype>>16); + + k = 32; + dir = 1; + do + { + bad = 0; + + clipsectorlist[0] = *sectnum; + clipsectcnt = 0; clipsectnum = 1; + do + { + /*Push FACE sprites + for(i=headspritesect[clipsectorlist[clipsectcnt]];i>=0;i=nextspritesect[i]) + { + spr = &sprite[i]; + if (((spr->cstat&48) != 0) && ((spr->cstat&48) != 48)) continue; + if ((spr->cstat&dasprclipmask) == 0) continue; + + dax = (*x)-spr->x; day = (*y)-spr->y; + t = (spr->clipdist<<2)+walldist; + if ((klabs(dax) < t) && (klabs(day) < t)) + { + t = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); + if (spr->cstat&128) daz = spr->z+(t>>1); else daz = spr->z; + if (picanm[spr->picnum]&0x00ff0000) daz -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (((*z) < daz+ceildist) && ((*z) > daz-t-flordist)) + { + t = (spr->clipdist<<2)+walldist; + + j = getangle(dax,day); + dx = (sintable[(j+512)&2047]>>11); + dy = (sintable[(j)&2047]>>11); + bad2 = 16; + do + { + *x = (*x) + dx; *y = (*y) + dy; + bad2--; if (bad2 == 0) break; + } while ((klabs((*x)-spr->x) < t) && (klabs((*y)-spr->y) < t)); + bad = -1; + k--; if (k <= 0) return(bad); + updatesector(*x,*y,sectnum); + } + } + }*/ + + sec = §or[clipsectorlist[clipsectcnt]]; + if (dir > 0) + startwall = sec->wallptr, endwall = startwall + sec->wallnum; + else + endwall = sec->wallptr, startwall = endwall + sec->wallnum; + + for(i=startwall,wal=&wall[startwall];i!=endwall;i+=dir,wal+=dir) + if (clipinsidebox(*x,*y,i,walldist-4) == 1) + { + j = 0; + if (wal->nextsector < 0) j = 1; + if (wal->cstat&dawalclipmask) j = 1; + if (j == 0) + { + sec2 = §or[wal->nextsector]; + + + //Find closest point on wall (dax, day) to (*x, *y) + dax = wall[wal->point2].x-wal->x; + day = wall[wal->point2].y-wal->y; + daz = dax*((*x)-wal->x) + day*((*y)-wal->y); + if (daz <= 0) + t = 0; + else + { + daz2 = dax*dax+day*day; + if (daz >= daz2) t = (1<<30); else t = divscale30(daz,daz2); + } + dax = wal->x + mulscale30(dax,t); + day = wal->y + mulscale30(day,t); + + + daz = getflorzofslope(clipsectorlist[clipsectcnt],dax,day); + daz2 = getflorzofslope(wal->nextsector,dax,day); + if ((daz2 < daz-(1<<8)) && ((sec2->floorstat&1) == 0)) + if (*z >= daz2-(flordist-1)) j = 1; + + daz = getceilzofslope(clipsectorlist[clipsectcnt],dax,day); + daz2 = getceilzofslope(wal->nextsector,dax,day); + if ((daz2 > daz+(1<<8)) && ((sec2->ceilingstat&1) == 0)) + if (*z <= daz2+(ceildist-1)) j = 1; + } + if (j != 0) + { + j = getangle(wall[wal->point2].x-wal->x,wall[wal->point2].y-wal->y); + dx = (sintable[(j+1024)&2047]>>11); + dy = (sintable[(j+512)&2047]>>11); + bad2 = 16; + do + { + *x = (*x) + dx; *y = (*y) + dy; + bad2--; if (bad2 == 0) break; + } while (clipinsidebox(*x,*y,i,walldist-4) != 0); + bad = -1; + k--; if (k <= 0) return(bad); + updatesector(*x,*y,sectnum); + } + else + { + for(j=clipsectnum-1;j>=0;j--) + if (wal->nextsector == clipsectorlist[j]) break; + if (j < 0) clipsectorlist[clipsectnum++] = wal->nextsector; + } + } + + clipsectcnt++; + } while (clipsectcnt < clipsectnum); + dir = -dir; + } while (bad != 0); + + return(bad); +} + + +// +// updatesector[z] +// +void updatesector(long x, long y, short *sectnum) +{ + walltype *wal; + long i, j; + + if (inside(x,y,*sectnum) == 1) return; + + if ((*sectnum >= 0) && (*sectnum < numsectors)) + { + wal = &wall[sector[*sectnum].wallptr]; + j = sector[*sectnum].wallnum; + do + { + i = wal->nextsector; + if (i >= 0) + if (inside(x,y,(short)i) == 1) + { + *sectnum = i; + return; + } + wal++; + j--; + } while (j != 0); + } + + for(i=numsectors-1;i>=0;i--) + if (inside(x,y,(short)i) == 1) + { + *sectnum = i; + return; + } + + *sectnum = -1; +} + +void updatesectorz(long x, long y, long z, short *sectnum) +{ + walltype *wal; + long i, j, cz, fz; + + getzsofslope(*sectnum, x, y, &cz, &fz); + if ((z >= cz) && (z <= fz)) + if (inside(x,y,*sectnum) != 0) return; + + if ((*sectnum >= 0) && (*sectnum < numsectors)) + { + wal = &wall[sector[*sectnum].wallptr]; + j = sector[*sectnum].wallnum; + do + { + i = wal->nextsector; + if (i >= 0) + { + getzsofslope(i, x, y, &cz, &fz); + if ((z >= cz) && (z <= fz)) + if (inside(x,y,(short)i) == 1) + { *sectnum = i; return; } + } + wal++; j--; + } while (j != 0); + } + + for (i=numsectors-1;i>=0;i--) + { + getzsofslope(i, x, y, &cz, &fz); + if ((z >= cz) && (z <= fz)) + if (inside(x,y,(short)i) == 1) + { *sectnum = i; return; } + } + + *sectnum = -1; +} + + +// +// rotatepoint +// +void rotatepoint(long xpivot, long ypivot, long x, long y, short daang, long *x2, long *y2) +{ + long dacos, dasin; + + dacos = sintable[(daang+2560)&2047]; + dasin = sintable[(daang+2048)&2047]; + x -= xpivot; + y -= ypivot; + *x2 = dmulscale14(x,dacos,-y,dasin) + xpivot; + *y2 = dmulscale14(y,dacos,x,dasin) + ypivot; +} + + +// +// getmousevalues +// + +void getmousevalues(long *mousx, long *mousy, long *bstatus) +{ + readmousexy(mousx,mousy); + readmousebstatus(bstatus); +} + + +// +// krand +// +long krand(void) +{ + randomseed = (randomseed*27584621)+1; + return(((unsigned long)randomseed)>>16); +} + + +// +// getzrange +// +void getzrange(long x, long y, long z, short sectnum, + long *ceilz, long *ceilhit, long *florz, long *florhit, + long walldist, unsigned long cliptype) +{ + sectortype *sec; + walltype *wal, *wal2; + spritetype *spr; + long clipsectcnt, startwall, endwall, tilenum, xoff, yoff, dax, day; + long xmin, ymin, xmax, ymax, i, j, k, l, daz, daz2, dx, dy; + long x1, y1, x2, y2, x3, y3, x4, y4, ang, cosang, sinang; + long xspan, yspan, xrepeat, yrepeat, dasprclipmask, dawalclipmask; + short cstat; + char clipyou; + + if (sectnum < 0) + { + *ceilz = 0x80000000; *ceilhit = -1; + *florz = 0x7fffffff; *florhit = -1; + return; + } + + //Extra walldist for sprites on sector lines + i = walldist+MAXCLIPDIST+1; + xmin = x-i; ymin = y-i; + xmax = x+i; ymax = y+i; + + getzsofslope(sectnum,x,y,ceilz,florz); + *ceilhit = sectnum+16384; *florhit = sectnum+16384; + + dawalclipmask = (cliptype&65535); + dasprclipmask = (cliptype>>16); + + clipsectorlist[0] = sectnum; + clipsectcnt = 0; clipsectnum = 1; + + do //Collect sectors inside your square first + { + sec = §or[clipsectorlist[clipsectcnt]]; + startwall = sec->wallptr; endwall = startwall + sec->wallnum; + for(j=startwall,wal=&wall[startwall];jnextsector; + if (k >= 0) + { + wal2 = &wall[wal->point2]; + x1 = wal->x; x2 = wal2->x; + if ((x1 < xmin) && (x2 < xmin)) continue; + if ((x1 > xmax) && (x2 > xmax)) continue; + y1 = wal->y; y2 = wal2->y; + if ((y1 < ymin) && (y2 < ymin)) continue; + if ((y1 > ymax) && (y2 > ymax)) continue; + + dx = x2-x1; dy = y2-y1; + if (dx*(y-y1) < (x-x1)*dy) continue; //back + if (dx > 0) dax = dx*(ymin-y1); else dax = dx*(ymax-y1); + if (dy > 0) day = dy*(xmax-x1); else day = dy*(xmin-x1); + if (dax >= day) continue; + + if (wal->cstat&dawalclipmask) continue; + sec = §or[k]; + if (editstatus == 0) + { + if (((sec->ceilingstat&1) == 0) && (z <= sec->ceilingz+(3<<8))) continue; + if (((sec->floorstat&1) == 0) && (z >= sec->floorz-(3<<8))) continue; + } + + for(i=clipsectnum-1;i>=0;i--) if (clipsectorlist[i] == k) break; + if (i < 0) clipsectorlist[clipsectnum++] = k; + + if ((x1 < xmin+MAXCLIPDIST) && (x2 < xmin+MAXCLIPDIST)) continue; + if ((x1 > xmax-MAXCLIPDIST) && (x2 > xmax-MAXCLIPDIST)) continue; + if ((y1 < ymin+MAXCLIPDIST) && (y2 < ymin+MAXCLIPDIST)) continue; + if ((y1 > ymax-MAXCLIPDIST) && (y2 > ymax-MAXCLIPDIST)) continue; + if (dx > 0) dax += dx*MAXCLIPDIST; else dax -= dx*MAXCLIPDIST; + if (dy > 0) day -= dy*MAXCLIPDIST; else day += dy*MAXCLIPDIST; + if (dax >= day) continue; + + //It actually got here, through all the continue's!!! + getzsofslope((short)k,x,y,&daz,&daz2); + if (daz > *ceilz) { *ceilz = daz; *ceilhit = k+16384; } + if (daz2 < *florz) { *florz = daz2; *florhit = k+16384; } + } + } + clipsectcnt++; + } while (clipsectcnt < clipsectnum); + + for(i=0;i=0;j=nextspritesect[j]) + { + spr = &sprite[j]; + cstat = spr->cstat; + if (cstat&dasprclipmask) + { + x1 = spr->x; y1 = spr->y; + + clipyou = 0; + switch(cstat&48) + { + case 0: + k = walldist+(spr->clipdist<<2)+1; + if ((klabs(x1-x) <= k) && (klabs(y1-y) <= k)) + { + daz = spr->z; + k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1); + if (cstat&128) daz += k; + if (picanm[spr->picnum]&0x00ff0000) daz -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + daz2 = daz - (k<<1); + clipyou = 1; + } + break; + case 16: + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + if ((cstat&4) > 0) xoff = -xoff; + k = spr->ang; l = spr->xrepeat; + dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; + l = tilesizx[tilenum]; k = (l>>1)+xoff; + x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l); + y1 -= mulscale16(day,k); y2 = y1+mulscale16(day,l); + if (clipinsideboxline(x,y,x1,y1,x2,y2,walldist+1) != 0) + { + daz = spr->z; k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1); + if (cstat&128) daz += k; + if (picanm[spr->picnum]&0x00ff0000) daz -= ((long)((signed char)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + daz2 = daz-(k<<1); + clipyou = 1; + } + break; + case 32: + daz = spr->z; daz2 = daz; + + if ((cstat&64) != 0) + if ((z > daz) == ((cstat&8)==0)) continue; + + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + if ((cstat&4) > 0) xoff = -xoff; + if ((cstat&8) > 0) yoff = -yoff; + + ang = spr->ang; + cosang = sintable[(ang+512)&2047]; sinang = sintable[ang]; + xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; + yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; + + dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat; + x1 += dmulscale16(sinang,dax,cosang,day)-x; + y1 += dmulscale16(sinang,day,-cosang,dax)-y; + l = xspan*xrepeat; + x2 = x1 - mulscale16(sinang,l); + y2 = y1 + mulscale16(cosang,l); + l = yspan*yrepeat; + k = -mulscale16(cosang,l); x3 = x2+k; x4 = x1+k; + k = -mulscale16(sinang,l); y3 = y2+k; y4 = y1+k; + + dax = mulscale14(sintable[(spr->ang-256+512)&2047],walldist+4); + day = mulscale14(sintable[(spr->ang-256)&2047],walldist+4); + x1 += dax; x2 -= day; x3 -= dax; x4 += day; + y1 += day; y2 += dax; y3 -= day; y4 -= dax; + + if ((y1^y2) < 0) + { + if ((x1^x2) < 0) clipyou ^= (x1*y2= 0) clipyou ^= 1; + } + if ((y2^y3) < 0) + { + if ((x2^x3) < 0) clipyou ^= (x2*y3= 0) clipyou ^= 1; + } + if ((y3^y4) < 0) + { + if ((x3^x4) < 0) clipyou ^= (x3*y4= 0) clipyou ^= 1; + } + if ((y4^y1) < 0) + { + if ((x4^x1) < 0) clipyou ^= (x4*y1= 0) clipyou ^= 1; + } + break; + } + + if (clipyou != 0) + { + if ((z > daz) && (daz > *ceilz)) { *ceilz = daz; *ceilhit = j+49152; } + if ((z < daz2) && (daz2 < *florz)) { *florz = daz2; *florhit = j+49152; } + } + } + } + } +} + + +// +// setview +// +void setview(long x1, long y1, long x2, long y2) +{ + long i; + + windowx1 = x1; wx1 = (x1<<12); + windowy1 = y1; wy1 = (y1<<12); + windowx2 = x2; wx2 = ((x2+1)<<12); + windowy2 = y2; wy2 = ((y2+1)<<12); + + xdimen = (x2-x1)+1; halfxdimen = (xdimen>>1); + xdimenrecip = divscale32(1L,xdimen); + ydimen = (y2-y1)+1; + + setaspect(65536L,(long)divscale16(ydim*320L,xdim*200L)); + + for(i=0;i cx2) || (cy1 > cy2)) return; + if (z <= 16) return; + if (picanm[picnum]&192) picnum += animateoffs(picnum,(short)0xc000); + if ((tilesizx[picnum] <= 0) || (tilesizy[picnum] <= 0)) return; + + if (((dastat&128) == 0) || (numpages < 2) || (beforedrawrooms != 0)) { + begindrawing(); //{{{ + dorotatesprite(sx,sy,z,a,picnum,dashade,dapalnum,dastat,cx1,cy1,cx2,cy2,guniqhudid); + enddrawing(); //}}} + } + + if ((dastat&64) && (cx1 <= 0) && (cy1 <= 0) && (cx2 >= xdim-1) && (cy2 >= ydim-1) && + (sx == (160<<16)) && (sy == (100<<16)) && (z == 65536L) && (a == 0) && ((dastat&1) == 0)) + permhead = permtail = 0; + + if ((dastat&128) == 0) return; + if (numpages >= 2) + { + per = &permfifo[permhead]; + per->sx = sx; per->sy = sy; per->z = z; per->a = a; + per->picnum = picnum; + per->dashade = dashade; per->dapalnum = dapalnum; + per->dastat = dastat; + per->pagesleft = numpages+((beforedrawrooms&1)<<7); + per->cx1 = cx1; per->cy1 = cy1; per->cx2 = cx2; per->cy2 = cy2; + per->uniqid = guniqhudid; //JF extension + + //Would be better to optimize out true bounding boxes + if (dastat&64) //If non-masking write, checking for overlapping cases + { + for(i=permtail;i!=permhead;i=((i+1)&(MAXPERMS-1))) + { + per2 = &permfifo[i]; + if ((per2->pagesleft&127) == 0) continue; + if (per2->sx != per->sx) continue; + if (per2->sy != per->sy) continue; + if (per2->z != per->z) continue; + if (per2->a != per->a) continue; + if (tilesizx[per2->picnum] > tilesizx[per->picnum]) continue; + if (tilesizy[per2->picnum] > tilesizy[per->picnum]) continue; + if (per2->cx1 < per->cx1) continue; + if (per2->cy1 < per->cy1) continue; + if (per2->cx2 > per->cx2) continue; + if (per2->cy2 > per->cy2) continue; + per2->pagesleft = 0; + } + if ((per->z == 65536) && (per->a == 0)) + for(i=permtail;i!=permhead;i=((i+1)&(MAXPERMS-1))) + { + per2 = &permfifo[i]; + if ((per2->pagesleft&127) == 0) continue; + if (per2->z != 65536) continue; + if (per2->a != 0) continue; + if (per2->cx1 < per->cx1) continue; + if (per2->cy1 < per->cy1) continue; + if (per2->cx2 > per->cx2) continue; + if (per2->cy2 > per->cy2) continue; + if ((per2->sx>>16) < (per->sx>>16)) continue; + if ((per2->sy>>16) < (per->sy>>16)) continue; + if ((per2->sx>>16)+tilesizx[per2->picnum] > (per->sx>>16)+tilesizx[per->picnum]) continue; + if ((per2->sy>>16)+tilesizy[per2->picnum] > (per->sy>>16)+tilesizy[per->picnum]) continue; + per2->pagesleft = 0; + } + } + + permhead = ((permhead+1)&(MAXPERMS-1)); + } +} + + +// +// makepalookup +// +void makepalookup(long palnum, char *remapbuf, signed char r, signed char g, signed char b, char dastat) +{ + long i, j, palscale; + char *ptr, *ptr2; + + if (paletteloaded == 0) return; + + if (palookup[palnum] == NULL) + { + //Allocate palookup buffer + if ((palookup[palnum] = (char *)kkmalloc(numpalookups<<8)) == NULL) + allocache((long*)&palookup[palnum],numpalookups<<8,&permanentlock); + } + + if (dastat == 0) return; + if ((r|g|b|63) != 63) return; + + if ((r|g|b) == 0) + { + for(i=0;i<256;i++) + { + ptr = (char *)(FP_OFF(palookup[0])+remapbuf[i]); + ptr2 = (char *)(FP_OFF(palookup[palnum])+i); + for(j=0;j> 6 ) ) >> 2; + tempbuf[k++] = + (curpalettefaded[i].g = + p.g + ( ( ( (long)palfadergb.g - (long)p.g ) * (long)offset ) >> 6 ) ) >> 2; + tempbuf[k++] = + (curpalettefaded[i].r = + p.r + ( ( ( (long)palfadergb.r - (long)p.r ) * (long)offset ) >> 6 ) ) >> 2; + tempbuf[k++] = curpalettefaded[i].f = 0; + } + + setpalette(0,256,(char*)tempbuf); +} + + +// +// clearview +// +void clearview(long dacol) +{ + long p, y, dx; + + if (qsetmode != 200) return; + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode == 3) { + palette_t p; + if (gammabrightness) p = curpalette[dacol]; + else { + p.r = britable[curbrightness][ curpalette[dacol].r ]; + p.g = britable[curbrightness][ curpalette[dacol].g ]; + p.b = britable[curbrightness][ curpalette[dacol].b ]; + } + bglClearColor(((float)p.r)/255.0, + ((float)p.g)/255.0, + ((float)p.b)/255.0, + 0); + bglClear(GL_COLOR_BUFFER_BIT); + return; + } +#endif + + begindrawing(); //{{{ + dx = windowx2-windowx1+1; + //dacol += (dacol<<8); dacol += (dacol<<16); + p = frameplace+ylookup[windowy1]+windowx1; + for(y=windowy1;y<=windowy2;y++) { + //clearbufbyte((void*)p,dx,dacol); + Bmemset((void*)p,dacol,dx); + p += ylookup[1]; + } + enddrawing(); //}}} + + faketimerhandler(); +} + + +// +// clearallviews +// +void clearallviews(long dacol) +{ + if (qsetmode != 200) return; + //dacol += (dacol<<8); dacol += (dacol<<16); + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode == 3) { + palette_t p; + if (gammabrightness) p = curpalette[dacol]; + else { + p.r = britable[curbrightness][ curpalette[dacol].r ]; + p.g = britable[curbrightness][ curpalette[dacol].g ]; + p.b = britable[curbrightness][ curpalette[dacol].b ]; + } + bglViewport(0,0,xdim,ydim); glox1 = -1; + bglClearColor(((float)p.r)/255.0, + ((float)p.g)/255.0, + ((float)p.b)/255.0, + 0); + bglClear(GL_COLOR_BUFFER_BIT); + return; + } +#endif + + begindrawing(); //{{{ + //clearbufbyte((void*)frameplace,imageSize,0L); + Bmemset((void*)frameplace,dacol,imageSize); + enddrawing(); //}}} + //nextpage(); + + faketimerhandler(); +} + + +// +// plotpixel +// +void plotpixel(long x, long y, char col) +{ +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode == 3 && qsetmode == 200) { + palette_t p; + if (gammabrightness) p = curpalette[col]; + else { + p.r = britable[curbrightness][ curpalette[col].r ]; + p.g = britable[curbrightness][ curpalette[col].g ]; + p.b = britable[curbrightness][ curpalette[col].b ]; + } + + setpolymost2dview(); // JBF 20040205: more efficient setup + + bglBegin(GL_POINTS); + bglColor4ub(p.r,p.g,p.b,255); + bglVertex2i(x,y); + bglEnd(); + + return; + } +#endif + + begindrawing(); //{{{ + drawpixel((void*)(ylookup[y]+x+frameplace),(long)col); + enddrawing(); //}}} +} + + +// +// getpixel +// +char getpixel(long x, long y) +{ + char r; + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode == 3 && qsetmode == 200) return 0; +#endif + + begindrawing(); //{{{ + r = readpixel((void*)(ylookup[y]+x+frameplace)); + enddrawing(); //}}} + return(r); +} + + + //MUST USE RESTOREFORDRAWROOMS AFTER DRAWING + +// +// setviewtotile +// +void setviewtotile(short tilenume, long xsiz, long ysiz) +{ + long i, j; + + //DRAWROOMS TO TILE BACKUP&SET CODE + tilesizx[tilenume] = xsiz; tilesizy[tilenume] = ysiz; + bakxsiz[setviewcnt] = xsiz; bakysiz[setviewcnt] = ysiz; + bakframeplace[setviewcnt] = frameplace; frameplace = waloff[tilenume]; + bakwindowx1[setviewcnt] = windowx1; bakwindowy1[setviewcnt] = windowy1; + bakwindowx2[setviewcnt] = windowx2; bakwindowy2[setviewcnt] = windowy2; +#ifdef POLYMOST + if (setviewcnt == 0) { + bakrendmode = rendmode; + baktile = tilenume; + } + rendmode = 0;//2; +#endif + copybufbyte(&startumost[windowx1],&bakumost[windowx1],(windowx2-windowx1+1)*sizeof(bakumost[0])); + copybufbyte(&startdmost[windowx1],&bakdmost[windowx1],(windowx2-windowx1+1)*sizeof(bakdmost[0])); + setviewcnt++; + + offscreenrendering = 1; + setview(0,0,ysiz-1,xsiz-1); + setaspect(65536,65536); + j = 0; for(i=0;i<=xsiz;i++) { ylookup[i] = j, j += ysiz; } + setvlinebpl(ysiz); +} + + +// +// setviewback +// +extern char modechange; +void setviewback(void) +{ + long i, j, k; + + if (setviewcnt <= 0) return; + setviewcnt--; + + offscreenrendering = (setviewcnt>0); +#ifdef POLYMOST + if (setviewcnt == 0) { + rendmode = bakrendmode; + invalidatetile(baktile,-1,-1); + } +#endif + + setview(bakwindowx1[setviewcnt],bakwindowy1[setviewcnt], + bakwindowx2[setviewcnt],bakwindowy2[setviewcnt]); + copybufbyte(&bakumost[windowx1],&startumost[windowx1],(windowx2-windowx1+1)*sizeof(startumost[0])); + copybufbyte(&bakdmost[windowx1],&startdmost[windowx1],(windowx2-windowx1+1)*sizeof(startdmost[0])); + frameplace = bakframeplace[setviewcnt]; + if (setviewcnt == 0) + k = bakxsiz[0]; + else + k = max(bakxsiz[setviewcnt-1],bakxsiz[setviewcnt]); + j = 0; for(i=0;i<=k;i++) ylookup[i] = j, j += bytesperline; + setvlinebpl(bytesperline); + modechange=1; +} + + +// +// squarerotatetile +// +void squarerotatetile(short tilenume) +{ + long i, j, k, xsiz, ysiz; + char *ptr1, *ptr2; + + xsiz = tilesizx[tilenume]; ysiz = tilesizy[tilenume]; + + //supports square tiles only for rotation part + if (xsiz == ysiz) + { + k = (xsiz<<1); + for(i=xsiz-1;i>=0;i--) + { + ptr1 = (char *)(waloff[tilenume]+i*(xsiz+1)); ptr2 = ptr1; + if ((i&1) != 0) { ptr1--; ptr2 -= xsiz; swapchar(ptr1,ptr2); } + for(j=(i>>1)-1;j>=0;j--) + { ptr1 -= 2; ptr2 -= k; swapchar2(ptr1,ptr2,xsiz); } + } + } +} + + +// +// preparemirror +// +void preparemirror(long dax, long day, long daz, short daang, long dahoriz, short dawall, short dasector, long *tposx, long *tposy, short *tang) +{ + long i, j, x, y, dx, dy; + + x = wall[dawall].x; dx = wall[wall[dawall].point2].x-x; + y = wall[dawall].y; dy = wall[wall[dawall].point2].y-y; + j = dx*dx + dy*dy; if (j == 0) return; + i = (((dax-x)*dx + (day-y)*dy)<<1); + *tposx = (x<<1) + scale(dx,i,j) - dax; + *tposy = (y<<1) + scale(dy,i,j) - day; + *tang = (((getangle(dx,dy)<<1)-daang)&2047); + + inpreparemirror = 1; +} + + +// +// completemirror +// +void completemirror(void) +{ + long i, dy, p; + +#ifdef POLYMOST + if (rendmode) return; +#endif + + //Can't reverse with uninitialized data + if (inpreparemirror) { inpreparemirror = 0; return; } + if (mirrorsx1 > 0) mirrorsx1--; + if (mirrorsx2 < windowx2-windowx1-1) mirrorsx2++; + if (mirrorsx2 < mirrorsx1) return; + + begindrawing(); + p = frameplace+ylookup[windowy1+mirrorsy1]+windowx1+mirrorsx1; + i = windowx2-windowx1-mirrorsx2-mirrorsx1; mirrorsx2 -= mirrorsx1; + for(dy=mirrorsy2-mirrorsy1-1;dy>=0;dy--) + { + copybufbyte((void*)(p+1),tempbuf,mirrorsx2+1); + tempbuf[mirrorsx2] = tempbuf[mirrorsx2-1]; + copybufreverse(&tempbuf[mirrorsx2],(void*)(p+i),mirrorsx2+1); + p += ylookup[1]; + faketimerhandler(); + } + enddrawing(); +} + + +// +// sectorofwall +// +long sectorofwall(short theline) +{ + long i, gap; + + if ((theline < 0) || (theline >= numwalls)) return(-1); + i = wall[theline].nextwall; if (i >= 0) return(wall[i].nextsector); + + gap = (numsectors>>1); i = gap; + while (gap > 1) + { + gap >>= 1; + if (sector[i].wallptr < theline) i += gap; else i -= gap; + } + while (sector[i].wallptr > theline) i--; + while (sector[i].wallptr+sector[i].wallnum <= theline) i++; + return(i); +} + + +// +// getceilzofslope +// +long getceilzofslope(short sectnum, long dax, long day) +{ + long dx, dy, i, j; + walltype *wal; + + if (!(sector[sectnum].ceilingstat&2)) return(sector[sectnum].ceilingz); + wal = &wall[sector[sectnum].wallptr]; + dx = wall[wal->point2].x-wal->x; dy = wall[wal->point2].y-wal->y; + i = (nsqrtasm(dx*dx+dy*dy)<<5); if (i == 0) return(sector[sectnum].ceilingz); + j = dmulscale3(dx,day-wal->y,-dy,dax-wal->x); + return(sector[sectnum].ceilingz+scale(sector[sectnum].ceilingheinum,j,i)); +} + + +// +// getflorzofslope +// +long getflorzofslope(short sectnum, long dax, long day) +{ + long dx, dy, i, j; + walltype *wal; + + if (!(sector[sectnum].floorstat&2)) return(sector[sectnum].floorz); + wal = &wall[sector[sectnum].wallptr]; + dx = wall[wal->point2].x-wal->x; dy = wall[wal->point2].y-wal->y; + i = (nsqrtasm(dx*dx+dy*dy)<<5); if (i == 0) return(sector[sectnum].floorz); + j = dmulscale3(dx,day-wal->y,-dy,dax-wal->x); + return(sector[sectnum].floorz+scale(sector[sectnum].floorheinum,j,i)); +} + + +// +// getzsofslope +// +void getzsofslope(short sectnum, long dax, long day, long *ceilz, long *florz) +{ + long dx, dy, i, j; + walltype *wal, *wal2; + sectortype *sec; + + sec = §or[sectnum]; + *ceilz = sec->ceilingz; *florz = sec->floorz; + if ((sec->ceilingstat|sec->floorstat)&2) + { + wal = &wall[sec->wallptr]; wal2 = &wall[wal->point2]; + dx = wal2->x-wal->x; dy = wal2->y-wal->y; + i = (nsqrtasm(dx*dx+dy*dy)<<5); if (i == 0) return; + j = dmulscale3(dx,day-wal->y,-dy,dax-wal->x); + if (sec->ceilingstat&2) *ceilz = (*ceilz)+scale(sec->ceilingheinum,j,i); + if (sec->floorstat&2) *florz = (*florz)+scale(sec->floorheinum,j,i); + } +} + + +// +// alignceilslope +// +void alignceilslope(short dasect, long x, long y, long z) +{ + long i, dax, day; + walltype *wal; + + wal = &wall[sector[dasect].wallptr]; + dax = wall[wal->point2].x-wal->x; + day = wall[wal->point2].y-wal->y; + + i = (y-wal->y)*dax - (x-wal->x)*day; if (i == 0) return; + sector[dasect].ceilingheinum = scale((z-sector[dasect].ceilingz)<<8, + nsqrtasm(dax*dax+day*day),i); + + if (sector[dasect].ceilingheinum == 0) sector[dasect].ceilingstat &= ~2; + else sector[dasect].ceilingstat |= 2; +} + + +// +// alignflorslope +// +void alignflorslope(short dasect, long x, long y, long z) +{ + long i, dax, day; + walltype *wal; + + wal = &wall[sector[dasect].wallptr]; + dax = wall[wal->point2].x-wal->x; + day = wall[wal->point2].y-wal->y; + + i = (y-wal->y)*dax - (x-wal->x)*day; if (i == 0) return; + sector[dasect].floorheinum = scale((z-sector[dasect].floorz)<<8, + nsqrtasm(dax*dax+day*day),i); + + if (sector[dasect].floorheinum == 0) sector[dasect].floorstat &= ~2; + else sector[dasect].floorstat |= 2; +} + + +// +// loopnumofsector +// +long loopnumofsector(short sectnum, short wallnum) +{ + long i, numloops, startwall, endwall; + + numloops = 0; + startwall = sector[sectnum].wallptr; + endwall = startwall + sector[sectnum].wallnum; + for(i=startwall;i= startwall+danumwalls)) return; + for(i=0;i 0) + { + j = 0; + while (loopnumofsector(sectnum,j+startwall) != dagoalloop) j++; + for(i=0;i= danumwalls) k -= danumwalls; + Bmemcpy(&wall[startwall+i],&wall[numwalls+k],sizeof(walltype)); + + wall[startwall+i].point2 += danumwalls-startwall-j; + if (wall[startwall+i].point2 >= danumwalls) + wall[startwall+i].point2 -= danumwalls; + wall[startwall+i].point2 += startwall; + } + newfirstwall += danumwalls-j; + if (newfirstwall >= startwall+danumwalls) newfirstwall -= danumwalls; + } + + for(i=0;i= numwallsofloop) k -= numwallsofloop; + Bmemcpy(&wall[startwall+i],&wall[numwalls+k],sizeof(walltype)); + + wall[startwall+i].point2 += numwallsofloop-newfirstwall; + if (wall[startwall+i].point2 >= numwallsofloop) + wall[startwall+i].point2 -= numwallsofloop; + wall[startwall+i].point2 += startwall; + } + + for(i=startwall;i= 0) wall[wall[i].nextwall].nextwall = i; +} + + +// +// drawline256 +// +void drawline256(long x1, long y1, long x2, long y2, char col) +{ + long dx, dy, i, j, p, inc, plc, daend; + + col = palookup[0][col]; + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode == 3) + { + palette_t p; + if (gammabrightness) p = curpalette[col]; + else { + p.r = britable[curbrightness][ curpalette[col].r ]; + p.g = britable[curbrightness][ curpalette[col].g ]; + p.b = britable[curbrightness][ curpalette[col].b ]; + } + + setpolymost2dview(); // JBF 20040205: more efficient setup + + bglBegin(GL_LINES); + bglColor4ub(p.r,p.g,p.b,255); + bglVertex2f((float)x1/4096.0,(float)y1/4096.0); + bglVertex2f((float)x2/4096.0,(float)y2/4096.0); + bglEnd(); + + return; + } +#endif + + dx = x2-x1; dy = y2-y1; + if (dx >= 0) + { + if ((x1 >= wx2) || (x2 < wx1)) return; + if (x1 < wx1) y1 += scale(wx1-x1,dy,dx), x1 = wx1; + if (x2 > wx2) y2 += scale(wx2-x2,dy,dx), x2 = wx2; + } + else + { + if ((x2 >= wx2) || (x1 < wx1)) return; + if (x2 < wx1) y2 += scale(wx1-x2,dy,dx), x2 = wx1; + if (x1 > wx2) y1 += scale(wx2-x1,dy,dx), x1 = wx2; + } + if (dy >= 0) + { + if ((y1 >= wy2) || (y2 < wy1)) return; + if (y1 < wy1) x1 += scale(wy1-y1,dx,dy), y1 = wy1; + if (y2 > wy2) x2 += scale(wy2-y2,dx,dy), y2 = wy2; + } + else + { + if ((y2 >= wy2) || (y1 < wy1)) return; + if (y2 < wy1) x2 += scale(wy1-y2,dx,dy), y2 = wy1; + if (y1 > wy2) x1 += scale(wy2-y1,dx,dy), y1 = wy2; + } + + if (klabs(dx) >= klabs(dy)) + { + if (dx == 0) return; + if (dx < 0) + { + i = x1; x1 = x2; x2 = i; + i = y1; y1 = y2; y2 = i; + } + + inc = divscale12(dy,dx); + plc = y1+mulscale12((2047-x1)&4095,inc); + i = ((x1+2048)>>12); daend = ((x2+2048)>>12); + + begindrawing(); //{{{ + for(;i>12); + if ((j >= startumost[i]) && (j < startdmost[i])) + drawpixel((void*)(frameplace+ylookup[j]+i),col); + plc += inc; + } + enddrawing(); //}}} + } + else + { + if (dy < 0) + { + i = x1; x1 = x2; x2 = i; + i = y1; y1 = y2; y2 = i; + } + + inc = divscale12(dx,dy); + plc = x1+mulscale12((2047-y1)&4095,inc); + i = ((y1+2048)>>12); daend = ((y2+2048)>>12); + + begindrawing(); //{{{ + p = ylookup[i]+frameplace; + for(;i>12); + if ((i >= startumost[j]) && (i < startdmost[j])) + drawpixel((void*)(j+p),col); + plc += inc; p += ylookup[1]; + } + enddrawing(); //}}} + } +} + +// +// drawline16 +// +// JBF: Had to add extra tests to make sure x-coordinates weren't winding up -'ve +// after clipping or crashes would ensue +unsigned long drawlinepat = 0xffffffff; + +void drawline16(long x1, long y1, long x2, long y2, char col) +{ + long i, dx, dy, p, pinc, d; + unsigned long patc=0; + + dx = x2-x1; dy = y2-y1; + if (dx >= 0) + { + if ((x1 >= xres) || (x2 < 0)) return; + if (x1 < 0) { if (dy) y1 += scale(0-x1,dy,dx); x1 = 0; } + if (x2 >= xres) { if (dy) y2 += scale(xres-1-x2,dy,dx); x2 = xres-1; } + } + else + { + if ((x2 >= xres) || (x1 < 0)) return; + if (x2 < 0) { if (dy) y2 += scale(0-x2,dy,dx); x2 = 0; } + if (x1 >= xres) { if (dy) y1 += scale(xres-1-x1,dy,dx); x1 = xres-1; } + } + if (dy >= 0) + { + if ((y1 >= ydim16) || (y2 < 0)) return; + if (y1 < 0) { if (dx) x1 += scale(0-y1,dx,dy); y1 = 0; if (x1 < 0) x1 = 0; } + if (y2 >= ydim16) { if (dx) x2 += scale(ydim16-1-y2,dx,dy); y2 = ydim16-1; if (x2 < 0) x2 = 0; } + } + else + { + if ((y2 >= ydim16) || (y1 < 0)) return; + if (y2 < 0) { if (dx) x2 += scale(0-y2,dx,dy); y2 = 0; if (x2 < 0) x2 = 0; } + if (y1 >= ydim16) { if (dx) x1 += scale(ydim16-1-y1,dx,dy); y1 = ydim16-1; if (x1 < 0) x1 = 0; } + } + + dx = klabs(x2-x1)+1; dy = klabs(y2-y1)+1; + if (dx >= dy) + { + if (x2 < x1) + { + i = x1; x1 = x2; x2 = i; + i = y1; y1 = y2; y2 = i; + } + d = 0; + if (y2 > y1) pinc = bytesperline; else pinc = -bytesperline; + + begindrawing(); //{{{ + p = (y1*bytesperline)+x1+frameplace; + if (dy == 0 && drawlinepat == 0xffffffff) { + i = ((long)col<<24)|((long)col<<16)|((long)col<<8)|col; + clearbufbyte((void *)p, dx, i); + } else + for(i=dx;i>0;i--) + { + if (drawlinepat & pow2long[(patc++)&31]) + drawpixel((char *)p, col); + d += dy; + if (d >= dx) { d -= dx; p += pinc; } + p++; + } + enddrawing(); //}}} + return; + } + + if (y2 < y1) + { + i = x1; x1 = x2; x2 = i; + i = y1; y1 = y2; y2 = i; + } + d = 0; + if (x2 > x1) pinc = 1; else pinc = -1; + + begindrawing(); //{{{ + p = (y1*bytesperline)+x1+frameplace; + for(i=dy;i>0;i--) + { + if (drawlinepat & pow2long[(patc++)&31]) + drawpixel((char *)p, col); + d += dx; + if (d >= dy) { d -= dy; p += pinc; } + p += bytesperline; + } + enddrawing(); //}}} +} + +void drawcircle16(long x1, long y1, long r, char col) +{ +#if 1 + long p, xp, yp, xpbpl, ypbpl, d, de, dse, patc=0; + + if (r < 0) r = -r; + if (x1+r < 0 || x1-r >= xres) return; + if (y1+r < 0 || y1-r >= ydim16) return; + + /* + * d + * 6 | 7 + * \ | / + * 5 \|/ 8 + * c----+----a + * 4 /|\ 1 + * / | \ + * 3 | 2 + * b + */ + + xp = 0; + yp = r; + d = 1 - r; + de = 2; + dse = 5 - (r << 1); + + begindrawing(); + p = (y1*bytesperline)+x1+frameplace; + + if (drawlinepat & pow2long[(patc++)&31]) { + if ((unsigned long)y1 < (unsigned long)ydim16 && (unsigned long)(x1+r) < (unsigned long)xres ) + drawpixel((char *)(p+r), col); // a + if ((unsigned long)x1 < (unsigned long)xres && (unsigned long)(y1+r) < (unsigned long)ydim16) + drawpixel((char *)(p+(r*bytesperline)), col); // b + if ((unsigned long)y1 < (unsigned long)ydim16 && (unsigned long)(x1-r) < (unsigned long)xres ) + drawpixel((char *)(p-r), col); // c + if ((unsigned long)x1 < (unsigned long)xres && (unsigned long)(y1-r) < (unsigned long)ydim16) + drawpixel((char *)(p-(r*bytesperline)), col); // d + } + + while (yp > xp) { + if (d < 0) { + d += de; + de += 2; + dse += 2; + xp++; + } else { + d += dse; + de += 2; + dse += 4; + xp++; + yp--; + } + + ypbpl = yp*bytesperline; + xpbpl = xp*bytesperline; + if (drawlinepat & pow2long[(patc++)&31]) { + if ((unsigned long)(x1+yp) < (unsigned long)xres && (unsigned long)(y1+xp) < (unsigned long)ydim16) + drawpixel((char *)(p+yp+xpbpl), col); // 1 + if ((unsigned long)(x1+xp) < (unsigned long)xres && (unsigned long)(y1+yp) < (unsigned long)ydim16) + drawpixel((char *)(p+xp+ypbpl), col); // 2 + if ((unsigned long)(x1-xp) < (unsigned long)xres && (unsigned long)(y1+yp) < (unsigned long)ydim16) + drawpixel((char *)(p-xp+ypbpl), col); // 3 + if ((unsigned long)(x1-yp) < (unsigned long)xres && (unsigned long)(y1+xp) < (unsigned long)ydim16) + drawpixel((char *)(p-yp+xpbpl), col); // 4 + if ((unsigned long)(x1-yp) < (unsigned long)xres && (unsigned long)(y1-xp) < (unsigned long)ydim16) + drawpixel((char *)(p-yp-xpbpl), col); // 5 + if ((unsigned long)(x1-xp) < (unsigned long)xres && (unsigned long)(y1-yp) < (unsigned long)ydim16) + drawpixel((char *)(p-xp-ypbpl), col); // 6 + if ((unsigned long)(x1+xp) < (unsigned long)xres && (unsigned long)(y1-yp) < (unsigned long)ydim16) + drawpixel((char *)(p+xp-ypbpl), col); // 7 + if ((unsigned long)(x1+yp) < (unsigned long)xres && (unsigned long)(y1-xp) < (unsigned long)ydim16) + drawpixel((char *)(p+yp-xpbpl), col); // 8 + } + } + enddrawing(); +#else + // JonoF's rough approximation of a circle + long l,spx,spy,lpx,lpy,px,py; + + spx = lpx = x1+mulscale14(r,sintable[0]); + spy = lpy = y1+mulscale14(r,sintable[512]); + + for (l=64;l<2048;l+=64) { + px = x1+mulscale14(r,sintable[l]); + py = y1+mulscale14(r,sintable[(l+512)&2047]); + + drawline16(lpx,lpy,px,py,col); + + lpx = px; + lpy = py; + } + + drawline16(lpx,lpy,spx,spy,col); +#endif +} + + +// +// qsetmode640350 +// +void qsetmode640350(void) +{ + if (qsetmode != 350) + { + if (setvideomode(640, 350, 8, fullscreen) < 0) { + //fprintf(stderr, "Couldn't set 640x350 video mode for some reason.\n"); + return; + } + + xdim = xres; + ydim = yres; + + setvgapalette(); + + ydim16 = 350; + halfxdim16 = 320; + midydim16 = 146; + + begindrawing(); //{{{ + clearbuf((char *)frameplace, (bytesperline*350L) >> 2, 0); + enddrawing(); //}}} + } + + qsetmode = 350; +} + + +// +// qsetmode640480 +// +void qsetmode640480(void) +{ + if (qsetmode != 480) + { + if (setvideomode(640, 480, 8, fullscreen) < 0) { + //fprintf(stderr, "Couldn't set 640x480 video mode for some reason.\n"); + return; + } + + xdim = xres; + ydim = yres; + + setvgapalette(); + + ydim16 = 336; + halfxdim16 = 320; + midydim16 = 200; + + begindrawing(); //{{{ + clearbuf((char *)(frameplace + (336l*bytesperline)), (bytesperline*144L) >> 2, 0x08080808l); + clearbuf((char *)frameplace, (bytesperline*336L) >> 2, 0L); + enddrawing(); //}}} + } + + qsetmode = 480; +} + + +// +// qsetmodeany +// +void qsetmodeany(long daxdim, long daydim) +{ + if (daxdim < 640) daxdim = 640; + if (daydim < 480) daydim = 480; + + if (qsetmode != ((daxdim<<16)|(daydim&0xffff))) { + if (setvideomode(daxdim, daydim, 8, fullscreen) < 0) + return; + + xdim = xres; + ydim = yres; + + setvgapalette(); + + ydim16 = yres - STATUS2DSIZ; + halfxdim16 = xres >> 1; + midydim16 = scale(200,yres,480); + + begindrawing(); //{{{ + clearbuf((char *)(frameplace + (ydim16*bytesperline)), (bytesperline*STATUS2DSIZ) >> 2, 0x08080808l); + clearbuf((char *)frameplace, (ydim16*bytesperline) >> 2, 0L); + enddrawing(); //}}} + } + + qsetmode = ((daxdim<<16)|(daydim&0xffff)); +} + + +// +// clear2dscreen +// +void clear2dscreen(void) +{ + int clearsz; + + begindrawing(); //{{{ + if (qsetmode == 350) clearsz = 350; + else { + if (ydim16 <= yres-STATUS2DSIZ) clearsz = yres - STATUS2DSIZ; + else clearsz = yres; + } + clearbuf((char *)frameplace, (bytesperline*clearsz) >> 2, 0); + enddrawing(); //}}} +} + + +// +// draw2dgrid +// +void draw2dgrid(long posxe, long posye, short ange, long zoome, short gride) +{ + long i, xp1, yp1, xp2=0, yp2, tempy; + + if (gride > 0) + { + begindrawing(); //{{{ + + yp1 = midydim16-mulscale14(posye+editorgridextent,zoome); + if (yp1 < 0) yp1 = 0; + yp2 = midydim16-mulscale14(posye-editorgridextent,zoome); + if (yp2 >= ydim16) yp2 = ydim16-1; + + if ((yp1 < ydim16) && (yp2 >= 0) && (yp2 >= yp1)) + { + xp1 = halfxdim16-mulscale14(posxe+editorgridextent,zoome); + for(i=-editorgridextent;i<=editorgridextent;i+=(2048>>gride)) + { + xp2 = xp1; + xp1 = halfxdim16-mulscale14(posxe-i,zoome); + if (xp1 >= xdim) break; + if (xp1 >= 0) + { + if (xp1 != xp2) + { + drawline16(xp1,yp1,xp1,yp2,8); + } + } + } + if ((i >= editorgridextent) && (xp1 < xdim)) + xp2 = xp1; + if ((xp2 >= 0) && (xp2 < xdim)) + { + drawline16(xp2,yp1,xp2,yp2,8); + } + } + xp1 = mulscale14(posxe+editorgridextent,zoome); + xp2 = mulscale14(posxe-editorgridextent,zoome); + tempy = 0x80000000l; + for(i=-editorgridextent;i<=editorgridextent;i+=(2048>>gride)) + { + yp1 = (((posye-i)*zoome)>>14); + if (yp1 != tempy) + { + if ((yp1 > midydim16-ydim16) && (yp1 <= midydim16)) + { + drawline16(halfxdim16-xp1,midydim16-yp1,halfxdim16-xp2,midydim16-yp1,8); + tempy = yp1; + } + } + } + enddrawing(); //}}} + } +} + + +// +// draw2dscreen +// + +char spritecol2d[MAXTILES][2]; + +void draw2dscreen(long posxe, long posye, short ange, long zoome, short gride) +{ + walltype *wal; + long i, j, k, xp1, yp1, xp2, yp2, tempy, templong; + char col, mask; + + if (qsetmode == 200) return; + + begindrawing(); //{{{ + + if (editstatus == 0) + { + faketimerhandler(); + clear2dscreen(); + + faketimerhandler(); + draw2dgrid(posxe,posye,ange,zoome,gride); + } + + faketimerhandler(); + for(i=numwalls-1,wal=&wall[i];i>=0;i--,wal--) + { + if (editstatus == 0) + { + if ((show2dwall[i>>3]&pow2char[i&7]) == 0) continue; + j = wal->nextwall; + if ((j >= 0) && (i > j)) + if ((show2dwall[j>>3]&pow2char[j&7]) > 0) continue; + } + else + { + j = wal->nextwall; + if ((j >= 0) && (i > j)) continue; + } + + if (j < 0) + { + col = 7; + if (i == linehighlight) if (totalclock & 16) col += (2<<2); + } + else + { + col = 4; + if ((wal->cstat&1) != 0) col = 5; + if ((i == linehighlight) || ((linehighlight >= 0) && (i == wall[linehighlight].nextwall))) + if (totalclock & 16) col += (2<<2); + } + + xp1 = mulscale14(wal->x-posxe,zoome); + yp1 = mulscale14(wal->y-posye,zoome); + xp2 = mulscale14(wall[wal->point2].x-posxe,zoome); + yp2 = mulscale14(wall[wal->point2].y-posye,zoome); + + if ((wal->cstat&64) > 0) + { + if (klabs(xp2-xp1) >= klabs(yp2-yp1)) + { + drawline16(halfxdim16+xp1,midydim16+yp1+1,halfxdim16+xp2,midydim16+yp2+1,col); + drawline16(halfxdim16+xp1,midydim16+yp1-1,halfxdim16+xp2,midydim16+yp2-1,col); + } + else + { + drawline16(halfxdim16+xp1+1,midydim16+yp1,halfxdim16+xp2+1,midydim16+yp2,col); + drawline16(halfxdim16+xp1-1,midydim16+yp1,halfxdim16+xp2-1,midydim16+yp2,col); + } + col += 8; + } + + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp2,midydim16+yp2,col); + if ((zoome >= 256) && (editstatus == 1)) + if (((halfxdim16+xp1) >= 2) && ((halfxdim16+xp1) <= xdim-3)) + if (((midydim16+yp1) >= 2) && ((midydim16+yp1) <= ydim16-3)) + { + char pointsize; + col = 6; + pointsize=2; + if (i == pointhighlight || ((wall[i].x == wall[pointhighlight].x) && (wall[i].y == wall[pointhighlight].y))) + { + if (totalclock & 16) + { + col += (2<<2); // JBF 20040116: two braces is all this needed. man I'm a fool sometimes. + pointsize += 1; + } + } + else if ((highlightcnt > 0) && (editstatus == 1)) + { + if (show2dwall[i>>3]&pow2char[i&7]) + if (totalclock & 16) + { + col += (2<<2); // JBF 20040116: two braces is all this needed. man I'm a fool sometimes. + pointsize += 1; + } + } + + templong = ((midydim16+yp1)*bytesperline)+(halfxdim16+xp1)+frameplace; + + drawline16(halfxdim16+xp1-pointsize,midydim16+yp1+pointsize,halfxdim16+xp1+pointsize,midydim16+yp1+pointsize,col); + drawline16(halfxdim16+xp1+pointsize,midydim16+yp1+pointsize,halfxdim16+xp1+pointsize,midydim16+yp1-pointsize,col); + drawline16(halfxdim16+xp1+pointsize,midydim16+yp1-pointsize,halfxdim16+xp1-pointsize,midydim16+yp1-pointsize,col); + drawline16(halfxdim16+xp1-pointsize,midydim16+yp1-pointsize,halfxdim16+xp1-pointsize,midydim16+yp1+pointsize,col); + + } + } + faketimerhandler(); + + if ((zoome >= 256) || (editstatus == 0)) + for(i=0;i=0;j=nextspritesect[j]) + if ((editstatus == 1) || (show2dsprite[j>>3]&pow2char[j&7])) + { + col = 3; + if (spritecol2d[sprite[j].picnum][0]) + col = spritecol2d[sprite[j].picnum][0]; + if ((sprite[j].cstat&1) > 0) + { + col = 5; + if (spritecol2d[sprite[j].picnum][1]) + col = spritecol2d[sprite[j].picnum][1]; + } + if (editstatus == 1) + { + if (j+16384 == pointhighlight || ((sprite[j].x == sprite[pointhighlight-16384].x) && (sprite[j].y == sprite[pointhighlight-16384].y))) { + if (totalclock & 32) col += (2<<2); + } + else if ((highlightcnt > 0) && (editstatus == 1)) + { + if (show2dsprite[j>>3]&pow2char[j&7]) + if (totalclock & 32) col += (2<<2); + } + } + + xp1 = mulscale14(sprite[j].x-posxe,zoome); + yp1 = mulscale14(sprite[j].y-posye,zoome); + if (((halfxdim16+xp1) >= 4) && ((halfxdim16+xp1) <= xdim-6)) + if (((midydim16+yp1) >= 4) && ((midydim16+yp1) <= ydim16-6)) + { + long temp; + templong = ((midydim16+yp1)*bytesperline)+(halfxdim16+xp1)+frameplace; + + + for (temp=0;temp<2;temp++) + { + drawpixel((char *)(templong+3+(bytesperline*temp)), col); + drawpixel((char *)(templong-3-(bytesperline*temp)), col); + drawpixel((char *)(templong-3+(bytesperline*temp)), col); + drawpixel((char *)(templong+3-(bytesperline*temp)), col); + } + + drawpixel((char *)(templong+2+(bytesperline*2)), col); + drawpixel((char *)(templong-2-(bytesperline*2)), col); + drawpixel((char *)(templong-2+(bytesperline*2)), col); + drawpixel((char *)(templong+2-(bytesperline*2)), col); + + for (temp=0;temp<2;temp++) + { + drawpixel((char *)(templong+temp+(bytesperline*3)), col); + drawpixel((char *)(templong-temp-(bytesperline*3)), col); + drawpixel((char *)(templong-temp+(bytesperline*3)), col); + drawpixel((char *)(templong+temp-(bytesperline*3)), col); + } + + + xp2 = mulscale11(sintable[(sprite[j].ang+2560)&2047],zoome) / 768; + yp2 = mulscale11(sintable[(sprite[j].ang+2048)&2047],zoome) / 768; + + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1+xp2,midydim16+yp1+yp2,col); + + if ((sprite[j].cstat&256) > 0) + { + if (((sprite[j].ang+256)&512) == 0) + { + drawline16(halfxdim16+xp1,midydim16+yp1+1,halfxdim16+xp1+xp2,midydim16+yp1+yp2+1,col); + drawline16(halfxdim16+xp1,midydim16+yp1-1,halfxdim16+xp1+xp2,midydim16+yp1+yp2-1,col); + drawline16(halfxdim16+xp1-1,midydim16+yp1,halfxdim16+xp1+xp2-1,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1+1,midydim16+yp1,halfxdim16+xp1+xp2+1,midydim16+yp1+yp2,col); + + } + else + { + drawline16(halfxdim16+xp1,midydim16+yp1+1,halfxdim16+xp1+xp2,midydim16+yp1+yp2+1,col); + drawline16(halfxdim16+xp1,midydim16+yp1-1,halfxdim16+xp1+xp2,midydim16+yp1+yp2-1,col); + drawline16(halfxdim16+xp1-1,midydim16+yp1,halfxdim16+xp1+xp2-1,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1+1,midydim16+yp1,halfxdim16+xp1+xp2+1,midydim16+yp1+yp2,col); + + } + + if ((sprite[j].cstat&32) > 0) { + long fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); + long fy = mulscale6(tilesizy[sprite[j].picnum], sprite[j].yrepeat); + long co[4][2], ii; + long sinang = sintable[(sprite[j].ang+512+1024)&2047]; + long cosang = sintable[(sprite[j].ang+1024)&2047]; + long r,s; + + fx = mulscale10(fx,zoome) >> 1; + fy = mulscale10(fy,zoome) >> 1; + + co[0][0] = -fx; + co[0][1] = -fy; + co[1][0] = fx; + co[1][1] = -fy; + co[2][0] = fx; + co[2][1] = fy; + co[3][0] = -fx; + co[3][1] = fy; + + for (ii=0;ii<4;ii++) { + r = mulscale14(cosang,co[ii][0]) - mulscale14(sinang,co[ii][1]); + s = mulscale14(sinang,co[ii][0]) + mulscale14(cosang,co[ii][1]); + co[ii][0] = r; + co[ii][1] = s; + } + drawlinepat = 0xcfcfcfcf; + for (ii=0;ii<4;ii++) + { + drawline16(halfxdim16 + xp1 + co[ii][0], midydim16 + yp1 - co[ii][1], + halfxdim16 + xp1 + co[(ii+1)&3][0], midydim16 + yp1 - co[(ii+1)&3][1], + col); + drawline16(halfxdim16 + xp1 + co[ii][0], midydim16 + yp1 - co[ii][1] + 1, + halfxdim16 + xp1 + co[(ii+1)&3][0], midydim16 + yp1 - co[(ii+1)&3][1] + 1, + col); + drawline16(halfxdim16 + xp1 + co[ii][0], midydim16 + yp1 - co[ii][1] - 1, + halfxdim16 + xp1 + co[(ii+1)&3][0], midydim16 + yp1 - co[(ii+1)&3][1] - 1, + col); + drawline16(halfxdim16 + xp1 + co[ii][0] + 1, midydim16 + yp1 - co[ii][1], + halfxdim16 + xp1 + co[(ii+1)&3][0] + 1, midydim16 + yp1 - co[(ii+1)&3][1], + col); + drawline16(halfxdim16 + xp1 + co[ii][0] - 1, midydim16 + yp1 - co[ii][1], + halfxdim16 + xp1 + co[(ii+1)&3][0] - 1, midydim16 + yp1 - co[(ii+1)&3][1], + col); + drawline16(halfxdim16 + xp1, midydim16 + yp1, + halfxdim16 + xp1 + co[(ii+1)&3][0], midydim16 + yp1 - co[(ii+1)&3][1], + col); + } + drawlinepat = 0xffffffff; + } + + else if ((sprite[j].cstat&16) > 0) + { + long fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); + xp2 = mulscale11(sintable[(sprite[j].ang+2560)&2047],zoome) / 6144; + yp2 = mulscale11(sintable[(sprite[j].ang+2048)&2047],zoome) / 6144; + + + if (((sprite[j].ang+256)&512) == 0) + { + if (!(sprite[j].cstat&64)) + { + drawline16(halfxdim16+xp1,midydim16+yp1-1,halfxdim16+xp1-xp2,midydim16+yp1-yp2-1,col); + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1-xp2,midydim16+yp1-yp2,col); + drawline16(halfxdim16+xp1,midydim16+yp1+1,halfxdim16+xp1-xp2,midydim16+yp1-yp2+1,col); + } + drawline16(halfxdim16+xp1,midydim16+yp1-1,halfxdim16+xp1+xp2,midydim16+yp1+yp2-1,col); + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1+xp2,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1,midydim16+yp1+1,halfxdim16+xp1+xp2,midydim16+yp1+yp2+1,col); + xp2 = mulscale10(sintable[(sprite[j].ang+1024)&2047],zoome) * fx / 32768; + yp2 = mulscale10(sintable[(sprite[j].ang+512)&2047],zoome) * fx / 32768; + drawline16(halfxdim16+xp1+1,midydim16+yp1,halfxdim16+xp1+xp2+1,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1-1,midydim16+yp1,halfxdim16+xp1-xp2-1,midydim16+yp1-yp2,col); + drawline16(halfxdim16+xp1-1,midydim16+yp1,halfxdim16+xp1+xp2-1,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1+1,midydim16+yp1,halfxdim16+xp1-xp2+1,midydim16+yp1-yp2,col); + + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1-xp2,midydim16+yp1-yp2,col); + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1+xp2,midydim16+yp1+yp2,col); + + drawline16(halfxdim16+xp1,midydim16+yp1-1,halfxdim16+xp1+xp2,midydim16+yp1+yp2-1,col); + drawline16(halfxdim16+xp1,midydim16+yp1+1,halfxdim16+xp1-xp2,midydim16+yp1-yp2+1,col); + drawline16(halfxdim16+xp1,midydim16+yp1+1,halfxdim16+xp1+xp2,midydim16+yp1+yp2+1,col); + drawline16(halfxdim16+xp1,midydim16+yp1-1,halfxdim16+xp1-xp2,midydim16+yp1-yp2-1,col); + } + else + { + if (!(sprite[j].cstat&64)) + { + drawline16(halfxdim16+xp1-1,midydim16+yp1,halfxdim16+xp1-xp2-1,midydim16+yp1-yp2,col); + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1-xp2,midydim16+yp1-yp2,col); + drawline16(halfxdim16+xp1+1,midydim16+yp1,halfxdim16+xp1-xp2+1,midydim16+yp1-yp2,col); + } + drawline16(halfxdim16+xp1-1,midydim16+yp1,halfxdim16+xp1+xp2-1,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1+xp2,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1+1,midydim16+yp1,halfxdim16+xp1+xp2+1,midydim16+yp1+yp2,col); + xp2 = mulscale10(sintable[(sprite[j].ang+1024)&2047],zoome) * fx / 32768; + yp2 = mulscale10(sintable[(sprite[j].ang+512)&2047],zoome) * fx / 32768; + drawline16(halfxdim16+xp1+1,midydim16+yp1,halfxdim16+xp1+xp2+1,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1-1,midydim16+yp1,halfxdim16+xp1-xp2-1,midydim16+yp1-yp2,col); + drawline16(halfxdim16+xp1-1,midydim16+yp1,halfxdim16+xp1+xp2-1,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1+1,midydim16+yp1,halfxdim16+xp1-xp2+1,midydim16+yp1-yp2,col); + + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1-xp2,midydim16+yp1-yp2,col); + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1+xp2,midydim16+yp1+yp2,col); + + drawline16(halfxdim16+xp1,midydim16+yp1-1,halfxdim16+xp1+xp2,midydim16+yp1+yp2-1,col); + drawline16(halfxdim16+xp1,midydim16+yp1+1,halfxdim16+xp1-xp2,midydim16+yp1-yp2+1,col); + drawline16(halfxdim16+xp1,midydim16+yp1+1,halfxdim16+xp1+xp2,midydim16+yp1+yp2+1,col); + drawline16(halfxdim16+xp1,midydim16+yp1-1,halfxdim16+xp1-xp2,midydim16+yp1-yp2-1,col); + } + + } + + col += 8; + } + + else if ((sprite[j].cstat&16) > 0) + { + long fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); + + xp2 = mulscale11(sintable[(sprite[j].ang+2560)&2047],zoome) / 6144; + yp2 = mulscale11(sintable[(sprite[j].ang+2048)&2047],zoome) / 6144; + + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1+xp2,midydim16+yp1+yp2,col); + if (!(sprite[j].cstat&64)) drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1-xp2,midydim16+yp1-yp2,col); + xp2 = mulscale10(sintable[(sprite[j].ang+1024)&2047],zoome) * fx / 32768; + yp2 = mulscale10(sintable[(sprite[j].ang+512)&2047],zoome) * fx / 32768; + + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1+xp2,midydim16+yp1+yp2,col); + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+xp1-xp2,midydim16+yp1-yp2,col); + + + col += 8; + } + + else if ((sprite[j].cstat&32) > 0) + { + long fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); + long fy = mulscale6(tilesizy[sprite[j].picnum], sprite[j].yrepeat); + long co[4][2], ii; + long sinang = sintable[(sprite[j].ang+512+1024)&2047]; + long cosang = sintable[(sprite[j].ang+1024)&2047]; + long r,s; + + fx = mulscale10(fx,zoome) >> 1; + fy = mulscale10(fy,zoome) >> 1; + + co[0][0] = -fx; + co[0][1] = -fy; + co[1][0] = fx; + co[1][1] = -fy; + co[2][0] = fx; + co[2][1] = fy; + co[3][0] = -fx; + co[3][1] = fy; + + for (ii=0;ii<4;ii++) { + r = mulscale14(cosang,co[ii][0]) - mulscale14(sinang,co[ii][1]); + s = mulscale14(sinang,co[ii][0]) + mulscale14(cosang,co[ii][1]); + co[ii][0] = r; + co[ii][1] = s; + } + + drawlinepat = 0xcfcfcfcf; + for (ii=0;ii<4;ii++) { + drawline16(halfxdim16 + xp1 + co[ii][0], midydim16 + yp1 - co[ii][1], + halfxdim16 + xp1 + co[(ii+1)&3][0], midydim16 + yp1 - co[(ii+1)&3][1], + col); + drawline16(halfxdim16 + xp1, midydim16 + yp1, + halfxdim16 + xp1 + co[(ii+1)&3][0], midydim16 + yp1 - co[(ii+1)&3][1], + col); + } + drawlinepat = 0xffffffff; + } + } + } + + faketimerhandler(); + xp1 = mulscale11(sintable[(ange+2560)&2047],zoome) / 768; //Draw white arrow + yp1 = mulscale11(sintable[(ange+2048)&2047],zoome) / 768; + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16-xp1,midydim16-yp1,15); + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16+yp1,midydim16-xp1,15); + drawline16(halfxdim16+xp1,midydim16+yp1,halfxdim16-yp1,midydim16+xp1,15); + + + enddrawing(); //}}} +} + + +// +// printext16 +// +void printext16(long xpos, long ypos, short col, short backcol, char *name, char fontsize) +{ + long stx, i, x, y, charxsiz; + char *fontptr, *letptr, *ptr; + + stx = xpos; + + if (fontsize) { fontptr = smalltextfont; charxsiz = 4; } + else { fontptr = textfont; charxsiz = 8; } + + begindrawing(); //{{{ + for(i=0;name[i];i++) + { + letptr = &fontptr[name[i]<<3]; + ptr = (char *)(bytesperline*(ypos+7)+(stx-fontsize)+frameplace); + for(y=7;y>=0;y--) + { + for(x=charxsiz-1;x>=0;x--) + { + if (letptr[y]&pow2char[7-fontsize-x]) + ptr[x] = (char)col; + else if (backcol >= 0) + ptr[x] = (char)backcol; + } + ptr -= bytesperline; + } + stx += charxsiz; + } + enddrawing(); //}}} +} + + +// +// printext256 +// +void printext256(long xpos, long ypos, short col, short backcol, char *name, char fontsize) +{ + long stx, i, x, y, charxsiz; + char *fontptr, *letptr, *ptr; + + stx = xpos; + + if (fontsize) { fontptr = smalltextfont; charxsiz = 4; } + else { fontptr = textfont; charxsiz = 8; } + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (!polymost_printext256(xpos,ypos,col,backcol,name,fontsize)) return; + + if (rendmode == 3) { + long xx, yy; + int lc=-1; + palette_t p,b; + + if (gammabrightness) { + p = curpalette[col]; + b = curpalette[backcol]; + } else { + p.r = britable[curbrightness][ curpalette[col].r ]; + p.g = britable[curbrightness][ curpalette[col].g ]; + p.b = britable[curbrightness][ curpalette[col].b ]; + b.r = britable[curbrightness][ curpalette[backcol].r ]; + b.g = britable[curbrightness][ curpalette[backcol].g ]; + b.b = britable[curbrightness][ curpalette[backcol].b ]; + } + + setpolymost2dview(); + bglDisable(GL_ALPHA_TEST); + bglDepthMask(GL_FALSE); // disable writing to the z-buffer + + bglBegin(GL_POINTS); + + for(i=0;name[i];i++) { + letptr = &fontptr[name[i]<<3]; + xx = stx-fontsize; + yy = ypos+7 + 2; //+1 is hack! + for(y=7;y>=0;y--) { + for(x=charxsiz-1;x>=0;x--) { + if (letptr[y]&pow2char[7-fontsize-x]) { + if (lc!=col) + bglColor4ub(p.r,p.g,p.b,255); + lc = col; + bglVertex2i(xx+x,yy); + } else if (backcol >= 0) { + if (lc!=backcol) + bglColor4ub(b.r,b.g,b.b,255); + lc = backcol; + bglVertex2i(xx+x,yy); + } + } + yy--; + } + stx += charxsiz; + } + + bglEnd(); + bglDepthMask(GL_TRUE); // re-enable writing to the z-buffer + + return; + } +#endif + + begindrawing(); //{{{ + for(i=0;name[i];i++) + { + letptr = &fontptr[name[i]<<3]; + ptr = (char *)(ylookup[ypos+7]+(stx-fontsize)+frameplace); + for(y=7;y>=0;y--) + { + for(x=charxsiz-1;x>=0;x--) + { + if (letptr[y]&pow2char[7-fontsize-x]) + ptr[x] = (char)col; + else if (backcol >= 0) + ptr[x] = (char)backcol; + } + ptr -= ylookup[1]; + } + stx += charxsiz; + } + enddrawing(); //}}} +} + + +// +// screencapture +// +long screencapture_tga(char *filename, char inverseit) +{ + long i,j; + char *ptr, head[18] = { 0,1,1,0,0,0,1,24,0,0,0,0,0/*wlo*/,0/*whi*/,0/*hlo*/,0/*hhi*/,8,0 }; + //char palette[4*256]; + char *fn = Bstrdup(filename), *inversebuf, c; + BFILE *fil; + + do { // JBF 2004022: So we don't overwrite existing screenshots + if (capturecount > 9999) return -1; + + i = Bstrrchr(fn,'.')-fn-4; + fn[i++] = ((capturecount/1000)%10)+48; + fn[i++] = ((capturecount/100)%10)+48; + fn[i++] = ((capturecount/10)%10)+48; + fn[i++] = (capturecount%10)+48; + i++; + fn[i++] = 't'; + fn[i++] = 'g'; + fn[i++] = 'a'; + + if ((fil = Bfopen(fn,"rb")) == NULL) break; + Bfclose(fil); + capturecount++; + } while (1); + fil = Bfopen(fn,"wb"); + if (fil == NULL) { + Bfree(fn); + return -1; + } + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode >= 3 && qsetmode == 200) { + head[1] = 0; // no colourmap + head[2] = 2; // uncompressed truecolour + head[3] = 0; // (low) first colourmap index + head[4] = 0; // (high) first colourmap index + head[5] = 0; // (low) number colourmap entries + head[6] = 0; // (high) number colourmap entries + head[7] = 0; // colourmap entry size + head[16] = 24; // 24 bits per pixel + } +#endif + + head[12] = xdim & 0xff; + head[13] = (xdim >> 8) & 0xff; + head[14] = ydim & 0xff; + head[15] = (ydim >> 8) & 0xff; + + Bfwrite(head, 18, 1, fil); + + begindrawing(); //{{{ + ptr = (char *)frameplace; + + // palette first +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode < 3 || (rendmode == 3 && qsetmode != 200)) { +#endif + //getpalette(0,256,palette); + for (i=0; i<256; i++) { + Bfputc(curpalettefaded[i].b, fil); // b + Bfputc(curpalettefaded[i].g, fil); // g + Bfputc(curpalettefaded[i].r, fil); // r + } +#if defined(POLYMOST) && defined(USE_OPENGL) + } +#endif + + // targa renders bottom to top, from left to right + if (inverseit && qsetmode != 200) { + inversebuf = (char *)kmalloc(bytesperline); + if (inversebuf) { + for (i=ydim-1; i>=0; i--) { + copybuf(ptr+i*bytesperline, inversebuf, xdim >> 2); + for (j=0; j < (bytesperline>>2); j++) ((long *)inversebuf)[j] ^= 0x0f0f0f0fL; + Bfwrite(inversebuf, xdim, 1, fil); + } + kfree(inversebuf); + } + } else { +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode >= 3 && qsetmode == 200) { + // 24bit + inversebuf = (char *)kmalloc(xdim*ydim*3); + if (inversebuf) { + bglReadPixels(0,0,xdim,ydim,GL_RGB,GL_UNSIGNED_BYTE,inversebuf); + j = xdim*ydim*3; + for (i=0; i=0; i--) + Bfwrite(ptr+i*bytesperline, xdim, 1, fil); +#if defined(POLYMOST) && defined(USE_OPENGL) + } +#endif + } + + enddrawing(); //}}} + + Bfclose(fil); + OSD_Printf("Saved screenshot to %s\n", fn); + Bfree(fn); + capturecount++; + return(0); +} + +// PCX is nasty, which is why I've lifted these functions from the PCX spec by ZSoft +static int writepcxbyte(char colour, unsigned char count, BFILE *fp) +{ + if (!count) return 0; + if (count == 1 && (colour & 0xc0) != 0xc0) { + Bfputc(colour, fp); + return 1; + } else { + Bfputc(0xc0 | count, fp); + Bfputc(colour, fp); + return 2; + } +} + +static void writepcxline(char *buf, long bytes, long step, BFILE *fp) +{ + char ths, last; + int srcIndex, i; + unsigned char runCount; + + runCount = 1; + last = *buf; + + for (srcIndex=1; srcIndex 9999) return -1; + + i = Bstrrchr(fn,'.')-fn-4; + fn[i++] = ((capturecount/1000)%10)+48; + fn[i++] = ((capturecount/100)%10)+48; + fn[i++] = ((capturecount/10)%10)+48; + fn[i++] = (capturecount%10)+48; + i++; + fn[i++] = 'p'; + fn[i++] = 'c'; + fn[i++] = 'x'; + + if ((fil = Bfopen(fn,"rb")) == NULL) break; + Bfclose(fil); + capturecount++; + } while (1); + fil = Bfopen(fn,"wb"); + if (fil == NULL) { + Bfree(fn); + return -1; + } + + memset(head,0,128); + head[0] = 10; + head[1] = 5; + head[2] = 1; + head[3] = 8; + head[12] = 72; head[13] = 0; + head[14] = 72; head[15] = 0; + head[65] = 1; // 8-bit + head[68] = 1; + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode >= 3 && qsetmode == 200) { + head[65] = 3; // 24-bit + } +#endif + + head[8] = (xdim-1) & 0xff; + head[9] = ((xdim-1) >> 8) & 0xff; + head[10] = (ydim-1) & 0xff; + head[11] = ((ydim-1) >> 8) & 0xff; + + bpl = xdim + (xdim&1); + + head[66] = bpl & 0xff; + head[67] = (bpl >> 8) & 0xff; + + Bfwrite(head, 128, 1, fil); + + begindrawing(); //{{{ + ptr = (char *)frameplace; + + // targa renders bottom to top, from left to right + if (inverseit && qsetmode != 200) { + inversebuf = (char *)kmalloc(bytesperline); + if (inversebuf) { + for (i=0; i> 2); + for (j=0; j < (bytesperline>>2); j++) ((long *)inversebuf)[j] ^= 0x0f0f0f0fL; + writepcxline(inversebuf, xdim, 1, fil); + } + kfree(inversebuf); + } + } else { +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode >= 3 && qsetmode == 200) { + // 24bit + inversebuf = (char *)kmalloc(xdim*ydim*3); + if (inversebuf) { + bglReadPixels(0,0,xdim,ydim,GL_RGB,GL_UNSIGNED_BYTE,inversebuf); + for (i=ydim-1; i>=0; i--) { + writepcxline(inversebuf+i*xdim*3, xdim, 3, fil); + writepcxline(inversebuf+i*xdim*3+1, xdim, 3, fil); + writepcxline(inversebuf+i*xdim*3+2, xdim, 3, fil); + } + kfree(inversebuf); + } + } else { +#endif + for (i=0; i 2) renderer = 2; + } else { + renderer = 3; + } + + rendmode = renderer; +#endif + + return 0; +} + +// +// getrendermode +// +int getrendermode(void) +{ +#ifndef POLYMOST + return 0; +#else + return rendmode; +#endif +} + + +// +// setrollangle +// +void setrollangle(long rolla) +{ +#ifdef POLYMOST + if (rolla == 0) gtang = 0.0; + else gtang = PI * (double)rolla / 1024.0; +#endif +} + + +// +// invalidatetile +// pal: pass -1 to invalidate all palettes for the tile, or >=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: ignored (33% translucence, using repeating) +// bit 3: ignored (67% translucence, using repeating) +// bit 4: opaque or masked (non-translucent) texture, using clamping +// bit 5: ignored +// bit 6: ignored (33% translucence, using clamping) +// bit 7: ignored (67% translucence, using clamping) +// clamping is for sprites, repeating is for walls +// +void invalidatetile(short tilenume, long pal, long how) +{ +#if defined(POLYMOST) && defined(USE_OPENGL) + int numpal, firstpal, np; + int hp; + + if (rendmode < 3) return; + + if (pal < 0) { + numpal = MAXPALOOKUPS; + firstpal = 0; + } else { + numpal = 1; + firstpal = pal % MAXPALOOKUPS; + } + + for (hp = 0; hp < 8; hp+=4) { + if (!(how & pow2long[hp])) continue; + + for (np = firstpal; np < firstpal+numpal; np++) { + gltexinvalidate(tilenume, np, hp); + } + } +#endif +} + + +// +// setpolymost2dview +// Sets OpenGL for 2D drawing +// +void setpolymost2dview(void) +{ +#if defined(POLYMOST) && defined(USE_OPENGL) + if (rendmode < 3) return; + + if (gloy1 != -1) { + bglViewport(0,0,xres,yres); + bglMatrixMode(GL_PROJECTION); + bglLoadIdentity(); + bglOrtho(0,xres,yres,0,-1,1); + bglMatrixMode(GL_MODELVIEW); + bglLoadIdentity(); + } + + gloy1 = -1; + + bglDisable(GL_DEPTH_TEST); + bglDisable(GL_TEXTURE_2D); + bglDisable(GL_BLEND); +#endif +} + + +/* + * vim:ts=8: + */ + diff --git a/polymer/build/src/game.c b/polymer/build/src/game.c new file mode 100644 index 000000000..2c86eacb8 --- /dev/null +++ b/polymer/build/src/game.c @@ -0,0 +1,6297 @@ +// 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) + +#include "compat.h" +#include "build.h" +#include "names.h" +#include "pragmas.h" +#include "cache1d.h" +#include "game.h" +#include "osd.h" +#include "mmulti.h" + +#include "baselayer.h" + +#define TIMERINTSPERSECOND 140 //280 +#define MOVESPERSECOND 40 +#define TICSPERFRAME 3 +#define MOVEFIFOSIZ 256 +#define EYEHEIGHT (32<<8) //Normally (32<<8), (51<<8) to make mirrors happy + +// declared in sound.c +void initsb(char,char,long,char,char,char,char); +void uninitsb(void); +void setears(long,long,long,long); +void wsayfollow(char *,long,long,long *,long *,char); +void wsay(char *,long,long,long); +void loadwaves(void); +void loadsong(char *); +void musicon(void); +void musicoff(void); +void refreshaudio(void); + +// declared in config.c +int loadsetup(const char *); +int writesetup(const char *); + + +/*************************************************************************** + KEN'S TAG DEFINITIONS: (Please define your own tags for your games) + + sector[?].lotag = 0 Normal sector + sector[?].lotag = 1 If you are on a sector with this tag, then all sectors + with same hi tag as this are operated. Once. + sector[?].lotag = 2 Same as sector[?].tag = 1 but this is retriggable. + sector[?].lotag = 3 A really stupid sector that really does nothing now. + sector[?].lotag = 4 A sector where you are put closer to the floor + (such as the slime in DOOM1.DAT) + sector[?].lotag = 5 A really stupid sector that really does nothing now. + sector[?].lotag = 6 A normal door - instead of pressing D, you tag the + sector with a 6. The reason I make you edit doors + this way is so that can program the doors + yourself. + sector[?].lotag = 7 A door the goes down to open. + sector[?].lotag = 8 A door that opens horizontally in the middle. + sector[?].lotag = 9 A sliding door that opens vertically in the middle. + -Example of the advantages of not using BSP tree. + sector[?].lotag = 10 A warping sector with floor and walls that shade. + sector[?].lotag = 11 A sector with all walls that do X-panning. + sector[?].lotag = 12 A sector with walls using the dragging function. + sector[?].lotag = 13 A sector with some swinging doors in it. + sector[?].lotag = 14 A revolving door sector. + sector[?].lotag = 15 A subway track. + sector[?].lotag = 16 A true double-sliding door. + + wall[?].lotag = 0 Normal wall + wall[?].lotag = 1 Y-panning wall + wall[?].lotag = 2 Switch - If you flip it, then all sectors with same hi + tag as this are operated. + wall[?].lotag = 3 Marked wall to detemine starting dir. (sector tag 12) + wall[?].lotag = 4 Mark on the shorter wall closest to the pivot point + of a swinging door. (sector tag 13) + wall[?].lotag = 5 Mark where a subway should stop. (sector tag 15) + wall[?].lotag = 6 Mark for true double-sliding doors (sector tag 16) + wall[?].lotag = 7 Water fountain + wall[?].lotag = 8 Bouncy wall! + + sprite[?].lotag = 0 Normal sprite + sprite[?].lotag = 1 If you press space bar on an AL, and the AL is tagged + with a 1, he will turn evil. + sprite[?].lotag = 2 When this sprite is operated, a bomb is shot at its + position. + sprite[?].lotag = 3 Rotating sprite. + sprite[?].lotag = 4 Sprite switch. + sprite[?].lotag = 5 Basketball hoop score. + +KEN'S STATUS DEFINITIONS: (Please define your own statuses for your games) + status = 0 Inactive sprite + status = 1 Active monster sprite + status = 2 Monster that becomes active only when it sees you + status = 3 Smoke on the wall for chainguns + status = 4 Splashing sprites (When you shoot slime) + status = 5 Explosion! + status = 6 Travelling bullet + status = 7 Bomb sprial-out explosion + status = 8 Player! + status = 9 EVILALGRAVE shrinking list + status = 10 EVILAL list + status = 11 Sprite respawning list + status = 12 Sprite which does not respawn (Andy's addition) + status = MAXSTATUS Non-existent sprite (this will be true for your + code also) +**************************************************************************/ + +typedef struct +{ + long x, y, z; +} point3d; + +typedef struct +{ + signed char fvel, svel, avel; + short bits; +} input; + +static long screentilt = 0, oscreentilt = 0; + + +static long fvel, svel, avel; +static long fvel2, svel2, avel2; + +#define NUMOPTIONS 8 +#define NUMKEYS 19 +char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0}; +char keys[NUMKEYS] = +{ + 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, + 0x1e,0x2c,0xd1,0xc9,0x33,0x34, + 0x9c,0x1c,0xd,0xc,0xf +}; +long xdimgame = 320, ydimgame = 200, bppgame = 8, xdim2d = 640, ydim2d = 480; // JBF 20050318: config.c expects to find these + +static long digihz[8] = {6000,8000,11025,16000,22050,32000,44100,48000}; + +static char frame2draw[MAXPLAYERS]; +static long frameskipcnt[MAXPLAYERS]; + +#define LAVASIZ 128 +#define LAVALOGSIZ 7 +#define LAVAMAXDROPS 32 +static char lavabakpic[(LAVASIZ+4)*(LAVASIZ+4)], lavainc[LAVASIZ]; +static long lavanumdrops, lavanumframes; +static long lavadropx[LAVAMAXDROPS], lavadropy[LAVAMAXDROPS]; +static long lavadropsiz[LAVAMAXDROPS], lavadropsizlookup[LAVAMAXDROPS]; +static long lavaradx[24][96], lavarady[24][96], lavaradcnt[32]; + + //Shared player variables +static long posx[MAXPLAYERS], posy[MAXPLAYERS], posz[MAXPLAYERS]; +static long horiz[MAXPLAYERS], zoom[MAXPLAYERS], hvel[MAXPLAYERS]; +static short ang[MAXPLAYERS], cursectnum[MAXPLAYERS], ocursectnum[MAXPLAYERS]; +static short playersprite[MAXPLAYERS], deaths[MAXPLAYERS]; +static long lastchaingun[MAXPLAYERS]; +static long health[MAXPLAYERS], flytime[MAXPLAYERS]; +static short oflags[MAXPLAYERS]; +static short numbombs[MAXPLAYERS]; +static short numgrabbers[MAXPLAYERS]; // Andy did this +static short nummissiles[MAXPLAYERS]; // Andy did this +static char dimensionmode[MAXPLAYERS]; +static char revolvedoorstat[MAXPLAYERS]; +static short revolvedoorang[MAXPLAYERS], revolvedoorrotang[MAXPLAYERS]; +static long revolvedoorx[MAXPLAYERS], revolvedoory[MAXPLAYERS]; + + //ENGINE CONTROLLED MULTIPLAYER VARIABLES: +extern long numplayers, myconnectindex; +extern long connecthead, connectpoint2[MAXPLAYERS]; //Player linked list variables (indeces, not connection numbers) + +static long nummoves; +// Bug: NUMSTATS used to be equal to the greatest tag number, +// so that the last statrate[] entry was random memory junk +// because stats 0-NUMSTATS required NUMSTATS+1 bytes. -Andy +#define NUMSTATS 13 +static signed char statrate[NUMSTATS] = {-1,0,-1,0,0,0,1,3,0,3,15,-1,-1}; + + //Input structures +static char networkmode; //0 is 2(n-1) mode, 1 is n(n-1) mode +static long locselectedgun, locselectedgun2; +static input loc, oloc, loc2; +static input ffsync[MAXPLAYERS], osync[MAXPLAYERS], ssync[MAXPLAYERS]; + //Input faketimerhandler -> movethings fifo +static long movefifoplc, movefifoend[MAXPLAYERS]; +static input baksync[MOVEFIFOSIZ][MAXPLAYERS]; + //Game recording variables +static long reccnt, recstat = 1; +static input recsync[16384][2]; + +//static long myminlag[MAXPLAYERS], mymaxlag, otherminlag, bufferjitter = 1; +static signed char otherlag[MAXPLAYERS] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; +static long averagelag[MAXPLAYERS] = {512,512,512,512,512,512,512,512,512,512,512,512,512,512,512,512}; + +static long fakemovefifoplc; +static long myx, myy, myz, omyx, omyy, omyz, myzvel; +static long myhoriz, omyhoriz; +static short myang, omyang, mycursectnum; +static long myxbak[MOVEFIFOSIZ], myybak[MOVEFIFOSIZ], myzbak[MOVEFIFOSIZ]; +static long myhorizbak[MOVEFIFOSIZ]; +static short myangbak[MOVEFIFOSIZ]; + + //MULTI.OBJ sync state variables +extern char syncstate; + //GAME.C sync state variables +static char syncstat, syncval[MOVEFIFOSIZ], othersyncval[MOVEFIFOSIZ]; +static long syncvaltottail, syncvalhead, othersyncvalhead, syncvaltail; + +static char detailmode = 0, ready2send = 0; +static long ototalclock = 0, gotlastpacketclock = 0, smoothratio; +static long oposx[MAXPLAYERS], oposy[MAXPLAYERS], oposz[MAXPLAYERS]; +static long ohoriz[MAXPLAYERS], ozoom[MAXPLAYERS]; +static short oang[MAXPLAYERS]; + +static point3d osprite[MAXSPRITES]; + +#define MAXINTERPOLATIONS 1024 +static long numinterpolations = 0, startofdynamicinterpolations = 0; +static long oldipos[MAXINTERPOLATIONS]; +static long bakipos[MAXINTERPOLATIONS]; +static long *curipos[MAXINTERPOLATIONS]; + +extern long cachecount; + +static char playerreadyflag[MAXPLAYERS]; + + //Miscellaneous variables +static char packbuf[MAXXDIM]; +static char tempbuf[MAXXDIM], boardfilename[80]; +static short tempshort[MAXSECTORS]; +static short screenpeek = 0, oldmousebstatus = 0; +short brightness = 0; +static short screensize, screensizeflag = 0; +static short neartagsector, neartagwall, neartagsprite; +static long lockclock, neartagdist, neartaghitdist; +extern long pageoffset, ydim16; +static long globhiz, globloz, globhihit, globlohit; + + //Over the shoulder mode variables +static long cameradist = -1, cameraang = 0, cameraclock = 0; + + //Board animation variables +#define MAXMIRRORS 64 +static short mirrorwall[MAXMIRRORS], mirrorsector[MAXMIRRORS], mirrorcnt; +static short floormirrorsector[64], floormirrorcnt; +static short turnspritelist[16], turnspritecnt; +static short warpsectorlist[64], warpsectorcnt; +static short xpanningsectorlist[16], xpanningsectorcnt; +static short ypanningwalllist[64], ypanningwallcnt; +static short floorpanninglist[64], floorpanningcnt; +static short dragsectorlist[16], dragxdir[16], dragydir[16], dragsectorcnt; +static long dragx1[16], dragy1[16], dragx2[16], dragy2[16], dragfloorz[16]; +static short swingcnt, swingwall[32][5], swingsector[32]; +static short swingangopen[32], swingangclosed[32], swingangopendir[32]; +static short swingang[32], swinganginc[32]; +static long swingx[32][8], swingy[32][8]; +static short revolvesector[4], revolveang[4], revolvecnt; +static long revolvex[4][16], revolvey[4][16]; +static long revolvepivotx[4], revolvepivoty[4]; +static short subwaytracksector[4][128], subwaynumsectors[4], subwaytrackcnt; +static long subwaystop[4][8], subwaystopcnt[4]; +static long subwaytrackx1[4], subwaytracky1[4]; +static long subwaytrackx2[4], subwaytracky2[4]; +static long subwayx[4], subwaygoalstop[4], subwayvel[4], subwaypausetime[4]; +static short waterfountainwall[MAXPLAYERS], waterfountaincnt[MAXPLAYERS]; +static short slimesoundcnt[MAXPLAYERS]; + + //Variables that let you type messages to other player +static char getmessage[162], getmessageleng; +static long getmessagetimeoff; +static char typemessage[162], typemessageleng = 0, typemode = 0; +/* +static char scantoasc[128] = +{ + 0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0, + 'q','w','e','r','t','y','u','i','o','p','[',']',0,0,'a','s', + 'd','f','g','h','j','k','l',';',39,'`',0,92,'z','x','c','v', + 'b','n','m',',','.','/',0,'*',0,32,0,0,0,0,0,0, + 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1', + '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; +static char scantoascwithshift[128] = +{ + 0,0,'!','@','#','$','%','^','&','*','(',')','_','+',0,0, + 'Q','W','E','R','T','Y','U','I','O','P','{','}',0,0,'A','S', + 'D','F','G','H','J','K','L',':',34,'~',0,'|','Z','X','C','V', + 'B','N','M','<','>','?',0,'*',0,32,0,0,0,0,0,0, + 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1', + '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; +*/ + + //These variables are for animating x, y, or z-coordinates of sectors, + //walls, or sprites (They are NOT to be used for changing the [].picnum's) + //See the setanimation(), and getanimategoal() functions for more details. +#define MAXANIMATES 512 +static long *animateptr[MAXANIMATES], animategoal[MAXANIMATES]; +static long animatevel[MAXANIMATES], animateacc[MAXANIMATES], animatecnt = 0; + +#if defined(POLYMOST) && defined(USE_OPENGL) + //These parameters are in exact order of sprite structure in BUILD.H +#define spawnsprite(newspriteindex2,x2,y2,z2,cstat2,shade2,pal2, \ + clipdist2,xrepeat2,yrepeat2,xoffset2,yoffset2,picnum2,ang2, \ + xvel2,yvel2,zvel2,owner2,sectnum2,statnum2,lotag2,hitag2,extra2) \ +{ \ + spritetype *spr2; \ + newspriteindex2 = insertsprite(sectnum2,statnum2); \ + spr2 = &sprite[newspriteindex2]; \ + spr2->x = x2; spr2->y = y2; spr2->z = z2; \ + spr2->cstat = cstat2; spr2->shade = shade2; \ + spr2->pal = pal2; spr2->clipdist = clipdist2; \ + spr2->xrepeat = xrepeat2; spr2->yrepeat = yrepeat2; \ + spr2->xoffset = xoffset2; spr2->yoffset = yoffset2; \ + spr2->picnum = picnum2; spr2->ang = ang2; \ + spr2->xvel = xvel2; spr2->yvel = yvel2; spr2->zvel = zvel2; \ + spr2->owner = owner2; \ + spr2->lotag = lotag2; spr2->hitag = hitag2; spr2->extra = extra2; \ + copybuf(&spr2->x,&osprite[newspriteindex2].x,3); \ + show2dsprite[newspriteindex2>>3] &= ~(1<<(newspriteindex2&7)); \ + if (show2dsector[sectnum2>>3]&(1<<(sectnum2&7))) \ + show2dsprite[newspriteindex2>>3] |= (1<<(newspriteindex2&7)); \ + clearbufbyte(&spriteext[newspriteindex2], sizeof(spriteexttype), 0); \ +} +#else +#define spawnsprite(newspriteindex2,x2,y2,z2,cstat2,shade2,pal2, \ + clipdist2,xrepeat2,yrepeat2,xoffset2,yoffset2,picnum2,ang2, \ + xvel2,yvel2,zvel2,owner2,sectnum2,statnum2,lotag2,hitag2,extra2) \ +{ \ + spritetype *spr2; \ + newspriteindex2 = insertsprite(sectnum2,statnum2); \ + spr2 = &sprite[newspriteindex2]; \ + spr2->x = x2; spr2->y = y2; spr2->z = z2; \ + spr2->cstat = cstat2; spr2->shade = shade2; \ + spr2->pal = pal2; spr2->clipdist = clipdist2; \ + spr2->xrepeat = xrepeat2; spr2->yrepeat = yrepeat2; \ + spr2->xoffset = xoffset2; spr2->yoffset = yoffset2; \ + spr2->picnum = picnum2; spr2->ang = ang2; \ + spr2->xvel = xvel2; spr2->yvel = yvel2; spr2->zvel = zvel2; \ + spr2->owner = owner2; \ + spr2->lotag = lotag2; spr2->hitag = hitag2; spr2->extra = extra2; \ + copybuf(&spr2->x,&osprite[newspriteindex2].x,3); \ + show2dsprite[newspriteindex2>>3] &= ~(1<<(newspriteindex2&7)); \ + if (show2dsector[sectnum2>>3]&(1<<(sectnum2&7))) \ + show2dsprite[newspriteindex2>>3] |= (1<<(newspriteindex2&7)); \ +} +#endif + +int nextvoxid = 0; + +static int osdcmd_restartvid(const osdfuncparm_t *parm) +{ + resetvideomode(); + if (setgamemode(fullscreen,xdim,ydim,bpp)) + OSD_Printf("restartvid: Reset failed...\n"); + + return OSDCMD_OK; +} + +static int osdcmd_vidmode(const osdfuncparm_t *parm) +{ + long newx = xdim, newy = ydim, newbpp = bpp, newfullscreen = fullscreen; + + if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP; + + switch (parm->numparms) { + case 1: // bpp switch + newbpp = Batol(parm->parms[0]); + break; + case 2: // res switch + newx = Batol(parm->parms[0]); + newy = Batol(parm->parms[1]); + break; + case 3: // res & bpp switch + case 4: + newx = Batol(parm->parms[0]); + newy = Batol(parm->parms[1]); + newbpp = Batol(parm->parms[2]); + if (parm->numparms == 4) + newfullscreen = (Batol(parm->parms[3]) != 0); + break; + } + + if (setgamemode(newfullscreen,newx,newy,newbpp)) + OSD_Printf("vidmode: Mode change failed!\n"); + screensize = xdim+1; + return OSDCMD_OK; +} + +#ifdef RENDERTYPEWIN +int DoLaunchWindow(void); // gamestartwin.c +#endif + +char *startwin_labeltext = "Starting KenBuild..."; + +long app_main(long argc, char *argv[]) +{ + long i, j, k, l, fil, waitplayers, x1, y1, x2, y2; + long other, packleng, netparm; + +#ifdef USE_OPENGL + OSD_RegisterFunction("restartvid","restartvid: reinitialise the video mode",osdcmd_restartvid); + OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: immediately change the video mode",osdcmd_vidmode); +#endif + + wm_setapptitle("KenBuild by Ken Silverman"); + + Bstrcpy(boardfilename, "nukeland.map"); + j = 0; netparm = argc; + for (i=1;i= 2); + + pskyoff[0] = 0; pskyoff[1] = 0; pskybits = 1; + + loadpics("tiles000.art",1048576); //Load artwork +#ifdef SUPERBUILD + if (!qloadkvx(nextvoxid,"voxel000.kvx")) + tiletovox[PLAYER] = nextvoxid++; + if (!qloadkvx(nextvoxid,"voxel001.kvx")) + tiletovox[BROWNMONSTER] = nextvoxid++; +#endif + if (!loaddefinitionsfile("kenbuild.def")) initprintf("Definitions file loaded.\n"); + + //Here's an example of TRUE ornamented walls + //The allocatepermanenttile should be called right after loadpics + //Since it resets the tile cache for each call. + if (allocatepermanenttile(SLIME,128,128) == 0) //If enough memory + { + printf("Not enough memory for slime!\n"); + exit(0); + } + if (allocatepermanenttile(MAXTILES-1,64,64) != 0) //If enough memory + { + //My face with an explosion written over it + copytilepiece(KENPICTURE,0,0,64,64,MAXTILES-1,0,0); + copytilepiece(EXPLOSION,0,0,64,64,MAXTILES-1,0,0); + } + + initlava(); + + for(j=0;j<256;j++) + tempbuf[j] = ((j+32)&255); //remap colors for screwy palette sectors + makepalookup(16,tempbuf,0,0,0,1); + + for(j=0;j<256;j++) tempbuf[j] = j; + makepalookup(17,tempbuf,24,24,24,1); + + for(j=0;j<256;j++) tempbuf[j] = j; //(j&31)+32; + makepalookup(18,tempbuf,8,8,48,1); + + prepareboard(boardfilename); //Load board + + initsb(option[1],option[2],digihz[option[7]>>4],((option[7]&4)>0)+1,((option[7]&2)>0)+1,60,option[7]&1); + //if (Bstrcmp(boardfilename,"klab.map") == 0) + // loadsong("klabsong.kdm"); + //else + loadsong("neatsong.ogg"); + musicon(); + + /* + if (option[4] > 0) + { + x1 = ((xdim-screensize)>>1); + x2 = x1+screensize-1; + y1 = (((ydim-32)-scale(screensize,ydim-32,xdim))>>1); + y2 = y1 + scale(screensize,ydim-32,xdim)-1; + + drawtilebackground(0L,0L,BACKGROUND,8,x1,y1,x2,y2,0); + + sendlogon(); + + if (option[4] < 5) waitplayers = 2; else waitplayers = option[4]-3; + while (numplayers < waitplayers) + { + sprintf(tempbuf,"%ld of %ld players in...",numplayers,waitplayers); + printext256(68L,84L,31,0,tempbuf,0); + nextpage(); + + if (getpacket(&other,packbuf) > 0) + if (packbuf[0] == 255) + keystatus[1] = 1; + + if (handleevents()) { + if (quitevent) { + keystatus[1] = 1; + quitevent = 0; + } + } + + if (keystatus[1]) + { + sendlogoff(); //Signing off + musicoff(); + uninitmultiplayers(); + uninittimer(); + uninitinput(); + uninitengine(); + uninitsb(); + uninitgroupfile(); + exit(0); + } + } + screenpeek = myconnectindex; + + if (numplayers <= 3) + networkmode = 1; + else + networkmode = 0; + + j = 1; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (myconnectindex == i) break; + j++; + } + sprintf(getmessage,"Player %ld",j); + if (networkmode == 0) + { + if (j == 1) Bstrcat(getmessage," (Master)"); + else Bstrcat(getmessage," (Slave)"); + } else + Bstrcat(getmessage," (Even)"); + getmessageleng = Bstrlen(getmessage); + getmessagetimeoff = totalclock+120; + } + */ + screenpeek = myconnectindex; + reccnt = 0; + for(i=connecthead;i>=0;i=connectpoint2[i]) initplayersprite((short)i); + + waitforeverybody(); + totalclock = ototalclock = 0; gotlastpacketclock = 0; nummoves = 0; + + ready2send = 1; + drawscreen(screenpeek,65536L); + + while (!keystatus[1]) //Main loop starts here + { + if (handleevents()) { + if (quitevent) { + keystatus[1] = 1; + quitevent = 0; + } + } + + refreshaudio(); + OSD_DispatchQueued(); + + // backslash (useful only with KDM) +// if (keystatus[0x2b]) { keystatus[0x2b] = 0; preparesndbuf(); } + + if ((networkmode == 1) || (myconnectindex != connecthead)) + while (fakemovefifoplc != movefifoend[myconnectindex]) fakedomovethings(); + + getpackets(); + + if (typemode == 0) //if normal game keys active + { + if ((keystatus[0x2a]&keystatus[0x36]&keystatus[0x13]) > 0) //Sh.Sh.R (replay) + { + keystatus[0x13] = 0; + playback(); + } + + if (keystatus[0x26]&(keystatus[0x1d]|keystatus[0x9d])) //Load game + { + keystatus[0x26] = 0; + loadgame(); + drawstatusbar(screenpeek); // Andy did this + } + + if (keystatus[0x1f]&(keystatus[0x1d]|keystatus[0x9d])) //Save game + { + keystatus[0x1f] = 0; + savegame(); + } + } + + if ((networkmode == 0) || (option[4] == 0)) + { + while (movefifoplc != movefifoend[0]) domovethings(); + } + else + { + j = connecthead; + if (j == myconnectindex) j = connectpoint2[j]; + averagelag[j] = ((averagelag[j]*7+(((movefifoend[myconnectindex]-movefifoend[j]+otherlag[j]+2)&255)<<8))>>3); + j = max(averagelag[j]>>9,1); + while (((movefifoend[myconnectindex]-movefifoplc)&(MOVEFIFOSIZ-1)) > j) + { + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (movefifoplc == movefifoend[i]) break; + if (i >= 0) break; + if (myconnectindex != connecthead) + { + k = ((movefifoend[myconnectindex]-movefifoend[connecthead]-otherlag[connecthead]+128)&255); + if (k > 128+1) ototalclock++; + if (k < 128-1) ototalclock--; + } + domovethings(); + } + } + i = (totalclock-gotlastpacketclock)*(65536/(TIMERINTSPERSECOND/MOVESPERSECOND)); + + drawscreen(screenpeek,i); + } + + sendlogoff(); //Signing off + musicoff(); + uninitmultiplayers(); + uninittimer(); + uninitinput(); + uninitengine(); + uninitsb(); + uninitgroupfile(); + + return(0); +} + +void operatesector(short dasector) +{ //Door code + long i, j, k, s, nexti, good, cnt, datag; + long dax, day, daz, dax2, day2, daz2, centx, centy; + short startwall, endwall, wallfind[2]; + + datag = sector[dasector].lotag; + + startwall = sector[dasector].wallptr; + endwall = startwall + sector[dasector].wallnum; + centx = 0L, centy = 0L; + for(i=startwall;i= 0) //If door already moving, reverse its direction + { + if (datag == 8) + daz = ((sector[dasector].ceilingz+sector[dasector].floorz)>>1); + else + daz = sector[dasector].floorz; + + if (animategoal[i] == daz) + animategoal[i] = sector[nextsectorneighborz(dasector,sector[dasector].floorz,-1,-1)].ceilingz; + else + animategoal[i] = daz; + animatevel[i] = 0; + } + else //else insert the door's ceiling on the animation list + { + if (sector[dasector].ceilingz == sector[dasector].floorz) + daz = sector[nextsectorneighborz(dasector,sector[dasector].floorz,-1,-1)].ceilingz; + else + { + if (datag == 8) + daz = ((sector[dasector].ceilingz+sector[dasector].floorz)>>1); + else + daz = sector[dasector].floorz; + } + if ((j = setanimation(§or[dasector].ceilingz,daz,6L,6L)) >= 0) + wsayfollow("updowndr.wav",4096L+(krand()&255)-128,256L,¢x,¢y,0); + } + } + //Simple door that moves down + if ((datag == 7) || (datag == 8)) //If the sector in front's elevator + { + i = getanimationgoal((long)§or[dasector].floorz); + if (i >= 0) //If elevator already moving, reverse its direction + { + if (datag == 8) + daz = ((sector[dasector].ceilingz+sector[dasector].floorz)>>1); + else + daz = sector[dasector].ceilingz; + + if (animategoal[i] == daz) + animategoal[i] = sector[nextsectorneighborz(dasector,sector[dasector].ceilingz,1,1)].floorz; + else + animategoal[i] = daz; + animatevel[i] = 0; + } + else //else insert the elevator's ceiling on the animation list + { + if (sector[dasector].floorz == sector[dasector].ceilingz) + daz = sector[nextsectorneighborz(dasector,sector[dasector].ceilingz,1,1)].floorz; + else + { + if (datag == 8) + daz = ((sector[dasector].ceilingz+sector[dasector].floorz)>>1); + else + daz = sector[dasector].ceilingz; + } + if ((j = setanimation(§or[dasector].floorz,daz,6L,6L)) >= 0) + wsayfollow("updowndr.wav",4096L+(krand()&255)-128,256L,¢x,¢y,0); + } + } + + if (datag == 9) //Smooshy-wall sideways double-door + { + //find any points with either same x or same y coordinate + // as center (centx, centy) - should be 2 points found. + wallfind[0] = -1; + wallfind[1] = -1; + for(i=startwall;i>1)-wall[wallfind[j]].x; + day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; + if (dax2 != 0) + { + dax2 = wall[wall[wall[wallfind[j]].point2].point2].x; + dax2 -= wall[wall[wallfind[j]].point2].x; + setanimation(&wall[wallfind[j]].x,wall[wallfind[j]].x+dax2,4L,0L); + setanimation(&wall[i].x,wall[i].x+dax2,4L,0L); + setanimation(&wall[wall[wallfind[j]].point2].x,wall[wall[wallfind[j]].point2].x+dax2,4L,0L); + } + else if (day2 != 0) + { + day2 = wall[wall[wall[wallfind[j]].point2].point2].y; + day2 -= wall[wall[wallfind[j]].point2].y; + setanimation(&wall[wallfind[j]].y,wall[wallfind[j]].y+day2,4L,0L); + setanimation(&wall[i].y,wall[i].y+day2,4L,0L); + setanimation(&wall[wall[wallfind[j]].point2].y,wall[wall[wallfind[j]].point2].y+day2,4L,0L); + } + } + else + { + i = wallfind[j]-1; if (i < startwall) i = endwall-1; + dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x; + day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; + if (dax2 != 0) + { + setanimation(&wall[wallfind[j]].x,centx,4L,0L); + setanimation(&wall[i].x,centx+dax2,4L,0L); + setanimation(&wall[wall[wallfind[j]].point2].x,centx+dax2,4L,0L); + } + else if (day2 != 0) + { + setanimation(&wall[wallfind[j]].y,centy,4L,0L); + setanimation(&wall[i].y,centy+day2,4L,0L); + setanimation(&wall[wall[wallfind[j]].point2].y,centy+day2,4L,0L); + } + } + } + wsayfollow("updowndr.wav",4096L-256L,256L,¢x,¢y,0); + wsayfollow("updowndr.wav",4096L+256L,256L,¢x,¢y,0); + } + + if (datag == 13) //Swinging door + { + for(i=0;i>1) == centx) && (((wall[wallfind[j]].y+wall[wall[wallfind[j]].point2].y)>>1) == centy)) + { //door was closed + //find what direction door should open + i = wallfind[j]-1; if (i < startwall) i = endwall-1; + dax2 = wall[i].x-wall[wallfind[j]].x; + day2 = wall[i].y-wall[wallfind[j]].y; + if (dax2 != 0) + { + dax2 = wall[wall[wall[wall[wallfind[j]].point2].point2].point2].x; + dax2 -= wall[wall[wall[wallfind[j]].point2].point2].x; + setanimation(&wall[wallfind[j]].x,wall[wallfind[j]].x+dax2,4L,0L); + setanimation(&wall[i].x,wall[i].x+dax2,4L,0L); + setanimation(&wall[wall[wallfind[j]].point2].x,wall[wall[wallfind[j]].point2].x+dax2,4L,0L); + setanimation(&wall[wall[wall[wallfind[j]].point2].point2].x,wall[wall[wall[wallfind[j]].point2].point2].x+dax2,4L,0L); + } + else if (day2 != 0) + { + day2 = wall[wall[wall[wall[wallfind[j]].point2].point2].point2].y; + day2 -= wall[wall[wall[wallfind[j]].point2].point2].y; + setanimation(&wall[wallfind[j]].y,wall[wallfind[j]].y+day2,4L,0L); + setanimation(&wall[i].y,wall[i].y+day2,4L,0L); + setanimation(&wall[wall[wallfind[j]].point2].y,wall[wall[wallfind[j]].point2].y+day2,4L,0L); + setanimation(&wall[wall[wall[wallfind[j]].point2].point2].y,wall[wall[wall[wallfind[j]].point2].point2].y+day2,4L,0L); + } + } + else + { //door was not closed + i = wallfind[j]-1; if (i < startwall) i = endwall-1; + dax2 = wall[i].x-wall[wallfind[j]].x; + day2 = wall[i].y-wall[wallfind[j]].y; + if (dax2 != 0) + { + setanimation(&wall[wallfind[j]].x,centx,4L,0L); + setanimation(&wall[i].x,centx+dax2,4L,0L); + setanimation(&wall[wall[wallfind[j]].point2].x,centx,4L,0L); + setanimation(&wall[wall[wall[wallfind[j]].point2].point2].x,centx+dax2,4L,0L); + } + else if (day2 != 0) + { + setanimation(&wall[wallfind[j]].y,centy,4L,0L); + setanimation(&wall[i].y,centy+day2,4L,0L); + setanimation(&wall[wall[wallfind[j]].point2].y,centy,4L,0L); + setanimation(&wall[wall[wall[wallfind[j]].point2].point2].y,centy+day2,4L,0L); + } + } + } + wsayfollow("updowndr.wav",4096L-64L,256L,¢x,¢y,0); + wsayfollow("updowndr.wav",4096L+64L,256L,¢x,¢y,0); + } +} + +void operatesprite(short dasprite) +{ + long datag; + + datag = sprite[dasprite].lotag; + + if (datag == 2) //A sprite that shoots a bomb + { + shootgun(dasprite, + sprite[dasprite].x,sprite[dasprite].y,sprite[dasprite].z, + sprite[dasprite].ang,100L,sprite[dasprite].sectnum,2); + } +} + +long changehealth(short snum, short deltahealth) +{ + long dax, day; + short good, k, startwall, endwall, s; + + if (health[snum] > 0) + { + health[snum] += deltahealth; + if (health[snum] > 999) health[snum] = 999; + + if (health[snum] <= 0) + { + health[snum] = -1; + wsayfollow("death.wav",4096L+(krand()&127)-64,256L,&posx[snum],&posy[snum],1); + sprite[playersprite[snum]].picnum = SKELETON; + } + + if ((snum == screenpeek) && (screensize <= xdim)) + { + if (health[snum] > 0) + sprintf(tempbuf,"Health:%3ld",health[snum]); + else + sprintf(tempbuf,"YOU STINK!"); + + printext((xdim>>1)-(Bstrlen(tempbuf)<<2),ydim-24,tempbuf,ALPHABET,80); + } + } + return(health[snum] <= 0); //You were just injured +} + +void changenumbombs(short snum, short deltanumbombs) { // Andy did this + numbombs[snum] += deltanumbombs; + if (numbombs[snum] > 999) numbombs[snum] = 999; + if (numbombs[snum] <= 0) { + wsayfollow("doh.wav",4096L+(krand()&127)-64,256L,&posx[snum],&posy[snum],1); + numbombs[snum] = 0; + } + + if ((snum == screenpeek) && (screensize <= xdim)) { + sprintf(tempbuf,"B:%3d",numbombs[snum]); + printext(8L,(ydim - 28L),tempbuf,ALPHABET,80); + } +} + +void changenummissiles(short snum, short deltanummissiles) { // Andy did this + nummissiles[snum] += deltanummissiles; + if (nummissiles[snum] > 999) nummissiles[snum] = 999; + if (nummissiles[snum] <= 0) { + wsayfollow("doh.wav",4096L+(krand()&127)-64,256L,&posx[snum],&posy[snum],1); + nummissiles[snum] = 0; + } + + if ((snum == screenpeek) && (screensize <= xdim)) { + sprintf(tempbuf,"M:%3d",nummissiles[snum]); + printext(8L,(ydim - 20L),tempbuf,ALPHABET,80); + } +} + +void changenumgrabbers(short snum, short deltanumgrabbers) { // Andy did this + numgrabbers[snum] += deltanumgrabbers; + if (numgrabbers[snum] > 999) numgrabbers[snum] = 999; + if (numgrabbers[snum] <= 0) { + wsayfollow("doh.wav",4096L+(krand()&127)-64,256L,&posx[snum],&posy[snum],1); + numgrabbers[snum] = 0; + } + + if ((snum == screenpeek) && (screensize <= xdim)) { + sprintf(tempbuf,"G:%3d",numgrabbers[snum]); + printext(8L,(ydim - 12L),tempbuf,ALPHABET,80); + } +} + +static long ostatusflytime = 0x80000000; +void drawstatusflytime(short snum) { // Andy did this + long nstatusflytime; + + if ((snum == screenpeek) && (screensize <= xdim)) { + nstatusflytime = (((flytime[snum] + 119) - lockclock) / 120); + if (nstatusflytime > 1000) nstatusflytime = 1000; + else if (nstatusflytime < 0) nstatusflytime = 0; + if (nstatusflytime != ostatusflytime) { + if (nstatusflytime > 999) sprintf(tempbuf,"FT:BIG"); + else sprintf(tempbuf,"FT:%3ld",nstatusflytime); + printext((xdim - 56L),(ydim - 20L),tempbuf,ALPHABET,80); + ostatusflytime = nstatusflytime; + } + } +} + +void drawstatusbar(short snum) { // Andy did this + long nstatusflytime; + + if ((snum == screenpeek) && (screensize <= xdim)) { + Bsprintf(tempbuf,"Deaths:%d",deaths[snum]); + printext((xdim>>1)-(Bstrlen(tempbuf)<<2),ydim-16,tempbuf,ALPHABET,80); + Bsprintf(tempbuf,"Health:%3ld",health[snum]); + printext((xdim>>1)-(Bstrlen(tempbuf)<<2),ydim-24,tempbuf,ALPHABET,80); + + Bsprintf(tempbuf,"B:%3d",numbombs[snum]); + printext(8L,(ydim - 28L),tempbuf,ALPHABET,80); + Bsprintf(tempbuf,"M:%3d",nummissiles[snum]); + printext(8L,(ydim - 20L),tempbuf,ALPHABET,80); + Bsprintf(tempbuf,"G:%3d",numgrabbers[snum]); + printext(8L,(ydim - 12L),tempbuf,ALPHABET,80); + + nstatusflytime = (((flytime[snum] + 119) - lockclock) / 120); + if (nstatusflytime < 0) { + Bsprintf(tempbuf,"FT: 0"); + ostatusflytime = 0; + } + else if (nstatusflytime > 999) { + Bsprintf(tempbuf,"FT:BIG"); + ostatusflytime = 999; + } + else { + Bsprintf(tempbuf,"FT:%3ld",nstatusflytime); + ostatusflytime = nstatusflytime; + } + printext((xdim - 56L),(ydim - 20L),tempbuf,ALPHABET,80); + } +} + +void prepareboard(char *daboardfilename) +{ + short startwall, endwall, dasector; + long i, j, k=0, s, dax, day, daz, dax2, day2; + + getmessageleng = 0; + typemessageleng = 0; + + randomseed = 17L; + + //Clear (do)animation's list + animatecnt = 0; + typemode = 0; + locselectedgun = 0; + locselectedgun2 = 0; + + if (loadboard(daboardfilename,0,&posx[0],&posy[0],&posz[0],&ang[0],&cursectnum[0]) == -1) + { + musicoff(); + uninitmultiplayers(); + uninittimer(); + uninitinput(); + uninitengine(); + uninitsb(); + uninitgroupfile(); + printf("Board not found\n"); + exit(0); + } else { + char *fp; + + strcpy(tempbuf, daboardfilename); + fp = strrchr(tempbuf,'.'); + if (fp) *fp = 0; + strcat(tempbuf,".mhk"); + + loadmaphack(tempbuf); + } + + setup3dscreen(); + + for(i=0;i dax2) dax2 = wall[j].x; + if (wall[j].y > day2) day2 = wall[j].y; + if (wall[j].lotag == 3) k = j; + } + if (wall[k].x == dax) dragxdir[dragsectorcnt] = -16; + if (wall[k].y == day) dragydir[dragsectorcnt] = -16; + if (wall[k].x == dax2) dragxdir[dragsectorcnt] = 16; + if (wall[k].y == day2) dragydir[dragsectorcnt] = 16; + + dasector = wall[startwall].nextsector; + dragx1[dragsectorcnt] = 0x7fffffff; + dragy1[dragsectorcnt] = 0x7fffffff; + dragx2[dragsectorcnt] = 0x80000000; + dragy2[dragsectorcnt] = 0x80000000; + startwall = sector[dasector].wallptr; + endwall = startwall+sector[dasector].wallnum; + for(j=startwall;j dragx2[dragsectorcnt]) dragx2[dragsectorcnt] = wall[j].x; + if (wall[j].y > dragy2[dragsectorcnt]) dragy2[dragsectorcnt] = wall[j].y; + + setinterpolation(§or[dasector].floorz); + setinterpolation(&wall[j].x); + setinterpolation(&wall[j].y); + setinterpolation(&wall[wall[j].nextwall].x); + setinterpolation(&wall[wall[j].nextwall].y); + } + + dragx1[dragsectorcnt] += (wall[sector[i].wallptr].x-dax); + dragy1[dragsectorcnt] += (wall[sector[i].wallptr].y-day); + dragx2[dragsectorcnt] -= (dax2-wall[sector[i].wallptr].x); + dragy2[dragsectorcnt] -= (day2-wall[sector[i].wallptr].y); + + dragfloorz[dragsectorcnt] = sector[i].floorz; + + dragsectorlist[dragsectorcnt++] = i; + break; + case 13: + startwall = sector[i].wallptr; + endwall = startwall+sector[i].wallnum; + for(j=startwall;j dax2) dax2 = wall[j].x; + if (wall[j].y > day2) day2 = wall[j].y; + } + for(j=startwall;j dax) && (wall[j].y > day) && (wall[j].x < dax2) && (wall[j].y < day2)) + { + subwayx[subwaytrackcnt] = wall[j].x; + } + else + { + subwaystop[subwaytrackcnt][subwaystopcnt[subwaytrackcnt]] = wall[j].x; + subwaystopcnt[subwaytrackcnt]++; + } + } + } + + for(j=1;j subwaytrackx1[subwaytrackcnt]) + if (wall[startwall].y > subwaytracky1[subwaytrackcnt]) + if (wall[startwall].x < subwaytrackx2[subwaytrackcnt]) + if (wall[startwall].y < subwaytracky2[subwaytrackcnt]) + { + if (sector[j].floorz != sector[i].floorz) + { + sector[j].ceilingstat |= 64; + sector[j].floorstat |= 64; + } + subwaytracksector[subwaytrackcnt][subwaynumsectors[subwaytrackcnt]] = j; + subwaynumsectors[subwaytrackcnt]++; + } + } + + subwayvel[subwaytrackcnt] = 64; + subwaypausetime[subwaytrackcnt] = 720; + + startwall = sector[i].wallptr; + endwall = startwall+sector[i].wallnum; + for(k=startwall;k subwaytrackx1[subwaytrackcnt]) + if (wall[k].y > subwaytracky1[subwaytrackcnt]) + if (wall[k].x < subwaytrackx2[subwaytrackcnt]) + if (wall[k].y < subwaytracky2[subwaytrackcnt]) + setinterpolation(&wall[k].x); + + for(j=1;j=0;k=nextspritesect[k]) + if (statrate[sprite[k].statnum] < 0) + setinterpolation(&sprite[k].x); + } + + + subwaytrackcnt++; + break; + } + if (sector[i].floorpicnum == FLOORMIRROR) + floormirrorsector[mirrorcnt++] = i; + //if (sector[i].ceilingpicnum == FLOORMIRROR) floormirrorsector[mirrorcnt++] = i; //SOS + } + + //Scan wall tags + + mirrorcnt = 0; + tilesizx[MIRROR] = 0; + tilesizy[MIRROR] = 0; + for(i=0;i= 0) && (wall[i].overpicnum == MIRROR) && (wall[i].cstat&32)) + { + if ((sector[s].floorstat&1) == 0) + { + wall[i].overpicnum = MIRRORLABEL+mirrorcnt; + sector[s].ceilingpicnum = MIRRORLABEL+mirrorcnt; + sector[s].floorpicnum = MIRRORLABEL+mirrorcnt; + sector[s].floorstat |= 1; + mirrorwall[mirrorcnt] = i; + mirrorsector[mirrorcnt] = s; + mirrorcnt++; + } + else + wall[i].overpicnum = sector[s].ceilingpicnum; + } + } + + //Invalidate textures in sector behind mirror + for(i=0;i=0;i--) copybuf(&sprite[i].x,&osprite[i].x,3); + + searchmap(cursectnum[connecthead]); + + lockclock = 0; + ototalclock = 0; + gotlastpacketclock = 0; + + screensize = xdim; + dax = ((xdim-screensize)>>1); + dax2 = dax+screensize-1; + day = (((ydim-32)-scale(screensize,ydim-32,xdim))>>1); + day2 = day + scale(screensize,ydim-32,xdim)-1; + setview(dax,day,dax2,day2); + + startofdynamicinterpolations = numinterpolations; + + /* + for(i=connecthead;i>=0;i=connectpoint2[i]) myminlag[i] = 0; + otherminlag = mymaxlag = 0; + */ +} + +void checktouchsprite(short snum, short sectnum) +{ + long i, nexti; + + if ((sectnum < 0) || (sectnum >= numsectors)) return; + + for(i=headspritesect[sectnum];i>=0;i=nexti) + { + nexti = nextspritesect[i]; + if (sprite[i].cstat&0x8000) continue; + if ((klabs(posx[snum]-sprite[i].x)+klabs(posy[snum]-sprite[i].y) < 512) && (klabs((posz[snum]>>8)-((sprite[i].z>>8)-(tilesizy[sprite[i].picnum]>>1))) <= 40)) + { + switch(sprite[i].picnum) + { + case COIN: + wsayfollow("getstuff.wav",4096L+(krand()&127)-64,192L,&sprite[i].x,&sprite[i].y,0); + changehealth(snum,5); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*60; + changespritestat((short)i,11); + } + break; + case DIAMONDS: + wsayfollow("getstuff.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + changehealth(snum,15); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*120; + changespritestat((short)i,11); + } + break; + case COINSTACK: + wsayfollow("getstuff.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + changehealth(snum,25); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*180; + changespritestat((short)i,11); + } + break; + case GIFTBOX: + wsayfollow("getstuff.wav",4096L+(krand()&127)+256-mulscale4(sprite[i].xrepeat,sprite[i].yrepeat),208L,&sprite[i].x,&sprite[i].y,0); + changehealth(snum,max(mulscale8(sprite[i].xrepeat,sprite[i].yrepeat),1)); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 90*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + case CANNON: + wsayfollow("getstuff.wav",3584L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + if (snum == myconnectindex) keystatus[4] = 1; + changenumbombs(snum,((sprite[i].xrepeat+sprite[i].yrepeat)>>1)); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 60*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + case LAUNCHER: + wsayfollow("getstuff.wav",3584L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + if (snum == myconnectindex) keystatus[5] = 1; + changenummissiles(snum,((sprite[i].xrepeat+sprite[i].yrepeat)>>1)); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 90*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + case GRABCANNON: + wsayfollow("getstuff.wav",3584L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + if (snum == myconnectindex) keystatus[6] = 1; + changenumgrabbers(snum,((sprite[i].xrepeat+sprite[i].yrepeat)>>1)); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + case AIRPLANE: + wsayfollow("getstuff.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + if (flytime[snum] < lockclock) flytime[snum] = lockclock; + flytime[snum] += 60*(sprite[i].xrepeat+sprite[i].yrepeat); + drawstatusflytime(snum); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + } + } + } +} + +void checkgrabbertouchsprite(short snum, short sectnum) // Andy did this +{ + long i, nexti; + short onum; + + if ((sectnum < 0) || (sectnum >= numsectors)) return; + onum = (sprite[snum].owner & (MAXSPRITES - 1)); + + for(i=headspritesect[sectnum];i>=0;i=nexti) + { + nexti = nextspritesect[i]; + if (sprite[i].cstat&0x8000) continue; + if ((klabs(sprite[snum].x-sprite[i].x)+klabs(sprite[snum].y-sprite[i].y) < 512) && (klabs((sprite[snum].z>>8)-((sprite[i].z>>8)-(tilesizy[sprite[i].picnum]>>1))) <= 40)) + { + switch(sprite[i].picnum) + { + case COIN: + wsayfollow("getstuff.wav",4096L+(krand()&127)-64,192L,&sprite[i].x,&sprite[i].y,0); + changehealth(onum,5); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*60; + changespritestat((short)i,11); + } + break; + case DIAMONDS: + wsayfollow("getstuff.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + changehealth(onum,15); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*120; + changespritestat((short)i,11); + } + break; + case COINSTACK: + wsayfollow("getstuff.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + changehealth(onum,25); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*180; + changespritestat((short)i,11); + } + break; + case GIFTBOX: + wsayfollow("getstuff.wav",4096L+(krand()&127)+256-mulscale4(sprite[i].xrepeat,sprite[i].yrepeat),208L,&sprite[i].x,&sprite[i].y,0); + changehealth(onum,max(mulscale8(sprite[i].xrepeat,sprite[i].yrepeat),1)); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 90*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + case CANNON: + wsayfollow("getstuff.wav",3584L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + if (onum == myconnectindex) keystatus[4] = 1; + changenumbombs(onum,((sprite[i].xrepeat+sprite[i].yrepeat)>>1)); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 60*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + case LAUNCHER: + wsayfollow("getstuff.wav",3584L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + if (onum == myconnectindex) keystatus[5] = 1; + changenummissiles(onum,((sprite[i].xrepeat+sprite[i].yrepeat)>>1)); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 90*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + case GRABCANNON: + wsayfollow("getstuff.wav",3584L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + if (onum == myconnectindex) keystatus[6] = 1; + changenumgrabbers(onum,((sprite[i].xrepeat+sprite[i].yrepeat)>>1)); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + case AIRPLANE: + wsayfollow("getstuff.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + if (flytime[snum] < lockclock) flytime[snum] = lockclock; + flytime[onum] += 60*(sprite[i].xrepeat+sprite[i].yrepeat); + drawstatusflytime(onum); + if (sprite[i].statnum == 12) deletesprite((short)i); + else { + sprite[i].cstat |= 0x8000; + sprite[i].extra = 120*(sprite[i].xrepeat+sprite[i].yrepeat); + changespritestat((short)i,11); + } + break; + } + } + } +} + +void shootgun(short snum, long x, long y, long z, + short daang, long dahoriz, short dasectnum, char guntype) +{ + short hitsect, hitwall, hitsprite, daang2; + long i, j, daz2, hitx, hity, hitz; + + switch(guntype) + { + case 0: //Shoot chain gun + daang2 = ((daang + (krand()&31)-16)&2047); + daz2 = ((100-dahoriz)*2000) + ((krand()-32768)>>1); + + hitscan(x,y,z,dasectnum, //Start position + sintable[(daang2+512)&2047], //X vector of 3D ang + sintable[daang2&2047], //Y vector of 3D ang + daz2, //Z vector of 3D ang + &hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + + if (wall[hitwall].picnum == KENPICTURE) + { + if (waloff[MAXTILES-1] != 0) wall[hitwall].picnum = MAXTILES-1; + wsayfollow("hello.wav",4096L+(krand()&127)-64,256L,&wall[hitwall].x,&wall[hitwall].y,0); + } + else if (((hitwall < 0) && (hitsprite < 0) && (hitz >= z) && ((sector[hitsect].floorpicnum == SLIME) || (sector[hitsect].floorpicnum == FLOORMIRROR))) || ((hitwall >= 0) && (wall[hitwall].picnum == SLIME))) + { //If you shoot slime, make a splash + wsayfollow("splash.wav",4096L+(krand()&511)-256,256L,&hitx,&hity,0); + spawnsprite(j,hitx,hity,hitz,2,0,0,32,64,64,0,0,SPLASH,daang, + 0,0,0,snum+4096,hitsect,4,63,0,0); //63=time left for splash + } + else + { + wsayfollow("shoot.wav",4096L+(krand()&127)-64,256L,&hitx,&hity,0); + + if ((hitsprite >= 0) && (sprite[hitsprite].statnum < MAXSTATUS)) + switch(sprite[hitsprite].picnum) + { + case BROWNMONSTER: + if (sprite[hitsprite].lotag > 0) sprite[hitsprite].lotag -= 10; + if (sprite[hitsprite].lotag > 0) + { + wsayfollow("hurt.wav",4096L+(krand()&511)-256,256L,&hitx,&hity,0); + if (sprite[hitsprite].lotag <= 25) + sprite[hitsprite].cstat |= 2; + } + else + { + wsayfollow("mondie.wav",4096L+(krand()&127)-64,256L,&hitx,&hity,0); + sprite[hitsprite].z += ((tilesizy[sprite[hitsprite].picnum]*sprite[hitsprite].yrepeat)<<1); + sprite[hitsprite].picnum = GIFTBOX; + sprite[hitsprite].cstat &= ~0x83; //Should not clip, foot-z + changespritestat(hitsprite,12); + + spawnsprite(j,hitx,hity,hitz+(32<<8),0,-4,0,32,64,64, + 0,0,EXPLOSION,daang,0,0,0,snum+4096, + hitsect,5,31,0,0); + } + break; + case EVILAL: + wsayfollow("blowup.wav",4096L+(krand()&127)-64,256L,&hitx,&hity,0); + sprite[hitsprite].picnum = EVILALGRAVE; + sprite[hitsprite].cstat = 0; + sprite[hitsprite].xvel = (krand()&255)-128; + sprite[hitsprite].yvel = (krand()&255)-128; + sprite[hitsprite].zvel = (krand()&4095)-3072; + changespritestat(hitsprite,9); + + spawnsprite(j,hitx,hity,hitz+(32<<8),0,-4,0,32,64,64,0, + 0,EXPLOSION,daang,0,0,0,snum+4096,hitsect,5,31,0,0); + //31=time left for explosion + + break; + case PLAYER: + for(j=connecthead;j>=0;j=connectpoint2[j]) + if (playersprite[j] == hitsprite) + { + wsayfollow("ouch.wav",4096L+(krand()&127)-64,256L,&hitx,&hity,0); + changehealth(j,-10); + break; + } + break; + } + + spawnsprite(j,hitx,hity,hitz+(8<<8),2,-4,0,32,16,16,0,0, + EXPLOSION,daang,0,0,0,snum+4096,hitsect,3,63,0,0); + + //Sprite starts out with center exactly on wall. + //This moves it back enough to see it at all angles. + movesprite((short)j,-(((long)sintable[(512+daang)&2047]*TICSPERFRAME)<<4),-(((long)sintable[daang]*TICSPERFRAME)<<4),0L,4L<<8,4L<<8,CLIPMASK1); + } + break; + case 1: //Shoot silver sphere bullet + spawnsprite(j,x,y,z,1+128,0,0,16,64,64,0,0,BULLET,daang, + sintable[(daang+512)&2047]>>5,sintable[daang&2047]>>5, + (100-dahoriz)<<6,snum+4096,dasectnum,6,0,0,0); + wsayfollow("shoot2.wav",4096L+(krand()&127)-64,128L,&sprite[j].x,&sprite[j].y,1); + break; + case 2: //Shoot bomb + spawnsprite(j,x,y,z,128,0,0,12,16,16,0,0,BOMB,daang, + sintable[(daang+512)&2047]*5>>8,sintable[daang&2047]*5>>8, + (80-dahoriz)<<6,snum+4096,dasectnum,6,0,0,0); + wsayfollow("shoot3.wav",4096L+(krand()&127)-64,192L,&sprite[j].x,&sprite[j].y,1); + break; + case 3: //Shoot missile (Andy did this) + spawnsprite(j,x,y,z,1+128,0,0,16,32,32,0,0,MISSILE,daang, + sintable[(daang+512)&2047]>>4,sintable[daang&2047]>>4, + (100-dahoriz)<<7,snum+4096,dasectnum,6,0,0,0); + wsayfollow("shoot3.wav",4096L+(krand()&127)-64,192L,&sprite[j].x,&sprite[j].y,1); + break; + case 4: //Shoot grabber (Andy did this) + spawnsprite(j,x,y,z,1+128,0,0,16,64,64,0,0,GRABBER,daang, + sintable[(daang+512)&2047]>>5,sintable[daang&2047]>>5, + (100-dahoriz)<<6,snum+4096,dasectnum,6,0,0,0); + wsayfollow("shoot4.wav",4096L+(krand()&127)-64,128L,&sprite[j].x,&sprite[j].y,1); + break; + } +} + +#define MAXVOXMIPS 5 +extern char *voxoff[][MAXVOXMIPS]; +void analyzesprites(long dax, long day) +{ + long i, j=0, k, *intptr; + point3d *ospr; + spritetype *tspr; + + //This function is called between drawrooms() and drawmasks() + //It has a list of possible sprites that may be drawn on this frame + + for(i=0,tspr=&tsprite[0];ipicnum] >= 0) + switch(tspr->picnum) + { + case PLAYER: + // //Get which of the 8 angles of the sprite to draw (0-7) + // //k ranges from 0-7 + //k = getangle(tspr->x-dax,tspr->y-day); + //k = (((tspr->ang+3072+128-k)&2047)>>8)&7; + // //This guy has only 5 pictures for 8 angles (3 are x-flipped) + //if (k <= 4) + //{ + // tspr->picnum += (k<<2); + // tspr->cstat &= ~4; //clear x-flipping bit + //} + //else + //{ + // tspr->picnum += ((8-k)<<2); + // tspr->cstat |= 4; //set x-flipping bit + //} + + if ((tspr->cstat&2) == 0) + { + //tspr->cstat |= 48; tspr->picnum = tiletovox[tspr->picnum]; + intptr = (long *)voxoff[ tiletovox[PLAYER] ][0]; + tspr->xrepeat = scale(tspr->xrepeat,56,intptr[2]); + tspr->yrepeat = scale(tspr->yrepeat,56,intptr[2]); + tspr->shade -= 6; + } + break; + case BROWNMONSTER: + //tspr->cstat |= 48; tspr->picnum = tiletovox[tspr->picnum]; + break; + } +#endif + + k = statrate[tspr->statnum]; + if (k >= 0) //Interpolate moving sprite + { + ospr = &osprite[tspr->owner]; + switch(k) + { + case 0: j = smoothratio; break; + case 1: j = (smoothratio>>1)+(((nummoves-tspr->owner)&1)<<15); break; + case 3: j = (smoothratio>>2)+(((nummoves-tspr->owner)&3)<<14); break; + case 7: j = (smoothratio>>3)+(((nummoves-tspr->owner)&7)<<13); break; + case 15: j = (smoothratio>>4)+(((nummoves-tspr->owner)&15)<<12); break; + } + k = tspr->x-ospr->x; tspr->x = ospr->x; + if (k != 0) tspr->x += mulscale16(k,j); + k = tspr->y-ospr->y; tspr->y = ospr->y; + if (k != 0) tspr->y += mulscale16(k,j); + k = tspr->z-ospr->z; tspr->z = ospr->z; + if (k != 0) tspr->z += mulscale16(k,j); + } + + //Don't allow close explosion sprites to be transluscent + k = tspr->statnum; + if ((k == 3) || (k == 4) || (k == 5) || (k == 7)) + if (klabs(dax-tspr->x) < 256) + if (klabs(day-tspr->y) < 256) + tspr->cstat &= ~2; + + tspr->shade += 6; + if (sector[tspr->sectnum].ceilingstat&1) + tspr->shade += sector[tspr->sectnum].ceilingshade; + else + tspr->shade += sector[tspr->sectnum].floorshade; + } +} + +void tagcode(void) +{ + long i, nexti, j, k, l, s, dax, day, daz, dax2, day2, cnt, good; + short startwall, endwall, dasector, p, oldang; + + for(p=connecthead;p>=0;p=connectpoint2[p]) + { + if (sector[cursectnum[p]].lotag == 1) + { + activatehitag(sector[cursectnum[p]].hitag); + sector[cursectnum[p]].lotag = 0; + sector[cursectnum[p]].hitag = 0; + } + if ((sector[cursectnum[p]].lotag == 2) && (cursectnum[p] != ocursectnum[p])) + activatehitag(sector[cursectnum[p]].hitag); + } + + for(i=0;i>2); + if (j >= 16) j = 31-j; + { + sector[dasector].ceilingshade = j; + sector[dasector].floorshade = j; + startwall = sector[dasector].wallptr; + endwall = startwall+sector[dasector].wallnum; + for(s=startwall;s=0;p=connectpoint2[p]) + if (sector[cursectnum[p]].lotag == 10) //warp sector + { + if (cursectnum[p] != ocursectnum[p]) + { + warpsprite(playersprite[p]); + posx[p] = sprite[playersprite[p]].x; + posy[p] = sprite[playersprite[p]].y; + posz[p] = sprite[playersprite[p]].z; + ang[p] = sprite[playersprite[p]].ang; + cursectnum[p] = sprite[playersprite[p]].sectnum; + + sprite[playersprite[p]].z += EYEHEIGHT; + + //warp(&posx[p],&posy[p],&posz[p],&ang[p],&cursectnum[p]); + //Update sprite representation of player + //setsprite(playersprite[p],posx[p],posy[p],posz[p]+EYEHEIGHT); + //sprite[playersprite[p]].ang = ang[p]; + } + } + + for(i=0;i>2)&255); + } + + for(i=0;i>2)&255); + sector[floorpanninglist[i]].floorypanning = ((lockclock>>2)&255); + } + + for(i=0;i dragx2[i]) dragxdir[i] = -16; + if (wall[startwall].y+dragydir[i] > dragy2[i]) dragydir[i] = -16; + + for(j=startwall;j>3); + + for(p=connecthead;p>=0;p=connectpoint2[p]) + if (cursectnum[p] == dasector) + { + posx[p] += dragxdir[i]; + posy[p] += dragydir[i]; + if (p == myconnectindex) + { myx += dragxdir[i]; myy += dragydir[i]; } + //posz[p] += (sector[dasector].floorz-j); + + //Update sprite representation of player + setsprite(playersprite[p],posx[p],posy[p],posz[p]+EYEHEIGHT); + sprite[playersprite[p]].ang = ang[p]; + } + } + + for(i=0;i=0;p=connectpoint2[p]) + if ((cursectnum[p] == swingsector[i]) || (testneighborsectors(cursectnum[p],swingsector[i]) == 1)) + { + cnt = 256; + do + { + good = 1; + + //swingangopendir is -1 if forwards, 1 is backwards + l = (swingangopendir[i] > 0); + for(k=l+3;k>=l;k--) + if (clipinsidebox(posx[p],posy[p],swingwall[i][k],128L) != 0) + { + good = 0; + break; + } + if (good == 0) + { + if (cnt == 256) + { + swinganginc[i] = -swinganginc[i]; + swingang[i] = oldang; + } + else + { + swingang[i] = ((swingang[i]-swinganginc[i])&2047); + } + for(k=1;k<=3;k++) + rotatepoint(swingx[i][0],swingy[i][0],swingx[i][k],swingy[i][k],swingang[i],&wall[swingwall[i][k]].x,&wall[swingwall[i][k]].y); + if (swingang[i] == swingangclosed[i]) + { + wsayfollow("closdoor.wav",4096L+(krand()&511)-256,256L,&swingx[i][0],&swingy[i][0],0); + swinganginc[i] = 0; + break; + } + if (swingang[i] == swingangopen[i]) + { + swinganginc[i] = 0; + break; + } + cnt--; + } + } while ((good == 0) && (cnt > 0)); + } + } + } + if (swinganginc[i] == 0) + for(j=1;j<=3;j++) + { + stopinterpolation(&wall[swingwall[i][j]].x); + stopinterpolation(&wall[swingwall[i][j]].y); + } + } + + for(i=0;i 2)) + { + dasector = subwaytracksector[i][0]; + startwall = sector[dasector].wallptr; + endwall = startwall+sector[dasector].wallnum; + for(k=startwall;k subwaytrackx1[i]) + if (wall[k].y > subwaytracky1[i]) + if (wall[k].x < subwaytrackx2[i]) + if (wall[k].y < subwaytracky2[i]) + wall[k].x += subwayvel[i]; + + for(j=1;j=0;s=nextspritesect[s]) + sprite[s].x += subwayvel[i]; + } + + for(p=connecthead;p>=0;p=connectpoint2[p]) + if (cursectnum[p] != subwaytracksector[i][0]) + if (sector[cursectnum[p]].floorz != sector[subwaytracksector[i][0]].floorz) + if (posx[p] > subwaytrackx1[i]) + if (posy[p] > subwaytracky1[i]) + if (posx[p] < subwaytrackx2[i]) + if (posy[p] < subwaytracky2[i]) + { + posx[p] += subwayvel[i]; + if (p == myconnectindex) + { myx += subwayvel[i]; } + + //Update sprite representation of player + setsprite(playersprite[p],posx[p],posy[p],posz[p]+EYEHEIGHT); + sprite[playersprite[p]].ang = ang[p]; + } + + subwayx[i] += subwayvel[i]; + } + + j = subwayvel[i]; + k = subwaystop[i][subwaygoalstop[i]] - subwayx[i]; + if (k > 0) + { + if (k > 4096) + { + if (subwayvel[i] < 256) subwayvel[i]++; + } + else + subwayvel[i] = (k>>4)+1; + } + else if (k < 0) + { + if (k < -4096) + { + if (subwayvel[i] > -256) subwayvel[i]--; + } + else + subwayvel[i] = (k>>4)-1; + } + if ((j < 0) && (subwayvel[i] >= 0)) subwayvel[i] = -1; + if ((j > 0) && (subwayvel[i] <= 0)) subwayvel[i] = 1; + + if ((subwayvel[i] <= 2) && (subwayvel[i] >= -2) && (klabs(k) < 2048)) + { + //Open / close doors + if ((subwaypausetime[i] == 720) || ((subwaypausetime[i] >= 120) && (subwaypausetime[i]-TICSPERFRAME < 120))) + activatehitag(sector[subwaytracksector[i][0]].hitag); + + subwaypausetime[i] -= TICSPERFRAME; + if (subwaypausetime[i] < 0) + { + subwaypausetime[i] = 720; + if (subwayvel[i] < 0) + { + subwaygoalstop[i]--; + if (subwaygoalstop[i] < 0) + { + subwaygoalstop[i] = 1; + subwayvel[i] = 1; + } + } + else if (subwayvel[i] > 0) + { + subwaygoalstop[i]++; + if (subwaygoalstop[i] >= subwaystopcnt[i]) + { + subwaygoalstop[i] = subwaystopcnt[i]-2; + subwayvel[i] = -1; + } + } + } + } + } +} + +void statuslistcode(void) +{ + short p, target, hitobject, daang, osectnum, movestat; + long i, nexti, j, nextj, k, l, dax, day, daz, dist, ox, oy, mindist; + long doubvel, xvect, yvect; + + //Go through active BROWNMONSTER list + for(i=headspritestat[1];i>=0;i=nexti) + { + nexti = nextspritestat[i]; + + k = krand(); + + //Choose a target player + mindist = 0x7fffffff; target = connecthead; + for(p=connecthead;p>=0;p=connectpoint2[p]) + { + dist = klabs(sprite[i].x-posx[p])+klabs(sprite[i].y-posy[p]); + if (dist < mindist) mindist = dist, target = p; + } + + //brown monster decides to shoot bullet + if ((k&63) == 23) + { + if (cansee(sprite[i].x,sprite[i].y,sprite[i].z-(tilesizy[sprite[i].picnum]<<7),sprite[i].sectnum,posx[target],posy[target],posz[target],cursectnum[target]) == 0) + { + if ((k&0xf00) == 0xb00) changespritestat(i,2); + } + else + { + wsayfollow("monshoot.wav",5144L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,1); + + doubvel = (TICSPERFRAME<<((ssync[target].bits&256)>0)); + xvect = 0, yvect = 0; + if (ssync[target].fvel != 0) + { + xvect += ((((long)ssync[target].fvel)*doubvel*(long)sintable[(ang[target]+512)&2047])>>3); + yvect += ((((long)ssync[target].fvel)*doubvel*(long)sintable[ang[target]&2047])>>3); + } + if (ssync[target].svel != 0) + { + xvect += ((((long)ssync[target].svel)*doubvel*(long)sintable[ang[target]&2047])>>3); + yvect += ((((long)ssync[target].svel)*doubvel*(long)sintable[(ang[target]+1536)&2047])>>3); + } + + ox = posx[target]; oy = posy[target]; + + //distance is j + j = ksqrt((ox-sprite[i].x)*(ox-sprite[i].x)+(oy-sprite[i].y)*(oy-sprite[i].y)); + + switch((sprite[i].extra>>11)&3) + { + case 1: j = -(j>>1); break; + case 3: j = 0; break; + case 0: case 2: break; + } + sprite[i].extra += 2048; + + //rate is (TICSPERFRAME<<19) + xvect = scale(xvect,j,TICSPERFRAME<<19); + yvect = scale(yvect,j,TICSPERFRAME<<19); + clipmove(&ox,&oy,&posz[target],&cursectnum[target],xvect<<14,yvect<<14,128L,4<<8,4<<8,CLIPMASK0); + ox -= sprite[i].x; + oy -= sprite[i].y; + + daang = ((getangle(ox,oy)+(krand()&7)-4)&2047); + + dax = (sintable[(daang+512)&2047]>>6); + day = (sintable[daang&2047]>>6); + daz = 0; + if (ox != 0) + daz = scale(dax,posz[target]+(8<<8)-sprite[i].z,ox); + else if (oy != 0) + daz = scale(day,posz[target]+(8<<8)-sprite[i].z,oy); + + spawnsprite(j,sprite[i].x,sprite[i].y,sprite[i].z,128,0,0, + 16,sprite[i].xrepeat,sprite[i].yrepeat,0,0,BULLET,daang,dax,day,daz,i,sprite[i].sectnum,6,0,0,0); + + sprite[i].extra &= (~2047); + } + } + + //Move brown monster + dax = sprite[i].x; //Back up old x&y if stepping off cliff + day = sprite[i].y; + + doubvel = max(mulscale7(sprite[i].xrepeat,sprite[i].yrepeat),4); + + osectnum = sprite[i].sectnum; + movestat = movesprite((short)i,(long)sintable[(sprite[i].ang+512)&2047]*doubvel,(long)sintable[sprite[i].ang]*doubvel,0L,4L<<8,4L<<8,CLIPMASK0); + if (globloz > sprite[i].z+(48<<8)) + { sprite[i].x = dax; sprite[i].y = day; movestat = 1; } + else + sprite[i].z = globloz-((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + + if ((sprite[i].sectnum != osectnum) && (sector[sprite[i].sectnum].lotag == 10)) + { warpsprite((short)i); movestat = 0; } + + if ((movestat != 0) || ((k&63) == 1)) + { + if (sprite[i].ang == (sprite[i].extra&2047)) + { + daang = (getangle(posx[target]-sprite[i].x,posy[target]-sprite[i].y)&2047); + daang = ((daang+(krand()&1023)-512)&2047); + sprite[i].extra = ((sprite[i].extra&(~2047))|daang); + } + if ((sprite[i].extra-sprite[i].ang)&1024) + { + sprite[i].ang = ((sprite[i].ang-32)&2047); + if (!((sprite[i].extra-sprite[i].ang)&1024)) sprite[i].ang = (sprite[i].extra&2047); + } + else + { + sprite[i].ang = ((sprite[i].ang+32)&2047); + if (((sprite[i].extra-sprite[i].ang)&1024)) sprite[i].ang = (sprite[i].extra&2047); + } + } + } + + for(i=headspritestat[10];i>=0;i=nexti) //EVILAL list + { + nexti = nextspritestat[i]; + + if (sprite[i].yrepeat < 38) continue; + if (sprite[i].yrepeat < 64) + { + sprite[i].xrepeat++; + sprite[i].yrepeat++; + continue; + } + + if ((nummoves-i)&statrate[10]) continue; + + //Choose a target player + mindist = 0x7fffffff; target = connecthead; + for(p=connecthead;p>=0;p=connectpoint2[p]) + { + dist = klabs(sprite[i].x-posx[p])+klabs(sprite[i].y-posy[p]); + if (dist < mindist) mindist = dist, target = p; + } + + k = (krand()&255); + + if ((sprite[i].lotag&32) && (k < 48)) //Al decides to reproduce + { + l = 0; + if ((sprite[i].lotag&64) && (k < 2)) //Give him a chance to reproduce without seeing you + l = 1; + else if (cansee(sprite[i].x,sprite[i].y,sprite[i].z-(tilesizy[sprite[i].picnum]<<7),sprite[i].sectnum,posx[target],posy[target],posz[target],cursectnum[target]) == 1) + l = 1; + if (l != 0) + { + spawnsprite(j,sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].cstat,sprite[i].shade,sprite[i].pal, + sprite[i].clipdist,38,38,sprite[i].xoffset,sprite[i].yoffset,sprite[i].picnum,krand()&2047,0,0,0,i, + sprite[i].sectnum,10,sprite[i].lotag,sprite[i].hitag,sprite[i].extra); + switch(krand()&31) //Mutations! + { + case 0: sprite[i].cstat ^= 2; break; + case 1: sprite[i].cstat ^= 512; break; + case 2: sprite[i].shade++; break; + case 3: sprite[i].shade--; break; + case 4: sprite[i].pal ^= 16; break; + case 5: case 6: case 7: sprite[i].lotag ^= (1<<(krand()&7)); break; + case 8: sprite[i].lotag = (krand()&255); break; + } + } + } + if (k >= 208+((sprite[i].lotag&128)>>2)) //Al decides to shoot bullet + { + if (cansee(sprite[i].x,sprite[i].y,sprite[i].z-(tilesizy[sprite[i].picnum]<<7),sprite[i].sectnum,posx[target],posy[target],posz[target],cursectnum[target]) == 1) + { + wsayfollow("zipguns.wav",5144L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,1); + + spawnsprite(j,sprite[i].x,sprite[i].y, + sector[sprite[i].sectnum].floorz-(24<<8), + 0,0,0,16,32,32,0,0,BULLET, + (getangle(posx[target]-sprite[j].x, + posy[target]-sprite[j].y)+(krand()&15)-8)&2047, + sintable[(sprite[j].ang+512)&2047]>>6, + sintable[sprite[j].ang&2047]>>6, + ((posz[target]+(8<<8)-sprite[j].z)<<8) / + (ksqrt((posx[target]-sprite[j].x) * + (posx[target]-sprite[j].x) + + (posy[target]-sprite[j].y) * + (posy[target]-sprite[j].y))+1), + i,sprite[i].sectnum,6,0,0,0); + } + } + + //Move Al + l = (((sprite[i].lotag&3)+2)<<8); + if (sprite[i].lotag&4) l = -l; + dax = sintable[(sprite[i].ang+512)&2047]*l; + day = sintable[sprite[i].ang]*l; + + osectnum = sprite[i].sectnum; + movestat = movesprite((short)i,dax,day,0L,-8L<<8,-8L<<8,CLIPMASK0); + sprite[i].z = globloz; + if ((sprite[i].sectnum != osectnum) && (sector[sprite[i].sectnum].lotag == 10)) + { + warpsprite((short)i); + movestat = 0; + } + + if (sprite[i].lotag&16) + { + if (((k&124) >= 120) && (cansee(sprite[i].x,sprite[i].y,sprite[i].z-(tilesizy[sprite[i].picnum]<<7),sprite[i].sectnum,posx[target],posy[target],posz[target],cursectnum[target]) == 1)) + sprite[i].ang = getangle(posx[target]-sprite[i].x,posy[target]-sprite[i].y); + else + sprite[i].ang = (krand()&2047); + } + + if (movestat != 0) + { + if ((k&2) && (cansee(sprite[i].x,sprite[i].y,sprite[i].z-(tilesizy[sprite[i].picnum]<<7),sprite[i].sectnum,posx[target],posy[target],posz[target],cursectnum[target]) == 1)) + sprite[i].ang = getangle(posx[target]-sprite[i].x,posy[target]-sprite[i].y); + else + sprite[i].ang = (krand()&2047); + + if ((movestat&49152) == 49152) + if (sprite[movestat&16383].picnum == EVILAL) + if ((k&31) >= 30) + { + wsayfollow("blowup.wav",5144L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + sprite[i].picnum = EVILALGRAVE; + sprite[i].cstat = 0; + sprite[i].xvel = (krand()&255)-128; + sprite[i].yvel = (krand()&255)-128; + sprite[i].zvel = (krand()&4095)-3072; + changespritestat(i,9); + } + + if (sprite[i].lotag&8) + if ((k&31) >= 30) + { + wsayfollow("blowup.wav",5144L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + sprite[i].picnum = EVILALGRAVE; + sprite[i].cstat = 0; + sprite[i].xvel = (krand()&255)-128; + sprite[i].yvel = (krand()&255)-128; + sprite[i].zvel = (krand()&4095)-3072; + changespritestat(i,9); + } + + if (movestat == -1) + { + wsayfollow("blowup.wav",5144L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + sprite[i].picnum = EVILALGRAVE; + sprite[i].cstat = 0; + sprite[i].xvel = (krand()&255)-128; + sprite[i].yvel = (krand()&255)-128; + sprite[i].zvel = (krand()&4095)-3072; + changespritestat(i,9); + } + } + } + + //Go through travelling bullet sprites + for(i=headspritestat[6];i>=0;i=nexti) + { + nexti = nextspritestat[i]; + + if ((nummoves-i)&statrate[6]) continue; + + //If the sprite is a bullet then... + if ((sprite[i].picnum == BULLET) || (sprite[i].picnum == GRABBER) || (sprite[i].picnum == MISSILE) || (sprite[i].picnum == BOMB)) + { + dax = ((((long)sprite[i].xvel)*TICSPERFRAME)<<12); + day = ((((long)sprite[i].yvel)*TICSPERFRAME)<<12); + daz = ((((long)sprite[i].zvel)*TICSPERFRAME)>>2); + if (sprite[i].picnum == BOMB) daz = 0; + + osectnum = sprite[i].sectnum; + hitobject = movesprite((short)i,dax,day,daz,4L<<8,4L<<8,CLIPMASK1); + if ((sprite[i].sectnum != osectnum) && (sector[sprite[i].sectnum].lotag == 10)) + { + warpsprite((short)i); + hitobject = 0; + } + + if (sprite[i].picnum == GRABBER) { // Andy did this (& Ken) !Homing! + checkgrabbertouchsprite(i,sprite[i].sectnum); + l = 0x7fffffff; + for (j = connecthead; j >= 0; j = connectpoint2[j]) // Players + if (j != (sprite[i].owner & (MAXSPRITES - 1))) + if (cansee(sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].sectnum,posx[j],posy[j],posz[j],cursectnum[j])) { + k = ksqrt(sqr(posx[j] - sprite[i].x) + sqr(posy[j] - sprite[i].y) + (sqr(posz[j] - sprite[i].z) >> 8)); + if (k < l) { + l = k; + dax = (posx[j] - sprite[i].x); + day = (posy[j] - sprite[i].y); + daz = (posz[j] - sprite[i].z); + } + } + for(j = headspritestat[1]; j >= 0; j = nextj) { // Active monsters + nextj = nextspritestat[j]; + if (cansee(sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].sectnum,sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].sectnum)) { + k = ksqrt(sqr(sprite[j].x - sprite[i].x) + sqr(sprite[j].y - sprite[i].y) + (sqr(sprite[j].z - sprite[i].z) >> 8)); + if (k < l) { + l = k; + dax = (sprite[j].x - sprite[i].x); + day = (sprite[j].y - sprite[i].y); + daz = (sprite[j].z - sprite[i].z); + } + } + } + for(j = headspritestat[2]; j >= 0; j = nextj) { // Inactive monsters + nextj = nextspritestat[j]; + if (cansee(sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].sectnum,sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].sectnum)) { + k = ksqrt(sqr(sprite[j].x - sprite[i].x) + sqr(sprite[j].y - sprite[i].y) + (sqr(sprite[j].z - sprite[i].z) >> 8)); + if (k < l) { + l = k; + dax = (sprite[j].x - sprite[i].x); + day = (sprite[j].y - sprite[i].y); + daz = (sprite[j].z - sprite[i].z); + } + } + } + if (l != 0x7fffffff) { + sprite[i].xvel = (divscale7(dax,l) + sprite[i].xvel); // 1/5 of velocity is homing, 4/5 is momentum + sprite[i].yvel = (divscale7(day,l) + sprite[i].yvel); // 1/5 of velocity is homing, 4/5 is momentum + sprite[i].zvel = (divscale7(daz,l) + sprite[i].zvel); // 1/5 of velocity is homing, 4/5 is momentum + l = ksqrt((sprite[i].xvel * sprite[i].xvel) + (sprite[i].yvel * sprite[i].yvel) + ((sprite[i].zvel * sprite[i].zvel) >> 8)); + sprite[i].xvel = divscale9(sprite[i].xvel,l); + sprite[i].yvel = divscale9(sprite[i].yvel,l); + sprite[i].zvel = divscale9(sprite[i].zvel,l); + sprite[i].ang = getangle(sprite[i].xvel,sprite[i].yvel); + } + } + + if (sprite[i].picnum == BOMB) + { + j = sprite[i].sectnum; + if ((sector[j].floorstat&2) && (sprite[i].z > globloz-(8<<8))) + { + k = sector[j].wallptr; + daang = getangle(wall[wall[k].point2].x-wall[k].x,wall[wall[k].point2].y-wall[k].y); + sprite[i].xvel += mulscale22(sintable[(daang+1024)&2047],sector[j].floorheinum); + sprite[i].yvel += mulscale22(sintable[(daang+512)&2047],sector[j].floorheinum); + } + } + + if (sprite[i].picnum == BOMB) + { + sprite[i].z += sprite[i].zvel; + sprite[i].zvel += (TICSPERFRAME<<7); + if (sprite[i].z < globhiz+(tilesizy[BOMB]<<6)) + { + sprite[i].z = globhiz+(tilesizy[BOMB]<<6); + sprite[i].zvel = -(sprite[i].zvel>>1); + } + if (sprite[i].z > globloz-(tilesizy[BOMB]<<6)) + { + sprite[i].z = globloz-(tilesizy[BOMB]<<6); + sprite[i].zvel = -(sprite[i].zvel>>1); + } + dax = sprite[i].xvel; day = sprite[i].yvel; + dist = dax*dax+day*day; + if (dist < 512) + { + bombexplode(i); + goto bulletisdeletedskip; + } + if (dist < 4096) + { + sprite[i].xrepeat = ((4096+2048)*16) / (dist+2048); + sprite[i].yrepeat = sprite[i].xrepeat; + sprite[i].xoffset = (krand()&15)-8; + sprite[i].yoffset = (krand()&15)-8; + } + if (mulscale30(krand(),dist) == 0) + { + sprite[i].xvel -= ksgn(sprite[i].xvel); + sprite[i].yvel -= ksgn(sprite[i].yvel); + sprite[i].zvel -= ksgn(sprite[i].zvel); + } + } + + //Check for bouncy objects before killing bullet + if ((hitobject&0xc000) == 16384) //Bullet hit a ceiling/floor + { + k = sector[hitobject&(MAXSECTORS-1)].wallptr; l = wall[k].point2; + daang = getangle(wall[l].x-wall[k].x,wall[l].y-wall[k].y); + + getzsofslope(hitobject&(MAXSECTORS-1),sprite[i].x,sprite[i].y,&k,&l); + if (sprite[i].z < ((k+l)>>1)) k = sector[hitobject&(MAXSECTORS-1)].ceilingheinum; + else k = sector[hitobject&(MAXSECTORS-1)].floorheinum; + + dax = mulscale14(k,sintable[(daang)&2047]); + day = mulscale14(k,sintable[(daang+1536)&2047]); + daz = 4096; + + k = sprite[i].xvel*dax+sprite[i].yvel*day+mulscale4(sprite[i].zvel,daz); + l = dax*dax+day*day+daz*daz; + if ((klabs(k)>>14) < l) + { + k = divscale17(k,l); + sprite[i].xvel -= mulscale16(dax,k); + sprite[i].yvel -= mulscale16(day,k); + sprite[i].zvel -= mulscale12(daz,k); + } + wsayfollow("bouncy.wav",4096L+(krand()&127)-64,255,&sprite[i].x,&sprite[i].y,1); + hitobject = 0; + sprite[i].owner = -1; //Bullet turns evil! + } + else if ((hitobject&0xc000) == 32768) //Bullet hit a wall + { + if (wall[hitobject&4095].lotag == 8) + { + dax = sprite[i].xvel; day = sprite[i].yvel; + if ((sprite[i].picnum != BOMB) || (dax*dax+day*day >= 512)) + { + k = (hitobject&4095); l = wall[k].point2; + j = getangle(wall[l].x-wall[k].x,wall[l].y-wall[k].y)+512; + + //k = cos(ang) * sin(ang) * 2 + k = mulscale13(sintable[(j+512)&2047],sintable[j&2047]); + //l = cos(ang * 2) + l = sintable[((j<<1)+512)&2047]; + + ox = sprite[i].xvel; oy = sprite[i].yvel; + dax = -ox; day = -oy; + sprite[i].xvel = dmulscale14(day,k,dax,l); + sprite[i].yvel = dmulscale14(dax,k,-day,l); + + if (sprite[i].picnum == BOMB) + { + sprite[i].xvel -= (sprite[i].xvel>>3); + sprite[i].yvel -= (sprite[i].yvel>>3); + sprite[i].zvel -= (sprite[i].zvel>>3); + } + ox -= sprite[i].xvel; oy -= sprite[i].yvel; + dist = ((ox*ox+oy*oy)>>8); + wsayfollow("bouncy.wav",4096L+(krand()&127)-64,min(dist,256),&sprite[i].x,&sprite[i].y,1); + hitobject = 0; + sprite[i].owner = -1; //Bullet turns evil! + } + } + } + else if ((hitobject&0xc000) == 49152) //Bullet hit a sprite + { + if (sprite[hitobject&4095].picnum == BOUNCYMAT) + { + if ((sprite[hitobject&4095].cstat&48) == 0) + { + sprite[i].xvel = -sprite[i].xvel; + sprite[i].yvel = -sprite[i].yvel; + sprite[i].zvel = -sprite[i].zvel; + dist = 255; + } + else if ((sprite[hitobject&4095].cstat&48) == 16) + { + j = sprite[hitobject&4095].ang; + + //k = cos(ang) * sin(ang) * 2 + k = mulscale13(sintable[(j+512)&2047],sintable[j&2047]); + //l = cos(ang * 2) + l = sintable[((j<<1)+512)&2047]; + + ox = sprite[i].xvel; oy = sprite[i].yvel; + dax = -ox; day = -oy; + sprite[i].xvel = dmulscale14(day,k,dax,l); + sprite[i].yvel = dmulscale14(dax,k,-day,l); + + ox -= sprite[i].xvel; oy -= sprite[i].yvel; + dist = ((ox*ox+oy*oy)>>8); + } + sprite[i].owner = -1; //Bullet turns evil! + wsayfollow("bouncy.wav",4096L+(krand()&127)-64,min(dist,256),&sprite[i].x,&sprite[i].y,1); + hitobject = 0; + } + } + + if (hitobject != 0) + { + if ((sprite[i].picnum == MISSILE) || (sprite[i].picnum == BOMB)) + { + if ((hitobject&0xc000) == 49152) + if (sprite[hitobject&4095].lotag == 5) //Basketball hoop + { + wsayfollow("niceshot.wav",3840L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + deletesprite((short)i); + goto bulletisdeletedskip; + } + + bombexplode(i); + goto bulletisdeletedskip; + } + + if ((hitobject&0xc000) == 16384) //Hits a ceiling / floor + { + wsayfollow("bullseye.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + deletesprite((short)i); + goto bulletisdeletedskip; + } + else if ((hitobject&0xc000) == 32768) //Bullet hit a wall + { + if (wall[hitobject&4095].picnum == KENPICTURE) + { + if (waloff[MAXTILES-1] != 0) + wall[hitobject&4095].picnum = MAXTILES-1; + wsayfollow("hello.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); //Ken says, "Hello... how are you today!" + } + else + wsayfollow("bullseye.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + + deletesprite((short)i); + goto bulletisdeletedskip; + } + else if ((hitobject&0xc000) == 49152) //Bullet hit a sprite + { + if ((sprite[hitobject&4095].lotag == 5) && (sprite[i].picnum == GRABBER)) { // Basketball hoop (Andy's addition) + wsayfollow("niceshot.wav",3840L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + switch (krand() & 63) { + case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: + sprite[i].picnum = COIN; break; + case 10: case 11: case 12: case 13: case 14: case 15: case 16: + sprite[i].picnum = DIAMONDS; break; + case 17: case 18: case 19: + sprite[i].picnum = COINSTACK; break; + case 20: case 21: case 22: case 23: + sprite[i].picnum = GIFTBOX; break; + case 24: case 25: + sprite[i].picnum = GRABCANNON; break; + case 26: case 27: + sprite[i].picnum = LAUNCHER; break; + case 28: case 29: case 30: + sprite[i].picnum = CANNON; break; + case 31: + sprite[i].picnum = AIRPLANE; break; + default: + deletesprite((short)i); + goto bulletisdeletedskip; + } + sprite[i].xvel = sprite[i].yvel = sprite[i].zvel = 0; + sprite[i].cstat &= ~0x83; //Should not clip, foot-z + changespritestat(i,12); + goto bulletisdeletedskip; + } + + //Check if bullet hit a player & find which player it was... + if (sprite[hitobject&4095].picnum == PLAYER) + for(j=connecthead;j>=0;j=connectpoint2[j]) + if (sprite[i].owner != j+4096) + if (playersprite[j] == (hitobject&4095)) + { + wsayfollow("ouch.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + if (sprite[i].picnum == GRABBER) { // Andy did this + k = ((sprite[i].xrepeat * sprite[i].yrepeat) * 3) >> 9; + changehealth((sprite[i].owner - 4096),k); + changehealth(j,-k); + } + else changehealth(j,-mulscale8(sprite[i].xrepeat,sprite[i].yrepeat)); + deletesprite((short)i); + goto bulletisdeletedskip; + } + + //Check if bullet hit any monsters... + j = (hitobject&4095); //j is the spritenum that the bullet (spritenum i) hit + if (sprite[i].owner != j) + { + switch(sprite[j].picnum) + { + case BROWNMONSTER: + if (sprite[j].lotag > 0) { + if (sprite[i].picnum == GRABBER) { // Andy did this + k = ((sprite[i].xrepeat * sprite[i].yrepeat) * 3) >> 9; + changehealth((sprite[i].owner - 4096),k); + sprite[j].lotag -= k; + } + sprite[j].lotag -= mulscale8(sprite[i].xrepeat,sprite[i].yrepeat); + } + if (sprite[j].lotag > 0) + { + if (sprite[j].lotag <= 25) sprite[j].cstat |= 2; + wsayfollow("hurt.wav",4096L+(krand()&511)-256,256L,&sprite[i].x,&sprite[i].y,1); + } + else + { + wsayfollow("mondie.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + sprite[j].z += ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<1); + sprite[j].picnum = GIFTBOX; + sprite[j].cstat &= ~0x83; //Should not clip, foot-z + + spawnsprite(k,sprite[j].x,sprite[j].y,sprite[j].z, + 0,-4,0,32,64,64,0,0,EXPLOSION,sprite[j].ang, + 0,0,0,j,sprite[j].sectnum,5,31,0,0); + //31=Time left for explosion to stay + + changespritestat(j,12); + } + deletesprite((short)i); + goto bulletisdeletedskip; + case EVILAL: + wsayfollow("blowup.wav",5144L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + sprite[j].picnum = EVILALGRAVE; + sprite[j].cstat = 0; + sprite[j].xvel = (krand()&255)-128; + sprite[j].yvel = (krand()&255)-128; + sprite[j].zvel = (krand()&4095)-3072; + changespritestat(j,9); + + deletesprite((short)i); + goto bulletisdeletedskip; + case AL: + wsayfollow("blowup.wav",5144L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + sprite[j].xrepeat += 2; + sprite[j].yrepeat += 2; + if (sprite[j].yrepeat >= 38) + { + sprite[j].picnum = EVILAL; + //sprite[j].cstat |= 2; //Make him transluscent + changespritestat(j,10); + } + deletesprite((short)i); + goto bulletisdeletedskip; + default: + wsayfollow("bullseye.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + deletesprite((short)i); + goto bulletisdeletedskip; + } + } + } + } + } +bulletisdeletedskip: continue; + } + + //Go through monster waiting for you list + for(i=headspritestat[2];i>=0;i=nexti) + { + nexti = nextspritestat[i]; + + if ((nummoves-i)&15) continue; + + //Use dot product to see if monster's angle is towards a player + for(p=connecthead;p>=0;p=connectpoint2[p]) + if (sintable[(sprite[i].ang+512)&2047]*(posx[p]-sprite[i].x) + sintable[sprite[i].ang&2047]*(posy[p]-sprite[i].y) >= 0) + if (cansee(sprite[i].x,sprite[i].y,sprite[i].z-(tilesizy[sprite[i].picnum]<<7),sprite[i].sectnum,posx[p],posy[p],posz[p],cursectnum[p]) == 1) + { + changespritestat(i,1); + //if (sprite[i].lotag == 100) + //{ + wsayfollow("iseeyou.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,1); + // sprite[i].lotag = 99; + //} + } + } + + //Go through smoke sprites + for(i=headspritestat[3];i>=0;i=nexti) + { + nexti = nextspritestat[i]; + + sprite[i].z -= (TICSPERFRAME<<6); + sprite[i].lotag -= TICSPERFRAME; + if (sprite[i].lotag < 0) deletesprite(i); + } + + //Go through splash sprites + for(i=headspritestat[4];i>=0;i=nexti) + { + nexti = nextspritestat[i]; + + sprite[i].lotag -= TICSPERFRAME; + sprite[i].picnum = SPLASH + ((63-sprite[i].lotag)>>4); + if (sprite[i].lotag < 0) deletesprite(i); + } + + //Go through explosion sprites + for(i=headspritestat[5];i>=0;i=nexti) + { + nexti = nextspritestat[i]; + + sprite[i].lotag -= TICSPERFRAME; + if (sprite[i].lotag < 0) deletesprite(i); + } + + //Go through bomb spriral-explosion sprites + for(i=headspritestat[7];i>=0;i=nexti) + { + nexti = nextspritestat[i]; + + sprite[i].xrepeat = (sprite[i].lotag>>2); + sprite[i].yrepeat = (sprite[i].lotag>>2); + sprite[i].lotag -= (TICSPERFRAME<<2); + if (sprite[i].lotag < 0) { deletesprite(i); continue; } + + if ((nummoves-i)&statrate[7]) continue; + + sprite[i].x += ((sprite[i].xvel*TICSPERFRAME)>>2); + sprite[i].y += ((sprite[i].yvel*TICSPERFRAME)>>2); + sprite[i].z += ((sprite[i].zvel*TICSPERFRAME)>>2); + + sprite[i].zvel += (TICSPERFRAME<<9); + if (sprite[i].z < sector[sprite[i].sectnum].ceilingz+(4<<8)) + { + sprite[i].z = sector[sprite[i].sectnum].ceilingz+(4<<8); + sprite[i].zvel = -(sprite[i].zvel>>1); + } + if (sprite[i].z > sector[sprite[i].sectnum].floorz-(4<<8)) + { + sprite[i].z = sector[sprite[i].sectnum].floorz-(4<<8); + sprite[i].zvel = -(sprite[i].zvel>>1); + } + } + + //EVILALGRAVE shrinking list + for(i=headspritestat[9];i>=0;i=nexti) + { + nexti = nextspritestat[i]; + + sprite[i].xrepeat = (sprite[i].lotag>>2); + sprite[i].yrepeat = (sprite[i].lotag>>2); + sprite[i].lotag -= TICSPERFRAME; + if (sprite[i].lotag < 0) { deletesprite(i); continue; } + + if ((nummoves-i)&statrate[9]) continue; + + sprite[i].x += (sprite[i].xvel*TICSPERFRAME); + sprite[i].y += (sprite[i].yvel*TICSPERFRAME); + sprite[i].z += (sprite[i].zvel*TICSPERFRAME); + + sprite[i].zvel += (TICSPERFRAME<<8); + if (sprite[i].z < sector[sprite[i].sectnum].ceilingz) + { + sprite[i].z = sector[sprite[i].sectnum].ceilingz; + sprite[i].xvel -= (sprite[i].xvel>>2); + sprite[i].yvel -= (sprite[i].yvel>>2); + sprite[i].zvel = -(sprite[i].zvel>>1); + } + if (sprite[i].z > sector[sprite[i].sectnum].floorz) + { + sprite[i].z = sector[sprite[i].sectnum].floorz; + sprite[i].xvel -= (sprite[i].xvel>>2); + sprite[i].yvel -= (sprite[i].yvel>>2); + sprite[i].zvel = -(sprite[i].zvel>>1); + } + } + + //Re-spawning sprite list + for(i=headspritestat[11];i>=0;i=nexti) + { + nexti = nextspritestat[i]; + + sprite[i].extra -= TICSPERFRAME; + if (sprite[i].extra < 0) + { + wsayfollow("warp.wav",6144L+(krand()&127)-64,128L,&sprite[i].x,&sprite[i].y,0); + sprite[i].cstat &= ~0x8000; + sprite[i].extra = -1; + changespritestat((short)i,0); + } + } +} + +void activatehitag(short dahitag) +{ + long i, nexti; + + for(i=0;i=0;i=nexti) + { + nexti = nextspritestat[i]; + if (sprite[i].hitag == dahitag) operatesprite(i); + } +} + +void bombexplode(long i) +{ + long j, nextj, k, daang, dax, day, dist; + + spawnsprite(j,sprite[i].x,sprite[i].y,sprite[i].z,0,-4,0, + 32,64,64,0,0,EXPLOSION,sprite[i].ang, + 0,0,0,sprite[i].owner,sprite[i].sectnum,5,31,0,0); + //31=Time left for explosion to stay + + for(k=0;k<12;k++) + { + spawnsprite(j,sprite[i].x,sprite[i].y,sprite[i].z+(8<<8),2,-4,0, + 32,24,24,0,0,EXPLOSION,sprite[i].ang, + (krand()>>7)-256,(krand()>>7)-256,(krand()>>2)-8192, + sprite[i].owner,sprite[i].sectnum,7,96,0,0); + //96=Time left for smoke to be alive + } + + for(j=connecthead;j>=0;j=connectpoint2[j]) + { + dist = (posx[j]-sprite[i].x)*(posx[j]-sprite[i].x); + dist += (posy[j]-sprite[i].y)*(posy[j]-sprite[i].y); + dist += ((posz[j]-sprite[i].z)>>4)*((posz[j]-sprite[i].z)>>4); + if (dist < 4194304) + if (cansee(sprite[i].x,sprite[i].y,sprite[i].z-(tilesizy[sprite[i].picnum]<<7),sprite[i].sectnum,posx[j],posy[j],posz[j],cursectnum[j]) == 1) + { + k = ((32768/((dist>>16)+4))>>5); + if (j == myconnectindex) + { + daang = getangle(posx[j]-sprite[i].x,posy[j]-sprite[i].y); + dax = ((k*sintable[(daang+512)&2047])>>14); + day = ((k*sintable[daang&2047])>>14); + fvel += ((dax*sintable[(ang[j]+512)&2047]+day*sintable[ang[j]&2047])>>14); + svel += ((day*sintable[(ang[j]+512)&2047]-dax*sintable[ang[j]&2047])>>14); + } + changehealth(j,-k); //if changehealth returns 1, you're dead + } + } + + for(k=1;k<=2;k++) //Check for hurting monsters + { + for(j=headspritestat[k];j>=0;j=nextj) + { + nextj = nextspritestat[j]; + + dist = (sprite[j].x-sprite[i].x)*(sprite[j].x-sprite[i].x); + dist += (sprite[j].y-sprite[i].y)*(sprite[j].y-sprite[i].y); + dist += ((sprite[j].z-sprite[i].z)>>4)*((sprite[j].z-sprite[i].z)>>4); + if (dist >= 4194304) continue; + if (cansee(sprite[i].x,sprite[i].y,sprite[i].z-(tilesizy[sprite[i].picnum]<<7),sprite[i].sectnum,sprite[j].x,sprite[j].y,sprite[j].z-(tilesizy[sprite[j].picnum]<<7),sprite[j].sectnum) == 0) + continue; + if (sprite[j].picnum == BROWNMONSTER) + { + sprite[j].z += ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<1); + sprite[j].picnum = GIFTBOX; + sprite[j].cstat &= ~0x83; //Should not clip, foot-z + changespritestat(j,12); + } + } + } + + for(j=headspritestat[10];j>=0;j=nextj) //Check for EVILAL's + { + nextj = nextspritestat[j]; + + dist = (sprite[j].x-sprite[i].x)*(sprite[j].x-sprite[i].x); + dist += (sprite[j].y-sprite[i].y)*(sprite[j].y-sprite[i].y); + dist += ((sprite[j].z-sprite[i].z)>>4)*((sprite[j].z-sprite[i].z)>>4); + if (dist >= 4194304) continue; + if (cansee(sprite[i].x,sprite[i].y,sprite[i].z-(tilesizy[sprite[i].picnum]<<7),sprite[i].sectnum,sprite[j].x,sprite[j].y,sprite[j].z-(tilesizy[sprite[j].picnum]<<7),sprite[j].sectnum) == 0) + continue; + + sprite[j].picnum = EVILALGRAVE; + sprite[j].cstat = 0; + sprite[j].xvel = (krand()&255)-128; + sprite[j].yvel = (krand()&255)-128; + sprite[j].zvel = (krand()&4095)-3072; + changespritestat(j,9); + } + + wsayfollow("blowup.wav",3840L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,0); + deletesprite((short)i); +} + +void processinput(short snum) +{ + long oldposx, oldposy, nexti; + long i, j, k, doubvel, xvect, yvect, goalz; + long dax, day, dax2, day2, odax, oday, odax2, oday2; + short startwall, endwall; + char *ptr; + + //SHARED KEYS: + //Movement code + if ((ssync[snum].fvel|ssync[snum].svel) != 0) + { + doubvel = (TICSPERFRAME<<((ssync[snum].bits&256)>0)); + + xvect = 0, yvect = 0; + if (ssync[snum].fvel != 0) + { + xvect += ((((long)ssync[snum].fvel)*doubvel*(long)sintable[(ang[snum]+512)&2047])>>3); + yvect += ((((long)ssync[snum].fvel)*doubvel*(long)sintable[ang[snum]&2047])>>3); + } + if (ssync[snum].svel != 0) + { + xvect += ((((long)ssync[snum].svel)*doubvel*(long)sintable[ang[snum]&2047])>>3); + yvect += ((((long)ssync[snum].svel)*doubvel*(long)sintable[(ang[snum]+1536)&2047])>>3); + } + if (flytime[snum] > lockclock) { xvect += xvect; yvect += yvect; } // DOuble flying speed + clipmove(&posx[snum],&posy[snum],&posz[snum],&cursectnum[snum],xvect,yvect,128L,4<<8,4<<8,CLIPMASK0); + revolvedoorstat[snum] = 1; + } + else + { + revolvedoorstat[snum] = 0; + } + + sprite[playersprite[snum]].cstat &= ~1; + //Push player away from walls if clipmove doesn't work + if (pushmove(&posx[snum],&posy[snum],&posz[snum],&cursectnum[snum],128L,4<<8,4<<8,CLIPMASK0) < 0) + changehealth(snum,-1000); //If this screws up, then instant death!!! + + // Getzrange returns the highest and lowest z's for an entire box, + // NOT just a point. This prevents you from falling off cliffs + // when you step only slightly over the cliff. + getzrange(posx[snum],posy[snum],posz[snum],cursectnum[snum],&globhiz,&globhihit,&globloz,&globlohit,128L,CLIPMASK0); + sprite[playersprite[snum]].cstat |= 1; + + if (ssync[snum].avel != 0) //ang += avel * constant + { //ENGINE calculates avel for you + doubvel = TICSPERFRAME; + if ((ssync[snum].bits&256) > 0) //Lt. shift makes turn velocity 50% faster + doubvel += (TICSPERFRAME>>1); + ang[snum] += ((((long)ssync[snum].avel)*doubvel)>>4); + ang[snum] &= 2047; + } + + if (health[snum] < 0) + { + health[snum] -= TICSPERFRAME; + if (health[snum] <= -160) + { + hvel[snum] = 0; + if (snum == myconnectindex) + fvel = 0, svel = 0, avel = 0, keystatus[3] = 1; + + deaths[snum]++; + health[snum] = 100; + numbombs[snum] = 0; + numgrabbers[snum] = 0; + nummissiles[snum] = 0; + flytime[snum] = 0; + + findrandomspot(&posx[snum],&posy[snum],&cursectnum[snum]); + posz[snum] = getflorzofslope(cursectnum[snum],posx[snum],posy[snum])-(1<<8); + horiz[snum] = 100; + ang[snum] = (krand()&2047); + + sprite[playersprite[snum]].x = posx[snum]; + sprite[playersprite[snum]].y = posy[snum]; + sprite[playersprite[snum]].z = posz[snum]+EYEHEIGHT; + sprite[playersprite[snum]].picnum = PLAYER; + sprite[playersprite[snum]].ang = ang[snum]; + sprite[playersprite[snum]].xrepeat = 64; + sprite[playersprite[snum]].yrepeat = 64; + changespritesect(playersprite[snum],cursectnum[snum]); + + drawstatusbar(snum); // Andy did this + + i = playersprite[snum]; + wsayfollow("zipguns.wav",4096L+(krand()&127)-64,256L,&sprite[i].x,&sprite[i].y,1); + for(k=0;k<16;k++) + { + spawnsprite(j,sprite[i].x,sprite[i].y,sprite[i].z+(8<<8),2,-4,0, + 32,24,24,0,0,EXPLOSION,sprite[i].ang, + (krand()&511)-256,(krand()&511)-256,(krand()&16384)-8192, + sprite[i].owner,sprite[i].sectnum,7,96,0,0); + //96=Time left for smoke to be alive + } + } + else + { + sprite[playersprite[snum]].xrepeat = max(((128+health[snum])>>1),0); + sprite[playersprite[snum]].yrepeat = max(((128+health[snum])>>1),0); + + hvel[snum] += (TICSPERFRAME<<2); + horiz[snum] = max(horiz[snum]-4,0); + posz[snum] += hvel[snum]; + if (posz[snum] > globloz-(4<<8)) + { + posz[snum] = globloz-(4<<8); + horiz[snum] = min(horiz[snum]+5,200); + hvel[snum] = 0; + } + } + } + + if (((ssync[snum].bits&8) > 0) && (horiz[snum] > 100-(200>>1))) horiz[snum] -= 4; //- + if (((ssync[snum].bits&4) > 0) && (horiz[snum] < 100+(200>>1))) horiz[snum] += 4; //+ + + goalz = globloz-EYEHEIGHT; + if (sector[cursectnum[snum]].lotag == 4) //slime sector + if ((globlohit&0xc000) != 49152) //You're not on a sprite + { + goalz = globloz-(8<<8); + if (posz[snum] >= goalz-(2<<8)) + { + clipmove(&posx[snum],&posy[snum],&posz[snum],&cursectnum[snum],-TICSPERFRAME<<14,-TICSPERFRAME<<14,128L,4<<8,4<<8,CLIPMASK0); + + if (slimesoundcnt[snum] >= 0) + { + slimesoundcnt[snum] -= TICSPERFRAME; + while (slimesoundcnt[snum] < 0) + { + slimesoundcnt[snum] += 120; + wsayfollow("slime.wav",4096L+(krand()&127)-64,256L,&posx[snum],&posy[snum],1); + } + } + } + } + if (goalz < globhiz+(16<<8)) //ceiling&floor too close + goalz = ((globloz+globhiz)>>1); + //goalz += mousz; + if (health[snum] >= 0) + { + if ((ssync[snum].bits&1) > 0) //A (stand high) + { + if (flytime[snum] <= lockclock) + { + if (posz[snum] >= globloz-(32<<8)) + { + goalz -= (16<<8); + if (ssync[snum].bits&256) goalz -= (24<<8); + } + } + else + { + hvel[snum] -= 192; + if (ssync[snum].bits&256) hvel[snum] -= 192; + } + } + if ((ssync[snum].bits&2) > 0) //Z (stand low) + { + if (flytime[snum] <= lockclock) + { + goalz += (12<<8); + if (ssync[snum].bits&256) goalz += (12<<8); + } + else + { + hvel[snum] += 192; + if (ssync[snum].bits&256) hvel[snum] += 192; + } + } + } + + if (flytime[snum] <= lockclock) + { + if (posz[snum] < goalz) + hvel[snum] += (TICSPERFRAME<<4); + else + hvel[snum] = (((goalz-posz[snum])*TICSPERFRAME)>>5); + } + else + { + hvel[snum] -= (hvel[snum]>>2); + hvel[snum] -= ksgn(hvel[snum]); + } + + posz[snum] += hvel[snum]; + if (posz[snum] > globloz-(4<<8)) posz[snum] = globloz-(4<<8), hvel[snum] = 0; + if (posz[snum] < globhiz+(4<<8)) posz[snum] = globhiz+(4<<8), hvel[snum] = 0; + + if (dimensionmode[snum] != 3) + { + if (((ssync[snum].bits&32) > 0) && (zoom[snum] > 48)) zoom[snum] -= (zoom[snum]>>4); + if (((ssync[snum].bits&16) > 0) && (zoom[snum] < 4096)) zoom[snum] += (zoom[snum]>>4); + } + + //Update sprite representation of player + // -should be after movement, but before shooting code + setsprite(playersprite[snum],posx[snum],posy[snum],posz[snum]+EYEHEIGHT); + sprite[playersprite[snum]].ang = ang[snum]; + + if (health[snum] >= 0) + { + if ((cursectnum[snum] < 0) || (cursectnum[snum] >= numsectors)) + { //How did you get in the wrong sector? + wsayfollow("ouch.wav",4096L+(krand()&127)-64,64L,&posx[snum],&posy[snum],1); + changehealth(snum,-TICSPERFRAME); + } + else if (globhiz+(8<<8) > globloz) + { //Ceiling and floor are smooshing you! + wsayfollow("ouch.wav",4096L+(krand()&127)-64,64L,&posx[snum],&posy[snum],1); + changehealth(snum,-TICSPERFRAME); + } + } + + if ((waterfountainwall[snum] >= 0) && (health[snum] >= 0)) + if ((wall[neartagwall].lotag != 7) || ((ssync[snum].bits&1024) == 0)) + { + i = waterfountainwall[snum]; + if (wall[i].overpicnum == USEWATERFOUNTAIN) + wall[i].overpicnum = WATERFOUNTAIN; + else if (wall[i].picnum == USEWATERFOUNTAIN) + wall[i].picnum = WATERFOUNTAIN; + + waterfountainwall[snum] = -1; + } + + if ((ssync[snum].bits&1024) > 0) //Space bar + { + //Continuous triggers... + + neartag(posx[snum],posy[snum],posz[snum],cursectnum[snum],ang[snum],&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1024L,3); + if (neartagsector == -1) + { + i = cursectnum[snum]; + if ((sector[i].lotag|sector[i].hitag) != 0) + neartagsector = i; + } + + if (wall[neartagwall].lotag == 7) //Water fountain + { + if (wall[neartagwall].overpicnum == WATERFOUNTAIN) + { + wsayfollow("water.wav",4096L+(krand()&127)-64,256L,&posx[snum],&posy[snum],1); + wall[neartagwall].overpicnum = USEWATERFOUNTAIN; + waterfountainwall[snum] = neartagwall; + } + else if (wall[neartagwall].picnum == WATERFOUNTAIN) + { + wsayfollow("water.wav",4096L+(krand()&127)-64,256L,&posx[snum],&posy[snum],1); + wall[neartagwall].picnum = USEWATERFOUNTAIN; + waterfountainwall[snum] = neartagwall; + } + + if (waterfountainwall[snum] >= 0) + { + waterfountaincnt[snum] -= TICSPERFRAME; + while (waterfountaincnt[snum] < 0) + { + waterfountaincnt[snum] += 120; + wsayfollow("water.wav",4096L+(krand()&127)-64,256L,&posx[snum],&posy[snum],1); + changehealth(snum,2); + } + } + } + + //1-time triggers... + if ((oflags[snum]&1024) == 0) + { + if (neartagsector >= 0) + if (sector[neartagsector].hitag == 0) + operatesector(neartagsector); + + if (neartagwall >= 0) + if (wall[neartagwall].lotag == 2) //Switch + { + activatehitag(wall[neartagwall].hitag); + + j = wall[neartagwall].overpicnum; + if (j == SWITCH1ON) //1-time switch + { + wall[neartagwall].overpicnum = GIFTBOX; + wall[neartagwall].lotag = 0; + wall[neartagwall].hitag = 0; + } + if (j == GIFTBOX) //1-time switch + { + wall[neartagwall].overpicnum = SWITCH1ON; + wall[neartagwall].lotag = 0; + wall[neartagwall].hitag = 0; + } + if (j == SWITCH2ON) wall[neartagwall].overpicnum = SWITCH2OFF; + if (j == SWITCH2OFF) wall[neartagwall].overpicnum = SWITCH2ON; + if (j == SWITCH3ON) wall[neartagwall].overpicnum = SWITCH3OFF; + if (j == SWITCH3OFF) wall[neartagwall].overpicnum = SWITCH3ON; + + i = wall[neartagwall].point2; + dax = ((wall[neartagwall].x+wall[i].x)>>1); + day = ((wall[neartagwall].y+wall[i].y)>>1); + wsayfollow("switch.wav",4096L+(krand()&255)-128,256L,&dax,&day,0); + } + + if (neartagsprite >= 0) + { + if (sprite[neartagsprite].lotag == 1) + { //if you're shoving innocent little AL around, he gets mad! + if (sprite[neartagsprite].picnum == AL) + { + sprite[neartagsprite].picnum = EVILAL; + sprite[neartagsprite].cstat |= 2; //Make him transluscent + sprite[neartagsprite].xrepeat = 38; + sprite[neartagsprite].yrepeat = 38; + changespritestat(neartagsprite,10); + } + } + if (sprite[neartagsprite].lotag == 4) + { + activatehitag(sprite[neartagsprite].hitag); + + j = sprite[neartagsprite].picnum; + if (j == SWITCH1ON) //1-time switch + { + sprite[neartagsprite].picnum = GIFTBOX; + sprite[neartagsprite].lotag = 0; + sprite[neartagsprite].hitag = 0; + } + if (j == GIFTBOX) //1-time switch + { + sprite[neartagsprite].picnum = SWITCH1ON; + sprite[neartagsprite].lotag = 0; + sprite[neartagsprite].hitag = 0; + } + if (j == SWITCH2ON) sprite[neartagsprite].picnum = SWITCH2OFF; + if (j == SWITCH2OFF) sprite[neartagsprite].picnum = SWITCH2ON; + if (j == SWITCH3ON) sprite[neartagsprite].picnum = SWITCH3OFF; + if (j == SWITCH3OFF) sprite[neartagsprite].picnum = SWITCH3ON; + + dax = sprite[neartagsprite].x; + day = sprite[neartagsprite].y; + wsayfollow("switch.wav",4096L+(krand()&255)-128,256L,&dax,&day,0); + } + } + } + } + + if ((ssync[snum].bits & 2048) > 0) { // Shoot a bullet + if ((numbombs[snum] == 0) && (((ssync[snum].bits >> 13) & 7) == 2) && (myconnectindex == snum)) + locselectedgun = 0; + if ((nummissiles[snum] == 0) && (((ssync[snum].bits >> 13) & 7) == 3) && (myconnectindex == snum)) + locselectedgun = 1; + if ((numgrabbers[snum] == 0) && (((ssync[snum].bits >> 13) & 7) == 4) && (myconnectindex == snum)) + locselectedgun = 1; + + if ((health[snum] >= 0) || ((krand() & 127) > -health[snum])) + switch((ssync[snum].bits >> 13) & 7) { + case 0: + if (lockclock > lastchaingun[snum]+8) { + lastchaingun[snum] = lockclock; + shootgun(snum,posx[snum],posy[snum],posz[snum],ang[snum],horiz[snum],cursectnum[snum],0); + } + break; + case 1: + if ((oflags[snum] & 2048) == 0) + shootgun(snum,posx[snum],posy[snum],posz[snum],ang[snum],horiz[snum],cursectnum[snum],1); + break; + case 2: + if ((oflags[snum] & 2048) == 0) + if (numbombs[snum] > 0) { + shootgun(snum,posx[snum],posy[snum],posz[snum],ang[snum],horiz[snum],cursectnum[snum],2); + changenumbombs(snum,-1); + } + break; + case 3: + if ((oflags[snum] & 2048) == 0) + if (nummissiles[snum] > 0) { + shootgun(snum,posx[snum],posy[snum],posz[snum],ang[snum],horiz[snum],cursectnum[snum],3); + changenummissiles(snum,-1); + } + break; + case 4: + if ((oflags[snum] & 2048) == 0) + if (numgrabbers[snum] > 0) { + shootgun(snum,posx[snum],posy[snum],posz[snum],ang[snum],horiz[snum],cursectnum[snum],4); + changenumgrabbers(snum,-1); + } + break; + } + } + + if ((ssync[snum].bits&4096) > (oflags[snum]&4096)) //Keypad enter + { + dimensionmode[snum]++; + if (dimensionmode[snum] > 3) dimensionmode[snum] = 1; + } + + oflags[snum] = ssync[snum].bits; +} + +void view(short snum, long *vx, long *vy, long *vz, short *vsectnum, short ang, long horiz) +{ + spritetype *sp; + long i, nx, ny, nz, hx, hy, hz, hitx, hity, hitz; + short bakcstat, hitsect, hitwall, hitsprite, daang; + + nx = (sintable[(ang+1536)&2047]>>4); + ny = (sintable[(ang+1024)&2047]>>4); + nz = (horiz-100)*128; + + sp = &sprite[snum]; + + bakcstat = sp->cstat; + sp->cstat &= (short)~0x101; + + updatesectorz(*vx,*vy,*vz,vsectnum); + hitscan(*vx,*vy,*vz,*vsectnum,nx,ny,nz,&hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + hx = hitx-(*vx); hy = hity-(*vy); + if (klabs(nx)+klabs(ny) > klabs(hx)+klabs(hy)) + { + *vsectnum = hitsect; + if (hitwall >= 0) + { + daang = getangle(wall[wall[hitwall].point2].x-wall[hitwall].x, + wall[wall[hitwall].point2].y-wall[hitwall].y); + + i = nx*sintable[daang]+ny*sintable[(daang+1536)&2047]; + if (klabs(nx) > klabs(ny)) hx -= mulscale28(nx,i); + else hy -= mulscale28(ny,i); + } + else if (hitsprite < 0) + { + if (klabs(nx) > klabs(ny)) hx -= (nx>>5); + else hy -= (ny>>5); + } + if (klabs(nx) > klabs(ny)) i = divscale16(hx,nx); + else i = divscale16(hy,ny); + if (i < cameradist) cameradist = i; + } + *vx = (*vx)+mulscale16(nx,cameradist); + *vy = (*vy)+mulscale16(ny,cameradist); + *vz = (*vz)+mulscale16(nz,cameradist); + + updatesectorz(*vx,*vy,*vz,vsectnum); + + sp->cstat = bakcstat; +} + +#if 0 // JBF: now in the engine +void updatesectorz(long x, long y, long z, short *sectnum) +{ + walltype *wal; + long i, j, cz, fz; + + getzsofslope(*sectnum,x,y,&cz,&fz); + if ((z >= cz) && (z <= fz)) + if (inside(x,y,*sectnum) != 0) return; + + if ((*sectnum >= 0) && (*sectnum < numsectors)) + { + wal = &wall[sector[*sectnum].wallptr]; + j = sector[*sectnum].wallnum; + do + { + i = wal->nextsector; + if (i >= 0) + { + getzsofslope(i,x,y,&cz,&fz); + if ((z >= cz) && (z <= fz)) + if (inside(x,y,(short)i) == 1) + { *sectnum = i; return; } + } + wal++; j--; + } while (j != 0); + } + + for(i=numsectors-1;i>=0;i--) + { + getzsofslope(i,x,y,&cz,&fz); + if ((z >= cz) && (z <= fz)) + if (inside(x,y,(short)i) == 1) + { *sectnum = i; return; } + } + + *sectnum = -1; +} +#endif + +void drawscreen(short snum, long dasmoothratio) +{ + long i, j, k=0, l, charsperline, tempint; + long x1, y1, x2, y2, ox1, oy1, ox2, oy2, dist, maxdist; + long cposx, cposy, cposz, choriz, czoom, tposx, tposy; + long tiltlock, *intptr, ovisibility, oparallaxvisibility; + short cang, tang, csect; + char ch, *ptr, *ptr2, *ptr3, *ptr4; + spritetype *tspr; + + smoothratio = max(min(dasmoothratio,65536),0); + + dointerpolations(); + + if ((snum == myconnectindex) && ((networkmode == 1) || (myconnectindex != connecthead))) + { + cposx = omyx+mulscale16(myx-omyx,smoothratio); + cposy = omyy+mulscale16(myy-omyy,smoothratio); + cposz = omyz+mulscale16(myz-omyz,smoothratio); + choriz = omyhoriz+mulscale16(myhoriz-omyhoriz,smoothratio); + cang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); + } + else + { + cposx = oposx[snum]+mulscale16(posx[snum]-oposx[snum],smoothratio); + cposy = oposy[snum]+mulscale16(posy[snum]-oposy[snum],smoothratio); + cposz = oposz[snum]+mulscale16(posz[snum]-oposz[snum],smoothratio); + choriz = ohoriz[snum]+mulscale16(horiz[snum]-ohoriz[snum],smoothratio); + cang = oang[snum]+mulscale16(((ang[snum]+1024-oang[snum])&2047)-1024,smoothratio); + } + czoom = ozoom[snum]+mulscale16(zoom[snum]-ozoom[snum],smoothratio); + + setears(cposx,cposy,(long)sintable[(cang+512)&2047]<<14,(long)sintable[cang&2047]<<14); + + if (dimensionmode[myconnectindex] == 3) + { + tempint = screensize; + + if (((loc.bits&32) > (screensizeflag&32)) && (screensize > 64)) + { + ox1 = ((xdim-screensize)>>1); + ox2 = ox1+screensize-1; + oy1 = (((ydim-32)-scale(screensize,ydim-32,xdim))>>1); + oy2 = oy1 + scale(screensize,ydim-32,xdim)-1; + screensize -= (screensize>>3); + + if (tempint > xdim) + { + screensize = xdim; + + flushperms(); + + rotatesprite((xdim-320)<<15,(ydim-32)<<16,65536L,0,STATUSBAR,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L); + i = ((xdim-320)>>1); + while (i >= 8) i -= 8, rotatesprite(i<<16,(ydim-32)<<16,65536L,0,STATUSBARFILL8,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L); + if (i >= 4) i -= 4, rotatesprite(i<<16,(ydim-32)<<16,65536L,0,STATUSBARFILL4,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L); + i = ((xdim-320)>>1)+320; + while (i <= xdim-8) rotatesprite(i<<16,(ydim-32)<<16,65536L,0,STATUSBARFILL8,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L), i += 8; + if (i <= xdim-4) rotatesprite(i<<16,(ydim-32)<<16,65536L,0,STATUSBARFILL4,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L), i += 4; + + drawstatusbar(screenpeek); // Andy did this + } + + x1 = ((xdim-screensize)>>1); + x2 = x1+screensize-1; + y1 = (((ydim-32)-scale(screensize,ydim-32,xdim))>>1); + y2 = y1 + scale(screensize,ydim-32,xdim)-1; + setview(x1,y1,x2,y2); + + // (ox1,oy1)ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + // ³ (x1,y1) ³ + // ³ ÚÄÄÄÄÄ¿ ³ + // ³ ³ ³ ³ + // ³ ÀÄÄÄÄÄÙ ³ + // ³ (x2,y2) ³ + // ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ(ox2,oy2) + + drawtilebackground(0L,0L,BACKGROUND,8,ox1,oy1,x1-1,oy2,0); + drawtilebackground(0L,0L,BACKGROUND,8,x2+1,oy1,ox2,oy2,0); + drawtilebackground(0L,0L,BACKGROUND,8,x1,oy1,x2,y1-1,0); + drawtilebackground(0L,0L,BACKGROUND,8,x1,y2+1,x2,oy2,0); + } + if (((loc.bits&16) > (screensizeflag&16)) && (screensize <= xdim)) + { + screensize += (screensize>>3); + if ((screensize > xdim) && (tempint == xdim)) + { + screensize = xdim+1; + x1 = 0; y1 = 0; + x2 = xdim-1; y2 = ydim-1; + } + else + { + if (screensize > xdim) screensize = xdim; + x1 = ((xdim-screensize)>>1); + x2 = x1+screensize-1; + y1 = (((ydim-32)-scale(screensize,ydim-32,xdim))>>1); + y2 = y1 + scale(screensize,ydim-32,xdim)-1; + } + setview(x1,y1,x2,y2); + } + screensizeflag = loc.bits; + } + + if (dimensionmode[snum] != 2) + { + if ((numplayers > 1) && (option[4] == 0)) + { + //Do not draw other views constantly if they're staying still + //It's a shame this trick will only work in screen-buffer mode + //At least screen-buffer mode covers all the HI hi-res modes + //if (vidoption == 2) + //{ + for(i=connecthead;i>=0;i=connectpoint2[i]) frame2draw[i] = 0; + frame2draw[snum] = 1; + + //2-1,3-1,4-2 + //5-2,6-2,7-2,8-3,9-3,10-3,11-3,12-4,13-4,14-4,15-4,16-5 + x1 = posx[snum]; y1 = posy[snum]; + for(j=(numplayers>>2)+1;j>0;j--) + { + maxdist = 0x80000000; + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (frame2draw[i] == 0) + { + x2 = posx[i]-x1; y2 = posy[i]-y1; + dist = dmulscale12(x2,x2,y2,y2); + + if (dist < 64) dist = 16384; + else if (dist > 16384) dist = 64; + else dist = 1048576 / dist; + + dist *= frameskipcnt[i]; + + //Increase frame rate if screen is moving + if ((posx[i] != oposx[i]) || (posy[i] != oposy[i]) || + (posz[i] != oposz[i]) || (ang[i] != oang[i]) || + (horiz[i] != ohoriz[i])) dist += dist; + + if (dist > maxdist) maxdist = dist, k = i; + } + + for(i=connecthead;i>=0;i=connectpoint2[i]) + frameskipcnt[i] += (frameskipcnt[i]>>3)+1; + frameskipcnt[k] = 0; + + frame2draw[k] = 1; + } + //} + //else + //{ + // for(i=connecthead;i>=0;i=connectpoint2[i]) frame2draw[i] = 1; + //} + + for(i=connecthead,j=0;i>=0;i=connectpoint2[i],j++) + if (frame2draw[i] != 0) + { + if (numplayers <= 4) + { + switch(j) + { + case 0: setview(0,0,(xdim>>1)-1,(ydim>>1)-1); break; + case 1: setview((xdim>>1),0,xdim-1,(ydim>>1)-1); break; + case 2: setview(0,(ydim>>1),(xdim>>1)-1,ydim-1); break; + case 3: setview((xdim>>1),(ydim>>1),xdim-1,ydim-1); break; + } + } + else + { + switch(j) + { + case 0: setview(0,0,(xdim>>2)-1,(ydim>>2)-1); break; + case 1: setview(xdim>>2,0,(xdim>>1)-1,(ydim>>2)-1); break; + case 2: setview(xdim>>1,0,xdim-(xdim>>2)-1,(ydim>>2)-1); break; + case 3: setview(xdim-(xdim>>2),0,xdim-1,(ydim>>2)-1); break; + case 4: setview(0,ydim>>2,(xdim>>2)-1,(ydim>>1)-1); break; + case 5: setview(xdim>>2,ydim>>2,(xdim>>1)-1,(ydim>>1)-1); break; + case 6: setview(xdim>>1,ydim>>2,xdim-(xdim>>2)-1,(ydim>>1)-1); break; + case 7: setview(xdim-(xdim>>2),ydim>>2,xdim-1,(ydim>>1)-1); break; + case 8: setview(0,ydim>>1,(xdim>>2)-1,ydim-(ydim>>2)-1); break; + case 9: setview(xdim>>2,ydim>>1,(xdim>>1)-1,ydim-(ydim>>2)-1); break; + case 10: setview(xdim>>1,ydim>>1,xdim-(xdim>>2)-1,ydim-(ydim>>2)-1); break; + case 11: setview(xdim-(xdim>>2),ydim>>1,xdim-1,ydim-(ydim>>2)-1); break; + case 12: setview(0,ydim-(ydim>>2),(xdim>>2)-1,ydim-1); break; + case 13: setview(xdim>>2,ydim-(ydim>>2),(xdim>>1)-1,ydim-1); break; + case 14: setview(xdim>>1,ydim-(ydim>>2),xdim-(xdim>>2)-1,ydim-1); break; + case 15: setview(xdim-(xdim>>2),ydim-(ydim>>2),xdim-1,ydim-1); break; + } + } + + if (i == snum) + { + sprite[playersprite[snum]].cstat |= 0x8000; + drawrooms(cposx,cposy,cposz,cang,choriz,cursectnum[i]); + sprite[playersprite[snum]].cstat &= ~0x8000; + analyzesprites(cposx,cposy); + } + else + { + sprite[playersprite[i]].cstat |= 0x8000; + drawrooms(posx[i],posy[i],posz[i],ang[i],horiz[i],cursectnum[i]); + sprite[playersprite[i]].cstat &= ~0x8000; + analyzesprites(posx[i],posy[i]); + } + drawmasks(); + if ((numgrabbers[i] > 0) || (nummissiles[i] > 0) || (numbombs[i] > 0)) + rotatesprite(160<<16,184L<<16,65536,0,GUNONBOTTOM,sector[cursectnum[i]].floorshade,0,2,windowx1,windowy1,windowx2,windowy2); + + if (lockclock < 384) + { + if (lockclock < 128) + rotatesprite(320<<15,200<<15,lockclock<<9,lockclock<<4,DEMOSIGN,(128-lockclock)>>2,0,1+2,windowx1,windowy1,windowx2,windowy2); + else if (lockclock < 256) + rotatesprite(320<<15,200<<15,65536,0,DEMOSIGN,0,0,2,windowx1,windowy1,windowx2,windowy2); + else + rotatesprite(320<<15,200<<15,(384-lockclock)<<9,lockclock<<4,DEMOSIGN,(lockclock-256)>>2,0,1+2,windowx1,windowy1,windowx2,windowy2); + } + + if (health[i] <= 0) + rotatesprite(320<<15,200<<15,(-health[i])<<11,(-health[i])<<5,NO,0,0,2,windowx1,windowy1,windowx2,windowy2); + } + } + else + { + //Init for screen rotation + if (getrendermode() == 0) { // JBF 20031220 + tiltlock = screentilt; + if ((tiltlock) || (detailmode)) + { + walock[MAXTILES-2] = 255; + if (waloff[MAXTILES-2] == 0) + allocache(&waloff[MAXTILES-2],320L*320L,&walock[MAXTILES-2]); + if ((tiltlock&1023) == 0) + setviewtotile(MAXTILES-2,200L>>detailmode,320L>>detailmode); + else + setviewtotile(MAXTILES-2,320L>>detailmode,320L>>detailmode); + if ((tiltlock&1023) == 512) + { //Block off unscreen section of 90ø tilted screen + j = ((320-60)>>detailmode); + for(i=(60>>detailmode)-1;i>=0;i--) + { + startumost[i] = 1; startumost[i+j] = 1; + startdmost[i] = 0; startdmost[i+j] = 0; + } + } + + i = (tiltlock&511); if (i > 256) i = 512-i; + i = sintable[i+512]*8 + sintable[i]*5L; + setaspect(i>>1,yxaspect); + } + } else { + tiltlock = screentilt; + // Ken loves to interpolate + setrollangle(oscreentilt + mulscale16(((screentilt-oscreentilt+1024)&2047)-1024,smoothratio)); + } + + if ((gotpic[FLOORMIRROR>>3]&(1<<(FLOORMIRROR&7))) > 0) + { + dist = 0x7fffffff; i = 0; + for(k=floormirrorcnt-1;k>=0;k--) + { + j = klabs(wall[sector[floormirrorsector[k]].wallptr].x-cposx); + j += klabs(wall[sector[floormirrorsector[k]].wallptr].y-cposy); + if (j < dist) dist = j, i = k; + } + + //if (cposz > sector[floormirrorsector[i]].ceilingz) i = 1-i; //SOS + + j = floormirrorsector[i]; + + if (cameradist < 0) sprite[playersprite[snum]].cstat |= 0x8000; + drawrooms(cposx,cposy,(sector[j].floorz<<1)-cposz,cang,201-choriz,j); //SOS + //drawrooms(cposx,cposy,cposz,cang,choriz,j+MAXSECTORS); //SOS + sprite[playersprite[snum]].cstat &= ~0x8000; + analyzesprites(cposx,cposy); + drawmasks(); + + //Temp horizon + if (getrendermode() == 0) { + l = scale(choriz-100,windowx2-windowx1,320)+((windowy1+windowy2)>>1); + begindrawing(); //{{{ + for(y1=windowy1,y2=windowy2;y1>2,31)<<8); + ptr4 = palookup[18]; + ptr4 += (min(klabs(y2-l)>>2,31)<<8); + + j = sintable[((y2+totalclock)<<6)&2047]; + j += sintable[((y2-totalclock)<<7)&2047]; + j >>= 14; + + //ptr2 += j; + + //for(x1=windowx1;x1<=windowx2;x1++) + // { ch = ptr[x1]; ptr[x1] = ptr3[ptr2[x1]]; ptr2[x1] = ptr4[ch]; } + + ox1 = windowx1-min(j,0); + ox2 = windowx2-max(j,0); + + for(x1=windowx1;x1>3] &= ~(1<<(FLOORMIRROR&7)); + } + + if (gotpic[DAYSKY>>3]&(1<<(DAYSKY&7))) + { + gotpic[DAYSKY>>3] &= ~(1<<(DAYSKY&7)); + pskyoff[0] = 0; pskyoff[1] = 0; pskybits = 1; + } + else if (gotpic[NIGHTSKY>>3]&(1<<(NIGHTSKY&7))) + { + gotpic[NIGHTSKY>>3] &= ~(1<<(NIGHTSKY&7)); + pskyoff[0] = 0; pskyoff[1] = 0; pskyoff[2] = 0; pskyoff[3] = 0; + pskyoff[4] = 0; pskyoff[5] = 0; pskyoff[6] = 0; pskyoff[7] = 0; + pskybits = 3; + } + + + //Over the shoulder mode + csect = cursectnum[snum]; + if (cameradist >= 0) + { + cang += cameraang; + view(playersprite[snum],&cposx,&cposy,&cposz,&csect,cang,choriz); + } + + //WARNING! Assuming (MIRRORLABEL&31) = 0 and MAXMIRRORS = 64 + intptr = (long *)&gotpic[MIRRORLABEL>>3]; // CHECK! + if (intptr[0]|intptr[1]) + for(i=MAXMIRRORS-1;i>=0;i--) + if (gotpic[(i+MIRRORLABEL)>>3]&(1<<(i&7))) + { + gotpic[(i+MIRRORLABEL)>>3] &= ~(1<<(i&7)); + + //Prepare drawrooms for drawing mirror and calculate reflected + //position into tposx, tposy, and tang (tposz == cposz) + //Must call preparemirror before drawrooms and + // completemirror after drawrooms + preparemirror(cposx,cposy,cposz,cang,choriz, + mirrorwall[i],mirrorsector[i],&tposx,&tposy,&tang); + + ovisibility = visibility; + oparallaxvisibility = parallaxvisibility; + visibility <<= 1; + parallaxvisibility <<= 1; + ptr = palookup[0]; palookup[0] = palookup[17]; palookup[17] = ptr; + + drawrooms(tposx,tposy,cposz,tang,choriz,mirrorsector[i]|MAXSECTORS); + for(j=0,tspr=&tsprite[0];jcstat&48) == 0) tspr->cstat |= 4; + analyzesprites(tposx,tposy); + drawmasks(); + + ptr = palookup[0]; palookup[0] = palookup[17]; palookup[17] = ptr; + visibility = ovisibility; + parallaxvisibility = oparallaxvisibility; + + completemirror(); //Reverse screen x-wise in this function + + break; + } + + if (cameradist < 0) sprite[playersprite[snum]].cstat |= 0x8000; + drawrooms(cposx,cposy,cposz,cang,choriz,csect); + sprite[playersprite[snum]].cstat &= ~0x8000; + analyzesprites(cposx,cposy); + drawmasks(); + + //Finish for screen rotation + if (getrendermode() == 0) { // JBF 20031220 + if ((tiltlock) || (detailmode)) + { + setviewback(); + i = (tiltlock&511); if (i > 256) i = 512-i; + i = sintable[i+512]*8 + sintable[i]*5L; + if (detailmode == 0) i >>= 1; + rotatesprite(320<<15,200<<15,i,tiltlock+512,MAXTILES-2,0,0,2+4+64,windowx1,windowy1,windowx2,windowy2); + walock[MAXTILES-2] = 1; + } + } + + if (((numgrabbers[screenpeek] > 0) || (nummissiles[screenpeek] > 0) || (numbombs[screenpeek] > 0)) && (cameradist < 0)) + { + //Reset startdmost to bottom of screen + if ((windowx1 == 0) && (windowx2 == 319) && (yxaspect == 65536) && (tiltlock == 0)) + { + x1 = 160L-(tilesizx[GUNONBOTTOM]>>1); y1 = windowy2+1; + for(i=0;i>2,0,1+2,windowx1,windowy1,windowx2,windowy2); + else if (lockclock < 256) + rotatesprite(320<<15,200<<15,65536,0,DEMOSIGN,0,0,2,windowx1,windowy1,windowx2,windowy2); + else + rotatesprite(320<<15,200<<15,(384-lockclock)<<9,lockclock<<4,DEMOSIGN,(lockclock-256)>>2,0,1+2,windowx1,windowy1,windowx2,windowy2); + } + + if (health[screenpeek] <= 0) + rotatesprite(320<<15,200<<15,(-health[screenpeek])<<11,(-health[screenpeek])<<5,NO,0,0,2,windowx1,windowy1,windowx2,windowy2); + } + } + + //Only animate lava if its picnum is on screen + //gotpic is a bit array where the tile number's bit is set + //whenever it is drawn (ceilings, walls, sprites, etc.) + if ((gotpic[SLIME>>3]&(1<<(SLIME&7))) > 0) + { + gotpic[SLIME>>3] &= ~(1<<(SLIME&7)); + if (waloff[SLIME] != 0) { + movelava((char *)waloff[SLIME]); + invalidatetile(SLIME,0,1); // JBF 20031228 + } + } + + if ((show2dsector[cursectnum[snum]>>3]&(1<<(cursectnum[snum]&7))) == 0) + searchmap(cursectnum[snum]); + + if (dimensionmode[snum] != 3) + { + //Move back pivot point + i = scale(czoom,screensize,320); + if (dimensionmode[snum] == 2) + { + clearview(0L); //Clear screen to specified color + drawmapview(cposx,cposy,i,cang); + } + drawoverheadmap(cposx,cposy,i,cang); + } + + if (typemode != 0) + { + charsperline = 40; + //if (dimensionmode[snum] == 2) charsperline = 80; + + for(i=0;i<=typemessageleng;i+=charsperline) + { + for(j=0;j 0) + { + charsperline = 40; + //if (dimensionmode[snum] == 2) charsperline = 80; + + for(i=0;i<=getmessageleng;i+=charsperline) + { + for(j=0;j getmessagetimeoff) + getmessageleng = 0; + } + if ((numplayers >= 2) && (screenpeek != myconnectindex)) + { + j = 1; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (i == screenpeek) break; + j++; + } + Bsprintf(tempbuf,"(Player %ld's view)",j); + printext256((xdim>>1)-(Bstrlen(tempbuf)<<2),0,24,-1,tempbuf,0); + } + + if (syncstat != 0) printext256(68L,84L,31,0,"OUT OF SYNC!",0); + if (syncstate != 0) printext256(68L,92L,31,0,"Missed Network packet!",0); + +// //Uncomment this to test cache locks +//extern long cacnum; +//typedef struct { long *hand, leng; char *lock; } cactype; +//extern cactype cac[]; +// +// j = 0; +// for(i=0;i= 200) +// { +// Bsprintf(tempbuf,"Locked- %ld: Leng:%ld, Lock:%ld",i,cac[i].leng,*cac[i].lock); +// printext256(0L,j,31,-1,tempbuf,1); j += 6; +// } + + nextpage(); // send completed frame to display + + while (totalclock >= ototalclock+(TIMERINTSPERSECOND/MOVESPERSECOND)) + faketimerhandler(); + + if (keystatus[0x3f]) //F5 + { + keystatus[0x3f] = 0; + detailmode ^= 1; + //setrendermode(3); + } + if (keystatus[0x58]) //F12 + { + keystatus[0x58] = 0; + screencapture("captxxxx.tga",keystatus[0x2a]|keystatus[0x36]); + } + if (keystatus[0x3e]) //F4 - screen re-size + { + keystatus[0x3e] = 0; + + if (keystatus[0x2a]|keystatus[0x36]) { + setgamemode(!fullscreen, xdim, ydim, bpp); + } else { + + //cycle through all modes + j=-1; + + // work out a mask to select the mode + for (i=0; i 8) brightness = 0; + setbrightness(brightness,(char *)&palette[0],0); + } + + if (option[4] == 0) //Single player only keys + { + if (keystatus[0xd2]) //Insert - Insert player + { + keystatus[0xd2] = 0; + if (numplayers < MAXPLAYERS) + { + connectpoint2[numplayers-1] = numplayers; + connectpoint2[numplayers] = -1; + + movefifoend[numplayers] = movefifoend[0]; //HACK 01/05/2000 + + initplayersprite(numplayers); + + clearallviews(0L); //Clear screen to specified color + + numplayers++; + } + } + if (keystatus[0xd3]) //Delete - Delete player + { + keystatus[0xd3] = 0; + if (numplayers > 1) + { + numplayers--; + connectpoint2[numplayers-1] = -1; + + deletesprite(playersprite[numplayers]); + playersprite[numplayers] = -1; + + if (myconnectindex >= numplayers) myconnectindex = 0; + if (screenpeek >= numplayers) screenpeek = 0; + + if (numplayers < 2) + setup3dscreen(); + else + clearallviews(0L); //Clear screen to specified color + } + } + if (keystatus[0x46]) //Scroll Lock + { + keystatus[0x46] = 0; + + myconnectindex = connectpoint2[myconnectindex]; + if (myconnectindex < 0) myconnectindex = connecthead; + screenpeek = myconnectindex; + } + } + + restoreinterpolations(); +} + +void movethings(void) +{ + long i; + + gotlastpacketclock = totalclock; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + copybufbyte(&ffsync[i],&baksync[movefifoend[i]][i],sizeof(input)); + movefifoend[i] = ((movefifoend[i]+1)&(MOVEFIFOSIZ-1)); + } +} + +void fakedomovethings(void) +{ + input *syn; + long i, j, k, doubvel, xvect, yvect, goalz; + short bakcstat; + + syn = (input *)&baksync[fakemovefifoplc][myconnectindex]; + + omyx = myx; + omyy = myy; + omyz = myz; + omyang = myang; + omyhoriz = myhoriz; + + bakcstat = sprite[playersprite[myconnectindex]].cstat; + sprite[playersprite[myconnectindex]].cstat &= ~0x101; + + if ((syn->fvel|syn->svel) != 0) + { + doubvel = (TICSPERFRAME<<((syn->bits&256)>0)); + + xvect = 0, yvect = 0; + if (syn->fvel != 0) + { + xvect += ((((long)syn->fvel)*doubvel*(long)sintable[(myang+512)&2047])>>3); + yvect += ((((long)syn->fvel)*doubvel*(long)sintable[myang&2047])>>3); + } + if (syn->svel != 0) + { + xvect += ((((long)syn->svel)*doubvel*(long)sintable[myang&2047])>>3); + yvect += ((((long)syn->svel)*doubvel*(long)sintable[(myang+1536)&2047])>>3); + } + if (flytime[myconnectindex] > lockclock) { xvect += xvect; yvect += yvect; } // DOuble flying speed + clipmove(&myx,&myy,&myz,&mycursectnum,xvect,yvect,128L,4<<8,4<<8,CLIPMASK0); + } + + pushmove(&myx,&myy,&myz,&mycursectnum,128L,4<<8,4<<8,CLIPMASK0); + getzrange(myx,myy,myz,mycursectnum,&globhiz,&globhihit,&globloz,&globlohit,128L,CLIPMASK0); + + if (syn->avel != 0) //ang += avel * constant + { //ENGINE calculates avel for you + doubvel = TICSPERFRAME; + if ((syn->bits&256) > 0) //Lt. shift makes turn velocity 50% faster + doubvel += (TICSPERFRAME>>1); + myang += ((((long)syn->avel)*doubvel)>>4); + myang &= 2047; + } + + if (((syn->bits&8) > 0) && (myhoriz > 100-(200>>1))) myhoriz -= 4; //- + if (((syn->bits&4) > 0) && (myhoriz < 100+(200>>1))) myhoriz += 4; //+ + + goalz = globloz-EYEHEIGHT; + if (sector[mycursectnum].lotag == 4) //slime sector + if ((globlohit&0xc000) != 49152) //You're not on a sprite + { + goalz = globloz-(8<<8); + if (myz >= goalz-(2<<8)) + clipmove(&myx,&myy,&myz,&mycursectnum,-TICSPERFRAME<<14,-TICSPERFRAME<<14,128L,4<<8,4<<8,CLIPMASK0); + } + if (goalz < globhiz+(16<<8)) //ceiling&floor too close + goalz = ((globloz+globhiz)>>1); + + if (health[myconnectindex] >= 0) + { + if ((syn->bits&1) > 0) //A (stand high) + { + if (flytime[myconnectindex] <= lockclock) + { + if (myz >= globloz-(32<<8)) + { + goalz -= (16<<8); + if (syn->bits&256) goalz -= (24<<8); + } + } + else + { + myzvel -= 192; + if (syn->bits&256) myzvel -= 192; + } + } + if ((syn->bits&2) > 0) //Z (stand low) + { + if (flytime[myconnectindex] <= lockclock) + { + goalz += (12<<8); + if (syn->bits&256) goalz += (12<<8); + } + else + { + myzvel += 192; + if (syn->bits&256) myzvel += 192; + } + } + } + + if (flytime[myconnectindex] <= lockclock) + { + if (myz < goalz) + myzvel += (TICSPERFRAME<<4); + else + myzvel = (((goalz-myz)*TICSPERFRAME)>>5); + } + else + { + myzvel -= (myzvel>>2); + myzvel -= ksgn(myzvel); + } + + myz += myzvel; + if (myz > globloz-(4<<8)) myz = globloz-(4<<8), myzvel = 0; + if (myz < globhiz+(4<<8)) myz = globhiz+(4<<8), myzvel = 0; + + sprite[playersprite[myconnectindex]].cstat = bakcstat; + + myxbak[fakemovefifoplc] = myx; + myybak[fakemovefifoplc] = myy; + myzbak[fakemovefifoplc] = myz; + myangbak[fakemovefifoplc] = myang; + myhorizbak[fakemovefifoplc] = myhoriz; + fakemovefifoplc = (fakemovefifoplc+1)&(MOVEFIFOSIZ-1); +} + + //Prediction correction +void fakedomovethingscorrect(void) +{ + long i; + + if ((networkmode == 0) && (myconnectindex == connecthead)) return; + + i = ((movefifoplc-1)&(MOVEFIFOSIZ-1)); + + if ((posx[myconnectindex] == myxbak[i]) && + (posy[myconnectindex] == myybak[i]) && + (posz[myconnectindex] == myzbak[i]) && + (horiz[myconnectindex] == myhorizbak[i]) && + (ang[myconnectindex] == myangbak[i])) + return; + + //Re-start fakedomovethings back to place of error + myx = omyx = posx[myconnectindex]; + myy = omyy = posy[myconnectindex]; + myz = omyz = posz[myconnectindex]; myzvel = hvel[myconnectindex]; + myang = omyang = ang[myconnectindex]; + mycursectnum = mycursectnum; + myhoriz = omyhoriz = horiz[myconnectindex]; + + fakemovefifoplc = movefifoplc; + while (fakemovefifoplc != movefifoend[myconnectindex]) fakedomovethings(); +} + +void domovethings(void) +{ + short i, j, startwall, endwall; + spritetype *spr; + walltype *wal; + point3d *ospr; + + nummoves++; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + copybufbyte(&baksync[movefifoplc][i],&ssync[i],sizeof(input)); + movefifoplc = ((movefifoplc+1)&(MOVEFIFOSIZ-1)); + + if (option[4] != 0) + { + syncval[syncvalhead] = (char)(randomseed&255); + syncvalhead = ((syncvalhead+1)&(MOVEFIFOSIZ-1)); + } + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + oposx[i] = posx[i]; + oposy[i] = posy[i]; + oposz[i] = posz[i]; + ohoriz[i] = horiz[i]; + ozoom[i] = zoom[i]; + oang[i] = ang[i]; + } + + for(i=NUMSTATS-1;i>=0;i--) + if (statrate[i] >= 0) + for(j=headspritestat[i];j>=0;j=nextspritestat[j]) + if (((nummoves-j)&statrate[i]) == 0) + copybuf(&sprite[j].x,&osprite[j].x,3); + + for(i=connecthead;i>=0;i=connectpoint2[i]) + ocursectnum[i] = cursectnum[i]; + + updateinterpolations(); + + if ((numplayers <= 2) && (recstat == 1)) + { + j = 0; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + copybufbyte(&ssync[i],&recsync[reccnt][j],sizeof(input)); + j++; + } + reccnt++; if (reccnt > 16383) reccnt = 16383; + } + + lockclock += TICSPERFRAME; + drawstatusflytime(screenpeek); // Andy did this + + if (cameradist >= 0) + { + cameradist = min(cameradist+((totalclock-cameraclock)<<10),65536); + if (keystatus[0x52]) //0 + cameraang -= ((totalclock-cameraclock)<<(2+(keystatus[0x2a]|keystatus[0x36]))); + if (keystatus[0x53]) //. + cameraang += ((totalclock-cameraclock)<<(2+(keystatus[0x2a]|keystatus[0x36]))); + cameraclock = totalclock; + } + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + processinput(i); //Move player + + checktouchsprite(i,cursectnum[i]); //Pick up coins + startwall = sector[cursectnum[i]].wallptr; + endwall = startwall + sector[cursectnum[i]].wallnum; + for(j=startwall,wal=&wall[j];jnextsector >= 0) checktouchsprite(i,wal->nextsector); + } + + doanimations(); + tagcode(); //Door code, moving sector code, other stuff + statuslistcode(); //Monster / bullet code / explosions + + fakedomovethingscorrect(); + + checkmasterslaveswitch(); +} + +void getinput(void) +{ + char ch, keystate, *ptr; + long i, j, k; + long mousx, mousy, bstatus; + + if (typemode == 0) //if normal game keys active + { + if (keystatus[keys[15]]) + { + keystatus[keys[15]] = 0; + + screenpeek = connectpoint2[screenpeek]; + if (screenpeek < 0) screenpeek = connecthead; + drawstatusbar(screenpeek); // Andy did this + } + + for(i=7;i>=0;i--) + if (keystatus[i+2]) + { keystatus[i+2] = 0; locselectedgun = i; break; } + } + + + //KEYTIMERSTUFF + if (!keystatus[keys[5]]) + { + if (keystatus[keys[2]]) avel = max(avel-16*TICSPERFRAME,-128); + if (keystatus[keys[3]]) avel = min(avel+16*TICSPERFRAME,127); + } + else + { + if (keystatus[keys[2]]) svel = min(svel+8*TICSPERFRAME,127); + if (keystatus[keys[3]]) svel = max(svel-8*TICSPERFRAME,-128); + } + if (keystatus[keys[0]]) fvel = min(fvel+8*TICSPERFRAME,127); + if (keystatus[keys[1]]) fvel = max(fvel-8*TICSPERFRAME,-128); + if (keystatus[keys[12]]) svel = min(svel+8*TICSPERFRAME,127); + if (keystatus[keys[13]]) svel = max(svel-8*TICSPERFRAME,-128); + + if (avel < 0) avel = min(avel+12*TICSPERFRAME,0); + if (avel > 0) avel = max(avel-12*TICSPERFRAME,0); + if (svel < 0) svel = min(svel+2*TICSPERFRAME,0); + if (svel > 0) svel = max(svel-2*TICSPERFRAME,0); + if (fvel < 0) fvel = min(fvel+2*TICSPERFRAME,0); + if (fvel > 0) fvel = max(fvel-2*TICSPERFRAME,0); + + if ((option[4] == 0) && (numplayers >= 2)) + { + if (!keystatus[0x4f]) + { + if (keystatus[0x4b]) avel2 = max(avel2-16*TICSPERFRAME,-128); + if (keystatus[0x4d]) avel2 = min(avel2+16*TICSPERFRAME,127); + } + else + { + if (keystatus[0x4b]) svel2 = min(svel2+8*TICSPERFRAME,127); + if (keystatus[0x4d]) svel2 = max(svel2-8*TICSPERFRAME,-128); + } + if (keystatus[0x48]) fvel2 = min(fvel2+8*TICSPERFRAME,127); + if (keystatus[0x4c]) fvel2 = max(fvel2-8*TICSPERFRAME,-128); + + if (avel2 < 0) avel2 = min(avel2+12*TICSPERFRAME,0); + if (avel2 > 0) avel2 = max(avel2-12*TICSPERFRAME,0); + if (svel2 < 0) svel2 = min(svel2+2*TICSPERFRAME,0); + if (svel2 > 0) svel2 = max(svel2-2*TICSPERFRAME,0); + if (fvel2 < 0) fvel2 = min(fvel2+2*TICSPERFRAME,0); + if (fvel2 > 0) fvel2 = max(fvel2-2*TICSPERFRAME,0); + } + + oscreentilt = screentilt; + if (keystatus[0x1a]) screentilt += ((4*TICSPERFRAME)<<(keystatus[0x2a]|keystatus[0x36])); + if (keystatus[0x1b]) screentilt -= ((4*TICSPERFRAME)<<(keystatus[0x2a]|keystatus[0x36])); + + i = (TICSPERFRAME<<1); + while ((screentilt != 0) && (i > 0)) + { screentilt = ((screentilt+ksgn(screentilt-1024))&2047); i--; } + if (keystatus[0x28]) screentilt = 1536; + + + loc.fvel = min(max(fvel,-128+8),127-8); + loc.svel = min(max(svel,-128+8),127-8); + loc.avel = min(max(avel,-128+16),127-16); + + getmousevalues(&mousx,&mousy,&bstatus); + loc.avel = min(max(loc.avel+(mousx<<3),-128),127); + loc.fvel = min(max(loc.fvel-(mousy<<3),-128),127); + + loc.bits = (locselectedgun<<13); + if (typemode == 0) //if normal game keys active + { + loc.bits |= (keystatus[0x32]<<9); //M (be master) + loc.bits |= ((keystatus[keys[14]]==1)<<12); //Map mode + } + loc.bits |= keystatus[keys[8]]; //Stand high + loc.bits |= (keystatus[keys[9]]<<1); //Stand low + loc.bits |= (keystatus[keys[16]]<<4); //Zoom in + loc.bits |= (keystatus[keys[17]]<<5); //Zoom out + loc.bits |= (keystatus[keys[4]]<<8); //Run + loc.bits |= (keystatus[keys[10]]<<2); //Look up + loc.bits |= (keystatus[keys[11]]<<3); //Look down + loc.bits |= ((keystatus[keys[7]]==1)<<10); //Space + loc.bits |= ((keystatus[keys[6]]==1)<<11); //Shoot + loc.bits |= (((bstatus&6)>(oldmousebstatus&6))<<10); //Space + loc.bits |= (((bstatus&1)>(oldmousebstatus&1))<<11); //Shoot + + oldmousebstatus = bstatus; + if (((loc.bits&2048) > 0) && (locselectedgun == 0)) + oldmousebstatus &= ~1; //Allow continous fire with mouse for chain gun + + //PRIVATE KEYS: +/* if (keystatus[0xb7]) //Printscreen + { + keystatus[0xb7] = 0; + printscreeninterrupt(); + } +*/ + if (keystatus[0x2f]) //V + { + keystatus[0x2f] = 0; + if (cameradist < 0) cameradist = 0; else cameradist = -1; + cameraang = 0; + } + + if (typemode == 0) //if normal game keys active + { + if (keystatus[0x19]) //P + { + keystatus[0x19] = 0; + parallaxtype++; + if (parallaxtype > 2) parallaxtype = 0; + } + if (keystatus[0x38]|keystatus[0xb8]) //ALT + { + if (keystatus[0x4a]) // Keypad - + visibility = min(visibility+(visibility>>3),16384); + if (keystatus[0x4e]) // Keypad + + visibility = max(visibility-(visibility>>3),128); + } + + if (keystatus[keys[18]]) //Typing mode + { + keystatus[keys[18]] = 0; + typemode = 1; + bflushchars(); + keyfifoplc = keyfifoend; //Reset keyboard fifo + } + } + else + { + while ((ch = bgetchar())) + { + if (ch == 8) //Backspace + { + if (typemessageleng == 0) { typemode = 0; break; } + typemessageleng--; + } + else if (ch == 9) // tab + { + keystatus[0xf] = 0; + typemode = 0; + break; + } + else if (ch == 13) //Either ENTER + { + keystatus[0x1c] = 0; keystatus[0x9c] = 0; + if (typemessageleng > 0) + { + packbuf[0] = 2; //Sending text is message type 4 + for(j=typemessageleng-1;j>=0;j--) + packbuf[j+1] = typemessage[j]; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + sendpacket(i,packbuf,typemessageleng+1); + + typemessageleng = 0; + } + typemode = 0; + break; + } + else if ((typemessageleng < 159) && (ch >= 32) && (ch < 128)) + { + typemessage[typemessageleng++] = ch; + } + } + } +} + +void initplayersprite(short snum) +{ + long i; + + if (playersprite[snum] >= 0) return; + + spawnsprite(playersprite[snum],posx[snum],posy[snum],posz[snum]+EYEHEIGHT, + 1+256,0,snum,32,64,64,0,0,PLAYER,ang[snum],0,0,0,snum+4096, + cursectnum[snum],8,0,0,0); + + switch(snum) + { + case 1: for(i=0;i<32;i++) tempbuf[i+192] = i+128; break; //green->red + case 2: for(i=0;i<32;i++) tempbuf[i+192] = i+32; break; //green->blue + case 3: for(i=0;i<32;i++) tempbuf[i+192] = i+224; break; //green->pink + case 4: for(i=0;i<32;i++) tempbuf[i+192] = i+64; break; //green->brown + case 5: for(i=0;i<32;i++) tempbuf[i+192] = i+96; break; + case 6: for(i=0;i<32;i++) tempbuf[i+192] = i+160; break; + case 7: for(i=0;i<32;i++) tempbuf[i+192] = i+192; break; + default: for(i=0;i<256;i++) tempbuf[i] = i; break; + } + makepalookup(snum,tempbuf,0,0,0,1); +} + +void playback(void) +{ + long i, j, k; + + ready2send = 0; + recstat = 0; i = reccnt; + while (!keystatus[1]) + { + if (handleevents()) { + if (quitevent) { + keystatus[1] = 1; + quitevent = 0; + } + } + + refreshaudio(); + + while (totalclock >= lockclock+TICSPERFRAME) + { + sampletimer(); + if (i >= reccnt) + { + prepareboard(boardfilename); + for(i=connecthead;i>=0;i=connectpoint2[i]) + initplayersprite((short)i); + totalclock = 0; + i = 0; + } + + k = 0; + for(j=connecthead;j>=0;j=connectpoint2[j]) + { + copybufbyte(&recsync[i][k],&ffsync[j],sizeof(input)); + k++; + } + movethings(); domovethings(); + i++; + } + drawscreen(screenpeek,(totalclock-gotlastpacketclock)*(65536/(TIMERINTSPERSECOND/MOVESPERSECOND))); + + if (keystatus[keys[15]]) + { + keystatus[keys[15]] = 0; + screenpeek = connectpoint2[screenpeek]; + if (screenpeek < 0) screenpeek = connecthead; + drawstatusbar(screenpeek); // Andy did this + } + if (keystatus[keys[14]]) + { + keystatus[keys[14]] = 0; + dimensionmode[screenpeek]++; + if (dimensionmode[screenpeek] > 3) dimensionmode[screenpeek] = 1; + } + } + + musicoff(); + uninitmultiplayers(); + uninittimer(); + uninitinput(); + uninitengine(); + uninitsb(); + uninitgroupfile(); + exit(0); +} + +void setup3dscreen(void) +{ + long i, dax, day, dax2, day2; + + i = setgamemode(fullscreen,xdimgame,ydimgame,bppgame); + if (i < 0) + { + printf("Error setting video mode.\n"); + sendlogoff(); + musicoff(); + uninitmultiplayers(); + uninittimer(); + uninitinput(); + uninitengine(); + uninitsb(); + uninitgroupfile(); + exit(0); + } + + //Make that ugly pink into black in case it ever shows up! + i = 0L; + setpalette(255,1,(char *)&i); + //outp(0x3c8,255); outp(0x3c9,0); outp(0x3c9,0); outp(0x3c9,0); + + screensize = xdim; + if (screensize > xdim) + { + dax = 0; day = 0; + dax2 = xdim-1; day2 = ydim-1; + } + else + { + dax = ((xdim-screensize)>>1); + dax2 = dax+screensize-1; + day = (((ydim-32)-scale(screensize,ydim-32,xdim))>>1); + day2 = day + scale(screensize,ydim-32,xdim)-1; + setview(dax,day,dax2,day2); + } + + flushperms(); + + if (screensize < xdim) + drawtilebackground(0L,0L,BACKGROUND,8,0L,0L,xdim-1L,ydim-1L,0); //Draw background + + if (screensize <= xdim) + { + rotatesprite((xdim-320)<<15,(ydim-32)<<16,65536L,0,STATUSBAR,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L); + i = ((xdim-320)>>1); + while (i >= 8) i -= 8, rotatesprite(i<<16,(ydim-32)<<16,65536L,0,STATUSBARFILL8,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L); + if (i >= 4) i -= 4, rotatesprite(i<<16,(ydim-32)<<16,65536L,0,STATUSBARFILL4,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L); + i = ((xdim-320)>>1)+320; + while (i <= xdim-8) rotatesprite(i<<16,(ydim-32)<<16,65536L,0,STATUSBARFILL8,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L), i += 8; + if (i <= xdim-4) rotatesprite(i<<16,(ydim-32)<<16,65536L,0,STATUSBARFILL4,0,0,8+16+64+128,0L,0L,xdim-1L,ydim-1L), i += 4; + + drawstatusbar(screenpeek); // Andy did this + } +} + +void findrandomspot(long *x, long *y, short *sectnum) +{ + short startwall, endwall, s, dasector; + long dax, day, daz, minx, maxx, miny, maxy, cnt; + + for(cnt=256;cnt>=0;cnt--) + { + do + { + dasector = mulscale16(krand(),numsectors); + } while ((sector[dasector].ceilingz+(8<<8) >= sector[dasector].floorz) || ((sector[dasector].lotag|sector[dasector].hitag) != 0) || ((sector[dasector].floorstat&1) != 0)); + + startwall = sector[dasector].wallptr; + endwall = startwall+sector[dasector].wallnum; + if (endwall <= startwall) continue; + + dax = 0L; + day = 0L; + minx = 0x7fffffff; maxx = 0x80000000; + miny = 0x7fffffff; maxy = 0x80000000; + + for(s=startwall;s maxx) maxx = wall[s].x; + if (wall[s].y < miny) miny = wall[s].y; + if (wall[s].y > maxy) maxy = wall[s].y; + } + + if ((maxx-minx <= 256) || (maxy-miny <= 256)) continue; + + dax /= (endwall-startwall); + day /= (endwall-startwall); + + if (inside(dax,day,dasector) == 0) continue; + + daz = sector[dasector].floorz-(32<<8); + if (pushmove(&dax,&day,&daz,&dasector,128L,4<<8,4<<8,CLIPMASK0) < 0) continue; + + *x = dax; *y = day; *sectnum = dasector; + return; + } +} + +void warp(long *x, long *y, long *z, short *daang, short *dasector) +{ + short startwall, endwall, s; + long i, j, dax, day, ox, oy; + + ox = *x; oy = *y; + + for(i=0;i= warpsectorcnt) i = 0; + } while (sector[warpsectorlist[i]].hitag != j); + *dasector = warpsectorlist[i]; + break; + } + + //Find center of sector + startwall = sector[*dasector].wallptr; + endwall = startwall+sector[*dasector].wallnum; + dax = 0L, day = 0L; + for(s=startwall;s= 0) + i = s; + } + *x = dax / (endwall-startwall); + *y = day / (endwall-startwall); + *z = sector[*dasector].floorz-(32<<8); + updatesector(*x,*y,dasector); + dax = ((wall[i].x+wall[wall[i].point2].x)>>1); + day = ((wall[i].y+wall[wall[i].point2].y)>>1); + *daang = getangle(dax-*x,day-*y); + + wsayfollow("warp.wav",3072L+(krand()&127)-64,192L,&ox,&oy,0); + wsayfollow("warp.wav",4096L+(krand()&127)-64,256L,x,y,0); +} + +void warpsprite(short spritenum) +{ + short dasectnum; + + dasectnum = sprite[spritenum].sectnum; + warp(&sprite[spritenum].x,&sprite[spritenum].y,&sprite[spritenum].z, + &sprite[spritenum].ang,&dasectnum); + + copybuf(&sprite[spritenum].x,&osprite[spritenum].x,3); + changespritesect(spritenum,dasectnum); + + show2dsprite[spritenum>>3] &= ~(1<<(spritenum&7)); + if (show2dsector[dasectnum>>3]&(1<<(dasectnum&7))) + show2dsprite[spritenum>>3] |= (1<<(spritenum&7)); +} + +void initlava(void) +{ + long x, y, z, r; + + for(z=0;z<32;z++) lavaradcnt[z] = 0; + for(x=-16;x<=16;x++) + for(y=-16;y<=16;y++) + { + r = ksqrt(x*x + y*y); + lavaradx[r][lavaradcnt[r]] = x; + lavarady[r][lavaradcnt[r]] = y; + lavaradcnt[r]++; + } + + for(z=0;z<16;z++) + lavadropsizlookup[z] = 8 / (ksqrt(z)+1); + + for(z=0;z>4)&7)-4)+12; + + lavanumdrops = 0; + lavanumframes = 0; +} + +#if defined(NOASM) +inline long addlava(long bx) +{ + char *b = (char *)bx; + return b[-133] + b[-132] + b[-131] + b[1] + b[-1] + b[131] + b[132]; +} +#elif defined(__WATCOMC__) +#pragma aux addlava =\ + "mov al, byte ptr [ebx-133]",\ + "mov dl, byte ptr [ebx-1]",\ + "add al, byte ptr [ebx-132]",\ + "add dl, byte ptr [ebx+131]",\ + "add al, byte ptr [ebx-131]",\ + "add dl, byte ptr [ebx+132]",\ + "add al, byte ptr [ebx+1]",\ + "add al, dl",\ + parm [ebx]\ + modify exact [eax edx] +long addlava(long); +#elif defined(_MSC_VER) +inline long addlava(long b) +{ + _asm { + mov ebx, b + mov al, byte ptr [ebx-133] + mov dl, byte ptr [ebx-1] + add al, byte ptr [ebx-132] + add dl, byte ptr [ebx+131] + add al, byte ptr [ebx-131] + add dl, byte ptr [ebx+132] + add al, byte ptr [ebx+1] + add al, dl + } +} +#elif defined(__GNUC__) && defined(__i386__) +inline long addlava(long b) +{ + long r; + __asm__ __volatile__ ( + "movb -133(%%ebx), %%al\n\t" + "movb -1(%%ebx), %%dl\n\t" + "addb -132(%%ebx), %%al\n\t" + "addb 131(%%ebx), %%dl\n\t" + "addb -131(%%ebx), %%al\n\t" + "addb 132(%%ebx), %%dl\n\t" + "addb 1(%%ebx), %%al\n\t" + "addb %%dl, %%al" + : "=a" (r) : "b" (b) + : "dx" + ); + return r; +} +#else +#error Unsupported compiler or architecture +#endif + +void movelava(char *dapic) +{ + long i, j, x, y, z, zz, dalavadropsiz, dadropsizlookup; + long dalavax, dalavay, *ptr, *ptr2; + + for(z=min(LAVAMAXDROPS-lavanumdrops-1,3);z>=0;z--) + { + lavadropx[lavanumdrops] = (Brand()&(LAVASIZ-1)); + lavadropy[lavanumdrops] = (Brand()&(LAVASIZ-1)); + lavadropsiz[lavanumdrops] = 1; + lavanumdrops++; + } + + for(z=lavanumdrops-1;z>=0;z--) + { + dadropsizlookup = lavadropsizlookup[lavadropsiz[z]]*(((z&1)<<1)-1); + dalavadropsiz = lavadropsiz[z]; + dalavax = lavadropx[z]; dalavay = lavadropy[z]; + for(zz=lavaradcnt[lavadropsiz[z]]-1;zz>=0;zz--) + { + i = (((lavaradx[dalavadropsiz][zz]+dalavax)&(LAVASIZ-1))< 10) + { + lavanumdrops--; + lavadropx[z] = lavadropx[lavanumdrops]; + lavadropy[z] = lavadropy[lavanumdrops]; + lavadropsiz[z] = lavadropsiz[lavanumdrops]; + } + } + + //Back up dapic with 1 pixel extra on each boundary + //(to prevent anding for wrap-around) + ptr = (long *)dapic; + ptr2 = (long *)((LAVASIZ+4)+1+((long)lavabakpic)); + for(x=0;x>2);y>0;y--) *ptr2++ = ((*ptr++)&0x1f1f1f1f); + ptr2++; + } + for(y=0;y>3)+ + ((addlava(y+1)&0xf8)<<5)+ + ((addlava(y+2)&0xf8)<<13)+ + ((addlava(y+3)&0xf8)<<21)+ + 0xc2c2c2c2; + } + } + + lavanumframes++; +} + +void doanimations(void) +{ + long i, j; + + for(i=animatecnt-1;i>=0;i--) + { + j = *animateptr[i]; + + if (j < animategoal[i]) + j = min(j+animatevel[i]*TICSPERFRAME,animategoal[i]); + else + j = max(j-animatevel[i]*TICSPERFRAME,animategoal[i]); + animatevel[i] += animateacc[i]; + + *animateptr[i] = j; + + if (j == animategoal[i]) + { + animatecnt--; + if (i != animatecnt) + { + stopinterpolation(animateptr[i]); + animateptr[i] = animateptr[animatecnt]; + animategoal[i] = animategoal[animatecnt]; + animatevel[i] = animatevel[animatecnt]; + animateacc[i] = animateacc[animatecnt]; + } + } + } +} + +long getanimationgoal(long animptr) +{ + long i; + + for(i=animatecnt-1;i>=0;i--) + if ((long *)animptr == animateptr[i]) return(i); + return(-1); +} + +long setanimation(long *animptr, long thegoal, long thevel, long theacc) +{ + long i, j; + + if (animatecnt >= MAXANIMATES) return(-1); + + j = animatecnt; + for(i=animatecnt-1;i>=0;i--) + if (animptr == animateptr[i]) + { j = i; break; } + + setinterpolation(animptr); + + animateptr[j] = animptr; + animategoal[j] = thegoal; + animatevel[j] = thevel; + animateacc[j] = theacc; + if (j == animatecnt) animatecnt++; + return(j); +} + +void checkmasterslaveswitch(void) +{ + long i, j; + + if (option[4] == 0) return; + + j = 0; + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (ssync[i].bits&512) j++; + if (j != 1) return; + + i = connecthead; + for(j=connectpoint2[i];j>=0;j=connectpoint2[j]) + { + if (ssync[j].bits&512) + { + connectpoint2[i] = connectpoint2[j]; + connectpoint2[j] = connecthead; + connecthead = (short)j; + + oloc.fvel = loc.fvel+1; + oloc.svel = loc.svel+1; + oloc.avel = loc.avel+1; + oloc.bits = loc.bits+1; + for(i=0;i=0;i=connectpoint2[i]) + { + if (myconnectindex == i) break; + j++; + } + if (j == 1) + Bstrcpy(getmessage,"Player 1 (Master)"); + else + Bsprintf(getmessage,"Player %ld (Slave)",j); + getmessageleng = Bstrlen(getmessage); + getmessagetimeoff = totalclock+120; + + return; + } + i = j; + } +} + + +long testneighborsectors(short sect1, short sect2) +{ + short i, startwall, num1, num2; + + num1 = sector[sect1].wallnum; + num2 = sector[sect2].wallnum; + if (num1 < num2) //Traverse walls of sector with fewest walls (for speed) + { + startwall = sector[sect1].wallptr; + for(i=num1-1;i>=0;i--) + if (wall[i+startwall].nextsector == sect2) + return(1); + } + else + { + startwall = sector[sect2].wallptr; + for(i=num2-1;i>=0;i--) + if (wall[i+startwall].nextsector == sect1) + return(1); + } + return(0); +} + +long loadgame(void) +{ + long i; + long fil; + + if ((fil = kopen4load("save0000.gam",0)) == -1) return(-1); + + kdfread(&numplayers,4,1,fil); + kdfread(&myconnectindex,4,1,fil); + kdfread(&connecthead,4,1,fil); + kdfread(connectpoint2,4,MAXPLAYERS,fil); + + //Make sure palookups get set, sprites will get overwritten later + for(i=connecthead;i>=0;i=connectpoint2[i]) initplayersprite((short)i); + + kdfread(posx,4,MAXPLAYERS,fil); + kdfread(posy,4,MAXPLAYERS,fil); + kdfread(posz,4,MAXPLAYERS,fil); + kdfread(horiz,4,MAXPLAYERS,fil); + kdfread(zoom,4,MAXPLAYERS,fil); + kdfread(hvel,4,MAXPLAYERS,fil); + kdfread(ang,2,MAXPLAYERS,fil); + kdfread(cursectnum,2,MAXPLAYERS,fil); + kdfread(ocursectnum,2,MAXPLAYERS,fil); + kdfread(playersprite,2,MAXPLAYERS,fil); + kdfread(deaths,2,MAXPLAYERS,fil); + kdfread(lastchaingun,4,MAXPLAYERS,fil); + kdfread(health,4,MAXPLAYERS,fil); + kdfread(numgrabbers,2,MAXPLAYERS,fil); + kdfread(nummissiles,2,MAXPLAYERS,fil); + kdfread(numbombs,2,MAXPLAYERS,fil); + kdfread(flytime,4,MAXPLAYERS,fil); + kdfread(oflags,2,MAXPLAYERS,fil); + kdfread(dimensionmode,1,MAXPLAYERS,fil); + kdfread(revolvedoorstat,1,MAXPLAYERS,fil); + kdfread(revolvedoorang,2,MAXPLAYERS,fil); + kdfread(revolvedoorrotang,2,MAXPLAYERS,fil); + kdfread(revolvedoorx,4,MAXPLAYERS,fil); + kdfread(revolvedoory,4,MAXPLAYERS,fil); + + kdfread(&numsectors,2,1,fil); + kdfread(sector,sizeof(sectortype),numsectors,fil); + kdfread(&numwalls,2,1,fil); + kdfread(wall,sizeof(walltype),numwalls,fil); + //Store all sprites (even holes) to preserve indeces + kdfread(sprite,sizeof(spritetype),MAXSPRITES,fil); + kdfread(headspritesect,2,MAXSECTORS+1,fil); + kdfread(prevspritesect,2,MAXSPRITES,fil); + kdfread(nextspritesect,2,MAXSPRITES,fil); + kdfread(headspritestat,2,MAXSTATUS+1,fil); + kdfread(prevspritestat,2,MAXSPRITES,fil); + kdfread(nextspritestat,2,MAXSPRITES,fil); + + kdfread(&fvel,4,1,fil); + kdfread(&svel,4,1,fil); + kdfread(&avel,4,1,fil); + + kdfread(&locselectedgun,4,1,fil); + kdfread(&loc.fvel,1,1,fil); + kdfread(&oloc.fvel,1,1,fil); + kdfread(&loc.svel,1,1,fil); + kdfread(&oloc.svel,1,1,fil); + kdfread(&loc.avel,1,1,fil); + kdfread(&oloc.avel,1,1,fil); + kdfread(&loc.bits,2,1,fil); + kdfread(&oloc.bits,2,1,fil); + + kdfread(&locselectedgun2,4,1,fil); + kdfread(&loc2.fvel,sizeof(input),1,fil); + + kdfread(ssync,sizeof(input),MAXPLAYERS,fil); + kdfread(osync,sizeof(input),MAXPLAYERS,fil); + + kdfread(boardfilename,1,80,fil); + kdfread(&screenpeek,2,1,fil); + kdfread(&oldmousebstatus,2,1,fil); + kdfread(&brightness,2,1,fil); + kdfread(&neartagsector,2,1,fil); + kdfread(&neartagwall,2,1,fil); + kdfread(&neartagsprite,2,1,fil); + kdfread(&lockclock,4,1,fil); + kdfread(&neartagdist,4,1,fil); + kdfread(&neartaghitdist,4,1,fil); + + kdfread(turnspritelist,2,16,fil); + kdfread(&turnspritecnt,2,1,fil); + kdfread(warpsectorlist,2,16,fil); + kdfread(&warpsectorcnt,2,1,fil); + kdfread(xpanningsectorlist,2,16,fil); + kdfread(&xpanningsectorcnt,2,1,fil); + kdfread(ypanningwalllist,2,64,fil); + kdfread(&ypanningwallcnt,2,1,fil); + kdfread(floorpanninglist,2,64,fil); + kdfread(&floorpanningcnt,2,1,fil); + kdfread(dragsectorlist,2,16,fil); + kdfread(dragxdir,2,16,fil); + kdfread(dragydir,2,16,fil); + kdfread(&dragsectorcnt,2,1,fil); + kdfread(dragx1,4,16,fil); + kdfread(dragy1,4,16,fil); + kdfread(dragx2,4,16,fil); + kdfread(dragy2,4,16,fil); + kdfread(dragfloorz,4,16,fil); + kdfread(&swingcnt,2,1,fil); + kdfread(swingwall,2,32*5,fil); + kdfread(swingsector,2,32,fil); + kdfread(swingangopen,2,32,fil); + kdfread(swingangclosed,2,32,fil); + kdfread(swingangopendir,2,32,fil); + kdfread(swingang,2,32,fil); + kdfread(swinganginc,2,32,fil); + kdfread(swingx,4,32*8,fil); + kdfread(swingy,4,32*8,fil); + kdfread(revolvesector,2,4,fil); + kdfread(revolveang,2,4,fil); + kdfread(&revolvecnt,2,1,fil); + kdfread(revolvex,4,4*16,fil); + kdfread(revolvey,4,4*16,fil); + kdfread(revolvepivotx,4,4,fil); + kdfread(revolvepivoty,4,4,fil); + kdfread(subwaytracksector,2,4*128,fil); + kdfread(subwaynumsectors,2,4,fil); + kdfread(&subwaytrackcnt,2,1,fil); + kdfread(subwaystop,4,4*8,fil); + kdfread(subwaystopcnt,4,4,fil); + kdfread(subwaytrackx1,4,4,fil); + kdfread(subwaytracky1,4,4,fil); + kdfread(subwaytrackx2,4,4,fil); + kdfread(subwaytracky2,4,4,fil); + kdfread(subwayx,4,4,fil); + kdfread(subwaygoalstop,4,4,fil); + kdfread(subwayvel,4,4,fil); + kdfread(subwaypausetime,4,4,fil); + kdfread(waterfountainwall,2,MAXPLAYERS,fil); + kdfread(waterfountaincnt,2,MAXPLAYERS,fil); + kdfread(slimesoundcnt,2,MAXPLAYERS,fil); + + //Warning: only works if all pointers are in sector structures! + kdfread(animateptr,4,MAXANIMATES,fil); + for(i=MAXANIMATES-1;i>=0;i--) + animateptr[i] = (long *)(animateptr[i]+((long)sector)); + + kdfread(animategoal,4,MAXANIMATES,fil); + kdfread(animatevel,4,MAXANIMATES,fil); + kdfread(animateacc,4,MAXANIMATES,fil); + kdfread(&animatecnt,4,1,fil); + + kdfread(&totalclock,4,1,fil); + kdfread(&numframes,4,1,fil); + kdfread(&randomseed,4,1,fil); + kdfread(&numpalookups,2,1,fil); + + kdfread(&visibility,4,1,fil); + kdfread(¶llaxvisibility,4,1,fil); + kdfread(¶llaxtype,1,1,fil); + kdfread(¶llaxyoffs,4,1,fil); + kdfread(pskyoff,2,MAXPSKYTILES,fil); + kdfread(&pskybits,2,1,fil); + + kdfread(&mirrorcnt,2,1,fil); + kdfread(mirrorwall,2,mirrorcnt,fil); + kdfread(mirrorsector,2,mirrorcnt,fil); + + //I should save off interpolation list, but they're pointers :( + numinterpolations = 0; + startofdynamicinterpolations = 0; + + kclose(fil); + + for(i=connecthead;i>=0;i=connectpoint2[i]) initplayersprite((short)i); + + totalclock = lockclock; + ototalclock = lockclock; + + Bstrcpy(getmessage,"Game loaded."); + getmessageleng = Bstrlen(getmessage); + getmessagetimeoff = totalclock+360+(getmessageleng<<4); + return(0); +} + +long savegame(void) +{ + long i; + BFILE *fil; + + if ((fil = Bfopen("save0000.gam","wb")) == 0) return(-1); + + dfwrite(&numplayers,4,1,fil); + dfwrite(&myconnectindex,4,1,fil); + dfwrite(&connecthead,4,1,fil); + dfwrite(connectpoint2,4,MAXPLAYERS,fil); + + dfwrite(posx,4,MAXPLAYERS,fil); + dfwrite(posy,4,MAXPLAYERS,fil); + dfwrite(posz,4,MAXPLAYERS,fil); + dfwrite(horiz,4,MAXPLAYERS,fil); + dfwrite(zoom,4,MAXPLAYERS,fil); + dfwrite(hvel,4,MAXPLAYERS,fil); + dfwrite(ang,2,MAXPLAYERS,fil); + dfwrite(cursectnum,2,MAXPLAYERS,fil); + dfwrite(ocursectnum,2,MAXPLAYERS,fil); + dfwrite(playersprite,2,MAXPLAYERS,fil); + dfwrite(deaths,2,MAXPLAYERS,fil); + dfwrite(lastchaingun,4,MAXPLAYERS,fil); + dfwrite(health,4,MAXPLAYERS,fil); + dfwrite(numgrabbers,2,MAXPLAYERS,fil); + dfwrite(nummissiles,2,MAXPLAYERS,fil); + dfwrite(numbombs,2,MAXPLAYERS,fil); + dfwrite(flytime,4,MAXPLAYERS,fil); + dfwrite(oflags,2,MAXPLAYERS,fil); + dfwrite(dimensionmode,1,MAXPLAYERS,fil); + dfwrite(revolvedoorstat,1,MAXPLAYERS,fil); + dfwrite(revolvedoorang,2,MAXPLAYERS,fil); + dfwrite(revolvedoorrotang,2,MAXPLAYERS,fil); + dfwrite(revolvedoorx,4,MAXPLAYERS,fil); + dfwrite(revolvedoory,4,MAXPLAYERS,fil); + + dfwrite(&numsectors,2,1,fil); + dfwrite(sector,sizeof(sectortype),numsectors,fil); + dfwrite(&numwalls,2,1,fil); + dfwrite(wall,sizeof(walltype),numwalls,fil); + //Store all sprites (even holes) to preserve indeces + dfwrite(sprite,sizeof(spritetype),MAXSPRITES,fil); + dfwrite(headspritesect,2,MAXSECTORS+1,fil); + dfwrite(prevspritesect,2,MAXSPRITES,fil); + dfwrite(nextspritesect,2,MAXSPRITES,fil); + dfwrite(headspritestat,2,MAXSTATUS+1,fil); + dfwrite(prevspritestat,2,MAXSPRITES,fil); + dfwrite(nextspritestat,2,MAXSPRITES,fil); + + dfwrite(&fvel,4,1,fil); + dfwrite(&svel,4,1,fil); + dfwrite(&avel,4,1,fil); + + dfwrite(&locselectedgun,4,1,fil); + dfwrite(&loc.fvel,1,1,fil); + dfwrite(&oloc.fvel,1,1,fil); + dfwrite(&loc.svel,1,1,fil); + dfwrite(&oloc.svel,1,1,fil); + dfwrite(&loc.avel,1,1,fil); + dfwrite(&oloc.avel,1,1,fil); + dfwrite(&loc.bits,2,1,fil); + dfwrite(&oloc.bits,2,1,fil); + + dfwrite(&locselectedgun2,4,1,fil); + dfwrite(&loc2.fvel,sizeof(input),1,fil); + + dfwrite(ssync,sizeof(input),MAXPLAYERS,fil); + dfwrite(osync,sizeof(input),MAXPLAYERS,fil); + + dfwrite(boardfilename,1,80,fil); + dfwrite(&screenpeek,2,1,fil); + dfwrite(&oldmousebstatus,2,1,fil); + dfwrite(&brightness,2,1,fil); + dfwrite(&neartagsector,2,1,fil); + dfwrite(&neartagwall,2,1,fil); + dfwrite(&neartagsprite,2,1,fil); + dfwrite(&lockclock,4,1,fil); + dfwrite(&neartagdist,4,1,fil); + dfwrite(&neartaghitdist,4,1,fil); + + dfwrite(turnspritelist,2,16,fil); + dfwrite(&turnspritecnt,2,1,fil); + dfwrite(warpsectorlist,2,16,fil); + dfwrite(&warpsectorcnt,2,1,fil); + dfwrite(xpanningsectorlist,2,16,fil); + dfwrite(&xpanningsectorcnt,2,1,fil); + dfwrite(ypanningwalllist,2,64,fil); + dfwrite(&ypanningwallcnt,2,1,fil); + dfwrite(floorpanninglist,2,64,fil); + dfwrite(&floorpanningcnt,2,1,fil); + dfwrite(dragsectorlist,2,16,fil); + dfwrite(dragxdir,2,16,fil); + dfwrite(dragydir,2,16,fil); + dfwrite(&dragsectorcnt,2,1,fil); + dfwrite(dragx1,4,16,fil); + dfwrite(dragy1,4,16,fil); + dfwrite(dragx2,4,16,fil); + dfwrite(dragy2,4,16,fil); + dfwrite(dragfloorz,4,16,fil); + dfwrite(&swingcnt,2,1,fil); + dfwrite(swingwall,2,32*5,fil); + dfwrite(swingsector,2,32,fil); + dfwrite(swingangopen,2,32,fil); + dfwrite(swingangclosed,2,32,fil); + dfwrite(swingangopendir,2,32,fil); + dfwrite(swingang,2,32,fil); + dfwrite(swinganginc,2,32,fil); + dfwrite(swingx,4,32*8,fil); + dfwrite(swingy,4,32*8,fil); + dfwrite(revolvesector,2,4,fil); + dfwrite(revolveang,2,4,fil); + dfwrite(&revolvecnt,2,1,fil); + dfwrite(revolvex,4,4*16,fil); + dfwrite(revolvey,4,4*16,fil); + dfwrite(revolvepivotx,4,4,fil); + dfwrite(revolvepivoty,4,4,fil); + dfwrite(subwaytracksector,2,4*128,fil); + dfwrite(subwaynumsectors,2,4,fil); + dfwrite(&subwaytrackcnt,2,1,fil); + dfwrite(subwaystop,4,4*8,fil); + dfwrite(subwaystopcnt,4,4,fil); + dfwrite(subwaytrackx1,4,4,fil); + dfwrite(subwaytracky1,4,4,fil); + dfwrite(subwaytrackx2,4,4,fil); + dfwrite(subwaytracky2,4,4,fil); + dfwrite(subwayx,4,4,fil); + dfwrite(subwaygoalstop,4,4,fil); + dfwrite(subwayvel,4,4,fil); + dfwrite(subwaypausetime,4,4,fil); + dfwrite(waterfountainwall,2,MAXPLAYERS,fil); + dfwrite(waterfountaincnt,2,MAXPLAYERS,fil); + dfwrite(slimesoundcnt,2,MAXPLAYERS,fil); + + //Warning: only works if all pointers are in sector structures! + for(i=MAXANIMATES-1;i>=0;i--) + animateptr[i] = (long *)(animateptr[i]-((long)sector)); + dfwrite(animateptr,4,MAXANIMATES,fil); + for(i=MAXANIMATES-1;i>=0;i--) + animateptr[i] = (long *)(animateptr[i]+((long)sector)); + + dfwrite(animategoal,4,MAXANIMATES,fil); + dfwrite(animatevel,4,MAXANIMATES,fil); + dfwrite(animateacc,4,MAXANIMATES,fil); + dfwrite(&animatecnt,4,1,fil); + + dfwrite(&totalclock,4,1,fil); + dfwrite(&numframes,4,1,fil); + dfwrite(&randomseed,4,1,fil); + dfwrite(&numpalookups,2,1,fil); + + dfwrite(&visibility,4,1,fil); + dfwrite(¶llaxvisibility,4,1,fil); + dfwrite(¶llaxtype,1,1,fil); + dfwrite(¶llaxyoffs,4,1,fil); + dfwrite(pskyoff,2,MAXPSKYTILES,fil); + dfwrite(&pskybits,2,1,fil); + + dfwrite(&mirrorcnt,2,1,fil); + dfwrite(mirrorwall,2,mirrorcnt,fil); + dfwrite(mirrorsector,2,mirrorcnt,fil); + + Bfclose(fil); + + Bstrcpy(getmessage,"Game saved."); + getmessageleng = Bstrlen(getmessage); + getmessagetimeoff = totalclock+360+(getmessageleng<<4); + return(0); +} + +void faketimerhandler(void) +{ + short other, packbufleng; + long i, j, k, l; + + sampletimer(); + if ((totalclock < ototalclock+(TIMERINTSPERSECOND/MOVESPERSECOND)) || (ready2send == 0)) return; + ototalclock += (TIMERINTSPERSECOND/MOVESPERSECOND); + + getpackets(); + if (getoutputcirclesize() >= 16) return; + getinput(); + + /* + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + { + k = (movefifoend[myconnectindex]-1)-movefifoend[i]; + myminlag[i] = min(myminlag[i],k); + mymaxlag = max(mymaxlag,k); + } + + if (((movefifoend[myconnectindex]-1)&(TIMERUPDATESIZ-1)) == 0) + { + i = mymaxlag-bufferjitter; mymaxlag = 0; + if (i > 0) bufferjitter += ((2+i)>>2); + else if (i < 0) bufferjitter -= ((2-i)>>2); + } + */ + + if (networkmode == 1) + { + packbuf[2] = 0; j = 3; + if (loc.fvel != oloc.fvel) packbuf[j++] = loc.fvel, packbuf[2] |= 1; + if (loc.svel != oloc.svel) packbuf[j++] = loc.svel, packbuf[2] |= 2; + if (loc.avel != oloc.avel) packbuf[j++] = loc.avel, packbuf[2] |= 4; + if ((loc.bits^oloc.bits)&0x00ff) packbuf[j++] = (loc.bits&255), packbuf[2] |= 8; + if ((loc.bits^oloc.bits)&0xff00) packbuf[j++] = ((loc.bits>>8)&255), packbuf[2] |= 16; + copybufbyte(&loc,&oloc,sizeof(input)); + + copybufbyte(&loc,&baksync[movefifoend[myconnectindex]][myconnectindex],sizeof(input)); + movefifoend[myconnectindex] = ((movefifoend[myconnectindex]+1)&(MOVEFIFOSIZ-1)); + + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + { + packbuf[0] = 17; + packbuf[1] = (char)((movefifoend[myconnectindex]-movefifoend[i])&(MOVEFIFOSIZ-1)); + + k = j; + if ((myconnectindex == connecthead) || ((i == connecthead) && (myconnectindex == connectpoint2[connecthead]))) + { + while (syncvalhead != syncvaltail) + { + packbuf[j++] = syncval[syncvaltail]; + syncvaltail = ((syncvaltail+1)&(MOVEFIFOSIZ-1)); + } + } + sendpacket(i,packbuf,j); + j = k; + } + + gotlastpacketclock = totalclock; + return; + } + + //MASTER (or 1 player game) + if ((myconnectindex == connecthead) || (option[4] == 0)) + { + copybufbyte(&loc,&ffsync[myconnectindex],sizeof(input)); + + if (option[4] != 0) + { + packbuf[0] = 0; + j = ((numplayers+1)>>1)+1; + for(k=1;k=0;i=connectpoint2[i]) + { + l = 0; + if (ffsync[i].fvel != osync[i].fvel) packbuf[j++] = ffsync[i].fvel, l |= 1; + if (ffsync[i].svel != osync[i].svel) packbuf[j++] = ffsync[i].svel, l |= 2; + if (ffsync[i].avel != osync[i].avel) packbuf[j++] = ffsync[i].avel, l |= 4; + if (ffsync[i].bits != osync[i].bits) + { + packbuf[j++] = (ffsync[i].bits&255); + packbuf[j++] = ((ffsync[i].bits>>8)&255); + l |= 8; + } + packbuf[k>>3] |= (l<<(k&7)); + k += 4; + + copybufbyte(&ffsync[i],&osync[i],sizeof(input)); + } + + while (syncvalhead != syncvaltail) + { + packbuf[j++] = syncval[syncvaltail]; + syncvaltail = ((syncvaltail+1)&(MOVEFIFOSIZ-1)); + } + + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + sendpacket(i,packbuf,j); + } + else if (numplayers >= 2) + { + if (keystatus[0xb5]) + { + keystatus[0xb5] = 0; + locselectedgun2++; if (locselectedgun2 >= 3) locselectedgun2 = 0; + } + + //Second player on 1 computer mode + loc2.fvel = min(max(fvel2,-128+8),127-8); + loc2.svel = min(max(svel2,-128+8),127-8); + loc2.avel = min(max(avel2,-128+16),127-16); + loc2.bits = (locselectedgun2<<13); + loc2.bits |= keystatus[0x45]; //Stand high + loc2.bits |= (keystatus[0x47]<<1); //Stand low + loc2.bits |= (1<<8); //Run + loc2.bits |= (keystatus[0x49]<<2); //Look up + loc2.bits |= (keystatus[0x37]<<3); //Look down + loc2.bits |= (keystatus[0x50]<<10); //Space + loc2.bits |= (keystatus[0x52]<<11); //Shoot + + other = connectpoint2[myconnectindex]; + if (other < 0) other = connecthead; + + copybufbyte(&loc2,&ffsync[other],sizeof(input)); + } + movethings(); //Move EVERYTHING (you too!) + } + else //I am a SLAVE + { + packbuf[0] = 1; packbuf[1] = 0; j = 2; + if (loc.fvel != oloc.fvel) packbuf[j++] = loc.fvel, packbuf[1] |= 1; + if (loc.svel != oloc.svel) packbuf[j++] = loc.svel, packbuf[1] |= 2; + if (loc.avel != oloc.avel) packbuf[j++] = loc.avel, packbuf[1] |= 4; + if ((loc.bits^oloc.bits)&0x00ff) packbuf[j++] = (loc.bits&255), packbuf[1] |= 8; + if ((loc.bits^oloc.bits)&0xff00) packbuf[j++] = ((loc.bits>>8)&255), packbuf[1] |= 16; + copybufbyte(&loc,&oloc,sizeof(input)); + sendpacket(connecthead,packbuf,j); + } +} + +void getpackets(void) +{ + long i, j, k, l; + long other, packbufleng, movecnt; + + if (option[4] == 0) return; + + movecnt = 0; + while ((packbufleng = getpacket(&other,packbuf)) > 0) + { + switch(packbuf[0]) + { + case 0: //[0] (receive master sync buffer) + j = ((numplayers+1)>>1)+1; k = (1<<3); + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + l = (packbuf[k>>3]>>(k&7)); + if (l&1) ffsync[i].fvel = packbuf[j++]; + if (l&2) ffsync[i].svel = packbuf[j++]; + if (l&4) ffsync[i].avel = packbuf[j++]; + if (l&8) + { + ffsync[i].bits = ((short)packbuf[j])+(((short)packbuf[j+1])<<8); + j += 2; + } + k += 4; + } + + while (j != packbufleng) + { + othersyncval[othersyncvalhead] = packbuf[j++]; + othersyncvalhead = ((othersyncvalhead+1)&(MOVEFIFOSIZ-1)); + } + if ((syncvalhead != syncvaltottail) && (othersyncvalhead != syncvaltottail)) + { + syncstat = 0; + do + { + syncstat |= (syncval[syncvaltottail]^othersyncval[syncvaltottail]); + syncvaltottail = ((syncvaltottail+1)&(MOVEFIFOSIZ-1)); + } while ((syncvalhead != syncvaltottail) && (othersyncvalhead != syncvaltottail)); + } + + movethings(); //Move all players and sprites + movecnt++; + break; + case 1: //[1] (receive slave sync buffer) + j = 2; k = packbuf[1]; + if (k&1) ffsync[other].fvel = packbuf[j++]; + if (k&2) ffsync[other].svel = packbuf[j++]; + if (k&4) ffsync[other].avel = packbuf[j++]; + if (k&8) ffsync[other].bits = ((ffsync[other].bits&0xff00)|((short)packbuf[j++])); + if (k&16) ffsync[other].bits = ((ffsync[other].bits&0x00ff)|(((short)packbuf[j++])<<8)); + break; + case 2: + getmessageleng = packbufleng-1; + for(j=getmessageleng-1;j>=0;j--) getmessage[j] = packbuf[j+1]; + getmessagetimeoff = totalclock+360+(getmessageleng<<4); + wsay("getstuff.wav",8192L,63L,63L); //Added 12/2004 + break; + case 3: + wsay("getstuff.wav",4096L,63L,63L); + break; + /* + case 5: + playerreadyflag[other] = packbuf[1]; + if ((other == connecthead) && (packbuf[1] == 2)) + sendpacket(connecthead,packbuf,2); + break; + */ + case 250: + playerreadyflag[other]++; + break; + case 17: + j = 3; k = packbuf[2]; + if (k&1) ffsync[other].fvel = packbuf[j++]; + if (k&2) ffsync[other].svel = packbuf[j++]; + if (k&4) ffsync[other].avel = packbuf[j++]; + if (k&8) ffsync[other].bits = ((ffsync[other].bits&0xff00)|((short)packbuf[j++])); + if (k&16) ffsync[other].bits = ((ffsync[other].bits&0x00ff)|(((short)packbuf[j++])<<8)); + otherlag[other] = packbuf[1]; + + copybufbyte(&ffsync[other],&baksync[movefifoend[other]][other],sizeof(input)); + movefifoend[other] = ((movefifoend[other]+1)&(MOVEFIFOSIZ-1)); + + while (j != packbufleng) + { + othersyncval[othersyncvalhead] = packbuf[j++]; + othersyncvalhead = ((othersyncvalhead+1)&(MOVEFIFOSIZ-1)); + } + if ((syncvalhead != syncvaltottail) && (othersyncvalhead != syncvaltottail)) + { + syncstat = 0; + do + { + syncstat |= (syncval[syncvaltottail]^othersyncval[syncvaltottail]); + syncvaltottail = ((syncvaltottail+1)&(MOVEFIFOSIZ-1)); + } while ((syncvalhead != syncvaltottail) && (othersyncvalhead != syncvaltottail)); + } + + break; + case 255: //[255] (logout) + keystatus[1] = 1; + break; + } + } + if ((networkmode == 0) && (myconnectindex != connecthead) && ((movecnt&1) == 0)) + { + if (rand()&1) ototalclock += (TICSPERFRAME>>1); + else ototalclock -= (TICSPERFRAME>>1); + } +} + +void drawoverheadmap(long cposx, long cposy, long czoom, short cang) +{ + long i, j, k, l=0, x1, y1, x2=0, y2=0, x3, y3, x4, y4, ox, oy, xoff, yoff; + long dax, day, cosang, sinang, xspan, yspan, sprx, spry; + long xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang; + long xvect, yvect, xvect2, yvect2; + char col; + walltype *wal, *wal2; + spritetype *spr; + + xvect = sintable[(-cang)&2047] * czoom; + yvect = sintable[(1536-cang)&2047] * czoom; + xvect2 = mulscale16(xvect,yxaspect); + yvect2 = mulscale16(yvect,yxaspect); + + //Draw red lines + for(i=0;inextwall; if (k < 0) continue; + + if ((show2dwall[j>>3]&(1<<(j&7))) == 0) continue; + if ((k > j) && ((show2dwall[k>>3]&(1<<(k&7))) > 0)) continue; + + if (sector[wal->nextsector].ceilingz == z1) + if (sector[wal->nextsector].floorz == z2) + if (((wal->cstat|wall[wal->nextwall].cstat)&(16+32)) == 0) continue; + + col = 152; + + if (dimensionmode[screenpeek] == 2) + { + if (sector[i].floorz != sector[i].ceilingz) + if (sector[wal->nextsector].floorz != sector[wal->nextsector].ceilingz) + if (((wal->cstat|wall[wal->nextwall].cstat)&(16+32)) == 0) + if (sector[i].floorz == sector[wal->nextsector].floorz) continue; + if (sector[i].floorpicnum != sector[wal->nextsector].floorpicnum) continue; + if (sector[i].floorshade != sector[wal->nextsector].floorshade) continue; + col = 12; + } + + ox = wal->x-cposx; oy = wal->y-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect)+(xdim<<11); + y1 = dmulscale16(oy,xvect2,ox,yvect2)+(ydim<<11); + + wal2 = &wall[wal->point2]; + ox = wal2->x-cposx; oy = wal2->y-cposy; + x2 = dmulscale16(ox,xvect,-oy,yvect)+(xdim<<11); + y2 = dmulscale16(oy,xvect2,ox,yvect2)+(ydim<<11); + + drawline256(x1,y1,x2,y2,col); + } + } + + //Draw sprites + k = playersprite[screenpeek]; + for(i=0;i=0;j=nextspritesect[j]) + if ((show2dsprite[j>>3]&(1<<(j&7))) > 0) + { + spr = &sprite[j]; if (spr->cstat&0x8000) continue; + col = 56; + if (spr->cstat&1) col = 248; + if (j == k) col = 31; + + k = statrate[spr->statnum]; + sprx = spr->x; + spry = spr->y; + if (k >= 0) + { + switch(k) + { + case 0: l = smoothratio; break; + case 1: l = (smoothratio>>1)+(((nummoves-j)&1)<<15); break; + case 3: l = (smoothratio>>2)+(((nummoves-j)&3)<<14); break; + case 7: l = (smoothratio>>3)+(((nummoves-j)&7)<<13); break; + case 15: l = (smoothratio>>4)+(((nummoves-j)&15)<<12); break; + } + sprx = osprite[j].x+mulscale16(sprx-osprite[j].x,l); + spry = osprite[j].y+mulscale16(spry-osprite[j].y,l); + } + + switch (spr->cstat&48) + { + case 0: + ox = sprx-cposx; oy = spry-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect); + y1 = dmulscale16(oy,xvect2,ox,yvect2); + + if (dimensionmode[screenpeek] == 1) + { + ox = (sintable[(spr->ang+512)&2047]>>7); + oy = (sintable[(spr->ang)&2047]>>7); + x2 = dmulscale16(ox,xvect,-oy,yvect); + y2 = dmulscale16(oy,xvect,ox,yvect); + + if (j == playersprite[screenpeek]) + { + x2 = 0L; + y2 = -(czoom<<5); + } + + x3 = mulscale16(x2,yxaspect); + y3 = mulscale16(y2,yxaspect); + + drawline256(x1-x2+(xdim<<11),y1-y3+(ydim<<11), + x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); + drawline256(x1-y2+(xdim<<11),y1+x3+(ydim<<11), + x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); + drawline256(x1+y2+(xdim<<11),y1-x3+(ydim<<11), + x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); + } + else + { + if (((gotsector[i>>3]&(1<<(i&7))) > 0) && (czoom > 96)) + { + daang = (spr->ang-cang)&2047; + if (j == playersprite[screenpeek]) { x1 = 0; y1 = 0; daang = 0; } + rotatesprite((x1<<4)+(xdim<<15),(y1<<4)+(ydim<<15),mulscale16(czoom*spr->yrepeat,yxaspect),daang,spr->picnum,spr->shade,spr->pal,(spr->cstat&2)>>1,windowx1,windowy1,windowx2,windowy2); + } + } + break; + case 16: + x1 = sprx; y1 = spry; + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + if ((spr->cstat&4) > 0) xoff = -xoff; + k = spr->ang; l = spr->xrepeat; + dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; + l = tilesizx[tilenum]; k = (l>>1)+xoff; + x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l); + y1 -= mulscale16(day,k); y2 = y1+mulscale16(day,l); + + ox = x1-cposx; oy = y1-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect); + y1 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x2-cposx; oy = y2-cposy; + x2 = dmulscale16(ox,xvect,-oy,yvect); + y2 = dmulscale16(oy,xvect2,ox,yvect2); + + drawline256(x1+(xdim<<11),y1+(ydim<<11), + x2+(xdim<<11),y2+(ydim<<11),col); + + break; + case 32: + if (dimensionmode[screenpeek] == 1) + { + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + if ((spr->cstat&4) > 0) xoff = -xoff; + if ((spr->cstat&8) > 0) yoff = -yoff; + + k = spr->ang; + cosang = sintable[(k+512)&2047]; sinang = sintable[k]; + xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; + yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; + + dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat; + x1 = sprx + dmulscale16(sinang,dax,cosang,day); + y1 = spry + dmulscale16(sinang,day,-cosang,dax); + l = xspan*xrepeat; + x2 = x1 - mulscale16(sinang,l); + y2 = y1 + mulscale16(cosang,l); + l = yspan*yrepeat; + k = -mulscale16(cosang,l); x3 = x2+k; x4 = x1+k; + k = -mulscale16(sinang,l); y3 = y2+k; y4 = y1+k; + + ox = x1-cposx; oy = y1-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect); + y1 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x2-cposx; oy = y2-cposy; + x2 = dmulscale16(ox,xvect,-oy,yvect); + y2 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x3-cposx; oy = y3-cposy; + x3 = dmulscale16(ox,xvect,-oy,yvect); + y3 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x4-cposx; oy = y4-cposy; + x4 = dmulscale16(ox,xvect,-oy,yvect); + y4 = dmulscale16(oy,xvect2,ox,yvect2); + + drawline256(x1+(xdim<<11),y1+(ydim<<11), + x2+(xdim<<11),y2+(ydim<<11),col); + + drawline256(x2+(xdim<<11),y2+(ydim<<11), + x3+(xdim<<11),y3+(ydim<<11),col); + + drawline256(x3+(xdim<<11),y3+(ydim<<11), + x4+(xdim<<11),y4+(ydim<<11),col); + + drawline256(x4+(xdim<<11),y4+(ydim<<11), + x1+(xdim<<11),y1+(ydim<<11),col); + + } + break; + } + } + + //Draw white lines + for(i=0;inextwall >= 0) continue; + + if ((show2dwall[j>>3]&(1<<(j&7))) == 0) continue; + + if (tilesizx[wal->picnum] == 0) continue; + if (tilesizy[wal->picnum] == 0) continue; + + if (j == k) + { x1 = x2; y1 = y2; } + else + { + ox = wal->x-cposx; oy = wal->y-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect)+(xdim<<11); + y1 = dmulscale16(oy,xvect2,ox,yvect2)+(ydim<<11); + } + + k = wal->point2; wal2 = &wall[k]; + ox = wal2->x-cposx; oy = wal2->y-cposy; + x2 = dmulscale16(ox,xvect,-oy,yvect)+(xdim<<11); + y2 = dmulscale16(oy,xvect2,ox,yvect2)+(ydim<<11); + + drawline256(x1,y1,x2,y2,24); + } + } +} + + //New movesprite using getzrange. Note that I made the getzrange + //parameters global (&globhiz,&globhihit,&globloz,&globlohit) so they + //don't need to be passed everywhere. Also this should make this + //movesprite function compatible with the older movesprite functions. +long movesprite(short spritenum, long dx, long dy, long dz, long ceildist, long flordist, long clipmask) +{ + long daz, zoffs, tempint; + short retval, dasectnum, datempshort; + spritetype *spr; + + spr = &sprite[spritenum]; + + if ((spr->cstat&128) == 0) + zoffs = -((tilesizy[spr->picnum]*spr->yrepeat)<<1); + else + zoffs = 0; + + dasectnum = spr->sectnum; //Can't modify sprite sectors directly becuase of linked lists + daz = spr->z+zoffs; //Must do this if not using the new centered centering (of course) + retval = clipmove(&spr->x,&spr->y,&daz,&dasectnum,dx,dy, + ((long)spr->clipdist)<<2,ceildist,flordist,clipmask); + + if (dasectnum < 0) retval = -1; + + if ((dasectnum != spr->sectnum) && (dasectnum >= 0)) + changespritesect(spritenum,dasectnum); + + //Set the blocking bit to 0 temporarly so getzrange doesn't pick up + //its own sprite + datempshort = spr->cstat; spr->cstat &= ~1; + getzrange(spr->x,spr->y,spr->z-1,spr->sectnum, + &globhiz,&globhihit,&globloz,&globlohit, + ((long)spr->clipdist)<<2,clipmask); + spr->cstat = datempshort; + + daz = spr->z+zoffs + dz; + if ((daz <= globhiz) || (daz > globloz)) + { + if (retval != 0) return(retval); + return(16384+dasectnum); + } + spr->z = daz-zoffs; + return(retval); +} + + +void waitforeverybody () +{ + long i; + if (numplayers < 2) return; + packbuf[0] = 250; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (i != myconnectindex) sendpacket(i,packbuf,1); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + playerreadyflag[myconnectindex]++; + while (1) + { + handleevents(); + refreshaudio(); + + drawrooms(posx[myconnectindex],posy[myconnectindex],posz[myconnectindex],ang[myconnectindex],horiz[myconnectindex],cursectnum[myconnectindex]); + if (!networkmode) Bsprintf(tempbuf,"Master/slave mode"); + else Bsprintf(tempbuf,"Peer-peer mode"); + printext256((xdim>>1)-(strlen(tempbuf)<<2),(ydim>>1)-24,31,0,tempbuf,0); + Bsprintf(tempbuf,"Waiting for players"); + printext256((xdim>>1)-(strlen(tempbuf)<<2),(ydim>>1)-16,31,0,tempbuf,0); + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (playerreadyflag[i] < playerreadyflag[myconnectindex]) + { + //slaves in M/S mode only wait for master + if ((!networkmode) && (myconnectindex != connecthead) && (i != connecthead)) + { + Bsprintf(tempbuf,"Player %ld",i); + printext256((xdim>>1)-(16<<2),(ydim>>1)+i*8,15,0,tempbuf,0); + } + else + { + Bsprintf(tempbuf,"Player %ld NOT ready",i); + printext256((xdim>>1)-(16<<2),(ydim>>1)+i*8,127,0,tempbuf,0); + } + } + else + { + Bsprintf(tempbuf,"Player %ld ready",i); + printext256((xdim>>1)-(16<<2),(ydim>>1)+i*8,31,0,tempbuf,0); + } + if (i == myconnectindex) + { + Bsprintf(tempbuf,"You->"); + printext256((xdim>>1)-(26<<2),(ydim>>1)+i*8,95,0,tempbuf,0); + } + } + nextpage(); + + + if (quitevent || keystatus[1]) { + sendlogoff(); //Signing off + musicoff(); + uninitmultiplayers(); + uninittimer(); + uninitinput(); + uninitengine(); + uninitsb(); + uninitgroupfile(); + exit(0); + } + + getpackets(); + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (playerreadyflag[i] < playerreadyflag[myconnectindex]) break; + if ((!networkmode) && (myconnectindex != connecthead)) { i = -1; break; } //slaves in M/S mode only wait for master + } + if (i < 0) return; + } +} + + +void searchmap(short startsector) +{ + long i, j, dasect, splc, send, startwall, endwall; + short dapic; + walltype *wal; + + if ((startsector < 0) || (startsector >= numsectors)) return; + for(i=0;i<(MAXSECTORS>>3);i++) show2dsector[i] = 0; + for(i=0;i<(MAXWALLS>>3);i++) show2dwall[i] = 0; + for(i=0;i<(MAXSPRITES>>3);i++) show2dsprite[i] = 0; + + automapping = 0; + + //Search your area recursively & set all show2dsector/show2dwalls + tempshort[0] = startsector; + show2dsector[startsector>>3] |= (1<<(startsector&7)); + dapic = sector[startsector].ceilingpicnum; + if (waloff[dapic] == 0) loadtile(dapic); + dapic = sector[startsector].floorpicnum; + if (waloff[dapic] == 0) loadtile(dapic); + for(splc=0,send=1;splc>3] |= (1<<(i&7)); + dapic = wall[i].picnum; + if (waloff[dapic] == 0) loadtile(dapic); + dapic = wall[i].overpicnum; + if (((dapic&0xfffff000) == 0) && (waloff[dapic] == 0)) loadtile(dapic); + + j = wal->nextsector; + if ((j >= 0) && ((show2dsector[j>>3]&(1<<(j&7))) == 0)) + { + show2dsector[j>>3] |= (1<<(j&7)); + + dapic = sector[j].ceilingpicnum; + if (waloff[dapic] == 0) loadtile(dapic); + dapic = sector[j].floorpicnum; + if (waloff[dapic] == 0) loadtile(dapic); + + tempshort[send++] = (short)j; + } + } + + for(i=headspritesect[dasect];i>=0;i=nextspritesect[i]) + { + show2dsprite[i>>3] |= (1<<(i&7)); + dapic = sprite[i].picnum; + if (waloff[dapic] == 0) loadtile(dapic); + } + } +} + +void setinterpolation(long *posptr) +{ + long i; + + if (numinterpolations >= MAXINTERPOLATIONS) return; + for(i=numinterpolations-1;i>=0;i--) + if (curipos[i] == posptr) return; + curipos[numinterpolations] = posptr; + oldipos[numinterpolations] = *posptr; + numinterpolations++; +} + +void stopinterpolation(long *posptr) +{ + long i; + + for(i=numinterpolations-1;i>=startofdynamicinterpolations;i--) + if (curipos[i] == posptr) + { + numinterpolations--; + oldipos[i] = oldipos[numinterpolations]; + bakipos[i] = bakipos[numinterpolations]; + curipos[i] = curipos[numinterpolations]; + } +} + +void updateinterpolations(void) //Stick at beginning of domovethings +{ + long i; + + for(i=numinterpolations-1;i>=0;i--) oldipos[i] = *curipos[i]; +} + +void dointerpolations(void) //Stick at beginning of drawscreen +{ + long i, j, odelta, ndelta; + + ndelta = 0; j = 0; + for(i=numinterpolations-1;i>=0;i--) + { + bakipos[i] = *curipos[i]; + odelta = ndelta; ndelta = (*curipos[i])-oldipos[i]; + if (odelta != ndelta) j = mulscale16(ndelta,smoothratio); + *curipos[i] = oldipos[i]+j; + } +} + +void restoreinterpolations(void) //Stick at end of drawscreen +{ + long i; + + for(i=numinterpolations-1;i>=0;i--) *curipos[i] = bakipos[i]; +} + +void printext(long x, long y, char *buffer, short tilenum, char invisiblecol) +{ + long i; + char ch; + + for(i=0;buffer[i]!=0;i++) + { + ch = buffer[i]; + rotatesprite((x-((8&15)<<3))<<16,(y-((8>>4)<<3))<<16,65536L,0,tilenum,0,0,8+16+64+128,x,y,x+7,y+7); + rotatesprite((x-((ch&15)<<3))<<16,(y-((ch>>4)<<3))<<16,65536L,0,tilenum,0,0,8+16+128,x,y,x+7,y+7); + x += 8; + } +} + +void drawtilebackground (long thex, long they, short tilenum, + signed char shade, long cx1, long cy1, + long cx2, long cy2, char dapalnum) +{ + long x, y, xsiz, ysiz, tx1, ty1, tx2, ty2; + + xsiz = tilesizx[tilenum]; tx1 = cx1/xsiz; tx2 = cx2/xsiz; + ysiz = tilesizy[tilenum]; ty1 = cy1/ysiz; ty2 = cy2/ysiz; + + for(x=tx1;x<=tx2;x++) + for(y=ty1;y<=ty2;y++) + rotatesprite(x*xsiz<<16,y*ysiz<<16,65536L,0,tilenum,shade,dapalnum,8+16+64+128,cx1,cy1,cx2,cy2); +} + + +/* + * vim:ts=4:sw=4: + */ diff --git a/polymer/build/src/gamestartwin.c b/polymer/build/src/gamestartwin.c new file mode 100644 index 000000000..f210933fd --- /dev/null +++ b/polymer/build/src/gamestartwin.c @@ -0,0 +1,144 @@ +#ifndef RENDERTYPEWIN +#error Only for Windows +#endif + +#include "build.h" +#include "editor.h" +#include "winlayer.h" +#include "compat.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include + + +#define IDCFULLSCREEN 100 +#define IDCVMODE 101 + +static void PopulateVideoModeLists(int fs, HWND list3d) +{ + int i,j; + char buf[64]; + + ComboBox_ResetContent(list3d); + for (i=0; i 0) { + if (!IsWindow(hwndLaunch) || quitevent) break; + if (IsDialogMessage(hwndStart, &msg) /*|| IsDialogMessage(hwndLaunch, &msg)*/) continue; + + TranslateMessage(&msg); + DispatchMessage(&msg); + } + EnableWindow(GetDlgItem(hwndStart,WIN_STARTWIN_ITEMLIST),TRUE); + } + if (quitevent) return 1; + return 0; +} + diff --git a/polymer/build/src/glbuild.c b/polymer/build/src/glbuild.c new file mode 100644 index 000000000..060c9ace3 --- /dev/null +++ b/polymer/build/src/glbuild.c @@ -0,0 +1,359 @@ +#include "glbuild.h" +#include "baselayer.h" +#include +#include +#include + +#if defined DYNAMIC_OPENGL && defined USE_OPENGL + +#ifdef RENDERTYPESDL +#include "SDL.h" +#endif + +void (APIENTRY * bglClearColor)( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); +void (APIENTRY * bglClear)( GLbitfield mask ); +void (APIENTRY * bglColorMask)( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); +void (APIENTRY * bglAlphaFunc)( GLenum func, GLclampf ref ); +void (APIENTRY * bglBlendFunc)( GLenum sfactor, GLenum dfactor ); +void (APIENTRY * bglCullFace)( GLenum mode ); +void (APIENTRY * bglFrontFace)( GLenum mode ); +void (APIENTRY * bglPolygonOffset)( GLfloat factor, GLfloat units ); +void (APIENTRY * bglPolygonMode)( GLenum face, GLenum mode ); +void (APIENTRY * bglEnable)( GLenum cap ); +void (APIENTRY * bglDisable)( GLenum cap ); +void (APIENTRY * bglGetFloatv)( GLenum pname, GLfloat *params ); +void (APIENTRY * bglGetIntegerv)( GLenum pname, GLint *params ); +void (APIENTRY * bglPushAttrib)( GLbitfield mask ); +void (APIENTRY * bglPopAttrib)( void ); +GLenum (APIENTRY * bglGetError)( void ); +const GLubyte* (APIENTRY * bglGetString)( GLenum name ); +void (APIENTRY * bglHint)( GLenum target, GLenum mode ); + +// Depth +void (APIENTRY * bglDepthFunc)( GLenum func ); +void (APIENTRY * bglDepthMask)( GLboolean flag ); +void (APIENTRY * bglDepthRange)( GLclampd near_val, GLclampd far_val ); + +// Matrix +void (APIENTRY * bglMatrixMode)( GLenum mode ); +void (APIENTRY * bglOrtho)( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); +void (APIENTRY * bglFrustum)( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); +void (APIENTRY * bglViewport)( GLint x, GLint y, GLsizei width, GLsizei height ); +void (APIENTRY * bglPushMatrix)( void ); +void (APIENTRY * bglPopMatrix)( void ); +void (APIENTRY * bglLoadIdentity)( void ); +void (APIENTRY * bglLoadMatrixf)( const GLfloat *m ); + +// Drawing +void (APIENTRY * bglBegin)( GLenum mode ); +void (APIENTRY * bglEnd)( void ); +void (APIENTRY * bglVertex2f)( GLfloat x, GLfloat y ); +void (APIENTRY * bglVertex2i)( GLint x, GLint y ); +void (APIENTRY * bglVertex3d)( GLdouble x, GLdouble y, GLdouble z ); +void (APIENTRY * bglVertex3fv)( const GLfloat *v ); +void (APIENTRY * bglColor4f)( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); +void (APIENTRY * bglColor4ub)( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ); +void (APIENTRY * bglTexCoord2d)( GLdouble s, GLdouble t ); +void (APIENTRY * bglTexCoord2f)( GLfloat s, GLfloat t ); + +// Lighting +void (APIENTRY * bglShadeModel)( GLenum mode ); + +// Raster funcs +void (APIENTRY * bglReadPixels)( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ); + +// Texture mapping +void (APIENTRY * bglTexEnvf)( GLenum target, GLenum pname, GLfloat param ); +void (APIENTRY * bglGenTextures)( GLsizei n, GLuint *textures ); // 1.1 +void (APIENTRY * bglDeleteTextures)( GLsizei n, const GLuint *textures); // 1.1 +void (APIENTRY * bglBindTexture)( GLenum target, GLuint texture ); // 1.1 +void (APIENTRY * bglTexImage2D)( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); +void (APIENTRY * bglTexSubImage2D)( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); // 1.1 +void (APIENTRY * bglTexParameterf)( GLenum target, GLenum pname, GLfloat param ); +void (APIENTRY * bglTexParameteri)( GLenum target, GLenum pname, GLint param ); +void (APIENTRY * bglGetTexLevelParameteriv)( GLenum target, GLint level, GLenum pname, GLint *params ); +void (APIENTRY * bglCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +void (APIENTRY * bglGetCompressedTexImageARB)(GLenum, GLint, GLvoid *); + +// Fog +void (APIENTRY * bglFogf)( GLenum pname, GLfloat param ); +void (APIENTRY * bglFogi)( GLenum pname, GLint param ); +void (APIENTRY * bglFogfv)( GLenum pname, const GLfloat *params ); + +#ifdef RENDERTYPEWIN +// Windows +HGLRC (WINAPI * bwglCreateContext)(HDC); +BOOL (WINAPI * bwglDeleteContext)(HGLRC); +PROC (WINAPI * bwglGetProcAddress)(LPCSTR); +BOOL (WINAPI * bwglMakeCurrent)(HDC,HGLRC); + +BOOL (WINAPI * bwglSwapBuffers)(HDC); +int (WINAPI * bwglChoosePixelFormat)(HDC,CONST PIXELFORMATDESCRIPTOR*); +int (WINAPI * bwglDescribePixelFormat)(HDC,int,UINT,LPPIXELFORMATDESCRIPTOR); +int (WINAPI * bwglGetPixelFormat)(HDC); +BOOL (WINAPI * bwglSetPixelFormat)(HDC,int,const PIXELFORMATDESCRIPTOR*); + +static HANDLE hGLDLL; +#endif + + +char *gldriver = NULL; + +static void * getproc_(const char *s, int *err, int fatal, int extension) +{ + void *t; +#if defined RENDERTYPESDL + t = (void*)SDL_GL_GetProcAddress(s); +#elif defined _WIN32 + if (extension) t = (void*)bwglGetProcAddress(s); + else t = (void*)GetProcAddress(hGLDLL,s); +#else +#error Need a dynamic loader for this platform... +#endif + if (!t && fatal) { + initprintf("Failed to find %s in %s\n", s, gldriver); + *err = 1; + } + return t; +} +#define GETPROC(s) getproc_(s,&err,1,0) +#define GETPROCSOFT(s) getproc_(s,&err,0,0) +#define GETPROCEXT(s) getproc_(s,&err,1,1) +#define GETPROCEXTSOFT(s) getproc_(s,&err,0,1) + +int loadgldriver(const char *driver) +{ + void *t; + int err=0; + +#ifdef RENDERTYPEWIN + if (hGLDLL) return 0; +#endif + + if (!driver) { +#ifdef _WIN32 + driver = "OPENGL32.DLL"; +#else + driver = "libGL.so"; +#endif + } + + initprintf("Loading %s\n",driver); + +#if defined RENDERTYPESDL + if (SDL_GL_LoadLibrary(driver)) return -1; +#elif defined _WIN32 + hGLDLL = LoadLibrary(driver); + if (!hGLDLL) return -1; +#endif + gldriver = strdup(driver); + +#ifdef RENDERTYPEWIN + bwglCreateContext = GETPROC("wglCreateContext"); + bwglDeleteContext = GETPROC("wglDeleteContext"); + bwglGetProcAddress = GETPROC("wglGetProcAddress"); + bwglMakeCurrent = GETPROC("wglMakeCurrent"); + + bwglSwapBuffers = GETPROC("wglSwapBuffers"); + bwglChoosePixelFormat = GETPROC("wglChoosePixelFormat"); + bwglDescribePixelFormat = GETPROC("wglDescribePixelFormat"); + bwglGetPixelFormat = GETPROC("wglGetPixelFormat"); + bwglSetPixelFormat = GETPROC("wglSetPixelFormat"); +#endif + + bglClearColor = GETPROC("glClearColor"); + bglClear = GETPROC("glClear"); + bglColorMask = GETPROC("glColorMask"); + bglAlphaFunc = GETPROC("glAlphaFunc"); + bglBlendFunc = GETPROC("glBlendFunc"); + bglCullFace = GETPROC("glCullFace"); + bglFrontFace = GETPROC("glFrontFace"); + bglPolygonOffset = GETPROC("glPolygonOffset"); + bglPolygonMode = GETPROC("glPolygonMode"); + bglEnable = GETPROC("glEnable"); + bglDisable = GETPROC("glDisable"); + bglGetFloatv = GETPROC("glGetFloatv"); + bglGetIntegerv = GETPROC("glGetIntegerv"); + bglPushAttrib = GETPROC("glPushAttrib"); + bglPopAttrib = GETPROC("glPopAttrib"); + bglGetError = GETPROC("glGetError"); + bglGetString = GETPROC("glGetString"); + bglHint = GETPROC("glHint"); + + // Depth + bglDepthFunc = GETPROC("glDepthFunc"); + bglDepthMask = GETPROC("glDepthMask"); + bglDepthRange = GETPROC("glDepthRange"); + + // Matrix + bglMatrixMode = GETPROC("glMatrixMode"); + bglOrtho = GETPROC("glOrtho"); + bglFrustum = GETPROC("glFrustum"); + bglViewport = GETPROC("glViewport"); + bglPushMatrix = GETPROC("glPushMatrix"); + bglPopMatrix = GETPROC("glPopMatrix"); + bglLoadIdentity = GETPROC("glLoadIdentity"); + bglLoadMatrixf = GETPROC("glLoadMatrixf"); + + // Drawing + bglBegin = GETPROC("glBegin"); + bglEnd = GETPROC("glEnd"); + bglVertex2f = GETPROC("glVertex2f"); + bglVertex2i = GETPROC("glVertex2i"); + bglVertex3d = GETPROC("glVertex3d"); + bglVertex3fv = GETPROC("glVertex3fv"); + bglColor4f = GETPROC("glColor4f"); + bglColor4ub = GETPROC("glColor4ub"); + bglTexCoord2d = GETPROC("glTexCoord2d"); + bglTexCoord2f = GETPROC("glTexCoord2f"); + + // Lighting + bglShadeModel = GETPROC("glShadeModel"); + + // Raster funcs + bglReadPixels = GETPROC("glReadPixels"); + + // Texture mapping + bglTexEnvf = GETPROC("glTexEnvf"); + bglGenTextures = GETPROC("glGenTextures"); + bglDeleteTextures = GETPROC("glDeleteTextures"); + bglBindTexture = GETPROC("glBindTexture"); + bglTexImage2D = GETPROC("glTexImage2D"); + bglTexSubImage2D = GETPROC("glTexSubImage2D"); + bglTexParameterf = GETPROC("glTexParameterf"); + bglTexParameteri = GETPROC("glTexParameteri"); + bglGetTexLevelParameteriv = GETPROC("glGetTexLevelParameteriv"); + + // Fog + bglFogf = GETPROC("glFogf"); + bglFogi = GETPROC("glFogi"); + bglFogfv = GETPROC("glFogfv"); + + loadglextensions(); + + if (err) unloadgldriver(); + return err; +} + +int loadglextensions(void) +{ + int err = 0; +#ifdef RENDERTYPEWIN + if (!hGLDLL) return 0; +#endif + + bglCompressedTexImage2DARB = GETPROCEXTSOFT("glCompressedTexImage2DARB"); + bglGetCompressedTexImageARB = GETPROCEXTSOFT("glGetCompressedTexImageARB"); + + return err; +} + +int unloadgldriver(void) +{ +#ifdef RENDERTYPEWIN + if (!hGLDLL) return 0; +#endif + + free(gldriver); + gldriver = NULL; + +#ifdef RENDERTYPEWIN + FreeLibrary(hGLDLL); + hGLDLL = NULL; +#endif + + bglClearColor = NULL; + bglClear = NULL; + bglColorMask = NULL; + bglAlphaFunc = NULL; + bglBlendFunc = NULL; + bglCullFace = NULL; + bglFrontFace = NULL; + bglPolygonOffset = NULL; + bglPolygonMode = NULL; + bglEnable = NULL; + bglDisable = NULL; + bglGetFloatv = NULL; + bglGetIntegerv = NULL; + bglPushAttrib = NULL; + bglPopAttrib = NULL; + bglGetError = NULL; + bglGetString = NULL; + bglHint = NULL; + + // Depth + bglDepthFunc = NULL; + bglDepthMask = NULL; + bglDepthRange = NULL; + + // Matrix + bglMatrixMode = NULL; + bglOrtho = NULL; + bglFrustum = NULL; + bglViewport = NULL; + bglPushMatrix = NULL; + bglPopMatrix = NULL; + bglLoadIdentity = NULL; + bglLoadMatrixf = NULL; + + // Drawing + bglBegin = NULL; + bglEnd = NULL; + bglVertex2f = NULL; + bglVertex2i = NULL; + bglVertex3d = NULL; + bglVertex3fv = NULL; + bglColor4f = NULL; + bglColor4ub = NULL; + bglTexCoord2d = NULL; + bglTexCoord2f = NULL; + + // Lighting + bglShadeModel = NULL; + + // Raster funcs + bglReadPixels = NULL; + + // Texture mapping + bglTexEnvf = NULL; + bglGenTextures = NULL; + bglDeleteTextures = NULL; + bglBindTexture = NULL; + bglTexImage2D = NULL; + bglTexSubImage2D = NULL; + bglTexParameterf = NULL; + bglTexParameteri = NULL; + bglGetTexLevelParameteriv = NULL; + bglCompressedTexImage2DARB = NULL; + bglGetCompressedTexImageARB = NULL; + + // Fog + bglFogf = NULL; + bglFogi = NULL; + bglFogfv = NULL; + +#ifdef RENDERTYPEWIN + bwglCreateContext = NULL; + bwglDeleteContext = NULL; + bwglGetProcAddress = NULL; + bwglMakeCurrent = NULL; + + bwglSwapBuffers = NULL; + bwglChoosePixelFormat = NULL; + bwglDescribePixelFormat = NULL; + bwglGetPixelFormat = NULL; + bwglSetPixelFormat = NULL; +#endif + + return 0; +} + +#else + +char *gldriver = ""; + +int loadgldriver(const char *a) { return 0; } +int unloadgldriver(void) { return 0; } + +#endif + diff --git a/polymer/build/src/gtkbits.c b/polymer/build/src/gtkbits.c new file mode 100644 index 000000000..8c359ecad --- /dev/null +++ b/polymer/build/src/gtkbits.c @@ -0,0 +1,238 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "baselayer.h" +#include "build.h" + +static int gtkenabled = 0; + +extern const GdkPixdata startbanner_pixdata; +static GtkWidget *startwin = NULL; +static GdkPixbuf *appicon = NULL; + +#define GLADE_HOOKUP_OBJECT(component,widget,name) \ + g_object_set_data_full (G_OBJECT (component), name, \ + gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) + +#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ + g_object_set_data (G_OBJECT (component), name, widget) + +#define lookup_widget(x,w) \ + (GtkWidget*) g_object_get_data(G_OBJECT(x), w) + +static gboolean on_startwin_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) +{ + quitevent++; + return TRUE; // FALSE would let the event go through. we want the game to decide when to close +} + +void gtkbuild_create_startwin(void) +{ + GtkWidget *banner, *label, *content, *scroll; + GtkWidget *hbox1, *fixed1; + GdkPixbuf *startbanner_pixbuf; + + if (!gtkenabled) return; + + startwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title (GTK_WINDOW (startwin), apptitle); + gtk_window_set_position (GTK_WINDOW (startwin), GTK_WIN_POS_CENTER); + gtk_window_set_resizable (GTK_WINDOW (startwin), FALSE); + gtk_window_set_type_hint (GTK_WINDOW (startwin), GDK_WINDOW_TYPE_HINT_DIALOG); + + hbox1 = gtk_hbox_new (FALSE, 0); + gtk_widget_show (hbox1); + gtk_container_add (GTK_CONTAINER (startwin), hbox1); + + startbanner_pixbuf = gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); + banner = gtk_image_new_from_pixbuf(startbanner_pixbuf); + g_object_unref((gpointer)startbanner_pixbuf); + gtk_widget_show (banner); + gtk_box_pack_start (GTK_BOX (hbox1), banner, FALSE, FALSE, 0); + + fixed1 = gtk_fixed_new (); + gtk_widget_show (fixed1); + gtk_box_pack_start (GTK_BOX (hbox1), fixed1, TRUE, TRUE, 0); + gtk_widget_set_size_request (fixed1, 390, -1); + + label = gtk_label_new (startwin_labeltext); + gtk_widget_show (label); + gtk_fixed_put (GTK_FIXED (fixed1), label, 6, 6); + gtk_widget_set_size_request (label, 378, 16); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); + + scroll = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_show (scroll); + gtk_fixed_put (GTK_FIXED (fixed1), scroll, 6, 28); + gtk_widget_set_size_request (scroll, 378, 248); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); + + content = gtk_text_view_new (); + gtk_widget_show (content); + gtk_container_add (GTK_CONTAINER(scroll), content); + //gtk_fixed_put (GTK_FIXED (fixed1), content, 6, 28); + gtk_widget_set_size_request (content, 378, 248); + gtk_text_view_set_editable (GTK_TEXT_VIEW (content), FALSE); + gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (content), GTK_WRAP_WORD); + gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (content), FALSE); + + g_signal_connect ((gpointer) startwin, "delete_event", + G_CALLBACK (on_startwin_delete_event), + NULL); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF (startwin, startwin, "startwin"); + GLADE_HOOKUP_OBJECT (startwin, banner, "banner"); + GLADE_HOOKUP_OBJECT (startwin, label, "label"); + GLADE_HOOKUP_OBJECT (startwin, scroll, "scroll"); + GLADE_HOOKUP_OBJECT (startwin, content, "content"); + + g_signal_connect((gpointer)startwin, "destroy", G_CALLBACK(gtk_widget_destroyed), (gpointer)&startwin); + gtk_widget_show (startwin); + gtk_main_iteration_do (FALSE); +} + +void gtkbuild_settitle_startwin(const char *title) +{ + if (!gtkenabled || !startwin) return; + gtk_window_set_title (GTK_WINDOW (startwin), title); +} + +void gtkbuild_puts_startwin(const char *str) +{ + GtkWidget *textview; + GtkTextBuffer *textbuffer; + GtkTextIter enditer; + GtkTextMark *mark; + const char *aptr, *bptr; + + if (!gtkenabled || !startwin || !str) return; + if (!(textview = lookup_widget(startwin, "content"))) return; + textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); + + gtk_text_buffer_get_end_iter(textbuffer, &enditer); + for (aptr = bptr = str; *aptr != 0; ) { + switch (*bptr) { + case '\b': + if (bptr > aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); +#if GTK_CHECK_VERSION(2,6,0) + gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); +#else + { + GtkTextIter iter2 = enditer; + gtk_text_iter_backward_cursor_position(&iter2); + //FIXME: this seems be deleting one too many chars somewhere! + if (!gtk_text_iter_equal(&iter2, &enditer)) + gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); + } +#endif + aptr = ++bptr; + break; + case 0: + if (bptr > aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); + aptr = bptr; + break; + case '\r': // FIXME + default: + bptr++; + break; + } + } + + mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1); + gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0); + gtk_text_buffer_delete_mark(textbuffer, mark); +} + +void gtkbuild_close_startwin(void) +{ + if (!gtkenabled) return; + if (startwin) { + gtk_widget_destroy (startwin); + startwin = NULL; + } +} + +void gtkbuild_update_startwin(void) +{ + if (!gtkenabled) return; + gtk_main_iteration_do (FALSE); +} + + +int gtkbuild_msgbox(char *name, char *msg) +{ + GtkWidget *dialog; + + if (!gtkenabled) return -1; + + dialog = gtk_message_dialog_new(NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + msg); + gtk_window_set_title(GTK_WINDOW(dialog), name); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + + return 1; +} + +int gtkbuild_ynbox(char *name, char *msg) +{ + int r; + GtkWidget *dialog; + + if (!gtkenabled) return -1; + + dialog = gtk_message_dialog_new(NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_YES_NO, + msg); + gtk_window_set_title(GTK_WINDOW(dialog), name); + r = gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + + if (r == GTK_RESPONSE_YES) return 1; + return 0; +} + +#ifdef RENDERTYPESDL +#include "sdlayer.h" +extern struct sdlappicon sdlappicon; +#endif +void gtkbuild_init(int argc, char **argv) +{ + gtkenabled = gtk_init_check(argc, argv); + if (!gtkenabled) return; +#ifdef RENDERTYPESDL + appicon = gdk_pixbuf_new_from_data((const guchar *)sdlappicon.pixels, + GDK_COLORSPACE_RGB, TRUE, 8, sdlappicon.width, sdlappicon.height, + sdlappicon.width*4, NULL, NULL); +#endif + if (appicon) gtk_window_set_default_icon(appicon); +} + +void gtkbuild_exit(int r) +{ + if (!gtkenabled) return; + if (appicon) g_object_unref((gpointer)appicon); + //gtk_exit(r); +} + +void *gtkbuild_get_app_icon(void) +{ + return appicon; +} diff --git a/polymer/build/src/hightile.c b/polymer/build/src/hightile.c new file mode 100644 index 000000000..182216af7 --- /dev/null +++ b/polymer/build/src/hightile.c @@ -0,0 +1,254 @@ +/* + * High-colour textures support for Polymost + * by Jonathon Fowler + * See the included license file "BUILDLIC.TXT" for license info. + */ + +#include "kplib.h" + +#define HICEFFECTMASK (1|2) +static palette_t hictinting[MAXPALOOKUPS]; + +struct hicskybox_t { + long ignore; + char *face[6]; +}; +typedef struct hicreplc_t { + struct hicreplc_t *next; + char palnum, ignore, flags, filler; + char *filename; + float alphacut; + struct hicskybox_t *skybox; +} hicreplctyp; +static hicreplctyp *hicreplc[MAXTILES]; +static char hicfirstinit = 0; + +// +// find the index into hicreplc[] which contains the replacement tile particulars +// +static hicreplctyp * hicfindsubst(long picnum, long palnum, long skybox) +{ + hicreplctyp *hr; + + if (!hicfirstinit) return NULL; + if ((unsigned long)picnum >= (unsigned long)MAXTILES) return NULL; + + do { + for (hr = hicreplc[picnum]; hr; hr = hr->next) { + if (hr->palnum == palnum) { + if (skybox) { + if (hr->skybox && !hr->skybox->ignore) return hr; + } else { + if (!hr->ignore) return hr; + } + } + } + + if (!palnum) break; + palnum = 0; + } while (1); + + return NULL; // no replacement found +} + + +// +// hicinit() +// Initialise the high-colour stuff to default. +// +void hicinit(void) +{ + long i,j; + hicreplctyp *hr, *next; + + for (i=0;i=0;i--) { + for (hr=hicreplc[i]; hr; ) { + next = hr->next; + + if (hr->skybox) { + for (j=5;j>=0;j--) { + if (hr->skybox->face[j]) { + free(hr->skybox->face[j]); + } + } + free(hr->skybox); + } + if (hr->filename) free(hr->filename); + free(hr); + + hr = next; + } + } + memset(hicreplc,0,sizeof(hicreplc)); + + hicfirstinit = 1; +} + + +// +// hicsetpalettetint(pal,r,g,b,effect) +// The tinting values represent a mechanism for emulating the effect of global sector +// palette shifts on true-colour textures and only true-colour textures. +// effect bitset: 1 = greyscale, 2 = invert +// +void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) +{ + if ((unsigned long)palnum >= (unsigned long)MAXPALOOKUPS) return; + if (!hicfirstinit) hicinit(); + + hictinting[palnum].r = r; + hictinting[palnum].g = g; + hictinting[palnum].b = b; + hictinting[palnum].f = effect & HICEFFECTMASK; +} + + +// +// hicsetsubsttex(picnum,pal,filen,alphacut) +// Specifies a replacement graphic file for an ART tile. +// +int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char flags) +{ + hicreplctyp *hr, *hrn; + + if ((unsigned long)picnum >= (unsigned long)MAXTILES) return -1; + if ((unsigned long)palnum >= (unsigned long)MAXPALOOKUPS) return -1; + if (!hicfirstinit) hicinit(); + + for (hr = hicreplc[picnum]; hr; hr = hr->next) { + if (hr->palnum == palnum) + break; + } + + if (!hr) { + // no replacement yet defined + hrn = (hicreplctyp *)calloc(1,sizeof(hicreplctyp)); + if (!hrn) return -1; + hrn->palnum = palnum; + } else hrn = hr; + + // store into hicreplc the details for this replacement + if (hrn->filename) free(hrn->filename); + + hrn->filename = strdup(filen); + if (!hrn->filename) { + if (hrn->skybox) return -1; // don't free the base structure if there's a skybox defined + if (hr == NULL) free(hrn); // not yet a link in the chain + return -1; + } + hrn->ignore = 0; + hrn->alphacut = min(alphacut,1.0); + hrn->flags = flags; + if (hr == NULL) { + hrn->next = hicreplc[picnum]; + hicreplc[picnum] = hrn; + } + + //printf("Replacement [%d,%d]: %s\n", picnum, palnum, hicreplc[i]->filename); + + return 0; +} + + +// +// hicsetskybox(picnum,pal,faces[6]) +// Specifies a graphic files making up a skybox. +// +int hicsetskybox(long picnum, long palnum, char *faces[6]) +{ + hicreplctyp *hr, *hrn; + long j; + + if ((unsigned long)picnum >= (unsigned long)MAXTILES) return -1; + if ((unsigned long)palnum >= (unsigned long)MAXPALOOKUPS) return -1; + for (j=5;j>=0;j--) if (!faces[j]) return -1; + if (!hicfirstinit) hicinit(); + + for (hr = hicreplc[picnum]; hr; hr = hr->next) { + if (hr->palnum == palnum) + break; + } + + if (!hr) { + // no replacement yet defined + hrn = (hicreplctyp *)calloc(1,sizeof(hicreplctyp)); + if (!hrn) return -1; + + hrn->palnum = palnum; + } else hrn = hr; + + if (!hrn->skybox) { + hrn->skybox = (struct hicskybox_t *)calloc(1,sizeof(struct hicskybox_t)); + if (!hrn->skybox) { + if (hr == NULL) free(hrn); // not yet a link in the chain + return -1; + } + } else { + for (j=5;j>=0;j--) { + if (hrn->skybox->face[j]) + free(hrn->skybox->face[j]); + } + } + + // store each face's filename + for (j=0;j<6;j++) { + hrn->skybox->face[j] = strdup(faces[j]); + if (!hrn->skybox->face[j]) { + for (--j; j>=0; --j) // free any previous faces + free(hrn->skybox->face[j]); + free(hrn->skybox); + hrn->skybox = NULL; + if (hr == NULL) free(hrn); + return -1; + } + } + hrn->skybox->ignore = 0; + if (hr == NULL) { + hrn->next = hicreplc[picnum]; + hicreplc[picnum] = hrn; + } + + return 0; +} + + +// +// hicclearsubst(picnum,pal) +// Clears a replacement for an ART tile, including skybox faces. +// +int hicclearsubst(long picnum, long palnum) +{ + hicreplctyp *hr, *hrn = NULL; + + if ((unsigned long)picnum >= (unsigned long)MAXTILES) return -1; + if ((unsigned long)palnum >= (unsigned long)MAXPALOOKUPS) return -1; + if (!hicfirstinit) return 0; + + for (hr = hicreplc[picnum]; hr; hrn = hr, hr = hr->next) { + if (hr->palnum == palnum) + break; + } + + if (!hr) return 0; + + if (hr->filename) free(hr->filename); + if (hr->skybox) { + int i; + for (i=5;i>=0;i--) + if (hr->skybox->face[i]) + free(hr->skybox->face[i]); + free(hr->skybox); + } + + if (hrn) hrn->next = hr->next; + else hicreplc[picnum] = hr->next; + free(hr); + + return 0; +} diff --git a/polymer/build/src/jfaud_sound.cpp b/polymer/build/src/jfaud_sound.cpp new file mode 100644 index 000000000..9bc8bfabb --- /dev/null +++ b/polymer/build/src/jfaud_sound.cpp @@ -0,0 +1,378 @@ +#ifdef __APPLE__ +# include +#else +# include "jfaud.hpp" +#endif + +#include + +#include "compat.h" +#include "baselayer.h" +#include "cache1d.h" + +extern "C" { +void initsb(char,char,long,char,char,char,char); +void uninitsb(void); +void setears(long,long,long,long); +void wsayfollow(char *,long,long,long *,long *,char); +void wsay(char *,long,long,long); +void loadwaves(void); +void loadsong(char *); +void musicon(void); +void musicoff(void); +void refreshaudio(void); +} + +#define NUMCHANNELS 16 +#define UNITSPERMTR 640.0 +#define WAVESFILE "WAVES.KWV" + +static char musistat = 0; +static char songname[BMAX_PATH] = ""; +static JFAud *jfaud = NULL; + +static int kwvnumwaves = 0; +static struct _kwvitem { + char instname[16]; + long wavleng; + long repstart; + long repleng; + long finetune; + long datastart; +} *kwvitems = NULL; + +static struct { + long *posx, *posy; + JFAudMixerChannel *handle; +} sfxchans[NUMCHANNELS]; + +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); + } +}; + +class KWVFile : public JFAudFile { +private: + int fh; + long datastart, datalen, datapos; +public: + KWVFile(const char *filename, const char *subfilename = NULL) + : JFAudFile(filename, NULL), + datastart(-1), datalen(-1), datapos(-1) + { + long i,j; + bool found = false; + + if (!subfilename) return; + + for (i=0;i(filename), 0); + if (fh < 0) return; + + datastart = kwvitems[i].datastart; + datalen = kwvitems[i].wavleng; + datapos = 0; + klseek(fh, datastart, SEEK_SET); + return; + } + } + } + + virtual ~KWVFile() + { + if (fh >= 0) kclose(fh); + } + virtual bool IsOpen(void) const + { + return datalen > 0 && fh >= 0; + } + + virtual long Read(long nbytes, void *buf) + { + if (!IsOpen()) return -1; + if (datalen - datapos < nbytes) nbytes = datalen - datapos; + if (nbytes <= 0) return 0; + nbytes = kread(fh, buf, nbytes); + if (nbytes > 0) datapos += nbytes; + return nbytes; + } + virtual long Seek(long pos, SeekFrom where) + { + long newpos; + if (!IsOpen()) return -1; + switch (where) { + case JFAudFile::Set: newpos = pos; break; + case JFAudFile::Cur: newpos = datapos + pos; break; + case JFAudFile::End: newpos = datalen + pos; break; + default: return -1; + } + if (newpos < 0) newpos = 0; + else if (newpos > datalen) newpos = datalen; + return klseek(fh, datastart + newpos, SEEK_SET); + } + virtual long Tell(void) const + { + if (!IsOpen()) return -1; + return datapos; + } + virtual long Length(void) const + { + if (!IsOpen()) return -1; + return datalen; + } +}; + +static JFAudFile *openfile(const char *fn, const char *subfn) +{ + char *ext; + bool loadkwv = false; + + ext = Bstrrchr(fn,'.'); + if (!ext || Bstrcasecmp(ext, ".kwv")) + return static_cast(new KenFile(fn,subfn)); + if (!subfn) return NULL; // KWV files need a sub name + + return static_cast(new KWVFile(fn, subfn)); +} + +static void logfunc(const char *s) { initprintf("%s", s); } + +void loadwaves(void) +{ + long fh, i, datastart; + + fh = kopen4load(WAVESFILE, 0); + if (fh < 0) return; + + if (kread(fh, &i, 4) != 4 || i != 0) return; + if (kread(fh, &kwvnumwaves, 4) != 4) return; kwvnumwaves = B_LITTLE32(kwvnumwaves); + + kwvitems = new struct _kwvitem [kwvnumwaves]; + if (!kwvitems) { + kclose(fh); + return; + } + + datastart = (4+4) + kwvnumwaves * (16+4*4); + for (i=0;iSetUserOpenFunc(openfile); + + musistat = 0; + if (!jfaud->InitWave(NULL, NUMCHANNELS, dasamplerate)) { + delete jfaud; + jfaud = NULL; + return; + } + + musistat = damusistat; + + for (i=NUMCHANNELS-1;i>=0;i--) sfxchans[i].handle = NULL; + + loadwaves(); +} + +void uninitsb(void) +{ + if (!jfaud) return; + + delete jfaud; + jfaud = NULL; + + if (kwvitems) delete [] kwvitems; +} + +void setears(long daposx, long daposy, long daxvect, long dayvect) +{ + JFAudMixer *mixer; + + if (!jfaud) return; + mixer = jfaud->GetWave(); + if (!mixer) return; + + mixer->SetListenerPosition((float)daposx/UNITSPERMTR, 0.0, (float)-daposy/UNITSPERMTR); + mixer->SetListenerOrientation((float)daxvect/UNITSPERMTR, 0.0, (float)-dayvect/UNITSPERMTR, + 0.0, 1.0, 0.0); +} + +static int storehandle(JFAudMixerChannel *handle, long *daxplc, long *dayplc) +{ + int i,empty = -1; + + for (i=NUMCHANNELS-1;i>=0;i--) { + if (!sfxchans[i].handle && empty<0) empty = i; + if (sfxchans[i].handle == handle) { + empty = i; + break; + } + } + + if (empty < 0) return -1; + + sfxchans[empty].handle = handle; + sfxchans[empty].posx = daxplc; + sfxchans[empty].posy = dayplc; + + return empty; +} + +static void stopcb(int r) +{ + jfaud->FreeSound(sfxchans[r].handle); + sfxchans[r].handle = NULL; +} + +void wsayfollow(char *dafilename, long dafreq, long davol, long *daxplc, long *dayplc, char followstat) +{ + JFAudMixerChannel *handl; + int r; + + if (!jfaud) return; + + handl = jfaud->PlayRawSound(WAVESFILE, dafilename, 1, 11025, 1, 1, false); + if (!handl) return; + + if (followstat) r = storehandle(handl, daxplc, dayplc); + else r = storehandle(handl, NULL, NULL); + + if (r >= 0) handl->SetStopCallback(stopcb, r); + + handl->SetPitch((float)dafreq / 4096.0); + handl->SetGain((float)davol / 256.0); + handl->SetPosition((float)(*daxplc) / UNITSPERMTR, 0.0, (float)(-*dayplc) / UNITSPERMTR); + handl->SetFollowListener(false); + handl->SetRolloff(1.0); + + handl->Play(); +} + +void wsay(char *dafilename, long dafreq, long volume1, long volume2) +{ + JFAudMixerChannel *handl; + int r; + + if (!jfaud) return; + + handl = jfaud->PlayRawSound(WAVESFILE, dafilename, 1, 11025, 1, 1, false); + if (!handl) return; + + r = storehandle(handl, NULL, NULL); + + if (r >= 0) handl->SetStopCallback(stopcb, r); + + handl->SetPitch((float)dafreq / 4096.0); + handl->SetGain((float)volume1 / 256.0); + handl->SetPosition(0.0, 0.0, 0.0); + handl->SetFollowListener(true); + handl->SetRolloff(0.0); + + handl->Play(); +} + +void loadsong(char *filename) +{ + if (!jfaud) return; + strcpy(songname,filename); +} + +void musicon(void) +{ + if (!jfaud || !musistat || !songname[0]) return; + + jfaud->PlayMusic(songname); +} + +void musicoff(void) +{ + if (!jfaud || !musistat) return; + + jfaud->StopMusic(); +} + +void refreshaudio(void) +{ + int i; + + if (!jfaud) return; + for (i=NUMCHANNELS-1;i>=0;i--) { + if (!sfxchans[i].handle || !jfaud->IsValidSound(sfxchans[i].handle)) continue; + if (!sfxchans[i].posx || !sfxchans[i].posy) continue; + + sfxchans[i].handle->SetPosition( + (float)(*sfxchans[i].posx)/UNITSPERMTR, + 0.0, + (float)(-*sfxchans[i].posy)/UNITSPERMTR); + } + jfaud->Update(); +} diff --git a/polymer/build/src/kplib.c b/polymer/build/src/kplib.c new file mode 100644 index 000000000..f3db7dd75 --- /dev/null +++ b/polymer/build/src/kplib.c @@ -0,0 +1,3117 @@ +/************************************************************************************************** +KPLIB.C: Ken's Picture LIBrary written by Ken Silverman +Copyright (c) 1998-2005 Ken Silverman +Ken Silverman's official web site: http://advsys.net/ken + +Features of KPLIB.C: + * Routines for decoding JPG, PNG, GIF, PCX, TGA, BMP, CEL. + See kpgetdim(), kprender(), and optional helper function: kpzload(). + * Routines for ZIP decompression. All ZIP functions start with the letters "kz". + * Multi-platform support: Dos/Windows/Linux/Mac/etc.. + * Compact code, all in a single source file. Yeah, bad design on my part... but makes life + easier for everyone else - you simply add a single C file to your project, throw a few + externs in there, add the function calls, and you're done! + +Brief history: +1998?: Wrote KPEG, a JPEG viewer for DOS +2000: Wrote KPNG, a PNG viewer for DOS +2001: Combined KPEG & KPNG, ported to Visual C, and made it into a library called KPLIB.C +2002: Added support for TGA, GIF, CEL, ZIP +2003: Added support for BMP +05/18/2004: Added support for 8&24 bit PCX +12/09/2005: Added support for progressive JPEG + +I offer this code to the community for free use - all I ask is that my name be included in the +credits. + +-Ken S. +**************************************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#if defined(__POWERPC__) +#define BIGENDIAN 1 +#endif + +#ifdef BIGENDIAN +static unsigned long LSWAPIB (unsigned long a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } +static unsigned short SSWAPIB (unsigned short a) { return((a>>8)+(a<<8)); } +#define LSWAPIL(a) (a) +#define SSWAPIL(a) (a) +#else +#define LSWAPIB(a) (a) +#define SSWAPIB(a) (a) +static unsigned long LSWAPIL (unsigned long a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } +static unsigned short SSWAPIL (unsigned short a) { return((a>>8)+(a<<8)); } +#endif + +#if !defined(_WIN32) && !defined(__DOS__) +#include +#include +typedef long long __int64; +static __inline long _lrotl (long i, int sh) + { return((i>>(-sh))|(i< +#endif + +#if defined(__DOS__) +#include +#elif defined(_WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif +#if !defined(max) +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#if !defined(min) +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#if defined(__GNUC__) +#define _inline inline +#endif + + //use GCC-specific extension to force symbol name to be something in particular to override underscoring. +#if defined(__GNUC__) && defined(__i386__) && !defined(NOASM) +#define ASMNAME(x) asm(x) +#else +#define ASMNAME(x) +#endif + +static long frameplace, bytesperline, xres, yres, globxoffs, globyoffs; + +static const long pow2mask[32] = +{ + 0x00000000,0x00000001,0x00000003,0x00000007, + 0x0000000f,0x0000001f,0x0000003f,0x0000007f, + 0x000000ff,0x000001ff,0x000003ff,0x000007ff, + 0x00000fff,0x00001fff,0x00003fff,0x00007fff, + 0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff, + 0x000fffff,0x001fffff,0x003fffff,0x007fffff, + 0x00ffffff,0x01ffffff,0x03ffffff,0x07ffffff, + 0x0fffffff,0x1fffffff,0x3fffffff,0x7fffffff, +}; +static const long pow2long[32] = +{ + 0x00000001,0x00000002,0x00000004,0x00000008, + 0x00000010,0x00000020,0x00000040,0x00000080, + 0x00000100,0x00000200,0x00000400,0x00000800, + 0x00001000,0x00002000,0x00004000,0x00008000, + 0x00010000,0x00020000,0x00040000,0x00080000, + 0x00100000,0x00200000,0x00400000,0x00800000, + 0x01000000,0x02000000,0x04000000,0x08000000, + 0x10000000,0x20000000,0x40000000,0x80000000, +}; + + //Hack for peekbits,getbits,suckbits (to prevent lots of duplicate code) + // 0: PNG: do 12-byte chunk_header removal hack + // !=0: ZIP: use 64K buffer (olinbuf) +static long zipfilmode; +typedef struct +{ + FILE *fil; //0:no file open, !=0:open file (either stand-alone or zip) + long comptyp; //0:raw data (can be ZIP or stand-alone), 8:PKZIP LZ77 *flate + long seek0; //0:stand-alone file, !=0: start of zip compressed stream data + long compleng;//Global variable for compression FIFO + long comptell;//Global variable for compression FIFO + long leng; //Uncompressed file size (bytes) + long pos; //Current uncompressed relative file position (0<=pos<=leng) + long endpos; //Temp global variable for kzread + long jmpplc; //Store place where decompression paused + long i; //For stand-alone/ZIP comptyp#0, this is like "uncomptell" + //For ZIP comptyp#8&btype==0 "<64K store", this saves i state + long bfinal; //LZ77 decompression state (for later calls) +} kzfilestate; +static kzfilestate kzfs; + +//Initialized tables (can't be in union) +//jpg: png: +// crmul 16384 abstab10 4096 +// cbmul 16384 hxbit 472 +// dct 4608 pow2mask 128* +// colclip 4096 +// colclipup8 4096 +// colclipup16 4096 +// unzig 256 +// pow2mask 128* +// dcflagor 64 + +long palcol[256] ASMNAME("palcol"), paleng; +unsigned char coltype, bitdepth; + +//============================ KPNGILIB begins =============================== + +#define PROCESSALPHAHERE 0 //Set to 1 for KPNG, 0 in all other cases + +//07/31/2000: KPNG.C first ported to C from READPNG.BAS +//10/11/2000: KPNG.C split into 2 files: KPNG.C and PNGINLIB.C +//11/24/2000: Finished adding support for coltypes 4&6 +//03/31/2001: Added support for Adam7-type interlaced images +//Currently, there is no support for: +// * 16-bit color depth +// * Some useless ancillary chunks, like: gAMA(gamma) & pHYs(aspect ratio) + + //.PNG specific variables: +static long bakcol = 0xff808080, bakr = 0x80, bakg = 0x80, bakb = 0x80; //this used to be public... +static long gslidew = 0, gslider = 0, xm, xmn[4], xr0, xr1, xplc, yplc, nfplace; +static long clen[320], cclen[19], bitpos, filt, xsiz, ysiz; +static long xsizbpl, ixsiz, ixoff, iyoff, ixstp, iystp, intlac, nbpl, trnsrgb ASMNAME("trnsrgb"); +static long ccind[19] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; +static long hxbit[59][2], ibuf0[288], nbuf0[32], ibuf1[32], nbuf1[32]; +static const unsigned char *filptr; +static unsigned char slidebuf[32768], opixbuf0[4], opixbuf1[4]; +static unsigned char pnginited = 0, olinbuf[65536] ASMNAME("olinbuf"); //WARNING:max xres is: 65536/bpp-1 +static long gotcmov = -2, abstab10[1024] ASMNAME("abstab10"); + + //Variables to speed up dynamic Huffman decoding: +#define LOGQHUFSIZ0 9 +#define LOGQHUFSIZ1 6 +static long qhufval0[1<>8) + ((a&0xff00)<<8) + (a<<24) + (a>>24)); +} + +static inline long bitrev (long b, long c) +{ + long i, j; + for(i=1,j=0,c=(1< 0x8000000) + { + cpuid(0x80000001,cpb); + i |= (cpb[3]&(1<<31)); + if (!((cpid[1]^0x68747541)|(cpid[3]^0x69746e65)|(cpid[2]^0x444d4163))) //AuthenticAMD + i |= (cpb[3]&((1<<22)|(1<<30))); + } + if (i&(1<<25)) i |= (1<<22); //SSE implies MMX+ support + return(i); +} + +static unsigned char fakebuf[8], *nfilptr; +static long nbitpos; +static void suckbitsnextblock () +{ + long n; + + if (!zipfilmode) + { + if (!nfilptr) + { //|===|===|crc|lng|typ|===|===| + // \ fakebuf: / + // |===|===| + //----x O---x O-------- + nbitpos = LSWAPIL(*(long *)&filptr[8]); + nfilptr = (unsigned char *)&filptr[nbitpos+12]; + *(long *)&fakebuf[0] = *(long *)&filptr[0]; //Copy last dword of IDAT chunk + if (*(long *)&filptr[12] == LSWAPIB(0x54414449)) //Copy 1st dword of next IDAT chunk + *(long *)&fakebuf[4] = *(long *)&filptr[16]; + filptr = &fakebuf[4]; bitpos -= 32; + } + else + { + filptr = nfilptr; nfilptr = 0; + bitpos -= ((nbitpos-4)<<3); + } + //if (n_from_suckbits < 4) will it crash? + } + else + { + //NOTE: should only read bytes inside compsize, not 64K!!! :/ + *(long *)&olinbuf[0] = *(long *)&olinbuf[sizeof(olinbuf)-4]; + n = min((unsigned)(kzfs.compleng-kzfs.comptell),sizeof(olinbuf)-4); + fread(&olinbuf[4],n,1,kzfs.fil); + kzfs.comptell += n; + bitpos -= ((sizeof(olinbuf)-4)<<3); + } +} + +static _inline long peekbits (long n) { return((LSWAPIB(*(long *)&filptr[bitpos>>3])>>(bitpos&7))&pow2mask[n]); } +static _inline void suckbits (long n) { bitpos += n; if (bitpos >= 0) suckbitsnextblock(); } +static _inline long getbits (long n) { long i = peekbits(n); suckbits(n); return(i); } + +static long hufgetsym (long *hitab, long *hbmax) +{ + long v, n; + + v = n = 0; + do { v = (v<<1)+getbits(1)+hbmax[n]-hbmax[n+1]; n++; } while (v >= 0); + return(hitab[hbmax[n]+v]); +} + + //This did not result in a speed-up on P4-3.6Ghz (02/22/2005) +//static long hufgetsym_skipb (long *hitab, long *hbmax, long n, long addit) +//{ +// long v; +// +// v = bitrev(getbits(n),n)+addit; +// do { v = (v<<1)+getbits(1)+hbmax[n]-hbmax[n+1]; n++; } while (v >= 0); +// return(hitab[hbmax[n]+v]); +//} + +static void qhufgencode (long *hitab, long *hbmax, long *qhval, unsigned char *qhbit, long numbits) +{ + long i, j, k, n, r; + + //r is the bit reverse of i. Ex: if: i = 1011100111, r = 1110011101 + i = r = 0; + for(n=1;n<=numbits;n++) + for(k=hbmax[n-1];k>n)&1) + hbmax[n]-hbmax[n+1]; + // + //n = numbits; + //k = hbmax[n]-r; + // + //j = peekbits(LOGQHUFSIZ); i = qhufval[j]; j = qhufbit[j]; + // + //i = j = 0; + //do + //{ + // i = (i<<1)+getbits(1)+nbuf0[j]-nbuf0[j+1]; j++; + //} while (i >= 0); + //i = ibuf0[nbuf0[j]+i]; + //qhval[r] = k; + + qhbit[r] = 0; //n-32; + } + + // //hufgetsym_skipb related code: + //for(k=n=0;n=0;i--) tbuf[inbuf[i]]++; + tbuf[0] = hbmax[0] = 0; //Hack to remove symbols of length 0? + for(i=0;i<31;i++) hbmax[i+1] = hbmax[i]+tbuf[i]; + for(i=0;i>i)&15); + iyoff = ((0x00402010>>i)&15); + if (((ixoff >= xsiz) || (iyoff >= ysiz)) && (intlac >= 2)) { i = -1; intlac--; } + } while (i < 0); + j = ((0x33221100>>i)&15); ixstp = (1<>i)&15); iystp = (1<>3) = 2 + //j=3,ixoff=4 2 ((12+(1<<3)-1 - 4)>>3) = 1 + //j=2,ixoff=2 3 4 5 ((12+(1<<2)-1 - 2)>>2) = 3 + //j=1,ixoff=1 6 7 8 9 a b ((12+(1<<1)-1 - 1)>>1) = 6 + ixsiz = ((xsiz+ixstp-1-ixoff)>>j); //It's confusing! See the above example. + nbpl = (bytesperline<>(coltype<<2))&15)*ixsiz; + switch (bitdepth) + { + case 1: xsizbpl = ((xsizbpl+7)>>3); break; + case 2: xsizbpl = ((xsizbpl+3)>>2); break; + case 4: xsizbpl = ((xsizbpl+1)>>1); break; + } + + memset(olinbuf,0,(xsizbpl+1)*sizeof(olinbuf[0])); + *(long *)&opixbuf0[0] = *(long *)&opixbuf1[0] = 0; + xplc = xsizbpl; yplc = globyoffs+iyoff; xm = 0; filt = -1; + + i = globxoffs+ixoff; i = (((-(i>=0))|(ixstp-1))&i); + k = (((-(yplc>=0))|(iystp-1))&yplc); + nfplace = k*bytesperline + (i<<2) + frameplace; + + //Precalculate x-clipping to screen borders (speeds up putbuf) + //Equation: (0 <= xr <= ixsiz) && (0 <= xr*ixstp+globxoffs+ixoff <= xres) + xr0 = max((-globxoffs-ixoff+(1<>j,0); + xr1 = min((xres-globxoffs-ixoff+(1<>j,ixsiz); + xr0 = ixsiz-xr0; + xr1 = ixsiz-xr1; + + if (coltype == 4) { xr0 = xr0*2; xr1 = xr1*2; } + else if (coltype == 2) { xr0 = xr0*3-2; xr1 = xr1*3-2; } + else if (coltype == 6) { xr0 = xr0*4-2; xr1 = xr1*4-2; } + else + { + switch(bitdepth) + { + case 1: xr0 += ((-ixsiz)&7)+7; + xr1 += ((-ixsiz)&7)+7; break; + case 2: xr0 = ((xr0+((-ixsiz)&3)+3)<<1); + xr1 = ((xr1+((-ixsiz)&3)+3)<<1); break; + case 4: xr0 = ((xr0+((-ixsiz)&1)+1)<<2); + xr1 = ((xr1+((-ixsiz)&1)+1)<<2); break; + } + } + ixstp <<= 2; + return(0); +} + +static long Paeth (long a, long b, long c) +{ + long pa, pb, pc; + + pa = b-c; pb = a-c; pc = labs(pa+pb); pa = labs(pa); pb = labs(pb); + if ((pa <= pb) && (pa <= pc)) return(a); + if (pb <= pc) return(b); else return(c); +} + +#if defined(NOASM) + +static inline long Paeth686 (long a, long b, long c) +{ + return(Paeth(a,b,c)); +} + +static inline void rgbhlineasm (long x, long xr1, long p, long ixstp) +{ + long i; + if (!trnsrgb) + { + for(;x>xr1;p+=ixstp,x-=3) *(long *)p = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000); + return; + } + for(;x>xr1;p+=ixstp,x-=3) + { + i = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000); + if (i == trnsrgb) i &= LSWAPIB(0xffffff); + *(long *)p = i; + } +} + +static inline void pal8hlineasm (long x, long xr1, long p, long ixstp) +{ + for(;x>xr1;p+=ixstp,x--) *(long *)p = palcol[olinbuf[x]]; +} + +#elif defined(__WATCOMC__) + + //NOTE: cmov now has correctly ordered registers (thx to bug fix in 11.0c!) +long Paeth686 (long, long, long); +#pragma aux Paeth686 =\ + ".686"\ + "mov edx, ecx"\ + "sub edx, eax"\ + "sub edx, ebx"\ + "lea edx, abstab10[edx*4+2048]"\ + "mov esi, [ebx*4+edx]"\ + "mov edi, [ecx*4+edx]"\ + "cmp edi, esi"\ + "cmovge edi, esi"\ + "cmovge ecx, ebx"\ + "cmp edi, [eax*4+edx]"\ + "cmovge ecx, eax"\ + parm nomemory [eax][ebx][ecx]\ + modify exact [ecx edx esi edi]\ + value [ecx] + + //Note: "cmove eax,?" may be faster than "jne ?:and eax,?" but who cares +void rgbhlineasm (long, long, long, long); +#pragma aux rgbhlineasm =\ + "sub ecx, edx"\ + "jle short endit"\ + "add edx, offset olinbuf"\ + "cmp dword ptr trnsrgb, 0"\ + "jz short begit2"\ + "begit: mov eax, dword ptr [ecx+edx]"\ + "or eax, 0xff000000"\ + "cmp eax, dword ptr trnsrgb"\ + "jne short skipit"\ + "and eax, 0xffffff"\ + "skipit: sub ecx, 3"\ + "mov [edi], eax"\ + "lea edi, [edi+ebx]"\ + "jnz short begit"\ + "jmp short endit"\ + "begit2: mov eax, dword ptr [ecx+edx]"\ + "or eax, 0xff000000"\ + "sub ecx, 3"\ + "mov [edi], eax"\ + "lea edi, [edi+ebx]"\ + "jnz short begit2"\ + "endit:"\ + parm [ecx][edx][edi][ebx]\ + modify exact [eax ecx edi]\ + value + +void pal8hlineasm (long, long, long, long); +#pragma aux pal8hlineasm =\ + "sub ecx, edx"\ + "jle short endit"\ + "add edx, offset olinbuf"\ + "begit: movzx eax, byte ptr [ecx+edx]"\ + "mov eax, dword ptr palcol[eax*4]"\ + "dec ecx"\ + "mov [edi], eax"\ + "lea edi, [edi+ebx]"\ + "jnz short begit"\ + "endit:"\ + parm [ecx][edx][edi][ebx]\ + modify exact [eax ecx edi]\ + value + +#elif defined(_MSC_VER) + +static _inline long Paeth686 (long a, long b, long c) +{ + _asm + { + mov eax, a + mov ebx, b + mov ecx, c + mov edx, ecx + sub edx, eax + sub edx, ebx + lea edx, abstab10[edx*4+2048] + mov esi, [ebx*4+edx] + mov edi, [ecx*4+edx] + cmp edi, esi + cmovge edi, esi + cmovge ecx, ebx + cmp edi, [eax*4+edx] + cmovl eax, ecx + } +} + +static _inline void rgbhlineasm (long c, long d, long t, long b) +{ + _asm + { + mov ecx, c + mov edx, d + mov edi, t + mov ebx, b + sub ecx, edx + jle short endit + add edx, offset olinbuf + cmp dword ptr trnsrgb, 0 + jz short begit2 + begit: mov eax, dword ptr [ecx+edx] + or eax, 0xff000000 + cmp eax, dword ptr trnsrgb + jne short skipit + and eax, 0xffffff + skipit: sub ecx, 3 + mov [edi], eax + lea edi, [edi+ebx] + jnz short begit + jmp short endit + begit2: mov eax, dword ptr [ecx+edx] + or eax, 0xff000000 + sub ecx, 3 + mov [edi], eax + lea edi, [edi+ebx] + jnz short begit2 + endit: + } +} + +static _inline void pal8hlineasm (long c, long d, long t, long b) +{ + _asm + { + mov ecx, c + mov edx, d + mov edi, t + mov ebx, b + sub ecx, edx + jle short endit + add edx, offset olinbuf + begit: movzx eax, byte ptr [ecx+edx] + mov eax, dword ptr palcol[eax*4] + sub ecx, 1 + mov [edi], eax + lea edi, [edi+ebx] + jnz short begit + endit: + } +} + +#elif defined(__GNUC__) && defined(__i386__) + +static inline long Paeth686 (long a, long b, long c) +{ + __asm__ __volatile__ ( + "movl %%ecx, %%edx\n\tsubl %%eax, %%edx\n\tsubl %%ebx, %%edx\n\t" + "leal (abstab10+2048)(,%%edx,4), %%edx\n\t" + "movl (%%edx,%%ebx,4), %%esi\n\tmovl (%%edx,%%ecx,4), %%edi\n\t" + "cmpl %%esi, %%edi\n\tcmovgel %%esi, %%edi\n\tcmovgel %%ebx, %%ecx\n\t" + "cmpl (%%edx,%%eax,4), %%edi\n\tcmovgel %%eax, %%ecx" + : "+c" (c) : "a" (a), "b" (b) : "esi","edi","memory","cc" + ); + return c; +} + + //Note: "cmove eax,?" may be faster than "jne ?:and eax,?" but who cares +static inline void rgbhlineasm (long c, long d, long t, long b) +{ + __asm__ __volatile__ ( + "subl %%edx, %%ecx\n\tjle 3f\n\taddl $olinbuf, %%edx\n\t" + "cmpl $0, trnsrgb(,1)\n\tjz 2f\n\t" + "0: movl (%%ecx,%%edx,1), %%eax\n\torl $0xff000000, %%eax\n\tcmpl trnsrgb(,1), %%eax\n\t" + "jne 1f\n\tandl $0xffffff, %%eax\n\t" + "1: subl $3, %%ecx\n\tmovl %%eax, (%%edi)\n\tleal (%%edi,%%ebx,1), %%edi\n\t" + "jnz 0b\n\tjmp 3f\n\t" + "2: movl (%%ecx,%%edx,1), %%eax\n\torl $0xff000000, %%eax\n\tsubl $3, %%ecx\n\t" + "movl %%eax, (%%edi)\n\tleal (%%edi,%%ebx,1), %%edi\n\tjnz 2b\n\t" + "3:" + : "+c" (c), "+D" (t) : "d" (d), "b" (b) : "eax","memory","cc" + ); +} + +static inline void pal8hlineasm (long c, long d, long t, long b) +{ + __asm__ __volatile__ ( + "subl %%edx, %%ecx\n\tjle 1f\n\taddl $olinbuf, %%edx\n\t" + "0: movzbl (%%ecx,%%edx,1), %%eax\n\tmovl palcol(,%%eax,4), %%eax\n\t" + "subl $1, %%ecx\n\tmovl %%eax, (%%edi)\n\tleal (%%edi,%%ebx,1), %%edi\n\tjnz 0b\n\t" + "1:" + : "+c" (c), "+D" (t) : "d" (d), "b" (b) : "eax","memory","cc" + ); +} + +#else + +#error Unsupported compiler or architecture. + +#endif + +static void putbuf (const unsigned char *buf, long leng) +{ + long i, x, p; + + if (filt < 0) + { + if (leng <= 0) return; + filt = buf[0]; if (filt == gotcmov) filt = 5; + i = 1; + } else i = 0; + + while (i < leng) + { + x = i+xplc; if (x > leng) x = leng; + switch (filt) + { + case 0: + while (i < x) { olinbuf[xplc] = buf[i]; xplc--; i++; } + break; + case 1: + while (i < x) + { + olinbuf[xplc] = (opixbuf1[xm] += buf[i]); + xm = xmn[xm]; xplc--; i++; + } + break; + case 2: + while (i < x) { olinbuf[xplc] += buf[i]; xplc--; i++; } + break; + case 3: + while (i < x) + { + opixbuf1[xm] = olinbuf[xplc] = ((opixbuf1[xm]+olinbuf[xplc])>>1)+buf[i]; + xm = xmn[xm]; xplc--; i++; + } + break; + case 4: + while (i < x) + { + opixbuf1[xm] = (char)(Paeth(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]); + opixbuf0[xm] = olinbuf[xplc]; + olinbuf[xplc] = opixbuf1[xm]; + xm = xmn[xm]; xplc--; i++; + } + break; + case 5: //Special hack for Paeth686 (Doesn't have to be case 5) + while (i < x) + { + opixbuf1[xm] = (char)(Paeth686(opixbuf1[xm],olinbuf[xplc],opixbuf0[xm])+buf[i]); + opixbuf0[xm] = olinbuf[xplc]; + olinbuf[xplc] = opixbuf1[xm]; + xm = xmn[xm]; xplc--; i++; + } + break; + } + + if (xplc > 0) return; + + //Draw line! + if ((unsigned long)yplc < (unsigned long)yres) + { + x = xr0; p = nfplace; + switch (coltype) + { + case 2: + rgbhlineasm(x,xr1,p,ixstp); + break; + case 4: + for(;x>xr1;p+=ixstp,x-=2) + { +#if (PROCESSALPHAHERE == 1) + //Enable this code to process alpha right here! + if (olinbuf[x-1] == 255) { *(long *)p = palcol[olinbuf[x]]; continue; } + if (!olinbuf[x-1]) { *(long *)p = bakcol; continue; } + //I do >>8, but theoretically should be: /255 + *(char *)(p) = *(char *)(p+1) = *(char *)(p+2) = *(char *)(p+3) = + (((((long)olinbuf[x])-bakr)*(long)olinbuf[x-1])>>8) + bakr; +#else + *(long *)p = (palcol[olinbuf[x]]&LSWAPIB(0xffffff))|LSWAPIL((long)olinbuf[x-1]); +#endif + } + break; + case 6: + for(;x>xr1;p+=ixstp,x-=4) + { +#if (PROCESSALPHAHERE == 1) + //Enable this code to process alpha right here! + if (olinbuf[x-1] == 255) { *(long *)p = *(long *)&olinbuf[x]; continue; } + if (!olinbuf[x-1]) { *(long *)p = bakcol; continue; } + //I do >>8, but theoretically should be: /255 + *(char *)(p ) = (((((long)olinbuf[x ])-bakr)*(long)olinbuf[x-1])>>8) + bakr; + *(char *)(p+1) = (((((long)olinbuf[x+1])-bakg)*(long)olinbuf[x-1])>>8) + bakg; + *(char *)(p+2) = (((((long)olinbuf[x+2])-bakb)*(long)olinbuf[x-1])>>8) + bakb; +#else + *(char *)(p ) = olinbuf[x ]; //R + *(char *)(p+1) = olinbuf[x+1]; //G + *(char *)(p+2) = olinbuf[x+2]; //B + *(char *)(p+3) = olinbuf[x-1]; //A +#endif + } + break; + default: + switch(bitdepth) + { + case 1: for(;x>xr1;p+=ixstp,x-- ) *(long *)p = palcol[olinbuf[x>>3]>>(x&7)]; break; + case 2: for(;x>xr1;p+=ixstp,x-=2) *(long *)p = palcol[olinbuf[x>>3]>>(x&6)]; break; + case 4: for(;x>xr1;p+=ixstp,x-=4) *(long *)p = palcol[olinbuf[x>>3]>>(x&4)]; break; + case 8: pal8hlineasm(x,xr1,p,ixstp); break; //for(;x>xr1;p+=ixstp,x--) *(long *)p = palcol[olinbuf[x]]; break; + } + break; + } + nfplace += nbpl; + } + + *(long *)&opixbuf0[0] = *(long *)&opixbuf1[0] = 0; + xplc = xsizbpl; yplc += iystp; + if ((intlac) && (yplc >= globyoffs+ysiz)) { intlac--; initpass(); } + if (i < leng) { filt = buf[i++]; if (filt == gotcmov) filt = 5; } else filt = -1; + } +} + +static void initpngtables() +{ + long i, j, k; + + //hxbit[0-58][0-1] is a combination of 4 different tables: + // 1st parameter: [0-29] are distances, [30-58] are lengths + // 2nd parameter: [0]: extra bits, [1]: base number + + j = 1; k = 0; + for(i=0;i<30;i++) + { + hxbit[i][1] = j; j += (1<= 2)); + } + j = 3; k = 0; + for(i=257;i<285;i++) + { + hxbit[i+30-257][1] = j; j += (1<= 264)); + } + hxbit[285+30-257][1] = 258; hxbit[285+30-257][0] = 0; + + k = getcputype(); + if (k&(1<<15)) + { + gotcmov = 4; + for(i=0;i<512;i++) abstab10[512+i] = abstab10[512-i] = i; + } +} + +static long kpngrend (const char *kfilebuf, long kfilength, + long daframeplace, long dabytesperline, long daxres, long dayres, + long daglobxoffs, long daglobyoffs) +{ + long i, j, k, bfinal, btype, hlit, hdist, leng; + long slidew, slider; + //long qhuf0v, qhuf1v; + + if (!pnginited) { pnginited = 1; initpngtables(); } + + if ((*(long *)&kfilebuf[0] != LSWAPIB(0x474e5089)) || (*(long *)&kfilebuf[4] != LSWAPIB(0x0a1a0a0d))) + return(-1); //"Invalid PNG file signature" + filptr = (unsigned char *)&kfilebuf[8]; + + trnsrgb = 0; + + while (1) + { + leng = LSWAPIL(*(long *)&filptr[0]); i = *(long *)&filptr[4]; + filptr = &filptr[8]; + + if (i == LSWAPIB(0x52444849)) //IHDR (must be first) + { + xsiz = LSWAPIL(*(long *)&filptr[0]); if (xsiz <= 0) return(-1); + ysiz = LSWAPIL(*(long *)&filptr[4]); if (ysiz <= 0) return(-1); + bitdepth = filptr[8]; if (!((1<= 2) return(-1); //"Unsupported interlace type" + intlac = filptr[12]*7; //0=no interlace/1=Adam7 interlace + + //Save code by making grayscale look like a palette color scheme + if ((!coltype) || (coltype == 4)) + { + j = 0xff000000; k = (255 / ((1<=0;i--) palcol[i] = LSWAPIB((LSWAPIL(*(long *)&filptr[i*3])>>8)|0xff000000); + } + else if (i == LSWAPIB(0x44474b62)) //bKGD (must be after PLTE and before IDAT) + { + switch(coltype) + { + case 0: case 4: + bakcol = (((long)filptr[0]<<8)+(long)filptr[1])*255/((1<>16)&255); + bakg = ((bakcol>>8)&255); + bakb = (bakcol&255); + bakcol = LSWAPIB(bakcol); + } + else if (i == LSWAPIB(0x534e5274)) //tRNS (must be after PLTE and before IDAT) + { + switch(coltype) + { + case 0: + if (bitdepth <= 8) + palcol[(long)filptr[1]] &= LSWAPIB(0xffffff); + //else {} // /c0 /d16 not yet supported + break; + case 2: + if (bitdepth == 8) + { trnsrgb = LSWAPIB((((long)filptr[1])<<16)+(((long)filptr[3])<<8)+((long)filptr[5])+0xff000000); } + //else {} //WARNING: PNG docs say: MUST compare all 48 bits :( + break; + case 3: + for(i=min(leng,paleng)-1;i>=0;i--) + palcol[i] &= LSWAPIB((((long)filptr[i])<<24)|0xffffff); + break; + default:; + } + } + else if (i == LSWAPIB(0x54414449)) { break; } //IDAT + + filptr = &filptr[leng+4]; //crc = LSWAPIL(*(long *)&filptr[-4]); + } + + //Initialize this for the getbits() function + zipfilmode = 0; + filptr = &filptr[leng-4]; bitpos = -((leng-4)<<3); nfilptr = 0; + //if (leng < 4) will it crash? + + frameplace = daframeplace; + bytesperline = dabytesperline; + xres = daxres; + yres = dayres; + globxoffs = daglobxoffs; + globyoffs = daglobyoffs; + + switch (coltype) + { + case 4: xmn[0] = 1; xmn[1] = 0; break; + case 2: xmn[0] = 1; xmn[1] = 2; xmn[2] = 0; break; + case 6: xmn[0] = 1; xmn[1] = 2; xmn[2] = 3; xmn[3] = 0; break; + default: xmn[0] = 0; break; + } + switch (bitdepth) + { + case 1: for(i=2;i<256;i++) palcol[i] = palcol[i&1]; break; + case 2: for(i=4;i<256;i++) palcol[i] = palcol[i&3]; break; + case 4: for(i=16;i<256;i++) palcol[i] = palcol[i&15]; break; + } + + //coltype: bitdepth: format: + // 0 1,2,4,8,16 I + // 2 8,16 RGB + // 3 1,2,4,8 P + // 4 8,16 IA + // 6 8,16 RGBA + xsizbpl = ((0x04021301>>(coltype<<2))&15)*xsiz; + switch (bitdepth) + { + case 1: xsizbpl = ((xsizbpl+7)>>3); break; + case 2: xsizbpl = ((xsizbpl+3)>>2); break; + case 4: xsizbpl = ((xsizbpl+1)>>1); break; + } + //Tests to see if xsiz > allocated space in olinbuf + //Note: xsizbpl gets re-written inside initpass() + if ((xsizbpl+1)*sizeof(olinbuf[0]) > sizeof(olinbuf)) return(-1); + + initpass(); + + slidew = 0; slider = 16384; + suckbits(16); //Actually 2 fields: 8:compmethflags, 8:addflagscheck + do + { + bfinal = getbits(1); btype = getbits(2); + if (btype == 0) + { + //Raw (uncompressed) + suckbits((-bitpos)&7); //Synchronize to start of next byte + i = getbits(16); if ((getbits(16)^i) != 0xffff) return(-1); + for(;i;i--) + { + if (slidew >= slider) + { + putbuf(&slidebuf[(slider-16384)&32767],16384); slider += 16384; + if ((yplc >= yres) && (intlac < 2)) return(0); + } + slidebuf[(slidew++)&32767] = (char)getbits(8); + } + continue; + } + if (btype == 3) continue; + + if (btype == 1) //Fixed Huffman + { + hlit = 288; hdist = 32; i = 0; + for(;i<144;i++) clen[i] = 8; //Fixed bit sizes (literals) + for(;i<256;i++) clen[i] = 9; //Fixed bit sizes (literals) + for(;i<280;i++) clen[i] = 7; //Fixed bit sizes (EOI,lengths) + for(;i<288;i++) clen[i] = 8; //Fixed bit sizes (lengths) + for(;i<320;i++) clen[i] = 5; //Fixed bit sizes (distances) + } + else //Dynamic Huffman + { + hlit = getbits(5)+257; hdist = getbits(5)+1; j = getbits(4)+4; + for(i=0;i= slider) + { + putbuf(&slidebuf[(slider-16384)&32767],16384); slider += 16384; + if ((yplc >= yres) && (intlac < 2)) return(0); + } + + k = peekbits(LOGQHUFSIZ0); + if (qhufbit0[k]) { i = qhufval0[k]; suckbits((long)qhufbit0[k]); } else i = hufgetsym(ibuf0,nbuf0); + //else i = hufgetsym_skipb(ibuf0,nbuf0,LOGQHUFSIZ0,qhuf0v); //hufgetsym_skipb related code + + if (i < 256) { slidebuf[(slidew++)&32767] = (char)i; continue; } + if (i == 256) break; + i = getbits(hxbit[i+30-257][0]) + hxbit[i+30-257][1]; + + k = peekbits(LOGQHUFSIZ1); + if (qhufbit1[k]) { j = qhufval1[k]; suckbits((long)qhufbit1[k]); } else j = hufgetsym(ibuf1,nbuf1); + //else j = hufgetsym_skipb(ibuf1,nbuf1,LOGQHUFSIZ1,qhuf1v); //hufgetsym_skipb related code + + j = getbits(hxbit[j][0]) + hxbit[j][1]; + i += slidew; do { slidebuf[slidew&32767] = slidebuf[(slidew-j)&32767]; slidew++; } while (slidew < i); + } + } while (!bfinal); + + slider -= 16384; + if (!((slider^slidew)&32768)) + putbuf(&slidebuf[slider&32767],slidew-slider); + else + { + putbuf(&slidebuf[slider&32767],(-slider)&32767); + putbuf(slidebuf,slidew&32767); + } + return(0); +} + +//============================= KPNGILIB ends ================================ +//============================ KPEGILIB begins =============================== + + //11/01/2000: This code was originally from KPEG.C + // All non 32-bit color drawing was removed + // "Motion" JPG code was removed + // A lot of parameters were added to kpeg() for library usage +static long kpeginited = 0; +static long clipxdim, clipydim; + +static long hufmaxatbit[8][20], hufvalatbit[8][20], hufcnt[8]; +static unsigned char hufnumatbit[8][20], huftable[8][256]; +static long hufquickval[8][1024], hufquickbits[8][1024], hufquickcnt[8]; +static long quantab[4][64], dct[12][64], lastdc[4], unzig[64], zigit[64]; //dct:10=MAX (says spec);+2 for hacks +static unsigned char gnumcomponents, dcflagor[64]; +static long gcompid[4], gcomphsamp[4], gcompvsamp[4], gcompquantab[4], gcomphsampshift[4], gcompvsampshift[4]; +static long lnumcomponents, lcompid[4], lcompdc[4], lcompac[4], lcomphsamp[4], lcompvsamp[4], lcompquantab[4]; +static long lcomphvsamp0, lcomphsampshift0, lcompvsampshift0; +static long colclip[1024], colclipup8[1024], colclipup16[1024]; +static unsigned char pow2char[8] = {1,2,4,8,16,32,64,128}; + +#if defined(NOASM) + +static inline long mulshr24 (long a, long b) +{ + return((long)((((__int64)a)*((__int64)b))>>24)); +} + +static inline long mulshr32 (long a, long b) +{ + return((long)((((__int64)a)*((__int64)b))>>32)); +} + +#elif defined(__WATCOMC__) + +long mulshr24 (long, long); +#pragma aux mulshr24 =\ + "imul edx"\ + "shrd eax, edx, 24"\ + parm nomemory [eax][edx]\ + modify exact [eax edx] + +long mulshr32 (long, long); +#pragma aux mulshr32 =\ + "imul edx"\ + parm nomemory [eax][edx]\ + modify exact [eax edx]\ + value [edx] + +#elif defined(_MSC_VER) + +static _inline long mulshr24 (long a, long d) +{ + _asm + { + mov eax, a + imul d + shrd eax, edx, 24 + } +} + +static _inline long mulshr32 (long a, long d) +{ + _asm + { + mov eax, a + imul d + mov eax, edx + } +} + +#elif defined(__GNUC__) && defined(__i386__) + +#define mulshr24(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx; shrdl $24, %%edx, %%eax" \ + : "+a" (__a), "+d" (__d) : : "cc"); \ + __a; }) + +#define mulshr32(a,d) \ + ({ long __a=(a), __d=(d); \ + __asm__ __volatile__ ("imull %%edx" \ + : "+a" (__a), "+d" (__d) : : "cc"); \ + __d; }) + +#else + +#error Unsupported compiler or architecture. + +#endif + +static long cosqr16[8] = //cosqr16[i] = ((cos(PI*i/16)*sqrt(2))<<24); + {23726566,23270667,21920489,19727919,16777216,13181774,9079764,4628823}; +static long crmul[4096], cbmul[4096]; + +static void initkpeg () +{ + long i, x, y; + + x = 0; //Back & forth diagonal pattern (aligning bytes for best compression) + for(i=0;i<16;i+=2) + { + for(y=8-1;y>=0;y--) + if ((unsigned)(i-y) < (unsigned)8) unzig[x++] = (y<<3)+i-y; + for(y=0;y<8;y++) + if ((unsigned)(i+1-y) < (unsigned)8) unzig[x++] = (y<<3)+i+1-y; + } + for(i=64-1;i>=0;i--) zigit[unzig[i]] = i; + for(i=64-1;i>=0;i--) dcflagor[i] = (unsigned char)(1<<(unzig[i]>>3)); + + for(i=0;i<128;i++) colclip[i] = i+128; + for(i=128;i<512;i++) colclip[i] = 255; + for(i=512;i<896;i++) colclip[i] = 0; + for(i=896;i<1024;i++) colclip[i] = i-896; + for(i=0;i<1024;i++) + { + colclipup8[i] = (colclip[i]<<8); + colclipup16[i] = (colclip[i]<<16)+0xff000000; //Hack: set alphas to 255 + } +#if defined(BIGENDIAN) + for(i=0;i<1024;i++) + { + colclip[i] = bswap(colclip[i]); + colclipup8[i] = bswap(colclipup8[i]); + colclipup16[i] = bswap(colclipup16[i]); + } +#endif + + for(i=0;i<2048;i++) + { + crmul[(i<<1)+0] = (i-1024)*1470104; //1.402*1048576 + crmul[(i<<1)+1] = (i-1024)*-748830; //-0.71414*1048576 + cbmul[(i<<1)+0] = (i-1024)*-360857; //-0.34414*1048576 + cbmul[(i<<1)+1] = (i-1024)*1858077; //1.772*1048576 + } + + memset((void *)&dct[10][0],0,64*2*sizeof(dct[0][0])); +} + +static void huffgetval (long index, long curbits, long num, long *daval, long *dabits) +{ + long b, v, pow2, *hmax; + + hmax = &hufmaxatbit[index][0]; + pow2 = pow2long[curbits-1]; + if (num&pow2) v = 1; else v = 0; + for(b=1;b<=16;b++) + { + if (v < hmax[b]) + { + *dabits = b; + *daval = huftable[index][hufvalatbit[index][b]+v]; + return; + } + pow2 >>= 1; v <<= 1; + if (num&pow2) v++; + } + *dabits = 16; *daval = 0; +} + +static void invdct8x8 (long *dc, unsigned char dcflag) +{ + #define SQRT2 23726566 //(sqrt(2))<<24 + #define C182 31000253 //(cos(PI/8)*2)<<24 + #define C18S22 43840978 //(cos(PI/8)*sqrt(2)*2)<<24 + #define C38S22 18159528 //(cos(PI*3/8)*sqrt(2)*2)<<24 + long *edc, t0, t1, t2, t3, t4, t5, t6, t7; + + edc = dc+64; + do + { + if (dcflag&1) //pow2char[z]) + { + t3 = dc[2] + dc[6]; + t2 = (mulshr32(dc[2]-dc[6],SQRT2<<6)<<2) - t3; + t4 = dc[0] + dc[4]; t5 = dc[0] - dc[4]; + t0 = t4+t3; t3 = t4-t3; t1 = t5+t2; t2 = t5-t2; + t4 = (mulshr32(dc[5]-dc[3]+dc[1]-dc[7],C182<<6)<<2); + t7 = dc[1] + dc[7] + dc[5] + dc[3]; + t6 = (mulshr32(dc[3]-dc[5],C18S22<<5)<<3) + t4 - t7; + t5 = (mulshr32(dc[1]+dc[7]-dc[5]-dc[3],SQRT2<<6)<<2) - t6; + t4 = (mulshr32(dc[1]-dc[7],C38S22<<6)<<2) - t4 + t5; + dc[0] = t0+t7; dc[7] = t0-t7; dc[1] = t1+t6; dc[6] = t1-t6; + dc[2] = t2+t5; dc[5] = t2-t5; dc[4] = t3+t4; dc[3] = t3-t4; + } + dc += 8; dcflag >>= 1; + } while (dc < edc); + dc -= 32; edc -= 24; + do + { + t3 = dc[2*8-32] + dc[6*8-32]; + t2 = (mulshr32(dc[2*8-32]-dc[6*8-32],SQRT2<<6)<<2) - t3; + t4 = dc[0*8-32] + dc[4*8-32]; t5 = dc[0*8-32] - dc[4*8-32]; + t0 = t4+t3; t3 = t4-t3; t1 = t5+t2; t2 = t5-t2; + t4 = (mulshr32(dc[5*8-32]-dc[3*8-32]+dc[1*8-32]-dc[7*8-32],C182<<6)<<2); + t7 = dc[1*8-32] + dc[7*8-32] + dc[5*8-32] + dc[3*8-32]; + t6 = (mulshr32(dc[3*8-32]-dc[5*8-32],C18S22<<5)<<3) + t4 - t7; + t5 = (mulshr32(dc[1*8-32]+dc[7*8-32]-dc[5*8-32]-dc[3*8-32],SQRT2<<6)<<2) - t6; + t4 = (mulshr32(dc[1*8-32]-dc[7*8-32],C38S22<<6)<<2) - t4 + t5; + dc[0*8-32] = t0+t7; dc[7*8-32] = t0-t7; dc[1*8-32] = t1+t6; dc[6*8-32] = t1-t6; + dc[2*8-32] = t2+t5; dc[5*8-32] = t2-t5; dc[4*8-32] = t3+t4; dc[3*8-32] = t3-t4; + dc++; + } while (dc < edc); +} + +static void yrbrend (long x, long y) +{ + long i, j, ox, oy, xx, yy, xxx, yyy, xxxend, yyyend, yv, cr, cb, p, pp, *odc, *dc, *dc2; + + odc = dct[0]; dc2 = dct[10]; + for(yy=0;yy<(lcompvsamp[0]<<3);yy+=8) + { + oy = y+yy+globyoffs; if ((unsigned)oy >= (unsigned)clipydim) { odc += (lcomphsamp[0]<<6); continue; } + pp = oy*bytesperline + ((x+globxoffs)<<2) + frameplace; + for(xx=0;xx<(lcomphsamp[0]<<3);xx+=8,odc+=64) + { + ox = x+xx+globxoffs; if ((unsigned)ox >= (unsigned)clipxdim) continue; + p = pp+(xx<<2); + dc = odc; + if (lnumcomponents > 1) dc2 = &dct[lcomphvsamp0][((yy>>lcompvsampshift0)<<3)+(xx>>lcomphsampshift0)]; + xxxend = min(clipxdim-ox,8); + yyyend = min(clipydim-oy,8); + if ((lcomphsamp[0] == 1) && (xxxend == 8)) + { + for(yyy=0;yyy>13)&~1; + cb = (dc2[xxx ]>>13)&~1; + ((long *)p)[xxx] = colclipup16[(unsigned)(yv+crmul[cr+2048] )>>22]+ + colclipup8[(unsigned)(yv+crmul[cr+2049]+cbmul[cb+2048])>>22]+ + colclip[(unsigned)(yv+cbmul[cb+2049] )>>22]; + } + p += bytesperline; + dc += 8; + if (!((yyy+1)&(lcompvsamp[0]-1))) dc2 += 8; + } + } + else if ((lcomphsamp[0] == 2) && (xxxend == 8)) + { + for(yyy=0;yyy>1)+64]>>13)&~1; + cb = (dc2[(xxx>>1) ]>>13)&~1; + i = crmul[cr+2049]+cbmul[cb+2048]; + cr = crmul[cr+2048]; + cb = cbmul[cb+2049]; + ((long *)p)[xxx] = colclipup16[(unsigned)(yv+cr)>>22]+ + colclipup8[(unsigned)(yv+ i)>>22]+ + colclip[(unsigned)(yv+cb)>>22]; + yv = dc[xxx+1]; + ((long *)p)[xxx+1] = colclipup16[(unsigned)(yv+cr)>>22]+ + colclipup8[(unsigned)(yv+ i)>>22]+ + colclip[(unsigned)(yv+cb)>>22]; + } + p += bytesperline; + dc += 8; + if (!((yyy+1)&(lcompvsamp[0]-1))) dc2 += 8; + } + } + else + { + for(yyy=0;yyy>13)&~1; + cb = (dc2[i ]>>13)&~1; + i++; + } + ((long *)p)[xxx] = colclipup16[(unsigned)(yv+crmul[cr+2048] )>>22]+ + colclipup8[(unsigned)(yv+crmul[cr+2049]+cbmul[cb+2048])>>22]+ + colclip[(unsigned)(yv+cbmul[cb+2049] )>>22]; + } + p += bytesperline; + dc += 8; + if (!((yyy+1)&(lcompvsamp[0]-1))) dc2 += 8; + } + } + } + } +} + +static long kpegrend (const char *kfilebuf, long kfilength, + long daframeplace, long dabytesperline, long daxres, long dayres, + long daglobxoffs, long daglobyoffs) +{ + long i, j, p, v, leng, xdim, ydim, index, prec, restartcnt, restartinterval; + long x, y, z, xx, yy, zz, *dc, *dc2, num, curbits, c, daval, dabits, *hqval, *hqbits, hqcnt, *quanptr; + long passcnt = 0, ghsampmax, gvsampmax, glhsampmax, glvsampmax, glhstep, glvstep; + long eobrun, Ss, Se, Ah, Al, Alut[2], dctx[12], dcty[12], ldctx[12], ldcty[12], lshx[4], lshy[4]; + short *dctbuf = 0, *dctptr[12], *ldctptr[12], *dcs; + unsigned char ch, marker, dcflag; + const unsigned char *kfileptr; + + if (!kpeginited) { kpeginited = 1; initkpeg(); } + + kfileptr = (unsigned char *)kfilebuf; + + if (*(unsigned short *)kfileptr == SSWAPIB(0xd8ff)) kfileptr += 2; + else return(-1); //"%s is not a JPEG file\n",filename + + restartinterval = 0; + for(i=0;i<4;i++) lastdc[i] = 0; + for(i=0;i<8;i++) hufcnt[i] = 0; + + coltype = 0; bitdepth = 8; //For PNGOUT + do + { + ch = *kfileptr++; if (ch != 255) continue; + do { marker = *kfileptr++; } while (marker == 255); + if (marker != 0xd9) //Don't read past end of buffer + { + leng = ((long)kfileptr[0]<<8)+(long)kfileptr[1]-2; + kfileptr += 2; + } + //printf("fileoffs=%08x, marker=%02x,leng=%d",((long)kfileptr)-((long)kfilebuf)-2,marker,leng); + switch(marker) + { + case 0xc0: case 0xc1: case 0xc2: + //processit! + kfileptr++; //numbits = *kfileptr++; + + ydim = SSWAPIL(*(unsigned short *)&kfileptr[0]); + xdim = SSWAPIL(*(unsigned short *)&kfileptr[2]); + //printf("%s: %ld / %ld = %ld\n",filename,xdim*ydim*3,kfilength,(xdim*ydim*3)/kfilength); + + frameplace = daframeplace; + bytesperline = dabytesperline; + xres = daxres; + yres = dayres; + globxoffs = daglobxoffs; + globyoffs = daglobyoffs; + + gnumcomponents = kfileptr[4]; + kfileptr += 5; + ghsampmax = gvsampmax = glhsampmax = glvsampmax = 0; + for(z=0;z>4); + gcompvsamp[z] = (kfileptr[1]&15); + gcompquantab[z] = kfileptr[2]; + for(i=0;i<8;i++) if (gcomphsamp[z] == pow2long[i]) { gcomphsampshift[z] = i; break; } + for(i=0;i<8;i++) if (gcompvsamp[z] == pow2long[i]) { gcompvsampshift[z] = i; break; } + if (gcomphsamp[z] > ghsampmax) { ghsampmax = gcomphsamp[z]; glhsampmax = gcomphsampshift[z]; } + if (gcompvsamp[z] > gvsampmax) { gvsampmax = gcompvsamp[z]; glvsampmax = gcompvsampshift[z]; } + kfileptr += 3; + } + + break; + case 0xc4: //Huffman table + do + { + ch = *kfileptr++; leng--; + if (ch >= 16) { index = ch-12; } + else { index = ch; } + memcpy((void *)&hufnumatbit[index][1],(void *)kfileptr,16); kfileptr += 16; + leng -= 16; + + v = 0; hufcnt[index] = 0; + hufquickcnt[index] = 0; + for(i=1;i<=16;i++) + { + hufmaxatbit[index][i] = v+hufnumatbit[index][i]; + hufvalatbit[index][i] = hufcnt[index]-v; + memcpy((void *)&huftable[index][hufcnt[index]],(void *)kfileptr,(long)hufnumatbit[index][i]); + if (i <= 10) + for(c=0;c0;j--) + { + hufquickval[index][hufquickcnt[index]] = huftable[index][hufcnt[index]+c]; + hufquickbits[index][hufquickcnt[index]] = i; + hufquickcnt[index]++; + } + kfileptr += hufnumatbit[index][i]; + leng -= hufnumatbit[index][i]; + hufcnt[index] += hufnumatbit[index][i]; + v = ((v+hufnumatbit[index][i])<<1); + } + + } while (leng > 0); + break; + case 0xdb: + do + { + ch = *kfileptr++; leng--; + index = (ch&15); + prec = (ch>>4); + for(z=0;z<64;z++) + { + v = (long)(*kfileptr++); + if (prec) v = (v<<8)+((long)(*kfileptr++)); + v <<= 19; + if (unzig[z]&7 ) v = mulshr24(v,cosqr16[unzig[z]&7 ]); + if (unzig[z]>>3) v = mulshr24(v,cosqr16[unzig[z]>>3]); + if (index) v >>= 6; + quantab[index][unzig[z]] = v; + } + leng -= 64; + if (prec) leng -= 64; + } while (leng > 0); + break; + case 0xdd: + restartinterval = SSWAPIL(*(unsigned short *)&kfileptr[0]); + kfileptr += leng; + break; + case 0xda: + if ((xdim <= 0) || (ydim <= 0)) { if (dctbuf) free(dctbuf); return(-1); } + + lnumcomponents = (long)(*kfileptr++); if (!lnumcomponents) { if (dctbuf) free(dctbuf); return(-1); } + if (lnumcomponents > 1) coltype = 2; + for(z=0;z>4); + lcompac[z] = (kfileptr[1]&15); + kfileptr += 2; + } + + Ss = kfileptr[0]; + Se = kfileptr[1]; + Ah = (kfileptr[2]>>4); + Al = (kfileptr[2]&15); + kfileptr += 3; + //printf("passcnt=%d, Ss=%d, Se=%d, Ah=%d, Al=%d\n",passcnt,Ss,Se,Ah,Al); + + if ((!passcnt) && ((Ss) || (Se != 63) || (Ah) || (Al))) + { + for(z=zz=0;z>(glhsampmax+3)) << gcomphsampshift[z]; + dcty[z] = ((ydim+(gvsampmax<<3)-1)>>(glvsampmax+3)) << gcompvsampshift[z]; + zz += dctx[z]*dcty[z]; + } + z = zz*64*sizeof(short); + dctbuf = (short *)malloc(z); if (!dctbuf) return(-1); + memset(dctbuf,0,z); + for(z=zz=0;z>glhstep); lcomphsamp[0] = min(lcomphsamp[0],glhstep); glhstep <<= 3; + glvstep = (gvsampmax>>glvstep); lcompvsamp[0] = min(lcompvsamp[0],glvstep); glvstep <<= 3; + lcomphvsamp0 = lcomphsamp[0]*lcompvsamp[0]; + + clipxdim = min(xdim+globxoffs,xres); + clipydim = min(ydim+globyoffs,yres); + + if ((max(globxoffs,0) >= xres) || (min(globxoffs+xdim,xres) <= 0) || + (max(globyoffs,0) >= yres) || (min(globyoffs+ydim,yres) <= 0)) + { if (dctbuf) free(dctbuf); return(0); } + + Alut[0] = (1<= kfilength) goto kpegrend_break2; //rest of file is missing! + + if (!dctbuf) dc = dct[0]; + for(c=0;c>lshy[c])*ldctx[c] + ((x+xx)>>lshx[c]))<<6]; + + //Get DC + if (!Ss) + { + while (curbits < 24) //Getbits + { + ch = *kfileptr++; if (ch == 255) kfileptr++; + num = (num<<8)+((long)ch); curbits += 8; + } + + if (!Ah) + { + i = ((num>>(curbits-10))&1023); + if (i < hufquickcnt[lcompdc[c]]) + { daval = hufquickval[lcompdc[c]][i]; curbits -= hufquickbits[lcompdc[c]][i]; } + else { huffgetval(lcompdc[c],curbits,num,&daval,&dabits); curbits -= dabits; } + + if (daval) + { + while (curbits < 24) //Getbits + { + ch = *kfileptr++; if (ch == 255) kfileptr++; + num = (num<<8)+((long)ch); curbits += 8; + } + + curbits -= daval; v = ((unsigned)num >> curbits) & pow2mask[daval]; + if (v <= pow2mask[daval-1]) v -= pow2mask[daval]; + lastdc[c] += v; + } + if (!dctbuf) dc[0] = lastdc[c]; else dcs[0] = (short)(lastdc[c]<>(curbits-10))&1023); + if (i < hqcnt) + { daval = hqval[i]; curbits -= hqbits[i]; } + else { huffgetval(lcompac[c]+4,curbits,num,&daval,&dabits); curbits -= dabits; } + + zz = (daval>>4); daval &= 15; + if (daval) + { + if (Ah) + { + //NOTE: Getbits not needed here - buffer should have enough bits + if (num&(pow2long[--curbits])) daval = Alut[0]; else daval = Alut[1]; + } + } + else if (zz < 15) + { + eobrun = pow2long[zz]; + if (zz) + { + while (curbits < 24) //Getbits + { + ch = *kfileptr++; if (ch == 255) kfileptr++; + num = (num<<8)+((long)ch); curbits += 8; + } + curbits -= zz; eobrun += ((unsigned)num >> curbits) & pow2mask[zz]; + } + if (!Ah) eobrun--; + break; + } + if (Ah) + { + do + { + if (dcs[z]) + { + while (curbits < 24) //Getbits + { + ch = *kfileptr++; if (ch == 255) kfileptr++; + num = (num<<8)+((long)ch); curbits += 8; + } + if (num&(pow2long[--curbits])) dcs[z] += ((short)Alut[dcs[z] < 0]); + } else if (--zz < 0) break; + z++; + } while (z <= Se); + if (daval) dcs[z] = daval; + } + else + { + z += zz; if (z > Se) break; + + while (curbits < 24) //Getbits + { + ch = *kfileptr++; if (ch == 255) kfileptr++; + num = (num<<8)+((long)ch); curbits += 8; + } + curbits -= daval; v = ((unsigned)num >> curbits) & pow2mask[daval]; + if (v <= pow2mask[daval-1]) v -= pow2mask[daval]; + dcflag |= dcflagor[z]; + if (!dctbuf) dc[unzig[z]] = v; else dcs[z] = (short)(v< 0)) + { + eobrun--; + for(;z<=Se;z++) + { + if (!dcs[z]) continue; + while (curbits < 24) //Getbits + { + ch = *kfileptr++; if (ch == 255) kfileptr++; + num = (num<<8)+((long)ch); curbits += 8; + } + if (num&(pow2long[--curbits])) dcs[z] += ((short)Alut[dcs[z] < 0]); + } + } + + if (!dctbuf) + { + for(z=64-1;z>=0;z--) dc[z] *= quanptr[z]; + invdct8x8(dc,dcflag); dc += 64; + } + } + } + + if (!dctbuf) yrbrend(x,y); + + restartcnt--; + if (!restartcnt) + { + kfileptr += 1-(curbits>>3); curbits = 0; + if ((kfileptr[-2] != 255) || (kfileptr[-1] != marker)) kfileptr--; + marker++; if (marker >= 0xd8) marker = 0xd0; + restartcnt = restartinterval; + for(i=0;i<4;i++) lastdc[i] = 0; + eobrun = 0; + } + } +kpegrend_break2:; + if (!dctbuf) return(0); + passcnt++; kfileptr -= ((curbits>>3)+1); break; + case 0xd9: break; + default: kfileptr += leng; break; + } + } while (kfileptr-(unsigned char *)kfilebuf < kfilength); + + if (!dctbuf) return(0); + + lnumcomponents = gnumcomponents; + for(i=0;i>lshy[c])*dctx[c] + ((x+xx)>>lshx[c]))<<6]; + quanptr = &quantab[gcompquantab[c]][0]; + for(z=0;z<64;z++) dc[z] = ((long)dcs[zigit[z]])*quanptr[z]; + invdct8x8(dc,-1); + } + yrbrend(x,y); + } + + free(dctbuf); return(0); +} + +//============================== KPEGILIB ends ============================== +//================================ GIF begins ================================ + +static unsigned char suffix[4100], filbuffer[768], tempstack[4096]; +static long prefix[4100]; + +static long kgifrend (const char *kfilebuf, long kfilelength, + long daframeplace, long dabytesperline, long daxres, long dayres, + long daglobxoffs, long daglobyoffs) +{ + long i, x, y, xsiz, ysiz, yinc, xend, xspan, yspan, currstr, numbitgoal; + long lzcols, dat, blocklen, bitcnt, xoff, yoff, transcol, backcol, *lptr; + char numbits, startnumbits, chunkind, ilacefirst; + const unsigned char *ptr, *cptr; + + coltype = 3; bitdepth = 8; //For PNGOUT + + if ((kfilebuf[0] != 'G') || (kfilebuf[1] != 'I') || + (kfilebuf[2] != 'F') || (kfilebuf[12])) return(-1); + paleng = (1<<((kfilebuf[10]&7)+1)); + ptr = (unsigned char *)&kfilebuf[13]; + if (kfilebuf[10]&128) { cptr = ptr; ptr += paleng*3; } + transcol = -1; + while ((chunkind = *ptr++) == '!') + { //! 0xf9 leng flags ?? ?? transcol + if (ptr[0] == 0xf9) { if (ptr[2]&1) transcol = (long)(((unsigned char)ptr[5])); } + ptr++; + do { i = *ptr++; ptr += i; } while (i); + } + if (chunkind != ',') return(-1); + + xoff = SSWAPIB(*(unsigned short *)&ptr[0]); + yoff = SSWAPIB(*(unsigned short *)&ptr[2]); + xspan = SSWAPIB(*(unsigned short *)&ptr[4]); + yspan = SSWAPIB(*(unsigned short *)&ptr[6]); ptr += 9; + if (ptr[-1]&64) { yinc = 8; ilacefirst = 1; } + else { yinc = 1; ilacefirst = 0; } + if (ptr[-1]&128) + { + paleng = (1<<((ptr[-1]&7)+1)); + cptr = ptr; ptr += paleng*3; + } + + for(i=0;i= 0) palcol[transcol] &= LSWAPIB(~0xff000000); + + //Handle GIF files with different logical&image sizes or non-0 offsets (added 05/15/2004) + xsiz = SSWAPIB(*(unsigned short *)&kfilebuf[6]); + ysiz = SSWAPIB(*(unsigned short *)&kfilebuf[8]); + if ((xoff != 0) || (yoff != 0) || (xsiz != xspan) || (ysiz != yspan)) + { + long xx[4], yy[4]; + if (kfilebuf[10]&128) backcol = palcol[(unsigned char)kfilebuf[11]]; else backcol = 0; + + //Fill border to backcol + xx[0] = max(daglobxoffs , 0); yy[0] = max(daglobyoffs , 0); + xx[1] = min(daglobxoffs+xoff ,daxres); yy[1] = min(daglobyoffs+yoff ,dayres); + xx[2] = max(daglobxoffs+xoff+xspan, 0); yy[2] = min(daglobyoffs+yoff+yspan,dayres); + xx[3] = min(daglobxoffs+xsiz ,daxres); yy[3] = min(daglobyoffs+ysiz ,dayres); + + lptr = (long *)(yy[0]*dabytesperline+daframeplace); + for(y=yy[0];y=0;i--) { suffix[i] = (char)(prefix[i] = i); } + currstr = lzcols+2; numbits = startnumbits; numbitgoal = (lzcols<<1); + blocklen = *ptr++; + memcpy(filbuffer,ptr,blocklen); ptr += blocklen; + bitcnt = 0; + while (1) + { + dat = (LSWAPIB(*(long *)&filbuffer[bitcnt>>3])>>(bitcnt&7)) & (numbitgoal-1); + bitcnt += numbits; + if ((bitcnt>>3) > blocklen-3) + { + *(short *)filbuffer = *(short *)&filbuffer[bitcnt>>3]; + i = blocklen-(bitcnt>>3); + blocklen = (long)*ptr++; + memcpy(&filbuffer[i],ptr,blocklen); ptr += blocklen; + bitcnt &= 7; blocklen += i; + } + if (dat == lzcols) + { + currstr = lzcols+2; numbits = startnumbits; numbitgoal = (lzcols<<1); + continue; + } + if ((currstr == numbitgoal) && (numbits < 12)) + { numbits++; numbitgoal <<= 1; } + + prefix[currstr] = dat; + for(i=0;dat>=lzcols;dat=prefix[dat]) tempstack[i++] = suffix[dat]; + tempstack[i] = (char)prefix[dat]; + suffix[currstr-1] = suffix[currstr] = (char)dat; + + for(;i>=0;i--) + { + if ((unsigned long)x < (unsigned long)daxres) + *(long *)(yoff+(x<<2)) = palcol[(long)tempstack[i]]; + x++; + if (x == xend) + { + y += yinc; + if (y >= yspan) + switch(yinc) + { + case 8: if (!ilacefirst) { y = daglobyoffs+2; yinc = 4; break; } + ilacefirst = 0; y = daglobyoffs+4; yinc = 8; break; + case 4: y = daglobyoffs+1; yinc = 2; break; + case 2: case 1: return(0); + } + if ((unsigned long)y < (unsigned long)dayres) + { yoff = y*dabytesperline+daframeplace; x = daglobxoffs; xend = xspan; } + else + { x = daglobxoffs+0x80000000; xend = xspan+0x80000000; } + } + } + currstr++; + } +} + +//=============================== GIF ends ================================== +//============================== CEL begins ================================= + + // //old .CEL format: + //short id = 0x9119, xdim, ydim, xoff, yoff, id = 0x0008; + //long imagebytes, filler[4]; + //char pal6bit[256][3], image[ydim][xdim]; +static long kcelrend (const char *buf, long fleng, + long daframeplace, long dabytesperline, long daxres, long dayres, + long daglobxoffs, long daglobyoffs) +{ + long i, x, y, x0, x1, y0, y1, xsiz, ysiz; + const char *cptr; + + if ((buf[0] != 0x19) || (buf[1] != 0x91) || + (buf[10] != 8) || (buf[11] != 0)) return(-1); + + coltype = 3; bitdepth = 8; paleng = 256; //For PNGOUT + + xsiz = (long)SSWAPIB(*(unsigned short *)&buf[2]); if (xsiz <= 0) return(-1); + ysiz = (long)SSWAPIB(*(unsigned short *)&buf[4]); if (ysiz <= 0) return(-1); + + cptr = &buf[32]; + for(i=0;i<256;i++) + { + palcol[i] = (((long)cptr[0])<<18) + + (((long)cptr[1])<<10) + + (((long)cptr[2])<< 2) + LSWAPIB(0xff000000); + cptr += 3; + } + + x0 = daglobyoffs; x1 = xsiz+daglobyoffs; + y0 = daglobyoffs; y1 = ysiz+daglobyoffs; + for(y=y0;y= 12) || (!((1< 32)) return(-1); + if (header[17]&0xc0) return(-1); + + fptr = (unsigned char *)&header[header[0]+18]; + xsiz = (long)SSWAPIB(*(unsigned short *)&header[12]); if (xsiz <= 0) return(-1); + ysiz = (long)SSWAPIB(*(unsigned short *)&header[14]); if (ysiz <= 0) return(-1); + colbyte = ((((long)header[16])+7)>>3); + + if (header[1] == 1) + { + pixbyte = ((((long)header[7])+7)>>3); + cptr = &fptr[-SSWAPIB(*(unsigned short *)&header[3])*pixbyte]; + fptr += SSWAPIB(*(unsigned short *)&header[5])*pixbyte; + } else pixbyte = colbyte; + + switch(pixbyte) //For PNGOUT + { + case 1: coltype = 0; bitdepth = 8; palcol[0] = LSWAPIB(0xff000000); + for(i=1;i<256;i++) palcol[i] = palcol[i-1]+LSWAPIB(0x10101); break; + case 2: case 3: coltype = 2; break; + case 4: coltype = 6; break; + } + + if (!(header[17]&16)) { x0 = 0; x1 = xsiz; xi = 1; } + else { x0 = xsiz-1; x1 = -1; xi =-1; } + if (header[17]&32) { y0 = 0; y1 = ysiz; yi = 1; pi = dabytesperline; } + else { y0 = ysiz-1; y1 = -1; yi =-1; pi =-dabytesperline; } + x0 += daglobxoffs; y0 += daglobyoffs; + x1 += daglobxoffs; y1 += daglobyoffs; + if (header[2] < 8) rlestat = -2; else rlestat = -1; + + p = y0*dabytesperline+daframeplace; + for(y=y0;y!=y1;y+=yi,p+=pi) + for(x=x0;x!=x1;x+=xi) + { + if (rlestat < 128) + { + if ((rlestat&127) == 127) { rlestat = (long)fptr[0]; fptr++; } + if (header[1] == 1) + { + if (colbyte == 1) i = fptr[0]; + else i = (long)SSWAPIB(*(unsigned short *)&fptr[0]); + nptr = &cptr[i*pixbyte]; + } else nptr = fptr; + + switch(pixbyte) + { + case 1: i = palcol[(long)nptr[0]]; break; + case 2: i = (long)SSWAPIB(*(unsigned short *)&nptr[0]); + i = LSWAPIB(((i&0x7c00)<<9) + ((i&0x03e0)<<6) + ((i&0x001f)<<3) + 0xff000000); + break; + case 3: i = (*(long *)&nptr[0]) | LSWAPIB(0xff000000); break; + case 4: i = (*(long *)&nptr[0]); break; + } + fptr += colbyte; + } + if (rlestat >= 0) rlestat--; + + if (((unsigned long)x < (unsigned long)daxres) && ((unsigned long)y < (unsigned long)dayres)) + *(long *)(x*4+p) = i; + } + return(0); +} + +//============================== TARGA ends ================================= +//============================== BMP begins ================================= + //TODO: handle BI_RLE8 and BI_RLE4 (compression types 1&2 respectively) + // ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + // ³ 0(2): "BM" ³ + // ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³ 10(4): rastoff³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + // ³headsiz=12 (OS/2 1.x)³³ 14(4): headsiz³ ³ All new formats: ³ + //ÚÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÁÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÁÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + //³ 18(2): xsiz ³ 18(4): xsiz ³ + //³ 20(2): ysiz ³ 22(4): ysiz ³ + //³ 22(2): planes (always 1) ³ 26(2): planes (always 1) ³ + //³ 24(2): cdim (1,4,8,24) ³ 28(2): cdim (1,4,8,16,24,32) ³ + //³ if (cdim < 16) ³ 30(4): compression (0,1,2,3!?,4) ³ + //³ 26(rastoff-14-headsiz): pal(bgr) ³ 34(4): (bitmap data size+3)&3 ³ + //³ ³ 46(4): N colors (0=2^cdim) ³ + //³ ³ if (cdim < 16) ³ + //³ ³ 14+headsiz(rastoff-14-headsiz): pal(bgr0) ³ + //ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + // ³ rastoff(?): bitmap data ³ + // ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ +static long kbmprend (const char *buf, long fleng, + long daframeplace, long dabytesperline, long daxres, long dayres, + long daglobxoffs, long daglobyoffs) +{ + long i, j, x, y, x0, x1, y0, y1, rastoff, headsiz, xsiz, ysiz, cdim, comp, cptrinc, *lptr; + const char *cptr; + + headsiz = *(long *)&buf[14]; + if (headsiz == LSWAPIB(12)) //OS/2 1.x (old format) + { + if (*(short *)(&buf[22]) != SSWAPIB(1)) return(-1); + xsiz = (long)SSWAPIB(*(unsigned short *)&buf[18]); + ysiz = (long)SSWAPIB(*(unsigned short *)&buf[20]); + cdim = (long)SSWAPIB(*(unsigned short *)&buf[24]); + comp = 0; + } + else //All newer formats... + { + if (*(short *)(&buf[26]) != SSWAPIB(1)) return(-1); + xsiz = LSWAPIB(*(long *)&buf[18]); + ysiz = LSWAPIB(*(long *)&buf[22]); + cdim = (long)SSWAPIB(*(unsigned short *)&buf[28]); + comp = LSWAPIB(*(long *)&buf[30]); + } + if ((xsiz <= 0) || (!ysiz)) return(-1); + //cdim must be: (1,4,8,16,24,32) + if (((unsigned long)(cdim-1) >= (unsigned long)32) || (!((1<>1); + } + for(palcol[i+3]=0;palcol[i+3]<32;palcol[i+3]++) + { + if (!(j&1)) break; + j = (((unsigned long)j)>>1); + } + } + } + palcol[0] = 24-(palcol[0]+palcol[3]); + palcol[1] = 16-(palcol[1]+palcol[4]); + palcol[2] = 8-(palcol[2]+palcol[5]); + palcol[3] = ((-1<<(24-palcol[3]))&0x00ff0000); + palcol[4] = ((-1<<(16-palcol[4]))&0x0000ff00); + palcol[5] = ((-1<<( 8-palcol[5]))&0x000000ff); + } + + cptrinc = (((xsiz*cdim+31)>>3)&~3); cptr = &buf[rastoff]; + if (ysiz < 0) { ysiz = -ysiz; } else { cptr = &cptr[(ysiz-1)*cptrinc]; cptrinc = -cptrinc; } + + x0 = daglobxoffs; x1 = xsiz+daglobxoffs; + y0 = daglobyoffs; y1 = ysiz+daglobyoffs; + if ((x0 >= daxres) || (x1 <= 0) || (y0 >= dayres) || (y1 <= 0)) return(0); + if (x0 < 0) x0 = 0; + if (x1 > daxres) x1 = daxres; + for(y=y0;y= (unsigned long)dayres) continue; + lptr = (long *)(y*dabytesperline-(daglobyoffs<<2)+daframeplace); + switch(cdim) + { + case 1: for(x=x0;x>3]>>((x&7)^7))&1)]; break; + case 4: for(x=x0;x>1]>>(((x&1)^1)<<2))&15)]; break; + case 8: for(x=x0;x= x1) { x = x0; y++; p += dabytesperline; } + } + } while (y < y1); + } + else if (nplanes == 3) //24-bit PCX + { + do + { + c = *cptr++; if (c < 192) i = 1; else { i = (c&63); c = *cptr++; } + for(;i;i--) + { + if ((unsigned long)y < (unsigned long)dayres) + if ((unsigned long)x < (unsigned long)daxres) *(char *)(x+p) = c; + x += 4; if (x >= x1) { j--; if (j < 0) { j = 3-1; y++; p += dabytesperline; } x = x0+j; } + } + } while (y < y1); + } + + return(0); +} + +//=============================== BMP ends ================================== +//=================== External picture interface begins ====================== + +void kpgetdim (const char *buf, long leng, long *xsiz, long *ysiz) +{ + long *lptr; + const unsigned char *cptr; + unsigned char *ubuf = (unsigned char *)buf; + + (*xsiz) = (*ysiz) = 0; if (leng < 16) return; + if ((ubuf[0] == 0x89) && (ubuf[1] == 0x50)) //.PNG + { + lptr = (long *)buf; + if ((lptr[0] != LSWAPIB(0x474e5089)) || (lptr[1] != LSWAPIB(0x0a1a0a0d))) return; + lptr = &lptr[2]; + while (((unsigned long)lptr-(unsigned long)buf) < (unsigned long)(leng-16)) + { + if (lptr[1] == LSWAPIB(0x52444849)) //IHDR + { (*xsiz) = LSWAPIL(lptr[2]); (*ysiz) = LSWAPIL(lptr[3]); break; } + lptr = (long *)((long)lptr + LSWAPIL(lptr[0]) + 12); + } + } + else if ((ubuf[0] == 0xff) && (ubuf[1] == 0xd8)) //.JPG + { + cptr = (unsigned char *)&buf[2]; + while (((unsigned long)cptr-(unsigned long)buf) < (unsigned long)(leng-8)) + { + if (cptr[0] != 255) { cptr = &cptr[1]; continue; } + if ((unsigned long)(cptr[1]-0xc0) < 3) + { + (*ysiz) = SSWAPIL(*(unsigned short *)&cptr[5]); + (*xsiz) = SSWAPIL(*(unsigned short *)&cptr[7]); + break; + } + cptr = &cptr[SSWAPIL(*(unsigned short *)&cptr[2])+2]; + } + } + else if ((ubuf[0] == 'G') && (ubuf[1] == 'I') && (ubuf[2] == 'F') && (ubuf[12] == 0)) //.GIF + { + (*xsiz) = (long)SSWAPIB(*(unsigned short *)&buf[6]); + (*ysiz) = (long)SSWAPIB(*(unsigned short *)&buf[8]); + } + else if ((ubuf[0] == 0x19) && (ubuf[1] == 0x91) && (ubuf[10] == 8) && (ubuf[11] == 0)) //old .CEL/.PIC + { + (*xsiz) = (long)SSWAPIB(*(unsigned short *)&buf[2]); + (*ysiz) = (long)SSWAPIB(*(unsigned short *)&buf[4]); + } + else if ((ubuf[0] == 'B') && (ubuf[1] == 'M')) //.BMP + { + if (*(long *)(&buf[14]) == LSWAPIB(12)) //OS/2 1.x (old format) + { + if (*(short *)(&buf[22]) != SSWAPIB(1)) return; + (*xsiz) = (long)SSWAPIB(*(unsigned short *)&buf[18]); + (*ysiz) = (long)SSWAPIB(*(unsigned short *)&buf[20]); + } + else //All newer formats... + { + if (*(short *)(&buf[26]) != SSWAPIB(1)) return; + (*xsiz) = LSWAPIB(*(long *)&buf[18]); + (*ysiz) = LSWAPIB(*(long *)&buf[22]); + } + } + else if (*(long *)ubuf == LSWAPIB(0x0801050a)) //.PCX + { + (*xsiz) = SSWAPIB(*(short *)&buf[ 8])-SSWAPIB(*(short *)&buf[4])+1; + (*ysiz) = SSWAPIB(*(short *)&buf[10])-SSWAPIB(*(short *)&buf[6])+1; + } + else + { //Unreliable .TGA identification - this MUST be final case! + if ((leng >= 20) && (!(ubuf[1]&0xfe))) + if ((ubuf[2] < 12) && ((1<= 20) && (!(ubuf[1]&0xfe))) + if ((ubuf[2] < 12) && ((1<= 'a') && (c0 <= 'z')) c0 -= 32; + c1 = *j; if ((c1 >= 'a') && (c1 <= 'z')) c1 -= 32; + if (c0 == '/') c0 = '\\'; + if (c1 == '/') c1 = '\\'; + if (c0 != c1) return(0); + i++; j++; + } while (*j); + return(!*i); +} + + //Same as: stricmp(st0,st1) except: '/' == '\' +static long filnamcmp (const char *st0, const char *st1) +{ + long i; + char ch0, ch1; + + for(i=0;st0[i];i++) + { + ch0 = st0[i]; if ((ch0 >= 'a') && (ch0 <= 'z')) ch0 -= 32; + ch1 = st1[i]; if ((ch1 >= 'a') && (ch1 <= 'z')) ch1 -= 32; + if (ch0 == '/') ch0 = '\\'; + if (ch1 == '/') ch1 = '\\'; + if (ch0 != ch1) return(-1); + } + if (!st1[i]) return(0); + return(-1); +} + +//===================== ZIP decompression code begins ======================== + + //format: (used by kzaddstack/kzopen to cache file name&start info) + //[char zipnam[?]\0] + //[next hashindex/-1][next index/-1][zipnam index][zipseek][char filnam[?]\0] + //[next hashindex/-1][next index/-1][zipnam index][zipseek][char filnam[?]\0] + //... + //[char zipnam[?]\0] + //[next hashindex/-1][next index/-1][zipnam index][zipseek][char filnam[?]\0] + //[next hashindex/-1][next index/-1][zipnam index][zipseek][char filnam[?]\0] + //... +#define KZHASHINITSIZE 8192 +static char *kzhashbuf = 0; +static long kzhashead[256], kzhashpos, kzlastfnam, kzhashsiz; + +static long kzcheckhashsiz (long siz) +{ + long i; + + if (!kzhashbuf) //Initialize hash table on first call + { + memset(kzhashead,-1,sizeof(kzhashead)); + kzhashbuf = (char *)malloc(KZHASHINITSIZE); if (!kzhashbuf) return(0); + kzhashpos = 0; kzlastfnam = -1; kzhashsiz = KZHASHINITSIZE; + } + if (kzhashpos+siz > kzhashsiz) //Make sure string fits in kzhashbuf + { + i = kzhashsiz; do { i <<= 1; } while (kzhashpos+siz > i); + kzhashbuf = (char *)realloc(kzhashbuf,i); if (!kzhashbuf) return(0); + kzhashsiz = i; + } + return(1); +} + +static long kzcalchash (const char *st) +{ + long i, hashind; + char ch; + + for(i=0,hashind=0;st[i];i++) + { + ch = st[i]; + if ((ch >= 'a') && (ch <= 'z')) ch -= 32; + if (ch == '/') ch = '\\'; + hashind = (ch - hashind*3); + } + return(hashind%(sizeof(kzhashead)/sizeof(kzhashead[0]))); +} + +static long kzcheckhash (const char *filnam, char **zipnam, long *zipseek) +{ + long i; + + if (!kzhashbuf) return(0); + if (filnam[0] == '|') filnam++; + for(i=kzhashead[kzcalchash(filnam)];i>=0;i=(*(long *)&kzhashbuf[i])) + if (!filnamcmp(filnam,&kzhashbuf[i+16])) + { + (*zipnam) = &kzhashbuf[*(long *)&kzhashbuf[i+8]]; + (*zipseek) = *(long *)&kzhashbuf[i+12]; + return(1); + } + return(0); +} + +void kzuninit () +{ + if (kzhashbuf) { free(kzhashbuf); kzhashbuf = 0; } + kzhashpos = kzhashsiz = 0; +} + + //Load ZIP directory into memory (hash) to allow fast access later +long kzaddstack (const char *zipnam) +{ + FILE *fil; + long i, j, hashind, zipnamoffs, numfiles; + char tempbuf[260+46]; + + fil = fopen(zipnam,"rb"); if (!fil) return(-1); + + //Write ZIP filename to hash + i = strlen(zipnam)+1; if (!kzcheckhashsiz(i)) { fclose(fil); return(-1); } + strcpy(&kzhashbuf[kzhashpos],zipnam); + zipnamoffs = kzhashpos; kzhashpos += i; + + fseek(fil,-22,SEEK_END); + fread(tempbuf,22,1,fil); + if (*(long *)&tempbuf[0] == LSWAPIB(0x06054b50)) //Fast way of finding dir info + { + numfiles = SSWAPIB(*(short *)&tempbuf[10]); + fseek(fil,LSWAPIB(*(long *)&tempbuf[16]),SEEK_SET); + } + else //Slow way of finding dir info (used when ZIP has junk at end) + { + fseek(fil,0,SEEK_SET); numfiles = 0; + while (1) + { + if (!fread(&j,4,1,fil)) { numfiles = -1; break; } + if (j == LSWAPIB(0x02014b50)) break; //Found central file header :) + if (j != LSWAPIB(0x04034b50)) { numfiles = -1; break; } + fread(tempbuf,26,1,fil); + fseek(fil,LSWAPIB(*(long *)&tempbuf[14]) + SSWAPIB(*(short *)&tempbuf[24]) + SSWAPIB(*(short *)&tempbuf[22]),SEEK_CUR); + numfiles++; + } + if (numfiles < 0) { fclose(fil); return(-1); } + fseek(fil,-4,SEEK_CUR); + } + for(i=0;i 2GB-32K bytes + gslidew = 0x7fffffff; //Force reload at beginning + + return((long)kzfs.fil); + default: fclose(kzfs.fil); kzfs.fil = 0; return(0); + } + } + return(0); +} + +// -------------------------------------------------------------------------- + +static long srchstat = -1, wildstpathleng; + +#if defined(__DOS__) +static char wildst[260] = ""; +static struct find_t findata; +#elif defined(_WIN32) +static char wildst[MAX_PATH] = ""; +static HANDLE hfind = INVALID_HANDLE_VALUE; +static WIN32_FIND_DATA findata; +#else +static char wildst[260] = ""; +static DIR *hfind = NULL; +static struct dirent *findata = NULL; +#endif + +void kzfindfilestart (const char *st) +{ +#ifdef _WIN32 + if (hfind != INVALID_HANDLE_VALUE) + { FindClose(hfind); hfind = INVALID_HANDLE_VALUE; } +#else + if (hfind) { closedir(hfind); hfind = NULL; } +#endif + strcpy(wildst,st); + srchstat = -3; +} + +long kzfindfile (char *filnam) +{ + long i; + + filnam[0] = 0; + if (srchstat == -3) + { + if (!wildst[0]) { srchstat = -1; return(0); } + do + { + srchstat = -2; + + //Extract directory from wildcard string for pre-pending + wildstpathleng = 0; + for(i=0;wildst[i];i++) + if ((wildst[i] == '/') || (wildst[i] == '\\')) + wildstpathleng = i+1; + + memcpy(filnam,wildst,wildstpathleng); + +#if defined(__DOS__) + if (_dos_findfirst(wildst,_A_SUBDIR,&findata)) + { if (!kzhashbuf) return(0); srchstat = kzlastfnam; continue; } + i = wildstpathleng; + if (findata.attrib&16) + if ((findata.name[0] == '.') && (!findata.name[1])) continue; + strcpy(&filnam[i],findata.name); + if (findata.attrib&16) strcat(&filnam[i],"\\"); +#elif defined(_WIN32) + hfind = FindFirstFile(wildst,&findata); + if (hfind == INVALID_HANDLE_VALUE) + { if (!kzhashbuf) return(0); srchstat = kzlastfnam; continue; } + if (findata.dwFileAttributes&FILE_ATTRIBUTE_HIDDEN) continue; + i = wildstpathleng; + if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) + if ((findata.cFileName[0] == '.') && (!findata.cFileName[1])) continue; + strcpy(&filnam[i],findata.cFileName); + if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) strcat(&filnam[i],"\\"); +#else + if (!hfind) + { + char *s = "."; + if (wildstpathleng > 0) { + filnam[wildstpathleng] = 0; + s = filnam; + } + hfind = opendir(s); + if (!hfind) { if (!kzhashbuf) return 0; srchstat = kzlastfnam; continue; } + } + break; // process srchstat == -2 +#endif + return(1); + } while (0); + } + if (srchstat == -2) + while (1) + { + memcpy(filnam,wildst,wildstpathleng); +#if defined(__DOS__) + if (_dos_findnext(&findata)) + { if (!kzhashbuf) return(0); srchstat = kzlastfnam; break; } + i = wildstpathleng; + if (findata.attrib&16) + if ((findata.name[0] == '.') && (!findata.name[1])) continue; + strcpy(&filnam[i],findata.name); + if (findata.attrib&16) strcat(&filnam[i],"\\"); +#elif defined(_WIN32) + if (!FindNextFile(hfind,&findata)) + { FindClose(hfind); if (!kzhashbuf) return(0); srchstat = kzlastfnam; break; } + if (findata.dwFileAttributes&FILE_ATTRIBUTE_HIDDEN) continue; + i = wildstpathleng; + if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) + if ((findata.cFileName[0] == '.') && (!findata.cFileName[1])) continue; + strcpy(&filnam[i],findata.cFileName); + if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) strcat(&filnam[i],"\\"); +#else + { + struct stat st; + if ((findata = readdir(hfind)) == NULL) + { closedir(hfind); hfind = NULL; if (!kzhashbuf) return 0; srchstat = kzlastfnam; break; } + i = wildstpathleng; + strcpy(&filnam[i],findata->d_name); + if (stat(filnam,&st) < 0) continue; + if (st.st_mode & S_IFDIR) + { if (findata->d_name[0] == '.' && !findata->d_name[1]) continue; } //skip . + else if ((st.st_mode & S_IFREG) || (st.st_mode & S_IFLNK)) + { if (findata->d_name[0] == '.') continue; } //skip hidden (dot) files + else continue; //skip devices and fifos and such + if (!wildmatch(findata->d_name,&wildst[wildstpathleng])) continue; + if (st.st_mode & S_IFDIR) strcat(&filnam[i],"/"); + } +#endif + return(1); + } + while (srchstat >= 0) + { + if (wildmatch(&kzhashbuf[srchstat+16],wildst)) + { + //strcpy(filnam,&kzhashbuf[srchstat+16]); + filnam[0] = '|'; strcpy(&filnam[1],&kzhashbuf[srchstat+16]); + srchstat = *(long *)&kzhashbuf[srchstat+4]; + return(1); + } + srchstat = *(long *)&kzhashbuf[srchstat+4]; + } + return(0); +} + +//File searching code (supports inside ZIP files!) How to use this code: +// char filnam[MAX_PATH]; +// kzfindfilestart("vxl/*.vxl"); +// while (kzfindfile(filnam)) puts(filnam); +//NOTES: +// * Directory names end with '\' or '/' (depending on system) +// * Files inside zip begin with '|' + +// -------------------------------------------------------------------------- + +static char *gzbufptr; +static void putbuf4zip (const unsigned char *buf, long uncomp0, long uncomp1) +{ + long i0, i1; + // uncomp0 ... uncomp1 + // &gzbufptr[kzfs.pos] ... &gzbufptr[kzfs.endpos]; + i0 = max(uncomp0,kzfs.pos); + i1 = min(uncomp1,kzfs.endpos); + if (i0 < i1) memcpy(&gzbufptr[i0],&buf[i0-uncomp0],i1-i0); +} + + //returns number of bytes copied +long kzread (void *buffer, long leng) +{ + long i, j, k, bfinal, btype, hlit, hdist; + + if ((!kzfs.fil) || (leng <= 0)) return(0); + + if (kzfs.comptyp == 0) + { + if (kzfs.pos != kzfs.i) //Seek only when position changes + fseek(kzfs.fil,kzfs.seek0+kzfs.pos,SEEK_SET); + i = min(kzfs.leng-kzfs.pos,leng); + fread(buffer,i,1,kzfs.fil); + kzfs.i += i; //kzfs.i is a local copy of ftell(kzfs.fil); + } + else if (kzfs.comptyp == 8) + { + zipfilmode = 1; + + //Initialize for putbuf4zip + gzbufptr = (char *)buffer; gzbufptr = &gzbufptr[-kzfs.pos]; + kzfs.endpos = min(kzfs.pos+leng,kzfs.leng); + if (kzfs.endpos == kzfs.pos) return(0); //Guard against reading 0 length + + if (kzfs.pos < gslidew-32768) // Must go back to start :( + { + if (kzfs.comptell) fseek(kzfs.fil,kzfs.seek0,SEEK_SET); + + gslidew = 0; gslider = 16384; + kzfs.jmpplc = 0; + + //Initialize for suckbits/peekbits/getbits + kzfs.comptell = min((unsigned)kzfs.compleng,sizeof(olinbuf)); + fread(&olinbuf[0],kzfs.comptell,1,kzfs.fil); + //Make it re-load when there are < 32 bits left in FIFO + bitpos = -(((long)sizeof(olinbuf)-4)<<3); + //Identity: filptr + (bitpos>>3) = &olinbuf[0] + filptr = &olinbuf[-(bitpos>>3)]; + } + else + { + i = max(gslidew-32768,0); j = gslider-16384; + + //HACK: Don't unzip anything until you have to... + // (keeps file pointer as low as possible) + if (kzfs.endpos <= gslidew) j = kzfs.endpos; + + //write uncompoffs on slidebuf from: i to j + if (!((i^j)&32768)) + putbuf4zip(&slidebuf[i&32767],i,j); + else + { + putbuf4zip(&slidebuf[i&32767],i,j&~32767); + putbuf4zip(slidebuf,j&~32767,j); + } + + //HACK: Don't unzip anything until you have to... + // (keeps file pointer as low as possible) + if (kzfs.endpos <= gslidew) goto retkzread; + } + + switch (kzfs.jmpplc) + { + case 0: goto kzreadplc0; + case 1: goto kzreadplc1; + case 2: goto kzreadplc2; + case 3: goto kzreadplc3; + } +kzreadplc0:; + do + { + bfinal = getbits(1); btype = getbits(2); + +#if 0 + //Display Huffman block offsets&lengths of input file - for debugging only! + { + static long ouncomppos = 0, ocomppos = 0; + if (kzfs.comptell == sizeof(olinbuf)) i = 0; + else if (kzfs.comptell < kzfs.compleng) i = kzfs.comptell-(sizeof(olinbuf)-4); + else i = kzfs.comptell-(kzfs.comptell%(sizeof(olinbuf)-4)); + i += ((long)&filptr[bitpos>>3])-((long)(&olinbuf[0])); + i = (i<<3)+(bitpos&7)-3; + if (gslidew) printf(" ULng:0x%08x CLng:0x%08x.%x",gslidew-ouncomppos,(i-ocomppos)>>3,((i-ocomppos)&7)<<1); + printf("\ntype:%d, Uoff:0x%08x Coff:0x%08x.%x",btype,gslidew,i>>3,(i&7)<<1); + if (bfinal) + { + printf(" ULng:0x%08x CLng:0x%08x.%x",kzfs.leng-gslidew,((kzfs.compleng<<3)-i)>>3,(((kzfs.compleng<<3)-i)&7)<<1); + printf("\n Uoff:0x%08x Coff:0x%08x.0",kzfs.leng,kzfs.compleng); + ouncomppos = ocomppos = 0; + } + else { ouncomppos = gslidew; ocomppos = i; } + } +#endif + + if (btype == 0) + { + //Raw (uncompressed) + suckbits((-bitpos)&7); //Synchronize to start of next byte + i = getbits(16); if ((getbits(16)^i) != 0xffff) return(-1); + for(;i;i--) + { + if (gslidew >= gslider) + { + putbuf4zip(&slidebuf[(gslider-16384)&32767],gslider-16384,gslider); gslider += 16384; + if (gslider-16384 >= kzfs.endpos) + { + kzfs.jmpplc = 1; kzfs.i = i; kzfs.bfinal = bfinal; + goto retkzread; +kzreadplc1:; i = kzfs.i; bfinal = kzfs.bfinal; + } + } + slidebuf[(gslidew++)&32767] = (char)getbits(8); + } + continue; + } + if (btype == 3) continue; + + if (btype == 1) //Fixed Huffman + { + hlit = 288; hdist = 32; i = 0; + for(;i<144;i++) clen[i] = 8; //Fixed bit sizes (literals) + for(;i<256;i++) clen[i] = 9; //Fixed bit sizes (literals) + for(;i<280;i++) clen[i] = 7; //Fixed bit sizes (EOI,lengths) + for(;i<288;i++) clen[i] = 8; //Fixed bit sizes (lengths) + for(;i<320;i++) clen[i] = 5; //Fixed bit sizes (distances) + } + else //Dynamic Huffman + { + hlit = getbits(5)+257; hdist = getbits(5)+1; j = getbits(4)+4; + for(i=0;i= gslider) + { + putbuf4zip(&slidebuf[(gslider-16384)&32767],gslider-16384,gslider); gslider += 16384; + if (gslider-16384 >= kzfs.endpos) + { + kzfs.jmpplc = 2; kzfs.bfinal = bfinal; goto retkzread; +kzreadplc2:; bfinal = kzfs.bfinal; + } + } + + k = peekbits(LOGQHUFSIZ0); + if (qhufbit0[k]) { i = qhufval0[k]; suckbits((long)qhufbit0[k]); } + else i = hufgetsym(ibuf0,nbuf0); + + if (i < 256) { slidebuf[(gslidew++)&32767] = (char)i; continue; } + if (i == 256) break; + i = getbits(hxbit[i+30-257][0]) + hxbit[i+30-257][1]; + + k = peekbits(LOGQHUFSIZ1); + if (qhufbit1[k]) { j = qhufval1[k]; suckbits((long)qhufbit1[k]); } + else j = hufgetsym(ibuf1,nbuf1); + + j = getbits(hxbit[j][0]) + hxbit[j][1]; + for(;i;i--,gslidew++) slidebuf[gslidew&32767] = slidebuf[(gslidew-j)&32767]; + } + } while (!bfinal); + + gslider -= 16384; + if (!((gslider^gslidew)&32768)) + putbuf4zip(&slidebuf[gslider&32767],gslider,gslidew); + else + { + putbuf4zip(&slidebuf[gslider&32767],gslider,gslidew&~32767); + putbuf4zip(slidebuf,gslidew&~32767,gslidew); + } +kzreadplc3:; kzfs.jmpplc = 3; + } + +retkzread:; + i = kzfs.pos; + kzfs.pos += leng; if (kzfs.pos > kzfs.leng) kzfs.pos = kzfs.leng; + return(kzfs.pos-i); +} + +long kzfilelength () +{ + if (!kzfs.fil) return(0); + return(kzfs.leng); +} + + //WARNING: kzseek(<-32768,SEEK_CUR); or: + // kzseek(0,SEEK_END); can make next kzread very slow!!! +long kzseek (long offset, long whence) +{ + if (!kzfs.fil) return(-1); + switch (whence) + { + case SEEK_CUR: kzfs.pos += offset; break; + case SEEK_END: kzfs.pos = kzfs.leng+offset; break; + case SEEK_SET: default: kzfs.pos = offset; + } + if (kzfs.pos < 0) kzfs.pos = 0; + if (kzfs.pos > kzfs.leng) kzfs.pos = kzfs.leng; + return(kzfs.pos); +} + +long kztell () +{ + if (!kzfs.fil) return(-1); + return(kzfs.pos); +} + +long kzgetc () +{ + char ch; + if (!kzread(&ch,1)) return(-1); + return((long)ch); +} + +long kzeof () +{ + if (!kzfs.fil) return(-1); + return(kzfs.pos >= kzfs.leng); +} + +void kzclose () +{ + if (kzfs.fil) { fclose(kzfs.fil); kzfs.fil = 0; } +} + +//====================== ZIP decompression code ends ========================= +//===================== HANDY PICTURE function begins ======================== + +void kpzload (const char *filnam, long *pic, long *bpl, long *xsiz, long *ysiz) +{ + char *buf; + long leng; + + (*pic) = 0; + if (!kzopen(filnam)) return; + leng = kzfilelength(); + buf = (char *)malloc(leng); if (!buf) return; + kzread(buf,leng); + kzclose(); + + kpgetdim(buf,leng,xsiz,ysiz); + (*bpl) = ((*xsiz)<<2); + (*pic) = (long)malloc((*ysiz)*(*bpl)); if (!(*pic)) { free(buf); return; } + if (kprender(buf,leng,*pic,*bpl,*xsiz,*ysiz,0,0) < 0) { free(buf); free((void *)*pic); (*pic) = 0; return; } + free(buf); +} +//====================== HANDY PICTURE function ends ========================= diff --git a/polymer/build/src/lzfP.h b/polymer/build/src/lzfP.h new file mode 100644 index 000000000..48963b2bc --- /dev/null +++ b/polymer/build/src/lzfP.h @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2000-2005 Marc Alexander Lehmann + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- + * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- + * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Alternatively, the contents of this file may be used under the terms of + * the GNU General Public License version 2 (the "GPL"), in which case the + * provisions of the GPL are applicable instead of the above. If you wish to + * allow the use of your version of this file only under the terms of the + * GPL and not to allow others to use your version of this file under the + * BSD license, indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by the GPL. If + * you do not delete the provisions above, a recipient may use your version + * of this file under either the BSD or the GPL. + */ + +#ifndef LZFP_h +#define LZFP_h + +#define STANDALONE 1 /* at the moment, this is ok. */ + +#ifndef STANDALONE +# include "lzf.h" +#endif + +/* + * size of hashtable is (1 << HLOG) * sizeof (char *) + * decompression is independent of the hash table size + * the difference between 15 and 14 is very small + * for small blocks (and 14 is usually a but faster). + * For a low-memory/faster configuration, use HLOG == 13; + * For best compression, use 15 or 16 (or more). + */ +#ifndef HLOG +# define HLOG 14 +#endif + +/* + * sacrifice very little compression quality in favour of compression speed. + * This gives almost the same compression as the default code, and is + * (very roughly) 15% faster. This is the preferable mode of operation. + */ + +#ifndef VERY_FAST +# define VERY_FAST 1 +#endif + +/* + * sacrifice some more compression quality in favour of compression speed. + * (roughly 1-2% worse compression for large blocks and + * 9-10% for small, redundant, blocks and >>20% better speed in both cases) + * In short: when in need for speed, enable this for binary data, + * possibly disable this for text data. + */ +#ifndef ULTRA_FAST +# define ULTRA_FAST 0 +#endif + +/* + * unconditionally aligning does not cost very much, so do it if unsure + */ +#ifndef STRICT_ALIGN +# define STRICT_ALIGN !(defined(__i386) || defined (__amd64)) +#endif + +/* + * use string functions to copy memory. + * this is usually a loss, even with glibc's optimized memcpy + */ +#ifndef USE_MEMCPY +# define USE_MEMCPY 0 +#endif + +/* + * you may choose to pre-set the hash table (might be faster on some + * modern cpus and large (>>64k) blocks) + */ +#ifndef INIT_HTAB +# define INIT_HTAB 0 +#endif + +/* + * avoid assigning values to errno variable? for some embedding purposes + * (linux kernel for example), this is neccessary. NOTE: this breaks + * the documentation in lzf.h. + */ +#ifndef AVOID_ERRNO +# define AVOID_ERRNO 0 +#endif + +/* + * Wether to pass the LZF_STATE variable as argument, or allocate it + * on the stack. For small-stack environments, define this to 1. + * NOTE: this breaks the prototype in lzf.h. + */ +#ifndef LZF_STATE_ARG +# define LZF_STATE_ARG 0 +#endif + +/*****************************************************************************/ +/* nothing should be changed below */ + +typedef unsigned char u8; + +typedef const u8 *LZF_STATE[1 << (HLOG)]; + +#if !STRICT_ALIGN +/* for unaligned accesses we need a 16 bit datatype. */ +# include +# if USHRT_MAX == 65535 + typedef unsigned short u16; +# elif UINT_MAX == 65535 + typedef unsigned int u16; +# else +# undef STRICT_ALIGN +# define STRICT_ALIGN 1 +# endif +#endif + +#if ULTRA_FAST +# if defined(VERY_FAST) +# undef VERY_FAST +# endif +#endif + +#if USE_MEMCPY || INIT_HTAB +# ifdef __cplusplus +# include +# else +# include +# endif +#endif + +#endif + diff --git a/polymer/build/src/lzf_c.c b/polymer/build/src/lzf_c.c new file mode 100644 index 000000000..b9b9ef991 --- /dev/null +++ b/polymer/build/src/lzf_c.c @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2000-2005 Marc Alexander Lehmann + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- + * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- + * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Alternatively, the contents of this file may be used under the terms of + * the GNU General Public License version 2 (the "GPL"), in which case the + * provisions of the GPL are applicable instead of the above. If you wish to + * allow the use of your version of this file only under the terms of the + * GPL and not to allow others to use your version of this file under the + * BSD license, indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by the GPL. If + * you do not delete the provisions above, a recipient may use your version + * of this file under either the BSD or the GPL. + */ + +#include "lzfP.h" + +#define HSIZE (1 << (HLOG)) + +/* + * don't play with this unless you benchmark! + * decompression is not dependent on the hash function + * the hashing function might seem strange, just believe me + * it works ;) + */ +#ifndef FRST +# define FRST(p) (((p[0]) << 8) | p[1]) +# define NEXT(v,p) (((v) << 8) | p[2]) +# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) +#endif +/* + * IDX works because it is very similar to a multiplicative hash, e.g. + * ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1)) + * the latter is also quite fast on newer CPUs, and sligthly better + * + * the next one is also quite good, albeit slow ;) + * (int)(cos(h & 0xffffff) * 1e6) + */ + +#if 0 +/* original lzv-like hash function, much worse and thus slower */ +# define FRST(p) (p[0] << 5) ^ p[1] +# define NEXT(v,p) ((v) << 5) ^ p[2] +# define IDX(h) ((h) & (HSIZE - 1)) +#endif + +#define MAX_LIT (1 << 5) +#define MAX_OFF (1 << 13) +#define MAX_REF ((1 << 8) + (1 << 3)) + +/* + * compressed format + * + * 000LLLLL ; literal + * LLLooooo oooooooo ; backref L + * 111ooooo LLLLLLLL oooooooo ; backref L+7 + * + */ + +unsigned int +lzf_compress (const void *const in_data, unsigned int in_len, + void *out_data, unsigned int out_len +#if LZF_STATE_ARG + , LZF_STATE *htab +#endif + ) +{ +#if !LZF_STATE_ARG + LZF_STATE htab; +#endif + const u8 **hslot; + const u8 *ip = (const u8 *)in_data; + u8 *op = (u8 *)out_data; + const u8 *in_end = ip + in_len; + u8 *out_end = op + out_len; + const u8 *ref; + + unsigned int hval = FRST (ip); + unsigned long off; + int lit = 0; + +#if INIT_HTAB +# if USE_MEMCPY + memset (htab, 0, sizeof (htab)); +# else + for (hslot = htab; hslot < htab + HSIZE; hslot++) + *hslot++ = ip; +# endif +#endif + + for (;;) + { + if (ip < in_end - 2) + { + hval = NEXT (hval, ip); + hslot = htab + IDX (hval); + ref = *hslot; *hslot = ip; + + if (1 +#if INIT_HTAB && !USE_MEMCPY + && ref < ip /* the next test will actually take care of this, but this is faster */ +#endif + && (off = ip - ref - 1) < MAX_OFF + && ip + 4 < in_end + && ref > (u8 *)in_data +#if STRICT_ALIGN + && ref[0] == ip[0] + && ref[1] == ip[1] + && ref[2] == ip[2] +#else + && *(u16 *)ref == *(u16 *)ip + && ref[2] == ip[2] +#endif + ) + { + /* match found at *ref++ */ + unsigned int len = 2; + unsigned int maxlen = in_end - ip - len; + maxlen = maxlen > MAX_REF ? MAX_REF : maxlen; + + if (op + lit + 1 + 3 >= out_end) + return 0; + + do + len++; + while (len < maxlen && ref[len] == ip[len]); + + if (lit) + { + *op++ = lit - 1; + lit = -lit; + do + *op++ = ip[lit]; + while (++lit); + } + + len -= 2; + ip++; + + if (len < 7) + { + *op++ = (off >> 8) + (len << 5); + } + else + { + *op++ = (off >> 8) + ( 7 << 5); + *op++ = len - 7; + } + + *op++ = off; + +#if ULTRA_FAST || VERY_FAST + ip += len; +#if VERY_FAST && !ULTRA_FAST + --ip; +#endif + hval = FRST (ip); + + hval = NEXT (hval, ip); + htab[IDX (hval)] = ip; + ip++; + +#if VERY_FAST && !ULTRA_FAST + hval = NEXT (hval, ip); + htab[IDX (hval)] = ip; + ip++; +#endif +#else + do + { + hval = NEXT (hval, ip); + htab[IDX (hval)] = ip; + ip++; + } + while (len--); +#endif + continue; + } + } + else if (ip == in_end) + break; + + /* one more literal byte we must copy */ + lit++; + ip++; + + if (lit == MAX_LIT) + { + if (op + 1 + MAX_LIT >= out_end) + return 0; + + *op++ = MAX_LIT - 1; +#if USE_MEMCPY + memcpy (op, ip - MAX_LIT, MAX_LIT); + op += MAX_LIT; + lit = 0; +#else + lit = -lit; + do + *op++ = ip[lit]; + while (++lit); +#endif + } + } + + if (lit) + { + if (op + lit + 1 >= out_end) + return 0; + + *op++ = lit - 1; + lit = -lit; + do + *op++ = ip[lit]; + while (++lit); + } + + return op - (u8 *) out_data; +} diff --git a/polymer/build/src/lzf_d.c b/polymer/build/src/lzf_d.c new file mode 100644 index 000000000..d0229d7dc --- /dev/null +++ b/polymer/build/src/lzf_d.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2000-2005 Marc Alexander Lehmann + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- + * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- + * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- + * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Alternatively, the contents of this file may be used under the terms of + * the GNU General Public License version 2 (the "GPL"), in which case the + * provisions of the GPL are applicable instead of the above. If you wish to + * allow the use of your version of this file only under the terms of the + * GPL and not to allow others to use your version of this file under the + * BSD license, indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by the GPL. If + * you do not delete the provisions above, a recipient may use your version + * of this file under either the BSD or the GPL. + */ + +#include "lzfP.h" + +#if AVOID_ERRNO +# define SET_ERRNO(n) +#else +# include +# define SET_ERRNO(n) errno = (n) +#endif + +unsigned int +lzf_decompress (const void *const in_data, unsigned int in_len, + void *out_data, unsigned int out_len) +{ + u8 const *ip = (const u8 *)in_data; + u8 *op = (u8 *)out_data; + u8 const *const in_end = ip + in_len; + u8 *const out_end = op + out_len; + + do + { + unsigned int ctrl = *ip++; + + if (ctrl < (1 << 5)) /* literal run */ + { + ctrl++; + + if (op + ctrl > out_end) + { + SET_ERRNO (E2BIG); + return 0; + } + +#if USE_MEMCPY + memcpy (op, ip, ctrl); + op += ctrl; + ip += ctrl; +#else + do + *op++ = *ip++; + while (--ctrl); +#endif + } + else /* back reference */ + { + unsigned int len = ctrl >> 5; + + u8 *ref = op - ((ctrl & 0x1f) << 8) - 1; + + if (len == 7) + len += *ip++; + + ref -= *ip++; + + if (op + len + 2 > out_end) + { + SET_ERRNO (E2BIG); + return 0; + } + + if (ref < (u8 *)out_data) + { + SET_ERRNO (EINVAL); + return 0; + } + + *op++ = *ref++; + *op++ = *ref++; + + do + *op++ = *ref++; + while (--len); + } + } + while (op < out_end && ip < in_end); + + return op - (u8 *)out_data; +} + diff --git a/polymer/build/src/lzwnew.c b/polymer/build/src/lzwnew.c new file mode 100644 index 000000000..dad07a960 --- /dev/null +++ b/polymer/build/src/lzwnew.c @@ -0,0 +1,116 @@ +//-------------------------------------------------------------------------------------------------- +#if defined(__POWERPC__) +static unsigned long LSWAPIB (unsigned long a) { return(((a>>8)&0xff00)+((a&0xff00)<<8)+(a<<24)+(a>>24)); } +static unsigned short SSWAPIB (unsigned short a) { return((a>>8)+(a<<8)); } +#else +#define LSWAPIB(a) (a) +#define SSWAPIB(a) (a) +#endif + +#define USENEW 1 +long lzwcompress (unsigned char *ucompbuf, long ucompleng, unsigned char *compbuf) +{ + long i, j, numnodes, *lptr, bitcnt, nbits, oneupnbits, hmask, *child; + long *sibly; +#if USENEW + long *sibry; +#endif + unsigned char *nodev, *cptr, *eptr; + + nodev = (unsigned char *)malloc((ucompleng+256)*sizeof(char)); if (!nodev) return(0); + child = (long *)malloc((ucompleng+256)*sizeof(long)); if (!child) { free(nodev); return(0); } + sibly = (long *)malloc((ucompleng+256)*sizeof(long)); if (!sibly) { free(child); free(nodev); return(0); } +#if USENEW + sibry = (long *)malloc((ucompleng+256)*sizeof(long)); if (!sibry) { free(sibly); free(child); free(nodev); return(0); } +#endif + + for(i=255;i>=0;i--) { nodev[i] = i; child[i] = -1; } + memset(compbuf,0,ucompleng+15); + + cptr = ucompbuf; eptr = &ucompbuf[ucompleng]; + + numnodes = 256; bitcnt = (4<<3); nbits = 8; oneupnbits = (1<<8); hmask = ((oneupnbits>>1)-1); + do + { + for(i=cptr[0];i>=0;i=j) + { + cptr++; if (cptr >= eptr) goto lzwcompbreak2b; + j = child[i]; if (j < 0) { child[i] = numnodes; break; } +#if USENEW + //This is about 2x faster when ucompbuf is more random, 5% slower when very compressible + while (cptr[0] != nodev[j]) + { + if (cptr[0] < nodev[j]) + { if (sibly[j] < 0) { sibly[j] = numnodes; goto lzwcompbreak2a; } j = sibly[j]; } + else { if (sibry[j] < 0) { sibry[j] = numnodes; goto lzwcompbreak2a; } j = sibry[j]; } + } +#else + for(;nodev[j]!=cptr[0];j=sibly[j]) + if (sibly[j] < 0) { sibly[j] = numnodes; goto lzwcompbreak2a; } +#endif + } +lzwcompbreak2a: nodev[numnodes] = cptr[0]; +lzwcompbreak2b: child[numnodes] = sibly[numnodes] = -1; +#if USENEW + sibry[numnodes] = -1; +#endif + + lptr = (long *)&compbuf[bitcnt>>3]; lptr[0] |= LSWAPIB(i<<(bitcnt&7)); + bitcnt += nbits; if ((i&hmask) > ((numnodes-1)&hmask)) bitcnt--; + + numnodes++; if (numnodes > oneupnbits) { nbits++; oneupnbits <<= 1; hmask = ((oneupnbits>>1)-1); } + } while ((cptr < eptr) && (bitcnt < (ucompleng<<3))); + +#if USENEW + free(sibry); +#endif + free(sibly); + free(child); free(nodev); + + lptr = (long *)compbuf; + if (((bitcnt+7)>>3) < ucompleng) { lptr[0] = LSWAPIB(numnodes); return((bitcnt+7)>>3); } + memcpy(compbuf,ucompbuf,ucompleng); return(ucompleng); +} + +long lzwuncompress (unsigned char *compbuf, long compleng, unsigned char *ucompbuf, long ucompleng) +{ + long i, dat, leng, bitcnt, *lptr, numnodes, totnodes, nbits, oneupnbits, hmask, *prefix; + unsigned char ch, *ucptr, *suffix; + long ucomp = (long)ucompbuf; + + if (compleng >= ucompleng) { memcpy(ucompbuf,compbuf,ucompleng); return ucompleng; } + + totnodes = LSWAPIB(((long *)compbuf)[0]); if (totnodes <= 0 || totnodes >= ucompleng+256) return 0; + + prefix = (long *)malloc(totnodes*sizeof(long)); if (!prefix) return 0; + suffix = (unsigned char *)malloc(totnodes*sizeof(char)); if (!suffix) { free(prefix); return 0; } + + numnodes = 256; bitcnt = (4<<3); nbits = 8; oneupnbits = (1<<8); hmask = ((oneupnbits>>1)-1); + do + { + lptr = (long *)&compbuf[bitcnt>>3]; dat = ((LSWAPIB(lptr[0])>>(bitcnt&7))&(oneupnbits-1)); + bitcnt += nbits; if ((dat&hmask) > ((numnodes-1)&hmask)) { dat &= hmask; bitcnt--; } + + prefix[numnodes] = dat; + + ucompbuf++; + for(leng=0;dat>=256;dat=prefix[dat]) { + if ((long)ucompbuf+leng-ucomp > ucompleng) goto bail; + ucompbuf[leng++] = suffix[dat]; + } + + ucptr = &ucompbuf[leng-1]; + for(i=(leng>>1)-1;i>=0;i--) { ch = ucompbuf[i]; ucompbuf[i] = ucptr[-i]; ucptr[-i] = ch; } + ucompbuf[-1] = dat; ucompbuf += leng; + + suffix[numnodes-1] = suffix[numnodes] = dat; + + numnodes++; if (numnodes > oneupnbits) { nbits++; oneupnbits <<= 1; hmask = ((oneupnbits>>1)-1); } + } while (numnodes < totnodes); + +bail: + free(suffix); free(prefix); + + return (long)ucompbuf-ucomp; +} +//-------------------------------------------------------------------------------------------------- diff --git a/polymer/build/src/md4.c b/polymer/build/src/md4.c new file mode 100644 index 000000000..7de5776a0 --- /dev/null +++ b/polymer/build/src/md4.c @@ -0,0 +1,272 @@ +/* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm + Modified from original version published in RFC1320 by + Jonathon Fowler (jonof@edgenetwork.org) + */ + +/* Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD4 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD4 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +typedef unsigned char * POINTER; +typedef unsigned short UINT2; +typedef unsigned long UINT4; + +#include "md4.h" +#include "compat.h" + +/* Constants for MD4Transform routine. + */ +#define S11 3 +#define S12 7 +#define S13 11 +#define S14 19 +#define S21 3 +#define S22 5 +#define S23 9 +#define S24 13 +#define S31 3 +#define S32 9 +#define S33 11 +#define S34 15 + +static void MD4Transform (UINT4 [4], unsigned char [64]); +static void Encode (unsigned char *, UINT4 *, unsigned int); +static void Decode (UINT4 *, unsigned char *, unsigned int); +#define MD4_memcpy memcpy +#define MD4_memset memset + +static unsigned char PADDING[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* F, G and H are basic MD4 functions. + */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) + +/* ROTATE_LEFT rotates x left n bits. + */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG and HH are transformations for rounds 1, 2 and 3 */ +/* Rotation is separate from addition to prevent recomputation */ +#define FF(a, b, c, d, x, s) { \ + (a) += F ((b), (c), (d)) + (x); \ + (a) = ROTATE_LEFT ((a), (s)); \ + } +#define GG(a, b, c, d, x, s) { \ + (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \ + (a) = ROTATE_LEFT ((a), (s)); \ + } +#define HH(a, b, c, d, x, s) { \ + (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \ + (a) = ROTATE_LEFT ((a), (s)); \ + } + +void md4once(unsigned char *block, unsigned int len, unsigned char digest[16]) +{ + MD4_CTX ctx; + + md4init(&ctx); + md4block(&ctx, block, len); + md4finish(digest, &ctx); +} + +/* MD4 initialization. Begins an MD4 operation, writing a new context. + */ +void md4init (MD4_CTX *context) +{ + context->count[0] = context->count[1] = 0; + + /* Load magic initialization constants. + */ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->state[3] = 0x10325476; +} + +/* MD4 block update operation. Continues an MD4 message-digest + operation, processing another message block, and updating the + context. + */ +void md4block (MD4_CTX *context, unsigned char *input, unsigned int inputLen) +{ + unsigned int i, index, partLen; + + /* Compute number of bytes mod 64 */ + index = (unsigned int)((context->count[0] >> 3) & 0x3F); + /* Update number of bits */ + if ((context->count[0] += ((UINT4)inputLen << 3)) + < ((UINT4)inputLen << 3)) + context->count[1]++; + context->count[1] += ((UINT4)inputLen >> 29); + + partLen = 64 - index; + + /* Transform as many times as possible. + */ + if (inputLen >= partLen) { + MD4_memcpy + ((POINTER)&context->buffer[index], (POINTER)input, partLen); + MD4Transform (context->state, context->buffer); + + for (i = partLen; i + 63 < inputLen; i += 64) + MD4Transform (context->state, &input[i]); + + index = 0; + } + else + i = 0; + + /* Buffer remaining input */ + MD4_memcpy + ((POINTER)&context->buffer[index], (POINTER)&input[i], + inputLen-i); +} + +/* MD4 finalization. Ends an MD4 message-digest operation, writing the + the message digest and zeroizing the context. + */ +void md4finish (unsigned char digest[16], MD4_CTX *context) +{ + unsigned char bits[8]; + unsigned int index, padLen; + + /* Save number of bits */ + Encode (bits, context->count, 8); + + /* Pad out to 56 mod 64. + */ + index = (unsigned int)((context->count[0] >> 3) & 0x3f); + padLen = (index < 56) ? (56 - index) : (120 - index); + md4block (context, PADDING, padLen); + + /* Append length (before padding) */ + md4block (context, bits, 8); + /* Store state in digest */ + Encode (digest, context->state, 16); + + /* Zeroize sensitive information. + */ + MD4_memset ((POINTER)context, 0, sizeof (*context)); +} + +/* MD4 basic transformation. Transforms state based on block. + */ +static void MD4Transform (UINT4 state[4], unsigned char block[64]) +{ + UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + + Decode (x, block, 64); + + /* Round 1 */ + FF (a, b, c, d, x[ 0], S11); /* 1 */ + FF (d, a, b, c, x[ 1], S12); /* 2 */ + FF (c, d, a, b, x[ 2], S13); /* 3 */ + FF (b, c, d, a, x[ 3], S14); /* 4 */ + FF (a, b, c, d, x[ 4], S11); /* 5 */ + FF (d, a, b, c, x[ 5], S12); /* 6 */ + FF (c, d, a, b, x[ 6], S13); /* 7 */ + FF (b, c, d, a, x[ 7], S14); /* 8 */ + FF (a, b, c, d, x[ 8], S11); /* 9 */ + FF (d, a, b, c, x[ 9], S12); /* 10 */ + FF (c, d, a, b, x[10], S13); /* 11 */ + FF (b, c, d, a, x[11], S14); /* 12 */ + FF (a, b, c, d, x[12], S11); /* 13 */ + FF (d, a, b, c, x[13], S12); /* 14 */ + FF (c, d, a, b, x[14], S13); /* 15 */ + FF (b, c, d, a, x[15], S14); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, x[ 0], S21); /* 17 */ + GG (d, a, b, c, x[ 4], S22); /* 18 */ + GG (c, d, a, b, x[ 8], S23); /* 19 */ + GG (b, c, d, a, x[12], S24); /* 20 */ + GG (a, b, c, d, x[ 1], S21); /* 21 */ + GG (d, a, b, c, x[ 5], S22); /* 22 */ + GG (c, d, a, b, x[ 9], S23); /* 23 */ + GG (b, c, d, a, x[13], S24); /* 24 */ + GG (a, b, c, d, x[ 2], S21); /* 25 */ + GG (d, a, b, c, x[ 6], S22); /* 26 */ + GG (c, d, a, b, x[10], S23); /* 27 */ + GG (b, c, d, a, x[14], S24); /* 28 */ + GG (a, b, c, d, x[ 3], S21); /* 29 */ + GG (d, a, b, c, x[ 7], S22); /* 30 */ + GG (c, d, a, b, x[11], S23); /* 31 */ + GG (b, c, d, a, x[15], S24); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, x[ 0], S31); /* 33 */ + HH (d, a, b, c, x[ 8], S32); /* 34 */ + HH (c, d, a, b, x[ 4], S33); /* 35 */ + HH (b, c, d, a, x[12], S34); /* 36 */ + HH (a, b, c, d, x[ 2], S31); /* 37 */ + HH (d, a, b, c, x[10], S32); /* 38 */ + HH (c, d, a, b, x[ 6], S33); /* 39 */ + HH (b, c, d, a, x[14], S34); /* 40 */ + HH (a, b, c, d, x[ 1], S31); /* 41 */ + HH (d, a, b, c, x[ 9], S32); /* 42 */ + HH (c, d, a, b, x[ 5], S33); /* 43 */ + HH (b, c, d, a, x[13], S34); /* 44 */ + HH (a, b, c, d, x[ 3], S31); /* 45 */ + HH (d, a, b, c, x[11], S32); /* 46 */ + HH (c, d, a, b, x[ 7], S33); /* 47 */ + HH (b, c, d, a, x[15], S34); /* 48 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + /* Zeroize sensitive information. + */ + MD4_memset ((POINTER)x, 0, sizeof (x)); +} + +/* Encodes input (UINT4) into output (unsigned char). Assumes len is + a multiple of 4. + */ +static void Encode (unsigned char *output, UINT4 *input, unsigned int len) +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) { + output[j] = (unsigned char)(input[i] & 0xff); + output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); + output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); + output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); + } +} + +/* Decodes input (unsigned char) into output (UINT4). Assumes len is + a multiple of 4. + */ +static void Decode (UINT4 *output, unsigned char *input, unsigned int len) +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | + (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); +} diff --git a/polymer/build/src/mdsprite.c b/polymer/build/src/mdsprite.c new file mode 100644 index 000000000..83c19b5a9 --- /dev/null +++ b/polymer/build/src/mdsprite.c @@ -0,0 +1,2561 @@ +//------------------------------------- MD2/MD3 LIBRARY BEGINS ------------------------------------- + +#ifdef __POWERPC__ +#define SHIFTMOD32(a) ((a)&31) +#else +#define SHIFTMOD32(a) (a) +#endif + +typedef struct +{ + long mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! + long shadeoff; + float scale, bscale, zadd; + GLuint *texid; // skins +} mdmodel; + +typedef struct _mdanim_t +{ + int startframe, endframe; + int fpssc, flags; + struct _mdanim_t *next; +} mdanim_t; +#define MDANIM_LOOP 0 +#define MDANIM_ONESHOT 1 + +typedef struct _mdskinmap_t +{ + unsigned char palette, filler[3]; // Build palette number + int skinnum, surfnum; // Skin identifier, surface number + char *fn; // Skin filename + GLuint texid[HICEFFECTMASK+1]; // OpenGL texture numbers for effect variations + struct _mdskinmap_t *next; +} mdskinmap_t; + + + //This MD2 code is based on the source code from David Henry (tfc_duke(at)hotmail.com) + // Was at http://tfc.duke.free.fr/us/tutorials/models/md2.htm + // Available from http://web.archive.org/web/20030816010242/http://tfc.duke.free.fr/us/tutorials/models/md2.htm + // Now at http://tfc.duke.free.fr/coding/md2.html (in French) + //He probably wouldn't recognize it if he looked at it though :) +typedef struct { float x, y, z; } point3d; + +typedef struct +{ + long id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8 + long numskins, numverts, numuv, numtris, numglcmds, numframes; + long ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each) +} md2head_t; + +typedef struct { unsigned char v[3], ni; } md2vert_t; //compressed vertex coords (x,y,z) +typedef struct +{ + point3d mul, add; //scale&translation vector + char name[16]; //frame name + md2vert_t verts[1]; //first vertex of this frame +} md2frame_t; + +typedef struct +{ + //WARNING: This top block is a union between md2model&md3model: Make sure it matches! + long mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! + long shadeoff; + float scale, bscale, zadd; + GLuint *texid; // texture ids for base skin if no mappings defined + + long numframes, cframe, nframe, fpssc, usesalpha; + float oldtime, curtime, interpol; + mdanim_t *animations; + mdskinmap_t *skinmap; + long numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified, + + //MD2 specific stuff: + long numverts, numglcmds, framebytes, *glcmds; + char *frames; + char *basepath; // pointer to string of base path + char *skinfn; // pointer to first of numskins 64-char strings +} md2model; + + +typedef struct { char nam[64]; long i; } md3shader_t; //ascz path of shader, shader index +typedef struct { long i[3]; } md3tri_t; //indices of tri +typedef struct { float u, v; } md3uv_t; +typedef struct { signed short x, y, z; unsigned char nlat, nlng; } md3xyzn_t; //xyz are [10:6] ints + +typedef struct +{ + point3d min, max, cen; //bounding box&origin + float r; //radius of bounding sphere + char nam[16]; //ascz frame name +} md3frame_t; + +typedef struct +{ + char nam[64]; //ascz tag name + point3d p, x, y, z; //tag object pos&orient +} md3tag_t; + +typedef struct +{ + long id; //IDP3(0x33806873) + char nam[64]; //ascz surface name + long flags; //? + long numframes, numshaders, numverts, numtris; //numframes same as md3head,max shade=~256,vert=~4096,tri=~8192 + md3tri_t *tris; //file format: rel offs from md3surf + md3shader_t *shaders; //file format: rel offs from md3surf + md3uv_t *uv; //file format: rel offs from md3surf + md3xyzn_t *xyzn; //file format: rel offs from md3surf + long ofsend; +} md3surf_t; + +typedef struct +{ + long id, vers; //id=IDP3(0x33806873), vers=15 + char nam[64]; //ascz path in PK3 + long flags; //? + long numframes, numtags, numsurfs, numskins; //max=~1024,~16,~32,numskins=artifact of MD2; use shader field instead + md3frame_t *frames; //file format: abs offs + md3tag_t *tags; //file format: abs offs + md3surf_t *surfs; //file format: abs offs + long eof; //file format: abs offs +} md3head_t; + +typedef struct +{ + //WARNING: This top block is a union between md2model&md3model: Make sure it matches! + long mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! + long shadeoff; + float scale, bscale, zadd; + unsigned int *texid; // texture ids for base skin if no mappings defined + + long numframes, cframe, nframe, fpssc, usesalpha; + float oldtime, curtime, interpol; + mdanim_t *animations; + mdskinmap_t *skinmap; + long numskins, skinloaded; // set to 1+numofskin when a skin is loaded and the tex coords are modified, + + //MD3 specific + md3head_t head; +} md3model; + +#define VOXBORDWIDTH 1 //use 0 to save memory, but has texture artifacts; 1 looks better... +#define VOXUSECHAR 0 +#if (VOXUSECHAR != 0) +typedef struct { unsigned char x, y, z, u, v; } vert_t; +#else +typedef struct { unsigned short x, y, z, u, v; } vert_t; +#endif +typedef struct { vert_t v[4]; } voxrect_t; +typedef struct +{ + //WARNING: This top block is a union of md2model,md3model,voxmodel: Make sure it matches! + long mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure! + long shadeoff; + float scale, bscale, zadd; + unsigned int *texid; // skins for palettes + + //VOX specific stuff: + voxrect_t *quad; long qcnt, qfacind[7]; + long *mytex, mytexx, mytexy; + long xsiz, ysiz, zsiz; + float xpiv, ypiv, zpiv; + long is8bit; +} voxmodel; +static voxmodel *voxmodels[MAXVOXELS]; + +typedef struct +{ // maps build tiles to particular animation frames of a model + int modelid; + int skinnum; + int framenum; // calculate the number from the name when declaring +} tile2model_t; +static tile2model_t tile2model[MAXTILES]; + + //Move this to appropriate place! +typedef struct { float xadd, yadd, zadd; short angadd, flags; } hudtyp; +hudtyp hudmem[2][MAXTILES]; //~320KB ... ok for now ... could replace with dynamic alloc + +static char mdinited=0; + +#define MODELALLOCGROUP 256 +static long nummodelsalloced = 0, nextmodelid = 0; +static mdmodel **models = NULL; + +static long maxmodelverts = 0, allocmodelverts = 0; +static point3d *vertlist = NULL; //temp array to store interpolated vertices for drawing + +mdmodel *mdload (const char *); +int mddraw (spritetype *); +void mdfree (mdmodel *); + +static void freeallmodels () +{ + int i; + + if (models) + { + for(i=0;imdnum == 1) { + voxmodel *v = (voxmodel*)m; + for(j=0;jtexid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); + v->texid[j] = 0; + } + } else if (m->mdnum == 2 || m->mdnum == 3) { + md2model *m2 = (md2model*)m; + mdskinmap_t *sk; + for(j=0;jnumskins*(HICEFFECTMASK+1);j++) + { + if (m2->texid[j]) bglDeleteTextures(1,(GLuint*)&m2->texid[j]); + m2->texid[j] = 0; + } + + for(sk=m2->skinmap;sk;sk=sk->next) + for(j=0;j<(HICEFFECTMASK+1);j++) + { + if (sk->texid[j]) bglDeleteTextures(1,(GLuint*)&sk->texid[j]); + sk->texid[j] = 0; + } + } + } + + for(i=0;itexid[j]) bglDeleteTextures(1,(GLuint*)&v->texid[j]); + v->texid[j] = 0; + } + } +} + +static void mdinit () +{ + memset(hudmem,0,sizeof(hudmem)); + freeallmodels(); + mdinited = 1; +} + +int md_loadmodel (const char *fn) +{ + mdmodel *vm, **ml; + + if (!mdinited) mdinit(); + + if (nextmodelid >= nummodelsalloced) + { + ml = (mdmodel **)realloc(models,(nummodelsalloced+MODELALLOCGROUP)*4); if (!ml) return(-1); + models = ml; nummodelsalloced += MODELALLOCGROUP; + } + + vm = mdload(fn); if (!vm) return(-1); + models[nextmodelid++] = vm; + return(nextmodelid-1); +} + +int md_setmisc (int modelid, float scale, int shadeoff, float zadd) +{ + mdmodel *m; + + if (!mdinited) mdinit(); + + if ((unsigned long)modelid >= (unsigned long)nextmodelid) return -1; + m = models[modelid]; + m->bscale = scale; + m->shadeoff = shadeoff; + m->zadd = zadd; + + return 0; +} + +int md_tilehasmodel (int tilenume) +{ + if (!mdinited) return -1; + return tile2model[tilenume].modelid; +} + +static long framename2index (mdmodel *vm, const char *nam) +{ + int i = 0; + + switch(vm->mdnum) + { + case 2: + { + md2model *m = (md2model *)vm; + md2frame_t *fr; + for(i=0;inumframes;i++) + { + fr = (md2frame_t *)&m->frames[i*m->framebytes]; + if (!Bstrcmp(fr->name, nam)) break; + } + } + break; + case 3: + { + md3model *m = (md3model *)vm; + for(i=0;inumframes;i++) + if (!Bstrcmp(m->head.frames[i].nam,nam)) break; + } + break; + } + return(i); +} + +int md_defineframe (int modelid, const char *framename, int tilenume, int skinnum) +{ + void *vm; + md2model *m; + int i; + + if (!mdinited) mdinit(); + + if ((unsigned long)modelid >= (unsigned long)nextmodelid) return(-1); + if ((unsigned long)tilenume >= (unsigned long)MAXTILES) return(-2); + if (!framename) return(-3); + + m = (md2model *)models[modelid]; + if (m->mdnum == 1) { + tile2model[tilenume].modelid = modelid; + tile2model[tilenume].framenum = tile2model[tilenume].skinnum = 0; + return 0; + } + + i = framename2index((mdmodel*)m,framename); + if (i == m->numframes) return(-3); // frame name invalid + + tile2model[tilenume].modelid = modelid; + tile2model[tilenume].framenum = i; + tile2model[tilenume].skinnum = skinnum; + + return 0; +} + +int md_defineanimation (int modelid, const char *framestart, const char *frameend, int fpssc, int flags) +{ + md2model *m; + mdanim_t ma, *map; + int i; + + if (!mdinited) mdinit(); + + if ((unsigned long)modelid >= (unsigned long)nextmodelid) return(-1); + + memset(&ma, 0, sizeof(ma)); + m = (md2model *)models[modelid]; + if (m->mdnum < 2) return 0; + + //find index of start frame + i = framename2index((mdmodel*)m,framestart); + if (i == m->numframes) return -2; + ma.startframe = i; + + //find index of finish frame which must trail start frame + i = framename2index((mdmodel*)m,frameend); + if (i == m->numframes) return -3; + ma.endframe = i; + + ma.fpssc = fpssc; + ma.flags = flags; + + map = (mdanim_t*)calloc(1,sizeof(mdanim_t)); + if (!map) return(-4); + memcpy(map, &ma, sizeof(ma)); + + map->next = m->animations; + m->animations = map; + + return(0); +} + +int md_defineskin (int modelid, const char *skinfn, int palnum, int skinnum, int surfnum) +{ + mdskinmap_t *sk, *skl; + md2model *m; + + if (!mdinited) mdinit(); + + if ((unsigned long)modelid >= (unsigned long)nextmodelid) return -1; + if (!skinfn) return -2; + if ((unsigned)palnum >= (unsigned)MAXPALOOKUPS) return -3; + + m = (md2model *)models[modelid]; + if (m->mdnum < 2) return 0; + if (m->mdnum == 2) surfnum = 0; + + skl = NULL; + for (sk = m->skinmap; sk; skl = sk, sk = sk->next) + if (sk->palette == (unsigned char)palnum && skinnum == sk->skinnum && surfnum == sk->surfnum) break; + if (!sk) { + sk = (mdskinmap_t *)calloc(1,sizeof(mdskinmap_t)); + if (!sk) return -4; + + if (!skl) m->skinmap = sk; + else skl->next = sk; + } else if (sk->fn) free(sk->fn); + + sk->palette = (unsigned char)palnum; + sk->skinnum = skinnum; + sk->surfnum = surfnum; + sk->fn = (char *)malloc(strlen(skinfn)+1); + if (!sk->fn) return(-4); + strcpy(sk->fn, skinfn); + + return 0; +} + +int md_definehud (int modelid, int tilex, double xadd, double yadd, double zadd, double angadd, int flags) +{ + if (!mdinited) mdinit(); + + if ((unsigned long)modelid >= (unsigned long)nextmodelid) return -1; + if ((unsigned long)tilex >= (unsigned long)MAXTILES) return -2; + + hudmem[(flags>>2)&1][tilex].xadd = xadd; + hudmem[(flags>>2)&1][tilex].yadd = yadd; + hudmem[(flags>>2)&1][tilex].zadd = zadd; + hudmem[(flags>>2)&1][tilex].angadd = ((short)angadd)|2048; + hudmem[(flags>>2)&1][tilex].flags = (short)flags; + + return 0; +} + +int md_undefinetile(int tile) +{ + if (!mdinited) return 0; + if ((unsigned)tile >= (unsigned)MAXTILES) return -1; + + tile2model[tile].modelid = -1; + return 0; +} + +int md_undefinemodel(int modelid) +{ + int i; + if (!mdinited) return 0; + if ((unsigned long)modelid >= (unsigned long)nextmodelid) return -1; + + for (i=MAXTILES-1; i>=0; i--) + if (tile2model[i].modelid == modelid) + tile2model[i].modelid = -1; + + if (models) { + mdfree(models[modelid]); + models[modelid] = NULL; + } + + return 0; +} + +static int daskinloader (long filh, long *fptr, long *bpl, long *sizx, long *sizy, long *osizx, long *osizy, char *hasalpha, char effect) +{ + long picfillen, j,y,x; + char *picfil,*cptr,al=255; + coltype *pic; + long xsiz, ysiz, tsizx, tsizy; + + picfillen = kfilelength(filh); + picfil = (char *)malloc(picfillen); if (!picfil) { return -1; } + kread(filh, picfil, picfillen); + + // tsizx/y = replacement texture's natural size + // xsiz/y = 2^x size of replacement + + kpgetdim(picfil,picfillen,&tsizx,&tsizy); + if (tsizx == 0 || tsizy == 0) { free(picfil); return -1; } + + if (!glinfo.texnpot) { + for(xsiz=1;xsiz=0;j--) { + swapchar(&pic[j].r, &pic[j].b); + } + } + + *sizx = xsiz; + *sizy = ysiz; + *bpl = xsiz; + *fptr = (long)pic; + *hasalpha = (al != 255); + return 0; +} + +// JONOF'S COMPRESSED TEXTURE CACHE STUFF --------------------------------------------------- +long mdloadskin_trytexcache(char *fn, long len, char effect, texcacheheader *head) +{ + long fil, fp; + char cachefn[BMAX_PATH], *cp; + unsigned char mdsum[16]; + + if (!glinfo.texcompr || !glusetexcompr || !glusetexcache) return -1; + if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) { + // lacking the necessary extensions to do this + initprintf("Warning: the GL driver lacks necessary functions to use caching\n"); + glusetexcache = 0; + return -1; + } + + md4once(fn, strlen(fn), mdsum); + for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++); + *(cp++) = '/'; + for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2); + sprintf(cp, "-%lx-0%x", len, effect); + + fil = kopen4load(cachefn, 0); + if (fil < 0) return -1; + + initprintf("Loading cached skin: %s\n", cachefn); + + if (kread(fil, head, sizeof(texcacheheader)) < (int)sizeof(texcacheheader)) goto failure; + if (memcmp(head->magic, "Polymost", 8)) goto failure; + + head->xdim = B_LITTLE32(head->xdim); + head->ydim = B_LITTLE32(head->ydim); + head->flags = B_LITTLE32(head->flags); + + if (!glinfo.texnpot && (head->flags & 1)) goto failure; + + return fil; +failure: + kclose(fil); + return -1; +} + +static long mdloadskin_cached(long fil, texcacheheader *head, long *doalloc, GLuint *glpic, long *xsiz, long *ysiz) +{ + int level, r; + texcachepicture pict; + void *pic = NULL, *packbuf = NULL; + void *midbuf = NULL; + long alloclen=0; + + if (*doalloc&1) { + bglGenTextures(1,glpic); //# of textures (make OpenGL allocate structure) + *doalloc |= 2; // prevents bglGenTextures being called again if we fail in here + } + bglBindTexture(GL_TEXTURE_2D,*glpic); + + bglGetError(); + + // load the mipmaps + for (level = 0; level==0 || (pict.xdim > 1 || pict.ydim > 1); level++) { + r = kread(fil, &pict, sizeof(texcachepicture)); + if (r < (int)sizeof(texcachepicture)) goto failure; + + pict.size = B_LITTLE32(pict.size); + pict.format = B_LITTLE32(pict.format); + pict.xdim = B_LITTLE32(pict.xdim); + pict.ydim = B_LITTLE32(pict.ydim); + pict.border = B_LITTLE32(pict.border); + pict.depth = B_LITTLE32(pict.depth); + + if (level == 0) { *xsiz = pict.xdim; *ysiz = pict.ydim; } + + if (alloclen < pict.size) { + void *picc = realloc(pic, pict.size); + if (!picc) goto failure; else pic = picc; + alloclen = pict.size; + + picc = realloc(packbuf, alloclen+16); + if (!picc) goto failure; else packbuf = picc; + + picc = realloc(midbuf, pict.size); + if (!picc) goto failure; else midbuf = picc; + } + + if (dedxtfilter(fil, &pict, pic, midbuf, packbuf, (head->flags&4)==4)) goto failure; + + bglCompressedTexImage2DARB(GL_TEXTURE_2D,level,pict.format,pict.xdim,pict.ydim,pict.border, + pict.size,pic); + if (bglGetError() != GL_NO_ERROR) goto failure; + } + + if (midbuf) free(midbuf); + if (pic) free(pic); + if (packbuf) free(packbuf); + return 0; +failure: + if (midbuf) free(midbuf); + if (pic) free(pic); + if (packbuf) free(packbuf); + return -1; +} +// --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF + + //Note: even though it says md2model, it works for both md2model&md3model +static long mdloadskin (md2model *m, int number, int pal, int surf) +{ + long i,j, fptr=0, bpl, xsiz, ysiz, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA; + char *skinfile, hasalpha, fn[BMAX_PATH+65]; + GLuint *texidx = NULL; + mdskinmap_t *sk, *skzero = NULL; + long doalloc = 1, filh; + + long cachefil = -1, picfillen; + texcacheheader cachead; + + if (m->mdnum == 2) surf = 0; + + if ((unsigned)pal >= (unsigned)MAXPALOOKUPS) return 0; + i = -1; + for (sk = m->skinmap; sk; sk = sk->next) + { + if ((int)sk->palette == pal && sk->skinnum == number && sk->surfnum == surf) + { + skinfile = sk->fn; + texidx = &sk->texid[ hictinting[pal].f ]; + strcpy(fn,skinfile); + //OSD_Printf("Using exact match skin (pal=%d,skinnum=%d,surfnum=%d) %s\n",pal,number,surf,skinfile); + break; + } + //If no match, give highest priority to number, then pal.. (Parkar's request, 02/27/2005) + else if (((int)sk->palette == 0) && (sk->skinnum == number) && (sk->surfnum == surf) && (i < 5)) { i = 5; skzero = sk; } + else if (((int)sk->palette == pal) && (sk->skinnum == 0) && (sk->surfnum == surf) && (i < 4)) { i = 4; skzero = sk; } + else if (((int)sk->palette == 0) && (sk->skinnum == 0) && (sk->surfnum == surf) && (i < 3)) { i = 3; skzero = sk; } + else if (((int)sk->palette == 0) && (sk->skinnum == number) && (i < 2)) { i = 2; skzero = sk; } + else if (((int)sk->palette == pal) && (sk->skinnum == 0) && (i < 1)) { i = 1; skzero = sk; } + else if (((int)sk->palette == 0) && (sk->skinnum == 0) && (i < 0)) { i = 0; skzero = sk; } + } + if (!sk) + { + if (skzero) + { + skinfile = skzero->fn; + texidx = &skzero->texid[ hictinting[pal].f ]; + strcpy(fn,skinfile); + //OSD_Printf("Using def skin 0,0 as fallback, pal=%d\n", pal); + } + else + { + if ((unsigned)number >= (unsigned)m->numskins) number = 0; + skinfile = m->skinfn + number*64; + texidx = &m->texid[ number * (HICEFFECTMASK+1) + hictinting[pal].f ]; + strcpy(fn,m->basepath); strcat(fn,skinfile); + //OSD_Printf("Using MD2/MD3 skin (%d) %s, pal=%d\n",number,skinfile,pal); + } + } + if (!skinfile[0]) return 0; + + if (*texidx) return *texidx; + *texidx = 0; + + if ((filh = kopen4load(fn, 0)) < 0) { + initprintf("Skin %s not found.\n",fn); + skinfile[0] = 0; + return 0; + } + + picfillen = kfilelength(filh); + kclose(filh); // FIXME: shouldn't have to do this. bug in cache1d.c + + cachefil = mdloadskin_trytexcache(fn, picfillen, hictinting[pal].f, &cachead); + if (cachefil >= 0 && !mdloadskin_cached(cachefil, &cachead, &doalloc, texidx, &xsiz, &ysiz)) { + osizx = cachead.xdim; + osizy = cachead.ydim; + m->usesalpha = hasalpha = (cachead.flags & 2) ? 1 : 0; + kclose(cachefil); + //kclose(filh); // FIXME: uncomment when cache1d.c is fixed + // cachefil >= 0, so it won't be rewritten + } else { + if (cachefil >= 0) kclose(cachefil); + cachefil = -1; // the compressed version will be saved to disk + + if ((filh = kopen4load(fn, 0)) < 0) return -1; + if (daskinloader(filh,&fptr,&bpl,&xsiz,&ysiz,&osizx,&osizy,&hasalpha,hictinting[pal].f)) + { + kclose(filh); + initprintf("Failed loading skin file \"%s\"\n", fn); + skinfile[0] = 0; + return(0); + } else kclose(filh); + m->usesalpha = hasalpha; + + if ((doalloc&3)==1) bglGenTextures(1,(GLuint*)texidx); + bglBindTexture(GL_TEXTURE_2D,*texidx); + + //gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,xsiz,ysiz,GL_BGRA_EXT,GL_UNSIGNED_BYTE,(char *)fptr); + if (glinfo.texcompr && glusetexcompr) intexfmt = hasalpha ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB; + else if (!hasalpha) intexfmt = GL_RGB; + if (glinfo.bgra) texfmt = GL_BGRA; + uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype*)fptr, xsiz, ysiz, 0); + free((void*)fptr); + } + + if (!m->skinloaded) + { + if (xsiz != osizx || ysiz != osizy) + { + float fx, fy; + fx = ((float)osizx)/((float)xsiz); + fy = ((float)osizy)/((float)ysiz); + if (m->mdnum == 2) + { + long *lptr; + for(lptr=m->glcmds;(i=*lptr++);) + for(i=labs(i);i>0;i--,lptr+=3) + { + ((float *)lptr)[0] *= fx; + ((float *)lptr)[1] *= fy; + } + } + else if (m->mdnum == 3) + { + md3model *m3 = (md3model *)m; + md3surf_t *s; + long surfi; + for (surfi=0;surfihead.numsurfs;surfi++) + { + s = &m3->head.surfs[surfi]; + for(i=s->numverts-1;i>=0;i--) + { + s->uv[i].u *= fx; + s->uv[i].v *= fy; + } + } + } + } + m->skinloaded = 1+number; + } + + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); + if (glinfo.maxanisotropy > 1.0) + bglTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,glanisotropy); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); + + if (cachefil < 0) { + // save off the compressed version + cachead.xdim = osizx; + cachead.ydim = osizy; + i = 0; + for (j=0;j<31;j++) { + if (xsiz == pow2long[j]) { i |= 1; } + if (ysiz == pow2long[j]) { i |= 2; } + } + cachead.flags = (i!=3) | (hasalpha ? 2 : 0); + writexcache(fn, picfillen, 0, hictinting[pal].f, &cachead); + } + + return(*texidx); +} + + //Note: even though it says md2model, it works for both md2model&md3model +static void updateanimation (md2model *m, spritetype *tspr) +{ + mdanim_t *anim; + long i, j; + + m->cframe = m->nframe = tile2model[tspr->picnum].framenum; + + for (anim = m->animations; + anim && anim->startframe != m->cframe; + anim = anim->next) ; + if (!anim) { m->interpol = 0; return; } + + if (((long)spriteext[tspr->owner].mdanimcur) != anim->startframe || + (spriteext[tspr->owner].flags & SPREXT_NOMDANIM)) + { + spriteext[tspr->owner].mdanimcur = (short)anim->startframe; + spriteext[tspr->owner].mdanimtims = mdtims; + m->cframe = m->nframe = anim->startframe; + m->interpol = 0; + return; + } + + i = (mdtims-spriteext[tspr->owner].mdanimtims)*anim->fpssc; + j = ((anim->endframe+1-anim->startframe)<<16); + + //Just in case you play the game for a VERY long time... + if (i < 0) { i = 0; spriteext[tspr->owner].mdanimtims = mdtims; } + //compare with j*2 instead of j to ensure i stays > j-65536 for MDANIM_ONESHOT + if ((i >= j+j) && (anim->fpssc)) //Keep mdanimtims close to mdtims to avoid the use of MOD + spriteext[tspr->owner].mdanimtims += j/anim->fpssc; + + if (anim->flags&MDANIM_ONESHOT) + { if (i > j-65536) i = j-65536; } + else { if (i >= j) { i -= j; if (i >= j) i %= j; } } + + m->cframe = (i>>16)+anim->startframe; + m->nframe = m->cframe+1; if (m->nframe > anim->endframe) m->nframe = anim->startframe; + m->interpol = ((float)(i&65535))/65536.f; +} + +//--------------------------------------- MD2 LIBRARY BEGINS --------------------------------------- + +static void md2free (md2model *m) +{ + mdanim_t *anim, *nanim = NULL; + mdskinmap_t *sk, *nsk = NULL; + + if (!m) return; + + for(anim=m->animations; anim; anim=nanim) + { + nanim = anim->next; + free(anim); + } + for(sk=m->skinmap; sk; sk=nsk) + { + nsk = sk->next; + free(sk->fn); + free(sk); + } + + if (m->frames) free(m->frames); + if (m->glcmds) free(m->glcmds); + if (m->basepath) free(m->basepath); + if (m->skinfn) free(m->skinfn); + + if (m->texid) free(m->texid); +} + +static md2model *md2load (int fil, const char *filnam) +{ + md2model *m; + md2head_t head; + char *buf, st[BMAX_PATH]; + long i; + + m = (md2model *)calloc(1,sizeof(md2model)); if (!m) return(0); + m->mdnum = 2; m->scale = .01; + + kread(fil,(char *)&head,sizeof(md2head_t)); + head.id = B_LITTLE32(head.id); head.vers = B_LITTLE32(head.vers); + head.skinxsiz = B_LITTLE32(head.skinxsiz); head.skinysiz = B_LITTLE32(head.skinysiz); + head.framebytes = B_LITTLE32(head.framebytes); head.numskins = B_LITTLE32(head.numskins); + head.numverts = B_LITTLE32(head.numverts); head.numuv = B_LITTLE32(head.numuv); + head.numtris = B_LITTLE32(head.numtris); head.numglcmds = B_LITTLE32(head.numglcmds); + head.numframes = B_LITTLE32(head.numframes); head.ofsskins = B_LITTLE32(head.ofsskins); + head.ofsuv = B_LITTLE32(head.ofsuv); head.ofstris = B_LITTLE32(head.ofstris); + head.ofsframes = B_LITTLE32(head.ofsframes); head.ofsglcmds = B_LITTLE32(head.ofsglcmds); + head.ofseof = B_LITTLE32(head.ofseof); + + if ((head.id != 0x32504449) || (head.vers != 8)) { free(m); return(0); } //"IDP2" + + m->numskins = head.numskins; + m->numframes = head.numframes; + m->numverts = head.numverts; + m->numglcmds = head.numglcmds; + m->framebytes = head.framebytes; + m->frames = (char *)calloc(m->numframes,m->framebytes); if (!m->frames) { free(m); return(0); } + m->glcmds = (long *)calloc(m->numglcmds,sizeof(long)); if (!m->glcmds) { free(m->frames); free(m); return(0); } + klseek(fil,head.ofsframes,SEEK_SET); + if (kread(fil,(char *)m->frames,m->numframes*m->framebytes) != m->numframes*m->framebytes) + { free(m->glcmds); free(m->frames); free(m); return(0); } + klseek(fil,head.ofsglcmds,SEEK_SET); + if (kread(fil,(char *)m->glcmds,m->numglcmds*sizeof(long)) != (long)(m->numglcmds*sizeof(long))) + { free(m->glcmds); free(m->frames); free(m); return(0); } + +#if B_BIG_ENDIAN != 0 + { + char *f = (char *)m->frames; + long *l,j; + md2frame_t *fr; + + for (i = m->numframes-1; i>=0; i--) { + fr = (md2frame_t *)f; + l = (long *)&fr->mul; + for (j=5;j>=0;j--) l[j] = B_LITTLE32(l[j]); + f += m->framebytes; + } + + for (i = m->numglcmds-1; i>=0; i--) { + m->glcmds[i] = B_LITTLE32(m->glcmds[i]); + } + } +#endif + + strcpy(st,filnam); + for(i=strlen(st)-1;i>0;i--) + if ((st[i] == '/') || (st[i] == '\\')) { i++; break; } + if (i<0) i=0; + st[i] = 0; + m->basepath = (char *)malloc(i+1); if (!m->basepath) { free(m->glcmds); free(m->frames); free(m); return(0); } + strcpy(m->basepath, st); + + m->skinfn = (char *)calloc(m->numskins,64); if (!m->skinfn) { free(m->basepath); free(m->glcmds); free(m->frames); free(m); return(0); } + klseek(fil,head.ofsskins,SEEK_SET); + if (kread(fil,m->skinfn,64*m->numskins) != 64*m->numskins) + { free(m->glcmds); free(m->frames); free(m); return(0); } + + m->texid = (GLuint *)calloc(m->numskins, sizeof(GLuint) * (HICEFFECTMASK+1)); + if (!m->texid) { free(m->skinfn); free(m->basepath); free(m->glcmds); free(m->frames); free(m); return(0); } + + maxmodelverts = max(maxmodelverts, m->numverts); + + return(m); +} + +static int md2draw (md2model *m, spritetype *tspr) +{ + point3d fp, fp1, fp2, m0, m1, a0, a1; + md2frame_t *f0, *f1; + unsigned char *c0, *c1; + long i, *lptr; + float f, g, k0, k1, k2, k3, k4, k5, k6, k7, mat[16], pc[4]; + +// if ((tspr->cstat&48) == 32) return 0; + + updateanimation(m,tspr); + +// -------- Unnecessarily clean (lol) code to generate translation/rotation matrix for MD2 --------- + + //create current&next frame's vertex list from whole list + f0 = (md2frame_t *)&m->frames[m->cframe*m->framebytes]; + f1 = (md2frame_t *)&m->frames[m->nframe*m->framebytes]; + f = m->interpol; g = 1-f; + m0.x = f0->mul.x*m->scale*g; m1.x = f1->mul.x*m->scale*f; + m0.y = f0->mul.y*m->scale*g; m1.y = f1->mul.y*m->scale*f; + m0.z = f0->mul.z*m->scale*g; m1.z = f1->mul.z*m->scale*f; + a0.x = f0->add.x*m->scale; a0.x = (f1->add.x*m->scale-a0.x)*f+a0.x; + a0.y = f0->add.y*m->scale; a0.y = (f1->add.y*m->scale-a0.y)*f+a0.y; + a0.z = f0->add.z*m->scale; a0.z = (f1->add.z*m->scale-a0.z)*f+a0.z + m->zadd*m->scale; + c0 = &f0->verts[0].v[0]; c1 = &f1->verts[0].v[0]; + + // Parkar: Moved up to be able to use k0 for the y-flipping code + k0 = tspr->z; + if ((globalorientation&128) && !((globalorientation&48)==32)) k0 += (float)((tilesizy[tspr->picnum]*tspr->yrepeat)<<1); + + // Parkar: Changed to use the same method as centeroriented sprites + if (globalorientation&8) //y-flipping + { + m0.z = -m0.z; m1.z = -m1.z; a0.z = -a0.z; + k0 -= (float)((tilesizy[tspr->picnum]*tspr->yrepeat)<<2); + } + if (globalorientation&4) { m0.y = -m0.y; m1.y = -m1.y; a0.y = -a0.y; } //x-flipping + + f = ((float)tspr->xrepeat)/64*m->bscale; + m0.x *= f; m1.x *= f; a0.x *= f; f = -f; // 20040610: backwards models aren't cool + m0.y *= f; m1.y *= f; a0.y *= f; + f = ((float)tspr->yrepeat)/64*m->bscale; + m0.z *= f; m1.z *= f; a0.z *= f; + + // floor aligned + k1 = tspr->y; + if((globalorientation&48)==32) + { + m0.z = -m0.z; m1.z = -m1.z; a0.z = -a0.z; + m0.y = -m0.y; m1.y = -m1.y; a0.y = -a0.y; + f = a0.x; a0.x = a0.z; a0.z = f; + k1 += (float)((tilesizy[tspr->picnum]*tspr->yrepeat)>>3); + } + + f = (65536.0*512.0)/((float)xdimen*viewingrange); + g = 32.0/((float)xdimen*gxyaspect); + m0.y *= f; m1.y *= f; a0.y = (((float)(tspr->x-globalposx))/ 1024.0 + a0.y)*f; + m0.x *=-f; m1.x *=-f; a0.x = (((float)(k1 -globalposy))/ -1024.0 + a0.x)*-f; + m0.z *= g; m1.z *= g; a0.z = (((float)(k0 -globalposz))/-16384.0 + a0.z)*g; + + k0 = ((float)(tspr->x-globalposx))*f/1024.0; + k1 = ((float)(tspr->y-globalposy))*f/1024.0; + f = gcosang2*gshang; + g = gsinang2*gshang; + k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] / 16384.0; + k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] / 16384.0; + k2 = k0*(1-k4)+k1*k5; + k3 = k1*(1-k4)-k0*k5; + k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang; + mat[0] = k4*k6 + k5*k7; mat[4] = gchang*gstang; mat[ 8] = k4*k7 - k5*k6; mat[12] = k2*k6 + k3*k7; + k6 = f*gctang + gsinang*gstang; k7 = g*gctang - gcosang*gstang; + mat[1] = k4*k6 + k5*k7; mat[5] = gchang*gctang; mat[ 9] = k4*k7 - k5*k6; mat[13] = k2*k6 + k3*k7; + k6 = gcosang2*gchang; k7 = gsinang2*gchang; + mat[2] = k4*k6 + k5*k7; mat[6] =-gshang; mat[10] = k4*k7 - k5*k6; mat[14] = k2*k6 + k3*k7; + + mat[12] += a0.y*mat[0] + a0.z*mat[4] + a0.x*mat[ 8]; + mat[13] += a0.y*mat[1] + a0.z*mat[5] + a0.x*mat[ 9]; + mat[14] += a0.y*mat[2] + a0.z*mat[6] + a0.x*mat[10]; + + // floor aligned + if((globalorientation&48)==32) + { + f = mat[4]; mat[4] = mat[8]*16.0; mat[8] = -f*(1.0/16.0); + f = mat[5]; mat[5] = mat[9]*16.0; mat[9] = -f*(1.0/16.0); + f = mat[6]; mat[6] = mat[10]*16.0; mat[10] = -f*(1.0/16.0); + } + + //Mirrors + if (grhalfxdown10x < 0) { mat[0] = -mat[0]; mat[4] = -mat[4]; mat[8] = -mat[8]; mat[12] = -mat[12]; } + +// ------ Unnecessarily clean (lol) code to generate translation/rotation matrix for MD2 ends ------ + +// PLAG: Cleaner model rotation code + if (spriteext[tspr->owner].pitch || spriteext[tspr->owner].roll) + { + if (spriteext[tspr->owner].xoff) + a0.x = (int)(spriteext[tspr->owner].xoff / (2048 * (m0.x+m1.x))); + else + a0.x = 0; + if (spriteext[tspr->owner].yoff) + a0.y = (int)(spriteext[tspr->owner].yoff / (2048 * (m0.y+m1.y))); + else + a0.y = 0; + if ((spriteext[tspr->owner].zoff) && !(tspr->cstat&1024)) + a0.z = (int)(spriteext[tspr->owner].zoff / (524288 * (m0.z+m1.z))); + else + a0.z = 0; + k0 = (float)sintable[(spriteext[tspr->owner].pitch+512)&2047] / 16384.0; + k1 = (float)sintable[spriteext[tspr->owner].pitch&2047] / 16384.0; + k2 = (float)sintable[(spriteext[tspr->owner].roll+512)&2047] / 16384.0; + k3 = (float)sintable[spriteext[tspr->owner].roll&2047] / 16384.0; + } + for(i=m->numverts-1;i>=0;i--) + { + if (spriteext[tspr->owner].pitch || spriteext[tspr->owner].roll) + { + fp.z = c0[(i<<2)+0] + a0.x; + fp.x = c0[(i<<2)+1] + a0.y; + fp.y = c0[(i<<2)+2] + a0.z; + fp1.x = fp.x*k2 + fp.y*k3; + fp1.y = fp.x*k0*(-k3) + fp.y*k0*k2 + fp.z*(-k1); + fp1.z = fp.x*k1*(-k3) + fp.y*k1*k2 + fp.z*k0; + fp.z = c1[(i<<2)+0] + a0.x; + fp.x = c1[(i<<2)+1] + a0.y; + fp2.y = c1[(i<<2)+2] + a0.z; + fp2.x = fp.x*k2 + fp.y*k3; + fp2.y = fp.x*k0*(-k3) + fp.y*k0*k2 + fp.z*(-k1); + fp2.z = fp.x*k1*(-k3) + fp.y*k1*k2 + fp.z*k0; + fp.z = (fp1.z - a0.x)*m0.x + (fp2.z - a0.x)*m1.x; + fp.x = (fp1.x - a0.y)*m0.y + (fp2.x - a0.y)*m1.y; + fp.y = (fp1.y - a0.z)*m0.z + (fp2.y - a0.z)*m1.z; + } + else + { + fp.z = c0[(i<<2)+0]*m0.x + c1[(i<<2)+0]*m1.x; + fp.y = c0[(i<<2)+2]*m0.z + c1[(i<<2)+2]*m1.z; + fp.x = c0[(i<<2)+1]*m0.y + c1[(i<<2)+1]*m1.y; + } + vertlist[i].x = fp.x; + vertlist[i].y = fp.y; + vertlist[i].z = fp.z; + } + bglMatrixMode(GL_MODELVIEW); //Let OpenGL (and perhaps hardware :) handle the matrix rotation + mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; bglLoadMatrixf(mat); +// PLAG: End + + i = mdloadskin(m,tile2model[tspr->picnum].skinnum,globalpal,0); if (!i) return 0; + + //bit 10 is an ugly hack in game.c\animatesprites telling MD2SPRITE + //to use Z-buffer hacks to hide overdraw problems with the shadows + if (tspr->cstat&1024) + { + bglDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS + bglDepthRange(0.0,0.9999); + } + bglPushAttrib(GL_POLYGON_BIT); + if ((grhalfxdown10x >= 0) ^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0)) bglFrontFace(GL_CW); else bglFrontFace(GL_CCW); + bglEnable(GL_CULL_FACE); + bglCullFace(GL_BACK); + + bglEnable(GL_TEXTURE_2D); + bglBindTexture(GL_TEXTURE_2D, i); + + pc[0] = pc[1] = pc[2] = ((float)(numpalookups-min(max(globalshade+m->shadeoff,0),numpalookups)))/((float)numpalookups); + pc[0] *= (float)hictinting[globalpal].r / 255.0; + pc[1] *= (float)hictinting[globalpal].g / 255.0; + pc[2] *= (float)hictinting[globalpal].b / 255.0; + if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } else pc[3] = 1.0; + if (m->usesalpha) //Sprites with alpha in texture + { +// bglEnable(GL_BLEND);// bglBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); +// bglEnable(GL_ALPHA_TEST); bglAlphaFunc(GL_GREATER,0.32); + float al = 0.32; + if (alphahackarray[globalpicnum] != 0) + al=alphahackarray[globalpicnum]; + bglEnable(GL_BLEND); + bglEnable(GL_ALPHA_TEST); + bglAlphaFunc(GL_GREATER,al); + } + else + { + if (tspr->cstat&2) bglEnable(GL_BLEND); else bglDisable(GL_BLEND); + } + bglColor4f(pc[0],pc[1],pc[2],pc[3]); + + for(lptr=m->glcmds;(i=*lptr++);) + { + if (i < 0) { bglBegin(GL_TRIANGLE_FAN); i = -i; } + else { bglBegin(GL_TRIANGLE_STRIP); } + for(;i>0;i--,lptr+=3) + { + bglTexCoord2f(((float *)lptr)[0],((float *)lptr)[1]); + bglVertex3fv((float *)&vertlist[lptr[2]]); + } + bglEnd(); + } + + if (m->usesalpha) bglDisable(GL_ALPHA_TEST); + bglDisable(GL_CULL_FACE); + bglPopAttrib(); + if (tspr->cstat&1024) + { + bglDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS + bglDepthRange(0.0,0.99999); + } + bglLoadIdentity(); + + return 1; +} + +//---------------------------------------- MD2 LIBRARY ENDS ---------------------------------------- + +// DICHOTOMIC RECURSIVE SORTING - USED BY MD3DRAW - MAY PUT IT IN ITS OWN SOURCE FILE LATER +int partition(unsigned short *indexes, float *depths, int f, int l) { + int up,down,temp; + float tempf; + unsigned short tempus; + float piv = depths[f]; + unsigned short piv2 = indexes[f]; + up = f; + down = l; + do { + while ((depths[up] <= piv) && (up < l)) + up++; + while ((depths[down] > piv) && (down > f)) + down--; + if (up < down ) + { + tempf = depths[up]; + depths[up] = depths[down]; + depths[down] = tempf; + tempus = indexes[up]; + indexes[up] = indexes[down]; + indexes[down] = tempus; + } + } while (down > up); + depths[f] = depths[down]; + depths[down] = piv; + indexes[f] = indexes[down]; + indexes[down] = piv2; + return down; +} + +void quicksort(unsigned short *indexes, float *depths, int first, int last) { + int pivIndex = 0; + if(first < last) { + pivIndex = partition(indexes,depths,first, last); + quicksort(indexes,depths,first,(pivIndex-1)); + quicksort(indexes,depths,(pivIndex+1),last); + } +} +// END OF QUICKSORT LIB + +//--------------------------------------- MD3 LIBRARY BEGINS --------------------------------------- + +static md3model *md3load (int fil) +{ + char *buf, st[BMAX_PATH+2], bst[BMAX_PATH+2]; + long i, j, surfi, ofsurf, bsc, offs[4], leng[4]; + md3model *m; + md3surf_t *s; + + m = (md3model *)calloc(1,sizeof(md3model)); if (!m) return(0); + m->mdnum = 3; m->texid = 0; m->scale = .01; + + kread(fil,&m->head,sizeof(md3head_t)); + m->head.id = B_LITTLE32(m->head.id); m->head.vers = B_LITTLE32(m->head.vers); + m->head.flags = B_LITTLE32(m->head.flags); m->head.numframes = B_LITTLE32(m->head.numframes); + m->head.numtags = B_LITTLE32(m->head.numtags); m->head.numsurfs = B_LITTLE32(m->head.numsurfs); + m->head.numskins = B_LITTLE32(m->head.numskins); m->head.frames = (md3frame_t*)B_LITTLE32((long)m->head.frames); + m->head.tags = (md3tag_t*)B_LITTLE32((long)m->head.tags); m->head.surfs = (md3surf_t*)B_LITTLE32((long)m->head.surfs); + m->head.eof = B_LITTLE32(m->head.eof); + + if ((m->head.id != 0x33504449) && (m->head.vers != 15)) { free(m); return(0); } //"IDP3" + + m->numskins = m->head.numskins; //<- dead code? + m->numframes = m->head.numframes; + + ofsurf = (long)m->head.surfs; + + klseek(fil,(long)m->head.frames,SEEK_SET); i = m->head.numframes*sizeof(md3frame_t); + m->head.frames = (md3frame_t *)malloc(i); if (!m->head.frames) { free(m); return(0); } + kread(fil,m->head.frames,i); + + if (m->head.numtags == 0) m->head.tags = NULL; + else { + klseek(fil,(long)m->head.tags,SEEK_SET); i = m->head.numtags*sizeof(md3tag_t); + m->head.tags = (md3tag_t *)malloc(i); if (!m->head.tags) { free(m->head.frames); free(m); return(0); } + kread(fil,m->head.tags,i); + } + + klseek(fil,(long)m->head.surfs,SEEK_SET); i = m->head.numsurfs*sizeof(md3surf_t); + m->head.surfs = (md3surf_t *)malloc(i); if (!m->head.surfs) { if (m->head.tags) free(m->head.tags); free(m->head.frames); free(m); return(0); } + +#if B_BIG_ENDIAN != 0 + { + long *l; + + for (i = m->head.numframes-1; i>=0; i--) { + l = (long *)&m->head.frames[i].min; + for (j=3+3+3+1-1;j>=0;j--) l[j] = B_LITTLE32(l[j]); + } + + for (i = m->head.numtags-1; i>=0; i--) { + l = (long *)&m->head.tags[i].p; + for (j=3+3+3+3-1;j>=0;j--) l[j] = B_LITTLE32(l[j]); + } + } +#endif + + for(surfi=0;surfihead.numsurfs;surfi++) + { + s = &m->head.surfs[surfi]; + klseek(fil,ofsurf,SEEK_SET); kread(fil,s,sizeof(md3surf_t)); + +#if B_BIG_ENDIAN != 0 + { + long *l; + s->id = B_LITTLE32(s->id); + l = (long *)&s->flags; + for (j=1+1+1+1+1+1+1+1+1+1-1;j>=0;j--) l[j] = B_LITTLE32(l[j]); + } +#endif + + offs[0] = ofsurf+((long)(s->tris )); leng[0] = s->numtris*sizeof(md3tri_t); + offs[1] = ofsurf+((long)(s->shaders)); leng[1] = s->numshaders*sizeof(md3shader_t); + offs[2] = ofsurf+((long)(s->uv )); leng[2] = s->numverts*sizeof(md3uv_t); + offs[3] = ofsurf+((long)(s->xyzn )); leng[3] = s->numframes*s->numverts*sizeof(md3xyzn_t); + + s->tris = (md3tri_t *)malloc(leng[0]+leng[1]+leng[2]+leng[3]); + if (!s->tris) + { + for(surfi--;surfi>=0;surfi--) free(m->head.surfs[surfi].tris); + if (m->head.tags) free(m->head.tags); free(m->head.frames); free(m); return(0); + } + s->shaders = (md3shader_t *)(((long)s->tris )+leng[0]); + s->uv = (md3uv_t *)(((long)s->shaders)+leng[1]); + s->xyzn = (md3xyzn_t *)(((long)s->uv )+leng[2]); + + klseek(fil,offs[0],SEEK_SET); kread(fil,s->tris ,leng[0]); + klseek(fil,offs[1],SEEK_SET); kread(fil,s->shaders,leng[1]); + klseek(fil,offs[2],SEEK_SET); kread(fil,s->uv ,leng[2]); + klseek(fil,offs[3],SEEK_SET); kread(fil,s->xyzn ,leng[3]); + +#if B_BIG_ENDIAN != 0 + { + long *l; + + for (i=s->numtris-1;i>=0;i--) { + for (j=2;j>=0;j--) s->tris[i].i[j] = B_LITTLE32(s->tris[i].i[j]); + } + for (i=s->numshaders-1;i>=0;i--) { + s->shaders[i].i = B_LITTLE32(s->shaders[i].i); + } + for (i=s->numverts-1;i>=0;i--) { + l = (long*)&s->uv[i].u; + l[0] = B_LITTLE32(l[0]); + l[1] = B_LITTLE32(l[1]); + } + for (i=s->numframes*s->numverts-1;i>=0;i--) { + s->xyzn[i].x = (signed short)B_LITTLE16((unsigned short)s->xyzn[i].x); + s->xyzn[i].y = (signed short)B_LITTLE16((unsigned short)s->xyzn[i].y); + s->xyzn[i].z = (signed short)B_LITTLE16((unsigned short)s->xyzn[i].z); + } + } +#endif + maxmodelverts = max(maxmodelverts, s->numverts); + ofsurf += s->ofsend; + } + +#if 0 + strcpy(st,filnam); + for(i=0,j=0;st[i];i++) if ((st[i] == '/') || (st[i] == '\\')) j = i+1; + st[j] = '*'; st[j+1] = 0; + kzfindfilestart(st); bsc = -1; + while (kzfindfile(st)) + { + if (st[0] == '\\') continue; + + for(i=0,j=0;st[i];i++) if (st[i] == '.') j = i+1; + if ((!stricmp(&st[j],"JPG")) || (!stricmp(&st[j],"PNG")) || (!stricmp(&st[j],"GIF")) || + (!stricmp(&st[j],"PCX")) || (!stricmp(&st[j],"TGA")) || (!stricmp(&st[j],"BMP")) || + (!stricmp(&st[j],"CEL"))) + { + for(i=0;st[i];i++) if (st[i] != filnam[i]) break; + if (i > bsc) { bsc = i; strcpy(bst,st); } + } + } + if (!mdloadskin(&m->texid,&m->usesalpha,bst)) ;//bad! +#endif + + return(m); +} + +static int md3draw (md3model *m, spritetype *tspr) +{ + point3d fp, fp1, fp2, m0, m1, a0, a1; + md3xyzn_t *v0, *v1; + long i, j, k, surfi, *lptr; + float f, g, k0, k1, k2, k3, k4, k5, k6, k7, mat[16], pc[4]; + md3surf_t *s; + //PLAG : sorting stuff + unsigned short *indexes; + float *maxdepths; + unsigned short tempus; + + +// if ((tspr->cstat&48) == 32) return 0; + + updateanimation((md2model *)m,tspr); + + //create current&next frame's vertex list from whole list + + f = m->interpol; g = 1-f; + m0.x = (1.0/64.0)*m->scale*g; m1.x = (1.0/64.0)*m->scale*f; + m0.y = (1.0/64.0)*m->scale*g; m1.y = (1.0/64.0)*m->scale*f; + m0.z = (1.0/64.0)*m->scale*g; m1.z = (1.0/64.0)*m->scale*f; + a0.x = a0.y = 0; a0.z = m->zadd*m->scale; + + // Parkar: Moved up to be able to use k0 for the y-flipping code + k0 = tspr->z; + if ((globalorientation&128) && !((globalorientation&48)==32)) k0 += (float)((tilesizy[tspr->picnum]*tspr->yrepeat)<<1); + + // Parkar: Changed to use the same method as centeroriented sprites + if (globalorientation&8) //y-flipping + { + m0.z = -m0.z; m1.z = -m1.z; a0.z = -a0.z; + k0 -= (float)((tilesizy[tspr->picnum]*tspr->yrepeat)<<2); + } + if (globalorientation&4) { m0.y = -m0.y; m1.y = -m1.y; a0.y = -a0.y; } //x-flipping + + f = ((float)tspr->xrepeat)/64*m->bscale; + m0.x *= f; m1.x *= f; a0.x *= f; f = -f; // 20040610: backwards models aren't cool + m0.y *= f; m1.y *= f; a0.y *= f; + f = ((float)tspr->yrepeat)/64*m->bscale; + m0.z *= f; m1.z *= f; a0.z *= f; + + // floor aligned + k1 = tspr->y; + if((globalorientation&48)==32) + { + m0.z = -m0.z; m1.z = -m1.z; a0.z = -a0.z; + m0.y = -m0.y; m1.y = -m1.y; a0.y = -a0.y; + f = a0.x; a0.x = a0.z; a0.z = f; + k1 += (float)((tilesizy[tspr->picnum]*tspr->yrepeat)>>3); + } + + f = (65536.0*512.0)/((float)xdimen*viewingrange); + g = 32.0/((float)xdimen*gxyaspect); + m0.y *= f; m1.y *= f; a0.y = (((float)(tspr->x-globalposx))/ 1024.0 + a0.y)*f; + m0.x *=-f; m1.x *=-f; a0.x = (((float)(k1 -globalposy))/ -1024.0 + a0.x)*-f; + m0.z *= g; m1.z *= g; a0.z = (((float)(k0 -globalposz))/-16384.0 + a0.z)*g; + + k0 = ((float)(tspr->x-globalposx))*f/1024.0; + k1 = ((float)(tspr->y-globalposy))*f/1024.0; + f = gcosang2*gshang; + g = gsinang2*gshang; + k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] / 16384.0; + k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] / 16384.0; + k2 = k0*(1-k4)+k1*k5; + k3 = k1*(1-k4)-k0*k5; + k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang; + mat[0] = k4*k6 + k5*k7; mat[4] = gchang*gstang; mat[ 8] = k4*k7 - k5*k6; mat[12] = k2*k6 + k3*k7; + k6 = f*gctang + gsinang*gstang; k7 = g*gctang - gcosang*gstang; + mat[1] = k4*k6 + k5*k7; mat[5] = gchang*gctang; mat[ 9] = k4*k7 - k5*k6; mat[13] = k2*k6 + k3*k7; + k6 = gcosang2*gchang; k7 = gsinang2*gchang; + mat[2] = k4*k6 + k5*k7; mat[6] =-gshang; mat[10] = k4*k7 - k5*k6; mat[14] = k2*k6 + k3*k7; + + mat[12] += a0.y*mat[0] + a0.z*mat[4] + a0.x*mat[ 8]; + mat[13] += a0.y*mat[1] + a0.z*mat[5] + a0.x*mat[ 9]; + mat[14] += a0.y*mat[2] + a0.z*mat[6] + a0.x*mat[10]; + + // floor aligned + if((globalorientation&48)==32) + { + f = mat[4]; mat[4] = mat[8]*16.0; mat[8] = -f*(1.0/16.0); + f = mat[5]; mat[5] = mat[9]*16.0; mat[9] = -f*(1.0/16.0); + f = mat[6]; mat[6] = mat[10]*16.0; mat[10] = -f*(1.0/16.0); + } + + //Mirrors + if (grhalfxdown10x < 0) { mat[0] = -mat[0]; mat[4] = -mat[4]; mat[8] = -mat[8]; mat[12] = -mat[12]; } + +//------------ + //bit 10 is an ugly hack in game.c\animatesprites telling MD2SPRITE + //to use Z-buffer hacks to hide overdraw problems with the shadows + if (tspr->cstat&1024) + { + bglDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS + bglDepthRange(0.0,0.9999); + } + bglPushAttrib(GL_POLYGON_BIT); + if ((grhalfxdown10x >= 0) ^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0)) bglFrontFace(GL_CW); else bglFrontFace(GL_CCW); + bglEnable(GL_CULL_FACE); + bglCullFace(GL_BACK); + + bglEnable(GL_TEXTURE_2D); + + pc[0] = pc[1] = pc[2] = ((float)(numpalookups-min(max(globalshade+m->shadeoff,0),numpalookups)))/((float)numpalookups); + pc[0] *= (float)hictinting[globalpal].r / 255.0; + pc[1] *= (float)hictinting[globalpal].g / 255.0; + pc[2] *= (float)hictinting[globalpal].b / 255.0; + if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } else pc[3] = 1.0; + if (m->usesalpha) //Sprites with alpha in texture + { +// bglEnable(GL_BLEND);// bglBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); +// bglEnable(GL_ALPHA_TEST); bglAlphaFunc(GL_GREATER,0.32); +// float al = 0.32; + // PLAG : default cutoff removed + float al = 0.0; + if (alphahackarray[globalpicnum] != 0) + al=alphahackarray[globalpicnum]; + bglEnable(GL_BLEND); + bglEnable(GL_ALPHA_TEST); + bglAlphaFunc(GL_GREATER,al); + } + else + { + if (tspr->cstat&2) bglEnable(GL_BLEND); else bglDisable(GL_BLEND); + } + bglColor4f(pc[0],pc[1],pc[2],pc[3]); +//------------ + +// PLAG: Cleaner model rotation code + if (spriteext[tspr->owner].pitch || spriteext[tspr->owner].roll) + { + if (spriteext[tspr->owner].xoff) + a0.x = (int)(spriteext[tspr->owner].xoff / (2048 * (m0.x+m1.x))); + else + a0.x = 0; + if (spriteext[tspr->owner].yoff) + a0.y = (int)(spriteext[tspr->owner].yoff / (2048 * (m0.x+m1.x))); + else + a0.y = 0; + if ((spriteext[tspr->owner].zoff) && !(tspr->cstat&1024)) + a0.z = (int)(spriteext[tspr->owner].zoff / (524288 * (m0.z+m1.z))); + else + a0.z = 0; + k0 = (float)sintable[(spriteext[tspr->owner].pitch+512)&2047] / 16384.0; + k1 = (float)sintable[spriteext[tspr->owner].pitch&2047] / 16384.0; + k2 = (float)sintable[(spriteext[tspr->owner].roll+512)&2047] / 16384.0; + k3 = (float)sintable[spriteext[tspr->owner].roll&2047] / 16384.0; + } + for(surfi=0;surfihead.numsurfs;surfi++) + { + s = &m->head.surfs[surfi]; + v0 = &s->xyzn[m->cframe*s->numverts]; + v1 = &s->xyzn[m->nframe*s->numverts]; + + for(i=s->numverts-1;i>=0;i--) + { + if (spriteext[tspr->owner].pitch || spriteext[tspr->owner].roll) + { + fp.z = v0[i].x + a0.x; + fp.x = v0[i].y + a0.y; + fp.y = v0[i].z + a0.z; + fp1.x = fp.x*k2 + fp.y*k3; + fp1.y = fp.x*k0*(-k3) + fp.y*k0*k2 + fp.z*(-k1); + fp1.z = fp.x*k1*(-k3) + fp.y*k1*k2 + fp.z*k0; + fp.z = v1[i].x + a0.x; + fp.x = v1[i].y + a0.y; + fp.y = v1[i].z + a0.z; + fp2.x = fp.x*k2 + fp.y*k3; + fp2.y = fp.x*k0*(-k3) + fp.y*k0*k2 + fp.z*(-k1); + fp2.z = fp.x*k1*(-k3) + fp.y*k1*k2 + fp.z*k0; + fp.z = (fp1.z - a0.x)*m0.x + (fp2.z - a0.x)*m1.x; + fp.x = (fp1.x - a0.y)*m0.y + (fp2.x - a0.y)*m1.y; + fp.y = (fp1.y - a0.z)*m0.z + (fp2.y - a0.z)*m1.z; + } + else + { + fp.z = v0[i].x*m0.x + v1[i].x*m1.x; + fp.y = v0[i].z*m0.z + v1[i].z*m1.z; + fp.x = v0[i].y*m0.y + v1[i].y*m1.y; + } + vertlist[i].x = fp.x; + vertlist[i].y = fp.y; + vertlist[i].z = fp.z; + } + bglMatrixMode(GL_MODELVIEW); //Let OpenGL (and perhaps hardware :) handle the matrix rotation + mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; bglLoadMatrixf(mat); +// PLAG: End + + i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,globalpal,surfi); if (!i) continue; + //i = mdloadskin((md2model *)m,tile2model[tspr->picnum].skinnum,surfi); //hack for testing multiple surfaces per MD3 + bglBindTexture(GL_TEXTURE_2D, i); + +//PLAG: delayed polygon-level sorted rendering + if (m->usesalpha && !(tspr->cstat & 1024)) + { + indexes = malloc(sizeof(unsigned short) * s->numtris); + maxdepths = malloc(sizeof(float) * s->numtris); + + // old sorting methods - dead code + /*for(i=s->numtris-1;i>=0;i--) + { + tempf = (vertlist[s->tris[i].i[0]].x * mat[2]) + (vertlist[s->tris[i].i[0]].y * mat[6]) + (vertlist[s->tris[i].i[0]].z * mat[10]) + mat[14]; + if (tempf < ((vertlist[s->tris[i].i[1]].x * mat[2]) + (vertlist[s->tris[i].i[1]].y * mat[6]) + (vertlist[s->tris[i].i[1]].z * mat[10]) + mat[14])) + tempf = (vertlist[s->tris[i].i[1]].x * mat[2]) + (vertlist[s->tris[i].i[1]].y * mat[6]) + (vertlist[s->tris[i].i[1]].z * mat[10]) + mat[14]; + if (tempf < ((vertlist[s->tris[i].i[2]].x * mat[2]) + (vertlist[s->tris[i].i[2]].y * mat[6]) + (vertlist[s->tris[i].i[2]].z * mat[10]) + mat[14])) + tempf = (vertlist[s->tris[i].i[2]].x * mat[2]) + (vertlist[s->tris[i].i[2]].y * mat[6]) + (vertlist[s->tris[i].i[2]].z * mat[10]) + mat[14]; + maxdepths[i] = tempf; + indexes[i] = i; + } + + for(i=s->numtris-1;i>=0;i--) + { + tempf = (vertlist[s->tris[i].i[0]].x * mat[2]) + (vertlist[s->tris[i].i[0]].y * mat[6]) + (vertlist[s->tris[i].i[0]].z * mat[10]) + mat[14]; + tempf += (vertlist[s->tris[i].i[1]].x * mat[2]) + (vertlist[s->tris[i].i[1]].y * mat[6]) + (vertlist[s->tris[i].i[1]].z * mat[10]) + mat[14]; + tempf += (vertlist[s->tris[i].i[2]].x * mat[2]) + (vertlist[s->tris[i].i[2]].y * mat[6]) + (vertlist[s->tris[i].i[2]].z * mat[10]) + mat[14]; + tempf /= 3.0f; + maxdepths[i] = tempf; + indexes[i] = i; + } + + for(i=s->numtris-1;i>=0;i--) + { + tempvec[0].x = (vertlist[s->tris[i].i[0]].x * mat[0]) + (vertlist[s->tris[i].i[0]].y * mat[4]) + (vertlist[s->tris[i].i[0]].z * mat[8]) + mat[12]; + tempvec[0].y = (vertlist[s->tris[i].i[0]].x * mat[1]) + (vertlist[s->tris[i].i[0]].y * mat[5]) + (vertlist[s->tris[i].i[0]].z * mat[9]) + mat[13]; + tempvec[0].z = (vertlist[s->tris[i].i[0]].x * mat[2]) + (vertlist[s->tris[i].i[0]].y * mat[6]) + (vertlist[s->tris[i].i[0]].z * mat[10]) + mat[14]; + + tempvec[1].x = (vertlist[s->tris[i].i[1]].x * mat[0]) + (vertlist[s->tris[i].i[1]].y * mat[4]) + (vertlist[s->tris[i].i[1]].z * mat[8]) + mat[12]; + tempvec[1].y = (vertlist[s->tris[i].i[1]].x * mat[1]) + (vertlist[s->tris[i].i[1]].y * mat[5]) + (vertlist[s->tris[i].i[1]].z * mat[9]) + mat[13]; + tempvec[1].z = (vertlist[s->tris[i].i[1]].x * mat[2]) + (vertlist[s->tris[i].i[1]].y * mat[6]) + (vertlist[s->tris[i].i[1]].z * mat[10]) + mat[14]; + + tempvec[2].x = (vertlist[s->tris[i].i[2]].x * mat[0]) + (vertlist[s->tris[i].i[2]].y * mat[4]) + (vertlist[s->tris[i].i[2]].z * mat[8]) + mat[12]; + tempvec[2].y = (vertlist[s->tris[i].i[2]].x * mat[1]) + (vertlist[s->tris[i].i[2]].y * mat[5]) + (vertlist[s->tris[i].i[2]].z * mat[9]) + mat[13]; + tempvec[2].z = (vertlist[s->tris[i].i[2]].x * mat[2]) + (vertlist[s->tris[i].i[2]].y * mat[6]) + (vertlist[s->tris[i].i[2]].z * mat[10]) + mat[14]; + + tempf = (tempvec[0].x * tempvec[0].x) + (tempvec[0].y * tempvec[0].y) + (tempvec[0].z * tempvec[0].z); + tempf += (tempvec[1].x * tempvec[1].x) + (tempvec[1].y * tempvec[1].y) + (tempvec[1].z * tempvec[1].z); + tempf += (tempvec[2].x * tempvec[2].x) + (tempvec[2].y * tempvec[2].y) + (tempvec[2].z * tempvec[2].z); + + maxdepths[i] = tempf; + indexes[i] = i; + }*/ + + for(i=s->numtris-1;i>=0;i--) + { + // Matrix multiplication - ugly but clear + fp.x = (vertlist[s->tris[i].i[0]].x * mat[0]) + (vertlist[s->tris[i].i[0]].y * mat[4]) + (vertlist[s->tris[i].i[0]].z * mat[8]) + mat[12]; + fp.y = (vertlist[s->tris[i].i[0]].x * mat[1]) + (vertlist[s->tris[i].i[0]].y * mat[5]) + (vertlist[s->tris[i].i[0]].z * mat[9]) + mat[13]; + fp.z = (vertlist[s->tris[i].i[0]].x * mat[2]) + (vertlist[s->tris[i].i[0]].y * mat[6]) + (vertlist[s->tris[i].i[0]].z * mat[10]) + mat[14]; + + fp1.x = (vertlist[s->tris[i].i[1]].x * mat[0]) + (vertlist[s->tris[i].i[1]].y * mat[4]) + (vertlist[s->tris[i].i[1]].z * mat[8]) + mat[12]; + fp1.y = (vertlist[s->tris[i].i[1]].x * mat[1]) + (vertlist[s->tris[i].i[1]].y * mat[5]) + (vertlist[s->tris[i].i[1]].z * mat[9]) + mat[13]; + fp1.z = (vertlist[s->tris[i].i[1]].x * mat[2]) + (vertlist[s->tris[i].i[1]].y * mat[6]) + (vertlist[s->tris[i].i[1]].z * mat[10]) + mat[14]; + + fp2.x = (vertlist[s->tris[i].i[2]].x * mat[0]) + (vertlist[s->tris[i].i[2]].y * mat[4]) + (vertlist[s->tris[i].i[2]].z * mat[8]) + mat[12]; + fp2.y = (vertlist[s->tris[i].i[2]].x * mat[1]) + (vertlist[s->tris[i].i[2]].y * mat[5]) + (vertlist[s->tris[i].i[2]].z * mat[9]) + mat[13]; + fp2.z = (vertlist[s->tris[i].i[2]].x * mat[2]) + (vertlist[s->tris[i].i[2]].y * mat[6]) + (vertlist[s->tris[i].i[2]].z * mat[10]) + mat[14]; + + f = (fp.x * fp.x) + (fp.y * fp.y) + (fp.z * fp.z); + + g = (fp1.x * fp1.x) + (fp1.y * fp1.y) + (fp1.z * fp1.z); + if (f > g) + f = g; + g = (fp2.x * fp2.x) + (fp2.y * fp2.y) + (fp2.z * fp2.z); + if (f > g) + f = g; + + maxdepths[i] = f; + indexes[i] = i; + } + + //bubble sort - dead code + /*test = 0; + j = 0; + while (j == 0) + { + j = 1; + for(i=s->numtris-1;i>0;i--) + if (maxdepths[i] < maxdepths[i-1]) + { + f = maxdepths[i]; + maxdepths[i] = maxdepths[i-1]; + maxdepths[i-1] = f; + k = indexes[i]; + indexes[i] = indexes[i-1]; + indexes[i-1] = k; + test++; + j = 0; + } + }*/ + + // dichotomic recursive sorting - about 100x less iterations than bubblesort + quicksort(indexes, maxdepths, 0, s->numtris - 1); + + bglBegin(GL_TRIANGLES); + for(i=s->numtris-1;i>=0;i--) + for(j=0;j<3;j++) + { + k = s->tris[indexes[i]].i[j]; + bglTexCoord2f(s->uv[k].u,s->uv[k].v); + bglVertex3fv((float *)&vertlist[k]); + } + bglEnd(); + + free(indexes); + free(maxdepths); + } + else + { + bglBegin(GL_TRIANGLES); + for(i=s->numtris-1;i>=0;i--) + for(j=0;j<3;j++) + { + k = s->tris[i].i[j]; + bglTexCoord2f(s->uv[k].u,s->uv[k].v); + bglVertex3fv((float *)&vertlist[k]); + } + bglEnd(); + } + } +//------------ + + if (m->usesalpha) bglDisable(GL_ALPHA_TEST); + bglDisable(GL_CULL_FACE); + bglPopAttrib(); + if (tspr->cstat&1024) + { + bglDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS + bglDepthRange(0.0,0.99999); + } + bglLoadIdentity(); + + return 1; +} + +static void md3free (md3model *m) +{ + mdanim_t *anim, *nanim = NULL; + mdskinmap_t *sk, *nsk = NULL; + md3surf_t *s; + long surfi; + + if (!m) return; + + for(anim=m->animations; anim; anim=nanim) + { + nanim = anim->next; + free(anim); + } + for(sk=m->skinmap; sk; sk=nsk) + { + nsk = sk->next; + free(sk->fn); + free(sk); + } + + if (m->head.surfs) + { + for(surfi=m->head.numsurfs-1;surfi>=0;surfi--) + { + s = &m->head.surfs[surfi]; + if (s->tris) free(s->tris); + } + free(m->head.surfs); + } + if (m->head.tags) free(m->head.tags); + if (m->head.frames) free(m->head.frames); + + if (m->texid) free(m->texid); + + free(m); +} + +//---------------------------------------- MD3 LIBRARY ENDS ---------------------------------------- +//--------------------------------------- VOX LIBRARY BEGINS --------------------------------------- + + //For loading/conversion only +static long xsiz, ysiz, zsiz, yzsiz, *vbit = 0; //vbit: 1 bit per voxel: 0=air,1=solid +static float xpiv, ypiv, zpiv; //Might want to use more complex/unique names! +static long *vcolhashead = 0, vcolhashsizm1; +typedef struct { long p, c, n; } voxcol_t; +static voxcol_t *vcol = 0; long vnum = 0, vmax = 0; +typedef struct { short x, y; } spoint2d; +static spoint2d *shp; +static long *shcntmal, *shcnt = 0, shcntp; +static long mytexo5, *zbit, gmaxx, gmaxy, garea, pow2m1[33]; +static voxmodel *gvox; + + //pitch must equal xsiz*4 +unsigned gloadtex (long *picbuf, long xsiz, long ysiz, long is8bit, long dapal) +{ + unsigned rtexid; + coltype *pic, *pic2; + unsigned char *cptr; + long i; + + pic = (coltype *)picbuf; //Correct for GL's RGB order; also apply gamma here.. + pic2 = (coltype *)malloc(xsiz*ysiz*sizeof(long)); if (!pic2) return((unsigned)-1); + cptr = (unsigned char*)&britable[gammabrightness ? 0 : curbrightness][0]; + if (!is8bit) + { + for(i=xsiz*ysiz-1;i>=0;i--) + { + pic2[i].b = cptr[pic[i].r]; + pic2[i].g = cptr[pic[i].g]; + pic2[i].r = cptr[pic[i].b]; + pic2[i].a = 255; + } + } + else + { + if (palookup[dapal] == 0) dapal = 0; + for(i=xsiz*ysiz-1;i>=0;i--) + { + pic2[i].b = cptr[palette[(long)palookup[dapal][pic[i].a]*3+2]*4]; + pic2[i].g = cptr[palette[(long)palookup[dapal][pic[i].a]*3+1]*4]; + pic2[i].r = cptr[palette[(long)palookup[dapal][pic[i].a]*3+0]*4]; + pic2[i].a = 255; + } + } + + bglGenTextures(1,(GLuint*)&rtexid); + bglBindTexture(GL_TEXTURE_2D,rtexid); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + bglTexImage2D(GL_TEXTURE_2D,0,4,xsiz,ysiz,0,GL_RGBA,GL_UNSIGNED_BYTE,(unsigned char *)pic2); + free(pic2); + return(rtexid); +} + +static long getvox (long x, long y, long z) +{ + z += x*yzsiz + y*zsiz; + for(x=vcolhashead[(z*214013)&vcolhashsizm1];x>=0;x=vcol[x].n) + if (vcol[x].p == z) return(vcol[x].c); + return(0x808080); +} + +static void putvox (long x, long y, long z, long col) +{ + if (vnum >= vmax) { vmax = max(vmax<<1,4096); vcol = (voxcol_t *)realloc(vcol,vmax*sizeof(voxcol_t)); } + + z += x*yzsiz + y*zsiz; + vcol[vnum].p = z; z = ((z*214013)&vcolhashsizm1); + vcol[vnum].c = col; + vcol[vnum].n = vcolhashead[z]; vcolhashead[z] = vnum++; +} + + //Set all bits in vbit from (x,y,z0) to (x,y,z1-1) to 0's +static void setzrange0 (long *lptr, long z0, long z1) +{ + long z, ze; + if (!((z0^z1)&~31)) { lptr[z0>>5] &= ((~(-1<>5); ze = (z1>>5); + lptr[z] &=~(-1<>5] |= ((~(-1<>5); ze = (z1>>5); + lptr[z] |= (-1<mytexx + x0; + for(dy=0;dy;dy--,i+=gvox->mytexx) + for(x=0;x>5]&(1<>5); dx += x0-1; c = (dx>>5) - (x0>>5); + m = ~pow2m1[x0&31]; m1 = pow2m1[(dx&31)+1]; + if (!c) { for(m&=m1;dy;dy--,i+=mytexo5) if (zbit[i]&m) return(0); } + else + { for(;dy;dy--,i+=mytexo5) + { + if (zbit[i]&m) return(0); + for(x=1;xmytexx + x0; + for(y=0;ymytexx) + for(x=0;x>5] |= (1<>5); dx += x0-1; c = (dx>>5) - (x0>>5); + m = ~pow2m1[x0&31]; m1 = pow2m1[(dx&31)+1]; + if (!c) { for(m&=m1;dy;dy--,i+=mytexo5) zbit[i] |= m; } + else + { for(;dy;dy--,i+=mytexo5) + { + zbit[i] |= m; + for(x=1;x gmaxx) gmaxx = x; + if (y > gmaxy) gmaxy = y; + garea += (x+(VOXBORDWIDTH<<1))*(y+(VOXBORDWIDTH<<1)); + gvox->qcnt++; +} + +static void addquad (long x0, long y0, long z0, long x1, long y1, long z1, long x2, long y2, long z2, long face) +{ + long i, j, x, y, z, xx, yy, nx = 0, ny = 0, nz = 0, *lptr; + voxrect_t *qptr; + + x = labs(x2-x0); y = labs(y2-y0); z = labs(z2-z0); + if (!x) { x = y; y = z; i = 0; } else if (!y) { y = z; i = 1; } else i = 2; + if (x < y) { z = x; x = y; y = z; i += 3; } + z = shcnt[y*shcntp+x]++; + lptr = &gvox->mytex[(shp[z].y+VOXBORDWIDTH)*gvox->mytexx+(shp[z].x+VOXBORDWIDTH)]; + switch(face) + { + case 0: ny = y1; x2 = x0; x0 = x1; x1 = x2; break; + case 1: ny = y0; y0++; y1++; y2++; break; + case 2: nz = z1; y0 = y2; y2 = y1; y1 = y0; z0++; z1++; z2++; break; + case 3: nz = z0; break; + case 4: nx = x1; y2 = y0; y0 = y1; y1 = y2; x0++; x1++; x2++; break; + case 5: nx = x0; break; + } + for(yy=0;yymytexx) + for(xx=0;xxmytex[(shp[z].y+yy)*gvox->mytexx+shp[z].x]; + lptr[xx] = lptr[VOXBORDWIDTH]; lptr[xx+x+VOXBORDWIDTH] = lptr[x-1+VOXBORDWIDTH]; + } + //Extend borders vertically + for(yy=0;yymytex[(shp[z].y+yy)*gvox->mytexx+shp[z].x], + &gvox->mytex[(shp[z].y+VOXBORDWIDTH)*gvox->mytexx+shp[z].x], + (x+(VOXBORDWIDTH<<1))<<2); + memcpy(&gvox->mytex[(shp[z].y+y+yy+VOXBORDWIDTH)*gvox->mytexx+shp[z].x], + &gvox->mytex[(shp[z].y+y-1+VOXBORDWIDTH)*gvox->mytexx+shp[z].x], + (x+(VOXBORDWIDTH<<1))<<2); + } + + qptr = &gvox->quad[gvox->qcnt]; + qptr->v[0].x = x0; qptr->v[0].y = y0; qptr->v[0].z = z0; + qptr->v[1].x = x1; qptr->v[1].y = y1; qptr->v[1].z = z1; + qptr->v[2].x = x2; qptr->v[2].y = y2; qptr->v[2].z = z2; + for(j=0;j<3;j++) { qptr->v[j].u = shp[z].x+VOXBORDWIDTH; qptr->v[j].v = shp[z].y+VOXBORDWIDTH; } + if (i < 3) qptr->v[1].u += x; else qptr->v[1].v += y; + qptr->v[2].u += x; qptr->v[2].v += y; + + qptr->v[3].u = qptr->v[0].u - qptr->v[1].u + qptr->v[2].u; + qptr->v[3].v = qptr->v[0].v - qptr->v[1].v + qptr->v[2].v; + qptr->v[3].x = qptr->v[0].x - qptr->v[1].x + qptr->v[2].x; + qptr->v[3].y = qptr->v[0].y - qptr->v[1].y + qptr->v[2].y; + qptr->v[3].z = qptr->v[0].z - qptr->v[1].z + qptr->v[2].z; + if (gvox->qfacind[face] < 0) gvox->qfacind[face] = gvox->qcnt; + gvox->qcnt++; + +} + +static long isolid (long x, long y, long z) +{ + if ((unsigned long)x >= (unsigned long)xsiz) return(0); + if ((unsigned long)y >= (unsigned long)ysiz) return(0); + if ((unsigned long)z >= (unsigned long)zsiz) return(0); + z += x*yzsiz + y*zsiz; return(vbit[z>>5]&(1<qfacind[i] = -1; + + i = ((max(ysiz,zsiz)+1)<<2); + bx0 = (long *)malloc(i<<1); if (!bx0) { free(gvox); return(0); } + by0 = (long *)(((long)bx0)+i); + + for(cnt=0;cnt<2;cnt++) + { + if (!cnt) daquad = cntquad; + else daquad = addquad; + gvox->qcnt = 0; + + memset(by0,-1,(max(ysiz,zsiz)+1)<<2); v = 0; + + for(i=-1;i<=1;i+=2) + for(y=0;y= 0) && ((by0[z] != oz) || (v >= ov))) + { daquad(bx0[z],y,by0[z],x,y,by0[z],x,y,z,i>=0); by0[z] = -1; } + if (v > ov) oz = z; else if ((v < ov) && (by0[z] != oz)) { bx0[z] = x; by0[z] = oz; } + } + + for(i=-1;i<=1;i+=2) + for(z=0;z= 0) && ((by0[y] != oz) || (v >= ov))) + { daquad(bx0[y],by0[y],z,x,by0[y],z,x,y,z,(i>=0)+2); by0[y] = -1; } + if (v > ov) oz = y; else if ((v < ov) && (by0[y] != oz)) { bx0[y] = x; by0[y] = oz; } + } + + for(i=-1;i<=1;i+=2) + for(x=0;x= 0) && ((by0[z] != oz) || (v >= ov))) + { daquad(x,bx0[z],by0[z],x,y,by0[z],x,y,z,(i>=0)+4); by0[z] = -1; } + if (v > ov) oz = z; else if ((v < ov) && (by0[z] != oz)) { bx0[z] = y; by0[z] = oz; } + } + + if (!cnt) + { + shp = (spoint2d *)malloc(gvox->qcnt*sizeof(spoint2d)); + if (!shp) { free(bx0); free(gvox); return(0); } + + sc = 0; + for(y=gmaxy;y;y--) + for(x=gmaxx;x>=y;x--) + { + i = shcnt[y*shcntp+x]; shcnt[y*shcntp+x] = sc; //shcnt changes from counter to head index + for(;i>0;i--) { shp[sc].x = x; shp[sc].y = y; sc++; } + } + + for(gvox->mytexx=32;gvox->mytexx<(gmaxx+(VOXBORDWIDTH<<1));gvox->mytexx<<=1); + for(gvox->mytexy=32;gvox->mytexy<(gmaxy+(VOXBORDWIDTH<<1));gvox->mytexy<<=1); + while (gvox->mytexx*gvox->mytexy*8 < garea*9) //This should be sufficient to fit most skins... + { +skindidntfit:; + if (gvox->mytexx <= gvox->mytexy) gvox->mytexx <<= 1; else gvox->mytexy <<= 1; + } + mytexo5 = (gvox->mytexx>>5); + + i = (((gvox->mytexx*gvox->mytexy+31)>>5)<<2); + zbit = (long *)malloc(i); if (!zbit) { free(bx0); free(gvox); free(shp); return(0); } + memset(zbit,0,i); + + v = gvox->mytexx*gvox->mytexy; + for(z=0;zmytexx,255)-dx))>>15); + y0 = (((rand()&32767)*(min(gvox->mytexy,255)-dy))>>15); +#else + x0 = (((rand()&32767)*(gvox->mytexx+1-dx))>>15); + y0 = (((rand()&32767)*(gvox->mytexy+1-dy))>>15); +#endif + i--; + if (i < 0) //Time-out! Very slow if this happens... but at least it still works :P + { + free(zbit); + + //Re-generate shp[].x/y (box sizes) from shcnt (now head indices) for next pass :/ + j = 0; + for(y=gmaxy;y;y--) + for(x=gmaxx;x>=y;x--) + { + i = shcnt[y*shcntp+x]; + for(;jquad = (voxrect_t *)malloc(gvox->qcnt*sizeof(voxrect_t)); + if (!gvox->quad) { free(zbit); free(shp); free(bx0); free(gvox); return(0); } + + gvox->mytex = (long *)malloc(gvox->mytexx*gvox->mytexy*sizeof(long)); + if (!gvox->mytex) { free(gvox->quad); free(zbit); free(shp); free(bx0); free(gvox); return(0); } + } + } + free(shp); free(zbit); free(bx0); + return(gvox); +} + +static long loadvox (const char *filnam) +{ + long i, j, k, x, y, z, pal[256], fil; + unsigned char c[3], *tbuf; + + fil = kopen4load((char *)filnam,0); if (fil < 0) return(-1); + kread(fil,&xsiz,4); xsiz = B_LITTLE32(xsiz); + kread(fil,&ysiz,4); ysiz = B_LITTLE32(ysiz); + kread(fil,&zsiz,4); zsiz = B_LITTLE32(zsiz); + xpiv = ((float)xsiz)*.5; + ypiv = ((float)ysiz)*.5; + zpiv = ((float)zsiz)*.5; + + klseek(fil,-768,SEEK_END); + for(i=0;i<256;i++) + { kread(fil,c,3); pal[i] = (((long)c[0])<<18)+(((long)c[1])<<10)+(((long)c[2])<<2)+(i<<24); } + pal[255] = -1; + + vcolhashsizm1 = 8192-1; + vcolhashead = (long *)malloc((vcolhashsizm1+1)*sizeof(long)); if (!vcolhashead) { kclose(fil); return(-1); } + memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(long)); + + yzsiz = ysiz*zsiz; i = ((xsiz*yzsiz+31)>>3); + vbit = (long *)malloc(i); if (!vbit) { kclose(fil); return(-1); } + memset(vbit,0,i); + + tbuf = (unsigned char *)malloc(zsiz*sizeof(char)); if (!tbuf) { kclose(fil); return(-1); } + + klseek(fil,12,SEEK_SET); + for(x=0;x=0;z--) + { if (tbuf[z] != 255) { i = j+z; vbit[i>>5] |= (1<>5]&(1<>5]&(1<>5]&(1<>5]&(1<>5]&(1<>5]&(1<=0; i--) xyoffs[i] = B_LITTLE16(xyoffs[i]); + + klseek(fil,-768,SEEK_END); + for(i=0;i<256;i++) + { kread(fil,c,3); pal[i] = B_LITTLE32((((long)c[0])<<18)+(((long)c[1])<<10)+(((long)c[2])<<2)+(i<<24)); } + + yzsiz = ysiz*zsiz; i = ((xsiz*yzsiz+31)>>3); + vbit = (long *)malloc(i); if (!vbit) { free(xyoffs); kclose(fil); return(-1); } + memset(vbit,0,i); + + for(vcolhashsizm1=4096;vcolhashsizm1<(mip1leng>>1);vcolhashsizm1<<=1); vcolhashsizm1--; //approx to numvoxs! + vcolhashead = (long *)malloc((vcolhashsizm1+1)*sizeof(long)); if (!vcolhashead) { free(xyoffs); kclose(fil); return(-1); } + memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(long)); + + klseek(fil,28+((xsiz+1)<<2)+((ysizp1*xsiz)<<1),SEEK_SET); + + i = kfilelength(fil)-ktell(fil); + tbuf = (unsigned char *)malloc(i); if (!tbuf) { free(xyoffs); kclose(fil); return(-1); } + kread(fil,tbuf,i); kclose(fil); + + cptr = tbuf; + for(x=0;x=0; i--) ylen[i] = B_LITTLE16(ylen[i]); + klseek(fil,32,SEEK_SET); + + yzsiz = ysiz*zsiz; i = ((xsiz*yzsiz+31)>>3); + vbit = (long *)malloc(i); if (!vbit) { free(ylen); kclose(fil); return(-1); } + memset(vbit,0,i); + + for(vcolhashsizm1=4096;vcolhashsizm10;i--) + { + kread(fil,c,8); //b,g,r,a,z_lo,z_hi,vis,dir + z0 = B_LITTLE16(*(unsigned short *)&c[4]); + if (!(c[6]&16)) setzrange1(vbit,j+z1,j+z0); + vbit[(j+z0)>>5] |= (1<>3); + vbit = (long *)malloc(i); if (!vbit) { kclose(fil); return(-1); } + memset(vbit,-1,i); + + vcolhashsizm1 = 1048576-1; + vcolhashead = (long *)malloc((vcolhashsizm1+1)*sizeof(long)); if (!vcolhashead) { kclose(fil); return(-1); } + memset(vcolhashead,-1,(vcolhashsizm1+1)*sizeof(long)); + + //Allocate huge buffer and load rest of file into it... + i = kfilelength(fil)-ktell(fil); + vbuf = (unsigned char *)malloc(i); if (!vbuf) { kclose(fil); return(-1); } + kread(fil,vbuf,i); + kclose(fil); + + v = vbuf; + for(y=0;ymytex) free(m->mytex); + if (m->quad) free(m->quad); + if (m->texid) free(m->texid); + free(m); +} + +static voxmodel *voxload (const char *filnam) +{ + long i, is8bit, ret; + voxmodel *vm; + + i = strlen(filnam)-4; if (i < 0) return(0); + if (!Bstrcasecmp(&filnam[i],".vox")) { ret = loadvox(filnam); is8bit = 1; } + else if (!Bstrcasecmp(&filnam[i],".kvx")) { ret = loadkvx(filnam); is8bit = 1; } + else if (!Bstrcasecmp(&filnam[i],".kv6")) { ret = loadkv6(filnam); is8bit = 0; } + //else if (!Bstrcasecmp(&filnam[i],".vxl")) { ret = loadvxl(filnam); is8bit = 0; } + else return(0); + if (ret >= 0) vm = vox2poly(); else vm = 0; + if (vm) + { + vm->mdnum = 1; //VOXel model id + vm->scale = vm->bscale = 1.0; + vm->xsiz = xsiz; vm->ysiz = ysiz; vm->zsiz = zsiz; + vm->xpiv = xpiv; vm->ypiv = ypiv; vm->zpiv = zpiv; + vm->is8bit = is8bit; + + vm->texid = (unsigned int *)calloc(MAXPALOOKUPS,sizeof(unsigned int)); + if (!vm->texid) { voxfree(vm); vm = 0; } + } + if (shcntmal) { free(shcntmal); shcntmal = 0; } + if (vbit) { free(vbit); vbit = 0; } + if (vcol) { free(vcol); vcol = 0; vnum = 0; vmax = 0; } + if (vcolhashead) { free(vcolhashead); vcolhashead = 0; } + return(vm); +} + + //Draw voxel model as perfect cubes +static int voxdraw (voxmodel *m, spritetype *tspr) +{ + point3d fp, m0, a0; + long i, j, k, fi, *lptr, xx, yy, zz; + float ru, rv, uhack[2], vhack[2], phack[2], clut[6] = {1,1,1,1,1,1}; //1.02,1.02,0.94,1.06,0.98,0.98}; + float f, g, k0, k1, k2, k3, k4, k5, k6, k7, mat[16], omat[16], pc[4]; + vert_t *vptr; + + if ((int)m == (int)0xffffffff) // hackhackhack + return 0; + if ((tspr->cstat&48)==32) return 0; + + //updateanimation((md2model *)m,tspr); + + m0.x = m->scale; + m0.y = m->scale; + m0.z = m->scale; + a0.x = a0.y = 0; a0.z = m->zadd*m->scale; + + //if (globalorientation&8) //y-flipping + //{ + // m0.z = -m0.z; a0.z = -a0.z; + // //Add height of 1st frame (use same frame to prevent animation bounce) + // a0.z += m->zsiz*m->scale; + //} + //if (globalorientation&4) { m0.y = -m0.y; a0.y = -a0.y; } //x-flipping + + f = ((float)tspr->xrepeat)*(256.0/320.0)/64.0*m->bscale; + m0.x *= f; a0.x *= f; f = -f; + m0.y *= f; a0.y *= f; + f = ((float)tspr->yrepeat)/64.0*m->bscale; + m0.z *= f; a0.z *= f; + + k0 = tspr->z; + if (globalorientation&128) k0 += (float)((tilesizy[tspr->picnum]*tspr->yrepeat)<<1); + + f = (65536.0*512.0)/((float)xdimen*viewingrange); + g = 32.0/((float)xdimen*gxyaspect); + m0.y *= f; a0.y = (((float)(tspr->x-globalposx))/ 1024.0 + a0.y)*f; + m0.x *=-f; a0.x = (((float)(tspr->y-globalposy))/ -1024.0 + a0.x)*-f; + m0.z *= g; a0.z = (((float)(k0 -globalposz))/-16384.0 + a0.z)*g; + + k0 = ((float)(tspr->x-globalposx))*f/1024.0; + k1 = ((float)(tspr->y-globalposy))*f/1024.0; + f = gcosang2*gshang; + g = gsinang2*gshang; + k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] / 16384.0; + k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] / 16384.0; + k2 = k0*(1-k4)+k1*k5; + k3 = k1*(1-k4)-k0*k5; + k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang; + mat[0] = k4*k6 + k5*k7; mat[4] = gchang*gstang; mat[ 8] = k4*k7 - k5*k6; mat[12] = k2*k6 + k3*k7; + k6 = f*gctang + gsinang*gstang; k7 = g*gctang - gcosang*gstang; + mat[1] = k4*k6 + k5*k7; mat[5] = gchang*gctang; mat[ 9] = k4*k7 - k5*k6; mat[13] = k2*k6 + k3*k7; + k6 = gcosang2*gchang; k7 = gsinang2*gchang; + mat[2] = k4*k6 + k5*k7; mat[6] =-gshang; mat[10] = k4*k7 - k5*k6; mat[14] = k2*k6 + k3*k7; + + mat[12] += a0.y*mat[0] + a0.z*mat[4] + a0.x*mat[ 8]; + mat[13] += a0.y*mat[1] + a0.z*mat[5] + a0.x*mat[ 9]; + mat[14] += a0.y*mat[2] + a0.z*mat[6] + a0.x*mat[10]; + + //Mirrors + if (grhalfxdown10x < 0) { mat[0] = -mat[0]; mat[4] = -mat[4]; mat[8] = -mat[8]; mat[12] = -mat[12]; } + +//------------ + //bit 10 is an ugly hack in game.c\animatesprites telling MD2SPRITE + //to use Z-buffer hacks to hide overdraw problems with the shadows + if (tspr->cstat&1024) + { + bglDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS + bglDepthRange(0.0,0.9999); + } + bglPushAttrib(GL_POLYGON_BIT); + if ((grhalfxdown10x >= 0) /*^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0)*/) bglFrontFace(GL_CW); else bglFrontFace(GL_CCW); + bglEnable(GL_CULL_FACE); + bglCullFace(GL_BACK); + + bglEnable(GL_TEXTURE_2D); + + pc[0] = pc[1] = pc[2] = ((float)(numpalookups-min(max(globalshade+m->shadeoff,0),numpalookups)))/((float)numpalookups); + pc[0] *= (float)hictinting[globalpal].r / 255.0; + pc[1] *= (float)hictinting[globalpal].g / 255.0; + pc[2] *= (float)hictinting[globalpal].b / 255.0; + if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } else pc[3] = 1.0; + if (tspr->cstat&2) bglEnable(GL_BLEND); else bglDisable(GL_BLEND); +//------------ + + //transform to Build coords + memcpy(omat,mat,sizeof(omat)); + f = 1.f/64.f; + g = m0.x*f; mat[0] *= g; mat[1] *= g; mat[2] *= g; + g = m0.y*f; mat[4] = omat[8]*g; mat[5] = omat[9]*g; mat[6] = omat[10]*g; + g =-m0.z*f; mat[8] = omat[4]*g; mat[9] = omat[5]*g; mat[10] = omat[6]*g; + mat[12] -= (m->xpiv*mat[0] + m->ypiv*mat[4] + (m->zpiv+m->zsiz*.5)*mat[ 8]); + mat[13] -= (m->xpiv*mat[1] + m->ypiv*mat[5] + (m->zpiv+m->zsiz*.5)*mat[ 9]); + mat[14] -= (m->xpiv*mat[2] + m->ypiv*mat[6] + (m->zpiv+m->zsiz*.5)*mat[10]); + bglMatrixMode(GL_MODELVIEW); //Let OpenGL (and perhaps hardware :) handle the matrix rotation + mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; + + bglLoadMatrixf(mat); + + ru = 1.f/((float)m->mytexx); + rv = 1.f/((float)m->mytexy); +#if (VOXBORDWIDTH == 0) + uhack[0] = ru*.125; uhack[1] = -uhack[0]; + vhack[0] = rv*.125; vhack[1] = -vhack[0]; +#endif + phack[0] = 0; phack[1] = 1.f/256.f; + + if (!m->texid[globalpal]) m->texid[globalpal] = gloadtex(m->mytex,m->mytexx,m->mytexy,m->is8bit,globalpal); + else bglBindTexture(GL_TEXTURE_2D,m->texid[globalpal]); + bglBegin(GL_QUADS); + for(i=0,fi=0;iqcnt;i++) + { + if (i == m->qfacind[fi]) { f = clut[fi++]; bglColor4f(pc[0]*f,pc[1]*f,pc[2]*f,pc[3]*f); } + vptr = &m->quad[i].v[0]; + + xx = vptr[0].x+vptr[2].x; + yy = vptr[0].y+vptr[2].y; + zz = vptr[0].z+vptr[2].z; + + for(j=0;j<4;j++) + { +#if (VOXBORDWIDTH == 0) + bglTexCoord2f(((float)vptr[j].u)*ru+uhack[vptr[j].u!=vptr[0].u], + ((float)vptr[j].v)*rv+vhack[vptr[j].v!=vptr[0].v]); +#else + bglTexCoord2f(((float)vptr[j].u)*ru,((float)vptr[j].v)*rv); +#endif + fp.x = ((float)vptr[j].x) - phack[xx>vptr[j].x*2] + phack[xxvptr[j].y*2] + phack[yyvptr[j].z*2] + phack[zzcstat&1024) + { + bglDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS + bglDepthRange(0.0,0.99999); + } + bglLoadIdentity(); + return 1; +} + +//---------------------------------------- VOX LIBRARY ENDS ---------------------------------------- +//--------------------------------------- MD LIBRARY BEGINS --------------------------------------- + +mdmodel *mdload (const char *filnam) +{ + mdmodel *vm; + int fil; + long i; + + vm = (mdmodel*)voxload(filnam); if (vm) return(vm); + + fil = kopen4load((char *)filnam,0); if (fil < 0) return(0); + kread(fil,&i,4); klseek(fil,0,SEEK_SET); + switch(B_LITTLE32(i)) + { + case 0x32504449: vm = (mdmodel*)md2load(fil,filnam); break; //IDP2 + case 0x33504449: vm = (mdmodel*)md3load(fil); break; //IDP3 + default: vm = (mdmodel*)0; break; + } + kclose(fil); + return(vm); +} + +int mddraw (spritetype *tspr) +{ + mdanim_t *anim; + mdmodel *vm; + + if (maxmodelverts > allocmodelverts) + { + point3d *vl = (point3d *)realloc(vertlist,sizeof(point3d)*maxmodelverts); + if (!vl) { OSD_Printf("ERROR: Not enough memory to allocate %d vertices!\n",maxmodelverts); return 0; } + vertlist = vl; allocmodelverts = maxmodelverts; + } + + vm = models[tile2model[tspr->picnum].modelid]; + if (vm->mdnum == 1) { return voxdraw((voxmodel *)vm,tspr); } + if (vm->mdnum == 2) { return md2draw((md2model *)vm,tspr); } + if (vm->mdnum == 3) { return md3draw((md3model *)vm,tspr); } + return 0; +} + +void mdfree (mdmodel *vm) +{ + if (vm->mdnum == 1) { voxfree((voxmodel *)vm); return; } + if (vm->mdnum == 2) { md2free((md2model *)vm); return; } + if (vm->mdnum == 3) { md3free((md3model *)vm); return; } +} + +//---------------------------------------- MD LIBRARY ENDS ---------------------------------------- diff --git a/polymer/build/src/misc/buildres.rc b/polymer/build/src/misc/buildres.rc new file mode 100644 index 000000000..0a5c4b6be --- /dev/null +++ b/polymer/build/src/misc/buildres.rc @@ -0,0 +1,31 @@ +#include + +100 ICON "rsrc/build_icon.ico" +200 BITMAP "rsrc/build.bmp" + +1000 DIALOGEX DISCARDABLE 20, 40, 265, 233 +STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU +CAPTION "Startup" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255 + CONTROL "Starting Build Editor...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8 + //CONTROL "", 102, "LISTBOX", LBS_HASSTRINGS | LBS_NOSEL | LBS_USETABSTOPS | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_DISABLENOSCROLL, 5, 92, 255, 138 + CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138 +END + +2000 DIALOGEX DISCARDABLE 20, 40, 279, 168 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL +CAPTION "Dialog" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "Video mode", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 3, 128, 64 + CONTROL "&Fullscreen", 100, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 15, 49, 10 + CONTROL "&2D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 30, 37, 8 + CONTROL "", 101, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 28, 75, 56 + CONTROL "&3D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 47, 37, 8 + CONTROL "", 102, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 46, 75, 56 + CONTROL "&Continue", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 140, 145, 64, 17 + CONTROL "E&xit", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 208, 145, 64, 17 +END + diff --git a/polymer/build/src/misc/enumdisplay.c b/polymer/build/src/misc/enumdisplay.c new file mode 100644 index 000000000..313839b9f --- /dev/null +++ b/polymer/build/src/misc/enumdisplay.c @@ -0,0 +1,156 @@ +#include +#define WIN32_LEAN_AND_MEAN +#include +#include + +#define DEFAULT_OUTPUT_FILE "enumdisplay.txt" +char *outputfile = DEFAULT_OUTPUT_FILE; + +HMODULE hDDrawDLL = NULL; +LPDIRECTDRAW lpDD = NULL; +FILE *output = NULL; + +void usage(void) +{ + printf( + "enumdisplay by Jonathon Fowler (jonof@edgenetwork.org)\n" + "Options:\n" + " -h, -?, --help This message\n" + " -o Use different output file (default: " + DEFAULT_OUTPUT_FILE ", use - for stdout)\n" + ); +} + +void dumpdevmode(DEVMODE *devmode) +{ + fprintf(output, "\tdmFields has"); + if (devmode->dmFields & DM_PELSWIDTH) fprintf(output, " DM_PELSWIDTH"); + if (devmode->dmFields & DM_PELSHEIGHT) fprintf(output, " DM_PELSHEIGHT"); + if (devmode->dmFields & DM_BITSPERPEL) fprintf(output, " DM_BITSPERPEL"); + fprintf(output, "\n\tdmPelsWidth = %d\n", devmode->dmPelsWidth); + fprintf(output, "\tdmPelsHeight = %d\n", devmode->dmPelsHeight); + fprintf(output, "\tdmBitsPerPel = %d\n", devmode->dmBitsPerPel); +} + +HRESULT WINAPI ddenum(DDSURFACEDESC *ddsd, VOID *udata) +{ + fprintf(output, "\tdwFlags has"); + if (ddsd->dwFlags & DDSD_WIDTH) fprintf(output, " DDSD_WIDTH"); + if (ddsd->dwFlags & DDSD_HEIGHT) fprintf(output, " DDSD_HEIGHT"); + if (ddsd->dwFlags & DDSD_PIXELFORMAT) fprintf(output, " DDSD_PIXELFORMAT"); + fprintf(output, "\n\tdwWidth = %d\n", ddsd->dwWidth); + fprintf(output, "\tdwHeight = %d\n", ddsd->dwHeight); + fprintf(output, "\tddpfPixelFormat.dwFlags has"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED1) fprintf(output, " DDPF_PALETTEINDEXED1"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED2) fprintf(output, " DDPF_PALETTEINDEXED2"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED4) fprintf(output, " DDPF_PALETTEINDEXED4"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) fprintf(output, " DDPF_PALETTEINDEXED8"); + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_RGB) fprintf(output, " DDPF_RGB"); + fprintf(output, "\n\tddpfPixelFormat.dwRGBBitCount = %d\n", ddsd->ddpfPixelFormat.dwRGBBitCount); + fprintf(output, "\n"); + + return(DDENUMRET_OK); +} + +int InitDirectDraw(void) +{ + HRESULT result; + HRESULT (WINAPI *aDirectDrawCreate)(GUID *, LPDIRECTDRAW *, IUnknown *); + HRESULT (WINAPI *aDirectDrawEnumerate)(LPDDENUMCALLBACK, LPVOID); + DDCAPS ddcaps; + + hDDrawDLL = LoadLibrary("DDRAW.DLL"); + if (!hDDrawDLL) { fprintf(output, "Failed loading DDRAW.DLL\n"); return -1; } + + aDirectDrawEnumerate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawEnumerateA"); + if (!aDirectDrawEnumerate) { fprintf(output, "Error fetching DirectDrawEnumerate\n"); return -1; } + + aDirectDrawCreate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawCreate"); + if (!aDirectDrawCreate) { fprintf(output, "Error fetching DirectDrawCreate\n"); return -1; } + + result = aDirectDrawCreate(NULL, &lpDD, NULL); + if (result != DD_OK) { fprintf(output, "DirectDrawCreate() failed (%d)\n", result); return -1; } + + return 0; +} + +void UninitDirectDraw(void) +{ + if (lpDD) IDirectDraw_Release(lpDD); + lpDD = NULL; + if (hDDrawDLL) FreeLibrary(hDDrawDLL); + hDDrawDLL = NULL; +} + +int main(int argc, char **argv) +{ + int i; + + DEVMODE devmode; + HRESULT hresult; + + for (i=1; i + +100 ICON "rsrc/game_icon.ico" +200 BITMAP "rsrc/game.bmp" + +1000 DIALOGEX DISCARDABLE 20, 40, 265, 233 +STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU +CAPTION "Startup" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255 + CONTROL "Starting KenBuild...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8 + //CONTROL "", 102, "LISTBOX", LBS_HASSTRINGS | LBS_NOSEL | LBS_USETABSTOPS | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_DISABLENOSCROLL, 5, 92, 255, 138 + CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138 +END + +2000 DIALOGEX DISCARDABLE 20, 40, 279, 168 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL +CAPTION "Dialog" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "Video mode", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 3, 128, 46 + CONTROL "&Fullscreen", 100, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 15, 49, 10 + CONTROL "&Mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 30, 37, 8 + CONTROL "", 101, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 28, 75, 56 + CONTROL "&Continue", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 140, 145, 64, 17 + CONTROL "E&xit", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 208, 145, 64, 17 +END + diff --git a/polymer/build/src/misc/getdxdidf.c b/polymer/build/src/misc/getdxdidf.c new file mode 100644 index 000000000..f0c7675c6 --- /dev/null +++ b/polymer/build/src/misc/getdxdidf.c @@ -0,0 +1,129 @@ +// compile with: +// gcc -o getdxdidf.exe src\getdxdidf.c -Ic:\mingw32\dx6\include -Lc:\mingw32\dx6\lib -ldxguid -ldinput -mwindows + +#define WIN32_LEAN_AND_MEAN +#define INITGUID +#include +#include +#include + + +char *WhatGUID(const GUID *guid) +{ + if (guid == &GUID_XAxis) return "&GUID_XAxis"; + if (guid == &GUID_YAxis) return "&GUID_YAxis"; + if (guid == &GUID_ZAxis) return "&GUID_ZAxis"; + if (guid == &GUID_RxAxis) return "&GUID_RxAxis"; + if (guid == &GUID_RyAxis) return "&GUID_RyAxis"; + if (guid == &GUID_RzAxis) return "&GUID_RzAxis"; + if (guid == &GUID_Slider) return "&GUID_Slider"; + + if (guid == &GUID_Button) return "&GUID_Button"; + if (guid == &GUID_Key) return "&GUID_Key"; + + if (guid == &GUID_POV) return "&GUID_POV"; + + if (guid == &GUID_Unknown) return "&GUID_Unknown"; + + return "NULL"; +} + + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + FILE *fp; + DWORD i; + + fp = fopen("didf.txt", "w"); + if (!fp) return -1; + setvbuf(fp, NULL, _IONBF, 0); + + + fprintf(fp, + "// Keyboard\n" + "\n" + "static DIOBJECTDATAFORMAT c_dfDIKeyboard_odf[] = {\n" + ); + + for (i=0; i +#include "SDL/SDL.h" + +int keytranslation[SDLK_LAST]; +char *keysyms[SDLK_LAST]; + +static int buildkeytranslationtable(void) +{ + memset(keytranslation,0,sizeof(keytranslation)); + memset(keysyms,0,sizeof(keysyms)); + +#define MAP(x,y) { \ + keytranslation[x] = y; \ + keysyms[x] = #x ; \ +} + MAP(SDLK_BACKSPACE, 0xe); + MAP(SDLK_TAB, 0xf); + MAP(SDLK_RETURN, 0x1c); + MAP(SDLK_PAUSE, 0x59); // 0x1d + 0x45 + 0x9d + 0xc5 + MAP(SDLK_ESCAPE, 0x1); + MAP(SDLK_SPACE, 0x39); + MAP(SDLK_EXCLAIM, 0x2); // '1' + MAP(SDLK_QUOTEDBL, 0x28); // ''' + MAP(SDLK_HASH, 0x4); // '3' + MAP(SDLK_DOLLAR, 0x5); // '4' + MAP(37, 0x6); // '5' <-- where's the keysym SDL guys? + MAP(SDLK_AMPERSAND, 0x8); // '7' + MAP(SDLK_QUOTE, 0x28); // ''' + MAP(SDLK_LEFTPAREN, 0xa); // '9' + MAP(SDLK_RIGHTPAREN, 0xb); // '0' + MAP(SDLK_ASTERISK, 0x9); // '8' + MAP(SDLK_PLUS, 0xd); // '=' + MAP(SDLK_COMMA, 0x33); + MAP(SDLK_MINUS, 0xc); + MAP(SDLK_PERIOD, 0x34); + MAP(SDLK_SLASH, 0x35); + MAP(SDLK_0, 0xb); + MAP(SDLK_1, 0x2); + MAP(SDLK_2, 0x3); + MAP(SDLK_3, 0x4); + MAP(SDLK_4, 0x5); + MAP(SDLK_5, 0x6); + MAP(SDLK_6, 0x7); + MAP(SDLK_7, 0x8); + MAP(SDLK_8, 0x9); + MAP(SDLK_9, 0xa); + MAP(SDLK_COLON, 0x27); + MAP(SDLK_SEMICOLON, 0x27); + MAP(SDLK_LESS, 0x33); + MAP(SDLK_EQUALS, 0xd); + MAP(SDLK_GREATER, 0x34); + MAP(SDLK_QUESTION, 0x35); + MAP(SDLK_AT, 0x3); // '2' + MAP(SDLK_LEFTBRACKET, 0x1a); + MAP(SDLK_BACKSLASH, 0x2b); + MAP(SDLK_RIGHTBRACKET, 0x1b); + MAP(SDLK_CARET, 0x7); // '7' + MAP(SDLK_UNDERSCORE, 0xc); + MAP(SDLK_BACKQUOTE, 0x29); + MAP(SDLK_a, 0x1e); + MAP(SDLK_b, 0x30); + MAP(SDLK_c, 0x2e); + MAP(SDLK_d, 0x20); + MAP(SDLK_e, 0x12); + MAP(SDLK_f, 0x21); + MAP(SDLK_g, 0x22); + MAP(SDLK_h, 0x23); + MAP(SDLK_i, 0x17); + MAP(SDLK_j, 0x24); + MAP(SDLK_k, 0x25); + MAP(SDLK_l, 0x26); + MAP(SDLK_m, 0x32); + MAP(SDLK_n, 0x31); + MAP(SDLK_o, 0x18); + MAP(SDLK_p, 0x19); + MAP(SDLK_q, 0x10); + MAP(SDLK_r, 0x13); + MAP(SDLK_s, 0x1f); + MAP(SDLK_t, 0x14); + MAP(SDLK_u, 0x16); + MAP(SDLK_v, 0x2f); + MAP(SDLK_w, 0x11); + MAP(SDLK_x, 0x2d); + MAP(SDLK_y, 0x15); + MAP(SDLK_z, 0x2c); + MAP(SDLK_DELETE, 0xd3); + MAP(SDLK_KP0, 0x52); + MAP(SDLK_KP1, 0x4f); + MAP(SDLK_KP2, 0x50); + MAP(SDLK_KP3, 0x51); + MAP(SDLK_KP4, 0x4b); + MAP(SDLK_KP5, 0x4c); + MAP(SDLK_KP6, 0x4d); + MAP(SDLK_KP7, 0x47); + MAP(SDLK_KP8, 0x48); + MAP(SDLK_KP9, 0x49); + MAP(SDLK_KP_PERIOD, 0x53); + MAP(SDLK_KP_DIVIDE, 0xb5); + MAP(SDLK_KP_MULTIPLY, 0x37); + MAP(SDLK_KP_MINUS, 0x4a); + MAP(SDLK_KP_PLUS, 0x4e); + MAP(SDLK_KP_ENTER, 0x9c); + //MAP(SDLK_KP_EQUALS, ); + MAP(SDLK_UP, 0xc8); + MAP(SDLK_DOWN, 0xd0); + MAP(SDLK_RIGHT, 0xcd); + MAP(SDLK_LEFT, 0xcb); + MAP(SDLK_INSERT, 0xd2); + MAP(SDLK_HOME, 0xc7); + MAP(SDLK_END, 0xcf); + MAP(SDLK_PAGEUP, 0xc9); + MAP(SDLK_PAGEDOWN, 0xd1); + MAP(SDLK_F1, 0x3b); + MAP(SDLK_F2, 0x3c); + MAP(SDLK_F3, 0x3d); + MAP(SDLK_F4, 0x3e); + MAP(SDLK_F5, 0x3f); + MAP(SDLK_F6, 0x40); + MAP(SDLK_F7, 0x41); + MAP(SDLK_F8, 0x42); + MAP(SDLK_F9, 0x43); + MAP(SDLK_F10, 0x44); + MAP(SDLK_F11, 0x57); + MAP(SDLK_F12, 0x58); + MAP(SDLK_NUMLOCK, 0x45); + MAP(SDLK_CAPSLOCK, 0x3a); + MAP(SDLK_SCROLLOCK, 0x46); + MAP(SDLK_RSHIFT, 0x36); + MAP(SDLK_LSHIFT, 0x2a); + MAP(SDLK_RCTRL, 0x9d); + MAP(SDLK_LCTRL, 0x1d); + MAP(SDLK_RALT, 0xb8); + MAP(SDLK_LALT, 0x38); + MAP(SDLK_LSUPER, 0xdb); // win l + MAP(SDLK_RSUPER, 0xdc); // win r + MAP(SDLK_PRINT, -2); // 0xaa + 0xb7 + MAP(SDLK_SYSREQ, 0x54); // alt+printscr + MAP(SDLK_BREAK, 0xb7); // ctrl+pause + MAP(SDLK_MENU, 0xdd); // win menu? +#undef MAP + + return 0; +} + +#undef main + +int main(int argc, char **argv) +{ + int i; + + buildkeytranslationtable(); + + for (i=0;i0) printf(", "); + if (i%8 == 7) printf("\n"); + printf("%d",keytranslation[i]); + } + + return 0; +} + diff --git a/polymer/build/src/mmulti.c b/polymer/build/src/mmulti.c new file mode 100644 index 000000000..88e0b63bc --- /dev/null +++ b/polymer/build/src/mmulti.c @@ -0,0 +1,641 @@ +#include +#include +#include + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#else +#include +#include +#ifndef __BEOS__ +#include +#endif +#ifdef __sun +#include +#endif +#include +#include +#include +#define SOCKET int +#define INVALID_HANDLE_VALUE (-1) +#define INVALID_SOCKET (-1) +#define SOCKET_ERROR (-1) +#define closesocket close +#define ioctlsocket ioctl +#define LPHOSTENT struct hostent * + +#include +static long GetTickCount(void) +{ + struct timeval tv; + long ti; + if (gettimeofday(&tv,NULL) < 0) return 0; + // tv is sec.usec, GTC gives msec + ti = tv.tv_sec * 1000; + ti += tv.tv_usec / 1000; + return ti; +} +#endif + +#ifdef KSFORBUILD +# include "baselayer.h" +# define printf initprintf +#endif + +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif + +#define MAXPLAYERS 16 +#define MAXPAKSIZ 256 //576 + + +#define PAKRATE 40 //Packet rate/sec limit ... necessary? +#define SIMMIS 0 //Release:0 Test:100 Packets per 256 missed. +#define SIMLAG 0 //Release:0 Test: 10 Packets to delay receipt +static long simlagcnt[MAXPLAYERS]; +static char simlagfif[MAXPLAYERS][SIMLAG+1][MAXPAKSIZ+2]; +#if ((SIMMIS != 0) || (SIMLAG != 0)) +#pragma message("\n\nWARNING! INTENTIONAL PACKET LOSS SIMULATION IS ENABLED!\nREMEMBER TO CHANGE SIMMIS&SIMLAG to 0 before RELEASE!\n\n") +#endif + +long myconnectindex, numplayers; +long connecthead, connectpoint2[MAXPLAYERS]; + +static long tims, lastsendtims[MAXPLAYERS]; +static char pakbuf[MAXPAKSIZ]; + +#define FIFSIZ 512 //16384/40 = 6min:49sec +static long ipak[MAXPLAYERS][FIFSIZ], icnt0[MAXPLAYERS]; +static long opak[MAXPLAYERS][FIFSIZ], ocnt0[MAXPLAYERS], ocnt1[MAXPLAYERS]; +static char pakmem[4194304]; static long pakmemi = 1; + +#define NETPORT 0x5bd9 +static SOCKET mysock; +static long myip, myport = NETPORT, otherip[MAXPLAYERS], otherport[MAXPLAYERS]; +static long snatchip = 0, snatchport = 0, danetmode = 255, netready = 0; + +void netuninit () +{ + if (mysock != (SOCKET)INVALID_HANDLE_VALUE) closesocket(mysock); +#ifdef _WIN32 + WSACleanup(); +#endif +} + +long netinit (long portnum) +{ + LPHOSTENT lpHostEnt; + char hostnam[256]; + struct sockaddr_in ip; + long i; + +#ifdef _WIN32 + WSADATA ws; + + if (WSAStartup(0x101,&ws) == SOCKET_ERROR) return(0); +#endif + + mysock = socket(AF_INET,SOCK_DGRAM,0); if (mysock == INVALID_SOCKET) return(0); +#ifdef __BEOS__ + i = 1; if (setsockopt(mysock,SOL_SOCKET,SO_NONBLOCK,&i,sizeof(i)) < 0) return(0); +#else + i = 1; if (ioctlsocket(mysock,FIONBIO,(unsigned long *)&i) == SOCKET_ERROR) return(0); +#endif + + ip.sin_family = AF_INET; + ip.sin_addr.s_addr = INADDR_ANY; + ip.sin_port = htons(portnum); + if (bind(mysock,(struct sockaddr *)&ip,sizeof(ip)) != SOCKET_ERROR) + { + myport = portnum; + if (gethostname(hostnam,sizeof(hostnam)) != SOCKET_ERROR) + if ((lpHostEnt = gethostbyname(hostnam))) + { + myip = ip.sin_addr.s_addr = *(long *)lpHostEnt->h_addr; + printf("mmulti: This machine's IP is %s\n", inet_ntoa(ip.sin_addr)); + } + return(1); + } + return(0); +} + +long netsend (long other, char *dabuf, long bufsiz) //0:buffer full... can't send +{ + struct sockaddr_in ip; + + if (!otherip[other]) return(0); + ip.sin_family = AF_INET; + ip.sin_addr.s_addr = otherip[other]; + ip.sin_port = otherport[other]; + return(sendto(mysock,dabuf,bufsiz,0,(struct sockaddr *)&ip,sizeof(struct sockaddr_in)) != SOCKET_ERROR); +} + +long netread (long *other, char *dabuf, long bufsiz) //0:no packets in buffer +{ + struct sockaddr_in ip; + long i; + + i = sizeof(ip); + if (recvfrom(mysock,dabuf,bufsiz,0,(struct sockaddr *)&ip,(int *)&i) == -1) return(0); +#if (SIMMIS > 0) + if ((rand()&255) < SIMMIS) return(0); +#endif + + snatchip = (long)ip.sin_addr.s_addr; snatchport = (long)ip.sin_port; + + (*other) = myconnectindex; + for(i=0;i 1) + i = simlagcnt[*other]%(SIMLAG+1); + *(short *)&simlagfif[*other][i][0] = bufsiz; memcpy(&simlagfif[*other][i][2],dabuf,bufsiz); + simlagcnt[*other]++; if (simlagcnt[*other] < SIMLAG+1) return(0); + i = simlagcnt[*other]%(SIMLAG+1); + bufsiz = *(short *)&simlagfif[*other][i][0]; memcpy(dabuf,&simlagfif[*other][i][2],bufsiz); +#endif + + return(1); +} + +long isvalidipaddress (char *st) +{ + long i, bcnt, num; + + bcnt = 0; num = 0; + for(i=0;st[i];i++) + { + if (st[i] == '.') { bcnt++; num = 0; continue; } + if (st[i] == ':') + { + if (bcnt != 3) return(0); + num = 0; + for(i++;st[i];i++) + { + if ((st[i] >= '0') && (st[i] <= '9')) + { num = num*10+st[i]-'0'; if (num >= 65536) return(0); } + else return(0); + } + return(1); + } + if ((st[i] >= '0') && (st[i] <= '9')) + { num = num*10+st[i]-'0'; if (num >= 256) return(0); } + + } + return(bcnt == 3); +} + +//---------------------------------- Obsolete variables&functions ---------------------------------- +char syncstate = 0; +void setpackettimeout (long datimeoutcount, long daresendagaincount) {} +void genericmultifunction (long other, char *bufptr, long messleng, long command) {} +long getoutputcirclesize () { return(0); } +void setsocket (long newsocket) { } +void flushpackets () {} +void sendlogon () {} +void sendlogoff () {} +//-------------------------------------------------------------------------------------------------- + +static long crctab16[256]; +static void initcrc16 () +{ + long i, j, k, a; + for(j=0;j<256;j++) + { + for(i=7,k=(j<<8),a=0;i>=0;i--,k=((k<<1)&65535)) + { + if ((k^a)&0x8000) a = ((a<<1)&65535)^0x1021; + else a = ((a<<1)&65535); + } + crctab16[j] = (a&65535); + } +} +#define updatecrc16(crc,dat) crc = (((crc<<8)&65535)^crctab16[((((unsigned short)crc)>>8)&65535)^dat]) +static unsigned short getcrc16 (char *buffer, long bufleng) +{ + long i, j; + + j = 0; + for(i=bufleng-1;i>=0;i--) updatecrc16(j,buffer[i]); + return((unsigned short)(j&65535)); +} + +void uninitmultiplayers () { netuninit(); } + +long getpacket(long *, char *); +static void initmultiplayers_reset(void) +{ + long i; + + initcrc16(); + memset(icnt0,0,sizeof(icnt0)); + memset(ocnt0,0,sizeof(ocnt0)); + memset(ocnt1,0,sizeof(ocnt1)); + memset(ipak,0,sizeof(ipak)); + //memset(opak,0,sizeof(opak)); //Don't need to init opak + //memset(pakmem,0,sizeof(pakmem)); //Don't need to init pakmem +#if (SIMLAG > 1) + memset(simlagcnt,0,sizeof(simlagcnt)); +#endif + + lastsendtims[0] = GetTickCount(); + for(i=1;i 0 && j<65535) portnum = j; + + printf("mmulti: Using port %ld\n", portnum); + } + } + + netinit(portnum); + + for(i=0;i= '0') && (argv[i][4] <= '9')) + { + numplayers = (argv[i][4]-'0'); + if ((argv[i][5] >= '0') && (argv[i][5] <= '9')) numplayers = numplayers*10+(argv[i][5]-'0'); + printf("mmulti: %ld-player game\n", numplayers); + } + printf("mmulti: Master-slave mode\n"); + } + else if (argv[i][2] == '1') + { + danetmode = 1; + myconnectindex = daindex; daindex++; + printf("mmulti: Peer-to-peer mode\n"); + } + continue; + } + else if ((argv[i][1] == 'P') || (argv[i][1] == 'p')) continue; + } + + st = strdup(argv[i]); if (!st) break; + if (isvalidipaddress(st)) + { + if ((danetmode == 1) && (daindex == myconnectindex)) daindex++; + for(j=0;st[j];j++) { + if (st[j] == ':') + { otherport[daindex] = htons((unsigned short)atol(&st[j+1])); st[j] = 0; break; } + } + otherip[daindex] = inet_addr(st); + printf("mmulti: Player %ld at %s:%d\n",daindex,st,ntohs(otherport[daindex])); + daindex++; + } + else + { + LPHOSTENT lph; + unsigned short pt = htons(NETPORT); + + for(j=0;st[j];j++) + if (st[j] == ':') + { pt = htons((unsigned short)atol(&st[j+1])); st[j] = 0; break; } + if ((lph = gethostbyname(st))) + { + if ((danetmode == 1) && (daindex == myconnectindex)) daindex++; + otherip[daindex] = *(long *)lph->h_addr; + otherport[daindex] = pt; + printf("mmulti: Player %ld at %s:%d (%s)\n",daindex, + inet_ntoa(*(struct in_addr *)lph->h_addr),ntohs(pt),argv[i]); + daindex++; + } else printf("mmulti: Failed resolving %s\n",argv[i]); + } + free(st); + } + if ((danetmode == 255) && (daindex)) { numplayers = 2; danetmode = 0; } //an IP w/o /n# defaults to /n0 + if ((numplayers >= 2) && (daindex) && (!danetmode)) myconnectindex = 1; + if (daindex > numplayers) numplayers = daindex; + + //for(i=0;i>8)&255,(otherip[i]>>16)&255,((unsigned long)otherip[i])>>24,ntohs(otherport[i])); + + connecthead = 0; + for(i=0;i= 2)) || (numplayers == 2)); +} + +long initmultiplayerscycle(void) +{ + long i, k; + + getpacket(&i,0); + + tims = GetTickCount(); + if (myconnectindex == connecthead) + { + for(i=numplayers-1;i>0;i--) + if (!otherip[i]) break; + if (!i) { + netready = 1; + return 0; + } + } + else + { + if (netready) return 0; + if (tims < lastsendtims[connecthead]) lastsendtims[connecthead] = tims; + if (tims >= lastsendtims[connecthead]+250) //1000/PAKRATE) + { + lastsendtims[connecthead] = tims; + + // short crc16ofs; //offset of crc16 + // long icnt0; //-1 (special packet for MMULTI.C's player collection) + // ... + // unsigned short crc16; //CRC16 of everything except crc16 + k = 2; + *(long *)&pakbuf[k] = -1; k += 4; + pakbuf[k++] = 0xaa; + *(unsigned short *)&pakbuf[0] = (unsigned short)k; + *(unsigned short *)&pakbuf[k] = getcrc16(pakbuf,k); k += 2; + netsend(connecthead,pakbuf,k); + } + } + + return 1; +} + +void initmultiplayers (long argc, char **argv, char damultioption, char dacomrateoption, char dapriority) +{ + long i, j, k, otims; + + if (initmultiplayersparms(argc,argv)) + { +#if 0 + //Console code seems to crash Win98 upon quitting game + //it's not necessary and it's not portable anyway + char tbuf[1024]; + unsigned long u; + HANDLE hconsout; + AllocConsole(); + SetConsoleTitle("Multiplayer status..."); + hconsout = GetStdHandle(STD_OUTPUT_HANDLE); + otims = 0; +#endif + while (initmultiplayerscycle()) + { +#if 0 + if ((tims < otims) || (tims > otims+100)) + { + otims = tims; + sprintf(tbuf,"\rWait for players (%d/%d): ",myconnectindex,numplayers); + for(i=0;i "); continue; } + if (!otherip[i]) { strcat(tbuf,"?.?.?.?:? "); continue; } + sprintf(&tbuf[strlen(tbuf)],"%d.%d.%d.%d:%04x ",otherip[i]&255,(otherip[i]>>8)&255,(otherip[i]>>16)&255,(((unsigned long)otherip[i])>>24),otherport[i]); + } + WriteConsole(hconsout,tbuf,strlen(tbuf),&u,0); + } + } + FreeConsole(); +#else + } +#endif + } + netready = 1; +} + +void dosendpackets (long other) +{ + long i, j, k; + + if (!otherip[other]) return; + + //Packet format: + // short crc16ofs; //offset of crc16 + // long icnt0; //earliest unacked packet + // char ibits[32]; //ack status of packets icnt0<=i>3)+k] |= (1<<((i-icnt0[other])&7)); + k += 32; + + while ((ocnt0[other] < ocnt1[other]) && (!opak[other][ocnt0[other]&(FIFSIZ-1)])) ocnt0[other]++; + for(i=ocnt0[other];i (long)sizeof(pakbuf)) break; + + *(unsigned short *)&pakbuf[k] = (unsigned short)j; k += 2; + *(long *)&pakbuf[k] = i; k += 4; + memcpy(&pakbuf[k],&pakmem[opak[other][i&(FIFSIZ-1)]+2],j); k += j; + } + *(unsigned short *)&pakbuf[k] = 0; k += 2; + *(unsigned short *)&pakbuf[0] = (unsigned short)k; + *(unsigned short *)&pakbuf[k] = getcrc16(pakbuf,k); k += 2; + + //printf("Send: "); for(i=0;i (long)sizeof(pakmem)) pakmemi = 1; + opak[other][ocnt1[other]&(FIFSIZ-1)] = pakmemi; + *(short *)&pakmem[pakmemi] = messleng; + memcpy(&pakmem[pakmemi+2],bufptr,messleng); pakmemi += messleng+2; + ocnt1[other]++; + + //printf("Send: "); for(i=0;i=0;i=connectpoint2[i]) + { + if (i != myconnectindex) dosendpackets(i); + if ((!danetmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + } + + while (netread(&other,pakbuf,sizeof(pakbuf))) + { + //Packet format: + // short crc16ofs; //offset of crc16 + // long icnt0; //earliest unacked packet + // char ibits[32]; //ack status of packets icnt0<=i>3)+k]&(1<<((i-ic0)&7))) + opak[other][i&(FIFSIZ-1)] = 0; + k += 32; + + messleng = (long)(*(unsigned short *)&pakbuf[k]); k += 2; + while (messleng) + { + j = *(long *)&pakbuf[k]; k += 4; + if ((j >= icnt0[other]) && (!ipak[other][j&(FIFSIZ-1)])) + { + if (pakmemi+messleng+2 > (long)sizeof(pakmem)) pakmemi = 1; + ipak[other][j&(FIFSIZ-1)] = pakmemi; + *(short *)&pakmem[pakmemi] = messleng; + memcpy(&pakmem[pakmemi+2],&pakbuf[k],messleng); pakmemi += messleng+2; + } + k += messleng; + messleng = (long)(*(unsigned short *)&pakbuf[k]); k += 2; + } + } + } + } + + //Return next valid packet from any player + if (!bufptr) return(0); + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (i != myconnectindex) + { + j = ipak[i][icnt0[i]&(FIFSIZ-1)]; + if (j) + { + messleng = *(short *)&pakmem[j]; memcpy(bufptr,&pakmem[j+2],messleng); + *retother = i; ipak[i][icnt0[i]&(FIFSIZ-1)] = 0; icnt0[i]++; + //printf("Recv: "); for(i=0;i k) { k = j; white = i; } + } + } + + printext256(4+(x<<3),4+(y<<3), white, -1, st, 0); +} + +static void _internal_drawosdstr(int x, int y, char *ch, int len, int shade, int pal) +{ + int i,j,k; + char st[1024]; + + if (len>1023) len=1023; + memcpy(st,ch,len); + st[len]=0; + + if (white<0) { + // find the palette index closest to white + k=0; + for(i=0;i<256;i++) + { + j = ((int)curpalette[i].r)+((int)curpalette[i].g)+((int)curpalette[i].b); + if (j > k) { k = j; white = i; } + } + } + + printext256(4+(x<<3),4+(y<<3), white, -1, st, 0); +} + +static void _internal_drawosdcursor(int x, int y, int type, int lastkeypress) +{ + int i,j,k; + char st[2] = { '_',0 }; + + if (type) st[0] = '#'; + + if (white<0) { + // find the palette index closest to white + k=0; + for(i=0;i<256;i++) + { + j = ((int)palette[i*3])+((int)palette[i*3+1])+((int)palette[i*3+2]); + if (j > k) { k = j; white = i; } + } + } + + printext256(4+(x<<3),4+(y<<3)+2, white, -1, st, 0); +} + +static int _internal_getcolumnwidth(int w) +{ + return w/8 - 1; +} + +static int _internal_getrowheight(int w) +{ + return w/8; +} + +static void _internal_clearbackground(int cols, int rows) +{ +} + +static int _internal_gettime(void) +{ + return 0; +} + +static void _internal_onshowosd(int a) +{ +} + +//////////////////////////// + +static int _internal_osdfunc_vars(const osdfuncparm_t *parm) +{ + int showval = (parm->numparms < 1); + + if (!Bstrcasecmp(parm->name, "osdrows")) { + if (showval) { OSD_Printf("osdrows is %d\n", osdrows); return OSDCMD_OK; } + else { + osdrows = atoi(parm->parms[0]); + if (osdrows < 1) osdrows = 1; + else if (osdrows > osdmaxrows) osdrows = osdmaxrows; + return OSDCMD_OK; + } + } + return OSDCMD_SHOWHELP; +} + +static int _internal_osdfunc_listsymbols(const osdfuncparm_t *parm) +{ + symbol_t *i; + + OSD_Printf("Symbol listing:\n"); + for (i=symbols; i!=NULL; i=i->next) + OSD_Printf(" %s\n", i->name); + + return OSDCMD_OK; +} + +static int _internal_osdfunc_help(const osdfuncparm_t *parm) +{ + symbol_t *symb; + + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + symb = findexactsymbol(parm->parms[0]); + if (!symb) { + OSD_Printf("Help Error: \"%s\" is not a defined variable or function\n", parm->parms[0]); + } else { + OSD_Printf("%s\n", symb->help); + } + + return OSDCMD_OK; +} + + + +//////////////////////////// + + +// +// OSD_Cleanup() -- Cleans up the on-screen display +// +void OSD_Cleanup(void) +{ + symbol_t *s; + + for (; symbols; symbols=s) { + s=symbols->next; + Bfree(symbols); + } + + osdinited=0; +} + + +// +// OSD_Init() -- Initialises the on-screen display +// +void OSD_Init(void) +{ + Bmemset(osdtext, 32, TEXTSIZE); + osdlines=1; + + osdinited=1; + + OSD_RegisterFunction("listsymbols","listsymbols: lists all the recognized symbols",_internal_osdfunc_listsymbols); + OSD_RegisterFunction("help","help: displays help on the named symbol",_internal_osdfunc_help); + OSD_RegisterFunction("osdrows","osdrows: sets the number of visible lines of the OSD",_internal_osdfunc_vars); + + atexit(OSD_Cleanup); +} + + +// +// OSD_SetLogFile() -- Sets the text file where printed text should be echoed +// +void OSD_SetLogFile(char *fn) +{ + if (osdlog) Bfclose(osdlog); + osdlog = NULL; + if (fn) osdlog = Bfopen(fn,"w"); + if (osdlog) setvbuf(osdlog, (char*)NULL, _IONBF, 0); +} + + +// +// OSD_SetFunctions() -- Sets some callbacks which the OSD uses to understand its world +// +void OSD_SetFunctions( + void (*drawchar)(int,int,char,int,int), + void (*drawstr)(int,int,char*,int,int,int), + void (*drawcursor)(int,int,int,int), + int (*colwidth)(int), + int (*rowheight)(int), + void (*clearbg)(int,int), + int (*gtime)(void), + void (*showosd)(int) + ) +{ + drawosdchar = drawchar; + drawosdstr = drawstr; + drawosdcursor = drawcursor; + getcolumnwidth = colwidth; + getrowheight = rowheight; + clearbackground = clearbg; + gettime = gtime; + onshowosd = showosd; + + if (!drawosdchar) drawosdchar = _internal_drawosdchar; + if (!drawosdstr) drawosdstr = _internal_drawosdstr; + if (!drawosdcursor) drawosdcursor = _internal_drawosdcursor; + if (!getcolumnwidth) getcolumnwidth = _internal_getcolumnwidth; + if (!getrowheight) getrowheight = _internal_getrowheight; + if (!clearbackground) clearbackground = _internal_clearbackground; + if (!gettime) gettime = _internal_gettime; + if (!onshowosd) onshowosd = _internal_onshowosd; +} + + +// +// OSD_SetParameters() -- Sets the parameters for presenting the text +// +void OSD_SetParameters( + int promptshade, int promptpal, + int editshade, int editpal, + int textshade, int textpal + ) +{ + osdpromptshade = promptshade; + osdpromptpal = promptpal; + osdeditshade = editshade; + osdeditpal = editpal; + osdtextshade = textshade; + osdtextpal = textpal; +} + + +// +// OSD_CaptureKey() -- Sets the scancode for the key which activates the onscreen display +// +void OSD_CaptureKey(int sc) +{ + osdkey = sc; +} + + +// +// OSD_HandleKey() -- Handles keyboard input when capturing input. +// Returns 0 if the key was handled internally, or the scancode if it should +// be passed on to the game. +// +int OSD_HandleKey(int sc, int press) +{ + char ch; + int i,j; + symbol_t *tabc = NULL; + static symbol_t *lastmatch = NULL; + + if (!osdinited) return sc; + + if (sc == osdkey) { + if (press) { + OSD_ShowDisplay(osdvisible ^ 1); + bflushchars(); + } + return 0;//sc; + } else if (!osdvisible) { + return sc; + } + + if (!press) { + if (sc == 42 || sc == 54) // shift + osdeditshift = 0; + if (sc == 29 || sc == 157) // control + osdeditcontrol = 0; + return 0;//sc; + } + + keytime = gettime(); + + if (sc != 15) lastmatch = NULL; // tab + + while ( (ch = bgetchar()) ) { + if (ch == 1) { // control a. jump to beginning of line + } else if (ch == 2) { // control b, move one character left + } else if (ch == 5) { // control e, jump to end of line + } else if (ch == 6) { // control f, move one character right + } else if (ch == 8 || ch == 127) { // control h, backspace + if (!osdeditcursor || !osdeditlen) return 0; + if (!osdovertype) { + if (osdeditcursor < osdeditlen) + Bmemmove(osdeditbuf+osdeditcursor-1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); + osdeditlen--; + } + osdeditcursor--; + if (osdeditcursor0;i--) if (osdeditbuf[i-1] == ' ') break; + for (j=0;osdeditbuf[i] != ' ' && i < osdeditlen;j++,i++) + osdedittmp[j] = osdeditbuf[i]; + osdedittmp[j] = 0; + + if (j > 0) + tabc = findsymbol(osdedittmp, NULL); + } else { + tabc = findsymbol(osdedittmp, lastmatch->next); + if (!tabc && lastmatch) + tabc = findsymbol(osdedittmp, NULL); // wrap + } + + if (tabc) { + for (i=osdeditcursor;i>0;i--) if (osdeditbuf[i-1] == ' ') break; + osdeditlen = i; + for (j=0;tabc->name[j] && osdeditlen <= EDITLENGTH;i++,j++,osdeditlen++) + osdeditbuf[i] = tabc->name[j]; + osdeditcursor = osdeditlen; + osdeditwinend = osdeditcursor; + osdeditwinstart = osdeditwinend-editlinewidth; + if (osdeditwinstart<0) { + osdeditwinstart=0; + osdeditwinend = editlinewidth; + } + + lastmatch = tabc; + } + } else if (ch == 11) { // control k, delete all to end of line + } else if (ch == 12) { // control l, clear screen + } else if (ch == 13) { // control m, enter + if (osdeditlen>0) { + osdeditbuf[osdeditlen] = 0; + Bmemmove(osdhistorybuf[1], osdhistorybuf[0], HISTORYDEPTH*(EDITLENGTH+1)); + Bmemmove(osdhistorybuf[0], osdeditbuf, EDITLENGTH+1); + if (osdhistorysize < HISTORYDEPTH) osdhistorysize++; + if (osdexeccount == HISTORYDEPTH) + OSD_Printf("Command Buffer Warning: Failed queueing command " + "for execution. Buffer full.\n"); + else + osdexeccount++; + osdhistorypos=-1; + } + + osdeditlen=0; + osdeditcursor=0; + osdeditwinstart=0; + osdeditwinend=editlinewidth; + } else if (ch == 16) { // control p, previous (ie. up arrow) + } else if (ch == 20) { // control t, swap previous two chars + } else if (ch == 21) { // control u, delete all to beginning + if (osdeditcursor>0 && osdeditlen) { + if (osdeditcursor0 && osdeditlen>0) { + i=osdeditcursor; + while (i>0 && osdeditbuf[i-1]==32) i--; + while (i>0 && osdeditbuf[i-1]!=32) i--; + if (osdeditcursor= 32) { // text char + if (!osdovertype && osdeditlen == EDITLENGTH) // buffer full, can't insert another char + return 0; + + if (!osdovertype) { + if (osdeditcursor < osdeditlen) + Bmemmove(osdeditbuf+osdeditcursor+1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); + osdeditlen++; + } else { + if (osdeditcursor == osdeditlen) + osdeditlen++; + } + osdeditbuf[osdeditcursor] = ch; + osdeditcursor++; + if (osdeditcursor>osdeditwinend) osdeditwinstart++,osdeditwinend++; + } + } + + if (sc == 15) { // tab + } else if (sc == 1) { // escape + OSD_ShowDisplay(0); + } else if (sc == 201) { // page up + if (osdhead < osdlines-1) + osdhead++; + } else if (sc == 209) { // page down + if (osdhead > 0) + osdhead--; + } else if (sc == 199) { // home + if (osdeditcontrol) { + osdhead = osdlines-1; + } else { + osdeditcursor = 0; + osdeditwinstart = osdeditcursor; + osdeditwinend = osdeditwinstart+editlinewidth; + } + } else if (sc == 207) { // end + if (osdeditcontrol) { + osdhead = 0; + } else { + osdeditcursor = osdeditlen; + osdeditwinend = osdeditcursor; + osdeditwinstart = osdeditwinend-editlinewidth; + if (osdeditwinstart<0) { + osdeditwinstart=0; + osdeditwinend = editlinewidth; + } + } + } else if (sc == 210) { // insert + osdovertype ^= 1; + } else if (sc == 203) { // left + if (osdeditcursor>0) { + if (osdeditcontrol) { + while (osdeditcursor>0) { + if (osdeditbuf[osdeditcursor-1] != 32) break; + osdeditcursor--; + } + while (osdeditcursor>0) { + if (osdeditbuf[osdeditcursor-1] == 32) break; + osdeditcursor--; + } + } else osdeditcursor--; + } + if (osdeditcursor=osdeditwinend) + osdeditwinstart+=(osdeditcursor-osdeditwinend), + osdeditwinend+=(osdeditcursor-osdeditwinend); + } else if (sc == 200) { // up + if (osdhistorypos < osdhistorysize-1) { + osdhistorypos++; + memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); + osdeditlen = osdeditcursor = 0; + while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; + if (osdeditcursor=osdeditwinend) + osdeditwinstart+=(osdeditcursor-osdeditwinend), + osdeditwinend+=(osdeditcursor-osdeditwinend); + } + } else if (sc == 208) { // down + if (osdhistorypos >= 0) { + if (osdhistorypos == 0) { + osdeditlen=0; + osdeditcursor=0; + osdeditwinstart=0; + osdeditwinend=editlinewidth; + osdhistorypos = -1; + } else { + osdhistorypos--; + memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); + osdeditlen = osdeditcursor = 0; + while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; + if (osdeditcursor=osdeditwinend) + osdeditwinstart+=(osdeditcursor-osdeditwinend), + osdeditwinend+=(osdeditcursor-osdeditwinend); + } + } + } else if (sc == 42 || sc == 54) { // shift + osdeditshift = 1; + } else if (sc == 29 || sc == 157) { // control + osdeditcontrol = 1; + } else if (sc == 58) { // capslock + osdeditcaps ^= 1; + } else if (sc == 28 || sc == 156) { // enter + } else if (sc == 14) { // backspace + } else if (sc == 211) { // delete + if (osdeditcursor == osdeditlen || !osdeditlen) return 0; + if (osdeditcursor <= osdeditlen-1) Bmemmove(osdeditbuf+osdeditcursor, osdeditbuf+osdeditcursor+1, osdeditlen-osdeditcursor-1); + osdeditlen--; + } + + return 0; +} + + +// +// OSD_ResizeDisplay() -- Handles readjustment of the display when the screen resolution +// changes on us. +// +void OSD_ResizeDisplay(int w, int h) +{ + int newcols; + int newmaxlines; + char newtext[TEXTSIZE]; + int i,j,k; + + newcols = getcolumnwidth(w); + newmaxlines = TEXTSIZE / newcols; + + j = min(newmaxlines, osdmaxlines); + k = min(newcols, osdcols); + + memset(newtext, 32, TEXTSIZE); + for (i=0;i osdmaxrows) osdrows = osdmaxrows; + + osdpos = 0; + osdhead = 0; + osdeditwinstart = 0; + osdeditwinend = editlinewidth; + white = -1; +} + + +// +// OSD_ShowDisplay() -- Shows or hides the onscreen display +// +void OSD_ShowDisplay(int onf) +{ + osdvisible = (onf != 0); + osdeditcontrol = 0; + osdeditshift = 0; + + grabmouse(osdvisible == 0); + onshowosd(osdvisible); + if (osdvisible) releaseallbuttons(); +} + + +// +// OSD_Draw() -- Draw the onscreen display +// +void OSD_Draw(void) +{ + unsigned topoffs; + int row, lines, x, len; + + if (!osdvisible || !osdinited) return; + + topoffs = osdhead * osdcols; + row = osdrows-1; + lines = min( osdlines-osdhead, osdrows ); + + begindrawing(); + + clearbackground(osdcols,osdrows+1); + + for (; lines>0; lines--, row--) { + drawosdstr(0,row,osdtext+topoffs,osdcols,osdtextshade,osdtextpal); + topoffs+=osdcols; + } + + drawosdchar(2,osdrows,'>',osdpromptshade,osdpromptpal); + if (osdeditcaps) drawosdchar(0,osdrows,'C',osdpromptshade,osdpromptpal); + if (osdeditshift) drawosdchar(1,osdrows,'H',osdpromptshade,osdpromptpal); + + len = min(osdcols-1-3, osdeditlen-osdeditwinstart); + for (x=0; x=0; cmd--) { + OSD_Dispatch((const char *)osdhistorybuf[cmd]); + } +} + + +// +// OSD_Dispatch() -- Executes a command string +// + +static char *strtoken(char *s, char **ptrptr, int *restart) +{ + char *p, *p2, *start; + + *restart = 0; + if (!ptrptr) return NULL; + + // if s != NULL, we process from the start of s, otherwise + // we just continue with where ptrptr points to + if (s) p = s; + else p = *ptrptr; + + if (!p) return NULL; + + // eat up any leading whitespace + while (*p != 0 && *p != ';' && *p == ' ') p++; + + // a semicolon is an end of statement delimiter like a \0 is, so we signal + // the caller to 'restart' for the rest of the string pointed at by *ptrptr + if (*p == ';') { + *restart = 1; + *ptrptr = p+1; + return NULL; + } + // or if we hit the end of the input, signal all done by nulling *ptrptr + else if (*p == 0) { + *ptrptr = NULL; + return NULL; + } + + if (*p == '\"') { + // quoted string + start = ++p; + p2 = p; + while (*p != 0) { + if (*p == '\"') { + p++; + break; + } else if (*p == '\\') { + switch (*(++p)) { + case 'n': *p2 = '\n'; break; + case 'r': *p2 = '\r'; break; + default: *p2 = *p; break; + } + } else { + *p2 = *p; + } + p2++, p++; + } + *p2 = 0; + } else { + start = p; + while (*p != 0 && *p != ';' && *p != ' ') p++; + } + + // if we hit the end of input, signal all done by nulling *ptrptr + if (*p == 0) { + *ptrptr = NULL; + } + // or if we came upon a semicolon, signal caller to restart with the + // string at *ptrptr + else if (*p == ';') { + *p = 0; + *ptrptr = p+1; + *restart = 1; + } + // otherwise, clip off the token and carry on + else { + *(p++) = 0; + *ptrptr = p; + } + + return start; +} + +#define MAXPARMS 512 +int OSD_Dispatch(const char *cmd) +{ + char *workbuf, *wp, *wtp, *state; + char *parms[MAXPARMS]; + int numparms, restart = 0; + osdfuncparm_t ofp; + symbol_t *symb; + //int i; + + workbuf = state = Bstrdup(cmd); + if (!workbuf) return -1; + + do { + numparms = 0; + Bmemset(parms, 0, sizeof(parms)); + wp = strtoken(state, &wtp, &restart); + if (!wp) { + state = wtp; + continue; + } + + symb = findexactsymbol(wp); + if (!symb) { + OSD_Printf("Error: \"%s\" is not defined\n", wp); + free(workbuf); + return -1; + } + + ofp.name = wp; + while (wtp && !restart) { + wp = strtoken(NULL, &wtp, &restart); + if (wp && numparms < MAXPARMS) parms[numparms++] = wp; + } + ofp.numparms = numparms; + ofp.parms = (const char **)parms; + ofp.raw = cmd; + switch (symb->func(&ofp)) { + case OSDCMD_OK: break; + case OSDCMD_SHOWHELP: OSD_Printf("%s\n", symb->help); break; + } + + state = wtp; + } while (wtp && restart); + + free(workbuf); + + return 0; +} + + +// +// OSD_RegisterFunction() -- Registers a new function +// +int OSD_RegisterFunction(const char *name, const char *help, int (*func)(const osdfuncparm_t*)) +{ + symbol_t *symb; + const char *cp; + + if (!osdinited) OSD_Init(); + + if (!name) { + Bprintf("OSD_RegisterFunction(): may not register a function with a null name\n"); + return -1; + } + if (!name[0]) { + Bprintf("OSD_RegisterFunction(): may not register a function with no name\n"); + return -1; + } + + // check for illegal characters in name + for (cp = name; *cp; cp++) { + if ((cp == name) && (*cp >= '0') && (*cp <= '9')) { + Bprintf("OSD_RegisterFunction(): first character of function name \"%s\" must not be a numeral\n", name); + return -1; + } + if ((*cp < '0') || + (*cp > '9' && *cp < 'A') || + (*cp > 'Z' && *cp < 'a' && *cp != '_') || + (*cp > 'z')) { + Bprintf("OSD_RegisterFunction(): illegal character in function name \"%s\"\n", name); + return -1; + } + } + + if (!help) help = "(no description for this function)"; + if (!func) { + Bprintf("OSD_RegisterFunction(): may not register a null function\n"); + return -1; + } + + symb = findexactsymbol(name); + if (symb) { + Bprintf("OSD_RegisterFunction(): \"%s\" is already defined\n", name); + return -1; + } + + symb = addnewsymbol(name); + if (!symb) { + Bprintf("OSD_RegisterFunction(): Failed registering function \"%s\"\n", name); + return -1; + } + + symb->name = name; + symb->help = help; + symb->func = func; + + return 0; +} + + +// +// addnewsymbol() -- Allocates space for a new symbol and attaches it +// appropriately to the lists, sorted. +// +static symbol_t *addnewsymbol(const char *name) +{ + symbol_t *newsymb, *s, *t; + + newsymb = (symbol_t *)Bmalloc(sizeof(symbol_t)); + if (!newsymb) { return NULL; } + Bmemset(newsymb, 0, sizeof(symbol_t)); + + // link it to the main chain + if (!symbols) { + symbols = newsymb; + } else { + if (Bstrcasecmp(name, symbols->name) <= 0) { + t = symbols; + symbols = newsymb; + symbols->next = t; + } else { + s = symbols; + while (s->next) { + if (Bstrcasecmp(s->next->name, name) > 0) break; + s=s->next; + } + t = s->next; + s->next = newsymb; + newsymb->next = t; + } + } + + return newsymb; +} + + +// +// findsymbol() -- Finds a symbol, possibly partially named +// +static symbol_t *findsymbol(const char *name, symbol_t *startingat) +{ + if (!startingat) startingat = symbols; + if (!startingat) return NULL; + + for (; startingat; startingat=startingat->next) + if (!Bstrncasecmp(name, startingat->name, Bstrlen(name))) return startingat; + + return NULL; +} + + +// +// findexactsymbol() -- Finds a symbol, complete named +// +static symbol_t *findexactsymbol(const char *name) +{ + symbol_t *startingat; + if (!symbols) return NULL; + + startingat = symbols; + + for (; startingat; startingat=startingat->next) + if (!Bstrcasecmp(name, startingat->name)) return startingat; + + return NULL; +} + diff --git a/polymer/build/src/osxbits.m b/polymer/build/src/osxbits.m new file mode 100644 index 000000000..781dc4b1f --- /dev/null +++ b/polymer/build/src/osxbits.m @@ -0,0 +1,37 @@ +#include "osxbits.h" +#include + +int osx_msgbox(char *name, char *msg) +{ + NSAlert *alert = [[NSAlert alloc] init]; + NSString *mmsg = [[NSString alloc] initWithCString: msg]; + [alert addButtonWithTitle: @"OK"]; + [alert setMessageText: mmsg]; + [alert setAlertStyle: NSInformationalAlertStyle]; + + [alert runModal]; + + [alert release]; + [mmsg release]; + + return 0; +} + +int osx_ynbox(char *name, char *msg) +{ + NSAlert *alert = [[NSAlert alloc] init]; + NSString *mmsg = [[NSString alloc] initWithCString: msg]; + int r; + + [alert addButtonWithTitle:@"Yes"]; + [alert addButtonWithTitle:@"No"]; + [alert setMessageText: mmsg]; + [alert setAlertStyle: NSInformationalAlertStyle]; + + r = ([alert runModal] == NSAlertFirstButtonReturn); + + [alert release]; + [mmsg release]; + + return r; +} diff --git a/polymer/build/src/polymost.c b/polymer/build/src/polymost.c new file mode 100644 index 000000000..3ea5db812 --- /dev/null +++ b/polymer/build/src/polymost.c @@ -0,0 +1,5103 @@ +/************************************************************************************************** +"POLYMOST" code written by Ken Silverman +Ken Silverman's official web site: http://www.advsys.net/ken + +Motivation: +When 3D Realms released the Duke Nukem 3D source code, I thought somebody would do a OpenGL or +Direct3D port. Well, after a few months passed, I saw no sign of somebody working on a true +hardware-accelerated port of Build, just people saying it wasn't possible. Eventually, I realized +the only way this was going to happen was for me to do it myself. First, I needed to port Build to +Windows. I could have done it myself, but instead I thought I'd ask my Australian buddy, Jonathon +Fowler, if he would upgrade his Windows port to my favorite compiler (MSVC) - which he did. Once +that was done, I was ready to start the "POLYMOST" project. + +About: +This source file is basically a complete rewrite of the entire rendering part of the Build engine. +There are small pieces in ENGINE.C to activate this code, and other minor hacks in other source +files, but most of it is in here. If you're looking for polymost-related code in the other source +files, you should find most of them by searching for either "polymost" or "rendmode". Speaking of +rendmode, there are now 4 rendering modes in Build: + + rendmode 0: The original code I wrote from 1993-1997 + rendmode 1: Solid-color rendering: my debug code before I did texture mapping + rendmode 2: Software rendering before I started the OpenGL code (Note: this is just a quick + hack to make testing easier - it's not optimized to my usual standards!) + rendmode 3: The OpenGL code + +The original Build engine did hidden surface removal by using a vertical span buffer on the tops +and bottoms of walls. This worked nice back in the day, but it it's not suitable for a polygon +engine. So I decided to write a brand new hidden surface removal algorithm - using the same idea +as the original Build - but one that worked with vectors instead of already rasterized data. + +Brief history: +06/20/2000: I release Build Source code +04/01/2003: 3D Realms releases Duke Nukem 3D source code +10/04/2003: Jonathon Fowler gets his Windows port working in Visual C +10/04/2003: I start writing POLYMOST.BAS, a new hidden surface removal algorithm for Build that + works on a polygon level instead of spans. +10/16/2003: Ported POLYMOST.BAS to C inside JonoF KenBuild's ENGINE.C; later this code was split + out of ENGINE.C and put in this file, POLYMOST.C. +12/10/2003: Started OpenGL code for POLYMOST (rendmode 3) +12/23/2003: 1st public release +01/01/2004: 2nd public release: fixed stray lines, status bar, mirrors, sky, and lots of other bugs. + +---------------------------------------------------------------------------------------------------- + +Todo list (in approximate chronological order): + +High priority: + * BOTH: Do accurate software sorting/chopping for sprites: drawing in wrong order is bad :/ + * BOTH: Fix hall of mirrors near "zenith". Call polymost_drawrooms twice? + * OPENGL: drawmapview() + +Low priority: + * SOFT6D: Do back-face culling of sprites during up/down/tilt transformation (top of drawpoly) + * SOFT6D: Fix depth shading: use saturation&LUT + * SOFT6D: Optimize using hyperbolic mapping (similar to KUBE algo) + * SOFT6D: Slab6-style voxel sprites. How to accelerate? :/ + * OPENGL: KENBUILD: Write flipping code for floor mirrors + * BOTH: KENBUILD: Parallaxing sky modes 1&2 + * BOTH: Masked/1-way walls don't clip correctly to sectors of intersecting ceiling/floor slopes + * BOTH: Editart x-center is not working correctly with Duke's camera/turret sprites + * BOTH: Get rid of horizontal line above Duke full-screen status bar + * BOTH: Combine ceilings/floors into a single triangle strip (should lower poly count by 2x) + * BOTH: Optimize/clean up texture-map setup equations + +**************************************************************************************************/ + +static long animateoffs(short tilenum, short fakevar); +long rendmode = 0; +long usemodels=1, usehightile=1; + + +#include //<-important! +typedef struct { float x, cy[2], fy[2]; long n, p, tag, ctag, ftag; } vsptyp; +#define VSPMAX 4096 //<- careful! +static vsptyp vsp[VSPMAX]; +static long vcnt, gtag; + +static double dxb1[MAXWALLSB], dxb2[MAXWALLSB]; + +#define SCISDIST 1.0 //1.0: Close plane clipping distance +#define USEZBUFFER 1 //1:use zbuffer (slow, nice sprite rendering), 0:no zbuffer (fast, bad sprite rendering) +#define LINTERPSIZ 4 //log2 of interpolation size. 4:pretty fast&acceptable quality, 0:best quality/slow! +#define DEPTHDEBUG 0 //1:render distance instead of texture, for debugging only!, 0:default +#define FOGSCALE 0.0000384 +#define PI 3.14159265358979323 + +static double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz; +static double gcosang, gsinang, gcosang2, gsinang2; +static double gchang, gshang, gctang, gstang, gvisibility; +static float gtang = 0.0; +double guo, gux, guy; //Screen-based texture mapping parameters +double gvo, gvx, gvy; +double gdo, gdx, gdy; + +#if (USEZBUFFER != 0) +long zbufmem = 0, zbufysiz = 0, zbufbpl = 0, *zbufoff = 0; +#endif + +#ifdef USE_OPENGL +long glredbluemode = 0; +static long lastglredbluemode = 0, redblueclearcnt = 0; + +static struct glfiltermodes { + char *name; + long min,mag; +} glfiltermodes[] = { + {"GL_NEAREST",GL_NEAREST,GL_NEAREST}, + {"GL_LINEAR",GL_LINEAR,GL_LINEAR}, + {"GL_NEAREST_MIPMAP_NEAREST",GL_NEAREST_MIPMAP_NEAREST,GL_NEAREST}, + {"GL_LINEAR_MIPMAP_NEAREST",GL_LINEAR_MIPMAP_NEAREST,GL_LINEAR}, + {"GL_NEAREST_MIPMAP_LINEAR",GL_NEAREST_MIPMAP_LINEAR,GL_NEAREST}, + {"GL_LINEAR_MIPMAP_LINEAR",GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR} +}; +#define numglfiltermodes (sizeof(glfiltermodes)/sizeof(glfiltermodes[0])) + +long glanisotropy = 1; // 0 = maximum supported by card +long glusetexcompr = 1; +long gltexfiltermode = 3; // GL_LINEAR_MIPMAP_NEAREST +long glusetexcache = 0; +long glusetexcachecompression = 1; +long glmultisample = 0, glnvmultisamplehint = 0; +long gltexmaxsize = 0; // 0 means autodetection on first run +long gltexmiplevel = 0; // discards this many mipmap levels +static long lastglpolygonmode = 0; //FUK +long glpolygonmode = 0; // 0:GL_FILL,1:GL_LINE,2:GL_POINT //FUK +static GLuint polymosttext = 0; +extern char nofog; +#endif + +#if defined(USE_MSC_PRAGMAS) +static inline void ftol (float f, long *a) +{ + _asm + { + mov eax, a + fld f + fistp dword ptr [eax] + } +} + +static inline void dtol (double d, long *a) +{ + _asm + { + mov eax, a + fld d + fistp dword ptr [eax] + } +} +#elif defined(USE_WATCOM_PRAGMAS) + +#pragma aux ftol =\ + "fistp dword ptr [eax]",\ + parm [eax 8087] +#pragma aux dtol =\ + "fistp dword ptr [eax]",\ + parm [eax 8087] + +#elif defined(USE_GCC_PRAGMAS) + +static inline void ftol (float f, long *a) +{ + __asm__ __volatile__ ( +#if 0 //(__GNUC__ >= 3) + "flds %1; fistpl %0;" +#else + "flds %1; fistpl (%0);" +#endif + : "=r" (a) : "m" (f) : "memory","cc"); +} + +static inline void dtol (double d, long *a) +{ + __asm__ __volatile__ ( +#if 0 //(__GNUC__ >= 3) + "fldl %1; fistpl %0;" +#else + "fldl %1; fistpl (%0);" +#endif + : "=r" (a) : "m" (d) : "memory","cc"); +} + +#else +static inline void ftol (float f, long *a) +{ + *a = (long)f; +} + +static inline void dtol (double d, long *a) +{ + *a = (long)d; +} +#endif + +static inline long imod (long a, long b) +{ + if (a >= 0) return(a%b); + return(((a+1)%b)+b-1); +} + +void drawline2d (float x0, float y0, float x1, float y1, char col) +{ + float f, dx, dy, fxres, fyres; + long e, inc, x, y; + unsigned long up16; + + dx = x1-x0; dy = y1-y0; if ((dx == 0) && (dy == 0)) return; + fxres = (float)xdimen; fyres = (float)ydimen; + if (x0 >= fxres) { if (x1 >= fxres) return; y0 += (fxres-x0)*dy/dx; x0 = fxres; } + else if (x0 < 0) { if (x1 < 0) return; y0 += ( 0-x0)*dy/dx; x0 = 0; } + if (x1 >= fxres) { y1 += (fxres-x1)*dy/dx; x1 = fxres; } + else if (x1 < 0) { y1 += ( 0-x1)*dy/dx; x1 = 0; } + if (y0 >= fyres) { if (y1 >= fyres) return; x0 += (fyres-y0)*dx/dy; y0 = fyres; } + else if (y0 < 0) { if (y1 < 0) return; x0 += ( 0-y0)*dx/dy; y0 = 0; } + if (y1 >= fyres) { x1 += (fyres-y1)*dx/dy; y1 = fyres; } + else if (y1 < 0) { x1 += ( 0-y1)*dx/dy; y1 = 0; } + + if (fabs(dx) > fabs(dy)) + { + if (x0 > x1) { f = x0; x0 = x1; x1 = f; f = y0; y0 = y1; y1 = f; } + y = (long)(y0*65536.f)+32768; + inc = (long)(dy/dx*65536.f+.5f); + x = (long)(x0+.5); if (x < 0) { y -= inc*x; x = 0; } //if for safety + e = (long)(x1+.5); if (e > xdimen) e = xdimen; //if for safety + up16 = (ydimen<<16); + for(;x>16]+x+frameoffset) = col; + } + else + { + if (y0 > y1) { f = x0; x0 = x1; x1 = f; f = y0; y0 = y1; y1 = f; } + x = (long)(x0*65536.f)+32768; + inc = (long)(dx/dy*65536.f+.5f); + y = (long)(y0+.5); if (y < 0) { x -= inc*y; y = 0; } //if for safety + e = (long)(y1+.5); if (e > ydimen) e = ydimen; //if for safety + up16 = (xdimen<<16); + for(;y>16)+frameoffset) = col; + } +} + +#ifdef USE_OPENGL +typedef struct { unsigned char r, g, b, a; } coltype; + +static void uploadtexture(long doalloc, long xsiz, long ysiz, long intexfmt, long texfmt, coltype *pic, long tsizx, long tsizy, long dameth); + +#include "md4.h" + +#define USELZF +#define USEKENFILTER 1 + +#ifdef USELZF +# include "lzf.h" +#else +# include "lzwnew.h" +#endif + +static char TEXCACHEDIR[] = "texcache"; +typedef struct { + char magic[8]; // 'Polymost' + long xdim, ydim; // of image, unpadded + long flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed +} texcacheheader; +typedef struct { + long size; + long format; + long xdim, ydim; // of mipmap (possibly padded) + long border, depth; +} texcachepicture; + +int dxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, unsigned long miplen); +int dedxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, int ispacked); + +static inline void phex(unsigned char v, char *s); +void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *head); + +static long mdtims, omdtims; +float alphahackarray[MAXTILES]; +#include "mdsprite.c" + +//-------------------------------------------------------------------------------------------------- +//TEXTURE MANAGEMENT: treats same texture with different .PAL as a separate texture. This makes the +// max number of virtual textures very large (MAXTILES*256). Instead of allocating a handle for +// every virtual texture, I use a cache where indexing is managed through a hash table. +// + +typedef struct pthtyp_t +{ + struct pthtyp_t *next; + GLuint glpic; + short picnum; + char palnum; + char effects; + char flags; // 1 = clamped (dameth&4), 2 = hightile, 4 = skybox face, 8 = hasalpha, 128 = invalidated + char skyface; + hicreplctyp *hicr; + + unsigned short sizx, sizy; + float scalex, scaley; +} pthtyp; + +#define GLTEXCACHEADSIZ 8192 +static pthtyp *gltexcachead[GLTEXCACHEADSIZ]; + +static long drawingskybox = 0; + +int gloadtile_art(long,long,long,pthtyp*,long); +int gloadtile_hi(long,long,hicreplctyp*,long,pthtyp*,long,char); +static int hicprecaching = 0; +static pthtyp * gltexcache (long dapicnum, long dapalnum, long dameth) +{ + long i, j; + hicreplctyp *si; + pthtyp *pth; + + j = (dapicnum&(GLTEXCACHEADSIZ-1)); + + if (usehightile) si = hicfindsubst(dapicnum,dapalnum,drawingskybox); + else si = NULL; + if (!si) { + if (drawingskybox) return NULL; + goto tryart; + } + + /* if palette > 0 && replacement found + * no effects are applied to the texture + * else if palette > 0 && no replacement found + * effects are applied to the palette 0 texture if it exists + */ + + // load a replacement + for(pth=gltexcachead[j]; pth; pth=pth->next) { + if (pth->picnum == dapicnum && + pth->palnum == si->palnum && + (si->palnum>0 ? 1 : (pth->effects == hictinting[dapalnum].f)) && + (pth->flags & (1+2+4)) == (((dameth&4)>>2)+2+((drawingskybox>0)<<2)) && + (drawingskybox>0 ? (pth->skyface == drawingskybox) : 1) + ) + { + if (pth->flags & 128) + { + pth->flags &= ~128; + if (gloadtile_hi(dapicnum,drawingskybox,si,dameth,pth,0, + (si->palnum>0) ? 0 : hictinting[dapalnum].f)) { // reload tile + if (drawingskybox) return NULL; + goto tryart; // failed, so try for ART + } + } + return(pth); + } + } + + pth = (pthtyp *)calloc(1,sizeof(pthtyp)); + if (!pth) return NULL; + + if (gloadtile_hi(dapicnum,drawingskybox,si,dameth,pth,1, (si->palnum>0) ? 0 : hictinting[dapalnum].f)) { + free(pth); + if (drawingskybox) return NULL; + goto tryart; // failed, so try for ART + } + pth->palnum = si->palnum; + pth->next = gltexcachead[j]; + gltexcachead[j] = pth; + return(pth); + +tryart: + if (hicprecaching) return NULL; + + // load from art + for(pth=gltexcachead[j]; pth; pth=pth->next) + if (pth->picnum == dapicnum && + pth->palnum == dapalnum && + (pth->flags & (1+2)) == ((dameth&4)>>2) + ) + { + if (pth->flags & 128) + { + pth->flags &= ~128; + if (gloadtile_art(dapicnum,dapalnum,dameth,pth,0)) return NULL; //reload tile (for animations) + } + return(pth); + } + + pth = (pthtyp *)calloc(1,sizeof(pthtyp)); + if (!pth) return NULL; + + if (gloadtile_art(dapicnum,dapalnum,dameth,pth,1)) { + free(pth); + return NULL; + } + pth->next = gltexcachead[j]; + gltexcachead[j] = pth; + return(pth); +} + +long gltexmayhavealpha (long dapicnum, long dapalnum) +{ + long j = (dapicnum&(GLTEXCACHEADSIZ-1)); + pthtyp *pth; + + for(pth=gltexcachead[j]; pth; pth=pth->next) + if ((pth->picnum == dapicnum) && (pth->palnum == dapalnum)) + return((pth->flags&8) != 0); + return(1); +} + +void gltexinvalidate (long dapicnum, long dapalnum, long dameth) +{ + long i, j; + pthtyp *pth; + + j = (dapicnum&(GLTEXCACHEADSIZ-1)); + for(pth=gltexcachead[j]; pth; pth=pth->next) + if (pth->picnum == dapicnum && pth->palnum == dapalnum && (pth->flags & 1) == ((dameth&4)>>2) ) + { pth->flags |= 128; } +} + + //Make all textures "dirty" so they reload, but not re-allocate + //This should be much faster than polymost_glreset() + //Use this for palette effects ... but not ones that change every frame! +void gltexinvalidateall () +{ + long j; + pthtyp *pth; + + for(j=GLTEXCACHEADSIZ-1;j>=0;j--) + for(pth=gltexcachead[j];pth;pth=pth->next) + pth->flags |= 128; + clearskins(); +#ifdef DEBUGGINGAIDS + OSD_Printf("gltexinvalidateall()\n"); +#endif +} + + +void gltexapplyprops (void) +{ + long i; + pthtyp *pth; + + if (glinfo.maxanisotropy > 1.0) + { + if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) glanisotropy = (long)glinfo.maxanisotropy; + } + + if (gltexfiltermode < 0) gltexfiltermode = 0; + else if (gltexfiltermode >= (long)numglfiltermodes) gltexfiltermode = numglfiltermodes-1; + for(i=GLTEXCACHEADSIZ-1;i>=0;i--) { + for(pth=gltexcachead[i];pth;pth=pth->next) { + bglBindTexture(GL_TEXTURE_2D,pth->glpic); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); + if (glinfo.maxanisotropy > 1.0) + bglTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,glanisotropy); + } + } + + { + int j; + mdskinmap_t *sk; + md2model *m; + + for (i=0;imdnum < 2) continue; + for (j=0;jnumskins*(HICEFFECTMASK+1);j++) + { + if (!m->texid[j]) continue; + bglBindTexture(GL_TEXTURE_2D,m->texid[j]); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); + if (glinfo.maxanisotropy > 1.0) + bglTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,glanisotropy); + } + + for (sk=m->skinmap;sk;sk=sk->next) + for (j=0;j<(HICEFFECTMASK+1);j++) + { + if (!sk->texid[j]) continue; + bglBindTexture(GL_TEXTURE_2D,sk->texid[j]); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); + if (glinfo.maxanisotropy > 1.0) + bglTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,glanisotropy); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- + +static float glox1, gloy1, glox2, gloy2; + + //Use this for both initialization and uninitialization of OpenGL. +static int gltexcacnum = -1; +void polymost_glreset () +{ + long i; + pthtyp *pth, *next; + //Reset if this is -1 (meaning 1st texture call ever), or > 0 (textures in memory) + if (gltexcacnum < 0) + { + gltexcacnum = 0; + + //Hack for polymost_dorotatesprite calls before 1st polymost_drawrooms() + gcosang = gcosang2 = ((double)16384)/262144.0; + gsinang = gsinang2 = ((double) 0)/262144.0; + } + else + { + for (i=GLTEXCACHEADSIZ-1; i>=0; i--) { + for (pth=gltexcachead[i]; pth;) { + next = pth->next; + bglDeleteTextures(1,&pth->glpic); + free(pth); + pth = next; + } + gltexcachead[i] = NULL; + } + clearskins(); + } + + if (polymosttext) bglDeleteTextures(1,&polymosttext); + polymosttext=0; + + memset(gltexcachead,0,sizeof(gltexcachead)); + glox1 = -1; +} + +// one-time initialisation of OpenGL for polymost +void polymost_glinit() +{ + GLfloat col[4]; + + bglFogi(GL_FOG_MODE,GL_EXP); //GL_EXP(default),GL_EXP2,GL_LINEAR + //bglHint(GL_FOG_HINT,GL_NICEST); + bglFogf(GL_FOG_DENSITY,1.0); //must be > 0, default is 1 + bglFogf(GL_FOG_START,0.0); //default is 0 + bglFogf(GL_FOG_END,1.0); //default is 1 + col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0; //range:0 to 1 + bglFogfv(GL_FOG_COLOR,col); //default is 0,0,0,0 + + bglBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + + if (glmultisample > 0 && glinfo.multisample) { + if (glinfo.nvmultisamplehint) + bglHint(GL_MULTISAMPLE_FILTER_HINT_NV, glnvmultisamplehint ? GL_NICEST:GL_FASTEST); + bglEnable(GL_MULTISAMPLE_ARB); + } +} + +void resizeglcheck () +{ + float m[4][4]; + + if (glredbluemode < lastglredbluemode) { + glox1 = -1; + bglColorMask(1,1,1,1); + } else if (glredbluemode != lastglredbluemode) { + redblueclearcnt = 0; + } + lastglredbluemode = glredbluemode; + + //FUK + if (lastglpolygonmode != glpolygonmode) + { + lastglpolygonmode = glpolygonmode; + switch(glpolygonmode) + { + default: + case 0: bglPolygonMode(GL_FRONT_AND_BACK,GL_FILL); break; + case 1: bglPolygonMode(GL_FRONT_AND_BACK,GL_LINE); break; + case 2: bglPolygonMode(GL_FRONT_AND_BACK,GL_POINT); break; + } + } + if (glpolygonmode) //FUK + { + bglClearColor(1.0,1.0,1.0,0.0); + bglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + bglDisable(GL_TEXTURE_2D); + } + + if ((glox1 != windowx1) || (gloy1 != windowy1) || (glox2 != windowx2) || (gloy2 != windowy2)) + { + glox1 = windowx1; gloy1 = windowy1; + glox2 = windowx2; gloy2 = windowy2; + + bglViewport(windowx1,yres-(windowy2+1),windowx2-windowx1+1,windowy2-windowy1+1); + + bglMatrixMode(GL_PROJECTION); + memset(m,0,sizeof(m)); + m[0][0] = (float)ydimen; m[0][2] = 1.0; + m[1][1] = (float)xdimen; m[1][2] = 1.0; + m[2][2] = 1.0; m[2][3] = (float)ydimen; + m[3][2] =-1.0; + bglLoadMatrixf(&m[0][0]); + + bglMatrixMode(GL_MODELVIEW); + bglLoadIdentity(); + + if (!nofog) bglEnable(GL_FOG); + + //bglEnable(GL_TEXTURE_2D); + } +} + +void fixtransparency (coltype *dapic, long daxsiz, long daysiz, long daxsiz2, long daysiz2, long dameth) +{ + coltype *wpptr; + long j, x, y, r, g, b, dox, doy, naxsiz2; + + dox = daxsiz2-1; doy = daysiz2-1; + if (dameth&4) { dox = min(dox,daxsiz); doy = min(doy,daysiz); } + else { daxsiz = daxsiz2; daysiz = daysiz2; } //Make repeating textures duplicate top/left parts + + daxsiz--; daysiz--; naxsiz2 = -daxsiz2; //Hacks for optimization inside loop + + //Set transparent pixels to average color of neighboring opaque pixels + //Doing this makes bilinear filtering look much better for masked textures (I.E. sprites) + for(y=doy;y>=0;y--) + { + wpptr = &dapic[y*daxsiz2+dox]; + for(x=dox;x>=0;x--,wpptr--) + { + if (wpptr->a) continue; + r = g = b = j = 0; + if ((x> 0) && (wpptr[ -1].a)) { r += (long)wpptr[ -1].r; g += (long)wpptr[ -1].g; b += (long)wpptr[ -1].b; j++; } + if ((x 0) && (wpptr[naxsiz2].a)) { r += (long)wpptr[naxsiz2].r; g += (long)wpptr[naxsiz2].g; b += (long)wpptr[naxsiz2].b; j++; } + if ((yr = r ; wpptr->g = g ; wpptr->b = b ; break; + case 2: wpptr->r = ((r + 1)>>1); wpptr->g = ((g + 1)>>1); wpptr->b = ((b + 1)>>1); break; + case 3: wpptr->r = ((r*85+128)>>8); wpptr->g = ((g*85+128)>>8); wpptr->b = ((b*85+128)>>8); break; + case 4: wpptr->r = ((r + 2)>>2); wpptr->g = ((g + 2)>>2); wpptr->b = ((b + 2)>>2); break; + default: break; + } + } + } +} + +static void uploadtexture(long doalloc, long xsiz, long ysiz, long intexfmt, long texfmt, coltype *pic, long tsizx, long tsizy, long dameth) +{ + coltype *wpptr, *rpptr; + long x2, y2, j, js=0, x3, y3, y, x, r, g, b, a, k; + + if (gltexmaxsize <= 0) { + GLint i = 0; + bglGetIntegerv(GL_MAX_TEXTURE_SIZE, &i); + if (!i) gltexmaxsize = 6; // 2^6 = 64 == default GL max texture size + else { + gltexmaxsize = 0; + for (; i>1; i>>=1) gltexmaxsize++; + } + } + + js = max(0,min(gltexmaxsize-1,gltexmiplevel)); + gltexmiplevel = js; + while ((xsiz>>js) > (1<>js) > (1< 1) || (y2 > 1);j++) + { + //x3 = ((x2+1)>>1); y3 = ((y2+1)>>1); + x3 = max(1, x2 >> 1); y3 = max(1, y2 >> 1); // this came from the GL_ARB_texture_non_power_of_two spec + for(y=0;yr = r; wpptr->g = g; wpptr->b = b; wpptr->a = a; break; + case 2: wpptr->r = ((r+1)>>1); wpptr->g = ((g+1)>>1); wpptr->b = ((b+1)>>1); wpptr->a = ((a+1)>>1); break; + case 3: wpptr->r = ((r*85+128)>>8); wpptr->g = ((g*85+128)>>8); wpptr->b = ((b*85+128)>>8); wpptr->a = ((a*85+128)>>8); break; + case 4: wpptr->r = ((r+2)>>2); wpptr->g = ((g+2)>>2); wpptr->b = ((b+2)>>2); wpptr->a = ((a+2)>>2); break; + default: break; + } + //if (wpptr->a) wpptr->a = 255; + } + } + if (tsizx >= 0) fixtransparency(pic,(tsizx+(1<>j,(tsizy+(1<>j,x3,y3,dameth); + if (j >= js) { + if (doalloc&1) + bglTexImage2D(GL_TEXTURE_2D,j-js,intexfmt,x3,y3,0,texfmt,GL_UNSIGNED_BYTE,pic); //loading 1st time + else + bglTexSubImage2D(GL_TEXTURE_2D,j-js,0,0,x3,y3,texfmt,GL_UNSIGNED_BYTE,pic); //overwrite old texture + } + x2 = x3; y2 = y3; + } +#endif +} + +int gloadtile_art (long dapic, long dapal, long dameth, pthtyp *pth, long doalloc) +{ + coltype *pic, *wpptr; + long j, x, y, x2, y2, xsiz, ysiz, dacol, tsizx, tsizy; + char hasalpha = 0; + + tsizx = tilesizx[dapic]; + tsizy = tilesizy[dapic]; + if (!glinfo.texnpot) { + for(xsiz=1;xsiz= tsizx) || (y >= tsizy))) //Clamp texture + { wpptr->r = wpptr->g = wpptr->b = wpptr->a = 0; continue; } + if (x < tsizx) x2 = x; else x2 = x-tsizx; + dacol = (long)(*(unsigned char *)(waloff[dapic]+x2*tsizy+y2)); + if (dacol == 255) { + wpptr->a = 0; hasalpha = 1; + } else { + wpptr->a = 255; + dacol = (long)((unsigned char)palookup[dapal][dacol]); + } + if (gammabrightness) { + wpptr->r = curpalette[dacol].r; + wpptr->g = curpalette[dacol].g; + wpptr->b = curpalette[dacol].b; + } else { + wpptr->r = britable[curbrightness][ curpalette[dacol].r ]; + wpptr->g = britable[curbrightness][ curpalette[dacol].g ]; + wpptr->b = britable[curbrightness][ curpalette[dacol].b ]; + } + } + } + } + + if (doalloc) bglGenTextures(1,(GLuint*)&pth->glpic); //# of textures (make OpenGL allocate structure) + bglBindTexture(GL_TEXTURE_2D,pth->glpic); + + fixtransparency(pic,tsizx,tsizy,xsiz,ysiz,dameth); + uploadtexture(doalloc,xsiz,ysiz,hasalpha?GL_RGBA:GL_RGB,GL_RGBA,pic,tsizx,tsizy,dameth); + + if (gltexfiltermode < 0) gltexfiltermode = 0; + else if (gltexfiltermode >= (long)numglfiltermodes) gltexfiltermode = numglfiltermodes-1; + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); + + if (glinfo.maxanisotropy > 1.0) + { + if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) glanisotropy = (long)glinfo.maxanisotropy; + bglTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,glanisotropy); + } + + if (!(dameth&4)) + { + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); + } + else + { //For sprite textures, clamping looks better than wrapping + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); + } + + if (pic) free(pic); + + pth->picnum = dapic; + pth->palnum = dapal; + pth->effects = 0; + pth->flags = ((dameth&4)>>2) | (hasalpha<<3); + pth->hicr = NULL; + + return 0; +} + +// JONOF'S COMPRESSED TEXTURE CACHE STUFF --------------------------------------------------- +static inline void phex(unsigned char v, char *s) +{ + int x; + x = v>>4; + s[0] = x<10 ? (x+'0') : (x-10+'a'); + x = v&15; + s[1] = x<10 ? (x+'0') : (x-10+'a'); +} + +long trytexcache(char *fn, long len, long dameth, char effect, texcacheheader *head) +{ + long fil, fp; + char cachefn[BMAX_PATH], *cp; + unsigned char mdsum[16]; + + if (!glinfo.texcompr || !glusetexcompr || !glusetexcache) return -1; + if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) { + // lacking the necessary extensions to do this + initprintf("Warning: the GL driver lacks necessary functions to use caching\n"); + glusetexcache = 0; + return -1; + } + + md4once(fn, strlen(fn), mdsum); + for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++); + *(cp++) = '/'; + for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2); + sprintf(cp, "-%lx-%lx%x", len, dameth, effect); + + fil = kopen4load(cachefn, 0); + if (fil < 0) return -1; + + initprintf("Loading cached tex: %s\n", cachefn); + + if (kread(fil, head, sizeof(texcacheheader)) < (int)sizeof(texcacheheader)) goto failure; + if (memcmp(head->magic, "Polymost", 8)) goto failure; + + head->xdim = B_LITTLE32(head->xdim); + head->ydim = B_LITTLE32(head->ydim); + head->flags = B_LITTLE32(head->flags); + + if (!glinfo.texnpot && (head->flags & 1)) goto failure; + + return fil; +failure: + kclose(fil); + return -1; +} + +void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *head) +{ + long fil=-1, fp; + char cachefn[BMAX_PATH], *cp; + unsigned char mdsum[16]; + texcachepicture pict; + char *pic = NULL, *packbuf = NULL; + void *midbuf = NULL; + unsigned long alloclen=0, level, miplen; + unsigned long padx, pady; + GLuint gi; + long j, k; + + if (!glinfo.texcompr || !glusetexcompr || !glusetexcache) return; + if (!bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB) { + // lacking the necessary extensions to do this + initprintf("Warning: the GL driver lacks necessary functions to use caching\n"); + glusetexcache = 0; + return; + } + + { + struct stat st; + if (stat(TEXCACHEDIR, &st) < 0) { + if (errno == ENOENT) { // path doesn't exist + // try to create the cache directory + if (Bmkdir(TEXCACHEDIR, S_IRWXU) < 0) { + initprintf("Failed to create texture cache directory %s\n", TEXCACHEDIR); + glusetexcache = 0; + return; + } else initprintf("Created texture cache directory %s\n", TEXCACHEDIR); + } else { + // another type of failure + glusetexcache = 0; + return; + } + } else if ((st.st_mode & S_IFDIR) != S_IFDIR) { + // cache directory isn't a directory + glusetexcache = 0; + return; + } + } + + gi = GL_FALSE; + bglGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &gi); + if (gi != GL_TRUE) return; + + md4once(fn, strlen(fn), mdsum); + for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++); + *(cp++) = '/'; + for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2); + sprintf(cp, "-%lx-%lx%x", len, dameth, effect); + + initprintf("Writing cached tex: %s\n", cachefn); + + fil = Bopen(cachefn,BO_BINARY|BO_CREAT|BO_TRUNC|BO_RDWR,BS_IREAD|BS_IWRITE); + if (fil < 0) return; + + memcpy(head->magic, "Polymost", 8); // sizes are set by caller + + if (glusetexcachecompression) head->flags |= 4; + + head->xdim = B_LITTLE32(head->xdim); + head->ydim = B_LITTLE32(head->ydim); + head->flags = B_LITTLE32(head->flags); + + if (Bwrite(fil, head, sizeof(texcacheheader)) != sizeof(texcacheheader)) goto failure; + + bglGetError(); + for (level = 0; level==0 || (padx > 1 || pady > 1); level++) { + bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_ARB, &gi); + if (bglGetError() != GL_NO_ERROR) goto failure; + if (gi != GL_TRUE) goto failure; // an uncompressed mipmap + bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_INTERNAL_FORMAT, &gi); + if (bglGetError() != GL_NO_ERROR) goto failure; + pict.format = B_LITTLE32(gi); + bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_WIDTH, &gi); + if (bglGetError() != GL_NO_ERROR) goto failure; + padx = gi; pict.xdim = B_LITTLE32(gi); + bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_HEIGHT, &gi); + if (bglGetError() != GL_NO_ERROR) goto failure; + pady = gi; pict.ydim = B_LITTLE32(gi); + bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_BORDER, &gi); + if (bglGetError() != GL_NO_ERROR) goto failure; + pict.border = B_LITTLE32(gi); + bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_DEPTH, &gi); + if (bglGetError() != GL_NO_ERROR) goto failure; + pict.depth = B_LITTLE32(gi); + bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &gi); + if (bglGetError() != GL_NO_ERROR) goto failure; + miplen = (long)gi; pict.size = B_LITTLE32(gi); + + if (alloclen < miplen) { + void *picc = realloc(pic, miplen); + if (!picc) goto failure; else pic = picc; + alloclen = miplen; + + picc = realloc(packbuf, alloclen+16); + if (!picc) goto failure; else packbuf = picc; + + picc = realloc(midbuf, miplen); + if (!picc) goto failure; else midbuf = picc; + } + + bglGetCompressedTexImageARB(GL_TEXTURE_2D, level, pic); + if (bglGetError() != GL_NO_ERROR) goto failure; + + if (Bwrite(fil, &pict, sizeof(texcachepicture)) != sizeof(texcachepicture)) goto failure; + if (dxtfilter(fil, &pict, pic, midbuf, packbuf, miplen)) goto failure; + } + +failure: + if (fil>=0) Bclose(fil); + if (midbuf) free(midbuf); + if (pic) free(pic); + if (packbuf) free(packbuf); +} + +int gloadtile_cached(long fil, texcacheheader *head, long *doalloc, pthtyp *pth) +{ + int level, r; + texcachepicture pict; + char *pic = NULL, *packbuf = NULL; + void *midbuf = NULL; + long alloclen=0; + + if (*doalloc&1) { + bglGenTextures(1,(GLuint*)&pth->glpic); //# of textures (make OpenGL allocate structure) + *doalloc |= 2; // prevents bglGenTextures being called again if we fail in here + } + bglBindTexture(GL_TEXTURE_2D,pth->glpic); + + pth->sizx = head->xdim; + pth->sizy = head->ydim; + + bglGetError(); + + // load the mipmaps + for (level = 0; level==0 || (pict.xdim > 1 || pict.ydim > 1); level++) { + r = kread(fil, &pict, sizeof(texcachepicture)); + if (r < (int)sizeof(texcachepicture)) goto failure; + + pict.size = B_LITTLE32(pict.size); + pict.format = B_LITTLE32(pict.format); + pict.xdim = B_LITTLE32(pict.xdim); + pict.ydim = B_LITTLE32(pict.ydim); + pict.border = B_LITTLE32(pict.border); + pict.depth = B_LITTLE32(pict.depth); + + if (alloclen < pict.size) { + void *picc = realloc(pic, pict.size); + if (!picc) goto failure; else pic = picc; + alloclen = pict.size; + + picc = realloc(packbuf, alloclen+16); + if (!picc) goto failure; else packbuf = picc; + + picc = realloc(midbuf, pict.size); + if (!picc) goto failure; else midbuf = picc; + } + + if (dedxtfilter(fil, &pict, pic, midbuf, packbuf, (head->flags&4)==4)) goto failure; + + bglCompressedTexImage2DARB(GL_TEXTURE_2D,level,pict.format,pict.xdim,pict.ydim,pict.border, + pict.size,pic); + if (bglGetError() != GL_NO_ERROR) goto failure; + } + + if (midbuf) free(midbuf); + if (pic) free(pic); + if (packbuf) free(packbuf); + return 0; +failure: + if (midbuf) free(midbuf); + if (pic) free(pic); + if (packbuf) free(packbuf); + return -1; +} +// --------------------------------------------------- JONOF'S COMPRESSED TEXTURE CACHE STUFF + +int gloadtile_hi(long dapic, long facen, hicreplctyp *hicr, long dameth, pthtyp *pth, long doalloc, char effect) +{ + coltype *pic = NULL, *rpptr; + long j, x, y, x2, y2, xsiz, ysiz, tsizx, tsizy; + + char *picfil = NULL, *fn, hasalpha = 255; + long picfillen, texfmt = GL_RGBA, intexfmt = GL_RGBA, filh; + + long cachefil = -1; + texcacheheader cachead; + + if (!hicr) return -1; + if (facen > 0) { + if (!hicr->skybox) return -1; + if (facen > 6) return -1; + if (!hicr->skybox->face[facen-1]) return -1; + fn = hicr->skybox->face[facen-1]; + } else { + if (!hicr->filename) return -1; + fn = hicr->filename; + } + + if ((filh = kopen4load(fn, 0)) < 0) { + initprintf("hightile: %s (pic %d) not found\n", fn, dapic); + if (facen > 0) + hicr->skybox->ignore = 1; + else + hicr->ignore = 1; + return -1; + } + picfillen = kfilelength(filh); + + kclose(filh); // FIXME: shouldn't have to do this. bug in cache1d.c + + cachefil = trytexcache(fn, picfillen, dameth, effect, &cachead); + if (cachefil >= 0 && !gloadtile_cached(cachefil, &cachead, &doalloc, pth)) { + tsizx = cachead.xdim; + tsizy = cachead.ydim; + hasalpha = (cachead.flags & 2) ? 0 : 255; + kclose(cachefil); + //kclose(filh); // FIXME: uncomment when cache1d.c is fixed + // cachefil >= 0, so it won't be rewritten + } else { + if (cachefil >= 0) kclose(cachefil); + cachefil = -1; // the compressed version will be saved to disk + + if ((filh = kopen4load(fn, 0)) < 0) return -1; + + picfil = (char *)malloc(picfillen); if (!picfil) { kclose(filh); return 1; } + kread(filh, picfil, picfillen); + kclose(filh); + + // tsizx/y = replacement texture's natural size + // xsiz/y = 2^x size of replacement + + kpgetdim(picfil,picfillen,&tsizx,&tsizy); + if (tsizx == 0 || tsizy == 0) { free(picfil); return -1; } + pth->sizx = tsizx; + pth->sizy = tsizy; + + if (!glinfo.texnpot) { + for(xsiz=1;xsiz tsizx) //Copy left to right + { + long *lptr = (long *)pic; + for(y=0;y tsizy) //Copy top to bottom + memcpy(&pic[xsiz*tsizy],pic,(ysiz-tsizy)*xsiz<<2); + } + if (!glinfo.bgra) { + for(j=xsiz*ysiz-1;j>=0;j--) { + swapchar(&pic[j].r, &pic[j].b); + } + } else texfmt = GL_BGRA; + free(picfil); picfil = 0; + + if (glinfo.texcompr && glusetexcompr && !(hicr->flags & 1)) + intexfmt = (hasalpha == 255) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB; + else if (hasalpha == 255) intexfmt = GL_RGB; + + if ((doalloc&3)==1) bglGenTextures(1,(GLuint*)&pth->glpic); //# of textures (make OpenGL allocate structure) + bglBindTexture(GL_TEXTURE_2D,pth->glpic); + + fixtransparency(pic,tsizx,tsizy,xsiz,ysiz,dameth); + uploadtexture(doalloc,xsiz,ysiz,intexfmt,texfmt,pic,-1,tsizy,dameth); + } + + // precalculate scaling parameters for replacement + if (facen > 0) { + pth->scalex = ((float)tsizx) / 64.0; + pth->scaley = ((float)tsizy) / 64.0; + } else { + pth->scalex = ((float)tsizx) / ((float)tilesizx[dapic]); + pth->scaley = ((float)tsizy) / ((float)tilesizy[dapic]); + } + + if (gltexfiltermode < 0) gltexfiltermode = 0; + else if (gltexfiltermode >= (long)numglfiltermodes) gltexfiltermode = numglfiltermodes-1; + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,glfiltermodes[gltexfiltermode].mag); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,glfiltermodes[gltexfiltermode].min); + + if (glinfo.maxanisotropy > 1.0) + { + if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) glanisotropy = (long)glinfo.maxanisotropy; + bglTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,glanisotropy); + } + + if (!(dameth&4)) + { + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); + } + else + { //For sprite textures, clamping looks better than wrapping + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); + } + + if (pic) free(pic); + + pth->picnum = dapic; + pth->effects = effect; + pth->flags = ((dameth&4)>>2) + 2 + ((facen>0)<<2); if (hasalpha != 255) pth->flags |= 8; + pth->skyface = facen; + pth->hicr = hicr; + + if (cachefil < 0) { + // save off the compressed version + cachead.xdim = tsizx; + cachead.ydim = tsizy; + x = 0; + for (j=0;j<31;j++) { + if (xsiz == pow2long[j]) { x |= 1; } + if (ysiz == pow2long[j]) { x |= 2; } + } + cachead.flags = (x!=3) | (hasalpha != 255 ? 2 : 0); + writexcache(fn, picfillen, dameth, effect, &cachead); + } + + return 0; +} + +#endif + + //(dpx,dpy) specifies an n-sided polygon. The polygon must be a convex clockwise loop. + // n must be <= 8 (assume clipping can double number of vertices) + //method: 0:solid, 1:masked(255 is transparent), 2:transluscent #1, 3:transluscent #2 + // +4 means it's a sprite, so wraparound isn't needed +static long pow2xsplit = 0, skyclamphack = 0; + +void drawpoly (double *dpx, double *dpy, long n, long method) +{ + #define PI 3.14159265358979323 + double ngdx = 0.0, ngdy = 0.0, ngdo = 0.0, ngux = 0.0, nguy = 0.0, nguo = 0.0; + double ngvx = 0.0, ngvy = 0.0, ngvo = 0.0, dp, up, vp, rdp, du0 = 0.0, du1 = 0.0, dui, duj; + double ngdx2, ngux2, ngvx2; + double f, r, ox, oy, oz, ox2, oy2, oz2, dd[16], uu[16], vv[16], px[16], py[16], uoffs; + long i, j, k, x, y, z, nn, ix0, ix1, mini, maxi, tsizx, tsizy, tsizxm1 = 0, tsizym1 = 0, ltsizy = 0; + long xx, yy, xi, d0, u0, v0, d1, u1, v1, xmodnice = 0, ymulnice = 0, dorot; + char dacol = 0, *walptr, *palptr = NULL, *vidp, *vide; +#ifdef USE_OPENGL + pthtyp *pth; +#endif + + if (method == -1) return; + + if (n == 3) + { + if ((dpx[0]-dpx[1])*(dpy[2]-dpy[1]) >= (dpx[2]-dpx[1])*(dpy[0]-dpy[1])) return; //for triangle + } + else + { + f = 0; //f is area of polygon / 2 + for(i=n-2,j=n-1,k=0;k= MAXTILES) globalpicnum = 0; + setgotpic(globalpicnum); + tsizx = tilesizx[globalpicnum]; + tsizy = tilesizy[globalpicnum]; + if (!palookup[globalpal]) globalpal = 0; + if (!waloff[globalpicnum]) + { + loadtile(globalpicnum); + if (!waloff[globalpicnum]) + { + if (rendmode != 3) return; + tsizx = tsizy = 1; method = 1; //Hack to update Z-buffer for invalid mirror textures + } + } + walptr = (char *)waloff[globalpicnum]; + + j = 0; dorot = ((gchang != 1.0) || (gctang != 1.0)); + if (dorot) + { + for(i=0;i= 3) && (px[j-1] == px[0]) && (py[j-1] == py[0])) j--; + if (j < 3) return; + n = j; + +#ifdef USE_OPENGL + if (rendmode == 3) + { + float hackscx, hackscy; + + if (skyclamphack) method |= 4; + pth = gltexcache(globalpicnum,globalpal,method&(~3)); + bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); + + if (pth && (pth->flags & 2)) + { + hackscx = pth->scalex; + hackscy = pth->scaley; + tsizx = pth->sizx; + tsizy = pth->sizy; + } + else { hackscx = 1.0; hackscy = 1.0; } + + if (!glinfo.texnpot) { + for(xx=1;xxhicr && pth->hicr->alphacut >= 0.0) al = pth->hicr->alphacut; + if (alphahackarray[globalpicnum]) + al=alphahackarray[globalpicnum]; + if (!waloff[globalpicnum]) al = 0.0; // invalid textures ignore the alpha cutoff settings + bglEnable(GL_BLEND); + bglEnable(GL_ALPHA_TEST); + bglAlphaFunc(GL_GREATER,al); + } + + if (!dorot) + { + for(i=n-1;i>=0;i--) + { + dd[i] = px[i]*gdx + py[i]*gdy + gdo; + uu[i] = px[i]*gux + py[i]*guy + guo; + vv[i] = px[i]*gvx + py[i]*gvy + gvo; + } + } + + { + float pc[4]; + f = ((float)(numpalookups-min(max(globalshade,0),numpalookups)))/((float)numpalookups); + pc[0] = pc[1] = pc[2] = f; + switch(method&3) + { + case 0: pc[3] = 1.0; break; + case 1: pc[3] = 1.0; break; + case 2: pc[3] = 0.66; break; + case 3: pc[3] = 0.33; break; + } + // tinting happens only to hightile textures, and only if the texture we're + // rendering isn't for the same palette as what we asked for + if (pth && (pth->flags & 2) && (pth->palnum != globalpal)) { + // apply tinting for replaced textures + pc[0] *= (float)hictinting[globalpal].r / 255.0; + pc[1] *= (float)hictinting[globalpal].g / 255.0; + pc[2] *= (float)hictinting[globalpal].b / 255.0; + } + bglColor4f(pc[0],pc[1],pc[2],pc[3]); + } + + //Hack for walls&masked walls which use textures that are not a power of 2 + if ((pow2xsplit) && (tsizx != xx)) + { + if (!dorot) + { + ngdx = gdx; ngdy = gdy; ngdo = gdo+(ngdx+ngdy)*.5; + ngux = gux; nguy = guy; nguo = guo+(ngux+nguy)*.5; + ngvx = gvx; ngvy = gvy; ngvo = gvo+(ngvx+ngvy)*.5; + } + else + { + ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1]; + r = 1.0 / (ox*px[0] + oy*px[1] + oz*px[2]); + ngdx = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; + ngux = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; + ngvx = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; + ox = px[2]-px[1]; oy = px[0]-px[2]; oz = px[1]-px[0]; + ngdy = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; + nguy = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; + ngvy = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; + ox = px[0]-.5; oy = py[0]-.5; //.5 centers texture nicely + ngdo = dd[0] - ox*ngdx - oy*ngdy; + nguo = uu[0] - ox*ngux - oy*nguy; + ngvo = vv[0] - ox*ngvx - oy*ngvy; + } + + ngux *= hackscx; nguy *= hackscx; nguo *= hackscx; + ngvx *= hackscy; ngvy *= hackscy; ngvo *= hackscy; + uoffs = ((double)(xx-tsizx)*.5); + ngux -= ngdx*uoffs; + nguy -= ngdy*uoffs; + nguo -= ngdo*uoffs; + + //Find min&max u coordinates (du0...du1) + for(i=0;i du1) du1 = f; + } + + f = 1.0/(double)tsizx; + ix0 = (long)floor(du0*f); + ix1 = (long)floor(du1*f); + for(;ix0<=ix1;ix0++) + { + du0 = (double)((ix0 )*tsizx); // + uoffs; + du1 = (double)((ix0+1)*tsizx); // + uoffs; + + i = 0; nn = 0; + duj = (px[i]*ngux + py[i]*nguy + nguo) / (px[i]*ngdx + py[i]*ngdy + ngdo); + do + { + j = i+1; if (j == n) j = 0; + + dui = duj; duj = (px[j]*ngux + py[j]*nguy + nguo) / (px[j]*ngdx + py[j]*ngdy + ngdo); + + if ((du0 <= dui) && (dui <= du1)) { uu[nn] = px[i]; vv[nn] = py[i]; nn++; } + if (duj <= dui) + { + if ((du1 < duj) != (du1 < dui)) + { + //ox*(ngux-ngdx*du1) + oy*(nguy-ngdy*du1) + (nguo-ngdo*du1) = 0 + //(px[j]-px[i])*f + px[i] = ox + //(py[j]-py[i])*f + py[i] = oy + + ///Solve for f + //((px[j]-px[i])*f + px[i])*(ngux-ngdx*du1) + + //((py[j]-py[i])*f + py[i])*(nguy-ngdy*du1) + (nguo-ngdo*du1) = 0 + + f = -( px[i] *(ngux-ngdx*du1) + py[i] *(nguy-ngdy*du1) + (nguo-ngdo*du1)) / + ((px[j]-px[i])*(ngux-ngdx*du1) + (py[j]-py[i])*(nguy-ngdy*du1)); + uu[nn] = (px[j]-px[i])*f + px[i]; + vv[nn] = (py[j]-py[i])*f + py[i]; nn++; + } + if ((du0 < duj) != (du0 < dui)) + { + f = -( px[i] *(ngux-ngdx*du0) + py[i] *(nguy-ngdy*du0) + (nguo-ngdo*du0)) / + ((px[j]-px[i])*(ngux-ngdx*du0) + (py[j]-py[i])*(nguy-ngdy*du0)); + uu[nn] = (px[j]-px[i])*f + px[i]; + vv[nn] = (py[j]-py[i])*f + py[i]; nn++; + } + } + else + { + if ((du0 < duj) != (du0 < dui)) + { + f = -( px[i] *(ngux-ngdx*du0) + py[i] *(nguy-ngdy*du0) + (nguo-ngdo*du0)) / + ((px[j]-px[i])*(ngux-ngdx*du0) + (py[j]-py[i])*(nguy-ngdy*du0)); + uu[nn] = (px[j]-px[i])*f + px[i]; + vv[nn] = (py[j]-py[i])*f + py[i]; nn++; + } + if ((du1 < duj) != (du1 < dui)) + { + f = -( px[i] *(ngux-ngdx*du1) + py[i] *(nguy-ngdy*du1) + (nguo-ngdo*du1)) / + ((px[j]-px[i])*(ngux-ngdx*du1) + (py[j]-py[i])*(nguy-ngdy*du1)); + uu[nn] = (px[j]-px[i])*f + px[i]; + vv[nn] = (py[j]-py[i])*f + py[i]; nn++; + } + } + i = j; + } while (i); + if (nn < 3) continue; + + bglBegin(GL_TRIANGLE_FAN); + for(i=0;i>4); + } + else + { + dacol = palookup[0][(long)(*(char *)(waloff[globalpicnum]))+(min(max(globalshade,0),numpalookups-1)<<8)]; + } + + if (grhalfxdown10x < 0) //Hack for mirrors + { + for(i=((n-1)>>1);i>=0;i--) + { + r = px[i]; px[i] = ((double)xdimen)-px[n-1-i]; px[n-1-i] = ((double)xdimen)-r; + r = py[i]; py[i] = py[n-1-i]; py[n-1-i] = r; + } + ngdo += ((double)xdimen)*ngdx; ngdx = -ngdx; + nguo += ((double)xdimen)*ngux; ngux = -ngux; + ngvo += ((double)xdimen)*ngvx; ngvx = -ngvx; + } + + ngdx2 = ngdx*(1<= py[1]); maxi = 1-mini; + for(z=2;z py[maxi]) maxi = z; + } + + i = maxi; dtol(py[i],&yy); if (yy > ydimen) yy = ydimen; + do + { + j = i+1; if (j == n) j = 0; + dtol(py[j],&y); if (y < 0) y = 0; + if (y < yy) + { + f = (px[j]-px[i])/(py[j]-py[i]); dtol(f*16384.0,&xi); + dtol((((double)yy-.5-py[j])*f + px[j])*16384.0+8192.0,&x); + for(;yy>y;yy--,x-=xi) lastx[yy-1] = (x>>14); + } + i = j; + } while (i != mini); + do + { + j = i+1; if (j == n) j = 0; + dtol(py[j],&yy); if (yy > ydimen) yy = ydimen; + if (y < yy) + { + f = (px[j]-px[i])/(py[j]-py[i]); dtol(f*16384.0,&xi); + dtol((((double)y+.5-py[j])*f + px[j])*16384.0+8192.0,&x); + for(;y>14); if (ix1 > xdimen) ix1 = xdimen; + if (ix0 < ix1) + { + if (rendmode == 1) + memset((void *)(ylookup[y]+ix0+frameoffset),dacol,ix1-ix0); + else + { + vidp = (char *)(ylookup[y]+frameoffset+ix0); + dp = ngdx*(double)ix0 + ngdy*(double)y + ngdo; + up = ngux*(double)ix0 + nguy*(double)y + nguo; + vp = ngvx*(double)ix0 + ngvy*(double)y + ngvo; + rdp = 65536.0/dp; dp += ngdx2; + dtol( rdp,&d0); + dtol(up*rdp,&u0); up += ngux2; + dtol(vp*rdp,&v0); vp += ngvx2; + rdp = 65536.0/dp; + + switch (method&3) + { + case 0: + if (xmodnice&ymulnice) //both u&v texture sizes are powers of 2 :) + { + for(xx=ix0;xx>LINTERPSIZ); + dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); + dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); + rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16)&tsizxm1)<>16)&tsizym1)]]; //+((d0>>13)&0x3f00)]; +#else + vidp[0] = ((d0>>16)&255); +#endif + d0 += d1; u0 += u1; v0 += v1; vidp++; + } + } + } + else + { + for(xx=ix0;xx>LINTERPSIZ); + dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); + dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); + rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16,tsizx)*tsizy + ((v0>>16)&tsizym1)]]; //+((d0>>13)&0x3f00)]; +#else + vidp[0] = ((d0>>16)&255); +#endif + d0 += d1; u0 += u1; v0 += v1; vidp++; + } + } + } + break; + case 1: + if (xmodnice) //both u&v texture sizes are powers of 2 :) + { + for(xx=ix0;xx>LINTERPSIZ); + dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); + dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); + rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16)&tsizxm1)*tsizy) + ((v0>>16)&tsizym1)]; +#if (DEPTHDEBUG == 0) +#if (USEZBUFFER != 0) + if ((dacol != 255) && (d0 <= zbufoff[(long)vidp])) + { + zbufoff[(long)vidp] = d0; + vidp[0] = palptr[((long)dacol)]; //+((d0>>13)&0x3f00)]; + } +#else + if (dacol != 255) vidp[0] = palptr[((long)dacol)]; //+((d0>>13)&0x3f00)]; +#endif +#else + if ((dacol != 255) && (vidp[0] > (d0>>16))) vidp[0] = ((d0>>16)&255); +#endif + d0 += d1; u0 += u1; v0 += v1; vidp++; + } + } + } + else + { + for(xx=ix0;xx>LINTERPSIZ); + dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); + dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); + rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16,tsizx)*tsizy + ((v0>>16)&tsizym1)]; +#if (DEPTHDEBUG == 0) +#if (USEZBUFFER != 0) + if ((dacol != 255) && (d0 <= zbufoff[(long)vidp])) + { + zbufoff[(long)vidp] = d0; + vidp[0] = palptr[((long)dacol)]; //+((d0>>13)&0x3f00)]; + } +#else + if (dacol != 255) vidp[0] = palptr[((long)dacol)]; //+((d0>>13)&0x3f00)]; +#endif +#else + if ((dacol != 255) && (vidp[0] > (d0>>16))) vidp[0] = ((d0>>16)&255); +#endif + d0 += d1; u0 += u1; v0 += v1; vidp++; + } + } + } + break; + case 2: //Transluscence #1 + for(xx=ix0;xx>LINTERPSIZ); + dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); + dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); + rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16,tsizx)*tsizy + ((v0>>16)&tsizym1)]; + //dacol = walptr[(((u0>>16)&tsizxm1)<>16)&tsizym1)]; +#if (DEPTHDEBUG == 0) +#if (USEZBUFFER != 0) + if ((dacol != 255) && (d0 <= zbufoff[(long)vidp])) + { + zbufoff[(long)vidp] = d0; + vidp[0] = transluc[(((long)vidp[0])<<8)+((long)palptr[((long)dacol)])]; //+((d0>>13)&0x3f00)])]; + } +#else + if (dacol != 255) + vidp[0] = transluc[(((long)vidp[0])<<8)+((long)palptr[((long)dacol)])]; //+((d0>>13)&0x3f00)])]; +#endif +#else + if ((dacol != 255) && (vidp[0] > (d0>>16))) vidp[0] = ((d0>>16)&255); +#endif + d0 += d1; u0 += u1; v0 += v1; vidp++; + } + } + break; + case 3: //Transluscence #2 + for(xx=ix0;xx>LINTERPSIZ); + dtol(up*rdp,&u1); up += ngux2; u1 = ((u1-u0)>>LINTERPSIZ); + dtol(vp*rdp,&v1); vp += ngvx2; v1 = ((v1-v0)>>LINTERPSIZ); + rdp = 65536.0/dp; vide = &vidp[min(ix1-xx,1<>16,tsizx)*tsizy + ((v0>>16)&tsizym1)]; + //dacol = walptr[(((u0>>16)&tsizxm1)<>16)&tsizym1)]; +#if (DEPTHDEBUG == 0) +#if (USEZBUFFER != 0) + if ((dacol != 255) && (d0 <= zbufoff[(long)vidp])) + { + zbufoff[(long)vidp] = d0; + vidp[0] = transluc[((long)vidp[0])+(((long)palptr[((long)dacol)/*+((d0>>13)&0x3f00)*/])<<8)]; + } +#else + if (dacol != 255) + vidp[0] = transluc[((long)vidp[0])+(((long)palptr[((long)dacol)/*+((d0>>13)&0x3f00)*/])<<8)]; +#endif +#else + if ((dacol != 255) && (vidp[0] > (d0>>16))) vidp[0] = ((d0>>16)&255); +#endif + d0 += d1; u0 += u1; v0 += v1; vidp++; + } + } + break; + } + } + } + } + } + i = j; + } while (i != maxi); + + if (rendmode == 1) + { + if (method&3) //Only draw border around sprites/maskwalls + { + for(i=0,j=n-1;i=2;i--) if (px[i] < px[imin]) imin = i; + + + vsp[vcnt].x = px[imin]; + vsp[vcnt].cy[0] = vsp[vcnt].fy[0] = py[imin]; + vcnt++; + i = imin+1; if (i >= n) i = 0; + j = imin-1; if (j < 0) j = n-1; + do + { + if (px[i] < px[j]) + { + if ((vcnt > 1) && (px[i] <= vsp[vcnt-1].x)) vcnt--; + vsp[vcnt].x = px[i]; + vsp[vcnt].cy[0] = py[i]; + k = j+1; if (k >= n) k = 0; + //(px[k],py[k]) + //(px[i],?) + //(px[j],py[j]) + vsp[vcnt].fy[0] = (px[i]-px[k])*(py[j]-py[k])/(px[j]-px[k]) + py[k]; + vcnt++; + i++; if (i >= n) i = 0; + } + else if (px[j] < px[i]) + { + if ((vcnt > 1) && (px[j] <= vsp[vcnt-1].x)) vcnt--; + vsp[vcnt].x = px[j]; + vsp[vcnt].fy[0] = py[j]; + k = i-1; if (k < 0) k = n-1; + //(px[k],py[k]) + //(px[j],?) + //(px[i],py[i]) + vsp[vcnt].cy[0] = (px[j]-px[k])*(py[i]-py[k])/(px[i]-px[k]) + py[k]; + vcnt++; + j--; if (j < 0) j = n-1; + } + else + { + if ((vcnt > 1) && (px[i] <= vsp[vcnt-1].x)) vcnt--; + vsp[vcnt].x = px[i]; + vsp[vcnt].cy[0] = py[i]; + vsp[vcnt].fy[0] = py[j]; + vcnt++; + i++; if (i >= n) i = 0; if (i == j) break; + j--; if (j < 0) j = n-1; + } + } while (i != j); + if (px[i] > vsp[vcnt-1].x) + { + vsp[vcnt].x = px[i]; + vsp[vcnt].cy[0] = vsp[vcnt].fy[0] = py[i]; + vcnt++; + } + + + for(i=0;i= 0)) return(1); + } + return(0); +} + +static long domostpolymethod = 0; + +void domost (float x0, float y0, float x1, float y1) +{ + double dpx[4], dpy[4]; + float d, f, n, t, slop, dx, dx0, dx1, nx, nx0, ny0, nx1, ny1; + float spx[4], spy[4], cy[2], cv[2]; + long i, j, k, z, ni, vcnt = 0, scnt, newi, dir, spt[4]; + + if (x0 < x1) + { + dir = 1; //clip dmost (floor) + y0 -= .01; y1 -= .01; + } + else + { + if (x0 == x1) return; + f = x0; x0 = x1; x1 = f; + f = y0; y0 = y1; y1 = f; + dir = 0; //clip umost (ceiling) + //y0 += .01; y1 += .01; //necessary? + } + + slop = (y1-y0)/(x1-x0); + for(i=vsp[0].n;i;i=newi) + { + newi = vsp[i].n; nx0 = vsp[i].x; nx1 = vsp[newi].x; + if ((x0 >= nx1) || (nx0 >= x1) || (vsp[i].ctag <= 0)) continue; + dx = nx1-nx0; + cy[0] = vsp[i].cy[0]; cv[0] = vsp[i].cy[1]-cy[0]; + cy[1] = vsp[i].fy[0]; cv[1] = vsp[i].fy[1]-cy[1]; + + scnt = 0; + + //Test if left edge requires split (x0,y0) (nx0,cy(0)), + if ((x0 > nx0) && (x0 < nx1)) + { + t = (x0-nx0)*cv[dir] - (y0-cy[dir])*dx; + if (((!dir) && (t < 0)) || ((dir) && (t > 0))) + { spx[scnt] = x0; spy[scnt] = y0; spt[scnt] = -1; scnt++; } + } + + //Test for intersection on umost (j == 0) and dmost (j == 1) + for(j=0;j<2;j++) + { + d = (y0-y1)*dx - (x0-x1)*cv[j]; + n = (y0-cy[j])*dx - (x0-nx0)*cv[j]; + if ((fabs(n) <= fabs(d)) && (d*n >= 0) && (d != 0)) + { + t = n/d; nx = (x1-x0)*t + x0; + if ((nx > nx0) && (nx < nx1)) + { + spx[scnt] = nx; spy[scnt] = (y1-y0)*t + y0; + spt[scnt] = j; scnt++; + } + } + } + + //Nice hack to avoid full sort later :) + if ((scnt >= 2) && (spx[scnt-1] < spx[scnt-2])) + { + f = spx[scnt-1]; spx[scnt-1] = spx[scnt-2]; spx[scnt-2] = f; + f = spy[scnt-1]; spy[scnt-1] = spy[scnt-2]; spy[scnt-2] = f; + j = spt[scnt-1]; spt[scnt-1] = spt[scnt-2]; spt[scnt-2] = j; + } + + //Test if right edge requires split + if ((x1 > nx0) && (x1 < nx1)) + { + t = (x1-nx0)*cv[dir] - (y1-cy[dir])*dx; + if (((!dir) && (t < 0)) || ((dir) && (t > 0))) + { spx[scnt] = x1; spy[scnt] = y1; spt[scnt] = -1; scnt++; } + } + + vsp[i].tag = vsp[newi].tag = -1; + for(z=0;z<=scnt;z++,i=vcnt) + { + if (z < scnt) + { + vcnt = vsinsaft(i); + t = (spx[z]-nx0)/dx; + vsp[i].cy[1] = t*cv[0] + cy[0]; + vsp[i].fy[1] = t*cv[1] + cy[1]; + vsp[vcnt].x = spx[z]; + vsp[vcnt].cy[0] = vsp[i].cy[1]; + vsp[vcnt].fy[0] = vsp[i].fy[1]; + vsp[vcnt].tag = spt[z]; + } + + ni = vsp[i].n; if (!ni) continue; //this 'if' fixes many bugs! + dx0 = vsp[i].x; if (x0 > dx0) continue; + dx1 = vsp[ni].x; if (x1 < dx1) continue; + ny0 = (dx0-x0)*slop + y0; + ny1 = (dx1-x0)*slop + y0; + + // dx0 dx1 + // ~ ~ + //---------------------------- + // t0+=0 t1+=0 + // vsp[i].cy[0] vsp[i].cy[1] + //============================ + // t0+=1 t1+=3 + //============================ + // vsp[i].fy[0] vsp[i].fy[1] + // t0+=2 t1+=6 + // + // ny0 ? ny1 ? + + k = 1+3; + if ((vsp[i].tag == 0) || (ny0 <= vsp[i].cy[0]+.01)) k--; + if ((vsp[i].tag == 1) || (ny0 >= vsp[i].fy[0]-.01)) k++; + if ((vsp[ni].tag == 0) || (ny1 <= vsp[i].cy[1]+.01)) k -= 3; + if ((vsp[ni].tag == 1) || (ny1 >= vsp[i].fy[1]-.01)) k += 3; + + if (!dir) + { + switch(k) + { + case 1: case 2: + dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; + dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; + dpx[2] = dx0; dpy[2] = ny0; drawpoly(dpx,dpy,3,domostpolymethod); + vsp[i].cy[0] = ny0; vsp[i].ctag = gtag; break; + case 3: case 6: + dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; + dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; + dpx[2] = dx1; dpy[2] = ny1; drawpoly(dpx,dpy,3,domostpolymethod); + vsp[i].cy[1] = ny1; vsp[i].ctag = gtag; break; + case 4: case 5: case 7: + dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; + dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; + dpx[2] = dx1; dpy[2] = ny1; + dpx[3] = dx0; dpy[3] = ny0; drawpoly(dpx,dpy,4,domostpolymethod); + vsp[i].cy[0] = ny0; vsp[i].cy[1] = ny1; vsp[i].ctag = gtag; break; + case 8: + dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; + dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; + dpx[2] = dx1; dpy[2] = vsp[i].fy[1]; + dpx[3] = dx0; dpy[3] = vsp[i].fy[0]; drawpoly(dpx,dpy,4,domostpolymethod); + vsp[i].ctag = vsp[i].ftag = -1; break; + default: break; + } + } + else + { + switch(k) + { + case 7: case 6: + dpx[0] = dx0; dpy[0] = ny0; + dpx[1] = dx1; dpy[1] = vsp[i].fy[1]; + dpx[2] = dx0; dpy[2] = vsp[i].fy[0]; drawpoly(dpx,dpy,3,domostpolymethod); + vsp[i].fy[0] = ny0; vsp[i].ftag = gtag; break; + case 5: case 2: + dpx[0] = dx0; dpy[0] = vsp[i].fy[0]; + dpx[1] = dx1; dpy[1] = ny1; + dpx[2] = dx1; dpy[2] = vsp[i].fy[1]; drawpoly(dpx,dpy,3,domostpolymethod); + vsp[i].fy[1] = ny1; vsp[i].ftag = gtag; break; + case 4: case 3: case 1: + dpx[0] = dx0; dpy[0] = ny0; + dpx[1] = dx1; dpy[1] = ny1; + dpx[2] = dx1; dpy[2] = vsp[i].fy[1]; + dpx[3] = dx0; dpy[3] = vsp[i].fy[0]; drawpoly(dpx,dpy,4,domostpolymethod); + vsp[i].fy[0] = ny0; vsp[i].fy[1] = ny1; vsp[i].ftag = gtag; break; + case 0: + dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; + dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; + dpx[2] = dx1; dpy[2] = vsp[i].fy[1]; + dpx[3] = dx0; dpy[3] = vsp[i].fy[0]; drawpoly(dpx,dpy,4,domostpolymethod); + vsp[i].ctag = vsp[i].ftag = -1; break; + default: break; + } + } + } + } + + gtag++; + + //Combine neighboring vertical strips with matching collinear top&bottom edges + //This prevents x-splits from propagating through the entire scan + i = vsp[0].n; + while (i) + { + ni = vsp[i].n; + if ((vsp[i].cy[0] >= vsp[i].fy[0]) && (vsp[i].cy[1] >= vsp[i].fy[1])) { vsp[i].ctag = vsp[i].ftag = -1; } + if ((vsp[i].ctag == vsp[ni].ctag) && (vsp[i].ftag == vsp[ni].ftag)) + { vsp[i].cy[1] = vsp[ni].cy[1]; vsp[i].fy[1] = vsp[ni].fy[1]; vsdel(ni); } + else i = ni; + } +} + +static void polymost_scansector (long sectnum); + +static void polymost_drawalls (long bunch) +{ + sectortype *sec, *nextsec; + walltype *wal, *wal2, *nwal; + double ox, oy, oz, ox2, oy2, px[3], py[3], dd[3], uu[3], vv[3]; + double fx, fy, x0, x1, y0, y1, cy0, cy1, fy0, fy1, xp0, yp0, xp1, yp1, ryp0, ryp1, nx0, ny0, nx1, ny1; + double t, r, t0, t1, ocy0, ocy1, ofy0, ofy1, oxp0, oyp0, ft[4]; + double oguo, ogux, oguy; + long i, x, y, z, cz, fz, wallnum, sectnum, nextsectnum; + + sectnum = thesector[bunchfirst[bunch]]; sec = §or[sectnum]; + +#ifdef USE_OPENGL + if (!nofog) { + if (rendmode == 3) { + float col[4]; + col[0] = (float)palookupfog[sec->floorpal].r / 63.f; + col[1] = (float)palookupfog[sec->floorpal].g / 63.f; + col[2] = (float)palookupfog[sec->floorpal].b / 63.f; + col[3] = 0; + bglFogfv(GL_FOG_COLOR,col); + bglFogf(GL_FOG_DENSITY,gvisibility*((float)((unsigned char)(sec->visibility+16)))); + } + } +#endif + + //DRAW WALLS SECTION! + for(z=bunchfirst[bunch];z>=0;z=p2[z]) + { + wallnum = thewall[z]; wal = &wall[wallnum]; wal2 = &wall[wal->point2]; + nextsectnum = wal->nextsector; nextsec = §or[nextsectnum]; + + //Offset&Rotate 3D coordinates to screen 3D space + x = wal->x-globalposx; y = wal->y-globalposy; + xp0 = (double)y*gcosang - (double)x*gsinang; + yp0 = (double)x*gcosang2 + (double)y*gsinang2; + x = wal2->x-globalposx; y = wal2->y-globalposy; + xp1 = (double)y*gcosang - (double)x*gsinang; + yp1 = (double)x*gcosang2 + (double)y*gsinang2; + + oxp0 = xp0; oyp0 = yp0; + + //Clip to close parallel-screen plane + if (yp0 < SCISDIST) + { + if (yp1 < SCISDIST) continue; + t0 = (SCISDIST-yp0)/(yp1-yp0); xp0 = (xp1-xp0)*t0+xp0; yp0 = SCISDIST; + nx0 = (wal2->x-wal->x)*t0+wal->x; + ny0 = (wal2->y-wal->y)*t0+wal->y; + } + else { t0 = 0.f; nx0 = wal->x; ny0 = wal->y; } + if (yp1 < SCISDIST) + { + t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; yp1 = SCISDIST; + nx1 = (wal2->x-wal->x)*t1+wal->x; + ny1 = (wal2->y-wal->y)*t1+wal->y; + } + else { t1 = 1.f; nx1 = wal2->x; ny1 = wal2->y; } + + ryp0 = 1.f/yp0; ryp1 = 1.f/yp1; + + //Generate screen coordinates for front side of wall + x0 = ghalfx*xp0*ryp0 + ghalfx; + x1 = ghalfx*xp1*ryp1 + ghalfx; + if (x1 <= x0) continue; + + ryp0 *= gyxscale; ryp1 *= gyxscale; + + getzsofslope(sectnum,(long)nx0,(long)ny0,&cz,&fz); + cy0 = ((float)(cz-globalposz))*ryp0 + ghoriz; + fy0 = ((float)(fz-globalposz))*ryp0 + ghoriz; + getzsofslope(sectnum,(long)nx1,(long)ny1,&cz,&fz); + cy1 = ((float)(cz-globalposz))*ryp1 + ghoriz; + fy1 = ((float)(fz-globalposz))*ryp1 + ghoriz; + + + globalpicnum = sec->floorpicnum; globalshade = sec->floorshade; globalpal = (long)((unsigned char)sec->floorpal); + globalorientation = sec->floorstat; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,sectnum); + if (!(globalorientation&1)) + { + //(singlobalang/-16384*(sx-ghalfx) + 0*(sy-ghoriz) + (cosviewingrangeglobalang/16384)*ghalfx)*d + globalposx = u*16 + //(cosglobalang/ 16384*(sx-ghalfx) + 0*(sy-ghoriz) + (sinviewingrangeglobalang/16384)*ghalfx)*d + globalposy = v*16 + //( 0*(sx-ghalfx) + 1*(sy-ghoriz) + ( 0)*ghalfx)*d + globalposz/16 = (sec->floorz/16) + if (!(globalorientation&64)) + { ft[0] = globalposx; ft[1] = globalposy; ft[2] = cosglobalang; ft[3] = singlobalang; } + else + { + //relative alignment + fx = (double)(wall[wall[sec->wallptr].point2].x-wall[sec->wallptr].x); + fy = (double)(wall[wall[sec->wallptr].point2].y-wall[sec->wallptr].y); + r = 1.0/sqrt(fx*fx+fy*fy); fx *= r; fy *= r; + ft[2] = cosglobalang*fx + singlobalang*fy; + ft[3] = singlobalang*fx - cosglobalang*fy; + ft[0] = ((double)(globalposx-wall[sec->wallptr].x))*fx + ((double)(globalposy-wall[sec->wallptr].y))*fy; + ft[1] = ((double)(globalposy-wall[sec->wallptr].y))*fx - ((double)(globalposx-wall[sec->wallptr].x))*fy; + if (!(globalorientation&4)) globalorientation ^= 32; else globalorientation ^= 16; + } + gdx = 0; + gdy = gxyaspect; if (!(globalorientation&2)) gdy /= (double)(sec->floorz-globalposz); + gdo = -ghoriz*gdy; + if (globalorientation&8) { ft[0] /= 8; ft[1] /= -8; ft[2] /= 2097152; ft[3] /= 2097152; } + else { ft[0] /= 16; ft[1] /= -16; ft[2] /= 4194304; ft[3] /= 4194304; } + gux = (double)ft[3]*((double)viewingrange)/-65536.0; + gvx = (double)ft[2]*((double)viewingrange)/-65536.0; + guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy; + guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo; + guo += (double)(ft[2]-gux)*ghalfx; + gvo -= (double)(ft[3]+gvx)*ghalfx; + + //Texture flipping + if (globalorientation&4) + { + r = gux; gux = gvx; gvx = r; + r = guy; guy = gvy; gvy = r; + r = guo; guo = gvo; gvo = r; + } + if (globalorientation&16) { gux = -gux; guy = -guy; guo = -guo; } + if (globalorientation&32) { gvx = -gvx; gvy = -gvy; gvo = -gvo; } + + //Texture panning + fx = (float)sec->floorxpanning*((float)(1<<(picsiz[globalpicnum]&15)))/256.0; + fy = (float)sec->floorypanning*((float)(1<<(picsiz[globalpicnum]>>4)))/256.0; + if ((globalorientation&(2+64)) == (2+64)) //Hack for panning for slopes w/ relative alignment + { + r = (float)sec->floorheinum / 4096.0; r = 1.0/sqrt(r*r+1); + if (!(globalorientation&4)) fy *= r; else fx *= r; + } + guy += gdy*fx; guo += gdo*fx; + gvy += gdy*fy; gvo += gdo*fy; + + if (globalorientation&2) //slopes + { + px[0] = x0; py[0] = ryp0 + ghoriz; + px[1] = x1; py[1] = ryp1 + ghoriz; + + //Pick some point guaranteed to be not collinear to the 1st two points + ox = nx0 + (ny1-ny0); + oy = ny0 + (nx0-nx1); + ox2 = (double)(oy-globalposy)*gcosang - (double)(ox-globalposx)*gsinang; + oy2 = (double)(ox-globalposx)*gcosang2 + (double)(oy-globalposy)*gsinang2; + oy2 = 1.0/oy2; + px[2] = ghalfx*ox2*oy2 + ghalfx; oy2 *= gyxscale; + py[2] = oy2 + ghoriz; + + for(i=0;i<3;i++) + { + dd[i] = px[i]*gdx + py[i]*gdy + gdo; + uu[i] = px[i]*gux + py[i]*guy + guo; + vv[i] = px[i]*gvx + py[i]*gvy + gvo; + } + + py[0] = fy0; + py[1] = fy1; + py[2] = (getflorzofslope(sectnum,(long)ox,(long)oy)-globalposz)*oy2 + ghoriz; + + ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1]; + r = 1.0 / (ox*px[0] + oy*px[1] + oz*px[2]); + gdx = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; + gux = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; + gvx = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; + ox = px[2]-px[1]; oy = px[0]-px[2]; oz = px[1]-px[0]; + gdy = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; + guy = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; + gvy = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; + gdo = dd[0] - px[0]*gdx - py[0]*gdy; + guo = uu[0] - px[0]*gux - py[0]*guy; + gvo = vv[0] - px[0]*gvx - py[0]*gvy; + + if (globalorientation&64) //Hack for relative alignment on slopes + { + r = (float)sec->floorheinum / 4096.0; + r = sqrt(r*r+1); + if (!(globalorientation&4)) { gvx *= r; gvy *= r; gvo *= r; } + else { gux *= r; guy *= r; guo *= r; } + } + } + domostpolymethod = (globalorientation>>7)&3; + if (globalposz >= getflorzofslope(sectnum,globalposx,globalposy)) domostpolymethod = -1; //Back-face culling + pow2xsplit = 0; domost(x0,fy0,x1,fy1); //flor + domostpolymethod = 0; + } + else if ((nextsectnum < 0) || (!(sector[nextsectnum].floorstat&1))) + { + //Parallaxing sky... hacked for Ken's mountain texture; paper-sky only :/ +#ifdef USE_OPENGL + if (rendmode == 3) + { + if (!nofog) { + bglDisable(GL_FOG); + //r = ((float)globalpisibility)*((float)((unsigned char)(sec->visibility+16)))*FOGSCALE; + //r *= ((double)xdimscale*(double)viewingrange*gdo) / (65536.0*65536.0); + //bglFogf(GL_FOG_DENSITY,r); + } + + //Use clamping for tiled sky textures + for(i=(1<0;i--) + if (pskyoff[i] != pskyoff[i-1]) + { skyclamphack = 1; break; } + } +#endif + if (bpp == 8 || !usehightile || !hicfindsubst(globalpicnum,globalpal,1)) + { + dd[0] = (float)xdimen*.0000001; //Adjust sky depth based on screen size! + t = (double)((1<<(picsiz[globalpicnum]&15))<>1)+parallaxyoffs)) - vv[1]*ghoriz; + i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesizy[globalpicnum]) i += i; + vv[0] += dd[0]*((double)sec->floorypanning)*((double)i)/256.0; + + + //Hack to draw black rectangle below sky when looking down... + gdx = 0; gdy = gxyaspect / 262144.0; gdo = -ghoriz*gdy; + gux = 0; guy = 0; guo = 0; + gvx = 0; gvy = (double)(tilesizy[globalpicnum]-1)*gdy; gvo = (double)(tilesizy[globalpicnum-1])*gdo; + oy = (((double)tilesizy[globalpicnum])*dd[0]-vv[0])/vv[1]; + if ((oy > fy0) && (oy > fy1)) domost(x0,oy,x1,oy); + else if ((oy > fy0) != (oy > fy1)) + { // fy0 fy1 + // \ / + //oy---------- oy---------- + // \ / + // fy1 fy0 + ox = (oy-fy0)*(x1-x0)/(fy1-fy0) + x0; + if (oy > fy0) { domost(x0,oy,ox,oy); domost(ox,oy,x1,fy1); } + else { domost(x0,fy0,ox,oy); domost(ox,oy,x1,oy); } + } else domost(x0,fy0,x1,fy1); + + + gdx = 0; gdy = 0; gdo = dd[0]; + gux = gdo*(t*((double)xdimscale)*((double)yxaspect)*((double)viewingrange))/(16384.0*65536.0*65536.0*5.0*1024.0); + guy = 0; //guo calculated later + gvx = 0; gvy = vv[1]; gvo = vv[0]; + + i = globalpicnum; r = (fy1-fy0)/(x1-x0); //slope of line + oy = ((double)viewingrange)/(ghalfx*256.0); oz = 1/oy; + + y = ((((long)((x0-ghalfx)*oy))+globalang)>>(11-pskybits)); + fx = x0; + do + { + globalpicnum = pskyoff[y&((1<floorxpanning) - gux*ghalfx; + y++; + ox = fx; fx = ((double)((y<<(11-pskybits))-globalang))*oz+ghalfx; + if (fx > x1) { fx = x1; i = -1; } + + pow2xsplit = 0; domost(ox,(ox-x0)*r+fy0,fx,(fx-x0)*r+fy0); //flor + } while (i >= 0); + + } + else //NOTE: code copied from ceiling code... lots of duplicated stuff :/ + { //Skybox code for parallax ceiling! + double _xp0, _yp0, _xp1, _yp1, _oxp0, _oyp0, _t0, _t1, _nx0, _ny0, _nx1, _ny1; + double _ryp0, _ryp1, _x0, _x1, _cy0, _fy0, _cy1, _fy1, _ox0, _ox1; + double nfy0, nfy1; + long skywalx[4] = {-512,512,512,-512}, skywaly[4] = {-512,-512,512,512}; + + pow2xsplit = 0; + skyclamphack = 1; + + for(i=0;i<4;i++) + { + x = skywalx[i&3]; y = skywaly[i&3]; + _xp0 = (double)y*gcosang - (double)x*gsinang; + _yp0 = (double)x*gcosang2 + (double)y*gsinang2; + x = skywalx[(i+1)&3]; y = skywaly[(i+1)&3]; + _xp1 = (double)y*gcosang - (double)x*gsinang; + _yp1 = (double)x*gcosang2 + (double)y*gsinang2; + + _oxp0 = _xp0; _oyp0 = _yp0; + + //Clip to close parallel-screen plane + if (_yp0 < SCISDIST) + { + if (_yp1 < SCISDIST) continue; + _t0 = (SCISDIST-_yp0)/(_yp1-_yp0); _xp0 = (_xp1-_xp0)*_t0+_xp0; _yp0 = SCISDIST; + _nx0 = (skywalx[(i+1)&3]-skywalx[i&3])*_t0+skywalx[i&3]; + _ny0 = (skywaly[(i+1)&3]-skywaly[i&3])*_t0+skywaly[i&3]; + } + else { _t0 = 0.f; _nx0 = skywalx[i&3]; _ny0 = skywaly[i&3]; } + if (_yp1 < SCISDIST) + { + _t1 = (SCISDIST-_oyp0)/(_yp1-_oyp0); _xp1 = (_xp1-_oxp0)*_t1+_oxp0; _yp1 = SCISDIST; + _nx1 = (skywalx[(i+1)&3]-skywalx[i&3])*_t1+skywalx[i&3]; + _ny1 = (skywaly[(i+1)&3]-skywaly[i&3])*_t1+skywaly[i&3]; + } + else { _t1 = 1.f; _nx1 = skywalx[(i+1)&3]; _ny1 = skywaly[(i+1)&3]; } + + _ryp0 = 1.f/_yp0; _ryp1 = 1.f/_yp1; + + //Generate screen coordinates for front side of wall + _x0 = ghalfx*_xp0*_ryp0 + ghalfx; + _x1 = ghalfx*_xp1*_ryp1 + ghalfx; + if (_x1 <= _x0) continue; + if ((_x0 >= x1) || (x0 >= _x1)) continue; + + _ryp0 *= gyxscale; _ryp1 *= gyxscale; + + _cy0 = -8192.f*_ryp0 + ghoriz; + _fy0 = 8192.f*_ryp0 + ghoriz; + _cy1 = -8192.f*_ryp1 + ghoriz; + _fy1 = 8192.f*_ryp1 + ghoriz; + + _ox0 = _x0; _ox1 = _x1; + + //Make sure: x0<=_x0<_x1<=_x1 + nfy0 = fy0; nfy1 = fy1; + if (_x0 < x0) + { + t = (x0-_x0)/(_x1-_x0); + _cy0 += (_cy1-_cy0)*t; + _fy0 += (_fy1-_fy0)*t; + _x0 = x0; + } + else if (_x0 > x0) nfy0 += (_x0-x0)*(fy1-fy0)/(x1-x0); + if (_x1 > x1) + { + t = (x1-_x1)/(_x1-_x0); + _cy1 += (_cy1-_cy0)*t; + _fy1 += (_fy1-_fy0)*t; + _x1 = x1; + } + else if (_x1 < x1) nfy1 += (_x1-x1)*(fy1-fy0)/(x1-x0); + + // (skybox floor) + //(_x0,_fy0)-(_x1,_fy1) + // (skybox wall) + //(_x0,_cy0)-(_x1,_cy1) + // (skybox ceiling) + //(_x0,nfy0)-(_x1,nfy1) + + //ceiling of skybox + ft[0] = 512/16; ft[1] = 512/-16; + ft[2] = ((float)cosglobalang)*(1.f/2147483648.f); + ft[3] = ((float)singlobalang)*(1.f/2147483648.f); + gdx = 0; + gdy = gxyaspect*(1.f/4194304.f); + gdo = -ghoriz*gdy; + gux = (double)ft[3]*((double)viewingrange)/-65536.0; + gvx = (double)ft[2]*((double)viewingrange)/-65536.0; + guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy; + guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo; + guo += (double)(ft[2]-gux)*ghalfx; + gvo -= (double)(ft[3]+gvx)*ghalfx; + gvx = -gvx; gvy = -gvy; gvo = -gvo; //y-flip skybox floor +#ifdef USE_OPENGL + drawingskybox = 6; //ceiling/5th texture/index 4 of skybox +#endif + if ((_fy0 > nfy0) && (_fy1 > nfy1)) domost(_x0,_fy0,_x1,_fy1); + else if ((_fy0 > nfy0) != (_fy1 > nfy1)) + { + //(ox,oy) is intersection of: (_x0,_cy0)-(_x1,_cy1) + // (_x0,nfy0)-(_x1,nfy1) + //ox = _x0 + (_x1-_x0)*t + //oy = _cy0 + (_cy1-_cy0)*t + //oy = nfy0 + (nfy1-nfy0)*t + t = (_fy0-nfy0)/(nfy1-nfy0-_fy1+_fy0); + ox = _x0 + (_x1-_x0)*t; + oy = _fy0 + (_fy1-_fy0)*t; + if (nfy0 > _fy0) { domost(_x0,nfy0,ox,oy); domost(ox,oy,_x1,_fy1); } + else { domost(_x0,_fy0,ox,oy); domost(ox,oy,_x1,nfy1); } + } else domost(_x0,nfy0,_x1,nfy1); + + //wall of skybox +#ifdef USE_OPENGL + drawingskybox = i+1; //i+1th texture/index i of skybox +#endif + gdx = (_ryp0-_ryp1)*gxyaspect*(1.f/512.f) / (_ox0-_ox1); + gdy = 0; + gdo = _ryp0*gxyaspect*(1.f/512.f) - gdx*_ox0; + gux = (_t0*_ryp0 - _t1*_ryp1)*gxyaspect*(64.f/512.f) / (_ox0-_ox1); + guo = _t0*_ryp0*gxyaspect*(64.f/512.f) - gux*_ox0; + guy = 0; + _t0 = -8192.0*_ryp0 + ghoriz; + _t1 = -8192.0*_ryp1 + ghoriz; + t = ((gdx*_ox0 + gdo)*8.f) / ((_ox1-_ox0) * _ryp0 * 2048.f); + gvx = (_t0-_t1)*t; + gvy = (_ox1-_ox0)*t; + gvo = -gvx*_ox0 - gvy*_t0; + if ((_cy0 > nfy0) && (_cy1 > nfy1)) domost(_x0,_cy0,_x1,_cy1); + else if ((_cy0 > nfy0) != (_cy1 > nfy1)) + { + //(ox,oy) is intersection of: (_x0,_fy0)-(_x1,_fy1) + // (_x0,nfy0)-(_x1,nfy1) + //ox = _x0 + (_x1-_x0)*t + //oy = _fy0 + (_fy1-_fy0)*t + //oy = nfy0 + (nfy1-nfy0)*t + t = (_cy0-nfy0)/(nfy1-nfy0-_cy1+_cy0); + ox = _x0 + (_x1-_x0)*t; + oy = _cy0 + (_cy1-_cy0)*t; + if (nfy0 > _cy0) { domost(_x0,nfy0,ox,oy); domost(ox,oy,_x1,_cy1); } + else { domost(_x0,_cy0,ox,oy); domost(ox,oy,_x1,nfy1); } + } else domost(_x0,nfy0,_x1,nfy1); + } + + //Floor of skybox +#ifdef USE_OPENGL + drawingskybox = 5; //floor/6th texture/index 5 of skybox +#endif + ft[0] = 512/16; ft[1] = -512/-16; + ft[2] = ((float)cosglobalang)*(1.f/2147483648.f); + ft[3] = ((float)singlobalang)*(1.f/2147483648.f); + gdx = 0; + gdy = gxyaspect*(-1.f/4194304.f); + gdo = -ghoriz*gdy; + gux = (double)ft[3]*((double)viewingrange)/-65536.0; + gvx = (double)ft[2]*((double)viewingrange)/-65536.0; + guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy; + guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo; + guo += (double)(ft[2]-gux)*ghalfx; + gvo -= (double)(ft[3]+gvx)*ghalfx; + domost(x0,fy0,x1,fy1); + + skyclamphack = 0; +#ifdef USE_OPENGL + drawingskybox = 0; +#endif + } +#ifdef USE_OPENGL + if (rendmode == 3) + { + skyclamphack = 0; + if (!nofog) { + bglEnable(GL_FOG); + //bglFogf(GL_FOG_DENSITY,gvisibility*((float)((unsigned char)(sec->visibility+16)))); + } + } +#endif + } + + globalpicnum = sec->ceilingpicnum; globalshade = sec->ceilingshade; globalpal = (long)((unsigned char)sec->ceilingpal); + globalorientation = sec->ceilingstat; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,sectnum); + if (!(globalorientation&1)) + { + if (!(globalorientation&64)) + { ft[0] = globalposx; ft[1] = globalposy; ft[2] = cosglobalang; ft[3] = singlobalang; } + else + { + //relative alignment + fx = (double)(wall[wall[sec->wallptr].point2].x-wall[sec->wallptr].x); + fy = (double)(wall[wall[sec->wallptr].point2].y-wall[sec->wallptr].y); + r = 1.0/sqrt(fx*fx+fy*fy); fx *= r; fy *= r; + ft[2] = cosglobalang*fx + singlobalang*fy; + ft[3] = singlobalang*fx - cosglobalang*fy; + ft[0] = ((double)(globalposx-wall[sec->wallptr].x))*fx + ((double)(globalposy-wall[sec->wallptr].y))*fy; + ft[1] = ((double)(globalposy-wall[sec->wallptr].y))*fx - ((double)(globalposx-wall[sec->wallptr].x))*fy; + if (!(globalorientation&4)) globalorientation ^= 32; else globalorientation ^= 16; + } + gdx = 0; + gdy = gxyaspect; + if (!(globalorientation&2)) gdy /= (double)(sec->ceilingz-globalposz); + gdo = -ghoriz*gdy; + if (globalorientation&8) { ft[0] /= 8; ft[1] /= -8; ft[2] /= 2097152; ft[3] /= 2097152; } + else { ft[0] /= 16; ft[1] /= -16; ft[2] /= 4194304; ft[3] /= 4194304; } + gux = (double)ft[3]*((double)viewingrange)/-65536.0; + gvx = (double)ft[2]*((double)viewingrange)/-65536.0; + guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy; + guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo; + guo += (double)(ft[2]-gux)*ghalfx; + gvo -= (double)(ft[3]+gvx)*ghalfx; + + //Texture flipping + if (globalorientation&4) + { + r = gux; gux = gvx; gvx = r; + r = guy; guy = gvy; gvy = r; + r = guo; guo = gvo; gvo = r; + } + if (globalorientation&16) { gux = -gux; guy = -guy; guo = -guo; } + if (globalorientation&32) { gvx = -gvx; gvy = -gvy; gvo = -gvo; } + + //Texture panning + fx = (float)sec->ceilingxpanning*((float)(1<<(picsiz[globalpicnum]&15)))/256.0; + fy = (float)sec->ceilingypanning*((float)(1<<(picsiz[globalpicnum]>>4)))/256.0; + if ((globalorientation&(2+64)) == (2+64)) //Hack for panning for slopes w/ relative alignment + { + r = (float)sec->ceilingheinum / 4096.0; r = 1.0/sqrt(r*r+1); + if (!(globalorientation&4)) fy *= r; else fx *= r; + } + guy += gdy*fx; guo += gdo*fx; + gvy += gdy*fy; gvo += gdo*fy; + + if (globalorientation&2) //slopes + { + px[0] = x0; py[0] = ryp0 + ghoriz; + px[1] = x1; py[1] = ryp1 + ghoriz; + + //Pick some point guaranteed to be not collinear to the 1st two points + ox = nx0 + (ny1-ny0); + oy = ny0 + (nx0-nx1); + ox2 = (double)(oy-globalposy)*gcosang - (double)(ox-globalposx)*gsinang ; + oy2 = (double)(ox-globalposx)*gcosang2 + (double)(oy-globalposy)*gsinang2; + oy2 = 1.0/oy2; + px[2] = ghalfx*ox2*oy2 + ghalfx; oy2 *= gyxscale; + py[2] = oy2 + ghoriz; + + for(i=0;i<3;i++) + { + dd[i] = px[i]*gdx + py[i]*gdy + gdo; + uu[i] = px[i]*gux + py[i]*guy + guo; + vv[i] = px[i]*gvx + py[i]*gvy + gvo; + } + + py[0] = cy0; + py[1] = cy1; + py[2] = (getceilzofslope(sectnum,(long)ox,(long)oy)-globalposz)*oy2 + ghoriz; + + ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1]; + r = 1.0 / (ox*px[0] + oy*px[1] + oz*px[2]); + gdx = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; + gux = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; + gvx = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; + ox = px[2]-px[1]; oy = px[0]-px[2]; oz = px[1]-px[0]; + gdy = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; + guy = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; + gvy = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; + gdo = dd[0] - px[0]*gdx - py[0]*gdy; + guo = uu[0] - px[0]*gux - py[0]*guy; + gvo = vv[0] - px[0]*gvx - py[0]*gvy; + + if (globalorientation&64) //Hack for relative alignment on slopes + { + r = (float)sec->ceilingheinum / 4096.0; + r = sqrt(r*r+1); + if (!(globalorientation&4)) { gvx *= r; gvy *= r; gvo *= r; } + else { gux *= r; guy *= r; guo *= r; } + } + } + domostpolymethod = (globalorientation>>7)&3; + if (globalposz <= getceilzofslope(sectnum,globalposx,globalposy)) domostpolymethod = -1; //Back-face culling + pow2xsplit = 0; domost(x1,cy1,x0,cy0); //ceil + domostpolymethod = 0; + } + else if ((nextsectnum < 0) || (!(sector[nextsectnum].ceilingstat&1))) + { +#ifdef USE_OPENGL + if (rendmode == 3) + { + if (!nofog) { + bglDisable(GL_FOG); + //r = ((float)globalpisibility)*((float)((unsigned char)(sec->visibility+16)))*FOGSCALE; + //r *= ((double)xdimscale*(double)viewingrange*gdo) / (65536.0*65536.0); + //bglFogf(GL_FOG_DENSITY,r); + } + + //Use clamping for tiled sky textures + for(i=(1<0;i--) + if (pskyoff[i] != pskyoff[i-1]) + { skyclamphack = 1; break; } + } +#endif + //Parallaxing sky... + if (bpp == 8 || !usehightile || !hicfindsubst(globalpicnum,globalpal,1)) + { + //Render for parallaxtype == 0 / paper-sky + dd[0] = (float)xdimen*.0000001; //Adjust sky depth based on screen size! + t = (double)((1<<(picsiz[globalpicnum]&15))<>1)+parallaxyoffs)) - vv[1]*ghoriz; + i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesizy[globalpicnum]) i += i; + vv[0] += dd[0]*((double)sec->ceilingypanning)*((double)i)/256.0; + + //Hack to draw black rectangle below sky when looking down... + gdx = 0; gdy = gxyaspect / -262144.0; gdo = -ghoriz*gdy; + gux = 0; guy = 0; guo = 0; + gvx = 0; gvy = 0; gvo = 0; + oy = -vv[0]/vv[1]; + if ((oy < cy0) && (oy < cy1)) domost(x1,oy,x0,oy); + else if ((oy < cy0) != (oy < cy1)) + { /* cy1 cy0 + // / \ + //oy---------- oy--------- + // / \ + // cy0 cy1 + */ + ox = (oy-cy0)*(x1-x0)/(cy1-cy0) + x0; + if (oy < cy0) { domost(ox,oy,x0,oy); domost(x1,cy1,ox,oy); } + else { domost(ox,oy,x0,cy0); domost(x1,oy,ox,oy); } + } else domost(x1,cy1,x0,cy0); + + gdx = 0; gdy = 0; gdo = dd[0]; + gux = gdo*(t*((double)xdimscale)*((double)yxaspect)*((double)viewingrange))/(16384.0*65536.0*65536.0*5.0*1024.0); + guy = 0; //guo calculated later + gvx = 0; gvy = vv[1]; gvo = vv[0]; + + i = globalpicnum; r = (cy1-cy0)/(x1-x0); //slope of line + oy = ((double)viewingrange)/(ghalfx*256.0); oz = 1/oy; + + y = ((((long)((x0-ghalfx)*oy))+globalang)>>(11-pskybits)); + fx = x0; + do + { + globalpicnum = pskyoff[y&((1<ceilingxpanning) - gux*ghalfx; + y++; + ox = fx; fx = ((double)((y<<(11-pskybits))-globalang))*oz+ghalfx; + if (fx > x1) { fx = x1; i = -1; } + pow2xsplit = 0; domost(fx,(fx-x0)*r+cy0,ox,(ox-x0)*r+cy0); //ceil + } while (i >= 0); + } + else + { //Skybox code for parallax ceiling! + double _xp0, _yp0, _xp1, _yp1, _oxp0, _oyp0, _t0, _t1, _nx0, _ny0, _nx1, _ny1; + double _ryp0, _ryp1, _x0, _x1, _cy0, _fy0, _cy1, _fy1, _ox0, _ox1; + double ncy0, ncy1; + long skywalx[4] = {-512,512,512,-512}, skywaly[4] = {-512,-512,512,512}; + + pow2xsplit = 0; + skyclamphack = 1; + + for(i=0;i<4;i++) + { + x = skywalx[i&3]; y = skywaly[i&3]; + _xp0 = (double)y*gcosang - (double)x*gsinang; + _yp0 = (double)x*gcosang2 + (double)y*gsinang2; + x = skywalx[(i+1)&3]; y = skywaly[(i+1)&3]; + _xp1 = (double)y*gcosang - (double)x*gsinang; + _yp1 = (double)x*gcosang2 + (double)y*gsinang2; + + _oxp0 = _xp0; _oyp0 = _yp0; + + //Clip to close parallel-screen plane + if (_yp0 < SCISDIST) + { + if (_yp1 < SCISDIST) continue; + _t0 = (SCISDIST-_yp0)/(_yp1-_yp0); _xp0 = (_xp1-_xp0)*_t0+_xp0; _yp0 = SCISDIST; + _nx0 = (skywalx[(i+1)&3]-skywalx[i&3])*_t0+skywalx[i&3]; + _ny0 = (skywaly[(i+1)&3]-skywaly[i&3])*_t0+skywaly[i&3]; + } + else { _t0 = 0.f; _nx0 = skywalx[i&3]; _ny0 = skywaly[i&3]; } + if (_yp1 < SCISDIST) + { + _t1 = (SCISDIST-_oyp0)/(_yp1-_oyp0); _xp1 = (_xp1-_oxp0)*_t1+_oxp0; _yp1 = SCISDIST; + _nx1 = (skywalx[(i+1)&3]-skywalx[i&3])*_t1+skywalx[i&3]; + _ny1 = (skywaly[(i+1)&3]-skywaly[i&3])*_t1+skywaly[i&3]; + } + else { _t1 = 1.f; _nx1 = skywalx[(i+1)&3]; _ny1 = skywaly[(i+1)&3]; } + + _ryp0 = 1.f/_yp0; _ryp1 = 1.f/_yp1; + + //Generate screen coordinates for front side of wall + _x0 = ghalfx*_xp0*_ryp0 + ghalfx; + _x1 = ghalfx*_xp1*_ryp1 + ghalfx; + if (_x1 <= _x0) continue; + if ((_x0 >= x1) || (x0 >= _x1)) continue; + + _ryp0 *= gyxscale; _ryp1 *= gyxscale; + + _cy0 = -8192.f*_ryp0 + ghoriz; + _fy0 = 8192.f*_ryp0 + ghoriz; + _cy1 = -8192.f*_ryp1 + ghoriz; + _fy1 = 8192.f*_ryp1 + ghoriz; + + _ox0 = _x0; _ox1 = _x1; + + //Make sure: x0<=_x0<_x1<=_x1 + ncy0 = cy0; ncy1 = cy1; + if (_x0 < x0) + { + t = (x0-_x0)/(_x1-_x0); + _cy0 += (_cy1-_cy0)*t; + _fy0 += (_fy1-_fy0)*t; + _x0 = x0; + } + else if (_x0 > x0) ncy0 += (_x0-x0)*(cy1-cy0)/(x1-x0); + if (_x1 > x1) + { + t = (x1-_x1)/(_x1-_x0); + _cy1 += (_cy1-_cy0)*t; + _fy1 += (_fy1-_fy0)*t; + _x1 = x1; + } + else if (_x1 < x1) ncy1 += (_x1-x1)*(cy1-cy0)/(x1-x0); + + // (skybox ceiling) + //(_x0,_cy0)-(_x1,_cy1) + // (skybox wall) + //(_x0,_fy0)-(_x1,_fy1) + // (skybox floor) + //(_x0,ncy0)-(_x1,ncy1) + + //ceiling of skybox +#ifdef USE_OPENGL + drawingskybox = 5; //ceiling/5th texture/index 4 of skybox +#endif + ft[0] = 512/16; ft[1] = -512/-16; + ft[2] = ((float)cosglobalang)*(1.f/2147483648.f); + ft[3] = ((float)singlobalang)*(1.f/2147483648.f); + gdx = 0; + gdy = gxyaspect*-(1.f/4194304.f); + gdo = -ghoriz*gdy; + gux = (double)ft[3]*((double)viewingrange)/-65536.0; + gvx = (double)ft[2]*((double)viewingrange)/-65536.0; + guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy; + guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo; + guo += (double)(ft[2]-gux)*ghalfx; + gvo -= (double)(ft[3]+gvx)*ghalfx; + if ((_cy0 < ncy0) && (_cy1 < ncy1)) domost(_x1,_cy1,_x0,_cy0); + else if ((_cy0 < ncy0) != (_cy1 < ncy1)) + { + //(ox,oy) is intersection of: (_x0,_cy0)-(_x1,_cy1) + // (_x0,ncy0)-(_x1,ncy1) + //ox = _x0 + (_x1-_x0)*t + //oy = _cy0 + (_cy1-_cy0)*t + //oy = ncy0 + (ncy1-ncy0)*t + t = (_cy0-ncy0)/(ncy1-ncy0-_cy1+_cy0); + ox = _x0 + (_x1-_x0)*t; + oy = _cy0 + (_cy1-_cy0)*t; + if (ncy0 < _cy0) { domost(ox,oy,_x0,ncy0); domost(_x1,_cy1,ox,oy); } + else { domost(ox,oy,_x0,_cy0); domost(_x1,ncy1,ox,oy); } + } else domost(_x1,ncy1,_x0,ncy0); + + //wall of skybox +#ifdef USE_OPENGL + drawingskybox = i+1; //i+1th texture/index i of skybox +#endif + gdx = (_ryp0-_ryp1)*gxyaspect*(1.f/512.f) / (_ox0-_ox1); + gdy = 0; + gdo = _ryp0*gxyaspect*(1.f/512.f) - gdx*_ox0; + gux = (_t0*_ryp0 - _t1*_ryp1)*gxyaspect*(64.f/512.f) / (_ox0-_ox1); + guo = _t0*_ryp0*gxyaspect*(64.f/512.f) - gux*_ox0; + guy = 0; + _t0 = -8192.0*_ryp0 + ghoriz; + _t1 = -8192.0*_ryp1 + ghoriz; + t = ((gdx*_ox0 + gdo)*8.f) / ((_ox1-_ox0) * _ryp0 * 2048.f); + gvx = (_t0-_t1)*t; + gvy = (_ox1-_ox0)*t; + gvo = -gvx*_ox0 - gvy*_t0; + if ((_fy0 < ncy0) && (_fy1 < ncy1)) domost(_x1,_fy1,_x0,_fy0); + else if ((_fy0 < ncy0) != (_fy1 < ncy1)) + { + //(ox,oy) is intersection of: (_x0,_fy0)-(_x1,_fy1) + // (_x0,ncy0)-(_x1,ncy1) + //ox = _x0 + (_x1-_x0)*t + //oy = _fy0 + (_fy1-_fy0)*t + //oy = ncy0 + (ncy1-ncy0)*t + t = (_fy0-ncy0)/(ncy1-ncy0-_fy1+_fy0); + ox = _x0 + (_x1-_x0)*t; + oy = _fy0 + (_fy1-_fy0)*t; + if (ncy0 < _fy0) { domost(ox,oy,_x0,ncy0); domost(_x1,_fy1,ox,oy); } + else { domost(ox,oy,_x0,_fy0); domost(_x1,ncy1,ox,oy); } + } else domost(_x1,ncy1,_x0,ncy0); + } + + //Floor of skybox +#ifdef USE_OPENGL + drawingskybox = 6; //floor/6th texture/index 5 of skybox +#endif + ft[0] = 512/16; ft[1] = 512/-16; + ft[2] = ((float)cosglobalang)*(1.f/2147483648.f); + ft[3] = ((float)singlobalang)*(1.f/2147483648.f); + gdx = 0; + gdy = gxyaspect*(1.f/4194304.f); + gdo = -ghoriz*gdy; + gux = (double)ft[3]*((double)viewingrange)/-65536.0; + gvx = (double)ft[2]*((double)viewingrange)/-65536.0; + guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy; + guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo; + guo += (double)(ft[2]-gux)*ghalfx; + gvo -= (double)(ft[3]+gvx)*ghalfx; + gvx = -gvx; gvy = -gvy; gvo = -gvo; //y-flip skybox floor + domost(x1,cy1,x0,cy0); + + skyclamphack = 0; +#ifdef USE_OPENGL + drawingskybox = 0; +#endif + } +#ifdef USE_OPENGL + if (rendmode == 3) + { + skyclamphack = 0; + if (!nofog) { + bglEnable(GL_FOG); + //bglFogf(GL_FOG_DENSITY,gvisibility*((float)((unsigned char)(sec->visibility+16)))); + } + } +#endif + } + + //(x0,cy0) == (u= 0,v=0,d=) + //(x1,cy0) == (u=wal->xrepeat*8,v=0) + //(x0,fy0) == (u= 0,v=v) + // u = (gux*sx + guy*sy + guo) / (gdx*sx + gdy*sy + gdo) + // v = (gvx*sx + gvy*sy + gvo) / (gdx*sx + gdy*sy + gdo) + // 0 = (gux*x0 + guy*cy0 + guo) / (gdx*x0 + gdy*cy0 + gdo) + //wal->xrepeat*8 = (gux*x1 + guy*cy0 + guo) / (gdx*x1 + gdy*cy0 + gdo) + // 0 = (gvx*x0 + gvy*cy0 + gvo) / (gdx*x0 + gdy*cy0 + gdo) + // v = (gvx*x0 + gvy*fy0 + gvo) / (gdx*x0 + gdy*fy0 + gdo) + //sx = x0, u = t0*wal->xrepeat*8, d = yp0; + //sx = x1, u = t1*wal->xrepeat*8, d = yp1; + //d = gdx*sx + gdo + //u = (gux*sx + guo) / (gdx*sx + gdo) + //yp0 = gdx*x0 + gdo + //yp1 = gdx*x1 + gdo + //t0*wal->xrepeat*8 = (gux*x0 + guo) / (gdx*x0 + gdo) + //t1*wal->xrepeat*8 = (gux*x1 + guo) / (gdx*x1 + gdo) + //gdx*x0 + gdo = yp0 + //gdx*x1 + gdo = yp1 + gdx = (ryp0-ryp1)*gxyaspect / (x0-x1); + gdy = 0; + gdo = ryp0*gxyaspect - gdx*x0; + + //gux*x0 + guo = t0*wal->xrepeat*8*yp0 + //gux*x1 + guo = t1*wal->xrepeat*8*yp1 + gux = (t0*ryp0 - t1*ryp1)*gxyaspect*(float)wal->xrepeat*8.f / (x0-x1); + guo = t0*ryp0*gxyaspect*(float)wal->xrepeat*8.f - gux*x0; + guo += (float)wal->xpanning*gdo; + gux += (float)wal->xpanning*gdx; + guy = 0; + //Derivation for u: + // (gvx*x0 + gvy*cy0 + gvo) / (gdx*x0 + gdy*cy0 + gdo) = 0 + // (gvx*x1 + gvy*cy1 + gvo) / (gdx*x1 + gdy*cy1 + gdo) = 0 + // (gvx*x0 + gvy*fy0 + gvo) / (gdx*x0 + gdy*fy0 + gdo) = v + // (gvx*x1 + gvy*fy1 + gvo) / (gdx*x1 + gdy*fy1 + gdo) = v + // (gvx*x0 + gvy*cy0 + gvo*1) = 0 + // (gvx*x1 + gvy*cy1 + gvo*1) = 0 + // (gvx*x0 + gvy*fy0 + gvo*1) = t + ogux = gux; oguy = guy; oguo = guo; + + if (nextsectnum >= 0) + { + getzsofslope(nextsectnum,(long)nx0,(long)ny0,&cz,&fz); + ocy0 = ((float)(cz-globalposz))*ryp0 + ghoriz; + ofy0 = ((float)(fz-globalposz))*ryp0 + ghoriz; + getzsofslope(nextsectnum,(long)nx1,(long)ny1,&cz,&fz); + ocy1 = ((float)(cz-globalposz))*ryp1 + ghoriz; + ofy1 = ((float)(fz-globalposz))*ryp1 + ghoriz; + + if ((wal->cstat&48) == 16) maskwall[maskwallcnt++] = z; + + if (((cy0 < ocy0) || (cy1 < ocy1)) && (!((sec->ceilingstat§or[nextsectnum].ceilingstat)&1))) + { + globalpicnum = wal->picnum; globalshade = wal->shade; globalpal = (long)((unsigned char)wal->pal); + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,wallnum+16384); + + if (!(wal->cstat&4)) i = sector[nextsectnum].ceilingz; else i = sec->ceilingz; + t0 = ((float)(i-globalposz))*ryp0 + ghoriz; + t1 = ((float)(i-globalposz))*ryp1 + ghoriz; + t = ((gdx*x0 + gdo) * (float)wal->yrepeat) / ((x1-x0) * ryp0 * 2048.f); + i = (1<<(picsiz[globalpicnum]>>4)); if (i < tilesizy[globalpicnum]) i <<= 1; + fy = (float)wal->ypanning * ((float)i) / 256.0; + gvx = (t0-t1)*t; + gvy = (x1-x0)*t; + gvo = -gvx*x0 - gvy*t0 + fy*gdo; gvx += fy*gdx; gvy += fy*gdy; + + if (wal->cstat&8) //xflip + { + t = (float)(wal->xrepeat*8 + wal->xpanning*2); + gux = gdx*t - gux; + guy = gdy*t - guy; + guo = gdo*t - guo; + } + if (wal->cstat&256) { gvx = -gvx; gvy = -gvy; gvo = -gvo; } //yflip + + pow2xsplit = 1; domost(x1,ocy1,x0,ocy0); + + if (wal->cstat&8) { gux = ogux; guy = oguy; guo = oguo; } + } + if (((ofy0 < fy0) || (ofy1 < fy1)) && (!((sec->floorstat§or[nextsectnum].floorstat)&1))) + { + if (!(wal->cstat&2)) nwal = wal; + else + { + nwal = &wall[wal->nextwall]; + guo += (float)(nwal->xpanning-wal->xpanning)*gdo; + gux += (float)(nwal->xpanning-wal->xpanning)*gdx; + guy += (float)(nwal->xpanning-wal->xpanning)*gdy; + } + globalpicnum = nwal->picnum; globalshade = nwal->shade; globalpal = (long)((unsigned char)nwal->pal); + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,wallnum+16384); + + if (!(nwal->cstat&4)) i = sector[nextsectnum].floorz; else i = sec->ceilingz; + t0 = ((float)(i-globalposz))*ryp0 + ghoriz; + t1 = ((float)(i-globalposz))*ryp1 + ghoriz; + t = ((gdx*x0 + gdo) * (float)wal->yrepeat) / ((x1-x0) * ryp0 * 2048.f); + i = (1<<(picsiz[globalpicnum]>>4)); if (i < tilesizy[globalpicnum]) i <<= 1; + fy = (float)nwal->ypanning * ((float)i) / 256.0; + gvx = (t0-t1)*t; + gvy = (x1-x0)*t; + gvo = -gvx*x0 - gvy*t0 + fy*gdo; gvx += fy*gdx; gvy += fy*gdy; + + if (wal->cstat&8) //xflip + { + t = (float)(wal->xrepeat*8 + nwal->xpanning*2); + gux = gdx*t - gux; + guy = gdy*t - guy; + guo = gdo*t - guo; + } + if (nwal->cstat&256) { gvx = -gvx; gvy = -gvy; gvo = -gvo; } //yflip + + pow2xsplit = 1; domost(x0,ofy0,x1,ofy1); + + if (wal->cstat&(2+8)) { guo = oguo; gux = ogux; guy = oguy; } + } + } + + if ((nextsectnum < 0) || (wal->cstat&32)) //White/1-way wall + { + if (nextsectnum < 0) globalpicnum = wal->picnum; else globalpicnum = wal->overpicnum; + globalshade = wal->shade; globalpal = (long)((unsigned char)wal->pal); + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,wallnum+16384); + + if (nextsectnum >= 0) { if (!(wal->cstat&4)) i = nextsec->ceilingz; else i = sec->ceilingz; } + else { if (!(wal->cstat&4)) i = sec->ceilingz; else i = sec->floorz; } + t0 = ((float)(i-globalposz))*ryp0 + ghoriz; + t1 = ((float)(i-globalposz))*ryp1 + ghoriz; + t = ((gdx*x0 + gdo) * (float)wal->yrepeat) / ((x1-x0) * ryp0 * 2048.f); + i = (1<<(picsiz[globalpicnum]>>4)); if (i < tilesizy[globalpicnum]) i <<= 1; + fy = (float)wal->ypanning * ((float)i) / 256.0; + gvx = (t0-t1)*t; + gvy = (x1-x0)*t; + gvo = -gvx*x0 - gvy*t0 + fy*gdo; gvx += fy*gdx; gvy += fy*gdy; + + if (wal->cstat&8) //xflip + { + t = (float)(wal->xrepeat*8 + wal->xpanning*2); + gux = gdx*t - gux; + guy = gdy*t - guy; + guo = gdo*t - guo; + } + if (wal->cstat&256) { gvx = -gvx; gvy = -gvy; gvo = -gvo; } //yflip + pow2xsplit = 1; domost(x0,-10000,x1,-10000); + } + + if (nextsectnum >= 0) + if ((!(gotsector[nextsectnum>>3]&pow2char[nextsectnum&7])) && (testvisiblemost(x0,x1))) + polymost_scansector(nextsectnum); + } +} + +static long wallfront(long, long); +static long polymost_bunchfront (long b1, long b2) +{ + double x1b1, x1b2, x2b1, x2b2; + long b1f, b2f, i; + + b1f = bunchfirst[b1]; x1b1 = dxb1[b1f]; x2b2 = dxb2[bunchlast[b2]]; if (x1b1 >= x2b2) return(-1); + b2f = bunchfirst[b2]; x1b2 = dxb1[b2f]; x2b1 = dxb2[bunchlast[b1]]; if (x1b2 >= x2b1) return(-1); + + if (x1b1 >= x1b2) + { + for(i=b2f;dxb2[i]<=x1b1;i=p2[i]); + return(wallfront(b1f,i)); + } + for(i=b1f;dxb2[i]<=x1b2;i=p2[i]); + return(wallfront(i,b2f)); +} + +static void polymost_scansector (long sectnum) +{ + double d, xp1, yp1, xp2, yp2; + walltype *wal, *wal2; + spritetype *spr; + long z, zz, startwall, endwall, numscansbefore, scanfirst, bunchfrst, nextsectnum; + long xs, ys, x1, y1, x2, y2; + + if (sectnum < 0) return; + if (automapping) show2dsector[sectnum>>3] |= pow2char[sectnum&7]; + + sectorborder[0] = sectnum, sectorbordercnt = 1; + do + { + sectnum = sectorborder[--sectorbordercnt]; + + for(z=headspritesect[sectnum];z>=0;z=nextspritesect[z]) + { + spr = &sprite[z]; + if ((((spr->cstat&0x8000) == 0) || (showinvisibility)) && + (spr->xrepeat > 0) && (spr->yrepeat > 0) && + (spritesortcnt < MAXSPRITESONSCREEN)) + { + xs = spr->x-globalposx; ys = spr->y-globalposy; + if ((spr->cstat&48) || (xs*gcosang+ys*gsinang > 0)) + { + copybufbyte(spr,&tsprite[spritesortcnt],sizeof(spritetype)); + tsprite[spritesortcnt++].owner = z; + } + } + } + + gotsector[sectnum>>3] |= pow2char[sectnum&7]; + + bunchfrst = numbunches; + numscansbefore = numscans; + + startwall = sector[sectnum].wallptr; endwall = sector[sectnum].wallnum+startwall; + scanfirst = numscans; + xp2 = 0; yp2 = 0; + for(z=startwall,wal=&wall[z];zpoint2]; + x1 = wal->x-globalposx; y1 = wal->y-globalposy; + x2 = wal2->x-globalposx; y2 = wal2->y-globalposy; + + nextsectnum = wal->nextsector; //Scan close sectors + if ((nextsectnum >= 0) && (!(wal->cstat&32)) && (!(gotsector[nextsectnum>>3]&pow2char[nextsectnum&7]))) + { + d = (double)x1*(double)y2 - (double)x2*(double)y1; xp1 = (double)(x2-x1); yp1 = (double)(y2-y1); + if (d*d <= (xp1*xp1 + yp1*yp1)*(SCISDIST*SCISDIST*260.0)) + sectorborder[sectorbordercnt++] = nextsectnum; + } + + if ((z == startwall) || (wall[z-1].point2 != z)) + { + xp1 = ((double)y1*(double)cosglobalang - (double)x1*(double)singlobalang )/64.0; + yp1 = ((double)x1*(double)cosviewingrangeglobalang + (double)y1*(double)sinviewingrangeglobalang)/64.0; + } + else { xp1 = xp2; yp1 = yp2; } + xp2 = ((double)y2*(double)cosglobalang - (double)x2*(double)singlobalang )/64.0; + yp2 = ((double)x2*(double)cosviewingrangeglobalang + (double)y2*(double)sinviewingrangeglobalang)/64.0; + if ((yp1 >= SCISDIST) || (yp2 >= SCISDIST)) + if ((double)xp1*(double)yp2 < (double)xp2*(double)yp1) //if wall is facing you... + { + if (yp1 >= SCISDIST) + dxb1[numscans] = (double)xp1*ghalfx/(double)yp1 + ghalfx; + else dxb1[numscans] = -1e32; + + if (yp2 >= SCISDIST) + dxb2[numscans] = (double)xp2*ghalfx/(double)yp2 + ghalfx; + else dxb2[numscans] = 1e32; + + if (dxb1[numscans] < dxb2[numscans]) + { thesector[numscans] = sectnum; thewall[numscans] = z; p2[numscans] = numscans+1; numscans++; } + } + + if ((wall[z].point2 < z) && (scanfirst < numscans)) + { p2[numscans-1] = scanfirst; scanfirst = numscans; } + } + + for(z=numscansbefore;z dxb1[p2[z]])) + { bunchfirst[numbunches++] = p2[z]; p2[z] = -1; } + + for(z=bunchfrst;z=0;zz=p2[zz]); + bunchlast[z] = zz; + } + } while (sectorbordercnt > 0); +} + +void polymost_drawrooms () +{ + long i, j, k, n, n2, closest; + double ox, oy, oz, ox2, oy2, oz2, r, px[6], py[6], pz[6], px2[6], py2[6], pz2[6], sx[6], sy[6]; + + if (!rendmode) return; + + begindrawing(); + frameoffset = frameplace + windowy1*bytesperline + windowx1; + +#ifdef USE_OPENGL + if (rendmode == 3) + { + resizeglcheck(); + + //bglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + bglEnable(GL_TEXTURE_2D); + //bglTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); //default anyway + bglEnable(GL_DEPTH_TEST); + bglDepthFunc(GL_ALWAYS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS + + //bglPolygonOffset(1,1); //Supposed to make sprites pasted on walls or floors not disappear + bglDepthRange(0.00001,1.0); //<- this is more widely supported than glPolygonOffset + + //Enable this for OpenGL red-blue glasses mode :) + if (glredbluemode) + { + float m[4][4]; + static int grbfcnt = 0; grbfcnt++; + if (redblueclearcnt < numpages) { redblueclearcnt++; bglColorMask(1,1,1,1); bglClear(GL_COLOR_BUFFER_BIT); } + if (grbfcnt&1) + { + bglViewport(windowx1-16,yres-(windowy2+1),windowx2-(windowx1-16)+1,windowy2-windowy1+1); + bglColorMask(1,0,0,1); + globalposx += singlobalang/1024; + globalposy -= cosglobalang/1024; + } + else + { + bglViewport(windowx1,yres-(windowy2+1),windowx2+16-windowx1+1,windowy2-windowy1+1); + bglColorMask(0,1,1,1); + globalposx -= singlobalang/1024; + globalposy += cosglobalang/1024; + } + } + } +#endif + + //Polymost supports true look up/down :) Here, we convert horizon to angle. + //gchang&gshang are cos&sin of this angle (respectively) + gyxscale = ((double)xdimenscale)/131072.0; + gxyaspect = ((double)xyaspect*(double)viewingrange)*(5.0/(65536.0*262144.0)); + gviewxrange = ((double)viewingrange)*((double)xdimen)/(32768.0*1024.0); + gcosang = ((double)cosglobalang)/262144.0; + gsinang = ((double)singlobalang)/262144.0; + gcosang2 = gcosang*((double)viewingrange)/65536.0; + gsinang2 = gsinang*((double)viewingrange)/65536.0; + ghalfx = (double)halfxdimen; grhalfxdown10 = 1.0/(((double)ghalfx)*1024); + ghoriz = (double)globalhoriz; + + gvisibility = ((float)globalvisibility)*gxyaspect*FOGSCALE; + + //global cos/sin height angle + r = (double)((ydimen>>1)-ghoriz); + gshang = r/sqrt(r*r+ghalfx*ghalfx); + gchang = sqrt(1.0-gshang*gshang); + ghoriz = (double)(ydimen>>1); + + //global cos/sin tilt angle + gctang = cos(gtang); + gstang = sin(gtang); + if (fabs(gstang) < .001) //This hack avoids nasty precision bugs in domost() + { gstang = 0; if (gctang > 0) gctang = 1.0; else gctang = -1.0; } + + if (inpreparemirror) + gstang = -gstang; + + //Generate viewport trapezoid (for handling screen up/down) + px[0] = px[3] = 0-1; px[1] = px[2] = windowx2+1-windowx1+2; + py[0] = py[1] = 0-1; py[2] = py[3] = windowy2+1-windowy1+2; n = 4; + for(i=0;i= n) j = 0; + if (pz[i] >= SCISDIST) { px2[n2] = px[i]; py2[n2] = py[i]; pz2[n2] = pz[i]; n2++; } + if ((pz[i] >= SCISDIST) != (pz[j] >= SCISDIST)) + { + r = (SCISDIST-pz[i])/(pz[j]-pz[i]); + px2[n2] = (px[j]-px[i])*r + px[i]; + py2[n2] = (py[j]-py[i])*r + py[i]; + pz2[n2] = SCISDIST; n2++; + } + } + if (n2 < 3) { enddrawing(); return; } + for(i=0;i>12,vy>>12,vz>>8,&hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,0xffff0030); + hitallsprites = 0; + + searchsector = hitsect; + if (hitwall >= 0) + { + searchwall = hitwall; searchstat = 0; + if (wall[hitwall].nextwall >= 0) + { + long cz, fz; + getzsofslope(wall[hitwall].nextsector,hitx,hity,&cz,&fz); + if (hitz > fz) + { + if (wall[hitwall].cstat&2) //'2' bottoms of walls + searchwall = wall[hitwall].nextwall; + } + else if ((hitz > cz) && (wall[hitwall].cstat&(16+32))) //masking or 1-way + searchstat = 4; + } + } + else if (hitsprite >= 0) { searchwall = hitsprite; searchstat = 3; } + else + { + long cz, fz; + getzsofslope(hitsect,hitx,hity,&cz,&fz); + if ((hitz<<1) < cz+fz) searchstat = 1; else searchstat = 2; + //if (vz < 0) searchstat = 1; else searchstat = 2; //Won't work for slopes :/ + } + searchit = 0; + } + + numscans = numbunches = 0; + + if (globalcursectnum >= MAXSECTORS) + globalcursectnum -= MAXSECTORS; + else + { + i = globalcursectnum; + updatesector(globalposx,globalposy,&globalcursectnum); + if (globalcursectnum < 0) globalcursectnum = i; + } + + polymost_scansector(globalcursectnum); + + if (inpreparemirror) + { + grhalfxdown10x = -grhalfxdown10; + inpreparemirror = 0; + polymost_drawalls(0); + numbunches--; + bunchfirst[0] = bunchfirst[numbunches]; + bunchlast[0] = bunchlast[numbunches]; + } + else + grhalfxdown10x = grhalfxdown10; + + while (numbunches > 0) + { + memset(tempbuf,0,numbunches+3); tempbuf[0] = 1; + + closest = 0; //Almost works, but not quite :( + for(i=1;ipoint2]; + sectnum = thesector[z]; sec = §or[sectnum]; + nsec = §or[wal->nextsector]; + z1 = max(nsec->ceilingz,sec->ceilingz); + z2 = min(nsec->floorz,sec->floorz); + + globalpicnum = wal->overpicnum; if ((unsigned long)globalpicnum >= MAXTILES) globalpicnum = 0; + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)thewall[z]+16384); + globalshade = (long)wal->shade; + globalpal = (long)((unsigned char)wal->pal); + globalorientation = (long)wal->cstat; + + sx0 = (float)(wal->x-globalposx); sx1 = (float)(wal2->x-globalposx); + sy0 = (float)(wal->y-globalposy); sy1 = (float)(wal2->y-globalposy); + yp0 = sx0*gcosang2 + sy0*gsinang2; + yp1 = sx1*gcosang2 + sy1*gsinang2; + if ((yp0 < SCISDIST) && (yp1 < SCISDIST)) return; + xp0 = sy0*gcosang - sx0*gsinang; + xp1 = sy1*gcosang - sx1*gsinang; + + //Clip to close parallel-screen plane + oxp0 = xp0; oyp0 = yp0; + if (yp0 < SCISDIST) { t0 = (SCISDIST-yp0)/(yp1-yp0); xp0 = (xp1-xp0)*t0+xp0; yp0 = SCISDIST; } + else t0 = 0.f; + if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; yp1 = SCISDIST; } + else { t1 = 1.f; } + + getzsofslope(sectnum,(long)((wal2->x-wal->x)*t0+wal->x),(long)((wal2->y-wal->y)*t0+wal->y),&cz[0],&fz[0]); + getzsofslope(wal->nextsector,(long)((wal2->x-wal->x)*t0+wal->x),(long)((wal2->y-wal->y)*t0+wal->y),&cz[1],&fz[1]); + getzsofslope(sectnum,(long)((wal2->x-wal->x)*t1+wal->x),(long)((wal2->y-wal->y)*t1+wal->y),&cz[2],&fz[2]); + getzsofslope(wal->nextsector,(long)((wal2->x-wal->x)*t1+wal->x),(long)((wal2->y-wal->y)*t1+wal->y),&cz[3],&fz[3]); + + ryp0 = 1.f/yp0; ryp1 = 1.f/yp1; + + //Generate screen coordinates for front side of wall + x0 = ghalfx*xp0*ryp0 + ghalfx; + x1 = ghalfx*xp1*ryp1 + ghalfx; + if (x1 <= x0) return; + + ryp0 *= gyxscale; ryp1 *= gyxscale; + + gdx = (ryp0-ryp1)*gxyaspect / (x0-x1); + gdy = 0; + gdo = ryp0*gxyaspect - gdx*x0; + + //gux*x0 + guo = t0*wal->xrepeat*8*yp0 + //gux*x1 + guo = t1*wal->xrepeat*8*yp1 + gux = (t0*ryp0 - t1*ryp1)*gxyaspect*(float)wal->xrepeat*8.f / (x0-x1); + guo = t0*ryp0*gxyaspect*(float)wal->xrepeat*8.f - gux*x0; + guo += (float)wal->xpanning*gdo; + gux += (float)wal->xpanning*gdx; + guy = 0; + + if (!(wal->cstat&4)) i = z1; else i = z2; + i -= globalposz; + t0 = ((float)i)*ryp0 + ghoriz; + t1 = ((float)i)*ryp1 + ghoriz; + t = ((gdx*x0 + gdo) * (float)wal->yrepeat) / ((x1-x0) * ryp0 * 2048.f); + i = (1<<(picsiz[globalpicnum]>>4)); if (i < tilesizy[globalpicnum]) i <<= 1; + fy = (float)wal->ypanning * ((float)i) / 256.0; + gvx = (t0-t1)*t; + gvy = (x1-x0)*t; + gvo = -gvx*x0 - gvy*t0 + fy*gdo; gvx += fy*gdx; gvy += fy*gdy; + + if (wal->cstat&8) //xflip + { + t = (float)(wal->xrepeat*8 + wal->xpanning*2); + gux = gdx*t - gux; + guy = gdy*t - guy; + guo = gdo*t - guo; + } + if (wal->cstat&256) { gvx = -gvx; gvy = -gvy; gvo = -gvo; } //yflip + + method = 1; pow2xsplit = 1; + if (wal->cstat&128) { if (!(wal->cstat&512)) method = 2; else method = 3; } + +#ifdef USE_OPENGL + if (!nofog) { + if (rendmode == 3) { + float col[4]; + col[0] = (float)palookupfog[sec->floorpal].r / 63.f; + col[1] = (float)palookupfog[sec->floorpal].g / 63.f; + col[2] = (float)palookupfog[sec->floorpal].b / 63.f; + col[3] = 0; + bglFogfv(GL_FOG_COLOR,col); + bglFogf(GL_FOG_DENSITY,gvisibility*((float)((unsigned char)(sec->visibility+16)))); + } + } +#endif + + for(i=0;i<2;i++) + { + csy[i] = ((float)(cz[i]-globalposz))*ryp0 + ghoriz; + fsy[i] = ((float)(fz[i]-globalposz))*ryp0 + ghoriz; + csy[i+2] = ((float)(cz[i+2]-globalposz))*ryp1 + ghoriz; + fsy[i+2] = ((float)(fz[i+2]-globalposz))*ryp1 + ghoriz; + } + + //Clip 2 quadrilaterals + // /csy3 + // / | + // csy0------/----csy2 + // | /xxxxxxx| + // | /xxxxxxxxx| + // csy1/xxxxxxxxxxx| + // |xxxxxxxxxxx/fsy3 + // |xxxxxxxxx/ | + // |xxxxxxx/ | + // fsy0----/------fsy2 + // | / + // fsy1/ + + dpx[0] = x0; dpy[0] = csy[1]; + dpx[1] = x1; dpy[1] = csy[3]; + dpx[2] = x1; dpy[2] = fsy[3]; + dpx[3] = x0; dpy[3] = fsy[1]; + n = 4; + + //Clip to (x0,csy[0])-(x1,csy[2]) + n2 = 0; t1 = -((dpx[0]-x0)*(csy[2]-csy[0]) - (dpy[0]-csy[0])*(x1-x0)); + for(i=0;i= n) j = 0; + + t0 = t1; t1 = -((dpx[j]-x0)*(csy[2]-csy[0]) - (dpy[j]-csy[0])*(x1-x0)); + if (t0 >= 0) { dpx2[n2] = dpx[i]; dpy2[n2] = dpy[i]; n2++; } + if ((t0 >= 0) != (t1 >= 0)) + { + r = t0/(t0-t1); + dpx2[n2] = (dpx[j]-dpx[i])*r + dpx[i]; + dpy2[n2] = (dpy[j]-dpy[i])*r + dpy[i]; + n2++; + } + } + if (n2 < 3) return; + + //Clip to (x1,fsy[2])-(x0,fsy[0]) + n = 0; t1 = -((dpx2[0]-x1)*(fsy[0]-fsy[2]) - (dpy2[0]-fsy[2])*(x0-x1)); + for(i=0;i= n2) j = 0; + + t0 = t1; t1 = -((dpx2[j]-x1)*(fsy[0]-fsy[2]) - (dpy2[j]-fsy[2])*(x0-x1)); + if (t0 >= 0) { dpx[n] = dpx2[i]; dpy[n] = dpy2[i]; n++; } + if ((t0 >= 0) != (t1 >= 0)) + { + r = t0/(t0-t1); + dpx[n] = (dpx2[j]-dpx2[i])*r + dpx2[i]; + dpy[n] = (dpy2[j]-dpy2[i])*r + dpy2[i]; + n++; + } + } + if (n < 3) return; + + drawpoly(dpx,dpy,n,method); +} + +void polymost_drawsprite (long snum) +{ + double px[6], py[6]; + float f, r, c, s, fx, fy, sx0, sy0, sx1, sy1, xp0, yp0, xp1, yp1, oxp0, oyp0, ryp0, ryp1, ft[4]; + float x0, y0, x1, y1, sc0, sf0, sc1, sf1, px2[6], py2[6], xv, yv, t0, t1; + long i, j, spritenum, xoff, yoff, method, npoints; + spritetype *tspr; + + tspr = tspriteptr[snum]; + if (tspr->owner < 0 || tspr->picnum < 0) return; + + globalpicnum = tspr->picnum; + globalshade = tspr->shade; + globalpal = tspr->pal; + globalorientation = tspr->cstat; + spritenum = tspr->owner; + + if ((globalorientation&48) != 48) { // only non-voxel sprites should do this + if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,spritenum+32768); + + xoff = (long)((signed char)((picanm[globalpicnum]>>8)&255))+((long)tspr->xoffset); + yoff = (long)((signed char)((picanm[globalpicnum]>>16)&255))+((long)tspr->yoffset); + } + + method = 1+4; + if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; } + +#ifdef USE_OPENGL + if (!nofog && rendmode == 3) { + float col[4]; + col[0] = (float)palookupfog[sector[tspr->sectnum].floorpal].r / 63.f; + col[1] = (float)palookupfog[sector[tspr->sectnum].floorpal].g / 63.f; + col[2] = (float)palookupfog[sector[tspr->sectnum].floorpal].b / 63.f; + col[3] = 0; + bglFogfv(GL_FOG_COLOR,col); //default is 0,0,0,0 + bglFogf(GL_FOG_DENSITY,gvisibility*((float)((unsigned char)(sector[tspr->sectnum].visibility+16)))); + } + + while (rendmode == 3 && !(spriteext[tspr->owner].flags&SPREXT_NOTMD)) { + if (usemodels && tile2model[tspr->picnum].modelid >= 0 && tile2model[tspr->picnum].framenum >= 0) { + if (mddraw(tspr)) return; + break; // else, render as flat sprite + } + if (usevoxels && (tspr->cstat&48)!=48 && tiletovox[tspr->picnum] >= 0 && voxmodels[ tiletovox[tspr->picnum] ]) { + if (voxdraw(voxmodels[ tiletovox[tspr->picnum] ], tspr)) return; + break; // else, render as flat sprite + } + if ((tspr->cstat&48)==48 && voxmodels[ tspr->picnum ]) { + voxdraw(voxmodels[ tspr->picnum ], tspr); + return; + } + break; + } +#endif + + switch((globalorientation>>4)&3) + { + case 0: //Face sprite + + //Project 3D to 2D + sx0 = (float)(tspr->x-globalposx); + sy0 = (float)(tspr->y-globalposy); + xp0 = sy0*gcosang - sx0*gsinang; + yp0 = sx0*gcosang2 + sy0*gsinang2; + if (yp0 <= SCISDIST) return; + ryp0 = 1/yp0; + sx0 = ghalfx*xp0*ryp0 + ghalfx; + sy0 = ((float)(tspr->z-globalposz))*gyxscale*ryp0 + ghoriz; + + f = ryp0*(float)xdimen/160.0; + fx = ((float)tspr->xrepeat)*f; + fy = ((float)tspr->yrepeat)*f*((float)yxaspect/65536.0); + sx0 -= fx*(float)xoff; if (tilesizx[globalpicnum]&1) sx0 += fx*.5; + sy0 -= fy*(float)yoff; + fx *= ((float)tilesizx[globalpicnum]); + fy *= ((float)tilesizy[globalpicnum]); + + px[0] = px[3] = sx0-fx*.5; px[1] = px[2] = sx0+fx*.5; + if (!(globalorientation&128)) { py[0] = py[1] = sy0-fy; py[2] = py[3] = sy0; } + else { py[0] = py[1] = sy0-fy*.5; py[2] = py[3] = sy0+fy*.5; } + + gdx = gdy = guy = gvx = 0; gdo = ryp0*gviewxrange; + if (!(globalorientation&4)) + { gux = (float)tilesizx[globalpicnum]*gdo/(px[1]-px[0]+.002); guo = -gux*(px[0]-.001); } + else { gux = (float)tilesizx[globalpicnum]*gdo/(px[0]-px[1]-.002); guo = -gux*(px[1]+.001); } + if (!(globalorientation&8)) + { gvy = (float)tilesizy[globalpicnum]*gdo/(py[3]-py[0]+.002); gvo = -gvy*(py[0]-.001); } + else { gvy = (float)tilesizy[globalpicnum]*gdo/(py[0]-py[3]-.002); gvo = -gvy*(py[3]+.001); } + + //Clip sprites to ceilings/floors when no parallaxing and not sloped + if (!(sector[tspr->sectnum].ceilingstat&3)) + { + sy0 = ((float)(sector[tspr->sectnum].ceilingz-globalposz))*gyxscale*ryp0 + ghoriz; + if (py[0] < sy0) py[0] = py[1] = sy0; + } + if (!(sector[tspr->sectnum].floorstat&3)) + { + sy0 = ((float)(sector[tspr->sectnum].floorz-globalposz))*gyxscale*ryp0 + ghoriz; + if (py[2] > sy0) py[2] = py[3] = sy0; + } + + pow2xsplit = 0; drawpoly(px,py,4,method); + break; + case 1: //Wall sprite + + //Project 3D to 2D + if (globalorientation&4) xoff = -xoff; + if (globalorientation&8) yoff = -yoff; + + xv = (float)tspr->xrepeat * (float)sintable[(tspr->ang )&2047] / 65536.0; + yv = (float)tspr->xrepeat * (float)sintable[(tspr->ang+1536)&2047] / 65536.0; + f = (float)(tilesizx[globalpicnum]>>1) + (float)xoff; + x0 = (float)(tspr->x-globalposx) - xv*f; x1 = xv*(float)tilesizx[globalpicnum] + x0; + y0 = (float)(tspr->y-globalposy) - yv*f; y1 = yv*(float)tilesizx[globalpicnum] + y0; + + yp0 = x0*gcosang2 + y0*gsinang2; + yp1 = x1*gcosang2 + y1*gsinang2; + if ((yp0 <= SCISDIST) && (yp1 <= SCISDIST)) return; + xp0 = y0*gcosang - x0*gsinang; + xp1 = y1*gcosang - x1*gsinang; + + //Clip to close parallel-screen plane + oxp0 = xp0; oyp0 = yp0; + if (yp0 < SCISDIST) { t0 = (SCISDIST-yp0)/(yp1-yp0); xp0 = (xp1-xp0)*t0+xp0; yp0 = SCISDIST; } + else { t0 = 0.f; } + if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; yp1 = SCISDIST; } + else { t1 = 1.f; } + + f = ((float)tspr->yrepeat) * (float)tilesizy[globalpicnum] * 4; + + ryp0 = 1.0/yp0; + ryp1 = 1.0/yp1; + sx0 = ghalfx*xp0*ryp0 + ghalfx; + sx1 = ghalfx*xp1*ryp1 + ghalfx; + ryp0 *= gyxscale; + ryp1 *= gyxscale; + + tspr->z -= ((yoff*tspr->yrepeat)<<2); + if (globalorientation&128) + { + tspr->z += ((tilesizy[globalpicnum]*tspr->yrepeat)<<1); + if (tilesizy[globalpicnum]&1) tspr->z += (tspr->yrepeat<<1); //Odd yspans + } + + sc0 = ((float)(tspr->z-globalposz-f))*ryp0 + ghoriz; + sc1 = ((float)(tspr->z-globalposz-f))*ryp1 + ghoriz; + sf0 = ((float)(tspr->z-globalposz))*ryp0 + ghoriz; + sf1 = ((float)(tspr->z-globalposz))*ryp1 + ghoriz; + + gdx = (ryp0-ryp1)*gxyaspect / (sx0-sx1); + gdy = 0; + gdo = ryp0*gxyaspect - gdx*sx0; + + //Original equations: + //(gux*sx0 + guo)/(gdx*sx1 + gdo) = tilesizx[globalpicnum]*t0 + //(gux*sx1 + guo)/(gdx*sx1 + gdo) = tilesizx[globalpicnum]*t1 + // + // gvx*sx0 + gvy*sc0 + gvo = 0 + // gvy*sx1 + gvy*sc1 + gvo = 0 + //(gvx*sx0 + gvy*sf0 + gvo)/(gdx*sx0 + gdo) = tilesizy[globalpicnum] + //(gvx*sx1 + gvy*sf1 + gvo)/(gdx*sx1 + gdo) = tilesizy[globalpicnum] + + //gux*sx0 + guo = t0*tilesizx[globalpicnum]*yp0 + //gux*sx1 + guo = t1*tilesizx[globalpicnum]*yp1 + if (globalorientation&4) { t0 = 1.f-t0; t1 = 1.f-t1; } + gux = (t0*ryp0 - t1*ryp1)*gxyaspect*(float)tilesizx[globalpicnum] / (sx0-sx1); + guy = 0; + guo = t0*ryp0*gxyaspect*(float)tilesizx[globalpicnum] - gux*sx0; + + //gvx*sx0 + gvy*sc0 + gvo = 0 + //gvx*sx1 + gvy*sc1 + gvo = 0 + //gvx*sx0 + gvy*sf0 + gvo = tilesizy[globalpicnum]*(gdx*sx0 + gdo) + f = ((float)tilesizy[globalpicnum])*(gdx*sx0 + gdo) / ((sx0-sx1)*(sc0-sf0)); + if (!(globalorientation&8)) + { + gvx = (sc0-sc1)*f; + gvy = (sx1-sx0)*f; + gvo = -gvx*sx0 - gvy*sc0; + } + else + { + gvx = (sf1-sf0)*f; + gvy = (sx0-sx1)*f; + gvo = -gvx*sx0 - gvy*sf0; + } + + //Clip sprites to ceilings/floors when no parallaxing + if (!(sector[tspr->sectnum].ceilingstat&1)) + { + f = ((float)tspr->yrepeat) * (float)tilesizy[globalpicnum] * 4; + if (sector[tspr->sectnum].ceilingz > tspr->z-f) + { + sc0 = ((float)(sector[tspr->sectnum].ceilingz-globalposz))*ryp0 + ghoriz; + sc1 = ((float)(sector[tspr->sectnum].ceilingz-globalposz))*ryp1 + ghoriz; + } + } + if (!(sector[tspr->sectnum].floorstat&1)) + { + if (sector[tspr->sectnum].floorz < tspr->z) + { + sf0 = ((float)(sector[tspr->sectnum].floorz-globalposz))*ryp0 + ghoriz; + sf1 = ((float)(sector[tspr->sectnum].floorz-globalposz))*ryp1 + ghoriz; + } + } + + if (sx0 > sx1) + { + if (globalorientation&64) return; //1-sided sprite + f = sx0; sx0 = sx1; sx1 = f; + f = sc0; sc0 = sc1; sc1 = f; + f = sf0; sf0 = sf1; sf1 = f; + } + + px[0] = sx0; py[0] = sc0; + px[1] = sx1; py[1] = sc1; + px[2] = sx1; py[2] = sf1; + px[3] = sx0; py[3] = sf0; + pow2xsplit = 0; drawpoly(px,py,4,method); + break; + case 2: //Floor sprite + + if ((globalorientation&64) != 0) + if ((globalposz > tspr->z) == (!(globalorientation&8))) + return; + if ((globalorientation&4) > 0) xoff = -xoff; + if ((globalorientation&8) > 0) yoff = -yoff; + + i = (tspr->ang&2047); + c = sintable[(i+512)&2047]/65536.0; + s = sintable[i]/65536.0; + x0 = ((tilesizx[globalpicnum]>>1)-xoff)*tspr->xrepeat; + y0 = ((tilesizy[globalpicnum]>>1)-yoff)*tspr->yrepeat; + x1 = ((tilesizx[globalpicnum]>>1)+xoff)*tspr->xrepeat; + y1 = ((tilesizy[globalpicnum]>>1)+yoff)*tspr->yrepeat; + + //Project 3D to 2D + for(j=0;j<4;j++) + { + sx0 = (float)(tspr->x-globalposx); + sy0 = (float)(tspr->y-globalposy); + if ((j+0)&2) { sy0 -= s*y0; sx0 -= c*y0; } else { sy0 += s*y1; sx0 += c*y1; } + if ((j+1)&2) { sx0 -= s*x0; sy0 += c*x0; } else { sx0 += s*x1; sy0 -= c*x1; } + px[j] = sy0*gcosang - sx0*gsinang; + py[j] = sx0*gcosang2 + sy0*gsinang2; + } + + if (tspr->z < globalposz) //if floor sprite is above you, reverse order of points + { + f = px[0]; px[0] = px[1]; px[1] = f; + f = py[0]; py[0] = py[1]; py[1] = f; + f = px[2]; px[2] = px[3]; px[3] = f; + f = py[2]; py[2] = py[3]; py[3] = f; + } + + //Clip to SCISDIST plane + npoints = 0; + for(i=0;i<4;i++) + { + j = ((i+1)&3); + if (py[i] >= SCISDIST) { px2[npoints] = px[i]; py2[npoints] = py[i]; npoints++; } + if ((py[i] >= SCISDIST) != (py[j] >= SCISDIST)) + { + f = (SCISDIST-py[i])/(py[j]-py[i]); + px2[npoints] = (px[j]-px[i])*f + px[i]; + py2[npoints] = (py[j]-py[i])*f + py[i]; npoints++; + } + } + if (npoints < 3) return; + + //Project rotated 3D points to screen + f = ((float)(tspr->z-globalposz))*gyxscale; + for(j=0;jz-globalposz); + gdo = -ghoriz*gdy; + //copied&modified from relative alignment + xv = (float)tspr->x + s*x1 + c*y1; fx = (double)-(x0+x1)*s; + yv = (float)tspr->y + s*y1 - c*x1; fy = (double)+(x0+x1)*c; + f = 1.0/sqrt(fx*fx+fy*fy); fx *= f; fy *= f; + ft[2] = singlobalang*fy + cosglobalang*fx; + ft[3] = singlobalang*fx - cosglobalang*fy; + ft[0] = ((double)(globalposy-yv))*fy + ((double)(globalposx-xv))*fx; + ft[1] = ((double)(globalposx-xv))*fy - ((double)(globalposy-yv))*fx; + gux = (double)ft[3]*((double)viewingrange)/(-65536.0*262144.0); + gvx = (double)ft[2]*((double)viewingrange)/(-65536.0*262144.0); + guy = (double)ft[0]*gdy; gvy = (double)ft[1]*gdy; + guo = (double)ft[0]*gdo; gvo = (double)ft[1]*gdo; + guo += (double)(ft[2]/262144.0-gux)*ghalfx; + gvo -= (double)(ft[3]/262144.0+gvx)*ghalfx; + f = 4.0/(float)tspr->xrepeat; gux *= f; guy *= f; guo *= f; + f =-4.0/(float)tspr->yrepeat; gvx *= f; gvy *= f; gvo *= f; + if (globalorientation&4) + { + gux = ((float)tilesizx[globalpicnum])*gdx - gux; + guy = ((float)tilesizx[globalpicnum])*gdy - guy; + guo = ((float)tilesizx[globalpicnum])*gdo - guo; + } + + pow2xsplit = 0; drawpoly(px,py,npoints,method); + break; + + case 3: //Voxel sprite + break; + } +} + + //sx,sy center of sprite; screen coods*65536 + //z zoom*65536. > is zoomed in + //a angle (0 is default) + //dastat&1 1:translucence + //dastat&2 1:auto-scale mode (use 320*200 coordinates) + //dastat&4 1:y-flip + //dastat&8 1:don't clip to startumost/startdmost + //dastat&16 1:force point passed to be top-left corner, 0:Editart center + //dastat&32 1:reverse translucence + //dastat&64 1:non-masked, 0:masked + //dastat&128 1:draw all pages (permanent) + //cx1,... clip window (actual screen coords) +void polymost_dorotatesprite (long sx, long sy, long z, short a, short picnum, + signed char dashade, char dapalnum, char dastat, long cx1, long cy1, long cx2, long cy2, long uniqid) +{ + static long onumframes = 0; + long i, n, nn, x, zz, xoff, yoff, xsiz, ysiz, method; + long ogpicnum, ogshade, ogpal, ofoffset, oxdimen, oydimen, oldviewingrange; + double ogxyaspect; + double ogchang, ogshang, ogctang, ogstang, oghalfx, oghoriz, fx, fy, x1, y1, z1, x2, y2; + double ogrhalfxdown10, ogrhalfxdown10x; + double d, cosang, sinang, cosang2, sinang2, px[8], py[8], px2[8], py2[8]; + float m[4][4]; + +#ifdef USE_OPENGL + if (rendmode == 3 && usemodels && hudmem[(dastat&4)>>2][picnum].angadd) + { + if ((tile2model[picnum].modelid >= 0) && (tile2model[picnum].framenum >= 0)) + { + spritetype tspr; + memset(&tspr,0,sizeof(spritetype)); + + if (hudmem[(dastat&4)>>2][picnum].flags&1) return; //"HIDE" is specified in DEF + + ogchang = gchang; gchang = 1.0; + ogshang = gshang; gshang = 0.0; d = (double)z/(65536.0*16384.0); + ogctang = gctang; gctang = (double)sintable[(a+512)&2047]*d; + ogstang = gstang; gstang = (double)sintable[a&2047]*d; + ogshade = globalshade; globalshade = dashade; + ogpal = globalpal; globalpal = (long)((unsigned char)dapalnum); + ogxyaspect = gxyaspect; gxyaspect = 1.0; + oldviewingrange = viewingrange; viewingrange = 65536; + + x1 = hudmem[(dastat&4)>>2][picnum].xadd; + y1 = hudmem[(dastat&4)>>2][picnum].yadd; + z1 = hudmem[(dastat&4)>>2][picnum].zadd; + if (!(hudmem[(dastat&4)>>2][picnum].flags&2)) //"NOBOB" is specified in DEF + { + fx = ((double)sx)*(1.0/65536.0); + fy = ((double)sy)*(1.0/65536.0); + + if (dastat&16) + { + xsiz = tilesizx[picnum]; ysiz = tilesizy[picnum]; + xoff = (long)((signed char)((picanm[picnum]>>8)&255))+(xsiz>>1); + yoff = (long)((signed char)((picanm[picnum]>>16)&255))+(ysiz>>1); + + d = (double)z/(65536.0*16384.0); + cosang2 = cosang = (double)sintable[(a+512)&2047]*d; + sinang2 = sinang = (double)sintable[a&2047]*d; + if ((dastat&2) || (!(dastat&8))) //Don't aspect unscaled perms + { d = (double)xyaspect/65536.0; cosang2 *= d; sinang2 *= d; } + fx += -(double)xoff*cosang2+ (double)yoff*sinang2; + fy += -(double)xoff*sinang - (double)yoff*cosang; + } + + if (!(dastat&2)) + { + x1 += fx/((double)(xdim<<15))-1.0; //-1: left of screen, +1: right of screen + y1 += fy/((double)(ydim<<15))-1.0; //-1: top of screen, +1: bottom of screen + } + else + { + x1 += fx/160.0-1.0; //-1: left of screen, +1: right of screen + y1 += fy/100.0-1.0; //-1: top of screen, +1: bottom of screen + } + } + tspr.ang = hudmem[(dastat&4)>>2][picnum].angadd+globalang; + tspr.xrepeat = tspr.yrepeat = 32; + + if (dastat&4) { x1 = -x1; y1 = -y1; } + tspr.x = (long)(((double)gcosang*z1 - (double)gsinang*x1)*16384.0 + globalposx); + tspr.y = (long)(((double)gsinang*z1 + (double)gcosang*x1)*16384.0 + globalposy); + tspr.z = (long)(globalposz + y1*16384.0*0.8); + tspr.picnum = picnum; + tspr.shade = dashade; + tspr.pal = dapalnum; + tspr.owner = uniqid+MAXSPRITES; + globalorientation = (dastat&1)+((dastat&32)<<4)+((dastat&4)<<1); + + if ((dastat&10) == 2) bglViewport(windowx1,yres-(windowy2+1),windowx2-windowx1+1,windowy2-windowy1+1); + else { bglViewport(0,0,xdim,ydim); glox1 = -1; } //Force fullscreen (glox1=-1 forces it to restore) + + bglMatrixMode(GL_PROJECTION); + memset(m,0,sizeof(m)); + if ((dastat&10) == 2) + { + m[0][0] = (float)ydimen; m[0][2] = 1.0; + m[1][1] = (float)xdimen; m[1][2] = 1.0; + m[2][2] = 1.0; m[2][3] = (float)ydimen; + m[3][2] =-1.0; + } + else { m[0][0] = m[2][3] = 1.0; m[1][1] = ((float)xdim)/((float)ydim); m[2][2] = 1.0001; m[3][2] = 1-m[2][2]; } + bglLoadMatrixf(&m[0][0]); + bglMatrixMode(GL_MODELVIEW); + bglLoadIdentity(); + + if (hudmem[(dastat&4)>>2][picnum].flags&8) //NODEPTH flag + bglDisable(GL_DEPTH_TEST); + else + { + bglEnable(GL_DEPTH_TEST); + if (onumframes != numframes) + { + onumframes = numframes; + bglClear(GL_DEPTH_BUFFER_BIT); + } + } + + mddraw(&tspr); + + viewingrange = oldviewingrange; + gxyaspect = ogxyaspect; + globalshade = ogshade; + globalpal = ogpal; + gchang = ogchang; + gshang = ogshang; + gctang = ogctang; + gstang = ogstang; + return; + } + } +#endif + + ogpicnum = globalpicnum; globalpicnum = picnum; + ogshade = globalshade; globalshade = dashade; + ogpal = globalpal; globalpal = (long)((unsigned char)dapalnum); + oghalfx = ghalfx; ghalfx = (double)(xdim>>1); + ogrhalfxdown10 = grhalfxdown10; grhalfxdown10 = 1.0/(((double)ghalfx)*1024); + ogrhalfxdown10x = grhalfxdown10x; grhalfxdown10x = grhalfxdown10; + oghoriz = ghoriz; ghoriz = (double)(ydim>>1); + ofoffset = frameoffset; frameoffset = frameplace; + oxdimen = xdimen; xdimen = xdim; + oydimen = ydimen; ydimen = ydim; + ogchang = gchang; gchang = 1.0; + ogshang = gshang; gshang = 0.0; + ogctang = gctang; gctang = 1.0; + ogstang = gstang; gstang = 0.0; + +#ifdef USE_OPENGL + if (rendmode == 3) + { + bglViewport(0,0,xdim,ydim); glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore) + bglMatrixMode(GL_PROJECTION); + memset(m,0,sizeof(m)); + m[0][0] = m[2][3] = 1.0; m[1][1] = ((float)xdim)/((float)ydim); m[2][2] = 1.0001; m[3][2] = 1-m[2][2]; + bglPushMatrix(); bglLoadMatrixf(&m[0][0]); + bglMatrixMode(GL_MODELVIEW); + bglLoadIdentity(); + + bglDisable(GL_DEPTH_TEST); + bglDisable(GL_ALPHA_TEST); + bglEnable(GL_TEXTURE_2D); + } +#endif + + method = 0; + if (!(dastat&64)) + { + method = 1; + if (dastat&1) { if (!(dastat&32)) method = 2; else method = 3; } + } + method |= 4; //Use OpenGL clamping - dorotatesprite never repeats + + xsiz = tilesizx[globalpicnum]; ysiz = tilesizy[globalpicnum]; + if (dastat&16) { xoff = 0; yoff = 0; } + else + { + xoff = (long)((signed char)((picanm[globalpicnum]>>8)&255))+(xsiz>>1); + yoff = (long)((signed char)((picanm[globalpicnum]>>16)&255))+(ysiz>>1); + } + if (dastat&4) yoff = ysiz-yoff; + + if (dastat&2) //Auto window size scaling + { + if (!(dastat&8)) + { + x = xdimenscale; //= scale(xdimen,yxaspect,320); + sx = ((cx1+cx2+2)<<15)+scale(sx-(320<<15),oxdimen,320); + sy = ((cy1+cy2+2)<<15)+mulscale16(sy-(200<<15),x); + } + else + { + //If not clipping to startmosts, & auto-scaling on, as a + //hard-coded bonus, scale to full screen instead + x = scale(xdim,yxaspect,320); + sx = (xdim<<15)+32768+scale(sx-(320<<15),xdim,320); + sy = (ydim<<15)+32768+mulscale16(sy-(200<<15),x); + } + z = mulscale16(z,x); + } + + d = (double)z/(65536.0*16384.0); + cosang2 = cosang = (double)sintable[(a+512)&2047]*d; + sinang2 = sinang = (double)sintable[a&2047]*d; + if ((dastat&2) || (!(dastat&8))) //Don't aspect unscaled perms + { d = (double)xyaspect/65536.0; cosang2 *= d; sinang2 *= d; } + px[0] = (double)sx/65536.0 - (double)xoff*cosang2+ (double)yoff*sinang2; + py[0] = (double)sy/65536.0 - (double)xoff*sinang - (double)yoff*cosang; + px[1] = px[0] + (double)xsiz*cosang2; + py[1] = py[0] + (double)xsiz*sinang; + px[3] = px[0] - (double)ysiz*sinang2; + py[3] = py[0] + (double)ysiz*cosang; + px[2] = px[1]+px[3]-px[0]; + py[2] = py[1]+py[3]-py[0]; + n = 4; + + gdx = 0; gdy = 0; gdo = 1.0; + //px[0]*gux + py[0]*guy + guo = 0 + //px[1]*gux + py[1]*guy + guo = xsiz-.0001 + //px[3]*gux + py[3]*guy + guo = 0 + d = 1.0/(px[0]*(py[1]-py[3]) + px[1]*(py[3]-py[0]) + px[3]*(py[0]-py[1])); + gux = (py[3]-py[0])*((double)xsiz-.0001)*d; + guy = (px[0]-px[3])*((double)xsiz-.0001)*d; + guo = 0 - px[0]*gux - py[0]*guy; + + if (!(dastat&4)) + { //px[0]*gvx + py[0]*gvy + gvo = 0 + //px[1]*gvx + py[1]*gvy + gvo = 0 + //px[3]*gvx + py[3]*gvy + gvo = ysiz-.0001 + gvx = (py[0]-py[1])*((double)ysiz-.0001)*d; + gvy = (px[1]-px[0])*((double)ysiz-.0001)*d; + gvo = 0 - px[0]*gvx - py[0]*gvy; + } + else + { //px[0]*gvx + py[0]*gvy + gvo = ysiz-.0001 + //px[1]*gvx + py[1]*gvy + gvo = ysiz-.0001 + //px[3]*gvx + py[3]*gvy + gvo = 0 + gvx = (py[1]-py[0])*((double)ysiz-.0001)*d; + gvy = (px[0]-px[1])*((double)ysiz-.0001)*d; + gvo = (double)ysiz-.0001 - px[0]*gvx - py[0]*gvy; + } + + cx2++; cy2++; + //Clippoly4 (converted from long to double) + nn = z = 0; + do + { + zz = z+1; if (zz == n) zz = 0; + x1 = px[z]; x2 = px[zz]-x1; if ((cx1 <= x1) && (x1 <= cx2)) { px2[nn] = x1; py2[nn] = py[z]; nn++; } + if (x2 <= 0) fx = cx2; else fx = cx1; d = fx-x1; + if ((d < x2) != (d < 0)) { px2[nn] = fx; py2[nn] = (py[zz]-py[z])*d/x2 + py[z]; nn++; } + if (x2 <= 0) fx = cx1; else fx = cx2; d = fx-x1; + if ((d < x2) != (d < 0)) { px2[nn] = fx; py2[nn] = (py[zz]-py[z])*d/x2 + py[z]; nn++; } + z = zz; + } while (z); + if (nn >= 3) + { + n = z = 0; + do + { + zz = z+1; if (zz == nn) zz = 0; + y1 = py2[z]; y2 = py2[zz]-y1; if ((cy1 <= y1) && (y1 <= cy2)) { py[n] = y1; px[n] = px2[z]; n++; } + if (y2 <= 0) fy = cy2; else fy = cy1; d = fy-y1; + if ((d < y2) != (d < 0)) { py[n] = fy; px[n] = (px2[zz]-px2[z])*d/y2 + px2[z]; n++; } + if (y2 <= 0) fy = cy1; else fy = cy2; d = fy-y1; + if ((d < y2) != (d < 0)) { py[n] = fy; px[n] = (px2[zz]-px2[z])*d/y2 + px2[z]; n++; } + z = zz; + } while (z); + pow2xsplit = 0; drawpoly(px,py,n,method); + } + +#ifdef USE_OPENGL + if (rendmode == 3) { + bglMatrixMode(GL_PROJECTION); bglPopMatrix(); + } +#endif + + globalpicnum = ogpicnum; + globalshade = ogshade; + globalpal = ogpal; + ghalfx = oghalfx; + grhalfxdown10 = ogrhalfxdown10; + grhalfxdown10x = ogrhalfxdown10x; + ghoriz = oghoriz; + frameoffset = ofoffset; + xdimen = oxdimen; + ydimen = oydimen; + gchang = ogchang; + gshang = ogshang; + gctang = ogctang; + gstang = ogstang; +} + +#ifdef USE_OPENGL +static float trapextx[2]; +static void drawtrap (float x0, float x1, float y0, float x2, float x3, float y1) +{ + float px[4], py[4]; + long i, n; + + if (y0 == y1) return; + px[0] = x0; py[0] = y0; py[2] = y1; + if (x0 == x1) { px[1] = x3; py[1] = y1; px[2] = x2; n = 3; } + else if (x2 == x3) { px[1] = x1; py[1] = y0; px[2] = x3; n = 3; } + else { px[1] = x1; py[1] = y0; px[2] = x3; px[3] = x2; py[3] = y1; n = 4; } + + bglBegin(GL_TRIANGLE_FAN); + for(i=0;i allocpoints) //16 for safety + { + allocpoints = numpoints+16; + rst = (raster*)realloc(rst,allocpoints*sizeof(raster)); + slist = (long*)realloc(slist,allocpoints*sizeof(long)); + npoint2 = (long*)realloc(npoint2,allocpoints*sizeof(long)); + } + + //Remove unnecessary collinear points: + for(i=0;i m1) { z |= 2; continue; } + npoint2[i] = k; npoint2[j] = -1; npoints--; i--; //collinear + } + if (!z) return; + trapextx[0] = trapextx[1] = px[0]; + for(i=j=0;i trapextx[1]) trapextx[1] = px[i]; + slist[j++] = i; + } + if (z != 3) //Simple polygon... early out + { + bglBegin(GL_TRIANGLE_FAN); + for(i=0;i>1);gap;gap>>=1) + for(i=0;i=0;j-=gap) + { + if (py[npoint2[slist[j]]] <= py[npoint2[slist[j+gap]]]) break; + k = slist[j]; slist[j] = slist[j+gap]; slist[j+gap] = k; + } + + numrst = 0; + for(z=0;z0;i--) + { + if (rst[i-1].xi*(py[i1]-rst[i-1].y) + rst[i-1].x < px[i1]) break; + rst[i+1] = rst[i-1]; + } + numrst += 2; + + if (i&1) //split inside area + { + j = i-1; + + x0 = (py[i1] - rst[j ].y)*rst[j ].xi + rst[j ].x; + x1 = (py[i1] - rst[j+1].y)*rst[j+1].xi + rst[j+1].x; + drawtrap(rst[j].x,rst[j+1].x,rst[j].y,x0,x1,py[i1]); + rst[j ].x = x0; rst[j ].y = py[i1]; + rst[j+3].x = x1; rst[j+3].y = py[i1]; + } + + m0 = (px[i0]-px[i1]) / (py[i0]-py[i1]); + m1 = (px[i3]-px[i2]) / (py[i3]-py[i2]); + j = ((px[i1] > px[i2]) || ((i1 == i2) && (m0 >= m1))) + i; + k = (i<<1)+1 - j; + rst[j].i = i0; rst[j].xi = m0; rst[j].x = px[i1]; rst[j].y = py[i1]; + rst[k].i = i3; rst[k].xi = m1; rst[k].x = px[i2]; rst[k].y = py[i2]; + } + else + { //NOTE:don't count backwards! + if (i1 == i2) { for(i=0;i py[i0]) && (py[i2] > py[i3])) //Delete raster + { + for(;j<=i+1;j+=2) + { + x0 = (py[i1] - rst[j ].y)*rst[j ].xi + rst[j ].x; + if ((i == j) && (i1 == i2)) x1 = x0; else x1 = (py[i1] - rst[j+1].y)*rst[j+1].xi + rst[j+1].x; + drawtrap(rst[j].x,rst[j+1].x,rst[j].y,x0,x1,py[i1]); + rst[j ].x = x0; rst[j ].y = py[i1]; + rst[j+1].x = x1; rst[j+1].y = py[i1]; + } + numrst -= 2; for(;i=0;i--) + { + ((float *)rx1)[i] = ((float)rx1[i])/4096.0; + ((float *)ry1)[i] = ((float)ry1[i])/4096.0; + } + + if (gloy1 != -1) setpolymost2dview(); //disables blending, texturing, and depth testing + bglEnable(GL_ALPHA_TEST); + bglEnable(GL_TEXTURE_2D); + pth = gltexcache(globalpicnum,globalpal,0); + bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); + + f = ((float)(numpalookups-min(max(globalshade,0),numpalookups)))/((float)numpalookups); + switch ((globalorientation>>7)&3) { + case 0: + case 1: a = 1.0; bglDisable(GL_BLEND); break; + case 2: a = 0.66; bglEnable(GL_BLEND); break; + case 3: a = 0.33; bglEnable(GL_BLEND); break; + } + bglColor4f(f,f,f,a); + + tessectrap((float *)rx1,(float *)ry1,xb1,npoints); +} +#endif + +long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen) +{ +#ifdef USE_OPENGL + float xdime, ydime, xdimepad, ydimepad, scx, scy; + long i; + pthtyp *pth; + + if ((rendmode != 3) || (qsetmode != 200)) return(-1); + + if (!glinfo.texnpot) { + i = (1<<(picsiz[wallnum]&15)); if (i < tilesizx[wallnum]) i += i; xdimepad = (float)i; + i = (1<<(picsiz[wallnum]>>4)); if (i < tilesizy[wallnum]) i += i; ydimepad = (float)i; + } else { + xdimepad = (float)tilesizx[wallnum]; + ydimepad = (float)tilesizy[wallnum]; + } + xdime = (float)tilesizx[wallnum]; xdimepad = xdime/xdimepad; + ydime = (float)tilesizy[wallnum]; ydimepad = ydime/ydimepad; + + if ((xdime <= dimen) && (ydime <= dimen)) + { + scx = xdime; + scy = ydime; + } + else + { + scx = (float)dimen; + scy = (float)dimen; + if (xdime < ydime) scx *= xdime/ydime; else scy *= ydime/xdime; + } + + pth = gltexcache(wallnum,0,4); + bglBindTexture(GL_TEXTURE_2D,pth ? pth->glpic : 0); + + bglDisable(GL_ALPHA_TEST); + + if (!pth || (pth->flags & 8)) { + bglDisable(GL_TEXTURE_2D); + bglBegin(GL_TRIANGLE_FAN); + if (gammabrightness) + bglColor4f((float)curpalette[255].r/255.0, + (float)curpalette[255].g/255.0, + (float)curpalette[255].b/255.0, + 1); + else + bglColor4f((float)britable[curbrightness][ curpalette[255].r ] / 255.0, + (float)britable[curbrightness][ curpalette[255].g ] / 255.0, + (float)britable[curbrightness][ curpalette[255].b ] / 255.0, + 1); + bglVertex2f((float)tilex ,(float)tiley ); + bglVertex2f((float)tilex+scx,(float)tiley ); + bglVertex2f((float)tilex+scx,(float)tiley+scy); + bglVertex2f((float)tilex ,(float)tiley+scy); + bglEnd(); + } + + bglColor4f(1,1,1,1); + bglEnable(GL_TEXTURE_2D); + bglEnable(GL_BLEND); + bglBegin(GL_TRIANGLE_FAN); + bglTexCoord2f( 0, 0); bglVertex2f((float)tilex ,(float)tiley ); + bglTexCoord2f(xdimepad, 0); bglVertex2f((float)tilex+scx,(float)tiley ); + bglTexCoord2f(xdimepad,ydimepad); bglVertex2f((float)tilex+scx,(float)tiley+scy); + bglTexCoord2f( 0,ydimepad); bglVertex2f((float)tilex ,(float)tiley+scy); + bglEnd(); + + return(0); +#else + return -1; +#endif +} + +long polymost_printext256(long xpos, long ypos, short col, short backcol, char *name, char fontsize) +{ +#ifndef USE_OPENGL + return -1; +#else + GLfloat tx, ty, txc, tyc; + int c; + palette_t p,b; + + if (gammabrightness) { + p = curpalette[col]; + b = curpalette[backcol]; + } else { + p.r = britable[curbrightness][ curpalette[col].r ]; + p.g = britable[curbrightness][ curpalette[col].g ]; + p.b = britable[curbrightness][ curpalette[col].b ]; + b.r = britable[curbrightness][ curpalette[backcol].r ]; + b.g = britable[curbrightness][ curpalette[backcol].g ]; + b.b = britable[curbrightness][ curpalette[backcol].b ]; + } + + if ((rendmode != 3) || (qsetmode != 200)) return(-1); + + if (!polymosttext) { + // construct a 256x128 8-bit alpha-only texture for the font glyph matrix + unsigned char *tbuf, *cptr, *tptr; + int h,i,j,l; + + bglGenTextures(1,&polymosttext); + if (!polymosttext) return -1; + + tbuf = (unsigned char *)Bmalloc(256*128); + if (!tbuf) { + bglDeleteTextures(1,&polymosttext); + polymosttext = 0; + return -1; + } + Bmemset(tbuf, 0, 256*128); + + cptr = (unsigned char*)textfont; + for (h=0;h<256;h++) { + tptr = tbuf + (h%32)*8 + (h/32)*256*8; + for (i=0;i<8;i++) { + for (j=0;j<8;j++) { + if (cptr[h*8+i] & pow2char[7-j]) tptr[j] = 255; + } + tptr += 256; + } + } + + cptr = (unsigned char*)smalltextfont; + for (h=0;h<256;h++) { + tptr = tbuf + 256*64 + (h%32)*8 + (h/32)*256*8; + for (i=1;i<7;i++) { + for (j=2;j<6;j++) { + if (cptr[h*8+i] & pow2char[7-j]) tptr[j-2] = 255; + } + tptr += 256; + } + } + + bglBindTexture(GL_TEXTURE_2D, polymosttext); + bglTexImage2D(GL_TEXTURE_2D,0,GL_ALPHA,256,128,0,GL_ALPHA,GL_UNSIGNED_BYTE,(GLvoid*)tbuf); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + free(tbuf); + } + else bglBindTexture(GL_TEXTURE_2D, polymosttext); + + setpolymost2dview(); // disables blending, texturing, and depth testing + bglDisable(GL_ALPHA_TEST); + bglDepthMask(GL_FALSE); // disable writing to the z-buffer + + if (backcol >= 0) { + bglColor4ub(b.r,b.g,b.b,255); + c = Bstrlen(name); + + bglBegin(GL_QUADS); + bglVertex2i(xpos,ypos); + bglVertex2i(xpos,ypos+(fontsize?6:8)); + bglVertex2i(xpos+(c<<(3-fontsize)),ypos+(fontsize?6:8)); + bglVertex2i(xpos+(c<<(3-fontsize)),ypos); + bglEnd(); + } + + bglEnable(GL_TEXTURE_2D); + bglEnable(GL_BLEND); + bglColor4ub(p.r,p.g,p.b,255); + txc = fontsize ? (4.0/256.0) : (8.0/256.0); + tyc = fontsize ? (6.0/128.0) : (8.0/128.0); + bglBegin(GL_QUADS); + for (c=0; name[c]; c++) { + tx = (float)(name[c]%32)/32.0; + ty = (float)((name[c]/32) + (fontsize*8))/16.0; + + bglTexCoord2f(tx,ty); bglVertex2i(xpos,ypos); + bglTexCoord2f(tx+txc,ty); bglVertex2i(xpos+(8>>fontsize),ypos); + bglTexCoord2f(tx+txc,ty+tyc); bglVertex2i(xpos+(8>>fontsize),ypos+(fontsize?6:8)); + bglTexCoord2f(tx,ty+tyc); bglVertex2i(xpos,ypos+(fontsize?6:8)); + + xpos += (8>>fontsize); + } + bglEnd(); + + bglDepthMask(GL_TRUE); // re-enable writing to the z-buffer + + return 0; +#endif +} + +// Console commands by JBF +#ifdef USE_OPENGL +static int gltexturemode(const osdfuncparm_t *parm) +{ + int m; + const char *p; + + if (parm->numparms != 1) { + OSD_Printf("Current texturing mode is %s\n", glfiltermodes[gltexfiltermode].name); + OSD_Printf(" Vaild modes are:\n"); + for (m = 0; m < (int)numglfiltermodes; m++) + OSD_Printf(" %d - %s\n",m,glfiltermodes[m].name); + + return OSDCMD_OK; + } + + m = Bstrtoul(parm->parms[0], (char **)&p, 10); + if (p == parm->parms[0]) { + // string + for (m = 0; m < (int)numglfiltermodes; m++) { + if (!Bstrcasecmp(parm->parms[0], glfiltermodes[m].name)) break; + } + if (m == numglfiltermodes) m = gltexfiltermode; // no change + } else { + if (m < 0) m = 0; + else if (m >= (int)numglfiltermodes) m = numglfiltermodes - 1; + } + + if (m != gltexfiltermode) { + gltexfiltermode = m; + gltexapplyprops(); + } + + OSD_Printf("Texture filtering mode changed to %s\n", glfiltermodes[gltexfiltermode].name ); + + return OSDCMD_OK; +} + +static int gltextureanisotropy(const osdfuncparm_t *parm) +{ + long l; + const char *p; + + if (parm->numparms != 1) { + OSD_Printf("Current texture anisotropy is %d\n", glanisotropy); + OSD_Printf(" Maximum is %d\n", (long)glinfo.maxanisotropy); + + return OSDCMD_OK; + } + + l = Bstrtoul(parm->parms[0], (char **)&p, 10); + if (l < 0 || l > (long)glinfo.maxanisotropy) l = 0; + + if (l != gltexfiltermode) { + glanisotropy = l; + gltexapplyprops(); + } + + OSD_Printf("Texture anisotropy changed to %d\n", glanisotropy ); + + return OSDCMD_OK; +} +#endif + +static int osdcmd_polymostvars(const osdfuncparm_t *parm) +{ + int showval = (parm->numparms < 1), val; + + if (!showval) val = atoi(parm->parms[0]); + if (!Bstrcasecmp(parm->name, "usemodels")) { + if (showval) { OSD_Printf("usemodels is %d\n", usemodels); } + else usemodels = (val != 0); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "usehightile")) { + if (showval) { OSD_Printf("usehightile is %d\n", usehightile); } + else usehightile = (val != 0); + return OSDCMD_OK; + } +#ifdef USE_OPENGL + else if (!Bstrcasecmp(parm->name, "glusetexcompr")) { + if (showval) { OSD_Printf("glusetexcompr is %d\n", glusetexcompr); } + else glusetexcompr = (val != 0); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "glredbluemode")) { + if (showval) { OSD_Printf("glredbluemode is %d\n", glredbluemode); } + else glredbluemode = (val != 0); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "gltexturemaxsize")) { + if (showval) { OSD_Printf("gltexturemaxsize is %d\n", gltexmaxsize); } + else gltexmaxsize = val; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "gltexturemiplevel")) { + if (showval) { OSD_Printf("gltexturemiplevel is %d\n", gltexmiplevel); } + else gltexmiplevel = val; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "usegoodalpha")) { + OSD_Printf("usegoodalpha is obsolete\n"); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "glpolygonmode")) { + if (showval) { OSD_Printf("glpolygonmode is %d\n", glpolygonmode); } + else glpolygonmode = val; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "glusetexcache")) { + if (showval) { OSD_Printf("glusetexcache is %d\n", glusetexcache); } + else glusetexcache = (val != 0); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "glusetexcachecompression")) { + if (showval) { OSD_Printf("glusetexcachecompression is %d\n", glusetexcachecompression); } + else glusetexcachecompression = (val != 0); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "glmultisample")) { + if (showval) { OSD_Printf("glmultisample is %d\n", glmultisample); } + else glmultisample = max(0,val); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "glnvmultisamplehint")) { + if (showval) { OSD_Printf("glnvmultisamplehint is %d\n", glnvmultisamplehint); } + else glnvmultisamplehint = (val != 0); + return OSDCMD_OK; + } +#endif + return OSDCMD_SHOWHELP; +} + +#if 0 +// because I'm lazy +static int dumptexturedefs(const osdfuncparm_t *parm) +{ + hicreplctyp *hr; + int i; + + if (!hicfirstinit) return OSDCMD_OK; + + initprintf("// Begin Texture Dump\n"); + for (i=0;inext) { + if (!hr->filename) continue; + initprintf(" pal %d { name \"%s\" ", hr->palnum, hr->filename); + if (hr->alphacut >= 0.0) initprintf("alphacut %g ", hr->alphacut); + initprintf("}\n"); + } + initprintf("}\n"); + } + initprintf("// End Texture Dump\n"); + + return OSDCMD_OK; // no replacement found +} +#endif + +void polymost_initosdfuncs(void) +{ +#ifdef USE_OPENGL + OSD_RegisterFunction("glusetexcompr","glusetexcompr: enable/disable OpenGL texture compression",osdcmd_polymostvars); + OSD_RegisterFunction("glredbluemode","glredbluemode: enable/disable experimental OpenGL red-blue glasses mode",osdcmd_polymostvars); + OSD_RegisterFunction("gltexturemode", "gltexturemode: changes the texture filtering settings", gltexturemode); + OSD_RegisterFunction("gltextureanisotropy", "gltextureanisotropy: changes the OpenGL texture anisotropy setting", gltextureanisotropy); + OSD_RegisterFunction("gltexturemaxsize","gltexturemaxsize: changes the maximum OpenGL texture size limit",osdcmd_polymostvars); + OSD_RegisterFunction("gltexturemiplevel","gltexturemiplevel: changes the highest OpenGL mipmap level used",osdcmd_polymostvars); + OSD_RegisterFunction("usegoodalpha","usegoodalpha: [OBSOLETE] enable/disable better looking OpenGL alpha hack",osdcmd_polymostvars); + OSD_RegisterFunction("glpolygonmode","glpolygonmode: debugging feature",osdcmd_polymostvars); //FUK + OSD_RegisterFunction("glusetexcache","glusetexcache: enable/disable OpenGL compressed texture cache",osdcmd_polymostvars); + OSD_RegisterFunction("glusetexcachecompression","usetexcachecompression: enable/disable compression of files in the OpenGL compressed texture cache",osdcmd_polymostvars); + OSD_RegisterFunction("glmultisample","glmultisample: sets the number of samples used for antialiasing (0 = off)",osdcmd_polymostvars); + OSD_RegisterFunction("glnvmultisamplehint","glnvmultisamplehint: enable/disable Nvidia multisampling hinting",osdcmd_polymostvars); +#endif + OSD_RegisterFunction("usemodels","usemodels: enable/disable model rendering in >8-bit mode",osdcmd_polymostvars); + OSD_RegisterFunction("usehightile","usehightile: enable/disable hightile texture rendering in >8-bit mode",osdcmd_polymostvars); + //OSD_RegisterFunction("dumptexturedefs","dumptexturedefs: dumps all texture definitions in the new style",dumptexturedefs); +} + +void polymost_precache(long dapicnum, long dapalnum, long datype) +{ +#ifdef USE_OPENGL + // dapicnum and dapalnum are like you'd expect + // datype is 0 for a wall/floor/ceiling and 1 for a sprite + // basically this just means walls are repeating + // while sprites are clamped + int mid; + + if (rendmode < 3) return; + + if (!palookup[dapalnum]) return;//dapalnum = 0; + + //OSD_Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype); + hicprecaching = 1; + gltexcache(dapicnum, dapalnum, (datype & 1) << 2); + hicprecaching = 0; + + if (datype == 0) return; + + mid = md_tilehasmodel(dapicnum); + if (mid < 0 || models[mid]->mdnum < 2) return; + + { + int i,j=0; + + if (models[mid]->mdnum == 3) + j = ((md3model *)models[mid])->head.numsurfs; + + for (i=0;i<=j;i++) + mdloadskin((md2model*)models[mid], 0, dapalnum, i); + } +#endif +} + +static unsigned short hicosub (unsigned short c) +{ + long r, g, b; + g = ((c>> 5)&63); + r = ((c>>11)-(g>>1))&31; + b = ((c>> 0)-(g>>1))&31; + return((r<<11)+(g<<5)+b); +} + +static unsigned short hicoadd (unsigned short c) +{ + long r, g, b; + g = ((c>> 5)&63); + r = ((c>>11)+(g>>1))&31; + b = ((c>> 0)+(g>>1))&31; + return((r<<11)+(g<<5)+b); +} + +/* +Description of Ken's filter to improve LZW compression of DXT1 format by ~15%: (as tested with the HRP) + + To increase LZW patterns, I store each field of the DXT block structure separately. + Here are the 3 DXT fields: + 1. __int64 alpha_4x4; //DXT3 only (16 byte structure size when included) + 2. short rgb0, rgb1; + 3. long index_4x4; + + Each field is then stored with its own specialized algorithm. + 1. I haven't done much testing with this field - I just copy it raw without any transform for now. + + 2. For rgb0 and rgb1, I use a "green" filter like this: + g = g; + r = r-g; + b = b-g; + For grayscale, this makes the stream: x,0,0,x,0,0,x,0,0,... instead of x,x,x,x,x,x,x,x,... + Q:what was the significance of choosing green? A:largest/most dominant component + Believe it or not, this gave 1% better compression :P + I tried subtracting each componenet with the previous pixel, but strangely it hurt compression. + Oh, the joy of trial & error. :) + + 3. For index_4x4, I transform the ordering of 2-bit indices in the DXT blocks from this: + 0123 0123 0123 ---- ---- ---- + 4567 4567 4567 ---- ---- ---- + 89ab 89ab 89ab ---- ---- ---- + cdef cdef cdef ---- ---- ---- + To this: (I swap x & y axes) + 048c 048c 048c |||| |||| |||| + 159d 159d 159d |||| |||| |||| + 26ae 26ae 26ae |||| |||| |||| + 37bf 37bf 37bf |||| |||| |||| + The trick is: going from the bottom of the 4th line to the top of the 5th line + is the exact same jump (geometrically) as from 5th to 6th, etc.. This is not true in the top case. + These silly tricks will increase patterns and therefore make LZW compress better. + I think this improved compression by a few % :) + */ + +int dxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, unsigned long miplen) +{ + void *writebuf; +#if (USEKENFILTER == 0) + unsigned long cleng,j; + if (glusetexcachecompression) { +#ifdef USELZF + cleng = lzf_compress(pic, miplen, packbuf, miplen-1); + if (cleng == 0) { + // failed to compress + cleng = miplen; + writebuf = pic; + } else writebuf = packbuf; +#else + cleng = lzwcompress(pic,miplen,packbuf); + writebuf = packbuf; +#endif + } else { + cleng = miplen; + writebuf = pic; + } + if (cleng < 0) return -1; j = B_LITTLE32(cleng); + if (Bwrite(fil, &j, sizeof(unsigned long)) != sizeof(unsigned long)) return -1; + if (Bwrite(fil, writebuf, cleng) != cleng) return -1; +#else + long j, k, offs, stride, cleng; + char *cptr; + + if ((pict->format == B_LITTLE32(GL_COMPRESSED_RGB_S3TC_DXT1_EXT)) || + (pict->format == B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT))) { offs = 0; stride = 8; } + else if ((pict->format == B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)) || + (pict->format == B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT))) { offs = 8; stride = 16; } + else { offs = 0; stride = 8; } + + if (stride == 16) //If DXT3... + { + //alpha_4x4 + cptr = midbuf; + for(k=0;k<8;k++) *cptr++ = pic[k]; + for(j=stride;j>0)&3) + (((c2[1]>>0)&3)<<2) + (((c2[2]>>0)&3)<<4) + (((c2[3]>>0)&3)<<6); + cptr[1] = ((c2[0]>>2)&3) + (((c2[1]>>2)&3)<<2) + (((c2[2]>>2)&3)<<4) + (((c2[3]>>2)&3)<<6); + cptr[2] = ((c2[0]>>4)&3) + (((c2[1]>>4)&3)<<2) + (((c2[2]>>4)&3)<<4) + (((c2[3]>>4)&3)<<6); + cptr[3] = ((c2[0]>>6)&3) + (((c2[1]>>6)&3)<<2) + (((c2[2]>>6)&3)<<4) + (((c2[3]>>6)&3)<<6); + cptr += 4; + } + if (glusetexcachecompression) { +#ifdef USELZF + j = (miplen/stride)*4; + cleng = lzf_compress(midbuf,j,packbuf,j-1); + if (cleng == 0) { + cleng = j; + writebuf = midbuf; + } else writebuf = packbuf; +#else + cleng = lzwcompress(midbuf,(miplen/stride)*4,packbuf); + writebuf = packbuf; +#endif + } else { + cleng = (miplen/stride)*4; + writebuf = midbuf; + } + j = B_LITTLE32(cleng); + Bwrite(fil,&j,4); + Bwrite(fil,writebuf,cleng); +#endif + return 0; +} + +int dedxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, int ispacked) +{ + void *inbuf; +#if (USEKENFILTER == 0) + unsigned long cleng; + if (kread(fil, &cleng, sizeof(unsigned long)) != sizeof(unsigned long)) return -1; cleng = B_LITTLE32(cleng); +#ifdef USELZF + if (ispacked && cleng < pict->size) inbuf = packbuf; else inbuf = pic; + if (kread(fil, inbuf, cleng) != cleng) return -1; + if (ispacked && cleng < pict->size) + if (lzf_decompress(packbuf, cleng, pic, pict->size) == 0) return -1; +#else + if (ispacked) inbuf = packbuf; else inbuf = pic; + if (kread(fil, inbuf, cleng) != cleng) return -1; + if (ispacked && lzwuncompress(packbuf, cleng, pic, pict->size) != pict->size) return -1; +#endif +#else + long j, k, offs, stride, cleng; + char *cptr; + + if (ispacked) inbuf = packbuf; else inbuf = midbuf; + + if ((pict->format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) || + (pict->format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)) { offs = 0; stride = 8; } + else if ((pict->format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) || + (pict->format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)) { offs = 8; stride = 16; } + else { offs = 0; stride = 8; } + + if (stride == 16) //If DXT3... + { + //alpha_4x4 + if (kread(fil,&cleng,4) < 4) return -1; cleng = B_LITTLE32(cleng); + j = (pict->size/stride)*8; +#ifdef USELZF + if (ispacked && cleng < j) inbuf = packbuf; else inbuf = midbuf; + if (kread(fil,inbuf,cleng) < cleng) return -1; + if (ispacked && cleng < j) + if (lzf_decompress(packbuf,cleng,midbuf,j) == 0) return -1; +#else + if (kread(fil,inbuf,cleng) < cleng) return -1; + if (ispacked && lzwuncompress(packbuf,cleng,midbuf,j) != j) return -1; +#endif + cptr = midbuf; + for(k=0;k<8;k++) pic[k] = *cptr++; + for(j=stride;jsize;j+=stride) + for(k=0;k<8;k++) pic[j+k] = (*cptr++); + } + + //rgb0,rgb1 + if (kread(fil,&cleng,4) < 4) return -1; cleng = B_LITTLE32(cleng); + j = (pict->size/stride)*4; +#ifdef USELZF + if (ispacked && cleng < j) inbuf = packbuf; else inbuf = midbuf; + if (kread(fil,inbuf,cleng) < cleng) return -1; + if (ispacked && cleng < j) + if (lzf_decompress(packbuf,cleng,midbuf,j) == 0) return -1; +#else + if (kread(fil,inbuf,cleng) < cleng) return -1; + if (ispacked && lzwuncompress(packbuf,cleng,midbuf,j) != j) return -1; +#endif + cptr = midbuf; + for(k=0;k<=2;k+=2) + for(j=0;jsize;j+=stride) + { + *(short *)(&pic[offs+j+k]) = hicoadd(*(short *)cptr); + cptr += 2; + } + + //index_4x4: + if (kread(fil,&cleng,4) < 4) return -1; cleng = B_LITTLE32(cleng); + j = (pict->size/stride)*4; +#ifdef USELZF + if (ispacked && cleng < j) inbuf = packbuf; else inbuf = midbuf; + if (kread(fil,inbuf,cleng) < cleng) return -1; + if (ispacked && cleng < j) + if (lzf_decompress(packbuf,cleng,midbuf,j) == 0) return -1; +#else + if (kread(fil,inbuf,cleng) < cleng) return -1; + if (ispacked && lzwuncompress(packbuf,cleng,midbuf,j) != j) return -1; +#endif + cptr = midbuf; + for(j=0;jsize;j+=stride) + { + pic[j+offs+4] = ((cptr[0]>>0)&3) + (((cptr[1]>>0)&3)<<2) + (((cptr[2]>>0)&3)<<4) + (((cptr[3]>>0)&3)<<6); + pic[j+offs+5] = ((cptr[0]>>2)&3) + (((cptr[1]>>2)&3)<<2) + (((cptr[2]>>2)&3)<<4) + (((cptr[3]>>2)&3)<<6); + pic[j+offs+6] = ((cptr[0]>>4)&3) + (((cptr[1]>>4)&3)<<2) + (((cptr[2]>>4)&3)<<4) + (((cptr[3]>>4)&3)<<6); + pic[j+offs+7] = ((cptr[0]>>6)&3) + (((cptr[1]>>6)&3)<<2) + (((cptr[2]>>6)&3)<<4) + (((cptr[3]>>6)&3)<<6); + cptr += 4; + } +#endif + return 0; +} + +// vim:ts=4:sw=4: diff --git a/polymer/build/src/pragmas.c b/polymer/build/src/pragmas.c new file mode 100644 index 000000000..6b29640bb --- /dev/null +++ b/polymer/build/src/pragmas.c @@ -0,0 +1,250 @@ +// Function-wrapped Watcom pragmas +// by Jonathon Fowler (jonof@edgenetwk.com) +// +// These functions represent some of the more longer-winded pragmas +// from the original pragmas.h wrapped into functions for easier +// use since many jumps and whatnot make it harder to write macro- +// inline versions. I'll eventually convert these to macro-inline +// equivalents. --Jonathon + +//#include "pragmas.h" +#include "compat.h" + +long dmval; + +#if defined(NOASM) + +// +// Generic C version +// + +void qinterpolatedown16(long bufptr, long num, long val, long add) +{ // gee, I wonder who could have provided this... + long i, *lptr = (long *)bufptr; + for(i=0;i>16); val += add; } +} + +void qinterpolatedown16short(long bufptr, long num, long val, long add) +{ // ...maybe the same person who provided this too? + long i; short *sptr = (short *)bufptr; + for(i=0;i>16); val += add; } +} + +void clearbuf(void *d, long c, long a) +{ + long *p = (long*)d; + while ((c--) > 0) *(p++) = a; +} + +void copybuf(void *s, void *d, long c) +{ + long *p = (long*)s, *q = (long*)d; + while ((c--) > 0) *(q++) = *(p++); +} + +void swapbuf4(void *a, void *b, long c) +{ + long *p = (long*)a, *q = (long*)b; + long x, y; + while ((c--) > 0) { + x = *q; + y = *p; + *(q++) = y; + *(p++) = x; + } +} + +void clearbufbyte(void *D, long c, long a) +{ // Cringe City + char *p = (char*)D; + long m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l }; + long n[4] = { 0,8,16,24 }; + long z=0; + while ((c--) > 0) { + *(p++) = (char)((a & m[z])>>n[z]); + z=(z+1)&3; + } +} + +void copybufbyte(void *S, void *D, long c) +{ + char *p = (char*)S, *q = (char*)D; + while((c--) > 0) *(q++) = *(p++); +} + +void copybufreverse(void *S, void *D, long c) +{ + char *p = (char*)S, *q = (char*)D; + while((c--) > 0) *(q++) = *(p--); +} + +#elif defined(__GNUC__) && defined(__i386__) // NOASM + +// +// GCC Inline Assembler version +// + +#define ASM __asm__ __volatile__ + + +long boundmulscale(long a, long b, long c) +{ + ASM ( + "imull %%ebx\n\t" + "movl %%edx, %%ebx\n\t" // mov ebx, edx + "shrdl %%cl, %%edx, %%eax\n\t" // mov eax, edx, cl + "sarl %%cl, %%edx\n\t" // sar edx, cl + "xorl %%eax, %%edx\n\t" // xor edx, eax + "js 0f\n\t" // js checkit + "xorl %%eax, %%edx\n\t" // xor edx, eax + "jz 1f\n\t" // js skipboundit + "cmpl $0xffffffff, %%edx\n\t" // cmp edx, 0xffffffff + "je 1f\n\t" // je skipboundit + "0:\n\t" // checkit: + "movl %%ebx, %%eax\n\t" // mov eax, ebx + "sarl $31, %%eax\n\t" // sar eax, 31 + "xorl $0x7fffffff, %%eax\n\t" // xor eax, 0x7fffffff + "1:" // skipboundit: + : "+a" (a), "+b" (b), "+c" (c) // input eax ebx ecx + : + : "edx", "cc" + ); + return a; +} + + +void clearbufbyte(void *D, long c, long a) +{ + ASM ( + "cmpl $4, %%ecx\n\t" + "jae 1f\n\t" + "testb $1, %%cl\n\t" + "jz 0f\n\t" // jz preskip + "stosb\n\t" + "0:\n\t" // preskip: + "shrl $1, %%ecx\n\t" + "rep\n\t" + "stosw\n\t" + "jmp 5f\n\t" // jmp endit + "1:\n\t" // intcopy: + "testl $1, %%edi\n\t" + "jz 2f\n\t" // jz skip1 + "stosb\n\t" + "decl %%ecx\n\t" + "2:\n\t" // skip1: + "testl $2, %%edi\n\t" + "jz 3f\n\t" // jz skip2 + "stosw\n\t" + "subl $2, %%ecx\n\t" + "3:\n\t" // skip2: + "movl %%ecx, %%ebx\n\t" + "shrl $2, %%ecx\n\t" + "rep\n\t" + "stosl\n\t" + "testb $2, %%bl\n\t" + "jz 4f\n\t" // jz skip3 + "stosw\n\t" + "4:\n\t" // skip3: + "testb $1, %%bl\n\t" + "jz 5f\n\t" // jz endit + "stosb\n\t" + "5:" // endit + : "+D" (D), "+c" (c), "+a" (a) : + : "ebx", "memory", "cc" + ); +} + +void copybufbyte(void *S, void *D, long c) +{ + ASM ( + "cmpl $4, %%ecx\n\t" // cmp ecx, 4 + "jae 1f\n\t" + "testb $1, %%cl\n\t" // test cl, 1 + "jz 0f\n\t" + "movsb\n\t" + "0:\n\t" // preskip: + "shrl $1, %%ecx\n\t" // shr ecx, 1 + "rep\n\t" + "movsw\n\t" + "jmp 5f\n\t" + "1:\n\t" // intcopy: + "testl $1, %%edi\n\t" // test edi, 1 + "jz 2f\n\t" + "movsb\n\t" + "decl %%ecx\n\t" + "2:\n\t" // skip1: + "testl $2, %%edi\n\t" // test edi, 2 + "jz 3f\n\t" + "movsw\n\t" + "subl $2, %%ecx\n\t" // sub ecx, 2 + "3:\n\t" // skip2: + "movl %%ecx, %%ebx\n\t" // mov ebx, ecx + "shrl $2, %%ecx\n\t" // shr ecx ,2 + "rep\n\t" + "movsl\n\t" + "testb $2, %%bl\n\t" // test bl, 2 + "jz 4f\n\t" + "movsw\n\t" + "4:\n\t" // skip3: + "testb $1, %%bl\n\t" // test bl, 1 + "jz 5f\n\t" + "movsb\n\t" + "5:" // endit: + : "+c" (c), "+S" (S), "+D" (D) : + : "ebx", "memory", "cc" + ); +} + +void copybufreverse(void *S, void *D, long c) +{ + ASM ( + "shrl $1, %%ecx\n\t" + "jnc 0f\n\t" // jnc skipit1 + "movb (%%esi), %%al\n\t" + "decl %%esi\n\t" + "movb %%al, (%%edi)\n\t" + "incl %%edi\n\t" + "0:\n\t" // skipit1: + "shrl $1, %%ecx\n\t" + "jnc 1f\n\t" // jnc skipit2 + "movw -1(%%esi), %%ax\n\t" + "subl $2, %%esi\n\t" + "rorw $8, %%ax\n\t" + "movw %%ax, (%%edi)\n\t" + "addl $2, %%edi\n\t" + "1:\n\t" // skipit2 + "testl %%ecx, %%ecx\n\t" + "jz 3f\n\t" // jz endloop + "2:\n\t" // begloop + "movl -3(%%esi), %%eax\n\t" + "subl $4, %%esi\n\t" + "bswapl %%eax\n\t" + "movl %%eax, (%%edi)\n\t" + "addl $4, %%edi\n\t" + "decl %%ecx\n\t" + "jnz 2b\n\t" // jnz begloop + "3:" + : "+S" (S), "+D" (D), "+c" (c) : + : "eax", "memory", "cc" + ); +} + +#elif defined(__WATCOMC__) // __GNUC__ && __i386__ + +// +// Watcom C Inline Assembler version +// + +#elif defined(_MSC_VER) // __WATCOMC__ + +// +// Microsoft C Inline Assembler version +// + +#else // _MSC_VER + +#error Unsupported compiler or architecture. + +#endif + + diff --git a/polymer/build/src/scriptfile.c b/polymer/build/src/scriptfile.c new file mode 100644 index 000000000..514cfcb93 --- /dev/null +++ b/polymer/build/src/scriptfile.c @@ -0,0 +1,394 @@ +/* + * File Tokeniser/Parser/Whatever + * by Jonathon Fowler + * Remixed completely by Ken Silverman + * See the included license file "BUILDLIC.TXT" for license info. + */ + +#include "scriptfile.h" +#include "baselayer.h" +#include "compat.h" +#include "cache1d.h" + + +#define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n')) +static void skipoverws(scriptfile *sf) { if ((sf->textptr < sf->eof) && (!sf->textptr[0])) sf->textptr++; } +static void skipovertoken(scriptfile *sf) { while ((sf->textptr < sf->eof) && (sf->textptr[0])) sf->textptr++; } + +char *scriptfile_gettoken(scriptfile *sf) +{ + char *start; + + skipoverws(sf); + if (sf->textptr >= sf->eof) return NULL; + + start = sf->ltextptr = sf->textptr; + skipovertoken(sf); + return start; +} + +int scriptfile_getstring(scriptfile *sf, char **retst) +{ + (*retst) = scriptfile_gettoken(sf); + if (*retst == NULL) + { + initprintf("Error on line %s:%d: unexpected eof\n",sf->filename,scriptfile_getlinum(sf,sf->textptr)); + return(-2); + } + return(0); +} + +int scriptfile_getnumber(scriptfile *sf, int *num) +{ + skipoverws(sf); + if (sf->textptr >= sf->eof) + { + initprintf("Error on line %s:%d: unexpected eof\n",sf->filename,scriptfile_getlinum(sf,sf->textptr)); + return -1; + } + + while ((sf->textptr[0] == '0') && (sf->textptr[1] >= '0') && (sf->textptr[1] <= '9')) + sf->textptr++; //hack to treat octal numbers like decimal + + sf->ltextptr = sf->textptr; + (*num) = strtol((const char *)sf->textptr,&sf->textptr,0); + if (!ISWS(*sf->textptr) && *sf->textptr) { + char *p = sf->textptr; + skipovertoken(sf); + initprintf("Error on line %s:%d: expecting int, got \"%s\"\n",sf->filename,scriptfile_getlinum(sf,sf->ltextptr),p); + return -2; + } + return 0; +} + +static double parsedouble(char *ptr, char **end) +{ + int beforedecimal = 1, negative = 0, dig; + int exposgn = 0, expo = 0; + double num = 0.0, decpl = 0.1; + char *p; + + p = ptr; + if (*p == '-') negative = 1, p++; + else if (*p == '+') p++; + for (;; p++) { + if (*p >= '0' && *p <= '9') { + dig = *p - '0'; + if (beforedecimal) num = num * 10.0 + dig; + else if (exposgn) expo = expo*10 + dig; + else { + num += (double)dig * decpl; + decpl /= 10.0; + } + } else if (*p == '.') { + if (beforedecimal) beforedecimal = 0; + else break; + } else if ((*p == 'E') || (*p == 'e')) { + exposgn = 1; + if (p[1] == '-') { exposgn = -1; p++; } + else if (p[1] == '+') p++; + } else break; + } + + if (end) *end = p; + if (exposgn) num *= pow(10.0,(double)(expo*exposgn)); + return negative ? -num : num; +} + +int scriptfile_getdouble(scriptfile *sf, double *num) +{ + skipoverws(sf); + if (sf->textptr >= sf->eof) + { + initprintf("Error on line %s:%d: unexpected eof\n",sf->filename,scriptfile_getlinum(sf,sf->textptr)); + return -1; + } + + sf->ltextptr = sf->textptr; + + // On Linux, locale settings interfere with interpreting x.y format numbers + //(*num) = strtod((const char *)sf->textptr,&sf->textptr); + (*num) = parsedouble(sf->textptr, &sf->textptr); + + if (!ISWS(*sf->textptr) && *sf->textptr) { + char *p = sf->textptr; + skipovertoken(sf); + initprintf("Error on line %s:%d: expecting float, got \"%s\"\n",sf->filename,scriptfile_getlinum(sf,sf->ltextptr),p); + return -2; + } + return 0; +} + +int scriptfile_getsymbol(scriptfile *sf, int *num) +{ + char *t, *e; + int v; + + t = scriptfile_gettoken(sf); + if (!t) return -1; + + v = Bstrtol(t, &e, 10); + if (*e) { + // looks like a string, so find it in the symbol table + if (scriptfile_getsymbolvalue(t, num)) return 0; + initprintf("Error on line %s:%d: expecting symbol, got \"%s\"\n",sf->filename,scriptfile_getlinum(sf,sf->ltextptr),t); + return -2; // not found + } + + *num = v; + return 0; +} + +int scriptfile_getbraces(scriptfile *sf, char **braceend) +{ + int bracecnt; + char *bracestart; + + skipoverws(sf); + if (sf->textptr >= sf->eof) + { + initprintf("Error on line %s:%d: unexpected eof\n",sf->filename,scriptfile_getlinum(sf,sf->textptr)); + return -1; + } + + if (sf->textptr[0] != '{') { + initprintf("Error on line %s:%d: expecting '{'\n",sf->filename,scriptfile_getlinum(sf,sf->textptr)); + return -1; + } + bracestart = ++sf->textptr; bracecnt = 1; + while (1) + { + if (sf->textptr >= sf->eof) return(0); + if (sf->textptr[0] == '{') bracecnt++; + if (sf->textptr[0] == '}') { bracecnt--; if (!bracecnt) break; } + sf->textptr++; + } + (*braceend) = sf->textptr; + sf->textptr = bracestart; + return 0; +} + + +int scriptfile_getlinum (scriptfile *sf, char *ptr) +{ + int i, stp, ind; + + //for(i=0;ilinenum;i++) if (sf->lineoffs[i] >= ind) return(i+1); //brute force algo + + ind = ((long)ptr) - ((long)sf->textbuf); + + for(stp=1;stp+stplinenum;stp+=stp); //stp = highest power of 2 less than sf->linenum + for(i=0;stp;stp>>=1) + if ((i+stp < sf->linenum) && (sf->lineoffs[i+stp] < ind)) i += stp; + return(i+1); //i = index to highest lineoffs which is less than ind; convert to 1-based line numbers +} + +void scriptfile_preparse (scriptfile *sf, char *tx, long flen) +{ + long i, cr, numcr, nflen, ws, cs, inquote; + + //Count number of lines + numcr = 1; + for(i=0;ilinenum = numcr; + sf->lineoffs = (long *)malloc(sf->linenum*sizeof(long)); + + //Preprocess file for comments (// and /*...*/, and convert all whitespace to single spaces) + nflen = 0; ws = 0; cs = 0; numcr = 0; inquote = 0; + for(i=0;ilineoffs[numcr++] = nflen; + if (cs == 1) cs = 0; + ws = 1; continue; //strip CR/LF + } + + if ((!inquote) && ((tx[i] == ' ') || (tx[i] == '\t'))) { ws = 1; continue; } //strip Space/Tab + if ((tx[i] == '/') && (tx[i+1] == '/') && (!cs)) cs = 1; + if ((tx[i] == '/') && (tx[i+1] == '*') && (!cs)) { ws = 1; cs = 2; } + if ((tx[i] == '*') && (tx[i+1] == '/') && (cs == 2)) { cs = 0; i++; continue; } + if (cs) continue; + + if (ws) { tx[nflen++] = 0; ws = 0; } + + //quotes inside strings: \" + if ((tx[i] == '\\') && (tx[i+1] == '\"')) { i++; tx[nflen++] = '\"'; continue; } + if (tx[i] == '\"') { inquote ^= 1; continue; } + tx[nflen++] = tx[i]; + } + tx[nflen++] = 0; sf->lineoffs[numcr] = nflen; + tx[nflen++] = 0; + +#if 0 + //for debugging only: + printf("pre-parsed file:flen=%d,nflen=%d\n",flen,nflen); + for(i=0;ilinenum); + for(i=0;ilinenum;i++) printf("line %d = byte %d\n",i,sf->lineoffs[i]); +#endif + flen = nflen; + + sf->textbuf = sf->textptr = tx; + sf->textlength = nflen; + sf->eof = &sf->textbuf[nflen-1]; +} + +scriptfile *scriptfile_fromfile(char *fn) +{ + int fp; + scriptfile *sf; + char *tx; + unsigned int flen; + + fp = kopen4load(fn,0); + if (fp<0) return NULL; + + flen = kfilelength(fp); + tx = (char *) malloc(flen + 2); + if (!tx) { + kclose(fp); + return NULL; + } + + sf = (scriptfile*) malloc(sizeof(scriptfile)); + if (!sf) { + kclose(fp); + free(tx); + return NULL; + } + + kread(fp, tx, flen); + tx[flen] = tx[flen+1] = 0; + + kclose(fp); + + scriptfile_preparse(sf,tx,flen); + sf->filename = strdup(fn); + + return sf; +} + +scriptfile *scriptfile_fromstring(char *string) +{ + scriptfile *sf; + char *tx; + unsigned int flen; + + if (!string) return NULL; + + flen = strlen(string); + + tx = (char *) malloc(flen + 2); + if (!tx) return NULL; + + sf = (scriptfile*) malloc(sizeof(scriptfile)); + if (!sf) { + free(tx); + return NULL; + } + + memcpy(tx, string, flen); + tx[flen] = tx[flen+1] = 0; + + scriptfile_preparse(sf,tx,flen); + sf->filename = NULL; + + return sf; +} + +void scriptfile_close(scriptfile *sf) +{ + if (!sf) return; + if (sf->lineoffs) free(sf->lineoffs); + if (sf->textbuf) free(sf->textbuf); + if (sf->filename) free(sf->filename); + sf->textbuf = NULL; + sf->filename = NULL; + free(sf); +} + + +#define SYMBTABSTARTSIZE 256 +static int symbtablength=0, symbtaballoclength=0; +static char *symbtab = NULL; + +static char * getsymbtabspace(int reqd) +{ + char *pos,*np; + int i; + + if (symbtablength + reqd > symbtaballoclength) + { + for(i=max(symbtaballoclength,SYMBTABSTARTSIZE);symbtablength+reqd>i;i<<=1); + np = (char *)realloc(symbtab, i); if (!np) return NULL; + symbtab = np; symbtaballoclength = i; + } + + pos = &symbtab[symbtablength]; + symbtablength += reqd; + return pos; +} + +int scriptfile_getsymbolvalue(char *name, int *val) +{ + char *scanner = symbtab; + + if (!symbtab) return 0; + while (scanner - symbtab < symbtablength) { + if (!Bstrcasecmp(name, scanner)) { + *val = *(int*)(scanner + strlen(scanner) + 1); + return 1; + } + + scanner += strlen(scanner) + 1 + sizeof(int); + } + + return 0; +} + +int scriptfile_addsymbolvalue(char *name, int val) +{ + int x; + char *sp; +// if (scriptfile_getsymbolvalue(name, &x)) return -1; // already exists + + if (symbtab) { + char *scanner = symbtab; + while (scanner - symbtab < symbtablength) { + if (!Bstrcasecmp(name, scanner)) { + *(int*)(scanner + strlen(scanner) + 1) = val; + return 1; + } + + scanner += strlen(scanner) + 1 + sizeof(int); + } + } + + sp = getsymbtabspace(strlen(name) + 1 + sizeof(int)); + if (!sp) return 0; + strcpy(sp, name); + sp += strlen(name)+1; + *(int*)sp = val; + return 1; // added +} + +void scriptfile_clearsymbols(void) +{ + if (symbtab) free(symbtab); + symbtab = NULL; + symbtablength = 0; + symbtaballoclength = 0; +} diff --git a/polymer/build/src/sdlayer.c b/polymer/build/src/sdlayer.c new file mode 100644 index 000000000..2ebb2e08c --- /dev/null +++ b/polymer/build/src/sdlayer.c @@ -0,0 +1,1510 @@ +// SDL interface layer +// for the Build Engine +// by Jonathon Fowler (jonof@edgenetwk.com) +// +// Use SDL1.2 from http://www.libsdl.org + +#include +#include +#ifndef __APPLE__ +# include "SDL.h" +#endif +#include "compat.h" +#include "sdlayer.h" +#include "cache1d.h" +#include "pragmas.h" +#include "a.h" +#include "build.h" +#include "osd.h" + +#ifdef USE_OPENGL +# include "glbuild.h" +#endif + +#if defined __APPLE__ +# include +# include "osxbits.h" +#elif defined HAVE_GTK2 +# include "gtkbits.h" +#endif + +#define SURFACE_FLAGS (SDL_SWSURFACE|SDL_HWPALETTE|SDL_HWACCEL) + +// undefine to restrict windowed resolutions to conventional sizes +#define ANY_WINDOWED_SIZE + +int _buildargc = 1; +char **_buildargv = NULL; +extern long app_main(long argc, char *argv[]); + +char quitevent=0, appactive=1; + +// video +static SDL_Surface *sdl_surface; +long xres=-1, yres=-1, bpp=0, fullscreen=0, bytesperline, imageSize; +long frameplace=0, lockcount=0; +char modechange=1; +char offscreenrendering=0; +char videomodereset = 0; +char nofog=0; +static unsigned short sysgamma[3][256]; +extern long curbrightness, gammabrightness; + +#ifdef USE_OPENGL +// OpenGL stuff +static char nogl=0; +#endif + +// input +char inputdevices=0; +char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; +unsigned char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; +static unsigned char keynames[256][24]; +long mousex=0,mousey=0,mouseb=0; +long *joyaxis = NULL, joyb=0, *joyhat = NULL; +char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0; +long joyaxespresent=0; + + +void (*keypresscallback)(long,long) = 0; +void (*mousepresscallback)(long,long) = 0; +void (*joypresscallback)(long,long) = 0; + +static unsigned char keytranslation[SDLK_LAST]; +static int buildkeytranslationtable(void); + +//static SDL_Surface * loadtarga(const char *fn); // for loading the icon +static SDL_Surface * loadappicon(void); + +int wm_msgbox(char *name, char *fmt, ...) +{ + char buf[1000]; + va_list va; + + va_start(va,fmt); + vsprintf(buf,fmt,va); + va_end(va); + +#if defined(__APPLE__) + return osx_msgbox(name, buf); +#elif defined HAVE_GTK2 + if (gtkbuild_msgbox(name, buf) >= 0) return 1; +#endif + puts(buf); + puts(" (press Return or Enter to continue)"); + getchar(); + + return 0; +} + +int wm_ynbox(char *name, char *fmt, ...) +{ + char buf[1000]; + char c; + va_list va; + int r; + + va_start(va,fmt); + vsprintf(buf,fmt,va); + va_end(va); + +#if defined __APPLE__ + return osx_ynbox(name, buf); +#elif defined HAVE_GTK2 + if ((r = gtkbuild_ynbox(name, buf)) >= 0) return r; +#endif + puts(buf); + puts(" (type 'Y' or 'N', and press Return or Enter to continue)"); + do c = getchar(); while (c != 'Y' && c != 'y' && c != 'N' && c != 'n'); + if (c == 'Y' || c == 'y') return 1; + + return 0; +} + +void wm_setapptitle(char *name) +{ + if (name) { + Bstrncpy(apptitle, name, sizeof(apptitle)-1); + apptitle[ sizeof(apptitle)-1 ] = 0; + } + + SDL_WM_SetCaption(apptitle, NULL); + +#ifdef HAVE_GTK2 + gtkbuild_settitle_startwin(apptitle); +#endif +} + + +// +// +// --------------------------------------- +// +// System +// +// --------------------------------------- +// +// + +int main(int argc, char *argv[]) +{ + int r; + + buildkeytranslationtable(); + +#ifdef HAVE_GTK2 + gtkbuild_init(&argc, &argv); + gtkbuild_create_startwin(); +#endif + + _buildargc = argc; + _buildargv = (char**)argv; + //_buildargv = (char**)malloc(argc * sizeof(char*)); + //memcpy(_buildargv, argv, sizeof(char*)*argc); + + baselayer_init(); + r = app_main(argc, argv); + +#ifdef HAVE_GTK2 + gtkbuild_close_startwin(); + gtkbuild_exit(r); +#endif + return r; +} + + +// +// initsystem() -- init SDL systems +// +int initsystem(void) +{ + const SDL_VideoInfo *vid; + const SDL_version *linked = SDL_Linked_Version(); + SDL_version compiled; + char drvname[32]; + + SDL_VERSION(&compiled); + + initprintf("Initialising SDL system interface " + "(compiled with SDL version %d.%d.%d, DLL version %d.%d.%d)\n", + linked->major, linked->minor, linked->patch, + compiled.major, compiled.minor, compiled.patch); + + if (SDL_Init(SDL_INIT_VIDEO //| SDL_INIT_TIMER +#ifdef NOSDLPARACHUTE + | SDL_INIT_NOPARACHUTE +#endif + )) { + initprintf("Initialisation failed! (%s)\n", SDL_GetError()); + return -1; + } + + atexit(uninitsystem); + + frameplace = 0; + lockcount = 0; + +#ifdef USE_OPENGL + if (loadgldriver(getenv("BUILD_GLDRV"))) { + initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n"); + nogl = 1; + } +#endif + +#ifndef __APPLE__ + { + SDL_Surface *icon; + //icon = loadtarga("icon.tga"); + icon = loadappicon(); + if (icon) { + SDL_WM_SetIcon(icon, 0); + SDL_FreeSurface(icon); + } + } +#endif + + if (SDL_VideoDriverName(drvname, 32)) + initprintf("Using \"%s\" video driver\n", drvname); + + // dump a quick summary of the graphics hardware +#ifdef DEBUGGINGAIDS + vid = SDL_GetVideoInfo(); + initprintf("Video device information:\n"); + initprintf(" Can create hardware surfaces? %s\n", (vid->hw_available)?"Yes":"No"); + initprintf(" Window manager available? %s\n", (vid->wm_available)?"Yes":"No"); + initprintf(" Accelerated hardware blits? %s\n", (vid->blit_hw)?"Yes":"No"); + initprintf(" Accelerated hardware colourkey blits? %s\n", (vid->blit_hw_CC)?"Yes":"No"); + initprintf(" Accelerated hardware alpha blits? %s\n", (vid->blit_hw_A)?"Yes":"No"); + initprintf(" Accelerated software blits? %s\n", (vid->blit_sw)?"Yes":"No"); + initprintf(" Accelerated software colourkey blits? %s\n", (vid->blit_sw_CC)?"Yes":"No"); + initprintf(" Accelerated software alpha blits? %s\n", (vid->blit_sw_A)?"Yes":"No"); + initprintf(" Accelerated colour fills? %s\n", (vid->blit_fill)?"Yes":"No"); + initprintf(" Total video memory: %dKB\n", vid->video_mem); +#endif + + return 0; +} + + +// +// uninitsystem() -- uninit SDL systems +// +void uninitsystem(void) +{ + uninitinput(); + uninitmouse(); + uninittimer(); + + SDL_Quit(); + +#ifdef USE_OPENGL + unloadgldriver(); +#endif +} + + +// +// initprintf() -- prints a string to the intitialization window +// +void initprintf(const char *f, ...) +{ + va_list va; + char buf[1024]; + + va_start(va, f); + vprintf(f,va); + va_end(va); + + va_start(va, f); + Bvsnprintf(buf, 1024, f, va); + va_end(va); + OSD_Printf(buf); + +#ifdef HAVE_GTK2 + gtkbuild_puts_startwin(buf); + gtkbuild_update_startwin(); +#endif +} + + +// +// debugprintf() -- prints a debug string to stderr +// +void debugprintf(const char *f, ...) +{ +#ifdef DEBUGGINGAIDS + va_list va; + + va_start(va,f); + Bvfprintf(stderr, f, va); + va_end(va); +#endif +} + + +// +// +// --------------------------------------- +// +// All things Input +// +// --------------------------------------- +// +// + +static char mouseacquired=0,moustat=0; +static long joyblast=0; +static SDL_Joystick *joydev = NULL; + +// +// initinput() -- init input system +// +int initinput(void) +{ + int i,j; + +#ifdef __APPLE__ + // force OS X to operate in >1 button mouse mode so that LMB isn't adulterated + if (!getenv("SDL_HAS3BUTTONMOUSE")) putenv("SDL_HAS3BUTTONMOUSE=1"); +#endif + + if (SDL_EnableKeyRepeat(250, 30)) initprintf("Error enabling keyboard repeat.\n"); + inputdevices = 1|2; // keyboard (1) and mouse (2) + mouseacquired = 0; + + SDL_EnableUNICODE(1); // let's hope this doesn't hit us too hard + + memset(keynames,0,sizeof(keynames)); + for (i=0; i= 256) return NULL; + return keynames[num]; +} + +const unsigned char *getjoyname(int what, int num) +{ + static char tmp[64]; + + switch (what) { + case 0: // axis + if ((unsigned)num > (unsigned)joynumaxes) return NULL; + sprintf(tmp,"Axis %d",num); + return tmp; + + case 1: // button + if ((unsigned)num > (unsigned)joynumbuttons) return NULL; + sprintf(tmp,"Button %d",num); + return tmp; + + case 2: // hat + if ((unsigned)num > (unsigned)joynumhats) return NULL; + sprintf(tmp,"Hat %d",num); + return tmp; + + default: + return NULL; + } +} + +// +// bgetchar, bkbhit, bflushchars -- character-based input functions +// +unsigned char bgetchar(void) +{ + unsigned char c; + if (keyasciififoplc == keyasciififoend) return 0; + c = keyasciififo[keyasciififoplc]; + keyasciififoplc = ((keyasciififoplc+1)&(KEYFIFOSIZ-1)); + return c; +} + +int bkbhit(void) +{ + return (keyasciififoplc != keyasciififoend); +} + +void bflushchars(void) +{ + keyasciififoplc = keyasciififoend = 0; +} + + +// +// set{key|mouse|joy}presscallback() -- sets a callback which gets notified when keys are pressed +// +void setkeypresscallback(void (*callback)(long, long)) { keypresscallback = callback; } +void setmousepresscallback(void (*callback)(long, long)) { mousepresscallback = callback; } +void setjoypresscallback(void (*callback)(long, long)) { joypresscallback = callback; } + +// +// initmouse() -- init mouse input +// +int initmouse(void) +{ + moustat=1; + grabmouse(1); + return 0; +} + +// +// uninitmouse() -- uninit mouse input +// +void uninitmouse(void) +{ + grabmouse(0); + moustat=0; +} + + +// +// grabmouse() -- show/hide mouse cursor +// +void grabmouse(char a) +{ + if (appactive && moustat) { + if (a != mouseacquired) { +#ifndef DEBUGGINGAIDS + SDL_GrabMode g; + + g = SDL_WM_GrabInput( a ? SDL_GRAB_ON : SDL_GRAB_OFF ); + mouseacquired = (g == SDL_GRAB_ON); + + SDL_ShowCursor(mouseacquired ? SDL_DISABLE : SDL_ENABLE); +#else + mouseacquired = a; +#endif + } + } else { + mouseacquired = a; + } + mousex = mousey = 0; +} + + +// +// readmousexy() -- return mouse motion information +// +void readmousexy(long *x, long *y) +{ + if (!mouseacquired || !appactive || !moustat) { *x = *y = 0; return; } + *x = mousex; + *y = mousey; + mousex = mousey = 0; +} + +// +// readmousebstatus() -- return mouse button information +// +void readmousebstatus(long *b) +{ + if (!mouseacquired || !appactive || !moustat) *b = 0; + else *b = mouseb; +} + +// +// setjoydeadzone() -- sets the dead and saturation zones for the joystick +// +void setjoydeadzone(int axis, unsigned short dead, unsigned short satur) +{ +} + + +// +// getjoydeadzone() -- gets the dead and saturation zones for the joystick +// +void getjoydeadzone(int axis, unsigned short *dead, unsigned short *satur) +{ + *dead = *satur = 0; +} + + +// +// releaseallbuttons() +// +void releaseallbuttons(void) +{ +} + + +// +// +// --------------------------------------- +// +// All things Timer +// Ken did this +// +// --------------------------------------- +// +// + +static Uint32 timerfreq=0; +static Uint32 timerlastsample=0; +static Uint32 timerticspersec=0; +static void (*usertimercallback)(void) = NULL; + +// +// inittimer() -- initialise timer +// +int inittimer(int tickspersecond) +{ + if (timerfreq) return 0; // already installed + + initprintf("Initialising timer\n"); + + timerfreq = 1000; + timerticspersec = tickspersecond; + timerlastsample = SDL_GetTicks() * timerticspersec / timerfreq; + + usertimercallback = NULL; + + return 0; +} + +// +// uninittimer() -- shut down timer +// +void uninittimer(void) +{ + if (!timerfreq) return; + + timerfreq=0; +} + +// +// sampletimer() -- update totalclock +// +void sampletimer(void) +{ + Uint32 i; + long n; + + if (!timerfreq) return; + + i = SDL_GetTicks(); + n = (long)(i * timerticspersec / timerfreq) - timerlastsample; + if (n>0) { + totalclock += n; + timerlastsample += n; + } + + if (usertimercallback) for (; n>0; n--) usertimercallback(); +} + +// +// getticks() -- returns the sdl ticks count +// +unsigned long getticks(void) +{ + return (unsigned long)SDL_GetTicks(); +} + + +// +// gettimerfreq() -- returns the number of ticks per second the timer is configured to generate +// +int gettimerfreq(void) +{ + return timerticspersec; +} + + +// +// installusertimercallback() -- set up a callback function to be called when the timer is fired +// +void (*installusertimercallback(void (*callback)(void)))(void) +{ + void (*oldtimercallback)(void); + + oldtimercallback = usertimercallback; + usertimercallback = callback; + + return oldtimercallback; +} + + + +// +// +// --------------------------------------- +// +// All things Video +// +// --------------------------------------- +// +// + + +// +// getvalidmodes() -- figure out what video modes are available +// +static int sortmodes(const struct validmode_t *a, const struct validmode_t *b) +{ + int x; + + if ((x = a->fs - b->fs) != 0) return x; + if ((x = a->bpp - b->bpp) != 0) return x; + if ((x = a->xdim - b->xdim) != 0) return x; + if ((x = a->ydim - b->ydim) != 0) return x; + + return 0; +} +static char modeschecked=0; +void getvalidmodes(void) +{ + static int cdepths[] = { + 8, +#ifdef USE_OPENGL + 16,24,32, +#endif + 0 }; + static int defaultres[][2] = { + {1280,1024},{1280,960},{1152,864},{1024,768},{800,600},{640,480}, + {640,400},{512,384},{480,360},{400,300},{320,240},{320,200},{0,0} + }; + SDL_Rect **modes; + SDL_PixelFormat pf = { NULL, 8, 1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0 }; + int i, j, maxx=0, maxy=0; + + if (modeschecked) return; + + validmodecnt=0; + initprintf("Detecting video modes:\n"); + +#define ADDMODE(x,y,c,f) if (validmodecnt> 3; + + modes = SDL_ListModes(&pf, SURFACE_FLAGS | SDL_FULLSCREEN); + if (modes == (SDL_Rect **)0) { + if (cdepths[j] > 8) cdepths[j] = -1; + continue; + } + + if (modes == (SDL_Rect **)-1) { + for (i=0; defaultres[i][0]; i++) + ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],1) + } else { + for (i=0; modes[i]; i++) { + if ((modes[i]->w > MAXXDIM) || (modes[i]->h > MAXYDIM)) continue; + + ADDMODE(modes[i]->w, modes[i]->h, cdepths[j], 1) + + if ((modes[i]->w > maxx) && (modes[i]->h > maxy)) { + maxx = modes[i]->w; + maxy = modes[i]->h; + } + } + } + } + + if (maxx == 0 && maxy == 0) { + initprintf("No fullscreen modes available!\n"); + maxx = MAXXDIM; maxy = MAXYDIM; + } + + // add windowed modes next + for (j=0; cdepths[j]; j++) { + if (cdepths[j] < 0) continue; + for (i=0; defaultres[i][0]; i++) + CHECK(defaultres[i][0],defaultres[i][1]) + ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],0) + } + +#undef CHECK +#undef ADDMODE + + qsort((void*)validmode, validmodecnt, sizeof(struct validmode_t), (int(*)(const void*,const void*))sortmodes); + + modeschecked=1; +} + + +// +// checkvideomode() -- makes sure the video mode passed is legal +// +int checkvideomode(int *x, int *y, int c, int fs) +{ + int i, nearest=-1, dx, dy, odx=9999, ody=9999; + + getvalidmodes(); + + if (c>8 +#ifdef USE_OPENGL + && nogl +#endif + ) return -1; + + // fix up the passed resolution values to be multiples of 8 + // and at least 320x200 or at most MAXXDIMxMAXYDIM + if (*x < 320) *x = 320; + if (*y < 200) *y = 200; + if (*x > MAXXDIM) *x = MAXXDIM; + if (*y > MAXYDIM) *y = MAXYDIM; + *x &= 0xfffffff8l; + + for (i=0; i 8 && sdl_surface) polymost_glreset(); +#endif + + // restore gamma before we change video modes if it was changed + if (sdl_surface && gammabrightness) { + SDL_SetGammaRamp(sysgamma[0], sysgamma[1], sysgamma[2]); + gammabrightness = 0; // redetect on next mode switch + } + +#if defined(USE_OPENGL) + if (c > 8) { + int i, j, multisamplecheck = (glmultisample > 0); + struct { + SDL_GLattr attr; + int value; + } attributes[] = { +#if 0 + { SDL_GL_RED_SIZE, 8 }, + { SDL_GL_GREEN_SIZE, 8 }, + { SDL_GL_BLUE_SIZE, 8 }, + { SDL_GL_ALPHA_SIZE, 8 }, + { SDL_GL_BUFFER_SIZE, c }, + { SDL_GL_STENCIL_SIZE, 0 }, + { SDL_GL_ACCUM_RED_SIZE, 0 }, + { SDL_GL_ACCUM_GREEN_SIZE, 0 }, + { SDL_GL_ACCUM_BLUE_SIZE, 0 }, + { SDL_GL_ACCUM_ALPHA_SIZE, 0 }, + { SDL_GL_DEPTH_SIZE, 24 }, +#endif + { SDL_GL_DOUBLEBUFFER, 1 }, + { SDL_GL_MULTISAMPLEBUFFERS, glmultisample > 0 }, + { SDL_GL_MULTISAMPLESAMPLES, glmultisample }, + }; + + if (nogl) return -1; + + initprintf("Setting video mode %dx%d (%d-bpp %s)\n", + x,y,c, ((fs&1) ? "fullscreen" : "windowed")); + do { + for (i=0; i < (int)(sizeof(attributes)/sizeof(attributes[0])); i++) { + j = attributes[i].value; + if (!multisamplecheck && + (attributes[i].attr == SDL_GL_MULTISAMPLEBUFFERS || + attributes[i].attr == SDL_GL_MULTISAMPLESAMPLES) + ) { + j = 0; + } + SDL_GL_SetAttribute(attributes[i].attr, j); + } + + sdl_surface = SDL_SetVideoMode(x, y, c, SDL_OPENGL | ((fs&1)?SDL_FULLSCREEN:0)); + if (!sdl_surface) { + if (multisamplecheck) { + initprintf("Multisample mode not possible. Retrying without multisampling.\n"); + glmultisample = 0; + continue; + } + initprintf("Unable to set video mode!\n"); + return -1; + } + } while (multisamplecheck--); + } else +#endif + { + initprintf("Setting video mode %dx%d (%d-bpp %s)\n", + x,y,c, ((fs&1) ? "fullscreen" : "windowed")); + sdl_surface = SDL_SetVideoMode(x, y, c, SURFACE_FLAGS | ((fs&1)?SDL_FULLSCREEN:0)); + if (!sdl_surface) { + initprintf("Unable to set video mode!\n"); + return -1; + } + } + +#if 0 + { + char flags[512] = ""; +#define FLAG(x,y) if ((sdl_surface->flags & x) == x) { strcat(flags, y); strcat(flags, " "); } + FLAG(SDL_HWSURFACE, "HWSURFACE") else + FLAG(SDL_SWSURFACE, "SWSURFACE") + FLAG(SDL_ASYNCBLIT, "ASYNCBLIT") + FLAG(SDL_ANYFORMAT, "ANYFORMAT") + FLAG(SDL_HWPALETTE, "HWPALETTE") + FLAG(SDL_DOUBLEBUF, "DOUBLEBUF") + FLAG(SDL_FULLSCREEN, "FULLSCREEN") + FLAG(SDL_OPENGL, "OPENGL") + FLAG(SDL_OPENGLBLIT, "OPENGLBLIT") + FLAG(SDL_RESIZABLE, "RESIZABLE") + FLAG(SDL_HWACCEL, "HWACCEL") + FLAG(SDL_SRCCOLORKEY, "SRCCOLORKEY") + FLAG(SDL_RLEACCEL, "RLEACCEL") + FLAG(SDL_SRCALPHA, "SRCALPHA") + FLAG(SDL_PREALLOC, "PREALLOC") +#undef FLAG + initprintf("SDL Surface flags: %s\n", flags); + } +#endif + + { + //static char t[384]; + //sprintf(t, "%s (%dx%d %s)", apptitle, x, y, ((fs) ? "fullscreen" : "windowed")); + SDL_WM_SetCaption(apptitle, 0); + } + +#ifdef USE_OPENGL + if (c > 8) { + GLubyte *p,*p2,*p3; + int i; + + polymost_glreset(); + + bglEnable(GL_TEXTURE_2D); + bglShadeModel(GL_SMOOTH); //GL_FLAT + bglClearColor(0,0,0,0.5); //Black Background + bglHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); //Use FASTEST for ortho! + bglHint(GL_LINE_SMOOTH_HINT,GL_NICEST); + bglDisable(GL_DITHER); + + glinfo.vendor = bglGetString(GL_VENDOR); + glinfo.renderer = bglGetString(GL_RENDERER); + glinfo.version = bglGetString(GL_VERSION); + glinfo.extensions = bglGetString(GL_EXTENSIONS); + + glinfo.maxanisotropy = 1.0; + glinfo.bgra = 0; + glinfo.texcompr = 0; + + // process the extensions string and flag stuff we recognize + p = Bstrdup(glinfo.extensions); + p3 = p; + while ((p2 = Bstrtoken(p3==p?p:NULL, " ", (char**)&p3, 1)) != NULL) { + if (!Bstrcmp(p2, "GL_EXT_texture_filter_anisotropic")) { + // supports anisotropy. get the maximum anisotropy level + bglGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glinfo.maxanisotropy); + } else if (!Bstrcmp(p2, "GL_EXT_texture_edge_clamp") || + !Bstrcmp(p2, "GL_SGIS_texture_edge_clamp")) { + // supports GL_CLAMP_TO_EDGE or GL_CLAMP_TO_EDGE_SGIS + glinfo.clamptoedge = 1; + } else if (!Bstrcmp(p2, "GL_EXT_bgra")) { + // support bgra textures + glinfo.bgra = 1; + } else if (!Bstrcmp(p2, "GL_ARB_texture_compression")) { + // support texture compression + glinfo.texcompr = 1; + } else if (!Bstrcmp(p2, "GL_ARB_texture_non_power_of_two")) { + // support non-power-of-two texture sizes + glinfo.texnpot = 1; + } else if (!Bstrcmp(p2, "WGL_3DFX_gamma_control")) { + // 3dfx cards have issues with fog + nofog = 1; + if (!(warnonce&1)) initprintf("3dfx card detected: OpenGL fog disabled\n"); + warnonce |= 1; + } else if (!Bstrcmp(p2, "GL_ARB_multisample")) { + // supports multisampling + glinfo.multisample = 1; + } else if (!Bstrcmp(p2, "GL_NV_multisample_filter_hint")) { + // supports nvidia's multisample hint extension + glinfo.nvmultisamplehint = 1; + } + } + Bfree(p); + } +#endif + + xres = x; + yres = y; + bpp = c; + fullscreen = fs; + //bytesperline = sdl_surface->pitch; + //imageSize = bytesperline*yres; + numpages = c>8?2:1; + frameplace = 0; + lockcount = 0; + modechange=1; + videomodereset = 0; + OSD_ResizeDisplay(xres,yres); + + // save the current system gamma to determine if gamma is available + if (!gammabrightness) { + float f = 1.0 + ((float)curbrightness / 10.0); + if (SDL_GetGammaRamp(sysgamma[0], sysgamma[1], sysgamma[2]) >= 0) + gammabrightness = 1; + + // see if gamma really is working by trying to set the brightness + if (gammabrightness && SDL_SetGamma(f,f,f) < 0) + gammabrightness = 0; // nope + } + + // setpalettefade will set the palette according to whether gamma worked + setpalettefade(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta); + + //if (c==8) setpalette(0,256,0); + //baselayer_onvideomodechange(c>8); + + if (regrab) grabmouse(1); + + return 0; +} + + +// +// resetvideomode() -- resets the video system +// +void resetvideomode(void) +{ + videomodereset = 1; + modeschecked = 0; +} + + +// +// begindrawing() -- locks the framebuffer for drawing +// +void begindrawing(void) +{ + long i,j; + + if (bpp > 8) { + if (offscreenrendering) return; + frameplace = 0; + bytesperline = 0; + imageSize = 0; + modechange = 0; + return; + } + + // lock the frame + if (lockcount++ > 0) + return; + + if (offscreenrendering) return; + + if (SDL_MUSTLOCK(sdl_surface)) SDL_LockSurface(sdl_surface); + frameplace = (long)sdl_surface->pixels; + + if (sdl_surface->pitch != bytesperline || modechange) { + bytesperline = sdl_surface->pitch; + imageSize = bytesperline*yres; + setvlinebpl(bytesperline); + + j = 0; + for(i=0;i<=ydim;i++) ylookup[i] = j, j += bytesperline; + modechange=0; + } +} + + +// +// enddrawing() -- unlocks the framebuffer +// +void enddrawing(void) +{ + if (bpp > 8) { + if (!offscreenrendering) frameplace = 0; + return; + } + + if (!frameplace) return; + if (lockcount > 1) { lockcount--; return; } + if (!offscreenrendering) frameplace = 0; + if (lockcount == 0) return; + lockcount = 0; + + if (offscreenrendering) return; + + if (SDL_MUSTLOCK(sdl_surface)) SDL_UnlockSurface(sdl_surface); +} + + +// +// showframe() -- update the display +// +void showframe(int w) +{ + long i,j; + +#ifdef USE_OPENGL + if (bpp > 8) { + if (palfadedelta) { + bglMatrixMode(GL_PROJECTION); + bglPushMatrix(); + bglLoadIdentity(); + bglMatrixMode(GL_MODELVIEW); + bglPushMatrix(); + bglLoadIdentity(); + + bglDisable(GL_DEPTH_TEST); + bglDisable(GL_ALPHA_TEST); + bglDisable(GL_TEXTURE_2D); + + bglEnable(GL_BLEND); + bglColor4ub(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta); + + bglBegin(GL_QUADS); + bglVertex2i(-1, -1); + bglVertex2i(1, -1); + bglVertex2i(1, 1); + bglVertex2i(-1, 1); + bglEnd(); + + bglMatrixMode(GL_MODELVIEW); + bglPopMatrix(); + bglMatrixMode(GL_PROJECTION); + bglPopMatrix(); + } + + SDL_GL_SwapBuffers(); + return; + } +#endif + + if (offscreenrendering) return; + + if (lockcount) { + printf("Frame still locked %ld times when showframe() called.\n", lockcount); + while (lockcount) enddrawing(); + } + + SDL_Flip(sdl_surface); +} + + +// +// setpalette() -- set palette values +// +int setpalette(int start, int num, char *dapal) +{ + SDL_Color pal[256]; + int i,n; + + if (bpp > 8) return 0; // no palette in opengl + + copybuf(curpalettefaded, pal, 256); + + for (i=start, n=num; n>0; i++, n--) { + /* + pal[i].b = dapal[0] << 2; + pal[i].g = dapal[1] << 2; + pal[i].r = dapal[2] << 2; + */ + curpalettefaded[i].f = pal[i].unused = 0; + dapal += 4; + } + + //return SDL_SetPalette(sdl_surface, SDL_LOGPAL|SDL_PHYSPAL, pal, 0, 256); + return SDL_SetColors(sdl_surface, pal, 0, 256); +} + +// +// getpalette() -- get palette values +// +/* +int getpalette(int start, int num, char *dapal) +{ + int i; + SDL_Palette *pal; + + // we shouldn't need to lock the surface to get the palette + pal = sdl_surface->format->palette; + + for (i=num; i>0; i--, start++) { + dapal[0] = pal->colors[start].b >> 2; + dapal[1] = pal->colors[start].g >> 2; + dapal[2] = pal->colors[start].r >> 2; + dapal += 4; + } + + return 1; +} +*/ + +// +// setgamma +// +int setgamma(float ro, float go, float bo) +{ + return SDL_SetGamma(ro,go,bo); +} + +#ifndef __APPLE__ +extern struct sdlappicon sdlappicon; +static SDL_Surface * loadappicon(void) +{ + SDL_Surface *surf; + + surf = SDL_CreateRGBSurfaceFrom((void*)sdlappicon.pixels, + sdlappicon.width, sdlappicon.height, 32, sdlappicon.width*4, + 0xffl,0xff00l,0xff0000l,0xff000000l); + + return surf; +} +#endif + +// +// +// --------------------------------------- +// +// Miscellany +// +// --------------------------------------- +// +// + + +// +// handleevents() -- process the SDL message queue +// returns !0 if there was an important event worth checking (like quitting) +// +int handleevents(void) +{ + int code, rv=0, j; + SDL_Event ev; + +#define SetKey(key,state) { \ + keystatus[key] = state; \ + if (state) { \ + keyfifo[keyfifoend] = key; \ + keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state; \ + keyfifoend = ((keyfifoend+2)&(KEYFIFOSIZ-1)); \ + } \ +} + + while (SDL_PollEvent(&ev)) { + switch (ev.type) { + case SDL_KEYDOWN: + case SDL_KEYUP: + code = keytranslation[ev.key.keysym.sym]; + + if (ev.key.keysym.unicode != 0 && ev.key.type == SDL_KEYDOWN && + (ev.key.keysym.unicode & 0xff80) == 0 && + ((keyasciififoend+1)&(KEYFIFOSIZ-1)) != keyasciififoplc) { + keyasciififo[keyasciififoend] = ev.key.keysym.unicode & 0x7f; + keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1)); + } + + // hook in the osd + if (OSD_HandleKey(code, (ev.key.type == SDL_KEYDOWN)) == 0) + break; + + if (ev.key.type == SDL_KEYDOWN) { + if (!keystatus[code]) { + SetKey(code, 1); + if (keypresscallback) + keypresscallback(code, 1); + } + } else { + SetKey(code, 0); + if (keypresscallback) + keypresscallback(code, 0); + } + break; + + case SDL_ACTIVEEVENT: + if (ev.active.state & SDL_APPINPUTFOCUS) { + appactive = ev.active.gain; + if (mouseacquired && moustat) { + if (appactive) { + SDL_WM_GrabInput(SDL_GRAB_ON); + SDL_ShowCursor(SDL_DISABLE); + } else { + SDL_WM_GrabInput(SDL_GRAB_OFF); + SDL_ShowCursor(SDL_ENABLE); + } + } + rv=-1; + } + break; + + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + switch (ev.button.button) { + case SDL_BUTTON_LEFT: j = 0; break; + case SDL_BUTTON_RIGHT: j = 1; break; + case SDL_BUTTON_MIDDLE: j = 2; break; + default: j = -1; break; + } + if (j<0) break; + + if (ev.button.state == SDL_PRESSED) + mouseb |= (1< 48000) dasamplerate = 48000; + + musicstat = damusistat; + + printOSD("Initialising FMOD...\n"); + printOSD(" Linked version: %.02f\n", FMOD_VERSION); + printOSD(" DLL version: %.02f\n", FSOUND_GetVersion()); + + if (FSOUND_GetVersion() < FMOD_VERSION) { + printOSD(" ... Failure: FMOD DLL too old! Sound disabled.\n"); + return; + } + + printOSD(" Samplerate: %d hz\n", dasamplerate); + + //FSOUND_SetOutput(FSOUND_OUTPUT_ASIO); + + if (FSOUND_Init(dasamplerate, NUMCHANNELS, 0)) { + printOSD(" ... Success\n"); + fmod_inited = 1; + } else { + printOSD(" ... Failure: %s\n", FMOD_ErrorString(FSOUND_GetError())); + } + + switch (FSOUND_GetOutput()) { + case FSOUND_OUTPUT_NOSOUND: s = "No Sound"; break; + case FSOUND_OUTPUT_WINMM: s = "WINMM"; break; + case FSOUND_OUTPUT_DSOUND: s = "DirectSound"; break; + case FSOUND_OUTPUT_OSS: s = "OSS"; break; + case FSOUND_OUTPUT_ESD: s = "ESound"; break; + case FSOUND_OUTPUT_ALSA: s = "ALSA"; break; + case FSOUND_OUTPUT_ASIO: s = "ASIO"; break; + default: s = "Other"; break; + } + printOSD("Using FMOD \"%s\" output driver\n", s); + + FSOUND_File_SetCallbacks( + (FSOUND_OPENCALLBACK)f_open, + (FSOUND_CLOSECALLBACK)f_close, + (FSOUND_READCALLBACK)f_read, + (FSOUND_SEEKCALLBACK)f_seek, + (FSOUND_TELLCALLBACK)f_tell); + //FSOUND_SetMemorySystem(fmod_cache, fmod_cachelen, NULL, NULL, NULL); + + loadwaves(); + + for (i=0; i=0;wavnum--) { + bad = 0; + + i = 0; + while ((dafilename[i] > 0) && (i < 16)) + { + ch1 = dafilename[i]; if ((ch1 >= 97) && (ch1 <= 123)) ch1 -= 32; + ch2 = instname[wavnum][i]; if ((ch2 >= 97) && (ch2 <= 123)) ch2 -= 32; + if (ch1 != ch2) {bad = 1; break;} + i++; + } + if (bad != 0) continue; + + for (i=0; i oldestpos) { + oldest = i; + oldestpos = FSOUND_GetCurrentPosition(channels[i]); + } + } + + if (free < 0) { + FSOUND_StopSound(channels[oldest]); + free = oldest; + } + + chan = FSOUND_PlaySoundEx(FSOUND_FREE, samples[wavnum], NULL, 1); + if (chan == -1) return; + FSOUND_SetFrequency(chan, dafreq*11025/4096); + FSOUND_SetVolume(chan, davol); + + FSOUND_SetPaused(chan, 0); + + channels[free] = chan; + return; + } +} + + +void wsay(char *dafilename, long dafreq, long volume1, long volume2) +{ + unsigned char ch1, ch2; + long i, j, bad, free=-1, oldest=0; + unsigned int oldestpos=0; + int chan; + + if (fmod_inited == 0) return; + + i = numwaves-1; + do + { + bad = 0; + + j = 0; + while ((dafilename[j] > 0) && (j < 16)) + { + ch1 = dafilename[j]; if ((ch1 >= 97) && (ch1 <= 123)) ch1 -= 32; + ch2 = instname[i][j]; if ((ch2 >= 97) && (ch2 <= 123)) ch2 -= 32; + if (ch1 != ch2) {bad = 1; break;} + j++; + } + if (bad == 0) + { + for (j=0; j oldestpos) { + oldest = j; + oldestpos = FSOUND_GetCurrentPosition(channels[j]); + } + } + + if (free < 0) { + FSOUND_StopSound(channels[oldest]); + free = oldest; + } + + chan = FSOUND_PlaySoundEx(FSOUND_FREE, samples[i], NULL, 1); + if (chan == -1) return; + FSOUND_SetFrequency(chan, dafreq*11025/4096); + FSOUND_SetVolume(chan, (volume1*volume2)>>1); + // set pan + FSOUND_SetPaused(chan, 0); + + channels[free] = chan; + + return; + } + + i--; + } while (i >= 0); +} + + +void loadwaves(void) +{ + long fil, dawaversionum, i, tmp; + long wavleng[MAXWAVES], repstart[MAXWAVES], repleng[MAXWAVES], finetune[MAXWAVES]; + char *p; + + fil = kopen4load("WAVES.KWV", 0); + + if (fil != -1) { + kread(fil, &dawaversionum, 4); dawaversionum = B_LITTLE32(dawaversionum); + if (dawaversionum != 0) { kclose(fil); return; } + + kread(fil, &numwaves, 4); numwaves = B_LITTLE32(numwaves); + for (i=0; i +#include +#include +#include +#include +#include + + +char defsrcext[] = ".DAT"; +char defoutext[] = ".C"; + +char source[MAXPATH], output[MAXPATH], bytesize; + + +int PathAddExt(char *path, char *ext); + + +void main(int argc, char *argv[]) +{ + printf("BIN2C - Binary to C data converter\n" + "Copyright (c) 1999 Jonathon Fowler\n\n"); + + if (argc < 4) + { + printf("Usage:\n" + " BIN2C source<.DAT> output<.C> b|w\n\n" + " source<.DAT> Binary source file\n" + " output<.C> Output C code file\n" + " b|w Byte or word-sized data\n\n"); + exit(0); + } + + int arg; + FILE *in, *out; + char datab1, datab2; + int across=0, maxacross; + long length, written=0; + + + // get the source file + strcpy(source, argv[1]); + strupr(source); + PathAddExt(source, defsrcext); + printf("þ Source file: %s\n", source); + + // get the output file + strcpy(output, argv[2]); + strupr(output); + PathAddExt(output, defoutext); + printf("þ Output file: %s\n", output); + + // get byte/word data + switch (tolower(argv[3][0])) + { + case 'b': + printf("þ Byte data.\n"); + bytesize=1; + break; + + case 'w': + printf("þ Word data.\n"); + bytesize=0; + break; + + default: + printf("þ Unknown data size specified. Defaulting to byte.\n"); + bytesize=1; + break; + } + + // open the input file + in = fopen(source, "rb"); + if (!in) + { + printf("Error opening %s\n", source); + exit(1); + } + + // open the output file + out = fopen(output, "w+t"); + if (!out) + { + printf("Error creating %s\n", output); + exit(1); + } + + length = filelength(fileno(in)); + + // write a header out to the output file + fprintf(out, "// %s\n\n// Generated by BIN2C.EXE\n// By Jonathon Fowler\n\n", output); + + // start a data block + fprintf(out, "%s datablock[] = {\n // %ld bytes", (bytesize) ? "char" : "unsigned", length); + + if (bytesize) + maxacross = 12; + else + maxacross = 9; + across = maxacross; + + // convert the data + for (written=0; written1) ? ',' : '\n'); + } else { + datab1 = fgetc(in); + datab2 = fgetc(in); + fprintf(out, " 0x%02X%02X%c", datab2, datab1, ((length-written)>2) ? ',' : '\n'); + } + + across++; + + if (!bytesize) written++; + } + + + fprintf(out, " };"); + + fclose(out); + fclose(in); +} + + +// Add an extention to a path if one doesn't exist +int PathAddExt(char *path, char *ext) +{ + char drive[MAXDRIVE], dir[MAXDIR], name[MAXFILE], extn[MAXEXT]; + int flags; + + flags = fnsplit(path, drive, dir, name, extn); + + if (!(flags & EXTENSION)) // tack on an extension + strcat(path, ext); + + return ((flags & EXTENSION) == 0); +} diff --git a/polymer/build/src/util/cacheinfo.c b/polymer/build/src/util/cacheinfo.c new file mode 100644 index 000000000..07b5f68ff --- /dev/null +++ b/polymer/build/src/util/cacheinfo.c @@ -0,0 +1,90 @@ +#include +#include +#include +#include +#include "compat.h" + +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 + +typedef struct { + char magic[8]; // 'Polymost' + long xdim, ydim; // of image, unpadded + long flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed +} texcacheheader; +typedef struct { + long size; + long format; + long xdim, ydim; // of mipmap (possibly padded) + long border, depth; +} texcachepicture; + +int main(int argc, char **argv) +{ + DIR *dir; + struct dirent *dirent; + struct stat st; + FILE *fp; + texcacheheader head; + texcachepicture mip; + + dir = opendir("."); + while ((dirent = readdir(dir))) { + if (stat(dirent->d_name, &st)) { + printf("%s: failed to stat\n", dirent->d_name); + continue; + } + if (!(st.st_mode&S_IFREG)) { + printf("%s: not a regular file\n", dirent->d_name); + continue; + } + + fp = fopen(dirent->d_name,"rb"); + if (!fp) { + printf("%s: failed to open\n", dirent->d_name); + continue; + } + + if (fread(&head, sizeof(head), 1, fp) != 1) { + fclose(fp); + printf("%s: failed to read header\n", dirent->d_name); + continue; + } + head.xdim = B_LITTLE32(head.xdim); + head.ydim = B_LITTLE32(head.ydim); + head.flags = B_LITTLE32(head.flags); + if (fread(&mip, sizeof(mip), 1, fp) != 1) { + fclose(fp); + printf("%s: failed to read mipmap header\n", dirent->d_name); + continue; + } + mip.format = B_LITTLE32(mip.format); + fclose(fp); + if (memcmp(head.magic, "Polymost", 8)) { + printf("%s: bad signature\n", dirent->d_name); + continue; + } + else { + char *format; + char flags[4] = "", flagsc = 0; + switch (mip.format) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: format = "RGB DXT1"; break; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: format = "RGBA DXT1"; break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: format = "RGBA DXT3"; break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: format = "RGBA DXT5"; break; + default: format = "Unknown"; break; + } + if (head.flags&1) flags[flagsc++] = '2'; + if (head.flags&2) flags[flagsc++] = 'A'; + if (head.flags&4) flags[flagsc++] = 'L'; + flags[flagsc++] = 0; + + printf("%s: flags=%s format=%s\n", dirent->d_name, flags, format); + } + } + closedir(dir); + + return 0; +} \ No newline at end of file diff --git a/polymer/build/src/util/generateicon.c b/polymer/build/src/util/generateicon.c new file mode 100644 index 000000000..c9d2341ea --- /dev/null +++ b/polymer/build/src/util/generateicon.c @@ -0,0 +1,110 @@ +#include "kplib.h" +#include "compat.h" + +struct icon { + int width,height; + unsigned int *pixels; + unsigned char *mask; +}; + +int writeicon(FILE *fp, struct icon *ico) +{ + int i; + + fprintf(fp, + "#include \"sdlayer.h\"\n" + "\n" + ); + fprintf(fp,"static unsigned int sdlappicon_pixels[] = {\n"); + for (i=0;iwidth*ico->height;i++) { + if ((i%6) == 0) fprintf(fp,"\t"); + else fprintf(fp," "); + fprintf(fp, "0x%08x,", B_LITTLE32(ico->pixels[i])); + if ((i%6) == 5) fprintf(fp,"\n"); + } + if ((i%16) > 0) fprintf(fp, "\n"); + fprintf(fp, "};\n\n"); + + fprintf(fp,"static unsigned char sdlappicon_mask[] = {\n"); + for (i=0;i<((ico->width+7)/8)*ico->height;i++) { + if ((i%14) == 0) fprintf(fp,"\t"); + else fprintf(fp," "); + fprintf(fp, "%3d,", ico->mask[i]); + if ((i%14) == 13) fprintf(fp,"\n"); + } + if ((i%16) > 0) fprintf(fp, "\n"); + fprintf(fp, "};\n\n"); + + fprintf(fp, + "struct sdlappicon sdlappicon = {\n" + " %d,%d, // width,height\n" + " sdlappicon_pixels,\n" + " sdlappicon_mask\n" + "};\n", + ico->width, ico->height + ); + + return 0; +} + +int main(int argc, char **argv) +{ + struct icon icon; + long bpl, xsiz, ysiz; + long i,j,k,c; + unsigned char *mask, *maskp, bm, *pp; + + if (argc<2) { + fprintf(stderr, "generateicon \n"); + return 1; + } + + memset(&icon, 0, sizeof(icon)); + + kpzload(argv[1], (long*)&icon.pixels, &bpl, (long*)&icon.width, (long*)&icon.height); + if (!icon.pixels) { + fprintf(stderr, "Failure loading %s\n", argv[1]); + return 1; + } + + if (bpl != icon.width * 4) { + fprintf(stderr, "bpl != icon.width * 4\n"); + free(icon.pixels); + return 1; + } + + icon.mask = (unsigned char *)calloc(icon.height, (icon.width+7)/8); + if (!icon.mask) { + fprintf(stderr, "Out of memory\n"); + free(icon.pixels); + return 1; + } + + maskp = icon.mask; + bm = 1; + pp = (unsigned char *)icon.pixels; + for (i=0; i 0) *maskp |= bm; + + bm <<= 1; + pp += 4; + } + + writeicon(stdout, &icon); + + free(icon.pixels); + free(icon.mask); + + return 0; +} + diff --git a/polymer/build/src/util/kextract.c b/polymer/build/src/util/kextract.c new file mode 100644 index 000000000..5558fd823 --- /dev/null +++ b/polymer/build/src/util/kextract.c @@ -0,0 +1,148 @@ +// "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) + +#include "compat.h" + +#define MAXFILES 4096 + +static char buf[65536]; + +static long numfiles, anyfiles4extraction; +static char marked4extraction[MAXFILES]; +static char filelist[MAXFILES][16]; +static long fileoffs[MAXFILES+1], fileleng[MAXFILES]; + +void findfiles(const char *dafilespec) +{ + char t[13]; + int i; + + for(i=numfiles-1;i>=0;i--) + { + memcpy(t,filelist[i],12); + t[12] = 0; + + if (Bwildmatch(t,dafilespec)) { + marked4extraction[i] = 1; + anyfiles4extraction = 1; + } + } +} + +int main(int argc, char **argv) +{ + long i, j, k, l, fil, fil2; + + if (argc < 3) + { + printf("KEXTRACT [grouped file][@file or filespec...] by Kenneth Silverman\n"); + printf(" This program extracts files from a previously grouped group file.\n"); + printf(" You can extract files using the ? and * wildcards.\n"); + printf(" Ex: kextract stuff.dat tiles000.art nukeland.map palette.dat\n"); + printf(" (stuff.dat is the group file, the rest are the files to extract)\n"); + return(0); + } + + if ((fil = Bopen(argv[1],BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) + { + printf("Error: %s could not be opened\n",argv[1]); + return(0); + } + + Bread(fil,buf,16); + if ((buf[0] != 'K') || (buf[1] != 'e') || (buf[2] != 'n') || + (buf[3] != 'S') || (buf[4] != 'i') || (buf[5] != 'l') || + (buf[6] != 'v') || (buf[7] != 'e') || (buf[8] != 'r') || + (buf[9] != 'm') || (buf[10] != 'a') || (buf[11] != 'n')) + { + Bclose(fil); + printf("Error: %s not a valid group file\n",argv[1]); + return(0); + } + numfiles = *((long*)&buf[12]); numfiles = B_LITTLE32(numfiles); + + Bread(fil,filelist,numfiles<<4); + + j = 0; + for(i=0;i1;i--) + { + if (argv[i][0] == '@') + { + if ((fil2 = Bopen(&argv[i][1],BO_BINARY|BO_RDONLY,BS_IREAD)) != -1) + { + l = Bread(fil2,buf,65536); + j = 0; + while ((j < l) && (buf[j] <= 32)) j++; + while (j < l) + { + k = j; + while ((k < l) && (buf[k] > 32)) k++; + + buf[k] = 0; + findfiles(&buf[j]); + j = k+1; + + while ((j < l) && (buf[j] <= 32)) j++; + } + Bclose(fil2); + } + } + else + findfiles(argv[i]); + } + + if (anyfiles4extraction == 0) + { + Bclose(fil); + printf("No files found in group file with those names\n"); + return(0); + } + + for(i=0;imode & BS_IFDIR) return 0; // is a directory + if (a->namlen > 12) return 0; // name too long + return Bwildmatch(a->name, matchstr); +} + +long filesize(const char *path, const char *name) +{ + char p[BMAX_PATH]; + struct stat st; + + strcpy(p, path); + strcat(p, "/"); + strcat(p, name); + + if (!stat(p, &st)) return st.st_size; + return 0; +} + +void findfiles(const char *dafilespec) +{ + struct Bdirent *name; + long daspeclen; + char daspec[128], *dir; + BDIR *di; + + strcpy(daspec,dafilespec); + daspeclen=strlen(daspec); + while ((daspec[daspeclen] != '\\') && (daspec[daspeclen] != '/') && (daspeclen > 0)) daspeclen--; + if (daspeclen > 0) { + daspec[daspeclen]=0; + dir = daspec; + matchstr = &daspec[daspeclen+1]; + } else { + dir = "."; + matchstr = daspec; + } + + di = Bopendir(dir); + if (!di) return; + + while ((name = Breaddir(di))) { + if (!checkmatch(name)) continue; + + strcpy(&filelist[numfiles][0],name->name); + jstrupr(&filelist[numfiles][0]); + fileleng[numfiles] = name->size; + filelist[numfiles][12] = (char)(fileleng[numfiles]&255); + filelist[numfiles][13] = (char)((fileleng[numfiles]>>8)&255); + filelist[numfiles][14] = (char)((fileleng[numfiles]>>16)&255); + filelist[numfiles][15] = (char)((fileleng[numfiles]>>24)&255); + + strcpy(filespec[numfiles],dir); + strcat(filespec[numfiles], "/"); + strcat(filespec[numfiles],name->name); + + numfiles++; + if (numfiles > MAXFILES) + { + printf("FATAL ERROR: TOO MANY FILES SELECTED! (MAX is 4096)\n"); + exit(0); + } + } + + Bclosedir(di); +} + +int main(int argc, char **argv) +{ + long i, j, k, l, fil, fil2; + + if (argc < 3) + { + printf("KGROUP [grouped file][@file or filespec...] by Kenneth Silverman\n"); + printf(" This program collects many files into 1 big uncompressed file called a\n"); + printf(" group file\n"); + printf(" Ex: kgroup stuff.dat *.art *.map *.k?? palette.dat tables.dat\n"); + printf(" (stuff.dat is the group file, the rest are the files to add)\n"); + exit(0); + } + + numfiles = 0; + for(i=argc-1;i>1;i--) + { + if (argv[i][0] == '@') + { + if ((fil = Bopen(&argv[i][1],BO_BINARY|BO_RDONLY,BS_IREAD)) != -1) + { + l = Bread(fil,buf,65536); + j = 0; + while ((j < l) && (buf[j] <= 32)) j++; + while (j < l) + { + k = j; + while ((k < l) && (buf[k] > 32)) k++; + + buf[k] = 0; + findfiles(&buf[j]); + j = k+1; + + while ((j < l) && (buf[j] <= 32)) j++; + } + Bclose(fil); + } + } + else + findfiles(argv[i]); + } + + if ((fil = Bopen(argv[1],BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) + { + printf("Error: %s could not be opened\n",argv[1]); + exit(0); + } + Bwrite(fil,"KenSilverman",12); + Bwrite(fil,&numfiles,4); + Bwrite(fil,filelist,numfiles<<4); + + for(i=0;i +#include +#include + +typedef struct { float x, y, z; } point3d; + +typedef struct +{ long id, vers, skinxsiz, skinysiz, framebytes; //id:"IPD2", vers:8 + long numskins, numverts, numuv, numtris, numglcmds, numframes; + long ofsskins, ofsuv, ofstris, ofsframes, ofsglcmds, ofseof; //ofsskins: skin names (64 bytes each) +} md2typ; + +typedef struct { point3d mul, add; } frametyp; + +int main (int argc, char **argv) +{ + FILE *fil; + long i, leng; + char *fbuf; + md2typ *head; + frametyp *fptr; + + if (argc != 4) { puts("KMD2TOOL [MD2 in file] [MD2 out file] [z offset] by Ken Silverman"); return(0); } + if (!stricmp(argv[1],argv[2])) { puts("input&output filenames can't be same"); return(0); } + + fil = fopen(argv[1],"rb"); if (!fil) { puts("error"); return(0); } + leng = filelength(_fileno(fil)); + fbuf = (char *)malloc(leng); if (!fbuf) { puts("error"); return(0); } + fread(fbuf,leng,1,fil); + fclose(fil); + + head = (md2typ *)fbuf; + if ((head->id != 0x32504449) && (head->vers != 8)) { free(fbuf); puts("error"); return(0); } //"IDP2" + for(i=0;inumframes;i++) + { + fptr = (frametyp *)&fbuf[head->ofsframes+head->framebytes*i]; + printf("frame %2d scale:%f,%f,%f offs:%f,%f,%f\n",i,fptr->mul.x,fptr->mul.y,fptr->mul.z,fptr->add.x,fptr->add.y,fptr->add.z); + fptr->add.z += atof(argv[3]); + } + + fil = fopen(argv[2],"wb"); if (!fil) { puts("error"); return(0); } + fwrite(fbuf,leng,1,fil); + fclose(fil); + + free(fbuf); + + return(0); +} + +#if 0 +!endif +#endif diff --git a/polymer/build/src/util/transpal.c b/polymer/build/src/util/transpal.c new file mode 100644 index 000000000..f2e5218a6 --- /dev/null +++ b/polymer/build/src/util/transpal.c @@ -0,0 +1,270 @@ +// "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) + +#include "compat.h" +#include "pragmas.h" + +#define MAXPALOOKUPS 256 + +static long numpalookups, transratio; +static char palettefilename[13], origpalookup[MAXPALOOKUPS<<8]; +static char palette[768], palookup[MAXPALOOKUPS<<8], transluc[65536]; +static char closestcol[64][64][64]; + +#define FASTPALGRIDSIZ 8 +static long rdist[129], gdist[129], bdist[129]; +static char colhere[((FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2))>>3]; +static char colhead[(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)*(FASTPALGRIDSIZ+2)]; +static long colnext[256]; +static char coldist[8] = {0,1,2,3,4,3,2,1}; +static long colscan[27]; + + + +char getclosestcol(long r, long g, long b) +{ + long i, j, k, dist, mindist, retcol; + long *rlookup, *glookup, *blookup; + char *ptr; + + if (closestcol[r][g][b] != 255) return(closestcol[r][g][b]); + + j = (r>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(g>>3)*FASTPALGRIDSIZ+(b>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1; + mindist = min(rdist[coldist[r&7]+64+8],gdist[coldist[g&7]+64+8]); + mindist = min(mindist,bdist[coldist[b&7]+64+8]); + mindist++; + + rlookup = (long *)&rdist[64-r]; + glookup = (long *)&gdist[64-g]; + blookup = (long *)&bdist[64-b]; + + retcol = -1; + for(k=26;k>=0;k--) + { + i = colscan[k]+j; if ((colhere[i>>3]&(1<<(i&7))) == 0) continue; + for(i=colhead[i];i>=0;i=colnext[i]) + { + ptr = (char *)&palette[i*3]; + dist = glookup[ptr[1]]; if (dist >= mindist) continue; + dist += rlookup[ptr[0]]; if (dist >= mindist) continue; + dist += blookup[ptr[2]]; if (dist >= mindist) continue; + mindist = dist; retcol = i; + } + } + if (retcol < 0) + { + mindist = 0x7fffffff; + ptr = (char *)&palette[768-3]; + for(i=255;i>=0;i--,ptr-=3) + { + dist = glookup[ptr[1]]; if (dist >= mindist) continue; + dist += rlookup[ptr[0]]; if (dist >= mindist) continue; + dist += blookup[ptr[2]]; if (dist >= mindist) continue; + mindist = dist; retcol = i; + } + } + ptr = (char *)&closestcol[r][g][b]; + *ptr = retcol; + if ((r >= 4) && (ptr[(-2)<<12] == retcol)) ptr[(-3)<<12] = retcol, ptr[(-2)<<12] = retcol, ptr[(-1)<<12] = retcol; + if ((g >= 4) && (ptr[(-2)<<6] == retcol)) ptr[(-3)<<6] = retcol, ptr[(-2)<<6] = retcol, ptr[(-1)<<6] = retcol; + if ((b >= 4) && (ptr[(-2)] == retcol)) ptr[(-3)] = retcol, ptr[(-2)] = retcol, ptr[(-1)] = retcol; + if ((r < 64-4) && (ptr[(2)<<12] == retcol)) ptr[(3)<<12] = retcol, ptr[(2)<<12] = retcol, ptr[(1)<<12] = retcol; + if ((g < 64-4) && (ptr[(2)<<6] == retcol)) ptr[(3)<<6] = retcol, ptr[(2)<<6] = retcol, ptr[(1)<<6] = retcol; + if ((b < 64-4) && (ptr[(2)] == retcol)) ptr[(3)] = retcol, ptr[(2)] = retcol, ptr[(1)] = retcol; + if ((r >= 2) && (ptr[(-1)<<12] == retcol)) ptr[(-1)<<12] = retcol; + if ((g >= 2) && (ptr[(-1)<<6] == retcol)) ptr[(-1)<<6] = retcol; + if ((b >= 2) && (ptr[(-1)] == retcol)) ptr[(-1)] = retcol; + if ((r < 64-2) && (ptr[(1)<<12] == retcol)) ptr[(1)<<12] = retcol; + if ((g < 64-2) && (ptr[(1)<<6] == retcol)) ptr[(1)<<6] = retcol; + if ((b < 64-2) && (ptr[(1)] == retcol)) ptr[(1)] = retcol; + return(retcol); +} + +char getpalookup(char dashade, char dacol) +{ + long r, g, b, t; + char *ptr; + + ptr = (char *)&palette[dacol*3]; + t = divscale16(numpalookups-dashade,numpalookups); + r = ((ptr[0]*t+32768)>>16); + g = ((ptr[1]*t+32768)>>16); + b = ((ptr[2]*t+32768)>>16); + return(getclosestcol(r,g,b)); +} + +char gettrans(char dat1, char dat2, long datransratio) +{ + long r, g, b; + char *ptr, *ptr2; + + ptr = (char *)&palette[dat1*3]; + ptr2 = (char *)&palette[dat2*3]; + r = ptr[0]; r += (((ptr2[0]-r)*datransratio+128)>>8); + g = ptr[1]; g += (((ptr2[1]-g)*datransratio+128)>>8); + b = ptr[2]; b += (((ptr2[2]-b)*datransratio+128)>>8); + return(getclosestcol(r,g,b)); +} + +void initfastcolorlookup(long rscale, long gscale, long bscale) +{ + long i, j, x, y, z; + char *ptr; + + j = 0; + for(i=64;i>=0;i--) + { + //j = (i-64)*(i-64); + rdist[i] = rdist[128-i] = j*rscale; + gdist[i] = gdist[128-i] = j*gscale; + bdist[i] = bdist[128-i] = j*bscale; + j += 129-(i<<1); + } + + clearbufbyte(FP_OFF(colhere),sizeof(colhere),0L); + clearbufbyte(FP_OFF(colhead),sizeof(colhead),0L); + + ptr = (char *)&palette[768-3]; + for(i=255;i>=0;i--,ptr-=3) + { + j = (ptr[0]>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(ptr[1]>>3)*FASTPALGRIDSIZ+(ptr[2]>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1; + if (colhere[j>>3]&(1<<(j&7))) colnext[i] = colhead[j]; else colnext[i] = -1; + colhead[j] = i; + colhere[j>>3] |= (1<<(j&7)); + } + + i = 0; + for(x=-FASTPALGRIDSIZ*FASTPALGRIDSIZ;x<=FASTPALGRIDSIZ*FASTPALGRIDSIZ;x+=FASTPALGRIDSIZ*FASTPALGRIDSIZ) + for(y=-FASTPALGRIDSIZ;y<=FASTPALGRIDSIZ;y+=FASTPALGRIDSIZ) + for(z=-1;z<=1;z++) + colscan[i++] = x+y+z; + i = colscan[13]; colscan[13] = colscan[26]; colscan[26] = i; +} + +int main(int argc, char **argv) +{ + char col, ch; + short orignumpalookups; + long fil, i, j, rscale, gscale, bscale; + char buf[65536]; + + ch = 13; + if (argc>1) { + if (argv[1][0] == '-') { + if (argv[1][1] == 't') { ch = 32; puts("Updating translucency table ONLY"); } + argc--; + argv++; + } + } + + if ((argc != 3) && (argc != 6)) + { + printf("TRANSPAL [-t] [numshades][trans#(0-inv,256-opa)][r][g][b] by Kenneth Silverman\n"); + printf(" Ex #1: transpal 32 170 30 59 11 (I use these values in my BUILD demo)\n"); + printf(" ÀÄÄÁÄÄÁÄÄÄ The RGB scales are optional\n"); + printf(" Ex #2: transpal 64 160\n\n"); + printf("Once tables are generated, the optional -t switch determines what to save:\n"); + printf(" Exclude -t to update both the shade table and transluscent table\n"); + printf(" Include -t to update the transluscent table ONLY\n"); + exit(0); + } + + strcpy(palettefilename,"palette.dat"); + numpalookups = atol(argv[1]); + transratio = atol(argv[2]); + + if (argc == 6) + { + rscale = atol(argv[3]); + gscale = atol(argv[4]); + bscale = atol(argv[5]); + } + else + { + rscale = 30; + gscale = 59; + bscale = 11; + } + + if ((numpalookups < 1) || (numpalookups > 256)) + { printf("Invalid number of shades\n"); exit(0); } + if ((transratio < 0) || (transratio > 256)) + { printf("Invalid transluscent ratio\n"); exit(0); } + + if ((fil = Bopen(palettefilename,BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) + { + printf("%s not found",palettefilename); + return(0); + } + Bread(fil,palette,768); + Bread(fil,&orignumpalookups,2); orignumpalookups = B_LITTLE16(orignumpalookups); + orignumpalookups = min(max(orignumpalookups,1),256); + Bread(fil,origpalookup,(long)orignumpalookups<<8); + Bclose(fil); + + clearbuf(buf,65536>>2,0L); + + initfastcolorlookup(rscale,gscale,bscale); + clearbuf(closestcol,262144>>2,0xffffffff); + + for(i=0;i>2)+buf,(long)col); + drawpixel(((((i<<1)+1)*320+(j+8))>>2)+buf,(long)col); + } + + for(i=0;i<256;i++) + for(j=0;j<6;j++) + { + drawpixel((((j+132+0)*320+(i+8))>>2)+buf,i); + + drawpixel((((i+132+8)*320+(j+0))>>2)+buf,i); + } + + for(i=0;i<256;i++) + for(j=0;j<256;j++) + { + col = gettrans((char)i,(char)j,transratio); + transluc[(i<<8)+j] = col; + + drawpixel((((j+132+8)*320+(i+8))>>2)+buf,(long)col); + } + + if (ch == 13) + { + short s; + if ((fil = Bopen(palettefilename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) + { printf("Couldn't save file %s",palettefilename); return(0); } + Bwrite(fil,palette,768); + s = B_LITTLE16(numpalookups); Bwrite(fil,&s,2); + Bwrite(fil,palookup,numpalookups<<8); + Bwrite(fil,transluc,65536); + Bclose(fil); + printf("Shade table AND transluscent table updated\n"); + } + else if (ch == 32) + { + short s; + if ((fil = Bopen(palettefilename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) + { printf("Couldn't save file %s",palettefilename); return(0); } + Bwrite(fil,palette,768); + s = B_LITTLE16(orignumpalookups); Bwrite(fil,&s,2); + Bwrite(fil,origpalookup,(long)orignumpalookups<<8); + Bwrite(fil,transluc,65536); + Bclose(fil); + printf("Transluscent table updated\n"); + } + else + printf("Palette file wasn't touched\n"); + + return 0; +} + diff --git a/polymer/build/src/util/vgafont.cpp b/polymer/build/src/util/vgafont.cpp new file mode 100644 index 000000000..7da2d093c --- /dev/null +++ b/polymer/build/src/util/vgafont.cpp @@ -0,0 +1,139 @@ +// VGA Font Grabber +// Copyright (c) 1997 Jonathon Fowler +// This is a DOS program originally written with Borland Turbo C++ for DOS 3.1 + + +#include +#include + +void main(void) +{ + int font, width, height, numchars; + struct REGPACK r; + FILE *fp; + + printf("VGA Font Grabber\n" + "Copyright (c) 1997 Jonathon Fowler\n"); + + do { + printf("\nSelect which font to grab:\n" + " 1. 8-by-8 ROM\n" + " 2. 8-by-14 ROM\n" + " 3. 8-by-16 ROM\n" + " 4. 9-by-16 ROM\n" + " 5. 9-by-14 ROM\n" + " 6. Quit\n" + " > "); + scanf("%d",&font); + + switch (font) { + case 1: + printf("Getting 8-by-8 ROM font..."); + + if ((fp = fopen("88vga.dat", "wb")) != NULL) { + width = 8; + height = 8; + numchars = 256; + + r.r_ax = 0x1130; // locate the font (1st half) + r.r_bx = 0x0300; + intr(0x10, &r); + + fwrite(MK_FP(r.r_es, r.r_bp), 1, (8 * 128), fp); + + r.r_ax = 0x1130; // locate the font (2nd half) + r.r_bx = 0x0400; + intr(0x10, &r); + + fwrite(MK_FP(r.r_es, r.r_bp), 1, (8 * 128), fp); + + fclose(fp); + } + + printf("Done\n"); + break; + case 2: + printf("Getting 8-by-14 ROM font..."); + + if ((fp = fopen("814vga.dat", "wb")) != NULL) { + width = 8; + height = 14; + numchars = 256; + + r.r_ax = 0x1130; // locate the font + r.r_bx = 0x0200; + intr(0x10, &r); + + fwrite(MK_FP(r.r_es, r.r_bp), 1, (14 * 256), fp); + + fclose(fp); + } + + printf("Done\n"); + break; + case 3: + printf("Getting 8-by-16 ROM font..."); + + if ((fp = fopen("816vga.dat", "wb")) != NULL) { + width = 8; + height = 16; + numchars = 256; + + r.r_ax = 0x1130; // locate the font + r.r_bx = 0x0600; + intr(0x10, &r); + + fwrite(MK_FP(r.r_es, r.r_bp), 1, (16 * 256), fp); + + fclose(fp); + } + + printf("Done\n"); + break; + case 4: + printf("Getting 9-by-16 ROM font..."); + + if ((fp = fopen("916vga.dat", "wb")) != NULL) { + width = 9; + height = 16; + numchars = 256; + + r.r_ax = 0x1130; // locate the font + r.r_bx = 0x0700; + intr(0x10, &r); + + fwrite(MK_FP(r.r_es, r.r_bp), 1, (16 * 256) *2, fp); + + fclose(fp); + } + + printf("Done\n"); + break; + case 5: + printf("Getting 9-by-14 ROM font..."); + + if ((fp = fopen("914vga.dat", "wb")) != NULL) { + width = 9; + height = 16; + numchars = 256; + + r.r_ax = 0x1130; // locate the font + r.r_bx = 0x0500; + intr(0x10, &r); + + fwrite(MK_FP(r.r_es, r.r_bp), 1, (14 * 256)* 2, fp); + + fclose(fp); + } + + printf("Done\n"); + break; + case 6: + break; + default: + printf("Please try again\n"); + break; + } + } while (font != 6); + +} diff --git a/polymer/build/src/util/wad2art.c b/polymer/build/src/util/wad2art.c new file mode 100644 index 000000000..fd318011e --- /dev/null +++ b/polymer/build/src/util/wad2art.c @@ -0,0 +1,283 @@ +// "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) + +#include "compat.h" +#include "pragmas.h" + +#define MAXWADS 4096 + +static long artversion, localtilestart, localtileend; +static long fil1, fil2; +static char wadata[MAXWADS][8]; +static long wadplc[MAXWADS], wadlen[MAXWADS], numwads; +static long xoffses[1024], ylookup[256], picanm[MAXWADS]; +static short tilesizx[MAXWADS], tilesizy[MAXWADS]; +static char pal[768], palookup[8192]; +static char screen[65536], tempbuf[131072]; + + +void loadwadheader(void) +{ + long i, j; + + Bread(fil1,&tempbuf[0],12); + numwads = ((long)tempbuf[4])+(((long)tempbuf[5])<<8)+(((long)tempbuf[6])<<16)+(((long)tempbuf[7])<<24); + i = ((long)tempbuf[8])+(((long)tempbuf[9])<<8)+(((long)tempbuf[10])<<16)+(((long)tempbuf[11])<<24); + Blseek(fil1,i,BSEEK_SET); + Bread(fil1,&tempbuf[0],numwads*16); + j = 0; + for(i=0;i>= 2; + + i = 0; + while (Bstrncasecmp(wadata[i],"COLORMAP",8) != 0) i++; + Blseek(fil1,wadplc[i],BSEEK_SET); + Bread(fil1,palookup,8192); + + if ((fil3 = Bopen("palette.dat",BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) + { printf("Cannot save palette.dat\n"); exit(0); } + Bwrite(fil3,pal,768); + danumshades = 32; + Bwrite(fil3,&danumshades,2); + Bwrite(fil3,palookup,8192); + Bclose(fil3); +} + +void saveart (short tilenum, short xlen, short ylen) +{ + long i, x, p, pend; + + pend = ylookup[ylen]; + + tilesizx[tilenum] = xlen; + tilesizy[tilenum] = ylen; + i = 0; + for(x=0;x= 10000) buffer[j++] = ((i/10000)%10)+48; + if (i >= 1000) buffer[j++] = ((i/1000)%10)+48; + if (i >= 100) buffer[j++] = ((i/100)%10)+48; + if (i >= 10) buffer[j++] = ((i/10)%10)+48; + buffer[j++] = (i%10)+48; + + buffer[j++] = 13; + buffer[j++] = 10; + Bwrite(fil3,&buffer[0],j); + } + + Bclose(fil3); +} + +void showart (char *part) +{ + char yoff, ylen; + short xsiz, ysiz; + long i, j, z, zx, zzx, x, y, p, pend, junk, curplc; + + curplc = -1; + if ((Bstrncasecmp(part,"L_START",7) == 0) || (Bstrncasecmp(part,"S_START",7) == 0) || (Bstrncasecmp(part,"P_START",7) == 0)) + { + if (Bstrncasecmp(part,"L_START",7) == 0) + z = 462; + else + { + z = 0; + while (Bstrncasecmp(wadata[z],part,7) != 0) z++; + z++; + } + + do + { + if (Bstrncasecmp(wadata[z],"P1_START",8) == 0) z++; + if (Bstrncasecmp(wadata[z],"P1_END",6) == 0) z++; + if (Bstrncasecmp(wadata[z],"P2_START",8) == 0) z++; + if (Bstrncasecmp(wadata[z],"S_START",7) == 0) break; + if (Bstrncasecmp(wadata[z],"S_END",5) == 0) break; + if (Bstrncasecmp(wadata[z],"P_END",5) == 0) break; + + if (curplc != wadplc[z]) Blseek(fil1,wadplc[z],BSEEK_SET); + read(fil1,&tempbuf[0],wadlen[z]); + curplc = wadplc[z]+wadlen[z]; + + xsiz = (long)tempbuf[0]+(((long)tempbuf[1])<<8); + ysiz = (long)tempbuf[2]+(((long)tempbuf[3])<<8); + if ((xsiz <= 0) || (ysiz <= 0) || (xsiz > 320) || (ysiz > 200)) goto skipit; + i = 8; + for(zx=0;zx>2,0xffffffff); + + for(x=0;x> 24) + 4096]; + else c = shlookup[a >> 12]; + a >>= c&0xff; + a = (a&0xffff0000)|(sqrtable[a]); + a >>= ((c&0xff00) >> 8); + + return a; +} + +static inline long msqrtasm(unsigned long c) +{ + unsigned long a,b; + + a = 0x40000000l; + b = 0x20000000l; + do { + if (c >= a) { + c -= a; + a += b*4; + } + a -= b; + a >>= 1; + b >>= 2; + } while (b); + if (c >= a) a++; + a >>= 1; + return a; +} + +static void initksqrt(void) +{ + long i, j, k; + + j = 1; k = 0; + for(i=0;i<4096;i++) + { + if (i >= j) { j <<= 2; k++; } + sqrtable[i] = (unsigned short)(msqrtasm((i<<18)+131072)<<1); + shlookup[i] = (k<<1)+((10-k)<<8); + if (i < 256) shlookup[i+4096] = ((k+6)<<1)+((10-(k+6))<<8); + } +} + + +long inside(long x, long y, short sectnum) +{ + walltype *wal; + long i, x1, y1, x2, y2; + char cnt; + + cnt = 0; + + wal = &wall[sector[sectnum].wallptr]; + for(i=sector[sectnum].wallnum;i>0;i--) + { + y1 = wal->y-y; y2 = wall[wal->point2].y-y; + if ((y1^y2) < 0) + { + x1 = wal->x-x; x2 = wall[wal->point2].x-x; + + if ((x1^x2) < 0) + cnt ^= (x1*y2= 0) + cnt ^= 1; + } + wal++; + } + return(cnt); +} + +long readbyte(void) +{ + if (filpos >= fileng) return(-1); + if ((filpos&16383) == 0) Bread(filhandle,filebuf,16384); + filpos++; + return((long)filebuf[(filpos-1)&16383]); +} + +long readline(void) +{ + long i, ch; + + do + { + do + { + ch = readbyte(); + if (ch < 0) return(0); + } while ((ch == 13) || (ch == 10)); + + i = 0; tempbuf[0] = 0; + while ((ch != 13) && (ch != 10)) + { + if (ch < 0) return(0); + if (ch == ';') + { + do + { + if (ch < 0) return(0); + ch = readbyte(); + } while ((ch != 13) && (ch != 10)); + break; + } + if ((ch == 32) || (ch == 9)) ch = ','; + if ((ch != ',') || (i == 0) || (tempbuf[i-1] != ',')) + { tempbuf[i++] = ch; tempbuf[i] = 0; } + ch = readbyte(); + } + if ((i > 0) && (tempbuf[i-1] == ',')) tempbuf[i-1] = 0; + } while (i <= 0); + return(i); +} + +void parsescript(void) +{ + long i, j, k, l, lasti, breakout, tstart, tend, textnum, frontbackstat; + long spritenumstat, slen; + char ch; + + clearbufbyte(FP_OFF(sectspri),MAXSECTS*8*sizeof(short),0xffffffff); + + if (scriptname[0] == 0) + { + for(i=0;i<4096;i++) texturelookup[i] = i; + return; + } + + if ((filhandle = Bopen(scriptname,BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) + { + printf("Could not find %s\n",scriptname); + exit(0); + } + filpos = 0; fileng = Bfilelength(filhandle); + while (readline() != 0) + { + i = 0; j = 0; lasti = 0; + while (1) + { + if ((tempbuf[i] == ',') || (tempbuf[i] == 0)) + { + if (tempbuf[i] == 0) { breakout = 1; } + else { breakout = 0, tempbuf[i] = 0; } + + if (j == 0) + { + if (tempbuf[lasti] == '[') + { + definemode = 0; + thingtypemode = 0; + texturelookupmode = 0; + tagtypemode = 0; + sectypemode = 0; + } + + if (Bstrcasecmp(&tempbuf[lasti],"#define") == 0) + definemode = 1; + + if (thingtypemode == 1) + { + thingoff[numthings] = thingopnum; + + k = lasti; + while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; + + if (tempbuf[k] == '-') + { + tempbuf[k] = 0; + thingnum[numthings] = atol(&tempbuf[lasti]); + thingnum2[numthings] = atol(&tempbuf[k+1]); + } + else + { + thingnum[numthings] = atol(&tempbuf[lasti]); + thingnum2[numthings] = thingnum[numthings]; + } + + numthings++; + } + else if (Bstrcasecmp(&tempbuf[lasti],"[THINGTYPES]") == 0) + thingtypemode = 1; + + if (texturelookupmode == 1) + { + textnum = 0; + if ((tempbuf[lasti] >= 48) && (tempbuf[lasti] <= 57)) + { + k = lasti; + while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; + + if (tempbuf[k] == '-') + { + tempbuf[k] = 0; + tstart = atol(&tempbuf[lasti]); + tend = atol(&tempbuf[k+1]); + for(k=tstart;k<=tend;k++) + tempshort[textnum++] = k; + } + else + tempshort[textnum++] = atol(&tempbuf[lasti]); + } + else + { + slen = 0; + while (tempbuf[lasti+slen] != 0) + { + ch = tempbuf[lasti+slen]; + if ((ch >= 97) && (ch <= 122)) tempbuf[lasti+slen] -= 32; + slen++; + } + if (slen > 0) + for(k=inumwads-1;k>=0;k--) + if ((iwadata[k][slen] == 0) || (iwadata[k][slen] == 32)) + if ((iwadata[k][slen-1] != 0) && (iwadata[k][slen-1] != 32)) + { + for(l=slen-1;l>=0;l--) + if (tempbuf[lasti+l] != '?') + { + ch = iwadata[k][l]; + if ((ch >= 97) && (ch <= 122)) ch -= 32; + if (tempbuf[lasti+l] != ch) break; + } + if (l < 0) tempshort[textnum++] = k; + } + } + } + else if (Bstrcasecmp(&tempbuf[lasti],"[TEXTURELOOKUPS]") == 0) + texturelookupmode = 1; + + if (tagtypemode == 1) + { + tagoff[numtags] = tagopnum; + + k = lasti; + while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; + + if (tempbuf[k] == '-') + { + tempbuf[k] = 0; + tagnum[numtags] = atol(&tempbuf[lasti]); + tagnum2[numtags] = atol(&tempbuf[k+1]); + } + else + { + tagnum[numtags] = atol(&tempbuf[lasti]); + tagnum2[numtags] = tagnum[numtags]; + } + + numtags++; + } + else if (Bstrcasecmp(&tempbuf[lasti],"[TAGCONVERSIONS]") == 0) + tagtypemode = 1; + + if (sectypemode == 1) + { + secoff[numsecs] = secopnum; + + k = lasti; + while ((tempbuf[k] != 0) && (tempbuf[k] != '-')) k++; + + if (tempbuf[k] == '-') + { + tempbuf[k] = 0; + secnum[numsecs] = atol(&tempbuf[lasti]); + secnum2[numsecs] = atol(&tempbuf[k+1]); + } + else + { + secnum[numsecs] = atol(&tempbuf[lasti]); + secnum2[numsecs] = secnum[numsecs]; + } + numsecs++; + } + else if (Bstrcasecmp(&tempbuf[lasti],"[SECTORCONVERSIONS]") == 0) + sectypemode = 1; + + } + else if (j > 0) + { + if (definemode == 1) + { + defineptr[numdefines] = (char *)(&define[definecnt]); + for(k=lasti;k= 48) && (tempbuf[k+1] <= 57)) + thingval[thingopnum] = atol(&tempbuf[k+1]); + else + { + for(l=0;l= 48) && (tempbuf[lasti] <= 57)) + l = atol(&tempbuf[lasti]); + else + { + for(l=0;l=0;k--) texturelookup[tempshort[k]] = l; + } + + if (tagtypemode == 1) + { + for(k=lasti;k= 48) && (tempbuf[lasti] <= 57)) //1 DIGIT ONLY! + { + spritenumstat = tempbuf[lasti]-48; + lasti++; + } + + if (Bstrcasecmp(&tempbuf[lasti],"sprite.x") == 0) tagfield[tagopnum] = 0; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.y") == 0) tagfield[tagopnum] = 1; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.z") == 0) tagfield[tagopnum] = 2; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.cstat") == 0) tagfield[tagopnum] = 3; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.shade") == 0) tagfield[tagopnum] = 4; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.pal") == 0) tagfield[tagopnum] = 5; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.clipdist") == 0) tagfield[tagopnum] = 6; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xrepeat") == 0) tagfield[tagopnum] = 7; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yrepeat") == 0) tagfield[tagopnum] = 8; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xoffset") == 0) tagfield[tagopnum] = 9; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yoffset") == 0) tagfield[tagopnum] = 10; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.picnum") == 0) tagfield[tagopnum] = 11; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.ang") == 0) tagfield[tagopnum] = 12; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xvel") == 0) tagfield[tagopnum] = 13; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yvel") == 0) tagfield[tagopnum] = 14; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.zvel") == 0) tagfield[tagopnum] = 15; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.owner") == 0) tagfield[tagopnum] = 16; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.sectnum") == 0) tagfield[tagopnum] = 17; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.statnum") == 0) tagfield[tagopnum] = 18; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.lotag") == 0) tagfield[tagopnum] = 19; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.hitag") == 0) tagfield[tagopnum] = 20; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.extra") == 0) tagfield[tagopnum] = 21; + + if (Bstrcasecmp(&tempbuf[lasti],"sector.wallptr") == 0) tagfield[tagopnum] = 32; + if (Bstrcasecmp(&tempbuf[lasti],"sector.wallnum") == 0) tagfield[tagopnum] = 33; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpicnum") == 0) tagfield[tagopnum] = 34; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpicnum") == 0) tagfield[tagopnum] = 35; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingheinum") == 0) tagfield[tagopnum] = 36; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorheinum") == 0) tagfield[tagopnum] = 37; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingz") == 0) tagfield[tagopnum] = 38; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorz") == 0) tagfield[tagopnum] = 39; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingshade") == 0) tagfield[tagopnum] = 40; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorshade") == 0) tagfield[tagopnum] = 41; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingxpanning") == 0) tagfield[tagopnum] = 42; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorxpanning") == 0) tagfield[tagopnum] = 43; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingypanning") == 0) tagfield[tagopnum] = 44; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorypanning") == 0) tagfield[tagopnum] = 45; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingstat") == 0) tagfield[tagopnum] = 46; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorstat") == 0) tagfield[tagopnum] = 47; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpal") == 0) tagfield[tagopnum] = 48; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpal") == 0) tagfield[tagopnum] = 49; + if (Bstrcasecmp(&tempbuf[lasti],"sector.visibility") == 0) tagfield[tagopnum] = 50; + if (Bstrcasecmp(&tempbuf[lasti],"sector.lotag") == 0) tagfield[tagopnum] = 51; + if (Bstrcasecmp(&tempbuf[lasti],"sector.hitag") == 0) tagfield[tagopnum] = 52; + if (Bstrcasecmp(&tempbuf[lasti],"sector.extra") == 0) tagfield[tagopnum] = 53; + + if (Bstrcasecmp(&tempbuf[lasti],"wall.x") == 0) tagfield[tagopnum] = 64; + if (Bstrcasecmp(&tempbuf[lasti],"wall.y") == 0) tagfield[tagopnum] = 65; + if (Bstrcasecmp(&tempbuf[lasti],"wall.point2") == 0) tagfield[tagopnum] = 66; + if (Bstrcasecmp(&tempbuf[lasti],"wall.nextsector") == 0) tagfield[tagopnum] = 67; + if (Bstrcasecmp(&tempbuf[lasti],"wall.nextwall") == 0) tagfield[tagopnum] = 68; + if (Bstrcasecmp(&tempbuf[lasti],"wall.picnum") == 0) tagfield[tagopnum] = 69; + if (Bstrcasecmp(&tempbuf[lasti],"wall.overpicnum") == 0) tagfield[tagopnum] = 70; + if (Bstrcasecmp(&tempbuf[lasti],"wall.shade") == 0) tagfield[tagopnum] = 71; + if (Bstrcasecmp(&tempbuf[lasti],"wall.pal") == 0) tagfield[tagopnum] = 72; + if (Bstrcasecmp(&tempbuf[lasti],"wall.cstat") == 0) tagfield[tagopnum] = 73; + if (Bstrcasecmp(&tempbuf[lasti],"wall.xrepeat") == 0) tagfield[tagopnum] = 74; + if (Bstrcasecmp(&tempbuf[lasti],"wall.yrepeat") == 0) tagfield[tagopnum] = 75; + if (Bstrcasecmp(&tempbuf[lasti],"wall.xpanning") == 0) tagfield[tagopnum] = 76; + if (Bstrcasecmp(&tempbuf[lasti],"wall.ypanning") == 0) tagfield[tagopnum] = 77; + if (Bstrcasecmp(&tempbuf[lasti],"wall.lotag") == 0) tagfield[tagopnum] = 78; + if (Bstrcasecmp(&tempbuf[lasti],"wall.hitag") == 0) tagfield[tagopnum] = 79; + if (Bstrcasecmp(&tempbuf[lasti],"wall.extra") == 0) tagfield[tagopnum] = 80; + + tagfield[tagopnum] += (frontbackstat<<7) + (spritenumstat<<8); + + if ((tempbuf[k+1] >= 48) && (tempbuf[k+1] <= 57)) + tagval[tagopnum] = atol(&tempbuf[k+1]); + else if (Bstrcasecmp("tag",&tempbuf[k+1]) == 0) + tagval[tagopnum] = 0x80000000; + else + { + for(l=0;l= 48) && (tempbuf[lasti] <= 57)) //1 DIGIT ONLY! + { + spritenumstat = tempbuf[lasti]-48; + lasti++; + } + + if (Bstrcasecmp(&tempbuf[lasti],"sprite.x") == 0) secfield[secopnum] = 0; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.y") == 0) secfield[secopnum] = 1; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.z") == 0) secfield[secopnum] = 2; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.cstat") == 0) secfield[secopnum] = 3; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.shade") == 0) secfield[secopnum] = 4; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.pal") == 0) secfield[secopnum] = 5; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.clipdist") == 0) secfield[secopnum] = 6; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xrepeat") == 0) secfield[secopnum] = 7; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yrepeat") == 0) secfield[secopnum] = 8; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xoffset") == 0) secfield[secopnum] = 9; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yoffset") == 0) secfield[secopnum] = 10; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.picnum") == 0) secfield[secopnum] = 11; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.ang") == 0) secfield[secopnum] = 12; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.xvel") == 0) secfield[secopnum] = 13; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.yvel") == 0) secfield[secopnum] = 14; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.zvel") == 0) secfield[secopnum] = 15; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.owner") == 0) secfield[secopnum] = 16; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.sectnum") == 0) secfield[secopnum] = 17; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.statnum") == 0) secfield[secopnum] = 18; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.lotag") == 0) secfield[secopnum] = 19; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.hitag") == 0) secfield[secopnum] = 20; + if (Bstrcasecmp(&tempbuf[lasti],"sprite.extra") == 0) secfield[secopnum] = 21; + + if (Bstrcasecmp(&tempbuf[lasti],"sector.wallptr") == 0) secfield[secopnum] = 32; + if (Bstrcasecmp(&tempbuf[lasti],"sector.wallnum") == 0) secfield[secopnum] = 33; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpicnum") == 0) secfield[secopnum] = 34; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpicnum") == 0) secfield[secopnum] = 35; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingheinum") == 0) secfield[secopnum] = 36; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorheinum") == 0) secfield[secopnum] = 37; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingz") == 0) secfield[secopnum] = 38; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorz") == 0) secfield[secopnum] = 39; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingshade") == 0) secfield[secopnum] = 40; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorshade") == 0) secfield[secopnum] = 41; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingxpanning") == 0) secfield[secopnum] = 42; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorxpanning") == 0) secfield[secopnum] = 43; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingypanning") == 0) secfield[secopnum] = 44; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorypanning") == 0) secfield[secopnum] = 45; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingstat") == 0) secfield[secopnum] = 46; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorstat") == 0) secfield[secopnum] = 47; + if (Bstrcasecmp(&tempbuf[lasti],"sector.ceilingpal") == 0) secfield[secopnum] = 48; + if (Bstrcasecmp(&tempbuf[lasti],"sector.floorpal") == 0) secfield[secopnum] = 49; + if (Bstrcasecmp(&tempbuf[lasti],"sector.visibility") == 0) secfield[secopnum] = 50; + if (Bstrcasecmp(&tempbuf[lasti],"sector.lotag") == 0) secfield[secopnum] = 51; + if (Bstrcasecmp(&tempbuf[lasti],"sector.hitag") == 0) secfield[secopnum] = 52; + if (Bstrcasecmp(&tempbuf[lasti],"sector.extra") == 0) secfield[secopnum] = 53; + + secfield[secopnum] += (spritenumstat<<8); + + if ((tempbuf[k+1] >= 48) && (tempbuf[k+1] <= 57)) + secval[secopnum] = atol(&tempbuf[k+1]); + else if (Bstrcasecmp("tag",&tempbuf[k+1]) == 0) + secval[secopnum] = 0x80000000; + else + { + for(l=0;l0;j>>=1) + if (i+j < inumwads) + if (Bstrcasecmp(iwadata[slist[i+j]],nam) <= 0) i += j; + if (Bstrcasecmp(iwadata[slist[i]],nam) == 0) return(slist[i]); + return(-1); +} + +int main(int argc, char **argv) +{ + char argstring[5][80]; + char iwadfil[80], pwadfil[80], doommap[16], buildmap[16], picstr[16]; + long w, numwads, numtexts, startnumtexts, danumtexts, numpnames; + long x, y, z, zz, zzz, zzx, zx, cx, cy, gap, p, pp, i, j, k, l, offs; + long dnumpoints, dnumlines, dnumsides, dnumsectors, dnumthings, good; + long minx, maxx, miny, maxy, numsectors, numwalls, wadtype; + long startnumwalls, l1, l2, startpoint2, dapoint2, area; + long fil, ifil, pfil, x1, y1, x2, y2, startwall, endwall; + long mapversion, posx, posy, posz, templong, cnt, boardwadindex; + short ang, cursectnum; + + printf("Wad2Map! Copyright 1995 by Ken Silverman\n"); + + if ((argc < 3) || (argc > 5)) + { + printf("Command line parameters: Wad2Map (PWADName) IWADName MapName (ScriptName)\n"); + printf(" Ex #1: wad2map c:\\doom\\doom.wad e1m1\n"); + printf(" Ex #2: wad2map c:\\doom\\doom.wad e1m1 kenbuild.txt\n"); + printf(" Ex #3: wad2map c:\\doom\\mypwad.wad c:\\doom\\doom.wad e1m1\n"); + printf(" Ex #4: wad2map c:\\doom\\mypwad.wad c:\\doom\\doom.wad e1m1 kenbuild.txt\n"); + exit(0); + } + + for(i=1;i>1);gap>0;gap>>=1) + for(z=0;z=0;zz-=gap) + { + if (Bstrcasecmp(iwadata[slist[zz]],iwadata[slist[zz+gap]]) <= 0) break; + i = slist[zz]; slist[zz] = slist[zz+gap]; slist[zz+gap] = i; + } + + if (ifil != pfil) + { + Bread(pfil,&pnumwads,4); + Bread(pfil,&pwadstart,4); + Blseek(pfil,pwadstart,SEEK_SET); + for(z=0;z= 0) + { + Blseek(ifil,iwadplc[w],BSEEK_SET); + startnumtexts = numtexts; + Bread(ifil,&danumtexts,4); numtexts += danumtexts; + Bread(ifil,&textoffs[startnumtexts],(numtexts-startnumtexts)*sizeof(long)); + for(z=startnumtexts;z=boardwadindex;w--) + { + Blseek(pfil,pwadplc[w],BSEEK_SET); + + if (Bstrcasecmp(pwadata[w],"VERTEXES") == 0) + { + dnumpoints = (pwadlen[w]>>2); + Bread(pfil,tempbuf,pwadlen[w]); + offs = 0; + for(z=0;z maxx) maxx = x; + if (y < miny) miny = y; + if (y > maxy) maxy = y; + } + cx = (((minx+maxx)>>1)&0xffffffc0); + cy = (((miny+maxy)>>1)&0xffffffc0); + + numwalls = 0; + + for(z=0;z= 0) && (z == side[line[zz].side2].sect)) + { + wx[numwalls] = px[line[zz].p2]; wy[numwalls] = py[line[zz].p2]; + wx2[numwalls] = px[line[zz].p1]; wy2[numwalls] = py[line[zz].p1]; + picindex[numwalls] = line[zz].side2; linindex[numwalls++] = zz; + } + } + + startpoint2 = startnumwalls; + for(zz=startnumwalls;zz 0)) j = 2; + else if ((wx2[zz+1]-x)*(wy2[zzz]-y) > (wy2[zz+1]-y)*(wx2[zzz]-x)) j = 2; + + if (j == 2) + { + i = wx[zz+1]; wx[zz+1] = wx[zzz]; wx[zzz] = i; + i = wy[zz+1]; wy[zz+1] = wy[zzz]; wy[zzz] = i; + i = wx2[zz+1]; wx2[zz+1] = wx2[zzz]; wx2[zzz] = i; + i = wy2[zz+1]; wy2[zz+1] = wy2[zzz]; wy2[zzz] = i; + i = picindex[zz+1]; picindex[zz+1] = picindex[zzz]; picindex[zzz] = i; + i = linindex[zz+1]; linindex[zz+1] = linindex[zzz]; linindex[zzz] = i; + } + } + point2[zz] = zz+1; + } + if (j == 0) point2[zz] = startpoint2, startpoint2 = zz+1; + } + + sector[z].wallptr = startnumwalls; + sector[z].wallnum = numwalls-startnumwalls; + } + + //Collect sectors + for(z=0;z>3); + if ((sector[z].ceilingstat&1) == 0) sector[z].ceilingshade = j; + if ((sector[z].floorstat&1) == 0) sector[z].floorshade = j; + for(i=startwall;i>1);gap>0;gap>>=1) + for(z=0;z=0;zz-=gap) + { + if (wx[slist[zz]] <= wx[slist[zz+gap]]) break; + i = slist[zz]; slist[zz] = slist[zz+gap]; slist[zz+gap] = i; + } + + for(z=0;z>= 1; + if ((zz+zzz < numwalls) && (wx[slist[zz+zzz]] < x2)) zz += zzz; + zzz >>= 1; + } while (zzz > 0); + + do + { + zzx = slist[zz]; + if (wx[zzx] > x2) break; + if (wy[zzx] == y2) + if ((wx[point2[zzx]] == x1) && (wy[point2[zzx]] == y1)) + { + wall[z].nextwall = zzx; + wall[z].nextsector = sectorofwall[zzx]; + break; + } + zz++; + } while (zz < numwalls); + + if (wall[z].nextwall < 0) + { + wall[z].picnum = sidemidpic[picindex[z]]; + wall[z].overpicnum = 0; + } + else + { + wall[z].picnum = sidetoppic[picindex[z]]; + if (wall[z].picnum <= 0) wall[z].picnum = sidebotpic[picindex[z]]; + if ((wall[z].picnum <= 0) && (wall[z].nextwall >= 0)) + { + zx = picindex[wall[z].nextwall]; + wall[z].picnum = sidetoppic[zx]; + if (wall[z].picnum <= 0) wall[z].picnum = sidebotpic[zx]; + } + wall[z].overpicnum = sidemidpic[picindex[z]]; + if (wall[z].overpicnum >= 0) wall[z].cstat |= (1+4+16); + } + wall[z].xrepeat = 8; + wall[z].yrepeat = 8; + wall[z].xpanning = (char)((-side[picindex[z]].xoffset)&255); + wall[z].ypanning = (char)(((side[picindex[z]].yoffset<<1))&255); + + if (line[linindex[z]].flags&1) wall[z].cstat |= 1; + //if (wall[z].nextwall >= 0) wall[z].cstat |= 4; + //if ((line[linindex[z]].flags&24) && (wall[z].nextwall >= 0)) + // wall[z].cstat |= 4; + } + + for(z=0;z= thingnum[i]) && (thing[z].type <= thingnum2[i])) + for(j=thingoff[i];j tagnum2[i])) continue; + + for(j=tagoff[i];j= 0) + if ((tagfield[j]&128) ^ (picindex[zx] == line[z].side1)) + l = wall[zx].nextsector; + + zzz = sectspri[l][(tagfield[j]>>8)&7]; + if (zzz < 0) + { + zzz = dnumthings++; + sectspri[l][(tagfield[j]>>8)&7] = zzz; + zzx = sector[l].wallptr; x1 = wall[zzx].x; y1 = wall[zzx].y; + zzx = wall[zzx].point2; x2 = wall[zzx].x; y2 = wall[zzx].y; + sprite[zzz].x = ((x1+x2)>>1) + ksgn(y1-y2); + sprite[zzz].y = ((y1+y2)>>1) + ksgn(x2-x1); + sprite[zzz].sectnum = l; + sprite[zzz].z = sector[l].floorz; + sprite[zzz].clipdist = 32; + sprite[zzz].xrepeat = 64; + sprite[zzz].yrepeat = 64; + } + + switch(tagop[j]) + { + case 0: setspritefield(zzz,k,zz); break; + case 1: setspritefield(zzz,k,getspritefield(zzz,k)+zz); break; + case 2: setspritefield(zzz,k,getspritefield(zzz,k)-zz); break; + case 3: setspritefield(zzz,k,getspritefield(zzz,k)|zz); break; + case 4: setspritefield(zzz,k,getspritefield(zzz,k)&zz); break; + case 5: setspritefield(zzz,k,getspritefield(zzz,k)^zz); break; + } + } + else if (k < 64) + { + l = sectorofwall[zx]; + if (wall[zx].nextsector >= 0) + if ((tagfield[j]&128) ^ (picindex[zx] == line[z].side1)) + l = wall[zx].nextsector; + + switch(tagop[j]) + { + case 0: setsectorfield(l,k,zz); break; + case 1: setsectorfield(l,k,getsectorfield(l,k)+zz); break; + case 2: setsectorfield(l,k,getsectorfield(l,k)-zz); break; + case 3: setsectorfield(l,k,getsectorfield(l,k)|zz); break; + case 4: setsectorfield(l,k,getsectorfield(l,k)&zz); break; + case 5: setsectorfield(l,k,getsectorfield(l,k)^zz); break; + } + } + else if (k < 96) + { + l = zx; + if (wall[zx].nextwall >= 0) + if ((tagfield[j]&128) ^ (picindex[zx] == line[z].side1)) + l = wall[zx].nextwall; + + switch(tagop[j]) + { + case 0: setwallfield(l,k,zz); break; + case 1: setwallfield(l,k,getwallfield(l,k)+zz); break; + case 2: setwallfield(l,k,getwallfield(l,k)-zz); break; + case 3: setwallfield(l,k,getwallfield(l,k)|zz); break; + case 4: setwallfield(l,k,getwallfield(l,k)&zz); break; + case 5: setwallfield(l,k,getwallfield(l,k)^zz); break; + } + } + } + } + } + + for(l=0;l= secnum[i]) && (sect[l].type <= secnum2[i])) + { + for(j=secoff[i];j>8)&7]; + if (zzz < 0) + { + zzz = dnumthings++; + sectspri[l][(secfield[j]>>8)&7] = zzz; + zzx = sector[l].wallptr; x1 = wall[zzx].x; y1 = wall[zzx].y; + zzx = wall[zzx].point2; x2 = wall[zzx].x; y2 = wall[zzx].y; + sprite[zzz].x = ((x1+x2)>>1) + ksgn(y1-y2); + sprite[zzz].y = ((y1+y2)>>1) + ksgn(x2-x1); + sprite[zzz].sectnum = l; + sprite[zzz].z = sector[l].floorz; + sprite[zzz].clipdist = 32; + sprite[zzz].xrepeat = 64; + sprite[zzz].yrepeat = 64; + } + + switch(secop[j]) + { + case 0: setspritefield(zzz,k,zz); break; + case 1: setspritefield(zzz,k,getspritefield(zzz,k)+zz); break; + case 2: setspritefield(zzz,k,getspritefield(zzz,k)-zz); break; + case 3: setspritefield(zzz,k,getspritefield(zzz,k)|zz); break; + case 4: setspritefield(zzz,k,getspritefield(zzz,k)&zz); break; + case 5: setspritefield(zzz,k,getspritefield(zzz,k)^zz); break; + } + } + else if (k < 64) + { + switch(secop[j]) + { + case 0: setsectorfield(l,k,zz); break; + case 1: setsectorfield(l,k,getsectorfield(l,k)+zz); break; + case 2: setsectorfield(l,k,getsectorfield(l,k)-zz); break; + case 3: setsectorfield(l,k,getsectorfield(l,k)|zz); break; + case 4: setsectorfield(l,k,getsectorfield(l,k)&zz); break; + case 5: setsectorfield(l,k,getsectorfield(l,k)^zz); break; + } + } + } + } + + for(z=0;z= 32768) || (klabs(y) >= 32768)) + wall[z].xrepeat = 255; + else + { + zx = mulscale10(ksqrtasm(x*x+y*y),wall[z].yrepeat); + wall[z].xrepeat = (char)min(max(zx,1),255); + } + + wall[z].picnum = texturelookup[wall[z].picnum]; + wall[z].overpicnum = texturelookup[wall[z].overpicnum]; + } + + mapversion = 7; posx = 0; posy = 0; posz = 0; ang = 1536; cursectnum = 0; + + //WATCH OUT THAT FOR DNUMTHINGS BEING HIGHER THAN NUMBER ON DOOM MAP! + for(i=0;i +#include +#include +#ifndef DIK_PAUSE +# define DIK_PAUSE 0xC5 +#endif +#include + +#include "dxdidf.h" // comment this out if c_dfDI* is being reported as multiply defined +#include +#include +#include +#include + +#if defined(USE_OPENGL) && defined(POLYMOST) +#include "glbuild.h" +#endif + +#include "compat.h" +#include "winlayer.h" +#include "pragmas.h" +#include "build.h" +#include "a.h" +#include "osd.h" + + +// undefine to restrict windowed resolutions to conventional sizes +#define ANY_WINDOWED_SIZE + +int _buildargc = 0; +char **_buildargv = NULL; +static char *argvbuf = NULL; +extern long app_main(long argc, char *argv[]); + +// Windows crud +static HINSTANCE hInstance = 0; +static HWND hWindow = 0; +#define WINDOW_STYLE (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX) +#define WindowClass "buildapp" +static BOOL window_class_registered = FALSE; +static HANDLE instanceflag = NULL; + +static HWND startupdlg = NULL; +static long startupdlgsaferect[4] = { -1,-1,-1,-1 }; +static int startupdlgcommand = 0; +static void (*startupdlgonclose)(void) = NULL; +int backgroundidle = 1; + +static WORD sysgamma[3][256]; +extern long curbrightness, gammabrightness; + +#if defined(USE_OPENGL) && defined(POLYMOST) +// OpenGL stuff +static HGLRC hGLRC = 0; +char nofog=0; +static char nogl=0; +#endif + +static LPTSTR GetWindowsErrorMsg(DWORD code); +static const char * GetDDrawError(HRESULT code); +static const char * GetDInputError(HRESULT code); +static void ShowErrorBox(const char *m); +static void ShowDDrawErrorBox(const char *m, HRESULT r); +static void ShowDInputErrorBox(const char *m, HRESULT r); +static BOOL CheckWinVersion(void); +static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +static BOOL InitDirectDraw(void); +static void UninitDirectDraw(void); +static int RestoreDirectDrawMode(void); +static void ReleaseDirectDrawSurfaces(void); +static BOOL InitDirectInput(void); +static void UninitDirectInput(void); +static void GetKeyNames(void); +static void AcquireInputDevices(char acquire, signed char device); +static void ProcessInputDevices(void); +static int SetupDirectDraw(int width, int height); +static void UninitDIB(void); +static int SetupDIB(int width, int height); +static void ReleaseOpenGL(void); +static void UninitOpenGL(void); +static int SetupOpenGL(int width, int height, int bitspp); +static BOOL RegisterWindowClass(void); +static BOOL CreateAppWindow(int modenum, char *wtitle); +static void DestroyAppWindow(void); +static void SaveSystemColours(void); +static void SetBWSystemColours(void); +static void RestoreSystemColours(void); + + +// video +static long desktopxdim=0,desktopydim=0,desktopbpp=0,modesetusing=-1; +long xres=-1, yres=-1, fullscreen=0, bpp=0, bytesperline=0, imageSize=0; +long frameplace=0, lockcount=0; +static int windowposx, windowposy, curvidmode = -1; +static int customxdim = 640, customydim = 480, custombpp = 8, customfs = 0; +static unsigned modeschecked=0; +unsigned maxrefreshfreq=60; +char modechange=1, repaintneeded=0; +char offscreenrendering=0; +long glcolourdepth=32; +char videomodereset = 0; + +// input and events +char inputdevices=0; +char quitevent=0, appactive=1; +long mousex=0, mousey=0, mouseb=0; +static unsigned long mousewheel[2] = { 0,0 }; +#define MouseWheelFakePressTime (100) // getticks() is a 1000Hz timer, and the button press is faked for 100ms +long *joyaxis = NULL, joyb=0, *joyhat = NULL; +char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0; + +static char taskswitching=1; + +char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend; +unsigned char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; +static unsigned char keynames[256][24]; +static unsigned long lastKeyDown = 0; +static unsigned long lastKeyTime = 0; + +void (*keypresscallback)(long,long) = 0; +void (*mousepresscallback)(long,long) = 0; +void (*joypresscallback)(long,long) = 0; + + + + +//------------------------------------------------------------------------------------------------- +// MAIN CRAP +//================================================================================================= + + +// +// win_gethwnd() -- gets the window handle +// +long win_gethwnd(void) +{ + return (long)hWindow; +} + + +// +// win_gethinstance() -- gets the application instance +// +long win_gethinstance(void) +{ + return (long)hInstance; +} + + +// +// win_allowtaskswitching() -- captures/releases alt+tab hotkeys +// +void win_allowtaskswitching(int onf) +{ + if (onf == taskswitching) return; + + if (onf) { + UnregisterHotKey(0,0); + UnregisterHotKey(0,1); + } else { + RegisterHotKey(0,0,MOD_ALT,VK_TAB); + RegisterHotKey(0,1,MOD_ALT|MOD_SHIFT,VK_TAB); + } + + taskswitching = onf; +} + + +// +// win_checkinstance() -- looks for another instance of a Build app +// +int win_checkinstance(void) +{ + if (!instanceflag) return 0; + return (WaitForSingleObject(instanceflag,0) == WAIT_TIMEOUT); +} + + +// +// wm_msgbox/wm_ynbox() -- window-manager-provided message boxes +// +int wm_msgbox(char *name, char *fmt, ...) +{ + char buf[1000]; + va_list va; + + va_start(va,fmt); + vsprintf(buf,fmt,va); + va_end(va); + + MessageBox(hWindow,buf,name,MB_OK|MB_TASKMODAL); + return 0; +} +int wm_ynbox(char *name, char *fmt, ...) +{ + char buf[1000]; + va_list va; + int r; + + va_start(va,fmt); + vsprintf(buf,fmt,va); + va_end(va); + + r = MessageBox((HWND)win_gethwnd(),buf,name,MB_YESNO|MB_TASKMODAL); + if (r==IDYES) return 1; + return 0; +} + +// +// wm_setapptitle() -- changes the window title +// +void wm_setapptitle(char *name) +{ + if (name) { + Bstrncpy(apptitle, name, sizeof(apptitle)-1); + apptitle[ sizeof(apptitle)-1 ] = 0; + } + + if (hWindow) SetWindowText(hWindow, apptitle); + if (startupdlg) { + char buf[1000]; + Bsnprintf(buf, 1000, "%s Startup", apptitle); + SetWindowText(startupdlg, buf); + } +} + +// +// SignalHandler() -- called when we've sprung a leak +// +static void SignalHandler(int signum) +{ + switch (signum) { + case SIGSEGV: + printOSD("Fatal Signal caught: SIGSEGV. Bailing out.\n"); + uninitsystem(); + if (stdout) fclose(stdout); + break; + default: + break; + } +} + + +// +// startup_dlgproc() -- dialog procedure for the initialisation dialog +// +#define FIELDSWIDE 366 +#define PADWIDE 5 // 5 units of padding +// An overlayed child dialog should have the DS_CONTROL style + +static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static HBITMAP hbmp = NULL; + RECT rdlg, rbmp, rtxt; + HDC hdc; + int height=5; + + switch (uMsg) { + case WM_INITDIALOG: + // set the bitmap + hbmp = LoadBitmap(hInstance, MAKEINTRESOURCE(WIN_STARTWINBMP)); + SendDlgItemMessage(hwndDlg, WIN_STARTWIN_ITEMBITMAP, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); + + // fetch the adjusted size + GetClientRect(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMBITMAP), &rbmp); + rbmp.right++; rbmp.bottom++; + + GetClientRect(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMTEXT), &rtxt); + rtxt.bottom++; + + // move the bitmap to the top of the client area + MoveWindow(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMBITMAP), + 0,0, rbmp.right,rbmp.bottom, + FALSE); + + // move the label + MoveWindow(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMTEXT), + rbmp.right+PADWIDE,PADWIDE, FIELDSWIDE,rtxt.bottom, + FALSE); + + // move the list box + MoveWindow(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMLIST), + rbmp.right+PADWIDE,PADWIDE+rtxt.bottom+PADWIDE, + FIELDSWIDE,rbmp.bottom-(PADWIDE+rtxt.bottom+PADWIDE+PADWIDE), + FALSE); + + SendDlgItemMessage(hwndDlg,WIN_STARTWIN_ITEMLIST, EM_LIMITTEXT, 0,0); + { + RECT rg; + GetWindowRect(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMLIST),&rg); + rg.right -= rg.left + GetSystemMetrics(SM_CXVSCROLL)+4; + rg.bottom -= rg.top; + rg.left = rg.top = 0; + SendDlgItemMessage(hwndDlg,WIN_STARTWIN_ITEMLIST, EM_SETRECTNP,0,(LPARAM)&rg); + } + + rdlg.left = 0; + rdlg.top = 0; + rdlg.right = rbmp.right+PADWIDE+FIELDSWIDE+PADWIDE; + rdlg.bottom = rbmp.bottom; + + AdjustWindowRect(&rdlg, + GetWindowLong(hwndDlg, GWL_STYLE), + FALSE); + + rdlg.right -= rdlg.left; + rdlg.bottom -= rdlg.top; + + hdc = GetDC(NULL); + rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; + rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; + ReleaseDC(NULL, hdc); + + SetWindowPos(hwndDlg,NULL, + rdlg.left,rdlg.top, + rdlg.right,rdlg.bottom, + SWP_NOREPOSITION); + + // save the safe region of the window + startupdlgsaferect[0] = rbmp.right; // left + startupdlgsaferect[1] = 0; // top + startupdlgsaferect[2] = PADWIDE+FIELDSWIDE+PADWIDE; // width + startupdlgsaferect[3] = rbmp.bottom; // height + + return TRUE; + + case WM_CLOSE: + quitevent = 1; + return TRUE; + + case WM_DESTROY: + if (hbmp) { + DeleteObject(hbmp); + hbmp = NULL; + } + + if (startupdlgonclose) startupdlgonclose(); + + startupdlg = NULL; + return TRUE; + + case WM_COMMAND: + startupdlgcommand = LOWORD(wParam); + return FALSE; + + case WM_CTLCOLORSTATIC: + switch (GetDlgCtrlID((HWND)lParam)) { + case WIN_STARTWIN_ITEMLIST: + return (BOOL)GetSysColorBrush(COLOR_WINDOW); + default: break; + } + break; + + default: break; + } + + return FALSE; +} + + +int win_getstartupwin(long *hwnd, long saferect[4], void (*onclose)(void)) +{ + if (!startupdlg) return 1; + + *hwnd = (long)startupdlg; + memcpy(saferect, startupdlgsaferect, sizeof(long)*4); + startupdlgonclose = onclose; + + return 0; +} + +int win_getstartupcommand(void) +{ + int t = startupdlgcommand; + startupdlgcommand = 0; + return t; +} + + +// +// WinMain() -- main Windows entry point +// +int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) +{ + int r; + char *argp; + FILE *fp; + HDC hdc; + + hInstance = hInst; + + if (CheckWinVersion() || hPrevInst) { + MessageBox(0, "This application must be run under Windows 95/98/Me or Windows 2000/XP or better.", + apptitle, MB_OK|MB_ICONSTOP); + return -1; + } + + hdc = GetDC(NULL); + r = GetDeviceCaps(hdc, BITSPIXEL); + ReleaseDC(NULL, hdc); + if (r < 8) { + MessageBox(0, "This application requires a desktop colour depth of 256-colours or more.", + apptitle, MB_OK|MB_ICONSTOP); + return -1; + } + + // carve up the commandline into more recognizable pieces + argvbuf = strdup(GetCommandLine()); + _buildargc = 0; + if (argvbuf) { + char quoted = 0, instring = 0, swallownext = 0; + char *p,*wp; int i; + for (p=wp=argvbuf; *p; p++) { + if (*p == ' ') { + if (instring && !quoted) { + // end of a string + *(wp++) = 0; + instring = 0; + } else if (instring) { + *(wp++) = *p; + } + } else if (*p == '"' && !swallownext) { + if (instring && quoted) { + // end of a string + if (p[1] == ' ') { + *(wp++) = 0; + instring = 0; + quoted = 0; + } else { + quoted = 0; + } + } else if (instring && !quoted) { + quoted = 1; + } else if (!instring) { + instring = 1; + quoted = 1; + _buildargc++; + } + } else if (*p == '\\' && p[1] == '"' && !swallownext) { + swallownext = 1; + } else { + if (!instring) _buildargc++; + instring = 1; + *(wp++) = *p; + swallownext = 0; + } + } + *wp = 0; + + _buildargv = (char**)malloc(sizeof(char*)*_buildargc); + wp = argvbuf; + for (i=0; i<_buildargc; i++,wp++) { + _buildargv[i] = wp; + while (*wp) wp++; + } + } + + // pipe standard outputs to files + if ((argp = Bgetenv("BUILD_LOGSTDOUT")) != NULL) + if (!Bstrcasecmp(argp, "TRUE")) { + fp = freopen("stdout.txt", "w", stdout); + if (!fp) { + fp = fopen("stdout.txt", "w"); + } + if (fp) setvbuf(fp, 0, _IONBF, 0); + *stdout = *fp; + *stderr = *fp; + } + +#if defined(USE_OPENGL) && defined(POLYMOST) + if ((argp = Bgetenv("BUILD_NOFOG")) != NULL) + nofog = Batol(argp); +#endif + + // install signal handlers + signal(SIGSEGV, SignalHandler); + + if (RegisterWindowClass()) return -1; + +#ifdef DISCLAIMER + MessageBox(0, + DISCLAIMER, + "Notice", + MB_OK|MB_ICONINFORMATION); +#endif + + atexit(uninitsystem); + + baselayer_init(); + + instanceflag = CreateSemaphore(NULL, 1,1, WindowClass); + + startupdlg = CreateDialog(hInstance, MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); + + r = app_main(_buildargc, _buildargv); + + fclose(stdout); + + if (instanceflag) CloseHandle(instanceflag); + + if (argvbuf) free(argvbuf); + + return r; +} + + +static int set_maxrefreshfreq(const osdfuncparm_t *parm) +{ + int freq; + if (parm->numparms == 0) { + if (maxrefreshfreq == 0) + OSD_Printf("maxrefreshfreq = No maximum\n"); + else + OSD_Printf("maxrefreshfreq = %d Hz\n",maxrefreshfreq); + return OSDCMD_OK; + } + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + + freq = Batol(parm->parms[0]); + if (freq < 0) return OSDCMD_SHOWHELP; + + maxrefreshfreq = (unsigned)freq; + modeschecked = 0; + + return OSDCMD_OK; +} + +// +// initsystem() -- init systems +// +int initsystem(void) +{ + DEVMODE desktopmode; + + initprintf("Initialising Windows DirectX/GDI system interface\n"); + + // get the desktop dimensions before anything changes them + ZeroMemory(&desktopmode, sizeof(DEVMODE)); + desktopmode.dmSize = sizeof(DEVMODE); + EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&desktopmode); + + desktopxdim = desktopmode.dmPelsWidth; + desktopydim = desktopmode.dmPelsHeight; + desktopbpp = desktopmode.dmBitsPerPel; + + if (desktopbpp <= 8) + // save the system colours + SaveSystemColours(); + + memset(curpalette, 0, sizeof(palette_t) * 256); + + atexit(uninitsystem); + + frameplace=0; + lockcount=0; + +#if defined(USE_OPENGL) && defined(POLYMOST) + if (loadgldriver(getenv("BUILD_GLDRV"))) { + initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n"); + nogl = 1; + } +#endif + + // try and start DirectDraw + if (InitDirectDraw()) + initprintf("DirectDraw initialisation failed. Fullscreen modes will be unavailable.\n"); + + OSD_RegisterFunction("maxrefreshfreq", "maxrefreshfreq: maximum display frequency to set for OpenGL Polymost modes (0=no maximum)", set_maxrefreshfreq); + return 0; +} + + +// +// uninitsystem() -- uninit systems +// +void uninitsystem(void) +{ + DestroyAppWindow(); + + if (startupdlg) { + DestroyWindow(startupdlg); + } + + uninitinput(); + uninittimer(); + + win_allowtaskswitching(1); + +#if defined(USE_OPENGL) && defined(POLYMOST) + unloadgldriver(); +#endif +} + + +// +// initprintf() -- prints a string to the intitialization window +// +void initprintf(const char *f, ...) +{ + va_list va; + char buf[1024],*p=NULL,*q=NULL,workbuf[1024]; + //int i = 0; + + static int newline = 0;//1; +// int overwriteline = -1; + + va_start(va, f); + Bvsnprintf(buf, 1024, f, va); + va_end(va); + OSD_Printf(buf); + if (!startupdlg) return; + + { + int curlen, linesbefore, linesafter; + HWND edctl; + + edctl = GetDlgItem(startupdlg,102); + if (!edctl) return; + + SendMessage(edctl, WM_SETREDRAW, FALSE,0); + curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); + SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); + linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); + p = buf; + while (*p) { + if (newline) { + SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); + newline = 0; + } + q = p; + while (*q && *q != '\n') q++; + memcpy(workbuf, p, q-p); + if (*q == '\n') { + if (!q[1]) { + newline = 1; + workbuf[q-p] = 0; + } else { + workbuf[q-p] = '\r'; + workbuf[q-p+1] = '\n'; + workbuf[q-p+2] = 0; + } + p = q+1; + } else { + workbuf[q-p] = 0; + p = q; + } + SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); + } + linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0); + SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); + SendMessage(edctl, WM_SETREDRAW, TRUE,0); + } + handleevents(); +} + + +// +// debugprintf() -- sends a debug string to the debugger +// +void debugprintf(const char *f, ...) +{ +#ifdef DEBUGGINGAIDS + va_list va; + char buf[1024]; + + if (!IsDebuggerPresent()) return; + + va_start(va,f); + Bvsnprintf(buf, 1024, f, va); + va_end(va); + + OutputDebugString(buf); +#endif +} + + +// +// handleevents() -- process the Windows message queue +// returns !0 if there was an important event worth checking (like quitting) +// +int handleevents(void) +{ + int rv=0; + MSG msg; + + //if (frameplace && fullscreen) printf("Offscreen buffer is locked!\n"); + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + if (msg.message == WM_QUIT) + quitevent = 1; + + if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) continue; + + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + ProcessInputDevices(); + +#ifdef DEBUGGINGAIDS + // break to the debugger if KP- is pressed + if (IsDebuggerPresent() && keystatus[0x4a]) { + keystatus[0x4a] = 0; + DebugBreak(); + } +#endif + + if (!appactive || quitevent) rv = -1; + + sampletimer(); + + return rv; +} + + + + + + + +//------------------------------------------------------------------------------------------------- +// INPUT (MOUSE/KEYBOARD/JOYSTICK?) +//================================================================================================= + +#define KEYBOARD 0 +#define MOUSE 1 +#define JOYSTICK 2 +#define NUM_INPUTS 3 + +static HMODULE hDInputDLL = NULL; +static LPDIRECTINPUTA lpDI = NULL; +static LPDIRECTINPUTDEVICE2A lpDID[NUM_INPUTS] = { NULL, NULL, NULL }; +static BOOL bDInputInited = FALSE; +#define INPUT_BUFFER_SIZE 32 +static GUID guidDevs[NUM_INPUTS]; + +static char devacquired[NUM_INPUTS] = { 0,0,0 }; +static HANDLE inputevt[NUM_INPUTS] = {0,0,0}; +static long joyblast=0; +static char moustat = 0, mousegrab = 0; + +static struct { + char *name; + LPDIRECTINPUTDEVICE2A *did; + const DIDATAFORMAT *df; +} devicedef[NUM_INPUTS] = { + { "keyboard", &lpDID[KEYBOARD], &c_dfDIKeyboard }, + { "mouse", &lpDID[MOUSE], &c_dfDIMouse }, + { "joystick", &lpDID[JOYSTICK], &c_dfDIJoystick } +}; +static struct _joydef { + const char *name; + unsigned ofs; // directinput 'dwOfs' value +} *axisdefs = NULL, *buttondefs = NULL, *hatdefs = NULL; + +struct _joydevicefeature { + unsigned int ofs; + const char *name; +}; +struct _joydevicedefn { + unsigned long devid; // is the value of DIDEVICEINSTANCE.guidProduct.Data1 + int nfeatures; + struct _joydevicefeature *features; +}; + +// This is to give more realistic names to the buttons, axes, etc on a controller than +// those the driver reports. Curse inconsistency. +struct _joydevicefeature joyfeatures_C20A046D[] = { // Logitech WingMan RumblePad USB + { 0, "Left Stick X" }, { 4, "Left Stick Y" }, { 8, "Right Stick X" }, + { 20, "Right Stick Y" }, { 24, "Throttle" }, +}; +struct _joydevicefeature joyfeatures_C218046D[] = { // Logitech RumblePad 2 USB + { 0, "Left Stick X" }, { 4, "Left Stick Y" }, { 8, "Right Stick X" }, + { 20, "Right Stick Y" }, { 32, "D-Pad" }, { 48, "Button 1" }, + { 49, "Button 2" }, { 50, "Button 3" }, { 51, "Button 4" }, + { 52, "Button 5" }, { 53, "Button 6" }, { 54, "Button 7" }, + { 55, "Button 8" }, { 56, "Button 9" }, { 57, "Button 10" }, + { 58, "Left Stick Press" }, { 59, "Right Stick Press" }, +}; +#define featurecount(x) (sizeof(x)/sizeof(struct _joydevicefeature)) +static struct _joydevicedefn *thisjoydef = NULL, joyfeatures[] = { + { 0xC20A046D, featurecount(joyfeatures_C20A046D), joyfeatures_C20A046D }, // Logitech WingMan RumblePad USB + { 0xC218046D, featurecount(joyfeatures_C218046D), joyfeatures_C218046D }, // Logitech RumblePad 2 USB +}; +#undef featurecount + +// I don't see any pressing need to store the key-up events yet +#define SetKey(key,state) { \ + keystatus[key] = state; \ + if (state) { \ + keyfifo[keyfifoend] = key; \ + keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state; \ + keyfifoend = ((keyfifoend+2)&(KEYFIFOSIZ-1)); \ + } \ +} + + +// +// initinput() -- init input system +// +int initinput(void) +{ + moustat=0; + memset(keystatus, 0, sizeof(keystatus)); + keyfifoplc = keyfifoend = 0; + keyasciififoplc = keyasciififoend = 0; + + inputdevices = 0; + joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0; + + if (InitDirectInput()) + return -1; + + return 0; +} + + +// +// uninitinput() -- uninit input system +// +void uninitinput(void) +{ + uninitmouse(); + UninitDirectInput(); +} + + +// +// bgetchar, bkbhit, bflushchars -- character-based input functions +// +unsigned char bgetchar(void) +{ + unsigned char c; + if (keyasciififoplc == keyasciififoend) return 0; + c = keyasciififo[keyasciififoplc]; + keyasciififoplc = ((keyasciififoplc+1)&(KEYFIFOSIZ-1)); + return c; +} + +int bkbhit(void) +{ + return (keyasciififoplc != keyasciififoend); +} + +void bflushchars(void) +{ + keyasciififoplc = keyasciififoend = 0; +} + + +// +// set{key|mouse|joy}presscallback() -- sets a callback which gets notified when keys are pressed +// +void setkeypresscallback(void (*callback)(long, long)) { keypresscallback = callback; } +void setmousepresscallback(void (*callback)(long, long)) { mousepresscallback = callback; } +void setjoypresscallback(void (*callback)(long, long)) { joypresscallback = callback; } + + +// +// initmouse() -- init mouse input +// +int initmouse(void) +{ + if (moustat) return 0; + + initprintf("Initialising mouse\n"); + + // grab input + moustat=1; + grabmouse(1); + + return 0; +} + + +// +// uninitmouse() -- uninit mouse input +// +void uninitmouse(void) +{ + if (!moustat) return; + + grabmouse(0); + moustat=mousegrab=0; +} + + +// +// grabmouse() -- show/hide mouse cursor +// +void grabmouse(char a) +{ + if (!moustat) return; + + mousegrab = a; + AcquireInputDevices(a,MOUSE); // only release or grab the mouse + + mousex = 0; + mousey = 0; + mouseb = 0; +} + + +// +// readmousexy() -- return mouse motion information +// +void readmousexy(long *x, long *y) +{ + if (!moustat || !devacquired[MOUSE] || !mousegrab) { *x = *y = 0; return; } + *x = mousex; + *y = mousey; + mousex = 0; + mousey = 0; +} + + +// +// readmousebstatus() -- return mouse button information +// +void readmousebstatus(long *b) +{ + if (!moustat || !devacquired[MOUSE] || !mousegrab) *b = 0; + else *b = mouseb; +} + + +// +// setjoydeadzone() -- sets the dead and saturation zones for the joystick +// +void setjoydeadzone(int axis, unsigned short dead, unsigned short satur) +{ + DIPROPDWORD dipdw; + HRESULT result; + + if (!lpDID[JOYSTICK]) return; + + if (dead > 10000) dead = 10000; + if (satur > 10000) satur = 10000; + if (dead >= satur) dead = satur-100; + if (axis >= joynumaxes) return; + + memset(&dipdw, 0, sizeof(dipdw)); + dipdw.diph.dwSize = sizeof(DIPROPDWORD); + dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); + if (axis < 0) { + dipdw.diph.dwObj = 0; + dipdw.diph.dwHow = DIPH_DEVICE; + } else { + dipdw.diph.dwObj = axisdefs[axis].ofs; + dipdw.diph.dwHow = DIPH_BYOFFSET; + } + dipdw.dwData = dead; + + result = IDirectInputDevice2_SetProperty(lpDID[JOYSTICK], DIPROP_DEADZONE, &dipdw.diph); + if FAILED(result) { + //ShowDInputErrorBox("Failed setting joystick dead zone", result); + initprintf("Failed setting joystick dead zone: %s\n", GetDInputError(result)); + return; + } + + dipdw.dwData = satur; + + result = IDirectInputDevice2_SetProperty(lpDID[JOYSTICK], DIPROP_SATURATION, &dipdw.diph); + if FAILED(result) { + //ShowDInputErrorBox("Failed setting joystick saturation point", result); + initprintf("Failed setting joystick saturation point: %s\n", GetDInputError(result)); + return; + } +} + + +// +// getjoydeadzone() -- gets the dead and saturation zones for the joystick +// +void getjoydeadzone(int axis, unsigned short *dead, unsigned short *satur) +{ + DIPROPDWORD dipdw; + HRESULT result; + + if (!dead || !satur) return; + if (!lpDID[JOYSTICK]) { *dead = *satur = 0; return; } + if (axis >= joynumaxes) { *dead = *satur = 0; return; } + + memset(&dipdw, 0, sizeof(dipdw)); + dipdw.diph.dwSize = sizeof(DIPROPDWORD); + dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); + if (axis < 0) { + dipdw.diph.dwObj = 0; + dipdw.diph.dwHow = DIPH_DEVICE; + } else { + dipdw.diph.dwObj = axisdefs[axis].ofs; + dipdw.diph.dwHow = DIPH_BYOFFSET; + } + + result = IDirectInputDevice2_GetProperty(lpDID[JOYSTICK], DIPROP_DEADZONE, &dipdw.diph); + if FAILED(result) { + //ShowDInputErrorBox("Failed getting joystick dead zone", result); + initprintf("Failed getting joystick dead zone: %s\n", GetDInputError(result)); + return; + } + + *dead = dipdw.dwData; + + result = IDirectInputDevice2_GetProperty(lpDID[JOYSTICK], DIPROP_SATURATION, &dipdw.diph); + if FAILED(result) { + //ShowDInputErrorBox("Failed getting joystick saturation point", result); + initprintf("Failed getting joystick saturation point: %s\n", GetDInputError(result)); + return; + } + + *satur = dipdw.dwData; +} + + +void releaseallbuttons(void) +{ + int i; + + if (mousepresscallback) { + if (mouseb & 1) mousepresscallback(1, 0); + if (mouseb & 2) mousepresscallback(2, 0); + if (mouseb & 4) mousepresscallback(3, 0); + if (mouseb & 8) mousepresscallback(4, 0); + if (mousewheel[0]>0) mousepresscallback(5,0); + if (mousewheel[1]>0) mousepresscallback(6,0); + } + mousewheel[0]=mousewheel[1]=0; + mouseb = 0; + + if (joypresscallback) { + for (i=0;i<32;i++) + if (joyb & (1<dwDevType&0xff) { + case DIDEVTYPE_KEYBOARD: + inputdevices |= (1<guidInstance); + break; + case DIDEVTYPE_MOUSE: + inputdevices |= (1<guidInstance); + break; + case DIDEVTYPE_JOYSTICK: + inputdevices |= (1<dwDevType & (DIDEVTYPEJOYSTICK_GAMEPAD<<8)) != 0); + d = joyisgamepad ? "GAMEPAD" : "JOYSTICK"; + COPYGUID(guidDevs[JOYSTICK],lpddi->guidInstance); + + thisjoydef = NULL; + for (i=0; i<(int)(sizeof(joyfeatures)/sizeof(joyfeatures[0])); i++) { + if (lpddi->guidProduct.Data1 == joyfeatures[i].devid) { + thisjoydef = &joyfeatures[i]; + break; + } + } + + // Outputs the GUID of the joystick to the console + /* + initprintf("GUID = {%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n", + lpddi->guidProduct.Data1, + lpddi->guidProduct.Data2, lpddi->guidProduct.Data3, + lpddi->guidProduct.Data4[0], lpddi->guidProduct.Data4[1], + lpddi->guidProduct.Data4[2], lpddi->guidProduct.Data4[3], + lpddi->guidProduct.Data4[4], lpddi->guidProduct.Data4[5], + lpddi->guidProduct.Data4[6], lpddi->guidProduct.Data4[7] + ); + */ + break; + default: d = "OTHER"; break; + } + + initprintf(" * %s: %s\n", d, lpddi->tszProductName); + + return DIENUM_CONTINUE; +} + +static const char *joyfindnameforofs(int ofs) +{ + int i; + if (!thisjoydef) return NULL; + for (i=0;infeatures;i++) { + if (ofs == (int)thisjoydef->features[i].ofs) + return Bstrdup(thisjoydef->features[i].name); + } + return NULL; +} + +static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) +{ + unsigned i; + long *typecounts = (long*)pvRef; + + if (lpddoi->dwType & DIDFT_AXIS) { + //initprintf(" Axis: %s (dwOfs=%d)\n", lpddoi->tszName, lpddoi->dwOfs); + + axisdefs[ typecounts[0] ].name = joyfindnameforofs(lpddoi->dwOfs); + if (!axisdefs[ typecounts[0] ].name) + axisdefs[ typecounts[0] ].name = Bstrdup(lpddoi->tszName); + axisdefs[ typecounts[0] ].ofs = lpddoi->dwOfs; + + typecounts[0]++; + } else if (lpddoi->dwType & DIDFT_BUTTON) { + //initprintf(" Button: %s (dwOfs=%d)\n", lpddoi->tszName, lpddoi->dwOfs); + + buttondefs[ typecounts[1] ].name = joyfindnameforofs(lpddoi->dwOfs); + if (!buttondefs[ typecounts[1] ].name) + buttondefs[ typecounts[1] ].name = Bstrdup(lpddoi->tszName); + buttondefs[ typecounts[1] ].ofs = lpddoi->dwOfs; + + typecounts[1]++; + } else if (lpddoi->dwType & DIDFT_POV) { + //initprintf(" POV: %s (dwOfs=%d)\n", lpddoi->tszName, lpddoi->dwOfs); + + hatdefs[ typecounts[2] ].name = joyfindnameforofs(lpddoi->dwOfs); + if (!hatdefs[ typecounts[2] ].name) + hatdefs[ typecounts[2] ].name = Bstrdup(lpddoi->tszName); + hatdefs[ typecounts[2] ].ofs = lpddoi->dwOfs; + + typecounts[2]++; + } + + return DIENUM_CONTINUE; +} + +#define HorribleDInputDeath( x, y ) \ + ShowDInputErrorBox(x,y); \ + UninitDirectInput(); \ + return TRUE + +static BOOL InitDirectInput(void) +{ + HRESULT result; + HRESULT (WINAPI *aDirectInputCreateA)(HINSTANCE, DWORD, LPDIRECTINPUTA *, LPUNKNOWN); + DIPROPDWORD dipdw; + LPDIRECTINPUTDEVICEA dev; + LPDIRECTINPUTDEVICE2A dev2; + DIDEVCAPS didc; + + int devn,i; + + if (bDInputInited) return FALSE; + + initprintf("Initialising DirectInput...\n"); + + // load up the DirectInput DLL + if (!hDInputDLL) { + initprintf(" - Loading DINPUT.DLL\n"); + hDInputDLL = LoadLibrary("DINPUT.DLL"); + if (!hDInputDLL) { + ShowErrorBox("Error loading DINPUT.DLL"); + return TRUE; + } + } + + // get the pointer to DirectInputCreate + aDirectInputCreateA = (void *)GetProcAddress(hDInputDLL, "DirectInputCreateA"); + if (!aDirectInputCreateA) ShowErrorBox("Error fetching DirectInputCreateA()"); + + // create a new DirectInput object + initprintf(" - Creating DirectInput object\n"); + result = aDirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &lpDI, NULL); + if FAILED(result) { HorribleDInputDeath("DirectInputCreateA() failed", result); } + else if (result != DI_OK) initprintf(" Created DirectInput object with warning: %s\n",GetDInputError(result)); + + // enumerate devices to make us look fancy + initprintf(" - Enumerating attached input devices\n"); + inputdevices = 0; + result = IDirectInput_EnumDevices(lpDI, 0, InitDirectInput_enum, NULL, DIEDFL_ATTACHEDONLY); + if FAILED(result) { HorribleDInputDeath("Failed enumerating attached input devices", result); } + else if (result != DI_OK) initprintf(" Enumerated input devices with warning: %s\n",GetDInputError(result)); + if (!(inputdevices & (1<=0; i--) if (axisdefs[i].name) free((void*)axisdefs[i].name); + free(axisdefs); axisdefs = NULL; + } + if (buttondefs) { + for (i=joynumbuttons-1; i>=0; i--) if (buttondefs[i].name) free((void*)buttondefs[i].name); + free(buttondefs); buttondefs = NULL; + } + if (hatdefs) { + for (i=joynumhats-1; i>=0; i--) if (hatdefs[i].name) free((void*)hatdefs[i].name); + free(hatdefs); hatdefs = NULL; + } + + for (devn = 0; devn < NUM_INPUTS; devn++) { + if (*devicedef[devn].did) { + initprintf(" - Releasing %s device\n", devicedef[devn].name); + + if (devn != JOYSTICK) IDirectInputDevice2_SetEventNotification(*devicedef[devn].did, NULL); + + IDirectInputDevice2_Release(*devicedef[devn].did); + *devicedef[devn].did = NULL; + } + if (inputevt[devn]) { + CloseHandle(inputevt[devn]); + inputevt[devn] = NULL; + } + } + + if (lpDI) { + initprintf(" - Releasing DirectInput object\n"); + IDirectInput_Release(lpDI); + lpDI = NULL; + } + + if (hDInputDLL) { + initprintf(" - Unloading DINPUT.DLL\n"); + FreeLibrary(hDInputDLL); + hDInputDLL = NULL; + } + + bDInputInited = FALSE; +} + + +// +// GetKeyNames() -- retrieves the names for all the keys on the keyboard +// +static void GetKeyNames(void) +{ + int i; + DIDEVICEOBJECTINSTANCE key; + HRESULT res; + char tbuf[MAX_PATH]; + + memset(keynames,0,sizeof(keynames)); + for (i=0;i<256;i++) { + ZeroMemory(&key,sizeof(key)); + key.dwSize = sizeof(DIDEVICEOBJECTINSTANCE); + + res = IDirectInputDevice_GetObjectInfo(*devicedef[KEYBOARD].did, &key, i, DIPH_BYOFFSET); + if (FAILED(res)) continue; + + CharToOem(key.tszName, tbuf); + strncpy(keynames[i], tbuf, sizeof(keynames[i])-1); + } +} + +const unsigned char *getkeyname(int num) +{ + if ((unsigned)num >= 256) return NULL; + return keynames[num]; +} + +const unsigned char *getjoyname(int what, int num) +{ + switch (what) { + case 0: // axis + if ((unsigned)num > (unsigned)joynumaxes) return NULL; + return axisdefs[num].name; + + case 1: // button + if ((unsigned)num > (unsigned)joynumbuttons) return NULL; + return buttondefs[num].name; + + case 2: // hat + if ((unsigned)num > (unsigned)joynumhats) return NULL; + return hatdefs[num].name; + + default: + return NULL; + } +} + +// +// AcquireInputDevices() -- (un)acquires the input devices +// +static void AcquireInputDevices(char acquire, signed char device) +{ + DWORD flags; + HRESULT result; + int i; + + if (!bDInputInited) return; + if (!hWindow) return; + + if (acquire) { + if (!appactive) return; // why acquire when inactive? + for (i=0; i 0 && t - mousewheel[0] > MouseWheelFakePressTime) { + if (mousepresscallback) mousepresscallback(5,0); + mousewheel[0] = 0; mouseb &= ~16; + } + if (mousewheel[1] > 0 && t - mousewheel[1] > MouseWheelFakePressTime) { + if (mousepresscallback) mousepresscallback(6,0); + mousewheel[1] = 0; mouseb &= ~32; + } + } + + if (numdevs == 0) return; // nothing to do + + // use event objects so that we can quickly get indication of when data is ready + // to be read and input events processed + ev = MsgWaitForMultipleObjects(numdevs, waithnds, FALSE, 0, 0); + if (/*(ev >= WAIT_OBJECT_0) &&*/ (ev < (WAIT_OBJECT_0+numdevs))) { + switch (idevnums[ev - WAIT_OBJECT_0]) { + case KEYBOARD: // keyboard + if (!lpDID[KEYBOARD]) break; + result = IDirectInputDevice2_GetDeviceData(lpDID[KEYBOARD], sizeof(DIDEVICEOBJECTDATA), + (LPDIDEVICEOBJECTDATA)&didod, &dwElements, 0); + if (result == DI_OK) { + DWORD k, numlockon = FALSE; + static DWORD shiftkey = 0, shiftkeycount = 0; + + numlockon = (GetKeyState(VK_NUMLOCK) & 1); + + // process the key events + for (i=0; i shiftkey=1, shiftkeycount=0\n"); + } + } else { + if ((thiskey == (SHIFT|UP)) && (nextkey == (NUMPAD|DOWN))) { + shiftkeycount--; + initprintf("shift is up and next key is numpad and down, shiftkeycount=%d\n", + shiftkeycount); + continue; + } else if (thiskey & SHIFT) { + if (thiskey & DOWN) { + shiftkeycount++; + initprintf("shift key down, shiftkeycount=%d\n", shiftkeycount); + continue; + } else { + if (shiftkeycount == 0) { + shiftkey = 0; + initprintf("shift key up and shiftkeycount == 0, shiftkey=0\n"); + } else { + shiftkeycount--; + initprintf("shift key up and shiftkeycount=%d\n",shiftkeycount); + continue; + } + } + } + } +#undef NUMPAD +#undef SHIFT +#undef UP +#undef DOWN + } +#endif + + if (k == DIK_PAUSE) continue; // fucking pause + + // hook in the osd + if (OSD_HandleKey(k, (didod[i].dwData & 0x80)) != 0) { + SetKey(k, (didod[i].dwData & 0x80) == 0x80); + + if (keypresscallback) + keypresscallback(k, (didod[i].dwData & 0x80) == 0x80); + } + + if (((lastKeyDown & 0x7fffffffl) == k) && !(didod[i].dwData & 0x80)) + lastKeyDown = 0; + else if (didod[i].dwData & 0x80) { + lastKeyDown = k; + lastKeyTime = t; + } + } + } + break; + + case MOUSE: // mouse + if (!lpDID[MOUSE]) break; + result = IDirectInputDevice2_GetDeviceData(lpDID[MOUSE], sizeof(DIDEVICEOBJECTDATA), + (LPDIDEVICEOBJECTDATA)&didod, &dwElements, 0); + + if (!mousegrab) break; + + if (result == DI_OK) { + // process the mouse events + mousex=0; + mousey=0; + for (i=0; i 0) { // wheel up + if (mousewheel[1] > 0 && mousepresscallback) mousepresscallback(6,0); + mousewheel[1] = t; + mouseb |= 32; if (mousepresscallback) mousepresscallback(6, 1); + } + else if ((int)didod[i].dwData < 0) { // wheel down + if (mousewheel[1] > 0 && mousepresscallback) mousepresscallback(6,0); + mousewheel[0] = t; + mouseb |= 16; if (mousepresscallback) mousepresscallback(5, 1); + } + break; + } + } + } + break; + case JOYSTICK: // joystick + if (!lpDID[JOYSTICK]) break; + result = IDirectInputDevice2_GetDeviceData(lpDID[JOYSTICK], sizeof(DIDEVICEOBJECTDATA), + (LPDIDEVICEOBJECTDATA)&didod, &dwElements, 0); + if (result == DI_OK) { + int j; + + for (i=0; i 0) { + u = (1000 + t - lastKeyTime)%1000; + if ((u >= 250) && !(lastKeyDown&0x80000000l)) { + if (OSD_HandleKey(lastKeyDown, 1) != 0) + SetKey(lastKeyDown, 1); + lastKeyDown |= 0x80000000l; + lastKeyTime = t; + } else if ((u >= 30) && (lastKeyDown&0x80000000l)) { + if (OSD_HandleKey(lastKeyDown&(0x7fffffffl), 1) != 0) + SetKey(lastKeyDown&(0x7fffffffl), 1); + lastKeyTime = t; + } + } +} + + +// +// ShowDInputErrorBox() -- shows an error message box for a DirectInput error +// +static void ShowDInputErrorBox(const char *m, HRESULT r) +{ + TCHAR msg[1024]; + + wsprintf(msg, "%s: %s", m, GetDInputError(r)); + MessageBox(0, msg, apptitle, MB_OK|MB_ICONSTOP); +} + + +// +// GetDInputError() -- stinking huge list of error messages since MS didn't want to include +// them in the DLL +// +static const char * GetDInputError(HRESULT code) +{ + switch (code) { + case DI_OK: return "DI_OK"; + case DI_BUFFEROVERFLOW: return "DI_BUFFEROVERFLOW"; + case DI_DOWNLOADSKIPPED: return "DI_DOWNLOADSKIPPED"; + case DI_EFFECTRESTARTED: return "DI_EFFECTRESTARTED"; + case DI_POLLEDDEVICE: return "DI_POLLEDDEVICE"; + case DI_TRUNCATED: return "DI_TRUNCATED"; + case DI_TRUNCATEDANDRESTARTED: return "DI_TRUNCATEDANDRESTARTED"; + case DIERR_ACQUIRED: return "DIERR_ACQUIRED"; + case DIERR_ALREADYINITIALIZED: return "DIERR_ALREADYINITIALIZED"; + case DIERR_BADDRIVERVER: return "DIERR_BADDRIVERVER"; + case DIERR_BETADIRECTINPUTVERSION: return "DIERR_BETADIRECTINPUTVERSION"; + case DIERR_DEVICEFULL: return "DIERR_DEVICEFULL"; + case DIERR_DEVICENOTREG: return "DIERR_DEVICENOTREG"; + case DIERR_EFFECTPLAYING: return "DIERR_EFFECTPLAYING"; + case DIERR_HASEFFECTS: return "DIERR_HASEFFECTS"; + case DIERR_GENERIC: return "DIERR_GENERIC"; + case DIERR_HANDLEEXISTS: return "DIERR_HANDLEEXISTS"; + case DIERR_INCOMPLETEEFFECT: return "DIERR_INCOMPLETEEFFECT"; + case DIERR_INPUTLOST: return "DIERR_INPUTLOST"; + case DIERR_INVALIDPARAM: return "DIERR_INVALIDPARAM"; + case DIERR_MOREDATA: return "DIERR_MOREDATA"; + case DIERR_NOAGGREGATION: return "DIERR_NOAGGREGATION"; + case DIERR_NOINTERFACE: return "DIERR_NOINTERFACE"; + case DIERR_NOTACQUIRED: return "DIERR_NOTACQUIRED"; + case DIERR_NOTBUFFERED: return "DIERR_NOTBUFFERED"; + case DIERR_NOTDOWNLOADED: return "DIERR_NOTDOWNLOADED"; + case DIERR_NOTEXCLUSIVEACQUIRED: return "DIERR_NOTEXCLUSIVEACQUIRED"; + case DIERR_NOTFOUND: return "DIERR_NOTFOUND"; + case DIERR_NOTINITIALIZED: return "DIERR_NOTINITIALIZED"; + case DIERR_OLDDIRECTINPUTVERSION: return "DIERR_OLDDIRECTINPUTVERSION"; + case DIERR_OUTOFMEMORY: return "DIERR_OUTOFMEMORY"; + case DIERR_UNSUPPORTED: return "DIERR_UNSUPPORTED"; + case E_PENDING: return "E_PENDING"; + default: break; + } + return "Unknown error"; +} + + + + +//------------------------------------------------------------------------------------------------- +// TIMER +//================================================================================================= + +static int64 timerfreq=0; +static long timerlastsample=0; +static int timerticspersec=0; +static void (*usertimercallback)(void) = NULL; + +// This timer stuff is all Ken's idea. + +// +// installusertimercallback() -- set up a callback function to be called when the timer is fired +// +void (*installusertimercallback(void (*callback)(void)))(void) +{ + void (*oldtimercallback)(void); + + oldtimercallback = usertimercallback; + usertimercallback = callback; + + return oldtimercallback; +} + + +// +// inittimer() -- initialise timer +// +int inittimer(int tickspersecond) +{ + int64 t; + + if (timerfreq) return 0; // already installed + + initprintf("Initialising timer\n"); + + // OpenWatcom seems to want us to query the value into a local variable + // instead of the global 'timerfreq' or else it gets pissed with an + // access violation + if (!QueryPerformanceFrequency((LARGE_INTEGER*)&t)) { + ShowErrorBox("Failed fetching timer frequency"); + return -1; + } + timerfreq = t; + timerticspersec = tickspersecond; + QueryPerformanceCounter((LARGE_INTEGER*)&t); + timerlastsample = (long)(t*timerticspersec / timerfreq); + + usertimercallback = NULL; + + return 0; +} + +// +// uninittimer() -- shut down timer +// +void uninittimer(void) +{ + if (!timerfreq) return; + + timerfreq=0; + timerticspersec = 0; +} + +// +// sampletimer() -- update totalclock +// +void sampletimer(void) +{ + int64 i; + long n; + + if (!timerfreq) return; + + QueryPerformanceCounter((LARGE_INTEGER*)&i); + n = (long)(i*timerticspersec / timerfreq) - timerlastsample; + if (n>0) { + totalclock += n; + timerlastsample += n; + } + + if (usertimercallback) for (; n>0; n--) usertimercallback(); +} + + +// +// getticks() -- returns the windows ticks count +// +unsigned long getticks(void) +{ + int64 i; + if (timerfreq == 0) return 0; + QueryPerformanceCounter((LARGE_INTEGER*)&i); + return (unsigned long)(i*longlong(1000)/timerfreq); +} + + +// +// gettimerfreq() -- returns the number of ticks per second the timer is configured to generate +// +int gettimerfreq(void) +{ + return timerticspersec; +} + + + + +//------------------------------------------------------------------------------------------------- +// VIDEO +//================================================================================================= + +// DirectDraw objects +static HMODULE hDDrawDLL = NULL; +static LPDIRECTDRAW lpDD = NULL; +static LPDIRECTDRAWSURFACE lpDDSPrimary = NULL; +static LPDIRECTDRAWSURFACE lpDDSBack = NULL; +static char * lpOffscreen = NULL; +static LPDIRECTDRAWPALETTE lpDDPalette = NULL; +static BOOL bDDrawInited = FALSE; +static DWORD DDdwCaps = 0, DDdwCaps2 = 0; + +// DIB stuff +static HDC hDC = NULL; // opengl shares this +static HDC hDCSection = NULL; +static HBITMAP hDIBSection = NULL; +static HPALETTE hPalette = NULL; +static VOID *lpPixels = NULL; + +#define NUM_SYS_COLOURS 25 +static int syscolouridx[NUM_SYS_COLOURS] = { + COLOR_SCROLLBAR, // 1 + COLOR_BACKGROUND, + COLOR_ACTIVECAPTION, + COLOR_INACTIVECAPTION, + COLOR_MENU, + COLOR_WINDOW, + COLOR_WINDOWFRAME, + COLOR_MENUTEXT, + COLOR_WINDOWTEXT, + COLOR_CAPTIONTEXT, // 10 + COLOR_ACTIVEBORDER, + COLOR_INACTIVEBORDER, + COLOR_APPWORKSPACE, + COLOR_HIGHLIGHT, + COLOR_HIGHLIGHTTEXT, + COLOR_BTNFACE, + COLOR_BTNSHADOW, + COLOR_GRAYTEXT, + COLOR_BTNTEXT, + COLOR_INACTIVECAPTIONTEXT, // 20 + COLOR_BTNHIGHLIGHT, + COLOR_3DDKSHADOW, + COLOR_3DLIGHT, + COLOR_INFOTEXT, + COLOR_INFOBK // 25 +}; +static DWORD syscolours[NUM_SYS_COLOURS]; +static char system_colours_saved = 0, bw_colours_set = 0; + +static int setgammaramp(WORD gt[3][256]); +static int getgammaramp(WORD gt[3][256]); + +// +// checkvideomode() -- makes sure the video mode passed is legal +// +int checkvideomode(int *x, int *y, int c, int fs) +{ + int i, nearest=-1, dx, dy, odx=9999, ody=9999; + + getvalidmodes(); + + // fix up the passed resolution values to be multiples of 8 + // and at least 320x200 or at most MAXXDIMxMAXYDIM + if (*x < 320) *x = 320; + if (*y < 200) *y = 200; + if (*x > MAXXDIM) *x = MAXXDIM; + if (*y > MAXYDIM) *y = MAXYDIM; + *x &= 0xfffffff8l; + + for (i=0; i= 0) gammabrightness = 1; + if (gammabrightness && setgamma(f,f,f) < 0) gammabrightness = 0; + } + + for (i=0;i8); + + return 0; +} + + +// +// getvalidmodes() -- figure out what video modes are available +// +#define ADDMODE(x,y,c,f,n) if (validmodecnt 8) { + for (i=0;i modes[i].freq && maxrefreshfreq > 0) || + (dm.dmDisplayFrequency > modes[i].freq && maxrefreshfreq == 0)) { + if (i==nmodes) nmodes++; + + modes[i].x = dm.dmPelsWidth; + modes[i].y = dm.dmPelsHeight; + modes[i].bpp = dm.dmBitsPerPel; + modes[i].freq = dm.dmDisplayFrequency; + } + } + + j++; + ZeroMemory(&dm,sizeof(DEVMODE)); + dm.dmSize = sizeof(DEVMODE); + } + + for (i=0;iddpfPixelFormat.dwRGBBitCount == 8) { + CHECK(ddsd->dwWidth, ddsd->dwHeight) + ADDMODE(ddsd->dwWidth, ddsd->dwHeight, ddsd->ddpfPixelFormat.dwRGBBitCount, 1,-1); + } + + return(DDENUMRET_OK); +} + +static int sortmodes(const struct validmode_t *a, const struct validmode_t *b) +{ + int x; + + if ((x = a->fs - b->fs) != 0) return x; + if ((x = a->bpp - b->bpp) != 0) return x; + if ((x = a->xdim - b->xdim) != 0) return x; + if ((x = a->ydim - b->ydim) != 0) return x; + + return 0; +} +void getvalidmodes(void) +{ + static int defaultres[][2] = { + {1280,1024},{1280,960},{1152,864},{1024,768},{800,600},{640,480}, + {640,400},{512,384},{480,360},{400,300},{320,240},{320,200},{0,0} + }; + int cdepths[2] = { 8, 0 }; + int i, j, maxx=0, maxy=0; + HRESULT result; + +#if defined(USE_OPENGL) && defined(POLYMOST) + if (desktopbpp > 8) cdepths[1] = desktopbpp; +#endif + + if (modeschecked) return; + + validmodecnt=0; + initprintf("Detecting video modes:\n"); + + if (bDDrawInited) { + // if DirectDraw initialisation didn't fail enumerate fullscreen modes + + result = IDirectDraw_EnumDisplayModes(lpDD, 0, NULL, 0, getvalidmodes_enum); + if (result != DD_OK) { + initprintf("Unable to enumerate fullscreen modes. Using default list.\n"); + for (j=0; j < 2; j++) { + if (cdepths[j] == 0) continue; + for (i=0; defaultres[i][0]; i++) + ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],1,-1) + } + } + } +#if defined(USE_OPENGL) && defined(POLYMOST) + cdsenummodes(); +#endif + + // windowed modes cant be bigger than the current desktop resolution + maxx = desktopxdim-1; + maxy = desktopydim-1; + + // add windowed modes next + for (j=0; j < 2; j++) { + if (cdepths[j] == 0) continue; + for (i=0; defaultres[i][0]; i++) + CHECK(defaultres[i][0],defaultres[i][1]) + ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],0,-1) + } + + qsort((void*)validmode, validmodecnt, sizeof(struct validmode_t), (int(*)(const void*,const void*))sortmodes); + + modeschecked=1; +} + +#undef CHECK +#undef ADDMODE + + +// +// resetvideomode() -- resets the video system +// +void resetvideomode(void) +{ + videomodereset = 1; + modeschecked = 0; +} + + +// +// begindrawing() -- locks the framebuffer for drawing +// +void begindrawing(void) +{ + long i,j; + + if (bpp > 8) { + if (offscreenrendering) return; + frameplace = 0; + bytesperline = 0; + imageSize = 0; + modechange = 0; + return; + } + + if (lockcount++ > 0) + return; // already locked + + if (offscreenrendering) return; + + if (!fullscreen) { + frameplace = (long)lpPixels; + } else { + frameplace = (long)lpOffscreen; + } + + if (!modechange) return; + + if (!fullscreen) { + bytesperline = xres|4; + } else { + bytesperline = xres|1; + } + + imageSize = bytesperline*yres; + setvlinebpl(bytesperline); + + j = 0; + for(i=0;i<=ydim;i++) ylookup[i] = j, j += bytesperline; + modechange=0; +} + + +// +// enddrawing() -- unlocks the framebuffer +// +void enddrawing(void) +{ + if (bpp > 8) { + if (!offscreenrendering) frameplace = 0; + return; + } + + if (!frameplace) return; + if (lockcount > 1) { lockcount--; return; } + if (!offscreenrendering) frameplace = 0; + lockcount = 0; +} + + +// +// showframe() -- update the display +// +void showframe(int w) +{ + HRESULT result; + DDSURFACEDESC ddsd; + char *p,*q; + int i,j; + +#if defined(USE_OPENGL) && defined(POLYMOST) + if (bpp > 8) { + if (palfadedelta) { + bglMatrixMode(GL_PROJECTION); + bglPushMatrix(); + bglLoadIdentity(); + bglMatrixMode(GL_MODELVIEW); + bglPushMatrix(); + bglLoadIdentity(); + + bglDisable(GL_DEPTH_TEST); + bglDisable(GL_ALPHA_TEST); + bglDisable(GL_TEXTURE_2D); + + bglEnable(GL_BLEND); + bglColor4ub(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta); + + bglBegin(GL_QUADS); + bglVertex2i(-1, -1); + bglVertex2i(1, -1); + bglVertex2i(1, 1); + bglVertex2i(-1, 1); + bglEnd(); + + bglMatrixMode(GL_MODELVIEW); + bglPopMatrix(); + bglMatrixMode(GL_PROJECTION); + bglPopMatrix(); + } + + bwglSwapBuffers(hDC); + return; + } +#endif + + w = 1; // wait regardless. ken thinks it's better to do so. + + if (offscreenrendering) return; + + if (lockcount) { + initprintf("Frame still locked %ld times when showframe() called.\n", lockcount); + while (lockcount) enddrawing(); + } + + if (!fullscreen) { + BitBlt(hDC, 0, 0, xres, yres, hDCSection, 0, 0, SRCCOPY); + } else { + if (!w) { + if ((result = IDirectDrawSurface_GetBltStatus(lpDDSBack, DDGBS_CANBLT)) == DDERR_WASSTILLDRAWING) + return; + + if ((result = IDirectDrawSurface_GetFlipStatus(lpDDSPrimary, DDGFS_CANFLIP)) == DDERR_WASSTILLDRAWING) + return; + } + + // lock the backbuffer surface + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + + result = IDirectDrawSurface_Lock(lpDDSBack, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL); + if (result == DDERR_SURFACELOST) { + if (!appactive) + return; // not in a position to restore display anyway + + IDirectDrawSurface_Restore(lpDDSPrimary); + result = IDirectDrawSurface_Lock(lpDDSBack, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL); + } + if (result != DD_OK) { + if (result != DDERR_WASSTILLDRAWING) + initprintf("Failed locking back-buffer surface: %s\n", GetDDrawError(result)); + return; + } + + // copy each scanline + p = (char *)ddsd.lpSurface; + q = (char *)lpOffscreen; + j = xres >> 2; + + for (i=0; i0; i++, n--) { + /* + lpal.palPalEntry[i].peBlue = dapal[0] << 2; + lpal.palPalEntry[i].peGreen = dapal[1] << 2; + lpal.palPalEntry[i].peRed = dapal[2] << 2; + */ + curpalettefaded[i].f = lpal.palPalEntry[i].peFlags = PC_RESERVED | PC_NOCOLLAPSE; + //dapal += 4; + } + + + if (bpp > 8) return 0; // no palette in opengl + + if (!fullscreen) { + if (num > 0) { + rgb = (RGBQUAD *)Bmalloc(sizeof(RGBQUAD)*num); + for (i=start, n=0; n 8) return 0; // only if an 8bit desktop do we do what follows + + // set 0 and 255 to black and white + lpal.palVersion = 0x300; + lpal.palNumEntries = 256; + lpal.palPalEntry[0].peBlue = 0; + lpal.palPalEntry[0].peGreen = 0; + lpal.palPalEntry[0].peRed = 0; + lpal.palPalEntry[0].peFlags = 0; + lpal.palPalEntry[255].peBlue = 255; + lpal.palPalEntry[255].peGreen = 255; + lpal.palPalEntry[255].peRed = 255; + lpal.palPalEntry[255].peFlags = 0; + + if (SetSystemPaletteUse(hDC, SYSPAL_NOSTATIC) == SYSPAL_ERROR) { + initprintf("Problem setting system palette use.\n"); + return -1; + } + + if (hPalette) { + if (num == 0) { start = 0; num = 256; } // refreshing the palette only + SetPaletteEntries(hPalette, start, num, lpal.palPalEntry+start); + } else { + hPalette = CreatePalette((LOGPALETTE *)lpal.palPalEntry); + if (!hPalette) { + initprintf("Problem creating palette.\n"); + return -1; + } + } + + if (SelectPalette(hDC, hPalette, FALSE) == NULL) { + initprintf("Problem selecting palette.\n"); + return -1; + } + + if (RealizePalette(hDC) == GDI_ERROR) { + initprintf("Failure realizing palette.\n"); + return -1; + } + + SetBWSystemColours(); + + } else { + if (!lpDDPalette) return -1; + result = IDirectDrawPalette_SetEntries(lpDDPalette, 0, start, num, (PALETTEENTRY*)&lpal.palPalEntry[start]); + if (result != DD_OK) { + initprintf("Palette set failed: %s\n", GetDDrawError(result)); + return -1; + } + } + + return 0; +} + +// +// getpalette() -- get palette values +// +/* +int getpalette(int start, int num, char *dapal) +{ + int i; + + for (i=num; i>0; i--, start++) { + dapal[0] = curpalette[start].b >> 2; + dapal[1] = curpalette[start].g >> 2; + dapal[2] = curpalette[start].r >> 2; + dapal += 4; + } + + return 0; +}*/ + + +// +// setgamma +// +static int setgammaramp(WORD gt[3][256]) +{ + if (!fullscreen || bpp > 8) { + // GL and windowed mode use DIB method + int i; + HDC hDC = GetDC(hWindow); + i = SetDeviceGammaRamp(hDC, gt) ? 0 : -1; + ReleaseDC(hWindow, hDC); + return i; + } else { + // fullscreen uses DirectX + LPDIRECTDRAWGAMMACONTROL gam; + HRESULT hr; + + if (!(DDdwCaps2 & DDCAPS2_PRIMARYGAMMA)) return -1; + + hr = IDirectDrawSurface_QueryInterface(lpDDSPrimary, &IID_IDirectDrawGammaControl, (LPVOID)&gam); + if (hr != DD_OK) { + ShowDDrawErrorBox("Error querying gamma control", hr); + return -1; + } + + hr = IDirectDrawGammaControl_SetGammaRamp(gam, 0, (LPDDGAMMARAMP)gt); + if (hr != DD_OK) { + IDirectDrawGammaControl_Release(gam); + ShowDDrawErrorBox("Error setting gamma ramp", hr); + return -1; + } + + IDirectDrawGammaControl_Release(gam); + return 0; + } +} + +int setgamma(float ro, float go, float bo) +{ + int i; + WORD gt[3][256]; + + if (!hWindow) return -1; + + ro = 1.0 / ro; go = 1.0 / go; bo = 1.0 / bo; + for (i=0;i<256;i++) { + gt[0][i] = (WORD)min(65535, max(0, (int)(pow((double)i / 256.0, ro) * 65535.0 + 0.5))); + gt[1][i] = (WORD)min(65535, max(0, (int)(pow((double)i / 256.0, go) * 65535.0 + 0.5))); + gt[2][i] = (WORD)min(65535, max(0, (int)(pow((double)i / 256.0, go) * 65535.0 + 0.5))); + } + + return setgammaramp(gt); +} + +static int getgammaramp(WORD gt[3][256]) +{ + if (!hWindow) return -1; + if (!fullscreen || bpp > 8) { + int i; + HDC hDC = GetDC(hWindow); + i = GetDeviceGammaRamp(hDC, gt) ? 0 : -1; + ReleaseDC(hWindow, hDC); + return i; + } else { + LPDIRECTDRAWGAMMACONTROL gam; + HRESULT hr; + + if (!(DDdwCaps2 & DDCAPS2_PRIMARYGAMMA)) return -1; + + hr = IDirectDrawSurface_QueryInterface(lpDDSPrimary, &IID_IDirectDrawGammaControl, (LPVOID)&gam); + if (hr != DD_OK) { + ShowDDrawErrorBox("Error querying gamma control", hr); + return -1; + } + + hr = IDirectDrawGammaControl_GetGammaRamp(gam, 0, (LPDDGAMMARAMP)gt); + if (hr != DD_OK) { + IDirectDrawGammaControl_Release(gam); + ShowDDrawErrorBox("Error getting gamma ramp", hr); + return -1; + } + + IDirectDrawGammaControl_Release(gam); + + return 0; + } +} + +// +// InitDirectDraw() -- get DirectDraw started +// + +// device enumerator +static BOOL WINAPI InitDirectDraw_enum(GUID *lpGUID, LPSTR lpDesc, LPSTR lpName, LPVOID lpContext) +{ + initprintf(" * %s\n", lpDesc); + return 1; +} + +static BOOL InitDirectDraw(void) +{ + HRESULT result; + HRESULT (WINAPI *aDirectDrawCreate)(GUID *, LPDIRECTDRAW *, IUnknown *); + HRESULT (WINAPI *aDirectDrawEnumerate)(LPDDENUMCALLBACK, LPVOID); + DDCAPS ddcaps; + + if (bDDrawInited) return FALSE; + + initprintf("Initialising DirectDraw...\n"); + + // load up the DirectDraw DLL + if (!hDDrawDLL) { + initprintf(" - Loading DDRAW.DLL\n"); + hDDrawDLL = LoadLibrary("DDRAW.DLL"); + if (!hDDrawDLL) { + ShowErrorBox("Error loading DDRAW.DLL"); + return TRUE; + } + } + + // get the pointer to DirectDrawEnumerate + aDirectDrawEnumerate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawEnumerateA"); + if (!aDirectDrawEnumerate) { + ShowErrorBox("Error fetching DirectDrawEnumerate()"); + UninitDirectDraw(); + return TRUE; + } + + // enumerate the devices to make us look fancy + initprintf(" - Enumerating display devices\n"); + aDirectDrawEnumerate(InitDirectDraw_enum, NULL); + + // get the pointer to DirectDrawCreate + aDirectDrawCreate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawCreate"); + if (!aDirectDrawCreate) { + ShowErrorBox("Error fetching DirectDrawCreate()"); + UninitDirectDraw(); + return TRUE; + } + + // create a new DirectDraw object + initprintf(" - Creating DirectDraw object\n"); + result = aDirectDrawCreate(NULL, &lpDD, NULL); + if (result != DD_OK) { + ShowDDrawErrorBox("DirectDrawCreate() failed", result); + UninitDirectDraw(); + return TRUE; + } + + // fetch capabilities + initprintf(" - Checking capabilities\n"); + ddcaps.dwSize = sizeof(DDCAPS); + result = IDirectDraw_GetCaps(lpDD, &ddcaps, NULL); + if (result != DD_OK) { + initprintf(" Unable to get capabilities.\n"); + } else { + DDdwCaps = ddcaps.dwCaps; + DDdwCaps2 = ddcaps.dwCaps2; + } + + bDDrawInited = TRUE; + + return FALSE; +} + + +// +// UninitDirectDraw() -- clean up DirectDraw +// +static void UninitDirectDraw(void) +{ + if (bDDrawInited) initprintf("Uninitialising DirectDraw...\n"); + + ReleaseDirectDrawSurfaces(); + + RestoreDirectDrawMode(); + + if (lpDD) { + initprintf(" - Releasing DirectDraw object\n"); + IDirectDraw_Release(lpDD); + lpDD = NULL; + } + + if (hDDrawDLL) { + initprintf(" - Unloading DDRAW.DLL\n"); + FreeLibrary(hDDrawDLL); + hDDrawDLL = NULL; + } + + bDDrawInited = FALSE; +} + + +// +// RestoreDirectDrawMode() -- resets the screen mode +// +static int RestoreDirectDrawMode(void) +{ + HRESULT result; + + if (fullscreen == 0 || /*bpp > 8 ||*/ !bDDrawInited) return FALSE; + + if (modesetusing == 1) ChangeDisplaySettings(NULL,0); + else if (modesetusing == 0) { + // restore previous display mode and set to normal cooperative level + result = IDirectDraw_RestoreDisplayMode(lpDD); + if (result != DD_OK) { + ShowDDrawErrorBox("Error restoring display mode", result); + UninitDirectDraw(); + return TRUE; + } + + result = IDirectDraw_SetCooperativeLevel(lpDD, hWindow, DDSCL_NORMAL); + if (result != DD_OK) { + ShowDDrawErrorBox("Error setting cooperative level", result); + UninitDirectDraw(); + return TRUE; + } + } + modesetusing = -1; + + return FALSE; +} + + +// +// ReleaseDirectDrawSurfaces() -- release the front and back buffers +// +static void ReleaseDirectDrawSurfaces(void) +{ + if (lpDDPalette) { + initprintf(" - Releasing palette\n"); + IDirectDrawPalette_Release(lpDDPalette); + lpDDPalette = NULL; + } + + if (lpDDSBack) { + initprintf(" - Releasing back-buffer surface\n"); + IDirectDrawSurface_Release(lpDDSBack); + lpDDSBack = NULL; + } + + if (lpDDSPrimary) { + initprintf(" - Releasing primary surface\n"); + IDirectDrawSurface_Release(lpDDSPrimary); + lpDDSPrimary = NULL; + } + + if (lpOffscreen) { + initprintf(" - Freeing offscreen buffer\n"); + free(lpOffscreen); + lpOffscreen = NULL; + } +} + + +// +// SetupDirectDraw() -- sets up DirectDraw rendering +// +static int SetupDirectDraw(int width, int height) +{ + HRESULT result; + DDSURFACEDESC ddsd; + + // now create the DirectDraw surfaces + ZeroMemory(&ddsd, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; + ddsd.dwBackBufferCount = 2; // triple-buffer + + initprintf(" - Creating primary surface\n"); + result = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL); + if (result != DD_OK) { + ShowDDrawErrorBox("Failure creating primary surface", result); + UninitDirectDraw(); + return TRUE; + } + + ZeroMemory(&ddsd.ddsCaps, sizeof(ddsd.ddsCaps)); + ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; + numpages = 1; // KJS 20031225 + + initprintf(" - Getting back buffer\n"); + result = IDirectDrawSurface_GetAttachedSurface(lpDDSPrimary, &ddsd.ddsCaps, &lpDDSBack); + if (result != DD_OK) { + ShowDDrawErrorBox("Failure fetching back-buffer surface", result); + UninitDirectDraw(); + return TRUE; + } + + initprintf(" - Allocating offscreen buffer\n"); + lpOffscreen = (char *)malloc((width|1)*height); + if (!lpOffscreen) { + ShowErrorBox("Failure allocating offscreen buffer"); + UninitDirectDraw(); + return TRUE; + } + + // attach a palette to the primary surface + initprintf(" - Creating palette\n"); + result = IDirectDraw_CreatePalette(lpDD, DDPCAPS_8BIT | DDPCAPS_ALLOW256, (PALETTEENTRY*)curpalette, &lpDDPalette, NULL); + if (result != DD_OK) { + ShowDDrawErrorBox("Failure creating palette", result); + UninitDirectDraw(); + return TRUE; + } + + result = IDirectDrawSurface_SetPalette(lpDDSPrimary, lpDDPalette); + if (result != DD_OK) { + ShowDDrawErrorBox("Failure setting palette", result); + UninitDirectDraw(); + return TRUE; + } + + return FALSE; +} + + +// +// UninitDIB() -- clean up the DIB renderer +// +static void UninitDIB(void) +{ + if (desktopbpp <= 8) + RestoreSystemColours(); + + if (hPalette) { + DeleteObject(hPalette); + hPalette = NULL; + } + + if (hDCSection) { + DeleteDC(hDCSection); + hDCSection = NULL; + } + + if (hDIBSection) { + DeleteObject(hDIBSection); + hDIBSection = NULL; + } + + if (hDC) { + ReleaseDC(hWindow, hDC); + hDC = NULL; + } +} + + +// +// SetupDIB() -- sets up DIB rendering +// +static int SetupDIB(int width, int height) +{ + struct binfo { + BITMAPINFOHEADER header; + RGBQUAD colours[256]; + } dibsect; + int i; + + if (!hDC) { + hDC = GetDC(hWindow); + if (!hDC) { + ShowErrorBox("Error getting device context"); + return TRUE; + } + } + + if (hDCSection) { + DeleteDC(hDCSection); + hDCSection = NULL; + } + + // destroy the previous DIB section if it existed + if (hDIBSection) { + DeleteObject(hDIBSection); + hDIBSection = NULL; + } + + // create the new DIB section + memset(&dibsect, 0, sizeof(dibsect)); + numpages = 1; // KJS 20031225 + dibsect.header.biSize = sizeof(dibsect.header); + dibsect.header.biWidth = width|1; // Ken did this + dibsect.header.biHeight = -height; + dibsect.header.biPlanes = 1; + dibsect.header.biBitCount = 8; + dibsect.header.biCompression = BI_RGB; + dibsect.header.biClrUsed = 256; + dibsect.header.biClrImportant = 256; + for (i=0; i<256; i++) { + dibsect.colours[i].rgbBlue = curpalette[i].b; + dibsect.colours[i].rgbGreen = curpalette[i].g; + dibsect.colours[i].rgbRed = curpalette[i].r; + } + + hDIBSection = CreateDIBSection(hDC, (BITMAPINFO *)&dibsect, DIB_RGB_COLORS, &lpPixels, NULL, 0); + if (!hDIBSection) { + ReleaseDC(hWindow, hDC); + hDC = NULL; + + ShowErrorBox("Error creating DIB section"); + return TRUE; + } + + memset(lpPixels, 0, width*height); + + // create a compatible memory DC + hDCSection = CreateCompatibleDC(hDC); + if (!hDCSection) { + ReleaseDC(hWindow, hDC); + hDC = NULL; + + ShowErrorBox("Error creating compatible DC"); + return TRUE; + } + + // select the DIB section into the memory DC + if (!SelectObject(hDCSection, hDIBSection)) { + ReleaseDC(hWindow, hDC); + hDC = NULL; + DeleteDC(hDCSection); + hDCSection = NULL; + + ShowErrorBox("Error creating compatible DC"); + return TRUE; + } + + return FALSE; +} + +#if defined(USE_OPENGL) && defined(POLYMOST) +// +// ReleaseOpenGL() -- cleans up OpenGL rendering stuff +// + +static HWND hGLWindow = NULL; + +static void ReleaseOpenGL(void) +{ + if (hGLRC) { + polymost_glreset(); + if (!bwglMakeCurrent(0,0)) { } + if (!bwglDeleteContext(hGLRC)) { } + hGLRC = NULL; + } + if (hGLWindow) { + if (hDC) { + ReleaseDC(hGLWindow, hDC); + hDC = NULL; + } + + DestroyWindow(hGLWindow); + hGLWindow = NULL; + } +} + + +// +// UninitOpenGL() -- unitialises any openGL libraries +// +static void UninitOpenGL(void) +{ + ReleaseOpenGL(); +} + + +// +// SetupOpenGL() -- sets up opengl rendering +// +static int SetupOpenGL(int width, int height, int bitspp) +{ + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, //Version Number + PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, //Must Support these + PFD_TYPE_RGBA, //Request An RGBA Format + 0, //Select Our Color Depth + 0,0,0,0,0,0, //Color Bits Ignored + 0, //No Alpha Buffer + 0, //Shift Bit Ignored + 0, //No Accumulation Buffer + 0,0,0,0, //Accumulation Bits Ignored + 32, //16/24/32 Z-Buffer depth + 0, //No Stencil Buffer + 0, //No Auxiliary Buffer + PFD_MAIN_PLANE, //Main Drawing Layer + 0, //Reserved + 0,0,0 //Layer Masks Ignored + }; + GLuint PixelFormat; + int minidriver; + int err; + static int warnonce = 0; + pfd.cColorBits = bitspp; + + hGLWindow = CreateWindow( + WindowClass, + "OpenGL Window", + WS_CHILD|WS_VISIBLE, + 0,0, + width,height, + hWindow, + (HMENU)1, + hInstance, + NULL); + if (!hGLWindow) { + ShowErrorBox("Error creating OpenGL child window."); + return TRUE; + } + + hDC = GetDC(hGLWindow); + if (!hDC) { + ReleaseOpenGL(); + ShowErrorBox("Error getting device context"); + return TRUE; + } + + minidriver = Bstrcasecmp(gldriver,"opengl32.dll"); + + if (minidriver) PixelFormat = bwglChoosePixelFormat(hDC,&pfd); + else PixelFormat = ChoosePixelFormat(hDC,&pfd); + if (!PixelFormat) { + ReleaseOpenGL(); + ShowErrorBox("Can't choose pixel format"); + return TRUE; + } + + if (minidriver) err = bwglSetPixelFormat(hDC, PixelFormat, &pfd); + else err = SetPixelFormat(hDC, PixelFormat, &pfd); + if (!err) { + ReleaseOpenGL(); + ShowErrorBox("Can't set pixel format"); + return TRUE; + } + + hGLRC = bwglCreateContext(hDC); + if (!hGLRC) { + ReleaseOpenGL(); + ShowErrorBox("Can't create GL RC"); + return TRUE; + } + + if (!bwglMakeCurrent(hDC, hGLRC)) { + ReleaseOpenGL(); + ShowErrorBox("Can't activate GL RC"); + return TRUE; + } + + polymost_glreset(); + + bglEnable(GL_TEXTURE_2D); + bglShadeModel(GL_SMOOTH); //GL_FLAT + bglClearColor(0,0,0,0.5); //Black Background + bglHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); //Use FASTEST for ortho! + bglHint(GL_LINE_SMOOTH_HINT,GL_NICEST); + bglHint(GL_TEXTURE_COMPRESSION_HINT, GL_NICEST); + bglDisable(GL_DITHER); + + { + GLubyte *p,*p2,*p3; + int i; + + glinfo.vendor = bglGetString(GL_VENDOR); + glinfo.renderer = bglGetString(GL_RENDERER); + glinfo.version = bglGetString(GL_VERSION); + glinfo.extensions = bglGetString(GL_EXTENSIONS); + + glinfo.maxanisotropy = 1.0; + glinfo.bgra = 0; + glinfo.texcompr = 0; + + // process the extensions string and flag stuff we recognize + p = Bstrdup(glinfo.extensions); + p3 = p; + while ((p2 = Bstrtoken(p3==p?p:NULL, " ", (char**)&p3, 1)) != NULL) { + if (!Bstrcmp(p2, "GL_EXT_texture_filter_anisotropic")) { + // supports anisotropy. get the maximum anisotropy level + bglGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glinfo.maxanisotropy); + } else if (!Bstrcmp(p2, "GL_EXT_texture_edge_clamp") || + !Bstrcmp(p2, "GL_SGIS_texture_edge_clamp")) { + // supports GL_CLAMP_TO_EDGE or GL_CLAMP_TO_EDGE_SGIS + glinfo.clamptoedge = 1; + } else if (!Bstrcmp(p2, "GL_EXT_bgra")) { + // support bgra textures + glinfo.bgra = 1; + } else if (!Bstrcmp(p2, "GL_ARB_texture_compression")) { + // support texture compression + glinfo.texcompr = 1; + } else if (!Bstrcmp(p2, "GL_ARB_texture_non_power_of_two")) { + // support non-power-of-two texture sizes + glinfo.texnpot = 1; + } else if (!Bstrcmp(p2, "WGL_3DFX_gamma_control")) { + // 3dfx cards have issues with fog + nofog = 1; + if (!(warnonce&1)) initprintf("3dfx card detected: OpenGL fog disabled\n"); + warnonce |= 1; + } + } + Bfree(p); + } + numpages = 2; // KJS 20031225: tell rotatesprite that it's double buffered! + + return FALSE; +} +#endif + +// +// CreateAppWindow() -- create the application window +// +static BOOL CreateAppWindow(int modenum, char *wtitle) +{ + RECT rect; + int w, h, x, y, stylebits = 0, stylebitsex = 0; + int width, height, fs, bitspp; + + HRESULT result; + + if (modenum == 0x7fffffff) { + width = customxdim; + height = customydim; + fs = customfs; + bitspp = custombpp; + } else { + width = validmode[modenum].xdim; + height = validmode[modenum].ydim; + fs = validmode[modenum].fs; + bitspp = validmode[modenum].bpp; + } + + if (width == xres && height == yres && fs == fullscreen && bitspp == bpp && !videomodereset) return FALSE; + + if (hWindow) { + if (bpp > 8) { +#if defined(USE_OPENGL) && defined(POLYMOST) + ReleaseOpenGL(); // release opengl +#endif + } else { + ReleaseDirectDrawSurfaces(); // releases directdraw surfaces + } + + if (!fs && fullscreen) { + // restore previous display mode and set to normal cooperative level + RestoreDirectDrawMode(); +#if defined(USE_OPENGL) && defined(POLYMOST) + } else if (fs && fullscreen) { + // using CDS for GL modes, so restore from DirectDraw + if (bpp != bitspp) RestoreDirectDrawMode(); +#endif + } + + + ShowWindow(hWindow, SW_HIDE); // so Windows redraws what's behind if the window shrinks + } + + if (fs) { + stylebitsex = WS_EX_TOPMOST; + stylebits = WS_POPUP; + } else { + stylebitsex = 0; + stylebits = WINDOW_STYLE; + } + + if (!hWindow) { + hWindow = CreateWindowEx( + stylebitsex, + "buildapp", + apptitle, + stylebits, + CW_USEDEFAULT, + CW_USEDEFAULT, + 320, + 200, + NULL, + NULL, + hInstance, + 0); + if (!hWindow) { + ShowErrorBox("Unable to create window"); + return TRUE; + } + + if (startupdlg) { + DestroyWindow(startupdlg); + } + } else { + SetWindowLong(hWindow,GWL_EXSTYLE,stylebitsex); + SetWindowLong(hWindow,GWL_STYLE,stylebits); + } + + // resize the window + if (!fs) { + rect.left = 0; + rect.top = 0; + rect.right = width-1; + rect.bottom = height-1; + AdjustWindowRect(&rect, stylebits, FALSE); + + w = (rect.right - rect.left); + h = (rect.bottom - rect.top); + x = (desktopxdim - w) / 2; + y = (desktopydim - h) / 2; + } else { + x=y=0; + w=width; + h=height; + } + SetWindowPos(hWindow, HWND_TOP, x, y, w, h, 0); + + SetWindowText(hWindow, wtitle); + ShowWindow(hWindow, SW_SHOWNORMAL); + SetForegroundWindow(hWindow); + SetFocus(hWindow); + + // fullscreen? + if (!fs) { + if (bitspp > 8) { +#if defined(USE_OPENGL) && defined(POLYMOST) + // yes, start up opengl + if (SetupOpenGL(width,height,bitspp)) { + return TRUE; + } +#endif + } else { + // no, use DIB section + if (SetupDIB(width,height)) { + return TRUE; + } + } + + modesetusing = -1; + + } else { + // yes, set up DirectDraw + + // clean up after the DIB renderer if it was being used + UninitDIB(); + + if (!bDDrawInited) { + DestroyWindow(hWindow); + hWindow = NULL; + return TRUE; + } + +#if defined(USE_OPENGL) && defined(POLYMOST) + if (bitspp > 8) { + DEVMODE dmScreenSettings; + + ZeroMemory(&dmScreenSettings, sizeof(DEVMODE)); + dmScreenSettings.dmSize = sizeof(DEVMODE); + dmScreenSettings.dmPelsWidth = width; + dmScreenSettings.dmPelsHeight = height; + dmScreenSettings.dmBitsPerPel = bitspp; + dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; + if (modenum != 0x7fffffff) { + dmScreenSettings.dmDisplayFrequency = validmode[modenum].extra; + dmScreenSettings.dmFields |= DM_DISPLAYFREQUENCY; + } + + if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { + ShowErrorBox("Video mode not supported"); + return TRUE; + } + + ShowWindow(hWindow, SW_SHOWNORMAL); + SetForegroundWindow(hWindow); + SetFocus(hWindow); + + modesetusing = 1; + } else +#endif + { + // set exclusive cooperative level + result = IDirectDraw_SetCooperativeLevel(lpDD, hWindow, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN); + if (result != DD_OK) { + ShowDDrawErrorBox("Error setting cooperative level", result); + UninitDirectDraw(); + return TRUE; + } + + result = IDirectDraw_SetDisplayMode(lpDD, width, height, bitspp); + if (result != DD_OK) { + ShowDDrawErrorBox("Error setting display mode", result); + UninitDirectDraw(); + return TRUE; + } + + modesetusing = 0; + } + + if (bitspp > 8) { +#if defined(USE_OPENGL) && defined(POLYMOST) + // we want an opengl mode + if (SetupOpenGL(width,height,bitspp)) { + return TRUE; + } +#endif + } else { + // we want software + if (SetupDirectDraw(width,height)) { + return TRUE; + } + } + } + +#if defined(USE_OPENGL) && defined(POLYMOST) + if (bitspp > 8) loadglextensions(); +#endif + + xres = width; + yres = height; + bpp = bitspp; + fullscreen = fs; + curvidmode = modenum; + + frameplace = 0; + lockcount = 0; + + // bytesperline is set when framebuffer is locked + //bytesperline = width; + //imageSize = bytesperline*yres; + + modechange = 1; + OSD_ResizeDisplay(xres,yres); + + UpdateWindow(hWindow); + + return FALSE; +} + + +// +// DestroyAppWindow() -- destroys the application window +// +static void DestroyAppWindow(void) +{ + if (hWindow && gammabrightness) { + setgammaramp(sysgamma); + gammabrightness = 0; + } + +#if defined(USE_OPENGL) && defined(POLYMOST) + UninitOpenGL(); +#endif + UninitDirectDraw(); + UninitDIB(); + + if (hWindow) { + DestroyWindow(hWindow); + hWindow = NULL; + } +} + + +// +// SaveSystemColours() -- save the Windows-reserved colours +// +static void SaveSystemColours(void) +{ + int i; + + if (system_colours_saved) return; + + for (i=0; i + Intensities range from 0-63, and palettes 26, 27, 28 and 29 are pre-defined for you as + white, red, green and blue respectively. Sector visibility controls fog density. + - Added movement_lock[] member to player struct. Functionality will be explained upon request + until the wiki is updated. As can be guessed, this is used to lock player movement. + - Fixed a couple of reload bugs + - Projectile system internally optimized and improved (ripped out remnants of variable based + system as well as modified the system to restore projectile defaults on game restart) + - Added the following primitives: + - movesprite + - checkavailweapon + - updatesectorz + - ssp + - stopallsounds + - soundoncevar + - stopsoundvar + Movesprite, checkavailweapon, updatesectorz and ssp work exactly as their + internal counterparts do. The sound commands are self-explanatory. + - Minor fixes to the error handling system -- it is now impossible to redefine internal + pointer gamevars. Some error messages also made more descriptive. + - Fixed handling of bad CON files + - Added "-condebug" command line parameter which prints one line to the init window per line + compiled. This is useful in cases where you've encountered a bug in the CON parser which + throws you into an infinite loop on compile, as you can see where the problem happened. + - Fixed "DNITEMS" cheat not triggering item cheat events + - CON commands "addlog" and "addlogvar" now print to console and log to eduke32.log + with all of the other log information rather than log.log + - Fixed multiplayer menu problem + - Added PROJECTILE_FLAG_RPG_IMPACT (defined as 32768) to projectile flags. This flag causes + an RPG type projectile to directly damage whatever it hits rather than do radius damage. + - By request, changed how Duke moves when submerging into and emerging from underwater sectors + - Various minor code clean-ups and fixes + + - Mapster32 changes: + - Added ' 5 2D mode key combination for changing the shade of every parallaxed ceiling + on the map at once + - Added ' 6 2D mode key combination for changing the height of every parallaxed ceiling + on the map at once + - Added ' Z 2D mode key combination for offsetting an entire map on the Z plane. This + is useful for merging sections of maps into other maps. + - Added Left ALT ' 7 2D mode key combination for scaling the entire map (multiply) + - Added Left ALT ' 8 2D mode key combination for scaling the entire map (divide) + - Added ' M key combination for setting .extra member (this is the SW middle tag) + - Help menus re-organized to be more useful + - Added ' P 3D mode key combination to set palette on all sectors selected in 2D mode + - Added ; V 3D mode key combination to set visibility on all sectors selected in 2D mode + - Added support for running without lookup.dat (obviously, this will disable alt pals) + +==1.2.1== + - Updated to current JFDuke3D and JFBuild release, see releasenotes.html for details + - Mapster32 updated to 1.0.1, hit F1 in 2D mode for new feature rundown + - Added "spritenoshade" command. This command works just like spritenvg and spriteshadow, and does + exactly what it claims to do. + - Fixed 1.2.0 bug which made the player's APLAYER sprite's position shift across the map each time a + bullet hole was left on a wall. + +==1.2.0== + - Updated to current JFDuke3D and JFBuild release, see releasenotes.html for details + - Introduction of Mapster32, the enhanced Build editor version 1.0.0 + - Lots of miscellaneous code clean-ups and bug fixes + - Fixed pre-placed tripbomb bug from EDuke32 1.0.0 + - Increased MAXCYCLERS to 1024 + - Renumbered EVENT_AIMDOWN to be event 63 + - Ripped out unused NAM and WW2GI-specific code + - Ripped out unused code specific to foreign, demo and beta versions of Duke + - Added several new primitives, as follows: + - whilevarn + - switch + - case + - default + - endswitch + - shootvar + - soundvar + - findplayer + - findotherplayer + - activatebysector + - operatesectors + - operateactivators + - operatemasterswitches + - checkactivatormotion + - zshoot + - dist + - ldist + - shiftvarl + - shitvarr + - spritenvg + - getangle + - whilevarvarn + - hitscan + - getplayervar + - setplayervar + - mulscale + - setaspect + Descriptions of these commands will be available soon on EDukeWiki + - Added "reloading" member to player struct (1 when reloading, 0 when not, weapon changes blocked while 1) + - Fixed setuserdef + - Fixed eventloadactor + - Added ud.statusbarscale to get/setuserdef + - Restricted all screen drawing commands to events + - Fixed issues with several events + - SHOTSPARK1 now sets temp_data[6-8] to hitwall, hitsect and hitspr, in that order + - Tweaked the operation of weapons to allow identical operation to Duke3D 1.5 (may cause issues with some existing mods) + - All effector sprites now made non-blockable non-hitscan-sensitive on map start + - Added "range" field to custom projectile system diff --git a/polymer/eduke32/GNU.TXT b/polymer/eduke32/GNU.TXT new file mode 100644 index 000000000..358ef6fb3 --- /dev/null +++ b/polymer/eduke32/GNU.TXT @@ -0,0 +1,87 @@ +GNU GENERAL PUBLIC LICENSE +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +Preamble +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + +a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + +c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +END OF TERMS AND CONDITIONS diff --git a/polymer/eduke32/MakeDistributions b/polymer/eduke32/MakeDistributions new file mode 100644 index 000000000..d59bb3d8e --- /dev/null +++ b/polymer/eduke32/MakeDistributions @@ -0,0 +1,43 @@ +# GNU Makefile to prepare source and binary distributions. +# make -f MakeDistributions [source|binary] + +SOURCEFILES=build.cfg GNU.TXT \ + Makefile Makefile.deps Makefile.msvc Makefile.watcom MakeDistributions \ + makemsc.bat makew.bat jfduke_releasenotes.html duke3d.def.sample \ + SEHELP.HLP STHELP.HLP ChangeLog enhance.con.sample + +BINARYFILES=build.cfg mapster32.exe eduke32.exe GNU.TXT \ + jfduke_releasenotes.html setup.exe duke3d.def.sample SEHELP.HLP STHELP.HLP \ + ChangeLog enhance.con.sample + +.PHONY: source binary + +datenow=$(shell date +%Y%m%d) + +sourcedir=eduke32_src_$(datenow) +binarydir=eduke32_$(datenow) + +all: source binary + +source: + rm -rf $(sourcedir) $(sourcedir).zip + mkdir -p $(sourcedir) $(sourcedir)/eobj $(sourcedir)/obj + touch $(sourcedir)/eobj/keep.me $(sourcedir)/obj/keep.me + cp $(SOURCEFILES) $(sourcedir) + find . -name "*~" -exec rm -rf '{}' ';'; + find . -name "*.orig" -exec rm -rf '{}' ';'; + find . -name "*.rej" -exec rm -rf '{}' ';'; + cp -R source rsrc $(sourcedir) + find $(sourcedir) | grep -i svn | xargs rm -rf + kzip -r $(sourcedir).zip $(sourcedir) + +binary: + make RELEASE=1 + upx mapster32.exe eduke32.exe + rm -rf $(binarydir) + mkdir $(binarydir) +# mkdir $(binarydir) $(binarydir)/models + cp $(BINARYFILES) $(binarydir) +# cp models/* $(binarydir)/models + kzip -r $(binarydir).zip $(binarydir) + diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile new file mode 100644 index 000000000..26f438284 --- /dev/null +++ b/polymer/eduke32/Makefile @@ -0,0 +1,222 @@ +# EDuke32 Makefile for GNU Make + +# SDK locations - adjust to match your setup +# DXROOT=c:/sdks/msc/dx61 + +# Engine options +SUPERBUILD = 1 +POLYMOST = 1 +USE_OPENGL = 1 +DYNAMIC_OPENGL = 1 +USE_A_C = 0 +NOASM = 0 + +# Debugging options +RELEASE?=1 + +# build locations + +SRC=source/ +RSRC=rsrc/ +EROOT=../build/ +EINC=$(EROOT)include/ +INC=$(SRC) +o=o + +ifneq (0,$(RELEASE)) + # debugging disabled + debug=-fomit-frame-pointer -O1 +else + # debugging enabled + debug=-ggdb -O0 +endif + +CC=gcc +CXX=g++ +# -Werror-implicit-function-declaration +OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-char-subscripts -Wno-unused \ + -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -DNOCOPYPROTECT \ + -I$(INC:/=) -I$(EINC:/=) -I$(SRC)jmact -I$(SRC)jaudiolib -I../jfaud/src +OURCXXFLAGS=-fno-exceptions -fno-rtti +LIBS=-lm +#JFAUDLIBS=../jfaud/libjfaud.a ../jfaud/mpadec/libmpadec/libmpadec.a +NASMFLAGS=-s #-g +EXESUFFIX= + +include $(EROOT)Makefile.shared + +ifeq ($(PLATFORM),LINUX) + OBJ=obj.nix/ + EOBJ=eobj.nix/ + NASMFLAGS+= -f elf +else + OBJ=obj/ + EOBJ=eobj/ +endif + +JMACTOBJ=$(OBJ)util_lib.$o \ + $(OBJ)file_lib.$o \ + $(OBJ)control.$o \ + $(OBJ)keyboard.$o \ + $(OBJ)mouse.$o \ + $(OBJ)mathutil.$o \ + $(OBJ)scriplib.$o + +AUDIOLIB_FX_STUB=$(OBJ)audiolib_fxstub.$o +AUDIOLIB_MUSIC_STUB=$(OBJ)audiolib_musicstub.$o +AUDIOLIB_JFAUD=$(OBJ)jfaud_sounds.$o +AUDIOLIB_FX=$(OBJ)mv_mix.$o \ + $(OBJ)mv_mix16.$o \ + $(OBJ)mvreverb.$o \ + $(OBJ)pitch.$o \ + $(OBJ)multivoc.$o \ + $(OBJ)ll_man.$o \ + $(OBJ)fx_man.$o \ + $(OBJ)dsoundout.$o +AUDIOLIB_MUSIC=$(OBJ)midi.$o \ + $(OBJ)mpu401.$o \ + $(OBJ)music.$o + +GAMEOBJS=$(OBJ)game.$o \ + $(OBJ)actors.$o \ + $(OBJ)anim.$o \ + $(OBJ)animlib.$o \ + $(OBJ)config.$o \ + $(OBJ)gamedef.$o \ + $(OBJ)gameexec.$o \ + $(OBJ)global.$o \ + $(OBJ)menus.$o \ + $(OBJ)namesdyn.$o \ + $(OBJ)player.$o \ + $(OBJ)premap.$o \ + $(OBJ)savegame.$o \ + $(OBJ)sector.$o \ + $(OBJ)sounds.$o \ + $(OBJ)rts.$o \ + $(OBJ)testcd.$o \ + $(OBJ)osdfuncs.$o \ + $(OBJ)osdcmds.$o \ + $(JMACTOBJ) + +EDITOROBJS=$(OBJ)astub.$o + +ifeq ($(PLATFORM),WINDOWS) + OURCFLAGS+= -DUNDERSCORES -I$(DXROOT)/include + NASMFLAGS+= -DUNDERSCORES -f win32 + GAMEOBJS+= $(OBJ)gameres.$o $(OBJ)winbits.$o + EDITOROBJS+= $(OBJ)buildres.$o +endif + +ifeq ($(RENDERTYPE),SDL) + OURCFLAGS+= $(subst -Dmain=SDL_main,,$(shell sdl-config --cflags)) + AUDIOLIBOBJ=$(AUDIOLIB_MUSIC_STUB) $(AUDIOLIB_FX_STUB) $(OBJ)sounds.$o + #AUDIOLIBOBJ=$(AUDIOLIB_JFAUD) + + ifeq (1,$(HAVE_GTK2)) + OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0) + GAMEOBJS+= $(OBJ)game_banner.$o + EDITOROBJS+= $(OBJ)editor_banner.$o + endif + + GAMEOBJS+= $(OBJ)game_icon.$o + EDITOROBJS+= $(OBJ)build_icon.$o +endif + +ifeq ($(RENDERTYPE),WIN) + AUDIOLIBOBJ=$(AUDIOLIB_MUSIC) $(AUDIOLIB_FX) $(OBJ)sounds.$o + #AUDIOLIBOBJ=$(AUDIOLIB_JFAUD) +endif + +GAMEOBJS+= $(AUDIOLIBOBJ) +OURCFLAGS+= $(BUILDCFLAGS) +OURCXXFLAGS+= $(BUILDCFLAGS) + +.PHONY: clean all engine $(EOBJ)$(ENGINELIB) $(EOBJ)$(EDITORLIB) + +# TARGETS + +# Invoking Make from the terminal in OSX just chains the build on to xcode +ifeq ($(PLATFORM),DARWIN) +ifeq ($(RELEASE),0) +style=Development +else +style=Deployment +endif +.PHONY: alldarwin +alldarwin: + cd osx && xcodebuild -target All -buildstyle $(style) +endif + +all: eduke32$(EXESUFFIX) mapster32$(EXESUFFIX) + +eduke32$(EXESUFFIX): $(GAMEOBJS) $(EOBJ)$(ENGINELIB) + $(CC) $(CFLAGS) $(OURCFLAGS) -o $@ $^ $(JFAUDLIBS) $(LIBS) $(STDCPPLIB) -Wl,-Map=$@.map + -rm eduke32.sym$(EXESUFFIX) + cp eduke32$(EXESUFFIX) eduke32.sym$(EXESUFFIX) + strip eduke32$(EXESUFFIX) + +mapster32$(EXESUFFIX): $(EDITOROBJS) $(EOBJ)$(EDITORLIB) $(EOBJ)$(ENGINELIB) + $(CC) $(CFLAGS) $(OURCFLAGS) -o $@ $^ $(LIBS) -Wl,-Map=$@.map + -rm mapster32.sym$(EXESUFFIX) + cp mapster32$(EXESUFFIX) mapster32.sym$(EXESUFFIX) + strip mapster32$(EXESUFFIX) + +include Makefile.deps + +.PHONY: enginelib editorlib +enginelib editorlib: + -mkdir $(EOBJ) + $(MAKE) -C $(EROOT) "OBJ=$(CURDIR)/$(EOBJ)" \ + SUPERBUILD=$(SUPERBUILD) POLYMOST=$(POLYMOST) \ + USE_OPENGL=$(USE_OPENGL) DYNAMIC_OPENGL=$(DYNAMIC_OPENGL) \ + USE_A_C=$(USE_A_C) NOASM=$(NOASM) RELEASE=$(RELEASE) $@ + +$(EOBJ)$(ENGINELIB): enginelib +$(EOBJ)$(EDITORLIB): editorlib + +# RULES +$(OBJ)%.$o: $(SRC)%.nasm + nasm $(NASMFLAGS) $< -o $@ +$(OBJ)%.$o: $(SRC)jaudiolib/%.nasm + nasm $(NASMFLAGS) $< -o $@ + +$(OBJ)%.$o: $(SRC)%.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 +$(OBJ)%.$o: $(SRC)%.cpp + $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 +$(OBJ)%.$o: $(SRC)jmact/%.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 +$(OBJ)%.$o: $(SRC)jaudiolib/%.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 + +$(OBJ)%.$o: $(SRC)misc/%.rc + windres -i $< -o $@ + +$(OBJ)%.$o: $(SRC)util/%.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 + +$(OBJ)%.$o: $(RSRC)%.c + $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 + +$(OBJ)game_banner.$o: $(RSRC)game_banner.c +$(OBJ)editor_banner.$o: $(RSRC)editor_banner.c +$(RSRC)game_banner.c: $(RSRC)game.bmp + echo "#include " > $@ + gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@ +$(RSRC)editor_banner.c: $(RSRC)build.bmp + echo "#include " > $@ + gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@ + +# PHONIES +clean: +ifeq ($(PLATFORM),DARWIN) + cd osx && xcodebuild -target All clean +else + -rm -f $(OBJ)* eduke32$(EXESUFFIX) eduke32.sym$(EXESUFFIX) mapster32$(EXESUFFIX) mapster32.sym$(EXESUFFIX) core* +endif + +veryclean: clean +ifeq ($(PLATFORM),DARWIN) +else + -rm -f $(EOBJ)* +endif diff --git a/polymer/eduke32/Makefile.deps b/polymer/eduke32/Makefile.deps new file mode 100644 index 000000000..401b5a001 --- /dev/null +++ b/polymer/eduke32/Makefile.deps @@ -0,0 +1,60 @@ +duke3d_h=$(EINC)build.h $(EINC)pragmas.h $(EINC)compat.h $(EINC)cache1d.h $(EINC)baselayer.h $(SRC)jmact/types.h $(SRC)jmact/file_lib.h $(SRC)jmact/util_lib.h $(SRC)jmact/keyboard.h $(SRC)jmact/control.h $(INC)develop.h $(INC)gamedefs.h $(INC)function.h $(INC)config.h $(INC)sounds.h $(INC)rts.h $(INC)_rts.h $(INC)soundefs.h $(SRC)jaudiolib/fx_man.h $(SRC)jaudiolib/music.h $(INC)namesdyn.h $(INC)funct.h $(INC)duke3d.h $(EINC)mmulti.h +gamedef_h=$(SRC)gamedef.h + +$(OBJ)game.$o: $(SRC)*.c $(SRC)jmact/scriplib.h $(duke3d_h) $(INC)osdfuncs.h $(INC)osdcmds.h +$(OBJ)actors.$o: $(SRC)actors.c $(duke3d_h) +$(OBJ)anim.$o: $(SRC)anim.c $(duke3d_h) $(SRC)jmact/animlib.h +$(OBJ)gamedef.$o: $(SRC)gamedef.c $(duke3d_h) $(gamedef_h) +$(OBJ)gameexec.$o: $(SRC)gameexec.c $(duke3d_h) $(gamedef_h) +$(OBJ)global.$o: $(SRC)global.c $(duke3d_h) +$(OBJ)menus.$o: $(SRC)menus.c $(duke3d_h) $(SRC)jmact/mouse.h +$(OBJ)namesdyn.$o: $(SRC)namesdyn.c $(duke3d_h) +$(OBJ)player.$o: $(SRC)player.c $(duke3d_h) +$(OBJ)premap.$o: $(SRC)premap.c $(duke3d_h) $(EINC)osd.h +$(OBJ)savegame.$o: $(SRC)savegame.c $(duke3d_h) +$(OBJ)sector.$o: $(SRC)sector.c $(duke3d_h) +$(OBJ)sounds.$o: $(SRC)sounds.c $(duke3d_h) +$(OBJ)jfaud_sounds.$o: $(SRC)jfaud_sounds.cpp $(duke3d_h) $(EINC)osd.h +$(OBJ)rts.$o: $(SRC)rts.c $(duke3d_h) +$(OBJ)config.$o: $(SRC)config.c $(duke3d_h) $(SRC)jmact/scriplib.h $(INC)_functio.h +$(OBJ)testcd.$o: $(SRC)testcd.c +$(OBJ)winbits.$o: $(SRC)winbits.c +$(OBJ)osdfuncs.$o: $(SRC)names.h $(EINC)build.h +$(OBJ)osdcmds.$o: $(SRC)osdcmds.c $(INC)osdcmds.h $(EINC)osd.h $(duke3d_h) + +$(OBJ)astub.$o: $(SRC)astub.c $(EINC)build.h $(EINC)pragmas.h $(EINC)compat.h $(EINC)editor.h + +$(OBJ)game_icon.$o: $(RSRC)game_icon.c +$(OBJ)build_icon.$o: $(RSRC)build_icon.c + +$(OBJ)gameres.$o: $(SRC)misc/gameres.rc $(RSRC)game.bmp $(RSRC)game_icon.ico +$(OBJ)buildres.$o: $(SRC)misc/buildres.rc $(RSRC)build.bmp $(RSRC)build_icon.ico + +# jMACT objects +$(OBJ)animlib.$o: $(SRC)jmact/animlib.c $(SRC)jmact/types.h $(INC)develop.h $(SRC)jmact/util_lib.h $(SRC)jmact/animlib.h $(EINC)compat.h +$(OBJ)util_lib.$o: $(SRC)jmact/util_lib.c $(SRC)jmact/util_lib.h $(SRC)jmact/types.h $(EINC)compat.h +$(OBJ)file_lib.$o: $(SRC)jmact/file_lib.c $(SRC)jmact/file_lib.h $(SRC)jmact/types.h +$(OBJ)control.$o: $(SRC)jmact/control.c $(SRC)jmact/types.h $(SRC)jmact/control.h $(SRC)jmact/keyboard.h $(SRC)jmact/mouse.h $(EINC)baselayer.h +$(OBJ)keyboard.$o: $(SRC)jmact/keyboard.c $(SRC)jmact/types.h $(SRC)jmact/keyboard.h $(EINC)compat.h $(EINC)baselayer.h +$(OBJ)mouse.$o: $(SRC)jmact/mouse.c $(SRC)jmact/types.h $(SRC)jmact/mouse.h $(EINC)baselayer.h +$(OBJ)mathutil.$o: $(SRC)jmact/mathutil.c $(SRC)jmact/types.h +$(OBJ)scriplib.$o: $(SRC)jmact/scriplib.c $(SRC)jmact/scriplib.h $(SRC)jmact/util_lib.h $(SRC)jmact/_scrplib.h $(SRC)jmact/types.h $(EINC)compat.h + +# jAudioLib objects +$(OBJ)audiolib_fxstub.$o: $(SRC)jaudiolib/audiolib_fxstub.c $(SRC)jaudiolib/fx_man.h +$(OBJ)audiolib_musicstub.$o: $(SRC)jaudiolib/audiolib_musicstub.c $(SRC)jaudiolib/music.h + +$(OBJ)audiolib_fx_fmod.$o: $(SRC)jaudiolib/audiolib_fx_fmod.c $(SRC)jaudiolib/fx_man_fmod.h $(INC)duke3d.h + +$(OBJ)mv_mix.$o: $(SRC)jaudiolib/mv_mix.nasm +$(OBJ)mv_mix16.$o: $(SRC)jaudiolib/mv_mix16.nasm +$(OBJ)mvreverb.$o: $(SRC)jaudiolib/mvreverb.nasm +$(OBJ)pitch.$o: $(SRC)jaudiolib/pitch.c $(SRC)jaudiolib/pitch.h +$(OBJ)multivoc.$o: $(SRC)jaudiolib/multivoc.c $(SRC)jaudiolib/usrhooks.h $(SRC)jaudiolib/linklist.h $(SRC)jaudiolib/pitch.h $(SRC)jaudiolib/multivoc.h $(SRC)jaudiolib/_multivc.h +$(OBJ)fx_man.$o: $(SRC)jaudiolib/fx_man.c $(SRC)jaudiolib/multivoc.h $(SRC)jaudiolib/ll_man.h $(SRC)jaudiolib/fx_man.h +$(OBJ)dsoundout.$o: $(SRC)jaudiolib/dsoundout.c $(SRC)jaudiolib/dsoundout.h + +$(OBJ)midi.$o: $(SRC)jaudiolib/midi.c $(SRC)jaudiolib/standard.h $(SRC)jaudiolib/usrhooks.h $(SRC)jaudiolib/music.h $(SRC)jaudiolib/_midi.h $(SRC)jaudiolib/midi.h +$(OBJ)mpu401.$o: $(SRC)jaudiolib/mpu401.c $(SRC)jaudiolib/mpu401.h +$(OBJ)music.$o: $(SRC)jaudiolib/music.c $(SRC)jaudiolib/music.h $(SRC)jaudiolib/midi.h $(SRC)jaudiolib/mpu401.h + diff --git a/polymer/eduke32/Makefile.msvc b/polymer/eduke32/Makefile.msvc new file mode 100644 index 000000000..f21705b03 --- /dev/null +++ b/polymer/eduke32/Makefile.msvc @@ -0,0 +1,151 @@ +# EDuke32 Makefile for Watcom Make + +SRC=source\ # +OBJ=obj\ # +EROOT=..\build\ # +EINC=$(EROOT)include\ # +EOBJ=eobj\ # +INC=$(SRC) +o=obj + +ENGINELIB=engine.lib +EDITORLIB=build.lib + +!ifdef DEBUG +# debugging options +flags_cl=/G6 /Ot /Z7 +flags_link=/DEBUG +!else +# release options +flags_cl=/G6Fy /Ox #/Ob1gity +flags_link=/RELEASE +!endif + + +DXROOT=c:\sdks\msc\dx7 + +ENGINEOPTS=/DSUPERBUILD /DPOLYMOST /DUSE_OPENGL /DDYNAMIC_OPENGL + +CC=cl +AS=ml +LINK=link /opt:nowin98 /nologo /opt:ref +CFLAGS= /MD /J /nologo $(flags_cl) \ + /I$(INC) /I$(EINC) /I$(SRC)jmact /I$(SRC)jaudiolib /I..\jfaud\src \ + /DNOCOPYPROTECT $(ENGINEOPTS) \ + /I$(DXROOT)\include /DRENDERTYPEWIN=1 +LIBS=user32.lib gdi32.lib shell32.lib dxguid.lib winmm.lib wsock32.lib \ + ..\jfaud\jfaud.lib ..\jfaud\mpadec\libmpadec\mpadec.lib /NODEFAULTLIB:libFLAC.lib \ + #opengl32.lib + ASFLAGS=/nologo /coff +ASFLAGS=/nologo /coff +EXESUFFIX=.exe + +JMACTOBJ=$(OBJ)util_lib.$o \ + $(OBJ)file_lib.$o \ + $(OBJ)control.$o \ + $(OBJ)keyboard.$o \ + $(OBJ)mouse.$o \ + $(OBJ)mathutil.$o \ + $(OBJ)scriplib.$o + +#AUDIOLIB_FX=$(OBJ)jaudiolib_fxstub.$o +#AUDIOLIB_MUSIC=$(OBJ)jaudiolib_musicstub.$o +#AUDIOLIB_FX=$(OBJ)jaudiolib_fx_fmod.$o +AUDIOLIB_JFAUD=$(OBJ)jfaud_sounds.$o +AUDIOLIB_FX=$(OBJ)mv_mix.$o \ + $(OBJ)mv_mix16.$o \ + $(OBJ)mvreverb.$o \ + $(OBJ)pitch.$o \ + $(OBJ)multivoc.$o \ + $(OBJ)ll_man.$o \ + $(OBJ)fx_man.$o \ + $(OBJ)dsoundout.$o +AUDIOLIB_MUSIC=$(OBJ)midi.$o \ + $(OBJ)mpu401.$o \ + $(OBJ)music.$o +#AUDIOLIBOBJ=$(AUDIOLIB_MUSIC) $(AUDIOLIB_FX) $(OBJ)sounds.$o +AUDIOLIBOBJ=$(AUDIOLIB_JFAUD) + + GAMEOBJS=$(OBJ)game.$o \ + $(OBJ)actors.$o \ + $(OBJ)anim.$o \ + $(OBJ)gamedef.$o \ + $(OBJ)gameexec.$o \ + $(OBJ)global.$o \ + $(OBJ)menus.$o \ + $(OBJ)namesdyn.$o \ + $(OBJ)player.$o \ + $(OBJ)premap.$o \ + $(OBJ)savegame.$o \ + $(OBJ)sector.$o \ + $(OBJ)rts.$o \ + $(OBJ)config.$o \ + $(OBJ)animlib.$o\ + $(OBJ)testcd.$o \ + $(OBJ)osdfuncs.$o \ + $(OBJ)osdcmds.$o \ + $(JMACTOBJ) \ + $(AUDIOLIBOBJ) \ + $(OBJ)winbits.$o $(OBJ)gameres.res + +EDITOROBJS=$(OBJ)astub.$o \ + $(OBJ)buildres.res + + +# RULES +.SUFFIXES: .masm + +{$(SRC)}.masm{$(OBJ)}.$o: + $(AS) /c $(ASFLAGS) /Fo$@ $< + +{$(SRC)jaudiolib}.masm{$(OBJ)}.$o: + $(AS) /c $(ASFLAGS) /Fo$@ $< + +{$(SRC)jmact}.c{$(OBJ)}.$o: + $(CC) /c $(CFLAGS) /Fo$@ $< + +{$(SRC)jaudiolib}.c{$(OBJ)}.$o: + $(CC) /c $(CFLAGS) /Fo$@ $< + +{$(SRC)util}.c{$(OBJ)}.$o: + $(CC) /c $(CFLAGS) /Fo$@ $< + +{$(SRC)}.c{$(OBJ)}.$o: + $(CC) /c $(CFLAGS) /Fo$@ $< + +{$(SRC)}.cpp{$(OBJ)}.$o: + $(CC) /c $(CFLAGS) /Fo$@ $< + +{$(SRC)misc}.rc{$(OBJ)}.res: + $(RC) /fo$@ /r $< + + +# TARGETS +all: eduke32$(EXESUFFIX) mapster32$(EXESUFFIX) ; + +eduke32$(EXESUFFIX): $(GAMEOBJS) $(EOBJ)$(ENGINELIB) + $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib $(flags_link) /MAP $** $(LIBS) msvcrt.lib + +mapster32$(EXESUFFIX): $(EDITOROBJS) $(EOBJ)$(ENGINELIB) $(EOBJ)$(EDITORLIB) + $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib $(flags_link) /MAP $** $(LIBS) msvcrt.lib + +!include Makefile.deps + +enginelib editorlib: AlwaysBuild + -mkdir $(EOBJ) + echo OBJ=$(MAKEDIR)\$(EOBJ) > $(EOBJ)overrides.mak + echo CFLAGS=$(ENGINEOPTS) >> $(EOBJ)overrides.mak + cd $(EROOT) + nmake /f Makefile.msvc "OVERRIDES=$(MAKEDIR)\$(EOBJ)overrides.mak" $@ + cd $(MAKEDIR) + +AlwaysBuild: ; +$(EOBJ)$(EDITORLIB): editorlib ; +$(EOBJ)$(ENGINELIB): enginelib ; + +# PHONIES +clean: + -del $(OBJ)* eduke32$(EXESUFFIX) mapster32$(EXESUFFIX) + +veryclean: clean + -del $(EOBJ)* diff --git a/polymer/eduke32/Makefile.watcom b/polymer/eduke32/Makefile.watcom new file mode 100644 index 000000000..bbc08bf7b --- /dev/null +++ b/polymer/eduke32/Makefile.watcom @@ -0,0 +1,143 @@ +# EDuke32 Makefile for Watcom Make + +SRC=source\ +OBJ=obj\ +EROOT=..\build\ +EINC=$(EROOT)include\ +EOBJ=eobj\ +INC=$(SRC) +o=obj + +ENGINELIB=engine.lib +EDITORLIB=build.lib + +!ifdef __LOADDLL__ +! loaddll wcc386 wccd386 +!endif + +DXROOT=c:\sdks\msc\dx7 + +ENGINEOPTS=-dSUPERBUILD -dPOLYMOST -dUSE_OPENGL -dDYNAMIC_OPENGL + +CC=wcc386 +CFLAGS= -5r -s -orb -fp5 -d2 -db & + -i=$(INC) -i=$(EINC) -i=$(SRC)jmact -i=$(SRC)jaudiolib -i=$(DXROOT)\include & + -dRENDERTYPEWIN=1 -dNOCOPYPROTECT $(ENGINEOPTS) +LIBS=winmm.lib wsock32.lib dxguid.lib #opengl32.lib +WASMFLAGS=-d1 +EXESUFFIX=.exe + +JMACTOBJ=$(OBJ)util_lib.$o & + $(OBJ)file_lib.$o & + $(OBJ)control.$o & + $(OBJ)keyboard.$o & + $(OBJ)mouse.$o & + $(OBJ)mathutil.$o & + $(OBJ)scriplib.$o + +#JAUDIOLIB_FX=$(OBJ)jaudiolib_fxstub.$o +#JAUDIOLIB_MUSIC=$(OBJ)jaudiolib_musicstub.$o +#JAUDIOLIB_FX=$(OBJ)jaudiolib_fx_fmod.$o +JAUDIOLIB_FX=$(OBJ)mv_mix.$o & + $(OBJ)mv_mix16.$o & + $(OBJ)mvreverb.$o & + $(OBJ)pitch.$o & + $(OBJ)multivoc.$o & + $(OBJ)ll_man.$o & + $(OBJ)fx_man.$o & + $(OBJ)dsoundout.$o +JAUDIOLIB_MUSIC=$(OBJ)midi.$o & + $(OBJ)mpu401.$o & + $(OBJ)music.$o +JAUDIOLIBOBJ=$(JAUDIOLIB_MUSIC) $(JAUDIOLIB_FX) + +GAMEOBJS=$(OBJ)game.$o & + $(OBJ)actors.$o & + $(OBJ)anim.$o & + $(OBJ)gamedef.$o & + $(OBJ)gameexec.$o & + $(OBJ)global.$o & + $(OBJ)menus.$o & + $(OBJ)namesdyn.$o & + $(OBJ)player.$o & + $(OBJ)premap.$o & + $(OBJ)savegame.$o & + $(OBJ)sector.$o & + $(OBJ)sounds.$o & + $(OBJ)rts.$o & + $(OBJ)config.$o & + $(OBJ)animlib.$o & + $(OBJ)testcd.$o & + $(OBJ)osdfuncs.$o & + $(OBJ)osdcmds.$o & + $(OBJ)winbits.$o & + $(JMACTOBJ) & + $(JAUDIOLIBOBJ) + +EDITOROBJS=$(OBJ)astub.$o + +# RULES +.EXTENSIONS: .wasm .res .rc + +.wasm: $(SRC) +.wasm: $(SRC)jaudiolib/ +.c: $(SRC) +.c: $(SRC)jmact/ +.c: $(SRC)jaudiolib/ +.c: $(SRC)util/ +.rc: $(SRC)misc/ + +.wasm.$o: + wasm $(WASMFLAGS) -fo=$(OBJ).$o $[@ + +.c.$o: + $(CC) $(CFLAGS) -fo=$(OBJ).$o $[@ + +.rc.res: + wrc -fo=$^*.res -r $[@ + + +# TARGETS +all: eduke32$(EXESUFFIX) build$(EXESUFFIX) .SYMBOLIC + %null + +eduke32$(EXESUFFIX): $(GAMEOBJS) $(OBJ)gameres.res $(EOBJ)$(ENGINELIB) + wlink NAME $@ & + SYSTEM WIN95 & + DEBUG ALL & + FILE { $(GAMEOBJS) $(ENGINEOBJS) } & + RESOURCE $(OBJ)gameres.res & + LIBPATH $(DXROOT)\lib & + LIBPATH $(EOBJ) & + LIBRARY { $(ENGINELIB) $(LIBS) } + +mapster32$(EXESUFFIX): $(EDITOROBJS) $(OBJ)buildres.res $(EOBJ)$(ENGINELIB) $(EOBJ)$(EDITORLIB) + wlink NAME $@ & + SYSTEM WIN95 & + DEBUG ALL & + FILE { $(EDITOROBJS) } & + RESOURCE $(OBJ)buildres.res & + LIBPATH $(DXROOT)\lib & + LIBPATH $(EOBJ) & + LIBRARY { $(LIBS) $(ENGINELIB) $(EDITORLIB) } + +!include Makefile.deps + +cwd=$+ $(%cwd) $- +enginelib editorlib: .SYMBOLIC + -mkdir $(EOBJ) + %write $(EOBJ)overrides.mak OBJ=$(cwd)\$(EOBJ) + %write $(EOBJ)overrides.mak CFLAGS=$(ENGINEOPTS) + cd $(EROOT) + wmake -f Makefile.watcom OVERRIDES=$(cwd)\$(EOBJ)overrides.mak $@ + cd $(cwd) + +$(EOBJ)$(EDITORLIB): editorlib .SYMBOLIC +$(EOBJ)$(ENGINELIB): enginelib .SYMBOLIC + +# PHONIES +clean: .SYMBOLIC + -del $(OBJ)* eduke32$(EXESUFFIX) mapster32$(EXESUFFIX) + +veryclean: clean .SYMBOLIC + -del $(EOBJ)* diff --git a/polymer/eduke32/SEHELP.HLP b/polymer/eduke32/SEHELP.HLP new file mode 100644 index 000000000..ce375c4bb --- /dev/null +++ b/polymer/eduke32/SEHELP.HLP @@ -0,0 +1,35 @@ +-SECTOR EFFECTOR HELP- + + 0 : ROTATED SECTOR + 1 : PIVOT SPRITE FOR SE 0 + 2 : EARTHQUAKE + 3 : RANDOM LIGHTS AFTER SHOT OUT + 4 : RANDOM LIGHTS + 6 : SUBWAY + 7 : TRANSPORT (UNDERWATER ST 1 or 2) + 8 : UP OPEN DOOR LIGHTS + 9 : DOWN OPEN DOOR LIGHTS + 10 : DOOR AUTO CLOSE (H=DELAY) + 11 : ROTATE SECTOR DOOR + 12 : LIGHT SWITCH + 13 : C-9 EXPLOSIVE + 14 : SUBWAY CAR + 15 : SLIDE DOOR (ST 25) + 16 : ROTATE REACTOR SECTOR + 17 : ELEVATOR TRANSPORT (ST 15) + 18 : INCREMENTAL SECTOR RISE/FALL + 19 : SHOT TOUCHPLATE CIELING DOWN + 20 : BRIDGE (ST 27) + 21 : DROP FLOOR (ST 28) + 22 : PRONG (ST 29) + 23 : TRANSPORT DESTINATION (H=SE 7) + 24 : CONVAIRBELT + 25 : ENGINE + 28 : LIGHTNING (H= TILE#4890) + 27 : CAMERA FOR PLAYBACK + 29 : FLOAT + 30 : 2 WAY TRAIN (ST=31) + 31 : FLOOR RISE + 32 : CEILING FALL + 33 : SPAWN JIB W/QUAKE + 36 : SKRINK RAY SHOOTER diff --git a/polymer/eduke32/STHELP.HLP b/polymer/eduke32/STHELP.HLP new file mode 100644 index 000000000..e70885dfb --- /dev/null +++ b/polymer/eduke32/STHELP.HLP @@ -0,0 +1,24 @@ +-SECTOR TAGS HELP- + + 1 : WATER (SE 7) + 2 : UNDERWATER (SE 7) + 9 : STAR TREK DOORS + 15 : ELEVATOR TRANSPORT (SE 17) + 16 : ELEVATOR PLATFORM DOWN + 17 : ELEVATOR PLATFORM UP + 18 : ELEVATOR DOWN + 19 : ELEVATOR UP + 20 : CEILING DOOR + 21 : FLOOR DOOR + 22 : SPLIT DOOR + 23 : SWING DOOR + 25 : SLIDE DOOR (SE 15) + 26 : SPLIT STAR TREK DOOR + 27 : BRIDGE (SE 20) + 28 : DROP FLOOR (SE 21) + 29 : TEETH DOOR (SE 22) + 30 : ROTATE RISE BRIDGE + 31 : 2 WAY TRAIN (SE=30) + 10000+ : 1 TIME SOUND + 32767 : SECRET ROOM + 65535 : END OF LEVEL diff --git a/polymer/eduke32/build.cfg b/polymer/eduke32/build.cfg new file mode 100644 index 000000000..60c444b2d --- /dev/null +++ b/polymer/eduke32/build.cfg @@ -0,0 +1,104 @@ +; Build editor configuration + +; Video mode selection +; 0 - Windowed +; 1 - Fullscreen +fullscreen = 0 + +; Video resolution selection +; 0 - 320 x 200 +; 1 - 360 x 200 +; 2 - 320 x 240 +; 3 - 360 x 240 +; 4 - 320 x 400 +; 5 - 360 x 400 +; 6 - 640 x 350 +; 7 - 640 x 400 +; 8 - 640 x 480 +; 9 - 800 x 600 +; 10 - 1024 x 768 +; 11 - 1280 x 1024 +; 12 - 1600 x 1200 +; You can select a seperate 2D editor resolution by +; removing the semicolon from the second line below +; and selecting a mode number. The minimum 2D mode +; is 640x480 (mode #8) +resolution = 8 +;2dresolution = 8 + +; 3D mode colour depth +bpp = 8 + +; Maximum OpenGL mode refresh rate (Windows only, in Hertz) +maxrefreshfreq = 60 + +; 3D mode brightness setting +; 0 - lowest +; 15 - highest +brightness = 0 + +; Sound sample frequency +; 0 - 6 KHz +; 1 - 8 KHz +; 2 - 11.025 KHz +; 3 - 16 KHz +; 4 - 22.05 KHz +; 5 - 32 KHz +; 6 - 44.1 KHz +samplerate = 4 + +; Music playback +; 0 - Off +; 1 - On +music = 1 + +; Enable mouse +; 0 - No +; 1 - Yes +mouse = 1 + +; Mouse sensitivity +mousesensitivity = 1.0 + +; Key Settings +; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex! +; +---------------------------------------------------------------------------------------------+ +; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 | +; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL | +; | | +; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A | +; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- | +; | | +; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E | +; |TAB Q W E R T Y U I O P [ ] \ DEL END PGDN KP7 KP8 KP9 KP+ | +; | | +; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D | +; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C | +; | KPENTER| +; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 | +; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 | +; | | +; | 1D 38 39 B8 9D CB D0 CD 52 53 | +; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. | +; +---------------------------------------------------------------------------------------------+ + +keyforward = C8 +keybackward = D0 +keyturnleft = CB +keyturnright = CD +keyrun = 2A +keystrafe = 9D +keyfire = 1D +keyuse = 39 +keystandhigh = 1E +keystandlow = 2C +keylookup = D1 +keylookdown = C9 +keystrafeleft = 33 +keystraferight = 34 +key2dmode = 9C +keyviewcycle = 1C +key2dzoomin = D +key2dzoomout = C +keychat = F + diff --git a/polymer/eduke32/duke3d.def.sample b/polymer/eduke32/duke3d.def.sample new file mode 100644 index 000000000..7a3c2ef61 --- /dev/null +++ b/polymer/eduke32/duke3d.def.sample @@ -0,0 +1,69 @@ +// Duke Nukem 3D Sample Defs file +// +// For an explanation of the contents of this file, read releasenotes.html +// in the section titled "DEF-file Language" + +include DEFS.CON + +// These entries define Hightile tints +// definetint +definetint 1 110 110 255 1 +definetint 2 255 110 80 1 +definetint 4 0 0 0 0 +definetint 6 192 255 138 3 +definetint 7 228 200 172 0 +definetint 8 180 255 200 0 + +// This entry defines a texture replacement +// definetexture 0 0 -1 -1 +//definetexture FEMPIC7 0 0 0 -1 -1 "textures/rikaa.png" + +// These entries demonstrate replacing the Pig Cop character with a model + // Editart tile indices: + // walk 2000-2019 + // pump 2025-2027 + // stand 2030-2034 + // shoot 2035-2037 + // dive 2040-2044 + // dived 2045-2049 + // dshoot 2050-2052 + // hit 2055 + // die 2056-2059 + // dead 2060 +// definemodel +// defineskin +// definemodelanim +// definemodelframe +definemodel "models/pigcop.md2" 1.30 0 +definemodelskin 0 "models/pigcop.jpg" + +definemodelanim "walk0" "walk13" 20 0 +definemodelframe "walk0" 2000 2019 + +definemodelanim "pump0" "pump2" 10 1 +definemodelframe "pump0" 2025 2027 + +definemodelframe "stand" 2030 2034 + +definemodelanim "shoot0" "shoot2" 10 1 +definemodelframe "shoot0" 2035 2037 + +definemodelanim "dive0" "dive3" 8 1 +definemodelframe "dive0" 2040 2044 +definemodelframe "dive3" 2045 2049 + +definemodelanim "dshoot0" "dshoot2" 10 1 +definemodelframe "dshoot0" 2050 2052 + +definemodelframe "die0" 2055 2055 +definemodelanim "die1" "dead" 13 1 +definemodelframe "die1" 2056 2059 +definemodelframe "dead" 2060 2060 + + +// These entries demonstrate voxel replacements +// definevoxel +// definevoxeltiles +//definevoxel "voxels/barstool.kvx" +//definevoxeltiles 1006 1006 + diff --git a/polymer/eduke32/enhance.con.sample b/polymer/eduke32/enhance.con.sample new file mode 100644 index 000000000..9190667d7 --- /dev/null +++ b/polymer/eduke32/enhance.con.sample @@ -0,0 +1,369 @@ +// include this file at the top of your game.con or eduke.con + +// Game Events + +// SYNTAX: +// +// onevent +// { +// ... actions +// } +// endevent + +// Internal event IDs + +/* +enum events { + EVENT_INIT, + EVENT_ENTERLEVEL, + EVENT_RESETWEAPONS, + EVENT_RESETINVENTORY, + EVENT_HOLSTER, + EVENT_LOOKLEFT, + EVENT_LOOKRIGHT, + EVENT_SOARUP, + EVENT_SOARDOWN, + EVENT_CROUCH, + EVENT_JUMP, + EVENT_RETURNTOCENTER, + EVENT_LOOKUP, + EVENT_LOOKDOWN, + EVENT_AIMUP, + EVENT_FIRE, + EVENT_CHANGEWEAPON, + EVENT_GETSHOTRANGE, + EVENT_GETAUTOAIMANGLE, + EVENT_GETLOADTILE, + EVENT_CHEATGETSTEROIDS, + EVENT_CHEATGETHEAT, + EVENT_CHEATGETBOOT, + EVENT_CHEATGETSHIELD, + EVENT_CHEATGETSCUBA, + EVENT_CHEATGETHOLODUKE, + EVENT_CHEATGETJETPACK, + EVENT_CHEATGETFIRSTAID, + EVENT_QUICKKICK, + EVENT_INVENTORY, + EVENT_USENIGHTVISION, + EVENT_USESTEROIDS, + EVENT_INVENTORYLEFT, + EVENT_INVENTORYRIGHT, + EVENT_HOLODUKEON, + EVENT_HOLODUKEOFF, + EVENT_USEMEDKIT, + EVENT_USEJETPACK, + EVENT_TURNAROUND, + EVENT_DISPLAYWEAPON, + EVENT_FIREWEAPON, + EVENT_SELECTWEAPON, + EVENT_MOVEFORWARD, + EVENT_MOVEBACKWARD, + EVENT_TURNLEFT, + EVENT_TURNRIGHT, + EVENT_STRAFELEFT, + EVENT_STRAFERIGHT, + EVENT_WEAPKEY1, + EVENT_WEAPKEY2, + EVENT_WEAPKEY3, + EVENT_WEAPKEY4, + EVENT_WEAPKEY5, + EVENT_WEAPKEY6, + EVENT_WEAPKEY7, + EVENT_WEAPKEY8, + EVENT_WEAPKEY9, + EVENT_WEAPKEY10, + EVENT_DRAWWEAPON, + EVENT_DISPLAYCROSSHAIR, + EVENT_DISPLAYREST, + EVENT_RESETPLAYER, + EVENT_INCURDAMAGE, + EVENT_AIMDOWN, + EVENT_GAME, + EVENT_PREVIOUSWEAPON, + EVENT_NEXTWEAPON, + EVENT_SWIMUP, + EVENT_SWIMDOWN, + EVENT_GETMENUTILE, + EVENT_SPAWN, + EVENT_LOGO, + EVENT_EGS +}; +*/ + +// Internal projectile stuff + +/* +enum projectilelabels { + PROJ_WORKSLIKE, + PROJ_SPAWNS, + PROJ_SXREPEAT, + PROJ_SYREPEAT, + PROJ_SOUND, + PROJ_ISOUND, + PROJ_VEL, + PROJ_EXTRA, + PROJ_DECAL, + PROJ_TRAIL, + PROJ_TXREPEAT, + PROJ_TYREPEAT, + PROJ_TOFFSET, + PROJ_TNUM, + PROJ_DROP, + PROJ_CSTAT, + PROJ_CLIPDIST, + PROJ_SHADE, + PROJ_XREPEAT, + PROJ_YREPEAT, + PROJ_PAL, + PROJ_EXTRA_RAND, + PROJ_HITRADIUS, + PROJ_VEL_MULT, + PROJ_OFFSET, + PROJ_BOUNCES, + PROJ_BSOUND, + PROJ_RANGE +}; +*/ + +// Variable definition Flags + +#define GAMEVAR_FLAG_GLOBAL 0 // global variable (default) +#define GAMEVAR_FLAG_PERPLAYER 1 // per-player variable +#define GAMEVAR_FLAG_PERACTOR 2 // per-actor variable + +// Weapon Flags +// 1 Holstering Clears Clip +// 2 Glows +// 4 Automatic +// 8 Fire Every other frame +// 16 Fire Every third frame +// 32 Random restart on automatic +// 64 Use Ammo per burst +// 128 Is a Bomb trigger +// 256 Using does NOT cause player to become 'visible' +// 512 Use 'throws' the 'shoots' item +// 1024 Check weapon availability at 'reload' time +// 2048 player should stop jumping +// 0 Spawn Type 1 (pistol shells) +// 4096 Spawn Type 2 (Shotgun shells) +// 8192 Spawn Type 3 (CHAINGUN shells) +// 16384 Semi-automatic + +// TRIPBOMB_CONTROL +// 1 Tripwire. Trip Bomb works with tripwire. +// 2 On timer. Trip Bomb works on timer + +// PIPEBOMB_CONTROL +// 1 Detonator. Pipe Bomb works with detonator. +// 2 On timer. Pipe Bomb works on timer + +gamevar WEAPON0_WORKSLIKE 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_RELOAD 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_FIREDELAY 7 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_TOTALTIME 14 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_HOLDDELAY 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_FLAGS 288 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_SHOOTS 2521 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_SPAWNTIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_SPAWN 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_INITIALSOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_FIRESOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON0_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON1_WORKSLIKE 1 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_CLIP 12 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_RELOAD 27 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_FIREDELAY 2 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_TOTALTIME 6 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_HOLDDELAY 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_FLAGS 4 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_SHOOTS 2595 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_SPAWNTIME 2 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_SPAWN 2533 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_INITIALSOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_FIRESOUND 3 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON1_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON2_WORKSLIKE 2 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_RELOAD 13 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_FIREDELAY 4 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_TOTALTIME 31 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_HOLDDELAY 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_FLAGS 1024 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_SHOOTS 2613 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_SPAWNTIME 24 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_SPAWN 2535 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_SHOTSPERBURST 7 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_INITIALSOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_FIRESOUND 109 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_SOUND2TIME 15 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_SOUND2SOUND 169 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON2_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON3_WORKSLIKE 3 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_RELOAD 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_FIREDELAY 4 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_TOTALTIME 10 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_HOLDDELAY 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_FLAGS 8276 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_SHOOTS 2536 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_SPAWNTIME 1 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_SPAWN 2533 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_INITIALSOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_FIRESOUND 6 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON3_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON4_WORKSLIKE 4 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_RELOAD 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_FIREDELAY 4 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_TOTALTIME 20 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_HOLDDELAY 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_FLAGS 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_SHOOTS 2605 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_SPAWNTIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_SPAWN 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_INITIALSOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_FIRESOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON4_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON5_WORKSLIKE 5 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_RELOAD 30 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_FIREDELAY 6 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_TOTALTIME 19 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_HOLDDELAY 12 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_FLAGS 512 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_SHOOTS 26 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_SPAWNTIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_SPAWN 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_INITIALSOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_FIRESOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON5_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON6_WORKSLIKE 6 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_RELOAD 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_FIREDELAY 10 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_TOTALTIME 12 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_HOLDDELAY 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_FLAGS 2 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_SHOOTS 2556 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_SPAWNTIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_SPAWN 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_INITIALSOUND 11 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_FIRESOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON6_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON7_WORKSLIKE 7 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_RELOAD 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_FIREDELAY 3 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_TOTALTIME 5 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_HOLDDELAY 5 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_FLAGS 72 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_SHOOTS 2605 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_SPAWNTIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_SPAWN 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_SHOTSPERBURST 2 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_INITIALSOUND 10 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_FIRESOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON7_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON8_WORKSLIKE 8 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_RELOAD 16 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_FIREDELAY 3 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_TOTALTIME 40 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_HOLDDELAY 7 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_FLAGS 3072 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_SHOOTS 2563 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_SPAWNTIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_SPAWN 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_INITIALSOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_FIRESOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON8_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON9_WORKSLIKE 9 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_RELOAD 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_FIREDELAY 3 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_TOTALTIME 8 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_HOLDDELAY 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_FLAGS 20 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_SHOOTS 1641 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_SPAWNTIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_SPAWN 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_INITIALSOUND 10 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_FIRESOUND 10 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON9_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON10_WORKSLIKE 10 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_RELOAD 10 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_FIREDELAY 2 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_TOTALTIME 10 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_HOLDDELAY 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_FLAGS 384 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_SHOOTS 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_SPAWNTIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_SPAWN 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_INITIALSOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_FIRESOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON10_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar WEAPON11_WORKSLIKE 11 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_CLIP 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_RELOAD 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_FIREDELAY 2 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_TOTALTIME 5 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_HOLDDELAY 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_FLAGS 2 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_SHOOTS 2448 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_SPAWNTIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_SPAWN 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_SHOTSPERBURST 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_INITIALSOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_FIRESOUND 388 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_SOUND2TIME 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_SOUND2SOUND 0 GAMEVAR_FLAG_PERPLAYER +gamevar WEAPON11_RENDERSIZE 0 GAMEVAR_FLAG_PERPLAYER + +gamevar GRENADE_LIFETIME 120 GAMEVAR_FLAG_PERPLAYER +gamevar GRENADE_LIFETIME_VAR 30 GAMEVAR_FLAG_PERPLAYER +gamevar STICKYBOMB_LIFETIME 120 GAMEVAR_FLAG_PERPLAYER +gamevar STICKYBOMB_LIFETIME_VAR 30 GAMEVAR_FLAG_PERPLAYER +gamevar TRIPBOMB_CONTROL 1 GAMEVAR_FLAG_PERPLAYER // set value to 2 for timed bomb +gamevar PIPEBOMB_CONTROL 1 GAMEVAR_FLAG_PERPLAYER // set value to 2 for grenade behavior diff --git a/polymer/eduke32/eobj/keep.me b/polymer/eduke32/eobj/keep.me new file mode 100644 index 000000000..e69de29bb diff --git a/polymer/eduke32/jfduke_releasenotes.html b/polymer/eduke32/jfduke_releasenotes.html new file mode 100644 index 000000000..2aa422e07 --- /dev/null +++ b/polymer/eduke32/jfduke_releasenotes.html @@ -0,0 +1,511 @@ + + + + + + Release Notes for JFDuke3D + + + + +

Release Notes for JFDuke3D

+

Release date: 9 October 2005

+ +

New Features and Improvements

+
    +
  • Improved stability with mods, particularly Duke Meets Doom which no longer crashes when you + punch a wall for instance. Big thanks to Richard "TerminX" Gobeille for his help with identifying + the cause of this problem and fixing it.
  • +
  • MD3 models may now have a skin for each surface of the model. If you don't know what this + means, don't worry. If you do, then you ought to realise the significance of this.
  • +
  • Polymost high-resolution texture and model skin caching has been made far more comprehensive. + This has the effect of reducing the number of pauses during gameplay when textures are loaded at + the expense of a longer wait during the level load phase while the textures and skins are loaded + from disk.
  • +
  • Individual user profile support. See this section for more + information.
  • +
+ +

Known Issues

+
    +
  • You may have instances where the game goes out of sync. The master can often restart the game + from the menu without everyone having to restart the game from scratch, and things should be + fine.
  • +
  • A test version in the near future will include my new sound code that supports OggVorbis and + other sound formats. For now, the existing AudioLib code is in use.
  • +
+ +

Individual User Profiles

+ +

With Windows 2000 and XP, having multiple user accounts for different people on the one computer has + been very easy, with XP especially so. Linux, BSD, and other *nix-like OS users have had this ability + forever and now JFDuke3D properly supports installations where each user can have his/her own set of + configuration and savegame files without interfering with other players on the same PC. On Windows the + default mode of behaviour is the same as in previous versions: everything is shared, but it is now possible + to enable "user profile mode". Linux/BSD users will run in "user profile mode" permanently; your personal + files will be located in ~/.jfduke3d so if you used previous versions of the port, you will + have to move your config and savegames there. Windows users can turn on "user profile mode" by creating an + empty file in the JFDuke3D directory named 'user_profiles_enabled'. Here is how:

+
    +
  1. In Windows Explorer, navigate to the JFDuke3D directory.
  2. +
  3. Open the File menu, move to the "New" option, and select "Text Document".
  4. +
  5. Type user_profiles_enabled and press Enter.
  6. +
  7. If a dialog box appears asking to confirm changing the filename extension to one that may + make the file unusable, choose "Yes".
  8. +
+

When you next run JFDuke3D, a JFDuke3D directory will be created in C:\Documents and + Settings\your username\Application Data along with a new configuration file. You will + then have to move your existing DUKE3D.CFG file to this location if you have used the game previously.

+ +

Multiplayer games

+ +

Multiplayer games are started via command-line parameters passed to DUKE3D.EXE. This is a short guide + to getting a multiplayer game running between these three hypothetical computers:

+ + + + + + + + + + +
Host nameIP address
faye192.168.1.2
asuka192.168.1.5
kaoru192.168.1.6
+

Keep in mind that the networking features are still being refined and there are + certain issues and caveats to be aware of when using it. The basic syntax of the network command + line is like so: DUKE3D (normal game parameters) /net (network parameters)

+ + + + + + + + + + + + + + + + + +
Network parameters
/nx:yGame comm type. x = 0 for master/slave or 1 for peer-to-peer.
+ If unspecified, y defaults to 2. For more than two players in a + master-slave game, you have to indicate the number on the master. + eg: /n0 or /n0:4
/pxOverrides the default port (23513) with x being the new port value.
address:portAn address of a machine. See the items below for more information.
+ +

Master/Slave mode

+

This mode is the easiest mode for use with Internet play since it requires only the address of the master + of the game (the person hosting the game) be specified by each slave who joins. Here are example command + lines each machine must run to join the game hosted by the machine named 'asuka': +

+ + + + +
asukaDUKE3D.EXE /net /n0:3
fayeDUKE3D.EXE /net /n0 192.168.1.5
kaoruDUKE3D.EXE /net /n0 192.168.1.5
+ +

Peer-to-peer mode

+

This mode is often useful for playing on a LAN where it is easier to coordinate and organise the order of + peers in the game. This mode will become simpler to set up in the future but for now this is how to do + it. Peer-to-peer mode requires each machine specify the addresses of each other machine in the game in the + same order, but indicating its own position in the sequence with the /n1 option.

+ + + + +
asukaDUKE3D.EXE /net /n1 192.168.1.2 192.168.1.6
fayeDUKE3D.EXE /net 192.168.1.5 /n1 192.168.1.6
kaoruDUKE3D.EXE /net 192.168.1.5 192.168.1.2 /n1
+ +

Addresses and ports

+

The networking code is capable of resolving WINS host names (on Windows) and DNS names to their + corresponding addresses, so if your network is configured with such services, instead of having to specify + raw IP addresses, you can give the computer's WINS host name or a DNS host name.

+

The default port the game communicates on is 23513. Some users may find it necessary to set up a + forward through their Internet firewall in order to get games working when playing across the Internet. + You can override the default port via the /p??? switch where ??? is the new + port number. If a master is running a game on a port other than the default, the slaves will have to + specify the alternative port with address:port notation, eg. 192.168.1.5:20000

+ +

3D Models

+ +

Polymost uses the Quake II MD2 and Quake III MD3 format for 3D models. You can replace any wall-aligned or + face sprite in the game with a 3D model using a declaration in the DUKE3D.DEF file. For more information + on the specifics of the DEF-file commands for 3D models, see here.

+

Included in this release is a model of the Pig Cop by Parkar, and the skin by Motionblur. You should + visit this site for a much larger pack of + textures and models. I shall use this model to demonstrate how to replace the Pig Cop character in Duke.

+ +

Here is the definition for the pig cop which is also included in the sample DUKE3D.DEF file.

+
+   //New syntax:
+model "models/pigcop.md2"
+{
+   scale 1.30 shade 0
+   skin { pal 0 file "models/pigcop.jpg" }
+   anim { frame0 "walk0" frame1 "walk13" fps 20 flags 0 }
+   frame { name "walk0" tile0 2000 tile1 2019 }
+
+   anim { frame0 "pump0" frame1 "pump2" fps 10 flags 1 }
+   frame { name "pump0" tile0 2025 tile1 2027 }
+
+   frame { name "stand" tile0 2030 tile1 2034 }
+
+   anim { frame0 "shoot0" frame1 "shoot2" fps 10 flags 1 }
+   frame { name "shoot0" tile0 2035 tile1 2037 }
+
+   anim { frame0 "dive0" frame1 "dive3" fps 8 flags 1 }
+   frame { name "dive0" tile0 2040 tile1 2044 }
+   frame { name "dive3" tile0 2045 tile1 2049 }
+
+   anim { frame0 "dshoot0" frame1 "dshoot2" fps 10 flags 1 }
+   frame { name "dshoot0" tile0 2050 tile1 2052 }
+
+   frame { name "die0" tile 2055 }
+   anim { frame0 "die1" frame1 "dead" fps 13 flags 1 }
+   frame { name "die1" tile0 2056 tile1 2059 }
+   frame { name "dead" tile 2060 }
+}
+
+
+   //Old syntax:
+definemodel "models/pigcop.md2" 1.30 0
+definemodelskin 0 "models/pigcop.jpg"
+
+definemodelanim "walk0" "walk13" 20 0
+definemodelframe "walk0" 2000 2019
+
+definemodelanim "pump0" "pump2" 10 1
+definemodelframe "pump0" 2025 2027
+
+definemodelframe "stand" 2030 2034
+
+definemodelanim "shoot0" "shoot2" 10 1
+definemodelframe "shoot0" 2035 2037
+
+definemodelanim "dive0" "dive3" 8 1
+definemodelframe "dive0" 2040 2044
+definemodelframe "dive3" 2045 2049
+
+definemodelanim "dshoot0" "dshoot2" 10 1
+definemodelframe "dshoot0" 2050 2052
+
+definemodelframe "die0" 2055 2055
+definemodelanim "die1" "dead" 13 1
+definemodelframe "die1" 2056 2059
+definemodelframe "dead" 2060 2060
+

Without going through every line of the example, here is the basis of how the definitions work. + You must put a + definemodel line before any other definemodelframe or definemodelanim lines. The frame and anim lines + refer the the definemodel line which precedes them. You can define frames and animations in any order, ie. + the animations do not need to be given before the frames, but it is a good convention to keep them + together for clarity.

+

The walking loop for the pig cop spans tiles 2000 to 2019. The model contains a fourteen frame walking + animation which we play at 20 frames per second. The first line of the example specifies the + "models/pigcop.md2" model should be drawn at 1.3 times its normal scale and be left undarkened or + lightened. The definemodelskin line specifies the skin to use for palette 0 for all the definemodelframe + lines that follow it. The first of the definemodelanim lines declares the fourteen frame walking animation + at 20fps which should loop (the 0 for the flags parameter says to loop). The definemodelframe line which + follows it maps the ART tiles from 2000 through to 2019 to play the walking animation. Because the name in + the definemodelframe line matches the first frame of the definemodelanim line, the animation will + automatically play.

+ +

Quake II and Quake III are registered trademarks of id + Software

+ +

DEF-file Language

+ +

Documentation of the DEF file language can now be found on my website as the information there is + common to all JFBuild-based ports.

+ +

Map Hack scripts

+ +

"Map Hack" scripts are files that override certain aspects of a map file when it is rendered in OpenGL + Polymost mode. Currently they allow for angle adjustment on sprites, and the ability to prevent particular + sprites from being drawn as a model. These are useful for making small corrections to ornamental sprites in + a way that doesn't require modifying the original map.

+

The game will automatically load a map hack script whenever a map is loaded. The script should have the + same base name as the original .MAP file, but with an .MHK extension. The map hack language is described + below. It uses the same parser as DEF files, so you can use comments in the same way.

+ +
+
sprite number
+
Begins a sprite definition. number is the sprite number to affect. You can find this in + the Build editor by highlighting the sprite in 2D mode and pressing Control+Tab. The next group of + commands describe the changes to make to the sprite. +
+
notmd
+ notmd2
+ notmd3
+
Prevents the sprite from being drawn as a model. It gets drawn as a regular sprite + instead. notmd2 and notmd3 are synonyms for + notmd.
+ +
nomdanim
+ nomd2anim
+ nomd3anim
+
Prevents model animation from playing if the sprite is being drawn as a model. + nomd2anim and nomd3anim are synonyms for + nomdanim.
+ +
angleoff angle
+ angoff angle
+
Adds angle to the angle of the sprite just before it is rendered. This is good + for fixing up things like toilet sprites that are facing the wrong way. + angoff is a synonym for angleoff.
+
+
+ +

Here is an example map hack script:

+
// Map hack file for JFDuke3D
+// Level: E1L2.MAP (Original Atomic Edition version)
+// Prepared by jonof@edgenetwork.org
+
+// Invisible switch behind hand dryer in toilet of porn shop
+sprite 191 notmd2
+
+// Invisible switches on telephones near billiards room in club
+sprite 254 notmd2
+sprite 517 notmd2
+
+// Toilet in restroom in club
+sprite 478 angoff -512
+ +

Hightile

+ +

This release features the "Hightile" texturing improvements to Polymost. Hightile allows Polymost to use + true-colour textures instead of the artwork in the game's usual .ART file.

+

Replacement textures can be saved as JPEG, PNG (alpha channel supported), TGA, BMP, CEL, GIF, and PCX + formats. Hightile uses Ken Silverman's picture library to provide rapid picture file loading.

+

Hightile textures are defined in the DUKE3D.DEF file. See the DEF-file language + reference for information on how to specify Hightile textures.

+ +

Limitations to Hightile

+
    +
  • Hightile will squash or stretch the replacement to fit in the dimensions of the original tile + it replaces. Artists should keep their replacements in the same ratio as the original tile for the + art to not look distorted.
  • +
+ +

ZIP file support

+ +

Duke (and Build games in general) can load game resources from a ZIP file.

+

ZIP files are used in Duke in the same manner as extra GRP files are specified. Use the "/g" command-line + switch to specify the ZIP to load. eg. DUKE3D.EXE /gMYFILE.ZIP

+ +

Polymost

+ +

Polymost is a full 3D implementation of the Build engine renderer, with hardware acceleration capability, + and perspective in six degrees of freedom. In Ken's own words (copied from POLYMOST.C in my Build engine + source distribution):

+
+"POLYMOST" code written by Ken Silverman
+Ken Silverman's official web site: http://www.advsys.net/ken
+
+Motivation:
+When 3D Realms released the Duke Nukem 3D source code, I thought somebody would do a OpenGL or
+Direct3D port. Well, after a few months passed, I saw no sign of somebody working on a true
+hardware-accelerated port of Build, just people saying it wasn't possible. Eventually, I realized
+the only way this was going to happen was for me to do it myself. First, I needed to port Build to
+Windows. I could have done it myself, but instead I thought I'd ask my Australian buddy, Jonathon
+Fowler, if he would upgrade his Windows port to my favorite compiler (MSVC) - which he did. Once
+that was done, I was ready to start the "POLYMOST" project.
+
+About:
+This source file is basically a complete rewrite of the entire rendering part of the Build engine.
+There are small pieces in ENGINE.C to activate this code, and other minor hacks in other source
+files, but most of it is in here. If you're looking for polymost-related code in the other source
+files, you should find most of them by searching for either "polymost" or "rendmode". Speaking of
+rendmode, there are now 4 rendering modes in Build:
+
+    rendmode 0: The original code I wrote from 1993-1997
+    rendmode 1: Solid-color rendering: my debug code before I did texture mapping
+    rendmode 2: Software rendering before I started the OpenGL code (Note: this is just a quick
+                hack to make testing easier - it's not optimized to my usual standards!)
+    rendmode 3: The OpenGL code
+
+The original Build engine did hidden surface removal by using a vertical span buffer on the tops
+and bottoms of walls. This worked nice back in the day, but it it's not suitable for a polygon
+engine. So I decided to write a brand new hidden surface removal algorithm - using the same idea
+as the original Build - but one that worked with vectors instead of already rasterized data.
+		
+

Polymost is the default renderer choice for any video mode with a colour depth greater than 256 + colours.

+

NOTE: If your computer does not have an OpenGL graphics card, Polymost in OpenGL mode + will most likely use the default Windows OpenGL rasterising facility which does all rendering in software. + This may be extremely slow. If your Windows installation doesn't have any form of OpenGL rendering ability, + Polymost will probably crash.

+

NOTE 2: OpenGL Polymost has been tested on an nVidia Riva TNT 16MB, an nVidia GeForce2 + GTS 32MB, an nVidia GeForce4 Ti4600 128MB, an nVidia GeForce 6800GT 256MB, an ATi Radeon Mobility 9000 64MB, + and a 3D-Labs Oxygen GVX420 128MB (minor texturing issues).

+ +

Console Commands

+ +

This is a list of console commands and variables and their purpose:

+ +
+
changelevel <episode> <level>
+
Warps to a new level.
+ +
dumpbuildinfo
+
Displays the compilation information for the game when it was built.
+ +
echo <text...>
+
Displays to the console what is passed as parameters to the command.
+ +
fileinfo <filename>
+
Displays some information about a given file, eg. size, CRC-32 checksum.
+ +
glinfo
+
Displays some information about the OpenGL driver.
+ +
glredbluemode <0 or 1>
+
Enables or disables the red-blue stereovision mode in OpenGL. This mode is experimental + at this time. We know the flicker is nasty and the menu background will mix into the screen. + To avoid the menu bug, run the game in fullscreen mode and type "glredbluemode 1" AFTER + beginning the game. Sorry, there is no way to change parallax or separation. Do not contact + us about bugs with this mode... if you do, we'll think twice about documenting hidden features + in future releases. :P
+ +
gltextureanisotropy <level>
+
Sets the OpenGL anisotropic filtering level.
+ +
gltexturemode <mode-number>
+
Sets the OpenGL texturing mode. Valid values are: + + + + + + + +
0GL_NEAREST (looks rather like the original software renderer)
1GL_LINEAR
2GL_NEAREST_MIPMAP_NEAREST
3GL_LINEAR_MIPMAP_NEAREST (bilinear)
4GL_NEAREST_MIPMAP_LINEAR
5GL_LINEAR_MIPMAP_LINEAR (trilinear)
+ +
glusetexcompr <0 or 1>
+
Enables or disables the use of OpenGL texture compression for hightile textures. You need + to use 'restartvid' to apply any changes to this value.
+ +
god
+
Enables God mode.
+ +
help <name>
+
Displays a help message for a particular console variable or command.
+ +
listsymbols
+
Displays the names of all commands and variables available in the console.
+ +
map <mapname>
+
Loads a user map.
+ +
noclip
+
Disables player collisions with world objects.
+ +
novoxmips <0 or 1>
+
Disables or enables the use of voxel mipmaps to improve voxel visual quality.
+ +
osdrows <num>
+
Sets the number of visible lines of the console when it is open.
+ +
quit
+
Exits the game.
+ +
restartvid
+
Resets the video system, reinitialising the video mode.
+ +
screencaptureformat <0 or 1>
+
0 = Targa, 1 = PCX
+ +
setrendermode <mode>
+
Sets the current Polymost render mode.
+ +
setstatusbarscale <percent>
+
Sets the size of the status bar as a percentage of its original full-width size. Minimum size is + 10%, maximum 100%.
+ +
showcoords <0 or 1>
+
Same as typing "DNCOORDS" cheat.
+ +
showfps <0 or 1>
+
Shows/hides the framerate counter. Same as typing "DNRATE" cheat.
+ +
spawn <tile-number or name> [pal] [cstat] [angle] [x y z]
+
Places a sprite of the given tile number or name at the current position, or if given, the "x + y z" location. A name is a label defined in the CON code. The sprite may be spawned with a + specific palette, cstat value, and angle if those parameters are given.
+ +
usegoodalpha <0 or 1>
+
If 1, a lower alpha cutoff value is used when rendering textures with transparency, which + gives better looking transparent textures at the expense of some sprites behind the transparent + item potentially being invisible in certain circumstances. 0 is a more compatible value (and is + the default) for this option but slight visual degradation will result.
+ +
usehightile <0 or 1>
+
Disables or enables the use of Hightile textures in GL Polymost mode if any are defined.
+ +
usemodels <0 or 1>
+
Disables or enables the use of 3D models in GL Polymost mode if any are defined.
+ +
usevoxels <0 or 1>
+
Disables or enables the use of voxels in the classic renderer if any are defined.
+ +
vidmode [xres yres] [bpp]
+
Changes the current video mode. You may pass either a new resolution (eg 640 480), + a new colour depth (eg 32), or both a resolution and colour depth (eg 640 480 32).
+ +
bpp <colourdepth>
+
Sets the display colour depth. Does not apply it immediately though. You need to use + 'restartvid' after setting this if you want to apply the change.
+
+ +
Happy Duke'ing!
+ Jonathon Fowler (jonof@edgenetwork.org)
+ + + diff --git a/polymer/eduke32/makemsc.bat b/polymer/eduke32/makemsc.bat new file mode 100644 index 000000000..19243ed20 --- /dev/null +++ b/polymer/eduke32/makemsc.bat @@ -0,0 +1 @@ +nmake /f Makefile.msvc %1 %2 %3 %4 %5 diff --git a/polymer/eduke32/makew.bat b/polymer/eduke32/makew.bat new file mode 100644 index 000000000..7184b0f08 --- /dev/null +++ b/polymer/eduke32/makew.bat @@ -0,0 +1 @@ +wmake -f Makefile.watcom %1 %2 %3 %4 %5 diff --git a/polymer/eduke32/obj/keep.me b/polymer/eduke32/obj/keep.me new file mode 100644 index 000000000..e69de29bb diff --git a/polymer/eduke32/rsrc/build.bmp b/polymer/eduke32/rsrc/build.bmp new file mode 100644 index 000000000..431d8ebe7 Binary files /dev/null and b/polymer/eduke32/rsrc/build.bmp differ diff --git a/polymer/eduke32/rsrc/build_icon.bmp b/polymer/eduke32/rsrc/build_icon.bmp new file mode 100644 index 000000000..fdb5e8899 Binary files /dev/null and b/polymer/eduke32/rsrc/build_icon.bmp differ diff --git a/polymer/eduke32/rsrc/build_icon.c b/polymer/eduke32/rsrc/build_icon.c new file mode 100644 index 000000000..d891ba084 --- /dev/null +++ b/polymer/eduke32/rsrc/build_icon.c @@ -0,0 +1,192 @@ +#include "sdlayer.h" + +static unsigned int sdlappicon_pixels[] = { + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffff2e6, 0xffffd2a3, + 0xffffb66e, 0xfffeaf5c, 0xfffeaf5c, 0xffffb15f, 0xfffeaf5c, 0xffffaa5a, + 0xffffab5b, 0xfffdb879, 0xffffd2a3, 0xfffff1e4, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xffffe8cc, 0xffffb66e, + 0xffffab5b, 0xfffdce9f, 0xfffde5c9, 0xfffff1e4, 0xfffefbf6, 0xfffff7ee, + 0xfffff2e6, 0xffffddb8, 0xfffecfa1, 0xffffc78c, 0xffffb66e, 0xffffa546, + 0xfffeb36b, 0xffffe8cc, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffefbf6, 0xffffbb7b, + 0xfffda241, 0xffffd7ad, 0xfffff7ee, 0xfffffcfe, 0xfffffcfe, 0xfffffcfe, + 0xfffcfffe, 0xfffffcfe, 0xfffcfffe, 0xfffcf4eb, 0xffffe7d3, 0xfffcdebe, + 0xfffbd1b0, 0xffffd8ae, 0xfffcc69b, 0xffffa546, 0xffffbb7b, 0xfffefbf6, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xffffe8cc, + 0xffff9e3e, 0xfffdb879, 0xffffe1c9, 0xffffecdd, 0xfffffdf7, 0xfffcfffe, + 0xfffff7ee, 0xffffe2c2, 0xffffd2a3, 0xfffec58a, 0xffffc07e, 0xffffc78c, + 0xffffd8ae, 0xffffe7d3, 0xffffe9cd, 0xffffeed6, 0xffffeed6, 0xfffff2e6, + 0xfffdce9f, 0xffff9e3e, 0xffffe8cc, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xffffe7d3, 0xffff9835, 0xffffbd73, 0xffffcc98, 0xfffddab5, 0xfffff8f7, + 0xfffce4c8, 0xffffc07e, 0xffffa556, 0xffff9835, 0xfffe9631, 0xffff8b1d, + 0xffff8500, 0xffff8400, 0xffff8500, 0xffff912b, 0xffffb66e, 0xffffe1c1, + 0xfffff7ee, 0xfffff7ee, 0xfffcfffe, 0xffffe0c8, 0xffff9d3c, 0xffffe8cc, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffeeada, 0xffff912b, 0xfffdb879, 0xffffbb7b, 0xfffddfbf, + 0xffffe7d3, 0xfffeaf5c, 0xffff8500, 0xffff870e, 0xfffe9631, 0xffff9d3c, + 0xffff9835, 0xffff9835, 0xffff912b, 0xffff870e, 0xffff8400, 0xffff8400, + 0xffff7f00, 0xffff870e, 0xffffb66e, 0xfffff7ee, 0xfffcfffe, 0xfffffdf7, + 0xfffdebd3, 0xffff9835, 0xfffce8d8, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffefbf6, 0xffff9d3c, 0xfffdb26a, 0xffffbb7b, + 0xfffdd5ab, 0xffffe0c8, 0xffff9d3c, 0xffff912b, 0xffff8400, 0xffff8b1d, + 0xffff9b21, 0xffff9e3e, 0xffff9e3e, 0xffff9b21, 0xffff8b1d, 0xffff8800, + 0xffff8500, 0xffff8400, 0xffff870e, 0xfffe8125, 0xffff8400, 0xfffea857, + 0xfffff1e4, 0xfffffbfd, 0xfffdeee2, 0xffffd2a3, 0xffff9d3c, 0xfffffdf7, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xffffbb7b, 0xffffb66e, + 0xfffeca96, 0xffffddb8, 0xffffdabe, 0xfffb870b, 0xffeb8500, 0xfffb870b, + 0xffffaa5a, 0xffffaa5a, 0xffff912b, 0xffff9835, 0xffff9d3c, 0xffff9835, + 0xffff912b, 0xffff870e, 0xffff7d1a, 0xffff8400, 0xffff9835, 0xfffeaf5c, + 0xffff912b, 0xffff8a19, 0xffff9406, 0xffffe2c2, 0xfffff1e4, 0xfffce4c8, + 0xffffc07e, 0xffffbb7b, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xffffe9cd, + 0xffff9d3c, 0xffffd8ae, 0xfffdd5ab, 0xfffeeada, 0xffeb8500, 0xffeb8500, + 0xffeb7f00, 0xfffdb26a, 0xfffdfaf5, 0xfffee4d0, 0xfff28500, 0xffde7110, + 0xffce6715, 0xffb25903, 0xffb35a07, 0xffc66000, 0xffd86b00, 0xfff17c13, + 0xffffcb97, 0xfffffdf7, 0xffffc07e, 0xffff8a19, 0xffff7f00, 0xffff9b21, + 0xfffeeeea, 0xffffddb8, 0xfffdd5ab, 0xffff9d3c, 0xfffeeada, 0xfffcfffe, + 0xfffcfffe, 0xffffb66e, 0xfffdc995, 0xfffce4c8, 0xfffff2e6, 0xffffab5b, + 0xfffc8e23, 0xfffb870b, 0xfff9af67, 0xfffff2e6, 0xffffc594, 0xfffcc69b, + 0xffe9994f, 0xff8f5800, 0xff994e00, 0xff974a16, 0xff9d4c00, 0xff994e00, + 0xff8c4800, 0xffcb6a1c, 0xfffbd1b0, 0xfffff7ee, 0xfffcfffe, 0xffffbb7b, + 0xffff7f00, 0xffff8800, 0xffffab5b, 0xffffe7d3, 0xfffdcda7, 0xffffbd73, + 0xffffb15f, 0xfffcfffe, 0xfffff2e6, 0xfffea343, 0xfffee4d0, 0xfffff2e6, + 0xffffe1c1, 0xffff7f00, 0xffff8a19, 0xfffda241, 0xfffff2e6, 0xffffc280, + 0xffff9835, 0xffffe0c8, 0xfffce8d8, 0xffb66a12, 0xff944f00, 0xffa24f07, + 0xffa24f07, 0xff9d4c00, 0xff975e05, 0xffe8b993, 0xffffe7d3, 0xffffaa5a, + 0xffffe7d3, 0xfffffdf7, 0xffff9e3e, 0xffff8f00, 0xfffe8300, 0xffffd8ae, + 0xffffdabe, 0xffffcc98, 0xffff9d3c, 0xfffcf4eb, 0xffffd2a3, 0xffffbb7b, + 0xffffe8cc, 0xfffff2e6, 0xfffdb879, 0xffff7f00, 0xffff8800, 0xfffcdcc5, + 0xfffdeee2, 0xffffa556, 0xffffdabe, 0xfffcfffe, 0xfffffcfe, 0xffebb180, + 0xff9b5c03, 0xff924d00, 0xff944f00, 0xff8e4f00, 0xffcc7311, 0xfffffcfe, + 0xfffffcfe, 0xfffee2b9, 0xffffaa5a, 0xffffebdb, 0xffffd8ae, 0xfffe8300, + 0xffff9406, 0xffffb15f, 0xffffe8cc, 0xffffd2a3, 0xffffb66e, 0xffffd2a3, + 0xffffb66e, 0xffffc594, 0xfffee4d0, 0xffffe8cc, 0xffff9835, 0xfffe8300, + 0xffffab5b, 0xfffffef9, 0xfffecfa1, 0xffffbd73, 0xfffffcfe, 0xfffcfffe, + 0xfffcfffe, 0xfffcf9f4, 0xffd06b00, 0xffb26000, 0xffbf6000, 0xffae6f17, + 0xfffcbe7c, 0xfffcfffe, 0xfffffcfe, 0xfffffef9, 0xffffb66e, 0xffffc07e, + 0xfffff2e6, 0xffff9d3c, 0xfffc8e23, 0xffff8b1d, 0xffffe7d3, 0xffffd8ae, + 0xffffc07e, 0xffffb66e, 0xffffaa5a, 0xffffd2a3, 0xfffdebd3, 0xfffbd1b0, + 0xffff8400, 0xffff7f00, 0xfffdc995, 0xfffff7ee, 0xfffdac66, 0xfffdf0dc, + 0xfffcfffe, 0xfffcfffe, 0xfffffcfe, 0xfffffcfe, 0xfffdf0dc, 0xfffff1e4, + 0xfffffdf7, 0xfffce4c8, 0xfffcfffe, 0xfffffcfe, 0xfffcfffe, 0xfffcfffe, + 0xfffdf0dc, 0xffffa556, 0xfffeeada, 0xffffc78c, 0xffff8a19, 0xfffe8125, + 0xffffd2a3, 0xfffce4c8, 0xfffdcda7, 0xfffdac66, 0xffffaa5a, 0xffffd8ae, + 0xffffefd7, 0xffffc78c, 0xffff7f00, 0xffff8800, 0xffffddb8, 0xffffe2c2, + 0xffff9e3e, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffeeeea, 0xfff1e7ca, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffffdf7, 0xffff9e3e, 0xffffddb8, 0xffffd8ae, + 0xffff8400, 0xffff8400, 0xffffc594, 0xffffe9cd, 0xffffd7ad, 0xffffaa5a, + 0xfffdae5b, 0xffffe7d3, 0xfffff7ee, 0xffffc280, 0xffff7f00, 0xffff8e00, + 0xfffdeee2, 0xffffe9cd, 0xfffeca96, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfff6dec2, 0xffad6806, 0xff926700, 0xffe98300, + 0xfffffbfd, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xffffc594, + 0xfffee4d0, 0xffffeed6, 0xffff8e00, 0xffff8500, 0xffffbd73, 0xffffecdd, + 0xffffddb8, 0xffffab5b, 0xffffab5b, 0xffffecdd, 0xfffdf9fb, 0xffffc07e, + 0xffff8400, 0xffff9406, 0xffffc594, 0xfffdce9f, 0xffe7ba8b, 0xffdfb78e, + 0xffdfb283, 0xffddb081, 0xffefbb8f, 0xfffcfffe, 0xffe0b88f, 0xff8c6000, + 0xff8d4d17, 0xffb86700, 0xfffdfaf5, 0xffffebdb, 0xffe4b787, 0xffddb081, + 0xffe2bb91, 0xffe6b98a, 0xfffeca96, 0xffffbb7b, 0xffff8500, 0xfffe8125, + 0xffffc280, 0xffffecdd, 0xfffedbb6, 0xffffaa5a, 0xffffb15f, 0xffffecdd, + 0xfffffdf7, 0xfffdcda7, 0xffff8b1d, 0xffff8e00, 0xffff8800, 0xffff8500, + 0xffc0670d, 0xff8a5203, 0xff935500, 0xff845200, 0xffb26d16, 0xfffeeeea, + 0xfffdf9fb, 0xffc27611, 0xffa0671c, 0xffeeaf76, 0xfffcfffe, 0xffe9994f, + 0xff926700, 0xff905104, 0xff8a5203, 0xffb26000, 0xffff8400, 0xffff7f00, + 0xfffe8125, 0xffff7f00, 0xffffc594, 0xffffeed6, 0xffffd7ad, 0xfffdae5b, + 0xfffdac66, 0xffffe1c9, 0xfffffef9, 0xffffddb8, 0xffff912b, 0xffff912b, + 0xffff9406, 0xffff8a19, 0xffde7110, 0xff974a16, 0xffa24f07, 0xff9d4c00, + 0xff9a5b00, 0xffe1a369, 0xfffcfffe, 0xfffdfaf5, 0xfffcf4eb, 0xfffcfffe, + 0xfffeeada, 0xffb66a12, 0xff965106, 0xffa24f07, 0xff974a16, 0xffd86b00, + 0xffff7f00, 0xffff8800, 0xffff8400, 0xffff8500, 0xffffd2a3, 0xfffeeada, + 0xfffdcda7, 0xffffaa5a, 0xffffb66e, 0xfffedbb6, 0xfffdfaf5, 0xfffeefe3, + 0xffff9d3c, 0xffff8a19, 0xffff8d23, 0xffff870e, 0xfffa8000, 0xffb25903, + 0xff964b00, 0xff9d4c00, 0xff9d4c00, 0xffad6806, 0xfffbd1b0, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xffdc831c, 0xff8c5914, 0xffa24f07, 0xff994e00, + 0xffa24f07, 0xfff77b10, 0xffff7d1a, 0xffff8500, 0xffff7f00, 0xffff9406, + 0xfffeeada, 0xffffe2c2, 0xffffc78c, 0xfffdb879, 0xffffd2a3, 0xffffc280, + 0xfffdf0dc, 0xfffff7ee, 0xffffb66e, 0xffff7f00, 0xffff870e, 0xfffe8125, + 0xffff7d00, 0xffd46800, 0xff9d4c00, 0xff9d4c00, 0xff935500, 0xffcf7c24, + 0xfffdf9fb, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfff0cbaf, 0xff9f5a00, + 0xff994e00, 0xff9d4c00, 0xffd56900, 0xffff7d1a, 0xfffe8125, 0xfffe8125, + 0xfffe8125, 0xffffb15f, 0xffffecdd, 0xfffddfbf, 0xffffbd73, 0xffffd2a3, + 0xfffff2e6, 0xffffa556, 0xfffde5c9, 0xffffecdd, 0xffffddb8, 0xffff7f00, + 0xfffe8125, 0xffff7f00, 0xffff7f00, 0xffff7a00, 0xffd06b00, 0xff8e4f00, + 0xffaf5e00, 0xfffdf9fb, 0xfffffef9, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffffef9, 0xffe6a261, 0xff975e05, 0xffbf6000, 0xffff7f00, 0xffff7f00, + 0xffff7f00, 0xffff8400, 0xffff8400, 0xffffddb8, 0xfffce4c8, 0xfffdd5ab, + 0xffff9d3c, 0xfffcf4eb, 0xfffffcfe, 0xfffdac66, 0xffffc280, 0xffffddb8, + 0xffffecdd, 0xffffab5b, 0xfffb8d1f, 0xffff7f00, 0xfff77b10, 0xffff7f00, + 0xffff7f00, 0xffcc7311, 0xffe6a261, 0xfffff2e6, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xffffeed6, 0xffffe2c2, 0xffdc831c, 0xffff8400, + 0xffff7a00, 0xffff7f00, 0xffff7f00, 0xffff8f00, 0xffffa546, 0xfffeeada, + 0xffffd2a3, 0xfffdc489, 0xffffb15f, 0xfffcfffe, 0xfffcfffe, 0xffffeed6, + 0xffff9835, 0xfffdcda7, 0xfffdd5ab, 0xfffdebd3, 0xffff9406, 0xfffb870b, + 0xffff7f00, 0xffff7f00, 0xffff7f00, 0xffffa556, 0xffffecdd, 0xfffeaf5c, + 0xffffaa5a, 0xfffeb36b, 0xfffeb36b, 0xffffb15f, 0xffffa041, 0xffffdabe, + 0xffffe1c9, 0xffff8400, 0xffff7f00, 0xffff7f00, 0xffff8a19, 0xffff9406, + 0xffffebdb, 0xffffcc98, 0xfffdcda7, 0xffff9d3c, 0xffffebdb, 0xfffcfffe, + 0xfffffcfe, 0xfffcfffe, 0xffffbd73, 0xffffb15f, 0xfffbd1b0, 0xffffe1c9, + 0xffffe2c2, 0xffff8c00, 0xfffb870b, 0xffff7f00, 0xfffa8000, 0xffffc594, + 0xfffffcfe, 0xfffcf4eb, 0xfffcead2, 0xffffe8cc, 0xfffee4d0, 0xffffe7d3, + 0xfffdfaf5, 0xfffffcfe, 0xfffedbb6, 0xffff8a19, 0xffff8400, 0xffff8c00, + 0xffff8a19, 0xffffe2c2, 0xfffee4d0, 0xffffcc98, 0xffffb66e, 0xffffbd73, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffdf9fb, 0xffff9d3c, + 0xffffbd73, 0xfffdce9f, 0xffffe2c2, 0xfff9dfcc, 0xffff9d3c, 0xffff8c00, + 0xfffe8125, 0xffff8e00, 0xffffaa5a, 0xffffc78c, 0xffffd8ae, 0xffffe7d3, + 0xfffeeada, 0xffffddb8, 0xffffc78c, 0xffffa546, 0xffff8400, 0xffff8400, + 0xffff8a19, 0xffffa12b, 0xfffde5c9, 0xffffe1c9, 0xffffcc98, 0xffffc280, + 0xffff9e3e, 0xfffffcfe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffffef9, + 0xfffcfffe, 0xfffeeada, 0xffff9406, 0xffffc594, 0xffffd2a3, 0xffffe8cc, + 0xfffeeada, 0xffffb15f, 0xfffe8125, 0xffff7f00, 0xffff8400, 0xffff7d1a, + 0xffff8a19, 0xffff9406, 0xffff912b, 0xffff8a19, 0xffff7f00, 0xffff8800, + 0xffff8400, 0xffff7f00, 0xfffdac66, 0xffffecdd, 0xfffdebd3, 0xffffd2a3, + 0xfffdcda7, 0xffff9835, 0xffffe9cd, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffffef9, 0xffffe7d3, 0xffff9b21, + 0xffffc280, 0xfffddab5, 0xfffddfbf, 0xfffff2e6, 0xffffe2c2, 0xffffb66e, + 0xffff9835, 0xffff8a19, 0xffff8500, 0xffff7f00, 0xffff8400, 0xffff8400, + 0xffff870e, 0xffff9835, 0xffffb76f, 0xffffddb8, 0xffffecdd, 0xffffdabe, + 0xffffdabe, 0xffffc594, 0xffff9b21, 0xfffdebd3, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffffcfe, 0xfffee4d0, 0xffff9e3e, 0xffffbb7b, 0xffffe2c2, 0xffffe2c2, + 0xfffff3e7, 0xfffff3e7, 0xffffebdb, 0xffffd8ae, 0xfffecfa1, 0xffffc280, + 0xffffc78c, 0xffffd2a3, 0xffffd8ae, 0xfffdebd3, 0xfffdf0dc, 0xfffdebd3, + 0xffffddb8, 0xffffddb8, 0xffffc280, 0xffffa041, 0xffffe7d3, 0xfffffef9, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffffdf7, 0xffffbd73, + 0xffff9e3e, 0xffffcc98, 0xffffe2c2, 0xffffe9cd, 0xffffe8cc, 0xfffff1e4, + 0xfffff2e6, 0xfffdf9fb, 0xfffffdf7, 0xfffff2e6, 0xffffecdd, 0xfffee4d0, + 0xffffe7d3, 0xffffdabe, 0xfffeca96, 0xffff9e3e, 0xffffbb7b, 0xfffffcfe, + 0xfffffef9, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffffcfe, 0xfffcfffe, 0xffffe7d3, 0xffffb361, 0xffffa546, 0xffffc07e, + 0xffffcc98, 0xffffd8ae, 0xffffe2c2, 0xffffecdd, 0xfffdeee2, 0xffffe8cc, + 0xffffd8ae, 0xffffc78c, 0xffffc07e, 0xffffa546, 0xffffb66e, 0xffffe1c9, + 0xfffffef9, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffffef9, 0xfffcfffe, + 0xfffff2e6, 0xfffdcda7, 0xffffb66e, 0xffffab5b, 0xffffaa5a, 0xffffaa5a, + 0xffffab5b, 0xffffaa5a, 0xffffaa5a, 0xffffbb7b, 0xffffd2a3, 0xfffff2e6, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, + 0xfffcfffe, 0xfffcfffe, 0xfffcfffe, 0xfffcfffe,}; + +static unsigned char sdlappicon_mask[] = { + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255,}; + +struct sdlappicon sdlappicon = { + 32,32, // width,height + sdlappicon_pixels, + sdlappicon_mask +}; diff --git a/polymer/eduke32/rsrc/build_icon.ico b/polymer/eduke32/rsrc/build_icon.ico new file mode 100644 index 000000000..b2e6dc75f Binary files /dev/null and b/polymer/eduke32/rsrc/build_icon.ico differ diff --git a/polymer/eduke32/rsrc/editor_banner.c b/polymer/eduke32/rsrc/editor_banner.c new file mode 100644 index 000000000..08b17c49a --- /dev/null +++ b/polymer/eduke32/rsrc/editor_banner.c @@ -0,0 +1,3310 @@ +#include +/* GdkPixbuf RGB C-Source image dump */ + +const GdkPixdata startbanner_pixdata = { + 0x47646b50, /* Pixbuf magic: 'GdkP' */ + 24 + 84000, /* header length + pixel_data length */ + 0x1010001, /* pixdata_type */ + 300, /* rowstride */ + 100, /* width */ + 280, /* height */ + /* pixel_data: */ + "\232\255\332\241\264\345\241\264\345\241\264\345\255\274\347\250\266" + "\334\241\264\345\255\274\347\255\274\347\255\274\347\255\274\347\255" + "\274\347\255\274\347\255\274\347\255\274\347\255\274\347\267\307\352" + "\250\266\334\267\307\352\306\313\352\326\332\371\326\332\353\335\345" + "\373\355\357\373\355\357\373\355\357\373\377\377\377\377\377\377\377" + "\377\377\377\377\377\355\357\373\326\332\353\311\324\353\335\345\373" + "\355\357\373\355\357\373\335\345\373\355\357\373\335\345\373\335\345" + "\373\311\324\353\311\324\353\335\345\373\335\345\373\335\345\373\355" + "\357\373\355\357\373\355\357\373\355\357\373\355\357\373\355\357\373" + "\355\357\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\241\264\345\250\266\334" + "\241\264\345\241\264\345\267\307\352\255\274\347\255\274\347\255\274" + "\347\267\307\352\267\307\352\253\304\355\255\274\347\267\307\352\267" + "\307\352\267\307\352\267\307\352\311\324\353\311\324\353\326\332\353" + "\335\345\373\355\357\373\377\377\377\355\357\373\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\355\357\373\355\357\373\355" + "\357\373\335\345\373\326\332\353\335\345\373\355\357\373\355\357\373" + "\335\345\373\335\345\373\335\345\373\335\345\373\311\324\353\267\307" + "\352\311\324\353\306\312\367\326\332\371\326\332\371\326\332\371\311" + "\324\353\326\332\371\326\332\353\326\332\353\335\345\373\355\357\373" + "\355\357\373\355\357\373\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\243\275\346\241\264\345\255\274\347\241\264\345" + "\255\274\347\255\274\347\255\274\347\255\274\347\255\274\347\255\274" + "\347\267\307\352\267\307\352\271\325\373\267\307\352\267\307\352\311" + "\324\353\335\345\373\355\357\373\355\357\373\355\357\373\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\355\357\373\355\357\373\311" + "\324\353\326\332\353\355\357\373\335\345\373\355\357\373\335\345\373" + "\335\345\373\335\345\373\326\332\371\267\307\352\267\307\352\267\307" + "\352\306\313\352\306\313\352\267\307\352\306\313\352\306\313\352\326" + "\332\371\326\332\353\311\324\353\335\345\373\335\345\373\355\357\373" + "\355\357\373\355\357\373\377\377\377\355\357\373\377\377\377\355\357" + "\373\355\357\373\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\241" + "\264\345\250\266\334\241\264\345\253\304\355\250\266\334\255\274\347" + "\267\307\352\255\274\347\255\274\347\255\274\347\267\307\352\255\274" + "\347\310\327\371\310\327\371\311\324\353\311\324\353\355\357\373\355" + "\357\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\355\357\373\326\332\353\326\332\353\355" + "\357\373\355\357\373\355\357\373\355\357\373\355\357\373\335\345\373" + "\326\332\371\306\313\352\306\313\352\255\274\347\306\313\352\267\307" + "\352\306\313\352\326\332\371\335\345\373\335\345\373\335\345\373\326" + "\332\371\311\324\353\326\332\353\335\345\373\355\357\373\355\357\373" + "\377\377\377\377\377\377\377\377\377\355\357\373\355\357\373\355\357" + "\373\355\357\373\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\255\274\347\241\264\345\241" + "\264\345\267\307\352\250\266\334\255\274\347\267\307\352\267\307\352" + "\255\274\347\267\307\352\270\311\367\255\274\347\335\345\373\335\345" + "\373\335\345\373\311\324\353\355\357\373\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\355\357\373\377\377\377\377\377\377\377\377\377\377\377" + "\377\355\357\373\355\357\373\326\332\353\335\345\373\377\377\377\355" + "\357\373\355\357\373\355\357\373\355\357\373\335\345\373\310\327\371" + "\310\327\371\267\307\352\306\313\352\310\327\371\335\345\373\335\345" + "\373\335\345\373\335\345\373\335\345\373\335\345\373\306\313\352\311" + "\324\353\326\332\371\335\345\373\355\357\373\355\357\373\377\377\377" + "\377\377\377\355\357\373\355\357\373\355\357\373\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\270\311\367\241\264\345\232\255\332\241\264\345\267" + "\307\352\255\274\347\270\311\367\310\327\371\270\311\367\310\327\371" + "\310\327\371\267\307\352\267\307\352\306\341\374\326\332\371\311\324" + "\353\355\357\373\355\357\373\377\377\377\355\357\373\377\377\377\355" + "\357\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\355\357\373\355\357" + "\373\326\332\353\324\324\334\355\357\373\377\377\377\377\377\377\355" + "\357\373\355\357\373\335\345\373\326\332\371\326\332\371\306\313\352" + "\311\324\353\310\327\371\335\345\373\335\345\373\326\332\353\311\324" + "\353\326\332\353\326\332\353\306\312\367\310\327\371\311\324\353\326" + "\332\353\335\345\373\355\357\373\355\357\373\355\357\373\355\357\373" + "\355\357\373\355\357\373\355\357\373\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\274\330" + "\350\271\325\373\232\254\344\241\264\345\243\275\346\243\275\346\243" + "\275\346\255\274\347\255\274\347\326\332\371\326\332\371\267\307\352" + "\250\266\334\266\276\323\311\324\353\306\313\352\355\357\373\355\357" + "\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\355\357\373\377\377\377\355\357\373" + "\377\377\377\377\377\377\377\377\377\377\377\377\355\357\373\311\324" + "\353\306\312\367\377\377\377\355\357\373\355\357\373\326\332\371\335" + "\345\373\335\345\373\355\357\373\355\357\373\310\327\371\267\307\352" + "\267\307\352\311\324\353\267\307\352\306\313\352\306\313\352\306\313" + "\352\311\324\353\335\345\373\355\357\373\355\357\373\326\332\353\326" + "\332\353\355\357\373\377\377\377\355\357\373\355\357\373\355\357\373" + "\355\357\373\355\357\373\355\357\373\355\357\373\355\357\373\355\357" + "\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\271\325\373\270\311\367\241\264" + "\345\241\264\345\241\264\345\241\264\345\255\274\347\243\275\346\250" + "\266\334\270\311\367\267\307\352\255\274\347\326\332\371\326\332\371" + "\335\345\373\326\332\353\355\357\373\335\345\373\377\377\377\355\357" + "\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\355\357\373\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\355\357\373\306\313\352\255\274\347\355\357" + "\373\355\357\373\335\345\373\326\332\371\326\332\371\326\332\371\335" + "\345\373\355\357\373\310\327\371\267\307\352\306\313\352\311\324\353" + "\326\332\353\326\332\371\335\345\373\355\357\373\311\324\353\326\332" + "\371\335\345\373\355\357\373\355\357\373\355\357\373\355\357\373\355" + "\357\373\355\357\373\355\357\373\335\345\373\355\357\373\355\357\373" + "\355\357\373\355\357\373\335\345\373\377\377\377\355\357\373\377\377" + "\377\355\357\373\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\267\307\352\270\311\367\241\264\345\232\255\332\232\254" + "\344\241\264\345\253\304\355\255\274\347\250\266\334\274\330\350\267" + "\307\352\267\307\352\355\357\373\355\357\373\355\357\373\355\357\373" + "\355\357\373\355\357\373\355\357\373\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\355\357\373\311\324\353\266\276\323\326\332\353\326\332\371\326\332" + "\371\306\312\367\310\327\371\306\313\352\306\313\352\311\324\353\306" + "\313\352\311\324\353\326\332\371\335\345\373\335\345\373\355\357\373" + "\355\357\373\335\345\373\326\332\371\335\345\373\335\345\373\355\357" + "\373\355\357\373\355\357\373\355\357\373\355\357\373\355\357\373\355" + "\357\373\335\345\373\326\332\353\335\345\373\335\345\373\355\357\373" + "\355\357\373\377\377\377\377\377\377\355\357\373\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\253\304\355" + "\267\307\352\243\275\346\232\255\332\241\264\345\232\254\344\232\255" + "\332\241\264\345\255\274\347\270\311\367\267\307\352\267\307\352\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\355\357\373" + "\377\377\377\355\357\373\377\377\377\355\357\373\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\355\357\373\335\345\373" + "\306\313\352\306\313\352\311\324\353\326\332\371\326\332\371\326\332" + "\371\310\327\371\310\327\371\310\327\371\326\332\371\335\345\373\355" + "\357\373\335\345\373\335\345\373\335\345\373\355\357\373\355\357\373" + "\335\345\373\326\332\371\326\332\353\311\324\353\326\332\353\335\345" + "\373\335\345\373\335\345\373\335\345\373\355\357\373\355\357\373\335" + "\345\373\355\357\373\355\357\373\355\357\373\355\357\373\355\357\373" + "\377\377\377\355\357\373\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\243\275\346\253\304\355\271\325\373" + "\253\304\355\252\271\371\253\304\355\241\264\345\232\255\332\241\264" + "\345\267\307\352\250\266\334\255\274\347\355\357\373\355\357\373\355" + "\357\373\377\377\377\377\377\377\355\357\373\377\377\377\377\377\377" + "\377\377\377\377\377\377\355\357\373\377\377\377\355\357\373\377\377" + "\377\355\357\373\377\377\377\355\357\373\355\357\373\377\377\377\355" + "\357\373\355\357\373\355\357\373\335\345\373\326\332\371\306\312\367" + "\326\332\371\326\332\371\326\332\371\326\332\371\310\327\371\306\312" + "\367\310\327\371\335\345\373\335\345\373\355\357\373\335\345\373\335" + "\345\373\355\357\373\355\357\373\355\357\373\335\345\373\326\332\371" + "\326\332\371\326\332\353\326\332\353\335\345\373\355\357\373\355\357" + "\373\355\357\373\355\357\373\355\357\373\335\345\373\335\345\373\355" + "\357\373\355\357\373\355\357\373\377\377\377\355\357\373\377\377\377" + "\355\357\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\255\274\347\253\304\355\271\325\373\267\307\352\243\275\346" + "\270\311\367\252\271\371\243\275\346\250\266\334\255\274\347\255\274" + "\347\267\307\352\377\377\377\326\332\353\335\345\373\377\377\377\377" + "\377\377\355\357\373\377\377\377\355\357\373\377\377\377\355\357\373" + "\377\377\377\377\377\377\377\377\377\355\357\373\377\377\377\355\357" + "\373\335\345\373\355\357\373\355\357\373\335\345\373\326\332\371\326" + "\332\371\326\332\371\326\332\371\310\327\371\326\332\371\326\332\371" + "\310\327\371\310\327\371\310\327\371\310\327\371\310\327\371\326\332" + "\371\335\345\373\335\345\373\335\345\373\335\345\373\326\332\371\326" + "\332\371\311\324\353\306\313\352\311\324\353\326\332\371\335\345\373" + "\355\357\373\355\357\373\355\357\373\355\357\373\355\357\373\355\357" + "\373\355\357\373\335\345\373\355\357\373\335\345\373\355\357\373\355" + "\357\373\355\357\373\377\377\377\355\357\373\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\252\271\371\241" + "\264\345\267\307\352\255\274\347\213\242\343\232\254\344\241\264\345" + "\241\264\345\232\255\332\250\266\334\250\266\334\306\312\367\355\357" + "\373\311\324\353\326\332\353\355\357\373\355\357\373\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\355\357\373" + "\355\357\373\355\357\373\335\345\373\335\345\373\335\345\373\326\332" + "\371\326\332\371\310\327\371\310\327\371\306\312\367\310\327\371\310" + "\327\371\310\327\371\326\332\371\326\332\371\335\345\373\335\345\373" + "\326\332\371\310\327\371\310\327\371\326\332\371\306\341\374\306\312" + "\367\267\307\352\306\312\367\306\313\352\267\307\352\306\313\352\266" + "\276\323\306\313\352\326\332\371\335\345\373\335\345\373\335\345\373" + "\355\357\373\335\345\373\355\357\373\335\345\373\335\345\373\335\345" + "\373\335\345\373\355\357\373\355\357\373\335\345\373\377\377\377\355" + "\357\373\377\377\377\377\377\377\355\357\373\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\241\264\345\232\254\344\271\325\373\274" + "\330\350\232\254\344\216\232\326\232\255\332\241\264\345\243\275\346" + "\255\274\347\255\274\347\270\311\367\335\345\373\306\313\352\311\324" + "\353\355\357\373\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\355\357\373\335\345\373\326\332\353\306\313\352" + "\306\313\352\255\274\347\326\332\371\310\327\371\271\325\373\306\312" + "\367\271\325\373\310\327\371\310\327\371\306\341\374\306\312\367\326" + "\332\371\335\345\373\335\345\373\335\345\373\310\327\371\267\307\352" + "\255\274\347\253\304\355\267\307\352\267\307\352\271\325\373\306\341" + "\374\310\327\371\267\307\352\310\327\371\326\332\371\326\332\371\326" + "\332\371\335\345\373\335\345\373\335\345\373\335\345\373\355\357\373" + "\335\345\373\335\345\373\326\332\353\335\345\373\355\357\373\335\345" + "\373\355\357\373\355\357\373\355\357\373\377\377\377\355\357\373\377" + "\377\377\377\377\377\355\357\373\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\241\264\345\232\255\332\255\274\347\253\304\355\213\242\343\232" + "\254\344\232\255\332\255\274\347\255\274\347\255\274\347\241\264\345" + "\232\254\344\326\332\371\310\327\371\306\313\352\267\307\352\255\274" + "\347\267\307\352\253\304\355\250\266\334\270\311\367\270\311\367\267" + "\307\352\250\266\334\255\274\347\306\312\367\306\312\367\310\327\371" + "\310\327\371\306\341\374\326\332\371\306\341\374\326\332\371\306\341" + "\374\326\332\371\326\332\371\310\327\371\310\327\371\271\325\373\267" + "\307\352\267\307\352\255\274\347\267\307\352\267\307\352\326\332\371" + "\335\345\373\335\345\373\335\345\373\326\332\371\326\332\371\335\345" + "\373\335\345\373\335\345\373\355\357\373\335\345\373\326\332\371\326" + "\332\371\326\332\371\310\327\371\270\311\367\271\325\373\271\325\373" + "\251\324\374\214\304\354\214\274\374\212\304\374\212\304\374\212\304" + "\374\204\274\374\204\274\374\214\274\374\204\274\374\204\274\374\214" + "\274\374\212\304\374\212\304\374\230\311\374\246\313\373\230\311\374" + "\251\324\374\271\325\373\306\341\374\306\341\374\335\345\373\355\357" + "\373\355\357\373\355\357\373\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\241\264\345\241\264" + "\345\253\304\355\267\307\352\232\254\344\232\254\344\241\264\345\255" + "\274\347\267\307\352\255\274\347\255\274\347\255\274\347\306\313\352" + "\310\327\371\310\327\371\267\307\352\250\266\334\255\274\347\253\304" + "\355\255\274\347\255\274\347\267\307\352\255\274\347\267\307\352\267" + "\307\352\271\325\373\310\327\371\310\327\371\306\341\374\326\332\371" + "\310\327\371\310\327\371\310\327\371\306\313\352\270\311\367\267\307" + "\352\267\307\352\270\311\367\306\312\367\310\327\371\310\327\371\310" + "\327\371\310\327\371\326\332\371\335\345\373\306\341\374\326\332\371" + "\306\341\374\326\332\371\306\341\374\326\332\371\306\341\374\306\341" + "\374\271\325\373\271\325\373\246\313\373\214\274\374t\264\374g\252\372" + "]\240\374T\244\374E\233\374E\233\3744\224\374,\214\374$\214\374$\214" + "\374$\214\374$\214\374$\214\374$\214\374$\214\374$\214\374$\214\374$" + "\214\374$\214\374$\214\374$\214\374$\214\374,\224\374<\234\374E\233\374" + "T\244\374\\\254\374l\264\374t\274\374\212\304\374\234\324\374\306\341" + "\374\306\341\374\335\345\373\335\345\373\355\357\373\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\232\254\344\232\254\344\253\304\355\270\311\367\232\254\344\232\255" + "\332\243\275\346\253\304\355\255\274\347\250\266\334\255\274\347\252" + "\271\371\266\276\323\310\327\371\306\341\374\310\327\371\310\327\371" + "\306\341\374\326\332\371\326\332\371\270\311\367\270\311\367\306\312" + "\367\310\327\371\310\327\371\310\327\371\310\327\371\310\327\371\310" + "\327\371\306\312\367\310\327\371\306\313\352\267\307\352\267\307\352" + "\267\307\352\306\313\352\270\311\367\310\327\371\310\327\371\310\327" + "\371\310\327\371\310\327\371\310\327\371\306\341\374\310\327\371\271" + "\325\373\271\325\373\246\313\373\246\313\373\230\311\374}\274\377g\252" + "\372T\244\3744\224\374$\214\374\34\204\374\24\204\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\26|\372\24\204\374\24\204\374\24" + "\204\374\24\204\374\24\204\374\26|\372\26|\372\14|\374\26|\372\26|\372" + "\14|\374\26|\372\26|\372\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24" + "\204\374\24\204\374\34\204\374$\214\3744\234\374T\244\374}\274\377\230" + "\311\374\251\324\374\306\341\374\335\345\373\355\357\373\377\377\377" + "\377\377\377\232\255\332\232\255\332\255\274\347\253\304\355\241\264" + "\345\232\254\344\241\264\345\255\274\347\255\274\347\250\266\334\250" + "\266\334\255\274\347\267\307\352\311\324\353\310\327\371\335\345\373" + "\335\345\373\306\341\374\306\341\374\306\341\374\310\327\371\310\327" + "\371\310\327\371\310\327\371\310\327\371\270\311\367\267\307\352\310" + "\327\371\267\307\352\274\330\350\270\311\367\310\327\371\310\327\371" + "\310\327\371\310\327\371\310\327\371\306\312\367\310\327\371\310\327" + "\371\306\341\374\310\327\371\271\325\373\270\311\367\246\313\373\204" + "\264\374w\251\371]\240\374E\233\374,\214\374\24\204\374\26|\372\24\204" + "\374\26|\372\26|\372\26|\372\26|\372\26|\372\24\204\374\26|\372\14}\362" + "\14}\362\26x\351\26x\351\6h\330\32h\327\7e\311\32h\327\7e\311\7e\311" + "\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311\6h\330\32h\327\32h" + "\327\6h\330\26x\351\26x\351\26x\351\14}\362\14}\362\26|\372\26|\372\24" + "\204\374\26|\372\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374,\224\374E\233\374\\\254\374\212\304\374\251\324\374\232\254" + "\344\232\254\344\253\304\355\270\311\367\253\304\355\241\264\345\232" + "\255\332\243\275\346\255\274\347\232\255\332\250\266\334\250\266\334" + "\326\332\371\267\307\352\306\313\352\306\341\374\326\332\371\310\327" + "\371\306\313\352\270\311\367\270\311\367\270\311\367\267\307\352\270" + "\311\367\267\307\352\267\307\352\255\274\347\306\312\367\310\327\371" + "\310\327\371\310\327\371\310\327\371\310\327\371\306\341\374\326\332" + "\371\306\341\374\270\311\367\270\311\367\270\311\367\230\311\374\204" + "\264\374g\252\372L\244\3745\214\373\34\204\374\24\204\374\24\204\374" + "\24\204\374\26|\372\26|\372\26|\372\26|\372\26x\351\26x\351\6h\330\7" + "e\311\7e\311\6V\251\6V\251\5I\230\5I\230\5F\210\4=~\5;t\5""6l\5""6d\5" + "*f\5""6d\4,X\5*f\4,X\5""6d\5*f\5""6d\5*f\5""6d\5""6d\5""6l\5""6l\5;t" + "\4=~\5F\210\5I\230\5K\246\6V\251\6V\251\5Y\270\7e\311\6h\330\6h\330\26" + "x\351\26x\351\26|\372\26|\372\26|\372\24\204\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\241\264\345\232\254\344\253\304\355\267\307\352" + "\271\325\373\255\274\347\241\264\345\243\275\346\255\274\347\250\266" + "\334\250\266\334\267\307\352\335\345\373\306\313\352\267\307\352\310" + "\327\371\306\341\374\270\311\367\267\307\352\306\341\374\255\274\347" + "\267\307\352\255\274\347\255\274\347\270\311\367\270\311\367\306\313" + "\352\306\341\374\310\327\371\310\327\371\310\327\371\310\327\371\310" + "\327\371\310\327\371\271\325\373\251\324\374\227\273\372t\264\374T\244" + "\3744\224\374\34\204\374\34\204\374\24\204\374\26|\372\26|\372\26|\372" + "\26r\367\26x\351\6h\330\7e\311\6V\251\5K\246\5F\210\5;t\5""6l\5""6d\4" + ",X\4$L\4$D\4\34E\4\34E\4$L\4$L\4$L\4,X\4,X\4,X\4,X\4,X\4,X\4,X\4,X\4" + ",X\4,X\4,X\4,X\5*f\4,X\5""6d\5*f\5*f\4,X\4,X\4,X\4,X\4,X\5""6d\5;t\4" + "=~\4=~\5F\210\6Z\230\5Y\270\5Y\270\7e\311\5l\346\26x\351\26x\351\26|" + "\372\26|\372\241\264\345\232\254\344\243\275\346\243\275\346\310\327" + "\371\253\304\355\243\275\346\241\264\345\241\264\345\250\266\334\267" + "\307\352\335\345\373\326\332\371\306\312\367\255\274\347\267\307\352" + "\267\307\352\255\274\347\243\275\346\253\304\355\255\274\347\270\311" + "\367\267\307\352\267\307\352\310\327\371\310\327\371\310\327\371\326" + "\332\371\310\327\371\310\327\371\310\327\371\271\325\373\246\313\373" + "\214\274\374g\252\372E\233\374$\214\374\24\204\374\24\204\374\26|\372" + "\26|\372\26|\372\26x\351\6h\330\7e\311\6V\251\5F\210\4=~\5""6l\4,X\4" + "$L\4$D\4$D\4$D\4\34E\4$L\4$L\4,X\4,X\5*f\5""6d\5*f\5""6d\5*f\5*f\5""6" + "d\5*f\5""6l\5""6l\5""6l\5""6l\5""6l\5""6l\5""6l\5""6l\5""6l\5""6l\5""6" + "l\5""6l\5;t\5""6l\5;t\5;t\5;t\5;t\5;t\5;t\5""6l\5*f\5""6d\5*f\5""6l\5" + "6d\5""6l\4=~\5F\210\5I\230\6V\251\5[\306\6h\330\252\271\371\241\264\345" + "\255\274\347\255\274\347\271\325\373\267\307\352\243\275\346\232\254" + "\344\232\255\332\232\255\332\306\312\367\335\345\373\267\307\352\250" + "\266\334\241\264\345\241\264\345\255\274\347\270\311\367\270\311\367" + "\252\271\371\267\307\352\310\327\371\306\312\367\270\311\367\310\327" + "\371\306\341\374\306\312\367\270\311\367\271\325\373\246\313\373\214" + "\274\374\\\254\374<\224\374\34\204\374\24\204\374\26|\372\26|\372\26" + "|\372\26r\367\6h\330\5[\306\5K\246\5F\210\5""6l\4,X\4$D\4$D\4\35<\4\35" + "<\4$L\4$L\4,X\4,X\5*f\4,X\5*f\5""6d\4,X\4,X\4,X\4,X\4,X\5#V\4$L\4$L\4" + "$L\4$L\4$L\4$L\4$L\4$L\4$L\4$L\4$L\5#V\4,X\4,X\4,X\4,X\4,X\5*f\5*f\5" + "6d\5""6l\5""6l\5""6l\5;t\5;t\4=~\4=~\4=~\4=~\5;t\5;t\5;t\5""6l\5""6l" + "\5""6l\5;t\4=~\326\332\353\250\266\334\216\232\326\243\275\346\306\313" + "\352\306\313\352\250\266\334\232\255\332\232\254\344\232\254\344\243" + "\275\346\243\275\346\255\274\347\267\307\352\270\311\367\270\311\367" + "\255\274\347\255\274\347\270\311\367\310\327\371\310\327\371\271\325" + "\373\310\327\371\310\327\371\310\327\371\271\325\373\246\313\373\214" + "\274\374g\252\372<\224\374\34\204\374\24\204\374\24\204\374\26|\372\26" + "|\372\26x\351\7e\311\5Y\270\5F\210\5""6l\4$L\4$D\4\35<\4$D\4$D\4$L\4" + ",X\4,X\4,X\4,X\4,X\4,X\4$L\4$L\4$L\4$D\4\35<\4\35<\4\34""4\4\34""4\4" + "\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24" + ",\4\24""4\4\24,\4\24,\4\24,\4\34""4\4\24""4\4\24""4\4\34""4\4\34""4\4" + "\34""4\4\24""4\4\35<\4\34E\4\34E\4$L\5#V\4,X\4,X\5""6d\5""6l\5;t\4=~" + "\4=~\4=~\4=~\4=~\4=~\5;t\326\332\353\310\327\371\243\275\346\232\254" + "\344\306\313\352\310\327\371\255\274\347\216\232\326\232\255\332\232" + "\254\344\243\275\346\253\304\355\306\312\367\310\327\371\310\327\371" + "\306\312\367\267\307\352\267\307\352\267\307\352\270\311\367\271\325" + "\373\306\313\352\271\325\373\270\311\367\227\273\372t\264\374E\233\374" + "$\203\373\24\204\374\24\204\374\26|\372\26|\372\26x\351\7e\311\6V\251" + "\4=~\4,X\4$D\4\35<\4$D\4$D\4$L\4$L\4,X\4,X\4,X\4$L\4$L\4$D\4\35<\4\24" + "4\4\24,\4\24$\4\14$\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4" + "\14\34\4\14$\4\14$\4\24$\4\24$\4\24$\4\24,\4\24,\4\24,\4\24,\4\24,\4" + "\24,\4\24,\4\24""4\4\24""4\4\24""4\4\24""4\4\24""4\4\24""4\4\24,\4\24" + "4\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24""4\4\24""4\4\35" + "<\4\34E\4$L\4,X\5*f\5""6l\5;t\4=~\4=~\267\307\352\335\345\373\326\332" + "\371\232\254\344\255\274\347\310\327\371\253\304\355\232\255\332\232" + "\255\332\243\275\346\271\325\373\271\325\373\306\312\367\271\325\373" + "\310\327\371\310\327\371\271\325\373\267\307\352\255\274\347\250\266" + "\334\270\311\367\253\304\355\204\264\374T\244\3744\224\374\24\204\374" + "\26|\372\26|\372\26|\372\26x\351\7e\311\5K\246\5;t\4,X\4\35<\4\35<\4" + "\35<\4$L\4,X\4,X\4,X\4$L\4$L\4$D\4\24""4\4\24,\4\24$\4\14\34\4\14\24" + "\4\14\24\4\14\24\4\14\24\4\4\24\4\14\24\4\14\34\4\14\34\4\14\34\4\14" + "$\4\24$\4\24$\4\24$\4\24$\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24""4" + "\4\34""4\4\34""4\4\24""4\4\34""4\4\34""4\4\34""4\4\34""4\4\34""4\4\34" + "4\4\34""4\4\34""4\4\34""4\4\34""4\4\34""4\4\34""4\4\34""4\4\24""4\4\34" + "4\4\24""4\4\24,\4\24,\4\24,\4\24$\4\24$\4\24$\4\24$\4\24,\4\34""4\4\35" + "<\4\34E\4,X\232\255\332\355\357\373\355\357\373\232\255\332\232\255\332" + "\270\311\367\267\307\352\232\255\332\241\264\345\270\311\367\310\327" + "\371\271\325\373\270\311\367\270\311\367\270\311\367\310\327\371\310" + "\327\371\306\312\367\253\304\355\241\264\345|\264\374E\233\374$\214\374" + "\24\204\374\26|\372\26|\372\26r\367\6h\330\5Y\270\4=~\4,X\4\35<\4\35" + "<\4$D\4$L\4,X\4,X\4,X\4$L\4$D\4\34""4\4\24,\4\14\34\4\14\24\4\4\14\4" + "\4\14\4\4\14\4\4\14\4\4\24\4\14\24\4\14\24\4\14\34\4\14\34\4\14$\4\14" + "\34\4\14$\4\24$\4\24$\4\14$\4\24$\4\24,\4\24$\4\24,\4\24,\4\24,\4\24" + ",\4\24,\4\24,\4\24""4\4\34""4\4\34""4\4\34""4\4\34""4\4\34""4\4\34""4" + "\4\24""4\4\35<\4\34""4\4\34""4\4\34""4\4\34""4\4\24""4\4\34""4\4\24""4" + "\4\34""4\4\34""4\4\34""4\4\34""4\4\24,\4\34""4\4\24,\4\24""4\4\24,\4" + "\24,\4\24$\4\24$\4\14$\4\14\34\4\14\34\4\14$\232\254\344\335\345\373" + "\355\357\373\232\255\332\232\255\332\255\274\347\253\304\355\250\266" + "\334\253\304\355\310\327\371\306\312\367\255\274\347\271\325\373\270" + "\311\367\270\311\367\270\311\367\271\325\373\246\313\373|\264\374E\233" + "\374$\214\374\24\204\374\26|\372\26r\367\26x\351\7e\311\5I\230\5""6d" + "\4$D\4\34""4\4\35<\4$L\4,X\4,X\4,X\4$L\4\35<\4\24,\4\14\34\4\14\24\4" + "\4\14\4\4\4\4\4\4\4\4\14\4\4\14\4\14\24\4\14\24\4\14\24\4\14\24\4\14" + "\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14$\4\14$\4\24" + "$\4\24,\4\24$\4\24,\4\24,\4\24,\4\24,\4\24,\4\34""4\4\24""4\4\34""4\4" + "\24""4\4\34""4\4\34""4\4\24""4\4\35<\4\34""4\4\35<\4\34""4\4\34""4\4" + "\35<\4\34""4\4\35<\4\34""4\4\34""4\4\34""4\4\34""4\4\24""4\4\34""4\4" + "\24,\4\24""4\4\24""4\4\34""4\4\24,\4\24,\4\24,\4\24,\4\24,\4\24,\4\24" + ",\4\24$\4\14$\241\264\345\306\313\352\355\357\373\306\313\352\232\254" + "\344\243\275\346\253\304\355\267\307\352\310\327\371\326\332\371\271" + "\325\373\270\311\367\310\327\371\271\325\373\270\311\367\227\273\372" + "t\264\374<\224\374$\203\373\24\204\374\26|\372\26r\367\5l\346\6V\251" + "\4=~\4$L\4\34""4\4\34""4\4$D\4$L\4,X\4,X\4$L\4\35<\4\24,\4\14\34\4\4" + "\14\4\4\4\0\0\0\0\0\0\4\4\4\4\4\14\4\4\14\4\4\14\4\14\24\4\14\24\4\4" + "\24\4\14\24\4\14\24\4\14\24\4\14\34\4\14\34\4\14\34\4\14\34\4\14$\4\24" + "$\4\14$\4\24$\4\24$\4\24$\4\24,\4\24,\4\24,\4\24,\4\24,\4\34""4\4\24" + "4\4\34""4\4\24""4\4\34""4\4\34""4\4\34""4\4\35<\4\34""4\4\35<\4\35<\4" + "\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\24""4\4\34""4\4\34""4\4\24""4\4" + "\24""4\4\34""4\4\34""4\4\34""4\4\24,\4\24""4\4\24,\4\24,\4\24,\4\24," + "\4\24,\4\24,\4\24,\4\24$\250\266\334\250\266\334\326\332\371\377\377" + "\377\232\254\344\232\254\344\253\304\355\271\325\373\326\332\371\326" + "\332\371\310\327\371\306\312\367\270\311\367\227\273\372g\252\372<\224" + "\374\34\204\374\24\204\374\26|\372\26r\367\6h\330\6V\251\5""6l\4$D\4" + "\34""4\4\35<\4$L\4,X\4,X\4$L\4$D\4\24,\4\14\24\4\4\14\0\0\0\0\0\0\0\0" + "\0\4\4\4\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\14\24\4\4\24\4\14\24\4" + "\14\24\4\14\24\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\24$" + "\4\14$\4\24$\4\24$\4\24,\4\24,\4\24,\4\24,\4\24,\4\24""4\4\24""4\4\24" + "4\4\34""4\4\34""4\4\34""4\4\34""4\4\34""4\4\35<\4\35<\4\35<\4\35<\4\35" + "<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\34""4\4\34""4\4\34" + "4\4\34""4\4\24""4\4\34""4\4\24""4\4\34,\4\24""4\4\34,\4\24,\4\24,\4\24" + ",\4\24$\4\24$\4\24$\267\307\352\216\232\326\326\332\371\377\377\377\213" + "\242\343\232\254\344\243\275\346\270\311\367\335\345\373\310\327\371" + "\270\311\367\252\271\371g\252\372E\233\374\34\204\374\24\204\374\26|" + "\372\26r\367\7e\311\5I\230\5""6d\4$D\4\34""4\4\35<\4$L\4,X\4$L\4$D\4" + "\24""4\4\14\34\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4\4\14\4\4\14\4\4" + "\14\4\4\14\4\4\14\4\4\14\4\14\24\4\4\14\4\14\24\4\14\24\4\14\24\4\14" + "\24\4\14\24\4\14\34\4\14\34\4\14\34\4\14\34\4\14$\4\24$\4\24$\4\14$\4" + "\24$\4\24,\4\24,\4\24,\4\24,\4\24""4\4\34,\4\24""4\4\24""4\4\34""4\4" + "\24""4\4\34""4\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<" + "\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\34""4\4\34""4" + "\4\24""4\4\24""4\4\24""4\4\24,\4\24""4\4\24,\4\24,\4\24,\4\24,\4\24," + "\4\24$\232\254\344\232\255\332\253\304\355\326\332\371\310\327\371\243" + "\275\346\255\274\347\271\325\373\270\311\367\213\242\343i\236\352<\224" + "\374\34\204\374\24\204\374\26|\372\26r\367\6h\330\5I\230\4,X\4\35<\4" + "\35<\4$D\4$L\4,X\4$L\4\35<\4\24$\4\14\24\4\4\4\0\0\0\0\0\0\0\0\0\4\4" + "\4\4\4\4\4\4\4\4\4\14\4\4\14\4\4\4\4\4\14\4\4\14\4\14\14\4\4\14\4\4\14" + "\4\4\24\4\14\24\4\4\24\4\14\24\4\14\24\4\14\34\4\14\34\4\14\34\4\14\34" + "\4\14$\4\14\34\4\14$\4\14$\4\24$\4\24,\4\24,\4\24,\4\24""4\4\24,\4\24" + "4\4\34""4\4\34""4\4\34""4\4\24""4\4\34""4\4\35<\4\35<\4\35<\4\35<\4\35" + "<\4\35<\4\35<\4\34E\4\35<\4$D\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\35" + "<\4\24""4\4\35<\4\34""4\4\34""4\4\34""4\4\34""4\4\34""4\4\24""4\4\24" + ",\4\24,\4\24,\4\24,\4\24,\4\24,\4\24$\232\254\344\232\255\332\241\264" + "\345\271\325\373\271\325\373\250\266\334\243\275\346\270\311\367\227" + "\273\372T\244\374$\214\374\26|\372\26|\372\26|\372\6h\330\5I\230\4,X" + "\4\35<\4\35<\4$D\4$L\4,X\4$L\4\34""4\4\14$\4\4\14\0\0\0\0\0\0\0\0\0\0" + "\0\0\4\4\4\0\0\0\4\4\4\4\4\4\4\4\4\4\4\14\4\4\4\4\4\14\4\4\14\4\4\14" + "\4\4\14\4\4\14\4\14\24\4\14\24\4\14\24\4\14\24\4\14\24\4\14\34\4\14\24" + "\4\14\34\4\14\34\4\24$\4\14\34\4\14$\4\24$\4\24$\4\24$\4\24,\4\24,\4" + "\24,\4\24,\4\24""4\4\34""4\4\34""4\4\34""4\4\34""4\4\35<\4\35<\4\35<" + "\4\35<\4\35<\4\35<\4\35<\4\34E\4$D\4$D\4$D\4\34E\4$D\4\35<\4\34E\4\35" + "<\4\35<\4\35<\4\35<\4\35<\4\35<\4\34""4\4\35<\4\34""4\4\34""4\4\24""4" + "\4\24,\4\34""4\4\24,\4\24,\4\24,\4\24,\4\24$\4\24,\213\242\343\216\232" + "\326\232\255\332\243\275\346\271\325\373\243\275\346\214\264\354]\240" + "\3744\224\374\24\204\374\26|\372\26|\372\5l\346\5I\230\5""6d\4\35<\4" + "\35<\4$D\4,X\4,X\4$L\4\24""4\4\14\34\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\4\4\4\0\0\0\4\4\4\4\4\4\4\4\4\4\4\14\4\4\4\4\4\14\4" + "\4\14\4\4\14\4\4\14\4\14\24\4\4\14\4\14\24\4\14\24\4\14\24\4\14\34\4" + "\14\34\4\14\34\4\14$\4\14\34\4\14$\4\24$\4\24$\4\24,\4\24,\4\24,\4\24" + ",\4\24""4\4\34""4\4\24""4\4\34""4\4\24""4\4\35<\4\35<\4\35<\4\35<\4\35" + "<\4\35<\4\34E\4$D\4$D\4$D\4\34E\4$D\4$D\4$D\4\34E\4$D\4$D\4$D\4\34E\4" + "\35<\4\35<\4\35<\4\35<\4\35<\4\34""4\4\35<\4\24""4\4\34""4\4\34""4\4" + "\34""4\4\24""4\4\24,\4\24,\4\24,\4\24,\4\24$\213\242\343\216\232\326" + "\213\242\343\232\254\344\227\273\372i\236\3524\224\374\34\204\374\26" + "|\372\26|\372\5l\346\5Y\270\5""6l\4\35<\4\34""4\4$D\5#V\4,X\4$D\4\24" + "4\4\14\24\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\0\0\0" + "\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\14\4\4\14\4\4\14\4\4\14\4\14\14\4" + "\4\14\4\4\24\4\4\24\4\14\24\4\4\24\4\14\24\4\14\34\4\14\24\4\14\34\4" + "\14\34\4\14$\4\14$\4\24$\4\14$\4\24,\4\24,\4\24,\4\34""4\4\24,\4\34""4" + "\4\24""4\4\34""4\4\35<\4\35<\4\35<\4\35<\4\35<\4\34E\4\35<\4$D\4$D\4" + "\34E\4$D\4$D\4$L\4\34E\4$D\4$D\4\34E\4$D\4\34E\4$D\4\34E\4\35<\4\35<" + "\4\35<\4\35<\4\35<\4\34""4\4\35<\4\24""4\4\34""4\4\24""4\4\34""4\4\34" + "4\4\24,\4\24,\4\24,\4\24,\213\242\343\213\242\343\213\242\343v\236\352" + "=\216\361$\214\374\26|\372\26|\372\26r\367\5[\306\5;t\4$D\4\34""4\4$" + "D\4$L\4,X\4$D\4\34""4\4\14\34\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\0\0\0\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4" + "\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\14\14\4\4\24\4\14\24\4\14\24\4" + "\14\34\4\14\34\4\14\34\4\14\34\4\24$\4\14$\4\24$\4\24$\4\24,\4\24,\4" + "\24,\4\24,\4\24""4\4\34""4\4\34""4\4\34""4\4\35<\4\35<\4\35<\4\35<\4" + "\35<\4$D\4$D\4\34E\4$D\4$L\4$L\4$L\4$L\4$L\4$L\4$L\4$D\4$L\4$D\4$D\4" + "$D\4\34E\4$D\4\34E\4\35<\4\35<\4\35<\4\35<\4\34""4\4\34""4\4\34""4\4" + "\34""4\4\34,\4\24""4\4\24,\4\24,\4\24,\4\24,\213\242\343\213\242\343" + "^\231\357,\214\374\24\204\374\26|\372\26|\372\6h\330\5F\210\4$L\4\35" + "<\4\35<\4$L\5#V\4$L\4\34""4\4\14\34\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\0\0\0\4\4\4" + "\4\4\4\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\14\24\4\4\14\4\14\24\4\14" + "\24\4\14\24\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14$\4\24$\4\24" + "$\4\24,\4\24,\4\24,\4\24,\4\24""4\4\24""4\4\34""4\4\34""4\4\35<\4\35" + "<\4\35<\4$D\4\34E\4$D\4\34E\4$D\4$D\4$L\4$D\4$L\4$L\4$L\4$L\4$L\4$L\4" + "$L\4$L\4$L\4$L\4\34E\4$D\4$D\4$D\4\34E\4$D\4\35<\4\35<\4\35<\4\35<\4" + "\24""4\4\34""4\4\24""4\4\34""4\4\24""4\4\24,\4\24,\4\24,v\236\352=\216" + "\361\24\204\374\24\204\374\26|\372\26x\351\6V\251\5*f\4\35<\4\35<\4$" + "D\4,X\4$L\4\35<\4\14\34\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4\4" + "\14\4\4\4\4\4\14\4\4\4\4\4\14\4\4\14\4\4\14\4\4\14\4\14\24\4\14\24\4" + "\4\24\4\14\24\4\14\34\4\14\34\4\14\34\4\14\34\4\14$\4\24$\4\24$\4\14" + "$\4\24,\4\24,\4\24,\4\24""4\4\34""4\4\34""4\4\35<\4\35<\4\35<\4$D\4$" + "D\4\34E\4$D\4$L\4$L\4$L\4,X\5#V\4,X\4,X\4,X\4,X\4,X\4,X\4,X\4,X\4$L\4" + "$L\4$L\4$L\4$L\4$L\4$D\4$D\4\35<\4\35<\4\35<\4\35<\4\35<\4\35<\4\34""4" + "\4\34""4\4\34""4\4\34""4\4\24""4\4\24,\4\24,$\214\374\24\204\374\26|" + "\372\26|\372\7e\311\4=~\4$L\4\35<\4$D\4$L\4,X\4\35<\4\24$\4\4\14\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4\4\4\4\4\4\4\4\4\4\4\14\4" + "\4\14\4\4\14\4\4\14\4\4\14\4\4\24\4\14\24\4\14\24\4\14\24\4\14\34\4\14" + "\24\4\14\34\4\14\34\4\14$\4\24$\4\24$\4\24,\4\24,\4\24,\4\24""4\4\34" + "4\4\35<\4\35<\4\35<\4\34E\4$D\4\34E\4$D\4\34E\4\34E\4$D\4$D\4$D\4\34" + "E\4$D\4\34E\4$D\4$D\4$D\4$D\4$L\4$L\4$L\5#V\4$L\4,X\4$L\4$L\4$L\4$L\4" + "$L\4$L\4$D\4$D\4\35<\4\35<\4\35<\4\34""4\4\34""4\4\34""4\4\34""4\4\34" + ",\4\24,\4\24,\24\204\374\26|\372\26x\351\6V\251\4,X\4\35<\4\35<\4$L\4" + ",X\4$L\4\24,\4\4\24\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4" + "\4\0\0\0\4\4\4\4\4\4\4\4\4\4\4\14\4\4\14\4\14\14\4\4\14\4\4\14\4\14\24" + "\4\4\24\4\14\24\4\14\24\4\14\34\4\14\34\4\14\34\4\24$\4\14$\4\24,\4\24" + ",\4\24,\4\24""4\4\24""4\4\34""4\4\34""4\4\24""4\4\24,\4\24,\4\24$\4\14" + "$\4\14$\4\14\34\4\14\34\4\14\34\4\14\24\4\14\24\4\4\14\4\14\24\4\4\14" + "\4\4\24\4\4\24\4\14\24\4\14\24\4\14\24\4\14\24\4\14\34\4\14\34\4\14\34" + "\4\24$\4\24$\4\24,\4\24,\4\34""4\4\35<\4\35<\4\34E\4$D\4\34E\4$L\4\34" + "E\4$D\4\35<\4\35<\4\34""4\4\34""4\4\24""4\4\24,\4\24,\26|\372\7e\311" + "\4=~\4$D\4\35<\4$D\4,X\5#V\4\34""4\4\14\34\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\0\0\0\4\4\4\4\4\4\4\4\4\4\4\14\4\4\4" + "\4\4\14\4\4\14\4\4\14\4\14\24\4\14\24\4\14\24\4\14\24\4\14\34\4\14\34" + "\4\14\34\4\14$\4\24$\4\24$\4\24$\4\24$\4\24$\4\14\34\4\14\34\4\14\24" + "\4\14\24\4\4\24\4\4\14\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\4\4\14\4\14\24\4\14\24\4" + "\14\34\4\24$\4\24,\4\24""4\4\35<\4\35<\4\35<\4\35<\4\35<\4\34""4\4\34" + "4\4\24,\6V\251\5*f\4\35<\4\35<\4$L\4,X\4$D\4\24$\4\4\14\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\0\0\0\4\4\4" + "\4\4\4\4\4\14\4\4\14\4\4\14\4\4\14\4\14\14\4\4\24\4\14\14\4\4\24\4\14" + "\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\24\4\4\24\4\4\14\4\4" + "\14\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\4\4\4\4\4\14\4\4\14\4\14\34\4\14$\4\24$\4\24,\4" + "\24""4\4\34""4\4\34""4\4$D\4\35<\4$D\4,X\4,X\4\34""4\4\14\24\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\4\4\4\4\4\4\4\4\4\4\4\4\4\4\14\4\4\14\4\4\14\4\14\24\4\14\24\4" + "\14\24\4\14\24\4\14\24\4\14\24\4\4\14\4\4\14\4\4\14\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4" + "\4\14\4\4\24\4\14\34\4\24$\4\35<\4$L\4,X\4$L\4\24$\4\4\14\0\0\0\0\0\0" + "\0\0\0\4\4\4\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\4\4\4\4\4\4\4\4\4\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4" + "\4\14\4\4\14\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\4\4\4\4\14\14\4\14\14\4\14\24\4\14\14\4\14\24\4\14\14" + "\4\14\24\4\14\14\4\14\24\4\14\14\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4$L\4,X\4\35<\4\14\24\0\0\0\0\0\0" + "\0\0\0\4\4\4\4\4\4\0\0\0\4\4\4\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\4\4\4\4\4\4\4\4\4\4\4\14\4\4\14\4\4\14\4\4\4\4\4" + "\4\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\24\4\34,\4$L\4,X\14/" + "Q\32Aj\11Ly\30F\210\31[\231\6V\251\27]\251\27]\251\27]\251\27]\251\27" + "]\251\27]\251\27]\251\27]\251\6V\251\31[\231\31[\231\11Ly\32Aj\26""9" + "X\14/Q\4$L\4\35<\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4$L\4\24,\4\4\14\0\0\0\4\4\4" + "\4\4\4\4\4\4\4\4\14\4\4\4\4\4\4\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\4\14\24\4\14$\4\35<\5""6l\5F\210\31[\231\31^\270\31f\306\30" + "w\330'\177\347'\177\3477\204\360,\212\3645\214\3734\224\3744\224\374" + "5\214\3734\224\3745\214\3735\214\373<\224\3745\214\373<\224\3745\214" + "\373<\224\374<\224\3744\224\374=\216\3617\204\3600\212\341'\177\347\30" + "w\330\30w\330\31^\270\31[\231\26D\226\5;t\4$D\4\24$\4\14\24\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\34\4\4\14\0\0\0\4\4\14\4" + "\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\24\4" + "\35<\5""6l\30F\210\5Y\270\31f\306\32h\327'\177\347,\214\374,\214\374" + "4\224\3744\224\3745\214\3735\214\373<\224\3744\224\374<\224\374<\224" + "\374<\234\374<\224\374<\234\374<\234\374E\233\374<\234\374E\233\374E" + "\233\374<\234\374E\233\374E\233\374<\234\374<\234\374<\224\374<\224\374" + "E\233\374<\224\374<\224\374<\224\374<\224\3744\224\374,\224\374,\212" + "\364-t\315\31f\306\31f\306\31[\231\5;t\4$L\4\14\34\0\0\0\0\0\0\0\0\0" + "\0\0\0\4\4\4\4\4\4\4\4\14\4\4\4\4\4\14\4\4\14\4\4\4\4\4\14\4\4\4\4\4" + "\4\4\4\4\4\4\4\0\0\0\0\0\0\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\4\14\14\4\34""4\4,X\5I\230\31f\306\30w\330\26x\351$\214\374,\214\374" + ",\214\374,\214\374,\214\374,\224\3744\224\3744\224\3744\224\3744\224" + "\3744\224\3744\224\3744\224\3744\224\3744\224\3744\224\3744\224\374<" + "\224\374<\224\374<\224\374<\234\374<\224\374<\234\374<\234\374<\234\374" + "<\224\374<\224\374<\234\374<\234\374<\234\374<\224\374<\234\374<\234" + "\374<\234\3744\224\374<\224\374<\224\3744\224\3744\224\3745\214\3735" + "\214\373,\212\364)v\367\30w\330\31f\306\27]\251\5""6l\4\35<\4\14\24\4" + "\4\14\4\4\14\4\4\14\4\4\14\4\4\4\4\4\4\4\4\14\4\4\4\4\4\4\4\4\14\4\4" + "\4\4\4\4\4\4\4\4\4\4\4\4\4\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\24\4$L\4=~\6V\251" + "\32h\327\26x\351\34\204\374\34\204\374$\203\373$\203\373,\214\374,\214" + "\374,\224\374,\214\374,\214\374,\214\374,\224\374,\214\374,\224\374," + "\214\374,\214\374,\224\374,\214\374,\224\374,\224\374,\224\374,\224\374" + ",\224\374,\224\374,\224\3744\224\3744\224\3744\224\3744\224\3744\224" + "\3744\224\3744\224\3744\224\3744\224\3744\224\3744\224\3744\224\3744" + "\224\3744\224\3744\224\3744\224\3744\224\3744\224\3744\224\3744\224\374" + "4\224\3744\224\3744\224\3745\214\373,\214\374,\214\374'\177\347\30w\330" + "\31^\270\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\4\4\4\14\4\4\14" + "\0\0\0\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\4$L\5F\210\5[\306\30w\330" + "\26r\367$\203\373\34\204\374\34\204\374$\203\373$\214\374$\214\374$\214" + "\374$\214\374$\214\374$\214\374\34\214\374\34\214\374\34\214\374$\214" + "\374\34\214\374$\214\374$\214\374$\214\374$\214\374$\214\374$\214\374" + ",\214\374,\224\374,\214\374,\224\374,\224\3744\224\374,\224\3744\224" + "\3744\224\3744\224\3744\224\3744\224\374,\224\3744\224\374,\224\374," + "\214\374,\224\374,\214\374,\224\374,\214\374,\214\374$\214\374$\214\374" + ",\214\374,\214\374,\214\374,\224\374,\224\374,\214\374,\224\374,\214" + "\374,\214\374,\214\374-\203\374$\203\373\4\4\14\4\4\14\4\4\14\4\4\14" + "\4\4\14\4\4\4\4\4\14\4\4\4\4\4\14\4\4\14\4\4\14\4\4\14\4\4\4\4\4\14\4" + "\4\4\4\4\4\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\24," + "\4=~\5Y\270\26x\351\26|\372\34\204\374\34\204\374\34\204\374\34\204\374" + "$\214\374$\214\374\34\214\374\34\214\374\34\204\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\34\204\374\34\204\374\34\204\374\34\204\374" + "\34\204\374\34\214\374$\214\374$\214\374$\214\374$\214\374,\224\374," + "\214\374,\224\374,\224\374,\214\374,\224\374,\224\3744\224\3744\224\374" + "4\224\3744\224\3744\224\3744\224\3744\224\374,\224\374,\224\374,\214" + "\374,\224\374,\214\374$\214\374,\224\374$\214\374$\214\374$\214\374$" + "\214\374$\214\374$\214\374$\214\374$\214\374$\214\374$\214\374$\214\374" + "$\214\374,\214\374,\224\374,\224\374\4\4\14\4\4\14\4\4\14\4\4\14\4\4" + "\14\4\4\14\4\4\14\4\4\14\4\4\4\4\4\14\4\4\4\4\4\14\4\4\4\4\4\14\4\4\4" + "\4\4\4\4\4\4\4\4\4\0\0\0\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\4,X\6V\251\5l\346\26" + "|\372\26|\372\26|\372\24\204\374\34\204\374\34\204\374\34\214\374\24" + "\204\374\24\204\374\24\204\374\14\204\374\24\204\374\14\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\34\214\374" + "\34\214\374$\214\374$\214\374$\214\374$\214\374$\214\374$\214\374,\224" + "\374$\214\374,\214\374,\224\374,\224\374,\224\3744\224\3744\224\374," + "\224\3744\224\3744\224\3744\224\374,\224\3744\224\3744\224\374,\224\374" + ",\224\374,\224\374,\224\374,\224\374$\214\374,\224\374$\214\374$\214" + "\374$\214\374$\214\374$\214\374\34\214\374\34\214\374\34\214\374\34\204" + "\374\34\214\374\34\204\374\34\214\374$\214\374$\214\374\4\4\14\4\14\14" + "\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14" + "\4\4\14\4\4\4\4\4\14\4\4\4\4\4\14\0\0\0\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\34\5""6l\5[\306" + "\26x\351\26|\372\34\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\14|\374\14|\374\14|\374\14|\374\14|\374\14|\374" + "\24\204\374\14\204\374\24\204\374\24\204\374\24\204\374\24\204\374\34" + "\204\374\34\214\374\34\204\374\34\214\374\34\214\374$\214\374$\214\374" + "$\214\374$\214\374,\224\374,\214\374,\214\374,\224\374,\214\374,\224" + "\3744\224\374,\224\3744\224\3744\224\3744\224\3744\224\3744\224\374," + "\224\3744\224\374,\224\374,\224\374,\214\374,\224\374,\214\374,\224\374" + "$\214\374$\214\374$\214\374$\214\374$\214\374$\214\374\34\204\374\34" + "\214\374\34\204\374\34\214\374\34\214\374\34\214\374\24\204\374\24\204" + "\374\24\204\374\4\14\24\4\4\14\4\4\14\4\4\14\4\4\14\4\14\14\4\4\14\4" + "\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\4\4\4\14\4\4\4\4\4\14\4\4\4\4\4" + "\4\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\4\24$\5;t\6h\330\26r\367\14|\374\24\204\374\24\204\374\24\204\374\24" + "\204\374\24\204\374\14\204\374\4|\374\4|\374\4|\374\4|\374\4|\374\14" + "|\374\4|\374\14|\374\14\204\374\14\204\374\14|\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\34\214\374\34\204\374\34\204\374\34\214\374" + "$\214\374$\214\374$\214\374$\214\374$\214\374$\214\374,\214\374,\224" + "\374,\224\374,\224\374,\224\374,\224\3744\224\3744\224\3744\224\3744" + "\224\3744\224\3744\224\3744\224\374,\224\374,\224\374,\214\374,\224\374" + ",\224\374,\224\374$\214\374$\214\374$\214\374$\214\374$\214\374$\214" + "\374\34\214\374\34\214\374\34\214\374\34\214\374\34\214\374\24\204\374" + "\24\204\374\24\204\374\24\204\374\24\204\374\4\4\14\4\14\24\4\14\24\4" + "\4\24\4\14\24\4\4\14\4\14\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14" + "\4\4\14\4\4\14\4\4\14\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\4\24,\4=~\6h\330\26r\367\14|\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\14\204\374\14|\374\4|\374\4|\374\4|\374\4" + "|\374\4|\374\4|\374\4|\374\4|\374\14\204\374\14\204\374\14|\374\14\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\34\204\374" + "\34\214\374\34\204\374\34\214\374$\214\374\34\214\374$\214\374$\214\374" + "$\214\374$\224\374,\214\374,\224\374,\214\374,\224\374,\214\3744\224" + "\374,\224\3744\224\3744\224\3744\224\3744\224\374,\224\3744\224\3744" + "\224\374,\224\374,\224\374,\214\374,\224\374,\224\374,\224\374$\214\374" + "$\214\374$\214\374$\214\374$\214\374$\214\374$\214\374\34\214\374\34" + "\204\374\34\214\374\34\204\374\24\204\374\24\204\374\24\204\374\24\204" + "\374\4\14\24\4\4\24\4\14\14\4\14\24\4\14\14\4\4\24\4\4\24\4\14\24\4\4" + "\24\4\14\14\4\4\14\4\14\14\4\4\14\4\4\14\4\4\14\4\4\14\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\24$\4=~\6h\330\26r\367\26" + "|\372\24\204\374\24\204\374\24\204\374\24\204\374\14\204\374\4|\374\4" + "|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\14|\374\14\204\374\14|\374\14\204\374\24\204\374\24\204\374\24" + "\204\374\24\204\374\24\204\374\24\204\374\34\204\374\34\214\374\34\214" + "\374$\214\374$\214\374$\214\374$\214\374,\224\374$\214\374,\224\374," + "\214\374,\224\374,\224\374,\224\3744\224\3744\224\3744\224\3744\224\374" + "4\224\3744\224\3744\224\3744\224\374,\214\374,\224\374,\224\374,\214" + "\374,\224\374,\214\374,\214\374$\214\374$\214\374$\214\374$\214\374\34" + "\214\374$\214\374\34\214\374\34\214\374\34\214\374\34\214\374\34\204" + "\374\24\204\374\24\204\374\24\204\374\4\14\24\4\14\24\4\4\24\4\14\24" + "\4\4\24\4\14\24\4\14\24\4\4\24\4\14\14\4\4\24\4\4\14\4\4\24\4\4\14\4" + "\4\14\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\24\5" + "6l\7e\311\26r\367\26|\372\26|\372\14|\374\24\204\374\14\204\374\4|\374" + "\4t\374\4|\374\4t\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\14\204\374\14|\374\14\204\374\14|\374\14\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\34\204\374\34\214\374\34\204\374" + "\34\214\374$\214\374$\214\374$\214\374$\214\374$\214\374,\224\374,\214" + "\374,\224\374,\224\374,\224\3744\224\3744\224\3744\224\3744\224\3744" + "\224\3744\224\3744\224\3744\224\3744\224\3744\224\3744\224\3744\224\374" + "4\224\374,\224\374,\224\374,\214\374,\224\374,\224\374$\214\374$\214" + "\374$\214\374$\214\374$\214\374\34\204\374\34\214\374\34\204\374\34\214" + "\374\24\204\374\34\214\374\24\204\374\24\204\374\24\204\374\4\14\24\4" + "\14\24\4\14\24\4\14\24\4\14\24\4\14\24\4\14\24\4\14\24\4\14\24\4\14\24" + "\4\14\24\4\14\24\4\4\14\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\4\4\14\4$L\5Y\270\26r\367\26|\372\24\204\374\24\204\374\14\204\374" + "\14\204\374\4|\374\4|\374\4t\374\4t\374\4|\374\4t\374\4|\374\4|\374\4" + "|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\14|\374\4|\374\14|\374" + "\14\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\34" + "\204\374\34\214\374\34\214\374$\214\374$\214\374$\214\374$\214\374$\214" + "\374,\224\374,\214\374,\224\3744\224\3744\224\3744\224\3744\224\3744" + "\224\3744\224\3744\224\374<\224\374<\234\374<\234\374<\234\374<\234\374" + "<\224\3744\224\3744\224\3744\224\3744\224\3744\224\3744\224\374,\224" + "\374,\214\374,\224\374,\214\374$\214\374$\214\374$\214\374$\214\374$" + "\214\374\34\214\374\34\214\374\34\214\374\34\204\374\24\204\374\24\204" + "\374\24\204\374\4\14\24\4\14\24\4\14\34\4\14\24\4\14\24\4\14\24\4\14" + "\24\4\4\24\4\14\24\4\14\24\4\14\24\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\4\24,\5I\230\14}\362\26|\372\26|\372\24\204\374" + "\24\204\374\14\204\374\4|\374\4|\374\4|\374\4t\374\4|\374\4t\364\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\14|\374" + "\14|\374\14\204\374\14\204\374\14|\374\24\204\374\24\204\374\24\204\374" + "\34\204\374\34\214\374\34\214\374\34\214\374$\214\374$\214\374$\214\374" + ",\214\374,\224\374,\224\374,\224\3744\224\3744\224\3744\224\3744\224" + "\374<\224\374<\234\374<\234\374<\234\374<\234\374<\234\374<\234\374<" + "\234\374<\234\374<\234\374<\234\374<\234\374<\224\3744\224\3744\224\374" + "4\224\3744\224\374,\224\374,\224\374,\224\374,\224\374,\224\374$\214" + "\374$\214\374$\214\374$\214\374\34\214\374\34\214\374\34\214\374\34\214" + "\374\34\204\374\24\204\374\24\204\374\4\14\34\4\14\34\4\14\34\4\14\34" + "\4\14\34\4\14\34\4\14\34\4\14\24\4\14\34\4\14\24\4\4\14\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\24\5""6l\6h\330\26|\372\24\204\374" + "\24\204\374\24\204\374\24\204\374\4|\374\4|\374\4t\374\4t\374\4t\374" + "\4t\374\4|\374\4t\374\4t\374\4t\374\4|\374\4|\374\4|\374\4t\374\4|\374" + "\4|\374\4|\374\4|\374\14\204\374\14|\374\14|\374\14|\374\24\204\374\24" + "\204\374\24\204\374\24\204\374\34\204\374\34\214\374$\214\374$\214\374" + "$\214\374$\214\374,\214\374,\224\374,\224\3745\214\3734\224\3744\224" + "\3744\224\374<\224\374<\234\374<\234\374<\234\374<\234\374<\234\374<" + "\234\374<\234\374E\233\374<\234\374E\233\374<\234\374<\234\374<\234\374" + "<\234\374<\234\374<\234\374<\224\3744\224\3744\224\3744\224\374,\224" + "\374,\214\374,\224\374,\224\374$\214\374$\214\374$\214\374$\214\374\34" + "\214\374\34\204\374\34\214\374\34\204\374\24\204\374\24\204\374\4\14" + "\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4\14\24\4" + "\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4\35<\5K\246\26|\372" + "\26|\372\24\204\374\24\204\374\24\204\374\14\204\374\4t\374\4|\374\4" + "t\374\4t\374\4t\374\4t\364\4|\374\4t\374\4t\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\14|\374\14\204\374" + "\14\204\374\24\204\374\24\204\374\24\204\374\24\204\374\34\204\374\34" + "\204\374\34\214\374$\214\374$\214\374$\214\374,\214\374,\214\374,\224" + "\3744\224\3744\224\3744\224\374<\224\374<\234\374<\234\374<\234\374<" + "\234\374E\233\374E\233\374E\233\374E\233\374E\233\374E\233\374E\233\374" + "E\233\374E\233\374E\233\374E\233\374<\224\374<\234\374<\234\374<\234" + "\374<\224\3744\224\3744\224\3744\224\3744\224\374,\224\374,\224\374," + "\214\374$\214\374$\214\374$\214\374$\214\374$\214\374\34\214\374\34\204" + "\374\24\204\374\24\204\374\4\14\34\4\14\34\4\14\34\4\14\34\4\14\34\4" + "\14\34\4\14\34\4\14\24\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14" + "\24\5""6l\6h\330\26|\372\24\204\374\24\204\374\24\204\374\24\204\374" + "\4|\374\4|\374\4|\374\4t\374\4t\374\4|\374\4|\374\4t\374\4|\374\4|\374" + "\4|\374\4|\374\4t\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\14|\374" + "\14|\374\14\204\374\24\204\374\24\204\374\24\204\374\24\204\374\34\204" + "\374\34\214\374\34\204\374$\214\374$\214\374$\214\374$\214\374,\224\374" + ",\214\3744\224\3744\224\3744\224\374<\234\374<\234\374<\234\374<\234" + "\374E\233\374E\233\374E\233\374E\233\374E\233\374E\233\374L\244\374E" + "\233\374L\244\374L\244\374L\244\374L\244\374E\233\374E\233\374E\233\374" + "E\233\374<\234\374<\234\374<\234\374<\234\374<\224\3744\224\3744\224" + "\3744\224\374,\224\374,\214\374,\224\374$\214\374$\214\374$\214\374\34" + "\214\374\34\214\374\34\214\374\34\204\374\24\204\374\4\14$\4\24$\4\14" + "$\4\14\34\4\24$\4\14\34\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\4\34,\5I\230\24\204\374\26|\372\34\204\374\24\204\374\24\204\374" + "\14\204\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4t\374\4|\374\4" + "|\374\4t\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\14\204\374\14|\374\14\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\34\204\374\34\214\374$\214\374$\214\374$\214\374,\214\374" + ",\224\374,\224\3744\224\3744\224\3744\224\374<\234\374<\234\374<\234" + "\374<\234\374E\233\374E\233\374E\233\374E\233\374L\244\374L\244\374L" + "\244\374L\244\374L\244\374L\244\374L\244\374L\244\374L\244\374L\244\374" + "L\244\374L\244\374E\233\374E\233\374E\233\374E\233\374<\234\374<\234" + "\374<\234\374<\224\3744\224\3744\224\3744\224\3744\224\374,\214\374," + "\224\374$\214\374$\214\374$\214\374$\214\374\34\214\374\34\214\374\24" + "\204\374\4\24$\4\14$\4\24$\4\24$\4\14$\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\4\4\14\4,X\7e\311\26|\372\34\204\374\34\214\374\34\204\374" + "\24\204\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4" + "|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\14|\374\14|\374\14|\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\34\204\374\34\214\374$\214\374$\214\374$\214\374,\224\374" + ",\214\3744\224\3744\224\3744\224\374<\224\374<\224\374<\234\374E\233" + "\374E\233\374E\233\374E\233\374E\233\374L\244\374L\244\374L\244\374L" + "\244\374L\244\374T\244\374T\244\374T\244\374T\244\374T\244\374T\244\374" + "T\244\374L\244\374L\244\374L\244\374E\233\374E\233\374E\233\374E\233" + "\374E\233\374<\234\374<\234\374<\234\374<\234\3744\224\3744\224\3744" + "\224\374,\224\374,\224\374,\224\374$\214\374$\214\374$\214\374\34\214" + "\374\34\214\374\4\24$\4\24,\4\24$\4\14$\4\4\14\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\4\14\24\4=~\26x\351$\203\373\34\204\374\34\204\374\34" + "\204\374\14\204\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4t\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\14|\374\14\204\374\14\204\374\14\204\374\24\204\374\24" + "\204\374\24\204\374\34\204\374\34\214\374\34\214\374$\214\374$\214\374" + ",\224\374,\224\374,\224\3744\224\3744\224\3744\224\374<\234\374<\234" + "\374<\234\374E\233\374E\233\374E\233\374L\244\374L\244\374L\244\374T" + "\244\374T\244\374T\244\374T\244\374T\244\374T\244\374T\244\374\\\254" + "\374T\244\374\\\254\374T\254\374T\244\374T\244\374T\244\374L\244\374" + "L\244\374L\244\374L\244\374L\244\374E\233\374E\233\374E\233\374<\234" + "\374<\224\374<\234\3744\224\374,\224\3744\224\374,\214\374,\224\374$" + "\214\374$\214\374$\214\374$\214\374\34\214\374\4\24,\4\24,\4\24$\4\4" + "\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\24$\5K\246\34\204\374\34\204" + "\374\34\204\374\34\214\374\34\204\374\14\204\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4t\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\14|\374\14|\374\14\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\34\214\374$\214\374" + "$\214\374$\214\374$\214\374,\224\374,\224\3744\224\3744\224\3744\224" + "\374<\234\374<\234\374<\234\374E\233\374E\233\374E\233\374L\244\374L" + "\244\374L\244\374T\244\374T\244\374T\244\374\\\254\374T\254\374T\244" + "\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254" + "\374\\\254\374\\\254\374T\244\374T\244\374T\244\374T\244\374L\244\374" + "L\244\374L\244\374E\233\374E\233\374E\233\374E\233\374<\234\374<\234" + "\3744\224\3744\224\3744\224\374,\224\374,\224\374$\214\374$\214\374$" + "\214\374\34\214\374\4\24,\4\14$\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\4\35<\31^\270\34\204\374$\203\373\34\214\374\34\214\374\24\204" + "\374\14|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\14\204\374\14\204\374\14\204\374\24\204\374\24\204\374\24\204\374\24" + "\204\374\34\204\374\34\214\374$\214\374$\214\374$\214\374,\224\374,\224" + "\3744\224\3744\224\3744\224\374<\234\374<\234\374<\234\374E\233\374E" + "\233\374L\244\374L\244\374L\244\374T\244\374T\244\374T\244\374T\254\374" + "\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374" + "\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374" + "\\\254\374\\\254\374T\254\374T\254\374T\244\374T\244\374L\244\374L\244" + "\374L\244\374E\233\374E\233\374E\233\374<\234\374<\234\3744\224\3744" + "\224\3744\224\374,\224\374,\224\374$\214\374$\214\374$\214\374\4\14$" + "\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4,X\32h\327$\203\373\34\204" + "\374$\214\374\34\214\374\24\204\374\14\204\374\4|\374\4|\374\4|\374\4" + "|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\4|\374\14|\374\14|\374\14|\374\14\204\374\14|\374\24\204" + "\374\24\204\374\24\204\374\34\214\374\34\214\374\34\214\374$\214\374" + "$\214\374$\214\374,\224\374,\214\3744\224\3744\224\374<\224\374<\234" + "\374<\234\374E\233\374E\233\374L\244\374L\244\374L\244\374L\244\374T" + "\244\374T\254\374T\244\374\\\254\374\\\254\374\\\254\374\\\254\374\\" + "\254\374\\\254\374\\\254\374g\252\372g\252\372g\252\372g\252\372g\252" + "\372g\252\372g\252\372g\252\372\\\254\374\\\254\374\\\254\374\\\254\374" + "\\\254\374\\\254\374T\244\374T\244\374L\244\374L\244\374L\244\374E\233" + "\374E\233\374E\233\374<\234\374<\234\374<\224\3744\224\3744\224\374," + "\224\374,\224\374$\214\374$\224\374\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\4\4\14\5""6d\26x\351$\203\373\34\214\374$\214\374\34\214\374\24" + "\204\374\14|\374\14|\374\14|\374\14|\374\14|\374\4|\374\14|\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\14\204\374\14|\374\14|\374" + "\14\204\374\14|\374\14\204\374\24\204\374\24\204\374\24\204\374\24\204" + "\374\24\204\374\34\204\374\34\214\374$\214\374$\214\374$\214\374,\224" + "\374,\214\3744\224\3744\224\3744\224\374<\234\374<\234\374<\234\374E" + "\233\374E\233\374E\233\374L\244\374L\244\374T\244\374T\244\374T\244\374" + "\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374g\252\372g\252\372" + "g\252\372l\264\374g\252\372l\264\374g\252\372l\264\374l\264\374l\264" + "\374l\264\374l\264\374g\252\372g\252\372\\\254\374\\\254\374\\\254\374" + "\\\254\374T\244\374T\244\374T\244\374T\244\374L\244\374L\244\374L\244" + "\374E\233\374E\233\374<\234\374<\234\374<\224\3744\224\3744\224\3744" + "\224\374,\224\374,\224\374\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\14\4=~" + "\34\177\364$\203\373$\203\373$\214\374\34\214\374\24\204\374\14|\374" + "\14|\374\14\204\374\14|\374\14|\374\14\204\374\14|\374\14\204\374\14" + "|\374\14\204\374\14|\374\14|\374\14|\374\14|\374\14|\374\14\204\374\14" + "|\374\14\204\374\14\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\34\204\374\34\214\374\34\214\374$\214\374$\214\374$\214\374,\214\374" + ",\224\374,\224\3744\224\3744\224\374<\224\374<\234\374<\234\374E\233" + "\374E\233\374E\233\374L\244\374T\244\374T\244\374T\244\374T\244\374\\" + "\254\374\\\254\374\\\254\374\\\254\374g\252\372g\252\372l\264\374g\252" + "\372l\264\374l\264\374g\252\372l\264\374l\264\374l\264\374l\264\374l" + "\264\374l\264\374l\264\374g\252\372l\264\374g\252\372g\252\372g\252\372" + "\\\254\374\\\254\374\\\254\374\\\254\374T\244\374T\244\374T\244\374T" + "\244\374L\244\374E\233\374E\233\374E\233\374<\234\374<\234\374<\224\374" + "4\224\3744\224\374,\224\374,\214\374\0\0\0\0\0\0\0\0\0\0\0\0\4\14\24" + "\5F\210$\203\373-\203\374$\214\374$\214\374\34\214\374\24\204\374\14" + "|\374\14\204\374\14|\374\14|\374\14\204\374\14\204\374\14\204\374\14" + "\204\374\14|\374\14|\374\14|\374\14\204\374\14|\374\14\204\374\14\204" + "\374\14\204\374\14\204\374\14\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\34\214\374\34\214\374\34\214\374$\214\374$\214" + "\374$\224\374,\224\374,\224\3744\224\3744\224\3744\224\374<\234\374<" + "\234\374E\233\374E\233\374L\244\374L\244\374L\244\374T\244\374T\244\374" + "T\244\374T\244\374\\\254\374\\\254\374\\\254\374g\252\372g\252\372g\252" + "\372l\264\374l\264\374l\264\374l\264\374l\264\374l\264\374l\264\374l" + "\264\374t\264\374t\264\374t\264\374l\264\374l\264\374l\264\374l\264\374" + "l\264\374l\264\374g\252\372g\252\372\\\254\374g\252\372\\\254\374\\\254" + "\374T\244\374T\254\374T\244\374L\244\374L\244\374E\233\374E\233\374E" + "\233\374<\234\374<\234\374<\224\3744\224\3744\224\374,\224\374\0\0\0" + "\0\0\0\0\0\0\4\14\24\5I\230$\203\373-\203\374,\224\374$\214\374$\214" + "\374\24\204\374\14\204\374\24\204\374\24\204\374\14\204\374\24\204\374" + "\14|\374\24\204\374\14\204\374\14|\374\14\204\374\14\204\374\14\204\374" + "\14\204\374\14\204\374\14|\374\24\204\374\24\204\374\14|\374\24\204\374" + "\24\204\374\24\204\374\34\214\374$\214\374$\214\374$\214\374$\214\374" + "$\214\374$\214\374,\224\374,\224\3744\224\3744\224\374<\224\374<\234" + "\374<\234\374E\233\374E\233\374E\233\374L\244\374L\244\374T\244\374T" + "\244\374T\244\374\\\254\374\\\254\374\\\254\374\\\254\374g\252\372g\252" + "\372l\264\374l\264\374l\264\374l\264\374l\264\374t\264\374l\264\374t" + "\264\374t\264\374t\264\374t\264\374t\274\374t\264\374t\274\374t\264\374" + "t\264\374t\264\374l\264\374l\264\374l\264\374l\264\374l\264\374g\252" + "\372g\252\372\\\254\374\\\254\374\\\254\374T\244\374T\244\374T\244\374" + "L\244\374L\244\374E\233\374E\233\374E\233\374<\234\374<\234\374<\224" + "\3744\224\3744\224\374\0\0\0\0\0\0\4\14\34\5I\230$\203\373-\203\374," + "\224\374$\214\374\34\214\374\24\204\374\24\204\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\14\204\374" + "\14|\374\24\204\374\24\204\374\24\204\374\14|\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\24\204\374\24\204\374\34\214\374$\214\374,\224" + "\3744\224\3744\224\3744\224\3744\224\374,\224\374,\214\3744\224\3744" + "\224\374<\224\374<\234\374<\234\374E\233\374E\233\374E\233\374L\244\374" + "L\244\374T\244\374T\244\374T\254\374T\244\374\\\254\374\\\254\374\\\254" + "\374g\252\372g\252\372g\252\372l\264\374l\264\374l\264\374t\264\374l" + "\264\374t\264\374t\264\374t\264\374t\274\374t\264\374t\274\374t\274\374" + "t\264\374t\274\374}\274\377t\264\374t\264\374t\274\374t\264\374t\264" + "\374l\264\374l\264\374g\252\372l\264\374l\264\374g\252\372g\252\372\\" + "\254\374\\\254\374\\\254\374T\244\374T\244\374T\244\374L\244\374L\244" + "\374E\233\374E\233\374<\234\374<\234\374<\224\3744\224\374\0\0\0\4\14" + "\34\5I\230-\203\374,\214\374,\224\374,\214\374$\214\374\24\204\374\24" + "\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204" + "\374\24\204\374\14|\374\24\204\374\24\204\374\24\204\374\24\204\374\24" + "\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\34\204" + "\374$\214\374,\224\3744\224\3744\224\3745\214\373<\224\374<\224\374<" + "\234\374<\224\3744\224\3744\224\374<\234\374<\234\374E\233\374E\233\374" + "E\233\374L\244\374L\244\374T\244\374T\244\374T\244\374T\244\374\\\254" + "\374\\\254\374\\\254\374g\252\372l\264\374l\264\374l\264\374l\264\374" + "l\264\374t\264\374t\264\374t\264\374t\264\374t\274\374t\274\374}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377t\274\374t\274\374t\264\374t\264\374l\264\374" + "l\264\374l\264\374l\264\374\\\254\374g\252\372\\\254\374\\\254\374\\" + "\254\374T\244\374T\244\374T\244\374L\244\374L\244\374E\233\374E\233\374" + "<\234\374<\234\3744\224\374\4\14\24\5I\230-\203\374,\214\374,\214\374" + ",\224\374\34\214\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24" + "\204\374\34\214\374\34\214\374$\214\374,\224\3744\224\3744\224\374<\224" + "\3745\214\373'\177\347'\177\347<\224\374E\233\374<\234\374<\224\374<" + "\224\374<\234\374E\233\374E\233\374L\244\374L\244\374T\244\374T\244\374" + "T\244\374T\244\374\\\254\374\\\254\374\\\254\374g\252\372g\252\372l\264" + "\374g\252\372g\252\372l\264\374l\264\374t\264\374l\264\374t\264\374t" + "\274\374t\264\374t\274\374t\264\374t\274\374}\274\377t\274\374}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377t\264\374t\274\374t\264\374t\264\374t\264\374l\264\374l\264\374l" + "\264\374g\252\372g\252\372\\\254\374\\\254\374\\\254\374T\244\374T\244" + "\374T\244\374L\244\374L\244\374E\233\374E\233\374<\234\374<\234\374\30" + "F\210$\203\3735\214\373,\224\374,\214\374$\214\374\34\214\374\24\204" + "\374\34\204\374\34\214\374\34\204\374\24\204\374\34\204\374\24\204\374" + "\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24" + "\204\374\34\214\374\34\204\374\34\214\374\34\214\374\34\214\374$\214" + "\3744\224\3744\224\374<\224\374<\224\3747\204\360\31^\270\5:Y\27@x7\204" + "\360Q\221\372L\244\374E\233\374E\233\374E\233\374E\233\374L\244\374L" + "\244\374T\244\374T\244\374\\\254\374\\\254\374\\\254\374\\\254\374g\252" + "\372g\252\372g\252\372l\264\374g\252\372l\264\374l\264\374l\264\374l" + "\264\374l\264\374l\264\374l\264\374l\264\374t\264\374t\264\374t\264\374" + "t\264\374t\264\374}\274\377t\264\374}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377t\274\374}\274\377t\264\374t\264\374t" + "\264\374l\264\374t\264\374l\264\374l\264\374l\264\374l\264\374g\252\372" + "\\\254\374\\\254\374\\\254\374T\244\374T\244\374T\244\374L\244\374E\233" + "\374E\233\374E\233\374<\234\374,\212\364-\203\374,\224\374,\224\374$" + "\214\374\34\214\374\34\204\374\34\214\374\34\214\374\34\214\374\24\204" + "\374\34\214\374\34\204\374\34\214\374\34\204\374\34\204\374\34\204\374" + "\34\214\374\34\204\374\34\204\374\34\204\374\34\214\374\34\214\374\34" + "\214\374$\214\374,\224\3744\224\3744\224\374<\224\3745\214\373-t\315" + "\30F\210\4\24$\0\0\0\4\14\24(b\246Q\221\372T\244\374L\244\374L\244\374" + "L\244\374L\244\374T\244\374T\244\374\\\254\374\\\254\374\\\254\374\\" + "\254\374\\\254\374g\252\372\\\254\374l\264\374\\\254\374g\252\372g\252" + "\372l\264\374g\252\372l\264\374g\252\372l\264\374l\264\374t\264\374t" + "\264\374t\274\374}\274\377}\274\377\204\274\374\212\304\374\212\304\374" + "\212\304\374\212\304\374\212\304\374\212\304\374\212\304\374\212\304" + "\374\212\304\374\212\304\374\212\304\374\204\274\374\204\274\374}\274" + "\377}\274\377t\264\374t\264\374l\264\374l\264\374l\264\374g\252\372g" + "\252\372g\252\372\\\254\374\\\254\374\\\254\374T\254\374T\244\374T\244" + "\374L\244\374L\244\374E\233\374E\233\3745\214\3734\224\374,\224\374$" + "\214\374\34\214\374\34\214\374\34\204\374\34\214\374\34\204\374\34\214" + "\374\34\214\374\34\204\374\34\214\374\34\204\374\34\214\374\34\204\374" + "\34\214\374\34\204\374\34\214\374\34\214\374\34\214\374\34\214\374$\214" + "\374,\214\3744\224\3744\224\374<\224\374<\224\3747\204\360\31^\270\4" + "$D\4\4\4\0\0\0\0\0\0\0\0\0\14/Q7\204\360]\240\374T\244\374T\244\374T" + "\244\374T\244\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\" + "\254\374g\252\372\\\254\374l\264\374\\\254\374g\252\372\\\254\374\\\254" + "\374\\\254\374g\252\372l\264\374t\264\374}\274\377\204\274\374\212\304" + "\374\230\311\374\230\311\374\230\311\374\246\313\373\234\324\374\246" + "\313\373\246\313\373\246\313\373\251\324\374\251\324\374\251\324\374" + "\251\324\374\251\324\374\246\313\373\246\313\373\246\313\373\246\313" + "\373\234\324\374\230\311\374\230\311\374\212\304\374\212\304\374}\274" + "\377t\264\374l\264\374l\264\374\\\254\374\\\254\374\\\254\374\\\254\374" + "\\\254\374\\\254\374T\244\374T\244\374T\244\374L\244\374E\233\374E\233" + "\3744\224\374,\224\374$\214\374\34\214\374\34\204\374\34\214\374\34\214" + "\374\34\214\374\34\214\374\34\214\374\34\214\374\34\204\374\34\214\374" + "\34\214\374\34\214\374\34\214\374\34\214\374$\214\374$\214\374$\214\374" + "$\214\374$\214\374,\214\3744\224\374<\234\374<\224\374<\224\374-t\315" + "\27@x\4\14\34\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\31[\231Q\221\372g" + "\252\372\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374" + "\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374\\\254\374" + "\\\254\374l\264\374l\264\374t\264\374\204\274\374\212\304\374\230\311" + "\374\230\311\374\246\313\373\251\324\374\246\313\373\251\324\374\251" + "\324\374\251\324\374\251\324\374\251\324\374\251\324\374\251\324\374" + "\251\324\374\246\313\373\251\324\374\246\313\373\251\324\374\251\324" + "\374\251\324\374\251\324\374\251\324\374\251\324\374\251\324\374\251" + "\324\374\251\324\374\246\313\373\234\324\374\230\311\374\230\311\374" + "\204\274\374}\274\377t\264\374g\252\372\\\254\374\\\254\374T\244\374" + "T\244\374T\254\374T\244\374L\244\374L\244\374E\233\3744\224\374,\214" + "\374$\214\374\34\214\374\34\204\374\34\214\374\34\214\374$\214\374\34" + "\214\374$\214\374\34\214\374\34\214\374\34\214\374$\214\374$\214\374" + "$\214\374$\214\374$\214\374$\214\374$\214\374,\214\3744\224\374<\234" + "\374<\234\374E\233\374<\224\374\31f\306\14/Q\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\14$@G\6YZv\310" + "\374;\225\326\6Z\205\6Z\205\6eu\7IO\6YZ\6eu\6eu\6eu\12j\253\31f\306\5" + "Y\270\34iu\6eu\6Z\205\6Z\205\6Z\230\31^\270\34x\300\34x\300\6Z\230\6" + "Z\230\6Z\205\6Z\230\5Y\270\7e\311\5""6d\4\4\14\0\0\0\0\0\0\0\0\0\0\0" + "\0\26""9Xi\236\352\204\274\374}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377\215\264\374i\236\352\26""9X\0\0\0\0\0\0\0\0\0" + "\0\0\0\14\17\24~\212\244\271\325\373\267\307\352\4\35<\0\0\0\0\0\0\0" + "\0\0\0\0\0\4\35<\6V\251\5[\306\5[\306\6h\330\6h\330\5l\3464\224\374T" + "\244\374T\244\374T\244\3744\224\374\24\204\374\24\204\374\10w\321\5(" + "\31\5>:\7IO\11m\217\6Z\205\6YZ\6eu\6eu\5>:\6YZ\34iu$\200\223\6Z\230\6" + "Z\205\6Z\230\6Z\230\6eu\6Z\205\12j\253\31f\306\5Y\270\5I\230\6Z\205\6" + "Z\205\6Z\230\6Z\230\7u\273\34x\300\6Z\230\6Z\205\11m\217\4\34$\0\0\0" + "\0\0\0\0\0\0\0\0\0\4\14\14""9f\242|\264\374}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377\204\274\374\204\264\3749f\242\4\14\34\0\0" + "\0\0\0\0\0\0\0\0\0\0[aq\267\307\352\306\341\374\310\327\371\4\14\24\0" + "\0\0\0\0\0\0\0\0\0\0\0\5""6l\5Y\270\5[\306\5[\306\7e\311\7e\311\26x\351" + "E\233\374T\244\374T\244\374L\244\374\34\214\374\24\204\374\24\204\374" + "\11Ly\4%\13\4""45\6Kf\6Kf\6eu\30Wb\34iu\6YZ\5>:\7IO\30Wb\6eu\6YZ\11L" + "y\6V\251\30w\330\12j\253\6Z\230\6Z\230\11m\217\5F\210\6eu\5F\210\5I\230" + "\6h\330\31f\306\11m\217\6eu\11m\217G\232\344W\244\352\4""2J\4\14\14\0" + "\0\0\0\0\0\0\0\0\0\0\0\4""2J\\\224\337\204\274\374}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377\215\264\374\\\224\337\14/Q\0\0\0\0\0\0\0" + "\0\0\0\0\0\14\17\24\230\243\270\306\341\374\306\341\374\310\327\371\4" + "\4\4\0\0\0\0\0\0\0\0\0\4\24$\5F\210\5Y\270\5Y\270\5[\306\7e\311\6h\330" + ",\212\364T\244\374T\244\374T\244\3744\224\374\24\204\374\24\204\374\10" + "w\321\5>:\5(\31\5>:(b\246\6Z\205\6Kf\6YZ\6YZ\6YZ\11Ly\11Ly\6Kf\7IO\6" + "Kf\6Z\205\6Z\230\6Z\230\6Kf\6eu\6Z\205\6Z\205\11m\217\31[\231\12j\253" + "\6Z\230\6Z\205\6Z\205\6Z\230\5l\346<\224\374\30w\330\5F\210\6Kf\4$D\4" + "\4\4\0\0\0\0\0\0\0\0\0\0\0\0,V\216w\251\371\204\274\374}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377\204\274\374\204\274" + "\374\204\264\374\204\264\374\204\264\374\204\264\374\204\264\374\204" + "\264\374\214\274\374\204\274\374\204\274\374\204\274\374}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377\204\274\374|\264\374" + "(b\246\4\4\24\0\0\0\0\0\0\0\0\0\0\0\0[aq\253\304\355\310\327\371\306" + "\341\374\271\325\373\0\0\0\0\0\0\0\0\0\0\0\0\4$L\5K\246\5Y\270\5Y\270" + "\5[\306\7e\311\5l\346E\233\374T\244\374T\254\374L\244\374$\214\374\24" + "\204\374\24\204\374\5I\230\4)(\5(\31\4""45\27]\251i\257\351\6eu\6Kf\34" + "iu\34iu\33V\206\11Ly\7IO\6Kf\34iu\34iu\11m\217\11m\217\6eu\6Kf\6Z\205" + "\27]\251\6Z\230\6Z\205\6eu\6eu\5[\3064\224\3743\226\361\5Y\270\5Y\270" + "\5Y\270\11Ly\6eu\5:Y\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\4\34,\\\224\337" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\214\274\374\204" + "\264\374\205\253\372i\236\352\\\224\337O\204\314Ls\266Ls\266Ls\266\\" + "\224\337^\231\357v\236\352\204\264\374\204\264\374\214\274\374\204\274" + "\374}\274\377}\274\377}\274\377}\274\377}\274\377\215\264\374\\\224\337" + "\14$@\0\0\0\0\0\0\0\0\0\0\0\0!$)\230\243\270\310\327\371\306\341\374" + "\310\327\371\310\327\371\0\0\0\0\0\0\0\0\0\4\4\24\5;t\6V\251\5Y\270\5" + "Y\270\5[\306\7e\311\31\207\352T\244\374T\244\374T\244\374<\234\374\24" + "\204\374\24\204\374\10w\321\4,X\5(\31\4)(\4)(\5F\210\227\273\372\11L" + "y\5:Y\7IO\7IO\7IO\6YZ\6YZ\6eu\6Kf\6Kf\11Ly\6Z\205\6Z\230\12j\253\11m" + "\217\6Z\205\6Kf\6Z\230\32h\327)v\367\34x\300\12j\253\12j\253\7u\273\12" + "j\253\6Z\230\6Kf\6eu\5F\210\4,\77\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\27@x" + "w\251\371}\274\377}\274\377\204\274\374\204\274\374\204\264\374i\236" + "\352O\204\3149f\242\32Aj\4,\77\15\37\40\14\14\14\26\26\32\15\37\40\14" + "$@\26""9X$Mz9f\242O\204\314i\236\352\205\253\372\214\274\374\204\274" + "\374\204\274\374}\274\377\204\274\374|\264\374,V\216\4\14\14\0\0\0\0" + "\0\0\0\0\0\4\4\4[aq\274\330\350\310\327\371\306\341\374\306\341\374\310" + "\327\371\0\0\0\0\0\0\0\0\0\4\24,\5F\210\5Y\270\6V\251\5Y\270\5Y\270\6" + "h\330<\224\374T\244\374T\254\374T\244\374$\214\374\24\204\374\26|\372" + "\6Kf\5(\31\4)(\4%\13\4)(\4,\77\234\324\374Ls\266\5>G\5>G\7IO\5>:\4""4" + "5\4""45\7IO\6Z\205\6Z\205\5F\210\5F\210\34iu\7IO\6Z\205\6Z\205,\210\315" + "F\252\354\26\205\251\11m\217\6V\251\5Y\270\6Z\230\11m\217$\200\223\34" + "iu\6eu\5F\210\11Ly\5;t\4\14\34\0\0\0\0\0\0\0\0\0\0\0\0\4\14\14O\204\314" + "\204\274\374\214\274\374\204\264\374i\236\352Ls\266\32Aj\4\34,\4\14\14" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\24\4\34," + "\26""9X,V\216O\204\314i\236\352\204\264\374\214\274\374\215\264\374O" + "\204\314\14$@\0\0\0\0\0\0\0\0\0\0\0\0,17\250\266\334\306\341\374\306" + "\341\374\306\341\374\306\341\374\310\327\371\0\0\0\0\0\0\0\0\0\4$L\5" + "I\230\5K\246\6V\251\5Y\270\5Y\270\15\202\340E\233\374T\244\374T\244\374" + "E\233\374\34\204\374\24\204\374\26x\351\4,\77\5(\31\4\26\31\5(\31\4)" + "(\4""2J,V\216\271\325\373\5:Y\5>:\4""45\4""45\4""45\30Wb$\200\223$\200" + "\223\11Ly\6Kf\11Ly\6eu\6Z\205,\210\315\6Z\230\6Z\205\6Z\205\11m\217," + "\210\315\26\205\251\6Z\230\11m\217\26\205\251\11m\217\6eu\5I\230\5K\246" + "\\\224\337\11Ly\4$L\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\5:Yi\236\352i\236" + "\352Ls\266\32Aj\4\24$\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\4\34,\32Aj/p\267v\236" + "\352w\251\371$Mz\4\4\14\0\0\0\0\0\0\0\0\0\4\4\4ox\214\274\330\350\306" + "\341\374\306\341\374\306\341\374\310\327\371\271\325\373\0\0\0\0\0\0" + "\4\4\14\5""6d\5K\246\6V\251\5Y\270\5Y\270\5[\306$\214\360T\244\374T\244" + "\374T\244\3744\224\374\24\204\374\24\204\374\6V\251\4\34,\4\26\31\4\26" + "\31\4)(\26""8J\4""45\5>G\224\324\354\214\304\334\7IO\5>:\5>:\5>:\4""4" + "5\7IO\6eu\11Ly\11m\217\26\205\251\33V\206\11Ly\6Z\205\6Z\230\6Z\230\6" + "Z\230\6Z\205\11m\217\12j\253\7e\311\5Y\270\6Z\205\6eu\11Ly\5K\246\27" + "]\251\11Ly\5F\210\5F\210\14$@\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4$Mz\32Aj\4" + "\24$\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\34\26""9" + "X$Mz\4\34""4\0\0\0\0\0\0\0\0\0\0\0\0,17\232\255\332\271\325\373\251\324" + "\374\271\325\373\271\325\373\271\325\373\270\311\367\0\0\0\0\0\0\4\14" + "$\4=~\5K\246\5K\246\5K\246\6V\251\7e\3113\226\361T\244\374T\244\374L" + "\244\374$\214\374\24\204\374\24\204\374\6Kf\4\34$\4\14\14\15\37\40\4" + ")(\5>:\4""45\4""2J\30Wb\306\341\374\30Wb\5>G\4)(\5>:\5>G\6YZ\34iu\11" + "m\217\11m\217\6Z\205\6eu\6Z\205\6Z\205\6Z\230\6Z\230\6Z\230\12j\253\11" + "m\217\6V\251\20X\367\5[\306\6Z\205\6eu\5F\210\5K\246;\225\326W\244\352" + "g\252\372W\244\352\33V\206\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\4\14\34\4\14\34\4" + "\14\34\4\14\34\4\14\24\14\14\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14ox\214\253\304" + "\355\270\311\367\271\325\373\251\324\374\271\325\373\270\311\367\270" + "\311\367\0\0\0\0\0\0\4\35<\5F\210\5K\246\5K\246\6V\251\6V\251\30w\330" + "E\233\374T\244\374\\\254\374E\233\374\34\204\374\24\204\374\31\207\352" + "\7IO\4\26\31\4%\13\14\14\14\5>G\4)(\5>G\4,\77\5>:Ls\266\34iu\7IO\5>:" + "\7IO\6YZ$\200\223$\200\223\6eu\6eu\6Z\205\6eu$\200\223\11m\217\11m\217" + "\6Z\230\11m\217\26\205\251;\225\326\6Z\230\32c\347E\233\374$\200\223" + "\6Z\205)v\3677c\367\31f\306;\225\326/p\267\5I\230\5F\210\4\35<\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\14" + "\4\24$\4\34E\5*f\4=~\26D\226\34L\24249\221ox\214EMW!$)\14\14\14\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0,17\232\255" + "\332\270\311\367\270\311\367\251\324\374\270\311\367\271\325\373\270" + "\311\367\270\311\367\0\0\0\4\4\4\4,X\5I\230\5K\246\5K\246\6V\251\5Y\270" + "\26x\351L\244\374T\244\374T\244\374,\224\374\24\204\374\24\204\374\12" + "j\253\5>:\4)(\4%\13\4%\13\4)(\5>G\4$L\4""2J\5:Y\5>:$\200\223\6YZ\5>:" + "\5>:\6YZ\6YZ\6eu\6eu\11m\217\11m\217\11m\217\6Z\205\6Z\205\6Z\205\6Z" + "\230\12j\253\6Z\230\12j\253\5K\246Iw\371H\210\355\6Z\205\12j\253jt\371" + "Iw\371\5I\230\5F\210\5F\210/p\267\5F\210\33V\206\4\24$\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\24\4\34,\14/Q\17""3v\26D\226" + "\31[\231\34x\300\31f\306\32h\3277S\323\377\377\377\355\357\373\266\276" + "\323ox\214EMW!$)\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\26\26" + "\32~\212\244\267\307\352\270\311\367\271\325\373\271\325\373\271\325" + "\373\271\325\373\270\311\367\270\311\367\0\0\0\4\14\24\5""6l\5I\230\5" + "I\230\5K\246\5K\246\5Y\270'\177\347T\244\374\\\254\374T\244\374$\214" + "\374\24\204\374\24\204\374\6Z\230\4""45\4""45\5(\31\4""45\7IO~\212\244" + "\27@xl\215\315l\215\315\5:Y\34iu\7IO\5>:\6YZ\6YZ\6YZ\6eu\11m\217\26\205" + "\251\12j\253\6Z\205\6Z\230\12j\253\12j\253\31^\270\6V\251\6Z\205\5Y\270" + "X^\367Iw\371\5K\246\6Z\230\34x\300\7e\311\6V\251\5F\210\31^\270G\232" + "\344/p\267\6Z\205(b\246\5:Y\4\34,\4\14\24\0\0\0\0\0\0\0\0\0\4\4\4\4\14" + "\24\4\34$\15.C\32Aj\5;t\4=~,V\216\31[\231(b\246\5K\246\31^\2707S\323" + "\355\357\373\377\377\377\355\357\373\355\357\373\326\332\353\230\243" + "\270[aq!$)\14\14\14\0\0\0\0\0\0\0\0\0\4\4\14!$)ox\214\267\307\352\271" + "\325\373\271\325\373\271\325\373\271\325\373\271\325\373\271\325\373" + "\271\325\373\270\311\367\0\0\0\4\24$\4=~\5I\230\5I\230\5K\246\6Z\230" + "\5Y\270=\216\361T\244\374T\254\374E\233\374\34\214\374\24\204\374\26" + "|\372G\4""45\4""45\4""45\4""45\5:Y\4,\77i\236\352\215\264\374" + "\5:Y\7IO\6YZ\7IO\7IO\6YZ\6eu\11m\217\11m\217\12j\253\26\205\251'\177" + "\347\6V\251\6V\251\30w\330T\244\374]\240\374\32c\347Q\221\372jt\371Z" + "\200\345\5F\210\11m\217\7u\273\5[\306<\224\374\32h\327\5F\210\6Z\205" + "\6Kf\6Z\205,\210\315\6Kf\5F\210\27@x\5#V\4\24,\4\24,\4)(\4,\77\4""2J" + "\5""6l\30F\210\33V\206\5*f\4$L\4$D\15.C\4\34""4\4\35<\14$@[aq~\212\244" + "\230\243\270\266\276\323\326\332\353\326\332\353\324\324\334\230\243" + "\270ox\214EMW,17EMW[aq\230\243\270\267\307\352\270\311\367\310\327\371" + "\310\327\371\271\325\373\306\341\374\306\341\374\306\341\374\310\327" + "\371\310\327\371\0\0\0\4\24""4\5F\210\5I\230\5I\230\5K\246\6V\251\7e" + "\311E\233\374T\244\374\\\254\374<\234\374\34\204\374\24\204\374)v\367" + "\227\273\372\4""45\4)(\4""45\5>:\5>:\5>:\5>:\5>:\12j\253\7u\273\6eu\6" + "eu\6eu\6eu\6eu$\200\223\11m\217\7u\273\26x\351\25N\344\26\205\251\7u" + "\273-\203\374\204\224\373\233\255\373H\210\355)v\367Iw\371\34\204\374" + "\12j\253\6Z\205\32c\347]\240\374'\177\347\7e\311(\246\275\11m\217\6Z" + "\230\11Ly\246\313\373\214\304\354\6Kf\6Z\230\34x\300\5:Y\5:Y\5>G\6Kf" + "\6eu\30Wb\30Wb\14$@\4\24$\4\14\24\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0" + "\4\4\4\14\14\14\26\26\32,17[aq~\212\244\266\276\323\324\324\334\324\324" + "\334\266\276\323\266\276\323\266\276\323\306\313\352\270\311\367\306" + "\313\352\267\307\352\271\325\373\271\325\373\271\325\373\271\325\373" + "\271\325\373\271\325\373\270\311\367\270\311\367\0\0\0\4$D\5F\210\5I" + "\230\5I\230\5I\230\5K\246\30w\330E\233\374T\244\374T\244\374,\224\374" + "\24\204\374\14\204\374\25N\344O\204\314\5:Y\4)(\4""45\5>:\5>:\7IO\5>" + ":\6YZ\6Z\205\12j\253\11m\217\6eu\6eu\11m\217\11m\217\26\205\251\26\205" + "\251\7u\273\10w\321\7e\311\5K\246\26x\351)v\367:\5>G\5>:\6" + "Kf\6V\251\7u\273\26\205\251\6eu\11m\217(\246\275(\246\275\17\214\304" + "\10w\321\6B\3127c\367\204\224\373u\210\372Iw\371\25N\344\5I\230\5Y\270" + "\7e\311\5[\306\5Y\270,\210\315\11m\217\7e\311%V\370%V\370%V\370)v\367" + "v\310\374\17\214\304\34x\300\31[\231\33V\206\7IO\6YZ\11m\217(\246\275" + "$Mz\6Kf\6Kf\4\34""4\4\14\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\14" + "\14\14EMW\230\243\270\326\332\353\306\313\352\311\324\353\310\327\371" + "\267\307\352\267\307\352\270\311\367\271\325\373\271\325\373\271\325" + "\373\271\325\373\271\325\373\270\311\367\270\311\367\4\4\24\5""6d\5I" + "\230\5I\230\5I\230\5I\230\5Y\270,\212\364L\244\374T\244\374L\244\374" + "\34\214\374\24\204\374$\214\374u\210\372\31^\270\7IO\5>G\30Wb\5>:\7I" + "O\5>G\7IO\7IOG\232\344\12j\253\7u\273\11m\217(\246\275\26\205\251\5K" + "\2467S\323\204\224\373\204\224\373Iw\371%V\370\5K\246\5[\306\6V\251\7" + "e\311)v\367\26r\367$\203\373\5[\306\12j\253\34x\300u\210\372X^\367%V" + "\370\6h\330\7u\273\17\214\304\11m\217\6eu\6Kf\7IO\6YZ\6eu\6eu\34iu\5" + ";t\5:Y\4\24$\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4" + "\14\14\4\4\14\4\14\14\4\14\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0,17\230\243\270\306\313\352\306\313\352\310\327\371\306" + "\312\367\267\307\352\271\325\373\271\325\373\251\324\374\271\325\373" + "\271\325\373\271\325\373\270\311\367\270\311\367\4\14\34\5""6l\5I\230" + "\5I\230\5I\230\5I\230\5[\3065\214\373L\244\374T\244\374E\233\374\34\204" + "\374\24\204\374\10w\321}\274\377Q\221\372\7IO\5>:\5>:\6YZ\7IO\5>:\7I" + "O\7IO0\212\341\12j\253\6Z\230\7u\273\6B\3127c\367u\210\372\204\224\373" + "jt\371-t\315\7e\311\17\214\304\4|\3637\250\374\10w\321\6h\330\6B\312" + "\6B\312Iw\371\31f\306\5I\230:\5>G\5>G\4""2J\7IO\7IO\5Y\270" + "\5[\3060\212\341T\244\374%V\3707c\367\26r\367\10w\321\7u\273\17\214\304" + "\15\202\340\24\204\374\34\214\374\10w\321\6V\251\32c\347Iw\371u\210\372" + "Z\200\345\5I\230\5Y\270'\177\347\17\214\304\11m\217\6Z\230\11m\217\6" + "eu$\200\223\26\205\251\34iu\11Ly\6Z\205\6eu\6Z\205\6Kf\5:Y\4\34$\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\24$\32AjLs\266\\\224\337i\257\351" + "l\264\374|\264\374t\264\374t\264\374g\252\372\\\224\337Ls\266,V\216\4" + "\34""4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\26\26\32~\212\244\271\325" + "\373\306\313\352\267\307\352\270\311\367\270\311\367\251\324\374\271" + "\325\373\271\325\373\271\325\373\270\311\367\270\311\367\4\24,\4=~\5" + "I\230\5I\230\5I\230\6V\251\30w\330<\224\374L\244\374T\244\374,\224\374" + "\24\204\374\24\204\374\30w\330\11LyIw\371\4,\77\4)(\5(\31$\200\223\5" + ">G\7IO\7IO\34iu\34x\300\6h\330L\244\374T\244\374\4\224\374\17\214\304" + "\7u\273\7u\273\26x\351\26r\367\4t\364\6h\330\6h\330\5I\230\5Y\270\24" + "\204\364$\214\374T\244\374\27]\251\12j\253\34\304\344\7u\273\5F\210\6" + "Z\205\17\214\304(\246\275$\200\223$\200\223\11Ly\7IO\7IO\6Z\205$\200" + "\223\26\205\251\34iu\4\24$\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\26""9" + "XLs\266g\252\372\204\264\374\204\264\374\204\274\374\204\274\374\204" + "\274\374\204\274\374\204\264\374\204\274\374\204\264\374\204\264\374" + "t\264\374O\204\314$Mz\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0,17\230\243" + "\270\267\307\352\267\307\352\270\311\367\251\324\374\270\311\367\251" + "\324\374\251\324\374\271\325\373\270\311\367\270\311\367\4\34""4\5F\210" + "\5I\230\5K\246\5I\230\6V\251\26x\351<\224\374L\244\374L\244\374,\214" + "\374\24\204\374\24\204\374l\264\374\6YZ\31f\306\4)(\4""45\5(\31\4=~\5" + ">G\5>G\5>:\6YZ\34x\300\6Z\230\7e\311\6Z\230\26\205\251\7u\273$\224\374" + "-\203\374\6h\330\5[\306\7e\311\4t\374v\236\352\233\255\373^\231\357\24" + "\204\364\10w\321\12j\253\6Z\230\7u\273$\200\223\6Z\230\12j\253\17\214" + "\304\4\220\344\7u\273\11m\217\11Ly\5;t\4=~\31[\231\31[\231\6eu\6Kf\4" + "\34,\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\14,V\216i\236\352}\274\377\204" + "\274\374\204\274\374}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377\204\274\374\204\264\374g\252\3729f\242" + "\4\24$\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0EMW\250\266\334\267\307\352\270\311" + "\367\270\311\367\251\324\374\270\311\367\271\325\373\271\325\373\270" + "\311\367\270\311\367\4\34E\5F\210\5K\246\5I\230\5I\230\5K\246'\177\347" + "E\233\374L\244\374E\233\374$\214\374\24\204\374\24\204\364/p\267<\224" + "\374\26x\351\11m\217\26\205\251\5>G\4\34,\4""45\4,\77\4""2J\7IO\11Ly" + "\12j\253\7u\273\10w\321\4|\374\14\204\374\10w\321\17\214\304\15\202\340" + "\14|\374\27""1\352\27""1\352,\224\374\14}\362\10w\321\10w\321(\246\275" + "\26\205\251\12j\253\12j\253\6Z\230\6V\251\11m\217\26\205\251\11m\217" + "\26\205\251\6Z\205\6YZ\5Y\270\12j\253\6Z\205\6eu\6eu\6Kf\4\14\24\0\0" + "\0\0\0\0\0\0\0\0\0\0\4\4\4,V\216w\251\371\204\274\374}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377\204\274\374\204\274\374|\264\374Ls\266" + "\14\34,\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4ox\214\267\307\352\267\307\352\253" + "\304\355\270\311\367\246\313\373\251\324\374\270\311\367\270\311\367" + "\270\311\367\4$L\5I\230\5I\230\5K\246\5I\230\5Y\270'\177\347<\224\374" + "L\244\374E\233\374\34\214\374\24\204\374\30w\330\11Ly,\210\315\7u\273" + "(\246\275$\200\223\5>G\5(\31\4%\13\4""2J\26""9X\5>:\6Kf\34x\300,\234" + "\3745\214\373\24\204\364\15\202\340\10w\321\34\177\364E\233\374Q\221" + "\372\26r\367\10w\321\17\214\304\7u\273\7u\273\12j\253\26\205\251\26\205" + "\251\6Z\230\5Y\270;\225\326\6Z\230\12j\253\11m\217\11m\217l\264\374\6" + "Z\205\34iu$\200\223\11m\217\6Z\205\6Z\205\34x\300\15.C\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0$Mzw\251\371\204\274\374}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377\204\274\374\204\264\374" + "9f\242\4\26\31\0\0\0\0\0\0\0\0\0\0\0\0,17\230\243\270\253\304\355\270" + "\311\367\253\304\355\251\324\374\251\324\374\271\325\373\270\311\367" + "\270\311\367\4$L\5I\230\5K\246\5K\246\5K\246\5Y\270$\214\360E\233\374" + "L\244\374<\234\374\34\214\374\24\204\374\10w\321\4,\77\11Ly\6YZ$\200" + "\223\5>:\5(\31\15\37\40\5(\31\4,X$Mz\34iu\6YZ\6Z\205\11m\217\12j\253" + "\17\214\3047\250\374\205\253\372g\252\372<\224\374\7u\273\17\214\304" + "\17\214\304\17\214\304\7u\273\26\205\251\7u\273\11m\217\6V\251\7e\311" + "\32h\327\6Z\205\6V\251\30w\330F\252\354\10w\321T\254\374\6Z\230\6eu\6" + "eu\12j\253\12j\253\12j\253\11Ly\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\15.C" + "\\\224\337\204\274\374}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377\214\274\374w\251\371$M" + "z\4\14\14\0\0\0\0\0\0\0\0\0\4\4\14ox\214\253\304\355\253\304\355\246" + "\313\373\270\311\367\251\324\374\270\311\367\270\311\367\246\313\373" + "\4,X\5K\246\5K\246\6V\251\5K\246\7e\311,\212\364E\233\374E\233\374<\224" + "\374\34\204\374\26|\372\31^\270\4""2J\4""45\7IO\7IO\4""45\5(\31\4)(\4" + "%\13\4)(\4,\77\5>G\6YZ\6Kf\7u\2737\250\374\6YZ\6eu\17\214\304\12j\253" + "\7u\273\11m\217\26\205\251(\246\275\12j\253\7u\273\6Z\2300\212\341\7" + "u\273\11m\217\7e\311\6Z\230\6V\251t\264\374\34x\300\26\205\251\26\205" + "\251\6eu\6Z\205\6Z\205\5Y\270\6V\251\6Z\205\6Z\205\5>G\4\4\4\0\0\0\0" + "\0\0\0\0\0\4\4\4/p\267\215\264\374}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377\215\264\374\\\224\337\14$@\0\0\0\0\0\0\0\0\0\0\0\0EMW\250\266" + "\334\253\304\355\251\324\374\251\324\374\251\324\374\271\325\373\270" + "\311\367\270\311\367\5*f\6V\251\5Y\270\6V\251\5Y\270\6h\330,\214\374" + "<\224\374E\233\374<\224\374\34\204\374\26|\372\6V\251\4\34""4\4)(\30" + "Wb\4""45\4""45\4\34$\4\26\31\4%\13\4)(\4)(\26""8J\6YZ\6Kf\12j\253\26" + "\205\251\6YZ\6eu(\246\275\26\205\251\26\205\251\11m\217\6Z\230\6Z\230" + "\32c\347Iw\371'\177\347\7e\311\11m\217\26\205\251F\252\354\30w\330i\257" + "\351\12j\253\6Z\205\26\205\251\11m\217\26\205\251v\310\374\6eu\6Z\205" + "\11m\217\6Z\205\6eu\4\34""4\0\0\0\0\0\0\0\0\0\0\0\0\4,Xw\251\371}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377\204\274\374w\251\371,V" + "\216\4\14\24\0\0\0\0\0\0\0\0\0!$)\230\243\270\253\304\355\270\311\367" + "\246\313\373\251\324\374\251\324\374\246\313\373\270\311\367\4\24$\4" + "$D\4$D\4\34E\4$D\4,X\5""6l\32Aj\32Aj\32Aj\5""6l\5""6l\4,X\4\14\34\4\14" + "\24\4\26\31\4\14\14\4\14\14\4\14\14\4\14\14\4\14\14\4\14\24\4\26\31\4" + "\26\31\4\26\31\14$@\14/Q\4)(\4)(\4)(\15.C\4""45\5>:\5>G\5:Y\5#V\5#V\5" + "#V\5#V\4\35<\4\35<\30Wb\4""2J\4,\77\4\34""4\4\35<\4\35<\4""45\6YZ\6K" + "f,\210\315\6Z\205\11m\217\11m\217\6Z\230\31[\231\14\34,\0\0\0\0\0\0\0" + "\0\0\0\0\0""9f\242|\264\374}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377\204\274\374\204\264\374O\204\314\14\34,\0\0\0\0\0\0\0\0\0\14" + "\17\24~\212\244\253\304\355\246\313\373\251\324\374\251\324\374\270\311" + "\367\232\255\332~\212\244\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4" + "\4\4\4\4\14\0\0\0\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\0\0\0\4\4\4\0\0\0" + "\4\4\4\0\0\0\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\4\4\4\4\4\4\0\0\0\0\0\0\4\14\14\4\14\24\4,\77\6Kf\6" + "Z\205\34x\300\34x\300\11Ly\4\14\24\0\0\0\0\0\0\0\0\0\4\34,G\232\344\204" + "\274\374}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\214" + "\274\374i\236\352\26""9X\0\0\0\0\0\0\0\0\0\4\4\4[aq\243\275\346\246\313" + "\373\251\324\374\243\275\346[aq!$)\14\17\24\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\4\24""4\6Kf\11m\217\11m\217\4""2J\4\4\4\0\0\0\0\0\0\0\0\0\14" + "$@i\236\352}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377\204\274\374w\251\371$Mz\4\4\4\0\0\0\0\0\0\0\0\0EMW\232\255" + "\332\246\313\373\243\275\346EMW\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\4\34,\6Kf\11Ly\4\35<\0\0\0\0\0\0\0\0\0\0\0\0\26" + "8Jv\236\352}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377\204\264\374\204\264\364,V\216\4\14\14\0\0\0\0\0\0\0\0\0""0" + "8P\232\255\332\251\324\374ox\214\4\14\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\26\31\5:Y\6Kf\4\34""4\0\0\0\0\0\0\0" + "\0\0\0\0\0\32Ajz\257\352}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377\204\274\374\204\264\3649f\242\4\14\24\0\0" + "\0\0\0\0\0\0\0,17\214\304\334\253\304\355EMW\0\0\0\0\0\0\0\0\0\0\0\0" + "\5""6l\5;t\5""6l\32Aj\5""6l\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32" + "Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32" + "Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32Aj\32" + "Aj\32Aj\32Aj\32Aj\32Aj\27@x\26""9X\4\24,\0\0\0\0\0\0\0\0\0\4\4\14\5:" + "Y\5""6l\4\34""4\4\4\4\0\0\0\0\0\0\0\0\0\32Ajz\257\352}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\204\274\374\204" + "\264\3749f\242\4\14\14\0\0\0\0\0\0\0\0\0,17\243\275\346\232\255\332," + "17\0\0\0\0\0\0\0\0\0\4\14\24Q\221\372H\210\355Q\221\372Q\221\372Q\221" + "\372^\231\357w\251\371\204\264\364\204\264\364\204\264\364w\251\371w" + "\251\371w\251\371w\251\371g\252\372i\236\352g\252\372i\236\352g\252\372" + "i\236\352g\252\372i\236\352g\252\372i\236\352g\252\372i\236\352g\252" + "\372i\236\352g\252\372i\236\352g\252\372i\236\352g\252\372i\236\352g" + "\252\372i\236\352g\252\372i\236\352g\252\372i\236\352g\252\372i\236\352" + "g\252\372i\236\352g\252\372i\236\352w\251\371Q\221\372\5""6l\4\4\4\0" + "\0\0\0\0\0\0\0\0\4,\77\5;t\26""8J\4\4\4\0\0\0\0\0\0\0\0\0""08Pv\236\352" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "\204\264\374\204\264\364$Mz\14\14\14\0\0\0\0\0\0\0\0\0""08P\243\275\346" + "\230\243\270\15\37\40\0\0\0\0\0\0\0\0\0\4\35<]\240\374\\\254\374\\\254" + "\374g\252\372\\\254\374l\264\374\214\274\374\230\311\374\246\313\373" + "\230\311\374\214\274\374\214\274\374\214\274\374\204\264\374\204\264" + "\374\204\274\374\204\264\374\204\274\374\204\264\374\204\274\374\204" + "\264\374\204\274\374\204\264\374\204\274\374\204\264\374\204\274\374" + "\204\264\374\204\274\374\204\264\374\204\274\374\204\264\374\204\274" + "\374\204\264\374\204\274\374\204\264\374\204\274\374\204\264\374\204" + "\274\374\204\264\374\204\274\374\204\264\374\204\274\374\204\264\374" + "\204\274\374\204\274\374\204\274\374\215\264\374l\264\374$Mz\4\4\14\0" + "\0\0\0\0\0\0\0\0\4,\77\5:Y\4""2J\4\4\14\0\0\0\0\0\0\0\0\0\4$D^\231\357" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "\204\264\374w\251\371$Mz\4\4\4\0\0\0\0\0\0\0\0\0EMW\246\313\373~\212" + "\244\26\26\32\0\0\0\0\0\0\0\0\0\4$D\\\254\374\\\254\374\\\254\374\\\254" + "\374\\\254\374g\252\372\204\274\374\230\311\374\230\311\374\212\304\374" + "\212\304\374\212\304\374\212\304\374}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\204\264\374" + "|\264\364$Mz\4\4\4\0\0\0\0\0\0\0\0\0\26""8J\5:Y\4""2J\4\14\24\0\0\0\0" + "\0\0\0\0\0\4\24$\\\224\337\204\274\374}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377\214\274\374i\236\352\26""9X\0\0\0\0\0\0\0" + "\0\0\4\4\4ox\214\251\324\374ox\214\14\17\24\0\0\0\0\0\0\0\0\0\14$@T\244" + "\374T\244\374\\\254\374\\\254\374\\\254\374\\\254\374}\274\377\230\311" + "\374\230\311\374\230\311\374\212\304\374\214\274\374\204\274\374}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377\204\264\374\204\264\374$Mz\14\14\14\0\0\0\0\0\0\0\0" + "\0\26""8J\6Kf\7IO\4\26\31\0\0\0\0\0\0\0\0\0\0\0\0""9f\242|\264\374}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377\204\274\374\204\264\374" + "O\204\314\14\34,\0\0\0\0\0\0\0\0\0\26\26\32~\212\244\251\324\374ox\214" + "\4\14\24\0\0\0\0\0\0\0\0\0\26""8JT\244\374T\244\374T\244\374T\244\374" + "T\244\374\\\254\374}\274\377\230\311\374\230\311\374\230\311\374\212" + "\304\374\212\304\374\212\304\374}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\204\274\374\204" + "\264\3749f\242\4\14\24\0\0\0\0\0\0\0\0\0\4\24$\5>G\6eu\4""45\0\0\0\0" + "\0\0\0\0\0\0\0\0\4,Xi\236\352\204\274\374}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377\214\274\374w\251\371$Mz\4\14\14\0\0\0\0\0\0\0\0\0," + "17\232\255\332\251\324\374[aq\4\4\14\0\0\0\0\0\0\0\0\0\32AjL\244\374" + "T\244\374T\244\374\\\254\374\\\254\374\\\254\374t\264\374\212\304\374" + "\230\311\374\230\311\374\212\304\374\212\304\374\212\304\374}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377\204\274\374\204\264\374/p\267\4\34,\0\0\0\0\0\0\0\0\0!" + "$)\5>G\5""6l\26""8J\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0/p\267\204\264\374}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377\204\274\374\215\264\374O\204\314\14$" + "@\0\0\0\0\0\0\0\0\0\0\0\0EMW\241\264\345\253\304\355EMW\4\4\4\0\0\0\0" + "\0\0\0\0\0\33V\206T\244\374T\244\374T\244\374T\244\374T\244\374T\244" + "\374t\264\374\212\304\374\230\311\374\230\311\374\212\304\374\212\304" + "\374\212\304\374\204\274\374}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377\204\264\374O\204\314" + "\14\34,\0\0\0\0\0\0\0\0\0\4\14\14\5:Y\5:Y\4$D\4\4\14\0\0\0\0\0\0\0\0" + "\0\0\0\0\14$@\\\224\337\204\264\374}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\215\264\374" + "i\236\352$Mz\4\4\4\0\0\0\0\0\0\0\0\0\4\14\14ox\214\271\325\373\266\276" + "\32308P\0\0\0\0\0\0\0\0\0\4\4\4""9f\242L\244\374T\244\374T\244\374T\244" + "\374\\\254\374T\244\374l\264\374\212\304\374\230\311\374\230\311\374" + "\212\304\374\212\304\374\212\304\374\204\274\374}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\215" + "\264\374\\\224\337\25*H\0\0\0\0\0\0\0\0\0\0\0\0\4)(\5>G\5""6d\4\24$\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\27@xw\251\371\204\274\374}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\214\274" + "\374|\264\3749f\242\4\14\34\0\0\0\0\0\0\0\0\0\0\0\0,17\232\255\332\306" + "\341\374\230\243\270!$)\0\0\0\0\0\0\0\0\0\4\14\34Ls\266L\244\374L\244" + "\374T\244\374T\244\374T\244\374T\244\374\\\254\374\204\274\374\230\311" + "\374\230\311\374\212\304\374\212\304\374\212\304\374\212\304\374}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377\214\274\374t\264\374\32Aj\4\4\14\0\0\0\0\0\0\0\0\0" + "\4\34,\4""2J\5""6d\4$L\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0$Mzw\251" + "\371\204\264\374}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377\204\264\374|\264\3749f\242\4\24$\0\0\0\0\0\0\0\0\0\0\0\0\14\14\14" + "ox\214\271\325\373\306\341\374ox\214\14\14\14\0\0\0\0\0\0\0\0\0\4$DO" + "\204\314L\244\374L\244\374L\244\374T\244\374T\244\374T\244\374T\244\374" + "}\274\377\230\311\374\212\304\374\230\311\374\212\304\374\212\304\374" + "\212\304\374}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377\204\274\374|\264\3749f\242\4\14\24\0" + "\0\0\0\0\0\0\0\0\26\26\32$Mz\32Aj\6Kf\4\34""4\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\4\4\4$Mz\\\224\337|\264\374\204\274\374}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\204" + "\274\374\204\264\374i\236\3529f\242\4\26\31\0\0\0\0\0\0\0\0\0\0\0\0\4" + "\4\4EMW\274\330\350\335\345\373\241\264\34508P\0\0\0\0\0\0\0\0\0\0\0" + "\0\26""9Xi\236\352L\244\374L\244\374L\244\374T\244\374T\244\374T\244" + "\374T\244\374t\264\374\212\304\374\230\311\374\212\304\374\212\304\374" + "\214\274\374\212\304\374\204\274\374}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\215\264\374" + "O\204\314\4\34""4\0\0\0\0\0\0\0\0\0\0\0\0\4,\77\5:Y\5:Y\5:Y\4\34,\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\14/Q/p\267i\236\352\205\253\372\204" + "\274\374\204\264\374\204\274\374\204\274\374\204\274\374\204\274\374" + "\204\274\374\204\264\374\204\264\374v\236\352O\204\314\32Aj\4\14\24\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0,17\266\276\323\306\341\374\306\341\374L" + "s\266\21\24$\0\0\0\0\0\0\0\0\0\0\0\0""9f\242|\264\364L\244\374L\244\374" + "L\244\374L\244\374T\244\374T\244\374L\244\374g\252\372\212\304\374\212" + "\304\374\230\311\374\212\304\374\212\304\374\212\304\374\204\274\374" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377\214\274\374g\252\372\26""9X\4\4\4\0\0\0\0\0\0" + "\0\0\0\4\14\24\5""6d\5""6l\6Kf\5:Y\4\34,\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\4\26\31\26""9X9f\242\\\224\337i\236\352w\251\371g\252\372w\251" + "\371g\252\372v\236\352\\\224\337Ls\266\32Aj\4\24$\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0!$)\230\243\270\306\341\374\224\324\354\213\242\3430" + "8P\0\0\0\0\0\0\0\0\0\0\0\0\4\34,O\204\314\204\264\374E\233\374E\233\374" + "L\244\374L\244\374L\244\374T\244\374L\244\374\\\254\374\204\274\374\212" + "\304\374\212\304\374\212\304\374\212\304\374\212\304\374\204\274\374" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377\204\274\374\205\253\3729f\242\4\14\34\0\0\0\0" + "\0\0\0\0\0\0\0\0\4\34""4\4=~\5F\210\27]\251\5;t\4\24,\4\4\4\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\24\14$@\26""8J$Mz\31[\231\31[\231$Mz" + "\26""9X\14$@\4\24$\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0!$)\230\243" + "\270\306\341\374\246\313\373u\210\37249\221\14\16\34\0\0\0\0\0\0\0\0" + "\0\0\0\0\27@xi\236\352\204\274\374E\233\374L\244\374L\244\374L\244\374" + "L\244\374L\244\374L\244\374T\244\374}\274\377\212\304\374\230\311\374" + "\212\304\374\212\304\374\212\304\374\204\274\374}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377\215\264\374\\\224\337\14/Q\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4," + "X\6Z\230\6V\251\31f\306(b\246\25*H\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\4\14\14\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4,17\230\243\270Q\221\3727\204\360\233" + "\255\373~\212\244\20\24,\0\0\0\0\0\0\0\0\0\0\0\0\4\26\31Ls\266\204\264" + "\374}\274\377E\233\374E\233\374E\233\374E\233\374L\244\374L\244\374L" + "\244\374L\244\374t\264\374\212\304\374\212\304\374\212\304\374\212\304" + "\374\212\304\374\212\304\374}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}" + "\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377" + "}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274" + "\377}\274\377}\274\377}\274\377}\274\377}\274\377}\274\377\214\274\374" + "\204\264\3749f\242\4\14\24\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\5""6d,\210" + "\315\5K\246\5I\230\5I\230\4""2J\4\14\34\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\14\16\34[aq\266\276\323\241\264\345" + "G\5""6d\6V\251\26x\351\24\204\374\14\204\374\24\204\374\34\204\374,\214" + "\374<\234\374E\233\374E\233\374E\233\374E\233\374E\233\3745\214\373\30" + "w\330\7e\311\6V\251\6V\251\6V\251\6V\251\6V\251\6V\251\6V\251\5K\246" + "\6V\251\5K\246\6V\251\5K\246\5K\246\5K\246\5K\246\5K\246\5I\230\5K\246" + "\5K\246\5I\230\5I\230\5I\230\5I\230\5I\230\5I\230\5I\230\5I\230\5I\230" + "\5I\230\5I\230\5I\230\5I\230\5I\230\5I\230\5I\230\5I\230\5I\230\5I\230" + "\5I\230\5K\246\5K\246\5K\246\5K\246\5K\246\5K\246\5K\246\5K\246\5K\246" + "\5K\246\6V\251\6V\251\6V\251\6V\251\6V\251\5Y\270\5Y\270\5Y\270\5Y\270" + "\5Y\270\5Y\270\5Y\270\5Y\270\5[\306\5[\306\5[\306\5[\306\5[\306\7e\311" + "\7e\311\7e\311\6h\330\6h\330\6h\330\6h\330\6h\330\5l\346\6h\330\5l\346" + "\5l\346\5:Y\4""2J\4""2J\5>G\5:Y\5:Y\6Z\205\31f\306\14}\362\24\204\374" + "\24\204\374\24\204\374$\214\3744\224\374E\233\374E\233\374E\233\374E" + "\233\374E\233\374E\233\3745\214\373\26x\351\7e\311\5Y\270\6V\251\6V\251" + "\5Y\270\5Y\270\6V\251\5Y\270\6V\251\6V\251\6V\251\6V\251\6V\251\6V\251" + "\6V\251\6V\251\5K\246\5K\246\6V\251\5K\246\5K\246\5K\246\5K\246\5K\246" + "\5K\246\5K\246\5K\246\5K\246\5K\246\5K\246\5K\246\5K\246\5K\246\5K\246" + "\6V\251\5K\246\5K\246\6V\251\5K\246\6V\251\5K\246\6V\251\6V\251\6V\251" + "\6V\251\6V\251\6V\251\6V\251\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270" + "\5Y\270\5Y\270\5[\306\5[\306\5[\306\5[\306\5[\306\7e\311\5[\306\7e\311" + "\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\5l\346\5l\346\5l\346" + "\5l\346\5l\346\5t\352\4t\364\4,X\4""2J\4""2J\5:Y\5:Y\5:Y\5:Y\5:Y\31[" + "\231\10w\321\24\204\364\24\204\374\14\204\374\24\204\374$\214\3744\234" + "\374E\233\374L\244\374L\244\374L\244\374E\233\374L\244\374<\224\374\31" + "\207\352\6h\330\5[\306\6V\251\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270" + "\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\6V\251\6V\251\6V\251\5Y\270\6V\251" + "\6V\251\6V\251\6V\251\6V\251\6V\251\6V\251\6V\251\6V\251\6V\251\6V\251" + "\6V\251\6V\251\6V\251\6V\251\6V\251\5Y\270\6V\251\5Y\270\6V\251\5Y\270" + "\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270" + "\5[\306\5[\306\5[\306\5[\306\5[\306\5[\306\5[\306\7e\311\7e\311\7e\311" + "\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\5l\346\5l\346\5l\346" + "\5l\346\5l\346\5t\352\5t\352\4t\364\4t\364\4t\364\5:Y\4""2J\4""2J\5>" + "G\5:Y\5:Y\5:Y\5:Y\6Kf\6Kf\6Z\230\26x\351\24\204\364\24\204\374\24\204" + "\374\24\204\374$\214\374<\224\374E\233\374L\244\374L\244\374L\244\374" + "L\244\374L\244\374<\224\374$\214\360\30w\330\7e\311\5Y\270\5Y\270\5Y" + "\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5" + "Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270" + "\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270" + "\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5[\306\5Y\270\5[\306\5[\306\5[\306" + "\5[\306\5[\306\5[\306\7e\311\5[\306\7e\311\7e\311\7e\311\6h\330\6h\330" + "\6h\330\6h\330\6h\330\6h\330\6h\330\5l\346\6h\330\5l\346\5l\346\5l\346" + "\5l\346\5t\352\5t\352\4t\364\4t\364\4t\364\4t\374\4|\374\4t\374\4|\374" + "\5:Y\4,X\4""2J\5:Y\5:Y\6Kf\5:Y\5>G\6Kf\5>G\5>G\6Kf\6V\251\30w\330\24" + "\204\374\24\204\374\24\204\374\24\204\374$\214\374<\224\374E\233\374" + "L\244\374E\233\374T\244\374T\244\374L\244\374E\233\3745\214\373\26x\351" + "\6h\330\7e\311\5[\306\5Y\270\5[\306\5[\306\5Y\270\5[\306\5Y\270\5[\306" + "\5Y\270\5[\306\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270\5Y\270" + "\5Y\270\5Y\270\5Y\270\5[\306\5Y\270\5[\306\5[\306\5[\306\5[\306\5Y\270" + "\5[\306\5[\306\5[\306\5[\306\5[\306\5[\306\5[\306\7e\311\5[\306\5[\306" + "\7e\311\7e\311\7e\311\6h\330\7e\311\6h\330\6h\330\6h\330\6h\330\6h\330" + "\6h\330\6h\330\5l\346\5l\346\5l\346\5l\346\5l\346\5t\352\5t\352\5t\352" + "\4t\364\4t\364\4t\364\4t\364\4t\364\4t\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\5""6d\4""2J\4""2J\5:Y\5:Y\6Kf\5:Y\5>G\6Kf\6Kf\7IO\5>G\5>G\6K" + "f\12j\253\26x\351\14|\374\24\204\374\24\204\374\24\204\374$\214\3744" + "\224\374E\233\374L\244\374T\244\374T\244\374L\244\374T\244\374L\244\374" + "<\224\374,\212\364\30w\330\6h\330\7e\311\7e\311\5[\306\5[\306\5[\306" + "\5[\306\5[\306\5[\306\5[\306\5[\306\5[\306\5[\306\5[\306\5[\306\5[\306" + "\5[\306\5[\306\5[\306\7e\311\5[\306\7e\311\5[\306\5[\306\5[\306\5[\306" + "\7e\311\5[\306\5[\306\7e\311\7e\311\7e\311\7e\311\7e\311\6h\330\7e\311" + "\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\5l\346" + "\5l\346\5l\346\5l\346\5l\346\5l\346\5t\352\5t\352\4t\364\4t\364\4t\364" + "\4t\364\4t\364\4t\374\4t\374\4t\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\5""6d\4""2J\5:Y\5>G\5""6d\5:Y\5:Y\5>G\5>G\30Wb\5:Y\5>" + "G\5>G\4""2J\5>G\6Kf\12j\253\26x\351\24\204\364\24\204\374\24\204\374" + "\24\204\374$\214\3744\224\374E\233\374T\244\374T\244\374T\244\374T\244" + "\374T\244\374T\244\374E\233\374<\224\374$\214\360\26x\351\6h\330\10w" + "\321\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311\7" + "e\311\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311\7e\311" + "\7e\311\7e\311\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330" + "\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\5l\346\5l\346\5l\346" + "\5t\352\5l\346\5t\352\5t\352\5t\352\5t\352\4t\364\4t\364\4t\364\4t\364" + "\4t\374\4|\374\4t\374\4|\374\4t\374\4|\374\4t\374\4t\374\4|\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\5""6d\4,X\5:Y\5>G\5""6d\5:Y\5:Y\5>G\5>G" + "\7IO\5>G\5>G\5>G\5>:\5>:\4""45\5>G\31[\231\12j\253\15\202\340\14}\362" + "\24\204\374\24\204\374\24\204\374\34\214\374,\224\374E\233\374L\244\374" + "T\244\374\\\254\374T\244\374T\244\374T\244\374T\244\374L\244\374<\224" + "\374,\212\364\26x\351\5t\352\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330" + "\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330" + "\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\5l\346" + "\6h\330\5l\346\5l\346\5l\346\5l\346\5l\346\5l\346\5l\346\5t\352\5l\346" + "\5t\352\4t\364\5t\352\4t\364\4t\364\4t\374\4t\364\4t\374\4t\364\4t\374" + "\4t\374\4|\374\4t\374\4t\374\4t\374\4t\374\4t\374\4t\374\4|\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\5""6d\4""2J\4""2J\5>G\5""6d\5:Y\5" + ":Y\5>G\5>G\7IO\5>G\5>G\5>G\5>:\4""45\4""45\5>G\30Wb\5>G\5:Y\6Z\230\30" + "w\330\14}\362\24\204\374\24\204\374\24\204\374\34\214\374$\214\374<\224" + "\374L\244\374T\244\374T\244\374T\254\374\\\254\374T\244\374T\244\374" + "T\244\374L\244\374E\233\3743\226\361\34\177\364\26x\351\5l\346\6h\330" + "\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330\6h\330" + "\5l\346\5l\346\5l\346\5l\346\5l\346\5l\346\5l\346\5l\346\5l\346\5l\346" + "\5l\346\5l\346\5t\352\5l\346\5t\352\5t\352\5l\346\4t\364\4t\364\4t\364" + "\4t\364\4t\364\4t\364\4t\364\4t\364\4t\364\4t\364\4t\374\4t\364\4t\374" + "\4t\364\4|\374\4t\374\4t\374\4|\374\4t\374\4|\374\4t\374\4|\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374\5""6d\4""2J\4""2J\5:Y\5:Y" + "\5:Y\7IO\4""2J\5>:\7IO\5>G\5>G\4""2J\4""45\4""45\4""45\5>:\6Kf\5>:\4" + "45\4""45\7IO\6Z\230\10w\321\26x\351\24\204\374\14\204\374\24\204\374" + "\24\204\374\34\214\374,\224\374<\234\374E\233\374T\244\374T\244\374\\" + "\254\374T\244\374T\244\374T\244\374T\244\374T\244\374E\233\374<\234\374" + ",\212\364\31\207\352\14}\362\26x\351\5l\346\5l\346\6h\330\5l\346\5l\346" + "\5l\346\5l\346\6h\330\5l\346\6h\330\5l\346\5l\346\5l\346\5l\346\5l\346" + "\5t\352\5l\346\5t\352\5t\352\5t\352\5t\352\4t\364\4t\364\4t\364\5t\352" + "\4t\364\4t\364\4t\364\4t\364\4t\364\4t\364\4t\364\4t\364\4t\364\4t\374" + "\4t\364\4t\374\4t\364\4t\374\4|\374\4|\374\4|\374\4|\374\4|\374\4|\374" + "\4|\374\4|\374\4|\374\4|\374\4|\374\14\204\374\24\204\374\34\214\374" + "\4,X\4""2J\4""2J\5>G\5:Y\5:Y\5:Y\5>:\4""45\5>G\5>:\5>G\4""45\4""45\4" + ")(\4)(\4""45\30Wb\4""45\4)(\4)(\4""45\5>:\5:Y\6Z\205\7e\311\26x\351\14" + "}\362\24\204\374\24\204\374\24\204\374\24\204\374\34\214\374,\224\374" + "<\234\374E\233\374T\244\374T\244\374T\244\374T\244\374\\\254\374\\\254" + "\374T\244\374T\244\374T\244\374L\244\374<\234\374,\224\374,\212\364\31" + "\207\352\14}\362\15\202\340\5t\352\5l\346\5t\352\5l\346\5t\352\5l\346" + "\5l\346\5t\352\5l\346\5l\346\5t\352\5t\352\5t\352\5l\346\5t\352\5t\352" + "\5l\346\5t\352\5t\352\5t\352\4t\364\5t\352\4t\364\4t\364\4t\364\4t\364" + "\4t\364\4t\364\4t\364\4|\363\4|\374\4|\363\4|\374\4|\363\4|\374\4|\374" + "\4|\374\4|\374\4|\374\14\204\374\14\204\374\24\204\374\34\214\374,\224" + "\3744\224\374<\234\374L\244\374T\244\374\5""6d\4""2J\4""2J\5>G\4""2J" + "\5:Y\7IO\5>G\4""45\5>:\5>G\5>:\4""45\4)(\5(\31\4)(\4""45\7IO\4""45\4" + ")(\4)(\4""45\5>:\5>G\5:Y\5""6d\11Ly\6V\251\10w\321\26x\351\24\204\374" + "\24\204\374\24\204\374\24\204\374\24\204\374$\214\374,\214\374<\224\374" + "E\233\374L\244\374T\244\374T\244\374T\244\374T\254\374\\\254\374T\244" + "\374T\244\374T\244\374T\244\374T\244\374E\233\374E\233\374<\224\3743" + "\226\361$\214\374\34\204\374\31\207\352\26x\351\14}\362\14}\362\4|\363" + "\5t\352\5t\352\5t\352\5t\352\5t\352\4t\364\5t\352\4t\364\5t\352\4t\364" + "\4t\364\4t\364\4t\364\4t\364\4t\364\4|\363\4|\363\4|\363\4|\363\4|\363" + "\4|\374\4|\374\4|\374\14|\374\14|\374\24\204\374\34\204\374$\214\374" + "$\214\3744\224\374<\234\374E\233\374L\244\374T\244\374T\244\374T\244" + "\374T\244\374T\244\374T\244\374\5""6d\4""2J\4""2J\4""2J\4""2J\4""2J\7" + "IO\4""45\4""45\5>:\4""45\4""45\4""45\4)(\5(\31\4)(\4)(\7IO\4""45\4)(" + "\5(\31\4)(\4""45\5>:\5>G\5:Y\5""6l\5""6d\5;t\5I\230\12j\253\32h\327\26" + "x\351\24\204\374\24\204\374\14\204\374\24\204\374\24\204\374\34\214\374" + "$\214\3744\224\374<\234\374E\233\374L\244\374T\244\374T\244\374\\\254" + "\374\\\254\374T\244\374T\244\374\\\254\374T\244\374\\\254\374T\244\374" + "T\244\374T\244\374T\244\374L\244\374E\233\374<\234\3744\224\3744\224" + "\3744\224\374,\214\374,\212\364$\214\374$\203\373\34\214\374\34\204\374" + "\34\204\374\34\204\374\34\204\374\34\204\374\34\204\374\34\204\374\34" + "\204\374$\214\374$\214\374$\214\374,\214\374,\214\3744\224\374<\224\374" + "<\224\374<\234\374E\233\374L\244\374T\244\374T\244\374T\244\374T\244" + "\374T\244\374\\\254\374T\244\374T\244\374\\\254\374T\244\374\\\254\374" + "T\244\374T\244\374\32Aj\4""2J\4""2J\4""2J\4""2J\4""2J\7IO\4""45\4""4" + "5\4""45\4""45\4""45\4""45\4)(\5(\31\5(\31\4)(\7IO\4""45\4)(\4)(\4)(\4" + "45\5>G\5>G\6Kf\6Kf\5""6l\5""6d\5""6l\5;t\11Ly\5I\230\6V\251\6h\330\26" + "x\351\24\204\364\14\204\374\24\204\374\14\204\374\24\204\374\24\204\374" + "\34\204\374$\214\374,\224\374<\234\374E\233\374L\244\374T\244\374T\244" + "\374T\244\374\\\254\374T\244\374T\244\374T\244\374T\244\374T\244\374" + "T\244\374T\244\374\\\254\374T\244\374\\\254\374T\244\374T\244\374T\244" + "\374T\244\374T\244\374T\244\374T\244\374L\244\374T\244\374L\244\374T" + "\244\374L\244\374T\244\374L\244\374T\244\374T\244\374T\244\374T\244\374" + "T\244\374\\\254\374T\254\374\\\254\374T\244\374T\244\374T\244\374T\244" + "\374T\244\374\\\254\374T\244\374T\244\374T\244\374\\\254\374T\244\374" + "T\244\374L\244\374E\233\374<\234\3744\224\374\5""6l\5*f\4""45\26""8J" + "\5>G\5>G\5>G\4""45\4)(\4)(\4\34$\4\34$\4\34,\4)(\4\26\31\4\34$\4\34$" + "\7IO\4""45\5(\31\4)(\4""45\5>G\5>G\5:Y\5:Y\5""6l\5""6d\5;t\6Kf\5;t\5" + ";t\5""6l\5""6d\5;t\5I\230\6V\251\7e\311\30w\330\14}\362\24\204\374\24" + "\204\374\14\204\374\24\204\374\24\204\374\24\204\374\34\214\374\34\214" + "\374,\214\374,\224\374<\224\374<\234\374E\233\374L\244\374T\244\374T" + "\244\374T\244\374T\244\374\\\254\374T\244\374\\\254\374T\244\374T\244" + "\374T\244\374\\\254\374T\254\374T\254\374\\\254\374T\244\374\\\254\374" + "\\\254\374T\254\374\\\254\374T\254\374\\\254\374T\244\374\\\254\374T" + "\244\374\\\254\374T\254\374T\244\374T\244\374T\244\374T\244\374\\\254" + "\374\\\254\374T\244\374T\254\374T\244\374T\244\374L\244\374E\233\374" + "<\234\3744\224\3744\224\374,\224\374$\214\374\34\204\374\24\204\374\24" + "\204\374\5""6l\5""6d\4,\77\5>:\5>G\5>G\5>:\4)(\4)(\4)(\4\34$\4\26\31" + "\4\34,\4)(\5(\31\5(\31\4\26\31\5>G\4""45\4\26\31\4)(\4""45\5>:\5>G\5" + ">G\6Kf\5""6l\5""6d\5;t\5""6l\5""6l\5;t\5""6l\5""6l\5""6l\5;t\27@x\5;" + "t\5F\210\6V\251\31^\270\6h\330\30w\330\14}\362\24\204\374\24\204\374" + "\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\34" + "\214\374$\214\374$\214\374,\214\3744\224\374<\224\374<\234\374E\233\374" + "E\233\374L\244\374L\244\374L\244\374L\244\374T\244\374T\244\374T\244" + "\374T\244\374T\244\374T\244\374T\244\374T\244\374T\244\374T\244\374T" + "\244\374T\244\374T\244\374T\244\374L\244\374L\244\374L\244\374L\244\374" + "L\244\374E\233\374<\234\374<\234\3744\224\374,\224\374$\214\374$\214" + "\374\34\214\374\34\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\24\204\374\5""6l\5:Y\4,\77\4""45\5>G\5>:\4""4" + "5\4)(\4)(\4\34$\4\26\31\4\26\31\4\34$\4)(\4)(\15\37\40\4\26\31\7IO\5" + ">:\4\26\31\4)(\4""45\5>:\5>G\5>G\5:Y\5""6d\5""6d\5""6d\5""6d\5""6l\5" + ";t\5""6l\5""6d\5""6l\5;t\4=~\5;t\5;t\5;t\4=~\6Z\205\6Z\230\6V\251\7u" + "\273\5t\352\24\204\364\14}\362\24\204\364\24\204\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\34\214\374\34\214\374$\214\374$\214\374$\214\374,\214\374" + ",\224\374,\214\374,\224\3744\224\3744\224\3744\224\3744\224\3744\224" + "\374,\224\3744\224\3744\224\374,\224\374,\224\374,\214\374,\214\374$" + "\214\374$\214\374\34\214\374\34\214\374\34\214\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\26|\372\26x\351\30w\330\7e\311-t\315\5""6l\5:" + "Y\4,\77\4""45\5>:\4""45\4)(\4)(\4\34$\4\34$\4\26\31\4\14\14\4\34$\4)" + "(\5(\31\15\37\40\4)(\30Wb\5>G\4)(\4)(\4""45\4""45\5>G\5>G\5:Y\5""6d\5" + "6d\5""6d\5""6d\5""6l\5""6l\5""6l\5""6l\5""6l\5;t\5F\210\5;t\5;t\11Ly" + "\11Ly\5F\210\6Z\205\5F\210\6Z\230\32h\327\26x\351\7u\273\7e\311\6h\330" + "\34\177\364,\214\374\24\204\364\26|\372\24\204\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\14\204\374\24\204\374\24\204\374\14|\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24" + "\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204" + "\374\26|\372\24\204\364\26x\351\7e\311\5[\306\27]\251\27]\251(b\246\15" + "8\214\5-z9f\242\5""6d\5:Y\4""2J\4""45\4,\77\4""45\4)(\4\34$\5(\31\4\26" + "\31\4\26\31\4\14\14\4\26\31\5(\31\4%\13\4\26\31\4)(\34iu\7IO\4\34$\4" + ")(\4""45\4""45\5>:\5>G\5:Y\5:Y\4,X\4,X\5""6d\5""6d\5;t\5""6l\5""6l\5" + ";t\11Ly\5F\210\5;t\5;t\5F\210\5F\210\5F\210\5F\210\11Ly\6Z\230\31f\306" + "\7e\311\6V\251\12j\253\6V\251\5Y\270]\240\374<\224\374\26x\351\6h\330" + "\15\202\340\5t\352\5t\352\26x\351\14}\362\34\204\374\24\204\364\14}\362" + "\24\204\364\24\204\374\26|\372\24\204\364\24\204\374\24\204\374\24\204" + "\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374\24\204\374" + "\24\204\374\24\204\374\24\204\364\26|\372\24\204\364\26x\351\26x\351" + "\6h\330\30w\330\30w\330\32h\327\31f\306\27]\251\5I\230\15""8\214\34L" + "\242\17""3v\5\27j\17""3v,V\216,V\216\17""3v\5-z\34L\242\5:Y\5:Y\5>G\4" + "45\4""45\4""45\4)(\4\34$\4\26\31\4\26\31\4\14\14\4\14\14\4\14\24\4%\13" + "\4\26\31\4\14\14\4)(\30Wb\5>:\4\34$\4)(\4)(\4""45\5>:\5>G\5:Y\4,X\4," + "X\4,X\4,X\5""6l\5""6l\5;t\5;t\5;t\11Ly\5F\210\11Ly\11Ly\5F\210\5F\210" + "\11Ly\5F\210\4=~\5F\210\5Y\270\5[\306\34x\300\12j\253\6V\251\5Y\270=" + "\216\361u\210\372\31f\306\5Y\270\7e\311\5Y\270\31f\306\6h\330\7e\311" + "<\224\3745\214\373\30w\330\30w\330\30w\330\10w\321\7e\311\30w\330\30" + "w\330\30w\330\30w\330\30w\330\26x\351\30w\330\32h\327\30w\330\26x\351" + "\30w\330\7e\311\5Y\270\27]\251\27]\251\31[\231\5I\230\30F\210\15""8\214" + "(b\246,V\216\27@x\5*f\5*f49\221\27@x\5\27j\35""3k49\221\27@x\17""3v\17" + "3v49\221\6Kf\5:Y\7IO\4,\77\4""45\4)(\4)(\4\26\31\4\26\31\4\26\31\4\14" + "\14\4\14\14\4\14\24\5(\31\4\14\14\4\14\14\4)(\30Wb\5>:\4)(\4\34$\4)(" + "\4""45\5>:\5>G\5:Y\4,X\4,X\4,X\5*f\5""6d\5;t\5;t\5;t\5;t\11Ly\6Z\230" + "\5F\210\5F\210\5F\210\5F\210\5F\210\5F\210\4=~\11m\217\5K\246\5[\306" + "'\177\347\12j\253\12j\253\5K\246\5[\306u\210\372H\210\355\5[\306\5Y\270" + "\7e\311\7e\311\7e\311\30w\330-t\315]\240\374\34x\300\12j\253\12j\253" + "\12j\253\6V\251\6V\251\27]\251\12j\253\12j\253\12j\253\34x\300\6V\251" + "\6Z\230\5K\246\27]\251/p\267\5F\210\11Ly\5;t\27@x\33V\206\30F\210\5;" + "t\30F\210\5-z\15""8\214,V\216\27@x\5\27j\5\27j49\221\5*f\17""3v\27@x" + "\17""3v\17""3v\17""3v\34L\242\6Kf\5:Y\7IO\4""45\4)(\4""45\4)(\4\26\31" + "\4\26\31\4\14\14\4\14\14\4\14\14\4\14\14\5(\31\4%\13\4\26\31\4)(\6YZ" + "\5>G\4)(\4)(\4)(\4)(\5>:\5>G\5:Y\4,X\4,X\4,X\4,X\5""6l\5;t\5;t\5;t\5" + ";t\11Ly\6Z\205\5F\210\11Ly\5F\210\11Ly\4=~\5F\210\4=~\6Z\205\5K\246\6" + "B\3123\226\361\6Z\230\12j\253\5K\246\6V\2517S\323u\210\372\5Y\270\5Y" + "\270\5Y\270\6V\251\34x\300\15\202\340\35E\270g\252\3720\212\341\34x\300" + "\34x\300\7u\273\12j\253\6V\251\31^\270\27]\251\31^\270\34x\300,\210\315" + "\34x\300\27]\251\27]\251\6V\251\34x\300\31[\231\30F\210\5""6l\5;t\30" + "F\210\27@x\33V\206\27@x\5*f\5-z\17""3v\27@x\30F\210\5\27j\26D\226\5\27" + "j\5*f\17""3v\27@x\17""3v\5*f9f\242\7IO\5:Y\5>G\7IO\7IO\5>G\4""45\5(\31" + "\4\26\31\4\14\14\4\26\31\4\26\31\4\26\31\4\14\14\4\14\24\4\34$\4)(\5" + ">:\4)(\4\26\31\4\26\31\4)(\4""45\5>:\5>G\5:Y\5:Y\5""6d\5""6l\5""6l\5" + "6l\5;t\4=~\5;t\5;t\5F\210\5I\230\4=~\5F\210\11Ly\5F\210\5F\210\4=~\5" + "F\210\4=~\12j\253\6V\2510\212\341\5I\230\5I\230\6V\251\6V\251\27]\251" + "\233\255\373H\210\355\5K\246\31f\306\5Y\270\7u\273,\210\315\15""8\214" + "u\210\372Z\200\345\5K\246\31^\270-t\315\6V\251\7u\273\5[\306\5Y\270\5" + "Y\270\7u\2730\212\341\31f\306\34x\300\31f\306\31^\270\34x\300\5I\230" + "\5F\210\5F\210\30F\210\5""6l\27@x\30F\210\30F\210\17""3v\35""3k\5*f\17" + "3v\30F\210,V\216\17""3v9f\242\35""3k\35""3k49\221\5*f\5-z\15""8\214\5" + ":Y\5>G\5>G\5>G\7IO\5>G\4""45\4\34$\4\14\14\4\26\31\4\14\14\4\26\31\4" + "\26\31\4\14\14\4\14\24\4\34$\4)(\5>:\4)(\4\26\31\5(\31\4)(\4""45\5>:" + "\4""2J\5:Y\5""6d\5""6d\5""6l\5""6l\5;t\5;t\4=~\5;t\5;t\5F\210\5I\230" + "\5F\210\5F\210\11Ly\6Z\205\5F\210\11Ly\4=~\4=~\27]\251\6Z\230\34x\300" + "\5K\246\5I\230\5K\246\6Z\230\5I\230G\232\344G\232\344\31^\270\5K\246" + "\6Z\230\31f\306\7u\273\15""8\214Z\200\345]\240\374\5I\230\5K\246\5Y\270" + "\5Y\270-t\315-t\315\31f\306\5Y\270\31^\270,\210\315\12j\253\31^\270\27" + "]\251\34x\300-t\315\5F\210\4=~\5F\210,V\216\30F\210\5*f\4=~\27@x,V\216" + "$Mz\5*f\5*f\17""3v9f\242\5-z,V\216\27@x\5*f$Mz\17""3v\5*f\34L\242\7I" + "O\5>G\7IO\5>G\7IO\5>G\4""45\4\34$\4\26\31\4\26\31\4\26\31\4\14\14\4\26" + "\31\4\14\14\4\26\31\5(\31\4)(\5>:\4)(\4\34$\5(\31\4""45\4""45\5>:\5:" + "Y\5:Y\5:Y\5""6l\5;t\5;t\5;t\11Ly\4=~\5;t\5;t\5F\210\5F\210\5F\210\11" + "Ly\5F\210\11Ly\4=~\4=~\4=~\4=~\6Z\230\6Z\230\34x\300-t\315\5I\230\6V" + "\251\12j\253\12j\253\6V\251\31f\306\5K\246\6Z\230\5K\246\6V\251\31f\306" + "-t\3157S\323\205\253\372\5I\230\5K\246\6V\251\6V\251\34x\300G" + "\7IO\5>G\5:Y\4,\77\4)(\5(\31\4\26\31\4\26\31\4\26\31\4\26\31\4\26\31" + "\4\26\31\4\26\31\4)(\4""45\5>G\4""45\4\34$\4)(\4""45\4""45\5>G\7IO\5" + ":Y\5""6l\5""6l\5""6l\11Ly\27@x\11Ly\5;t\5;t\4=~\5F\210\5F\210\4=~\11" + "Ly\11Ly\5F\210\11Ly\5F\210\5F\210\4=~\31[\231\5F\210\12j\253G\232\344" + "\6Z\230\27]\251/p\267\27]\251\6V\251\34x\300\5K\246\6V\251\4=~\31[\231" + "\227\273\372w\251\371\34L\242w\251\371\31^\270\5K\246\6V\251\27]\251" + "\12j\253-t\315\31^\270\12j\253\31f\306,\210\315\12j\253\27]\251\27]\251" + "\6V\251-t\315-t\315-t\315\5F\210\5F\210\30F\210\31[\231\4=~\5""6l\5;" + "t\17""3v\17""3v\17""3v\5*f\5-z\34L\242\15""8\214\26D\22649\221\5*f\5" + "*f\5*f\35""3k\6Kf\5:Y\6YZ\5>G\5>G\4""45\4)(\4)(\4)(\5(\31\4\26\31\4\26" + "\31\4)(\4\26\31\4\26\31\4)(\4""45\7IO\4""45\4)(\4)(\4""45\5>:\5>G\5:" + "Y\6Kf\5""6d\5;t\5""6l\5;t\11Ly\4=~\5;t\5""6l\4=~\4=~\5F\210\4=~\4=~\11" + "Ly\11Ly\11Ly\4=~\5F\210\4=~\6Z\230\5F\210\5K\246W\244\352\6V\251\6Z\230" + "\6Z\230\5F\210\31[\231/p\267\5F\210\30F\210\4,X9f\242\306\341\374H\210" + "\355\15""8\214\\\224\337-t\315\5I\230\6V\251\27]\251\12j\253\31[\231" + "\6Z\230\6V\251\5Y\270-t\315\6V\251\27]\251\27]\251\5K\246\31^\270/p\267" + ",\210\315\5I\230\4=~\4=~\5F\210\31[\231\30F\210\5""6l\5""6l\17""3v\30" + "F\210\26D\226\15""8\214\34L\242\5-z\5-z9f\242\30F\210\5#V\32Aj\14/Q\6" + "Kf\7IO\7IO\7IO\4""2J\4,\77\4""45\4""45\4""45\4)(\4\34$\4\34$\4)(\4\34" + "$\4\34$\4)(\5>:\7IO\4""45\4)(\4""45\5>:\5>G\7IO\6Kf\5;t\6Kf\5;t\5""6" + "l\5;t\27@x\11Ly\5;t\5;t\4=~\4=~\5F\210\5;t\5;t\11Ly\11Ly\4=~\5;t\4=~" + "\5F\210\31[\231\4=~\5F\210G\232\344\34x\300\5F\210\5F\210\26D\226\5F" + "\210(b\246\11Ly$Mz,V\216\311\324\353\355\357\373\5I\230\4=~/p\267/p\267" + "\5I\230/p\267\27]\251\6Z\230\27]\251\27]\251\6V\251\5Y\270\30w\330\5" + "Y\270\31^\270/p\267\5Y\270\6V\251\5K\246\31^\270\6V\251\5I\230\5F\210" + "\4=~\5F\210\31[\231\30F\210\27@x\17""3v\30F\210(b\246\31[\231\15""8\214" + "\15""8\214\5-z\15""8\2149f\242\5#V\5#V\27%V\6Kf\7IO\7IO\7IO\5:Y\5>G\5" + ">:\5>:\5>:\4""45\4)(\4)(\4)(\4)(\4)(\4)(\5>G\6YZ\5>:\4""45\4""45\5>:" + "\5>G\7IO\6Kf\11Ly\5""6l\5;t\5""6l\5""6l\5;t\4=~\5""6l\5;t\4=~\4=~\4=" + "~\5;t\5;t\5;t\5;t\5;t\5;t\5;t\6Z\205\31[\231\4=~\5F\210;\225\326;\225" + "\326\6Z\205\4=~\5;t\5F\210\31[\231\6Z\230\5;t\11Ly\310\327\371\270\311" + "\367\5F\210\5F\210\6V\251\27]\251\31[\231/p\267\31[\231\6Z\230\27]\251" + "\27]\251\31^\270\31f\306-t\315\5Y\270\31f\306-t\315\31f\306\31f\306\5" + "K\246\31f\306/p\267/p\267\27]\251\5F\210\4=~\30F\210\33V\206\33V\206" + "\30F\210\4=~\34L\242(b\246\17""3v\34L\242\26D\226\5-z9f\242\17""3v\4" + "\34E\27%V\30Wb\5:Y\7IO\7IO\7IO\5>G\7IO\7IO\5>:\5>:\4)(\4)(\4)(\4)(\4" + ")(\4""45\5>:\6YZ\5>:\4""45\5>:\5>:\5>G\6Kf\6eu\6Kf\5;t\5;t\5""6l\5""6" + "l\5;t\5;t\5""6l\5;t\4=~\5;t\4=~\5""6l\6Kf\5""6l\11Ly\11Ly\4=~\4=~\6Z" + "\205\31[\231\4=~\11Ly,\210\315W\244\352\5F\210\5;t\33V\206\31[\231\6" + "Z\230\12j\253\6Z\230\4=~\205\253\372,V\216\5I\230\5F\210\5I\230\5I\230" + "\5I\230\6Z\230\31[\231\31[\231\6Z\230\6Z\230\31^\270\32h\327\32h\327" + "\5Y\270\27]\251\31^\270\31f\306\32h\327\31^\270\6V\251\5K\246\31^\270" + "/p\267/p\267\6Z\230\4=~\4=~,V\216,V\216\30F\210\30F\210(b\246\27@x,V" + "\216/p\267\5""6l(b\246\27@x\5#V\27%V\6Kf\6Kf\7IO\7IO\5>G\5>G\6YZ\6YZ" + "\6YZ\6YZ\4""45\4)(\4""45\4""45\4)(\4)(\4)(\30Wb\7IO\7IO\5>:\5>G\7IO\6" + "Kf\5F\210\5F\210\11Ly\11Ly\11Ly\5;t\5""6l\5""6l\5;t\5;t\5;t\4=~\11Ly" + "\5""6l\5""6d\5""6d\5""6l\5""6l\5""6l\5""6l\5\27j\30F\210\4=~\11Ly,\210" + "\315G\232\344\5K\246\5F\210\6Z\205\5I\230\31^\270\31f\306\5F\210\11L" + "y\31[\231\5I\230/p\267\30F\210\26D\226\\\224\337\5-z\4=~\31[\231\31[" + "\231$\200\223(b\246\27]\251\5Y\270-t\315\5Y\270\31f\306\31f\306\31f\306" + "G\7IO\6YZ\6YZ\6YZ\6YZ\5>:\4)(\4""45" + "\4""45\4)(\4""45\4""45\30Wb\7IO\6YZ\5>:\7IO\7IO\6Kf\31[\231\6Z\230\5" + "F\210\5;t\5;t\11Ly\5;t\5""6l\5""6l\5;t\5;t\5;t\5;t\5""6d\5""6d\5:Y\5" + "6l\5""6l\5*f\5*f\5*f\30F\210\4=~\5F\210,\210\315G\232\344-t\315-t\315" + "\31[\231\6V\251\30w\330H\210\355\5F\210\27@x\31[\231\5I\230\204\274\374" + "(b\246\34L\242\233\255\373Z\200\345\15""8\214\31[\231\27]\251(b\246\27" + "]\251\6V\251\5Y\270\32h\327\32h\327-t\315\5Y\270\31f\306\31f\306\31f" + "\306\31f\306\34x\300\27]\251\5I\230\6Z\230(b\246\30F\210\6Z\230\31[\231" + "\5F\210(b\246\26D\226\5-z\31^\270\26D\226\26D\226,V\216\17""3v\17""3" + "v\35""3k\5#V", +}; + + diff --git a/polymer/eduke32/rsrc/game.bmp b/polymer/eduke32/rsrc/game.bmp new file mode 100644 index 000000000..db0f6b5ba Binary files /dev/null and b/polymer/eduke32/rsrc/game.bmp differ diff --git a/polymer/eduke32/rsrc/game_banner.c b/polymer/eduke32/rsrc/game_banner.c new file mode 100644 index 000000000..14b019b44 --- /dev/null +++ b/polymer/eduke32/rsrc/game_banner.c @@ -0,0 +1,3681 @@ +#include +/* GdkPixbuf RGB C-Source image dump */ + +const GdkPixdata startbanner_pixdata = { + 0x47646b50, /* Pixbuf magic: 'GdkP' */ + 24 + 84000, /* header length + pixel_data length */ + 0x1010001, /* pixdata_type */ + 300, /* rowstride */ + 100, /* width */ + 280, /* height */ + /* pixel_data: */ + "\40""3Z\40""3Z\31*W\31*W\26$I\31*W\31*W\31*W\26$I\26$I\26$I\31*W\31*" + "W\31*W\26$I\31*W\26$I\40""3Z\26$I\15$;\24\26*\10\25*\13\26\32\14\13\31" + "\4\6\30\4\4\14\0\0\0\0\0\0\0\0\0\4\4\14\4\6\30\10\25*\24\26*\5\13(\4" + "\4\14\4\6\30\4\6\30\4\6\30\4\6\30\4\6\30\26\33""8\26\33""8\5\13(\5\13" + "(\5\13(\4\6\30\4\6\30\4\6\30\4\4\14\4\6\30\4\6\30\4\4\14\4\4\14\4\4\4" + "\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\40""3Z\31*W\31*W\34,e\26$I\31*W\31*W\31*W\26$I\10$L\26$I\26$I\26" + "$I\26$I\26$I\26$I\24\26*\26\33""8\24\26*\5\13(\4\4\14\4\4\14\4\4\14\4" + "\4\4\0\0\0\4\4\4\4\4\4\4\4\4\4\4\4\4\4\14\4\4\14\14\13\31\26\33""8\14" + "\13\31\4\6\30\4\4\14\4\6\30\4\6\30\5\13(\4\6\30\7\27""9\26$I\7\27""9" + "\7\27""9\5\13(\5\13(\10\25*\24\14,\10\25*\24\14,\14\13\31\5\13(\4\4\14" + "\4\4\14\4\4\14\4\4\14\4\4\4\0\0\0\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\31*W\31*W\31*W\31*W\31*W\26$I\31*W\26$I\31*W\26$I\26$I\26" + "$I\7\31G\15$;\26$I\15$;\4\6\30\4\6\30\4\4\14\4\4\14\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\0\0\0\4\4\14\4\6\30\24\26*\24\26" + "*\4\6\30\14\13\31\4\6\30\4\6\30\4\6\30\4\6\30\5\13(\26$I\26\33""8\26" + "$I\26\33""8\26\33""8\26$I\26\33""8\24\26*\10\25*\24\14,\24\26*\5\13(" + "\4\6\30\4\6\30\4\4\14\4\4\14\4\4\4\4\4\4\4\4\4\4\4\14\4\4\14\4\4\4\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\31*W\31*W\31*W\26$I\40""3Z\31*W\26$I\26$I\31*W\31*W" + "\26$I\26$I\7\27""9\7\27""9\15$;\26\33""8\4\6\30\4\4\14\4\4\4\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\4\4\4\4\4" + "\14\13\26\32\24\26*\4\6\30\4\4\14\4\6\30\4\6\30\4\6\30\4\6\30\5\13(\26" + "\33""8\7\27""9\26$I\26\33""8\26\33""8\26\33""8\5\13(\5\13(\4\6\30\4\6" + "\30\5\13(\26\33""8\24\26*\5\13(\4\6\30\4\4\14\4\4\14\4\4\4\0\0\0\4\4" + "\14\4\4\14\4\4\14\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\31*W\40""3Z\31*W\10$L\31*W\31*W" + "\26$I\26$I\26$I\26$I\7\31G\26$I\10\25*\5\13(\10\25*\24\26*\4\4\14\0\0" + "\0\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4\4\4\4\4\4\0\0\0" + "\0\0\0\4\4\4\4\4\14\4\6\30\24\26*\13\26\32\4\4\4\4\4\14\4\4\14\4\6\30" + "\4\6\30\5\13(\10\25*\5\12""9\26$I\26\33""8\7\27""9\5\13(\4\6\30\4\6\30" + "\4\6\30\4\6\30\5\13(\26\33""8\7\27""9\10\25*\5\13(\4\6\30\4\4\14\4\4" + "\14\4\4\4\4\6\30\4\6\30\4\4\14\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\7\31G\34,e%7g\31*W\26" + "$I\26$I\15$;\7\27""9\15$;\7\27""9\7\27""9\26$I\26$I\10\25*\10\25*\35" + "#/\14\13\31\4\4\14\14\4\4\14\4\4\4\14\4\4\14\4\4\14\4\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\4\4\14\24\26*\35#/\4\4\14\4\4" + "\4\4\4\14\4\4\14\4\6\30\5\13(\5\13(\5\13(\7\27""9\26\33""8\7\27""9\4" + "\6\30\5\13(\10\25*\26\33""8\24\26*\24\26*\7\27""9\7\27""9\24\26*\10\25" + "*\13\26\32\14\13\31\4\14\14\4\14\14\4\6\30\4\6\30\4\4\14\4\4\14\4\4\14" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\15$;\15$;\33""5e\34,e\31*W\40""3Z\31*W\31*W\31*W\5\13(\5\13(\15" + "$;\31*W\26$I\10\25*\26\33""8\4\6\30\14\13\31\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\4\4\4\4\4\4\4\4\14\4\4\14\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0" + "\14\13\31\7\27""9\5\12""9\4\4\4\4\4\14\4\6\30\5\13(\5\13(\5\13(\4\6\30" + "\4\4\14\7\27""9\26$I\26$I\15$;\26\33""8\26$I\26\33""8\26\33""8\24\26" + "*\5\13(\4\6\30\4\6\30\13\26\32\24\26*\4\6\30\4\4\14\4\4\14\4\6\30\4\6" + "\30\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\14\4\4\4\0\0\0\0\0\0\4\4\4" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\10$L\7\31G\34,e\31*W\34,e\31*W\31*W\31*W\40" + "3Z\7\31G\15$;\31*W\24\14,\24\26*\4\6\30\24\26*\4\4\14\14\13\31\0\0\0" + "\4\4\4\0\0\0\0\0\0\0\0\0\4\4\4\4\4\4\4\4\4\4\4\4\14\4\4\0\0\0\0\0\0\4" + "\14\4\0\0\0\0\0\0\14\13\31\26\33""8\26$I\4\4\14\4\4\14\4\6\30\5\13(\5" + "\13(\5\13(\10\25*\4\6\30\7\27""9\26\33""8\26\33""8\26\33""8\24\26*\5" + "\13(\4\6\30\4\6\30\26\33""8\10\25*\4\6\30\4\4\14\4\6\30\4\4\14\4\4\14" + "\4\4\14\4\4\14\4\4\14\14\13\31\14\13\31\4\6\30\14\13\31\14\13\31\14\13" + "\31\4\4\14\0\0\0\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\26$I\10" + "$L\40""3Z%7g\34,e\33""5e\31*W\31*W\31*W\15$;\26$I\26$I\4\4\14\4\6\30" + "\4\4\14\4\6\30\4\4\14\14\13\31\4\4\14\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\4\4\4\4\4\4\0\0\0\4\4\14\24\14,\26" + "$I\24\26*\5\13(\5\13(\7\27""9\5\12""9\26\33""8\26\33""8\15$;\26\33""8" + "\26\33""8\5\13(\4\6\30\4\6\30\4\6\30\4\6\30\4\6\30\5\13(\5\13(\4\6\30" + "\4\6\30\4\4\14\4\4\14\4\4\14\4\6\30\4\6\30\14\13\31\14\13\31\13\26\32" + "\13\26\32\14\13\31\4\6\30\14\13\31\0\0\0\4\4\14\4\4\4\4\4\4\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\31*W\10$L\31*W%7g\40""3Z\34,e\33""5e\40""3Z\31" + "*W\7\31G\26$I\26$I\0\0\0\4\14\14\4\4\4\4\4\4\0\0\0\4\14\14\4\4\4\4\4" + "\14\0\0\0\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\4\0\0\0\0\0" + "\0\0\0\0\0\0\0\4\4\14\4\6\30\26\33""8\26\33""8\24\14,\5\13(\5\13(\5\13" + "(\5\12""9\7\27""9\5\12""9\5\13(\4\6\30\4\6\30\4\6\30\5\13(\4\6\30\4\6" + "\30\4\6\30\4\6\30\5\13(\24\26*\24\26*\10\25*\14\13\31\14\13\31\13\26" + "\32\13\26\32\4\6\30\14\13\31\13\26\32\14\13\31\4\4\14\4\4\14\4\4\14\4" + "\4\4\4\4\14\4\4\14\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\31*W\10$L\7" + "\31G\10$L\31*W\10$L\34,e\40""3Z\40""3Z\26$I\40""3Z\31*W\4\14\4\13\26" + "\32\4\14\14\0\0\0\0\0\0\4\4\14\0\0\0\0\0\0\4\4\4\0\0\0\4\4\14\4\4\4\4" + "\4\4\4\4\4\4\14\4\14\14\4\4\4\14\4\4\4\4\4\4\4\4\14\4\4\14\4\6\30\4\6" + "\30\24\14,\5\12""9\5\12""9\5\13(\5\13(\5\13(\5\13(\5\12""9\5\12""9\5" + "\13(\4\6\30\4\6\30\4\6\30\4\6\30\4\6\30\4\4\14\4\4\14\5\13(\5\13(\10" + "\25*\24\26*\24\26*\14\13\31\4\6\30\4\4\14\4\6\30\4\4\14\4\6\30\4\6\30" + "\5\13(\4\6\30\4\4\14\4\6\30\4\4\4\0\0\0\4\4\14\4\4\14\0\0\0\0\0\0\0\0" + "\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\31*W\31*W\7\31G\26$I\4+X\7\31G\10$L\31*W\40""3Z\26$" + "I\31*W\7\27""9\4\4\14\24\26*\13\26\32\4\4\4\4\4\4\4\4\14\4\4\4\4\4\14" + "\0\0\0\4\4\4\4\4\4\0\0\0\4\4\14\4\4\14\4\4\14\4\4\14\4\6\30\4\6\30\4" + "\6\30\5\13(\5\13(\10\25*\5\13(\5\12""9\5\13(\5\13(\5\12""9\10\25*\5\12" + "9\7\27""9\5\12""9\5\12""9\5\13(\5\13(\4\6\30\5\13(\5\13(\5\13(\24\14" + ",\10\25*\26\33""8\26\33""8\5\13(\4\6\30\4\6\30\4\6\30\4\6\30\4\4\14\4" + "\4\14\4\6\30\4\6\30\4\6\30\14\13\31\4\6\30\4\6\30\4\6\30\4\4\14\4\4\14" + "\4\4\14\4\4\4\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10$L\31*W\10$L\40""3Z%7" + "g\34,e\34,e\31*W%7g\31*W\40""3Z\7\27""9\4\6\30\24\26*\24\26*\4\4\14\4" + "\4\14\4\4\14\4\4\4\4\4\4\0\0\0\0\0\0\4\4\4\4\4\14\4\4\14\4\6\30\4\6\30" + "\4\6\30\5\13(\5\13(\5\13(\7\27""9\7\27""9\7\27""9\7\27""9\7\27""9\5\12" + "9\5\13(\5\13(\5\13(\5\13(\5\13(\5\12""9\5\13(\5\13(\5\12""9\7\27""9\15" + "$;\15$;\26$I\26$I\26\33""8\26$I\26\33""8\10\25*\5\13(\4\6\30\4\6\30\4" + "\6\30\4\6\30\4\6\30\5\13(\10\25*\13\26\32\4\6\30\4\6\30\4\6\30\4\6\30" + "\4\4\14\4\4\4\4\4\14\4\4\4\0\0\0\4\4\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\34,e\33""5" + "e\7\31G\15$;\34,e!6u%7g\34,e\31*W\26$I\31*W\7\27""9\4\6\30\26\33""8\26" + "\33""8\4\4\14\4\4\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\4\14\4\6\30\5\13" + "(\24\14,\26\33""8\26$I\5\12""9\7\27""9\7\27""9\7\27""9\5\12""9\7\27""9" + "\7\27""9\5\13(\7\27""9\5\13(\5\13(\5\13(\5\13(\7\27""9\26$I\26$I\31*" + "W\10$L\26$I\7\31G\5\12""9\7\27""9\15$;\7\27""9\5\13(\5\13(\5\13(\5\13" + "(\4\6\30\4\6\30\4\6\30\4\6\30\4\6\30\10\25*\10\25*\5\13(\4\6\30\4\6\30" + "\4\6\30\4\6\30\4\4\14\4\4\14\0\0\0\4\4\4\4\4\14\4\4\4\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\34,e\33""5e\31*W\31*W\34,e%7g\40""3Z\40""3Z\31*W\31*W\31*W\34,e" + "\5\13(\7\27""9\7\31G\26$I\26$I\10$L\26$I\31*W\7\31G\7\31G\26$I\31*W\31" + "*W\7\31G\5\12""9\7\27""9\10\25*\5\12""9\10\25*\5\12""9\5\13(\5\12""9" + "\5\13(\5\13(\7\27""9\7\27""9\7\27""9\15$;\26$I\31*W\26$I\10$L\10\25*" + "\5\13(\5\13(\5\13(\10\25*\10\25*\5\13(\5\13(\4\6\30\4\6\30\5\13(\5\13" + "(\10\25*\5\12""9\5\12""9\7\31G\7\31G\7\31G\10$L\4""4i\4=0;i--) oldipos[i] = *curipos[i]; +} + +void setinterpolation(long *posptr) +{ + long i; + + if (numinterpolations >= MAXINTERPOLATIONS) return; + for(i=numinterpolations-1;i>=0;i--) + if (curipos[i] == posptr) return; + curipos[numinterpolations] = posptr; + oldipos[numinterpolations] = *posptr; + numinterpolations++; +} + +void stopinterpolation(long *posptr) +{ + long i; + + for(i=numinterpolations-1;i>=startofdynamicinterpolations;i--) + if (curipos[i] == posptr) + { + numinterpolations--; + oldipos[i] = oldipos[numinterpolations]; + bakipos[i] = bakipos[numinterpolations]; + curipos[i] = curipos[numinterpolations]; + } +} + +void dointerpolations(long smoothratio) //Stick at beginning of drawscreen +{ + long i, j, odelta, ndelta; + + ndelta = 0; j = 0; + for(i=numinterpolations-1;i>=0;i--) + { + bakipos[i] = *curipos[i]; + odelta = ndelta; ndelta = (*curipos[i])-oldipos[i]; + if (odelta != ndelta) j = mulscale16(ndelta,smoothratio); + *curipos[i] = oldipos[i]+j; + } +} + +void restoreinterpolations() //Stick at end of drawscreen +{ + long i; + + for(i=numinterpolations-1;i>=0;i--) *curipos[i] = bakipos[i]; +} + +long ceilingspace(short sectnum) +{ + if( (sector[sectnum].ceilingstat&1) && sector[sectnum].ceilingpal == 0 ) + { + if ((sector[sectnum].ceilingpicnum==MOONSKY1)||(sector[sectnum].ceilingpicnum==BIGORBIT1)) return 1; + + } + return 0; +} + +long floorspace(short sectnum) +{ + if( (sector[sectnum].floorstat&1) && sector[sectnum].ceilingpal == 0 ) + { + if ((sector[sectnum].floorpicnum==MOONSKY1)||(sector[sectnum].floorpicnum==BIGORBIT1)) return 1; + } + return 0; +} + +void addammo( short weapon,struct player_struct *p,short amount) +{ + p->ammo_amount[weapon] += amount; + + if( p->ammo_amount[weapon] > max_ammo_amount[weapon] ) + p->ammo_amount[weapon] = max_ammo_amount[weapon]; +} + +void addweaponnoswitch( struct player_struct *p, short weapon) +{ + if ( p->gotweapon[weapon] == 0 ) + { + p->gotweapon[weapon] = 1; + if(weapon == SHRINKER_WEAPON) + p->gotweapon[GROW_WEAPON] = 1; + } + switch(weapon) + { + case KNEE_WEAPON: + case TRIPBOMB_WEAPON: + case HANDREMOTE_WEAPON: + case HANDBOMB_WEAPON: break; + case SHOTGUN_WEAPON: spritesound(SHOTGUN_COCK,p->i);break; + case PISTOL_WEAPON: spritesound(INSERT_CLIP,p->i);break; + default: spritesound(SELECT_WEAPON,p->i);break; + } +} + +void addweapon( struct player_struct *p,short weapon) +{ + short snum; + snum = sprite[p->i].yvel; + + addweaponnoswitch(p,weapon); + + if (p->reloading) return; + + p->random_club_frame = 0; + + if(p->holster_weapon == 0) + { + p->weapon_pos = -1; + p->last_weapon = p->curr_weapon; + } + else + { + p->weapon_pos = 10; + p->holster_weapon = 0; + p->last_weapon = -1; + } + + p->kickback_pic = 0; + + if(p->curr_weapon != weapon) + { + p->curr_weapon = weapon; + + SetGameVarID(g_iWeaponVarID,p->curr_weapon, p->i, snum); + if(p->curr_weapon>=0) + { + SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + } + else + { + SetGameVarID(g_iWorksLikeVarID,-1, p->i, snum); + } + OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1); + } +} + +void checkavailinven( struct player_struct *p ) +{ + + if(p->firstaid_amount > 0) + p->inven_icon = 1; + else if(p->steroids_amount > 0) + p->inven_icon = 2; + else if(p->holoduke_amount > 0) + p->inven_icon = 3; + else if(p->jetpack_amount > 0) + p->inven_icon = 4; + else if(p->heat_amount > 0) + p->inven_icon = 5; + else if(p->scuba_amount > 0) + p->inven_icon = 6; + else if(p->boot_amount > 0) + p->inven_icon = 7; + else p->inven_icon = 0; +} + +void checkavailweapon( struct player_struct *p ) +{ + short i,snum; + int32 weap; + + if(p->reloading == 1) return; + + if(p->wantweaponfire >= 0) + { + weap = p->wantweaponfire; + p->wantweaponfire = -1; + + if(weap == p->curr_weapon) return; + else if( p->gotweapon[weap] && p->ammo_amount[weap] > 0 ) + { + addweapon(p,weap); + return; + } + } + + weap = p->curr_weapon; + if( p->gotweapon[weap] && p->ammo_amount[weap] > 0 ) + return; + if( p->gotweapon[weap] && !(p->weaponswitch & 2)) + return; + + snum = sprite[p->i].yvel; + + for(i=0;i<10;i++) + { + weap = ud.wchoice[snum][i]; + if (VOLUMEONE && weap > 6) continue; + + if(weap == 0) weap = 9; + else weap--; + + if( weap == 0 || ( p->gotweapon[weap] && p->ammo_amount[weap] > 0 ) ) + break; + } + + if(i == 10) weap = 0; + + // Found the weapon + + p->last_weapon = p->curr_weapon; + p->random_club_frame = 0; + p->curr_weapon = weap; + SetGameVarID(g_iWeaponVarID,p->curr_weapon, p->i, snum); + if(p->curr_weapon>=0) + { + SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + } + else + { + SetGameVarID(g_iWorksLikeVarID,-1, p->i, snum); + } + OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1); + p->kickback_pic = 0; + if(p->holster_weapon == 1) + { + p->holster_weapon = 0; + p->weapon_pos = 10; + } + else p->weapon_pos = -1; +} + +long ifsquished(short i, short p) +{ + sectortype *sc; + char squishme; + long floorceildist; + + if(PN == APLAYER && ud.clipping) + return 0; + + sc = §or[SECT]; + floorceildist = sc->floorz - sc->ceilingz; + + if(sc->lotag != 23) + { + if(sprite[i].pal == 1) + squishme = floorceildist < (32<<8) && (sc->lotag&32768) == 0; + else + squishme = floorceildist < (12<<8); // && (sc->lotag&32768) == 0; + } + else squishme = 0; + + if( squishme ) + { + FTA(10,&ps[p]); + + if(badguy(&sprite[i])) sprite[i].xvel = 0; + + if(sprite[i].pal == 1) + { + hittype[i].picnum = SHOTSPARK1; + hittype[i].extra = 1; + return 0; + } + + return 1; + } + return 0; +} + +void hitradius( short i, long r, long hp1, long hp2, long hp3, long hp4 ) +{ + spritetype *s,*sj; + walltype *wal; + long d, q, x1, y1; + long sectcnt, sectend, dasect, startwall, endwall, nextsect; + short j,k,p,x,nextj,sect; + char statlist[] = {0,1,6,10,12,2,5}; + short *tempshort = (short *)tempbuf; + + s = &sprite[i]; + + if(s->picnum == RPG && s->xrepeat < 11) goto SKIPWALLCHECK; + + if(s->picnum != SHRINKSPARK) + { + tempshort[0] = s->sectnum; + dasect = s->sectnum; + sectcnt = 0; sectend = 1; + + do + { + dasect = tempshort[sectcnt++]; + if(((sector[dasect].ceilingz-s->z)>>8) < r) + { + d = klabs(wall[sector[dasect].wallptr].x-s->x)+klabs(wall[sector[dasect].wallptr].y-s->y); + if(d < r) + checkhitceiling(dasect); + else + { + d = klabs(wall[wall[wall[sector[dasect].wallptr].point2].point2].x-s->x)+klabs(wall[wall[wall[sector[dasect].wallptr].point2].point2].y-s->y); + if(d < r) + checkhitceiling(dasect); + } + } + + startwall = sector[dasect].wallptr; + endwall = startwall+sector[dasect].wallnum; + for(x=startwall,wal=&wall[startwall];xx-s->x)+klabs(wal->y-s->y) ) < r) + { + nextsect = wal->nextsector; + if (nextsect >= 0) + { + for(dasect=sectend-1;dasect>=0;dasect--) + if (tempshort[dasect] == nextsect) break; + if (dasect < 0) tempshort[sectend++] = nextsect; + } + x1 = (((wal->x+wall[wal->point2].x)>>1)+s->x)>>1; + y1 = (((wal->y+wall[wal->point2].y)>>1)+s->y)>>1; + updatesector(x1,y1,§); + if( sect >= 0 && cansee(x1,y1,s->z,sect,s->x,s->y,s->z,s->sectnum ) ) + checkhitwall(i,x,wal->x,wal->y,s->z,s->picnum); + } + } + while (sectcnt < sectend); + } + +SKIPWALLCHECK: + + q = -(16<<8)+(TRAND&((32<<8)-1)); + + for(x = 0;x<7;x++) + { + j = headspritestat[statlist[x]]; + while(j >= 0) + { + nextj = nextspritestat[j]; + sj = &sprite[j]; + + if( x == 0 || x >= 5 || AFLAMABLE(sj->picnum) ) + { + if( s->picnum != SHRINKSPARK || (sj->cstat&257) ) + if( dist( s, sj ) < r ) + { + if( badguy(sj) && !cansee( sj->x, sj->y,sj->z+q, sj->sectnum, s->x, s->y, s->z+q, s->sectnum) ) + goto BOLT; + checkhitsprite( j, i ); + } + } + else if( sj->extra >= 0 && sj != s && ( sj->picnum == TRIPBOMB || badguy(sj) || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL || (sj->cstat&257) || sj->picnum == DUKELYINGDEAD ) ) + { + if( s->picnum == SHRINKSPARK && sj->picnum != SHARK && ( j == s->owner || sj->xrepeat < 24 ) ) + { + j = nextj; + continue; + } + if( s->picnum == MORTER && j == s->owner) + { + j = nextj; + continue; + } + + if(sj->picnum == APLAYER) sj->z -= PHEIGHT; + d = dist( s, sj ); + if(sj->picnum == APLAYER) sj->z += PHEIGHT; + + if ( d < r && cansee( sj->x, sj->y, sj->z-(8<<8), sj->sectnum, s->x, s->y, s->z-(12<<8), s->sectnum) ) + { + hittype[j].ang = getangle(sj->x-s->x,sj->y-s->y); + + if ( s->picnum == RPG && sj->extra > 0) + hittype[j].picnum = RPG; + else + { + if( s->picnum == SHRINKSPARK ) + hittype[j].picnum = SHRINKSPARK; + else hittype[j].picnum = RADIUSEXPLOSION; + } + + if(s->picnum != SHRINKSPARK) + { + if ( d < r/3 ) + { + if(hp4 == hp3) hp4++; + hittype[j].extra = hp3 + (TRAND%(hp4-hp3)); + } + else if ( d < 2*r/3 ) + { + if(hp3 == hp2) hp3++; + hittype[j].extra = hp2 + (TRAND%(hp3-hp2)); + } + else if ( d < r ) + { + if(hp2 == hp1) hp2++; + hittype[j].extra = hp1 + (TRAND%(hp2-hp1)); + } + + if( sprite[j].picnum != TANK && sprite[j].picnum != ROTATEGUN && sprite[j].picnum != RECON && sprite[j].picnum != BOSS1 && sprite[j].picnum != BOSS2 && sprite[j].picnum != BOSS3 && sprite[j].picnum != BOSS4 ) + { + if(sj->xvel < 0) sj->xvel = 0; + sj->xvel += (s->extra<<2); + } + + if( sj->picnum == PODFEM1 || sj->picnum == FEM1 || + sj->picnum == FEM2 || sj->picnum == FEM3 || + sj->picnum == FEM4 || sj->picnum == FEM5 || + sj->picnum == FEM6 || sj->picnum == FEM7 || + sj->picnum == FEM8 || sj->picnum == FEM9 || + sj->picnum == FEM10 || sj->picnum == STATUE || + sj->picnum == STATUEFLASH || sj->picnum == SPACEMARINE || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL) + checkhitsprite( j, i ); + } + else if(s->extra == 0) hittype[j].extra = 0; + + if ( sj->picnum != RADIUSEXPLOSION && + s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS ) + { + if(sj->picnum == APLAYER) + { + p = sj->yvel; + if(ps[p].newowner >= 0) + { + ps[p].newowner = -1; + ps[p].posx = ps[p].oposx; + ps[p].posy = ps[p].oposy; + ps[p].posz = ps[p].oposz; + ps[p].ang = ps[p].oang; + updatesector(ps[p].posx,ps[p].posy,&ps[p].cursectnum); + setpal(&ps[p]); + + k = headspritestat[1]; + while(k >= 0) + { + if(sprite[k].picnum==CAMERA1) + sprite[k].yvel = 0; + k = nextspritestat[k]; + } + } + } + hittype[j].owner = s->owner; + } + } + } +BOLT: + j = nextj; + } + } +} + +int movesprite(short spritenum, long xchange, long ychange, long zchange, unsigned long cliptype) +{ + long daz,h, oldx, oldy; + short retval, dasectnum, a, cd; + char bg; + + bg = badguy(&sprite[spritenum]); + + if(sprite[spritenum].statnum == 5 || (bg && sprite[spritenum].xrepeat < 4 ) ) + { + sprite[spritenum].x += (xchange*TICSPERFRAME)>>2; + sprite[spritenum].y += (ychange*TICSPERFRAME)>>2; + sprite[spritenum].z += (zchange*TICSPERFRAME)>>2; + if(bg) + setsprite(spritenum,sprite[spritenum].x,sprite[spritenum].y,sprite[spritenum].z); + return 0; + } + + dasectnum = sprite[spritenum].sectnum; + + daz = sprite[spritenum].z; + h = ((tilesizy[sprite[spritenum].picnum]*sprite[spritenum].yrepeat)<<1); + daz -= h; + + if( bg ) + { + oldx = sprite[spritenum].x; + oldy = sprite[spritenum].y; + + if( sprite[spritenum].xrepeat > 60 ) + retval = clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((xchange*TICSPERFRAME)<<11),((ychange*TICSPERFRAME)<<11),1024L,(4<<8),(4<<8),cliptype); + else + { + if(sprite[spritenum].picnum == LIZMAN) + cd = 292L; + else if( (actortype[sprite[spritenum].picnum]&3) ) + cd = sprite[spritenum].clipdist<<2; + else + cd = 192L; + + retval = clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((xchange*TICSPERFRAME)<<11),((ychange*TICSPERFRAME)<<11),cd,(4<<8),(4<<8),cliptype); + } + + if( dasectnum < 0 || ( dasectnum >= 0 && + ( ( hittype[spritenum].actorstayput >= 0 && hittype[spritenum].actorstayput != dasectnum ) || + ( ( sprite[spritenum].picnum == BOSS2 ) && sprite[spritenum].pal == 0 && sector[dasectnum].lotag != 3 ) || + ( ( sprite[spritenum].picnum == BOSS1 || sprite[spritenum].picnum == BOSS2 ) && sector[dasectnum].lotag == 1 ) || + ( sector[dasectnum].lotag == 1 && ( sprite[spritenum].picnum == LIZMAN || ( sprite[spritenum].picnum == LIZTROOP && sprite[spritenum].zvel == 0 ) ) ) + ) ) + ) + { + sprite[spritenum].x = oldx; + sprite[spritenum].y = oldy; + if(sector[dasectnum].lotag == 1 && sprite[spritenum].picnum == LIZMAN) + sprite[spritenum].ang = (TRAND&2047); + else if( (hittype[spritenum].temp_data[0]&3) == 1 && sprite[spritenum].picnum != COMMANDER ) + sprite[spritenum].ang = (TRAND&2047); + setsprite(spritenum,oldx,oldy,sprite[spritenum].z); + if(dasectnum < 0) dasectnum = 0; + return (16384+dasectnum); + } + if( (retval&49152) >= 32768 && (hittype[spritenum].cgg==0) ) sprite[spritenum].ang += 768; + } + else + { + if(sprite[spritenum].statnum == 4) + retval = + clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((xchange*TICSPERFRAME)<<11),((ychange*TICSPERFRAME)<<11),8L,(4<<8),(4<<8),cliptype); + else + retval = + clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((xchange*TICSPERFRAME)<<11),((ychange*TICSPERFRAME)<<11),(long)(sprite[spritenum].clipdist<<2),(4<<8),(4<<8),cliptype); + } + + if( dasectnum >= 0) + if ( (dasectnum != sprite[spritenum].sectnum) ) + changespritesect(spritenum,dasectnum); + daz = sprite[spritenum].z + ((zchange*TICSPERFRAME)>>3); + if ((daz > hittype[spritenum].ceilingz) && (daz <= hittype[spritenum].floorz)) + sprite[spritenum].z = daz; + else + if (retval == 0) + return(16384+dasectnum); + + return(retval); +} + +short ssp(short i,unsigned long cliptype) //The set sprite function +{ + spritetype *s; + long movetype; + + s = &sprite[i]; + + movetype = movesprite(i, + (s->xvel*(sintable[(s->ang+512)&2047]))>>14, + (s->xvel*(sintable[s->ang&2047]))>>14,s->zvel, + cliptype); + + return (movetype==0); +} + +void insertspriteq(short i) +{ + if(spriteqamount > 0) + { + if(spriteq[spriteqloc] >= 0) + sprite[spriteq[spriteqloc]].xrepeat = 0; + spriteq[spriteqloc] = i; + spriteqloc = (spriteqloc+1)%spriteqamount; + } + // else sprite[i].xrepeat = sprite[i].yrepeat = 0; + else deletesprite(i); +} + +void lotsofmoney(spritetype *s, short n) +{ + short i ,j; + for(i=n;i>0;i--) + { + j = EGS(s->sectnum,s->x,s->y,s->z-(TRAND%(47<<8)),MONEY,-32,8,8,TRAND&2047,0,0,0,5); + sprite[j].cstat = TRAND&12; + } +} + +void lotsofmail(spritetype *s, short n) +{ + short i ,j; + for(i=n;i>0;i--) + { + j = EGS(s->sectnum,s->x,s->y,s->z-(TRAND%(47<<8)),MAIL,-32,8,8,TRAND&2047,0,0,0,5); + sprite[j].cstat = TRAND&12; + } +} + +void lotsofpaper(spritetype *s, short n) +{ + short i ,j; + for(i=n;i>0;i--) + { + j = EGS(s->sectnum,s->x,s->y,s->z-(TRAND%(47<<8)),PAPER,-32,8,8,TRAND&2047,0,0,0,5); + sprite[j].cstat = TRAND&12; + } +} + +void guts(spritetype *s,short gtype, short n, short p) +{ + long gutz,floorz; + short i,a,j; + char sx,sy; + signed char pal; + + if(badguy(s) && s->xrepeat < 16) + sx = sy = 8; + else sx = sy = 32; + + gutz = s->z-(8<<8); + floorz = getflorzofslope(s->sectnum,s->x,s->y); + + if( gutz > ( floorz-(8<<8) ) ) + gutz = floorz-(8<<8); + + if(s->picnum == COMMANDER) + gutz -= (24<<8); + + if( badguy(s) && s->pal == 6) + pal = 6; + else pal = 0; + + for(j=0;jsectnum,s->x+(TRAND&255)-128,s->y+(TRAND&255)-128,gutz-(TRAND&8191),gtype,-32,sx,sy,a,48+(TRAND&31),-512-(TRAND&2047),ps[p].i,5); + if(PN == JIBS2) + { + sprite[i].xrepeat >>= 2; + sprite[i].yrepeat >>= 2; + } + if(pal == 6) + sprite[i].pal = 6; + } +} + +void gutsdir(spritetype *s,short gtype, short n, short p) +{ + long gutz,floorz; + short i,a,j; + char sx,sy; + + if(badguy(s) && s->xrepeat < 16) + sx = sy = 8; + else sx = sy = 32; + + gutz = s->z-(8<<8); + floorz = getflorzofslope(s->sectnum,s->x,s->y); + + if( gutz > ( floorz-(8<<8) ) ) + gutz = floorz-(8<<8); + + if(s->picnum == COMMANDER) + gutz -= (24<<8); + + for(j=0;jsectnum,s->x,s->y,gutz,gtype,-32,sx,sy,a,256+(TRAND&127),-512-(TRAND&2047),ps[p].i,5); + } +} + +void setsectinterpolate(short i) +{ + long j, k, startwall,endwall; + + startwall = sector[SECT].wallptr; + endwall = startwall+sector[SECT].wallnum; + + for(j=startwall;j= 0) + { + setinterpolation(&wall[k].x); + setinterpolation(&wall[k].y); + k = wall[k].point2; + setinterpolation(&wall[k].x); + setinterpolation(&wall[k].y); + } + } +} + +void clearsectinterpolate(short i) +{ + short j,startwall,endwall; + + startwall = sector[SECT].wallptr; + endwall = startwall+sector[SECT].wallnum; + for(j=startwall;j= 0) + { + stopinterpolation(&wall[wall[j].nextwall].x); + stopinterpolation(&wall[wall[j].nextwall].y); + } + } +} + +void ms(short i) +{ + //T1,T2 and T3 are used for all the sector moving stuff!!! + + short startwall,endwall,x; + long tx,ty,j,k; + spritetype *s; + + s = &sprite[i]; + + s->x += (s->xvel*(sintable[(s->ang+512)&2047]))>>14; + s->y += (s->xvel*(sintable[s->ang&2047]))>>14; + + j = T2; + k = T3; + + startwall = sector[s->sectnum].wallptr; + endwall = startwall+sector[s->sectnum].wallnum; + for(x=startwall;xx+tx,s->y+ty); + + j++; + } +} + +void movefta(void) +{ + long x, px, py, sx, sy; + short i, j, p, psect, ssect, nexti; + spritetype *s; + + i = headspritestat[2]; + while(i >= 0) + { + nexti = nextspritestat[i]; + + s = &sprite[i]; + p = findplayer(s,&x); + + ssect = psect = s->sectnum; + + if(sprite[ps[p].i].extra > 0 ) + { + if( x < 30000 ) + { + hittype[i].timetosleep++; + if( hittype[i].timetosleep >= (x>>8) ) + { + if(badguy(s)) + { + px = ps[p].oposx+64-(TRAND&127); + py = ps[p].oposy+64-(TRAND&127); + updatesector(px,py,&psect); + if(psect == -1) + { + i = nexti; + continue; + } + sx = s->x+64-(TRAND&127); + sy = s->y+64-(TRAND&127); + updatesector(px,py,&ssect); + if(ssect == -1) + { + i = nexti; + continue; + } + j = cansee(sx,sy,s->z-(TRAND%(52<<8)),s->sectnum,px,py,ps[p].oposz-(TRAND%(32<<8)),ps[p].cursectnum); + } + else + j = cansee(s->x,s->y,s->z-((TRAND&31)<<8),s->sectnum,ps[p].oposx,ps[p].oposy,ps[p].oposz-((TRAND&31)<<8),ps[p].cursectnum); + + // j = 1; + + if(j) switch(dynamictostatic[s->picnum]) + { + case RUBBERCAN__STATIC: + case EXPLODINGBARREL__STATIC: + case WOODENHORSE__STATIC: + case HORSEONSIDE__STATIC: + case CANWITHSOMETHING__STATIC: + case CANWITHSOMETHING2__STATIC: + case CANWITHSOMETHING3__STATIC: + case CANWITHSOMETHING4__STATIC: + case FIREBARREL__STATIC: + case FIREVASE__STATIC: + case NUKEBARREL__STATIC: + case NUKEBARRELDENTED__STATIC: + case NUKEBARRELLEAKED__STATIC: + case TRIPBOMB__STATIC: + if (sector[s->sectnum].ceilingstat&1 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + s->shade = sector[s->sectnum].ceilingshade; + else s->shade = sector[s->sectnum].floorshade; + + hittype[i].timetosleep = 0; + changespritestat(i,6); + break; + default: + hittype[i].timetosleep = 0; + check_fta_sounds(i); + changespritestat(i,1); + break; + } + else hittype[i].timetosleep = 0; + } + } + if( badguy( s ) && checkspriteflags(i,SPRITE_FLAG_NOSHADE) == 0) + { + if (sector[s->sectnum].ceilingstat&1) + s->shade = sector[s->sectnum].ceilingshade; + else s->shade = sector[s->sectnum].floorshade; + } + } + i = nexti; + } +} + +short ifhitsectors(short sectnum) +{ + short i; + + i = headspritestat[5]; + while(i >= 0) + { + if( PN == EXPLOSION2 && sectnum == SECT ) + return i; + i = nextspritestat[i]; + } + return -1; +} + +short ifhitbyweapon(short sn) +{ + short j, k, p; + spritetype *npc; + + if( hittype[sn].extra >= 0 ) + { + if(sprite[sn].extra >= 0 ) + { + npc = &sprite[sn]; + + if(npc->picnum == APLAYER) + { + if(ud.god && hittype[sn].picnum != SHRINKSPARK ) return -1; + + p = npc->yvel; + j = hittype[sn].owner; + + if( j >= 0 && + sprite[j].picnum == APLAYER && + (gametype_flags[ud.coop] & GAMETYPE_FLAG_COOP) && + ud.ffire == 0 ) + return -1; + + npc->extra -= hittype[sn].extra; + + if(j >= 0) + { + if(npc->extra <= 0 && hittype[sn].picnum != FREEZEBLAST) + { + npc->extra = 0; + + ps[p].wackedbyactor = j; + + if( sprite[hittype[sn].owner].picnum == APLAYER && p != sprite[hittype[sn].owner].yvel ) + ps[p].frag_ps = sprite[j].yvel; + + hittype[sn].owner = ps[p].i; + } + } + + if(checkspriteflagsp(hittype[sn].picnum,SPRITE_FLAG_PROJECTILE) && (thisprojectile[sn].workslike & PROJECTILE_FLAG_RPG)) + { + ps[p].posxv += + hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<2; + ps[p].posyv += + hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<2; + } + + switch(dynamictostatic[hittype[sn].picnum]) + { + case RADIUSEXPLOSION__STATIC: + case RPG__STATIC: + case HYDRENT__STATIC: + case HEAVYHBOMB__STATIC: + case SEENINE__STATIC: + case OOZFILTER__STATIC: + case EXPLODINGBARREL__STATIC: + ps[p].posxv += + hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<2; + ps[p].posyv += + hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<2; + break; + default: + ps[p].posxv += + hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<1; + ps[p].posyv += + hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<1; + break; + } + } + else + { + if(hittype[sn].extra == 0 ) + if( hittype[sn].picnum == SHRINKSPARK && npc->xrepeat < 24 ) + return -1; + + npc->extra -= hittype[sn].extra; + if(npc->picnum != RECON && npc->owner >= 0 && sprite[npc->owner].statnum < MAXSTATUS ) + npc->owner = hittype[sn].owner; + } + + hittype[sn].extra = -1; + return hittype[sn].picnum; + } + } + + hittype[sn].extra = -1; + return -1; +} + +void movecyclers(void) +{ + short q, j, x, t, s, *c; + walltype *wal; + char cshade; + + for(q=numcyclers-1;q>=0;q--) + { + + c = &cyclers[q][0]; + s = c[0]; + + t = c[3]; + j = t+(sintable[c[1]&2047]>>10); + cshade = c[2]; + + if( j < cshade ) j = cshade; + else if( j > t ) j = t; + + c[1] += sector[s].extra; + if(c[5]) + { + wal = &wall[sector[s].wallptr]; + for(x = sector[s].wallnum;x>0;x--,wal++) + if( wal->hitag != 1 ) + { + wal->shade = j; + + if( (wal->cstat&2) && wal->nextwall >= 0) + wall[wal->nextwall].shade = j; + + } + sector[s].floorshade = sector[s].ceilingshade = j; + } + } +} + +void movedummyplayers(void) +{ + short i, p, nexti; + + i = headspritestat[13]; + while(i >= 0) + { + nexti = nextspritestat[i]; + + p = sprite[OW].yvel; + + if( ps[p].on_crane >= 0 || sector[ps[p].cursectnum].lotag != 1 || sprite[ps[p].i].extra <= 0 ) + { + ps[p].dummyplayersprite = -1; + KILLIT(i); + } + else + { + if(ps[p].on_ground && ps[p].on_warping_sector == 1 && sector[ps[p].cursectnum].lotag == 1 ) + { + CS = 257; + SZ = sector[SECT].ceilingz+(27<<8); + SA = ps[p].ang; + if(T1 == 8) + T1 = 0; + else T1++; + } + else + { + if(sector[SECT].lotag != 2) SZ = sector[SECT].floorz; + CS = (short) 32768; + } + } + + SX += (ps[p].posx-ps[p].oposx); + SY += (ps[p].posy-ps[p].oposy); + setsprite(i,SX,SY,SZ); + +BOLT: + + i = nexti; + } +} + +short otherp; +void moveplayers(void) //Players +{ + short i , nexti; + long otherx; + spritetype *s; + struct player_struct *p; + + i = headspritestat[10]; + while(i >= 0) + { + nexti = nextspritestat[i]; + + s = &sprite[i]; + p = &ps[s->yvel]; + if(s->owner >= 0) + { + if(p->newowner >= 0 ) //Looking thru the camera + { + s->x = p->oposx; + s->y = p->oposy; + hittype[i].bposz = s->z = p->oposz+PHEIGHT; + s->ang = p->oang; + setsprite(i,s->x,s->y,s->z); + } + else + { + if(ud.multimode > 1) + otherp = findotherplayer(s->yvel,&otherx); + else + { + otherp = s->yvel; + otherx = 0; + } + + execute(i,s->yvel,otherx); + + if(ud.multimode > 1) + if( sprite[ps[otherp].i].extra > 0 ) + { + if( s->yrepeat > 32 && sprite[ps[otherp].i].yrepeat < 32) + { + if( otherx < 1400 && p->knee_incs == 0 ) + { + p->knee_incs = 1; + p->weapon_pos = -1; + p->actorsqu = ps[otherp].i; + } + } + } + if(ud.god) + { + s->extra = max_player_health; + s->cstat = 257; + p->jetpack_amount = 1599; + } + + + if( s->extra > 0 ) + { + hittype[i].owner = i; + + if(ud.god == 0) + if( ceilingspace(s->sectnum) || floorspace(s->sectnum) ) + quickkill(p); + } + else + { + + p->posx = s->x; + p->posy = s->y; + p->posz = s->z-(20<<8); + + p->newowner = -1; + + if( p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS ) + { + p->ang += getincangle(p->ang,getangle(sprite[p->wackedbyactor].x-p->posx,sprite[p->wackedbyactor].y-p->posy))>>1; + p->ang &= 2047; + } + + } + s->ang = p->ang; + } + } + else + { + if(p->holoduke_on == -1) + KILLIT(i); + + hittype[i].bposx = s->x; + hittype[i].bposy = s->y; + hittype[i].bposz = s->z; + + s->cstat = 0; + + if(s->xrepeat < 42) + { + s->xrepeat += 4; + s->cstat |= 2; + } + else s->xrepeat = 42; + if(s->yrepeat < 36) + s->yrepeat += 4; + else + { + s->yrepeat = 36; + if(sector[s->sectnum].lotag != 2) + makeitfall(i); + if(s->zvel == 0 && sector[s->sectnum].lotag == 1) + s->z += (32<<8); + } + + if(s->extra < 8) + { + s->xvel = 128; + s->ang = p->ang; + s->extra++; + ssp(i,CLIPMASK0); + } + else + { + s->ang = 2047-p->ang; + setsprite(i,s->x,s->y,s->z); + } + } + + if (sector[s->sectnum].ceilingstat&1) + s->shade += (sector[s->sectnum].ceilingshade-s->shade)>>1; + else + s->shade += (sector[s->sectnum].floorshade-s->shade)>>1; + +BOLT: + i = nexti; + } +} + +void movefx(void) +{ + short i, j, nexti, p; + long x, ht; + spritetype *s; + + i = headspritestat[11]; + while(i >= 0) + { + s = &sprite[i]; + + nexti = nextspritestat[i]; + + switch(dynamictostatic[s->picnum]) + { + case RESPAWN__STATIC: + if(sprite[i].extra == 66) + { + j = spawn(i,SHT); + // sprite[j].pal = sprite[i].pal; + KILLIT(i); + } + else if(sprite[i].extra > (66-13)) + sprite[i].extra++; + break; + + case MUSICANDSFX__STATIC: + + ht = s->hitag; + + if(T2 != SoundToggle) + { + T2 = SoundToggle; + T1 = 0; + } + + if(s->lotag >= 1000 && s->lotag < 2000) + { + x = ldist(&sprite[ps[screenpeek].i],s); + if( x < ht && T1 == 0 ) + { + FX_SetReverb( s->lotag - 1000 ); + T1 = 1; + } + if( x >= ht && T1 == 1 ) + { + FX_SetReverb(0); + FX_SetReverbDelay(0); + T1 = 0; + } + } + else if(s->lotag < 999 && (unsigned)sector[s->sectnum].lotag < 9 && AmbienceToggle && sector[SECT].floorz != sector[SECT].ceilingz) + { + if( (soundm[s->lotag]&2) ) + { + x = dist(&sprite[ps[screenpeek].i],s); + if( x < ht && T1 == 0 && FX_VoiceAvailable(soundpr[s->lotag]-1) ) + { + if(numenvsnds == NumVoices) + { + j = headspritestat[11]; + while(j >= 0) + { + if( PN == MUSICANDSFX && j != i && sprite[j].lotag < 999 && hittype[j].temp_data[0] == 1 && dist(&sprite[j],&sprite[ps[screenpeek].i]) > x ) + { + stopenvsound(sprite[j].lotag,j); + break; + } + j = nextspritestat[j]; + } + if(j == -1) goto BOLT; + } + spritesound(s->lotag,i); + T1 = 1; + } + if( x >= ht && T1 == 1 ) + { + T1 = 0; + stopenvsound(s->lotag,i); + } + } + if( (soundm[s->lotag]&16) ) + { + if(T5 > 0) T5--; + else for(p=connecthead;p>=0;p=connectpoint2[p]) + if( p == myconnectindex && ps[p].cursectnum == s->sectnum ) + { + j = s->lotag+((unsigned)global_random%(s->hitag+1)); + sound(j); + T5 = 26*40 + (global_random%(26*40)); + } + } + } + break; + } +BOLT: + i = nexti; + } +} + +void movefallers(void) +{ + short i, nexti, sect, j; + spritetype *s; + long x; + + i = headspritestat[12]; + while(i >= 0) + { + nexti = nextspritestat[i]; + s = &sprite[i]; + + sect = s->sectnum; + + if( T1 == 0 ) + { + s->z -= (16<<8); + T2 = s->ang; + x = s->extra; + IFHIT + { + if( j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER ) + { + if(s->extra <= 0) + { + T1 = 1; + j = headspritestat[12]; + while(j >= 0) + { + if(sprite[j].hitag == SHT) + { + hittype[j].temp_data[0] = 1; + sprite[j].cstat &= (65535-64); + if(sprite[j].picnum == CEILINGSTEAM || sprite[j].picnum == STEAM) + sprite[j].cstat |= 32768; + } + j = nextspritestat[j]; + } + } + } + else + { + hittype[i].extra = 0; + s->extra = x; + } + } + s->ang = T2; + s->z += (16<<8); + } + else if(T1 == 1) + { + if(s->lotag > 0) + { + s->lotag-=3; + if(s->lotag <= 0) + { + s->xvel = (32+(TRAND&63)); + s->zvel = -(1024+(TRAND&1023)); + } + } + else + { + if( s->xvel > 0) + { + s->xvel -= 8; + ssp(i,CLIPMASK0); + } + + if( floorspace(s->sectnum) ) x = 0; + else + { + if(ceilingspace(s->sectnum)) + x = gc/6; + else + x = gc; + } + + if( s->z < (sector[sect].floorz-FOURSLEIGHT) ) + { + s->zvel += x; + if(s->zvel > 6144) + s->zvel = 6144; + s->z += s->zvel; + } + if( (sector[sect].floorz-s->z) < (16<<8) ) + { + j = 1+(TRAND&7); + for(x=0;x= 0) + { + nexti = nextspritestat[i]; + + t = &hittype[i].temp_data[0]; + s = &sprite[i]; + sect = s->sectnum; + + if( sect < 0 ) KILLIT(i); + + hittype[i].bposx = s->x; + hittype[i].bposy = s->y; + hittype[i].bposz = s->z; + + IFWITHIN(CRANE,CRANE+3) + { + //t[0] = state + //t[1] = checking sector number + + if(s->xvel) getglobalz(i); + + if( t[0] == 0 ) //Waiting to check the sector + { + j = headspritesect[t[1]]; + while(j>=0) + { + nextj = nextspritesect[j]; + switch( sprite[j].statnum ) + { + case 1: + case 2: + case 6: + case 10: + s->ang = getangle(msx[t[4]+1]-s->x,msy[t[4]+1]-s->y); + setsprite(j,msx[t[4]+1],msy[t[4]+1],sprite[j].z); + t[0]++; + goto BOLT; + } + j = nextj; + } + } + + else if(t[0]==1) + { + if( s->xvel < 184 ) + { + s->picnum = CRANE+1; + s->xvel += 8; + } + ssp(i,CLIPMASK0); + if(sect == t[1]) + t[0]++; + } + else if(t[0]==2 || t[0]==7) + { + s->z += (1024+512); + + if(t[0]==2) + { + if( (sector[sect].floorz - s->z) < (64<<8) ) + if(s->picnum > CRANE) s->picnum--; + + if( (sector[sect].floorz - s->z) < (4096+1024)) + t[0]++; + } + if(t[0]==7) + { + if( (sector[sect].floorz - s->z) < (64<<8) ) + { + if(s->picnum > CRANE) s->picnum--; + else + { + if(s->owner==-2) + { + spritesound(DUKE_GRUNT,ps[p].i); + p = findplayer(s,&x); + if(ps[p].on_crane == i) + ps[p].on_crane = -1; + } + t[0]++; + s->owner = -1; + } + } + } + } + else if(t[0]==3) + { + s->picnum++; + if( s->picnum == (CRANE+2) ) + { + p = checkcursectnums(t[1]); + if(p >= 0 && ps[p].on_ground) + { + s->owner = -2; + ps[p].on_crane = i; + spritesound(DUKE_GRUNT,ps[p].i); + ps[p].ang = s->ang+1024; + } + else + { + j = headspritesect[t[1]]; + while(j>=0) + { + switch( sprite[j].statnum ) + { + case 1: + case 6: + s->owner = j; + break; + } + j = nextspritesect[j]; + } + } + + t[0]++;//Grabbed the sprite + t[2]=0; + goto BOLT; + } + } + else if(t[0]==4) //Delay before going up + { + t[2]++; + if(t[2] > 10) + t[0]++; + } + else if(t[0]==5 || t[0] == 8) + { + if(t[0]==8 && s->picnum < (CRANE+2)) + if( (sector[sect].floorz-s->z) > 8192) + s->picnum++; + + if(s->z < msx[t[4]+2]) + { + t[0]++; + s->xvel = 0; + } + else + s->z -= (1024+512); + } + else if(t[0]==6) + { + if( s->xvel < 192 ) + s->xvel += 8; + s->ang = getangle(msx[t[4]]-s->x,msy[t[4]]-s->y); + ssp(i,CLIPMASK0); + if( ((s->x-msx[t[4]])*(s->x-msx[t[4]])+(s->y-msy[t[4]])*(s->y-msy[t[4]]) ) < (128*128) ) + t[0]++; + } + + else if(t[0]==9) + t[0] = 0; + + setsprite(msy[t[4]+2],s->x,s->y,s->z-(34<<8)); + + if(s->owner != -1) + { + p = findplayer(s,&x); + + IFHIT + { + if(s->owner == -2) + if(ps[p].on_crane == i) + ps[p].on_crane = -1; + s->owner = -1; + s->picnum = CRANE; + goto BOLT; + } + + if(s->owner >= 0) + { + setsprite(s->owner,s->x,s->y,s->z); + + hittype[s->owner].bposx = s->x; + hittype[s->owner].bposy = s->y; + hittype[s->owner].bposz = s->z; + + s->zvel = 0; + } + else if(s->owner == -2) + { + ps[p].oposx = ps[p].posx = s->x-(sintable[(ps[p].ang+512)&2047]>>6); + ps[p].oposy = ps[p].posy = s->y-(sintable[ps[p].ang&2047]>>6); + ps[p].oposz = ps[p].posz = s->z+(2<<8); + setsprite(ps[p].i,ps[p].posx,ps[p].posy,ps[p].posz); + ps[p].cursectnum = sprite[ps[p].i].sectnum; + } + } + + goto BOLT; + } + + IFWITHIN(WATERFOUNTAIN,WATERFOUNTAIN+3) + { + if(t[0] > 0) + { + if( t[0] < 20 ) + { + t[0]++; + + s->picnum++; + + if( s->picnum == ( WATERFOUNTAIN+3 ) ) + s->picnum = WATERFOUNTAIN+1; + } + else + { + p = findplayer(s,&x); + + if(x > 512) + { + t[0] = 0; + s->picnum = WATERFOUNTAIN; + } + else t[0] = 1; + } + } + goto BOLT; + } + + if( AFLAMABLE(s->picnum) ) + { + if(T1 == 1) + { + T2++; + if( (T2&3) > 0) goto BOLT; + + if( s->picnum == TIRE && T2 == 32 ) + { + s->cstat = 0; + j = spawn(i,BLOODPOOL); + sprite[j].shade = 127; + } + else + { + if(s->shade < 64) s->shade++; + else KILLIT(i); + } + + j = s->xrepeat-(TRAND&7); + if(j < 10) + { + KILLIT(i); + } + + s->xrepeat = j; + + j = s->yrepeat-(TRAND&7); + if(j < 4) { KILLIT(i); } + s->yrepeat = j; + } + if(s->picnum == BOX) + { + makeitfall(i); + hittype[i].ceilingz = sector[s->sectnum].ceilingz; + } + goto BOLT; + } + + if(s->picnum == TRIPBOMB) + { + // long lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, -1, -1); + // if(lTripBombControl & TRIPBOMB_TIMER) + if (hittype[i].temp_data[6] == 1) + { + + if(hittype[i].temp_data[7] >= 1) + { + hittype[i].temp_data[7]--; + } + + if(hittype[i].temp_data[7] <= 0) + { + // s->extra = *actorscrptr[s->picnum]; + T3=16; + hittype[i].temp_data[6]=3; + spritesound(LASERTRIP_ARMING,i); + } + // we're on a timer.... + } + if(T3 > 0 && hittype[i].temp_data[6] == 3) + { + T3--; + if(T3 == 8) + { + spritesound(LASERTRIP_EXPLODE,i); + for(j=0;j<5;j++) RANDOMSCRAP; + x = s->extra; + hitradius( i, tripbombblastradius, x>>2,x>>1,x-(x>>2),x); + + j = spawn(i,EXPLOSION2); + sprite[j].ang = s->ang; + sprite[j].xvel = 348; + ssp(j,CLIPMASK0); + + j = headspritestat[5]; + while(j >= 0) + { + if(sprite[j].picnum == LASERLINE && s->hitag == sprite[j].hitag) + sprite[j].xrepeat = sprite[j].yrepeat = 0; + j = nextspritestat[j]; + } + KILLIT(i); + } + goto BOLT; + } + else + { + x = s->extra; + s->extra = 1; + l = s->ang; + IFHIT { hittype[i].temp_data[6] = 3; T3 = 16; } + s->extra = x; + s->ang = l; + } + + if( T1 < 32 ) + { + p = findplayer(s,&x); + if( x > 768 ) T1++; + else if(T1 > 16) T1++; + } + if( T1 == 32 ) + { + l = s->ang; + s->ang = T6; + + T4 = s->x;T5 = s->y; + s->x += sintable[(T6+512)&2047]>>9; + s->y += sintable[(T6)&2047]>>9; + s->z -= (3<<8); + setsprite(i,s->x,s->y,s->z); + + x = hitasprite(i,&m); + + hittype[i].lastvx = x; + + s->ang = l; + + k = 0; + + // if(lTripBombControl & TRIPBOMB_TRIPWIRE) + if (hittype[i].temp_data[6] != 1) + { + // we're on a trip wire + + while(x > 0) + { + j = spawn(i,LASERLINE); + setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + sprite[j].hitag = s->hitag; + hittype[j].temp_data[1] = sprite[j].z; + + s->x += sintable[(T6+512)&2047]>>4; + s->y += sintable[(T6)&2047]>>4; + + if( x < 1024 ) + { + sprite[j].xrepeat = x>>5; + break; + } + x -= 1024; + } + } + T1++; + s->x = T4;s->y = T5; + s->z += (3<<8); + setsprite(i,s->x,s->y,s->z); + T4 = 0; + // if( m >= 0 && lTripBombControl & TRIPBOMB_TRIPWIRE) + if (m >= 0 && hittype[i].temp_data[6] != 1) + { + hittype[i].temp_data[6] = 3; + T3 = 13; + spritesound(LASERTRIP_ARMING,i); + } + else T3 = 0; + } + if(T1 == 33) + { + T2++; + + + T4 = s->x;T5 = s->y; + s->x += sintable[(T6+512)&2047]>>9; + s->y += sintable[(T6)&2047]>>9; + s->z -= (3<<8); + setsprite(i,s->x,s->y,s->z); + + x = hitasprite(i,&m); + + s->x = T4;s->y = T5; + s->z += (3<<8); + setsprite(i,s->x,s->y,s->z); + + // if( hittype[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE) + if( hittype[i].lastvx != x && hittype[i].temp_data[6] != 1) + { + hittype[i].temp_data[6] = 3; + T3 = 13; + spritesound(LASERTRIP_ARMING,i); + } + } + goto BOLT; + } + + + if( s->picnum >= CRACK1 && s->picnum <= CRACK4 ) + { + if(s->hitag > 0) + { + t[0] = s->cstat; + t[1] = s->ang; + j = ifhitbyweapon(i); + if(j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER ) + { + j = headspritestat[6]; + while(j >= 0) + { + if(s->hitag == sprite[j].hitag && ( sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE ) ) + if(sprite[j].shade != -32) + sprite[j].shade = -32; + j = nextspritestat[j]; + } + + goto DETONATE; + } + else + { + s->cstat = t[0]; + s->ang = t[1]; + s->extra = 0; + } + } + goto BOLT; + } + + if( s->picnum == FIREEXT ) + { + j = ifhitbyweapon(i); + if( j == -1 ) goto BOLT; + + for(k=0;k<16;k++) + { + j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + sprite[j].pal = 2; + } + + spawn(i,EXPLOSION2); + spritesound(PIPEBOMB_EXPLODE,i); + spritesound(GLASS_HEAVYBREAK,i); + + if(s->hitag > 0) + { + j = headspritestat[6]; + while(j >= 0) + { + if(s->hitag == sprite[j].hitag && ( sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE ) ) + if(sprite[j].shade != -32) + sprite[j].shade = -32; + j = nextspritestat[j]; + } + + x = s->extra; + spawn(i,EXPLOSION2); + hitradius( i, pipebombblastradius,x>>2, x-(x>>1),x-(x>>2), x); + spritesound(PIPEBOMB_EXPLODE,i); + + goto DETONATE; + } + else + { + hitradius(i,seenineblastradius,10,15,20,25); + KILLIT(i); + } + goto BOLT; + } + + if(s->picnum == OOZFILTER || s->picnum == SEENINE || s->picnum == SEENINEDEAD || s->picnum == (SEENINEDEAD+1) ) + { + if(s->shade != -32 && s->shade != -33) + { + if(s->xrepeat) + j = (ifhitbyweapon(i) >= 0); + else + j = 0; + + if( j || s->shade == -31 ) + { + if(j) s->lotag = 0; + + t[3] = 1; + + j = headspritestat[6]; + while(j >= 0) + { + if(s->hitag == sprite[j].hitag && ( sprite[j].picnum == SEENINE || sprite[j].picnum == OOZFILTER ) ) + sprite[j].shade = -32; + j = nextspritestat[j]; + } + } + } + else + { + if(s->shade == -32) + { + if(s->lotag > 0) + { + s->lotag-=3; + if(s->lotag <= 0) s->lotag = -99; + } + else + s->shade = -33; + } + else + { + if( s->xrepeat > 0 ) + { + T3++; + if(T3 == 3) + { + if( s->picnum == OOZFILTER ) + { + T3 = 0; + goto DETONATE; + } + if( s->picnum != (SEENINEDEAD+1) ) + { + T3 = 0; + + if(s->picnum == SEENINEDEAD) s->picnum++; + else if(s->picnum == SEENINE) + s->picnum = SEENINEDEAD; + } + else goto DETONATE; + } + goto BOLT; + } + +DETONATE: + + earthquaketime = 16; + + j = headspritestat[3]; + while(j >= 0) + { + if( s->hitag == sprite[j].hitag ) + { + if(sprite[j].lotag == 13) + { + if( hittype[j].temp_data[2] == 0 ) + hittype[j].temp_data[2] = 1; + } + else if(sprite[j].lotag == 8) + hittype[j].temp_data[4] = 1; + else if(sprite[j].lotag == 18) + { + if(hittype[j].temp_data[0] == 0) + hittype[j].temp_data[0] = 1; + } + else if(sprite[j].lotag == 21) + hittype[j].temp_data[0] = 1; + } + j = nextspritestat[j]; + } + + s->z -= (32<<8); + + if( ( t[3] == 1 && s->xrepeat ) || s->lotag == -99 ) + { + x = s->extra; + spawn(i,EXPLOSION2); + hitradius( i,seenineblastradius,x>>2, x-(x>>1),x-(x>>2), x); + spritesound(PIPEBOMB_EXPLODE,i); + } + + if(s->xrepeat) + for(x=0;x<8;x++) RANDOMSCRAP; + + KILLIT(i); + } + } + goto BOLT; + } + + if(s->picnum == MASTERSWITCH) + { + if(s->yvel == 1) + { + s->hitag--; + if(s->hitag <= 0) + { + operatesectors(sect,i); + + j = headspritesect[sect]; + while(j >= 0) + { + if(sprite[j].statnum == 3) + { + switch(sprite[j].lotag) + { + case 2: + case 21: + case 31: + case 32: + case 36: + hittype[j].temp_data[0] = 1; + break; + case 3: + hittype[j].temp_data[4] = 1; + break; + } + } + else if(sprite[j].statnum == 6) + { + switch(dynamictostatic[sprite[j].picnum]) + { + case SEENINE__STATIC: + case OOZFILTER__STATIC: + sprite[j].shade = -31; + break; + } + } + j = nextspritesect[j]; + } + KILLIT(i); + } + } + goto BOLT; + } + switchpicnum = s->picnum; + if ((s->picnum > SIDEBOLT1) && (s->picnum <= SIDEBOLT1+3)) { + switchpicnum = SIDEBOLT1; + } + if ((s->picnum > BOLT1) && (s->picnum <= BOLT1+3)) { + switchpicnum = BOLT1; + } + + switch(dynamictostatic[switchpicnum]) + { + case VIEWSCREEN__STATIC: + case VIEWSCREEN2__STATIC: + + if(s->xrepeat == 0) KILLIT(i); + + p = findplayer(s, &x); + + if( x < 2048 ) + { + if( SP == 1 ) + camsprite = i; + } + else if( camsprite != -1 && T1 == 1) + { + camsprite = -1; + T1 = 0; + //loadtile(s->picnum); + //invalidatetile(s->picnum,-1,255); + walock[TILE_VIEWSCR] = 199; + } + + goto BOLT; + + case TRASH__STATIC: + + if(s->xvel == 0) s->xvel = 1; + IFMOVING + { + makeitfall(i); + if(TRAND&1) s->zvel -= 256; + if( klabs(s->xvel) < 48 ) + s->xvel += (TRAND&3); + } + else KILLIT(i); + break; + + case SIDEBOLT1__STATIC: + // case SIDEBOLT1+1: + // case SIDEBOLT1+2: + // case SIDEBOLT1+3: + p = findplayer(s, &x); + if( x > 20480 ) goto BOLT; + +CLEAR_THE_BOLT2: + if(t[2]) + { + t[2]--; + goto BOLT; + } + if( (s->xrepeat|s->yrepeat) == 0 ) + { + s->xrepeat=t[0]; + s->yrepeat=t[1]; + } + if( (TRAND&8) == 0 ) + { + t[0]=s->xrepeat; + t[1]=s->yrepeat; + t[2] = global_random&4; + s->xrepeat=s->yrepeat=0; + goto CLEAR_THE_BOLT2; + } + s->picnum++; + + if(l&1) s->cstat ^= 2; + + if( (TRAND&1) && sector[sect].floorpicnum == HURTRAIL ) + spritesound(SHORT_CIRCUIT,i); + + if(s->picnum == SIDEBOLT1+4) s->picnum = SIDEBOLT1; + + goto BOLT; + + case BOLT1__STATIC: + // case BOLT1+1: + // case BOLT1+2: + // case BOLT1+3: + p = findplayer(s, &x); + if( x > 20480 ) goto BOLT; + + if( t[3] == 0 ) + t[3]=sector[sect].floorshade; + +CLEAR_THE_BOLT: + if(t[2]) + { + t[2]--; + sector[sect].floorshade = 20; + sector[sect].ceilingshade = 20; + goto BOLT; + } + if( (s->xrepeat|s->yrepeat) == 0 ) + { + s->xrepeat=t[0]; + s->yrepeat=t[1]; + } + else if( (TRAND&8) == 0 ) + { + t[0]=s->xrepeat; + t[1]=s->yrepeat; + t[2] = global_random&4; + s->xrepeat=s->yrepeat=0; + goto CLEAR_THE_BOLT; + } + s->picnum++; + + l = global_random&7; + s->xrepeat=l+8; + + if(l&1) s->cstat ^= 2; + + if( s->picnum == (BOLT1+1) && (TRAND&7) == 0 && sector[sect].floorpicnum == HURTRAIL ) + spritesound(SHORT_CIRCUIT,i); + + if(s->picnum==BOLT1+4) s->picnum=BOLT1; + + if(s->picnum&1) + { + sector[sect].floorshade = 0; + sector[sect].ceilingshade = 0; + } + else + { + sector[sect].floorshade = 20; + sector[sect].ceilingshade = 20; + } + goto BOLT; + + case WATERDRIP__STATIC: + + if( t[1] ) + { + t[1]--; + if(t[1] == 0) + s->cstat &= 32767; + } + else + { + makeitfall(i); + ssp(i,CLIPMASK0); + if(s->xvel > 0) s->xvel -= 2; + + if(s->zvel == 0) + { + s->cstat |= 32768; + + if(s->pal != 2 && s->hitag == 0) + spritesound(SOMETHING_DRIPPING,i); + + if(sprite[s->owner].picnum != WATERDRIP) + { + KILLIT(i); + } + else + { + hittype[i].bposz = s->z = t[0]; + t[1] = 48+(TRAND&31); + } + } + } + + + goto BOLT; + + case DOORSHOCK__STATIC: + j = klabs(sector[sect].ceilingz-sector[sect].floorz)>>9; + s->yrepeat = j+4; + s->xrepeat = 16; + s->z = sector[sect].floorz; + goto BOLT; + + case TOUCHPLATE__STATIC: + if( t[1] == 1 && s->hitag >= 0) //Move the sector floor + { + x = sector[sect].floorz; + + if(t[3] == 1) + { + if(x >= t[2]) + { + sector[sect].floorz = x; + t[1] = 0; + } + else + { + sector[sect].floorz += sector[sect].extra; + p = checkcursectnums(sect); + if(p >= 0) ps[p].posz += sector[sect].extra; + } + } + else + { + if(x <= s->z) + { + sector[sect].floorz = s->z; + t[1] = 0; + } + else + { + sector[sect].floorz -= sector[sect].extra; + p = checkcursectnums(sect); + if(p >= 0) + ps[p].posz -= sector[sect].extra; + } + } + goto BOLT; + } + + if(t[5] == 1) goto BOLT; + + p = checkcursectnums(sect); + if( p >= 0 && ( ps[p].on_ground || s->ang == 512) ) + { + if( t[0] == 0 && !check_activator_motion(s->lotag) ) + { + t[0] = 1; + t[1] = 1; + t[3] = !t[3]; + operatemasterswitches(s->lotag); + operateactivators(s->lotag,p); + if(s->hitag > 0) + { + s->hitag--; + if(s->hitag == 0) t[5] = 1; + } + } + } + else t[0] = 0; + + if(t[1] == 1) + { + j = headspritestat[6]; + while(j >= 0) + { + if(j != i && sprite[j].picnum == TOUCHPLATE && sprite[j].lotag == s->lotag) + { + hittype[j].temp_data[1] = 1; + hittype[j].temp_data[3] = t[3]; + } + j = nextspritestat[j]; + } + } + goto BOLT; + + case CANWITHSOMETHING__STATIC: + case CANWITHSOMETHING2__STATIC: + case CANWITHSOMETHING3__STATIC: + case CANWITHSOMETHING4__STATIC: + makeitfall(i); + IFHIT + { + spritesound(VENT_BUST,i); + for(j=0;j<10;j++) + RANDOMSCRAP; + + if(s->lotag) spawn(i,s->lotag); + + KILLIT(i); + } + goto BOLT; + + case EXPLODINGBARREL__STATIC: + case WOODENHORSE__STATIC: + case HORSEONSIDE__STATIC: + case FLOORFLAME__STATIC: + case FIREBARREL__STATIC: + case FIREVASE__STATIC: + case NUKEBARREL__STATIC: + case NUKEBARRELDENTED__STATIC: + case NUKEBARRELLEAKED__STATIC: + case TOILETWATER__STATIC: + case RUBBERCAN__STATIC: + case STEAM__STATIC: + case CEILINGSTEAM__STATIC: + p = findplayer(s, &x); + execute(i,p,x); + goto BOLT; + case WATERBUBBLEMAKER__STATIC: + p = findplayer(s, &x); + execute(i,p,x); + goto BOLT; + } + +BOLT: + i = nexti; + } +} + +void bounce(short i) +{ + long k, l, daang, dax, day, daz, xvect, yvect, zvect; + short hitsect; + spritetype *s = &sprite[i]; + + xvect = mulscale10(s->xvel,sintable[(s->ang+512)&2047]); + yvect = mulscale10(s->xvel,sintable[s->ang&2047]); + zvect = s->zvel; + + hitsect = s->sectnum; + + k = sector[hitsect].wallptr; l = wall[k].point2; + daang = getangle(wall[l].x-wall[k].x,wall[l].y-wall[k].y); + + if ( s->z < (hittype[i].floorz+hittype[i].ceilingz)>>1) + k = sector[hitsect].ceilingheinum; + else + k = sector[hitsect].floorheinum; + + dax = mulscale14(k,sintable[(daang)&2047]); + day = mulscale14(k,sintable[(daang+1536)&2047]); + daz = 4096; + + k = xvect*dax+yvect*day+zvect*daz; + l = dax*dax+day*day+daz*daz; + if ((klabs(k)>>14) < l) + { + k = divscale17(k,l); + xvect -= mulscale16(dax,k); + yvect -= mulscale16(day,k); + zvect -= mulscale16(daz,k); + } + + s->zvel = zvect; + s->xvel = ksqrt(dmulscale8(xvect,xvect,yvect,yvect)); + s->ang = getangle(xvect,yvect); +} + +void moveweapons(void) +{ + short i, j=0, k, f, nexti, p, q, tempsect; + long dax,day,daz, x, l, ll, x1, y1; + unsigned long qq; + spritetype *s; + + i = headspritestat[4]; + while(i >= 0) + { + nexti = nextspritestat[i]; + s = &sprite[i]; + + if(s->sectnum < 0) KILLIT(i); + + hittype[i].bposx = s->x; + hittype[i].bposy = s->y; + hittype[i].bposz = s->z; + // here + + if(checkspriteflags(i,SPRITE_FLAG_PROJECTILE)) + { + /* Custom projectiles. This is a big hack. */ + + if (thisprojectile[i].pal >= 0) + s->pal=thisprojectile[i].pal; + + if (thisprojectile[i].workslike & PROJECTILE_FLAG_KNEE) + KILLIT(i); + + if (thisprojectile[i].trail > -1) + { + for(f=0;f<=thisprojectile[i].tnum;f++) + { + j = spawn(i,thisprojectile[i].trail); + if (thisprojectile[i].toffset != 0) + sprite[j].z += (thisprojectile[i].toffset<<8); + else + sprite[j].z += (1<<8); + if (thisprojectile[i].txrepeat >= 0) sprite[j].xrepeat=thisprojectile[i].txrepeat; + if (thisprojectile[i].tyrepeat >= 0) sprite[j].yrepeat=thisprojectile[i].tyrepeat; + + } + } + + if (thisprojectile[i].workslike & PROJECTILE_FLAG_RPG) + { + // if (thisprojectile[i].workslike & COOLEXPLOSION1) + // if( Sound[WIERDSHOT_FLY].num == 0 ) + // spritesound(WIERDSHOT_FLY,i); + + p = -1; + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_COOLEXPLOSION1) + { + s->shade++; + if(s->shade >= 40) KILLIT(i); + } + + if(sector[s->sectnum].lotag == 2) + { + k = s->xvel>>1; + ll = s->zvel>>1; + } + else + { + k = s->xvel; + ll = s->zvel; + } + + if (thisprojectile[i].drop) s->zvel=s->zvel-thisprojectile[i].drop; + + dax = s->x; day = s->y; daz = s->z; + + if(thisprojectile[i].range > 0) + { + if (!(hittype[i].temp_data[8])) + hittype[i].temp_data[8] = 1; + else + hittype[i].temp_data[8]++; + + if(hittype[i].temp_data[8] > thisprojectile[i].range) + { + if (thisprojectile[i].workslike & PROJECTILE_FLAG_EXPLODEONTIMER) + { + if (thisprojectile[i].spawns >= 0 ) + { + k = spawn(i,thisprojectile[i].spawns); + sprite[k].x = dax; + sprite[k].y = day; + sprite[k].z = daz; + + if (thisprojectile[i].sxrepeat > 4) sprite[k].xrepeat=thisprojectile[i].sxrepeat; + if (thisprojectile[i].syrepeat > 4) sprite[k].yrepeat=thisprojectile[i].syrepeat; + } + if (thisprojectile[i].isound > -1) + spritesound(thisprojectile[i].isound,i); + + s->extra=thisprojectile[i].extra; + + if(thisprojectile[i].extra_rand > 0) + s->extra += (TRAND&thisprojectile[i].extra_rand); + + x = s->extra; + hitradius( i,thisprojectile[i].hitradius, x>>2,x>>1,x-(x>>2),x); + } + KILLIT(i); + } + } + + if (thisprojectile[i].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS) + { + /* if(s->yvel < 1 || s->extra < 2 || (s->xvel|s->zvel) == 0) + Did this cause the bug with prematurely exploding projectiles? */ + if (s->yvel < 1) + { + + if (thisprojectile[i].spawns >= 0 ) + { + k = spawn(i,thisprojectile[i].spawns); + sprite[k].x = dax; + sprite[k].y = day; + sprite[k].z = daz; + + if (thisprojectile[i].sxrepeat > 4) sprite[k].xrepeat=thisprojectile[i].sxrepeat; + if (thisprojectile[i].syrepeat > 4) sprite[k].yrepeat=thisprojectile[i].syrepeat; + } + if (thisprojectile[i].isound > -1) + spritesound(thisprojectile[i].isound,i); + + s->extra=thisprojectile[i].extra; + + if(thisprojectile[i].extra_rand > 0) + s->extra += (TRAND&thisprojectile[i].extra_rand); + + x = s->extra; + hitradius( i,thisprojectile[i].hitradius, x>>2,x>>1,x-(x>>2),x); + + KILLIT(i); + } + + } + + + getglobalz(i); + qq = CLIPMASK1; + + for(f=1;f<=thisprojectile[i].velmult;f++) + j = movesprite(i, + (k*(sintable[(s->ang+512)&2047]))>>14, + (k*(sintable[s->ang&2047]))>>14,ll,qq); + + + if(!(thisprojectile[i].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS) && s->yvel >= 0) + if( FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256 ) + j = 49152|s->yvel; + + if(s->sectnum < 0) { KILLIT(i); } + + if( (j&49152) != 49152) + if(!(thisprojectile[i].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS)) + { + if(s->z < hittype[i].ceilingz) + { + j = 16384|(s->sectnum); + s->zvel = -1; + } + else + if( ( s->z > hittype[i].floorz && sector[s->sectnum].lotag != 1 ) || + ( s->z > hittype[i].floorz+(16<<8) && sector[s->sectnum].lotag == 1 ) ) + { + j = 16384|(s->sectnum); + if(sector[s->sectnum].lotag != 1) + s->zvel = 1; + } + } + + if(thisprojectile[i].workslike & 8192) + { + for(k=-3;k<2;k++) + { + + x = EGS(s->sectnum, + s->x+((k*sintable[(s->ang+512)&2047])>>9), + s->y+((k*sintable[s->ang&2047])>>9), + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/24)),s->picnum,-40+(k<<2), // FIRELASER + s->xrepeat,s->yrepeat,0,0,0,s->owner,5); + + sprite[x].cstat = 128; + sprite[x].pal = s->pal; + + } + } + else if(thisprojectile[i].workslike & PROJECTILE_FLAG_SPIT) if(s->zvel < 6144) + s->zvel += gc-112; + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_WATERBUBBLES && sector[s->sectnum].lotag == 2 && rnd(140)) + spawn(i,WATERBUBBLE); + + if( j != 0 ) + { + if(thisprojectile[i].workslike & PROJECTILE_FLAG_COOLEXPLOSION1) + { + /* if( (j&49152) == 49152 && sprite[j&(MAXSPRITES-1)].picnum != APLAYER) + goto BOLT; */ + s->xvel = 0; + s->zvel = 0; + } + + if( (j&49152) == 49152 ) + { + j &= (MAXSPRITES-1); + + /* if(thisprojectile[i].workslike & PROJECTILE_FLAG_FREEZEBLAST && sprite[j].pal == 1 ) + if( badguy(&sprite[j]) || sprite[j].picnum == APLAYER ) + { + j = spawn(i,TRANSPORTERSTAR); + sprite[j].pal = 1; + sprite[j].xrepeat = 32; + sprite[j].yrepeat = 32; + + KILLIT(i); + }*/ + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_NOENEMYHITS) + { + if( wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR ) + s->yvel--; + + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + s->ang = ((k<<1) - s->ang)&2047; + + if (thisprojectile[i].bsound > -1) + spritesound(thisprojectile[i].bsound,i); + + if (thisprojectile[i].workslike & PROJECTILE_FLAG_LOSESVELOCITY) + { + s->xvel=s->xvel>>1; + s->zvel=s->zvel>>1; + } + goto BOLT; + } + + checkhitsprite(j,i); + + if(sprite[j].picnum == APLAYER) + { + p = sprite[j].yvel; + spritesound(PISTOL_BODYHIT,j); + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_SPIT) + { + ps[p].horiz += 32; + ps[p].return_to_center = 8; + + if(ps[p].loogcnt == 0) + { + if(Sound[DUKE_LONGTERM_PAIN].num < 1) + spritesound(DUKE_LONGTERM_PAIN,ps[p].i); + + j = 3+(TRAND&3); + ps[p].numloogs = j; + ps[p].loogcnt = 24*4; + for(x=0;x < j;x++) + { + ps[p].loogiex[x] = TRAND%xdim; + ps[p].loogiey[x] = TRAND%ydim; + } + } + } + } + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_RPG_IMPACT) + { + + hittype[j].owner = s->owner; + hittype[j].picnum = s->picnum; + hittype[j].extra = thisprojectile[i].extra; + + if (thisprojectile[i].spawns >= 0 ) + { + k = spawn(i,thisprojectile[i].spawns); + sprite[k].x = dax; + sprite[k].y = day; + sprite[k].z = daz; + + if (thisprojectile[i].sxrepeat > 4) sprite[k].xrepeat=thisprojectile[i].sxrepeat; + if (thisprojectile[i].syrepeat > 4) sprite[k].yrepeat=thisprojectile[i].syrepeat; + } + + if (thisprojectile[i].isound > -1) + spritesound(thisprojectile[i].isound,i); + + KILLIT(i); + + } + + } + else if( (j&49152) == 32768 ) + { + j &= (MAXWALLS-1); + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_BOUNCESOFFMIRRORS && ( wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR ) ) + { + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + s->ang = ((k<<1) - s->ang)&2047; + s->owner = i; + spawn(i,TRANSPORTERSTAR); + goto BOLT; + } + else + { + setsprite(i,dax,day,daz); + checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS) + { + if( wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR ) + s->yvel--; + + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + s->ang = ((k<<1) - s->ang)&2047; + + if (thisprojectile[i].bsound > -1) + spritesound(thisprojectile[i].bsound,i); + + if (thisprojectile[i].workslike & PROJECTILE_FLAG_LOSESVELOCITY) + { + s->xvel=s->xvel>>1; + s->zvel=s->zvel>>1; + } + goto BOLT; + } + } + } + else if( (j&49152) == 16384) + { + setsprite(i,dax,day,daz); + + if(s->zvel < 0) + { + if( sector[s->sectnum].ceilingstat&1 ) + if(sector[s->sectnum].ceilingpal == 0) + KILLIT(i); + + checkhitceiling(s->sectnum); + } + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS) + { + bounce(i); + ssp(i,qq); + + /* if(s->xrepeat > 8) + s->xrepeat -= 2; + if(s->yrepeat > 8) + s->yrepeat -= 2;*/ + s->yvel--; + + if (thisprojectile[i].bsound > -1) + spritesound(thisprojectile[i].bsound,i); + + if (thisprojectile[i].workslike & PROJECTILE_FLAG_LOSESVELOCITY) + { + s->xvel=s->xvel>>1; + s->zvel=s->zvel>>1; + } + + goto BOLT; + } + } + + + if(thisprojectile[i].workslike & RPG && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) + spawn(i,WATERBUBBLE); + + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_RPG) + { + if (thisprojectile[i].spawns > 0) + { + k = spawn(i,thisprojectile[i].spawns); + sprite[k].x = dax; + sprite[k].y = day; + sprite[k].z = daz; + + if (thisprojectile[i].sxrepeat > 4) sprite[k].xrepeat=thisprojectile[i].sxrepeat; + if (thisprojectile[i].syrepeat > 4) sprite[k].yrepeat=thisprojectile[i].syrepeat; + } + /* if(s->xrepeat < 10) + { + sprite[k].xrepeat = 6; + sprite[k].yrepeat = 6; + }*/ + /* else if( (j&49152) == 16384) + { + if( s->zvel > 0) + spawn(i,EXPLOSION2BOT); + else + { + sprite[k].cstat |= 8; + sprite[k].z += (48<<8); + } + } + */ + } + + + if (thisprojectile[i].workslike & PROJECTILE_FLAG_BULLET) + { + p = findplayer(s,&x); + execute(i,p,x); + goto BOLT; + } + + + if(thisprojectile[i].workslike & PROJECTILE_FLAG_RPG) + { + if (thisprojectile[i].isound > -1) + spritesound(thisprojectile[i].isound,i); + + /* if(s->xrepeat >= 10) + {*/ + s->extra=thisprojectile[i].extra; + if(thisprojectile[i].extra_rand > 0) + s->extra += (TRAND&thisprojectile[i].extra_rand); + + x = s->extra; + hitradius( i,thisprojectile[i].hitradius, x>>2,x>>1,x-(x>>2),x); + /* } + else + { + x = s->extra+(global_random&3); + hitradius( i,(thisprojectile[i].hitradius>>1),x>>2,x>>1,x-(x>>2),x); + }*/ + // if (!(thisprojectile[i].workslike & PROJECTILE_FLAG_COOLEXPLOSION1)) + KILLIT(i); + } + } + + + goto BOLT; + + + } + } + else + + { + + // here + switch(dynamictostatic[s->picnum]) + { + case RADIUSEXPLOSION__STATIC: + case KNEE__STATIC: + KILLIT(i); + case TONGUE__STATIC: + T1 = sintable[(T2)&2047]>>9; + T2 += 32; + if(T2 > 2047) KILLIT(i); + + if(sprite[s->owner].statnum == MAXSTATUS) + if(badguy(&sprite[s->owner]) == 0) + KILLIT(i); + + s->ang = sprite[s->owner].ang; + s->x = sprite[s->owner].x; + s->y = sprite[s->owner].y; + if(sprite[s->owner].picnum == APLAYER) + s->z = sprite[s->owner].z-(34<<8); + for(k=0;ksectnum, + s->x+((k*sintable[(s->ang+512)&2047])>>9), + s->y+((k*sintable[s->ang&2047])>>9), + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),TONGUE,-40+(k<<1), + 8,8,0,0,0,i,5); + sprite[q].cstat = 128; + sprite[q].pal = 8; + } + q = EGS(s->sectnum, + s->x+((k*sintable[(s->ang+512)&2047])>>9), + s->y+((k*sintable[s->ang&2047])>>9), + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),INNERJAW,-40, + 32,32,0,0,0,i,5); + sprite[q].cstat = 128; + if( T2 > 512 && T2 < (1024) ) + sprite[q].picnum = INNERJAW+1; + + goto BOLT; + + case FREEZEBLAST__STATIC: + if(s->yvel < 1 || s->extra < 2 || (s->xvel|s->zvel) == 0) + { + j = spawn(i,TRANSPORTERSTAR); + sprite[j].pal = 1; + sprite[j].xrepeat = 32; + sprite[j].yrepeat = 32; + KILLIT(i); + } + case SHRINKSPARK__STATIC: + case RPG__STATIC: + case FIRELASER__STATIC: + case SPIT__STATIC: + case COOLEXPLOSION1__STATIC: + + if( s->picnum == COOLEXPLOSION1 ) + if( !issoundplaying(WIERDSHOT_FLY) ) + spritesound(WIERDSHOT_FLY,i); + + p = -1; + + if(s->picnum == RPG && sector[s->sectnum].lotag == 2) + { + k = s->xvel>>1; + ll = s->zvel>>1; + } + else + { + k = s->xvel; + ll = s->zvel; + } + + dax = s->x; day = s->y; daz = s->z; + + getglobalz(i); + qq = CLIPMASK1; + + switch(dynamictostatic[s->picnum]) + { + case RPG__STATIC: + if(hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) + { + j = spawn(i,SMALLSMOKE); + sprite[j].z += (1<<8); + } + break; + } + + j = movesprite(i, + (k*(sintable[(s->ang+512)&2047]))>>14, + (k*(sintable[s->ang&2047]))>>14,ll,qq); + + if(s->picnum == RPG && s->yvel >= 0) + if( FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256 ) + j = 49152|s->yvel; + + if(s->sectnum < 0) { KILLIT(i); } + + if( (j&49152) != 49152) + if(s->picnum != FREEZEBLAST) + { + if(s->z < hittype[i].ceilingz) + { + j = 16384|(s->sectnum); + s->zvel = -1; + } + else + if( ( s->z > hittype[i].floorz && sector[s->sectnum].lotag != 1 ) || + ( s->z > hittype[i].floorz+(16<<8) && sector[s->sectnum].lotag == 1 ) ) + { + j = 16384|(s->sectnum); + if(sector[s->sectnum].lotag != 1) + s->zvel = 1; + } + } + + if(s->picnum == FIRELASER) + { + for(k=-3;k<2;k++) + { + x = EGS(s->sectnum, + s->x+((k*sintable[(s->ang+512)&2047])>>9), + s->y+((k*sintable[s->ang&2047])>>9), + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/24)),FIRELASER,-40+(k<<2), + s->xrepeat,s->yrepeat,0,0,0,s->owner,5); + + sprite[x].cstat = 128; + sprite[x].pal = s->pal; + } + } + else if(s->picnum == SPIT) if(s->zvel < 6144) + s->zvel += gc-112; + + if( j != 0 ) + { + if(s->picnum == COOLEXPLOSION1) + { + if( (j&49152) == 49152 && sprite[j&(MAXSPRITES-1)].picnum != APLAYER) + goto BOLT; + s->xvel = 0; + s->zvel = 0; + } + + if( (j&49152) == 49152 ) + { + j &= (MAXSPRITES-1); + + if(s->picnum == FREEZEBLAST && sprite[j].pal == 1 ) + if( badguy(&sprite[j]) || sprite[j].picnum == APLAYER ) + { + j = spawn(i,TRANSPORTERSTAR); + sprite[j].pal = 1; + sprite[j].xrepeat = 32; + sprite[j].yrepeat = 32; + + KILLIT(i); + } + + checkhitsprite(j,i); + + if(sprite[j].picnum == APLAYER) + { + p = sprite[j].yvel; + spritesound(PISTOL_BODYHIT,j); + + if(s->picnum == SPIT) + { + ps[p].horiz += 32; + ps[p].return_to_center = 8; + + if(ps[p].loogcnt == 0) + { + if(!isspritemakingsound(ps[p].i, DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,ps[p].i); + + j = 3+(TRAND&3); + ps[p].numloogs = j; + ps[p].loogcnt = 24*4; + for(x=0;x < j;x++) + { + ps[p].loogiex[x] = TRAND%xdim; + ps[p].loogiey[x] = TRAND%ydim; + } + } + } + } + } + else if( (j&49152) == 32768 ) + { + j &= (MAXWALLS-1); + + if(s->picnum != RPG && s->picnum != FREEZEBLAST && s->picnum != SPIT && ( wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR ) ) + { + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + s->ang = ((k<<1) - s->ang)&2047; + s->owner = i; + spawn(i,TRANSPORTERSTAR); + goto BOLT; + } + else + { + setsprite(i,dax,day,daz); + checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + + if(s->picnum == FREEZEBLAST) + { + if( wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR ) + { + s->extra >>= 1; + s->yvel--; + } + + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + s->ang = ((k<<1) - s->ang)&2047; + goto BOLT; + } + } + } + else if( (j&49152) == 16384) + { + setsprite(i,dax,day,daz); + + if(s->zvel < 0) + { + if( sector[s->sectnum].ceilingstat&1 ) + if(sector[s->sectnum].ceilingpal == 0) + KILLIT(i); + + checkhitceiling(s->sectnum); + } + + if(s->picnum == FREEZEBLAST) + { + bounce(i); + ssp(i,qq); + s->extra >>= 1; + if(s->xrepeat > 8) + s->xrepeat -= 2; + if(s->yrepeat > 8) + s->yrepeat -= 2; + s->yvel--; + goto BOLT; + } + } + + if(s->picnum != SPIT) + { + if(s->picnum == RPG) + { + k = spawn(i,EXPLOSION2); + sprite[k].x = dax; + sprite[k].y = day; + sprite[k].z = daz; + + if(s->xrepeat < 10) + { + sprite[k].xrepeat = 6; + sprite[k].yrepeat = 6; + } + else if( (j&49152) == 16384) + { + if( s->zvel > 0) + spawn(i,EXPLOSION2BOT); + else { sprite[k].cstat |= 8; sprite[k].z += (48<<8); } + } + } + else if(s->picnum == SHRINKSPARK) + { + spawn(i,SHRINKEREXPLOSION); + spritesound(SHRINKER_HIT,i); + hitradius(i,shrinkerblastradius,0,0,0,0); + } + else if( s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER) + { + k = spawn(i,EXPLOSION2); + sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat>>1; + if( (j&49152) == 16384) + { + if( s->zvel < 0) + { sprite[k].cstat |= 8; sprite[k].z += (72<<8); } + } + } + if( s->picnum == RPG ) + { + spritesound(RPG_EXPLODE,i); + + if(s->xrepeat >= 10) + { + x = s->extra; + hitradius( i,rpgblastradius, x>>2,x>>1,x-(x>>2),x); + } + else + { + x = s->extra+(global_random&3); + hitradius( i,(rpgblastradius>>1),x>>2,x>>1,x-(x>>2),x); + } + } + } + if(s->picnum != COOLEXPLOSION1) KILLIT(i); + } + if(s->picnum == COOLEXPLOSION1) + { + s->shade++; + if(s->shade >= 40) KILLIT(i); + } + else if(s->picnum == RPG && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) + spawn(i,WATERBUBBLE); + + goto BOLT; + + + case SHOTSPARK1__STATIC: + p = findplayer(s,&x); + execute(i,p,x); + goto BOLT; + } + } +BOLT: + i = nexti; + } +} + +void movetransports(void) +{ + char warpspriteto; + short i, j, k, l, p, sect, sectlotag, nexti, nextj, nextk; + long ll,onfloorz,q; + + i = headspritestat[9]; //Transporters + + while(i >= 0) + { + sect = SECT; + sectlotag = sector[sect].lotag; + + nexti = nextspritestat[i]; + + if(OW == i) + { + i = nexti; + continue; + } + + onfloorz = T5; + + if(T1 > 0) T1--; + + j = headspritesect[sect]; + while(j >= 0) + { + nextj = nextspritesect[j]; + + switch(sprite[j].statnum) + { + case 10: // Player + + if( sprite[j].owner != -1 ) + { + p = sprite[j].yvel; + + ps[p].on_warping_sector = 1; + + if( ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0 ) + { + if(ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0 ) + { + if(sprite[i].pal == 0) + { + spawn(i,TRANSPORTERBEAM); + spritesound(TELEPORTER,i); + } + + for(k=connecthead;k>=0;k=connectpoint2[k]) + if(ps[k].cursectnum == sprite[OW].sectnum) + { + ps[k].frag_ps = p; + sprite[ps[k].i].extra = 0; + } + + ps[p].ang = sprite[OW].ang; + + if(sprite[OW].owner != OW) + { + T1 = 13; + hittype[OW].temp_data[0] = 13; + ps[p].transporter_hold = 13; + } + + ps[p].bobposx = ps[p].oposx = ps[p].posx = sprite[OW].x; + ps[p].bobposy = ps[p].oposy = ps[p].posy = sprite[OW].y; + ps[p].oposz = ps[p].posz = sprite[OW].z-PHEIGHT; + + changespritesect(j,sprite[OW].sectnum); + ps[p].cursectnum = sprite[j].sectnum; + + if(sprite[i].pal == 0) + { + k = spawn(OW,TRANSPORTERBEAM); + spritesound(TELEPORTER,k); + } + + break; + } + } + else if( !(sectlotag == 1 && ps[p].on_ground == 1) ) break; + + if(onfloorz == 0 && klabs(SZ-ps[p].posz) < 6144 ) + if( (ps[p].jetpack_on == 0 ) || (ps[p].jetpack_on && (sync[p].bits&1) ) || + (ps[p].jetpack_on && (sync[p].bits&2) ) ) + { + ps[p].oposx = ps[p].posx += sprite[OW].x-SX; + ps[p].oposy = ps[p].posy += sprite[OW].y-SY; + + if( ps[p].jetpack_on && ( (sync[p].bits&1) || ps[p].jetpack_on < 11 ) ) + ps[p].posz = sprite[OW].z-6144; + else ps[p].posz = sprite[OW].z+6144; + ps[p].oposz = ps[p].posz; + + hittype[ps[p].i].bposx = ps[p].posx; + hittype[ps[p].i].bposy = ps[p].posy; + hittype[ps[p].i].bposz = ps[p].posz; + + changespritesect(j,sprite[OW].sectnum); + ps[p].cursectnum = sprite[OW].sectnum; + + break; + } + + k = 0; + + if( onfloorz && sectlotag == 1 && ps[p].on_ground && ps[p].posz > (sector[sect].floorz-1080) && ( (sync[p].bits&2) || ps[p].poszv > 2048 ) ) + // if( onfloorz && sectlotag == 1 && ps[p].posz > (sector[sect].floorz-(6<<8)) ) + { + k = 1; + if(screenpeek == p) + { + FX_StopAllSounds(); + clearsoundlocks(); + } + if(sprite[ps[p].i].extra > 0) + spritesound(DUKE_UNDERWATER,j); + ps[p].oposz = ps[p].posz = + sector[sprite[OW].sectnum].ceilingz; + + ps[p].posxv = 4096-(TRAND&8192); + ps[p].posyv = 4096-(TRAND&8192); + // ps[p].poszv += 1080; + } + + if( onfloorz && sectlotag == 2 && ps[p].posz < (sector[sect].ceilingz+1080) && ps[p].poszv == 0) + { + k = 1; + // if( sprite[j].extra <= 0) break; + if(screenpeek == p) + { + FX_StopAllSounds(); + clearsoundlocks(); + } + spritesound(DUKE_GASP,j); + + ps[p].oposz = ps[p].posz = + sector[sprite[OW].sectnum].floorz; + + ps[p].jumping_toggle = 1; + ps[p].jumping_counter = 0; + ps[p].poszv += 1024; + } + + if(k == 1) + { + ps[p].oposx = ps[p].posx += sprite[OW].x-SX; + ps[p].oposy = ps[p].posy += sprite[OW].y-SY; + + if(sprite[OW].owner != OW) + ps[p].transporter_hold = -2; + ps[p].cursectnum = sprite[OW].sectnum; + + changespritesect(j,sprite[OW].sectnum); + setsprite(ps[p].i,ps[p].posx,ps[p].posy,ps[p].posz+PHEIGHT); + + setpal(&ps[p]); + + if( (TRAND&255) < 32 ) + spawn(j,WATERSPLASH2); + + if(sectlotag == 1) + for(l = 0;l < 9;l++) + { + q = spawn(ps[p].i,WATERBUBBLE); + sprite[q].z += TRAND&16383; + } + } + } + break; + + case 1: + if ( (sprite[j].picnum == SHARK) + || (sprite[j].picnum == COMMANDER) + || (sprite[j].picnum == OCTABRAIN) + || ((sprite[j].picnum >= GREENSLIME) && (sprite[j].picnum >= GREENSLIME+7)) + ) { + if(sprite[j].extra > 0) + goto JBOLT; + } + case 4: + case 5: + case 12: + case 13: + + ll = klabs(sprite[j].zvel); + + { + warpspriteto = 0; + if( ll && sectlotag == 2 && sprite[j].z < (sector[sect].ceilingz+ll) ) + warpspriteto = 1; + + if( ll && sectlotag == 1 && sprite[j].z > (sector[sect].floorz-ll) ) + warpspriteto = 1; + + if( sectlotag == 0 && ( onfloorz || klabs(sprite[j].z-SZ) < 4096) ) + { + if( sprite[OW].owner != OW && onfloorz && T1 > 0 && sprite[j].statnum != 5 ) + { + T1++; + goto BOLT; + } + warpspriteto = 1; + } + + if (warpspriteto && checkspriteflags(j,SPRITE_FLAG_DECAL)) goto JBOLT; + + if( warpspriteto ) switch(dynamictostatic[sprite[j].picnum]) + { + case TRANSPORTERSTAR__STATIC: + case TRANSPORTERBEAM__STATIC: + case TRIPBOMB__STATIC: + case BULLETHOLE__STATIC: + case WATERSPLASH2__STATIC: + case BURNING__STATIC: + case BURNING2__STATIC: + case FIRE__STATIC: + case FIRE2__STATIC: + case TOILETWATER__STATIC: + case LASERLINE__STATIC: + goto JBOLT; + case PLAYERONWATER__STATIC: + if(sectlotag == 2) + { + sprite[j].cstat &= 32767; + break; + } + default: + if(sprite[j].statnum == 5 && !(sectlotag == 1 || sectlotag == 2) ) + break; + + case WATERBUBBLE__STATIC: + // if( rnd(192) && sprite[j].picnum == WATERBUBBLE) + // break; + + if(sectlotag > 0) + { + k = spawn(j,WATERSPLASH2); + if( sectlotag == 1 && sprite[j].statnum == 4 ) + { + sprite[k].xvel = sprite[j].xvel>>1; + sprite[k].ang = sprite[j].ang; + ssp(k,CLIPMASK0); + } + } + + switch(sectlotag) + { + case 0: + if(onfloorz) + { + if( sprite[j].statnum == 4 || ( checkcursectnums(sect) == -1 && checkcursectnums(sprite[OW].sectnum) == -1 ) ) + { + sprite[j].x += (sprite[OW].x-SX); + sprite[j].y += (sprite[OW].y-SY); + sprite[j].z -= SZ - sector[sprite[OW].sectnum].floorz; + sprite[j].ang = sprite[OW].ang; + + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + hittype[j].bposz = sprite[j].z; + + if(sprite[i].pal == 0) + { + k = spawn(i,TRANSPORTERBEAM); + spritesound(TELEPORTER,k); + + k = spawn(OW,TRANSPORTERBEAM); + spritesound(TELEPORTER,k); + } + + if( sprite[OW].owner != OW ) + { + T1 = 13; + hittype[OW].temp_data[0] = 13; + } + + changespritesect(j,sprite[OW].sectnum); + } + } + else + { + sprite[j].x += (sprite[OW].x-SX); + sprite[j].y += (sprite[OW].y-SY); + sprite[j].z = sprite[OW].z+4096; + + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + hittype[j].bposz = sprite[j].z; + + changespritesect(j,sprite[OW].sectnum); + } + break; + case 1: + sprite[j].x += (sprite[OW].x-SX); + sprite[j].y += (sprite[OW].y-SY); + sprite[j].z = sector[sprite[OW].sectnum].ceilingz+ll; + + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + hittype[j].bposz = sprite[j].z; + + changespritesect(j,sprite[OW].sectnum); + + break; + case 2: + sprite[j].x += (sprite[OW].x-SX); + sprite[j].y += (sprite[OW].y-SY); + sprite[j].z = sector[sprite[OW].sectnum].floorz-ll; + + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + hittype[j].bposz = sprite[j].z; + + changespritesect(j,sprite[OW].sectnum); + + break; + } + + break; + } + } + break; + + } +JBOLT: + j = nextj; + } +BOLT: + i = nexti; + } +} + +void moveactors(void) +{ + long x, m, l, *t; + short a, i, j, nexti, nextj, sect, p; + spritetype *s; + unsigned short k; + int switchpicnum; + + i = headspritestat[1]; + while(i >= 0) + { + nexti = nextspritestat[i]; + + s = &sprite[i]; + + sect = s->sectnum; + + if( s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS) + KILLIT(i); + + t = &hittype[i].temp_data[0]; + + hittype[i].bposx = s->x; + hittype[i].bposy = s->y; + hittype[i].bposz = s->z; + switchpicnum=s->picnum; + if ((s->picnum > GREENSLIME)&&(s->picnum <= GREENSLIME+7)) { + switchpicnum = GREENSLIME; + } + switch(dynamictostatic[switchpicnum]) + { + case DUCK__STATIC: + case TARGET__STATIC: + if(s->cstat&32) + { + t[0]++; + if(t[0] > 60) + { + t[0] = 0; + s->cstat = 128+257+16; + s->extra = 1; + } + } + else + { + j = ifhitbyweapon(i); + if( j >= 0 ) + { + s->cstat = 32+128; + k = 1; + + j = headspritestat[1]; + while(j >= 0) + { + if( sprite[j].lotag == s->lotag && + sprite[j].picnum == s->picnum ) + { + if( ( sprite[j].hitag && !(sprite[j].cstat&32) ) || + ( !sprite[j].hitag && (sprite[j].cstat&32) ) + ) + { + k = 0; + break; + } + } + + j = nextspritestat[j]; + } + + if(k == 1) + { + operateactivators(s->lotag,-1); + operateforcefields(i,s->lotag); + operatemasterswitches(s->lotag); + } + } + } + goto BOLT; + + case RESPAWNMARKERRED__STATIC: + case RESPAWNMARKERYELLOW__STATIC: + case RESPAWNMARKERGREEN__STATIC: + T1++; + if(T1 > respawnitemtime) + { + KILLIT(i); + } + if( T1 >= (respawnitemtime>>1) && T1 < ((respawnitemtime>>1)+(respawnitemtime>>2)) ) + PN = RESPAWNMARKERYELLOW; + else if( T1 > ((respawnitemtime>>1)+(respawnitemtime>>2)) ) + PN = RESPAWNMARKERGREEN; + makeitfall(i); + break; + + case HELECOPT__STATIC: + case DUKECAR__STATIC: + + s->z += s->zvel; + t[0]++; + + if(t[0] == 4) spritesound(WAR_AMBIENCE2,i); + + if( t[0] > (26*8) ) + { + sound(RPG_EXPLODE); + for(j=0;j<32;j++) RANDOMSCRAP; + earthquaketime = 16; + KILLIT(i); + } + else if((t[0]&3) == 0) + spawn(i,EXPLOSION2); + ssp(i,CLIPMASK0); + break; + case RAT__STATIC: + makeitfall(i); + IFMOVING + { + if( (TRAND&255) < 3 ) spritesound(RATTY,i); + s->ang += (TRAND&31)-15+(sintable[(t[0]<<8)&2047]>>11); + } + else + { + T1++; + if(T1 > 1) { KILLIT(i); } + else s->ang = (TRAND&2047); + } + if(s->xvel < 128) + s->xvel+=2; + s->ang += (TRAND&3)-6; + break; + case QUEBALL__STATIC: + case STRIPEBALL__STATIC: + if(s->xvel) + { + j = headspritestat[0]; + while(j >= 0) + { + nextj = nextspritestat[j]; + if( sprite[j].picnum == POCKET && ldist(&sprite[j],s) < 52 ) KILLIT(i); + j = nextj; + } + + j = clipmove(&s->x,&s->y,&s->z,&s->sectnum, + (((s->xvel*(sintable[(s->ang+512)&2047]))>>14)*TICSPERFRAME)<<11, + (((s->xvel*(sintable[s->ang&2047]))>>14)*TICSPERFRAME)<<11, + 24L,(4<<8),(4<<8),CLIPMASK1); + + if(j&49152) + { + if( (j&49152) == 32768 ) + { + j &= (MAXWALLS-1); + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + s->ang = ((k<<1) - s->ang)&2047; + } + else if( (j&49152) == 49152 ) + { + j &= (MAXSPRITES-1); + checkhitsprite(i,j); + } + } + s->xvel --; + if(s->xvel < 0) s->xvel = 0; + if( s->picnum == STRIPEBALL ) + { + s->cstat = 257; + s->cstat |= 4&s->xvel; + s->cstat |= 8&s->xvel; + } + } + else + { + p = findplayer(s,&x); + + if( x < 1596) + { + + // if(s->pal == 12) + { + j = getincangle(ps[p].ang,getangle(s->x-ps[p].posx,s->y-ps[p].posy)); + if( j > -64 && j < 64 && (sync[p].bits&(1<<29)) ) + if(ps[p].toggle_key_flag == 1) + { + a = headspritestat[1]; + while(a >= 0) + { + if(sprite[a].picnum == QUEBALL || sprite[a].picnum == STRIPEBALL) + { + j = getincangle(ps[p].ang,getangle(sprite[a].x-ps[p].posx,sprite[a].y-ps[p].posy)); + if( j > -64 && j < 64 ) + { + findplayer(&sprite[a],&l); + if(x > l) break; + } + } + a = nextspritestat[a]; + } + if(a == -1) + { + if(s->pal == 12) + s->xvel = 164; + else s->xvel = 140; + s->ang = ps[p].ang; + ps[p].toggle_key_flag = 2; + } + } + } + } + if( x < 512 && s->sectnum == ps[p].cursectnum ) + { + s->ang = getangle(s->x-ps[p].posx,s->y-ps[p].posy); + s->xvel = 48; + } + } + + break; + case FORCESPHERE__STATIC: + + if(s->yvel == 0) + { + s->yvel = 1; + + for(l=512;l<(2048-512);l+= 128) + for(j=0;j<2048;j += 128) + { + k = spawn(i,FORCESPHERE); + sprite[k].cstat = 257+128; + sprite[k].clipdist = 64; + sprite[k].ang = j; + sprite[k].zvel = sintable[l&2047]>>5; + sprite[k].xvel = sintable[(l+512)&2047]>>9; + sprite[k].owner = i; + } + } + + if(t[3] > 0) + { + if(s->zvel < 6144) + s->zvel += 192; + s->z += s->zvel; + if(s->z > sector[sect].floorz) + s->z = sector[sect].floorz; + t[3]--; + if(t[3] == 0) + KILLIT(i); + } + else if(t[2] > 10) + { + j = headspritestat[5]; + while(j >= 0) + { + if(sprite[j].owner == i && sprite[j].picnum == FORCESPHERE) + hittype[j].temp_data[1] = 1+(TRAND&63); + j = nextspritestat[j]; + } + t[3] = 64; + } + + goto BOLT; + + case RECON__STATIC: + + getglobalz(i); + + if (sector[s->sectnum].ceilingstat&1) + s->shade += (sector[s->sectnum].ceilingshade-s->shade)>>1; + else s->shade += (sector[s->sectnum].floorshade-s->shade)>>1; + + if( s->z < sector[sect].ceilingz+(32<<8) ) + s->z = sector[sect].ceilingz+(32<<8); + + if( ud.multimode < 2 ) + { + if( actor_tog == 1) + { + s->cstat = (short)32768; + goto BOLT; + } + else if(actor_tog == 2) s->cstat = 257; + } + IFHIT + { + if( s->extra < 0 && t[0] != -1 ) + { + t[0] = -1; + s->extra = 0; + } + spritesound(RECO_PAIN,i); + RANDOMSCRAP; + } + + if(t[0] == -1) + { + s->z += 1024; + t[2]++; + if( (t[2]&3) == 0) spawn(i,EXPLOSION2); + getglobalz(i); + s->ang += 96; + s->xvel = 128; + j = ssp(i,CLIPMASK0); + if(j != 1 || s->z > hittype[i].floorz) + { + for(l=0;l<16;l++) + RANDOMSCRAP; + spritesound(LASERTRIP_EXPLODE,i); + spawn(i,PIGCOP); + ps[myconnectindex].actors_killed++; + KILLIT(i); + } + goto BOLT; + } + else + { + if( s->z > hittype[i].floorz-(48<<8) ) + s->z = hittype[i].floorz-(48<<8); + } + + p = findplayer(s,&x); + j = s->owner; + + // 3 = findplayerz, 4 = shoot + + if( t[0] >= 4 ) + { + t[2]++; + if( (t[2]&15) == 0 ) + { + a = s->ang; + s->ang = hittype[i].tempang; + spritesound(RECO_ATTACK,i); + shoot(i,FIRELASER); + s->ang = a; + } + if( t[2] > (26*3) || !cansee(s->x,s->y,s->z-(16<<8),s->sectnum, ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum ) ) + { + t[0] = 0; + t[2] = 0; + } + else hittype[i].tempang += + getincangle(hittype[i].tempang,getangle(ps[p].posx-s->x,ps[p].posy-s->y))/3; + } + else if(t[0] == 2 || t[0] == 3) + { + t[3] = 0; + if(s->xvel > 0) s->xvel -= 16; + else s->xvel = 0; + + if(t[0] == 2) + { + l = ps[p].posz-s->z; + if( klabs(l) < (48<<8) ) t[0] = 3; + else s->z += ksgn(ps[p].posz-s->z)<<10; + } + else + { + t[2]++; + if( t[2] > (26*3) || !cansee(s->x,s->y,s->z-(16<<8),s->sectnum, ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum ) ) + { + t[0] = 1; + t[2] = 0; + } + else if( (t[2]&15) == 0 ) + { + spritesound(RECO_ATTACK,i); + shoot(i,FIRELASER); + } + } + s->ang += getincangle(s->ang,getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>2; + } + + if( t[0] != 2 && t[0] != 3 ) + { + l = ldist(&sprite[j],s); + if(l <= 1524) + { + a = s->ang; + s->xvel >>= 1; + } + else a = getangle(sprite[j].x-s->x,sprite[j].y-s->y); + + if(t[0] == 1 || t[0] == 4) // Found a locator and going with it + { + l = dist(&sprite[j],s); + + if( l <= 1524 ) { if(t[0] == 1) t[0] = 0; else t[0] = 5; } + else + { + // Control speed here + if(l > 1524) { if( s->xvel < 256 ) s->xvel += 32; } + else + { + if(s->xvel > 0) s->xvel -= 16; + else s->xvel = 0; + } + } + + if(t[0] < 2) t[2]++; + + if( x < 6144 && t[0] < 2 && t[2] > (26*4) ) + { + t[0] = 2+(TRAND&2); + t[2] = 0; + hittype[i].tempang = s->ang; + } + } + + if(t[0] == 0 || t[0] == 5) + { + if(t[0] == 0) + t[0] = 1; + else t[0] = 4; + j = s->owner = LocateTheLocator(s->hitag,-1); + if(j == -1) + { + s->hitag = j = hittype[i].temp_data[5]; + s->owner = LocateTheLocator(j,-1); + j = s->owner; + if(j == -1) KILLIT(i); + } + else s->hitag++; + } + + t[3] = getincangle(s->ang,a); + s->ang += t[3]>>3; + + if(s->z < sprite[j].z) + s->z += 1024; + else s->z -= 1024; + } + + if(!isspritemakingsound(i,RECO_ROAM)) + spritesound(RECO_ROAM,i); + + ssp(i,CLIPMASK0); + + goto BOLT; + + case OOZ__STATIC: + case OOZ2__STATIC: + + getglobalz(i); + + j = (hittype[i].floorz-hittype[i].ceilingz)>>9; + if(j > 255) j = 255; + + x = 25-(j>>1); + if(x < 8) x = 8; + else if(x > 48) x = 48; + + s->yrepeat = j; + s->xrepeat = x; + s->z = hittype[i].floorz; + + goto BOLT; + + case GREENSLIME__STATIC: + // case GREENSLIME+1: + // case GREENSLIME+2: + // case GREENSLIME+3: + // case GREENSLIME+4: + // case GREENSLIME+5: + // case GREENSLIME+6: + // case GREENSLIME+7: + + // #ifndef VOLUMEONE + if( ud.multimode < 2 ) + { + if( actor_tog == 1) + { + s->cstat = (short)32768; + goto BOLT; + } + else if(actor_tog == 2) s->cstat = 257; + } + // #endif + + t[1]+=128; + + if(sector[sect].floorstat&1) + KILLIT(i); + + p = findplayer(s,&x); + + if(x > 20480) + { + hittype[i].timetosleep++; + if( hittype[i].timetosleep > SLEEPTIME ) + { + hittype[i].timetosleep = 0; + changespritestat(i,2); + goto BOLT; + } + } + + if(t[0] == -5) // FROZEN + { + t[3]++; + if(t[3] > 280) + { + s->pal = 0; + t[0] = 0; + goto BOLT; + } + makeitfall(i); + s->cstat = 257; + s->picnum = GREENSLIME+2; + s->extra = 1; + s->pal = 1; + IFHIT + { + if(j == FREEZEBLAST) goto BOLT; + for(j=16; j >= 0 ;j--) + { + k = EGS(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,TRAND&2047,32+(TRAND&63),1024-(TRAND&1023),i,5); + sprite[k].pal = 1; + } + spritesound(GLASS_BREAKING,i); + KILLIT(i); + } + else if(x < 1024 && ps[p].quick_kick == 0) + { + j = getincangle(ps[p].ang,getangle(SX-ps[p].posx,SY-ps[p].posy)); + if( j > -128 && j < 128 ) + ps[p].quick_kick = 14; + } + + goto BOLT; + } + + if(x < 1596) + s->cstat = 0; + else s->cstat = 257; + + if(t[0] == -4) //On the player + { + if( sprite[ps[p].i].extra < 1 ) + { + t[0] = 0; + goto BOLT; + } + + setsprite(i,s->x,s->y,s->z); + + s->ang = ps[p].ang; + + if( ( (sync[p].bits&4) || (ps[p].quick_kick > 0) ) && sprite[ps[p].i].extra > 0 ) + if( ps[p].quick_kick > 0 || ( ps[p].curr_weapon != HANDREMOTE_WEAPON && ps[p].curr_weapon != HANDBOMB_WEAPON && ps[p].curr_weapon != TRIPBOMB_WEAPON && ps[p].ammo_amount[ps[p].curr_weapon] >= 0) ) + { + for(x=0;x<8;x++) + { + j = EGS(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(s->zvel>>2),i,5); + sprite[j].pal = 6; + } + + spritesound(SLIM_DYING,i); + spritesound(SQUISHED,i); + if( (TRAND&255) < 32 ) + { + j = spawn(i,BLOODPOOL); + sprite[j].pal = 0; + } + ps[p].actors_killed ++; + t[0] = -3; + if(ps[p].somethingonplayer == i) + ps[p].somethingonplayer = -1; + KILLIT(i); + } + + s->z = ps[p].posz+ps[p].pyoff-t[2]+(8<<8); + + s->z += (100-ps[p].horiz)<<4; + + if( t[2] > 512) + t[2] -= 128; + + if( t[2] < 348) + t[2] += 128; + + if(ps[p].newowner >= 0) + { + ps[p].newowner = -1; + ps[p].posx = ps[p].oposx; + ps[p].posy = ps[p].oposy; + ps[p].posz = ps[p].oposz; + ps[p].ang = ps[p].oang; + + updatesector(ps[p].posx,ps[p].posy,&ps[p].cursectnum); + setpal(&ps[p]); + + j = headspritestat[1]; + while(j >= 0) + { + if(sprite[j].picnum==CAMERA1) sprite[j].yvel = 0; + j = nextspritestat[j]; + } + } + + if(t[3]>0) + { + short frames[] = {5,5,6,6,7,7,6,5}; + + s->picnum = GREENSLIME+frames[t[3]]; + + if( t[3] == 5 ) + { + sprite[ps[p].i].extra += -(5+(TRAND&3)); + spritesound(SLIM_ATTACK,i); + } + + if(t[3] < 7) t[3]++; + else t[3] = 0; + + } + else + { + s->picnum = GREENSLIME+5; + if(rnd(32)) + t[3] = 1; + } + + s->xrepeat = 20+(sintable[t[1]&2047]>>13); + s->yrepeat = 15+(sintable[t[1]&2047]>>13); + + s->x = ps[p].posx + (sintable[(ps[p].ang+512)&2047]>>7); + s->y = ps[p].posy + (sintable[ps[p].ang&2047]>>7); + + goto BOLT; + } + + else if(s->xvel < 64 && x < 768) + { + if(ps[p].somethingonplayer == -1) + { + ps[p].somethingonplayer = i; + if(t[0] == 3 || t[0] == 2) //Falling downward + t[2] = (12<<8); + else t[2] = -(13<<8); //Climbing up duke + t[0] = -4; + } + } + + IFHIT + { + spritesound(SLIM_DYING,i); + + ps[p].actors_killed ++; + if(ps[p].somethingonplayer == i) + ps[p].somethingonplayer = -1; + + if(j == FREEZEBLAST) + { + spritesound(SOMETHINGFROZE,i); t[0] = -5 ; t[3] = 0 ; + goto BOLT; + } + + if( (TRAND&255) < 32 ) + { + j = spawn(i,BLOODPOOL); + sprite[j].pal = 0; + } + + for(x=0;x<8;x++) + { + j = EGS(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(s->zvel>>2),i,5); + sprite[j].pal = 6; + } + t[0] = -3; + KILLIT(i); + } + // All weap + if(t[0] == -1) //Shrinking down + { + makeitfall(i); + + s->cstat &= 65535-8; + s->picnum = GREENSLIME+4; + + // if(s->yrepeat > 62) + // guts(s,JIBS6,5,myconnectindex); + + if(s->xrepeat > 32) s->xrepeat -= TRAND&7; + if(s->yrepeat > 16) s->yrepeat -= TRAND&7; + else + { + s->xrepeat = 40; + s->yrepeat = 16; + t[5] = -1; + t[0] = 0; + } + + goto BOLT; + } + else if(t[0] != -2) getglobalz(i); + + if(t[0] == -2) //On top of somebody + { + makeitfall(i); + sprite[t[5]].xvel = 0; + + l = sprite[t[5]].ang; + + s->z = sprite[t[5]].z; + s->x = sprite[t[5]].x+(sintable[(l+512)&2047]>>11); + s->y = sprite[t[5]].y+(sintable[l&2047]>>11); + + s->picnum = GREENSLIME+2+(global_random&1); + + if(s->yrepeat < 64) s->yrepeat+=2; + else + { + if(s->xrepeat < 32) s->xrepeat += 4; + else + { + t[0] = -1; + x = ldist(s,&sprite[t[5]]); + if(x < 768) { + sprite[t[5]].xrepeat = 0; + + // JBF 20041129: a slimer eating another enemy really ought + // to decrease the maximum kill count by one. + if (sprite[t[5]].extra > 0) ps[myconnectindex].max_actors_killed--; + } + } + } + + goto BOLT; + } + + //Check randomly to see of there is an actor near + if(rnd(32)) + { + j = headspritesect[sect]; + while(j>=0) + { + switch(dynamictostatic[sprite[j].picnum]) + { + case LIZTROOP__STATIC: + case LIZMAN__STATIC: + case PIGCOP__STATIC: + case NEWBEAST__STATIC: + if( ldist(s,&sprite[j]) < 768 && (klabs(s->z-sprite[j].z)<8192) ) //Gulp them + { + t[5] = j; + t[0] = -2; + t[1] = 0; + goto BOLT; + } + } + + j = nextspritesect[j]; + } + } + + //Moving on the ground or ceiling + + if(t[0] == 0 || t[0] == 2) + { + s->picnum = GREENSLIME; + + if( (TRAND&511) == 0 ) + spritesound(SLIM_ROAM,i); + + if(t[0]==2) + { + s->zvel = 0; + s->cstat &= (65535-8); + + if( (sector[sect].ceilingstat&1) || (hittype[i].ceilingz+6144) < s->z) + { + s->z += 2048; + t[0] = 3; + goto BOLT; + } + } + else + { + s->cstat |= 8; + makeitfall(i); + } + + if( everyothertime&1 ) ssp(i,CLIPMASK0); + + if(s->xvel > 96) + { + s->xvel -= 2; + goto BOLT; + } + else + { + if(s->xvel < 32) s->xvel += 4; + s->xvel = 64 - (sintable[(t[1]+512)&2047]>>9); + + s->ang += getincangle(s->ang, + getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>3; + // TJR + } + + s->xrepeat = 36 + (sintable[(t[1]+512)&2047]>>11); + s->yrepeat = 16 + (sintable[t[1]&2047]>>13); + + if(rnd(4) && (sector[sect].ceilingstat&1) == 0 && + klabs(hittype[i].floorz-hittype[i].ceilingz) + < (192<<8) ) + { + s->zvel = 0; + t[0]++; + } + + } + + if(t[0]==1) + { + s->picnum = GREENSLIME; + if(s->yrepeat < 40) s->yrepeat+=8; + if(s->xrepeat > 8) s->xrepeat-=4; + if(s->zvel > -(2048+1024)) + s->zvel -= 348; + s->z += s->zvel; + if(s->z < hittype[i].ceilingz+4096) + { + s->z = hittype[i].ceilingz+4096; + s->xvel = 0; + t[0] = 2; + } + } + + if(t[0]==3) + { + s->picnum = GREENSLIME+1; + + makeitfall(i); + + if(s->z > hittype[i].floorz-(8<<8)) + { + s->yrepeat-=4; + s->xrepeat+=2; + } + else + { + if(s->yrepeat < (40-4)) s->yrepeat+=8; + if(s->xrepeat > 8) s->xrepeat-=4; + } + + if(s->z > hittype[i].floorz-2048) + { + s->z = hittype[i].floorz-2048; + t[0] = 0; + s->xvel = 0; + } + } + goto BOLT; + + case BOUNCEMINE__STATIC: + case MORTER__STATIC: + j = spawn(i, (PLUTOPAK ? FRAMEEFFECT1 : FRAMEEFFECT1_13) ); + hittype[j].temp_data[0] = 3; + + case HEAVYHBOMB__STATIC: + + if( (s->cstat&32768) ) + { + t[2]--; + if(t[2] <= 0) + { + spritesound(TELEPORTER,i); + spawn(i,TRANSPORTERSTAR); + s->cstat = 257; + } + goto BOLT; + } + + p = findplayer(s,&x); + + if( x < 1220 ) s->cstat &= ~257; + else s->cstat |= 257; + + if(t[3] == 0 ) + { + j = ifhitbyweapon(i); + if(j >= 0) + { + t[3] = 1; + t[4] = 0; + l = 0; + s->xvel = 0; + goto DETONATEB; + } + } + + if( s->picnum != BOUNCEMINE ) + { + makeitfall(i); + + if( sector[sect].lotag != 1 && s->z >= hittype[i].floorz-(FOURSLEIGHT) && s->yvel < 3 ) + { + if( s->yvel > 0 || (s->yvel == 0 && hittype[i].floorz == sector[sect].floorz )) + spritesound(PIPEBOMB_BOUNCE,i); + s->zvel = -((4-s->yvel)<<8); + if(sector[s->sectnum].lotag== 2) + s->zvel >>= 2; + s->yvel++; + } + if( s->z < hittype[i].ceilingz ) // && sector[sect].lotag != 2 ) + { + s->z = hittype[i].ceilingz+(3<<8); + s->zvel = 0; + } + } + + j = movesprite(i, + (s->xvel*(sintable[(s->ang+512)&2047]))>>14, + (s->xvel*(sintable[s->ang&2047]))>>14, + s->zvel,CLIPMASK0); + + if(sector[SECT].lotag == 1 && s->zvel == 0) + { + s->z += (32<<8); + if(t[5] == 0) + { + t[5] = 1; + spawn(i,WATERSPLASH2); + } + } + else t[5] = 0; + + if(t[3] == 0 && ( s->picnum == BOUNCEMINE || s->picnum == MORTER ) && (j || x < 844) ) + { + t[3] = 1; + t[4] = 0; + l = 0; + s->xvel = 0; + goto DETONATEB; + } + + if(sprite[s->owner].picnum == APLAYER) + l = sprite[s->owner].yvel; + else l = -1; + + if(s->xvel > 0) + { + s->xvel -= 5; + if(sector[sect].lotag == 2) + s->xvel -= 10; + + if(s->xvel < 0) + s->xvel = 0; + if(s->xvel&8) s->cstat ^= 4; + } + + if( (j&49152) == 32768 ) + { + j &= (MAXWALLS-1); + + checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + + s->ang = ((k<<1) - s->ang)&2047; + s->xvel >>= 1; + } + + // long lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, -1); + +DETONATEB: + + // if(lPipeBombControl & PIPEBOMB_TIMER) + // { + + if( s->picnum == HEAVYHBOMB && hittype[i].temp_data[6] == 1) + { + /* if(s->extra >= 1) + { + s->extra--; + } + + if(s->extra <= 0) + s->lotag=911; + */ + + if(hittype[i].temp_data[7] >= 1) + { + hittype[i].temp_data[7]--; + } + + if(hittype[i].temp_data[7] <= 0) + { + hittype[i].temp_data[6] = 3; + // s->extra = *actorscrptr[s->picnum]; + } + } + // } + + if(( l >= 0 && ps[l].hbomb_on == 0 && hittype[i].temp_data[6] == 2) || t[3] == 1) + hittype[i].temp_data[6] = 3; + + if(hittype[i].temp_data[6] == 3) + + { + t[4]++; + + if(t[4] == 2) + { + x = s->extra; + m = 0; + switch(dynamictostatic[s->picnum]) + { + case HEAVYHBOMB__STATIC: m = pipebombblastradius;break; + case MORTER__STATIC: m = morterblastradius;break; + case BOUNCEMINE__STATIC: m = bouncemineblastradius;break; + } + + hitradius( i, m,x>>2,x>>1,x-(x>>2),x); + spawn(i,EXPLOSION2); + if( s->zvel == 0 ) + spawn(i,EXPLOSION2BOT); + spritesound(PIPEBOMB_EXPLODE,i); + for(x=0;x<8;x++) + RANDOMSCRAP; + } + + if(s->yrepeat) + { + s->yrepeat = 0; + goto BOLT; + } + + if(t[4] > 20) + { + if(s->owner != i || ud.respawn_items == 0) + { + KILLIT(i); + } + else + { + t[2] = respawnitemtime; + spawn(i,RESPAWNMARKERRED); + s->cstat = (short) 32768; + s->yrepeat = 9; + goto BOLT; + } + } + } + else if(s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0) + if( cansee(s->x,s->y,s->z-(8<<8),s->sectnum,ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum) ) + if(ps[p].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON] ) + { + if((gametype_flags[ud.coop] & GAMETYPE_FLAG_WEAPSTAY) && s->owner == i) + { + for(j=0;jpicnum) + goto BOLT; + + if(ps[p].weapreccnt < 255) + ps[p].weaprecs[ps[p].weapreccnt++] = s->picnum; + } + + addammo(HANDBOMB_WEAPON,&ps[p],1); + spritesound(DUKE_GET,ps[p].i); + + if( ps[p].gotweapon[HANDBOMB_WEAPON] == 0 || s->owner == ps[p].i ) + addweapon(&ps[p],HANDBOMB_WEAPON); + + if( sprite[s->owner].picnum != APLAYER ) + { + ps[p].pals[0] = 0; + ps[p].pals[1] = 32; + ps[p].pals[2] = 0; + ps[p].pals_time = 32; + } + + if( s->owner != i || ud.respawn_items == 0 ) + { + if(s->owner == i && (gametype_flags[ud.coop] & GAMETYPE_FLAG_WEAPSTAY)) + goto BOLT; + KILLIT(i); + } + else + { + t[2] = respawnitemtime; + spawn(i,RESPAWNMARKERRED); + s->cstat = (short) 32768; + } + } + + if(t[0] < 8) t[0]++; + goto BOLT; + + case REACTORBURNT__STATIC: + case REACTOR2BURNT__STATIC: + goto BOLT; + + case REACTOR__STATIC: + case REACTOR2__STATIC: + + if( t[4] == 1 ) + { + j = headspritesect[sect]; + while(j >= 0) + { + switch(dynamictostatic[sprite[j].picnum]) + { + case SECTOREFFECTOR__STATIC: + if(sprite[j].lotag == 1) + { + sprite[j].lotag = (short) 65535; + sprite[j].hitag = (short) 65535; + } + break; + case REACTOR__STATIC: + sprite[j].picnum = REACTORBURNT; + break; + case REACTOR2__STATIC: + sprite[j].picnum = REACTOR2BURNT; + break; + case REACTORSPARK__STATIC: + case REACTOR2SPARK__STATIC: + sprite[j].cstat = (short) 32768; + break; + } + j = nextspritesect[j]; + } + goto BOLT; + } + + if(t[1] >= 20) + { + t[4] = 1; + goto BOLT; + } + + p = findplayer(s,&x); + + t[2]++; + if( t[2] == 4 ) t[2]=0; + + if( x < 4096 ) + { + if( (TRAND&255) < 16 ) + { + if(!isspritemakingsound(ps[p].i, DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,ps[p].i); + + spritesound(SHORT_CIRCUIT,i); + + sprite[ps[p].i].extra --; + ps[p].pals_time = 32; + ps[p].pals[0] = 32; + ps[p].pals[1] = 0; + ps[p].pals[2] = 0; + } + t[0] += 128; + if( t[3] == 0 ) + t[3] = 1; + } + else t[3] = 0; + + if( t[1] ) + { + t[1]++; + + t[4] = s->z; + s->z = sector[sect].floorz-(TRAND%(sector[sect].floorz-sector[sect].ceilingz)); + + switch( t[1] ) + { + case 3: + //Turn on all of those flashing sectoreffector. + hitradius( i, 4096, + impact_damage<<2, + impact_damage<<2, + impact_damage<<2, + impact_damage<<2 ); + /* + j = headspritestat[3]; + while(j>=0) + { + if( sprite[j].lotag == 3 ) + hittype[j].temp_data[4]=1; + else if(sprite[j].lotag == 12) + { + hittype[j].temp_data[4] = 1; + sprite[j].lotag = 3; + sprite[j].owner = 0; + hittype[j].temp_data[0] = s->shade; + } + j = nextspritestat[j]; + } + */ + j = headspritestat[6]; + while(j >= 0) + { + if(sprite[j].picnum == MASTERSWITCH) + if(sprite[j].hitag == s->hitag) + if(sprite[j].yvel == 0) + sprite[j].yvel = 1; + j = nextspritestat[j]; + } + break; + + case 4: + case 7: + case 10: + case 15: + j = headspritesect[sect]; + while(j >= 0) + { + l = nextspritesect[j]; + + if(j != i) + { + deletesprite(j); + break; + } + j = l; + } + break; + } + for(x=0;x<16;x++) + RANDOMSCRAP; + + s->z = t[4]; + t[4] = 0; + + } + else + { + IFHIT + { + for(x=0;x<32;x++) + RANDOMSCRAP; + if(s->extra < 0) + t[1] = 1; + } + } + goto BOLT; + + case CAMERA1__STATIC: + + if( t[0] == 0 ) + { + t[1]+=8; + if(camerashitable) + { + IFHIT + { + t[0] = 1; // static + s->cstat = (short)32768; + for(x=0;x<5;x++) RANDOMSCRAP; + goto BOLT; + } + } + + if(s->hitag > 0) + { + if(t[1]hitag) + s->ang+=8; + else if(t[1]<(s->hitag*3)) + s->ang-=8; + else if(t[1] < (s->hitag<<2) ) + s->ang+=8; + else + { + t[1]=8; + s->ang+=16; + } + } + } + goto BOLT; + } + + + // #ifndef VOLOMEONE + if( ud.multimode < 2 && badguy(s) ) + { + if( actor_tog == 1) + { + s->cstat = (short)32768; + goto BOLT; + } + else if(actor_tog == 2) s->cstat = 257; + } + // #endif + + p = findplayer(s,&x); + + execute(i,p,x); + +BOLT: + + i = nexti; + } + +} + +void moveexplosions(void) // STATNUM 5 +{ + short i, j, k, nexti, sect, p; + long l, x, *t; + spritetype *s; + int switchpicnum; + + i = headspritestat[5]; + while(i >= 0) + { + nexti = nextspritestat[i]; + + t = &hittype[i].temp_data[0]; + s = &sprite[i]; + sect = s->sectnum; + + if( sect < 0 || s->xrepeat == 0 ) KILLIT(i); + + hittype[i].bposx = s->x; + hittype[i].bposy = s->y; + hittype[i].bposz = s->z; + switchpicnum = s->picnum; + if ((s->picnum > NUKEBUTTON)&&(s->picnum <= NUKEBUTTON+3)) { + switchpicnum = NUKEBUTTON; + } + if ((s->picnum > GLASSPIECES)&&(s->picnum <= GLASSPIECES+2)) { + switchpicnum = GLASSPIECES; + } + if (s->picnum ==INNERJAW+1) { + switchpicnum--; + } + if ( (s->picnum == MONEY+1) || (s->picnum == MAIL+1) || (s->picnum == PAPER+1) ) + hittype[i].floorz = s->z = getflorzofslope(s->sectnum,s->x,s->y); + else switch(dynamictostatic[switchpicnum]) + { + case NEON1__STATIC: + case NEON2__STATIC: + case NEON3__STATIC: + case NEON4__STATIC: + case NEON5__STATIC: + case NEON6__STATIC: + + if( (global_random/(s->lotag+1)&31) > 4) s->shade = -127; + else s->shade = 127; + goto BOLT; + + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + + if( t[0] == 7*26 ) goto BOLT; + s->z += 16+(TRAND&15); + t[0]++; + if( (t[0]%9) == 0 ) s->yrepeat++; + goto BOLT; + + case NUKEBUTTON__STATIC: + // case NUKEBUTTON+1: + // case NUKEBUTTON+2: + // case NUKEBUTTON+3: + + if(t[0]) + { + t[0]++; + if(t[0] == 8) s->picnum = NUKEBUTTON+1; + else if(t[0] == 16) + { + s->picnum = NUKEBUTTON+2; + ps[sprite[s->owner].yvel].fist_incs = 1; + } + if( ps[sprite[s->owner].yvel].fist_incs == 26 ) + s->picnum = NUKEBUTTON+3; + } + goto BOLT; + + case FORCESPHERE__STATIC: + + l = s->xrepeat; + if(t[1] > 0) + { + t[1]--; + if(t[1] == 0) + { + KILLIT(i); + } + } + if(hittype[s->owner].temp_data[1] == 0) + { + if(t[0] < 64) + { + t[0]++; + l += 3; + } + } + else + if(t[0] > 64) + { + t[0]--; + l -= 3; + } + + s->x = sprite[s->owner].x; + s->y = sprite[s->owner].y; + s->z = sprite[s->owner].z; + s->ang += hittype[s->owner].temp_data[0]; + + if(l > 64) l = 64; + else if(l < 1) l = 1; + + s->xrepeat = l; + s->yrepeat = l; + s->shade = (l>>1)-48; + + for(j=t[0];j > 0;j--) + ssp(i,CLIPMASK0); + goto BOLT; + case WATERSPLASH2__STATIC: + + t[0]++; + if(t[0] == 1 ) + { + if(sector[sect].lotag != 1 && sector[sect].lotag != 2) + KILLIT(i); + /* else + { + l = getflorzofslope(sect,s->x,s->y)-s->z; + if( l > (16<<8) ) KILLIT(i); + } + else */ if (!issoundplaying(ITEM_SPLASH)) + spritesound(ITEM_SPLASH,i); + } + if(t[0] == 3) + { + t[0] = 0; + t[1]++; + } + if(t[1] == 5) + deletesprite(i); + goto BOLT; + case FRAMEEFFECT1_13__STATIC: + if (PLUTOPAK) goto BOLT; // JBF: ideally this should never happen... + + case FRAMEEFFECT1__STATIC: + + if(s->owner >= 0) + { + t[0]++; + + if( t[0] > 7 ) + { + KILLIT(i); + } + else if( t[0] > 4 ) + s->cstat |= 512+2; + else if( t[0] > 2 ) + s->cstat |= 2; + s->xoffset = sprite[s->owner].xoffset; + s->yoffset = sprite[s->owner].yoffset; + } + goto BOLT; + case INNERJAW__STATIC: + // case INNERJAW+1: + + p = findplayer(s,&x); + if(x < 512) + { + ps[p].pals_time = 32; + ps[p].pals[0] = 32; + ps[p].pals[1] = 0; + ps[p].pals[2] = 0; + sprite[ps[p].i].extra -= 4; + } + + case FIRELASER__STATIC: + if(s->extra != 999) + s->extra = 999; + else KILLIT(i); + break; + case TONGUE__STATIC: + KILLIT(i); + + case MONEY__STATIC: + case MAIL__STATIC: + case PAPER__STATIC: + + s->xvel = (TRAND&7)+(sintable[T1&2047]>>9); + T1 += (TRAND&63); + if( (T1&2047) > 512 && (T1&2047) < 1596) + { + if(sector[sect].lotag == 2) + { + if(s->zvel < 64) + s->zvel += (gc>>5)+(TRAND&7); + } + else + if(s->zvel < 144) + s->zvel += (gc>>5)+(TRAND&7); + } + + ssp(i,CLIPMASK0); + + if( (TRAND&3) == 0 ) + setsprite(i,s->x,s->y,s->z); + + if(s->sectnum == -1) KILLIT(i); + l = getflorzofslope(s->sectnum,s->x,s->y); + + if( s->z > l ) + { + s->z = l; + + insertspriteq(i); + PN ++; + + j = headspritestat[5]; + while(j >= 0) + { + if(sprite[j].picnum == BLOODPOOL) + if(ldist(s,&sprite[j]) < 348) + { + s->pal = 2; + break; + } + j = nextspritestat[j]; + } + } + + break; + + case JIBS1__STATIC: + case JIBS2__STATIC: + case JIBS3__STATIC: + case JIBS4__STATIC: + case JIBS5__STATIC: + case JIBS6__STATIC: + case HEADJIB1__STATIC: + case ARMJIB1__STATIC: + case LEGJIB1__STATIC: + case LIZMANHEAD1__STATIC: + case LIZMANARM1__STATIC: + case LIZMANLEG1__STATIC: + case DUKETORSO__STATIC: + case DUKEGUN__STATIC: + case DUKELEG__STATIC: + + if(s->xvel > 0) s->xvel--; + else s->xvel = 0; + + if( t[5] < 30*10 ) + t[5]++; + else { KILLIT(i); } + + + if(s->zvel > 1024 && s->zvel < 1280) + { + setsprite(i,s->x,s->y,s->z); + sect = s->sectnum; + } + + l = getflorzofslope(sect,s->x,s->y); + x = getceilzofslope(sect,s->x,s->y); + if(x == l || sect < 0 || sect >= MAXSECTORS) KILLIT(i); + + if( s->z < l-(2<<8) ) + { + if(t[1] < 2) t[1]++; + else if(sector[sect].lotag != 2) + { + t[1] = 0; + if( s->picnum == DUKELEG || s->picnum == DUKETORSO || s->picnum == DUKEGUN ) + { + if(t[0] > 6) t[0] = 0; + else t[0]++; + } + else + { + if(t[0] > 2) + t[0] = 0; + else t[0]++; + } + } + + if(s->zvel < 6144) + { + if(sector[sect].lotag == 2) + { + if(s->zvel < 1024) + s->zvel += 48; + else s->zvel = 1024; + } + else s->zvel += gc-50; + } + + s->x += (s->xvel*sintable[(s->ang+512)&2047])>>14; + s->y += (s->xvel*sintable[s->ang&2047])>>14; + s->z += s->zvel; + + } + else + { + if(t[2] == 0) + { + if( s->sectnum == -1) { KILLIT(i); } + if( (sector[s->sectnum].floorstat&2) ) { KILLIT(i); } + t[2]++; + } + l = getflorzofslope(s->sectnum,s->x,s->y); + + s->z = l-(2<<8); + s->xvel = 0; + + if(s->picnum == JIBS6) + { + t[1]++; + if( (t[1]&3) == 0 && t[0] < 7) + t[0]++; + if(t[1] > 20) KILLIT(i); + } + else { s->picnum = JIBS6; t[0] = 0; t[1] = 0; } + } + goto BOLT; + + case BLOODPOOL__STATIC: + case PUKE__STATIC: + + if(t[0] == 0) + { + t[0] = 1; + if(sector[sect].floorstat&2) { KILLIT(i); } + else insertspriteq(i); + } + + makeitfall(i); + + p = findplayer(s,&x); + + s->z = hittype[i].floorz-(FOURSLEIGHT); + + if(t[2] < 32) + { + t[2]++; + if(hittype[i].picnum == TIRE) + { + if(s->xrepeat < 64 && s->yrepeat < 64) + { + s->xrepeat += TRAND&3; + s->yrepeat += TRAND&3; + } + } + else + { + if(s->xrepeat < 32 && s->yrepeat < 32) + { + s->xrepeat += TRAND&3; + s->yrepeat += TRAND&3; + } + } + } + + if(x < 844 && s->xrepeat > 6 && s->yrepeat > 6) + { + if( s->pal == 0 && (TRAND&255) < 16 && s->picnum != PUKE) + { + if(ps[p].boot_amount > 0) + ps[p].boot_amount--; + else + { + if(!isspritemakingsound(ps[p].i,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,ps[p].i); + sprite[ps[p].i].extra --; + ps[p].pals_time = 32; + ps[p].pals[0] = 16; + ps[p].pals[1] = 0; + ps[p].pals[2] = 0; + } + } + + if(t[1] == 1) goto BOLT; + t[1] = 1; + + if(hittype[i].picnum == TIRE) + ps[p].footprintcount = 10; + else ps[p].footprintcount = 3; + + ps[p].footprintpal = s->pal; + ps[p].footprintshade = s->shade; + + if(t[2] == 32) + { + s->xrepeat -= 6; + s->yrepeat -= 6; + } + } + else t[1] = 0; + goto BOLT; + + case BURNING__STATIC: + case BURNING2__STATIC: + case FECES__STATIC: + case WATERBUBBLE__STATIC: + case SMALLSMOKE__STATIC: + case EXPLOSION2__STATIC: + case SHRINKEREXPLOSION__STATIC: + case EXPLOSION2BOT__STATIC: + case BLOOD__STATIC: + case LASERSITE__STATIC: + case FORCERIPPLE__STATIC: + case TRANSPORTERSTAR__STATIC: + case TRANSPORTERBEAM__STATIC: + p = findplayer(s,&x); + execute(i,p,x); + goto BOLT; + + case SHELL__STATIC: + case SHOTGUNSHELL__STATIC: + + ssp(i,CLIPMASK0); + + if(sect < 0 || ( sector[sect].floorz + 256 ) < s->z ) KILLIT(i); + + if(sector[sect].lotag == 2) + { + t[1]++; + if(t[1] > 8) + { + t[1] = 0; + t[0]++; + t[0] &= 3; + } + if(s->zvel < 128) s->zvel += (gc/13); // 8 + else s->zvel -= 64; + if(s->xvel > 0) + s->xvel -= 4; + else s->xvel = 0; + } + else + { + t[1]++; + if(t[1] > 3) + { + t[1] = 0; + t[0]++; + t[0] &= 3; + } + if(s->zvel < 512) s->zvel += (gc/3); // 52; + if(s->xvel > 0) + s->xvel --; + // else KILLIT(i); + } + + goto BOLT; + + case GLASSPIECES__STATIC: + // case GLASSPIECES+1: + // case GLASSPIECES+2: + + makeitfall(i); + + if(s->zvel > 4096) s->zvel = 4096; + if(sect < 0) KILLIT(i); + + if( s->z == hittype[i].floorz-(FOURSLEIGHT) && t[0] < 3) + { + s->zvel = -((3-t[0])<<8)-(TRAND&511); + if(sector[sect].lotag == 2) + s->zvel >>= 1; + s->xrepeat >>= 1; + s->yrepeat >>= 1; + if( rnd(96) ) + setsprite(i,s->x,s->y,s->z); + t[0]++;//Number of bounces + } + else if( t[0] == 3 ) KILLIT(i); + + if(s->xvel > 0) + { + s->xvel -= 2; + s->cstat = ((s->xvel&3)<<2); + } + else s->xvel = 0; + + ssp(i,CLIPMASK0); + + goto BOLT; + } + + IFWITHIN(SCRAP6,SCRAP5+3) + { + if(s->xvel > 0) + s->xvel--; + else s->xvel = 0; + + if(s->zvel > 1024 && s->zvel < 1280) + { + setsprite(i,s->x,s->y,s->z); + sect = s->sectnum; + } + + if( s->z < sector[sect].floorz-(2<<8) ) + { + if(t[1] < 1) t[1]++; + else + { + t[1] = 0; + + if(s->picnum < SCRAP6+8) + { + if(t[0] > 6) + t[0] = 0; + else t[0]++; + } + else + { + if(t[0] > 2) + t[0] = 0; + else t[0]++; + } + } + if(s->zvel < 4096) s->zvel += gc-50; + s->x += (s->xvel*sintable[(s->ang+512)&2047])>>14; + s->y += (s->xvel*sintable[s->ang&2047])>>14; + s->z += s->zvel; + } + else + { + if(s->picnum == SCRAP1 && s->yvel > 0) + { + j = spawn(i,s->yvel); + setsprite(j,s->x,s->y,s->z); + getglobalz(j); + sprite[j].hitag = sprite[j].lotag = 0; + } + KILLIT(i); + } + goto BOLT; + } + +BOLT: + i = nexti; + } +} + +void moveeffectors(void) //STATNUM 3 +{ + long q=0, l, m, x, st, j, *t; + short i, k, nexti, nextk, p, sh, nextj; + spritetype *s; + sectortype *sc; + walltype *wal; + + fricxv = fricyv = 0; + + i = headspritestat[3]; + while(i >= 0) + { + nexti = nextspritestat[i]; + s = &sprite[i]; + + sc = §or[s->sectnum]; + st = s->lotag; + sh = s->hitag; + + t = &hittype[i].temp_data[0]; + + switch(st) + { + case 0: + { + long zchange = 0; + + zchange = 0; + + j = s->owner; + + if( sprite[j].lotag == (short) 65535 ) + KILLIT(i); + + q = sc->extra>>3; + l = 0; + + if(sc->lotag == 30) + { + q >>= 2; + + if( sprite[i].extra == 1 ) + { + if(hittype[i].tempang < 256) + { + hittype[i].tempang += 4; + if(hittype[i].tempang >= 256) + callsound(s->sectnum,i); + if(s->clipdist) l = 1; + else l = -1; + } + else hittype[i].tempang = 256; + + if( sc->floorz > s->z ) //z's are touching + { + sc->floorz -= 512; + zchange = -512; + if( sc->floorz < s->z ) + sc->floorz = s->z; + } + + else if( sc->floorz < s->z ) //z's are touching + { + sc->floorz += 512; + zchange = 512; + if( sc->floorz > s->z ) + sc->floorz = s->z; + } + } + else if(sprite[i].extra == 3) + { + if(hittype[i].tempang > 0) + { + hittype[i].tempang -= 4; + if(hittype[i].tempang <= 0) + callsound(s->sectnum,i); + if( s->clipdist ) l = -1; + else l = 1; + } + else hittype[i].tempang = 0; + + if( sc->floorz > T4 ) //z's are touching + { + sc->floorz -= 512; + zchange = -512; + if( sc->floorz < T4 ) + sc->floorz = T4; + } + + else if( sc->floorz < T4 ) //z's are touching + { + sc->floorz += 512; + zchange = 512; + if( sc->floorz > T4 ) + sc->floorz = T4; + } + } + + s->ang += (l*q); + t[2] += (l*q); + } + else + { + if( hittype[j].temp_data[0] == 0 ) break; + if( hittype[j].temp_data[0] == 2 ) KILLIT(i); + + if( sprite[j].ang > 1024 ) + l = -1; + else l = 1; + if( t[3] == 0 ) + t[3] = ldist(s,&sprite[j]); + s->xvel = t[3]; + s->x = sprite[j].x; + s->y = sprite[j].y; + s->ang += (l*q); + t[2] += (l*q); + } + + if( l && (sc->floorstat&64) ) + { + for(p=connecthead;p>=0;p=connectpoint2[p]) + { + if( ps[p].cursectnum == s->sectnum && ps[p].on_ground == 1) + { + + ps[p].ang += (l*q); + ps[p].ang &= 2047; + + ps[p].posz += zchange; + + rotatepoint( sprite[j].x,sprite[j].y, + ps[p].posx,ps[p].posy,(q*l), + &m,&x); + + ps[p].bobposx += m-ps[p].posx; + ps[p].bobposy += x-ps[p].posy; + + ps[p].posx = m; + ps[p].posy = x; + + if(sprite[ps[p].i].extra <= 0) + { + sprite[ps[p].i].x = m; + sprite[ps[p].i].y = x; + } + } + } + + p = headspritesect[s->sectnum]; + while(p >= 0) + { + if(sprite[p].statnum != 3 && sprite[p].statnum != 4) + if( sprite[p].picnum != LASERLINE ) + { + if(sprite[p].picnum == APLAYER && sprite[p].owner >= 0) + { + p = nextspritesect[p]; + continue; + } + + sprite[p].ang += (l*q); + sprite[p].ang &= 2047; + + sprite[p].z += zchange; + + rotatepoint(sprite[j].x,sprite[j].y, + sprite[p].x,sprite[p].y,(q*l), + &sprite[p].x,&sprite[p].y); + + } + p = nextspritesect[p]; + } + + } + + ms(i); + } + + break; + case 1: //Nothing for now used as the pivot + if(s->owner == -1) //Init + { + s->owner = i; + + j = headspritestat[3]; + while(j >= 0) + { + if( sprite[j].lotag == 19 && sprite[j].hitag == sh ) + { + t[0] = 0; + break; + } + j = nextspritestat[j]; + } + } + + break; + case 6: + k = sc->extra; + + if(t[4] > 0) + { + t[4]--; + if( t[4] >= (k-(k>>3)) ) + s->xvel -= (k>>5); + if( t[4] > ((k>>1)-1) && t[4] < (k-(k>>3)) ) + s->xvel = 0; + if( t[4] < (k>>1) ) + s->xvel += (k>>5); + if( t[4] < ((k>>1)-(k>>3)) ) + { + t[4] = 0; + s->xvel = k; + } + } + else s->xvel = k; + + j = headspritestat[3]; + while( j >= 0) + { + if( (sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (hittype[j].temp_data[0] == t[0]) ) + { + sprite[j].xvel = s->xvel; + // if( t[4] == 1 ) + { + if(hittype[j].temp_data[5] == 0) + hittype[j].temp_data[5] = dist(&sprite[j],s); + x = ksgn( dist(&sprite[j],s)-hittype[j].temp_data[5] ); + if(sprite[j].extra) + x = -x; + s->xvel += x; + } + hittype[j].temp_data[4] = t[4]; + } + j = nextspritestat[j]; + } + x = 0; + + + case 14: + if(s->owner==-1) + s->owner = LocateTheLocator((short)t[3],(short)t[0]); + + if(s->owner == -1) + { + Bsprintf(tempbuf,"Could not find any locators for SE# 6 and 14 with a hitag of %ld.\n",t[3]); + gameexit(tempbuf); + } + + j = ldist(&sprite[s->owner],s); + + if( j < 1024L ) + { + if(st==6) + if(sprite[s->owner].hitag&1) + t[4]=sc->extra; //Slow it down + t[3]++; + s->owner = LocateTheLocator(t[3],t[0]); + if(s->owner==-1) + { + t[3]=0; + s->owner = LocateTheLocator(0,t[0]); + } + } + + if(s->xvel) + { + x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); + q = getincangle(s->ang,x)>>3; + + t[2] += q; + s->ang += q; + + if(s->xvel == sc->extra ) + { + if( (sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0 ) + { + if( !issoundplaying(hittype[i].lastvx) ) + spritesound(hittype[i].lastvx,i); + } + else if( ud.monsters_off == 0 && sc->floorpal == 0 && (sc->floorstat&1) && rnd(8) ) + { + p = findplayer(s,&x); + if(x < 20480) + { + j = s->ang; + s->ang = getangle(s->x-ps[p].posx,s->y-ps[p].posy); + shoot(i,RPG); + s->ang = j; + } + } + } + + if(s->xvel <= 64 && (sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0 ) + stopspritesound(hittype[i].lastvx,i); + + if( (sc->floorz-sc->ceilingz) < (108<<8) ) + { + if(ud.clipping == 0 && s->xvel >= 192) + for(p=connecthead;p>=0;p=connectpoint2[p]) + if(sprite[ps[p].i].extra > 0) + { + k = ps[p].cursectnum; + updatesector(ps[p].posx,ps[p].posy,&k); + if( ( k == -1 && ud.clipping == 0 ) || ( k == s->sectnum && ps[p].cursectnum != s->sectnum ) ) + { + ps[p].posx = s->x; + ps[p].posy = s->y; + ps[p].cursectnum = s->sectnum; + + setsprite(ps[p].i,s->x,s->y,s->z); + quickkill(&ps[p]); + } + } + } + + m = (s->xvel*sintable[(s->ang+512)&2047])>>14; + x = (s->xvel*sintable[s->ang&2047])>>14; + + for(p = connecthead;p >= 0;p=connectpoint2[p]) + if(sector[ps[p].cursectnum].lotag != 2) + { + if(po[p].os == s->sectnum) + { + po[p].ox += m; + po[p].oy += x; + } + + if(s->sectnum == sprite[ps[p].i].sectnum) + { + rotatepoint(s->x,s->y,ps[p].posx,ps[p].posy,q,&ps[p].posx,&ps[p].posy); + + ps[p].posx += m; + ps[p].posy += x; + + ps[p].bobposx += m; + ps[p].bobposy += x; + + ps[p].ang += q; + + if(numplayers > 1) + { + ps[p].oposx = ps[p].posx; + ps[p].oposy = ps[p].posy; + } + if( sprite[ps[p].i].extra <= 0 ) + { + sprite[ps[p].i].x = ps[p].posx; + sprite[ps[p].i].y = ps[p].posy; + } + } + } + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if (sprite[j].statnum != 10 && sector[sprite[j].sectnum].lotag != 2 && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS ) + { + rotatepoint(s->x,s->y, + sprite[j].x,sprite[j].y,q, + &sprite[j].x,&sprite[j].y); + + sprite[j].x+= m; + sprite[j].y+= x; + + sprite[j].ang+=q; + + if(numplayers > 1) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + } + } + j = nextspritesect[j]; + } + + ms(i); + setsprite(i,s->x,s->y,s->z); + + if( (sc->floorz-sc->ceilingz) < (108<<8) ) + { + if(ud.clipping == 0 && s->xvel >= 192) + for(p=connecthead;p>=0;p=connectpoint2[p]) + if(sprite[ps[p].i].extra > 0) + { + k = ps[p].cursectnum; + updatesector(ps[p].posx,ps[p].posy,&k); + if( ( k == -1 && ud.clipping == 0 ) || ( k == s->sectnum && ps[p].cursectnum != s->sectnum ) ) + { + ps[p].oposx = ps[p].posx = s->x; + ps[p].oposy = ps[p].posy = s->y; + ps[p].cursectnum = s->sectnum; + + setsprite(ps[p].i,s->x,s->y,s->z); + quickkill(&ps[p]); + } + } + + j = headspritesect[sprite[OW].sectnum]; + while(j >= 0) + { + l = nextspritesect[j]; + if (sprite[j].statnum == 1 && badguy(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS ) + { + k = sprite[j].sectnum; + updatesector(sprite[j].x,sprite[j].y,&k); + if( sprite[j].extra >= 0 && k == s->sectnum ) + { + gutsdir(&sprite[j],JIBS6,72,myconnectindex); + spritesound(SQUISHED,i); + deletesprite(j); + } + } + j = l; + } + } + } + + break; + + case 30: + if(s->owner == -1) + { + t[3] = !t[3]; + s->owner = LocateTheLocator(t[3],t[0]); + } + else + { + + if(t[4] == 1) // Starting to go + { + if( ldist( &sprite[s->owner],s ) < (2048-128) ) + t[4] = 2; + else + { + if(s->xvel == 0) + operateactivators(s->hitag+(!t[3]),-1); + if(s->xvel < 256) + s->xvel += 16; + } + } + if(t[4] == 2) + { + l = FindDistance2D(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); + + if(l <= 128) + s->xvel = 0; + + if( s->xvel > 0 ) + s->xvel -= 16; + else + { + s->xvel = 0; + operateactivators(s->hitag+(short)t[3],-1); + s->owner = -1; + s->ang += 1024; + t[4] = 0; + operateforcefields(i,s->hitag); + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS ) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + } + j = nextspritesect[j]; + } + + } + } + } + + if(s->xvel) + { + l = (s->xvel*sintable[(s->ang+512)&2047])>>14; + x = (s->xvel*sintable[s->ang&2047])>>14; + + if( (sc->floorz-sc->ceilingz) < (108<<8) ) + if(ud.clipping == 0) + for(p=connecthead;p>=0;p=connectpoint2[p]) + if(sprite[ps[p].i].extra > 0) + { + k = ps[p].cursectnum; + updatesector(ps[p].posx,ps[p].posy,&k); + if( ( k == -1 && ud.clipping == 0 ) || ( k == s->sectnum && ps[p].cursectnum != s->sectnum ) ) + { + ps[p].posx = s->x; + ps[p].posy = s->y; + ps[p].cursectnum = s->sectnum; + + setsprite(ps[p].i,s->x,s->y,s->z); + quickkill(&ps[p]); + } + } + + for(p = connecthead;p >= 0;p = connectpoint2[p]) + { + if( sprite[ps[p].i].sectnum == s->sectnum ) + { + ps[p].posx += l; + ps[p].posy += x; + + if(numplayers > 1) + { + ps[p].oposx = ps[p].posx; + ps[p].oposy = ps[p].posy; + } + + ps[p].bobposx += l; + ps[p].bobposy += x; + } + + if( po[p].os == s->sectnum ) + { + po[p].ox += l; + po[p].oy += x; + } + } + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS ) + { + if(numplayers < 2) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + } + + sprite[j].x += l; + sprite[j].y += x; + + if(numplayers > 1) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + } + } + j = nextspritesect[j]; + } + + ms(i); + setsprite(i,s->x,s->y,s->z); + + if( (sc->floorz-sc->ceilingz) < (108<<8) ) + { + if(ud.clipping == 0) + for(p=connecthead;p>=0;p=connectpoint2[p]) + if(sprite[ps[p].i].extra > 0) + { + k = ps[p].cursectnum; + updatesector(ps[p].posx,ps[p].posy,&k); + if( ( k == -1 && ud.clipping == 0 ) || ( k == s->sectnum && ps[p].cursectnum != s->sectnum ) ) + { + ps[p].posx = s->x; + ps[p].posy = s->y; + + ps[p].oposx = ps[p].posx; + ps[p].oposy = ps[p].posy; + + ps[p].cursectnum = s->sectnum; + + setsprite(ps[p].i,s->x,s->y,s->z); + quickkill(&ps[p]); + } + } + + j = headspritesect[sprite[OW].sectnum]; + while(j >= 0) + { + l = nextspritesect[j]; + if (sprite[j].statnum == 1 && badguy(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS ) + { + // if(sprite[j].sectnum != s->sectnum) + { + k = sprite[j].sectnum; + updatesector(sprite[j].x,sprite[j].y,&k); + if( sprite[j].extra >= 0 && k == s->sectnum ) + { + gutsdir(&sprite[j],JIBS6,24,myconnectindex); + spritesound(SQUISHED,j); + deletesprite(j); + } + } + + } + j = l; + } + } + } + + break; + + + case 2://Quakes + if(t[4] > 0 && t[0] == 0 ) + { + if( t[4] < sh ) + t[4]++; + else t[0] = 1; + } + + if(t[0] > 0) + { + t[0]++; + + s->xvel = 3; + + if(t[0] > 96) + { + t[0] = -1; //Stop the quake + t[4] = -1; + KILLIT(i); + } + else + { + if( (t[0]&31) == 8 ) + { + earthquaketime = 48; + spritesound(EARTHQUAKE,ps[screenpeek].i); + } + + if( klabs( sc->floorheinum-t[5] ) < 8 ) + sc->floorheinum = t[5]; + else sc->floorheinum += ( ksgn(t[5]-sc->floorheinum)<<4 ); + } + + m = (s->xvel*sintable[(s->ang+512)&2047])>>14; + x = (s->xvel*sintable[s->ang&2047])>>14; + + + for(p=connecthead;p>=0;p=connectpoint2[p]) + if(ps[p].cursectnum == s->sectnum && ps[p].on_ground) + { + ps[p].posx += m; + ps[p].posy += x; + + ps[p].bobposx += m; + ps[p].bobposy += x; + } + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + nextj = nextspritesect[j]; + + if (sprite[j].picnum != SECTOREFFECTOR) + { + sprite[j].x+=m; + sprite[j].y+=x; + setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + } + j = nextj; + } + ms(i); + setsprite(i,s->x,s->y,s->z); + } + break; + + //Flashing sector lights after reactor EXPLOSION2 + + case 3: + + if( t[4] == 0 ) break; + p = findplayer(s,&x); + + // if(t[5] > 0) { t[5]--; break; } + + if( (global_random/(sh+1)&31) < 4 && !t[2]) + { + // t[5] = 4+(global_random&7); + sc->ceilingpal = s->owner>>8; + sc->floorpal = s->owner&0xff; + t[0] = s->shade + (global_random&15); + } + else + { + // t[5] = 4+(global_random&3); + sc->ceilingpal = s->pal; + sc->floorpal = s->pal; + t[0] = t[3]; + } + + sc->ceilingshade = t[0]; + sc->floorshade = t[0]; + + wal = &wall[sc->wallptr]; + + for(x=sc->wallnum;x > 0;x--,wal++) + { + if( wal->hitag != 1 ) + { + wal->shade = t[0]; + if((wal->cstat&2) && wal->nextwall >= 0) + { + wall[wal->nextwall].shade = wal->shade; + } + } + } + + break; + + case 4: + + if((global_random/(sh+1)&31) < 4 ) + { + t[1] = s->shade + (global_random&15);//Got really bright + t[0] = s->shade + (global_random&15); + sc->ceilingpal = s->owner>>8; + sc->floorpal = s->owner&0xff; + j = 1; + } + else + { + t[1] = t[2]; + t[0] = t[3]; + + sc->ceilingpal = s->pal; + sc->floorpal = s->pal; + + j = 0; + } + + sc->floorshade = t[1]; + sc->ceilingshade = t[1]; + + wal = &wall[sc->wallptr]; + + for(x=sc->wallnum;x > 0; x--,wal++) + { + if(j) wal->pal = (s->owner&0xff); + else wal->pal = s->pal; + + if( wal->hitag != 1 ) + { + wal->shade = t[0]; + if((wal->cstat&2) && wal->nextwall >= 0) + wall[wal->nextwall].shade = wal->shade; + } + } + + j = headspritesect[SECT]; + while(j >= 0) + { + if(sprite[j].cstat&16 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + { + if (sc->ceilingstat&1) + sprite[j].shade = sc->ceilingshade; + else sprite[j].shade = sc->floorshade; + } + + j = nextspritesect[j]; + } + + if(t[4]) KILLIT(i); + + break; + + //BOSS + case 5: + p = findplayer(s,&x); + if(x < 8192) + { + j = s->ang; + s->ang = getangle(s->x-ps[p].posx,s->y-ps[p].posy); + shoot(i,FIRELASER); + s->ang = j; + } + + if(s->owner==-1) //Start search + { + t[4]=0; + l = 0x7fffffff; + while(1) //Find the shortest dist + { + s->owner = LocateTheLocator((short)t[4],-1); //t[0] hold sectnum + + if(s->owner==-1) break; + + m = ldist(&sprite[ps[p].i],&sprite[s->owner]); + + if(l > m) + { + q = s->owner; + l = m; + } + + t[4]++; + } + + s->owner = q; + s->zvel = ksgn(sprite[q].z-s->z)<<4; + } + + if(ldist(&sprite[s->owner],s) < 1024) + { + short ta; + ta = s->ang; + s->ang = getangle(ps[p].posx-s->x,ps[p].posy-s->y); + s->ang = ta; + s->owner = -1; + goto BOLT; + + } + else s->xvel=256; + + x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); + q = getincangle(s->ang,x)>>3; + s->ang += q; + + if(rnd(32)) + { + t[2]+=q; + sc->ceilingshade = 127; + } + else + { + t[2] += + getincangle(t[2]+512,getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>2; + sc->ceilingshade = 0; + } + IFHIT + { + t[3]++; + if(t[3] == 5) + { + s->zvel += 1024; + FTA(7,&ps[myconnectindex]); + } + } + + s->z += s->zvel; + sc->ceilingz += s->zvel; + sector[t[0]].ceilingz += s->zvel; + ms(i); + setsprite(i,s->x,s->y,s->z); + break; + + + case 8: + case 9: + + // work only if its moving + + j = -1; + + if(hittype[i].temp_data[4]) + { + hittype[i].temp_data[4]++; + if( hittype[i].temp_data[4] > 8 ) KILLIT(i); + j = 1; + } + else j = getanimationgoal(&sc->ceilingz); + + if( j >= 0 ) + { + short sn; + + if( (sc->lotag&0x8000) || hittype[i].temp_data[4] ) + x = -t[3]; + else + x = t[3]; + + if ( st == 9 ) x = -x; + + j = headspritestat[3]; + while(j >= 0) + { + if( ((sprite[j].lotag) == st ) && (sprite[j].hitag) == sh ) + { + sn = sprite[j].sectnum; + m = sprite[j].shade; + + wal = &wall[sector[sn].wallptr]; + + for(l=sector[sn].wallnum;l>0;l--,wal++) + { + if( wal->hitag != 1 ) + { + wal->shade+=x; + + if(wal->shade < m) + wal->shade = m; + else if(wal->shade > hittype[j].temp_data[2]) + wal->shade = hittype[j].temp_data[2]; + + if(wal->nextwall >= 0) + if(wall[wal->nextwall].hitag != 1) + wall[wal->nextwall].shade = wal->shade; + } + } + + sector[sn].floorshade += x; + sector[sn].ceilingshade += x; + + if(sector[sn].floorshade < m) + sector[sn].floorshade = m; + else if(sector[sn].floorshade > hittype[j].temp_data[0]) + sector[sn].floorshade = hittype[j].temp_data[0]; + + if(sector[sn].ceilingshade < m) + sector[sn].ceilingshade = m; + else if(sector[sn].ceilingshade > hittype[j].temp_data[1]) + sector[sn].ceilingshade = hittype[j].temp_data[1]; + + } + j = nextspritestat[j]; + } + } + break; + case 10: + + if( (sc->lotag&0xff) == 27 || ( sc->floorz > sc->ceilingz && (sc->lotag&0xff) != 23 ) || sc->lotag == (short) 32791 ) + { + j = 1; + + if( (sc->lotag&0xff) != 27) + for(p=connecthead;p>=0;p=connectpoint2[p]) + if( sc->lotag != 30 && sc->lotag != 31 && sc->lotag != 0 ) + if(s->sectnum == sprite[ps[p].i].sectnum) + j = 0; + + if(j == 1) + { + if(t[0] > sh ) + switch(sector[s->sectnum].lotag) + { + case 20: + case 21: + case 22: + case 26: + if( getanimationgoal(§or[s->sectnum].ceilingz) >= 0 ) + break; + default: + activatebysector(s->sectnum,i); + t[0] = 0; + break; + } + else t[0]++; + } + } + else t[0]=0; + break; + case 11: //Swingdoor + + if( t[5] > 0) + { + t[5]--; + break; + } + + if( t[4] ) + { + short startwall,endwall; + + startwall = sc->wallptr; + endwall = startwall+sc->wallnum; + + for(j=startwall;j= 0) + { + if( sprite[k].extra > 0 && badguy(&sprite[k]) && clipinsidebox(sprite[k].x,sprite[k].y,j,256L) == 1 ) + goto BOLT; + k = nextspritestat[k]; + } + + k = headspritestat[10]; + while(k >= 0) + { + if( sprite[k].owner >= 0 && clipinsidebox(sprite[k].x,sprite[k].y,j,144L) == 1 ) + { + t[5] = 8; // Delay + k = (SP>>3)*t[3]; + t[2]-=k; + t[4]-=k; + ms(i); + setsprite(i,s->x,s->y,s->z); + goto BOLT; + } + k = nextspritestat[k]; + } + } + + k = (SP>>3)*t[3]; + t[2]+=k; + t[4]+=k; + ms(i); + setsprite(i,s->x,s->y,s->z); + + if(t[4] <= -511 || t[4] >= 512) + { + t[4] = 0; + t[2] &= 0xffffff00; + ms(i); + setsprite(i,s->x,s->y,s->z); + break; + } + } + break; + case 12: + if( t[0] == 3 || t[3] == 1 ) //Lights going off + { + sc->floorpal = 0; + sc->ceilingpal = 0; + + wal = &wall[sc->wallptr]; + for(j = sc->wallnum;j > 0; j--, wal++) + if(wal->hitag != 1) + { + wal->shade = t[1]; + wal->pal = 0; + } + + sc->floorshade = t[1]; + sc->ceilingshade = t[2]; + t[0]=0; + + j = headspritesect[SECT]; + while(j >= 0) + { + if(sprite[j].cstat&16 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + { + if (sc->ceilingstat&1) + sprite[j].shade = sc->ceilingshade; + else sprite[j].shade = sc->floorshade; + } + j = nextspritesect[j]; + + } + + if(t[3] == 1) KILLIT(i); + } + if( t[0] == 1 ) //Lights flickering on + { + if( sc->floorshade > s->shade ) + { + sc->floorpal = s->pal; + sc->ceilingpal = s->pal; + + sc->floorshade -= 2; + sc->ceilingshade -= 2; + + wal = &wall[sc->wallptr]; + for(j=sc->wallnum;j>0;j--,wal++) + if(wal->hitag != 1) + { + wal->pal = s->pal; + wal->shade -= 2; + } + } + else t[0] = 2; + + j = headspritesect[SECT]; + while(j >= 0) + { + if(sprite[j].cstat&16) + { + if (sc->ceilingstat&1 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + sprite[j].shade = sc->ceilingshade; + else sprite[j].shade = sc->floorshade; + } + j = nextspritesect[j]; + } + } + break; + + + case 13: + if( t[2] ) + { + j = (SP<<5)|1; + + if( s->ang == 512 ) + { + if( s->owner ) + { + if( klabs(t[0]-sc->ceilingz) >= j ) + sc->ceilingz += ksgn(t[0]-sc->ceilingz)*j; + else sc->ceilingz = t[0]; + } + else + { + if( klabs(t[1]-sc->floorz) >= j ) + sc->floorz += ksgn(t[1]-sc->floorz)*j; + else sc->floorz = t[1]; + } + } + else + { + if( klabs(t[1]-sc->floorz) >= j ) + sc->floorz += ksgn(t[1]-sc->floorz)*j; + else sc->floorz = t[1]; + if( klabs(t[0]-sc->ceilingz) >= j ) + sc->ceilingz += ksgn(t[0]-sc->ceilingz)*j; + sc->ceilingz = t[0]; + } + + if( t[3] == 1 ) + { + //Change the shades + + t[3]++; + sc->ceilingstat ^= 1; + + if(s->ang == 512) + { + wal = &wall[sc->wallptr]; + for(j=sc->wallnum;j>0;j--,wal++) + wal->shade = s->shade; + + sc->floorshade = s->shade; + + if(ps[0].one_parallax_sectnum >= 0) + { + sc->ceilingpicnum = + sector[ps[0].one_parallax_sectnum].ceilingpicnum; + sc->ceilingshade = + sector[ps[0].one_parallax_sectnum].ceilingshade; + } + } + } + t[2]++; + if(t[2] > 256) + KILLIT(i); + } + + + if( t[2] == 4 && s->ang != 512) + for(x=0;x<7;x++) RANDOMSCRAP; + break; + + + case 15: + + if(t[4]) + { + s->xvel = 16; + + if(t[4] == 1) //Opening + { + if( t[3] >= (SP>>3) ) + { + t[4] = 0; //Turn off the sliders + callsound(s->sectnum,i); + break; + } + t[3]++; + } + else if(t[4] == 2) + { + if(t[3]<1) + { + t[4] = 0; + callsound(s->sectnum,i); + break; + } + t[3]--; + } + + ms(i); + setsprite(i,s->x,s->y,s->z); + } + break; + + case 16: //Reactor + + t[2]+=32; + if(sc->floorzceilingz) s->shade=0; + + else if( sc->ceilingz < t[3] ) + { + + //The following code check to see if + //there is any other sprites in the sector. + //If there isn't, then kill this sectoreffector + //itself..... + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].picnum == REACTOR || sprite[j].picnum == REACTOR2) + break; + j = nextspritesect[j]; + } + if(j == -1) { KILLIT(i); } + else s->shade=1; + } + + if(s->shade) sc->ceilingz+=1024; + else sc->ceilingz-=512; + + ms(i); + setsprite(i,s->x,s->y,s->z); + + break; + + case 17: + + q = t[0]*(SP<<2); + + sc->ceilingz += q; + sc->floorz += q; + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].statnum == 10 && sprite[j].owner >= 0) + { + p = sprite[j].yvel; + if(numplayers < 2) + ps[p].oposz = ps[p].posz; + ps[p].posz += q; + ps[p].truefz += q; + ps[p].truecz += q; + if(numplayers > 1) + ps[p].oposz = ps[p].posz; + } + if( sprite[j].statnum != 3 ) + { + hittype[j].bposz = sprite[j].z; + sprite[j].z += q; + } + + hittype[j].floorz = sc->floorz; + hittype[j].ceilingz = sc->ceilingz; + + j = nextspritesect[j]; + } + + if( t[0] ) if(t[0]) //If in motion + { + if( klabs(sc->floorz-t[2]) <= SP) + { + activatewarpelevators(i,0); + break; + } + + if(t[0]==-1) + { + if( sc->floorz > t[3] ) + break; + } + else if( sc->ceilingz < t[4] ) break; + + if( t[1] == 0 ) break; + t[1] = 0; + + j = headspritestat[3]; + while(j >= 0) + { + if( i != j && (sprite[j].lotag) == 17) + if( (sc->hitag-t[0]) == + (sector[sprite[j].sectnum].hitag) + && sh == (sprite[j].hitag)) + break; + j = nextspritestat[j]; + } + + if(j == -1) break; + + k = headspritesect[s->sectnum]; + while(k >= 0) + { + nextk = nextspritesect[k]; + + if(sprite[k].statnum == 10 && sprite[k].owner >= 0) + { + p = sprite[k].yvel; + + ps[p].posx += sprite[j].x-s->x; + ps[p].posy += sprite[j].y-s->y; + ps[p].posz = sector[sprite[j].sectnum].floorz-(sc->floorz-ps[p].posz); + + hittype[k].floorz = sector[sprite[j].sectnum].floorz; + hittype[k].ceilingz = sector[sprite[j].sectnum].ceilingz; + + ps[p].bobposx = ps[p].oposx = ps[p].posx; + ps[p].bobposy = ps[p].oposy = ps[p].posy; + ps[p].oposz = ps[p].posz; + + ps[p].truefz = hittype[k].floorz; + ps[p].truecz = hittype[k].ceilingz; + ps[p].bobcounter = 0; + + changespritesect(k,sprite[j].sectnum); + ps[p].cursectnum = sprite[j].sectnum; + } + else if( sprite[k].statnum != 3 ) + { + sprite[k].x += + sprite[j].x-s->x; + sprite[k].y += + sprite[j].y-s->y; + sprite[k].z = sector[sprite[j].sectnum].floorz- + (sc->floorz-sprite[k].z); + + hittype[k].bposx = sprite[k].x; + hittype[k].bposy = sprite[k].y; + hittype[k].bposz = sprite[k].z; + + changespritesect(k,sprite[j].sectnum); + setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + + hittype[k].floorz = sector[sprite[j].sectnum].floorz; + hittype[k].ceilingz = sector[sprite[j].sectnum].ceilingz; + + } + k = nextk; + } + } + break; + + case 18: + if(t[0]) + { + if(s->pal) + { + if(s->ang == 512) + { + sc->ceilingz -= sc->extra; + if(sc->ceilingz <= t[1]) + { + sc->ceilingz = t[1]; + KILLIT(i); + } + } + else + { + sc->floorz += sc->extra; + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if( ps[sprite[j].yvel].on_ground == 1 ) + ps[sprite[j].yvel].posz += sc->extra; + if( sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) + { + hittype[j].bposz = sprite[j].z += sc->extra; + hittype[j].floorz = sc->floorz; + } + j = nextspritesect[j]; + } + if(sc->floorz >= t[1]) + { + sc->floorz = t[1]; + KILLIT(i); + } + } + } + else + { + if(s->ang == 512) + { + sc->ceilingz += sc->extra; + if(sc->ceilingz >= s->z) + { + sc->ceilingz = s->z; + KILLIT(i); + } + } + else + { + sc->floorz -= sc->extra; + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if( ps[sprite[j].yvel].on_ground == 1 ) + ps[sprite[j].yvel].posz -= sc->extra; + if( sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) + { + hittype[j].bposz = sprite[j].z -= sc->extra; + hittype[j].floorz = sc->floorz; + } + j = nextspritesect[j]; + } + if(sc->floorz <= s->z) + { + sc->floorz = s->z; + KILLIT(i); + } + } + } + + t[2]++; + if(t[2] >= s->hitag) + { + t[2] = 0; + t[0] = 0; + } + } + break; + + case 19: //Battlestar galactia shields + + if(t[0]) + { + if(t[0] == 1) + { + t[0]++; + x = sc->wallptr; + q = x+sc->wallnum; + for(j=x;j= 0) + { + wall[wall[j].nextwall].overpicnum = 0; + wall[wall[j].nextwall].cstat &= (128+32+8+4+2); + } + } + } + + if(sc->ceilingz < sc->floorz) + sc->ceilingz += SP; + else + { + sc->ceilingz = sc->floorz; + + j = headspritestat[3]; + while(j >= 0) + { + if(sprite[j].lotag == 0 && sprite[j].hitag==sh) + { + q = sprite[sprite[j].owner].sectnum; + sector[sprite[j].sectnum].floorpal = sector[sprite[j].sectnum].ceilingpal = + sector[q].floorpal; + sector[sprite[j].sectnum].floorshade = sector[sprite[j].sectnum].ceilingshade = + sector[q].floorshade; + + hittype[sprite[j].owner].temp_data[0] = 2; + } + j = nextspritestat[j]; + } + KILLIT(i); + } + } + else //Not hit yet + { + IFHITSECT + { + FTA(8,&ps[myconnectindex]); + + l = headspritestat[3]; + while(l >= 0) + { + x = sprite[l].lotag&0x7fff; + switch( x ) + { + case 0: + if(sprite[l].hitag == sh) + { + q = sprite[l].sectnum; + sector[q].floorshade = + sector[q].ceilingshade = + sprite[sprite[l].owner].shade; + sector[q].floorpal = + sector[q].ceilingpal = + sprite[sprite[l].owner].pal; + } + break; + + case 1: + case 12: + // case 18: + case 19: + + if( sh == sprite[l].hitag ) + if( hittype[l].temp_data[0] == 0 ) + { + hittype[l].temp_data[0] = 1; //Shut them all on + sprite[l].owner = i; + } + + break; + } + l = nextspritestat[l]; + } + } + } + + break; + + case 20: //Extend-o-bridge + + if( t[0] == 0 ) break; + if( t[0] == 1 ) s->xvel = 8; + else s->xvel = -8; + + if( s->xvel ) //Moving + { + x = (s->xvel*sintable[(s->ang+512)&2047])>>14; + l = (s->xvel*sintable[s->ang&2047])>>14; + + t[3] += s->xvel; + + s->x += x; + s->y += l; + + if( t[3] <= 0 || (t[3]>>6) >= (SP>>6) ) + { + s->x -= x; + s->y -= l; + t[0] = 0; + callsound(s->sectnum,i); + break; + } + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + nextj = nextspritesect[j]; + + if( sprite[j].statnum != 3 && sprite[j].zvel == 0) + { + sprite[j].x += x; + sprite[j].y += l; + setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + if( sector[sprite[j].sectnum].floorstat&2 ) + if(sprite[j].statnum == 2) + makeitfall(j); + } + j = nextj; + } + + dragpoint((short)t[1],wall[t[1]].x+x,wall[t[1]].y+l); + dragpoint((short)t[2],wall[t[2]].x+x,wall[t[2]].y+l); + + for(p=connecthead;p>=0;p=connectpoint2[p]) + if(ps[p].cursectnum == s->sectnum && ps[p].on_ground) + { + ps[p].posx += x; + ps[p].posy += l; + + ps[p].oposx = ps[p].posx; + ps[p].oposy = ps[p].posy; + + setsprite(ps[p].i,ps[p].posx,ps[p].posy,ps[p].posz+PHEIGHT); + } + + sc->floorxpanning-=x>>3; + sc->floorypanning-=l>>3; + + sc->ceilingxpanning-=x>>3; + sc->ceilingypanning-=l>>3; + } + + break; + + case 21: // Cascading effect + + if( t[0] == 0 ) break; + + if( s->ang == 1536 ) + l = (long) &sc->ceilingz; + else + l = (long) &sc->floorz; + + if( t[0] == 1 ) //Decide if the s->sectnum should go up or down + { + s->zvel = ksgn(s->z-*(long *)l) * (SP<<4); + t[0]++; + } + + if( sc->extra == 0 ) + { + *(long *)l += s->zvel; + + if(klabs(*(long *)l-s->z) < 1024) + { + *(long *)l = s->z; + KILLIT(i); //All done + } + } + else sc->extra--; + break; + + case 22: + + if( t[1] ) + { + if(getanimationgoal(§or[t[0]].ceilingz) >= 0) + sc->ceilingz += sc->extra*9; + else t[1] = 0; + } + break; + + case 24: + case 34: + + if(t[4]) break; + + x = (SP*sintable[(s->ang+512)&2047])>>18; + l = (SP*sintable[s->ang&2047])>>18; + + k = 0; + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + nextj = nextspritesect[j]; + if(sprite[j].zvel >= 0) + switch(sprite[j].statnum) + { + case 5: + switch(dynamictostatic[sprite[j].picnum]) + { + case BLOODPOOL__STATIC: + case PUKE__STATIC: + case FOOTPRINTS__STATIC: + case FOOTPRINTS2__STATIC: + case FOOTPRINTS3__STATIC: + case FOOTPRINTS4__STATIC: + case BULLETHOLE__STATIC: + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + sprite[j].xrepeat = sprite[j].yrepeat = 0; + j = nextj; + continue; + case LASERLINE__STATIC: + j = nextj; + continue; + } + case 6: + if(sprite[j].picnum == TRIPBOMB) break; + case 1: + case 0: + if( + sprite[j].picnum == BOLT1 || + sprite[j].picnum == BOLT1+1 || + sprite[j].picnum == BOLT1+2 || + sprite[j].picnum == BOLT1+3 || + sprite[j].picnum == SIDEBOLT1 || + sprite[j].picnum == SIDEBOLT1+1 || + sprite[j].picnum == SIDEBOLT1+2 || + sprite[j].picnum == SIDEBOLT1+3 || + wallswitchcheck(j) + ) + break; + + if( !(sprite[j].picnum >= CRANE && sprite[j].picnum <= (CRANE+3))) + { + if( sprite[j].z > (hittype[j].floorz-(16<<8)) ) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + + sprite[j].x += x>>2; + sprite[j].y += l>>2; + + setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + + if( sector[sprite[j].sectnum].floorstat&2 ) + if(sprite[j].statnum == 2) + makeitfall(j); + } + } + break; + } + j = nextj; + } + + p = myconnectindex; + if(ps[p].cursectnum == s->sectnum && ps[p].on_ground) + if( klabs(ps[p].posz-ps[p].truefz) < PHEIGHT+(9<<8) ) + { + fricxv += x<<3; + fricyv += l<<3; + } + + sc->floorxpanning += SP>>7; + + break; + + case 35: + if(sc->ceilingz > s->z) + for(j = 0;j < 8;j++) + { + s->ang += TRAND&511; + k = spawn(i,SMALLSMOKE); + sprite[k].xvel = 96+(TRAND&127); + ssp(k,CLIPMASK0); + setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + if( rnd(16) ) + spawn(i,EXPLOSION2); + } + + switch(t[0]) + { + case 0: + sc->ceilingz += s->yvel; + if(sc->ceilingz > sc->floorz) + sc->floorz = sc->ceilingz; + if(sc->ceilingz > s->z+(32<<8)) + t[0]++; + break; + case 1: + sc->ceilingz-=(s->yvel<<2); + if(sc->ceilingz < t[4]) + { + sc->ceilingz = t[4]; + t[0] = 0; + } + break; + } + break; + + case 25: //PISTONS + + if( t[4] == 0 ) break; + + if(sc->floorz <= sc->ceilingz) + s->shade = 0; + else if( sc->ceilingz <= t[3]) + s->shade = 1; + + if(s->shade) + { + sc->ceilingz += SP<<4; + if(sc->ceilingz > sc->floorz) + sc->ceilingz = sc->floorz; + } + else + { + sc->ceilingz -= SP<<4; + if(sc->ceilingz < t[3]) + sc->ceilingz = t[3]; + } + + break; + + case 26: + + s->xvel = 32; + l = (s->xvel*sintable[(s->ang+512)&2047])>>14; + x = (s->xvel*sintable[s->ang&2047])>>14; + + s->shade++; + if( s->shade > 7 ) + { + s->x = t[3]; + s->y = t[4]; + sc->floorz -= ((s->zvel*s->shade)-s->zvel); + s->shade = 0; + } + else + sc->floorz += s->zvel; + + j = headspritesect[s->sectnum]; + while( j >= 0 ) + { + nextj = nextspritesect[j]; + if(sprite[j].statnum != 3 && sprite[j].statnum != 10) + { + hittype[j].bposx = sprite[j].x; + hittype[j].bposy = sprite[j].y; + + sprite[j].x += l; + sprite[j].y += x; + + sprite[j].z += s->zvel; + setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + } + j = nextj; + } + + p = myconnectindex; + if(sprite[ps[p].i].sectnum == s->sectnum && ps[p].on_ground) + { + fricxv += l<<5; + fricyv += x<<5; + } + + for(p = connecthead;p >= 0;p = connectpoint2[p]) + if(sprite[ps[p].i].sectnum == s->sectnum && ps[p].on_ground) + ps[p].posz += s->zvel; + + ms(i); + setsprite(i,s->x,s->y,s->z); + + break; + + + case 27: + + if(ud.recstat == 0) break; + + hittype[i].tempang = s->ang; + + p = findplayer(s,&x); + if( sprite[ps[p].i].extra > 0 && myconnectindex == screenpeek) + { + if( t[0] < 0 ) + { + ud.camerasprite = i; + t[0]++; + } + else if(ud.recstat == 2 && ps[p].newowner == -1) + { + if(cansee(s->x,s->y,s->z,SECT,ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum)) + { + if(x < (long)((unsigned)sh)) + { + ud.camerasprite = i; + t[0] = 999; + s->ang += getincangle(s->ang,getangle(ps[p].posx-s->x,ps[p].posy-s->y))>>3; + SP = 100+((s->z-ps[p].posz)/257); + + } + else if(t[0] == 999) + { + if(ud.camerasprite == i) + t[0] = 0; + else t[0] = -10; + ud.camerasprite = i; + + } + } + else + { + s->ang = getangle(ps[p].posx-s->x,ps[p].posy-s->y); + + if(t[0] == 999) + { + if(ud.camerasprite == i) + t[0] = 0; + else t[0] = -20; + ud.camerasprite = i; + } + } + } + } + break; + case 28: + if(t[5] > 0) + { + t[5]--; + break; + } + + if(T1 == 0) + { + p = findplayer(s,&x); + if( x > 15500 ) + break; + T1 = 1; + T2 = 64 + (TRAND&511); + T3 = 0; + } + else + { + T3++; + if(T3 > T2) + { + T1 = 0; + ps[screenpeek].visibility = ud.const_visibility; + break; + } + else if( T3 == (T2>>1) ) + spritesound(THUNDER,i); + else if(T3 == (T2>>3) ) + spritesound(LIGHTNING_SLAP,i); + else if( T3 == (T2>>2) ) + { + j = headspritestat[0]; + while(j >= 0) + { + if( sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag) + sprite[j].cstat |= 32768; + j = nextspritestat[j]; + } + } + else if(T3 > (T2>>3) && T3 < (T2>>2) ) + { + if( cansee(s->x,s->y,s->z,s->sectnum,ps[screenpeek].posx,ps[screenpeek].posy,ps[screenpeek].posz,ps[screenpeek].cursectnum ) ) + j = 1; + else j = 0; + + if( rnd(192) && (T3&1) ) + { + if(j) + ps[screenpeek].visibility = 0; + } + else if(j) + ps[screenpeek].visibility = ud.const_visibility; + + j = headspritestat[0]; + while(j >= 0) + { + if( sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag) + { + if ( rnd(32) && (T3&1) ) + { + sprite[j].cstat &= 32767; + spawn(j,SMALLSMOKE); + + p = findplayer(s,&x); + x = ldist(&sprite[ps[p].i], &sprite[j]); + if( x < 768 ) + { + if(!isspritemakingsound(ps[p].i,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,ps[p].i); + spritesound(SHORT_CIRCUIT,ps[p].i); + sprite[ps[p].i].extra -= 8+(TRAND&7); + ps[p].pals_time = 32; + ps[p].pals[0] = 16; + ps[p].pals[1] = 0; + ps[p].pals[2] = 0; + } + break; + } + else sprite[j].cstat |= 32768; + } + + j = nextspritestat[j]; + } + } + } + break; + case 29: + s->hitag += 64; + l = mulscale12((long)s->yvel,sintable[s->hitag&2047]); + sc->floorz = s->z + l; + break; + case 31: // True Drop Floor + if(t[0] == 1) + { + // Choose dir + + if(t[3] > 0) + { + t[3]--; + break; + } + + if(t[2] == 1) // Retract + { + if(SA != 1536) + { + if( klabs( sc->floorz - s->z ) < SP ) + { + sc->floorz = s->z; + t[2] = 0; + t[0] = 0; + t[3] = s->hitag; + callsound(s->sectnum,i); + } + else + { + l = ksgn(s->z-sc->floorz)*SP; + sc->floorz += l; + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if( ps[sprite[j].yvel].on_ground == 1 ) + ps[sprite[j].yvel].posz += l; + if( sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) + { + hittype[j].bposz = sprite[j].z += l; + hittype[j].floorz = sc->floorz; + } + j = nextspritesect[j]; + } + } + } + else + { + if( klabs( sc->floorz - t[1] ) < SP ) + { + sc->floorz = t[1]; + callsound(s->sectnum,i); + t[2] = 0; + t[0] = 0; + t[3] = s->hitag; + } + else + { + l = ksgn(t[1]-sc->floorz)*SP; + sc->floorz += l; + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if( ps[sprite[j].yvel].on_ground == 1 ) + ps[sprite[j].yvel].posz += l; + if( sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4 ) + { + hittype[j].bposz = sprite[j].z += l; + hittype[j].floorz = sc->floorz; + } + j = nextspritesect[j]; + } + } + } + break; + } + + if( (s->ang&2047) == 1536) + { + if( klabs( s->z-sc->floorz ) < SP ) + { + callsound(s->sectnum,i); + t[0] = 0; + t[2] = 1; + t[3] = s->hitag; + } + else + { + l = ksgn(s->z-sc->floorz)*SP; + sc->floorz += l; + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if( ps[sprite[j].yvel].on_ground == 1 ) + ps[sprite[j].yvel].posz += l; + if( sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4 ) + { + hittype[j].bposz = sprite[j].z += l; + hittype[j].floorz = sc->floorz; + } + j = nextspritesect[j]; + } + } + } + else + { + if( klabs( sc->floorz-t[1] ) < SP ) + { + t[0] = 0; + callsound(s->sectnum,i); + t[2] = 1; + t[3] = s->hitag; + } + else + { + l = ksgn(s->z-t[1])*SP; + sc->floorz -= l; + + j = headspritesect[s->sectnum]; + while(j >= 0) + { + if(sprite[j].picnum == APLAYER && sprite[j].owner >= 0) + if( ps[sprite[j].yvel].on_ground == 1 ) + ps[sprite[j].yvel].posz -= l; + if(sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4 ) + { + hittype[j].bposz = sprite[j].z -= l; + hittype[j].floorz = sc->floorz; + } + j = nextspritesect[j]; + } + } + } + } + break; + + case 32: // True Drop Ceiling + if(t[0] == 1) + { + // Choose dir + + if(t[2] == 1) // Retract + { + if(SA != 1536) + { + if( klabs( sc->ceilingz - s->z ) < + (SP<<1) ) + { + sc->ceilingz = s->z; + callsound(s->sectnum,i); + t[2] = 0; + t[0] = 0; + } + else sc->ceilingz += + ksgn(s->z-sc->ceilingz)*SP; + } + else + { + if( klabs( sc->ceilingz - t[1] ) < + (SP<<1) ) + { + sc->ceilingz = t[1]; + callsound(s->sectnum,i); + t[2] = 0; + t[0] = 0; + } + else sc->ceilingz += + ksgn(t[1]-sc->ceilingz)*SP; + } + break; + } + + if( (s->ang&2047) == 1536) + { + if( klabs(sc->ceilingz-s->z ) < + (SP<<1) ) + { + t[0] = 0; + t[2] = !t[2]; + callsound(s->sectnum,i); + sc->ceilingz = s->z; + } + else sc->ceilingz += + ksgn(s->z-sc->ceilingz)*SP; + } + else + { + if( klabs(sc->ceilingz-t[1] ) < (SP<<1) ) + { + t[0] = 0; + t[2] = !t[2]; + callsound(s->sectnum,i); + } + else sc->ceilingz -= ksgn(s->z-t[1])*SP; + } + } + break; + + case 33: + if( earthquaketime > 0 && (TRAND&7) == 0 ) + RANDOMSCRAP; + break; + case 36: + + if( t[0] ) + { + if( t[0] == 1 ) + shoot(i,sc->extra); + else if( t[0] == 26*5 ) + t[0] = 0; + t[0]++; + } + break; + + case 128: //SE to control glass breakage + + wal = &wall[t[2]]; + + if(wal->cstat|32) + { + wal->cstat &= (255-32); + wal->cstat |= 16; + if(wal->nextwall >= 0) + { + wall[wal->nextwall].cstat &= (255-32); + wall[wal->nextwall].cstat |= 16; + } + } + else break; + + wal->overpicnum++; + if(wal->nextwall >= 0) + wall[wal->nextwall].overpicnum++; + + if(t[0] < t[1]) t[0]++; + else + { + wal->cstat &= (128+32+8+4+2); + if(wal->nextwall >= 0) + wall[wal->nextwall].cstat &= (128+32+8+4+2); + KILLIT(i); + } + break; + + case 130: + if(t[0] > 80) { KILLIT(i); } + else t[0]++; + + x = sc->floorz-sc->ceilingz; + + if( rnd(64) ) + { + k = spawn(i,EXPLOSION2); + sprite[k].xrepeat = sprite[k].yrepeat = 2+(TRAND&7); + sprite[k].z = sc->floorz-(TRAND%x); + sprite[k].ang += 256-(TRAND%511); + sprite[k].xvel = TRAND&127; + ssp(k,CLIPMASK0); + } + break; + case 131: + if(t[0] > 40) { KILLIT(i); } + else t[0]++; + + x = sc->floorz-sc->ceilingz; + + if( rnd(32) ) + { + k = spawn(i,EXPLOSION2); + sprite[k].xrepeat = sprite[k].yrepeat = 2+(TRAND&3); + sprite[k].z = sc->floorz-(TRAND%x); + sprite[k].ang += 256-(TRAND%511); + sprite[k].xvel = TRAND&127; + ssp(k,CLIPMASK0); + } + break; + } +BOLT: + i = nexti; + } + + //Sloped sin-wave floors! + for(i=headspritestat[3];i>=0;i=nextspritestat[i]) + { + s = &sprite[i]; + if (s->lotag != 29) continue; + sc = §or[s->sectnum]; + if (sc->wallnum != 4) continue; + wal = &wall[sc->wallptr+2]; + alignflorslope(s->sectnum,wal->x,wal->y,sector[wal->nextsector].floorz); + } +} + diff --git a/polymer/eduke32/source/anim.c b/polymer/eduke32/source/anim.c new file mode 100644 index 000000000..b56d5c040 --- /dev/null +++ b/polymer/eduke32/source/anim.c @@ -0,0 +1,292 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "duke3d.h" +#include "animlib.h" + +void endanimsounds(long fr) +{ + switch(ud.volume_number) + { + case 0:break; + case 1: + switch(fr) + { + case 1: + sound(WIND_AMBIENCE); + break; + case 26: + sound(ENDSEQVOL2SND1); + break; + case 36: + sound(ENDSEQVOL2SND2); + break; + case 54: + sound(THUD); + break; + case 62: + sound(ENDSEQVOL2SND3); + break; + case 75: + sound(ENDSEQVOL2SND4); + break; + case 81: + sound(ENDSEQVOL2SND5); + break; + case 115: + sound(ENDSEQVOL2SND6); + break; + case 124: + sound(ENDSEQVOL2SND7); + break; + } + break; + case 2: + switch(fr) + { + case 1: + sound(WIND_REPEAT); + break; + case 98: + sound(DUKE_GRUNT); + break; + case 82+20: + sound(THUD); + sound(SQUISHED); + break; + case 104+20: + sound(ENDSEQVOL3SND3); + break; + case 114+20: + sound(ENDSEQVOL3SND2); + break; + case 158: + sound(PIPEBOMB_EXPLODE); + break; + } + break; + } +} + +void logoanimsounds(long fr) +{ + switch(fr) + { + case 1: + sound(FLY_BY); + break; + case 19: + sound(PIPEBOMB_EXPLODE); + break; + } +} + +void intro4animsounds(long fr) +{ + switch(fr) + { + case 1: + sound(INTRO4_B); + break; + case 12: + case 34: + sound(SHORT_CIRCUIT); + break; + case 18: + sound(INTRO4_5); + break; + } +} + +void first4animsounds(long fr) +{ + switch(fr) + { + case 1: + sound(INTRO4_1); + break; + case 12: + sound(INTRO4_2); + break; + case 7: + sound(INTRO4_3); + break; + case 26: + sound(INTRO4_4); + break; + } +} + +void intro42animsounds(long fr) +{ + switch(fr) + { + case 10: + sound(INTRO4_6); + break; + } +} + +void endanimvol41(long fr) +{ + switch(fr) + { + case 3: + sound(DUKE_UNDERWATER); + break; + case 35: + sound(VOL4ENDSND1); + break; + } +} + +void endanimvol42(long fr) +{ + switch(fr) + { + case 11: + sound(DUKE_UNDERWATER); + break; + case 20: + sound(VOL4ENDSND1); + break; + case 39: + sound(VOL4ENDSND2); + break; + case 50: + FX_StopAllSounds(); + break; + } +} + +void endanimvol43(long fr) +{ + switch(fr) + { + case 1: + sound(BOSS4_DEADSPEECH); + break; + case 40: + sound(VOL4ENDSND1); + sound(DUKE_UNDERWATER); + break; + case 50: + sound(BIGBANG); + break; + } +} + +void playanm(char *fn,char t) +{ + char *animbuf, *palptr; + long i, j, k, length=0, numframes=0; + int32 handle=-1; + + // return; + + if(t != 7 && t != 9 && t != 10 && t != 11) + KB_FlushKeyboardQueue(); + + if( KB_KeyWaiting() ) + { + FX_StopAllSounds(); + goto ENDOFANIMLOOP; + } + + handle = kopen4load(fn,0); + if(handle == -1) return; + length = kfilelength(handle); + + walock[TILE_ANIM] = 219+t; + + allocache((long *)&animbuf,length,&walock[TILE_ANIM]); + + tilesizx[TILE_ANIM] = 200; + tilesizy[TILE_ANIM] = 320; + + kread(handle,animbuf,length); + kclose(handle); + + ANIM_LoadAnim (animbuf); + numframes = ANIM_NumFrames(); + + palptr = ANIM_GetPalette(); + for(i=0;i<256;i++) + { + /* + j = (i<<2); k = j-i; + tempbuf[j+0] = (palptr[k+2]>>2); + tempbuf[j+1] = (palptr[k+1]>>2); + tempbuf[j+2] = (palptr[k+0]>>2); + tempbuf[j+3] = 0; + */ + j = i*3; + tempbuf[j+0] = (palptr[j+0]>>2); + tempbuf[j+1] = (palptr[j+1]>>2); + tempbuf[j+2] = (palptr[j+2]>>2); + } + + //setpalette(0L,256L,tempbuf); + //setbrightness(ud.brightness>>2,tempbuf,2); + setgamepalette(&ps[myconnectindex],tempbuf,2); + + ototalclock = totalclock + 10; + + for(i=1;i=20 && sprite[j].picnum<=59) + { + if(sprite[j].picnum==26) { + sprite[j].xrepeat = 8; sprite[j].yrepeat = 8; + } + else + { + sprite[j].xrepeat = 32; sprite[j].yrepeat = 32; + } + } + + } + + Bstrcpy(levelname,mapname); + pskyoff[0]=0; + for(i=0;i<8;i++) pskyoff[i]=0; + + for(i=0;i 10000 && sector[sectnum].lotag < 32767) + Bsprintf(lo,"%d 1 TIME SOUND",sector[sectnum].lotag); + if(qsetmode != 200) + Bsprintf(tempbuf,"%hu,%s",sector[sectnum].hitag,lo); + else Bstrcpy(tempbuf,lo); + } + return(tempbuf); +} + +const char *ExtGetWallCaption(short wallnum) +{ + long i=0; + + if(!(onnames==2 || onnames==4)) + { + tempbuf[0] = 0; + return(tempbuf); + } + + // HERE + + if ((wall[wallnum].lotag|wall[wallnum].hitag) == 0) + { + tempbuf[0] = 0; + } + else + { + Bsprintf(tempbuf,"%hu,%hu",wall[wallnum].hitag,wall[wallnum].lotag); + } + return(tempbuf); +} //end + +const char *SectorEffectorText(short spritenum) +{ + switch(sprite[spritenum].lotag) + { + case 0: Bsprintf(tempbuf,"SE: ROTATED SECTOR"); break; + case 1: Bsprintf(tempbuf,"SE: PIVOT SPRITE FOR SE 0"); break; + case 2: Bsprintf(tempbuf,"SE: EARTHQUAKE"); break; + case 3: Bsprintf(tempbuf,"SE: RANDOM LIGHTS AFTER SHOT OUT"); break; + case 4: Bsprintf(tempbuf,"SE: RANDOM LIGHTS"); break; + case 6: Bsprintf(tempbuf,"SE: SUBWAY"); break; + case 7: Bsprintf(tempbuf,"SE: TRANSPORT"); break; + case 8: Bsprintf(tempbuf,"SE: UP OPEN DOOR LIGHTS"); break; + case 9: Bsprintf(tempbuf,"SE: DOWN OPEN DOOR LIGHTS"); break; + case 10: Bsprintf(tempbuf,"SE: DOOR AUTO CLOSE (H=DELAY)"); break; + case 11: Bsprintf(tempbuf,"SE: ROTATE SECTOR DOOR"); break; + case 12: Bsprintf(tempbuf,"SE: LIGHT SWITCH"); break; + case 13: Bsprintf(tempbuf,"SE: EXPLOSIVE"); break; + case 14: Bsprintf(tempbuf,"SE: SUBWAY CAR"); break; + case 15: Bsprintf(tempbuf,"SE: SLIDE DOOR (ST 25)"); break; + case 16: Bsprintf(tempbuf,"SE: ROTATE REACTOR SECTOR"); break; + case 17: Bsprintf(tempbuf,"SE: ELEVATOR TRANSPORT (ST 15)"); break; + case 18: Bsprintf(tempbuf,"SE: INCREMENTAL SECTOR RISE/FALL"); break; + case 19: Bsprintf(tempbuf,"SE: CEILING FALL ON EXPLOSION"); break; + case 20: Bsprintf(tempbuf,"SE: BRIDGE (ST 27)"); break; + case 21: Bsprintf(tempbuf,"SE: DROP FLOOR (ST 28)"); break; + case 22: Bsprintf(tempbuf,"SE: TEETH DOOR (ST 29)"); break; + case 23: Bsprintf(tempbuf,"SE: 1-WAY SE7 DESTINATION (H=SE 7)"); break; + case 24: Bsprintf(tempbuf,"SE: CONVAYER BELT"); break; + case 25: Bsprintf(tempbuf,"SE: ENGINE"); break; + case 28: Bsprintf(tempbuf,"SE: LIGHTNING (H= TILE#4890)"); break; + case 27: Bsprintf(tempbuf,"SE: CAMERA FOR PLAYBACK"); break; + case 29: Bsprintf(tempbuf,"SE: FLOAT"); break; + case 30: Bsprintf(tempbuf,"SE: 2 WAY TRAIN (ST=31)"); break; + case 31: Bsprintf(tempbuf,"SE: FLOOR RISE"); break; + case 32: Bsprintf(tempbuf,"SE: CEILING FALL"); break; + case 33: Bsprintf(tempbuf,"SE: SPAWN JIB W/QUAKE"); break; + case 36: Bsprintf(tempbuf,"SE: SKRINK RAY SHOOTER"); break; + default: SpriteName(spritenum,tempbuf); break; + } + return (tempbuf); +} + +const char *ExtGetSpriteCaption(short spritenum) +{ + if((onnames!=5 && onnames!=6 &&(!(onnames==3 || onnames==4 || onnames==7 || onnames==8))) || (onnames==7 && sprite[spritenum].picnum!=1)) + { + tempbuf[0] = 0; + return(tempbuf); + } + + if (onnames==5) + { + switch(sprite[spritenum].picnum) + { + case FIRSTGUNSPRITE: + case CHAINGUNSPRITE : + case RPGSPRITE: + case FREEZESPRITE: + case SHRINKERSPRITE: + case HEAVYHBOMB: + case TRIPBOMBSPRITE: + case SHOTGUNSPRITE: + case DEVISTATORSPRITE: + case FREEZEAMMO: + case AMMO: + case BATTERYAMMO: + case DEVISTATORAMMO: + case RPGAMMO: + case GROWAMMO: + case CRYSTALAMMO: + case HBOMBAMMO: + case AMMOLOTS: + case SHOTGUNAMMO: + case COLA: + case SIXPAK: + case FIRSTAID: + case SHIELD: + case STEROIDS: + case AIRTANK: + case JETPACK: + case HEATSENSOR: + case ACCESSCARD: + case BOOTS: + break; + default: + { + tempbuf[0] = 0; + return(tempbuf); + } + } + } + + if( onnames==6 && sprite[spritenum].picnum != sprite[cursprite].picnum) + { + tempbuf[0] = 0; + return(tempbuf); + } + + tempbuf[0] = 0; + if ((sprite[spritenum].lotag|sprite[spritenum].hitag) == 0) + { + SpriteName(spritenum,lo); + if(lo[0]!=0) + { + if(sprite[spritenum].pal==1) Bsprintf(tempbuf,"%s (MULTIPLAYER)",lo); + else Bsprintf(tempbuf,"%s",lo); + } + } + else + if(sprite[spritenum].picnum==SECTOREFFECTOR) + { + if (onnames==8) + tempbuf[0] = 0; + else + { + Bsprintf(lo,"%s: %hu",SectorEffectorText(spritenum),sprite[spritenum].lotag); + Bsprintf(tempbuf,"%s, %hu",lo,sprite[spritenum].hitag); + } + } + else + { + SpriteName(spritenum,lo); + if (sprite[spritenum].extra != -1) + Bsprintf(tempbuf,"%hu,%hu,%d %s",sprite[spritenum].hitag,sprite[spritenum].lotag,sprite[spritenum].extra,lo); + else + Bsprintf(tempbuf,"%hu,%hu %s",sprite[spritenum].hitag,sprite[spritenum].lotag,lo); + } + return(tempbuf); + +} //end + +//printext16 parameters: +//printext16(long xpos, long ypos, short col, short backcol, +// char name[82], char fontsize) +// xpos 0-639 (top left) +// ypos 0-479 (top left) +// col 0-15 +// backcol 0-15, -1 is transparent background +// name +// fontsize 0=8*8, 1=3*5 + +//drawline16 parameters: +// drawline16(long x1, long y1, long x2, long y2, char col) +// x1, x2 0-639 +// y1, y2 0-143 (status bar is 144 high, origin is top-left of STATUS BAR) +// col 0-15 + +void ExtShowSectorData(short sectnum) //F5 +{ + short statnum=0; + int x,x2,y; + int nexti; + int i,c=0; + int secrets=0; + int totalactors1=0,totalactors2=0,totalactors3=0,totalactors4=0; + int totalrespawn=0; + + if(qsetmode==200) + return; + + for(i=0;ixmax) xmax=x; + } + tempbuf[x]=0; + printext16(xx*4,ydim16+(y*6)+2,11,-1,tempbuf,1); + x=0; y++; + if(y>18) {col++; y=6; xx+=xmax; xmax=0; + } + } + enddrawing(); + + kclose(fp); + +}// end Show2dText + +void Show3dText(char *name) +{ + int i,fp; + char x=0,y=4,xmax=0,xx=0,col=0; + int t; + if((fp=kopen4load(name,0)) == -1) + { + begindrawing(); + printext256(1*4,4*8,whitecol,-1,"ERROR: file not found.",0); + enddrawing(); + return; + } + t=65; + begindrawing(); + while(t!=EOF && col<5) + { + t = 0; + if (kread(fp,&t,1)<=0) + t = EOF; + while(t!=EOF && t!='\n' && x<250) + { + tempbuf[x]=t; + t = 0; if (kread(fp,&t,1)<=0) t = EOF; + x++; if(x>xmax) xmax=x; + } + tempbuf[x]=0; + printext256(xx*4,(y*6)+2,whitecol,-1,tempbuf,1); + x=0; y++; + if(y>18) {col++; y=6; xx+=xmax; xmax=0; + } + } + enddrawing(); + + kclose(fp); +}// end Show3dText + +void ShowHelpText(char *name) +{ + BFILE *fp; + int i,t; + char x=0,y=4,xmax=0,xx=0,col=0; + if((fp=fopenfrompath("helpdoc.txt","rb")) == NULL) + { + begindrawing(); + printext256(1*4,4*8,whitecol,-1,"ERROR: file not found.",0); + enddrawing(); + return; + } + /* + Bfgets(tempbuf,80,fp); + while(!Bfeof(fp) && Bstrcmp(tempbuf,"SectorEffector")) + { + Bfgets(tempbuf,80,fp); + } + */ + y=2; + Bfgets(tempbuf,80,fp); + Bstrcat(tempbuf,"\n"); + begindrawing(); + while(!Bfeof(fp) && !(Bstrcmp(tempbuf,"SectorEffector")==0)) + { + Bfgets(tempbuf,80,fp); + Bstrcat(tempbuf,"\n"); + printext256(x*4,(y*6)+2,whitecol,-1,tempbuf,1); + y++; + } + enddrawing(); + + Bfclose(fp); +}// end ShowHelpText + +void ExtShowSpriteData(short spritenum) //F6 +{ + if (qsetmode != 200) + Show2dText("sehelp.hlp"); + /* if (qsetmode == 200) // In 3D mode + return; + + while (KEY_PRESSED(KEYSC_F6)); + ResetKeys(); + ContextHelp(spritenum); // Get context sensitive help */ +}// end ExtShowSpriteData + +// Floor Over Floor (duke3d) + +// If standing in sector with SE42 or SE44 +// then draw viewing to SE41 and raise all =hi SE43 cielings. + +// If standing in sector with SE43 or SE45 +// then draw viewing to SE40 and lower all =hi SE42 floors. + +int fofsizex = -1; +int fofsizey = -1; +void ResetFOFSize() +{ + if (fofsizex != -1) tilesizx[FOF] = fofsizex; + if (fofsizey != -1) tilesizy[FOF] = fofsizey; +} + +static void ExtSE40Draw(int spnum,long x,long y,long z,short a,short h) +{ + static long tempsectorz[MAXSECTORS]; + static long tempsectorpicnum[MAXSECTORS]; + + int i=0,j=0,k=0; + int floor1=0,floor2=0,ok=0,fofmode=0,draw_both=0; + long offx,offy,offz; + + if(sprite[spnum].ang!=512) return; + + // Things are a little different now, as we allow for masked transparent + // floors and ceilings. So the FOF textures is no longer required + // if (!(gotpic[FOF>>3]&(1<<(FOF&7)))) + // return; + // gotpic[FOF>>3] &= ~(1<<(FOF&7)); + + if (tilesizx[562]) + { + fofsizex = tilesizx[562]; + tilesizx[562] = 0; + } + if (tilesizy[562]) + { + fofsizey = tilesizy[562]; + tilesizy[562] = 0; + } + + floor1=spnum; + + if(sprite[spnum].lotag==42) fofmode=40; + if(sprite[spnum].lotag==43) fofmode=41; + if(sprite[spnum].lotag==44) fofmode=40; + if(sprite[spnum].lotag==45) fofmode=41; + + // fofmode=sprite[spnum].lotag-2; + + // sectnum=sprite[j].sectnum; + // sectnum=cursectnum; + ok++; + + /* recursive? + for(j=0;j= 1024) + offz = sprite[floor2].z; + else if (fofmode==41) + offz = sector[sprite[floor2].sectnum].floorz; + else + offz = sector[sprite[floor2].sectnum].ceilingz; + + if (sprite[floor1].ang >= 1024) + offz -= sprite[floor1].z; + else if (fofmode==40) + offz -= sector[sprite[floor1].sectnum].floorz; + else + offz -= sector[sprite[floor1].sectnum].ceilingz; + + // if(ok==2) { Message("no floor2",RED); return; } + + for(j=0;j 0) //ALT + { + keystatus[67] = 0; + wallsprite=0; + curwall = 0; + curwallnum = 0; + cursearchspritenum = 0; + cursectornum=0; + cursector_lotag = sector[sectnum].lotag; + cursector_lotag=getnumber16("Enter search sector lotag : ", cursector_lotag, 65536L,0); + Bsprintf(tempbuf,"Search sector lotag %d",cursector_lotag); + printmessage16(tempbuf); + } + else EditSectorData(sectnum); +}// end ExtEditSectorData + +void ExtEditWallData(short wallnum) //F8 +{ + if(qsetmode==200) + return; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT + { + wallsprite=1; + curwall = wallnum; + curwallnum = 0; + cursearchspritenum = 0; + cursectornum = 0; + search_lotag = wall[curwall].lotag; + search_hitag = wall[curwall].hitag; + search_lotag=getnumber16("Enter wall search lotag : ", search_lotag, 65536L,0); + search_hitag=getnumber16("Enter wall search hitag : ", search_hitag, 65536L,0); + // Bsprintf(tempbuf,"Current wall %d lo=%d hi=%d", + // curwall,wall[curwall].lotag,wall[curwall].hitag); + Bsprintf(tempbuf,"Search wall lo=%d hi=%d",search_lotag,search_hitag); + printmessage16(tempbuf); + } + else EditWallData(wallnum); +} + +void ExtEditSpriteData(short spritenum) //F8 +{ + if(qsetmode==200) + return; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT + { + wallsprite=2; + cursearchsprite = spritenum; + curwallnum = 0; + cursearchspritenum = 0; + cursectornum = 0; + search_lotag = sprite[cursearchsprite].lotag; + search_hitag = sprite[cursearchsprite].hitag; + search_lotag=getnumber16("Enter sprite search lotag : ", search_lotag, 65536L,0); + search_hitag=getnumber16("Enter sprite search hitag : ", search_hitag, 65536L,0); + Bsprintf(tempbuf,"Search sprite lo=%d hi=%d",search_lotag,search_hitag); + printmessage16(tempbuf); + } + else EditSpriteData(spritenum); +} + +void PrintStatus(char *string,int num,char x,char y,char color) +{ + Bsprintf(tempbuf,"%s %d",string,num); + begindrawing(); + printext16(x*8,ydim16+y*8,color,-1,tempbuf,0); + enddrawing(); +} + +void SpriteName(short spritenum, char *lo2) +{ + Bsprintf(lo2,names[sprite[spritenum].picnum]); +}// end SpriteName + +void ReadPaletteTable() +{ + int i,j,fp; + char lookup_num; + if((fp=kopen4load("lookup.dat",0)) == -1) + { + if((fp=kopen4load("lookup.dat",1)) == -1) + { + initprintf("LOOKUP.DAT not found, creating dummy palette lookups\n"); + for(i=0;i<256;i++) + tempbuf[i] = ((i+32)&255); //remap colors for screwy palette sectors + makepalookup(MAXPALOOKUPS,tempbuf,0,0,0,1); + return; + } + } + initprintf("Loading palette lookups... "); + kread(fp,&num_tables,1); + for(j=0;j 640); + + if(totalclock > lastupdate) + { + mousecol += mouseadd; + if(mousecol >= 30 || mousecol <= 0) + { + mouseadd = -mouseadd; + mousecol += mouseadd; + } + lastupdate = totalclock + 3; + } + + switch(whitecol) + { + case 1: // Shadow Warrior + col = whitecol+mousecol; + break; + case 31: // Duke Nukem 3D + col = whitecol-mousecol; + break; + default: + col = whitecol; + break; + } + + if(col != whitecol) + { + for(i=(j?3:2);i<=(j?7:3);i++) + { + plotpixel(searchx+i,searchy,col); + plotpixel(searchx-i,searchy,col); + plotpixel(searchx,searchy-i,col); + plotpixel(searchx,searchy+i,col); + } + for(i=1;i<=(j?2:1);i++) + { + plotpixel(searchx+i,searchy,whitecol); + plotpixel(searchx-i,searchy,whitecol); + plotpixel(searchx,searchy-i,whitecol); + plotpixel(searchx,searchy+i,whitecol); + } + i=(j?8:4); + plotpixel(searchx+i,searchy,0); + plotpixel(searchx-i,searchy,0); + plotpixel(searchx,searchy-i,0); + plotpixel(searchx,searchy+i,0); + } +} + +int AskIfSure(void) +{ + int retval=0; + + begindrawing(); //{{{ + printext256(0,0,whitecol,0,"Are you sure you want to proceed?",0); + enddrawing(); //}}} + + showframe(1); + + while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]) == 0) + { + if (handleevents()) { + if (quitevent) { + retval = 0; + break; + } + } + if (keystatus[0x15] != 0) { + keystatus[0x15] = 0; + retval = 0; break; + } + } + while(keystatus[1]) + { + keystatus[1] = 0; + retval = 1; + break; + } + return(retval); +} + +void Keys3d(void) +{ + long i,count,rate,nexti; + short statnum=0; + + char smooshyalign=0, repeatpanalign=0, *ptr, buffer[80]; + short sectnum, nextsectnum, startwall, endwall, dasector, daang; + long j, k, cnt, templong, doubvel, changedir, wallfind[2], daz[2]; + long dashade[2], goalz, xvect, yvect, hiz, loz; + short hitsect, hitwall, hitsprite; + long hitx, hity, hitz, dax, day, hihit, lohit; + long repeatcountx=0,repeatcounty=0; + + /* start Mapster32 */ + + if (sidemode != 0) + { + setviewback(); + rotatesprite(320<<15,200<<15,65536,(horiz-100)<<2,4094,0,0,2+4,0,0,0,0); + lockbyte4094 = 0; + searchx = ydim-1-searchx; + searchx ^= searchy; searchy ^= searchx; searchx ^= searchy; + + // overwritesprite(160L,170L,1153,0,1+2,0); + rotatesprite(160<<16,170<<16,65536,(100-horiz+1024)<<3,1153,0,0,2,0,0,0,0); + + } + + if(usedcount && !helpon) + { + if(searchstat!=3) + { + count=0; + for(i=0;i640?0:1; + i = (ydimgame>>6)+(j<<2); + printext256((xdimgame>>6)+2,ydimgame-(ydimgame>>1)+2,0,-1,"Clipboard",j); + printext256((xdimgame>>6),ydimgame-(ydimgame>>1),whitecol,-1,"Clipboard",j); + Bsprintf(tempbuf,"Pic: %d %s",temppicnum,names[temppicnum]); + printext256((xdimgame>>6)+2,ydimgame-(ydimgame>>1)+2+i+i,0,-1,tempbuf,j); + printext256((xdimgame>>6),ydimgame-(ydimgame>>1)+i+i,whitecol,-1,tempbuf,j); + Bsprintf(tempbuf,"Shd: %d",tempshade); + printext256((xdimgame>>6)+2,ydimgame-(ydimgame>>1)+2+i+i+i,0,-1,tempbuf,j); + printext256((xdimgame>>6),ydimgame-(ydimgame>>1)+i+i+i,whitecol,-1,tempbuf,j); + Bsprintf(tempbuf,"Pal: %d",temppal); + printext256((xdimgame>>6)+2,ydimgame-(ydimgame>>1)+2+i+i+i+i,0,-1,tempbuf,j); + printext256((xdimgame>>6),ydimgame-(ydimgame>>1)+i+i+i+i,whitecol,-1,tempbuf,j); + Bsprintf(tempbuf,"Cst: %d",tempcstat); + printext256((xdimgame>>6)+2,ydimgame-(ydimgame>>1)+2+i+i+i+i+i,0,-1,tempbuf,j); + printext256((xdimgame>>6),ydimgame-(ydimgame>>1)+i+i+i+i+i,whitecol,-1,tempbuf,j); + Bsprintf(tempbuf,"Lot: %d",templotag); + printext256((xdimgame>>6)+2,ydimgame-(ydimgame>>1)+2+i+i+i+i+i+i,0,-1,tempbuf,j); + printext256((xdimgame>>6),ydimgame-(ydimgame>>1)+i+i+i+i+i+i,whitecol,-1,tempbuf,j); + Bsprintf(tempbuf,"Hit: %d",temphitag); + printext256((xdimgame>>6)+2,ydimgame-(ydimgame>>1)+2+i+i+i+i+i+i+i,0,-1,tempbuf,j); + printext256((xdimgame>>6),ydimgame-(ydimgame>>1)+i+i+i+i+i+i+i,whitecol,-1,tempbuf,j); + Bsprintf(tempbuf,"Ext: %d",tempextra); + printext256((xdimgame>>6)+2,ydimgame-(ydimgame>>1)+2+i+i+i+i+i+i+i+i,0,-1,tempbuf,j); + printext256((xdimgame>>6),ydimgame-(ydimgame>>1)+i+i+i+i+i+i+i+i,whitecol,-1,tempbuf,j); + enddrawing(); + }// end if usedcount + + if ((totalclock > (lastmessagetime + 120*3))) + { + char msgbuf[2048]; + switch (searchstat) + { + case 0: + case 4: + { + long dax, day, dist; + dax = wall[searchwall].x-wall[wall[searchwall].point2].x; + day = wall[searchwall].y-wall[wall[searchwall].point2].y; + dist = ksqrt(dax*dax+day*day); + Bsprintf(msgbuf,"Wall %d: length:%ld lo:%d hi:%d",searchwall,dist,wall[searchwall].lotag,wall[searchwall].hitag); + _message(msgbuf); + break; + } + case 1: + Bsprintf(msgbuf,"Sector %d ceiling: lo:%s hi:%d",searchsector,ExtGetSectorCaption(searchsector),sector[searchsector].hitag); + _message(msgbuf); + break; + case 2: + Bsprintf(msgbuf,"Sector %d floor: lo:%s hi:%d",searchsector,ExtGetSectorCaption(searchsector),sector[searchsector].hitag); + _message(msgbuf); + break; + case 3: + { + if (strlen(names[sprite[searchwall].picnum]) > 0) { + if (sprite[searchwall].picnum==SECTOREFFECTOR) + Bsprintf(msgbuf,"Sprite %d %s: lo:%d hi:%d",searchwall,SectorEffectorText(searchwall),sprite[searchwall].lotag,sprite[searchwall].hitag); + else Bsprintf(msgbuf,"Sprite %d %s: lo:%d hi:%d ex:%d",searchwall,names[sprite[searchwall].picnum],sprite[searchwall].lotag,sprite[searchwall].hitag,sprite[searchwall].extra); + } + else Bsprintf(msgbuf,"Sprite %d picnum %d: lo:%d hi:%d ex:%d",searchwall,sprite[searchwall].picnum,sprite[searchwall].lotag,sprite[searchwall].hitag,sprite[searchwall].extra); + _message(msgbuf); + break; + } + } + } + + if (keystatus[0x4] > 0) /* 3 (toggle floor-over-floor (cduke3d only) */ + { + floor_over_floor = !floor_over_floor; + if (!floor_over_floor) ResetFOFSize(); + keystatus[0x4] = 0; + } + + if (keystatus[KEYSC_F3]) + { + mlook = 1-mlook; + Bsprintf(tempbuf,"Mouselook: %d",mlook); + message(tempbuf); + keystatus[KEYSC_F3] = 0; + } + + // 'P - Will copy palette to all sectors highlighted with R-Alt key + if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_P]) // ' P + { + short w, start_wall, end_wall, currsector; + unsigned char pal; + + keystatus[KEYSC_P] = 0; + + if(highlightsectorcnt == -1) + { + message("You didn't select any sectors!"); + return; + } + + pal = (unsigned char)getnumber256("Palette: ",0,MAXPALOOKUPS,0); + if(AskIfSure()) return; + + for (i = 0; i < highlightsectorcnt; i++) + { + currsector = highlightsector[i]; + sector[currsector].ceilingpal = pal; + sector[currsector].floorpal = pal; + // Do all the walls in the sector + start_wall = sector[currsector].wallptr; + end_wall = start_wall + sector[currsector].wallnum; + + for (w = start_wall; w < end_wall; w++) + { + wall[w].pal = pal; + } + } + message("Palettes changed"); + } + + // ;P - Will copy palette to all sectors & sprites within highlighted with R-Alt key + if (keystatus[KEYSC_SEMI] && keystatus[KEYSC_P]) // ; P + { + short w, start_wall, end_wall, currsector; + unsigned char pal; + + keystatus[KEYSC_P] = 0; + + if(highlightsectorcnt == -1) + { + message("You didn't select any sectors!"); + return; + } + + pal = (unsigned char)getnumber256("Palette: ",0,MAXPALOOKUPS,0); + if(AskIfSure()) return; + + for (i = 0; i < highlightsectorcnt; i++) + { + currsector = highlightsector[i]; + sector[currsector].ceilingpal = pal; + sector[currsector].floorpal = pal; + // Do all the walls in the sector + start_wall = sector[currsector].wallptr; + end_wall = start_wall + sector[currsector].wallnum; + for (w = start_wall; w < end_wall; w++) + { + wall[w].pal = pal; + } + for (k=0;k= 0) + { + j = nextspritesect[w]; + sprite[i].pal = pal; + w = j; + } + } + } + message("Palettes changed"); + } + + if (keystatus[KEYSC_SEMI] && keystatus[KEYSC_V]) // ; V + { + short w, start_wall, end_wall, currsector; + unsigned char visval; + + keystatus[KEYSC_V] = 0; + + if(highlightsectorcnt == -1) + { + message("You didn't select any sectors!"); + return; + } + visval = (unsigned char)getnumber256("Visibility of selected sectors: ",sector[searchsector].visibility,255,0); + if(AskIfSure()) return; + + for (i = 0; i < highlightsectorcnt; i++) + { + currsector = highlightsector[i]; + sector[currsector].visibility = visval; + } + message("Visibility changed on all selected sectors"); + } + + + if (keystatus[0xd3] > 0) + { + if (searchstat == 3) + { + deletesprite(searchwall); + updatenumsprites(); + Bsprintf(tempbuf,"Sprite (%d) deleted",searchwall); + message(tempbuf); + asksave = 1; + } + keystatus[0xd3] = 0; + } + + if (keystatus[KEYSC_F6] > 0) //F6 + { + keystatus[KEYSC_F6] = 0; + autospritehelp=!autospritehelp; + Bsprintf(tempbuf,"Automatic SECTOREFFECTOR help: %d",autospritehelp); + message(tempbuf); + } + if (keystatus[KEYSC_F7] > 0) //F7 + { + keystatus[KEYSC_F7] = 0; + autosecthelp=!autosecthelp; + Bsprintf(tempbuf,"Automatic sector tag help: %d",autosecthelp); + message(tempbuf); + + } + + if ((searchstat == 3) && (sprite[searchwall].picnum==SECTOREFFECTOR)) + if (autospritehelp && helpon==0) Show3dText("sehelp.hlp"); + + if (searchstat == 1 || searchstat == 2) + if (autosecthelp && helpon==0) Show3dText("sthelp.hlp"); + + + + if (keystatus[0x33] > 0) // , Search & fix panning to the left (3D) + { + if (searchstat == 3) + { + i = searchwall; + if ((keystatus[0x2a]|keystatus[0x36]) > 0) + sprite[i].ang = ((sprite[i].ang+2048-1)&2047); + else + { + sprite[i].ang = ((sprite[i].ang+2048-128)&2047); + keystatus[0x33] = 0; + } + Bsprintf(tempbuf,"Sprite (%ld) angle: %d",i,sprite[i].ang); + message(tempbuf); + } + } + if (keystatus[0x34] > 0) // . Search & fix panning to the right (3D) + { + if ((searchstat == 0) || (searchstat == 4)) + { + AutoAlignWalls((long)searchwall,0L); + keystatus[0x34] = 0; + } + if (searchstat == 3) + { + i = searchwall; + if ((keystatus[0x2a]|keystatus[0x36]) > 0) + sprite[i].ang = ((sprite[i].ang+2048+1)&2047); + else + { + sprite[i].ang = ((sprite[i].ang+2048+128)&2047); + keystatus[0x34] = 0; + } + Bsprintf(tempbuf,"Sprite (%ld) angle: %d",i,sprite[i].ang); + message(tempbuf); + } + } + + if ((keystatus[KEYSC_L] > 0) && (keystatus[KEYSC_QUOTE] > 0)) // ' L + { + switch (searchstat) + { + case 1: + strcpy(tempbuf,"Sector ceilingz: "); + sector[searchsector].ceilingz = getnumber256(tempbuf,sector[searchsector].ceilingz,8388608,1); + if (!(sector[searchsector].ceilingstat&2)) + sector[searchsector].ceilingheinum = 0; + + strcpy(tempbuf,"Sector ceiling slope: "); + sector[searchsector].ceilingheinum = getnumber256(tempbuf,sector[searchsector].ceilingheinum,8388608,1); + break; + case 2: + strcpy(tempbuf,"Sector floorz: "); + sector[searchsector].floorz = getnumber256(tempbuf,sector[searchsector].floorz,8388608,1); + if (!(sector[searchsector].floorstat&2)) + sector[searchsector].floorheinum = 0; + strcpy(tempbuf,"Sector floor slope: "); + sector[searchsector].floorheinum = getnumber256(tempbuf,sector[searchsector].floorheinum,8388608,1); + break; + case 3: + strcpy(tempbuf,"Sprite x: "); + sprite[searchwall].x = getnumber256(tempbuf,sprite[searchwall].x,131072,1); + strcpy(tempbuf,"Sprite y: "); + sprite[searchwall].y = getnumber256(tempbuf,sprite[searchwall].y,131072,1); + strcpy(tempbuf,"Sprite z: "); + sprite[searchwall].z = getnumber256(tempbuf,sprite[searchwall].z,8388608,1); + strcpy(tempbuf,"Sprite angle: "); + sprite[searchwall].ang = getnumber256(tempbuf,sprite[searchwall].ang,2048L,0); + break; + } + if (sector[searchsector].ceilingheinum == 0) + sector[searchsector].ceilingstat &= ~2; + else + sector[searchsector].ceilingstat |= 2; + + if (sector[searchsector].floorheinum == 0) + sector[searchsector].floorstat &= ~2; + else + sector[searchsector].floorstat |= 2; + asksave = 1; + keystatus[KEYSC_L] = 0; + } + + if ((keystatus[KEYSC_G] > 0)) // G + { + switch (searchstat) + { + case 0: + strcpy(tempbuf,"Wall picnum: "); + i = getnumber256(tempbuf,wall[searchwall].picnum,MAXTILES-1,0); + if(tilesizx[i] != 0) + wall[searchwall].picnum = i; + break; + case 1: + strcpy(tempbuf,"Sector ceiling picnum: "); + i = getnumber256(tempbuf,sector[searchsector].ceilingpicnum,MAXTILES-1,0); + if(tilesizx[i] != 0) + sector[searchsector].ceilingpicnum = i; + break; + case 2: + strcpy(tempbuf,"Sector floor picnum: "); + i = getnumber256(tempbuf,sector[searchsector].floorpicnum,MAXTILES-1,0); + if(tilesizx[i] != 0) + sector[searchsector].floorpicnum = i; + break; + case 3: + strcpy(tempbuf,"Sprite picnum: "); + i = getnumber256(tempbuf,sprite[searchwall].picnum,MAXTILES-1,0); + if(tilesizx[i] != 0) + sprite[searchwall].picnum = i; + break; + case 4: + strcpy(tempbuf,"Masked wall picnum: "); + i = getnumber256(tempbuf,wall[searchwall].overpicnum,MAXTILES-1,0); + if(tilesizx[i] != 0) + wall[searchwall].overpicnum = i; + break; + } + asksave = 1; + keystatus[KEYSC_G] = 0; + } + + getzrange(posx,posy,posz,cursectnum,&hiz,&hihit,&loz,&lohit,128L,CLIPMASK0); + + if (keystatus[KEYSC_CAPS] > 0) + { + zmode++; + if (zmode == 3) zmode = 0; + else if (zmode == 1) zlock = (loz-posz)&0xfffffc00; + if (zmode == 0) message("Zmode = Gravity"); + else if (zmode == 1) message("Zmode = Locked/Sector"); + else if (zmode == 2) message("Zmode = Locked/Free"); + keystatus[KEYSC_CAPS] = 0; + } + + + + if (keystatus[KEYSC_B] > 0) // B (clip Blocking xor) (3D) + { + if (searchstat == 3) + { + sprite[searchwall].cstat ^= 1; + // sprite[searchwall].cstat &= ~256; + // sprite[searchwall].cstat |= ((sprite[searchwall].cstat&1)<<8); + sprintf(getmessage,"Sprite (%d) blocking %s",searchwall,sprite[searchwall].cstat&1?"ON":"OFF"); + message(getmessage); + asksave = 1; + } + else + { + wall[searchwall].cstat ^= 1; + // wall[searchwall].cstat &= ~64; + if ((wall[searchwall].nextwall >= 0) && ((keystatus[0x2a]|keystatus[0x36]) == 0)) + { + wall[wall[searchwall].nextwall].cstat &= ~(1+64); + wall[wall[searchwall].nextwall].cstat |= (wall[searchwall].cstat&1); + } + sprintf(getmessage,"Wall (%d) blocking %s",searchwall,wall[searchwall].cstat&1?"ON":"OFF"); + message(getmessage); + asksave = 1; + } + keystatus[KEYSC_B] = 0; + } + if (keystatus[KEYSC_T] > 0) // T (transluscence for sprites/masked walls) + { + if (searchstat == 1) //Set masked/transluscent ceilings/floors + { + i = (sector[searchsector].ceilingstat&(128+256)); + sector[searchsector].ceilingstat &= ~(128+256); + switch(i) + { + case 0: sector[searchsector].ceilingstat |= 128; break; + case 128: sector[searchsector].ceilingstat |= 256; break; + case 256: sector[searchsector].ceilingstat |= 384; break; + case 384: sector[searchsector].ceilingstat |= 0; break; + } + asksave = 1; + } + if (searchstat == 2) + { + i = (sector[searchsector].floorstat&(128+256)); + sector[searchsector].floorstat &= ~(128+256); + switch(i) + { + case 0: sector[searchsector].floorstat |= 128; break; + case 128: sector[searchsector].floorstat |= 256; break; + case 256: sector[searchsector].floorstat |= 384; break; + case 384: sector[searchsector].floorstat |= 0; break; + } + asksave = 1; + } + + if ((keystatus[KEYSC_QUOTE]) > 0) + { + switch (searchstat) + { + case 0: case 4: + strcpy(buffer,"Wall lotag: "); + wall[searchwall].lotag = getnumber256(buffer,(long)wall[searchwall].lotag,65536L,0); + break; + case 1: + strcpy(buffer,"Sector lotag: "); + sector[searchsector].lotag = getnumber256(buffer,(long)sector[searchsector].lotag,65536L,0); + break; + case 2: + strcpy(buffer,"Sector lotag: "); + sector[searchsector].lotag = getnumber256(buffer,(long)sector[searchsector].lotag,65536L,0); + break; + case 3: + strcpy(buffer,"Sprite lotag: "); + sprite[searchwall].lotag = getnumber256(buffer,(long)sprite[searchwall].lotag,65536L,0); + break; + } + } + else + { + if (searchstat == 3) + { + if ((sprite[searchwall].cstat&2) == 0) + sprite[searchwall].cstat |= 2; + else if ((sprite[searchwall].cstat&512) == 0) + sprite[searchwall].cstat |= 512; + else + sprite[searchwall].cstat &= ~(2+512); + asksave = 1; + } + if (searchstat == 4) + { + if ((wall[searchwall].cstat&128) == 0) + wall[searchwall].cstat |= 128; + else if ((wall[searchwall].cstat&512) == 0) + wall[searchwall].cstat |= 512; + else + wall[searchwall].cstat &= ~(128+512); + + if (wall[searchwall].nextwall >= 0) + { + wall[wall[searchwall].nextwall].cstat &= ~(128+512); + wall[wall[searchwall].nextwall].cstat |= (wall[searchwall].cstat&(128+512)); + } + asksave = 1; + } + } + keystatus[KEYSC_T] = 0; + } + + + if (keystatus[KEYSC_M] > 0 && (keystatus[KEYSC_QUOTE]) > 0) // M + { + switch (searchstat) + { + case 0: case 4: + strcpy(buffer,"Wall extra: "); + wall[searchwall].extra = getnumber256(buffer,(long)wall[searchwall].extra,65536L,1); + break; + case 1: + strcpy(buffer,"Sector extra: "); + sector[searchsector].extra = getnumber256(buffer,(long)sector[searchsector].extra,65536L,1); + break; + case 2: + strcpy(buffer,"Sector extra: "); + sector[searchsector].extra = getnumber256(buffer,(long)sector[searchsector].extra,65536L,1); + break; + case 3: + strcpy(buffer,"Sprite extra: "); + sprite[searchwall].extra = getnumber256(buffer,(long)sprite[searchwall].extra,65536L,1); + break; + } + asksave = 1; + keystatus[KEYSC_M] = 0; + } + + if (keystatus[KEYSC_1] > 0) // 1 (make 1-way wall) + { + if (searchstat != 3) + { + wall[searchwall].cstat ^= 32; + sprintf(getmessage,"Wall (%d) 1 side masking %s",searchwall,wall[searchwall].cstat&32?"ON":"OFF"); + message(getmessage); + asksave = 1; + } + else + { + sprite[searchwall].cstat ^= 64; + i = sprite[searchwall].cstat; + if ((i&48) == 32) + { + sprite[searchwall].cstat &= ~8; + if ((i&64) > 0) + if (posz > sprite[searchwall].z) + sprite[searchwall].cstat |= 8; + } + asksave = 1; + sprintf(getmessage,"Sprite (%d) 1 sided %s",searchwall,sprite[searchwall].cstat&64?"ON":"OFF"); + message(getmessage); + + } + keystatus[KEYSC_1] = 0; + } + if (keystatus[KEYSC_2] > 0) // 2 (bottom wall swapping) + { + if (searchstat != 3) + { + wall[searchwall].cstat ^= 2; + sprintf(getmessage,"Wall (%d) bottom texture swap %s",searchwall,wall[searchwall].cstat&2?"ON":"OFF"); + message(getmessage); + asksave = 1; + } + keystatus[KEYSC_2] = 0; + } + if (keystatus[KEYSC_O] > 0) // O (top/bottom orientation - for doors) + { + if ((searchstat == 0) || (searchstat == 4)) + { + wall[searchwall].cstat ^= 4; + asksave = 1; + } + if (searchstat == 3) // O (ornament onto wall) (2D) + { + asksave = 1; + i = searchwall; + + hitscan(sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].sectnum, + sintable[(sprite[i].ang+2560+1024)&2047], + sintable[(sprite[i].ang+2048+1024)&2047], + 0, + &hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + + sprite[i].x = hitx; + sprite[i].y = hity; + sprite[i].z = hitz; + changespritesect(i,hitsect); + if (hitwall >= 0) + sprite[i].ang = ((getangle(wall[wall[hitwall].point2].x-wall[hitwall].x,wall[wall[hitwall].point2].y-wall[hitwall].y)+512)&2047); + + //Make sure sprite's in right sector + if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) + { + j = wall[hitwall].point2; + sprite[i].x -= ksgn(wall[j].y-wall[hitwall].y); + sprite[i].y += ksgn(wall[j].x-wall[hitwall].x); + } + } + keystatus[KEYSC_O] = 0; + } + if (keystatus[KEYSC_M] > 0) // M (masking walls) + { + if (searchstat != 3) + { + i = wall[searchwall].nextwall; + templong = (keystatus[0x2a]|keystatus[0x36]); + if (i >= 0) + { + wall[searchwall].cstat ^= 16; + sprintf(getmessage,"Wall (%d) masking %s",searchwall,wall[searchwall].cstat&16?"ON":"OFF"); + message(getmessage); + if ((wall[searchwall].cstat&16) > 0) + { + wall[searchwall].cstat &= ~8; + if (templong == 0) + { + wall[i].cstat |= 8; //auto other-side flip + wall[i].cstat |= 16; + wall[i].overpicnum = wall[searchwall].overpicnum; + } + } + else + { + wall[searchwall].cstat &= ~8; + if (templong == 0) + { + wall[i].cstat &= ~8; //auto other-side unflip + wall[i].cstat &= ~16; + } + } + wall[searchwall].cstat &= ~32; + if (templong == 0) wall[i].cstat &= ~32; + asksave = 1; + } + } + keystatus[KEYSC_M] = 0; + } + + if (keystatus[KEYSC_H] > 0) // H (hitscan sensitivity) + { + if ((keystatus[KEYSC_QUOTE]) > 0) + { + switch (searchstat) + { + case 0: case 4: + strcpy(buffer,"Wall hitag: "); + wall[searchwall].hitag = getnumber256(buffer,(long)wall[searchwall].hitag,65536L,0); + break; + case 1: + strcpy(buffer,"Sector hitag: "); + sector[searchsector].hitag = getnumber256(buffer,(long)sector[searchsector].hitag,65536L,0); + break; + case 2: + strcpy(buffer,"Sector hitag: "); + sector[searchsector].hitag = getnumber256(buffer,(long)sector[searchsector].hitag,65536L,0); + break; + case 3: + strcpy(buffer,"Sprite hitag: "); + sprite[searchwall].hitag = getnumber256(buffer,(long)sprite[searchwall].hitag,65536L,0); + break; + } + } + + else + { + + if (searchstat == 3) + { + sprite[searchwall].cstat ^= 256; + sprintf(getmessage,"Sprite (%d) hitscan sensitivity %s",searchwall,sprite[searchwall].cstat&256?"ON":"OFF"); + message(getmessage); + asksave = 1; + } + else + { + wall[searchwall].cstat ^= 64; + + if ((wall[searchwall].nextwall >= 0) && ((keystatus[0x2a]|keystatus[0x36]) == 0)) + { + wall[wall[searchwall].nextwall].cstat &= ~64; + wall[wall[searchwall].nextwall].cstat |= (wall[searchwall].cstat&64); + } + sprintf(getmessage,"Wall (%d) hitscan sensitivity %s",searchwall,wall[searchwall].cstat&64?"ON":"OFF"); + message(getmessage); + + asksave = 1; + } + } + keystatus[KEYSC_H] = 0; + } + + smooshyalign = keystatus[0x4c]; + repeatpanalign = (keystatus[0x2a]|keystatus[0x36]|(bstatus&2)); + + if(bstatus&4) + { + if(bstatus&1) + { + searchit = 0; + if (searchx != osearchx) + { + if ((repeatcountx == 0) || (repeatcountx > 16)) + { + changedir = 0; + if (osearchx > searchx) changedir = -1; + if (searchx > osearchx) changedir = 1; + + if ((searchstat == 0) || (searchstat == 4)) + { + if(!(wall[searchwall].cstat&8)) changedir = -changedir; + if (repeatpanalign == 0) + wall[searchwall].xrepeat = changechar(wall[searchwall].xrepeat,changedir,smooshyalign,1); + else + wall[searchwall].xpanning = changechar(wall[searchwall].xpanning,changedir,smooshyalign,0); + } + if ((searchstat == 1) || (searchstat == 2)) + { + if (searchstat == 1) + sector[searchsector].ceilingxpanning = changechar(sector[searchsector].ceilingxpanning,changedir,smooshyalign,0); + else + sector[searchsector].floorxpanning = changechar(sector[searchsector].floorxpanning,changedir,smooshyalign,0); + } + if (searchstat == 3) + { + sprite[searchwall].xrepeat = changechar(sprite[searchwall].xrepeat,changedir,smooshyalign,1); + if (sprite[searchwall].xrepeat < 4) + sprite[searchwall].xrepeat = 4; + } + asksave = 1; + repeatcountx = max(1,repeatcountx); + } + repeatcountx += (synctics>>1); + searchx = osearchx; + } + else + repeatcountx = 0; + + if (searchy != osearchy) + { + if ((repeatcounty == 0) || (repeatcounty > 16)) + { + changedir = 0; + if (osearchy < searchy) changedir = -1; + if (searchy < osearchy) changedir = 1; + + if ((searchstat == 0) || (searchstat == 4)) + { + if(wall[searchwall].cstat&4) changedir = -changedir; + if (repeatpanalign == 0) + wall[searchwall].yrepeat = changechar(wall[searchwall].yrepeat,changedir,smooshyalign,1); + else + wall[searchwall].ypanning = changechar(wall[searchwall].ypanning,changedir,smooshyalign,0); + } + if ((searchstat == 1) || (searchstat == 2)) + { + if (searchstat == 1) + sector[searchsector].ceilingypanning = changechar(sector[searchsector].ceilingypanning,changedir,smooshyalign,0); + else + sector[searchsector].floorypanning = changechar(sector[searchsector].floorypanning,changedir,smooshyalign,0); + } + if (searchstat == 3) + { + sprite[searchwall].yrepeat = changechar(sprite[searchwall].yrepeat,changedir,smooshyalign,1); + if (sprite[searchwall].yrepeat < 4) + sprite[searchwall].yrepeat = 4; + } + asksave = 1; + repeatcounty = max(1,repeatcounty); + } + searchy = osearchy; + repeatcounty += (synctics>>1); + //} + } + else + repeatcounty = 0; + } + if (bstatus&16) // - + { + mouseb &= ~16; + bstatus &= ~16; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT + { + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //CTRL + { + if (visibility < 16384) visibility += visibility; + } + else + { + if ((keystatus[0x2a]|keystatus[0x36]) == 0) + k = 16; else k = 1; + + if (highlightsectorcnt >= 0) + for(i=0;i 0) + { + for(i=0;i 0) + { + sector[searchsector].visibility++; + if (sector[searchsector].visibility == 240) + sector[searchsector].visibility = 239; + k--; + } + asksave = 1; + } + } + else + { + k = 0; + if (highlightsectorcnt >= 0) + { + for(i=0;i 0) //ALT + { + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //CTRL + { + if (visibility > 32) visibility >>= 1; + } + else + { + if ((keystatus[0x2a]|keystatus[0x36]) == 0) + k = 16; else k = 1; + + if (highlightsectorcnt >= 0) + for(i=0;i 0) + { + for(i=0;i 0) + { + sector[searchsector].visibility--; + if (sector[searchsector].visibility == 239) + sector[searchsector].visibility = 240; + k--; + } + asksave = 1; + } + } + else + { + k = 0; + if (highlightsectorcnt >= 0) + { + for(i=0;i 0) // mousewheel, -, and +, cycle picnum + { + j = i = (keystatus[KEYSC_EQUAL]|(bstatus&32))?1:-1; + switch (searchstat) + { + case 0: + while(!tilesizx[wall[searchwall].picnum]||!tilesizy[wall[searchwall].picnum]||j) { + if(wall[searchwall].picnum+i >= MAXTILES) wall[searchwall].picnum = 0; + else if(wall[searchwall].picnum+i < 0) wall[searchwall].picnum = MAXTILES-1; + else wall[searchwall].picnum += i; + j = 0; + } + break; + case 1: + while(!tilesizx[sector[searchsector].ceilingpicnum]||!tilesizy[sector[searchsector].ceilingpicnum]||j) { + if(sector[searchsector].ceilingpicnum+i >= MAXTILES) sector[searchsector].ceilingpicnum = 0; + else if(sector[searchsector].ceilingpicnum+i < 0) sector[searchsector].ceilingpicnum = MAXTILES-1; + else sector[searchsector].ceilingpicnum += i; + j = 0; + } + break; + case 2: + while(!tilesizx[sector[searchsector].floorpicnum]||!tilesizy[sector[searchsector].floorpicnum]||j) { + if(sector[searchsector].floorpicnum+i >= MAXTILES) sector[searchsector].floorpicnum = 0; + else if(sector[searchsector].floorpicnum+i < 0) sector[searchsector].floorpicnum = MAXTILES-1; + else sector[searchsector].floorpicnum += i; + j = 0; + } + break; + case 3: + while(!tilesizx[sprite[searchwall].picnum]||!tilesizy[sprite[searchwall].picnum]||j) { + if(sprite[searchwall].picnum+i >= MAXTILES) sprite[searchwall].picnum = 0; + else if(sprite[searchwall].picnum+i < 0) sprite[searchwall].picnum = MAXTILES-1; + else sprite[searchwall].picnum += i; + j = 0; + } + break; + case 4: + while(!tilesizx[wall[searchwall].overpicnum]||!tilesizy[wall[searchwall].overpicnum]||j) { + if(wall[searchwall].overpicnum+i >= MAXTILES) wall[searchwall].overpicnum = 0; + else if(wall[searchwall].overpicnum+i < 0) wall[searchwall].overpicnum = MAXTILES-1; + else wall[searchwall].overpicnum += i; + j = 0; + } + break; + } + asksave = 1; + keystatus[KEYSC_DASH] = keystatus[KEYSC_EQUAL] = 0; + mouseb &= ~(16|32); + } + + if (keystatus[KEYSC_E] > 0) // E (expand) + { + if (searchstat == 1) + { + sector[searchsector].ceilingstat ^= 8; + sprintf(getmessage,"Sector (%d) ceiling texture expansion %s",searchsector,sector[searchsector].ceilingstat&8?"ON":"OFF"); + message(getmessage); + asksave = 1; + } + if (searchstat == 2) + { + sector[searchsector].floorstat ^= 8; + sprintf(getmessage,"Sector (%d) floor texture expansion %s",searchsector,sector[searchsector].floorstat&8?"ON":"OFF"); + message(getmessage); + asksave = 1; + } + keystatus[KEYSC_E] = 0; + } + if (keystatus[KEYSC_R] > 0) // R (relative alignment, rotation) + { + + if (keystatus[KEYSC_QUOTE] > 0) // FRAMERATE TOGGLE + { + + framerateon = !framerateon; + if(framerateon) message("Show framerate ON"); + else message("Show framerate OFF"); + + } + + else + + { + if (searchstat == 1) + { + sector[searchsector].ceilingstat ^= 64; + sprintf(getmessage,"Sector (%d) ceiling texture relativity %s",searchsector,sector[searchsector].ceilingstat&64?"ON":"OFF"); + message(getmessage); + asksave = 1; + } + if (searchstat == 2) + { + sector[searchsector].floorstat ^= 64; + sprintf(getmessage,"Sector (%d) ceiling texture relativity %s",searchsector,sector[searchsector].floorstat&64?"ON":"OFF"); + message(getmessage); + asksave = 1; + } + if (searchstat == 3) + { + i = sprite[searchwall].cstat; + if ((i&48) < 32) i += 16; + + else i &= ~48; + sprite[searchwall].cstat = i; + + if (sprite[searchwall].cstat&16) + sprintf(getmessage,"Sprite (%d) wall aligned",searchwall); + else if (sprite[searchwall].cstat&32) + sprintf(getmessage,"Sprite (%d) floor aligned",searchwall); + else + sprintf(getmessage,"Sprite (%d) un-aligned",searchwall); + message(getmessage); + asksave = 1; + } + } + keystatus[KEYSC_R] = 0; + } + if (keystatus[KEYSC_F] > 0) //F (Flip) + { + keystatus[KEYSC_F] = 0; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT-F (relative alignmment flip) + { + if (searchstat != 3) + { + setfirstwall(searchsector,searchwall); + asksave = 1; + } + } + else + { + if ((searchstat == 0) || (searchstat == 4)) + { + i = wall[searchwall].cstat; + i = ((i>>3)&1)+((i>>7)&2); //3-x,8-y + switch(i) + { + case 0: i = 1; break; + case 1: i = 3; break; + case 2: i = 0; break; + case 3: i = 2; break; + } + i = ((i&1)<<3)+((i&2)<<7); + wall[searchwall].cstat &= ~0x0108; + wall[searchwall].cstat |= i; + asksave = 1; + } + if (searchstat == 1) //8-way ceiling flipping (bits 2,4,5) + { + i = sector[searchsector].ceilingstat; + i = (i&0x4)+((i>>4)&3); + switch(i) + { + case 0: i = 6; break; + case 6: i = 3; break; + case 3: i = 5; break; + case 5: i = 1; break; + case 1: i = 7; break; + case 7: i = 2; break; + case 2: i = 4; break; + case 4: i = 0; break; + } + i = (i&0x4)+((i&3)<<4); + sector[searchsector].ceilingstat &= ~0x34; + sector[searchsector].ceilingstat |= i; + asksave = 1; + } + if (searchstat == 2) //8-way floor flipping (bits 2,4,5) + { + i = sector[searchsector].floorstat; + i = (i&0x4)+((i>>4)&3); + switch(i) + { + case 0: i = 6; break; + case 6: i = 3; break; + case 3: i = 5; break; + case 5: i = 1; break; + case 1: i = 7; break; + case 7: i = 2; break; + case 2: i = 4; break; + case 4: i = 0; break; + } + i = (i&0x4)+((i&3)<<4); + sector[searchsector].floorstat &= ~0x34; + sector[searchsector].floorstat |= i; + asksave = 1; + } + if (searchstat == 3) + { + i = sprite[searchwall].cstat; + if (((i&48) == 32) && ((i&64) == 0)) + { + sprite[searchwall].cstat &= ~0xc; + sprite[searchwall].cstat |= ((i&4)^4); + } + else + { + i = ((i>>2)&3); + switch(i) + { + case 0: i = 1; break; + case 1: i = 3; break; + case 2: i = 0; break; + case 3: i = 2; break; + } + i <<= 2; + sprite[searchwall].cstat &= ~0xc; + sprite[searchwall].cstat |= i; + } + asksave = 1; + } + } + } + + if (keystatus[0xc7] > 0) // HOME + updownunits = 256; + else if (keystatus[0xcf] > 0) // END + updownunits = 512; + else + updownunits = 1024; + + if ((keystatus[0xc9] > 0) || ((bstatus&2) && (bstatus&32))) // PGUP + { + k = 0; + if (highlightsectorcnt >= 0) + { + for(i=0;i 0) //CTRL - put sprite on ceiling + { + sprite[searchwall].z = getceilzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y); + if (sprite[searchwall].cstat&128) sprite[searchwall].z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1); + if ((sprite[searchwall].cstat&48) != 32) + sprite[searchwall].z += ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<2); + } + else + { + k = 0; + if (highlightcnt >= 0) + for(i=0;i 0) || ((bstatus&2) && (bstatus&16))) // PGDN + { + k = 0; + if (highlightsectorcnt >= 0) + { + for(i=0;i sector[searchsector].floorz) + sector[searchsector].ceilingz = sector[searchsector].floorz; + if (searchstat == 3) + { + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //CTRL - put sprite on ground + { + sprite[searchwall].z = getflorzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y); + if (sprite[searchwall].cstat&128) sprite[searchwall].z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1); + } + else + { + k = 0; + if (highlightcnt >= 0) + for(i=0;i 640)); + enddrawing(); + } + } + } + clockval[clockcnt] = i; + clockcnt = ((clockcnt+1)&15); + + tempbuf[0] = 0; + if((bstatus&4) && (bstatus&2)) + Bsprintf(tempbuf,"PAN"); + else if(bstatus&4) + Bsprintf(tempbuf,"SHADE/SIZE"); + else if(bstatus&2) + Bsprintf(tempbuf,"Z"); + else if(bstatus&1) + Bsprintf(tempbuf,"LOCK"); + if(tempbuf[0] != 0) + { + printext256(searchx+4+2,searchy+4+2,0,-1,tempbuf,!(xdimgame > 640)); + printext256(searchx+4,searchy+4,whitecol,-1,tempbuf,!(xdimgame > 640)); + } + if(helpon==1) + { + for(i=0;i 640)))+2,0,-1,Help3d[i],!(xdimgame > 640)); + printext256(0*8,8+(i*(8+(xdimgame > 640))),whitecol,-1,Help3d[i],!(xdimgame > 640)); + enddrawing(); + switch(i) + { + case 8: Bsprintf(tempbuf,"%d",autosave); break; + case 9: Bsprintf(tempbuf,"%s",SKILLMODE[skill]); break; + case 10: Bsprintf(tempbuf,"%d",tabgraphic); break; + case 11: Bsprintf(tempbuf,"%d",framerateon); break; + case 12: Bsprintf(tempbuf,"%s",SPRDSPMODE[nosprites]); break; + case 13: Bsprintf(tempbuf,"%d",shadepreview); break; + case 14: Bsprintf(tempbuf,"%d",purpleon); break; + default : sprintf(tempbuf," "); break; + } + begindrawing(); + if(!strcmp(tempbuf,"0")) + Bsprintf(tempbuf,"OFF"); + else if(!strcmp(tempbuf,"1")) + Bsprintf(tempbuf,"ON"); + else if(!strcmp(tempbuf,"2")) + Bsprintf(tempbuf,"ON (2)"); + + printext256((20+((xdimgame > 640) * 20))*8+2,8+(i*8+(xdimgame > 640))+2,0,-1,tempbuf,!(xdimgame > 640)); + printext256((20+((xdimgame > 640) * 20))*8,8+(i*8+(xdimgame > 640)),whitecol,-1,tempbuf,!(xdimgame > 640)); + enddrawing(); + } + } + + /* if(purpleon) { + begindrawing(); + // printext256(1*4,1*8,whitecol,-1,"Purple ON",0); + sprintf(getmessage,"Purple ON"); + message(getmessage); + enddrawing(); + } + */ + if(sector[cursectnum].lotag==2) + { + if(sector[cursectnum].floorpal==8) SetBOSS1Palette(); + else SetWATERPalette(); + } + else SetGAMEPalette(); + + + //Stick this in 3D part of ExtCheckKeys + //Also choose your own key scan codes + + + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x20]==1) // ' d + /* + { + ShowHelpText("SectorEffector"); + } */ + + { + keystatus[0x20] = 0; + skill++; if(skill>MAXSKILL-1) skill=0; + sprintf(tempbuf,"%s",SKILLMODE[skill]); + // printext256(1*4,1*8,11,-1,tempbuf,0); + message(tempbuf); + } + + begindrawing(); + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x22]==1) // ' g + { + keystatus[0x22] = 0; + tabgraphic++; + if (tabgraphic > 2) tabgraphic = 0; + if(tabgraphic) message("Graphics ON"); + else message("Graphics OFF"); + } + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x2d]==1) // ' x + { + keystatus[0x2d] = 0; + shadepreview=!shadepreview; + if(shadepreview) message("Sprite shade preview ON"); + else message("Sprite shade preview OFF"); + } + + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x13]==1) // ' r + { + keystatus[0x13] = 0; + framerateon=!framerateon; + if(framerateon) message("Framerate ON"); + else message("Framerate OFF"); + } + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x11]==1) // ' w + { + keystatus[0x11] = 0; + nosprites++; if(nosprites>3) nosprites=0; + Bsprintf(tempbuf,"%s",SPRDSPMODE[nosprites]); + // printext256(1*4,1*8,whitecol,-1,tempbuf,0); + message(tempbuf); + } + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x15]==1) // ' y + { + keystatus[0x15] = 0; + purpleon=!purpleon; if(nosprites>3) nosprites=0; + if(purpleon) message("Purple ON"); + else message("Purple OFF"); + } + enddrawing(); + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x2e]==1) // ' C + { + keystatus[0x2e] = 0; + switch (searchstat) + { + case 0: + case 4: + for(i=0;i0) // F2 + { + usedcount=!usedcount; + keystatus[0x3c] = 0; + } + if(keystatus[0x0f]>0) // TAB : USED + { + // usedcount=!usedcount; + + count=0; + for(i=0;i= 256*/ && sprite[i].sectnum != MAXSECTORS) + { + radius = mulscale15(sprite[i].hitag,zoom); + col = 6; + if (i+16384 == pointhighlight) + if (totalclock & 32) col += (2<<2); + drawlinepat = 0xf0f0f0f0; + drawcircle16(halfxdim16+xp1, midydim16+yp1, radius, col); + drawlinepat = 0xffffffff; + } + } + enddrawing(); + + if(keystatus[0x3b]==1 || (keystatus[KEYSC_QUOTE]==1 && keystatus[0x29]==1)) //F1 or ' ~ + { + keystatus[0x3b]=0; + clearmidstatbar16(); + begindrawing(); + for(i=0;i 9) + { + j = 256; + k = 90; + } + printext16(j,ydim16+32+(i*9)-k,11,-1,Help2d[i],0); + } + enddrawing(); + } + + if((keystatus[KEYSC_QUOTE]==1 && keystatus[KEYSC_D]==1)) // ' D delete all sprites of a certain type + { + keystatus[KEYSC_D]=0; + Bsprintf(tempbuf,"Delete all sprites of picnum: "); + i = getnumber16(tempbuf,-1,MAXSPRITES-1,1); + if (i >= 0) + { + for(j=0;j 0) // M (tag) + { + keystatus[0x32] = 0; + if ((keystatus[0x38]|keystatus[0xb8]) > 0) //ALT + { + if (pointhighlight >= 16384) + { + i = pointhighlight-16384; + Bsprintf(tempbuf,"Sprite (%d) Extra: ",i); + sprite[i].extra = getnumber16(tempbuf,sprite[i].extra,65536L,1); + clearmidstatbar16(); + showspritedata((short)i); + } + else if (linehighlight >= 0) + { + i = linehighlight; + Bsprintf(tempbuf,"Wall (%d) Extra: ",i); + wall[i].extra = getnumber16(tempbuf,wall[i].extra,65536L,1); + clearmidstatbar16(); + showwalldata((short)i); + } + printmessage16(""); + } + else + { + for (i=0;i 0) // /? Reset panning&repeat to 0 + { + if ((ppointhighlight&0xc000) == 16384) + { + if ((keystatus[0x2a]|keystatus[0x36]) > 0) + { + sprite[cursprite].xrepeat = sprite[cursprite].yrepeat; + } + else + { + sprite[cursprite].xrepeat = 64; + sprite[cursprite].yrepeat = 64; + } + } + keystatus[0x35] = 0; + asksave = 1; + } + + if ((keystatus[0x4b]|keystatus[0x4d]) > 0) // 4 & 6 (keypad) + { + smooshyalign = keystatus[0x4c]; + if ((repeatcountx == 0) || (repeatcountx > 16)) + { + changedir = 0; + if (keystatus[0x4b] > 0) changedir = -1; + if (keystatus[0x4d] > 0) changedir = 1; + + if ((ppointhighlight&0xc000) == 16384) + { + sprite[cursprite].xrepeat = changechar(sprite[cursprite].xrepeat,changedir,smooshyalign,1); + if (sprite[cursprite].xrepeat < 4) + sprite[cursprite].xrepeat = 4; + } + asksave = 1; + repeatcountx = max(1,repeatcountx); + } + repeatcountx += synctics; + } + else + repeatcountx = 0; + + if ((keystatus[0x48]|keystatus[0x50]) > 0) // 2 & 8 (keypad) + { + smooshyalign = keystatus[0x4c]; + if ((repeatcounty == 0) || (repeatcounty > 16)) + { + changedir = 0; + if (keystatus[0x48] > 0) changedir = -1; + if (keystatus[0x50] > 0) changedir = 1; + + if ((ppointhighlight&0xc000) == 16384) + { + sprite[cursprite].yrepeat = changechar(sprite[cursprite].yrepeat,changedir,smooshyalign,1); + if (sprite[cursprite].yrepeat < 4) + sprite[cursprite].yrepeat = 4; + } + asksave = 1; + repeatcounty = max(1,repeatcounty); + } + repeatcounty += synctics; + //} + } + else + repeatcounty = 0; + + if (keystatus[0x13] > 0) // R (relative alignment, rotation) + { + if (pointhighlight >= 16384) + { + i = sprite[cursprite].cstat; + if ((i&48) < 32) i += 16; + + else i &= ~48; + sprite[cursprite].cstat = i; + + if (sprite[cursprite].cstat&16) + sprintf(getmessage,"Sprite (%d) is wall aligned",cursprite); + else if (sprite[cursprite].cstat&32) + sprintf(getmessage,"Sprite (%d) is floor aligned",cursprite); + else + sprintf(getmessage,"Sprite (%d) is un-aligned",cursprite); + message(getmessage); + asksave = 1; + + } + keystatus[0x13] = 0; + } + + + if(keystatus[KEYSC_QUOTE] && keystatus[KEYSC_S]) // ' S + { + if (pointhighlight >= 16384) + { + keystatus[0x1f] = 0; + Bsprintf(tempbuf,"Sprite (%d) xrepeat: ",cursprite); + sprite[cursprite].xrepeat=getnumber16(tempbuf, sprite[cursprite].xrepeat, 256,0); + Bsprintf(tempbuf,"Sprite (%d) yrepeat: ",cursprite); + sprite[cursprite].yrepeat=getnumber16(tempbuf, sprite[cursprite].yrepeat, 256,0); + Bsprintf(tempbuf,"Sprite (%d) updated",i); + printmessage16(tempbuf); + } + } + + if(keystatus[KEYSC_QUOTE] && keystatus[KEYSC_F]) // ' F + { + keystatus[KEYSC_F] = 0; + j = 0; + for(i=0;i0) // [ search backward + { + keystatus[0x1a]=0; + if(wallsprite==0) + { + SearchSectorsBackward(); + } + else + + if(wallsprite==1) + { + if(curwallnum>0) curwallnum--; + for(i=curwallnum;i>=0;i--) + { + if( + (wall[i].picnum==wall[curwall].picnum) + &&((search_lotag==0)|| + (search_lotag!=0 && search_lotag==wall[i].lotag)) + &&((search_hitag==0)|| + (search_hitag!=0 && search_hitag==wall[i].hitag)) + ) + { + posx=(wall[i].x)-(( (wall[i].x)-(wall[wall[i].point2].x) )/2); + posy=(wall[i].y)-(( (wall[i].y)-(wall[wall[i].point2].y) )/2); + printmessage16("< Wall search: found"); + // curwallnum--; + keystatus[0x1a]=0; + return; + } + curwallnum--; + } + printmessage16("< Wall search: none found"); + } + else + + if(wallsprite==2) + { + if(cursearchspritenum>0) cursearchspritenum--; + for(i=cursearchspritenum;i>=0;i--) + { + + if( + (sprite[i].picnum==sprite[cursearchsprite].picnum && + sprite[i].statnum==0 ) + &&((search_lotag==0)|| + (search_lotag!=0 && search_lotag==sprite[i].lotag)) + &&((search_hitag==0)|| + (search_hitag!=0 && search_hitag==sprite[i].hitag)) + ) + { + posx=sprite[i].x; + posy=sprite[i].y; + ang= sprite[i].ang; + printmessage16("< Sprite search: found"); + // curspritenum--; + keystatus[0x1a]=0; + return; + } + cursearchspritenum--; + } + printmessage16("< Sprite search: none found"); + } + } + + + if(keystatus[0x1b]>0) // ] search forward + { + keystatus[0x1b]=0; + if(wallsprite==0) + { + SearchSectorsForward(); + } + else + + if(wallsprite==1) + { + if(curwallnum Wall search: found"); + // curwallnum++; + keystatus[0x1b]=0; + return; + } + curwallnum++; + } + printmessage16("> Wall search: none found"); + } + else + + if(wallsprite==2) + { + if(cursearchspritenum Sprite search: found"); + // curspritenum++; + keystatus[0x1b]=0; + return; + } + cursearchspritenum++; + } + printmessage16("> Sprite search: none found"); + } + } + + if (keystatus[0x22] > 0) // G (grid on/off) + { + grid += ((keystatus[0x2a]|keystatus[0x36]) > 0?-1:1); + if (grid == -1 || grid == 9) { + switch(grid) { + case -1: + grid = 8; + break; + case 9: + grid = 0; + break; + } + } + if(!grid) sprintf(tempbuf,"Grid off"); + else sprintf(tempbuf,"Grid size: %d (%d units)",grid,2048>>grid); + printmessage16(tempbuf); + keystatus[0x22] = 0; + } + + if ((totalclock > getmessagetimeoff) && (totalclock > (lastpm16time + 120*3))) + { + long olinehighlight, opointhighlight, ocursectornum; + + updatesector(mousxplc,mousyplc,&cursectornum); + if (pointhighlight >= 16384) + { + char tmpbuf[2048]; + i = pointhighlight-16384; + if (strlen(names[sprite[i].picnum]) > 0) { + if (sprite[i].picnum==SECTOREFFECTOR) + Bsprintf(tmpbuf,"Sprite %d %s: lo:%d hi:%d",i,SectorEffectorText(i),sprite[i].lotag,sprite[i].hitag); + else Bsprintf(tmpbuf,"Sprite %d %s: lo:%d hi:%d ex:%d",i,names[sprite[i].picnum],sprite[i].lotag,sprite[i].hitag,sprite[i].extra); + } + else Bsprintf(tmpbuf,"Sprite %d picnum %d: lo:%d hi:%d ex:%d",i,sprite[i].picnum,sprite[i].lotag,sprite[i].hitag,sprite[i].extra); + _printmessage16(tmpbuf); + } + else if ((linehighlight >= 0) && (sectorofwall(linehighlight) == cursectornum)) + { + long dax, day, dist; + dax = wall[linehighlight].x-wall[wall[linehighlight].point2].x; + day = wall[linehighlight].y-wall[wall[linehighlight].point2].y; + dist = ksqrt(dax*dax+day*day); + Bsprintf(tempbuf,"Wall %d: length:%ld lo:%d hi:%d",linehighlight,dist,wall[linehighlight].lotag,wall[linehighlight].hitag); + _printmessage16(tempbuf); + } + else if (cursectornum >= 0) + { + Bsprintf(tempbuf,"Sector %d: lo:%d hi:%d",cursectornum,sector[cursectornum].lotag,sector[cursectornum].hitag); + _printmessage16(tempbuf); + } + else _printmessage16(""); + } + + if ((keystatus[0x26] > 0) && (keystatus[KEYSC_QUOTE] > 0)) // ' L + { + if (pointhighlight >= 16384) + { + i = pointhighlight - 16384; + Bsprintf(tempbuf,"Sprite %d x: ",i); + sprite[i].x = getnumber16(tempbuf,sprite[i].x,131072,1); + Bsprintf(tempbuf,"Sprite %d y: ",i); + sprite[i].y = getnumber16(tempbuf,sprite[i].y,131072,1); + Bsprintf(tempbuf,"Sprite %d z: ",i); + sprite[i].z = getnumber16(tempbuf,sprite[i].z,8388608,1); + Bsprintf(tempbuf,"Sprite %d angle: ",i); + sprite[i].ang = getnumber16(tempbuf,sprite[i].ang,2048L,0); + Bsprintf(tempbuf,"Sprite %d updated",i); + printmessage16(tempbuf); + } + + else if (pointhighlight <= 16383) + { + i = linehighlight; + Bsprintf(tempbuf,"Wall %d x: ",i); + wall[i].x = getnumber16(tempbuf,wall[i].x,131072,1); + Bsprintf(tempbuf,"Wall %d y: ",i); + wall[i].y = getnumber16(tempbuf,wall[i].y,131072,1); + Bsprintf(tempbuf,"Wall %d updated",i); + printmessage16(tempbuf); + } + + keystatus[0x26] = 0; + } + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x06]==1) // ' 5 + { + signed char shade; + keystatus[0x06]=0; + + shade=getnumber16("Global parallaxed sky shade: ",0,128,1); + + for(i=0;i>1,255); + } + for(i=0;i>= 1; + sector[i].floorz >>= 1; + } + for(i=0;i>= 1; + wall[i].y >>= 1; + wall[i].yrepeat = min(wall[i].yrepeat<<1,255); + } + for(i=0;i>= 1; + sprite[i].y >>= 1; + sprite[i].z >>= 1; + sprite[i].xrepeat = max(sprite[i].xrepeat>>1,1); + sprite[i].yrepeat = max(sprite[i].yrepeat>>1,1); + } + printmessage16("Map scaled"); + } + + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x04]==1) // ' 3 + { + onnames++; if(onnames>8) onnames=0; + keystatus[0x04]=0; + Bsprintf(tempbuf,"Mode %d %s",onnames,SpriteMode[onnames]); + printmessage16(tempbuf); + // clearmidstatbar16(); + // for(i=0;i=20 && sprite[i].picnum<=59) + { + sprite[i].xrepeat = 32; + sprite[i].yrepeat = 32; + } + } + + } + */ + + // What the fuck is this supposed to do? + + /* Motorcycle ha ha ha + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x06]==1) // ' 5 + { + keystatus[0x06]=0; + sidemode++; if (sidemode > 2) sidemode = 0; + if (sidemode == 1) + { + editstatus = 0; + zmode = 2; + posz = ((sector[cursectnum].ceilingz+sector[cursectnum].floorz)>>1); + } + else + { + editstatus = 1; + zmode = 1; + } + } + */ + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x08]==1) // ' 7 : swap hilo + { + keystatus[0x08]=0; + + if (pointhighlight >= 16384) + { + temp=sprite[cursprite].lotag; + sprite[cursprite].lotag=sprite[cursprite].hitag; + sprite[cursprite].hitag=temp; + Bsprintf(tempbuf,"Sprite %d tags swapped",cursprite); + printmessage16(tempbuf); + } + else if (linehighlight >= 0) + { + temp=wall[linehighlight].lotag; + wall[linehighlight].lotag=wall[linehighlight].hitag; + wall[linehighlight].hitag=temp; + Bsprintf(tempbuf,"Wall %d tags swapped",linehighlight); + printmessage16(tempbuf); + } + } + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x24]==1) // ' J + { + posx=getnumber16("X-coordinate: ",posx,131072L,1); + posy=getnumber16("Y-coordinate: ",posy,131072L,1); + Bsprintf(tempbuf,"Current pos now (%ld, %ld)",posx,posy); + printmessage16(tempbuf); + keystatus[0x24]=0; + } + +}// end key2d + +void ExtSetupSpecialSpriteCols(void) +{ + short i; + for (i=0;i=0;i--) + sector[i].wallnum = sector[i+1].wallptr-sector[i].wallptr; + sector[numsectors-1].wallnum = numwalls-sector[numsectors-1].wallptr; + + for(i=0;ipicnum<11) tspr->xrepeat=0; + + if(nosprites==1||nosprites==3) + switch(tspr->picnum) + { + case SEENINE : + tspr->xrepeat=0; + } + + if(shadepreview && !(tspr->cstat & 16)) + { + if (sector[tspr->sectnum].ceilingstat&1) + l = sector[tspr->sectnum].ceilingshade; + else + { + l = sector[tspr->sectnum].floorshade; + if (sector[tspr->sectnum].floorpal != 0 && sector[tspr->sectnum].floorpal < num_tables) + tspr->pal=sector[tspr->sectnum].floorpal; + } + if(l < -127) l = -127; + if(l > 126) l = 127; + + tspr->shade = l; + + } + + switch(tspr->picnum) + { + // 5-frame walk + case 1550 : // Shark + frames=5; + // 2-frame walk + case 1445 : // duke kick + case LIZTROOPDUCKING : + case 2030 : // pig shot + case OCTABRAIN : + case PIGCOPDIVE : + case 2190 : // liz capt shot + case BOSS1SHOOT : + case BOSS1LOB : + case LIZTROOPSHOOT : + if(frames==0) frames=2; + + // 4-frame walk + case 1491 : // duke crawl + case LIZTROOP : + case LIZTROOPRUNNING : + case PIGCOP : + case LIZMAN : + case BOSS1 : + case BOSS2 : + case BOSS3 : + case BOSS4 : + case NEWBEAST: + if(frames==0) frames=4; + case LIZTROOPJETPACK : + case DRONE : + case COMMANDER : + case TANK : + case RECON : + if(frames==0) frames = 10; + case CAMERA1: + case APLAYER : + if(frames==0) frames=1; + case GREENSLIME : + case EGG : + case PIGCOPSTAYPUT : + case LIZMANSTAYPUT: + case LIZTROOPSTAYPUT : + case LIZMANSPITTING : + case LIZMANFEEDING : + case LIZMANJUMP : + if(skill!=4) + { + if(tspr->lotag>skill+1) + { + tspr->xrepeat=0; break; + } + } + if(nosprites==2||nosprites==3) + { + tspr->xrepeat=0; + // tspr->cstat|=32768; + } + // else tspr->cstat&=32767; + + if (bpp > 8 && usemodels && md_tilehasmodel(tspr->picnum)) { + tspr->cstat &= ~4; + break; + } + + if(frames!=0) + { + if(frames==10) frames=0; + k = getangle(tspr->x-posx,tspr->y-posy); + k = (((tspr->ang+3072+128-k)&2047)>>8)&7; + //This guy has only 5 pictures for 8 angles (3 are x-flipped) + if (k <= 4) + { + tspr->picnum += k; + tspr->cstat &= ~4; //clear x-flipping bit + } + else + { + tspr->picnum += 8-k; + tspr->cstat |= 4; //set x-flipping bit + } + } + + if(frames==2) tspr->picnum+=((((4-(totalclock>>5)))&1)*5); + if(frames==4) tspr->picnum+=((((4-(totalclock>>5)))&3)*5); + if(frames==5) tspr->picnum+=(((totalclock>>5)%5))*5; + + if(tilesizx[tspr->picnum] == 0) + tspr->picnum -= 5; //Hack, for actors + + break; + default: + break; + + } + } +} + +void Keys2d3d(void) +{ + int i, j; + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x1e]==1) // ' a + { + keystatus[0x1e] = 0; + autosave=!autosave; + if(autosave) message("Autosave ON"); + else message("Autosave OFF"); + } + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[KEYSC_N]==1) // ' n + { + keystatus[KEYSC_N] = 0; + noclip=!noclip; + if(noclip) message("Clipping disabled"); + else message("Clipping enabled"); + } + + if ((totalclock > autosavetimer) && (autosave)) + { + if (asksave) + { + fixspritesectors(); //Do this before saving! + // updatesector(startposx,startposy,&startsectnum); + ExtPreSaveMap(); + saveboard("autosave.map",&startposx,&startposy,&startposz,&startang,&startsectnum); + ExtSaveMap("autosave.map"); + message("Board autosaved to AUTOSAVE.MAP"); + } + autosavetimer = totalclock+120*180; + } + + if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //CTRL + if (keystatus[0x1f] > 0) // S + { + if (levelname) + { + fixspritesectors(); //Do this before saving! + updatesector(startposx,startposy,&startsectnum); + ExtPreSaveMap(); + saveboard(levelname,&startposx,&startposy,&startposz,&startang,&startsectnum); + ExtSaveMap(levelname); + message("Board saved"); + asksave = 0; + keystatus[0x1f] = 0; + } + } + + if (keystatus[buildkeys[14]] > 0) // Enter + { + getmessageleng = 0; + getmessagetimeoff = 0; + } + + if (getmessageleng > 0) + { + charsperline = 64; + //if (dimensionmode[snum] == 2) charsperline = 80; + if (qsetmode == 200) + { + for(i=0;i<=getmessageleng;i+=charsperline) + { + for(j=0;j>6)+2,((i/charsperline)<<3)+(ydimgame-(ydimgame>>5))-(((getmessageleng-1)/charsperline)<<3)+2,0,-1,tempbuf,xdimgame>640?0:1); + printext256((xdimgame>>6),((i/charsperline)<<3)+(ydimgame-(ydimgame>>5))-(((getmessageleng-1)/charsperline)<<3),whitecol,-1,tempbuf,xdimgame>640?0:1); + } + enddrawing(); + } + } + else printmessage16(getmessage); + if (totalclock > getmessagetimeoff) + getmessageleng = 0; + } + +} + +void ExtCheckKeys(void) +{ + readmousebstatus(&bstatus); + Keys2d3d(); + if (qsetmode == 200) //In 3D mode + { + Keys3d(); + m32_showmouse(); + if (sidemode != 1) editinput(); + } + else + { + Keys2d(); + } +} + +void faketimerhandler(void) +{ + long i, j, dax, day, dist; + long hiz, hihit, loz, lohit, oposx, oposy; + short hitwall, daang; + + counter++; if(counter>=5) counter=0; + + sampletimer(); + if (totalclock < ototalclock+TICSPERFRAME) + return; + if (qsetmode != 200) + return; + if (sidemode != 1) + return; + ototalclock = totalclock; + + oposx = posx; oposy = posy; + hitwall = clipmove(&posx,&posy,&posz,&cursectnum,xvel,yvel,128L,4L<<8,4L<<8,0); + xvel = ((posx-oposx)<<14); yvel = ((posy-oposy)<<14); + + yvel += 80000; + if ((hitwall&0xc000) == 32768) + { + hitwall &= (MAXWALLS-1); + i = wall[hitwall].point2; + daang = getangle(wall[i].x-wall[hitwall].x,wall[i].y-wall[hitwall].y); + + xvel -= (xvel>>4); + if (xvel < 0) xvel++; + if (xvel > 0) xvel--; + + yvel -= (yvel>>4); + if (yvel < 0) yvel++; + if (yvel > 0) yvel--; + + i = 4-keystatus[buildkeys[4]]; + xvel += mulscale(vel,(long)sintable[(ang+512)&2047],i); + yvel += mulscale(vel,(long)sintable[ang&2047],i); + + if (((daang-ang)&2047) < 1024) + ang = ((ang+((((daang-ang)&2047)+24)>>4))&2047); + else + ang = ((ang-((((ang-daang)&2047)+24)>>4))&2047); + + timoff = ototalclock; + } + else + { + if (ototalclock > timoff+32) + ang = ((ang+((timoff+32-ototalclock)>>4))&2047); + } + + getzrange(posx,posy,posz,cursectnum,&hiz,&hihit,&loz,&lohit,128L,0); + + oposx -= posx; oposy -= posy; + + dist = ksqrt(oposx*oposx+oposy*oposy); + if (ototalclock > timoff+32) dist = 0; + + daang = mulscale(dist,angvel,9); + posz += (daang<<6); + if (posz > loz-(4<<8)) posz = loz-(4<<8), hvel = 0; + if (posz < hiz+(4<<8)) posz = hiz+(4<<8), hvel = 0; + + horiz = ((horiz*7+(100-(daang>>1)))>>3); + if (horiz < 100) horiz++; + if (horiz > 100) horiz--; + + if(keystatus[KEYSC_QUOTE]==1 && keystatus[0x06]==1) // ' 5 + { + keystatus[0x06]=0; + editstatus = 1; + sidemode = 2; + } +} + +void SetBOSS1Palette() +{int x; + if(acurpalette==3) return; + acurpalette=3; + kensetpalette(BOSS1palette); +} + + +void SetSLIMEPalette() +{int x; + if(acurpalette==2) return; + acurpalette=2; + kensetpalette(SLIMEpalette); +} + +void SetWATERPalette() +{int x; + if(acurpalette==1) return; + acurpalette=1; + kensetpalette(WATERpalette); +} + + +void SetGAMEPalette() +{int x; + if(acurpalette==0) return; + acurpalette=0; + kensetpalette(GAMEpalette); +} + +void kensetpalette(char *vgapal) +{ + long i; + char vesapal[1024]; + + for(i=0;i<256;i++) + { + vesapal[i*4+0] = vgapal[i*3+2]; + vesapal[i*4+1] = vgapal[i*3+1]; + vesapal[i*4+2] = vgapal[i*3+0]; + vesapal[i*4+3] = 0; + } + setpalette(0L,256L,vesapal); +} + +void SearchSectorsForward() +{ + long ii=0; + if(cursector_lotag!=0) + { + if(cursectornum Sector search: found"); + // cursectornum++; + keystatus[0x1b]=0; // ] + return; + } + cursectornum++; + } + } + printmessage16("> Sector search: none found"); +} + +void SearchSectorsBackward() +{ + long ii=0; + if(cursector_lotag!=0) + { + if(cursectornum>0) cursectornum--; + for(ii=cursectornum;ii>=0;ii--) + { + if(sector[ii].lotag==cursector_lotag) + { + posx=wall[sector[ii].wallptr].x; + posy=wall[sector[ii].wallptr].y; + printmessage16("< Sector search: found"); + // cursectornum--; + keystatus[0x1a]=0; // [ + return; + } + cursectornum--; + } + } + printmessage16("< Sector search: none found"); +} + +// Build edit originally by Ed Coolidge +void EditSectorData(short sectnum) +{ + char disptext[80]; + char edittext[80]; + char snotbuf[80]; + char col=1, row=0, rowmax = 6, dispwidth = 24; + long xpos = 200, ypos = ydim-STATUS2DSIZ+48; + int i = -1; + char editval = 0; + disptext[dispwidth] = 0; + clearmidstatbar16(); + showsectordata(sectnum); + + begindrawing(); + while(keystatus[1] == 0) + { + if (handleevents()) { + if (quitevent) quitevent = 0; + } + printmessage16("Edit mode, press to exit"); + if (keystatus[0xd0] > 0) + { + if (row < rowmax) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + row++; + } + keystatus[0xd0] = 0; + } + if (keystatus[0xc8] > 0) + { + if (row > 0) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + row--; + } + keystatus[0xc8] = 0; + } + if (keystatus[0xcb] > 0) + { + if (col == 2) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 1; + xpos = 200; + rowmax = 6; + dispwidth = 24; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + keystatus[0xcb] = 0; + } + if (keystatus[0xcd] > 0) + { + if (col == 1) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 2; + xpos = 400; + rowmax = 6; + dispwidth = 24; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + keystatus[0xcd] = 0; + } + if (keystatus[0x1c] > 0) + { + keystatus[0x1c] = 0; + editval = 1; + } + + if (col == 1) + { + switch (row) + { + case 0: + for (i=Bsprintf(disptext,"Flags (hex): %x",sector[sectnum].ceilingstat); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Flags: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingstat = (short)getnumber16(edittext,(long)sector[sectnum].ceilingstat,32768L,0); + } + break; + case 1: + for (i=Bsprintf(disptext,"(X,Y)pan: %d, %d",sector[sectnum].ceilingxpanning,sector[sectnum].ceilingypanning); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Sector (%d) Ceiling X Pan: ",sectnum); + printmessage16(edittext); + sector[sectnum].ceilingxpanning = (char)getnumber16(edittext,(long)sector[sectnum].ceilingxpanning,256L,0); + Bsprintf(edittext,"Sector (%d) Ceiling Y Pan: ",sectnum); + printmessage16(edittext); + sector[sectnum].ceilingypanning = (char)getnumber16(edittext,(long)sector[sectnum].ceilingypanning,256L,0); + } + break; + case 2: + for (i=Bsprintf(disptext,"Shade byte: %d",sector[sectnum].ceilingshade); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Shade: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingshade = (char)getnumber16(edittext,(long)sector[sectnum].ceilingshade,128L,1); + } + break; + + case 3: + for (i=Bsprintf(disptext,"Z-coordinate: %ld",sector[sectnum].ceilingz); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Z-coordinate: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingz = getnumber16(edittext,sector[sectnum].ceilingz,8388608,1); //2147483647L,-2147483648L + } + break; + + case 4: + for (i=Bsprintf(disptext,"Tile number: %d",sector[sectnum].ceilingpicnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Tile Number: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingpicnum = (short)getnumber16(edittext,(long)sector[sectnum].ceilingpicnum,MAXTILES,0); + } + break; + + case 5: + for (i=Bsprintf(disptext,"Ceiling heinum: %d",sector[sectnum].ceilingheinum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Heinum: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingheinum = (short)getnumber16(edittext,(long)sector[sectnum].ceilingheinum,32768L,1); + } + break; + + case 6: + for (i=Bsprintf(disptext,"Palookup number: %d",sector[sectnum].ceilingpal); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Ceiling Palookup Number: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].ceilingpal = (char)getnumber16(edittext,(long)sector[sectnum].ceilingpal,MAXPALOOKUPS,0); + } + break; + } + } + if (col == 2) + { + switch (row) + { + case 0: + for (i=Bsprintf(disptext,"Flags (hex): %x",sector[sectnum].floorstat); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Flags: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorstat = (short)getnumber16(edittext,(long)sector[sectnum].floorstat,1024L,0); + } + break; + + case 1: + for (i=Bsprintf(disptext,"(X,Y)pan: %d, %d",sector[sectnum].floorxpanning,sector[sectnum].floorypanning); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Sector (%d) Floor X Pan: ",sectnum); + printmessage16(edittext); + sector[sectnum].floorxpanning = (char)getnumber16(edittext,(long)sector[sectnum].floorxpanning,256L,0); + Bsprintf(edittext,"Sector (%d) Floor Y Pan: ",sectnum); + printmessage16(edittext); + sector[sectnum].floorypanning = (char)getnumber16(edittext,(long)sector[sectnum].floorypanning,256L,0); + } + break; + + case 2: + for (i=Bsprintf(disptext,"Shade byte: %d",sector[sectnum].floorshade); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Shade: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorshade = (char)getnumber16(edittext,(long)sector[sectnum].floorshade,65536L,1L); + } + break; + + case 3: + for (i=Bsprintf(disptext,"Z-coordinate: %ld",sector[sectnum].floorz); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Z-coordinate: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorz = getnumber16(edittext,sector[sectnum].floorz,8388608L,1); //2147483647L,-2147483648L + } + break; + + case 4: + for (i=Bsprintf(disptext,"Tile number: %d",sector[sectnum].floorpicnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Tile Number: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorpicnum = (short)getnumber16(edittext,(long)sector[sectnum].floorpicnum,MAXTILES,0); + } + break; + case 5: + for (i=Bsprintf(disptext,"Floor heinum: %d",sector[sectnum].floorheinum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Flooring Heinum: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorheinum = (short)getnumber16(edittext,(long)sector[sectnum].floorheinum,32768L,1); + } + break; + case 6: + for (i=Bsprintf(disptext,"Palookup number: %d",sector[sectnum].floorpal); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sector (%d) Floor Palookup Number: ",sectnum); + if (editval) + { + printmessage16(edittext); + sector[sectnum].floorpal = (char)getnumber16(edittext,(long)sector[sectnum].floorpal,MAXPALOOKUPS,0); + } + break; + } + } + printext16(xpos,ypos+row*8,11,1,disptext,0); + if (editval) + { + editval = 0; + } + showframe(1); + } + printext16(xpos,ypos+row*8,11,0,disptext,0); + printmessage16(""); + enddrawing(); + showframe(1); + keystatus[1] = 0; +} + +void EditWallData(short wallnum) +{ + char disptext[80]; + char edittext[80]; + char snotbuf[80]; + char col=1, row=0, dispwidth = 24; + long xpos = 200, ypos = ydim-STATUS2DSIZ+48; + int i = -1; + char editval = 0; + disptext[dispwidth] = 0; + clearmidstatbar16(); + showwalldata(wallnum); + begindrawing(); + while(keystatus[1] == 0) + { + if (handleevents()) { + if (quitevent) quitevent = 0; + } + printmessage16("Edit mode, press to exit"); + if (keystatus[0xd0] > 0) + { + if (row < 6) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + row++; + } + keystatus[0xd0] = 0; + } + if (keystatus[0xc8] > 0) + { + if (row > 0) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + row--; + } + keystatus[0xc8] = 0; + } + if (keystatus[0x1c] > 0) + { + keystatus[0x1c] = 0; + editval = 1; + } + switch (row) + { + case 0: + for (i=Bsprintf(disptext,"Flags (hex): %x",wall[wallnum].cstat); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) Flags: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].cstat = (short)getnumber16(edittext,(long)wall[wallnum].cstat,1024L,0); + } + break; + case 1: + for (i=Bsprintf(disptext,"Shade: %d",wall[wallnum].shade); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) Shade: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].shade = (char)getnumber16(edittext,(long)wall[wallnum].shade,127,1); + } + break; + case 2: + for (i=Bsprintf(disptext,"Pal: %d",wall[wallnum].pal); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) Pal: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].pal = (char)getnumber16(edittext,(long)wall[wallnum].pal,MAXPALOOKUPS,0); + } + break; + case 3: + for (i=Bsprintf(disptext,"(X,Y)repeat: %d, %d",wall[wallnum].xrepeat,wall[wallnum].yrepeat); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Wall (%d) X Repeat: ",wallnum); + printmessage16(edittext); + wall[wallnum].xrepeat = (char)getnumber16(edittext,(long)wall[wallnum].xrepeat,256L,0); + Bsprintf(edittext,"Wall (%d) Y Repeat: ",wallnum); + printmessage16(edittext); + wall[wallnum].yrepeat = (char)getnumber16(edittext,(long)wall[wallnum].yrepeat,256L,0); + } + break; + case 4: + for (i=Bsprintf(disptext,"(X,Y)pan: %d, %d",wall[wallnum].xpanning,wall[wallnum].ypanning); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Wall (%d) X Pan: ",wallnum); + printmessage16(edittext); + wall[wallnum].xpanning = (char)getnumber16(edittext,(long)wall[wallnum].xpanning,256L,0); + Bsprintf(edittext,"Wall (%d) Y Pan: ",wallnum); + printmessage16(edittext); + wall[wallnum].ypanning = (char)getnumber16(edittext,(long)wall[wallnum].ypanning,256L,0); + } + break; + case 5: + for (i=Bsprintf(disptext,"Tile number: %d",wall[wallnum].picnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) Tile number: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].picnum = (short)getnumber16(edittext,(long)wall[wallnum].picnum,MAXTILES,0); + } + break; + + case 6: + for (i=Bsprintf(disptext,"OverTile number: %d",wall[wallnum].overpicnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Wall (%d) OverTile number: ",wallnum); + if (editval) + { + printmessage16(edittext); + wall[wallnum].overpicnum = (short)getnumber16(edittext,(long)wall[wallnum].overpicnum,MAXTILES,0); + } + break; + } + printext16(xpos,ypos+row*8,11,1,disptext,0); + if (editval) + { + editval = 0; + //showwalldata(wallnum); + //printmessage16(""); + } + //enddrawing(); + showframe(1); + } + //begindrawing(); + printext16(xpos,ypos+row*8,11,0,disptext,0); + printmessage16(""); + enddrawing(); + showframe(1); + keystatus[1] = 0; +} + +void EditSpriteData(short spritenum) +{ + char disptext[80]; + char edittext[80]; + char snotbuf[80]; + char col=1, row=0, rowmax=5, dispwidth = 24; + long xpos = 200, ypos = ydim-STATUS2DSIZ+48; + int i = -1; + char editval = 0; + disptext[dispwidth] = 0; + clearmidstatbar16(); + showspritedata(spritenum); + + while(keystatus[1] == 0) + { + begindrawing(); + if (handleevents()) { + if (quitevent) quitevent = 0; + } + printmessage16("Edit mode, press to exit"); + if (keystatus[0xd0] > 0) + { + if (row < rowmax) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + row++; + } + keystatus[0xd0] = 0; + } + if (keystatus[0xc8] > 0) + { + if (row > 0) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + row--; + } + keystatus[0xc8] = 0; + } + if (keystatus[0xcb] > 0) + { + if (col == 2) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 1; + xpos = 200; + rowmax = 5; + dispwidth = 24; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + else if (col == 1) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 0; + xpos = 8; + rowmax = 2; + dispwidth = 23; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + keystatus[0xcb] = 0; + } + if (keystatus[0xcd] > 0) + { + if (col == 0) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 1; + xpos = 200; + rowmax = 5; + dispwidth = 24; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + else if (col == 1) + { + printext16(xpos,ypos+row*8,11,0,disptext,0); + col = 2; + xpos = 400; + rowmax = 6; + dispwidth = 26; + disptext[dispwidth] = 0; + if (row > rowmax) row = rowmax; + } + keystatus[0xcd] = 0; + } + if (keystatus[0x1c] > 0) + { + keystatus[0x1c] = 0; + editval = 1; + } + switch (row) + { + case 0: + if (col == 0) + { + for (i=Bsprintf(disptext,"X-coordinate: %ld",sprite[spritenum].x); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) X-coordinate: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].x = getnumber16(edittext,sprite[spritenum].x,131072,1); + } + } + else if (col == 1) + { + for (i=Bsprintf(disptext,"Flags (hex): %x",sprite[spritenum].cstat); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Flags: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].cstat = (short)getnumber16(edittext,(long)sprite[spritenum].cstat,32768L,0); + } + } + else if (col == 2) + { + for (i=Bsprintf(disptext,"Angle (2048 degrees): %d",sprite[spritenum].ang); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Angle: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].ang = (short)getnumber16(edittext,(long)sprite[spritenum].ang,2048L,0); + } + } + break; + case 1: + if (col == 0) + { + for (i=Bsprintf(disptext,"Y-coordinate: %ld",sprite[spritenum].y); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Y-coordinate: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].y = getnumber16(edittext,sprite[spritenum].y,131072,1); + } + } + else if (col == 1) + { + for (i=Bsprintf(disptext,"Shade: %d",sprite[spritenum].shade); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Shade: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].shade = (char)getnumber16(edittext,(long)sprite[spritenum].shade,127,1); + } + } + else if (col == 2) + { + for (i=Bsprintf(disptext,"X-Velocity: %d",sprite[spritenum].xvel); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) X-Velocity: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].xvel = getnumber16(edittext,(long)sprite[spritenum].xvel,32767,1); + } + } + break; + case 2: + if (col == 0) + { + for (i=Bsprintf(disptext,"Z-coordinate: %ld",sprite[spritenum].z); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Z-coordinate: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].z = getnumber16(edittext,sprite[spritenum].z,8388608,1); //2147483647L,-2147483648L + } + } + else if (col == 1) + { + for (i=Bsprintf(disptext,"Pal: %d",sprite[spritenum].pal); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Pal: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].pal = (char)getnumber16(edittext,(long)sprite[spritenum].pal,MAXPALOOKUPS,0); + } + } + else if (col == 2) + { + for (i=Bsprintf(disptext,"Y-Velocity: %d",sprite[spritenum].yvel); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Y-Velocity: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].yvel = getnumber16(edittext,(long)sprite[spritenum].yvel,32767,1); + } + } + + break; + case 3: + if (col == 1) + { + for (i=Bsprintf(disptext,"(X,Y)repeat: %d, %d",sprite[spritenum].xrepeat,sprite[spritenum].yrepeat); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Sprite (%d) X Repeat: ",spritenum); + printmessage16(edittext); + sprite[spritenum].xrepeat = (char)getnumber16(edittext,(long)sprite[spritenum].xrepeat,256L,0); + Bsprintf(edittext,"Sprite (%d) Y Repeat: ",spritenum); + printmessage16(edittext); + sprite[spritenum].yrepeat = (char)getnumber16(edittext,(long)sprite[spritenum].yrepeat,256L,0); + } + } + else if (col == 2) + { + for (i=Bsprintf(disptext,"Z-Velocity: %d",sprite[spritenum].zvel); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Z-Velocity: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].zvel = getnumber16(edittext,(long)sprite[spritenum].zvel,32767,1); + } + } + + break; + case 4: + if (col == 1) + { + for (i=Bsprintf(disptext,"(X,Y)offset: %d, %d",sprite[spritenum].xoffset,sprite[spritenum].yoffset); i < dispwidth; i++) disptext[i] = ' '; + if (editval) + { + Bsprintf(edittext,"Sprite (%d) X Offset: ",spritenum); + printmessage16(edittext); + sprite[spritenum].xoffset = (char)getnumber16(edittext,(long)sprite[spritenum].xoffset,128L,1); + Bsprintf(edittext,"Sprite (%d) Y Offset: ",spritenum); + printmessage16(edittext); + sprite[spritenum].yoffset = (char)getnumber16(edittext,(long)sprite[spritenum].yoffset,128L,1); + } + } + else if (col == 2) + { + for (i=Bsprintf(disptext,"Owner: %d",sprite[spritenum].owner); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Owner: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].owner = getnumber16(edittext,(long)sprite[spritenum].owner,MAXSPRITES,0); + } + } + + break; + case 5: + if (col == 1) + { + for (i=Bsprintf(disptext,"Tile number: %d",sprite[spritenum].picnum); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Tile number: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].picnum = (short)getnumber16(edittext,(long)sprite[spritenum].picnum,MAXTILES,0); + } + } + else if (col == 2) + { + for (i=Bsprintf(disptext,"Clipdist: %d",sprite[spritenum].clipdist); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Clipdist: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].clipdist = (char)getnumber16(edittext,(long)sprite[spritenum].clipdist,255,0); + } + } + + break; + case 6: + if (col == 2) + { + for (i=Bsprintf(disptext,"Extra: %d",sprite[spritenum].extra); i < dispwidth; i++) disptext[i] = ' '; + Bsprintf(edittext,"Sprite (%d) Extra: ",spritenum); + if (editval) + { + printmessage16(edittext); + sprite[spritenum].extra = getnumber16(edittext,(long)sprite[spritenum].extra,32767,1); + } + } + + break; + } + printext16(xpos,ypos+row*8,11,1,disptext,0); + if (editval) + { + editval = 0; + } + enddrawing(); + showframe(1); + } + begindrawing(); + printext16(xpos,ypos+row*8,11,0,disptext,0); + printmessage16(""); + enddrawing(); + showframe(1); + keystatus[1] = 0; +} + +// Build edit + +#define M_RED 12 +#define M_BLUE 9 + +void ResetKeys(void) +{ + int i; + + for (i = 0; i < MAXKEYBOARDSCAN; i++) + { + keystatus[i] = 0; + } +} + +void Msg(char *string, char color) +{ + clearmidstatbar16(); + + printext16(1*4,ydim16+4*8,color,-1,string,0); + +} + +long GetAToken(char *name, char *tc, long length) +{ + int i,x=0; + char t,*tmp,tokenfound=0; + char *token; + long count=0; + + if(!(token = (char *)malloc(9))) + { + Msg("Out of heap space!",M_RED); + return(tokenfound); + } + + + do{ + + // Find the token symbol + do { + t = *tc; + tc++; + count++; + } while(t!='@' && count < length); + + + if(t=='@') + { + tmp = token; + x=1; + + do { + // Read in the token + *tmp = t; + tmp++; + t = *tc; + tc++; + x++; + count++; + } while((t>=48 && t<=127) && t!='@' && x < 9 && count < length); + + *tmp = 0; + + if(!strcmp(name,Bstrupr(token))) + tokenfound = 1; + } + } while(!tokenfound && count < length); + + + if(!tokenfound) count=0; + return(count); + +} +/* +void ContextHelp(short spritenum) +{ + int i,fp; + char t,*tc; + char x=0,y=4; + char *name,*hightag; + char *filebuffer; + spritetype *sp; + short lotag=0; + long size=0,tokresult=0; + + + sp = &sprite[spritenum]; + + clearmidstatbar16(); + + if((fp=kopen4load("sehelp.hp2",0)) == -1) + { + Msg("ERROR: Help file not found.",M_RED); + return; + } + + // Read in whole file + size = kfilelength(fp); + filebuffer = (char *)malloc(size); + if (filebuffer == NULL) + { + Msg("Not enough memory to load sehelp.hp2",M_RED); + return; + } + + if (kread(fp, filebuffer, size) != size) + { + Msg("Unexpected end of file while reading sehelp.hp2",M_RED); + kclose(fp); + return; + } + + // close the file + kclose(fp); + + // Conver filebuffer to all upper case + //strupr(filebuffer); + + // Assign a token name to search for based on the sprite being pointed to. + name = (char *)malloc(20); + hightag = (char *)malloc(sizeof(short)); + + // Make the token + strcpy(name,"@TAG"); + // Make sure 500-600 SOBJ bounding tags all say the same thing. + lotag = sp->lotag; + if(lotag > 500 && lotag <= 600 ) lotag = 500; + // Give help summary for unknown sprites. + if((lotag == 0 || lotag > 1006) && sp->lotag == 0) lotag = 999; + + sprintf(hightag,"%d",lotag); + //itoa(lotag,hightag,10); + strcat(name,hightag); + + tc = filebuffer; + + if(!(tokresult = GetAToken(name,tc,size))) + { + // This message should never happen unless something is real wrong! + Msg("No help available.",M_RED); + return; + } + + tc += tokresult; + + do { + tc++; + t = *tc; + while(t!='\n' && t!='@' && t!='#' && x<128) + { + tempbuf[x]=t; + tc++; + t = *tc; + x++; + if(x >= 128) break; + } + tempbuf[x]=0; + x=0; + printext16(x*4,ydim16+(y*6)+2,11,-1,tempbuf,1); + y++; + + if(y>16) + { + y=18; + printext16(x*4,ydim16+(y*6)+2,11,-1,"Hit any key to continue or Q to quit....",1); + while (bgetchar() == NULL); + if (keystatus[KEYSC_Q]) + { + clearmidstatbar16(); + return; + } + ResetKeys(); + clearmidstatbar16(); + + y=6; + } + + } while(t!='@' && t!='#'); +} +*/ diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c new file mode 100644 index 000000000..9fa4b081c --- /dev/null +++ b/polymer/eduke32/source/config.c @@ -0,0 +1,794 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +/* +#include +#include +#include +#include +#include +*/ + +#include "duke3d.h" +#include "scriplib.h" +#include "osd.h" + +#include "baselayer.h" + +// we load this in to get default button and key assignments +// as well as setting up function mappings + +#define __SETUP__ // JBF 20031211 +#include "_functio.h" + +// +// Sound variables +// +int32 FXDevice; +int32 MusicDevice; +int32 FXVolume; +int32 MusicVolume; +int32 SoundToggle; +int32 MusicToggle; +int32 VoiceToggle; +int32 AmbienceToggle; +//fx_blaster_config BlasterConfig; +int32 NumVoices; +int32 NumChannels; +int32 NumBits; +int32 MixRate; +//int32 MidiPort; +int32 ReverseStereo; + +int32 ControllerType; +int32 RunMode; +int32 AutoAim; // JBF 20031125 +int32 ShowOpponentWeapons; + +// JBF 20031211: Store the input settings because +// (currently) jmact can't regurgitate them +byte KeyboardKeys[NUMGAMEFUNCTIONS][2]; +int32 MouseFunctions[MAXMOUSEBUTTONS][2]; +int32 MouseDigitalFunctions[MAXMOUSEAXES][2]; +int32 MouseAnalogueAxes[MAXMOUSEAXES]; +int32 MouseAnalogueScale[MAXMOUSEAXES]; +int32 JoystickFunctions[MAXJOYBUTTONS][2]; +int32 JoystickDigitalFunctions[MAXJOYAXES][2]; +int32 JoystickAnalogueAxes[MAXJOYAXES]; +int32 JoystickAnalogueScale[MAXJOYAXES]; +int32 JoystickAnalogueDead[MAXJOYAXES]; +int32 JoystickAnalogueSaturate[MAXJOYAXES]; + +// +// Screen variables +// + +int32 ScreenMode = 1; +int32 ScreenWidth = 640; +int32 ScreenHeight = 480; +int32 ScreenBPP = 8; + +static char setupfilename[256]={SETUPFILENAME}; +int32 scripthandle = -1; +static int32 setupread=0; + +/* +=================== += += CONFIG_FunctionNameToNum += +=================== +*/ + +int32 CONFIG_FunctionNameToNum( char * func ) +{ + int32 i; + + for (i=0;i= (unsigned)NUMGAMEFUNCTIONS) + { + return NULL; + } + else + { + return gamefunctions[func]; + } +} + +/* +=================== += += CONFIG_AnalogNameToNum += +=================== +*/ + + +int32 CONFIG_AnalogNameToNum( char * func ) +{ + + if (!Bstrcasecmp(func,"analog_turning")) + { + return analog_turning; + } + if (!Bstrcasecmp(func,"analog_strafing")) + { + return analog_strafing; + } + if (!Bstrcasecmp(func,"analog_moving")) + { + return analog_moving; + } + if (!Bstrcasecmp(func,"analog_lookingupanddown")) + { + return analog_lookingupanddown; + } + + return -1; +} + + +char * CONFIG_AnalogNumToName( int32 func ) +{ + switch (func) { + case analog_turning: + return "analog_turning"; + case analog_strafing: + return "analog_strafing"; + case analog_moving: + return "analog_moving"; + case analog_lookingupanddown: + return "analog_lookingupanddown"; + } + + return NULL; +} + + +/* +=================== += += CONFIG_SetDefaults += +=================== +*/ + +void CONFIG_SetDefaults( void ) +{ + // JBF 20031211 + int32 i,f; + byte k1,k2; + + FXDevice = -1; + MusicDevice = -1; + NumVoices = 8; + NumChannels = 2; + NumBits = 8; + MixRate = 22050; + SoundToggle = 1; + MusicToggle = 1; + VoiceToggle = 1; + AmbienceToggle = 1; + FXVolume = 220; + MusicVolume = 200; + ReverseStereo = 0; + myaimmode = ps[0].aim_mode = 0; + ud.mouseaiming = 0; + ud.weaponswitch = 3; // new+empty + AutoAim = 1; + ControllerType = 1; + ud.mouseflip = 0; + ud.runkey_mode = 0; + ud.statusbarscale = 100; + ud.screen_size = 8; + ud.screen_tilting = 1; + ud.shadows = 1; + ud.detail = 1; + ud.lockout = 0; + ud.pwlockout[0] = '\0'; + ud.crosshair = 0; + ud.m_marker = 1; + ud.m_ffire = 1; + ud.levelstats = 0; + ud.drawweapon = 1; + ShowOpponentWeapons = 0; + Bstrcpy(ud.rtsname, "DUKE.RTS"); + Bstrcpy(myname, "Duke"); + + Bstrcpy(ud.ridecule[0], "An inspiration for birth control."); + Bstrcpy(ud.ridecule[1], "You're gonna die for that!"); + Bstrcpy(ud.ridecule[2], "It hurts to be you."); + Bstrcpy(ud.ridecule[3], "Lucky Son of a Bitch."); + Bstrcpy(ud.ridecule[4], "Hmmm....Payback time."); + Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker."); + Bstrcpy(ud.ridecule[6], "Damn, you're ugly."); + Bstrcpy(ud.ridecule[7], "Ha ha ha...Wasted!"); + Bstrcpy(ud.ridecule[8], "You suck!"); + Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!"); + + // JBF 20031211 + memset(KeyboardKeys, 0xff, sizeof(KeyboardKeys)); + for (i=0; i < (int32)(sizeof(keydefaults)/sizeof(keydefaults[0]))/3; i++) { + f = CONFIG_FunctionNameToNum( keydefaults[3*i+0] ); + if (f == -1) continue; + k1 = KB_StringToScanCode( keydefaults[3*i+1] ); + k2 = KB_StringToScanCode( keydefaults[3*i+2] ); + + KeyboardKeys[f][0] = k1; + KeyboardKeys[f][1] = k2; + } + + memset(MouseFunctions, -1, sizeof(MouseFunctions)); + for (i=0; i= 0) + { + for(dummy = 0;dummy < 10;dummy++) + { + commmacro[13] = dummy+'0'; + SCRIPT_GetString( scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]); + } + + SCRIPT_GetString( scripthandle, "Comm Setup","PlayerName",&myname[0]); + + SCRIPT_GetString( scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]); + + SCRIPT_GetNumber( scripthandle, "Screen Setup", "Shadows",&ud.shadows); + SCRIPT_GetString( scripthandle, "Screen Setup","Password",&ud.pwlockout[0]); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "Detail",&ud.detail); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "Tilt",&ud.screen_tilting); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "Messages",&ud.fta_on); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "ScreenWidth",&ScreenWidth); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "ScreenHeight",&ScreenHeight); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "ScreenMode",&ScreenMode); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "ScreenGamma",&ud.brightness); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "ScreenSize",&ud.screen_size); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "Out",&ud.lockout); + + SCRIPT_GetNumber( scripthandle, "Screen Setup", "ScreenBPP", &ScreenBPP); + if (ScreenBPP < 8) ScreenBPP = 8; + +#ifdef RENDERTYPEWIN + SCRIPT_GetNumber( scripthandle, "Screen Setup", "MaxRefreshFreq", (int32*)&maxrefreshfreq); +#endif + + SCRIPT_GetNumber( scripthandle, "Screen Setup", "GLTextureMode", &gltexfiltermode); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "GLAnisotropy", &glanisotropy); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "GLUseTextureCompr", &glusetexcompr); + dummy = usemodels; SCRIPT_GetNumber( scripthandle, "Screen Setup", "UseModels",&dummy); usemodels = dummy != 0; + dummy = usehightile; SCRIPT_GetNumber( scripthandle, "Screen Setup", "UseHightile",&dummy); usehightile = dummy != 0; + + SCRIPT_GetNumber( scripthandle, "Misc", "Executions",&ud.executions); + ud.executions++; + SCRIPT_GetNumber( scripthandle, "Misc", "RunMode",&RunMode); + SCRIPT_GetNumber( scripthandle, "Misc", "Crosshairs",&ud.crosshair); + SCRIPT_GetNumber( scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale); + SCRIPT_GetNumber( scripthandle, "Misc", "ShowLevelStats",&ud.levelstats); + SCRIPT_GetNumber( scripthandle, "Misc", "ShowOpponentWeapons",&ShowOpponentWeapons); + SCRIPT_GetNumber( scripthandle, "Misc", "ShowViewWeapon",&ud.drawweapon); + SCRIPT_GetNumber( scripthandle, "Misc", "ShowFPS",&ud.tickrate); + dummy = useprecache; SCRIPT_GetNumber( scripthandle, "Misc", "UsePrecache",&dummy); useprecache = dummy != 0; + if(ud.wchoice[0][0] == 0 && ud.wchoice[0][1] == 0) + { + ud.wchoice[0][0] = 3; + ud.wchoice[0][1] = 4; + ud.wchoice[0][2] = 5; + ud.wchoice[0][3] = 7; + ud.wchoice[0][4] = 8; + ud.wchoice[0][5] = 6; + ud.wchoice[0][6] = 0; + ud.wchoice[0][7] = 2; + ud.wchoice[0][8] = 9; + ud.wchoice[0][9] = 1; + + for(dummy=0;dummy<10;dummy++) + { + Bsprintf(buf,"WeaponChoice%ld",dummy); + SCRIPT_GetNumber( scripthandle, "Misc", buf, &ud.wchoice[0][dummy]); + } + } + + SCRIPT_GetNumber( scripthandle, "Sound Setup", "FXDevice",&FXDevice); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "MusicDevice",&MusicDevice); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "FXVolume",&FXVolume); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "MusicVolume",&MusicVolume); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "SoundToggle",&SoundToggle); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "MusicToggle",&MusicToggle); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "VoiceToggle",&VoiceToggle); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "AmbienceToggle",&AmbienceToggle); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "NumVoices",&NumVoices); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "NumChannels",&NumChannels); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "NumBits",&NumBits); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "MixRate",&MixRate); + SCRIPT_GetNumber( scripthandle, "Sound Setup", "ReverseStereo",&ReverseStereo); + + SCRIPT_GetNumber( scripthandle, "Controls","ControllerType",&ControllerType); + SCRIPT_GetNumber( scripthandle, "Controls","MouseAimingFlipped",&ud.mouseflip); // mouse aiming inverted + SCRIPT_GetNumber( scripthandle, "Controls","MouseAiming",&ud.mouseaiming); // 1=momentary/0=toggle + //SCRIPT_GetNumber( scripthandle, "Controls","GameMouseAiming",(int32 *)&ps[0].aim_mode); // dupe of below (?) + ps[0].aim_mode = ud.mouseaiming; + SCRIPT_GetNumber( scripthandle, "Controls","AimingFlag",(int32 *)&myaimmode); // (if toggle mode) gives state + SCRIPT_GetNumber( scripthandle, "Controls","RunKeyBehaviour",&ud.runkey_mode); // JBF 20031125 + SCRIPT_GetNumber( scripthandle, "Controls","AutoAim",&AutoAim); // JBF 20031125 + ps[0].auto_aim = AutoAim; + SCRIPT_GetNumber( scripthandle, "Controls","WeaponSwitchMode",&ud.weaponswitch); + glusetexcache = glusetexcachecompression = -1; + SCRIPT_GetNumber( scripthandle, "Screen Setup", "GLUseCompressedTextureCache", &glusetexcache); + SCRIPT_GetNumber( scripthandle, "Screen Setup", "GLUseTextureCacheCompression", &glusetexcachecompression); + if(glusetexcache == -1 && glusetexcachecompression == -1) + { + i=wm_ynbox("Texture caching", + "Would you like to enable the on-disk texture cache? " + "This feature may use up to 200 megabytes of disk " + "space if you have a great deal of high resolution " + "textures and skins, but textures will load exponentially " + "faster after the first time they are loaded."); + if (i) i = 'y'; + if(i == 'y' || i == 'Y' ) + useprecache = glusetexcompr = glusetexcache = glusetexcachecompression = 1; + else glusetexcache = glusetexcachecompression = 0; + } + + } + + CONFIG_ReadKeys(); + + //CONFIG_SetupMouse(scripthandle); + //CONFIG_SetupJoystick(scripthandle); + + setupread = 1; +} + +/* +=================== += += CONFIG_WriteSetup += +=================== +*/ + +void CONFIG_WriteSetup( void ) +{ + int32 dummy; + + //if (!setupread) return; + if (scripthandle < 0) + scripthandle = SCRIPT_Init(setupfilename); + + SCRIPT_PutNumber( scripthandle, "Screen Setup", "Shadows",ud.shadows,false,false); + SCRIPT_PutString( scripthandle, "Screen Setup", "Password",ud.pwlockout); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "Detail",ud.detail,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "Tilt",ud.screen_tilting,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "Messages",ud.fta_on,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "Out",ud.lockout,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "ScreenWidth",ScreenWidth,false,false); // JBF 20031206 + SCRIPT_PutNumber( scripthandle, "Screen Setup", "ScreenHeight",ScreenHeight,false,false); // JBF 20031206 + SCRIPT_PutNumber( scripthandle, "Screen Setup", "ScreenMode",ScreenMode,false,false); // JBF 20031206 + SCRIPT_PutNumber( scripthandle, "Screen Setup", "ScreenBPP",ScreenBPP,false,false); // JBF 20040523 +#ifdef RENDERTYPEWIN + SCRIPT_PutNumber( scripthandle, "Screen Setup", "MaxRefreshFreq",maxrefreshfreq,false,false); +#endif + SCRIPT_PutNumber( scripthandle, "Screen Setup", "GLTextureMode",gltexfiltermode,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "GLAnisotropy",glanisotropy,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "GLUseTextureCompr",glusetexcompr,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "GLUseCompressedTextureCache", glusetexcache,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "GLUseTextureCacheCompression", glusetexcachecompression,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "UseModels",usemodels,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "UseHightile",usehightile,false,false); + SCRIPT_PutNumber( scripthandle, "Sound Setup", "FXVolume",FXVolume,false,false); + SCRIPT_PutNumber( scripthandle, "Sound Setup", "MusicVolume",MusicVolume,false,false); + SCRIPT_PutNumber( scripthandle, "Sound Setup", "SoundToggle",SoundToggle,false,false); + SCRIPT_PutNumber( scripthandle, "Sound Setup", "VoiceToggle",VoiceToggle,false,false); + SCRIPT_PutNumber( scripthandle, "Sound Setup", "AmbienceToggle",AmbienceToggle,false,false); + SCRIPT_PutNumber( scripthandle, "Sound Setup", "MusicToggle",MusicToggle,false,false); + SCRIPT_PutNumber( scripthandle, "Sound Setup", "ReverseStereo",ReverseStereo,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "ScreenSize",ud.screen_size,false,false); + SCRIPT_PutNumber( scripthandle, "Screen Setup", "ScreenGamma",ud.brightness,false,false); + SCRIPT_PutNumber( scripthandle, "Misc", "Executions",ud.executions,false,false); + SCRIPT_PutNumber( scripthandle, "Misc", "RunMode",RunMode,false,false); + SCRIPT_PutNumber( scripthandle, "Misc", "Crosshairs",ud.crosshair,false,false); + SCRIPT_PutNumber( scripthandle, "Misc", "ShowLevelStats",ud.levelstats,false,false); + SCRIPT_PutNumber( scripthandle, "Misc", "StatusBarScale",ud.statusbarscale,false,false); + SCRIPT_PutNumber( scripthandle, "Misc", "ShowOpponentWeapons",ShowOpponentWeapons,false,false); + SCRIPT_PutNumber( scripthandle, "Misc", "UsePrecache",useprecache,false,false); + SCRIPT_PutNumber( scripthandle, "Misc", "ShowViewWeapon",ud.drawweapon,false,false); + SCRIPT_PutNumber( scripthandle, "Misc", "ShowFPS",ud.tickrate,false,false); + SCRIPT_PutNumber( scripthandle, "Controls", "MouseAimingFlipped",ud.mouseflip,false,false); + SCRIPT_PutNumber( scripthandle, "Controls","MouseAiming",ud.mouseaiming,false,false); + //SCRIPT_PutNumber( scripthandle, "Controls","GameMouseAiming",(int32) ps[myconnectindex].aim_mode,false,false); + SCRIPT_PutNumber( scripthandle, "Controls","AimingFlag",(long) myaimmode,false,false); + SCRIPT_PutNumber( scripthandle, "Controls","RunKeyBehaviour",ud.runkey_mode,false,false); + SCRIPT_PutNumber( scripthandle, "Controls","AutoAim",AutoAim,false,false); + SCRIPT_PutNumber( scripthandle, "Controls","WeaponSwitchMode",ud.weaponswitch,false,false); + + // JBF 20031211 + for(dummy=0;dummy= (MAXMOUSEBUTTONS-2)) continue; + + Bsprintf(buf,"MouseButtonClicked%ld",dummy); + SCRIPT_PutString( scripthandle,"Controls", buf, CONFIG_FunctionNumToName( MouseFunctions[dummy][1] )); + } + for (dummy=0;dummysectnum,s->x+(TRAND&255)-128,s->y+(TRAND&255)-128,s->z-(8<<8)-(TRAND&8191),SCRAP6+(TRAND&15),-8,48,48,TRAND&2047,(TRAND&63)+64,-512-(TRAND&2047),i,5) + +#define PHEIGHT (38<<8) + +// #define P(X) printf("%ld\n",X); + +#define WAIT(X) ototalclock=totalclock+(X);while(totalclock=(B) && (PN)<=(E)) +#define KILLIT(KX) {ResetActorGameVars(KX);deletesprite(KX);goto BOLT;} + + +#define IFMOVING if(ssp(i,CLIPMASK0)) +#define IFHIT j=ifhitbyweapon(i);if(j >= 0) +#define IFHITSECT j=ifhitsectors(s->sectnum);if(j >= 0) + +#define AFLAMABLE(X) (X==BOX||X==TREE1||X==TREE2||X==TIRE||X==CONE) + + +#define IFSKILL1 if(player_skill<1) +#define IFSKILL2 if(player_skill<2) +#define IFSKILL3 if(player_skill<3) +#define IFSKILL4 if(player_skill<4) + +#define rnd(X) ((TRAND>>8)>=(255-(X))) + +typedef struct { + short i; + int voice; +} SOUNDOWNER; + +#define __USRHOOKS_H + +enum USRHOOKS_Errors { + USRHOOKS_Warning = -2, + USRHOOKS_Error = -1, + USRHOOKS_Ok = 0 +}; + +typedef struct { + signed char avel, horz; + short fvel, svel; + unsigned long bits, bits2; +} input; + +#define sync dsync // JBF 20040604: sync is a function on some platforms +extern input inputfifo[MOVEFIFOSIZ][MAXPLAYERS], sync[MAXPLAYERS]; +extern input recsync[RECSYNCBUFSIZ]; + +extern long movefifosendplc; + +typedef struct { + char *ptr; + volatile char lock; +int length, num; +} SAMPLE; + +struct animwalltype { + short wallnum; + long tag; +}; + +extern struct animwalltype animwall[MAXANIMWALLS]; +extern short numanimwalls,probey,lastprobey; + +extern char typebuflen,typebuf[41]; +extern char MusicPtr[72000*2]; +extern long msx[2048],msy[2048]; +extern short cyclers[MAXCYCLERS][6],numcyclers; +extern char myname[32]; + +struct savehead { + char name[19]; + int32 numplr,volnum,levnum,plrskl; + char boardfn[BMAX_PATH]; +}; + +struct user_defs { + char god,warp_on,cashman,eog,showallmap; + char show_help,scrollmode,clipping; + char user_name[MAXPLAYERS][32]; + char ridecule[10][40]; + char savegame[10][22]; + char pwlockout[128],rtsname[128]; + char overhead_on,last_overhead,showweapons; + + short pause_on,from_bonus; + short camerasprite,last_camsprite; + short last_level,secretlevel; + + long const_visibility,uw_framerate; + long camera_time,folfvel,folavel,folx,foly,fola; + long reccnt; + + int32 runkey_mode,statusbarscale,mouseaiming,weaponswitch,drawweapon; // JBF 20031125 + + int32 entered_name,screen_tilting,shadows,fta_on,executions,auto_run; + int32 coords,tickrate,levelstats,m_coop,coop,screen_size,lockout,crosshair; + int32 wchoice[MAXPLAYERS][MAX_WEAPONS],playerai; + + int32 respawn_monsters,respawn_items,respawn_inventory,recstat,monsters_off,brightness; + int32 m_respawn_items,m_respawn_monsters,m_respawn_inventory,m_recstat,m_monsters_off,detail; + int32 m_ffire,ffire,m_player_skill,m_level_number,m_volume_number,multimode; + int32 player_skill,level_number,volume_number,m_marker,marker,mouseflip; +}; + +struct player_orig { + long ox,oy,oz; + short oa,os; +}; + + +extern char numplayersprites; +extern char picsiz[MAXTILES]; + +extern long fricxv,fricyv; + +struct player_struct { + long zoom,exitx,exity,loogiex[64],loogiey[64],numloogs,loogcnt; + long posx, posy, posz, horiz, ohoriz, ohorizoff, invdisptime; + long bobposx,bobposy,oposx,oposy,oposz,pyoff,opyoff; + long posxv,posyv,poszv,last_pissed_time,truefz,truecz; + long player_par,visibility; + long bobcounter,weapon_sway; + long pals_time,randomflamex,crack_time; + + char aim_mode,auto_aim,weaponswitch; + + short ang,oang,angvel,cursectnum,look_ang,last_extra,subweapon; + short ammo_amount[MAX_WEAPONS],wackedbyactor,frag,fraggedself; + + short curr_weapon, last_weapon, tipincs, horizoff, wantweaponfire; + short holoduke_amount,newowner,hurt_delay,hbomb_hold_delay; + short jumping_counter,airleft,knee_incs,access_incs; + short fta,ftq,access_wallnum,access_spritenum; + short kickback_pic,got_access,weapon_ang,firstaid_amount; + short somethingonplayer,on_crane,i,one_parallax_sectnum; + short over_shoulder_on,random_club_frame,fist_incs; + short one_eighty_count,cheat_phase; + short dummyplayersprite,extra_extra8,quick_kick; + short heat_amount,actorsqu,timebeforeexit,customexitsound; + + short weaprecs[16],weapreccnt; + unsigned long interface_toggle_flag; + + short orotscrnang,rotscrnang,dead_flag,show_empty_weapon; // JBF 20031220: added orotscrnang + short scuba_amount,jetpack_amount,steroids_amount,shield_amount; + short holoduke_on,pycount,weapon_pos,frag_ps; + short transporter_hold,last_full_weapon,footprintshade,boot_amount; + + int scream_voice; + + char gm,on_warping_sector,footprintcount; + char hbomb_on,jumping_toggle,rapid_fire_hold,on_ground; + char name[32],inven_icon,buttonpalette; + + char jetpack_on,spritebridge,lastrandomspot; + char scuba_on,footprintpal,heat_on; + + char holster_weapon,falling_counter; + char gotweapon[MAX_WEAPONS],refresh_inventory,*palette; + + char toggle_key_flag,knuckle_incs; // ,select_dir; + char walking_snd_toggle, palookup, hard_landing; + char /*fire_flag,*/pals[3]; + char return_to_center, reloading, movement_lock[4]; + + long max_secret_rooms,secret_rooms,max_actors_killed,actors_killed; + long runspeed; + short sbs, sound_pitch; +}; + +extern char tempbuf[2048], packbuf[576]; + +extern long gc,max_player_health,max_armour_amount,max_ammo_amount[MAX_WEAPONS]; + +extern long impact_damage,respawnactortime,respawnitemtime; + +#define MOVFIFOSIZ 256 + +extern short spriteq[1024],spriteqloc,spriteqamount; +extern struct player_struct ps[MAXPLAYERS]; +extern struct player_orig po[MAXPLAYERS]; +extern struct user_defs ud; +extern short int moustat; +extern short int global_random; +extern long scaredfallz; +extern char buf[1024]; //My own generic input buffer + +extern char fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; +extern char scantoasc[128],ready2send; +extern char scantoascwithshift[128]; + +//extern fx_device device; +extern SAMPLE Sound[ NUM_SOUNDS ]; +extern int32 VoiceToggle,AmbienceToggle; +extern SOUNDOWNER SoundOwner[NUM_SOUNDS][4]; + +extern char playerreadyflag[MAXPLAYERS],playerquitflag[MAXPLAYERS]; +extern char sounds[NUM_SOUNDS][BMAX_PATH]; + +// JBF 20040531: adding 16 extra to the script so we have some leeway +// to (hopefully) safely abort when hitting the limit +extern long script[MAXSCRIPTSIZE+16],*scriptptr,*insptr,*labelcode,labelcnt,defaultlabelcnt,*labeltype; +extern char *label,*textptr,error,warning,killit_flag; +extern long *actorscrptr[MAXTILES],*parsing_actor; +extern long *actorLoadEventScrptr[MAXTILES]; +extern char actortype[MAXTILES]; +extern char *music_pointer; + +extern char ipath[80],opath[80]; + +extern char music_fn[8][11][13],music_select; +extern char env_music_fn[8][13]; +extern short camsprite; + +// extern char gotz; +extern char inspace(short sectnum); + +struct weaponhit { + char cgg; + short picnum,ang,extra,owner,movflag; + short tempang,actorstayput,dispicnum; + short timetosleep; + long floorz,ceilingz,lastvx,lastvy,bposx,bposy,bposz; + long temp_data[10]; +}; + +extern struct weaponhit hittype[MAXSPRITES]; + +extern input loc; +extern input recsync[RECSYNCBUFSIZ]; +extern long avgfvel, avgsvel, avgavel, avghorz, avgbits, avgbits2; + +extern long numplayers, myconnectindex; +extern long connecthead, connectpoint2[MAXPLAYERS]; //Player linked list variables (indeces, not connection numbers) +extern short screenpeek; + +extern int current_menu; +extern long tempwallptr,animatecnt; +extern long lockclock,frameplace; +extern char display_mirror,loadfromgrouponly,rtsplaying; + +extern long movefifoend[MAXPLAYERS], groupfile; +extern long ototalclock; + +extern long *animateptr[MAXANIMATES], animategoal[MAXANIMATES]; +extern long animatevel[MAXANIMATES]; +// extern long oanimateval[MAXANIMATES]; +extern short neartagsector, neartagwall, neartagsprite; +extern long neartaghitdist; +extern short animatesect[MAXANIMATES]; +extern long movefifoplc, vel,svel,angvel,horiz; + +extern short mirrorwall[64], mirrorsector[64], mirrorcnt; + +#define NUMKEYS 19 + +extern long frameplace, chainplace, chainnumpages; + +#include "funct.h" + +extern char screencapt; +extern short soundps[NUM_SOUNDS],soundpe[NUM_SOUNDS],soundvo[NUM_SOUNDS]; +extern char soundpr[NUM_SOUNDS],soundm[NUM_SOUNDS]; +extern long soundsiz[NUM_SOUNDS]; +extern char level_names[77][33]; +extern long partime[77],designertime[77]; +extern char volume_names[7][33]; +extern char skill_names[5][33]; + +#define MAXGAMETYPES 32 +extern char gametype_names[MAXGAMETYPES][33]; +extern int gametype_flags[MAXGAMETYPES]; +extern char num_gametypes; + +enum gametypeflags { + GAMETYPE_FLAG_COOP = 1, + GAMETYPE_FLAG_WEAPSTAY = 2, + GAMETYPE_FLAG_FRAGBAR = 4, + GAMETYPE_FLAG_SCORESHEET = 8, + GAMETYPE_FLAG_DMSWITCHES = 16, + GAMETYPE_FLAG_COOPSPAWN = 32, + GAMETYPE_FLAG_ACCESSCARDSPRITES = 64, + GAMETYPE_FLAG_COOPVIEW = 128, + GAMETYPE_FLAG_COOPSOUND = 256, + GAMETYPE_FLAG_OTHERPLAYERSINMAP = 512, + GAMETYPE_FLAG_ITEMRESPAWN = 1024, + GAMETYPE_FLAG_MARKEROPTION = 2048, + GAMETYPE_FLAG_PLAYERSFRIENDLY = 4096, + GAMETYPE_FLAG_FIXEDRESPAWN = 8192, + GAMETYPE_FLAG_ACCESSATSTART = 16384, + GAMETYPE_FLAG_PRESERVEINVENTORYDEATH = 32768 +}; + +extern char level_file_names[77][BMAX_PATH]; +extern char num_volumes; + +extern int32 SoundToggle,MusicToggle; +extern short last_threehundred,lastsavedpos; +extern char restorepalette; + +extern short buttonstat; +extern long cachecount; +extern char boardfilename[BMAX_PATH],waterpal[768],slimepal[768],titlepal[768],drealms[768],endingpal[768]; +extern char betaname[80]; +extern char cachedebug,earthquaketime; +extern char networkmode; +extern char lumplockbyte[11]; + +//DUKE3D.H - replace the end "my's" with this +extern long myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; +extern short myhoriz, omyhoriz, myhorizoff, omyhorizoff, globalskillsound; +extern short myang, omyang, mycursectnum, myjumpingcounter; +extern char myjumpingtoggle, myonground, myhardlanding,myreturntocenter; +extern long fakemovefifoplc; +extern long myxbak[MOVEFIFOSIZ], myybak[MOVEFIFOSIZ], myzbak[MOVEFIFOSIZ]; +extern long myhorizbak[MOVEFIFOSIZ]; +extern short myangbak[MOVEFIFOSIZ]; + +extern short weaponsandammosprites[15]; + +//DUKE3D.H: +typedef struct { + short frag[MAXPLAYERS], got_access, last_extra, shield_amount, curr_weapon; + short ammo_amount[MAX_WEAPONS], holoduke_on; + char gotweapon[MAX_WEAPONS], inven_icon, jetpack_on, heat_on; + short firstaid_amount, steroids_amount, holoduke_amount, jetpack_amount; + short heat_amount, scuba_amount, boot_amount; + short last_weapon, weapon_pos, kickback_pic; +} STATUSBARTYPE; + +extern STATUSBARTYPE sbar; +extern short frags[MAXPLAYERS][MAXPLAYERS]; +extern long cameradist, cameraclock, dukefriction,show_shareware; +extern char networkmode, movesperpacket; +extern char gamequit; + +extern char pus,pub,camerashitable,freezerhurtowner,lasermode; +extern char syncstat, syncval[MAXPLAYERS][MOVEFIFOSIZ]; +extern signed char multiwho, multipos, multiwhat, multiflag; +extern long syncvalhead[MAXPLAYERS], syncvaltail, syncvaltottail; +extern long numfreezebounces,rpgblastradius,pipebombblastradius,tripbombblastradius,shrinkerblastradius,morterblastradius,bouncemineblastradius,seenineblastradius; +extern char stereo,playerswhenstarted,everyothertime; +extern long myminlag[MAXPLAYERS], mymaxlag, otherminlag, bufferjitter; + +extern long numinterpolations, startofdynamicinterpolations; +extern long oldipos[MAXINTERPOLATIONS]; +extern long bakipos[MAXINTERPOLATIONS]; +extern long *curipos[MAXINTERPOLATIONS]; + +extern short numclouds,clouds[128],cloudx[128],cloudy[128]; +extern long cloudtotalclock,totalmemory; + +extern long stereomode, stereowidth, stereopixelwidth; + +extern long myaimmode, myaimstat, omyaimstat; + +#define IFISGLMODE if (getrendermode() >= 3) +#define IFISSOFTMODE if (getrendermode() < 3) + +#define TILE_SAVESHOT (MAXTILES-1) +#define TILE_LOADSHOT (MAXTILES-3) +#define TILE_TILT (MAXTILES-2) +#define TILE_ANIM (MAXTILES-4) +#define TILE_VIEWSCR (MAXTILES-5) + +extern char useprecache; + +enum events { + EVENT_INIT, + EVENT_ENTERLEVEL, + EVENT_RESETWEAPONS, + EVENT_RESETINVENTORY, + EVENT_HOLSTER, + EVENT_LOOKLEFT, + EVENT_LOOKRIGHT, + EVENT_SOARUP, + EVENT_SOARDOWN, + EVENT_CROUCH, + EVENT_JUMP, + EVENT_RETURNTOCENTER, + EVENT_LOOKUP, + EVENT_LOOKDOWN, + EVENT_AIMUP, + EVENT_FIRE, + EVENT_CHANGEWEAPON, + EVENT_GETSHOTRANGE, + EVENT_GETAUTOAIMANGLE, + EVENT_GETLOADTILE, + EVENT_CHEATGETSTEROIDS, + EVENT_CHEATGETHEAT, + EVENT_CHEATGETBOOT, + EVENT_CHEATGETSHIELD, + EVENT_CHEATGETSCUBA, + EVENT_CHEATGETHOLODUKE, + EVENT_CHEATGETJETPACK, + EVENT_CHEATGETFIRSTAID, + EVENT_QUICKKICK, + EVENT_INVENTORY, + EVENT_USENIGHTVISION, + EVENT_USESTEROIDS, + EVENT_INVENTORYLEFT, + EVENT_INVENTORYRIGHT, + EVENT_HOLODUKEON, + EVENT_HOLODUKEOFF, + EVENT_USEMEDKIT, + EVENT_USEJETPACK, + EVENT_TURNAROUND, + EVENT_DISPLAYWEAPON, + EVENT_FIREWEAPON, + EVENT_SELECTWEAPON, + EVENT_MOVEFORWARD, + EVENT_MOVEBACKWARD, + EVENT_TURNLEFT, + EVENT_TURNRIGHT, + EVENT_STRAFELEFT, + EVENT_STRAFERIGHT, + EVENT_WEAPKEY1, + EVENT_WEAPKEY2, + EVENT_WEAPKEY3, + EVENT_WEAPKEY4, + EVENT_WEAPKEY5, + EVENT_WEAPKEY6, + EVENT_WEAPKEY7, + EVENT_WEAPKEY8, + EVENT_WEAPKEY9, + EVENT_WEAPKEY10, + EVENT_DRAWWEAPON, + EVENT_DISPLAYCROSSHAIR, + EVENT_DISPLAYREST, + EVENT_RESETPLAYER, + EVENT_INCURDAMAGE, + EVENT_AIMDOWN, + EVENT_GAME, + EVENT_PREVIOUSWEAPON, + EVENT_NEXTWEAPON, + EVENT_SWIMUP, + EVENT_SWIMDOWN, + EVENT_GETMENUTILE, + EVENT_SPAWN, + EVENT_LOGO, + EVENT_EGS, + EVENT_DOFIRE, + EVENT_PRESSEDFIRE, + EVENT_USE, + EVENT_PROCESSINPUT +}; + +// store global game definitions + +enum gamevarflags { + MAXGAMEVARS = 1024, + MAXVARLABEL = 26, + GAMEVAR_FLAG_NORMAL = 0, // normal + GAMEVAR_FLAG_PERPLAYER = 1, // per-player variable + GAMEVAR_FLAG_PERACTOR = 2, // per-actor variable + GAMEVAR_FLAG_USER_MASK = 3, + GAMEVAR_FLAG_DEFAULT = 256, // allow override + GAMEVAR_FLAG_SECRET = 512, // don't dump... + GAMEVAR_FLAG_NODEFAULT = 1024, // don't add to 'default' array. + GAMEVAR_FLAG_SYSTEM = 2048, // cannot change mode flags...(only default value) + GAMEVAR_FLAG_READONLY = 4096, // values are read-only (no setvar allowed) + GAMEVAR_FLAG_PLONG = 8192, // plValue is a pointer to a long + GAMEVAR_FLAG_SYNCCHECK = 16384 // check event sync when translating +}; + +typedef struct { + long lValue; + char szLabel[MAXVARLABEL]; + unsigned long dwFlags; + + long *plValues; // array of values when 'per-player', or 'per-actor' +} MATTGAMEVAR; + +extern MATTGAMEVAR aGameVars[MAXGAMEVARS]; +extern MATTGAMEVAR aDefaultGameVars[MAXGAMEVARS]; +extern int iGameVarCount; + +extern int spriteflags[MAXTILES], actorspriteflags[MAXSPRITES]; +extern inline int checkspriteflags(short sActor, int iType); +extern inline int checkspriteflagsp(short sPicnum, int iType); + +enum spriteflags { + SPRITE_FLAG_SHADOW = 1, + SPRITE_FLAG_NVG = 2, + SPRITE_FLAG_NOSHADE = 4, + SPRITE_FLAG_PROJECTILE = 8, + SPRITE_FLAG_DECAL = 16, + SPRITE_FLAG_BADGUY = 32 +}; + +extern short spritecache[MAXTILES][3]; + +extern int g_iReturnVarID; +extern int g_iWeaponVarID; +extern int g_iWorksLikeVarID; +extern int g_iZRangeVarID; +extern int g_iAngRangeVarID; +extern int g_iAimAngleVarID; +extern int g_iLoTagID; // var ID of "LOTAG" +extern int g_iHiTagID; // ver ID of "HITAG" +extern int g_iTextureID; // ver ID of "TEXTURE" + +extern char g_bEnhanced; // are we 'enhanced' (more minerals, etc) + +extern char g_szBuf[1024]; + +#define NAM_GRENADE_LIFETIME 120 +#define NAM_GRENADE_LIFETIME_VAR 30 + +extern long *aplWeaponClip[MAX_WEAPONS]; // number of items in clip +extern long *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) +extern long *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire +extern long *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) +extern long *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. +extern long *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon +extern long *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots +extern long *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item +extern long *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn +extern long *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst' +extern long *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like +extern long *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when initialy firing. zero for no sound +extern long *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic) +extern long *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time +extern long *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID +extern long *aplWeaponRenderSize[MAX_WEAPONS]; // Rendering size +extern long *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed +extern long *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted + +extern short timer; + +enum weaponflags { + WEAPON_FLAG_HOLSTER_CLEARS_CLIP = 1, // 'holstering' clears the current clip + WEAPON_FLAG_GLOWS = 2, // weapon 'glows' (shrinker and grower) + WEAPON_FLAG_AUTOMATIC = 4, // automatic fire (continues while 'fire' is held down + WEAPON_FLAG_FIREEVERYOTHER = 8, // during 'hold time' fire every frame + WEAPON_FLAG_FIREEVERYTHIRD = 16, // during 'hold time' fire every third frame + WEAPON_FLAG_RANDOMRESTART = 32, // restart for automatic is 'randomized' by RND 3 + WEAPON_FLAG_AMMOPERSHOT = 64, // uses ammo for each shot (for automatic) + WEAPON_FLAG_BOMB_TRIGGER = 128, // weapon is the 'bomb' trigger + WEAPON_FLAG_NOVISIBLE = 256, // weapon use does not cause user to become 'visible' + WEAPON_FLAG_THROWIT = 512, // weapon 'throws' the 'shoots' item... + WEAPON_FLAG_CHECKATRELOAD = 1024, // check weapon availability at 'reload' time + WEAPON_FLAG_STANDSTILL = 2048, // player stops jumping before actual fire (like tripbomb in duke) + WEAPON_FLAG_SPAWNTYPE1 = 0, // just spawn + WEAPON_FLAG_SPAWNTYPE2 = 4096, // spawn like shotgun shells + WEAPON_FLAG_SPAWNTYPE3 = 8192, // spawn like chaingun shells + WEAPON_FLAG_SEMIAUTO = 16384, // cancel button press after each shot + WEAPON_FLAG_RELOAD_TIMING = 32768 // special casing for pistol reload sounds +}; + +#define TRIPBOMB_TRIPWIRE 1 +#define TRIPBOMB_TIMER 2 + +#define PIPEBOMB_REMOTE 1 +#define PIPEBOMB_TIMER 2 + +// custom projectiles + +enum projectileflags { + PROJECTILE_FLAG_BULLET = 1, + PROJECTILE_FLAG_RPG = 2, + PROJECTILE_FLAG_BOUNCESOFFWALLS = 4, + PROJECTILE_FLAG_BOUNCESOFFMIRRORS = 8, + PROJECTILE_FLAG_KNEE = 16, + PROJECTILE_FLAG_WATERBUBBLES = 32, + PROJECTILE_FLAG_TIMED = 64, + PROJECTILE_FLAG_NOENEMYHITS = 128, + PROJECTILE_FLAG_SPIT = 256, + PROJECTILE_FLAG_COOLEXPLOSION1 = 512, + PROJECTILE_FLAG_BLOOD = 1024, + PROJECTILE_FLAG_LOSESVELOCITY = 2048, + PROJECTILE_FLAG_NOAIM = 4096, + PROJECTILE_FLAG_RANDDECALSIZE = 8192, + PROJECTILE_FLAG_EXPLODEONTIMER = 16384, + PROJECTILE_FLAG_RPG_IMPACT = 32768 +}; + +typedef struct { + int workslike, extra, cstat, extra_rand, hitradius, range; + short spawns, sound, isound, vel, decal, trail, tnum, drop, clipdist, offset, bounces, bsound, toffset; + signed char sxrepeat, syrepeat, txrepeat, tyrepeat, shade, xrepeat, yrepeat, pal, velmult; +} proj_struct; + +proj_struct projectile[MAXTILES], thisprojectile[MAXSPRITES], defaultprojectile[MAXTILES]; + +// logo control + +enum logoflags { + LOGO_FLAG_ENABLED = 1, + LOGO_FLAG_PLAYANIM = 2, + LOGO_FLAG_PLAYMUSIC = 4, + LOGO_FLAG_3DRSCREEN = 8, + LOGO_FLAG_TITLESCREEN = 16, + LOGO_FLAG_DUKENUKEM = 32, + LOGO_FLAG_THREEDEE = 64, + LOGO_FLAG_PLUTOPAKSPRITE = 128 +}; + +extern char numl, condebug; + +extern char cheatkey[2]; + +#define MAXCHEATLEN 20 + +extern short weapon_sprites[MAX_WEAPONS]; + +#ifdef __cplusplus +} +#endif diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h new file mode 100644 index 000000000..423d161a1 --- /dev/null +++ b/polymer/eduke32/source/funct.h @@ -0,0 +1,355 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#ifndef __funct_h__ +#define __funct_h__ + +struct player_struct; // JBF: duke3d.h defines this later + +extern void sendscore(char *s); +extern void SoundStartup(void ); +extern void SoundShutdown(void ); +extern void MusicStartup(void ); +extern void MusicShutdown(void ); +extern int USRHOOKS_GetMem(char **ptr,unsigned long size); +extern int USRHOOKS_FreeMem(char *ptr); +extern void intomenusounds(void ); +extern void playmusic(char *fn); +extern char loadsound(unsigned short num); +extern int xyzsound(short num,short i,long x,long y,long z); +extern void sound(short num); +extern int spritesound(unsigned short num,short i); +extern void stopsound(short num); +extern void stopenvsound(short num,short i); +extern void pan3dsound(void ); +extern void testcallback(unsigned long num); +extern void clearsoundlocks(void); +extern short callsound(short sn,short whatsprite); +extern short check_activator_motion(short lotag); +extern char isadoorwall(short dapic); +extern char isanunderoperator(short lotag); +extern char isanearoperator(short lotag); +extern short checkcursectnums(short sect); +extern long ldist(spritetype *s1,spritetype *s2); +extern long dist(spritetype *s1,spritetype *s2); +extern short findplayer(spritetype *s,long *d); +extern short findotherplayer(short p,long *d); +extern void doanimations(void ); +extern int getanimationgoal(long *animptr); +extern int setanimation(short animsect,long *animptr,long thegoal,long thevel); +extern void animatecamsprite(void ); +extern void animatewalls(void ); +extern char activatewarpelevators(short s,short d); +extern void operatesectors(short sn,short ii); +extern void operaterespawns(short low); +extern void operateactivators(short low,short snum); +extern void operatemasterswitches(short low); +extern void operateforcefields(short s,short low); +extern char checkhitswitch(short snum,long w,char switchtype); +extern void activatebysector(short sect,short j); +extern void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith); +extern void checkplayerhurt(struct player_struct *p,short j); +extern char checkhitceiling(short sn); +extern void checkhitsprite(short i,short sn); +extern void allignwarpelevators(void ); +extern void cheatkeys(short snum); +extern void checksectors(short snum); +extern int32 RTS_AddFile(char *filename); +extern void RTS_Init(char *filename); +extern int32 RTS_NumSounds(void ); +extern int32 RTS_SoundLength(int32 lump); +extern char *RTS_GetSoundName(int32 i); +extern void RTS_ReadLump(int32 lump,void *dest); +extern void *RTS_GetSound(int32 lump); +extern void docacheit(void); +extern void xyzmirror(short i,short wn); +extern void vscrn(void ); +extern void pickrandomspot(short snum); +extern void resetplayerstats(short snum); +extern void resetweapons(short snum); +extern void resetinventory(short snum); +extern void resetprestat(short snum,char g); +extern void setupbackdrop(short backpicnum); +extern void cachespritenum(short i); +extern void cachegoodsprites(void ); +extern void prelevel(char g); +extern void newgame(char vn,char ln,char sk); +extern void resetpspritevars(char g); +extern void resettimevars(void ); +extern void genspriteremaps(void ); +extern void waitforeverybody(void); +extern char checksum(long sum); +extern char getsound(unsigned short num); +extern void precachenecessarysounds(void ); +extern void cacheit(void ); +extern void dofrontscreens(char *); +extern void clearfifo(void); +extern void resetmys(void); +extern int enterlevel(char g); +extern void backtomenu(void); +extern void setpal(struct player_struct *p); +extern void incur_damage(short snum); +extern void quickkill(struct player_struct *p); +extern void forceplayerangle(struct player_struct *p); +extern void tracers(long x1,long y1,long z1,long x2,long y2,long z2,long n); +extern long hits(short i); +extern long hitasprite(short i,short *hitsp); +extern long hitawall(struct player_struct *p,short *hitw); +extern short aim(spritetype *s,short aang); +extern short shoot(short i,short atwith); +extern void displayloogie(short snum); +extern char animatefist(short gs,short snum); +extern char animateknee(short gs,short snum); +extern char animateknuckles(short gs,short snum); +extern void displaymasks(short snum); +extern char animatetip(short gs,short snum); +extern char animateaccess(short gs,short snum); +extern void displayweapon(short snum); +extern void getinput(short snum); +extern char doincrements(struct player_struct *p); +extern void checkweapons(struct player_struct *p); +extern void processinput(short snum); +extern void cmenu(short cm); +extern void savetemp(char *fn,long daptr,long dasiz); +extern void getangplayers(short snum); +// extern int loadpheader(char spot,int32 *vn,int32 *ln,int32 *psk,int32 *numplr); +extern int loadplayer(signed char spot); +extern int saveplayer(signed char spot); +extern void sendgameinfo(void ); +extern int probe(int x,int y,int i,int n); +extern int menutext(int x,int y,short s,short p,char *t); +extern void bar(int x,int y,short *p,short dainc,char damodify,short s,short pa); +extern void barsm(int x,int y,short *p,short dainc,char damodify,short s,short pa); +extern void dispnames(void ); +extern int getfilenames(char *path, char kind[]); +extern void sortfilenames(void); +extern void menus(void ); +extern void palto(char r,char g,char b,long e); +extern void drawoverheadmap(long cposx,long cposy,long czoom,short cang); +extern void playanm(char *fn,char); +extern short getincangle(short a,short na); +extern char ispecial(char c); +extern char isaltok(char c); +extern void getglobalz(short sActor); +extern void makeitfall(short sActor); +extern void getlabel(void ); +extern long keyword(void ); +extern long transword(void ); +extern long transnum(long type); +extern char parsecommand(void ); +extern void passone(void ); +extern void loadefs(char *fn); +extern char dodge(spritetype *s); +extern short furthestangle(short sActor,short angs); +extern short furthestcanseepoint(short sActor,spritetype *ts,long *dax,long *day); +extern void alterang(short a); +extern void move(void); +extern void parseifelse(long condition); +extern char parse(void ); +extern void execute(short sActor,short sPlayer,long lDist); +extern void overwritesprite(long thex,long they,short tilenum,signed char shade,char stat,char dapalnum); +extern void timerhandler(void); +extern int gametext(int x,int y,char *t,char s,short dabits); +extern int gametextpal(int x,int y,char *t,char s,char p); +extern int minitext(int x,int y,char *t,char p,short sb); +extern void gamenumber(long x,long y,long n,char s); +extern void Shutdown(void ); +extern void allowtimetocorrecterrorswhenquitting(void ); +extern void getpackets(void ); +extern void faketimerhandler(void); +extern void checksync(void ); +extern void check_fta_sounds(short i); +extern inline short inventory(spritetype *s); +extern short badguy(spritetype *s); +extern short badguypic(short pn); +extern void myos(long x,long y,short tilenum,signed char shade,char orientation); +extern void myospal(long x,long y,short tilenum,signed char shade,char orientation,char p); +extern void invennum(long x,long y,char num1,char ha,char sbits); +extern void weaponnum(short ind,long x,long y,long num1,long num2,char ha); +extern void weaponnum999(char ind,long x,long y,long num1,long num2,char ha); +extern void weapon_amounts(struct player_struct *p,long x,long y,long u); +extern void digitalnumber(long x,long y,long n,char s,char cs); +extern void scratchmarks(long x,long y,long n,char s,char p); +extern void displayinventory(struct player_struct *p); +extern void displayfragbar(void ); +extern void coolgaugetext(short snum); +extern void tics(void ); +extern void clocks(void ); +extern void coords(short snum); +extern void operatefta(void); +extern void FTA(short q,struct player_struct *p); +extern void showtwoscreens(void ); +extern void binscreen(void ); +extern void gameexit(char *t); +extern short strget(short x,short y,char *t,short dalen,short c); +extern void displayrest(long smoothratio); +extern void updatesectorz(long x,long y,long z,short *sectnum); +extern void view(struct player_struct *pp,long *vx,long *vy,long *vz,short *vsectnum,short ang,short horiz); +extern void drawbackground(void ); +extern void displayrooms(short snum,long smoothratio); +extern short LocateTheLocator(short n,short sn); +extern short EGS(short whatsect,long s_x,long s_y,long s_z,short s_pn,signed char s_s,signed char s_xr,signed char s_yr,short s_a,short s_ve,long s_zv,short s_ow,signed char s_ss); +extern char wallswitchcheck(short i); +extern short spawn(short j,short pn); +extern void animatesprites(long x,long y,short a,long smoothratio); +extern void cheats(void ); +extern void nonsharedkeys(void ); +extern void comlinehelp(char **argv); +extern void checkcommandline(int argc,char **argv); +extern void printstr(short x,short y,char string[],char attribute); +extern void Logo(void ); +extern void loadtmb(void ); +extern void compilecons(void ); +extern void Startup(void ); +extern void getnames(void ); +extern int main(int argc,char **argv); +extern char opendemoread(char which_demo); +extern void opendemowrite(void ); +extern void record(void ); +extern void closedemowrite(void ); +extern long playback(void ); +extern char moveloop(void); +extern void fakedomovethingscorrect(void); +extern void fakedomovethings(void ); +extern char domovethings(void ); +extern void displaybonuspics(short x,short y,short p); +extern void doorders(void ); +extern void dobonus(char bonusonly); +extern void cameratext(short i); +extern void vglass(long x,long y,short a,short wn,short n); +extern void lotsofglass(short i,short wallnum,short n); +extern void spriteglass(short i,short n); +extern void ceilingglass(short i,short sectnum,short n); +extern void lotsofcolourglass(short i,short wallnum,short n); +extern void SetupGameButtons(void ); +extern long GetTime(void ); +extern void CenterCenter(void ); +extern void UpperLeft(void ); +extern void LowerRight(void ); +extern void CenterThrottle(void ); +extern void CenterRudder(void ); +extern void CONFIG_GetSetupFilename(void ); +extern int32 CONFIG_FunctionNameToNum(char *func); +extern char *CONFIG_FunctionNumToName(int32 func); +extern int32 CONFIG_AnalogNameToNum(char *func); +extern char *CONFIG_AnalogNumToName(int32 func); +extern void CONFIG_SetDefaults(void ); +extern void CONFIG_ReadKeys(void ); +extern void readsavenames(void ); +extern void CONFIG_ReadSetup(void ); +extern void CONFIG_WriteSetup(void ); +extern void CheckAnimStarted(char *funcname); +extern uint16 findpage(uint16 framenumber); +extern void loadpage(uint16 pagenumber,uint16 *pagepointer); +extern void CPlayRunSkipDump(char *srcP,char *dstP); +extern void renderframe(uint16 framenumber,uint16 *pagepointer); +extern void drawframe(uint16 framenumber); +extern void updateinterpolations(void); +extern void setinterpolation(long *posptr); +extern void stopinterpolation(long *posptr); +extern void dointerpolations(long smoothratio); +extern void restoreinterpolations(void); +extern long ceilingspace(short sectnum); +extern long floorspace(short sectnum); +extern void addammo(short weapon,struct player_struct *p,short amount); +extern void addweaponnoswitch(struct player_struct *p,short weapon); +extern void addweapon(struct player_struct *p,short weapon); +extern void checkavailinven(struct player_struct *p); +extern void checkavailweapon(struct player_struct *p); +extern long ifsquished(short i,short p); +extern void hitradius(short i,long r,long hp1,long hp2,long hp3,long hp4); +extern int movesprite(short spritenum,long xchange,long ychange,long zchange,unsigned long cliptype); +extern short ssp(short i,unsigned long cliptype); +extern void insertspriteq(short i); +extern void lotsofmoney(spritetype *s,short n); +extern void lotsofmail(spritetype *s, short n); +extern void lotsofpaper(spritetype *s, short n); +extern void guts(spritetype *s,short gtype,short n,short p); +extern void setsectinterpolate(short i); +extern void clearsectinterpolate(short i); +extern void ms(short i); +extern void movefta(void ); +extern short ifhitsectors(short sectnum); +extern short ifhitbyweapon(short sn); +extern void movecyclers(void ); +extern void movedummyplayers(void ); +extern void moveplayers(void ); +extern void movefx(void ); +extern void movefallers(void ); +extern void movestandables(void ); +extern void bounce(short i); +extern void moveweapons(void ); +extern void movetransports(void ); +extern void moveeffectors(void ); +extern void moveactors(void ); +extern void moveexplosions(void ); + +// game.c +extern void setstatusbarscale(long sc); + +extern void setgamepalette(struct player_struct *player, char *pal, int set); +extern void fadepal(int r, int g, int b, int start, int end, int step); + +extern int minitextshade(int x,int y,char *t,char s,char p,short sb); +extern int txgametext(int starttile, int x,int y,char *t,char s,char p,short orientation,long x1, long y1, long x2, long y2); +extern void txdigitalnumber(short starttile, long x,long y,long n,char s,char pal,char cs,long x1, long y1, long x2, long y2); +extern long txdist(spritetype *s1,spritetype *s2); +extern void myosx(long x,long y,short tilenum,signed char shade,char orientation); +extern void myospalx(long x,long y,short tilenum,signed char shade,char orientation,char p); +extern void ResetGameVars(void); +extern void ResetActorGameVars(short sActor); + +extern void sanitizegametype(); +// extern void readnames(); +extern void setupdynamictostatic(); +extern void processnames(char *szLabel, long lValue); + +extern void LoadActor(short sActor, short sPlayer, long lDist); + +extern long GetGameVar(char *szGameLabel, long lDefault, short sActor, short sPlayer); +extern void DumpGameVars(FILE *fp); +extern void AddLog(char *psz); + +extern void ResetSystemDefaults(void); +extern void InitGameVarPointers(void); +extern void InitGameVars(void); +extern void SaveGameVars(FILE *fil); +extern void ReadGameVars(long fil); + +extern int GetGameID(char *szGameLabel); +extern long GetGameVarID(int id, short sActor, short sPlayer); +extern void SetGameVarID(int id, long lValue, short sActor, short sPlayer); + +extern void onvideomodechange(int newmode); + +extern void OnEvent(int iEventID, short sActor,short sPlayer,long lDist); + +extern int isspritemakingsound(short i, int num); +extern int issoundplaying(int num); +extern void stopspritesound(short num, short i); + +#endif // __funct_h__ diff --git a/polymer/eduke32/source/function.h b/polymer/eduke32/source/function.h new file mode 100644 index 000000000..4eef07153 --- /dev/null +++ b/polymer/eduke32/source/function.h @@ -0,0 +1,105 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +// function.h + +// file created by makehead.exe +// these headers contain default key assignments, as well as +// default button assignments and game function names +// axis defaults are also included + + +#ifndef _function_public_ +#define _function_public_ +#ifdef __cplusplus +extern "C" { +#endif + +#define NUMGAMEFUNCTIONS 53 + +extern char * gamefunctions[]; + +enum + { + gamefunc_Move_Forward, + gamefunc_Move_Backward, + gamefunc_Turn_Left, + gamefunc_Turn_Right, + gamefunc_Strafe, + gamefunc_Fire, + gamefunc_Open, + gamefunc_Run, + gamefunc_AutoRun, + gamefunc_Jump, + gamefunc_Crouch, + gamefunc_Look_Up, + gamefunc_Look_Down, + gamefunc_Look_Left, + gamefunc_Look_Right, + gamefunc_Strafe_Left, + gamefunc_Strafe_Right, + gamefunc_Aim_Up, + gamefunc_Aim_Down, + gamefunc_Weapon_1, + gamefunc_Weapon_2, + gamefunc_Weapon_3, + gamefunc_Weapon_4, + gamefunc_Weapon_5, + gamefunc_Weapon_6, + gamefunc_Weapon_7, + gamefunc_Weapon_8, + gamefunc_Weapon_9, + gamefunc_Weapon_10, + gamefunc_Inventory, + gamefunc_Inventory_Left, + gamefunc_Inventory_Right, + gamefunc_Holo_Duke, + gamefunc_Jetpack, + gamefunc_NightVision, + gamefunc_MedKit, + gamefunc_TurnAround, + gamefunc_SendMessage, + gamefunc_Map, + gamefunc_Shrink_Screen, + gamefunc_Enlarge_Screen, + gamefunc_Center_View, + gamefunc_Holster_Weapon, + gamefunc_Show_Opponents_Weapon, + gamefunc_Map_Follow_Mode, + gamefunc_See_Coop_View, + gamefunc_Mouse_Aiming, + gamefunc_Toggle_Crosshair, + gamefunc_Steroids, + gamefunc_Quick_Kick, + gamefunc_Next_Weapon, + gamefunc_Previous_Weapon, + gamefunc_Show_Console + }; +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c new file mode 100644 index 000000000..f9ac23dd8 --- /dev/null +++ b/polymer/eduke32/source/game.c @@ -0,0 +1,10479 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "types.h" +#include "develop.h" +#include "scriplib.h" +#include "file_lib.h" +#include "mathutil.h" +#include "gamedefs.h" +#include "keyboard.h" +#include "mouse.h" // JBF 20030809 +#include "function.h" +#include "control.h" +#include "fx_man.h" +#include "sounds.h" +#include "config.h" + +#include "osd.h" +#include "osdfuncs.h" +#include "osdcmds.h" + +//#include "crc32.h" + +#include "duke3d.h" + +#include "util_lib.h" + +#define VERSION " 1.3.1-2" + +#define HEAD "EDuke32"VERSION" (shareware mode)" +#define HEAD2 "EDuke32"VERSION + +#define IDFSIZE 479985668 +#define IDFILENAME "DUKE3D.IDF" + +#define TIMERUPDATESIZ 32 + +long cameradist = 0, cameraclock = 0; +char playerswhenstarted; +char qe,cp; + +static int32 CommandSoundToggleOff = 0; +static int32 CommandMusicToggleOff = 0; +static char *CommandMap = NULL; +static char *CommandName = NULL; + +char confilename[BMAX_PATH] = {"EDUKE.CON"}, boardfilename[BMAX_PATH] = {0}; +char waterpal[768], slimepal[768], titlepal[768], drealms[768], endingpal[768]; +char firstdemofile[80] = { '\0' }; +int display_bonus_screen = 1, userconfiles = 0; + +static int netparamcount = 0; +static char **netparam = NULL; + +void setstatusbarscale(long sc) +{ + ud.statusbarscale = min(100,max(10,sc)); + vscrn(); +} + +static inline long sbarx(long x) +{ + if (ud.screen_size == 4) return scale(x<<16,ud.statusbarscale,100); + return (((320l<<16) - scale(320l<<16,ud.statusbarscale,100)) >> 1) + scale(x<<16,ud.statusbarscale,100); +} + +static inline long sbary(long y) +{ + return ((200l<<16) - scale(200l<<16,ud.statusbarscale,100) + scale(y<<16,ud.statusbarscale,100)); +} + +static inline long sbarsc(long sc) +{ + return scale(sc,ud.statusbarscale,100); +} + +void patchstatusbar(long x1, long y1, long x2, long y2) +{ + long scl, tx, ty; + long clx1,cly1,clx2,cly2,clofx,clofy; + + scl = sbarsc(65536); + tx = sbarx(0); ty = sbary(200-tilesizy[BOTTOMSTATUSBAR]); + + clx1 = scale(scale(x1,xdim,320),ud.statusbarscale,100); + cly1 = scale(scale(y1,ydim,200),ud.statusbarscale,100); + clx2 = scale(scale(x2,xdim,320),ud.statusbarscale,100); + cly2 = scale(scale(y2,ydim,200),ud.statusbarscale,100); + clofx = (xdim - scale(xdim,ud.statusbarscale,100)) >> 1; + clofy = (ydim - scale(ydim,ud.statusbarscale,100)); + + rotatesprite(tx,ty,scl,0,BOTTOMSTATUSBAR,4,0,10+16+64,clx1+clofx,cly1+clofy,clx2+clofx-1,cly2+clofy-1); +} + +int recfilep,totalreccnt; +char debug_on = 0,actor_tog = 0,*rtsptr,memorycheckoveride=0; + +extern char syncstate; +extern int32 numlumps; + +FILE *frecfilep = (FILE *)NULL; +void pitch_test( void ); + +char restorepalette,screencapt,nomorelogohack; +int sendmessagecommand = -1; + +static char *duke3dgrp = "duke3d.grp"; // JBF 20030925 +static char *duke3ddef = "duke3d.def"; + +extern long lastvisinc; + +// JBF 20031221: These ought to disappear when things mature +extern int showmultidiags; +extern int netmode, nethostplayers; +extern char netjoinhost[64]; +int startupnetworkgame(void); +int processnetworkrequests(void); + +void setgamepalette(struct player_struct *player, char *pal, int set) +{ + if (player != &ps[screenpeek]) { + // another head + player->palette = pal; + return; + } + + if (getrendermode() < 3) { + // 8-bit mode + player->palette = pal; + setbrightness(ud.brightness>>2, pal, set); + //pub = pus = NUMPAGES; + return; + } + + if (pal == palette || pal == waterpal || pal == slimepal) { + if (player->palette != palette && player->palette != waterpal && player->palette != slimepal) + setbrightness(ud.brightness>>2, palette, set); + else setpalettefade(0,0,0,0); + } else { + setbrightness(ud.brightness>>2, pal, set); + } + player->palette = pal; +} + +int txgametext(int starttile, int x,int y,char *t,char s,char p,short orientation,long x1, long y1, long x2, long y2) +{ + short ac,newx; + char centre, *oldt; + + centre = ( x == (320>>1) ); + newx = 0; + oldt = t; + + if(centre) + { + while(*t) + { + if(*t == 32) {newx+=5;t++;continue;} + else ac = *t - '!' + starttile; + + if( ac < starttile || ac > (starttile + 93) ) break; + + if(*t >= '0' && *t <= '9') + newx += 8; + else newx += tilesizx[ac]; + t++; + } + + t = oldt; + x = (320>>1)-(newx>>1); + } + + while(*t) + { + if(*t == 32) {x+=5;t++;continue;} + else ac = *t - '!' + starttile; + + if( ac < starttile || ac > (starttile + 93) ) + break; + + rotatesprite(x<<16,y<<16,65536L,0,ac,s,p,2|orientation,x1,y1,x2,y2); + if(*t >= '0' && *t <= '9') + x += 8; + else x += tilesizx[ac]; + + t++; + } + + return (x); +} + +inline int gametext(int x,int y,char *t,char s,short dabits) +{ + return(txgametext(STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1)); +} + +inline int gametextpal(int x,int y,char *t,char s,char p) +{ + return(txgametext(STARTALPHANUM, x,y,t,s,p,26,0, 0, xdim-1, ydim-1)); +} + +int minitextshade(int x,int y,char *t,char s,char p,short sb) +{ + short ac; + char ch,cmode; + + cmode = (sb&256)!=0; + sb &= 255; + + while(*t) + { + ch = Btoupper(*t); + if(ch == 32) {x+=5;t++;continue;} + else ac = ch - '!' + MINIFONT; + + if (cmode) rotatesprite(sbarx(x),sbary(y),sbarsc(65536L),0,ac,s,p,sb,0,0,xdim-1,ydim-1); + else rotatesprite(x<<16,y<<16,65536L,0,ac,s,p,sb,0,0,xdim-1,ydim-1); + x += 4; // tilesizx[ac]+1; + + t++; + } + return (x); +} + +inline int minitext(int x,int y,char *t,char p,short sb) +{ + return (minitextshade(x,y,t,0,p,sb)); +} + +void gamenumber(long x,long y,long n,char s) +{ + char b[10]; + //ltoa(n,b,10); + Bsnprintf(b,10,"%ld",n); + gametext(x,y,b,s,2+8+16); +} + +char recbuf[80]; +void allowtimetocorrecterrorswhenquitting(void) +{ + long i, j, oldtotalclock; + + ready2send = 0; + + for(j=0;j<8;j++) + { + oldtotalclock = totalclock; + + while (totalclock < oldtotalclock+TICSPERFRAME) { + handleevents(); + getpackets(); + } + if(KB_KeyPressed(sc_Escape)) return; + + packbuf[0] = 127; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (i != myconnectindex) sendpacket(i,packbuf,1); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + } +} + +#define MAXUSERQUOTES 4 +long quotebot, quotebotgoal; +short user_quote_time[MAXUSERQUOTES]; +char user_quote[MAXUSERQUOTES][128]; +// char typebuflen,typebuf[41]; + +void adduserquote(char *daquote) +{ + long i; + + for(i=MAXUSERQUOTES-1;i>0;i--) + { + strcpy(user_quote[i],user_quote[i-1]); + user_quote_time[i] = user_quote_time[i-1]; + } + strcpy(user_quote[0],daquote); + OSD_Printf("%s\n", daquote); + user_quote_time[0] = 180; + pub = NUMPAGES; +} + +void getpackets(void) +{ + long i, j, k, l; + FILE *fp; + long other, packbufleng; + input *osyn, *nsyn; + + sampletimer(); + AudioUpdate(); + + // only dispatch commands here when not in a game + if( !(ps[myconnectindex].gm&MODE_GAME) ) { OSD_DispatchQueued(); } + + if(qe == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && KB_KeyPressed(sc_Delete)) + { + qe = 1; + gameexit("Quick Exit."); + } + + if (numplayers < 2) return; + while ((packbufleng = getpacket(&other,packbuf)) > 0) + { + switch(packbuf[0]) + { + case 126: + //Slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!networkmode) && (myconnectindex == connecthead)) + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + multiflag = 2; + multiwhat = 0; + multiwho = packbuf[2]; //other: need to send in m/s mode because of possible re-transmit + multipos = packbuf[1]; + loadplayer( multipos ); + multiflag = 0; + break; + case 0: //[0] (receive master sync buffer) + j = 1; + + if ((movefifoend[other]&(TIMERUPDATESIZ-1)) == 0) + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + { + if (playerquitflag[i] == 0) continue; + if (i == myconnectindex) + otherminlag = (long)((signed char)packbuf[j]); + j++; + } + + osyn = (input *)&inputfifo[(movefifoend[connecthead]-1)&(MOVEFIFOSIZ-1)][0]; + nsyn = (input *)&inputfifo[(movefifoend[connecthead])&(MOVEFIFOSIZ-1)][0]; + + k = j; + for(i=connecthead;i>=0;i=connectpoint2[i]) + j += playerquitflag[i] + playerquitflag[i]; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (playerquitflag[i] == 0) continue; + + l = packbuf[k++]; + l |= (long)packbuf[k++] << 8; + + if (i == myconnectindex) + { j += ((l&1)<<1)+(l&2)+((l&4)>>2)+((l&8)>>3)+((l&16)>>4)+((l&32)>>5)+((l&64)>>6)+((l&128)>>7)+((l&256)>>8)+((l&512)>>9)+((l&1024)>>10)+((l&2048)>>11); continue; } + + copybufbyte(&osyn[i],&nsyn[i],sizeof(input)); + if (l&1) nsyn[i].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; + if (l&2) nsyn[i].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; + if (l&4) nsyn[i].avel = (signed char)packbuf[j++]; + if (l&8) nsyn[i].bits = ((nsyn[i].bits&0xffffff00)|((long)packbuf[j++])); + if (l&16) nsyn[i].bits = ((nsyn[i].bits&0xffff00ff)|((long)packbuf[j++])<<8); + if (l&32) nsyn[i].bits = ((nsyn[i].bits&0xff00ffff)|((long)packbuf[j++])<<16); + if (l&64) nsyn[i].bits = ((nsyn[i].bits&0x00ffffff)|((long)packbuf[j++])<<24); + if (l&128) nsyn[i].horz = (signed char)packbuf[j++]; + if (l&256) nsyn[i].bits2 = ((nsyn[i].bits2&0xffffff00)|((long)packbuf[j++])); + if (l&512) nsyn[i].bits2 = ((nsyn[i].bits2&0xffff00ff)|((long)packbuf[j++])<<8); + if (l&1024) nsyn[i].bits2 = ((nsyn[i].bits2&0xff00ffff)|((long)packbuf[j++])<<16); + if (l&2048) nsyn[i].bits2 = ((nsyn[i].bits2&0x00ffffff)|((long)packbuf[j++])<<24); + + if (nsyn[i].bits&(1<<26)) playerquitflag[i] = 0; + movefifoend[i]++; + } + + while (j != packbufleng) + { + for(i=connecthead;i>=0;i=connectpoint2[i]) + if(i != myconnectindex) + { + syncval[i][syncvalhead[i]&(MOVEFIFOSIZ-1)] = packbuf[j]; + syncvalhead[i]++; + } + j++; + } + + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + for(j=1;j=0;i=connectpoint2[i]) + if (i != other) + sendpacket(i,packbuf,packbufleng); + } + else if (((long)packbuf[1]) != myconnectindex) + { + //Master re-transmits message not intended for master + sendpacket((long)packbuf[1],packbuf,packbufleng); + break; + } + } + + strcpy(recbuf,packbuf+2); + recbuf[packbufleng-2] = 0; + + adduserquote(recbuf); + sound(EXITMENUSOUND); + + pus = NUMPAGES; + pub = NUMPAGES; + + break; + + case 5: + //Slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!networkmode) && (myconnectindex == connecthead)) + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + ud.m_level_number = ud.level_number = packbuf[1]; + ud.m_volume_number = ud.volume_number = packbuf[2]; + ud.m_player_skill = ud.player_skill = packbuf[3]; + ud.m_monsters_off = ud.monsters_off = packbuf[4]; + ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5]; + ud.m_respawn_items = ud.respawn_items = packbuf[6]; + ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7]; + ud.m_coop = packbuf[8]; + ud.m_marker = ud.marker = packbuf[9]; + ud.m_ffire = ud.ffire = packbuf[10]; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + resetweapons(i); + resetinventory(i); + } + + newgame(ud.volume_number,ud.level_number,ud.player_skill); + ud.coop = ud.m_coop; + + if (enterlevel(MODE_GAME)) backtomenu(); + + break; + case 6: + //slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!networkmode) && (myconnectindex == connecthead)) + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + if (packbuf[2] != BYTEVERSION) + gameexit("\nYou cannot play Duke with different versions."); + + other = packbuf[1]; + + for (i=3;packbuf[i];i++) + ud.user_name[other][i-3] = packbuf[i]; + ud.user_name[other][i-3] = 0; + i++; + + j = i; //This used to be Duke packet #9... now concatenated with Duke packet #6 + for (;i-j<10;i++) ud.wchoice[other][i-j] = packbuf[i]; + + ps[other].aim_mode = packbuf[i++]; + ps[other].auto_aim = packbuf[i++]; + ps[other].weaponswitch = packbuf[i++]; + + break; + case 7: + //slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!networkmode) && (myconnectindex == connecthead)) + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + if(numlumps == 0) break; + + if (SoundToggle == 0 || ud.lockout == 1 || FXDevice < 0 ) + break; + rtsptr = (char *)RTS_GetSound(packbuf[1]-1); + if (*rtsptr == 'C') + FX_PlayVOC3D(rtsptr,0,0,0,255,-packbuf[1]); + else + FX_PlayWAV3D(rtsptr,0,0,0,255,-packbuf[1]); + rtsplaying = 7; + break; + case 8: + //Slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!networkmode) && (myconnectindex == connecthead)) + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + ud.m_level_number = ud.level_number = packbuf[1]; + ud.m_volume_number = ud.volume_number = packbuf[2]; + ud.m_player_skill = ud.player_skill = packbuf[3]; + ud.m_monsters_off = ud.monsters_off = packbuf[4]; + ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5]; + ud.m_respawn_items = ud.respawn_items = packbuf[6]; + ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7]; + ud.m_coop = ud.coop = packbuf[8]; + ud.m_marker = ud.marker = packbuf[9]; + ud.m_ffire = ud.ffire = packbuf[10]; + + copybufbyte(packbuf+10,boardfilename,packbufleng-11); + boardfilename[packbufleng-11] = 0; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + resetweapons(i); + resetinventory(i); + } + + newgame(ud.volume_number,ud.level_number,ud.player_skill); + if (enterlevel(MODE_GAME)) backtomenu(); + break; + + case 16: + movefifoend[other] = movefifoplc = movefifosendplc = fakemovefifoplc = 0; + syncvalhead[other] = syncvaltottail = 0L; + case 17: + j = 1; + + if ((movefifoend[other]&(TIMERUPDATESIZ-1)) == 0) + if (other == connecthead) + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + { + if (i == myconnectindex) + otherminlag = (long)((signed char)packbuf[j]); + j++; + } + + osyn = (input *)&inputfifo[(movefifoend[other]-1)&(MOVEFIFOSIZ-1)][0]; + nsyn = (input *)&inputfifo[(movefifoend[other])&(MOVEFIFOSIZ-1)][0]; + + copybufbyte(&osyn[other],&nsyn[other],sizeof(input)); + k = packbuf[j++]; + k |= (long)packbuf[j++] << 8; + if (k&1) nsyn[other].fvel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; + if (k&2) nsyn[other].svel = packbuf[j]+((short)packbuf[j+1]<<8), j += 2; + if (k&4) nsyn[other].avel = (signed char)packbuf[j++]; + if (k&8) nsyn[other].bits = ((nsyn[other].bits&0xffffff00)|((long)packbuf[j++])); + if (k&16) nsyn[other].bits = ((nsyn[other].bits&0xffff00ff)|((long)packbuf[j++])<<8); + if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((long)packbuf[j++])<<16); + if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((long)packbuf[j++])<<24); + if (k&128) nsyn[other].horz = (signed char)packbuf[j++]; + if (k&256) nsyn[other].bits2 = ((nsyn[other].bits2&0xffffff00)|((long)packbuf[j++])); + if (k&512) nsyn[other].bits2 = ((nsyn[other].bits2&0xffff00ff)|((long)packbuf[j++])<<8); + if (k&1024) nsyn[other].bits2 = ((nsyn[other].bits2&0xff00ffff)|((long)packbuf[j++])<<16); + if (k&2048) nsyn[other].bits2 = ((nsyn[other].bits2&0x00ffffff)|((long)packbuf[j++])<<24); + movefifoend[other]++; + + for(i=1;i packbufleng) + initprintf("INVALID GAME PACKET!!! (%ld too many bytes)\n",j-packbufleng); + + while (j != packbufleng) + { + syncval[other][syncvalhead[other]&(MOVEFIFOSIZ-1)] = packbuf[j++]; + syncvalhead[other]++; + } + + break; + case 127: + break; + + case 250: + playerreadyflag[other]++; + break; + case 255: + gameexit(" "); + break; + } + } +} + +extern void computergetinput(long snum, input *syn); + +void faketimerhandler() +{ + long i, j, k, l; + long momx, momy; + // short who; + input *osyn, *nsyn; + + if(qe == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && KB_KeyPressed(sc_Delete)) + { + qe = 1; + gameexit("Quick Exit."); + } + + sampletimer(); + AudioUpdate(); + if ((totalclock < ototalclock+TICSPERFRAME) || (ready2send == 0)) return; + ototalclock += TICSPERFRAME; + + getpackets(); if (getoutputcirclesize() >= 16) return; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + if (movefifoend[i] < movefifoend[myconnectindex]-200) return; + + getinput(myconnectindex); + + avgfvel += loc.fvel; + avgsvel += loc.svel; + avgavel += loc.avel; + avghorz += loc.horz; + avgbits |= loc.bits; + avgbits2 |= loc.bits2; + if (movefifoend[myconnectindex]&(movesperpacket-1)) + { + copybufbyte(&inputfifo[(movefifoend[myconnectindex]-1)&(MOVEFIFOSIZ-1)][myconnectindex], + &inputfifo[movefifoend[myconnectindex]&(MOVEFIFOSIZ-1)][myconnectindex],sizeof(input)); + movefifoend[myconnectindex]++; + return; + } + nsyn = &inputfifo[movefifoend[myconnectindex]&(MOVEFIFOSIZ-1)][myconnectindex]; + nsyn[0].fvel = avgfvel/movesperpacket; + nsyn[0].svel = avgsvel/movesperpacket; + nsyn[0].avel = avgavel/movesperpacket; + nsyn[0].horz = avghorz/movesperpacket; + nsyn[0].bits = avgbits; + nsyn[0].bits2 = avgbits2; + avgfvel = avgsvel = avgavel = avghorz = avgbits = avgbits2 = 0; + movefifoend[myconnectindex]++; + + if (numplayers < 2) + { + if (ud.multimode > 1) for(i=connecthead;i>=0;i=connectpoint2[i]) + if(i != myconnectindex) + { + //clearbufbyte(&inputfifo[movefifoend[i]&(MOVEFIFOSIZ-1)][i],sizeof(input),0L); + if(ud.playerai) + computergetinput(i,&inputfifo[movefifoend[i]&(MOVEFIFOSIZ-1)][i]); + movefifoend[i]++; + } + return; + } + + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + { + k = (movefifoend[myconnectindex]-1)-movefifoend[i]; + myminlag[i] = min(myminlag[i],k); + mymaxlag = max(mymaxlag,k); + } + + if (((movefifoend[myconnectindex]-1)&(TIMERUPDATESIZ-1)) == 0) + { + i = mymaxlag-bufferjitter; mymaxlag = 0; + if (i > 0) bufferjitter += ((3+i)>>2); + else if (i < 0) bufferjitter -= ((1-i)>>2); + } + + if (networkmode == 1) + { + packbuf[0] = 17; + if ((movefifoend[myconnectindex]-1) == 0) packbuf[0] = 16; + j = 1; + + //Fix timers and buffer/jitter value + if (((movefifoend[myconnectindex]-1)&(TIMERUPDATESIZ-1)) == 0) + { + if (myconnectindex != connecthead) + { + i = myminlag[connecthead]-otherminlag; + if (klabs(i) > 8) i >>= 1; + else if (klabs(i) > 2) i = ksgn(i); + else i = 0; + + totalclock -= TICSPERFRAME*i; + myminlag[connecthead] -= i; otherminlag += i; + } + + if (myconnectindex == connecthead) + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + packbuf[j++] = min(max(myminlag[i],-128),127); + + for(i=connecthead;i>=0;i=connectpoint2[i]) + myminlag[i] = 0x7fffffff; + } + + osyn = (input *)&inputfifo[(movefifoend[myconnectindex]-2)&(MOVEFIFOSIZ-1)][myconnectindex]; + nsyn = (input *)&inputfifo[(movefifoend[myconnectindex]-1)&(MOVEFIFOSIZ-1)][myconnectindex]; + + k = j; + packbuf[j++] = 0; + packbuf[j++] = 0; + + if (nsyn[0].fvel != osyn[0].fvel) + { + packbuf[j++] = (char)nsyn[0].fvel; + packbuf[j++] = (char)(nsyn[0].fvel>>8); + packbuf[k] |= 1; + } + if (nsyn[0].svel != osyn[0].svel) + { + packbuf[j++] = (char)nsyn[0].svel; + packbuf[j++] = (char)(nsyn[0].svel>>8); + packbuf[k] |= 2; + } + if (nsyn[0].avel != osyn[0].avel) + { + packbuf[j++] = (signed char)nsyn[0].avel; + packbuf[k] |= 4; + } + if ((nsyn[0].bits^osyn[0].bits)&0x000000ff) packbuf[j++] = (nsyn[0].bits&255), packbuf[k] |= 8; + if ((nsyn[0].bits^osyn[0].bits)&0x0000ff00) packbuf[j++] = ((nsyn[0].bits>>8)&255), packbuf[k] |= 16; + if ((nsyn[0].bits^osyn[0].bits)&0x00ff0000) packbuf[j++] = ((nsyn[0].bits>>16)&255), packbuf[k] |= 32; + if ((nsyn[0].bits^osyn[0].bits)&0xff000000) packbuf[j++] = ((nsyn[0].bits>>24)&255), packbuf[k] |= 64; + if (nsyn[0].horz != osyn[0].horz) + { + packbuf[j++] = (char)nsyn[0].horz; + packbuf[k] |= 128; + } + k++; + packbuf[k] = 0; + if ((nsyn[0].bits2^osyn[0].bits2)&0x000000ff) packbuf[j++] = (nsyn[0].bits2&255), packbuf[k] |= 1; + if ((nsyn[0].bits2^osyn[0].bits2)&0x0000ff00) packbuf[j++] = ((nsyn[0].bits2>>8)&255), packbuf[k] |= 2; + if ((nsyn[0].bits2^osyn[0].bits2)&0x00ff0000) packbuf[j++] = ((nsyn[0].bits2>>16)&255), packbuf[k] |= 4; + if ((nsyn[0].bits2^osyn[0].bits2)&0xff000000) packbuf[j++] = ((nsyn[0].bits2>>24)&255), packbuf[k] |= 8; + + while (syncvalhead[myconnectindex] != syncvaltail) + { + packbuf[j++] = syncval[myconnectindex][syncvaltail&(MOVEFIFOSIZ-1)]; + syncvaltail++; + } + + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + sendpacket(i,packbuf,j); + + return; + } + if (myconnectindex != connecthead) //Slave + { + //Fix timers and buffer/jitter value + if (((movefifoend[myconnectindex]-1)&(TIMERUPDATESIZ-1)) == 0) + { + i = myminlag[connecthead]-otherminlag; + if (klabs(i) > 8) i >>= 1; + else if (klabs(i) > 2) i = ksgn(i); + else i = 0; + + totalclock -= TICSPERFRAME*i; + myminlag[connecthead] -= i; otherminlag += i; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + myminlag[i] = 0x7fffffff; + } + + packbuf[0] = 1; packbuf[1] = 0; packbuf[2] = 0; j = 3; + + osyn = (input *)&inputfifo[(movefifoend[myconnectindex]-2)&(MOVEFIFOSIZ-1)][myconnectindex]; + nsyn = (input *)&inputfifo[(movefifoend[myconnectindex]-1)&(MOVEFIFOSIZ-1)][myconnectindex]; + + if (nsyn[0].fvel != osyn[0].fvel) + { + packbuf[j++] = (char)nsyn[0].fvel; + packbuf[j++] = (char)(nsyn[0].fvel>>8); + packbuf[1] |= 1; + } + if (nsyn[0].svel != osyn[0].svel) + { + packbuf[j++] = (char)nsyn[0].svel; + packbuf[j++] = (char)(nsyn[0].svel>>8); + packbuf[1] |= 2; + } + if (nsyn[0].avel != osyn[0].avel) + { + packbuf[j++] = (signed char)nsyn[0].avel; + packbuf[1] |= 4; + } + if ((nsyn[0].bits^osyn[0].bits)&0x000000ff) packbuf[j++] = (nsyn[0].bits&255), packbuf[1] |= 8; + if ((nsyn[0].bits^osyn[0].bits)&0x0000ff00) packbuf[j++] = ((nsyn[0].bits>>8)&255), packbuf[1] |= 16; + if ((nsyn[0].bits^osyn[0].bits)&0x00ff0000) packbuf[j++] = ((nsyn[0].bits>>16)&255), packbuf[1] |= 32; + if ((nsyn[0].bits^osyn[0].bits)&0xff000000) packbuf[j++] = ((nsyn[0].bits>>24)&255), packbuf[1] |= 64; + if (nsyn[0].horz != osyn[0].horz) + { + packbuf[j++] = (char)nsyn[0].horz; + packbuf[1] |= 128; + } + packbuf[2] = 0; + if ((nsyn[0].bits2^osyn[0].bits2)&0x000000ff) packbuf[j++] = (nsyn[0].bits2&255), packbuf[2] |= 1; + if ((nsyn[0].bits2^osyn[0].bits2)&0x0000ff00) packbuf[j++] = ((nsyn[0].bits2>>8)&255), packbuf[2] |= 2; + if ((nsyn[0].bits2^osyn[0].bits2)&0x00ff0000) packbuf[j++] = ((nsyn[0].bits2>>16)&255), packbuf[2] |= 4; + if ((nsyn[0].bits2^osyn[0].bits2)&0xff000000) packbuf[j++] = ((nsyn[0].bits2>>24)&255), packbuf[2] |= 8; + + while (syncvalhead[myconnectindex] != syncvaltail) + { + packbuf[j++] = syncval[myconnectindex][syncvaltail&(MOVEFIFOSIZ-1)]; + syncvaltail++; + } + + sendpacket(connecthead,packbuf,j); + return; + } + + //This allows allow packet resends + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (movefifoend[i] <= movefifosendplc) + { + packbuf[0] = 127; + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + sendpacket(i,packbuf,1); + return; + } + + while (1) //Master + { + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (playerquitflag[i] && (movefifoend[i] <= movefifosendplc)) return; + + osyn = (input *)&inputfifo[(movefifosendplc-1)&(MOVEFIFOSIZ-1)][0]; + nsyn = (input *)&inputfifo[(movefifosendplc )&(MOVEFIFOSIZ-1)][0]; + + //MASTER -> SLAVE packet + packbuf[0] = 0; j = 1; + + //Fix timers and buffer/jitter value + if ((movefifosendplc&(TIMERUPDATESIZ-1)) == 0) + { + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (playerquitflag[i]) + packbuf[j++] = min(max(myminlag[i],-128),127); + + for(i=connecthead;i>=0;i=connectpoint2[i]) + myminlag[i] = 0x7fffffff; + } + + k = j; + for(i=connecthead;i>=0;i=connectpoint2[i]) + j += playerquitflag[i] + playerquitflag[i]; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (playerquitflag[i] == 0) continue; + + packbuf[k] = 0; + if (nsyn[i].fvel != osyn[i].fvel) + { + packbuf[j++] = (char)nsyn[i].fvel; + packbuf[j++] = (char)(nsyn[i].fvel>>8); + packbuf[k] |= 1; + } + if (nsyn[i].svel != osyn[i].svel) + { + packbuf[j++] = (char)nsyn[i].svel; + packbuf[j++] = (char)(nsyn[i].svel>>8); + packbuf[k] |= 2; + } + if (nsyn[i].avel != osyn[i].avel) + { + packbuf[j++] = (signed char)nsyn[i].avel; + packbuf[k] |= 4; + } + if ((nsyn[i].bits^osyn[i].bits)&0x000000ff) packbuf[j++] = (nsyn[i].bits&255), packbuf[k] |= 8; + if ((nsyn[i].bits^osyn[i].bits)&0x0000ff00) packbuf[j++] = ((nsyn[i].bits>>8)&255), packbuf[k] |= 16; + if ((nsyn[i].bits^osyn[i].bits)&0x00ff0000) packbuf[j++] = ((nsyn[i].bits>>16)&255), packbuf[k] |= 32; + if ((nsyn[i].bits^osyn[i].bits)&0xff000000) packbuf[j++] = ((nsyn[i].bits>>24)&255), packbuf[k] |= 64; + if (nsyn[i].horz != osyn[i].horz) + { + packbuf[j++] = (char)nsyn[i].horz; + packbuf[k] |= 128; + } + k++; + packbuf[k] = 0; + if ((nsyn[i].bits2^osyn[i].bits2)&0x000000ff) packbuf[j++] = (nsyn[i].bits2&255), packbuf[k] |= 1; + if ((nsyn[i].bits2^osyn[i].bits2)&0x0000ff00) packbuf[j++] = ((nsyn[i].bits2>>8)&255), packbuf[k] |= 2; + if ((nsyn[i].bits2^osyn[i].bits2)&0x00ff0000) packbuf[j++] = ((nsyn[i].bits2>>16)&255), packbuf[k] |= 4; + if ((nsyn[i].bits2^osyn[i].bits2)&0xff000000) packbuf[j++] = ((nsyn[i].bits2>>24)&255), packbuf[k] |= 8; + k++; + } + + while (syncvalhead[myconnectindex] != syncvaltail) + { + packbuf[j++] = syncval[myconnectindex][syncvaltail&(MOVEFIFOSIZ-1)]; + syncvaltail++; + } + + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (playerquitflag[i]) + { + sendpacket(i,packbuf,j); + if (nsyn[i].bits&(1<<26)) + playerquitflag[i] = 0; + } + + movefifosendplc += movesperpacket; + } +} + +extern long cacnum; +typedef struct { long *hand, leng; char *lock; } cactype; +extern cactype cac[]; + +void caches(void) +{ + short i,k; + + k = 0; + for(i=0;i= 200) + { + Bsprintf(tempbuf,"Locked- %d: Leng:%ld, Lock:%d",i,cac[i].leng,*cac[i].lock); + printext256(0L,k,31,-1,tempbuf,1); k += 6; + } + + k += 6; + + for(i=1;i<11;i++) + if (lumplockbyte[i] >= 200) + { + Bsprintf(tempbuf,"RTS Locked %d:",i); + printext256(0L,k,31,-1,tempbuf,1); k += 6; + } + + +} + +void checksync(void) +{ + long i, k; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (syncvalhead[i] == syncvaltottail) break; + if (i < 0) + { + syncstat = 0; + do + { + for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (syncval[i][syncvaltottail&(MOVEFIFOSIZ-1)] != + syncval[connecthead][syncvaltottail&(MOVEFIFOSIZ-1)]) + syncstat = 1; + + syncvaltottail++; + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (syncvalhead[i] == syncvaltottail) break; + } while (i < 0); + } + if (connectpoint2[connecthead] < 0) syncstat = 0; + + if (syncstat) + { + printext256(4L,130L,31,0,"Out Of Sync - Please restart game",0); + printext256(4L,138L,31,0,"RUN DN3DHELP.EXE for information.",0); + } + if (syncstate) + { + printext256(4L,160L,31,0,"Missed Network packet!",0); + printext256(4L,138L,31,0,"RUN DN3DHELP.EXE for information.",0); + } +} + +void check_fta_sounds(short i) +{ + if(sprite[i].extra > 0) + switch(dynamictostatic[PN]) + { + case LIZTROOPONTOILET__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOP__STATIC: + spritesound(PRED_RECOG,i); + break; + case LIZMAN__STATIC: + case LIZMANSPITTING__STATIC: + case LIZMANFEEDING__STATIC: + case LIZMANJUMP__STATIC: + spritesound(CAPT_RECOG,i); + break; + case PIGCOP__STATIC: + case PIGCOPDIVE__STATIC: + spritesound(PIG_RECOG,i); + break; + case RECON__STATIC: + spritesound(RECO_RECOG,i); + break; + case DRONE__STATIC: + spritesound(DRON_RECOG,i); + break; + case COMMANDER__STATIC: + case COMMANDERSTAYPUT__STATIC: + spritesound(COMM_RECOG,i); + break; + case ORGANTIC__STATIC: + spritesound(TURR_RECOG,i); + break; + case OCTABRAIN__STATIC: + case OCTABRAINSTAYPUT__STATIC: + spritesound(OCTA_RECOG,i); + break; + case BOSS1__STATIC: + sound(BOS1_RECOG); + break; + case BOSS2__STATIC: + if(sprite[i].pal == 1) + sound(BOS2_RECOG); + else sound(WHIPYOURASS); + break; + case BOSS3__STATIC: + if(sprite[i].pal == 1) + sound(BOS3_RECOG); + else sound(RIPHEADNECK); + break; + case BOSS4__STATIC: + case BOSS4STAYPUT__STATIC: + if(sprite[i].pal == 1) + sound(BOS4_RECOG); + sound(BOSS4_FIRSTSEE); + break; + case GREENSLIME__STATIC: + spritesound(SLIM_RECOG,i); + break; + } +} + +inline short inventory(spritetype *s) +{ + switch(dynamictostatic[s->picnum]) + { + case FIRSTAID__STATIC: + case STEROIDS__STATIC: + case HEATSENSOR__STATIC: + case BOOTS__STATIC: + case JETPACK__STATIC: + case HOLODUKE__STATIC: + case AIRTANK__STATIC: + return 1; + } + return 0; +} + +inline int checkspriteflags(short sActor, int iType) +{ + int i; + + i = spriteflags[sprite[sActor].picnum]; i ^= actorspriteflags[sActor]; + if(i & iType) return 1; + else return 0; +} + +inline int checkspriteflagsp(short sPicnum, int iType) +{ + if(spriteflags[sPicnum] & iType) return 1; + else return 0; +} + +inline short badguypic(short pn) +{ + //this case can't be handled by the dynamictostatic system because it adds + //stuff to the value from names.h so handling separately + if ((pn >= GREENSLIME) && (pn <= GREENSLIME+7)) return 1; + + if(checkspriteflagsp(pn,SPRITE_FLAG_BADGUY)) return 1; + + if( actortype[pn] ) return 1; + + switch(dynamictostatic[pn]) + { + case SHARK__STATIC: + case RECON__STATIC: + case DRONE__STATIC: + case LIZTROOPONTOILET__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOPSTAYPUT__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOP__STATIC: + case OCTABRAIN__STATIC: + case COMMANDER__STATIC: + case COMMANDERSTAYPUT__STATIC: + case PIGCOP__STATIC: + case EGG__STATIC: + case PIGCOPSTAYPUT__STATIC: + case PIGCOPDIVE__STATIC: + case LIZMAN__STATIC: + case LIZMANSPITTING__STATIC: + case LIZMANFEEDING__STATIC: + case LIZMANJUMP__STATIC: + case ORGANTIC__STATIC: + case BOSS1__STATIC: + case BOSS2__STATIC: + case BOSS3__STATIC: + case BOSS4__STATIC: + //case GREENSLIME: + //case GREENSLIME+1: + //case GREENSLIME+2: + //case GREENSLIME+3: + //case GREENSLIME+4: + //case GREENSLIME+5: + //case GREENSLIME+6: + //case GREENSLIME+7: + case RAT__STATIC: + case ROTATEGUN__STATIC: + return 1; + } + return 0; +} + +inline short badguy(spritetype *s) +{ + return(badguypic(s->picnum)); +} + +void myos(long x, long y, short tilenum, signed char shade, char orientation) +{ + char p; + short a; + + if(orientation&4) + a = 1024; + else a = 0; + + p = sector[ps[screenpeek].cursectnum].floorpal; + rotatesprite(x<<16,y<<16,65536L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); +} + +void myospal(long x, long y, short tilenum, signed char shade, char orientation, char p) +{ + short a; + + if(orientation&4) + a = 1024; + else a = 0; + + rotatesprite(x<<16,y<<16,65536L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); +} + +void myosx(long x, long y, short tilenum, signed char shade, char orientation) +{ + char p; + short a; + + if(orientation&4) + a = 1024; + else a = 0; + + p = sector[ps[screenpeek].cursectnum].floorpal; + rotatesprite(x<<16,y<<16,32768L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); +} + +void myospalx(long x, long y, short tilenum, signed char shade, char orientation, char p) +{ + short a; + + if(orientation&4) + a = 1024; + else a = 0; + + rotatesprite(x<<16,y<<16,32768L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); +} + +void invennum(long x,long y,char num1,char ha,char sbits) +{ + char dabuf[80] = {0}; + Bsprintf(dabuf,"%d",num1); + if(num1 > 99) + { + rotatesprite(sbarx(x-4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,sbits,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[1]-'0',ha,0,sbits,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[2]-'0',ha,0,sbits,0,0,xdim-1,ydim-1); + } + else if(num1 > 9) + { + rotatesprite(sbarx(x),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,sbits,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[1]-'0',ha,0,sbits,0,0,xdim-1,ydim-1); + } + else + rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,sbits,0,0,xdim-1,ydim-1); +} + +void orderweaponnum(short ind,long x,long y,long num1, long num2,char ha) +{ + rotatesprite(sbarx(x-7),sbary(y),sbarsc(65536L),0,THREEBYFIVE+ind+1,ha-10,7,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x-3),sbary(y),sbarsc(65536L),0,THREEBYFIVE+10,ha,0,10,0,0,xdim-1,ydim-1); + + minitextshade(x+1,y-4,"ORDER",26,6,2+8+16+128 + 256); +} + +void weaponnum(short ind,long x,long y,long num1, long num2,char ha) +{ + char dabuf[80] = {0}; + + rotatesprite(sbarx(x-7),sbary(y),sbarsc(65536L),0,THREEBYFIVE+ind+1,ha-10,7,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x-3),sbary(y),sbarsc(65536L),0,THREEBYFIVE+10,ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+9),sbary(y),sbarsc(65536L),0,THREEBYFIVE+11,ha,0,10,0,0,xdim-1,ydim-1); + + if(num1 > 99) num1 = 99; + if(num2 > 99) num2 = 99; + + Bsprintf(dabuf,"%ld",num1); + if(num1 > 9) + { + rotatesprite(sbarx(x),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[1]-'0',ha,0,10,0,0,xdim-1,ydim-1); + } + else rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); + + Bsprintf(dabuf,"%ld",num2); + if(num2 > 9) + { + rotatesprite(sbarx(x+13),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+17),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[1]-'0',ha,0,10,0,0,xdim-1,ydim-1); + } + else rotatesprite(sbarx(x+13),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); +} + +void weaponnum999(char ind,long x,long y,long num1, long num2,char ha) +{ + char dabuf[80] = {0}; + + rotatesprite(sbarx(x-7),sbary(y),sbarsc(65536L),0,THREEBYFIVE+ind+1,ha-10,7,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x-4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+10,ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+13),sbary(y),sbarsc(65536L),0,THREEBYFIVE+11,ha,0,10,0,0,xdim-1,ydim-1); + + Bsprintf(dabuf,"%ld",num1); + if(num1 > 99) + { + rotatesprite(sbarx(x),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[1]-'0',ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+8),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[2]-'0',ha,0,10,0,0,xdim-1,ydim-1); + } + else if(num1 > 9) + { + rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+8),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[1]-'0',ha,0,10,0,0,xdim-1,ydim-1); + } + else rotatesprite(sbarx(x+8),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); + + Bsprintf(dabuf,"%ld",num2); + if(num2 > 99) + { + rotatesprite(sbarx(x+17),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+21),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[1]-'0',ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+25),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[2]-'0',ha,0,10,0,0,xdim-1,ydim-1); + } + else if(num2 > 9) + { + rotatesprite(sbarx(x+17),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(x+21),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[1]-'0',ha,0,10,0,0,xdim-1,ydim-1); + } + else rotatesprite(sbarx(x+25),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); +} + +void weapon_amounts(struct player_struct *p,long x,long y,long u) +{ + int cw; + + cw = p->curr_weapon; + + if (u&4) + { + if (u != -1) patchstatusbar(88,178,88+37,178+6); //original code: (96,178,96+12,178+6); + weaponnum999(PISTOL_WEAPON,x,y, + p->ammo_amount[PISTOL_WEAPON],max_ammo_amount[PISTOL_WEAPON], + 12-20*(cw == PISTOL_WEAPON) ); + } + if (u&8) + { + if (u != -1) patchstatusbar(88,184,88+37,184+6); //original code: (96,184,96+12,184+6); + weaponnum999(SHOTGUN_WEAPON,x,y+6, + p->ammo_amount[SHOTGUN_WEAPON],max_ammo_amount[SHOTGUN_WEAPON], + (!p->gotweapon[SHOTGUN_WEAPON]*9)+12-18* + (cw == SHOTGUN_WEAPON) ); + } + if (u&16) + { + if (u != -1) patchstatusbar(88,190,88+37,190+6); //original code: (96,190,96+12,190+6); + weaponnum999(CHAINGUN_WEAPON,x,y+12, + p->ammo_amount[CHAINGUN_WEAPON],max_ammo_amount[CHAINGUN_WEAPON], + (!p->gotweapon[CHAINGUN_WEAPON]*9)+12-18* + (cw == CHAINGUN_WEAPON) ); + } + if (u&32) + { + if (u != -1) patchstatusbar(127,178,127+29,178+6); //original code: (135,178,135+8,178+6); + weaponnum(RPG_WEAPON,x+39,y, + p->ammo_amount[RPG_WEAPON],max_ammo_amount[RPG_WEAPON], + (!p->gotweapon[RPG_WEAPON]*9)+12-19* + (cw == RPG_WEAPON) ); + } + if (u&64) + { + if (u != -1) patchstatusbar(127,184,127+29,184+6); //original code: (135,184,135+8,184+6); + weaponnum(HANDBOMB_WEAPON,x+39,y+6, + p->ammo_amount[HANDBOMB_WEAPON],max_ammo_amount[HANDBOMB_WEAPON], + (((!p->ammo_amount[HANDBOMB_WEAPON])|(!p->gotweapon[HANDBOMB_WEAPON]))*9)+12-19* + ((cw == HANDBOMB_WEAPON) || (cw == HANDREMOTE_WEAPON))); + } + if (u&128) + { + if (u != -1) patchstatusbar(127,190,127+29,190+6); //original code: (135,190,135+8,190+6); + + if (VOLUMEONE) { + orderweaponnum(SHRINKER_WEAPON,x+39,y+12, + p->ammo_amount[SHRINKER_WEAPON],max_ammo_amount[SHRINKER_WEAPON], + (!p->gotweapon[SHRINKER_WEAPON]*9)+12-18* + (cw == SHRINKER_WEAPON) ); + } else { + if(p->subweapon&(1<ammo_amount[GROW_WEAPON],max_ammo_amount[GROW_WEAPON], + (!p->gotweapon[GROW_WEAPON]*9)+12-18* + (cw == GROW_WEAPON) ); + else + weaponnum(SHRINKER_WEAPON,x+39,y+12, + p->ammo_amount[SHRINKER_WEAPON],max_ammo_amount[SHRINKER_WEAPON], + (!p->gotweapon[SHRINKER_WEAPON]*9)+12-18* + (cw == SHRINKER_WEAPON) ); + } + } + if (u&256) + { + if (u != -1) patchstatusbar(158,178,162+29,178+6); //original code: (166,178,166+8,178+6); + + if (VOLUMEONE) { + orderweaponnum(DEVISTATOR_WEAPON,x+70,y, + p->ammo_amount[DEVISTATOR_WEAPON],max_ammo_amount[DEVISTATOR_WEAPON], + (!p->gotweapon[DEVISTATOR_WEAPON]*9)+12-18* + (cw == DEVISTATOR_WEAPON) ); + } else { + weaponnum(DEVISTATOR_WEAPON,x+70,y, + p->ammo_amount[DEVISTATOR_WEAPON],max_ammo_amount[DEVISTATOR_WEAPON], + (!p->gotweapon[DEVISTATOR_WEAPON]*9)+12-18* + (cw == DEVISTATOR_WEAPON) ); + } + } + if (u&512) + { + if (u != -1) patchstatusbar(158,184,162+29,184+6); //original code: (166,184,166+8,184+6); + if (VOLUMEONE) { + orderweaponnum(TRIPBOMB_WEAPON,x+70,y+6, + p->ammo_amount[TRIPBOMB_WEAPON],max_ammo_amount[TRIPBOMB_WEAPON], + (!p->gotweapon[TRIPBOMB_WEAPON]*9)+12-18* + (cw == TRIPBOMB_WEAPON) ); + } else { + weaponnum(TRIPBOMB_WEAPON,x+70,y+6, + p->ammo_amount[TRIPBOMB_WEAPON],max_ammo_amount[TRIPBOMB_WEAPON], + (!p->gotweapon[TRIPBOMB_WEAPON]*9)+12-18* + (cw == TRIPBOMB_WEAPON) ); + } + } + + if (u&65536L) + { + if (u != -1) patchstatusbar(158,190,162+29,190+6); //original code: (166,190,166+8,190+6); + if (VOLUMEONE) { + orderweaponnum(-1,x+70,y+12, + p->ammo_amount[FREEZE_WEAPON],max_ammo_amount[FREEZE_WEAPON], + (!p->gotweapon[FREEZE_WEAPON]*9)+12-18* + (cw == FREEZE_WEAPON) ); + } else { + weaponnum(-1,x+70,y+12, + p->ammo_amount[FREEZE_WEAPON],max_ammo_amount[FREEZE_WEAPON], + (!p->gotweapon[FREEZE_WEAPON]*9)+12-18* + (cw == FREEZE_WEAPON) ); + } + } +} + +void digitalnumber(long x,long y,long n,char s,char cs) +{ + + short i, j, k, p, c; + char b[10]; + + //ltoa(n,b,10); + Bsnprintf(b,10,"%ld",n); + i = strlen(b); + j = 0; + + for(k=0;k>1); + + j = 0; + for(k=0;k>1); + + j = 0; + for(k=0;k= 0;i--) + { + overwritesprite(x-2,y,SCRATCH+4,s,0,0); + x += tilesizx[SCRATCH+4]-1; + } + + ni = n%5; + if(ni) overwritesprite(x,y,SCRATCH+ni-1,s,p,0); +} + */ +void displayinventory(struct player_struct *p) +{ + short n, j, xoff, y; + + j = xoff = 0; + + n = (p->jetpack_amount > 0)<<3; if(n&8) j++; + n |= ( p->scuba_amount > 0 )<<5; if(n&32) j++; + n |= (p->steroids_amount > 0)<<1; if(n&2) j++; + n |= ( p->holoduke_amount > 0)<<2; if(n&4) j++; + n |= (p->firstaid_amount > 0); if(n&1) j++; + n |= (p->heat_amount > 0)<<4; if(n&16) j++; + n |= (p->boot_amount > 0)<<6; if(n&64) j++; + + xoff = 160-(j*11); + + j = 0; + + if(ud.screen_size > 4) + y = 154; + else y = 172; + + if(ud.screen_size == 4) + { + if(ud.multimode > 1) + xoff += 56; + else xoff += 65; + } + + while( j <= 9 ) + { + if( n&(1<inven_icon == j+1) + rotatesprite((xoff-2)<<16,(y+19)<<16,65536L,1024,ARROW,-32,0,2+16,windowx1,windowy1,windowx2,windowy2); + } + + j++; + } +} + +void displayfragbar(void) +{ + short i, j; + + j = 0; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + if(i > j) j = i; + + rotatesprite(0,0,65600L,0,FRAGBAR,0,0,2+8+16+64,0,0,xdim-1,ydim-1); + if(j >= 4) rotatesprite(319,(8)<<16,65600L,0,FRAGBAR,0,0,10+16+64,0,0,xdim-1,ydim-1); + if(j >= 8) rotatesprite(319,(16)<<16,65600L,0,FRAGBAR,0,0,10+16+64,0,0,xdim-1,ydim-1); + if(j >= 12) rotatesprite(319,(24)<<16,65600L,0,FRAGBAR,0,0,10+16+64,0,0,xdim-1,ydim-1); + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + minitext(21+(73*(i&3)),2+((i&28)<<1),&ud.user_name[i][0],sprite[ps[i].i].pal,2+8+16); + Bsprintf(tempbuf,"%d",ps[i].frag-ps[i].fraggedself); + minitext(17+50+(73*(i&3)),2+((i&28)<<1),tempbuf,sprite[ps[i].i].pal,2+8+16); + } +} + +void coolgaugetext(short snum) +{ + struct player_struct *p; + long i, j, o, ss, u; + char c, permbit; + + p = &ps[snum]; + + if (p->invdisptime > 0) displayinventory(p); + + + if(ps[snum].gm&MODE_MENU) + if( (current_menu >= 400 && current_menu <= 405) ) + return; + + ss = ud.screen_size; if (ss < 4) return; + + if (getrendermode() >= 3) pus = NUMPAGES; // JBF 20040101: always redraw in GL + + if ( ud.multimode > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + { + if (pus) + { displayfragbar(); } + else + { + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (ps[i].frag != sbar.frag[i]) { displayfragbar(); break; } + } + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i != myconnectindex) + sbar.frag[i] = ps[i].frag; + } + + if (ss == 4) //DRAW MINI STATUS BAR: + { + rotatesprite(sbarx(5),sbary(200-28),sbarsc(65536L),0,HEALTHBOX,0,21,10+16,0,0,xdim-1,ydim-1); + if (p->inven_icon) + rotatesprite(sbarx(69),sbary(200-30),sbarsc(65536L),0,INVENTORYBOX,0,21,10+16,0,0,xdim-1,ydim-1); + + if(sprite[p->i].pal == 1 && p->last_extra < 2) + digitalnumber(20,200-17,1,-16,10+16); + else digitalnumber(20,200-17,p->last_extra,-16,10+16); + + rotatesprite(sbarx(37),sbary(200-28),sbarsc(65536L),0,AMMOBOX,0,21,10+16,0,0,xdim-1,ydim-1); + + if (p->curr_weapon == HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; else i = p->curr_weapon; + digitalnumber(53,200-17,p->ammo_amount[i],-16,10+16); + + o = 158; permbit = 0; + if (p->inven_icon) + { + switch(p->inven_icon) + { + case 1: i = FIRSTAID_ICON; break; + case 2: i = STEROIDS_ICON; break; + case 3: i = HOLODUKE_ICON; break; + case 4: i = JETPACK_ICON; break; + case 5: i = HEAT_ICON; break; + case 6: i = AIRTANK_ICON; break; + case 7: i = BOOT_ICON; break; + default: i = -1; + } + if (i >= 0) rotatesprite(sbarx(231-o),sbary(200-21),sbarsc(65536L),0,i,0,0,10+16+permbit,0,0,xdim-1,ydim-1); + + minitext(292-30-o,190,"%",6,10+16+permbit + 256); + + j = 0x80000000; + switch(p->inven_icon) + { + case 1: i = p->firstaid_amount; break; + case 2: i = ((p->steroids_amount+3)>>2); break; + case 3: i = ((p->holoduke_amount+15)/24); j = p->holoduke_on; break; + case 4: i = ((p->jetpack_amount+15)>>4); j = p->jetpack_on; break; + case 5: i = p->heat_amount/12; j = p->heat_on; break; + case 6: i = ((p->scuba_amount+63)>>6); break; + case 7: i = (p->boot_amount>>1); break; + } + invennum(284-30-o,200-6,(char)i,0,10+permbit); + if (p->inven_icon >= 6) minitext(284-35-o,180,"AUTO",2,10+16+permbit + 256); + } + return; + } + + //DRAW/UPDATE FULL STATUS BAR: + +if (pus) { pus = 0; u = -1; } else u = 0; + +if (sbar.frag[myconnectindex] != p->frag) { sbar.frag[myconnectindex] = p->frag; u |= 32768; } + if (sbar.got_access != p->got_access) { sbar.got_access = p->got_access; u |= 16384; } + if (sbar.last_extra != p->last_extra) { sbar.last_extra = p->last_extra; u |= 1; } + { + long lAmount=GetGameVar("PLR_MORALE",-1, p->i, snum); + if(lAmount == -1) + { + if (sbar.shield_amount != p->shield_amount) { sbar.shield_amount = p->shield_amount; u |= 2; } + } + else + { + if (sbar.shield_amount != lAmount) { sbar.shield_amount = lAmount; u |= 2; } + } + } + if (sbar.curr_weapon != p->curr_weapon) { sbar.curr_weapon = p->curr_weapon; u |= (4+8+16+32+64+128+256+512+1024+65536L); } + for(i=1;i < MAX_WEAPONS;i++) + { + if (sbar.ammo_amount[i] != p->ammo_amount[i]) + { + sbar.ammo_amount[i] = p->ammo_amount[i]; + if(i < 9) + u |= ((2<gotweapon[i]) + { + sbar.gotweapon[i] = p->gotweapon[i]; + if(i < 9 ) + u |= ((2<inven_icon) { sbar.inven_icon = p->inven_icon; u |= (2048+4096+8192); } + if (sbar.holoduke_on != p->holoduke_on) { sbar.holoduke_on = p->holoduke_on; u |= (4096+8192); } + if (sbar.jetpack_on != p->jetpack_on) { sbar.jetpack_on = p->jetpack_on; u |= (4096+8192); } + if (sbar.heat_on != p->heat_on) { sbar.heat_on = p->heat_on; u |= (4096+8192); } + if (sbar.firstaid_amount != p->firstaid_amount) { sbar.firstaid_amount = p->firstaid_amount; u |= 8192; } + if (sbar.steroids_amount != p->steroids_amount) { sbar.steroids_amount = p->steroids_amount; u |= 8192; } + if (sbar.holoduke_amount != p->holoduke_amount) { sbar.holoduke_amount = p->holoduke_amount; u |= 8192; } + if (sbar.jetpack_amount != p->jetpack_amount) { sbar.jetpack_amount = p->jetpack_amount; u |= 8192; } + if (sbar.heat_amount != p->heat_amount) { sbar.heat_amount = p->heat_amount; u |= 8192; } + if (sbar.scuba_amount != p->scuba_amount) { sbar.scuba_amount = p->scuba_amount; u |= 8192; } + if (sbar.boot_amount != p->boot_amount) { sbar.boot_amount = p->boot_amount; u |= 8192; } + if (u == 0) return; + + //0 - update health + //1 - update armor + //2 - update PISTOL_WEAPON ammo + //3 - update SHOTGUN_WEAPON ammo + //4 - update CHAINGUN_WEAPON ammo + //5 - update RPG_WEAPON ammo + //6 - update HANDBOMB_WEAPON ammo + //7 - update SHRINKER_WEAPON ammo + //8 - update DEVISTATOR_WEAPON ammo + //9 - update TRIPBOMB_WEAPON ammo + //10 - update ammo display + //11 - update inventory icon + //12 - update inventory on/off + //13 - update inventory % + //14 - update keys + //15 - update kills + //16 - update FREEZE_WEAPON ammo + if (u == -1) + { + patchstatusbar(0,0,320,200); + if (ud.multimode > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + rotatesprite(sbarx(277+1),sbary(200-27-1),sbarsc(65536L),0,KILLSICON,0,0,10+16,0,0,xdim-1,ydim-1); + } + if (ud.multimode > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + { + if (u&32768) + { + if (u != -1) patchstatusbar(276,183,299,193); + digitalnumber(287,200-17,max(p->frag-p->fraggedself,0),-16,10+16); + } + } + else + { + if (u&16384) + { + if (u != -1) patchstatusbar(275,182,299,194); + if (p->got_access&4) rotatesprite(sbarx(275),sbary(182),sbarsc(65536L),0,ACCESS_ICON,0,23,10+16,0,0,xdim-1,ydim-1); + if (p->got_access&2) rotatesprite(sbarx(288),sbary(182),sbarsc(65536L),0,ACCESS_ICON,0,21,10+16,0,0,xdim-1,ydim-1); + if (p->got_access&1) rotatesprite(sbarx(281),sbary(189),sbarsc(65536L),0,ACCESS_ICON,0,0,10+16,0,0,xdim-1,ydim-1); + } + } + if (u&(4+8+16+32+64+128+256+512+65536L)) weapon_amounts(p,96,182,u); + + if (u&1) + { + if (u != -1) patchstatusbar(20,183,43,194); //Original code:(20,183,43,193); + if (sprite[p->i].pal == 1 && p->last_extra < 2) + digitalnumber(32,200-17,1,-16,10+16); + else digitalnumber(32,200-17,p->last_extra,-16,10+16); + } + if (u&2) + { + long lAmount=GetGameVar("PLR_MORALE",-1, p->i, snum); + if (u != -1) patchstatusbar(52,183,75,193); + if(lAmount == -1) + { + digitalnumber(64,200-17,p->shield_amount,-16,10+16); + } + else + { + digitalnumber(64,200-17,lAmount,-16,10+16); + } + } + + if (u&1024) + { + if (u != -1) patchstatusbar(196,183,219,194); //Original code:(196,183,219,193); + if (p->curr_weapon != KNEE_WEAPON) + { + if (p->curr_weapon == HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; else i = p->curr_weapon; + digitalnumber(230-22,200-17,p->ammo_amount[i],-16,10+16); + } + } + + if (u&(2048+4096+8192)) + { + if (u != -1) + { + if (u&(2048+4096)) { patchstatusbar(231,179,265,197); } + else { patchstatusbar(250,190,261,196); } //Original code:(250,190,261,195); + } + if (p->inven_icon) + { + o = 0; permbit = 0; + + if (u&(2048+4096)) + { + switch(p->inven_icon) + { + case 1: i = FIRSTAID_ICON; break; + case 2: i = STEROIDS_ICON; break; + case 3: i = HOLODUKE_ICON; break; + case 4: i = JETPACK_ICON; break; + case 5: i = HEAT_ICON; break; + case 6: i = AIRTANK_ICON; break; + case 7: i = BOOT_ICON; break; + } + + rotatesprite(sbarx(231-o),sbary(200-21),sbarsc(65536L),0,i,0,0,10+16+permbit,0,0,xdim-1,ydim-1); + minitext(292-30-o,190,"%",6,10+16+permbit + 256); + if (p->inven_icon >= 6) minitext(284-35-o,180,"AUTO",2,10+16+permbit + 256); + } + if (u&(2048+4096)) + { + switch(p->inven_icon) + { + case 3: j = p->holoduke_on; break; + case 4: j = p->jetpack_on; break; + case 5: j = p->heat_on; break; + default: j = 0x80000000; + } + if (j > 0) minitext(288-30-o,180,"ON",0,10+16+permbit + 256); + else if ((unsigned long)j != 0x80000000) minitext(284-30-o,180,"OFF",2,10+16+permbit + 256); + } + if (u&8192) + { + switch(p->inven_icon) + { + case 1: i = p->firstaid_amount; break; + case 2: i = ((p->steroids_amount+3)>>2); break; + case 3: i = ((p->holoduke_amount+15)/24); break; + case 4: i = ((p->jetpack_amount+15)>>4); break; + case 5: i = p->heat_amount/12; break; + case 6: i = ((p->scuba_amount+63)>>6); break; + case 7: i = (p->boot_amount>>1); break; + } + invennum(284-30-o,200-6,(char)i,0,10+permbit); + } + } + } +} + +#define AVERAGEFRAMES 16 +static long frameval[AVERAGEFRAMES], framecnt = 0; + +void tics(void) +{ + long i,j; + char b[10]; + + i = totalclock; + if (i != frameval[framecnt]) + { + j=(TICRATE*AVERAGEFRAMES)/(i-frameval[framecnt]); + Bsprintf(b,"%ld",j>0?j:0); + /* printext256(windowx1,windowy1,31,-21,b,1); */ + minitext(320-strlen(b)*4,ud.multimode>1&&ud.multimode<5?9:ud.multimode>4?17:1,b,(TICRATE*AVERAGEFRAMES)/(i-frameval[framecnt]) < 40?2:0,26); + frameval[framecnt] = i; + } + + framecnt = ((framecnt+1)&(AVERAGEFRAMES-1)); +} + +void coords(short snum) +{ + short y = 8; + + if((gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + { + if(ud.multimode > 1 && ud.multimode < 5) + y = 16; + else if(ud.multimode > 4) + y = 24; + } + sprintf(tempbuf,"X= %ld",ps[snum].posx); + printext256(250L,y,31,-1,tempbuf,0); + sprintf(tempbuf,"Y= %ld",ps[snum].posy); + printext256(250L,y+9L,31,-1,tempbuf,0); + Bsprintf(tempbuf,"Z= %ld",ps[snum].posz); + printext256(250L,y+18L,31,-1,tempbuf,0); + Bsprintf(tempbuf,"A= %d",ps[snum].ang); + printext256(250L,y+27L,31,-1,tempbuf,0); + Bsprintf(tempbuf,"ZV= %ld",ps[snum].poszv); + printext256(250L,y+36L,31,-1,tempbuf,0); + Bsprintf(tempbuf,"OG= %d",ps[snum].on_ground); + printext256(250L,y+45L,31,-1,tempbuf,0); + Bsprintf(tempbuf,"AM= %d",ps[snum].ammo_amount[GROW_WEAPON]); + printext256(250L,y+54L,31,-1,tempbuf,0); + Bsprintf(tempbuf,"LFW= %d",ps[snum].last_full_weapon); + printext256(250L,y+63L,31,-1,tempbuf,0); + Bsprintf(tempbuf,"SECTL= %d",sector[ps[snum].cursectnum].lotag); + printext256(250L,y+72L,31,-1,tempbuf,0); + Bsprintf(tempbuf,"SEED= %ld",randomseed); + printext256(250L,y+81L,31,-1,tempbuf,0); + Bsprintf(tempbuf,"THOLD= %d",ps[snum].transporter_hold); + printext256(250L,y+90L+7,31,-1,tempbuf,0); +} + +void operatefta(void) +{ + long i, j, k; + + if(ud.screen_size > 0) j = 200-45; else j = 200-8; + quotebot = min(quotebot,j); + quotebotgoal = min(quotebotgoal,j); + if(ps[myconnectindex].gm&MODE_TYPE) j -= 8; + quotebotgoal = j; j = quotebot; + for(i=0;i 4) + gametext(320>>1,j,user_quote[i],0,2+8+16); + else if (k > 2) gametext(320>>1,j,user_quote[i],0,2+8+16+1); + else gametext(320>>1,j,user_quote[i],0,2+8+16+1+32); + j -= 8; + } + + if (ps[screenpeek].fta <= 1) return; + + if ((gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR) && ud.screen_size > 0 && ud.multimode > 1) + { + j = 0; k = 8; + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i > j) j = i; + + if (j >= 4 && j <= 8) k += 8; + else if (j > 8 && j <= 12) k += 16; + else if (j > 12) k += 24; + } + else k = 0; + + if (ps[screenpeek].ftq == 115 || ps[screenpeek].ftq == 116) + { + k = quotebot; + for(i=0;i 4) + gametext(320>>1,k,fta_quotes[ps[screenpeek].ftq],0,2+8+16); + else + if (j > 2) gametext(320>>1,k,fta_quotes[ps[screenpeek].ftq],0,2+8+16+1); + else + gametext(320>>1,k,fta_quotes[ps[screenpeek].ftq],0,2+8+16+1+32); +} + +void FTA(short q,struct player_struct *p) +{ + if( ud.fta_on == 1) + { + if( p->fta > 0 && q != 115 && q != 116 ) + if( p->ftq == 115 || p->ftq == 116 ) return; + + p->fta = 100; + + if( p->ftq != q || q == 26 ) + // || q == 26 || q == 115 || q ==116 || q == 117 || q == 122 ) + { + p->ftq = q; + pub = NUMPAGES; + pus = NUMPAGES; + if (p == &ps[screenpeek]) OSD_Printf("%s\n",fta_quotes[q]); + } + } +} + +void showtwoscreens(void) +{ + short i; + + if (!VOLUMEALL) { + setview(0,0,xdim-1,ydim-1); + flushperms(); + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 1); // JBF 20040308 + fadepal(0,0,0, 0,64,7); + KB_FlushKeyboardQueue(); + rotatesprite(0,0,65536L,0,3291,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + IFISSOFTMODE fadepal(0,0,0, 63,0,-7); else nextpage(); + while( !KB_KeyWaiting() ) { handleevents(); getpackets(); } + + fadepal(0,0,0, 0,64,7); + KB_FlushKeyboardQueue(); + rotatesprite(0,0,65536L,0,3290,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + IFISSOFTMODE fadepal(0,0,0, 63,0,-7); else nextpage(); + while( !KB_KeyWaiting() ) { handleevents(); getpackets(); } + } +} +/* +void binscreen(void) +{ + long fil; +#ifdef VOLUMEONE + fil = kopen4load("dukesw.bin",1); +#else + fil = kopen4load("duke3d.bin",1); +#endif + if(fil == -1) return; + kread(fil,(char *)0xb8000,4000); + kclose(fil); +} +*/ + +extern long qsetmode; + +void gameexit(char *t) +{ + short i; + + if(*t != 0) ps[myconnectindex].palette = (char *) &palette[0]; + + if(numplayers > 1) + { + allowtimetocorrecterrorswhenquitting(); + uninitmultiplayers(); + } + + if(ud.recstat == 1) closedemowrite(); +else if(ud.recstat == 2) { if (frecfilep) fclose(frecfilep); } // JBF: fixes crash on demo playback + + if(qe || cp) + goto GOTOHERE; + + if(playerswhenstarted > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_SCORESHEET) && *t == ' ') + { + dobonus(1); + setgamemode(ScreenMode,ScreenWidth,ScreenHeight,ScreenBPP); + } + + if( *t != 0 && *(t+1) != 'V' && *(t+1) != 'Y') + showtwoscreens(); + +GOTOHERE: + + if (qsetmode == 200) + Shutdown(); + + if(*t != 0) + { + //setvmode(0x3); // JBF + //binscreen(); + // if(*t == ' ' && *(t+1) == 0) *t = 0; + //printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + if (!(t[0] == ' ' && t[1] == 0)) { + wm_msgbox(HEAD2, t); + } + } + + uninitgroupfile(); + + //unlink("duke3d.tmp"); + + exit(0); +} + +short inputloc = 0; +short strget(short x,short y,char *t,short dalen,short c) +{ + short ch; + + while((ch = KB_Getch()) != 0) + { + if(ch == asc_BackSpace) + { + if( inputloc > 0 ) + { + inputloc--; + *(t+inputloc) = 0; + } + } + else + { + if(ch == asc_Enter) + { + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + return (1); + } + else if(ch == asc_Escape) + { + KB_ClearKeyDown(sc_Escape); + return (-1); + } + else if ( ch >= 32 && inputloc < dalen && ch < 127) + { + ch = Btoupper(ch); + if (c != 997 || (ch >= '0' && ch <= '9')) { // JBF 20040508: so we can have numeric only if we want + *(t+inputloc) = ch; + *(t+inputloc+1) = 0; + inputloc++; + } + } + } + } + + if( c == 999 ) return(0); + if( c == 998 ) + { + char b[41],ii; + for(ii=0;ii>11); + rotatesprite((x+8)<<16,(y+4)<<16,32768L,0,SPINNINGNUKEICON+((totalclock>>3)%7),c,0,2+8,0,0,xdim-1,ydim-1); + + return (0); +} + +void typemode(void) +{ + short ch, hitstate, i, j; + + if( ps[myconnectindex].gm&MODE_SENDTOWHOM ) + { + if(sendmessagecommand != -1 || ud.multimode < 3 || movesperpacket == 4) + { + tempbuf[0] = 4; + tempbuf[2] = 0; + recbuf[0] = 0; + + if(ud.multimode < 3) + sendmessagecommand = 2; + + strcat(recbuf,ud.user_name[myconnectindex]); + strcat(recbuf,": "); + strcat(recbuf,typebuf); + j = strlen(recbuf); + recbuf[j] = 0; + strcat(tempbuf+2,recbuf); + + if(sendmessagecommand >= ud.multimode || movesperpacket == 4) + { + tempbuf[1] = 255; + for(ch=connecthead;ch >= 0;ch=connectpoint2[ch]) + { + if (ch != myconnectindex) sendpacket(ch,tempbuf,j+2); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + adduserquote(recbuf); + quotebot += 8; + quotebotgoal = quotebot; + } + else if(sendmessagecommand >= 0) + { + tempbuf[1] = (char)sendmessagecommand; + if ((!networkmode) && (myconnectindex != connecthead)) + sendmessagecommand = connecthead; + sendpacket(sendmessagecommand,tempbuf,j+2); + } + + sendmessagecommand = -1; + ps[myconnectindex].gm &= ~(MODE_TYPE|MODE_SENDTOWHOM); + } + else if(sendmessagecommand == -1) + { + j = 50; + gametext(320>>1,j,"SEND MESSAGE TO...",0,2+8+16); j += 8; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (i == myconnectindex) + { + minitextshade((320>>1)-40+1,j+1,"A/ENTER - ALL",26,0,2+8+16); + minitext((320>>1)-40,j,"A/ENTER - ALL",0,2+8+16); j += 7; + } + else + { + Bsprintf(buf," %d - %s",i+1,ud.user_name[i]); + minitextshade((320>>1)-40-6+1,j+1,buf,26,0,2+8+16); + minitext((320>>1)-40-6,j,buf,0,2+8+16); j += 7; + } + } + minitextshade((320>>1)-40-4+1,j+1," ESC - Abort",26,0,2+8+16); + minitext((320>>1)-40-4,j," ESC - Abort",0,2+8+16); j += 7; + + if (ud.screen_size > 0) j = 200-45; else j = 200-8; + gametext(320>>1,j,typebuf,0,2+8+16); + + if( KB_KeyWaiting() ) + { + i = KB_GetCh(); + + if(i == 'A' || i == 'a' || i == 13) + sendmessagecommand = ud.multimode; + else if(i >= '1' || i <= (ud.multimode + '1') ) + sendmessagecommand = i - '1'; + else + { + sendmessagecommand = ud.multimode; + if(i == 27) + { + ps[myconnectindex].gm &= ~(MODE_TYPE|MODE_SENDTOWHOM); + sendmessagecommand = -1; + } + else + typebuf[0] = 0; + } + + KB_ClearKeyDown(sc_1); + KB_ClearKeyDown(sc_2); + KB_ClearKeyDown(sc_3); + KB_ClearKeyDown(sc_4); + KB_ClearKeyDown(sc_5); + KB_ClearKeyDown(sc_6); + KB_ClearKeyDown(sc_7); + KB_ClearKeyDown(sc_8); + KB_ClearKeyDown(sc_A); + KB_ClearKeyDown(sc_Escape); + KB_ClearKeyDown(sc_Enter); + } + } + } + else + { + if(ud.screen_size > 0) j = 200-45; else j = 200-8; + hitstate = strget(320>>1,j,typebuf,30,1); + + if(hitstate == 1) + { + KB_ClearKeyDown(sc_Enter); + ps[myconnectindex].gm |= MODE_SENDTOWHOM; + } + else if(hitstate == -1) + ps[myconnectindex].gm &= ~(MODE_TYPE|MODE_SENDTOWHOM); + else pub = NUMPAGES; + } +} + +void moveclouds(void) +{ + if( totalclock > cloudtotalclock || totalclock < (cloudtotalclock-7)) + { + short i; + + cloudtotalclock = totalclock+6; + + for(i=0;i>9); + cloudy[i] += (sintable[ps[screenpeek].ang&2047]>>9); + + sector[clouds[i]].ceilingxpanning = cloudx[i]>>6; + sector[clouds[i]].ceilingypanning = cloudy[i]>>6; + } + } +} + +void drawoverheadmap(long cposx, long cposy, long czoom, short cang) +{ + long i, j, k, l, x1, y1, x2=0, y2=0, x3, y3, x4, y4, ox, oy, xoff, yoff; + long dax, day, cosang, sinang, xspan, yspan, sprx, spry; + long xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang; + long xvect, yvect, xvect2, yvect2; + short p; + char col; + walltype *wal, *wal2; + spritetype *spr; + + xvect = sintable[(-cang)&2047] * czoom; + yvect = sintable[(1536-cang)&2047] * czoom; + xvect2 = mulscale16(xvect,yxaspect); + yvect2 = mulscale16(yvect,yxaspect); + + //Draw red lines + for(i=0;i>3]&(1<<(i&7)))) continue; + + startwall = sector[i].wallptr; + endwall = sector[i].wallptr + sector[i].wallnum; + + z1 = sector[i].ceilingz; z2 = sector[i].floorz; + + for(j=startwall,wal=&wall[startwall];jnextwall; if (k < 0) continue; + + //if ((show2dwall[j>>3]&(1<<(j&7))) == 0) continue; + //if ((k > j) && ((show2dwall[k>>3]&(1<<(k&7))) > 0)) continue; + + if (sector[wal->nextsector].ceilingz == z1) + if (sector[wal->nextsector].floorz == z2) + if (((wal->cstat|wall[wal->nextwall].cstat)&(16+32)) == 0) continue; + + col = 139; //red + if ((wal->cstat|wall[wal->nextwall].cstat)&1) col = 234; //magenta + + if (!(show2dsector[wal->nextsector>>3]&(1<<(wal->nextsector&7)))) + col = 24; + else continue; + + ox = wal->x-cposx; oy = wal->y-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect)+(xdim<<11); + y1 = dmulscale16(oy,xvect2,ox,yvect2)+(ydim<<11); + + wal2 = &wall[wal->point2]; + ox = wal2->x-cposx; oy = wal2->y-cposy; + x2 = dmulscale16(ox,xvect,-oy,yvect)+(xdim<<11); + y2 = dmulscale16(oy,xvect2,ox,yvect2)+(ydim<<11); + + drawline256(x1,y1,x2,y2,col); + } + } + + //Draw sprites + k = ps[screenpeek].i; + for(i=0;i>3]&(1<<(i&7)))) continue; + for(j=headspritesect[i];j>=0;j=nextspritesect[j]) + //if ((show2dsprite[j>>3]&(1<<(j&7))) > 0) + { + spr = &sprite[j]; + + if (j == k || (spr->cstat&0x8000) || spr->cstat == 257 || spr->xrepeat == 0) continue; + + col = 71; //cyan + if (spr->cstat&1) col = 234; //magenta + + sprx = spr->x; + spry = spr->y; + + if( (spr->cstat&257) != 0) switch (spr->cstat&48) + { + case 0: break; + + ox = sprx-cposx; oy = spry-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect); + y1 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = (sintable[(spr->ang+512)&2047]>>7); + oy = (sintable[(spr->ang)&2047]>>7); + x2 = dmulscale16(ox,xvect,-oy,yvect); + y2 = dmulscale16(oy,xvect,ox,yvect); + + x3 = mulscale16(x2,yxaspect); + y3 = mulscale16(y2,yxaspect); + + drawline256(x1-x2+(xdim<<11),y1-y3+(ydim<<11), + x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); + drawline256(x1-y2+(xdim<<11),y1+x3+(ydim<<11), + x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); + drawline256(x1+y2+(xdim<<11),y1-x3+(ydim<<11), + x1+x2+(xdim<<11),y1+y3+(ydim<<11),col); + break; + + case 16: + if( spr->picnum == LASERLINE ) + { + x1 = sprx; y1 = spry; + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + if ((spr->cstat&4) > 0) xoff = -xoff; + k = spr->ang; l = spr->xrepeat; + dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; + l = tilesizx[tilenum]; k = (l>>1)+xoff; + x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l); + y1 -= mulscale16(day,k); y2 = y1+mulscale16(day,l); + + ox = x1-cposx; oy = y1-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect); + y1 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x2-cposx; oy = y2-cposy; + x2 = dmulscale16(ox,xvect,-oy,yvect); + y2 = dmulscale16(oy,xvect2,ox,yvect2); + + drawline256(x1+(xdim<<11),y1+(ydim<<11), + x2+(xdim<<11),y2+(ydim<<11),col); + } + + break; + + case 32: + + tilenum = spr->picnum; + xoff = (long)((signed char)((picanm[tilenum]>>8)&255))+((long)spr->xoffset); + yoff = (long)((signed char)((picanm[tilenum]>>16)&255))+((long)spr->yoffset); + if ((spr->cstat&4) > 0) xoff = -xoff; + if ((spr->cstat&8) > 0) yoff = -yoff; + + k = spr->ang; + cosang = sintable[(k+512)&2047]; sinang = sintable[k]; + xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; + yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; + + dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat; + x1 = sprx + dmulscale16(sinang,dax,cosang,day); + y1 = spry + dmulscale16(sinang,day,-cosang,dax); + l = xspan*xrepeat; + x2 = x1 - mulscale16(sinang,l); + y2 = y1 + mulscale16(cosang,l); + l = yspan*yrepeat; + k = -mulscale16(cosang,l); x3 = x2+k; x4 = x1+k; + k = -mulscale16(sinang,l); y3 = y2+k; y4 = y1+k; + + ox = x1-cposx; oy = y1-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect); + y1 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x2-cposx; oy = y2-cposy; + x2 = dmulscale16(ox,xvect,-oy,yvect); + y2 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x3-cposx; oy = y3-cposy; + x3 = dmulscale16(ox,xvect,-oy,yvect); + y3 = dmulscale16(oy,xvect2,ox,yvect2); + + ox = x4-cposx; oy = y4-cposy; + x4 = dmulscale16(ox,xvect,-oy,yvect); + y4 = dmulscale16(oy,xvect2,ox,yvect2); + + drawline256(x1+(xdim<<11),y1+(ydim<<11), + x2+(xdim<<11),y2+(ydim<<11),col); + + drawline256(x2+(xdim<<11),y2+(ydim<<11), + x3+(xdim<<11),y3+(ydim<<11),col); + + drawline256(x3+(xdim<<11),y3+(ydim<<11), + x4+(xdim<<11),y4+(ydim<<11),col); + + drawline256(x4+(xdim<<11),y4+(ydim<<11), + x1+(xdim<<11),y1+(ydim<<11),col); + + break; + } + } + } + + //Draw white lines + for(i=0;i>3]&(1<<(i&7)))) continue; + + startwall = sector[i].wallptr; + endwall = sector[i].wallptr + sector[i].wallnum; + + k = -1; + for(j=startwall,wal=&wall[startwall];jnextwall >= 0) continue; + + //if ((show2dwall[j>>3]&(1<<(j&7))) == 0) continue; + + if (tilesizx[wal->picnum] == 0) continue; + if (tilesizy[wal->picnum] == 0) continue; + + if (j == k) + { x1 = x2; y1 = y2; } + else + { + ox = wal->x-cposx; oy = wal->y-cposy; + x1 = dmulscale16(ox,xvect,-oy,yvect)+(xdim<<11); + y1 = dmulscale16(oy,xvect2,ox,yvect2)+(ydim<<11); + } + + k = wal->point2; wal2 = &wall[k]; + ox = wal2->x-cposx; oy = wal2->y-cposy; + x2 = dmulscale16(ox,xvect,-oy,yvect)+(xdim<<11); + y2 = dmulscale16(oy,xvect2,ox,yvect2)+(ydim<<11); + + drawline256(x1,y1,x2,y2,24); + } + } + + for(p=connecthead;p >= 0;p=connectpoint2[p]) + { + if(ud.scrollmode && p == screenpeek) continue; + + ox = sprite[ps[p].i].x-cposx; oy = sprite[ps[p].i].y-cposy; + daang = (sprite[ps[p].i].ang-cang)&2047; + if (p == screenpeek) { ox = 0; oy = 0; daang = 0; } + x1 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16); + y1 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16); + + if(p == screenpeek || (gametype_flags[ud.coop] & GAMETYPE_FLAG_OTHERPLAYERSINMAP ) ) + { + if(sprite[ps[p].i].xvel > 16 && ps[p].on_ground) + i = APLAYERTOP+((totalclock>>4)&3); + else + i = APLAYERTOP; + + j = klabs(ps[p].truefz-ps[p].posz)>>8; + j = mulscale(czoom*(sprite[ps[p].i].yrepeat+j),yxaspect,16); + + if(j < 22000) j = 22000; + else if(j > (65536<<1)) j = (65536<<1); + + rotatesprite((x1<<4)+(xdim<<15),(y1<<4)+(ydim<<15),j, + daang,i,sprite[ps[p].i].shade,sprite[ps[p].i].pal, + (sprite[ps[p].i].cstat&2)>>1,windowx1,windowy1,windowx2,windowy2); + } + } +} + +void palto(char r,char g,char b,long e) +{ + int i; + char temparray[768]; + long tc; +/* + for(i=0;i<768;i+=3) + { + temparray[i ] = + ps[myconnectindex].palette[i+0]+((((long)r-(long)ps[myconnectindex].palette[i+0])*(long)(e&127))>>6); + temparray[i+1] = + ps[myconnectindex].palette[i+1]+((((long)g-(long)ps[myconnectindex].palette[i+1])*(long)(e&127))>>6); + temparray[i+2] = + ps[myconnectindex].palette[i+2]+((((long)b-(long)ps[myconnectindex].palette[i+2])*(long)(e&127))>>6); + } +*/ + + //setbrightness(ud.brightness>>2,temparray); + setpalettefade(r,g,b,e&127); + if (getrendermode() >= 3) pus = pub = NUMPAGES; // JBF 20040110: redraw the status bar next time + if ((e&128) == 0) { + nextpage(); + for (tc = totalclock; totalclock < tc + 4; handleevents(), getpackets() ); + } +} + +void displayrest(long smoothratio) +{ + long a, i, j; + char fader=0,fadeg=0,fadeb=0,fadef=0,tintr=0,tintg=0,tintb=0,tintf=0,dotint=0; + + struct player_struct *pp; + walltype *wal; + long cposx,cposy,cang; + + pp = &ps[screenpeek]; + + // this takes care of fullscreen tint for OpenGL + if (getrendermode() >= 3) { + if (pp->palette == waterpal) tintr=0,tintg=0,tintb=63,tintf=8; + else if (pp->palette == slimepal) tintr=0,tintg=63,tintb=0,tintf=8; + } + + // this does pain tinting etc from the CON + if( pp->pals_time >= 0 && pp->loogcnt == 0) // JBF 20040101: pals_time > 0 now >= 0 + { + fader = pp->pals[0]; + fadeg = pp->pals[1]; + fadeb = pp->pals[2]; + fadef = pp->pals_time; + restorepalette = 1; // JBF 20040101 + dotint = 1; + } + // reset a normal palette + else if( restorepalette ) + { + //setbrightness(ud.brightness>>2,&pp->palette[0],0); + setgamepalette(pp,pp->palette,0); + restorepalette = 0; + } + // loogies courtesy of being snotted on + else if(pp->loogcnt > 0) { + //palto(0,64,0,(pp->loogcnt>>1)+128); + fader = 0; + fadeg = 64; + fadeb = 0; + fadef = pp->loogcnt>>1; + dotint = 1; + } + if (fadef > tintf) { + tintr = fader; + tintg = fadeg; + tintb = fadeb; + tintf = fadef; + } + + if(ud.show_help) + { + switch(ud.show_help) + { + case 1: + rotatesprite(0,0,65536L,0,TEXTSTORY,0,0,10+16+64, 0,0,xdim-1,ydim-1); + break; + case 2: + rotatesprite(0,0,65536L,0,F1HELP,0,0,10+16+64, 0,0,xdim-1,ydim-1); + break; + } + + if ( KB_KeyPressed(sc_Escape ) ) + { + KB_ClearKeyDown(sc_Escape); + ud.show_help = 0; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + vscrn(); + } + if (tintf > 0 || dotint) palto(tintr,tintg,tintb,tintf|128); + return; + } + + i = pp->cursectnum; + + show2dsector[i>>3] |= (1<<(i&7)); + wal = &wall[sector[i].wallptr]; + for(j=sector[i].wallnum;j>0;j--,wal++) + { + i = wal->nextsector; + if (i < 0) continue; + if (wal->cstat&0x0071) continue; + if (wall[wal->nextwall].cstat&0x0071) continue; + if (sector[i].lotag == 32767) continue; + if (sector[i].ceilingz >= sector[i].floorz) continue; + show2dsector[i>>3] |= (1<<(i&7)); + } + + if(ud.camerasprite == -1) + { + if( ud.overhead_on != 2 ) + { + if(pp->newowner >= 0) + cameratext(pp->newowner); + else + { + displayweapon(screenpeek); + if(pp->over_shoulder_on == 0 ) + displaymasks(screenpeek); + } + moveclouds(); + } + + if( ud.overhead_on > 0 ) + { + smoothratio = min(max(smoothratio,0),65536); + dointerpolations(smoothratio); + if( ud.scrollmode == 0 ) + { + if(pp->newowner == -1) + { + if (screenpeek == myconnectindex && numplayers > 1) + { + cposx = omyx+mulscale16((long)(myx-omyx),smoothratio); + cposy = omyy+mulscale16((long)(myy-omyy),smoothratio); + cang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); + } + else + { + cposx = pp->oposx+mulscale16((long)(pp->posx-pp->oposx),smoothratio); + cposy = pp->oposy+mulscale16((long)(pp->posy-pp->oposy),smoothratio); + cang = pp->oang+mulscale16((long)(((pp->ang+1024-pp->oang)&2047)-1024),smoothratio); + } + } + else + { + cposx = pp->oposx; + cposy = pp->oposy; + cang = pp->oang; + } + } + else + { + + ud.fola += ud.folavel>>3; + ud.folx += (ud.folfvel*sintable[(512+2048-ud.fola)&2047])>>14; + ud.foly += (ud.folfvel*sintable[(512+1024-512-ud.fola)&2047])>>14; + + cposx = ud.folx; + cposy = ud.foly; + cang = ud.fola; + } + + if(ud.overhead_on == 2) + { + clearview(0L); + drawmapview(cposx,cposy,pp->zoom,cang); + } + drawoverheadmap( cposx,cposy,pp->zoom,cang); + + restoreinterpolations(); + + if(ud.overhead_on == 2) + { + if(ud.screen_size > 0) a = 147; + else a = 182; + + minitext(1,a+6,volume_names[ud.volume_number],0,2+8+16); + minitext(1,a+12,level_names[ud.volume_number*11 + ud.level_number],0,2+8+16); + } + } + } + + coolgaugetext(screenpeek); + operatefta(); + + if( KB_KeyPressed(sc_Escape) && ud.overhead_on == 0 + && ud.show_help == 0 + && ps[myconnectindex].newowner == -1) + { + if( (ps[myconnectindex].gm&MODE_MENU) == MODE_MENU && current_menu < 51) + { + KB_ClearKeyDown(sc_Escape); + ps[myconnectindex].gm &= ~MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + cameraclock = totalclock; + cameradist = 65536L; + } + walock[TILE_SAVESHOT] = 199; + vscrn(); + } + else if( (ps[myconnectindex].gm&MODE_MENU) != MODE_MENU && + ps[myconnectindex].newowner == -1 && + (ps[myconnectindex].gm&MODE_TYPE) != MODE_TYPE) + { + KB_ClearKeyDown(sc_Escape); + FX_StopAllSounds(); + clearsoundlocks(); + + intomenusounds(); + + ps[myconnectindex].gm |= MODE_MENU; + + if(ud.multimode < 2 && ud.recstat != 2) ready2send = 0; + + if(ps[myconnectindex].gm&MODE_GAME) cmenu(50); + else cmenu(0); + screenpeek = myconnectindex; + } + } + + OnEvent(EVENT_DISPLAYREST, ps[screenpeek].i, screenpeek, -1); + + if(ps[myconnectindex].newowner == -1 && ud.overhead_on == 0 && ud.crosshair && ud.camerasprite == -1) + { + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DISPLAYCROSSHAIR, ps[screenpeek].i, screenpeek, -1); + + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0) + rotatesprite((160L-(ps[myconnectindex].look_ang>>1))<<16,100L<<16,65536L,0,CROSSHAIR,0,0,2+1,windowx1,windowy1,windowx2,windowy2); + } + if(ps[myconnectindex].gm&MODE_TYPE) + typemode(); + else + menus(); + + if( ud.pause_on==1 && (ps[myconnectindex].gm&MODE_MENU) == 0 ) + menutext(160,100,0,0,"GAME PAUSED"); + + if(ud.coords) + coords(screenpeek); + if(ud.tickrate&&!(ps[myconnectindex].gm&MODE_MENU)) + tics(); + + // JBF 20040124: display level stats in screen corner + if(ud.levelstats && (ps[myconnectindex].gm&MODE_MENU) == 0) { + i = (ud.screen_size <= 4)?0:scale(tilesizy[BOTTOMSTATUSBAR],ud.statusbarscale,100); + + Bsprintf(tempbuf,"Time: %ld:%02ld", + (ps[myconnectindex].player_par/(26*60)), + (ps[myconnectindex].player_par/26)%60); + minitext(320-5*12,200-i-6-6-6,tempbuf,0,26); + + if(ud.player_skill > 3 ) + Bsprintf(tempbuf,"Kills: %ld",ps[myconnectindex].actors_killed); + else + Bsprintf(tempbuf,"Kills: %ld/%ld",ps[myconnectindex].actors_killed, + ps[myconnectindex].max_actors_killed>ps[myconnectindex].actors_killed? + ps[myconnectindex].max_actors_killed:ps[myconnectindex].actors_killed); + minitext(320-5*12,200-i-6-6,tempbuf,0,26); + + Bsprintf(tempbuf,"Secrets: %ld/%ld", ps[myconnectindex].secret_rooms,ps[myconnectindex].max_secret_rooms); + minitext(320-5*12,200-i-6,tempbuf,0,26); + } + if (tintf > 0 || dotint) palto(tintr,tintg,tintb,tintf|128); +} + +void view(struct player_struct *pp, long *vx, long *vy,long *vz,short *vsectnum, short ang, short horiz) +{ + spritetype *sp; + long i, nx, ny, nz, hx, hy, hz, hitx, hity, hitz; + short bakcstat, hitsect, hitwall, hitsprite, daang; + + nx = (sintable[(ang+1536)&2047]>>4); + ny = (sintable[(ang+1024)&2047]>>4); + nz = (horiz-100)*128; + + sp = &sprite[pp->i]; + + bakcstat = sp->cstat; + sp->cstat &= (short)~0x101; + + updatesectorz(*vx,*vy,*vz,vsectnum); + hitscan(*vx,*vy,*vz,*vsectnum,nx,ny,nz,&hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + + if(*vsectnum < 0) + { + sp->cstat = bakcstat; + return; + } + + hx = hitx-(*vx); hy = hity-(*vy); + if (klabs(nx)+klabs(ny) > klabs(hx)+klabs(hy)) + { + *vsectnum = hitsect; + if (hitwall >= 0) + { + daang = getangle(wall[wall[hitwall].point2].x-wall[hitwall].x, + wall[wall[hitwall].point2].y-wall[hitwall].y); + + i = nx*sintable[daang]+ny*sintable[(daang+1536)&2047]; + if (klabs(nx) > klabs(ny)) hx -= mulscale28(nx,i); + else hy -= mulscale28(ny,i); + } + else if (hitsprite < 0) + { + if (klabs(nx) > klabs(ny)) hx -= (nx>>5); + else hy -= (ny>>5); + } + if (klabs(nx) > klabs(ny)) i = divscale16(hx,nx); + else i = divscale16(hy,ny); + if (i < cameradist) cameradist = i; + } + *vx = (*vx)+mulscale16(nx,cameradist); + *vy = (*vy)+mulscale16(ny,cameradist); + *vz = (*vz)+mulscale16(nz,cameradist); + + cameradist = min(cameradist+((totalclock-cameraclock)<<10),65536); + cameraclock = totalclock; + + updatesectorz(*vx,*vy,*vz,vsectnum); + + sp->cstat = bakcstat; +} + +//REPLACE FULLY +void drawbackground(void) +{ + short dapicnum; + long x,y,x1,y1,x2,y2,rx; + + flushperms(); + + switch(ud.m_volume_number) + { + default:dapicnum = BIGHOLE;break; + case 1:dapicnum = BIGHOLE;break; + case 2:dapicnum = BIGHOLE;break; + } + + if (tilesizx[dapicnum] == 0 || tilesizy[dapicnum] == 0) { + pus = pub = NUMPAGES; + return; + } + + y1 = 0; y2 = ydim; + if( (ready2send && ps[myconnectindex].gm == MODE_GAME) || ud.recstat == 2 ) + //if (ud.recstat == 0 || ud.recstat == 1 || (ud.recstat == 2 && ud.reccnt > 0)) // JBF 20040717 + { + if (ud.screen_size == 8) + y1 = scale(ydim,200-scale(tilesizy[BOTTOMSTATUSBAR],ud.statusbarscale,100),200); + else if((gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + { + if (ud.multimode > 1) y1 += scale(ydim,8,200); + if (ud.multimode > 4) y1 += scale(ydim,8,200); + } + } else { + // when not rendering a game, fullscreen wipe + SetGameVarID(g_iReturnVarID,BIGHOLE, -1, -1); + OnEvent(EVENT_GETMENUTILE, -1, -1, -1); + if (GetGameVar("MENU_TILE", 1, -1, -1)) + { + for(y=y1;y 8) { + // across top + for (y=0; y> 1; + x1 = xdim-x2; x1 -= x1%tilesizx[dapicnum]; + for(y=y1-y1%tilesizy[dapicnum]; y 8 && ( ready2send || ud.recstat == 2 )) + { + y = 0; + if((gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + { + if (ud.multimode > 1) y += 8; + if (ud.multimode > 4) y += 8; + } + + x1 = max(windowx1-4,0); + y1 = max(windowy1-4,y); + x2 = min(windowx2+4,xdim-1); + y2 = min(windowy2+4,scale(ydim,200-scale(tilesizy[BOTTOMSTATUSBAR],ud.statusbarscale,100),200)-1); + + for(y=y1+4;y=0;j=nextspritestat[j]) + { + if( sprite[j].picnum==1 && sprite[j].lotag==fofmode && sprite[j].hitag==sprite[floor1].hitag ) + { + floor1=j; + fofmode=sprite[j].lotag; + ok++; + break; + } + } + // if(ok==1) { Message("no floor1",RED); return; } + + if(fofmode==40) k=41; else k=40; + + for(j=headspritestat[15];j>=0;j=nextspritestat[j]) + { + if( sprite[j].picnum==1 && sprite[j].lotag==k && sprite[j].hitag==sprite[floor1].hitag ) + { + floor2=j; ok++; break; + } + } + + i=floor1; + offx=sprite[floor2].x-sprite[floor1].x; + offy=sprite[floor2].y-sprite[floor1].y; + offz=0; + + if (sprite[floor2].ang >= 1024) + offz = sprite[floor2].z; + else if (fofmode==41) + offz = sector[sprite[floor2].sectnum].floorz; + else + offz = sector[sprite[floor2].sectnum].ceilingz; + + if (sprite[floor1].ang >= 1024) + offz -= sprite[floor1].z; + else if (fofmode==40) + offz -= sector[sprite[floor1].sectnum].floorz; + else + offz -= sector[sprite[floor1].sectnum].ceilingz; + + + // if(ok==2) { Message("no floor2",RED); return; } + + for(j=headspritestat[15];j>=0;j=nextspritestat[j]) // raise ceiling or floor + { + if(sprite[j].picnum==1 && sprite[j].lotag==k+2 && sprite[j].hitag==sprite[floor1].hitag ) + { + if(k==40) + { + tempsectorz[sprite[j].sectnum]=sector[sprite[j].sectnum].floorz; + sector[sprite[j].sectnum].floorz+=(((z-sector[sprite[j].sectnum].floorz)/32768)+1)*32768; + tempsectorpicnum[sprite[j].sectnum]=sector[sprite[j].sectnum].floorpicnum; + sector[sprite[j].sectnum].floorpicnum=562; + } + else + { + tempsectorz[sprite[j].sectnum]=sector[sprite[j].sectnum].ceilingz; + sector[sprite[j].sectnum].ceilingz+=(((z-sector[sprite[j].sectnum].ceilingz)/32768)-1)*32768; + tempsectorpicnum[sprite[j].sectnum]=sector[sprite[j].sectnum].ceilingpicnum; + sector[sprite[j].sectnum].ceilingpicnum=562; + } + draw_both = 1; + } + } + + drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum); + animatesprites(x,y,a,smoothratio); + drawmasks(); + + if (draw_both) + { + for(j=headspritestat[15];j>=0;j=nextspritestat[j]) // restore ceiling or floor for the draw both sectors + { + if(sprite[j].picnum==1 && + sprite[j].lotag==k+2 && + sprite[j].hitag==sprite[floor1].hitag) + { + if(k==40) + { + sector[sprite[j].sectnum].floorz=tempsectorz[sprite[j].sectnum]; + sector[sprite[j].sectnum].floorpicnum=tempsectorpicnum[sprite[j].sectnum]; + } + else + { + sector[sprite[j].sectnum].ceilingz=tempsectorz[sprite[j].sectnum]; + sector[sprite[j].sectnum].ceilingpicnum=tempsectorpicnum[sprite[j].sectnum]; + } + }// end if + }// end for + + // Now re-draw + drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum); + animatesprites(x,y,a,smoothratio); + drawmasks(); + } +} // end SE40 + +static void se40code(long x,long y,long z,long a,long h, long smoothratio) +{ + int i; + + i = headspritestat[15]; + while(i >= 0) + { + int t = sprite[i].lotag; + switch(t) + { + // case 40: + // case 41: + // SE40_Draw(i,x,y,a,smoothratio); + // break; + case 42: + case 43: + case 44: + case 45: + if(ps[screenpeek].cursectnum == sprite[i].sectnum) + SE40_Draw(i,x,y,z,a,h,smoothratio); + break; + } + i = nextspritestat[i]; + } +} +#endif + +static long oyrepeat=-1; + +void displayrooms(short snum,long smoothratio) +{ + long cposx,cposy,cposz,dst,j,fz,cz,hz,lz; + short sect, cang, k, choriz,tsect; + struct player_struct *p; + long tposx,tposy,tposz,dx,dy,thoriz,i; + short tang; + long tiltcx,tiltcy,tiltcs=0; // JBF 20030807 + + p = &ps[snum]; + + if(pub > 0 || getrendermode() >= 3) // JBF 20040101: redraw background always + { + if(ud.screen_size > 8 || (ud.screen_size == 8 && ud.statusbarscale<100)) drawbackground(); + pub = 0; + } + + if( ud.overhead_on == 2 || ud.show_help || p->cursectnum == -1) + return; + + smoothratio = min(max(smoothratio,0),65536); + + visibility = p->visibility; + + if(ud.pause_on || ps[snum].on_crane > -1) smoothratio = 65536; + + sect = p->cursectnum; + if(sect < 0 || sect >= MAXSECTORS) return; + + dointerpolations(smoothratio); + + animatecamsprite(); + + if(ud.camerasprite >= 0) + { + spritetype *s; + + s = &sprite[ud.camerasprite]; + + if(s->yvel < 0) s->yvel = -100; + else if(s->yvel > 199) s->yvel = 300; + + cang = hittype[ud.camerasprite].tempang+mulscale16((long)(((s->ang+1024-hittype[ud.camerasprite].tempang)&2047)-1024),smoothratio); +#ifdef SE40 + se40code(s->x,s->y,s->z,cang,s->yvel,smoothratio); +#endif + drawrooms(s->x,s->y,s->z-(4<<8),cang,s->yvel,s->sectnum); + animatesprites(s->x,s->y,cang,smoothratio); + drawmasks(); + } + else + { + i = divscale22(1,sprite[p->i].yrepeat+28); + if (i != oyrepeat) + { + oyrepeat = i; + setaspect(oyrepeat,yxaspect); + } + + if(screencapt) + { + walock[TILE_SAVESHOT] = 199; + if (waloff[TILE_SAVESHOT] == 0) + allocache((long *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]); + setviewtotile(TILE_SAVESHOT,200L,320L); + } + else if( getrendermode() == 0 && ( ( ud.screen_tilting && p->rotscrnang ) || ud.detail==0 ) ) + { + if (ud.screen_tilting) tang = p->rotscrnang; else tang = 0; + + if (xres <= 320 && yres <= 240) { // JBF 20030807: Increased tilted-screen quality + tiltcs = 1; + tiltcx = 320; + tiltcy = 200; + } else { + tiltcs = 2; + tiltcx = 640; + tiltcy = 480; + } + + walock[TILE_TILT] = 255; + if (waloff[TILE_TILT] == 0) + allocache(&waloff[TILE_TILT],tiltcx*tiltcx,&walock[TILE_TILT]); + if ((tang&1023) == 0) + setviewtotile(TILE_TILT,tiltcy>>(1-ud.detail),tiltcx>>(1-ud.detail)); + else + setviewtotile(TILE_TILT,tiltcx>>(1-ud.detail),tiltcx>>(1-ud.detail)); + if ((tang&1023) == 512) + { //Block off unscreen section of 90ø tilted screen + j = ((tiltcx-(60*tiltcs))>>(1-ud.detail)); + for(i=((60*tiltcs)>>(1-ud.detail))-1;i>=0;i--) + { + startumost[i] = 1; startumost[i+j] = 1; + startdmost[i] = 0; startdmost[i+j] = 0; + } + } + + i = (tang&511); if (i > 256) i = 512-i; + i = sintable[i+512]*8 + sintable[i]*5L; + setaspect(i>>1,yxaspect); + } else if (getrendermode() > 0 /*&& (p->rotscrnang || p->orotscrnang)*/) { + setrollangle(p->orotscrnang + mulscale16(((p->rotscrnang - p->orotscrnang + 1024)&2047)-1024,smoothratio)); + p->orotscrnang = p->rotscrnang; // JBF: save it for next time + } + + if ( (snum == myconnectindex) && (numplayers > 1) ) + { + cposx = omyx+mulscale16((long)(myx-omyx),smoothratio); + cposy = omyy+mulscale16((long)(myy-omyy),smoothratio); + cposz = omyz+mulscale16((long)(myz-omyz),smoothratio); + cang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); + choriz = omyhoriz+omyhorizoff+mulscale16((long)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio); + sect = mycursectnum; + } + else + { + cposx = p->oposx+mulscale16((long)(p->posx-p->oposx),smoothratio); + cposy = p->oposy+mulscale16((long)(p->posy-p->oposy),smoothratio); + cposz = p->oposz+mulscale16((long)(p->posz-p->oposz),smoothratio); + cang = p->oang+mulscale16((long)(((p->ang+1024-p->oang)&2047)-1024),smoothratio); + choriz = p->ohoriz+p->ohorizoff+mulscale16((long)(p->horiz+p->horizoff-p->ohoriz-p->ohorizoff),smoothratio); + } + cang += p->look_ang; + + if (p->newowner >= 0) + { + cang = p->ang+p->look_ang; + choriz = p->horiz+p->horizoff; + cposx = p->posx; + cposy = p->posy; + cposz = p->posz; + sect = sprite[p->newowner].sectnum; + smoothratio = 65536L; + } + + else if( p->over_shoulder_on == 0 ) + cposz += p->opyoff+mulscale16((long)(p->pyoff-p->opyoff),smoothratio); + else view(p,&cposx,&cposy,&cposz,§,cang,choriz); + + cz = hittype[p->i].ceilingz; + fz = hittype[p->i].floorz; + + if(earthquaketime > 0 && p->on_ground == 1) + { + cposz += 256-(((earthquaketime)&1)<<9); + cang += (2-((earthquaketime)&2))<<2; + } + + if(sprite[p->i].pal == 1) cposz -= (18<<8); + + if(p->newowner >= 0) + choriz = 100+sprite[p->newowner].shade; + else if(p->spritebridge == 0) + { + if( cposz < ( p->truecz + (4<<8) ) ) cposz = cz + (4<<8); + else if( cposz > ( p->truefz - (4<<8) ) ) cposz = fz - (4<<8); + } + + if (sect >= 0) + { + getzsofslope(sect,cposx,cposy,&cz,&fz); + if (cposz < cz+(4<<8)) cposz = cz+(4<<8); + if (cposz > fz-(4<<8)) cposz = fz-(4<<8); + } + + if(choriz > 299) choriz = 299; + else if(choriz < -99) choriz = -99; +#ifdef SE40 + se40code(cposx,cposy,cposz,cang,choriz,smoothratio); +#endif + if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) + { + dst = 0x7fffffff; i = 0; + for(k=0;k>1) + (j>>2); + + drawrooms(tposx,tposy,cposz,tang,choriz,mirrorsector[i]+MAXSECTORS); + + display_mirror = 1; + animatesprites(tposx,tposy,tang,smoothratio); + display_mirror = 0; + + drawmasks(); + completemirror(); //Reverse screen x-wise in this function + visibility = j; + } + gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7)); + } + + drawrooms(cposx,cposy,cposz,cang,choriz,sect); + animatesprites(cposx,cposy,cang,smoothratio); + drawmasks(); + + if(screencapt == 1) + { + setviewback(); + screencapt = 0; + // walock[TILE_SAVESHOT] = 1; + } + else if( getrendermode() == 0 && ( ( ud.screen_tilting && p->rotscrnang) || ud.detail==0 ) ) + { + if (ud.screen_tilting) tang = p->rotscrnang; else tang = 0; + + if (getrendermode() == 0) { + setviewback(); + picanm[TILE_TILT] &= 0xff0000ff; + i = (tang&511); if (i > 256) i = 512-i; + i = sintable[i+512]*8 + sintable[i]*5L; + if ((1-ud.detail) == 0) i >>= 1; + i>>=(tiltcs-1); // JBF 20030807 + rotatesprite(160<<16,100<<16,i,tang+512,TILE_TILT,0,0,4+2+64,windowx1,windowy1,windowx2,windowy2); + walock[TILE_TILT] = 199; + } + } + } + + restoreinterpolations(); + + if (totalclock < lastvisinc) + { + if (klabs(p->visibility-ud.const_visibility) > 8) + p->visibility += (ud.const_visibility-p->visibility)>>2; + } + else p->visibility = ud.const_visibility; +} + +short LocateTheLocator(short n,short sn) +{ + short i; + + i = headspritestat[7]; + while(i >= 0) + { + if( (sn == -1 || sn == SECT) && n == SLT ) + return i; + i = nextspritestat[i]; + } + return -1; +} + +short EGS(short whatsect,long s_x,long s_y,long s_z,short s_pn,signed char s_s,signed char s_xr,signed char s_yr,short s_a,short s_ve,long s_zv,short s_ow,signed char s_ss) +{ + short i; + long p; + spritetype *s; + + i = insertsprite(whatsect,s_ss); + + if( i < 0 ) + gameexit(" Too many sprites spawned."); + + hittype[i].bposx = s_x; + hittype[i].bposy = s_y; + hittype[i].bposz = s_z; + + s = &sprite[i]; + + s->x = s_x; + s->y = s_y; + s->z = s_z; + s->cstat = 0; + s->picnum = s_pn; + s->shade = s_s; + s->xrepeat = s_xr; + s->yrepeat = s_yr; + s->pal = 0; + + s->ang = s_a; + s->xvel = s_ve; + s->zvel = s_zv; + s->owner = s_ow; + s->xoffset = 0; + s->yoffset = 0; + s->yvel = 0; + s->clipdist = 0; + s->pal = 0; + s->lotag = 0; + + hittype[i].picnum = sprite[s_ow].picnum; + + hittype[i].lastvx = 0; + hittype[i].lastvy = 0; + + hittype[i].timetosleep = 0; + hittype[i].actorstayput = -1; + hittype[i].extra = -1; + hittype[i].owner = s_ow; + hittype[i].cgg = 0; + hittype[i].movflag = 0; + hittype[i].tempang = 0; + hittype[i].dispicnum = 0; + hittype[i].floorz = hittype[s_ow].floorz; + hittype[i].ceilingz = hittype[s_ow].ceilingz; + + T1=T3=T4=T6=T7=T8=T9=0; + + actorspriteflags[i] = 0; + + if( actorscrptr[s_pn] ) + { + s->extra = *actorscrptr[s_pn]; + T5 = *(actorscrptr[s_pn]+1); + T2 = *(actorscrptr[s_pn]+2); + s->hitag = *(actorscrptr[s_pn]+3); + } + else + { + T2=T5=0; + s->extra = 0; + s->hitag = 0; + } + + if (show2dsector[SECT>>3]&(1<<(SECT&7))) show2dsprite[i>>3] |= (1<<(i&7)); + else show2dsprite[i>>3] &= ~(1<<(i&7)); + + clearbufbyte(&spriteext[i], sizeof(spriteexttype), 0); + + /* + if(s->sectnum < 0) + { + s->xrepeat = s->yrepeat = 0; + changespritestat(i,5); + } + */ + ResetActorGameVars(i); + actorspriteflags[i] = 0; + OnEvent(EVENT_EGS,i, findplayer(&sprite[i],&p), p); + return(i); +} + +char wallswitchcheck(short i) +{ + int j; + //MULTISWITCH has 4 states so deal with it separately + if ((PN >= MULTISWITCH) && (PN <=MULTISWITCH+3)) return 1; + // ACCESSSWITCH and ACCESSSWITCH2 are only active in 1 state so deal with them separately + if ((PN == ACCESSSWITCH) || (PN == ACCESSSWITCH2)) return 1; + //loop to catch both states of switches + for (j=0;j<=1;j++) { + switch(dynamictostatic[PN-j]) + { + case HANDPRINTSWITCH__STATIC: + //case HANDPRINTSWITCH+1: + case ALIENSWITCH__STATIC: + //case ALIENSWITCH+1: + case MULTISWITCH__STATIC: + //case MULTISWITCH+1: + //case MULTISWITCH+2: + //case MULTISWITCH+3: + //case ACCESSSWITCH: + //case ACCESSSWITCH2: + case PULLSWITCH__STATIC: + //case PULLSWITCH+1: + case HANDSWITCH__STATIC: + //case HANDSWITCH+1: + case SLOTDOOR__STATIC: + //case SLOTDOOR+1: + case LIGHTSWITCH__STATIC: + //case LIGHTSWITCH+1: + case SPACELIGHTSWITCH__STATIC: + //case SPACELIGHTSWITCH+1: + case SPACEDOORSWITCH__STATIC: + //case SPACEDOORSWITCH+1: + case FRANKENSTINESWITCH__STATIC: + //case FRANKENSTINESWITCH+1: + case LIGHTSWITCH2__STATIC: + //case LIGHTSWITCH2+1: + case POWERSWITCH1__STATIC: + //case POWERSWITCH1+1: + case LOCKSWITCH1__STATIC: + //case LOCKSWITCH1+1: + case POWERSWITCH2__STATIC: + //case POWERSWITCH2+1: + case DIPSWITCH__STATIC: + //case DIPSWITCH+1: + case DIPSWITCH2__STATIC: + //case DIPSWITCH2+1: + case TECHSWITCH__STATIC: + //case TECHSWITCH+1: + case DIPSWITCH3__STATIC: + //case DIPSWITCH3+1: + return 1; + } + } + return 0; +} + +long tempwallptr; +short spawn( short j, short pn ) +{ + short i, s, startwall, endwall, sect, clostest=0; + long x, y, d, p; + spritetype *sp; + + if(j >= 0) + { + i = EGS(sprite[j].sectnum,sprite[j].x,sprite[j].y,sprite[j].z + ,pn,0,0,0,0,0,0,j,0); + hittype[i].picnum = sprite[j].picnum; + } + else + { + i = pn; + + hittype[i].picnum = PN; + hittype[i].timetosleep = 0; + hittype[i].extra = -1; + + hittype[i].bposx = SX; + hittype[i].bposy = SY; + hittype[i].bposz = SZ; + + OW = hittype[i].owner = i; + hittype[i].cgg = 0; + hittype[i].movflag = 0; + hittype[i].tempang = 0; + hittype[i].dispicnum = 0; + hittype[i].floorz = sector[SECT].floorz; + hittype[i].ceilingz = sector[SECT].ceilingz; + + hittype[i].lastvx = 0; + hittype[i].lastvy = 0; + hittype[i].actorstayput = -1; + + T1 = T2 = T3 = T4 = T5 = T6 = T7 = T8 = T9 = 0; + + actorspriteflags[i] = 0; + + if( PN != SPEAKER && PN != LETTER && PN != DUCK && PN != TARGET && PN != TRIPBOMB && PN != VIEWSCREEN && PN != VIEWSCREEN2 && (CS&48) ) + if( !(PN >= CRACK1 && PN <= CRACK4) ) + { + if(SS == 127) return i; + if( wallswitchcheck(i) == 1 && (CS&16) ) + { + if( PN != ACCESSSWITCH && PN != ACCESSSWITCH2 && sprite[i].pal) + { + if( (ud.multimode < 2) || (ud.multimode > 1 && !(gametype_flags[ud.coop] & GAMETYPE_FLAG_DMSWITCHES)) ) + { + sprite[i].xrepeat = sprite[i].yrepeat = 0; + sprite[i].cstat = SLT = SHT = 0; + return i; + } + } + CS |= 257; + if( sprite[i].pal && PN != ACCESSSWITCH && PN != ACCESSSWITCH2) + sprite[i].pal = 0; + return i; + } + + if( SHT ) + { + changespritestat(i,12); + CS |= 257; + SH = impact_damage; + return i; + } + } + + s = PN; + + if( CS&1 ) CS |= 256; + + if( actorscrptr[s] ) + { + SH = *(actorscrptr[s]); + T5 = *(actorscrptr[s]+1); + T2 = *(actorscrptr[s]+2); + if( *(actorscrptr[s]+3) && SHT == 0 ) + SHT = *(actorscrptr[s]+3); + } + else T2 = T5 = 0; + } + + sp = &sprite[i]; + sect = sp->sectnum; + + //some special cases that can't be handled through the dynamictostatic system. + if (((sp->picnum >= BOLT1)&&(sp->picnum <= BOLT1+3))||((sp->picnum >= SIDEBOLT1)&&(sp->picnum <= SIDEBOLT1+3))) + { + T1 = sp->xrepeat; + T2 = sp->yrepeat; + sp->yvel = 0; + changespritestat(i,6); + } + else if (((sp->picnum >= CAMERA1)&&(sp->picnum <= CAMERA1+3))||(sp->picnum==CAMERAPOLE)||(sp->picnum==GENERICPOLE)) + { + if (sp->picnum != GENERICPOLE) { + sp->extra = 1; + + if(camerashitable) sp->cstat = 257; + else sp->cstat = 0; + } + if( ud.multimode < 2 && sp->pal != 0 ) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + + } + else { + sp->pal = 0; + if (!(sp->picnum == CAMERAPOLE || sp->picnum == GENERICPOLE)) { + sp->picnum = CAMERA1; + changespritestat(i,1); + } + } + } + else switch(dynamictostatic[sp->picnum]) + { + default: + + if( actorscrptr[sp->picnum] ) + { + if( j == -1 && sp->lotag > ud.player_skill ) + { + sp->xrepeat=sp->yrepeat=0; + changespritestat(i,5); + break; + } + + // Init the size + if(sp->xrepeat == 0 || sp->yrepeat == 0) + sp->xrepeat = sp->yrepeat = 1; + + if( actortype[sp->picnum] & 3) + { + if( ud.monsters_off == 1 ) + { + sp->xrepeat=sp->yrepeat=0; + changespritestat(i,5); + break; + } + + makeitfall(i); + + if( actortype[sp->picnum] & 2) + hittype[i].actorstayput = sp->sectnum; + + ps[myconnectindex].max_actors_killed++; + sp->clipdist = 80; + if(j >= 0) + { + if(sprite[j].picnum == RESPAWN) + hittype[i].tempang = sprite[i].pal = sprite[j].pal; + changespritestat(i,1); + } + else changespritestat(i,2); + } + else + { + sp->clipdist = 40; + sp->owner = i; + changespritestat(i,1); + } + + hittype[i].timetosleep = 0; + + if(j >= 0) + sp->ang = sprite[j].ang; + } + break; + case FOF__STATIC: + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + case WATERSPLASH2__STATIC: + if(j >= 0) + { + setsprite(i,sprite[j].x,sprite[j].y,sprite[j].z); + sp->xrepeat = sp->yrepeat = 8+(TRAND&7); + } + else sp->xrepeat = sp->yrepeat = 16+(TRAND&15); + + sp->shade = -16; + sp->cstat |= 128; + if(j >= 0) + { + if(sector[sprite[j].sectnum].lotag == 2) + { + sp->z = getceilzofslope(SECT,SX,SY)+(16<<8); + sp->cstat |= 8; + } + else if( sector[sprite[j].sectnum].lotag == 1) + sp->z = getflorzofslope(SECT,SX,SY); + } + + if(sector[sect].floorpicnum == FLOORSLIME || + sector[sect].ceilingpicnum == FLOORSLIME) + sp->pal = 7; + case NEON1__STATIC: + case NEON2__STATIC: + case NEON3__STATIC: + case NEON4__STATIC: + case NEON5__STATIC: + case NEON6__STATIC: + case DOMELITE__STATIC: + if(sp->picnum != WATERSPLASH2) + sp->cstat |= 257; + case NUKEBUTTON__STATIC: + if(sp->picnum == DOMELITE) + sp->cstat |= 257; + case JIBS1__STATIC: + case JIBS2__STATIC: + case JIBS3__STATIC: + case JIBS4__STATIC: + case JIBS5__STATIC: + case JIBS6__STATIC: + case HEADJIB1__STATIC: + case ARMJIB1__STATIC: + case LEGJIB1__STATIC: + case LIZMANHEAD1__STATIC: + case LIZMANARM1__STATIC: + case LIZMANLEG1__STATIC: + case DUKETORSO__STATIC: + case DUKEGUN__STATIC: + case DUKELEG__STATIC: + changespritestat(i,5); + break; + case TONGUE__STATIC: + if(j >= 0) + sp->ang = sprite[j].ang; + sp->z -= 38<<8; + sp->zvel = 256-(TRAND&511); + sp->xvel = 64-(TRAND&127); + changespritestat(i,4); + break; + case NATURALLIGHTNING__STATIC: + sp->cstat &= ~257; + sp->cstat |= 32768; + break; + case TRANSPORTERSTAR__STATIC: + case TRANSPORTERBEAM__STATIC: + if(j == -1) break; + if(sp->picnum == TRANSPORTERBEAM) + { + sp->xrepeat = 31; + sp->yrepeat = 1; + sp->z = sector[sprite[j].sectnum].floorz-(40<<8); + } + else + { + if(sprite[j].statnum == 4) + { + sp->xrepeat = 8; + sp->yrepeat = 8; + } + else + { + sp->xrepeat = 48; + sp->yrepeat = 64; + if(sprite[j].statnum == 10 || badguy(&sprite[j]) ) + sp->z -= (32<<8); + } + } + + sp->shade = -127; + sp->cstat = 128|2; + sp->ang = sprite[j].ang; + + sp->xvel = 128; + changespritestat(i,5); + ssp(i,CLIPMASK0); + setsprite(i,sp->x,sp->y,sp->z); + break; + + case FRAMEEFFECT1_13__STATIC: + if (PLUTOPAK) break; + case FRAMEEFFECT1__STATIC: + if(j >= 0) + { + sp->xrepeat = sprite[j].xrepeat; + sp->yrepeat = sprite[j].yrepeat; + T2 = sprite[j].picnum; + } + else sp->xrepeat = sp->yrepeat = 0; + + changespritestat(i,5); + + break; + + case LASERLINE__STATIC: + sp->yrepeat = 6; + sp->xrepeat = 32; + + if(lasermode == 1) + sp->cstat = 16 + 2; + else if(lasermode == 0 || lasermode == 2) + sp->cstat = 16; + else + { + sp->xrepeat = 0; + sp->yrepeat = 0; + } + + if(j >= 0) sp->ang = hittype[j].temp_data[5]+512; + changespritestat(i,5); + break; + + case FORCESPHERE__STATIC: + if(j == -1 ) + { + sp->cstat = (short) 32768; + changespritestat(i,2); + } + else + { + sp->xrepeat = sp->yrepeat = 1; + changespritestat(i,5); + } + break; + + case BLOOD__STATIC: + sp->xrepeat = sp->yrepeat = 16; + sp->z -= (26<<8); + if( j >= 0 && sprite[j].pal == 6 ) + sp->pal = 6; + changespritestat(i,5); + break; + case BLOODPOOL__STATIC: + case PUKE__STATIC: + { + short s1; + s1 = sp->sectnum; + + updatesector(sp->x+108,sp->y+108,&s1); + if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + { + updatesector(sp->x-108,sp->y-108,&s1); + if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + { + updatesector(sp->x+108,sp->y-108,&s1); + if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + { + updatesector(sp->x-108,sp->y+108,&s1); + if(s1 >= 0 && sector[s1].floorz != sector[sp->sectnum].floorz) + { sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;} + } + else { sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;} + } + else { sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;} + } + else { sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;} + } + + if( sector[SECT].lotag == 1 ) + { + changespritestat(i,5); + break; + } + + if(j >= 0 && sp->picnum != PUKE) + { + if( sprite[j].pal == 1) + sp->pal = 1; + else if( sprite[j].pal != 6 && sprite[j].picnum != NUKEBARREL && sprite[j].picnum != TIRE ) + { + if(sprite[j].picnum == FECES) + sp->pal = 7; // Brown + else sp->pal = 2; // Red + } + else sp->pal = 0; // green + + if(sprite[j].picnum == TIRE) + sp->shade = 127; + } + sp->cstat |= 32; + case FECES__STATIC: + if( j >= 0) + sp->xrepeat = sp->yrepeat = 1; + changespritestat(i,5); + break; + + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + sp->cstat |= 16; + sp->xrepeat = 7+(TRAND&7); + sp->yrepeat = 7+(TRAND&7); + sp->z -= (16<<8); + if(j >= 0 && sprite[j].pal == 6) + sp->pal = 6; + insertspriteq(i); + changespritestat(i,5); + break; + + case TRIPBOMB__STATIC: + if( sp->lotag > ud.player_skill ) + { + sp->xrepeat=sp->yrepeat=0; + changespritestat(i,5); + break; + } + + sp->xrepeat=4; + sp->yrepeat=5; + + sp->owner = i; + sp->hitag = i; + + sp->xvel = 16; + ssp(i,CLIPMASK0); + hittype[i].temp_data[0] = 17; + hittype[i].temp_data[2] = 0; + hittype[i].temp_data[5] = sp->ang; + + case SPACEMARINE__STATIC: + if(sp->picnum == SPACEMARINE) + { + sp->extra = 20; + sp->cstat |= 257; + } + changespritestat(i,2); + break; + + case HYDRENT__STATIC: + case PANNEL1__STATIC: + case PANNEL2__STATIC: + case SATELITE__STATIC: + case FUELPOD__STATIC: + case SOLARPANNEL__STATIC: + case ANTENNA__STATIC: + case GRATE1__STATIC: + case CHAIR1__STATIC: + case CHAIR2__STATIC: + case CHAIR3__STATIC: + case BOTTLE1__STATIC: + case BOTTLE2__STATIC: + case BOTTLE3__STATIC: + case BOTTLE4__STATIC: + case BOTTLE5__STATIC: + case BOTTLE6__STATIC: + case BOTTLE7__STATIC: + case BOTTLE8__STATIC: + case BOTTLE10__STATIC: + case BOTTLE11__STATIC: + case BOTTLE12__STATIC: + case BOTTLE13__STATIC: + case BOTTLE14__STATIC: + case BOTTLE15__STATIC: + case BOTTLE16__STATIC: + case BOTTLE17__STATIC: + case BOTTLE18__STATIC: + case BOTTLE19__STATIC: + case OCEANSPRITE1__STATIC: + case OCEANSPRITE2__STATIC: + case OCEANSPRITE3__STATIC: + case OCEANSPRITE5__STATIC: + case MONK__STATIC: + case INDY__STATIC: + case LUKE__STATIC: + case JURYGUY__STATIC: + case SCALE__STATIC: + case VACUUM__STATIC: + case FANSPRITE__STATIC: + case CACTUS__STATIC: + case CACTUSBROKE__STATIC: + case HANGLIGHT__STATIC: + case FETUS__STATIC: + case FETUSBROKE__STATIC: + case CAMERALIGHT__STATIC: + case MOVIECAMERA__STATIC: + case IVUNIT__STATIC: + case POT1__STATIC: + case POT2__STATIC: + case POT3__STATIC: + case TRIPODCAMERA__STATIC: + case SUSHIPLATE1__STATIC: + case SUSHIPLATE2__STATIC: + case SUSHIPLATE3__STATIC: + case SUSHIPLATE4__STATIC: + case SUSHIPLATE5__STATIC: + case WAITTOBESEATED__STATIC: + case VASE__STATIC: + case PIPE1__STATIC: + case PIPE2__STATIC: + case PIPE3__STATIC: + case PIPE4__STATIC: + case PIPE5__STATIC: + case PIPE6__STATIC: + sp->clipdist = 32; + sp->cstat |= 257; + case OCEANSPRITE4__STATIC: + changespritestat(i,0); + break; + case FEMMAG1__STATIC: + case FEMMAG2__STATIC: + sp->cstat &= ~257; + changespritestat(i,0); + break; + case DUKETAG__STATIC: + case SIGN1__STATIC: + case SIGN2__STATIC: + if(ud.multimode < 2 && sp->pal) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + } + else sp->pal = 0; + break; + case MASKWALL1__STATIC: + case MASKWALL2__STATIC: + case MASKWALL3__STATIC: + case MASKWALL4__STATIC: + case MASKWALL5__STATIC: + case MASKWALL6__STATIC: + case MASKWALL7__STATIC: + case MASKWALL8__STATIC: + case MASKWALL9__STATIC: + case MASKWALL10__STATIC: + case MASKWALL11__STATIC: + case MASKWALL12__STATIC: + case MASKWALL13__STATIC: + case MASKWALL14__STATIC: + case MASKWALL15__STATIC: + j = sp->cstat&60; + sp->cstat = j|1; + changespritestat(i,0); + break; + case FOOTPRINTS__STATIC: + case FOOTPRINTS2__STATIC: + case FOOTPRINTS3__STATIC: + case FOOTPRINTS4__STATIC: + if(j >= 0) + { + short s1; + s1 = sp->sectnum; + + updatesector(sp->x+84,sp->y+84,&s1); + if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + { + updatesector(sp->x-84,sp->y-84,&s1); + if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + { + updatesector(sp->x+84,sp->y-84,&s1); + if(s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + { + updatesector(sp->x-84,sp->y+84,&s1); + if(s1 >= 0 && sector[s1].floorz != sector[sp->sectnum].floorz) + { sp->xrepeat = sp->yrepeat = 0;changespritestat(i,5);break;} + } + else { sp->xrepeat = sp->yrepeat = 0;break;} + } + else { sp->xrepeat = sp->yrepeat = 0;break;} + } + else { sp->xrepeat = sp->yrepeat = 0;break;} + + sp->cstat = 32+((ps[sprite[j].yvel].footprintcount&1)<<2); + sp->ang = sprite[j].ang; + } + + sp->z = sector[sect].floorz; + if(sector[sect].lotag != 1 && sector[sect].lotag != 2) + sp->xrepeat = sp->yrepeat = 32; + + insertspriteq(i); + changespritestat(i,5); + break; + + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case PODFEM1__STATIC: + case NAKED1__STATIC: + case STATUE__STATIC: + case TOUGHGAL__STATIC: + sp->yvel = sp->hitag; + sp->hitag = -1; + if(sp->picnum == PODFEM1) sp->extra <<= 1; + case BLOODYPOLE__STATIC: + + case QUEBALL__STATIC: + case STRIPEBALL__STATIC: + + if(sp->picnum == QUEBALL || sp->picnum == STRIPEBALL) + { + sp->cstat = 256; + sp->clipdist = 8; + } + else + { + sp->cstat |= 257; + sp->clipdist = 32; + } + + changespritestat(i,2); + break; + + case DUKELYINGDEAD__STATIC: + if(j >= 0 && sprite[j].picnum == APLAYER) + { + sp->xrepeat = sprite[j].xrepeat; + sp->yrepeat = sprite[j].yrepeat; + sp->shade = sprite[j].shade; + sp->pal = ps[sprite[j].yvel].palookup; + } + case DUKECAR__STATIC: + case HELECOPT__STATIC: + // if(sp->picnum == HELECOPT || sp->picnum == DUKECAR) sp->xvel = 1024; + sp->cstat = 0; + sp->extra = 1; + sp->xvel = 292; + sp->zvel = 360; + case RESPAWNMARKERRED__STATIC: + case BLIMP__STATIC: + + if(sp->picnum == RESPAWNMARKERRED) + { + sp->xrepeat = sp->yrepeat = 24; + if(j >= 0) sp->z = hittype[j].floorz; // -(1<<4); + } + else + { + sp->cstat |= 257; + sp->clipdist = 128; + } + case MIKE__STATIC: + if(sp->picnum == MIKE) + { + sp->yvel = sp->hitag; + sp->hitag = 0; + } + case WEATHERWARN__STATIC: + changespritestat(i,1); + break; + + case SPOTLITE__STATIC: + T1 = sp->x; + T2 = sp->y; + break; + case BULLETHOLE__STATIC: + sp->xrepeat = sp->yrepeat = 3; + sp->cstat = 16+(krand()&12); + insertspriteq(i); + case MONEY__STATIC: + case MAIL__STATIC: + case PAPER__STATIC: + if( sp->picnum == MONEY || sp->picnum == MAIL || sp->picnum == PAPER ) + { + hittype[i].temp_data[0] = TRAND&2047; + sp->cstat = TRAND&12; + sp->xrepeat = sp->yrepeat = 8; + sp->ang = TRAND&2047; + } + changespritestat(i,5); + break; + + case VIEWSCREEN__STATIC: + case VIEWSCREEN2__STATIC: + sp->owner = i; + sp->lotag = 1; + sp->extra = 1; + changespritestat(i,6); + break; + + case SHELL__STATIC: //From the player + case SHOTGUNSHELL__STATIC: + if( j >= 0 ) + { + short snum,a; + + if(sprite[j].picnum == APLAYER) + { + snum = sprite[j].yvel; + a = ps[snum].ang-(TRAND&63)+8; //Fine tune + + T1 = TRAND&1; + if(sp->picnum == SHOTGUNSHELL) + sp->z = (6<<8)+ps[snum].pyoff+ps[snum].posz-((ps[snum].horizoff+ps[snum].horiz-100)<<4); + else sp->z = (3<<8)+ps[snum].pyoff+ps[snum].posz-((ps[snum].horizoff+ps[snum].horiz-100)<<4); + sp->zvel = -(TRAND&255); + } + else + { + a = sp->ang; + sp->z = sprite[j].z-PHEIGHT+(3<<8); + } + + sp->x = sprite[j].x+(sintable[(a+512)&2047]>>7); + sp->y = sprite[j].y+(sintable[a&2047]>>7); + + sp->shade = -8; + + if (sp->yvel == 1) + { + sp->ang = a+512; + sp->xvel = 30; + } + else + { + sp->ang = a-512; + sp->xvel = 20; + } + sp->xrepeat=sp->yrepeat=4; + + changespritestat(i,5); + } + break; + + case RESPAWN__STATIC: + sp->extra = 66-13; + case MUSICANDSFX__STATIC: + if( ud.multimode < 2 && sp->pal == 1) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + sp->cstat = (short)32768; + changespritestat(i,11); + break; + + case EXPLOSION2__STATIC: + case EXPLOSION2BOT__STATIC: + case BURNING__STATIC: + case BURNING2__STATIC: + case SMALLSMOKE__STATIC: + case SHRINKEREXPLOSION__STATIC: + case COOLEXPLOSION1__STATIC: + + if(j >= 0) + { + sp->ang = sprite[j].ang; + sp->shade = -64; + sp->cstat = 128|(TRAND&4); + } + + if(sp->picnum == EXPLOSION2 || sp->picnum == EXPLOSION2BOT) + { + sp->xrepeat = 48; + sp->yrepeat = 48; + sp->shade = -127; + sp->cstat |= 128; + } + else if(sp->picnum == SHRINKEREXPLOSION ) + { + sp->xrepeat = 32; + sp->yrepeat = 32; + } + else if( sp->picnum == SMALLSMOKE ) + { + // 64 "money" + sp->xrepeat = 24; + sp->yrepeat = 24; + } + else if(sp->picnum == BURNING || sp->picnum == BURNING2) + { + sp->xrepeat = 4; + sp->yrepeat = 4; + } + + if(j >= 0) + { + x = getflorzofslope(sp->sectnum,sp->x,sp->y); + if(sp->z > x-(12<<8) ) + sp->z = x-(12<<8); + } + + changespritestat(i,5); + + break; + + case PLAYERONWATER__STATIC: + if(j >= 0) + { + sp->xrepeat = sprite[j].xrepeat; + sp->yrepeat = sprite[j].yrepeat; + sp->zvel = 128; + if(sector[sp->sectnum].lotag != 2) + sp->cstat |= 32768; + } + changespritestat(i,13); + break; + + case APLAYER__STATIC: + sp->xrepeat = sp->yrepeat = 0; + //j = ud.coop; + //if(j == 2) j = 0; + j=(gametype_flags[ud.coop] & GAMETYPE_FLAG_COOPSPAWN ) / GAMETYPE_FLAG_COOPSPAWN ; + if( ud.multimode < 2 || (ud.multimode > 1 && j != sp->lotag) ) + changespritestat(i,5); + else + changespritestat(i,10); + break; + case WATERBUBBLE__STATIC: + if(j >= 0 && sprite[j].picnum == APLAYER) + sp->z -= (16<<8); + if( sp->picnum == WATERBUBBLE) + { + if( j >= 0 ) + sp->ang = sprite[j].ang; + sp->xrepeat = sp->yrepeat = 4; + } + else sp->xrepeat = sp->yrepeat = 32; + + changespritestat(i,5); + break; + + case CRANE__STATIC: + + sp->cstat |= 64|257; + + sp->picnum += 2; + sp->z = sector[sect].ceilingz+(48<<8); + T5 = tempwallptr; + + msx[tempwallptr] = sp->x; + msy[tempwallptr] = sp->y; + msx[tempwallptr+2] = sp->z; + + s = headspritestat[0]; + while(s >= 0) + { + if( sprite[s].picnum == CRANEPOLE && SHT == (sprite[s].hitag) ) + { + msy[tempwallptr+2] = s; + + T2 = sprite[s].sectnum; + + sprite[s].xrepeat = 48; + sprite[s].yrepeat = 128; + + msx[tempwallptr+1] = sprite[s].x; + msy[tempwallptr+1] = sprite[s].y; + + sprite[s].x = sp->x; + sprite[s].y = sp->y; + sprite[s].z = sp->z; + sprite[s].shade = sp->shade; + + setsprite(s,sprite[s].x,sprite[s].y,sprite[s].z); + break; + } + s = nextspritestat[s]; + } + + tempwallptr += 3; + sp->owner = -1; + sp->extra = 8; + changespritestat(i,6); + break; + + case WATERDRIP__STATIC: + if((j >= 0 && sprite[j].statnum == 10) || sprite[j].statnum == 1) + { + sp->shade = 32; + if(sprite[j].pal != 1) + { + sp->pal = 2; + sp->z -= (18<<8); + } + else sp->z -= (13<<8); + sp->ang = getangle(ps[connecthead].posx-sp->x,ps[connecthead].posy-sp->y); + sp->xvel = 48-(TRAND&31); + ssp(i,CLIPMASK0); + } + else if(j == -1) + { + sp->z += (4<<8); + T1 = sp->z; + T2 = TRAND&127; + } + case TRASH__STATIC: + + if(sp->picnum != WATERDRIP) + sp->ang = TRAND&2047; + + case WATERDRIPSPLASH__STATIC: + + sp->xrepeat = 24; + sp->yrepeat = 24; + + + changespritestat(i,6); + break; + + case PLUG__STATIC: + sp->lotag = 9999; + changespritestat(i,6); + break; + case TOUCHPLATE__STATIC: + T3 = sector[sect].floorz; + if(sector[sect].lotag != 1 && sector[sect].lotag != 2) + sector[sect].floorz = sp->z; + if(sp->pal && ud.multimode > 1) + { + sp->xrepeat=sp->yrepeat=0; + changespritestat(i,5); + break; + } + case WATERBUBBLEMAKER__STATIC: + if (sp->hitag && sp->picnum == WATERBUBBLEMAKER) { // JBF 20030913: Pisses off move(), eg. in bobsp2 + OSD_Printf("WARNING: WATERBUBBLEMAKER %d @ %d,%d with hitag!=0. Applying fixup.\n", + i,sp->x,sp->y); + sp->hitag = 0; + } + sp->cstat |= 32768; + changespritestat(i,6); + break; + //case BOLT1: + //case BOLT1+1: + //case BOLT1+2: + //case BOLT1+3: + //case SIDEBOLT1: + //case SIDEBOLT1+1: + //case SIDEBOLT1+2: + //case SIDEBOLT1+3: + // T1 = sp->xrepeat; + // T2 = sp->yrepeat; + case MASTERSWITCH__STATIC: + if(sp->picnum == MASTERSWITCH) + sp->cstat |= 32768; + sp->yvel = 0; + changespritestat(i,6); + break; + case TARGET__STATIC: + case DUCK__STATIC: + case LETTER__STATIC: + sp->extra = 1; + sp->cstat |= 257; + changespritestat(i,1); + break; + case OCTABRAINSTAYPUT__STATIC: + case LIZTROOPSTAYPUT__STATIC: + case PIGCOPSTAYPUT__STATIC: + case LIZMANSTAYPUT__STATIC: + case BOSS1STAYPUT__STATIC: + case PIGCOPDIVE__STATIC: + case COMMANDERSTAYPUT__STATIC: + case BOSS4STAYPUT__STATIC: + hittype[i].actorstayput = sp->sectnum; + case BOSS1__STATIC: + case BOSS2__STATIC: + case BOSS3__STATIC: + case BOSS4__STATIC: + case ROTATEGUN__STATIC: + case GREENSLIME__STATIC: + if(sp->picnum == GREENSLIME) + sp->extra = 1; + case DRONE__STATIC: + case LIZTROOPONTOILET__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOP__STATIC: + case OCTABRAIN__STATIC: + case COMMANDER__STATIC: + case PIGCOP__STATIC: + case LIZMAN__STATIC: + case LIZMANSPITTING__STATIC: + case LIZMANFEEDING__STATIC: + case LIZMANJUMP__STATIC: + case ORGANTIC__STATIC: + case RAT__STATIC: + case SHARK__STATIC: + + if(sp->pal == 0) + { + switch(dynamictostatic[sp->picnum]) + { + case LIZTROOPONTOILET__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOPSTAYPUT__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOP__STATIC: + sp->pal = 22; + break; + } + } + + if( sp->picnum == BOSS4STAYPUT || sp->picnum == BOSS1 || sp->picnum == BOSS2 || sp->picnum == BOSS1STAYPUT || sp->picnum == BOSS3 || sp->picnum == BOSS4 ) + { + if(j >= 0 && sprite[j].picnum == RESPAWN) + sp->pal = sprite[j].pal; + if(sp->pal) + { + sp->clipdist = 80; + sp->xrepeat = 40; + sp->yrepeat = 40; + } + else + { + sp->xrepeat = 80; + sp->yrepeat = 80; + sp->clipdist = 164; + } + } + else + { + if(sp->picnum != SHARK) + { + sp->xrepeat = 40; + sp->yrepeat = 40; + sp->clipdist = 80; + } + else + { + sp->xrepeat = 60; + sp->yrepeat = 60; + sp->clipdist = 40; + } + } + + if(j >= 0) sp->lotag = 0; + + if( ( sp->lotag > ud.player_skill ) || ud.monsters_off == 1 ) + { + sp->xrepeat=sp->yrepeat=0; + changespritestat(i,5); + break; + } + else + { + makeitfall(i); + + if(sp->picnum == RAT) + { + sp->ang = TRAND&2047; + sp->xrepeat = sp->yrepeat = 48; + sp->cstat = 0; + } + else + { + sp->cstat |= 257; + + if(sp->picnum != SHARK) + ps[myconnectindex].max_actors_killed++; + } + + if(sp->picnum == ORGANTIC) sp->cstat |= 128; + + if(j >= 0) + { + hittype[i].timetosleep = 0; + check_fta_sounds(i); + changespritestat(i,1); + } + else changespritestat(i,2); + } + + if(sp->picnum == ROTATEGUN) + sp->zvel = 0; + + break; + + case LOCATORS__STATIC: + sp->cstat |= 32768; + changespritestat(i,7); + break; + + case ACTIVATORLOCKED__STATIC: + case ACTIVATOR__STATIC: + sp->cstat = (short) 32768; + if(sp->picnum == ACTIVATORLOCKED) + sector[sp->sectnum].lotag |= 16384; + changespritestat(i,8); + break; + + case DOORSHOCK__STATIC: + sp->cstat |= 1+256; + sp->shade = -12; + changespritestat(i,6); + break; + + case OOZ__STATIC: + case OOZ2__STATIC: + sp->shade = -12; + + if(j >= 0) + { + if( sprite[j].picnum == NUKEBARREL ) + sp->pal = 8; + insertspriteq(i); + } + + changespritestat(i,1); + + getglobalz(i); + + j = (hittype[i].floorz-hittype[i].ceilingz)>>9; + + sp->yrepeat = j; + sp->xrepeat = 25-(j>>1); + sp->cstat |= (TRAND&4); + + break; + + case HEAVYHBOMB__STATIC: + if(j >= 0) + sp->owner = j; + else sp->owner = i; + sp->xrepeat = sp->yrepeat = 9; + sp->yvel = 4; + case REACTOR2__STATIC: + case REACTOR__STATIC: + case RECON__STATIC: + + if(sp->picnum == RECON) + { + if( sp->lotag > ud.player_skill ) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + return i; + } + ps[myconnectindex].max_actors_killed++; + hittype[i].temp_data[5] = 0; + if(ud.monsters_off == 1) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + sp->extra = 130; + } + + if(sp->picnum == REACTOR || sp->picnum == REACTOR2) + sp->extra = impact_damage; + + CS |= 257; // Make it hitable + + if( ud.multimode < 2 && sp->pal != 0) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + sp->pal = 0; + SS = -17; + + changespritestat(i,2); + break; + + case ATOMICHEALTH__STATIC: + case STEROIDS__STATIC: + case HEATSENSOR__STATIC: + case SHIELD__STATIC: + case AIRTANK__STATIC: + case TRIPBOMBSPRITE__STATIC: + case JETPACK__STATIC: + case HOLODUKE__STATIC: + + case FIRSTGUNSPRITE__STATIC: + case CHAINGUNSPRITE__STATIC: + case SHOTGUNSPRITE__STATIC: + case RPGSPRITE__STATIC: + case SHRINKERSPRITE__STATIC: + case FREEZESPRITE__STATIC: + case DEVISTATORSPRITE__STATIC: + + case SHOTGUNAMMO__STATIC: + case FREEZEAMMO__STATIC: + case HBOMBAMMO__STATIC: + case CRYSTALAMMO__STATIC: + case GROWAMMO__STATIC: + case BATTERYAMMO__STATIC: + case DEVISTATORAMMO__STATIC: + case RPGAMMO__STATIC: + case BOOTS__STATIC: + case AMMO__STATIC: + case AMMOLOTS__STATIC: + case COLA__STATIC: + case FIRSTAID__STATIC: + case SIXPAK__STATIC: + + if(j >= 0) + { + sp->lotag = 0; + sp->z -= (32<<8); + sp->zvel = -1024; + ssp(i,CLIPMASK0); + sp->cstat = TRAND&4; + } + else + { + sp->owner = i; + sp->cstat = 0; + } + + if( ( ud.multimode < 2 && sp->pal != 0) || (sp->lotag > ud.player_skill) ) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + + sp->pal = 0; + + case ACCESSCARD__STATIC: + + if(sp->picnum == ATOMICHEALTH) + sp->cstat |= 128; + + if(ud.multimode > 1 && !(gametype_flags[ud.coop]&GAMETYPE_FLAG_ACCESSCARDSPRITES) && sp->picnum == ACCESSCARD) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + else + { + if(sp->picnum == AMMO) + sp->xrepeat = sp->yrepeat = 16; + else sp->xrepeat = sp->yrepeat = 32; + } + + sp->shade = -17; + + if(j >= 0) changespritestat(i,1); + else + { + changespritestat(i,2); + makeitfall(i); + } + break; + + case WATERFOUNTAIN__STATIC: + SLT = 1; + + case TREE1__STATIC: + case TREE2__STATIC: + case TIRE__STATIC: + case CONE__STATIC: + case BOX__STATIC: + CS = 257; // Make it hitable + sprite[i].extra = 1; + changespritestat(i,6); + break; + + case FLOORFLAME__STATIC: + sp->shade = -127; + changespritestat(i,6); + break; + + case BOUNCEMINE__STATIC: + sp->owner = i; + sp->cstat |= 1+256; //Make it hitable + sp->xrepeat = sp->yrepeat = 24; + sp->shade = -127; + sp->extra = impact_damage<<2; + changespritestat(i,2); + break; + + + + case STEAM__STATIC: + if(j >= 0) + { + sp->ang = sprite[j].ang; + sp->cstat = 16+128+2; + sp->xrepeat=sp->yrepeat=1; + sp->xvel = -8; + ssp(i,CLIPMASK0); + } + case CEILINGSTEAM__STATIC: + changespritestat(i,6); + break; + + case SECTOREFFECTOR__STATIC: + sp->yvel = sector[sect].extra; + sp->cstat |= 32768; + sp->xrepeat = sp->yrepeat = 0; + + switch(sp->lotag) + { + case 28: + T6 = 65;// Delay for lightning + break; + case 7: // Transporters!!!! + case 23:// XPTR END + if(sp->lotag != 23) + { + for(j=0;jcstat = 0; + changespritestat(i,9); + return i; + case 1: + sp->owner = -1; + T1 = 1; + break; + case 18: + + if(sp->ang == 512) + { + T2 = sector[sect].ceilingz; + if(sp->pal) + sector[sect].ceilingz = sp->z; + } + else + { + T2 = sector[sect].floorz; + if(sp->pal) + sector[sect].floorz = sp->z; + } + + sp->hitag <<= 2; + break; + + case 19: + sp->owner = -1; + break; + case 25: // Pistons + T4 = sector[sect].ceilingz; + T5 = 1; + sector[sect].ceilingz = sp->z; + setinterpolation(§or[sect].ceilingz); + break; + case 35: + sector[sect].ceilingz = sp->z; + break; + case 27: + if(ud.recstat == 1) + { + sp->xrepeat=sp->yrepeat=64; + sp->cstat &= 32767; + } + break; + case 12: + + T2 = sector[sect].floorshade; + T3 = sector[sect].ceilingshade; + break; + + case 13: + + T1 = sector[sect].ceilingz; + T2 = sector[sect].floorz; + + if( klabs(T1-sp->z) < klabs(T2-sp->z) ) + sp->owner = 1; + else sp->owner = 0; + + if(sp->ang == 512) + { + if(sp->owner) + sector[sect].ceilingz = sp->z; + else + sector[sect].floorz = sp->z; + } + else + sector[sect].ceilingz = sector[sect].floorz = sp->z; + + if( sector[sect].ceilingstat&1 ) + { + sector[sect].ceilingstat ^= 1; + T4 = 1; + + if(!sp->owner && sp->ang==512) + { + sector[sect].ceilingstat ^= 1; + T4 = 0; + } + + sector[sect].ceilingshade = + sector[sect].floorshade; + + if(sp->ang==512) + { + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + for(j=startwall;j= 0) + if( !(sector[x].ceilingstat&1) ) + { + sector[sect].ceilingpicnum = + sector[x].ceilingpicnum; + sector[sect].ceilingshade = + sector[x].ceilingshade; + break; //Leave earily + } + } + } + } + + break; + + case 17: + + T3 = sector[sect].floorz; //Stopping loc + + j = nextsectorneighborz(sect,sector[sect].floorz,-1,-1); + T4 = sector[j].ceilingz; + + j = nextsectorneighborz(sect,sector[sect].ceilingz,1,1); + T5 = sector[j].floorz; + + if(numplayers < 2) + { + setinterpolation(§or[sect].floorz); + setinterpolation(§or[sect].ceilingz); + } + + break; + + case 24: + sp->yvel <<= 1; + case 36: + break; + + case 20: + { + long q; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + //find the two most clostest wall x's and y's + q = 0x7fffffff; + + for(s=startwall;sx-x,sp->y-y); + if( d < q ) + { + q = d; + clostest = s; + } + } + + T2 = clostest; + + q = 0x7fffffff; + + for(s=startwall;sx-x,sp->y-y); + if(d < q && s != T2) + { + q = d; + clostest = s; + } + } + + T3 = clostest; + } + + break; + + case 3: + + T4=sector[sect].floorshade; + + sector[sect].floorshade = sp->shade; + sector[sect].ceilingshade = sp->shade; + + sp->owner = sector[sect].ceilingpal<<8; + sp->owner |= sector[sect].floorpal; + + //fix all the walls; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + for(s=startwall;sshade; + if( (wall[s].cstat&2) && wall[s].nextwall >= 0) + wall[wall[s].nextwall].shade = sp->shade; + } + break; + + case 31: + T2 = sector[sect].floorz; + // T3 = sp->hitag; + if(sp->ang != 1536) sector[sect].floorz = sp->z; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + for(s=startwall;shitag; + if(sp->ang != 1536) sector[sect].ceilingz = sp->z; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + for(s=startwall;sowner = sector[sect].ceilingpal<<8; + sp->owner |= sector[sect].floorpal; + + for(s=startwall;s T4) + T4 = wall[s].shade; + + break; + + case 9: + if( sector[sect].lotag && + labs(sector[sect].ceilingz-sp->z) > 1024) + sector[sect].lotag |= 32768; //If its open + case 8: + //First, get the ceiling-floor shade + + T1 = sector[sect].floorshade; + T2 = sector[sect].ceilingshade; + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + for(s=startwall;s T3) + T3 = wall[s].shade; + + T4 = 1; //Take Out; + + break; + + case 11://Pivitor rotater + if(sp->ang>1024) T4 = 2; + else T4 = -2; + case 0: + case 2://Earthquakemakers + case 5://Boss Creature + case 6://Subway + case 14://Caboos + case 15://Subwaytype sliding door + case 16://That rotating blocker reactor thing + case 26://ESCELATOR + case 30://No rotational subways + + if(sp->lotag == 0) + { + if( sector[sect].lotag == 30 ) + { + if(sp->pal) sprite[i].clipdist = 1; + else sprite[i].clipdist = 0; + T4 = sector[sect].floorz; + sector[sect].hitag = i; + } + + for(j = 0;j < MAXSPRITES;j++) + { + if( sprite[j].statnum < MAXSTATUS ) + if( sprite[j].picnum == SECTOREFFECTOR && + sprite[j].lotag == 1 && + sprite[j].hitag == sp->hitag) + { + if( sp->ang == 512 ) + { + sp->x = sprite[j].x; + sp->y = sprite[j].y; + } + break; + } + } + if(j == MAXSPRITES) + { + Bsprintf(tempbuf,"Found lonely Sector Effector (lotag 0) at (%ld,%ld)\n",sp->x,sp->y); + gameexit(tempbuf); + } + sp->owner = j; + } + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + T2 = tempwallptr; + for(s=startwall;sx; + msy[tempwallptr] = wall[s].y-sp->y; + tempwallptr++; + if(tempwallptr > 2047) + { + Bsprintf(tempbuf,"Too many moving sectors at (%ld,%ld).\n",wall[s].x,wall[s].y); + gameexit(tempbuf); + } + } + if( sp->lotag == 30 || sp->lotag == 6 || sp->lotag == 14 || sp->lotag == 5 ) + { + + startwall = sector[sect].wallptr; + endwall = startwall+sector[sect].wallnum; + + if(sector[sect].hitag == -1) + sp->extra = 0; + else sp->extra = 1; + + sector[sect].hitag = i; + + j = 0; + + for(s=startwall;s= 0 && + sector[ wall[ s ].nextsector].hitag == 0 && + sector[ wall[ s ].nextsector].lotag < 3 ) + { + s = wall[s].nextsector; + j = 1; + break; + } + } + + if(j == 0) + { + Bsprintf(tempbuf,"Subway found no zero'd sectors with locators\nat (%ld,%ld).\n",sp->x,sp->y); + gameexit(tempbuf); + } + + sp->owner = -1; + T1 = s; + + if(sp->lotag != 30) + T4 = sp->hitag; + } + + else if(sp->lotag == 16) + T4 = sector[sect].ceilingz; + + else if( sp->lotag == 26 ) + { + T4 = sp->x; + T5 = sp->y; + if(sp->shade==sector[sect].floorshade) //UP + sp->zvel = -256; + else + sp->zvel = 256; + + sp->shade = 0; + } + else if( sp->lotag == 2) + { + T6 = sector[sp->sectnum].floorheinum; + sector[sp->sectnum].floorheinum = 0; + } + } + + switch(sp->lotag) + { + case 6: + case 14: + j = callsound(sect,i); + if(j == -1) j = SUBWAY; + hittype[i].lastvx = j; + case 30: + if(numplayers > 1) break; + case 0: + case 1: + case 5: + case 11: + case 15: + case 16: + case 26: + setsectinterpolate(i); + break; + } + + switch(sprite[i].lotag) + { + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + changespritestat(i,15); + break; + default: + changespritestat(i,3); + break; + } + + break; + + + case SEENINE__STATIC: + case OOZFILTER__STATIC: + + sp->shade = -16; + if(sp->xrepeat <= 8) + { + sp->cstat = (short)32768; + sp->xrepeat=sp->yrepeat=0; + } + else sp->cstat = 1+256; + sp->extra = impact_damage<<2; + sp->owner = i; + + changespritestat(i,6); + break; + + case CRACK1__STATIC: + case CRACK2__STATIC: + case CRACK3__STATIC: + case CRACK4__STATIC: + case FIREEXT__STATIC: + if(sp->picnum == FIREEXT) + { + sp->cstat = 257; + sp->extra = impact_damage<<2; + } + else + { + sp->cstat |= (sp->cstat & 48) ? 1 : 17; + sp->extra = 1; + } + + if( ud.multimode < 2 && sp->pal != 0) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + break; + } + + sp->pal = 0; + sp->owner = i; + changespritestat(i,6); + sp->xvel = 8; + ssp(i,CLIPMASK0); + break; + + case TOILET__STATIC: + case STALL__STATIC: + sp->lotag = 1; + sp->cstat |= 257; + sp->clipdist = 8; + sp->owner = i; + break; + case CANWITHSOMETHING__STATIC: + case CANWITHSOMETHING2__STATIC: + case CANWITHSOMETHING3__STATIC: + case CANWITHSOMETHING4__STATIC: + case RUBBERCAN__STATIC: + sp->extra = 0; + case EXPLODINGBARREL__STATIC: + case HORSEONSIDE__STATIC: + case FIREBARREL__STATIC: + case NUKEBARREL__STATIC: + case FIREVASE__STATIC: + case NUKEBARRELDENTED__STATIC: + case NUKEBARRELLEAKED__STATIC: + case WOODENHORSE__STATIC: + + if(j >= 0) + sp->xrepeat = sp->yrepeat = 32; + sp->clipdist = 72; + makeitfall(i); + if(j >= 0) + sp->owner = j; + else sp->owner = i; + case EGG__STATIC: + if( ud.monsters_off == 1 && sp->picnum == EGG ) + { + sp->xrepeat = sp->yrepeat = 0; + changespritestat(i,5); + } + else + { + if(sp->picnum == EGG) + sp->clipdist = 24; + sp->cstat = 257|(TRAND&4); + changespritestat(i,2); + } + break; + case TOILETWATER__STATIC: + sp->shade = -16; + changespritestat(i,6); + break; + } + + OnEvent(EVENT_SPAWN,i, findplayer(&sprite[i],&p), p); + return i; +} + +#ifdef _MSC_VER +// Visual C thought this was a bit too hard to optimise so we'd better +// tell it not to try... such a pussy it is. +//#pragma auto_inline( off ) +#pragma optimize("g",off) +#endif +void animatesprites(long x,long y,short a,long smoothratio) +{ + short i, j, k, p, sect; + long l, t1,t3,t4; + spritetype *s,*t; + int switchpic; + + for(j=0;j < spritesortcnt; j++) + { + t = &tsprite[j]; + i = t->owner; + s = &sprite[t->owner]; + //greenslime can't be handled through the dynamictostatic system due to addition on constant + if ((t->picnum >= GREENSLIME)&&(t->picnum <= GREENSLIME+7)) { + } else switch(dynamictostatic[t->picnum]) + { + case BLOODPOOL__STATIC: + case PUKE__STATIC: + case FOOTPRINTS__STATIC: + case FOOTPRINTS2__STATIC: + case FOOTPRINTS3__STATIC: + case FOOTPRINTS4__STATIC: + if(t->shade == 127) continue; + break; + case RESPAWNMARKERRED__STATIC: + case RESPAWNMARKERYELLOW__STATIC: + case RESPAWNMARKERGREEN__STATIC: + if(ud.marker == 0) + t->xrepeat = t->yrepeat = 0; + continue; + case CHAIR3__STATIC: + if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) { + t->cstat &= ~4; + break; + } + + k = (((t->ang+3072+128-a)&2047)>>8)&7; + if(k>4) + { + k = 8-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + t->picnum = s->picnum+k; + break; + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + if(ud.lockout) t->xrepeat = t->yrepeat = 0; + else if(t->pal == 6) + { + t->shade = -127; + continue; + } + case BULLETHOLE__STATIC: + case CRACK1__STATIC: + case CRACK2__STATIC: + case CRACK3__STATIC: + case CRACK4__STATIC: + t->shade = 16; + continue; + case NEON1__STATIC: + case NEON2__STATIC: + case NEON3__STATIC: + case NEON4__STATIC: + case NEON5__STATIC: + case NEON6__STATIC: + continue; + //case GREENSLIME: + //case GREENSLIME+1: + //case GREENSLIME+2: + //case GREENSLIME+3: + //case GREENSLIME+4: + //case GREENSLIME+5: + //case GREENSLIME+6: + //case GREENSLIME+7: + // break; + default: + if( ( (t->cstat&16) ) || ( badguy(t) && t->extra > 0) || t->statnum == 10) + continue; + } + + if (checkspriteflags(i,SPRITE_FLAG_NOSHADE)) + l = sprite[j].shade; + else + { + if (sector[t->sectnum].ceilingstat&1) + l = sector[t->sectnum].ceilingshade; + else + l = sector[t->sectnum].floorshade; + if(l < -127) l = -127; + if(l > 128) l = 127; + } + t->shade = l; + } + + + for(j=0;j < spritesortcnt; j++ ) //Between drawrooms() and drawmasks() + { //is the perfect time to animate sprites + t = &tsprite[j]; + i = t->owner; + s = &sprite[i]; + + switch(dynamictostatic[s->picnum]) + { + case SECTOREFFECTOR__STATIC: + if(t->lotag == 27 && ud.recstat == 1) + { + t->picnum = 11+((totalclock>>3)&1); + t->cstat |= 128; + } + else + t->xrepeat = t->yrepeat = 0; + break; + case NATURALLIGHTNING__STATIC: + t->shade = -127; + break; + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case MAN__STATIC: + case MAN2__STATIC: + case WOMAN__STATIC: + case NAKED1__STATIC: + case PODFEM1__STATIC: + case FEMMAG1__STATIC: + case FEMMAG2__STATIC: + case FEMPIC1__STATIC: + case FEMPIC2__STATIC: + case FEMPIC3__STATIC: + case FEMPIC4__STATIC: + case FEMPIC5__STATIC: + case FEMPIC6__STATIC: + case FEMPIC7__STATIC: + case BLOODYPOLE__STATIC: + case FEM6PAD__STATIC: + case STATUE__STATIC: + case STATUEFLASH__STATIC: + case OOZ__STATIC: + case OOZ2__STATIC: + case WALLBLOOD1__STATIC: + case WALLBLOOD2__STATIC: + case WALLBLOOD3__STATIC: + case WALLBLOOD4__STATIC: + case WALLBLOOD5__STATIC: + case WALLBLOOD7__STATIC: + case WALLBLOOD8__STATIC: + case SUSHIPLATE1__STATIC: + case SUSHIPLATE2__STATIC: + case SUSHIPLATE3__STATIC: + case SUSHIPLATE4__STATIC: + case FETUS__STATIC: + case FETUSJIB__STATIC: + case FETUSBROKE__STATIC: + case HOTMEAT__STATIC: + case FOODOBJECT16__STATIC: + case DOLPHIN1__STATIC: + case DOLPHIN2__STATIC: + case TOUGHGAL__STATIC: + case TAMPON__STATIC: + case XXXSTACY__STATIC: + if(ud.lockout) + { + t->xrepeat = t->yrepeat = 0; + continue; + } + } + switch(s->picnum) + { + + case 4946: + case 4947: + case 693: + case 2254: + case 4560: + case 4561: + case 4562: + case 4498: + case 4957: + if(ud.lockout) + { + t->xrepeat = t->yrepeat = 0; + continue; + } + } + + if( t->statnum == 99 ) continue; + if( s->statnum != 1 && s->picnum == APLAYER && ps[s->yvel].newowner == -1 && s->owner >= 0 ) + { + t->x -= mulscale16(65536-smoothratio,ps[s->yvel].posx-ps[s->yvel].oposx); + t->y -= mulscale16(65536-smoothratio,ps[s->yvel].posy-ps[s->yvel].oposy); + t->z = ps[s->yvel].oposz + mulscale16(smoothratio,ps[s->yvel].posz-ps[s->yvel].oposz); + t->z += (40<<8); + } + else if( ( s->statnum == 0 && s->picnum != CRANEPOLE) || s->statnum == 10 || s->statnum == 6 || s->statnum == 4 || s->statnum == 5 || s->statnum == 1 ) + { + t->x -= mulscale16(65536-smoothratio,s->x-hittype[i].bposx); + t->y -= mulscale16(65536-smoothratio,s->y-hittype[i].bposy); + t->z -= mulscale16(65536-smoothratio,s->z-hittype[i].bposz); + } + + sect = s->sectnum; + t1 = T2;t3 = T4;t4 = T5; + switchpic = s->picnum; + //some special cases because dynamictostatic system can't handle addition to constants + if ((s->picnum >= SCRAP6)&&(s->picnum<=SCRAP6+7)) + switchpic = SCRAP5; + else if ((s->picnum==MONEY+1)||(s->picnum==MAIL+1)||(s->picnum==PAPER+1)) + switchpic--; + + switch(dynamictostatic[switchpic]) + { + case DUKELYINGDEAD__STATIC: + t->z += (24<<8); + break; + case BLOODPOOL__STATIC: + case FOOTPRINTS__STATIC: + case FOOTPRINTS2__STATIC: + case FOOTPRINTS3__STATIC: + case FOOTPRINTS4__STATIC: + if(t->pal == 6) + t->shade = -127; + case PUKE__STATIC: + case MONEY__STATIC: + //case MONEY+1__STATIC: + case MAIL__STATIC: + //case MAIL+1__STATIC: + case PAPER__STATIC: + //case PAPER+1__STATIC: + if(ud.lockout && s->pal == 2) + { + t->xrepeat = t->yrepeat = 0; + continue; + } + break; + case TRIPBOMB__STATIC: + continue; + case FORCESPHERE__STATIC: + if(t->statnum == 5) + { + short sqa,sqb; + + sqa = + getangle( + sprite[s->owner].x-ps[screenpeek].posx, + sprite[s->owner].y-ps[screenpeek].posy); + sqb = + getangle( + sprite[s->owner].x-t->x, + sprite[s->owner].y-t->y); + + if( klabs(getincangle(sqa,sqb)) > 512 ) + if( ldist(&sprite[s->owner],t) < ldist(&sprite[ps[screenpeek].i],&sprite[s->owner]) ) + t->xrepeat = t->yrepeat = 0; + } + continue; + case BURNING__STATIC: + case BURNING2__STATIC: + if( sprite[s->owner].statnum == 10 ) + { + if( display_mirror == 0 && sprite[s->owner].yvel == screenpeek && ps[sprite[s->owner].yvel].over_shoulder_on == 0 ) + t->xrepeat = 0; + else + { + t->ang = getangle(x-t->x,y-t->y); + t->x = sprite[s->owner].x; + t->y = sprite[s->owner].y; + t->x += sintable[(t->ang+512)&2047]>>10; + t->y += sintable[t->ang&2047]>>10; + } + } + break; + + case ATOMICHEALTH__STATIC: + t->z -= (4<<8); + break; + case CRYSTALAMMO__STATIC: + t->shade = (sintable[(totalclock<<4)&2047]>>10); + continue; + case VIEWSCREEN__STATIC: + case VIEWSCREEN2__STATIC: + if(camsprite >= 0 && hittype[OW].temp_data[0] == 1) + { + t->picnum = STATIC; + t->cstat |= (rand()&12); + t->xrepeat += 8; + t->yrepeat += 8; + } else if (camsprite >= 0 && waloff[TILE_VIEWSCR] && walock[TILE_VIEWSCR] > 200) { + t->picnum = TILE_VIEWSCR; + } + break; + + case SHRINKSPARK__STATIC: + t->picnum = SHRINKSPARK+( (totalclock>>4)&3 ); + break; + case GROWSPARK__STATIC: + t->picnum = GROWSPARK+( (totalclock>>4)&3 ); + break; + case RPG__STATIC: + if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) { + t->cstat &= ~4; + break; + } + + k = getangle(s->x-x,s->y-y); + k = (((s->ang+3072+128-k)&2047)/170); + if(k > 6) + { + k = 12-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + t->picnum = RPG+k; + break; + + case RECON__STATIC: + if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) { + t->cstat &= ~4; + break; + } + + k = getangle(s->x-x,s->y-y); + if( T1 < 4 ) + k = (((s->ang+3072+128-k)&2047)/170); + else k = (((s->ang+3072+128-k)&2047)/170); + + if(k>6) + { + k = 12-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + + if( klabs(t3) > 64 ) k += 7; + t->picnum = RECON+k; + + break; + + case APLAYER__STATIC: + + p = s->yvel; + + if(t->pal == 1) t->z -= (18<<8); + + if(ps[p].over_shoulder_on > 0 && ps[p].newowner < 0 ) + { + t->cstat |= 2; + if ( screenpeek == myconnectindex && numplayers >= 2 ) + { + t->x = omyx+mulscale16((long)(myx-omyx),smoothratio); + t->y = omyy+mulscale16((long)(myy-omyy),smoothratio); + t->z = omyz+mulscale16((long)(myz-omyz),smoothratio)+(40<<8); + t->ang = omyang+mulscale16((long)(((myang+1024-omyang)&2047)-1024),smoothratio); + t->sectnum = mycursectnum; + } + } + + if( ( display_mirror == 1 || screenpeek != p || s->owner == -1 ) && ud.multimode > 1 && ud.showweapons && sprite[ps[p].i].extra > 0 && ps[p].curr_weapon > 0 ) + { + memcpy((spritetype *)&tsprite[spritesortcnt],(spritetype *)t,sizeof(spritetype)); + + tsprite[spritesortcnt].statnum = 99; + + tsprite[spritesortcnt].yrepeat = ( t->yrepeat>>3 ); + if(t->yrepeat < 4) t->yrepeat = 4; + + tsprite[spritesortcnt].shade = t->shade; + tsprite[spritesortcnt].cstat = 0; + + switch(ps[p].curr_weapon) + { + case PISTOL_WEAPON: tsprite[spritesortcnt].picnum = FIRSTGUNSPRITE; break; + case SHOTGUN_WEAPON: tsprite[spritesortcnt].picnum = SHOTGUNSPRITE; break; + case CHAINGUN_WEAPON: tsprite[spritesortcnt].picnum = CHAINGUNSPRITE; break; + case RPG_WEAPON: tsprite[spritesortcnt].picnum = RPGSPRITE; break; + case HANDREMOTE_WEAPON: + case HANDBOMB_WEAPON: tsprite[spritesortcnt].picnum = HEAVYHBOMB; break; + case TRIPBOMB_WEAPON: tsprite[spritesortcnt].picnum = TRIPBOMBSPRITE; break; + case GROW_WEAPON: tsprite[spritesortcnt].picnum = GROWSPRITEICON; break; + case SHRINKER_WEAPON: tsprite[spritesortcnt].picnum = SHRINKERSPRITE; break; + case FREEZE_WEAPON: tsprite[spritesortcnt].picnum = FREEZESPRITE; break; + case DEVISTATOR_WEAPON: tsprite[spritesortcnt].picnum = DEVISTATORSPRITE; break; + } + + if(s->owner >= 0) + tsprite[spritesortcnt].z = ps[p].posz-(12<<8); + else tsprite[spritesortcnt].z = s->z-(51<<8); + if(ps[p].curr_weapon == HANDBOMB_WEAPON) + { + tsprite[spritesortcnt].xrepeat = 10; + tsprite[spritesortcnt].yrepeat = 10; + } + else + { + tsprite[spritesortcnt].xrepeat = 16; + tsprite[spritesortcnt].yrepeat = 16; + } + tsprite[spritesortcnt].pal = 0; + spritesortcnt++; + } + + if(s->owner == -1) + { + if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) { + k = 0; + t->cstat &= ~4; + } else { + k = (((s->ang+3072+128-a)&2047)>>8)&7; + if(k>4) + { + k = 8-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + } + + if(sector[t->sectnum].lotag == 2) k += 1795-1405; + else if( (hittype[i].floorz-s->z) > (64<<8) ) k += 60; + + t->picnum += k; + t->pal = ps[p].palookup; + + goto PALONLY; + } + + if( ps[p].on_crane == -1 && (sector[s->sectnum].lotag&0x7ff) != 1 ) + { + l = s->z-hittype[ps[p].i].floorz+(3<<8); + if( l > 1024 && s->yrepeat > 32 && s->extra > 0 ) + s->yoffset = (signed char)(l/(s->yrepeat<<2)); + else s->yoffset=0; + } + + if(ps[p].newowner > -1) + { + t4 = *(actorscrptr[APLAYER]+1); + t3 = 0; + t1 = *(actorscrptr[APLAYER]+2); + } + + if(ud.camerasprite == -1 && ps[p].newowner == -1) + if(s->owner >= 0 && display_mirror == 0 && ps[p].over_shoulder_on == 0 ) + if( ud.multimode < 2 || ( ud.multimode > 1 && p == screenpeek ) ) + { + t->owner = -1; + t->xrepeat = t->yrepeat = 0; + continue; + } + +PALONLY: + + if( sector[sect].floorpal && sector[sect].floorpal < numl) + t->pal = sector[sect].floorpal; + + if(s->owner == -1) continue; + + if( t->z > hittype[i].floorz && t->xrepeat < 32 ) + t->z = hittype[i].floorz; + + break; + + case JIBS1__STATIC: + case JIBS2__STATIC: + case JIBS3__STATIC: + case JIBS4__STATIC: + case JIBS5__STATIC: + case JIBS6__STATIC: + case HEADJIB1__STATIC: + case LEGJIB1__STATIC: + case ARMJIB1__STATIC: + case LIZMANHEAD1__STATIC: + case LIZMANARM1__STATIC: + case LIZMANLEG1__STATIC: + case DUKELEG__STATIC: + case DUKEGUN__STATIC: + case DUKETORSO__STATIC: + if(ud.lockout) + { + t->xrepeat = t->yrepeat = 0; + continue; + } + if(t->pal == 6) t->shade = -120; + case SCRAP1__STATIC: + case SCRAP2__STATIC: + case SCRAP3__STATIC: + case SCRAP4__STATIC: + case SCRAP5__STATIC: + + + + if(hittype[i].picnum == BLIMP && t->picnum == SCRAP1 && s->yvel >= 0) + t->picnum = s->yvel; + else t->picnum += T1; + t->shade -= 6; + + if( sector[sect].floorpal && sector[sect].floorpal < numl ) + t->pal = sector[sect].floorpal; + break; + + case WATERBUBBLE__STATIC: + if(sector[t->sectnum].floorpicnum == FLOORSLIME) + { + t->pal = 7; + break; + } + default: + + if( sector[sect].floorpal && sector[sect].floorpal < numl ) + t->pal = sector[sect].floorpal; + break; + } + + if( actorscrptr[s->picnum] ) + { + if(t4) + { + l = *(long *)(t4+8); + + if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) { + k = 0; + t->cstat &= ~4; + } + else switch( l ) + { + case 2: + k = (((s->ang+3072+128-a)&2047)>>8)&1; + break; + + case 3: + case 4: + k = (((s->ang+3072+128-a)&2047)>>7)&7; + if(k > 3) + { + t->cstat |= 4; + k = 7-k; + } + else t->cstat &= ~4; + break; + + case 5: + k = getangle(s->x-x,s->y-y); + k = (((s->ang+3072+128-k)&2047)>>8)&7; + if(k>4) + { + k = 8-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + break; + case 7: + k = getangle(s->x-x,s->y-y); + k = (((s->ang+3072+128-k)&2047)/170); + if(k>6) + { + k = 12-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + break; + case 8: + k = (((s->ang+3072+128-a)&2047)>>8)&7; + t->cstat &= ~4; + break; + default: + k = 0; + break; + } + + t->picnum += k + ( *(long *)t4 ) + l * t3; + + if(l > 0) while(tilesizx[t->picnum] == 0 && t->picnum > 0 ) + t->picnum -= l; //Hack, for actors + + if( hittype[i].dispicnum >= 0) + hittype[i].dispicnum = t->picnum; + } + else if(display_mirror == 1) + t->cstat |= 4; + } + + if( s->statnum == 13 || badguy(s) || checkspriteflags(i,SPRITE_FLAG_SHADOW) || (s->picnum == APLAYER && s->owner >= 0) ) + if(t->statnum != 99 && s->picnum != EXPLOSION2 && s->picnum != HANGLIGHT && s->picnum != DOMELITE) + if(s->picnum != HOTMEAT) + { + if( hittype[i].dispicnum < 0 ) + { + hittype[i].dispicnum++; + continue; + } + else if( ud.shadows && spritesortcnt < (MAXSPRITESONSCREEN-2)) + { + long daz,xrep,yrep; + + if( (sector[sect].lotag&0xff) > 2 || s->statnum == 4 || s->statnum == 5 || s->picnum == DRONE || s->picnum == COMMANDER ) + daz = sector[sect].floorz; + else + daz = hittype[i].floorz; + + if( (s->z-daz) < (8<<8) ) + if( ps[screenpeek].posz < daz ) + { + memcpy((spritetype *)&tsprite[spritesortcnt],(spritetype *)t,sizeof(spritetype)); + + tsprite[spritesortcnt].statnum = 99; + + tsprite[spritesortcnt].yrepeat = ( t->yrepeat>>3 ); + if(t->yrepeat < 4) t->yrepeat = 4; + + tsprite[spritesortcnt].shade = 127; + tsprite[spritesortcnt].cstat |= 2; + + tsprite[spritesortcnt].z = daz; + xrep = tsprite[spritesortcnt].xrepeat;// - (klabs(daz-t->z)>>11); + tsprite[spritesortcnt].xrepeat = xrep; + tsprite[spritesortcnt].pal = 4; + + yrep = tsprite[spritesortcnt].yrepeat;// - (klabs(daz-t->z)>>11); + tsprite[spritesortcnt].yrepeat = yrep; + + if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum) >= 0) + { + tsprite[spritesortcnt].yrepeat = 0; + // 512:trans reverse + //1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues + tsprite[spritesortcnt].cstat |= (512+1024); + } + + spritesortcnt++; + } + } + + if( ps[screenpeek].heat_amount > 0 && ps[screenpeek].heat_on && (badguy(s) || checkspriteflags(i,SPRITE_FLAG_NVG) || s->picnum == APLAYER || s->statnum == 13)) + { + t->pal = 6; + t->shade = 0; + } + } + + switch(dynamictostatic[s->picnum]) + { + case LASERLINE__STATIC: + if(sector[t->sectnum].lotag == 2) t->pal = 8; + t->z = sprite[s->owner].z-(3<<8); + if(lasermode == 2 && ps[screenpeek].heat_on == 0 ) + t->yrepeat = 0; + case EXPLOSION2__STATIC: + case EXPLOSION2BOT__STATIC: + case FREEZEBLAST__STATIC: + case ATOMICHEALTH__STATIC: + case FIRELASER__STATIC: + case SHRINKSPARK__STATIC: + case GROWSPARK__STATIC: + case CHAINGUN__STATIC: + case SHRINKEREXPLOSION__STATIC: + case RPG__STATIC: + case FLOORFLAME__STATIC: + if(t->picnum == EXPLOSION2) + { + ps[screenpeek].visibility = -127; + lastvisinc = totalclock+32; + //restorepalette = 1; // JBF 20040101: why? + } + t->shade = -127; + break; + case FIRE__STATIC: + case FIRE2__STATIC: + case BURNING__STATIC: + case BURNING2__STATIC: + if( sprite[s->owner].picnum != TREE1 && sprite[s->owner].picnum != TREE2 ) + t->z = sector[t->sectnum].floorz; + t->shade = -127; + break; + case COOLEXPLOSION1__STATIC: + t->shade = -127; + t->picnum += (s->shade>>1); + break; + case PLAYERONWATER__STATIC: + if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) { + k = 0; + t->cstat &= ~4; + } else { + k = (((t->ang+3072+128-a)&2047)>>8)&7; + if(k>4) + { + k = 8-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + } + + t->picnum = s->picnum+k+((T1<4)*5); + t->shade = sprite[s->owner].shade; + + break; + + case WATERSPLASH2__STATIC: + t->picnum = WATERSPLASH2+t1; + break; + case REACTOR2__STATIC: + t->picnum = s->picnum + T3; + break; + case SHELL__STATIC: + t->picnum = s->picnum+(T1&1); + case SHOTGUNSHELL__STATIC: + t->cstat |= 12; + if(T1 > 1) t->cstat &= ~4; + if(T1 > 2) t->cstat &= ~12; + break; + case FRAMEEFFECT1_13__STATIC: + if (PLUTOPAK) break; + case FRAMEEFFECT1__STATIC: + if(s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) + { + if(sprite[s->owner].picnum == APLAYER) + if(ud.camerasprite == -1) + if(screenpeek == sprite[s->owner].yvel && display_mirror == 0) + { + t->owner = -1; + break; + } + if( (sprite[s->owner].cstat&32768) == 0 ) + { + t->picnum = hittype[s->owner].dispicnum; + t->pal = sprite[s->owner].pal; + t->shade = sprite[s->owner].shade; + t->ang = sprite[s->owner].ang; + t->cstat = 2|sprite[s->owner].cstat; + } + } + break; + + case CAMERA1__STATIC: + case RAT__STATIC: + + if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum) >= 0) { + t->cstat &= ~4; + break; + } + + k = (((t->ang+3072+128-a)&2047)>>8)&7; + if(k>4) + { + k = 8-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + t->picnum = s->picnum+k; + break; + } + + hittype[i].dispicnum = t->picnum; + if(sector[t->sectnum].floorpicnum == MIRROR) + t->xrepeat = t->yrepeat = 0; + } +} +#ifdef _MSC_VER +//#pragma auto_inline( ) +#pragma optimize("",on) +#endif + +static char terminx[64] = { "Undead TC still sucks." }; + +// #define NUMCHEATCODES 26 +// #define NUMCHEATCODES (signed int)(sizeof(cheatquotes)/sizeof(cheatquotes[14])) +#define NUMCHEATCODES (signed int)(sizeof(cheatquotes)/sizeof(cheatquotes[MAXCHEATLEN])) +char cheatquotes[][MAXCHEATLEN] = { + "cornholio", // 0 + "stuff", // 1 + "scotty###", // 2 + "coords", // 3 + "view", // 4 + "time", // 5 + "unlock", // 6 + "cashman", // 7 + "items", // 8 + "rate", // 9 + "skill#", // 10 + "beta", // 11 + "hyper", // 12 + "monsters", // 13 + "", // 14 + "", // 15 + "todd", // 16 + "showmap", // 17 + "kroz", // 18 + "allen", // 19 + "clip", // 20 + "weapons", // 21 + "inventory", // 22 + "keys", // 23 + "debug", // 24 + "", // 25 + "txisgod", // 26 + }; + +enum cheats { + CHEAT_CORNHOLIO, + CHEAT_STUFF, + CHEAT_SCOTTY, + CHEAT_COORDS, + CHEAT_VIEW, + CHEAT_TIME, + CHEAT_UNLOCK, + CHEAT_CASHMAN, + CHEAT_ITEMS, + CHEAT_RATE, + CHEAT_SKILL, + CHEAT_BETA, + CHEAT_HYPER, + CHEAT_MONSTERS, + CHEAT_RESERVED, + CHEAT_RESERVED2, + CHEAT_TODD, + CHEAT_SHOWMAP, + CHEAT_KROZ, + CHEAT_ALLEN, + CHEAT_CLIP, + CHEAT_WEAPONS, + CHEAT_INVENTORY, + CHEAT_KEYS, + CHEAT_DEBUG, + CHEAT_RESERVED3, + CHEAT_TXISGOD, +}; + +void CheatGetInventory(void) +{ + SetGameVarID(g_iReturnVarID, 400, ps[myconnectindex].i, myconnectindex); + OnEvent(EVENT_CHEATGETSTEROIDS, ps[myconnectindex].i, myconnectindex, -1); + if( GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex) >=0) + { + ps[myconnectindex].steroids_amount = + GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex); + } + + SetGameVarID(g_iReturnVarID, 1200, ps[myconnectindex].i, myconnectindex); + OnEvent(EVENT_CHEATGETHEAT, ps[myconnectindex].i, myconnectindex, -1); + if( GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex) >=0) + { + ps[myconnectindex].heat_amount = + GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex); + } + + SetGameVarID(g_iReturnVarID, 200, ps[myconnectindex].i, myconnectindex); + OnEvent(EVENT_CHEATGETBOOT, ps[myconnectindex].i, myconnectindex, -1); + if( GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex) >=0) + { + ps[myconnectindex].boot_amount = + GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex); + } + + SetGameVarID(g_iReturnVarID, 100, ps[myconnectindex].i, myconnectindex); + OnEvent(EVENT_CHEATGETSHIELD, ps[myconnectindex].i, myconnectindex, -1); + if( GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex) >=0) + { + ps[myconnectindex].shield_amount = + GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex); + } + + SetGameVarID(g_iReturnVarID, 6400, ps[myconnectindex].i, myconnectindex); + OnEvent(EVENT_CHEATGETSCUBA, ps[myconnectindex].i, myconnectindex, -1); + if( GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex) >=0) + { + ps[myconnectindex].scuba_amount = + GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex); + } + + SetGameVarID(g_iReturnVarID, 2400, ps[myconnectindex].i, myconnectindex); + OnEvent(EVENT_CHEATGETHOLODUKE, ps[myconnectindex].i, myconnectindex, -1); + if( GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex) >=0) + { + ps[myconnectindex].holoduke_amount = + GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex); + } + + SetGameVarID(g_iReturnVarID, 1600, ps[myconnectindex].i, myconnectindex); + OnEvent(EVENT_CHEATGETJETPACK, ps[myconnectindex].i, myconnectindex, -1); + if( GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex) >=0) + { + ps[myconnectindex].jetpack_amount = + GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex); + } + + SetGameVarID(g_iReturnVarID, max_player_health, ps[myconnectindex].i, myconnectindex); + OnEvent(EVENT_CHEATGETFIRSTAID, ps[myconnectindex].i, myconnectindex, -1); + if( GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex) >=0) + { + ps[myconnectindex].firstaid_amount = + GetGameVarID(g_iReturnVarID, ps[myconnectindex].i, myconnectindex); + } +} + +char cheatbuf[MAXCHEATLEN],cheatbuflen; + +void cheats(void) +{ + short ch, i, j, k=0,x,y, keystate, weapon; + static char z=0; + char consolecheat = 0; // JBF 20030914 + + if (osdcmd_cheatsinfo_stat.cheatnum != -1) { // JBF 20030914 + k = osdcmd_cheatsinfo_stat.cheatnum; + osdcmd_cheatsinfo_stat.cheatnum = -1; + consolecheat = 1; + } + + if( (ps[myconnectindex].gm&MODE_TYPE) || (ps[myconnectindex].gm&MODE_MENU)) + return; + + if (VOLUMEONE && !z) { + strcpy(cheatquotes[2],"scotty##"); + strcpy(cheatquotes[6],""); + z=1; + } + + if (consolecheat && numplayers < 2 && ud.recstat == 0) + goto FOUNDCHEAT; + + if ( ps[myconnectindex].cheat_phase == 1) + { + while (KB_KeyWaiting()) + { + ch = Btolower(KB_Getch()); + + if( !( (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') ) ) + { + ps[myconnectindex].cheat_phase = 0; + // FTA(46,&ps[myconnectindex]); + return; + } + + cheatbuf[cheatbuflen++] = ch; + cheatbuf[cheatbuflen] = 0; + KB_ClearKeysDown(); + + if(cheatbuflen > MAXCHEATLEN) + { + ps[myconnectindex].cheat_phase = 0; + return; + } + + for(k=0;k < NUMCHEATCODES;k++) + { + for(j = 0;j= '0' && ch <= '9') ) + { + if( cheatquotes[k][j+1] == 0 ) goto FOUNDCHEAT; + if(j == cheatbuflen-1) return; + } + else break; + } + } + + ps[myconnectindex].cheat_phase = 0; + return; + +FOUNDCHEAT: + { + switch(k) + { + case CHEAT_WEAPONS: + if (VOLUMEONE) { + j = 6; + } else { + j = 0; + } + + for ( weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS-j;weapon++ ) + { + addammo( weapon, &ps[myconnectindex], max_ammo_amount[weapon] ); + ps[myconnectindex].gotweapon[weapon] = 1; + } + + KB_FlushKeyBoardQueue(); + ps[myconnectindex].cheat_phase = 0; + FTA(119,&ps[myconnectindex]); + return; + + case CHEAT_INVENTORY: + KB_FlushKeyBoardQueue(); + ps[myconnectindex].cheat_phase = 0; + CheatGetInventory(); + FTA(120,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + return; + + case CHEAT_KEYS: + ps[myconnectindex].got_access = 7; + KB_FlushKeyBoardQueue(); + ps[myconnectindex].cheat_phase = 0; + FTA(121,&ps[myconnectindex]); + return; + + case CHEAT_DEBUG: + debug_on = 1-debug_on; + KB_FlushKeyBoardQueue(); + ps[myconnectindex].cheat_phase = 0; + + { + int i,j; + FILE * fp=fopen("debug.con","w"); + for(i=0;i= 0) + { + fprintf(fp,"Sprite %d (%ld,%ld,%ld) (picnum: %d)\n",j,sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].picnum); + for(i=0;i 0 ) + { + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + } + else if(volnume > num_volumes-1) + { + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + } + else if(volnume == 0) + { + if(levnume > 5) + { + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + } + } + else + { + if(levnume >= 11) + { + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + } + } + + ud.m_volume_number = ud.volume_number = volnume; + ud.m_level_number = ud.level_number = levnume; + } else { // JBF 20030914 + ud.m_volume_number = ud.volume_number = osdcmd_cheatsinfo_stat.volume; + ud.m_level_number = ud.level_number = osdcmd_cheatsinfo_stat.level; + } + + } + else + { + i = strlen(cheatquotes[k])-1; + ud.m_player_skill = ud.player_skill = cheatbuf[i] - '1'; + } + if(numplayers > 1 && myconnectindex == connecthead) + { + tempbuf[0] = 5; + tempbuf[1] = ud.m_level_number; + tempbuf[2] = ud.m_volume_number; + tempbuf[3] = ud.m_player_skill; + tempbuf[4] = ud.m_monsters_off; + tempbuf[5] = ud.m_respawn_monsters; + tempbuf[6] = ud.m_respawn_items; + tempbuf[7] = ud.m_respawn_inventory; + tempbuf[8] = ud.m_coop; + tempbuf[9] = ud.m_marker; + tempbuf[10] = ud.m_ffire; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + sendpacket(i,tempbuf,11); + } + else ps[myconnectindex].gm |= MODE_RESTART; + + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_COORDS: + ps[myconnectindex].cheat_phase = 0; + ud.coords = 1-ud.coords; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_VIEW: + if( ps[myconnectindex].over_shoulder_on ) + ps[myconnectindex].over_shoulder_on = 0; + else + { + ps[myconnectindex].over_shoulder_on = 1; + cameradist = 0; + cameraclock = totalclock; + } + FTA(22,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_TIME: + + FTA(21,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_UNLOCK: + if (VOLUMEONE) return; + + for(i=numsectors-1;i>=0;i--) //Unlock + { + j = sector[i].lotag; + if(j == -1 || j == 32767) continue; + if( (j & 0x7fff) > 2 ) + { + if( j&(0xffff-16384) ) + sector[i].lotag &= (0xffff-16384); + operatesectors(i,ps[myconnectindex].i); + } + } + operateforcefields(ps[myconnectindex].i,-1); + + FTA(100,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_CASHMAN: + ud.cashman = 1-ud.cashman; + KB_ClearKeyDown(sc_N); + ps[myconnectindex].cheat_phase = 0; + return; + + case CHEAT_ITEMS: + CheatGetInventory(); + ps[myconnectindex].got_access = 7; + FTA(5,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_SHOWMAP: // SHOW ALL OF THE MAP TOGGLE; + ud.showallmap = 1-ud.showallmap; + if(ud.showallmap) + { + for(i=0;i<(MAXSECTORS>>3);i++) + show2dsector[i] = 255; + for(i=0;i<(MAXWALLS>>3);i++) + show2dwall[i] = 255; + FTA(111,&ps[myconnectindex]); + } + else + { + for(i=0;i<(MAXSECTORS>>3);i++) + show2dsector[i] = 0; + for(i=0;i<(MAXWALLS>>3);i++) + show2dwall[i] = 0; + FTA(1,&ps[myconnectindex]); + } + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_TODD: + FTA(99,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_RATE: + ud.tickrate = !ud.tickrate; + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_BETA: + FTA(105,&ps[myconnectindex]); + KB_ClearKeyDown(sc_H); + ps[myconnectindex].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_HYPER: + ps[myconnectindex].steroids_amount = 399; + ps[myconnectindex].heat_amount = 1200; + ps[myconnectindex].cheat_phase = 0; + FTA(37,&ps[myconnectindex]); + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_MONSTERS: + if(actor_tog == 3) actor_tog = 0; + actor_tog++; + ps[screenpeek].cheat_phase = 0; + KB_FlushKeyBoardQueue(); + return; + + case CHEAT_RESERVED: + case CHEAT_RESERVED3: + ud.eog = 1; + ps[myconnectindex].gm |= MODE_EOL; + KB_FlushKeyBoardQueue(); + return; + } + } + } + } + else + { + if( KB_KeyPressed(cheatkey[0]) ) + { + if( ps[myconnectindex].cheat_phase >= 0 && numplayers < 2 && ud.recstat == 0) + ps[myconnectindex].cheat_phase = -1; + } + + if( KB_KeyPressed(cheatkey[1]) ) + { + if( ps[myconnectindex].cheat_phase == -1 ) + { + if(ud.player_skill == 4) + { + FTA(22,&ps[myconnectindex]); + ps[myconnectindex].cheat_phase = 0; + } + else + { + ps[myconnectindex].cheat_phase = 1; + // FTA(25,&ps[myconnectindex]); + cheatbuflen = 0; + } + KB_FlushKeyboardQueue(); + } + else if(ps[myconnectindex].cheat_phase != 0) + { + ps[myconnectindex].cheat_phase = 0; + KB_ClearKeyDown(cheatkey[0]); + KB_ClearKeyDown(cheatkey[1]); + } + } + } +} + +long nonsharedtimer; +void nonsharedkeys(void) +{ + short i,ch, weapon; + long j; + + if(ud.recstat == 2) + { + ControlInfo noshareinfo; + CONTROL_GetInput( &noshareinfo ); + } + + if( KB_KeyPressed( sc_F12 ) ) + { + KB_ClearKeyDown( sc_F12 ); + screencapture("duke0000.tga",0); + FTA(103,&ps[myconnectindex]); + } + + if( !ALT_IS_PRESSED && ud.overhead_on == 0) + { + if( BUTTON( gamefunc_Enlarge_Screen ) ) + { + CONTROL_ClearButton( gamefunc_Enlarge_Screen ); + if(ud.screen_size > 0) + sound(THUD); + ud.screen_size -= 4; + vscrn(); + } + if( BUTTON( gamefunc_Shrink_Screen ) ) + { + CONTROL_ClearButton( gamefunc_Shrink_Screen ); + if(ud.screen_size < 64) sound(THUD); + ud.screen_size += 4; + vscrn(); + } + } + + if( ps[myconnectindex].cheat_phase == 1 || (ps[myconnectindex].gm&(MODE_MENU|MODE_TYPE))) return; + + if( BUTTON(gamefunc_See_Coop_View) && ( (gametype_flags[ud.coop] & GAMETYPE_FLAG_COOPVIEW) || ud.recstat == 2) ) + { + CONTROL_ClearButton( gamefunc_See_Coop_View ); + screenpeek = connectpoint2[screenpeek]; + if(screenpeek == -1) screenpeek = connecthead; + restorepalette = 1; + } + + if( ud.multimode > 1 && BUTTON(gamefunc_Show_Opponents_Weapon) ) + { + CONTROL_ClearButton(gamefunc_Show_Opponents_Weapon); + ud.showweapons = 1-ud.showweapons; + ShowOpponentWeapons = ud.showweapons; + FTA(82-ud.showweapons,&ps[screenpeek]); + } + + if( BUTTON(gamefunc_Toggle_Crosshair) ) + { + CONTROL_ClearButton(gamefunc_Toggle_Crosshair); + ud.crosshair = 1-ud.crosshair; + FTA(21-ud.crosshair,&ps[screenpeek]); + } + + if(ud.overhead_on && BUTTON(gamefunc_Map_Follow_Mode) ) + { + CONTROL_ClearButton(gamefunc_Map_Follow_Mode); + ud.scrollmode = 1-ud.scrollmode; + if(ud.scrollmode) + { + ud.folx = ps[screenpeek].oposx; + ud.foly = ps[screenpeek].oposy; + ud.fola = ps[screenpeek].oang; + } + FTA(83+ud.scrollmode,&ps[myconnectindex]); + } + + if( SHIFTS_IS_PRESSED || ALT_IS_PRESSED ) + { + i = 0; + if( KB_KeyPressed( sc_F1) ) { KB_ClearKeyDown(sc_F1);i = 1; } + if( KB_KeyPressed( sc_F2) ) { KB_ClearKeyDown(sc_F2);i = 2; } + if( KB_KeyPressed( sc_F3) ) { KB_ClearKeyDown(sc_F3);i = 3; } + if( KB_KeyPressed( sc_F4) ) { KB_ClearKeyDown(sc_F4);i = 4; } + if( KB_KeyPressed( sc_F5) ) { KB_ClearKeyDown(sc_F5);i = 5; } + if( KB_KeyPressed( sc_F6) ) { KB_ClearKeyDown(sc_F6);i = 6; } + if( KB_KeyPressed( sc_F7) ) { KB_ClearKeyDown(sc_F7);i = 7; } + if( KB_KeyPressed( sc_F8) ) { KB_ClearKeyDown(sc_F8);i = 8; } + if( KB_KeyPressed( sc_F9) ) { KB_ClearKeyDown(sc_F9);i = 9; } + if( KB_KeyPressed( sc_F10) ) {KB_ClearKeyDown(sc_F10);i = 10; } + + if(i) + { + if(SHIFTS_IS_PRESSED) + { + if(i == 5 && ps[myconnectindex].fta > 0 && ps[myconnectindex].ftq == 26) + { + music_select++; + if (VOLUMEALL) { + if(music_select == 44) music_select = 0; + } else { + if(music_select == 6) music_select = 0; + } + strcpy(&tempbuf[0],"PLAYING "); + strcat(&tempbuf[0],&music_fn[0][music_select][0]); + playmusic(&music_fn[0][music_select][0]); + strcpy(&fta_quotes[26][0],&tempbuf[0]); + FTA(26,&ps[myconnectindex]); + return; + } + + adduserquote(ud.ridecule[i-1]); + + ch = 0; + + tempbuf[ch] = 4; + tempbuf[ch+1] = 255; + tempbuf[ch+2] = 0; + strcat(tempbuf+2,ud.ridecule[i-1]); + + i = 2+strlen(ud.ridecule[i-1]); + + if(ud.multimode > 1) + for(ch=connecthead;ch>=0;ch=connectpoint2[ch]) + { + if (ch != myconnectindex) sendpacket(ch,tempbuf,i); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + + pus = NUMPAGES; + pub = NUMPAGES; + + return; + + } + + if(ud.lockout == 0) + if(SoundToggle && ALT_IS_PRESSED && ( RTS_NumSounds() > 0 ) && rtsplaying == 0 && VoiceToggle ) + { + rtsptr = (char *)RTS_GetSound (i-1); + if(*rtsptr == 'C') + FX_PlayVOC3D( rtsptr,0,0,0,255,-i); + else FX_PlayWAV3D( rtsptr,0,0,0,255,-i); + + rtsplaying = 7; + + if(ud.multimode > 1) + { + tempbuf[0] = 7; + tempbuf[1] = i; + + for(ch=connecthead;ch>=0;ch=connectpoint2[ch]) + { + if(ch != myconnectindex) sendpacket(ch,tempbuf,2); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + } + + pus = NUMPAGES; + pub = NUMPAGES; + + return; + } + } + } + + if(!ALT_IS_PRESSED && !SHIFTS_IS_PRESSED) + { + + if( ud.multimode > 1 && BUTTON(gamefunc_SendMessage) ) + { + KB_FlushKeyboardQueue(); + CONTROL_ClearButton( gamefunc_SendMessage ); + ps[myconnectindex].gm |= MODE_TYPE; + typebuf[0] = 0; + inputloc = 0; + } + + if( KB_KeyPressed(sc_F1) || ( ud.show_help && ( KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) ) ) ) + { + KB_ClearKeyDown(sc_F1); + KB_ClearKeyDown(sc_Space); + KB_ClearKeyDown(sc_kpad_Enter); + KB_ClearKeyDown(sc_Enter); + ud.show_help ++; + + if( ud.show_help > 2 ) + { + ud.show_help = 0; + if(ud.multimode < 2 && ud.recstat != 2) ready2send = 1; + vscrn(); + } + else + { + setview(0,0,xdim-1,ydim-1); + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 0; + totalclock = ototalclock; + } + } + } + + // if(ud.multimode < 2) + { + if(ud.recstat != 2 && KB_KeyPressed( sc_F2 ) ) + { + KB_ClearKeyDown( sc_F2 ); + + if(movesperpacket == 4 && connecthead != myconnectindex) + return; + +FAKE_F2: + if(sprite[ps[myconnectindex].i].extra <= 0) + { + FTA(118,&ps[myconnectindex]); + return; + } + cmenu(350); + screencapt = 1; + displayrooms(myconnectindex,65536); + //savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100); + screencapt = 0; + FX_StopAllSounds(); + clearsoundlocks(); + + // setview(0,0,xdim-1,ydim-1); + ps[myconnectindex].gm |= MODE_MENU; + + if(ud.multimode < 2) + { + ready2send = 0; + totalclock = ototalclock; + screenpeek = myconnectindex; + } + } + + if(KB_KeyPressed( sc_F3 )) + { + KB_ClearKeyDown( sc_F3 ); + + if(movesperpacket == 4 && connecthead != myconnectindex) + return; +FAKE_F3: + cmenu(300); + FX_StopAllSounds(); + clearsoundlocks(); + + // setview(0,0,xdim-1,ydim-1); + ps[myconnectindex].gm |= MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 0; + totalclock = ototalclock; + } + screenpeek = myconnectindex; + } + } + + if(KB_KeyPressed( sc_F4 ) && FXDevice >= 0 ) + { + KB_ClearKeyDown( sc_F4 ); + FX_StopAllSounds(); + clearsoundlocks(); + + ps[myconnectindex].gm |= MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 0; + totalclock = ototalclock; + } + cmenu(701); + + } + + if( KB_KeyPressed( sc_F6 ) && (ps[myconnectindex].gm&MODE_GAME)) + { + KB_ClearKeyDown( sc_F6 ); + + if(movesperpacket == 4 && connecthead != myconnectindex) + return; + + if(lastsavedpos == -1) goto FAKE_F2; + + KB_FlushKeyboardQueue(); + + if(sprite[ps[myconnectindex].i].extra <= 0) + { + FTA(118,&ps[myconnectindex]); + return; + } + screencapt = 1; + displayrooms(myconnectindex,65536); + //savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100); + screencapt = 0; + if( lastsavedpos >= 0 ) + { +/* inputloc = strlen(&ud.savegame[lastsavedpos][0]); + current_menu = 360+lastsavedpos; + probey = lastsavedpos; */ + if(ud.multimode > 1) + saveplayer(-1-(lastsavedpos)); + else saveplayer(lastsavedpos); + } + } + + if(KB_KeyPressed( sc_F7 ) ) + { + KB_ClearKeyDown(sc_F7); + if( ps[myconnectindex].over_shoulder_on ) + ps[myconnectindex].over_shoulder_on = 0; + else + { + ps[myconnectindex].over_shoulder_on = 1; + cameradist = 0; + cameraclock = totalclock; + } + FTA(109+ps[myconnectindex].over_shoulder_on,&ps[myconnectindex]); + } + + if( KB_KeyPressed( sc_F5 ) && MusicDevice >= 0 ) + { + KB_ClearKeyDown( sc_F5 ); + strcpy(&tempbuf[0],&music_fn[0][music_select][0]); + strcat(&tempbuf[0],". USE SHIFT-F5 TO CHANGE."); + strcpy(&fta_quotes[26][0],&tempbuf[0]); + FTA(26,&ps[myconnectindex]); + + } + + if(KB_KeyPressed( sc_F8 )) + { + KB_ClearKeyDown( sc_F8 ); + ud.fta_on = !ud.fta_on; + if(ud.fta_on) FTA(23,&ps[myconnectindex]); + else + { + ud.fta_on = 1; + FTA(24,&ps[myconnectindex]); + ud.fta_on = 0; + } + } + + if(KB_KeyPressed( sc_F9 ) && (ps[myconnectindex].gm&MODE_GAME) ) + { + KB_ClearKeyDown( sc_F9 ); + + if(movesperpacket == 4 && myconnectindex != connecthead) + return; + + if(lastsavedpos == -1) goto FAKE_F3; + + if( lastsavedpos >= 0 ) + { + KB_FlushKeyboardQueue(); + KB_ClearKeysDown(); + FX_StopAllSounds(); + + if(ud.multimode > 1) + { + loadplayer(-1-lastsavedpos); + ps[myconnectindex].gm = MODE_GAME; + } + else + { + i = loadplayer(lastsavedpos); + if(i == 0) + ps[myconnectindex].gm = MODE_GAME; + } + } + } + + if(KB_KeyPressed( sc_F10 )) + { + KB_ClearKeyDown( sc_F10 ); + cmenu(500); + FX_StopAllSounds(); + clearsoundlocks(); + ps[myconnectindex].gm |= MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 0; + totalclock = ototalclock; + } + } + + if( ud.overhead_on != 0) + { + + j = totalclock-nonsharedtimer; nonsharedtimer += j; + if ( BUTTON( gamefunc_Enlarge_Screen ) ) + ps[myconnectindex].zoom += mulscale6(j,max(ps[myconnectindex].zoom,256)); + if ( BUTTON( gamefunc_Shrink_Screen ) ) + ps[myconnectindex].zoom -= mulscale6(j,max(ps[myconnectindex].zoom,256)); + + if( (ps[myconnectindex].zoom > 2048) ) + ps[myconnectindex].zoom = 2048; + if( (ps[myconnectindex].zoom < 48) ) + ps[myconnectindex].zoom = 48; + + } + } + + if( KB_KeyPressed(sc_Escape) && ud.overhead_on && ps[myconnectindex].newowner == -1 ) + { + KB_ClearKeyDown( sc_Escape ); + ud.last_overhead = ud.overhead_on; + ud.overhead_on = 0; + ud.scrollmode = 0; + vscrn(); + } + + if( BUTTON(gamefunc_AutoRun) ) + { + CONTROL_ClearButton(gamefunc_AutoRun); + ud.auto_run = 1-ud.auto_run; + RunMode = ud.auto_run; + FTA(85+ud.auto_run,&ps[myconnectindex]); + } + + if( BUTTON(gamefunc_Map) ) + { + CONTROL_ClearButton( gamefunc_Map ); + if( ud.last_overhead != ud.overhead_on && ud.last_overhead) + { + ud.overhead_on = ud.last_overhead; + ud.last_overhead = 0; + } + else + { + ud.overhead_on++; + if(ud.overhead_on == 3 ) ud.overhead_on = 0; + ud.last_overhead = ud.overhead_on; + } + restorepalette = 1; + vscrn(); + } + + if(KB_KeyPressed( sc_F11 )) + { + KB_ClearKeyDown( sc_F11 ); + if(SHIFTS_IS_PRESSED) ud.brightness-=4; + else ud.brightness+=4; + + if (ud.brightness > (7<<2) ) + ud.brightness = 0; + else if(ud.brightness < 0) + ud.brightness = (7<<2); + + setbrightness(ud.brightness>>2,&ps[myconnectindex].palette[0],0); + if(ud.brightness < 20) FTA( 29 + (ud.brightness>>2) ,&ps[myconnectindex]); + else if(ud.brightness < 40) FTA( 96 + (ud.brightness>>2) - 5,&ps[myconnectindex]); + } +} + +void comlinehelp(char **argv) +{ + char *s = "Command line help.\n" + "?, -?\t\tThis help message\n" + "-l##\t\tLevel (1-11)\n" + "-v#\t\tVolume (1-4)\n" + "-s#\t\tSkill (1-4)\n" + "-r\t\tRecord demo\n" + "-dFILE\t\tStart to play demo FILE\n" + "-m\t\tNo monsters\n" + "-ns\t\tNo sound\n" + "-nm\t\tNo music\n" + "-t#\t\tRespawn, 1 = Monsters, 2 = Items, 3 = Inventory, x = All\n" + "-c#\t\tMP mode, 1 = DukeMatch(spawn), 2 = Coop, 3 = Dukematch(no spawn)\n" + "-q#\t\tFake multiplayer (2-8 players)\n" + "-a\t\tUse player AI (fake multiplayer only)\n" + "-i#\t\tNetwork mode (1/0) (multiplayer only) (default == 1)\n" + "-f#\t\tSend fewer packets (1, 2, 4) (multiplayer only)\n" + "-gFILE\t\tUse multiple group files (must be last on command line)\n" + "-hFILE\t\tUse FILE instead of DUKE3D.DEF\n" + "-xFILE\t\tUse specified CON file (default EDUKE.CON/GAME.CON)\n" + "-u#########\tUser's favorite weapon order (default: 3425689071)\n" + "-#\t\tLoad and run a game (slot 0-9)\n" + "-map FILE\tUse a map FILE\n" + "-name NAME\tFoward NAME\n" + "-net\t\tNet mode game\n" + "-nD\t\tDump game definitions to gamevars.txt\n" + "-condebug, -z#\tLine-by-line CON compilation debugging"; + wm_msgbox(apptitle,s); +} + +void checkcommandline(int argc,char **argv) +{ + short i, j; + char *c; + int firstnet = 0; + + i = 1; + + ud.fta_on = 1; + ud.god = 0; + ud.m_respawn_items = 0; + ud.m_respawn_monsters = 0; + ud.m_respawn_inventory = 0; + ud.warp_on = 0; + ud.cashman = 0; + ud.m_player_skill = ud.player_skill = 2; + + if(argc > 1) + { + while(i < argc) + { + c = argv[i]; + if (((*c == '/') || (*c == '-')) && (!firstnet)) + { + if (!Bstrcasecmp(c+1,"net")) { + firstnet = i; + netparamcount = argc - i - 1; + netparam = (char **)calloc(netparamcount, sizeof(char**)); + i++; + continue; + } + if (!Bstrcasecmp(c+1,"name")) { + if (argc > i+1) { + CommandName = argv[i+1]; + i++; + } + i++; + continue; + } + if (!Bstrcasecmp(c+1,"map")) { + if (argc > i+1) { + CommandMap = argv[i+1]; + i++; + } + i++; + continue; + } + if (!Bstrcasecmp(c+1,"condebug")) { + condebug = 1; + i++; + continue; + } + } + + if (firstnet > 0) { + if (*c == '-' || *c == '/') { + c++; + if (((c[0] == 'n') || (c[0] == 'N')) && (c[1] == '0')) + { networkmode = 0; initprintf("Network mode: master/slave\n"); } + else if (((c[0] == 'n') || (c[0] == 'N')) && (c[1] == '1')) + { networkmode = 1; initprintf("Network mode: peer-to-peer\n"); } + } + netparam[i-firstnet-1] = argv[i]; + i++; + continue; + } + + + if(*c == '?') + { + comlinehelp(argv); + exit(-1); + } + + if((*c == '/') || (*c == '-')) + { + c++; + switch(*c) + { + default: + // printf("Unknown command line parameter '%s'\n",argv[i]); + case '?': + comlinehelp(argv); + exit(0); + case 'x': + case 'X': + c++; + if(*c) + { + strcpy(confilename,c); + userconfiles = 1; + /* if(SafeFileExists(c) == 0) + { + initprintf("Could not find CON file '%s'.\n",confilename ); + exit(-1); + } + else */ initprintf("Using CON file: '%s'\n",confilename); + } + break; + case 'g': + case 'G': + c++; + if(*c) + { + strcpy(tempbuf,c); + if( strchr(tempbuf,'.') == 0) + strcat(tempbuf,".grp"); + + j = initgroupfile(tempbuf); + if( j == -1 ) + initprintf("Could not find GRP file %s.\n",tempbuf); + else + { + groupfile = j; + initprintf("Using GRP file %s.\n",tempbuf); + } + } + + break; + case 'h': + case 'H': + c++; + if (*c) { + duke3ddef = c; + initprintf("Using DEF file %s.\n",duke3ddef); + } + break; + + case 'a': + case 'A': + ud.playerai = 1; + initprintf("Other player AI.\n"); + break; + case 'n': + case 'N': + c++; + if(*c == 's' || *c == 'S') + { + CommandSoundToggleOff = 2; + initprintf("Sound off.\n"); + } + else if(*c == 'm' || *c == 'M') + { + CommandMusicToggleOff = 1; + initprintf("Music off.\n"); + } + + else if( *c == 'D') + { + FILE * fp=fopenfrompath("gamevars.txt","w"); + InitGameVars(); + DumpGameVars(fp); + fclose(fp); + initprintf("Game variables saved to gamevars.txt.\n"); + } + + else + { + comlinehelp(argv); + exit(-1); + } + break; + case 'i': + case 'I': + c++; + if(*c == '0') networkmode = 0; + if(*c == '1') networkmode = 1; + initprintf("Network Mode %d\n",networkmode); + break; + case 'c': + case 'C': + + c++; + //if(*c == '1' || *c == '2' || *c == '3' ) + // ud.m_coop = *c - '0' - 1; + //else ud.m_coop = 0; + + ud.m_coop = 0; + while ((*c >= '0')&&(*c <= '9')) { + ud.m_coop *= 10; + ud.m_coop += *c - '0'; + c++; + } + ud.m_coop--; + //switch(ud.m_coop) + //{ + //case 0: + // initprintf("Dukematch (spawn).\n"); + // break; + //case 1: + // initprintf("Cooperative play.\n"); + // break; + //case 2: + // initprintf("Dukematch (no spawn).\n"); + // break; + //} + break; + case 'f': + case 'F': + c++; + if(*c == '1') + movesperpacket = 1; + if(*c == '2') + movesperpacket = 2; + if(*c == '4') + { + movesperpacket = 4; + setpackettimeout(0x3fffffff,0x3fffffff); + } + break; + case 't': + case 'T': + c++; + if(*c == '1') ud.m_respawn_monsters = 1; + else if(*c == '2') ud.m_respawn_items = 1; + else if(*c == '3') ud.m_respawn_inventory = 1; + else + { + ud.m_respawn_monsters = 1; + ud.m_respawn_items = 1; + ud.m_respawn_inventory = 1; + } + initprintf("Respawn on.\n"); + break; + case 'm': + case 'M': + if( *(c+1) != 'a' && *(c+1) != 'A' ) + { + ud.m_monsters_off = 1; + ud.m_player_skill = ud.player_skill = 0; + initprintf("Monsters off.\n"); + } + break; + case 'w': + case 'W': + ud.coords = 1; + break; + case 'q': + case 'Q': + initprintf("Fake multiplayer mode.\n"); + if( *(++c) == 0) ud.multimode = 1; + else ud.multimode = atol(c)%17; + ud.m_coop = ud.coop = 0; + ud.m_marker = ud.marker = 1; + ud.m_respawn_monsters = ud.respawn_monsters = 1; + ud.m_respawn_items = ud.respawn_items = 1; + ud.m_respawn_inventory = ud.respawn_inventory = 1; + + break; + case 'r': + case 'R': + ud.m_recstat = 1; + initprintf("Demo record mode on.\n"); + break; + case 'd': + case 'D': + c++; + if( strchr(c,'.') == 0) + strcat(c,".dmo"); + initprintf("Play demo %s.\n",c); + strcpy(firstdemofile,c); + break; + case 'l': + case 'L': + ud.warp_on = 1; + c++; + ud.m_level_number = ud.level_number = (atol(c)-1)%11; + break; + case 'j': + case 'J': + initprintf(HEAD2); + exit(0); + + case 'v': + case 'V': + c++; + ud.warp_on = 1; + ud.m_volume_number = ud.volume_number = atol(c)-1; + break; + case 's': + case 'S': + c++; + ud.m_player_skill = ud.player_skill = (atol(c)%5); + if(ud.m_player_skill == 4) + ud.m_respawn_monsters = ud.respawn_monsters = 1; + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + ud.warp_on = 2 + (*c) - '0'; + break; + case 'u': + case 'U': + c++; + j = 0; + if(*c) + { + initprintf("Using favorite weapon order(s).\n"); + while(*c) + { + ud.wchoice[0][j] = *c-'0'; + c++; + j++; + } + while(j < 10) + { + if(j == 9) + ud.wchoice[0][9] = 1; + else + ud.wchoice[0][j] = 2; + + j++; + } + } + else + { + initprintf("Using default weapon orders.\n"); + ud.wchoice[0][0] = 3; + ud.wchoice[0][1] = 4; + ud.wchoice[0][2] = 5; + ud.wchoice[0][3] = 7; + ud.wchoice[0][4] = 8; + ud.wchoice[0][5] = 6; + ud.wchoice[0][6] = 0; + ud.wchoice[0][7] = 2; + ud.wchoice[0][8] = 9; + ud.wchoice[0][9] = 1; + } + + break; + case 'z': + case 'Z': + c++; + condebug = atol(c); + if(!condebug) + condebug = 1; + break; + } + } + i++; + } + } +} + +void printstr(short x, short y, char string[81], char attribute) +{ + char character; + short i, pos; + /* + pos = (y*80+x)<<1; + i = 0; + while (string[i] != 0) + { + character = string[i]; + printchrasm(0xb8000+(long)pos,1L,((long)attribute<<8)+(long)character); + i++; + pos+=2; + } + */ +} + +/* +void cacheicon(void) +{ + if(cachecount > 0) + { + if( (ps[myconnectindex].gm&MODE_MENU) == 0 ) + rotatesprite((320-7)<<16,(200-23)<<16,32768L,0,SPINNINGNUKEICON,0,0,2,windowx1,windowy1,windowx2,windowy2); + cachecount = 0; + } +} + */ + +void Logo(void) +{ + short i,j,soundanm; + long logoflags=GetGameVar("LOGO_FLAGS",255, -1, -1); + soundanm = 0; + + ready2send = 0; + + KB_FlushKeyboardQueue(); + KB_ClearKeysDown(); // JBF + + setview(0,0,xdim-1,ydim-1); + clearview(0L); + IFISSOFTMODE palto(0,0,0,63); + + flushperms(); + nextpage(); + + MUSIC_StopSong(); + FX_StopAllSounds(); // JBF 20031228 + clearsoundlocks(); // JBF 20031228 + if (ud.multimode < 2 && (logoflags & LOGO_FLAG_ENABLED)) + { + if (VOLUMEALL && (logoflags & LOGO_FLAG_PLAYANIM)) { + + if(!KB_KeyWaiting() && nomorelogohack == 0) + { + getpackets(); + playanm("logo.anm",5); + IFISSOFTMODE palto(0,0,0,63); + KB_FlushKeyboardQueue(); + KB_ClearKeysDown(); // JBF + } + + clearview(0L); + nextpage(); + } + if (logoflags & LOGO_FLAG_PLAYMUSIC) + playmusic(&env_music_fn[0][0]); + + fadepal(0,0,0, 0,64,7); + //ps[myconnectindex].palette = drealms; + //palto(0,0,0,63); + if (logoflags & LOGO_FLAG_3DRSCREEN) + { + setgamepalette(&ps[myconnectindex], drealms, 3); // JBF 20040308 + rotatesprite(0,0,65536L,0,DREALMS,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + nextpage(); + fadepal(0,0,0, 63,0,-7); + totalclock = 0; + while( totalclock < (120*7) && !KB_KeyWaiting() ) { + handleevents(); + getpackets(); + } + } + KB_ClearKeysDown(); // JBF + + fadepal(0,0,0, 0,64,7); + clearview(0L); + nextpage(); + if (logoflags & LOGO_FLAG_TITLESCREEN) + { + //ps[myconnectindex].palette = titlepal; + setgamepalette(&ps[myconnectindex], titlepal, 3); // JBF 20040308 + flushperms(); + rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); + KB_FlushKeyboardQueue(); + fadepal(0,0,0, 63,0,-7); + totalclock = 0; + + while(totalclock < (860+120) && !KB_KeyWaiting()) + { + rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); + if (logoflags & LOGO_FLAG_DUKENUKEM) + { + if( totalclock > 120 && totalclock < (120+60) ) + { + if(soundanm == 0) + { + soundanm = 1; + sound(PIPEBOMB_EXPLODE); + } + rotatesprite(160<<16,104<<16,(totalclock-120)<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); + } + else if( totalclock >= (120+60) ) + rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); + } else soundanm = 1; + if (logoflags & LOGO_FLAG_THREEDEE) + { + if( totalclock > 220 && totalclock < (220+30) ) + { + if( soundanm == 1) + { + soundanm = 2; + sound(PIPEBOMB_EXPLODE); + } + + rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,(129)<<16,(totalclock - 220 )<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); + } + else if( totalclock >= (220+30) ) + rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); + } else soundanm = 2; + if (PLUTOPAK && (logoflags & LOGO_FLAG_PLUTOPAKSPRITE)) { // JBF 20030804 + if( totalclock >= 280 && totalclock < 395 ) + { + rotatesprite(160<<16,(151)<<16,(410-totalclock)<<12,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); + if(soundanm == 2) + { + soundanm = 3; + sound(FLY_BY); + } + } + else if( totalclock >= 395 ) + { + if(soundanm == 3) + { + soundanm = 4; + sound(PIPEBOMB_EXPLODE); + } + rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); + } + } + OnEvent(EVENT_LOGO, -1, screenpeek, -1); + handleevents(); + getpackets(); + nextpage(); + } + } + KB_ClearKeysDown(); // JBF + } + + if(ud.multimode > 1) + { + setgamepalette(&ps[myconnectindex], titlepal, 3); + rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); + + rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); + + gametext(160,190,"WAITING FOR PLAYERS",14,2); + nextpage(); + } + + waitforeverybody(); + + flushperms(); + clearview(0L); + nextpage(); + + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 0); // JBF 20040308 + sound(NITEVISION_ONOFF); + + //palto(0,0,0,0); + clearview(0L); +} + +void loadtmb(void) +{ + char tmb[8000]; + long fil, l; + + fil = kopen4load("d3dtimbr.tmb",0); + if(fil == -1) return; + l = kfilelength(fil); + kread(fil,(char *)tmb,l); + MUSIC_RegisterTimbreBank(tmb); + kclose(fil); +} + +/* +=================== += += ShutDown += +=================== +*/ + +void Shutdown( void ) +{ + SoundShutdown(); + MusicShutdown(); + uninittimer(); + uninitengine(); + CONTROL_Shutdown(); + CONFIG_WriteSetup(); + KB_Shutdown(); +} + +/* +=================== += += Startup += +=================== +*/ + +void compilecons(void) +{ + char *tempname; + int i; + label = (char *)&sprite[0]; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816 + labelcode = (long *)§or[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240 + labeltype = (long *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536 + // if we compile for a V7 engine wall[] should be used for label names since it's bigger + + if(userconfiles == 0) + { + i = kopen4load(confilename,0); + if (i!=-1) + kclose(i); + else Bsprintf(confilename,"GAME.CON"); + } + loadefs(confilename); + + if( loadfromgrouponly ) + { + if(userconfiles == 0) + { + i = kopen4load("EDUKE.CON",1); + if (i!=-1) + { + Bsprintf(confilename,"EDUKE.CON"); + kclose(i); + } + else Bsprintf(confilename,"GAME.CON"); + } + loadefs(confilename); + } + + if ((unsigned long)labelcnt > sizeof(sprite)/64 ) // see the arithmetic above for why + gameexit("Error: too many labels defined!"); + else + { + char *newlabel; + long *newlabelcode; + + newlabel = (char *)malloc(labelcnt<<6); + newlabelcode = (long *)malloc(labelcnt*sizeof(long)); + + if (!newlabel || !newlabelcode) + { + gameexit("Error: out of memory retaining labels\n"); + } + + copybuf(label, newlabel, (labelcnt*64)/4); + copybuf(labelcode, newlabelcode, (labelcnt*sizeof(long))/4); + + label = newlabel; + labelcode = newlabelcode; + } + clearbufbyte(&sprite[0], sizeof(sprite), 0); + clearbufbyte(§or[0], sizeof(sector), 0); + clearbufbyte(&wall[0], sizeof(wall), 0); + + OnEvent(EVENT_INIT, -1, -1, -1); +} + +void sanitizegametype() +{ + // initprintf("ud.m_coop=%i before sanitization\n",ud.m_coop); + if (ud.m_coop >= num_gametypes || ud.m_coop < 0) { + ud.m_coop = 0; + } + Bsprintf(tempbuf,"%s\n",gametype_names[ud.m_coop]); + initprintf(tempbuf); + if(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_ITEMRESPAWN) ud.m_respawn_items = 1; + else ud.m_respawn_items = 0; + // initprintf("ud.m_coop=%i after sanitisation\n",ud.m_coop); +} + +void Startup(void) +{ + int i; + + CONFIG_ReadSetup(); + + // readnames(); + + compilecons(); // JBF 20040116: Moved to below setup reading, because otherwise blown + + setupdynamictostatic(); + + if (ud.multimode > 1) sanitizegametype(); + + if (CommandSoundToggleOff) SoundToggle = 0; + if (CommandMusicToggleOff) MusicToggle = 0; + if (CommandName) strcpy(myname,CommandName); + if (CommandMap) { + if (VOLUMEONE) { + initprintf("The -map option is available in the registered version only!\n"); + boardfilename[0] = 0; + } else { + char *dot, *slash; + + Bstrcpy(boardfilename, CommandMap); + + dot = Bstrrchr(boardfilename,'.'); + slash = Bstrrchr(boardfilename,'/'); + if (!slash) slash = Bstrrchr(boardfilename,'\\'); + + if ((!slash && !dot) || (slash && dot < slash)) + Bstrcat(boardfilename,".map"); + + i = kopen4load(boardfilename,0); + if (i!=-1) { + initprintf("Using level: '%s'.\n",boardfilename); + kclose(i); + } + else + { + initprintf("Level '%s' not found.\n",boardfilename); + boardfilename[0] = 0; + } + } + } + + if (VOLUMEONE) { + initprintf("*** You have run Duke Nukem 3D %ld times. ***\n\n",ud.executions); + if(ud.executions >= 50) initprintf("IT IS NOW TIME TO UPGRADE TO THE COMPLETE VERSION!!!\n"); + } + + if (initengine()) { + wm_msgbox("Build Engine Initialisation Error", + "There was a problem initialising the Build engine: %s", engineerrstr); + exit(1); + } + + if (CONTROL_Startup( ControllerType, &GetTime, TICRATE )) { + uninitengine(); + exit(1); + } + SetupGameButtons(); + CONFIG_SetupMouse(); + CONFIG_SetupJoystick(); + + // JBF 20040215: evil and nasty place to do this, but joysticks are evil and nasty too + if (ControllerType == controltype_keyboardandjoystick) { + for (i=0;i 1) + initprintf("Multiplayer initialized.\n"); + + screenpeek = myconnectindex; + ps[myconnectindex].palette = (char *) &palette[0]; + + if(networkmode == 255) + networkmode = 1; + + getnames(); +} + +void sendscore(char *s) +{ + if(numplayers > 1) + genericmultifunction(-1,s,strlen(s)+1,5); +} + +void getnames(void) +{ + int i,l; + + for(l=0;myname[l];l++) + ud.user_name[myconnectindex][l] = Btoupper(myname[l]); + + if(numplayers > 1) + { + buf[0] = 6; + buf[1] = myconnectindex; + buf[2] = BYTEVERSION; + l = 3; + + //null terminated player name to send + for(i=0;myname[i];i++) buf[l++] = Btoupper(myname[i]); + buf[l++] = 0; + + for(i=0;i<10;i++) + { + ud.wchoice[myconnectindex][i] = ud.wchoice[0][i]; + buf[l++] = (char)ud.wchoice[0][i]; + } + + buf[l++] = ps[myconnectindex].aim_mode = ud.mouseaiming; + buf[l++] = ps[myconnectindex].auto_aim = AutoAim; + buf[l++] = ps[myconnectindex].weaponswitch = ud.weaponswitch; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (i != myconnectindex) sendpacket(i,&buf[0],l); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + + getpackets(); + + waitforeverybody(); + } + + if(cp == 1 && numplayers < 2) + gameexit("Please put the Duke Nukem 3D Atomic Edition CD in the CD-ROM drive."); +} + +void writestring(long a1,long a2,long a3,short a4,long vx,long vy,long vz) +{ + + FILE *fp; + + fp = (FILE *)fopenfrompath("debug.txt","rt+"); + + fprintf(fp,"%ld %ld %ld %d %ld %ld %ld\n",a1,a2,a3,a4,vx,vy,vz); + + fclose(fp); + +} + +char testcd(char *fn, long testsiz); + +// JBF: various hacks here +void copyprotect(void) +{ + // FILE *fp; + // char idfile[256]; + + cp = 0; + +#ifdef NOCOPYPROTECT + return; +#endif + if (VOLUMEONE) return; + + if( testcd(IDFILENAME, IDFSIZE) ) + { + cp = 1; + return; + } +} + +void backtomenu(void) +{ + boardfilename[0] = 0; + if (ud.recstat == 1) closedemowrite(); + ud.warp_on = 0; + ps[myconnectindex].gm = MODE_MENU; + cmenu(0); + KB_FlushKeyboardQueue(); +} + +int shareware = 0; + +char *startwin_labeltext = "Starting EDuke32..."; + +int load_script(char *szScript) +{ + FILE* fp = fopenfrompath(szScript, "r"); + + if(fp != NULL) + { + char line[255]; + OSD_Printf("Executing \"%s\"\n", szScript); + while(fgets(line ,sizeof(line)-1, fp) != NULL) + OSD_Dispatch(strtok(line,"\r\n")); + fclose(fp); + return 0; + } + return 1; +} + +void app_main(int argc,char **argv) +{ + long i, j, k, l; +#ifdef RENDERTYPEWIN + if (win_checkinstance()) { + if (!wm_ynbox("EDuke32","Another Build game is currently running. " + "Do you wish to continue starting this copy?")) + return; + } +#endif + + OSD_SetLogFile("eduke32.log"); + +#if 1 // defined(_WIN32) + if (!access("user_profiles_enabled", F_OK)) +#endif + { + char cwd[BMAX_PATH]; + char *homedir; + int asperr; + +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + addsearchpath("/usr/share/games/eduke32"); + addsearchpath("/usr/local/share/games/eduke32"); +#elif defined(__APPLE__) + addsearchpath("/Library/Application Support/EDuke32"); +#endif + if (getcwd(cwd,BMAX_PATH)) addsearchpath(cwd); + if ((homedir = Bgethomedir())) { + Bsnprintf(cwd,sizeof(cwd),"%s/" +#if defined(_WIN32) + "EDuke32 Settings" +#elif defined(__APPLE__) + "Library/Application Support/EDuke32" +#else + ".eduke32" +#endif + ,homedir); + asperr = addsearchpath(cwd); + if (asperr == -2) { + if (Bmkdir(cwd,S_IRWXU) == 0) asperr = addsearchpath(cwd); + else asperr = -1; + } + if ((asperr == 0)) + chdir(cwd); + Bfree(homedir); + } + } + + // JBF 20030925: Because it's annoying renaming GRP files whenever I want to test different game data + if (getenv("DUKE3DGRP")) { + duke3dgrp = getenv("DUKE3DGRP"); + initprintf("Using `%s' as main GRP file\n", duke3dgrp); + } + initgroupfile(duke3dgrp); + i = kopen4load("DUKESW.BIN",1); // JBF 20030810 + if (i!=-1) { + initprintf("Using Shareware GRP file.\n"); + shareware = 1; + kclose(i); + } + copyprotect(); + if (cp) return; + + // gotta set the proper title after we compile the CONs if this is the full version + + if (VOLUMEALL) wm_setapptitle(HEAD2); + else wm_setapptitle(HEAD); + + initprintf("%s%s\n",apptitle," ("__DATE__" "__TIME__")"); + initprintf("Copyright (c) 1996, 2003 3D Realms Entertainment\n"); + initprintf("Copyright (c) 2006 EDuke32 team\n\n"); + + ud.multimode = 1; + + checkcommandline(argc,argv); + if (!loaddefinitionsfile(duke3ddef)) initprintf("Definitions file loaded.\n"); + if (condebug) + initprintf("CON debugging activated (%d).\n\n",condebug); + + if (netparamcount > 0) _buildargc = (argc -= netparamcount+1); // crop off the net parameters + + RegisterShutdownFunction( Shutdown ); + + if (VOLUMEONE) { + initprintf("Distribution of shareware Duke Nukem 3D is restricted in certain ways.\n"); + initprintf("Please read LICENSE.DOC for more details.\n"); + } + + Startup(); // a bunch of stuff including compiling cons + + if (quitevent) return; + + // initprintf("numplayers=%i\n",numplayers); + + if(numplayers > 1) + { + ud.multimode = numplayers; + sendlogon(); + } + else if(boardfilename[0] != 0) + { + ud.m_level_number = 7; + ud.m_volume_number = 0; + ud.warp_on = 1; + } + + getnames(); + + if(ud.multimode > 1) + { + playerswhenstarted = ud.multimode; + + if(ud.warp_on == 0) + { + ud.m_monsters_off = 1; + ud.m_player_skill = 0; + } + } + + ud.last_level = -1; + + RTS_Init(ud.rtsname); + if(numlumps) initprintf("Using .RTS file: %s\n",ud.rtsname); + + if (CONTROL_JoystickEnabled) + CONTROL_CenterJoystick + ( + CenterCenter, + UpperLeft, + LowerRight, + CenterThrottle, + CenterRudder + ); + + if( setgamemode(ScreenMode,ScreenWidth,ScreenHeight,ScreenBPP) < 0 ) + { + initprintf("Failure setting video mode %dx%dx%d %s! Attempting safer mode...", + ScreenWidth,ScreenHeight,ScreenBPP,ScreenMode?"fullscreen":"windowed"); + ScreenMode = 0; // JBF: was 2 + ScreenWidth = 320; + ScreenHeight = 240; // JBF: was 200 + ScreenBPP = 8; + setgamemode(ScreenMode,ScreenWidth,ScreenHeight,ScreenBPP); + } + + initprintf("Initializing OSD...\n"); + + OSD_SetFunctions( + GAME_drawosdchar, + GAME_drawosdstr, + GAME_drawosdcursor, + GAME_getcolumnwidth, + GAME_getrowheight, + GAME_clearbackground, + (int(*)(void))GetTime, + GAME_onshowosd + ); + OSD_SetParameters(0,2, 0,0, 4,0); + registerosdcommands(); + + initprintf("Checking music inits...\n"); + MusicStartup(); + initprintf("Checking sound inits...\n"); + SoundStartup(); + loadtmb(); + + if (VOLUMEONE) { + if(numplayers > 4 || ud.multimode > 4) + gameexit(" The full version of Duke Nukem 3D supports 5 or more players."); + } + + setbrightness(ud.brightness>>2,&ps[myconnectindex].palette[0],0); + + // ESCESCAPE; + + FX_StopAllSounds(); + clearsoundlocks(); + + load_script("autoexec.cfg"); + + if(ud.warp_on > 1 && ud.multimode < 2) + { + clearview(0L); + //ps[myconnectindex].palette = palette; + //palto(0,0,0,0); + setgamepalette(&ps[myconnectindex], palette, 0); // JBF 20040308 + rotatesprite(320<<15,200<<15,65536L,0,LOADSCREEN,0,0,2+8+64,0,0,xdim-1,ydim-1); + menutext(160,105,0,0,"LOADING SAVED GAME..."); + nextpage(); + + j = loadplayer(ud.warp_on-2); + if(j) + ud.warp_on = 0; + } + + // getpackets(); + +MAIN_LOOP_RESTART: + + if(ud.warp_on == 0) + Logo(); + else if(ud.warp_on == 1) + { + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + + if (enterlevel(MODE_GAME)) backtomenu(); + } + else vscrn(); + /* + if(ud.warp_on == 0) + Logo(); + + MAIN_LOOP_RESTART: + + if(ud.warp_on == 1) + { + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + + if (enterlevel(MODE_GAME)) backtomenu(); + } + else if(ud.warp_on != 0) vscrn(); + */ + if( ud.warp_on == 0 && playback() ) + { + FX_StopAllSounds(); + clearsoundlocks(); + nomorelogohack = 1; + goto MAIN_LOOP_RESTART; + } + + ud.auto_run = RunMode; + ud.showweapons = ShowOpponentWeapons; + ps[myconnectindex].aim_mode = ud.mouseaiming; + ps[myconnectindex].auto_aim = AutoAim; + ps[myconnectindex].weaponswitch = ud.weaponswitch; + + ud.warp_on = 0; + KB_KeyDown[sc_Pause] = 0; // JBF: I hate the pause key + + while ( !(ps[myconnectindex].gm&MODE_END) ) //The whole loop!!!!!!!!!!!!!!!!!! + { + if (handleevents()) { // JBF + if (quitevent) { + KB_KeyDown[sc_Escape] = 1; + quitevent = 0; + } + } + + AudioUpdate(); + + OSD_DispatchQueued(); + + if( ud.recstat == 2 || ud.multimode > 1 || ( ud.show_help == 0 && (ps[myconnectindex].gm&MODE_MENU) != MODE_MENU ) ) + if( ps[myconnectindex].gm&MODE_GAME ) + if( moveloop() ) continue; + + if( ps[myconnectindex].gm&MODE_EOL || ps[myconnectindex].gm&MODE_RESTART ) + { + if( ps[myconnectindex].gm&MODE_EOL && display_bonus_screen == 1) + { + closedemowrite(); + + ready2send = 0; + + i = ud.screen_size; + ud.screen_size = 0; + vscrn(); + ud.screen_size = i; + dobonus(0); + + if(ud.eog) + { + ud.eog = 0; + if(ud.multimode < 2) + { + if (!VOLUMEALL) { + doorders(); + } + ps[myconnectindex].gm = MODE_MENU; + cmenu(0); + probey = 0; + goto MAIN_LOOP_RESTART; + } + else + { + ud.m_level_number = 0; + ud.level_number = 0; + } + } + } + display_bonus_screen = 1; + ready2send = 0; + if(numplayers > 1) ps[myconnectindex].gm = MODE_GAME; + if (enterlevel(ps[myconnectindex].gm)) { + backtomenu(); + goto MAIN_LOOP_RESTART; + } + continue; + } + + cheats(); + nonsharedkeys(); + + if( (ud.show_help == 0 && ud.multimode < 2 && !(ps[myconnectindex].gm&MODE_MENU) ) || ud.multimode > 1 || ud.recstat == 2) + i = min(max((totalclock-ototalclock)*(65536L/TICSPERFRAME),0),65536); + else + i = 65536; + + displayrooms(screenpeek,i); + displayrest(i); + + // if( KB_KeyPressed(sc_F) ) + // { + // KB_ClearKeyDown(sc_F); + // addplayer(); + // } + + if(ps[myconnectindex].gm&MODE_DEMO) + goto MAIN_LOOP_RESTART; + + if(debug_on) caches(); + + checksync(); + + if (VOLUMEONE) { + if(ud.show_help == 0 && show_shareware > 0 && (ps[myconnectindex].gm&MODE_MENU) == 0 ) + rotatesprite((320-50)<<16,9<<16,65536L,0,BETAVERSION,0,0,2+8+16+128,0,0,xdim-1,ydim-1); + } + + nextpage(); + + while (!(ps[myconnectindex].gm&MODE_MENU) && ready2send && totalclock >= ototalclock+TICSPERFRAME) + faketimerhandler(); + } + + gameexit(" "); +} + +char opendemoread(char which_demo) // 0 = mine +{ + char d[13]; + char ver; + short i; + + strcpy(d, "demo_.dmo"); + + if(which_demo == 10) + d[4] = 'x'; + else + d[4] = '0' + which_demo; + + ud.reccnt = 0; + + if(which_demo == 1 && firstdemofile[0] != 0) + { + if ((recfilep = kopen4load(firstdemofile,loadfromgrouponly)) == -1) return(0); + } + else + if ((recfilep = kopen4load(d,loadfromgrouponly)) == -1) return(0); + + if (kread(recfilep,&ud.reccnt,sizeof(long)) != sizeof(long)) goto corrupt; + if (kread(recfilep,&ver,sizeof(char)) != sizeof(char)) goto corrupt; + if( (ver != BYTEVERSION) ) // || (ud.reccnt < 512) ) + { + if (ver == BYTEVERSION_JF) initprintf("Demo %s is for Regular edition.\n", d); + else if (ver == BYTEVERSION_JF+1) initprintf("Demo %s is for Atomic edition.\n", d); + else if (ver == BYTEVERSION_JF+2) initprintf("Demo %s is for Shareware version.\n", d); + else OSD_Printf("Demo %s is of an incompatible version (%d).\n", d, ver); + kclose(recfilep); + ud.reccnt=0; + return 0; + } + + if (kread(recfilep,(char *)&ud.volume_number,sizeof(char)) != sizeof(char)) goto corrupt; + if (kread(recfilep,(char *)&ud.level_number,sizeof(char)) != sizeof(char)) goto corrupt; + if (kread(recfilep,(char *)&ud.player_skill,sizeof(char)) != sizeof(char)) goto corrupt; + if (kread(recfilep,(char *)&ud.m_coop,sizeof(char)) != sizeof(char)) goto corrupt; + if (kread(recfilep,(char *)&ud.m_ffire,sizeof(char)) != sizeof(char)) goto corrupt; + if (kread(recfilep,(short *)&ud.multimode,sizeof(short)) != sizeof(short)) goto corrupt; + if (kread(recfilep,(short *)&ud.m_monsters_off,sizeof(short)) != sizeof(short)) goto corrupt; + if (kread(recfilep,(int32 *)&ud.m_respawn_monsters,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int32 *)&ud.m_respawn_items,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int32 *)&ud.m_respawn_inventory,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(int32 *)&ud.playerai,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(char *)&ud.user_name[0][0],sizeof(ud.user_name)) != sizeof(ud.user_name)) goto corrupt; + if (kread(recfilep,(int32 *)&ud.auto_run,sizeof(int32)) != sizeof(int32)) goto corrupt; + if (kread(recfilep,(char *)boardfilename,sizeof(boardfilename)) != sizeof(boardfilename)) goto corrupt; + if( boardfilename[0] != 0 ) + { + ud.m_level_number = 7; + ud.m_volume_number = 0; + } + + for(i=0;i=0;i=connectpoint2[i]) + { + copybufbyte(&sync[i],&recsync[ud.reccnt],sizeof(input)); + ud.reccnt++; + totalreccnt++; + if (ud.reccnt >= RECSYNCBUFSIZ) + { + dfwrite(recsync,sizeof(input)*ud.multimode,ud.reccnt/ud.multimode,frecfilep); + ud.reccnt = 0; + } + } +} + +void closedemowrite(void) +{ + if (ud.recstat == 1) + { + if (ud.reccnt > 0) + { + dfwrite(recsync,sizeof(input)*ud.multimode,ud.reccnt/ud.multimode,frecfilep); + + fseek(frecfilep,SEEK_SET,0L); + fwrite(&totalreccnt,sizeof(long),1,frecfilep); + ud.recstat = ud.m_recstat = 0; + } + fclose(frecfilep); + } +} + +char which_demo = 1; +char in_menu = 0; + +// extern long syncs[]; +long playback(void) +{ + long i,j,k,l,t,tc; + short p; + char foundemo; + + if( ready2send ) return 0; + + foundemo = 0; + +RECHECK: + + in_menu = ps[myconnectindex].gm&MODE_MENU; + + pub = NUMPAGES; + pus = NUMPAGES; + + flushperms(); + + if(numplayers < 2) foundemo = opendemoread(which_demo); + + if(foundemo == 0) + { + if(which_demo > 1) + { + which_demo = 1; + goto RECHECK; + } + fadepal(0,0,0, 0,63,7); + setgamepalette(&ps[myconnectindex], palette, 1); // JBF 20040308 + drawbackground(); + menus(); + //ps[myconnectindex].palette = palette; + nextpage(); + fadepal(0,0,0, 63,0,-7); + ud.reccnt = 0; + } + else + { + ud.recstat = 2; + which_demo++; + if(which_demo == 10) which_demo = 1; + if (enterlevel(MODE_DEMO)) return 1; + } + + if(foundemo == 0 || in_menu || KB_KeyWaiting() || numplayers > 1) + { + FX_StopAllSounds(); + clearsoundlocks(); + ps[myconnectindex].gm |= MODE_MENU; + } + + ready2send = 0; + i = 0; + + KB_FlushKeyboardQueue(); + + k = 0; + + while (ud.reccnt > 0 || foundemo == 0) + { + if(foundemo) while ( totalclock >= (lockclock+TICSPERFRAME) ) + { + if ((i == 0) || (i >= RECSYNCBUFSIZ)) + { + i = 0; + l = min(ud.reccnt,RECSYNCBUFSIZ); + if (kdfread(recsync,sizeof(input)*ud.multimode,l/ud.multimode,recfilep) != l/ud.multimode) { + OSD_Printf("Demo %d is corrupt.\n", which_demo-1); + foundemo = 0; + ud.reccnt = 0; + kclose(recfilep); + ps[myconnectindex].gm |= MODE_MENU; + break; + } + } + + for(j=connecthead;j>=0;j=connectpoint2[j]) + { + copybufbyte(&recsync[i],&inputfifo[movefifoend[j]&(MOVEFIFOSIZ-1)][j],sizeof(input)); + movefifoend[j]++; + i++; + ud.reccnt--; + } + domovethings(); + } + + if(foundemo == 0) + drawbackground(); + else + { + nonsharedkeys(); + + j = min(max((totalclock-lockclock)*(65536/TICSPERFRAME),0),65536); + displayrooms(screenpeek,j); + displayrest(j); + + if(ud.multimode > 1 && ps[myconnectindex].gm ) + getpackets(); + } + + if( (ps[myconnectindex].gm&MODE_MENU) && (ps[myconnectindex].gm&MODE_EOL) ) + goto RECHECK; + + if (KB_KeyPressed(sc_Escape)) + { + KB_ClearKeyDown(sc_Escape); + FX_StopAllSounds(); + clearsoundlocks(); + ps[myconnectindex].gm |= MODE_MENU; + cmenu(0); + intomenusounds(); + } + + if(ps[myconnectindex].gm&MODE_TYPE) + { + typemode(); + if((ps[myconnectindex].gm&MODE_TYPE) != MODE_TYPE) + ps[myconnectindex].gm = MODE_MENU; + } + else + { + menus(); + if( ud.multimode > 1 ) + { + ControlInfo noshareinfo; + CONTROL_GetInput( &noshareinfo ); + if( BUTTON(gamefunc_SendMessage) ) + { + KB_FlushKeyboardQueue(); + CONTROL_ClearButton( gamefunc_SendMessage ); + ps[myconnectindex].gm = MODE_TYPE; + typebuf[0] = 0; + inputloc = 0; + } + } + } + + operatefta(); + + if(ud.last_camsprite != ud.camerasprite) + { + ud.last_camsprite = ud.camerasprite; + ud.camera_time = totalclock+(TICRATE*2); + } + + if (VOLUMEONE) { + if( ud.show_help == 0 && (ps[myconnectindex].gm&MODE_MENU) == 0 ) + rotatesprite((320-50)<<16,9<<16,65536L,0,BETAVERSION,0,0,2+8+16+128,0,0,xdim-1,ydim-1); + } + handleevents(); + getpackets(); + nextpage(); + + if( ps[myconnectindex].gm==MODE_END || ps[myconnectindex].gm==MODE_GAME ) + { + if(foundemo) + kclose(recfilep); + return 0; + } + } + kclose(recfilep); + +#if 0 + { + unsigned long crcv; + // sync checker + + initcrc32table(); + crc32init(&crcv); + crc32block(&crcv, (unsigned char *)wall, sizeof(wall)); + crc32block(&crcv, (unsigned char *)sector, sizeof(sector)); + crc32block(&crcv, (unsigned char *)sprite, sizeof(sprite)); + crc32finish(&crcv); + initprintf("Checksum = %08X\n",crcv); + } +#endif + + if(ps[myconnectindex].gm&MODE_MENU) goto RECHECK; + return 1; +} + +char moveloop() +{ + long i; + + if (numplayers > 1) + while (fakemovefifoplc < movefifoend[myconnectindex]) fakedomovethings(); + + getpackets(); + + if (numplayers < 2) bufferjitter = 0; + while (movefifoend[myconnectindex]-movefifoplc > bufferjitter) + { + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (movefifoplc == movefifoend[i]) break; + if (i >= 0) break; + if( domovethings() ) return 1; + } + return 0; +} + +void fakedomovethingscorrect(void) +{ + long i; + struct player_struct *p; + + if (numplayers < 2) return; + + i = ((movefifoplc-1)&(MOVEFIFOSIZ-1)); + p = &ps[myconnectindex]; + + if (p->posx == myxbak[i] && p->posy == myybak[i] && p->posz == myzbak[i] + && p->horiz == myhorizbak[i] && p->ang == myangbak[i]) return; + + myx = p->posx; omyx = p->oposx; myxvel = p->posxv; + myy = p->posy; omyy = p->oposy; myyvel = p->posyv; + myz = p->posz; omyz = p->oposz; myzvel = p->poszv; + myang = p->ang; omyang = p->oang; + mycursectnum = p->cursectnum; + myhoriz = p->horiz; omyhoriz = p->ohoriz; + myhorizoff = p->horizoff; omyhorizoff = p->ohorizoff; + myjumpingcounter = p->jumping_counter; + myjumpingtoggle = p->jumping_toggle; + myonground = p->on_ground; + myhardlanding = p->hard_landing; + myreturntocenter = p->return_to_center; + + fakemovefifoplc = movefifoplc; + while (fakemovefifoplc < movefifoend[myconnectindex]) + fakedomovethings(); + +} + +void fakedomovethings(void) +{ + input *syn; + struct player_struct *p; + long i, j, k, doubvel, fz, cz, hz, lz, x, y; + unsigned long sb_snum; + short psect, psectlotag, tempsect, backcstat; + char shrunk, spritebridge; + + syn = (input *)&inputfifo[fakemovefifoplc&(MOVEFIFOSIZ-1)][myconnectindex]; + + p = &ps[myconnectindex]; + + backcstat = sprite[p->i].cstat; + sprite[p->i].cstat &= ~257; + + sb_snum = syn->bits; + + psect = mycursectnum; + psectlotag = sector[psect].lotag; + spritebridge = 0; + + shrunk = (sprite[p->i].yrepeat < 32); + + if( ud.clipping == 0 && ( sector[psect].floorpicnum == MIRROR || psect < 0 || psect >= MAXSECTORS) ) + { + myx = omyx; + myy = omyy; + } + else + { + omyx = myx; + omyy = myy; + } + + omyhoriz = myhoriz; + omyhorizoff = myhorizoff; + omyz = myz; + omyang = myang; + + getzrange(myx,myy,myz,psect,&cz,&hz,&fz,&lz,163L,CLIPMASK0); + + j = getflorzofslope(psect,myx,myy); + + if( (lz&49152) == 16384 && psectlotag == 1 && klabs(myz-j) > PHEIGHT+(16<<8) ) + psectlotag = 0; + + if( p->aim_mode == 0 && myonground && psectlotag != 2 && (sector[psect].floorstat&2) ) + { + x = myx+(sintable[(myang+512)&2047]>>5); + y = myy+(sintable[myang&2047]>>5); + tempsect = psect; + updatesector(x,y,&tempsect); + if (tempsect >= 0) + { + k = getflorzofslope(psect,x,y); + if (psect == tempsect) + myhorizoff += mulscale16(j-k,160); + else if (klabs(getflorzofslope(tempsect,x,y)-k) <= (4<<8)) + myhorizoff += mulscale16(j-k,160); + } + } + if (myhorizoff > 0) myhorizoff -= ((myhorizoff>>3)+1); + else if (myhorizoff < 0) myhorizoff += (((-myhorizoff)>>3)+1); + + if(hz >= 0 && (hz&49152) == 49152) + { + hz &= (MAXSPRITES-1); + if (sprite[hz].statnum == 1 && sprite[hz].extra >= 0) + { + hz = 0; + cz = getceilzofslope(psect,myx,myy); + } + } + + if(lz >= 0 && (lz&49152) == 49152) + { + j = lz&(MAXSPRITES-1); + if ((sprite[j].cstat&33) == 33) + { + psectlotag = 0; + spritebridge = 1; + } + if(badguy(&sprite[j]) && sprite[j].xrepeat > 24 && klabs(sprite[p->i].z-sprite[j].z) < (84<<8) ) + { + j = getangle( sprite[j].x-myx,sprite[j].y-myy); + myxvel -= sintable[(j+512)&2047]<<4; + myyvel -= sintable[j&2047]<<4; + } + } + + if( sprite[p->i].extra <= 0 ) + { + if( psectlotag == 2 ) + { + if(p->on_warping_sector == 0) + { + if( klabs(myz-fz) > (PHEIGHT>>1)) + myz += 348; + } + clipmove(&myx,&myy,&myz,&mycursectnum,0,0,164L,(4L<<8),(4L<<8),CLIPMASK0); + } + + updatesector(myx,myy,&mycursectnum); + pushmove(&myx,&myy,&myz,&mycursectnum,128L,(4L<<8),(20L<<8),CLIPMASK0); + + myhoriz = 100; + myhorizoff = 0; + + goto ENDFAKEPROCESSINPUT; + } + + doubvel = TICSPERFRAME; + + if(p->on_crane >= 0) goto FAKEHORIZONLY; + + if(p->one_eighty_count < 0) myang += 128; + + i = 40; + + if( psectlotag == 2) + { + myjumpingcounter = 0; + + if ( sb_snum&1 ) + { + if(myzvel > 0) myzvel = 0; + myzvel -= 348; + if(myzvel < -(256*6)) myzvel = -(256*6); + } + else if (sb_snum&(1<<1)) + { + if(myzvel < 0) myzvel = 0; + myzvel += 348; + if(myzvel > (256*6)) myzvel = (256*6); + } + else + { + if(myzvel < 0) + { + myzvel += 256; + if(myzvel > 0) + myzvel = 0; + } + if(myzvel > 0) + { + myzvel -= 256; + if(myzvel < 0) + myzvel = 0; + } + } + + if(myzvel > 2048) myzvel >>= 1; + + myz += myzvel; + + if(myz > (fz-(15<<8)) ) + myz += ((fz-(15<<8))-myz)>>1; + + if(myz < (cz+(4<<8)) ) + { + myz = cz+(4<<8); + myzvel = 0; + } + } + + else if(p->jetpack_on) + { + myonground = 0; + myjumpingcounter = 0; + myhardlanding = 0; + + if(p->jetpack_on < 11) + myz -= (p->jetpack_on<<7); //Goin up + + if(shrunk) j = 512; + else j = 2048; + + if (sb_snum&1) //A + myz -= j; + if (sb_snum&(1<<1)) //Z + myz += j; + + if(shrunk == 0 && ( psectlotag == 0 || psectlotag == 2 ) ) k = 32; + else k = 16; + + if(myz > (fz-(k<<8)) ) + myz += ((fz-(k<<8))-myz)>>1; + if(myz < (cz+(18<<8)) ) + myz = cz+(18<<8); + } + else if( psectlotag != 2 ) + { + if (psectlotag == 1 && p->spritebridge == 0) + { + if(shrunk == 0) i = 34; + else i = 12; + } + if(myz < (fz-(i<<8)) && (floorspace(psect)|ceilingspace(psect)) == 0 ) //falling + { + if( (sb_snum&3) == 0 && myonground && (sector[psect].floorstat&2) && myz >= (fz-(i<<8)-(16<<8) ) ) + myz = fz-(i<<8); + else + { + myonground = 0; + + myzvel += (gc+80); + + if(myzvel >= (4096+2048)) myzvel = (4096+2048); + } + } + + else + { + if(psectlotag != 1 && psectlotag != 2 && myonground == 0 && myzvel > (6144>>1)) + myhardlanding = myzvel>>10; + myonground = 1; + + if(i==40) + { + //Smooth on the ground + + k = ((fz-(i<<8))-myz)>>1; + if( klabs(k) < 256 ) k = 0; + myz += k; // ((fz-(i<<8))-myz)>>1; + myzvel -= 768; // 412; + if(myzvel < 0) myzvel = 0; + } + else if(myjumpingcounter == 0) + { + myz += ((fz-(i<<7))-myz)>>1; //Smooth on the water + if(p->on_warping_sector == 0 && myz > fz-(16<<8)) + { + myz = fz-(16<<8); + myzvel >>= 1; + } + } + + if( sb_snum&2 ) + myz += (2048+768); + + if( (sb_snum&1) == 0 && myjumpingtoggle == 1) + myjumpingtoggle = 0; + + else if( (sb_snum&1) && myjumpingtoggle == 0 ) + { + if( myjumpingcounter == 0 ) + if( (fz-cz) > (56<<8) ) + { + myjumpingcounter = 1; + myjumpingtoggle = 1; + } + } + if( myjumpingcounter && (sb_snum&1) == 0 ) + myjumpingcounter = 0; + } + + if(myjumpingcounter) + { + if( (sb_snum&1) == 0 && myjumpingtoggle == 1) + myjumpingtoggle = 0; + + if( myjumpingcounter < (1024+256) ) + { + if(psectlotag == 1 && myjumpingcounter > 768) + { + myjumpingcounter = 0; + myzvel = -512; + } + else + { + myzvel -= (sintable[(2048-128+myjumpingcounter)&2047])/12; + myjumpingcounter += 180; + + myonground = 0; + } + } + else + { + myjumpingcounter = 0; + myzvel = 0; + } + } + + myz += myzvel; + + if(myz < (cz+(4<<8)) ) + { + myjumpingcounter = 0; + if(myzvel < 0) myxvel = myyvel = 0; + myzvel = 128; + myz = cz+(4<<8); + } + + } + + if ( p->fist_incs || + p->transporter_hold > 2 || + myhardlanding || + p->access_incs > 0 || + p->knee_incs > 0 || + (p->curr_weapon == TRIPBOMB_WEAPON && + p->kickback_pic > 1 && + p->kickback_pic < 4 ) ) + { + doubvel = 0; + myxvel = 0; + myyvel = 0; + } + else if ( syn->avel ) //p->ang += syncangvel * constant + { //ENGINE calculates angvel for you + long tempang; + + tempang = syn->avel<<1; + + if(psectlotag == 2) + myang += (tempang-(tempang>>3))*ksgn(doubvel); + else myang += (tempang)*ksgn(doubvel); + myang &= 2047; + } + + if ( myxvel || myyvel || syn->fvel || syn->svel ) + { + if(p->steroids_amount > 0 && p->steroids_amount < 400) + doubvel <<= 1; + + myxvel += ((syn->fvel*doubvel)<<6); + myyvel += ((syn->svel*doubvel)<<6); + + if( ( p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && myonground ) || ( myonground && (sb_snum&2) ) ) + { + myxvel = mulscale16(myxvel,p->runspeed-0x2000); + myyvel = mulscale16(myyvel,p->runspeed-0x2000); + } + else + { + if(psectlotag == 2) + { + myxvel = mulscale16(myxvel,p->runspeed-0x1400); + myyvel = mulscale16(myyvel,p->runspeed-0x1400); + } + else + { + myxvel = mulscale16(myxvel,p->runspeed); + myyvel = mulscale16(myyvel,p->runspeed); + } + } + + if( abs(myxvel) < 2048 && abs(myyvel) < 2048 ) + myxvel = myyvel = 0; + + if( shrunk ) + { + myxvel = + mulscale16(myxvel,(p->runspeed)-(p->runspeed>>1)+(p->runspeed>>2)); + myyvel = + mulscale16(myyvel,(p->runspeed)-(p->runspeed>>1)+(p->runspeed>>2)); + } + } + +FAKEHORIZONLY: + if(psectlotag == 1 || spritebridge == 1) i = (4L<<8); else i = (20L<<8); + + clipmove(&myx,&myy,&myz,&mycursectnum,myxvel,myyvel,164L,4L<<8,i,CLIPMASK0); + pushmove(&myx,&myy,&myz,&mycursectnum,164L,4L<<8,4L<<8,CLIPMASK0); + + if( p->jetpack_on == 0 && psectlotag != 1 && psectlotag != 2 && shrunk) + myz += 30<<8; + + if ((sb_snum&(1<<18)) || myhardlanding) + myreturntocenter = 9; + + if (sb_snum&(1<<13)) + { + myreturntocenter = 9; + if (sb_snum&(1<<5)) myhoriz += 6; + myhoriz += 6; + } + else if (sb_snum&(1<<14)) + { + myreturntocenter = 9; + if (sb_snum&(1<<5)) myhoriz -= 6; + myhoriz -= 6; + } + else if (sb_snum&(1<<3)) + { + if (sb_snum&(1<<5)) myhoriz += 6; + myhoriz += 6; + } + else if (sb_snum&(1<<4)) + { + if (sb_snum&(1<<5)) myhoriz -= 6; + myhoriz -= 6; + } + + if (myreturntocenter > 0) + if ((sb_snum&(1<<13)) == 0 && (sb_snum&(1<<14)) == 0) + { + myreturntocenter--; + myhoriz += 33-(myhoriz/3); + } + + if(p->aim_mode) + myhoriz += syn->horz>>1; + else + { + if( myhoriz > 95 && myhoriz < 105) myhoriz = 100; + if( myhorizoff > -5 && myhorizoff < 5) myhorizoff = 0; + } + + if (myhardlanding > 0) + { + myhardlanding--; + myhoriz -= (myhardlanding<<4); + } + + if (myhoriz > 299) myhoriz = 299; + else if (myhoriz < -99) myhoriz = -99; + + if(p->knee_incs > 0) + { + myhoriz -= 48; + myreturntocenter = 9; + } + + +ENDFAKEPROCESSINPUT: + + myxbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myx; + myybak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myy; + myzbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myz; + myangbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myang; + myhorizbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myhoriz; + fakemovefifoplc++; + + sprite[p->i].cstat = backcstat; +} + +char domovethings(void) +{ + short i, j, k; + char ch; + + long p; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + if( sync[i].bits&(1<<17) ) + { + multiflag = 2; + multiwhat = (sync[i].bits>>18)&1; + multipos = (unsigned) (sync[i].bits>>19)&15; + multiwho = i; + + if( multiwhat ) + { + saveplayer( multipos ); + multiflag = 0; + + if(multiwho != myconnectindex) + { + strcpy(fta_quotes[122],&ud.user_name[multiwho][0]); + strcat(fta_quotes[122]," SAVED A MULTIPLAYER GAME"); + FTA(122,&ps[myconnectindex]); + } + else + { + strcpy(fta_quotes[122],"MULTIPLAYER GAME SAVED"); + FTA(122,&ps[myconnectindex]); + } + break; + } + else + { + // waitforeverybody(); + + j = loadplayer( multipos ); + + multiflag = 0; + + if(j == 0) + { + if(multiwho != myconnectindex) + { + strcpy(fta_quotes[122],&ud.user_name[multiwho][0]); + strcat(fta_quotes[122]," LOADED A MULTIPLAYER GAME"); + FTA(122,&ps[myconnectindex]); + } + else + { + strcpy(fta_quotes[122],"MULTIPLAYER GAME LOADED"); + FTA(122,&ps[myconnectindex]); + } + return 1; + } + } + } + + ud.camerasprite = -1; + lockclock += TICSPERFRAME; + + if(earthquaketime > 0) earthquaketime--; + if(rtsplaying > 0) rtsplaying--; + + for(i=0;i 0 ) + { + show_shareware--; + if(show_shareware == 0) + { + pus = NUMPAGES; + pub = NUMPAGES; + } + } + + everyothertime++; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + copybufbyte(&inputfifo[movefifoplc&(MOVEFIFOSIZ-1)][i],&sync[i],sizeof(input)); + movefifoplc++; + + updateinterpolations(); + + j = -1; + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if ((sync[i].bits&(1<<26)) == 0) { j = i; continue; } + + closedemowrite(); + + if (i == myconnectindex) gameexit(" "); + if (screenpeek == i) + { + screenpeek = connectpoint2[i]; + if (screenpeek < 0) screenpeek = connecthead; + } + + if (i == connecthead) connecthead = connectpoint2[connecthead]; + else connectpoint2[j] = connectpoint2[i]; + + numplayers--; + ud.multimode--; + + if (numplayers < 2) + sound(GENERIC_AMBIENCE17); + + pub = NUMPAGES; + pus = NUMPAGES; + vscrn(); + + Bsprintf(buf,"%s is history!",ud.user_name[i]); + + quickkill(&ps[i]); + deletesprite(ps[i].i); + + adduserquote(buf); + + if(j < 0 && networkmode == 0 ) + gameexit( " \nThe 'MASTER/First player' just quit the game. All\nplayers are returned from the game. This only happens in 5-8\nplayer mode as a different network scheme is used."); + } + + if ((numplayers >= 2) && ((movefifoplc&7) == 7)) + { + ch = (char)(randomseed&255); + for(i=connecthead;i>=0;i=connectpoint2[i]) + ch += ((ps[i].posx+ps[i].posy+ps[i].posz+ps[i].ang+ps[i].horiz)&255); + syncval[myconnectindex][syncvalhead[myconnectindex]&(MOVEFIFOSIZ-1)] = ch; + syncvalhead[myconnectindex]++; + } + + if(ud.recstat == 1) record(); + + if( ud.pause_on == 0 ) + { + global_random = TRAND; + movedummyplayers();//ST 13 + } + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + cheatkeys(i); + + if( ud.pause_on == 0 ) + { + processinput(i); + checksectors(i); + } + } + + if( ud.pause_on == 0 ) + { + + movefta(); //ST 2 + moveweapons(); //ST 5 (must be last) + movetransports(); //ST 9 + + moveplayers(); //ST 10 + movefallers(); //ST 12 + moveexplosions(); //ST 4 + + moveactors(); //ST 1 + moveeffectors(); //ST 3 + + movestandables(); //ST 6 + + for (k=0;k= 0) + { + j = nextspritestat[i]; + OnEvent(EVENT_GAME,i, findplayer(&sprite[i],&p), p); + i = j; + } + } + + doanimations(); + movefx(); //ST 11 + } + + fakedomovethingscorrect(); + + if( (everyothertime&1) == 0) + { + animatewalls(); + movecyclers(); + pan3dsound(); + } + return 0; +} + +void doorders(void) +{ + short i; + + setview(0,0,xdim-1,ydim-1); + + fadepal(0,0,0, 0,63,7); + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 1); // JBF 20040308 + KB_FlushKeyboardQueue(); + rotatesprite(0,0,65536L,0,ORDERING,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + fadepal(0,0,0, 63,0,-7); + while( !KB_KeyWaiting() ) { handleevents(); getpackets(); } + + fadepal(0,0,0, 0,63,7); + KB_FlushKeyboardQueue(); + rotatesprite(0,0,65536L,0,ORDERING+1,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + fadepal(0,0,0, 63,0,-7); + while( !KB_KeyWaiting() ) { handleevents(); getpackets(); } + + fadepal(0,0,0, 0,63,7); + KB_FlushKeyboardQueue(); + rotatesprite(0,0,65536L,0,ORDERING+2,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + fadepal(0,0,0, 63,0,-7); + while( !KB_KeyWaiting() ) { handleevents(); getpackets(); } + + fadepal(0,0,0, 0,63,7); + KB_FlushKeyboardQueue(); + rotatesprite(0,0,65536L,0,ORDERING+3,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + fadepal(0,0,0, 63,0,-7); + while( !KB_KeyWaiting() ) { handleevents(); getpackets(); } +} + +void dobonus(char bonusonly) +{ + short t, r, tinc,gfx_offset; + long i, y,xfragtotal,yfragtotal; + short bonuscnt; + int clockpad = 2; + char *lastmapname; + long breathe[] = + { + 0, 30,VICTORY1+1,176,59, + 30, 60,VICTORY1+2,176,59, + 60, 90,VICTORY1+1,176,59, + 90, 120,0 ,176,59 + }; + + long bossmove[] = + { + 0, 120,VICTORY1+3,86,59, + 220, 260,VICTORY1+4,86,59, + 260, 290,VICTORY1+5,86,59, + 290, 320,VICTORY1+6,86,59, + 320, 350,VICTORY1+7,86,59, + 350, 380,VICTORY1+8,86,59 + }; + + if (ud.volume_number == 0 && ud.last_level == 8 && boardfilename[0]) { + lastmapname = Bstrrchr(boardfilename,'\\'); + if (!lastmapname) lastmapname = Bstrrchr(boardfilename,'/'); + if (!lastmapname) lastmapname = boardfilename; + } else lastmapname = level_names[(ud.volume_number*11)+ud.last_level-1]; + + bonuscnt = 0; + + fadepal(0,0,0, 0,64,7); + setview(0,0,xdim-1,ydim-1); + clearview(0L); + nextpage(); + flushperms(); + + FX_StopAllSounds(); + clearsoundlocks(); + FX_SetReverb(0L); + + if(bonusonly) goto FRAGBONUS; + + if(numplayers < 2 && ud.eog && ud.from_bonus == 0) + switch(ud.volume_number) + { + case 0: + if(ud.lockout == 0) + { + setgamepalette(&ps[myconnectindex], endingpal, 3); // JBF 20040308 + clearview(0L); + rotatesprite(0,50<<16,65536L,0,VICTORY1,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + nextpage(); + //ps[myconnectindex].palette = endingpal; + fadepal(0,0,0, 63,0,-1); + + KB_FlushKeyboardQueue(); + totalclock = 0; tinc = 0; + while( 1 ) + { + clearview(0L); + rotatesprite(0,50<<16,65536L,0,VICTORY1,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + + // boss + if( totalclock > 390 && totalclock < 780 ) + for(t=0;t<35;t+=5) if( bossmove[t+2] && (totalclock%390) > bossmove[t] && (totalclock%390) <= bossmove[t+1] ) + { + if(t==10 && bonuscnt == 1) { sound(SHOTGUN_FIRE);sound(SQUISHED); bonuscnt++; } + rotatesprite(bossmove[t+3]<<16,bossmove[t+4]<<16,65536L,0,bossmove[t+2],0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + } + + // Breathe + if( totalclock < 450 || totalclock >= 750 ) + { + if(totalclock >= 750) + { + rotatesprite(86<<16,59<<16,65536L,0,VICTORY1+8,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + if(totalclock >= 750 && bonuscnt == 2) { sound(DUKETALKTOBOSS); bonuscnt++; } + } + for(t=0;t<20;t+=5) + if( breathe[t+2] && (totalclock%120) > breathe[t] && (totalclock%120) <= breathe[t+1] ) + { + if(t==5 && bonuscnt == 0) + { + sound(BOSSTALKTODUKE); + bonuscnt++; + } + rotatesprite(breathe[t+3]<<16,breathe[t+4]<<16,65536L,0,breathe[t+2],0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + } + } + handleevents(); + getpackets(); + nextpage(); + if( KB_KeyWaiting() ) break; + } + } + + fadepal(0,0,0, 0,64,1); + + KB_FlushKeyboardQueue(); + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 + + rotatesprite(0,0,65536L,0,3292,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + IFISSOFTMODE fadepal(0,0,0, 63,0,-1); else nextpage(); + while( !KB_KeyWaiting() ) { handleevents(); getpackets(); } + fadepal(0,0,0, 0,64,1); + MUSIC_StopSong(); + FX_StopAllSounds(); + clearsoundlocks(); + break; + case 1: + MUSIC_StopSong(); + clearview(0L); + nextpage(); + + if(ud.lockout == 0) + { + playanm("cineov2.anm",1); + KB_FlushKeyBoardQueue(); + clearview(0L); + nextpage(); + } + + sound(PIPEBOMB_EXPLODE); + + fadepal(0,0,0, 0,64,1); + setview(0,0,xdim-1,ydim-1); + KB_FlushKeyboardQueue(); + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 + rotatesprite(0,0,65536L,0,3293,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); + IFISSOFTMODE fadepal(0,0,0, 63,0,-1); else nextpage(); + while( !KB_KeyWaiting() ) { handleevents(); getpackets(); } + IFISSOFTMODE fadepal(0,0,0, 0,64,1); + + break; + + case 3: + + setview(0,0,xdim-1,ydim-1); + + MUSIC_StopSong(); + clearview(0L); + nextpage(); + + if(ud.lockout == 0) + { + KB_FlushKeyboardQueue(); + playanm("vol4e1.anm",8); + clearview(0L); + nextpage(); + playanm("vol4e2.anm",10); + clearview(0L); + nextpage(); + playanm("vol4e3.anm",11); + clearview(0L); + nextpage(); + } + + FX_StopAllSounds(); + clearsoundlocks(); + sound(ENDSEQVOL3SND4); + KB_FlushKeyBoardQueue(); + + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 + IFISSOFTMODE palto(0,0,0,63); + clearview(0L); + menutext(160,60,0,0,"THANKS TO ALL OUR"); + menutext(160,60+16,0,0,"FANS FOR GIVING"); + menutext(160,60+16+16,0,0,"US BIG HEADS."); + menutext(160,70+16+16+16,0,0,"LOOK FOR A DUKE NUKEM 3D"); + menutext(160,70+16+16+16+16,0,0,"SEQUEL SOON."); + nextpage(); + + fadepal(0,0,0, 63,0,-3); + KB_FlushKeyboardQueue(); + while(!KB_KeyWaiting()) { handleevents(); getpackets(); } + fadepal(0,0,0, 0,64,3); + + clearview(0L); + nextpage(); + + playanm("DUKETEAM.ANM",4); + + KB_FlushKeyBoardQueue(); + while(!KB_KeyWaiting()) { handleevents(); getpackets(); } + + clearview(0L); + nextpage(); + IFISSOFTMODE palto(0,0,0,63); + + FX_StopAllSounds(); + clearsoundlocks(); + KB_FlushKeyBoardQueue(); + + break; + + case 2: + + MUSIC_StopSong(); + clearview(0L); + nextpage(); + if(ud.lockout == 0) + { + fadepal(0,0,0, 63,0,-1); + playanm("cineov3.anm",2); + KB_FlushKeyBoardQueue(); + ototalclock = totalclock+200; + while(totalclock < ototalclock) { handleevents(); getpackets(); } + clearview(0L); + nextpage(); + + FX_StopAllSounds(); + clearsoundlocks(); + } + + playanm("RADLOGO.ANM",3); + + if( ud.lockout == 0 && !KB_KeyWaiting() ) + { + sound(ENDSEQVOL3SND5); + while(issoundplaying(ENDSEQVOL3SND5)) { handleevents(); getpackets(); } + if(KB_KeyWaiting()) goto ENDANM; + sound(ENDSEQVOL3SND6); + while(issoundplaying(ENDSEQVOL3SND6)) { handleevents(); getpackets(); } + if(KB_KeyWaiting()) goto ENDANM; + sound(ENDSEQVOL3SND7); + while(issoundplaying(ENDSEQVOL3SND7)) { handleevents(); getpackets(); } + if(KB_KeyWaiting()) goto ENDANM; + sound(ENDSEQVOL3SND8); + while(issoundplaying(ENDSEQVOL3SND8)) { handleevents(); getpackets(); } + if(KB_KeyWaiting()) goto ENDANM; + sound(ENDSEQVOL3SND9); + while(issoundplaying(ENDSEQVOL3SND9)) { handleevents(); getpackets(); } + } + + KB_FlushKeyBoardQueue(); + totalclock = 0; + while(!KB_KeyWaiting() && totalclock < 120) { handleevents(); getpackets(); } + +ENDANM: + + FX_StopAllSounds(); + clearsoundlocks(); + + KB_FlushKeyBoardQueue(); + + clearview(0L); + + break; + } + +FRAGBONUS: + + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 3); // JBF 20040308 + IFISSOFTMODE palto(0,0,0,63); // JBF 20031228 + KB_FlushKeyboardQueue(); + totalclock = 0; tinc = 0; + bonuscnt = 0; + + MUSIC_StopSong(); + FX_StopAllSounds(); + clearsoundlocks(); + + if(playerswhenstarted > 1 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_SCORESHEET)) + { + if(!(MusicToggle == 0 || MusicDevice < 0)) + sound(BONUSMUSIC); + + rotatesprite(0,0,65536L,0,MENUSCREEN,16,0,2+8+16+64,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,34<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite((260)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,0,0,2+8,0,0,xdim-1,ydim-1); + gametext(160,58+2,"MULTIPLAYER TOTALS",0,2+8+16); + gametext(160,58+10,level_names[(ud.volume_number*11)+ud.last_level-1],0,2+8+16); + + gametext(160,165,"PRESS ANY KEY TO CONTINUE",0,2+8+16); + + + t = 0; + minitext(23,80," NAME KILLS",8,2+8+16+128); + for(i=0;i 1) return; + + fadepal(0,0,0, 0,64,7); + } + + if(bonusonly || ud.multimode > 1) return; + + switch(ud.volume_number) + { + case 1: + gfx_offset = 5; + break; + default: + gfx_offset = 0; + break; + } + + rotatesprite(0,0,65536L,0,BONUSSCREEN+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + + menutext(160,20-6,0,0,lastmapname); + menutext(160,36-6,0,0,"COMPLETED"); + + gametext(160,192,"PRESS ANY KEY TO CONTINUE",16,2+8+16); + + if(!(MusicToggle == 0 || MusicDevice < 0)) + sound(BONUSMUSIC); + + nextpage(); + KB_FlushKeyboardQueue(); + fadepal(0,0,0, 63,0,-1); + bonuscnt = 0; + totalclock = 0; tinc = 0; + + { + int ii, ij; + + for (ii=ps[myconnectindex].player_par/(26*60), ij=1; ii>9; ii/=10, ij++) ; + clockpad = max(clockpad,ij); + for (ii=partime[ud.volume_number*11+ud.last_level-1]/(26*60), ij=1; ii>9; ii/=10, ij++) ; + clockpad = max(clockpad,ij); + for (ii=designertime[ud.volume_number*11+ud.last_level-1]/(26*60), ij=1; ii>9; ii/=10, ij++) ; + clockpad = max(clockpad,ij); + } + + while( 1 ) + { + handleevents(); + AudioUpdate(); + + if(ps[myconnectindex].gm&MODE_EOL) + { + rotatesprite(0,0,65536L,0,BONUSSCREEN+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + + if( totalclock > (1000000000L) && totalclock < (1000000320L) ) + { + switch( (totalclock>>4)%15 ) + { + case 0: + if(bonuscnt == 6) + { + bonuscnt++; + sound(SHOTGUN_COCK); + switch(rand()&3) + { + case 0: + sound(BONUS_SPEECH1); + break; + case 1: + sound(BONUS_SPEECH2); + break; + case 2: + sound(BONUS_SPEECH3); + break; + case 3: + sound(BONUS_SPEECH4); + break; + } + } + case 1: + case 4: + case 5: + rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+3+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + break; + case 2: + case 3: + rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+4+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + break; + } + } + else if( totalclock > (10240+120L) ) break; + else + { + switch( (totalclock>>5)&3 ) + { + case 1: + case 3: + rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+1+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + break; + case 2: + rotatesprite(199<<16,31<<16,65536L,0,BONUSSCREEN+2+gfx_offset,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); + break; + } + } + + menutext(160,20-6,0,0,lastmapname); + menutext(160,36-6,0,0,"COMPLETED"); + + gametext(160,192,"PRESS ANY KEY TO CONTINUE",16,2+8+16); + + if( totalclock > (60*3) ) + { + gametext(10,59+9,"Your Time:",0,2+8+16); + gametext(10,69+9,"Par time:",0,2+8+16); + gametext(10,78+9,"3D Realms' Time:",0,2+8+16); + if(bonuscnt == 0) + bonuscnt++; + + if( totalclock > (60*4) ) + { + if(bonuscnt == 1) + { + bonuscnt++; + sound(PIPEBOMB_EXPLODE); + } + + Bsprintf(tempbuf,"%0*ld:%02ld",clockpad, + (ps[myconnectindex].player_par/(26*60)), + (ps[myconnectindex].player_par/26)%60); + gametext((320>>2)+71,60+9,tempbuf,0,2+8+16); + + Bsprintf(tempbuf,"%0*ld:%02ld",clockpad, + (partime[ud.volume_number*11+ud.last_level-1]/(26*60)), + (partime[ud.volume_number*11+ud.last_level-1]/26)%60); + gametext((320>>2)+71,69+9,tempbuf,0,2+8+16); + + Bsprintf(tempbuf,"%0*ld:%02ld",clockpad, + (designertime[ud.volume_number*11+ud.last_level-1]/(26*60)), + (designertime[ud.volume_number*11+ud.last_level-1]/26)%60); + gametext((320>>2)+71,78+9,tempbuf,0,2+8+16); + + } + } + if( totalclock > (60*6) ) + { + gametext(10,94+9,"Enemies Killed:",0,2+8+16); + gametext(10,99+4+9,"Enemies Left:",0,2+8+16); + + if(bonuscnt == 2) + { + bonuscnt++; + sound(FLY_BY); + } + + if( totalclock > (60*7) ) + { + if(bonuscnt == 3) + { + bonuscnt++; + sound(PIPEBOMB_EXPLODE); + } + Bsprintf(tempbuf,"%-3ld",ps[myconnectindex].actors_killed); + gametext((320>>2)+70,93+9,tempbuf,0,2+8+16); + if(ud.player_skill > 3 ) + { + Bsprintf(tempbuf,"N/A"); + gametext((320>>2)+70,99+4+9,tempbuf,0,2+8+16); + } + else + { + if( (ps[myconnectindex].max_actors_killed-ps[myconnectindex].actors_killed) < 0 ) + Bsprintf(tempbuf,"%-3d",0); + else Bsprintf(tempbuf,"%-3ld",ps[myconnectindex].max_actors_killed-ps[myconnectindex].actors_killed); + gametext((320>>2)+70,99+4+9,tempbuf,0,2+8+16); + } + } + } + if( totalclock > (60*9) ) + { + gametext(10,120+9,"Secrets Found:",0,2+8+16); + gametext(10,130+9,"Secrets Missed:",0,2+8+16); + if(bonuscnt == 4) bonuscnt++; + + if( totalclock > (60*10) ) + { + if(bonuscnt == 5) + { + bonuscnt++; + sound(PIPEBOMB_EXPLODE); + } + Bsprintf(tempbuf,"%-3ld",ps[myconnectindex].secret_rooms); + gametext((320>>2)+70,120+9,tempbuf,0,2+8+16); + if( ps[myconnectindex].secret_rooms > 0 ) + Bsprintf(tempbuf,"%-3ld%%",(100*ps[myconnectindex].secret_rooms/ps[myconnectindex].max_secret_rooms)); + Bsprintf(tempbuf,"%-3ld",ps[myconnectindex].max_secret_rooms-ps[myconnectindex].secret_rooms); + gametext((320>>2)+70,130+9,tempbuf,0,2+8+16); + } + } + + if(totalclock > 10240 && totalclock < 10240+10240) + totalclock = 1024; + + if( ( (MOUSE_GetButtons()&7) || KB_KeyWaiting() ) && totalclock > (60*2) ) // JBF 20030809 + { + MOUSE_ClearButton(7); + if( KB_KeyPressed( sc_F12 ) ) + { + KB_ClearKeyDown( sc_F12 ); + screencapture("eduke0000.tga",0); + } + + if( totalclock < (60*13) ) + { + KB_FlushKeyboardQueue(); + totalclock = (60*13); + } + else if( totalclock < (1000000000L)) + totalclock = (1000000000L); + } + } + else break; + nextpage(); + } +} + +void cameratext(short i) +{ + char flipbits; + long x , y; + + if(!T1) + { + rotatesprite(24<<16,33<<16,65536L,0,CAMCORNER,0,0,2,windowx1,windowy1,windowx2,windowy2); + rotatesprite((320-26)<<16,34<<16,65536L,0,CAMCORNER+1,0,0,2,windowx1,windowy1,windowx2,windowy2); + rotatesprite(22<<16,163<<16,65536L,512,CAMCORNER+1,0,0,2+4,windowx1,windowy1,windowx2,windowy2); + rotatesprite((310-10)<<16,163<<16,65536L,512,CAMCORNER+1,0,0,2,windowx1,windowy1,windowx2,windowy2); + if(totalclock&16) + rotatesprite(46<<16,32<<16,65536L,0,CAMLIGHT,0,0,2,windowx1,windowy1,windowx2,windowy2); + } + else + { + flipbits = (totalclock<<1)&48; + for(x=0;x<394;x+=64) + for(y=0;y<200;y+=64) + rotatesprite(x<<16,y<<16,65536L,0,STATIC,0,0,2+flipbits,windowx1,windowy1,windowx2,windowy2); + } +} + +void vglass(long x,long y,short a,short wn,short n) +{ + long z, zincs; + short sect; + + sect = wall[wn].nextsector; + if(sect == -1) return; + zincs = ( sector[sect].floorz-sector[sect].ceilingz ) / n; + + for(z = sector[sect].ceilingz;z < sector[sect].floorz; z += zincs ) + EGS(sect,x,y,z-(TRAND&8191),GLASSPIECES+(z&(TRAND%3)),-32,36,36,a+128-(TRAND&255),16+(TRAND&31),0,-1,5); +} + +void lotsofglass(short i,short wallnum,short n) +{ + long j, xv, yv, z, x1, y1; + short sect, a; + + sect = -1; + + if(wallnum < 0) + { + for(j=n-1; j >= 0 ;j--) + { + a = SA-256+(TRAND&511)+1024; + EGS(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,a,32+(TRAND&63),1024-(TRAND&1023),i,5); + } + return; + } + + j = n+1; + + x1 = wall[wallnum].x; + y1 = wall[wallnum].y; + + xv = wall[wall[wallnum].point2].x-x1; + yv = wall[wall[wallnum].point2].y-y1; + + x1 -= ksgn(yv); + y1 += ksgn(xv); + + xv /= j; + yv /= j; + + for(j=n;j>0;j--) + { + x1 += xv; + y1 += yv; + + updatesector(x1,y1,§); + if(sect >= 0) + { + z = sector[sect].floorz-(TRAND&(klabs(sector[sect].ceilingz-sector[sect].floorz))); + if( z < -(32<<8) || z > (32<<8) ) + z = SZ-(32<<8)+(TRAND&((64<<8)-1)); + a = SA-1024; + EGS(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(TRAND&63),-(TRAND&1023),i,5); + } + } +} + +void spriteglass(short i,short n) +{ + long j, k, a, z; + + for(j=n;j>0;j--) + { + a = TRAND&2047; + z = SZ-((TRAND&16)<<8); + k = EGS(SECT,SX,SY,z,GLASSPIECES+(j%3),TRAND&15,36,36,a,32+(TRAND&63),-512-(TRAND&2047),i,5); + sprite[k].pal = sprite[i].pal; + } +} + +void ceilingglass(short i,short sectnum,short n) +{ + long j, xv, yv, z, x1, y1; + short a,s, startwall,endwall; + + startwall = sector[sectnum].wallptr; + endwall = startwall+sector[sectnum].wallnum; + + for(s=startwall;s<(endwall-1);s++) + { + x1 = wall[s].x; + y1 = wall[s].y; + + xv = (wall[s+1].x-x1)/(n+1); + yv = (wall[s+1].y-y1)/(n+1); + + for(j=n;j>0;j--) + { + x1 += xv; + y1 += yv; + a = TRAND&2047; + z = sector[sectnum].ceilingz+((TRAND&15)<<8); + EGS(sectnum,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,(TRAND&31),0,i,5); + } + } +} + + +void lotsofcolourglass(short i,short wallnum,short n) +{ + long j, xv, yv, z, x1, y1; + short sect = -1, a, k; + + if(wallnum < 0) + { + for(j=n-1; j >= 0 ;j--) + { + a = TRAND&2047; + k = EGS(SECT,SX,SY,SZ-(TRAND&(63<<8)),GLASSPIECES+(j%3),-32,36,36,a,32+(TRAND&63),1024-(TRAND&2047),i,5); + sprite[k].pal = TRAND&15; + } + return; + } + + j = n+1; + x1 = wall[wallnum].x; + y1 = wall[wallnum].y; + + xv = (wall[wall[wallnum].point2].x-wall[wallnum].x)/j; + yv = (wall[wall[wallnum].point2].y-wall[wallnum].y)/j; + + for(j=n;j>0;j--) + { + x1 += xv; + y1 += yv; + + updatesector(x1,y1,§); + z = sector[sect].floorz-(TRAND&(klabs(sector[sect].ceilingz-sector[sect].floorz))); + if( z < -(32<<8) || z > (32<<8) ) + z = SZ-(32<<8)+(TRAND&((64<<8)-1)); + a = SA-1024; + k = EGS(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(TRAND&63),-(TRAND&2047),i,5); + sprite[k].pal = TRAND&7; + } +} + +void SetupGameButtons( void ) +{ + CONTROL_DefineFlag(gamefunc_Move_Forward,false); + CONTROL_DefineFlag(gamefunc_Move_Backward,false); + CONTROL_DefineFlag(gamefunc_Turn_Left,false); + CONTROL_DefineFlag(gamefunc_Turn_Right,false); + CONTROL_DefineFlag(gamefunc_Strafe,false); + CONTROL_DefineFlag(gamefunc_Fire,false); + CONTROL_DefineFlag(gamefunc_Open,false); + CONTROL_DefineFlag(gamefunc_Run,false); + CONTROL_DefineFlag(gamefunc_AutoRun,false); + CONTROL_DefineFlag(gamefunc_Jump,false); + CONTROL_DefineFlag(gamefunc_Crouch,false); + CONTROL_DefineFlag(gamefunc_Look_Up,false); + CONTROL_DefineFlag(gamefunc_Look_Down,false); + CONTROL_DefineFlag(gamefunc_Look_Left,false); + CONTROL_DefineFlag(gamefunc_Look_Right,false); + CONTROL_DefineFlag(gamefunc_Strafe_Left,false); + CONTROL_DefineFlag(gamefunc_Strafe_Right,false); + CONTROL_DefineFlag(gamefunc_Aim_Up,false); + CONTROL_DefineFlag(gamefunc_Aim_Down,false); + CONTROL_DefineFlag(gamefunc_Weapon_1,false); + CONTROL_DefineFlag(gamefunc_Weapon_2,false); + CONTROL_DefineFlag(gamefunc_Weapon_3,false); + CONTROL_DefineFlag(gamefunc_Weapon_4,false); + CONTROL_DefineFlag(gamefunc_Weapon_5,false); + CONTROL_DefineFlag(gamefunc_Weapon_6,false); + CONTROL_DefineFlag(gamefunc_Weapon_7,false); + CONTROL_DefineFlag(gamefunc_Weapon_8,false); + CONTROL_DefineFlag(gamefunc_Weapon_9,false); + CONTROL_DefineFlag(gamefunc_Weapon_10,false); + CONTROL_DefineFlag(gamefunc_Inventory,false); + CONTROL_DefineFlag(gamefunc_Inventory_Left,false); + CONTROL_DefineFlag(gamefunc_Inventory_Right,false); + CONTROL_DefineFlag(gamefunc_Holo_Duke,false); + CONTROL_DefineFlag(gamefunc_Jetpack,false); + CONTROL_DefineFlag(gamefunc_NightVision,false); + CONTROL_DefineFlag(gamefunc_MedKit,false); + CONTROL_DefineFlag(gamefunc_TurnAround,false); + CONTROL_DefineFlag(gamefunc_SendMessage,false); + CONTROL_DefineFlag(gamefunc_Map,false); + CONTROL_DefineFlag(gamefunc_Shrink_Screen,false); + CONTROL_DefineFlag(gamefunc_Enlarge_Screen,false); + CONTROL_DefineFlag(gamefunc_Center_View,false); + CONTROL_DefineFlag(gamefunc_Holster_Weapon,false); + CONTROL_DefineFlag(gamefunc_Show_Opponents_Weapon,false); + CONTROL_DefineFlag(gamefunc_Map_Follow_Mode,false); + CONTROL_DefineFlag(gamefunc_See_Coop_View,false); + CONTROL_DefineFlag(gamefunc_Mouse_Aiming,false); + CONTROL_DefineFlag(gamefunc_Toggle_Crosshair,false); + CONTROL_DefineFlag(gamefunc_Steroids,false); + CONTROL_DefineFlag(gamefunc_Quick_Kick,false); + CONTROL_DefineFlag(gamefunc_Next_Weapon,false); + CONTROL_DefineFlag(gamefunc_Previous_Weapon,false); +} + +/* +=================== += += GetTime += +=================== +*/ + +long GetTime(void) +{ + return totalclock; +} + +/* +=================== += += 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"); +} + diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c new file mode 100644 index 000000000..785e17f45 --- /dev/null +++ b/polymer/eduke32/source/gamedef.c @@ -0,0 +1,5992 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "duke3d.h" +#include "gamedef.h" + +#include "osd.h" + +int conversion = 13; + +static char compilefile[BMAX_PATH] = "(none)"; // file we're currently compiling +static char parsing_item_name[MAXVARLABEL] = "(none)", previous_item_name[MAXVARLABEL] = "NULL"; + +static short total_lines,line_number; +static char checking_ifelse,parsing_state; +char g_szBuf[1024]; + +long *casescriptptr=NULL; // the pointer to the start of the case table in a switch statement +// first entry is 'default' code. +int casecount = 0; +signed char checking_switch = 0, current_event = -1; +char labelsonly = 0, nokeywordcheck = 0, dynamicremap = 0; +static short num_braces = 0; // init to some sensible defaults + +char redefined_fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; +int redefined_quotes = 0; + +long *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine +long *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) +long *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire +long *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) +long *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. +long *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon +long *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots +long *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item +long *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn +long *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst' +long *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like +long *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when initialy firing. zero for no sound +long *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic) +long *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time +long *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID +long *aplWeaponRenderSize[MAX_WEAPONS]; // size of weapon sprite, 0 = normal, 1 = half size (RR style) +long *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed +long *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted + +int g_iReturnVarID=-1; // var ID of "RETURN" +int g_iWeaponVarID=-1; // var ID of "WEAPON" +int g_iWorksLikeVarID=-1; // var ID of "WORKSLIKE" +int g_iZRangeVarID=-1; // var ID of "ZRANGE" +int g_iAngRangeVarID=-1; // var ID of "ANGRANGE" +int g_iAimAngleVarID=-1; // var ID of "AUTOAIMANGLE" +int g_iLoTagID=-1; // var ID of "LOTAG" +int g_iHiTagID=-1; // var ID of "HITAG" +int g_iTextureID=-1; // var ID of "TEXTURE" +int g_iThisActorID=-1; // var ID of "THISACTOR" + +long *actorLoadEventScrptr[MAXTILES]; + +long *apScriptGameEvent[MAXGAMEEVENTS]; +long *parsing_event=NULL; + +MATTGAMEVAR aGameVars[MAXGAMEVARS]; +int iGameVarCount=0; + +MATTGAMEVAR aDefaultGameVars[MAXGAMEVARS]; // the 'original' values +int iDefaultGameVarCount=0; + +void ReportError(int iError); +void FreeGameVars(void); + +extern long qsetmode; + +enum errors { + ERROR_CLOSEBRACKET, + ERROR_EVENTONLY, + ERROR_EXCEEDSMAXTILES, + ERROR_EXPECTEDKEYWORD, + ERROR_FOUNDWITHIN, + ERROR_ISAKEYWORD, + ERROR_NOENDSWITCH, + ERROR_NOTAGAMEDEF, + ERROR_NOTAGAMEVAR, + ERROR_OPENBRACKET, + ERROR_PARAMUNDEFINED, + ERROR_SYMBOLNOTRECOGNIZED, + ERROR_SYNTAXERROR, + ERROR_VARREADONLY, + ERROR_VARTYPEMISMATCH, + WARNING_DUPLICATEDEFINITION, + WARNING_EVENTSYNC, + WARNING_LABELSONLY, +}; + +enum labeltypes { + LABEL_ANY = -1, + LABEL_ACTION = 1, + LABEL_AI = 2, + LABEL_DEFINE = 4, + LABEL_MOVE = 8, + LABEL_STATE = 16, +}; + +static char *labeltypenames[] = { + "define", + "state", + "actor", + "action", + "ai", + "move" + }; + +static char *translatelabeltype(long type) +{ + int i; + char x[64]; + + x[0] = 0; + for (i=0;i<6;i++) { + if (!(type & (1<pals_time and p->pals[0-2] + "sound", // 15 plays a sound that was defined with definesound + "fall", // 16 causes actor to fall to sector floor height + "state", // 17 begins defining a state if used outside a state or actor, otherwise calls a state + "ends", // 18 ends defining a state + "define", // 19 defines a value + "", // 20 was previously used to define a comment + "ifai", // 21 checks if actor is currently performing a specific ai function + "killit", // 22 kills an actor + "addweapon", // 23 adds a weapon to the closest player + "ai", // 24 sets an ai function to be used by an actor + "addphealth", // 25 adds health to the player + "ifdead", // 26 checks if actor is dead + "ifsquished", // 27 checks if actor has been squished + "sizeto", // 28 gradually increases actor size until it matches parameters given + "{", // 29 used to indicate segments of code + "}", // 30 used to indicate segments of code + "spawn", // 31 spawns an actor + "move", // 32 + "ifwasweapon", // 33 + "ifaction", // 34 + "ifactioncount", // 35 + "resetactioncount", // 36 + "debris", // 37 + "pstomp", // 38 + "", // 39 was previously used to define the start of a comment block + "cstat", // 40 + "ifmove", // 41 + "resetplayer", // 42 + "ifonwater", // 43 + "ifinwater", // 44 + "ifcanshoottarget", // 45 + "ifcount", // 46 + "resetcount", // 47 + "addinventory", // 48 + "ifactornotstayput", // 49 + "hitradius", // 50 + "ifp", // 51 + "count", // 52 + "ifactor", // 53 + "music", // 54 + "include", // 55 + "ifstrength", // 56 + "definesound", // 57 + "guts", // 58 + "ifspawnedby", // 59 + "gamestartup", // 60 + "wackplayer", // 61 + "ifgapzl", // 62 + "ifhitspace", // 63 + "ifoutside", // 64 + "ifmultiplayer", // 65 + "operate", // 66 + "ifinspace", // 67 + "debug", // 68 + "endofgame", // 69 + "ifbulletnear", // 70 + "ifrespawn", // 71 + "iffloordistl", // 72 + "ifceilingdistl", // 73 + "spritepal", // 74 + "ifpinventory", // 75 + "betaname", // 76 + "cactor", // 77 + "ifphealthl", // 78 + "definequote", // 79 + "quote", // 80 + "ifinouterspace", // 81 + "ifnotmoving", // 82 + "respawnhitag", // 83 + "tip", // 84 + "ifspritepal", // 85 + "money", // 86 + "soundonce", // 87 + "addkills", // 88 + "stopsound", // 89 + "ifawayfromwall", // 90 + "ifcanseetarget", // 91 + "globalsound", // 92 + "lotsofglass", // 93 + "ifgotweaponce", // 94 + "getlastpal", // 95 + "pkick", // 96 + "mikesnd", // 97 + "useractor", // 98 + "sizeat", // 99 + "addstrength", // 100 [#] + "cstator", // 101 + "mail", // 102 + "paper", // 103 + "tossweapon", // 104 + "sleeptime", // 105 + "nullop", // 106 + "definevolumename", // 107 + "defineskillname", // 108 + "ifnosounds", // 109 + "clipdist", // 110 + "ifangdiffl", // 111 + "gamevar", // 112 + "ifvarl", // 113 + "ifvarg", // 114 + "setvarvar", // 115 + "setvar", // 116 + "addvarvar", // 117 + "addvar", // 118 + "ifvarvarl", // 119 + "ifvarvarg", // 120 + "addlogvar", // 121 + "addlog", // 122 + "onevent", // 123 + "endevent", // 124 + "ifvare", // 125 + "ifvarvare", // 126 + "spgetlotag", // 127 + "spgethitag", // 128 + "sectgetlotag", // 129 + "sectgethitag", // 130 + "ifsound", // 131 + "gettexturefloor", // 132 + "gettextureceiling", // 133 + "inittimer", // 134 + "starttrack", // 135 + "randvar", // 136 + "enhanced", // 137 + "getangletotarget", // 138 + "getactorangle", // 139 + "setactorangle", // 140 + "mulvar", // 141 + "mulvarvar", // 142 + "divvar", // 143 + "divvarvar", // 144 + "modvar", // 145 + "modvarvar", // 146 + "andvar", // 147 + "andvarvar", // 148 + "orvar", // 149 + "orvarvar", // 150 + "getplayerangle", // 151 + "setplayerangle", // 152 + "lockplayer", // 153 + "setsector", // 154 + "getsector", // 155 + "setactor", // 156 + "getactor", // 157 + "setwall", // 158 + "getwall", // 159 + "findnearactor", // 160 + "findnearactorvar", // 161 + "setactorvar", // 162 + "getactorvar", // 163 + "espawn", // 164 + "getplayer", // 165 + "setplayer", // 166 + "sqrt", // 167 + "eventloadactor", // 168 + "espawnvar", // 169 + "getuserdef", // 170 + "setuserdef", // 171 + "subvarvar", // 172 + "subvar", // 173 + "ifvarn", // 174 + "ifvarvarn", // 175 + "ifvarand", // 176 + "ifvarvarand", // 177 + "myos", // 178 + "myospal", // 179 + "displayrand", // 180 + "sin", // 181 + "xorvarvar", // 182 + "xorvar", // 183 + "randvarvar", // 184 + "myosx", // 185 + "myospalx", // 186 + "gmaxammo", // 187 + "smaxammo", // 188 + "startlevel", // 189 + "eshoot", // 190 + "qspawn", // 191 + "rotatesprite", // 192 + "defineprojectile", // 193 + "spriteshadow", // 194 + "cos", // 195 + "eshootvar", // 196 + "findnearactor3d", // 197 + "findnearactor3dvar", // 198 + "flash", // 199 + "qspawnvar", // 200 + "eqspawn", // 201 + "eqspawnvar", // 202 + "minitext", // 203 + "gametext", // 204 + "digitalnumber", // 205 + "addweaponvar", // 206 + "setprojectile", // 207 + "angoff", // 208 + "updatesector", // 209 + "insertspriteq", // 210 + "angoffvar", // 211 + "whilevarn", // 212 + "switch", // 213 + "case", // 214 + "default", // 215 + "endswitch", // 216 + "shootvar", // 217 + "soundvar", // 218 + "findplayer", // 219 + "findotherplayer", // 220 + "activatebysector", // 221 sectnum, spriteid + "operatesectors", // 222 sectnum, spriteid + "operaterespawns", // 223 lotag + "operateactivators", // 224 lotag, player index + "operatemasterswitches", // 225 lotag + "checkactivatormotion", // 226 lotag + "zshoot", // 227 zvar projnum + "dist", // 228 sprite1 sprite2 + "ldist", // 229 sprite1 sprite2 + "shiftvarl", // 230 + "shiftvarr", // 231 + "spritenvg", // 232 + "getangle", // 233 + "whilevarvarn", // 234 + "hitscan", // 235 + "time", // 236 + "getplayervar", // 237 + "setplayervar", // 238 + "mulscale", // 239 + "setaspect", // 240 + "txdist", // 241 + "spritenoshade", // 242 + "movesprite", // 243 + "checkavailweapon", // 244 + "soundoncevar", // 245 + "updatesectorz", // 246 + "stopallsounds", // 247 + "ssp", // 248 + "stopsoundvar", // 249 + "displayrandvar", // 250 + "displayrandvarvar", // 251 + "checkavailinven", // 252 + "globalsoundvar", // 253 + "guniqhudid", // 254 + "getprojectile", // 255 + "getthisprojectile", // 256 + "setthisprojectile", // 257 + "definecheat", // 258 + "cheatkeys", // 259 + "userquote", // 260 + "precache", // 261 + "projectile", // 262 + "redefinequote", // 263 + "dynquote", // 264 + "getpname", // 265 + "qstrcat", // 266 + "qstrcpy", // 267 + "setsprite", // 268 + "rotatepoint", // 269 + "dragpoint", // 270 + "getzrange", // 271 + "changespritestat", // 272 + "getceilzofslope", // 273 + "getflorzofslope", // 274 + "neartag", // 275 + "definegametype", // 276 + "changespritesect", // 277 + "spriteflags", // 278 + "savegamevar", // 279 + "readgamevar", // 280 + "findnearsprite", // 281 + "findnearspritevar", // 282 + "findnearsprite3d", // 283 + "findnearsprite3dvar", // 284 + "dynamicremap", // 285 + "setinput", // 286 + "getinput", // 287 + "save", // 288 + "" + }; + +LABELS sectorlabels[]= { + { "wallptr", SECTOR_WALLPTR, 0, 0 }, + { "wallnum", SECTOR_WALLNUM, 0, 0 }, + { "ceilingz", SECTOR_CEILINGZ, 0, 0 }, + { "floorz", SECTOR_FLOORZ, 0, 0 }, + { "ceilingstat", SECTOR_CEILINGSTAT, 0, 0 }, + { "floorstat", SECTOR_FLOORSTAT, 0, 0 }, + { "ceilingpicnum", SECTOR_CEILINGPICNUM, 0, 0 }, + { "ceilingslope", SECTOR_CEILINGSLOPE, 0, 0 }, + { "ceilingshade", SECTOR_CEILINGSHADE, 0, 0 }, + { "ceilingpal", SECTOR_CEILINGPAL, 0, 0 }, + { "ceilingxpanning", SECTOR_CEILINGXPANNING, 0, 0 }, + { "ceilingypanning", SECTOR_CEILINGYPANNING, 0, 0 }, + { "floorpicnum", SECTOR_FLOORPICNUM, 0, 0 }, + { "floorslope", SECTOR_FLOORSLOPE, 0, 0 }, + { "floorshade", SECTOR_FLOORSHADE, 0, 0 }, + { "floorpal", SECTOR_FLOORPAL, 0, 0 }, + { "floorxpanning", SECTOR_FLOORXPANNING, 0, 0 }, + { "floorypanning", SECTOR_FLOORYPANNING, 0, 0 }, + { "visibility", SECTOR_VISIBILITY, 0, 0 }, + { "alignto", SECTOR_ALIGNTO, 0, 0 }, + { "lotag", SECTOR_LOTAG, 0, 0 }, + { "hitag", SECTOR_HITAG, 0, 0 }, + { "extra", SECTOR_EXTRA, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST + }; + +LABELS walllabels[]= { + { "x", WALL_X, 0, 0 }, + { "y", WALL_Y, 0, 0 }, + { "point2", WALL_POINT2, 0, 0 }, + { "nextwall", WALL_NEXTWALL, 0, 0 }, + { "nextsector", WALL_NEXTSECTOR, 0, 0 }, + { "cstat", WALL_CSTAT, 0, 0 }, + { "picnum", WALL_PICNUM, 0, 0 }, + { "overpicnum", WALL_OVERPICNUM, 0, 0 }, + { "shade", WALL_SHADE, 0, 0 }, + { "pal", WALL_PAL, 0, 0 }, + { "xrepeat", WALL_XREPEAT, 0, 0 }, + { "yrepeat", WALL_YREPEAT, 0, 0 }, + { "xpanning", WALL_XPANNING, 0, 0 }, + { "ypanning", WALL_YPANNING, 0, 0 }, + { "lotag", WALL_LOTAG, 0, 0 }, + { "hitag", WALL_HITAG, 0, 0 }, + { "extra", WALL_EXTRA, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST + }; + +LABELS actorlabels[]= { + { "x", ACTOR_X, 0, 0 }, + { "y", ACTOR_Y, 0, 0 }, + { "z", ACTOR_Z, 0, 0 }, + { "cstat", ACTOR_CSTAT, 0, 0 }, + { "picnum", ACTOR_PICNUM, 0, 0 }, + { "shade", ACTOR_SHADE, 0, 0 }, + { "pal", ACTOR_PAL, 0, 0 }, + { "clipdist", ACTOR_CLIPDIST, 0, 0 }, + { "detail", ACTOR_DETAIL, 0, 0 }, + { "xrepeat", ACTOR_XREPEAT, 0, 0 }, + { "yrepeat", ACTOR_YREPEAT, 0, 0 }, + { "xoffset", ACTOR_XOFFSET, 0, 0 }, + { "yoffset", ACTOR_YOFFSET, 0, 0 }, + { "sectnum", ACTOR_SECTNUM, 0, 0 }, + { "statnum", ACTOR_STATNUM, 0, 0 }, + { "ang", ACTOR_ANG, 0, 0 }, + { "owner", ACTOR_OWNER, 0, 0 }, + { "xvel", ACTOR_XVEL, 0, 0 }, + { "yvel", ACTOR_YVEL, 0, 0 }, + { "zvel", ACTOR_ZVEL, 0, 0 }, + { "lotag", ACTOR_LOTAG, 0, 0 }, + { "hitag", ACTOR_HITAG, 0, 0 }, + { "extra", ACTOR_EXTRA, 0, 0 }, + + // hittype labels... + { "htcgg", ACTOR_HTCGG, 0, 0 }, + { "htpicnum", ACTOR_HTPICNUM, 0, 0 }, + { "htang", ACTOR_HTANG, 0, 0 }, + { "htextra", ACTOR_HTEXTRA, 0, 0 }, + { "htowner", ACTOR_HTOWNER, 0, 0 }, + { "htmovflag", ACTOR_HTMOVFLAG, 0, 0 }, + { "httempang", ACTOR_HTTEMPANG, 0, 0 }, + { "htactorstayput", ACTOR_HTACTORSTAYPUT, 0, 0 }, + { "htdispicnum", ACTOR_HTDISPICNUM, 0, 0 }, + { "httimetosleep", ACTOR_HTTIMETOSLEEP, 0, 0 }, + { "htfloorz", ACTOR_HTFLOORZ, 0, 0 }, + { "htceilingz", ACTOR_HTCEILINGZ, 0, 0 }, + { "htlastvx", ACTOR_HTLASTVX, 0, 0 }, + { "htlastvy", ACTOR_HTLASTVY, 0, 0 }, + { "htbposx", ACTOR_HTBPOSX, 0, 0 }, + { "htbposy", ACTOR_HTBPOSY, 0, 0 }, + { "htbposz", ACTOR_HTBPOSZ, 0, 0 }, + { "htg_t", ACTOR_HTG_T, LABEL_HASPARM2, 8 }, + + // model flags + + { "angoff", ACTOR_ANGOFF, 0, 0 }, + { "pitch", ACTOR_PITCH, 0, 0 }, + { "roll", ACTOR_ROLL, 0, 0 }, + { "mdxoff", ACTOR_MDXOFF, 0, 0 }, + { "mdyoff", ACTOR_MDYOFF, 0, 0 }, + { "mdzoff", ACTOR_MDZOFF, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST + }; + +LABELS playerlabels[]= { + { "zoom", PLAYER_ZOOM, 0, 0 }, + { "exitx", PLAYER_EXITX, 0, 0 }, + { "exity", PLAYER_EXITY, 0, 0 }, + { "loogiex", PLAYER_LOOGIEX, LABEL_HASPARM2, 64 }, + { "loogiey", PLAYER_LOOGIEY, LABEL_HASPARM2, 64 }, + { "numloogs", PLAYER_NUMLOOGS, 0, 0 }, + { "loogcnt", PLAYER_LOOGCNT, 0, 0 }, + { "posx", PLAYER_POSX, 0, 0 }, + { "posy", PLAYER_POSY, 0, 0 }, + { "posz", PLAYER_POSZ, 0, 0 }, + { "horiz", PLAYER_HORIZ, 0, 0 }, + { "ohoriz", PLAYER_OHORIZ, 0, 0 }, + { "ohorizoff", PLAYER_OHORIZOFF, 0, 0 }, + { "invdisptime", PLAYER_INVDISPTIME, 0, 0 }, + { "bobposx", PLAYER_BOBPOSX, 0, 0 }, + { "bobposy", PLAYER_BOBPOSY, 0, 0 }, + { "oposx", PLAYER_OPOSX, 0, 0 }, + { "oposy", PLAYER_OPOSY, 0, 0 }, + { "oposz", PLAYER_OPOSZ, 0, 0 }, + { "pyoff", PLAYER_PYOFF, 0, 0 }, + { "opyoff", PLAYER_OPYOFF, 0, 0 }, + { "posxv", PLAYER_POSXV, 0, 0 }, + { "posyv", PLAYER_POSYV, 0, 0 }, + { "poszv", PLAYER_POSZV, 0, 0 }, + { "last_pissed_time", PLAYER_LAST_PISSED_TIME, 0, 0 }, + { "truefz", PLAYER_TRUEFZ, 0, 0 }, + { "truecz", PLAYER_TRUECZ, 0, 0 }, + { "player_par", PLAYER_PLAYER_PAR, 0, 0 }, + { "visibility", PLAYER_VISIBILITY, 0, 0 }, + { "bobcounter", PLAYER_BOBCOUNTER, 0, 0 }, + { "weapon_sway", PLAYER_WEAPON_SWAY, 0, 0 }, + { "pals_time", PLAYER_PALS_TIME, 0, 0 }, + { "randomflamex", PLAYER_RANDOMFLAMEX, 0, 0 }, + { "crack_time", PLAYER_CRACK_TIME, 0, 0 }, + { "aim_mode", PLAYER_AIM_MODE, 0, 0 }, + { "ang", PLAYER_ANG, 0, 0 }, + { "oang", PLAYER_OANG, 0, 0 }, + { "angvel", PLAYER_ANGVEL, 0, 0 }, + { "cursectnum", PLAYER_CURSECTNUM, 0, 0 }, + { "look_ang", PLAYER_LOOK_ANG, 0, 0 }, + { "last_extra", PLAYER_LAST_EXTRA, 0, 0 }, + { "subweapon", PLAYER_SUBWEAPON, 0, 0 }, + { "ammo_amount", PLAYER_AMMO_AMOUNT, LABEL_HASPARM2, MAX_WEAPONS }, + { "wackedbyactor", PLAYER_WACKEDBYACTOR, 0, 0 }, + { "frag", PLAYER_FRAG, 0, 0 }, + { "fraggedself", PLAYER_FRAGGEDSELF, 0, 0 }, + { "curr_weapon", PLAYER_CURR_WEAPON, 0, 0 }, + { "last_weapon", PLAYER_LAST_WEAPON, 0, 0 }, + { "tipincs", PLAYER_TIPINCS, 0, 0 }, + { "horizoff", PLAYER_HORIZOFF, 0, 0 }, + { "wantweaponfire", PLAYER_WANTWEAPONFIRE, 0, 0 }, + { "holoduke_amount", PLAYER_HOLODUKE_AMOUNT, 0, 0 }, + { "newowner", PLAYER_NEWOWNER, 0, 0 }, + { "hurt_delay", PLAYER_HURT_DELAY, 0, 0 }, + { "hbomb_hold_delay", PLAYER_HBOMB_HOLD_DELAY, 0, 0 }, + { "jumping_counter", PLAYER_JUMPING_COUNTER, 0, 0 }, + { "airleft", PLAYER_AIRLEFT, 0, 0 }, + { "knee_incs", PLAYER_KNEE_INCS, 0, 0 }, + { "access_incs", PLAYER_ACCESS_INCS, 0, 0 }, + { "fta", PLAYER_FTA, 0, 0 }, + { "ftq", PLAYER_FTQ, 0, 0 }, + { "access_wallnum", PLAYER_ACCESS_WALLNUM, 0, 0 }, + { "access_spritenum", PLAYER_ACCESS_SPRITENUM, 0, 0 }, + { "kickback_pic", PLAYER_KICKBACK_PIC, 0, 0 }, + { "got_access", PLAYER_GOT_ACCESS, 0, 0 }, + { "weapon_ang", PLAYER_WEAPON_ANG, 0, 0 }, + { "firstaid_amount", PLAYER_FIRSTAID_AMOUNT, 0, 0 }, + { "somethingonplayer", PLAYER_SOMETHINGONPLAYER, 0, 0 }, + { "on_crane", PLAYER_ON_CRANE, 0, 0 }, + { "i", PLAYER_I, 0, 0 }, + { "one_parallax_sectnum", PLAYER_ONE_PARALLAX_SECTNUM, 0, 0 }, + { "over_shoulder_on", PLAYER_OVER_SHOULDER_ON, 0, 0 }, + { "random_club_frame", PLAYER_RANDOM_CLUB_FRAME, 0, 0 }, + { "fist_incs", PLAYER_FIST_INCS, 0, 0 }, + { "one_eighty_count", PLAYER_ONE_EIGHTY_COUNT, 0, 0 }, + { "cheat_phase", PLAYER_CHEAT_PHASE, 0, 0 }, + { "dummyplayersprite", PLAYER_DUMMYPLAYERSPRITE, 0, 0 }, + { "extra_extra8", PLAYER_EXTRA_EXTRA8, 0, 0 }, + { "quick_kick", PLAYER_QUICK_KICK, 0, 0 }, + { "heat_amount", PLAYER_HEAT_AMOUNT, 0, 0 }, + { "actorsqu", PLAYER_ACTORSQU, 0, 0 }, + { "timebeforeexit", PLAYER_TIMEBEFOREEXIT, 0, 0 }, + { "customexitsound", PLAYER_CUSTOMEXITSOUND, 0, 0 }, + { "weaprecs[16]", PLAYER_WEAPRECS, 0, 0 }, + { "weapreccnt", PLAYER_WEAPRECCNT, 0, 0 }, + { "interface_toggle_flag", PLAYER_INTERFACE_TOGGLE_FLAG, 0, 0 }, + { "rotscrnang", PLAYER_ROTSCRNANG, 0, 0 }, + { "dead_flag", PLAYER_DEAD_FLAG, 0, 0 }, + { "show_empty_weapon", PLAYER_SHOW_EMPTY_WEAPON, 0, 0 }, + { "scuba_amount", PLAYER_SCUBA_AMOUNT, 0, 0 }, + { "jetpack_amount", PLAYER_JETPACK_AMOUNT, 0, 0 }, + { "steroids_amount", PLAYER_STEROIDS_AMOUNT, 0, 0 }, + { "shield_amount", PLAYER_SHIELD_AMOUNT, 0, 0 }, + { "holoduke_on", PLAYER_HOLODUKE_ON, 0, 0 }, + { "pycount", PLAYER_PYCOUNT, 0, 0 }, + { "weapon_pos", PLAYER_WEAPON_POS, 0, 0 }, + { "frag_ps", PLAYER_FRAG_PS, 0, 0 }, + { "transporter_hold", PLAYER_TRANSPORTER_HOLD, 0, 0 }, + { "last_full_weapon", PLAYER_LAST_FULL_WEAPON, 0, 0 }, + { "footprintshade", PLAYER_FOOTPRINTSHADE, 0, 0 }, + { "boot_amount", PLAYER_BOOT_AMOUNT, 0, 0 }, + { "scream_voice", PLAYER_SCREAM_VOICE, 0, 0 }, + { "gm", PLAYER_GM, 0, 0 }, + { "on_warping_sector", PLAYER_ON_WARPING_SECTOR, 0, 0 }, + { "footprintcount", PLAYER_FOOTPRINTCOUNT, 0, 0 }, + { "hbomb_on", PLAYER_HBOMB_ON, 0, 0 }, + { "jumping_toggle", PLAYER_JUMPING_TOGGLE, 0, 0 }, + { "rapid_fire_hold", PLAYER_RAPID_FIRE_HOLD, 0, 0 }, + { "on_ground", PLAYER_ON_GROUND, 0, 0 }, + { "name", PLAYER_NAME, LABEL_ISSTRING, 32 }, + { "inven_icon", PLAYER_INVEN_ICON, 0, 0 }, + { "buttonpalette", PLAYER_BUTTONPALETTE, 0, 0 }, + { "jetpack_on", PLAYER_JETPACK_ON, 0, 0 }, + { "spritebridge", PLAYER_SPRITEBRIDGE, 0, 0 }, + { "lastrandomspot", PLAYER_LASTRANDOMSPOT, 0, 0 }, + { "scuba_on", PLAYER_SCUBA_ON, 0, 0 }, + { "footprintpal", PLAYER_FOOTPRINTPAL, 0, 0 }, + { "heat_on", PLAYER_HEAT_ON, 0, 0 }, + { "holster_weapon", PLAYER_HOLSTER_WEAPON, 0, 0 }, + { "falling_counter", PLAYER_FALLING_COUNTER, 0, 0 }, + { "gotweapon", PLAYER_GOTWEAPON, LABEL_HASPARM2, MAX_WEAPONS }, + { "refresh_inventory", PLAYER_REFRESH_INVENTORY, 0, 0 }, + { "palette", PLAYER_PALETTE, 0, 0 }, + { "toggle_key_flag", PLAYER_TOGGLE_KEY_FLAG, 0, 0 }, + { "knuckle_incs", PLAYER_KNUCKLE_INCS, 0, 0 }, + { "walking_snd_toggle", PLAYER_WALKING_SND_TOGGLE, 0, 0 }, + { "palookup", PLAYER_PALOOKUP, 0, 0 }, + { "hard_landing", PLAYER_HARD_LANDING, 0, 0 }, + { "max_+_rooms", PLAYER_MAX_SECRET_ROOMS, 0, 0 }, + { "secret_rooms", PLAYER_SECRET_ROOMS, 0, 0 }, + { "pals", PLAYER_PALS, LABEL_HASPARM2, 2 }, + { "max_actors_killed", PLAYER_MAX_ACTORS_KILLED, 0, 0 }, + { "actors_killed", PLAYER_ACTORS_KILLED, 0, 0 }, + { "return_to_center", PLAYER_RETURN_TO_CENTER, 0, 0 }, + { "runspeed", PLAYER_RUNSPEED, 0, 0 }, + { "sbs", PLAYER_SBS, 0, 0 }, + { "reloading", PLAYER_RELOADING, 0, 0 }, + { "auto_aim", PLAYER_AUTO_AIM, 0, 0 }, + { "movement_lock", PLAYER_MOVEMENT_LOCK, LABEL_HASPARM2, 4 }, + { "sound_pitch", PLAYER_SOUND_PITCH, 0, 0 }, + { "weaponswitch", PLAYER_WEAPONSWITCH, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST + }; + +LABELS projectilelabels[]= { + { "workslike", PROJ_WORKSLIKE, 0, 0 }, + { "spawns", PROJ_SPAWNS, 0, 0 }, + { "sxrepeat", PROJ_SXREPEAT, 0, 0 }, + { "syrepeat", PROJ_SYREPEAT, 0, 0 }, + { "sound", PROJ_SOUND, 0, 0 }, + { "isound", PROJ_ISOUND, 0, 0 }, + { "vel", PROJ_VEL, 0, 0 }, + { "extra", PROJ_EXTRA, 0, 0 }, + { "decal", PROJ_DECAL, 0, 0 }, + { "trail", PROJ_TRAIL, 0, 0 }, + { "txrepeat", PROJ_TXREPEAT, 0, 0 }, + { "tyrepeat", PROJ_TYREPEAT, 0, 0 }, + { "toffset", PROJ_TOFFSET, 0, 0 }, + { "tnum", PROJ_TNUM, 0, 0 }, + { "drop", PROJ_DROP, 0, 0 }, + { "cstat", PROJ_CSTAT, 0, 0 }, + { "clipdist", PROJ_CLIPDIST, 0, 0 }, + { "shade", PROJ_SHADE, 0, 0 }, + { "xrepeat", PROJ_XREPEAT, 0, 0 }, + { "yrepeat", PROJ_YREPEAT, 0, 0 }, + { "pal", PROJ_PAL, 0, 0 }, + { "extra_rand", PROJ_EXTRA_RAND, 0, 0 }, + { "hitradius", PROJ_HITRADIUS, 0, 0 }, + { "velmult", PROJ_VEL_MULT, 0, 0 }, + { "offset", PROJ_OFFSET, 0, 0 }, + { "bounces", PROJ_BOUNCES, 0, 0 }, + { "bsound", PROJ_BSOUND, 0, 0 }, + { "range", PROJ_RANGE, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST + }; + +LABELS userdefslabels[]= { + // { "", 1, 0, 0 }, + { "god", USERDEFS_GOD, 0, 0 }, + { "warp_on", USERDEFS_WARP_ON, 0, 0 }, + { "cashman", USERDEFS_CASHMAN, 0, 0 }, + { "eog", USERDEFS_EOG, 0, 0 }, + { "showallmap", USERDEFS_SHOWALLMAP, 0, 0 }, + { "show_help", USERDEFS_SHOW_HELP, 0, 0 }, + { "scrollmode", USERDEFS_SCROLLMODE, 0, 0 }, + { "clipping", USERDEFS_CLIPPING, 0, 0 }, + { "user_name", USERDEFS_USER_NAME, LABEL_HASPARM2, MAXPLAYERS }, + { "ridecule", USERDEFS_RIDECULE, LABEL_HASPARM2 | LABEL_ISSTRING, 10 }, + { "savegame", USERDEFS_SAVEGAME, LABEL_HASPARM2 | LABEL_ISSTRING, 10 }, + { "pwlockout", USERDEFS_PWLOCKOUT, LABEL_ISSTRING, 128 }, + { "rtsname;", USERDEFS_RTSNAME, LABEL_ISSTRING, 128 }, + { "overhead_on", USERDEFS_OVERHEAD_ON, 0, 0 }, + { "last_overhead", USERDEFS_LAST_OVERHEAD, 0, 0 }, + { "showweapons", USERDEFS_SHOWWEAPONS, 0, 0 }, + + { "pause_on", USERDEFS_PAUSE_ON, 0, 0 }, + { "from_bonus", USERDEFS_FROM_BONUS, 0, 0 }, + { "camerasprite", USERDEFS_CAMERASPRITE, 0, 0 }, + { "last_camsprite", USERDEFS_LAST_CAMSPRITE, 0, 0 }, + { "last_level", USERDEFS_LAST_LEVEL, 0, 0 }, + { "secretlevel", USERDEFS_SECRETLEVEL, 0, 0 }, + + { "const_visibility", USERDEFS_CONST_VISIBILITY, 0, 0 }, + { "uw_framerate", USERDEFS_UW_FRAMERATE, 0, 0 }, + { "camera_time", USERDEFS_CAMERA_TIME, 0, 0 }, + { "folfvel", USERDEFS_FOLFVEL, 0, 0 }, + { "folavel", USERDEFS_FOLAVEL, 0, 0 }, + { "folx", USERDEFS_FOLX, 0, 0 }, + { "foly", USERDEFS_FOLY, 0, 0 }, + { "fola", USERDEFS_FOLA, 0, 0 }, + { "reccnt", USERDEFS_RECCNT, 0, 0 }, + + { "entered_name", USERDEFS_ENTERED_NAME, 0, 0 }, + { "screen_tilting", USERDEFS_SCREEN_TILTING, 0, 0 }, + { "shadows", USERDEFS_SHADOWS, 0, 0 }, + { "fta_on", USERDEFS_FTA_ON, 0, 0 }, + { "executions", USERDEFS_EXECUTIONS, 0, 0 }, + { "auto_run", USERDEFS_AUTO_RUN, 0, 0 }, + { "coords", USERDEFS_COORDS, 0, 0 }, + { "tickrate", USERDEFS_TICKRATE, 0, 0 }, + { "m_coop", USERDEFS_M_COOP, 0, 0 }, + { "coop", USERDEFS_COOP, 0, 0 }, + { "screen_size", USERDEFS_SCREEN_SIZE, 0, 0 }, + { "lockout", USERDEFS_LOCKOUT, 0, 0 }, + { "crosshair", USERDEFS_CROSSHAIR, 0, 0 }, + { "wchoice[MAXPLAYERS][MAX_WEAPONS]", USERDEFS_WCHOICE, 0, 0 }, + { "playerai", USERDEFS_PLAYERAI, 0, 0 }, + { "respawn_monsters", USERDEFS_RESPAWN_MONSTERS, 0, 0 }, + { "respawn_items", USERDEFS_RESPAWN_ITEMS, 0, 0 }, + { "respawn_inventory", USERDEFS_RESPAWN_INVENTORY, 0, 0 }, + { "recstat", USERDEFS_RECSTAT, 0, 0 }, + { "monsters_off", USERDEFS_MONSTERS_OFF, 0, 0 }, + { "brightness", USERDEFS_BRIGHTNESS, 0, 0 }, + { "m_respawn_items", USERDEFS_M_RESPAWN_ITEMS, 0, 0 }, + { "m_respawn_monsters", USERDEFS_M_RESPAWN_MONSTERS, 0, 0 }, + { "m_respawn_inventory", USERDEFS_M_RESPAWN_INVENTORY, 0, 0 }, + { "m_recstat", USERDEFS_M_RECSTAT, 0, 0 }, + { "m_monsters_off", USERDEFS_M_MONSTERS_OFF, 0, 0 }, + { "detail", USERDEFS_DETAIL, 0, 0 }, + { "m_ffire", USERDEFS_M_FFIRE, 0, 0 }, + { "ffire", USERDEFS_FFIRE, 0, 0 }, + { "m_player_skill", USERDEFS_M_PLAYER_SKILL, 0, 0 }, + { "m_level_number", USERDEFS_M_LEVEL_NUMBER, 0, 0 }, + { "m_volume_number", USERDEFS_M_VOLUME_NUMBER, 0, 0 }, + { "multimode", USERDEFS_MULTIMODE, 0, 0 }, + { "player_skill", USERDEFS_PLAYER_SKILL, 0, 0 }, + { "level_number", USERDEFS_LEVEL_NUMBER, 0, 0 }, + { "volume_number", USERDEFS_VOLUME_NUMBER, 0, 0 }, + { "m_marker", USERDEFS_M_MARKER, 0, 0 }, + { "marker", USERDEFS_MARKER, 0, 0 }, + { "mouseflip", USERDEFS_MOUSEFLIP, 0, 0 }, + { "statusbarscale", USERDEFS_STATUSBARSCALE, 0, 0 }, + { "drawweapon", USERDEFS_DRAWWEAPON, 0, 0 }, + { "mouseaiming", USERDEFS_MOUSEAIMING, 0, 0 }, + { "weaponswitch", USERDEFS_WEAPONSWITCH, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST + }; + +LABELS inputlabels[]= { + { "avel", INPUT_AVEL, 0, 0 }, + { "horz", INPUT_HORZ, 0, 0 }, + { "fvel", INPUT_FVEL, 0, 0 }, + { "svel", INPUT_SVEL, 0, 0 }, + { "bits", INPUT_BITS, 0, 0 }, + { "bits2", INPUT_BITS2, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST +}; + +void skipcomments(void) +{ + char c; + while ((c = *textptr)) + { + if (c == ' ' || c == '\t' || c == '\r') + textptr++; + else if (c == '\n') { + line_number++; + textptr++; + } + else if (c == '/' && textptr[1] == '/') + { + if (!(error || warning) && condebug > 1) + initprintf("%s:%ld: debug: got comment.\n",compilefile,line_number); + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) + textptr++; + } + else if (c == '/' && textptr[1] == '*') + { + if (!(error || warning) && condebug > 1) + initprintf("%s:%ld: debug: got start of comment block.\n",compilefile,line_number); + while (*textptr && !(textptr[0] == '*' && textptr[1] == '/')) + { + if (*textptr == '\n') + line_number++; + textptr++; + } + if ((!(error || warning) && condebug > 1) && (textptr[0] == '*' && textptr[1] == '/')) + initprintf("%s:%ld: debug: got end of comment block.\n",compilefile,line_number); + if (!*textptr) + { + if(!(error || warning) && condebug) + initprintf("%s:%ld: debug: EOF in comment!\n",compilefile,line_number); + ReportError(-1); + initprintf("%s:%ld: error: found `/*' with no `*/'.\n",compilefile,line_number); + parsing_state = num_braces = 0; + parsing_actor = 0; + error++; + break; + } + else textptr+=2; + } + else break; + } +} + +void DefineProjectile(long lVar1, long lLabelID, long lVar2) +{ + switch(lLabelID) + { + case PROJ_WORKSLIKE: + projectile[lVar1].workslike=lVar2; + break; + + case PROJ_SPAWNS: + projectile[lVar1].spawns=lVar2; + break; + + case PROJ_SXREPEAT: + projectile[lVar1].sxrepeat=lVar2; + break; + + case PROJ_SYREPEAT: + projectile[lVar1].syrepeat=lVar2; + break; + + case PROJ_SOUND: + projectile[lVar1].sound=lVar2; + break; + + case PROJ_ISOUND: + projectile[lVar1].isound=lVar2; + break; + + case PROJ_VEL: + projectile[lVar1].vel=lVar2; + break; + + case PROJ_EXTRA: + projectile[lVar1].extra=lVar2; + break; + + case PROJ_DECAL: + projectile[lVar1].decal=lVar2; + break; + + case PROJ_TRAIL: + projectile[lVar1].trail=lVar2; + break; + + case PROJ_TXREPEAT: + projectile[lVar1].txrepeat=lVar2; + break; + + case PROJ_TYREPEAT: + projectile[lVar1].tyrepeat=lVar2; + break; + + case PROJ_TOFFSET: + projectile[lVar1].toffset=lVar2; + break; + + case PROJ_TNUM: + projectile[lVar1].tnum=lVar2; + break; + + case PROJ_DROP: + projectile[lVar1].drop=lVar2; + break; + + case PROJ_CSTAT: + projectile[lVar1].cstat=lVar2; + break; + + case PROJ_CLIPDIST: + projectile[lVar1].clipdist=lVar2; + break; + + case PROJ_SHADE: + projectile[lVar1].shade=lVar2; + break; + + case PROJ_XREPEAT: + projectile[lVar1].xrepeat=lVar2; + break; + + case PROJ_YREPEAT: + projectile[lVar1].yrepeat=lVar2; + break; + + case PROJ_PAL: + projectile[lVar1].pal=lVar2; + break; + + case PROJ_EXTRA_RAND: + projectile[lVar1].extra_rand=lVar2; + break; + + case PROJ_HITRADIUS: + projectile[lVar1].hitradius=lVar2; + break; + + case PROJ_VEL_MULT: + projectile[lVar1].velmult=lVar2; + break; + + case PROJ_OFFSET: + projectile[lVar1].offset=lVar2; + break; + + case PROJ_BOUNCES: + projectile[lVar1].bounces=lVar2; + break; + + case PROJ_BSOUND: + projectile[lVar1].bsound=lVar2; + break; + + case PROJ_RANGE: + projectile[lVar1].range=lVar2; + break; + + default: + break; + } + + // defaultprojectile[lVar1] = projectile[lVar1]; + Bmemcpy(&defaultprojectile[lVar1], &projectile[lVar1], sizeof(projectile[lVar1])); + + return; +} + +char CheckEventSync(int iEventID) +{ + if(parsing_event || parsing_actor) + { + switch(iEventID) + { + case EVENT_CHEATGETSTEROIDS: + case EVENT_CHEATGETHEAT: + case EVENT_CHEATGETBOOT: + case EVENT_CHEATGETSHIELD: + case EVENT_CHEATGETSCUBA: + case EVENT_CHEATGETHOLODUKE: + case EVENT_CHEATGETJETPACK: + case EVENT_CHEATGETFIRSTAID: + case EVENT_DISPLAYWEAPON: + case EVENT_DRAWWEAPON: + case EVENT_DISPLAYCROSSHAIR: + case EVENT_DISPLAYREST: + case EVENT_ENTERLEVEL: + case EVENT_GETLOADTILE: + case EVENT_GETMENUTILE: + case EVENT_INIT: + case EVENT_LOGO: + return 0; + default: + return 1; + } + } + return 1; +} + +void AddLog(char *psz) +{ + Bstrcpy(tempbuf,psz); + if(tempbuf[Bstrlen(psz)] != '\n') + Bstrcat(tempbuf,"\n"); + if (qsetmode == 200) OSD_Printf(tempbuf); + else initprintf(tempbuf); +} + +char AddGameVar(char *pszLabel, long lValue, unsigned long dwFlags); + +void ReadGameVars(long fil) +{ + int i; + long l; + + // AddLog("Reading gamevars from savegame"); + + kdfread(&l,sizeof(l),1,fil); + kdfread(g_szBuf,l,1,fil); + g_szBuf[l]=0; + AddLog(g_szBuf); + + FreeGameVars(); // nuke 'em from orbit, it's the only way to be sure... + // Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); + // AddLog(g_szBuf); + + kdfread(&iGameVarCount,sizeof(iGameVarCount),1,fil); + + for(i=0;i (MAXVARLABEL-1) ) + { + error++; + initprintf("%s:%ld: error: variable name `%s' exceeds limit of %d characters.\n",compilefile,line_number,pszLabel, MAXVARLABEL); + return 0; + } + for(i=0;i= iGameVarCount) + { + if(id==MAXGAMEVARS) + return(*insptr++); + else if(id&(MAXGAMEVARS<<1)) + { + m=1; + id ^= (MAXGAMEVARS<<1); + } + else + { + AddLog("GetGameVarID: Invalid Game ID"); + return -1; + } + } + if( id == g_iThisActorID ) + { + return sActor; + } + if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER ) + { + // for the current player + if(sPlayer >=0 && sPlayer < MAXPLAYERS) + { + //Bsprintf(g_szBuf,"GetGameVarID( %d, %d, %d) returns %ld\n",id,sActor,sPlayer, aGameVars[id].plValues[sPlayer]); + //AddLog(g_szBuf); + if(m) return -aGameVars[id].plValues[sPlayer]; + else return aGameVars[id].plValues[sPlayer]; + } + else + { + if(m) return -aGameVars[id].lValue; + else return aGameVars[id].lValue; + } + } + else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR ) + { + // for the current actor + if(sActor >= 0 && sActor <=MAXSPRITES) + { + if(m) return -aGameVars[id].plValues[sActor]; + else return aGameVars[id].plValues[sActor]; + } + else + { + if(m) return -aGameVars[id].lValue; + else return aGameVars[id].lValue; + } + } + else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG ) + { + if(m) return -(*((long*)aGameVars[id].lValue)); + else return (*((long*)aGameVars[id].lValue)); + } + else + { + if(m) return -aGameVars[id].lValue; + else return aGameVars[id].lValue; + } + +} + +void SetGameVarID(int id, long lValue, short sActor, short sPlayer) +{ + if(id<0 || id >= iGameVarCount) + { + AddLog("Invalid Game ID"); + return; + } + //Bsprintf(g_szBuf,"SGVI: %d ('%s') to %ld for %d %d",id,aGameVars[id].szLabel,lValue,sActor,sPlayer); + //AddLog(g_szBuf); + if((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) && (sPlayer != -1)) + { + // for the current player + aGameVars[id].plValues[sPlayer]=lValue; + } + else if((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) && (sActor != -1)) + { + // for the current actor + aGameVars[id].plValues[sActor]=lValue; + } + else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG ) + { + // set the value at pointer + *((long*)aGameVars[id].lValue)=lValue; + } + else + { + aGameVars[id].lValue=lValue; + } + +} + +long GetGameVar(char *szGameLabel, long lDefault, short sActor, short sPlayer) +{ + int i; + for(i=0;i=0 ; i++) + { + if(!Bstrcasecmp(pLabel[i].name,psz)) + { + l= pLabel[i].lId; + break; // stop for loop + } + } + return l; +} + +long getlabeloffset(LABELS *pLabel, char *psz) +{ + // find the label psz in the table pLabel. + // returns the offset in the array for the label, or -1 + long l=-1; + int i; + + for(i=0;pLabel[i].lId >=0 ; i++) + { + if(!Bstrcasecmp(pLabel[i].name,psz)) + { + // printf("Label has flags of %02X\n",pLabel[i].flags); + return i; + } + } + return -1; +} + +void getlabel(void) +{ + long i; + + skipcomments(); + + while( isalnum(*textptr) == 0 ) + { + if(*textptr == 0x0a) line_number++; + textptr++; + if( *textptr == 0) + return; + } + + i = 0; + while( ispecial(*textptr) == 0 && *textptr!=']' ) + label[(labelcnt<<6)+i++] = *(textptr++); + + label[(labelcnt<<6)+i] = 0; + if (!(error || warning) && condebug > 1) + initprintf("%s:%ld: debug: got label `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); +} + +long keyword(void) +{ + long i; + char *temptextptr; + + skipcomments(); + + temptextptr = textptr; + + while( isaltok(*temptextptr) == 0 ) + { + temptextptr++; + if( *temptextptr == 0 ) + return 0; + } + + i = 0; + while( isaltok(*temptextptr) ) + { + tempbuf[i] = *(temptextptr++); + i++; + } + tempbuf[i] = 0; + for(i=0;i 1) + initprintf("%s:%ld: debug: accepted gamevar `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); + i |= f; + *scriptptr++=i; +} + +inline void transvar(void) +{ + transvartype(0); +} + +inline void transmultvarstype(int type, char num) +{ + char i; + for(i=0;i 1) + { + gl = translatelabeltype(labeltype[i]); + initprintf("%s:%ld: debug: accepted %s label `%s'.\n",compilefile,line_number,gl,label+(i<<6)); + Bfree(gl); + } + *(scriptptr++) = labelcode[i]; + textptr += l; + return labeltype[i]; + } + *(scriptptr++) = 0; + textptr += l; + el = translatelabeltype(type); + gl = translatelabeltype(labeltype[i]); + ReportError(-1); + initprintf("%s:%ld: warning: expected a %s, found a %s.\n",compilefile,line_number,el,gl); + Bfree(el); + Bfree(gl); + return -1; // valid label name, but wrong type + } + } + + if( isdigit(*textptr) == 0 && *textptr != '-') + { + ReportError(ERROR_PARAMUNDEFINED); + error++; + textptr+=l; + return -1; // error! + } + + if( isdigit(*textptr) && labelsonly ) + { + ReportError(WARNING_LABELSONLY); + // warning++; + } + if (!(error || warning) && condebug > 1) + initprintf("%s:%ld: debug: accepted constant %ld.\n",compilefile,line_number,atol(textptr)); + *scriptptr = atol(textptr); + scriptptr++; + + textptr += l; + + return 0; // literal value +} + +long CountCaseStatements() +{ + long lCount; + char *temptextptr; + long *savescript; + long *savecase; + short temp_line_number; + + + temp_line_number=line_number; + + casecount=0; + temptextptr=textptr; + savescript=scriptptr; + savecase=casescriptptr; + casescriptptr=NULL; + //Bsprintf(g_szBuf,"CSS: %.12s",textptr); + //AddLog(g_szBuf); + while(parsecommand() == 0) + { + //Bsprintf(g_szBuf,"CSSL: %.20s",textptr); + //AddLog(g_szBuf); + ; + } + // since we processed the endswitch, we need to re-increment checking_switch + checking_switch++; + + textptr=temptextptr; + scriptptr=savescript; + + line_number = temp_line_number; + + lCount=casecount; + casecount=0; + casescriptptr=savecase; + return lCount; +} + +char parsecommand(void) +{ + long i, j=0, k=0, *tempscrptr; + char done, *temptextptr; + + long tw; + + if (((unsigned)(scriptptr-script) > MAXSCRIPTSIZE) && error == 0) { + /* Bsprintf(tempbuf,"fatal error: Size of compiled CON code exceeds maximum size! (%ud, %d)\n",(unsigned)(scriptptr-script),MAXSCRIPTSIZE); */ + ReportError(-1); + initprintf("%s:%ld: internal compiler error: Aborted (%ud)\n",compilefile,line_number,(unsigned)(scriptptr-script)); + initprintf(tempbuf); + error++; + } + + if( (error+warning) > 63 || ( *textptr == '\0' ) || ( *(textptr+1) == '\0' ) ) return 1; + + if (checking_switch > 0 ) + { + //Bsprintf(g_szBuf,"PC(): '%.25s'",textptr); + //AddLog(g_szBuf); + } + tw = transword(); + // Bsprintf(tempbuf,"%s",keyw[tw]); + // AddLog(tempbuf); + + skipcomments(); // yes? no? + + switch(tw) + { + default: + case -1: + return 0; //End + case CON_STATE: + if( parsing_actor == 0 && parsing_state == 0 ) + { + getlabel(); + scriptptr--; + labelcode[labelcnt] = (long) scriptptr; + labeltype[labelcnt] = LABEL_STATE; + + parsing_state = 1; + Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6)); + labelcnt++; + return 0; + } + + getlabel(); + + for(i=0;i 1) + initprintf("%s:%ld: debug: accepted state label `%s'.\n",compilefile,line_number,label+(j<<6)); + *scriptptr = labelcode[j]; + break; + } + else + { + char *gl; + gl = translatelabeltype(labeltype[j]); + ReportError(-1); + initprintf("%s:%ld: warning: expected a state, found a %s.\n",compilefile,line_number,gl); + Bfree(gl); + *(scriptptr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions + return 0; // valid label name, but wrong type + } + } + } + if(j==labelcnt) + { + ReportError(-1); + initprintf("%s:%ld: error: state `%s' not found.\n",compilefile,line_number,label+(labelcnt<<6)); + error++; + } + scriptptr++; + return 0; + + case CON_ENDS: + if( parsing_state == 0 ) + { + ReportError(-1); + initprintf("%s:%ld: error: found `ends' without open `state'.\n",compilefile,line_number); + error++; + } + // else + { + if( num_braces > 0 ) + { + ReportError(ERROR_OPENBRACKET); + error++; + } + if( num_braces < 0 ) + { + ReportError(ERROR_CLOSEBRACKET); + error++; + } + if( checking_switch > 0 ) + { + ReportError(ERROR_NOENDSWITCH); + error++; + + checking_switch = 0; // can't be checking anymore... + } + + parsing_state = 0; + Bsprintf(parsing_item_name,"(none)"); + } + return 0; + + case CON_SETTHISPROJECTILE: + case CON_SETPROJECTILE: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETTHISPROJECTILE: + case CON_GETPROJECTILE: + { + long lLabelID; + + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while((*textptr != '[')) + { + textptr++; + } + if(*textptr == '[') + textptr++; + + // get the ID of the DEF + if(tw == CON_SETTHISPROJECTILE) + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while(*textptr != '.') + { + if(*textptr == 0xa) + break; + if(!*textptr) + break; + + textptr++; + } + if(*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabeloffset(projectilelabels,label+(labelcnt<<6)); + //printf("LabelID is %ld\n",lLabelID); + if(lLabelID == -1 ) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + + *scriptptr++=projectilelabels[lLabelID].lId; + + //printf("member's flags are: %02Xh\n",playerlabels[lLabelID].flags); + + // now at target VAR... + + // get the ID of the DEF + switch(tw) + { + case CON_SETPROJECTILE: + case CON_SETTHISPROJECTILE: + transvar(); + break; + default: + transvartype(GAMEVAR_FLAG_READONLY); + break; + } + break; + } + + case CON_GAMEVAR: + // syntax: gamevar + // defines var1 and sets initial value. + // flags are used to define usage + // (see top of this files for flags) + //printf("Got gamedef. Getting Label. '%.20s'\n",textptr); + + if(isdigit(*textptr) || (*textptr == '-')) + { + getlabel(); + error++; + ReportError(ERROR_SYNTAXERROR); + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + scriptptr -= 3; // we complete the process anyways just to skip past the fucked up section + return 0; + } + + getlabel(); + //printf("Got Label '%.20s'\n",textptr); + // Check to see it's already defined + + for(i=0;i= defaultlabelcnt) + { + warning++; + ReportError(WARNING_DUPLICATEDEFINITION); + } + break; + } + } + //printf("Translating. '%.20s'\n",textptr); + transnum(LABEL_DEFINE); + //printf("Translated. '%.20s'\n",textptr); + if(i == labelcnt) + { + // printf("Defining Definition '%s' to be '%d'\n",label+(labelcnt<<6),*(scriptptr-1)); + labeltype[labelcnt] = LABEL_DEFINE; + labelcode[labelcnt++] = *(scriptptr-1); + if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && dynamicremap) + processnames(label+(i<<6),*(scriptptr-1)); + } + scriptptr -= 2; + return 0; + } + + case CON_PALFROM: + for(j=0;j<4;j++) + { + if( keyword() == -1 ) + transnum(LABEL_DEFINE); + else break; + } + + while(j<4) + { + *scriptptr = 0; + scriptptr++; + j++; + } + return 0; + + case CON_MOVE: + if( parsing_actor || parsing_state ) + { + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transnum(LABEL_MOVE); + + j = 0; + while(keyword() == -1) + { + transnum(LABEL_DEFINE); + scriptptr--; + j |= *scriptptr; + } + *scriptptr = j; + + scriptptr++; + } + else + { + scriptptr--; + getlabel(); + // Check to see it's already defined + + for(i=0;i= 0) break; + transnum(LABEL_DEFINE); + } + for(k=j;k<2;k++) + { + *scriptptr = 0; + scriptptr++; + } + } + return 0; + + case CON_MUSIC: + { + // NOTE: this doesn't get stored in the PCode... + + // music 1 stalker.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid + // thecall.mid ahgeez.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid + scriptptr--; + transnum(LABEL_DEFINE); // Volume Number (0/4) + scriptptr--; + + k = *scriptptr-1; + + if(k >= 0) // if it's background music + { + i = 0; + // get the file name... + while(keyword() == -1) + { + while( isaltok(*textptr) == 0 ) + { + if(*textptr == 0x0a) line_number++; + textptr++; + if( *textptr == 0 ) break; + } + j = 0; + while( isaltok(*(textptr+j)) ) + { + music_fn[k][i][j] = textptr[j]; + j++; + } + music_fn[k][i][j] = '\0'; + textptr += j; + if(i > 9) break; + i++; + } + } + else + { + i = 0; + while(keyword() == -1) + { + while( isaltok(*textptr) == 0 ) + { + if(*textptr == 0x0a) line_number++; + textptr++; + if( *textptr == 0 ) break; + } + j = 0; + while( isaltok(*(textptr+j)) ) + { + env_music_fn[i][j] = textptr[j]; + j++; + } + env_music_fn[i][j] = '\0'; + + textptr += j; + if(i > 9) break; + i++; + } + } + } + return 0; + + case CON_INCLUDE: + scriptptr--; + while( isaltok(*textptr) == 0 ) + { + if(*textptr == 0x0a) line_number++; + textptr++; + if( *textptr == 0 ) break; + } + j = 0; + while( isaltok(*textptr) ) + { + tempbuf[j] = *(textptr++); + j++; + } + tempbuf[j] = '\0'; + + { + short temp_line_number; + char temp_ifelse_check; + char *origtptr, *mptr; + char parentcompilefile[255]; + int fp; + + fp = kopen4load(tempbuf,loadfromgrouponly); + if(fp < 0) + { + error++; + initprintf("%s:%ld: error: could not find file `%s'.\n",compilefile,line_number,tempbuf); + return 0; + } + + j = kfilelength(fp); + + mptr = (char *)Bmalloc(j+1); + if (!mptr) + { + kclose(fp); + error++; + initprintf("%s:%ld: error: could not allocate %ld bytes to include `%s'.\n", + line_number,compilefile,j,tempbuf); + return 0; + } + + initprintf("Including: %s (%ld bytes)\n",tempbuf, j); + kread(fp, mptr, j); + kclose(fp); + mptr[j] = 0; + + if (*textptr == '"') // skip past the closing quote if it's there so we don't screw up the next line + textptr++; + origtptr = textptr; + + Bstrcpy(parentcompilefile, compilefile); + Bstrcpy(compilefile, tempbuf); + temp_line_number = line_number; + line_number = 1; + temp_ifelse_check = checking_ifelse; + checking_ifelse = 0; + + textptr = mptr; + do done = parsecommand(); while (!done); + + Bstrcpy(compilefile, parentcompilefile); + total_lines += line_number; + line_number = temp_line_number; + checking_ifelse = temp_ifelse_check; + + textptr = origtptr; + + Bfree(mptr); + } + return 0; + + case CON_AI: + if( parsing_actor || parsing_state ) + { + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transnum(LABEL_AI); + } + else + { + scriptptr--; + getlabel(); + + for(i=0;i= 0) break; + if(j == 1) + transnum(LABEL_ACTION); + else if(j == 2) + { + transnum(LABEL_MOVE); + k = 0; + while(keyword() == -1) + { + transnum(LABEL_DEFINE); + scriptptr--; + k |= *scriptptr; + } + *scriptptr = k; + scriptptr++; + return 0; + } + } + for(k=j;k<3;k++) + { + *scriptptr = 0; + scriptptr++; + } + } + return 0; + + case CON_ACTION: + if( parsing_actor || parsing_state ) + { + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transnum(LABEL_ACTION); + } + else + { + scriptptr--; + getlabel(); + // Check to see it's already defined + + for(i=0;i= 0) break; + transnum(LABEL_DEFINE); + } + for(k=j;k<5;k++) + { + *scriptptr = 0; + scriptptr++; + } + } + return 0; + + case CON_ACTOR: + if( parsing_state || parsing_actor ) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + num_braces = 0; + scriptptr--; + parsing_actor = scriptptr; + + skipcomments(); + j = 0; + while( isaltok(*(textptr+j)) ) + { + parsing_item_name[j] = textptr[j]; + j++; + } + parsing_item_name[j] = 0; + transnum(LABEL_DEFINE); + // Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6)); + scriptptr--; + actorscrptr[*scriptptr] = parsing_actor; + + for(j=0;j<4;j++) + { + *(parsing_actor+j) = 0; + if(j == 3) + { + j = 0; + while(keyword() == -1) + { + transnum(LABEL_DEFINE); + scriptptr--; + j |= *scriptptr; + } + *scriptptr = j; + scriptptr++; + break; + } + else + { + if(keyword() >= 0) + { + scriptptr += (4-j); + break; + } + switch(j) + { + case 0: transnum(LABEL_DEFINE); break; + case 1: transnum(LABEL_ACTION); break; + case 2: transnum(LABEL_MOVE|LABEL_DEFINE); break; + } + *(parsing_actor+j) = *(scriptptr-1); + } + } + checking_ifelse = 0; + return 0; + + case CON_ONEVENT: + if( parsing_state || parsing_actor ) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + num_braces = 0; + scriptptr--; + parsing_event = scriptptr; + parsing_actor = scriptptr; + + skipcomments(); + j = 0; + while( isaltok(*(textptr+j)) ) + { + parsing_item_name[j] = textptr[j]; + j++; + } + parsing_item_name[j] = 0; + labelsonly = 1; + transnum(LABEL_DEFINE); + labelsonly = 0; + scriptptr--; + j= *scriptptr; // type of event + current_event = j; + //Bsprintf(g_szBuf,"Adding Event for %d at %lX",j, parsing_event); + //AddLog(g_szBuf); + if(j>=MAXGAMEEVENTS || j < 0) + { + initprintf("%s:%ld: error: invalid event ID.\n",compilefile,line_number); + error++; + return 0; + } + + if(apScriptGameEvent[j]) + { + tempscrptr = parsing_event; + parsing_event = parsing_actor = 0; + ReportError(-1); + parsing_event = parsing_actor = tempscrptr; + initprintf("%s:%ld: warning: duplicate event `%s'.\n",compilefile,line_number,parsing_item_name); + } + else apScriptGameEvent[j]=parsing_event; + + checking_ifelse = 0; + + return 0; + + case CON_EVENTLOADACTOR: + if( parsing_state || parsing_actor ) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + num_braces = 0; + scriptptr--; + parsing_actor = scriptptr; + + skipcomments(); + j = 0; + while( isaltok(*(textptr+j)) ) + { + parsing_item_name[j] = textptr[j]; + j++; + } + parsing_item_name[j] = 0; + transnum(LABEL_DEFINE); + scriptptr--; + actorLoadEventScrptr[*scriptptr] = parsing_actor; + + checking_ifelse = 0; + return 0; + + case CON_USERACTOR: + if( parsing_state || parsing_actor ) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + num_braces = 0; + scriptptr--; + parsing_actor = scriptptr; + + transnum(LABEL_DEFINE); + scriptptr--; + + skipcomments(); + j = 0; + while( isaltok(*(textptr+j)) ) + { + parsing_item_name[j] = textptr[j]; + j++; + } + parsing_item_name[j] = 0; + + j = *scriptptr; + transnum(LABEL_DEFINE); + scriptptr--; + actorscrptr[*scriptptr] = parsing_actor; + actortype[*scriptptr] = j; + + for(j=0;j<4;j++) + { + *(parsing_actor+j) = 0; + if(j == 3) + { + j = 0; + while(keyword() == -1) + { + transnum(LABEL_DEFINE); + scriptptr--; + j |= *scriptptr; + } + *scriptptr = j; + scriptptr++; + break; + } + else + { + if(keyword() >= 0) + { + for (i=4-j; i; i--) *(scriptptr++) = 0; + break; + } + switch(j) + { + case 0: transnum(LABEL_DEFINE); break; + case 1: transnum(LABEL_ACTION); break; + case 2: transnum(LABEL_MOVE|LABEL_DEFINE); break; + } + *(parsing_actor+j) = *(scriptptr-1); + } + } + checking_ifelse = 0; + return 0; + + case CON_INSERTSPRITEQ: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + return 0; + + case CON_DYNQUOTE: + transnum(LABEL_DEFINE); + for(j = 0;j < 4;j++) + { + if( keyword() == -1 ) + transvar(); + else break; + } + + while(j < 4) + { + *scriptptr = 0; + scriptptr++; + j++; + } + return 0; + + case CON_ESPAWN: + case CON_ESHOOT: + case CON_QSPAWN: + case CON_EQSPAWN: + case CON_STRENGTH: + case CON_SHOOT: + case CON_ADDPHEALTH: + case CON_SPAWN: + case CON_CSTAT: + case CON_COUNT: + case CON_ENDOFGAME: + case CON_SPRITEPAL: + case CON_CACTOR: + case CON_MONEY: + case CON_ADDKILLS: + case CON_DEBUG: + case CON_ADDSTRENGTH: + case CON_CSTATOR: + case CON_MAIL: + case CON_PAPER: + case CON_SLEEPTIME: + case CON_CLIPDIST: + case CON_LOTSOFGLASS: + case CON_SAVE: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_ANGOFF: + case CON_USERQUOTE: + case CON_QUOTE: + case CON_SOUND: + case CON_GLOBALSOUND: + case CON_SOUNDONCE: + case CON_STOPSOUND: + transnum(LABEL_DEFINE); + if (tw == CON_CSTAT) + { + if(*(scriptptr-1) == 32767) + { + ReportError(-1); + initprintf("%s:%ld: warning: tried to set cstat 32767, using 32768 instead.\n",compilefile,line_number); + *(scriptptr-1) = 32768; + } + else if((*(scriptptr-1) & 32) && (*(scriptptr-1) & 16)) + { + i = *(scriptptr-1); + *(scriptptr-1) ^= 48; + ReportError(-1); + initprintf("%s:%ld: warning: tried to set cstat %ld, using %ld instead.\n",compilefile,line_number,i,*(scriptptr-1)); + } + } + return 0; + + case CON_HITRADIUS: + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + case CON_ADDAMMO: + case CON_ADDWEAPON: + case CON_SIZETO: + case CON_SIZEAT: + case CON_DEBRIS: + case CON_ADDINVENTORY: + case CON_GUTS: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + break; + + case CON_ELSE: + if( checking_ifelse ) + { + checking_ifelse--; + tempscrptr = scriptptr; + scriptptr++; //Leave a spot for the fail location + parsecommand(); + *tempscrptr = (long) scriptptr; + } + else + { + scriptptr--; + error++; + ReportError(-1); + initprintf("%s:%ld: error: found `else' with no `if'.\n",compilefile,line_number); + } + return 0; + + case CON_SETSECTOR: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETSECTOR: + { + long lLabelID; + + // syntax getsector[].x + // gets the value of sector[].xxx into + + // now get name of .xxx + while((*textptr != '[')) + { + textptr++; + } + if(*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while(*textptr != '.') + { + if(*textptr == 0xa) + break; + if(!*textptr) + break; + + textptr++; + } + if(*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabelid(sectorlabels,label+(labelcnt<<6)); + + if(lLabelID == -1 ) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + *scriptptr++=lLabelID; + + // now at target VAR... + + // get the ID of the DEF + if (tw==CON_GETSECTOR) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_FINDNEARACTOR: + case CON_FINDNEARACTOR3D: + case CON_FINDNEARSPRITE: + case CON_FINDNEARSPRITE3D: + { + + // syntax findnearactor + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + + transnum(LABEL_DEFINE); // get + + transnum(LABEL_DEFINE); // get maxdist + + switch(tw) + { + case CON_FINDNEARACTOR3D: + case CON_FINDNEARSPRITE3D: + transnum(LABEL_DEFINE); + default: + break; + } + + // target var + // get the ID of the DEF + transvartype(GAMEVAR_FLAG_READONLY); + break; + } + + case CON_FINDNEARACTORVAR: + case CON_FINDNEARACTOR3DVAR: + case CON_FINDNEARSPRITEVAR: + case CON_FINDNEARSPRITE3DVAR: + { + + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + + transnum(LABEL_DEFINE); // get + + // get the ID of the DEF + transvar(); + switch(tw) + { + case CON_FINDNEARACTOR3DVAR: + case CON_FINDNEARSPRITE3DVAR: + transvar(); + default: + break; + } + // target var + // get the ID of the DEF + transvartype(GAMEVAR_FLAG_READONLY); + break; + } + + case CON_SQRT: + { + // syntax sqrt + // gets the sqrt of invar into outvar + + // get the ID of the DEF + transvar(); + // target var + // get the ID of the DEF + transvartype(GAMEVAR_FLAG_READONLY); + break; + } + + case CON_SETWALL: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETWALL: + { + long lLabelID; + + + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while((*textptr != '[')) + { + textptr++; + } + if(*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while(*textptr != '.') + { + if(*textptr == 0xa) + break; + if(!*textptr) + break; + + textptr++; + } + if(*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabelid(walllabels,label+(labelcnt<<6)); + + if(lLabelID == -1 ) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + *scriptptr++=lLabelID; + + // now at target VAR... + + // get the ID of the DEF + if (tw == CON_GETWALL) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_SETPLAYER: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETPLAYER: + { + long lLabelID; + + + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while((*textptr != '[')) + { + textptr++; + } + if(*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while(*textptr != '.') + { + if(*textptr == 0xa) + break; + if(!*textptr) + break; + + textptr++; + } + if(*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabeloffset(playerlabels,label+(labelcnt<<6)); + //printf("LabelID is %ld\n",lLabelID); + if(lLabelID == -1 ) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + + *scriptptr++=playerlabels[lLabelID].lId; + + //printf("member's flags are: %02Xh\n",playerlabels[lLabelID].flags); + if (playerlabels[lLabelID].flags & LABEL_HASPARM2) + { + //printf("Member has PARM2\n"); + // get parm2 + // get the ID of the DEF + transvar(); + } + else + { + //printf("Member does not have Parm2\n"); + } + + // now at target VAR... + + // get the ID of the DEF + if (tw==CON_GETPLAYER) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_SETINPUT: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETINPUT: + { + long lLabelID; + + + // syntax getwall[].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while((*textptr != '[')) + { + textptr++; + } + if(*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while(*textptr != '.') + { + if(*textptr == 0xa) + break; + if(!*textptr) + break; + + textptr++; + } + if(*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabeloffset(inputlabels,label+(labelcnt<<6)); + //printf("LabelID is %ld\n",lLabelID); + if(lLabelID == -1 ) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + + *scriptptr++=inputlabels[lLabelID].lId; + + // now at target VAR... + + // get the ID of the DEF + if (tw==CON_GETINPUT) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_SETUSERDEF: + case CON_GETUSERDEF: + { + long lLabelID; + + // syntax [gs]etuserdef.x + // gets the value of ud.xxx into + + // now get name of .xxx + while(*textptr != '.') + { + if(*textptr == 0xa) + break; + if(!*textptr) + break; + + textptr++; + } + if(*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabelid(userdefslabels,label+(labelcnt<<6)); + + if(lLabelID == -1 ) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + *scriptptr++=lLabelID; + + // now at target VAR... + + // get the ID of the DEF + if (tw==CON_GETUSERDEF) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_SETACTORVAR: + case CON_SETPLAYERVAR: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETACTORVAR: + case CON_GETPLAYERVAR: + { + // syntax [gs]etactorvar[]. + // gets the value of the per-actor variable varx into VAR + + // now get name of + while((*textptr != '[')) + { + textptr++; + } + if(*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of . + while(*textptr != '.') + { + if(*textptr == 0xa) + break; + if(!*textptr) + break; + + textptr++; + } + if(*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + + // get the ID of the DEF + getlabel(); + //printf("found label of '%s'\n", label+(labelcnt<<6)); + + // Check to see if it's a keyword + for(i=0;i].x + // gets the value of wall[].xxx into + + // now get name of .xxx + while((*textptr != '[')) + { + textptr++; + } + if(*textptr == '[') + textptr++; + + // get the ID of the DEF + labelsonly = 1; + transvar(); + labelsonly = 0; + // now get name of .xxx + while(*textptr != '.') + { + if(*textptr == 0xa) + break; + if(!*textptr) + break; + + textptr++; + } + if(*textptr!='.') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + textptr++; + /// now pointing at 'xxx' + getlabel(); + //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + + lLabelID=getlabeloffset(actorlabels,label+(labelcnt<<6)); + //printf("LabelID is %ld\n",lLabelID); + if(lLabelID == -1 ) + { + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + + *scriptptr++=actorlabels[lLabelID].lId; + + //printf("member's flags are: %02Xh\n",actorlabels[lLabelID].flags); + if (actorlabels[lLabelID].flags & LABEL_HASPARM2) + { + //printf("Member has PARM2\n"); + // get parm2 + // get the ID of the DEF + transvar(); + } + else + { + //printf("Member does not have Parm2\n"); + } + + // now at target VAR... + + // get the ID of the DEF + if(tw == CON_GETACTOR) + transvartype(GAMEVAR_FLAG_READONLY); + else + transvar(); + break; + } + + case CON_ESHOOTVAR: + case CON_ESPAWNVAR: + case CON_QSPAWNVAR: + case CON_EQSPAWNVAR: + case CON_OPERATERESPAWNS: + case CON_OPERATEMASTERSWITCHES: + case CON_CHECKACTIVATORMOTION: + case CON_TIME: + case CON_INITTIMER: + case CON_LOCKPLAYER: + case CON_SHOOTVAR: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_SOUNDVAR: + case CON_GLOBALSOUNDVAR: + case CON_STOPSOUNDVAR: + case CON_SOUNDONCEVAR: + case CON_ANGOFFVAR: + case CON_CHECKAVAILWEAPON: + case CON_CHECKAVAILINVEN: + case CON_GUNIQHUDID: + case CON_SAVEGAMEVAR: + case CON_READGAMEVAR: + transvar(); + return 0; + + case CON_ENHANCED: + { + // don't store in pCode... + scriptptr--; + //printf("We are enhanced, baby...\n"); + transnum(LABEL_DEFINE); + scriptptr--; + if(*scriptptr > BYTEVERSION_JF) + { + warning++; + initprintf("%s:%ld: warning: need build %ld, found build %ld\n",compilefile,line_number,k,BYTEVERSION_JF); + } + break; + } + + case CON_DYNAMICREMAP: + { + scriptptr--; + initprintf("Dynamic tile remapping enabled.\n"); + dynamicremap = 1; + break; + } + + case CON_RANDVAR: + case CON_ZSHOOT: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_SETVAR: + case CON_ADDVAR: + case CON_SUBVAR: + case CON_DISPLAYRANDVAR: + case CON_MULVAR: + case CON_DIVVAR: + case CON_MODVAR: + case CON_ANDVAR: + case CON_ORVAR: + case CON_XORVAR: + case CON_SHIFTVARL: + case CON_SHIFTVARR: + + // syntax: [rand|add|set]var + // sets var1 to const1 + // adds const1 to var1 (const1 can be negative...) + //printf("Found [add|set]var at line= %ld\n",line_number); + + // get the ID of the DEF + if(tw != CON_ZSHOOT) + transvartype(GAMEVAR_FLAG_READONLY); + else transvar(); + + transnum(LABEL_DEFINE); // the number to check against... + return 0; + case CON_RANDVARVAR: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_SETVARVAR: + case CON_ADDVARVAR: + case CON_SUBVARVAR: + case CON_MULVARVAR: + case CON_DIVVARVAR: + case CON_MODVARVAR: + case CON_ANDVARVAR: + case CON_ORVARVAR: + case CON_XORVARVAR: + case CON_DISPLAYRANDVARVAR: + case CON_SIN: + case CON_COS: + transvartype(GAMEVAR_FLAG_READONLY); + transvar(); + return 0; + + case CON_SMAXAMMO: + case CON_ADDWEAPONVAR: + case CON_ACTIVATEBYSECTOR: + case CON_OPERATESECTORS: + case CON_OPERATEACTIVATORS: + case CON_SSP: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GMAXAMMO: + case CON_DIST: + case CON_LDIST: + case CON_TXDIST: + case CON_GETANGLE: + case CON_MULSCALE: + case CON_SETASPECT: + // get the ID of the DEF + switch(tw) + { + case CON_DIST: + case CON_LDIST: + case CON_TXDIST: + case CON_GETANGLE: + transvartype(GAMEVAR_FLAG_READONLY); + break; + default: + transvar(); + break; + } + + // get the ID of the DEF + if (tw == CON_GMAXAMMO) + transvartype(GAMEVAR_FLAG_READONLY); + else transvar(); + + switch(tw) + { + case CON_DIST: + case CON_LDIST: + case CON_TXDIST: + case CON_GETANGLE: + transvartype(GAMEVAR_FLAG_READONLY); + break; + case CON_MULSCALE: + transmultvars(2); + break; + } + return 0; + + case CON_FLASH: + return 0; + + case CON_DRAGPOINT: + transmultvars(3); + return 0; + + case CON_GETFLORZOFSLOPE: + case CON_GETCEILZOFSLOPE: + transmultvars(3); + transvartype(GAMEVAR_FLAG_READONLY); + return 0; + + case CON_DEFINEPROJECTILE: + { + short y; + signed long z; + + if( parsing_state || parsing_actor ) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + scriptptr--; + + transnum(LABEL_DEFINE); + j = *(scriptptr-1); + + if(j>=MAXTILES) + { + ReportError(ERROR_EXCEEDSMAXTILES); + error++; + } + + transnum(LABEL_DEFINE); + y = *(scriptptr-1); + transnum(LABEL_DEFINE); + z = *(scriptptr-1); + + DefineProjectile(j,y,z); + spriteflags[j] |= SPRITE_FLAG_PROJECTILE; + return 0; + } + + case CON_PROJECTILE: + { + int y; + signed long z; + char *bracepos; + + scriptptr--; + + if( parsing_state || parsing_actor ) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + transnum(LABEL_DEFINE); + scriptptr--; + j = *(scriptptr); + if(j>=MAXTILES) + { + ReportError(ERROR_EXCEEDSMAXTILES); + error++; + } + + num_braces = 0; + skipcomments(); + if(textptr[0]!='{') + { + while(textptr[0] != '}') + { + textptr++; + if (textptr[0] == '\n' || textptr[0] == '\r') + line_number++; + } + if(textptr[0]=='}') + textptr++; + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + num_braces++; + temptextptr = ++textptr; + + while(textptr[0] != '}') + textptr++; + if(textptr[0]!='}') + { + error++; + ReportError(ERROR_SYNTAXERROR); + return 0; + } + + bracepos=textptr; + textptr=temptextptr; + + while(textptr < bracepos) + { + getlabel(); + initprintf("%s:%ld: debug: label is `%s'\n",compilefile,line_number,label+(labelcnt<<6)); + y=getlabeloffset(projectilelabels,label+(labelcnt<<6)); + if(y != -1 ) + { + nokeywordcheck = 1; + transnum(LABEL_DEFINE); + nokeywordcheck = 0; + scriptptr--; + z = *(scriptptr); + DefineProjectile(j,y,z); + skipcomments(); + continue; + } + error++; + ReportError(ERROR_SYMBOLNOTRECOGNIZED); + return 0; + } + textptr = bracepos; + if(textptr[0] != '}') + { + initprintf("%s:%ld: error: EOF in projectile definition!\n",compilefile,line_number); + error++; + return 0; + } + num_braces--; + textptr++; + spriteflags[j] |= SPRITE_FLAG_PROJECTILE; + return 0; + } + + case CON_SPRITEFLAGS: + { + if( parsing_actor == 0 && parsing_state == 0 ) + { + scriptptr--; + + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + + if(j>=MAXTILES) + { + ReportError(ERROR_EXCEEDSMAXTILES); + error++; + } + + transnum(LABEL_DEFINE); + scriptptr--; + spriteflags[j] = *scriptptr; + + return 0; + } + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transvar(); + return 0; + } + + case CON_SPRITESHADOW: + case CON_SPRITENVG: + case CON_SPRITENOSHADE: + case CON_PRECACHE: + { + if( parsing_state || parsing_actor ) + { + ReportError(ERROR_FOUNDWITHIN); + error++; + } + + scriptptr--; + + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + + if(j>=MAXTILES) + { + ReportError(ERROR_EXCEEDSMAXTILES); + error++; + } + + switch (tw) + { + case CON_SPRITESHADOW: + spriteflags[*scriptptr] |= SPRITE_FLAG_SHADOW; + break; + case CON_SPRITENVG: + spriteflags[*scriptptr] |= SPRITE_FLAG_NVG; + break; + case CON_SPRITENOSHADE: + spriteflags[*scriptptr] |= SPRITE_FLAG_NOSHADE; + break; + case CON_PRECACHE: + spritecache[*scriptptr][0] = j; + transnum(LABEL_DEFINE); + scriptptr--; + i = *scriptptr; + if(i>=MAXTILES) + { + ReportError(ERROR_EXCEEDSMAXTILES); + error++; + } + spritecache[j][1] = i; + transnum(LABEL_DEFINE); + scriptptr--; + i = *scriptptr; + spritecache[j][2] = i; + break; + } + return 0; + } + + case CON_IFVARVARG: + case CON_IFVARVARL: + case CON_IFVARVARE: + case CON_IFVARVARN: + case CON_IFVARVARAND: + case CON_WHILEVARVARN: + transmultvars(2); + tempscrptr = scriptptr; + scriptptr++; // Leave a spot for the fail location + + j = keyword(); + parsecommand(); + + *tempscrptr = (long) scriptptr; + + if(tw != CON_WHILEVARVARN) checking_ifelse++; + return 0; + + case CON_SPGETLOTAG: + case CON_SPGETHITAG: + case CON_SECTGETLOTAG: + case CON_SECTGETHITAG: + case CON_GETTEXTUREFLOOR: + case CON_GETTEXTURECEILING: + // no paramaters... + return 0; + + case CON_STARTTRACK: + // one parameter (track#) + transnum(LABEL_DEFINE); + return 0; + + case CON_IFVARL: + case CON_IFVARG: + case CON_IFVARE: + case CON_IFVARN: + case CON_IFVARAND: + case CON_WHILEVARN: + + // get the ID of the DEF + transvar(); + transnum(LABEL_DEFINE); // the number to check against... + + tempscrptr = scriptptr; + scriptptr++; //Leave a spot for the fail location + + j = keyword(); + parsecommand(); + + *tempscrptr = (long) scriptptr; + + if(tw != CON_WHILEVARN) checking_ifelse++; + return 0; + + case CON_ADDLOGVAR: + + // syntax: addlogvar + + // prints the line number in the log file. + *scriptptr=line_number; + scriptptr++; + + // get the ID of the DEF + transvar(); + return 0; + + case CON_ROTATESPRITE: + if( parsing_event == 0 && parsing_state == 0) + { + ReportError(ERROR_EVENTONLY); + error++; + } + + // syntax: + // long x, long y, long z, short a, short tilenum, signed char shade, char orientation, x1, y1, x2, y2 + // myospal adds char pal + + // get the ID of the DEFs + + transmultvars(12); + break; + + case CON_GETZRANGE: + transmultvars(4); + transmultvarstype(GAMEVAR_FLAG_READONLY,4); + transmultvars(2); + break; + + case CON_HITSCAN: + // get the ID of the DEF + transmultvars(7); + transmultvarstype(GAMEVAR_FLAG_READONLY,6); + transvar(); + break; + + case CON_ROTATEPOINT: + case CON_NEARTAG: + transmultvars(5); + transmultvarstype(GAMEVAR_FLAG_READONLY,2); + if (tw == CON_NEARTAG) + { + transmultvarstype(GAMEVAR_FLAG_READONLY,2); + transmultvars(2); + } + break; + + case CON_MOVESPRITE: + case CON_SETSPRITE: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + transmultvars(4); + if (tw == CON_MOVESPRITE) + transvar(); + break; + + case CON_MINITEXT: + case CON_GAMETEXT: + case CON_DIGITALNUMBER: + if( parsing_event == 0 && parsing_state == 0) + { + ReportError(ERROR_EVENTONLY); + error++; + } + + switch(tw) + { + case CON_GAMETEXT: + case CON_DIGITALNUMBER: + transmultvars(6); + default: + transmultvars(5); + break; + } + break; + + case CON_UPDATESECTOR: + case CON_UPDATESECTORZ: + transmultvars(2); + if (tw==CON_UPDATESECTORZ) + transvar(); + transvartype(GAMEVAR_FLAG_READONLY); + break; + + case CON_MYOS: + case CON_MYOSPAL: + case CON_MYOSX: + case CON_MYOSPALX: + if( parsing_event == 0 && parsing_state == 0) + { + ReportError(ERROR_EVENTONLY); + error++; + } + + // syntax: + // long x, long y, short tilenum, signed char shade, char orientation + // myospal adds char pal + + transmultvars(5); + if(tw==CON_MYOSPAL || tw==CON_MYOSPALX) + { + // Parse: pal + + // get the ID of the DEF + transvar(); + } + break; + + case CON_FINDPLAYER: + case CON_FINDOTHERPLAYER: + case CON_DISPLAYRAND: + + // syntax: displayrand + // gets rand (not game rand) into + + // Get The ID of the DEF + transvartype(GAMEVAR_FLAG_READONLY); + break; + + case CON_SWITCH: + //AddLog("Got Switch statement"); + if(checking_switch) + { + // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=",__FILE__,__LINE__, checking_switch); + // AddLog(g_szBuf); + } + checking_switch++; // allow nesting (if other things work) + // Get The ID of the DEF + transvar(); + + tempscrptr= scriptptr; + *scriptptr++=0; // leave spot for end location (for after processing) + *scriptptr++=0; // count of case statements + casescriptptr=scriptptr; // the first case's pointer. + + *scriptptr++=0; // leave spot for 'default' location (null if none) + + j = keyword(); + temptextptr=textptr; + // probably does not allow nesting... + + //AddLog("Counting Case Statements..."); + + j=CountCaseStatements(); + //Bsprintf(g_szBuf,"Done Counting Case Statements: found %d.", j); + //AddLog(g_szBuf); + if(checking_switch>1) + { + // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=",__FILE__,__LINE__, checking_switch); + // AddLog(g_szBuf); + } + if( j<0 ) + { + return 1; + } + if (tempscrptr) + { + tempscrptr[1]=(long)j; // save count of cases + } + else + { + //Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__); + //AddLog(g_szBuf); + } + + while(j--) + { + // leave room for statements + *scriptptr++=0; // value check + *scriptptr++=0; // code offset + } + + //Bsprintf(g_szBuf,"SWITCH1: '%.22s'",textptr); + //AddLog(g_szBuf); + + casecount=0; + + while ( parsecommand() == 0 ) + { + //Bsprintf(g_szBuf,"SWITCH2: '%.22s'",textptr); + //AddLog(g_szBuf); + } + //Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr); + //AddLog(g_szBuf); + // done processing switch. clean up. + if(checking_switch!=1) + { + // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=%d",__FILE__,__LINE__, checking_switch); + // AddLog(g_szBuf); + } + casecount=0; + if (tempscrptr) + { + tempscrptr[0]= (long)scriptptr - (long)&script[0]; // save 'end' location + } + else + { + //Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__); + //AddLog(g_szBuf); + } + casescriptptr=NULL; + // decremented in endswitch. Don't decrement here... + // checking_switch--; // allow nesting (maybe if other things work) + tempscrptr=NULL; + if(checking_switch) + { + //Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=%d",__FILE__,__LINE__, checking_switch); + //AddLog(g_szBuf); + } + //AddLog("End of Switch statement"); + break; + + case CON_CASE: + //AddLog("Found Case"); +repeatcase: + scriptptr--; // don't save in code + if(checking_switch<1) + { + error++; + ReportError(-1); + initprintf("%s:%ld: error: found `case' statement when not in switch\n",compilefile,line_number); + return 1; + } + casecount++; + //Bsprintf(g_szBuf,"case1: %.12s",textptr); + //AddLog(g_szBuf); + transnum(LABEL_DEFINE); + if(*textptr == ':') + textptr++; + //Bsprintf(g_szBuf,"case2: %.12s",textptr); + //AddLog(g_szBuf); + + j=*(--scriptptr); // get value + //Bsprintf(g_szBuf,"case: Value of case %ld is %ld",(long)casecount,(long)j); + //AddLog(g_szBuf); + if( casescriptptr) + { + //AddLog("Adding value to script"); + casescriptptr[casecount++]=j; // save value + casescriptptr[casecount]=(long)((long*)scriptptr-&script[0]); // save offset + } + // j = keyword(); + //Bsprintf(g_szBuf,"case3: %.12s",textptr); + //AddLog(g_szBuf); + + j = keyword(); + if (j == CON_CASE) + { + //AddLog("Found Repeat Case"); + transword(); // eat 'case' + goto repeatcase; + } + //Bsprintf(g_szBuf,"case4: '%.12s'",textptr); + //AddLog(g_szBuf); + while(parsecommand() == 0) + { + //Bsprintf(g_szBuf,"case5 '%.25s'",textptr); + //AddLog(g_szBuf); + j = keyword(); + if (j == CON_CASE) + { + //AddLog("Found Repeat Case"); + transword(); // eat 'case' + goto repeatcase; + } + } + //AddLog("End Case"); + return 0; + // break; + case CON_DEFAULT: + scriptptr--; // don't save + if(checking_switch<1) + { + error++; + ReportError(-1); + initprintf("%s:%ld: error: found `default' statement when not in switch\n",compilefile,line_number); + return 1; + } + if(casescriptptr && casescriptptr[0]!=0) + { + // duplicate default statement + error++; + ReportError(-1); + initprintf("%s:%ld: error: multiple `default' statements found in switch\n",compilefile,line_number); + } + if (casescriptptr) + { + casescriptptr[0]=(long)(scriptptr-&script[0]); // save offset + } + //Bsprintf(g_szBuf,"default: '%.22s'",textptr); + //AddLog(g_szBuf); + while( parsecommand() == 0) + { + //Bsprintf(g_szBuf,"defaultParse: '%.22s'",textptr); + //AddLog(g_szBuf); + ; + } + break; + + case CON_ENDSWITCH: + //AddLog("End Switch"); + checking_switch--; + if(checking_switch < 0 ) + { + error++; + ReportError(-1); + initprintf("%s:%ld: error: found `endswitch' without matching `switch'\n",compilefile,line_number); + } + if (casescriptptr) + { + int i; + + //Bsprintf(g_szBuf,"Default Offset is %ld\n Total of %ld cases",casescriptptr[0],(long)casecount/2); + //AddLog(g_szBuf); + for(i=1;i<=casecount;i++) + { + if (i & 1) + { + //Bsprintf(g_szBuf,"Case Value %d is %ld",i/2+1,casescriptptr[i]); + //AddLog(g_szBuf); + } + else + { + //Bsprintf(g_szBuf,"Offset %d is %ld",i/2+1,casescriptptr[i]); + //AddLog(g_szBuf); + } + } + } + else + { + //AddLog("Not saving case value: just counting"); + } + return 1; // end of block + break; + + case CON_CHANGESPRITESTAT: + case CON_CHANGESPRITESECT: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETPNAME: + case CON_STARTLEVEL: + case CON_QSTRCAT: + case CON_QSTRCPY: + transmultvars(2); + return 0; + case CON_SETACTORANGLE: + case CON_SETPLAYERANGLE: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_GETANGLETOTARGET: + case CON_GETACTORANGLE: + case CON_GETPLAYERANGLE: + // Syntax: + + // get the ID of the DEF + transvar(); + return 0; + + case CON_ADDLOG: + // syntax: addlog + + // prints the line number in the log file. + *scriptptr=line_number; + scriptptr++; + return 0; + + case CON_IFPINVENTORY: + case CON_IFRND: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_IFPDISTL: + case CON_IFPDISTG: + case CON_IFWASWEAPON: + case CON_IFACTIONCOUNT: + case CON_IFCOUNT: + case CON_IFACTOR: + case CON_IFSTRENGTH: + case CON_IFSPAWNEDBY: + case CON_IFGAPZL: + case CON_IFFLOORDISTL: + case CON_IFCEILINGDISTL: + // case 74: + case CON_IFPHEALTHL: + case CON_IFSPRITEPAL: + case CON_IFGOTWEAPONCE: + case CON_IFANGDIFFL: + case CON_IFSOUND: + case CON_IFAI: + case CON_IFACTION: + case CON_IFMOVE: + switch(tw) + { + case CON_IFAI: + transnum(LABEL_AI); + break; + case CON_IFACTION: + transnum(LABEL_ACTION); + break; + case CON_IFMOVE: + transnum(LABEL_MOVE); + break; + case CON_IFPINVENTORY: + transnum(LABEL_DEFINE); + transnum(LABEL_DEFINE); + break; + default: + transnum(LABEL_DEFINE); + break; + } + case CON_IFONWATER: + case CON_IFINWATER: + case CON_IFACTORNOTSTAYPUT: + case CON_IFCANSEE: + case CON_IFHITWEAPON: + case CON_IFSQUISHED: + case CON_IFDEAD: + case CON_IFCANSHOOTTARGET: + case CON_IFP: + case CON_IFHITSPACE: + case CON_IFOUTSIDE: + case CON_IFMULTIPLAYER: + case CON_IFINSPACE: + case CON_IFBULLETNEAR: + case CON_IFRESPAWN: + case CON_IFINOUTERSPACE: + case CON_IFNOTMOVING: + case CON_IFAWAYFROMWALL: + case CON_IFCANSEETARGET: + case CON_IFNOSOUNDS: + if(tw == CON_IFP) + { + j = 0; + do + { + transnum(LABEL_DEFINE); + scriptptr--; + j |= *scriptptr; + } + while(keyword() == -1); + *scriptptr = j; + scriptptr++; + } + + tempscrptr = scriptptr; + scriptptr++; //Leave a spot for the fail location + + j = keyword(); + parsecommand(); + + *tempscrptr = (long) scriptptr; + + checking_ifelse++; + return 0; + + case CON_LEFTBRACE: + if(!(parsing_state || parsing_actor || parsing_event)) + { + error++; + ReportError(ERROR_SYNTAXERROR); + } + num_braces++; + do + done = parsecommand(); + while( done == 0 ); + return 0; + + case CON_RIGHTBRACE: + num_braces--; + if( num_braces < 0 ) + { + if(checking_switch) + { + ReportError(ERROR_NOENDSWITCH); + } + + ReportError(-1); + initprintf("%s:%ld: error: found more `}' than `{'.\n",compilefile,line_number); + error++; + } + return 1; + + case CON_BETANAME: + scriptptr--; + j = 0; + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) + { + betaname[j] = *textptr; + j++; textptr++; + } + betaname[j] = 0; + return 0; + + case CON_DEFINEVOLUMENAME: + scriptptr--; + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + while( *textptr == ' ' ) textptr++; + + if (j < 0 || j > 6) + { + initprintf("%s:%ld: error: volume number exceeds maximum volume count.\n",compilefile,line_number); + error++; + while( *textptr != 0x0a && *textptr != 0 ) textptr++; + break; + } + + + i = 0; + + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) + { + volume_names[j][i] = toupper(*textptr); + textptr++,i++; + if(i >= (signed)sizeof(volume_names[j])-1) + { + initprintf("%s:%ld: error: volume name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(volume_names[j])-1); + error++; + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) textptr++; + break; + } + } + num_volumes = j+1; + volume_names[j][i] = '\0'; + return 0; + + case CON_DEFINESKILLNAME: + scriptptr--; + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + while( *textptr == ' ' ) textptr++; + + if (j < 0 || j >= 5) + { + initprintf("%s:%ld: error: skill number exceeds maximum skill count.\n",compilefile,line_number); + error++; + while( *textptr != 0x0a && *textptr != 0 ) textptr++; + break; + } + + + i = 0; + + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) + { + skill_names[j][i] = toupper(*textptr); + textptr++,i++; + if(i >= (signed)sizeof(skill_names[j])-1) + { + initprintf("%s:%ld: error: skill name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(skill_names[j])-1); + error++; + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) textptr++; + break; + } + } + skill_names[j][i] = '\0'; + return 0; + + case CON_DEFINEGAMETYPE: + scriptptr--; //remove opcode from compiled code + transnum(LABEL_DEFINE); //translate number + scriptptr--; //remove it from compiled code + j = *scriptptr; //put it into j + + transnum(LABEL_DEFINE); //translate number + scriptptr--; //remove it from compiled code + gametype_flags[j] = *scriptptr; //put it into the flags + + while( *textptr == ' ' ) textptr++; + + if (j < 0 || j >= MAXGAMETYPES) + { + initprintf("%s:%ld: error: gametype number exceeds maximum gametype count.\n",compilefile,line_number); + error++; + while( *textptr != 0x0a && *textptr != 0 ) textptr++; + break; + } + num_gametypes = j+1; + + i = 0; + + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) + { + gametype_names[j][i] = toupper(*textptr); + textptr++,i++; + if(i >= (signed)sizeof(gametype_names[j])-1) + { + initprintf("%s:%ld: error: gametype name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(gametype_names[j])-1); + error++; + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) textptr++; + break; + } + } + gametype_names[j][i] = '\0'; + return 0; + + case CON_DEFINELEVELNAME: + scriptptr--; + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; + transnum(LABEL_DEFINE); + scriptptr--; + k = *scriptptr; + while( *textptr == ' ' ) textptr++; + + if (j < 0 || j > 6) + { + initprintf("%s:%ld: error: volume number exceeds maximum volume count.\n",compilefile,line_number); + error++; + while( *textptr != 0x0a && *textptr != 0 ) textptr++; + break; + } + if (k < 0 || k >= 11) + { + initprintf("%s:%ld: error: level number exceeds maximum number of levels per episode.\n", + line_number,compilefile); + error++; + while( *textptr != 0x0a && *textptr != 0 ) textptr++; + break; + } + + i = 0; + while( *textptr != ' ' && *textptr != 0x0a ) + { + level_file_names[j*11+k][i] = *textptr; + textptr++,i++; + if(i > BMAX_PATH) + { + initprintf("%s:%ld: error: level file name exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); + error++; + while( *textptr != ' ') textptr++; + break; + } + } + level_names[j*11+k][i] = '\0'; + + while( *textptr == ' ' ) textptr++; + + partime[j*11+k] = + (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ + (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); + + textptr += 5; + while( *textptr == ' ' ) textptr++; + + designertime[j*11+k] = + (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ + (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); + + textptr += 5; + while( *textptr == ' ' ) textptr++; + + i = 0; + + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) + { + level_names[j*11+k][i] = toupper(*textptr); + textptr++,i++; + if(i >= (signed)sizeof(level_names[j*11+k])-1) + { + initprintf("%s:%ld: error: level name exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(level_names[j*11+k])-1); + error++; + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) textptr++; + break; + } + } + level_names[j*11+k][i] = '\0'; + return 0; + + case CON_DEFINEQUOTE: + case CON_REDEFINEQUOTE: + if (tw == CON_DEFINEQUOTE) + scriptptr--; + + transnum(LABEL_DEFINE); + + k = *(scriptptr-1); + + if(k >= NUMOFFIRSTTIMEACTIVE) + { + initprintf("%s:%ld: error: quote number exceeds limit of %ld.\n",compilefile,line_number,NUMOFFIRSTTIMEACTIVE); + error++; + } + + if (tw == CON_DEFINEQUOTE) + scriptptr--; + + i = 0; + + while( *textptr == ' ' ) + textptr++; + + if (tw == CON_REDEFINEQUOTE) + redefined_quotes++; + + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) + { + if(*textptr == '%' && *(textptr+1) == 's') + { + initprintf("%s:%ld: error: quote text contains string identifier.\n",compilefile,line_number); + error++; + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) textptr++; + break; + } + if (tw == CON_DEFINEQUOTE) + fta_quotes[k][i] = *textptr; + else redefined_fta_quotes[redefined_quotes][i] = *textptr; + textptr++,i++; + if(i >= (signed)sizeof(fta_quotes[k])-1) + { + initprintf("%s:%ld: error: quote text exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(fta_quotes[k])-1); + error++; + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) textptr++; + break; + } + } + if (tw == CON_DEFINEQUOTE) + fta_quotes[k][i] = '\0'; + else + { + redefined_fta_quotes[redefined_quotes][i] = '\0'; + *scriptptr++=redefined_quotes; + } + return 0; + + case CON_CHEATKEYS: + scriptptr--; + transnum(LABEL_DEFINE); + cheatkey[0] = *(scriptptr-1); + transnum(LABEL_DEFINE); + cheatkey[1] = *(scriptptr-1); + return 0; + + case CON_DEFINECHEAT: + scriptptr--; + transnum(LABEL_DEFINE); + k = *(scriptptr-1); + + if(k > 25) + { + initprintf("%s:%ld: error: cheat redefinition attempts to redefine nonexistant cheat.\n",compilefile,line_number); + error++; + } + scriptptr--; + i = 0; + while( *textptr == ' ' ) + textptr++; + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 && *textptr != ' ') + { + cheatquotes[k][i] = *textptr; + textptr++,i++; + if(i >= (signed)sizeof(cheatquotes[k])-1) + { + initprintf("%s:%ld: error: cheat exceeds limit of %ld characters.\n",compilefile,line_number,MAXCHEATLEN,sizeof(cheatquotes[k])-1); + error++; + while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 && *textptr != ' ') textptr++; + break; + } + } + cheatquotes[k][i] = '\0'; + return 0; + + case CON_DEFINESOUND: + scriptptr--; + transnum(LABEL_DEFINE); + k = *(scriptptr-1); + if(k >= NUM_SOUNDS) + { + initprintf("%s:%ld: error: exceeded sound limit of %ld.\n",compilefile,line_number,NUM_SOUNDS); + error++; + } + scriptptr--; + i = 0; + while( *textptr == ' ') + textptr++; + + while( *textptr != ' ' ) + { + sounds[k][i] = *textptr; + textptr++,i++; + if(i >= BMAX_PATH) + { + puts(sounds[k]); + initprintf("%s:%ld: error: sound filename exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); + error++; + while( *textptr != ' ' ) textptr++; + break; + } + } + sounds[k][i] = '\0'; + + transnum(LABEL_DEFINE); + soundps[k] = *(scriptptr-1); + scriptptr--; + transnum(LABEL_DEFINE); + soundpe[k] = *(scriptptr-1); + scriptptr--; + transnum(LABEL_DEFINE); + soundpr[k] = *(scriptptr-1); + scriptptr--; + transnum(LABEL_DEFINE); + soundm[k] = *(scriptptr-1); + scriptptr--; + transnum(LABEL_DEFINE); + soundvo[k] = *(scriptptr-1); + scriptptr--; + return 0; + + case CON_ENDEVENT: + + if( parsing_event == 0) + { + ReportError(-1); + initprintf("%s:%ld: error: found `endevent' without open `onevent'.\n",compilefile,line_number); + error++; + } + if( num_braces > 0 ) + { + ReportError(ERROR_OPENBRACKET); + error++; + } + if( num_braces < 0 ) + { + ReportError(ERROR_CLOSEBRACKET); + error++; + } + parsing_event = 0; + parsing_actor = 0; + current_event = -1; + Bsprintf(parsing_item_name,"(none)"); + return 0; + + case CON_ENDA: + if( parsing_actor == 0 ) + { + ReportError(-1); + initprintf("%s:%ld: error: found `enda' without open `actor'.\n",compilefile,line_number); + error++; + } + if( num_braces > 0 ) + { + ReportError(ERROR_OPENBRACKET); + error++; + } + if( num_braces < 0 ) + { + ReportError(ERROR_CLOSEBRACKET); + error++; + } + parsing_actor = 0; + Bsprintf(parsing_item_name,"(none)"); + return 0; + + case CON_BREAK: + if(checking_switch) + { + //Bsprintf(g_szBuf," * (L%ld) case Break statement.\n",line_number); + //AddLog(g_szBuf); + return 1; + } + return 0; + + case CON_FALL: + case CON_TIP: + // case 21: + case CON_KILLIT: + case CON_RESETACTIONCOUNT: + case CON_PSTOMP: + case CON_RESETPLAYER: + case CON_RESETCOUNT: + case CON_WACKPLAYER: + case CON_OPERATE: + case CON_RESPAWNHITAG: + case CON_GETLASTPAL: + case CON_PKICK: + case CON_MIKESND: + case CON_TOSSWEAPON: + if(!CheckEventSync(current_event)) + ReportError(WARNING_EVENTSYNC); + case CON_NULLOP: + case CON_STOPALLSOUNDS: + return 0; + case CON_GAMESTARTUP: + { + long params[30]; + + scriptptr--; + for(j = 0; j < 30; j++) + { + transnum(LABEL_DEFINE); + scriptptr--; + params[j] = *scriptptr; + + if (j != 25) continue; + + if (keyword() != -1) { + initprintf("Version 1.3D CON files detected.\n"); + break; + } else { + conversion = 14; + initprintf("Version 1.4+ CON files detected.\n"); + } + + } + + /* + v1.3d v1.5 + DEFAULTVISIBILITY DEFAULTVISIBILITY + GENERICIMPACTDAMAGE GENERICIMPACTDAMAGE + MAXPLAYERHEALTH MAXPLAYERHEALTH + STARTARMORHEALTH STARTARMORHEALTH + RESPAWNACTORTIME RESPAWNACTORTIME + RESPAWNITEMTIME RESPAWNITEMTIME + RUNNINGSPEED RUNNINGSPEED + RPGBLASTRADIUS GRAVITATIONALCONSTANT + PIPEBOMBRADIUS RPGBLASTRADIUS + SHRINKERBLASTRADIUS PIPEBOMBRADIUS + TRIPBOMBBLASTRADIUS SHRINKERBLASTRADIUS + MORTERBLASTRADIUS TRIPBOMBBLASTRADIUS + BOUNCEMINEBLASTRADIUS MORTERBLASTRADIUS + SEENINEBLASTRADIUS BOUNCEMINEBLASTRADIUS + MAXPISTOLAMMO SEENINEBLASTRADIUS + MAXSHOTGUNAMMO MAXPISTOLAMMO + MAXCHAINGUNAMMO MAXSHOTGUNAMMO + MAXRPGAMMO MAXCHAINGUNAMMO + MAXHANDBOMBAMMO MAXRPGAMMO + MAXSHRINKERAMMO MAXHANDBOMBAMMO + MAXDEVISTATORAMMO MAXSHRINKERAMMO + MAXTRIPBOMBAMMO MAXDEVISTATORAMMO + MAXFREEZEAMMO MAXTRIPBOMBAMMO + CAMERASDESTRUCTABLE MAXFREEZEAMMO + NUMFREEZEBOUNCES MAXGROWAMMO + FREEZERHURTOWNER CAMERASDESTRUCTABLE + NUMFREEZEBOUNCES + FREEZERHURTOWNER + QSIZE + TRIPBOMBLASERMODE + */ + + j = 0; + ud.const_visibility = params[j++]; + impact_damage = params[j++]; + max_player_health = params[j++]; + max_armour_amount = params[j++]; + respawnactortime = params[j++]; + respawnitemtime = params[j++]; + dukefriction = params[j++]; + if (conversion == 14) gc = params[j++]; + rpgblastradius = params[j++]; + pipebombblastradius = params[j++]; + shrinkerblastradius = params[j++]; + tripbombblastradius = params[j++]; + morterblastradius = params[j++]; + bouncemineblastradius = params[j++]; + seenineblastradius = params[j++]; + max_ammo_amount[PISTOL_WEAPON] = params[j++]; + max_ammo_amount[SHOTGUN_WEAPON] = params[j++]; + max_ammo_amount[CHAINGUN_WEAPON] = params[j++]; + max_ammo_amount[RPG_WEAPON] = params[j++]; + max_ammo_amount[HANDBOMB_WEAPON] = params[j++]; + max_ammo_amount[SHRINKER_WEAPON] = params[j++]; + max_ammo_amount[DEVISTATOR_WEAPON] = params[j++]; + max_ammo_amount[TRIPBOMB_WEAPON] = params[j++]; + max_ammo_amount[FREEZE_WEAPON] = params[j++]; + if (conversion == 14) max_ammo_amount[GROW_WEAPON] = params[j++]; + camerashitable = params[j++]; + numfreezebounces = params[j++]; + freezerhurtowner = params[j++]; + if (conversion == 14) { + spriteqamount = params[j++]; + if(spriteqamount > 1024) spriteqamount = 1024; + else if(spriteqamount < 0) spriteqamount = 0; + + lasermode = params[j++]; + } + } + return 0; + } + return 0; +} + +void passone(void) +{ +#ifdef DEBUG + int i; +#endif + + while( parsecommand() == 0 ); + + if( (error+warning) > 63) + initprintf( "fatal error: too many warnings or errors: Aborted\n"); + +#ifdef DEBUG + initprintf("Game Definitions\n"); + for(i=0;i + +#include "duke3d.h" +#include "gamedef.h" +#include "scriplib.h" + +#include "osd.h" + +static short g_i,g_p; +static long g_x,*g_t; +static spritetype *g_sp; + +extern int32 scripthandle; + +void DoUserDef(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, short sPlayer, long lParm2) +{ + int iPlayer; + long lValue; + + lValue=GetGameVarID((int)lVar2, sActor, sPlayer); + + if(sPlayer != myconnectindex) return; + + switch(lLabelID) + { + case USERDEFS_GOD: + if(bSet) + ud.god = lValue; + else + SetGameVarID((int)lVar2, ud.god, sActor, sPlayer); + break; + + case USERDEFS_WARP_ON: + if(bSet) + ud.warp_on = lValue; + else + SetGameVarID((int)lVar2, ud.warp_on, sActor, sPlayer); + break; + + case USERDEFS_CASHMAN: + if(bSet) + ud.cashman = lValue; + else + SetGameVarID((int)lVar2, ud.cashman, sActor, sPlayer); + break; + + case USERDEFS_EOG: + if(bSet) + ud.eog = lValue; + else + SetGameVarID((int)lVar2, ud.eog, sActor, sPlayer); + break; + + case USERDEFS_SHOWALLMAP: + if(bSet) + ud.showallmap = lValue; + else + SetGameVarID((int)lVar2, ud.showallmap, sActor, sPlayer); + break; + + case USERDEFS_SHOW_HELP: + if(bSet) + ud.show_help = lValue; + else + SetGameVarID((int)lVar2, ud.show_help, sActor, sPlayer); + break; + + case USERDEFS_SCROLLMODE: + if(bSet) + ud.scrollmode = lValue; + else + SetGameVarID((int)lVar2, ud.scrollmode, sActor, sPlayer); + break; + + case USERDEFS_CLIPPING: + if(bSet) + ud.clipping = lValue; + else + SetGameVarID((int)lVar2, ud.clipping, sActor, sPlayer); + break; + + // case USERDEFS_USER_NAME: + // if(bSet) + // { + // ud.user_name[MAXPLAYERS][32] = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.user_name[MAXPLAYERS][32], sActor, sPlayer); + // } + // break; + + // case USERDEFS_RIDECULE: + // if(bSet) + // { + // ud.ridecule = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.ridecule, sActor, sPlayer); + // } + // break; + + // case USERDEFS_SAVEGAME: + // if(bSet) + // { + // ud.savegame = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.savegame, sActor, sPlayer); + // } + // break; + + // case USERDEFS_PWLOCKOUT: + // if(bSet) + // { + // ud.pwlockout = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.pwlockout, sActor, sPlayer); + // } + // break; + + // case USERDEFS_RTSNAME: + // if(bSet) + // { + // ud.rtsname = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.rtsname, sActor, sPlayer); + // } + // break; + + case USERDEFS_OVERHEAD_ON: + if(bSet) + ud.overhead_on = lValue; + else + SetGameVarID((int)lVar2, ud.overhead_on, sActor, sPlayer); + break; + + case USERDEFS_LAST_OVERHEAD: + if(bSet) + ud.last_overhead = lValue; + else + SetGameVarID((int)lVar2, ud.last_overhead, sActor, sPlayer); + break; + + case USERDEFS_SHOWWEAPONS: + if(bSet) + ud.showweapons = lValue; + else + SetGameVarID((int)lVar2, ud.showweapons, sActor, sPlayer); + break; + + + case USERDEFS_PAUSE_ON: + if(bSet) + ud.pause_on = lValue; + else + SetGameVarID((int)lVar2, ud.pause_on, sActor, sPlayer); + break; + + case USERDEFS_FROM_BONUS: + if(bSet) + ud.from_bonus = lValue; + else + SetGameVarID((int)lVar2, ud.from_bonus, sActor, sPlayer); + break; + + case USERDEFS_CAMERASPRITE: + if(bSet) + ud.camerasprite = lValue; + else + SetGameVarID((int)lVar2, ud.camerasprite, sActor, sPlayer); + break; + + case USERDEFS_LAST_CAMSPRITE: + if(bSet) + ud.last_camsprite = lValue; + else + SetGameVarID((int)lVar2, ud.last_camsprite, sActor, sPlayer); + break; + + case USERDEFS_LAST_LEVEL: + if(bSet) + ud.last_level = lValue; + else + SetGameVarID((int)lVar2, ud.last_level, sActor, sPlayer); + break; + + case USERDEFS_SECRETLEVEL: + if(bSet) + ud.secretlevel = lValue; + else + SetGameVarID((int)lVar2, ud.secretlevel, sActor, sPlayer); + break; + + case USERDEFS_CONST_VISIBILITY: + if(bSet) + ud.const_visibility = lValue; + else + SetGameVarID((int)lVar2, ud.const_visibility, sActor, sPlayer); + break; + + case USERDEFS_UW_FRAMERATE: + if(bSet) + ud.uw_framerate = lValue; + else + SetGameVarID((int)lVar2, ud.uw_framerate, sActor, sPlayer); + break; + + case USERDEFS_CAMERA_TIME: + if(bSet) + ud.camera_time = lValue; + else + SetGameVarID((int)lVar2, ud.camera_time, sActor, sPlayer); + break; + + case USERDEFS_FOLFVEL: + if(bSet) + ud.folfvel = lValue; + else + SetGameVarID((int)lVar2, ud.folfvel, sActor, sPlayer); + break; + + case USERDEFS_FOLAVEL: + if(bSet) + ud.folavel = lValue; + else + SetGameVarID((int)lVar2, ud.folavel, sActor, sPlayer); + break; + + case USERDEFS_FOLX: + if(bSet) + ud.folx = lValue; + else + SetGameVarID((int)lVar2, ud.folx, sActor, sPlayer); + break; + + case USERDEFS_FOLY: + if(bSet) + ud.foly = lValue; + else + SetGameVarID((int)lVar2, ud.foly, sActor, sPlayer); + break; + + case USERDEFS_FOLA: + if(bSet) + ud.fola = lValue; + else + SetGameVarID((int)lVar2, ud.fola, sActor, sPlayer); + break; + + case USERDEFS_RECCNT: + if(bSet) + ud.reccnt = lValue; + else + SetGameVarID((int)lVar2, ud.reccnt, sActor, sPlayer); + break; + + case USERDEFS_ENTERED_NAME: + if(bSet) + ud.entered_name = lValue; + else + SetGameVarID((int)lVar2, ud.entered_name, sActor, sPlayer); + break; + + case USERDEFS_SCREEN_TILTING: + if(bSet) + ud.screen_tilting = lValue; + else + SetGameVarID((int)lVar2, ud.screen_tilting, sActor, sPlayer); + break; + + case USERDEFS_SHADOWS: + if(bSet) + ud.shadows = lValue; + else + SetGameVarID((int)lVar2, ud.shadows, sActor, sPlayer); + break; + + case USERDEFS_FTA_ON: + if(bSet) + ud.fta_on = lValue; + else + SetGameVarID((int)lVar2, ud.fta_on, sActor, sPlayer); + break; + + case USERDEFS_EXECUTIONS: + if(bSet) + ud.executions = lValue; + else + SetGameVarID((int)lVar2, ud.executions, sActor, sPlayer); + break; + + case USERDEFS_AUTO_RUN: + if(bSet) + ud.auto_run = lValue; + else + SetGameVarID((int)lVar2, ud.auto_run, sActor, sPlayer); + break; + + case USERDEFS_COORDS: + if(bSet) + ud.coords = lValue; + else + SetGameVarID((int)lVar2, ud.coords, sActor, sPlayer); + break; + + case USERDEFS_TICKRATE: + if(bSet) + ud.tickrate = lValue; + else + SetGameVarID((int)lVar2, ud.tickrate, sActor, sPlayer); + break; + + case USERDEFS_M_COOP: + if(bSet) + ud.m_coop = lValue; + else + SetGameVarID((int)lVar2, ud.m_coop, sActor, sPlayer); + break; + + case USERDEFS_COOP: + if(bSet) + ud.coop = lValue; + else + SetGameVarID((int)lVar2, ud.coop, sActor, sPlayer); + break; + + case USERDEFS_SCREEN_SIZE: + if(bSet) + ud.screen_size = lValue; + else + SetGameVarID((int)lVar2, ud.screen_size, sActor, sPlayer); + break; + + case USERDEFS_LOCKOUT: + if(bSet) + ud.lockout = lValue; + else + SetGameVarID((int)lVar2, ud.lockout, sActor, sPlayer); + break; + + case USERDEFS_CROSSHAIR: + if(bSet) + ud.crosshair = lValue; + else + SetGameVarID((int)lVar2, ud.crosshair, sActor, sPlayer); + break; + + // case USERDEFS_WCHOICE: + // if(bSet) + // { + // ud.wchoice = lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ud.wchoice, sActor, sPlayer); + // } + // break; + + case USERDEFS_PLAYERAI: + if(bSet) + ud.playerai = lValue; + else + SetGameVarID((int)lVar2, ud.playerai, sActor, sPlayer); + break; + + case USERDEFS_RESPAWN_MONSTERS: + if(bSet) + ud.respawn_monsters = lValue; + else + SetGameVarID((int)lVar2, ud.respawn_monsters, sActor, sPlayer); + break; + + case USERDEFS_RESPAWN_ITEMS: + if(bSet) + ud.respawn_items = lValue; + else + SetGameVarID((int)lVar2, ud.respawn_items, sActor, sPlayer); + break; + + case USERDEFS_RESPAWN_INVENTORY: + if(bSet) + ud.respawn_inventory = lValue; + else + SetGameVarID((int)lVar2, ud.respawn_inventory, sActor, sPlayer); + break; + + case USERDEFS_RECSTAT: + if(bSet) + ud.recstat = lValue; + else + SetGameVarID((int)lVar2, ud.recstat, sActor, sPlayer); + break; + + case USERDEFS_MONSTERS_OFF: + if(bSet) + ud.monsters_off = lValue; + else + SetGameVarID((int)lVar2, ud.monsters_off, sActor, sPlayer); + break; + + case USERDEFS_BRIGHTNESS: + if(bSet) + ud.brightness = lValue; + else + SetGameVarID((int)lVar2, ud.brightness, sActor, sPlayer); + break; + + case USERDEFS_M_RESPAWN_ITEMS: + if(bSet) + ud.m_respawn_items = lValue; + else + SetGameVarID((int)lVar2, ud.m_respawn_items, sActor, sPlayer); + break; + + case USERDEFS_M_RESPAWN_MONSTERS: + if(bSet) + ud.m_respawn_monsters = lValue; + else + SetGameVarID((int)lVar2, ud.m_respawn_monsters, sActor, sPlayer); + break; + + case USERDEFS_M_RESPAWN_INVENTORY: + if(bSet) + ud.m_respawn_inventory = lValue; + else + SetGameVarID((int)lVar2, ud.m_respawn_inventory, sActor, sPlayer); + break; + + case USERDEFS_M_RECSTAT: + if(bSet) + ud.m_recstat = lValue; + else + SetGameVarID((int)lVar2, ud.m_recstat, sActor, sPlayer); + break; + + case USERDEFS_M_MONSTERS_OFF: + if(bSet) + ud.m_monsters_off = lValue; + else + SetGameVarID((int)lVar2, ud.m_monsters_off, sActor, sPlayer); + break; + + case USERDEFS_DETAIL: + if(bSet) + ud.detail = lValue; + else + SetGameVarID((int)lVar2, ud.detail, sActor, sPlayer); + break; + + case USERDEFS_M_FFIRE: + if(bSet) + ud.m_ffire = lValue; + else + SetGameVarID((int)lVar2, ud.m_ffire, sActor, sPlayer); + break; + + case USERDEFS_FFIRE: + if(bSet) + ud.ffire = lValue; + else + SetGameVarID((int)lVar2, ud.ffire, sActor, sPlayer); + break; + + case USERDEFS_M_PLAYER_SKILL: + if(bSet) + ud.m_player_skill = lValue; + else + SetGameVarID((int)lVar2, ud.m_player_skill, sActor, sPlayer); + break; + + case USERDEFS_M_LEVEL_NUMBER: + if(bSet) + ud.m_level_number = lValue; + else + SetGameVarID((int)lVar2, ud.m_level_number, sActor, sPlayer); + break; + + case USERDEFS_M_VOLUME_NUMBER: + if(bSet) + ud.m_volume_number = lValue; + else + SetGameVarID((int)lVar2, ud.m_volume_number, sActor, sPlayer); + break; + + case USERDEFS_MULTIMODE: + if(bSet) + ud.multimode = lValue; + else + SetGameVarID((int)lVar2, ud.multimode, sActor, sPlayer); + break; + + case USERDEFS_PLAYER_SKILL: + if(bSet) + ud.player_skill = lValue; + else + SetGameVarID((int)lVar2, ud.player_skill, sActor, sPlayer); + break; + + case USERDEFS_LEVEL_NUMBER: + if(bSet) + ud.level_number = lValue; + else + SetGameVarID((int)lVar2, ud.level_number, sActor, sPlayer); + break; + + case USERDEFS_VOLUME_NUMBER: + if(bSet) + ud.volume_number = lValue; + else + SetGameVarID((int)lVar2, ud.volume_number, sActor, sPlayer); + break; + + case USERDEFS_M_MARKER: + if(bSet) + ud.m_marker = lValue; + else + SetGameVarID((int)lVar2, ud.m_marker, sActor, sPlayer); + break; + + case USERDEFS_MARKER: + if(bSet) + ud.marker = lValue; + else + SetGameVarID((int)lVar2, ud.marker, sActor, sPlayer); + break; + + case USERDEFS_MOUSEFLIP: + if(bSet) + ud.mouseflip = lValue; + else + SetGameVarID((int)lVar2, ud.mouseflip, sActor, sPlayer); + break; + + case USERDEFS_STATUSBARSCALE: + if(bSet) + ud.statusbarscale = lValue; + else + SetGameVarID((int)lVar2, ud.statusbarscale, sActor, sPlayer); + break; + + case USERDEFS_DRAWWEAPON: + if(bSet) + ud.drawweapon = lValue; + else + SetGameVarID((int)lVar2, ud.drawweapon, sActor, sPlayer); + break; + + case USERDEFS_MOUSEAIMING: + if(bSet) + ud.mouseaiming = lValue; + else + SetGameVarID((int)lVar2, ud.mouseaiming, sActor, sPlayer); + break; + + case USERDEFS_WEAPONSWITCH: + if(bSet) + ud.weaponswitch = lValue; + else + SetGameVarID((int)lVar2, ud.weaponswitch, sActor, sPlayer); + break; + + default: + break; + } + return; +} + +void DoThisProjectile(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, short sPlayer) +{ + long lValue,proj; + + if(lVar1 == g_iThisActorID ) + { + // if they've asked for 'this', then use 'this'... + proj=sActor; + } + else + { + if(sActor < 0 || sActor >= MAXSPRITES) + return; + proj=GetGameVarID((int)lVar1, sActor, sPlayer); + } + + lValue=GetGameVarID((int)lVar2, sActor, sPlayer); + + switch(lLabelID) + { + case PROJ_WORKSLIKE: + if(bSet) + thisprojectile[proj].workslike=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].workslike, sActor, sPlayer); + break; + + case PROJ_SPAWNS: + if(bSet) + thisprojectile[proj].spawns=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].spawns, sActor, sPlayer); + break; + + case PROJ_SXREPEAT: + if(bSet) + thisprojectile[proj].sxrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].sxrepeat, sActor, sPlayer); + break; + + case PROJ_SYREPEAT: + if(bSet) + thisprojectile[proj].syrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].syrepeat, sActor, sPlayer); + break; + + case PROJ_SOUND: + if(bSet) + thisprojectile[proj].sound=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].sound, sActor, sPlayer); + break; + + case PROJ_ISOUND: + if(bSet) + thisprojectile[proj].isound=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].isound, sActor, sPlayer); + break; + + case PROJ_VEL: + if(bSet) + thisprojectile[proj].vel=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].vel, sActor, sPlayer); + break; + + case PROJ_EXTRA: + if(bSet) + thisprojectile[proj].extra=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].extra, sActor, sPlayer); + break; + + case PROJ_DECAL: + if(bSet) + thisprojectile[proj].decal=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].decal, sActor, sPlayer); + break; + + case PROJ_TRAIL: + if(bSet) + thisprojectile[proj].trail=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].trail, sActor, sPlayer); + break; + + case PROJ_TXREPEAT: + if(bSet) + thisprojectile[proj].txrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].txrepeat, sActor, sPlayer); + break; + + case PROJ_TYREPEAT: + if(bSet) + thisprojectile[proj].tyrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].tyrepeat, sActor, sPlayer); + break; + + case PROJ_TOFFSET: + if(bSet) + thisprojectile[proj].toffset=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].toffset, sActor, sPlayer); + break; + + case PROJ_TNUM: + if(bSet) + thisprojectile[proj].tnum=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].tnum, sActor, sPlayer); + break; + + case PROJ_DROP: + if(bSet) + thisprojectile[proj].drop=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].drop, sActor, sPlayer); + break; + + case PROJ_CSTAT: + if(bSet) + thisprojectile[proj].cstat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].cstat, sActor, sPlayer); + break; + + case PROJ_CLIPDIST: + if(bSet) + thisprojectile[proj].clipdist=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].clipdist, sActor, sPlayer); + break; + + case PROJ_SHADE: + if(bSet) + thisprojectile[proj].shade=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].shade, sActor, sPlayer); + break; + + case PROJ_XREPEAT: + if(bSet) + thisprojectile[proj].xrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].xrepeat, sActor, sPlayer); + break; + + case PROJ_YREPEAT: + if(bSet) + thisprojectile[proj].yrepeat=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].yrepeat, sActor, sPlayer); + break; + + case PROJ_PAL: + if(bSet) + thisprojectile[proj].pal=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].pal, sActor, sPlayer); + break; + + case PROJ_EXTRA_RAND: + if(bSet) + thisprojectile[proj].extra_rand=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].extra_rand, sActor, sPlayer); + break; + + case PROJ_HITRADIUS: + if(bSet) + thisprojectile[proj].hitradius=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].hitradius, sActor, sPlayer); + break; + + case PROJ_VEL_MULT: + if(bSet) + thisprojectile[proj].velmult=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].velmult, sActor, sPlayer); + break; + + case PROJ_OFFSET: + if(bSet) + thisprojectile[proj].offset=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].offset, sActor, sPlayer); + break; + + case PROJ_BOUNCES: + if(bSet) + thisprojectile[proj].bounces=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].bounces, sActor, sPlayer); + break; + + case PROJ_BSOUND: + if(bSet) + thisprojectile[proj].bsound=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].bsound, sActor, sPlayer); + break; + + case PROJ_RANGE: + if(bSet) + thisprojectile[proj].range=lValue; + else + SetGameVarID((int)lVar2, thisprojectile[proj].range, sActor, sPlayer); + break; + + default: + break; + } + return; +} + +void DoPlayer(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, short sPlayer, long lParm2) +{ + int iPlayer; + long lValue; + long lTemp; + + lValue=GetGameVarID((int)lVar2, sActor, sPlayer); + + if(lVar1 == g_iThisActorID ) + { + // if they've asked for 'this', then use 'this player'... + iPlayer=g_p; + } + else + { + if(sPlayer<0 || sPlayer >= MAXPLAYERS) + return; + iPlayer=GetGameVarID((int)lVar1, sActor, sPlayer); + } + + if(iPlayer<0 || iPlayer >= MAXPLAYERS) + return; + + switch(lLabelID) + { + case PLAYER_ZOOM: + if(bSet) + ps[iPlayer].zoom=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].zoom, sActor, sPlayer); + break; + + case PLAYER_EXITX: + if(bSet) + ps[iPlayer].exitx=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].exitx, sActor, sPlayer); + break; + + case PLAYER_EXITY: + if(bSet) + ps[iPlayer].exity=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].exity, sActor, sPlayer); + break; + + case PLAYER_LOOGIEX: + lTemp=lParm2; + if(bSet) + ps[iPlayer].loogiex[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].loogiex[lTemp], sActor, sPlayer); + break; + + case PLAYER_LOOGIEY: + lTemp=lParm2; + if(bSet) + ps[iPlayer].loogiey[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].loogiey[lTemp], sActor, sPlayer); + break; + + case PLAYER_NUMLOOGS: + if(bSet) + ps[iPlayer].numloogs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].numloogs, sActor, sPlayer); + break; + + case PLAYER_LOOGCNT: + if(bSet) + ps[iPlayer].loogcnt=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].loogcnt, sActor, sPlayer); + break; + + case PLAYER_POSX: + if(bSet) + ps[iPlayer].posx=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posx, sActor, sPlayer); + break; + + case PLAYER_POSY: + if(bSet) + ps[iPlayer].posy=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posy, sActor, sPlayer); + break; + + case PLAYER_POSZ: + if(bSet) + ps[iPlayer].posz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posz, sActor, sPlayer); + break; + + case PLAYER_HORIZ: + if(bSet) + ps[iPlayer].horiz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].horiz, sActor, sPlayer); + break; + + case PLAYER_OHORIZ: + if(bSet) + ps[iPlayer].ohoriz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ohoriz, sActor, sPlayer); + break; + + case PLAYER_OHORIZOFF: + if(bSet) + ps[iPlayer].ohorizoff=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ohorizoff, sActor, sPlayer); + break; + + case PLAYER_INVDISPTIME: + if(bSet) + ps[iPlayer].invdisptime=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].invdisptime, sActor, sPlayer); + break; + + case PLAYER_BOBPOSX: + if(bSet) + ps[iPlayer].bobposx=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].bobposx, sActor, sPlayer); + break; + + case PLAYER_BOBPOSY: + if(bSet) + ps[iPlayer].bobposy=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].bobposy, sActor, sPlayer); + break; + + case PLAYER_OPOSX: + if(bSet) + ps[iPlayer].oposx=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].oposx, sActor, sPlayer); + break; + + case PLAYER_OPOSY: + if(bSet) + ps[iPlayer].oposy=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].oposy, sActor, sPlayer); + break; + + case PLAYER_OPOSZ: + if(bSet) + ps[iPlayer].oposz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].oposz, sActor, sPlayer); + break; + + case PLAYER_PYOFF: + if(bSet) + ps[iPlayer].pyoff=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].pyoff, sActor, sPlayer); + break; + + case PLAYER_OPYOFF: + if(bSet) + ps[iPlayer].opyoff=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].opyoff, sActor, sPlayer); + break; + + case PLAYER_POSXV: + if(bSet) + ps[iPlayer].posxv=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posxv, sActor, sPlayer); + break; + + case PLAYER_POSYV: + if(bSet) + ps[iPlayer].posyv=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].posyv, sActor, sPlayer); + break; + + case PLAYER_POSZV: + if(bSet) + ps[iPlayer].poszv=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].poszv, sActor, sPlayer); + break; + + case PLAYER_LAST_PISSED_TIME: + if(bSet) + ps[iPlayer].last_pissed_time=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].last_pissed_time, sActor, sPlayer); + break; + + case PLAYER_TRUEFZ: + if(bSet) + ps[iPlayer].truefz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].truefz, sActor, sPlayer); + break; + + case PLAYER_TRUECZ: + if(bSet) + ps[iPlayer].truecz=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].truecz, sActor, sPlayer); + break; + + case PLAYER_PLAYER_PAR: + if(bSet) + ps[iPlayer].player_par=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].player_par, sActor, sPlayer); + break; + + case PLAYER_VISIBILITY: + if(bSet) + ps[iPlayer].visibility=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].visibility, sActor, sPlayer); + break; + + case PLAYER_BOBCOUNTER: + if(bSet) + ps[iPlayer].bobcounter=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].bobcounter, sActor, sPlayer); + break; + + case PLAYER_WEAPON_SWAY: + if(bSet) + ps[iPlayer].weapon_sway=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weapon_sway, sActor, sPlayer); + break; + + case PLAYER_PALS_TIME: + if(bSet) + ps[iPlayer].pals_time=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].pals_time, sActor, sPlayer); + break; + + case PLAYER_RANDOMFLAMEX: + if(bSet) + ps[iPlayer].randomflamex=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].randomflamex, sActor, sPlayer); + break; + + case PLAYER_CRACK_TIME: + if(bSet) + ps[iPlayer].crack_time=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].crack_time, sActor, sPlayer); + break; + + case PLAYER_AIM_MODE: + if(bSet) + ps[iPlayer].aim_mode=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].aim_mode, sActor, sPlayer); + break; + + case PLAYER_ANG: + if(bSet) + ps[iPlayer].ang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ang, sActor, sPlayer); + break; + + case PLAYER_OANG: + if(bSet) + ps[iPlayer].oang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].oang, sActor, sPlayer); + break; + + case PLAYER_ANGVEL: + if(bSet) + ps[iPlayer].angvel=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].angvel, sActor, sPlayer); + break; + + case PLAYER_CURSECTNUM: + if(bSet) + ps[iPlayer].cursectnum=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].cursectnum, sActor, sPlayer); + break; + + case PLAYER_LOOK_ANG: + if(bSet) + ps[iPlayer].look_ang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].look_ang, sActor, sPlayer); + break; + + case PLAYER_LAST_EXTRA: + if(bSet) + ps[iPlayer].last_extra=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].last_extra, sActor, sPlayer); + break; + + case PLAYER_SUBWEAPON: + if(bSet) + ps[iPlayer].subweapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].subweapon, sActor, sPlayer); + break; + + case PLAYER_AMMO_AMOUNT: + lTemp=lParm2; + if(bSet) + ps[iPlayer].ammo_amount[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ammo_amount[lTemp], sActor, sPlayer); + break; + + case PLAYER_WACKEDBYACTOR: + if(bSet) + ps[iPlayer].wackedbyactor=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].wackedbyactor, sActor, sPlayer); + break; + + case PLAYER_FRAG: + if(bSet) + ps[iPlayer].frag=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].frag, sActor, sPlayer); + break; + + case PLAYER_FRAGGEDSELF: + if(bSet) + ps[iPlayer].fraggedself=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].fraggedself, sActor, sPlayer); + break; + + case PLAYER_CURR_WEAPON: + if(bSet) + ps[iPlayer].curr_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].curr_weapon, sActor, sPlayer); + break; + + case PLAYER_LAST_WEAPON: + if(bSet) + ps[iPlayer].last_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].last_weapon, sActor, sPlayer); + break; + + case PLAYER_TIPINCS: + if(bSet) + ps[iPlayer].tipincs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].tipincs, sActor, sPlayer); + break; + + case PLAYER_HORIZOFF: + if(bSet) + ps[iPlayer].horizoff=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].horizoff, sActor, sPlayer); + break; + + case PLAYER_WANTWEAPONFIRE: + if(bSet) + ps[iPlayer].wantweaponfire=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].wantweaponfire, sActor, sPlayer); + break; + + case PLAYER_HOLODUKE_AMOUNT: + if(bSet) + ps[iPlayer].holoduke_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].holoduke_amount, sActor, sPlayer); + break; + + case PLAYER_NEWOWNER: + if(bSet) + ps[iPlayer].newowner=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].newowner, sActor, sPlayer); + break; + + case PLAYER_HURT_DELAY: + if(bSet) + ps[iPlayer].hurt_delay=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].hurt_delay, sActor, sPlayer); + break; + + case PLAYER_HBOMB_HOLD_DELAY: + if(bSet) + ps[iPlayer].hbomb_hold_delay=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].hbomb_hold_delay, sActor, sPlayer); + break; + + case PLAYER_JUMPING_COUNTER: + if(bSet) + ps[iPlayer].jumping_counter=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].jumping_counter, sActor, sPlayer); + break; + + case PLAYER_AIRLEFT: + if(bSet) + ps[iPlayer].airleft=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].airleft, sActor, sPlayer); + break; + + case PLAYER_KNEE_INCS: + if(bSet) + ps[iPlayer].knee_incs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].knee_incs, sActor, sPlayer); + break; + + case PLAYER_ACCESS_INCS: + if(bSet) + ps[iPlayer].access_incs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].access_incs, sActor, sPlayer); + break; + + case PLAYER_FTA: + if(bSet) + ps[iPlayer].fta=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].fta, sActor, sPlayer); + break; + + case PLAYER_FTQ: + if(bSet) + ps[iPlayer].ftq=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].ftq, sActor, sPlayer); + break; + + case PLAYER_ACCESS_WALLNUM: + if(bSet) + ps[iPlayer].access_wallnum=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].access_wallnum, sActor, sPlayer); + break; + + case PLAYER_ACCESS_SPRITENUM: + if(bSet) + ps[iPlayer].access_spritenum=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].access_spritenum, sActor, sPlayer); + break; + + case PLAYER_KICKBACK_PIC: + if(bSet) + ps[iPlayer].kickback_pic=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].kickback_pic, sActor, sPlayer); + break; + + case PLAYER_GOT_ACCESS: + if(bSet) + ps[iPlayer].got_access=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].got_access, sActor, sPlayer); + break; + + case PLAYER_WEAPON_ANG: + if(bSet) + ps[iPlayer].weapon_ang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weapon_ang, sActor, sPlayer); + break; + + case PLAYER_FIRSTAID_AMOUNT: + if(bSet) + ps[iPlayer].firstaid_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].firstaid_amount, sActor, sPlayer); + break; + + case PLAYER_SOMETHINGONPLAYER: + if(bSet) + ps[iPlayer].somethingonplayer=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].somethingonplayer, sActor, sPlayer); + break; + + case PLAYER_ON_CRANE: + if(bSet) + ps[iPlayer].on_crane=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].on_crane, sActor, sPlayer); + break; + + case PLAYER_I: + if(bSet) + ps[iPlayer].i=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].i, sActor, sPlayer); + break; + + case PLAYER_ONE_PARALLAX_SECTNUM: + if(bSet) + ps[iPlayer].one_parallax_sectnum=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].one_parallax_sectnum, sActor, sPlayer); + break; + + case PLAYER_OVER_SHOULDER_ON: + if(bSet) + ps[iPlayer].over_shoulder_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].over_shoulder_on, sActor, sPlayer); + break; + + case PLAYER_RANDOM_CLUB_FRAME: + if(bSet) + ps[iPlayer].random_club_frame=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].random_club_frame, sActor, sPlayer); + break; + + case PLAYER_FIST_INCS: + if(bSet) + ps[iPlayer].fist_incs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].fist_incs, sActor, sPlayer); + break; + + case PLAYER_ONE_EIGHTY_COUNT: + if(bSet) + ps[iPlayer].one_eighty_count=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].one_eighty_count, sActor, sPlayer); + break; + + case PLAYER_CHEAT_PHASE: + if(bSet) + ps[iPlayer].cheat_phase=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].cheat_phase, sActor, sPlayer); + break; + + case PLAYER_DUMMYPLAYERSPRITE: + if(bSet) + ps[iPlayer].dummyplayersprite=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].dummyplayersprite, sActor, sPlayer); + break; + + case PLAYER_EXTRA_EXTRA8: + if(bSet) + ps[iPlayer].extra_extra8=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].extra_extra8, sActor, sPlayer); + break; + + case PLAYER_QUICK_KICK: + if(bSet) + ps[iPlayer].quick_kick=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].quick_kick, sActor, sPlayer); + break; + + case PLAYER_HEAT_AMOUNT: + if(bSet) + ps[iPlayer].heat_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].heat_amount, sActor, sPlayer); + break; + + case PLAYER_ACTORSQU: + if(bSet) + ps[iPlayer].actorsqu=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].actorsqu, sActor, sPlayer); + break; + + case PLAYER_TIMEBEFOREEXIT: + if(bSet) + ps[iPlayer].timebeforeexit=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].timebeforeexit, sActor, sPlayer); + break; + + case PLAYER_CUSTOMEXITSOUND: + if(bSet) + ps[iPlayer].customexitsound=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].customexitsound, sActor, sPlayer); + break; + + case PLAYER_WEAPRECS: + if(bSet) + ps[iPlayer].weaprecs[16]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weaprecs[16], sActor, sPlayer); + break; + + case PLAYER_WEAPRECCNT: + if(bSet) + ps[iPlayer].weapreccnt=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weapreccnt, sActor, sPlayer); + break; + + case PLAYER_INTERFACE_TOGGLE_FLAG: + if(bSet) + ps[iPlayer].interface_toggle_flag=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].interface_toggle_flag, sActor, sPlayer); + break; + + case PLAYER_ROTSCRNANG: + if(bSet) + ps[iPlayer].rotscrnang=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].rotscrnang, sActor, sPlayer); + break; + + case PLAYER_DEAD_FLAG: + if(bSet) + ps[iPlayer].dead_flag=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].dead_flag, sActor, sPlayer); + break; + + case PLAYER_SHOW_EMPTY_WEAPON: + if(bSet) + ps[iPlayer].show_empty_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].show_empty_weapon, sActor, sPlayer); + break; + + case PLAYER_SCUBA_AMOUNT: + if(bSet) + ps[iPlayer].scuba_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].scuba_amount, sActor, sPlayer); + break; + + case PLAYER_JETPACK_AMOUNT: + if(bSet) + ps[iPlayer].jetpack_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].jetpack_amount, sActor, sPlayer); + break; + + case PLAYER_STEROIDS_AMOUNT: + if(bSet) + ps[iPlayer].steroids_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].steroids_amount, sActor, sPlayer); + break; + + case PLAYER_SHIELD_AMOUNT: + if(bSet) + ps[iPlayer].shield_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].shield_amount, sActor, sPlayer); + break; + + case PLAYER_HOLODUKE_ON: + if(bSet) + ps[iPlayer].holoduke_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].holoduke_on, sActor, sPlayer); + break; + + case PLAYER_PYCOUNT: + if(bSet) + ps[iPlayer].pycount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].pycount, sActor, sPlayer); + break; + + case PLAYER_WEAPON_POS: + if(bSet) + ps[iPlayer].weapon_pos=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weapon_pos, sActor, sPlayer); + break; + + case PLAYER_FRAG_PS: + if(bSet) + ps[iPlayer].frag_ps=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].frag_ps, sActor, sPlayer); + break; + + case PLAYER_TRANSPORTER_HOLD: + if(bSet) + ps[iPlayer].transporter_hold=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].transporter_hold, sActor, sPlayer); + break; + + case PLAYER_LAST_FULL_WEAPON: + if(bSet) + ps[iPlayer].last_full_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].last_full_weapon, sActor, sPlayer); + break; + + case PLAYER_FOOTPRINTSHADE: + if(bSet) + ps[iPlayer].footprintshade=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].footprintshade, sActor, sPlayer); + break; + + case PLAYER_BOOT_AMOUNT: + if(bSet) + ps[iPlayer].boot_amount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].boot_amount, sActor, sPlayer); + break; + + case PLAYER_SCREAM_VOICE: + if(bSet) + ps[iPlayer].scream_voice=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].scream_voice, sActor, sPlayer); + break; + + case PLAYER_GM: + if(bSet) + ps[iPlayer].gm=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].gm, sActor, sPlayer); + break; + + case PLAYER_ON_WARPING_SECTOR: + if(bSet) + ps[iPlayer].on_warping_sector=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].on_warping_sector, sActor, sPlayer); + break; + + case PLAYER_FOOTPRINTCOUNT: + if(bSet) + ps[iPlayer].footprintcount=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].footprintcount, sActor, sPlayer); + break; + + case PLAYER_HBOMB_ON: + if(bSet) + ps[iPlayer].hbomb_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].hbomb_on, sActor, sPlayer); + break; + + case PLAYER_JUMPING_TOGGLE: + if(bSet) + ps[iPlayer].jumping_toggle=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].jumping_toggle, sActor, sPlayer); + break; + + case PLAYER_RAPID_FIRE_HOLD: + if(bSet) + ps[iPlayer].rapid_fire_hold=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].rapid_fire_hold, sActor, sPlayer); + break; + + case PLAYER_ON_GROUND: + if(bSet) + ps[iPlayer].on_ground=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].on_ground, sActor, sPlayer); + break; + + case PLAYER_NAME: + if(bSet) + ps[iPlayer].name[32]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].name[32], sActor, sPlayer); + break; + + case PLAYER_INVEN_ICON: + if(bSet) + ps[iPlayer].inven_icon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].inven_icon, sActor, sPlayer); + break; + + case PLAYER_BUTTONPALETTE: + if(bSet) + ps[iPlayer].buttonpalette=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].buttonpalette, sActor, sPlayer); + break; + + case PLAYER_JETPACK_ON: + if(bSet) + ps[iPlayer].jetpack_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].jetpack_on, sActor, sPlayer); + break; + + case PLAYER_SPRITEBRIDGE: + if(bSet) + ps[iPlayer].spritebridge=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].spritebridge, sActor, sPlayer); + break; + + case PLAYER_LASTRANDOMSPOT: + if(bSet) + ps[iPlayer].lastrandomspot=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].lastrandomspot, sActor, sPlayer); + break; + + case PLAYER_SCUBA_ON: + if(bSet) + ps[iPlayer].scuba_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].scuba_on, sActor, sPlayer); + break; + + case PLAYER_FOOTPRINTPAL: + if(bSet) + ps[iPlayer].footprintpal=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].footprintpal, sActor, sPlayer); + break; + + case PLAYER_HEAT_ON: + if(bSet) + ps[iPlayer].heat_on=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].heat_on, sActor, sPlayer); + break; + + case PLAYER_HOLSTER_WEAPON: + if(bSet) + ps[iPlayer].holster_weapon=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].holster_weapon, sActor, sPlayer); + break; + + case PLAYER_FALLING_COUNTER: + if(bSet) + ps[iPlayer].falling_counter=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].falling_counter, sActor, sPlayer); + break; + + case PLAYER_GOTWEAPON: + lTemp=lParm2; + if(bSet) + ps[iPlayer].gotweapon[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].gotweapon[lTemp], sActor, sPlayer); + break; + + case PLAYER_REFRESH_INVENTORY: + if(bSet) + ps[iPlayer].refresh_inventory=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].refresh_inventory, sActor, sPlayer); + break; + + // case PLAYER_PALETTE: + // if(bSet) + // { + // ps[iPlayer].palette=lValue; + // } + // else + // { + // SetGameVarID((int)lVar2, ps[iPlayer].palette, sActor, sPlayer); + // } + // break; + + case PLAYER_TOGGLE_KEY_FLAG: + if(bSet) + ps[iPlayer].toggle_key_flag=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].toggle_key_flag, sActor, sPlayer); + break; + + case PLAYER_KNUCKLE_INCS: + if(bSet) + ps[iPlayer].knuckle_incs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].knuckle_incs, sActor, sPlayer); + break; + + case PLAYER_WALKING_SND_TOGGLE: + if(bSet) + ps[iPlayer].walking_snd_toggle=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].walking_snd_toggle, sActor, sPlayer); + break; + + case PLAYER_PALOOKUP: + if(bSet) + ps[iPlayer].palookup=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].palookup, sActor, sPlayer); + break; + + case PLAYER_HARD_LANDING: + if(bSet) + ps[iPlayer].hard_landing=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].hard_landing, sActor, sPlayer); + break; + + case PLAYER_MAX_SECRET_ROOMS: + if(bSet) + ps[iPlayer].max_secret_rooms=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].max_secret_rooms, sActor, sPlayer); + break; + + case PLAYER_SECRET_ROOMS: + if(bSet) + ps[iPlayer].secret_rooms=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].secret_rooms, sActor, sPlayer); + break; + + case PLAYER_PALS: + lTemp=lParm2; + if(bSet) + ps[iPlayer].pals[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].pals[lTemp], sActor, sPlayer); + break; + + case PLAYER_MAX_ACTORS_KILLED: + if(bSet) + ps[iPlayer].max_actors_killed=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].max_actors_killed, sActor, sPlayer); + break; + + case PLAYER_ACTORS_KILLED: + if(bSet) + ps[iPlayer].actors_killed=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].actors_killed, sActor, sPlayer); + break; + + case PLAYER_RETURN_TO_CENTER: + if(bSet) + ps[iPlayer].return_to_center=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].return_to_center, sActor, sPlayer); + break; + + case PLAYER_RUNSPEED: + if(bSet) + ps[iPlayer].runspeed=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].runspeed, sActor, sPlayer); + break; + + case PLAYER_SBS: + if(bSet) + ps[iPlayer].sbs=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].sbs, sActor, sPlayer); + break; + + case PLAYER_RELOADING: + if(bSet) + ps[iPlayer].reloading=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].reloading, sActor, sPlayer); + break; + + case PLAYER_AUTO_AIM: + if(bSet) + ps[iPlayer].auto_aim=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].auto_aim, sActor, sPlayer); + break; + + case PLAYER_MOVEMENT_LOCK: + lTemp=lParm2; + if(bSet) + ps[iPlayer].movement_lock[lTemp]=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].movement_lock[lTemp], sActor, sPlayer); + break; + + case PLAYER_SOUND_PITCH: + if(bSet) + ps[iPlayer].sound_pitch=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].sound_pitch, sActor, sPlayer); + break; + + case PLAYER_WEAPONSWITCH: + if(bSet) + ps[iPlayer].weaponswitch=lValue; + else + SetGameVarID((int)lVar2, ps[iPlayer].weaponswitch, sActor, sPlayer); + break; + + default: + break; + } + return; +} + +void DoInput(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, short sPlayer) +{ + int iPlayer; + long lValue; + long lTemp; + + lValue=GetGameVarID((int)lVar2, sActor, sPlayer); + + if(lVar1 == g_iThisActorID ) + { + // if they've asked for 'this', then use 'this player'... + iPlayer=g_p; + } + else + { + if(sPlayer<0 || sPlayer >= MAXPLAYERS) + return; + iPlayer=GetGameVarID((int)lVar1, sActor, sPlayer); + } + + if(iPlayer<0 || iPlayer >= MAXPLAYERS) + return; + + switch(lLabelID) + { + case INPUT_AVEL: + if(bSet) + sync[iPlayer].avel=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].avel, sActor, sPlayer); + break; + case INPUT_HORZ: + if(bSet) + sync[iPlayer].horz=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].horz, sActor, sPlayer); + break; + case INPUT_FVEL: + if(bSet) + sync[iPlayer].fvel=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].fvel, sActor, sPlayer); + break; + case INPUT_SVEL: + if(bSet) + sync[iPlayer].svel=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].svel, sActor, sPlayer); + break; + case INPUT_BITS: + if(bSet) + sync[iPlayer].bits=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].bits, sActor, sPlayer); + break; + case INPUT_BITS2: + if(bSet) + sync[iPlayer].bits2=lValue; + else + SetGameVarID((int)lVar2, sync[iPlayer].bits2, sActor, sPlayer); + break; + default: + break; + } + return; +} + +void DoWall(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, short sPlayer) +{ + int iWall; + long lValue; + + lValue=GetGameVarID((int)lVar2, sActor, sPlayer); + + iWall=GetGameVarID((int)lVar1, sActor, sPlayer); + + if(iWall<0 || iWall >= MAXWALLS) + return; + + switch(lLabelID) + { + case WALL_X: + if(bSet) + wall[iWall].x=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].x, sActor, sPlayer); + break; + case WALL_Y: + if(bSet) + wall[iWall].y=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].y, sActor, sPlayer); + break; + case WALL_POINT2: + if(bSet) + wall[iWall].point2=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].point2, sActor, sPlayer); + break; + case WALL_NEXTWALL: + if(bSet) + wall[iWall].nextwall=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].nextwall, sActor, sPlayer); + break; + case WALL_NEXTSECTOR: + if(bSet) + wall[iWall].nextsector=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].nextsector, sActor, sPlayer); + break; + case WALL_CSTAT: + if(bSet) + wall[iWall].cstat=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].cstat, sActor, sPlayer); + break; + case WALL_PICNUM: + if(bSet) + wall[iWall].picnum=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].picnum, sActor, sPlayer); + break; + case WALL_OVERPICNUM: + if(bSet) + wall[iWall].overpicnum=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].overpicnum, sActor, sPlayer); + break; + case WALL_SHADE: + if(bSet) + wall[iWall].shade=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].shade, sActor, sPlayer); + break; + case WALL_PAL: + if(bSet) + wall[iWall].pal=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].pal, sActor, sPlayer); + break; + case WALL_XREPEAT: + if(bSet) + wall[iWall].xrepeat=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].xrepeat, sActor, sPlayer); + break; + case WALL_YREPEAT: + if(bSet) + wall[iWall].yrepeat=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].yrepeat, sActor, sPlayer); + break; + case WALL_XPANNING: + if(bSet) + wall[iWall].xpanning=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].xpanning, sActor, sPlayer); + break; + case WALL_YPANNING: + if(bSet) + wall[iWall].ypanning=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].ypanning, sActor, sPlayer); + break; + case WALL_LOTAG: + if(bSet) + wall[iWall].lotag=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].lotag, sActor, sPlayer); + break; + case WALL_HITAG: + if(bSet) + wall[iWall].hitag=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].hitag, sActor, sPlayer); + break; + case WALL_EXTRA: + if(bSet) + wall[iWall].extra=lValue; + else + SetGameVarID((int)lVar2, wall[iWall].extra, sActor, sPlayer); + break; + default: + break; + } + return; +} + +void DoSector(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, short sPlayer) +{ + int iSector; + long lValue; + + + if(lVar1 == g_iThisActorID ) + { + // if they've asked for 'this', then use 'this'... + iSector=sprite[g_i].sectnum; + } + else + { + iSector=GetGameVarID((int)lVar1, sActor, sPlayer); + } + + if(iSector<0 || iSector >= MAXSECTORS) + return; + + lValue=GetGameVarID((int)lVar2, sActor, sPlayer); + + switch(lLabelID) + { + case SECTOR_WALLPTR: + if(bSet) + sector[iSector].wallptr=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].wallptr,sActor,sPlayer); + break; + case SECTOR_WALLNUM: + if(bSet) + sector[iSector].wallnum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].wallnum,sActor,sPlayer); + break; + case SECTOR_CEILINGZ: + if(bSet) + sector[iSector].ceilingz=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingz,sActor,sPlayer); + break; + case SECTOR_FLOORZ: + if(bSet) + sector[iSector].floorz=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorz,sActor,sPlayer); + break; + case SECTOR_CEILINGSTAT: + if(bSet) + sector[iSector].ceilingstat=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingstat,sActor,sPlayer); + break; + case SECTOR_FLOORSTAT: + if(bSet) + sector[iSector].floorstat=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorstat,sActor,sPlayer); + break; + case SECTOR_CEILINGPICNUM: + if(bSet) + sector[iSector].ceilingpicnum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingpicnum,sActor,sPlayer); + break; + case SECTOR_CEILINGSLOPE: + if(bSet) + sector[iSector].ceilingheinum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingheinum,sActor,sPlayer); + break; + case SECTOR_CEILINGSHADE: + if(bSet) + sector[iSector].ceilingshade=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingshade,sActor,sPlayer); + break; + case SECTOR_CEILINGPAL: + if(bSet) + sector[iSector].ceilingpal=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingpal,sActor,sPlayer); + break; + case SECTOR_CEILINGXPANNING: + if(bSet) + sector[iSector].ceilingxpanning=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].ceilingypanning,sActor,sPlayer); + break; + case SECTOR_FLOORPICNUM: + if(bSet) + sector[iSector].floorpicnum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorpicnum,sActor,sPlayer); + break; + case SECTOR_FLOORSLOPE: + if(bSet) + sector[iSector].floorheinum=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorheinum,sActor,sPlayer); + break; + case SECTOR_FLOORSHADE: + if(bSet) + sector[iSector].floorshade=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorshade,sActor,sPlayer); + break; + case SECTOR_FLOORPAL: + if(bSet) + sector[iSector].floorpal=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorpal,sActor,sPlayer); + break; + case SECTOR_FLOORXPANNING: + if(bSet) + sector[iSector].floorxpanning=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorxpanning,sActor,sPlayer); + break; + case SECTOR_FLOORYPANNING: + if(bSet) + sector[iSector].floorypanning=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].floorypanning,sActor,sPlayer); + break; + case SECTOR_VISIBILITY: + if(bSet) + sector[iSector].visibility=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].visibility,sActor,sPlayer); + break; + case SECTOR_ALIGNTO: + if(bSet) + sector[iSector].filler=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].filler,sActor,sPlayer); + break; + case SECTOR_LOTAG: + if(bSet) + sector[iSector].lotag=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].lotag,sActor,sPlayer); + break; + case SECTOR_HITAG: + if(bSet) + sector[iSector].hitag=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].hitag,sActor,sPlayer); + break; + case SECTOR_EXTRA: + if(bSet) + sector[iSector].extra=lValue; + else + SetGameVarID((int)lVar2, sector[iSector].extra,sActor,sPlayer); + break; + default: + break; + } + return; +} + +void DoActor(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, short sPlayer, long lParm2) +{ + int iActor; + long lValue; + long lTemp; + + lValue=GetGameVarID((int)lVar2, sActor, sPlayer); + + if(lVar1 == g_iThisActorID ) + { + // if they've asked for 'this', then use 'this'... + iActor=g_i; + } + else + { + if(sActor < 0 || sActor >= MAXSPRITES) + return; + iActor=GetGameVarID((int)lVar1, sActor, sPlayer); + } + + if(iActor < 0 || iActor >= MAXSPRITES) + return; + + switch(lLabelID) + { + case ACTOR_X: + if(bSet) + sprite[iActor].x=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].x,sActor,sPlayer); + break; + case ACTOR_Y: + if(bSet) + sprite[iActor].y=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].y,sActor,sPlayer); + break; + case ACTOR_Z: + if(bSet) + sprite[iActor].z=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].z,sActor,sPlayer); + break; + case ACTOR_CSTAT: + if(bSet) + sprite[iActor].cstat=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].cstat,sActor,sPlayer); + break; + case ACTOR_PICNUM: + if(bSet) + sprite[iActor].picnum=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].picnum,sActor,sPlayer); + break; + case ACTOR_SHADE: + if(bSet) + sprite[iActor].shade=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].shade,sActor,sPlayer); + break; + case ACTOR_PAL: + if(bSet) + sprite[iActor].pal=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].pal,sActor,sPlayer); + break; + case ACTOR_CLIPDIST: + if(bSet) + sprite[iActor].clipdist=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].clipdist,sActor,sPlayer); + break; + case ACTOR_DETAIL: + if(bSet) + sprite[iActor].filler=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].filler,sActor,sPlayer); + break; + case ACTOR_XREPEAT: + if(bSet) + sprite[iActor].xrepeat=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].xrepeat,sActor,sPlayer); + break; + case ACTOR_YREPEAT: + if(bSet) + sprite[iActor].yrepeat=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].yrepeat,sActor,sPlayer); + break; + case ACTOR_XOFFSET: + if(bSet) + sprite[iActor].xoffset=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].xoffset,sActor,sPlayer); + break; + case ACTOR_YOFFSET: + if(bSet) + sprite[iActor].yoffset=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].yoffset,sActor,sPlayer); + break; + case ACTOR_SECTNUM: + if(bSet) + changespritesect(iActor,lValue); + else + SetGameVarID((int)lVar2, sprite[iActor].sectnum,sActor,sPlayer); + break; + case ACTOR_STATNUM: + if(bSet) + changespritestat(iActor,lValue); + else + SetGameVarID((int)lVar2, sprite[iActor].statnum,sActor,sPlayer); + break; + case ACTOR_ANG: + if(bSet) + sprite[iActor].ang=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].ang,sActor,sPlayer); + break; + case ACTOR_OWNER: + if(bSet) + sprite[iActor].owner=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].owner,sActor,sPlayer); + break; + case ACTOR_XVEL: + if(bSet) + sprite[iActor].xvel=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].xvel,sActor,sPlayer); + break; + case ACTOR_YVEL: + if(bSet) + sprite[iActor].yvel=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].yvel,sActor,sPlayer); + break; + case ACTOR_ZVEL: + if(bSet) + sprite[iActor].zvel=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].zvel,sActor,sPlayer); + break; + case ACTOR_LOTAG: + if(bSet) + sprite[iActor].lotag=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].lotag,sActor,sPlayer); + break; + case ACTOR_HITAG: + if(bSet) + sprite[iActor].hitag=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].hitag,sActor,sPlayer); + break; + case ACTOR_EXTRA: + if(bSet) + sprite[iActor].extra=lValue; + else + SetGameVarID((int)lVar2, sprite[iActor].extra,sActor,sPlayer); + break; + case ACTOR_HTCGG: + if(bSet) + hittype[iActor].cgg=lValue; + else + SetGameVarID((int)lVar2, hittype[iActor].cgg, sActor, sPlayer); + break; + case ACTOR_HTPICNUM : + if(bSet) + hittype[iActor].picnum=lValue; + else + SetGameVarID((int)lVar2, hittype[iActor].picnum, sActor, sPlayer); + break; + case ACTOR_HTANG: + if(bSet) + hittype[iActor].ang=lValue; + else + SetGameVarID((int)lVar2, hittype[iActor].ang, sActor, sPlayer); + break; + case ACTOR_HTEXTRA: + if(bSet) + hittype[iActor].extra=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].extra, sActor, sPlayer); + break; + case ACTOR_HTOWNER: + if(bSet) + hittype[iActor].owner=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].owner, sActor, sPlayer); + break; + case ACTOR_HTMOVFLAG: + if(bSet) + hittype[iActor].movflag=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].movflag, sActor, sPlayer); + break; + case ACTOR_HTTEMPANG: + if(bSet) + hittype[iActor].tempang=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].tempang, sActor, sPlayer); + break; + case ACTOR_HTACTORSTAYPUT: + if(bSet) + hittype[iActor].actorstayput=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].actorstayput, sActor, sPlayer); + break; + case ACTOR_HTDISPICNUM: + if(bSet) + hittype[iActor].dispicnum=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].dispicnum, sActor, sPlayer); + break; + case ACTOR_HTTIMETOSLEEP: + if(bSet) + hittype[iActor].timetosleep=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].timetosleep, sActor, sPlayer); + break; + case ACTOR_HTFLOORZ: + if(bSet) + hittype[iActor].floorz=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].floorz, sActor, sPlayer); + break; + case ACTOR_HTCEILINGZ: + if(bSet) + hittype[iActor].ceilingz=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].ceilingz, sActor, sPlayer); + break; + case ACTOR_HTLASTVX: + if(bSet) + hittype[iActor].lastvx=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].lastvx, sActor, sPlayer); + break; + case ACTOR_HTLASTVY: + if(bSet) + hittype[iActor].lastvy=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].lastvy, sActor, sPlayer); + break; + case ACTOR_HTBPOSX: + if(bSet) + hittype[iActor].bposx=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].bposx, sActor, sPlayer); + break; + case ACTOR_HTBPOSY: + if(bSet) + hittype[iActor].bposy=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].bposy, sActor, sPlayer); + break; + case ACTOR_HTBPOSZ: + if(bSet) + hittype[iActor].bposz=lValue; + else + SetGameVarID((int)lVar2,hittype[iActor].bposz, sActor, sPlayer); + break; + case ACTOR_HTG_T: + lTemp=lParm2; + if(bSet) + hittype[iActor].temp_data[lTemp]=lValue; + else + SetGameVarID((int)lVar2, hittype[iActor].temp_data[lTemp], sActor, sPlayer); + break; + case ACTOR_ANGOFF: + if(bSet) + spriteext[iActor].angoff=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].angoff, sActor, sPlayer); + break; + case ACTOR_PITCH: + if(bSet) + spriteext[iActor].pitch=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].pitch, sActor, sPlayer); + break; + case ACTOR_ROLL: + if(bSet) + spriteext[iActor].roll=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].roll, sActor, sPlayer); + break; + case ACTOR_MDXOFF: + if(bSet) + spriteext[iActor].xoff=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].xoff, sActor, sPlayer); + break; + case ACTOR_MDYOFF: + if(bSet) + spriteext[iActor].yoff=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].yoff, sActor, sPlayer); + break; + case ACTOR_MDZOFF: + if(bSet) + spriteext[iActor].zoff=lValue; + else + SetGameVarID((int)lVar2,spriteext[iActor].zoff, sActor, sPlayer); + break; + + default: + break; + } + return; +} + +void DoProjectile(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, short sPlayer) +{ + long lValue,proj; + + // proj=GetGameVarID((int)lVar1, sActor, sPlayer); + proj=lVar1; + lValue=GetGameVarID((int)lVar2, sActor, sPlayer); + + switch(lLabelID) + { + case PROJ_WORKSLIKE: + if(bSet) + projectile[proj].workslike=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].workslike, sActor, sPlayer); + break; + + case PROJ_SPAWNS: + if(bSet) + projectile[proj].spawns=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].spawns, sActor, sPlayer); + break; + + case PROJ_SXREPEAT: + if(bSet) + projectile[proj].sxrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].sxrepeat, sActor, sPlayer); + break; + + case PROJ_SYREPEAT: + if(bSet) + projectile[proj].syrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].syrepeat, sActor, sPlayer); + break; + + case PROJ_SOUND: + if(bSet) + projectile[proj].sound=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].sound, sActor, sPlayer); + break; + + case PROJ_ISOUND: + if(bSet) + projectile[proj].isound=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].isound, sActor, sPlayer); + break; + + case PROJ_VEL: + if(bSet) + projectile[proj].vel=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].vel, sActor, sPlayer); + break; + + case PROJ_EXTRA: + if(bSet) + projectile[proj].extra=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].extra, sActor, sPlayer); + break; + + case PROJ_DECAL: + if(bSet) + projectile[proj].decal=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].decal, sActor, sPlayer); + break; + + case PROJ_TRAIL: + if(bSet) + projectile[proj].trail=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].trail, sActor, sPlayer); + break; + + case PROJ_TXREPEAT: + if(bSet) + projectile[proj].txrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].txrepeat, sActor, sPlayer); + break; + + case PROJ_TYREPEAT: + if(bSet) + projectile[proj].tyrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].tyrepeat, sActor, sPlayer); + break; + + case PROJ_TOFFSET: + if(bSet) + projectile[proj].toffset=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].toffset, sActor, sPlayer); + break; + + case PROJ_TNUM: + if(bSet) + projectile[proj].tnum=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].tnum, sActor, sPlayer); + break; + + case PROJ_DROP: + if(bSet) + projectile[proj].drop=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].drop, sActor, sPlayer); + break; + + case PROJ_CSTAT: + if(bSet) + projectile[proj].cstat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].cstat, sActor, sPlayer); + break; + + case PROJ_CLIPDIST: + if(bSet) + projectile[proj].clipdist=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].clipdist, sActor, sPlayer); + break; + + case PROJ_SHADE: + if(bSet) + projectile[proj].shade=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].shade, sActor, sPlayer); + break; + + case PROJ_XREPEAT: + if(bSet) + projectile[proj].xrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].xrepeat, sActor, sPlayer); + break; + + case PROJ_YREPEAT: + if(bSet) + projectile[proj].yrepeat=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].yrepeat, sActor, sPlayer); + break; + + case PROJ_PAL: + if(bSet) + projectile[proj].pal=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].pal, sActor, sPlayer); + break; + + case PROJ_EXTRA_RAND: + if(bSet) + projectile[proj].extra_rand=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].extra_rand, sActor, sPlayer); + break; + + case PROJ_HITRADIUS: + if(bSet) + projectile[proj].hitradius=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].hitradius, sActor, sPlayer); + break; + + case PROJ_VEL_MULT: + if(bSet) + projectile[proj].velmult=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].velmult, sActor, sPlayer); + break; + + case PROJ_OFFSET: + if(bSet) + projectile[proj].offset=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].offset, sActor, sPlayer); + break; + + case PROJ_BOUNCES: + if(bSet) + projectile[proj].bounces=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].bounces, sActor, sPlayer); + break; + + case PROJ_BSOUND: + if(bSet) + projectile[proj].bsound=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].bsound, sActor, sPlayer); + break; + + case PROJ_RANGE: + if(bSet) + projectile[proj].range=lValue; + else + SetGameVarID((int)lVar2, projectile[proj].range, sActor, sPlayer); + break; + + default: + break; + } + return; +} + +void OnEvent(int iEventID, short sActor,short sPlayer,long lDist) +{ + short og_i,og_p; + long og_x; + long *og_t; + spritetype *og_sp; + char okillit_flag; + long *oinsptr; + + char done; + + if( iEventID >= MAXGAMEEVENTS) + { + AddLog("Invalid Event ID"); + return; + } + + if( apScriptGameEvent[iEventID] == 0 ) + { + //Bsprintf(g_szBuf,"No event found for %d",iEventID); + //AddLog(g_szBuf); + return; + } + + // save current values... + og_i=g_i; + og_p=g_p; + og_x=g_x; + og_sp=g_sp; + og_t=g_t; + okillit_flag=killit_flag; + oinsptr=insptr; + + g_i = sActor; // current sprite ID + g_p = sPlayer; // current player ID + g_x = lDist; // ? + g_sp = &sprite[g_i]; + g_t = &hittype[g_i].temp_data[0]; + + insptr = (apScriptGameEvent[iEventID]); + //Bsprintf(g_szBuf,"Executing event for %d at %lX",iEventID, insptr); + //AddLog(g_szBuf); + + killit_flag = 0; + do + done = parse(); + while( done == 0 ); + + // restore old values... + g_i=og_i; + g_p=og_p; + g_x=og_x; + g_sp=og_sp; + g_t=og_t; + killit_flag=okillit_flag; + insptr=oinsptr; + + //AddLog("End of Execution"); +} + +char dodge(spritetype *s) +{ + short i; + long bx,by,mx,my,bxvect,byvect,mxvect,myvect,d; + + mx = s->x; + my = s->y; + mxvect = sintable[(s->ang+512)&2047]; myvect = sintable[s->ang&2047]; + + for(i=headspritestat[4];i>=0;i=nextspritestat[i]) //weapons list + { + if( OW == i || SECT != s->sectnum) + continue; + + bx = SX-mx; + by = SY-my; + bxvect = sintable[(SA+512)&2047]; byvect = sintable[SA&2047]; + + if (mxvect*bx + myvect*by >= 0) + if (bxvect*bx + byvect*by < 0) + { + d = bxvect*by - byvect*bx; + if (klabs(d) < 65536*64) + { + s->ang -= 512+(TRAND&1024); + return 1; + } + } + } + return 0; +} + +short furthestangle(short sActor,short angs) +{ + short j, hitsect,hitwall,hitspr,furthest_angle=0, angincs; + long hx, hy, hz, d, greatestd; + spritetype *s = &sprite[sActor]; + + greatestd = -(1<<30); + angincs = 2048/angs; + + if(s->picnum != APLAYER) + if( (g_t[0]&63) > 2 ) return( s->ang + 1024 ); + + for(j=s->ang;j<(2048+s->ang);j+=angincs) + { + hitscan(s->x, s->y, s->z-(8<<8), s->sectnum, + sintable[(j+512)&2047], + sintable[j&2047],0, + &hitsect,&hitwall,&hitspr,&hx,&hy,&hz,CLIPMASK1); + + d = klabs(hx-s->x) + klabs(hy-s->y); + + if(d > greatestd) + { + greatestd = d; + furthest_angle = j; + } + } + return (furthest_angle&2047); +} + +short furthestcanseepoint(short sActor,spritetype *ts,long *dax,long *day) +{ + short j, hitsect,hitwall,hitspr, angincs, tempang; + long hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy; + spritetype *s = &sprite[sActor]; + + if( (g_t[0]&63) ) return -1; + + if(ud.multimode < 2 && ud.player_skill < 3) + angincs = 2048/2; + else angincs = 2048/(1+(TRAND&1)); + + for(j=ts->ang;j<(2048+ts->ang);j+=(angincs-(TRAND&511))) + { + hitscan(ts->x, ts->y, ts->z-(16<<8), ts->sectnum, + sintable[(j+512)&2047], + sintable[j&2047],16384-(TRAND&32767), + &hitsect,&hitwall,&hitspr,&hx,&hy,&hz,CLIPMASK1); + + d = klabs(hx-ts->x)+klabs(hy-ts->y); + da = klabs(hx-s->x)+klabs(hy-s->y); + + if( d < da ) + if(cansee(hx,hy,hz,hitsect,s->x,s->y,s->z-(16<<8),s->sectnum)) + { + *dax = hx; + *day = hy; + return hitsect; + } + } + return -1; +} + +void getglobalz(short sActor) +{ + long hz,lz,zr; + + spritetype *s = &sprite[sActor]; + + if( s->statnum == 10 || s->statnum == 6 || s->statnum == 2 || s->statnum == 1 || s->statnum == 4) + { + if(s->statnum == 4) + zr = 4L; + else zr = 127L; + + getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&hittype[sActor].ceilingz,&hz,&hittype[sActor].floorz,&lz,zr,CLIPMASK0); + + if( (lz&49152) == 49152 && (sprite[lz&(MAXSPRITES-1)].cstat&48) == 0 ) + { + lz &= (MAXSPRITES-1); + if( badguy(&sprite[lz]) && sprite[lz].pal != 1) + { + if( s->statnum != 4 ) + { + hittype[sActor].dispicnum = -4; // No shadows on actors + s->xvel = -256; + ssp(sActor,CLIPMASK0); + } + } + else if(sprite[lz].picnum == APLAYER && badguy(s) ) + { + hittype[sActor].dispicnum = -4; // No shadows on actors + s->xvel = -256; + ssp(sActor,CLIPMASK0); + } + else if(s->statnum == 4 && sprite[lz].picnum == APLAYER) + if(s->owner == lz) + { + hittype[sActor].ceilingz = sector[s->sectnum].ceilingz; + hittype[sActor].floorz = sector[s->sectnum].floorz; + } + } + } + else + { + hittype[sActor].ceilingz = sector[s->sectnum].ceilingz; + hittype[sActor].floorz = sector[s->sectnum].floorz; + } +} + +void makeitfall(short sActor) +{ + spritetype *s = &sprite[sActor]; + long hz,lz,c; + + if( floorspace(s->sectnum) ) + c = 0; + else + { + if( ceilingspace(s->sectnum) || sector[s->sectnum].lotag == 2) + c = gc/6; + else c = gc; + } + + if( ( s->statnum == 1 || s->statnum == 10 || s->statnum == 2 || s->statnum == 6 ) ) + getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&hittype[sActor].ceilingz,&hz,&hittype[sActor].floorz,&lz,127L,CLIPMASK0); + else + { + hittype[sActor].ceilingz = sector[s->sectnum].ceilingz; + hittype[sActor].floorz = sector[s->sectnum].floorz; + } + + if( s->z < hittype[sActor].floorz-(FOURSLEIGHT) ) + { + if( sector[s->sectnum].lotag == 2 && s->zvel > 3122 ) + s->zvel = 3144; + if(s->zvel < 6144) + s->zvel += c; + else s->zvel = 6144; + s->z += s->zvel; + } + if( s->z >= hittype[sActor].floorz-(FOURSLEIGHT) ) + { + s->z = hittype[sActor].floorz - FOURSLEIGHT; + s->zvel = 0; + } +} + +short getincangle(short a,short na) +{ + a &= 2047; + na &= 2047; + + if(klabs(a-na) < 1024) + return (na-a); + else + { + if(na > 1024) na -= 2048; + if(a > 1024) a -= 2048; + + na -= 2048; + a -= 2048; + return (na-a); + } +} + +void alterang(short a) +{ + short aang, angdif, goalang,j; + long ticselapsed, *moveptr; + + moveptr = (long *)g_t[1]; + + ticselapsed = (g_t[0])&31; + + aang = g_sp->ang; + + g_sp->xvel += (*moveptr-g_sp->xvel)/5; + if(g_sp->zvel < 648) g_sp->zvel += ((*(moveptr+1)<<4)-g_sp->zvel)/5; + + if(a&seekplayer) + { + j = ps[g_p].holoduke_on; + + // NOTE: looks like 'owner' is set to target sprite ID... + + if(j >= 0 && cansee(sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].sectnum,g_sp->x,g_sp->y,g_sp->z,g_sp->sectnum) ) + g_sp->owner = j; + else g_sp->owner = ps[g_p].i; + + if(sprite[g_sp->owner].picnum == APLAYER) + goalang = getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y); + else + goalang = getangle(sprite[g_sp->owner].x-g_sp->x,sprite[g_sp->owner].y-g_sp->y); + + if(g_sp->xvel && g_sp->picnum != DRONE) + { + angdif = getincangle(aang,goalang); + + if(ticselapsed < 2) + { + if( klabs(angdif) < 256) + { + j = 128-(TRAND&256); + g_sp->ang += j; + if( hits(g_i) < 844 ) + g_sp->ang -= j; + } + } + else if(ticselapsed > 18 && ticselapsed < 26) // choose + { + if(klabs(angdif>>2) < 128) g_sp->ang = goalang; + else g_sp->ang += angdif>>2; + } + } + else g_sp->ang = goalang; + } + + if(ticselapsed < 1) + { + j = 2; + if(a&furthestdir) + { + goalang = furthestangle(g_i,j); + g_sp->ang = goalang; + g_sp->owner = ps[g_p].i; + } + + if(a&fleeenemy) + { + goalang = furthestangle(g_i,j); + g_sp->ang = goalang; // += angdif; // = getincangle(aang,goalang)>>1; + } + } +} + +void move() +{ + long l, *moveptr; + short j, a, goalang, angdif; + long daxvel; + + a = g_sp->hitag; + + if(a == -1) a = 0; + + g_t[0]++; + + if(a&face_player) + { + if(ps[g_p].newowner >= 0) + goalang = getangle(ps[g_p].oposx-g_sp->x,ps[g_p].oposy-g_sp->y); + else goalang = getangle(ps[g_p].posx-g_sp->x,ps[g_p].posy-g_sp->y); + angdif = getincangle(g_sp->ang,goalang)>>2; + if(angdif > -8 && angdif < 0) angdif = 0; + g_sp->ang += angdif; + } + + if(a&spin) + g_sp->ang += sintable[ ((g_t[0]<<3)&2047) ]>>6; + + if(a&face_player_slow) + { + if(ps[g_p].newowner >= 0) + goalang = getangle(ps[g_p].oposx-g_sp->x,ps[g_p].oposy-g_sp->y); + else goalang = getangle(ps[g_p].posx-g_sp->x,ps[g_p].posy-g_sp->y); + angdif = ksgn(getincangle(g_sp->ang,goalang))<<5; + if(angdif > -32 && angdif < 0) + { + angdif = 0; + g_sp->ang = goalang; + } + g_sp->ang += angdif; + } + + + if((a&jumptoplayer) == jumptoplayer) + { + if(g_t[0] < 16) + g_sp->zvel -= (sintable[(512+(g_t[0]<<4))&2047]>>5); + } + + if(a&face_player_smart) + { + long newx,newy; + + newx = ps[g_p].posx+(ps[g_p].posxv/768); + newy = ps[g_p].posy+(ps[g_p].posyv/768); + goalang = getangle(newx-g_sp->x,newy-g_sp->y); + angdif = getincangle(g_sp->ang,goalang)>>2; + if(angdif > -8 && angdif < 0) angdif = 0; + g_sp->ang += angdif; + } + + if( g_t[1] == 0 || a == 0 ) + { + if( ( badguy(g_sp) && g_sp->extra <= 0 ) || (hittype[g_i].bposx != g_sp->x) || (hittype[g_i].bposy != g_sp->y) ) + { + hittype[g_i].bposx = g_sp->x; + hittype[g_i].bposy = g_sp->y; + setsprite(g_i,g_sp->x,g_sp->y,g_sp->z); + } + return; + } + + moveptr = (long *)g_t[1]; + + if(a&geth) g_sp->xvel += (*moveptr-g_sp->xvel)>>1; + if(a&getv) g_sp->zvel += ((*(moveptr+1)<<4)-g_sp->zvel)>>1; + + if(a&dodgebullet) + dodge(g_sp); + + if(g_sp->picnum != APLAYER) + alterang(a); + + if(g_sp->xvel > -6 && g_sp->xvel < 6 ) g_sp->xvel = 0; + + a = badguy(g_sp); + + if(g_sp->xvel || g_sp->zvel) + { + if(a && g_sp->picnum != ROTATEGUN) + { + if( (g_sp->picnum == DRONE || g_sp->picnum == COMMANDER) && g_sp->extra > 0) + { + if(g_sp->picnum == COMMANDER) + { + hittype[g_i].floorz = l = getflorzofslope(g_sp->sectnum,g_sp->x,g_sp->y); + if( g_sp->z > (l-(8<<8)) ) + { + if( g_sp->z > (l-(8<<8)) ) g_sp->z = l-(8<<8); + g_sp->zvel = 0; + } + + hittype[g_i].ceilingz = l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y); + if( (g_sp->z-l) < (80<<8) ) + { + g_sp->z = l+(80<<8); + g_sp->zvel = 0; + } + } + else + { + if( g_sp->zvel > 0 ) + { + hittype[g_i].floorz = l = getflorzofslope(g_sp->sectnum,g_sp->x,g_sp->y); + if( g_sp->z > (l-(30<<8)) ) + g_sp->z = l-(30<<8); + } + else + { + hittype[g_i].ceilingz = l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y); + if( (g_sp->z-l) < (50<<8) ) + { + g_sp->z = l+(50<<8); + g_sp->zvel = 0; + } + } + } + } + else if(g_sp->picnum != ORGANTIC) + { + if(g_sp->zvel > 0 && hittype[g_i].floorz < g_sp->z) + g_sp->z = hittype[g_i].floorz; + if( g_sp->zvel < 0) + { + l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y); + if( (g_sp->z-l) < (66<<8) ) + { + g_sp->z = l+(66<<8); + g_sp->zvel >>= 1; + } + } + } + } + else if(g_sp->picnum == APLAYER) + if( (g_sp->z-hittype[g_i].ceilingz) < (32<<8) ) + g_sp->z = hittype[g_i].ceilingz+(32<<8); + + daxvel = g_sp->xvel; + angdif = g_sp->ang; + + if( a && g_sp->picnum != ROTATEGUN ) + { + if( g_x < 960 && g_sp->xrepeat > 16 ) + { + + daxvel = -(1024-g_x); + angdif = getangle(ps[g_p].posx-g_sp->x,ps[g_p].posy-g_sp->y); + + if(g_x < 512) + { + ps[g_p].posxv = 0; + ps[g_p].posyv = 0; + } + else + { + ps[g_p].posxv = mulscale(ps[g_p].posxv,ps[g_p].runspeed-0x2000,16); + ps[g_p].posyv = mulscale(ps[g_p].posyv,ps[g_p].runspeed-0x2000,16); + } + } + else if(g_sp->picnum != DRONE && g_sp->picnum != SHARK && g_sp->picnum != COMMANDER) + { + if( hittype[g_i].bposz != g_sp->z || ( ud.multimode < 2 && ud.player_skill < 2 ) ) + { + if( (g_t[0]&1) || ps[g_p].actorsqu == g_i ) return; + else daxvel <<= 1; + } + else + { + if( (g_t[0]&3) || ps[g_p].actorsqu == g_i ) return; + else daxvel <<= 2; + } + } + } + + hittype[g_i].movflag = movesprite(g_i, + (daxvel*(sintable[(angdif+512)&2047]))>>14, + (daxvel*(sintable[angdif&2047]))>>14,g_sp->zvel,CLIPMASK0); + } + + if( a ) + { + if (sector[g_sp->sectnum].ceilingstat&1) + g_sp->shade += (sector[g_sp->sectnum].ceilingshade-g_sp->shade)>>1; + else g_sp->shade += (sector[g_sp->sectnum].floorshade-g_sp->shade)>>1; + + if( sector[g_sp->sectnum].floorpicnum == MIRROR ) + deletesprite(g_i); + } +} + +char parse(void); + +void parseifelse(long condition) +{ + if( condition ) + { + // skip 'else' pointer.. and... + insptr+=2; + parse(); + } + else + { + insptr = (long *) *(insptr+1); + if(*insptr == 10) + { + // else... + // skip 'else' and... + insptr+=2; + parse(); + } + } +} + +// long *it = 0x00589a04; + +char parse(void) +{ + long j, l, s, tw; + + if (!(error || warning) && condebug) + { + // Bsprintf(g_szBuf," * DEBUG! Executing: %s",keyw[*insptr]); + // AddLog(g_szBuf); + } + + if(killit_flag) return 1; + + // if(*it == 1668249134L) gameexit("\nERR"); + // Bsprintf(g_szBuf,"Parsing: %d",*insptr); + // AddLog(g_szBuf); + + tw = *insptr; + + switch(tw) + { + case CON_REDEFINEQUOTE: + { + int q, i; + insptr++; + q = *insptr++; + i = *insptr++; + Bstrcpy(fta_quotes[q],redefined_fta_quotes[i]); + break; + } + case CON_GETTHISPROJECTILE: + case CON_SETTHISPROJECTILE: + { + // syntax [gs]etplayer[].x + // + long lLabelID; + long lVar1, lVar2; + long lParm2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + lVar2=*insptr++; + DoThisProjectile(tw==CON_SETTHISPROJECTILE,lVar1,lLabelID,lVar2,g_i,g_p); + break; + } + case CON_IFRND: + insptr++; + parseifelse( rnd(*insptr)); + break; + case CON_IFCANSHOOTTARGET: + + if(g_x > 1024) + { + short temphit, sclip, angdif; + + if( badguy(g_sp) && g_sp->xrepeat > 56 ) + { + sclip = 3084; + angdif = 48; + } + else + { + sclip = 768; + angdif = 16; + } + + j = hitasprite(g_i,&temphit); + if(j == (1<<30)) + { + parseifelse(1); + break; + } + if(j > sclip) + { + if(temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) + j = 0; + else + { + g_sp->ang += angdif;j = hitasprite(g_i,&temphit);g_sp->ang -= angdif; + if(j > sclip) + { + if(temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) + j = 0; + else + { + g_sp->ang -= angdif;j = hitasprite(g_i,&temphit);g_sp->ang += angdif; + if( j > 768 ) + { + if(temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) + j = 0; + else j = 1; + } + else j = 0; + } + } + else j = 0; + } + } + else j = 0; + } + else j = 1; + + parseifelse(j); + break; + case CON_IFCANSEETARGET: + j = cansee(g_sp->x,g_sp->y,g_sp->z-((TRAND&41)<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz/*-((TRAND&41)<<8)*/,sprite[ps[g_p].i].sectnum); + parseifelse(j); + if( j ) hittype[g_i].timetosleep = SLEEPTIME; + break; + + case CON_IFACTORNOTSTAYPUT: + parseifelse(hittype[g_i].actorstayput == -1); + break; + case CON_IFCANSEE: + { + spritetype *s; + short sect; + + // select sprite for monster to target + // if holoduke is on, let them target holoduke first. + // + if(ps[g_p].holoduke_on >= 0) + { + s = &sprite[ps[g_p].holoduke_on]; + j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((32<<8)-1)),g_sp->sectnum, + s->x,s->y,s->z,s->sectnum); + + if(j == 0) + { + // they can't see player's holoduke + // check for player... + s = &sprite[ps[g_p].i]; + } + } + else s = &sprite[ps[g_p].i]; // holoduke not on. look for player + + // can they see player, (or player's holoduke) + j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((47<<8))),g_sp->sectnum, + s->x,s->y,s->z-(24<<8),s->sectnum); + + if(j == 0) + { + // they can't see it. + + // Huh?. This does nothing.... + // (the result is always j==0....) + if( ( klabs(hittype[g_i].lastvx-g_sp->x)+klabs(hittype[g_i].lastvy-g_sp->y) ) < + ( klabs(hittype[g_i].lastvx-s->x)+klabs(hittype[g_i].lastvy-s->y) ) ) + j = 0; + + // um yeah, this if() will always fire.... + if( j == 0 ) + { + // search around for target player + + // also modifies 'target' x&y if found.. + + j = furthestcanseepoint(g_i,s,&hittype[g_i].lastvx,&hittype[g_i].lastvy); + + if(j == -1) j = 0; + else j = 1; + } + } + else + { + // else, they did see it. + // save where we were looking... + hittype[g_i].lastvx = s->x; + hittype[g_i].lastvy = s->y; + } + + if( j == 1 && ( g_sp->statnum == 1 || g_sp->statnum == 6 ) ) + hittype[g_i].timetosleep = SLEEPTIME; + + parseifelse(j == 1); + break; + } + + case CON_IFHITWEAPON: + parseifelse(ifhitbyweapon(g_i) >= 0); + break; + case CON_IFSQUISHED: + parseifelse( ifsquished(g_i, g_p) == 1); + break; + case CON_IFDEAD: + { + j = g_sp->extra; + if(g_sp->picnum == APLAYER) + j--; + parseifelse(j < 0); + } + break; + case CON_AI: + insptr++; + g_t[5] = *insptr++; + g_t[4] = *(long *)(g_t[5]); // Action + g_t[1] = *(long *)(g_t[5]+4); // move + g_sp->hitag = *(long *)(g_t[5]+8); // Ai + g_t[0] = g_t[2] = g_t[3] = 0; + if(g_sp->hitag&random_angle) + g_sp->ang = TRAND&2047; + break; + case CON_ACTION: + insptr++; + g_t[2] = 0; + g_t[3] = 0; + g_t[4] = *insptr++; + break; + + case CON_IFPDISTL: + insptr++; + parseifelse(g_x < *insptr); + if(g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0) + hittype[g_i].timetosleep = SLEEPTIME; + break; + case CON_IFPDISTG: + insptr++; + parseifelse(g_x > *insptr); + if(g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0) + hittype[g_i].timetosleep = SLEEPTIME; + break; + case CON_ELSE: + insptr = (long *) *(insptr+1); + break; + case CON_ADDSTRENGTH: + insptr++; + g_sp->extra += *insptr++; + break; + case CON_STRENGTH: + insptr++; + g_sp->extra = *insptr++; + break; + case CON_IFGOTWEAPONCE: + insptr++; + + if((gametype_flags[ud.coop]&GAMETYPE_FLAG_WEAPSTAY) && ud.multimode > 1) + { + if(*insptr == 0) + { + for(j=0;j < ps[g_p].weapreccnt;j++) + if( ps[g_p].weaprecs[j] == g_sp->picnum ) + break; + + parseifelse(j < ps[g_p].weapreccnt && g_sp->owner == g_i); + } + else if(ps[g_p].weapreccnt < 16) + { + ps[g_p].weaprecs[ps[g_p].weapreccnt++] = g_sp->picnum; + parseifelse(g_sp->owner == g_i); + } + } + else parseifelse(0); + break; + case CON_GETLASTPAL: + insptr++; + if(g_sp->picnum == APLAYER) + g_sp->pal = ps[g_sp->yvel].palookup; + else g_sp->pal = hittype[g_i].tempang; + hittype[g_i].tempang = 0; + break; + case CON_TOSSWEAPON: + insptr++; + checkweapons(&ps[g_sp->yvel]); + break; + case CON_NULLOP: + insptr++; + break; + case CON_MIKESND: + insptr++; + if(!isspritemakingsound(g_i,g_sp->yvel)) + spritesound(g_sp->yvel,g_i); + break; + case CON_PKICK: + insptr++; + + if( ud.multimode > 1 && g_sp->picnum == APLAYER ) + { + if(ps[otherp].quick_kick == 0) + ps[otherp].quick_kick = 14; + } + else if(g_sp->picnum != APLAYER && ps[g_p].quick_kick == 0) + ps[g_p].quick_kick = 14; + break; + case CON_SIZETO: + insptr++; + + j = (*insptr++-g_sp->xrepeat)<<1; + g_sp->xrepeat += ksgn(j); + + if( ( g_sp->picnum == APLAYER && g_sp->yrepeat < 36 ) || *insptr < g_sp->yrepeat || ((g_sp->yrepeat*(tilesizy[g_sp->picnum]+8))<<2) < (hittype[g_i].floorz - hittype[g_i].ceilingz) ) + { + j = ((*insptr)-g_sp->yrepeat)<<1; + if( klabs(j) ) g_sp->yrepeat += ksgn(j); + } + + insptr++; + + break; + case CON_SIZEAT: + insptr++; + g_sp->xrepeat = (char) *insptr++; + g_sp->yrepeat = (char) *insptr++; + break; + case CON_SHOOT: + insptr++; + shoot(g_i,(short)*insptr++); + break; + case CON_SOUNDONCE: + insptr++; + if(!isspritemakingsound(g_i,*insptr)) + spritesound((short) *insptr,g_i); + insptr++; + break; + case CON_IFSOUND: + insptr++; + parseifelse( Sound[*insptr].num > 0 ); + // parseifelse(SoundOwner[*insptr][0].i == g_i); + break; + case CON_STOPSOUND: + insptr++; + if(isspritemakingsound(g_i,*insptr)) + stopspritesound((short)*insptr,g_i); + insptr++; + break; + case CON_GLOBALSOUND: + insptr++; + if(g_p == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) + spritesound((short) *insptr,ps[screenpeek].i); + insptr++; + break; + case CON_SOUND: + insptr++; + spritesound((short) *insptr++,g_i); + break; + case CON_TIP: + insptr++; + ps[g_p].tipincs = 26; + break; + case CON_FALL: + insptr++; + g_sp->xoffset = 0; + g_sp->yoffset = 0; + // if(!gotz) + { + long c; + + if( floorspace(g_sp->sectnum) ) + c = 0; + else + { + if( ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2) + c = gc/6; + else c = gc; + } + + if( hittype[g_i].cgg <= 0 || (sector[g_sp->sectnum].floorstat&2) ) + { + getglobalz(g_i); + hittype[g_i].cgg = 6; + } + else hittype[g_i].cgg --; + + if( g_sp->z < (hittype[g_i].floorz-FOURSLEIGHT) ) + { + g_sp->zvel += c; + g_sp->z+=g_sp->zvel; + + if(g_sp->zvel > 6144) g_sp->zvel = 6144; + } + else + { + g_sp->z = hittype[g_i].floorz - FOURSLEIGHT; + + if( badguy(g_sp) || ( g_sp->picnum == APLAYER && g_sp->owner >= 0) ) + { + + if( g_sp->zvel > 3084 && g_sp->extra <= 1) + { + if(g_sp->pal != 1 && g_sp->picnum != DRONE) + { + if(g_sp->picnum == APLAYER && g_sp->extra > 0) + goto SKIPJIBS; + guts(g_sp,JIBS6,15,g_p); + spritesound(SQUISHED,g_i); + spawn(g_i,BLOODPOOL); + } + +SKIPJIBS: + + hittype[g_i].picnum = SHOTSPARK1; + hittype[g_i].extra = 1; + g_sp->zvel = 0; + } + else if(g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != 1) + { + + j = g_sp->sectnum; + pushmove(&g_sp->x,&g_sp->y,&g_sp->z,(short*)&j,128L,(4L<<8),(4L<<8),CLIPMASK0); + if(j != g_sp->sectnum && j >= 0 && j < MAXSECTORS) + changespritesect(g_i,j); + + spritesound(THUD,g_i); + } + } + if(sector[g_sp->sectnum].lotag == 1) + switch (dynamictostatic[g_sp->picnum]) + { + case OCTABRAIN__STATIC: + case COMMANDER__STATIC: + case DRONE__STATIC: + break; + default: + g_sp->z += (24<<8); + break; + } + else g_sp->zvel = 0; + } + } + + break; + case CON_ENDA: + case CON_BREAK: + case CON_ENDS: + return 1; + case CON_RIGHTBRACE: + insptr++; + return 1; + case CON_ADDAMMO: + insptr++; + if( ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr] ) + { + killit_flag = 2; + break; + } + addammo( *insptr, &ps[g_p], *(insptr+1) ); + if(ps[g_p].curr_weapon == KNEE_WEAPON) + if( ps[g_p].gotweapon[*insptr]) { + if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); + else addweapon( &ps[g_p], *insptr ); + } + insptr += 2; + break; + case CON_MONEY: + insptr++; + lotsofmoney(g_sp,*insptr++); + break; + case CON_MAIL: + insptr++; + lotsofmail(g_sp,*insptr++); + break; + case CON_SLEEPTIME: + insptr++; + hittype[g_i].timetosleep = (short)*insptr++; + break; + case CON_PAPER: + insptr++; + lotsofpaper(g_sp,*insptr++); + break; + case CON_ADDKILLS: + insptr++; + ps[g_p].actors_killed += *insptr++; + hittype[g_i].actorstayput = -1; + break; + case CON_LOTSOFGLASS: + insptr++; + spriteglass(g_i,*insptr++); + break; + case CON_KILLIT: + insptr++; + killit_flag = 1; + break; + case CON_ADDWEAPON: + insptr++; + if( ps[g_p].gotweapon[*insptr] == 0 ) { + if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); + else addweapon( &ps[g_p], *insptr ); + } + else if( ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr] ) + { + killit_flag = 2; + break; + } + addammo( *insptr, &ps[g_p], *(insptr+1) ); + if(ps[g_p].curr_weapon == KNEE_WEAPON) + if( ps[g_p].gotweapon[*insptr]) { + if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); + else addweapon( &ps[g_p], *insptr ); + } + insptr+=2; + break; + case CON_DEBUG: + insptr++; + printf("%ld\n",*insptr++); + break; + case CON_ENDOFGAME: + insptr++; + ps[g_p].timebeforeexit = *insptr++; + ps[g_p].customexitsound = -1; + ud.eog = 1; + break; + case CON_ADDPHEALTH: + insptr++; + + if(ps[g_p].newowner >= 0) + { + ps[g_p].newowner = -1; + ps[g_p].posx = ps[g_p].oposx; + ps[g_p].posy = ps[g_p].oposy; + ps[g_p].posz = ps[g_p].oposz; + ps[g_p].ang = ps[g_p].oang; + updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum); + setpal(&ps[g_p]); + + j = headspritestat[1]; + while(j >= 0) + { + if(sprite[j].picnum==CAMERA1) + sprite[j].yvel = 0; + j = nextspritestat[j]; + } + } + + j = sprite[ps[g_p].i].extra; + + if(g_sp->picnum != ATOMICHEALTH) + { + if( j > max_player_health && *insptr > 0 ) + { + insptr++; + break; + } + else + { + if(j > 0) + j += *insptr; + if ( j > max_player_health && *insptr > 0 ) + j = max_player_health; + } + } + else + { + if( j > 0 ) + j += *insptr; + if ( j > (max_player_health<<1) ) + j = (max_player_health<<1); + } + + if(j < 0) j = 0; + + if(ud.god == 0) + { + if(*insptr > 0) + { + if( ( j - *insptr ) < (max_player_health>>2) && + j >= (max_player_health>>2) ) + spritesound(DUKE_GOTHEALTHATLOW,ps[g_p].i); + + ps[g_p].last_extra = j; + } + + sprite[ps[g_p].i].extra = j; + } + + insptr++; + break; + case CON_STATE: + { + long *tempscrptr; + + tempscrptr = insptr+2; + + insptr = (long *) *(insptr+1); + while(1) if(parse()) break; + insptr = tempscrptr; + } + break; + case CON_LEFTBRACE: + insptr++; + while(1) if(parse()) break; + break; + case CON_MOVE: + insptr++; + g_t[0]=0; + g_t[1] = *insptr++; + g_sp->hitag = *insptr++; + if(g_sp->hitag&random_angle) + g_sp->ang = TRAND&2047; + break; + + case CON_ADDWEAPONVAR: + insptr++; + if( ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)] == 0 ) { + if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); + else addweapon( &ps[g_p], GetGameVarID(*(insptr),g_i,g_p) ); + } + else if( ps[g_p].ammo_amount[GetGameVarID(*(insptr),g_i,g_p)] >= max_ammo_amount[GetGameVarID(*(insptr),g_i,g_p)] ) + { + killit_flag = 2; + break; + } + addammo( GetGameVarID(*(insptr),g_i,g_p), &ps[g_p], GetGameVarID(*(insptr+1),g_i,g_p) ); + if(ps[g_p].curr_weapon == KNEE_WEAPON) + if( ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)] ) { + if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); + else addweapon( &ps[g_p], GetGameVarID(*(insptr),g_i,g_p) ); + } + insptr+=2; + break; + + case CON_ACTIVATEBYSECTOR: + case CON_OPERATESECTORS: + case CON_OPERATEACTIVATORS: + case CON_SETASPECT: + case CON_SSP: + { + long var1, var2; + + insptr++; + var1 = GetGameVarID(*insptr++,g_i,g_p); + var2 = GetGameVarID(*insptr++,g_i,g_p); + + switch(tw) + { + case CON_ACTIVATEBYSECTOR: + activatebysector(var1, var2); + break; + case CON_OPERATESECTORS: + operatesectors(var1, var2); + break; + case CON_OPERATEACTIVATORS: + operateactivators(var1, var2); + break; + case CON_SETASPECT: + setaspect(var1, var2); + break; + case CON_SSP: + ssp(var1, var2); + break; + } + break; + } + + case CON_OPERATERESPAWNS: + case CON_OPERATEMASTERSWITCHES: + case CON_CHECKACTIVATORMOTION: + { + long var1; + + insptr++; + var1 = GetGameVarID(*insptr++,g_i,g_p); + + switch(tw) + { + case CON_OPERATERESPAWNS: + operaterespawns(var1); + break; + case CON_OPERATEMASTERSWITCHES: + operatemasterswitches(var1); + break; + case CON_CHECKACTIVATORMOTION: + SetGameVarID(g_iReturnVarID, check_activator_motion(var1), g_i, g_p); + break; + } + break; + } + + + case CON_INSERTSPRITEQ: + insptr++; + insertspriteq(g_i); + break; + + case CON_GETPNAME: + case CON_QSTRCAT: + case CON_QSTRCPY: + case CON_CHANGESPRITESTAT: + case CON_CHANGESPRITESECT: + { + int i,j; + insptr++; + i = GetGameVarID(*insptr++, g_i, g_p); + j = GetGameVarID(*insptr++, g_i, g_p); + switch(tw) + { + case CON_GETPNAME: + if (ud.user_name[j][0] != 0) + Bsprintf(fta_quotes[i],ud.user_name[j]); + else Bsprintf(fta_quotes[i],"%d",j); + break; + case CON_QSTRCAT: + Bstrncat(fta_quotes[i],fta_quotes[j],63-Bstrlen(fta_quotes[i])); + break; + case CON_QSTRCPY: + Bstrcpy(fta_quotes[i],fta_quotes[j]); + break; + case CON_CHANGESPRITESTAT: + changespritestat(i,j); + break; + case CON_CHANGESPRITESECT: + changespritesect(i,j); + break; + } + break; + } + + case CON_STARTLEVEL: + { + // from 'level' cheat in game.c (about line 6250) + long volnume; + long levnume; + int i; + + insptr++; // skip command + volnume=GetGameVarID(*insptr++,g_i,g_p); + levnume=GetGameVarID(*insptr++,g_i,g_p); + + if(volnume > num_volumes || volnume < 0) + { + /* + if( g_cmddebug&CMDDEBUG_COMPILE) + { + Bsprintf(g_szBuf,"startlevel: Invalid Volume number: %ld. Command ignored.",volnume); + AddLog(g_szBuf); + } + */ + break; + } + + if(levnume >= 11 || levnume <0) + { + /* + if( g_cmddebug&CMDDEBUG_COMPILE) + { + Bsprintf(g_szBuf,"startlevel: Invalid Level number: %ld. Command ignored.",levnume); + AddLog(g_szBuf); + } + */ + break; + } + + ud.m_volume_number = ud.volume_number = volnume; + ud.m_level_number = ud.level_number = levnume; + if(numplayers > 1 && myconnectindex == connecthead) + { + tempbuf[0] = 5; + tempbuf[1] = ud.m_level_number; + tempbuf[2] = ud.m_volume_number; + tempbuf[3] = ud.m_player_skill; + tempbuf[4] = ud.m_monsters_off; + tempbuf[5] = ud.m_respawn_monsters; + tempbuf[6] = ud.m_respawn_items; + tempbuf[7] = ud.m_respawn_inventory; + tempbuf[8] = ud.m_coop; + tempbuf[9] = ud.m_marker; + tempbuf[10] = ud.m_ffire; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + sendpacket(i,tempbuf,11); + } + else { ps[myconnectindex].gm |= MODE_EOL; display_bonus_screen = 0; } // MODE_RESTART; + + break; + } + + case CON_MYOSX: + case CON_MYOSPALX: + case CON_MYOS: + case CON_MYOSPAL: + { + long x,y; + short tilenum; + signed char shade; + char orientation; + char pal; + + insptr++; + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + tilenum=GetGameVarID(*insptr++,g_i,g_p); + shade=GetGameVarID(*insptr++,g_i,g_p); + orientation=GetGameVarID(*insptr++,g_i,g_p); + + switch(tw) + { + case CON_MYOS: + myos(x,y,tilenum,shade,orientation); + break; + case CON_MYOSPAL: + pal=GetGameVarID(*insptr++,g_i,g_p); + myospal(x,y,tilenum,shade,orientation,pal); + break; + case CON_MYOSX: + myosx(x,y,tilenum,shade,orientation); + break; + case CON_MYOSPALX: + pal=GetGameVarID(*insptr++,g_i,g_p); + myospalx(x,y,tilenum,shade,orientation,pal); + break; + } + break; + } + + case CON_SWITCH: + { + long lVarID; + long lValue; + long *lpDefault; + long *lpCases; + long lCases; + long lEnd; + long lCheckCase; + char bMatched; + long *lTempInsPtr; + + // command format: + // variable ID to check + // script offset to 'end' + // count of case statements + // script offset to default case (null if none) + // For each case: value, ptr to code + //AddLog("Processing Switch..."); + insptr++; // p-code + lVarID=*insptr++; + lValue=GetGameVarID(lVarID, g_i, g_p); + lEnd=*insptr++; + lCases=*insptr++; + lpDefault=insptr++; + lpCases=insptr; + insptr+=lCases*2; + bMatched=0; + lTempInsPtr=insptr; + //Bsprintf(g_szBuf,"lEnd= %ld *lpDefault=%ld",lEnd,*lpDefault); + //AddLog(g_szBuf); + + //Bsprintf(g_szBuf,"Checking %ld cases for %ld",lCases, lValue); + //AddLog(g_szBuf); + for(lCheckCase=0; lCheckCasesectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = spawn(g_i, lIn); + + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + insertspriteq(lReturn); + break; + } + + case CON_INITTIMER: + { + short i; + insptr++; + i = GetGameVarID(*insptr++, g_i, g_p); + if (timer != i) + { + uninittimer(); + inittimer(i); + timer = i; + } + break; + } + + case CON_TIME: + { + insptr += 2; + break; + } + + case CON_ESPAWNVAR: + { + long lIn, lReturn=-1; + + insptr++; + + lIn=*insptr++; + lIn=GetGameVarID(lIn, g_i, g_p); + if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = spawn(g_i, lIn); + + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + break; + } + + case CON_QSPAWNVAR: + { + long lIn, lReturn=-1; + + insptr++; + + lIn=*insptr++; + lIn=GetGameVarID(lIn, g_i, g_p); + if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = spawn(g_i, lIn); + + insertspriteq(lReturn); + break; + } + + case CON_ESPAWN: + { + long lReturn=-1; + + insptr++; + if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = spawn(g_i,*insptr); + insptr++; + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + break; + } + + case CON_EQSPAWN: + { + long lReturn=-1; + + insptr++; + if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = spawn(g_i,*insptr); + insptr++; + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + insertspriteq(lReturn); + break; + } + + case CON_QSPAWN: + { + long lReturn=-1; + + insptr++; + if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = spawn(g_i,*insptr); + insptr++; + insertspriteq(lReturn); + break; + } + + case CON_ESHOOT: + { + long lReturn=-1; + + insptr++; + if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = shoot(g_i,*insptr); + insptr++; + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + break; + } + + case CON_ZSHOOT: + { + insptr++; + hittype[g_i].temp_data[9] = GetGameVarID(*insptr++, g_i, g_p); + if (hittype[g_i].temp_data[9] == 0) + hittype[g_i].temp_data[9] = 1; + shoot(g_i,*insptr++); + hittype[g_i].temp_data[9]=0; + break; + } + + case CON_SHOOTVAR: + case CON_ESHOOTVAR: + { + long lIn, lReturn=-1; + + insptr++; + + lIn=GetGameVarID(*insptr++, g_i, g_p); + if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + lReturn = shoot(g_i, lIn); + if (tw == CON_ESHOOTVAR) + SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); + break; + } + + case CON_SOUNDVAR: + case CON_STOPSOUNDVAR: + case CON_SOUNDONCEVAR: + case CON_GLOBALSOUNDVAR: + { + int sound; + + insptr++; + sound=GetGameVarID(*insptr++, g_i, g_p); + + switch(tw) + { + case CON_SOUNDONCEVAR: + if(!isspritemakingsound(g_i,sound)) + spritesound((short)sound,g_i); + break; + case CON_GLOBALSOUNDVAR: + spritesound((short)sound,ps[screenpeek].i); + break; + case CON_STOPSOUNDVAR: + if(isspritemakingsound(g_i,sound)) + stopspritesound((short)sound,g_i); + break; + case CON_SOUNDVAR: + spritesound((short)sound,g_i); + break; + } + break; + } + + case CON_GUNIQHUDID: + { + int i; + insptr++; + i=GetGameVarID(*insptr++, g_i, g_p); + if (i < MAXUNIQHUDID-1) + guniqhudid = i; + break; + } + + case CON_SAVEGAMEVAR: + case CON_READGAMEVAR: + { + int32 i=0; + insptr++; + if (scripthandle < 0) break; + switch(tw) + { + case CON_SAVEGAMEVAR: + i=GetGameVarID(*insptr, g_i, g_p); + SCRIPT_PutNumber( scripthandle, "Gamevars",aGameVars[*insptr++].szLabel,i,false,false); + break; + case CON_READGAMEVAR: + SCRIPT_GetNumber( scripthandle, "Gamevars",aGameVars[*insptr].szLabel,&i); + SetGameVarID(*insptr++, i, g_i, g_p); + break; + } + break; + } + + case CON_ROTATESPRITE: + { + long x,y,z; + short tilenum; + short a; + signed char shade; + char orientation; + char pal; + long x1, y1, x2, y2; + insptr++; + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + z=GetGameVarID(*insptr++,g_i,g_p); + a=GetGameVarID(*insptr++,g_i,g_p); + tilenum=GetGameVarID(*insptr++,g_i,g_p); + shade=GetGameVarID(*insptr++,g_i,g_p); + pal=GetGameVarID(*insptr++,g_i,g_p); + orientation=GetGameVarID(*insptr++,g_i,g_p); + x1=GetGameVarID(*insptr++,g_i,g_p); + y1=GetGameVarID(*insptr++,g_i,g_p); + x2=GetGameVarID(*insptr++,g_i,g_p); + y2=GetGameVarID(*insptr++,g_i,g_p); + + rotatesprite(x<<16,y<<16,z,a,tilenum,shade,pal,2|orientation,x1,y1,x2,y2); + break; + } + + case CON_MINITEXT: + case CON_GAMETEXT: + case CON_DIGITALNUMBER: + { + long x,y,z; + short tilenum=0; + short a; + signed char shade; + char orientation=0; + char pal; + long x1=0, y1=0, x2=0, y2=0; + long q; + insptr++; + + if (tw == CON_GAMETEXT || tw == CON_DIGITALNUMBER) + tilenum=GetGameVarID(*insptr++,g_i,g_p); + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + q=GetGameVarID(*insptr++,g_i,g_p); + shade=GetGameVarID(*insptr++,g_i,g_p); + pal=GetGameVarID(*insptr++,g_i,g_p); + if (tw == CON_GAMETEXT || tw == CON_DIGITALNUMBER) + { + orientation=GetGameVarID(*insptr++,g_i,g_p); + x1=GetGameVarID(*insptr++,g_i,g_p); + y1=GetGameVarID(*insptr++,g_i,g_p); + x2=GetGameVarID(*insptr++,g_i,g_p); + y2=GetGameVarID(*insptr++,g_i,g_p); + } + + if (tw == CON_MINITEXT) minitextshade(x,y,fta_quotes[q],shade,pal,26); + else if (tw == CON_GAMETEXT) txgametext(tilenum,x>>1,y,fta_quotes[q],shade,pal,orientation,x1,y1,x2,y2); + else if (tw == CON_DIGITALNUMBER) txdigitalnumber(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2); + break; + } + + case CON_ANGOFF: + insptr++; + spriteext[g_i].angoff=*insptr++; + break; + + case CON_GETZRANGE: + { + long x, y, z, ceilz, ceilhit, florz, florhit, walldist, clipmask; + long ceilzvar, ceilhitvar, florzvar, florhitvar; + short sectnum; + + insptr++; + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + z=GetGameVarID(*insptr++,g_i,g_p); + sectnum=GetGameVarID(*insptr++,g_i,g_p); + ceilzvar=*insptr++; + ceilhitvar=*insptr++; + florzvar=*insptr++; + florhitvar=*insptr++; + walldist=GetGameVarID(*insptr++,g_i,g_p); + clipmask=GetGameVarID(*insptr++,g_i,g_p); + + getzrange(x, y, z, sectnum, &ceilz, &ceilhit, &florz, &florhit, walldist, clipmask); + SetGameVarID(ceilzvar, ceilz, g_i, g_p); + SetGameVarID(ceilhitvar, ceilhit, g_i, g_p); + SetGameVarID(florzvar, florz, g_i, g_p); + SetGameVarID(florhitvar, florhit, g_i, g_p); + break; + } + + case CON_HITSCAN: + { + long xs, ys, zs, vx, vy, vz, hitx, hity, hitz; + short sectnum, hitsect, hitwall, hitsprite; + unsigned long cliptype; + + long hitxvar, hityvar, hitzvar; + short hitsectvar, hitwallvar, hitspritevar; + + insptr++; + xs=GetGameVarID(*insptr++,g_i,g_p); + ys=GetGameVarID(*insptr++,g_i,g_p); + zs=GetGameVarID(*insptr++,g_i,g_p); + sectnum=GetGameVarID(*insptr++,g_i,g_p); + vx=GetGameVarID(*insptr++,g_i,g_p); + vy=GetGameVarID(*insptr++,g_i,g_p); + vz=GetGameVarID(*insptr++,g_i,g_p); + hitsectvar=*insptr++; + hitwallvar=*insptr++; + hitspritevar=*insptr++; + hitxvar=*insptr++; + hityvar=*insptr++; + hitzvar=*insptr++; + cliptype=GetGameVarID(*insptr++,g_i,g_p); + hitscan(xs, ys, zs, sectnum, vx, vy, vz, &hitsect, &hitwall, &hitsprite, &hitx, &hity, &hitz, cliptype); + SetGameVarID(hitsectvar, hitsect, g_i, g_p); + SetGameVarID(hitwallvar, hitwall, g_i, g_p); + SetGameVarID(hitspritevar, hitsprite, g_i, g_p); + SetGameVarID(hitxvar, hitx, g_i, g_p); + SetGameVarID(hityvar, hity, g_i, g_p); + SetGameVarID(hitzvar, hitz, g_i, g_p); + break; + } + + case CON_ROTATEPOINT: + { + long xpivot, ypivot, x, y, x2, y2, x2var, y2var; + short daang; + + insptr++; + xpivot=GetGameVarID(*insptr++,g_i,g_p); + ypivot=GetGameVarID(*insptr++,g_i,g_p); + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + daang=GetGameVarID(*insptr++,g_i,g_p); + x2var=*insptr++; + y2var=*insptr++; + rotatepoint(xpivot,ypivot,x,y,daang,&x2,&y2); + SetGameVarID(x2var, x2, g_i, g_p); + SetGameVarID(y2var, y2, g_i, g_p); + break; + } + + case CON_NEARTAG: + { + // neartag(long x, long y, long z, short sectnum, short ang, //Starting position & angle + // short *neartagsector, //Returns near sector if sector[].tag != 0 + // short *neartagwall, //Returns near wall if wall[].tag != 0 + // short *neartagsprite, //Returns near sprite if sprite[].tag != 0 + // long *neartaghitdist, //Returns actual distance to object (scale: 1024=largest grid size) + // long neartagrange, //Choose maximum distance to scan (scale: 1024=largest grid size) + // char tagsearch) //1-lotag only, 2-hitag only, 3-lotag&hitag + + long x, y, z, neartaghitdist, neartagrange; + short sectnum, ang, neartagsector, neartagwall, neartagsprite; + long neartagsectorvar, neartagwallvar, neartagspritevar, neartaghitdistvar; + char tagsearch; + + insptr++; + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + z=GetGameVarID(*insptr++,g_i,g_p); + sectnum=GetGameVarID(*insptr++,g_i,g_p); + ang=GetGameVarID(*insptr++,g_i,g_p); + neartagsectorvar=*insptr++; + neartagwallvar=*insptr++; + neartagspritevar=*insptr++; + neartaghitdistvar=*insptr++; + neartagrange=GetGameVarID(*insptr++,g_i,g_p); + tagsearch=GetGameVarID(*insptr++,g_i,g_p); + neartag(x, y, z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, neartagrange, tagsearch); + SetGameVarID(neartagsectorvar, neartagsector, g_i, g_p); + SetGameVarID(neartagwallvar, neartagwall, g_i, g_p); + SetGameVarID(neartagspritevar, neartagsprite, g_i, g_p); + SetGameVarID(neartaghitdistvar, neartaghitdist, g_i, g_p); + break; + } + + case CON_MOVESPRITE: + case CON_SETSPRITE: + { + short spritenum; + long x, y, z; + unsigned long cliptype, returnvar; + insptr++; + spritenum = GetGameVarID(*insptr++,g_i,g_p); + x = GetGameVarID(*insptr++,g_i,g_p); + y = GetGameVarID(*insptr++,g_i,g_p); + z = GetGameVarID(*insptr++,g_i,g_p); + switch(tw) + { + case CON_MOVESPRITE: + cliptype = GetGameVarID(*insptr++,g_i,g_p); + returnvar = *insptr++; + SetGameVarID(returnvar, movesprite(spritenum, x, y, z, cliptype), g_i, g_p); + break; + case CON_SETSPRITE: + setsprite(spritenum, x, y, z); + break; + } + break; + } + + case CON_GETFLORZOFSLOPE: + case CON_GETCEILZOFSLOPE: + { + short sectnum; + long x, y; + unsigned long returnvar; + insptr++; + sectnum = GetGameVarID(*insptr++,g_i,g_p); + x = GetGameVarID(*insptr++,g_i,g_p); + y = GetGameVarID(*insptr++,g_i,g_p); + returnvar = *insptr++; + switch(tw) + { + case CON_GETFLORZOFSLOPE: + SetGameVarID(returnvar, getflorzofslope(sectnum,x,y), g_i, g_p); + break; + case CON_GETCEILZOFSLOPE: + SetGameVarID(returnvar, getceilzofslope(sectnum,x,y), g_i, g_p); + break; + } + break; + } + + case CON_UPDATESECTOR: + case CON_UPDATESECTORZ: + { + long x,y,z=0; + int var; + short w; + + w=sprite[g_i].sectnum; + + insptr++; + + x=GetGameVarID(*insptr++,g_i,g_p); + y=GetGameVarID(*insptr++,g_i,g_p); + if (tw==CON_UPDATESECTORZ) z=GetGameVarID(*insptr++,g_i,g_p); + var=*insptr++; + + if (tw==CON_UPDATESECTOR) updatesector(x,y,&w); + else if (tw==CON_UPDATESECTORZ) updatesectorz(x,y,z,&w); + + SetGameVarID(var, w, g_i, g_p); + break; + } + + case CON_SPAWN: + insptr++; + if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + spawn(g_i,*insptr); + insptr++; + break; + case CON_IFWASWEAPON: + insptr++; + parseifelse( hittype[g_i].picnum == *insptr); + break; + case CON_IFAI: + insptr++; + parseifelse(g_t[5] == *insptr); + break; + case CON_IFACTION: + insptr++; + parseifelse(g_t[4] == *insptr); + break; + case CON_IFACTIONCOUNT: + insptr++; + parseifelse(g_t[2] >= *insptr); + break; + case CON_RESETACTIONCOUNT: + insptr++; + g_t[2] = 0; + break; + case CON_DEBRIS: + { + short dnum; + + insptr++; + dnum = *insptr++; + + if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) + for(j=(*insptr)-1;j>=0;j--) + { + if(g_sp->picnum == BLIMP && dnum == SCRAP1) + s = 0; + else s = (TRAND%3); + + l = EGS(g_sp->sectnum, + g_sp->x+(TRAND&255)-128,g_sp->y+(TRAND&255)-128,g_sp->z-(8<<8)-(TRAND&8191), + dnum+s,g_sp->shade,32+(TRAND&15),32+(TRAND&15), + TRAND&2047,(TRAND&127)+32, + -(TRAND&2047),g_i,5); + if(g_sp->picnum == BLIMP && dnum == SCRAP1) + sprite[l].yvel = weaponsandammosprites[j%14]; + else sprite[l].yvel = -1; + sprite[l].pal = g_sp->pal; + } + insptr++; + } + break; + + case CON_COUNT: + insptr++; + g_t[0] = (short) *insptr++; + break; + case CON_CSTATOR: + insptr++; + g_sp->cstat |= (short) *insptr++; + break; + case CON_CLIPDIST: + insptr++; + g_sp->clipdist = (short) *insptr++; + break; + case CON_CSTAT: + insptr++; + g_sp->cstat = (short) *insptr++; + break; + case CON_SAVE: + { + int i; + time_t curtime; + + insptr++; + i = *insptr++; + if(movesperpacket == 4 && connecthead != myconnectindex) + break; + + lastsavedpos = i; + curtime = time(NULL); + Bstrcpy(tempbuf,asctime(localtime(&curtime))); + clearbuf(ud.savegame[lastsavedpos],sizeof(ud.savegame[lastsavedpos]),0); + Bsprintf(ud.savegame[lastsavedpos],"Auto"); + for(i=0;i<13;i++) + Bmemcpy(&ud.savegame[lastsavedpos][i+4],&tempbuf[i+3],sizeof(tempbuf[i+3])); + ud.savegame[lastsavedpos][Bstrlen(ud.savegame[lastsavedpos])] = '\0'; + OSD_Printf("Saving to slot %d\n",lastsavedpos); + + KB_FlushKeyboardQueue(); + + screencapt = 1; + displayrooms(myconnectindex,65536); + //savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100); + screencapt = 0; + if(ud.multimode > 1) + saveplayer(-1-(lastsavedpos)); + else saveplayer(lastsavedpos); + + break; + } + case CON_IFMOVE: + insptr++; + parseifelse(g_t[1] == *insptr); + break; + case CON_RESETPLAYER: + { + insptr++; + + //AddLog("resetplayer"); + if(ud.multimode < 2) + { + if( lastsavedpos >= 0 && ud.recstat != 2 ) + { + ps[g_p].gm = MODE_MENU; + KB_ClearKeyDown(sc_Space); + cmenu(15000); + } + else ps[g_p].gm = MODE_RESTART; + killit_flag = 2; + } + else + { + pickrandomspot(g_p); + g_sp->x = hittype[g_i].bposx = ps[g_p].bobposx = ps[g_p].oposx = ps[g_p].posx; + g_sp->y = hittype[g_i].bposy = ps[g_p].bobposy = ps[g_p].oposy =ps[g_p].posy; + g_sp->z = hittype[g_i].bposy = ps[g_p].oposz =ps[g_p].posz; + updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum); + setsprite(ps[g_p].i,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+PHEIGHT); + g_sp->cstat = 257; + + g_sp->shade = -12; + g_sp->clipdist = 64; + g_sp->xrepeat = 42; + g_sp->yrepeat = 36; + g_sp->owner = g_i; + g_sp->xoffset = 0; + g_sp->pal = ps[g_p].palookup; + + ps[g_p].last_extra = g_sp->extra = max_player_health; + ps[g_p].wantweaponfire = -1; + ps[g_p].horiz = 100; + ps[g_p].on_crane = -1; + ps[g_p].frag_ps = g_p; + ps[g_p].horizoff = 0; + ps[g_p].opyoff = 0; + ps[g_p].wackedbyactor = -1; + ps[g_p].shield_amount = max_armour_amount; + ps[g_p].dead_flag = 0; + ps[g_p].pals_time = 0; + ps[g_p].footprintcount = 0; + ps[g_p].weapreccnt = 0; + ps[g_p].fta = 0; + ps[g_p].ftq = 0; + ps[g_p].posxv = ps[g_p].posyv = 0; + ps[g_p].rotscrnang = 0; + ps[g_p].runspeed = dukefriction; + ps[g_p].falling_counter = 0; + + hittype[g_i].extra = -1; + hittype[g_i].owner = g_i; + + hittype[g_i].cgg = 0; + hittype[g_i].movflag = 0; + hittype[g_i].tempang = 0; + hittype[g_i].actorstayput = -1; + hittype[g_i].dispicnum = 0; + hittype[g_i].owner = ps[g_p].i; + + resetinventory(g_p); + resetweapons(g_p); + + ps[g_p].reloading = 0; + + ps[g_p].movement_lock[1] = 0; + ps[g_p].movement_lock[2] = 0; + ps[g_p].movement_lock[3] = 0; + ps[g_p].movement_lock[4] = 0; + + OnEvent(EVENT_RESETPLAYER, ps[g_p].i, g_p, -1); + cameradist = 0; + cameraclock = totalclock; + } + setpal(&ps[g_p]); + //AddLog("EOF: resetplayer"); + } + break; + case CON_IFONWATER: + parseifelse( klabs(g_sp->z-sector[g_sp->sectnum].floorz) < (32<<8) && sector[g_sp->sectnum].lotag == 1); + break; + case CON_IFINWATER: + parseifelse( sector[g_sp->sectnum].lotag == 2); + break; + case CON_IFCOUNT: + insptr++; + parseifelse(g_t[0] >= *insptr); + break; + case CON_IFACTOR: + insptr++; + parseifelse(g_sp->picnum == *insptr); + break; + case CON_RESETCOUNT: + insptr++; + g_t[0] = 0; + break; + case CON_ADDINVENTORY: + insptr+=2; + switch(*(insptr-1)) + { + case GET_STEROIDS: + ps[g_p].steroids_amount = *insptr; + ps[g_p].inven_icon = 2; + break; + case GET_SHIELD: + ps[g_p].shield_amount += *insptr;// 100; + if(ps[g_p].shield_amount > max_player_health) + ps[g_p].shield_amount = max_player_health; + break; + case GET_SCUBA: + ps[g_p].scuba_amount = *insptr;// 1600; + ps[g_p].inven_icon = 6; + break; + case GET_HOLODUKE: + ps[g_p].holoduke_amount = *insptr;// 1600; + ps[g_p].inven_icon = 3; + break; + case GET_JETPACK: + ps[g_p].jetpack_amount = *insptr;// 1600; + ps[g_p].inven_icon = 4; + break; + case GET_ACCESS: + switch(g_sp->pal) + { + case 0: ps[g_p].got_access |= 1;break; + case 21: ps[g_p].got_access |= 2;break; + case 23: ps[g_p].got_access |= 4;break; + } + break; + case GET_HEATS: + ps[g_p].heat_amount = *insptr; + ps[g_p].inven_icon = 5; + break; + case GET_FIRSTAID: + ps[g_p].inven_icon = 1; + ps[g_p].firstaid_amount = *insptr; + break; + case GET_BOOTS: + ps[g_p].inven_icon = 7; + ps[g_p].boot_amount = *insptr; + break; + } + insptr++; + break; + case CON_HITRADIUS: + hitradius(g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5)); + insptr+=6; + break; + case CON_IFP: + { + insptr++; + + l = *insptr; + j = 0; + + s = g_sp->xvel; + + if( (l&8) && ps[g_p].on_ground && (sync[g_p].bits&2) ) + j = 1; + else if( (l&16) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground && + ps[g_p].poszv > 2048 ) + j = 1; + else if( (l&32) && ps[g_p].jumping_counter > 348 ) + j = 1; + else if( (l&1) && s >= 0 && s < 8) + j = 1; + else if( (l&2) && s >= 8 && !(sync[g_p].bits&(1<<5)) ) + j = 1; + else if( (l&4) && s >= 8 && sync[g_p].bits&(1<<5) ) + j = 1; + else if( (l&64) && ps[g_p].posz < (g_sp->z-(48<<8)) ) + j = 1; + else if( (l&128) && s <= -8 && !(sync[g_p].bits&(1<<5)) ) + j = 1; + else if( (l&256) && s <= -8 && (sync[g_p].bits&(1<<5)) ) + j = 1; + else if( (l&512) && ( ps[g_p].quick_kick > 0 || ( ps[g_p].curr_weapon == KNEE_WEAPON && ps[g_p].kickback_pic > 0 ) ) ) + j = 1; + else if( (l&1024) && sprite[ps[g_p].i].xrepeat < 32 ) + j = 1; + else if( (l&2048) && ps[g_p].jetpack_on ) + j = 1; + else if( (l&4096) && ps[g_p].steroids_amount > 0 && ps[g_p].steroids_amount < 400 ) + j = 1; + else if( (l&8192) && ps[g_p].on_ground) + j = 1; + else if( (l&16384) && sprite[ps[g_p].i].xrepeat > 32 && sprite[ps[g_p].i].extra > 0 && ps[g_p].timebeforeexit == 0 ) + j = 1; + else if( (l&32768) && sprite[ps[g_p].i].extra <= 0) + j = 1; + else if( (l&65536L) ) + { + if(g_sp->picnum == APLAYER && ud.multimode > 1) + j = getincangle(ps[otherp].ang,getangle(ps[g_p].posx-ps[otherp].posx,ps[g_p].posy-ps[otherp].posy)); + else + j = getincangle(ps[g_p].ang,getangle(g_sp->x-ps[g_p].posx,g_sp->y-ps[g_p].posy)); + + if( j > -128 && j < 128 ) + j = 1; + else + j = 0; + } + + parseifelse((long) j); + + } + break; + case CON_IFSTRENGTH: + insptr++; + parseifelse(g_sp->extra <= *insptr); + break; + case CON_GUTS: + insptr += 2; + guts(g_sp,*(insptr-1),*insptr,g_p); + insptr++; + break; + case CON_IFSPAWNEDBY: + insptr++; + // if(g_sp->owner >= 0 && sprite[g_sp->owner].picnum == *insptr) + // parseifelse(1); + // else + parseifelse( hittype[g_i].picnum == *insptr); + break; + case CON_WACKPLAYER: + insptr++; + forceplayerangle(&ps[g_p]); + return 0; + case CON_FLASH: + insptr++; + sprite[g_i].shade = -127; + ps[g_p].visibility = -127; + lastvisinc = totalclock+32; + return 0; + case CON_STOPALLSOUNDS: + insptr++; + if (screenpeek == g_p) + FX_StopAllSounds(); + return 0; + case CON_IFGAPZL: + insptr++; + parseifelse( (( hittype[g_i].floorz - hittype[g_i].ceilingz ) >> 8 ) < *insptr); + break; + case CON_IFHITSPACE: + parseifelse( sync[g_p].bits&(1<<29)); + break; + case CON_IFOUTSIDE: + parseifelse(sector[g_sp->sectnum].ceilingstat&1); + break; + case CON_IFMULTIPLAYER: + parseifelse(ud.multimode > 1); + break; + case CON_OPERATE: + insptr++; + if( sector[g_sp->sectnum].lotag == 0 ) + { + neartag(g_sp->x,g_sp->y,g_sp->z-(32<<8),g_sp->sectnum,g_sp->ang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,768L,1); + if( neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag) ) + if( (sector[neartagsector].lotag&0xff) == 23 || sector[neartagsector].floorz == sector[neartagsector].ceilingz ) + if( (sector[neartagsector].lotag&16384) == 0 ) + if( (sector[neartagsector].lotag&32768) == 0 ) + { + j = headspritesect[neartagsector]; + while(j >= 0) + { + if(sprite[j].picnum == ACTIVATOR) + break; + j = nextspritesect[j]; + } + if(j == -1) + operatesectors(neartagsector,g_i); + } + } + break; + case CON_IFINSPACE: + parseifelse(ceilingspace(g_sp->sectnum)); + break; + case CON_SPRITEPAL: + insptr++; + if(g_sp->picnum != APLAYER) + hittype[g_i].tempang = g_sp->pal; + g_sp->pal = *insptr++; + break; + case CON_CACTOR: + insptr++; + g_sp->picnum = *insptr++; + break; + case CON_IFBULLETNEAR: + parseifelse( dodge(g_sp) == 1); + break; + case CON_IFRESPAWN: + if( badguy(g_sp) ) + parseifelse( ud.respawn_monsters ); + else if( inventory(g_sp) ) + parseifelse( ud.respawn_inventory ); + else + parseifelse( ud.respawn_items ); + break; + case CON_IFFLOORDISTL: + insptr++; + // getglobalz(g_i); + parseifelse( (hittype[g_i].floorz - g_sp->z) <= ((*insptr)<<8)); + break; + case CON_IFCEILINGDISTL: + insptr++; + // getglobalz(g_i); + parseifelse( ( g_sp->z - hittype[g_i].ceilingz ) <= ((*insptr)<<8)); + break; + case CON_PALFROM: + insptr++; + ps[g_p].pals_time = *insptr++; + for(j=0;j<3;j++) + { + ps[g_p].pals[j] = *insptr++; + } + break; + + case CON_DYNQUOTE: + { + long var1, var2, var3, var4; + insptr++; + Bstrcpy(tempbuf,fta_quotes[*insptr++]); + var1 = GetGameVarID(*insptr++, g_i, g_p); + var2 = GetGameVarID(*insptr++, g_i, g_p); + var3 = GetGameVarID(*insptr++, g_i, g_p); + var4 = GetGameVarID(*insptr++, g_i, g_p); + Bsprintf(fta_quotes[122],tempbuf,var1,var2,var3,var4); + FTA(122,&ps[g_p]); + break; + } + + /* case 74: + insptr++; + getglobalz(g_i); + parseifelse( (( hittype[g_i].floorz - hittype[g_i].ceilingz ) >> 8 ) >= *insptr); + break; + */ + + + case CON_ADDLOG: + { + long l; + insptr++; + l=*insptr++; // var + Bsprintf(g_szBuf,"CONLOG: L=%ld",l); + AddLog(g_szBuf); + break; + } + case CON_ADDLOGVAR: + { + long l,m=1,lVarID; + char szBuf[256]; + insptr++; + l=*insptr++; // l=Line number, *instpr=varID + + lVarID = *insptr; + if( (lVarID >= iGameVarCount) || lVarID < 0) + { + if(*insptr==MAXGAMEVARS) // addlogvar for a constant? Har. + insptr++; + else if(*insptr&(MAXGAMEVARS<<1)) + { + m = -1; + lVarID ^= (MAXGAMEVARS<<1); + goto good; + } + // invalid varID + insptr++; + Bsprintf(g_szBuf,"CONLOGVAR: L=%ld INVALID VARIABLE",l); + AddLog(g_szBuf); + break; // out of switch + } +good: + Bsprintf(szBuf,"CONLOGVAR: L=%ld %s ",l, aGameVars[lVarID].szLabel); + strcpy(g_szBuf,szBuf); + + if( aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_READONLY) + { + Bsprintf(szBuf," (read-only)"); + strcat(g_szBuf,szBuf); + } + if( aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_PERPLAYER) + { + Bsprintf(szBuf," (Per Player. Player=%d)",g_p); + } + else if( aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_PERACTOR) + { + Bsprintf(szBuf," (Per Actor. Actor=%d)",g_i); + } + else + { + Bsprintf(szBuf," (Global)"); + } + strcat(g_szBuf,szBuf); + Bsprintf(szBuf," =%ld", GetGameVarID(lVarID, g_i, g_p)*m); + strcat(g_szBuf,szBuf); + AddLog(g_szBuf); + insptr++; + break; + } + + case CON_SETSECTOR: + case CON_GETSECTOR: + { + // syntax [gs]etsector[].x + // + long lLabelID; + long lVar1, lVar2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + lVar2=*insptr++; + DoSector(tw==CON_SETSECTOR, lVar1, lLabelID, lVar2, g_i, g_p); + break; + } + case CON_SQRT: + { + // syntax sqrt + + long lInVarID; + long lOutVarID; + long lIn; + + insptr++; + lInVarID=*insptr++; + lOutVarID=*insptr++; + lIn=GetGameVarID(lInVarID, g_i, g_p); + SetGameVarID(lOutVarID, ksqrt(lIn), g_i, g_p); + break; + } + case CON_FINDNEARACTOR: + case CON_FINDNEARSPRITE: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + long lType; + long lMaxDist; + long lVarID; + long lTemp; + long lFound; + long lDist; + short j, k; + + insptr++; + + lType=*insptr++; + lMaxDist=*insptr++; + lVarID=*insptr++; + + lFound=-1; + lDist=32767; // big number + + for (k=0;k=0) + { + if(sprite[j].picnum == lType && j != g_i) + { + lTemp=ldist(&sprite[g_i], &sprite[j]); + if( lTemp < lMaxDist ) + { + if (lTemp < lDist) + { + lFound=j; + j = MAXSPRITES; + break; + } + } + } + j = nextspritestat[j]; + } + if(tw==CON_FINDNEARACTOR || j == MAXSPRITES) + break; + } + SetGameVarID(lVarID, lFound, g_i, g_p); + break; + } + + case CON_FINDNEARACTORVAR: + case CON_FINDNEARSPRITEVAR: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + long lType; + long lMaxDistVar; + long lMaxDist; + long lVarID; + long lTemp; + long lFound; + long lDist; + short j, k; + + insptr++; + + lType=*insptr++; + lMaxDistVar=*insptr++; + lVarID=*insptr++; + lMaxDist=GetGameVarID(lMaxDistVar, g_i, g_p); + lFound=-1; + lDist=32767; // big number + + for (k=0;k=0) + { + if(sprite[j].picnum == lType && j != g_i) + { + lTemp=ldist(&sprite[g_i], &sprite[j]); + if( lTemp < lMaxDist ) + { + if (lTemp < lDist) + { + lFound=j; + j = MAXSPRITES; + break; + } + } + } + j = nextspritestat[j]; + } + if(tw==CON_FINDNEARACTORVAR || j == MAXSPRITES) + break; + } + SetGameVarID(lVarID, lFound, g_i, g_p); + break; + } + + case CON_FINDPLAYER: + case CON_FINDOTHERPLAYER: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + short j=0; + long var1, d; + + insptr++; + var1 = *insptr++; + + if (tw == CON_FINDPLAYER) j=findplayer(&sprite[g_i],&d); + else if (tw == CON_FINDOTHERPLAYER) j=findotherplayer(g_i,&d); + + SetGameVarID(g_iReturnVarID, j, g_i, g_p); + SetGameVarID(var1, d, g_i, g_p); + + break; + } + + + case CON_FINDNEARACTOR3DVAR: + case CON_FINDNEARSPRITE3DVAR: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + long lType; + long lMaxDistVar; + long lMaxZDistVar; + long lMaxDist; + long lMaxZDist; + long lVarID; + long lTemp; + long lTemp2; + long lFound; + long lDist; + short j, k; + + insptr++; + + lType=*insptr++; + lMaxDistVar=*insptr++; + lMaxZDistVar=*insptr++; + lVarID=*insptr++; + lMaxDist=GetGameVarID(lMaxDistVar, g_i, g_p); + lMaxZDist=GetGameVarID(lMaxZDistVar, g_i, g_p); + lFound=-1; + lDist=32767; // big number + + for (k=0;k=0) + { + if(sprite[j].picnum == lType && j != g_i) + { + lTemp=ldist(&sprite[g_i], &sprite[j]); + lTemp2=txdist(&sprite[g_i], &sprite[j]); + if( (lTemp < lMaxDist) && (lTemp2 < lMaxZDist) ) + { + if (lTemp < lDist) + { + lFound=j; + j = MAXSPRITES; + break; + } + } + } + j = nextspritestat[j]; + } + if(tw==CON_FINDNEARACTOR3DVAR || j == MAXSPRITES) + break; + } + SetGameVarID(lVarID, lFound, g_i, g_p); + + break; + } + + case CON_FINDNEARACTOR3D: + case CON_FINDNEARSPRITE3D: + { + // syntax findnearactorvar + // gets the sprite ID of the nearest actor within max dist + // that is of into + // -1 for none found + // + long lType; + long lMaxDist; + long lMaxZDist; + long lVarID; + long lTemp; + long lTemp2; + long lFound; + long lDist; + short j, k; + + insptr++; + + lType=*insptr++; + lMaxDist=*insptr++; + lMaxZDist=*insptr++; + lVarID=*insptr++; + + lFound=-1; + lDist=32767; // big number + + for (k=0;k=0) + { + if(sprite[j].picnum == lType && j != g_i) + { + lTemp=ldist(&sprite[g_i], &sprite[j]); + lTemp2=txdist(&sprite[g_i], &sprite[j]); + if( (lTemp < lMaxDist) && (lTemp2 < lMaxZDist) ) + { + if (lTemp < lDist) + { + lFound=j; + j = MAXSPRITES; + break; + } + } + } + j = nextspritestat[j]; + } + if(tw==CON_FINDNEARACTOR3DVAR || j == MAXSPRITES) + break; + } + SetGameVarID(lVarID, lFound, g_i, g_p); + break; + } + + case CON_SETPLAYER: + case CON_GETPLAYER: + { + // syntax [gs]etplayer[].x + // + long lLabelID; + long lVar1, lVar2; + long lParm2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + // HACK: need to have access to labels structure at run-time... + + switch(lLabelID) + { + case PLAYER_AMMO_AMOUNT: + case PLAYER_GOTWEAPON: + case PLAYER_PALS: + case PLAYER_MOVEMENT_LOCK: + case PLAYER_LOOGIEX: + case PLAYER_LOOGIEY: + lParm2=GetGameVarID(*insptr++, g_i, g_p); + break; + default: + lParm2=0; + break; + } + lVar2=*insptr++; + + DoPlayer(tw==CON_SETPLAYER, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + + case CON_SETINPUT: + case CON_GETINPUT: + { + // syntax [gs]etplayer[].x + // + long lLabelID; + long lVar1, lVar2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + + lVar2=*insptr++; + + DoInput(tw==CON_SETINPUT, lVar1, lLabelID, lVar2, g_i, g_p); + break; + } + + case CON_GETUSERDEF: + case CON_SETUSERDEF: + { + // syntax [gs]etuserdef.xxx + // + long lLabelID; + long lVar1, lVar2; + long lParm2=0; + + insptr++; + lVar1=-1; + lLabelID=*insptr++; + lVar2=*insptr++; + + DoUserDef(tw==CON_SETUSERDEF, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + case CON_GETPROJECTILE: + case CON_SETPROJECTILE: + { + // syntax [gs]etplayer[].x + // + long lLabelID; + long lVar1, lVar2; + long lParm2; + + insptr++; + lVar1=GetGameVarID(*insptr++, g_i, g_p); + lLabelID=*insptr++; + lVar2=*insptr++; + DoProjectile(tw==CON_SETPROJECTILE,lVar1,lLabelID,lVar2,g_i,g_p); + + break; + } + + + case CON_SETWALL: + case CON_GETWALL: + { + // syntax [gs]etwall[].x + // + long lLabelID; + long lVar1, lVar2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + lVar2=*insptr++; + + DoWall(tw==CON_SETWALL, lVar1, lLabelID, lVar2, g_i, g_p); + break; + } + case CON_SETACTORVAR: + case CON_GETACTORVAR: + { + // syntax [gs]etactorvar[]. + // gets the value of the per-actor variable varx into VAR + // + long lVar1, lVar2, lVar3; + long lTemp,lSprite; + + insptr++; + + lVar1=*insptr++; + lVar2=*insptr++; + lVar3=*insptr++; + + lSprite=GetGameVarID(lVar1, g_i, g_p); + if(lSprite >= 0) + { + switch(tw) + { + case CON_SETACTORVAR: + lTemp=GetGameVarID(lVar3, g_i, g_p); + SetGameVarID(lVar2, lTemp, lSprite, g_p); + break; + case CON_GETACTORVAR: + lTemp=GetGameVarID(lVar2, lSprite, g_p); + SetGameVarID(lVar3, lTemp, g_i, g_p); + break; + } + } + break; + } + + case CON_SETPLAYERVAR: + case CON_GETPLAYERVAR: + { + // syntax [gs]etactorvar[]. + // gets the value of the per-actor variable varx into VAR + // + long lVar1, lVar2, lVar3; + long lTemp,lSprite; + + insptr++; + + lVar1=*insptr++; + lVar2=*insptr++; + lVar3=*insptr++; + + lSprite=GetGameVarID(lVar1, g_i, g_p); + if(lSprite >= 0) + { + switch(tw) + { + case CON_SETPLAYERVAR: + lTemp=GetGameVarID(lVar3, g_i, g_p); + SetGameVarID(lVar2, lTemp, g_i, lSprite); + break; + case CON_GETPLAYERVAR: + lTemp=GetGameVarID(lVar2, g_i, lSprite); + SetGameVarID(lVar3, lTemp, g_i, g_p); + break; + } + } + break; + } + + case CON_SETACTOR: + case CON_GETACTOR: + { + // syntax [gs]etactor[].x + // + long lLabelID; + long lVar1, lVar2; + long lParm2; + + insptr++; + lVar1=*insptr++; + lLabelID=*insptr++; + + switch(lLabelID) + { + case ACTOR_HTG_T: + lParm2=GetGameVarID(*insptr++, g_i, g_p); + break; + default: + lParm2=0; + break; + } + lVar2=*insptr++; + + DoActor(tw==CON_SETACTOR, lVar1, lLabelID, lVar2, g_i, g_p, lParm2); + break; + } + case CON_GETANGLETOTARGET: + { + int i; + short ang; + + insptr++; + i=*insptr++; // ID of def + + // hittype[g_i].lastvx and lastvy are last known location of target. + ang=getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y); + SetGameVarID(i, ang, g_i, g_p ); + break; + } + case CON_ANGOFFVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + spriteext[g_i].angoff=GetGameVarID(i, g_i, g_p); + break; + } + case CON_LOCKPLAYER: + { + int i; + insptr++; + i=*insptr++; // ID of def + ps[g_p].transporter_hold=GetGameVarID(i, g_i, g_p); + break; + } + case CON_CHECKAVAILWEAPON: + case CON_CHECKAVAILINVEN: + { + int i; + + insptr++; + + if (*insptr == g_iThisActorID) + { + i = g_p; + insptr++; + } + else + i=GetGameVarID(*insptr++, g_i, g_p); + if (i < MAXPLAYERS) + { + if (tw == CON_CHECKAVAILWEAPON) + checkavailweapon(&ps[i]); + else checkavailinven(&ps[i]); + } + break; + } + case CON_GETPLAYERANGLE: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, ps[g_p].ang, g_i, g_p ); + break; + } + case CON_SETPLAYERANGLE: + { + int i; + insptr++; + i=*insptr++; // ID of def + ps[g_p].ang=GetGameVarID(i, g_i, g_p); + ps[g_p].ang &= 2047; + break; + } + case CON_GETACTORANGLE: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, g_sp->ang, g_i, g_p ); + break; + } + case CON_SETACTORANGLE: + { + int i; + insptr++; + i=*insptr++; // ID of def + g_sp->ang=GetGameVarID(i, g_i, g_p); + g_sp->ang &= 2047; + break; + } + case CON_SETVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, *insptr++, g_i, g_p ); + break; + } + case CON_SETVARVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(*insptr++, g_i, g_p), g_i, g_p ); + break; + } + + case CON_RANDVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, mulscale(krand(), *insptr++, 16), g_i, g_p ); + break; + } + case CON_DISPLAYRANDVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, mulscale(rand(), *insptr++, 15), g_i, g_p ); + break; + } + case CON_MULVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) * *insptr++, g_i, g_p ); + break; + } + + case CON_DIVVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + if( (*insptr) == 0 ) + { + gameexit("CON_DIVVAR: Divide by zero."); + } + SetGameVarID(i, GetGameVarID(i, g_i, g_p) / *insptr++, g_i, g_p ); + break; + } + case CON_MODVAR: + { + int i; + long l; + long lResult; + insptr++; + i=*insptr++; // ID of def + l=*insptr++; + if( l == 0 ) + { + gameexit("CON_MODVAR: Mod by zero."); + } + lResult=GetGameVarID(i, g_i, g_p) % l; + SetGameVarID(i, lResult, g_i, g_p ); + break; + } + case CON_ANDVAR: + { + int i; + long l; + long lResult; + insptr++; + i=*insptr++; // ID of def + l=*insptr++; + lResult=GetGameVarID(i, g_i, g_p) & l; + SetGameVarID(i, lResult, g_i, g_p ); + break; + } + case CON_ORVAR: + { + int i; + long l; + long lResult; + insptr++; + i=*insptr++; // ID of def + l=*insptr++; + lResult=GetGameVarID(i, g_i, g_p) | l; + SetGameVarID(i, lResult, g_i, g_p ); + break; + } + case CON_XORVAR: + { + int i; + long l; + long lResult; + insptr++; + i=*insptr++; // ID of def + l=*insptr++; + lResult=GetGameVarID(i, g_i, g_p) ^ l; + SetGameVarID(i, lResult, g_i, g_p ); + break; + } + + case CON_RANDVARVAR: + { + int i; + long l1; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(*insptr++, g_i, g_p); + lResult=mulscale(krand(), l1+1, 16); + SetGameVarID(i, lResult , g_i, g_p ); + break; + } + + case CON_DISPLAYRANDVARVAR: + { + int i; + long l1; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(*insptr++, g_i, g_p); + lResult=mulscale(rand(), l1+1, 15); + SetGameVarID(i, lResult , g_i, g_p ); + break; + } + + case CON_GMAXAMMO: + { + int i; + long l1; // l2; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + lResult=max_ammo_amount[l1]; + SetGameVarID(*insptr++, lResult , g_i, g_p ); + break; + } + + case CON_SMAXAMMO: + { + int i; + long l1,l2; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + max_ammo_amount[l1]=l2; + break; + } + + case CON_MULVARVAR: + { + int i; + long l1,l2; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + lResult=l1*l2; + SetGameVarID(i, lResult , g_i, g_p ); + break; + } + case CON_DIVVARVAR: + { + int i; + long l1,l2; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr++, g_i, g_p); + if(l2==0) + { + gameexit("CON_DIVVARVAR: Divide by zero."); + } + lResult=l1/l2; + SetGameVarID(i, lResult , g_i, g_p ); + break; + } + case CON_MODVARVAR: + { + int i; + long l1,l2; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr, g_i, g_p); + if(l2==0) + { + gameexit("CON_MODVARVAR: Mod by zero."); + } + lResult=l1 % l2; + SetGameVarID(i, lResult , g_i, g_p ); + insptr++; + break; + } + case CON_ANDVARVAR: + { + int i; + long l1,l2; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr, g_i, g_p); + lResult=l1 & l2; + SetGameVarID(i, lResult , g_i, g_p ); + insptr++; + break; + } + case CON_XORVARVAR: + { + int i; + long l1,l2; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr, g_i, g_p); + lResult=l1 ^ l2; + SetGameVarID(i, lResult , g_i, g_p ); + insptr++; + break; + } + case CON_ORVARVAR: + { + int i; + long l1,l2; + long lResult; + insptr++; + i=*insptr++; // ID of def + l1=GetGameVarID(i, g_i, g_p); + l2=GetGameVarID(*insptr, g_i, g_p); + lResult=l1 | l2; + SetGameVarID(i, lResult , g_i, g_p ); + insptr++; + break; + } + case CON_SUBVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) - *insptr, g_i, g_p ); + insptr++; + break; + } + case CON_SUBVARVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) - GetGameVarID(*insptr, g_i, g_p), g_i, g_p ); + insptr++; + break; + } + case CON_ADDVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + //Bsprintf(g_szBuf,"AddVar %d to Var ID=%d, g_i=%d, g_p=%d\n",*insptr, i, g_i, g_p); + //AddLog(g_szBuf); + SetGameVarID(i, GetGameVarID(i, g_i, g_p) + *insptr, g_i, g_p ); + insptr++; + break; + } + case CON_SHIFTVARL: + { + int i; + insptr++; + i=*insptr++; // ID of def + //Bsprintf(g_szBuf,"AddVar %d to Var ID=%d, g_i=%d, g_p=%d\n",*insptr, i, g_i, g_p); + //AddLog(g_szBuf); + SetGameVarID(i, GetGameVarID(i, g_i, g_p) << *insptr, g_i, g_p ); + insptr++; + break; + } + + case CON_SHIFTVARR: + { + int i; + insptr++; + i=*insptr++; // ID of def + //Bsprintf(g_szBuf,"AddVar %d to Var ID=%d, g_i=%d, g_p=%d\n",*insptr, i, g_i, g_p); + //AddLog(g_szBuf); + SetGameVarID(i, GetGameVarID(i, g_i, g_p) >> *insptr, g_i, g_p ); + insptr++; + break; + } + + + case CON_SIN: + { + int i; + long lValue; + insptr++; + i=*insptr++; // ID of def + lValue=GetGameVarID(*insptr, g_i, g_p); + lValue=sintable[lValue&2047]; + SetGameVarID(i, lValue , g_i, g_p ); + insptr++; + break; + } + case CON_COS: + { + int i; + long lValue; + insptr++; + i=*insptr++; // ID of def + lValue=GetGameVarID(*insptr, g_i, g_p); + // propiedad trigonometrica con el seno para hallar coseno: cos = sqrt(1-sen^2) + // I don't know anything about sin/cos, and I don't know anything about foreign languages, either. :( + lValue=sintable[(lValue+512)&2047]; + SetGameVarID(i, lValue , g_i, g_p ); + insptr++; + break; + } + case CON_ADDVARVAR: + { + int i; + insptr++; + i=*insptr++; // ID of def + SetGameVarID(i, GetGameVarID(i, g_i, g_p) + GetGameVarID(*insptr, g_i, g_p), g_i, g_p ); + insptr++; + break; + } + case CON_SPGETLOTAG: + { + insptr++; + SetGameVarID(g_iLoTagID, g_sp->lotag, g_i, g_p); + break; + } + case CON_SPGETHITAG: + { + insptr++; + SetGameVarID(g_iHiTagID, g_sp->hitag, g_i, g_p); + break; + } + case CON_SECTGETLOTAG: + { + insptr++; + SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p); + break; + } + case CON_SECTGETHITAG: + { + insptr++; + SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p); + break; + } + case CON_GETTEXTUREFLOOR: + { + insptr++; + SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p); + break; + } + case CON_STARTTRACK: + { + insptr++; + music_select=*insptr++; + playmusic(&music_fn[ud.volume_number][music_select][0]); + break; + } + case CON_GETTEXTURECEILING: + { + insptr++; + SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p); + break; + } + case CON_IFVARVARAND: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) & GetGameVarID(*(insptr), g_i, g_p) ) + { + j=1; + } + parseifelse( j ); + break; + } + case CON_IFVARVARN: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) != GetGameVarID(*(insptr), g_i, g_p) ) + { + j=1; + } + parseifelse( j ); + break; + } + case CON_IFVARVARE: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) == GetGameVarID(*(insptr), g_i, g_p) ) + { + j=1; + } + parseifelse( j ); + break; + } + case CON_IFVARVARG: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) > GetGameVarID(*(insptr), g_i, g_p) ) + { + j=1; + } + parseifelse( j ); + break; + } + case CON_IFVARVARL: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) < GetGameVarID(*(insptr), g_i, g_p) ) + { + j=1; + } + parseifelse( j ); + break; + } + case CON_IFVARE: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) == *insptr) + { + j=1; + } + parseifelse( j ); + break; + } + case CON_IFVARN: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) != *insptr) + { + j=1; + } + parseifelse( j ); + break; + } + case CON_WHILEVARN: + { + int i; + long *savedinsptr; + savedinsptr=insptr; + j=1; + while (j) + { + insptr=savedinsptr; + insptr++; + i=*insptr++; // ID of def + j=0; + + if(GetGameVarID(i, g_i, g_p) != *insptr) + { + j=1; + } + parseifelse( j ); + } + break; + } + case CON_WHILEVARVARN: + { + int i,k; + long *savedinsptr; + savedinsptr=insptr; + j=1; + while (j) + { + insptr=savedinsptr; + insptr++; + i=*insptr++; // ID of def + k=*(insptr); // ID of def + j=0; + + if(GetGameVarID(i, g_i, g_p) != GetGameVarID(k, g_i, g_p)) + { + j=1; + } + parseifelse( j ); + } + break; + } + case CON_IFVARAND: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) & *insptr) + { + j=1; + } + parseifelse( j ); + break; + } + case CON_IFVARG: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) > *insptr) + { + j=1; + } + parseifelse( j ); + break; + } + case CON_IFVARL: + { + int i; + insptr++; + i=*insptr++; // ID of def + j=0; + if(GetGameVarID(i, g_i, g_p) < *insptr) + { + j=1; + } + parseifelse( j ); + break; + } + + case CON_IFPHEALTHL: + insptr++; + parseifelse( sprite[ps[g_p].i].extra < *insptr); + break; + + case CON_IFPINVENTORY: + { + insptr++; + j = 0; + switch(*insptr++) + { + case GET_STEROIDS:if( ps[g_p].steroids_amount != *insptr) + j = 1; + break; + case GET_SHIELD:if(ps[g_p].shield_amount != max_player_health ) + j = 1; + break; + case GET_SCUBA:if(ps[g_p].scuba_amount != *insptr) j = 1;break; + case GET_HOLODUKE:if(ps[g_p].holoduke_amount != *insptr) j = 1;break; + case GET_JETPACK:if(ps[g_p].jetpack_amount != *insptr) j = 1;break; + case GET_ACCESS: + switch(g_sp->pal) + { + case 0: if(ps[g_p].got_access&1) j = 1;break; + case 21: if(ps[g_p].got_access&2) j = 1;break; + case 23: if(ps[g_p].got_access&4) j = 1;break; + } + break; + case GET_HEATS:if(ps[g_p].heat_amount != *insptr) j = 1;break; + case GET_FIRSTAID: + if(ps[g_p].firstaid_amount != *insptr) j = 1;break; + case GET_BOOTS: + if(ps[g_p].boot_amount != *insptr) j = 1;break; + } + + parseifelse(j); + break; + } + case CON_PSTOMP: + insptr++; + if( ps[g_p].knee_incs == 0 && sprite[ps[g_p].i].xrepeat >= 40 ) + if( cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+(16<<8),sprite[ps[g_p].i].sectnum) ) + { + ps[g_p].knee_incs = 1; + if(ps[g_p].weapon_pos == 0) + ps[g_p].weapon_pos = -1; + ps[g_p].actorsqu = g_i; + } + break; + case CON_IFAWAYFROMWALL: + { + short s1; + + s1 = g_sp->sectnum; + + j = 0; + + updatesector(g_sp->x+108,g_sp->y+108,&s1); + if( s1 == g_sp->sectnum ) + { + updatesector(g_sp->x-108,g_sp->y-108,&s1); + if( s1 == g_sp->sectnum ) + { + updatesector(g_sp->x+108,g_sp->y-108,&s1); + if( s1 == g_sp->sectnum ) + { + updatesector(g_sp->x-108,g_sp->y+108,&s1); + if( s1 == g_sp->sectnum ) + j = 1; + } + } + } + parseifelse( j ); + } + + break; + case CON_QUOTE: + insptr++; + FTA(*insptr,&ps[g_p]); + insptr++; + break; + case CON_USERQUOTE: + insptr++; + adduserquote(fta_quotes[*insptr]); + insptr++; + break; + case CON_IFINOUTERSPACE: + parseifelse( floorspace(g_sp->sectnum)); + break; + case CON_IFNOTMOVING: + parseifelse( (hittype[g_i].movflag&49152) > 16384 ); + break; + case CON_RESPAWNHITAG: + insptr++; + switch(dynamictostatic[g_sp->picnum]) + { + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case PODFEM1__STATIC: + case NAKED1__STATIC: + case STATUE__STATIC: + if(g_sp->yvel) operaterespawns(g_sp->yvel); + break; + default: + if(g_sp->hitag >= 0) operaterespawns(g_sp->hitag); + break; + } + break; + case CON_IFSPRITEPAL: + insptr++; + parseifelse( g_sp->pal == *insptr); + break; + + case CON_IFANGDIFFL: + insptr++; + j = klabs(getincangle(ps[g_p].ang,g_sp->ang)); + parseifelse( j <= *insptr); + break; + + case CON_IFNOSOUNDS: + for(j=1;jpicnum] == 0 ) return; + + insptr = actorLoadEventScrptr[g_sp->picnum]; + + killit_flag = 0; + + if(g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS) + { + // if(badguy(g_sp)) + // ps[g_p].actors_killed++; + deletesprite(g_i); + return; + } + do + done = parse(); + while( done == 0 ); + + if(killit_flag == 1) + { + // if player was set to squish, first stop that... + if (g_p >= 0 ) + { + if(ps[g_p].actorsqu == g_i) + ps[g_p].actorsqu = -1; + } + deletesprite(g_i); + } +} + +void execute(short sActor,short sPlayer,long lDist) +{ + char done; + + g_i = sActor; // Sprite ID + g_p = sPlayer; // Player ID + g_x = lDist; // ?? + g_sp = &sprite[g_i]; // Pointer to sprite structure + g_t = &hittype[g_i].temp_data[0]; // Sprite's 'extra' data + + if( actorscrptr[g_sp->picnum] == 0 ) return; + + insptr = 4 + (actorscrptr[g_sp->picnum]); + + killit_flag = 0; + + if(g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS) + { + if(badguy(g_sp)) + ps[g_p].actors_killed++; + deletesprite(g_i); + return; + } + + if(g_t[4]) + { + g_sp->lotag += TICSPERFRAME; + + if(g_sp->lotag > *(long *)(g_t[4]+16) ) + { + g_t[2]++; + g_sp->lotag = 0; + g_t[3] += *(long *)( g_t[4]+12 ); + } + + if( klabs(g_t[3]) >= klabs( *(long *)(g_t[4]+4) * *(long *)(g_t[4]+12) ) ) + g_t[3] = 0; + } + + do + done = parse(); + while( done == 0 ); + + if(killit_flag == 1) + { + // if player was set to squish, first stop that... + if(ps[g_p].actorsqu == g_i) + ps[g_p].actorsqu = -1; + deletesprite(g_i); + } + else + { + move(); + + if( g_sp->statnum == 1) + { + if( badguy(g_sp) ) + { + if( g_sp->xrepeat > 60 ) return; + if( ud.respawn_monsters == 1 && g_sp->extra <= 0 ) return; + } + else if( ud.respawn_items == 1 && (g_sp->cstat&32768) ) return; + + if(hittype[g_i].timetosleep > 1) + hittype[g_i].timetosleep--; + else if(hittype[g_i].timetosleep == 1) + changespritestat(g_i,2); + } + + else if(g_sp->statnum == 6) + switch(dynamictostatic[g_sp->picnum]) + { + case RUBBERCAN__STATIC: + case EXPLODINGBARREL__STATIC: + case WOODENHORSE__STATIC: + case HORSEONSIDE__STATIC: + case CANWITHSOMETHING__STATIC: + case FIREBARREL__STATIC: + case NUKEBARREL__STATIC: + case NUKEBARRELDENTED__STATIC: + case NUKEBARRELLEAKED__STATIC: + case TRIPBOMB__STATIC: + case EGG__STATIC: + if(hittype[g_i].timetosleep > 1) + hittype[g_i].timetosleep--; + else if(hittype[g_i].timetosleep == 1) + changespritestat(g_i,2); + break; + } + } +} diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c new file mode 100644 index 000000000..5f71cc9ca --- /dev/null +++ b/polymer/eduke32/source/global.c @@ -0,0 +1,180 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "duke3d.h" + +char MusicPtr[72000*2]; + +short global_random; +short neartagsector, neartagwall, neartagsprite; + +long neartaghitdist,lockclock,max_player_health,max_armour_amount,max_ammo_amount[MAX_WEAPONS]; +// JBF: gc modified to default to Atomic ed. default when using 1.3d CONs +long gc=176; + +// long temp_data[MAXSPRITES][6]; +struct weaponhit hittype[MAXSPRITES]; +short spriteq[1024],spriteqloc,spriteqamount=64; +struct animwalltype animwall[MAXANIMWALLS]; +short numanimwalls; +long *animateptr[MAXANIMATES], animategoal[MAXANIMATES], animatevel[MAXANIMATES], animatecnt; +// long oanimateval[MAXANIMATES]; +short animatesect[MAXANIMATES]; +long msx[2048],msy[2048]; +short cyclers[MAXCYCLERS][6],numcyclers; + +char fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; + +char tempbuf[2048], packbuf[576]; + +char buf[1024]; + +short camsprite; +short mirrorwall[64], mirrorsector[64], mirrorcnt; + +int current_menu; + +char betaname[80]; + +char level_names[77][33],level_file_names[77][BMAX_PATH]; +long partime[77],designertime[77]; +char volume_names[7][33] = { "L.A. MELTDOWN", "LUNAR APOCALYPSE", "SHRAPNEL CITY" }; +char skill_names[5][33] = { "PIECE OF CAKE", "LET'S ROCK", "COME GET SOME", "DAMN I'M GOOD" }; + +char gametype_names[MAXGAMETYPES][33] = { "DUKEMATCH (SPAWN)","COOPERATIVE PLAY","DUKEMATCH (NO SPAWN)"}; +int gametype_flags[MAXGAMETYPES] = {4+8+16+1024+2048+16384,1+2+32+64+128+256+512+4096+8192+32768,2+4+8+16+16384}; +char num_gametypes = 3; + +long soundsiz[NUM_SOUNDS]; + +short soundps[NUM_SOUNDS],soundpe[NUM_SOUNDS],soundvo[NUM_SOUNDS]; +char soundm[NUM_SOUNDS],soundpr[NUM_SOUNDS]; +char sounds[NUM_SOUNDS][BMAX_PATH]; + +short title_zoom; + +char num_volumes = 3; + +short timer=120; +//fx_device device; + +SAMPLE Sound[ NUM_SOUNDS ]; +SOUNDOWNER SoundOwner[NUM_SOUNDS][4]; + +char numplayersprites,loadfromgrouponly=0,earthquaketime; + +long fricxv,fricyv; +struct player_orig po[MAXPLAYERS]; +struct player_struct ps[MAXPLAYERS]; +struct user_defs ud; + +char pus, pub; +char syncstat, syncval[MAXPLAYERS][MOVEFIFOSIZ]; +long syncvalhead[MAXPLAYERS], syncvaltail, syncvaltottail; + +input sync[MAXPLAYERS], loc; +input recsync[RECSYNCBUFSIZ]; +long avgfvel, avgsvel, avgavel, avghorz, avgbits, avgbits2; + + +input inputfifo[MOVEFIFOSIZ][MAXPLAYERS]; +input recsync[RECSYNCBUFSIZ]; + +long movefifosendplc; + +//Multiplayer syncing variables +short screenpeek; +long movefifoend[MAXPLAYERS]; + + +//Game recording variables + +char playerreadyflag[MAXPLAYERS],ready2send; +char playerquitflag[MAXPLAYERS]; +long vel, svel, angvel, horiz, ototalclock, respawnactortime=768, respawnitemtime=768, groupfile; + +long *scriptptr,*insptr,*labelcode,labelcnt,defaultlabelcnt,*labeltype; +long *actorscrptr[MAXTILES],*parsing_actor; +char *label,*textptr,error,warning,killit_flag; +char *music_pointer; +char actortype[MAXTILES]; +long script[MAXSCRIPTSIZE+16]; + +char display_mirror,typebuflen,typebuf[41]; + +char music_fn[8][11][13],music_select; +char env_music_fn[8][13]; +char rtsplaying; + + +short weaponsandammosprites[15] = { + RPGSPRITE__STATIC, + CHAINGUNSPRITE__STATIC, + DEVISTATORAMMO__STATIC, + RPGAMMO__STATIC, + RPGAMMO__STATIC, + JETPACK__STATIC, + SHIELD__STATIC, + FIRSTAID__STATIC, + STEROIDS__STATIC, + RPGAMMO__STATIC, + RPGAMMO__STATIC, + RPGSPRITE__STATIC, + RPGAMMO__STATIC, + FREEZESPRITE__STATIC, + FREEZEAMMO__STATIC + }; + +long impact_damage; +char condebug; + +//GLOBAL.C - replace the end "my's" with this +long myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; +short myhoriz, omyhoriz, myhorizoff, omyhorizoff; +short myang, omyang, mycursectnum, myjumpingcounter,frags[MAXPLAYERS][MAXPLAYERS]; + +char myjumpingtoggle, myonground, myhardlanding, myreturntocenter; +signed char multiwho, multipos, multiwhat, multiflag; + +long fakemovefifoplc,movefifoplc; +long myxbak[MOVEFIFOSIZ], myybak[MOVEFIFOSIZ], myzbak[MOVEFIFOSIZ]; +long myhorizbak[MOVEFIFOSIZ],dukefriction = 0xcc00, show_shareware; + +short myangbak[MOVEFIFOSIZ]; +char myname[32],camerashitable,freezerhurtowner=0,lasermode=0; +char networkmode = 255, movesperpacket = 1,gamequit = 0,everyothertime; +long numfreezebounces=3,rpgblastradius,pipebombblastradius,tripbombblastradius,shrinkerblastradius,morterblastradius,bouncemineblastradius,seenineblastradius; +STATUSBARTYPE sbar; + +long myminlag[MAXPLAYERS], mymaxlag, otherminlag, bufferjitter = 1; +short numclouds,clouds[128],cloudx[128],cloudy[128]; +long cloudtotalclock = 0,totalmemory = 0; +long numinterpolations = 0, startofdynamicinterpolations = 0; +long oldipos[MAXINTERPOLATIONS]; +long bakipos[MAXINTERPOLATIONS]; +long *curipos[MAXINTERPOLATIONS]; + +int nextvoxid = 0; + +int spriteflags[MAXTILES], actorspriteflags[MAXSPRITES]; + +char cheatkey[2] = { sc_D, sc_N }; diff --git a/polymer/eduke32/source/jaudiolib/_midi.h b/polymer/eduke32/source/jaudiolib/_midi.h new file mode 100644 index 000000000..b28edd216 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/_midi.h @@ -0,0 +1,281 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) + +*/ +/********************************************************************** + module: _MIDI.H + + author: James R. Dose + date: May 25, 1994 + + Private header for MIDI.C. Midi song file playback routines. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef ___MIDI_H +#define ___MIDI_H + +#define RELATIVE_BEAT( measure, beat, tick ) \ + ( ( tick ) + ( ( beat ) << 9 ) + ( ( measure ) << 16 ) ) + +//Bobby Prince thinks this may be 100 +//#define GENMIDI_DefaultVolume 100 +#define GENMIDI_DefaultVolume 90 + +#define MAX_FORMAT 1 + +#define NUM_MIDI_CHANNELS 16 + +#define TIME_PRECISION 16 + +#define MIDI_HEADER_SIGNATURE 0x6468544d // "MThd" +#define MIDI_TRACK_SIGNATURE 0x6b72544d // "MTrk" + +#define MIDI_VOLUME 7 +#define MIDI_PAN 10 +#define MIDI_DETUNE 94 +#define MIDI_RHYTHM_CHANNEL 9 +#define MIDI_RPN_MSB 100 +#define MIDI_RPN_LSB 101 +#define MIDI_DATAENTRY_MSB 6 +#define MIDI_DATAENTRY_LSB 38 +#define MIDI_PITCHBEND_MSB 0 +#define MIDI_PITCHBEND_LSB 0 +#define MIDI_RUNNING_STATUS 0x80 +#define MIDI_NOTE_OFF 0x8 +#define MIDI_NOTE_ON 0x9 +#define MIDI_POLY_AFTER_TCH 0xA +#define MIDI_CONTROL_CHANGE 0xB +#define MIDI_PROGRAM_CHANGE 0xC +#define MIDI_AFTER_TOUCH 0xD +#define MIDI_PITCH_BEND 0xE +#define MIDI_SPECIAL 0xF +#define MIDI_SYSEX 0xF0 +#define MIDI_SYSEX_CONTINUE 0xF7 +#define MIDI_META_EVENT 0xFF +#define MIDI_END_OF_TRACK 0x2F +#define MIDI_TEMPO_CHANGE 0x51 +#define MIDI_TIME_SIGNATURE 0x58 +#define MIDI_RESET_ALL_CONTROLLERS 0x79 +#define MIDI_ALL_NOTES_OFF 0x7b +#define MIDI_MONO_MODE_ON 0x7E +#define MIDI_SYSTEM_RESET 0xFF + +#define GET_NEXT_EVENT( track, data ) \ + ( data ) = *( track )->pos; \ + ( track )->pos += 1 + +#define GET_MIDI_CHANNEL( event ) ( ( event ) & 0xf ) +#define GET_MIDI_COMMAND( event ) ( ( event ) >> 4 ) + +#define EMIDI_INFINITE -1 +#define EMIDI_END_LOOP_VALUE 127 +#define EMIDI_ALL_CARDS 127 +#define EMIDI_INCLUDE_TRACK 110 +#define EMIDI_EXCLUDE_TRACK 111 +#define EMIDI_PROGRAM_CHANGE 112 +#define EMIDI_VOLUME_CHANGE 113 +#define EMIDI_CONTEXT_START 114 +#define EMIDI_CONTEXT_END 115 +#define EMIDI_LOOP_START 116 +#define EMIDI_LOOP_END 117 +#define EMIDI_SONG_LOOP_START 118 +#define EMIDI_SONG_LOOP_END 119 + +#define EMIDI_GeneralMIDI 0 + +#define EMIDI_AffectsCurrentCard( c, type ) \ + ( ( ( c ) == EMIDI_ALL_CARDS ) || ( ( c ) == ( type ) ) ) + + +#define EMIDI_NUM_CONTEXTS 7 +typedef struct + { + unsigned char *pos; + unsigned char *loopstart; + short loopcount; + short RunningStatus; + unsigned time; + long FPSecondsPerTick; + short tick; + short beat; + short measure; + short BeatsPerMeasure; + short TicksPerBeat; + short TimeBase; + long delay; + short active; + } songcontext; + +typedef struct + { + unsigned char *start; + unsigned char *pos; + + long delay; + short active; + short RunningStatus; + + short currentcontext; + songcontext context[ EMIDI_NUM_CONTEXTS ]; + + char EMIDI_IncludeTrack; + char EMIDI_ProgramChange; + char EMIDI_VolumeChange; + } track; + +static long _MIDI_ReadNumber( void *from, size_t size ); +static long _MIDI_ReadDelta( track *ptr ); +static void _MIDI_ResetTracks( void ); +static void _MIDI_AdvanceTick( void ); +static void _MIDI_MetaEvent( track *Track ); +static void _MIDI_SysEx( track *Track ); +static int _MIDI_InterpretControllerInfo( track *Track, int TimeSet, + int channel, int c1, int c2 ); +static int _MIDI_SendControlChange( int channel, int c1, int c2 ); +static void _MIDI_SetChannelVolume( int channel, int volume ); +static void _MIDI_SendChannelVolumes( void ); +static int _MIDI_ProcessNextTick( void ); +static void _MIDI_InitEMIDI( void ); + +/* + if ( c1 == EMIDI_LOOP_START ) + { + if ( c2 == 0 ) + { + Track->context[ 0 ].loopcount = EMIDI_INFINITE; + } + else + { + Track->context[ 0 ].loopcount = c2; + } + + Track->context[ 0 ].pos = Track->pos; + Track->context[ 0 ].loopstart = Track->pos; + Track->context[ 0 ].RunningStatus = Track->RunningStatus; + Track->context[ 0 ].time = _MIDI_Time; + Track->context[ 0 ].FPSecondsPerTick = _MIDI_FPSecondsPerTick; + Track->context[ 0 ].tick = _MIDI_Tick; + Track->context[ 0 ].beat = _MIDI_Beat; + Track->context[ 0 ].measure = _MIDI_Measure; + Track->context[ 0 ].BeatsPerMeasure = _MIDI_BeatsPerMeasure; + Track->context[ 0 ].TicksPerBeat = _MIDI_TicksPerBeat; + Track->context[ 0 ].TimeBase = _MIDI_TimeBase; + break; + } + + if ( ( c1 == EMIDI_LOOP_END ) && + ( c2 == EMIDI_END_LOOP_VALUE ) ) + { + if ( ( Track->context[ 0 ].loopstart != NULL ) && + ( Track->context[ 0 ].loopcount != 0 ) ) + { + if ( Track->context[ 0 ].loopcount != EMIDI_INFINITE ) + { + Track->context[ 0 ].loopcount--; + } + + Track->pos = Track->context[ 0 ].loopstart; + Track->RunningStatus = Track->context[ 0 ].RunningStatus; + + if ( !TimeSet ) + { + _MIDI_Time = Track->context[ 0 ].time; + _MIDI_FPSecondsPerTick = Track->context[ 0 ].FPSecondsPerTick; + _MIDI_Tick = Track->context[ 0 ].tick; + _MIDI_Beat = Track->context[ 0 ].beat; + _MIDI_Measure = Track->context[ 0 ].measure; + _MIDI_BeatsPerMeasure = Track->context[ 0 ].BeatsPerMeasure; + _MIDI_TicksPerBeat = Track->context[ 0 ].TicksPerBeat; + _MIDI_TimeBase = Track->context[ 0 ].TimeBase; + TimeSet = TRUE; + } + } + break; + } + + if ( c1 == MIDI_MONO_MODE_ON ) + { + Track->pos++; + } + + if ( ( c1 == MIDI_VOLUME ) && ( !Track->EMIDI_VolumeChange ) ) + { + _MIDI_SetChannelVolume( channel, c2 ); + break; + } + else if ( ( c1 == EMIDI_VOLUME_CHANGE ) && + ( Track->EMIDI_VolumeChange ) ) + { + _MIDI_SetChannelVolume( channel, c2 ); + break; + } + + if ( ( c1 == EMIDI_PROGRAM_CHANGE ) && + ( Track->EMIDI_ProgramChange ) ) + { + _MIDI_Funcs->ProgramChange( channel, MIDI_PatchMap[ c2 & 0x7f ] ); + break; + } + + if ( c1 == EMIDI_CONTEXT_START ) + { + break; + } + + if ( c1 == EMIDI_CONTEXT_END ) + { + if ( ( Track->currentcontext != _MIDI_Context ) || + ( Track->context[ _MIDI_Context ].pos == NULL ) + { + break; + } + + Track->currentcontext = _MIDI_Context; + Track->context[ 0 ].loopstart = Track->context[ _MIDI_Context ].loopstart; + Track->context[ 0 ].loopcount = Track->context[ _MIDI_Context ].loopcount; + Track->pos = Track->context[ _MIDI_Context ].pos; + Track->RunningStatus = Track->context[ _MIDI_Context ].RunningStatus; + + if ( TimeSet ) + { + break; + } + + _MIDI_Time = Track->context[ _MIDI_Context ].time; + _MIDI_FPSecondsPerTick = Track->context[ _MIDI_Context ].FPSecondsPerTick; + _MIDI_Tick = Track->context[ _MIDI_Context ].tick; + _MIDI_Beat = Track->context[ _MIDI_Context ].beat; + _MIDI_Measure = Track->context[ _MIDI_Context ].measure; + _MIDI_BeatsPerMeasure = Track->context[ _MIDI_Context ].BeatsPerMeasure; + _MIDI_TicksPerBeat = Track->context[ _MIDI_Context ].TicksPerBeat; + _MIDI_TimeBase = Track->context[ _MIDI_Context ].TimeBase; + TimeSet = TRUE; + break; + } + + if ( _MIDI_Funcs->ControlChange ) + { + _MIDI_Funcs->ControlChange( channel, c1, c2 ); + } + */ + +#endif diff --git a/polymer/eduke32/source/jaudiolib/_multivc.h b/polymer/eduke32/source/jaudiolib/_multivc.h new file mode 100644 index 000000000..78025d88e --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/_multivc.h @@ -0,0 +1,310 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + file: _MULTIVC.H + + author: James R. Dose + date: December 20, 1993 + + Private header for MULTIVOC.C + + (c) Copyright 1993 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef ___MULTIVC_H +#define ___MULTIVC_H + +#define TRUE ( 1 == 1 ) +#define FALSE ( !TRUE ) + +#define VOC_8BIT 0x0 +#define VOC_CT4_ADPCM 0x1 +#define VOC_CT3_ADPCM 0x2 +#define VOC_CT2_ADPCM 0x3 +#define VOC_16BIT 0x4 +#define VOC_ALAW 0x6 +#define VOC_MULAW 0x7 +#define VOC_CREATIVE_ADPCM 0x200 + +#define T_SIXTEENBIT_STEREO 0 +#define T_8BITS 1 +#define T_MONO 2 +#define T_16BITSOURCE 4 +#define T_LEFTQUIET 8 +#define T_RIGHTQUIET 16 +#define T_DEFAULT T_SIXTEENBIT_STEREO + +#define MV_MaxPanPosition 31 +#define MV_NumPanPositions ( MV_MaxPanPosition + 1 ) +#define MV_MaxTotalVolume 255 +//#define MV_MaxVolume 63 +#define MV_NumVoices 8 + +#define MIX_VOLUME( volume ) \ + ( ( max( 0, min( ( volume ), 255 ) ) * ( MV_MaxVolume + 1 ) ) >> 8 ) +// ( ( max( 0, min( ( volume ), 255 ) ) ) >> 2 ) + +//#define SILENCE_16BIT 0x80008000 +#define SILENCE_16BIT 0 +#define SILENCE_8BIT 0x80808080 +//#define SILENCE_16BIT_PAS 0 + +//#define MixBufferSize 256 +#define MixBufferSize (MV_GetBufferSize(MV_RequestedMixRate)) + +#define NumberOfBuffers 16 +#define TotalBufferSize ( MixBufferSize * NumberOfBuffers ) + +#define PI 3.1415926536 + +typedef enum + { + Raw, + VOC, + DemandFeed, + WAV + } wavedata; + +typedef enum + { + NoMoreData, + KeepPlaying + } playbackstatus; + + +typedef struct VoiceNode + { + struct VoiceNode *next; + struct VoiceNode *prev; + + wavedata wavetype; + char bits; + + playbackstatus ( *GetSound )( struct VoiceNode *voice ); + + void ( *mix )( unsigned long position, unsigned long rate, + char *start, unsigned long length ); + + char *NextBlock; + char *LoopStart; + char *LoopEnd; + unsigned LoopCount; + unsigned long LoopSize; + unsigned long BlockLength; + + unsigned long PitchScale; + unsigned long FixedPointBufferSize; + + char *sound; + unsigned long length; + unsigned long SamplingRate; + unsigned long RateScale; + unsigned long position; + int Playing; + + int handle; + int priority; + + void ( *DemandFeed )( char **ptr, unsigned long *length ); + + short *LeftVolume; + short *RightVolume; + + unsigned long callbackval; + + } VoiceNode; + +typedef struct + { + VoiceNode *start; + VoiceNode *end; + } VList; + +typedef struct + { + char left; + char right; + } Pan; + +typedef signed short MONO16; +typedef signed char MONO8; + +typedef struct + { + MONO16 left; + MONO16 right; +// unsigned short left; +// unsigned short right; + } STEREO16; + +typedef struct + { + MONO16 left; + MONO16 right; + } SIGNEDSTEREO16; + +typedef struct + { +// MONO8 left; +// MONO8 right; + char left; + char right; + } STEREO8; + +typedef struct + { + char RIFF[ 4 ]; + unsigned long file_size; + char WAVE[ 4 ]; + char fmt[ 4 ]; + unsigned long format_size; + } riff_header; + +typedef struct + { + unsigned short wFormatTag; + unsigned short nChannels; + unsigned long nSamplesPerSec; + unsigned long nAvgBytesPerSec; + unsigned short nBlockAlign; + unsigned short nBitsPerSample; + } format_header; + +typedef struct + { + unsigned char DATA[ 4 ]; + unsigned long size; + } data_header; + +typedef MONO8 VOLUME8[ 256 ]; +typedef MONO16 VOLUME16[ 256 ]; + +typedef char HARSH_CLIP_TABLE_8[ MV_NumVoices * 256 ]; + +static unsigned MV_GetBufferSize(unsigned); + +static void MV_Mix( VoiceNode *voice, int buffer ); +static void MV_PlayVoice( VoiceNode *voice ); +static void MV_StopVoice( VoiceNode *voice ); +static int MV_ServiceVoc( int ); + +static playbackstatus MV_GetNextVOCBlock( VoiceNode *voice ); +static playbackstatus MV_GetNextDemandFeedBlock( VoiceNode *voice ); +static playbackstatus MV_GetNextRawBlock( VoiceNode *voice ); +static playbackstatus MV_GetNextWAVBlock( VoiceNode *voice ); + +static void MV_ServiceRecord( void ); +static VoiceNode *MV_GetVoice( int handle ); +static VoiceNode *MV_AllocVoice( int priority ); + +static short *MV_GetVolumeTable( int vol ); + +static void MV_SetVoiceMixMode( VoiceNode *voice ); + +static void MV_SetVoicePitch( VoiceNode *voice, unsigned long rate, int pitchoffset ); +static void MV_CalcVolume( int MaxLevel ); +static void MV_CalcPanTable( void ); + +void ClearBuffer_DW(void *ptr, long data, long length) +{ + long *pptr = ptr; + for (; length>0; length--) *(pptr++) = data; +} + +/* +#define ClearBuffer_DW( ptr, data, length ) \ + ({ void *__ptr=(ptr); unsigned __data=(data); int __length=(length); \ + __asm__ __volatile__ ("rep; stosl" \ + : "+c" (__length), "+D" (__ptr) : "a" (__data) : "memory", "cc"); \ + 0; }) +*/ +/* +#pragma aux ClearBuffer_DW = \ + "cld", \ + "push es", \ + "push ds", \ + "pop es", \ + "rep stosd", \ + "pop es", \ +parm [ edi ] [ eax ] [ ecx ] modify exact [ ecx edi ]; +*/ + +#if defined(__WATCOMC__) + +#pragma aux MV_Mix8BitMono parm [eax] [edx] [ebx] [ecx] +#pragma aux MV_Mix8BitStereo parm [eax] [edx] [ebx] [ecx] +#pragma aux MV_Mix16BitMono parm [eax] [edx] [ebx] [ecx] +#pragma aux MV_Mix16BitStereo parm [eax] [edx] [ebx] [ecx] +#pragma aux MV_Mix16BitMono16 parm [eax] [edx] [ebx] [ecx] +#pragma aux MV_Mix8BitMono16 parm [eax] [edx] [ebx] [ecx] +#pragma aux MV_Mix8BitStereo16 parm [eax] [edx] [ebx] [ecx] +#pragma aux MV_Mix16BitStereo16 parm [eax] [edx] [ebx] [ecx] + +#pragma aux MV_16BitReverb parm [eax] [edx] [ebx] [ecx] modify exact [eax ebx ecx edx esi edi] +#pragma aux MV_8BitReverb parm [eax] [edx] [ebx] [ecx] modify exact [eax ebx ecx edx esi edi] +#pragma aux MV_16BitReverbFast parm [eax] [edx] [ebx] [ecx] modify exact [eax ebx ecx edx esi edi] +#pragma aux MV_8BitReverbFast parm [eax] [edx] [ebx] [ecx] modify exact [eax ebx ecx edx esi edi] + +#define CDEC + +#elif defined(_MSC_VER) + +#define CDEC _cdecl + +#else + +#define CDEC __cdecl + +#endif + + +void CDEC MV_Mix8BitMono( unsigned long position, unsigned long rate, + char *start, unsigned long length ); + +void CDEC MV_Mix8BitStereo( unsigned long position, + unsigned long rate, char *start, unsigned long length ); + +void CDEC MV_Mix16BitMono( unsigned long position, + unsigned long rate, char *start, unsigned long length ); + +void CDEC MV_Mix16BitStereo( unsigned long position, + unsigned long rate, char *start, unsigned long length ); + +void CDEC MV_Mix16BitMono16( unsigned long position, + unsigned long rate, char *start, unsigned long length ); + +void CDEC MV_Mix8BitMono16( unsigned long position, unsigned long rate, + char *start, unsigned long length ); + +void CDEC MV_Mix8BitStereo16( unsigned long position, + unsigned long rate, char *start, unsigned long length ); + +void CDEC MV_Mix16BitStereo16( unsigned long position, + unsigned long rate, char *start, unsigned long length ); + +void CDEC MV_16BitReverb( char *src, char *dest, VOLUME16 *volume, int count ); +void CDEC MV_8BitReverb( signed char *src, signed char *dest, VOLUME16 *volume, int count ); +void CDEC MV_16BitReverbFast( char *src, char *dest, int count, int shift ); +void CDEC MV_8BitReverbFast( signed char *src, signed char *dest, int count, int shift ); + +#undef CDEC + +#endif diff --git a/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c b/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c new file mode 100644 index 000000000..e2e7b1fd3 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/audiolib_fx_fmod.c @@ -0,0 +1,737 @@ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. + + FMOD AudioLib implementation by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#include "fx_man_fmod.h" +#include "duke3d.h" + +#include "fmod.h" + +#define TRUE (1==1) +#define FALSE (1==0) + +#define dprintOSD(...) + +#ifdef WINDOWS +extern long hWindow; +#endif + + +void (*FX_CallBackFunc)(unsigned long) = NULL; +int FX_ErrorCode = FX_Ok; + +#define FX_SetErrorCode( status ) \ + FX_ErrorCode = ( status ); + +FSOUND_SAMPLE * FX_Samples[NUM_SOUNDS + 11]; // 11 remote ridicules + +int FX_NumVoices = 0; +static char chtoggle=0; +static char *chstates=NULL, *chstatesa, *chstatesb; +static long *chcallvals=NULL; + +int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *samplesize, long *datalen); +int FX_ReadVOCData(char *data, char *buf, int bufferlen, char eightbit); + +int FX_SimulateCallbacks(void); + + +/*--------------------------------------------------------------------- + Function: FX_ErrorString + + Returns a pointer to the error message associated with an error + number. A -1 returns a pointer the current error. +---------------------------------------------------------------------*/ + +char *FX_ErrorString(int ErrorNumber) +{ + char *ErrorString; + + switch( ErrorNumber ) + { + case FX_Warning : + case FX_Error : + ErrorString = FX_ErrorString( FX_ErrorCode ); + break; + + case FX_Ok : + ErrorString = "Fx ok."; + break; + + case FX_ASSVersion : + ErrorString = "Apogee Sound System Version WinMM " + "Programmed by Jim Dose, Ported by Jonathon Fowler\n" + "(c) Copyright 1995 James R. Dose. All Rights Reserved.\n"; + break; + + case FX_FMODInit : + ErrorString = "Failed initializing FMOD."; + break; + + default : + ErrorString = "Unknown Fx error code."; + break; + } + + return( ErrorString ); +} + + +/*--------------------------------------------------------------------- + Function: FX_Init + + Selects which sound device to use. +---------------------------------------------------------------------*/ + +static char *OutputType(int a) +{ + switch (a) { + case FSOUND_OUTPUT_NOSOUND: return "no-sound"; + case FSOUND_OUTPUT_WINMM: return "WinMM"; + case FSOUND_OUTPUT_DSOUND: return "DirectSound"; + case FSOUND_OUTPUT_A3D: return "Aureal3D"; + case FSOUND_OUTPUT_OSS: return "OSS"; + case FSOUND_OUTPUT_ESD: return "ESD"; + case FSOUND_OUTPUT_ALSA: return "ALSA"; + case FSOUND_OUTPUT_ASIO: return "ASIO"; + case FSOUND_OUTPUT_XBOX: return "Xbox"; + case FSOUND_OUTPUT_PS2: return "Playstation2"; + case FSOUND_OUTPUT_MAC: return "Macintosh Sound Manager"; + default: return "unknown"; + } +} + +int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits, unsigned mixrate) +{ + FSOUND_Close(); + + memset(FX_Samples, 0, sizeof(FX_Samples)); + +#ifdef WINDOWS + if (hWindow) { + //FSOUND_SetHWND(&hWindow); + } +#endif + if (!FSOUND_Init(mixrate, numvoices, FSOUND_INIT_GLOBALFOCUS)) { + FX_SetErrorCode( FX_FMODInit ); + return FX_Error; + } + + printOSD("FX_Init(): %d voices, %d channels, %dHz samplerate\n", numvoices,numchannels,FSOUND_GetOutputRate()); + printOSD("FX_Init(): FMOD is using the %s output driver\n", OutputType(FSOUND_GetOutput())); + + chtoggle=0; + if (chstates) free(chstates); + chstates = (char*)malloc(numvoices*2 + sizeof(long)*numvoices); + memset(chstates,0,numvoices*2 + sizeof(long)*numvoices); + + chcallvals = (long*)(chstates + numvoices*2); + chstatesa = chstates; + chstatesb = chstates + numvoices; + + FX_NumVoices = numvoices; + + FX_SetErrorCode(FX_Ok); + return FX_Ok; +} + + +/*--------------------------------------------------------------------- + Function: FX_Shutdown + + Terminates use of sound device. +---------------------------------------------------------------------*/ + +int FX_Shutdown(void) +{ + unsigned int curalloced, maxalloced; + + if (chstates) { + FSOUND_GetMemoryStats(&curalloced, &maxalloced); + printOSD("FX_Shutdown(): allocation stats - currently %d bytes, maximum %d bytes\n",curalloced,maxalloced); + } + + FSOUND_Close(); + + if (chstates) free(chstates); + chstates=chstatesa=chstatesb=0; + + FX_SetErrorCode(FX_Ok); + return FX_Ok; +} + + +/*--------------------------------------------------------------------- + Function: FX_SetCallback + + Sets the function to call when a voice is done. +---------------------------------------------------------------------*/ + +int FX_SetCallBack(void ( *function )( unsigned long )) +{ + FX_CallBackFunc = function; + FX_SetErrorCode(FX_Ok); + return FX_Ok; +} + + +/*--------------------------------------------------------------------- + Function: FX_SetVolume + + Sets the volume of the current sound device. +---------------------------------------------------------------------*/ + +void FX_SetVolume(int volume) +{ + FSOUND_SetSFXMasterVolume(volume); +} + + +/*--------------------------------------------------------------------- + Function: FX_SetReverseStereo + + Set the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +void FX_SetReverseStereo(int setting) +{ +} + + +/*--------------------------------------------------------------------- + Function: FX_GetReverseStereo + + Returns the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +int FX_GetReverseStereo(void) +{ + return 0; +} + + +/*--------------------------------------------------------------------- + Function: FX_SetReverb + + Sets the reverb level. +---------------------------------------------------------------------*/ + +void FX_SetReverb(int reverb) +{ +} + + +/*--------------------------------------------------------------------- + Function: FX_SetReverbDelay + + Sets the delay level of reverb to add to mix. +---------------------------------------------------------------------*/ + +void FX_SetReverbDelay(int delay) +{ +} + + +/*--------------------------------------------------------------------- + Function: FX_VoiceAvailable + + Checks if a voice can be play at the specified priority. +---------------------------------------------------------------------*/ + +int FX_VoiceAvailable(int priority) +{ + FX_SimulateCallbacks(); + return 1; +} + + +/*--------------------------------------------------------------------- + Function: FX_PlayLoopedVOC + + Begin playback of sound data with the given volume and priority. + JBF: As a hack, since Duke3D passes the sound/sample number as the + callbackval parameter, we can use this as an index into the + FX_Samples array to access samples if they've already been loaded. + RemoteRidicule sounds have negative callback values, so they + take up residence at the end of FX_Samples. +---------------------------------------------------------------------*/ + +int FX_PlayLoopedVOC + ( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) +{ + return FX_PlayLoopedSound(pitchoffset, vol, callbackval); +} + + +/*--------------------------------------------------------------------- + Function: FX_PlayWAV + + Begin playback of sound data with the given volume and priority. +---------------------------------------------------------------------*/ + +int FX_PlayLoopedWAV + ( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) +{ + return FX_PlayLoopedSound(pitchoffset, vol, callbackval); +} + + +/*--------------------------------------------------------------------- + Function: FX_PlayVOC3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int FX_PlayVOC3D + ( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval + ) +{ + return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval); +} + + +/*--------------------------------------------------------------------- + Function: FX_PlayWAV3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int FX_PlayWAV3D + ( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval + ) +{ + return FX_PlayPositionedSound(pitchoffset, angle, distance, callbackval); +} + + +/*--------------------------------------------------------------------- + Function: FX_Pan3D + + Set the angle and distance from the listener of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +int FX_Pan3D + ( + int handle, + int angle, + int distance + ) +{ + return FX_Ok; +} + + +/*--------------------------------------------------------------------- + Function: FX_StopSound + + Halts playback of a specific voice +---------------------------------------------------------------------*/ + +int FX_StopSound(int handle) +{ + FX_SimulateCallbacks(); + FSOUND_StopSound(handle); + + if (handle>=0 && handle> (channels-1)) / (samplesize>>3), flags, samplerate, -1, -1, priority); + if (samp) { + if (FSOUND_Sample_Lock(samp,0,datalen,&ptr1,&ptr2,&ptr1len,&ptr2len)) { + if (FX_ReadVOCData(ptr,ptr1,datalen,(samplesize==8))) ; + FSOUND_Sample_Unlock(samp,ptr1,ptr2,ptr1len,ptr2len); + } + } + } + } else { + samp = FSOUND_Sample_Load(number, ptr, FSOUND_LOADMEMORY, size); + } + + dprintOSD("FX_LoadSample(): loaded sound %d\n",number); + if (samp) FSOUND_Sample_SetDefaults(samp, -1, -1, -1, priority); + FX_Samples[number] = samp; + + return (samp != NULL); +} + + +int FX_SampleLoaded(unsigned long number) +{ + return (FX_Samples[number] != NULL); +} + + +#define REGRESSTC(tc) (256000000/(65536-(tc))) +#define REGRESSSR(sr) (1000000/(256-(sr))) + +int FX_ReadVOCInfo(char *data, long size, int *samplerate, int *channels, int *samplesize, long *datalen) +{ + short version,version2; + char blocktype=0; + int blocklen=0; + char *ptr=data; + + if (memcmp(ptr, "Creative Voice File\x1A", 0x14)) return -1; + ptr += 0x14; + + ptr += 2; + version = ((short*)ptr)[0]; + version2 = ((short*)ptr)[1]; + + if (~version + 0x1234 != version2) return -1; + + ptr += 4; + + while (1) { + blocktype = *(ptr++); + if ((ptr-data)>size) return -1; // truncated + + if (blocktype == 0) + break; + + blocklen = *(ptr++); + blocklen |= *(ptr++) << 8; + blocklen |= *(ptr++) << 16; + + switch (blocktype) { + case 1: /* sound data begin block */ + if (!*samplerate) + *samplerate = REGRESSSR(ptr[0]); + if (ptr[1] != 0) { + /* only 8-bit files please */ + return -1; + } + if (!*channels) *channels = 1; + *samplesize = 8; + *datalen += blocklen-2; + ptr += blocklen; + break; + + case 2: /* sound continue */ + *datalen += blocklen; + ptr += blocklen; + break; + +#if 0 + case 3: /* silence */ + kread(fh, blockprop, 3); + /* + length = blockprop[0] | (blockprop[1] << 8) + sample rate = REGRESSSR(blockprop[2])) + */ + break; + + case 4: /* marker */ + kread(fh, &blockprop, 2); + /* + id = blockprop[0] | (blockprop[1] << 8)) + */ + break; + + case 5: /* ASCII data */ + klseek(fh, blocklen, SEEK_CUR); + /* + asciiz string + */ + break; + + case 6: /* repeat */ + kread(fh, blockprop, 2); + /* + num repetitions = (blockprop[0] | (blockprop[1] << 8)) - 1 + */ + break; + + case 7: /* end repeat */ + break; +#endif + + case 8: /* sound attribute extension block */ + *samplerate = REGRESSTC(ptr[0] | (ptr[1] << 8)); + *samplesize = 8; + if (ptr[3] == 1) { + *samplerate >>= 1; + *channels = 2; + } else + *channels = 1; + if (ptr[2] != 0) { + /* only 8-bit files please */ + return -1; + } + ptr += 4; + /* a block 1 follows */ + break; + + case 9: /* sound data format 3 */ + *samplerate = *((long*)(ptr)); + *samplesize = ptr[4]; + *channels = ptr[5]; + if ((ptr[6] | (ptr[7] << 8)) != 0 && + (ptr[6] | (ptr[7] << 8)) != 4) { + /* only PCM please */ + return -1; + } + *datalen += blocklen-12; + ptr += blocklen; + break; + + default: + ptr += blocklen; + break; + } + } + + return 0; +} + + +int FX_ReadVOCData(char *data, char *buf, int bufferlen, char eightbit) +{ + short offset; + char blocktype=0; + int blocklen=0, br; + + data += 0x14 + 2 + 4; + + while (bufferlen>0) { + blocktype = *(data++); + + if (blocktype == 0) + break; + + blocklen = *(data++); + blocklen |= *(data++) << 8; + blocklen |= *(data++) << 16; + + switch (blocktype) { + case 1: /* sound data */ + data += 2; + + br = min(blocklen-2, bufferlen); + goto convertdata; + + case 2: /* sound continue */ + br = min(blocklen, bufferlen); + goto convertdata; + + case 9: /* sound data format 3 */ + data += 12; + + br = min(blocklen-12, bufferlen); + goto convertdata; + + default: + data += blocklen; + continue; + } +convertdata: + bufferlen -= br; + if (eightbit) { + // FMOD wants signed data + for (; br>0; br--) + *(buf++) = (char)((short)(*(data++)) - 0x80); + } else { + memcpy(buf,data,br); + buf += br; + data += br; + } + } + + return 0; +} + + +int FX_SimulateCallbacks(void) +{ + int i; + + if (!FX_CallBackFunc || !chstates) return 0; + + chstatesa = chstates + (FX_NumVoices * chtoggle); + chstatesb = chstates + (FX_NumVoices * (chtoggle^1)); + + for (i=0;i chstatesb[i]) continue; // channel has begun playing + + // channel has ended playing + FX_CallBackFunc(chcallvals[i]); + dprintOSD("FX_SimulateCallbacks(): channel %d ended sound %d\n",i,chcallvals[i]); + } + + chtoggle ^= 1; + + return 0; +} + diff --git a/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c b/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c new file mode 100644 index 000000000..a0bfcc4a2 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/audiolib_fxstub.c @@ -0,0 +1,368 @@ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. + + Dummy AudioLib stub implementation by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#include "fx_man.h" + + +#define TRUE ( 1 == 1 ) +#define FALSE ( !TRUE ) + + +int FX_ErrorCode = FX_Ok; + +#define FX_SetErrorCode( status ) \ + FX_ErrorCode = ( status ); + + + +/*--------------------------------------------------------------------- + Function: FX_ErrorString + + Returns a pointer to the error message associated with an error + number. A -1 returns a pointer the current error. +---------------------------------------------------------------------*/ + +char *FX_ErrorString + ( + int ErrorNumber + ) + + { + char *ErrorString; + + switch( ErrorNumber ) + { + case FX_Warning : + case FX_Error : + ErrorString = FX_ErrorString( FX_ErrorCode ); + break; + + case FX_Ok : + ErrorString = "Fx ok."; + break; + + case FX_ASSVersion : + ErrorString = "Apogee Sound System Version 0 " + "Programmed by Jim Dose\n" + "(c) Copyright 1995 James R. Dose. All Rights Reserved.\n"; + break; + + default : + ErrorString = "Unknown Fx error code."; + break; + } + + return( ErrorString ); + } + + +/*--------------------------------------------------------------------- + Function: FX_Init + + Selects which sound device to use. +---------------------------------------------------------------------*/ + +int FX_Init + ( + int SoundCard, + int numvoices, + int numchannels, + int samplebits, + unsigned mixrate + ) + + { + return( FX_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: FX_Shutdown + + Terminates use of sound device. +---------------------------------------------------------------------*/ + +int FX_Shutdown + ( + void + ) + + { + return( FX_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetCallback + + Sets the function to call when a voice is done. +---------------------------------------------------------------------*/ + +int FX_SetCallBack + ( + void ( *function )( unsigned long ) + ) + + { + return( FX_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetVolume + + Sets the volume of the current sound device. +---------------------------------------------------------------------*/ + +void FX_SetVolume + ( + int volume + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: FX_SetReverseStereo + + Set the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +void FX_SetReverseStereo + ( + int setting + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: FX_GetReverseStereo + + Returns the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +int FX_GetReverseStereo + ( + void + ) + + { + return 0; + } + + +/*--------------------------------------------------------------------- + Function: FX_SetReverb + + Sets the reverb level. +---------------------------------------------------------------------*/ + +void FX_SetReverb + ( + int reverb + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: FX_SetReverbDelay + + Sets the delay level of reverb to add to mix. +---------------------------------------------------------------------*/ + +void FX_SetReverbDelay + ( + int delay + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: FX_VoiceAvailable + + Checks if a voice can be play at the specified priority. +---------------------------------------------------------------------*/ + +int FX_VoiceAvailable + ( + int priority + ) + + { + return 0; + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayLoopedVOC + + Begin playback of sound data with the given volume and priority. +---------------------------------------------------------------------*/ + +int FX_PlayLoopedVOC + ( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + return( 0 ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayWAV + + Begin playback of sound data with the given volume and priority. +---------------------------------------------------------------------*/ + +int FX_PlayLoopedWAV + ( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + return( 0 ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayVOC3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int FX_PlayVOC3D + ( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval + ) + + { + return( 0 ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayWAV3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int FX_PlayWAV3D + ( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval + ) + + { + return( 0 ); + } + + +/*--------------------------------------------------------------------- + Function: FX_Pan3D + + Set the angle and distance from the listener of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +int FX_Pan3D + ( + int handle, + int angle, + int distance + ) + + { + return( 0 ); + } + + +/*--------------------------------------------------------------------- + Function: FX_StopSound + + Halts playback of a specific voice +---------------------------------------------------------------------*/ + +int FX_StopSound + ( + int handle + ) + + { + return( FX_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: FX_StopAllSounds + + Halts playback of all sounds. +---------------------------------------------------------------------*/ + +int FX_StopAllSounds + ( + void + ) + + { + return( FX_Ok ); + } + + +void AudioUpdate(void) { } diff --git a/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c new file mode 100644 index 000000000..a8e2e1a2e --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c @@ -0,0 +1,510 @@ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. + + Dummy AudioLib stub implementation by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#include "music.h" + + +#define TRUE ( 1 == 1 ) +#define FALSE ( !TRUE ) + + +int MUSIC_ErrorCode = MUSIC_Ok; + + +/*--------------------------------------------------------------------- + Function: MUSIC_ErrorString + + Returns a pointer to the error message associated with an error + number. A -1 returns a pointer the current error. +---------------------------------------------------------------------*/ + +char *MUSIC_ErrorString + ( + int ErrorNumber + ) + + { + char *ErrorString; + + switch( ErrorNumber ) + { + case MUSIC_Warning : + case MUSIC_Error : + ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode ); + break; + + case MUSIC_Ok : + ErrorString = "Music ok."; + break; + + case MUSIC_ASSVersion : + ErrorString = "Apogee Sound System Version " + "Programmed by Jim Dose\n" + "(c) Copyright 1996 James R. Dose. All Rights Reserved.\n"; + break; + + case MUSIC_SoundCardError : + break; + + case MUSIC_MPU401Error : + ErrorString = "Could not detect MPU-401."; + break; + + case MUSIC_InvalidCard : + ErrorString = "Invalid Music device."; + break; + + case MUSIC_MidiError : + ErrorString = "Error playing MIDI file."; + break; + + case MUSIC_TaskManError : + ErrorString = "TaskMan error."; + break; + + case MUSIC_DPMI_Error : + ErrorString = "DPMI Error in MUSIC."; + break; + + default : + ErrorString = "Unknown Music error code."; + break; + } + + return( ErrorString ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_Init + + Selects which sound device to use. +---------------------------------------------------------------------*/ + +int MUSIC_Init + ( + int SoundCard, + int Address + ) + + { + int i; + int status; + + status = MUSIC_Ok; + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_Shutdown + + Terminates use of sound device. +---------------------------------------------------------------------*/ + +int MUSIC_Shutdown + ( + void + ) + + { + int status; + + status = MUSIC_Ok; + + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetMaxFMMidiChannel + + Sets the maximum MIDI channel that FM cards respond to. +---------------------------------------------------------------------*/ + +void MUSIC_SetMaxFMMidiChannel + ( + int channel + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetVolume + + Sets the volume of music playback. +---------------------------------------------------------------------*/ + +void MUSIC_SetVolume + ( + int volume + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetMidiChannelVolume + + Sets the volume of music playback on the specified MIDI channel. +---------------------------------------------------------------------*/ + +void MUSIC_SetMidiChannelVolume + ( + int channel, + int volume + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_ResetMidiChannelVolumes + + Sets the volume of music playback on all MIDI channels to full volume. +---------------------------------------------------------------------*/ + +void MUSIC_ResetMidiChannelVolumes + ( + void + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetVolume + + Returns the volume of music playback. +---------------------------------------------------------------------*/ + +int MUSIC_GetVolume + ( + void + ) + + { + return( 0 ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetLoopFlag + + Set whether the music will loop or end when it reaches the end of + the song. +---------------------------------------------------------------------*/ + +void MUSIC_SetLoopFlag + ( + int loopflag + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SongPlaying + + Returns whether there is a song playing. +---------------------------------------------------------------------*/ + +int MUSIC_SongPlaying + ( + void + ) + + { + return( 0 ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_Continue + + Continues playback of a paused song. +---------------------------------------------------------------------*/ + +void MUSIC_Continue + ( + void + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_Pause + + Pauses playback of a song. +---------------------------------------------------------------------*/ + +void MUSIC_Pause + ( + void + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_StopSong + + Stops playback of current song. +---------------------------------------------------------------------*/ + +int MUSIC_StopSong + ( + void + ) + + { + return( MUSIC_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_PlaySong + + Begins playback of MIDI song. +---------------------------------------------------------------------*/ + +int MUSIC_PlaySong + ( + unsigned char *song, + int loopflag + ) + + { + return( MUSIC_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetContext + + Sets the song context. +---------------------------------------------------------------------*/ + +void MUSIC_SetContext + ( + int context + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetContext + + Returns the current song context. +---------------------------------------------------------------------*/ + +int MUSIC_GetContext + ( + void + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetSongTick + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_SetSongTick + ( + unsigned long PositionInTicks + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetSongTime + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_SetSongTime + ( + unsigned long milliseconds + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetSongPosition + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_SetSongPosition + ( + int measure, + int beat, + int tick + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetSongPosition + + Returns the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_GetSongPosition + ( + songposition *pos + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetSongLength + + Returns the length of the song. +---------------------------------------------------------------------*/ + +void MUSIC_GetSongLength + ( + songposition *pos + ) + + { + } + + + + + + +/*--------------------------------------------------------------------- + Function: MUSIC_FadeVolume + + Fades music volume from current level to another over a specified + period of time. +---------------------------------------------------------------------*/ + +int MUSIC_FadeVolume + ( + int tovolume, + int milliseconds + ) + + { + return( MUSIC_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_FadeActive + + Returns whether the fade routine is active. +---------------------------------------------------------------------*/ + +int MUSIC_FadeActive + ( + void + ) + + { + return( 0 ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_StopFade + + Stops fading the music. +---------------------------------------------------------------------*/ + +void MUSIC_StopFade + ( + void + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_RerouteMidiChannel + + Sets callback function to reroute MIDI commands from specified + function. +---------------------------------------------------------------------*/ + +void MUSIC_RerouteMidiChannel + ( + int channel, + int ( *function )( int event, int c1, int c2 ) + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_RegisterTimbreBank + + Halts playback of all sounds. +---------------------------------------------------------------------*/ + +void MUSIC_RegisterTimbreBank + ( + unsigned char *timbres + ) + + { + } + + +void MUSIC_Update(void) +{ +} + diff --git a/polymer/eduke32/source/jaudiolib/dsoundout.c b/polymer/eduke32/source/jaudiolib/dsoundout.c new file mode 100644 index 000000000..0ab98202c --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/dsoundout.c @@ -0,0 +1,585 @@ +/* + * DirectSound output code for MultiVoc + * by Jonathon Fowler (jonof@edgenetwk.com) + */ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. +*/ +//------------------------------------------------------------------------- + +#include "dsoundout.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include "dsound.h" +#include "osd.h" + +#include "winlayer.h" + +#if defined(__WATCOMC__) || defined(_MSC_VER) +#include +#endif + + +#ifndef RENDERTYPEWIN +#error The DirectSound output module for AudioLib only works with the Windows interface. +#endif + +static CRITICAL_SECTION mutex; +static int _DSOUND_CriticalSectionAlloced = FALSE; +static HANDLE isrthread = NULL; +static HANDLE isrfinish = NULL; + +static HMODULE hDSoundDLL = NULL; +static LPDIRECTSOUND lpDS = NULL; +static LPDIRECTSOUNDBUFFER lpDSBPrimary = NULL; +static LPDIRECTSOUNDBUFFER lpDSBSecondary = NULL; +static LPDIRECTSOUNDNOTIFY lpDSNotify = NULL; +static HANDLE *hPosNotify = NULL; + +static int (*_DSOUND_CallBack)(int) = NULL; +static int _DSOUND_BufferLength = 0; +static int _DSOUND_NumBuffers = 0; +static char *_DSOUND_MixBuffer = NULL; + +static int DSOUND_Installed = FALSE; + +int DSOUND_ErrorCode = DSOUND_Ok; + +#define DSOUND_SetErrorCode( status ) \ + DSOUND_ErrorCode = ( status ); + + + +/* + * DisableInterrupts + * Enter the critical section. + */ +int DisableInterrupts(void) +{ + if (!_DSOUND_CriticalSectionAlloced) return -1; + + EnterCriticalSection(&mutex); + + return 0; +} + + +/* + * RestoreInterrupts + * Leave the critical section. + */ +int RestoreInterrupts(int a) +{ + if (!_DSOUND_CriticalSectionAlloced) return -1; + + LeaveCriticalSection(&mutex); + + return 0; + a=a; +} + + +/* + * DSOUND_ErrorString + * Returns a description of an error code. + */ +char *DSOUND_ErrorString(int errorcode) +{ + switch (errorcode) { + case DSOUND_Warning: + case DSOUND_Error: + return DSOUND_ErrorString(DSOUND_ErrorCode); + + case DSOUND_Ok: + return "DirectSound ok."; + + case DSOUND_NoDLL: + return "Failed loading DSOUND.DLL."; + + case DSOUND_NoDirectSoundCreate: + return "Failed getting DirectSoundCreate entry point."; + + case DSOUND_FailedDSC: + return "DirectSoundCreate failed."; + + case DSOUND_FailedSetCoopLevel: + return "Failed setting cooperative level."; + + case DSOUND_FailedCreatePrimary: + return "Failed creating primary buffer."; + + case DSOUND_FailedSetFormat: + return "Failed setting primary buffer format."; + + case DSOUND_FailedCreateSecondary: + return "Failed creating secondary buffer."; + + case DSOUND_FailedCreateNotifyEvent: + return "Failed creating notification event object."; + + case DSOUND_FailedQueryNotify: + return "Failed querying notification interface."; + + case DSOUND_FailedSetNotify: + return "Failed setting notification positions."; + + case DSOUND_FailedCreateFinishEvent: + return "Failed creating finish event object."; + + case DSOUND_FailedCreateThread: + return "Failed creating playback thread."; + + case DSOUND_FailedPlaySecondary: + return "Failed playing secondary buffer."; + + case DSOUND_FailedGetExitCode: + return "GetExitCodeThread failed."; + + default: + return "Unknown DirectSound error code."; + } +} + + +/* + * DSOUND_Init + * Initializes the DirectSound objects. + */ +int DSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int buffersize) +{ + HRESULT (WINAPI *aDirectSoundCreate)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN); + HRESULT hr; + DSBUFFERDESC dsbuf; + WAVEFORMATEX wfex; + DSBPOSITIONNOTIFY posn; + + if (DSOUND_Installed) { + DSOUND_Shutdown(); + } + + printOSD("Initializing DirectSound...\n"); + + if (!_DSOUND_CriticalSectionAlloced) { + // initialize the critical section object we'll use to + // simulate (dis|en)abling interrupts + InitializeCriticalSection(&mutex); + _DSOUND_CriticalSectionAlloced = TRUE; + } + + printOSD(" - Loading DSOUND.DLL\n"); + hDSoundDLL = LoadLibrary("DSOUND.DLL"); + if (!hDSoundDLL) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_NoDLL); + return DSOUND_Error; + } + + aDirectSoundCreate = (void *)GetProcAddress(hDSoundDLL, "DirectSoundCreate"); + if (!aDirectSoundCreate) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_NoDirectSoundCreate); + return DSOUND_Error; + } + + printOSD(" - Creating DirectSound object\n"); + hr = aDirectSoundCreate(NULL, &lpDS, NULL); + if (hr != DS_OK) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedDSC); + return DSOUND_Error; + } + + hr = IDirectSound_SetCooperativeLevel(lpDS, (HWND)win_gethwnd(), DSSCL_EXCLUSIVE); + if (hr != DS_OK) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedSetCoopLevel); + return DSOUND_Error; + } + + printOSD(" - Creating primary buffer\n"); + ZeroMemory(&dsbuf, sizeof(dsbuf)); + dsbuf.dwSize = sizeof(DSBUFFERDESC); + dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER; + hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBPrimary, NULL); + if (hr != DS_OK) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedCreatePrimary); + return DSOUND_Error; + } + + printOSD(" - Setting primary buffer format\n" + " Channels: %d\n" + " Sample rate: %dHz\n" + " Sample size: %d bits\n", + numchannels, mixrate, samplebits); + ZeroMemory(&wfex, sizeof(wfex)); + wfex.wFormatTag = WAVE_FORMAT_PCM; + wfex.nChannels = numchannels; + wfex.nSamplesPerSec = mixrate; + wfex.wBitsPerSample = samplebits; + wfex.nBlockAlign = (wfex.wBitsPerSample / 8) * wfex.nChannels; + wfex.nAvgBytesPerSec = wfex.nBlockAlign * wfex.nSamplesPerSec; + hr = IDirectSoundBuffer_SetFormat(lpDSBPrimary, &wfex); + if (hr != DS_OK) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedSetFormat); + return DSOUND_Error; + } + + printOSD(" - Creating secondary buffer\n"); + ZeroMemory(&dsbuf, sizeof(dsbuf)); + dsbuf.dwSize = sizeof(DSBUFFERDESC); + dsbuf.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_LOCSOFTWARE; + dsbuf.dwBufferBytes = buffersize; + dsbuf.lpwfxFormat = &wfex; + hr = IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpDSBSecondary, NULL); + if (hr != DS_OK) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedCreateSecondary); + return DSOUND_Error; + } + + hr = IDirectSoundBuffer_QueryInterface(lpDSBSecondary, &IID_IDirectSoundNotify, &lpDSNotify); + if (hr != DS_OK) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedQueryNotify); + return DSOUND_Error; + } + + hPosNotify = (HANDLE *)malloc(sizeof(HANDLE)); + if (!hPosNotify) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedSetNotify); + return DSOUND_Error; + } + + hPosNotify[0] = CreateEvent(NULL, FALSE, FALSE, NULL); + if (!hPosNotify) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedCreateNotifyEvent); + return DSOUND_Error; + } + + _DSOUND_BufferLength = 0; + _DSOUND_NumBuffers = 1; + posn.dwOffset = 0; + posn.hEventNotify = hPosNotify[0]; + + hr = IDirectSoundNotify_SetNotificationPositions(lpDSNotify, 1, &posn); + if (hr != DS_OK) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedSetNotify); + return DSOUND_Error; + } + + DSOUND_Installed = TRUE; + + DSOUND_SetErrorCode(DSOUND_Ok); + return DSOUND_Ok; +} + + +/* + * DSOUND_Shutdown + * Shuts down DirectSound and it's associates. + */ +int DSOUND_Shutdown(void) +{ + int i; + + if (DSOUND_Installed) printOSD("Uninitializing DirectSound...\n"); + + DSOUND_Installed = FALSE; + + DSOUND_StopPlayback(); + + if (lpDSNotify) { + IDirectSoundNotify_Release(lpDSNotify); + lpDSNotify = NULL; + } + + if (hPosNotify) { + for (i=0; i<_DSOUND_NumBuffers; i++) { + if (hPosNotify[i]) CloseHandle(hPosNotify[i]); + } + free(hPosNotify); + hPosNotify = NULL; + } + + if (lpDSBSecondary) { + printOSD(" - Releasing secondary buffer\n"); + IDirectSoundBuffer_Stop(lpDSBSecondary); + IDirectSoundBuffer_Release(lpDSBSecondary); + lpDSBSecondary = NULL; + } + + if (lpDSBPrimary) { + printOSD(" - Releasing primary buffer\n"); + IDirectSoundBuffer_Release(lpDSBPrimary); + lpDSBPrimary = NULL; + } + + if (lpDS) { + printOSD(" - Releasing DirectSound object\n"); + IDirectSound_Release(lpDS); + lpDS = NULL; + } + + if (hDSoundDLL) { + printOSD(" - Unloading DSOUND.DLL\n"); + FreeLibrary(hDSoundDLL); + hDSoundDLL = NULL; + } + + DSOUND_SetErrorCode(DSOUND_Ok); + return DSOUND_Ok; +} + + +/* + * DSOUND_SetMixMode + * Bit of filler for the future. + */ +int DSOUND_SetMixMode(int mode) +{ + return mode; +} + + +//#define DEBUGAUDIO + +#ifdef DEBUGAUDIO +#include +#endif +static DWORD WINAPI isr(LPVOID parm) +{ + HANDLE *handles; + HRESULT hr; + DWORD rv; +#ifdef DEBUGAUDIO + int h; +#endif + int p; + LPVOID lockptr; DWORD lockbytes; + LPVOID lockptr2; DWORD lockbytes2; + + handles = (HANDLE *)malloc(sizeof(HANDLE)*(1+_DSOUND_NumBuffers)); + if (!handles) return 1; + + handles[0] = isrfinish; + for (p=0; p<_DSOUND_NumBuffers; p++) + handles[p+1] = hPosNotify[p]; + +#ifdef DEBUGAUDIO + h = creat("audio.raw",S_IREAD|S_IWRITE); +#endif + + while (1) { + rv = WaitForMultipleObjects(1+_DSOUND_NumBuffers, handles, FALSE, INFINITE); + + if (!(rv >= WAIT_OBJECT_0 && rv <= WAIT_OBJECT_0+1+_DSOUND_NumBuffers)) return -1; + + if (rv == WAIT_OBJECT_0) { + // we've been asked to finish up + break; + } + + // otherwise we just service the interrupt + if (_DSOUND_CallBack) { + DisableInterrupts(); + + p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1); +#ifdef DEBUGAUDIO + write(h, _DSOUND_MixBuffer + p*_DSOUND_BufferLength, _DSOUND_BufferLength); +#endif + + hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength, + &lockptr, &lockbytes, &lockptr2, &lockbytes2, 0); + if (hr == DSERR_BUFFERLOST) { + hr = IDirectSoundBuffer_Restore(lpDSBSecondary); + } + if (hr == DS_OK) { + /* +#define copybuf(S,D,c) \ + ({ void *__S=(S), *__D=(D); long __c=(c); \ + __asm__ __volatile__ ("rep; movsl" \ + : "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \ + 0; }) +*/ + //copybuf(_DSOUND_MixBuffer + p * _DSOUND_BufferLength, lockptr, _DSOUND_BufferLength >> 2); + memcpy(lockptr, _DSOUND_MixBuffer + p * _DSOUND_BufferLength, _DSOUND_BufferLength); + IDirectSoundBuffer_Unlock(lpDSBSecondary, lockptr, lockbytes, lockptr2, lockbytes2); + } + + RestoreInterrupts(0); + } + } + +#ifdef DEBUGAUDIO + close(h); +#endif + + return 0; +} + + +/* + * DSOUND_BeginBufferedPlayback + * Spins off a thread that behaves somewhat like the SoundBlaster DMA ISR did. + */ +int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), int buffersize, int numdivisions) +{ + DWORD threadid; + HRESULT hr; + DSBPOSITIONNOTIFY *posns; + int i; + + _DSOUND_CallBack = CallBackFunc; + _DSOUND_MixBuffer = BufferStart; + + if (!lpDSBSecondary) return DSOUND_Error; + + if (isrthread) { + DSOUND_StopPlayback(); + } + + isrfinish = CreateEvent(NULL, TRUE, FALSE, NULL); + if (!isrfinish) { + DSOUND_SetErrorCode(DSOUND_FailedCreateFinishEvent); + return DSOUND_Error; + } + + isrthread = CreateThread(NULL, 0, isr, NULL, CREATE_SUSPENDED, &threadid); + if (!isrthread) { + DSOUND_SetErrorCode(DSOUND_FailedCreateThread); + return DSOUND_Error; + } + + hPosNotify = (HANDLE *)malloc(sizeof(HANDLE)*numdivisions); + if (!hPosNotify) { + DSOUND_Shutdown(); + DSOUND_SetErrorCode(DSOUND_FailedSetNotify); + return DSOUND_Error; + } + + memset(hPosNotify, 0, sizeof(HANDLE)*numdivisions); + for (i=0; i +#include +#include "multivoc.h" +#include "ll_man.h" +#include "fx_man.h" + +#define TRUE ( 1 == 1 ) +#define FALSE ( !TRUE ) + +static unsigned FX_MixRate; + +int FX_SoundDevice = -1; +int FX_ErrorCode = FX_Ok; +int FX_Installed = FALSE; + +#define FX_SetErrorCode( status ) \ + FX_ErrorCode = ( status ); + +/*--------------------------------------------------------------------- + Function: FX_ErrorString + + Returns a pointer to the error message associated with an error + number. A -1 returns a pointer the current error. +---------------------------------------------------------------------*/ + +char *FX_ErrorString + ( + int ErrorNumber + ) + + { + char *ErrorString; + + switch( ErrorNumber ) + { + case FX_Warning : + case FX_Error : + ErrorString = FX_ErrorString( FX_ErrorCode ); + break; + + case FX_Ok : + ErrorString = "Fx ok."; + break; + + case FX_ASSVersion : + ErrorString = "Apogee Sound System Version 0 " + "Programmed by Jim Dose\n" + "(c) Copyright 1995 James R. Dose. All Rights Reserved.\n"; + break; + + case FX_BlasterError : + case FX_SoundCardError : + ErrorString = "Sound device error."; + break; + + case FX_InvalidCard : + ErrorString = "Invalid Sound Fx device."; + break; + + case FX_MultiVocError : + ErrorString = MV_ErrorString( MV_Error ); + break; + + case FX_DPMI_Error : + ErrorString = "DPMI Error in FX_MAN."; + break; + + default : + ErrorString = "Unknown Fx error code."; + break; + } + + return( ErrorString ); + } + + +#if 0 +/*--------------------------------------------------------------------- + Function: FX_SetupCard + + Sets the configuration of a sound device. +---------------------------------------------------------------------*/ + +int FX_SetupCard + ( + int SoundCard, + fx_device *device + ) + + { + int status; + int DeviceStatus; + + FX_SoundDevice = SoundCard; + + status = FX_Ok; + FX_SetErrorCode( FX_Ok ); + + switch( SoundCard ) + { + case SoundBlaster : + DeviceStatus = BLASTER_Init(); + if ( DeviceStatus != BLASTER_Ok ) + { + FX_SetErrorCode( FX_SoundCardError ); + status = FX_Error; + break; + } + + device->MaxVoices = 32; + BLASTER_GetCardInfo( &device->MaxSampleBits, &device->MaxChannels ); + break; + + default : + FX_SetErrorCode( FX_InvalidCard ); + status = FX_Error; + } + return( status ); + } +#endif + + +#if 0 +/*--------------------------------------------------------------------- + Function: FX_GetBlasterSettings + + Returns the current BLASTER environment variable settings. +---------------------------------------------------------------------*/ + +int FX_GetBlasterSettings + ( + fx_blaster_config *blaster + ) + + { + int status; + BLASTER_CONFIG Blaster; + + FX_SetErrorCode( FX_Ok ); + + status = BLASTER_GetEnv( &Blaster ); + if ( status != BLASTER_Ok ) + { + FX_SetErrorCode( FX_BlasterError ); + return( FX_Error ); + } + + blaster->Type = Blaster.Type; + blaster->Address = Blaster.Address; + blaster->Interrupt = Blaster.Interrupt; + blaster->Dma8 = Blaster.Dma8; + blaster->Dma16 = Blaster.Dma16; + blaster->Midi = Blaster.Midi; + blaster->Emu = Blaster.Emu; + + return( FX_Ok ); + } +#endif + + +#if 0 +/*--------------------------------------------------------------------- + Function: FX_SetupSoundBlaster + + Handles manual setup of the Sound Blaster information. +---------------------------------------------------------------------*/ + +int FX_SetupSoundBlaster + ( + fx_blaster_config blaster, + int *MaxVoices, + int *MaxSampleBits, + int *MaxChannels + ) + + { + int DeviceStatus; + BLASTER_CONFIG Blaster; + + FX_SetErrorCode( FX_Ok ); + + FX_SoundDevice = SoundBlaster; + + Blaster.Type = blaster.Type; + Blaster.Address = blaster.Address; + Blaster.Interrupt = blaster.Interrupt; + Blaster.Dma8 = blaster.Dma8; + Blaster.Dma16 = blaster.Dma16; + Blaster.Midi = blaster.Midi; + Blaster.Emu = blaster.Emu; + + BLASTER_SetCardSettings( Blaster ); + + DeviceStatus = BLASTER_Init(); + if ( DeviceStatus != BLASTER_Ok ) + { + FX_SetErrorCode( FX_SoundCardError ); + return( FX_Error ); + } + + *MaxVoices = 8; + BLASTER_GetCardInfo( MaxSampleBits, MaxChannels ); + + return( FX_Ok ); + } +#endif + + +/*--------------------------------------------------------------------- + Function: FX_Init + + Selects which sound device to use. +---------------------------------------------------------------------*/ + +int FX_Init + ( + int SoundCard, + int numvoices, + int numchannels, + int samplebits, + unsigned mixrate + ) + + { + int status; + int devicestatus; + + if ( FX_Installed ) + { + FX_Shutdown(); + } + + FX_MixRate = mixrate; + + status = FX_Ok; + FX_SoundDevice = SoundCard; + + devicestatus = MV_Init( SoundCard, FX_MixRate, numvoices, + numchannels, samplebits ); + if ( devicestatus != MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + status = FX_Error; + } + + if ( status == FX_Ok ) + { + FX_Installed = TRUE; + } + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: FX_Shutdown + + Terminates use of sound device. +---------------------------------------------------------------------*/ + +int FX_Shutdown + ( + void + ) + + { + int status; + + if ( !FX_Installed ) + { + return( FX_Ok ); + } + + status = MV_Shutdown(); + if ( status != MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + status = FX_Error; + } + + FX_Installed = FALSE; + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetCallback + + Sets the function to call when a voice is done. +---------------------------------------------------------------------*/ + +int FX_SetCallBack + ( + void ( *function )( unsigned long ) + ) + + { + MV_SetCallBack( function ); + + return( FX_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetVolume + + Sets the volume of the current sound device. +---------------------------------------------------------------------*/ + +void FX_SetVolume + ( + int volume + ) + + { + MV_SetVolume( volume ); + } + + +/*--------------------------------------------------------------------- + Function: FX_GetVolume + + Returns the volume of the current sound device. +---------------------------------------------------------------------*/ + +int FX_GetVolume + ( + void + ) + + { + return MV_GetVolume(); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetReverseStereo + + Set the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +void FX_SetReverseStereo + ( + int setting + ) + + { + MV_SetReverseStereo( setting ); + } + + +/*--------------------------------------------------------------------- + Function: FX_GetReverseStereo + + Returns the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +int FX_GetReverseStereo + ( + void + ) + + { + return MV_GetReverseStereo(); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetReverb + + Sets the reverb level. +---------------------------------------------------------------------*/ + +void FX_SetReverb + ( + int reverb + ) + + { + MV_SetReverb( reverb ); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetFastReverb + + Sets the reverb level. +---------------------------------------------------------------------*/ + +void FX_SetFastReverb + ( + int reverb + ) + + { + MV_SetFastReverb( reverb ); + } + + +/*--------------------------------------------------------------------- + Function: FX_GetMaxReverbDelay + + Returns the maximum delay time for reverb. +---------------------------------------------------------------------*/ + +int FX_GetMaxReverbDelay + ( + void + ) + + { + return MV_GetMaxReverbDelay(); + } + + +/*--------------------------------------------------------------------- + Function: FX_GetReverbDelay + + Returns the current delay time for reverb. +---------------------------------------------------------------------*/ + +int FX_GetReverbDelay + ( + void + ) + + { + return MV_GetReverbDelay(); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetReverbDelay + + Sets the delay level of reverb to add to mix. +---------------------------------------------------------------------*/ + +void FX_SetReverbDelay + ( + int delay + ) + + { + MV_SetReverbDelay( delay ); + } + + +/*--------------------------------------------------------------------- + Function: FX_VoiceAvailable + + Checks if a voice can be play at the specified priority. +---------------------------------------------------------------------*/ + +int FX_VoiceAvailable + ( + int priority + ) + + { + return MV_VoiceAvailable( priority ); + } + +/*--------------------------------------------------------------------- + Function: FX_EndLooping + + Stops the voice associated with the specified handle from looping + without stoping the sound. +---------------------------------------------------------------------*/ + +int FX_EndLooping + ( + int handle + ) + + { + int status; + + status = MV_EndLooping( handle ); + if ( status == MV_Error ) + { + FX_SetErrorCode( FX_MultiVocError ); + status = FX_Warning; + } + + return( status ); + } + +/*--------------------------------------------------------------------- + Function: FX_SetPan + + Sets the stereo and mono volume level of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +int FX_SetPan + ( + int handle, + int vol, + int left, + int right + ) + + { + int status; + + status = MV_SetPan( handle, vol, left, right ); + if ( status == MV_Error ) + { + FX_SetErrorCode( FX_MultiVocError ); + status = FX_Warning; + } + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetPitch + + Sets the pitch of the voice associated with the specified handle. +---------------------------------------------------------------------*/ + +int FX_SetPitch + ( + int handle, + int pitchoffset + ) + + { + int status; + + status = MV_SetPitch( handle, pitchoffset ); + if ( status == MV_Error ) + { + FX_SetErrorCode( FX_MultiVocError ); + status = FX_Warning; + } + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: FX_SetFrequency + + Sets the frequency of the voice associated with the specified handle. +---------------------------------------------------------------------*/ + +int FX_SetFrequency + ( + int handle, + int frequency + ) + + { + int status; + + status = MV_SetFrequency( handle, frequency ); + if ( status == MV_Error ) + { + FX_SetErrorCode( FX_MultiVocError ); + status = FX_Warning; + } + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayVOC + + Begin playback of sound data with the given volume and priority. +---------------------------------------------------------------------*/ + +int FX_PlayVOC + ( + char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int handle; + + handle = MV_PlayVOC( ptr, pitchoffset, vol, left, right, + priority, callbackval ); + if ( handle < MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + handle = FX_Warning; + } + + return( handle ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayLoopedVOC + + Begin playback of sound data with the given volume and priority. +---------------------------------------------------------------------*/ + +int FX_PlayLoopedVOC + ( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int handle; + + handle = MV_PlayLoopedVOC( ptr, loopstart, loopend, pitchoffset, + vol, left, right, priority, callbackval ); + if ( handle < MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + handle = FX_Warning; + } + + return( handle ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayWAV + + Begin playback of sound data with the given volume and priority. +---------------------------------------------------------------------*/ + +int FX_PlayWAV + ( + char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int handle; + + handle = MV_PlayWAV( ptr, pitchoffset, vol, left, right, + priority, callbackval ); + if ( handle < MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + handle = FX_Warning; + } + + return( handle ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayWAV + + Begin playback of sound data with the given volume and priority. +---------------------------------------------------------------------*/ + +int FX_PlayLoopedWAV + ( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int handle; + + handle = MV_PlayLoopedWAV( ptr, loopstart, loopend, + pitchoffset, vol, left, right, priority, callbackval ); + if ( handle < MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + handle = FX_Warning; + } + + return( handle ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayVOC3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int FX_PlayVOC3D + ( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval + ) + + { + int handle; + + handle = MV_PlayVOC3D( ptr, pitchoffset, angle, distance, + priority, callbackval ); + if ( handle < MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + handle = FX_Warning; + } + + return( handle ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayWAV3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int FX_PlayWAV3D + ( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval + ) + + { + int handle; + + handle = MV_PlayWAV3D( ptr, pitchoffset, angle, distance, + priority, callbackval ); + if ( handle < MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + handle = FX_Warning; + } + + return( handle ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayRaw + + Begin playback of raw sound data with the given volume and priority. +---------------------------------------------------------------------*/ + +int FX_PlayRaw + ( + char *ptr, + unsigned long length, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int handle; + + handle = MV_PlayRaw( ptr, length, rate, pitchoffset, + vol, left, right, priority, callbackval ); + if ( handle < MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + handle = FX_Warning; + } + + return( handle ); + } + + +/*--------------------------------------------------------------------- + Function: FX_PlayLoopedRaw + + Begin playback of raw sound data with the given volume and priority. +---------------------------------------------------------------------*/ + +int FX_PlayLoopedRaw + ( + char *ptr, + unsigned long length, + char *loopstart, + char *loopend, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int handle; + + handle = MV_PlayLoopedRaw( ptr, length, loopstart, loopend, + rate, pitchoffset, vol, left, right, priority, callbackval ); + if ( handle < MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + handle = FX_Warning; + } + + return( handle ); + } + + +/*--------------------------------------------------------------------- + Function: FX_Pan3D + + Set the angle and distance from the listener of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +int FX_Pan3D + ( + int handle, + int angle, + int distance + ) + + { + int status; + + status = MV_Pan3D( handle, angle, distance ); + if ( status != MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + status = FX_Warning; + } + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: FX_SoundActive + + Tests if the specified sound is currently playing. +---------------------------------------------------------------------*/ + +int FX_SoundActive + ( + int handle + ) + + { + return( MV_VoicePlaying( handle ) ); + } + + +/*--------------------------------------------------------------------- + Function: FX_SoundsPlaying + + Reports the number of voices playing. +---------------------------------------------------------------------*/ + +int FX_SoundsPlaying + ( + void + ) + + { + return( MV_VoicesPlaying() ); + } + + +/*--------------------------------------------------------------------- + Function: FX_StopSound + + Halts playback of a specific voice +---------------------------------------------------------------------*/ + +int FX_StopSound + ( + int handle + ) + + { + int status; + + status = MV_Kill( handle ); + if ( status != MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + return( FX_Warning ); + } + + return( FX_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: FX_StopAllSounds + + Halts playback of all sounds. +---------------------------------------------------------------------*/ + +int FX_StopAllSounds + ( + void + ) + + { + int status; + + status = MV_KillAllVoices(); + if ( status != MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + return( FX_Warning ); + } + + return( FX_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: FX_StartDemandFeedPlayback + + Plays a digitized sound from a user controlled buffering system. +---------------------------------------------------------------------*/ + +int FX_StartDemandFeedPlayback + ( + void ( *function )( char **ptr, unsigned long *length ), + int rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int handle; + + handle = MV_StartDemandFeedPlayback( function, rate, + pitchoffset, vol, left, right, priority, callbackval ); + if ( handle < MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + handle = FX_Warning; + } + + return( handle ); + } + +#if 0 +/*--------------------------------------------------------------------- + Function: FX_StartRecording + + Starts the sound recording engine. +---------------------------------------------------------------------*/ + +int FX_StartRecording + ( + int MixRate, + void ( *function )( char *ptr, int length ) + ) + + { + int status; + + switch( FX_SoundDevice ) + { + case SoundBlaster : + status = MV_StartRecording( MixRate, function ); + if ( status != MV_Ok ) + { + FX_SetErrorCode( FX_MultiVocError ); + status = FX_Warning; + } + else + { + status = FX_Ok; + } + break; + + default : + FX_SetErrorCode( FX_InvalidCard ); + status = FX_Warning; + break; + } + + return( status ); + } +#endif + +#if 0 +/*--------------------------------------------------------------------- + Function: FX_StopRecord + + Stops the sound record engine. +---------------------------------------------------------------------*/ + +void FX_StopRecord + ( + void + ) + + { + // Stop sound playback + switch( FX_SoundDevice ) + { + case SoundBlaster : + MV_StopRecord(); + break; + } + } +#endif + +extern void MUSIC_Update(void); +void AudioUpdate(void) { MUSIC_Update(); } diff --git a/polymer/eduke32/source/jaudiolib/fx_man.h b/polymer/eduke32/source/jaudiolib/fx_man.h new file mode 100644 index 000000000..f2fa2429d --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/fx_man.h @@ -0,0 +1,137 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: FX_MAN.H + + author: James R. Dose + date: March 17, 1994 + + Public header for FX_MAN.C + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __FX_MAN_H +#define __FX_MAN_H + +typedef struct + { + int MaxVoices; + int MaxSampleBits; + int MaxChannels; + } fx_device; + +#define MonoFx 1 +#define StereoFx 2 + +typedef struct + { + unsigned long Address; + unsigned long Type; + unsigned long Interrupt; + unsigned long Dma8; + unsigned long Dma16; + unsigned long Midi; + unsigned long Emu; + } fx_blaster_config; + +enum FX_ERRORS + { + FX_Warning = -2, + FX_Error = -1, + FX_Ok = 0, + FX_ASSVersion, + FX_BlasterError, + FX_SoundCardError, + FX_InvalidCard, + FX_MultiVocError, + FX_DPMI_Error + }; + +/* +enum fx_BLASTER_Types + { + fx_SB = 1, + fx_SBPro = 2, + fx_SB20 = 3, + fx_SBPro2 = 4, + fx_SB16 = 6 + }; +*/ + +char *FX_ErrorString( int ErrorNumber ); +//int FX_SetupCard( int SoundCard, fx_device *device ); +//int FX_GetBlasterSettings( fx_blaster_config *blaster ); +//int FX_SetupSoundBlaster( fx_blaster_config blaster, int *MaxVoices, int *MaxSampleBits, int *MaxChannels ); +int FX_Init( int SoundCard, int numvoices, int numchannels, int samplebits, unsigned mixrate ); +int FX_Shutdown( void ); +int FX_SetCallBack( void ( *function )( unsigned long ) ); +void FX_SetVolume( int volume ); +int FX_GetVolume( void ); + +void FX_SetReverseStereo( int setting ); +int FX_GetReverseStereo( void ); +void FX_SetReverb( int reverb ); +void FX_SetFastReverb( int reverb ); +int FX_GetMaxReverbDelay( void ); +int FX_GetReverbDelay( void ); +void FX_SetReverbDelay( int delay ); + +int FX_VoiceAvailable( int priority ); +int FX_EndLooping( int handle ); +int FX_SetPan( int handle, int vol, int left, int right ); +int FX_SetPitch( int handle, int pitchoffset ); +int FX_SetFrequency( int handle, int frequency ); + +int FX_PlayVOC( char *ptr, int pitchoffset, int vol, int left, int right, + int priority, unsigned long callbackval ); +int FX_PlayLoopedVOC( char *ptr, long loopstart, long loopend, + int pitchoffset, int vol, int left, int right, int priority, + unsigned long callbackval ); +int FX_PlayWAV( char *ptr, int pitchoffset, int vol, int left, int right, + int priority, unsigned long callbackval ); +int FX_PlayLoopedWAV( char *ptr, long loopstart, long loopend, + int pitchoffset, int vol, int left, int right, int priority, + unsigned long callbackval ); +int FX_PlayVOC3D( char *ptr, int pitchoffset, int angle, int distance, + int priority, unsigned long callbackval ); +int FX_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance, + int priority, unsigned long callbackval ); +int FX_PlayRaw( char *ptr, unsigned long length, unsigned rate, + int pitchoffset, int vol, int left, int right, int priority, + unsigned long callbackval ); +int FX_PlayLoopedRaw( char *ptr, unsigned long length, char *loopstart, + char *loopend, unsigned rate, int pitchoffset, int vol, int left, + int right, int priority, unsigned long callbackval ); +int FX_Pan3D( int handle, int angle, int distance ); +int FX_SoundActive( int handle ); +int FX_SoundsPlaying( void ); +int FX_StopSound( int handle ); +int FX_StopAllSounds( void ); +int FX_StartDemandFeedPlayback( void ( *function )( char **ptr, unsigned long *length ), + int rate, int pitchoffset, int vol, int left, int right, + int priority, unsigned long callbackval ); +int FX_StartRecording( int MixRate, void ( *function )( char *ptr, int length ) ); +void FX_StopRecord( void ); + +void FX_Update(void); + +#endif diff --git a/polymer/eduke32/source/jaudiolib/fx_man_fmod.h b/polymer/eduke32/source/jaudiolib/fx_man_fmod.h new file mode 100644 index 000000000..e1b92ae3a --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/fx_man_fmod.h @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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: 1994 - Jim Dose +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#ifndef __FX_MAN_H +#define __FX_MAN_H + + +enum FX_ERRORS + { + FX_Warning = -2, + FX_Error = -1, + FX_Ok = 0, + FX_ASSVersion, + FX_FMODInit + }; + + +char *FX_ErrorString( int ErrorNumber ); +int FX_Init( int SoundCard, int numvoices, int numchannels, int samplebits, unsigned mixrate ); +int FX_Shutdown( void ); +int FX_SetCallBack( void ( *function )( unsigned long ) ); +void FX_SetVolume( int volume ); + +void FX_SetReverseStereo( int setting ); +int FX_GetReverseStereo( void ); +void FX_SetReverb( int reverb ); +void FX_SetReverbDelay( int delay ); + +int FX_VoiceAvailable( int priority ); + +int FX_PlayLoopedVOC( char *ptr, long loopstart, long loopend, + int pitchoffset, int vol, int left, int right, int priority, + unsigned long callbackval ); +int FX_PlayLoopedWAV( char *ptr, long loopstart, long loopend, + int pitchoffset, int vol, int left, int right, int priority, + unsigned long callbackval ); +int FX_PlayVOC3D( char *ptr, int pitchoffset, int angle, int distance, + int priority, unsigned long callbackval ); +int FX_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance, + int priority, unsigned long callbackval ); + +int FX_Pan3D( int handle, int angle, int distance ); +int FX_StopSound( int handle ); +int FX_StopAllSounds( void ); + +int FX_LoadSample(char *ptr, long size, unsigned long number, int priority); +int FX_SampleLoaded(unsigned long number); + +int FX_PlayLoopedSound(int,int,unsigned long); +int FX_PlayPositionedSound(int,int,int,unsigned long); + +int FX_SimulateCallbacks(void); + +#endif diff --git a/polymer/eduke32/source/jaudiolib/linklist.h b/polymer/eduke32/source/jaudiolib/linklist.h new file mode 100644 index 000000000..70a7d9622 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/linklist.h @@ -0,0 +1,119 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +#ifndef __linklist_h +#define __linklist_h +#ifdef __cplusplus +extern "C" { +#endif + + +#define NewNode(type) ((type*)SafeMalloc(sizeof(type))) + + +#define LL_CreateNewLinkedList(rootnode,type,next,prev) \ + { \ + (rootnode) = NewNode(type); \ + (rootnode)->prev = (rootnode); \ + (rootnode)->next = (rootnode); \ + } + + + +#define LL_AddNode(rootnode, newnode, next, prev) \ + { \ + (newnode)->next = (rootnode); \ + (newnode)->prev = (rootnode)->prev; \ + (rootnode)->prev->next = (newnode); \ + (rootnode)->prev = (newnode); \ + } + +#define LL_TransferList(oldroot,newroot,next,prev) \ + { \ + if ((oldroot)->prev != (oldroot)) \ + { \ + (oldroot)->prev->next = (newroot); \ + (oldroot)->next->prev = (newroot)->prev; \ + (newroot)->prev->next = (oldroot)->next; \ + (newroot)->prev = (oldroot)->prev; \ + (oldroot)->next = (oldroot); \ + (oldroot)->prev = (oldroot); \ + } \ + } + +#define LL_ReverseList(root,type,next,prev) \ + { \ + type *newend,*trav,*tprev; \ + \ + newend = (root)->next; \ + for(trav = (root)->prev; trav != newend; trav = tprev) \ + { \ + tprev = trav->prev; \ + LL_MoveNode(trav,newend,next,prev); \ + } \ + } + + +#define LL_RemoveNode(node,next,prev) \ + { \ + (node)->prev->next = (node)->next; \ + (node)->next->prev = (node)->prev; \ + (node)->next = (node); \ + (node)->prev = (node); \ + } + + +#define LL_SortedInsertion(rootnode,insertnode,next,prev,type,sortparm) \ + { \ + type *hoya; \ + \ + hoya = (rootnode)->next; \ + while((hoya != (rootnode)) && ((insertnode)->sortparm > hoya->sortparm)) \ + { \ + hoya = hoya->next; \ + } \ + LL_AddNode(hoya,(insertnode),next,prev); \ + } + +#define LL_MoveNode(node,newroot,next,prev) \ + { \ + LL_RemoveNode((node),next,prev); \ + LL_AddNode((newroot),(node),next,prev); \ + } + +#define LL_ListEmpty(list,next,prev) \ + ( \ + ((list)->next == (list)) && \ + ((list)->prev == (list)) \ + ) + +#define LL_Free(list) SafeFree(list) +#define LL_Reset(list,next,prev) (list)->next = (list)->prev = (list) +#define LL_New LL_CreateNewLinkedList +#define LL_Remove LL_RemoveNode +#define LL_Add LL_AddNode +#define LL_Empty LL_ListEmpty +#define LL_Move LL_MoveNode + + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jaudiolib/ll_man.c b/polymer/eduke32/source/jaudiolib/ll_man.c new file mode 100644 index 000000000..9c169d042 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/ll_man.c @@ -0,0 +1,103 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: LL_MAN.C + + author: James R. Dose + date: January 1, 1994 + + Linked list management routines. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#include +#include "ll_man.h" + +#define OFFSET( structure, offset ) \ + ( *( ( char ** )&( structure )[ offset ] ) ) + + +/********************************************************************** + + Memory locked functions: + +**********************************************************************/ + + +void LL_AddNode + ( + char *item, + char **head, + char **tail, + int next, + int prev + ) + + { + OFFSET( item, prev ) = NULL; + OFFSET( item, next ) = *head; + + if ( *head ) + { + OFFSET( *head, prev ) = item; + } + else + { + *tail = item; + } + + *head = item; + } + +void LL_RemoveNode + ( + char *item, + char **head, + char **tail, + int next, + int prev + ) + + { + if ( OFFSET( item, prev ) == NULL ) + { + *head = OFFSET( item, next ); + } + else + { + OFFSET( OFFSET( item, prev ), next ) = OFFSET( item, next ); + } + + if ( OFFSET( item, next ) == NULL ) + { + *tail = OFFSET( item, prev ); + } + else + { + OFFSET( OFFSET( item, next ), prev ) = OFFSET( item, prev ); + } + + OFFSET( item, next ) = NULL; + OFFSET( item, prev ) = NULL; + } + + diff --git a/polymer/eduke32/source/jaudiolib/ll_man.h b/polymer/eduke32/source/jaudiolib/ll_man.h new file mode 100644 index 000000000..39f1f422e --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/ll_man.h @@ -0,0 +1,75 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: LL_MAN.H + + author: James R. Dose + date: February 4, 1994 + + Public header for LL_MAN.C. Linked list management routines. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __LL_MAN_H +#define __LL_MAN_H + +enum LL_Errors + { + LL_Warning = -2, + LL_Error = -1, + LL_Ok = 0 + }; + +typedef struct list + { + void *start; + void *end; + } list; + +void LL_AddNode( char *node, char **head, char **tail, int next, int prev ); +void LL_RemoveNode( char *node, char **head, char **tail, int next, int prev ); + +#define LL_AddToHead( type, listhead, node ) \ + LL_AddNode( ( char * )( node ), \ + ( char ** )&( ( listhead )->start ), \ + ( char ** )&( ( listhead )->end ), \ + ( int )&( ( type * ) 0 )->next, \ + ( int )&( ( type * ) 0 )->prev ) + +#define LL_AddToTail( type, listhead, node ) \ + LL_AddNode( ( char * )( node ), \ + ( char ** )&( ( listhead )->end ), \ + ( char ** )&( ( listhead )->start ), \ + ( int )&( ( type * ) 0 )->prev, \ + ( int )&( ( type * ) 0 )->next ) + +#define LL_Remove( type, listhead, node ) \ + LL_RemoveNode( ( char * )( node ), \ + ( char ** )&( ( listhead )->start ), \ + ( char ** )&( ( listhead )->end ), \ + ( int )&( ( type * ) 0 )->next, \ + ( int )&( ( type * ) 0 )->prev ) + +#define LL_NextNode( node ) ( ( node )->next ) +#define LL_PreviousNode( node ) ( ( node )->prev ) + +#endif diff --git a/polymer/eduke32/source/jaudiolib/midi.c b/polymer/eduke32/source/jaudiolib/midi.c new file mode 100644 index 000000000..2e144587c --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/midi.c @@ -0,0 +1,2048 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: MIDI.C + + author: James R. Dose + date: May 25, 1994 + + Midi song file playback routines. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#include +#include +#include "standard.h" +#include "usrhooks.h" +#include "music.h" +#include "_midi.h" +#include "midi.h" +#include "mpu401.h" + +#define WIN32_LEAN_AND_MEAN +#include + +static __int64 nexttick, tickdelta; + +extern int MUSIC_SoundDevice; + +static const int _MIDI_CommandLengths[ NUM_MIDI_CHANNELS ] = + { + 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 2, 0 + }; + +static int ( *_MIDI_RerouteFunctions[ NUM_MIDI_CHANNELS ] ) + ( + int event, + int c1, + int c2 + ) = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + +static track *_MIDI_TrackPtr = NULL; +static int _MIDI_TrackMemSize; +static int _MIDI_NumTracks; + +static int _MIDI_SongActive = FALSE; +static int _MIDI_SongLoaded = FALSE; +static int _MIDI_Loop = FALSE; + +static int _MIDI_Division; +static int _MIDI_Tick = 0; +static int _MIDI_Beat = 1; +static int _MIDI_Measure = 1; +static unsigned _MIDI_Time; +static int _MIDI_BeatsPerMeasure; +static int _MIDI_TicksPerBeat; +static int _MIDI_TimeBase; +static long _MIDI_FPSecondsPerTick; +static unsigned _MIDI_TotalTime; +static int _MIDI_TotalTicks; +static int _MIDI_TotalBeats; +static int _MIDI_TotalMeasures; + + unsigned long _MIDI_PositionInTicks; + unsigned long _MIDI_GlobalPositionInTicks; + +static int _MIDI_Context; + +static int _MIDI_ActiveTracks; +static int _MIDI_TotalVolume = MIDI_MaxVolume; + +static int _MIDI_ChannelVolume[ NUM_MIDI_CHANNELS ]; +static int _MIDI_UserChannelVolume[ NUM_MIDI_CHANNELS ] = + { + 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256 + }; + +static midifuncs *_MIDI_Funcs = NULL; + +static int Reset = FALSE; + +int MIDI_Tempo = 120; + +char MIDI_PatchMap[ 128 ]; + + +/********************************************************************** + + Memory locked functions: + +**********************************************************************/ + + +/*--------------------------------------------------------------------- + Function: _MIDI_ReadNumber + + Reads a variable length number from a MIDI track. +---------------------------------------------------------------------*/ + +static long _MIDI_ReadNumber + ( + void *from, + size_t size + ) + + { + unsigned char *FromPtr; + long value; + + if ( size > 4 ) + { + size = 4; + } + + FromPtr = ( unsigned char * )from; + + value = 0; + while( size-- ) + { + value <<= 8; + value += *FromPtr++; + } + + return( value ); + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_ReadDelta + + Reads a variable length encoded delta delay time from the MIDI data. +---------------------------------------------------------------------*/ + +static long _MIDI_ReadDelta + ( + track *ptr + ) + + { + long value; + unsigned char c; + + GET_NEXT_EVENT( ptr, value ); + + if ( value & 0x80 ) + { + value &= 0x7f; + do + { + GET_NEXT_EVENT( ptr, c ); + value = ( value << 7 ) + ( c & 0x7f ); + } + while ( c & 0x80 ); + } + + return( value ); + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_ResetTracks + + Sets the track pointers to the beginning of the song. +---------------------------------------------------------------------*/ + +static void _MIDI_ResetTracks + ( + void + ) + + { + int i; + track *ptr; + + _MIDI_Tick = 0; + _MIDI_Beat = 1; + _MIDI_Measure = 1; + _MIDI_Time = 0; + _MIDI_BeatsPerMeasure = 4; + _MIDI_TicksPerBeat = _MIDI_Division; + _MIDI_TimeBase = 4; + + _MIDI_PositionInTicks = 0; + //_MIDI_GlobalPositionInTicks = 0; + _MIDI_ActiveTracks = 0; + _MIDI_Context = 0; + + ptr = _MIDI_TrackPtr; + for( i = 0; i < _MIDI_NumTracks; i++ ) + { + ptr->pos = ptr->start; + ptr->delay = _MIDI_ReadDelta( ptr ); + ptr->active = ptr->EMIDI_IncludeTrack; + ptr->RunningStatus = 0; + ptr->currentcontext = 0; + ptr->context[ 0 ].loopstart = ptr->start; + ptr->context[ 0 ].loopcount = 0; + + if ( ptr->active ) + { + _MIDI_ActiveTracks++; + } + + ptr++; + } + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_AdvanceTick + + Increment tick counters. +---------------------------------------------------------------------*/ + +static void _MIDI_AdvanceTick + ( + void + ) + + { + _MIDI_PositionInTicks++; + _MIDI_Time += _MIDI_FPSecondsPerTick; + + _MIDI_Tick++; + while( _MIDI_Tick > _MIDI_TicksPerBeat ) + { + _MIDI_Tick -= _MIDI_TicksPerBeat; + _MIDI_Beat++; + } + while( _MIDI_Beat > _MIDI_BeatsPerMeasure ) + { + _MIDI_Beat -= _MIDI_BeatsPerMeasure; + _MIDI_Measure++; + } + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_SysEx + + Interpret SysEx Event. +---------------------------------------------------------------------*/ + +static void _MIDI_SysEx + ( + track *Track + ) + + { + int length; + + length = _MIDI_ReadDelta( Track ); + Track->pos += length; + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_MetaEvent + + Interpret Meta Event. +---------------------------------------------------------------------*/ + +static void _MIDI_MetaEvent + ( + track *Track + ) + + { + int command; + int length; + int denominator; + long tempo; + + GET_NEXT_EVENT( Track, command ); + GET_NEXT_EVENT( Track, length ); + + switch( command ) + { + case MIDI_END_OF_TRACK : + Track->active = FALSE; + + _MIDI_ActiveTracks--; + break; + + case MIDI_TEMPO_CHANGE : + tempo = 60000000L / _MIDI_ReadNumber( Track->pos, 3 ); + MIDI_SetTempo( tempo ); + break; + + case MIDI_TIME_SIGNATURE : + if ( ( _MIDI_Tick > 0 ) || ( _MIDI_Beat > 1 ) ) + { + _MIDI_Measure++; + } + + _MIDI_Tick = 0; + _MIDI_Beat = 1; + + _MIDI_BeatsPerMeasure = (int)*Track->pos; + denominator = (int)*( Track->pos + 1 ); + _MIDI_TimeBase = 1; + while( denominator > 0 ) + { + _MIDI_TimeBase += _MIDI_TimeBase; + denominator--; + } + _MIDI_TicksPerBeat = ( _MIDI_Division * 4 ) / _MIDI_TimeBase; + break; + } + + Track->pos += length; + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_InterpretControllerInfo + + Interprets the MIDI controller info. +---------------------------------------------------------------------*/ + +static int _MIDI_InterpretControllerInfo + ( + track *Track, + int TimeSet, + int channel, + int c1, + int c2 + ) + + { + track *trackptr; + int tracknum; + int loopcount; + + switch( c1 ) + { + case MIDI_MONO_MODE_ON : + Track->pos++; + break; + + case MIDI_VOLUME : + if ( !Track->EMIDI_VolumeChange ) + { + _MIDI_SetChannelVolume( channel, c2 ); + } + break; + + case EMIDI_INCLUDE_TRACK : + case EMIDI_EXCLUDE_TRACK : + break; + + case EMIDI_PROGRAM_CHANGE : + if ( Track->EMIDI_ProgramChange ) + { + _MIDI_Funcs->ProgramChange( channel, MIDI_PatchMap[ c2 & 0x7f ] ); + } + break; + + case EMIDI_VOLUME_CHANGE : + if ( Track->EMIDI_VolumeChange ) + { + _MIDI_SetChannelVolume( channel, c2 ); + } + break; + + case EMIDI_CONTEXT_START : + break; + + case EMIDI_CONTEXT_END : + if ( ( Track->currentcontext == _MIDI_Context ) || + ( _MIDI_Context < 0 ) || + ( Track->context[ _MIDI_Context ].pos == NULL ) ) + { + break; + } + + Track->currentcontext = _MIDI_Context; + Track->context[ 0 ].loopstart = Track->context[ _MIDI_Context ].loopstart; + Track->context[ 0 ].loopcount = Track->context[ _MIDI_Context ].loopcount; + Track->pos = Track->context[ _MIDI_Context ].pos; + Track->RunningStatus = Track->context[ _MIDI_Context ].RunningStatus; + + if ( TimeSet ) + { + break; + } + + _MIDI_Time = Track->context[ _MIDI_Context ].time; + _MIDI_FPSecondsPerTick = Track->context[ _MIDI_Context ].FPSecondsPerTick; + _MIDI_Tick = Track->context[ _MIDI_Context ].tick; + _MIDI_Beat = Track->context[ _MIDI_Context ].beat; + _MIDI_Measure = Track->context[ _MIDI_Context ].measure; + _MIDI_BeatsPerMeasure = Track->context[ _MIDI_Context ].BeatsPerMeasure; + _MIDI_TicksPerBeat = Track->context[ _MIDI_Context ].TicksPerBeat; + _MIDI_TimeBase = Track->context[ _MIDI_Context ].TimeBase; + TimeSet = TRUE; + break; + + case EMIDI_LOOP_START : + case EMIDI_SONG_LOOP_START : + if ( c2 == 0 ) + { + loopcount = EMIDI_INFINITE; + } + else + { + loopcount = c2; + } + + if ( c1 == EMIDI_SONG_LOOP_START ) + { + trackptr = _MIDI_TrackPtr; + tracknum = _MIDI_NumTracks; + } + else + { + trackptr = Track; + tracknum = 1; + } + + while( tracknum > 0 ) + { + trackptr->context[ 0 ].loopcount = loopcount; + trackptr->context[ 0 ].pos = trackptr->pos; + trackptr->context[ 0 ].loopstart = trackptr->pos; + trackptr->context[ 0 ].RunningStatus = trackptr->RunningStatus; + trackptr->context[ 0 ].active = trackptr->active; + trackptr->context[ 0 ].delay = trackptr->delay; + trackptr->context[ 0 ].time = _MIDI_Time; + trackptr->context[ 0 ].FPSecondsPerTick = _MIDI_FPSecondsPerTick; + trackptr->context[ 0 ].tick = _MIDI_Tick; + trackptr->context[ 0 ].beat = _MIDI_Beat; + trackptr->context[ 0 ].measure = _MIDI_Measure; + trackptr->context[ 0 ].BeatsPerMeasure = _MIDI_BeatsPerMeasure; + trackptr->context[ 0 ].TicksPerBeat = _MIDI_TicksPerBeat; + trackptr->context[ 0 ].TimeBase = _MIDI_TimeBase; + trackptr++; + tracknum--; + } + break; + + case EMIDI_LOOP_END : + case EMIDI_SONG_LOOP_END : + if ( ( c2 != EMIDI_END_LOOP_VALUE ) || + ( Track->context[ 0 ].loopstart == NULL ) || + ( Track->context[ 0 ].loopcount == 0 ) ) + { + break; + } + + if ( c1 == EMIDI_SONG_LOOP_END ) + { + trackptr = _MIDI_TrackPtr; + tracknum = _MIDI_NumTracks; + _MIDI_ActiveTracks = 0; + } + else + { + trackptr = Track; + tracknum = 1; + _MIDI_ActiveTracks--; + } + + while( tracknum > 0 ) + { + if ( trackptr->context[ 0 ].loopcount != EMIDI_INFINITE ) + { + trackptr->context[ 0 ].loopcount--; + } + + trackptr->pos = trackptr->context[ 0 ].loopstart; + trackptr->RunningStatus = trackptr->context[ 0 ].RunningStatus; + trackptr->delay = trackptr->context[ 0 ].delay; + trackptr->active = trackptr->context[ 0 ].active; + if ( trackptr->active ) + { + _MIDI_ActiveTracks++; + } + + if ( !TimeSet ) + { + _MIDI_Time = trackptr->context[ 0 ].time; + _MIDI_FPSecondsPerTick = trackptr->context[ 0 ].FPSecondsPerTick; + _MIDI_Tick = trackptr->context[ 0 ].tick; + _MIDI_Beat = trackptr->context[ 0 ].beat; + _MIDI_Measure = trackptr->context[ 0 ].measure; + _MIDI_BeatsPerMeasure = trackptr->context[ 0 ].BeatsPerMeasure; + _MIDI_TicksPerBeat = trackptr->context[ 0 ].TicksPerBeat; + _MIDI_TimeBase = trackptr->context[ 0 ].TimeBase; + TimeSet = TRUE; + } + + trackptr++; + tracknum--; + } + break; + + default : + if ( _MIDI_Funcs->ControlChange ) + { + _MIDI_Funcs->ControlChange( channel, c1, c2 ); + } + } + + return TimeSet; + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_ServiceRoutine + + Task that interperates the MIDI data. +---------------------------------------------------------------------*/ + +static int _MIDI_ServiceRoutine ( void ) +{ + int event; + int channel; + int command; + track *Track; + int tracknum; + int status; + int c1; + int c2; + int TimeSet = FALSE; + + if ( _MIDI_SongActive ) { + Track = _MIDI_TrackPtr; + tracknum = 0; + while( tracknum < _MIDI_NumTracks ) { + while ( ( Track->active ) && ( Track->delay == 0 ) ) { + GET_NEXT_EVENT( Track, event ); + + if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL ) { + switch( event ) { + case MIDI_SYSEX : + case MIDI_SYSEX_CONTINUE : + _MIDI_SysEx( Track ); + break; + + case MIDI_META_EVENT : + _MIDI_MetaEvent( Track ); + break; + } + + if ( Track->active ) { + Track->delay = _MIDI_ReadDelta( Track ); + } + continue; + } + + if ( event & MIDI_RUNNING_STATUS ) { + Track->RunningStatus = event; + } else { + event = Track->RunningStatus; + Track->pos--; + } + + channel = GET_MIDI_CHANNEL( event ); + command = GET_MIDI_COMMAND( event ); + + if ( _MIDI_CommandLengths[ command ] > 0 ) { + GET_NEXT_EVENT( Track, c1 ); + if ( _MIDI_CommandLengths[ command ] > 1 ) { + GET_NEXT_EVENT( Track, c2 ); + } + } + + if ( _MIDI_RerouteFunctions[ channel ] != NULL ) { + status = _MIDI_RerouteFunctions[ channel ]( event, c1, c2 ); + + if ( status == MIDI_DONT_PLAY ) { + Track->delay = _MIDI_ReadDelta( Track ); + continue; + } + } + + switch ( command ) { + case MIDI_NOTE_OFF : + if ( _MIDI_Funcs->NoteOff ) { + _MIDI_Funcs->NoteOff( channel, c1, c2 ); + } + break; + + case MIDI_NOTE_ON : + if ( _MIDI_Funcs->NoteOn ) { + _MIDI_Funcs->NoteOn( channel, c1, c2 ); + } + break; + + case MIDI_POLY_AFTER_TCH : + if ( _MIDI_Funcs->PolyAftertouch ) { + _MIDI_Funcs->PolyAftertouch( channel, c1, c2 ); + } + break; + + case MIDI_CONTROL_CHANGE : + TimeSet = _MIDI_InterpretControllerInfo( Track, TimeSet, channel, c1, c2 ); + break; + + case MIDI_PROGRAM_CHANGE : + if ( ( _MIDI_Funcs->ProgramChange ) && ( !Track->EMIDI_ProgramChange ) ) { + _MIDI_Funcs->ProgramChange( channel, MIDI_PatchMap[ c1 & 0x7f ] ); + } + break; + + case MIDI_AFTER_TOUCH : + if ( _MIDI_Funcs->ChannelAftertouch ) { + _MIDI_Funcs->ChannelAftertouch( channel, c1 ); + } + break; + + case MIDI_PITCH_BEND : + if ( _MIDI_Funcs->PitchBend ) { + _MIDI_Funcs->PitchBend( channel, c1, c2 ); + } + break; + + default : + break; + } + + Track->delay = _MIDI_ReadDelta( Track ); + } + + Track->delay--; + Track++; + tracknum++; + + if ( _MIDI_ActiveTracks == 0 ) { + _MIDI_ResetTracks(); + if ( _MIDI_Loop ) { + tracknum = 0; + Track = _MIDI_TrackPtr; + } else { + _MIDI_SongActive = FALSE; + break; + } + } + } + + _MIDI_AdvanceTick(); + _MIDI_GlobalPositionInTicks++; + } + return 0; +} + + +/*--------------------------------------------------------------------- + Function: _MIDI_SendControlChange + + Sends a control change to the proper device +---------------------------------------------------------------------*/ + +static int _MIDI_SendControlChange + ( + int channel, + int c1, + int c2 + ) + + { + int status; + + if ( _MIDI_RerouteFunctions[ channel ] != NULL ) + { + status = _MIDI_RerouteFunctions[ channel ]( 0xB0 + channel, + c1, c2 ); + if ( status == MIDI_DONT_PLAY ) + { + return( MIDI_Ok ); + } + } + + if ( _MIDI_Funcs == NULL ) + { + return( MIDI_Error ); + } + + if ( _MIDI_Funcs->ControlChange == NULL ) + { + return( MIDI_Error ); + } + + _MIDI_Funcs->ControlChange( channel, c1, c2 ); + + return( MIDI_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_RerouteMidiChannel + + Sets callback function to reroute MIDI commands from specified + function. +---------------------------------------------------------------------*/ + +void MIDI_RerouteMidiChannel + ( + int channel, + int ( *function )( int event, int c1, int c2 ) + ) + + { + if ( ( channel >= 1 ) && ( channel <= 16 ) ) + { + _MIDI_RerouteFunctions[ channel - 1 ] = function; + } + } + + +/*--------------------------------------------------------------------- + Function: MIDI_AllNotesOff + + Sends all notes off commands on all midi channels. +---------------------------------------------------------------------*/ + +int MIDI_AllNotesOff + ( + void + ) + + { + int channel; + + for( channel = 0; channel < NUM_MIDI_CHANNELS; channel++ ) + { + _MIDI_SendControlChange( channel, 0x40, 0 ); + _MIDI_SendControlChange( channel, MIDI_ALL_NOTES_OFF, 0 ); + _MIDI_SendControlChange( channel, 0x78, 0 ); + } + + return( MIDI_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_SetChannelVolume + + Sets the volume of the specified midi channel. +---------------------------------------------------------------------*/ + +static void _MIDI_SetChannelVolume + ( + int channel, + int volume + ) + + { + int status; + int remotevolume; + + _MIDI_ChannelVolume[ channel ] = volume; + + if ( _MIDI_RerouteFunctions[ channel ] != NULL ) + { + remotevolume = volume * _MIDI_TotalVolume; + remotevolume *= _MIDI_UserChannelVolume[ channel ]; + remotevolume /= MIDI_MaxVolume; + remotevolume >>= 8; + + status = _MIDI_RerouteFunctions[ channel ]( 0xB0 + channel, + MIDI_VOLUME, remotevolume ); + if ( status == MIDI_DONT_PLAY ) + { + return; + } + } + + if ( _MIDI_Funcs == NULL ) + { + return; + } + + if ( _MIDI_Funcs->ControlChange == NULL ) + { + return; + } + + // For user volume + volume *= _MIDI_UserChannelVolume[ channel ]; + + if ( _MIDI_Funcs->SetVolume == NULL ) + { + volume *= _MIDI_TotalVolume; + volume /= MIDI_MaxVolume; + } + + // For user volume + volume >>= 8; + + _MIDI_Funcs->ControlChange( channel, MIDI_VOLUME, volume ); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SetUserChannelVolume + + Sets the volume of the specified midi channel. +---------------------------------------------------------------------*/ + +void MIDI_SetUserChannelVolume + ( + int channel, + int volume + ) + + { + // Convert channel from 1-16 to 0-15 + channel--; + + volume = max( 0, volume ); + volume = min( volume, 256 ); + + if ( ( channel >= 0 ) && ( channel < NUM_MIDI_CHANNELS ) ) + { + _MIDI_UserChannelVolume[ channel ] = volume; + _MIDI_SetChannelVolume( channel, _MIDI_ChannelVolume[ channel ] ); + } + } + + +/*--------------------------------------------------------------------- + Function: MIDI_ResetUserChannelVolume + + Sets the volume of the specified midi channel. +---------------------------------------------------------------------*/ + +void MIDI_ResetUserChannelVolume + ( + void + ) + + { + int channel; + + for( channel = 0; channel < NUM_MIDI_CHANNELS; channel++ ) + { + _MIDI_UserChannelVolume[ channel ] = 256; + } + + _MIDI_SendChannelVolumes(); + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_SendChannelVolumes + + Sets the volume on all the midi channels. +---------------------------------------------------------------------*/ + +static void _MIDI_SendChannelVolumes + ( + void + ) + + { + int channel; + + for( channel = 0; channel < NUM_MIDI_CHANNELS; channel++ ) + { + _MIDI_SetChannelVolume( channel, _MIDI_ChannelVolume[ channel ] ); + } + } + + +/*--------------------------------------------------------------------- + Function: MIDI_Reset + + Resets the MIDI device to General Midi defaults. +---------------------------------------------------------------------*/ + +int MIDI_Reset + ( + void + ) + + { + int channel; + long time; + unsigned flags; + + MIDI_AllNotesOff(); + + for( channel = 0; channel < NUM_MIDI_CHANNELS; channel++ ) + { + _MIDI_SendControlChange( channel, MIDI_RESET_ALL_CONTROLLERS, 0 ); + _MIDI_SendControlChange( channel, MIDI_RPN_MSB, MIDI_PITCHBEND_MSB ); + _MIDI_SendControlChange( channel, MIDI_RPN_LSB, MIDI_PITCHBEND_LSB ); + _MIDI_SendControlChange( channel, MIDI_DATAENTRY_MSB, 2 ); /* Pitch Bend Sensitivity MSB */ + _MIDI_SendControlChange( channel, MIDI_DATAENTRY_LSB, 0 ); /* Pitch Bend Sensitivity LSB */ + _MIDI_ChannelVolume[ channel ] = GENMIDI_DefaultVolume; + } + + _MIDI_SendChannelVolumes(); + + Reset = TRUE; + + return( MIDI_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SetVolume + + Sets the total volume of the music. +---------------------------------------------------------------------*/ + +int MIDI_SetVolume + ( + int volume + ) + + { + int i; + + if ( _MIDI_Funcs == NULL ) + { + return( MIDI_NullMidiModule ); + } + + volume = min( MIDI_MaxVolume, volume ); + volume = max( 0, volume ); + + _MIDI_TotalVolume = volume; + + if ( _MIDI_Funcs->SetVolume ) + { + _MIDI_Funcs->SetVolume( volume ); + + for( i = 0; i < NUM_MIDI_CHANNELS; i++ ) + { + if ( _MIDI_RerouteFunctions[ i ] != NULL ) + { + _MIDI_SetChannelVolume( i, _MIDI_ChannelVolume[ i ] ); + } + } + } + else + { + _MIDI_SendChannelVolumes(); + } + + return( MIDI_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_GetVolume + + Returns the total volume of the music. +---------------------------------------------------------------------*/ + +int MIDI_GetVolume + ( + void + ) + + { + int volume; + + if ( _MIDI_Funcs == NULL ) + { + return( MIDI_NullMidiModule ); + } + + if ( _MIDI_Funcs->GetVolume ) + { + volume = _MIDI_Funcs->GetVolume(); + } + else + { + volume = _MIDI_TotalVolume; + } + + return( volume ); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SetContext + + Sets the song context. +---------------------------------------------------------------------*/ + +void MIDI_SetContext + ( + int context + ) + + { + if ( ( context > 0 ) && ( context < EMIDI_NUM_CONTEXTS ) ) + { + _MIDI_Context = context; + } + } + + +/*--------------------------------------------------------------------- + Function: MIDI_GetContext + + Returns the current song context. +---------------------------------------------------------------------*/ + +int MIDI_GetContext + ( + void + ) + + { + return _MIDI_Context; + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SetLoopFlag + + Sets whether the song should loop when finished or not. +---------------------------------------------------------------------*/ + +void MIDI_SetLoopFlag + ( + int loopflag + ) + + { + _MIDI_Loop = loopflag; + } + + +/*--------------------------------------------------------------------- + Function: MIDI_ContinueSong + + Continues playback of a paused song. +---------------------------------------------------------------------*/ + +void MIDI_ContinueSong + ( + void + ) + + { + if ( _MIDI_SongLoaded ) + { + _MIDI_SongActive = TRUE; + MPU_Unpause(); + } + } + + +/*--------------------------------------------------------------------- + Function: MIDI_PauseSong + + Pauses playback of the current song. +---------------------------------------------------------------------*/ + +void MIDI_PauseSong + ( + void + ) + + { + if ( _MIDI_SongLoaded ) + { + _MIDI_SongActive = FALSE; + MIDI_AllNotesOff(); + MPU_Pause(); + } + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SongPlaying + + Returns whether a song is playing or not. +---------------------------------------------------------------------*/ + +int MIDI_SongPlaying + ( + void + ) + + { + return( _MIDI_SongActive ); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SetMidiFuncs + + Selects the routines that send the MIDI data to the music device. +---------------------------------------------------------------------*/ + +void MIDI_SetMidiFuncs + ( + midifuncs *funcs + ) + + { + _MIDI_Funcs = funcs; + } + + +/*--------------------------------------------------------------------- + Function: MIDI_StopSong + + Stops playback of the currently playing song. +---------------------------------------------------------------------*/ + +void MIDI_StopSong + ( + void + ) + + { + if ( _MIDI_SongLoaded ) + { + _MIDI_SongActive = FALSE; + _MIDI_SongLoaded = FALSE; + + MIDI_Reset(); + _MIDI_ResetTracks(); + + if ( _MIDI_Funcs->ReleasePatches ) + { + _MIDI_Funcs->ReleasePatches(); + } + + USRHOOKS_FreeMem( _MIDI_TrackPtr ); + + _MIDI_TrackPtr = NULL; + _MIDI_NumTracks = 0; + _MIDI_TrackMemSize = 0; + + _MIDI_TotalTime = 0; + _MIDI_TotalTicks = 0; + _MIDI_TotalBeats = 0; + _MIDI_TotalMeasures = 0; + + MPU_Reset(); + } + } + + +/*--------------------------------------------------------------------- + Function: MIDI_PlaySong + + Begins playback of a MIDI song. +---------------------------------------------------------------------*/ + +int MIDI_PlaySong + ( + unsigned char *song, + int loopflag + ) + + { + int numtracks; + int format; + long headersize; + long tracklength; + track *CurrentTrack; + unsigned char *ptr; + int status; + DWORD i; + + if ( _MIDI_SongLoaded ) + { + MIDI_StopSong(); + } + + MPU_Init(MUSIC_SoundDevice); + + _MIDI_Loop = loopflag; + + if ( _MIDI_Funcs == NULL ) + { + return( MIDI_NullMidiModule ); + } + + if ( *( unsigned long * )song != MIDI_HEADER_SIGNATURE ) + { + return( MIDI_InvalidMidiFile ); + } + + song += 4; + + headersize = _MIDI_ReadNumber( song, 4 ); + song += 4; + format = _MIDI_ReadNumber( song, 2 ); + _MIDI_NumTracks = _MIDI_ReadNumber( song + 2, 2 ); + _MIDI_Division = _MIDI_ReadNumber( song + 4, 2 ); + if ( _MIDI_Division < 0 ) + { + // If a SMPTE time division is given, just set to 96 so no errors occur + _MIDI_Division = 96; + } + + if ( format > MAX_FORMAT ) + { + return( MIDI_UnknownMidiFormat ); + } + + ptr = song + headersize; + + if ( _MIDI_NumTracks == 0 ) + { + return( MIDI_NoTracks ); + } + + _MIDI_TrackMemSize = _MIDI_NumTracks * sizeof( track ); + status = USRHOOKS_GetMem( (void**)&_MIDI_TrackPtr, _MIDI_TrackMemSize ); + if ( status != USRHOOKS_Ok ) + { + return( MIDI_NoMemory ); + } + + CurrentTrack = _MIDI_TrackPtr; + numtracks = _MIDI_NumTracks; + while( numtracks-- ) + { + if ( *( unsigned long * )ptr != MIDI_TRACK_SIGNATURE ) + { + USRHOOKS_FreeMem( _MIDI_TrackPtr ); + + _MIDI_TrackPtr = NULL; + _MIDI_TrackMemSize = 0; + + return( MIDI_InvalidTrack ); + } + + tracklength = _MIDI_ReadNumber( ptr + 4, 4 ); + ptr += 8; + CurrentTrack->start = ptr; + ptr += tracklength; + CurrentTrack++; + } + + if ( _MIDI_Funcs->GetVolume != NULL ) + { + _MIDI_TotalVolume = _MIDI_Funcs->GetVolume(); + } + + _MIDI_InitEMIDI(); + + if ( _MIDI_Funcs->LoadPatch ) + { + MIDI_LoadTimbres(); + } + + _MIDI_ResetTracks(); + + if ( !Reset ) + { + MIDI_Reset(); + } + + Reset = FALSE; + + MIDI_SetDivision( _MIDI_Division ); + //MIDI_SetTempo( 120 ); + + _MIDI_SongLoaded = TRUE; + _MIDI_SongActive = TRUE; + + while (_MPU_BuffersWaiting < 4) _MIDI_ServiceRoutine(); + MPU_BeginPlayback(); + + return( MIDI_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SetTempo + + Sets the song tempo. +---------------------------------------------------------------------*/ + +void MIDI_SetTempo + ( + int tempo + ) + + { + long tickspersecond; + + MIDI_Tempo = tempo; + tickspersecond = ( ( tempo ) * _MIDI_Division ) / 60; + _MIDI_FPSecondsPerTick = ( 1 << TIME_PRECISION ) / tickspersecond; + MPU_SetTempo(tempo); + } + +void MIDI_SetDivision(int division) +{ + MPU_SetDivision(division); +} + + +/*--------------------------------------------------------------------- + Function: MIDI_GetTempo + + Returns the song tempo. +---------------------------------------------------------------------*/ + +int MIDI_GetTempo + ( + void + ) + + { + return( MIDI_Tempo ); + } + + +/*--------------------------------------------------------------------- + Function: _MIDI_ProcessNextTick + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +static int _MIDI_ProcessNextTick + ( + void + ) + + { + int event; + int channel; + int command; + track *Track; + int tracknum; + int status; + int c1; + int c2; + int TimeSet = FALSE; + + Track = _MIDI_TrackPtr; + tracknum = 0; + while( ( tracknum < _MIDI_NumTracks ) && ( Track != NULL ) ) + { + while ( ( Track->active ) && ( Track->delay == 0 ) ) + { + GET_NEXT_EVENT( Track, event ); + + if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL ) + { + switch( event ) + { + case MIDI_SYSEX : + case MIDI_SYSEX_CONTINUE : + _MIDI_SysEx( Track ); + break; + + case MIDI_META_EVENT : + _MIDI_MetaEvent( Track ); + break; + } + + if ( Track->active ) + { + Track->delay = _MIDI_ReadDelta( Track ); + } + + continue; + } + + if ( event & MIDI_RUNNING_STATUS ) + { + Track->RunningStatus = event; + } + else + { + event = Track->RunningStatus; + Track->pos--; + } + + channel = GET_MIDI_CHANNEL( event ); + command = GET_MIDI_COMMAND( event ); + + if ( _MIDI_CommandLengths[ command ] > 0 ) + { + GET_NEXT_EVENT( Track, c1 ); + if ( _MIDI_CommandLengths[ command ] > 1 ) + { + GET_NEXT_EVENT( Track, c2 ); + } + } + + if ( _MIDI_RerouteFunctions[ channel ] != NULL ) + { + status = _MIDI_RerouteFunctions[ channel ]( event, c1, c2 ); + + if ( status == MIDI_DONT_PLAY ) + { + Track->delay = _MIDI_ReadDelta( Track ); + continue; + } + } + + switch ( command ) + { + case MIDI_NOTE_OFF : + break; + + case MIDI_NOTE_ON : + break; + + case MIDI_POLY_AFTER_TCH : + if ( _MIDI_Funcs->PolyAftertouch ) + { + _MIDI_Funcs->PolyAftertouch( channel, c1, c2 ); + } + break; + + case MIDI_CONTROL_CHANGE : + TimeSet = _MIDI_InterpretControllerInfo( Track, TimeSet, + channel, c1, c2 ); + break; + + case MIDI_PROGRAM_CHANGE : + if ( ( _MIDI_Funcs->ProgramChange ) && + ( !Track->EMIDI_ProgramChange ) ) + { + _MIDI_Funcs->ProgramChange( channel, c1 ); + } + break; + + case MIDI_AFTER_TOUCH : + if ( _MIDI_Funcs->ChannelAftertouch ) + { + _MIDI_Funcs->ChannelAftertouch( channel, c1 ); + } + break; + + case MIDI_PITCH_BEND : + if ( _MIDI_Funcs->PitchBend ) + { + _MIDI_Funcs->PitchBend( channel, c1, c2 ); + } + break; + + default : + break; + } + + Track->delay = _MIDI_ReadDelta( Track ); + } + + Track->delay--; + Track++; + tracknum++; + + if ( _MIDI_ActiveTracks == 0 ) + { + break; + } + } + + _MIDI_AdvanceTick(); + + return( TimeSet ); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SetSongTick + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MIDI_SetSongTick + ( + unsigned long PositionInTicks + ) + + { + if ( !_MIDI_SongLoaded ) + { + return; + } + + MIDI_PauseSong(); + + if ( PositionInTicks < _MIDI_PositionInTicks ) + { + _MIDI_ResetTracks(); + MIDI_Reset(); + } + + while( _MIDI_PositionInTicks < PositionInTicks ) + { + if ( _MIDI_ProcessNextTick() ) + { + break; + } + if ( _MIDI_ActiveTracks == 0 ) + { + _MIDI_ResetTracks(); + if ( !_MIDI_Loop ) + { + return; + } + break; + } + } + + MIDI_SetVolume( _MIDI_TotalVolume ); + MIDI_ContinueSong(); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SetSongTime + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MIDI_SetSongTime + ( + unsigned long milliseconds + ) + + { + unsigned long mil; + unsigned long sec; + unsigned long newtime; + + if ( !_MIDI_SongLoaded ) + { + return; + } + + MIDI_PauseSong(); + + mil = ( ( milliseconds % 1000 ) << TIME_PRECISION ) / 1000; + sec = ( milliseconds / 1000 ) << TIME_PRECISION; + newtime = sec + mil; + + if ( newtime < _MIDI_Time ) + { + _MIDI_ResetTracks(); + MIDI_Reset(); + } + + while( _MIDI_Time < newtime ) + { + if ( _MIDI_ProcessNextTick() ) + { + break; + } + if ( _MIDI_ActiveTracks == 0 ) + { + _MIDI_ResetTracks(); + if ( !_MIDI_Loop ) + { + return; + } + break; + } + } + + MIDI_SetVolume( _MIDI_TotalVolume ); + MIDI_ContinueSong(); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_SetSongPosition + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MIDI_SetSongPosition + ( + int measure, + int beat, + int tick + ) + + { + unsigned long pos; + + if ( !_MIDI_SongLoaded ) + { + return; + } + + MIDI_PauseSong(); + + pos = RELATIVE_BEAT( measure, beat, tick ); + + if ( pos < (unsigned long)RELATIVE_BEAT( _MIDI_Measure, _MIDI_Beat, _MIDI_Tick ) ) + { + _MIDI_ResetTracks(); + MIDI_Reset(); + } + + while( (unsigned long)RELATIVE_BEAT( _MIDI_Measure, _MIDI_Beat, _MIDI_Tick ) < pos ) + { + if ( _MIDI_ProcessNextTick() ) + { + break; + } + if ( _MIDI_ActiveTracks == 0 ) + { + _MIDI_ResetTracks(); + if ( !_MIDI_Loop ) + { + return; + } + break; + } + } + + MIDI_SetVolume( _MIDI_TotalVolume ); + MIDI_ContinueSong(); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_GetSongPosition + + Returns the position of the song pointer in Measures, beats, ticks. +---------------------------------------------------------------------*/ + +void MIDI_GetSongPosition + ( + songposition *pos + ) + + { + unsigned long mil; + unsigned long sec; + + mil = ( _MIDI_Time & ( ( 1 << TIME_PRECISION ) - 1 ) ) * 1000; + sec = _MIDI_Time >> TIME_PRECISION; + pos->milliseconds = ( mil >> TIME_PRECISION ) + ( sec * 1000 ); + pos->tickposition = _MIDI_PositionInTicks; + pos->measure = _MIDI_Measure; + pos->beat = _MIDI_Beat; + pos->tick = _MIDI_Tick; + } + + +/*--------------------------------------------------------------------- + Function: MIDI_GetSongLength + + Returns the length of the song. +---------------------------------------------------------------------*/ + +void MIDI_GetSongLength + ( + songposition *pos + ) + + { + unsigned long mil; + unsigned long sec; + + mil = ( _MIDI_TotalTime & ( ( 1 << TIME_PRECISION ) - 1 ) ) * 1000; + sec = _MIDI_TotalTime >> TIME_PRECISION; + + pos->milliseconds = ( mil >> TIME_PRECISION ) + ( sec * 1000 ); + pos->measure = _MIDI_TotalMeasures; + pos->beat = _MIDI_TotalBeats; + pos->tick = _MIDI_TotalTicks; + pos->tickposition = 0; + } + + +/*--------------------------------------------------------------------- + Function: MIDI_InitEMIDI + + Sets up the EMIDI +---------------------------------------------------------------------*/ + +static void _MIDI_InitEMIDI + ( + void + ) + + { + int event; + int command; + int channel; + int length; + int IncludeFound; + track *Track; + int tracknum; + int type; + int c1; + int c2; + + type = EMIDI_GeneralMIDI; + + _MIDI_ResetTracks(); + + _MIDI_TotalTime = 0; + _MIDI_TotalTicks = 0; + _MIDI_TotalBeats = 0; + _MIDI_TotalMeasures = 0; + + Track = _MIDI_TrackPtr; + tracknum = 0; + while( ( tracknum < _MIDI_NumTracks ) && ( Track != NULL ) ) + { + _MIDI_Tick = 0; + _MIDI_Beat = 1; + _MIDI_Measure = 1; + _MIDI_Time = 0; + _MIDI_BeatsPerMeasure = 4; + _MIDI_TicksPerBeat = _MIDI_Division; + _MIDI_TimeBase = 4; + + _MIDI_PositionInTicks = 0; + _MIDI_ActiveTracks = 0; + _MIDI_Context = -1; + + Track->RunningStatus = 0; + Track->active = TRUE; + + Track->EMIDI_ProgramChange = FALSE; + Track->EMIDI_VolumeChange = FALSE; + Track->EMIDI_IncludeTrack = TRUE; + + memset( Track->context, 0, sizeof( Track->context ) ); + + while( Track->delay > 0 ) + { + _MIDI_AdvanceTick(); + Track->delay--; + } + + IncludeFound = FALSE; + while ( Track->active ) + { + GET_NEXT_EVENT( Track, event ); + + if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL ) + { + switch( event ) + { + case MIDI_SYSEX : + case MIDI_SYSEX_CONTINUE : + _MIDI_SysEx( Track ); + break; + + case MIDI_META_EVENT : + _MIDI_MetaEvent( Track ); + break; + } + + if ( Track->active ) + { + Track->delay = _MIDI_ReadDelta( Track ); + while( Track->delay > 0 ) + { + _MIDI_AdvanceTick(); + Track->delay--; + } + } + + continue; + } + + if ( event & MIDI_RUNNING_STATUS ) + { + Track->RunningStatus = event; + } + else + { + event = Track->RunningStatus; + Track->pos--; + } + + channel = GET_MIDI_CHANNEL( event ); + command = GET_MIDI_COMMAND( event ); + length = _MIDI_CommandLengths[ command ]; + + if ( command == MIDI_CONTROL_CHANGE ) + { + if ( *Track->pos == MIDI_MONO_MODE_ON ) + { + length++; + } + GET_NEXT_EVENT( Track, c1 ); + GET_NEXT_EVENT( Track, c2 ); + length -= 2; + + switch( c1 ) + { + case EMIDI_LOOP_START : + case EMIDI_SONG_LOOP_START : + if ( c2 == 0 ) + { + Track->context[ 0 ].loopcount = EMIDI_INFINITE; + } + else + { + Track->context[ 0 ].loopcount = c2; + } + + Track->context[ 0 ].pos = Track->pos; + Track->context[ 0 ].loopstart = Track->pos; + Track->context[ 0 ].RunningStatus = Track->RunningStatus; + Track->context[ 0 ].time = _MIDI_Time; + Track->context[ 0 ].FPSecondsPerTick = _MIDI_FPSecondsPerTick; + Track->context[ 0 ].tick = _MIDI_Tick; + Track->context[ 0 ].beat = _MIDI_Beat; + Track->context[ 0 ].measure = _MIDI_Measure; + Track->context[ 0 ].BeatsPerMeasure = _MIDI_BeatsPerMeasure; + Track->context[ 0 ].TicksPerBeat = _MIDI_TicksPerBeat; + Track->context[ 0 ].TimeBase = _MIDI_TimeBase; + break; + + case EMIDI_LOOP_END : + case EMIDI_SONG_LOOP_END : + if ( c2 == EMIDI_END_LOOP_VALUE ) + { + Track->context[ 0 ].loopstart = NULL; + Track->context[ 0 ].loopcount = 0; + } + break; + + case EMIDI_INCLUDE_TRACK : + if ( EMIDI_AffectsCurrentCard( c2, type ) ) + { + //printf( "Include track %d on card %d\n", tracknum, c2 ); + IncludeFound = TRUE; + Track->EMIDI_IncludeTrack = TRUE; + } + else if ( !IncludeFound ) + { + //printf( "Track excluded %d on card %d\n", tracknum, c2 ); + IncludeFound = TRUE; + Track->EMIDI_IncludeTrack = FALSE; + } + break; + + case EMIDI_EXCLUDE_TRACK : + if ( EMIDI_AffectsCurrentCard( c2, type ) ) + { + //printf( "Exclude track %d on card %d\n", tracknum, c2 ); + Track->EMIDI_IncludeTrack = FALSE; + } + break; + + case EMIDI_PROGRAM_CHANGE : + if ( !Track->EMIDI_ProgramChange ) + //printf( "Program change on track %d\n", tracknum ); + Track->EMIDI_ProgramChange = TRUE; + break; + + case EMIDI_VOLUME_CHANGE : + if ( !Track->EMIDI_VolumeChange ) + //printf( "Volume change on track %d\n", tracknum ); + Track->EMIDI_VolumeChange = TRUE; + break; + + case EMIDI_CONTEXT_START : + if ( ( c2 > 0 ) && ( c2 < EMIDI_NUM_CONTEXTS ) ) + { + Track->context[ c2 ].pos = Track->pos; + Track->context[ c2 ].loopstart = Track->context[ 0 ].loopstart; + Track->context[ c2 ].loopcount = Track->context[ 0 ].loopcount; + Track->context[ c2 ].RunningStatus = Track->RunningStatus; + Track->context[ c2 ].time = _MIDI_Time; + Track->context[ c2 ].FPSecondsPerTick = _MIDI_FPSecondsPerTick; + Track->context[ c2 ].tick = _MIDI_Tick; + Track->context[ c2 ].beat = _MIDI_Beat; + Track->context[ c2 ].measure = _MIDI_Measure; + Track->context[ c2 ].BeatsPerMeasure = _MIDI_BeatsPerMeasure; + Track->context[ c2 ].TicksPerBeat = _MIDI_TicksPerBeat; + Track->context[ c2 ].TimeBase = _MIDI_TimeBase; + } + break; + + case EMIDI_CONTEXT_END : + break; + } + } + + Track->pos += length; + Track->delay = _MIDI_ReadDelta( Track ); + + while( Track->delay > 0 ) + { + _MIDI_AdvanceTick(); + Track->delay--; + } + } + + _MIDI_TotalTime = max( _MIDI_TotalTime, _MIDI_Time ); + if ( RELATIVE_BEAT( _MIDI_Measure, _MIDI_Beat, _MIDI_Tick ) > + RELATIVE_BEAT( _MIDI_TotalMeasures, _MIDI_TotalBeats, + _MIDI_TotalTicks ) ) + { + _MIDI_TotalTicks = _MIDI_Tick; + _MIDI_TotalBeats = _MIDI_Beat; + _MIDI_TotalMeasures = _MIDI_Measure; + } + + Track++; + tracknum++; + } + + _MIDI_ResetTracks(); + } + + +/*--------------------------------------------------------------------- + Function: MIDI_LoadTimbres + + Preloads the timbres on cards that use patch-caching. +---------------------------------------------------------------------*/ + +void MIDI_LoadTimbres + ( + void + ) + + { + int event; + int command; + int channel; + int length; + int Finished; + track *Track; + int tracknum; + + Track = _MIDI_TrackPtr; + tracknum = 0; + while( ( tracknum < _MIDI_NumTracks ) && ( Track != NULL ) ) + { + Finished = FALSE; + while ( !Finished ) + { + GET_NEXT_EVENT( Track, event ); + + if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL ) + { + switch( event ) + { + case MIDI_SYSEX : + case MIDI_SYSEX_CONTINUE : + length = _MIDI_ReadDelta( Track ); + Track->pos += length; + break; + + case MIDI_META_EVENT : + GET_NEXT_EVENT( Track, command ); + GET_NEXT_EVENT( Track, length ); + + if ( command == MIDI_END_OF_TRACK ) + { + Finished = TRUE; + } + + Track->pos += length; + break; + } + + if ( !Finished ) + { + _MIDI_ReadDelta( Track ); + } + + continue; + } + + if ( event & MIDI_RUNNING_STATUS ) + { + Track->RunningStatus = event; + } + else + { + event = Track->RunningStatus; + Track->pos--; + } + + channel = GET_MIDI_CHANNEL( event ); + command = GET_MIDI_COMMAND( event ); + length = _MIDI_CommandLengths[ command ]; + + if ( command == MIDI_CONTROL_CHANGE ) + { + if ( *Track->pos == MIDI_MONO_MODE_ON ) + { + length++; + } + + if ( *Track->pos == EMIDI_PROGRAM_CHANGE ) + { + _MIDI_Funcs->LoadPatch( *( Track->pos + 1 ) ); + } + } + + if ( channel == MIDI_RHYTHM_CHANNEL ) + { + if ( command == MIDI_NOTE_ON ) + { + _MIDI_Funcs->LoadPatch( 128 + *Track->pos ); + } + } + else + { + if ( command == MIDI_PROGRAM_CHANGE ) + { + _MIDI_Funcs->LoadPatch( *Track->pos ); + } + } + Track->pos += length; + _MIDI_ReadDelta( Track ); + } + Track++; + tracknum++; + } + + _MIDI_ResetTracks(); + } + + +void MIDI_UpdateMusic(void) +{ + if (!_MIDI_SongLoaded || !_MIDI_SongActive) return; + while (_MPU_BuffersWaiting < 4) _MIDI_ServiceRoutine(); +} + diff --git a/polymer/eduke32/source/jaudiolib/midi.h b/polymer/eduke32/source/jaudiolib/midi.h new file mode 100644 index 000000000..343d99536 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/midi.h @@ -0,0 +1,100 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: MIDI.H + + author: James R. Dose + date: May 25, 1994 + + Public header for MIDI.C. Midi song file playback routines. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __MIDI_H +#define __MIDI_H + +enum MIDI_Errors + { + MIDI_Warning = -2, + MIDI_Error = -1, + MIDI_Ok = 0, + MIDI_NullMidiModule, + MIDI_InvalidMidiFile, + MIDI_UnknownMidiFormat, + MIDI_NoTracks, + MIDI_InvalidTrack, + MIDI_NoMemory, + MIDI_DPMI_Error + }; + + +#define MIDI_PASS_THROUGH 1 +#define MIDI_DONT_PLAY 0 + +#define MIDI_MaxVolume 255 + +extern char MIDI_PatchMap[ 128 ]; + +typedef struct + { + void ( *NoteOff )( int channel, int key, int velocity ); + void ( *NoteOn )( int channel, int key, int velocity ); + void ( *PolyAftertouch )( int channel, int key, int pressure ); + void ( *ControlChange )( int channel, int number, int value ); + void ( *ProgramChange )( int channel, int program ); + void ( *ChannelAftertouch )( int channel, int pressure ); + void ( *PitchBend )( int channel, int lsb, int msb ); + void ( *ReleasePatches )( void ); + void ( *LoadPatch )( int number ); + void ( *SetVolume )( int volume ); + int ( *GetVolume )( void ); + void ( *FinishBuffer )( void ); + } midifuncs; + +void MIDI_RerouteMidiChannel( int channel, int ( *function )( int event, int c1, int c2 ) ); +int MIDI_AllNotesOff( void ); +void MIDI_SetUserChannelVolume( int channel, int volume ); +void MIDI_ResetUserChannelVolume( void ); +int MIDI_Reset( void ); +int MIDI_SetVolume( int volume ); +int MIDI_GetVolume( void ); +void MIDI_SetMidiFuncs( midifuncs *funcs ); +void MIDI_SetContext( int context ); +int MIDI_GetContext( void ); +void MIDI_SetLoopFlag( int loopflag ); +void MIDI_ContinueSong( void ); +void MIDI_PauseSong( void ); +int MIDI_SongPlaying( void ); +void MIDI_StopSong( void ); +int MIDI_PlaySong( unsigned char *song, int loopflag ); +void MIDI_SetTempo( int tempo ); +int MIDI_GetTempo( void ); +void MIDI_SetSongTick( unsigned long PositionInTicks ); +void MIDI_SetSongTime( unsigned long milliseconds ); +void MIDI_SetSongPosition( int measure, int beat, int tick ); +void MIDI_GetSongPosition( songposition *pos ); +void MIDI_GetSongLength( songposition *pos ); +void MIDI_LoadTimbres( void ); +void MIDI_UpdateMusic(void); +void MIDI_SetDivision( int division ); + +#endif diff --git a/polymer/eduke32/source/jaudiolib/mpu401.c b/polymer/eduke32/source/jaudiolib/mpu401.c new file mode 100644 index 000000000..988e38a24 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mpu401.c @@ -0,0 +1,475 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: MPU401.C + + author: James R. Dose + date: January 1, 1994 + + Low level routines to support sending of MIDI data to MPU401 + compatible MIDI interfaces. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#include "mpu401.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include + +static HMIDISTRM hmido = (HMIDISTRM)-1; +static MIDIOUTCAPS midicaps; +static DWORD mididevice = -1; + +typedef struct { + long time; + long stream; + long event; +} MIDIEVENTHEAD; +#define PAD(x) ((((x)+3)&(~3))) + +#define BUFFERLEN (32*4*4) +#define NUMBUFFERS 6 +static char eventbuf[NUMBUFFERS][BUFFERLEN]; +static int eventcnt[NUMBUFFERS]; +static MIDIHDR bufferheaders[NUMBUFFERS]; + int _MPU_CurrentBuffer = 0; + int _MPU_BuffersWaiting = 0; + +extern unsigned long _MIDI_GlobalPositionInTicks; +unsigned long _MPU_LastEvent=0; + +#define MIDI_NOTE_OFF 0x80 +#define MIDI_NOTE_ON 0x90 +#define MIDI_POLY_AFTER_TCH 0xA0 +#define MIDI_CONTROL_CHANGE 0xB0 +#define MIDI_PROGRAM_CHANGE 0xC0 +#define MIDI_AFTER_TOUCH 0xD0 +#define MIDI_PITCH_BEND 0xE0 +#define MIDI_META_EVENT 0xFF +#define MIDI_END_OF_TRACK 0x2F +#define MIDI_TEMPO_CHANGE 0x51 +#define MIDI_MONO_MODE_ON 0x7E +#define MIDI_ALL_NOTES_OFF 0x7B + + +/********************************************************************** + + Memory locked functions: + +**********************************************************************/ + + +void MPU_FinishBuffer( int buffer ) +{ + if (!eventcnt[buffer]) return; + ZeroMemory(&bufferheaders[buffer], sizeof(MIDIHDR)); + bufferheaders[buffer].lpData = eventbuf[buffer]; + bufferheaders[buffer].dwBufferLength = + bufferheaders[buffer].dwBytesRecorded = eventcnt[buffer]; + midiOutPrepareHeader((HMIDIOUT)hmido, &bufferheaders[buffer], sizeof(MIDIHDR)); + midiStreamOut(hmido, &bufferheaders[buffer], sizeof(MIDIHDR)); +// printf("Sending %d bytes (buffer %d)\n",eventcnt[buffer],buffer); + _MPU_BuffersWaiting++; +} + +void MPU_BeginPlayback( void ) +{ + _MPU_LastEvent = _MIDI_GlobalPositionInTicks; + if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido); +} + +void MPU_Pause(void) +{ + if (hmido != (HMIDISTRM)-1) midiStreamPause(hmido); +} + +void MPU_Unpause(void) +{ + if (hmido != (HMIDISTRM)-1) midiStreamRestart(hmido); +} + + +void CALLBACK MPU_MIDICallback(HMIDIOUT handle, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) +{ + int i; + switch (uMsg) { + case MOM_DONE: + midiOutUnprepareHeader((HMIDIOUT)handle, (MIDIHDR*)dwParam1, sizeof(MIDIHDR)); + for (i=0;i BUFFERLEN) { + // buffer over-full + nextbuffer = MPU_GetNextBuffer(); + if (nextbuffer < 0) { +// printf("All buffers full!\n"); + return; + } + MPU_FinishBuffer(_MPU_CurrentBuffer); + _MPU_CurrentBuffer = nextbuffer; + } + + p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer]; + ((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent; + ((long*)p)[1] = 0; + ((long*)p)[2] = (MEVT_SHORTMSG << 24) | ((*((long*)data)) & masks[count-1]); + eventcnt[_MPU_CurrentBuffer] += 12; + } else { + padded = PAD(count); + if (eventcnt[_MPU_CurrentBuffer] + 12 + padded > BUFFERLEN) { + // buffer over-full + nextbuffer = MPU_GetNextBuffer(); + if (nextbuffer < 0) { +// printf("All buffers full!\n"); + return; + } + MPU_FinishBuffer(_MPU_CurrentBuffer); + _MPU_CurrentBuffer = nextbuffer; + } + + p = eventbuf[_MPU_CurrentBuffer] + eventcnt[_MPU_CurrentBuffer]; + ((long*)p)[0] = _MIDI_GlobalPositionInTicks - _MPU_LastEvent; + ((long*)p)[1] = 0; + ((long*)p)[2] = (MEVT_LONGMSG<<24) | (count & 0xffffffl); + p+=12; eventcnt[_MPU_CurrentBuffer] += 12; + for (; count>0; count--, padded--, eventcnt[_MPU_CurrentBuffer]++) + *(p++) = *(data++); + for (; padded>0; padded--, eventcnt[_MPU_CurrentBuffer]++) + *(p++) = 0; + } + _MPU_LastEvent = _MIDI_GlobalPositionInTicks; +} + + +/*--------------------------------------------------------------------- + Function: MPU_SendMidiImmediate + + Sends a MIDI message immediately to the the music device. +---------------------------------------------------------------------*/ +void MPU_SendMidiImmediate( char *data, int count ) +{ + MIDIHDR mhdr; + static int masks[3] = { 0x00ffffffl, 0x0000ffffl, 0x000000ffl }; + + if (!count) return; + if (count<=3) midiOutShortMsg((HMIDIOUT)hmido, (*((long*)data)) & masks[count-1]); + else { + ZeroMemory(&mhdr, sizeof(mhdr)); + mhdr.lpData = data; + mhdr.dwBufferLength = count; + midiOutPrepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR)); + midiOutLongMsg((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR)); + while (!(mhdr.dwFlags & MHDR_DONE)) ; + midiOutUnprepareHeader((HMIDIOUT)hmido, &mhdr, sizeof(MIDIHDR)); + } +} + + +/*--------------------------------------------------------------------- + Function: MPU_Reset + + Resets the MPU401 card. +---------------------------------------------------------------------*/ + +int MPU_Reset + ( + void + ) + + { + midiStreamStop(hmido); + midiStreamClose(hmido); + + return( MPU_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MPU_Init + + Detects and initializes the MPU401 card. +---------------------------------------------------------------------*/ + +int MPU_Init + ( + int addr + ) + + { + int i; + + for (i=0;i +#include +#ifndef _MSC_VER +#include +#endif +#include "dsoundout.h" +#include "usrhooks.h" +#include "linklist.h" +#include "pitch.h" +#include "multivoc.h" +#include "_multivc.h" +#include "osd.h" + +#ifdef __MINGW32__ +#define min(a,b) (((a)<(b))?(a):(b)) +#define max(a,b) (((a)>(b))?(a):(b)) +#endif + +#define STEREO 1 +#define SIXTEEN_BIT 2 + +#define MONO_8BIT 0 +#define STEREO_8BIT ( STEREO ) +#define MONO_16BIT ( SIXTEEN_BIT ) +#define STEREO_16BIT ( STEREO | SIXTEEN_BIT ) + +#define RoundFixed( fixedval, bits ) \ + ( \ + ( \ + (fixedval) + ( 1 << ( (bits) - 1 ) )\ + ) >> (bits) \ + ) + +#define IS_QUIET( ptr ) ( ( void * )( ptr ) == ( void * )&MV_VolumeTable[ 0 ] ) + +static int MV_ReverbLevel; +static int MV_ReverbDelay; +static VOLUME16 *MV_ReverbTable = NULL; + +//static signed short MV_VolumeTable[ MV_MaxVolume + 1 ][ 256 ]; +static signed short MV_VolumeTable[ 63 + 1 ][ 256 ]; + +//static Pan MV_PanTable[ MV_NumPanPositions ][ MV_MaxVolume + 1 ]; +static Pan MV_PanTable[ MV_NumPanPositions ][ 63 + 1 ]; + +static int MV_Installed = FALSE; +static int MV_SoundCard = -1; +static int MV_TotalVolume = MV_MaxTotalVolume; +static int MV_MaxVoices = 1; +static int MV_Recording; + +static int MV_BufferSize = 0; +static int MV_BufferLength; + +static int MV_NumberOfBuffers = NumberOfBuffers; + +static int MV_MixMode = MONO_8BIT; +static int MV_Channels = 1; +static int MV_Bits = 8; + +static int MV_Silence = SILENCE_8BIT; +static int MV_SwapLeftRight = FALSE; + +static int MV_RequestedMixRate; +static int MV_MixRate; + +static int MV_BuffShift; + +static int MV_TotalMemory; + +static int MV_BufferEmpty[ NumberOfBuffers ]; +char *MV_MixBuffer[ NumberOfBuffers + 1 ]; +static char *MV_MixBufferPtr = NULL; + +static VoiceNode *MV_Voices = NULL; + +static VoiceNode VoiceList; +static VoiceNode VoicePool; + +static int MV_MixPage = 0; +static int MV_VoiceHandle = MV_MinVoiceHandle; + +static void ( *MV_CallBackFunc )( unsigned long ) = NULL; +static void ( *MV_RecordFunc )( char *ptr, int length ) = NULL; +static void ( *MV_MixFunction )( VoiceNode *voice, int buffer ); + +static int MV_MaxVolume = 63; + +char *MV_HarshClipTable; +char *MV_MixDestination; +short *MV_LeftVolume; +short *MV_RightVolume; +int MV_SampleSize = 1; +int MV_RightChannelOffset; + +unsigned long MV_MixPosition; + +int MV_ErrorCode = MV_Ok; + +#define MV_SetErrorCode( status ) \ + MV_ErrorCode = ( status ); + + +/*--------------------------------------------------------------------- + Function: MV_ErrorString + + Returns a pointer to the error message associated with an error + number. A -1 returns a pointer the current error. +---------------------------------------------------------------------*/ + +char *MV_ErrorString + ( + int ErrorNumber + ) + + { + char *ErrorString; + + switch( ErrorNumber ) + { + case MV_Warning : + case MV_Error : + ErrorString = MV_ErrorString( MV_ErrorCode ); + break; + + case MV_Ok : + ErrorString = "Multivoc ok."; + break; + + case MV_UnsupportedCard : + ErrorString = "Selected sound card is not supported by Multivoc."; + break; + + case MV_NotInstalled : + ErrorString = "Multivoc not installed."; + break; + + case MV_NoVoices : + ErrorString = "No free voices available to Multivoc."; + break; + + case MV_NoMem : + ErrorString = "Out of memory in Multivoc."; + break; + + case MV_VoiceNotFound : + ErrorString = "No voice with matching handle found."; + break; + + case MV_BlasterError : + ErrorString = DSOUND_ErrorString( DSOUND_ErrorCode ); + break; + + case MV_DPMI_Error : + ErrorString = "DPMI Error in Multivoc."; + break; + + case MV_InvalidVOCFile : + ErrorString = "Invalid VOC file passed in to Multivoc."; + break; + + case MV_InvalidWAVFile : + ErrorString = "Invalid WAV file passed in to Multivoc."; + break; + + case MV_InvalidMixMode : + ErrorString = "Invalid mix mode request in Multivoc."; + break; + + case MV_IrqFailure : + ErrorString = "Playback failed, possibly due to an invalid or conflicting IRQ."; + break; + + case MV_DMAFailure : + ErrorString = "Playback failed, possibly due to an invalid or conflicting DMA channel."; + break; + + case MV_DMA16Failure : + ErrorString = "Playback failed, possibly due to an invalid or conflicting DMA channel. \n" + "Make sure the 16-bit DMA channel is correct."; + break; + + case MV_NullRecordFunction : + ErrorString = "Null record function passed to MV_StartRecording."; + break; + + default : + ErrorString = "Unknown Multivoc error code."; + break; + } + + return( ErrorString ); + } + + +/********************************************************************** + + Memory locked functions: + +**********************************************************************/ + + +/*--------------------------------------------------------------------- + Function: MV_GetBufferSize + + Returns the buffer size for the given samplerate. +---------------------------------------------------------------------*/ +#define BASEBUFSZ (512+128) +static unsigned MV_GetBufferSize(unsigned samplerate) +{ + static unsigned lastsr = 0, lastbufsz = 0; + + if (samplerate == lastsr) return lastbufsz; + + lastsr = samplerate; + lastbufsz = (samplerate*BASEBUFSZ/22050)&(~15); + + return lastbufsz; +} + + +/*--------------------------------------------------------------------- + Function: MV_Mix + + Mixes the sound into the buffer. +---------------------------------------------------------------------*/ + +static void MV_Mix + ( + VoiceNode *voice, + int buffer + ) + + { + char *start; + int length; + long voclength; + unsigned long position; + unsigned long rate; + unsigned long FixedPointBufferSize; + + if ( ( voice->length == 0 ) && ( voice->GetSound( voice ) != KeepPlaying ) ) + { + return; + } + + length = MixBufferSize; + FixedPointBufferSize = voice->FixedPointBufferSize; + + MV_MixDestination = MV_MixBuffer[ buffer ]; + MV_LeftVolume = voice->LeftVolume; + MV_RightVolume = voice->RightVolume; + + if ( ( MV_Channels == 2 ) && ( IS_QUIET( MV_LeftVolume ) ) ) + { + MV_LeftVolume = MV_RightVolume; + MV_MixDestination += MV_RightChannelOffset; + } + + // Add this voice to the mix + while( length > 0 ) + { + start = voice->sound; + rate = voice->RateScale; + position = voice->position; + + // Check if the last sample in this buffer would be + // beyond the length of the sample block + if ( ( position + FixedPointBufferSize ) >= voice->length ) + { + if ( position < voice->length ) + { + voclength = ( voice->length - position + rate - 1 ) / rate; + } + else + { + voice->GetSound( voice ); + return; + } + } + else + { + voclength = length; + } + + voice->mix( position, rate, start, voclength ); + + if ( voclength & 1 ) + { + MV_MixPosition += rate; + voclength -= 1; + } + voice->position = MV_MixPosition; + + length -= voclength; + + if ( voice->position >= voice->length ) + { + // Get the next block of sound + if ( voice->GetSound( voice ) != KeepPlaying ) + { + return; + } + + if ( length > 0 ) + { + // Get the position of the last sample in the buffer + FixedPointBufferSize = voice->RateScale * ( length - 1 ); + } + } + } + } + + +/*--------------------------------------------------------------------- + Function: MV_PlayVoice + + Adds a voice to the play list. +---------------------------------------------------------------------*/ + +void MV_PlayVoice + ( + VoiceNode *voice + ) + + { + unsigned flags; + + flags = DisableInterrupts(); + LL_SortedInsertion( &VoiceList, voice, prev, next, VoiceNode, priority ); + + RestoreInterrupts( flags ); + } + + +/*--------------------------------------------------------------------- + Function: MV_StopVoice + + Removes the voice from the play list and adds it to the free list. +---------------------------------------------------------------------*/ + +void MV_StopVoice + ( + VoiceNode *voice + ) + + { + unsigned flags; + + flags = DisableInterrupts(); + + // move the voice from the play list to the free list + LL_Remove( voice, next, prev ); + LL_Add( &VoicePool, voice, next, prev ); + + RestoreInterrupts( flags ); + } + + +/*--------------------------------------------------------------------- + Function: MV_ServiceVoc + + Starts playback of the waiting buffer and mixes the next one. +---------------------------------------------------------------------*/ + +// static int backcolor = 1; + +int MV_ServiceVoc + ( + int buffer + ) + + { + VoiceNode *voice; + VoiceNode *next; + + // Get the currently playing buffer + MV_MixPage = buffer; + + // Toggle which buffer we'll mix next + MV_MixPage++; + if ( MV_MixPage >= MV_NumberOfBuffers ) + { + MV_MixPage -= MV_NumberOfBuffers; + } + + if ( MV_ReverbLevel == 0 ) + { + // Initialize buffer + //Commented out so that the buffer is always cleared. + //This is so the guys at Echo Speech can mix into the + //buffer even when no sounds are playing. + //if ( !MV_BufferEmpty[ MV_MixPage ] ) + { + ClearBuffer_DW( MV_MixBuffer[ MV_MixPage ], MV_Silence, MV_BufferSize >> 2 ); + MV_BufferEmpty[ MV_MixPage ] = TRUE; + } + } + else + { + char *end; + char *source; + char *dest; + int count; + int length; + + end = MV_MixBuffer[ 0 ] + MV_BufferLength; + dest = MV_MixBuffer[ MV_MixPage ]; + source = MV_MixBuffer[ MV_MixPage ] - MV_ReverbDelay; + if ( source < MV_MixBuffer[ 0 ] ) + { + source += MV_BufferLength; + } + + length = MV_BufferSize; + while( length > 0 ) + { + count = length; + if ( source + count > end ) + { + count = end - source; + } + + if ( MV_Bits == 16 ) + { + if ( MV_ReverbTable != NULL ) + { + MV_16BitReverb( source, dest, MV_ReverbTable, count / 2 ); + } + else + { + MV_16BitReverbFast( source, dest, count / 2, MV_ReverbLevel ); + } + } + else + { + if ( MV_ReverbTable != NULL ) + { + MV_8BitReverb( source, dest, MV_ReverbTable, count ); + } + else + { + MV_8BitReverbFast( source, dest, count, MV_ReverbLevel ); + } + } + + // if we go through the loop again, it means that we've wrapped around the buffer + source = MV_MixBuffer[ 0 ]; + dest += count; + length -= count; + } + } + + // Play any waiting voices + for( voice = VoiceList.next; voice != &VoiceList; voice = next ) + { +// if ( ( voice < &MV_Voices[ 0 ] ) || ( voice > &MV_Voices[ 8 ] ) ) +// { +// SetBorderColor(backcolor++); +// break; +// } + + MV_BufferEmpty[ MV_MixPage ] = FALSE; + + MV_MixFunction( voice, MV_MixPage ); + + next = voice->next; + + // Is this voice done? + if ( !voice->Playing ) + { + MV_StopVoice( voice ); + + if ( MV_CallBackFunc ) + { + MV_CallBackFunc( voice->callbackval ); + } + } + } + + return MV_MixPage; + } + + +/*--------------------------------------------------------------------- + Function: MV_GetNextVOCBlock + + Interperate the information of a VOC format sound file. +---------------------------------------------------------------------*/ + +playbackstatus MV_GetNextVOCBlock + ( + VoiceNode *voice + ) + + { + unsigned char *ptr; + int blocktype; + int lastblocktype; + unsigned long blocklength; + unsigned long samplespeed; + unsigned int tc; + int packtype; + int voicemode; + int done; + unsigned BitsPerSample; + unsigned Channels; + unsigned Format; + + if ( voice->BlockLength > 0 ) + { + voice->position -= voice->length; + voice->sound += voice->length >> 16; + if ( voice->bits == 16 ) + { + voice->sound += voice->length >> 16; + } + voice->length = min( voice->BlockLength, 0x8000 ); + voice->BlockLength -= voice->length; + voice->length <<= 16; + return( KeepPlaying ); + } + + if ( ( voice->length > 0 ) && ( voice->LoopEnd != NULL ) && + ( voice->LoopStart != NULL ) ) + { + voice->BlockLength = voice->LoopSize; + voice->sound = voice->LoopStart; + voice->position = 0; + voice->length = min( voice->BlockLength, 0x8000 ); + voice->BlockLength -= voice->length; + voice->length <<= 16; + return( KeepPlaying ); + } + + ptr = ( unsigned char * )voice->NextBlock; + + voice->Playing = TRUE; + + voicemode = 0; + lastblocktype = 0; + packtype = 0; + + done = FALSE; + while( !done ) + { + // Stop playing if we get a NULL pointer + if ( ptr == NULL ) + { + voice->Playing = FALSE; + done = TRUE; + break; + } + + blocktype = ( int )*ptr; + blocklength = ( *( unsigned long * )( ptr + 1 ) ) & 0x00ffffff; + ptr += 4; + + switch( blocktype ) + { + case 0 : + // End of data + if ( ( voice->LoopStart == NULL ) || + ( voice->LoopStart >= ( ptr - 4 ) ) ) + { + voice->Playing = FALSE; + done = TRUE; + } + else + { + voice->BlockLength = (char*)( ptr - 4 ) - voice->LoopStart; + voice->sound = voice->LoopStart; + voice->position = 0; + voice->length = min( voice->BlockLength, 0x8000 ); + voice->BlockLength -= voice->length; + voice->length <<= 16; + return( KeepPlaying ); + } + break; + + case 1 : + // Sound data block + voice->bits = 8; + if ( lastblocktype != 8 ) + { + tc = ( unsigned int )*ptr << 8; + packtype = *( ptr + 1 ); + } + + ptr += 2; + blocklength -= 2; + + samplespeed = 256000000L / ( 65536 - tc ); + + // Skip packed or stereo data + if ( ( packtype != 0 ) || ( voicemode != 0 ) ) + { + ptr += blocklength; + } + else + { + done = TRUE; + } + voicemode = 0; + break; + + case 2 : + // Sound continuation block + samplespeed = voice->SamplingRate; + done = TRUE; + break; + + case 3 : + // Silence + // Not implimented. + ptr += blocklength; + break; + + case 4 : + // Marker + // Not implimented. + ptr += blocklength; + break; + + case 5 : + // ASCII string + // Not implimented. + ptr += blocklength; + break; + + case 6 : + // Repeat begin + if ( voice->LoopEnd == NULL ) + { + voice->LoopCount = *( unsigned short * )ptr; + voice->LoopStart = ptr + blocklength; + } + ptr += blocklength; + break; + + case 7 : + // Repeat end + ptr += blocklength; + if ( lastblocktype == 6 ) + { + voice->LoopCount = 0; + } + else + { + if ( ( voice->LoopCount > 0 ) && ( voice->LoopStart != NULL ) ) + { + ptr = voice->LoopStart; + if ( voice->LoopCount < 0xffff ) + { + voice->LoopCount--; + if ( voice->LoopCount == 0 ) + { + voice->LoopStart = NULL; + } + } + } + } + break; + + case 8 : + // Extended block + voice->bits = 8; + tc = *( unsigned short * )ptr; + packtype = *( ptr + 2 ); + voicemode = *( ptr + 3 ); + ptr += blocklength; + break; + + case 9 : + // New sound data block + samplespeed = *( unsigned long * )ptr; + BitsPerSample = ( unsigned )*( ptr + 4 ); + Channels = ( unsigned )*( ptr + 5 ); + Format = ( unsigned )*( unsigned short * )( ptr + 6 ); + + if ( ( BitsPerSample == 8 ) && ( Channels == 1 ) && + ( Format == VOC_8BIT ) ) + { + ptr += 12; + blocklength -= 12; + voice->bits = 8; + done = TRUE; + } + else if ( ( BitsPerSample == 16 ) && ( Channels == 1 ) && + ( Format == VOC_16BIT ) ) + { + ptr += 12; + blocklength -= 12; + voice->bits = 16; + done = TRUE; + } + else + { + ptr += blocklength; + } + break; + + default : + // Unknown data. Probably not a VOC file. + voice->Playing = FALSE; + done = TRUE; + break; + } + + lastblocktype = blocktype; + } + + if ( voice->Playing ) + { + voice->NextBlock = ptr + blocklength; + voice->sound = ptr; + + voice->SamplingRate = samplespeed; + voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate; + + // Multiply by MixBufferSize - 1 + voice->FixedPointBufferSize = ( voice->RateScale * MixBufferSize ) - + voice->RateScale; + + if ( voice->LoopEnd != NULL ) + { + if ( blocklength > ( unsigned long )voice->LoopEnd ) + { + blocklength = ( unsigned long )voice->LoopEnd; + } + else + { + voice->LoopEnd = ( char * )blocklength; + } + + voice->LoopStart = voice->sound + ( unsigned long )voice->LoopStart; + voice->LoopEnd = voice->sound + ( unsigned long )voice->LoopEnd; + voice->LoopSize = voice->LoopEnd - voice->LoopStart; + } + + if ( voice->bits == 16 ) + { + blocklength /= 2; + } + + voice->position = 0; + voice->length = min( blocklength, 0x8000 ); + voice->BlockLength = blocklength - voice->length; + voice->length <<= 16; + + MV_SetVoiceMixMode( voice ); + + return( KeepPlaying ); + } + + return( NoMoreData ); + } + + +/*--------------------------------------------------------------------- + Function: MV_GetNextDemandFeedBlock + + Controls playback of demand fed data. +---------------------------------------------------------------------*/ + +playbackstatus MV_GetNextDemandFeedBlock + ( + VoiceNode *voice + ) + + { + if ( voice->BlockLength > 0 ) + { + voice->position -= voice->length; + voice->sound += voice->length >> 16; + voice->length = min( voice->BlockLength, 0x8000 ); + voice->BlockLength -= voice->length; + voice->length <<= 16; + + return( KeepPlaying ); + } + + if ( voice->DemandFeed == NULL ) + { + return( NoMoreData ); + } + + voice->position = 0; + ( voice->DemandFeed )( &voice->sound, &voice->BlockLength ); + voice->length = min( voice->BlockLength, 0x8000 ); + voice->BlockLength -= voice->length; + voice->length <<= 16; + + if ( ( voice->length > 0 ) && ( voice->sound != NULL ) ) + { + return( KeepPlaying ); + } + return( NoMoreData ); + } + + +/*--------------------------------------------------------------------- + Function: MV_GetNextRawBlock + + Controls playback of demand fed data. +---------------------------------------------------------------------*/ + +playbackstatus MV_GetNextRawBlock + ( + VoiceNode *voice + ) + + { + if ( voice->BlockLength <= 0 ) + { + if ( voice->LoopStart == NULL ) + { + voice->Playing = FALSE; + return( NoMoreData ); + } + + voice->BlockLength = voice->LoopSize; + voice->NextBlock = voice->LoopStart; + voice->length = 0; + voice->position = 0; + } + + voice->sound = voice->NextBlock; + voice->position -= voice->length; + voice->length = min( voice->BlockLength, 0x8000 ); + voice->NextBlock += voice->length; + if ( voice->bits == 16 ) + { + voice->NextBlock += voice->length; + } + voice->BlockLength -= voice->length; + voice->length <<= 16; + + return( KeepPlaying ); + } + + +/*--------------------------------------------------------------------- + Function: MV_GetNextWAVBlock + + Controls playback of demand fed data. +---------------------------------------------------------------------*/ + +playbackstatus MV_GetNextWAVBlock + ( + VoiceNode *voice + ) + + { + if ( voice->BlockLength <= 0 ) + { + if ( voice->LoopStart == NULL ) + { + voice->Playing = FALSE; + return( NoMoreData ); + } + + voice->BlockLength = voice->LoopSize; + voice->NextBlock = voice->LoopStart; + voice->length = 0; + voice->position = 0; + } + + voice->sound = voice->NextBlock; + voice->position -= voice->length; + voice->length = min( voice->BlockLength, 0x8000 ); + voice->NextBlock += voice->length; + if ( voice->bits == 16 ) + { + voice->NextBlock += voice->length; + } + voice->BlockLength -= voice->length; + voice->length <<= 16; + + return( KeepPlaying ); + } + + +/*--------------------------------------------------------------------- + Function: MV_ServiceRecord + + Starts recording of the waiting buffer. +---------------------------------------------------------------------*/ + +static void MV_ServiceRecord + ( + void + ) + + { + if ( MV_RecordFunc ) + { + MV_RecordFunc( MV_MixBuffer[ 0 ] + MV_MixPage * MixBufferSize, + MixBufferSize ); + } + + // Toggle which buffer we'll mix next + MV_MixPage++; + if ( MV_MixPage >= NumberOfBuffers ) + { + MV_MixPage = 0; + } + } + + +/*--------------------------------------------------------------------- + Function: MV_GetVoice + + Locates the voice with the specified handle. +---------------------------------------------------------------------*/ + +VoiceNode *MV_GetVoice + ( + int handle + ) + + { + VoiceNode *voice; + unsigned flags; + + flags = DisableInterrupts(); + + for( voice = VoiceList.next; voice != &VoiceList; voice = voice->next ) + { + if ( handle == voice->handle ) + { + break; + } + } + + RestoreInterrupts( flags ); + + if ( voice == &VoiceList ) + { + MV_SetErrorCode( MV_VoiceNotFound ); + voice = NULL; + } + + return( voice ); + } + + +/*--------------------------------------------------------------------- + Function: MV_VoicePlaying + + Checks if the voice associated with the specified handle is + playing. +---------------------------------------------------------------------*/ + +int MV_VoicePlaying + ( + int handle + ) + + { + VoiceNode *voice; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( FALSE ); + } + + voice = MV_GetVoice( handle ); + + if ( voice == NULL ) + { + return( FALSE ); + } + + return( TRUE ); + } + + +/*--------------------------------------------------------------------- + Function: MV_KillAllVoices + + Stops output of all currently active voices. +---------------------------------------------------------------------*/ + +int MV_KillAllVoices + ( + void + ) + + { + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + // Remove all the voices from the list + while( VoiceList.next != &VoiceList ) + { + MV_Kill( VoiceList.next->handle ); + } + + return( MV_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MV_Kill + + Stops output of the voice associated with the specified handle. +---------------------------------------------------------------------*/ + +int MV_Kill + ( + int handle + ) + + { + VoiceNode *voice; + unsigned flags; + unsigned long callbackval; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + flags = DisableInterrupts(); + + voice = MV_GetVoice( handle ); + if ( voice == NULL ) + { + RestoreInterrupts( flags ); + MV_SetErrorCode( MV_VoiceNotFound ); + return( MV_Error ); + } + + callbackval = voice->callbackval; + + MV_StopVoice( voice ); + + RestoreInterrupts( flags ); + + if ( MV_CallBackFunc ) + { + MV_CallBackFunc( callbackval ); + } + + return( MV_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MV_VoicesPlaying + + Determines the number of currently active voices. +---------------------------------------------------------------------*/ + +int MV_VoicesPlaying + ( + void + ) + + { + VoiceNode *voice; + int NumVoices = 0; + unsigned flags; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( 0 ); + } + + flags = DisableInterrupts(); + + for( voice = VoiceList.next; voice != &VoiceList; voice = voice->next ) + { + NumVoices++; + } + + RestoreInterrupts( flags ); + + return( NumVoices ); + } + + +/*--------------------------------------------------------------------- + Function: MV_AllocVoice + + Retrieve an inactive or lower priority voice for output. +---------------------------------------------------------------------*/ + +VoiceNode *MV_AllocVoice + ( + int priority + ) + + { + VoiceNode *voice; + VoiceNode *node; + unsigned flags; + +//return( NULL ); + if ( MV_Recording ) + { + return( NULL ); + } + + flags = DisableInterrupts(); + + // Check if we have any free voices + if ( LL_Empty( &VoicePool, next, prev ) ) + { + // check if we have a higher priority than a voice that is playing. + voice = VoiceList.next; + for( node = voice->next; node != &VoiceList; node = node->next ) + { + if ( node->priority < voice->priority ) + { + voice = node; + } + } + + if ( priority >= voice->priority ) + { + MV_Kill( voice->handle ); + } + } + + // Check if any voices are in the voice pool + if ( LL_Empty( &VoicePool, next, prev ) ) + { + // No free voices + RestoreInterrupts( flags ); + return( NULL ); + } + + voice = VoicePool.next; + LL_Remove( voice, next, prev ); + RestoreInterrupts( flags ); + + // Find a free voice handle + do + { + MV_VoiceHandle++; + if ( MV_VoiceHandle < MV_MinVoiceHandle ) + { + MV_VoiceHandle = MV_MinVoiceHandle; + } + } + while( MV_VoicePlaying( MV_VoiceHandle ) ); + + voice->handle = MV_VoiceHandle; + + return( voice ); + } + + +/*--------------------------------------------------------------------- + Function: MV_VoiceAvailable + + Checks if a voice can be play at the specified priority. +---------------------------------------------------------------------*/ + +int MV_VoiceAvailable + ( + int priority + ) + + { + VoiceNode *voice; + VoiceNode *node; + unsigned flags; + + // Check if we have any free voices + if ( !LL_Empty( &VoicePool, next, prev ) ) + { + return( TRUE ); + } + + flags = DisableInterrupts(); + + // check if we have a higher priority than a voice that is playing. + voice = VoiceList.next; + for( node = VoiceList.next; node != &VoiceList; node = node->next ) + { + if ( node->priority < voice->priority ) + { + voice = node; + } + } + + RestoreInterrupts( flags ); + + if ( ( voice != &VoiceList ) && ( priority >= voice->priority ) ) + { + return( TRUE ); + } + + return( FALSE ); + } + + +/*--------------------------------------------------------------------- + Function: MV_SetVoicePitch + + Sets the pitch for the specified voice. +---------------------------------------------------------------------*/ + +void MV_SetVoicePitch + ( + VoiceNode *voice, + unsigned long rate, + int pitchoffset + ) + + { + voice->SamplingRate = rate; + voice->PitchScale = PITCH_GetScale( pitchoffset ); + voice->RateScale = ( rate * voice->PitchScale ) / MV_MixRate; + + // Multiply by MixBufferSize - 1 + voice->FixedPointBufferSize = ( voice->RateScale * MixBufferSize ) - + voice->RateScale; + } + + +/*--------------------------------------------------------------------- + Function: MV_SetPitch + + Sets the pitch for the voice associated with the specified handle. +---------------------------------------------------------------------*/ + +int MV_SetPitch + ( + int handle, + int pitchoffset + ) + + { + VoiceNode *voice; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + voice = MV_GetVoice( handle ); + if ( voice == NULL ) + { + MV_SetErrorCode( MV_VoiceNotFound ); + return( MV_Error ); + } + + MV_SetVoicePitch( voice, voice->SamplingRate, pitchoffset ); + + return( MV_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MV_SetFrequency + + Sets the frequency for the voice associated with the specified handle. +---------------------------------------------------------------------*/ + +int MV_SetFrequency + ( + int handle, + int frequency + ) + + { + VoiceNode *voice; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + voice = MV_GetVoice( handle ); + if ( voice == NULL ) + { + MV_SetErrorCode( MV_VoiceNotFound ); + return( MV_Error ); + } + + MV_SetVoicePitch( voice, frequency, 0 ); + + return( MV_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MV_GetVolumeTable + + Returns a pointer to the volume table associated with the specified + volume. +---------------------------------------------------------------------*/ + +static short *MV_GetVolumeTable + ( + int vol + ) + + { + int volume; + short *table; + + volume = MIX_VOLUME( vol ); + + table = (short*)&MV_VolumeTable[ volume ]; + + return( table ); + } + + +/*--------------------------------------------------------------------- + Function: MV_SetVoiceMixMode + + Selects which method should be used to mix the voice. +---------------------------------------------------------------------*/ + +static void MV_SetVoiceMixMode + ( + VoiceNode *voice + ) + + { + unsigned flags; + int test; + + flags = DisableInterrupts(); + + test = T_DEFAULT; + if ( MV_Bits == 8 ) + { + test |= T_8BITS; + } + + if ( voice->bits == 16 ) + { + test |= T_16BITSOURCE; + } + + if ( MV_Channels == 1 ) + { + test |= T_MONO; + } + else + { + if ( IS_QUIET( voice->RightVolume ) ) + { + test |= T_RIGHTQUIET; + } + else if ( IS_QUIET( voice->LeftVolume ) ) + { + test |= T_LEFTQUIET; + } + } + + // Default case + voice->mix = MV_Mix8BitMono; + + switch( test ) + { + case T_8BITS | T_MONO | T_16BITSOURCE : + voice->mix = MV_Mix8BitMono16; + break; + + case T_8BITS | T_MONO : + voice->mix = MV_Mix8BitMono; + break; + + case T_8BITS | T_16BITSOURCE | T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix8BitMono16; + break; + + case T_8BITS | T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix8BitMono; + break; + + case T_8BITS | T_16BITSOURCE | T_RIGHTQUIET : + voice->mix = MV_Mix8BitMono16; + break; + + case T_8BITS | T_RIGHTQUIET : + voice->mix = MV_Mix8BitMono; + break; + + case T_8BITS | T_16BITSOURCE : + voice->mix = MV_Mix8BitStereo16; + break; + + case T_8BITS : + voice->mix = MV_Mix8BitStereo; + break; + + case T_MONO | T_16BITSOURCE : + voice->mix = MV_Mix16BitMono16; + break; + + case T_MONO : + voice->mix = MV_Mix16BitMono; + break; + + case T_16BITSOURCE | T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix16BitMono16; + break; + + case T_LEFTQUIET : + MV_LeftVolume = MV_RightVolume; + voice->mix = MV_Mix16BitMono; + break; + + case T_16BITSOURCE | T_RIGHTQUIET : + voice->mix = MV_Mix16BitMono16; + break; + + case T_RIGHTQUIET : + voice->mix = MV_Mix16BitMono; + break; + + case T_16BITSOURCE : + voice->mix = MV_Mix16BitStereo16; + break; + + case T_SIXTEENBIT_STEREO : + voice->mix = MV_Mix16BitStereo; + break; + + default : + voice->mix = MV_Mix8BitMono; + } + + RestoreInterrupts( flags ); + } + + +/*--------------------------------------------------------------------- + Function: MV_SetVoiceVolume + + Sets the stereo and mono volume level of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +void MV_SetVoiceVolume + ( + VoiceNode *voice, + int vol, + int left, + int right + ) + + { + if ( MV_Channels == 1 ) + { + left = vol; + right = vol; + } + + if ( MV_SwapLeftRight ) + { + // SBPro uses reversed panning + voice->LeftVolume = MV_GetVolumeTable( right ); + voice->RightVolume = MV_GetVolumeTable( left ); + } + else + { + voice->LeftVolume = MV_GetVolumeTable( left ); + voice->RightVolume = MV_GetVolumeTable( right ); + } + + MV_SetVoiceMixMode( voice ); + } + + +/*--------------------------------------------------------------------- + Function: MV_EndLooping + + Stops the voice associated with the specified handle from looping + without stoping the sound. +---------------------------------------------------------------------*/ + +int MV_EndLooping + ( + int handle + ) + + { + VoiceNode *voice; + unsigned flags; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + flags = DisableInterrupts(); + + voice = MV_GetVoice( handle ); + if ( voice == NULL ) + { + RestoreInterrupts( flags ); + MV_SetErrorCode( MV_VoiceNotFound ); + return( MV_Warning ); + } + + voice->LoopCount = 0; + voice->LoopStart = NULL; + voice->LoopEnd = NULL; + + RestoreInterrupts( flags ); + + return( MV_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MV_SetPan + + Sets the stereo and mono volume level of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +int MV_SetPan + ( + int handle, + int vol, + int left, + int right + ) + + { + VoiceNode *voice; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + voice = MV_GetVoice( handle ); + if ( voice == NULL ) + { + MV_SetErrorCode( MV_VoiceNotFound ); + return( MV_Warning ); + } + + MV_SetVoiceVolume( voice, vol, left, right ); + + return( MV_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MV_Pan3D + + Set the angle and distance from the listener of the voice associated + with the specified handle. +---------------------------------------------------------------------*/ + +int MV_Pan3D + ( + int handle, + int angle, + int distance + ) + + { + int left; + int right; + int mid; + int volume; + int status; + + if ( distance < 0 ) + { + distance = -distance; + angle += MV_NumPanPositions / 2; + } + + volume = MIX_VOLUME( distance ); + + // Ensure angle is within 0 - 31 + angle &= MV_MaxPanPosition; + + left = MV_PanTable[ angle ][ volume ].left; + right = MV_PanTable[ angle ][ volume ].right; + mid = max( 0, 255 - distance ); + + status = MV_SetPan( handle, mid, left, right ); + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MV_SetReverb + + Sets the level of reverb to add to mix. +---------------------------------------------------------------------*/ + +void MV_SetReverb + ( + int reverb + ) + + { + MV_ReverbLevel = MIX_VOLUME( reverb ); + MV_ReverbTable = &MV_VolumeTable[ MV_ReverbLevel ]; + } + + +/*--------------------------------------------------------------------- + Function: MV_SetFastReverb + + Sets the level of reverb to add to mix. +---------------------------------------------------------------------*/ + +void MV_SetFastReverb + ( + int reverb + ) + + { + MV_ReverbLevel = max( 0, min( 16, reverb ) ); + MV_ReverbTable = NULL; + } + + +/*--------------------------------------------------------------------- + Function: MV_GetMaxReverbDelay + + Returns the maximum delay time for reverb. +---------------------------------------------------------------------*/ + +int MV_GetMaxReverbDelay + ( + void + ) + + { + int maxdelay; + + maxdelay = MixBufferSize * MV_NumberOfBuffers; + + return maxdelay; + } + + +/*--------------------------------------------------------------------- + Function: MV_GetReverbDelay + + Returns the current delay time for reverb. +---------------------------------------------------------------------*/ + +int MV_GetReverbDelay + ( + void + ) + + { + return MV_ReverbDelay / MV_SampleSize; + } + + +/*--------------------------------------------------------------------- + Function: MV_SetReverbDelay + + Sets the delay level of reverb to add to mix. +---------------------------------------------------------------------*/ + +void MV_SetReverbDelay + ( + int delay + ) + + { + int maxdelay; + + maxdelay = MV_GetMaxReverbDelay(); + MV_ReverbDelay = max( MixBufferSize, min( delay, maxdelay ) ); + MV_ReverbDelay *= MV_SampleSize; + } + + +/*--------------------------------------------------------------------- + Function: MV_SetMixMode + + Prepares Multivoc to play stereo of mono digitized sounds. +---------------------------------------------------------------------*/ + +int MV_SetMixMode + ( + int numchannels, + int samplebits + ) + + { + int mode; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + mode = 0; + if ( numchannels == 2 ) + { + mode |= STEREO; + } + if ( samplebits == 16 ) + { + mode |= SIXTEEN_BIT; + } + + MV_MixMode = DSOUND_SetMixMode( mode ); + + MV_Channels = 1; + if ( MV_MixMode & STEREO ) + { + MV_Channels = 2; + } + + MV_Bits = 8; + if ( MV_MixMode & SIXTEEN_BIT ) + { + MV_Bits = 16; + } + + MV_BuffShift = 7 + MV_Channels; + MV_SampleSize = sizeof( MONO8 ) * MV_Channels; + + if ( MV_Bits == 8 ) + { + MV_Silence = SILENCE_8BIT; + } + else + { + MV_Silence = SILENCE_16BIT; + MV_BuffShift += 1; + MV_SampleSize *= 2; + } + + MV_BufferSize = MixBufferSize * MV_SampleSize; + MV_NumberOfBuffers = TotalBufferSize / MV_BufferSize; + MV_BufferLength = TotalBufferSize; + + MV_RightChannelOffset = MV_SampleSize / 2; + + return( MV_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MV_StartPlayback + + Starts the sound playback engine. +---------------------------------------------------------------------*/ + +int MV_StartPlayback + ( + void + ) + + { + int status; + int buffer; + + // Initialize the buffers + ClearBuffer_DW( MV_MixBuffer[ 0 ], MV_Silence, TotalBufferSize >> 2 ); + for( buffer = 0; buffer < MV_NumberOfBuffers; buffer++ ) + { + MV_BufferEmpty[ buffer ] = TRUE; + } + + // Set the mix buffer variables + MV_MixPage = 1; + + MV_MixFunction = MV_Mix; + + MV_MixRate = MV_RequestedMixRate; + + // Start playback + status = DSOUND_BeginBufferedPlayback( MV_MixBuffer[ 0 ], MV_ServiceVoc, TotalBufferSize, MV_NumberOfBuffers ); + if ( status != DSOUND_Ok ) + { + MV_SetErrorCode( MV_BlasterError ); + return( MV_Error ); + } + + return( MV_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MV_StopPlayback + + Stops the sound playback engine. +---------------------------------------------------------------------*/ + +void MV_StopPlayback + ( + void + ) + + { + VoiceNode *voice; + VoiceNode *next; + unsigned flags; + + // Stop sound playback + DSOUND_StopPlayback(); + + // Make sure all callbacks are done. + flags = DisableInterrupts(); + + for( voice = VoiceList.next; voice != &VoiceList; voice = next ) + { + next = voice->next; + + MV_StopVoice( voice ); + + if ( MV_CallBackFunc ) + { + MV_CallBackFunc( voice->callbackval ); + } + } + + RestoreInterrupts( flags ); + } + + +#if 0 +/*--------------------------------------------------------------------- + Function: MV_StartRecording + + Starts the sound recording engine. +---------------------------------------------------------------------*/ + +int MV_StartRecording + ( + int MixRate, + void ( *function )( char *ptr, int length ) + ) + + { + int status; + + switch( MV_SoundCard ) + { + case SoundBlaster : + break; + + default : + MV_SetErrorCode( MV_UnsupportedCard ); + return( MV_Error ); + break; + } + + if ( function == NULL ) + { + MV_SetErrorCode( MV_NullRecordFunction ); + return( MV_Error ); + } + + MV_StopPlayback(); + + // Initialize the buffers + ClearBuffer_DW( MV_MixBuffer[ 0 ], SILENCE_8BIT, TotalBufferSize >> 2 ); + + // Set the mix buffer variables + MV_MixPage = 0; + + MV_RecordFunc = function; + + // Start playback + switch( MV_SoundCard ) + { + case SoundBlaster : + status = BLASTER_BeginBufferedRecord( MV_MixBuffer[ 0 ], + TotalBufferSize, NumberOfBuffers, MixRate, MONO_8BIT, + MV_ServiceRecord ); + + if ( status != BLASTER_Ok ) + { + MV_SetErrorCode( MV_BlasterError ); + return( MV_Error ); + } + break; + } + + MV_Recording = TRUE; + return( MV_Ok ); + } +#endif + +#if 0 +/*--------------------------------------------------------------------- + Function: MV_StopRecord + + Stops the sound record engine. +---------------------------------------------------------------------*/ + +void MV_StopRecord + ( + void + ) + + { + // Stop sound playback + switch( MV_SoundCard ) + { + case SoundBlaster : + BLASTER_StopPlayback(); + break; + } + + MV_Recording = FALSE; + MV_StartPlayback(); + } +#endif + + +/*--------------------------------------------------------------------- + Function: MV_StartDemandFeedPlayback + + Plays a digitized sound from a user controlled buffering system. +---------------------------------------------------------------------*/ + +int MV_StartDemandFeedPlayback + ( + void ( *function )( char **ptr, unsigned long *length ), + int rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + VoiceNode *voice; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + // Request a voice from the voice pool + voice = MV_AllocVoice( priority ); + if ( voice == NULL ) + { + MV_SetErrorCode( MV_NoVoices ); + return( MV_Error ); + } + + voice->wavetype = DemandFeed; + voice->bits = 8; + voice->GetSound = MV_GetNextDemandFeedBlock; + voice->NextBlock = NULL; + voice->DemandFeed = function; + voice->LoopStart = NULL; + voice->LoopCount = 0; + voice->BlockLength = 0; + voice->position = 0; + voice->sound = NULL; + voice->length = 0; + voice->BlockLength = 0; + voice->Playing = TRUE; + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + + MV_SetVoicePitch( voice, rate, pitchoffset ); + MV_SetVoiceVolume( voice, vol, left, right ); + MV_PlayVoice( voice ); + + return( voice->handle ); + } + + +/*--------------------------------------------------------------------- + Function: MV_PlayRaw + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayRaw + ( + char *ptr, + unsigned long length, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int status; + + status = MV_PlayLoopedRaw( ptr, length, NULL, NULL, rate, pitchoffset, + vol, left, right, priority, callbackval ); + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MV_PlayLoopedRaw + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayLoopedRaw + ( + char *ptr, + long length, + char *loopstart, + char *loopend, + unsigned rate, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + VoiceNode *voice; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + // Request a voice from the voice pool + voice = MV_AllocVoice( priority ); + if ( voice == NULL ) + { + MV_SetErrorCode( MV_NoVoices ); + return( MV_Error ); + } + + voice->wavetype = Raw; + voice->bits = 8; + voice->GetSound = MV_GetNextRawBlock; + voice->Playing = TRUE; + voice->NextBlock = ptr; + voice->position = 0; + voice->BlockLength = length; + voice->length = 0; + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + voice->LoopStart = loopstart; + voice->LoopEnd = loopend; + voice->LoopSize = ( voice->LoopEnd - voice->LoopStart ) + 1; + + MV_SetVoicePitch( voice, rate, pitchoffset ); + MV_SetVoiceVolume( voice, vol, left, right ); + MV_PlayVoice( voice ); + + return( voice->handle ); + } + + +/*--------------------------------------------------------------------- + Function: MV_PlayWAV + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayWAV + ( + char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int status; + + status = MV_PlayLoopedWAV( ptr, -1, -1, pitchoffset, vol, left, right, + priority, callbackval ); + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MV_PlayWAV3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int MV_PlayWAV3D + ( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval + ) + + { + int left; + int right; + int mid; + int volume; + int status; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + if ( distance < 0 ) + { + distance = -distance; + angle += MV_NumPanPositions / 2; + } + + volume = MIX_VOLUME( distance ); + + // Ensure angle is within 0 - 31 + angle &= MV_MaxPanPosition; + + left = MV_PanTable[ angle ][ volume ].left; + right = MV_PanTable[ angle ][ volume ].right; + mid = max( 0, 255 - distance ); + + status = MV_PlayWAV( ptr, pitchoffset, mid, left, right, priority, + callbackval ); + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MV_PlayLoopedWAV + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayLoopedWAV + ( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + riff_header *riff; + format_header *format; + data_header *data; + VoiceNode *voice; + int length; + int absloopend; + int absloopstart; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + riff = ( riff_header * )ptr; + + if ( ( strncmp( riff->RIFF, "RIFF", 4 ) != 0 ) || + ( strncmp( riff->WAVE, "WAVE", 4 ) != 0 ) || + ( strncmp( riff->fmt, "fmt ", 4) != 0 ) ) + { + MV_SetErrorCode( MV_InvalidWAVFile ); + return( MV_Error ); + } + + format = ( format_header * )( riff + 1 ); + data = ( data_header * )( ( ( char * )format ) + riff->format_size ); + + // Check if it's PCM data. + if ( format->wFormatTag != 1 ) + { + MV_SetErrorCode( MV_InvalidWAVFile ); + return( MV_Error ); + } + + if ( format->nChannels != 1 ) + { + MV_SetErrorCode( MV_InvalidWAVFile ); + return( MV_Error ); + } + + if ( ( format->nBitsPerSample != 8 ) && + ( format->nBitsPerSample != 16 ) ) + { + MV_SetErrorCode( MV_InvalidWAVFile ); + return( MV_Error ); + } + + if ( strncmp( data->DATA, "data", 4 ) != 0 ) + { + MV_SetErrorCode( MV_InvalidWAVFile ); + return( MV_Error ); + } + + // Request a voice from the voice pool + voice = MV_AllocVoice( priority ); + if ( voice == NULL ) + { + MV_SetErrorCode( MV_NoVoices ); + return( MV_Error ); + } + + voice->wavetype = WAV; + voice->bits = format->nBitsPerSample; + voice->GetSound = MV_GetNextWAVBlock; + + length = data->size; + absloopstart = loopstart; + absloopend = loopend; + if ( voice->bits == 16 ) + { + loopstart *= 2; + data->size &= ~1; + loopend *= 2; + length /= 2; + } + + loopend = min( loopend, data->size ); + absloopend = min( absloopend, length ); + + voice->Playing = TRUE; + voice->DemandFeed = NULL; + voice->LoopStart = NULL; + voice->LoopCount = 0; + voice->position = 0; + voice->length = 0; + voice->BlockLength = absloopend; + voice->NextBlock = ( char * )( data + 1 ); + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + voice->LoopStart = voice->NextBlock + loopstart; + voice->LoopEnd = voice->NextBlock + loopend; + voice->LoopSize = absloopend - absloopstart; + + if ( ( loopstart >= data->size ) || ( loopstart < 0 ) ) + { + voice->LoopStart = NULL; + voice->LoopEnd = NULL; + voice->BlockLength = length; + } + + MV_SetVoicePitch( voice, format->nSamplesPerSec, pitchoffset ); + MV_SetVoiceVolume( voice, vol, left, right ); + MV_PlayVoice( voice ); + + return( voice->handle ); + } + + +/*--------------------------------------------------------------------- + Function: MV_PlayVOC3D + + Begin playback of sound data at specified angle and distance + from listener. +---------------------------------------------------------------------*/ + +int MV_PlayVOC3D + ( + char *ptr, + int pitchoffset, + int angle, + int distance, + int priority, + unsigned long callbackval + ) + + { + int left; + int right; + int mid; + int volume; + int status; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + if ( distance < 0 ) + { + distance = -distance; + angle += MV_NumPanPositions / 2; + } + + volume = MIX_VOLUME( distance ); + + // Ensure angle is within 0 - 31 + angle &= MV_MaxPanPosition; + + left = MV_PanTable[ angle ][ volume ].left; + right = MV_PanTable[ angle ][ volume ].right; + mid = max( 0, 255 - distance ); + + status = MV_PlayVOC( ptr, pitchoffset, mid, left, right, priority, + callbackval ); + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MV_PlayVOC + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayVOC + ( + char *ptr, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + int status; + + status = MV_PlayLoopedVOC( ptr, -1, -1, pitchoffset, vol, left, right, + priority, callbackval ); + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MV_PlayLoopedVOC + + Begin playback of sound data with the given sound levels and + priority. +---------------------------------------------------------------------*/ + +int MV_PlayLoopedVOC + ( + char *ptr, + long loopstart, + long loopend, + int pitchoffset, + int vol, + int left, + int right, + int priority, + unsigned long callbackval + ) + + { + VoiceNode *voice; + int status; + + if ( !MV_Installed ) + { + MV_SetErrorCode( MV_NotInstalled ); + return( MV_Error ); + } + + // Make sure it's a valid VOC file. + status = strncmp( ptr, "Creative Voice File", 19 ); + if ( status != 0 ) + { + MV_SetErrorCode( MV_InvalidVOCFile ); + return( MV_Error ); + } + + // Request a voice from the voice pool + voice = MV_AllocVoice( priority ); + if ( voice == NULL ) + { + MV_SetErrorCode( MV_NoVoices ); + return( MV_Error ); + } + + voice->wavetype = VOC; + voice->bits = 8; + voice->GetSound = MV_GetNextVOCBlock; + voice->NextBlock = ptr + *( unsigned short int * )( ptr + 0x14 ); + voice->DemandFeed = NULL; + voice->LoopStart = NULL; + voice->LoopCount = 0; + voice->BlockLength = 0; + voice->PitchScale = PITCH_GetScale( pitchoffset ); + voice->length = 0; + voice->next = NULL; + voice->prev = NULL; + voice->priority = priority; + voice->callbackval = callbackval; + voice->LoopStart = ( char * )loopstart; + voice->LoopEnd = ( char * )loopend; + voice->LoopSize = loopend - loopstart + 1; + + if ( loopstart < 0 ) + { + voice->LoopStart = NULL; + voice->LoopEnd = NULL; + } + + MV_SetVoiceVolume( voice, vol, left, right ); + MV_PlayVoice( voice ); + + return( voice->handle ); + } + + +/*--------------------------------------------------------------------- + Function: MV_CreateVolumeTable + + Create the table used to convert sound data to a specific volume + level. +---------------------------------------------------------------------*/ + +void MV_CreateVolumeTable + ( + int index, + int volume, + int MaxVolume + ) + + { + int val; + int level; + int i; + + level = ( volume * MaxVolume ) / MV_MaxTotalVolume; + if ( MV_Bits == 16 ) + { + for( i = 0; i < 65536; i += 256 ) + { + val = i - 0x8000; + val *= level; + val /= MV_MaxVolume; + MV_VolumeTable[ index ][ i / 256 ] = val; + } + } + else + { + for( i = 0; i < 256; i++ ) + { + val = i - 0x80; + val *= level; + val /= MV_MaxVolume; + MV_VolumeTable[ volume ][ i ] = val; + } + } + } + + +/*--------------------------------------------------------------------- + Function: MV_CalcVolume + + Create the table used to convert sound data to a specific volume + level. +---------------------------------------------------------------------*/ + +void MV_CalcVolume + ( + int MaxVolume + ) + + { + int volume; + + for( volume = 0; volume < 128; volume++ ) + { + MV_HarshClipTable[ volume ] = 0; + MV_HarshClipTable[ volume + 384 ] = 255; + } + for( volume = 0; volume < 256; volume++ ) + { + MV_HarshClipTable[ volume + 128 ] = volume; + } + + // For each volume level, create a translation table with the + // appropriate volume calculated. + for( volume = 0; volume <= MV_MaxVolume; volume++ ) + { + MV_CreateVolumeTable( volume, volume, MaxVolume ); + } + } + + +/*--------------------------------------------------------------------- + Function: MV_CalcPanTable + + Create the table used to determine the stereo volume level of + a sound located at a specific angle and distance from the listener. +---------------------------------------------------------------------*/ + +void MV_CalcPanTable + ( + void + ) + + { + int level; + int angle; + int distance; + int HalfAngle; + int ramp; + + HalfAngle = ( MV_NumPanPositions / 2 ); + + for( distance = 0; distance <= MV_MaxVolume; distance++ ) + { + level = ( 255 * ( MV_MaxVolume - distance ) ) / MV_MaxVolume; + for( angle = 0; angle <= HalfAngle / 2; angle++ ) + { + ramp = level - ( ( level * angle ) / + ( MV_NumPanPositions / 4 ) ); + + MV_PanTable[ angle ][ distance ].left = ramp; + MV_PanTable[ HalfAngle - angle ][ distance ].left = ramp; + MV_PanTable[ HalfAngle + angle ][ distance ].left = level; + MV_PanTable[ MV_MaxPanPosition - angle ][ distance ].left = level; + + MV_PanTable[ angle ][ distance ].right = level; + MV_PanTable[ HalfAngle - angle ][ distance ].right = level; + MV_PanTable[ HalfAngle + angle ][ distance ].right = ramp; + MV_PanTable[ MV_MaxPanPosition - angle ][ distance ].right = ramp; + } + } + } + + +/*--------------------------------------------------------------------- + Function: MV_SetVolume + + Sets the volume of digitized sound playback. +---------------------------------------------------------------------*/ + +void MV_SetVolume + ( + int volume + ) + + { + volume = max( 0, volume ); + volume = min( volume, MV_MaxTotalVolume ); + + MV_TotalVolume = volume; + + // Calculate volume table + MV_CalcVolume( volume ); + } + + +/*--------------------------------------------------------------------- + Function: MV_GetVolume + + Returns the volume of digitized sound playback. +---------------------------------------------------------------------*/ + +int MV_GetVolume + ( + void + ) + + { + return( MV_TotalVolume ); + } + + +/*--------------------------------------------------------------------- + Function: MV_SetCallBack + + Set the function to call when a voice stops. +---------------------------------------------------------------------*/ + +void MV_SetCallBack + ( + void ( *function )( unsigned long ) + ) + + { + MV_CallBackFunc = function; + } + + +/*--------------------------------------------------------------------- + Function: MV_SetReverseStereo + + Set the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +void MV_SetReverseStereo + ( + int setting + ) + + { + MV_SwapLeftRight = setting; + } + + +/*--------------------------------------------------------------------- + Function: MV_GetReverseStereo + + Returns the orientation of the left and right channels. +---------------------------------------------------------------------*/ + +int MV_GetReverseStereo + ( + void + ) + + { + return( MV_SwapLeftRight ); + } + +#if 0 +/*--------------------------------------------------------------------- + Function: MV_TestPlayback + + Checks if playback has started. +---------------------------------------------------------------------*/ + +int MV_TestPlayback + ( + void + ) + + { + unsigned flags; + long time; + int start; + int status; + int pos; + + flags = DisableInterrupts(); + _enable(); + + status = MV_Error; + start = MV_MixPage; + time = clock() + CLOCKS_PER_SEC * 2; + + while( clock() < time ) + { + if ( MV_MixPage != start ) + { + status = MV_Ok; + } + } + + RestoreInterrupts( flags ); + + if ( status != MV_Ok ) + { + // Just in case an error doesn't get reported + MV_SetErrorCode( MV_DMAFailure ); + + switch( MV_SoundCard ) + { + case SoundBlaster : + pos = BLASTER_GetCurrentPos(); + break; + + default : + MV_SetErrorCode( MV_UnsupportedCard ); + pos = -2; + break; + } + + if ( pos > 0 ) + { + MV_SetErrorCode( MV_IrqFailure ); + } + else if ( pos == 0 ) + { + if ( MV_Bits == 16 ) + { + MV_SetErrorCode( MV_DMA16Failure ); + } + else + { + MV_SetErrorCode( MV_DMAFailure ); + } + } + } + + return( status ); + } +#endif + + +/*--------------------------------------------------------------------- + Function: MV_Init + + Perform the initialization of variables and memory used by + Multivoc. +---------------------------------------------------------------------*/ + +int MV_Init + ( + int soundcard, + int MixRate, + int Voices, + int numchannels, + int samplebits + ) + + { + char *ptr; + int status; + int buffer; + int index; + + if ( MV_Installed ) + { + MV_Shutdown(); + } + + printOSD("Initializing MultiVoc...\n"); + + MV_SetErrorCode( MV_Ok ); + + MV_TotalMemory = Voices * sizeof( VoiceNode ) + sizeof( HARSH_CLIP_TABLE_8 ); + status = USRHOOKS_GetMem( ( void ** )&ptr, MV_TotalMemory ); + if ( status != USRHOOKS_Ok ) + { + MV_SetErrorCode( MV_NoMem ); + return( MV_Error ); + } + + MV_Voices = ( VoiceNode * )ptr; + MV_HarshClipTable = ptr + ( MV_TotalMemory - sizeof( HARSH_CLIP_TABLE_8 ) ); + + // Set number of voices before calculating volume table + MV_MaxVoices = Voices; + + printOSD(" - Maximum voices: %d\n", MV_MaxVoices); + + LL_Reset( &VoiceList, next, prev ); + LL_Reset( &VoicePool, next, prev ); + + for( index = 0; index < Voices; index++ ) + { + LL_Add( &VoicePool, &MV_Voices[ index ], next, prev ); + } + + // Set the sampling rate + MV_RequestedMixRate = MixRate; + + printOSD(" - Using %d byte mixing buffers\n", MixBufferSize); + + // Allocate mix buffer within 1st megabyte + ptr = (char *)malloc(TotalBufferSize + 4); // FIXME: temporarily fixes bounds error somewhere... + if ( !ptr ) + { + USRHOOKS_FreeMem( MV_Voices ); + MV_Voices = NULL; + MV_TotalMemory = 0; + + MV_SetErrorCode( MV_NoMem ); + return( MV_Error ); + } + + MV_MixBufferPtr = ptr; + + MV_SetReverseStereo( FALSE ); + + // Initialize the sound card + status = DSOUND_Init(soundcard, MixRate, numchannels, samplebits, + TotalBufferSize); + if ( status != DSOUND_Ok ) + { + MV_SetErrorCode( MV_BlasterError ); + } + + if ( MV_ErrorCode != MV_Ok ) + { + status = MV_ErrorCode; + + USRHOOKS_FreeMem( MV_Voices ); + MV_Voices = NULL; + MV_TotalMemory = 0; + + free(ptr); + + MV_SetErrorCode( status ); + return( MV_Error ); + } + + MV_SoundCard = soundcard; + MV_Installed = TRUE; + MV_CallBackFunc = NULL; + MV_RecordFunc = NULL; + MV_Recording = FALSE; + MV_ReverbLevel = 0; + MV_ReverbTable = NULL; + + // Set Mixer to play stereo digitized sound + MV_SetMixMode( numchannels, samplebits ); + MV_ReverbDelay = MV_BufferSize * 3; + + //MV_MixBuffer[ MV_NumberOfBuffers ] = ptr; + for( buffer = 0; buffer < MV_NumberOfBuffers; buffer++ ) + { + MV_MixBuffer[ buffer ] = ptr; + ptr += MV_BufferSize; + } + + // Calculate pan table + MV_CalcPanTable(); + + MV_SetVolume( MV_MaxTotalVolume ); + + // Start the playback engine + status = MV_StartPlayback(); + if ( status != MV_Ok ) + { + // Preserve error code while we shutdown. + status = MV_ErrorCode; + MV_Shutdown(); + MV_SetErrorCode( status ); + return( MV_Error ); + } + + return( MV_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MV_Shutdown + + Restore any resources allocated by Multivoc back to the system. +---------------------------------------------------------------------*/ + +int MV_Shutdown + ( + void + ) + + { + int buffer; + unsigned flags; + + if ( !MV_Installed ) + { + return( MV_Ok ); + } + + printOSD("Uninitializing MultiVoc...\n"); + + flags = DisableInterrupts(); + + MV_KillAllVoices(); + + MV_Installed = FALSE; + + // Stop the sound recording engine + if ( MV_Recording ) + { + //MV_StopRecord(); + } + + // Stop the sound playback engine + MV_StopPlayback(); + + // Shutdown the sound card + DSOUND_Shutdown(); + + RestoreInterrupts( flags ); + + // Free any voices we allocated + USRHOOKS_FreeMem( MV_Voices ); + MV_Voices = NULL; + MV_TotalMemory = 0; + + LL_Reset( &VoiceList, next, prev ); + LL_Reset( &VoicePool, next, prev ); + + MV_MaxVoices = 1; + + // Release the descriptor from our mix buffer + if (MV_MixBufferPtr) free(MV_MixBufferPtr); + MV_MixBufferPtr = NULL; + + for( buffer = 0; buffer < NumberOfBuffers; buffer++ ) + { + MV_MixBuffer[ buffer ] = NULL; + } + + return( MV_Ok ); + } + + diff --git a/polymer/eduke32/source/jaudiolib/multivoc.h b/polymer/eduke32/source/jaudiolib/multivoc.h new file mode 100644 index 000000000..19af4479e --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/multivoc.h @@ -0,0 +1,117 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + file: MULTIVOC.H + + author: James R. Dose + date: December 20, 1993 + + Public header for MULTIVOC.C + + (c) Copyright 1993 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __MULTIVOC_H +#define __MULTIVOC_H + +#define MV_MinVoiceHandle 1 + +extern int MV_ErrorCode; + +enum MV_Errors + { + MV_Warning = -2, + MV_Error = -1, + MV_Ok = 0, + MV_UnsupportedCard, + MV_NotInstalled, + MV_NoVoices, + MV_NoMem, + MV_VoiceNotFound, + MV_BlasterError, + MV_DPMI_Error, + MV_InvalidVOCFile, + MV_InvalidWAVFile, + MV_InvalidMixMode, + MV_IrqFailure, + MV_DMAFailure, + MV_DMA16Failure, + MV_NullRecordFunction + }; + +char *MV_ErrorString( int ErrorNumber ); +int MV_VoicePlaying( int handle ); +int MV_KillAllVoices( void ); +int MV_Kill( int handle ); +int MV_VoicesPlaying( void ); +int MV_VoiceAvailable( int priority ); +int MV_SetPitch( int handle, int pitchoffset ); +int MV_SetFrequency( int handle, int frequency ); +int MV_EndLooping( int handle ); +int MV_SetPan( int handle, int vol, int left, int right ); +int MV_Pan3D( int handle, int angle, int distance ); +void MV_SetReverb( int reverb ); +void MV_SetFastReverb( int reverb ); +int MV_GetMaxReverbDelay( void ); +int MV_GetReverbDelay( void ); +void MV_SetReverbDelay( int delay ); +int MV_SetMixMode( int numchannels, int samplebits ); +int MV_StartPlayback( void ); +void MV_StopPlayback( void ); +int MV_StartRecording( int MixRate, void ( *function )( char *ptr, int length ) ); +void MV_StopRecord( void ); +int MV_StartDemandFeedPlayback( void ( *function )( char **ptr, unsigned long *length ), + int rate, int pitchoffset, int vol, int left, int right, + int priority, unsigned long callbackval ); +int MV_PlayRaw( char *ptr, unsigned long length, + unsigned rate, int pitchoffset, int vol, int left, + int right, int priority, unsigned long callbackval ); +int MV_PlayLoopedRaw( char *ptr, long length, + char *loopstart, char *loopend, unsigned rate, int pitchoffset, + int vol, int left, int right, int priority, + unsigned long callbackval ); +int MV_PlayWAV( char *ptr, int pitchoffset, int vol, int left, + int right, int priority, unsigned long callbackval ); +int MV_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance, + int priority, unsigned long callbackval ); +int MV_PlayLoopedWAV( char *ptr, long loopstart, long loopend, + int pitchoffset, int vol, int left, int right, int priority, + unsigned long callbackval ); +int MV_PlayVOC3D( char *ptr, int pitchoffset, int angle, int distance, + int priority, unsigned long callbackval ); +int MV_PlayVOC( char *ptr, int pitchoffset, int vol, int left, int right, + int priority, unsigned long callbackval ); +int MV_PlayLoopedVOC( char *ptr, long loopstart, long loopend, + int pitchoffset, int vol, int left, int right, int priority, + unsigned long callbackval ); +void MV_CreateVolumeTable( int index, int volume, int MaxVolume ); +void MV_SetVolume( int volume ); +int MV_GetVolume( void ); +void MV_SetCallBack( void ( *function )( unsigned long ) ); +void MV_SetReverseStereo( int setting ); +int MV_GetReverseStereo( void ); +int MV_Init( int soundcard, int MixRate, int Voices, int numchannels, + int samplebits ); +int MV_Shutdown( void ); + +void MV_Update(void); + +#endif diff --git a/polymer/eduke32/source/jaudiolib/music.c b/polymer/eduke32/source/jaudiolib/music.c new file mode 100644 index 000000000..2e396d0e1 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/music.c @@ -0,0 +1,595 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: MUSIC.C + + author: James R. Dose + date: March 25, 1994 + + Device independant music playback routines. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#include +#include +#include "music.h" +#include "midi.h" +#include "mpu401.h" + +#define TRUE ( 1 == 1 ) +#define FALSE ( !TRUE ) + +#ifdef __MINGW32__ +#define max(a,b) (((a)>(b))?(a):(b)) +#define min(a,b) (((a)<(b))?(a):(b)) +#endif + +int MUSIC_SoundDevice = -1; +int MUSIC_ErrorCode = MUSIC_Ok; + +static midifuncs MUSIC_MidiFunctions; + +static int MUSIC_FadeLength; +static int MUSIC_FadeRate; +static unsigned MUSIC_CurrentFadeVolume; +static unsigned MUSIC_LastFadeVolume; +static int MUSIC_EndingFadeVolume; + +int MUSIC_InitMidi( int card, midifuncs *Funcs, int Address ); + +#define MUSIC_SetErrorCode( status ) \ + MUSIC_ErrorCode = ( status ); + +/*--------------------------------------------------------------------- + Function: MUSIC_ErrorString + + Returns a pointer to the error message associated with an error + number. A -1 returns a pointer the current error. +---------------------------------------------------------------------*/ + +char *MUSIC_ErrorString + ( + int ErrorNumber + ) + + { + char *ErrorString; + + switch( ErrorNumber ) + { + case MUSIC_Warning : + case MUSIC_Error : + ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode ); + break; + + case MUSIC_Ok : + ErrorString = "Music ok."; + break; + + case MUSIC_ASSVersion : + ErrorString = "Apogee Sound System Version WinMM " + "Programmed by Jim Dose, Ported by Jonathon Fowler\n" + "(c) Copyright 1996 James R. Dose. All Rights Reserved.\n"; + break; + + case MUSIC_SoundCardError : + case MUSIC_MPU401Error : + ErrorString = "Could not detect MPU-401."; + break; + + case MUSIC_InvalidCard : + ErrorString = "Invalid Music device."; + break; + + case MUSIC_MidiError : + ErrorString = "Error playing MIDI file."; + break; + + case MUSIC_TaskManError : + ErrorString = "TaskMan error."; + break; + + case MUSIC_DPMI_Error : + ErrorString = "DPMI Error in MUSIC."; + break; + + default : + ErrorString = "Unknown Music error code."; + break; + } + + return( ErrorString ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_Init + + Selects which sound device to use. +---------------------------------------------------------------------*/ + +int MUSIC_Init + ( + int SoundCard, + int Address + ) + + { + int i; + int status; + + for( i = 0; i < 128; i++ ) + { + MIDI_PatchMap[ i ] = i; + } + + MUSIC_SoundDevice = SoundCard; + + status = MUSIC_InitMidi( SoundCard, &MUSIC_MidiFunctions, Address ); + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_Shutdown + + Terminates use of sound device. +---------------------------------------------------------------------*/ + +int MUSIC_Shutdown + ( + void + ) + + { + int status; + + status = MUSIC_Ok; + + MIDI_StopSong(); + + //MPU_Reset(); + + return( status ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetVolume + + Sets the volume of music playback. +---------------------------------------------------------------------*/ + +void MUSIC_SetVolume + ( + int volume + ) + + { + volume = max( 0, volume ); + volume = min( volume, 255 ); + + if ( MUSIC_SoundDevice != -1 ) + { + MIDI_SetVolume( volume ); + } + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetMidiChannelVolume + + Sets the volume of music playback on the specified MIDI channel. +---------------------------------------------------------------------*/ + +void MUSIC_SetMidiChannelVolume + ( + int channel, + int volume + ) + + { + MIDI_SetUserChannelVolume( channel, volume ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_ResetMidiChannelVolumes + + Sets the volume of music playback on all MIDI channels to full volume. +---------------------------------------------------------------------*/ + +void MUSIC_ResetMidiChannelVolumes + ( + void + ) + + { + MIDI_ResetUserChannelVolume(); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetVolume + + Returns the volume of music playback. +---------------------------------------------------------------------*/ + +int MUSIC_GetVolume + ( + void + ) + + { + if ( MUSIC_SoundDevice == -1 ) + { + return( 0 ); + } + return( MIDI_GetVolume() ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetLoopFlag + + Set whether the music will loop or end when it reaches the end of + the song. +---------------------------------------------------------------------*/ + +void MUSIC_SetLoopFlag + ( + int loopflag + ) + + { + MIDI_SetLoopFlag( loopflag ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SongPlaying + + Returns whether there is a song playing. +---------------------------------------------------------------------*/ + +int MUSIC_SongPlaying + ( + void + ) + + { + return( MIDI_SongPlaying() ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_Continue + + Continues playback of a paused song. +---------------------------------------------------------------------*/ + +void MUSIC_Continue + ( + void + ) + + { + MIDI_ContinueSong(); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_Pause + + Pauses playback of a song. +---------------------------------------------------------------------*/ + +void MUSIC_Pause + ( + void + ) + + { + MIDI_PauseSong(); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_StopSong + + Stops playback of current song. +---------------------------------------------------------------------*/ + +int MUSIC_StopSong + ( + void + ) + + { + MUSIC_StopFade(); + MIDI_StopSong(); + MUSIC_SetErrorCode( MUSIC_Ok ); + return( MUSIC_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_PlaySong + + Begins playback of MIDI song. +---------------------------------------------------------------------*/ + +int MUSIC_PlaySong + ( + unsigned char *song, + int loopflag + ) + + { + int status; + + MUSIC_StopSong(); + + status = MIDI_PlaySong( song, loopflag ); + if ( status != MIDI_Ok ) + { + MUSIC_SetErrorCode( MUSIC_MidiError ); + return( MUSIC_Warning ); + } + + return( MUSIC_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetContext + + Sets the song context. +---------------------------------------------------------------------*/ + +void MUSIC_SetContext + ( + int context + ) + + { + MIDI_SetContext( context ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetContext + + Returns the current song context. +---------------------------------------------------------------------*/ + +int MUSIC_GetContext + ( + void + ) + + { + return MIDI_GetContext(); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetSongTick + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_SetSongTick + ( + unsigned long PositionInTicks + ) + + { + MIDI_SetSongTick( PositionInTicks ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetSongTime + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_SetSongTime + ( + unsigned long milliseconds + ) + + { + MIDI_SetSongTime( milliseconds ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetSongPosition + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_SetSongPosition + ( + int measure, + int beat, + int tick + ) + + { + MIDI_SetSongPosition( measure, beat, tick ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetSongPosition + + Returns the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_GetSongPosition + ( + songposition *pos + ) + + { + MIDI_GetSongPosition( pos ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetSongLength + + Returns the length of the song. +---------------------------------------------------------------------*/ + +void MUSIC_GetSongLength + ( + songposition *pos + ) + + { + MIDI_GetSongLength( pos ); + } + + +int MUSIC_InitMidi + ( + int card, + midifuncs *Funcs, + int Address + ) + + { + int status; + + Funcs->NoteOff = MPU_NoteOff; + Funcs->NoteOn = MPU_NoteOn; + Funcs->PolyAftertouch = MPU_PolyAftertouch; + Funcs->ControlChange = MPU_ControlChange; + Funcs->ProgramChange = MPU_ProgramChange; + Funcs->ChannelAftertouch = MPU_ChannelAftertouch; + Funcs->PitchBend = MPU_PitchBend; + Funcs->ReleasePatches = NULL; + Funcs->LoadPatch = NULL; + Funcs->SetVolume = NULL /*MPU_SetVolume*/; + Funcs->GetVolume = NULL /*MPU_GetVolume*/; + + MIDI_SetMidiFuncs( Funcs ); + + return( MIDI_Ok ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_FadeVolume + + Fades music volume from current level to another over a specified + period of time. +---------------------------------------------------------------------*/ + +int MUSIC_FadeVolume + ( + int tovolume, + int milliseconds + ) + + { + int fromvolume; + + MIDI_SetVolume( tovolume ); + return( MUSIC_Ok ); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_FadeActive + + Returns whether the fade routine is active. +---------------------------------------------------------------------*/ + +int MUSIC_FadeActive + ( + void + ) + + { + return( 0 ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_StopFade + + Stops fading the music. +---------------------------------------------------------------------*/ + +void MUSIC_StopFade + ( + void + ) + + { + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_RerouteMidiChannel + + Sets callback function to reroute MIDI commands from specified + function. +---------------------------------------------------------------------*/ + +void MUSIC_RerouteMidiChannel + ( + int channel, + int ( *function )( int event, int c1, int c2 ) + ) + + { + MIDI_RerouteMidiChannel( channel, function ); + } + + +/*--------------------------------------------------------------------- + Function: MUSIC_RegisterTimbreBank + + Halts playback of all sounds. +---------------------------------------------------------------------*/ + +void MUSIC_RegisterTimbreBank + ( + unsigned char *timbres + ) + + { + } + + +void MUSIC_Update(void) +{ + MIDI_UpdateMusic(); +} + diff --git a/polymer/eduke32/source/jaudiolib/music.h b/polymer/eduke32/source/jaudiolib/music.h new file mode 100644 index 000000000..028790d92 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/music.h @@ -0,0 +1,90 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: MUSIC.H + + author: James R. Dose + date: March 25, 1994 + + Public header for MUSIC.C + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __MUSIC_H +#define __MUSIC_H + +extern int MUSIC_ErrorCode; + +enum MUSIC_ERRORS + { + MUSIC_Warning = -2, + MUSIC_Error = -1, + MUSIC_Ok = 0, + MUSIC_ASSVersion, + MUSIC_SoundCardError, + MUSIC_MPU401Error, + MUSIC_InvalidCard, + MUSIC_MidiError, + MUSIC_TaskManError, + MUSIC_DPMI_Error + }; + +typedef struct + { + unsigned long tickposition; + unsigned long milliseconds; + unsigned int measure; + unsigned int beat; + unsigned int tick; + } songposition; + +#define MUSIC_LoopSong ( 1 == 1 ) +#define MUSIC_PlayOnce ( !MUSIC_LoopSong ) + +char *MUSIC_ErrorString( int ErrorNumber ); +int MUSIC_Init( int SoundCard, int Address ); +int MUSIC_Shutdown( void ); +void MUSIC_SetVolume( int volume ); +void MUSIC_SetMidiChannelVolume( int channel, int volume ); +void MUSIC_ResetMidiChannelVolumes( void ); +int MUSIC_GetVolume( void ); +void MUSIC_SetLoopFlag( int loopflag ); +int MUSIC_SongPlaying( void ); +void MUSIC_Continue( void ); +void MUSIC_Pause( void ); +int MUSIC_StopSong( void ); +int MUSIC_PlaySong( unsigned char *song, int loopflag ); +void MUSIC_SetContext( int context ); +int MUSIC_GetContext( void ); +void MUSIC_SetSongTick( unsigned long PositionInTicks ); +void MUSIC_SetSongTime( unsigned long milliseconds ); +void MUSIC_SetSongPosition( int measure, int beat, int tick ); +void MUSIC_GetSongPosition( songposition *pos ); +void MUSIC_GetSongLength( songposition *pos ); +int MUSIC_FadeVolume( int tovolume, int milliseconds ); +int MUSIC_FadeActive( void ); +void MUSIC_StopFade( void ); +void MUSIC_RerouteMidiChannel( int channel, int ( *function )( int event, int c1, int c2 ) ); +void MUSIC_RegisterTimbreBank( unsigned char *timbres ); +void MUSIC_Update(void); + +#endif diff --git a/polymer/eduke32/source/jaudiolib/mv_mix.masm b/polymer/eduke32/source/jaudiolib/mv_mix.masm new file mode 100644 index 000000000..92742de36 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mv_mix.masm @@ -0,0 +1,487 @@ +.586P + +EXTRN _MV_HarshClipTable : dword +EXTRN _MV_MixDestination : dword +EXTRN _MV_MixPosition : dword +EXTRN _MV_LeftVolume : dword +EXTRN _MV_RightVolume : dword +EXTRN _MV_SampleSize : dword +EXTRN _MV_RightChannelOffset : dword + +CODE SEGMENT PUBLIC USE32 'DATA' +ASSUME cs:CODE,ds:CODE + +;================ +; +; MV_Mix8BitMono +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC _MV_Mix8BitMono +_MV_Mix8BitMono: +; Two at once + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [apatch7+2],bl + mov byte ptr [apatch8+2],bl + mov byte ptr [apatch9+3],bl + + ; Volume table ptr + mov ebx, _MV_LeftVolume ; Since we're mono, use left volume + mov dword ptr [apatch1+4],ebx + mov dword ptr [apatch2+4],ebx + + ; Harsh Clip table ptr + mov ebx, _MV_HarshClipTable + add ebx, 128 + mov dword ptr [apatch3+2],ebx + mov dword ptr [apatch4+2],ebx + + ; Rate scale ptr + mov dword ptr [apatch5+2],edx + mov dword ptr [apatch6+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + shr ecx, 1 ; double sample count + cmp ecx, 0 + je short exit8m + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; apatch1 - volume table +; apatch2 - volume table +; apatch3 - harsh clip table +; apatch4 - harsh clip table +; apatch5 - sample rate +; apatch6 - sample rate + + mov eax,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr eax,16 ; finish calculation for first sample + + mov ebx,ebp ; begin calculating second sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for second sample + + movzx eax, byte ptr [esi+eax] ; get first sample + movzx ebx, byte ptr [esi+ebx] ; get second sample + +;ALIGN 4 +mix8Mloop: + movzx edx, byte ptr [edi] ; get current sample from destination +apatch1: + movsx eax, byte ptr [2*eax+12345678h] ; volume translate first sample +apatch2: + movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate second sample + add eax, edx ; mix first sample +apatch9: + movzx edx, byte ptr [edi + 1] ; get current sample from destination +apatch3: + mov eax, [eax + 12345678h] ; harsh clip new sample + add ebx, edx ; mix second sample + mov [edi], al ; write new sample to destination + mov edx, ebp ; begin calculating third sample +apatch4: + mov ebx, [ebx + 12345678h] ; harsh clip new sample +apatch5: + add ebp,12345678h ; advance frac pointer + shr edx, 16 ; finish calculation for third sample + mov eax, ebp ; begin calculating fourth sample +apatch7: + add edi, 1 ; move destination to second sample + shr eax, 16 ; finish calculation for fourth sample + mov [edi], bl ; write new sample to destination +apatch6: + add ebp,12345678h ; advance frac pointer + movzx ebx, byte ptr [esi+eax] ; get fourth sample + movzx eax, byte ptr [esi+edx] ; get third sample +apatch8: + add edi, 2 ; move destination to third sample + dec ecx ; decrement count + jnz mix8Mloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +exit8m: + popad + ret + + +;================ +; +; MV_Mix8BitStereo +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC _MV_Mix8BitStereo +_MV_Mix8BitStereo: + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [bpatch8+2],bl + + ; Right channel offset + mov ebx, _MV_RightChannelOffset + mov dword ptr [bpatch6+3],ebx + mov dword ptr [bpatch7+2],ebx + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [bpatch1+4],ebx + + mov ebx, _MV_RightVolume + mov dword ptr [bpatch2+4],ebx + + ; Rate scale ptr + mov dword ptr [bpatch3+2],edx + + ; Harsh Clip table ptr + mov ebx, _MV_HarshClipTable + add ebx,128 + mov dword ptr [bpatch4+2],ebx + mov dword ptr [bpatch5+2],ebx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je short exit8S + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; bpatch1 - left volume table +; bpatch2 - right volume table +; bpatch3 - sample rate +; bpatch4 - harsh clip table +; bpatch5 - harsh clip table + + mov eax,ebp ; begin calculating first sample + shr eax,16 ; finish calculation for first sample + + movzx ebx, byte ptr [esi+eax] ; get first sample + +;ALIGN 4 +mix8Sloop: +bpatch1: + movsx eax, byte ptr [2*ebx+12345678h] ; volume translate left sample + movzx edx, byte ptr [edi] ; get current sample from destination +bpatch2: + movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate right sample + add eax, edx ; mix left sample +bpatch3: + add ebp,12345678h ; advance frac pointer +bpatch6: + movzx edx, byte ptr [edi+12345678h] ; get current sample from destination +bpatch4: + mov eax, [eax + 12345678h] ; harsh clip left sample + add ebx, edx ; mix right sample + mov [edi], al ; write left sample to destination +bpatch5: + mov ebx, [ebx + 12345678h] ; harsh clip right sample + mov edx, ebp ; begin calculating second sample +bpatch7: + mov [edi+12345678h], bl ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +bpatch8: + add edi, 2 ; move destination to second sample + movzx ebx, byte ptr [esi+edx] ; get second sample + dec ecx ; decrement count + jnz mix8Sloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position + +EXIT8S: + popad + ret + + +;================ +; +; MV_Mix16BitMono +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC _MV_Mix16BitMono +_MV_Mix16BitMono: +; Two at once + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [cpatch5+3],bl + mov byte ptr [cpatch6+3],bl + add bl,bl + mov byte ptr [cpatch7+2],bl + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [cpatch1+4],ebx + mov dword ptr [cpatch2+4],ebx + + ; Rate scale ptr + mov dword ptr [cpatch3+2],edx + mov dword ptr [cpatch4+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + shr ecx, 1 ; double sample count + cmp ecx, 0 + je exit16M + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; cpatch1 - volume table +; cpatch2 - volume table +; cpatch3 - sample rate +; cpatch4 - sample rate + + mov eax,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr eax,16 ; finish calculation for first sample + + mov ebx,ebp ; begin calculating second sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for second sample + + movzx eax, byte ptr [esi+eax] ; get first sample + movzx ebx, byte ptr [esi+ebx] ; get second sample + +;ALIGN 4 +mix16Mloop: + movsx edx, word ptr [edi] ; get current sample from destination +cpatch1: + movsx eax, word ptr [2*eax+12345678h] ; volume translate first sample +cpatch2: + movsx ebx, word ptr [2*ebx+12345678h] ; volume translate second sample + add eax, edx ; mix first sample +cpatch5: + movsx edx, word ptr [edi + 2] ; get current sample from destination + + cmp eax, -32768 ; Harsh clip sample + jge short m16skip1 + mov eax, -32768 + jmp short m16skip2 +m16skip1: + cmp eax, 32767 + jle short m16skip2 + mov eax, 32767 +m16skip2: + add ebx, edx ; mix second sample + mov [edi], ax ; write new sample to destination + mov edx, ebp ; begin calculating third sample + + cmp ebx, -32768 ; Harsh clip sample + jge short m16skip3 + mov ebx, -32768 + jmp short m16skip4 +m16skip3: + cmp ebx, 32767 + jle short m16skip4 + mov ebx, 32767 +m16skip4: +cpatch3: + add ebp,12345678h ; advance frac pointer + shr edx, 16 ; finish calculation for third sample + mov eax, ebp ; begin calculating fourth sample +cpatch6: + mov [edi + 2], bx ; write new sample to destination + shr eax, 16 ; finish calculation for fourth sample + +cpatch4: + add ebp,12345678h ; advance frac pointer + movzx ebx, byte ptr [esi+eax] ; get fourth sample +cpatch7: + add edi, 4 ; move destination to third sample + movzx eax, byte ptr [esi+edx] ; get third sample + dec ecx ; decrement count + jnz mix16Mloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +EXIT16M: + popad + ret + + +;================ +; +; MV_Mix16BitStereo +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC _MV_Mix16BitStereo +_MV_Mix16BitStereo: + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [dpatch6+2],bl + + ; Right channel offset + mov ebx, _MV_RightChannelOffset + mov dword ptr [dpatch4+3],ebx + mov dword ptr [dpatch5+3],ebx + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [dpatch1+4],ebx + + mov ebx, _MV_RightVolume + mov dword ptr [dpatch2+4],ebx + + ; Rate scale ptr + mov dword ptr [dpatch3+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je exit16S + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; dpatch1 - left volume table +; dpatch2 - right volume table +; dpatch3 - sample rate + + mov eax,ebp ; begin calculating first sample + shr eax,16 ; finish calculation for first sample + + movzx ebx, byte ptr [esi+eax] ; get first sample + +;ALIGN 4 +mix16Sloop: +dpatch1: + movsx eax, word ptr [2*ebx+12345678h] ; volume translate left sample + movsx edx, word ptr [edi] ; get current sample from destination +dpatch2: + movsx ebx, word ptr [2*ebx+12345678h] ; volume translate right sample + add eax, edx ; mix left sample +dpatch3: + add ebp,12345678h ; advance frac pointer +dpatch4: + movsx edx, word ptr [edi+12345678h] ; get current sample from destination + + cmp eax, -32768 ; Harsh clip sample + jge short s16skip1 + mov eax, -32768 + jmp short s16skip2 +s16skip1: + cmp eax, 32767 + jle short s16skip2 + mov eax, 32767 +s16skip2: + add ebx, edx ; mix right sample + mov [edi], ax ; write left sample to destination + + cmp ebx, -32768 ; Harsh clip sample + jge short s16skip3 + mov ebx, -32768 + jmp short s16skip4 +s16skip3: + cmp ebx, 32767 + jle short s16skip4 + mov ebx, 32767 +s16skip4: + + mov edx, ebp ; begin calculating second sample +dpatch5: + mov [edi+12345678h], bx ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +dpatch6: + add edi, 4 ; move destination to second sample + movzx ebx, byte ptr [esi+edx] ; get second sample + dec ecx ; decrement count + jnz mix16Sloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +exit16S: + popad + ret + +CODE ENDS +END diff --git a/polymer/eduke32/source/jaudiolib/mv_mix.nasm b/polymer/eduke32/source/jaudiolib/mv_mix.nasm new file mode 100644 index 000000000..af01017f5 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mv_mix.nasm @@ -0,0 +1,524 @@ +;Copyright (C) 1994-1995 Apogee Software, Ltd. +; +;This program 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. +; +;Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) + +CPU 386 + +SECTION .data + +%ifdef UNDERSCORES + +%define MV_Mix8BitMono _MV_Mix8BitMono +%define MV_Mix8BitStereo _MV_Mix8BitStereo +%define MV_Mix16BitMono _MV_Mix16BitMono +%define MV_Mix16BitStereo _MV_Mix16BitStereo + +%else + +%define _MV_HarshClipTable MV_HarshClipTable +%define _MV_MixDestination MV_MixDestination +%define _MV_MixPosition MV_MixPosition +%define _MV_LeftVolume MV_LeftVolume +%define _MV_RightVolume MV_RightVolume +%define _MV_SampleSize MV_SampleSize +%define _MV_RightChannelOffset MV_RightChannelOffset + +%endif + + EXTERN _MV_HarshClipTable + EXTERN _MV_MixDestination + EXTERN _MV_MixPosition + EXTERN _MV_LeftVolume + EXTERN _MV_RightVolume + EXTERN _MV_SampleSize + EXTERN _MV_RightChannelOffset + + GLOBAL MV_Mix8BitMono + GLOBAL MV_Mix8BitStereo + GLOBAL MV_Mix16BitMono + GLOBAL MV_Mix16BitStereo + + +;================ +; +; MV_Mix8BitMono +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + + ALIGN 4 +MV_Mix8BitMono: +; Two at once + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, dword [_MV_SampleSize] + mov byte [apatch7+2],bl + mov byte [apatch8+2],bl + mov byte [apatch9+3],bl + + ; Volume table ptr + mov ebx, dword [_MV_LeftVolume] ; Since we're mono, use left volume + mov dword [apatch1+4],ebx + mov dword [apatch2+4],ebx + + ; Harsh Clip table ptr + mov ebx, dword [_MV_HarshClipTable] + add ebx, 128 + mov dword [apatch3+2],ebx + mov dword [apatch4+2],ebx + + ; Rate scale ptr + mov dword [apatch5+2],edx + mov dword [apatch6+2],edx + + mov edi, dword [_MV_MixDestination] ; Get the position to write to + + ; Number of samples to mix + shr ecx, 1 ; double sample count + cmp ecx, 0 + je short exit8m + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; apatch1 - volume table +; apatch2 - volume table +; apatch3 - harsh clip table +; apatch4 - harsh clip table +; apatch5 - sample rate +; apatch6 - sample rate + + mov eax,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr eax,16 ; finish calculation for first sample + + mov ebx,ebp ; begin calculating second sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for second sample + + movzx eax, byte [esi+eax] ; get first sample + movzx ebx, byte [esi+ebx] ; get second sample + + ALIGN 4 +mix8Mloop: + movzx edx, byte [edi] ; get current sample from destination +apatch1: + movsx eax, byte [2*eax+12345678h] ; volume translate first sample +apatch2: + movsx ebx, byte [2*ebx+12345678h] ; volume translate second sample + add eax, edx ; mix first sample +apatch9: + movzx edx, byte [edi + 1] ; get current sample from destination +apatch3: + mov eax, dword [eax + 12345678h] ; harsh clip new sample + add ebx, edx ; mix second sample + mov byte [edi], al ; write new sample to destination + mov edx, ebp ; begin calculating third sample +apatch4: + mov ebx, dword [ebx + 12345678h] ; harsh clip new sample +apatch5: + add ebp,12345678h ; advance frac pointer + shr edx, 16 ; finish calculation for third sample + mov eax, ebp ; begin calculating fourth sample +apatch7: + add edi, 1 ; move destination to second sample + shr eax, 16 ; finish calculation for fourth sample + mov byte [edi], bl ; write new sample to destination +apatch6: + add ebp,12345678h ; advance frac pointer + movzx ebx, byte [esi+eax] ; get fourth sample + movzx eax, byte [esi+edx] ; get third sample +apatch8: + add edi, 2 ; move destination to third sample + dec ecx ; decrement count + jnz mix8Mloop ; loop + + mov dword [_MV_MixDestination], edi ; Store the current write position + mov dword [_MV_MixPosition], ebp ; return position +exit8m: + popad + ret + + +;================ +; +; MV_Mix8BitStereo +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + + ALIGN 4 +MV_Mix8BitStereo: + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, dword [_MV_SampleSize] + mov byte [bpatch8+2],bl + + ; Right channel offset + mov ebx, dword [_MV_RightChannelOffset] + mov dword [bpatch6+3],ebx + mov dword [bpatch7+2],ebx + + ; Volume table ptr + mov ebx, dword [_MV_LeftVolume] + mov dword [bpatch1+4],ebx + + mov ebx, dword [_MV_RightVolume] + mov dword [bpatch2+4],ebx + + ; Rate scale ptr + mov dword [bpatch3+2],edx + + ; Harsh Clip table ptr + mov ebx, dword [_MV_HarshClipTable] + add ebx,128 + mov dword [bpatch4+2],ebx + mov dword [bpatch5+2],ebx + + mov edi, dword [_MV_MixDestination] ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je short EXIT8S + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; bpatch1 - left volume table +; bpatch2 - right volume table +; bpatch3 - sample rate +; bpatch4 - harsh clip table +; bpatch5 - harsh clip table + + mov eax,ebp ; begin calculating first sample + shr eax,16 ; finish calculation for first sample + + movzx ebx, byte [esi+eax] ; get first sample + + ALIGN 4 +mix8Sloop: +bpatch1: + movsx eax, byte [2*ebx+12345678h] ; volume translate left sample + movzx edx, byte [edi] ; get current sample from destination +bpatch2: + movsx ebx, byte [2*ebx+12345678h] ; volume translate right sample + add eax, edx ; mix left sample +bpatch3: + add ebp,12345678h ; advance frac pointer +bpatch6: + movzx edx, byte [edi+12345678h] ; get current sample from destination +bpatch4: + mov eax, dword [eax + 12345678h] ; harsh clip left sample + add ebx, edx ; mix right sample + mov byte [edi], al ; write left sample to destination +bpatch5: + mov ebx, dword [ebx + 12345678h] ; harsh clip right sample + mov edx, ebp ; begin calculating second sample +bpatch7: + mov byte [edi+12345678h], bl ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +bpatch8: + add edi, 2 ; move destination to second sample + movzx ebx, byte [esi+edx] ; get second sample + dec ecx ; decrement count + jnz mix8Sloop ; loop + + mov dword [_MV_MixDestination], edi ; Store the current write position + mov dword [_MV_MixPosition], ebp ; return position + +EXIT8S: + popad + ret + + +;================ +; +; MV_Mix16BitMono +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + + ALIGN 4 +MV_Mix16BitMono: +; Two at once + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, dword [_MV_SampleSize] + mov byte [cpatch5+3],bl + mov byte [cpatch6+3],bl + add bl,bl + mov byte [cpatch7+2],bl + + ; Volume table ptr + mov ebx, dword [_MV_LeftVolume] + mov dword [cpatch1+4],ebx + mov dword [cpatch2+4],ebx + + ; Rate scale ptr + mov dword [cpatch3+2],edx + mov dword [cpatch4+2],edx + + mov edi, dword [_MV_MixDestination] ; Get the position to write to + + ; Number of samples to mix + shr ecx, 1 ; double sample count + cmp ecx, 0 + je near EXIT16M + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; cpatch1 - volume table +; cpatch2 - volume table +; cpatch3 - sample rate +; cpatch4 - sample rate + + mov eax,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr eax,16 ; finish calculation for first sample + + mov ebx,ebp ; begin calculating second sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for second sample + + movzx eax, byte [esi+eax] ; get first sample + movzx ebx, byte [esi+ebx] ; get second sample + + ALIGN 4 +mix16Mloop: + movsx edx, word [edi] ; get current sample from destination +cpatch1: + movsx eax, word [2*eax+12345678h] ; volume translate first sample +cpatch2: + movsx ebx, word [2*ebx+12345678h] ; volume translate second sample + add eax, edx ; mix first sample +cpatch5: + movsx edx, word [edi + 2] ; get current sample from destination + + cmp eax, -32768 ; Harsh clip sample + jge short m16skip1 + mov eax, -32768 + jmp short m16skip2 +m16skip1: + cmp eax, 32767 + jle short m16skip2 + mov eax, 32767 +m16skip2: + add ebx, edx ; mix second sample + mov word [edi], ax ; write new sample to destination + mov edx, ebp ; begin calculating third sample + + cmp ebx, -32768 ; Harsh clip sample + jge short m16skip3 + mov ebx, -32768 + jmp short m16skip4 +m16skip3: + cmp ebx, 32767 + jle short m16skip4 + mov ebx, 32767 +m16skip4: +cpatch3: + add ebp,12345678h ; advance frac pointer + shr edx, 16 ; finish calculation for third sample + mov eax, ebp ; begin calculating fourth sample +cpatch6: + mov word [edi + 2], bx ; write new sample to destination + shr eax, 16 ; finish calculation for fourth sample + +cpatch4: + add ebp,12345678h ; advance frac pointer + movzx ebx, byte [esi+eax] ; get fourth sample +cpatch7: + add edi, 4 ; move destination to third sample + movzx eax, byte [esi+edx] ; get third sample + dec ecx ; decrement count + jnz mix16Mloop ; loop + + mov dword [_MV_MixDestination], edi ; Store the current write position + mov dword [_MV_MixPosition], ebp ; return position +EXIT16M: + popad + ret + + +;================ +; +; MV_Mix16BitStereo +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + + ALIGN 4 +MV_Mix16BitStereo: + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, dword [_MV_SampleSize] + mov byte [dpatch6+2],bl + + ; Right channel offset + mov ebx, dword [_MV_RightChannelOffset] + mov dword [dpatch4+3],ebx + mov dword [dpatch5+3],ebx + + ; Volume table ptr + mov ebx, dword [_MV_LeftVolume] + mov dword [dpatch1+4],ebx + + mov ebx, dword [_MV_RightVolume] + mov dword [dpatch2+4],ebx + + ; Rate scale ptr + mov dword [dpatch3+2],edx + + mov edi, dword [_MV_MixDestination] ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je near exit16S + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; dpatch1 - left volume table +; dpatch2 - right volume table +; dpatch3 - sample rate + + mov eax,ebp ; begin calculating first sample + shr eax,16 ; finish calculation for first sample + + movzx ebx, byte [esi+eax] ; get first sample + + ALIGN 4 +mix16Sloop: +dpatch1: + movsx eax, word [2*ebx+12345678h] ; volume translate left sample + movsx edx, word [edi] ; get current sample from destination +dpatch2: + movsx ebx, word [2*ebx+12345678h] ; volume translate right sample + add eax, edx ; mix left sample +dpatch3: + add ebp,12345678h ; advance frac pointer +dpatch4: + movsx edx, word [edi+12345678h] ; get current sample from destination + + cmp eax, -32768 ; Harsh clip sample + jge short s16skip1 + mov eax, -32768 + jmp short s16skip2 +s16skip1: + cmp eax, 32767 + jle short s16skip2 + mov eax, 32767 +s16skip2: + add ebx, edx ; mix right sample + mov word [edi], ax ; write left sample to destination + + cmp ebx, -32768 ; Harsh clip sample + jge short s16skip3 + mov ebx, -32768 + jmp short s16skip4 +s16skip3: + cmp ebx, 32767 + jle short s16skip4 + mov ebx, 32767 +s16skip4: + + mov edx, ebp ; begin calculating second sample +dpatch5: + mov word [edi+12345678h], bx ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +dpatch6: + add edi, 4 ; move destination to second sample + movzx ebx, byte [esi+edx] ; get second sample + dec ecx ; decrement count + jnz mix16Sloop ; loop + + mov dword [_MV_MixDestination], edi ; Store the current write position + mov dword [_MV_MixPosition], ebp ; return position +exit16S: + popad + ret + diff --git a/polymer/eduke32/source/jaudiolib/mv_mix.wasm b/polymer/eduke32/source/jaudiolib/mv_mix.wasm new file mode 100644 index 000000000..7f6ca7971 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mv_mix.wasm @@ -0,0 +1,491 @@ +.586P + +EXTRN _MV_HarshClipTable : dword +EXTRN _MV_MixDestination : dword +EXTRN _MV_MixPosition : dword +EXTRN _MV_LeftVolume : dword +EXTRN _MV_RightVolume : dword +EXTRN _MV_SampleSize : dword +EXTRN _MV_RightChannelOffset : dword + +CODE SEGMENT PUBLIC USE32 'DATA' +ASSUME cs:CODE,ds:CODE + +;================ +; +; MV_Mix8BitMono +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC MV_Mix8BitMono_ +MV_Mix8BitMono_: +; Two at once + pushad + ; Thanks to Lauri Liinat for spotting this lunacy + ;mov eax, dword ptr [esp + 0*4 + 9*4] + ;mov edx, dword ptr [esp + 1*4 + 9*4] + ;mov ebx, dword ptr [esp + 2*4 + 9*4] + ;mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [apatch7+2],bl + mov byte ptr [apatch8+2],bl + mov byte ptr [apatch9+3],bl + + ; Volume table ptr + mov ebx, _MV_LeftVolume ; Since we're mono, use left volume + mov dword ptr [apatch1+4],ebx + mov dword ptr [apatch2+4],ebx + + ; Harsh Clip table ptr + mov ebx, _MV_HarshClipTable + add ebx, 128 + mov dword ptr [apatch3+2],ebx + mov dword ptr [apatch4+2],ebx + + ; Rate scale ptr + mov dword ptr [apatch5+2],edx + mov dword ptr [apatch6+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + shr ecx, 1 ; double sample count + cmp ecx, 0 + je short exit8m + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; apatch1 - volume table +; apatch2 - volume table +; apatch3 - harsh clip table +; apatch4 - harsh clip table +; apatch5 - sample rate +; apatch6 - sample rate + + mov eax,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr eax,16 ; finish calculation for first sample + + mov ebx,ebp ; begin calculating second sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for second sample + + movzx eax, byte ptr [esi+eax] ; get first sample + movzx ebx, byte ptr [esi+ebx] ; get second sample + +;ALIGN 4 +mix8Mloop: + movzx edx, byte ptr [edi] ; get current sample from destination +apatch1: + movsx eax, byte ptr [2*eax+12345678h] ; volume translate first sample +apatch2: + movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate second sample + add eax, edx ; mix first sample +apatch9: + movzx edx, byte ptr [edi + 1] ; get current sample from destination +apatch3: + mov eax, [eax + 12345678h] ; harsh clip new sample + add ebx, edx ; mix second sample + mov [edi], al ; write new sample to destination + mov edx, ebp ; begin calculating third sample +apatch4: + mov ebx, [ebx + 12345678h] ; harsh clip new sample +apatch5: + add ebp,12345678h ; advance frac pointer + shr edx, 16 ; finish calculation for third sample + mov eax, ebp ; begin calculating fourth sample +apatch7: + add edi, 1 ; move destination to second sample + shr eax, 16 ; finish calculation for fourth sample + mov [edi], bl ; write new sample to destination +apatch6: + add ebp,12345678h ; advance frac pointer + movzx ebx, byte ptr [esi+eax] ; get fourth sample + movzx eax, byte ptr [esi+edx] ; get third sample +apatch8: + add edi, 2 ; move destination to third sample + dec ecx ; decrement count + jnz mix8Mloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +exit8m: + popad + ret + + +;================ +; +; MV_Mix8BitStereo +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC MV_Mix8BitStereo_ +MV_Mix8BitStereo_: + pushad + ; Thanks to Lauri Liinat for spotting this lunacy + ;mov eax, dword ptr [esp + 0*4 + 9*4] + ;mov edx, dword ptr [esp + 1*4 + 9*4] + ;mov ebx, dword ptr [esp + 2*4 + 9*4] + ;mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [bpatch8+2],bl + + ; Right channel offset + mov ebx, _MV_RightChannelOffset + mov dword ptr [bpatch6+3],ebx + mov dword ptr [bpatch7+2],ebx + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [bpatch1+4],ebx + + mov ebx, _MV_RightVolume + mov dword ptr [bpatch2+4],ebx + + ; Rate scale ptr + mov dword ptr [bpatch3+2],edx + + ; Harsh Clip table ptr + mov ebx, _MV_HarshClipTable + add ebx,128 + mov dword ptr [bpatch4+2],ebx + mov dword ptr [bpatch5+2],ebx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je short exit8S + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; bpatch1 - left volume table +; bpatch2 - right volume table +; bpatch3 - sample rate +; bpatch4 - harsh clip table +; bpatch5 - harsh clip table + + mov eax,ebp ; begin calculating first sample + shr eax,16 ; finish calculation for first sample + + movzx ebx, byte ptr [esi+eax] ; get first sample + +;ALIGN 4 +mix8Sloop: +bpatch1: + movsx eax, byte ptr [2*ebx+12345678h] ; volume translate left sample + movzx edx, byte ptr [edi] ; get current sample from destination +bpatch2: + movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate right sample + add eax, edx ; mix left sample +bpatch3: + add ebp,12345678h ; advance frac pointer +bpatch6: + movzx edx, byte ptr [edi+12345678h] ; get current sample from destination +bpatch4: + mov eax, [eax + 12345678h] ; harsh clip left sample + add ebx, edx ; mix right sample + mov [edi], al ; write left sample to destination +bpatch5: + mov ebx, [ebx + 12345678h] ; harsh clip right sample + mov edx, ebp ; begin calculating second sample +bpatch7: + mov [edi+12345678h], bl ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +bpatch8: + add edi, 2 ; move destination to second sample + movzx ebx, byte ptr [esi+edx] ; get second sample + dec ecx ; decrement count + jnz mix8Sloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position + +EXIT8S: + popad + ret + + +;================ +; +; MV_Mix16BitMono +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC MV_Mix16BitMono_ +MV_Mix16BitMono_: +; Two at once + pushad + ; Thanks to Lauri Liinat for spotting this lunacy + ;mov eax, dword ptr [esp + 0*4 + 9*4] + ;mov edx, dword ptr [esp + 1*4 + 9*4] + ;mov ebx, dword ptr [esp + 2*4 + 9*4] + ;mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [cpatch5+3],bl + mov byte ptr [cpatch6+3],bl + add bl,bl + mov byte ptr [cpatch7+2],bl + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [cpatch1+4],ebx + mov dword ptr [cpatch2+4],ebx + + ; Rate scale ptr + mov dword ptr [cpatch3+2],edx + mov dword ptr [cpatch4+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + shr ecx, 1 ; double sample count + cmp ecx, 0 + je exit16M + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; cpatch1 - volume table +; cpatch2 - volume table +; cpatch3 - sample rate +; cpatch4 - sample rate + + mov eax,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr eax,16 ; finish calculation for first sample + + mov ebx,ebp ; begin calculating second sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for second sample + + movzx eax, byte ptr [esi+eax] ; get first sample + movzx ebx, byte ptr [esi+ebx] ; get second sample + +;ALIGN 4 +mix16Mloop: + movsx edx, word ptr [edi] ; get current sample from destination +cpatch1: + movsx eax, word ptr [2*eax+12345678h] ; volume translate first sample +cpatch2: + movsx ebx, word ptr [2*ebx+12345678h] ; volume translate second sample + add eax, edx ; mix first sample +cpatch5: + movsx edx, word ptr [edi + 2] ; get current sample from destination + + cmp eax, -32768 ; Harsh clip sample + jge short m16skip1 + mov eax, -32768 + jmp short m16skip2 +m16skip1: + cmp eax, 32767 + jle short m16skip2 + mov eax, 32767 +m16skip2: + add ebx, edx ; mix second sample + mov [edi], ax ; write new sample to destination + mov edx, ebp ; begin calculating third sample + + cmp ebx, -32768 ; Harsh clip sample + jge short m16skip3 + mov ebx, -32768 + jmp short m16skip4 +m16skip3: + cmp ebx, 32767 + jle short m16skip4 + mov ebx, 32767 +m16skip4: +cpatch3: + add ebp,12345678h ; advance frac pointer + shr edx, 16 ; finish calculation for third sample + mov eax, ebp ; begin calculating fourth sample +cpatch6: + mov [edi + 2], bx ; write new sample to destination + shr eax, 16 ; finish calculation for fourth sample + +cpatch4: + add ebp,12345678h ; advance frac pointer + movzx ebx, byte ptr [esi+eax] ; get fourth sample +cpatch7: + add edi, 4 ; move destination to third sample + movzx eax, byte ptr [esi+edx] ; get third sample + dec ecx ; decrement count + jnz mix16Mloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +EXIT16M: + popad + ret + + +;================ +; +; MV_Mix16BitStereo +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC MV_Mix16BitStereo_ +MV_Mix16BitStereo_: + pushad + ; Thanks to Lauri Liinat for spotting this lunacy + ;mov eax, dword ptr [esp + 0*4 + 9*4] + ;mov edx, dword ptr [esp + 1*4 + 9*4] + ;mov ebx, dword ptr [esp + 2*4 + 9*4] + ;mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [dpatch6+2],bl + + ; Right channel offset + mov ebx, _MV_RightChannelOffset + mov dword ptr [dpatch4+3],ebx + mov dword ptr [dpatch5+3],ebx + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [dpatch1+4],ebx + + mov ebx, _MV_RightVolume + mov dword ptr [dpatch2+4],ebx + + ; Rate scale ptr + mov dword ptr [dpatch3+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je exit16S + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; dpatch1 - left volume table +; dpatch2 - right volume table +; dpatch3 - sample rate + + mov eax,ebp ; begin calculating first sample + shr eax,16 ; finish calculation for first sample + + movzx ebx, byte ptr [esi+eax] ; get first sample + +;ALIGN 4 +mix16Sloop: +dpatch1: + movsx eax, word ptr [2*ebx+12345678h] ; volume translate left sample + movsx edx, word ptr [edi] ; get current sample from destination +dpatch2: + movsx ebx, word ptr [2*ebx+12345678h] ; volume translate right sample + add eax, edx ; mix left sample +dpatch3: + add ebp,12345678h ; advance frac pointer +dpatch4: + movsx edx, word ptr [edi+12345678h] ; get current sample from destination + + cmp eax, -32768 ; Harsh clip sample + jge short s16skip1 + mov eax, -32768 + jmp short s16skip2 +s16skip1: + cmp eax, 32767 + jle short s16skip2 + mov eax, 32767 +s16skip2: + add ebx, edx ; mix right sample + mov [edi], ax ; write left sample to destination + + cmp ebx, -32768 ; Harsh clip sample + jge short s16skip3 + mov ebx, -32768 + jmp short s16skip4 +s16skip3: + cmp ebx, 32767 + jle short s16skip4 + mov ebx, 32767 +s16skip4: + + mov edx, ebp ; begin calculating second sample +dpatch5: + mov [edi+12345678h], bx ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +dpatch6: + add edi, 4 ; move destination to second sample + movzx ebx, byte ptr [esi+edx] ; get second sample + dec ecx ; decrement count + jnz mix16Sloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +exit16S: + popad + ret + +CODE ENDS +END diff --git a/polymer/eduke32/source/jaudiolib/mv_mix16.masm b/polymer/eduke32/source/jaudiolib/mv_mix16.masm new file mode 100644 index 000000000..a949ba915 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mv_mix16.masm @@ -0,0 +1,507 @@ +.586P + +EXTRN _MV_HarshClipTable:DWORD +EXTRN _MV_MixDestination:DWORD +EXTRN _MV_MixPosition:DWORD +EXTRN _MV_LeftVolume:DWORD +EXTRN _MV_RightVolume:DWORD +EXTRN _MV_SampleSize:DWORD +EXTRN _MV_RightChannelOffset:DWORD + +CODE SEGMENT PUBLIC USE32 'DATA' +ASSUME cs:CODE,ds:CODE + + +;================ +; +; MV_Mix8BitMono16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC _MV_Mix8BitMono16 +_MV_Mix8BitMono16: +; Two at once + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + inc esi + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [apatch7+2],bl + mov byte ptr [apatch8+2],bl + mov byte ptr [apatch9+3],bl + + ; Volume table ptr + mov ebx, _MV_LeftVolume ; Since we're mono, use left volume + mov dword ptr [apatch1+4],ebx + mov dword ptr [apatch2+4],ebx + + ; Harsh Clip table ptr + mov ebx, _MV_HarshClipTable + add ebx, 128 + mov dword ptr [apatch3+2],ebx + mov dword ptr [apatch4+2],ebx + + ; Rate scale ptr + mov dword ptr [apatch5+2],edx + mov dword ptr [apatch6+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + shr ecx, 1 ; double sample count + cmp ecx, 0 + je exit8m + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; apatch1 - volume table +; apatch2 - volume table +; apatch3 - harsh clip table +; apatch4 - harsh clip table +; apatch5 - sample rate +; apatch6 - sample rate + + mov eax,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr eax,16 ; finish calculation for first sample + + mov ebx,ebp ; begin calculating second sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for second sample + + movsx eax, byte ptr [esi+2*eax] ; get first sample + movsx ebx, byte ptr [esi+2*ebx] ; get second sample + add eax, 80h + add ebx, 80h + +;ALIGN 4 +mix8Mloop: + movzx edx, byte ptr [edi] ; get current sample from destination +apatch1: + movsx eax, byte ptr [2*eax+12345678h] ; volume translate first sample +apatch2: + movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate second sample + add eax, edx ; mix first sample +apatch9: + movzx edx, byte ptr [edi + 1] ; get current sample from destination +apatch3: + mov eax, [eax + 12345678h] ; harsh clip new sample + add ebx, edx ; mix second sample + mov [edi], al ; write new sample to destination + mov edx, ebp ; begin calculating third sample +apatch4: + mov ebx, [ebx + 12345678h] ; harsh clip new sample +apatch5: + add ebp,12345678h ; advance frac pointer + shr edx, 16 ; finish calculation for third sample + mov eax, ebp ; begin calculating fourth sample +apatch7: + add edi, 2 ; move destination to second sample + shr eax, 16 ; finish calculation for fourth sample + mov [edi], bl ; write new sample to destination +apatch6: + add ebp,12345678h ; advance frac pointer + movsx ebx, byte ptr [esi+2*eax] ; get fourth sample + movsx eax, byte ptr [esi+2*edx] ; get third sample + add ebx, 80h + add eax, 80h +apatch8: + add edi, 2 ; move destination to third sample + dec ecx ; decrement count + jnz mix8Mloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +exit8m: + popad + ret + + +;================ +; +; MV_Mix8BitStereo16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC _MV_Mix8BitStereo16 +_MV_Mix8BitStereo16: + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + inc esi + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [bpatch8+2],bl + ; mov byte ptr [bpatch9+2],bl + + ; Right channel offset + mov ebx, _MV_RightChannelOffset + mov dword ptr [bpatch6+3],ebx + mov dword ptr [bpatch7+2],ebx + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [bpatch1+4],ebx + + mov ebx, _MV_RightVolume + mov dword ptr [bpatch2+4],ebx + + ; Rate scale ptr + mov dword ptr [bpatch3+2],edx + + ; Harsh Clip table ptr + mov ebx, _MV_HarshClipTable + add ebx,128 + mov dword ptr [bpatch4+2],ebx + mov dword ptr [bpatch5+2],ebx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je short exit8S + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; bpatch1 - left volume table +; bpatch2 - right volume table +; bpatch3 - sample rate +; bpatch4 - harsh clip table +; bpatch5 - harsh clip table + + mov eax,ebp ; begin calculating first sample + shr eax,16 ; finish calculation for first sample + + movsx ebx, byte ptr [esi+2*eax] ; get first sample + add ebx, 80h + +;ALIGN 4 +mix8Sloop: +bpatch1: + movsx eax, byte ptr [2*ebx+12345678h] ; volume translate left sample + movzx edx, byte ptr [edi] ; get current sample from destination +bpatch2: + movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate right sample + add eax, edx ; mix left sample +bpatch3: + add ebp,12345678h ; advance frac pointer +bpatch6: + movzx edx, byte ptr [edi+12345678h] ; get current sample from destination +bpatch4: + mov eax, [eax + 12345678h] ; harsh clip left sample + add ebx, edx ; mix right sample + mov [edi], al ; write left sample to destination +bpatch5: + mov ebx, [ebx + 12345678h] ; harsh clip right sample + mov edx, ebp ; begin calculating second sample +bpatch7: + mov [edi+12345678h], bl ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +bpatch8: + add edi, 1 ; move destination to second sample + movsx ebx, byte ptr [esi+2*edx] ; get second sample + add ebx, 80h + dec ecx ; decrement count + jnz mix8Sloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position + +EXIT8S: + popad + ret + + +;================ +; +; MV_Mix16BitMono16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC _MV_Mix16BitMono16 +_MV_Mix16BitMono16: + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [cpatch4+2],bl + mov byte ptr [cpatch5+3],bl + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [cpatch2+4],ebx + inc ebx + mov dword ptr [cpatch1+4],ebx + + ; Rate scale ptr + mov dword ptr [cpatch3+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je exit16M + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; cpatch1 - volume table +; cpatch2 - volume table +; cpatch3 - sample rate +; cpatch4 - sample rate + + mov ebx,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for first sample + movzx eax, word ptr [esi+2*ebx] ; get low byte of sample + xor eax, 8000h + movzx ebx, ah + sub ah, ah + + movsx edx, word ptr [edi] ; get current sample from destination + +;ALIGN 4 +mix16Mloop: +cpatch1: + movsx eax, byte ptr [2*eax+12345678h] ; volume translate low byte of sample +cpatch2: + movsx ebx, word ptr [2*ebx+12345678h] ; volume translate high byte of sample + lea eax, [ eax + ebx + 80h ] ; mix high byte of sample + add eax, edx ; mix low byte of sample +cpatch5: + movsx edx, word ptr [edi + 2] ; get current sample from destination + + cmp eax, -32768 ; Harsh clip sample + jge short m16skip1 + mov eax, -32768 + jmp short m16skip2 +m16skip1: + cmp eax, 32767 + jle short m16skip2 + mov eax, 32767 +m16skip2: + mov ebx, ebp ; begin calculating second sample + mov [edi], ax ; write new sample to destination + + shr ebx, 16 ; finish calculation for second sample +cpatch3: + add ebp, 12345678h ; advance frac pointer + + movzx eax, word ptr [esi+2*ebx] ; get second sample +cpatch4: + add edi, 2 ; move destination to second sample + xor eax, 8000h + movzx ebx, ah + sub ah, ah + + dec ecx ; decrement count + jnz mix16Mloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +EXIT16M: + popad + ret + + +;================ +; +; MV_Mix16BitStereo16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC _MV_Mix16BitStereo16 +_MV_Mix16BitStereo16: + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [dpatch9+2],bl + + ; Right channel offset + mov ebx, _MV_RightChannelOffset + mov dword ptr [dpatch7+3],ebx + mov dword ptr [dpatch8+3],ebx + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [dpatch1+4],ebx + inc ebx + mov dword ptr [dpatch2+4],ebx + + mov ebx, _MV_RightVolume + mov dword ptr [dpatch3+4],ebx + inc ebx + mov dword ptr [dpatch4+4],ebx + + ; Rate scale ptr + mov dword ptr [dpatch5+2],edx + + ; Source ptr + mov dword ptr [dpatch6+4],esi + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je exit16S + +; eax - scratch +; ebx - scratch +; edx - scratch +; esi - scratch +; ecx - count +; edi - destination +; ebp - frac pointer +; dpatch1 - left volume table +; dpatch2 - right volume table +; dpatch3 - sample rate + + mov ebx,ebp ; begin calculating first sample + shr ebx,16 ; finish calculation for first sample + + movzx edx, word ptr [esi+2*ebx] ; get first sample + xor edx, 8000h ; Change from signed to unsigned + movzx esi, dh ; put high byte in esi + sub dh, dh ; lo byte in edx + +;ALIGN 4 +mix16Sloop: + ; Left channel +dpatch1: + movsx eax, word ptr [2*esi+12345678h] ; volume translate high byte of sample +dpatch2: + movsx ebx, byte ptr [2*edx+12345678h] ; volume translate low byte of sample + lea eax, [ eax + ebx + 80h ] ; mix high byte of sample + + ; Right channel +dpatch3: + movsx esi, word ptr [2*esi+12345678h] ; volume translate high byte of sample +dpatch4: + movsx ebx, byte ptr [2*edx+12345678h] ; volume translate low byte of sample + lea ebx, [ esi + ebx + 80h ] ; mix high byte of sample + +dpatch7: + movsx edx, word ptr [edi+12345678h] ; get current sample from destination +dpatch5: + add ebp,12345678h ; advance frac pointer + + add eax, edx ; mix left sample + + cmp eax, -32768 ; Harsh clip sample + jge short s16skip1 + mov eax, -32768 + jmp short s16skip2 +s16skip1: + cmp eax, 32767 + jle short s16skip2 + mov eax, 32767 +s16skip2: + movsx edx, word ptr [edi+2] ; get current sample from destination + mov [edi], ax ; write left sample to destination + add ebx, edx ; mix right sample + + cmp ebx, -32768 ; Harsh clip sample + jge short s16skip3 + mov ebx, -32768 + jmp short s16skip4 +s16skip3: + cmp ebx, 32767 + jle short s16skip4 + mov ebx, 32767 +s16skip4: + + mov edx, ebp ; begin calculating second sample +dpatch8: + mov [edi+12345678h], bx ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +dpatch9: + add edi, 4 ; move destination to second sample + +dpatch6: + movzx edx, word ptr [2*edx+12345678h] ; get second sample + xor edx, 8000h ; Change from signed to unsigned + movzx esi, dh ; put high byte in esi + sub dh, dh ; lo byte in edx + + dec ecx ; decrement count + jnz mix16Sloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +exit16S: + popad + ret + + +CODE ENDS +END diff --git a/polymer/eduke32/source/jaudiolib/mv_mix16.nasm b/polymer/eduke32/source/jaudiolib/mv_mix16.nasm new file mode 100644 index 000000000..110329ecb --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mv_mix16.nasm @@ -0,0 +1,544 @@ +;Copyright (C) 1994-1995 Apogee Software, Ltd. +; +;This program 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. +; +;Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) + + +CPU 386 + +SECTION .data + +%ifdef UNDERSCORES + +%define MV_Mix8BitMono16 _MV_Mix8BitMono16 +%define MV_Mix8BitStereo16 _MV_Mix8BitStereo16 +%define MV_Mix16BitMono16 _MV_Mix16BitMono16 +%define MV_Mix16BitStereo16 _MV_Mix16BitStereo16 + +%else + +%define _MV_HarshClipTable MV_HarshClipTable +%define _MV_MixDestination MV_MixDestination +%define _MV_MixPosition MV_MixPosition +%define _MV_LeftVolume MV_LeftVolume +%define _MV_RightVolume MV_RightVolume +%define _MV_SampleSize MV_SampleSize +%define _MV_RightChannelOffset MV_RightChannelOffset + +%endif + + EXTERN _MV_HarshClipTable + EXTERN _MV_MixDestination + EXTERN _MV_MixPosition + EXTERN _MV_LeftVolume + EXTERN _MV_RightVolume + EXTERN _MV_SampleSize + EXTERN _MV_RightChannelOffset + + GLOBAL MV_Mix8BitMono16 + GLOBAL MV_Mix8BitStereo16 + GLOBAL MV_Mix16BitMono16 + GLOBAL MV_Mix16BitStereo16 + +%define OFFSET + +;================ +; +; MV_Mix8BitMono16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + + ALIGN 4 +MV_Mix8BitMono16: +; Two at once + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + inc esi + + ; Sample size + mov ebx, dword [_MV_SampleSize] + mov byte [apatch7+2],bl + mov byte [apatch8+2],bl + mov byte [apatch9+3],bl + + ; Volume table ptr + mov ebx, dword [_MV_LeftVolume] ; Since we're mono, use left volume + mov dword [apatch1+4],ebx + mov dword [apatch2+4],ebx + + ; Harsh Clip table ptr + mov ebx, dword [_MV_HarshClipTable] + add ebx, 128 + mov dword [apatch3+2],ebx + mov dword [apatch4+2],ebx + + ; Rate scale ptr + mov dword [apatch5+2],edx + mov dword [apatch6+2],edx + + mov edi, dword [_MV_MixDestination] ; Get the position to write to + + ; Number of samples to mix + shr ecx, 1 ; double sample count + cmp ecx, 0 + je near exit8m + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; apatch1 - volume table +; apatch2 - volume table +; apatch3 - harsh clip table +; apatch4 - harsh clip table +; apatch5 - sample rate +; apatch6 - sample rate + + mov eax,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr eax,16 ; finish calculation for first sample + + mov ebx,ebp ; begin calculating second sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for second sample + + movsx eax, byte [esi+2*eax] ; get first sample + movsx ebx, byte [esi+2*ebx] ; get second sample + add eax, 80h + add ebx, 80h + + ALIGN 4 +mix8Mloop: + movzx edx, byte [edi] ; get current sample from destination +apatch1: + movsx eax, byte [2*eax+12345678h] ; volume translate first sample +apatch2: + movsx ebx, byte [2*ebx+12345678h] ; volume translate second sample + add eax, edx ; mix first sample +apatch9: + movzx edx, byte [edi + 1] ; get current sample from destination +apatch3: + mov eax, dword [eax + 12345678h] ; harsh clip new sample + add ebx, edx ; mix second sample + mov byte [edi], al ; write new sample to destination + mov edx, ebp ; begin calculating third sample +apatch4: + mov ebx, dword [ebx + 12345678h] ; harsh clip new sample +apatch5: + add ebp,12345678h ; advance frac pointer + shr edx, 16 ; finish calculation for third sample + mov eax, ebp ; begin calculating fourth sample +apatch7: + add edi, 2 ; move destination to second sample + shr eax, 16 ; finish calculation for fourth sample + mov byte [edi], bl ; write new sample to destination +apatch6: + add ebp,12345678h ; advance frac pointer + movsx ebx, byte [esi+2*eax] ; get fourth sample + movsx eax, byte [esi+2*edx] ; get third sample + add ebx, 80h + add eax, 80h +apatch8: + add edi, 2 ; move destination to third sample + dec ecx ; decrement count + jnz mix8Mloop ; loop + + mov dword [_MV_MixDestination], edi ; Store the current write position + mov dword [_MV_MixPosition], ebp ; return position +exit8m: + popad + ret + + +;================ +; +; MV_Mix8BitStereo16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + + ALIGN 4 +MV_Mix8BitStereo16: + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + inc esi + + ; Sample size + mov ebx, dword [_MV_SampleSize] + mov byte [bpatch8+2],bl + ; mov byte [bpatch9+2],bl + + ; Right channel offset + mov ebx, dword [_MV_RightChannelOffset] + mov dword [bpatch6+3],ebx + mov dword [bpatch7+2],ebx + + ; Volume table ptr + mov ebx, dword [_MV_LeftVolume] + mov dword [bpatch1+4],ebx + + mov ebx, dword [_MV_RightVolume] + mov dword [bpatch2+4],ebx + + ; Rate scale ptr + mov dword [bpatch3+2],edx + + ; Harsh Clip table ptr + mov ebx, dword [_MV_HarshClipTable] + add ebx,128 + mov dword [bpatch4+2],ebx + mov dword [bpatch5+2],ebx + + mov edi, dword [_MV_MixDestination] ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je short EXIT8S + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; bpatch1 - left volume table +; bpatch2 - right volume table +; bpatch3 - sample rate +; bpatch4 - harsh clip table +; bpatch5 - harsh clip table + + mov eax,ebp ; begin calculating first sample + shr eax,16 ; finish calculation for first sample + + movsx ebx, byte [esi+2*eax] ; get first sample + add ebx, 80h + + ALIGN 4 +mix8Sloop: +bpatch1: + movsx eax, byte [2*ebx+12345678h] ; volume translate left sample + movzx edx, byte [edi] ; get current sample from destination +bpatch2: + movsx ebx, byte [2*ebx+12345678h] ; volume translate right sample + add eax, edx ; mix left sample +bpatch3: + add ebp,12345678h ; advance frac pointer +bpatch6: + movzx edx, byte [edi+12345678h] ; get current sample from destination +bpatch4: + mov eax, dword [eax + 12345678h] ; harsh clip left sample + add ebx, edx ; mix right sample + mov byte [edi], al ; write left sample to destination +bpatch5: + mov ebx, dword [ebx + 12345678h] ; harsh clip right sample + mov edx, ebp ; begin calculating second sample +bpatch7: + mov byte [edi+12345678h], bl ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +bpatch8: + add edi, 1 ; move destination to second sample + movsx ebx, byte [esi+2*edx] ; get second sample + add ebx, 80h + dec ecx ; decrement count + jnz mix8Sloop ; loop + + mov dword [_MV_MixDestination], edi ; Store the current write position + mov dword [_MV_MixPosition], ebp ; return position + +EXIT8S: + popad + ret + + +;================ +; +; MV_Mix16BitMono16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + + ALIGN 4 +MV_Mix16BitMono16: + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, dword [_MV_SampleSize] + mov byte [cpatch4+2],bl + mov byte [cpatch5+3],bl + + ; Volume table ptr + mov ebx, dword [_MV_LeftVolume] + mov dword [cpatch2+4],ebx + inc ebx + mov dword [cpatch1+4],ebx + + ; Rate scale ptr + mov dword [cpatch3+2],edx + + mov edi, dword [_MV_MixDestination] ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je near EXIT16M + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; cpatch1 - volume table +; cpatch2 - volume table +; cpatch3 - sample rate +; cpatch4 - sample rate + + mov ebx,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for first sample + movzx eax, word [esi+2*ebx] ; get low byte of sample + xor eax, 8000h + movzx ebx, ah + sub ah, ah + + movsx edx, word [edi] ; get current sample from destination + + ALIGN 4 +mix16Mloop: +cpatch1: + movsx eax, byte [2*eax+12345678h] ; volume translate low byte of sample +cpatch2: + movsx ebx, word [2*ebx+12345678h] ; volume translate high byte of sample + lea eax, [ eax + ebx + 80h ] ; mix high byte of sample + add eax, edx ; mix low byte of sample +cpatch5: + movsx edx, word [edi + 2] ; get current sample from destination + + cmp eax, -32768 ; Harsh clip sample + jge short m16skip1 + mov eax, -32768 + jmp short m16skip2 +m16skip1: + cmp eax, 32767 + jle short m16skip2 + mov eax, 32767 +m16skip2: + mov ebx, ebp ; begin calculating second sample + mov word [edi], ax ; write new sample to destination + + shr ebx, 16 ; finish calculation for second sample +cpatch3: + add ebp, 12345678h ; advance frac pointer + + movzx eax, word [esi+2*ebx] ; get second sample +cpatch4: + add edi, 2 ; move destination to second sample + xor eax, 8000h + movzx ebx, ah + sub ah, ah + + dec ecx ; decrement count + jnz mix16Mloop ; loop + + mov dword [_MV_MixDestination], edi ; Store the current write position + mov dword [_MV_MixPosition], ebp ; return position +EXIT16M: + popad + ret + + +;================ +; +; MV_Mix16BitStereo16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + + ALIGN 4 +MV_Mix16BitStereo16: + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, dword [_MV_SampleSize] + mov byte [dpatch9+2],bl + + ; Right channel offset + mov ebx, dword [_MV_RightChannelOffset] + mov dword [dpatch7+3],ebx + mov dword [dpatch8+3],ebx + + ; Volume table ptr + mov ebx, dword [_MV_LeftVolume] + mov dword [dpatch1+4],ebx + inc ebx + mov dword [dpatch2+4],ebx + + mov ebx, dword [_MV_RightVolume] + mov dword [dpatch3+4],ebx + inc ebx + mov dword [dpatch4+4],ebx + + ; Rate scale ptr + mov dword [dpatch5+2],edx + + ; Source ptr + mov dword [dpatch6+4],esi + + mov edi, dword [_MV_MixDestination] ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je near exit16S + +; eax - scratch +; ebx - scratch +; edx - scratch +; esi - scratch +; ecx - count +; edi - destination +; ebp - frac pointer +; dpatch1 - left volume table +; dpatch2 - right volume table +; dpatch3 - sample rate + + mov ebx,ebp ; begin calculating first sample + shr ebx,16 ; finish calculation for first sample + + movzx edx, word [esi+2*ebx] ; get first sample + xor edx, 8000h ; Change from signed to unsigned + movzx esi, dh ; put high byte in esi + sub dh, dh ; lo byte in edx + + ALIGN 4 +mix16Sloop: + ; Left channel +dpatch1: + movsx eax, word [2*esi+12345678h] ; volume translate high byte of sample +dpatch2: + movsx ebx, byte [2*edx+12345678h] ; volume translate low byte of sample + lea eax, [ eax + ebx + 80h ] ; mix high byte of sample + + ; Right channel +dpatch3: + movsx esi, word [2*esi+12345678h] ; volume translate high byte of sample +dpatch4: + movsx ebx, byte [2*edx+12345678h] ; volume translate low byte of sample + lea ebx, [ esi + ebx + 80h ] ; mix high byte of sample + +dpatch7: + movsx edx, word [edi+12345678h] ; get current sample from destination +dpatch5: + add ebp,12345678h ; advance frac pointer + + add eax, edx ; mix left sample + + cmp eax, -32768 ; Harsh clip sample + jge short s16skip1 + mov eax, -32768 + jmp short s16skip2 +s16skip1: + cmp eax, 32767 + jle short s16skip2 + mov eax, 32767 +s16skip2: + movsx edx, word [edi+2] ; get current sample from destination + mov word [edi], ax ; write left sample to destination + add ebx, edx ; mix right sample + + cmp ebx, -32768 ; Harsh clip sample + jge short s16skip3 + mov ebx, -32768 + jmp short s16skip4 +s16skip3: + cmp ebx, 32767 + jle short s16skip4 + mov ebx, 32767 +s16skip4: + + mov edx, ebp ; begin calculating second sample +dpatch8: + mov word [edi+12345678h], bx ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +dpatch9: + add edi, 4 ; move destination to second sample + +dpatch6: + movzx edx, word [2*edx+12345678h] ; get second sample + xor edx, 8000h ; Change from signed to unsigned + movzx esi, dh ; put high byte in esi + sub dh, dh ; lo byte in edx + + dec ecx ; decrement count + jnz mix16Sloop ; loop + + mov dword [_MV_MixDestination], edi ; Store the current write position + mov dword [_MV_MixPosition], ebp ; return position +exit16S: + popad + ret + diff --git a/polymer/eduke32/source/jaudiolib/mv_mix16.wasm b/polymer/eduke32/source/jaudiolib/mv_mix16.wasm new file mode 100644 index 000000000..3d6e711d6 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mv_mix16.wasm @@ -0,0 +1,511 @@ +.586P + +EXTRN _MV_HarshClipTable:DWORD +EXTRN _MV_MixDestination:DWORD +EXTRN _MV_MixPosition:DWORD +EXTRN _MV_LeftVolume:DWORD +EXTRN _MV_RightVolume:DWORD +EXTRN _MV_SampleSize:DWORD +EXTRN _MV_RightChannelOffset:DWORD + +CODE SEGMENT PUBLIC USE32 'DATA' +ASSUME cs:CODE,ds:CODE + + +;================ +; +; MV_Mix8BitMono16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC MV_Mix8BitMono16_ +MV_Mix8BitMono16_: +; Two at once + pushad + ; Thanks to Lauri Liinat for spotting this lunacy + ;mov eax, dword ptr [esp + 0*4 + 9*4] + ;mov edx, dword ptr [esp + 1*4 + 9*4] + ;mov ebx, dword ptr [esp + 2*4 + 9*4] + ;mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + inc esi + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [apatch7+2],bl + mov byte ptr [apatch8+2],bl + mov byte ptr [apatch9+3],bl + + ; Volume table ptr + mov ebx, _MV_LeftVolume ; Since we're mono, use left volume + mov dword ptr [apatch1+4],ebx + mov dword ptr [apatch2+4],ebx + + ; Harsh Clip table ptr + mov ebx, _MV_HarshClipTable + add ebx, 128 + mov dword ptr [apatch3+2],ebx + mov dword ptr [apatch4+2],ebx + + ; Rate scale ptr + mov dword ptr [apatch5+2],edx + mov dword ptr [apatch6+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + shr ecx, 1 ; double sample count + cmp ecx, 0 + je exit8m + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; apatch1 - volume table +; apatch2 - volume table +; apatch3 - harsh clip table +; apatch4 - harsh clip table +; apatch5 - sample rate +; apatch6 - sample rate + + mov eax,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr eax,16 ; finish calculation for first sample + + mov ebx,ebp ; begin calculating second sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for second sample + + movsx eax, byte ptr [esi+2*eax] ; get first sample + movsx ebx, byte ptr [esi+2*ebx] ; get second sample + add eax, 80h + add ebx, 80h + +;ALIGN 4 +mix8Mloop: + movzx edx, byte ptr [edi] ; get current sample from destination +apatch1: + movsx eax, byte ptr [2*eax+12345678h] ; volume translate first sample +apatch2: + movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate second sample + add eax, edx ; mix first sample +apatch9: + movzx edx, byte ptr [edi + 1] ; get current sample from destination +apatch3: + mov eax, [eax + 12345678h] ; harsh clip new sample + add ebx, edx ; mix second sample + mov [edi], al ; write new sample to destination + mov edx, ebp ; begin calculating third sample +apatch4: + mov ebx, [ebx + 12345678h] ; harsh clip new sample +apatch5: + add ebp,12345678h ; advance frac pointer + shr edx, 16 ; finish calculation for third sample + mov eax, ebp ; begin calculating fourth sample +apatch7: + add edi, 2 ; move destination to second sample + shr eax, 16 ; finish calculation for fourth sample + mov [edi], bl ; write new sample to destination +apatch6: + add ebp,12345678h ; advance frac pointer + movsx ebx, byte ptr [esi+2*eax] ; get fourth sample + movsx eax, byte ptr [esi+2*edx] ; get third sample + add ebx, 80h + add eax, 80h +apatch8: + add edi, 2 ; move destination to third sample + dec ecx ; decrement count + jnz mix8Mloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +exit8m: + popad + ret + + +;================ +; +; MV_Mix8BitStereo16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC MV_Mix8BitStereo16_ +MV_Mix8BitStereo16_: + pushad + ; Thanks to Lauri Liinat for spotting this lunacy + ;mov eax, dword ptr [esp + 0*4 + 9*4] + ;mov edx, dword ptr [esp + 1*4 + 9*4] + ;mov ebx, dword ptr [esp + 2*4 + 9*4] + ;mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + inc esi + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [bpatch8+2],bl + ; mov byte ptr [bpatch9+2],bl + + ; Right channel offset + mov ebx, _MV_RightChannelOffset + mov dword ptr [bpatch6+3],ebx + mov dword ptr [bpatch7+2],ebx + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [bpatch1+4],ebx + + mov ebx, _MV_RightVolume + mov dword ptr [bpatch2+4],ebx + + ; Rate scale ptr + mov dword ptr [bpatch3+2],edx + + ; Harsh Clip table ptr + mov ebx, _MV_HarshClipTable + add ebx,128 + mov dword ptr [bpatch4+2],ebx + mov dword ptr [bpatch5+2],ebx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je short exit8S + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; bpatch1 - left volume table +; bpatch2 - right volume table +; bpatch3 - sample rate +; bpatch4 - harsh clip table +; bpatch5 - harsh clip table + + mov eax,ebp ; begin calculating first sample + shr eax,16 ; finish calculation for first sample + + movsx ebx, byte ptr [esi+2*eax] ; get first sample + add ebx, 80h + +;ALIGN 4 +mix8Sloop: +bpatch1: + movsx eax, byte ptr [2*ebx+12345678h] ; volume translate left sample + movzx edx, byte ptr [edi] ; get current sample from destination +bpatch2: + movsx ebx, byte ptr [2*ebx+12345678h] ; volume translate right sample + add eax, edx ; mix left sample +bpatch3: + add ebp,12345678h ; advance frac pointer +bpatch6: + movzx edx, byte ptr [edi+12345678h] ; get current sample from destination +bpatch4: + mov eax, [eax + 12345678h] ; harsh clip left sample + add ebx, edx ; mix right sample + mov [edi], al ; write left sample to destination +bpatch5: + mov ebx, [ebx + 12345678h] ; harsh clip right sample + mov edx, ebp ; begin calculating second sample +bpatch7: + mov [edi+12345678h], bl ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +bpatch8: + add edi, 1 ; move destination to second sample + movsx ebx, byte ptr [esi+2*edx] ; get second sample + add ebx, 80h + dec ecx ; decrement count + jnz mix8Sloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position + +EXIT8S: + popad + ret + + +;================ +; +; MV_Mix16BitMono16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC MV_Mix16BitMono16_ +MV_Mix16BitMono16_: + pushad + ; Thanks to Lauri Liinat for spotting this lunacy + ;mov eax, dword ptr [esp + 0*4 + 9*4] + ;mov edx, dword ptr [esp + 1*4 + 9*4] + ;mov ebx, dword ptr [esp + 2*4 + 9*4] + ;mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [cpatch4+2],bl + mov byte ptr [cpatch5+3],bl + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [cpatch2+4],ebx + inc ebx + mov dword ptr [cpatch1+4],ebx + + ; Rate scale ptr + mov dword ptr [cpatch3+2],edx + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je exit16M + +; eax - scratch +; ebx - scratch +; edx - scratch +; ecx - count +; edi - destination +; esi - source +; ebp - frac pointer +; cpatch1 - volume table +; cpatch2 - volume table +; cpatch3 - sample rate +; cpatch4 - sample rate + + mov ebx,ebp ; begin calculating first sample + add ebp,edx ; advance frac pointer + shr ebx,16 ; finish calculation for first sample + movzx eax, word ptr [esi+2*ebx] ; get low byte of sample + xor eax, 8000h + movzx ebx, ah + sub ah, ah + + movsx edx, word ptr [edi] ; get current sample from destination + +;ALIGN 4 +mix16Mloop: +cpatch1: + movsx eax, byte ptr [2*eax+12345678h] ; volume translate low byte of sample +cpatch2: + movsx ebx, word ptr [2*ebx+12345678h] ; volume translate high byte of sample + lea eax, [ eax + ebx + 80h ] ; mix high byte of sample + add eax, edx ; mix low byte of sample +cpatch5: + movsx edx, word ptr [edi + 2] ; get current sample from destination + + cmp eax, -32768 ; Harsh clip sample + jge short m16skip1 + mov eax, -32768 + jmp short m16skip2 +m16skip1: + cmp eax, 32767 + jle short m16skip2 + mov eax, 32767 +m16skip2: + mov ebx, ebp ; begin calculating second sample + mov [edi], ax ; write new sample to destination + + shr ebx, 16 ; finish calculation for second sample +cpatch3: + add ebp, 12345678h ; advance frac pointer + + movzx eax, word ptr [esi+2*ebx] ; get second sample +cpatch4: + add edi, 2 ; move destination to second sample + xor eax, 8000h + movzx ebx, ah + sub ah, ah + + dec ecx ; decrement count + jnz mix16Mloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +EXIT16M: + popad + ret + + +;================ +; +; MV_Mix16BitStereo16 +; +;================ + +; eax - position +; edx - rate +; ebx - start +; ecx - number of samples to mix + +ALIGN 16 +PUBLIC MV_Mix16BitStereo16_ +MV_Mix16BitStereo16_: + pushad + ; Thanks to Lauri Liinat for spotting this lunacy + ;mov eax, dword ptr [esp + 0*4 + 9*4] + ;mov edx, dword ptr [esp + 1*4 + 9*4] + ;mov ebx, dword ptr [esp + 2*4 + 9*4] + ;mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov ebp, eax + + mov esi, ebx ; Source pointer + + ; Sample size + mov ebx, _MV_SampleSize + mov byte ptr [dpatch9+2],bl + + ; Right channel offset + mov ebx, _MV_RightChannelOffset + mov dword ptr [dpatch7+3],ebx + mov dword ptr [dpatch8+3],ebx + + ; Volume table ptr + mov ebx, _MV_LeftVolume + mov dword ptr [dpatch1+4],ebx + inc ebx + mov dword ptr [dpatch2+4],ebx + + mov ebx, _MV_RightVolume + mov dword ptr [dpatch3+4],ebx + inc ebx + mov dword ptr [dpatch4+4],ebx + + ; Rate scale ptr + mov dword ptr [dpatch5+2],edx + + ; Source ptr + mov dword ptr [dpatch6+4],esi + + mov edi, _MV_MixDestination ; Get the position to write to + + ; Number of samples to mix + cmp ecx, 0 + je exit16S + +; eax - scratch +; ebx - scratch +; edx - scratch +; esi - scratch +; ecx - count +; edi - destination +; ebp - frac pointer +; dpatch1 - left volume table +; dpatch2 - right volume table +; dpatch3 - sample rate + + mov ebx,ebp ; begin calculating first sample + shr ebx,16 ; finish calculation for first sample + + movzx edx, word ptr [esi+2*ebx] ; get first sample + xor edx, 8000h ; Change from signed to unsigned + movzx esi, dh ; put high byte in esi + sub dh, dh ; lo byte in edx + +;ALIGN 4 +mix16Sloop: + ; Left channel +dpatch1: + movsx eax, word ptr [2*esi+12345678h] ; volume translate high byte of sample +dpatch2: + movsx ebx, byte ptr [2*edx+12345678h] ; volume translate low byte of sample + lea eax, [ eax + ebx + 80h ] ; mix high byte of sample + + ; Right channel +dpatch3: + movsx esi, word ptr [2*esi+12345678h] ; volume translate high byte of sample +dpatch4: + movsx ebx, byte ptr [2*edx+12345678h] ; volume translate low byte of sample + lea ebx, [ esi + ebx + 80h ] ; mix high byte of sample + +dpatch7: + movsx edx, word ptr [edi+12345678h] ; get current sample from destination +dpatch5: + add ebp,12345678h ; advance frac pointer + + add eax, edx ; mix left sample + + cmp eax, -32768 ; Harsh clip sample + jge short s16skip1 + mov eax, -32768 + jmp short s16skip2 +s16skip1: + cmp eax, 32767 + jle short s16skip2 + mov eax, 32767 +s16skip2: + movsx edx, word ptr [edi+2] ; get current sample from destination + mov [edi], ax ; write left sample to destination + add ebx, edx ; mix right sample + + cmp ebx, -32768 ; Harsh clip sample + jge short s16skip3 + mov ebx, -32768 + jmp short s16skip4 +s16skip3: + cmp ebx, 32767 + jle short s16skip4 + mov ebx, 32767 +s16skip4: + + mov edx, ebp ; begin calculating second sample +dpatch8: + mov [edi+12345678h], bx ; write right sample to destination + shr edx, 16 ; finish calculation for second sample +dpatch9: + add edi, 4 ; move destination to second sample + +dpatch6: + movzx edx, word ptr [2*edx+12345678h] ; get second sample + xor edx, 8000h ; Change from signed to unsigned + movzx esi, dh ; put high byte in esi + sub dh, dh ; lo byte in edx + + dec ecx ; decrement count + jnz mix16Sloop ; loop + + mov _MV_MixDestination, edi ; Store the current write position + mov _MV_MixPosition, ebp ; return position +exit16S: + popad + ret + + +CODE ENDS +END diff --git a/polymer/eduke32/source/jaudiolib/mvreverb.masm b/polymer/eduke32/source/jaudiolib/mvreverb.masm new file mode 100644 index 000000000..9a432534b --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mvreverb.masm @@ -0,0 +1,202 @@ +.586P + +CODE SEGMENT PUBLIC USE32 'DATA' +ASSUME cs:CODE,ds:CODE + +;================ +; +; MV_16BitReverb +; +;================ + +; eax - source position +; edx - destination position +; ebx - Volume table +; ecx - number of samples + +ALIGN 16 +PUBLIC _MV_16BitReverb +_MV_16BitReverb: + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov esi, eax + lea edi, [edx - 2] + +;ALIGN 4 +rev16loop: + movzx eax, word ptr [esi] ; get sample + add edi, 2 + + movzx edx, ah + sub ah, ah + + movsx eax, byte ptr [2*eax+ebx+1] ; volume translate low byte of sample + xor edx, 80h + + movsx edx, word ptr [2*edx+ebx] ; volume translate high byte of sample + add esi, 2 + + lea eax, [ eax + edx + 80h ] ; mix high byte of sample + dec ecx ; decrement count + + mov [edi], ax ; write new sample to destination + jnz rev16loop ; loop + + popad + ret + + +;================ +; +; MV_8BitReverb +; +;================ + +; eax - source position +; edx - destination position +; ebx - Volume table +; ecx - number of samples + +ALIGN 16 +PUBLIC _MV_8BitReverb +_MV_8BitReverb: + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov esi, eax + lea edi, [edx - 1] + + xor eax, eax + +;ALIGN 4 +rev8loop: +; movzx eax, byte ptr [esi] ; get sample + mov al, byte ptr [esi] ; get sample + inc edi + +; movsx eax, byte ptr [2*eax+ebx] ; volume translate sample + mov al, byte ptr [2*eax+ebx] ; volume translate sample + inc esi + +; add eax, 80h + add al, 80h + dec ecx ; decrement count + + mov [edi], al ; write new sample to destination + jnz rev8loop ; loop + + popad + ret + + +;================ +; +; MV_16BitReverbFast +; +;================ + +; eax - source position +; edx - destination position +; ebx - number of samples +; ecx - shift + +ALIGN 16 +PUBLIC _MV_16BitReverbFast +_MV_16BitReverbFast: + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov esi, eax + mov eax,OFFSET rpatch16+3 + + mov [eax],cl + lea edi, [edx - 2] + +;ALIGN 4 +frev16loop: + mov ax, word ptr [esi] ; get sample + add edi, 2 + +rpatch16: + sar ax, 5 ;;;;Add 1 before shift + add esi, 2 + + mov [edi], ax ; write new sample to destination + dec ebx ; decrement count + + jnz frev16loop ; loop + + popad + ret + + +;================ +; +; MV_8BitReverbFast +; +;================ + +; eax - source position +; edx - destination position +; ebx - number of samples +; ecx - shift + +ALIGN 16 +PUBLIC _MV_8BitReverbFast +_MV_8BitReverbFast: + pushad + mov eax, dword ptr [esp + 0*4 + 9*4] + mov edx, dword ptr [esp + 1*4 + 9*4] + mov ebx, dword ptr [esp + 2*4 + 9*4] + mov ecx, dword ptr [esp + 3*4 + 9*4] + + mov esi, eax + mov eax,OFFSET rpatch8+2 + + mov edi, edx + mov edx, 80h + + mov [eax],cl + mov eax, 80h + + shr eax, cl + + dec edi + sub edx, eax + +;ALIGN 4 +frev8loop: + mov al, byte ptr [esi] ; get sample + inc esi + + mov ecx, eax + inc edi + +rpatch8: + shr eax, 3 + xor ecx, 80h ; flip the sign bit + + shr ecx, 7 ; shift the sign down to 1 + add eax, edx + + add eax, ecx ; add sign bit to round to 0 + dec ebx ; decrement count + + mov [edi], al ; write new sample to destination + jnz frev8loop ; loop + + popad + ret + +CODE ENDS +END diff --git a/polymer/eduke32/source/jaudiolib/mvreverb.nasm b/polymer/eduke32/source/jaudiolib/mvreverb.nasm new file mode 100644 index 000000000..4574fa6b6 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mvreverb.nasm @@ -0,0 +1,230 @@ +;Copyright (C) 1994-1995 Apogee Software, Ltd. +; +;This program 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. +; +;Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) + +CPU 386 + +SECTION .data + +%ifdef UNDERSCORES + +%define MV_16BitReverb _MV_16BitReverb +%define MV_8BitReverb _MV_8BitReverb +%define MV_16BitReverbFast _MV_16BitReverbFast +%define MV_8BitReverbFast _MV_8BitReverbFast + +%endif + + GLOBAL MV_16BitReverb + GLOBAL MV_8BitReverb + GLOBAL MV_16BitReverbFast + GLOBAL MV_8BitReverbFast + +%define OFFSET + +;================ +; +; MV_16BitReverb +; +;================ + +; eax - source position +; edx - destination position +; ebx - Volume table +; ecx - number of samples + + ALIGN 4 +MV_16BitReverb: + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov esi, eax + lea edi, [edx - 2] + + ALIGN 4 +rev16loop: + movzx eax, word [esi] ; get sample + add edi, 2 + + movzx edx, ah + sub ah, ah + + movsx eax, byte [2*eax+ebx+1] ; volume translate low byte of sample + xor edx, 80h + + movsx edx, word [2*edx+ebx] ; volume translate high byte of sample + add esi, 2 + + lea eax, [ eax + edx + 80h ] ; mix high byte of sample + dec ecx ; decrement count + + mov word [edi], ax ; write new sample to destination + jnz rev16loop ; loop + + popad + ret + + +;================ +; +; MV_8BitReverb +; +;================ + +; eax - source position +; edx - destination position +; ebx - Volume table +; ecx - number of samples + + ALIGN 4 +MV_8BitReverb: + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov esi, eax + lea edi, [edx - 1] + + xor eax, eax + + ALIGN 4 +rev8loop: +; movzx eax, byte ptr [esi] ; get sample + mov al, byte [esi] ; get sample + inc edi + +; movsx eax, byte ptr [2*eax+ebx] ; volume translate sample + mov al, byte [2*eax+ebx] ; volume translate sample + inc esi + +; add eax, 80h + add al, 80h + dec ecx ; decrement count + + mov byte [edi], al ; write new sample to destination + jnz rev8loop ; loop + + popad + ret + + +;================ +; +; MV_16BitReverbFast +; +;================ + +; eax - source position +; edx - destination position +; ebx - number of samples +; ecx - shift + + ALIGN 4 +MV_16BitReverbFast: + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov esi, eax + mov eax,OFFSET rpatch16+3 + + mov byte [eax],cl + lea edi, [edx - 2] + + ALIGN 4 +frev16loop: + mov ax, word [esi] ; get sample + add edi, 2 + +rpatch16: + sar ax, 5 ;;;;Add 1 before shift + add esi, 2 + + mov word [edi], ax ; write new sample to destination + dec ebx ; decrement count + + jnz frev16loop ; loop + + popad + ret + + +;================ +; +; MV_8BitReverbFast +; +;================ + +; eax - source position +; edx - destination position +; ebx - number of samples +; ecx - shift + + ALIGN 4 +MV_8BitReverbFast: + pushad + mov eax, dword [esp + 0*4 + 9*4] + mov edx, dword [esp + 1*4 + 9*4] + mov ebx, dword [esp + 2*4 + 9*4] + mov ecx, dword [esp + 3*4 + 9*4] + + mov esi, eax + mov eax,OFFSET rpatch8+2 + + mov edi, edx + mov edx, 80h + + mov byte [eax],cl + mov eax, 80h + + shr eax, cl + + dec edi + sub edx, eax + + ALIGN 4 +frev8loop: + mov al, byte [esi] ; get sample + inc esi + + mov ecx, eax + inc edi + +rpatch8: + shr eax, 3 + xor ecx, 80h ; flip the sign bit + + shr ecx, 7 ; shift the sign down to 1 + add eax, edx + + add eax, ecx ; add sign bit to round to 0 + dec ebx ; decrement count + + mov byte [edi], al ; write new sample to destination + jnz frev8loop ; loop + + popad + ret + diff --git a/polymer/eduke32/source/jaudiolib/mvreverb.wasm b/polymer/eduke32/source/jaudiolib/mvreverb.wasm new file mode 100644 index 000000000..249d71b1f --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/mvreverb.wasm @@ -0,0 +1,174 @@ +.586P + +CODE SEGMENT PUBLIC USE32 'DATA' +ASSUME cs:CODE,ds:CODE + +;================ +; +; MV_16BitReverb +; +;================ + +; eax - source position +; edx - destination position +; ebx - Volume table +; ecx - number of samples + +ALIGN 16 +PUBLIC MV_16BitReverb_ +MV_16BitReverb_: + mov esi, eax + lea edi, [edx - 2] + +;ALIGN 4 +rev16loop: + movzx eax, word ptr [esi] ; get sample + add edi, 2 + + movzx edx, ah + sub ah, ah + + movsx eax, byte ptr [2*eax+ebx+1] ; volume translate low byte of sample + xor edx, 80h + + movsx edx, word ptr [2*edx+ebx] ; volume translate high byte of sample + add esi, 2 + + lea eax, [ eax + edx + 80h ] ; mix high byte of sample + dec ecx ; decrement count + + mov [edi], ax ; write new sample to destination + jnz rev16loop ; loop + + ret + + +;================ +; +; MV_8BitReverb +; +;================ + +; eax - source position +; edx - destination position +; ebx - Volume table +; ecx - number of samples + +ALIGN 16 +PUBLIC MV_8BitReverb_ +MV_8BitReverb_: + mov esi, eax + lea edi, [edx - 1] + + xor eax, eax + +;ALIGN 4 +rev8loop: +; movzx eax, byte ptr [esi] ; get sample + mov al, byte ptr [esi] ; get sample + inc edi + +; movsx eax, byte ptr [2*eax+ebx] ; volume translate sample + mov al, byte ptr [2*eax+ebx] ; volume translate sample + inc esi + +; add eax, 80h + add al, 80h + dec ecx ; decrement count + + mov [edi], al ; write new sample to destination + jnz rev8loop ; loop + + ret + + +;================ +; +; MV_16BitReverbFast +; +;================ + +; eax - source position +; edx - destination position +; ebx - number of samples +; ecx - shift + +ALIGN 16 +PUBLIC MV_16BitReverbFast_ +MV_16BitReverbFast_: + mov esi, eax + mov eax,OFFSET rpatch16+3 + + mov [eax],cl + lea edi, [edx - 2] + +;ALIGN 4 +frev16loop: + mov ax, word ptr [esi] ; get sample + add edi, 2 + +rpatch16: + sar ax, 5 ;;;;Add 1 before shift + add esi, 2 + + mov [edi], ax ; write new sample to destination + dec ebx ; decrement count + + jnz frev16loop ; loop + + ret + + +;================ +; +; MV_8BitReverbFast +; +;================ + +; eax - source position +; edx - destination position +; ebx - number of samples +; ecx - shift + +ALIGN 16 +PUBLIC MV_8BitReverbFast_ +MV_8BitReverbFast_: + mov esi, eax + mov eax,OFFSET rpatch8+2 + + mov edi, edx + mov edx, 80h + + mov [eax],cl + mov eax, 80h + + shr eax, cl + + dec edi + sub edx, eax + +;ALIGN 4 +frev8loop: + mov al, byte ptr [esi] ; get sample + inc esi + + mov ecx, eax + inc edi + +rpatch8: + shr eax, 3 + xor ecx, 80h ; flip the sign bit + + shr ecx, 7 ; shift the sign down to 1 + add eax, edx + + add eax, ecx ; add sign bit to round to 0 + dec ebx ; decrement count + + mov [edi], al ; write new sample to destination + jnz frev8loop ; loop + + ret + +CODE ENDS +END diff --git a/polymer/eduke32/source/jaudiolib/pitch.c b/polymer/eduke32/source/jaudiolib/pitch.c new file mode 100644 index 000000000..a49e2c9e1 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/pitch.c @@ -0,0 +1,197 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: PITCH.C + + author: James R. Dose + date: June 14, 1993 + + Routines for pitch scaling. + + (c) Copyright 1993 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#include +//#include +#include "standard.h" +#include "pitch.h" + +#define MAXDETUNE 25 + +static unsigned long PitchTable[ 12 ][ MAXDETUNE ] = + { + { 0x10000, 0x10097, 0x1012f, 0x101c7, 0x10260, 0x102f9, 0x10392, 0x1042c, + 0x104c6, 0x10561, 0x105fb, 0x10696, 0x10732, 0x107ce, 0x1086a, 0x10907, + 0x109a4, 0x10a41, 0x10adf, 0x10b7d, 0x10c1b, 0x10cba, 0x10d59, 0x10df8, + 0x10e98 }, + { 0x10f38, 0x10fd9, 0x1107a, 0x1111b, 0x111bd, 0x1125f, 0x11302, 0x113a5, + 0x11448, 0x114eb, 0x1158f, 0x11634, 0x116d8, 0x1177e, 0x11823, 0x118c9, + 0x1196f, 0x11a16, 0x11abd, 0x11b64, 0x11c0c, 0x11cb4, 0x11d5d, 0x11e06, + 0x11eaf }, + { 0x11f59, 0x12003, 0x120ae, 0x12159, 0x12204, 0x122b0, 0x1235c, 0x12409, + 0x124b6, 0x12563, 0x12611, 0x126bf, 0x1276d, 0x1281c, 0x128cc, 0x1297b, + 0x12a2b, 0x12adc, 0x12b8d, 0x12c3e, 0x12cf0, 0x12da2, 0x12e55, 0x12f08, + 0x12fbc }, + { 0x1306f, 0x13124, 0x131d8, 0x1328d, 0x13343, 0x133f9, 0x134af, 0x13566, + 0x1361d, 0x136d5, 0x1378d, 0x13846, 0x138fe, 0x139b8, 0x13a72, 0x13b2c, + 0x13be6, 0x13ca1, 0x13d5d, 0x13e19, 0x13ed5, 0x13f92, 0x1404f, 0x1410d, + 0x141cb }, + { 0x1428a, 0x14349, 0x14408, 0x144c8, 0x14588, 0x14649, 0x1470a, 0x147cc, + 0x1488e, 0x14951, 0x14a14, 0x14ad7, 0x14b9b, 0x14c5f, 0x14d24, 0x14dea, + 0x14eaf, 0x14f75, 0x1503c, 0x15103, 0x151cb, 0x15293, 0x1535b, 0x15424, + 0x154ee }, + { 0x155b8, 0x15682, 0x1574d, 0x15818, 0x158e4, 0x159b0, 0x15a7d, 0x15b4a, + 0x15c18, 0x15ce6, 0x15db4, 0x15e83, 0x15f53, 0x16023, 0x160f4, 0x161c5, + 0x16296, 0x16368, 0x1643a, 0x1650d, 0x165e1, 0x166b5, 0x16789, 0x1685e, + 0x16934 }, + { 0x16a09, 0x16ae0, 0x16bb7, 0x16c8e, 0x16d66, 0x16e3e, 0x16f17, 0x16ff1, + 0x170ca, 0x171a5, 0x17280, 0x1735b, 0x17437, 0x17513, 0x175f0, 0x176ce, + 0x177ac, 0x1788a, 0x17969, 0x17a49, 0x17b29, 0x17c09, 0x17cea, 0x17dcc, + 0x17eae }, + { 0x17f91, 0x18074, 0x18157, 0x1823c, 0x18320, 0x18406, 0x184eb, 0x185d2, + 0x186b8, 0x187a0, 0x18888, 0x18970, 0x18a59, 0x18b43, 0x18c2d, 0x18d17, + 0x18e02, 0x18eee, 0x18fda, 0x190c7, 0x191b5, 0x192a2, 0x19391, 0x19480, + 0x1956f }, + { 0x1965f, 0x19750, 0x19841, 0x19933, 0x19a25, 0x19b18, 0x19c0c, 0x19d00, + 0x19df4, 0x19ee9, 0x19fdf, 0x1a0d5, 0x1a1cc, 0x1a2c4, 0x1a3bc, 0x1a4b4, + 0x1a5ad, 0x1a6a7, 0x1a7a1, 0x1a89c, 0x1a998, 0x1aa94, 0x1ab90, 0x1ac8d, + 0x1ad8b }, + { 0x1ae89, 0x1af88, 0x1b088, 0x1b188, 0x1b289, 0x1b38a, 0x1b48c, 0x1b58f, + 0x1b692, 0x1b795, 0x1b89a, 0x1b99f, 0x1baa4, 0x1bbaa, 0x1bcb1, 0x1bdb8, + 0x1bec0, 0x1bfc9, 0x1c0d2, 0x1c1dc, 0x1c2e6, 0x1c3f1, 0x1c4fd, 0x1c609, + 0x1c716 }, + { 0x1c823, 0x1c931, 0x1ca40, 0x1cb50, 0x1cc60, 0x1cd70, 0x1ce81, 0x1cf93, + 0x1d0a6, 0x1d1b9, 0x1d2cd, 0x1d3e1, 0x1d4f6, 0x1d60c, 0x1d722, 0x1d839, + 0x1d951, 0x1da69, 0x1db82, 0x1dc9c, 0x1ddb6, 0x1ded1, 0x1dfec, 0x1e109, + 0x1e225 }, + { 0x1e343, 0x1e461, 0x1e580, 0x1e6a0, 0x1e7c0, 0x1e8e0, 0x1ea02, 0x1eb24, + 0x1ec47, 0x1ed6b, 0x1ee8f, 0x1efb4, 0x1f0d9, 0x1f1ff, 0x1f326, 0x1f44e, + 0x1f576, 0x1f69f, 0x1f7c9, 0x1f8f3, 0x1fa1e, 0x1fb4a, 0x1fc76, 0x1fda3, + 0x1fed1 } + }; + + +//static int PITCH_Installed = FALSE; + + +/*--------------------------------------------------------------------- + Function: PITCH_Init + + Initializes pitch table. +---------------------------------------------------------------------*/ +/* +void PITCH_Init + ( + void + ) + + { + int note; + int detune; + + if ( !PITCH_Installed ) + { + for( note = 0; note < 12; note++ ) + { + for( detune = 0; detune < MAXDETUNE; detune++ ) + { + PitchTable[ note ][ detune ] = 0x10000 * + pow( 2, ( note * MAXDETUNE + detune ) / ( 12.0 * MAXDETUNE ) ); + } + } + + PITCH_Installed = TRUE; + } + } +*/ + +/********************************************************************** + + Memory locked functions: + +**********************************************************************/ + + +/*--------------------------------------------------------------------- + Function: PITCH_GetScale + + Returns a fixed-point value to scale number the specified amount. +---------------------------------------------------------------------*/ + +unsigned long PITCH_GetScale + ( + int pitchoffset + ) + + { + unsigned long scale; + int octaveshift; + int noteshift; + int note; + int detune; + +// if ( !PITCH_Installed ) +// { +// PITCH_Init(); +// } + + if ( pitchoffset == 0 ) + { + return( PitchTable[ 0 ][ 0 ] ); + } + + noteshift = pitchoffset % 1200; + if ( noteshift < 0 ) + { + noteshift += 1200; + } + + note = noteshift / 100; + detune = ( noteshift % 100 ) / ( 100 / MAXDETUNE ); + octaveshift = ( pitchoffset - noteshift ) / 1200; + + if ( detune < 0 ) + { + detune += ( 100 / MAXDETUNE ); + note--; + if ( note < 0 ) + { + note += 12; + octaveshift--; + } + } + + scale = PitchTable[ note ][ detune ]; + + if ( octaveshift < 0 ) + { + scale >>= -octaveshift; + } + else + { + scale <<= octaveshift; + } + + return( scale ); + } + + + diff --git a/polymer/eduke32/source/jaudiolib/pitch.h b/polymer/eduke32/source/jaudiolib/pitch.h new file mode 100644 index 000000000..b054507a7 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/pitch.h @@ -0,0 +1,44 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: PITCH.H + + author: James R. Dose + date: June 14, 1994 + + Public header for PITCH.C + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __PITCH_H +#define __PITCH_H + +enum PITCH_ERRORS + { + PITCH_Warning = -2, + PITCH_Error = -1, + PITCH_Ok = 0, + }; + +//void PITCH_Init( void ); +unsigned long PITCH_GetScale( int pitchoffset ); +#endif diff --git a/polymer/eduke32/source/jaudiolib/sdlout.c b/polymer/eduke32/source/jaudiolib/sdlout.c new file mode 100644 index 000000000..37c510a16 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/sdlout.c @@ -0,0 +1,266 @@ +/* + * DirectSound output code for MultiVoc + * by Jonathon Fowler (jonof@edgenetwk.com) + */ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. +*/ +//------------------------------------------------------------------------- + +#include "sdlout.h" +#include "SDL.h" +#include +#include +#include "osd.h" + +#include "sdlayer.h" + +#if defined(__WATCOMC__) || defined(_MSC_VER) +#include +#endif + + +#ifndef RENDERTYPESDL +#error The SDL output module for AudioLib only works with the SDL interface. +#endif + +static int (*_SDLSOUND_CallBack)(int) = NULL; +static int _SDLSOUND_BufferLength = 0; +static int _SDLSOUND_NumBuffers = 0; +static char *_SDLSOUND_MixBuffer = NULL; + +static int SDLSOUND_Installed = FALSE; + +int SDLSOUND_ErrorCode = SDLSOUND_Ok; + +#define SDLSOUND_SetErrorCode( status ) \ + SDLSOUND_ErrorCode = ( status ); + +static void isr(void *userdata, unsigned char *stream, int len); + +/* + * DisableInterrupts + * Enter the critical section. + */ +int DisableInterrupts(void) +{ + SDL_LockAudio(); + + return 0; +} + + +/* + * RestoreInterrupts + * Leave the critical section. + */ +int RestoreInterrupts(int a) +{ + SDL_UnlockAudio(); + + return 0; + a=a; +} + + +/* + * SDLSOUND_ErrorString + * Returns a description of an error code. + */ +char *SDLSOUND_ErrorString(int errorcode) +{ + switch (errorcode) { + case SDLSOUND_Warning: + case SDLSOUND_Error: + return SDLSOUND_ErrorString(SDLSOUND_ErrorCode); + + case SDLSOUND_Ok: + return "SDL Sound ok."; + + default: + return "Unknown SDL sound error code."; + } +} + + +/* + * SDLSOUND_Init + * Initializes the SDL sound objects. + */ +int SDLSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int buffersize) +{ + SDL_AudioSpec spec,got; + + if (SDLSOUND_Installed) { + SDLSOUND_Shutdown(); + } + + printOSD("Initializing SDL sound...\n"); + + printOSD(" - Requested sound format\n" + " Channels: %d\n" + " Sample rate: %dHz\n" + " Sample size: %d bits\n", + numchannels, mixrate, samplebits); + + spec.freq = mixrate; + spec.format = (samplebits == 8 ? AUDIO_U8 : AUDIO_S16LSB); + spec.channels = (numchannels == 1 ? 1:2); + spec.samples = (buffersize >> (spec.channels-1)) >> (samplebits==16); + spec.callback = isr; + spec.userdata = NULL; + + + SDLSOUND_Installed = TRUE; + + SDLSOUND_SetErrorCode(SDLSOUND_Ok); + return SDLSOUND_Ok; +} + + +/* + * SDLSOUND_Shutdown + * Shuts down SDL sound and it's associates. + */ +int SDLSOUND_Shutdown(void) +{ + int i; + + if (SDLSOUND_Installed) printOSD("Uninitializing SDL sound...\n"); + + SDLSOUND_Installed = FALSE; + + SDLSOUND_StopPlayback(); + + + SDLSOUND_SetErrorCode(SDLSOUND_Ok); + return SDLSOUND_Ok; +} + + +/* + * SDLSOUND_SetMixMode + * Bit of filler for the future. + */ +int SDLSOUND_SetMixMode(int mode) +{ + return mode; +} + + +static void isr(void *userdata, unsigned char *stream, int len) +{ + // otherwise we just service the interrupt + if (_DSOUND_CallBack) { + + p = _DSOUND_CallBack(rv-WAIT_OBJECT_0-1); + + hr = IDirectSoundBuffer_Lock(lpDSBSecondary, p*_DSOUND_BufferLength, _DSOUND_BufferLength, + &lockptr, &lockbytes, &lockptr2, &lockbytes2, 0); + if (hr == DSERR_BUFFERLOST) { + hr = IDirectSoundBuffer_Restore(lpDSBSecondary); + } + if (hr == DS_OK) { + /* +#define copybuf(S,D,c) \ + ({ void *__S=(S), *__D=(D); long __c=(c); \ + __asm__ __volatile__ ("rep; movsl" \ + : "+S" (__S), "+D" (__D), "+c" (__c) : : "memory", "cc"); \ + 0; }) +*/ + //copybuf(_DSOUND_MixBuffer + p * _DSOUND_BufferLength, lockptr, _DSOUND_BufferLength >> 2); + memcpy(lockptr, _DSOUND_MixBuffer + p * _DSOUND_BufferLength, _DSOUND_BufferLength); + IDirectSoundBuffer_Unlock(lpDSBSecondary, lockptr, lockbytes, lockptr2, lockbytes2); + } + + } + } +} + + +/* + * SDLSOUND_BeginBufferedPlayback + * Unpause SDL sound playback. + */ +int DSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), int buffersize, int numdivisions) +{ + _SDLSOUND_CallBack = CallBackFunc; + _SDLSOUND_MixBuffer = BufferStart; + + _SDLSOUND_BufferLength = buffersize/numdivisions; + _SDLSOUND_NumBuffers = numdivisions; + + return SDLSOUND_Ok; +} + + +/* + * DSOUND_StopPlayback + * Halts the playback thread. + */ +int DSOUND_StopPlayback(void) +{ +// DWORD exitcode; + BOOL t; + int i; + + if (isrthread) { + SetEvent(isrfinish); + + printOSD("DirectSound: Waiting for sound thread to exit\n"); + if (WaitForSingleObject(isrthread, 300) == WAIT_OBJECT_0) + printOSD("DirectSound: Sound thread has exited\n"); + else + printOSD("DirectSound: Sound thread failed to exit!\n"); + /* + while (1) { + if (!GetExitCodeThread(isrthread, &exitcode)) { + DSOUND_SetErrorCode(DSOUND_FailedGetExitCode); + return DSOUND_Warning; + } + if (exitcode != STILL_ACTIVE) break; + }*/ + + CloseHandle(isrthread); + isrthread = NULL; + } + + if (isrfinish) { + CloseHandle(isrfinish); + isrfinish = NULL; + } + + if (lpDSBSecondary) { + IDirectSoundBuffer_Stop(lpDSBSecondary); + } + + if (hPosNotify) { + for (i=0; i<_DSOUND_NumBuffers; i++) { + if (hPosNotify[i]) CloseHandle(hPosNotify[i]); + } + free(hPosNotify); + hPosNotify = NULL; + } + + return DSOUND_Ok; +} + + diff --git a/polymer/eduke32/source/jaudiolib/sdlout.h b/polymer/eduke32/source/jaudiolib/sdlout.h new file mode 100644 index 000000000..73dbf545e --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/sdlout.h @@ -0,0 +1,48 @@ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. +*/ +//------------------------------------------------------------------------- + +#ifndef __sdlout_h__ +#define __sdlout_h__ + +enum SDLSOUND_ERRORS { + SDLSOUND_Warning = -2, + SDLSOUND_Error = -1, + SDLSOUND_Ok = 0 +}; + +extern int SDLSOUND_ErrorCode; + +char *SDLSOUND_ErrorString(int); + +int DisableInterrupts(void); // simulated using critical sections +int RestoreInterrupts(int); + +int SDLSOUND_Init(int soundcard, int mixrate, int numchannels, int samplebits, int buffersize); +int SDLSOUND_Shutdown(void); + +int SDLSOUND_SetMixMode(int mode); +int SDLSOUND_BeginBufferedPlayback(char *BufferStart, int (*CallBackFunc)(int), int buffersize, int numdivisions); +int SDLSOUND_StopPlayback(void); + +#endif // __sdlout_h__ + diff --git a/polymer/eduke32/source/jaudiolib/standard.h b/polymer/eduke32/source/jaudiolib/standard.h new file mode 100644 index 000000000..167c605df --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/standard.h @@ -0,0 +1,73 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: STANDARD.H + + author: James R. Dose + date: May 25, 1994 + + Header containing standard definitions. + + (c) Copyright 1994 James R. Dose. All Rights Reserved. +**********************************************************************/ + +#ifndef __STANDARD_H +#define __STANDARD_H + +typedef int boolean; +typedef int errorcode; + +#ifndef TRUE + #define TRUE ( 1 == 1 ) + #define FALSE ( !TRUE ) +#endif + +enum STANDARD_ERRORS + { + Warning = -2, + FatalError = -1, + Success = 0 + }; + +#define BITSET( data, bit ) \ + ( ( ( data ) & ( bit ) ) == ( bit ) ) + +#define ARRAY_LENGTH( array ) \ + ( sizeof( array ) / sizeof( ( array )[ 0 ] ) ) + +#define WITHIN_BOUNDS( array, index ) \ + ( ( 0 <= ( index ) ) && ( ( index ) < ARRAY_LENGTH( array ) ) ) + +#define FOREVER for( ; ; ) + +#ifdef NDEBUG + #define DEBUGGING 0 +#else + #define DEBUGGING 1 +#endif + +#define DEBUG_CODE \ + if ( DEBUGGING == 0 ) \ + { \ + } \ + else + +#endif diff --git a/polymer/eduke32/source/jaudiolib/usrhooks.h b/polymer/eduke32/source/jaudiolib/usrhooks.h new file mode 100644 index 000000000..25e3fcf10 --- /dev/null +++ b/polymer/eduke32/source/jaudiolib/usrhooks.h @@ -0,0 +1,56 @@ +/* +Copyright (C) 1994-1995 Apogee Software, Ltd. + +This program 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. + +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +/********************************************************************** + module: USRHOOKS.H + + author: James R. Dose + date: July 26, 1994 + + Public header file for USRHOOKS.C. + + This module contains cover functions for operations the library + needs that may be restricted by the calling program. The function + prototypes in this header should not be modified. +**********************************************************************/ + +#ifndef __USRHOOKS_H +#define __USRHOOKS_H + +/*--------------------------------------------------------------------- + Error definitions +---------------------------------------------------------------------*/ + +enum USRHOOKS_Errors + { + USRHOOKS_Warning = -2, + USRHOOKS_Error = -1, + USRHOOKS_Ok = 0 + }; + + +/*--------------------------------------------------------------------- + Function Prototypes +---------------------------------------------------------------------*/ + +int USRHOOKS_GetMem( void **ptr, unsigned long size ); +int USRHOOKS_FreeMem( void *ptr ); + +#endif diff --git a/polymer/eduke32/source/jfaud_sounds.cpp b/polymer/eduke32/source/jfaud_sounds.cpp new file mode 100644 index 000000000..b96271813 --- /dev/null +++ b/polymer/eduke32/source/jfaud_sounds.cpp @@ -0,0 +1,681 @@ +/* + * 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 + */ + +#ifdef __APPLE__ +# include +#else +# include "jfaud.hpp" +#endif + +#include "types.h" +#include "duke3d.h" +extern "C" { +#ifdef RENDERTYPEWIN +# include "winlayer.h" +#endif +#include "osd.h" +long numenvsnds; +} + +#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 ZUNITSPERMETRE 8192.0 + +#include + +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; +} + +typedef struct { + JFAudMixerChannel *chan; + int owner; // sprite number + int soundnum; // sound number +} SoundChannel; + +static SoundChannel *chans = NULL; +static JFAud *jfaud = NULL; + +static bool havemidi = false, havewave = false; + + +static void stopcallback(int r) +{ + jfaud->FreeSound(chans[r].chan); + chans[r].chan = NULL; + chans[r].owner = -1; +} + +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 || !jfaud->IsValidSound(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; + + 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(NULL, NumVoices, MixRate)) { + delete jfaud; + jfaud = NULL; + return; + } + + chans = new SoundChannel[NumVoices]; + if (!chans) { + delete jfaud; + jfaud = NULL; + return; + } + + havewave = true; + + for (i=NumVoices-1; i>=0; i--) { + chans[i].owner = -1; + } + + if (jfaud->InitMIDI(NULL)) havemidi = true; +} + +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].chan && !jfaud->IsValidSound(chans[i].chan)) + chans[i].chan = NULL; + } + jfaud->Update(); +} + + +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(char *fn) +{ + char dafn[BMAX_PATH], *dotpos; + int i; + const char *extns[] = { ".ogg",".mp3",".mid", NULL }; + + if (!MusicToggle) return; + if (!jfaud) return; + + dotpos = Bstrrchr(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; + } + } +} + +char 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].chan || !jfaud->IsValidSound(chans[j].chan)) continue; + if (chans[j].owner == i) + if (num < 0 || chans[j].soundnum == num) n++; + } + return n; +} + +int issoundplaying(int num) +{ + int j,n=0; + + if (!jfaud || !havewave) return 0; + for (j=NumVoices-1; j>=0; j--) { + if (!chans[j].chan || !jfaud->IsValidSound(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; + + if (!jfaud || !havewave || + num >= NUM_SOUNDS || + ((soundm[num] & SOUNDM_PARENT) && ud.lockout) || // parental mode + SoundToggle == 0 || + (ps[myconnectindex].timebeforeexit > 0 && ps[myconnectindex].timebeforeexit <= 26*3) || + (ps[myconnectindex].gm & MODE_MENU) + ) return -1; + + if (soundm[num] & SOUNDM_PLAYER) { + sound(num); + return 0; + } + +// swaplong(&y,&z); +// y = -y>>4; + + 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].chan || chans[j].owner < 0) continue; + if (soundm[ chans[j].soundnum ] & SOUNDM_DUKE) return -1; + } + } + + // XXX: here goes musicandsfx ranging. This will change the refdist. + + { + int ps = soundps[num], pe = soundpe[num], cx; + cx = klabs(pe-ps); + if (cx) { + if (ps < pe) pitch = translatepitch(ps + rand()%cx); + else pitch = translatepitch(pe + rand()%cx); + } else pitch = translatepitch(ps); + } + + if (ps[screenpeek].sound_pitch) pitch = translatepitch(ps[screenpeek].sound_pitch); + + //gain += soundvo[num]; +/* if (PN != MUSICANDSFX && + !cansee(ps[screenpeek].oposx,ps[screenpeek].oposy,ps[screenpeek].oposz-(24<<8), + ps[screenpeek].cursectnum,SX,SY,SZ-(24<<8),SECT) ) + gain *= 1.0/32.0; */ + + switch(num) + { + case PIPEBOMB_EXPLODE: + case LASERTRIP_EXPLODE: + case RPG_EXPLODE: + gain = 1.0; + global = 1; + if (sector[ps[screenpeek].cursectnum].lotag == 2) pitch -= translatepitch(1024); + break; + default: + if(sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&SOUNDM_DUKE) == 0) + pitch = translatepitch(-768); + //if( sndist > 31444 && PN != MUSICANDSFX) + // return -1; + break; + } + if (ps[screenpeek].sound_pitch) pitch = translatepitch(ps[screenpeek].sound_pitch); +/* + // 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); + if (soundm[num] & SOUNDM_GLOBAL) global = 1; + chan->SetFilter((soundm[num]&SOUNDM_NICE) ? JFAudMixerChannel::Filter4Point : JFAudMixerChannel::FilterNearest); + + 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 : 0.3); + chan->SetFollowListener(false); + chan->SetPosition((float)x/UNITSPERMETRE, (float)z/ZUNITSPERMETRE, (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 = klabs(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); + chan->SetRolloff(0.0); + chan->SetFollowListener(true); + chan->SetPosition(0.0, 0.0, 0.0); + chan->SetFilter((soundm[num]&SOUNDM_NICE) ? JFAudMixerChannel::Filter4Point : JFAudMixerChannel::FilterNearest); + + 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].chan || !jfaud->IsValidSound(chans[j].chan) || chans[j].soundnum != num) continue; + + jfaud->FreeSound(chans[j].chan); + chans[j].chan = NULL; + chans[j].owner = -1; + } +} + +void stopspritesound(short num, short i) +{ + int j; + + if (!jfaud || !havewave) return; + for (j=NumVoices-1;j>=0;j--) { + if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan) || chans[j].owner != i || chans[j].soundnum != num) continue; + + jfaud->FreeSound(chans[j].chan); + chans[j].chan = NULL; + chans[j].owner = -1; + return; + } +} + +void stopenvsound(short num, short i) +{ + int j; + + if (!jfaud || !havewave) return; + for (j=NumVoices-1;j>=0;j--) { + if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan) || chans[j].owner != i) continue; + + jfaud->FreeSound(chans[j].chan); + chans[j].chan = NULL; + chans[j].owner = -1; + } +} + +void pan3dsound(void) +{ + JFAudMixer *mix; + int j, global; + short i; + long cx, cy, cz, sx,sy,sz; + short ca,cs; + float gain; + + numenvsnds = 0; + if (!jfaud || !havewave) return; + mix = jfaud->GetWave(); + if (!mix) return; + + if(ud.camerasprite == -1) { + cx = ps[screenpeek].oposx; + cy = -ps[screenpeek].oposz>>4; + cz = ps[screenpeek].oposy; + cs = ps[screenpeek].cursectnum; + ca = ps[screenpeek].ang+ps[screenpeek].look_ang; + } else { + cx = sprite[ud.camerasprite].x; + cy = -sprite[ud.camerasprite].z>>4; + cz = sprite[ud.camerasprite].y; + cs = sprite[ud.camerasprite].sectnum; + ca = sprite[ud.camerasprite].ang; + } + + mix->SetListenerPosition((float)cx/UNITSPERMETRE, (float)cy/UNITSPERMETRE, (float)cz/ZUNITSPERMETRE); + 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].chan || !jfaud->IsValidSound(chans[j].chan) || chans[j].owner < 0) continue; + + global = 0; + gain = 1.0; + i = chans[j].owner; + + sx = sprite[i].x; + sy = -sprite[i].z >> 4; + sz = sprite[i].y; + + //gain += soundvo[num]; +// if (PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,sx,sy,sz-(24<<8),SECT) ) +// gain *= 1.0/32.0; + + if(PN == MUSICANDSFX && SLT < 999) numenvsnds++; + 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 : 0.3); + chans[j].chan->SetFollowListener(false); + chans[j].chan->SetPosition((float)sx/UNITSPERMETRE, (float)sy/UNITSPERMETRE, (float)sz/ZUNITSPERMETRE); + } + } +} + +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 ) +{ + int j; + + if (!jfaud) return 0; + for (j=NumVoices-1;j>=0;j--) { + if (!chans[j].chan || !jfaud->IsValidSound(chans[j].chan)) return 1; + } + return 0; +} + +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 ) +{ +} + diff --git a/polymer/eduke32/source/jmact/_control.h b/polymer/eduke32/source/jmact/_control.h new file mode 100644 index 000000000..b53513170 --- /dev/null +++ b/polymer/eduke32/source/jmact/_control.h @@ -0,0 +1,271 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is NOT part of Duke Nukem 3D version 1.5 - Atomic Edition +However, it is either an older version of a file that is, or is +some test code written during the development of Duke Nukem 3D. +This file is provided purely for educational interest. + +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. + +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +*/ +//------------------------------------------------------------------------- + +//**************************************************************************** +// +// Private header for CONTROL.C +// +//**************************************************************************** + +#ifndef _control_private +#define _control_private +#ifdef __cplusplus +extern "C" { +#endif + +//**************************************************************************** +// +// DEFINES +// +//**************************************************************************** + +#define BUTTON0_SCAN_1 sc_Space +#define BUTTON0_SCAN_2 sc_Enter +#define BUTTON0_SCAN_3 sc_kpad_Enter +#define BUTTON1_SCAN sc_Escape + +#define AXISUNDEFINED 0x7f +#define BUTTONUNDEFINED 0x7f +#define KEYUNDEFINED 0x7f + +#define SENSITIVE 0x400 +//#define MINSENSITIVE 0x30 + +#define THRESHOLD 0x200 +#define MINTHRESHOLD 0x80 + +#define USERINPUTDELAY 200 + +#define ResetMouse 0 +#define GetMouseButtons 3 +#define GetMouseDelta 11 + +#define MouseInt 0x33 +#define JoyMax 0xa00 +#define MaxJoyValue 5000 +#define MINIMUMMOUSESENSITIVITY 0x1000 +#define DEFAULTMOUSESENSITIVITY 0x7000+MINIMUMMOUSESENSITIVITY + +#define CONTROL_NUM_FLAGS 64 +#define INSTANT_ONOFF 0 +#define TOGGLE_ONOFF 1 + +#define MAXCONTROLVALUE 0x7fff + +// Maximum number of buttons for any controller +#define MAXBUTTONS 32 + +// Number of Mouse buttons + +#define MAXMOUSEBUTTONS 6 + +// Number of Mouse Axes + +#define MAXMOUSEAXES 2 + +// Number of JOY buttons + +#define MAXJOYBUTTONS 32 + +// Number of JOY axes + +#define MAXJOYAXES 6 + +// Number of GamePad axes + +#define MAXGAMEPADAXES 2 + +// Number of axes + +#define MAXAXES 6 + +// NORMAL axis scale + +#define NORMALAXISSCALE (65536) + +#define BUTTONSET(x,value) \ + (\ + ((x)>31) ?\ + (CONTROL_ButtonState2 |= (value<<((x)-32))) :\ + (CONTROL_ButtonState1 |= (value<<(x)))\ + ) + +#define BUTTONCLEAR(x) \ + (\ + ((x)>31) ?\ + (CONTROL_ButtonState2 &= (~(1<<((x)-32)))) :\ + (CONTROL_ButtonState1 &= (~(1<<(x))))\ + ) + +#define BUTTONHELDSET(x,value)\ + (\ + ((x)>31) ?\ + (CONTROL_ButtonHeldState2 |= value<<((x)-32)) :\ + (CONTROL_ButtonHeldState1 |= value<<(x))\ + ) + +#define LIMITCONTROL(x)\ + {\ + if ((*x)>MAXCONTROLVALUE) \ + {\ + (*x) = MAXCONTROLVALUE;\ + }\ + if ((*x)<-MAXCONTROLVALUE) \ + {\ + (*x) = -MAXCONTROLVALUE;\ + }\ + } +#define SGN(x) \ + ( ( (x) > 0 ) ? 1 : ( (x) < 0 ) ? -1 : 0 ) + +//**************************************************************************** +// +// TYPEDEFS +// +//**************************************************************************** + +typedef enum + { + motion_Left = -1, + motion_Up = -1, + motion_None = 0, + motion_Right = 1, + motion_Down = 1 + } motion; + + +typedef struct + { + int32 joyMinX; + int32 joyMinY; + int32 threshMinX; + int32 threshMinY; + int32 threshMaxX; + int32 threshMaxY; + int32 joyMaxX; + int32 joyMaxY; + int32 joyMultXL; + int32 joyMultYL; + int32 joyMultXH; + int32 joyMultYH; + } JoystickDef; + +// int32 ThrottleMin; +// int32 RudderMin; +// int32 ThrottlethreshMin; +// int32 RudderthreshMin; +// int32 ThrottlethreshMax; +// int32 RudderthreshMax; +// int32 ThrottleMax; +// int32 RudderMax; +// int32 ThrottleMultL; +// int32 RudderMultL; +// int32 ThrottleMultH; +// int32 RudderMultH; + +/* +typedef struct + { + byte active : 1; + byte used : 1; + byte toggle : 1; + byte buttonheld : 1; + byte cleared : 1; + } controlflags; +typedef struct + { + volatile byte active : 1; + volatile byte used : 1; + volatile byte toggle : 1; + volatile byte buttonheld : 1; + volatile byte cleared : 1; + } controlflags; +*/ +typedef struct + { + byte active ; + byte used ; + byte toggle ; + byte buttonheld ; + int32 cleared ; + } controlflags; + +typedef struct + { + kb_scancode key1; + kb_scancode key2; + } controlkeymaptype; + +typedef struct + { + byte singleclicked; + byte doubleclicked; + word extra; + } controlbuttontype; + +typedef struct + { + byte analogmap; + byte minmap; + byte maxmap; + byte extra; + } controlaxismaptype; + +typedef struct + { + int32 analog; + int32 digital; + } controlaxistype; + + +//*************************************************************************** +// +// PROTOTYPES +// +//*************************************************************************** + +void CONTROL_GetMouseDelta( void ); +byte CONTROL_GetMouseButtons( void ); +boolean CONTROL_StartMouse( void ); +void CONTROL_GetJoyAbs( void ); +void CONTROL_GetJoyDelta( void ); +void CONTROL_SetJoyScale( void ); +boolean CONTROL_StartJoy( int32 joy ); +void CONTROL_ShutJoy( int32 joy ); +void CONTROL_SetFlag( int32 which, boolean active ); +void CONTROL_ButtonFunctionState( boolean * state ); +boolean CONTROL_KeyboardFunctionPressed( int32 whichfunction ); +boolean CONTROL_CheckRange( int32 which ); +int32 CONTROL_GetTime( void ); +void CONTROL_AxisFunctionState( boolean * state ); +void CONTROL_GetJoyMovement( ControlInfo * info ); + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jmact/_scrplib.h b/polymer/eduke32/source/jmact/_scrplib.h new file mode 100644 index 000000000..b27db8045 --- /dev/null +++ b/polymer/eduke32/source/jmact/_scrplib.h @@ -0,0 +1,209 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is NOT part of Duke Nukem 3D version 1.5 - Atomic Edition +However, it is either an older version of a file that is, or is +some test code written during the development of Duke Nukem 3D. +This file is provided purely for educational interest. + +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. + +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +// scrplib.h + +#ifndef _scriplib_private +#define _scriplib_private +#ifdef __cplusplus +extern "C" { +#endif + +#define SCRIPTSECTIONSTART ('[') +#define SCRIPTSECTIONEND (']') +#define SCRIPTENTRYSEPARATOR ('=') +#define SCRIPTCOMMENT (';') +#define SCRIPTEOL ('\n') +#define SCRIPTNULL ('\0') +#define SCRIPTSTRINGSEPARATOR ('"') +#define SCRIPTHEXFIRST ('0') +#define SCRIPTHEXSECOND ('x') +#define SCRIPTSPACE (' ') +#define SCRIPTDEFAULTVALUE ('~') +#define MAXSCRIPTFILES 20 +#define SCRIPT(scripthandle,item) (scriptfiles[(scripthandle)]->item) + +typedef enum + { + linetype_comment, + linetype_section, + linetype_entry + } linetype_t; + +typedef struct scriptline + { + int32 type; + void * ptr; + struct scriptline *nextline; + struct scriptline *prevline; + } ScriptLineType; + +typedef struct scriptentry + { + char * name; + char * value; + struct scriptentry *nextentry; + struct scriptentry *preventry; + } ScriptEntryType; + +typedef struct scriptsection + { + char * name; + ScriptEntryType *entries; + ScriptLineType *lastline; + struct scriptsection *nextsection; + struct scriptsection *prevsection; + } ScriptSectionType; + +typedef struct + { + ScriptSectionType * script; + ScriptSectionType * lastsection; + ScriptLineType * scriptlines; + char scriptfilename[128]; + } script_t; + +/* +============== += += SCRIPT_New += +============== +*/ + +int32 SCRIPT_New( void ); + +/* +============== += += SCRIPT_Delete += +============== +*/ +void SCRIPT_Delete( int32 scripthandle ); + +/* +============== += += SCRIPT_FreeSection += +============== +*/ +void SCRIPT_FreeSection( ScriptSectionType * section ); + +/* +============== += += SafeWriteString += +============== +*/ +void SafeWriteString (int32 handle, char * string); + +/* +============== += += SCRIPT_AddLine += +============== +*/ + + +ScriptLineType * SCRIPT_AddLine + ( + ScriptLineType * root, + int32 type, + void * ptr + ); + +/* +============== += += SCRIPT_SectionExists += +============== +*/ +ScriptSectionType * SCRIPT_SectionExists + ( + int32 scripthandle, + char * sectionname + ); + +/* +============== += += SCRIPT_AddSection += +============== +*/ +ScriptSectionType * SCRIPT_AddSection( int32 scripthandle, char * sectionname ); + +/* +============== += += SCRIPT_EntryExists += +============== +*/ +ScriptEntryType * SCRIPT_EntryExists + ( + ScriptSectionType * section, + char * entryname + ); + +/* +============== += += SCRIPT_AddEntry += +============== +*/ +void SCRIPT_AddEntry + ( + int32 scripthandle, + char * sectionname, + char * entryname, + char * entryvalue + ); + +/* +============== += += SCRIPT_DecodeToken += +============== +*/ + +void SCRIPT_DecodeToken ( int32 scripthandle, char * str ); + + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jmact/animlib.c b/polymer/eduke32/source/jmact/animlib.c new file mode 100644 index 000000000..6a1c840b9 --- /dev/null +++ b/polymer/eduke32/source/jmact/animlib.c @@ -0,0 +1,368 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#include "compat.h" +#include "types.h" +#include "develop.h" +#include "util_lib.h" +#include "animlib.h" + +//**************************************************************************** +// +// GLOBALS +// +//**************************************************************************** + +//**************************************************************************** +// +// LOCALS +// +//**************************************************************************** +static anim_t * anim=NULL; +static boolean Anim_Started = false; + +//**************************************************************************** +// +// CheckAnimStarted () +// +//**************************************************************************** + +static void CheckAnimStarted ( char * funcname ) + { + if (!Anim_Started) + Error("ANIMLIB_%s: Anim has not been initialized\n",funcname); + } +//**************************************************************************** +// +// findpage () +// - given a frame number return the large page number it resides in +// +//**************************************************************************** + +uint16 findpage (uint16 framenumber) + { + uint16 i; + + CheckAnimStarted ( "findpage" ); + for(i=0; ilpheader.nLps; i++) + { + if + ( + anim->LpArray[i].baseRecord <= framenumber && + anim->LpArray[i].baseRecord + anim->LpArray[i].nRecords > framenumber + ) + return(i); + } + return(i); + } + + +//**************************************************************************** +// +// loadpage () +// - seek out and load in the large page specified +// +//**************************************************************************** + +void loadpage (uint16 pagenumber, uint16 *pagepointer) + { + int32 size; + byte * buffer; + + CheckAnimStarted ( "loadpage" ); + buffer = anim->buffer; + if (anim->curlpnum != pagenumber) + { + anim->curlpnum = pagenumber; + buffer += 0xb00 + (pagenumber*0x10000); + size = sizeof(lp_descriptor); + /* + Bmemcpy(&anim->curlp,buffer,size); + + // JBF: why didn't this get read from the LpArray[] table? + anim->curlp.baseRecord = B_LITTLE16(anim->curlp.baseRecord); + anim->curlp.nRecords = B_LITTLE16(anim->curlp.nRecords); + anim->curlp.nBytes = B_LITTLE16(anim->curlp.nBytes); + */ + Bmemcpy(&anim->curlp, &anim->LpArray[pagenumber], size); + + buffer += size + sizeof(uint16); + Bmemcpy(pagepointer,buffer,anim->curlp.nBytes+(anim->curlp.nRecords*2)); + } + } + + +//**************************************************************************** +// +// CPlayRunSkipDump () +// - This version of the decompressor is here for portability to non PC's +// +//**************************************************************************** + +void CPlayRunSkipDump (char *srcP, char *dstP) + { + signed char cnt; + uint16 wordCnt; + byte pixel; + + +nextOp: + cnt = (signed char) *srcP++; + if (cnt > 0) + goto dump; + if (cnt == 0) + goto run; + cnt -= 0x80; + if (cnt == 0) + goto longOp; +/* shortSkip */ + dstP += cnt; /* adding 7-bit count to 32-bit pointer */ + goto nextOp; +dump: + do + { + *dstP++ = *srcP++; + } while (--cnt); + goto nextOp; +run: + wordCnt = (byte)*srcP++; /* 8-bit unsigned count */ + pixel = *srcP++; + do + { + *dstP++ = pixel; + } while (--wordCnt); + + goto nextOp; +longOp: + wordCnt = B_LITTLE16(*((uint16 *)srcP)); + srcP += sizeof(uint16); + if ((int16)wordCnt <= 0) + goto notLongSkip; /* Do SIGNED test. */ + +/* longSkip. */ + dstP += wordCnt; + goto nextOp; + +notLongSkip: + if (wordCnt == 0) + goto stop; + wordCnt -= 0x8000; /* Remove sign bit. */ + if (wordCnt >= 0x4000) + goto longRun; + +/* longDump. */ + do + { + *dstP++ = *srcP++; + } while (--wordCnt); + goto nextOp; + +longRun: + wordCnt -= 0x4000; /* Clear "longRun" bit. */ + pixel = *srcP++; + do + { + *dstP++ = pixel; + } while (--wordCnt); + goto nextOp; + +stop: /* all done */ + ; + } + + + +//**************************************************************************** +// +// renderframe () +// - draw the frame sepcified from the large page in the buffer pointed to +// +//**************************************************************************** + +void renderframe (uint16 framenumber, uint16 *pagepointer) + { + uint16 offset=0; + uint16 i; + uint16 destframe; + byte *ppointer; + + CheckAnimStarted ( "renderframe" ); + destframe = framenumber - anim->curlp.baseRecord; + + for(i = 0; i < destframe; i++) + { + offset += B_LITTLE16(pagepointer[i]); + } + ppointer = (byte *)pagepointer; + + ppointer+=anim->curlp.nRecords*2+offset; + if(ppointer[1]) + { + ppointer += (4 + B_LITTLE16(((uint16 *)ppointer)[1]) + (B_LITTLE16(((uint16 *)ppointer)[1]) & 1)); + } + else + { + ppointer+=4; + } + + CPlayRunSkipDump (ppointer, anim->imagebuffer); + } + + +//**************************************************************************** +// +// drawframe () +// - high level frame draw routine +// +//**************************************************************************** + +void drawframe (uint16 framenumber) + { + CheckAnimStarted ( "drawframe" ); + loadpage(findpage(framenumber), anim->thepage); + renderframe(framenumber, anim->thepage); + } + + +//**************************************************************************** +// +// ANIM_LoadAnim () +// +//**************************************************************************** + +void ANIM_LoadAnim (char * buffer) + { + uint16 i; + int32 size; + + if (!Anim_Started) { + anim = SafeMalloc(sizeof(anim_t)); + Anim_Started = true; + } + + anim->buffer = buffer; + anim->curlpnum = 0xffff; + anim->currentframe = -1; + size = sizeof(lpfileheader); + Bmemcpy(&anim->lpheader, buffer, size ); + + anim->lpheader.id = B_LITTLE32(anim->lpheader.id); + anim->lpheader.maxLps = B_LITTLE16(anim->lpheader.maxLps); + anim->lpheader.nLps = B_LITTLE16(anim->lpheader.nLps); + anim->lpheader.nRecords = B_LITTLE32(anim->lpheader.nRecords); + anim->lpheader.maxRecsPerLp = B_LITTLE16(anim->lpheader.maxRecsPerLp); + anim->lpheader.lpfTableOffset = B_LITTLE16(anim->lpheader.lpfTableOffset); + anim->lpheader.contentType = B_LITTLE32(anim->lpheader.contentType); + anim->lpheader.width = B_LITTLE16(anim->lpheader.width); + anim->lpheader.height = B_LITTLE16(anim->lpheader.height); + anim->lpheader.nFrames = B_LITTLE32(anim->lpheader.nFrames); + anim->lpheader.framesPerSecond = B_LITTLE16(anim->lpheader.framesPerSecond); + + buffer += size+128; + // load the color palette + for (i = 0; i < 768; i += 3) + { + anim->pal[i+2] = *buffer++; + anim->pal[i+1] = *buffer++; + anim->pal[i] = *buffer++; + buffer++; + } + // read in large page descriptors + size = sizeof(anim->LpArray); + Bmemcpy(&anim->LpArray,buffer,size); + + for (i = 0; i < size/sizeof(lp_descriptor); i++) + { + anim->LpArray[i].baseRecord = B_LITTLE16(anim->LpArray[i].baseRecord); + anim->LpArray[i].nRecords = B_LITTLE16(anim->LpArray[i].nRecords); + anim->LpArray[i].nBytes = B_LITTLE16(anim->LpArray[i].nBytes); + } + } + +//**************************************************************************** +// +// ANIM_FreeAnim () +// +//**************************************************************************** + +void ANIM_FreeAnim ( void ) + { + if (Anim_Started) + { + SafeFree(anim); + Anim_Started = false; + } + } + +//**************************************************************************** +// +// ANIM_NumFrames () +// +//**************************************************************************** + +int32 ANIM_NumFrames ( void ) + { + CheckAnimStarted ( "NumFrames" ); + return anim->lpheader.nRecords; + } + +//**************************************************************************** +// +// ANIM_DrawFrame () +// +//**************************************************************************** + +byte * ANIM_DrawFrame (int32 framenumber) + { + int32 cnt; + + CheckAnimStarted ( "DrawFrame" ); + if ((anim->currentframe != -1) && (anim->currentframe<=framenumber)) + { + for (cnt = anim->currentframe; cnt < framenumber; cnt++) + drawframe (cnt); + } + else + { + for (cnt = 0; cnt < framenumber; cnt++) + drawframe (cnt); + } + anim->currentframe = framenumber; + return anim->imagebuffer; + } + +//**************************************************************************** +// +// ANIM_GetPalette () +// +//**************************************************************************** + +byte * ANIM_GetPalette ( void ) + { + CheckAnimStarted ( "GetPalette" ); + return anim->pal; + } diff --git a/polymer/eduke32/source/jmact/animlib.h b/polymer/eduke32/source/jmact/animlib.h new file mode 100644 index 000000000..92cb1cab8 --- /dev/null +++ b/polymer/eduke32/source/jmact/animlib.h @@ -0,0 +1,175 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +///////////////////////////////////////////////////////////////////////////// +// +// ANIMLIB.H +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef _animlib_public_ +#define _animlib_public_ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __GNUC__ +# define PACKED __attribute__ ((packed)) +#else +# define PACKED +# ifdef _MSC_VER +# pragma pack(1) +# endif +# ifdef __WATCOMC__ +# pragma pack(push,1); +# endif +#endif + +// structure declarations for deluxe animate large page files */ + +typedef struct PACKED + { + uint32 id; // 4 character ID == "LPF " */ + uint16 maxLps; // max # largePages allowed. 256 FOR NOW. */ + uint16 nLps; // # largePages in this file. */ + uint32 nRecords; // # records in this file. 65534 is current limit plus */ + // one for last-to-first delta for looping the animation */ + uint16 maxRecsPerLp; // # records permitted in an lp. 256 FOR NOW. */ + uint16 lpfTableOffset; // Absolute Seek position of lpfTable. 1280 FOR NOW. + // The lpf Table is an array of 256 large page structures + // that is used to facilitate finding records in an anim + // file without having to seek through all of the Large + // Pages to find which one a specific record lives in. */ + uint32 contentType; // 4 character ID == "ANIM" */ + uint16 width; // Width of screen in pixels. */ + uint16 height; // Height of screen in pixels. */ + byte variant; // 0==ANIM. */ + byte version; // 0==frame rate is multiple of 18 cycles/sec. + // 1==frame rate is multiple of 70 cycles/sec. */ + byte hasLastDelta; // 1==Last record is a delta from last-to-first frame. */ + byte lastDeltaValid; // 0==The last-to-first delta (if present) hasn't been + // updated to match the current first&last frames, so it + // should be ignored. */ + byte pixelType; // /* 0==256 color. */ + byte CompressionType;// /* 1==(RunSkipDump) Only one used FOR NOW. */ + byte otherRecsPerFrm;// /* 0 FOR NOW. */ + byte bitmaptype; // /* 1==320x200, 256-color. Only one implemented so far. */ + byte recordTypes[32];// /* Not yet implemented. */ + uint32 nFrames; // /* In case future version adds other records at end of + // file, we still know how many actual frames. + // NOTE: DOES include last-to-first delta when present. */ + uint16 framesPerSecond; // Number of frames to play per second. */ + uint16 pad2[29]; // 58 bytes of filler to round up to 128 bytes total. */ + } lpfileheader; + +// this is the format of a large page structure +typedef struct PACKED + { + uint16 baseRecord; // Number of first record in this large page. + uint16 nRecords; // Number of records in lp. + // bit 15 of "nRecords" == "has continuation from previous lp". + // bit 14 of "nRecords" == "final record continues on next lp". + uint16 nBytes; // Total number of bytes of contents, excluding header. + } lp_descriptor; + +#undef PACKED +#ifdef _MSC_VER +# pragma pack() +#endif +#ifdef __WATCOMC__ +# pragma pack(pop); +#endif + +typedef struct + { + uint16 framecount; // current frame of anim + lpfileheader lpheader; // file header will be loaded into this structure + lp_descriptor LpArray[256]; // arrays of large page structs used to find frames + uint16 curlpnum; // initialize to an invalid Large page number + lp_descriptor curlp; // header of large page currently in memory + uint16 thepage[0x8000]; // buffer where current large page is loaded + byte imagebuffer[0x10000]; // buffer where anim frame is decoded + byte * buffer; + byte pal[768]; + int32 currentframe; + } anim_t; + +//**************************************************************************** +// +// ANIM_LoadAnim () +// +// Setup internal anim data structure +// +//**************************************************************************** + +void ANIM_LoadAnim (char * buffer); + +//**************************************************************************** +// +// ANIM_FreeAnim () +// +// Free up internal anim data structure +// +//**************************************************************************** + +void ANIM_FreeAnim ( void ); + +//**************************************************************************** +// +// ANIM_NumFrames () +// +// returns the number of frames in the current anim +// +//**************************************************************************** + +int32 ANIM_NumFrames ( void ); + +//**************************************************************************** +// +// ANIM_DrawFrame () +// +// Draw the frame to a returned buffer +// +//**************************************************************************** + +byte * ANIM_DrawFrame (int32 framenumber); + +//**************************************************************************** +// +// ANIM_GetPalette () +// +// return the palette of the anim +//**************************************************************************** + +byte * ANIM_GetPalette ( void ); + +extern anim_t * anim; + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jmact/control.c b/polymer/eduke32/source/jmact/control.c new file mode 100644 index 000000000..2eb65e1f0 --- /dev/null +++ b/polymer/eduke32/source/jmact/control.c @@ -0,0 +1,982 @@ +/* + * control.c + * MACT library controller handling + * + * Derived from MACT386.LIB disassembly by Jonathon Fowler + * + */ + +#include "types.h" +#include "keyboard.h" +#include "mouse.h" +#include "control.h" +#include "_control.h" +#include "util_lib.h" + +#include "baselayer.h" +#include "compat.h" +#include "pragmas.h" + + +boolean CONTROL_JoyPresent = false; +boolean CONTROL_JoystickEnabled = false; +boolean CONTROL_MousePresent = false; +boolean CONTROL_MouseEnabled = false; +uint32 CONTROL_ButtonState1 = 0; +uint32 CONTROL_ButtonHeldState1 = 0; +uint32 CONTROL_ButtonState2 = 0; +uint32 CONTROL_ButtonHeldState2 = 0; + +static int32 CONTROL_UserInputDelay = -1; +static int32 CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY; +static int32 CONTROL_NumMouseButtons = 0; +static int32 CONTROL_NumMouseAxes = 0; +static int32 CONTROL_NumJoyButtons = 0; +static int32 CONTROL_NumJoyAxes = 0; +static controlflags CONTROL_Flags[CONTROL_NUM_FLAGS]; +static controlbuttontype CONTROL_MouseButtonMapping[MAXMOUSEBUTTONS], + CONTROL_JoyButtonMapping[MAXJOYBUTTONS]; +static controlkeymaptype CONTROL_KeyMapping[CONTROL_NUM_FLAGS]; +static controlaxismaptype CONTROL_MouseAxesMap[MAXMOUSEAXES], // maps physical axes onto virtual ones + CONTROL_JoyAxesMap[MAXJOYAXES]; +static controlaxistype CONTROL_MouseAxes[MAXMOUSEAXES], // physical axes + CONTROL_JoyAxes[MAXJOYAXES]; +static controlaxistype CONTROL_LastMouseAxes[MAXMOUSEAXES], + CONTROL_LastJoyAxes[MAXJOYAXES]; +static int32 CONTROL_MouseAxesScale[MAXMOUSEAXES], CONTROL_JoyAxesScale[MAXJOYAXES]; +static int32 CONTROL_MouseButtonState[MAXMOUSEBUTTONS], CONTROL_JoyButtonState[MAXJOYBUTTONS]; +static int32 CONTROL_MouseButtonClickedTime[MAXMOUSEBUTTONS], CONTROL_JoyButtonClickedTime[MAXJOYBUTTONS]; +static boolean CONTROL_MouseButtonClickedState[MAXMOUSEBUTTONS], CONTROL_JoyButtonClickedState[MAXJOYBUTTONS]; +static boolean CONTROL_MouseButtonClicked[MAXMOUSEBUTTONS], CONTROL_JoyButtonClicked[MAXJOYBUTTONS]; +static byte CONTROL_MouseButtonClickedCount[MAXMOUSEBUTTONS], CONTROL_JoyButtonClickedCount[MAXJOYBUTTONS]; +static boolean CONTROL_UserInputCleared[3]; +static int32 (*GetTime)(void); +static boolean CONTROL_Started = false; +static int32 ticrate; +static int32 CONTROL_DoubleClickSpeed; + + +void CONTROL_GetMouseDelta(void) +{ + int32 x,y; + + MOUSE_GetDelta(&x, &y); + + /* What in the name of all things sacred is this? + if (labs(*x) > labs(*y)) { + *x /= 3; + } else { + *y /= 3; + } + *y = *y * 96; + *x = (*x * 32 * CONTROL_MouseSensitivity) >> 15; + */ + + CONTROL_MouseAxes[0].analog = mulscale8(x, CONTROL_MouseSensitivity); + CONTROL_MouseAxes[1].analog = mulscale6(y, CONTROL_MouseSensitivity); +} + +int32 CONTROL_GetMouseSensitivity(void) +{ + return (CONTROL_MouseSensitivity - MINIMUMMOUSESENSITIVITY); +} + +void CONTROL_SetMouseSensitivity(int32 newsensitivity) +{ + CONTROL_MouseSensitivity = newsensitivity + MINIMUMMOUSESENSITIVITY; +} + +boolean CONTROL_StartMouse(void) +{ + CONTROL_NumMouseButtons = MAXMOUSEBUTTONS; + return MOUSE_Init(); +} + +void CONTROL_GetJoyAbs( void ) +{ +} + +void CONTROL_FilterJoyDelta(void) +{ +} + +void CONTROL_GetJoyDelta( void ) +{ + int32 i; + + for (i=0; i> 5; +} + + +void CONTROL_SetJoyScale( void ) +{ +} + +void CONTROL_CenterJoystick + ( + void ( *CenterCenter )( void ), + void ( *UpperLeft )( void ), + void ( *LowerRight )( void ), + void ( *CenterThrottle )( void ), + void ( *CenterRudder )( void ) + ) +{ +} + +boolean CONTROL_StartJoy(int32 joy) +{ + return (inputdevices & 3) == 3; +} + +void CONTROL_ShutJoy(int32 joy) +{ + CONTROL_JoyPresent = false; +} + +int32 CONTROL_GetTime(void) +{ + static int32 t = 0; + t += 5; + return t; +} + +boolean CONTROL_CheckRange(int32 which) +{ + if ((uint32)which < (uint32)CONTROL_NUM_FLAGS) return false; + //Error("CONTROL_CheckRange: Index %d out of valid range for %d control flags.", + // which, CONTROL_NUM_FLAGS); + return true; +} + +void CONTROL_SetFlag(int32 which, boolean active) +{ + if (CONTROL_CheckRange(which)) return; + + if (CONTROL_Flags[which].toggle == INSTANT_ONOFF) { + CONTROL_Flags[which].active = active; + } else { + if (active) { + CONTROL_Flags[which].buttonheld = false; + } else if (CONTROL_Flags[which].buttonheld == false) { + CONTROL_Flags[which].buttonheld = true; + CONTROL_Flags[which].active = (CONTROL_Flags[which].active ? false : true); + } + } +} + +boolean CONTROL_KeyboardFunctionPressed(int32 which) +{ + boolean key1 = 0, key2 = 0; + + if (CONTROL_CheckRange(which)) return false; + + if (!CONTROL_Flags[which].used) return false; + + if (CONTROL_KeyMapping[which].key1 != KEYUNDEFINED) + key1 = KB_KeyDown[ CONTROL_KeyMapping[which].key1 ] ? true : false; + + if (CONTROL_KeyMapping[which].key2 != KEYUNDEFINED) + key2 = KB_KeyDown[ CONTROL_KeyMapping[which].key2 ] ? true : false; + + return (key1 | key2); +} + +void CONTROL_ClearKeyboardFunction(int32 which) +{ + if (CONTROL_CheckRange(which)) return; + + if (!CONTROL_Flags[which].used) return; + + if (CONTROL_KeyMapping[which].key1 != KEYUNDEFINED) + KB_KeyDown[ CONTROL_KeyMapping[which].key1 ] = 0; + + if (CONTROL_KeyMapping[which].key2 != KEYUNDEFINED) + KB_KeyDown[ CONTROL_KeyMapping[which].key2 ] = 0; +} + +void CONTROL_DefineFlag( int32 which, boolean toggle ) +{ + if (CONTROL_CheckRange(which)) return; + + CONTROL_Flags[which].active = false; + CONTROL_Flags[which].used = true; + CONTROL_Flags[which].toggle = toggle; + CONTROL_Flags[which].buttonheld = false; + CONTROL_Flags[which].cleared = 0; +} + +boolean CONTROL_FlagActive( int32 which ) +{ + if (CONTROL_CheckRange(which)) return false; + + return CONTROL_Flags[which].used; +} + +void CONTROL_MapKey( int32 which, kb_scancode key1, kb_scancode key2 ) +{ + if (CONTROL_CheckRange(which)) return; + + CONTROL_KeyMapping[which].key1 = key1 ? key1 : KEYUNDEFINED; + CONTROL_KeyMapping[which].key2 = key2 ? key2 : KEYUNDEFINED; +} + +void CONTROL_PrintKeyMap(void) +{ + int32 i; + + for (i=0;i= (uint32)MAXMOUSEBUTTONS) { + //Error("CONTROL_MapButton: button %d out of valid range for %d mouse buttons.", + // whichbutton, CONTROL_NumMouseButtons); + return; + } + set = CONTROL_MouseButtonMapping; + break; + + case controldevice_joystick: + if ((uint32)whichbutton >= (uint32)MAXJOYBUTTONS) { + //Error("CONTROL_MapButton: button %d out of valid range for %d joystick buttons.", + // whichbutton, CONTROL_NumJoyButtons); + return; + } + set = CONTROL_JoyButtonMapping; + break; + + default: + //Error("CONTROL_MapButton: invalid controller device type"); + return; + } + + if (doubleclicked) + set[whichbutton].doubleclicked = whichfunction; + else + set[whichbutton].singleclicked = whichfunction; +} + +void CONTROL_MapAnalogAxis( int32 whichaxis, int32 whichanalog, controldevice device ) +{ + controlaxismaptype *set; + + if ((uint32)whichanalog >= (uint32)analog_maxtype) { + //Error("CONTROL_MapAnalogAxis: analog function %d out of valid range for %d analog functions.", + // whichanalog, analog_maxtype); + return; + } + + switch (device) { + case controldevice_mouse: + if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES) { + //Error("CONTROL_MapAnalogAxis: axis %d out of valid range for %d mouse axes.", + // whichaxis, MAXMOUSEAXES); + return; + } + + set = CONTROL_MouseAxesMap; + break; + + case controldevice_joystick: + if ((uint32)whichaxis >= (uint32)MAXJOYAXES) { + //Error("CONTROL_MapAnalogAxis: axis %d out of valid range for %d joystick axes.", + // whichaxis, MAXJOYAXES); + return; + } + + set = CONTROL_JoyAxesMap; + break; + + default: + //Error("CONTROL_MapAnalogAxis: invalid controller device type"); + return; + } + + set[whichaxis].analogmap = whichanalog; +} + +void CONTROL_SetAnalogAxisScale( int32 whichaxis, int32 axisscale, controldevice device ) +{ + int32 *set; + + switch (device) { + case controldevice_mouse: + if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES) { + //Error("CONTROL_SetAnalogAxisScale: axis %d out of valid range for %d mouse axes.", + // whichaxis, MAXMOUSEAXES); + return; + } + + set = CONTROL_MouseAxesScale; + break; + + case controldevice_joystick: + if ((uint32)whichaxis >= (uint32)MAXJOYAXES) { + //Error("CONTROL_SetAnalogAxisScale: axis %d out of valid range for %d joystick axes.", + // whichaxis, MAXJOYAXES); + return; + } + + set = CONTROL_JoyAxesScale; + break; + + default: + //Error("CONTROL_SetAnalogAxisScale: invalid controller device type"); + return; + } + + set[whichaxis] = axisscale; +} + +void CONTROL_MapDigitalAxis( int32 whichaxis, int32 whichfunction, int32 direction, controldevice device ) +{ + controlaxismaptype *set; + + if (CONTROL_CheckRange(whichfunction)) whichfunction = AXISUNDEFINED; + + switch (device) { + case controldevice_mouse: + if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES) { + //Error("CONTROL_MapDigitalAxis: axis %d out of valid range for %d mouse axes.", + // whichaxis, MAXMOUSEAXES); + return; + } + + set = CONTROL_MouseAxesMap; + break; + + case controldevice_joystick: + if ((uint32)whichaxis >= (uint32)MAXJOYAXES) { + //Error("CONTROL_MapDigitalAxis: axis %d out of valid range for %d joystick axes.", + // whichaxis, MAXJOYAXES); + return; + } + + set = CONTROL_JoyAxesMap; + break; + + default: + //Error("CONTROL_MapDigitalAxis: invalid controller device type"); + return; + } + + switch (direction) { // JBF: this is all very much a guess. The ASM puzzles me. + case axis_up: + case axis_left: + set[whichaxis].minmap = whichfunction; + break; + case axis_down: + case axis_right: + set[whichaxis].maxmap = whichfunction; + break; + default: + break; + } +} + +void CONTROL_ClearFlags(void) +{ + int32 i; + + for (i=0;i> i) & 1; + + DeviceButtonState[i] = bs; + ButtonClickedState[i] = false; + + if (bs) { + if (ButtonClicked[i] == false) { + ButtonClicked[i] = true; + + if (ButtonClickedCount[i] == 0 || tm > ButtonClickedTime[i]) { + ButtonClickedTime[i] = tm + CONTROL_DoubleClickSpeed; + ButtonClickedCount[i] = 1; + } + else if (tm < ButtonClickedTime[i]) { + ButtonClickedState[i] = true; + ButtonClickedTime[i] = 0; + ButtonClickedCount[i] = 2; + } + } + else if (ButtonClickedCount[i] == 2) { + ButtonClickedState[i] = true; + } + } else { + if (ButtonClickedCount[i] == 2) + ButtonClickedCount[i] = 0; + + ButtonClicked[i] = false; + } + } +} + +void CONTROL_GetDeviceButtons(void) +{ + int32 t; + + t = GetTime(); + + if (CONTROL_MouseEnabled) { + DoGetDeviceButtons( + MOUSE_GetButtons(), t, + CONTROL_NumMouseButtons, + CONTROL_MouseButtonState, + CONTROL_MouseButtonClickedTime, + CONTROL_MouseButtonClickedState, + CONTROL_MouseButtonClicked, + CONTROL_MouseButtonClickedCount + ); + } + + if (CONTROL_JoystickEnabled) { + int32 buttons = joyb; + if (joynumhats > 0 && joyhat[0] != -1) { + static int32 hatstate[] = { 1, 1|2, 2, 2|4, 4, 4|8, 8, 8|1 }; + int val; + + // thanks SDL for this much more sensible method + val = ((joyhat[0] + 4500 / 2) % 36000) / 4500; + if (val < 8) buttons |= hatstate[val] << min(MAXJOYBUTTONS,joynumbuttons); + } + + DoGetDeviceButtons( + buttons, t, + CONTROL_NumJoyButtons, + CONTROL_JoyButtonState, + CONTROL_JoyButtonClickedTime, + CONTROL_JoyButtonClickedState, + CONTROL_JoyButtonClicked, + CONTROL_JoyButtonClickedCount + ); + } +} + +void CONTROL_DigitizeAxis(int32 axis, controldevice device) +{ + controlaxistype *set, *lastset; + + switch (device) { + case controldevice_mouse: + set = CONTROL_MouseAxes; + lastset = CONTROL_LastMouseAxes; + break; + + case controldevice_joystick: + set = CONTROL_JoyAxes; + lastset = CONTROL_LastJoyAxes; + break; + + default: return; + } + + if (set[axis].analog > 0) { + if (set[axis].analog > THRESHOLD) { // if very much in one direction, + set[axis].digital = 1; // set affirmative + } else { + if (set[axis].analog > MINTHRESHOLD) { // if hanging in limbo, + if (lastset[axis].digital == 1) // set if in same direction as last time + set[axis].digital = 1; + } + } + } else { + if (set[axis].analog < -THRESHOLD) { + set[axis].digital = -1; + } else { + if (set[axis].analog < -MINTHRESHOLD) { + if (lastset[axis].digital == -1) + set[axis].digital = -1; + } + } + } +} + +void CONTROL_ScaleAxis(int32 axis, controldevice device) +{ + controlaxistype *set; + int32 *scale; + + switch (device) { + case controldevice_mouse: + set = CONTROL_MouseAxes; + scale = CONTROL_MouseAxesScale; + break; + + case controldevice_joystick: + set = CONTROL_JoyAxes; + scale = CONTROL_JoyAxesScale; + break; + + default: return; + } + + set[axis].analog = mulscale16(set[axis].analog, scale[axis]); +} + +void CONTROL_ApplyAxis(int32 axis, ControlInfo *info, controldevice device) +{ + controlaxistype *set; + controlaxismaptype *map; + + switch (device) { + case controldevice_mouse: + set = CONTROL_MouseAxes; + map = CONTROL_MouseAxesMap; + break; + + case controldevice_joystick: + set = CONTROL_JoyAxes; + map = CONTROL_JoyAxesMap; + break; + + default: return; + } + + switch (map[axis].analogmap) { + case analog_turning: info->dyaw += set[axis].analog; break; + case analog_strafing: info->dx += set[axis].analog; break; + case analog_lookingupanddown: info->dpitch += set[axis].analog; break; + case analog_elevation: info->dy += set[axis].analog; break; + case analog_rolling: info->droll += set[axis].analog; break; + case analog_moving: info->dz += set[axis].analog; break; + default: break; + } +} + +void CONTROL_PollDevices(ControlInfo *info) +{ + int32 i; + + memcpy(CONTROL_LastMouseAxes, CONTROL_MouseAxes, sizeof(CONTROL_MouseAxes)); + memcpy(CONTROL_LastJoyAxes, CONTROL_JoyAxes, sizeof(CONTROL_JoyAxes)); + + memset(CONTROL_MouseAxes, 0, sizeof(CONTROL_MouseAxes)); + memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes)); + memset(info, 0, sizeof(ControlInfo)); + + if (CONTROL_MouseEnabled) { + CONTROL_GetMouseDelta(); + + for (i=0; idir = dir_None; + + // checks if CONTROL_UserInputDelay is too far in the future due to clock skew? + if (GetTime() + ((ticrate * USERINPUTDELAY) / 1000) < CONTROL_UserInputDelay) + CONTROL_UserInputDelay = -1; + + if (GetTime() >= CONTROL_UserInputDelay) { + if (CONTROL_MouseAxes[1].digital == -1) + info->dir = dir_North; + else if (CONTROL_MouseAxes[1].digital == 1) + info->dir = dir_South; + else if (CONTROL_MouseAxes[0].digital == -1) + info->dir = dir_West; + else if (CONTROL_MouseAxes[0].digital == 1) + info->dir = dir_East; + + if (CONTROL_JoyAxes[1].digital == -1) + info->dir = dir_North; + else if (CONTROL_JoyAxes[1].digital == 1) + info->dir = dir_South; + else if (CONTROL_JoyAxes[0].digital == -1) + info->dir = dir_West; + else if (CONTROL_JoyAxes[0].digital == 1) + info->dir = dir_East; + } + + info->button0 = CONTROL_MouseButtonState[0] | CONTROL_JoyButtonState[0]; + info->button1 = CONTROL_MouseButtonState[1] | CONTROL_JoyButtonState[1]; + + if (KB_KeyDown[sc_kpad_8] || KB_KeyDown[sc_UpArrow]) + info->dir = dir_North; + else if (KB_KeyDown[sc_kpad_2] || KB_KeyDown[sc_DownArrow]) + info->dir = dir_South; + else if (KB_KeyDown[sc_kpad_4] || KB_KeyDown[sc_LeftArrow]) + info->dir = dir_West; + else if (KB_KeyDown[sc_kpad_6] || KB_KeyDown[sc_RightArrow]) + info->dir = dir_East; + + if (KB_KeyDown[BUTTON0_SCAN_1] || KB_KeyDown[BUTTON0_SCAN_2] || KB_KeyDown[BUTTON0_SCAN_3]) + info->button0 = 1; + if (KB_KeyDown[BUTTON1_SCAN]) + info->button1 = 1; + + if (CONTROL_UserInputCleared[1]) { + if (!info->button0) + CONTROL_UserInputCleared[1] = false; + else + info->button0 = false; + } + if (CONTROL_UserInputCleared[2]) { + if (!info->button1) + CONTROL_UserInputCleared[2] = false; + else + info->button1 = false; + } +} + +void CONTROL_ClearUserInput( UserInput *info ) +{ + switch (info->dir) { + case dir_North: + case dir_South: + case dir_East: + case dir_West: + CONTROL_UserInputCleared[0] = true; + CONTROL_UserInputDelay = GetTime() + ((ticrate * USERINPUTDELAY) / 1000); + switch (info->dir) { + case dir_North: KB_KeyDown[sc_UpArrow] = KB_KeyDown[sc_kpad_8] = 0; break; + case dir_South: KB_KeyDown[sc_DownArrow] = KB_KeyDown[sc_kpad_2] = 0; break; + case dir_East: KB_KeyDown[sc_LeftArrow] = KB_KeyDown[sc_kpad_4] = 0; break; + case dir_West: KB_KeyDown[sc_RightArrow] = KB_KeyDown[sc_kpad_6] = 0; break; + default: break; + } + break; + default: break; + } + if (info->button0) CONTROL_UserInputCleared[1] = true; + if (info->button1) CONTROL_UserInputCleared[2] = true; +} + +void CONTROL_ClearButton( int32 whichbutton ) +{ + if (CONTROL_CheckRange( whichbutton )) return; + BUTTONCLEAR( whichbutton ); + CONTROL_Flags[whichbutton].cleared = true; +} + +void CONTROL_GetInput( ControlInfo *info ) +{ + int32 i, periphs[CONTROL_NUM_FLAGS]; + + CONTROL_PollDevices( info ); + + memset(periphs, 0, sizeof(periphs)); + CONTROL_ButtonFunctionState(periphs); + CONTROL_AxisFunctionState(periphs); + + CONTROL_ButtonHeldState1 = CONTROL_ButtonState1; + CONTROL_ButtonHeldState2 = CONTROL_ButtonState2; + CONTROL_ButtonState1 = CONTROL_ButtonState2 = 0; + + for (i=0; i0)); + CONTROL_JoyPresent = ((inputdevices & 3) == 3); + CONTROL_JoystickEnabled = CONTROL_JoyPresent; + break; + } + + if (CONTROL_MousePresent) + initprintf("CONTROL_Startup: Mouse Present\n"); + if (CONTROL_JoyPresent) + initprintf("CONTROL_Startup: Joystick Present\n"); + + CONTROL_ButtonState1 = 0; + CONTROL_ButtonState2 = 0; + CONTROL_ButtonHeldState1 = 0; + CONTROL_ButtonHeldState2 = 0; + + memset(CONTROL_UserInputCleared, 0, sizeof(CONTROL_UserInputCleared)); + + for (i=0; i31) ? \ + ((CONTROL_ButtonState2>>( (x) - 32) ) & 1) :\ + ((CONTROL_ButtonState1>> (x) ) & 1) \ + ) +#define BUTTONHELD(x) \ + ( \ + ((x)>31) ? \ + ((CONTROL_ButtonHeldState2>>((x)-32)) & 1) :\ + ((CONTROL_ButtonHeldState1>>(x)) & 1)\ + ) +#define BUTTONJUSTPRESSED(x) \ + ( BUTTON( x ) && !BUTTONHELD( x ) ) +#define BUTTONRELEASED(x) \ + ( !BUTTON( x ) && BUTTONHELD( x ) ) +#define BUTTONSTATECHANGED(x) \ + ( BUTTON( x ) != BUTTONHELD( x ) ) + + +//*************************************************************************** +// +// TYPEDEFS +// +//*************************************************************************** +typedef enum + { + axis_up, + axis_down, + axis_left, + axis_right + } axisdirection; + +typedef enum + { + analog_turning=0, + analog_strafing=1, + analog_lookingupanddown=2, + analog_elevation=3, + analog_rolling=4, + analog_moving=5, + analog_maxtype + } analogcontrol; + +typedef enum + { + dir_North, + dir_NorthEast, + dir_East, + dir_SouthEast, + dir_South, + dir_SouthWest, + dir_West, + dir_NorthWest, + dir_None + } direction; + +typedef struct + { + boolean button0; + boolean button1; + direction dir; + } UserInput; + +typedef struct + { + fixed dx; + fixed dy; + fixed dz; + fixed dyaw; + fixed dpitch; + fixed droll; + } ControlInfo; + +typedef enum + { + controltype_keyboard, + controltype_keyboardandmouse, + controltype_keyboardandjoystick + } controltype; + +typedef enum + { + controldevice_keyboard, + controldevice_mouse, + controldevice_joystick + } controldevice; + + +//*************************************************************************** +// +// GLOBALS +// +//*************************************************************************** + +extern boolean CONTROL_MousePresent; +extern boolean CONTROL_JoyPresent; +extern boolean CONTROL_MouseEnabled; +extern boolean CONTROL_JoystickEnabled; +extern uint32 CONTROL_ButtonState1; +extern uint32 CONTROL_ButtonHeldState1; +extern uint32 CONTROL_ButtonState2; +extern uint32 CONTROL_ButtonHeldState2; + + +//*************************************************************************** +// +// PROTOTYPES +// +//*************************************************************************** + +void CONTROL_MapKey( int32 which, kb_scancode key1, kb_scancode key2 ); +void CONTROL_MapButton + ( + int32 whichfunction, + int32 whichbutton, + boolean doubleclicked, + controldevice device + ); +void CONTROL_DefineFlag( int32 which, boolean toggle ); +boolean CONTROL_FlagActive( int32 which ); +void CONTROL_ClearAssignments( void ); +void CONTROL_GetUserInput( UserInput *info ); +void CONTROL_GetInput( ControlInfo *info ); +void CONTROL_ClearButton( int32 whichbutton ); +void CONTROL_ClearUserInput( UserInput *info ); +void CONTROL_WaitRelease( void ); +void CONTROL_Ack( void ); +void CONTROL_CenterJoystick + ( + void ( *CenterCenter )( void ), + void ( *UpperLeft )( void ), + void ( *LowerRight )( void ), + void ( *CenterThrottle )( void ), + void ( *CenterRudder )( void ) + ); +int32 CONTROL_GetMouseSensitivity( void ); +void CONTROL_SetMouseSensitivity( int32 newsensitivity ); +boolean CONTROL_Startup + ( + controltype which, + int32 ( *TimeFunction )( void ), + int32 ticspersecond + ); +void CONTROL_Shutdown( void ); + +void CONTROL_SetDoubleClickDelay(int32 delay); +int32 CONTROL_GetDoubleClickDelay(void); + +void CONTROL_MapAnalogAxis + ( + int32 whichaxis, + int32 whichanalog, + controldevice device + ); + +void CONTROL_MapDigitalAxis + ( + int32 whichaxis, + int32 whichfunction, + int32 direction, + controldevice device + ); +void CONTROL_SetAnalogAxisScale + ( + int32 whichaxis, + int32 axisscale, + controldevice device + ); + +void CONTROL_PrintKeyMap(void); +void CONTROL_PrintControlFlag(int32 which); +void CONTROL_PrintAxes( void ); + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jmact/develop.h b/polymer/eduke32/source/jmact/develop.h new file mode 100644 index 000000000..74b962674 --- /dev/null +++ b/polymer/eduke32/source/jmact/develop.h @@ -0,0 +1,66 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#ifndef _develop_public +#define _develop_public +#ifdef __cplusplus +extern "C" { +#endif + +#define DEVELOPMENT 0 +#define SHAREWARE 0 +#define LOCATIONINFO 1 +#define SOFTWAREERROR 1 +#define MEMORYCORRUPTIONTEST 1 +#define PRECACHETEST 0 +#define DATACORRUPTIONTEST 0 +#define RANDOMNUMBERTEST 0 + + +#if ( LOCATIONINFO == 1 ) + +#define funcstart() \ + { \ + SoftError( "funcstart : module '%s' at line %d.\n", __FILE__, __LINE__ );\ + } + +#define funcend() \ + { \ + SoftError( " funcend : module '%s' at line %d.\n", __FILE__, __LINE__ );\ + } + +#else + +#define funcstart() +#define funcend() + +#endif + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jmact/file_lib.c b/polymer/eduke32/source/jmact/file_lib.c new file mode 100644 index 000000000..64a9ab85a --- /dev/null +++ b/polymer/eduke32/source/jmact/file_lib.c @@ -0,0 +1,136 @@ +/* + * file_lib.c + * File functions to emulate MACT + * + * by Jonathon Fowler + * + * Since we weren't given the source for MACT386.LIB so I've had to do some + * creative interpolation here. + * + */ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. +*/ +//------------------------------------------------------------------------- + +#include +#ifndef _MSC_VER +#include +#endif +#include +#include +#include "types.h" +#include "file_lib.h" +#include "util_lib.h" +#include "compat.h" +#include "cache1d.h" + +#ifndef O_BINARY +#define O_BINARY 0 +#endif +#ifndef O_TEXT +#define O_TEXT 0 +#endif +#ifndef F_OK +#define F_OK 0 +#endif + +#define MaxFiles 20 +static char *FileNames[MaxFiles]; + +int32 SafeOpen(const char *filename, int32 mode, int32 sharemode) +{ + int32 h; + + h = openfrompath(filename, mode, sharemode); + if (h < 0) Error("Error opening %s: %s", filename, strerror(errno)); + + if (h < MaxFiles) { + if (FileNames[h]) SafeFree(FileNames[h]); + FileNames[h] = (char*)SafeMalloc(strlen(filename)+1); + if (FileNames[h]) strcpy(FileNames[h], filename); + } + + return h; +} + +int32 SafeOpenRead(const char *filename, int32 filetype) +{ + int32 h; + + switch (filetype) { + case filetype_binary: + return SafeOpen(filename, O_RDONLY|O_BINARY, S_IREAD); + case filetype_text: + return SafeOpen(filename, O_RDONLY|O_TEXT, S_IREAD); + default: + Error("SafeOpenRead: Illegal filetype specified"); + return -1; + } +} + +void SafeClose ( int32 handle ) +{ + int r; + + if (handle < 0) return; + if (close(handle) < 0) { + if (handle < MaxFiles) + Error("Unable to close file %s", FileNames[handle]); + else + Error("Unable to close file"); + } + + if (handle < MaxFiles && FileNames[handle]) { + SafeFree(FileNames[handle]); + FileNames[handle] = NULL; + } +} + +boolean SafeFileExists(const char *filename) +{ + if (!access(filename, F_OK)) return true; + return false; +} + +int32 SafeFileLength ( int32 handle ) +{ + if (handle < 0) return -1; + return Bfilelength(handle); +} + +void SafeRead(int32 handle, void *buffer, int32 count) +{ + int32 b; + + b = read(handle, buffer, count); + if (b != count) { + close(handle); + if (handle < MaxFiles) + Error("File read failure %s reading %d bytes from file %s.", + strerror(errno), count, FileNames[handle]); + else + Error("File read failure %s reading %d bytes.", + strerror(errno), count); + } +} + + diff --git a/polymer/eduke32/source/jmact/file_lib.h b/polymer/eduke32/source/jmact/file_lib.h new file mode 100644 index 000000000..f5a2ee04d --- /dev/null +++ b/polymer/eduke32/source/jmact/file_lib.h @@ -0,0 +1,260 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +*/ +//------------------------------------------------------------------------- + +#ifndef _file_lib_public +#define _file_lib_public +#ifdef __cplusplus +extern "C" { +#endif + +enum + { + filetype_binary, + filetype_text + }; + +enum + { + access_read, + access_write, + access_append + }; + +//========================================================================== +// +// SafeOpenWrite - Opens a file for writing, returns handle +// +//========================================================================== +int32 SafeOpenWrite ( const char * filename, int32 filetype ); + +//========================================================================== +// +// SafeOpenRead - Opens a file for reading, returns handle +// +//========================================================================== +int32 SafeOpenRead ( const char * filename, int32 filetype ); + +//========================================================================== +// +// SafeOpenAppend - Opens a file for appending, returns handle +// +//========================================================================== +int32 SafeOpenAppend ( const char * filename, int32 filetype ); + +//========================================================================== +// +// SafeClose - Close a file denoted by the file handle +// +//========================================================================== +void SafeClose ( int32 handle ); + +//========================================================================== +// +// SafeFileExists - Checks for existence of file +// +//========================================================================== +boolean SafeFileExists ( const char * filename ); + +//========================================================================== +// +// SafeFileLength - Get length of a file pointed to by handle +// +//========================================================================== +int32 SafeFileLength ( int32 handle ); + +//========================================================================== +// +// SafeRead - reads from a handle +// +// handle - handle of file to read from +// +// buffer - pointer of buffer to read into +// +// count - number of bytes to read +// +//========================================================================== +void SafeRead (int32 handle, void *buffer, int32 count); + +//========================================================================== +// +// SafeWrite - writes to a handle +// +// handle - handle of file to write to +// +// buffer - pointer of buffer to write from +// +// count - number of bytes to write +// +//========================================================================== +void SafeWrite (int32 handle, void *buffer, int32 count); + +//========================================================================== +// +// LoadFile - Load a file +// +// filename - name of file +// +// bufferptr - pointer to pointer of buffer to read into +// +// returns number of bytes read +// +//========================================================================== +int32 LoadFile ( const char * filename, void ** bufferptr ); + +//========================================================================== +// +// SaveFile - Save a file +// +// filename - name of file +// +// bufferptr - pointer to buffer to write from +// +// count - number of bytes to write +// +//========================================================================== +void SaveFile ( const char * filename, void * bufferptr, int32 count ); + +//========================================================================== +// +// GetPathFromEnvironment - Add a pathname described in an environment +// variable to a standard filename. +// +// fullname - final string containing entire path +// +// envname - string naming enivronment variable +// +// filename - standard filename +// +//========================================================================== +void GetPathFromEnvironment( char *fullname, const char *envname, const char *filename ); + +//========================================================================== +// +// DefaultExtension - Add a default extension to a path +// +// path - a path +// +// extension - default extension should include '.' +// +//========================================================================== +void DefaultExtension (char *path, const char *extension); + +//========================================================================== +// +// DefaultPath - Add the default path to a filename if it doesn't have one +// +// path - filename +// +// extension - default path +// +//========================================================================== +void DefaultPath (char *path, const char *basepath); + +//========================================================================== +// +// ExtractFileBase - Extract the base filename from a path +// +// path - the path +// +// dest - where the file base name will be placed +// +//========================================================================== +void ExtractFileBase (char *path, char *dest); + +//========================================================================== +// +// GetExtension - Extract the extension from a name +// returns true if an extension is found +// returns false otherwise +// +//========================================================================== +boolean GetExtension( char *filename, char *extension ); + +//========================================================================== +// +// SetExtension - Sets the extension from a name. Assumes that enough +// space is left at the end of the string to hold an extension. +// +//========================================================================== +void SetExtension( char *filename, const char *extension ); + +#ifdef __MSDOS__ +//****************************************************************************** +// +// GetPath +// +// Purpose +// To parse the directory entered by the user to make the directory. +// +// Parms +// Path - the path to be parsed. +// +// Returns +// Pointer to next path +// +//****************************************************************************** +char * GetPath (char * path, char *dir); + +//****************************************************************************** +// +// ChangeDirectory () +// +// Purpose +// To change to a directory. Checks for drive changes. +// +// Parms +// path - The path to change to. +// +// Returns +// TRUE - If successful. +// FALSE - If unsuccessful. +// +//****************************************************************************** +boolean ChangeDirectory (char * path); + +//****************************************************************************** +// +// ChangeDrive () +// +// Purpose +// To change drives. +// +// Parms +// drive - The drive to change to. +// +// Returns +// TRUE - If drive change successful. +// FALSE - If drive change unsuccessful. +// +//****************************************************************************** +boolean ChangeDrive (char *drive); + +#endif + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jmact/keyboard.c b/polymer/eduke32/source/jmact/keyboard.c new file mode 100644 index 000000000..8bf48e764 --- /dev/null +++ b/polymer/eduke32/source/jmact/keyboard.c @@ -0,0 +1,289 @@ +/* + * keyboard.c + * MACT library -to- JonoF's Build Port Keyboard Glue + * + * by Jonathon Fowler + * + * Since we don't have the source to the MACT library I've had to + * concoct some magic to glue its idea of controllers into that of + * my Build port. + * + */ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. +*/ +//------------------------------------------------------------------------- + +#include "compat.h" +#include "types.h" +#include "keyboard.h" +#include "control.h" + + +kb_scancode KB_LastScan; + +static boolean numpad = 0; + +// translation table for taking key names to scancodes and back again +static struct { + char *key; + kb_scancode sc; +} sctokeylut[] = { + { "Escape", 0x1 }, + { "1", 0x2 }, + { "2", 0x3 }, + { "3", 0x4 }, + { "4", 0x5 }, + { "5", 0x6 }, + { "6", 0x7 }, + { "7", 0x8 }, + { "8", 0x9 }, + { "9", 0xa }, + { "0", 0xb }, + { "-", 0xc }, + { "=", 0xd }, + { "BakSpc", 0xe }, + { "Tab", 0xf }, + { "Q", 0x10 }, + { "W", 0x11 }, + { "E", 0x12 }, + { "R", 0x13 }, + { "T", 0x14 }, + { "Y", 0x15 }, + { "U", 0x16 }, + { "I", 0x17 }, + { "O", 0x18 }, + { "P", 0x19 }, + { "[", 0x1a }, + { "]", 0x1b }, + { "Enter", 0x1c }, + { "LCtrl", 0x1d }, + { "A", 0x1e }, + { "S", 0x1f }, + { "D", 0x20 }, + { "F", 0x21 }, + { "G", 0x22 }, + { "H", 0x23 }, + { "J", 0x24 }, + { "K", 0x25 }, + { "L", 0x26 }, + { ";", 0x27 }, + { "'", 0x28 }, + { "`", 0x29 }, + { "LShift", 0x2a }, + { "\\", 0x2b }, + { "Z", 0x2c }, + { "X", 0x2d }, + { "C", 0x2e }, + { "V", 0x2f }, + { "B", 0x30 }, + { "N", 0x31 }, + { "M", 0x32 }, + { ",", 0x33 }, + { ".", 0x34 }, + { "/", 0x35 }, + { "RShift", 0x36 }, + { "Kpad*", 0x37 }, + { "LAlt", 0x38 }, + { "Space", 0x39 }, + { "CapLck", 0x3a }, + { "F1", 0x3b }, + { "F2", 0x3c }, + { "F3", 0x3d }, + { "F4", 0x3e }, + { "F5", 0x3f }, + { "F6", 0x40 }, + { "F7", 0x41 }, + { "F8", 0x42 }, + { "F9", 0x43 }, + { "F10", 0x44 }, + { "NumLck", 0x45 }, + { "ScrLck", 0x46 }, + { "Kpad7", 0x47 }, + { "Kpad8", 0x48 }, + { "Kpad9", 0x49 }, + { "Kpad-", 0x4a }, + { "Kpad4", 0x4b }, + { "Kpad5", 0x4c }, + { "Kpad6", 0x4d }, + { "Kpad+", 0x4e }, + { "Kpad1", 0x4f }, + { "Kpad2", 0x50 }, + { "Kpad3", 0x51 }, + { "Kpad0", 0x52 }, + { "Kpad.", 0x53 }, + { "F11", 0x57 }, + { "F12", 0x58 }, + { "KpdEnt", 0x9c }, + { "RCtrl", 0x9d }, + { "Kpad/", 0xb5 }, + { "RAlt", 0xb8 }, + { "PrtScn", 0xb7 }, + { "Pause", 0xc5 }, + { "Home", 0xc7 }, + { "Up", 0xc8 }, + { "PgUp", 0xc9 }, + { "Left", 0xcb }, + { "Right", 0xcd }, + { "End", 0xcf }, + { "Down", 0xd0 }, + { "PgDn", 0xd1 }, + { "Insert", 0xd2 }, + { "Delete", 0xd3 }, +}; + +// translation table for turning scancode into ascii characters +/* +static char sctoasc[2][256] = { + { +// 0 1 2 3 4 5 6 7 8 9 a b c d e f + 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, 9, // 0x00 + 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 13, 0, 'a', 's', // 0x10 + 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'','`', 0, '\\','z', 'x', 'c', 'v', // 0x20 + 'b', 'n', 'm', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, // 0x30 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, // 0x40 + 0, 0, 0, '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x50 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x70 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, // 0x90 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0 + 0, 0, 0, 0, 0, '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 0xf0 + }, + { +// 0 1 2 3 4 5 6 7 8 9 a b c d e f + 0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 8, 9, // 0x00 + 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 13, 0, 'A', 'S', // 0x10 + 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|', 'Z', 'X', 'C', 'V', // 0x20 + 'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, // 0x30 + 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', // 0x40 + '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x50 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x70 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, // 0x90 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0 + 0, 0, 0, 0, 0, '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 0xf0 + } +}; +*/ + +boolean KB_KeyWaiting( void ) +{ + return bkbhit(); +// return (keyfifoplc != keyfifoend); +} + +char KB_Getch( void ) +{ +/* + unsigned char ch; + char shifted; + if (keyfifoplc == keyfifoend) return 0; + ch = keyfifo[keyfifoplc]; + keyfifoplc = ((keyfifoplc+2)&(KEYFIFOSIZ-1)); + + shifted = ((keystatus[0x2a]!=0)||(keystatus[0x36]!=0)); + if (ch >= 0x47 && ch <= 0x52) shifted = numpad; + + return sctoasc[shifted][ch]; +*/ + return (char)bgetchar(); +} + +void KB_Addch( char ch ) +{ +} + +void KB_FlushKeyboardQueue( void ) +{ + //keyfifoplc = keyfifoend = 0; + bflushchars(); +} + +void KB_ClearKeysDown( void ) +{ + int i; + KB_LastScan = 0; + memset(keystatus, 0, sizeof(keystatus)); + //keyfifoplc = keyfifoend = 0; + //bflushchars(); +} + +char *KB_ScanCodeToString( kb_scancode scancode ) +{ + unsigned s; + + for (s=0; s < (sizeof(sctokeylut)/sizeof(sctokeylut[0])); s++) + if (sctokeylut[s].sc == scancode) return sctokeylut[s].key; + + return ""; +} + +kb_scancode KB_StringToScanCode( char * string ) +{ + unsigned s; + + for (s=0; s < (sizeof(sctokeylut)/sizeof(sctokeylut[0])); s++) + if (!Bstrcasecmp(sctokeylut[s].key, string)) return sctokeylut[s].sc; + + return 0; +} + +void KB_TurnKeypadOn( void ) +{ + numpad = 1; +} + +void KB_TurnKeypadOff( void ) +{ + numpad = 0; +} + +boolean KB_KeypadActive( void ) +{ + return numpad; +} + +static void KB_KeyEvent( long scancode, long keypressed ) +{ + if (keypressed) KB_LastScan = scancode; +} + +void KB_Startup( void ) +{ + numpad = 0; + setkeypresscallback(KB_KeyEvent); +} + +void KB_Shutdown( void ) +{ + setkeypresscallback((void(*)(long,long))NULL); +} + diff --git a/polymer/eduke32/source/jmact/keyboard.h b/polymer/eduke32/source/jmact/keyboard.h new file mode 100644 index 000000000..059cf9092 --- /dev/null +++ b/polymer/eduke32/source/jmact/keyboard.h @@ -0,0 +1,230 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#ifndef _keyboard_public +#define _keyboard_public +#ifdef __cplusplus +extern "C" { +#endif + +#include "baselayer.h" // for the keyboard stuff + +/* +============================================================================= + + DEFINES + +============================================================================= +*/ + +typedef uint8 kb_scancode; + +#define sc_None 0 +#define sc_Bad 0xff +#define sc_Comma 0x33 +#define sc_Period 0x34 +#define sc_Return 0x1c +#define sc_Enter sc_Return +#define sc_Escape 0x01 +#define sc_Space 0x39 +#define sc_BackSpace 0x0e +#define sc_Tab 0x0f +#define sc_LeftAlt 0x38 +#define sc_LeftControl 0x1d +#define sc_CapsLock 0x3a +#define sc_LeftShift 0x2a +#define sc_RightShift 0x36 +#define sc_F1 0x3b +#define sc_F2 0x3c +#define sc_F3 0x3d +#define sc_F4 0x3e +#define sc_F5 0x3f +#define sc_F6 0x40 +#define sc_F7 0x41 +#define sc_F8 0x42 +#define sc_F9 0x43 +#define sc_F10 0x44 +#define sc_F11 0x57 +#define sc_F12 0x58 +#define sc_Kpad_Star 0x37 +#define sc_Pause 0x59 +#define sc_ScrollLock 0x46 +#define sc_NumLock 0x45 +#define sc_Slash 0x35 +#define sc_SemiColon 0x27 +#define sc_Quote 0x28 +#define sc_Tilde 0x29 +#define sc_BackSlash 0x2b + +#define sc_OpenBracket 0x1a +#define sc_CloseBracket 0x1b + +#define sc_1 0x02 +#define sc_2 0x03 +#define sc_3 0x04 +#define sc_4 0x05 +#define sc_5 0x06 +#define sc_6 0x07 +#define sc_7 0x08 +#define sc_8 0x09 +#define sc_9 0x0a +#define sc_0 0x0b +#define sc_Minus 0x0c +#define sc_Equals 0x0d +#define sc_Plus 0x0d + +#define sc_kpad_1 0x4f +#define sc_kpad_2 0x50 +#define sc_kpad_3 0x51 +#define sc_kpad_4 0x4b +#define sc_kpad_5 0x4c +#define sc_kpad_6 0x4d +#define sc_kpad_7 0x47 +#define sc_kpad_8 0x48 +#define sc_kpad_9 0x49 +#define sc_kpad_0 0x52 +#define sc_kpad_Minus 0x4a +#define sc_kpad_Plus 0x4e +#define sc_kpad_Period 0x53 + +#define sc_A 0x1e +#define sc_B 0x30 +#define sc_C 0x2e +#define sc_D 0x20 +#define sc_E 0x12 +#define sc_F 0x21 +#define sc_G 0x22 +#define sc_H 0x23 +#define sc_I 0x17 +#define sc_J 0x24 +#define sc_K 0x25 +#define sc_L 0x26 +#define sc_M 0x32 +#define sc_N 0x31 +#define sc_O 0x18 +#define sc_P 0x19 +#define sc_Q 0x10 +#define sc_R 0x13 +#define sc_S 0x1f +#define sc_T 0x14 +#define sc_U 0x16 +#define sc_V 0x2f +#define sc_W 0x11 +#define sc_X 0x2d +#define sc_Y 0x15 +#define sc_Z 0x2c + +// Extended scan codes + +#define sc_UpArrow 0xc8 //0x5a +#define sc_DownArrow 0xd0 //0x6a +#define sc_LeftArrow 0xcb //0x6b +#define sc_RightArrow 0xcd //0x6c +#define sc_Insert 0xd2 //0x5e +#define sc_Delete 0xd3 //0x5f +#define sc_Home 0xc7 //0x61 +#define sc_End 0xcf //0x62 +#define sc_PgUp 0xc9 //0x63 +#define sc_PgDn 0xd1 //0x64 +#define sc_RightAlt 0xb8 //0x65 +#define sc_RightControl 0x9d //0x66 +#define sc_kpad_Slash 0xb5 //0x67 +#define sc_kpad_Enter 0x9c //0x68 +#define sc_PrintScreen 0xb7 //0x69 +#define sc_LastScanCode 0x6e + +// Ascii scan codes + +#define asc_Enter 13 +#define asc_Escape 27 +#define asc_BackSpace 8 +#define asc_Tab 9 +#define asc_Space 32 + +#define MAXKEYBOARDSCAN 128 + + +/* +============================================================================= + + GLOBAL VARIABLES + +============================================================================= +*/ + +//extern byte KB_KeyDown[ MAXKEYBOARDSCAN ]; // Keyboard state array +#define KB_KeyDown keystatus +extern kb_scancode KB_LastScan; + + +/* +============================================================================= + + MACROS + +============================================================================= +*/ + +#define KB_GetLastScanCode() ( KB_LastScan ) + +#define KB_SetLastScanCode( scancode ) { KB_LastScan = ( scancode ); } + +#define KB_ClearLastScanCode() { KB_SetLastScanCode( sc_None ); } + +#define KB_KeyPressed( scan ) ( keystatus[ ( scan ) ] != 0 ) + +#define KB_ClearKeyDown( scan ) { keystatus[ ( scan ) ] = FALSE; } + + +/* +============================================================================= + + FUNCTION PROTOTYPES + +============================================================================= +*/ + +boolean KB_KeyWaiting( void ); // Checks if a character is waiting in the keyboard queue +char KB_Getch( void ); // Gets the next keypress +void KB_Addch( char ch ); // Adds key to end of queue +void KB_FlushKeyboardQueue( void ); // Empties the keyboard queue of all waiting characters. +void KB_ClearKeysDown( void ); // Clears all keys down flags. +char * KB_ScanCodeToString( kb_scancode scancode ); // convert scancode into a string +kb_scancode KB_StringToScanCode( char * string ); // convert a string into a scancode +void KB_TurnKeypadOn( void ); // turn the keypad on +void KB_TurnKeypadOff( void ); // turn the keypad off +boolean KB_KeypadActive( void ); // check whether keypad is active +void KB_Startup( void ); +void KB_Shutdown( void ); + +#define KB_FlushKeyBoardQueue KB_FlushKeyboardQueue +#define KB_GetCh KB_Getch + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jmact/mathutil.c b/polymer/eduke32/source/jmact/mathutil.c new file mode 100644 index 000000000..422051cce --- /dev/null +++ b/polymer/eduke32/source/jmact/mathutil.c @@ -0,0 +1,112 @@ +/* + * mathutil.c + * Mathematical utility functions to emulate MACT + * + * by Jonathon Fowler + * + * Since we weren't given the source for MACT386.LIB so I've had to do some + * creative interpolation here. + * + */ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. +*/ +//------------------------------------------------------------------------- + +#include "types.h" + +#if 0 +// Ken's reverse-engineering job +int32 FindDistance2D(int32 x, int32 y) +{ + int32 i; + x = labs(x); + y = labs(y); + if (!x) return(y); + if (!y) return(x); + if (y < x) { i = x; x = y; y = i; } //swap x, y + x += (x>>1); + return ((x>>6)+(x>>2)+y-(y>>5)-(y>>7)); //handle 1 octant +} + +// My abomination +#define square(x) ((x)*(x)) +/* +int32 FindDistance2D(int32 dx, int32 dy) +{ +// return (int32)floor(sqrt((double)(sqr(dx)+sqr(dy)))); + return ksqrt(square(dx)+square(dy)); +} +*/ +int32 FindDistance3D(int32 dx, int32 dy, int32 dz) +{ +// return (int32)floor(sqrt((double)(sqr(dx)+sqr(dy)+sqr(dz)))); + return ksqrt(square(dx)+square(dy)+square(dz)); +} + +#else + +#include + +// This extracted from the Rise of the Triad source RT_UTIL.C :-| + +#define SWAP(a,b) \ + { \ + a=(a)^(b); \ + b=(a)^(b); \ + a=(a)^(b); \ + } + +int32 FindDistance2D(int32 x, int32 y) +{ + int32 t; + + x= abs(x); /* absolute values */ + y= abs(y); + + if (x>1); + + return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6)); +} + + +int32 FindDistance3D(int32 x, int32 y, int32 z) + { + int32 t; + + x= abs(x); /* absolute values */ + y= abs(y); + z= abs(z); + + if (x>4) + (t>>2) + (t>>3)); + } +#endif diff --git a/polymer/eduke32/source/jmact/mathutil.h b/polymer/eduke32/source/jmact/mathutil.h new file mode 100644 index 000000000..c5856c98a --- /dev/null +++ b/polymer/eduke32/source/jmact/mathutil.h @@ -0,0 +1,34 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is NOT part of Duke Nukem 3D version 1.5 - Atomic Edition +However, it is either an older version of a file that is, or is +some test code written during the development of Duke Nukem 3D. +This file is provided purely for educational interest. + +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. + +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +*/ +//------------------------------------------------------------------------- + + +extern int32 FindDistance2D(int32 dx, int32 dy); +extern int32 FindDistance3D(int32 dx, int32 dy, int32 dz); +extern int32 FindDistance3D_HP(int32 dx, int32 dy, int32 dz); +extern int32 ArcTangentAppx(int32 dx, int32 dy); + diff --git a/polymer/eduke32/source/jmact/mouse.c b/polymer/eduke32/source/jmact/mouse.c new file mode 100644 index 000000000..3be081550 --- /dev/null +++ b/polymer/eduke32/source/jmact/mouse.c @@ -0,0 +1,88 @@ +/* + * mouse.c + * MACT library -to- JonoF's Build Port Mouse Glue + * + * by Jonathon Fowler + * + * Since we don't have the source to the MACT library I've had to + * concoct some magic to glue its idea of controllers into that of + * my Build port. + * + */ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. +*/ +//------------------------------------------------------------------------- + +#include "types.h" +#include "mouse.h" +#include "baselayer.h" + + +boolean MOUSE_Init( void ) +{ + initmouse(); + return ((inputdevices & 2) == 2); +} + + +void MOUSE_Shutdown( void ) +{ + uninitmouse(); +} + + +void MOUSE_ShowCursor( void ) +{ +} + + +void MOUSE_HideCursor( void ) +{ +} + + +int32 MOUSE_GetButtons( void ) +{ + int32 buttons; + readmousebstatus(&buttons); + return buttons; +} + + +int32 MOUSE_ClearButton( int32 b ) +{ + return (mouseb &= ~b); +} + + +void MOUSE_GetPosition( int32*x, int32*y ) +{ +} + + +void MOUSE_GetDelta( int32*x, int32*y ) +{ + readmousexy(x,y); +} + + + diff --git a/polymer/eduke32/source/jmact/mouse.h b/polymer/eduke32/source/jmact/mouse.h new file mode 100644 index 000000000..57e376db3 --- /dev/null +++ b/polymer/eduke32/source/jmact/mouse.h @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#ifndef __mouse_h +#define __mouse_h +#ifdef __cplusplus +extern "C" { +#endif + +#define LEFT_MOUSE 1 +#define RIGHT_MOUSE 2 +#define MIDDLE_MOUSE 4 +#define THUMB_MOUSE 8 +#define WHEELDOWN_MOUSE 16 +#define WHEELUP_MOUSE 32 +#define LEFT_MOUSE_PRESSED( button ) ( ( ( button ) & LEFT_MOUSE ) != 0 ) +#define RIGHT_MOUSE_PRESSED( button ) ( ( ( button ) & RIGHT_MOUSE ) != 0 ) +#define MIDDLE_MOUSE_PRESSED( button ) ( ( ( button ) & MIDDLE_MOUSE ) != 0 ) + +boolean MOUSE_Init( void ); +void MOUSE_Shutdown( void ); +void MOUSE_ShowCursor( void ); +void MOUSE_HideCursor( void ); +int32 MOUSE_GetButtons( void ); +int32 MOUSE_ClearButton( int32 b ); +void MOUSE_GetPosition( int32*x, int32*y ); +void MOUSE_GetDelta( int32*x, int32*y ); + +#ifdef __cplusplus +}; +#endif +#endif /* __mouse_h */ diff --git a/polymer/eduke32/source/jmact/scriplib.c b/polymer/eduke32/source/jmact/scriplib.c new file mode 100644 index 000000000..6ce59bf69 --- /dev/null +++ b/polymer/eduke32/source/jmact/scriplib.c @@ -0,0 +1,918 @@ +/* + * scriplib.c + * MACT library Script file parsing and writing + * + * by Jonathon Fowler + * + * Since we weren't given the source for MACT386.LIB so I've had to do some + * creative interpolation here. + * + * This all should be rewritten in a much much cleaner fashion. + * + */ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. +*/ +//------------------------------------------------------------------------- + +#include "compat.h" +#include "types.h" +#include "scriplib.h" +#include "util_lib.h" +#include "file_lib.h" +#include "_scrplib.h" +#include +#include +#include + +#ifdef __WATCOMC__ +#include +#endif + + +static script_t *scriptfiles[MAXSCRIPTFILES]; + + +#define SC(s) scriptfiles[s] + + +int32 SCRIPT_New(void) +{ + int32 i; + + for (i=0; i= MAXSCRIPTFILES) return; + + if (!SC(scripthandle)) return; + + if (SCRIPT(scripthandle,script)) { + while (SCRIPT(scripthandle,script)->nextsection != SCRIPT(scripthandle,script)) { + s = SCRIPT(scripthandle,script)->nextsection; + SCRIPT_FreeSection(SCRIPT(scripthandle,script)); + SafeFree(SCRIPT(scripthandle,script)); + SCRIPT(scripthandle,script) = s; + } + + SafeFree(SCRIPT(scripthandle,script)); + } + + SafeFree(SC(scripthandle)); + SC(scripthandle) = 0; +} + +void SCRIPT_FreeSection(ScriptSectionType * section) +{ + ScriptEntryType *e; + + if (!section) return; + if (!section->entries) return; + + while (section->entries->nextentry != section->entries) { + e = section->entries->nextentry; + SafeFree(section->entries); + section->entries = e; + } + + SafeFree(section->entries); + free(section->name); +} + +#define AllocSection(s) \ + { \ + (s) = SafeMalloc(sizeof(ScriptSectionType)); \ + (s)->name = NULL; \ + (s)->entries = NULL; \ + (s)->lastline = NULL; \ + (s)->nextsection = (s); \ + (s)->prevsection = (s); \ + } +#define AllocEntry(e) \ + { \ + (e) = SafeMalloc(sizeof(ScriptEntryType)); \ + (e)->name = NULL; \ + (e)->value = NULL; \ + (e)->nextentry = (e); \ + (e)->preventry = (e); \ + } + +ScriptSectionType * SCRIPT_SectionExists( int32 scripthandle, char * sectionname ) +{ + ScriptSectionType *s, *ls=NULL; + + if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return NULL; + if (!sectionname) return NULL; + if (!SC(scripthandle)) return NULL; + if (!SCRIPT(scripthandle,script)) return NULL; + + for (s = SCRIPT(scripthandle,script); ls != s; ls=s,s=s->nextsection) + if (!Bstrcasecmp(s->name, sectionname)) return s; + + return NULL; +} + +ScriptSectionType * SCRIPT_AddSection( int32 scripthandle, char * sectionname ) +{ + ScriptSectionType *s,*s2; + + if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return NULL; + if (!sectionname) return NULL; + if (!SC(scripthandle)) return NULL; + + s = SCRIPT_SectionExists(scripthandle, sectionname); + if (s) return s; + + AllocSection(s); + s->name = strdup(sectionname); + if (!SCRIPT(scripthandle,script)) { + SCRIPT(scripthandle,script) = s; + } else { + s2 = SCRIPT(scripthandle,script); + while (s2->nextsection != s2) s2=s2->nextsection; + s2->nextsection = s; + s->prevsection = s2; + } + + return s; +} + +ScriptEntryType * SCRIPT_EntryExists ( ScriptSectionType * section, char * entryname ) +{ + ScriptEntryType *e,*le=NULL; + + if (!section) return NULL; + if (!entryname) return NULL; + if (!section->entries) return NULL; + + for (e = section->entries; le != e; le=e,e=e->nextentry) + if (!Bstrcasecmp(e->name, entryname)) return e; + + return NULL; +} + +void SCRIPT_AddEntry ( int32 scripthandle, char * sectionname, char * entryname, char * entryvalue ) +{ + ScriptSectionType *s; + ScriptEntryType *e,*e2; + + if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return; + if (!sectionname || !entryname || !entryvalue) return; + if (!SC(scripthandle)) return; + +// s = SCRIPT_SectionExists(scripthandle, sectionname); +// if (!s) { + s = SCRIPT_AddSection(scripthandle, sectionname); + if (!s) return; +// } + + e = SCRIPT_EntryExists(s, entryname); + if (!e) { + AllocEntry(e); + e->name = strdup(entryname); + if (!s->entries) { + s->entries = e; + } else { + e2 = s->entries; + while (e2->nextentry != e2) e2=e2->nextentry; + e2->nextentry = e; + e->preventry = e2; + } + } + + if (e->value) free(e->value); + e->value = strdup(entryvalue); +} + + +int32 SCRIPT_ParseBuffer(int32 scripthandle, char *data, int32 length) +{ + char *fence = data + length; + char *dp, *sp, ch=0, lastch=0; + char *currentsection = ""; + char *currententry = NULL; + char *currentvalue = NULL; + enum { + ParsingIdle, + ParsingSectionBegin, + ParsingSectionName, + ParsingEntry, + ParsingValueBegin, + ParsingValue + }; + enum { + ExpectingSection = 1, + ExpectingEntry = 2, + ExpectingAssignment = 4, + ExpectingValue = 8, + ExpectingComment = 16 + }; + int state; + int expect; + int linenum=1; + int rv = 0; +#define SETRV(v) if (v>rv||rv==0) rv=v + + if (!data) return 1; + if (length < 0) return 1; + + dp = sp = data; + state = ParsingIdle; + expect = ExpectingSection | ExpectingEntry; + +#define EATLINE(p) while (length > 0 && *p != '\n' && *p != '\r') { p++; length--; } +#define LETTER() { lastch = ch; ch = *(sp++); length--; } + + while (length > 0) { + switch (state) { + case ParsingIdle: + LETTER(); + switch (ch) { + // whitespace + case ' ': + case '\t': continue; + case '\n': if (lastch == '\r') continue; linenum++; continue; + case '\r': linenum++; continue; + + case ';': + /*case '#':*/ + EATLINE(sp); + continue; + + case '[': if (!(expect & ExpectingSection)) { + // Unexpected section start + printf("Unexpected start of section on line %d.\n", linenum); + SETRV(-1); + EATLINE(sp); + continue; + } else { + state = ParsingSectionBegin; + continue; + } + + default: if (isalpha(ch)) { + if (!(expect & ExpectingEntry)) { + // Unexpected name start + printf("Unexpected entry label on line %d.\n", linenum); + SETRV(-1); + EATLINE(sp); + continue; + } else { + currententry = dp = sp-1; + state = ParsingEntry; + continue; + } + } else { + // Unexpected character + printf("Illegal character (ASCII %d) on line %d.\n", ch, linenum); + SETRV(-1); + EATLINE(sp); + continue; + } + } + + case ParsingSectionBegin: + currentsection = dp = sp; + state = ParsingSectionName; + case ParsingSectionName: + LETTER(); + switch (ch) { + case '\n': + case '\r': // Unexpected newline + printf("Unexpected newline on line %d.\n", linenum); + SETRV(-1); + state = ParsingIdle; + linenum++; + continue; + + case ']': + *(dp) = 0; // Add new section + expect = ExpectingSection | ExpectingEntry; + state = ParsingIdle; + EATLINE(sp); + continue; + + default: + dp++; + continue; + } + + case ParsingEntry: + LETTER(); + switch (ch) { + case ';': + /*case '#':*/ + // unexpected comment + EATLINE(sp); + printf("Unexpected comment on line %d.\n", linenum); + SETRV(-1); + case '\n': + case '\r': + // Unexpected newline + printf("Unexpected newline on line %d.\n", linenum); + SETRV(-1); + expect = ExpectingSection | ExpectingEntry; + state = ParsingIdle; + linenum++; + continue; + + case '=': + // Entry name finished, now for the value + while (*dp == ' ' || *dp == '\t') dp--; + *(++dp) = 0; + state = ParsingValueBegin; + continue; + + default: + dp++; + continue; + } + + case ParsingValueBegin: + currentvalue = dp = sp; + state = ParsingValue; + case ParsingValue: + LETTER(); + switch (ch) { + case '\n': + case '\r': + // value complete, add it using parsed name + while (*dp == ' ' && *dp == '\t') dp--; + *(dp) = 0; + while (*currentvalue == ' ' || *currentvalue == '\t') currentvalue++; + state = ParsingIdle; + linenum++; + + SCRIPT_AddSection(scripthandle,currentsection); + SCRIPT_AddEntry(scripthandle,currentsection,currententry,currentvalue); + continue; + + default: + dp++; + continue; + } + + default: length=0; + continue; + } + } + + if (sp > fence) printf("Stepped outside the fence!\n"); + + return rv; +} + + +//--- + +int32 SCRIPT_Init( char * name ) +{ + int32 h = SCRIPT_New(); + + if (h >= 0) strncpy(SCRIPT(h,scriptfilename), name, 127); + + return h; +} + +void SCRIPT_Free( int32 scripthandle ) +{ + SCRIPT_Delete(scripthandle); +} + +int32 SCRIPT_Parse ( char *data, int32 length, char * name ) +{ + return 0; +} + +int32 SCRIPT_Load ( char * filename ) +{ + int32 s,h,l; + char *b; + + h = SafeOpenRead(filename, filetype_binary); + l = SafeFileLength(h)+1; + b = (char *)SafeMalloc(l); + SafeRead(h,b,l-1); + b[l-1] = '\n'; // JBF 20040111: evil nasty hack to trick my evil nasty parser + SafeClose(h); + + s = SCRIPT_Init(filename); + if (s<0) { + SafeFree(b); + return -1; + } + + SCRIPT_ParseBuffer(s,b,l); + + SafeFree(b); + + return s; +} + +void SCRIPT_Save (int32 scripthandle, char * filename) +{ + char *section, *entry, *value; + int sec, ent, numsect, nument; + FILE *fp; + + + if (!filename) return; + if (!SC(scripthandle)) return; + + fp = fopen(filename, "w"); + if (!fp) return; + + numsect = SCRIPT_NumberSections(scripthandle); + for (sec=0; sec0) fprintf(fp, "\n"); + if (section[0] != 0) + fprintf(fp, "[%s]\n", section); + + nument = SCRIPT_NumberEntries(scripthandle,section); + for (ent=0; entnextsection) c++; + + return c; +} + +char * SCRIPT_Section( int32 scripthandle, int32 which ) +{ + ScriptSectionType *s,*ls=NULL; + + if (!SC(scripthandle)) return ""; + if (!SCRIPT(scripthandle,script)) return ""; + + for (s = SCRIPT(scripthandle,script); which>0 && ls != s; ls=s, s=s->nextsection, which--) ; + + return s->name; +} + +int32 SCRIPT_NumberEntries( int32 scripthandle, char * sectionname ) +{ + ScriptSectionType *s; + ScriptEntryType *e,*le=NULL; + int32 c=0; + + if (!SC(scripthandle)) return 0; + if (!SCRIPT(scripthandle,script)) return 0; + + s = SCRIPT_SectionExists(scripthandle, sectionname); + if (!s) return 0; + + for (e = s->entries; le != e; le=e,e=e->nextentry) c++; + return c; +} + +char * SCRIPT_Entry( int32 scripthandle, char * sectionname, int32 which ) +{ + ScriptSectionType *s; + ScriptEntryType *e,*le=NULL; + + if (!SC(scripthandle)) return 0; + if (!SCRIPT(scripthandle,script)) return 0; + + s = SCRIPT_SectionExists(scripthandle, sectionname); + if (!s) return ""; + + for (e = s->entries; which>0 && le != e; le=e, e=e->nextentry, which--) ; + return e->name; +} + +char * SCRIPT_GetRaw(int32 scripthandle, char * sectionname, char * entryname) +{ + ScriptSectionType *s; + ScriptEntryType *e; + + if (!SC(scripthandle)) return 0; + if (!SCRIPT(scripthandle,script)) return 0; + + s = SCRIPT_SectionExists(scripthandle, sectionname); + e = SCRIPT_EntryExists(s, entryname); + + if (!e) return ""; + return e->value; +} + +boolean SCRIPT_GetString( int32 scripthandle, char * sectionname, char * entryname, char * dest ) +{ + ScriptSectionType *s; + ScriptEntryType *e; + char *p, ch; + int c; + + if (!SC(scripthandle)) return 1; + if (!SCRIPT(scripthandle,script)) return 1; + + s = SCRIPT_SectionExists(scripthandle, sectionname); + e = SCRIPT_EntryExists(s, entryname); + + //dest[0] = 0; + if (!e) return 1; + + p = e->value; + c = 0; + + if (*p == '\"') { + // quoted string + p++; + while ((ch = *(p++))) { + switch (ch) { + case '\\': + ch = *(p++); + switch (ch) { + case 0: return 0; + case 'n': dest[c++] = '\n'; break; + case 'r': dest[c++] = '\r'; break; + case 't': dest[c++] = '\t'; break; + default: dest[c++] = ch; break; + } + break; + case '\"': + dest[c] = 0; + return 0; + default: + dest[c++] = ch; + break; + } + } + } else { + while ((ch = *(p++))) { + if (ch == ' ' || ch == '\t') { dest[c] = 0; break; } + else dest[c++] = ch; + } + } + + return 0; +} + +boolean SCRIPT_GetDoubleString( int32 scripthandle, char * sectionname, char * entryname, char * dest1, char * dest2 ) +{ + ScriptSectionType *s; + ScriptEntryType *e; + char *p, ch; + int c,d=0; + + if (!SC(scripthandle)) return 1; + if (!SCRIPT(scripthandle,script)) return 1; + + s = SCRIPT_SectionExists(scripthandle, sectionname); + e = SCRIPT_EntryExists(s, entryname); + + //dest1[0] = 0; + //dest2[0] = 0; + if (!e) return 1; + + p = e->value; + c = 0; + + if (*p == '\"') { + // quoted string + p++; + while ((ch = *(p++))) { + switch (ch) { + case '\\': + ch = *(p++); + switch (ch) { + case 0: return 0; + case 'n': dest1[c++] = '\n'; break; + case 'r': dest1[c++] = '\r'; break; + case 't': dest1[c++] = '\t'; break; + default: dest1[c++] = ch; break; + } + break; + case '\"': + dest1[c] = 0; + goto breakme; + default: + dest1[c++] = ch; + break; + } + } + if (ch == 0) return 0; + } else { + while ((ch = *(p++))) { + if (ch == ' ' || ch == '\t') { dest1[c] = 0; break; } + else dest1[c++] = ch; + } + } + +breakme: + while (*p == ' ' || *p == '\t') p++; + if (*p == 0) return 0; + + c = 0; + + if (*p == '\"') { + // quoted string + p++; + while ((ch = *(p++))) { + switch (ch) { + case '\\': + ch = *(p++); + switch (ch) { + case 0: return 0; + case 'n': dest2[c++] = '\n'; break; + case 'r': dest2[c++] = '\r'; break; + case 't': dest2[c++] = '\t'; break; + default: dest2[c++] = ch; break; + } + break; + case '\"': + dest2[c] = 0; + return 0; + default: + dest2[c++] = ch; + break; + } + } + } else { + while ((ch = *(p++))) { + if (ch == ' ' || ch == '\t') { dest2[c] = 0; break; } + else dest2[c++] = ch; + } + } + + return 0; +} + +boolean SCRIPT_GetNumber( int32 scripthandle, char * sectionname, char * entryname, int32 * number ) +{ + ScriptSectionType *s; + ScriptEntryType *e; + char *p; + + if (!SC(scripthandle)) return 1; + if (!SCRIPT(scripthandle,script)) return 1; + + s = SCRIPT_SectionExists(scripthandle, sectionname); + e = SCRIPT_EntryExists(s, entryname); + + if (!e) return 1;// *number = 0; + else { + if (e->value[0] == '0' && e->value[1] == 'x') { + // hex + *number = strtol(e->value+2, &p, 16); + if (p == e->value || *p != 0 || *p != ' ' || *p != '\t') return 1; + } else { + // decimal + *number = strtol(e->value, &p, 10); + if (p == e->value || *p != 0 || *p != ' ' || *p != '\t') return 1; + } + } + + return 0; +} + +boolean SCRIPT_GetBoolean( int32 scripthandle, char * sectionname, char * entryname, boolean * boole ) +{ + ScriptSectionType *s; + ScriptEntryType *e; + + if (!SC(scripthandle)) return 1; + if (!SCRIPT(scripthandle,script)) return 1; + + s = SCRIPT_SectionExists(scripthandle, sectionname); + e = SCRIPT_EntryExists(s, entryname); + + if (!e) return 1;// *boole = 0; + else { + if (!Bstrncasecmp(e->value, "true", 4)) *boole = 1; + else if (!Bstrncasecmp(e->value, "false", 5)) *boole = 0; + else if (e->value[0] == '1' && (e->value[1] == ' ' || e->value[1] == '\t' || e->value[1] == 0)) *boole = 1; + else if (e->value[0] == '0' && (e->value[1] == ' ' || e->value[1] == '\t' || e->value[1] == 0)) *boole = 0; + } + + return 0; +} + +boolean SCRIPT_GetDouble( int32 scripthandle, char * sectionname, char * entryname, double * number ) +{ + ScriptSectionType *s; + ScriptEntryType *e; + + if (!SC(scripthandle)) return 1; + if (!SCRIPT(scripthandle,script)) return 1; + + s = SCRIPT_SectionExists(scripthandle, sectionname); + e = SCRIPT_EntryExists(s, entryname); + + if (!e) return 1;// *number = 0.0; + else { + } + + return 0; +} + +void SCRIPT_PutComment( int32 scripthandle, char * sectionname, char * comment ) +{ +} + +void SCRIPT_PutEOL( int32 scripthandle, char * sectionname ) +{ +} + +void SCRIPT_PutMultiComment + ( + int32 scripthandle, + char * sectionname, + char * comment, + ... + ) +{ +} + +void SCRIPT_PutSection( int32 scripthandle, char * sectionname ) +{ + SCRIPT_AddSection(scripthandle, sectionname); +} + +void SCRIPT_PutRaw + ( + int32 scripthandle, + char * sectionname, + char * entryname, + char * raw + ) +{ + SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw); +} + +void SCRIPT_PutString + ( + int32 scripthandle, + char * sectionname, + char * entryname, + char * string + ) +{ + char *raw,*q,*p; + int len = 3; + if (!string) string = ""; + + for (q=string; *q; q++) { + if (*q == '\r' || *q == '\n' || *q == '\t' || *q == '\\' || *q == '"') len+=2; + else if (*q >= ' ') len++; + } + p = raw = Bmalloc(len); + *(p++) = '"'; + for (q=string; *q; q++) { + if (*q == '\r') { *(p++) = '\\'; *(p++) = 'r'; } + else if (*q == '\n') { *(p++) = '\\'; *(p++) = 'n'; } + else if (*q == '\t') { *(p++) = '\\'; *(p++) = 't'; } + else if (*q == '\\' || *q == '"') { *(p++) = '\\'; *(p++) = *q; } + else if (*q >= ' ') *(p++) = *q; + } + *(p++) = '"'; + *p=0; + + SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw); + Bfree(raw); +} + +void SCRIPT_PutDoubleString + ( + int32 scripthandle, + char * sectionname, + char * entryname, + char * string1, + char * string2 + ) +{ + char *raw,*q,*p; + int len = 6; + if (!string1) string1 = ""; + if (!string2) string2 = ""; + + for (q=string1; *q; q++) { + if (*q == '\r' || *q == '\n' || *q == '\t' || *q == '\\' || *q == '"') len+=2; + else if (*q >= ' ') len++; + } + for (q=string2; *q; q++) { + if (*q == '\r' || *q == '\n' || *q == '\t' || *q == '\\' || *q == '"') len+=2; + else if (*q >= ' ') len++; + } + p = raw = Bmalloc(len); + *(p++) = '"'; + for (q=string1; *q; q++) { + if (*q == '\r') { *(p++) = '\\'; *(p++) = 'r'; } + else if (*q == '\n') { *(p++) = '\\'; *(p++) = 'n'; } + else if (*q == '\t') { *(p++) = '\\'; *(p++) = 't'; } + else if (*q == '\\' || *q == '"') { *(p++) = '\\'; *(p++) = *q; } + else if (*q >= ' ') *(p++) = *q; + } + *(p++) = '"'; + *(p++) = ' '; + *(p++) = '"'; + for (q=string2; *q; q++) { + if (*q == '\r') { *(p++) = '\\'; *(p++) = 'r'; } + else if (*q == '\n') { *(p++) = '\\'; *(p++) = 'n'; } + else if (*q == '\t') { *(p++) = '\\'; *(p++) = 't'; } + else if (*q == '\\' || *q == '"') { *(p++) = '\\'; *(p++) = *q; } + else if (*q >= ' ') *(p++) = *q; + } + *(p++) = '"'; + *p=0; + + SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw); + Bfree(raw); +} + +void SCRIPT_PutNumber + ( + int32 scripthandle, + char * sectionname, + char * entryname, + int32 number, + boolean hexadecimal, + boolean defaultvalue + ) +{ + char raw[64]; + + if (hexadecimal) sprintf(raw, "0x%lX", number); + else sprintf(raw, "%ld", number); + + SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw); +} + +void SCRIPT_PutBoolean + ( + int32 scripthandle, + char * sectionname, + char * entryname, + boolean boole + ) +{ + char raw[2] = "0"; + + if (boole) raw[0] = '1'; + + SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw); +} + +void SCRIPT_PutDouble + ( + int32 scripthandle, + char * sectionname, + char * entryname, + double number, + boolean defaultvalue + ) +{ + char raw[64]; + + sprintf(raw, "%g", number); + + SCRIPT_AddEntry(scripthandle, sectionname, entryname, raw); +} + diff --git a/polymer/eduke32/source/jmact/scriplib.h b/polymer/eduke32/source/jmact/scriplib.h new file mode 100644 index 000000000..ab8d1b7e9 --- /dev/null +++ b/polymer/eduke32/source/jmact/scriplib.h @@ -0,0 +1,355 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +*/ +//------------------------------------------------------------------------- + +// scriplib.h + +#ifndef _scriplib_public +#define _scriplib_public +#ifdef __cplusplus +extern "C" { +#endif + +/* +============== += += SCRIPT_Init += +============== +*/ +int32 SCRIPT_Init( char * name ); + + +/* +============== += += SCRIPT_Free += +============== +*/ +void SCRIPT_Free( int32 scripthandle ); + +/* +============== += += SCRIPT_Parse += +============== +*/ + +int32 SCRIPT_Parse ( char *data, int32 length, char * name ); + + +/* +============== += += SCRIPT_Load += +============== +*/ + +int32 SCRIPT_Load ( char * filename ); + +/* +============== += += SCRIPT_Save += +============== +*/ +void SCRIPT_Save (int32 scripthandle, char * filename); + + +/* +============== += += SCRIPT_NumberSections += +============== +*/ + +int32 SCRIPT_NumberSections( int32 scripthandle ); + +/* +============== += += SCRIPT_Section += +============== +*/ + +char * SCRIPT_Section( int32 scripthandle, int32 which ); + +/* +============== += += SCRIPT_NumberEntries += +============== +*/ + +int32 SCRIPT_NumberEntries( int32 scripthandle, char * sectionname ); + +/* +============== += += SCRIPT_Entry += +============== +*/ + +char * SCRIPT_Entry( int32 scripthandle, char * sectionname, int32 which ); + + +/* +============== += += SCRIPT_GetRaw += +============== +*/ +char * SCRIPT_GetRaw(int32 scripthandle, char * sectionname, char * entryname); + +/* +============== += += SCRIPT_GetString += +============== +*/ +boolean SCRIPT_GetString + ( + int32 scripthandle, + char * sectionname, + char * entryname, + char * dest + ); + +/* +============== += += SCRIPT_GetDoubleString += +============== +*/ +boolean SCRIPT_GetDoubleString + ( + int32 scripthandle, + char * sectionname, + char * entryname, + char * dest1, + char * dest2 + ); + +/* +============== += += SCRIPT_GetNumber += +============== +*/ +boolean SCRIPT_GetNumber + ( + int32 scripthandle, + char * sectionname, + char * entryname, + int32 * number + ); + +/* +============== += += SCRIPT_GetBoolean += +============== +*/ +boolean SCRIPT_GetBoolean + ( + int32 scripthandle, + char * sectionname, + char * entryname, + boolean * boole + ); + +/* +============== += += SCRIPT_GetDouble += +============== +*/ + +boolean SCRIPT_GetDouble + ( + int32 scripthandle, + char * sectionname, + char * entryname, + double * number + ); + + + +/* +============== += += SCRIPT_PutComment += +============== +*/ +void SCRIPT_PutComment( int32 scripthandle, char * sectionname, char * comment ); + +/* +============== += += SCRIPT_PutEOL += +============== +*/ +void SCRIPT_PutEOL( int32 scripthandle, char * sectionname ); + +/* +============== += += SCRIPT_PutMultiComment += +============== +*/ +void SCRIPT_PutMultiComment + ( + int32 scripthandle, + char * sectionname, + char * comment, + ... + ); + +/* +============== += += SCRIPT_PutSection += +============== +*/ +void SCRIPT_PutSection( int32 scripthandle, char * sectionname ); + +/* +============== += += SCRIPT_PutRaw += +============== +*/ +void SCRIPT_PutRaw + ( + int32 scripthandle, + char * sectionname, + char * entryname, + char * raw + ); + +/* +============== += += SCRIPT_PutString += +============== +*/ +void SCRIPT_PutString + ( + int32 scripthandle, + char * sectionname, + char * entryname, + char * string + ); + +/* +============== += += SCRIPT_PutDoubleString += +============== +*/ +void SCRIPT_PutDoubleString + ( + int32 scripthandle, + char * sectionname, + char * entryname, + char * string1, + char * string2 + ); + +/* +============== += += SCRIPT_PutNumber += +============== +*/ +void SCRIPT_PutNumber + ( + int32 scripthandle, + char * sectionname, + char * entryname, + int32 number, + boolean hexadecimal, + boolean defaultvalue + ); + +/* +============== += += SCRIPT_PutBoolean += +============== +*/ +void SCRIPT_PutBoolean + ( + int32 scripthandle, + char * sectionname, + char * entryname, + boolean boole + ); + +/* +============== += += SCRIPT_PutDouble += +============== +*/ + +void SCRIPT_PutDouble + ( + int32 scripthandle, + char * sectionname, + char * entryname, + double number, + boolean defaultvalue + ); + + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jmact/types.h b/polymer/eduke32/source/jmact/types.h new file mode 100644 index 000000000..98e24485a --- /dev/null +++ b/polymer/eduke32/source/jmact/types.h @@ -0,0 +1,112 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#ifndef _types_public +#define _types_public +#ifdef __cplusplus +extern "C" { +#endif + + +//*************************************************************************** +// +// Global Data Types (For portability) +// +//*************************************************************************** + +typedef unsigned char uint8; +typedef uint8 byte; +typedef signed char int8; + +typedef unsigned short int uint16; +typedef uint16 word; +typedef short int int16; + +typedef unsigned long uint32; +typedef long int32; +typedef uint32 dword; + +typedef int32 fixed; +typedef int32 boolean; +typedef float float32; +typedef double float64; +//typedef long double float128; +typedef float64 appfloat; + +#define MAXINT32 0x7fffffff +#define MININT32 -0x80000000 +#define MAXUINT32 0xffffffff +#define MINUINT32 0 + +#define MAXINT16 0x7fff +#define MININT16 -0x8000 +#define MAXUINT16 0xffff +#define MINUINT16 0 + +//*************************************************************************** +// +// boolean values +// +//*************************************************************************** + +#define true ( 1 == 1 ) +#define false ( ! true ) + +#ifndef TRUE + #define TRUE ( 1 == 1 ) + #define FALSE ( !TRUE ) +#endif + +//*************************************************************************** +// +// BYTE ACCESS MACROS +// +//*************************************************************************** + +// WORD macros +#define Int16_HighByte( x ) ( (uint8) ((x)>>8) ) +#define Int16_LowByte( x ) ( (uint8) ((x)&0xff) ) + +// DWORD macros +#define Int32_4Byte( x ) ( (uint8) ((x)>>24)&0xff ) +#define Int32_3Byte( x ) ( (uint8) (((x)>>16)&0xff) ) +#define Int32_2Byte( x ) ( (uint8) (((x)>>8)&0xff) ) +#define Int32_1Byte( x ) ( (uint8) ((x)&0xff) ) + +#ifdef __WATCOMC__ +# ifndef strcasecmp +# define strcasecmp stricmp +# endif +# ifndef strncasecmp +# define strncasecmp strnicmp +# endif +#endif + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/jmact/util_lib.c b/polymer/eduke32/source/jmact/util_lib.c new file mode 100644 index 000000000..42848d4d8 --- /dev/null +++ b/polymer/eduke32/source/jmact/util_lib.c @@ -0,0 +1,153 @@ +/* + * util_lib.c + * Utility functions to emulate MACT + * + * by Jonathon Fowler + * + * Since we weren't given the source for MACT386.LIB so I've had to do some + * creative interpolation here. + * + */ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. +*/ +//------------------------------------------------------------------------- + +#include "compat.h" +#include "types.h" +#include "util_lib.h" +#include "baselayer.h" + +//#define MOTOROLA + + +static void (*ShutDown)(void) = NULL; // this is defined by whoever links us + + +void RegisterShutdownFunction( void (* sh) (void) ) +{ + ShutDown = sh; +} + +#ifndef RENDERTYPEWIN +void Error(char *error, ...) +{ + va_list va; + + if (ShutDown) ShutDown(); + + if (error) { + va_start(va, error); + vprintf(error, va); + va_end(va); + printf("\n\n"); + } + + exit((error != NULL)); +} +#endif + +char CheckParm(char *check) +{ + int c; + + for (c=1;c<_buildargc;c++) { + if (_buildargv[c][0] == '/' || _buildargv[c][0] == '-') + if (!Bstrcasecmp(&_buildargv[c][1], check)) return c; + } + + return 0; +} + +void *SafeMalloc (int32 size) +{ + void *p; + + p = malloc(size); + if (!p) Error("SafeMalloc failure for %d bytes",size); + + return p; +} + +void SafeFree (void * ptr) +{ + if (!ptr) Error("Tried to deallocate NULL pointer."); + free(ptr); +} + +void SafeRealloc (void ** ptr, int32 newsize) +{ + void *p; + + p = realloc(*ptr, newsize); + if (!p) Error("SafeRealloc failure for %d bytes",newsize); + + *ptr = p; +} + +int32 ParseHex (char *hex) +{ + return strtol(hex, NULL, 16); +} + +int32 ParseNum (char *str) +{ + return strtol(str, NULL, 10); +} + +int16 MotoShort (int16 l) +{ +#if B_LITTLE_ENDIAN != 0 + return l; +#else + return ((l & 0x00ff) << 8) | ((l & 0xff00) >> 8); +#endif +} + +int16 IntelShort (int16 l) +{ +#if B_BIG_ENDIAN != 0 + return ((l & 0x00ff) << 8) | ((l & 0xff00) >> 8); +#else + return l; +#endif +} + +int32 MotoLong (int32 l) +{ +#if B_LITTLE_ENDIAN != 0 + return l; +#else + int32 t = ((l & 0x00ff00ffl) << 8) | ((l & 0xff00ff00l) >> 8); + return ((t & 0x0000ffffl) << 16) | ((t & 0xffff0000l) >> 16); +#endif +} + +int32 IntelLong (int32 l) +{ +#if B_BIG_ENDIAN != 0 + int32 t = ((l & 0x00ff00ffl) << 8) | ((l & 0xff00ff00l) >> 8); + return ((t & 0x0000ffffl) << 16) | ((t & 0xffff0000l) >> 16); +#else + return l; +#endif +} + diff --git a/polymer/eduke32/source/jmact/util_lib.h b/polymer/eduke32/source/jmact/util_lib.h new file mode 100644 index 000000000..8e1e631c9 --- /dev/null +++ b/polymer/eduke32/source/jmact/util_lib.h @@ -0,0 +1,67 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +//*************************************************************************** +// +// UTIL_LIB.C - various utils +// +//*************************************************************************** + +#ifndef _util_lib_public +#define _util_lib_public +#ifdef __cplusplus +extern "C" { +#endif + +#if RENDERTYPEWIN +#include "winlayer.h" +#define _argc _buildargc +#define _argv _buildargv +#endif + +void RegisterShutdownFunction( void (* sh) (void) ); +void Error (char *error, ...); + +char CheckParm (char *check); + +void *SafeMalloc (int32 size); +int32 SafeMallocSize (void * ptr); +void SafeFree (void * ptr); +void SafeRealloc (void ** ptr, int32 newsize); +int32 ParseHex (char *hex); +int32 ParseNum (char *str); +int16 MotoShort (int16 l); +int16 IntelShort (int16 l); +int32 MotoLong (int32 l); +int32 IntelLong (int32 l); + +void HeapSort(char * base, int32 nel, int32 width, int32 (*compare)(), void (*switcher)()); + +#ifdef __cplusplus +}; +#endif +#endif diff --git a/polymer/eduke32/source/keys.h b/polymer/eduke32/source/keys.h new file mode 100644 index 000000000..fbf20155e --- /dev/null +++ b/polymer/eduke32/source/keys.h @@ -0,0 +1,135 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1997, 2005 - 3D Realms Entertainment + +This file is part of Shadow Warrior version 1.2 + +Shadow Warrior 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: 1997 - Frank Maddin and Jim Norwood +Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms +*/ +//------------------------------------------------------------------------- + +#ifndef KEYS_H + +#define KEYS_H + + #define NUM_CODES 128 + + #define ESC 0x1B + #define ENTER 0x0D + + #define KEYSC_ESC 1 + #define KEYSC_1 2 + #define KEYSC_2 3 + #define KEYSC_3 4 + #define KEYSC_4 5 + #define KEYSC_5 6 + #define KEYSC_6 7 + #define KEYSC_7 8 + #define KEYSC_8 9 + #define KEYSC_9 10 + #define KEYSC_0 11 + #define KEYSC_DASH 12 + #define KEYSC_EQUAL 13 + + #define KEYSC_BS 14 + #define KEYSC_TAB 15 + #define KEYSC_Q 16 + #define KEYSC_W 17 + #define KEYSC_E 18 + #define KEYSC_R 19 + #define KEYSC_T 20 + #define KEYSC_Y 21 + #define KEYSC_U 22 + #define KEYSC_I 23 + #define KEYSC_O 24 + #define KEYSC_P 25 + #define KEYSC_LBRACK 26 + #define KEYSC_RBRACK 27 + #define KEYSC_ENTER 28 + + #define KEYSC_CTRL 29 + #define KEYSC_A 30 + #define KEYSC_S 31 + #define KEYSC_D 32 + #define KEYSC_F 33 + #define KEYSC_G 34 + #define KEYSC_H 35 + #define KEYSC_J 36 + #define KEYSC_K 37 + #define KEYSC_L 38 + #define KEYSC_SEMI 39 + #define KEYSC_QUOTE 40 + #define KEYSC_BQUOTE 41 + #define KEYSC_TILDE 41 + + #define KEYSC_LSHIFT 42 + #define KEYSC_BSLASH 43 + #define KEYSC_Z 44 + #define KEYSC_X 45 + #define KEYSC_C 46 + #define KEYSC_V 47 + #define KEYSC_B 48 + #define KEYSC_N 49 + #define KEYSC_M 50 + #define KEYSC_COMMA 51 + #define KEYSC_PERIOD 52 + #define KEYSC_SLASH 53 + #define KEYSC_RSHIFT 54 + #define KEYSC_STAR 55 + + #define KEYSC_ALT 56 + #define KEYSC_SPACE 57 + #define KEYSC_CAPS 58 + + #define KEYSC_F1 59 + #define KEYSC_F2 60 + #define KEYSC_F3 61 + #define KEYSC_F4 62 + #define KEYSC_F5 63 + #define KEYSC_F6 64 + #define KEYSC_F7 65 + #define KEYSC_F8 66 + #define KEYSC_F9 67 + #define KEYSC_F10 68 + + #define KEYSC_F11 0x57 + #define KEYSC_F12 0x58 + + #define KEYSC_NUM 69 + #define KEYSC_SCROLL 70 + + #define KEYSC_HOME 71 + #define KEYSC_UP 72 + #define KEYSC_PGUP 73 + #define KEYSC_GMINUS 74 + #define KEYSC_LEFT 75 + #define KEYSC_KP5 76 + #define KEYSC_RIGHT 77 + #define KEYSC_GPLUS 78 + #define KEYSC_END 79 + #define KEYSC_DOWN 80 + #define KEYSC_PGDN 81 + #define KEYSC_INS 82 + #define KEYSC_DEL 83 + + #define asc_Esc 27 + #define asc_Enter 13 + #define asc_Space 32 + +#endif diff --git a/polymer/eduke32/source/mapster32.h b/polymer/eduke32/source/mapster32.h new file mode 100644 index 000000000..2692b60b5 --- /dev/null +++ b/polymer/eduke32/source/mapster32.h @@ -0,0 +1,163 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - Richard Gobeille + +This file is part of Mapster32 + +Mapster32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#define TICSPERFRAME 3 + +// #define VULGARITY + +char *defsfilename = "duke3d.def"; + +extern char keystatus[]; +extern short defaultspritecstat; +extern long posx, posy, posz, horiz, qsetmode; +extern short ang, cursectnum; +extern short ceilingheinum, floorheinum; +extern char names[MAXTILES][25]; + +extern long ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d; + +extern long zmode, kensplayerheight, zlock; + +extern short editstatus, searchit; +extern long searchx, searchy, osearchx, osearchy; //search input +extern short searchsector, searchwall, searchstat; //search output + +extern short temppicnum, tempcstat, templotag, temphitag, tempextra; +extern char tempshade, temppal, tempvis, tempxrepeat, tempyrepeat, somethingintab; + +static long ototalclock = 0, clockval[16], clockcnt = 0; + +#define NUMOPTIONS 9 +#define NUMKEYS 19 + +char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0,0}; +char keys[NUMBUILDKEYS] = + { + 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, + 0x1e,0x2c,0xd1,0xc9,0x47,0x49, + 0x9c,0x1c,0xd,0xc,0xf,0x45 + }; + +int nextvoxid = 0; + +extern long whitecol; +extern char vgapal16[4*256]; +extern void AutoAlignWalls(long nWall0, long ply); +extern char changechar(char dachar, long dadir, char smooshyalign, char boundcheck); +extern void _printmessage16(char name[82]); +extern void updatenumsprites(void); + +extern long lastpm16time, synctics; +extern long halfxdim16, midydim16, zoom; +extern void fixrepeats(short i); + +char autospritehelp=0,autosecthelp=0; +static char pskysearch[MAXSECTORS]; +short MinRate=24, MinD=3; +long xoldtimerhandler, lastmessagetime; + +static char tempbuf[1024]; //1024 +static int numsprite[MAXSPRITES]; +static int multisprite[MAXSPRITES]; +static char lo[32]; +char levelname[255]; +static short curwall=0,curwallnum=0; +static short cursearchsprite=0,cursearchspritenum=0,cursector_lotag=0,cursectornum=0; +static short search_lotag=0,search_hitag=0; +static char wallsprite=0; +static char helpon=0; +//static char onwater=0; +static char onnames=4; +static char usedcount=1; +static short cursprite; +long mousxplc,mousyplc; +long ppointhighlight; +static int counter=0; +char nosprites=0,purpleon=0,skill=4; +char framerateon=1,tabgraphic=2,shadepreview=0,autosave=1; + + +static char sidemode=0; +extern long vel, svel, hvel, angvel; +long xvel, yvel, timoff; + +void SearchSectorsForward(); +void SearchSectorsBackward(); +void SpriteName(short spritenum, char *lo2); +int ActorMem(long i); +void PrintStatus(char *string,int num,char x,char y,char color); +void SetBOSS1Palette(); +void SetSLIMEPalette(); +void SetWATERPalette(); +void SetGAMEPalette(); +void kensetpalette(char *vgapal); + +extern short grid; + +extern void EditSpriteData(short spritenum); +extern void EditWallData(short wallnum); +extern void EditSectorData(short sectnum); + +char GAMEpalette[768]; +char WATERpalette[768]; +char SLIMEpalette[768]; +char TITLEpalette[768]; +char REALMSpalette[768]; +char BOSS1palette[768]; + +char num_tables; + +int updownunits=1024; +extern short highlightsector[MAXSECTORS], highlightsectorcnt; +extern short highlight[MAXWALLS]; +extern short pointhighlight, linehighlight, highlightcnt; +extern short asksave; + +char getmessage[162], getmessageleng; +long getmessagetimeoff, charsperline; +extern long startposx, startposy, startposz; +extern short startang, startsectnum; + +long autosavetimer; +extern long numsprites; +extern char spritecol2d[MAXTILES][2]; +extern char custom2dcolors; +extern char mlook; + +int intro=0; +extern long frameplace, ydim16, halfxdim16, midydim16, zoom; +extern char pow2char[8]; + +static int acurpalette=0; + +extern void showsectordata(short sectnum); +extern void showwalldata(short wallnum); +extern void showspritedata(short spritenum); +extern long checksectorpointer(short i, short sectnum); + +extern double msens; + +void ContextHelp(short spritenum); +void ResetKeys(); + +extern void clearfilenames(void), fixspritesectors(void); + #define KEY_PRESSED(sc) KB_KeyPressed((sc)) diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c new file mode 100644 index 000000000..4e7b24bb2 --- /dev/null +++ b/polymer/eduke32/source/menus.c @@ -0,0 +1,4043 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "duke3d.h" +#include "mouse.h" +#include "osd.h" +#include + +extern char inputloc; +extern int recfilep; +//extern char vgacompatible; +short probey=0,lastprobey=0,last_menu,globalskillsound=-1; +short sh,onbar,buttonstat,deletespot; +short last_zero,last_fifty,last_onehundred,last_threehundred = 0; + +static char fileselect = 1, menunamecnt, menuname[256][64], curpath[80], menupath[80]; + +static CACHE1D_FIND_REC *finddirs=NULL, *findfiles=NULL, *finddirshigh=NULL, *findfileshigh=NULL; +static int numdirs=0, numfiles=0; +static int currentlist=0; + +static int function, whichkey; +static int changesmade, newvidmode, curvidmode, newfullscreen; +static int vidsets[16] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 }, curvidset, newvidset = 0; + +static char *mousebuttonnames[] = { "Left", "Right", "Middle", "Thumb", "Wheel Down", "Wheel Up" }; + +void cmenu(short cm) +{ + current_menu = cm; + + if( (cm >= 1000 && cm <= 1009) ) + return; + + if( cm == 0 ) + probey = last_zero; + else if(cm == 50) + probey = last_fifty; + else if(cm == 100) + probey = last_onehundred; + else if(cm >= 300 && cm < 400) + probey = last_threehundred; + else if(cm == 110) + probey = 1; + else probey = 0; + lastprobey = -1; +} + +void savetemp(char *fn,long daptr,long dasiz) +{ + FILE *fp; + + if ((fp = fopen(fn,"wb")) == (FILE *)NULL) + return; + + fwrite((char *)daptr,dasiz,1,fp); + + fclose(fp); +} + +void getangplayers(short snum) +{ + short i,a; + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if(i != snum) + { + a = ps[snum].ang+getangle(ps[i].posx-ps[snum].posx,ps[i].posy-ps[snum].posy); + a = a-1024; + rotatesprite( + (320<<15) + (((sintable[(a+512)&2047])>>7)<<15), + (320<<15) - (((sintable[a&2047])>>8)<<15), + klabs(sintable[((a>>1)+768)&2047]<<2),0,APLAYER,0,ps[i].palookup,0,0,0,xdim-1,ydim-1); + } + } +} + +#define LMB (buttonstat&1) +#define RMB (buttonstat&2) + +ControlInfo minfo; + +long mi; + +static int probe_(int type,int x,int y,int i,int n) +{ + short centre, s; + + s = 1+(CONTROL_GetMouseSensitivity()>>4); + + if( ControllerType == 1 && CONTROL_MousePresent ) + { + CONTROL_GetInput( &minfo ); + mi += minfo.dz; + } + + else minfo.dz = minfo.dyaw = 0; + + if( x == (320>>1) ) + centre = 320>>2; + else centre = 0; + + if(!buttonstat) + { + if( KB_KeyPressed( sc_UpArrow ) || KB_KeyPressed( sc_PgUp ) || KB_KeyPressed( sc_kpad_8 ) || + mi < -8192 ) + { + mi = 0; + KB_ClearKeyDown( sc_UpArrow ); + KB_ClearKeyDown( sc_kpad_8 ); + KB_ClearKeyDown( sc_PgUp ); + sound(KICK_HIT); + + probey--; + if(probey < 0) probey = n-1; + minfo.dz = 0; + } + if( KB_KeyPressed( sc_DownArrow ) || KB_KeyPressed( sc_PgDn ) || KB_KeyPressed( sc_kpad_2 ) + || mi > 8192 ) + { + mi = 0; + KB_ClearKeyDown( sc_DownArrow ); + KB_ClearKeyDown( sc_kpad_2 ); + KB_ClearKeyDown( sc_PgDn ); + sound(KICK_HIT); + probey++; + minfo.dz = 0; + } + } + + if(probey >= n) + probey = 0; + + if(centre) + { + // rotatesprite(((320>>1)+(centre)+54)<<16,(y+(probey*i)-4)<<16,65536L,0,SPINNINGNUKEICON+6-((6+(totalclock>>3))%7),sh,0,10,0,0,xdim-1,ydim-1); + // rotatesprite(((320>>1)-(centre)-54)<<16,(y+(probey*i)-4)<<16,65536L,0,SPINNINGNUKEICON+((totalclock>>3)%7),sh,0,10,0,0,xdim-1,ydim-1); + + rotatesprite(((320>>1)+(centre>>1)+70)<<16,(y+(probey*i)-4)<<16,65536L>>type,0,SPINNINGNUKEICON+6-((6+(totalclock>>3))%7),sh,0,10,0,0,xdim-1,ydim-1); + rotatesprite(((320>>1)-(centre>>1)-70)<<16,(y+(probey*i)-4)<<16,65536L>>type,0,SPINNINGNUKEICON+((totalclock>>3)%7),sh,0,10,0,0,xdim-1,ydim-1); + } + else + rotatesprite((x<<16)-((tilesizx[BIGFNTCURSOR]-4)<<(16-type)),(y+(probey*i)-(4>>type))<<16,65536L>>type,0,SPINNINGNUKEICON+(((totalclock>>3))%7),sh,0,10,0,0,xdim-1,ydim-1); + + if( KB_KeyPressed(sc_Space) || KB_KeyPressed( sc_kpad_Enter ) || KB_KeyPressed( sc_Enter ) || (LMB && !onbar) ) + { + if(current_menu != 110) + sound(PISTOL_BODYHIT); + KB_ClearKeyDown( sc_Enter ); + KB_ClearKeyDown( sc_Space ); + KB_ClearKeyDown( sc_kpad_Enter ); + return(probey); + } + else if( KB_KeyPressed( sc_Escape ) || (RMB) ) + { + onbar = 0; + KB_ClearKeyDown( sc_Escape ); + sound(EXITMENUSOUND); + return(-1); + } + else + { + if(onbar == 0) return(-probey-2); + if ( KB_KeyPressed( sc_LeftArrow ) || KB_KeyPressed( sc_kpad_4 ) || ((buttonstat&1) && minfo.dyaw < -128 ) ) + return(probey); + else if ( KB_KeyPressed( sc_RightArrow ) || KB_KeyPressed( sc_kpad_6 ) || ((buttonstat&1) && minfo.dyaw > 128 ) ) + return(probey); + else return(-probey-2); + } +} +int probe(int x,int y,int i,int n) { return probe_(0,x,y,i,n); } +int probesm(int x,int y,int i,int n) { return probe_(1,x,y,i,n); } + +int menutext(int x,int y,short s,short p,char *t) +{ + short i, ac, centre; + + y -= 12; + + i = centre = 0; + + if( x == (320>>1) ) + { + while( *(t+i) ) + { + if(*(t+i) == ' ') + { + centre += 5; + i++; + continue; + } + ac = 0; + if(*(t+i) >= '0' && *(t+i) <= '9') + ac = *(t+i) - '0' + BIGALPHANUM-10; + else if(*(t+i) >= 'a' && *(t+i) <= 'z') + ac = toupper(*(t+i)) - 'A' + BIGALPHANUM; + else if(*(t+i) >= 'A' && *(t+i) <= 'Z') + ac = *(t+i) - 'A' + BIGALPHANUM; + else switch(*(t+i)) + { + case '-': + ac = BIGALPHANUM-11; + break; + case '.': + ac = BIGPERIOD; + break; + case '\'': + ac = BIGAPPOS; + break; + case ',': + ac = BIGCOMMA; + break; + case '!': + ac = BIGX; + break; + case '?': + ac = BIGQ; + break; + case ';': + ac = BIGSEMI; + break; + case ':': + ac = BIGSEMI; + break; + default: + centre += 5; + i++; + continue; + } + + centre += tilesizx[ac]-1; + i++; + } + } + + if(centre) + x = (320-centre-10)>>1; + + while(*t) + { + if(*t == ' ') {x+=5;t++;continue;} + ac = 0; + if(*t >= '0' && *t <= '9') + ac = *t - '0' + BIGALPHANUM-10; + else if(*t >= 'a' && *t <= 'z') + ac = toupper(*t) - 'A' + BIGALPHANUM; + else if(*t >= 'A' && *t <= 'Z') + ac = *t - 'A' + BIGALPHANUM; + else switch(*t) + { + case '-': + ac = BIGALPHANUM-11; + break; + case '.': + ac = BIGPERIOD; + break; + case ',': + ac = BIGCOMMA; + break; + case '!': + ac = BIGX; + break; + case '\'': + ac = BIGAPPOS; + break; + case '?': + ac = BIGQ; + break; + case ';': + ac = BIGSEMI; + break; + case ':': + ac = BIGCOLIN; + break; + default: + x += 5; + t++; + continue; + } + + rotatesprite(x<<16,y<<16,65536L,0,ac,s,p,10+16,0,0,xdim-1,ydim-1); + + x += tilesizx[ac]; + t++; + } + return (x); +} + +static void bar_(int type, int x,int y,short *p,short dainc,char damodify,short s, short pa) +{ + short xloc; + char rev; + + if(dainc < 0) { dainc = -dainc; rev = 1; } + else rev = 0; + y-=2; + + if(damodify) + { + if(rev == 0) + { + if( *p > 0 && (KB_KeyPressed( sc_LeftArrow ) || KB_KeyPressed( sc_kpad_4 ) || ((buttonstat&1) && minfo.dyaw < -256 ) ) ) // && onbar) ) + { + KB_ClearKeyDown( sc_LeftArrow ); + KB_ClearKeyDown( sc_kpad_4 ); + + *p -= dainc; + if(*p < 0) + *p = 0; + sound(KICK_HIT); + } + if( *p < 63 && (KB_KeyPressed( sc_RightArrow ) || KB_KeyPressed( sc_kpad_6 ) || ((buttonstat&1) && minfo.dyaw > 256 ) ) )//&& onbar) ) + { + KB_ClearKeyDown( sc_RightArrow ); + KB_ClearKeyDown( sc_kpad_6 ); + + *p += dainc; + if(*p > 63) + *p = 63; + sound(KICK_HIT); + } + } + else + { + if( *p > 0 && (KB_KeyPressed( sc_RightArrow ) || KB_KeyPressed( sc_kpad_6 ) || ((buttonstat&1) && minfo.dyaw > 256 ) ) )//&& onbar) ) + { + KB_ClearKeyDown( sc_RightArrow ); + KB_ClearKeyDown( sc_kpad_6 ); + + *p -= dainc; + if(*p < 0) + *p = 0; + sound(KICK_HIT); + } + if( *p < 64 && (KB_KeyPressed( sc_LeftArrow ) || KB_KeyPressed( sc_kpad_4 ) || ((buttonstat&1) && minfo.dyaw < -256 ) ) ) // && onbar) ) + { + KB_ClearKeyDown( sc_LeftArrow ); + KB_ClearKeyDown( sc_kpad_4 ); + + *p += dainc; + if(*p > 64) + *p = 64; + sound(KICK_HIT); + } + } + } + + xloc = *p; + + rotatesprite( (x<<16)+(22<<(16-type)),(y<<16)-(3<<(16-type)),65536L>>type,0,SLIDEBAR,s,pa,10,0,0,xdim-1,ydim-1); + if(rev == 0) + rotatesprite( (x<<16)+((xloc+1)<<(16-type)),(y<<16)+(1<<(16-type)),65536L>>type,0,SLIDEBAR+1,s,pa,10,0,0,xdim-1,ydim-1); + else + rotatesprite( (x<<16)+((65-xloc)<<(16-type)),(y<<16)+(1<<(16-type)),65536L>>type,0,SLIDEBAR+1,s,pa,10,0,0,xdim-1,ydim-1); +} + +void bar(int x,int y,short *p,short dainc,char damodify,short s, short pa) { bar_(0,x,y,p,dainc,damodify,s,pa); } +void barsm(int x,int y,short *p,short dainc,char damodify,short s, short pa) { bar_(1,x,y,p,dainc,damodify,s,pa); } + +static void modval(int min, int max,int *p,short dainc,char damodify) +{ + char rev; + + if(dainc < 0) { dainc = -dainc; rev = 1; } + else rev = 0; + + if(damodify) + { + if(rev == 0) + { + if( KB_KeyPressed( sc_LeftArrow ) || KB_KeyPressed( sc_kpad_4 ) || ((buttonstat&1) && minfo.dyaw < -256 ) ) // && onbar) ) + { + KB_ClearKeyDown( sc_LeftArrow ); + KB_ClearKeyDown( sc_kpad_4 ); + + *p -= dainc; + if(*p < min) + *p = max; + sound(PISTOL_BODYHIT); + } + if( KB_KeyPressed( sc_RightArrow ) || KB_KeyPressed( sc_kpad_6 ) || ((buttonstat&1) && minfo.dyaw > 256 ) )//&& onbar) ) + { + KB_ClearKeyDown( sc_RightArrow ); + KB_ClearKeyDown( sc_kpad_6 ); + + *p += dainc; + if(*p > max) + *p = min; + sound(PISTOL_BODYHIT); + } + } + else + { + if( KB_KeyPressed( sc_RightArrow ) || KB_KeyPressed( sc_kpad_6 ) || ((buttonstat&1) && minfo.dyaw > 256 ))//&& onbar )) + { + KB_ClearKeyDown( sc_RightArrow ); + KB_ClearKeyDown( sc_kpad_6 ); + + *p -= dainc; + if(*p < min) + *p = max; + sound(PISTOL_BODYHIT); + } + if( KB_KeyPressed( sc_LeftArrow ) || KB_KeyPressed( sc_kpad_4 ) || ((buttonstat&1) && minfo.dyaw < -256 ))// && onbar) ) + { + KB_ClearKeyDown( sc_LeftArrow ); + KB_ClearKeyDown( sc_kpad_4 ); + + *p += dainc; + if(*p > max) + *p = min; + sound(PISTOL_BODYHIT); + } + } + } +} + +#define SHX(X) 0 +// ((x==X)*(-sh)) +#define PHX(X) 0 +// ((x==X)?1:2) +#define MWIN(X) rotatesprite( 320<<15,200<<15,X,0,MENUSCREEN,-16,0,10+64,0,0,xdim-1,ydim-1) +#define MWINXY(X,OX,OY) rotatesprite( ( 320+(OX) )<<15, ( 200+(OY) )<<15,X,0,MENUSCREEN,-16,0,10+64,0,0,xdim-1,ydim-1) + +extern int loadpheader(char spot,struct savehead *saveh); + +static struct savehead savehead; +//static int32 volnum,levnum,plrskl,numplr; +//static char brdfn[BMAX_PATH]; +short lastsavedpos = -1; + +void dispnames(void) +{ + short x, c = 160; + + c += 64; + for(x = 0;x <= 108;x += 12) + rotatesprite((c+91-64)<<16,(x+56)<<16,65536L,0,TEXTBOX,24,0,10,0,0,xdim-1,ydim-1); + + rotatesprite(22<<16,97<<16,65536L,0,WINDOWBORDER2,24,0,10,0,0,xdim-1,ydim-1); + rotatesprite(180<<16,97<<16,65536L,1024,WINDOWBORDER2,24,0,10,0,0,xdim-1,ydim-1); + rotatesprite(99<<16,50<<16,65536L,512,WINDOWBORDER1,24,0,10,0,0,xdim-1,ydim-1); + rotatesprite(103<<16,144<<16,65536L,1024+512,WINDOWBORDER1,24,0,10,0,0,xdim-1,ydim-1); + + for (x=0;x<=9;x++) + minitext(c,48+(12*x),ud.savegame[x],2,10+16); +} + +void clearfilenames(void) +{ + klistfree(finddirs); + klistfree(findfiles); + finddirs = findfiles = NULL; + numfiles = numdirs = 0; +} + +int getfilenames(char *path, char kind[]) +{ + CACHE1D_FIND_REC *r; + + clearfilenames(); + finddirs = klistpath(path,"*",CACHE1D_FIND_DIR); + findfiles = klistpath(path,kind,CACHE1D_FIND_FILE); + for (r = finddirs; r; r=r->next) numdirs++; + for (r = findfiles; r; r=r->next) numfiles++; + + finddirshigh = finddirs; + findfileshigh = findfiles; + currentlist = 0; + if (findfileshigh) currentlist = 1; + + return(0); +} + +long quittimer = 0; + +void menus(void) +{ + CACHE1D_FIND_REC *dir; + short c,x,i; + long l,m; + char *p = NULL; + + getpackets(); + + if(ControllerType == 1 && CONTROL_MousePresent) + { + if(buttonstat != 0 && !onbar) + { + x = MOUSE_GetButtons()<<3; + if( x ) buttonstat = x<<3; + else buttonstat = 0; + } + else + buttonstat = MOUSE_GetButtons(); + } + else buttonstat = 0; + + if( (ps[myconnectindex].gm&MODE_MENU) == 0 ) + { + walock[TILE_LOADSHOT] = 1; + return; + } + + ps[myconnectindex].gm &= (0xff-MODE_TYPE); + ps[myconnectindex].fta = 0; + + x = 0; + + sh = 4-(sintable[(totalclock<<4)&2047]>>11); + + if(bpp > 8 && (ps[myconnectindex].gm&MODE_GAME || (ps[myconnectindex].gm&MODE_DEMO && ud.recstat != 0))) + { + long x,y,y1=0,y2=ydim; + for(y=y1;y= 1000 && current_menu <= 2999 && current_menu >= 300 && current_menu <= 369)) + vscrn(); + + switch(current_menu) + { + case 25000: + gametext(160,90,"SELECT A SAVE SPOT BEFORE",0,2+8+16); + gametext(160,90+9,"YOU QUICK RESTORE.",0,2+8+16); + + x = probe(186,124,0,0); + if(x >= -1) + { + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + ps[myconnectindex].gm &= ~MODE_MENU; + } + break; + + case 20000: + x = probe(326,190,0,0); + gametext(160,50-8,"YOU ARE PLAYING THE SHAREWARE",0,2+8+16); + gametext(160,59-8,"VERSION OF DUKE NUKEM 3D. WHILE",0,2+8+16); + gametext(160,68-8,"THIS VERSION IS REALLY COOL, YOU",0,2+8+16); + gametext(160,77-8,"ARE MISSING OVER 75%% OF THE TOTAL",0,2+8+16); + gametext(160,86-8,"GAME, ALONG WITH OTHER GREAT EXTRAS",0,2+8+16); + gametext(160,95-8,"AND GAMES, WHICH YOU'LL GET WHEN",0,2+8+16); + gametext(160,104-8,"YOU ORDER THE COMPLETE VERSION AND",0,2+8+16); + gametext(160,113-8,"GET THE FINAL TWO EPISODES.",0,2+8+16); + + gametext(160,113+8,"PLEASE READ THE 'HOW TO ORDER' ITEM",0,2+8+16); + gametext(160,122+8,"ON THE MAIN MENU IF YOU WISH TO",0,2+8+16); + gametext(160,131+8,"UPGRADE TO THE FULL REGISTERED",0,2+8+16); + gametext(160,140+8,"VERSION OF DUKE NUKEM 3D.",0,2+8+16); + gametext(160,149+16,"PRESS ANY KEY...",0,2+8+16); + + if( x >= -1 ) cmenu(100); + break; + + case 20001: + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"NETWORK GAME"); + + x = probe(160,100-18,18,3); + + if (x == -1) cmenu(0); + else if (x == 2) cmenu(20010); + else if (x == 1) cmenu(20020); + else if (x == 0) cmenu(20002); + + menutext(160,100-18,0,0,"PLAYER SETUP"); + menutext(160,100,0,0,"JOIN GAME"); + menutext(160,100+18,0,0,"HOST GAME"); + break; + + case 20002: + case 20003: + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"PLAYER SETUP"); + + if (current_menu == 20002) { + x = probe(46,50,20,2); + + if (x == -1) cmenu(20001); + else if (x == 0) { + strcpy(buf, myname); + inputloc = strlen(buf); + current_menu = 20003; + + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + } else if (x == 1) { + // send colour update + } + } else { + x = strget(40+100,50-9,buf,31,0); + if (x) { + if (x == 1) { + strcpy(myname,buf); + // send name update + } + + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + + current_menu = 20002; + } + } + + menutext(40,50,0,0,"NAME"); + if (current_menu == 20002) gametext(40+100,50-9,myname,0,2+8+16); + + menutext(40,50+20,0,0,"COLOR"); + rotatesprite((40+120)<<16,(50+20+(tilesizy[APLAYER]>>1))<<16,65536L,0,APLAYER,0,0,10,0,0,xdim-1,ydim-1); + + break; + + case 20010: + //note: this menu does not seem to be used and has not been updated to support custom game types + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"HOST NETWORK GAME"); + + x = probe(46,50,80,2); + + if (x == -1) { + cmenu(20001); + probey = 2; + } + else if (x == 0) cmenu(20011); + + menutext(40,50,0,0,"GAME OPTIONS"); + minitext(90,60, "GAME TYPE" ,2,26); + minitext(90,60+8, "EPISODE" ,2,26); + minitext(90,60+8+8, "LEVEL" ,2,26); + minitext(90,60+8+8+8, "MONSTERS" ,2,26); + if (ud.m_coop == 0) + minitext(90,60+8+8+8+8, "MARKERS" ,2,26); + else if (ud.m_coop == 1) + minitext(90,60+8+8+8+8, "FRIENDLY FIRE",2,26); + minitext(90,60+8+8+8+8+8, "USER MAP" ,2,26); + + /* if (ud.m_coop == 1) minitext(90+60,60,"COOPERATIVE PLAY",0,26); + else if (ud.m_coop == 2) minitext(90+60,60,"DUKEMATCH (NO SPAWN)",0,26); + else minitext(90+60,60,"DUKEMATCH (SPAWN)",0,26);*/ + gametext(90+60,60,gametype_names[ud.m_coop],0,26); + + minitext(90+60,60+8, volume_names[ud.m_volume_number],0,26); + minitext(90+60,60+8+8, level_names[11*ud.m_volume_number+ud.m_level_number],0,26); + if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) + minitext(90+60,60+8+8+8, skill_names[ud.m_player_skill],0,26); + else minitext(90+60,60+8+8+8, "NONE",0,28); + if (ud.m_coop == 0) { + if (ud.m_marker) minitext(90+60,60+8+8+8+8,"ON",0,26); + else minitext(90+60,60+8+8+8+8,"OFF",0,26); + } else if (ud.m_coop == 1) { + if (ud.m_ffire) minitext(90+60,60+8+8+8+8,"ON",0,26); + else minitext(90+60,60+8+8+8+8,"OFF",0,26); + } + + menutext(40,50+80,0,0,"LAUNCH GAME"); + break; + + case 20011: + c = (320>>1) - 120; + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"NET GAME OPTIONS"); + + x = probe(c,57-8,16,8); + + switch(x) + { + case -1: + cmenu(20010); + break; + case 0: + ud.m_coop++; + if(ud.m_coop == 3) ud.m_coop = 0; + break; + case 1: + if (!VOLUMEONE) { + ud.m_volume_number++; + if(ud.m_volume_number == num_volumes) ud.m_volume_number = 0; + if(ud.m_volume_number == 0 && ud.m_level_number > 6) + ud.m_level_number = 0; + if(ud.m_level_number > 10) ud.m_level_number = 0; + } + break; + case 2: + ud.m_level_number++; + if (!VOLUMEONE) { + if(ud.m_volume_number == 0 && ud.m_level_number > 6) + ud.m_level_number = 0; + } else { + if(ud.m_volume_number == 0 && ud.m_level_number > 5) + ud.m_level_number = 0; + } + if(ud.m_level_number > 10) ud.m_level_number = 0; + break; + case 3: + if(ud.m_monsters_off == 1 && ud.m_player_skill > 0) + ud.m_monsters_off = 0; + + if(ud.m_monsters_off == 0) + { + ud.m_player_skill++; + if(ud.m_player_skill > 3) + { + ud.m_player_skill = 0; + ud.m_monsters_off = 1; + } + } + else ud.m_monsters_off = 0; + + break; + + case 4: + if(ud.m_coop == 0) + ud.m_marker = !ud.m_marker; + break; + + case 5: + if(ud.m_coop == 1) + ud.m_ffire = !ud.m_ffire; + break; + + case 6: + // pick the user map + break; + + case 7: + cmenu(20010); + break; + } + + c += 40; + + // if(ud.m_coop==1) gametext(c+70,57-7-9,"COOPERATIVE PLAY",0,2+8+16); + // else if(ud.m_coop==2) gametext(c+70,57-7-9,"DUKEMATCH (NO SPAWN)",0,2+8+16); + // else gametext(c+70,57-7-9,"DUKEMATCH (SPAWN)",0,2+8+16); + gametext(c+70,57-7-9,gametype_names[ud.m_coop],0,26); + + gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],0,2+8+16); + + gametext(c+70,57+16+16-7-9,&level_names[11*ud.m_volume_number+ud.m_level_number][0],0,2+8+16); + + if(ud.m_monsters_off == 0 || ud.m_player_skill > 0) + gametext(c+70,57+16+16+16-7-9,skill_names[ud.m_player_skill],0,2+8+16); + else gametext(c+70,57+16+16+16-7-9,"NONE",0,2+8+16); + + if(ud.m_coop == 0) + { + if(ud.m_marker) + gametext(c+70,57+16+16+16+16-7-9,"ON",0,2+8+16); + else gametext(c+70,57+16+16+16+16-7-9,"OFF",0,2+8+16); + } + + if(ud.m_coop == 1) + { + if(ud.m_ffire) + gametext(c+70,57+16+16+16+16+16-7-9,"ON",0,2+8+16); + else gametext(c+70,57+16+16+16+16+16-7-9,"OFF",0,2+8+16); + } + + c -= 44; + + menutext(c,57-9,SHX(-2),PHX(-2),"GAME TYPE"); + + sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); + menutext(c,57+16-9,SHX(-3),PHX(-3),tempbuf); + + sprintf(tempbuf,"LEVEL %ld",ud.m_level_number+1); + menutext(c,57+16+16-9,SHX(-4),PHX(-4),tempbuf); + + menutext(c,57+16+16+16-9,SHX(-5),PHX(-5),"MONSTERS"); + + if(ud.m_coop == 0) + menutext(c,57+16+16+16+16-9,SHX(-6),PHX(-6),"MARKERS"); + else + menutext(c,57+16+16+16+16-9,SHX(-6),1,"MARKERS"); + + if(ud.m_coop == 1) + menutext(c,57+16+16+16+16+16-9,SHX(-6),PHX(-6),"FR. FIRE"); + else menutext(c,57+16+16+16+16+16-9,SHX(-6),1,"FR. FIRE"); + + if (VOLUMEALL) { + menutext(c,57+16+16+16+16+16+16-9,SHX(-7),boardfilename[0] == 0,"USER MAP"); + if( boardfilename[0] != 0 ) + gametext(c+70+44,57+16+16+16+16+16,boardfilename,0,2+8+16); + } else { + menutext(c,57+16+16+16+16+16+16-9,SHX(-7),1,"USER MAP"); + } + + menutext(c,57+16+16+16+16+16+16+16-9,SHX(-8),PHX(-8),"ACCEPT"); + break; + + case 20020: + case 20021: // editing server + case 20022: // editing port + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"JOIN NETWORK GAME"); + + if (current_menu == 20020) { + x = probe(46,50,20,3); + + if (x == -1) { + cmenu(20001); + probey = 1; + } else if (x == 0) { + strcpy(buf, "localhost"); + inputloc = strlen(buf); + current_menu = 20021; + } else if (x == 1) { + strcpy(buf, "19014"); + inputloc = strlen(buf); + current_menu = 20022; + } else if (x == 2) { + } + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + } else if (current_menu == 20021) { + x = strget(40+100,50-9,buf,31,0); + if (x) { + if (x == 1) { + //strcpy(myname,buf); + } + + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + + current_menu = 20020; + } + } else if (current_menu == 20022) { + x = strget(40+100,50+20-9,buf,5,997); + if (x) { + if (x == 1) { + //strcpy(myname,buf); + } + + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + + current_menu = 20020; + } + } + + menutext(40,50,0,0,"SERVER"); + if (current_menu != 20021) gametext(40+100,50-9,"server",0,2+8+16); + + menutext(40,50+20,0,0,"PORT"); + if (current_menu != 20022) { + sprintf(tempbuf,"%d",19014); + gametext(40+100,50+20-9,tempbuf,0,2+8+16); + } + + menutext(160,50+20+20,0,0,"CONNECT"); + + + // ADDRESS + // PORT + // CONNECT + break; + + case 15001: + case 15000: + + gametext(160,90,"LOAD last game:",0,2+8+16); + + sprintf(tempbuf,"\"%s\"",ud.savegame[lastsavedpos]); + gametext(160,99,tempbuf,0,2+8+16); + + gametext(160,99+9,"(Y/N)",0,2+8+16); + + if( KB_KeyPressed(sc_Escape) || KB_KeyPressed(sc_N) || RMB) + { + if(sprite[ps[myconnectindex].i].extra <= 0) + { + if (enterlevel(MODE_GAME)) backtomenu(); + return; + } + + KB_ClearKeyDown(sc_N); + KB_ClearKeyDown(sc_Escape); + + ps[myconnectindex].gm &= ~MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + } + + if( KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB ) + { + KB_FlushKeyboardQueue(); + KB_ClearKeysDown(); + FX_StopAllSounds(); + + if(ud.multimode > 1) + { + loadplayer(-1-lastsavedpos); + ps[myconnectindex].gm = MODE_GAME; + } + else + { + c = loadplayer(lastsavedpos); + if(c == 0) + ps[myconnectindex].gm = MODE_GAME; + } + } + + probe(186,124+9,0,0); + + break; + + case 10000: + case 10001: + + c = 60; + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"ADULT MODE"); + + x = probe(60,50+16,16,2); + if(x == -1) { cmenu(202); probey = 6; break; } + + menutext(c,50+16,SHX(-2),PHX(-2),"ADULT MODE"); + menutext(c,50+16+16,SHX(-3),PHX(-3),"ENTER PASSWORD"); + + if(ud.lockout) menutext(c+160+40,50+16,0,0,"OFF"); + else menutext(c+160+40,50+16,0,0,"ON"); + + if(current_menu == 10001) + { + gametext(160,50+16+16+16+16-12,"ENTER PASSWORD",0,2+8+16); + x = strget((320>>1),50+16+16+16+16,buf,19, 998); + + if( x ) + { + if(ud.pwlockout[0] == 0 || ud.lockout == 0 ) + strcpy(&ud.pwlockout[0],buf); + else if( strcmp(buf,&ud.pwlockout[0]) == 0 ) + { + ud.lockout = 0; + buf[0] = 0; + + for(x=0;x= 0 ) + wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; + + } + current_menu = 10000; + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_kpad_Enter); + KB_FlushKeyboardQueue(); + } + } + else + { + if(x == 0) + { + if( ud.lockout == 1 ) + { + if(ud.pwlockout[0] == 0) + { + ud.lockout = 0; + for(x=0;x= 0 ) + wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; + } + else + { + buf[0] = 0; + current_menu = 10001; + inputloc = 0; + KB_FlushKeyboardQueue(); + } + } + else + { + ud.lockout = 1; + + for(x=0;x>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); + + dispnames(); + + sprintf(tempbuf,"PLAYERS: %-2ld ",savehead.numplr); + gametext(160,156,tempbuf,0,2+8+16); + + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+savehead.volnum,1+savehead.levnum,savehead.plrskl); + gametext(160,168,tempbuf,0,2+8+16); + + if (savehead.volnum == 0 && savehead.levnum == 7) + gametext(160,180,savehead.boardfn,0,2+8+16); + + gametext(160,90,"LOAD game:",0,2+8+16); + sprintf(tempbuf,"\"%s\"",ud.savegame[current_menu-1000]); + gametext(160,99,tempbuf,0,2+8+16); + gametext(160,99+9,"(Y/N)",0,2+8+16); + + if( KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB ) + { + lastsavedpos = current_menu-1000; + + KB_FlushKeyboardQueue(); + KB_ClearKeysDown(); + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + + if(ud.multimode > 1) + { + if( ps[myconnectindex].gm&MODE_GAME ) + { + loadplayer(-1-lastsavedpos); + ps[myconnectindex].gm = MODE_GAME; + } + else + { + tempbuf[0] = 126; + tempbuf[1] = lastsavedpos; + tempbuf[2] = myconnectindex; + for(x=connecthead;x>=0;x=connectpoint2[x]) + { + if (x != myconnectindex) sendpacket(x,tempbuf,3); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + getpackets(); + + loadplayer(lastsavedpos); + + multiflag = 0; + } + } + else + { + c = loadplayer(lastsavedpos); + if(c == 0) + ps[myconnectindex].gm = MODE_GAME; + } + + break; + } + if( KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) + { + KB_ClearKeyDown(sc_N); + KB_ClearKeyDown(sc_Escape); + sound(EXITMENUSOUND); + if(ps[myconnectindex].gm&MODE_DEMO) cmenu(300); + else + { + ps[myconnectindex].gm &= ~MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + } + } + + probe(186,124+9,0,0); + + break; + + case 1500: + + if( KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB ) + { + KB_FlushKeyboardQueue(); + cmenu(100); + } + if( KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) + { + KB_ClearKeyDown(sc_N); + KB_ClearKeyDown(sc_Escape); + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + ps[myconnectindex].gm &= ~MODE_MENU; + sound(EXITMENUSOUND); + break; + } + probe(186,124,0,0); + gametext(160,90,"ABORT this game?",0,2+8+16); + gametext(160,90+9,"(Y/N)",0,2+8+16); + + break; + + case 2000: + case 2001: + case 2002: + case 2003: + case 2004: + case 2005: + case 2006: + case 2007: + case 2008: + case 2009: + + rotatesprite(160<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"SAVE GAME"); + + rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); + sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); + gametext(160,156,tempbuf,0,2+8+16); + + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); + gametext(160,168,tempbuf,0,2+8+16); + + if (ud.volume_number == 0 && ud.level_number == 7) + gametext(160,180,boardfilename,0,2+8+16); + + dispnames(); + + gametext(160,90,"OVERWRITE previous SAVED game?",0,2+8+16); + gametext(160,90+9,"(Y/N)",0,2+8+16); + + if( KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB ) + { + inputloc = strlen(&ud.savegame[current_menu-2000][0]); + + cmenu(current_menu-2000+360); + + KB_FlushKeyboardQueue(); + break; + } + if( KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) + { + KB_ClearKeyDown(sc_N); + KB_ClearKeyDown(sc_Escape); + cmenu(351); + sound(EXITMENUSOUND); + } + + probe(186,124,0,0); + + break; + + case 990: + case 991: + case 992: + case 993: + case 994: + case 995: + case 996: + case 997: + case 998: + c = 160; + if (!VOLUMEALL || !PLUTOPAK) { + //rotatesprite(c<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); + rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(c,24,0,0,current_menu == 998 ? "PORT CREDITS" : "CREDITS"); + + l = 8; + } else { + l = 3; + } + + if(KB_KeyPressed(sc_Escape)) { cmenu(0); break; } + + if( KB_KeyPressed( sc_LeftArrow ) || + KB_KeyPressed( sc_kpad_4 ) || + KB_KeyPressed( sc_UpArrow ) || + KB_KeyPressed( sc_PgUp ) || + KB_KeyPressed( sc_kpad_8 ) ) + { + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_PgUp); + KB_ClearKeyDown(sc_kpad_8); + + sound(KICK_HIT); + current_menu--; + if(current_menu < 990) current_menu = 990+l; + } + else if( + KB_KeyPressed( sc_PgDn ) || + KB_KeyPressed( sc_Enter ) || + KB_KeyPressed( sc_Space ) || + KB_KeyPressed( sc_kpad_Enter ) || + KB_KeyPressed( sc_RightArrow ) || + KB_KeyPressed( sc_DownArrow ) || + KB_KeyPressed( sc_kpad_2 ) || + KB_KeyPressed( sc_kpad_9 ) || + KB_KeyPressed( sc_kpad_6 ) ) + { + KB_ClearKeyDown(sc_PgDn); + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_Enter); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_kpad_9); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_Space); + sound(KICK_HIT); + current_menu++; + if(current_menu > 990+l) current_menu = 990; + } + + if (!VOLUMEALL || !PLUTOPAK) { + switch (current_menu) { + case 990: + gametext(c,40, "ORIGINAL CONCEPT",0,2+8+16); + gametext(c,40+9, "TODD REPLOGLE",0,2+8+16); + gametext(c,40+9+9, "ALLEN H. BLUM III",0,2+8+16); + + gametext(c,40+9+9+9+9, "PRODUCED & DIRECTED BY",0,2+8+16); + gametext(c,40+9+9+9+9+9, "GREG MALONE",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9+9, "EXECUTIVE PRODUCER",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9, "GEORGE BROUSSARD",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9+9+9+9+9, "BUILD ENGINE",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9+9+9,"KEN SILVERMAN",0,2+8+16); + break; + case 991: + gametext(c,40, "GAME PROGRAMMING",0,2+8+16); + gametext(c,40+9, "TODD REPLOGLE",0,2+8+16); + + gametext(c,40+9+9+9, "3D ENGINE/TOOLS/NET",0,2+8+16); + gametext(c,40+9+9+9+9, "KEN SILVERMAN",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9, "NETWORK LAYER/SETUP PROGRAM",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9, "MARK DOCHTERMANN",0,2+8+16); + break; + case 992: + gametext(c,40, "MAP DESIGN",0,2+8+16); + gametext(c,40+9, "ALLEN H BLUM III",0,2+8+16); + gametext(c,40+9+9, "RICHARD GRAY",0,2+8+16); + + gametext(c,40+9+9+9+9, "3D MODELING",0,2+8+16); + gametext(c,40+9+9+9+9+9, "CHUCK JONES",0,2+8+16); + gametext(c,40+9+9+9+9+9+9, "SAPPHIRE CORPORATION",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9+9+9, "ARTWORK",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9, "DIRK JONES, STEPHEN HORNBACK",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9+9, "JAMES STOREY, DAVID DEMARET",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9+9+9,"DOUGLAS R WOOD",0,2+8+16); + break; + case 993: + gametext(c,40, "SOUND ENGINE",0,2+8+16); + gametext(c,40+9, "JIM DOSE",0,2+8+16); + + gametext(c,40+9+9+9, "SOUND & MUSIC DEVELOPMENT",0,2+8+16); + gametext(c,40+9+9+9+9, "ROBERT PRINCE",0,2+8+16); + gametext(c,40+9+9+9+9+9, "LEE JACKSON",0,2+8+16); + + gametext(c,40+9+9+9+9+9+9+9, "VOICE TALENT",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9, "LANI MINELLA - VOICE PRODUCER",0,2+8+16); + gametext(c,40+9+9+9+9+9+9+9+9+9, "JON ST. JOHN AS \"DUKE NUKEM\"",0,2+8+16); + break; + case 994: + gametext(c,60, "GRAPHIC DESIGN",0,2+8+16); + gametext(c,60+9, "PACKAGING, MANUAL, ADS",0,2+8+16); + gametext(c,60+9+9, "ROBERT M. ATKINS",0,2+8+16); + gametext(c,60+9+9+9, "MICHAEL HADWIN",0,2+8+16); + + gametext(c,60+9+9+9+9+9, "SPECIAL THANKS TO",0,2+8+16); + gametext(c,60+9+9+9+9+9+9, "STEVEN BLACKBURN, TOM HALL",0,2+8+16); + gametext(c,60+9+9+9+9+9+9+9, "SCOTT MILLER, JOE SIEGLER",0,2+8+16); + gametext(c,60+9+9+9+9+9+9+9+9, "TERRY NAGY, COLLEEN COMPTON",0,2+8+16); + gametext(c,60+9+9+9+9+9+9+9+9+9, "HASH INC., FORMGEN, INC.",0,2+8+16); + break; + case 995: + gametext(c,49, "THE 3D REALMS BETA TESTERS",0,2+8+16); + + gametext(c,49+9+9, "NATHAN ANDERSON, WAYNE BENNER",0,2+8+16); + gametext(c,49+9+9+9, "GLENN BRENSINGER, ROB BROWN",0,2+8+16); + gametext(c,49+9+9+9+9, "ERIK HARRIS, KEN HECKBERT",0,2+8+16); + gametext(c,49+9+9+9+9+9, "TERRY HERRIN, GREG HIVELY",0,2+8+16); + gametext(c,49+9+9+9+9+9+9, "HANK LEUKART, ERIC BAKER",0,2+8+16); + gametext(c,49+9+9+9+9+9+9+9, "JEFF RAUSCH, KELLY ROGERS",0,2+8+16); + gametext(c,49+9+9+9+9+9+9+9+9, "MIKE DUNCAN, DOUG HOWELL",0,2+8+16); + gametext(c,49+9+9+9+9+9+9+9+9+9, "BILL BLAIR",0,2+8+16); + break; + case 996: + gametext(c,32, "COMPANY PRODUCT SUPPORT",0,2+8+16); + + gametext(c,32+9+9, "THE FOLLOWING COMPANIES WERE COOL",0,2+8+16); + gametext(c,32+9+9+9, "ENOUGH TO GIVE US LOTS OF STUFF",0,2+8+16); + gametext(c,32+9+9+9+9, "DURING THE MAKING OF DUKE NUKEM 3D.",0,2+8+16); + + gametext(c,32+9+9+9+9+9+9, "ALTEC LANSING MULTIMEDIA",0,2+8+16); + gametext(c,32+9+9+9+9+9+9+9, "FOR TONS OF SPEAKERS AND THE",0,2+8+16); + gametext(c,32+9+9+9+9+9+9+9+9, "THX-LICENSED SOUND SYSTEM",0,2+8+16); + gametext(c,32+9+9+9+9+9+9+9+9+9, "FOR INFO CALL 1-800-548-0620",0,2+8+16); + + gametext(c,32+9+9+9+9+9+9+9+9+9+9+9,"CREATIVE LABS, INC.",0,2+8+16); + + gametext(c,32+9+9+9+9+9+9+9+9+9+9+9+9+9,"THANKS FOR THE HARDWARE, GUYS.",0,2+8+16); + break; + case 997: + gametext(c,50, "DUKE NUKEM IS A TRADEMARK OF",0,2+8+16); + gametext(c,50+9, "3D REALMS ENTERTAINMENT",0,2+8+16); + + gametext(c,50+9+9+9, "DUKE NUKEM",0,2+8+16); + gametext(c,50+9+9+9+9, "(C) 1996 3D REALMS ENTERTAINMENT",0,2+8+16); + + if (VOLUMEONE) { + gametext(c,106, "PLEASE READ LICENSE.DOC FOR SHAREWARE",0,2+8+16); + gametext(c,106+9, "DISTRIBUTION GRANTS AND RESTRICTIONS",0,2+8+16); + } + + gametext(c,VOLUMEONE?134:115, "MADE IN DALLAS, TEXAS USA",0,2+8+16); + break; + case 998: + l = 10; + goto cheat_for_port_credits; + } + break; + } + + // Plutonium pak menus + switch(current_menu) + { + case 990: + case 991: + case 992: + rotatesprite(160<<16,200<<15,65536L,0,2504+current_menu-990,0,0,10+64,0,0,xdim-1,ydim-1); + break; + case 993: // JBF 20031220 + rotatesprite(160<<16,200<<15,65536L,0,MENUSCREEN,0,0,10+64,0,0,xdim-1,ydim-1); + menutext(160,28,0,0,"PORT CREDITS"); + +cheat_for_port_credits: + if (conversion == 13) l = (-2); + gametext(160,38-l,"EDUKE PORT TO JFDUKE, NEW FEATURES,",0,2+8+16); + gametext(160,38+8-l,"FUNCTIONS, AND ENGINE MODIFICATIONS",0,2+8+16); + p = "Richard \"TerminX\" Gobeille, EDuke32 team"; + minitext(160-(Bstrlen(p)<<1), 38+8+10-l, p, 8, 10+16+128); + + gametext(160,70-l,"DUKE3D AND BUILD ENGINE PORTING,",0,2+8+16); + gametext(160,70+8-l, "MODIFICATIONS, AND GENERAL GUIDANCE",0,2+8+16); + p = "Jonathon \"JonoF\" Fowler"; + minitext(160-(Bstrlen(p)<<1), 70+8+10-l, p, 8, 10+16+128); + + gametext(160,102-l,"\"POLYMOST\" OPENGL RENDERER",0,2+8+16); + gametext(160,102+8-l,"NETWORKING, OTHER CODE",0,2+8+16); + p = "Ken Silverman"; + minitext(160-(Bstrlen(p)<<1), 102+8+10-l, p, 8, 10+16+128); + + + // /* for (i=0;i<7;i++) { + // switch (i) { + // case 0: p = "This program is distributed under the terms of the"; break; + // case 1: p = "GNU General Public License version 2 as published by the"; break; + // case 2: p = "Free Software Foundation. See GNU.TXT for details."; break; + // case 3: p = NULL; break; + // case 4: p = "Visit http://www.eduke32.com for the source code,"; break; + // case 5: p = "latest news, and the current version of this port."; break; + // case 6: p = "EDuke originally by Matt Saettler."; break; + // } + // if (!p) continue; + // //minitext(160-(Bstrlen(p)<<1)+1, 110+10+1+(i*7)-l, p, 4, 10+16+128); + // minitext(160-(Bstrlen(p)<<1), 130+10+(i*7)-l, p, /*12*/8, 10+16+128); + // } + // */ + { + const char *scroller[] = { + "This program is distributed under the terms of the", + "GNU General Public License version 2 as published by the", + "Free Software Foundation. See GNU.TXT for details.", + "", + "EDuke originally by Matthew Saettler", + "", + "Thanks to these people for their input and contributions:", + "", + "Ed Coolidge", + "Javier Martinez", + "Jeff Hart", + "Jonathan Smith", + "Jose del Castillo", + "Lachlan McDonald", + "Matthew Palmer", + "Peter Green", + "Pierre-Loup Archambeaud Griffais", + "", + "--x--", + "", + "", + "", + "", + "" + }; + const int numlines = sizeof(scroller)/sizeof(char *); + for (m=0,i=(totalclock/104)%numlines; m<6; m++,i++) { + if (i==numlines) i=0; + minitext(160-(Bstrlen(scroller[i])<<1), 100+10+10+8+4+(m*7)-l, (char*)scroller[i], 8, 10+16+128); + } + } + + for (i=0;i<2;i++) { + switch (i) { + case 0: p = "www.eduke32.com"; break; + case 1: p = ""; break; // fuck I am lazy + } + minitext(160-(Bstrlen(p)<<1), 135+10+10+10+10+4+(i*7)-l, p, 8, 10+16+128); + } + break; + } + break; + + case 0: + c = (320>>1); + rotatesprite(c<<16,28<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite((c+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8,0,0,xdim-1,ydim-1); + x = probe(c,67,16,6); + if(x >= 0) + { + if( ud.multimode > 1 && x == 0 && ud.recstat != 2) + { + if( movesperpacket == 4 && myconnectindex != connecthead ) + break; + + last_zero = 0; + cmenu( 600 ); + } + else + { + last_zero = x; + switch(x) + { + case 0: + cmenu(100); + break; + //case 1: break;//cmenu(20001);break; // JBF 20031128: I'm taking over the TEN menu option + case 1: cmenu(202);break; // JBF 20031205: was 200 + case 2: + if(movesperpacket == 4 && connecthead != myconnectindex) + break; + cmenu(300); + break; + case 3: KB_FlushKeyboardQueue();cmenu(400);break; + case 4: cmenu(990);break; + case 5: cmenu(500);break; + } + } + } + + if(KB_KeyPressed(sc_Q)) cmenu(500); + + if(x == -1) + { + ps[myconnectindex].gm &= ~MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + } + + if(movesperpacket == 4) + { + if( myconnectindex == connecthead ) + menutext(c,67,SHX(-2),PHX(-2),"NEW GAME"); + else + menutext(c,67,SHX(-2),1,"NEW GAME"); + } + else + menutext(c,67,SHX(-2),PHX(-2),"NEW GAME"); + + // menutext(c,67+16,0,1,"NETWORK GAME"); + + menutext(c,67+16/*+16*/,SHX(-3),PHX(-3),"OPTIONS"); + + if(movesperpacket == 4 && connecthead != myconnectindex) + menutext(c,67+16+16/*+16*/,SHX(-4),1,"LOAD GAME"); + else menutext(c,67+16+16/*+16*/,SHX(-4),PHX(-4),"LOAD GAME"); + + if (!VOLUMEALL) { + + menutext(c,67+16+16+16/*+16*/,SHX(-5),PHX(-5),"HOW TO ORDER"); + } else { + + menutext(c,67+16+16+16/*+16*/,SHX(-5),PHX(-5),"HELP"); + } + + menutext(c,67+16+16+16+16/*+16*/,SHX(-6),PHX(-6),"CREDITS"); + + + menutext(c,67+16+16+16+16+16/*+16*/,SHX(-7),PHX(-7),"QUIT"); + break; + + case 50: + c = (320>>1); + rotatesprite(c<<16,32<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite((c+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8,0,0,xdim-1,ydim-1); + x = probe(c,67,16,7); + switch(x) + { + case 0: + if(movesperpacket == 4 && myconnectindex != connecthead) + break; + if(ud.multimode < 2 || ud.recstat == 2) + cmenu(1500); + else + { + cmenu(600); + last_fifty = 0; + } + break; + case 1: + if(movesperpacket == 4 && connecthead != myconnectindex) + break; + if(ud.recstat != 2) + { + last_fifty = 1; + cmenu(350); + setview(0,0,xdim-1,ydim-1); + } + break; + case 2: + if(movesperpacket == 4 && connecthead != myconnectindex) + break; + last_fifty = 2; + cmenu(300); + break; + case 3: + last_fifty = 3; + cmenu(202); // JBF 20031205: was 200 + break; + case 4: + last_fifty = 4; + KB_FlushKeyboardQueue(); + cmenu(400); + break; + case 5: + if(numplayers < 2) + { + last_fifty = 5; + cmenu(501); + } + break; + case 6: + last_fifty = 6; + cmenu(500); + break; + case -1: + ps[myconnectindex].gm &= ~MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + break; + } + + if( KB_KeyPressed(sc_Q) ) + cmenu(500); + + if(movesperpacket == 4 && connecthead != myconnectindex) + { + menutext(c,67 ,SHX(-2),1,"NEW GAME"); + menutext(c,67+16 ,SHX(-3),1,"SAVE GAME"); + menutext(c,67+16+16 ,SHX(-4),1,"LOAD GAME"); + } + else + { + menutext(c,67 ,SHX(-2),PHX(-2),"NEW GAME"); + menutext(c,67+16 ,SHX(-3),PHX(-3),"SAVE GAME"); + menutext(c,67+16+16 ,SHX(-4),PHX(-4),"LOAD GAME"); + } + + menutext(c,67+16+16+16 ,SHX(-5),PHX(-5),"OPTIONS"); + if (!VOLUMEALL) { + menutext(c,67+16+16+16+16 ,SHX(-6),PHX(-6),"HOW TO ORDER"); + } else { + menutext(c,67+16+16+16+16 ,SHX(-6),PHX(-6)," HELP"); + } + if(numplayers > 1) + menutext(c,67+16+16+16+16+16 ,SHX(-7),1,"QUIT TO TITLE"); + else menutext(c,67+16+16+16+16+16 ,SHX(-7),PHX(-7),"QUIT TO TITLE"); + menutext(c,67+16+16+16+16+16+16,SHX(-8),PHX(-8),"QUIT GAME"); + break; + + case 100: + rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,24,0,0,"SELECT AN EPISODE"); + // if(boardfilename[0]) + if (PLUTOPAK) + x = probe(160,60-(num_volumes*2),20,num_volumes+1); + // else x = probe(160,60,20,4); + // if(boardfilename[0]) + else + x = probe(160,VOLUMEONE?60:60-(num_volumes*2),20,VOLUMEONE?3:num_volumes+1); + // else x = probe(160,60,20,3); + if(x >= 0) + { + if (VOLUMEONE) { + if(x > 0) + cmenu(20000); + else + { + ud.m_volume_number = x; + ud.m_level_number = 0; + last_onehundred = x; + cmenu(110); + } + } + + if (!VOLUMEONE) { + if(x == num_volumes /*&& boardfilename[0]*/) + { + //ud.m_volume_number = 0; + //ud.m_level_number = 7; + currentlist = 1; + last_onehundred = x; + cmenu(101); + } + else + { + ud.m_volume_number = x; + ud.m_level_number = 0; + last_onehundred = x; + cmenu(110); + } + } + } + else if(x == -1) + { + if(ps[myconnectindex].gm&MODE_GAME) cmenu(50); + else cmenu(0); + } + + + + c = 80; + if (VOLUMEONE) { + menutext(160,60,SHX(-2),PHX(-2),volume_names[0]); + menutext(160,60+20,SHX(-3),1,volume_names[1]); + menutext(160,60+20+20,SHX(-4),1,volume_names[2]); + if (PLUTOPAK) + menutext(160,60+20+20,SHX(-5),1,volume_names[3]); + } else { + for (i=0;i 0) + { + while(KB_KeyPressed(sc_End)?seeker->next:seeker->prev) + seeker = KB_KeyPressed(sc_End)?seeker->next:seeker->prev; + if (seeker) { + if (currentlist) findfileshigh = seeker; + else finddirshigh = seeker; + sound(KICK_HIT); + } + } + else if((KB_KeyPressed(sc_PgUp)|KB_KeyPressed(sc_PgDn)) > 0) + { + seeker = currentlist?findfileshigh:finddirshigh; + i = 6; + while(i>0) { + if(KB_KeyPressed(sc_PgDn)?seeker->next:seeker->prev) + seeker = KB_KeyPressed(sc_PgDn)?seeker->next:seeker->prev; + i--; + } + if (seeker) { + if (currentlist) findfileshigh = seeker; + else finddirshigh = seeker; + sound(KICK_HIT); + } + } + else + { + char ch2, ch; + ch = KB_Getch(); + if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) { + if (ch >= 'a') ch -= ('a'-'A'); + while (seeker) { + ch2 = seeker->name[0]; + if (ch2 >= 'a' && ch2 <= 'z') ch2 -= ('a'-'A'); + if (ch2 == ch) break; + seeker = seeker->next; + } + if (seeker) { + if (currentlist) findfileshigh = seeker; + else finddirshigh = seeker; + sound(KICK_HIT); + } + } + } + } + gametext(40+4,12+32,"DIRECTORIES",0,2+8+16); + + if (finddirshigh) { + dir = finddirshigh; + for(i=0; i<2; i++) if (!dir->prev) break; else dir=dir->prev; + for(i=2; i>-2 && dir; i--, dir=dir->next) { + if (dir == finddirshigh) c=0; else c=16; + minitextshade(40,1+12+32+8*(3-i),dir->name,c,0,26); + } + } + + gametext(40+4,8+32+40+8-1,"MAP FILES",0,2+8+16); + + if (findfileshigh) { + dir = findfileshigh; + for(i=0; i<4; i++) if (!dir->prev) break; else dir=dir->prev; + for(i=4; i>-4 && dir; i--, dir=dir->next) { + if (dir == findfileshigh) c=0; else c=16; + minitextshade(40,(8+32+8*5)+8*(6-i),dir->name,c,2,26); + } + } + + if( KB_KeyPressed( sc_LeftArrow ) || KB_KeyPressed( sc_kpad_4 ) || ((buttonstat&1) && minfo.dyaw < -256 ) || + KB_KeyPressed( sc_RightArrow ) || KB_KeyPressed( sc_kpad_6 ) || ((buttonstat&1) && minfo.dyaw > 256 ) || + KB_KeyPressed( sc_Tab ) ) + { + KB_ClearKeyDown( sc_LeftArrow ); + KB_ClearKeyDown( sc_kpad_4 ); + KB_ClearKeyDown( sc_RightArrow ); + KB_ClearKeyDown( sc_kpad_6 ); + KB_ClearKeyDown( sc_Tab ); + currentlist = 1-currentlist; + sound(KICK_HIT); + } + + onbar = 0; + probey = 2; + if (currentlist == 0) x = probe(50,12+32+16+4,0,3); + else x = probe(50,8+32+40+40+4,0,3); + + if (probey == 1) { + if (currentlist == 0) { + if (finddirshigh) + if (finddirshigh->prev) finddirshigh = finddirshigh->prev; + } else { + if (findfileshigh) + if (findfileshigh->prev) findfileshigh = findfileshigh->prev; + } + } else if (probey == 0) { + if (currentlist == 0) { + if (finddirshigh) + if (finddirshigh->next) finddirshigh = finddirshigh->next; + } else { + if (findfileshigh) + if (findfileshigh->next) findfileshigh = findfileshigh->next; + } + } + + if(x == -1) { + cmenu(100); + clearfilenames(); + boardfilename[0] = 0; + } + else if(x >= 0) + { + if (currentlist == 0) { + if (!finddirshigh) break; + strcat(boardfilename, finddirshigh->name); + strcat(boardfilename, "/"); + Bcorrectfilename(boardfilename, 1); + cmenu(101); + KB_FlushKeyboardQueue(); + } else { + if (!findfileshigh) break; + strcat(boardfilename, findfileshigh->name); + ud.m_volume_number = 0; + ud.m_level_number = 7; + cmenu(110); + } + clearfilenames(); + } + break; + + + + case 110: + c = (320>>1); + rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(c,24,0,0,"SELECT SKILL"); + x = probe(c,70,19,4); + if(x >= 0) + { + switch(x) + { + case 0: globalskillsound = JIBBED_ACTOR6;break; + case 1: globalskillsound = BONUS_SPEECH1;break; + case 2: globalskillsound = DUKE_GETWEAPON2;break; + case 3: globalskillsound = JIBBED_ACTOR5;break; + } + + sound(globalskillsound); + + ud.m_player_skill = x+1; + if(x == 3) ud.m_respawn_monsters = 1; + else ud.m_respawn_monsters = 0; + + ud.m_monsters_off = ud.monsters_off = 0; + + ud.m_respawn_items = 0; + ud.m_respawn_inventory = 0; + + ud.multimode = 1; + + if(ud.m_volume_number == 3) + { + flushperms(); + setview(0,0,xdim-1,ydim-1); + clearview(0L); + nextpage(); + } + + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + if (enterlevel(MODE_GAME)) backtomenu(); + } + else if(x == -1) + { + cmenu(100); + KB_FlushKeyboardQueue(); + } + + menutext(c,70,SHX(-2),PHX(-2),skill_names[0]); + menutext(c,70+19,SHX(-3),PHX(-3),skill_names[1]); + menutext(c,70+19+19,SHX(-4),PHX(-4),skill_names[2]); + menutext(c,70+19+19+19,SHX(-5),PHX(-5),skill_names[3]); + break; + + case 200: + + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"GAME OPTIONS"); + + c = (320>>1)-120; + + { + int io, ii, yy, d=c+160+40, enabled; + char *opts[] = { + "Crosshair", + "Level stats", + "Status bar size", + "-", + "Mouse aiming type", + "Mouse aiming toggle", + "Invert mouse aim", + "Auto-aiming", + "Run key style", + "Auto weapon switching", + "-", + "Screen size", + "Detail", + "Shadows", + "Screen tilting", + "-", + "Record demo", + "-", + "More...", + NULL + }; + + yy = 34; + for (ii=io=0; opts[ii]; ii++) { + if (opts[ii][0] == '-' && !opts[ii][1]) { + if (io <= probey) yy += 4; + continue; + } + if (io < probey) yy += 8; + io++; + } + + onbar = (probey == 2 || probey == 9); + x = probesm(c,yy+5,0,io); + + if (x == -1) { cmenu(202); break; } + + yy = 34; + for (ii=io=0; opts[ii]; ii++) { + if (opts[ii][0] == '-' && !opts[ii][1]) { + yy += 4; + continue; + } + enabled = 1; + switch (io) { + case 0: if (x==io) ud.crosshair = 1-ud.crosshair; + modval(0,1,(int *)&ud.crosshair,1,probey==0); + gametextpal(d,yy, ud.crosshair ? "On" : "Off", 0, 0); break; + case 1: if (x==io) ud.levelstats = 1-ud.levelstats; + modval(0,1,(int *)&ud.levelstats,1,probey==1); + gametextpal(d,yy, ud.levelstats ? "Shown" : "Hidden", 0, 0); break; + case 2: + { + short sbs, sbsl; + sbs = sbsl = scale(max(0,ud.statusbarscale-50),63,100-50); + barsm(d+8,yy+7, (short *)&sbs,9,x==io,SHX(-5),PHX(-5)); + if (x == io && sbs != sbsl) { + sbs = scale(sbs,100-50,63)+50; + setstatusbarscale(sbs); + } + } + break; + case 3: if (ps[myconnectindex].gm&MODE_GAME || numplayers > 1) enabled = 0; + if (enabled && x==io) ud.mouseaiming = !ud.mouseaiming; + if (enabled) modval(0,1,(int *)&ud.mouseaiming,1,probey==3); + // don't change when in a multiplayer game + // because the state is sent during getnames() + // however, this will be fixed later + gametextpal(d,yy, ud.mouseaiming ? "Held" : "Toggle", enabled?0:10, 0); break; + case 4: enabled = !ud.mouseaiming; + if (enabled && x==io) myaimmode = 1-myaimmode; + if (enabled) modval(0,1,(int *)&myaimmode,1,probey==4); + gametextpal(d,yy, myaimmode && enabled ? "On" : "Off", enabled?0:10, 0); break; + case 5: if (x==io) ud.mouseflip = 1-ud.mouseflip; + modval(0,1,(int *)&ud.mouseflip,1,probey==5); + gametextpal(d,yy, ud.mouseflip ? "On" : "Off", 0, 0); break; + case 6: if (ps[myconnectindex].gm&MODE_GAME || numplayers > 1) enabled = 0; + if (enabled && x==io) AutoAim = 1-AutoAim; + if (enabled) modval(0,1,(int *)&AutoAim,1,probey==6); + gametextpal(d,yy, AutoAim ? "On" : "Off", enabled?0:10, 0); break; + case 7: if (x==io) ud.runkey_mode = 1-ud.runkey_mode; + modval(0,1,(int *)&ud.runkey_mode,1,probey==7); + gametextpal(d,yy, ud.runkey_mode ? "Classic" : "Modern", 0, 0); break; + case 8: if (ps[myconnectindex].gm&MODE_GAME || numplayers > 1) enabled = 0; + if (enabled && x==io) { ud.weaponswitch = (ud.weaponswitch == 3) ? 0 : ud.weaponswitch+1; } + if (enabled) modval(0,3,(int *)&ud.weaponswitch,1,probey==8); + { char *s[] = { "Off", "Pickup", "Empty", "Both" }; + gametextpal(d,yy, s[ud.weaponswitch], enabled?0:10, 0); break; } + break; + case 9: barsm(d+8,yy+7, (short *)&ud.screen_size,-4,x==io,SHX(-5),PHX(-5)); break; + case 10: if (x==io) ud.detail = 1-ud.detail; + modval(0,1,(int *)&ud.detail,1,probey==10); + gametextpal(d,yy, ud.detail ? "High" : "Low", 0, 0); break; + case 11: if (x==io) ud.shadows = 1-ud.shadows; + modval(0,1,(int *)&ud.shadows,1,probey==11); + gametextpal(d,yy, ud.shadows ? "On" : "Off", 0, 0); break; + case 12: if (x==io) ud.screen_tilting = 1-ud.screen_tilting; + modval(0,1,(int *)&ud.screen_tilting,1,probey==12); + gametextpal(d,yy, ud.screen_tilting ? "On" : "Off", 0, 0); break; // original had a 'full' option + case 13: if (x==io) { + enabled = !((ps[myconnectindex].gm&MODE_GAME) && ud.m_recstat != 1); + if( (ps[myconnectindex].gm&MODE_GAME) ) closedemowrite(); + else ud.m_recstat = !ud.m_recstat; + } + if( (ps[myconnectindex].gm&MODE_GAME) && ud.m_recstat != 1 ) + enabled = 0; + gametextpal(d,yy, ud.m_recstat ? ((ud.m_recstat && enabled && ps[myconnectindex].gm&MODE_GAME) ? "Recording" : "On") : "Off", 0, !enabled ? 1 : 0); break; + case 14: if (x==io) cmenu(201); break; + default: break; + } + gametextpal(c,yy, opts[ii], enabled?5:15, 2); + io++; + yy += 8; + } + } + break; + + case 201: + + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"GAME OPTIONS"); + + c = (320>>1)-120; + + { + int io, ii, yy, d=c+160+40, enabled; + char *opts[] = { + "HUD weapon", + "FPS counter", + "-", + "Hightile textures", + "Precache textures", + "GL texture compression", + "Cache textures on disk", + "Compress disk cache", + "-", + "Models", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "-", + "Previous page", + NULL + }; + + yy = 34; + for (ii=io=0; opts[ii]; ii++) { + if (opts[ii][0] == '-' && !opts[ii][1]) { + if (io <= probey) yy += 4; + continue; + } + if (io < probey) yy += 8; + io++; + } + + onbar = (probey == 2 || probey == 9); + x = probesm(c,yy+5,0,io); + + if (x == -1) { cmenu(202); break; } + + yy = 34; + for (ii=io=0; opts[ii]; ii++) { + if (opts[ii][0] == '-' && !opts[ii][1]) { + yy += 4; + continue; + } + enabled = 1; + switch (io) { + case 0: if (x==io) ud.drawweapon = 1-ud.drawweapon; + modval(0,1,(int *)&ud.drawweapon,1,probey==0); + gametextpal(d,yy, ud.drawweapon ? "On" : "Off", 0, 0); break; + case 1: if (x==io) ud.tickrate = 1-ud.tickrate; + modval(0,1,(int *)&ud.tickrate,1,probey==1); + gametextpal(d,yy, ud.tickrate ? "On" : "Off", 0, 0); break; + case 2: if (x==io) usehightile = 1-usehightile; + modval(0,1,(int *)&usehightile,1,probey==2); + gametextpal(d,yy, usehightile ? "On" : "Off", 0, 0); break; + case 3: enabled = usehightile; + if (enabled && x==io) useprecache = !useprecache; + if (enabled) modval(0,1,(int *)&useprecache,1,probey==3); + // don't change when in a multiplayer game + // because the state is sent during getnames() + // however, this will be fixed later + gametextpal(d,yy, useprecache && enabled ? "On" : "Off", enabled?0:10, 0); break; + case 4: enabled = usehightile; + if (enabled && x==io) glusetexcompr = !glusetexcompr; + if (enabled) modval(0,1,(int *)&glusetexcompr,1,probey==4); + gametextpal(d,yy, glusetexcompr && enabled ? "On" : "Off", enabled?0:10, 0); break; + case 5: enabled = (glusetexcompr && usehightile && useprecache); + if (enabled && x==io) glusetexcache = !glusetexcache; + if (enabled) modval(0,1,(int *)&glusetexcache,1,probey==5); + gametextpal(d,yy, glusetexcache && enabled ? "On" : "Off", enabled?0:10, 0); break; + case 6: enabled = (glusetexcompr && usehightile && useprecache && glusetexcache); + if (enabled && x==io) glusetexcachecompression = !glusetexcachecompression; + if (enabled) modval(0,1,(int *)&glusetexcachecompression,1,probey==6); + gametextpal(d,yy, glusetexcachecompression && enabled ? "On" : "Off", enabled?0:10, 0); break; + case 7: if (x==io) usemodels = 1-usemodels; + modval(0,1,(int *)&usemodels,1,probey==7); + gametextpal(d,yy, usemodels ? "On" : "Off", 0, 0); break; + case 8: if (x==io) cmenu(200); break; + default: break; + } + gametextpal(c,yy, opts[ii], enabled?5:15, 2); + io++; + yy += 8; + } + } + break; + + // JBF 20031205: Second level options menu selection + case 202: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"OPTIONS"); + + c = 200>>1; + + onbar = 0; + x = probe(160,c-18-18-18,18,7); + + switch (x) { + case -1: + if(ps[myconnectindex].gm&MODE_GAME) cmenu(50);else cmenu(0); + break; + + case 0: + cmenu(200); + break; + + case 1: + cmenu(700); + break; + + case 2: + { + int dax = xdim, day = ydim, daz; + curvidmode = newvidmode = checkvideomode(&dax,&day,bpp,fullscreen); + if (newvidmode == 0x7fffffffl) newvidmode = validmodecnt; + newfullscreen = fullscreen; + changesmade = 0; + + dax = 0; + for (day = 0; day < validmodecnt; day++) { + if (dax == sizeof(vidsets)/sizeof(vidsets[1])) break; + for (daz = 0; daz < dax; daz++) + if ((validmode[day].bpp|((validmode[day].fs&1)<<16)) == (vidsets[daz]&0x1ffffl)) break; + if (vidsets[daz] != -1) continue; + if (validmode[day].bpp == 8) { + vidsets[dax++] = 8|((validmode[day].fs&1)<<16); + vidsets[dax++] = 0x20000|8|((validmode[day].fs&1)<<16); + } else + vidsets[dax++] = 0x20000|validmode[day].bpp|((validmode[day].fs&1)<<16); + } + for (dax = 0; dax < (long)(sizeof(vidsets)/sizeof(vidsets[1])) && vidsets[dax] != -1; dax++) + if (vidsets[dax] == (((getrendermode()>=2)<<17)|(fullscreen<<16)|bpp)) break; + if (dax < (long)(sizeof(vidsets)/sizeof(vidsets[1]))) newvidset = dax; + curvidset = newvidset; + + cmenu(203); + } + break; + + case 3: + currentlist = 0; + case 4: + case 5: + if (x==5 && (!CONTROL_JoystickEnabled || !CONTROL_JoyPresent)) break; + cmenu(204+x-3); + break; + + case 6: +#ifndef AUSTRALIA + cmenu(10000); +#endif + break; + } + + menutext(160,c-18-18-18,0,0,"GAME OPTIONS"); + menutext(160,c-18-18, 0,0,"SOUND OPTIONS"); + menutext(160,c-18, 0,0,"VIDEO SETTINGS"); + menutext(160,c, 0,0,"KEYBOARD SETUP"); + menutext(160,c+18, 0,0,"MOUSE SETUP"); + menutext(160,c+18+18, 0,CONTROL_JoyPresent==0 || CONTROL_JoystickEnabled==0,"JOYSTICK SETUP"); + menutext(160,c+18+18+18,0,0,"PARENTAL LOCK"); + break; + + // JBF 20031206: Video settings menu + case 203: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"VIDEO SETTINGS"); + + c = (320>>1)-120; + +#if defined(POLYMOST) && defined(USE_OPENGL) + x = 7; +#else + x = 5; +#endif + onbar = (probey == 4); + if (probey == 0 || probey == 1 || probey == 2) + x = probe(c+6,50,16,x); + else if (probey == 3) + x = probe(c+6,50+16+16+22,0,x); + else + x = probe(c+6,50+62-16-16-16,16,x); + + if (probey==0 && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_RightArrow))) { + sound(PISTOL_BODYHIT); + x=0; + } + switch (x) { + case -1: + cmenu(202); + probey = 2; + break; + + case 0: + do { + if (KB_KeyPressed(sc_LeftArrow)) { + newvidmode--; + if (newvidmode < 0) newvidmode = validmodecnt-1; + } else { + newvidmode++; + if (newvidmode >= validmodecnt) newvidmode = 0; + } + } while ((validmode[newvidmode].fs&1) != ((vidsets[newvidset]>>16)&1) || validmode[newvidmode].bpp != (vidsets[newvidset] & 0x0ffff)); + //OSD_Printf("New mode is %dx%dx%d-%d %d\n",validmode[newvidmode].xdim,validmode[newvidmode].ydim,validmode[newvidmode].bpp,validmode[newvidmode].fs,newvidmode); + if ((curvidmode == 0x7fffffffl && newvidmode == validmodecnt) || curvidmode == newvidmode) + changesmade &= ~1; + else + changesmade |= 1; + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_RightArrow); + break; + + case 1: + { + int lastvidset, lastvidmode, safevidmode = -1; + lastvidset = newvidset; + lastvidmode = newvidmode; + // find the next vidset compatible with the current fullscreen setting + while (vidsets[0] != -1) { + newvidset++; + if (newvidset == sizeof(vidsets)/sizeof(vidsets[0]) || vidsets[newvidset] == -1) { newvidset = -1; continue; } + if (((vidsets[newvidset]>>16)&1) != newfullscreen) continue; + break; + } + + if ((vidsets[newvidset] & 0x0ffff) != (vidsets[lastvidset] & 0x0ffff)) { + // adjust the video mode to something legal for the new vidset + do { + newvidmode++; + if (newvidmode == lastvidmode) break; // end of cycle + if (newvidmode >= validmodecnt) newvidmode = 0; + if (validmode[newvidmode].bpp == (vidsets[newvidset]&0x0ffff) && + validmode[newvidmode].fs == newfullscreen && + validmode[newvidmode].xdim <= validmode[lastvidmode].xdim && + (safevidmode==-1?1:(validmode[newvidmode].xdim>=validmode[safevidmode].xdim)) && + validmode[newvidmode].ydim <= validmode[lastvidmode].ydim && + (safevidmode==-1?1:(validmode[newvidmode].ydim>=validmode[safevidmode].ydim)) + ) + safevidmode = newvidmode; + } while (1); + if (safevidmode == -1) { + //OSD_Printf("No best fit!\n"); + newvidmode = lastvidmode; + newvidset = lastvidset; + } else { + //OSD_Printf("Best fit is %dx%dx%d-%d %d\n",validmode[safevidmode].xdim,validmode[safevidmode].ydim,validmode[safevidmode].bpp,validmode[safevidmode].fs,safevidmode); + newvidmode = safevidmode; + } + } + if (newvidset != curvidset) changesmade |= 4; else changesmade &= ~4; + if (newvidmode != curvidmode) changesmade |= 1; else changesmade &= ~1; + } + break; + + case 2: + newfullscreen = !newfullscreen; + { + int lastvidset, lastvidmode, safevidmode = -1, safevidset = -1; + lastvidset = newvidset; + lastvidmode = newvidmode; + // find the next vidset compatible with the current fullscreen setting + while (vidsets[0] != -1) { + newvidset++; + if (newvidset == lastvidset) break; + if (newvidset == sizeof(vidsets)/sizeof(vidsets[0]) || vidsets[newvidset] == -1) { newvidset = -1; continue; } + if (((vidsets[newvidset]>>16)&1) != newfullscreen) continue; + if ((vidsets[newvidset] & 0x2ffff) != (vidsets[lastvidset] & 0x2ffff)) { + if ((vidsets[newvidset] & 0x20000) == (vidsets[lastvidset] & 0x20000)) safevidset = newvidset; + continue; + } + break; + } + if (newvidset == lastvidset) { + if (safevidset == -1) { + newfullscreen = !newfullscreen; + break; + } else { + newvidset = safevidset; + } + } + + // adjust the video mode to something legal for the new vidset + do { + newvidmode++; + if (newvidmode == lastvidmode) break; // end of cycle + if (newvidmode >= validmodecnt) newvidmode = 0; + if (validmode[newvidmode].bpp == (vidsets[newvidset]&0x0ffff) && + validmode[newvidmode].fs == newfullscreen && + validmode[newvidmode].xdim <= validmode[lastvidmode].xdim && + (safevidmode==-1?1:(validmode[newvidmode].xdim>=validmode[safevidmode].xdim)) && + validmode[newvidmode].ydim <= validmode[lastvidmode].ydim && + (safevidmode==-1?1:(validmode[newvidmode].ydim>=validmode[safevidmode].ydim)) + ) + safevidmode = newvidmode; + } while (1); + if (safevidmode == -1) { + //OSD_Printf("No best fit!\n"); + newvidmode = lastvidmode; + newvidset = lastvidset; + newfullscreen = !newfullscreen; + } else { + //OSD_Printf("Best fit is %dx%dx%d-%d %d\n",validmode[safevidmode].xdim,validmode[safevidmode].ydo,,validmode[safevidmode].bpp,validmode[safevidmode].fs,safevidmode); + newvidmode = safevidmode; + } + if (newvidset != curvidset) changesmade |= 4; else changesmade &= ~4; + if (newvidmode != curvidmode) changesmade |= 1; else changesmade &= ~1; + } + if (newfullscreen == fullscreen) changesmade &= ~2; else changesmade |= 2; + break; + + case 3: + if (!changesmade) break; + { + long pxdim, pydim, pfs, pbpp, prend; + long nxdim, nydim, nfs, nbpp, nrend; + + pxdim = xdim; pydim = ydim; pbpp = bpp; pfs = fullscreen; prend = getrendermode(); + nxdim = (newvidmode==validmodecnt)?xdim:validmode[newvidmode].xdim; + nydim = (newvidmode==validmodecnt)?ydim:validmode[newvidmode].ydim; + nfs = newfullscreen; + nbpp = (newvidmode==validmodecnt)?bpp:validmode[newvidmode].bpp; + nrend = (vidsets[newvidset] & 0x20000) ? (nbpp==8?2:3) : 0; + + if (setgamemode(nfs, nxdim, nydim, nbpp) < 0) { + if (setgamemode(pfs, pxdim, pydim, pbpp) < 0) { + setrendermode(prend); + gameexit("Failed restoring old video mode."); + } else onvideomodechange(pbpp > 8); + } else onvideomodechange(nbpp > 8); + vscrn(); + setrendermode(nrend); + + curvidmode = newvidmode; curvidset = newvidset; + changesmade = 0; + + ScreenMode = fullscreen; + ScreenWidth = xdim; + ScreenHeight = ydim; + ScreenBPP = bpp; + } + break; + + case 4: + break; + +#if defined(POLYMOST) && defined(USE_OPENGL) + case 5: + if (bpp==8) break; + switch (gltexfiltermode) { + case 0: gltexfiltermode = 3; break; + case 3: gltexfiltermode = 5; break; + case 5: gltexfiltermode = 0; break; + default: gltexfiltermode = 3; break; + } + gltexapplyprops(); + break; + + case 6: + if (bpp==8) break; + glanisotropy *= 2; + if (glanisotropy > glinfo.maxanisotropy) glanisotropy = 1; + gltexapplyprops(); + break; +#endif + } + + menutext(c,50,0,0,"RESOLUTION"); + sprintf(tempbuf,"%ld x %ld", + (newvidmode==validmodecnt)?xdim:validmode[newvidmode].xdim, + (newvidmode==validmodecnt)?ydim:validmode[newvidmode].ydim); + gametext(c+154,50-8,tempbuf,0,2+8+16); + + menutext(c,50+16,0,0,"VIDEO MODE"); + sprintf(tempbuf, "%dbit %s", vidsets[newvidset]&0x0ffff, (vidsets[newvidset]&0x20000)?"Polymost":"Classic"); + gametext(c+154,50+16-8,tempbuf,0,2+8+16); + + menutext(c,50+16+16,0,0,"FULLSCREEN"); + menutext(c+154,50+16+16,0,0,newfullscreen?"YES":"NO"); + + menutext(c+16,50+16+16+22,0,changesmade==0,"APPLY CHANGES"); + + menutext(c,50+62+16,SHX(-6),PHX(-6),"BRIGHTNESS"); + { + short ss = ud.brightness; + bar(c+167,50+62+16,&ss,8,x==4,SHX(-6),PHX(-6)); + if(x==4) { + ud.brightness = ss; + setbrightness(ud.brightness>>2,&ps[myconnectindex].palette[0],0); + } + } + +#if defined(POLYMOST) && defined(USE_OPENGL) + menutext(c,50+62+16+16,0,bpp==8,"FILTERING"); + switch (gltexfiltermode) { + case 0: strcpy(tempbuf,"NEAREST"); break; + case 3: strcpy(tempbuf,"BILINEAR"); break; + case 5: strcpy(tempbuf,"TRILINEAR"); break; + default: strcpy(tempbuf,"OTHER"); break; + } + menutext(c+154,50+62+16+16,0,bpp==8,tempbuf); + + menutext(c,50+62+16+16+16,0,bpp==8,"ANISOTROPY"); + if (glanisotropy == 1) strcpy(tempbuf,"NONE"); + else sprintf(tempbuf,"%ld-tap",glanisotropy); + menutext(c+154,50+62+16+16+16,0,bpp==8,tempbuf); +#endif + break; + + case 204: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"KEYS SETUP"); + + c = (320>>1)-120; + + onbar = 0; + x = probe(0,0,0,NUMGAMEFUNCTIONS); + + if (x==-1) { + cmenu(202); + probey = 3; + } else if (x>=0) { + function = probey; + whichkey = currentlist; + cmenu(210); + KB_FlushKeyboardQueue(); + KB_ClearLastScanCode(); + break; + } + + // the top of our list + m = probey - 6; + if (m < 0) m = 0; + else if (m + 13 >= NUMGAMEFUNCTIONS) m = NUMGAMEFUNCTIONS-13; + + if (probey == gamefunc_Show_Console) currentlist = 0; + else if (KB_KeyPressed( sc_LeftArrow ) || KB_KeyPressed( sc_kpad_4 ) || + KB_KeyPressed( sc_RightArrow ) || KB_KeyPressed( sc_kpad_6 ) || + KB_KeyPressed( sc_Tab )) { + currentlist ^= 1; + KB_ClearKeyDown( sc_LeftArrow ); + KB_ClearKeyDown( sc_RightArrow ); + KB_ClearKeyDown( sc_kpad_4 ); + KB_ClearKeyDown( sc_kpad_6 ); + KB_ClearKeyDown( sc_Tab ); + sound(KICK_HIT); + } else if (KB_KeyPressed( sc_Delete )) { + KeyboardKeys[probey][currentlist] = 0; + CONTROL_MapKey( probey, KeyboardKeys[probey][0], KeyboardKeys[probey][1] ); + sound(KICK_HIT); + KB_ClearKeyDown( sc_Delete ); + } + + for (l=0; l < min(13,NUMGAMEFUNCTIONS); l++) { + p = CONFIG_FunctionNumToName(m+l); + if (!p) continue; + + strcpy(tempbuf, p); + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(70,34+l*8,tempbuf,(m+l == probey)?0:16,1,10+16); + + //strcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[m+l][0])); + strcpy(tempbuf, getkeyname(KeyboardKeys[m+l][0])); + if (!tempbuf[0]) strcpy(tempbuf, " -"); + minitextshade(70+100,34+l*8,tempbuf, + (m+l == probey && !currentlist?0:16),2,10+16); + + //strcpy(tempbuf, KB_ScanCodeToString(KeyboardKeys[m+l][1])); + strcpy(tempbuf, getkeyname(KeyboardKeys[m+l][1])); + if (!tempbuf[0]) strcpy(tempbuf, " -"); + minitextshade(70+120+34,34+l*8,tempbuf, + (m+l == probey && currentlist?0:16),2,10+16); + } + + gametext(160,144,"UP/DOWN = SELECT ACTION",0,2+8+16); + gametext(160,144+9,"LEFT/RIGHT = SELECT LIST",0,2+8+16); + gametext(160,144+9+9,"ENTER = MODIFY DELETE = CLEAR",0,2+8+16); + + break; + + case 210: { + int32 sc; + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"KEYS SETUP"); + + gametext(320>>1,90,"PRESS THE KEY TO ASSIGN AS",0,2+8+16); + sprintf(tempbuf,"%s FOR \"%s\"", whichkey?"SECONDARY":"PRIMARY", CONFIG_FunctionNumToName(function)); + gametext(320>>1,90+9,tempbuf,0,2+8+16); + gametext(320>>1,90+9+9+9,"PRESS \"ESCAPE\" TO CANCEL",0,2+8+16); + + sc = KB_GetLastScanCode(); + if ( sc != sc_None ) { + if ( sc == sc_Escape ) { + sound(EXITMENUSOUND); + } else { + sound(PISTOL_BODYHIT); + + KeyboardKeys[function][whichkey] = KB_GetLastScanCode(); + if (function == gamefunc_Show_Console) + OSD_CaptureKey(KB_GetLastScanCode()); + else + CONTROL_MapKey( function, KeyboardKeys[function][0], KeyboardKeys[function][1] ); + } + + cmenu(204); + + currentlist = whichkey; + probey = function; + + KB_ClearKeyDown(sc); + } + + break; + } + case 205: + rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,15,0,0,"MOUSE SETUP"); + + c = 60-4; + + onbar = (probey == (MAXMOUSEBUTTONS-2)*2+2); + if (probey < (MAXMOUSEBUTTONS-2)*2+2) + x = probe(0,0,0,(MAXMOUSEBUTTONS-2)*2+2+2); + else + x = probe(c+6,125-((MAXMOUSEBUTTONS-2)*2+2)*16,16,(MAXMOUSEBUTTONS-2)*2+2+2); + + if (x==-1) { + cmenu(202); + probey = 4; + break; + } else if (x == (MAXMOUSEBUTTONS-2)*2+2) { + // sensitivity + } else if (x == (MAXMOUSEBUTTONS-2)*2+2+1) { + //advanced + cmenu(212); + break; + } else if (x >= 0) { + //set an option + cmenu(211); + function = 0; + whichkey = x; + if (x < (MAXMOUSEBUTTONS-2)*2) + probey = MouseFunctions[x>>1][x&1]; + else + probey = MouseFunctions[x-4][0]; + if (probey < 0) probey = NUMGAMEFUNCTIONS-1; + break; + } + + for (l=0; l < (MAXMOUSEBUTTONS-2)*2+2; l++) { + tempbuf[0] = 0; + if (l < (MAXMOUSEBUTTONS-2)*2) { + if (l&1) { + Bstrcpy(tempbuf, "Double "); + m = MouseFunctions[l>>1][1]; + } else + m = MouseFunctions[l>>1][0]; + Bstrcat(tempbuf, mousebuttonnames[l>>1]); + } else { + Bstrcpy(tempbuf, mousebuttonnames[l-(MAXMOUSEBUTTONS-2)]); + m = MouseFunctions[l-(MAXMOUSEBUTTONS-2)][0]; + } + + minitextshade(c+20,30+l*8,tempbuf,(l==probey)?0:16,1,10+16); + + if (m == -1) + minitextshade(c+100+20,30+l*8," -NONE-",(l==probey)?0:16,2,10+16); + else { + strcpy(tempbuf, CONFIG_FunctionNumToName(m)); + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(c+100+20,30+l*8,tempbuf,(l==probey)?0:16,2,10+16); + } + } + + { + short sense; + sense = CONTROL_GetMouseSensitivity()>>10; + + menutext(c,125,SHX(-7),PHX(-7),"SENSITIVITY"); + bar(c+167,125,&sense,4,x==(MAXMOUSEBUTTONS-2)*2+2,SHX(-7),PHX(-7)); + CONTROL_SetMouseSensitivity( sense<<10 ); + } + + menutext(c,125+16,0,0,"ADVANCED..."); + + if (probey < (MAXMOUSEBUTTONS-2)*2+2) { + gametext(160,149,"UP/DOWN = SELECT BUTTON",0,2+8+16); + gametext(160,149+9,"ENTER = MODIFY",0,2+8+16); + } + break; + + case 211: + rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + if (function == 0) menutext(320>>1,15,0,0,"MOUSE SETUP"); + else if (function == 1) menutext(320>>1,15,0,0,"ADVANCED MOUSE"); + else if (function == 2) menutext(320>>1,15,0,0,"JOYSTICK BUTTONS"); + else if (function == 3) menutext(320>>1,15,0,0,"JOYSTICK AXES"); + + x = probe(0,0,0,NUMGAMEFUNCTIONS); + + if (x==-1) { + if (function == 0) { // mouse button + cmenu(205); + probey = whichkey; + } else if (function == 1) { // mouse digital axis + cmenu(212); + probey = 2+(whichkey^2); + } else if (function == 2) { // joystick button/hat + cmenu(207); + probey = whichkey; + } else if (function == 3) { // joystick digital axis + cmenu((whichkey>>2)+208); + probey = 1+((whichkey>>1)&1)*4+(whichkey&1); + } + break; + } else if (x >= 0) { + if (x == NUMGAMEFUNCTIONS-1) x = -1; + + if (function == 0) { + if (whichkey < (MAXMOUSEBUTTONS-2)*2) { + MouseFunctions[whichkey>>1][whichkey&1] = x; + CONTROL_MapButton( x, whichkey>>1, whichkey&1, controldevice_mouse); + } else { + MouseFunctions[whichkey-(MAXMOUSEBUTTONS-2)][0] = x; + CONTROL_MapButton( x, whichkey-(MAXMOUSEBUTTONS-2), 0, controldevice_mouse); + } + cmenu(205); + probey = whichkey; + } else if (function == 1) { + MouseDigitalFunctions[whichkey>>1][whichkey&1] = x; + CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_mouse); + cmenu(212); + probey = 2+(whichkey^2); + } else if (function == 2) { + if (whichkey < 2*joynumbuttons) { + JoystickFunctions[whichkey>>1][whichkey&1] = x; + CONTROL_MapButton( x, whichkey>>1, whichkey&1, controldevice_joystick); + } else { + JoystickFunctions[joynumbuttons + (whichkey-2*joynumbuttons)][0] = x; + CONTROL_MapButton( x, joynumbuttons + (whichkey-2*joynumbuttons), 0, controldevice_joystick); + } + cmenu(207); + probey = whichkey; + } else if (function == 3) { + JoystickDigitalFunctions[whichkey>>1][whichkey&1] = x; + CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_joystick); + cmenu((whichkey>>2)+208); + probey = 1+((whichkey>>1)&1)*4+(whichkey&1); + } + break; + } + + gametext(320>>1,25,"SELECT A FUNCTION TO ASSIGN",0,2+8+16); + + if (function == 0) { + if (whichkey < (MAXMOUSEBUTTONS-2)*2) + sprintf(tempbuf,"TO %s%s", (whichkey&1)?"DOUBLE-CLICKED ":"", mousebuttonnames[whichkey>>1]); + else + Bstrcpy(tempbuf, mousebuttonnames[whichkey-(MAXMOUSEBUTTONS-2)]); + } else if (function == 1) { + Bstrcpy(tempbuf,"TO DIGITAL "); + switch (whichkey) { + case 0: Bstrcat(tempbuf, "LEFT"); break; + case 1: Bstrcat(tempbuf, "RIGHT"); break; + case 2: Bstrcat(tempbuf, "UP"); break; + case 3: Bstrcat(tempbuf, "DOWN"); break; + } + } else if (function == 2) { + static char *directions[] = { "UP", "RIGHT", "DOWN", "LEFT" }; + if (whichkey < 2*joynumbuttons) + Bsprintf(tempbuf,"TO %s%s", (whichkey&1)?"DOUBLE-CLICKED ":"", getjoyname(1,whichkey>>1)); + else + Bsprintf(tempbuf,"TO HAT %s", directions[whichkey-2*joynumbuttons]); + } else if (function == 3) { + Bsprintf(tempbuf,"TO DIGITAL %s %s",getjoyname(0,whichkey>>1),(whichkey&1)?"POSITIVE":"NEGATIVE"); + } + + gametext(320>>1,25+9,tempbuf,0,2+8+16); + + if (KB_KeyPressed( sc_End )) { KB_ClearKeyDown(sc_End); probey = NUMGAMEFUNCTIONS-1; sound(KICK_HIT); } + else if (KB_KeyPressed( sc_Home )) { KB_ClearKeyDown(sc_Home); probey = 0; sound(KICK_HIT); } + + m = probey - 6; + if (m < 0) m = 0; + else if (m + 13 >= NUMGAMEFUNCTIONS) m = NUMGAMEFUNCTIONS-13; + + for (l=0; l < min(13,NUMGAMEFUNCTIONS); l++) { + if (l+m == NUMGAMEFUNCTIONS-1) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(m+l)); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(100,46+l*8,tempbuf,(m+l == probey)?0:16,10+16); + } + + gametext(320>>1,154,"PRESS \"ESCAPE\" TO CANCEL",0,2+8+16); + + break; + + case 212: + rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,15,0,0,"ADVANCED MOUSE"); + + c = (320>>1)-120; + + onbar = (probey == 0 || probey == 1); + if (probey < 2) + x = probe(c+6,40,16,6); + else if (probey < 6) { + m=50; + x = probe(c+6+10,91-(10+10),10,6); + } else { + x = probe(c+6,140-(16+16+16+16+16+16),16,6); + } + + switch (x) { + case -1: + cmenu(205); + probey = (MAXMOUSEBUTTONS-2)*2+2+1; + break; + + case 0: + // x-axis scale + case 1: + // y-axis scale + break; + + case 2: + // digital up + case 3: + // digital down + case 4: + // digital left + case 5: + // digital right + function = 1; + whichkey = (x-2)^2; // flip the actual axis number + cmenu(211); + probey = MouseDigitalFunctions[whichkey>>1][whichkey&1]; + if (probey < 0) probey = NUMGAMEFUNCTIONS-1; + break; + + case 6: + // analogue x + case 7: + // analogue y + l = MouseAnalogueAxes[x-6]; + if (l == analog_turning) l = analog_strafing; + else if (l == analog_strafing) l = analog_lookingupanddown; + else if (l == analog_lookingupanddown) l = analog_moving; + else if (l == analog_moving) l = -1; + else l = analog_turning; + MouseAnalogueAxes[x-6] = l; + CONTROL_MapAnalogAxis(x-6,l,controldevice_mouse); + break; + + } + + menutext(c,40,0,0,"X-AXIS SCALE"); + l = (MouseAnalogueScale[0]+262144) >> 13; + bar(c+160+40,40,(short *)&l,1,x==0,0,0); + l = (l<<13)-262144; + if (l != MouseAnalogueScale[0]) { + CONTROL_SetAnalogAxisScale( 0, l, controldevice_mouse ); + MouseAnalogueScale[0] = l; + } + Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); + gametext(c+160-16,40-8,tempbuf,0,2+8+16); + + menutext(c,40+16,0,0,"Y-AXIS SCALE"); + l = (MouseAnalogueScale[1]+262144) >> 13; + bar(c+160+40,40+16,(short *)&l,1,x==1,0,0); + l = (l<<13)-262144; + if (l != MouseAnalogueScale[1]) { + CONTROL_SetAnalogAxisScale( 1, l, controldevice_mouse ); + MouseAnalogueScale[1] = l; + } + Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); + gametext(c+160-16,40+16-8,tempbuf,0,2+8+16); + + menutext(c,40+16+16+8,0,0,"DIGITAL AXES ACTIONS"); + + gametext(c+10,84,"UP:",0,2+8+16); + if (MouseDigitalFunctions[1][0] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[1][0])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(c+10+60,85,tempbuf,0,10+16); + + gametext(c+10,84+10,"DOWN:",0,2+8+16); + if (MouseDigitalFunctions[1][1] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[1][1])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(c+10+60,85+10,tempbuf,0,10+16); + + gametext(c+10,84+10+10,"LEFT:",0,2+8+16); + if (MouseDigitalFunctions[0][0] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[0][0])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(c+10+60,85+10+10,tempbuf,0,10+16); + + gametext(c+10,84+10+10+10,"RIGHT:",0,2+8+16); + if (MouseDigitalFunctions[0][1] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(MouseDigitalFunctions[0][1])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(c+10+60,85+10+10+10,tempbuf,0,10+16); + + /* JBF 20040107: It would appear giving these options confuses some tinkerers, so they've + * been moved to the bottom, and hidden in case I dare to reenable them again. + menutext(c,116+16+8,0,0,"ANALOG X"); + if (CONFIG_AnalogNumToName( MouseAnalogueAxes[0] )) { + p = CONFIG_AnalogNumToName( MouseAnalogueAxes[0] ); + if (p) { + gametext(c+148+4,118+16, strchr(p,'_')+1, 0, 2+8+16 ); + } + } + if (probey == 6) gametext(160,158,"Default is \"turning\"",8,2+8+16); + + menutext(c,116+16+16+8,0,0,"ANALOG Y"); + if (CONFIG_AnalogNumToName( MouseAnalogueAxes[1] )) { + p = CONFIG_AnalogNumToName( MouseAnalogueAxes[1] ); + if (p) { + gametext(c+148+4,118+16+16, strchr(p,'_')+1, 0, 2+8+16 ); + } + } + if (probey == 7) gametext(160,158,"Default is \"moving\"",8,2+8+16); + */ + break; + + case 206: + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"JOYSTICK SETUP"); + + x = probe(160,100-18,18,3); + + switch (x) { + case -1: + cmenu(202); + probey = 5; + break; + case 0: + case 1: + cmenu(207+x); + break; + case 2: + cmenu(213); + break; + } + + menutext(160,100-18,0,0,"EDIT BUTTONS"); + menutext(160,100,0,0,"EDIT AXES"); + menutext(160,100+18,0,0,"DEAD ZONES"); + + break; + + case 207: + rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,15,0,0,"JOYSTICK BUTTONS"); + + c = 2*joynumbuttons + 4*(joynumhats>0); + + x = probe(0,0,0,c); + + if (x == -1) { + cmenu(206); + probey = 0; + break; + } else if (x >= 0) { + function = 2; + whichkey = x; + cmenu(211); + if (x < 2*joynumbuttons) { + probey = JoystickFunctions[x>>1][x&1]; + } else { + probey = JoystickFunctions[joynumbuttons + (x-2*joynumbuttons)][0]; + } + if (probey < 0) probey = NUMGAMEFUNCTIONS-1; + break; + } + + // the top of our list + if (c < 13) m = 0; + else { + m = probey - 6; + if (m < 0) m = 0; + else if (m + 13 >= c) m = c-13; + } + + for (l=0; l>1)); + x = JoystickFunctions[(l+m)>>1][(l+m)&1]; + } else { + static char *directions[] = { "Up", "Right", "Down", "Left" }; + sprintf(tempbuf, "Hat %s", directions[(l+m)-2*joynumbuttons]); + x = JoystickFunctions[joynumbuttons + ((l+m)-2*joynumbuttons)][0]; + } + minitextshade(80-4,33+l*8,tempbuf,(m+l == probey)?0:16,1,10+16); + + if (x == -1) + minitextshade(176,33+l*8," -NONE-",(m+l==probey)?0:16,2,10+16); + else { + strcpy(tempbuf, CONFIG_FunctionNumToName(x)); + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitextshade(176,33+l*8,tempbuf,(m+l==probey)?0:16,2,10+16); + } + } + + gametext(160,149,"UP/DOWN = SELECT BUTTON",0,2+8+16); + gametext(160,149+9,"ENTER = MODIFY",0,2+8+16); + break; + + case 208: + case 209: + case 217: + case 218: + case 219: + case 220: + case 221: + case 222: + { + int thispage, twothispage; + + rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,15,0,0,"JOYSTICK AXES"); + + thispage = (current_menu < 217) ? (current_menu-208) : (current_menu-217)+2; + twothispage = (thispage*2+1 < joynumaxes); + + onbar = 0; + switch (probey) { + case 0: + case 4: onbar = 1; x = probe(88,45+(probey==4)*64,0,1+(4< 2) { + if (thispage == ((joynumaxes+1)/2)-1) cmenu(208); + else { + if (current_menu == 209) cmenu(217); + else cmenu( current_menu+1 ); + } + } + break; + + case 4: // bar + if (!twothispage && joynumaxes > 2) + cmenu(208); + case 0: break; + + case 1: // digitals + case 2: + case 5: + case 6: + function = 3; + whichkey = ((thispage*2+(x==5||x==6)) << 1) + (x==2||x==6); + cmenu(211); + probey = JoystickDigitalFunctions[whichkey>>1][whichkey&1]; + if (probey < 0) probey = NUMGAMEFUNCTIONS-1; + break; + + case 3: // analogues + case 7: + l = JoystickAnalogueAxes[thispage*2+(x==7)]; + if (l == analog_turning) l = analog_strafing; + else if (l == analog_strafing) l = analog_lookingupanddown; + else if (l == analog_lookingupanddown) l = analog_moving; + else if (l == analog_moving) l = -1; + else l = analog_turning; + JoystickAnalogueAxes[thispage*2+(x==7)] = l; + CONTROL_MapAnalogAxis(thispage*2+(x==7),l,controldevice_joystick); + break; + default:break; + } + + Bsprintf(tempbuf,getjoyname(0,thispage*2)); + menutext(42,32,0,0,tempbuf); + if (twothispage) + { + Bsprintf(tempbuf,getjoyname(0,thispage*2+1)); + menutext(42,32+64,0,0,tempbuf); + } + gametext(76,38,"SCALE",0,2+8+16); + l = (JoystickAnalogueScale[thispage*2]+262144) >> 13; + bar(140+56,38+8,(short *)&l,1,x==0,0,0); + l = (l<<13)-262144; + if (l != JoystickAnalogueScale[thispage*2]) { + CONTROL_SetAnalogAxisScale( thispage*2, l, controldevice_joystick ); + JoystickAnalogueScale[thispage*2] = l; + } + Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); + gametext(140,38,tempbuf,0,2+8+16); + + gametext(76,38+15,"DIGITAL",0,2+8+16); + if (JoystickDigitalFunctions[thispage*2][0] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2][0])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(140+12,38+15,tempbuf,0,10+16); + + if (JoystickDigitalFunctions[thispage*2][1] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2][1])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(140+12+72,38+15,tempbuf,0,10+16); + + gametext(76,38+15+15,"ANALOG",0,2+8+16); + if (CONFIG_AnalogNumToName( JoystickAnalogueAxes[thispage*2] )) { + p = CONFIG_AnalogNumToName( JoystickAnalogueAxes[thispage*2] ); + if (p) { + gametext(140+12,38+15+15, strchr(p,'_')+1, 0, 2+8+16 ); + } + } + + if (twothispage) { + gametext(76,38+64,"SCALE",0,2+8+16); + l = (JoystickAnalogueScale[thispage*2+1]+262144) >> 13; + bar(140+56,38+8+64,(short *)&l,1,x==4,0,0); + l = (l<<13)-262144; + if (l != JoystickAnalogueScale[thispage*2+1]) { + CONTROL_SetAnalogAxisScale( thispage*2+1, l, controldevice_joystick ); + JoystickAnalogueScale[thispage*2+1] = l; + } + Bsprintf(tempbuf,"%s%.2f",l>=0?" ":"",(float)l/65536.0); + gametext(140,38+64,tempbuf,0,2+8+16); + + gametext(76,38+64+15,"DIGITAL",0,2+8+16); + if (JoystickDigitalFunctions[thispage*2+1][0] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2+1][0])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(140+12,38+15+64,tempbuf,0,10+16); + + if (JoystickDigitalFunctions[thispage*2+1][1] < 0) + strcpy(tempbuf, " -NONE-"); + else + strcpy(tempbuf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[thispage*2+1][1])); + + for (i=0;tempbuf[i];i++) if (tempbuf[i]=='_') tempbuf[i] = ' '; + minitext(140+12+72,38+15+64,tempbuf,0,10+16); + + gametext(76,38+64+15+15,"ANALOG",0,2+8+16); + if (CONFIG_AnalogNumToName( JoystickAnalogueAxes[thispage*2+1] )) { + p = CONFIG_AnalogNumToName( JoystickAnalogueAxes[thispage*2+1] ); + if (p) { + gametext(140+12,38+64+15+15, strchr(p,'_')+1, 0, 2+8+16 ); + } + } + } + + if (joynumaxes > 2) { + menutext(320>>1,twothispage?158:108,SHX(-10),(joynumaxes<=2),"NEXT..."); + sprintf(tempbuf,"Page %d of %d",thispage+1,(joynumaxes+1)/2); + gametext(320-100,158,tempbuf,0,2+8+16); + } + break; + } + + case 213: + case 214: + case 215: + case 216: { // Pray this is enough pages for now :-| + int first,last; + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"JOY DEAD ZONES"); + + first = 4*(current_menu-213); + last = min(4*(current_menu-213)+4,joynumaxes); + + onbar = 1; + x = probe(320,48,15,2*(last-first)+(joynumaxes>4)); + + if (x==-1) { + cmenu(206); + probey = 2; + break; + } else if (x==2*(last-first) && joynumaxes>4) { + cmenu( (current_menu-213) == (joynumaxes/4) ? 213 : (current_menu+1) ); + probey = 0; + break; + } + + for (m=first;m4) { + menutext(32,48+30*(last-first),0,0,"NEXT..."); + sprintf(tempbuf,"Page %d of %d", 1+(current_menu-213), (joynumaxes+3)/4); + gametext(320-100,158,tempbuf,0,2+8+16); + } + break; + } + + case 700: + case 701: + c = (320>>1)-120; + rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"SOUND OPTIONS"); + onbar = ( probey == 2 || probey == 3 ); + + x = probe(c,50,16,7); + switch(x) + { + case -1: + if(ps[myconnectindex].gm&MODE_GAME && current_menu == 701) + { + ps[myconnectindex].gm &= ~MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + } + + else cmenu(202); + probey = 1; + break; + case 0: + if (FXDevice >= 0) + { + SoundToggle = 1-SoundToggle; + if( SoundToggle == 0 ) + { + FX_StopAllSounds(); + clearsoundlocks(); + } + onbar = 0; + } + break; + case 1: + + if(numplayers < 2) + if(MusicDevice >= 0) + { + MusicToggle = 1-MusicToggle; + if( MusicToggle == 0 ) MUSIC_Pause(); + else + { + if(ud.recstat != 2 && ps[myconnectindex].gm&MODE_GAME) + playmusic(&music_fn[0][music_select][0]); + else playmusic(&env_music_fn[0][0]); + + MUSIC_Continue(); + } + } + onbar = 0; + + break; + case 4: + if(SoundToggle && (FXDevice >= 0)) VoiceToggle = 1-VoiceToggle; + onbar = 0; + break; + case 5: + if(SoundToggle && (FXDevice >= 0)) AmbienceToggle = 1-AmbienceToggle; + onbar = 0; + break; + case 6: + if(SoundToggle && (FXDevice >= 0)) + { + ReverseStereo = 1-ReverseStereo; + FX_SetReverseStereo(ReverseStereo); + } + onbar = 0; + break; + default: + onbar = 1; + break; + } + + if(SoundToggle && FXDevice >= 0) menutext(c+160+40,50,0,(FXDevice<0),"ON"); + else menutext(c+160+40,50,0,(FXDevice<0),"OFF"); + + if(MusicToggle && (MusicDevice >= 0) && (numplayers<2)) + menutext(c+160+40,50+16,0,(MusicDevice < 0),"ON"); + else menutext(c+160+40,50+16,0,(MusicDevice < 0),"OFF"); + + menutext(c,50,SHX(-2),(FXDevice<0),"SOUND"); + menutext(c,50+16+16,SHX(-4),(FXDevice<0)||SoundToggle==0,"SOUND VOLUME"); + { + l = FXVolume; + FXVolume >>= 2; + bar(c+167+40,50+16+16,(short *)&FXVolume,4,(FXDevice>=0)&&x==2,SHX(-4),SoundToggle==0||(FXDevice<0)); + if(l != FXVolume) + FXVolume <<= 2; + if(l != FXVolume) + FX_SetVolume( (short) FXVolume ); + } + menutext(c,50+16,SHX(-3),(MusicDevice<0),"MUSIC"); + menutext(c,50+16+16+16,SHX(-5),(MusicDevice<0)||MusicToggle==0,"MUSIC VOLUME"); + { + l = MusicVolume; + MusicVolume >>= 2; + bar(c+167+40,50+16+16+16, + (short *)&MusicVolume,4, + (MusicDevice>=0) && x==3,SHX(-5), + MusicToggle==0||(MusicDevice<0)); + MusicVolume <<= 2; + if(l != MusicVolume) + MUSIC_SetVolume( (short) MusicVolume ); + + } + menutext(c,50+16+16+16+16,SHX(-6),(FXDevice<0)||SoundToggle==0,"DUKE TALK"); + menutext(c,50+16+16+16+16+16,SHX(-7),(FXDevice<0)||SoundToggle==0,"AMBIENCE"); + + menutext(c,50+16+16+16+16+16+16,SHX(-8),(FXDevice<0)||SoundToggle==0,"FLIP STEREO"); + + if(VoiceToggle) menutext(c+160+40,50+16+16+16+16,0,(FXDevice<0)||SoundToggle==0,"ON"); + else menutext(c+160+40,50+16+16+16+16,0,(FXDevice<0)||SoundToggle==0,"OFF"); + + if(AmbienceToggle) menutext(c+160+40,50+16+16+16+16+16,0,(FXDevice<0)||SoundToggle==0,"ON"); + else menutext(c+160+40,50+16+16+16+16+16,0,(FXDevice<0)||SoundToggle==0,"OFF"); + + if(ReverseStereo) menutext(c+160+40,50+16+16+16+16+16+16,0,(FXDevice<0)||SoundToggle==0,"ON"); + else menutext(c+160+40,50+16+16+16+16+16+16,0,(FXDevice<0)||SoundToggle==0,"OFF"); + + + break; + + case 350: + cmenu(351); + screencapt = 1; + displayrooms(myconnectindex,65536); + //savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100); + screencapt = 0; + break; + + case 360: + case 361: + case 362: + case 363: + case 364: + case 365: + case 366: + case 367: + case 368: + case 369: + case 351: + case 300: + + c = 320>>1; + rotatesprite(c<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); + rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + + if(current_menu == 300) menutext(c,24,0,0,"LOAD GAME"); + else menutext(c,24,0,0,"SAVE GAME"); + + if(current_menu >= 360 && current_menu <= 369 ) + { + sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); + gametext(160,156,tempbuf,0,2+8+16); + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); + gametext(160,168,tempbuf,0,2+8+16); + if (ud.volume_number == 0 && ud.level_number == 7) + gametext(160,180,boardfilename,0,2+8+16); + + x = strget((320>>1),184,&ud.savegame[current_menu-360][0],19, 999 ); + + if(x == -1) + { + // readsavenames(); + ps[myconnectindex].gm = MODE_GAME; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + goto DISPLAYNAMES; + } + + if( x == 1 ) + { + if( ud.savegame[current_menu-360][0] == 0 ) + { + KB_FlushKeyboardQueue(); + cmenu(351); + } + else + { + if(ud.multimode > 1) + saveplayer(-1-(current_menu-360)); + else saveplayer(current_menu-360); + lastsavedpos = current_menu-360; + ps[myconnectindex].gm = MODE_GAME; + + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + KB_ClearKeyDown(sc_Escape); + sound(EXITMENUSOUND); + } + } + + rotatesprite(101<<16,97<<16,65536>>1,512,TILE_SAVESHOT,-32,0,2+4+8+64,0,0,xdim-1,ydim-1); + dispnames(); + rotatesprite((c+67+strlen(&ud.savegame[current_menu-360][0])*4)<<16,(50+12*probey)<<16,32768L-10240,0,SPINNINGNUKEICON+(((totalclock)>>3)%7),0,0,10,0,0,xdim-1,ydim-1); + break; + } + + last_threehundred = probey; + + x = probe(c+68,54,12,10); + + if(current_menu == 300) + { + if( ud.savegame[probey][0] ) + { + if( lastprobey != probey ) + { + loadpheader(probey,&savehead); + lastprobey = probey; + } + + rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); + sprintf(tempbuf,"PLAYERS: %-2ld ",savehead.numplr); + gametext(160,156,tempbuf,0,2+8+16); + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+savehead.volnum,1+savehead.levnum,savehead.plrskl); + gametext(160,168,tempbuf,0,2+8+16); + if (savehead.volnum == 0 && savehead.levnum == 7) + gametext(160,180,savehead.boardfn,0,2+8+16); + } + else menutext(69,70,0,0,"EMPTY"); + } + else + { + if( ud.savegame[probey][0] ) + { + if(lastprobey != probey) + loadpheader(probey,&savehead); + lastprobey = probey; + rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); + } + else menutext(69,70,0,0,"EMPTY"); + sprintf(tempbuf,"PLAYERS: %-2ld ",ud.multimode); + gametext(160,156,tempbuf,0,2+8+16); + sprintf(tempbuf,"EPISODE: %-2ld / LEVEL: %-2ld / SKILL: %-2ld",1+ud.volume_number,1+ud.level_number,ud.player_skill); + gametext(160,168,tempbuf,0,2+8+16); + if (ud.volume_number == 0 && ud.level_number == 7) + gametext(160,180,boardfilename,0,2+8+16); + } + + switch( x ) + { + case -1: + if(current_menu == 300) + { + if( (ps[myconnectindex].gm&MODE_GAME) != MODE_GAME) + { + cmenu(0); + break; + } + else + ps[myconnectindex].gm &= ~MODE_MENU; + } + else + ps[myconnectindex].gm = MODE_GAME; + + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + + break; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + if( current_menu == 300) + { + if( ud.savegame[x][0] ) + current_menu = (1000+x); + } + else + { + if( ud.savegame[x][0] != 0) + current_menu = 2000+x; + else + { + KB_FlushKeyboardQueue(); + current_menu = (360+x); + ud.savegame[x][0] = 0; + inputloc = 0; + } + } + break; + } + +DISPLAYNAMES: + dispnames(); + break; + + case 400: + case 401: + if (VOLUMEALL) goto VOLUME_ALL_40x; + case 402: + case 403: + + c = 320>>1; + + if( KB_KeyPressed( sc_LeftArrow ) || + KB_KeyPressed( sc_kpad_4 ) || + KB_KeyPressed( sc_UpArrow ) || + KB_KeyPressed( sc_PgUp ) || + KB_KeyPressed( sc_kpad_8 ) ) + { + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_PgUp); + KB_ClearKeyDown(sc_kpad_8); + + sound(KICK_HIT); + current_menu--; + if(current_menu < 400) current_menu = 403; + } + else if( + KB_KeyPressed( sc_PgDn ) || + KB_KeyPressed( sc_Enter ) || + KB_KeyPressed( sc_kpad_Enter ) || + KB_KeyPressed( sc_RightArrow ) || + KB_KeyPressed( sc_DownArrow ) || + KB_KeyPressed( sc_kpad_2 ) || + KB_KeyPressed( sc_kpad_9 ) || + KB_KeyPressed( sc_Space ) || + KB_KeyPressed( sc_kpad_6 ) ) + { + KB_ClearKeyDown(sc_PgDn); + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_Enter); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_kpad_9); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_Space); + sound(KICK_HIT); + current_menu++; + if(current_menu > 403) current_menu = 400; + } + + if( KB_KeyPressed(sc_Escape) ) + { + if(ps[myconnectindex].gm&MODE_GAME) + cmenu(50); + else cmenu(0); + return; + } + + flushperms(); + rotatesprite(0,0,65536L,0,ORDERING+current_menu-400,0,0,10+16+64,0,0,xdim-1,ydim-1); + + break; +VOLUME_ALL_40x: + + c = 320>>1; + + if( KB_KeyPressed( sc_LeftArrow ) || + KB_KeyPressed( sc_kpad_4 ) || + KB_KeyPressed( sc_UpArrow ) || + KB_KeyPressed( sc_PgUp ) || + KB_KeyPressed( sc_kpad_8 ) ) + { + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_PgUp); + KB_ClearKeyDown(sc_kpad_8); + + sound(KICK_HIT); + current_menu--; + if(current_menu < 400) current_menu = 401; + } + else if( + KB_KeyPressed( sc_PgDn ) || + KB_KeyPressed( sc_Enter ) || + KB_KeyPressed( sc_kpad_Enter ) || + KB_KeyPressed( sc_RightArrow ) || + KB_KeyPressed( sc_DownArrow ) || + KB_KeyPressed( sc_kpad_2 ) || + KB_KeyPressed( sc_kpad_9 ) || + KB_KeyPressed( sc_Space ) || + KB_KeyPressed( sc_kpad_6 ) ) + { + KB_ClearKeyDown(sc_PgDn); + KB_ClearKeyDown(sc_Enter); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_Enter); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_kpad_9); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_Space); + sound(KICK_HIT); + current_menu++; + if(current_menu > 401) current_menu = 400; + } + + if( KB_KeyPressed(sc_Escape) ) + { + if(ps[myconnectindex].gm&MODE_GAME) + cmenu(50); + else cmenu(0); + return; + } + + flushperms(); + switch(current_menu) + { + case 400: + rotatesprite(0,0,65536L,0,TEXTSTORY,0,0,10+16+64, 0,0,xdim-1,ydim-1); + break; + case 401: + rotatesprite(0,0,65536L,0,F1HELP,0,0,10+16+64, 0,0,xdim-1,ydim-1); + break; + } + + break; + + case 500: + c = 320>>1; + + gametext(c,90,"Are you sure you want to quit?",0,2+8+16); + gametext(c,99,"(Y/N)",0,2+8+16); + + if( KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB ) + { + KB_FlushKeyboardQueue(); + + if( gamequit == 0 && ( numplayers > 1 ) ) + { + if(ps[myconnectindex].gm&MODE_GAME) + { + gamequit = 1; + quittimer = totalclock+120; + } + else + { + sendlogoff(); + gameexit(" "); + } + } + else if( numplayers < 2 ) + gameexit(" "); + + if( ( totalclock > quittimer ) && ( gamequit == 1) ) + gameexit("Timed out."); + } + + x = probe(186,124,0,0); + if(x == -1 || KB_KeyPressed(sc_N) || RMB) + { + KB_ClearKeyDown(sc_N); + quittimer = 0; + if( ps[myconnectindex].gm&MODE_DEMO ) + ps[myconnectindex].gm = MODE_DEMO; + else + { + ps[myconnectindex].gm &= ~MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + } + } + + break; + case 501: + c = 320>>1; + gametext(c,90,"Quit to Title?",0,2+8+16); + gametext(c,99,"(Y/N)",0,2+8+16); + + if( KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB ) + { + KB_FlushKeyboardQueue(); + ps[myconnectindex].gm = MODE_DEMO; + if(ud.recstat == 1) + closedemowrite(); + cmenu(0); + } + + x = probe(186,124,0,0); + + if(x == -1 || KB_KeyPressed(sc_N) || RMB) + { + ps[myconnectindex].gm &= ~MODE_MENU; + if(ud.multimode < 2 && ud.recstat != 2) + { + ready2send = 1; + totalclock = ototalclock; + } + } + + break; + + case 601: + displayfragbar(); + rotatesprite(160<<16,29<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,34,0,0,&ud.user_name[myconnectindex][0]); + + sprintf(tempbuf,"Waiting for master"); + gametext(160,50,tempbuf,0,2+8+16); + gametext(160,59,"to select level",0,2+8+16); + + if( KB_KeyPressed(sc_Escape) ) + { + KB_ClearKeyDown(sc_Escape); + sound(EXITMENUSOUND); + cmenu(0); + } + break; + + case 602: + if(menunamecnt == 0) + { + // getfilenames("SUBD"); + getfilenames(".","*.MAP"); + if (menunamecnt == 0) + cmenu(600); + } + case 603: + c = (320>>1) - 120; + displayfragbar(); + rotatesprite(320>>1<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(320>>1,24,0,0,"USER MAPS"); + for(x=0;x 256 ) ) + { + KB_ClearKeyDown( sc_RightArrow ); + KB_ClearKeyDown( sc_kpad_6 ); + probey += 15; + if(probey >= menunamecnt) + probey -= 15; + else sound(KICK_HIT); + } + + onbar = 0; + x = probe(0,0,0,menunamecnt); + + if(x == -1) cmenu(600); + else if(x >= 0) + { + tempbuf[0] = 8; + tempbuf[1] = ud.m_level_number = 6; + tempbuf[2] = ud.m_volume_number = 0; + tempbuf[3] = ud.m_player_skill+1; + + if(ud.player_skill == 3) + ud.m_respawn_monsters = 1; + else ud.m_respawn_monsters = 0; + + if(ud.m_coop == 0) ud.m_respawn_items = 1; + else ud.m_respawn_items = 0; + + ud.m_respawn_inventory = 1; + + tempbuf[4] = ud.m_monsters_off; + tempbuf[5] = ud.m_respawn_monsters; + tempbuf[6] = ud.m_respawn_items; + tempbuf[7] = ud.m_respawn_inventory; + tempbuf[8] = ud.m_coop; + tempbuf[9] = ud.m_marker; + + x = strlen(menuname[probey]); + + copybufbyte(menuname[probey],tempbuf+10,x); + copybufbyte(menuname[probey],boardfilename,x+1); + + for(c=connecthead;c>=0;c=connectpoint2[c]) + { + if (c != myconnectindex) sendpacket(c,tempbuf,x+10); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill+1); + if (enterlevel(MODE_GAME)) backtomenu(); + } + break; + + case 600: + c = (320>>1) - 120; + if((ps[myconnectindex].gm&MODE_GAME) != MODE_GAME) + displayfragbar(); + rotatesprite(160<<16,26<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); + menutext(160,31,0,0,&ud.user_name[myconnectindex][0]); + + x = probe(c,57-8,16,8); + + switch(x) + { + case -1: + ud.m_recstat = 0; + if(ps[myconnectindex].gm&MODE_GAME) cmenu(50); + else cmenu(0); + break; + case 0: + ud.m_coop++; + if(ud.m_coop == num_gametypes) ud.m_coop = 0; + break; + case 1: + if (!VOLUMEONE) { + ud.m_volume_number++; + if(ud.m_volume_number == num_volumes) ud.m_volume_number = 0; + if(ud.m_volume_number == 0 && ud.m_level_number > 6) + ud.m_level_number = 0; + if(ud.m_level_number > 10) ud.m_level_number = 0; + } + break; + case 2: + ud.m_level_number++; + if (!VOLUMEONE) { + if(ud.m_volume_number == 0 && ud.m_level_number > 6) + ud.m_level_number = 0; + } else { + if(ud.m_volume_number == 0 && ud.m_level_number > 5) + ud.m_level_number = 0; + } + if(ud.m_level_number > 10) ud.m_level_number = 0; + break; + case 3: + if(ud.m_monsters_off == 1 && ud.m_player_skill > 0) + ud.m_monsters_off = 0; + + if(ud.m_monsters_off == 0) + { + ud.m_player_skill++; + if(ud.m_player_skill > 3) + { + ud.m_player_skill = 0; + ud.m_monsters_off = 1; + } + } + else ud.m_monsters_off = 0; + + break; + + case 4: + if((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION)) + ud.m_marker = !ud.m_marker; + break; + + case 5: + if((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_COOP)) + ud.m_ffire = !ud.m_ffire; + break; + + case 6: + if (VOLUMEALL) { + if(boardfilename[0] == 0) break; + + tempbuf[0] = 5; + tempbuf[1] = ud.m_level_number = 7; + tempbuf[2] = ud.m_volume_number = 0; + tempbuf[3] = ud.m_player_skill+1; + + ud.level_number = ud.m_level_number; + ud.volume_number = ud.m_volume_number; + + if( ud.m_player_skill == 3 ) ud.m_respawn_monsters = 1; + else ud.m_respawn_monsters = 0; + + if((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_ITEMRESPAWN)) ud.m_respawn_items = 1; + else ud.m_respawn_items = 0; + + ud.m_respawn_inventory = 1; + + tempbuf[4] = ud.m_monsters_off; + tempbuf[5] = ud.m_respawn_monsters; + tempbuf[6] = ud.m_respawn_items; + tempbuf[7] = ud.m_respawn_inventory; + tempbuf[8] = ud.m_coop; + tempbuf[9] = ud.m_marker; + tempbuf[10] = ud.m_ffire; + + for(c=connecthead;c>=0;c=connectpoint2[c]) + { + resetweapons(c); + resetinventory(c); + + } + for(c=connecthead;c>=0;c=connectpoint2[c]) + { + if (c != myconnectindex) sendpacket(c,tempbuf,11); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill+1); + if (enterlevel(MODE_GAME)) backtomenu(); + + return; + } + case 7: + + tempbuf[0] = 5; + tempbuf[1] = ud.m_level_number; + tempbuf[2] = ud.m_volume_number; + tempbuf[3] = ud.m_player_skill+1; + + if( ud.m_player_skill == 3 ) ud.m_respawn_monsters = 1; + else ud.m_respawn_monsters = 0; + + if((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_ITEMRESPAWN)) ud.m_respawn_items = 1; + else ud.m_respawn_items = 0; + + ud.m_respawn_inventory = 1; + + tempbuf[4] = ud.m_monsters_off; + tempbuf[5] = ud.m_respawn_monsters; + tempbuf[6] = ud.m_respawn_items; + tempbuf[7] = ud.m_respawn_inventory; + tempbuf[8] = ud.m_coop; + tempbuf[9] = ud.m_marker; + tempbuf[10] = ud.m_ffire; + + for(c=connecthead;c>=0;c=connectpoint2[c]) + { + resetweapons(c); + resetinventory(c); + + } + for(c=connecthead;c>=0;c=connectpoint2[c]) + { + if(c != myconnectindex) sendpacket(c,tempbuf,11); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill+1); + if (enterlevel(MODE_GAME)) backtomenu(); + + return; + + } + + c += 40; + + //if(ud.m_coop==1) gametext(c+70,57-7-9,"COOPERATIVE PLAY",0,2+8+16); + //else if(ud.m_coop==2) gametext(c+70,57-7-9,"DUKEMATCH (NO SPAWN)",0,2+8+16); + //else gametext(c+70,57-7-9,"DUKEMATCH (SPAWN)",0,2+8+16); + gametext(c+70,57-7-9,gametype_names[ud.m_coop],0,2+8+16); + if (VOLUMEONE) { + gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],0,2+8+16); + } else { + gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],0,2+8+16); + } + + gametext(c+70,57+16+16-7-9,&level_names[11*ud.m_volume_number+ud.m_level_number][0],0,2+8+16); + + if(ud.m_monsters_off == 0 || ud.m_player_skill > 0) + gametext(c+70,57+16+16+16-7-9,skill_names[ud.m_player_skill],0,2+8+16); + else gametext(c+70,57+16+16+16-7-9,"NONE",0,2+8+16); + + if(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION) + { + if(ud.m_marker) + gametext(c+70,57+16+16+16+16-7-9,"ON",0,2+8+16); + else gametext(c+70,57+16+16+16+16-7-9,"OFF",0,2+8+16); + } + + if(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_COOP) + { + if(ud.m_ffire) + gametext(c+70,57+16+16+16+16+16-7-9,"ON",0,2+8+16); + else gametext(c+70,57+16+16+16+16+16-7-9,"OFF",0,2+8+16); + } + + c -= 44; + + menutext(c,57-9,SHX(-2),PHX(-2),"GAME TYPE"); + + if (VOLUMEONE) { + sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); + menutext(c,57+16-9,SHX(-3),1,tempbuf); + } else { + sprintf(tempbuf,"EPISODE %ld",ud.m_volume_number+1); + menutext(c,57+16-9,SHX(-3),PHX(-3),tempbuf); + } + + sprintf(tempbuf,"LEVEL %ld",ud.m_level_number+1); + menutext(c,57+16+16-9,SHX(-4),PHX(-4),tempbuf); + + menutext(c,57+16+16+16-9,SHX(-5),PHX(-5),"MONSTERS"); + + if(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION) + menutext(c,57+16+16+16+16-9,SHX(-6),PHX(-6),"MARKERS"); + else + menutext(c,57+16+16+16+16-9,SHX(-6),1,"MARKERS"); + + if(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_COOP) + menutext(c,57+16+16+16+16+16-9,SHX(-6),PHX(-6),"FR. FIRE"); + else menutext(c,57+16+16+16+16+16-9,SHX(-6),1,"FR. FIRE"); + + if (VOLUMEALL) { + menutext(c,57+16+16+16+16+16+16-9,SHX(-7),boardfilename[0] == 0,"USER MAP"); + if( boardfilename[0] != 0 ) + gametext(c+70+44,57+16+16+16+16+16,boardfilename,0,2+8+16); + } else { + menutext(c,57+16+16+16+16+16+16-9,SHX(-7),1,"USER MAP"); + } + + menutext(c,57+16+16+16+16+16+16+16-9,SHX(-8),PHX(-8),"START GAME"); + + break; + } + + if( (ps[myconnectindex].gm&MODE_MENU) != MODE_MENU) + { + vscrn(); + cameraclock = totalclock; + cameradist = 65536L; + } +} diff --git a/polymer/eduke32/source/misc/buildres.rc b/polymer/eduke32/source/misc/buildres.rc new file mode 100644 index 000000000..5f22e6354 --- /dev/null +++ b/polymer/eduke32/source/misc/buildres.rc @@ -0,0 +1,30 @@ +#include + +100 ICON "rsrc/build_icon.ico" +200 BITMAP "rsrc/build.bmp" + +1000 DIALOGEX DISCARDABLE 20, 40, 265, 233 +STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU +CAPTION "Startup" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255 + CONTROL "Starting Build Editor for Duke Nukem 3D...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8 + CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138 +END + +2000 DIALOGEX DISCARDABLE 20, 40, 279, 168 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL +CAPTION "Dialog" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "Video mode", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 3, 128, 64 + CONTROL "&Fullscreen", 100, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 15, 49, 10 + CONTROL "&2D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 30, 37, 8 + CONTROL "", 101, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 28, 75, 56 + CONTROL "&3D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 47, 37, 8 + CONTROL "", 102, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 46, 75, 56 + CONTROL "&Continue", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 140, 145, 64, 17 + CONTROL "E&xit", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 208, 145, 64, 17 +END + diff --git a/polymer/eduke32/source/misc/gameres.rc b/polymer/eduke32/source/misc/gameres.rc new file mode 100644 index 000000000..df1d1c2f2 --- /dev/null +++ b/polymer/eduke32/source/misc/gameres.rc @@ -0,0 +1,14 @@ +#include + +100 ICON "rsrc/game_icon.ico" +200 BITMAP "rsrc/game.bmp" + +1000 DIALOGEX DISCARDABLE 20, 40, 265, 233 +STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU +CAPTION "Startup" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255 + CONTROL "Starting EDuke32...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8 + CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138 +END diff --git a/polymer/eduke32/source/names.h b/polymer/eduke32/source/names.h new file mode 100644 index 000000000..aa4803f84 --- /dev/null +++ b/polymer/eduke32/source/names.h @@ -0,0 +1,766 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2004, 2005 - Richard Gobeille (EDuke32 functionality) + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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 +*/ +//------------------------------------------------------------------------- + +#define SECTOREFFECTOR 1 +#define ACTIVATOR 2 +#define TOUCHPLATE 3 +#define ACTIVATORLOCKED 4 +#define MUSICANDSFX 5 +#define LOCATORS 6 +#define CYCLER 7 +#define MASTERSWITCH 8 +#define RESPAWN 9 +#define GPSPEED 10 +#define FOF 13 +#define ARROW 20 +#define FIRSTGUNSPRITE 21 +#define CHAINGUNSPRITE 22 +#define RPGSPRITE 23 +#define FREEZESPRITE 24 +#define SHRINKERSPRITE 25 +#define HEAVYHBOMB 26 +#define TRIPBOMBSPRITE 27 +#define SHOTGUNSPRITE 28 +#define DEVISTATORSPRITE 29 +#define HEALTHBOX 30 +#define AMMOBOX 31 +#define GROWSPRITEICON 32 +#define INVENTORYBOX 33 +#define FREEZEAMMO 37 +#define AMMO 40 +#define BATTERYAMMO 41 +#define DEVISTATORAMMO 42 +#define RPGAMMO 44 +#define GROWAMMO 45 +#define CRYSTALAMMO 46 +#define HBOMBAMMO 47 +#define AMMOLOTS 48 +#define SHOTGUNAMMO 49 +#define COLA 51 +#define SIXPAK 52 +#define FIRSTAID 53 +#define SHIELD 54 +#define STEROIDS 55 +#define AIRTANK 56 +#define JETPACK 57 +#define HEATSENSOR 59 +#define ACCESSCARD 60 +#define BOOTS 61 +#define MIRRORBROKE 70 +#define CLOUDYOCEAN 78 +#define CLOUDYSKIES 79 +#define MOONSKY1 80 +#define MOONSKY2 81 +#define MOONSKY3 82 +#define MOONSKY4 83 +#define BIGORBIT1 84 +#define BIGORBIT2 85 +#define BIGORBIT3 86 +#define BIGORBIT4 87 +#define BIGORBIT5 88 +#define LA 89 +#define REDSKY1 98 +#define REDSKY2 99 +#define ATOMICHEALTH 100 +#define TECHLIGHT2 120 +#define TECHLIGHTBUST2 121 +#define TECHLIGHT4 122 +#define TECHLIGHTBUST4 123 +#define WALLLIGHT4 124 +#define WALLLIGHTBUST4 125 +#define ACCESSSWITCH 130 +#define SLOTDOOR 132 +#define LIGHTSWITCH 134 +#define SPACEDOORSWITCH 136 +#define SPACELIGHTSWITCH 138 +#define FRANKENSTINESWITCH 140 +#define NUKEBUTTON 142 +#define MULTISWITCH 146 +#define DOORTILE5 150 +#define DOORTILE6 151 +#define DOORTILE1 152 +#define DOORTILE2 153 +#define DOORTILE3 154 +#define DOORTILE4 155 +#define DOORTILE7 156 +#define DOORTILE8 157 +#define DOORTILE9 158 +#define DOORTILE10 159 +#define DOORSHOCK 160 +#define DIPSWITCH 162 +#define DIPSWITCH2 164 +#define TECHSWITCH 166 +#define DIPSWITCH3 168 +#define ACCESSSWITCH2 170 +#define REFLECTWATERTILE 180 +#define FLOORSLIME 200 +#define BIGFORCE 230 +#define EPISODE 247 +#define MASKWALL9 255 +#define W_LIGHT 260 +#define SCREENBREAK1 263 +#define SCREENBREAK2 264 +#define SCREENBREAK3 265 +#define SCREENBREAK4 266 +#define SCREENBREAK5 267 +#define SCREENBREAK6 268 +#define SCREENBREAK7 269 +#define SCREENBREAK8 270 +#define SCREENBREAK9 271 +#define SCREENBREAK10 272 +#define SCREENBREAK11 273 +#define SCREENBREAK12 274 +#define SCREENBREAK13 275 +#define MASKWALL1 285 +#define W_TECHWALL1 293 +#define W_TECHWALL2 297 +#define W_TECHWALL15 299 +#define W_TECHWALL3 301 +#define W_TECHWALL4 305 +#define W_TECHWALL10 306 +#define W_TECHWALL16 307 +#define WATERTILE2 336 +#define BPANNEL1 341 +#define PANNEL1 342 +#define PANNEL2 343 +#define WATERTILE 344 +#define STATIC 351 +#define W_SCREENBREAK 357 +#define W_HITTECHWALL3 360 +#define W_HITTECHWALL4 361 +#define W_HITTECHWALL2 362 +#define W_HITTECHWALL1 363 +#define MASKWALL10 387 +#define MASKWALL11 391 +#define DOORTILE22 395 +#define FANSPRITE 407 +#define FANSPRITEBROKE 411 +#define FANSHADOW 412 +#define FANSHADOWBROKE 416 +#define DOORTILE18 447 +#define DOORTILE19 448 +#define DOORTILE20 449 +// #define SPACESHUTTLE 487 +#define SATELLITE 489 +#define VIEWSCREEN2 499 +#define VIEWSCREENBROKE 501 +#define VIEWSCREEN 502 +#define GLASS 503 +#define GLASS2 504 +#define STAINGLASS1 510 +#define MASKWALL5 514 +#define SATELITE 516 +#define FUELPOD 517 +#define SLIMEPIPE 538 +#define CRACK1 546 +#define CRACK2 547 +#define CRACK3 548 +#define CRACK4 549 +#define FOOTPRINTS 550 +#define DOMELITE 551 +#define CAMERAPOLE 554 +#define CHAIR1 556 +#define CHAIR2 557 +#define BROKENCHAIR 559 +#define MIRROR 560 +#define WATERFOUNTAIN 563 +#define WATERFOUNTAINBROKE 567 +#define FEMMAG1 568 +#define TOILET 569 +#define STALL 571 +#define STALLBROKE 573 +#define FEMMAG2 577 +#define REACTOR2 578 +#define REACTOR2BURNT 579 +#define REACTOR2SPARK 580 +#define GRATE1 595 +#define BGRATE1 596 +#define SOLARPANNEL 602 +#define NAKED1 603 +#define ANTENNA 607 +#define MASKWALL12 609 +#define TOILETBROKE 615 +#define PIPE2 616 +#define PIPE1B 617 +#define PIPE3 618 +#define PIPE1 619 +#define CAMERA1 621 +#define BRICK 626 +#define SPLINTERWOOD 630 +#define PIPE2B 633 +#define BOLT1 634 +#define W_NUMBERS 640 +#define WATERDRIP 660 +#define WATERBUBBLE 661 +#define WATERBUBBLEMAKER 662 +#define W_FORCEFIELD 663 +#define VACUUM 669 +#define FOOTPRINTS2 672 +#define FOOTPRINTS3 673 +#define FOOTPRINTS4 674 +#define EGG 675 +#define SCALE 678 +#define CHAIR3 680 +#define CAMERALIGHT 685 +#define MOVIECAMERA 686 +#define IVUNIT 689 +#define POT1 694 +#define POT2 695 +#define POT3 697 +#define PIPE3B 700 +#define WALLLIGHT3 701 +#define WALLLIGHTBUST3 702 +#define WALLLIGHT1 703 +#define WALLLIGHTBUST1 704 +#define WALLLIGHT2 705 +#define WALLLIGHTBUST2 706 +#define LIGHTSWITCH2 712 +#define WAITTOBESEATED 716 +#define DOORTILE14 717 +#define STATUE 753 +#define MIKE 762 +#define VASE 765 +#define SUSHIPLATE1 768 +#define SUSHIPLATE2 769 +#define SUSHIPLATE3 774 +#define SUSHIPLATE4 779 +#define DOORTILE16 781 +#define SUSHIPLATE5 792 +#define OJ 806 +#define MASKWALL13 830 +#define HURTRAIL 859 +#define POWERSWITCH1 860 +#define LOCKSWITCH1 862 +#define POWERSWITCH2 864 +#define ATM 867 +#define STATUEFLASH 869 +#define ATMBROKE 888 +#define BIGHOLE2 893 +#define STRIPEBALL 901 +#define QUEBALL 902 +#define POCKET 903 +#define WOODENHORSE 904 +#define TREE1 908 +#define TREE2 910 +#define CACTUS 911 +#define MASKWALL2 913 +#define MASKWALL3 914 +#define MASKWALL4 915 +#define FIREEXT 916 +#define TOILETWATER 921 +#define NEON1 925 +#define NEON2 926 +#define CACTUSBROKE 939 +#define BOUNCEMINE 940 +#define BROKEFIREHYDRENT 950 +#define BOX 951 +#define BULLETHOLE 952 +#define BOTTLE1 954 +#define BOTTLE2 955 +#define BOTTLE3 956 +#define BOTTLE4 957 +#define FEMPIC5 963 +#define FEMPIC6 964 +#define FEMPIC7 965 +#define HYDROPLANT 969 +#define OCEANSPRITE1 971 +#define OCEANSPRITE2 972 +#define OCEANSPRITE3 973 +#define OCEANSPRITE4 974 +#define OCEANSPRITE5 975 +#define GENERICPOLE 977 +#define CONE 978 +#define HANGLIGHT 979 +#define HYDRENT 981 +#define MASKWALL14 988 +#define TIRE 990 +#define PIPE5 994 +#define PIPE6 995 +#define PIPE4 996 +#define PIPE4B 997 +#define BROKEHYDROPLANT 1003 +#define PIPE5B 1005 +#define NEON3 1007 +#define NEON4 1008 +#define NEON5 1009 +#define BOTTLE5 1012 +#define BOTTLE6 1013 +#define BOTTLE8 1014 +#define SPOTLITE 1020 +#define HANGOOZ 1022 +#define MASKWALL15 1024 +#define BOTTLE7 1025 +#define HORSEONSIDE 1026 +#define GLASSPIECES 1031 +#define HORSELITE 1034 +#define DONUTS 1045 +#define NEON6 1046 +#define MASKWALL6 1059 +#define CLOCK 1060 +#define RUBBERCAN 1062 +#define BROKENCLOCK 1067 +#define PLUG 1069 +#define OOZFILTER 1079 +#define FLOORPLASMA 1082 +#define REACTOR 1088 +#define REACTORSPARK 1092 +#define REACTORBURNT 1096 +#define DOORTILE15 1102 +#define HANDSWITCH 1111 +#define CIRCLEPANNEL 1113 +#define CIRCLEPANNELBROKE 1114 +#define PULLSWITCH 1122 +#define MASKWALL8 1124 +#define BIGHOLE 1141 +#define ALIENSWITCH 1142 +#define DOORTILE21 1144 +#define HANDPRINTSWITCH 1155 +#define BOTTLE10 1157 +#define BOTTLE11 1158 +#define BOTTLE12 1159 +#define BOTTLE13 1160 +#define BOTTLE14 1161 +#define BOTTLE15 1162 +#define BOTTLE16 1163 +#define BOTTLE17 1164 +#define BOTTLE18 1165 +#define BOTTLE19 1166 +#define DOORTILE17 1169 +#define MASKWALL7 1174 +#define JAILBARBREAK 1175 +#define DOORTILE11 1178 +#define DOORTILE12 1179 +#define VENDMACHINE 1212 +#define VENDMACHINEBROKE 1214 +#define COLAMACHINE 1215 +#define COLAMACHINEBROKE 1217 +#define CRANEPOLE 1221 +#define CRANE 1222 +#define BARBROKE 1225 +#define BLOODPOOL 1226 +#define NUKEBARREL 1227 +#define NUKEBARRELDENTED 1228 +#define NUKEBARRELLEAKED 1229 +#define CANWITHSOMETHING 1232 +#define MONEY 1233 +#define BANNER 1236 +#define EXPLODINGBARREL 1238 +#define EXPLODINGBARREL2 1239 +#define FIREBARREL 1240 +#define SEENINE 1247 +#define SEENINEDEAD 1248 +#define STEAM 1250 +#define CEILINGSTEAM 1255 +#define PIPE6B 1260 +#define TRANSPORTERBEAM 1261 +#define RAT 1267 +#define TRASH 1272 +#define FEMPIC1 1280 +#define FEMPIC2 1289 +#define BLANKSCREEN 1293 +#define PODFEM1 1294 +#define FEMPIC3 1298 +#define FEMPIC4 1306 +#define FEM1 1312 +#define FEM2 1317 +#define FEM3 1321 +#define FEM5 1323 +#define BLOODYPOLE 1324 +#define FEM4 1325 +#define FEM6 1334 +#define FEM6PAD 1335 +#define FEM8 1336 +#define HELECOPT 1346 +#define FETUSJIB 1347 +#define HOLODUKE 1348 +#define SPACEMARINE 1353 +#define INDY 1355 +#define FETUS 1358 +#define FETUSBROKE 1359 +#define MONK 1352 +#define LUKE 1354 +#define COOLEXPLOSION1 1360 +#define WATERSPLASH2 1380 +#define FIREVASE 1390 +#define SCRATCH 1393 +#define FEM7 1395 +#define APLAYERTOP 1400 +#define APLAYER 1405 +#define PLAYERONWATER 1420 +#define DUKELYINGDEAD 1518 +#define DUKETORSO 1520 +#define DUKEGUN 1528 +#define DUKELEG 1536 +#define SHARK 1550 +#define BLOOD 1620 +#define FIRELASER 1625 +#define TRANSPORTERSTAR 1630 +#define SPIT 1636 +#define LOOGIE 1637 +#define FIST 1640 +#define FREEZEBLAST 1641 +#define DEVISTATORBLAST 1642 +#define SHRINKSPARK 1646 +#define TONGUE 1647 +#define MORTER 1650 +#define SHRINKEREXPLOSION 1656 +#define RADIUSEXPLOSION 1670 +#define FORCERIPPLE 1671 +#define LIZTROOP 1680 +#define LIZTROOPRUNNING 1681 +#define LIZTROOPSTAYPUT 1682 +#define LIZTOP 1705 +#define LIZTROOPSHOOT 1715 +#define LIZTROOPJETPACK 1725 +#define LIZTROOPDSPRITE 1734 +#define LIZTROOPONTOILET 1741 +#define LIZTROOPJUSTSIT 1742 +#define LIZTROOPDUCKING 1744 +#define HEADJIB1 1768 +#define ARMJIB1 1772 +#define LEGJIB1 1776 +#define CANNONBALL 1817 +#define OCTABRAIN 1820 +#define OCTABRAINSTAYPUT 1821 +#define OCTATOP 1845 +#define OCTADEADSPRITE 1855 +#define INNERJAW 1860 +#define DRONE 1880 +#define EXPLOSION2 1890 +#define COMMANDER 1920 +#define COMMANDERSTAYPUT 1921 +#define RECON 1960 +#define TANK 1975 +#define PIGCOP 2000 +#define PIGCOPSTAYPUT 2001 +#define PIGCOPDIVE 2045 +#define PIGCOPDEADSPRITE 2060 +#define PIGTOP 2061 +#define LIZMAN 2120 +#define LIZMANSTAYPUT 2121 +#define LIZMANSPITTING 2150 +#define LIZMANFEEDING 2160 +#define LIZMANJUMP 2165 +#define LIZMANDEADSPRITE 2185 +#define FECES 2200 +#define LIZMANHEAD1 2201 +#define LIZMANARM1 2205 +#define LIZMANLEG1 2209 +#define EXPLOSION2BOT 2219 +#define USERWEAPON 2235 +#define HEADERBAR 2242 +#define JIBS1 2245 +#define JIBS2 2250 +#define JIBS3 2255 +#define JIBS4 2260 +#define JIBS5 2265 +#define BURNING 2270 +#define FIRE 2271 +#define JIBS6 2286 +#define BLOODSPLAT1 2296 +#define BLOODSPLAT3 2297 +#define BLOODSPLAT2 2298 +#define BLOODSPLAT4 2299 +#define OOZ 2300 +#define OOZ2 2309 +#define WALLBLOOD1 2301 +#define WALLBLOOD2 2302 +#define WALLBLOOD3 2303 +#define WALLBLOOD4 2304 +#define WALLBLOOD5 2305 +#define WALLBLOOD6 2306 +#define WALLBLOOD7 2307 +#define WALLBLOOD8 2308 +#define BURNING2 2310 +#define FIRE2 2311 +#define CRACKKNUCKLES 2324 +#define SMALLSMOKE 2329 +#define SMALLSMOKEMAKER 2330 +#define FLOORFLAME 2333 +#define ROTATEGUN 2360 +#define GREENSLIME 2370 +#define WATERDRIPSPLASH 2380 +#define SCRAP6 2390 +#define SCRAP1 2400 +#define SCRAP2 2404 +#define SCRAP3 2408 +#define SCRAP4 2412 +#define SCRAP5 2416 +#define ORGANTIC 2420 +#define BETAVERSION 2440 +#define PLAYERISHERE 2442 +#define PLAYERWASHERE 2443 +#define SELECTDIR 2444 +#define F1HELP 2445 +#define NOTCHON 2446 +#define NOTCHOFF 2447 +#define GROWSPARK 2448 +#define DUKEICON 2452 +#define BADGUYICON 2453 +#define FOODICON 2454 +#define GETICON 2455 +#define MENUSCREEN 2456 +#define MENUBAR 2457 +#define KILLSICON 2458 +#define FIRSTAID_ICON 2460 +#define HEAT_ICON 2461 +#define BOTTOMSTATUSBAR 2462 +#define BOOT_ICON 2463 +#define FRAGBAR 2465 +#define JETPACK_ICON 2467 +#define AIRTANK_ICON 2468 +#define STEROIDS_ICON 2469 +#define HOLODUKE_ICON 2470 +#define ACCESS_ICON 2471 +#define DIGITALNUM 2472 +#define DUKECAR 2491 +#define CAMCORNER 2482 +#define CAMLIGHT 2484 +#define LOGO 2485 +#define TITLE 2486 +#define NUKEWARNINGICON 2487 +#define MOUSECURSOR 2488 +#define SLIDEBAR 2489 +#define DREALMS 2492 +#define BETASCREEN 2493 +#define WINDOWBORDER1 2494 +#define TEXTBOX 2495 +#define WINDOWBORDER2 2496 +#define DUKENUKEM 2497 +#define THREEDEE 2498 +#define INGAMEDUKETHREEDEE 2499 +#define TENSCREEN 2500 +#define PLUTOPAKSPRITE 2501 +#define DEVISTATOR 2510 +#define KNEE 2521 +#define CROSSHAIR 2523 +#define FIRSTGUN 2524 +#define FIRSTGUNRELOAD 2528 +#define FALLINGCLIP 2530 +#define CLIPINHAND 2531 +#define HAND 2532 +#define SHELL 2533 +#define SHOTGUNSHELL 2535 +#define CHAINGUN 2536 +#define RPGGUN 2544 +#define RPGMUZZLEFLASH 2545 +#define FREEZE 2548 +#define CATLITE 2552 +#define SHRINKER 2556 +#define HANDHOLDINGLASER 2563 +#define TRIPBOMB 2566 +#define LASERLINE 2567 +#define HANDHOLDINGACCESS 2568 +#define HANDREMOTE 2570 +#define HANDTHROW 2573 +#define TIP 2576 +#define GLAIR 2578 +#define SCUBAMASK 2581 +#define SPACEMASK 2584 +#define FORCESPHERE 2590 +#define SHOTSPARK1 2595 +#define RPG 2605 +#define LASERSITE 2612 +#define SHOTGUN 2613 +#define BOSS1 2630 +#define BOSS1STAYPUT 2631 +#define BOSS1SHOOT 2660 +#define BOSS1LOB 2670 +#define BOSSTOP 2696 +#define BOSS2 2710 +#define BOSS3 2760 +#define SPINNINGNUKEICON 2813 +#define BIGFNTCURSOR 2820 +#define SMALLFNTCURSOR 2821 +#define STARTALPHANUM 2822 +#define ENDALPHANUM 2915 +#define BIGALPHANUM 2940 +#define BIGPERIOD 3002 +#define BIGCOMMA 3003 +#define BIGX 3004 +#define BIGQ 3005 +#define BIGSEMI 3006 +#define BIGCOLIN 3007 +#define THREEBYFIVE 3010 +#define BIGAPPOS 3022 +#define BLANK 3026 +#define MINIFONT 3072 +#define BUTTON1 3164 +#define GLASS3 3187 +#define RESPAWNMARKERRED 3190 +#define RESPAWNMARKERYELLOW 3200 +#define RESPAWNMARKERGREEN 3210 +#define BONUSSCREEN 3240 +#define VIEWBORDER 3250 +#define VICTORY1 3260 +#define ORDERING 3270 +#define TEXTSTORY 3280 +#define LOADSCREEN 3281 +#define BORNTOBEWILDSCREEN 3370 +#define BLIMP 3400 +#define FEM9 3450 +#define FOOTPRINT 3701 +#define FRAMEEFFECT1_13 3999 +#define POOP 4094 +#define FRAMEEFFECT1 4095 +#define PANNEL3 4099 +#define SCREENBREAK14 4120 +#define SCREENBREAK15 4123 +#define SCREENBREAK19 4125 +#define SCREENBREAK16 4127 +#define SCREENBREAK17 4128 +#define SCREENBREAK18 4129 +#define W_TECHWALL11 4130 +#define W_TECHWALL12 4131 +#define W_TECHWALL13 4132 +#define W_TECHWALL14 4133 +#define W_TECHWALL5 4134 +#define W_TECHWALL6 4136 +#define W_TECHWALL7 4138 +#define W_TECHWALL8 4140 +#define W_TECHWALL9 4142 +#define BPANNEL3 4100 +#define W_HITTECHWALL16 4144 +#define W_HITTECHWALL10 4145 +#define W_HITTECHWALL15 4147 +#define W_MILKSHELF 4181 +#define W_MILKSHELFBROKE 4203 +#define PURPLELAVA 4240 +#define LAVABUBBLE 4340 +#define DUKECUTOUT 4352 +#define TARGET 4359 +#define GUNPOWDERBARREL 4360 +#define DUCK 4361 +#define HATRACK 4367 +#define DESKLAMP 4370 +#define COFFEEMACHINE 4372 +#define CUPS 4373 +#define GAVALS 4374 +#define GAVALS2 4375 +#define POLICELIGHTPOLE 4377 +#define FLOORBASKET 4388 +#define PUKE 4389 +#define DOORTILE23 4391 +#define TOPSECRET 4396 +#define SPEAKER 4397 +#define TEDDYBEAR 4400 +#define ROBOTDOG 4402 +#define ROBOTPIRATE 4404 +#define ROBOTMOUSE 4407 +#define MAIL 4410 +#define MAILBAG 4413 +#define HOTMEAT 4427 +#define COFFEEMUG 4438 +#define DONUTS2 4440 +#define TRIPODCAMERA 4444 +#define METER 4453 +#define DESKPHONE 4454 +#define GUMBALLMACHINE 4458 +#define GUMBALLMACHINEBROKE 4459 +#define PAPER 4460 +#define MACE 4464 +#define GENERICPOLE2 4465 +#define XXXSTACY 4470 +#define WETFLOOR 4495 +#define BROOM 4496 +#define MOP 4497 +#define LETTER 4502 +#define PIRATE1A 4510 +#define PIRATE4A 4511 +#define PIRATE2A 4512 +#define PIRATE5A 4513 +#define PIRATE3A 4514 +#define PIRATE6A 4515 +#define PIRATEHALF 4516 +#define CHESTOFGOLD 4520 +#define SIDEBOLT1 4525 +#define FOODOBJECT1 4530 +#define FOODOBJECT2 4531 +#define FOODOBJECT3 4532 +#define FOODOBJECT4 4533 +#define FOODOBJECT5 4534 +#define FOODOBJECT6 4535 +#define FOODOBJECT7 4536 +#define FOODOBJECT8 4537 +#define FOODOBJECT9 4538 +#define FOODOBJECT10 4539 +#define FOODOBJECT11 4540 +#define FOODOBJECT12 4541 +#define FOODOBJECT13 4542 +#define FOODOBJECT14 4543 +#define FOODOBJECT15 4544 +#define FOODOBJECT16 4545 +#define FOODOBJECT17 4546 +#define FOODOBJECT18 4547 +#define FOODOBJECT19 4548 +#define FOODOBJECT20 4549 +#define HEADLAMP 4550 +#define TAMPON 4557 +#define SKINNEDCHICKEN 4554 +#define FEATHEREDCHICKEN 4555 +#define ROBOTDOG2 4560 +#define JOLLYMEAL 4569 +#define DUKEBURGER 4570 +#define SHOPPINGCART 4576 +#define CANWITHSOMETHING2 4580 +#define CANWITHSOMETHING3 4581 +#define CANWITHSOMETHING4 4582 +#define SNAKEP 4590 +#define DOLPHIN1 4591 +#define DOLPHIN2 4592 +#define NEWBEAST 4610 +#define NEWBEASTSTAYPUT 4611 +#define NEWBEASTJUMP 4690 +#define NEWBEASTHANG 4670 +#define NEWBEASTHANGDEAD 4671 +#define BOSS4 4740 +#define BOSS4STAYPUT 4741 +#define FEM10 4864 +#define TOUGHGAL 4866 +#define MAN 4871 +#define MAN2 4872 +#define WOMAN 4874 +#define PLEASEWAIT 4887 +#define NATURALLIGHTNING 4890 +#define WEATHERWARN 4893 +#define DUKETAG 4900 +#define SIGN1 4909 +#define SIGN2 4912 +#define JURYGUY 4943 + +// These tile positions are reserved! +#define RESERVEDSLOT1 6132 +#define RESERVEDSLOT2 6133 +#define RESERVEDSLOT3 6134 +#define RESERVEDSLOT4 6135 +#define RESERVEDSLOT5 6136 +#define RESERVEDSLOT6 6137 +#define RESERVEDSLOT7 6138 +#define RESERVEDSLOT8 6139 +#define RESERVEDSLOT9 6140 +#define RESERVEDSLOT10 6141 +#define RESERVEDSLOT11 6142 +#define RESERVEDSLOT12 6143 diff --git a/polymer/eduke32/source/namesdyn.c b/polymer/eduke32/source/namesdyn.c new file mode 100644 index 000000000..24999b8c3 --- /dev/null +++ b/polymer/eduke32/source/namesdyn.c @@ -0,0 +1,2421 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +// Maybe this should be called "hacks.c" instead of "namesdyn.c"... + +#include "build.h" +#include "duke3d.h" +#include "compat.h" + +unsigned short SECTOREFFECTOR = 1; +unsigned short ACTIVATOR = 2; +unsigned short TOUCHPLATE = 3; +unsigned short ACTIVATORLOCKED = 4; +unsigned short MUSICANDSFX = 5; +unsigned short LOCATORS = 6; +unsigned short CYCLER = 7; +unsigned short MASTERSWITCH = 8; +unsigned short RESPAWN = 9; +unsigned short GPSPEED = 10; +unsigned short FOF = 13; +unsigned short ARROW = 20; +unsigned short FIRSTGUNSPRITE = 21; +unsigned short CHAINGUNSPRITE = 22; +unsigned short RPGSPRITE = 23; +unsigned short FREEZESPRITE = 24; +unsigned short SHRINKERSPRITE = 25; +unsigned short HEAVYHBOMB = 26; +unsigned short TRIPBOMBSPRITE = 27; +unsigned short SHOTGUNSPRITE = 28; +unsigned short DEVISTATORSPRITE = 29; +unsigned short HEALTHBOX = 30; +unsigned short AMMOBOX = 31; +unsigned short GROWSPRITEICON = 32; +unsigned short INVENTORYBOX = 33; +unsigned short FREEZEAMMO = 37; +unsigned short AMMO = 40; +unsigned short BATTERYAMMO = 41; +unsigned short DEVISTATORAMMO = 42; +unsigned short RPGAMMO = 44; +unsigned short GROWAMMO = 45; +unsigned short CRYSTALAMMO = 46; +unsigned short HBOMBAMMO = 47; +unsigned short AMMOLOTS = 48; +unsigned short SHOTGUNAMMO = 49; +unsigned short COLA = 51; +unsigned short SIXPAK = 52; +unsigned short FIRSTAID = 53; +unsigned short SHIELD = 54; +unsigned short STEROIDS = 55; +unsigned short AIRTANK = 56; +unsigned short JETPACK = 57; +unsigned short HEATSENSOR = 59; +unsigned short ACCESSCARD = 60; +unsigned short BOOTS = 61; +unsigned short MIRRORBROKE = 70; +unsigned short CLOUDYOCEAN = 78; +unsigned short CLOUDYSKIES = 79; +unsigned short MOONSKY1 = 80; +unsigned short MOONSKY2 = 81; +unsigned short MOONSKY3 = 82; +unsigned short MOONSKY4 = 83; +unsigned short BIGORBIT1 = 84; +unsigned short BIGORBIT2 = 85; +unsigned short BIGORBIT3 = 86; +unsigned short BIGORBIT4 = 87; +unsigned short BIGORBIT5 = 88; +unsigned short LA = 89; +unsigned short REDSKY1 = 98; +unsigned short REDSKY2 = 99; +unsigned short ATOMICHEALTH = 100; +unsigned short TECHLIGHT2 = 120; +unsigned short TECHLIGHTBUST2 = 121; +unsigned short TECHLIGHT4 = 122; +unsigned short TECHLIGHTBUST4 = 123; +unsigned short WALLLIGHT4 = 124; +unsigned short WALLLIGHTBUST4 = 125; +unsigned short ACCESSSWITCH = 130; +unsigned short SLOTDOOR = 132; +unsigned short LIGHTSWITCH = 134; +unsigned short SPACEDOORSWITCH = 136; +unsigned short SPACELIGHTSWITCH = 138; +unsigned short FRANKENSTINESWITCH = 140; +unsigned short NUKEBUTTON = 142; +unsigned short MULTISWITCH = 146; +unsigned short DOORTILE5 = 150; +unsigned short DOORTILE6 = 151; +unsigned short DOORTILE1 = 152; +unsigned short DOORTILE2 = 153; +unsigned short DOORTILE3 = 154; +unsigned short DOORTILE4 = 155; +unsigned short DOORTILE7 = 156; +unsigned short DOORTILE8 = 157; +unsigned short DOORTILE9 = 158; +unsigned short DOORTILE10 = 159; +unsigned short DOORSHOCK = 160; +unsigned short DIPSWITCH = 162; +unsigned short DIPSWITCH2 = 164; +unsigned short TECHSWITCH = 166; +unsigned short DIPSWITCH3 = 168; +unsigned short ACCESSSWITCH2 = 170; +unsigned short REFLECTWATERTILE = 180; +unsigned short FLOORSLIME = 200; +unsigned short BIGFORCE = 230; +unsigned short EPISODE = 247; +unsigned short MASKWALL9 = 255; +unsigned short W_LIGHT = 260; +unsigned short SCREENBREAK1 = 263; +unsigned short SCREENBREAK2 = 264; +unsigned short SCREENBREAK3 = 265; +unsigned short SCREENBREAK4 = 266; +unsigned short SCREENBREAK5 = 267; +unsigned short SCREENBREAK6 = 268; +unsigned short SCREENBREAK7 = 269; +unsigned short SCREENBREAK8 = 270; +unsigned short SCREENBREAK9 = 271; +unsigned short SCREENBREAK10 = 272; +unsigned short SCREENBREAK11 = 273; +unsigned short SCREENBREAK12 = 274; +unsigned short SCREENBREAK13 = 275; +unsigned short MASKWALL1 = 285; +unsigned short W_TECHWALL1 = 293; +unsigned short W_TECHWALL2 = 297; +unsigned short W_TECHWALL15 = 299; +unsigned short W_TECHWALL3 = 301; +unsigned short W_TECHWALL4 = 305; +unsigned short W_TECHWALL10 = 306; +unsigned short W_TECHWALL16 = 307; +unsigned short WATERTILE2 = 336; +unsigned short BPANNEL1 = 341; +unsigned short PANNEL1 = 342; +unsigned short PANNEL2 = 343; +unsigned short WATERTILE = 344; +unsigned short STATIC = 351; +unsigned short W_SCREENBREAK = 357; +unsigned short W_HITTECHWALL3 = 360; +unsigned short W_HITTECHWALL4 = 361; +unsigned short W_HITTECHWALL2 = 362; +unsigned short W_HITTECHWALL1 = 363; +unsigned short MASKWALL10 = 387; +unsigned short MASKWALL11 = 391; +unsigned short DOORTILE22 = 395; +unsigned short FANSPRITE = 407; +unsigned short FANSPRITEBROKE = 411; +unsigned short FANSHADOW = 412; +unsigned short FANSHADOWBROKE = 416; +unsigned short DOORTILE18 = 447; +unsigned short DOORTILE19 = 448; +unsigned short DOORTILE20 = 449; +unsigned short SATELLITE = 489; +unsigned short VIEWSCREEN2 = 499; +unsigned short VIEWSCREENBROKE = 501; +unsigned short VIEWSCREEN = 502; +unsigned short GLASS = 503; +unsigned short GLASS2 = 504; +unsigned short STAINGLASS1 = 510; +unsigned short MASKWALL5 = 514; +unsigned short SATELITE = 516; +unsigned short FUELPOD = 517; +unsigned short SLIMEPIPE = 538; +unsigned short CRACK1 = 546; +unsigned short CRACK2 = 547; +unsigned short CRACK3 = 548; +unsigned short CRACK4 = 549; +unsigned short FOOTPRINTS = 550; +unsigned short DOMELITE = 551; +unsigned short CAMERAPOLE = 554; +unsigned short CHAIR1 = 556; +unsigned short CHAIR2 = 557; +unsigned short BROKENCHAIR = 559; +unsigned short MIRROR = 560; +unsigned short WATERFOUNTAIN = 563; +unsigned short WATERFOUNTAINBROKE = 567; +unsigned short FEMMAG1 = 568; +unsigned short TOILET = 569; +unsigned short STALL = 571; +unsigned short STALLBROKE = 573; +unsigned short FEMMAG2 = 577; +unsigned short REACTOR2 = 578; +unsigned short REACTOR2BURNT = 579; +unsigned short REACTOR2SPARK = 580; +unsigned short GRATE1 = 595; +unsigned short BGRATE1 = 596; +unsigned short SOLARPANNEL = 602; +unsigned short NAKED1 = 603; +unsigned short ANTENNA = 607; +unsigned short MASKWALL12 = 609; +unsigned short TOILETBROKE = 615; +unsigned short PIPE2 = 616; +unsigned short PIPE1B = 617; +unsigned short PIPE3 = 618; +unsigned short PIPE1 = 619; +unsigned short CAMERA1 = 621; +unsigned short BRICK = 626; +unsigned short SPLINTERWOOD = 630; +unsigned short PIPE2B = 633; +unsigned short BOLT1 = 634; +unsigned short W_NUMBERS = 640; +unsigned short WATERDRIP = 660; +unsigned short WATERBUBBLE = 661; +unsigned short WATERBUBBLEMAKER = 662; +unsigned short W_FORCEFIELD = 663; +unsigned short VACUUM = 669; +unsigned short FOOTPRINTS2 = 672; +unsigned short FOOTPRINTS3 = 673; +unsigned short FOOTPRINTS4 = 674; +unsigned short EGG = 675; +unsigned short SCALE = 678; +unsigned short CHAIR3 = 680; +unsigned short CAMERALIGHT = 685; +unsigned short MOVIECAMERA = 686; +unsigned short IVUNIT = 689; +unsigned short POT1 = 694; +unsigned short POT2 = 695; +unsigned short POT3 = 697; +unsigned short PIPE3B = 700; +unsigned short WALLLIGHT3 = 701; +unsigned short WALLLIGHTBUST3 = 702; +unsigned short WALLLIGHT1 = 703; +unsigned short WALLLIGHTBUST1 = 704; +unsigned short WALLLIGHT2 = 705; +unsigned short WALLLIGHTBUST2 = 706; +unsigned short LIGHTSWITCH2 = 712; +unsigned short WAITTOBESEATED = 716; +unsigned short DOORTILE14 = 717; +unsigned short STATUE = 753; +unsigned short MIKE = 762; +unsigned short VASE = 765; +unsigned short SUSHIPLATE1 = 768; +unsigned short SUSHIPLATE2 = 769; +unsigned short SUSHIPLATE3 = 774; +unsigned short SUSHIPLATE4 = 779; +unsigned short DOORTILE16 = 781; +unsigned short SUSHIPLATE5 = 792; +unsigned short OJ = 806; +unsigned short MASKWALL13 = 830; +unsigned short HURTRAIL = 859; +unsigned short POWERSWITCH1 = 860; +unsigned short LOCKSWITCH1 = 862; +unsigned short POWERSWITCH2 = 864; +unsigned short ATM = 867; +unsigned short STATUEFLASH = 869; +unsigned short ATMBROKE = 888; +unsigned short BIGHOLE2 = 893; +unsigned short STRIPEBALL = 901; +unsigned short QUEBALL = 902; +unsigned short POCKET = 903; +unsigned short WOODENHORSE = 904; +unsigned short TREE1 = 908; +unsigned short TREE2 = 910; +unsigned short CACTUS = 911; +unsigned short MASKWALL2 = 913; +unsigned short MASKWALL3 = 914; +unsigned short MASKWALL4 = 915; +unsigned short FIREEXT = 916; +unsigned short TOILETWATER = 921; +unsigned short NEON1 = 925; +unsigned short NEON2 = 926; +unsigned short CACTUSBROKE = 939; +unsigned short BOUNCEMINE = 940; +unsigned short BROKEFIREHYDRENT = 950; +unsigned short BOX = 951; +unsigned short BULLETHOLE = 952; +unsigned short BOTTLE1 = 954; +unsigned short BOTTLE2 = 955; +unsigned short BOTTLE3 = 956; +unsigned short BOTTLE4 = 957; +unsigned short FEMPIC5 = 963; +unsigned short FEMPIC6 = 964; +unsigned short FEMPIC7 = 965; +unsigned short HYDROPLANT = 969; +unsigned short OCEANSPRITE1 = 971; +unsigned short OCEANSPRITE2 = 972; +unsigned short OCEANSPRITE3 = 973; +unsigned short OCEANSPRITE4 = 974; +unsigned short OCEANSPRITE5 = 975; +unsigned short GENERICPOLE = 977; +unsigned short CONE = 978; +unsigned short HANGLIGHT = 979; +unsigned short HYDRENT = 981; +unsigned short MASKWALL14 = 988; +unsigned short TIRE = 990; +unsigned short PIPE5 = 994; +unsigned short PIPE6 = 995; +unsigned short PIPE4 = 996; +unsigned short PIPE4B = 997; +unsigned short BROKEHYDROPLANT = 1003; +unsigned short PIPE5B = 1005; +unsigned short NEON3 = 1007; +unsigned short NEON4 = 1008; +unsigned short NEON5 = 1009; +unsigned short BOTTLE5 = 1012; +unsigned short BOTTLE6 = 1013; +unsigned short BOTTLE8 = 1014; +unsigned short SPOTLITE = 1020; +unsigned short HANGOOZ = 1022; +unsigned short MASKWALL15 = 1024; +unsigned short BOTTLE7 = 1025; +unsigned short HORSEONSIDE = 1026; +unsigned short GLASSPIECES = 1031; +unsigned short HORSELITE = 1034; +unsigned short DONUTS = 1045; +unsigned short NEON6 = 1046; +unsigned short MASKWALL6 = 1059; +unsigned short CLOCK = 1060; +unsigned short RUBBERCAN = 1062; +unsigned short BROKENCLOCK = 1067; +unsigned short PLUG = 1069; +unsigned short OOZFILTER = 1079; +unsigned short FLOORPLASMA = 1082; +unsigned short REACTOR = 1088; +unsigned short REACTORSPARK = 1092; +unsigned short REACTORBURNT = 1096; +unsigned short DOORTILE15 = 1102; +unsigned short HANDSWITCH = 1111; +unsigned short CIRCLEPANNEL = 1113; +unsigned short CIRCLEPANNELBROKE = 1114; +unsigned short PULLSWITCH = 1122; +unsigned short MASKWALL8 = 1124; +unsigned short BIGHOLE = 1141; +unsigned short ALIENSWITCH = 1142; +unsigned short DOORTILE21 = 1144; +unsigned short HANDPRINTSWITCH = 1155; +unsigned short BOTTLE10 = 1157; +unsigned short BOTTLE11 = 1158; +unsigned short BOTTLE12 = 1159; +unsigned short BOTTLE13 = 1160; +unsigned short BOTTLE14 = 1161; +unsigned short BOTTLE15 = 1162; +unsigned short BOTTLE16 = 1163; +unsigned short BOTTLE17 = 1164; +unsigned short BOTTLE18 = 1165; +unsigned short BOTTLE19 = 1166; +unsigned short DOORTILE17 = 1169; +unsigned short MASKWALL7 = 1174; +unsigned short JAILBARBREAK = 1175; +unsigned short DOORTILE11 = 1178; +unsigned short DOORTILE12 = 1179; +unsigned short VENDMACHINE = 1212; +unsigned short VENDMACHINEBROKE = 1214; +unsigned short COLAMACHINE = 1215; +unsigned short COLAMACHINEBROKE = 1217; +unsigned short CRANEPOLE = 1221; +unsigned short CRANE = 1222; +unsigned short BARBROKE = 1225; +unsigned short BLOODPOOL = 1226; +unsigned short NUKEBARREL = 1227; +unsigned short NUKEBARRELDENTED = 1228; +unsigned short NUKEBARRELLEAKED = 1229; +unsigned short CANWITHSOMETHING = 1232; +unsigned short MONEY = 1233; +unsigned short BANNER = 1236; +unsigned short EXPLODINGBARREL = 1238; +unsigned short EXPLODINGBARREL2 = 1239; +unsigned short FIREBARREL = 1240; +unsigned short SEENINE = 1247; +unsigned short SEENINEDEAD = 1248; +unsigned short STEAM = 1250; +unsigned short CEILINGSTEAM = 1255; +unsigned short PIPE6B = 1260; +unsigned short TRANSPORTERBEAM = 1261; +unsigned short RAT = 1267; +unsigned short TRASH = 1272; +unsigned short FEMPIC1 = 1280; +unsigned short FEMPIC2 = 1289; +unsigned short BLANKSCREEN = 1293; +unsigned short PODFEM1 = 1294; +unsigned short FEMPIC3 = 1298; +unsigned short FEMPIC4 = 1306; +unsigned short FEM1 = 1312; +unsigned short FEM2 = 1317; +unsigned short FEM3 = 1321; +unsigned short FEM5 = 1323; +unsigned short BLOODYPOLE = 1324; +unsigned short FEM4 = 1325; +unsigned short FEM6 = 1334; +unsigned short FEM6PAD = 1335; +unsigned short FEM8 = 1336; +unsigned short HELECOPT = 1346; +unsigned short FETUSJIB = 1347; +unsigned short HOLODUKE = 1348; +unsigned short SPACEMARINE = 1353; +unsigned short INDY = 1355; +unsigned short FETUS = 1358; +unsigned short FETUSBROKE = 1359; +unsigned short MONK = 1352; +unsigned short LUKE = 1354; +unsigned short COOLEXPLOSION1 = 1360; +unsigned short WATERSPLASH2 = 1380; +unsigned short FIREVASE = 1390; +unsigned short SCRATCH = 1393; +unsigned short FEM7 = 1395; +unsigned short APLAYERTOP = 1400; +unsigned short APLAYER = 1405; +unsigned short PLAYERONWATER = 1420; +unsigned short DUKELYINGDEAD = 1518; +unsigned short DUKETORSO = 1520; +unsigned short DUKEGUN = 1528; +unsigned short DUKELEG = 1536; +unsigned short SHARK = 1550; +unsigned short BLOOD = 1620; +unsigned short FIRELASER = 1625; +unsigned short TRANSPORTERSTAR = 1630; +unsigned short SPIT = 1636; +unsigned short LOOGIE = 1637; +unsigned short FIST = 1640; +unsigned short FREEZEBLAST = 1641; +unsigned short DEVISTATORBLAST = 1642; +unsigned short SHRINKSPARK = 1646; +unsigned short TONGUE = 1647; +unsigned short MORTER = 1650; +unsigned short SHRINKEREXPLOSION = 1656; +unsigned short RADIUSEXPLOSION = 1670; +unsigned short FORCERIPPLE = 1671; +unsigned short LIZTROOP = 1680; +unsigned short LIZTROOPRUNNING = 1681; +unsigned short LIZTROOPSTAYPUT = 1682; +unsigned short LIZTOP = 1705; +unsigned short LIZTROOPSHOOT = 1715; +unsigned short LIZTROOPJETPACK = 1725; +unsigned short LIZTROOPDSPRITE = 1734; +unsigned short LIZTROOPONTOILET = 1741; +unsigned short LIZTROOPJUSTSIT = 1742; +unsigned short LIZTROOPDUCKING = 1744; +unsigned short HEADJIB1 = 1768; +unsigned short ARMJIB1 = 1772; +unsigned short LEGJIB1 = 1776; +unsigned short CANNONBALL = 1817; +unsigned short OCTABRAIN = 1820; +unsigned short OCTABRAINSTAYPUT = 1821; +unsigned short OCTATOP = 1845; +unsigned short OCTADEADSPRITE = 1855; +unsigned short INNERJAW = 1860; +unsigned short DRONE = 1880; +unsigned short EXPLOSION2 = 1890; +unsigned short COMMANDER = 1920; +unsigned short COMMANDERSTAYPUT = 1921; +unsigned short RECON = 1960; +unsigned short TANK = 1975; +unsigned short PIGCOP = 2000; +unsigned short PIGCOPSTAYPUT = 2001; +unsigned short PIGCOPDIVE = 2045; +unsigned short PIGCOPDEADSPRITE = 2060; +unsigned short PIGTOP = 2061; +unsigned short LIZMAN = 2120; +unsigned short LIZMANSTAYPUT = 2121; +unsigned short LIZMANSPITTING = 2150; +unsigned short LIZMANFEEDING = 2160; +unsigned short LIZMANJUMP = 2165; +unsigned short LIZMANDEADSPRITE = 2185; +unsigned short FECES = 2200; +unsigned short LIZMANHEAD1 = 2201; +unsigned short LIZMANARM1 = 2205; +unsigned short LIZMANLEG1 = 2209; +unsigned short EXPLOSION2BOT = 2219; +unsigned short USERWEAPON = 2235; +unsigned short HEADERBAR = 2242; +unsigned short JIBS1 = 2245; +unsigned short JIBS2 = 2250; +unsigned short JIBS3 = 2255; +unsigned short JIBS4 = 2260; +unsigned short JIBS5 = 2265; +unsigned short BURNING = 2270; +unsigned short FIRE = 2271; +unsigned short JIBS6 = 2286; +unsigned short BLOODSPLAT1 = 2296; +unsigned short BLOODSPLAT3 = 2297; +unsigned short BLOODSPLAT2 = 2298; +unsigned short BLOODSPLAT4 = 2299; +unsigned short OOZ = 2300; +unsigned short OOZ2 = 2309; +unsigned short WALLBLOOD1 = 2301; +unsigned short WALLBLOOD2 = 2302; +unsigned short WALLBLOOD3 = 2303; +unsigned short WALLBLOOD4 = 2304; +unsigned short WALLBLOOD5 = 2305; +unsigned short WALLBLOOD6 = 2306; +unsigned short WALLBLOOD7 = 2307; +unsigned short WALLBLOOD8 = 2308; +unsigned short BURNING2 = 2310; +unsigned short FIRE2 = 2311; +unsigned short CRACKKNUCKLES = 2324; +unsigned short SMALLSMOKE = 2329; +unsigned short SMALLSMOKEMAKER = 2330; +unsigned short FLOORFLAME = 2333; +unsigned short ROTATEGUN = 2360; +unsigned short GREENSLIME = 2370; +unsigned short WATERDRIPSPLASH = 2380; +unsigned short SCRAP6 = 2390; +unsigned short SCRAP1 = 2400; +unsigned short SCRAP2 = 2404; +unsigned short SCRAP3 = 2408; +unsigned short SCRAP4 = 2412; +unsigned short SCRAP5 = 2416; +unsigned short ORGANTIC = 2420; +unsigned short BETAVERSION = 2440; +unsigned short PLAYERISHERE = 2442; +unsigned short PLAYERWASHERE = 2443; +unsigned short SELECTDIR = 2444; +unsigned short F1HELP = 2445; +unsigned short NOTCHON = 2446; +unsigned short NOTCHOFF = 2447; +unsigned short GROWSPARK = 2448; +unsigned short DUKEICON = 2452; +unsigned short BADGUYICON = 2453; +unsigned short FOODICON = 2454; +unsigned short GETICON = 2455; +unsigned short MENUSCREEN = 2456; +unsigned short MENUBAR = 2457; +unsigned short KILLSICON = 2458; +unsigned short FIRSTAID_ICON = 2460; +unsigned short HEAT_ICON = 2461; +unsigned short BOTTOMSTATUSBAR = 2462; +unsigned short BOOT_ICON = 2463; +unsigned short FRAGBAR = 2465; +unsigned short JETPACK_ICON = 2467; +unsigned short AIRTANK_ICON = 2468; +unsigned short STEROIDS_ICON = 2469; +unsigned short HOLODUKE_ICON = 2470; +unsigned short ACCESS_ICON = 2471; +unsigned short DIGITALNUM = 2472; +unsigned short DUKECAR = 2491; +unsigned short CAMCORNER = 2482; +unsigned short CAMLIGHT = 2484; +unsigned short LOGO = 2485; +unsigned short TITLE = 2486; +unsigned short NUKEWARNINGICON = 2487; +unsigned short MOUSECURSOR = 2488; +unsigned short SLIDEBAR = 2489; +unsigned short DREALMS = 2492; +unsigned short BETASCREEN = 2493; +unsigned short WINDOWBORDER1 = 2494; +unsigned short TEXTBOX = 2495; +unsigned short WINDOWBORDER2 = 2496; +unsigned short DUKENUKEM = 2497; +unsigned short THREEDEE = 2498; +unsigned short INGAMEDUKETHREEDEE = 2499; +unsigned short TENSCREEN = 2500; +unsigned short PLUTOPAKSPRITE = 2501; +unsigned short DEVISTATOR = 2510; +unsigned short KNEE = 2521; +unsigned short CROSSHAIR = 2523; +unsigned short FIRSTGUN = 2524; +unsigned short FIRSTGUNRELOAD = 2528; +unsigned short FALLINGCLIP = 2530; +unsigned short CLIPINHAND = 2531; +unsigned short HAND = 2532; +unsigned short SHELL = 2533; +unsigned short SHOTGUNSHELL = 2535; +unsigned short CHAINGUN = 2536; +unsigned short RPGGUN = 2544; +unsigned short RPGMUZZLEFLASH = 2545; +unsigned short FREEZE = 2548; +unsigned short CATLITE = 2552; +unsigned short SHRINKER = 2556; +unsigned short HANDHOLDINGLASER = 2563; +unsigned short TRIPBOMB = 2566; +unsigned short LASERLINE = 2567; +unsigned short HANDHOLDINGACCESS = 2568; +unsigned short HANDREMOTE = 2570; +unsigned short HANDTHROW = 2573; +unsigned short TIP = 2576; +unsigned short GLAIR = 2578; +unsigned short SCUBAMASK = 2581; +unsigned short SPACEMASK = 2584; +unsigned short FORCESPHERE = 2590; +unsigned short SHOTSPARK1 = 2595; +unsigned short RPG = 2605; +unsigned short LASERSITE = 2612; +unsigned short SHOTGUN = 2613; +unsigned short BOSS1 = 2630; +unsigned short BOSS1STAYPUT = 2631; +unsigned short BOSS1SHOOT = 2660; +unsigned short BOSS1LOB = 2670; +unsigned short BOSSTOP = 2696; +unsigned short BOSS2 = 2710; +unsigned short BOSS3 = 2760; +unsigned short SPINNINGNUKEICON = 2813; +unsigned short BIGFNTCURSOR = 2820; +unsigned short SMALLFNTCURSOR = 2821; +unsigned short STARTALPHANUM = 2822; +unsigned short ENDALPHANUM = 2915; +unsigned short BIGALPHANUM = 2940; +unsigned short BIGPERIOD = 3002; +unsigned short BIGCOMMA = 3003; +unsigned short BIGX = 3004; +unsigned short BIGQ = 3005; +unsigned short BIGSEMI = 3006; +unsigned short BIGCOLIN = 3007; +unsigned short THREEBYFIVE = 3010; +unsigned short BIGAPPOS = 3022; +unsigned short BLANK = 3026; +unsigned short MINIFONT = 3072; +unsigned short BUTTON1 = 3164; +unsigned short GLASS3 = 3187; +unsigned short RESPAWNMARKERRED = 3190; +unsigned short RESPAWNMARKERYELLOW = 3200; +unsigned short RESPAWNMARKERGREEN = 3210; +unsigned short BONUSSCREEN = 3240; +unsigned short VIEWBORDER = 3250; +unsigned short VICTORY1 = 3260; +unsigned short ORDERING = 3270; +unsigned short TEXTSTORY = 3280; +unsigned short LOADSCREEN = 3281; +unsigned short BORNTOBEWILDSCREEN = 3370; +unsigned short BLIMP = 3400; +unsigned short FEM9 = 3450; +unsigned short FOOTPRINT = 3701; +unsigned short FRAMEEFFECT1_13 = 3999; +unsigned short POOP = 4094; +unsigned short FRAMEEFFECT1 = 4095; +unsigned short PANNEL3 = 4099; +unsigned short SCREENBREAK14 = 4120; +unsigned short SCREENBREAK15 = 4123; +unsigned short SCREENBREAK19 = 4125; +unsigned short SCREENBREAK16 = 4127; +unsigned short SCREENBREAK17 = 4128; +unsigned short SCREENBREAK18 = 4129; +unsigned short W_TECHWALL11 = 4130; +unsigned short W_TECHWALL12 = 4131; +unsigned short W_TECHWALL13 = 4132; +unsigned short W_TECHWALL14 = 4133; +unsigned short W_TECHWALL5 = 4134; +unsigned short W_TECHWALL6 = 4136; +unsigned short W_TECHWALL7 = 4138; +unsigned short W_TECHWALL8 = 4140; +unsigned short W_TECHWALL9 = 4142; +unsigned short BPANNEL3 = 4100; +unsigned short W_HITTECHWALL16 = 4144; +unsigned short W_HITTECHWALL10 = 4145; +unsigned short W_HITTECHWALL15 = 4147; +unsigned short W_MILKSHELF = 4181; +unsigned short W_MILKSHELFBROKE = 4203; +unsigned short PURPLELAVA = 4240; +unsigned short LAVABUBBLE = 4340; +unsigned short DUKECUTOUT = 4352; +unsigned short TARGET = 4359; +unsigned short GUNPOWDERBARREL = 4360; +unsigned short DUCK = 4361; +unsigned short HATRACK = 4367; +unsigned short DESKLAMP = 4370; +unsigned short COFFEEMACHINE = 4372; +unsigned short CUPS = 4373; +unsigned short GAVALS = 4374; +unsigned short GAVALS2 = 4375; +unsigned short POLICELIGHTPOLE = 4377; +unsigned short FLOORBASKET = 4388; +unsigned short PUKE = 4389; +unsigned short DOORTILE23 = 4391; +unsigned short TOPSECRET = 4396; +unsigned short SPEAKER = 4397; +unsigned short TEDDYBEAR = 4400; +unsigned short ROBOTDOG = 4402; +unsigned short ROBOTPIRATE = 4404; +unsigned short ROBOTMOUSE = 4407; +unsigned short MAIL = 4410; +unsigned short MAILBAG = 4413; +unsigned short HOTMEAT = 4427; +unsigned short COFFEEMUG = 4438; +unsigned short DONUTS2 = 4440; +unsigned short TRIPODCAMERA = 4444; +unsigned short METER = 4453; +unsigned short DESKPHONE = 4454; +unsigned short GUMBALLMACHINE = 4458; +unsigned short GUMBALLMACHINEBROKE = 4459; +unsigned short PAPER = 4460; +unsigned short MACE = 4464; +unsigned short GENERICPOLE2 = 4465; +unsigned short XXXSTACY = 4470; +unsigned short WETFLOOR = 4495; +unsigned short BROOM = 4496; +unsigned short MOP = 4497; +unsigned short LETTER = 4502; +unsigned short PIRATE1A = 4510; +unsigned short PIRATE4A = 4511; +unsigned short PIRATE2A = 4512; +unsigned short PIRATE5A = 4513; +unsigned short PIRATE3A = 4514; +unsigned short PIRATE6A = 4515; +unsigned short PIRATEHALF = 4516; +unsigned short CHESTOFGOLD = 4520; +unsigned short SIDEBOLT1 = 4525; +unsigned short FOODOBJECT1 = 4530; +unsigned short FOODOBJECT2 = 4531; +unsigned short FOODOBJECT3 = 4532; +unsigned short FOODOBJECT4 = 4533; +unsigned short FOODOBJECT5 = 4534; +unsigned short FOODOBJECT6 = 4535; +unsigned short FOODOBJECT7 = 4536; +unsigned short FOODOBJECT8 = 4537; +unsigned short FOODOBJECT9 = 4538; +unsigned short FOODOBJECT10 = 4539; +unsigned short FOODOBJECT11 = 4540; +unsigned short FOODOBJECT12 = 4541; +unsigned short FOODOBJECT13 = 4542; +unsigned short FOODOBJECT14 = 4543; +unsigned short FOODOBJECT15 = 4544; +unsigned short FOODOBJECT16 = 4545; +unsigned short FOODOBJECT17 = 4546; +unsigned short FOODOBJECT18 = 4547; +unsigned short FOODOBJECT19 = 4548; +unsigned short FOODOBJECT20 = 4549; +unsigned short HEADLAMP = 4550; +unsigned short TAMPON = 4557; +unsigned short SKINNEDCHICKEN = 4554; +unsigned short FEATHEREDCHICKEN = 4555; +unsigned short ROBOTDOG2 = 4560; +unsigned short JOLLYMEAL = 4569; +unsigned short DUKEBURGER = 4570; +unsigned short SHOPPINGCART = 4576; +unsigned short CANWITHSOMETHING2 = 4580; +unsigned short CANWITHSOMETHING3 = 4581; +unsigned short CANWITHSOMETHING4 = 4582; +unsigned short SNAKEP = 4590; +unsigned short DOLPHIN1 = 4591; +unsigned short DOLPHIN2 = 4592; +unsigned short NEWBEAST = 4610; +unsigned short NEWBEASTSTAYPUT = 4611; +unsigned short NEWBEASTJUMP = 4690; +unsigned short NEWBEASTHANG = 4670; +unsigned short NEWBEASTHANGDEAD = 4671; +unsigned short BOSS4 = 4740; +unsigned short BOSS4STAYPUT = 4741; +unsigned short FEM10 = 4864; +unsigned short TOUGHGAL = 4866; +unsigned short MAN = 4871; +unsigned short MAN2 = 4872; +unsigned short WOMAN = 4874; +unsigned short PLEASEWAIT = 4887; +unsigned short NATURALLIGHTNING = 4890; +unsigned short WEATHERWARN = 4893; +unsigned short DUKETAG = 4900; +unsigned short SIGN1 = 4909; +unsigned short SIGN2 = 4912; +unsigned short JURYGUY = 4943; +unsigned short RESERVEDSLOT1 = 6132; +unsigned short RESERVEDSLOT2 = 6133; +unsigned short RESERVEDSLOT3 = 6134; +unsigned short RESERVEDSLOT4 = 6135; +unsigned short RESERVEDSLOT5 = 6136; +unsigned short RESERVEDSLOT6 = 6137; +unsigned short RESERVEDSLOT7 = 6138; +unsigned short RESERVEDSLOT8 = 6139; +unsigned short RESERVEDSLOT9 = 6140; +unsigned short RESERVEDSLOT10 = 6141; +unsigned short RESERVEDSLOT11 = 6142; +unsigned short RESERVEDSLOT12 = 6143; + +unsigned short dynamictostatic[MAXTILES]; + +void processnames(char *szLabel, long lValue) +{ + switch (szLabel[0]) { + case 'A': + if (!Bstrcmp(szLabel,"ACTIVATOR")) ACTIVATOR = lValue; + else if (!Bstrcmp(szLabel,"ACTIVATORLOCKED")) ACTIVATORLOCKED = lValue; + else if (!Bstrcmp(szLabel,"ARROW")) ARROW = lValue; + else if (!Bstrcmp(szLabel,"AMMOBOX")) AMMOBOX = lValue; + else if (!Bstrcmp(szLabel,"AMMO")) AMMO = lValue; + else if (!Bstrcmp(szLabel,"AMMOLOTS")) AMMOLOTS = lValue; + else if (!Bstrcmp(szLabel,"AIRTANK")) AIRTANK = lValue; + else if (!Bstrcmp(szLabel,"ACCESSCARD")) ACCESSCARD = lValue; + else if (!Bstrcmp(szLabel,"ATOMICHEALTH")) ATOMICHEALTH = lValue; + else if (!Bstrcmp(szLabel,"ACCESSSWITCH")) ACCESSSWITCH = lValue; + else if (!Bstrcmp(szLabel,"ACCESSSWITCH2")) ACCESSSWITCH2 = lValue; + else if (!Bstrcmp(szLabel,"ANTENNA")) ANTENNA = lValue; + else if (!Bstrcmp(szLabel,"ATM")) ATM = lValue; + else if (!Bstrcmp(szLabel,"ATMBROKE")) ATMBROKE = lValue; + else if (!Bstrcmp(szLabel,"ALIENSWITCH")) ALIENSWITCH = lValue; + else if (!Bstrcmp(szLabel,"APLAYERTOP")) APLAYERTOP = lValue; + else if (!Bstrcmp(szLabel,"APLAYER")) APLAYER = lValue; + else if (!Bstrcmp(szLabel,"ARMJIB1")) ARMJIB1 = lValue; + else if (!Bstrcmp(szLabel,"AIRTANK_ICON")) AIRTANK_ICON = lValue; + else if (!Bstrcmp(szLabel,"ACCESS_ICON")) ACCESS_ICON = lValue; + break; + case 'B': + if (!Bstrcmp(szLabel,"BATTERYAMMO")) BATTERYAMMO = lValue; + else if (!Bstrcmp(szLabel,"BOOTS")) BOOTS = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT1")) BIGORBIT1 = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT2")) BIGORBIT2 = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT3")) BIGORBIT3 = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT4")) BIGORBIT4 = lValue; + else if (!Bstrcmp(szLabel,"BIGORBIT5")) BIGORBIT5 = lValue; + else if (!Bstrcmp(szLabel,"BIGFORCE")) BIGFORCE = lValue; + else if (!Bstrcmp(szLabel,"BPANNEL1")) BPANNEL1 = lValue; + else if (!Bstrcmp(szLabel,"BROKENCHAIR")) BROKENCHAIR = lValue; + else if (!Bstrcmp(szLabel,"BGRATE1")) BGRATE1 = lValue; + else if (!Bstrcmp(szLabel,"BRICK")) BRICK = lValue; + else if (!Bstrcmp(szLabel,"BOLT1")) BOLT1 = lValue; + else if (!Bstrcmp(szLabel,"BIGHOLE2")) BIGHOLE2 = lValue; + else if (!Bstrcmp(szLabel,"BOUNCEMINE")) BOUNCEMINE = lValue; + else if (!Bstrcmp(szLabel,"BROKEFIREHYDRENT")) BROKEFIREHYDRENT = lValue; + else if (!Bstrcmp(szLabel,"BOX")) BOX = lValue; + else if (!Bstrcmp(szLabel,"BULLETHOLE")) BULLETHOLE = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE1")) BOTTLE1 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE2")) BOTTLE2 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE3")) BOTTLE3 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE4")) BOTTLE4 = lValue; + else if (!Bstrcmp(szLabel,"BROKEHYDROPLANT")) BROKEHYDROPLANT = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE5")) BOTTLE5 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE6")) BOTTLE6 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE8")) BOTTLE8 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE7")) BOTTLE7 = lValue; + else if (!Bstrcmp(szLabel,"BROKENCLOCK")) BROKENCLOCK = lValue; + else if (!Bstrcmp(szLabel,"BIGHOLE")) BIGHOLE = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE10")) BOTTLE10 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE11")) BOTTLE11 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE12")) BOTTLE12 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE13")) BOTTLE13 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE14")) BOTTLE14 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE15")) BOTTLE15 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE16")) BOTTLE16 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE17")) BOTTLE17 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE18")) BOTTLE18 = lValue; + else if (!Bstrcmp(szLabel,"BOTTLE19")) BOTTLE19 = lValue; + else if (!Bstrcmp(szLabel,"BARBROKE")) BARBROKE = lValue; + else if (!Bstrcmp(szLabel,"BLOODPOOL")) BLOODPOOL = lValue; + else if (!Bstrcmp(szLabel,"BANNER")) BANNER = lValue; + else if (!Bstrcmp(szLabel,"BLANKSCREEN")) BLANKSCREEN = lValue; + else if (!Bstrcmp(szLabel,"BLOODYPOLE")) BLOODYPOLE = lValue; + else if (!Bstrcmp(szLabel,"BLOOD")) BLOOD = lValue; + else if (!Bstrcmp(szLabel,"BURNING")) BURNING = lValue; + else if (!Bstrcmp(szLabel,"BLOODSPLAT1")) BLOODSPLAT1 = lValue; + else if (!Bstrcmp(szLabel,"BLOODSPLAT3")) BLOODSPLAT3 = lValue; + else if (!Bstrcmp(szLabel,"BLOODSPLAT2")) BLOODSPLAT2 = lValue; + else if (!Bstrcmp(szLabel,"BLOODSPLAT4")) BLOODSPLAT4 = lValue; + else if (!Bstrcmp(szLabel,"BURNING2")) BURNING2 = lValue; + else if (!Bstrcmp(szLabel,"BETAVERSION")) BETAVERSION = lValue; + else if (!Bstrcmp(szLabel,"BADGUYICON")) BADGUYICON = lValue; + else if (!Bstrcmp(szLabel,"BOTTOMSTATUSBAR")) BOTTOMSTATUSBAR = lValue; + else if (!Bstrcmp(szLabel,"BOOT_ICON")) BOOT_ICON = lValue; + else if (!Bstrcmp(szLabel,"BETASCREEN")) BETASCREEN = lValue; + else if (!Bstrcmp(szLabel,"BOSS1")) BOSS1 = lValue; + else if (!Bstrcmp(szLabel,"BOSS1STAYPUT")) BOSS1STAYPUT = lValue; + else if (!Bstrcmp(szLabel,"BOSS1SHOOT")) BOSS1SHOOT = lValue; + else if (!Bstrcmp(szLabel,"BOSS1LOB")) BOSS1LOB = lValue; + else if (!Bstrcmp(szLabel,"BOSSTOP")) BOSSTOP = lValue; + else if (!Bstrcmp(szLabel,"BOSS2")) BOSS2 = lValue; + else if (!Bstrcmp(szLabel,"BOSS3")) BOSS3 = lValue; + else if (!Bstrcmp(szLabel,"BIGFNTCURSOR")) BIGFNTCURSOR = lValue; + else if (!Bstrcmp(szLabel,"BIGALPHANUM")) BIGALPHANUM = lValue; + else if (!Bstrcmp(szLabel,"BIGPERIOD")) BIGPERIOD = lValue; + else if (!Bstrcmp(szLabel,"BIGCOMMA")) BIGCOMMA = lValue; + else if (!Bstrcmp(szLabel,"BIGX")) BIGX = lValue; + else if (!Bstrcmp(szLabel,"BIGQ")) BIGQ = lValue; + else if (!Bstrcmp(szLabel,"BIGSEMI")) BIGSEMI = lValue; + else if (!Bstrcmp(szLabel,"BIGCOLIN")) BIGCOLIN = lValue; + else if (!Bstrcmp(szLabel,"BIGAPPOS")) BIGAPPOS = lValue; + else if (!Bstrcmp(szLabel,"BLANK")) BLANK = lValue; + else if (!Bstrcmp(szLabel,"BUTTON1")) BUTTON1 = lValue; + else if (!Bstrcmp(szLabel,"BONUSSCREEN")) BONUSSCREEN = lValue; + else if (!Bstrcmp(szLabel,"BORNTOBEWILDSCREEN")) BORNTOBEWILDSCREEN = lValue; + else if (!Bstrcmp(szLabel,"BLIMP")) BLIMP = lValue; + else if (!Bstrcmp(szLabel,"BPANNEL3")) BPANNEL3 = lValue; + else if (!Bstrcmp(szLabel,"BROOM")) BROOM = lValue; + else if (!Bstrcmp(szLabel,"BOSS4")) BOSS4 = lValue; + else if (!Bstrcmp(szLabel,"BOSS4STAYPUT")) BOSS4STAYPUT = lValue; + break; + case 'C': + if (!Bstrcmp(szLabel,"CYCLER")) CYCLER = lValue; + else if (!Bstrcmp(szLabel,"CHAINGUNSPRITE")) CHAINGUNSPRITE = lValue; + else if (!Bstrcmp(szLabel,"CRYSTALAMMO")) CRYSTALAMMO = lValue; + else if (!Bstrcmp(szLabel,"COLA")) COLA = lValue; + else if (!Bstrcmp(szLabel,"CLOUDYOCEAN")) CLOUDYOCEAN = lValue; + else if (!Bstrcmp(szLabel,"CLOUDYSKIES")) CLOUDYSKIES = lValue; + else if (!Bstrcmp(szLabel,"CRACK1")) CRACK1 = lValue; + else if (!Bstrcmp(szLabel,"CRACK2")) CRACK2 = lValue; + else if (!Bstrcmp(szLabel,"CRACK3")) CRACK3 = lValue; + else if (!Bstrcmp(szLabel,"CRACK4")) CRACK4 = lValue; + else if (!Bstrcmp(szLabel,"CAMERAPOLE")) CAMERAPOLE = lValue; + else if (!Bstrcmp(szLabel,"CHAIR1")) CHAIR1 = lValue; + else if (!Bstrcmp(szLabel,"CHAIR2")) CHAIR2 = lValue; + else if (!Bstrcmp(szLabel,"CAMERA1")) CAMERA1 = lValue; + else if (!Bstrcmp(szLabel,"CHAIR3")) CHAIR3 = lValue; + else if (!Bstrcmp(szLabel,"CAMERALIGHT")) CAMERALIGHT = lValue; + else if (!Bstrcmp(szLabel,"CACTUS")) CACTUS = lValue; + else if (!Bstrcmp(szLabel,"CACTUSBROKE")) CACTUSBROKE = lValue; + else if (!Bstrcmp(szLabel,"CONE")) CONE = lValue; + else if (!Bstrcmp(szLabel,"CLOCK")) CLOCK = lValue; + else if (!Bstrcmp(szLabel,"CIRCLEPANNEL")) CIRCLEPANNEL = lValue; + else if (!Bstrcmp(szLabel,"CIRCLEPANNELBROKE")) CIRCLEPANNELBROKE = lValue; + else if (!Bstrcmp(szLabel,"COLAMACHINE")) COLAMACHINE = lValue; + else if (!Bstrcmp(szLabel,"COLAMACHINEBROKE")) COLAMACHINEBROKE = lValue; + else if (!Bstrcmp(szLabel,"CRANEPOLE")) CRANEPOLE = lValue; + else if (!Bstrcmp(szLabel,"CRANE")) CRANE = lValue; + else if (!Bstrcmp(szLabel,"CANWITHSOMETHING")) CANWITHSOMETHING = lValue; + else if (!Bstrcmp(szLabel,"CEILINGSTEAM")) CEILINGSTEAM = lValue; + else if (!Bstrcmp(szLabel,"COOLEXPLOSION1")) COOLEXPLOSION1 = lValue; + else if (!Bstrcmp(szLabel,"CANNONBALL")) CANNONBALL = lValue; + else if (!Bstrcmp(szLabel,"COMMANDER")) COMMANDER = lValue; + else if (!Bstrcmp(szLabel,"COMMANDERSTAYPUT")) COMMANDERSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"CRACKKNUCKLES")) CRACKKNUCKLES = lValue; + else if (!Bstrcmp(szLabel,"CAMCORNER")) CAMCORNER = lValue; + else if (!Bstrcmp(szLabel,"CAMLIGHT")) CAMLIGHT = lValue; + else if (!Bstrcmp(szLabel,"CROSSHAIR")) CROSSHAIR = lValue; + else if (!Bstrcmp(szLabel,"CLIPINHAND")) CLIPINHAND = lValue; + else if (!Bstrcmp(szLabel,"CHAINGUN")) CHAINGUN = lValue; + else if (!Bstrcmp(szLabel,"CATLITE")) CATLITE = lValue; + else if (!Bstrcmp(szLabel,"COFFEEMACHINE")) COFFEEMACHINE = lValue; + else if (!Bstrcmp(szLabel,"CUPS")) CUPS = lValue; + else if (!Bstrcmp(szLabel,"COFFEEMUG")) COFFEEMUG = lValue; + else if (!Bstrcmp(szLabel,"CHESTOFGOLD")) CHESTOFGOLD = lValue; + else if (!Bstrcmp(szLabel,"CANWITHSOMETHING2")) CANWITHSOMETHING2 = lValue; + else if (!Bstrcmp(szLabel,"CANWITHSOMETHING3")) CANWITHSOMETHING3 = lValue; + else if (!Bstrcmp(szLabel,"CANWITHSOMETHING4")) CANWITHSOMETHING4 = lValue; + break; + case 'D': + if (!Bstrcmp(szLabel,"DEVISTATORSPRITE")) DEVISTATORSPRITE = lValue; + else if (!Bstrcmp(szLabel,"DEVISTATORAMMO")) DEVISTATORAMMO = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE5")) DOORTILE5 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE6")) DOORTILE6 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE1")) DOORTILE1 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE2")) DOORTILE2 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE3")) DOORTILE3 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE4")) DOORTILE4 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE7")) DOORTILE7 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE8")) DOORTILE8 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE9")) DOORTILE9 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE10")) DOORTILE10 = lValue; + else if (!Bstrcmp(szLabel,"DOORSHOCK")) DOORSHOCK = lValue; + else if (!Bstrcmp(szLabel,"DIPSWITCH")) DIPSWITCH = lValue; + else if (!Bstrcmp(szLabel,"DIPSWITCH2")) DIPSWITCH2 = lValue; + else if (!Bstrcmp(szLabel,"DIPSWITCH3")) DIPSWITCH3 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE22")) DOORTILE22 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE18")) DOORTILE18 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE19")) DOORTILE19 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE20")) DOORTILE20 = lValue; + else if (!Bstrcmp(szLabel,"DOMELITE")) DOMELITE = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE14")) DOORTILE14 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE16")) DOORTILE16 = lValue; + else if (!Bstrcmp(szLabel,"DONUTS")) DONUTS = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE15")) DOORTILE15 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE21")) DOORTILE21 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE17")) DOORTILE17 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE11")) DOORTILE11 = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE12")) DOORTILE12 = lValue; + else if (!Bstrcmp(szLabel,"DUKELYINGDEAD")) DUKELYINGDEAD = lValue; + else if (!Bstrcmp(szLabel,"DUKETORSO")) DUKETORSO = lValue; + else if (!Bstrcmp(szLabel,"DUKEGUN")) DUKEGUN = lValue; + else if (!Bstrcmp(szLabel,"DUKELEG")) DUKELEG = lValue; + else if (!Bstrcmp(szLabel,"DEVISTATORBLAST")) DEVISTATORBLAST = lValue; + else if (!Bstrcmp(szLabel,"DRONE")) DRONE = lValue; + else if (!Bstrcmp(szLabel,"DUKEICON")) DUKEICON = lValue; + else if (!Bstrcmp(szLabel,"DIGITALNUM")) DIGITALNUM = lValue; + else if (!Bstrcmp(szLabel,"DUKECAR")) DUKECAR = lValue; + else if (!Bstrcmp(szLabel,"DREALMS")) DREALMS = lValue; + else if (!Bstrcmp(szLabel,"DUKENUKEM")) DUKENUKEM = lValue; + else if (!Bstrcmp(szLabel,"DEVISTATOR")) DEVISTATOR = lValue; + else if (!Bstrcmp(szLabel,"DUKECUTOUT")) DUKECUTOUT = lValue; + else if (!Bstrcmp(szLabel,"DUCK")) DUCK = lValue; + else if (!Bstrcmp(szLabel,"DESKLAMP")) DESKLAMP = lValue; + else if (!Bstrcmp(szLabel,"DOORTILE23")) DOORTILE23 = lValue; + else if (!Bstrcmp(szLabel,"DONUTS2")) DONUTS2 = lValue; + else if (!Bstrcmp(szLabel,"DESKPHONE")) DESKPHONE = lValue; + else if (!Bstrcmp(szLabel,"DUKEBURGER")) DUKEBURGER = lValue; + else if (!Bstrcmp(szLabel,"DOLPHIN1")) DOLPHIN1 = lValue; + else if (!Bstrcmp(szLabel,"DOLPHIN2")) DOLPHIN2 = lValue; + else if (!Bstrcmp(szLabel,"DUKETAG")) DUKETAG = lValue; + break; + case 'E': + if (!Bstrcmp(szLabel,"EPISODE")) EPISODE = lValue; + else if (!Bstrcmp(szLabel,"EGG")) EGG = lValue; + else if (!Bstrcmp(szLabel,"EXPLODINGBARREL")) EXPLODINGBARREL = lValue; + else if (!Bstrcmp(szLabel,"EXPLODINGBARREL2")) EXPLODINGBARREL2 = lValue; + else if (!Bstrcmp(szLabel,"EXPLOSION2")) EXPLOSION2 = lValue; + else if (!Bstrcmp(szLabel,"EXPLOSION2BOT")) EXPLOSION2BOT = lValue; + else if (!Bstrcmp(szLabel,"ENDALPHANUM")) ENDALPHANUM = lValue; + break; + case 'F': + if (!Bstrcmp(szLabel,"FOF")) FOF = lValue; + else if (!Bstrcmp(szLabel,"FIRSTGUNSPRITE")) FIRSTGUNSPRITE = lValue; + else if (!Bstrcmp(szLabel,"FREEZESPRITE")) FREEZESPRITE = lValue; + else if (!Bstrcmp(szLabel,"FREEZEAMMO")) FREEZEAMMO = lValue; + else if (!Bstrcmp(szLabel,"FIRSTAID")) FIRSTAID = lValue; + else if (!Bstrcmp(szLabel,"FRANKENSTINESWITCH")) FRANKENSTINESWITCH = lValue; + else if (!Bstrcmp(szLabel,"FLOORSLIME")) FLOORSLIME = lValue; + else if (!Bstrcmp(szLabel,"FANSPRITE")) FANSPRITE = lValue; + else if (!Bstrcmp(szLabel,"FANSPRITEBROKE")) FANSPRITEBROKE = lValue; + else if (!Bstrcmp(szLabel,"FANSHADOW")) FANSHADOW = lValue; + else if (!Bstrcmp(szLabel,"FANSHADOWBROKE")) FANSHADOWBROKE = lValue; + else if (!Bstrcmp(szLabel,"FUELPOD")) FUELPOD = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINTS")) FOOTPRINTS = lValue; + else if (!Bstrcmp(szLabel,"FEMMAG1")) FEMMAG1 = lValue; + else if (!Bstrcmp(szLabel,"FEMMAG2")) FEMMAG2 = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINTS2")) FOOTPRINTS2 = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINTS3")) FOOTPRINTS3 = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINTS4")) FOOTPRINTS4 = lValue; + else if (!Bstrcmp(szLabel,"FIREEXT")) FIREEXT = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC5")) FEMPIC5 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC6")) FEMPIC6 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC7")) FEMPIC7 = lValue; + else if (!Bstrcmp(szLabel,"FLOORPLASMA")) FLOORPLASMA = lValue; + else if (!Bstrcmp(szLabel,"FIREBARREL")) FIREBARREL = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC1")) FEMPIC1 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC2")) FEMPIC2 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC3")) FEMPIC3 = lValue; + else if (!Bstrcmp(szLabel,"FEMPIC4")) FEMPIC4 = lValue; + else if (!Bstrcmp(szLabel,"FEM1")) FEM1 = lValue; + else if (!Bstrcmp(szLabel,"FEM2")) FEM2 = lValue; + else if (!Bstrcmp(szLabel,"FEM3")) FEM3 = lValue; + else if (!Bstrcmp(szLabel,"FEM5")) FEM5 = lValue; + else if (!Bstrcmp(szLabel,"FEM4")) FEM4 = lValue; + else if (!Bstrcmp(szLabel,"FEM6")) FEM6 = lValue; + else if (!Bstrcmp(szLabel,"FEM6PAD")) FEM6PAD = lValue; + else if (!Bstrcmp(szLabel,"FEM8")) FEM8 = lValue; + else if (!Bstrcmp(szLabel,"FETUSJIB")) FETUSJIB = lValue; + else if (!Bstrcmp(szLabel,"FETUS")) FETUS = lValue; + else if (!Bstrcmp(szLabel,"FETUSBROKE")) FETUSBROKE = lValue; + else if (!Bstrcmp(szLabel,"FIREVASE")) FIREVASE = lValue; + else if (!Bstrcmp(szLabel,"FEM7")) FEM7 = lValue; + else if (!Bstrcmp(szLabel,"FIRELASER")) FIRELASER = lValue; + else if (!Bstrcmp(szLabel,"FIST")) FIST = lValue; + else if (!Bstrcmp(szLabel,"FREEZEBLAST")) FREEZEBLAST = lValue; + else if (!Bstrcmp(szLabel,"FORCERIPPLE")) FORCERIPPLE = lValue; + else if (!Bstrcmp(szLabel,"FECES")) FECES = lValue; + else if (!Bstrcmp(szLabel,"FIRE")) FIRE = lValue; + else if (!Bstrcmp(szLabel,"FIRE2")) FIRE2 = lValue; + else if (!Bstrcmp(szLabel,"FLOORFLAME")) FLOORFLAME = lValue; + else if (!Bstrcmp(szLabel,"F1HELP")) F1HELP = lValue; + else if (!Bstrcmp(szLabel,"FOODICON")) FOODICON = lValue; + else if (!Bstrcmp(szLabel,"FIRSTAID_ICON")) FIRSTAID_ICON = lValue; + else if (!Bstrcmp(szLabel,"FRAGBAR")) FRAGBAR = lValue; + else if (!Bstrcmp(szLabel,"FIRSTGUN")) FIRSTGUN = lValue; + else if (!Bstrcmp(szLabel,"FIRSTGUNRELOAD")) FIRSTGUNRELOAD = lValue; + else if (!Bstrcmp(szLabel,"FALLINGCLIP")) FALLINGCLIP = lValue; + else if (!Bstrcmp(szLabel,"FREEZE")) FREEZE = lValue; + else if (!Bstrcmp(szLabel,"FORCESPHERE")) FORCESPHERE = lValue; + else if (!Bstrcmp(szLabel,"FEM9")) FEM9 = lValue; + else if (!Bstrcmp(szLabel,"FOOTPRINT")) FOOTPRINT = lValue; + else if (!Bstrcmp(szLabel,"FRAMEEFFECT1")) FRAMEEFFECT1 = lValue; + else if (!Bstrcmp(szLabel,"FRAMEEFFECT1_13")) FRAMEEFFECT1_13 = lValue; + else if (!Bstrcmp(szLabel,"FLOORBASKET")) FLOORBASKET = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT1")) FOODOBJECT1 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT2")) FOODOBJECT2 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT3")) FOODOBJECT3 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT4")) FOODOBJECT4 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT5")) FOODOBJECT5 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT6")) FOODOBJECT6 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT7")) FOODOBJECT7 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT8")) FOODOBJECT8 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT9")) FOODOBJECT9 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT10")) FOODOBJECT10 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT11")) FOODOBJECT11 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT12")) FOODOBJECT12 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT13")) FOODOBJECT13 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT14")) FOODOBJECT14 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT15")) FOODOBJECT15 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT16")) FOODOBJECT16 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT17")) FOODOBJECT17 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT18")) FOODOBJECT18 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT19")) FOODOBJECT19 = lValue; + else if (!Bstrcmp(szLabel,"FOODOBJECT20")) FOODOBJECT20 = lValue; + else if (!Bstrcmp(szLabel,"FEATHEREDCHICKEN")) FEATHEREDCHICKEN = lValue; + else if (!Bstrcmp(szLabel,"FEM10")) FEM10 = lValue; + break; + case 'G': + if (!Bstrcmp(szLabel,"GPSPEED")) GPSPEED = lValue; + else if (!Bstrcmp(szLabel,"GROWSPRITEICON")) GROWSPRITEICON = lValue; + else if (!Bstrcmp(szLabel,"GROWAMMO")) GROWAMMO = lValue; + else if (!Bstrcmp(szLabel,"GLASS")) GLASS = lValue; + else if (!Bstrcmp(szLabel,"GLASS2")) GLASS2 = lValue; + else if (!Bstrcmp(szLabel,"GRATE1")) GRATE1 = lValue; + else if (!Bstrcmp(szLabel,"GENERICPOLE")) GENERICPOLE = lValue; + else if (!Bstrcmp(szLabel,"GLASSPIECES")) GLASSPIECES = lValue; + else if (!Bstrcmp(szLabel,"GREENSLIME")) GREENSLIME = lValue; + else if (!Bstrcmp(szLabel,"GROWSPARK")) GROWSPARK = lValue; + else if (!Bstrcmp(szLabel,"GETICON")) GETICON = lValue; + else if (!Bstrcmp(szLabel,"GLAIR")) GLAIR = lValue; + else if (!Bstrcmp(szLabel,"GLASS3")) GLASS3 = lValue; + else if (!Bstrcmp(szLabel,"GUNPOWDERBARREL")) GUNPOWDERBARREL = lValue; + else if (!Bstrcmp(szLabel,"GAVALS")) GAVALS = lValue; + else if (!Bstrcmp(szLabel,"GAVALS2")) GAVALS2 = lValue; + else if (!Bstrcmp(szLabel,"GUMBALLMACHINE")) GUMBALLMACHINE = lValue; + else if (!Bstrcmp(szLabel,"GUMBALLMACHINEBROKE")) GUMBALLMACHINEBROKE = lValue; + else if (!Bstrcmp(szLabel,"GENERICPOLE2")) GENERICPOLE2 = lValue; + break; + case 'H': + if (!Bstrcmp(szLabel,"HEAVYHBOMB")) HEAVYHBOMB = lValue; + else if (!Bstrcmp(szLabel,"HEALTHBOX")) HEALTHBOX = lValue; + else if (!Bstrcmp(szLabel,"HBOMBAMMO")) HBOMBAMMO = lValue; + else if (!Bstrcmp(szLabel,"HEATSENSOR")) HEATSENSOR = lValue; + else if (!Bstrcmp(szLabel,"HURTRAIL")) HURTRAIL = lValue; + else if (!Bstrcmp(szLabel,"HYDROPLANT")) HYDROPLANT = lValue; + else if (!Bstrcmp(szLabel,"HANGLIGHT")) HANGLIGHT = lValue; + else if (!Bstrcmp(szLabel,"HYDRENT")) HYDRENT = lValue; + else if (!Bstrcmp(szLabel,"HANGOOZ")) HANGOOZ = lValue; + else if (!Bstrcmp(szLabel,"HORSEONSIDE")) HORSEONSIDE = lValue; + else if (!Bstrcmp(szLabel,"HORSELITE")) HORSELITE = lValue; + else if (!Bstrcmp(szLabel,"HANDSWITCH")) HANDSWITCH = lValue; + else if (!Bstrcmp(szLabel,"HANDPRINTSWITCH")) HANDPRINTSWITCH = lValue; + else if (!Bstrcmp(szLabel,"HELECOPT")) HELECOPT = lValue; + else if (!Bstrcmp(szLabel,"HOLODUKE")) HOLODUKE = lValue; + else if (!Bstrcmp(szLabel,"HEADJIB1")) HEADJIB1 = lValue; + else if (!Bstrcmp(szLabel,"HEADERBAR")) HEADERBAR = lValue; + else if (!Bstrcmp(szLabel,"HEAT_ICON")) HEAT_ICON = lValue; + else if (!Bstrcmp(szLabel,"HOLODUKE_ICON")) HOLODUKE_ICON = lValue; + else if (!Bstrcmp(szLabel,"HAND")) HAND = lValue; + else if (!Bstrcmp(szLabel,"HANDHOLDINGLASER")) HANDHOLDINGLASER = lValue; + else if (!Bstrcmp(szLabel,"HANDHOLDINGACCESS")) HANDHOLDINGACCESS = lValue; + else if (!Bstrcmp(szLabel,"HANDREMOTE")) HANDREMOTE = lValue; + else if (!Bstrcmp(szLabel,"HANDTHROW")) HANDTHROW = lValue; + else if (!Bstrcmp(szLabel,"HATRACK")) HATRACK = lValue; + else if (!Bstrcmp(szLabel,"HOTMEAT")) HOTMEAT = lValue; + else if (!Bstrcmp(szLabel,"HEADLAMP")) HEADLAMP = lValue; + break; + case 'I': + if (!Bstrcmp(szLabel,"INVENTORYBOX")) INVENTORYBOX = lValue; + else if (!Bstrcmp(szLabel,"IVUNIT")) IVUNIT = lValue; + else if (!Bstrcmp(szLabel,"INDY")) INDY = lValue; + else if (!Bstrcmp(szLabel,"INNERJAW")) INNERJAW = lValue; + else if (!Bstrcmp(szLabel,"INGAMEDUKETHREEDEE")) INGAMEDUKETHREEDEE = lValue; + break; + case 'J': + if (!Bstrcmp(szLabel,"JETPACK")) JETPACK = lValue; + else if (!Bstrcmp(szLabel,"JAILBARBREAK")) JAILBARBREAK = lValue; + else if (!Bstrcmp(szLabel,"JIBS1")) JIBS1 = lValue; + else if (!Bstrcmp(szLabel,"JIBS2")) JIBS2 = lValue; + else if (!Bstrcmp(szLabel,"JIBS3")) JIBS3 = lValue; + else if (!Bstrcmp(szLabel,"JIBS4")) JIBS4 = lValue; + else if (!Bstrcmp(szLabel,"JIBS5")) JIBS5 = lValue; + else if (!Bstrcmp(szLabel,"JIBS6")) JIBS6 = lValue; + else if (!Bstrcmp(szLabel,"JETPACK_ICON")) JETPACK_ICON = lValue; + else if (!Bstrcmp(szLabel,"JOLLYMEAL")) JOLLYMEAL = lValue; + else if (!Bstrcmp(szLabel,"JURYGUY")) JURYGUY = lValue; + break; + case 'K': + if (!Bstrcmp(szLabel,"KILLSICON")) KILLSICON = lValue; + else if (!Bstrcmp(szLabel,"KNEE")) KNEE = lValue; + break; + case 'L': + if (!Bstrcmp(szLabel,"LOCATORS")) LOCATORS = lValue; + else if (!Bstrcmp(szLabel,"LA")) LA = lValue; + else if (!Bstrcmp(szLabel,"LIGHTSWITCH")) LIGHTSWITCH = lValue; + else if (!Bstrcmp(szLabel,"LIGHTSWITCH2")) LIGHTSWITCH2 = lValue; + else if (!Bstrcmp(szLabel,"LOCKSWITCH1")) LOCKSWITCH1 = lValue; + else if (!Bstrcmp(szLabel,"LUKE")) LUKE = lValue; + else if (!Bstrcmp(szLabel,"LOOGIE")) LOOGIE = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOP")) LIZTROOP = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPRUNNING")) LIZTROOPRUNNING = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPSTAYPUT")) LIZTROOPSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"LIZTOP")) LIZTOP = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPSHOOT")) LIZTROOPSHOOT = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPJETPACK")) LIZTROOPJETPACK = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPDSPRITE")) LIZTROOPDSPRITE = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPONTOILET")) LIZTROOPONTOILET = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPJUSTSIT")) LIZTROOPJUSTSIT = lValue; + else if (!Bstrcmp(szLabel,"LIZTROOPDUCKING")) LIZTROOPDUCKING = lValue; + else if (!Bstrcmp(szLabel,"LEGJIB1")) LEGJIB1 = lValue; + else if (!Bstrcmp(szLabel,"LIZMAN")) LIZMAN = lValue; + else if (!Bstrcmp(szLabel,"LIZMANSTAYPUT")) LIZMANSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"LIZMANSPITTING")) LIZMANSPITTING = lValue; + else if (!Bstrcmp(szLabel,"LIZMANFEEDING")) LIZMANFEEDING = lValue; + else if (!Bstrcmp(szLabel,"LIZMANJUMP")) LIZMANJUMP = lValue; + else if (!Bstrcmp(szLabel,"LIZMANDEADSPRITE")) LIZMANDEADSPRITE = lValue; + else if (!Bstrcmp(szLabel,"LIZMANHEAD1")) LIZMANHEAD1 = lValue; + else if (!Bstrcmp(szLabel,"LIZMANARM1")) LIZMANARM1 = lValue; + else if (!Bstrcmp(szLabel,"LIZMANLEG1")) LIZMANLEG1 = lValue; + else if (!Bstrcmp(szLabel,"LOGO")) LOGO = lValue; + else if (!Bstrcmp(szLabel,"LASERLINE")) LASERLINE = lValue; + else if (!Bstrcmp(szLabel,"LASERSITE")) LASERSITE = lValue; + else if (!Bstrcmp(szLabel,"LOADSCREEN")) LOADSCREEN = lValue; + else if (!Bstrcmp(szLabel,"LAVABUBBLE")) LAVABUBBLE = lValue; + else if (!Bstrcmp(szLabel,"LETTER")) LETTER = lValue; + break; + case 'M': + if (!Bstrcmp(szLabel,"MUSICANDSFX")) MUSICANDSFX = lValue; + else if (!Bstrcmp(szLabel,"MASTERSWITCH")) MASTERSWITCH = lValue; + else if (!Bstrcmp(szLabel,"MIRRORBROKE")) MIRRORBROKE = lValue; + else if (!Bstrcmp(szLabel,"MOONSKY1")) MOONSKY1 = lValue; + else if (!Bstrcmp(szLabel,"MOONSKY2")) MOONSKY2 = lValue; + else if (!Bstrcmp(szLabel,"MOONSKY3")) MOONSKY3 = lValue; + else if (!Bstrcmp(szLabel,"MOONSKY4")) MOONSKY4 = lValue; + else if (!Bstrcmp(szLabel,"MULTISWITCH")) MULTISWITCH = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL9")) MASKWALL9 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL1")) MASKWALL1 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL10")) MASKWALL10 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL11")) MASKWALL11 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL5")) MASKWALL5 = lValue; + else if (!Bstrcmp(szLabel,"MIRROR")) MIRROR = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL12")) MASKWALL12 = lValue; + else if (!Bstrcmp(szLabel,"MOVIECAMERA")) MOVIECAMERA = lValue; + else if (!Bstrcmp(szLabel,"MIKE")) MIKE = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL13")) MASKWALL13 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL2")) MASKWALL2 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL3")) MASKWALL3 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL4")) MASKWALL4 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL14")) MASKWALL14 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL15")) MASKWALL15 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL6")) MASKWALL6 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL8")) MASKWALL8 = lValue; + else if (!Bstrcmp(szLabel,"MASKWALL7")) MASKWALL7 = lValue; + else if (!Bstrcmp(szLabel,"MONEY")) MONEY = lValue; + else if (!Bstrcmp(szLabel,"MONK")) MONK = lValue; + else if (!Bstrcmp(szLabel,"MORTER")) MORTER = lValue; + else if (!Bstrcmp(szLabel,"MENUSCREEN")) MENUSCREEN = lValue; + else if (!Bstrcmp(szLabel,"MENUBAR")) MENUBAR = lValue; + else if (!Bstrcmp(szLabel,"MOUSECURSOR")) MOUSECURSOR = lValue; + else if (!Bstrcmp(szLabel,"MINIFONT")) MINIFONT = lValue; + else if (!Bstrcmp(szLabel,"MAIL")) MAIL = lValue; + else if (!Bstrcmp(szLabel,"MAILBAG")) MAILBAG = lValue; + else if (!Bstrcmp(szLabel,"METER")) METER = lValue; + else if (!Bstrcmp(szLabel,"MACE")) MACE = lValue; + else if (!Bstrcmp(szLabel,"MOP")) MOP = lValue; + else if (!Bstrcmp(szLabel,"MAN")) MAN = lValue; + else if (!Bstrcmp(szLabel,"MAN2")) MAN2 = lValue; + break; + case 'N': + if (!Bstrcmp(szLabel,"NUKEBUTTON")) NUKEBUTTON = lValue; + else if (!Bstrcmp(szLabel,"NAKED1")) NAKED1 = lValue; + else if (!Bstrcmp(szLabel,"NEON1")) NEON1 = lValue; + else if (!Bstrcmp(szLabel,"NEON2")) NEON2 = lValue; + else if (!Bstrcmp(szLabel,"NEON3")) NEON3 = lValue; + else if (!Bstrcmp(szLabel,"NEON4")) NEON4 = lValue; + else if (!Bstrcmp(szLabel,"NEON5")) NEON5 = lValue; + else if (!Bstrcmp(szLabel,"NEON6")) NEON6 = lValue; + else if (!Bstrcmp(szLabel,"NUKEBARREL")) NUKEBARREL = lValue; + else if (!Bstrcmp(szLabel,"NUKEBARRELDENTED")) NUKEBARRELDENTED = lValue; + else if (!Bstrcmp(szLabel,"NUKEBARRELLEAKED")) NUKEBARRELLEAKED = lValue; + else if (!Bstrcmp(szLabel,"NOTCHON")) NOTCHON = lValue; + else if (!Bstrcmp(szLabel,"NOTCHOFF")) NOTCHOFF = lValue; + else if (!Bstrcmp(szLabel,"NUKEWARNINGICON")) NUKEWARNINGICON = lValue; + else if (!Bstrcmp(szLabel,"NEWBEAST")) NEWBEAST = lValue; + else if (!Bstrcmp(szLabel,"NEWBEASTSTAYPUT")) NEWBEASTSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"NEWBEASTJUMP")) NEWBEASTJUMP = lValue; + else if (!Bstrcmp(szLabel,"NEWBEASTHANG")) NEWBEASTHANG = lValue; + else if (!Bstrcmp(szLabel,"NEWBEASTHANGDEAD")) NEWBEASTHANGDEAD = lValue; + else if (!Bstrcmp(szLabel,"NATURALLIGHTNING")) NATURALLIGHTNING = lValue; + break; + case 'O': + if (!Bstrcmp(szLabel,"OJ")) OJ = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE1")) OCEANSPRITE1 = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE2")) OCEANSPRITE2 = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE3")) OCEANSPRITE3 = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE4")) OCEANSPRITE4 = lValue; + else if (!Bstrcmp(szLabel,"OCEANSPRITE5")) OCEANSPRITE5 = lValue; + else if (!Bstrcmp(szLabel,"OOZFILTER")) OOZFILTER = lValue; + else if (!Bstrcmp(szLabel,"OCTABRAIN")) OCTABRAIN = lValue; + else if (!Bstrcmp(szLabel,"OCTABRAINSTAYPUT")) OCTABRAINSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"OCTATOP")) OCTATOP = lValue; + else if (!Bstrcmp(szLabel,"OCTADEADSPRITE")) OCTADEADSPRITE = lValue; + else if (!Bstrcmp(szLabel,"OOZ")) OOZ = lValue; + else if (!Bstrcmp(szLabel,"OOZ2")) OOZ2 = lValue; + else if (!Bstrcmp(szLabel,"ORGANTIC")) ORGANTIC = lValue; + else if (!Bstrcmp(szLabel,"ORDERING")) ORDERING = lValue; + break; + case 'P': + if (!Bstrcmp(szLabel,"PANNEL1")) PANNEL1 = lValue; + else if (!Bstrcmp(szLabel,"PANNEL2")) PANNEL2 = lValue; + else if (!Bstrcmp(szLabel,"PIPE2")) PIPE2 = lValue; + else if (!Bstrcmp(szLabel,"PIPE1B")) PIPE1B = lValue; + else if (!Bstrcmp(szLabel,"PIPE3")) PIPE3 = lValue; + else if (!Bstrcmp(szLabel,"PIPE1")) PIPE1 = lValue; + else if (!Bstrcmp(szLabel,"PIPE2B")) PIPE2B = lValue; + else if (!Bstrcmp(szLabel,"POT1")) POT1 = lValue; + else if (!Bstrcmp(szLabel,"POT2")) POT2 = lValue; + else if (!Bstrcmp(szLabel,"POT3")) POT3 = lValue; + else if (!Bstrcmp(szLabel,"PIPE3B")) PIPE3B = lValue; + else if (!Bstrcmp(szLabel,"POWERSWITCH1")) POWERSWITCH1 = lValue; + else if (!Bstrcmp(szLabel,"POWERSWITCH2")) POWERSWITCH2 = lValue; + else if (!Bstrcmp(szLabel,"POCKET")) POCKET = lValue; + else if (!Bstrcmp(szLabel,"PIPE5")) PIPE5 = lValue; + else if (!Bstrcmp(szLabel,"PIPE6")) PIPE6 = lValue; + else if (!Bstrcmp(szLabel,"PIPE4")) PIPE4 = lValue; + else if (!Bstrcmp(szLabel,"PIPE4B")) PIPE4B = lValue; + else if (!Bstrcmp(szLabel,"PIPE5B")) PIPE5B = lValue; + else if (!Bstrcmp(szLabel,"PLUG")) PLUG = lValue; + else if (!Bstrcmp(szLabel,"PULLSWITCH")) PULLSWITCH = lValue; + else if (!Bstrcmp(szLabel,"PIPE6B")) PIPE6B = lValue; + else if (!Bstrcmp(szLabel,"PODFEM1")) PODFEM1 = lValue; + else if (!Bstrcmp(szLabel,"PLAYERONWATER")) PLAYERONWATER = lValue; + else if (!Bstrcmp(szLabel,"PIGCOP")) PIGCOP = lValue; + else if (!Bstrcmp(szLabel,"PIGCOPSTAYPUT")) PIGCOPSTAYPUT = lValue; + else if (!Bstrcmp(szLabel,"PIGCOPDIVE")) PIGCOPDIVE = lValue; + else if (!Bstrcmp(szLabel,"PIGCOPDEADSPRITE")) PIGCOPDEADSPRITE = lValue; + else if (!Bstrcmp(szLabel,"PIGTOP")) PIGTOP = lValue; + else if (!Bstrcmp(szLabel,"PLAYERISHERE")) PLAYERISHERE = lValue; + else if (!Bstrcmp(szLabel,"PLAYERWASHERE")) PLAYERWASHERE = lValue; + else if (!Bstrcmp(szLabel,"PLUTOPAKSPRITE")) PLUTOPAKSPRITE = lValue; + else if (!Bstrcmp(szLabel,"POOP")) POOP = lValue; + else if (!Bstrcmp(szLabel,"PANNEL3")) PANNEL3 = lValue; + else if (!Bstrcmp(szLabel,"PURPLELAVA")) PURPLELAVA = lValue; + else if (!Bstrcmp(szLabel,"POLICELIGHTPOLE")) POLICELIGHTPOLE = lValue; + else if (!Bstrcmp(szLabel,"PUKE")) PUKE = lValue; + else if (!Bstrcmp(szLabel,"PAPER")) PAPER = lValue; + else if (!Bstrcmp(szLabel,"PIRATE1A")) PIRATE1A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE4A")) PIRATE4A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE2A")) PIRATE2A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE5A")) PIRATE5A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE3A")) PIRATE3A = lValue; + else if (!Bstrcmp(szLabel,"PIRATE6A")) PIRATE6A = lValue; + else if (!Bstrcmp(szLabel,"PIRATEHALF")) PIRATEHALF = lValue; + else if (!Bstrcmp(szLabel,"PLEASEWAIT")) PLEASEWAIT = lValue; + break; + case 'Q': + if (!Bstrcmp(szLabel,"QUEBALL")) QUEBALL = lValue; + break; + case 'R': + if (!Bstrcmp(szLabel,"RESPAWN")) RESPAWN = lValue; + else if (!Bstrcmp(szLabel,"RPGSPRITE")) RPGSPRITE = lValue; + else if (!Bstrcmp(szLabel,"RPGAMMO")) RPGAMMO = lValue; + else if (!Bstrcmp(szLabel,"REDSKY1")) REDSKY1 = lValue; + else if (!Bstrcmp(szLabel,"REDSKY2")) REDSKY2 = lValue; + else if (!Bstrcmp(szLabel,"REFLECTWATERTILE")) REFLECTWATERTILE = lValue; + else if (!Bstrcmp(szLabel,"REACTOR2")) REACTOR2 = lValue; + else if (!Bstrcmp(szLabel,"REACTOR2BURNT")) REACTOR2BURNT = lValue; + else if (!Bstrcmp(szLabel,"REACTOR2SPARK")) REACTOR2SPARK = lValue; + else if (!Bstrcmp(szLabel,"RUBBERCAN")) RUBBERCAN = lValue; + else if (!Bstrcmp(szLabel,"REACTOR")) REACTOR = lValue; + else if (!Bstrcmp(szLabel,"REACTORSPARK")) REACTORSPARK = lValue; + else if (!Bstrcmp(szLabel,"REACTORBURNT")) REACTORBURNT = lValue; + else if (!Bstrcmp(szLabel,"RAT")) RAT = lValue; + else if (!Bstrcmp(szLabel,"RADIUSEXPLOSION")) RADIUSEXPLOSION = lValue; + else if (!Bstrcmp(szLabel,"RECON")) RECON = lValue; + else if (!Bstrcmp(szLabel,"ROTATEGUN")) ROTATEGUN = lValue; + else if (!Bstrcmp(szLabel,"RPGGUN")) RPGGUN = lValue; + else if (!Bstrcmp(szLabel,"RPGMUZZLEFLASH")) RPGMUZZLEFLASH = lValue; + else if (!Bstrcmp(szLabel,"RPG")) RPG = lValue; + else if (!Bstrcmp(szLabel,"RESPAWNMARKERRED")) RESPAWNMARKERRED = lValue; + else if (!Bstrcmp(szLabel,"RESPAWNMARKERYELLOW")) RESPAWNMARKERYELLOW = lValue; + else if (!Bstrcmp(szLabel,"RESPAWNMARKERGREEN")) RESPAWNMARKERGREEN = lValue; + else if (!Bstrcmp(szLabel,"ROBOTDOG")) ROBOTDOG = lValue; + else if (!Bstrcmp(szLabel,"ROBOTPIRATE")) ROBOTPIRATE = lValue; + else if (!Bstrcmp(szLabel,"ROBOTMOUSE")) ROBOTMOUSE = lValue; + else if (!Bstrcmp(szLabel,"ROBOTDOG2")) ROBOTDOG2 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT1")) RESERVEDSLOT1 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT2")) RESERVEDSLOT2 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT3")) RESERVEDSLOT3 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT4")) RESERVEDSLOT4 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT5")) RESERVEDSLOT5 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT6")) RESERVEDSLOT6 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT7")) RESERVEDSLOT7 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT8")) RESERVEDSLOT8 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT9")) RESERVEDSLOT9 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT10")) RESERVEDSLOT10 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT11")) RESERVEDSLOT11 = lValue; + else if (!Bstrcmp(szLabel,"RESERVEDSLOT12")) RESERVEDSLOT12 = lValue; + break; + case 'S': + if (!Bstrcmp(szLabel,"SECTOREFFECTOR")) SECTOREFFECTOR = lValue; + else if (!Bstrcmp(szLabel,"SHRINKERSPRITE")) SHRINKERSPRITE = lValue; + else if (!Bstrcmp(szLabel,"SHOTGUNSPRITE")) SHOTGUNSPRITE = lValue; + else if (!Bstrcmp(szLabel,"SHOTGUNAMMO")) SHOTGUNAMMO = lValue; + else if (!Bstrcmp(szLabel,"SIXPAK")) SIXPAK = lValue; + else if (!Bstrcmp(szLabel,"SHIELD")) SHIELD = lValue; + else if (!Bstrcmp(szLabel,"STEROIDS")) STEROIDS = lValue; + else if (!Bstrcmp(szLabel,"SLOTDOOR")) SLOTDOOR = lValue; + else if (!Bstrcmp(szLabel,"SPACEDOORSWITCH")) SPACEDOORSWITCH = lValue; + else if (!Bstrcmp(szLabel,"SPACELIGHTSWITCH")) SPACELIGHTSWITCH = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK1")) SCREENBREAK1 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK2")) SCREENBREAK2 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK3")) SCREENBREAK3 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK4")) SCREENBREAK4 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK5")) SCREENBREAK5 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK6")) SCREENBREAK6 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK7")) SCREENBREAK7 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK8")) SCREENBREAK8 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK9")) SCREENBREAK9 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK10")) SCREENBREAK10 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK11")) SCREENBREAK11 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK12")) SCREENBREAK12 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK13")) SCREENBREAK13 = lValue; + else if (!Bstrcmp(szLabel,"STATIC")) STATIC = lValue; + else if (!Bstrcmp(szLabel,"SATELLITE")) SATELLITE = lValue; + else if (!Bstrcmp(szLabel,"STAINGLASS1")) STAINGLASS1 = lValue; + else if (!Bstrcmp(szLabel,"SATELITE")) SATELITE = lValue; + else if (!Bstrcmp(szLabel,"SLIMEPIPE")) SLIMEPIPE = lValue; + else if (!Bstrcmp(szLabel,"STALL")) STALL = lValue; + else if (!Bstrcmp(szLabel,"STALLBROKE")) STALLBROKE = lValue; + else if (!Bstrcmp(szLabel,"SOLARPANNEL")) SOLARPANNEL = lValue; + else if (!Bstrcmp(szLabel,"SPLINTERWOOD")) SPLINTERWOOD = lValue; + else if (!Bstrcmp(szLabel,"SCALE")) SCALE = lValue; + else if (!Bstrcmp(szLabel,"STATUE")) STATUE = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE1")) SUSHIPLATE1 = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE2")) SUSHIPLATE2 = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE3")) SUSHIPLATE3 = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE4")) SUSHIPLATE4 = lValue; + else if (!Bstrcmp(szLabel,"SUSHIPLATE5")) SUSHIPLATE5 = lValue; + else if (!Bstrcmp(szLabel,"STATUEFLASH")) STATUEFLASH = lValue; + else if (!Bstrcmp(szLabel,"STRIPEBALL")) STRIPEBALL = lValue; + else if (!Bstrcmp(szLabel,"SPOTLITE")) SPOTLITE = lValue; + else if (!Bstrcmp(szLabel,"SEENINE")) SEENINE = lValue; + else if (!Bstrcmp(szLabel,"SEENINEDEAD")) SEENINEDEAD = lValue; + else if (!Bstrcmp(szLabel,"STEAM")) STEAM = lValue; + else if (!Bstrcmp(szLabel,"SPACEMARINE")) SPACEMARINE = lValue; + else if (!Bstrcmp(szLabel,"SCRATCH")) SCRATCH = lValue; + else if (!Bstrcmp(szLabel,"SHARK")) SHARK = lValue; + else if (!Bstrcmp(szLabel,"SPIT")) SPIT = lValue; + else if (!Bstrcmp(szLabel,"SHRINKSPARK")) SHRINKSPARK = lValue; + else if (!Bstrcmp(szLabel,"SHRINKEREXPLOSION")) SHRINKEREXPLOSION = lValue; + else if (!Bstrcmp(szLabel,"SMALLSMOKE")) SMALLSMOKE = lValue; + else if (!Bstrcmp(szLabel,"SMALLSMOKEMAKER")) SMALLSMOKEMAKER = lValue; + else if (!Bstrcmp(szLabel,"SCRAP6")) SCRAP6 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP1")) SCRAP1 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP2")) SCRAP2 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP3")) SCRAP3 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP4")) SCRAP4 = lValue; + else if (!Bstrcmp(szLabel,"SCRAP5")) SCRAP5 = lValue; + else if (!Bstrcmp(szLabel,"SELECTDIR")) SELECTDIR = lValue; + else if (!Bstrcmp(szLabel,"STEROIDS_ICON")) STEROIDS_ICON = lValue; + else if (!Bstrcmp(szLabel,"SLIDEBAR")) SLIDEBAR = lValue; + else if (!Bstrcmp(szLabel,"SHELL")) SHELL = lValue; + else if (!Bstrcmp(szLabel,"SHOTGUNSHELL")) SHOTGUNSHELL = lValue; + else if (!Bstrcmp(szLabel,"SHRINKER")) SHRINKER = lValue; + else if (!Bstrcmp(szLabel,"SCUBAMASK")) SCUBAMASK = lValue; + else if (!Bstrcmp(szLabel,"SPACEMASK")) SPACEMASK = lValue; + else if (!Bstrcmp(szLabel,"SHOTSPARK1")) SHOTSPARK1 = lValue; + else if (!Bstrcmp(szLabel,"SHOTGUN")) SHOTGUN = lValue; + else if (!Bstrcmp(szLabel,"SPINNINGNUKEICON")) SPINNINGNUKEICON = lValue; + else if (!Bstrcmp(szLabel,"SMALLFNTCURSOR")) SMALLFNTCURSOR = lValue; + else if (!Bstrcmp(szLabel,"STARTALPHANUM")) STARTALPHANUM = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK14")) SCREENBREAK14 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK15")) SCREENBREAK15 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK19")) SCREENBREAK19 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK16")) SCREENBREAK16 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK17")) SCREENBREAK17 = lValue; + else if (!Bstrcmp(szLabel,"SCREENBREAK18")) SCREENBREAK18 = lValue; + else if (!Bstrcmp(szLabel,"SPEAKER")) SPEAKER = lValue; + else if (!Bstrcmp(szLabel,"SIDEBOLT1")) SIDEBOLT1 = lValue; + else if (!Bstrcmp(szLabel,"SKINNEDCHICKEN")) SKINNEDCHICKEN = lValue; + else if (!Bstrcmp(szLabel,"SHOPPINGCART")) SHOPPINGCART = lValue; + else if (!Bstrcmp(szLabel,"SNAKEP")) SNAKEP = lValue; + else if (!Bstrcmp(szLabel,"SIGN1")) SIGN1 = lValue; + else if (!Bstrcmp(szLabel,"SIGN2")) SIGN2 = lValue; + break; + case 'T': + if (!Bstrcmp(szLabel,"TOUCHPLATE")) TOUCHPLATE = lValue; + else if (!Bstrcmp(szLabel,"TRIPBOMBSPRITE")) TRIPBOMBSPRITE = lValue; + else if (!Bstrcmp(szLabel,"TECHLIGHT2")) TECHLIGHT2 = lValue; + else if (!Bstrcmp(szLabel,"TECHLIGHTBUST2")) TECHLIGHTBUST2 = lValue; + else if (!Bstrcmp(szLabel,"TECHLIGHT4")) TECHLIGHT4 = lValue; + else if (!Bstrcmp(szLabel,"TECHLIGHTBUST4")) TECHLIGHTBUST4 = lValue; + else if (!Bstrcmp(szLabel,"TECHSWITCH")) TECHSWITCH = lValue; + else if (!Bstrcmp(szLabel,"TOILET")) TOILET = lValue; + else if (!Bstrcmp(szLabel,"TOILETBROKE")) TOILETBROKE = lValue; + else if (!Bstrcmp(szLabel,"TREE1")) TREE1 = lValue; + else if (!Bstrcmp(szLabel,"TREE2")) TREE2 = lValue; + else if (!Bstrcmp(szLabel,"TOILETWATER")) TOILETWATER = lValue; + else if (!Bstrcmp(szLabel,"TIRE")) TIRE = lValue; + else if (!Bstrcmp(szLabel,"TRANSPORTERBEAM")) TRANSPORTERBEAM = lValue; + else if (!Bstrcmp(szLabel,"TRASH")) TRASH = lValue; + else if (!Bstrcmp(szLabel,"TRANSPORTERSTAR")) TRANSPORTERSTAR = lValue; + else if (!Bstrcmp(szLabel,"TONGUE")) TONGUE = lValue; + else if (!Bstrcmp(szLabel,"TANK")) TANK = lValue; + else if (!Bstrcmp(szLabel,"TITLE")) TITLE = lValue; + else if (!Bstrcmp(szLabel,"TEXTBOX")) TEXTBOX = lValue; + else if (!Bstrcmp(szLabel,"THREEDEE")) THREEDEE = lValue; + else if (!Bstrcmp(szLabel,"TENSCREEN")) TENSCREEN = lValue; + else if (!Bstrcmp(szLabel,"TRIPBOMB")) TRIPBOMB = lValue; + else if (!Bstrcmp(szLabel,"TIP")) TIP = lValue; + else if (!Bstrcmp(szLabel,"THREEBYFIVE")) THREEBYFIVE = lValue; + else if (!Bstrcmp(szLabel,"TEXTSTORY")) TEXTSTORY = lValue; + else if (!Bstrcmp(szLabel,"TARGET")) TARGET = lValue; + else if (!Bstrcmp(szLabel,"TOPSECRET")) TOPSECRET = lValue; + else if (!Bstrcmp(szLabel,"TEDDYBEAR")) TEDDYBEAR = lValue; + else if (!Bstrcmp(szLabel,"TRIPODCAMERA")) TRIPODCAMERA = lValue; + else if (!Bstrcmp(szLabel,"TAMPON")) TAMPON = lValue; + else if (!Bstrcmp(szLabel,"TOUGHGAL")) TOUGHGAL = lValue; + break; + case 'U': + if (!Bstrcmp(szLabel,"USERWEAPON")) USERWEAPON = lValue; + break; + case 'V': + if (!Bstrcmp(szLabel,"VIEWSCREEN2")) VIEWSCREEN2 = lValue; + else if (!Bstrcmp(szLabel,"VIEWSCREENBROKE")) VIEWSCREENBROKE = lValue; + else if (!Bstrcmp(szLabel,"VIEWSCREEN")) VIEWSCREEN = lValue; + else if (!Bstrcmp(szLabel,"VACUUM")) VACUUM = lValue; + else if (!Bstrcmp(szLabel,"VASE")) VASE = lValue; + else if (!Bstrcmp(szLabel,"VENDMACHINE")) VENDMACHINE = lValue; + else if (!Bstrcmp(szLabel,"VENDMACHINEBROKE")) VENDMACHINEBROKE = lValue; + else if (!Bstrcmp(szLabel,"VIEWBORDER")) VIEWBORDER = lValue; + else if (!Bstrcmp(szLabel,"VICTORY1")) VICTORY1 = lValue; + break; + case 'W': + if (!Bstrcmp(szLabel,"WALLLIGHT4")) WALLLIGHT4 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHTBUST4")) WALLLIGHTBUST4 = lValue; + else if (!Bstrcmp(szLabel,"W_LIGHT")) W_LIGHT = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL1")) W_TECHWALL1 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL2")) W_TECHWALL2 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL15")) W_TECHWALL15 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL3")) W_TECHWALL3 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL4")) W_TECHWALL4 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL10")) W_TECHWALL10 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL16")) W_TECHWALL16 = lValue; + else if (!Bstrcmp(szLabel,"WATERTILE2")) WATERTILE2 = lValue; + else if (!Bstrcmp(szLabel,"WATERTILE")) WATERTILE = lValue; + else if (!Bstrcmp(szLabel,"W_SCREENBREAK")) W_SCREENBREAK = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL3")) W_HITTECHWALL3 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL4")) W_HITTECHWALL4 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL2")) W_HITTECHWALL2 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL1")) W_HITTECHWALL1 = lValue; + else if (!Bstrcmp(szLabel,"WATERFOUNTAIN")) WATERFOUNTAIN = lValue; + else if (!Bstrcmp(szLabel,"WATERFOUNTAINBROKE")) WATERFOUNTAINBROKE = lValue; + else if (!Bstrcmp(szLabel,"W_NUMBERS")) W_NUMBERS = lValue; + else if (!Bstrcmp(szLabel,"WATERDRIP")) WATERDRIP = lValue; + else if (!Bstrcmp(szLabel,"WATERBUBBLE")) WATERBUBBLE = lValue; + else if (!Bstrcmp(szLabel,"WATERBUBBLEMAKER")) WATERBUBBLEMAKER = lValue; + else if (!Bstrcmp(szLabel,"W_FORCEFIELD")) W_FORCEFIELD = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHT3")) WALLLIGHT3 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHTBUST3")) WALLLIGHTBUST3 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHT1")) WALLLIGHT1 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHTBUST1")) WALLLIGHTBUST1 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHT2")) WALLLIGHT2 = lValue; + else if (!Bstrcmp(szLabel,"WALLLIGHTBUST2")) WALLLIGHTBUST2 = lValue; + else if (!Bstrcmp(szLabel,"WAITTOBESEATED")) WAITTOBESEATED = lValue; + else if (!Bstrcmp(szLabel,"WOODENHORSE")) WOODENHORSE = lValue; + else if (!Bstrcmp(szLabel,"WATERSPLASH2")) WATERSPLASH2 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD1")) WALLBLOOD1 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD2")) WALLBLOOD2 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD3")) WALLBLOOD3 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD4")) WALLBLOOD4 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD5")) WALLBLOOD5 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD6")) WALLBLOOD6 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD7")) WALLBLOOD7 = lValue; + else if (!Bstrcmp(szLabel,"WALLBLOOD8")) WALLBLOOD8 = lValue; + else if (!Bstrcmp(szLabel,"WATERDRIPSPLASH")) WATERDRIPSPLASH = lValue; + else if (!Bstrcmp(szLabel,"WINDOWBORDER1")) WINDOWBORDER1 = lValue; + else if (!Bstrcmp(szLabel,"WINDOWBORDER2")) WINDOWBORDER2 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL11")) W_TECHWALL11 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL12")) W_TECHWALL12 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL13")) W_TECHWALL13 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL14")) W_TECHWALL14 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL5")) W_TECHWALL5 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL6")) W_TECHWALL6 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL7")) W_TECHWALL7 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL8")) W_TECHWALL8 = lValue; + else if (!Bstrcmp(szLabel,"W_TECHWALL9")) W_TECHWALL9 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL16")) W_HITTECHWALL16 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL10")) W_HITTECHWALL10 = lValue; + else if (!Bstrcmp(szLabel,"W_HITTECHWALL15")) W_HITTECHWALL15 = lValue; + else if (!Bstrcmp(szLabel,"W_MILKSHELF")) W_MILKSHELF = lValue; + else if (!Bstrcmp(szLabel,"W_MILKSHELFBROKE")) W_MILKSHELFBROKE = lValue; + else if (!Bstrcmp(szLabel,"WETFLOOR")) WETFLOOR = lValue; + else if (!Bstrcmp(szLabel,"WOMAN")) WOMAN = lValue; + else if (!Bstrcmp(szLabel,"WEATHERWARN")) WEATHERWARN = lValue; + break; + case 'X': + if (!Bstrcmp(szLabel,"XXXSTACY")) XXXSTACY = lValue; + break; + } +} + +void setupdynamictostatic(void) +{ + clearbufbyte(dynamictostatic,MAXTILES,0); + dynamictostatic[SECTOREFFECTOR] = SECTOREFFECTOR__STATIC; + dynamictostatic[ACTIVATOR] = ACTIVATOR__STATIC; + dynamictostatic[TOUCHPLATE] = TOUCHPLATE__STATIC; + dynamictostatic[ACTIVATORLOCKED] = ACTIVATORLOCKED__STATIC; + dynamictostatic[MUSICANDSFX] = MUSICANDSFX__STATIC; + dynamictostatic[LOCATORS] = LOCATORS__STATIC; + dynamictostatic[CYCLER] = CYCLER__STATIC; + dynamictostatic[MASTERSWITCH] = MASTERSWITCH__STATIC; + dynamictostatic[RESPAWN] = RESPAWN__STATIC; + dynamictostatic[GPSPEED] = GPSPEED__STATIC; + dynamictostatic[FOF] = FOF__STATIC; + dynamictostatic[ARROW] = ARROW__STATIC; + dynamictostatic[FIRSTGUNSPRITE] = FIRSTGUNSPRITE__STATIC; + dynamictostatic[CHAINGUNSPRITE] = CHAINGUNSPRITE__STATIC; + dynamictostatic[RPGSPRITE] = RPGSPRITE__STATIC; + dynamictostatic[FREEZESPRITE] = FREEZESPRITE__STATIC; + dynamictostatic[SHRINKERSPRITE] = SHRINKERSPRITE__STATIC; + dynamictostatic[HEAVYHBOMB] = HEAVYHBOMB__STATIC; + dynamictostatic[TRIPBOMBSPRITE] = TRIPBOMBSPRITE__STATIC; + dynamictostatic[SHOTGUNSPRITE] = SHOTGUNSPRITE__STATIC; + dynamictostatic[DEVISTATORSPRITE] = DEVISTATORSPRITE__STATIC; + dynamictostatic[HEALTHBOX] = HEALTHBOX__STATIC; + dynamictostatic[AMMOBOX] = AMMOBOX__STATIC; + dynamictostatic[GROWSPRITEICON] = GROWSPRITEICON__STATIC; + dynamictostatic[INVENTORYBOX] = INVENTORYBOX__STATIC; + dynamictostatic[FREEZEAMMO] = FREEZEAMMO__STATIC; + dynamictostatic[AMMO] = AMMO__STATIC; + dynamictostatic[BATTERYAMMO] = BATTERYAMMO__STATIC; + dynamictostatic[DEVISTATORAMMO] = DEVISTATORAMMO__STATIC; + dynamictostatic[RPGAMMO] = RPGAMMO__STATIC; + dynamictostatic[GROWAMMO] = GROWAMMO__STATIC; + dynamictostatic[CRYSTALAMMO] = CRYSTALAMMO__STATIC; + dynamictostatic[HBOMBAMMO] = HBOMBAMMO__STATIC; + dynamictostatic[AMMOLOTS] = AMMOLOTS__STATIC; + dynamictostatic[SHOTGUNAMMO] = SHOTGUNAMMO__STATIC; + dynamictostatic[COLA] = COLA__STATIC; + dynamictostatic[SIXPAK] = SIXPAK__STATIC; + dynamictostatic[FIRSTAID] = FIRSTAID__STATIC; + dynamictostatic[SHIELD] = SHIELD__STATIC; + dynamictostatic[STEROIDS] = STEROIDS__STATIC; + dynamictostatic[AIRTANK] = AIRTANK__STATIC; + dynamictostatic[JETPACK] = JETPACK__STATIC; + dynamictostatic[HEATSENSOR] = HEATSENSOR__STATIC; + dynamictostatic[ACCESSCARD] = ACCESSCARD__STATIC; + dynamictostatic[BOOTS] = BOOTS__STATIC; + dynamictostatic[MIRRORBROKE] = MIRRORBROKE__STATIC; + dynamictostatic[CLOUDYOCEAN] = CLOUDYOCEAN__STATIC; + dynamictostatic[CLOUDYSKIES] = CLOUDYSKIES__STATIC; + dynamictostatic[MOONSKY1] = MOONSKY1__STATIC; + dynamictostatic[MOONSKY2] = MOONSKY2__STATIC; + dynamictostatic[MOONSKY3] = MOONSKY3__STATIC; + dynamictostatic[MOONSKY4] = MOONSKY4__STATIC; + dynamictostatic[BIGORBIT1] = BIGORBIT1__STATIC; + dynamictostatic[BIGORBIT2] = BIGORBIT2__STATIC; + dynamictostatic[BIGORBIT3] = BIGORBIT3__STATIC; + dynamictostatic[BIGORBIT4] = BIGORBIT4__STATIC; + dynamictostatic[BIGORBIT5] = BIGORBIT5__STATIC; + dynamictostatic[LA] = LA__STATIC; + dynamictostatic[REDSKY1] = REDSKY1__STATIC; + dynamictostatic[REDSKY2] = REDSKY2__STATIC; + dynamictostatic[ATOMICHEALTH] = ATOMICHEALTH__STATIC; + dynamictostatic[TECHLIGHT2] = TECHLIGHT2__STATIC; + dynamictostatic[TECHLIGHTBUST2] = TECHLIGHTBUST2__STATIC; + dynamictostatic[TECHLIGHT4] = TECHLIGHT4__STATIC; + dynamictostatic[TECHLIGHTBUST4] = TECHLIGHTBUST4__STATIC; + dynamictostatic[WALLLIGHT4] = WALLLIGHT4__STATIC; + dynamictostatic[WALLLIGHTBUST4] = WALLLIGHTBUST4__STATIC; + dynamictostatic[ACCESSSWITCH] = ACCESSSWITCH__STATIC; + dynamictostatic[SLOTDOOR] = SLOTDOOR__STATIC; + dynamictostatic[LIGHTSWITCH] = LIGHTSWITCH__STATIC; + dynamictostatic[SPACEDOORSWITCH] = SPACEDOORSWITCH__STATIC; + dynamictostatic[SPACELIGHTSWITCH] = SPACELIGHTSWITCH__STATIC; + dynamictostatic[FRANKENSTINESWITCH] = FRANKENSTINESWITCH__STATIC; + dynamictostatic[NUKEBUTTON] = NUKEBUTTON__STATIC; + dynamictostatic[MULTISWITCH] = MULTISWITCH__STATIC; + dynamictostatic[DOORTILE5] = DOORTILE5__STATIC; + dynamictostatic[DOORTILE6] = DOORTILE6__STATIC; + dynamictostatic[DOORTILE1] = DOORTILE1__STATIC; + dynamictostatic[DOORTILE2] = DOORTILE2__STATIC; + dynamictostatic[DOORTILE3] = DOORTILE3__STATIC; + dynamictostatic[DOORTILE4] = DOORTILE4__STATIC; + dynamictostatic[DOORTILE7] = DOORTILE7__STATIC; + dynamictostatic[DOORTILE8] = DOORTILE8__STATIC; + dynamictostatic[DOORTILE9] = DOORTILE9__STATIC; + dynamictostatic[DOORTILE10] = DOORTILE10__STATIC; + dynamictostatic[DOORSHOCK] = DOORSHOCK__STATIC; + dynamictostatic[DIPSWITCH] = DIPSWITCH__STATIC; + dynamictostatic[DIPSWITCH2] = DIPSWITCH2__STATIC; + dynamictostatic[TECHSWITCH] = TECHSWITCH__STATIC; + dynamictostatic[DIPSWITCH3] = DIPSWITCH3__STATIC; + dynamictostatic[ACCESSSWITCH2] = ACCESSSWITCH2__STATIC; + dynamictostatic[REFLECTWATERTILE] = REFLECTWATERTILE__STATIC; + dynamictostatic[FLOORSLIME] = FLOORSLIME__STATIC; + dynamictostatic[BIGFORCE] = BIGFORCE__STATIC; + dynamictostatic[EPISODE] = EPISODE__STATIC; + dynamictostatic[MASKWALL9] = MASKWALL9__STATIC; + dynamictostatic[W_LIGHT] = W_LIGHT__STATIC; + dynamictostatic[SCREENBREAK1] = SCREENBREAK1__STATIC; + dynamictostatic[SCREENBREAK2] = SCREENBREAK2__STATIC; + dynamictostatic[SCREENBREAK3] = SCREENBREAK3__STATIC; + dynamictostatic[SCREENBREAK4] = SCREENBREAK4__STATIC; + dynamictostatic[SCREENBREAK5] = SCREENBREAK5__STATIC; + dynamictostatic[SCREENBREAK6] = SCREENBREAK6__STATIC; + dynamictostatic[SCREENBREAK7] = SCREENBREAK7__STATIC; + dynamictostatic[SCREENBREAK8] = SCREENBREAK8__STATIC; + dynamictostatic[SCREENBREAK9] = SCREENBREAK9__STATIC; + dynamictostatic[SCREENBREAK10] = SCREENBREAK10__STATIC; + dynamictostatic[SCREENBREAK11] = SCREENBREAK11__STATIC; + dynamictostatic[SCREENBREAK12] = SCREENBREAK12__STATIC; + dynamictostatic[SCREENBREAK13] = SCREENBREAK13__STATIC; + dynamictostatic[MASKWALL1] = MASKWALL1__STATIC; + dynamictostatic[W_TECHWALL1] = W_TECHWALL1__STATIC; + dynamictostatic[W_TECHWALL2] = W_TECHWALL2__STATIC; + dynamictostatic[W_TECHWALL15] = W_TECHWALL15__STATIC; + dynamictostatic[W_TECHWALL3] = W_TECHWALL3__STATIC; + dynamictostatic[W_TECHWALL4] = W_TECHWALL4__STATIC; + dynamictostatic[W_TECHWALL10] = W_TECHWALL10__STATIC; + dynamictostatic[W_TECHWALL16] = W_TECHWALL16__STATIC; + dynamictostatic[WATERTILE2] = WATERTILE2__STATIC; + dynamictostatic[BPANNEL1] = BPANNEL1__STATIC; + dynamictostatic[PANNEL1] = PANNEL1__STATIC; + dynamictostatic[PANNEL2] = PANNEL2__STATIC; + dynamictostatic[WATERTILE] = WATERTILE__STATIC; + dynamictostatic[STATIC] = STATIC__STATIC; + dynamictostatic[W_SCREENBREAK] = W_SCREENBREAK__STATIC; + dynamictostatic[W_HITTECHWALL3] = W_HITTECHWALL3__STATIC; + dynamictostatic[W_HITTECHWALL4] = W_HITTECHWALL4__STATIC; + dynamictostatic[W_HITTECHWALL2] = W_HITTECHWALL2__STATIC; + dynamictostatic[W_HITTECHWALL1] = W_HITTECHWALL1__STATIC; + dynamictostatic[MASKWALL10] = MASKWALL10__STATIC; + dynamictostatic[MASKWALL11] = MASKWALL11__STATIC; + dynamictostatic[DOORTILE22] = DOORTILE22__STATIC; + dynamictostatic[FANSPRITE] = FANSPRITE__STATIC; + dynamictostatic[FANSPRITEBROKE] = FANSPRITEBROKE__STATIC; + dynamictostatic[FANSHADOW] = FANSHADOW__STATIC; + dynamictostatic[FANSHADOWBROKE] = FANSHADOWBROKE__STATIC; + dynamictostatic[DOORTILE18] = DOORTILE18__STATIC; + dynamictostatic[DOORTILE19] = DOORTILE19__STATIC; + dynamictostatic[DOORTILE20] = DOORTILE20__STATIC; + dynamictostatic[SATELLITE] = SATELLITE__STATIC; + dynamictostatic[VIEWSCREEN2] = VIEWSCREEN2__STATIC; + dynamictostatic[VIEWSCREENBROKE] = VIEWSCREENBROKE__STATIC; + dynamictostatic[VIEWSCREEN] = VIEWSCREEN__STATIC; + dynamictostatic[GLASS] = GLASS__STATIC; + dynamictostatic[GLASS2] = GLASS2__STATIC; + dynamictostatic[STAINGLASS1] = STAINGLASS1__STATIC; + dynamictostatic[MASKWALL5] = MASKWALL5__STATIC; + dynamictostatic[SATELITE] = SATELITE__STATIC; + dynamictostatic[FUELPOD] = FUELPOD__STATIC; + dynamictostatic[SLIMEPIPE] = SLIMEPIPE__STATIC; + dynamictostatic[CRACK1] = CRACK1__STATIC; + dynamictostatic[CRACK2] = CRACK2__STATIC; + dynamictostatic[CRACK3] = CRACK3__STATIC; + dynamictostatic[CRACK4] = CRACK4__STATIC; + dynamictostatic[FOOTPRINTS] = FOOTPRINTS__STATIC; + dynamictostatic[DOMELITE] = DOMELITE__STATIC; + dynamictostatic[CAMERAPOLE] = CAMERAPOLE__STATIC; + dynamictostatic[CHAIR1] = CHAIR1__STATIC; + dynamictostatic[CHAIR2] = CHAIR2__STATIC; + dynamictostatic[BROKENCHAIR] = BROKENCHAIR__STATIC; + dynamictostatic[MIRROR] = MIRROR__STATIC; + dynamictostatic[WATERFOUNTAIN] = WATERFOUNTAIN__STATIC; + dynamictostatic[WATERFOUNTAINBROKE] = WATERFOUNTAINBROKE__STATIC; + dynamictostatic[FEMMAG1] = FEMMAG1__STATIC; + dynamictostatic[TOILET] = TOILET__STATIC; + dynamictostatic[STALL] = STALL__STATIC; + dynamictostatic[STALLBROKE] = STALLBROKE__STATIC; + dynamictostatic[FEMMAG2] = FEMMAG2__STATIC; + dynamictostatic[REACTOR2] = REACTOR2__STATIC; + dynamictostatic[REACTOR2BURNT] = REACTOR2BURNT__STATIC; + dynamictostatic[REACTOR2SPARK] = REACTOR2SPARK__STATIC; + dynamictostatic[GRATE1] = GRATE1__STATIC; + dynamictostatic[BGRATE1] = BGRATE1__STATIC; + dynamictostatic[SOLARPANNEL] = SOLARPANNEL__STATIC; + dynamictostatic[NAKED1] = NAKED1__STATIC; + dynamictostatic[ANTENNA] = ANTENNA__STATIC; + dynamictostatic[MASKWALL12] = MASKWALL12__STATIC; + dynamictostatic[TOILETBROKE] = TOILETBROKE__STATIC; + dynamictostatic[PIPE2] = PIPE2__STATIC; + dynamictostatic[PIPE1B] = PIPE1B__STATIC; + dynamictostatic[PIPE3] = PIPE3__STATIC; + dynamictostatic[PIPE1] = PIPE1__STATIC; + dynamictostatic[CAMERA1] = CAMERA1__STATIC; + dynamictostatic[BRICK] = BRICK__STATIC; + dynamictostatic[SPLINTERWOOD] = SPLINTERWOOD__STATIC; + dynamictostatic[PIPE2B] = PIPE2B__STATIC; + dynamictostatic[BOLT1] = BOLT1__STATIC; + dynamictostatic[W_NUMBERS] = W_NUMBERS__STATIC; + dynamictostatic[WATERDRIP] = WATERDRIP__STATIC; + dynamictostatic[WATERBUBBLE] = WATERBUBBLE__STATIC; + dynamictostatic[WATERBUBBLEMAKER] = WATERBUBBLEMAKER__STATIC; + dynamictostatic[W_FORCEFIELD] = W_FORCEFIELD__STATIC; + dynamictostatic[VACUUM] = VACUUM__STATIC; + dynamictostatic[FOOTPRINTS2] = FOOTPRINTS2__STATIC; + dynamictostatic[FOOTPRINTS3] = FOOTPRINTS3__STATIC; + dynamictostatic[FOOTPRINTS4] = FOOTPRINTS4__STATIC; + dynamictostatic[EGG] = EGG__STATIC; + dynamictostatic[SCALE] = SCALE__STATIC; + dynamictostatic[CHAIR3] = CHAIR3__STATIC; + dynamictostatic[CAMERALIGHT] = CAMERALIGHT__STATIC; + dynamictostatic[MOVIECAMERA] = MOVIECAMERA__STATIC; + dynamictostatic[IVUNIT] = IVUNIT__STATIC; + dynamictostatic[POT1] = POT1__STATIC; + dynamictostatic[POT2] = POT2__STATIC; + dynamictostatic[POT3] = POT3__STATIC; + dynamictostatic[PIPE3B] = PIPE3B__STATIC; + dynamictostatic[WALLLIGHT3] = WALLLIGHT3__STATIC; + dynamictostatic[WALLLIGHTBUST3] = WALLLIGHTBUST3__STATIC; + dynamictostatic[WALLLIGHT1] = WALLLIGHT1__STATIC; + dynamictostatic[WALLLIGHTBUST1] = WALLLIGHTBUST1__STATIC; + dynamictostatic[WALLLIGHT2] = WALLLIGHT2__STATIC; + dynamictostatic[WALLLIGHTBUST2] = WALLLIGHTBUST2__STATIC; + dynamictostatic[LIGHTSWITCH2] = LIGHTSWITCH2__STATIC; + dynamictostatic[WAITTOBESEATED] = WAITTOBESEATED__STATIC; + dynamictostatic[DOORTILE14] = DOORTILE14__STATIC; + dynamictostatic[STATUE] = STATUE__STATIC; + dynamictostatic[MIKE] = MIKE__STATIC; + dynamictostatic[VASE] = VASE__STATIC; + dynamictostatic[SUSHIPLATE1] = SUSHIPLATE1__STATIC; + dynamictostatic[SUSHIPLATE2] = SUSHIPLATE2__STATIC; + dynamictostatic[SUSHIPLATE3] = SUSHIPLATE3__STATIC; + dynamictostatic[SUSHIPLATE4] = SUSHIPLATE4__STATIC; + dynamictostatic[DOORTILE16] = DOORTILE16__STATIC; + dynamictostatic[SUSHIPLATE5] = SUSHIPLATE5__STATIC; + dynamictostatic[OJ] = OJ__STATIC; + dynamictostatic[MASKWALL13] = MASKWALL13__STATIC; + dynamictostatic[HURTRAIL] = HURTRAIL__STATIC; + dynamictostatic[POWERSWITCH1] = POWERSWITCH1__STATIC; + dynamictostatic[LOCKSWITCH1] = LOCKSWITCH1__STATIC; + dynamictostatic[POWERSWITCH2] = POWERSWITCH2__STATIC; + dynamictostatic[ATM] = ATM__STATIC; + dynamictostatic[STATUEFLASH] = STATUEFLASH__STATIC; + dynamictostatic[ATMBROKE] = ATMBROKE__STATIC; + dynamictostatic[BIGHOLE2] = BIGHOLE2__STATIC; + dynamictostatic[STRIPEBALL] = STRIPEBALL__STATIC; + dynamictostatic[QUEBALL] = QUEBALL__STATIC; + dynamictostatic[POCKET] = POCKET__STATIC; + dynamictostatic[WOODENHORSE] = WOODENHORSE__STATIC; + dynamictostatic[TREE1] = TREE1__STATIC; + dynamictostatic[TREE2] = TREE2__STATIC; + dynamictostatic[CACTUS] = CACTUS__STATIC; + dynamictostatic[MASKWALL2] = MASKWALL2__STATIC; + dynamictostatic[MASKWALL3] = MASKWALL3__STATIC; + dynamictostatic[MASKWALL4] = MASKWALL4__STATIC; + dynamictostatic[FIREEXT] = FIREEXT__STATIC; + dynamictostatic[TOILETWATER] = TOILETWATER__STATIC; + dynamictostatic[NEON1] = NEON1__STATIC; + dynamictostatic[NEON2] = NEON2__STATIC; + dynamictostatic[CACTUSBROKE] = CACTUSBROKE__STATIC; + dynamictostatic[BOUNCEMINE] = BOUNCEMINE__STATIC; + dynamictostatic[BROKEFIREHYDRENT] = BROKEFIREHYDRENT__STATIC; + dynamictostatic[BOX] = BOX__STATIC; + dynamictostatic[BULLETHOLE] = BULLETHOLE__STATIC; + dynamictostatic[BOTTLE1] = BOTTLE1__STATIC; + dynamictostatic[BOTTLE2] = BOTTLE2__STATIC; + dynamictostatic[BOTTLE3] = BOTTLE3__STATIC; + dynamictostatic[BOTTLE4] = BOTTLE4__STATIC; + dynamictostatic[FEMPIC5] = FEMPIC5__STATIC; + dynamictostatic[FEMPIC6] = FEMPIC6__STATIC; + dynamictostatic[FEMPIC7] = FEMPIC7__STATIC; + dynamictostatic[HYDROPLANT] = HYDROPLANT__STATIC; + dynamictostatic[OCEANSPRITE1] = OCEANSPRITE1__STATIC; + dynamictostatic[OCEANSPRITE2] = OCEANSPRITE2__STATIC; + dynamictostatic[OCEANSPRITE3] = OCEANSPRITE3__STATIC; + dynamictostatic[OCEANSPRITE4] = OCEANSPRITE4__STATIC; + dynamictostatic[OCEANSPRITE5] = OCEANSPRITE5__STATIC; + dynamictostatic[GENERICPOLE] = GENERICPOLE__STATIC; + dynamictostatic[CONE] = CONE__STATIC; + dynamictostatic[HANGLIGHT] = HANGLIGHT__STATIC; + dynamictostatic[HYDRENT] = HYDRENT__STATIC; + dynamictostatic[MASKWALL14] = MASKWALL14__STATIC; + dynamictostatic[TIRE] = TIRE__STATIC; + dynamictostatic[PIPE5] = PIPE5__STATIC; + dynamictostatic[PIPE6] = PIPE6__STATIC; + dynamictostatic[PIPE4] = PIPE4__STATIC; + dynamictostatic[PIPE4B] = PIPE4B__STATIC; + dynamictostatic[BROKEHYDROPLANT] = BROKEHYDROPLANT__STATIC; + dynamictostatic[PIPE5B] = PIPE5B__STATIC; + dynamictostatic[NEON3] = NEON3__STATIC; + dynamictostatic[NEON4] = NEON4__STATIC; + dynamictostatic[NEON5] = NEON5__STATIC; + dynamictostatic[BOTTLE5] = BOTTLE5__STATIC; + dynamictostatic[BOTTLE6] = BOTTLE6__STATIC; + dynamictostatic[BOTTLE8] = BOTTLE8__STATIC; + dynamictostatic[SPOTLITE] = SPOTLITE__STATIC; + dynamictostatic[HANGOOZ] = HANGOOZ__STATIC; + dynamictostatic[MASKWALL15] = MASKWALL15__STATIC; + dynamictostatic[BOTTLE7] = BOTTLE7__STATIC; + dynamictostatic[HORSEONSIDE] = HORSEONSIDE__STATIC; + dynamictostatic[GLASSPIECES] = GLASSPIECES__STATIC; + dynamictostatic[HORSELITE] = HORSELITE__STATIC; + dynamictostatic[DONUTS] = DONUTS__STATIC; + dynamictostatic[NEON6] = NEON6__STATIC; + dynamictostatic[MASKWALL6] = MASKWALL6__STATIC; + dynamictostatic[CLOCK] = CLOCK__STATIC; + dynamictostatic[RUBBERCAN] = RUBBERCAN__STATIC; + dynamictostatic[BROKENCLOCK] = BROKENCLOCK__STATIC; + dynamictostatic[PLUG] = PLUG__STATIC; + dynamictostatic[OOZFILTER] = OOZFILTER__STATIC; + dynamictostatic[FLOORPLASMA] = FLOORPLASMA__STATIC; + dynamictostatic[REACTOR] = REACTOR__STATIC; + dynamictostatic[REACTORSPARK] = REACTORSPARK__STATIC; + dynamictostatic[REACTORBURNT] = REACTORBURNT__STATIC; + dynamictostatic[DOORTILE15] = DOORTILE15__STATIC; + dynamictostatic[HANDSWITCH] = HANDSWITCH__STATIC; + dynamictostatic[CIRCLEPANNEL] = CIRCLEPANNEL__STATIC; + dynamictostatic[CIRCLEPANNELBROKE] = CIRCLEPANNELBROKE__STATIC; + dynamictostatic[PULLSWITCH] = PULLSWITCH__STATIC; + dynamictostatic[MASKWALL8] = MASKWALL8__STATIC; + dynamictostatic[BIGHOLE] = BIGHOLE__STATIC; + dynamictostatic[ALIENSWITCH] = ALIENSWITCH__STATIC; + dynamictostatic[DOORTILE21] = DOORTILE21__STATIC; + dynamictostatic[HANDPRINTSWITCH] = HANDPRINTSWITCH__STATIC; + dynamictostatic[BOTTLE10] = BOTTLE10__STATIC; + dynamictostatic[BOTTLE11] = BOTTLE11__STATIC; + dynamictostatic[BOTTLE12] = BOTTLE12__STATIC; + dynamictostatic[BOTTLE13] = BOTTLE13__STATIC; + dynamictostatic[BOTTLE14] = BOTTLE14__STATIC; + dynamictostatic[BOTTLE15] = BOTTLE15__STATIC; + dynamictostatic[BOTTLE16] = BOTTLE16__STATIC; + dynamictostatic[BOTTLE17] = BOTTLE17__STATIC; + dynamictostatic[BOTTLE18] = BOTTLE18__STATIC; + dynamictostatic[BOTTLE19] = BOTTLE19__STATIC; + dynamictostatic[DOORTILE17] = DOORTILE17__STATIC; + dynamictostatic[MASKWALL7] = MASKWALL7__STATIC; + dynamictostatic[JAILBARBREAK] = JAILBARBREAK__STATIC; + dynamictostatic[DOORTILE11] = DOORTILE11__STATIC; + dynamictostatic[DOORTILE12] = DOORTILE12__STATIC; + dynamictostatic[VENDMACHINE] = VENDMACHINE__STATIC; + dynamictostatic[VENDMACHINEBROKE] = VENDMACHINEBROKE__STATIC; + dynamictostatic[COLAMACHINE] = COLAMACHINE__STATIC; + dynamictostatic[COLAMACHINEBROKE] = COLAMACHINEBROKE__STATIC; + dynamictostatic[CRANEPOLE] = CRANEPOLE__STATIC; + dynamictostatic[CRANE] = CRANE__STATIC; + dynamictostatic[BARBROKE] = BARBROKE__STATIC; + dynamictostatic[BLOODPOOL] = BLOODPOOL__STATIC; + dynamictostatic[NUKEBARREL] = NUKEBARREL__STATIC; + dynamictostatic[NUKEBARRELDENTED] = NUKEBARRELDENTED__STATIC; + dynamictostatic[NUKEBARRELLEAKED] = NUKEBARRELLEAKED__STATIC; + dynamictostatic[CANWITHSOMETHING] = CANWITHSOMETHING__STATIC; + dynamictostatic[MONEY] = MONEY__STATIC; + dynamictostatic[BANNER] = BANNER__STATIC; + dynamictostatic[EXPLODINGBARREL] = EXPLODINGBARREL__STATIC; + dynamictostatic[EXPLODINGBARREL2] = EXPLODINGBARREL2__STATIC; + dynamictostatic[FIREBARREL] = FIREBARREL__STATIC; + dynamictostatic[SEENINE] = SEENINE__STATIC; + dynamictostatic[SEENINEDEAD] = SEENINEDEAD__STATIC; + dynamictostatic[STEAM] = STEAM__STATIC; + dynamictostatic[CEILINGSTEAM] = CEILINGSTEAM__STATIC; + dynamictostatic[PIPE6B] = PIPE6B__STATIC; + dynamictostatic[TRANSPORTERBEAM] = TRANSPORTERBEAM__STATIC; + dynamictostatic[RAT] = RAT__STATIC; + dynamictostatic[TRASH] = TRASH__STATIC; + dynamictostatic[FEMPIC1] = FEMPIC1__STATIC; + dynamictostatic[FEMPIC2] = FEMPIC2__STATIC; + dynamictostatic[BLANKSCREEN] = BLANKSCREEN__STATIC; + dynamictostatic[PODFEM1] = PODFEM1__STATIC; + dynamictostatic[FEMPIC3] = FEMPIC3__STATIC; + dynamictostatic[FEMPIC4] = FEMPIC4__STATIC; + dynamictostatic[FEM1] = FEM1__STATIC; + dynamictostatic[FEM2] = FEM2__STATIC; + dynamictostatic[FEM3] = FEM3__STATIC; + dynamictostatic[FEM5] = FEM5__STATIC; + dynamictostatic[BLOODYPOLE] = BLOODYPOLE__STATIC; + dynamictostatic[FEM4] = FEM4__STATIC; + dynamictostatic[FEM6] = FEM6__STATIC; + dynamictostatic[FEM6PAD] = FEM6PAD__STATIC; + dynamictostatic[FEM8] = FEM8__STATIC; + dynamictostatic[HELECOPT] = HELECOPT__STATIC; + dynamictostatic[FETUSJIB] = FETUSJIB__STATIC; + dynamictostatic[HOLODUKE] = HOLODUKE__STATIC; + dynamictostatic[SPACEMARINE] = SPACEMARINE__STATIC; + dynamictostatic[INDY] = INDY__STATIC; + dynamictostatic[FETUS] = FETUS__STATIC; + dynamictostatic[FETUSBROKE] = FETUSBROKE__STATIC; + dynamictostatic[MONK] = MONK__STATIC; + dynamictostatic[LUKE] = LUKE__STATIC; + dynamictostatic[COOLEXPLOSION1] = COOLEXPLOSION1__STATIC; + dynamictostatic[WATERSPLASH2] = WATERSPLASH2__STATIC; + dynamictostatic[FIREVASE] = FIREVASE__STATIC; + dynamictostatic[SCRATCH] = SCRATCH__STATIC; + dynamictostatic[FEM7] = FEM7__STATIC; + dynamictostatic[APLAYERTOP] = APLAYERTOP__STATIC; + dynamictostatic[APLAYER] = APLAYER__STATIC; + dynamictostatic[PLAYERONWATER] = PLAYERONWATER__STATIC; + dynamictostatic[DUKELYINGDEAD] = DUKELYINGDEAD__STATIC; + dynamictostatic[DUKETORSO] = DUKETORSO__STATIC; + dynamictostatic[DUKEGUN] = DUKEGUN__STATIC; + dynamictostatic[DUKELEG] = DUKELEG__STATIC; + dynamictostatic[SHARK] = SHARK__STATIC; + dynamictostatic[BLOOD] = BLOOD__STATIC; + dynamictostatic[FIRELASER] = FIRELASER__STATIC; + dynamictostatic[TRANSPORTERSTAR] = TRANSPORTERSTAR__STATIC; + dynamictostatic[SPIT] = SPIT__STATIC; + dynamictostatic[LOOGIE] = LOOGIE__STATIC; + dynamictostatic[FIST] = FIST__STATIC; + dynamictostatic[FREEZEBLAST] = FREEZEBLAST__STATIC; + dynamictostatic[DEVISTATORBLAST] = DEVISTATORBLAST__STATIC; + dynamictostatic[SHRINKSPARK] = SHRINKSPARK__STATIC; + dynamictostatic[TONGUE] = TONGUE__STATIC; + dynamictostatic[MORTER] = MORTER__STATIC; + dynamictostatic[SHRINKEREXPLOSION] = SHRINKEREXPLOSION__STATIC; + dynamictostatic[RADIUSEXPLOSION] = RADIUSEXPLOSION__STATIC; + dynamictostatic[FORCERIPPLE] = FORCERIPPLE__STATIC; + dynamictostatic[LIZTROOP] = LIZTROOP__STATIC; + dynamictostatic[LIZTROOPRUNNING] = LIZTROOPRUNNING__STATIC; + dynamictostatic[LIZTROOPSTAYPUT] = LIZTROOPSTAYPUT__STATIC; + dynamictostatic[LIZTOP] = LIZTOP__STATIC; + dynamictostatic[LIZTROOPSHOOT] = LIZTROOPSHOOT__STATIC; + dynamictostatic[LIZTROOPJETPACK] = LIZTROOPJETPACK__STATIC; + dynamictostatic[LIZTROOPDSPRITE] = LIZTROOPDSPRITE__STATIC; + dynamictostatic[LIZTROOPONTOILET] = LIZTROOPONTOILET__STATIC; + dynamictostatic[LIZTROOPJUSTSIT] = LIZTROOPJUSTSIT__STATIC; + dynamictostatic[LIZTROOPDUCKING] = LIZTROOPDUCKING__STATIC; + dynamictostatic[HEADJIB1] = HEADJIB1__STATIC; + dynamictostatic[ARMJIB1] = ARMJIB1__STATIC; + dynamictostatic[LEGJIB1] = LEGJIB1__STATIC; + dynamictostatic[CANNONBALL] = CANNONBALL__STATIC; + dynamictostatic[OCTABRAIN] = OCTABRAIN__STATIC; + dynamictostatic[OCTABRAINSTAYPUT] = OCTABRAINSTAYPUT__STATIC; + dynamictostatic[OCTATOP] = OCTATOP__STATIC; + dynamictostatic[OCTADEADSPRITE] = OCTADEADSPRITE__STATIC; + dynamictostatic[INNERJAW] = INNERJAW__STATIC; + dynamictostatic[DRONE] = DRONE__STATIC; + dynamictostatic[EXPLOSION2] = EXPLOSION2__STATIC; + dynamictostatic[COMMANDER] = COMMANDER__STATIC; + dynamictostatic[COMMANDERSTAYPUT] = COMMANDERSTAYPUT__STATIC; + dynamictostatic[RECON] = RECON__STATIC; + dynamictostatic[TANK] = TANK__STATIC; + dynamictostatic[PIGCOP] = PIGCOP__STATIC; + dynamictostatic[PIGCOPSTAYPUT] = PIGCOPSTAYPUT__STATIC; + dynamictostatic[PIGCOPDIVE] = PIGCOPDIVE__STATIC; + dynamictostatic[PIGCOPDEADSPRITE] = PIGCOPDEADSPRITE__STATIC; + dynamictostatic[PIGTOP] = PIGTOP__STATIC; + dynamictostatic[LIZMAN] = LIZMAN__STATIC; + dynamictostatic[LIZMANSTAYPUT] = LIZMANSTAYPUT__STATIC; + dynamictostatic[LIZMANSPITTING] = LIZMANSPITTING__STATIC; + dynamictostatic[LIZMANFEEDING] = LIZMANFEEDING__STATIC; + dynamictostatic[LIZMANJUMP] = LIZMANJUMP__STATIC; + dynamictostatic[LIZMANDEADSPRITE] = LIZMANDEADSPRITE__STATIC; + dynamictostatic[FECES] = FECES__STATIC; + dynamictostatic[LIZMANHEAD1] = LIZMANHEAD1__STATIC; + dynamictostatic[LIZMANARM1] = LIZMANARM1__STATIC; + dynamictostatic[LIZMANLEG1] = LIZMANLEG1__STATIC; + dynamictostatic[EXPLOSION2BOT] = EXPLOSION2BOT__STATIC; + dynamictostatic[USERWEAPON] = USERWEAPON__STATIC; + dynamictostatic[HEADERBAR] = HEADERBAR__STATIC; + dynamictostatic[JIBS1] = JIBS1__STATIC; + dynamictostatic[JIBS2] = JIBS2__STATIC; + dynamictostatic[JIBS3] = JIBS3__STATIC; + dynamictostatic[JIBS4] = JIBS4__STATIC; + dynamictostatic[JIBS5] = JIBS5__STATIC; + dynamictostatic[BURNING] = BURNING__STATIC; + dynamictostatic[FIRE] = FIRE__STATIC; + dynamictostatic[JIBS6] = JIBS6__STATIC; + dynamictostatic[BLOODSPLAT1] = BLOODSPLAT1__STATIC; + dynamictostatic[BLOODSPLAT3] = BLOODSPLAT3__STATIC; + dynamictostatic[BLOODSPLAT2] = BLOODSPLAT2__STATIC; + dynamictostatic[BLOODSPLAT4] = BLOODSPLAT4__STATIC; + dynamictostatic[OOZ] = OOZ__STATIC; + dynamictostatic[OOZ2] = OOZ2__STATIC; + dynamictostatic[WALLBLOOD1] = WALLBLOOD1__STATIC; + dynamictostatic[WALLBLOOD2] = WALLBLOOD2__STATIC; + dynamictostatic[WALLBLOOD3] = WALLBLOOD3__STATIC; + dynamictostatic[WALLBLOOD4] = WALLBLOOD4__STATIC; + dynamictostatic[WALLBLOOD5] = WALLBLOOD5__STATIC; + dynamictostatic[WALLBLOOD6] = WALLBLOOD6__STATIC; + dynamictostatic[WALLBLOOD7] = WALLBLOOD7__STATIC; + dynamictostatic[WALLBLOOD8] = WALLBLOOD8__STATIC; + dynamictostatic[BURNING2] = BURNING2__STATIC; + dynamictostatic[FIRE2] = FIRE2__STATIC; + dynamictostatic[CRACKKNUCKLES] = CRACKKNUCKLES__STATIC; + dynamictostatic[SMALLSMOKE] = SMALLSMOKE__STATIC; + dynamictostatic[SMALLSMOKEMAKER] = SMALLSMOKEMAKER__STATIC; + dynamictostatic[FLOORFLAME] = FLOORFLAME__STATIC; + dynamictostatic[ROTATEGUN] = ROTATEGUN__STATIC; + dynamictostatic[GREENSLIME] = GREENSLIME__STATIC; + dynamictostatic[WATERDRIPSPLASH] = WATERDRIPSPLASH__STATIC; + dynamictostatic[SCRAP6] = SCRAP6__STATIC; + dynamictostatic[SCRAP1] = SCRAP1__STATIC; + dynamictostatic[SCRAP2] = SCRAP2__STATIC; + dynamictostatic[SCRAP3] = SCRAP3__STATIC; + dynamictostatic[SCRAP4] = SCRAP4__STATIC; + dynamictostatic[SCRAP5] = SCRAP5__STATIC; + dynamictostatic[ORGANTIC] = ORGANTIC__STATIC; + dynamictostatic[BETAVERSION] = BETAVERSION__STATIC; + dynamictostatic[PLAYERISHERE] = PLAYERISHERE__STATIC; + dynamictostatic[PLAYERWASHERE] = PLAYERWASHERE__STATIC; + dynamictostatic[SELECTDIR] = SELECTDIR__STATIC; + dynamictostatic[F1HELP] = F1HELP__STATIC; + dynamictostatic[NOTCHON] = NOTCHON__STATIC; + dynamictostatic[NOTCHOFF] = NOTCHOFF__STATIC; + dynamictostatic[GROWSPARK] = GROWSPARK__STATIC; + dynamictostatic[DUKEICON] = DUKEICON__STATIC; + dynamictostatic[BADGUYICON] = BADGUYICON__STATIC; + dynamictostatic[FOODICON] = FOODICON__STATIC; + dynamictostatic[GETICON] = GETICON__STATIC; + dynamictostatic[MENUSCREEN] = MENUSCREEN__STATIC; + dynamictostatic[MENUBAR] = MENUBAR__STATIC; + dynamictostatic[KILLSICON] = KILLSICON__STATIC; + dynamictostatic[FIRSTAID_ICON] = FIRSTAID_ICON__STATIC; + dynamictostatic[HEAT_ICON] = HEAT_ICON__STATIC; + dynamictostatic[BOTTOMSTATUSBAR] = BOTTOMSTATUSBAR__STATIC; + dynamictostatic[BOOT_ICON] = BOOT_ICON__STATIC; + dynamictostatic[FRAGBAR] = FRAGBAR__STATIC; + dynamictostatic[JETPACK_ICON] = JETPACK_ICON__STATIC; + dynamictostatic[AIRTANK_ICON] = AIRTANK_ICON__STATIC; + dynamictostatic[STEROIDS_ICON] = STEROIDS_ICON__STATIC; + dynamictostatic[HOLODUKE_ICON] = HOLODUKE_ICON__STATIC; + dynamictostatic[ACCESS_ICON] = ACCESS_ICON__STATIC; + dynamictostatic[DIGITALNUM] = DIGITALNUM__STATIC; + dynamictostatic[DUKECAR] = DUKECAR__STATIC; + dynamictostatic[CAMCORNER] = CAMCORNER__STATIC; + dynamictostatic[CAMLIGHT] = CAMLIGHT__STATIC; + dynamictostatic[LOGO] = LOGO__STATIC; + dynamictostatic[TITLE] = TITLE__STATIC; + dynamictostatic[NUKEWARNINGICON] = NUKEWARNINGICON__STATIC; + dynamictostatic[MOUSECURSOR] = MOUSECURSOR__STATIC; + dynamictostatic[SLIDEBAR] = SLIDEBAR__STATIC; + dynamictostatic[DREALMS] = DREALMS__STATIC; + dynamictostatic[BETASCREEN] = BETASCREEN__STATIC; + dynamictostatic[WINDOWBORDER1] = WINDOWBORDER1__STATIC; + dynamictostatic[TEXTBOX] = TEXTBOX__STATIC; + dynamictostatic[WINDOWBORDER2] = WINDOWBORDER2__STATIC; + dynamictostatic[DUKENUKEM] = DUKENUKEM__STATIC; + dynamictostatic[THREEDEE] = THREEDEE__STATIC; + dynamictostatic[INGAMEDUKETHREEDEE] = INGAMEDUKETHREEDEE__STATIC; + dynamictostatic[TENSCREEN] = TENSCREEN__STATIC; + dynamictostatic[PLUTOPAKSPRITE] = PLUTOPAKSPRITE__STATIC; + dynamictostatic[DEVISTATOR] = DEVISTATOR__STATIC; + dynamictostatic[KNEE] = KNEE__STATIC; + dynamictostatic[CROSSHAIR] = CROSSHAIR__STATIC; + dynamictostatic[FIRSTGUN] = FIRSTGUN__STATIC; + dynamictostatic[FIRSTGUNRELOAD] = FIRSTGUNRELOAD__STATIC; + dynamictostatic[FALLINGCLIP] = FALLINGCLIP__STATIC; + dynamictostatic[CLIPINHAND] = CLIPINHAND__STATIC; + dynamictostatic[HAND] = HAND__STATIC; + dynamictostatic[SHELL] = SHELL__STATIC; + dynamictostatic[SHOTGUNSHELL] = SHOTGUNSHELL__STATIC; + dynamictostatic[CHAINGUN] = CHAINGUN__STATIC; + dynamictostatic[RPGGUN] = RPGGUN__STATIC; + dynamictostatic[RPGMUZZLEFLASH] = RPGMUZZLEFLASH__STATIC; + dynamictostatic[FREEZE] = FREEZE__STATIC; + dynamictostatic[CATLITE] = CATLITE__STATIC; + dynamictostatic[SHRINKER] = SHRINKER__STATIC; + dynamictostatic[HANDHOLDINGLASER] = HANDHOLDINGLASER__STATIC; + dynamictostatic[TRIPBOMB] = TRIPBOMB__STATIC; + dynamictostatic[LASERLINE] = LASERLINE__STATIC; + dynamictostatic[HANDHOLDINGACCESS] = HANDHOLDINGACCESS__STATIC; + dynamictostatic[HANDREMOTE] = HANDREMOTE__STATIC; + dynamictostatic[HANDTHROW] = HANDTHROW__STATIC; + dynamictostatic[TIP] = TIP__STATIC; + dynamictostatic[GLAIR] = GLAIR__STATIC; + dynamictostatic[SCUBAMASK] = SCUBAMASK__STATIC; + dynamictostatic[SPACEMASK] = SPACEMASK__STATIC; + dynamictostatic[FORCESPHERE] = FORCESPHERE__STATIC; + dynamictostatic[SHOTSPARK1] = SHOTSPARK1__STATIC; + dynamictostatic[RPG] = RPG__STATIC; + dynamictostatic[LASERSITE] = LASERSITE__STATIC; + dynamictostatic[SHOTGUN] = SHOTGUN__STATIC; + dynamictostatic[BOSS1] = BOSS1__STATIC; + dynamictostatic[BOSS1STAYPUT] = BOSS1STAYPUT__STATIC; + dynamictostatic[BOSS1SHOOT] = BOSS1SHOOT__STATIC; + dynamictostatic[BOSS1LOB] = BOSS1LOB__STATIC; + dynamictostatic[BOSSTOP] = BOSSTOP__STATIC; + dynamictostatic[BOSS2] = BOSS2__STATIC; + dynamictostatic[BOSS3] = BOSS3__STATIC; + dynamictostatic[SPINNINGNUKEICON] = SPINNINGNUKEICON__STATIC; + dynamictostatic[BIGFNTCURSOR] = BIGFNTCURSOR__STATIC; + dynamictostatic[SMALLFNTCURSOR] = SMALLFNTCURSOR__STATIC; + dynamictostatic[STARTALPHANUM] = STARTALPHANUM__STATIC; + dynamictostatic[ENDALPHANUM] = ENDALPHANUM__STATIC; + dynamictostatic[BIGALPHANUM] = BIGALPHANUM__STATIC; + dynamictostatic[BIGPERIOD] = BIGPERIOD__STATIC; + dynamictostatic[BIGCOMMA] = BIGCOMMA__STATIC; + dynamictostatic[BIGX] = BIGX__STATIC; + dynamictostatic[BIGQ] = BIGQ__STATIC; + dynamictostatic[BIGSEMI] = BIGSEMI__STATIC; + dynamictostatic[BIGCOLIN] = BIGCOLIN__STATIC; + dynamictostatic[THREEBYFIVE] = THREEBYFIVE__STATIC; + dynamictostatic[BIGAPPOS] = BIGAPPOS__STATIC; + dynamictostatic[BLANK] = BLANK__STATIC; + dynamictostatic[MINIFONT] = MINIFONT__STATIC; + dynamictostatic[BUTTON1] = BUTTON1__STATIC; + dynamictostatic[GLASS3] = GLASS3__STATIC; + dynamictostatic[RESPAWNMARKERRED] = RESPAWNMARKERRED__STATIC; + dynamictostatic[RESPAWNMARKERYELLOW] = RESPAWNMARKERYELLOW__STATIC; + dynamictostatic[RESPAWNMARKERGREEN] = RESPAWNMARKERGREEN__STATIC; + dynamictostatic[BONUSSCREEN] = BONUSSCREEN__STATIC; + dynamictostatic[VIEWBORDER] = VIEWBORDER__STATIC; + dynamictostatic[VICTORY1] = VICTORY1__STATIC; + dynamictostatic[ORDERING] = ORDERING__STATIC; + dynamictostatic[TEXTSTORY] = TEXTSTORY__STATIC; + dynamictostatic[LOADSCREEN] = LOADSCREEN__STATIC; + dynamictostatic[BORNTOBEWILDSCREEN] = BORNTOBEWILDSCREEN__STATIC; + dynamictostatic[BLIMP] = BLIMP__STATIC; + dynamictostatic[FEM9] = FEM9__STATIC; + dynamictostatic[FOOTPRINT] = FOOTPRINT__STATIC; + dynamictostatic[POOP] = POOP__STATIC; + dynamictostatic[FRAMEEFFECT1] = FRAMEEFFECT1__STATIC; + dynamictostatic[FRAMEEFFECT1_13] = FRAMEEFFECT1_13__STATIC; + dynamictostatic[PANNEL3] = PANNEL3__STATIC; + dynamictostatic[SCREENBREAK14] = SCREENBREAK14__STATIC; + dynamictostatic[SCREENBREAK15] = SCREENBREAK15__STATIC; + dynamictostatic[SCREENBREAK19] = SCREENBREAK19__STATIC; + dynamictostatic[SCREENBREAK16] = SCREENBREAK16__STATIC; + dynamictostatic[SCREENBREAK17] = SCREENBREAK17__STATIC; + dynamictostatic[SCREENBREAK18] = SCREENBREAK18__STATIC; + dynamictostatic[W_TECHWALL11] = W_TECHWALL11__STATIC; + dynamictostatic[W_TECHWALL12] = W_TECHWALL12__STATIC; + dynamictostatic[W_TECHWALL13] = W_TECHWALL13__STATIC; + dynamictostatic[W_TECHWALL14] = W_TECHWALL14__STATIC; + dynamictostatic[W_TECHWALL5] = W_TECHWALL5__STATIC; + dynamictostatic[W_TECHWALL6] = W_TECHWALL6__STATIC; + dynamictostatic[W_TECHWALL7] = W_TECHWALL7__STATIC; + dynamictostatic[W_TECHWALL8] = W_TECHWALL8__STATIC; + dynamictostatic[W_TECHWALL9] = W_TECHWALL9__STATIC; + dynamictostatic[BPANNEL3] = BPANNEL3__STATIC; + dynamictostatic[W_HITTECHWALL16] = W_HITTECHWALL16__STATIC; + dynamictostatic[W_HITTECHWALL10] = W_HITTECHWALL10__STATIC; + dynamictostatic[W_HITTECHWALL15] = W_HITTECHWALL15__STATIC; + dynamictostatic[W_MILKSHELF] = W_MILKSHELF__STATIC; + dynamictostatic[W_MILKSHELFBROKE] = W_MILKSHELFBROKE__STATIC; + dynamictostatic[PURPLELAVA] = PURPLELAVA__STATIC; + dynamictostatic[LAVABUBBLE] = LAVABUBBLE__STATIC; + dynamictostatic[DUKECUTOUT] = DUKECUTOUT__STATIC; + dynamictostatic[TARGET] = TARGET__STATIC; + dynamictostatic[GUNPOWDERBARREL] = GUNPOWDERBARREL__STATIC; + dynamictostatic[DUCK] = DUCK__STATIC; + dynamictostatic[HATRACK] = HATRACK__STATIC; + dynamictostatic[DESKLAMP] = DESKLAMP__STATIC; + dynamictostatic[COFFEEMACHINE] = COFFEEMACHINE__STATIC; + dynamictostatic[CUPS] = CUPS__STATIC; + dynamictostatic[GAVALS] = GAVALS__STATIC; + dynamictostatic[GAVALS2] = GAVALS2__STATIC; + dynamictostatic[POLICELIGHTPOLE] = POLICELIGHTPOLE__STATIC; + dynamictostatic[FLOORBASKET] = FLOORBASKET__STATIC; + dynamictostatic[PUKE] = PUKE__STATIC; + dynamictostatic[DOORTILE23] = DOORTILE23__STATIC; + dynamictostatic[TOPSECRET] = TOPSECRET__STATIC; + dynamictostatic[SPEAKER] = SPEAKER__STATIC; + dynamictostatic[TEDDYBEAR] = TEDDYBEAR__STATIC; + dynamictostatic[ROBOTDOG] = ROBOTDOG__STATIC; + dynamictostatic[ROBOTPIRATE] = ROBOTPIRATE__STATIC; + dynamictostatic[ROBOTMOUSE] = ROBOTMOUSE__STATIC; + dynamictostatic[MAIL] = MAIL__STATIC; + dynamictostatic[MAILBAG] = MAILBAG__STATIC; + dynamictostatic[HOTMEAT] = HOTMEAT__STATIC; + dynamictostatic[COFFEEMUG] = COFFEEMUG__STATIC; + dynamictostatic[DONUTS2] = DONUTS2__STATIC; + dynamictostatic[TRIPODCAMERA] = TRIPODCAMERA__STATIC; + dynamictostatic[METER] = METER__STATIC; + dynamictostatic[DESKPHONE] = DESKPHONE__STATIC; + dynamictostatic[GUMBALLMACHINE] = GUMBALLMACHINE__STATIC; + dynamictostatic[GUMBALLMACHINEBROKE] = GUMBALLMACHINEBROKE__STATIC; + dynamictostatic[PAPER] = PAPER__STATIC; + dynamictostatic[MACE] = MACE__STATIC; + dynamictostatic[GENERICPOLE2] = GENERICPOLE2__STATIC; + dynamictostatic[XXXSTACY] = XXXSTACY__STATIC; + dynamictostatic[WETFLOOR] = WETFLOOR__STATIC; + dynamictostatic[BROOM] = BROOM__STATIC; + dynamictostatic[MOP] = MOP__STATIC; + dynamictostatic[LETTER] = LETTER__STATIC; + dynamictostatic[PIRATE1A] = PIRATE1A__STATIC; + dynamictostatic[PIRATE4A] = PIRATE4A__STATIC; + dynamictostatic[PIRATE2A] = PIRATE2A__STATIC; + dynamictostatic[PIRATE5A] = PIRATE5A__STATIC; + dynamictostatic[PIRATE3A] = PIRATE3A__STATIC; + dynamictostatic[PIRATE6A] = PIRATE6A__STATIC; + dynamictostatic[PIRATEHALF] = PIRATEHALF__STATIC; + dynamictostatic[CHESTOFGOLD] = CHESTOFGOLD__STATIC; + dynamictostatic[SIDEBOLT1] = SIDEBOLT1__STATIC; + dynamictostatic[FOODOBJECT1] = FOODOBJECT1__STATIC; + dynamictostatic[FOODOBJECT2] = FOODOBJECT2__STATIC; + dynamictostatic[FOODOBJECT3] = FOODOBJECT3__STATIC; + dynamictostatic[FOODOBJECT4] = FOODOBJECT4__STATIC; + dynamictostatic[FOODOBJECT5] = FOODOBJECT5__STATIC; + dynamictostatic[FOODOBJECT6] = FOODOBJECT6__STATIC; + dynamictostatic[FOODOBJECT7] = FOODOBJECT7__STATIC; + dynamictostatic[FOODOBJECT8] = FOODOBJECT8__STATIC; + dynamictostatic[FOODOBJECT9] = FOODOBJECT9__STATIC; + dynamictostatic[FOODOBJECT10] = FOODOBJECT10__STATIC; + dynamictostatic[FOODOBJECT11] = FOODOBJECT11__STATIC; + dynamictostatic[FOODOBJECT12] = FOODOBJECT12__STATIC; + dynamictostatic[FOODOBJECT13] = FOODOBJECT13__STATIC; + dynamictostatic[FOODOBJECT14] = FOODOBJECT14__STATIC; + dynamictostatic[FOODOBJECT15] = FOODOBJECT15__STATIC; + dynamictostatic[FOODOBJECT16] = FOODOBJECT16__STATIC; + dynamictostatic[FOODOBJECT17] = FOODOBJECT17__STATIC; + dynamictostatic[FOODOBJECT18] = FOODOBJECT18__STATIC; + dynamictostatic[FOODOBJECT19] = FOODOBJECT19__STATIC; + dynamictostatic[FOODOBJECT20] = FOODOBJECT20__STATIC; + dynamictostatic[HEADLAMP] = HEADLAMP__STATIC; + dynamictostatic[TAMPON] = TAMPON__STATIC; + dynamictostatic[SKINNEDCHICKEN] = SKINNEDCHICKEN__STATIC; + dynamictostatic[FEATHEREDCHICKEN] = FEATHEREDCHICKEN__STATIC; + dynamictostatic[ROBOTDOG2] = ROBOTDOG2__STATIC; + dynamictostatic[JOLLYMEAL] = JOLLYMEAL__STATIC; + dynamictostatic[DUKEBURGER] = DUKEBURGER__STATIC; + dynamictostatic[SHOPPINGCART] = SHOPPINGCART__STATIC; + dynamictostatic[CANWITHSOMETHING2] = CANWITHSOMETHING2__STATIC; + dynamictostatic[CANWITHSOMETHING3] = CANWITHSOMETHING3__STATIC; + dynamictostatic[CANWITHSOMETHING4] = CANWITHSOMETHING4__STATIC; + dynamictostatic[SNAKEP] = SNAKEP__STATIC; + dynamictostatic[DOLPHIN1] = DOLPHIN1__STATIC; + dynamictostatic[DOLPHIN2] = DOLPHIN2__STATIC; + dynamictostatic[NEWBEAST] = NEWBEAST__STATIC; + dynamictostatic[NEWBEASTSTAYPUT] = NEWBEASTSTAYPUT__STATIC; + dynamictostatic[NEWBEASTJUMP] = NEWBEASTJUMP__STATIC; + dynamictostatic[NEWBEASTHANG] = NEWBEASTHANG__STATIC; + dynamictostatic[NEWBEASTHANGDEAD] = NEWBEASTHANGDEAD__STATIC; + dynamictostatic[BOSS4] = BOSS4__STATIC; + dynamictostatic[BOSS4STAYPUT] = BOSS4STAYPUT__STATIC; + dynamictostatic[FEM10] = FEM10__STATIC; + dynamictostatic[TOUGHGAL] = TOUGHGAL__STATIC; + dynamictostatic[MAN] = MAN__STATIC; + dynamictostatic[MAN2] = MAN2__STATIC; + dynamictostatic[WOMAN] = WOMAN__STATIC; + dynamictostatic[PLEASEWAIT] = PLEASEWAIT__STATIC; + dynamictostatic[NATURALLIGHTNING] = NATURALLIGHTNING__STATIC; + dynamictostatic[WEATHERWARN] = WEATHERWARN__STATIC; + dynamictostatic[DUKETAG] = DUKETAG__STATIC; + dynamictostatic[SIGN1] = SIGN1__STATIC; + dynamictostatic[SIGN2] = SIGN2__STATIC; + dynamictostatic[JURYGUY] = JURYGUY__STATIC; + dynamictostatic[RESERVEDSLOT1] = RESERVEDSLOT1__STATIC; + dynamictostatic[RESERVEDSLOT2] = RESERVEDSLOT2__STATIC; + dynamictostatic[RESERVEDSLOT3] = RESERVEDSLOT3__STATIC; + dynamictostatic[RESERVEDSLOT4] = RESERVEDSLOT4__STATIC; + dynamictostatic[RESERVEDSLOT5] = RESERVEDSLOT5__STATIC; + dynamictostatic[RESERVEDSLOT6] = RESERVEDSLOT6__STATIC; + dynamictostatic[RESERVEDSLOT7] = RESERVEDSLOT7__STATIC; + dynamictostatic[RESERVEDSLOT8] = RESERVEDSLOT8__STATIC; + dynamictostatic[RESERVEDSLOT9] = RESERVEDSLOT9__STATIC; + dynamictostatic[RESERVEDSLOT10] = RESERVEDSLOT10__STATIC; + dynamictostatic[RESERVEDSLOT11] = RESERVEDSLOT11__STATIC; + dynamictostatic[RESERVEDSLOT12] = RESERVEDSLOT12__STATIC; + + weaponsandammosprites[0] = RPGSPRITE; + weaponsandammosprites[1] = CHAINGUNSPRITE; + weaponsandammosprites[2] = DEVISTATORAMMO; + weaponsandammosprites[3] = RPGAMMO; + weaponsandammosprites[4] = RPGAMMO; + weaponsandammosprites[5] = JETPACK; + weaponsandammosprites[6] = SHIELD; + weaponsandammosprites[7] = FIRSTAID; + weaponsandammosprites[8] = STEROIDS; + weaponsandammosprites[9] = RPGAMMO; + weaponsandammosprites[10] = RPGAMMO; + weaponsandammosprites[11] = RPGSPRITE; + weaponsandammosprites[12] = RPGAMMO; + weaponsandammosprites[13] = FREEZESPRITE; + weaponsandammosprites[14] = FREEZEAMMO; + + weapon_sprites[0] = KNEE; + weapon_sprites[1] = FIRSTGUNSPRITE; + weapon_sprites[2] = SHOTGUNSPRITE; + weapon_sprites[3] = CHAINGUNSPRITE; + weapon_sprites[4] = RPGSPRITE; + weapon_sprites[5] = HEAVYHBOMB; + weapon_sprites[6] = SHRINKERSPRITE; + weapon_sprites[7] = DEVISTATORSPRITE; + weapon_sprites[8] = TRIPBOMBSPRITE; + weapon_sprites[9] = FREEZESPRITE; + weapon_sprites[10] = HEAVYHBOMB; + weapon_sprites[11] = SHRINKERSPRITE; +} + +/* +void readnames() { + char buffer[1024], *p, *name, *number, *endptr; + int num, syms=0, line=0, a; + BFILE *fp; + + fp = fopenfrompath("NAMES.H","r"); + if (!fp) { + if ((fp = fopenfrompath("names.h","r")) == NULL) { + initprintf("Failed to open NAMES.H\n"); + return; + } + } + + //clearbufbyte(names, sizeof(names), 0); + //memset(names,0,sizeof(names)); + + initprintf("Loading NAMES.H\n"); + + while (Bfgets(buffer, 1024, fp)) { + a = Bstrlen(buffer); + if (a >= 1) { + if (a > 1) + if (buffer[a-2] == '\r') buffer[a-2] = 0; + if (buffer[a-1] == '\n') buffer[a-1] = 0; + } + + p = buffer; + line++; + while (*p == 32) p++; + if (*p == 0) continue; // blank line + + if (*p == '#') { + p++; + while (*p == 32) p++; + if (*p == 0) continue; // null directive + + else if (!Bstrncmp(p, "define ", 7)) { + // #define_... + p += 7; + while (*p == 32) p++; + if (*p == 0) { + initprintf("Error: Malformed #define at line %d\n", line-1); + continue; + } + + name = p; + while (*p != 32 && *p != 0) p++; + if (*p == 32) { + *(p++) = 0; + while (*p == 32) p++; + if (*p == 0) { // #define_NAME with no number + initprintf("Error: No number given for name \"%s\" (line %d)\n", name, line-1); + continue; + } + + number = p; + while (*p != 0) p++; + if (*p != 0) *p = 0; + + // add to list + num = Bstrtol(number, &endptr, 10); + if (*endptr != 0) { + p = endptr; + goto badline; + } + //initprintf("Grokked \"%s\" -> \"%d\"\n", name, num); + if (num < 0 || num >= MAXTILES) { + initprintf("Error: Constant %d for name \"%s\" out of range (line %d)\n", num, name, line-1); + continue; + } + processnames(name,num); + syms++; + + continue; + + } else { // #define_NAME with no number + initprintf("Error: No number given for name \"%s\" (line %d)\n", name, line-1); + continue; + } + } else goto badline; + } else if (*p == '/') { + if (*(p+1) == '/') continue; // comment + } +badline: + initprintf("Error: Invalid statement found at character %d on line %d\n", (p-buffer), line-1); + } + initprintf("Read %d lines, loaded %d names.\n", line, syms); + Bfclose(fp); +} +*/ diff --git a/polymer/eduke32/source/namesdyn.h b/polymer/eduke32/source/namesdyn.h new file mode 100644 index 000000000..793053e26 --- /dev/null +++ b/polymer/eduke32/source/namesdyn.h @@ -0,0 +1,1501 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +extern unsigned short SECTOREFFECTOR; +#define SECTOREFFECTOR__STATIC 1 +extern unsigned short ACTIVATOR; +#define ACTIVATOR__STATIC 2 +extern unsigned short TOUCHPLATE; +#define TOUCHPLATE__STATIC 3 +extern unsigned short ACTIVATORLOCKED; +#define ACTIVATORLOCKED__STATIC 4 +extern unsigned short MUSICANDSFX; +#define MUSICANDSFX__STATIC 5 +extern unsigned short LOCATORS; +#define LOCATORS__STATIC 6 +extern unsigned short CYCLER; +#define CYCLER__STATIC 7 +extern unsigned short MASTERSWITCH; +#define MASTERSWITCH__STATIC 8 +extern unsigned short RESPAWN; +#define RESPAWN__STATIC 9 +extern unsigned short GPSPEED; +#define GPSPEED__STATIC 10 +extern unsigned short FOF; +#define FOF__STATIC 13 +extern unsigned short ARROW; +#define ARROW__STATIC 20 +extern unsigned short FIRSTGUNSPRITE; +#define FIRSTGUNSPRITE__STATIC 21 +extern unsigned short CHAINGUNSPRITE; +#define CHAINGUNSPRITE__STATIC 22 +extern unsigned short RPGSPRITE; +#define RPGSPRITE__STATIC 23 +extern unsigned short FREEZESPRITE; +#define FREEZESPRITE__STATIC 24 +extern unsigned short SHRINKERSPRITE; +#define SHRINKERSPRITE__STATIC 25 +extern unsigned short HEAVYHBOMB; +#define HEAVYHBOMB__STATIC 26 +extern unsigned short TRIPBOMBSPRITE; +#define TRIPBOMBSPRITE__STATIC 27 +extern unsigned short SHOTGUNSPRITE; +#define SHOTGUNSPRITE__STATIC 28 +extern unsigned short DEVISTATORSPRITE; +#define DEVISTATORSPRITE__STATIC 29 +extern unsigned short HEALTHBOX; +#define HEALTHBOX__STATIC 30 +extern unsigned short AMMOBOX; +#define AMMOBOX__STATIC 31 +extern unsigned short GROWSPRITEICON; +#define GROWSPRITEICON__STATIC 32 +extern unsigned short INVENTORYBOX; +#define INVENTORYBOX__STATIC 33 +extern unsigned short FREEZEAMMO; +#define FREEZEAMMO__STATIC 37 +extern unsigned short AMMO; +#define AMMO__STATIC 40 +extern unsigned short BATTERYAMMO; +#define BATTERYAMMO__STATIC 41 +extern unsigned short DEVISTATORAMMO; +#define DEVISTATORAMMO__STATIC 42 +extern unsigned short RPGAMMO; +#define RPGAMMO__STATIC 44 +extern unsigned short GROWAMMO; +#define GROWAMMO__STATIC 45 +extern unsigned short CRYSTALAMMO; +#define CRYSTALAMMO__STATIC 46 +extern unsigned short HBOMBAMMO; +#define HBOMBAMMO__STATIC 47 +extern unsigned short AMMOLOTS; +#define AMMOLOTS__STATIC 48 +extern unsigned short SHOTGUNAMMO; +#define SHOTGUNAMMO__STATIC 49 +extern unsigned short COLA; +#define COLA__STATIC 51 +extern unsigned short SIXPAK; +#define SIXPAK__STATIC 52 +extern unsigned short FIRSTAID; +#define FIRSTAID__STATIC 53 +extern unsigned short SHIELD; +#define SHIELD__STATIC 54 +extern unsigned short STEROIDS; +#define STEROIDS__STATIC 55 +extern unsigned short AIRTANK; +#define AIRTANK__STATIC 56 +extern unsigned short JETPACK; +#define JETPACK__STATIC 57 +extern unsigned short HEATSENSOR; +#define HEATSENSOR__STATIC 59 +extern unsigned short ACCESSCARD; +#define ACCESSCARD__STATIC 60 +extern unsigned short BOOTS; +#define BOOTS__STATIC 61 +extern unsigned short MIRRORBROKE; +#define MIRRORBROKE__STATIC 70 +extern unsigned short CLOUDYOCEAN; +#define CLOUDYOCEAN__STATIC 78 +extern unsigned short CLOUDYSKIES; +#define CLOUDYSKIES__STATIC 79 +extern unsigned short MOONSKY1; +#define MOONSKY1__STATIC 80 +extern unsigned short MOONSKY2; +#define MOONSKY2__STATIC 81 +extern unsigned short MOONSKY3; +#define MOONSKY3__STATIC 82 +extern unsigned short MOONSKY4; +#define MOONSKY4__STATIC 83 +extern unsigned short BIGORBIT1; +#define BIGORBIT1__STATIC 84 +extern unsigned short BIGORBIT2; +#define BIGORBIT2__STATIC 85 +extern unsigned short BIGORBIT3; +#define BIGORBIT3__STATIC 86 +extern unsigned short BIGORBIT4; +#define BIGORBIT4__STATIC 87 +extern unsigned short BIGORBIT5; +#define BIGORBIT5__STATIC 88 +extern unsigned short LA; +#define LA__STATIC 89 +extern unsigned short REDSKY1; +#define REDSKY1__STATIC 98 +extern unsigned short REDSKY2; +#define REDSKY2__STATIC 99 +extern unsigned short ATOMICHEALTH; +#define ATOMICHEALTH__STATIC 100 +extern unsigned short TECHLIGHT2; +#define TECHLIGHT2__STATIC 120 +extern unsigned short TECHLIGHTBUST2; +#define TECHLIGHTBUST2__STATIC 121 +extern unsigned short TECHLIGHT4; +#define TECHLIGHT4__STATIC 122 +extern unsigned short TECHLIGHTBUST4; +#define TECHLIGHTBUST4__STATIC 123 +extern unsigned short WALLLIGHT4; +#define WALLLIGHT4__STATIC 124 +extern unsigned short WALLLIGHTBUST4; +#define WALLLIGHTBUST4__STATIC 125 +extern unsigned short ACCESSSWITCH; +#define ACCESSSWITCH__STATIC 130 +extern unsigned short SLOTDOOR; +#define SLOTDOOR__STATIC 132 +extern unsigned short LIGHTSWITCH; +#define LIGHTSWITCH__STATIC 134 +extern unsigned short SPACEDOORSWITCH; +#define SPACEDOORSWITCH__STATIC 136 +extern unsigned short SPACELIGHTSWITCH; +#define SPACELIGHTSWITCH__STATIC 138 +extern unsigned short FRANKENSTINESWITCH; +#define FRANKENSTINESWITCH__STATIC 140 +extern unsigned short NUKEBUTTON; +#define NUKEBUTTON__STATIC 142 +extern unsigned short MULTISWITCH; +#define MULTISWITCH__STATIC 146 +extern unsigned short DOORTILE5; +#define DOORTILE5__STATIC 150 +extern unsigned short DOORTILE6; +#define DOORTILE6__STATIC 151 +extern unsigned short DOORTILE1; +#define DOORTILE1__STATIC 152 +extern unsigned short DOORTILE2; +#define DOORTILE2__STATIC 153 +extern unsigned short DOORTILE3; +#define DOORTILE3__STATIC 154 +extern unsigned short DOORTILE4; +#define DOORTILE4__STATIC 155 +extern unsigned short DOORTILE7; +#define DOORTILE7__STATIC 156 +extern unsigned short DOORTILE8; +#define DOORTILE8__STATIC 157 +extern unsigned short DOORTILE9; +#define DOORTILE9__STATIC 158 +extern unsigned short DOORTILE10; +#define DOORTILE10__STATIC 159 +extern unsigned short DOORSHOCK; +#define DOORSHOCK__STATIC 160 +extern unsigned short DIPSWITCH; +#define DIPSWITCH__STATIC 162 +extern unsigned short DIPSWITCH2; +#define DIPSWITCH2__STATIC 164 +extern unsigned short TECHSWITCH; +#define TECHSWITCH__STATIC 166 +extern unsigned short DIPSWITCH3; +#define DIPSWITCH3__STATIC 168 +extern unsigned short ACCESSSWITCH2; +#define ACCESSSWITCH2__STATIC 170 +extern unsigned short REFLECTWATERTILE; +#define REFLECTWATERTILE__STATIC 180 +extern unsigned short FLOORSLIME; +#define FLOORSLIME__STATIC 200 +extern unsigned short BIGFORCE; +#define BIGFORCE__STATIC 230 +extern unsigned short EPISODE; +#define EPISODE__STATIC 247 +extern unsigned short MASKWALL9; +#define MASKWALL9__STATIC 255 +extern unsigned short W_LIGHT; +#define W_LIGHT__STATIC 260 +extern unsigned short SCREENBREAK1; +#define SCREENBREAK1__STATIC 263 +extern unsigned short SCREENBREAK2; +#define SCREENBREAK2__STATIC 264 +extern unsigned short SCREENBREAK3; +#define SCREENBREAK3__STATIC 265 +extern unsigned short SCREENBREAK4; +#define SCREENBREAK4__STATIC 266 +extern unsigned short SCREENBREAK5; +#define SCREENBREAK5__STATIC 267 +extern unsigned short SCREENBREAK6; +#define SCREENBREAK6__STATIC 268 +extern unsigned short SCREENBREAK7; +#define SCREENBREAK7__STATIC 269 +extern unsigned short SCREENBREAK8; +#define SCREENBREAK8__STATIC 270 +extern unsigned short SCREENBREAK9; +#define SCREENBREAK9__STATIC 271 +extern unsigned short SCREENBREAK10; +#define SCREENBREAK10__STATIC 272 +extern unsigned short SCREENBREAK11; +#define SCREENBREAK11__STATIC 273 +extern unsigned short SCREENBREAK12; +#define SCREENBREAK12__STATIC 274 +extern unsigned short SCREENBREAK13; +#define SCREENBREAK13__STATIC 275 +extern unsigned short MASKWALL1; +#define MASKWALL1__STATIC 285 +extern unsigned short W_TECHWALL1; +#define W_TECHWALL1__STATIC 293 +extern unsigned short W_TECHWALL2; +#define W_TECHWALL2__STATIC 297 +extern unsigned short W_TECHWALL15; +#define W_TECHWALL15__STATIC 299 +extern unsigned short W_TECHWALL3; +#define W_TECHWALL3__STATIC 301 +extern unsigned short W_TECHWALL4; +#define W_TECHWALL4__STATIC 305 +extern unsigned short W_TECHWALL10; +#define W_TECHWALL10__STATIC 306 +extern unsigned short W_TECHWALL16; +#define W_TECHWALL16__STATIC 307 +extern unsigned short WATERTILE2; +#define WATERTILE2__STATIC 336 +extern unsigned short BPANNEL1; +#define BPANNEL1__STATIC 341 +extern unsigned short PANNEL1; +#define PANNEL1__STATIC 342 +extern unsigned short PANNEL2; +#define PANNEL2__STATIC 343 +extern unsigned short WATERTILE; +#define WATERTILE__STATIC 344 +extern unsigned short STATIC; +#define STATIC__STATIC 351 +extern unsigned short W_SCREENBREAK; +#define W_SCREENBREAK__STATIC 357 +extern unsigned short W_HITTECHWALL3; +#define W_HITTECHWALL3__STATIC 360 +extern unsigned short W_HITTECHWALL4; +#define W_HITTECHWALL4__STATIC 361 +extern unsigned short W_HITTECHWALL2; +#define W_HITTECHWALL2__STATIC 362 +extern unsigned short W_HITTECHWALL1; +#define W_HITTECHWALL1__STATIC 363 +extern unsigned short MASKWALL10; +#define MASKWALL10__STATIC 387 +extern unsigned short MASKWALL11; +#define MASKWALL11__STATIC 391 +extern unsigned short DOORTILE22; +#define DOORTILE22__STATIC 395 +extern unsigned short FANSPRITE; +#define FANSPRITE__STATIC 407 +extern unsigned short FANSPRITEBROKE; +#define FANSPRITEBROKE__STATIC 411 +extern unsigned short FANSHADOW; +#define FANSHADOW__STATIC 412 +extern unsigned short FANSHADOWBROKE; +#define FANSHADOWBROKE__STATIC 416 +extern unsigned short DOORTILE18; +#define DOORTILE18__STATIC 447 +extern unsigned short DOORTILE19; +#define DOORTILE19__STATIC 448 +extern unsigned short DOORTILE20; +#define DOORTILE20__STATIC 449 +extern unsigned short SATELLITE; +#define SATELLITE__STATIC 489 +extern unsigned short VIEWSCREEN2; +#define VIEWSCREEN2__STATIC 499 +extern unsigned short VIEWSCREENBROKE; +#define VIEWSCREENBROKE__STATIC 501 +extern unsigned short VIEWSCREEN; +#define VIEWSCREEN__STATIC 502 +extern unsigned short GLASS; +#define GLASS__STATIC 503 +extern unsigned short GLASS2; +#define GLASS2__STATIC 504 +extern unsigned short STAINGLASS1; +#define STAINGLASS1__STATIC 510 +extern unsigned short MASKWALL5; +#define MASKWALL5__STATIC 514 +extern unsigned short SATELITE; +#define SATELITE__STATIC 516 +extern unsigned short FUELPOD; +#define FUELPOD__STATIC 517 +extern unsigned short SLIMEPIPE; +#define SLIMEPIPE__STATIC 538 +extern unsigned short CRACK1; +#define CRACK1__STATIC 546 +extern unsigned short CRACK2; +#define CRACK2__STATIC 547 +extern unsigned short CRACK3; +#define CRACK3__STATIC 548 +extern unsigned short CRACK4; +#define CRACK4__STATIC 549 +extern unsigned short FOOTPRINTS; +#define FOOTPRINTS__STATIC 550 +extern unsigned short DOMELITE; +#define DOMELITE__STATIC 551 +extern unsigned short CAMERAPOLE; +#define CAMERAPOLE__STATIC 554 +extern unsigned short CHAIR1; +#define CHAIR1__STATIC 556 +extern unsigned short CHAIR2; +#define CHAIR2__STATIC 557 +extern unsigned short BROKENCHAIR; +#define BROKENCHAIR__STATIC 559 +extern unsigned short MIRROR; +#define MIRROR__STATIC 560 +extern unsigned short WATERFOUNTAIN; +#define WATERFOUNTAIN__STATIC 563 +extern unsigned short WATERFOUNTAINBROKE; +#define WATERFOUNTAINBROKE__STATIC 567 +extern unsigned short FEMMAG1; +#define FEMMAG1__STATIC 568 +extern unsigned short TOILET; +#define TOILET__STATIC 569 +extern unsigned short STALL; +#define STALL__STATIC 571 +extern unsigned short STALLBROKE; +#define STALLBROKE__STATIC 573 +extern unsigned short FEMMAG2; +#define FEMMAG2__STATIC 577 +extern unsigned short REACTOR2; +#define REACTOR2__STATIC 578 +extern unsigned short REACTOR2BURNT; +#define REACTOR2BURNT__STATIC 579 +extern unsigned short REACTOR2SPARK; +#define REACTOR2SPARK__STATIC 580 +extern unsigned short GRATE1; +#define GRATE1__STATIC 595 +extern unsigned short BGRATE1; +#define BGRATE1__STATIC 596 +extern unsigned short SOLARPANNEL; +#define SOLARPANNEL__STATIC 602 +extern unsigned short NAKED1; +#define NAKED1__STATIC 603 +extern unsigned short ANTENNA; +#define ANTENNA__STATIC 607 +extern unsigned short MASKWALL12; +#define MASKWALL12__STATIC 609 +extern unsigned short TOILETBROKE; +#define TOILETBROKE__STATIC 615 +extern unsigned short PIPE2; +#define PIPE2__STATIC 616 +extern unsigned short PIPE1B; +#define PIPE1B__STATIC 617 +extern unsigned short PIPE3; +#define PIPE3__STATIC 618 +extern unsigned short PIPE1; +#define PIPE1__STATIC 619 +extern unsigned short CAMERA1; +#define CAMERA1__STATIC 621 +extern unsigned short BRICK; +#define BRICK__STATIC 626 +extern unsigned short SPLINTERWOOD; +#define SPLINTERWOOD__STATIC 630 +extern unsigned short PIPE2B; +#define PIPE2B__STATIC 633 +extern unsigned short BOLT1; +#define BOLT1__STATIC 634 +extern unsigned short W_NUMBERS; +#define W_NUMBERS__STATIC 640 +extern unsigned short WATERDRIP; +#define WATERDRIP__STATIC 660 +extern unsigned short WATERBUBBLE; +#define WATERBUBBLE__STATIC 661 +extern unsigned short WATERBUBBLEMAKER; +#define WATERBUBBLEMAKER__STATIC 662 +extern unsigned short W_FORCEFIELD; +#define W_FORCEFIELD__STATIC 663 +extern unsigned short VACUUM; +#define VACUUM__STATIC 669 +extern unsigned short FOOTPRINTS2; +#define FOOTPRINTS2__STATIC 672 +extern unsigned short FOOTPRINTS3; +#define FOOTPRINTS3__STATIC 673 +extern unsigned short FOOTPRINTS4; +#define FOOTPRINTS4__STATIC 674 +extern unsigned short EGG; +#define EGG__STATIC 675 +extern unsigned short SCALE; +#define SCALE__STATIC 678 +extern unsigned short CHAIR3; +#define CHAIR3__STATIC 680 +extern unsigned short CAMERALIGHT; +#define CAMERALIGHT__STATIC 685 +extern unsigned short MOVIECAMERA; +#define MOVIECAMERA__STATIC 686 +extern unsigned short IVUNIT; +#define IVUNIT__STATIC 689 +extern unsigned short POT1; +#define POT1__STATIC 694 +extern unsigned short POT2; +#define POT2__STATIC 695 +extern unsigned short POT3; +#define POT3__STATIC 697 +extern unsigned short PIPE3B; +#define PIPE3B__STATIC 700 +extern unsigned short WALLLIGHT3; +#define WALLLIGHT3__STATIC 701 +extern unsigned short WALLLIGHTBUST3; +#define WALLLIGHTBUST3__STATIC 702 +extern unsigned short WALLLIGHT1; +#define WALLLIGHT1__STATIC 703 +extern unsigned short WALLLIGHTBUST1; +#define WALLLIGHTBUST1__STATIC 704 +extern unsigned short WALLLIGHT2; +#define WALLLIGHT2__STATIC 705 +extern unsigned short WALLLIGHTBUST2; +#define WALLLIGHTBUST2__STATIC 706 +extern unsigned short LIGHTSWITCH2; +#define LIGHTSWITCH2__STATIC 712 +extern unsigned short WAITTOBESEATED; +#define WAITTOBESEATED__STATIC 716 +extern unsigned short DOORTILE14; +#define DOORTILE14__STATIC 717 +extern unsigned short STATUE; +#define STATUE__STATIC 753 +extern unsigned short MIKE; +#define MIKE__STATIC 762 +extern unsigned short VASE; +#define VASE__STATIC 765 +extern unsigned short SUSHIPLATE1; +#define SUSHIPLATE1__STATIC 768 +extern unsigned short SUSHIPLATE2; +#define SUSHIPLATE2__STATIC 769 +extern unsigned short SUSHIPLATE3; +#define SUSHIPLATE3__STATIC 774 +extern unsigned short SUSHIPLATE4; +#define SUSHIPLATE4__STATIC 779 +extern unsigned short DOORTILE16; +#define DOORTILE16__STATIC 781 +extern unsigned short SUSHIPLATE5; +#define SUSHIPLATE5__STATIC 792 +extern unsigned short OJ; +#define OJ__STATIC 806 +extern unsigned short MASKWALL13; +#define MASKWALL13__STATIC 830 +extern unsigned short HURTRAIL; +#define HURTRAIL__STATIC 859 +extern unsigned short POWERSWITCH1; +#define POWERSWITCH1__STATIC 860 +extern unsigned short LOCKSWITCH1; +#define LOCKSWITCH1__STATIC 862 +extern unsigned short POWERSWITCH2; +#define POWERSWITCH2__STATIC 864 +extern unsigned short ATM; +#define ATM__STATIC 867 +extern unsigned short STATUEFLASH; +#define STATUEFLASH__STATIC 869 +extern unsigned short ATMBROKE; +#define ATMBROKE__STATIC 888 +extern unsigned short BIGHOLE2; +#define BIGHOLE2__STATIC 893 +extern unsigned short STRIPEBALL; +#define STRIPEBALL__STATIC 901 +extern unsigned short QUEBALL; +#define QUEBALL__STATIC 902 +extern unsigned short POCKET; +#define POCKET__STATIC 903 +extern unsigned short WOODENHORSE; +#define WOODENHORSE__STATIC 904 +extern unsigned short TREE1; +#define TREE1__STATIC 908 +extern unsigned short TREE2; +#define TREE2__STATIC 910 +extern unsigned short CACTUS; +#define CACTUS__STATIC 911 +extern unsigned short MASKWALL2; +#define MASKWALL2__STATIC 913 +extern unsigned short MASKWALL3; +#define MASKWALL3__STATIC 914 +extern unsigned short MASKWALL4; +#define MASKWALL4__STATIC 915 +extern unsigned short FIREEXT; +#define FIREEXT__STATIC 916 +extern unsigned short TOILETWATER; +#define TOILETWATER__STATIC 921 +extern unsigned short NEON1; +#define NEON1__STATIC 925 +extern unsigned short NEON2; +#define NEON2__STATIC 926 +extern unsigned short CACTUSBROKE; +#define CACTUSBROKE__STATIC 939 +extern unsigned short BOUNCEMINE; +#define BOUNCEMINE__STATIC 940 +extern unsigned short BROKEFIREHYDRENT; +#define BROKEFIREHYDRENT__STATIC 950 +extern unsigned short BOX; +#define BOX__STATIC 951 +extern unsigned short BULLETHOLE; +#define BULLETHOLE__STATIC 952 +extern unsigned short BOTTLE1; +#define BOTTLE1__STATIC 954 +extern unsigned short BOTTLE2; +#define BOTTLE2__STATIC 955 +extern unsigned short BOTTLE3; +#define BOTTLE3__STATIC 956 +extern unsigned short BOTTLE4; +#define BOTTLE4__STATIC 957 +extern unsigned short FEMPIC5; +#define FEMPIC5__STATIC 963 +extern unsigned short FEMPIC6; +#define FEMPIC6__STATIC 964 +extern unsigned short FEMPIC7; +#define FEMPIC7__STATIC 965 +extern unsigned short HYDROPLANT; +#define HYDROPLANT__STATIC 969 +extern unsigned short OCEANSPRITE1; +#define OCEANSPRITE1__STATIC 971 +extern unsigned short OCEANSPRITE2; +#define OCEANSPRITE2__STATIC 972 +extern unsigned short OCEANSPRITE3; +#define OCEANSPRITE3__STATIC 973 +extern unsigned short OCEANSPRITE4; +#define OCEANSPRITE4__STATIC 974 +extern unsigned short OCEANSPRITE5; +#define OCEANSPRITE5__STATIC 975 +extern unsigned short GENERICPOLE; +#define GENERICPOLE__STATIC 977 +extern unsigned short CONE; +#define CONE__STATIC 978 +extern unsigned short HANGLIGHT; +#define HANGLIGHT__STATIC 979 +extern unsigned short HYDRENT; +#define HYDRENT__STATIC 981 +extern unsigned short MASKWALL14; +#define MASKWALL14__STATIC 988 +extern unsigned short TIRE; +#define TIRE__STATIC 990 +extern unsigned short PIPE5; +#define PIPE5__STATIC 994 +extern unsigned short PIPE6; +#define PIPE6__STATIC 995 +extern unsigned short PIPE4; +#define PIPE4__STATIC 996 +extern unsigned short PIPE4B; +#define PIPE4B__STATIC 997 +extern unsigned short BROKEHYDROPLANT; +#define BROKEHYDROPLANT__STATIC 1003 +extern unsigned short PIPE5B; +#define PIPE5B__STATIC 1005 +extern unsigned short NEON3; +#define NEON3__STATIC 1007 +extern unsigned short NEON4; +#define NEON4__STATIC 1008 +extern unsigned short NEON5; +#define NEON5__STATIC 1009 +extern unsigned short BOTTLE5; +#define BOTTLE5__STATIC 1012 +extern unsigned short BOTTLE6; +#define BOTTLE6__STATIC 1013 +extern unsigned short BOTTLE8; +#define BOTTLE8__STATIC 1014 +extern unsigned short SPOTLITE; +#define SPOTLITE__STATIC 1020 +extern unsigned short HANGOOZ; +#define HANGOOZ__STATIC 1022 +extern unsigned short MASKWALL15; +#define MASKWALL15__STATIC 1024 +extern unsigned short BOTTLE7; +#define BOTTLE7__STATIC 1025 +extern unsigned short HORSEONSIDE; +#define HORSEONSIDE__STATIC 1026 +extern unsigned short GLASSPIECES; +#define GLASSPIECES__STATIC 1031 +extern unsigned short HORSELITE; +#define HORSELITE__STATIC 1034 +extern unsigned short DONUTS; +#define DONUTS__STATIC 1045 +extern unsigned short NEON6; +#define NEON6__STATIC 1046 +extern unsigned short MASKWALL6; +#define MASKWALL6__STATIC 1059 +extern unsigned short CLOCK; +#define CLOCK__STATIC 1060 +extern unsigned short RUBBERCAN; +#define RUBBERCAN__STATIC 1062 +extern unsigned short BROKENCLOCK; +#define BROKENCLOCK__STATIC 1067 +extern unsigned short PLUG; +#define PLUG__STATIC 1069 +extern unsigned short OOZFILTER; +#define OOZFILTER__STATIC 1079 +extern unsigned short FLOORPLASMA; +#define FLOORPLASMA__STATIC 1082 +extern unsigned short REACTOR; +#define REACTOR__STATIC 1088 +extern unsigned short REACTORSPARK; +#define REACTORSPARK__STATIC 1092 +extern unsigned short REACTORBURNT; +#define REACTORBURNT__STATIC 1096 +extern unsigned short DOORTILE15; +#define DOORTILE15__STATIC 1102 +extern unsigned short HANDSWITCH; +#define HANDSWITCH__STATIC 1111 +extern unsigned short CIRCLEPANNEL; +#define CIRCLEPANNEL__STATIC 1113 +extern unsigned short CIRCLEPANNELBROKE; +#define CIRCLEPANNELBROKE__STATIC 1114 +extern unsigned short PULLSWITCH; +#define PULLSWITCH__STATIC 1122 +extern unsigned short MASKWALL8; +#define MASKWALL8__STATIC 1124 +extern unsigned short BIGHOLE; +#define BIGHOLE__STATIC 1141 +extern unsigned short ALIENSWITCH; +#define ALIENSWITCH__STATIC 1142 +extern unsigned short DOORTILE21; +#define DOORTILE21__STATIC 1144 +extern unsigned short HANDPRINTSWITCH; +#define HANDPRINTSWITCH__STATIC 1155 +extern unsigned short BOTTLE10; +#define BOTTLE10__STATIC 1157 +extern unsigned short BOTTLE11; +#define BOTTLE11__STATIC 1158 +extern unsigned short BOTTLE12; +#define BOTTLE12__STATIC 1159 +extern unsigned short BOTTLE13; +#define BOTTLE13__STATIC 1160 +extern unsigned short BOTTLE14; +#define BOTTLE14__STATIC 1161 +extern unsigned short BOTTLE15; +#define BOTTLE15__STATIC 1162 +extern unsigned short BOTTLE16; +#define BOTTLE16__STATIC 1163 +extern unsigned short BOTTLE17; +#define BOTTLE17__STATIC 1164 +extern unsigned short BOTTLE18; +#define BOTTLE18__STATIC 1165 +extern unsigned short BOTTLE19; +#define BOTTLE19__STATIC 1166 +extern unsigned short DOORTILE17; +#define DOORTILE17__STATIC 1169 +extern unsigned short MASKWALL7; +#define MASKWALL7__STATIC 1174 +extern unsigned short JAILBARBREAK; +#define JAILBARBREAK__STATIC 1175 +extern unsigned short DOORTILE11; +#define DOORTILE11__STATIC 1178 +extern unsigned short DOORTILE12; +#define DOORTILE12__STATIC 1179 +extern unsigned short VENDMACHINE; +#define VENDMACHINE__STATIC 1212 +extern unsigned short VENDMACHINEBROKE; +#define VENDMACHINEBROKE__STATIC 1214 +extern unsigned short COLAMACHINE; +#define COLAMACHINE__STATIC 1215 +extern unsigned short COLAMACHINEBROKE; +#define COLAMACHINEBROKE__STATIC 1217 +extern unsigned short CRANEPOLE; +#define CRANEPOLE__STATIC 1221 +extern unsigned short CRANE; +#define CRANE__STATIC 1222 +extern unsigned short BARBROKE; +#define BARBROKE__STATIC 1225 +extern unsigned short BLOODPOOL; +#define BLOODPOOL__STATIC 1226 +extern unsigned short NUKEBARREL; +#define NUKEBARREL__STATIC 1227 +extern unsigned short NUKEBARRELDENTED; +#define NUKEBARRELDENTED__STATIC 1228 +extern unsigned short NUKEBARRELLEAKED; +#define NUKEBARRELLEAKED__STATIC 1229 +extern unsigned short CANWITHSOMETHING; +#define CANWITHSOMETHING__STATIC 1232 +extern unsigned short MONEY; +#define MONEY__STATIC 1233 +extern unsigned short BANNER; +#define BANNER__STATIC 1236 +extern unsigned short EXPLODINGBARREL; +#define EXPLODINGBARREL__STATIC 1238 +extern unsigned short EXPLODINGBARREL2; +#define EXPLODINGBARREL2__STATIC 1239 +extern unsigned short FIREBARREL; +#define FIREBARREL__STATIC 1240 +extern unsigned short SEENINE; +#define SEENINE__STATIC 1247 +extern unsigned short SEENINEDEAD; +#define SEENINEDEAD__STATIC 1248 +extern unsigned short STEAM; +#define STEAM__STATIC 1250 +extern unsigned short CEILINGSTEAM; +#define CEILINGSTEAM__STATIC 1255 +extern unsigned short PIPE6B; +#define PIPE6B__STATIC 1260 +extern unsigned short TRANSPORTERBEAM; +#define TRANSPORTERBEAM__STATIC 1261 +extern unsigned short RAT; +#define RAT__STATIC 1267 +extern unsigned short TRASH; +#define TRASH__STATIC 1272 +extern unsigned short FEMPIC1; +#define FEMPIC1__STATIC 1280 +extern unsigned short FEMPIC2; +#define FEMPIC2__STATIC 1289 +extern unsigned short BLANKSCREEN; +#define BLANKSCREEN__STATIC 1293 +extern unsigned short PODFEM1; +#define PODFEM1__STATIC 1294 +extern unsigned short FEMPIC3; +#define FEMPIC3__STATIC 1298 +extern unsigned short FEMPIC4; +#define FEMPIC4__STATIC 1306 +extern unsigned short FEM1; +#define FEM1__STATIC 1312 +extern unsigned short FEM2; +#define FEM2__STATIC 1317 +extern unsigned short FEM3; +#define FEM3__STATIC 1321 +extern unsigned short FEM5; +#define FEM5__STATIC 1323 +extern unsigned short BLOODYPOLE; +#define BLOODYPOLE__STATIC 1324 +extern unsigned short FEM4; +#define FEM4__STATIC 1325 +extern unsigned short FEM6; +#define FEM6__STATIC 1334 +extern unsigned short FEM6PAD; +#define FEM6PAD__STATIC 1335 +extern unsigned short FEM8; +#define FEM8__STATIC 1336 +extern unsigned short HELECOPT; +#define HELECOPT__STATIC 1346 +extern unsigned short FETUSJIB; +#define FETUSJIB__STATIC 1347 +extern unsigned short HOLODUKE; +#define HOLODUKE__STATIC 1348 +extern unsigned short SPACEMARINE; +#define SPACEMARINE__STATIC 1353 +extern unsigned short INDY; +#define INDY__STATIC 1355 +extern unsigned short FETUS; +#define FETUS__STATIC 1358 +extern unsigned short FETUSBROKE; +#define FETUSBROKE__STATIC 1359 +extern unsigned short MONK; +#define MONK__STATIC 1352 +extern unsigned short LUKE; +#define LUKE__STATIC 1354 +extern unsigned short COOLEXPLOSION1; +#define COOLEXPLOSION1__STATIC 1360 +extern unsigned short WATERSPLASH2; +#define WATERSPLASH2__STATIC 1380 +extern unsigned short FIREVASE; +#define FIREVASE__STATIC 1390 +extern unsigned short SCRATCH; +#define SCRATCH__STATIC 1393 +extern unsigned short FEM7; +#define FEM7__STATIC 1395 +extern unsigned short APLAYERTOP; +#define APLAYERTOP__STATIC 1400 +extern unsigned short APLAYER; +#define APLAYER__STATIC 1405 +extern unsigned short PLAYERONWATER; +#define PLAYERONWATER__STATIC 1420 +extern unsigned short DUKELYINGDEAD; +#define DUKELYINGDEAD__STATIC 1518 +extern unsigned short DUKETORSO; +#define DUKETORSO__STATIC 1520 +extern unsigned short DUKEGUN; +#define DUKEGUN__STATIC 1528 +extern unsigned short DUKELEG; +#define DUKELEG__STATIC 1536 +extern unsigned short SHARK; +#define SHARK__STATIC 1550 +extern unsigned short BLOOD; +#define BLOOD__STATIC 1620 +extern unsigned short FIRELASER; +#define FIRELASER__STATIC 1625 +extern unsigned short TRANSPORTERSTAR; +#define TRANSPORTERSTAR__STATIC 1630 +extern unsigned short SPIT; +#define SPIT__STATIC 1636 +extern unsigned short LOOGIE; +#define LOOGIE__STATIC 1637 +extern unsigned short FIST; +#define FIST__STATIC 1640 +extern unsigned short FREEZEBLAST; +#define FREEZEBLAST__STATIC 1641 +extern unsigned short DEVISTATORBLAST; +#define DEVISTATORBLAST__STATIC 1642 +extern unsigned short SHRINKSPARK; +#define SHRINKSPARK__STATIC 1646 +extern unsigned short TONGUE; +#define TONGUE__STATIC 1647 +extern unsigned short MORTER; +#define MORTER__STATIC 1650 +extern unsigned short SHRINKEREXPLOSION; +#define SHRINKEREXPLOSION__STATIC 1656 +extern unsigned short RADIUSEXPLOSION; +#define RADIUSEXPLOSION__STATIC 1670 +extern unsigned short FORCERIPPLE; +#define FORCERIPPLE__STATIC 1671 +extern unsigned short LIZTROOP; +#define LIZTROOP__STATIC 1680 +extern unsigned short LIZTROOPRUNNING; +#define LIZTROOPRUNNING__STATIC 1681 +extern unsigned short LIZTROOPSTAYPUT; +#define LIZTROOPSTAYPUT__STATIC 1682 +extern unsigned short LIZTOP; +#define LIZTOP__STATIC 1705 +extern unsigned short LIZTROOPSHOOT; +#define LIZTROOPSHOOT__STATIC 1715 +extern unsigned short LIZTROOPJETPACK; +#define LIZTROOPJETPACK__STATIC 1725 +extern unsigned short LIZTROOPDSPRITE; +#define LIZTROOPDSPRITE__STATIC 1734 +extern unsigned short LIZTROOPONTOILET; +#define LIZTROOPONTOILET__STATIC 1741 +extern unsigned short LIZTROOPJUSTSIT; +#define LIZTROOPJUSTSIT__STATIC 1742 +extern unsigned short LIZTROOPDUCKING; +#define LIZTROOPDUCKING__STATIC 1744 +extern unsigned short HEADJIB1; +#define HEADJIB1__STATIC 1768 +extern unsigned short ARMJIB1; +#define ARMJIB1__STATIC 1772 +extern unsigned short LEGJIB1; +#define LEGJIB1__STATIC 1776 +extern unsigned short CANNONBALL; +#define CANNONBALL__STATIC 1817 +extern unsigned short OCTABRAIN; +#define OCTABRAIN__STATIC 1820 +extern unsigned short OCTABRAINSTAYPUT; +#define OCTABRAINSTAYPUT__STATIC 1821 +extern unsigned short OCTATOP; +#define OCTATOP__STATIC 1845 +extern unsigned short OCTADEADSPRITE; +#define OCTADEADSPRITE__STATIC 1855 +extern unsigned short INNERJAW; +#define INNERJAW__STATIC 1860 +extern unsigned short DRONE; +#define DRONE__STATIC 1880 +extern unsigned short EXPLOSION2; +#define EXPLOSION2__STATIC 1890 +extern unsigned short COMMANDER; +#define COMMANDER__STATIC 1920 +extern unsigned short COMMANDERSTAYPUT; +#define COMMANDERSTAYPUT__STATIC 1921 +extern unsigned short RECON; +#define RECON__STATIC 1960 +extern unsigned short TANK; +#define TANK__STATIC 1975 +extern unsigned short PIGCOP; +#define PIGCOP__STATIC 2000 +extern unsigned short PIGCOPSTAYPUT; +#define PIGCOPSTAYPUT__STATIC 2001 +extern unsigned short PIGCOPDIVE; +#define PIGCOPDIVE__STATIC 2045 +extern unsigned short PIGCOPDEADSPRITE; +#define PIGCOPDEADSPRITE__STATIC 2060 +extern unsigned short PIGTOP; +#define PIGTOP__STATIC 2061 +extern unsigned short LIZMAN; +#define LIZMAN__STATIC 2120 +extern unsigned short LIZMANSTAYPUT; +#define LIZMANSTAYPUT__STATIC 2121 +extern unsigned short LIZMANSPITTING; +#define LIZMANSPITTING__STATIC 2150 +extern unsigned short LIZMANFEEDING; +#define LIZMANFEEDING__STATIC 2160 +extern unsigned short LIZMANJUMP; +#define LIZMANJUMP__STATIC 2165 +extern unsigned short LIZMANDEADSPRITE; +#define LIZMANDEADSPRITE__STATIC 2185 +extern unsigned short FECES; +#define FECES__STATIC 2200 +extern unsigned short LIZMANHEAD1; +#define LIZMANHEAD1__STATIC 2201 +extern unsigned short LIZMANARM1; +#define LIZMANARM1__STATIC 2205 +extern unsigned short LIZMANLEG1; +#define LIZMANLEG1__STATIC 2209 +extern unsigned short EXPLOSION2BOT; +#define EXPLOSION2BOT__STATIC 2219 +extern unsigned short USERWEAPON; +#define USERWEAPON__STATIC 2235 +extern unsigned short HEADERBAR; +#define HEADERBAR__STATIC 2242 +extern unsigned short JIBS1; +#define JIBS1__STATIC 2245 +extern unsigned short JIBS2; +#define JIBS2__STATIC 2250 +extern unsigned short JIBS3; +#define JIBS3__STATIC 2255 +extern unsigned short JIBS4; +#define JIBS4__STATIC 2260 +extern unsigned short JIBS5; +#define JIBS5__STATIC 2265 +extern unsigned short BURNING; +#define BURNING__STATIC 2270 +extern unsigned short FIRE; +#define FIRE__STATIC 2271 +extern unsigned short JIBS6; +#define JIBS6__STATIC 2286 +extern unsigned short BLOODSPLAT1; +#define BLOODSPLAT1__STATIC 2296 +extern unsigned short BLOODSPLAT3; +#define BLOODSPLAT3__STATIC 2297 +extern unsigned short BLOODSPLAT2; +#define BLOODSPLAT2__STATIC 2298 +extern unsigned short BLOODSPLAT4; +#define BLOODSPLAT4__STATIC 2299 +extern unsigned short OOZ; +#define OOZ__STATIC 2300 +extern unsigned short OOZ2; +#define OOZ2__STATIC 2309 +extern unsigned short WALLBLOOD1; +#define WALLBLOOD1__STATIC 2301 +extern unsigned short WALLBLOOD2; +#define WALLBLOOD2__STATIC 2302 +extern unsigned short WALLBLOOD3; +#define WALLBLOOD3__STATIC 2303 +extern unsigned short WALLBLOOD4; +#define WALLBLOOD4__STATIC 2304 +extern unsigned short WALLBLOOD5; +#define WALLBLOOD5__STATIC 2305 +extern unsigned short WALLBLOOD6; +#define WALLBLOOD6__STATIC 2306 +extern unsigned short WALLBLOOD7; +#define WALLBLOOD7__STATIC 2307 +extern unsigned short WALLBLOOD8; +#define WALLBLOOD8__STATIC 2308 +extern unsigned short BURNING2; +#define BURNING2__STATIC 2310 +extern unsigned short FIRE2; +#define FIRE2__STATIC 2311 +extern unsigned short CRACKKNUCKLES; +#define CRACKKNUCKLES__STATIC 2324 +extern unsigned short SMALLSMOKE; +#define SMALLSMOKE__STATIC 2329 +extern unsigned short SMALLSMOKEMAKER; +#define SMALLSMOKEMAKER__STATIC 2330 +extern unsigned short FLOORFLAME; +#define FLOORFLAME__STATIC 2333 +extern unsigned short ROTATEGUN; +#define ROTATEGUN__STATIC 2360 +extern unsigned short GREENSLIME; +#define GREENSLIME__STATIC 2370 +extern unsigned short WATERDRIPSPLASH; +#define WATERDRIPSPLASH__STATIC 2380 +extern unsigned short SCRAP6; +#define SCRAP6__STATIC 2390 +extern unsigned short SCRAP1; +#define SCRAP1__STATIC 2400 +extern unsigned short SCRAP2; +#define SCRAP2__STATIC 2404 +extern unsigned short SCRAP3; +#define SCRAP3__STATIC 2408 +extern unsigned short SCRAP4; +#define SCRAP4__STATIC 2412 +extern unsigned short SCRAP5; +#define SCRAP5__STATIC 2416 +extern unsigned short ORGANTIC; +#define ORGANTIC__STATIC 2420 +extern unsigned short BETAVERSION; +#define BETAVERSION__STATIC 2440 +extern unsigned short PLAYERISHERE; +#define PLAYERISHERE__STATIC 2442 +extern unsigned short PLAYERWASHERE; +#define PLAYERWASHERE__STATIC 2443 +extern unsigned short SELECTDIR; +#define SELECTDIR__STATIC 2444 +extern unsigned short F1HELP; +#define F1HELP__STATIC 2445 +extern unsigned short NOTCHON; +#define NOTCHON__STATIC 2446 +extern unsigned short NOTCHOFF; +#define NOTCHOFF__STATIC 2447 +extern unsigned short GROWSPARK; +#define GROWSPARK__STATIC 2448 +extern unsigned short DUKEICON; +#define DUKEICON__STATIC 2452 +extern unsigned short BADGUYICON; +#define BADGUYICON__STATIC 2453 +extern unsigned short FOODICON; +#define FOODICON__STATIC 2454 +extern unsigned short GETICON; +#define GETICON__STATIC 2455 +extern unsigned short MENUSCREEN; +#define MENUSCREEN__STATIC 2456 +extern unsigned short MENUBAR; +#define MENUBAR__STATIC 2457 +extern unsigned short KILLSICON; +#define KILLSICON__STATIC 2458 +extern unsigned short FIRSTAID_ICON; +#define FIRSTAID_ICON__STATIC 2460 +extern unsigned short HEAT_ICON; +#define HEAT_ICON__STATIC 2461 +extern unsigned short BOTTOMSTATUSBAR; +#define BOTTOMSTATUSBAR__STATIC 2462 +extern unsigned short BOOT_ICON; +#define BOOT_ICON__STATIC 2463 +extern unsigned short FRAGBAR; +#define FRAGBAR__STATIC 2465 +extern unsigned short JETPACK_ICON; +#define JETPACK_ICON__STATIC 2467 +extern unsigned short AIRTANK_ICON; +#define AIRTANK_ICON__STATIC 2468 +extern unsigned short STEROIDS_ICON; +#define STEROIDS_ICON__STATIC 2469 +extern unsigned short HOLODUKE_ICON; +#define HOLODUKE_ICON__STATIC 2470 +extern unsigned short ACCESS_ICON; +#define ACCESS_ICON__STATIC 2471 +extern unsigned short DIGITALNUM; +#define DIGITALNUM__STATIC 2472 +extern unsigned short DUKECAR; +#define DUKECAR__STATIC 2491 +extern unsigned short CAMCORNER; +#define CAMCORNER__STATIC 2482 +extern unsigned short CAMLIGHT; +#define CAMLIGHT__STATIC 2484 +extern unsigned short LOGO; +#define LOGO__STATIC 2485 +extern unsigned short TITLE; +#define TITLE__STATIC 2486 +extern unsigned short NUKEWARNINGICON; +#define NUKEWARNINGICON__STATIC 2487 +extern unsigned short MOUSECURSOR; +#define MOUSECURSOR__STATIC 2488 +extern unsigned short SLIDEBAR; +#define SLIDEBAR__STATIC 2489 +extern unsigned short DREALMS; +#define DREALMS__STATIC 2492 +extern unsigned short BETASCREEN; +#define BETASCREEN__STATIC 2493 +extern unsigned short WINDOWBORDER1; +#define WINDOWBORDER1__STATIC 2494 +extern unsigned short TEXTBOX; +#define TEXTBOX__STATIC 2495 +extern unsigned short WINDOWBORDER2; +#define WINDOWBORDER2__STATIC 2496 +extern unsigned short DUKENUKEM; +#define DUKENUKEM__STATIC 2497 +extern unsigned short THREEDEE; +#define THREEDEE__STATIC 2498 +extern unsigned short INGAMEDUKETHREEDEE; +#define INGAMEDUKETHREEDEE__STATIC 2499 +extern unsigned short TENSCREEN; +#define TENSCREEN__STATIC 2500 +extern unsigned short PLUTOPAKSPRITE; +#define PLUTOPAKSPRITE__STATIC 2501 +extern unsigned short DEVISTATOR; +#define DEVISTATOR__STATIC 2510 +extern unsigned short KNEE; +#define KNEE__STATIC 2521 +extern unsigned short CROSSHAIR; +#define CROSSHAIR__STATIC 2523 +extern unsigned short FIRSTGUN; +#define FIRSTGUN__STATIC 2524 +extern unsigned short FIRSTGUNRELOAD; +#define FIRSTGUNRELOAD__STATIC 2528 +extern unsigned short FALLINGCLIP; +#define FALLINGCLIP__STATIC 2530 +extern unsigned short CLIPINHAND; +#define CLIPINHAND__STATIC 2531 +extern unsigned short HAND; +#define HAND__STATIC 2532 +extern unsigned short SHELL; +#define SHELL__STATIC 2533 +extern unsigned short SHOTGUNSHELL; +#define SHOTGUNSHELL__STATIC 2535 +extern unsigned short CHAINGUN; +#define CHAINGUN__STATIC 2536 +extern unsigned short RPGGUN; +#define RPGGUN__STATIC 2544 +extern unsigned short RPGMUZZLEFLASH; +#define RPGMUZZLEFLASH__STATIC 2545 +extern unsigned short FREEZE; +#define FREEZE__STATIC 2548 +extern unsigned short CATLITE; +#define CATLITE__STATIC 2552 +extern unsigned short SHRINKER; +#define SHRINKER__STATIC 2556 +extern unsigned short HANDHOLDINGLASER; +#define HANDHOLDINGLASER__STATIC 2563 +extern unsigned short TRIPBOMB; +#define TRIPBOMB__STATIC 2566 +extern unsigned short LASERLINE; +#define LASERLINE__STATIC 2567 +extern unsigned short HANDHOLDINGACCESS; +#define HANDHOLDINGACCESS__STATIC 2568 +extern unsigned short HANDREMOTE; +#define HANDREMOTE__STATIC 2570 +extern unsigned short HANDTHROW; +#define HANDTHROW__STATIC 2573 +extern unsigned short TIP; +#define TIP__STATIC 2576 +extern unsigned short GLAIR; +#define GLAIR__STATIC 2578 +extern unsigned short SCUBAMASK; +#define SCUBAMASK__STATIC 2581 +extern unsigned short SPACEMASK; +#define SPACEMASK__STATIC 2584 +extern unsigned short FORCESPHERE; +#define FORCESPHERE__STATIC 2590 +extern unsigned short SHOTSPARK1; +#define SHOTSPARK1__STATIC 2595 +extern unsigned short RPG; +#define RPG__STATIC 2605 +extern unsigned short LASERSITE; +#define LASERSITE__STATIC 2612 +extern unsigned short SHOTGUN; +#define SHOTGUN__STATIC 2613 +extern unsigned short BOSS1; +#define BOSS1__STATIC 2630 +extern unsigned short BOSS1STAYPUT; +#define BOSS1STAYPUT__STATIC 2631 +extern unsigned short BOSS1SHOOT; +#define BOSS1SHOOT__STATIC 2660 +extern unsigned short BOSS1LOB; +#define BOSS1LOB__STATIC 2670 +extern unsigned short BOSSTOP; +#define BOSSTOP__STATIC 2696 +extern unsigned short BOSS2; +#define BOSS2__STATIC 2710 +extern unsigned short BOSS3; +#define BOSS3__STATIC 2760 +extern unsigned short SPINNINGNUKEICON; +#define SPINNINGNUKEICON__STATIC 2813 +extern unsigned short BIGFNTCURSOR; +#define BIGFNTCURSOR__STATIC 2820 +extern unsigned short SMALLFNTCURSOR; +#define SMALLFNTCURSOR__STATIC 2821 +extern unsigned short STARTALPHANUM; +#define STARTALPHANUM__STATIC 2822 +extern unsigned short ENDALPHANUM; +#define ENDALPHANUM__STATIC 2915 +extern unsigned short BIGALPHANUM; +#define BIGALPHANUM__STATIC 2940 +extern unsigned short BIGPERIOD; +#define BIGPERIOD__STATIC 3002 +extern unsigned short BIGCOMMA; +#define BIGCOMMA__STATIC 3003 +extern unsigned short BIGX; +#define BIGX__STATIC 3004 +extern unsigned short BIGQ; +#define BIGQ__STATIC 3005 +extern unsigned short BIGSEMI; +#define BIGSEMI__STATIC 3006 +extern unsigned short BIGCOLIN; +#define BIGCOLIN__STATIC 3007 +extern unsigned short THREEBYFIVE; +#define THREEBYFIVE__STATIC 3010 +extern unsigned short BIGAPPOS; +#define BIGAPPOS__STATIC 3022 +extern unsigned short BLANK; +#define BLANK__STATIC 3026 +extern unsigned short MINIFONT; +#define MINIFONT__STATIC 3072 +extern unsigned short BUTTON1; +#define BUTTON1__STATIC 3164 +extern unsigned short GLASS3; +#define GLASS3__STATIC 3187 +extern unsigned short RESPAWNMARKERRED; +#define RESPAWNMARKERRED__STATIC 3190 +extern unsigned short RESPAWNMARKERYELLOW; +#define RESPAWNMARKERYELLOW__STATIC 3200 +extern unsigned short RESPAWNMARKERGREEN; +#define RESPAWNMARKERGREEN__STATIC 3210 +extern unsigned short BONUSSCREEN; +#define BONUSSCREEN__STATIC 3240 +extern unsigned short VIEWBORDER; +#define VIEWBORDER__STATIC 3250 +extern unsigned short VICTORY1; +#define VICTORY1__STATIC 3260 +extern unsigned short ORDERING; +#define ORDERING__STATIC 3270 +extern unsigned short TEXTSTORY; +#define TEXTSTORY__STATIC 3280 +extern unsigned short LOADSCREEN; +#define LOADSCREEN__STATIC 3281 +extern unsigned short BORNTOBEWILDSCREEN; +#define BORNTOBEWILDSCREEN__STATIC 3370 +extern unsigned short BLIMP; +#define BLIMP__STATIC 3400 +extern unsigned short FEM9; +#define FEM9__STATIC 3450 +extern unsigned short FOOTPRINT; +#define FOOTPRINT__STATIC 3701 +extern unsigned short FRAMEEFFECT1_13; +#define FRAMEEFFECT1_13__STATIC 3999 +extern unsigned short POOP; +#define POOP__STATIC 4094 +extern unsigned short FRAMEEFFECT1; +#define FRAMEEFFECT1__STATIC 4095 +extern unsigned short PANNEL3; +#define PANNEL3__STATIC 4099 +extern unsigned short SCREENBREAK14; +#define SCREENBREAK14__STATIC 4120 +extern unsigned short SCREENBREAK15; +#define SCREENBREAK15__STATIC 4123 +extern unsigned short SCREENBREAK19; +#define SCREENBREAK19__STATIC 4125 +extern unsigned short SCREENBREAK16; +#define SCREENBREAK16__STATIC 4127 +extern unsigned short SCREENBREAK17; +#define SCREENBREAK17__STATIC 4128 +extern unsigned short SCREENBREAK18; +#define SCREENBREAK18__STATIC 4129 +extern unsigned short W_TECHWALL11; +#define W_TECHWALL11__STATIC 4130 +extern unsigned short W_TECHWALL12; +#define W_TECHWALL12__STATIC 4131 +extern unsigned short W_TECHWALL13; +#define W_TECHWALL13__STATIC 4132 +extern unsigned short W_TECHWALL14; +#define W_TECHWALL14__STATIC 4133 +extern unsigned short W_TECHWALL5; +#define W_TECHWALL5__STATIC 4134 +extern unsigned short W_TECHWALL6; +#define W_TECHWALL6__STATIC 4136 +extern unsigned short W_TECHWALL7; +#define W_TECHWALL7__STATIC 4138 +extern unsigned short W_TECHWALL8; +#define W_TECHWALL8__STATIC 4140 +extern unsigned short W_TECHWALL9; +#define W_TECHWALL9__STATIC 4142 +extern unsigned short BPANNEL3; +#define BPANNEL3__STATIC 4100 +extern unsigned short W_HITTECHWALL16; +#define W_HITTECHWALL16__STATIC 4144 +extern unsigned short W_HITTECHWALL10; +#define W_HITTECHWALL10__STATIC 4145 +extern unsigned short W_HITTECHWALL15; +#define W_HITTECHWALL15__STATIC 4147 +extern unsigned short W_MILKSHELF; +#define W_MILKSHELF__STATIC 4181 +extern unsigned short W_MILKSHELFBROKE; +#define W_MILKSHELFBROKE__STATIC 4203 +extern unsigned short PURPLELAVA; +#define PURPLELAVA__STATIC 4240 +extern unsigned short LAVABUBBLE; +#define LAVABUBBLE__STATIC 4340 +extern unsigned short DUKECUTOUT; +#define DUKECUTOUT__STATIC 4352 +extern unsigned short TARGET; +#define TARGET__STATIC 4359 +extern unsigned short GUNPOWDERBARREL; +#define GUNPOWDERBARREL__STATIC 4360 +extern unsigned short DUCK; +#define DUCK__STATIC 4361 +extern unsigned short HATRACK; +#define HATRACK__STATIC 4367 +extern unsigned short DESKLAMP; +#define DESKLAMP__STATIC 4370 +extern unsigned short COFFEEMACHINE; +#define COFFEEMACHINE__STATIC 4372 +extern unsigned short CUPS; +#define CUPS__STATIC 4373 +extern unsigned short GAVALS; +#define GAVALS__STATIC 4374 +extern unsigned short GAVALS2; +#define GAVALS2__STATIC 4375 +extern unsigned short POLICELIGHTPOLE; +#define POLICELIGHTPOLE__STATIC 4377 +extern unsigned short FLOORBASKET; +#define FLOORBASKET__STATIC 4388 +extern unsigned short PUKE; +#define PUKE__STATIC 4389 +extern unsigned short DOORTILE23; +#define DOORTILE23__STATIC 4391 +extern unsigned short TOPSECRET; +#define TOPSECRET__STATIC 4396 +extern unsigned short SPEAKER; +#define SPEAKER__STATIC 4397 +extern unsigned short TEDDYBEAR; +#define TEDDYBEAR__STATIC 4400 +extern unsigned short ROBOTDOG; +#define ROBOTDOG__STATIC 4402 +extern unsigned short ROBOTPIRATE; +#define ROBOTPIRATE__STATIC 4404 +extern unsigned short ROBOTMOUSE; +#define ROBOTMOUSE__STATIC 4407 +extern unsigned short MAIL; +#define MAIL__STATIC 4410 +extern unsigned short MAILBAG; +#define MAILBAG__STATIC 4413 +extern unsigned short HOTMEAT; +#define HOTMEAT__STATIC 4427 +extern unsigned short COFFEEMUG; +#define COFFEEMUG__STATIC 4438 +extern unsigned short DONUTS2; +#define DONUTS2__STATIC 4440 +extern unsigned short TRIPODCAMERA; +#define TRIPODCAMERA__STATIC 4444 +extern unsigned short METER; +#define METER__STATIC 4453 +extern unsigned short DESKPHONE; +#define DESKPHONE__STATIC 4454 +extern unsigned short GUMBALLMACHINE; +#define GUMBALLMACHINE__STATIC 4458 +extern unsigned short GUMBALLMACHINEBROKE; +#define GUMBALLMACHINEBROKE__STATIC 4459 +extern unsigned short PAPER; +#define PAPER__STATIC 4460 +extern unsigned short MACE; +#define MACE__STATIC 4464 +extern unsigned short GENERICPOLE2; +#define GENERICPOLE2__STATIC 4465 +extern unsigned short XXXSTACY; +#define XXXSTACY__STATIC 4470 +extern unsigned short WETFLOOR; +#define WETFLOOR__STATIC 4495 +extern unsigned short BROOM; +#define BROOM__STATIC 4496 +extern unsigned short MOP; +#define MOP__STATIC 4497 +extern unsigned short LETTER; +#define LETTER__STATIC 4502 +extern unsigned short PIRATE1A; +#define PIRATE1A__STATIC 4510 +extern unsigned short PIRATE4A; +#define PIRATE4A__STATIC 4511 +extern unsigned short PIRATE2A; +#define PIRATE2A__STATIC 4512 +extern unsigned short PIRATE5A; +#define PIRATE5A__STATIC 4513 +extern unsigned short PIRATE3A; +#define PIRATE3A__STATIC 4514 +extern unsigned short PIRATE6A; +#define PIRATE6A__STATIC 4515 +extern unsigned short PIRATEHALF; +#define PIRATEHALF__STATIC 4516 +extern unsigned short CHESTOFGOLD; +#define CHESTOFGOLD__STATIC 4520 +extern unsigned short SIDEBOLT1; +#define SIDEBOLT1__STATIC 4525 +extern unsigned short FOODOBJECT1; +#define FOODOBJECT1__STATIC 4530 +extern unsigned short FOODOBJECT2; +#define FOODOBJECT2__STATIC 4531 +extern unsigned short FOODOBJECT3; +#define FOODOBJECT3__STATIC 4532 +extern unsigned short FOODOBJECT4; +#define FOODOBJECT4__STATIC 4533 +extern unsigned short FOODOBJECT5; +#define FOODOBJECT5__STATIC 4534 +extern unsigned short FOODOBJECT6; +#define FOODOBJECT6__STATIC 4535 +extern unsigned short FOODOBJECT7; +#define FOODOBJECT7__STATIC 4536 +extern unsigned short FOODOBJECT8; +#define FOODOBJECT8__STATIC 4537 +extern unsigned short FOODOBJECT9; +#define FOODOBJECT9__STATIC 4538 +extern unsigned short FOODOBJECT10; +#define FOODOBJECT10__STATIC 4539 +extern unsigned short FOODOBJECT11; +#define FOODOBJECT11__STATIC 4540 +extern unsigned short FOODOBJECT12; +#define FOODOBJECT12__STATIC 4541 +extern unsigned short FOODOBJECT13; +#define FOODOBJECT13__STATIC 4542 +extern unsigned short FOODOBJECT14; +#define FOODOBJECT14__STATIC 4543 +extern unsigned short FOODOBJECT15; +#define FOODOBJECT15__STATIC 4544 +extern unsigned short FOODOBJECT16; +#define FOODOBJECT16__STATIC 4545 +extern unsigned short FOODOBJECT17; +#define FOODOBJECT17__STATIC 4546 +extern unsigned short FOODOBJECT18; +#define FOODOBJECT18__STATIC 4547 +extern unsigned short FOODOBJECT19; +#define FOODOBJECT19__STATIC 4548 +extern unsigned short FOODOBJECT20; +#define FOODOBJECT20__STATIC 4549 +extern unsigned short HEADLAMP; +#define HEADLAMP__STATIC 4550 +extern unsigned short TAMPON; +#define TAMPON__STATIC 4557 +extern unsigned short SKINNEDCHICKEN; +#define SKINNEDCHICKEN__STATIC 4554 +extern unsigned short FEATHEREDCHICKEN; +#define FEATHEREDCHICKEN__STATIC 4555 +extern unsigned short ROBOTDOG2; +#define ROBOTDOG2__STATIC 4560 +extern unsigned short JOLLYMEAL; +#define JOLLYMEAL__STATIC 4569 +extern unsigned short DUKEBURGER; +#define DUKEBURGER__STATIC 4570 +extern unsigned short SHOPPINGCART; +#define SHOPPINGCART__STATIC 4576 +extern unsigned short CANWITHSOMETHING2; +#define CANWITHSOMETHING2__STATIC 4580 +extern unsigned short CANWITHSOMETHING3; +#define CANWITHSOMETHING3__STATIC 4581 +extern unsigned short CANWITHSOMETHING4; +#define CANWITHSOMETHING4__STATIC 4582 +extern unsigned short SNAKEP; +#define SNAKEP__STATIC 4590 +extern unsigned short DOLPHIN1; +#define DOLPHIN1__STATIC 4591 +extern unsigned short DOLPHIN2; +#define DOLPHIN2__STATIC 4592 +extern unsigned short NEWBEAST; +#define NEWBEAST__STATIC 4610 +extern unsigned short NEWBEASTSTAYPUT; +#define NEWBEASTSTAYPUT__STATIC 4611 +extern unsigned short NEWBEASTJUMP; +#define NEWBEASTJUMP__STATIC 4690 +extern unsigned short NEWBEASTHANG; +#define NEWBEASTHANG__STATIC 4670 +extern unsigned short NEWBEASTHANGDEAD; +#define NEWBEASTHANGDEAD__STATIC 4671 +extern unsigned short BOSS4; +#define BOSS4__STATIC 4740 +extern unsigned short BOSS4STAYPUT; +#define BOSS4STAYPUT__STATIC 4741 +extern unsigned short FEM10; +#define FEM10__STATIC 4864 +extern unsigned short TOUGHGAL; +#define TOUGHGAL__STATIC 4866 +extern unsigned short MAN; +#define MAN__STATIC 4871 +extern unsigned short MAN2; +#define MAN2__STATIC 4872 +extern unsigned short WOMAN; +#define WOMAN__STATIC 4874 +extern unsigned short PLEASEWAIT; +#define PLEASEWAIT__STATIC 4887 +extern unsigned short NATURALLIGHTNING; +#define NATURALLIGHTNING__STATIC 4890 +extern unsigned short WEATHERWARN; +#define WEATHERWARN__STATIC 4893 +extern unsigned short DUKETAG; +#define DUKETAG__STATIC 4900 +extern unsigned short SIGN1; +#define SIGN1__STATIC 4909 +extern unsigned short SIGN2; +#define SIGN2__STATIC 4912 +extern unsigned short JURYGUY; +#define JURYGUY__STATIC 4943 +extern unsigned short RESERVEDSLOT1; +#define RESERVEDSLOT1__STATIC 6132 +extern unsigned short RESERVEDSLOT2; +#define RESERVEDSLOT2__STATIC 6133 +extern unsigned short RESERVEDSLOT3; +#define RESERVEDSLOT3__STATIC 6134 +extern unsigned short RESERVEDSLOT4; +#define RESERVEDSLOT4__STATIC 6135 +extern unsigned short RESERVEDSLOT5; +#define RESERVEDSLOT5__STATIC 6136 +extern unsigned short RESERVEDSLOT6; +#define RESERVEDSLOT6__STATIC 6137 +extern unsigned short RESERVEDSLOT7; +#define RESERVEDSLOT7__STATIC 6138 +extern unsigned short RESERVEDSLOT8; +#define RESERVEDSLOT8__STATIC 6139 +extern unsigned short RESERVEDSLOT9; +#define RESERVEDSLOT9__STATIC 6140 +extern unsigned short RESERVEDSLOT10; +#define RESERVEDSLOT10__STATIC 6141 +extern unsigned short RESERVEDSLOT11; +#define RESERVEDSLOT11__STATIC 6142 +extern unsigned short RESERVEDSLOT12; +#define RESERVEDSLOT12__STATIC 6143 +extern unsigned short dynamictostatic[MAXTILES]; diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c new file mode 100644 index 000000000..f871aaf46 --- /dev/null +++ b/polymer/eduke32/source/osdcmds.c @@ -0,0 +1,654 @@ +//------------------------------------------------------------------------- +/* +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "osdcmds.h" +#include "osd.h" +#include "baselayer.h" +#include "duke3d.h" +#include "crc32.h" + +#include + +struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat; + +int osdcmd_quit(const osdfuncparm_t *parm) +{ + extern long quittimer; + parm=parm; + if( gamequit == 0 && ( numplayers > 1 ) ) + { + if(ps[myconnectindex].gm&MODE_GAME) + { + gamequit = 1; + quittimer = totalclock+120; + } + else + { + sendlogoff(); + gameexit(" "); + } + } + else if( numplayers < 2 ) + gameexit(" "); + + return OSDCMD_OK; +} + +int osdcmd_echo(const osdfuncparm_t *parm) +{ + int i; + for (i = 0; i < parm->numparms; i++) { + if (i > 0) OSD_Printf(" "); + OSD_Printf("%s", parm->parms[i]); + } + OSD_Printf("\n"); + + return OSDCMD_OK; +} + +int osdcmd_changelevel(const osdfuncparm_t *parm) +{ + int volume=0,level,i; + char *p; + + if (!VOLUMEONE) { + if (parm->numparms != 2) return OSDCMD_SHOWHELP; + + volume = strtol(parm->parms[0], &p, 10) - 1; + if (p[0]) return OSDCMD_SHOWHELP; + level = strtol(parm->parms[1], &p, 10) - 1; + if (p[0]) return OSDCMD_SHOWHELP; + } else { + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + + level = strtol(parm->parms[0], &p, 10) - 1; + if (p[0]) return OSDCMD_SHOWHELP; + } + + if (volume < 0) return OSDCMD_SHOWHELP; + if (level < 0) return OSDCMD_SHOWHELP; + + if (!VOLUMEONE) { + if (volume > num_volumes) { + OSD_Printf("changelevel: invalid volume number (range 1-%ld)\n",num_volumes); + return OSDCMD_OK; + } + } + + if (volume == 0) { + if (level > 5) { + OSD_Printf("changelevel: invalid volume 1 level number (range 1-6)\n"); + return OSDCMD_OK; + } + } else { + if (level > 10) { + OSD_Printf("changelevel: invalid volume 2+ level number (range 1-11)\n"); + return OSDCMD_SHOWHELP; + } + } + + if (ps[myconnectindex].gm & MODE_GAME) { + // in-game behave like a cheat + osdcmd_cheatsinfo_stat.cheatnum = 2; + osdcmd_cheatsinfo_stat.volume = volume; + osdcmd_cheatsinfo_stat.level = level; + } else { + // out-of-game behave like a menu command + osdcmd_cheatsinfo_stat.cheatnum = -1; + + ud.m_volume_number = volume; + ud.m_level_number = level; + + ud.m_monsters_off = ud.monsters_off = 0; + + ud.m_respawn_items = 0; + ud.m_respawn_inventory = 0; + + ud.multimode = 1; + + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + if (enterlevel(MODE_GAME)) backtomenu(); + } + + return OSDCMD_OK; +} + +int osdcmd_map(const osdfuncparm_t *parm) +{ + int i; + char filename[256]; + + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + + strcpy(filename,parm->parms[0]); + if( strchr(filename,'.') == 0) + strcat(filename,".map"); + + if ((i = kopen4load(filename,0)) < 0) { + OSD_Printf("map: file \"%s\" not found.\n", filename); + return OSDCMD_OK; + } + kclose(i); + + strcpy(boardfilename, filename); + + if (ps[myconnectindex].gm & MODE_GAME) { + // in-game behave like a cheat + osdcmd_cheatsinfo_stat.cheatnum = 2; + osdcmd_cheatsinfo_stat.volume = 0; + osdcmd_cheatsinfo_stat.level = 7; + } else { + // out-of-game behave like a menu command + osdcmd_cheatsinfo_stat.cheatnum = -1; + + ud.m_volume_number = 0; + ud.m_level_number = 7; + + ud.m_monsters_off = ud.monsters_off = 0; + + ud.m_respawn_items = 0; + ud.m_respawn_inventory = 0; + + ud.multimode = 1; + + newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + if (enterlevel(MODE_GAME)) backtomenu(); + } + + return OSDCMD_OK; +} + +int osdcmd_god(const osdfuncparm_t *parm) +{ + parm=parm; + if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME) { + osdcmd_cheatsinfo_stat.cheatnum = 0; + } else { + OSD_Printf("god: Not in a single-player game.\n"); + } + + return OSDCMD_OK; +} + +int osdcmd_noclip(const osdfuncparm_t *parm) +{ + parm=parm; + if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME) { + osdcmd_cheatsinfo_stat.cheatnum = 20; + } else { + OSD_Printf("noclip: Not in a single-player game.\n"); + } + + return OSDCMD_OK; +} + +int osdcmd_fileinfo(const osdfuncparm_t *parm) +{ + unsigned long crc, length; + int i,j; + char buf[256]; + + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + + if ((i = kopen4load((char *)parm->parms[0],0)) < 0) { + OSD_Printf("fileinfo: File \"%s\" not found.\n", parm->parms[0]); + return OSDCMD_OK; + } + + length = kfilelength(i); + + crc32init(&crc); + do { + j = kread(i,buf,256); + crc32block(&crc,buf,j); + } while (j == 256); + crc32finish(&crc); + + kclose(i); + + OSD_Printf("fileinfo: %s\n" + " File size: %d\n" + " CRC-32: %08X\n", + parm->parms[0], length, crc); + + return OSDCMD_OK; +} + +static int osdcmd_restartvid(const osdfuncparm_t *parm) +{ + extern long qsetmode; + + resetvideomode(); + if (setgamemode(ScreenMode,ScreenWidth,ScreenHeight,ScreenBPP)) + gameexit("restartvid: Reset failed...\n"); + onvideomodechange(ScreenBPP>8); + vscrn(); + + return OSDCMD_OK; +} + +static int osdcmd_vidmode(const osdfuncparm_t *parm) +{ + int newbpp = ScreenBPP, newwidth = ScreenWidth, + newheight = ScreenHeight, newfs = ScreenMode; + if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP; + + switch (parm->numparms) { + case 1: // bpp switch + newbpp = Batol(parm->parms[0]); + break; + case 2: // res switch + newwidth = Batol(parm->parms[0]); + newheight = Batol(parm->parms[1]); + break; + case 3: // res & bpp switch + case 4: + newwidth = Batol(parm->parms[0]); + newheight = Batol(parm->parms[1]); + newbpp = Batol(parm->parms[2]); + if (parm->numparms == 4) + newfs = (Batol(parm->parms[3]) != 0); + break; + } + + if (setgamemode(newfs,newwidth,newheight,newbpp)) { + initprintf("vidmode: Mode change failed!\n"); + if (setgamemode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP)) + gameexit("vidmode: Reset failed!\n"); + } + ScreenBPP = newbpp; ScreenWidth = newwidth; ScreenHeight = newheight; + ScreenMode = newfs; + onvideomodechange(ScreenBPP>8); + vscrn(); + return OSDCMD_OK; +} + +static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm) +{ + if (parm->numparms == 0) { + OSD_Printf("setstatusbarscale: scale is %d%%\n", ud.statusbarscale); + return OSDCMD_OK; + } else if (parm->numparms != 1) return OSDCMD_SHOWHELP; + + setstatusbarscale(Batol(parm->parms[0])); + OSD_Printf("setstatusbarscale: new scale is %d%%\n", ud.statusbarscale); + return OSDCMD_OK; +} + +static int osdcmd_spawn(const osdfuncparm_t *parm) +{ + long x=0,y=0,z=0; + unsigned short cstat=0,picnum=0; + unsigned char pal=0; + short ang=0; + short set=0, idx; + + if (numplayers > 1 || !(ps[myconnectindex].gm & MODE_GAME)) { + OSD_Printf("spawn: Can't spawn sprites in multiplayer games or demos\n"); + return OSDCMD_OK; + } + + switch (parm->numparms) { + case 7: // x,y,z + x = Batol(parm->parms[4]); + y = Batol(parm->parms[5]); + z = Batol(parm->parms[6]); + set |= 8; + case 4: // ang + ang = Batol(parm->parms[3]) & 2047; set |= 4; + case 3: // cstat + cstat = (unsigned short)Batol(parm->parms[2]); set |= 2; + case 2: // pal + pal = (unsigned char)Batol(parm->parms[1]); set |= 1; + case 1: // tile number + if (isdigit(parm->parms[0][0])) { + picnum = (unsigned short)Batol(parm->parms[0]); + } else { + int i,j; + for (j=0; j<2; j++) { + for (i=0; iparms[0])) || + (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0])) + ) { + picnum = (unsigned short)labelcode[i]; + break; + } + } + if (i= MAXTILES) { + OSD_Printf("spawn: Invalid tile number\n"); + return OSDCMD_OK; + } + break; + default: + return OSDCMD_SHOWHELP; + } + + idx = spawn(ps[myconnectindex].i, (short)picnum); + if (set & 1) sprite[idx].pal = (char)pal; + if (set & 2) sprite[idx].cstat = (short)cstat; + if (set & 4) sprite[idx].ang = ang; + if (set & 8) { + if (setsprite(idx, x,y,z) < 0) { + OSD_Printf("spawn: Sprite can't be spawned into null space\n"); + deletesprite(idx); + } + } + + return OSDCMD_OK; +} + +int osdcmd_setvar(const osdfuncparm_t *parm) +{ + int i, varval; + char varname[256]; + + if (parm->numparms != 2) return OSDCMD_SHOWHELP; + + if (ud.multimode != 1) + { + OSD_Printf("Command not allowed in multiplayer\n"); + return OSDCMD_OK; + } + + strcpy(varname,parm->parms[0]); + varval = Batol(parm->parms[1]); + + for(i=0;inumparms != 1) return OSDCMD_SHOWHELP; + parm=parm; + if (numplayers > 1) { + OSD_Printf("cmenu: disallowed in multiplayer\n"); + return OSDCMD_OK; + } else { + cmenu(Batol(parm->parms[0])); + } + + return OSDCMD_OK; +} + +int osdcmd_exec(const osdfuncparm_t *parm) +{ + char fn[BMAX_PATH]; + extern int load_script(char *szStartupScript); + + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + Bstrcpy(fn,parm->parms[0]); + + if (load_script(fn)) { + OSD_Printf("exec: file \"%s\" not found.\n", fn); + return OSDCMD_OK; + } + return OSDCMD_OK; +} + +/* +static int osdcmd_vars(const osdfuncparm_t *parm) +{ + int showval = (parm->numparms < 1); + + if (!Bstrcasecmp(parm->name, "myname")) { + if (showval) { OSD_Printf("Your name is \"%s\"\n", myname); } + else { + Bstrncpy(myname, parm->parms[0], sizeof(myname)-1); + myname[sizeof(myname)-1] = 0; + // XXX: now send the update over the wire + } + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "showcoords")) { + if (showval) { OSD_Printf("showcoords is %d\n", ud.coords); } + else ud.coords = (atoi(parm->parms[0]) != 0); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "useprecache")) { + if (showval) { OSD_Printf("useprecache is %d\n", useprecache); } + else useprecache = (atoi(parm->parms[0]) != 0); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->name, "drawweapon")) { + if (showval) { OSD_Printf("drawweapon is %d\n", ud.drawweapon); } + else ud.drawweapon = (atoi(parm->parms[0]) != 0); + return OSDCMD_OK; + } + return OSDCMD_SHOWHELP; +} +*/ +enum cvartypes { + CVAR_INT, + CVAR_UNSIGNEDINT, + CVAR_BOOL, + CVAR_STRING +}; + +struct cvarmappings { + char *name; + char *helpstr; + void *var; + int type; // 0 = integer, 1 = unsigned integer, 2 = boolean, 3 = string, |128 = not in multiplayer + int extra; // for string, is the length +} cvar[] = + { + { "showfps", "showfps: show the frame rate counter", (void*)&ud.tickrate, CVAR_BOOL, 0 }, + { "showcoords", "showcoords: show your position in the game world", (void*)&ud.coords, CVAR_BOOL, 0 }, + { "useprecache", "useprecache: enable/disable the pre-level caching routine", (void*)&useprecache, CVAR_BOOL, 0 }, + { "drawweapon", "drawweapon: enable/disable weapon drawing", (void*)&ud.drawweapon, CVAR_BOOL, 0 }, + { "name", "name: change your multiplayer nickname", (void*)&myname[0], CVAR_STRING, sizeof(myname) } + }; + +int osdcmd_cvar_set(const osdfuncparm_t *parm) +{ + int showval = (parm->numparms == 0); + unsigned int i; + + for (i = 0; i < sizeof(cvar)/sizeof(struct cvarmappings); i++) { + if (!Bstrcasecmp(parm->name, cvar[i].name)) { + if ((cvar[i].type & 0x80) && ud.multimode != 1) { + // sound the alarm + OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvar[i].name); + return OSDCMD_OK; + } else + switch (cvar[i].type&0x7f) { + case CVAR_INT: + case CVAR_UNSIGNEDINT: + case CVAR_BOOL: + { + int val; + if (showval) { + OSD_Printf("%s %d\n",cvar[i].name,*(int*)cvar[i].var); + return OSDCMD_OK; + } + + val = atoi(parm->parms[0]); + if (cvar[i].type == CVAR_BOOL) val = val != 0; + *(int*)cvar[i].var = val; + } break; + case CVAR_STRING: + { + if (showval) { + OSD_Printf("%s \"%s\"\n",cvar[i].name,(char*)cvar[i].var); + return OSDCMD_OK; + } + else { + Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1); + ((char*)cvar[i].var)[cvar[i].extra-1] = 0; + // XXX: now send the update over the wire + } + } break; + default: break; + } + } + } + OSD_Printf("\n"); + return OSDCMD_OK; +} + +int osdcmd_sensitivity(const osdfuncparm_t *parm) +{ + if (parm->numparms != 1) { + OSD_Printf("sensitivity %d\n",CONTROL_GetMouseSensitivity()>>10); + return OSDCMD_OK; + } + CONTROL_SetMouseSensitivity(atoi(parm->parms[0])<<10); + OSD_Printf("\n"); + return OSDCMD_OK; +} + +int osdcmd_gamma(const osdfuncparm_t *parm) +{ + if (parm->numparms != 1) { + OSD_Printf("gamma %d\n",ud.brightness>>2); + return OSDCMD_OK; + } + ud.brightness = atoi(parm->parms[0])<<2; + setbrightness(ud.brightness>>2,&ps[screenpeek].palette[0],0); + OSD_Printf("\n"); + return OSDCMD_OK; +} + +int osdcmd_give(const osdfuncparm_t *parm) +{ + int i; + + if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME) { + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + if (!Bstrcasecmp(parm->parms[0], "all")) { + osdcmd_cheatsinfo_stat.cheatnum = 1; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "health")) { + sprite[ps[myconnectindex].i].extra = 200; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "weapons")) { + osdcmd_cheatsinfo_stat.cheatnum = 21; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "ammo")) { + for (i=PISTOL_WEAPON;iparms[0], "armor")) { + ps[myconnectindex].shield_amount = 100; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "keys")) { + osdcmd_cheatsinfo_stat.cheatnum = 23; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "inventory")) { + osdcmd_cheatsinfo_stat.cheatnum = 22; + return OSDCMD_OK; + } + } else { + OSD_Printf("give: Not in a single-player game.\n"); + return OSDCMD_OK; + } + return OSDCMD_SHOWHELP; +} + +void onvideomodechange(int newmode) +{ + char *pal; + + if (newmode) { + if (ps[screenpeek].palette == palette || + ps[screenpeek].palette == waterpal || + ps[screenpeek].palette == slimepal) + pal = palette; + else + pal = ps[screenpeek].palette; + } else { + pal = ps[screenpeek].palette; + } + + setbrightness(ud.brightness>>2, pal, 0); + restorepalette = 1; +} + +int registerosdcommands(void) +{ + unsigned int i; + + osdcmd_cheatsinfo_stat.cheatnum = -1; + + for (i=0; i: warps to the given level", osdcmd_changelevel); + } else { + OSD_RegisterFunction("changelevel","changelevel : warps to the given level", osdcmd_changelevel); + OSD_RegisterFunction("map","map : loads the given user map", osdcmd_map); + } + OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu); + OSD_RegisterFunction("exec","exec : executes a script", osdcmd_exec); + OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); + OSD_RegisterFunction("gamma","gamma : changes brightness", osdcmd_gamma); + OSD_RegisterFunction("give","give : gives requested item", osdcmd_give); + OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip); + + OSD_RegisterFunction("setstatusbarscale","setstatusbarscale : changes the status bar scale", osdcmd_setstatusbarscale); + OSD_RegisterFunction("sensitivity","sensitivity : changes the mouse sensitivity", osdcmd_sensitivity); + OSD_RegisterFunction("spawn","spawn [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn); + OSD_RegisterFunction("setvar","setvar : sets the value of a gamevar", osdcmd_setvar); + + OSD_RegisterFunction("fileinfo","fileinfo : gets a file's information", osdcmd_fileinfo); + OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit); + + /* OSD_RegisterFunction("myname","myname: change your multiplayer nickname", osdcmd_vars); + OSD_RegisterFunction("showfps","showfps: show the frame rate counter", osdcmd_vars); + OSD_RegisterFunction("showcoords","showcoords: show your position in the game world", osdcmd_vars); + OSD_RegisterFunction("useprecache","useprecache: enable/disable the pre-level caching routine", osdcmd_vars); + OSD_RegisterFunction("drawweapon","drawweapon: enable/disable weapon drawing", osdcmd_vars); */ + + OSD_RegisterFunction("restartvid","restartvid: reinitialised the video mode",osdcmd_restartvid); + OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: immediately change the video mode",osdcmd_vidmode); + + //baselayer_onvideomodechange = onvideomodechange; + + return 0; +} + diff --git a/polymer/eduke32/source/osdcmds.h b/polymer/eduke32/source/osdcmds.h new file mode 100644 index 000000000..d0c77b7b7 --- /dev/null +++ b/polymer/eduke32/source/osdcmds.h @@ -0,0 +1,14 @@ +#ifndef __osdcmds_h__ +#define __osdcmds_h__ + +struct osdcmd_cheatsinfo { + int cheatnum; // -1 = none, else = see cheats() + int volume,level; +}; + +extern struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat; + +int registerosdcommands(void); + +#endif // __osdcmds_h__ + diff --git a/polymer/eduke32/source/osdfuncs.c b/polymer/eduke32/source/osdfuncs.c new file mode 100644 index 000000000..0e2dfce1d --- /dev/null +++ b/polymer/eduke32/source/osdfuncs.c @@ -0,0 +1,90 @@ +#include "duke3d.h" +#include "build.h" +#include "namesdyn.h" + +void GAME_drawosdchar(int x, int y, char ch, int shade, int pal) +{ + short ac; + + if (ch == 32) return; + ac = ch-'!'+STARTALPHANUM; + if (ac < STARTALPHANUM || ac > ENDALPHANUM) return; + + rotatesprite(((x<<3)+x)<<16, (y<<3)<<16, 65536l, 0, ac, shade, pal, 8|16, 0, 0, xdim-1, ydim-1); +} + +void GAME_drawosdstr(int x, int y, char *ch, int len, int shade, int pal) +{ + short ac; + + for (x = (x<<3)+x; len>0; len--, ch++, x++) { + if (*ch == 32) { x+=5; continue; } + ac = *ch-'!'+STARTALPHANUM; + if (ac < STARTALPHANUM || ac > ENDALPHANUM) return; + + rotatesprite(x<<16, (y<<3)<<16, 65536l, 0, ac, shade, pal, 8|16, 0, 0, xdim-1, ydim-1); + if (*ch >= '0' && *ch <= '9') x+=8; + else x += tilesizx[ac]; + } +} + +void GAME_drawosdcursor(int x, int y, int type, int lastkeypress) +{ + short ac; + + if (type) ac = SMALLFNTCURSOR; + else ac = '_'-'!'+STARTALPHANUM; + + if (!((GetTime()-lastkeypress) & 0x40l)) + rotatesprite(((x<<3)+x)<<16, ((y<<3)+(type?-1:2))<<16, 65536l, 0, ac, 0, 8, 8|16, 0, 0, xdim-1, ydim-1); +} + +int GAME_getcolumnwidth(int w) +{ + return w/9; +} + +int GAME_getrowheight(int w) +{ + return w>>3; +} + +void GAME_onshowosd(int shown) +{ + if (numplayers == 1) + if ((shown && !ud.pause_on) || (!shown && ud.pause_on)) + KB_KeyDown[sc_Pause] = 1; +} + +//#define BGTILE 311 +//#define BGTILE 1156 +#define BGTILE 1141 // BIGHOLE +#define BORDTILE 3250 // VIEWBORDER +#define BITSTH 1+32+8+16 // high translucency +#define BITSTL 1+8+16 // low translucency +#define BITS 8+16+64 // solid +#define SHADE 16 +#define PALETTE 4 +void GAME_clearbackground(int c, int r) +{ + long x, y, xsiz, ysiz, tx2, ty2; + long daydim, bits; + + if (getrendermode() < 3) bits = BITS; else bits = BITSTL; + + daydim = r<<3; + + xsiz = tilesizx[BGTILE]; tx2 = xdim/xsiz; + ysiz = tilesizy[BGTILE]; ty2 = daydim/ysiz; + + for(x=0;x<=tx2;x++) + for(y=0;y<=ty2;y++) + rotatesprite(x*xsiz<<16,y*ysiz<<16,65536L,0,BGTILE,SHADE,PALETTE,bits,0,0,xdim,daydim); + + xsiz = tilesizy[BORDTILE]; tx2 = xdim/xsiz; + ysiz = tilesizx[BORDTILE]; + + for(x=0;x<=tx2;x++) + rotatesprite(x*xsiz<<16,(daydim+ysiz+1)<<16,65536L,1536,BORDTILE,SHADE-12,PALETTE,BITS,0,0,xdim,daydim+ysiz+1); +} + diff --git a/polymer/eduke32/source/osdfuncs.h b/polymer/eduke32/source/osdfuncs.h new file mode 100644 index 000000000..4f1ddaac1 --- /dev/null +++ b/polymer/eduke32/source/osdfuncs.h @@ -0,0 +1,8 @@ +void GAME_drawosdchar(int x, int y, char ch, int shade, int pal); +void GAME_drawosdstr(int x, int y, char *ch, int len, int shade, int pal); +void GAME_drawosdcursor(int x, int y, int type, int lastkeypress); +int GAME_getcolumnwidth(int w); +int GAME_getrowheight(int w); +void GAME_clearbackground(int c, int r); +void GAME_onshowosd(int shown); + diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c new file mode 100644 index 000000000..dec88ea52 --- /dev/null +++ b/polymer/eduke32/source/player.c @@ -0,0 +1,5807 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +// Savage Baggage Masters + +#include "duke3d.h" + +long g_currentweapon; +long g_gun_pos; +long g_looking_arc; +long g_weapon_offset; +long g_gs; +long g_kb; +long g_looking_angSR1; +long g_weapon_xoffset; + +int32 turnheldtime; //MED +int32 lastcontroltime; //MED + +void setpal(struct player_struct *p) +{ + if(p->heat_on) p->palette = slimepal; + else if ((sector[p->cursectnum].ceilingpicnum >= FLOORSLIME)&&(sector[p->cursectnum].ceilingpicnum <=FLOORSLIME+2)) { + p->palette = slimepal; + } else { + if(sector[p->cursectnum].lotag == 2) p->palette = waterpal; + else p->palette = palette; + + } + restorepalette = 1; +} + +void fadepal(int r, int g, int b, int start, int end, int step) +{ + if (getrendermode() >= 3) return; + if (step > 0) for (; start < end; start += step) palto(r,g,b,start); + else for (; start >= end; start += step) palto(r,g,b,start); +} + +void incur_damage(short snum) +{ + long damage = 0L, shield_damage = 0L; + short i; + + struct player_struct *p; + + p = &ps[snum]; + + SetGameVarID(g_iReturnVarID,0,p->i,snum); + OnEvent(EVENT_INCURDAMAGE, p->i, snum, -1); + + if(GetGameVarID(g_iReturnVarID,p->i,snum) == 0) + + { + sprite[p->i].extra -= p->extra_extra8>>8; + + damage = sprite[p->i].extra - p->last_extra; + + if ( damage < 0 ) + { + p->extra_extra8 = 0; + + if ( p->shield_amount > 0 ) + { + shield_damage = damage * (20 + (TRAND%30)) / 100; + damage -= shield_damage; + + p->shield_amount += shield_damage; + + if ( p->shield_amount < 0 ) + { + damage += p->shield_amount; + p->shield_amount = 0; + } + } + + sprite[p->i].extra = p->last_extra + damage; + } + + } + +} + +void quickkill(struct player_struct *p) +{ + p->pals[0] = 48; + p->pals[1] = 48; + p->pals[2] = 48; + p->pals_time = 48; + + sprite[p->i].extra = 0; + sprite[p->i].cstat |= 32768; + if(ud.god == 0) guts(&sprite[p->i],JIBS6,8,myconnectindex); + return; +} + +void forceplayerangle(struct player_struct *p) +{ + short n; + + n = 128-(TRAND&255); + + p->horiz += 64; + p->return_to_center = 9; + p->look_ang = n>>1; + p->rotscrnang = n>>1; +} + +void tracers(long x1,long y1,long z1,long x2,long y2,long z2,long n) +{ + long i, xv, yv, zv; + short sect = -1; + + i = n+1; + xv = (x2-x1)/i; + yv = (y2-y1)/i; + zv = (z2-z1)/i; + + if( ( klabs(x1-x2)+klabs(y1-y2) ) < 3084 ) + return; + + for(i=n;i>0;i--) + { + x1 += xv; + y1 += yv; + z1 += zv; + updatesector(x1,y1,§); + if(sect >= 0) + { + if(sector[sect].lotag == 2) + EGS(sect,x1,y1,z1,WATERBUBBLE,-32,4+(TRAND&3),4+(TRAND&3),TRAND&2047,0,0,ps[0].i,5); + else + EGS(sect,x1,y1,z1,SMALLSMOKE,-32,14,14,0,0,0,ps[0].i,5); + } + } +} + +void hitscantrail(long x1, long y1, long z1, long x2, long y2, long z2, short ang, short atwith) +{ + long xv, yv, zv, n, j, i; + short sect = -1; + + /* mathematical bullshit */ + + x1 += (sintable[(348+ang+512)&2047]/projectile[atwith].offset); + y1 += (sintable[(ang+348)&2047]/projectile[atwith].offset); + + /* find the distance between our player's projectile firing position and the impact point */ + + n = (FindDistance2D(x1-x2,y1-y2))/256; + + /* apply an offset if needed, defined in CONs */ + + z1 += (projectile[atwith].toffset<<8)+1024; + + /* figure out how much distance to put between each sprite */ + + xv = (x2-x1)/n; + yv = (y2-y1)/n; + zv = (z2-z1)/n; + + // Bsprintf(tempbuf,"%ld, %ld, %ld (%ld)",xv,yv,zv,n); + // AddLog(tempbuf); + + x1 += xv/4; + y1 += yv/4; + z1 += zv/4; + + /* spawn the trail sprites */ + + for(i=0;i= 0) + { + j = EGS(sect,x1,y1,z1,projectile[atwith].trail,-32,projectile[atwith].txrepeat,projectile[atwith].tyrepeat,ang,0,0,ps[0].i,0); + changespritestat(j,1); + } + else continue; + } +} + +long hits(short i) +{ + long sx,sy,sz; + short sect,hw,hs; + long zoff; + + if(PN == APLAYER) zoff = (40<<8); + else zoff = 0; + + hitscan(SX,SY,SZ-zoff,SECT, + sintable[(SA+512)&2047], + sintable[SA&2047], + 0,§,&hw,&hs,&sx,&sy,&sz,CLIPMASK1); + + return ( FindDistance2D( sx-SX,sy-SY ) ); +} + +long hitasprite(short i,short *hitsp) +{ + long sx,sy,sz,zoff; + short sect,hw; + + if(badguy(&sprite[i]) ) + zoff = (42<<8); + else if(PN == APLAYER) zoff = (39<<8); + else zoff = 0; + + hitscan(SX,SY,SZ-zoff,SECT, + sintable[(SA+512)&2047], + sintable[SA&2047], + 0,§,&hw,hitsp,&sx,&sy,&sz,CLIPMASK1); + + if(hw >= 0 && (wall[hw].cstat&16) && badguy(&sprite[i]) ) + return((1<<30)); + + return ( FindDistance2D(sx-SX,sy-SY) ); +} + +/* +long hitaspriteandwall(short i,short *hitsp,short *hitw,short *x, short *y) +{ + long sz; + short sect; + + hitscan(SX,SY,SZ,SECT, + sintable[(SA+512)&2047], + sintable[SA&2047], + 0,§,hitw,hitsp,x,y,&sz,CLIPMASK1); + + return ( FindDistance2D(*x-SX,*y-SY) ); +} +*/ + +long hitawall(struct player_struct *p,short *hitw) +{ + long sx,sy,sz; + short sect,hs; + + hitscan(p->posx,p->posy,p->posz,p->cursectnum, + sintable[(p->ang+512)&2047], + sintable[p->ang&2047], + 0,§,hitw,&hs,&sx,&sy,&sz,CLIPMASK0); + + return ( FindDistance2D(sx-p->posx,sy-p->posy) ); +} + +short aim(spritetype *s,short aang) +{ + char gotshrinker,gotfreezer; + short i, j, a, k, cans; + short aimstats[] = {10,13,1,2}; + long dx1, dy1, dx2, dy2, dx3, dy3, smax, sdist; + long xv, yv; + + a = s->ang; + + j = -1; + if(s->picnum == APLAYER && !ps[s->yvel].auto_aim) return -1; + + gotshrinker = s->picnum == APLAYER && *aplWeaponWorksLike[ps[s->yvel].curr_weapon] == SHRINKER_WEAPON; + gotfreezer = s->picnum == APLAYER && *aplWeaponWorksLike[ps[s->yvel].curr_weapon] == FREEZE_WEAPON; + + smax = 0x7fffffff; + + dx1 = sintable[(a+512-aang)&2047]; + dy1 = sintable[(a-aang)&2047]; + dx2 = sintable[(a+512+aang)&2047]; + dy2 = sintable[(a+aang)&2047]; + + dx3 = sintable[(a+512)&2047]; + dy3 = sintable[a&2047]; + + for(k=0;k<4;k++) + { + if( j >= 0 ) + break; + for(i=headspritestat[aimstats[k]];i >= 0;i=nextspritestat[i]) + if( sprite[i].xrepeat > 0 && sprite[i].extra >= 0 && (sprite[i].cstat&(257+32768)) == 257) + if( badguy(&sprite[i]) || k < 2 ) + { + if(badguy(&sprite[i]) || PN == APLAYER || PN == SHARK) + { + if( PN == APLAYER && + // ud.ffire == 0 && + (gametype_flags[ud.coop]& GAMETYPE_FLAG_PLAYERSFRIENDLY ) && + s->picnum == APLAYER && + s != &sprite[i]) + continue; + + if(gotshrinker && sprite[i].xrepeat < 30 ) + { + if (PN == SHARK) { + if(sprite[i].xrepeat < 20) continue; + continue; + } else if ((PN >= GREENSLIME)&&(PN <= GREENSLIME+7)) { + } else { + continue; + } + } + if(gotfreezer && sprite[i].pal == 1) continue; + } + + xv = (SX-s->x); + yv = (SY-s->y); + + if( (dy1*xv) <= (dx1*yv) ) + if( ( dy2*xv ) >= (dx2*yv) ) + { + sdist = mulscale(dx3,xv,14) + mulscale(dy3,yv,14); + if( sdist > 512 && sdist < smax ) + { + if(s->picnum == APLAYER) + a = (klabs(scale(SZ-s->z,10,sdist)-(ps[s->yvel].horiz+ps[s->yvel].horizoff-100)) < 100); + else a = 1; + + if(PN == ORGANTIC || PN == ROTATEGUN ) + cans = cansee(SX,SY,SZ,SECT,s->x,s->y,s->z-(32<<8),s->sectnum); + else cans = cansee(SX,SY,SZ-(32<<8),SECT,s->x,s->y,s->z-(32<<8),s->sectnum); + + if( a && cans ) + { + smax = sdist; + j = i; + } + } + } + } + } + + return j; +} + +short shoot(short i,short atwith) +{ + short sect, hitsect, hitspr, hitwall, l, sa, p, j, k, wh, scount; + long sx, sy, sz, vel, zvel, hitx, hity, hitz, x, oldzvel, dal; + unsigned char sizx,sizy; + spritetype *s; + + s = &sprite[i]; + sect = s->sectnum; + zvel = 0; + + if( s->picnum == APLAYER ) + { + p = s->yvel; + + sx = ps[p].posx; + sy = ps[p].posy; + sz = ps[p].posz+ps[p].pyoff+(4<<8); + sa = ps[p].ang; + + ps[p].crack_time = 777; + } + else + { + p = -1; + sa = s->ang; + sx = s->x; + sy = s->y; + sz = s->z-((s->yrepeat*tilesizy[s->picnum])<<1)+(4<<8); + if(s->picnum != ROTATEGUN) + { + sz -= (7<<8); + if(badguy(s) && PN != COMMANDER) + { + sx += (sintable[(sa+1024+96)&2047]>>7); + sy += (sintable[(sa+512+96)&2047]>>7); + } + } + } + + if(checkspriteflagsp(atwith,SPRITE_FLAG_PROJECTILE)) + { + /* Custom projectiles. This is a big hack. */ + + if (projectile[atwith].offset == 0) projectile[atwith].offset = 1; + + // writestring(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047],zvel<<6); + if(projectile[atwith].workslike & PROJECTILE_FLAG_BLOOD || projectile[atwith].workslike & PROJECTILE_FLAG_KNEE) + { + + if(projectile[atwith].workslike & PROJECTILE_FLAG_BLOOD) + { + if(p >= 0) + sa += 64 - (TRAND&127); + else sa += 1024 + 64 - (TRAND&127); + zvel = 1024-(TRAND&2047); + } + + if(projectile[atwith].workslike & PROJECTILE_FLAG_KNEE) + { + if(p >= 0) + { + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + sz += (6<<8); + sa += 15; + } + else if (!(projectile[atwith].workslike & PROJECTILE_FLAG_NOAIM)) + { + j = ps[findplayer(s,&x)].i; + zvel = ( (sprite[j].z-sz)<<8 ) / (x+1); + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + } + + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz,sect, + sintable[(sa+512)&2047], + sintable[sa&2047],zvel<<6, + &hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + + if(projectile[atwith].workslike & PROJECTILE_FLAG_BLOOD) + { + + if (projectile[atwith].range == 0) + projectile[atwith].range = 1024; + + if( FindDistance2D(sx-hitx,sy-hity) < projectile[atwith].range ) + if (FindDistance2D(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y) > (mulscale(projectile[atwith].xrepeat+8,tilesizx[projectile[atwith].decal],3))) + if( hitwall >= 0 && wall[hitwall].overpicnum != BIGFORCE ) + if( ( wall[hitwall].nextsector >= 0 && hitsect >= 0 && + sector[wall[hitwall].nextsector].lotag == 0 && + sector[hitsect].lotag == 0 && + sector[wall[hitwall].nextsector].lotag == 0 && + (sector[hitsect].floorz-sector[wall[hitwall].nextsector].floorz) > (mulscale(projectile[atwith].yrepeat,tilesizy[projectile[atwith].decal],3)<<8) ) || + ( wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0 ) ) + if( (wall[hitwall].cstat&16) == 0) + { + if(wall[hitwall].nextsector >= 0) + { + k = headspritesect[wall[hitwall].nextsector]; + while(k >= 0) + { + if(sprite[k].statnum == 3 && sprite[k].lotag == 13) + return 0; + k = nextspritesect[k]; + } + } + + if( wall[hitwall].nextwall >= 0 && + wall[wall[hitwall].nextwall].hitag != 0 ) + return 0; + + if(wall[hitwall].hitag == 0) + { + if(projectile[atwith].decal >= 0) + { + k = spawn(i,projectile[atwith].decal); + /* + sprite[k].xvel = -12; + sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, + wall[hitwall].y-wall[wall[hitwall].point2].y)+512; + sprite[k].x = hitx; + sprite[k].y = hity; + sprite[k].z = hitz; + sprite[k].cstat |= (TRAND&4); + sprite[k].xrepeat = projectile[atwith].xrepeat; + sprite[k].yrepeat = projectile[atwith].yrepeat; + sprite[k].cstat = 16+(krand()&12); + ssp(k,CLIPMASK0); + setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + insertspriteq(k); + */ + + if(!spriteflags[projectile[atwith].decal] & SPRITE_FLAG_DECAL) + spriteflags[projectile[atwith].decal] |= SPRITE_FLAG_DECAL; + + k = spawn(i,projectile[atwith].decal); + sprite[k].xvel = -1; + sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, + wall[hitwall].y-wall[wall[hitwall].point2].y)+512; + sprite[k].x = hitx; + sprite[k].y = hity; + sprite[k].z = hitz; + if(projectile[atwith].workslike & PROJECTILE_FLAG_RANDDECALSIZE) + { + wh = (TRAND&projectile[atwith].xrepeat); + if (wh < projectile[atwith].yrepeat) + wh = projectile[atwith].yrepeat; + sprite[k].xrepeat = wh; + sprite[k].yrepeat = wh; + } + else + { + sprite[k].xrepeat = projectile[atwith].xrepeat; + sprite[k].yrepeat = projectile[atwith].yrepeat; + } + sprite[k].z += sprite[k].yrepeat<<8; + // sprite[k].cstat = 16+(krand()&12); + sprite[k].cstat = 16; + + wh = (TRAND&1); + if (wh == 1) + sprite[k].cstat |= 4; + + wh = (TRAND&1); + if (wh == 1) + sprite[k].cstat |= 8; + + wh = sprite[k].sectnum; + sprite[k].shade = sector[wh].floorshade; + sprite[k].x -= mulscale13(1,sintable[(sprite[k].ang+2560)&2047]); + sprite[k].y -= mulscale13(1,sintable[(sprite[k].ang+2048)&2047]); + + ssp(k,CLIPMASK0); + insertspriteq(k); + changespritestat(k,5); + + } + // if( PN == OOZFILTER || PN == NEWBEAST ) + // sprite[k].pal = 6; + } + } + return 0; + } + + if(hitsect < 0) return 0; + + if ((projectile[atwith].range == 0) && (projectile[atwith].workslike & PROJECTILE_FLAG_KNEE)) + projectile[atwith].range = 1024; + + if( (projectile[atwith].range > 0) && (( klabs(sx-hitx)+klabs(sy-hity) ) > projectile[atwith].range) ) + return 0; + else + { + if(hitwall >= 0 || hitspr >= 0) + { + j = EGS(hitsect,hitx,hity,hitz,atwith,-15,0,0,sa,32,0,i,4); + thisprojectile[j].workslike = projectile[sprite[j].picnum].workslike; + sprite[j].extra = projectile[atwith].extra; + if(projectile[atwith].extra_rand > 0) + sprite[j].extra += (TRAND&projectile[atwith].extra_rand); + if(p >= 0) + { + if(projectile[atwith].spawns >= 0) + { + k = spawn(j,projectile[atwith].spawns); + sprite[k].z -= (8<<8); + } + if (projectile[atwith].sound > -1) spritesound(projectile[atwith].sound,j); + } + + if ( p >= 0 && ps[p].steroids_amount > 0 && ps[p].steroids_amount < 400 ) + sprite[j].extra += (max_player_health>>2); + + if( hitspr >= 0 && sprite[hitspr].picnum != ACCESSSWITCH && sprite[hitspr].picnum != ACCESSSWITCH2 ) + { + checkhitsprite(hitspr,j); + if(p >= 0) checkhitswitch(p,hitspr,1); + } + + else if( hitwall >= 0 ) + { + if( wall[hitwall].cstat&2 ) + if(wall[hitwall].nextsector >= 0) + if(hitz >= (sector[wall[hitwall].nextsector].floorz) ) + hitwall = wall[hitwall].nextwall; + + if( hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2 ) + { + checkhitwall(j,hitwall,hitx,hity,hitz,atwith); + if(p >= 0) checkhitswitch(p,hitwall,0); + } + } + } + else if(p >= 0 && zvel > 0 && sector[hitsect].lotag == 1) + { + j = spawn(ps[p].i,WATERSPLASH2); + sprite[j].x = hitx; + sprite[j].y = hity; + sprite[j].ang = ps[p].ang; // Total tweek + sprite[j].xvel = 32; + ssp(i,CLIPMASK0); + sprite[j].xvel = 0; + + } + } + return 0; + } + + + if(projectile[atwith].workslike & PROJECTILE_FLAG_BULLET) + { + + if( s->extra >= 0 ) s->shade = projectile[atwith].shade; + + if(p >= 0) + { + int angRange; + int zRange; + + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if( GetGameVarID(g_iAimAngleVarID,i,p) > 0 ) + { + j = aim( s, GetGameVarID(g_iAimAngleVarID,i,p)); + } + if(j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); + if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN) ) + { + dal -= (8<<8); + return 0; + } + zvel = ( ( sprite[j].z-sz-dal )<<8 ) / ldist(&sprite[ps[p].i], &sprite[j]) ; + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + + angRange=32; + zRange=256; + SetGameVarID(g_iAngRangeVarID,32, i,p); + SetGameVarID(g_iZRangeVarID,256,i,p); + OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + angRange=GetGameVarID(g_iAngRangeVarID,i,p); + zRange=GetGameVarID(g_iZRangeVarID,i,p); + + sa += (angRange/2)-(TRAND&(angRange-1)); + if(j == -1) + { + // no target + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + } + zvel += (zRange/2)-(TRAND&(zRange-1)); + sz -= (2<<8); + } + else + { + j = findplayer(s,&x); + sz -= (4<<8); + zvel = ( (ps[j].posz-sz) <<8 ) / (ldist(&sprite[ps[j].i], s ) ); + if(s->picnum != BOSS1) + { + zvel += 128-(TRAND&255); + sa += 32-(TRAND&63); + } + else + { + zvel += 128-(TRAND&255); + sa = getangle(ps[j].posx-sx,ps[j].posy-sy)+64-(TRAND&127); + } + } + + if (projectile[atwith].cstat >= 0) s->cstat &= ~projectile[atwith].cstat; + else s->cstat &= ~257; + + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + + + if (projectile[atwith].cstat >= 0) s->cstat |= projectile[atwith].cstat; + else s->cstat |= 257; + + if(hitsect < 0) return 0; + + if( (projectile[atwith].range > 0) && (( klabs(sx-hitx)+klabs(sy-hity) ) > projectile[atwith].range) ) return 0; + + if (projectile[atwith].trail > -1) + hitscantrail(sx,sy,sz,hitx,hity,hitz,sa,atwith); + + if (projectile[atwith].workslike & PROJECTILE_FLAG_WATERBUBBLES) + { + if( (TRAND&15) == 0 && sector[hitsect].lotag == 2 ) + tracers(hitx,hity,hitz,sx,sy,sz,8-(ud.multimode>>1)); + } + + if(p >= 0) + { + k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,10,10,sa,0,0,i,4); + sprite[k].extra = projectile[atwith].extra; + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + hittype[k].temp_data[6] = hitwall; + hittype[k].temp_data[7] = hitsect; + hittype[k].temp_data[8] = hitspr; + + if(projectile[atwith].extra_rand > 0) + sprite[k].extra += (TRAND%projectile[atwith].extra_rand); + + if( hitwall == -1 && hitspr == -1) + { + if( zvel < 0 ) + { + if( sector[hitsect].ceilingstat&1 ) + { + sprite[k].xrepeat = 0; + sprite[k].yrepeat = 0; + return 0; + } + else + checkhitceiling(hitsect); + } + if (projectile[atwith].spawns >= 0) + { + wh=spawn(k,projectile[atwith].spawns); + if (projectile[atwith].sxrepeat > 4) sprite[wh].xrepeat=projectile[atwith].sxrepeat; + if (projectile[atwith].syrepeat > 4) sprite[wh].yrepeat=projectile[atwith].syrepeat; + } + } + + if(hitspr >= 0) + { + checkhitsprite(hitspr,k); + if( sprite[hitspr].picnum == APLAYER && (!(gametype_flags[ud.coop] & GAMETYPE_FLAG_COOP) || ud.ffire == 1) ) + { + l = spawn(k,JIBS6); + sprite[k].xrepeat = sprite[k].yrepeat = 0; + sprite[l].z += (4<<8); + sprite[l].xvel = 16; + sprite[l].xrepeat = sprite[l].yrepeat = 24; + sprite[l].ang += 64-(TRAND&127); + } + else { + if (projectile[atwith].spawns >= 0) + { + wh=spawn(k,projectile[atwith].spawns); + if (projectile[atwith].sxrepeat > 4) sprite[wh].xrepeat=projectile[atwith].sxrepeat; + if (projectile[atwith].syrepeat > 4) sprite[wh].yrepeat=projectile[atwith].syrepeat; + } + } + if(p >= 0 && ( + sprite[hitspr].picnum == DIPSWITCH || + sprite[hitspr].picnum == DIPSWITCH+1 || + sprite[hitspr].picnum == DIPSWITCH2 || + sprite[hitspr].picnum == DIPSWITCH2+1 || + sprite[hitspr].picnum == DIPSWITCH3 || + sprite[hitspr].picnum == DIPSWITCH3+1 || + sprite[hitspr].picnum == HANDSWITCH || + sprite[hitspr].picnum == HANDSWITCH+1) ) + { + checkhitswitch(p,hitspr,1); + return 0; + } + } + else if( hitwall >= 0 ) + { + if (projectile[atwith].spawns >= 0) + { + wh=spawn(k,projectile[atwith].spawns); + if (projectile[atwith].sxrepeat > 4) sprite[wh].xrepeat=projectile[atwith].sxrepeat; + if (projectile[atwith].syrepeat > 4) sprite[wh].yrepeat=projectile[atwith].syrepeat; + } + if( isadoorwall(wall[hitwall].picnum) == 1 ) + goto DOSKIPBULLETHOLE; + if(p >= 0 && ( + wall[hitwall].picnum == DIPSWITCH || + wall[hitwall].picnum == DIPSWITCH+1 || + wall[hitwall].picnum == DIPSWITCH2 || + wall[hitwall].picnum == DIPSWITCH2+1 || + wall[hitwall].picnum == DIPSWITCH3 || + wall[hitwall].picnum == DIPSWITCH3+1 || + wall[hitwall].picnum == HANDSWITCH || + wall[hitwall].picnum == HANDSWITCH+1) ) + { + checkhitswitch(p,hitwall,0); + return 0; + } + + if(wall[hitwall].hitag != 0 || ( wall[hitwall].nextwall >= 0 && wall[wall[hitwall].nextwall].hitag != 0 ) ) + goto DOSKIPBULLETHOLE; + + if( hitsect >= 0 && sector[hitsect].lotag == 0 ) + if( wall[hitwall].overpicnum != BIGFORCE ) + if( (wall[hitwall].nextsector >= 0 && sector[wall[hitwall].nextsector].lotag == 0 ) || + ( wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0 ) ) + if( (wall[hitwall].cstat&16) == 0) + { + if(wall[hitwall].nextsector >= 0) + { + l = headspritesect[wall[hitwall].nextsector]; + while(l >= 0) + { + if(sprite[l].statnum == 3 && sprite[l].lotag == 13) + goto DOSKIPBULLETHOLE; + l = nextspritesect[l]; + } + } + + l = headspritestat[5]; + while(l >= 0) + { + if(sprite[l].picnum == projectile[atwith].decal) + if(dist(&sprite[l],&sprite[k]) < (12+(TRAND&7)) ) + goto DOSKIPBULLETHOLE; + l = nextspritestat[l]; + } + if (projectile[atwith].decal >= 0) + { + l = spawn(k,projectile[atwith].decal); + sprite[l].xvel = -1; + sprite[l].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, + wall[hitwall].y-wall[wall[hitwall].point2].y)+512; + if(projectile[atwith].workslike & PROJECTILE_FLAG_RANDDECALSIZE) + { + wh = (TRAND&projectile[atwith].xrepeat); + if (wh < projectile[atwith].yrepeat) + wh = projectile[atwith].yrepeat; + sprite[l].xrepeat = wh; + sprite[l].yrepeat = wh; + } + else + { + sprite[l].xrepeat = projectile[atwith].xrepeat; + sprite[l].yrepeat = projectile[atwith].yrepeat; + } + sprite[l].cstat = 16+(krand()&12); + sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); + sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); + + ssp(l,CLIPMASK0); + insertspriteq(l); + } + } + +DOSKIPBULLETHOLE: + + if( wall[hitwall].cstat&2 ) + if(wall[hitwall].nextsector >= 0) + if(hitz >= (sector[wall[hitwall].nextsector].floorz) ) + hitwall = wall[hitwall].nextwall; + + checkhitwall(k,hitwall,hitx,hity,hitz,atwith); + } + } + else + { + k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,24,24,sa,0,0,i,4); + sprite[k].extra = projectile[atwith].extra; + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + hittype[k].temp_data[6] = hitwall; + hittype[k].temp_data[7] = hitsect; + hittype[k].temp_data[8] = hitspr; + + if( hitspr >= 0 ) + { + checkhitsprite(hitspr,k); + if( sprite[hitspr].picnum != APLAYER ) + { + if (projectile[atwith].spawns >= 0) + { + wh=spawn(k,projectile[atwith].spawns); + if (projectile[atwith].sxrepeat > 4) sprite[wh].xrepeat=projectile[atwith].sxrepeat; + if (projectile[atwith].syrepeat > 4) sprite[wh].yrepeat=projectile[atwith].syrepeat; + } + } + else sprite[k].xrepeat = sprite[k].yrepeat = 0; + } + else if( hitwall >= 0 ) + checkhitwall(k,hitwall,hitx,hity,hitz,atwith); + } + + if( (TRAND&255) < 4 ) + if (projectile[atwith].isound >= 0) + xyzsound(projectile[atwith].isound,k,hitx,hity,hitz); + + return 0; + } + + if(projectile[atwith].workslike & PROJECTILE_FLAG_RPG) + { + + /* if(projectile[atwith].workslike & PROJECTILE_FLAG_FREEZEBLAST) + sz += (3<<8);*/ + + if( s->extra >= 0 ) s->shade = projectile[atwith].shade; + + scount = 1; + vel = projectile[atwith].vel; + + j = -1; + + if(p >= 0) + { + // j = aim( s, AUTO_AIM_ANGLE ); // 48 + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if( GetGameVarID(g_iAimAngleVarID,i,p) > 0 ) + { + j = aim( s, GetGameVarID(g_iAimAngleVarID,i,p)); + } + if(j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); + zvel = ( (sprite[j].z-sz-dal)*vel ) / ldist(&sprite[ps[p].i], &sprite[j]); + if( sprite[j].picnum != RECON ) + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + // else zvel = (100-ps[p].horiz-ps[p].horizoff)*81; + else zvel = ((100-ps[p].horiz-ps[p].horizoff)*(projectile[atwith].vel/8)); + if (projectile[atwith].sound > -1) spritesound(projectile[atwith].sound,i); + } + else + { + if (!(projectile[atwith].workslike & PROJECTILE_FLAG_NOAIM)) + { + j = findplayer(s,&x); + sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy); + + l = ldist(&sprite[ps[j].i],s); + zvel = ( (ps[j].oposz-sz)*vel) / l; + + if( badguy(s) && (s->hitag&face_player_smart) ) + sa = s->ang+(TRAND&31)-16; + } + } + + + + if( p >= 0 && j >= 0) + l = j; + else l = -1; + + /* j = EGS(sect, + sx+(sintable[(348+sa+512)&2047]/448), + sy+(sintable[(sa+348)&2047]/448), + sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4);*/ + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + j = EGS(sect, + sx+(sintable[(348+sa+512)&2047]/projectile[atwith].offset), + sy+(sintable[(sa+348)&2047]/projectile[atwith].offset), + sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); + + sprite[j].xrepeat=projectile[atwith].xrepeat; + sprite[j].yrepeat=projectile[atwith].yrepeat; + + + if(projectile[atwith].extra_rand > 0) + sprite[j].extra += (TRAND&projectile[atwith].extra_rand); + if(!(projectile[atwith].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS)) + sprite[j].yvel = l; + else + { + if (projectile[atwith].bounces >= 1) sprite[j].yvel = projectile[atwith].bounces; + else sprite[j].yvel = numfreezebounces; + // sprite[j].xrepeat >>= 1; + // sprite[j].yrepeat >>= 1; + sprite[j].zvel -= (2<<4); + } + /* + if(p == -1) + { + if(!(projectile[atwith].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS)) + { + sprite[j].xrepeat = projectile[atwith].xrepeat; // 30 + sprite[j].yrepeat = projectile[atwith].yrepeat; + sprite[j].extra >>= 2; + } + } + */ + if (projectile[atwith].cstat >= 0) sprite[j].cstat = projectile[atwith].cstat; + else sprite[j].cstat = 128; + if (projectile[atwith].clipdist >= 0) sprite[j].clipdist = projectile[atwith].clipdist; + else sprite[j].clipdist = 40; + + Bmemcpy(&thisprojectile[j], &projectile[sprite[j].picnum], sizeof(projectile[sprite[j].picnum])); + + // sa = s->ang+32-(TRAND&63); + // zvel = oldzvel+512-(TRAND&1023); + + return 0; + } + + } + + else + + { + switch(dynamictostatic[atwith]) + { + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + + if(p >= 0) + sa += 64 - (TRAND&127); + else sa += 1024 + 64 - (TRAND&127); + zvel = 1024-(TRAND&2047); + case KNEE__STATIC: + if(atwith == KNEE ) + { + if(p >= 0) + { + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + sz += (6<<8); + sa += 15; + } + else + { + j = ps[findplayer(s,&x)].i; + zvel = ( (sprite[j].z-sz)<<8 ) / (x+1); + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + } + + // writestring(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047],zvel<<6); + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz,sect, + sintable[(sa+512)&2047], + sintable[sa&2047],zvel<<6, + &hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + + if( atwith == BLOODSPLAT1 || atwith == BLOODSPLAT2 || atwith == BLOODSPLAT3 || atwith == BLOODSPLAT4 ) + { + if( FindDistance2D(sx-hitx,sy-hity) < 1024 ) + if( hitwall >= 0 && wall[hitwall].overpicnum != BIGFORCE ) + if( ( wall[hitwall].nextsector >= 0 && hitsect >= 0 && + sector[wall[hitwall].nextsector].lotag == 0 && + sector[hitsect].lotag == 0 && + sector[wall[hitwall].nextsector].lotag == 0 && + (sector[hitsect].floorz-sector[wall[hitwall].nextsector].floorz) > (16<<8) ) || + ( wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0 ) ) + if( (wall[hitwall].cstat&16) == 0) + { + if(wall[hitwall].nextsector >= 0) + { + k = headspritesect[wall[hitwall].nextsector]; + while(k >= 0) + { + if(sprite[k].statnum == 3 && sprite[k].lotag == 13) + return 0; + k = nextspritesect[k]; + } + } + + if( wall[hitwall].nextwall >= 0 && + wall[wall[hitwall].nextwall].hitag != 0 ) + return 0; + + if(wall[hitwall].hitag == 0) + { + k = spawn(i,atwith); + sprite[k].xvel = -12; + sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, + wall[hitwall].y-wall[wall[hitwall].point2].y)+512; + sprite[k].x = hitx; + sprite[k].y = hity; + sprite[k].z = hitz; + sprite[k].cstat |= (TRAND&4); + ssp(k,CLIPMASK0); + setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + if( PN == OOZFILTER || PN == NEWBEAST ) + sprite[k].pal = 6; + } + } + return 0; + } + + if(hitsect < 0) break; + + if( ( klabs(sx-hitx)+klabs(sy-hity) ) < 1024 ) + { + if(hitwall >= 0 || hitspr >= 0) + { + j = EGS(hitsect,hitx,hity,hitz,KNEE,-15,0,0,sa,32,0,i,4); + sprite[j].extra += (TRAND&7); + if(p >= 0) + { + k = spawn(j,SMALLSMOKE); + sprite[k].z -= (8<<8); + spritesound(KICK_HIT,j); + } + + if ( p >= 0 && ps[p].steroids_amount > 0 && ps[p].steroids_amount < 400 ) + sprite[j].extra += (max_player_health>>2); + + if( hitspr >= 0 && sprite[hitspr].picnum != ACCESSSWITCH && sprite[hitspr].picnum != ACCESSSWITCH2 ) + { + checkhitsprite(hitspr,j); + if(p >= 0) checkhitswitch(p,hitspr,1); + } + + else if( hitwall >= 0 ) + { + if( wall[hitwall].cstat&2 ) + if(wall[hitwall].nextsector >= 0) + if(hitz >= (sector[wall[hitwall].nextsector].floorz) ) + hitwall = wall[hitwall].nextwall; + + if( hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2 ) + { + checkhitwall(j,hitwall,hitx,hity,hitz,atwith); + if(p >= 0) checkhitswitch(p,hitwall,0); + } + } + } + else if(p >= 0 && zvel > 0 && sector[hitsect].lotag == 1) + { + j = spawn(ps[p].i,WATERSPLASH2); + sprite[j].x = hitx; + sprite[j].y = hity; + sprite[j].ang = ps[p].ang; // Total tweek + sprite[j].xvel = 32; + ssp(i,CLIPMASK0); + sprite[j].xvel = 0; + + } + } + + break; + + case SHOTSPARK1__STATIC: + case SHOTGUN__STATIC: + case CHAINGUN__STATIC: + + if( s->extra >= 0 ) s->shade = -96; + + if(p >= 0) + { + int angRange; + int zRange; + + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if( GetGameVarID(g_iAimAngleVarID,i,p) > 0 ) + { + j = aim( s, GetGameVarID(g_iAimAngleVarID,i,p)); + } + if(j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); + if (((sprite[j].picnum>=GREENSLIME)&&(sprite[j].picnum<=GREENSLIME+7))||(sprite[j].picnum==ROTATEGUN)) { + + dal -= (8<<8); + + } + zvel = ( ( sprite[j].z-sz-dal )<<8 ) / ldist(&sprite[ps[p].i], &sprite[j]) ; + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + + angRange=32; + zRange=256; + SetGameVarID(g_iAngRangeVarID,32, i,p); + SetGameVarID(g_iZRangeVarID,256,i,p); + OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + angRange=GetGameVarID(g_iAngRangeVarID,i,p); + zRange=GetGameVarID(g_iZRangeVarID,i,p); + + sa += (angRange/2)-(TRAND&(angRange-1)); + if(j == -1) + { + // no target + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + } + zvel += (zRange/2)-(TRAND&(zRange-1)); + sz -= (2<<8); + } + else + { + j = findplayer(s,&x); + sz -= (4<<8); + zvel = ( (ps[j].posz-sz) <<8 ) / (ldist(&sprite[ps[j].i], s ) ); + if(s->picnum != BOSS1) + { + zvel += 128-(TRAND&255); + sa += 32-(TRAND&63); + } + else + { + zvel += 128-(TRAND&255); + sa = getangle(ps[j].posx-sx,ps[j].posy-sy)+64-(TRAND&127); + } + } + + s->cstat &= ~257; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + s->cstat |= 257; + + if(hitsect < 0) return 0; + + if( (TRAND&15) == 0 && sector[hitsect].lotag == 2 ) + tracers(hitx,hity,hitz,sx,sy,sz,8-(ud.multimode>>1)); + + if(p >= 0) + { + k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,10,10,sa,0,0,i,4); + sprite[k].extra = *actorscrptr[atwith]; + sprite[k].extra += (TRAND%6); + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + hittype[k].temp_data[6] = hitwall; + hittype[k].temp_data[7] = hitsect; + hittype[k].temp_data[8] = hitspr; + + + if( hitwall == -1 && hitspr == -1) + { + if( zvel < 0 ) + { + if( sector[hitsect].ceilingstat&1 ) + { + sprite[k].xrepeat = 0; + sprite[k].yrepeat = 0; + return 0; + } + else + checkhitceiling(hitsect); + } + spawn(k,SMALLSMOKE); + } + + if(hitspr >= 0) + { + checkhitsprite(hitspr,k); + if( sprite[hitspr].picnum == APLAYER && (!(gametype_flags[ud.coop]&GAMETYPE_FLAG_COOP ) || ud.ffire == 1) ) + { + l = spawn(k,JIBS6); + sprite[k].xrepeat = sprite[k].yrepeat = 0; + sprite[l].z += (4<<8); + sprite[l].xvel = 16; + sprite[l].xrepeat = sprite[l].yrepeat = 24; + sprite[l].ang += 64-(TRAND&127); + } + else spawn(k,SMALLSMOKE); + + if(p >= 0 && ( + sprite[hitspr].picnum == DIPSWITCH || + sprite[hitspr].picnum == DIPSWITCH+1 || + sprite[hitspr].picnum == DIPSWITCH2 || + sprite[hitspr].picnum == DIPSWITCH2+1 || + sprite[hitspr].picnum == DIPSWITCH3 || + sprite[hitspr].picnum == DIPSWITCH3+1 || + sprite[hitspr].picnum == HANDSWITCH || + sprite[hitspr].picnum == HANDSWITCH+1) ) + { + checkhitswitch(p,hitspr,1); + return 0; + } + } + else if( hitwall >= 0 ) + { + spawn(k,SMALLSMOKE); + + if( isadoorwall(wall[hitwall].picnum) == 1 ) + goto SKIPBULLETHOLE; + if(p >= 0 && ( + wall[hitwall].picnum == DIPSWITCH || + wall[hitwall].picnum == DIPSWITCH+1 || + wall[hitwall].picnum == DIPSWITCH2 || + wall[hitwall].picnum == DIPSWITCH2+1 || + wall[hitwall].picnum == DIPSWITCH3 || + wall[hitwall].picnum == DIPSWITCH3+1 || + wall[hitwall].picnum == HANDSWITCH || + wall[hitwall].picnum == HANDSWITCH+1) ) + { + checkhitswitch(p,hitwall,0); + return 0; + } + + if(wall[hitwall].hitag != 0 || ( wall[hitwall].nextwall >= 0 && wall[wall[hitwall].nextwall].hitag != 0 ) ) + goto SKIPBULLETHOLE; + + if( hitsect >= 0 && sector[hitsect].lotag == 0 ) + if( wall[hitwall].overpicnum != BIGFORCE ) + if( (wall[hitwall].nextsector >= 0 && sector[wall[hitwall].nextsector].lotag == 0 ) || + ( wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0 ) ) + if( (wall[hitwall].cstat&16) == 0) + { + if(wall[hitwall].nextsector >= 0) + { + l = headspritesect[wall[hitwall].nextsector]; + while(l >= 0) + { + if(sprite[l].statnum == 3 && sprite[l].lotag == 13) + goto SKIPBULLETHOLE; + l = nextspritesect[l]; + } + } + + l = headspritestat[5]; + while(l >= 0) + { + if(sprite[l].picnum == BULLETHOLE) + if(dist(&sprite[l],&sprite[k]) < (12+(TRAND&7)) ) + goto SKIPBULLETHOLE; + l = nextspritestat[l]; + } + l = spawn(k,BULLETHOLE); + sprite[l].xvel = -1; + sprite[l].x = hitx; + sprite[l].y = hity; + sprite[l].z = hitz; + + sprite[l].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, + wall[hitwall].y-wall[wall[hitwall].point2].y)+512; + + sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); + sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); + ssp(l,CLIPMASK0); + } + +SKIPBULLETHOLE: + + if( wall[hitwall].cstat&2 ) + if(wall[hitwall].nextsector >= 0) + if(hitz >= (sector[wall[hitwall].nextsector].floorz) ) + hitwall = wall[hitwall].nextwall; + + checkhitwall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); + } + } + else + { + k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,24,24,sa,0,0,i,4); + sprite[k].extra = *actorscrptr[atwith]; + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + hittype[k].temp_data[6] = hitwall; + hittype[k].temp_data[7] = hitsect; + hittype[k].temp_data[8] = hitspr; + + if( hitspr >= 0 ) + { + checkhitsprite(hitspr,k); + if( sprite[hitspr].picnum != APLAYER ) + spawn(k,SMALLSMOKE); + else sprite[k].xrepeat = sprite[k].yrepeat = 0; + } + else if( hitwall >= 0 ) + checkhitwall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); + } + + if( (TRAND&255) < 4 ) + xyzsound(PISTOL_RICOCHET,k,hitx,hity,hitz); + + return 0; + + case FIRELASER__STATIC: + case SPIT__STATIC: + case COOLEXPLOSION1__STATIC: + + if( s->extra >= 0 ) s->shade = -96; + + scount = 1; + if(atwith == SPIT) vel = 292; + else + { + if(atwith == COOLEXPLOSION1) + { + if(s->picnum == BOSS2) vel = 644; + else vel = 348; + sz -= (4<<7); + } + else + { + vel = 840; + sz -= (4<<7); + } + } + + if(p >= 0) + { + // j = aim( s, AUTO_AIM_ANGLE ); + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if( GetGameVarID(g_iAimAngleVarID,i,p) > 0 ) + { + j = aim( s, GetGameVarID(g_iAimAngleVarID,i,p)); + } + + if(j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)-(12<<8); + zvel = ((sprite[j].z-sz-dal)*vel ) / ldist(&sprite[ps[p].i], &sprite[j]) ; + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + else + zvel = (100-ps[p].horiz-ps[p].horizoff)*98; + } + else + { + j = findplayer(s,&x); + // sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy); + sa += 16-(TRAND&31); + zvel = ( ( (ps[j].oposz - sz + (3<<8) ) )*vel ) / ldist(&sprite[ps[j].i],s); + } + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + oldzvel = zvel; + + if(atwith == SPIT) { sizx = 18;sizy = 18,sz -= (10<<8); } + else + { + if( atwith == FIRELASER ) + { + if(p >= 0) + { + + sizx = 34; + sizy = 34; + } + else + { + sizx = 18; + sizy = 18; + } + } + else + { + sizx = 18; + sizy = 18; + } + } + + if(p >= 0) sizx = 7,sizy = 7; + + while(scount > 0) + { + j = EGS(sect,sx,sy,sz,atwith,-127,sizx,sizy,sa,vel,zvel,i,4); + sprite[j].extra += (TRAND&7); + + if(atwith == COOLEXPLOSION1) + { + sprite[j].shade = 0; + if(PN == BOSS2) + { + l = sprite[j].xvel; + sprite[j].xvel = 1024; + ssp(j,CLIPMASK0); + sprite[j].xvel = l; + sprite[j].ang += 128-(TRAND&255); + } + } + + sprite[j].cstat = 128; + sprite[j].clipdist = 4; + + sa = s->ang+32-(TRAND&63); + zvel = oldzvel+512-(TRAND&1023); + + scount--; + } + + return 0; + + case FREEZEBLAST__STATIC: + sz += (3<<8); + case RPG__STATIC: + + if( s->extra >= 0 ) s->shade = -96; + + scount = 1; + vel = 644; + + j = -1; + + if(p >= 0) + { + // j = aim( s, AUTO_AIM_ANGLE ); // 48 + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if( GetGameVarID(g_iAimAngleVarID,i,p) > 0 ) + { + j = aim( s, GetGameVarID(g_iAimAngleVarID,i,p)); + } + + if(j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); + zvel = ( (sprite[j].z-sz-dal)*vel ) / ldist(&sprite[ps[p].i], &sprite[j]); + if( sprite[j].picnum != RECON ) + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + else zvel = (100-ps[p].horiz-ps[p].horizoff)*81; + if(atwith == RPG) + spritesound(RPG_SHOOT,i); + + } + else + { + j = findplayer(s,&x); + sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy); + if(PN == BOSS3) + sz -= (32<<8); + else if(PN == BOSS2) + { + vel += 128; + sz += 24<<8; + } + + l = ldist(&sprite[ps[j].i],s); + zvel = ( (ps[j].oposz-sz)*vel) / l; + + if( badguy(s) && (s->hitag&face_player_smart) ) + sa = s->ang+(TRAND&31)-16; + } + + if( p >= 0 && j >= 0) + l = j; + else l = -1; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + j = EGS(sect, + sx+(sintable[(348+sa+512)&2047]/448), + sy+(sintable[(sa+348)&2047]/448), + sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); + + sprite[j].extra += (TRAND&7); + if(atwith != FREEZEBLAST) + sprite[j].yvel = l; + else + { + sprite[j].yvel = numfreezebounces; + sprite[j].xrepeat >>= 1; + sprite[j].yrepeat >>= 1; + sprite[j].zvel -= (2<<4); + } + + if(p == -1) + { + if(PN == BOSS3) + { + if(TRAND&1) + { + sprite[j].x -= sintable[sa&2047]>>6; + sprite[j].y -= sintable[(sa+1024+512)&2047]>>6; + sprite[j].ang -= 8; + } + else + { + sprite[j].x += sintable[sa&2047]>>6; + sprite[j].y += sintable[(sa+1024+512)&2047]>>6; + sprite[j].ang += 4; + } + sprite[j].xrepeat = 42; + sprite[j].yrepeat = 42; + } + else if(PN == BOSS2) + { + sprite[j].x -= sintable[sa&2047]/56; + sprite[j].y -= sintable[(sa+1024+512)&2047]/56; + sprite[j].ang -= 8+(TRAND&255)-128; + sprite[j].xrepeat = 24; + sprite[j].yrepeat = 24; + } + else if(atwith != FREEZEBLAST) + { + sprite[j].xrepeat = 30; + sprite[j].yrepeat = 30; + sprite[j].extra >>= 2; + } + } + + else if(*aplWeaponWorksLike[ps[p].curr_weapon] == DEVISTATOR_WEAPON) + { + sprite[j].extra >>= 2; + sprite[j].ang += 16-(TRAND&31); + sprite[j].zvel += 256-(TRAND&511); + + if( ps[p].hbomb_hold_delay ) + { + sprite[j].x -= sintable[sa&2047]/644; + sprite[j].y -= sintable[(sa+1024+512)&2047]/644; + } + else + { + sprite[j].x += sintable[sa&2047]>>8; + sprite[j].y += sintable[(sa+1024+512)&2047]>>8; + } + sprite[j].xrepeat >>= 1; + sprite[j].yrepeat >>= 1; + } + + sprite[j].cstat = 128; + if(atwith == RPG) + sprite[j].clipdist = 4; + else + sprite[j].clipdist = 40; + + break; + + case HANDHOLDINGLASER__STATIC: + + if(p >= 0) + zvel = (100-ps[p].horiz-ps[p].horizoff)*32; + else zvel = 0; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz-ps[p].pyoff,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + + j = 0; + if(hitspr >= 0) break; + + if(hitwall >= 0 && hitsect >= 0) + if( ((hitx-sx)*(hitx-sx)+(hity-sy)*(hity-sy)) < (290*290) ) + { + if( wall[hitwall].nextsector >= 0) + { + if( sector[wall[hitwall].nextsector].lotag <= 2 && sector[hitsect].lotag <= 2 ) + j = 1; + } + else if( sector[hitsect].lotag <= 2 ) + j = 1; + } + + if(j == 1) + { + long lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, ps[p].i, p); + k = EGS(hitsect,hitx,hity,hitz,TRIPBOMB,-16,4,5,sa,0,0,i,6); + if(lTripBombControl & TRIPBOMB_TIMER) + { + long lLifetime=GetGameVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, ps[p].i, p); + long lLifetimeVar=GetGameVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, ps[p].i, p); + // set timer. blows up when at zero.... + hittype[k].temp_data[7]=lLifetime + + mulscale(krand(),lLifetimeVar, 14) + - lLifetimeVar; + hittype[k].temp_data[6]=1; + } + else + + sprite[k].hitag = k; + spritesound(LASERTRIP_ONWALL,k); + sprite[k].xvel = -20; + ssp(k,CLIPMASK0); + sprite[k].cstat = 16; + hittype[k].temp_data[5] = sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y)-512; + + + } + return 0; + + case BOUNCEMINE__STATIC: + case MORTER__STATIC: + + if( s->extra >= 0 ) s->shade = -96; + + j = ps[findplayer(s,&x)].i; + x = ldist(&sprite[j],s); + + zvel = -x>>1; + + if(zvel < -4096) + zvel = -2048; + vel = x>>4; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + EGS(sect, + sx+(sintable[(512+sa+512)&2047]>>8), + sy+(sintable[(sa+512)&2047]>>8), + sz+(6<<8),atwith,-64,32,32,sa,vel,zvel,i,1); + break; + + case GROWSPARK__STATIC: + + if(p >= 0) + { + // j = aim( s, AUTO_AIM_ANGLE ); + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if( GetGameVarID(g_iAimAngleVarID,i,p) > 0 ) + { + j = aim( s, GetGameVarID(g_iAimAngleVarID,i,p)); + } + + if(j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); + if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN) ) { + dal -= (8<<8); + + } + zvel = ( ( sprite[j].z-sz-dal )<<8 ) / (ldist(&sprite[ps[p].i], &sprite[j]) ); + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + else + { + sa += 16-(TRAND&31); + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + zvel += 128-(TRAND&255); + } + + sz -= (2<<8); + } + else + { + j = findplayer(s,&x); + sz -= (4<<8); + zvel = ( (ps[j].posz-sz) <<8 ) / (ldist(&sprite[ps[j].i], s ) ); + zvel += 128-(TRAND&255); + sa += 32-(TRAND&63); + } + + k = 0; + + // RESHOOTGROW: + + s->cstat &= ~257; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + hitscan(sx,sy,sz,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); + + s->cstat |= 257; + + j = EGS(sect,hitx,hity,hitz,GROWSPARK,-16,28,28,sa,0,0,i,1); + + sprite[j].pal = 2; + sprite[j].cstat |= 130; + sprite[j].xrepeat = sprite[j].yrepeat = 1; + + if( hitwall == -1 && hitspr == -1 && hitsect >= 0) + { + if( zvel < 0 && (sector[hitsect].ceilingstat&1) == 0) + checkhitceiling(hitsect); + } + else if(hitspr >= 0) checkhitsprite(hitspr,j); + else if(hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2 ) + { + /* if(wall[hitwall].overpicnum == MIRROR && k == 0) + { + l = getangle( + wall[wall[hitwall].point2].x-wall[hitwall].x, + wall[wall[hitwall].point2].y-wall[hitwall].y); + + sx = hitx; + sy = hity; + sz = hitz; + sect = hitsect; + sa = ((l<<1) - sa)&2047; + sx += sintable[(sa+512)&2047]>>12; + sy += sintable[sa&2047]>>12; + + k++; + goto RESHOOTGROW; + } + else */ + checkhitwall(j,hitwall,hitx,hity,hitz,atwith); + } + + break; + + case SHRINKER__STATIC: + if( s->extra >= 0 ) s->shade = -96; + if(p >= 0) + { + // j = aim( s, AUTO_AIM_ANGLE ); + SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if( GetGameVarID(g_iAimAngleVarID,i,p) > 0 ) + { + j = aim( s, GetGameVarID(g_iAimAngleVarID,i,p)); + } + + if(j >= 0) + { + dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1); + zvel = ( (sprite[j].z-sz-dal-(4<<8))*768) / (ldist( &sprite[ps[p].i], &sprite[j])); + sa = getangle(sprite[j].x-sx,sprite[j].y-sy); + } + else zvel = (100-ps[p].horiz-ps[p].horizoff)*98; + } + else if(s->statnum != 3) + { + j = findplayer(s,&x); + l = ldist(&sprite[ps[j].i],s); + zvel = ( (ps[j].oposz-sz)*512) / l ; + } + else zvel = 0; + if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + j = EGS(sect, + sx+(sintable[(512+sa+512)&2047]>>12), + sy+(sintable[(sa+512)&2047]>>12), + sz+(2<<8),SHRINKSPARK,-16,28,28,sa,768,zvel,i,4); + + sprite[j].cstat = 128; + sprite[j].clipdist = 32; + + + return 0; + } + } + return (long) s; +} + +void displayloogie(short snum) +{ + long i, a, x, y, z; + + if(ps[snum].loogcnt == 0) return; + + y = (ps[snum].loogcnt<<2); + for(i=0;i>5; + z = 4096+((ps[snum].loogcnt+i)<<9); + x = (-sync[snum].avel)+(sintable[((ps[snum].loogcnt+i)<<6)&2047]>>10); + + rotatesprite( + (ps[snum].loogiex[i]+x)<<16,(200+ps[snum].loogiey[i]-y)<<16,z-(i<<8),256-a, + LOOGIE,0,0,2,0,0,xdim-1,ydim-1); + } +} + +char animatefist(short gs,short snum) +{ + short looking_arc,fisti,fistpal; + long fistzoom, fistz; + + fisti = ps[snum].fist_incs; + if(fisti > 32) fisti = 32; + if(fisti <= 0) return 0; + + looking_arc = klabs(ps[snum].look_ang)/9; + + fistzoom = 65536L - (sintable[(512+(fisti<<6))&2047]<<2); + if(fistzoom > 90612L) + fistzoom = 90612L; + if(fistzoom < 40920) + fistzoom = 40290; + fistz = 194 + (sintable[((6+fisti)<<7)&2047]>>9); + + if(sprite[ps[snum].i].pal == 1) + fistpal = 1; + else + fistpal = sector[ps[snum].cursectnum].floorpal; + + rotatesprite( + (-fisti+222+(sync[snum].avel>>4))<<16, + (looking_arc+fistz)<<16, + fistzoom,0,FIST,gs,fistpal,2,0,0,xdim-1,ydim-1); + + return 1; +} + +char animateknee(short gs,short snum) +{ + short knee_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-72,-32,-8}; + short looking_arc, pal; + + if(ps[snum].knee_incs > 11 || ps[snum].knee_incs == 0 || sprite[ps[snum].i].extra <= 0) return 0; + + looking_arc = knee_y[ps[snum].knee_incs] + klabs(ps[snum].look_ang)/9; + + looking_arc -= (ps[snum].hard_landing<<3); + + if(sprite[ps[snum].i].pal == 1) + pal = 1; + else + { + pal = sector[ps[snum].cursectnum].floorpal; + if(pal == 0) + pal = ps[snum].palookup; + } + + myospal(105+(sync[snum].avel>>4)-(ps[snum].look_ang>>1)+(knee_y[ps[snum].knee_incs]>>2),looking_arc+280-((ps[snum].horiz-ps[snum].horizoff)>>4),KNEE,gs,4,pal); + + return 1; +} + +char animateknuckles(short gs,short snum) +{ + short knuckle_frames[] = {0,1,2,2,3,3,3,2,2,1,0}; + short looking_arc, pal; + + if(ps[snum].knuckle_incs == 0 || sprite[ps[snum].i].extra <= 0) return 0; + + looking_arc = klabs(ps[snum].look_ang)/9; + + looking_arc -= (ps[snum].hard_landing<<3); + + if(sprite[ps[snum].i].pal == 1) + pal = 1; + else + pal = sector[ps[snum].cursectnum].floorpal; + + myospal(160+(sync[snum].avel>>4)-(ps[snum].look_ang>>1),looking_arc+180-((ps[snum].horiz-ps[snum].horizoff)>>4),CRACKKNUCKLES+knuckle_frames[ps[snum].knuckle_incs>>1],gs,4,pal); + + return 1; +} + +long lastvisinc; + +void DoFire(short snum) +{ + int i; + + struct player_struct *p; + p = &ps[snum]; + + SetGameVarID(g_iReturnVarID,0,p->i,snum); + OnEvent(EVENT_DOFIRE, p->i, snum, -1); + + if(GetGameVarID(g_iReturnVarID,p->i,snum) == 0) + { + if (p->weapon_pos != 0) return; + + // if ((aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON) && (p->ammo_amount[p->curr_weapon] == 0)) + // return; + + //AddLog("DoFire()"); + if(aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON) + { + //Bsprintf(g_szBuf,"%d: using Ammo. was: %d",p->curr_weapon,p->ammo_amount[p->curr_weapon]); + // AddLog(g_szBuf); + p->ammo_amount[p->curr_weapon]--; + } + + if(aplWeaponFireSound[p->curr_weapon][snum]) + { + //Bsprintf(g_szBuf,"DoFire():firesound(%ld)",aplWeaponFireSound[p->curr_weapon][snum]); + //AddLog(g_szBuf); + spritesound(aplWeaponFireSound[p->curr_weapon][snum],p->i); + } + + SetGameVarID(g_iWeaponVarID,p->curr_weapon,p->i,snum); + SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + //Bsprintf(g_szBuf,"DoFire():shoot(%ld)",aplWeaponShoots[p->curr_weapon][snum]); + //AddLog(g_szBuf); + shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + for(i=1;icurr_weapon][snum];i++) + { + //Bsprintf(g_szBuf,"DoFire():shoot(%ld)",aplWeaponShoots[p->curr_weapon][snum]); + //AddLog(g_szBuf); + + if(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AMMOPERSHOT) + { + if(p->ammo_amount[p->curr_weapon] > 0) + { + p->ammo_amount[p->curr_weapon]--; + shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + } + } + else + { + shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + } + } + + if(! (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE )) + { + // make them visible if not set... + lastvisinc = totalclock+32; + p->visibility = 0; + } + + if( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) && + aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] + && p->ammo_amount[p->curr_weapon] > 0 + && (aplWeaponClip[p->curr_weapon][snum]) + && ((p->ammo_amount[p->curr_weapon]%(aplWeaponClip[p->curr_weapon][snum]))==0) + ) + { + //AddLog("DoFire():ClipCheck"); + // do clip check... + p->kickback_pic=aplWeaponTotalTime[p->curr_weapon][snum]; + // is same as (*kb).... + } + + //Bsprintf(g_szBuf,"%d: Do fire: exit ammo: %d",p->curr_weapon,p->ammo_amount[p->curr_weapon]); + //AddLog(g_szBuf); + } +} + +void DoSpawn(short snum) +{ + int j; + + struct player_struct *p; + p = &ps[snum]; + + if(!aplWeaponSpawn[p->curr_weapon][snum]) + return; + + j = spawn(p->i, aplWeaponSpawn[p->curr_weapon][snum]); + + /* if((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_SPAWNTYPE2 ) ) + { + // like shotgun shells + // p->kickback_pic++; + } + else */ + if((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_SPAWNTYPE3 ) ) + { + // like chaingun shells + sprite[j].ang += 1024; + sprite[j].ang &= 2047; + sprite[j].xvel += 32; + sprite[j].z += (3<<8); + } + + ssp(j,CLIPMASK0); + +} + +void displaymasks(short snum) +{ + short i, p; + + if(sprite[ps[snum].i].pal == 1) + p = 1; + else + p = sector[ps[snum].cursectnum].floorpal; + + if(ps[snum].scuba_on) + { + if(ud.screen_size > 4) + { + rotatesprite(43<<16,(200-8-tilesizy[SCUBAMASK])<<16,65536,0,SCUBAMASK,0,p,2+16,windowx1,windowy1,windowx2,windowy2); + rotatesprite((320-43)<<16,(200-8-tilesizy[SCUBAMASK])<<16,65536,1024,SCUBAMASK,0,p,2+4+16,windowx1,windowy1,windowx2,windowy2); + } + else + { + rotatesprite(43<<16,(200-tilesizy[SCUBAMASK])<<16,65536,0,SCUBAMASK,0,p,2+16,windowx1,windowy1,windowx2,windowy2); + rotatesprite((320-43)<<16,(200-tilesizy[SCUBAMASK])<<16,65536,1024,SCUBAMASK,0,p,2+4+16,windowx1,windowy1,windowx2,windowy2); + } + } +} + +char animatetip(short gs,short snum) +{ + short p,looking_arc; + short tip_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; + + if(ps[snum].tipincs == 0) return 0; + + looking_arc = klabs(ps[snum].look_ang)/9; + looking_arc -= (ps[snum].hard_landing<<3); + + if(sprite[ps[snum].i].pal == 1) + p = 1; + else + p = sector[ps[snum].cursectnum].floorpal; + + /* if(ps[snum].access_spritenum >= 0) + p = sprite[ps[snum].access_spritenum].pal; + else + p = wall[ps[snum].access_wallnum].pal; + */ + myospal(170+(sync[snum].avel>>4)-(ps[snum].look_ang>>1), + (tip_y[ps[snum].tipincs]>>1)+looking_arc+240-((ps[snum].horiz-ps[snum].horizoff)>>4),TIP+((26-ps[snum].tipincs)>>4),gs,0,p); + + return 1; +} + +char animateaccess(short gs,short snum) +{ + short access_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; + short looking_arc; + char p; + + if(ps[snum].access_incs == 0 || sprite[ps[snum].i].extra <= 0) return 0; + + looking_arc = access_y[ps[snum].access_incs] + klabs(ps[snum].look_ang)/9; + looking_arc -= (ps[snum].hard_landing<<3); + + if(ps[snum].access_spritenum >= 0) + p = sprite[ps[snum].access_spritenum].pal; + else p = 0; + // else + // p = wall[ps[snum].access_wallnum].pal; + + if((ps[snum].access_incs-3) > 0 && (ps[snum].access_incs-3)>>3) + myospal(170+(sync[snum].avel>>4)-(ps[snum].look_ang>>1)+(access_y[ps[snum].access_incs]>>2),looking_arc+266-((ps[snum].horiz-ps[snum].horizoff)>>4),HANDHOLDINGLASER+(ps[snum].access_incs>>3),gs,0,p); + else + myospal(170+(sync[snum].avel>>4)-(ps[snum].look_ang>>1)+(access_y[ps[snum].access_incs]>>2),looking_arc+266-((ps[snum].horiz-ps[snum].horizoff)>>4),HANDHOLDINGACCESS,gs,4,p); + + return 1; +} + +short fistsign; + +void displayweapon(short snum) +{ + long gun_pos, looking_arc, cw; + long weapon_xoffset, i, j, x1, y1, x2; + char o,pal; + signed char gs; + struct player_struct *p; + short *kb; + + p = &ps[snum]; + kb = &p->kickback_pic; + + o = 0; + + looking_arc = klabs(p->look_ang)/9; + + gs = sprite[p->i].shade; + if(gs > 24) gs = 24; + + if(p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (sprite[p->i].pal != 1 && sprite[p->i].extra <= 0) || animatefist(gs,snum) || animateknuckles(gs,snum) || animatetip(gs,snum) || animateaccess(gs,snum) ) + return; + + animateknee(gs,snum); + + gun_pos = 80-(p->weapon_pos*p->weapon_pos); + + weapon_xoffset = (160)-90; + weapon_xoffset -= (sintable[((p->weapon_sway>>1)+512)&2047]/(1024+512)); + weapon_xoffset -= 58 + p->weapon_ang; + if( sprite[p->i].xrepeat < 32 ) + gun_pos -= klabs(sintable[(p->weapon_sway<<2)&2047]>>9); + else gun_pos -= klabs(sintable[(p->weapon_sway>>1)&2047]>>10); + + gun_pos -= (p->hard_landing<<3); + + if(p->last_weapon >= 0) + { + cw = aplWeaponWorksLike[p->last_weapon][snum]; + } + else + { + cw = aplWeaponWorksLike[p->curr_weapon][snum]; + } + + g_gun_pos=gun_pos; + g_looking_arc=looking_arc; + g_currentweapon=cw; + g_weapon_xoffset=weapon_xoffset; + g_gs=gs; + g_kb=*kb; + g_looking_angSR1=p->look_ang>>1; + + SetGameVarID(g_iReturnVarID,0,p->i,snum); + OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1); + + if(GetGameVarID(g_iReturnVarID,p->i,snum) == 0) + { + j = 14-p->quick_kick; + if(j != 14) + { + if(sprite[p->i].pal == 1) + pal = 1; + else + { + pal = sector[p->cursectnum].floorpal; + if(pal == 0) + pal = p->palookup; + } + + + if( j < 5 || j > 9 ) + myospal(weapon_xoffset+80-(p->look_ang>>1), + looking_arc+250-gun_pos,KNEE,gs,o|4,pal); + else myospal(weapon_xoffset+160-16-(p->look_ang>>1), + looking_arc+214-gun_pos,KNEE+1,gs,o|4,pal); + } + + if( sprite[p->i].xrepeat < 40 ) + { + if(p->jetpack_on == 0 ) + { + i = sprite[p->i].xvel; + looking_arc += 32-(i>>1); + fistsign += i>>1; + } + cw = weapon_xoffset; + weapon_xoffset += sintable[(fistsign)&2047]>>10; + myos(weapon_xoffset+250-(p->look_ang>>1), + looking_arc+258-(klabs(sintable[(fistsign)&2047]>>8)), + FIST,gs,o); + weapon_xoffset = cw; + weapon_xoffset -= sintable[(fistsign)&2047]>>10; + myos(weapon_xoffset+40-(p->look_ang>>1), + looking_arc+200+(klabs(sintable[(fistsign)&2047]>>8)), + FIST,gs,o|4); + } + else switch(cw) + + { + + case KNEE_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + if( (*kb) > 0 ) + { + if(sprite[p->i].pal == 1) + pal = 1; + else + { + pal = sector[p->cursectnum].floorpal; + if(pal == 0) + pal = p->palookup; + } + + if(*aplWeaponRenderSize[KNEE_WEAPON] == 0) + { + if( (*kb) < 5 || (*kb) > 9 ) + myospal(weapon_xoffset+220-(p->look_ang>>1), + looking_arc+250-gun_pos,KNEE,gs,o,pal); + else + myospal(weapon_xoffset+160-(p->look_ang>>1), + looking_arc+214-gun_pos,KNEE+1,gs,o,pal); + } + else + { + if( (*kb) < 5 || (*kb) > 9 ) + myospalx(weapon_xoffset+220-(p->look_ang>>1), + looking_arc+250-gun_pos,KNEE,gs,o,pal); + else + myospalx(weapon_xoffset+160-(p->look_ang>>1), + looking_arc+214-gun_pos,KNEE+1,gs,o,pal); + } + } + } + break; + + case TRIPBOMB_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + weapon_xoffset += 8; + gun_pos -= 10; + + if(*aplWeaponRenderSize[TRIPBOMB_WEAPON] == 0) + { + if((*kb) > 6) + looking_arc += ((*kb)<<3); + else if((*kb) < 4) + + myospal(weapon_xoffset+142-(p->look_ang>>1), + looking_arc+234-gun_pos,HANDHOLDINGLASER+3,gs,o,pal); + + myospal(weapon_xoffset+130-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o,pal); + myospal(weapon_xoffset+152-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o|4,pal); + } + else + { + if((*kb) > 6) + looking_arc += ((*kb)<<3); + else if((*kb) < 4) + + myospalx(weapon_xoffset+142-(p->look_ang>>1), + looking_arc+234-gun_pos,HANDHOLDINGLASER+3,gs,o,pal); + + myospalx(weapon_xoffset+130-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o,pal); + myospalx(weapon_xoffset+152-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o|4,pal); + } + } + break; + + case RPG_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + if(sprite[p->i].pal == 1) + pal = 1; + else pal = sector[p->cursectnum].floorpal; + + weapon_xoffset -= sintable[(768+((*kb)<<7))&2047]>>11; + gun_pos += sintable[(768+((*kb)<<7))&2047]>>11; + + if(*aplWeaponRenderSize[RPG_WEAPON] == 0) + { + if(*kb > 0) + { + if(*kb < 8) + { + myospal(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN+((*kb)>>1),gs,o,pal); + } + } + + myospal(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN,gs,o,pal); + } + + else + + { + + if(*kb > 0) + { + if(*kb < 8) + { + myospalx(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN+((*kb)>>1),gs,o,pal); + } + } + + myospalx(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN,gs,o,pal); + } + } + break; + + case SHOTGUN_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + + weapon_xoffset -= 8; + + if(*aplWeaponRenderSize[SHOTGUN_WEAPON] == 0) + { + switch(*kb) + { + case 1: + case 2: + myospal(weapon_xoffset+168-(p->look_ang>>1),looking_arc+201-gun_pos, + SHOTGUN+2,-128,o,pal); + case 0: + case 6: + case 7: + case 8: + myospal(weapon_xoffset+146-(p->look_ang>>1),looking_arc+202-gun_pos, + SHOTGUN,gs,o,pal); + break; + case 3: + case 4: + case 5: + case 9: + case 10: + case 11: + case 12: + if( *kb > 1 && *kb < 5 ) + { + gun_pos -= 40; + weapon_xoffset += 20; + + myospal(weapon_xoffset+178-(p->look_ang>>1),looking_arc+194-gun_pos, + SHOTGUN+1+((*(kb)-1)>>1),-128,o,pal); + } + + myospal(weapon_xoffset+158-(p->look_ang>>1),looking_arc+220-gun_pos, + SHOTGUN+3,gs,o,pal); + + break; + case 13: + case 14: + case 15: + myospal(32+weapon_xoffset+166-(p->look_ang>>1),looking_arc+210-gun_pos, + SHOTGUN+4,gs,o,pal); + break; + case 16: + case 17: + case 18: + case 19: + myospal(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + break; + case 20: + case 21: + case 22: + case 23: + myospal(64+weapon_xoffset+176-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+6,gs,o,pal); + break; + case 24: + case 25: + case 26: + case 27: + myospal(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + break; + case 28: + case 29: + case 30: + myospal(32+weapon_xoffset+156-(p->look_ang>>1),looking_arc+206-gun_pos, + SHOTGUN+4,gs,o,pal); + break; + } + } + else + + { + + switch(*kb) + { + case 1: + case 2: + myospalx(weapon_xoffset+168-(p->look_ang>>1),looking_arc+201-gun_pos, + SHOTGUN+2,-128,o,pal); + case 0: + case 6: + case 7: + case 8: + myospalx(weapon_xoffset+146-(p->look_ang>>1),looking_arc+202-gun_pos, + SHOTGUN,gs,o,pal); + break; + case 3: + case 4: + case 5: + case 9: + case 10: + case 11: + case 12: + if( *kb > 1 && *kb < 5 ) + { + gun_pos -= 40; + weapon_xoffset += 20; + + myospalx(weapon_xoffset+178-(p->look_ang>>1),looking_arc+194-gun_pos, + SHOTGUN+1+((*(kb)-1)>>1),-128,o,pal); + } + + myospalx(weapon_xoffset+158-(p->look_ang>>1),looking_arc+220-gun_pos, + SHOTGUN+3,gs,o,pal); + + break; + case 13: + case 14: + case 15: + myospalx(32+weapon_xoffset+166-(p->look_ang>>1),looking_arc+210-gun_pos, + SHOTGUN+4,gs,o,pal); + break; + case 16: + case 17: + case 18: + case 19: + myospalx(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + break; + case 20: + case 21: + case 22: + case 23: + myospalx(64+weapon_xoffset+176-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+6,gs,o,pal); + break; + case 24: + case 25: + case 26: + case 27: + myospalx(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + break; + case 28: + case 29: + case 30: + myospalx(32+weapon_xoffset+156-(p->look_ang>>1),looking_arc+206-gun_pos, + SHOTGUN+4,gs,o,pal); + break; + } + } + } + break; + + + case CHAINGUN_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if(*kb > 0) + gun_pos -= sintable[(*kb)<<7]>>12; + + if(*kb > 0 && sprite[p->i].pal != 1) weapon_xoffset += 1-(rand()&3); + + if(*aplWeaponRenderSize[CHAINGUN_WEAPON] == 0) + { + + myospal(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, + CHAINGUN,gs,o,pal); + switch(*kb) + { + case 0: + myospal(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + default: + if(*kb > *aplWeaponFireDelay[CHAINGUN_WEAPON] && *kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]) + { + i = 0; + if(sprite[p->i].pal != 1) i = rand()&7; + myospal(i+weapon_xoffset-4+140-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); + if(sprite[p->i].pal != 1) i = rand()&7; + myospal(i+weapon_xoffset-4+184-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); + } + if(*kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]-2) + { + i = rand()&7; + myospal(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-2)/5),gs,o,pal); + myospal(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1+((*kb)>>1),gs,o,pal); + } + else myospal(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + } + } + else + { + + myospalx(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, + CHAINGUN,gs,o,pal); + switch(*kb) + { + case 0: + myospalx(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + default: + if(*kb > *aplWeaponFireDelay[CHAINGUN_WEAPON] && *kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]) + { + i = 0; + if(sprite[p->i].pal != 1) i = rand()&7; + myospalx(i+weapon_xoffset-4+140-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); + if(sprite[p->i].pal != 1) i = rand()&7; + myospalx(i+weapon_xoffset-4+184-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); + } + if(*kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]-4) + { + i = rand()&7; + myospalx(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-2)/5),gs,o,pal); + myospalx(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1+((*kb)>>1),gs,o,pal); + } + else myospalx(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + } + } + } + break; + + case PISTOL_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if(*aplWeaponRenderSize[PISTOL_WEAPON] == 0) + { + if( (*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) + { + short kb_frames[] = {0,1,2,0,0,0,0},l; + + l = 195-12+weapon_xoffset; + + if((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) + l -= 3; + + myospal((l-(p->look_ang>>1)),(looking_arc+244-gun_pos),FIRSTGUN+kb_frames[*kb],gs,2,pal); + } + else + { + + if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-17) + myospal(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o,pal); + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-12) + { + myospal(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o,pal); + myospal(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + } + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-7) + { + myospal(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o,pal); + myospal(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + } + + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-4) + { + myospal(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o,pal); + myospal(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o,pal); + } + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-2) + { + myospal(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o,pal); + myospal(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + } + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]) + myospal(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o,pal); + + } + } + else + { + if( (*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) + { + short kb_frames[] = {0,1,2,0,0,0,0},l; + + l = 195-12+weapon_xoffset; + + if((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) + l -= 3; + + myospalx((l-(p->look_ang>>1)),(looking_arc+244-gun_pos),FIRSTGUN+kb_frames[*kb],gs,2,pal); + } + else + { + + if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-17) + myospalx(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o,pal); + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-12) + { + myospalx(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o,pal); + myospalx(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + } + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-7) + { + myospalx(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o,pal); + myospalx(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + } + + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-4) + { + myospalx(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o,pal); + myospalx(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o,pal); + } + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]-2) + { + myospalx(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o,pal); + myospalx(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + } + else if((*kb) < *aplWeaponReload[PISTOL_WEAPON]) + myospalx(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o,pal); + + } + } + } + + break; + case HANDBOMB_WEAPON: + { + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if(*aplWeaponRenderSize[HANDBOMB_WEAPON] == 0) + { + + if((*kb)) + { + if((*kb) < (*aplWeaponTotalTime[p->curr_weapon])) + { + + char throw_frames[] + = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; + + if((*kb) < 7) + gun_pos -= 10*(*kb); //D + else if((*kb) < 12) + gun_pos += 20*((*kb)-10); //U + else if((*kb) < 20) + gun_pos -= 9*((*kb)-14); //D + + myospal(weapon_xoffset+190-(p->look_ang>>1),looking_arc+250-gun_pos,HANDTHROW+throw_frames[(*kb)],gs,o,pal); + } + } + else + myospal(weapon_xoffset+190-(p->look_ang>>1),looking_arc+260-gun_pos,HANDTHROW,gs,o,pal); + } + else + { + + if((*kb)) + { + char throw_frames[] + = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; + + if((*kb) < 7) + gun_pos -= 10*(*kb); //D + else if((*kb) < 12) + gun_pos += 20*((*kb)-10); //U + else if((*kb) < 20) + gun_pos -= 9*((*kb)-14); //D + + myospalx(weapon_xoffset+190-(p->look_ang>>1),looking_arc+250-gun_pos,HANDTHROW+throw_frames[(*kb)],gs,o,pal); + } + else + myospalx(weapon_xoffset+190-(p->look_ang>>1),looking_arc+260-gun_pos,HANDTHROW,gs,o,pal); + } + } + } + break; + + case HANDREMOTE_WEAPON: + { + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + signed char remote_frames[] = {0,1,1,2,1,1,0,0,0,0,0}; + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + weapon_xoffset = -48; + if(*aplWeaponRenderSize[HANDREMOTE_WEAPON] == 0) + { + if((*kb)) + myospal(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE+remote_frames[(*kb)],gs,o,pal); + else + myospal(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE,gs,o,pal); + } + else + { + if((*kb)) + myospalx(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE+remote_frames[(*kb)],gs,o,pal); + else + myospalx(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE,gs,o,pal); + } + } + } + break; + + case DEVISTATOR_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if(*aplWeaponRenderSize[DEVISTATOR_WEAPON] == 0) + { + if((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) + { + char cycloidy[] = {0,4,12,24,12,4,0}; + + i = ksgn((*kb)>>2); + + if(p->hbomb_hold_delay) + { + myospal( (cycloidy[*kb]>>1)+weapon_xoffset+268-(p->look_ang>>1),cycloidy[*kb]+looking_arc+238-gun_pos,DEVISTATOR+i,-32,o,pal); + myospal(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); + } + else + { + myospal( -(cycloidy[*kb]>>1)+weapon_xoffset+30-(p->look_ang>>1),cycloidy[*kb]+looking_arc+240-gun_pos,DEVISTATOR+i,-32,o|4,pal); + myospal(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + } + } + else + { + myospal(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + myospal(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); + } + } + else + { + if((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) + { + char cycloidy[] = {0,4,12,24,12,4,0}; + + i = ksgn((*kb)>>2); + + if(p->hbomb_hold_delay) + { + myospalx( (cycloidy[*kb]>>1)+weapon_xoffset+268-(p->look_ang>>1),cycloidy[*kb]+looking_arc+238-gun_pos,DEVISTATOR+i,-32,o,pal); + myospalx(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); + } + else + { + myospalx( -(cycloidy[*kb]>>1)+weapon_xoffset+30-(p->look_ang>>1),cycloidy[*kb]+looking_arc+240-gun_pos,DEVISTATOR+i,-32,o|4,pal); + myospalx(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + } + } + else + { + myospalx(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + myospalx(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); + } + } + } + break; + + case FREEZE_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + + if(*aplWeaponRenderSize[FREEZE_WEAPON] == 0) + { + if((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) + { + char cat_frames[] = { 0,0,1,1,2,2 }; + + if(sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + looking_arc += rand()&3; + } + gun_pos -= 16; + myospal(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE+2,-32,o,pal); + myospal(weapon_xoffset+210-(p->look_ang>>1),looking_arc+235-gun_pos,FREEZE+3+cat_frames[*kb%6],-32,o,pal); + } + else myospal(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE,gs,o,pal); + } + else + { + if((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) + { + char cat_frames[] = { 0,0,1,1,2,2 }; + + if(sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + looking_arc += rand()&3; + } + gun_pos -= 16; + myospalx(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE+2,-32,o,pal); + myospalx(weapon_xoffset+210-(p->look_ang>>1),looking_arc+235-gun_pos,FREEZE+3+cat_frames[*kb%6],-32,o,pal); + } + else myospalx(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE,gs,o,pal); + } + } + break; + + case GROW_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + weapon_xoffset += 28; + looking_arc += 18; + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + if(*aplWeaponRenderSize[GROW_WEAPON] == 0) + { + if((*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && (*kb) > 0) + { + if(sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + gun_pos += (rand()&3); + } + + myospal(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, + o,2); + + myospal(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER-1,gs,o,pal); + } + else + { + myospal(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+2, + 16-(sintable[p->random_club_frame&2047]>>10), + o,2); + + myospal(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER-2,gs,o,pal); + } + } + else + { + if((*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && (*kb) > 0) + { + if(sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + gun_pos += (rand()&3); + } + + myospalx(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, + o,2); + + myospalx(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER-1,gs,o,pal); + } + else + { + myospalx(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+2, + 16-(sintable[p->random_club_frame&2047]>>10), + o,2); + + myospalx(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER-2,gs,o,pal); + } + } + } + break; + + case SHRINKER_WEAPON: + + SetGameVarID(g_iReturnVarID,0,ps[screenpeek].i,screenpeek); + OnEvent(EVENT_DRAWWEAPON,ps[screenpeek].i,screenpeek, -1); + if(GetGameVarID(g_iReturnVarID,ps[screenpeek].i,screenpeek) == 0 && ud.drawweapon > 0) + { + weapon_xoffset += 28; + looking_arc += 18; + if(sprite[p->i].pal == 1) + pal = 1; + else + pal = sector[p->cursectnum].floorpal; + if(*aplWeaponRenderSize[SHRINKER_WEAPON] == 0) + { + if(((*kb) > 0) && ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum])) + { + if(sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + gun_pos += (rand()&3); + } + + myospal(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, + o,0); + + myospal(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+1,gs,o,pal); + + } + else + { + myospal(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+2, + 16-(sintable[p->random_club_frame&2047]>>10), + o,0); + + myospal(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER,gs,o,pal); + } + } + else + { + if(((*kb) > 0) && ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum])) + { + if(sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + gun_pos += (rand()&3); + } + + myospalx(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, + o,0); + myospalx(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+1,gs,o,pal); + } + else + { + myospalx(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+2, + 16-(sintable[p->random_club_frame&2047]>>10), + o,0); + + myospalx(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER,gs,o,pal); + } + } + } + break; + + } + } + displayloogie(snum); + +} + +#define TURBOTURNTIME (TICRATE/8) // 7 +#define NORMALTURN 15 +#define PREAMBLETURN 5 +#define NORMALKEYMOVE 40 +#define MAXVEL ((NORMALKEYMOVE*2)+10) +#define MAXSVEL ((NORMALKEYMOVE*2)+10) +#define MAXANGVEL 127 +#define MAXHORIZ 127 + +long myaimmode = 0, myaimstat = 0, omyaimstat = 0; + +static ControlInfo lastinfo = { 0,0,0,0,0,0 }; +void getinput(short snum) +{ + short j, daang; + // MED + ControlInfo info; + int32 tics; + boolean running; + int32 turnamount; + int32 keymove; + int32 momx,momy; + struct player_struct *p; + unsigned char tmpbuf[2048]; + + momx = momy = 0; + p = &ps[snum]; + + CONTROL_GetInput( &info ); + + info.dx += lastinfo.dx; + info.dy += lastinfo.dy; + info.dz += lastinfo.dz; + info.dyaw += lastinfo.dyaw; + info.dpitch += lastinfo.dpitch; + info.droll += lastinfo.droll; + memset(&lastinfo.dx, 0, sizeof(lastinfo)); + + if( (p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) ) + { + loc.fvel = vel = 0; + loc.svel = svel = 0; + loc.avel = angvel = 0; + loc.horz = horiz = 0; + loc.bits = (((long)gamequit)<<26); + info.dz = info.dyaw = 0; + return; + } + + tics = totalclock-lastcontroltime; + lastcontroltime = totalclock; + + if (ud.mouseaiming) + myaimmode = BUTTON(gamefunc_Mouse_Aiming); + else + { + omyaimstat = myaimstat; myaimstat = BUTTON(gamefunc_Mouse_Aiming); + if (myaimstat > omyaimstat) + { + myaimmode ^= 1; + FTA(44+myaimmode,p); + } + } + + if(multiflag == 1) + { + loc.bits = 1<<17; + loc.bits |= multiwhat<<18; + loc.bits |= multipos<<19; + multiflag = 0; + return; + } + + loc.bits = BUTTON(gamefunc_Jump); + loc.bits |= BUTTON(gamefunc_Crouch)<<1; + loc.bits |= BUTTON(gamefunc_Fire)<<2; + loc.bits |= BUTTON(gamefunc_Aim_Up)<<3; + loc.bits |= BUTTON(gamefunc_Aim_Down)<<4; + if (ud.runkey_mode) loc.bits |= (ud.auto_run | BUTTON(gamefunc_Run))<<5; + else loc.bits |= (BUTTON(gamefunc_Run) ^ ud.auto_run)<<5; + loc.bits |= BUTTON(gamefunc_Look_Left)<<6; + loc.bits |= BUTTON(gamefunc_Look_Right)<<7; + + if ( aplWeaponFlags[ps[snum].curr_weapon][snum] & WEAPON_FLAG_SEMIAUTO && BUTTON( gamefunc_Fire ) ) + CONTROL_ClearButton(gamefunc_Fire); + + j=0; + + if (BUTTON(gamefunc_Weapon_1)) + j = 1; + if (BUTTON(gamefunc_Weapon_2)) + j = 2; + if (BUTTON(gamefunc_Weapon_3)) + j = 3; + if (BUTTON(gamefunc_Weapon_4)) + j = 4; + if (BUTTON(gamefunc_Weapon_5)) + j = 5; + if (BUTTON(gamefunc_Weapon_6)) + j = 6; + if (BUTTON(gamefunc_Weapon_7)) + j = 7; + if (BUTTON(gamefunc_Weapon_8)) + j = 8; + if (BUTTON(gamefunc_Weapon_9)) + j = 9; + if (BUTTON(gamefunc_Weapon_10)) + j = 10; + if (BUTTON(gamefunc_Previous_Weapon)) + j = 11; + if (BUTTON(gamefunc_Next_Weapon)) + j = 12; + + loc.bits |= j<<8; + loc.bits |= BUTTON(gamefunc_Steroids)<<12; + loc.bits |= BUTTON(gamefunc_Look_Up)<<13; + loc.bits |= BUTTON(gamefunc_Look_Down)<<14; + loc.bits |= BUTTON(gamefunc_NightVision)<<15; + loc.bits |= BUTTON(gamefunc_MedKit)<<16; + loc.bits |= BUTTON(gamefunc_Center_View)<<18; + loc.bits |= BUTTON(gamefunc_Holster_Weapon)<<19; + loc.bits |= BUTTON(gamefunc_Inventory_Left)<<20; + loc.bits |= KB_KeyPressed(sc_Pause)<<21; + loc.bits |= BUTTON(gamefunc_Quick_Kick)<<22; + loc.bits |= myaimmode<<23; + loc.bits |= BUTTON(gamefunc_Holo_Duke)<<24; + loc.bits |= BUTTON(gamefunc_Jetpack)<<25; + loc.bits |= (((long)gamequit)<<26); + loc.bits |= BUTTON(gamefunc_Inventory_Right)<<27; + loc.bits |= BUTTON(gamefunc_TurnAround)<<28; + loc.bits |= BUTTON(gamefunc_Open)<<29; + loc.bits |= BUTTON(gamefunc_Inventory)<<30; + loc.bits |= KB_KeyPressed(sc_Escape)<<31; + + // running = BUTTON(gamefunc_Run)|ud.auto_run; + // JBF: Run key behaviour is selectable + if (ud.runkey_mode) + running = BUTTON(gamefunc_Run)|ud.auto_run; // classic + else + running = ud.auto_run^BUTTON(gamefunc_Run); // modern + + svel = vel = angvel = horiz = 0; + + if( CONTROL_JoystickEnabled ) + if ( running ) info.dz *= 2; + + if( BUTTON(gamefunc_Strafe) ) { + lastinfo.dyaw = info.dyaw % 8; + svel = -info.dyaw/8; + } else { + lastinfo.dyaw = info.dyaw % 64; + angvel = info.dyaw/64; + } + + if( myaimmode ) + { + lastinfo.dz = info.dz % (314-128); + if(ud.mouseflip) + horiz -= info.dz/(314-128); + else horiz += info.dz/(314-128); + + info.dz = 0; + } else { + lastinfo.dz = info.dz % (1<<6); + } + + svel -= info.dx; + vel = -info.dz>>6; + + if (running) + { + turnamount = NORMALTURN<<1; + keymove = NORMALKEYMOVE<<1; + } + else + { + turnamount = NORMALTURN; + keymove = NORMALKEYMOVE; + } + + if (BUTTON(gamefunc_Strafe)) + { + if ( BUTTON(gamefunc_Turn_Left) && (ps[snum].movement_lock[3] == 0)) + { + svel -= -keymove; + } + if ( BUTTON(gamefunc_Turn_Right) && (ps[snum].movement_lock[4] == 0)) + { + svel -= keymove; + } + } + else + { + if ( BUTTON(gamefunc_Turn_Left)) + { + turnheldtime += tics; + if (turnheldtime>=TURBOTURNTIME) + { + angvel -= turnamount; + } + else + { + angvel -= PREAMBLETURN; + } + } + else if ( BUTTON(gamefunc_Turn_Right)) + { + turnheldtime += tics; + if (turnheldtime>=TURBOTURNTIME) + { + angvel += turnamount; + } + else + { + angvel += PREAMBLETURN; + } + } + else + { + turnheldtime=0; + } + } + + if ( BUTTON(gamefunc_Strafe_Left) && (ps[snum].movement_lock[3] == 0)) + svel += keymove; + if ( BUTTON(gamefunc_Strafe_Right) && (ps[snum].movement_lock[4] == 0)) + svel += -keymove; + if ( BUTTON(gamefunc_Move_Forward) && (ps[snum].movement_lock[1] == 0)) + vel += keymove; + if ( BUTTON(gamefunc_Move_Backward) && (ps[snum].movement_lock[2] == 0)) + vel += -keymove; + + if(vel < -MAXVEL) vel = -MAXVEL; + if(vel > MAXVEL) vel = MAXVEL; + if(svel < -MAXSVEL) svel = -MAXSVEL; + if(svel > MAXSVEL) svel = MAXSVEL; + if(angvel < -MAXANGVEL) angvel = -MAXANGVEL; + if(angvel > MAXANGVEL) angvel = MAXANGVEL; + if(horiz < -MAXHORIZ) horiz = -MAXHORIZ; + if(horiz > MAXHORIZ) horiz = MAXHORIZ; + + loc.bits2 = BUTTON(gamefunc_Move_Forward); + loc.bits2 |= BUTTON(gamefunc_Move_Backward)<<1; + loc.bits2 |= BUTTON(gamefunc_Strafe_Left)<<2; + loc.bits2 |= BUTTON(gamefunc_Strafe_Right)<<3; + loc.bits2 |= BUTTON(gamefunc_Turn_Left)<<4; + loc.bits2 |= BUTTON(gamefunc_Turn_Right)<<5; + + if(ud.scrollmode && ud.overhead_on) + { + ud.folfvel = vel; + ud.folavel = angvel; + loc.fvel = 0; + loc.svel = 0; + loc.avel = 0; + loc.horz = 0; + return; + } + + if( numplayers > 1 ) + daang = myang; + else daang = p->ang; + + momx = mulscale9(vel,sintable[(daang+2560)&2047]); + momy = mulscale9(vel,sintable[(daang+2048)&2047]); + + momx += mulscale9(svel,sintable[(daang+2048)&2047]); + momy += mulscale9(svel,sintable[(daang+1536)&2047]); + + momx += fricxv; + momy += fricyv; + + if (momx == 0) momx = 1; // HACK; the game seems to "forget" about the rest of the data if we aren't moving + if (momy == 0) momy = 1; + + loc.fvel = momx; + loc.svel = momy; + + loc.avel = angvel; + loc.horz = horiz; +} + +char doincrements(struct player_struct *p) +{ + long /*j,*/i,snum; + + snum = sprite[p->i].yvel; + // j = sync[snum].avel; + // p->weapon_ang = -(j/5); + + p->player_par++; + + if(p->invdisptime > 0) + p->invdisptime--; + + if(p->tipincs > 0) p->tipincs--; + + if(p->last_pissed_time > 0 ) + { + p->last_pissed_time--; + + if( p->last_pissed_time == (26*219) ) + { + spritesound(FLUSH_TOILET,p->i); + if(snum == screenpeek || (gametype_flags[ud.coop] & GAMETYPE_FLAG_COOPSOUND)) + spritesound(DUKE_PISSRELIEF,p->i); + } + + if( p->last_pissed_time == (26*218) ) + { + p->holster_weapon = 0; + p->weapon_pos = 10; + } + } + + if(p->crack_time > 0) + { + p->crack_time--; + if(p->crack_time == 0) + { + p->knuckle_incs = 1; + p->crack_time = 777; + } + } + + if( p->steroids_amount > 0 && p->steroids_amount < 400) + { + p->steroids_amount--; + if(p->steroids_amount == 0) + checkavailinven(p); + if( !(p->steroids_amount&7) ) + if(snum == screenpeek || (gametype_flags[ud.coop] & GAMETYPE_FLAG_COOPSOUND)) + spritesound(DUKE_HARTBEAT,p->i); + } + + if(p->heat_on && p->heat_amount > 0) + { + p->heat_amount--; + if( p->heat_amount == 0 ) + { + p->heat_on = 0; + checkavailinven(p); + spritesound(NITEVISION_ONOFF,p->i); + setpal(p); + } + } + + if( p->holoduke_on >= 0 ) + { + p->holoduke_amount--; + if(p->holoduke_amount <= 0) + { + spritesound(TELEPORTER,p->i); + p->holoduke_on = -1; + checkavailinven(p); + } + } + + if( p->jetpack_on && p->jetpack_amount > 0 ) + { + p->jetpack_amount--; + if(p->jetpack_amount <= 0) + { + p->jetpack_on = 0; + checkavailinven(p); + spritesound(DUKE_JETPACK_OFF,p->i); + stopspritesound(DUKE_JETPACK_IDLE,p->i); + stopspritesound(DUKE_JETPACK_ON,p->i); + } + } + + if(p->quick_kick > 0 && sprite[p->i].pal != 1) + { + p->quick_kick--; + if( p->quick_kick == 8 ) + shoot(p->i,KNEE); + } + + if(p->access_incs && sprite[p->i].pal != 1) + { + p->access_incs++; + if(sprite[p->i].extra <= 0) + p->access_incs = 12; + if(p->access_incs == 12) + { + if(p->access_spritenum >= 0) + { + checkhitswitch(snum,p->access_spritenum,1); + switch(sprite[p->access_spritenum].pal) + { + case 0:p->got_access &= (0xffff-0x1);break; + case 21:p->got_access &= (0xffff-0x2);break; + case 23:p->got_access &= (0xffff-0x4);break; + } + p->access_spritenum = -1; + } + else + { + checkhitswitch(snum,p->access_wallnum,0); + switch(wall[p->access_wallnum].pal) + { + case 0:p->got_access &= (0xffff-0x1);break; + case 21:p->got_access &= (0xffff-0x2);break; + case 23:p->got_access &= (0xffff-0x4);break; + } + } + } + + if(p->access_incs > 20) + { + p->access_incs = 0; + p->weapon_pos = 10; + p->kickback_pic = 0; + } + } + + if(p->scuba_on == 0 && sector[p->cursectnum].lotag == 2) + { + if(p->scuba_amount > 0) + { + p->scuba_on = 1; + p->inven_icon = 6; + FTA(76,p); + } + else + { + if(p->airleft > 0) + p->airleft--; + else + { + p->extra_extra8 += 32; + if(p->last_extra < (max_player_health>>1) && (p->last_extra&3) == 0) + spritesound(DUKE_LONGTERM_PAIN,p->i); + } + } + } + else if(p->scuba_amount > 0 && p->scuba_on) + { + p->scuba_amount--; + if(p->scuba_amount == 0) + { + p->scuba_on = 0; + checkavailinven(p); + } + } + + if(p->knuckle_incs) + { + p->knuckle_incs ++; + if(p->knuckle_incs==10) + { + if(totalclock > 1024) + if(snum == screenpeek || (gametype_flags[ud.coop] & GAMETYPE_FLAG_COOPSOUND)) + { + + if(rand()&1) + spritesound(DUKE_CRACK,p->i); + else spritesound(DUKE_CRACK2,p->i); + + } + + spritesound(DUKE_CRACK_FIRST,p->i); + + } + else if( p->knuckle_incs == 22 || (sync[snum].bits&(1<<2))) + p->knuckle_incs=0; + + return 1; + } + return 0; +} + +short weapon_sprites[MAX_WEAPONS] = { KNEE__STATIC, FIRSTGUNSPRITE__STATIC, SHOTGUNSPRITE__STATIC, + CHAINGUNSPRITE__STATIC, RPGSPRITE__STATIC, HEAVYHBOMB__STATIC, SHRINKERSPRITE__STATIC, DEVISTATORSPRITE__STATIC, + TRIPBOMBSPRITE__STATIC, FREEZESPRITE__STATIC, HEAVYHBOMB__STATIC, SHRINKERSPRITE__STATIC}; + +void checkweapons(struct player_struct *p) +{ + short j,cw; + + long snum; + + snum = sprite[p->i].yvel; + + cw = aplWeaponWorksLike[p->curr_weapon][snum]; + + if(cw < 1 || cw >= MAX_WEAPONS) return; + + if(cw) + { + if(TRAND&1) + spawn(p->i,weapon_sprites[cw]); + else switch(cw) + { + case RPG_WEAPON: + case HANDBOMB_WEAPON: + spawn(p->i,EXPLOSION2); + break; + } + } +} + +void processinput(short snum) +{ + long j, i, k, doubvel, fz, cz, hz, lz, truefdist, x, y; + char shrunk; + unsigned long sb_snum; + short psect, psectlotag,*kb, tempsect, pi; + struct player_struct *p; + spritetype *s; + + p = &ps[snum]; + pi = p->i; + s = &sprite[pi]; + + kb = &p->kickback_pic; + + OnEvent(EVENT_PROCESSINPUT, pi, snum, -1); + + if(p->cheat_phase <= 0) sb_snum = sync[snum].bits; + else sb_snum = 0; + + if((sb_snum&(1<<2))) + { + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_PRESSEDFIRE, pi, snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) != 0) + sb_snum &= ~(1<<2); + } + + psect = p->cursectnum; + if(psect == -1) + { + if(s->extra > 0 && ud.clipping == 0) + { + quickkill(p); + spritesound(SQUISHED,pi); + } + psect = 0; + } + + psectlotag = sector[psect].lotag; + p->spritebridge = 0; + p->sbs = 0; + + shrunk = (s->yrepeat < 32); + getzrange(p->posx,p->posy,p->posz,psect,&cz,&hz,&fz,&lz,163L,CLIPMASK0); + + j = getflorzofslope(psect,p->posx,p->posy); + + p->truefz = j; + p->truecz = getceilzofslope(psect,p->posx,p->posy); + + truefdist = klabs(p->posz-j); + if( (lz&49152) == 16384 && psectlotag == 1 && truefdist > PHEIGHT+(16<<8) ) + psectlotag = 0; + + hittype[pi].floorz = fz; + hittype[pi].ceilingz = cz; + + p->ohoriz = p->horiz; + p->ohorizoff = p->horizoff; + + if( p->aim_mode == 0 && p->on_ground && psectlotag != 2 && (sector[psect].floorstat&2) ) + { + x = p->posx+(sintable[(p->ang+512)&2047]>>5); + y = p->posy+(sintable[p->ang&2047]>>5); + tempsect = psect; + updatesector(x,y,&tempsect); + if (tempsect >= 0) + { + k = getflorzofslope(psect,x,y); + if (psect == tempsect) + p->horizoff += mulscale16(j-k,160); + else if (klabs(getflorzofslope(tempsect,x,y)-k) <= (4<<8)) + p->horizoff += mulscale16(j-k,160); + } + } + + if (p->horizoff > 0) p->horizoff -= ((p->horizoff>>3)+1); + else if (p->horizoff < 0) p->horizoff += (((-p->horizoff)>>3)+1); + + if( hz >= 0 && (hz&49152) == 49152) + { + hz &= (MAXSPRITES-1); + + if(sprite[hz].statnum == 1 && sprite[hz].extra >= 0) + { + hz = 0; + cz = p->truecz; + } + } + + if(lz >= 0 && (lz&49152) == 49152) + { + j = lz&(MAXSPRITES-1); + + if( (sprite[j].cstat&33) == 33 ) + { + psectlotag = 0; + p->footprintcount = 0; + p->spritebridge = 1; + p->sbs = j; + } + else if(badguy(&sprite[j]) && sprite[j].xrepeat > 24 && klabs(s->z-sprite[j].z) < (84<<8) ) + { + j = getangle(sprite[j].x-p->posx,sprite[j].y-p->posy); + p->posxv -= sintable[(j+512)&2047]<<4; + p->posyv -= sintable[j&2047]<<4; + } + } + + + if ( s->extra > 0 ) incur_damage( snum ); + else + { + s->extra = 0; + p->shield_amount = 0; + } + + p->last_extra = s->extra; + + if(p->loogcnt > 0) p->loogcnt--; + else p->loogcnt = 0; + + if(p->fist_incs) + { + // the fist puching the end-of-level thing... + p->fist_incs++; + if(p->fist_incs == 28) + { + if(ud.recstat == 1) closedemowrite(); + sound(PIPEBOMB_EXPLODE); + p->pals[0] = 64; + p->pals[1] = 64; + p->pals[2] = 64; + p->pals_time = 48; + } + if(p->fist_incs > 42) + { + if(p->buttonpalette && ud.from_bonus == 0) + { + ud.from_bonus = ud.level_number+1; + if(ud.secretlevel > 0 && ud.secretlevel < 12) ud.level_number = ud.secretlevel-1; + ud.m_level_number = ud.level_number; + } + else + { + if(ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + if(ud.level_number == ud.secretlevel && ud.from_bonus > 0 ) + ud.level_number = ud.from_bonus; + else ud.level_number++; + + if(ud.level_number > 10) ud.level_number = 0; + ud.m_level_number = ud.level_number; + + } + } + for(i=connecthead;i>=0;i=connectpoint2[i]) + ps[i].gm = MODE_EOL; + p->fist_incs = 0; + + return; + } + } + + if(p->timebeforeexit > 1 && p->last_extra > 0) + { + p->timebeforeexit--; + if(p->timebeforeexit == 26*5) + { + FX_StopAllSounds(); + clearsoundlocks(); + if(p->customexitsound >= 0) + { + sound(p->customexitsound); + FTA(102,p); + } + } + else if(p->timebeforeexit == 1) + { + for(i=connecthead;i>=0;i=connectpoint2[i]) + ps[i].gm = MODE_EOL; + if(ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + ud.level_number++; + ud.m_level_number = ud.level_number; + } + return; + } + } + /* + if(p->select_dir) + { + if(psectlotag != 15 || (sb_snum&(1<<31)) ) + p->select_dir = 0; + else + { + if(sync[snum].fvel > 127) + { + p->select_dir = 0; + activatewarpelevators(pi,-1); + } + else if(sync[snum].fvel <= -127) + { + p->select_dir = 0; + activatewarpelevators(pi,1); + } + return; + } + } + */ + + if(p->pals_time >= 0) + p->pals_time--; + + if(p->fta > 0) + { + p->fta--; + if(p->fta == 0) + { + pub = NUMPAGES; + pus = NUMPAGES; + p->ftq = 0; + } + } + + if( s->extra <= 0 ) + { + if(p->dead_flag == 0) + { + if(s->pal != 1) + { + p->pals[0] = 63; + p->pals[1] = 0; + p->pals[2] = 0; + p->pals_time = 63; + p->posz -= (16<<8); + s->z -= (16<<8); + } + + if(ud.recstat == 1 && ud.multimode < 2) + closedemowrite(); + + if(s->pal != 1) + p->dead_flag = (512-((TRAND&1)<<10)+(TRAND&255)-512)&2047; + + p->jetpack_on = 0; + p->holoduke_on = -1; + + stopspritesound(DUKE_JETPACK_IDLE,p->i); + if(p->scream_voice > FX_Ok) + { + FX_StopSound(p->scream_voice); + testcallback(DUKE_SCREAM); + p->scream_voice = FX_Ok; + } + + if( s->pal != 1 && (s->cstat&32768) == 0) s->cstat = 0; + + if( ud.multimode > 1 && ( s->pal != 1 || (s->cstat&32768) ) ) + { + if(p->frag_ps != snum) + { + ps[p->frag_ps].frag++; + frags[p->frag_ps][snum]++; + + if( ud.user_name[p->frag_ps][0] != 0) + { + if(snum == screenpeek) + { + Bsprintf(&fta_quotes[115][0],"KILLED BY %s",&ud.user_name[p->frag_ps][0]); + FTA(115,p); + } + else + { + Bsprintf(&fta_quotes[116][0],"KILLED %s",&ud.user_name[snum][0]); + FTA(116,&ps[p->frag_ps]); + } + } + else + { + if(snum == screenpeek) + { + Bsprintf(&fta_quotes[115][0],"KILLED BY PLAYER %d",1+p->frag_ps); + FTA(115,p); + } + else + { + Bsprintf(&fta_quotes[116][0],"KILLED PLAYER %d",1+snum); + FTA(116,&ps[p->frag_ps]); + } + } + } + else p->fraggedself++; + + if(myconnectindex == connecthead) + { + unsigned char tmpbuf[2048]; + Bsprintf(tmpbuf,"frag %d killed %d\n",p->frag_ps+1,snum+1); + sendscore(tmpbuf); + // printf(tempbuf); + } + + p->frag_ps = snum; + pus = NUMPAGES; + } + } + + if( psectlotag == 2 ) + { + if(p->on_warping_sector == 0) + { + if( klabs(p->posz-fz) > (PHEIGHT>>1)) + p->posz += 348; + } + else + { + s->z -= 512; + s->zvel = -348; + } + + clipmove(&p->posx,&p->posy, + &p->posz,&p->cursectnum, + 0,0,164L,(4L<<8),(4L<<8),CLIPMASK0); + // p->bobcounter += 32; + } + + p->oposx = p->posx; + p->oposy = p->posy; + p->oposz = p->posz; + p->oang = p->ang; + p->opyoff = p->pyoff; + + p->horiz = 100; + p->horizoff = 0; + + updatesector(p->posx,p->posy,&p->cursectnum); + + pushmove(&p->posx,&p->posy,&p->posz,&p->cursectnum,128L,(4L<<8),(20L<<8),CLIPMASK0); + + if( fz > cz+(16<<8) && s->pal != 1) + p->rotscrnang = (p->dead_flag + ( (fz+p->posz)>>7))&2047; + + p->on_warping_sector = 0; + + return; + } + + if(p->transporter_hold > 0) + { + p->transporter_hold--; + if(p->transporter_hold == 0 && p->on_warping_sector) + p->transporter_hold = 2; + } + if(p->transporter_hold < 0) + p->transporter_hold++; + + if(p->newowner >= 0) + { + i = p->newowner; + p->posx = SX; + p->posy = SY; + p->posz = SZ; + p->ang = SA; + p->posxv = p->posyv = s->xvel = 0; + p->look_ang = 0; + p->rotscrnang = 0; + + doincrements(p); + + if(*aplWeaponWorksLike[p->curr_weapon] == HANDREMOTE_WEAPON) + { + goto SHOOTINCODE; + } + + return; + } + + doubvel = TICSPERFRAME; + + if (p->rotscrnang > 0) p->rotscrnang -= ((p->rotscrnang>>1)+1); + else if (p->rotscrnang < 0) p->rotscrnang += (((-p->rotscrnang)>>1)+1); + + p->look_ang -= (p->look_ang>>2); + + if( sb_snum&(1<<6) ) + { + // look_left + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_LOOKLEFT,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + p->look_ang -= 152; + p->rotscrnang += 24; + } + } + + if( sb_snum&(1<<7) ) + { + // look_right + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_LOOKRIGHT,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + p->look_ang += 152; + p->rotscrnang -= 24; + } + } + + if(p->on_crane >= 0) + goto HORIZONLY; + + j = ksgn(sync[snum].avel); + /* + if( j && ud.screen_tilting == 2) + { + k = 4; + if(sb_snum&(1<<5)) k <<= 2; + p->rotscrnang -= k*j; + p->look_ang += k*j; + } + */ + + if( s->xvel < 32 || p->on_ground == 0 || p->bobcounter == 1024 ) + { + if( (p->weapon_sway&2047) > (1024+96) ) + p->weapon_sway -= 96; + else if( (p->weapon_sway&2047) < (1024-96) ) + p->weapon_sway += 96; + else p->weapon_sway = 1024; + } + else p->weapon_sway = p->bobcounter; + + s->xvel = + ksqrt( (p->posx-p->bobposx)*(p->posx-p->bobposx)+(p->posy-p->bobposy)*(p->posy-p->bobposy)); + if(p->on_ground) p->bobcounter += sprite[p->i].xvel>>1; + + if( ud.clipping == 0 && ( sector[p->cursectnum].floorpicnum == MIRROR || p->cursectnum < 0 || p->cursectnum >= MAXSECTORS) ) + { + p->posx = p->oposx; + p->posy = p->oposy; + } + else + { + p->oposx = p->posx; + p->oposy = p->posy; + } + + p->bobposx = p->posx; + p->bobposy = p->posy; + + p->oposz = p->posz; + p->opyoff = p->pyoff; + p->oang = p->ang; + + if(p->one_eighty_count < 0) + { + p->one_eighty_count += 128; + p->ang += 128; + } + + // Shrinking code + + i = 40; + + if( psectlotag == 2) + { + // under water + p->jumping_counter = 0; + + p->pycount += 32; + p->pycount &= 2047; + p->pyoff = sintable[p->pycount]>>7; + + if(!isspritemakingsound(pi,DUKE_UNDERWATER)) + spritesound(DUKE_UNDERWATER,pi); + + if ( sb_snum&1 ) + { + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_SWIMUP,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + // jump + if(p->poszv > 0) p->poszv = 0; + p->poszv -= 348; + if(p->poszv < -(256*6)) p->poszv = -(256*6); + } + } + else if (sb_snum&(1<<1)) + { + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_SWIMDOWN,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + // crouch + if(p->poszv < 0) p->poszv = 0; + p->poszv += 348; + if(p->poszv > (256*6)) p->poszv = (256*6); + } + } + else + { + // normal view + if(p->poszv < 0) + { + p->poszv += 256; + if(p->poszv > 0) + p->poszv = 0; + } + if(p->poszv > 0) + { + p->poszv -= 256; + if(p->poszv < 0) + p->poszv = 0; + } + } + + if(p->poszv > 2048) + p->poszv >>= 1; + + p->posz += p->poszv; + + if(p->posz > (fz-(15<<8)) ) + p->posz += ((fz-(15<<8))-p->posz)>>1; + + if(p->posz < (cz+(4<<8)) ) + { + p->posz = cz+(4<<8); + p->poszv = 0; + } + + if( p->scuba_on && (TRAND&255) < 8 ) + { + j = spawn(pi,WATERBUBBLE); + sprite[j].x += + sintable[(p->ang+512+64-(global_random&128))&2047]>>6; + sprite[j].y += + sintable[(p->ang+64-(global_random&128))&2047]>>6; + sprite[j].xrepeat = 3; + sprite[j].yrepeat = 2; + sprite[j].z = p->posz+(8<<8); + } + } + + else if(p->jetpack_on) + { + p->on_ground = 0; + p->jumping_counter = 0; + p->hard_landing = 0; + p->falling_counter = 0; + + p->pycount += 32; + p->pycount &= 2047; + p->pyoff = sintable[p->pycount]>>7; + + if(p->jetpack_on < 11) + { + p->jetpack_on++; + p->posz -= (p->jetpack_on<<7); //Goin up + } + else if(p->jetpack_on == 11 && !isspritemakingsound(pi,DUKE_JETPACK_IDLE)) + spritesound(DUKE_JETPACK_IDLE,pi); + + if(shrunk) j = 512; + else j = 2048; + + if ( sb_snum&1 ) //A (soar high) + { + // jump + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_SOARUP,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + p->posz -= j; + p->crack_time = 777; + } + } + + if (sb_snum&(1<<1)) //Z (soar low) + { + // crouch + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_SOARDOWN,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + p->posz += j; + p->crack_time = 777; + } + } + + if( shrunk == 0 && (psectlotag == 0 || psectlotag == 2)) k = 32; + else k = 16; + + if( psectlotag != 2 && p->scuba_on == 1 ) + p->scuba_on = 0; + + if(p->posz > (fz-(k<<8)) ) + p->posz += ((fz-(k<<8))-p->posz)>>1; + if(p->posz < (hittype[pi].ceilingz+(18<<8)) ) + p->posz = hittype[pi].ceilingz+(18<<8); + + } + else if( psectlotag != 2 ) + { + if(p->airleft != 15*26) + p->airleft = 15*26; //Aprox twenty seconds. + + if(p->scuba_on == 1) + p->scuba_on = 0; + + if( psectlotag == 1 && p->spritebridge == 0) + { + if(shrunk == 0) + { + i = 34; + p->pycount += 32; + p->pycount &= 2047; + p->pyoff = sintable[p->pycount]>>6; + } + else i = 12; + + if(shrunk == 0 && truefdist <= PHEIGHT) + { + if(p->on_ground == 1) + { + if( p->dummyplayersprite == -1 ) + p->dummyplayersprite = + spawn(pi,PLAYERONWATER); + + p->footprintcount = 6; + if(sector[p->cursectnum].floorpicnum == FLOORSLIME) + p->footprintpal = 8; + else p->footprintpal = 0; + p->footprintshade = 0; + } + } + } + else + { + if(p->footprintcount > 0 && p->on_ground) + if( (sector[p->cursectnum].floorstat&2) != 2 ) + { + for(j=headspritesect[psect];j>=0;j=nextspritesect[j]) + if( sprite[j].picnum == FOOTPRINTS || sprite[j].picnum == FOOTPRINTS2 || sprite[j].picnum == FOOTPRINTS3 || sprite[j].picnum == FOOTPRINTS4 ) + if (klabs(sprite[j].x-p->posx) < 384) + if (klabs(sprite[j].y-p->posy) < 384) + break; + if(j < 0) + { + p->footprintcount--; + if( sector[p->cursectnum].lotag == 0 && sector[p->cursectnum].hitag == 0 ) + { + switch(TRAND&3) + { + case 0: j = spawn(pi,FOOTPRINTS); break; + case 1: j = spawn(pi,FOOTPRINTS2); break; + case 2: j = spawn(pi,FOOTPRINTS3); break; + default: j = spawn(pi,FOOTPRINTS4); break; + } + sprite[j].pal = p->footprintpal; + sprite[j].shade = p->footprintshade; + } + } + } + } + + if(p->posz < (fz-(i<<8)) ) //falling + { + + // not jumping or crouching + if( (sb_snum&3) == 0 && p->on_ground && (sector[psect].floorstat&2) && p->posz >= (fz-(i<<8)-(16<<8) ) ) + p->posz = fz-(i<<8); + else + { + p->on_ground = 0; + p->poszv += (gc+80); // (TICSPERFRAME<<6); + if(p->poszv >= (4096+2048)) p->poszv = (4096+2048); + if(p->poszv > 2400 && p->falling_counter < 255) + { + p->falling_counter++; + if( p->falling_counter == 38 ) + p->scream_voice = spritesound(DUKE_SCREAM,pi); + } + + if( (p->posz+p->poszv) >= (fz-(i<<8)) ) // hit the ground + if(sector[p->cursectnum].lotag != 1) + { + if( p->falling_counter > 62 ) quickkill(p); + + else if( p->falling_counter > 9 ) + { + j = p->falling_counter; + s->extra -= j-(TRAND&3); + if(s->extra <= 0) + { + spritesound(SQUISHED,pi); + p->pals[0] = 63; + p->pals[1] = 0; + p->pals[2] = 0; + p->pals_time = 63; + } + else + { + spritesound(DUKE_LAND,pi); + spritesound(DUKE_LAND_HURT,pi); + } + + p->pals[0] = 16; + p->pals[1] = 0; + p->pals[2] = 0; + p->pals_time = 32; + } + else if(p->poszv > 2048) spritesound(DUKE_LAND,pi); + } + } + } + + else + { + p->falling_counter = 0; + if(p->scream_voice > FX_Ok) + { + FX_StopSound(p->scream_voice); + p->scream_voice = FX_Ok; + } + + if(psectlotag != 1 && psectlotag != 2 && p->on_ground == 0 && p->poszv > (6144>>1)) + p->hard_landing = p->poszv>>10; + + p->on_ground = 1; + + if( i==40 ) + { + //Smooth on the ground + + k = ((fz-(i<<8))-p->posz)>>1; + if( klabs(k) < 256 ) k = 0; + p->posz += k; + p->poszv -= 768; + if(p->poszv < 0) p->poszv = 0; + } + else if(p->jumping_counter == 0) + { + p->posz += ((fz-(i<<7))-p->posz)>>1; //Smooth on the water + if(p->on_warping_sector == 0 && p->posz > fz-(16<<8)) + { + p->posz = fz-(16<<8); + p->poszv >>= 1; + } + } + + p->on_warping_sector = 0; + + if( (sb_snum&2) ) + { + // crouching + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_CROUCH,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + p->posz += (2048+768); + p->crack_time = 777; + } + } + + // jumping + if( (sb_snum&1) == 0 && p->jumping_toggle == 1) + p->jumping_toggle = 0; + + else if( (sb_snum&1) && p->jumping_toggle == 0 ) + { + if( p->jumping_counter == 0 ) + if( (fz-cz) > (56<<8) ) + { + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_JUMP,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + p->jumping_counter = 1; + p->jumping_toggle = 1; + } + } + } + + if( p->jumping_counter && (sb_snum&1) == 0 ) + p->jumping_toggle = 0; + } + + if(p->jumping_counter) + { + if( (sb_snum&1) == 0 && p->jumping_toggle == 1) + p->jumping_toggle = 0; + + if( p->jumping_counter < (1024+256) ) + { + if(psectlotag == 1 && p->jumping_counter > 768) + { + p->jumping_counter = 0; + p->poszv = -512; + } + else + { + p->poszv -= (sintable[(2048-128+p->jumping_counter)&2047])/12; + p->jumping_counter += 180; + p->on_ground = 0; + } + } + else + { + p->jumping_counter = 0; + p->poszv = 0; + } + } + + p->posz += p->poszv; + + if(p->posz < (cz+(4<<8))) + { + p->jumping_counter = 0; + if(p->poszv < 0) + p->posxv = p->posyv = 0; + p->poszv = 128; + p->posz = cz+(4<<8); + } + } + + //Do the quick lefts and rights + + if ( p->fist_incs || + p->transporter_hold > 2 || + p->hard_landing || + p->access_incs > 0 || + p->knee_incs > 0 || + (*aplWeaponWorksLike[p->curr_weapon] == TRIPBOMB_WEAPON && + *kb > 1 && + *kb < 4 ) ) + { + doubvel = 0; + p->posxv = 0; + p->posyv = 0; + } + else if ( sync[snum].avel ) //p->ang += syncangvel * constant + { //ENGINE calculates angvel for you + long tempang; + + tempang = sync[snum].avel<<1; + + if( psectlotag == 2 ) p->angvel =(tempang-(tempang>>3))*ksgn(doubvel); + else p->angvel = tempang*ksgn(doubvel); + + p->ang += p->angvel; + p->ang &= 2047; + p->crack_time = 777; + } + + if(p->spritebridge == 0) + { + j = sector[s->sectnum].floorpicnum; + + if( j == PURPLELAVA || sector[s->sectnum].ceilingpicnum == PURPLELAVA ) + { + if(p->boot_amount > 0) + { + p->boot_amount--; + p->inven_icon = 7; + if(p->boot_amount <= 0) + checkavailinven(p); + } + else + { + if(!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,pi); + p->pals[0] = 0; p->pals[1] = 8; p->pals[2] = 0; + p->pals_time = 32; + s->extra--; + } + } + + k = 0; + + if(p->on_ground && truefdist <= PHEIGHT+(16<<8)) + { + switch(dynamictostatic[j]) + { + case HURTRAIL__STATIC: + if( rnd(32) ) + { + if(p->boot_amount > 0) + k = 1; + else + { + if(!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,pi); + p->pals[0] = 64; p->pals[1] = 64; p->pals[2] = 64; + p->pals_time = 32; + s->extra -= 1+(TRAND&3); + if(!isspritemakingsound(pi,SHORT_CIRCUIT)) + spritesound(SHORT_CIRCUIT,pi); + } + } + break; + case FLOORSLIME__STATIC: + if( rnd(16) ) + { + if(p->boot_amount > 0) + k = 1; + else + { + if(!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,pi); + p->pals[0] = 0; p->pals[1] = 8; p->pals[2] = 0; + p->pals_time = 32; + s->extra -= 1+(TRAND&3); + } + } + break; + case FLOORPLASMA__STATIC: + if( rnd(32) ) + { + if( p->boot_amount > 0 ) + k = 1; + else + { + if(!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN,pi); + p->pals[0] = 8; p->pals[1] = 0; p->pals[2] = 0; + p->pals_time = 32; + s->extra -= 1+(TRAND&3); + } + } + break; + } + } + + if( k ) + { + FTA(75,p); + p->boot_amount -= 2; + if(p->boot_amount <= 0) + checkavailinven(p); + } + } + + if ( p->posxv || p->posyv || sync[snum].fvel || sync[snum].svel ) + { + p->crack_time = 777; + + k = sintable[p->bobcounter&2047]>>12; + + if((truefdist < PHEIGHT+(8<<8) ) && ( k == 1 || k == 3 )) + { + if(p->spritebridge == 0 && p->walking_snd_toggle == 0 && p->on_ground) + { + switch( psectlotag ) + { + case 0: + + if(lz >= 0 && (lz&(MAXSPRITES-1))==49152 ) + j = sprite[lz&(MAXSPRITES-1)].picnum; + else j = sector[psect].floorpicnum; + + switch(dynamictostatic[j]) + { + case PANNEL1__STATIC: + case PANNEL2__STATIC: + spritesound(DUKE_WALKINDUCTS,pi); + p->walking_snd_toggle = 1; + break; + } + break; + case 1: + if((TRAND&1) == 0) + spritesound(DUKE_ONWATER,pi); + p->walking_snd_toggle = 1; + break; + } + } + } + else if(p->walking_snd_toggle > 0) + p->walking_snd_toggle --; + + if(p->jetpack_on == 0 && p->steroids_amount > 0 && p->steroids_amount < 400) + doubvel <<= 1; + + /* + loc.bits2 = BUTTON(gamefunc_Move_Forward); + loc.bits2 |= BUTTON(gamefunc_Move_Backward)<<1; + loc.bits2 |= BUTTON(gamefunc_Strafe_Left)<<2; + loc.bits2 |= BUTTON(gamefunc_Strafe_Right)<<3; + loc.bits2 |= BUTTON(gamefunc_Turn_Left)<<4; + loc.bits2 |= BUTTON(gamefunc_Turn_Right)<<5; + */ + if (sync[snum].bits2&(1)) + OnEvent(EVENT_MOVEFORWARD,pi,snum, -1); + + if (sync[snum].bits2&(1<<1)) + OnEvent(EVENT_MOVEBACKWARD,pi,snum, -1); + + if (sync[snum].bits2&(1<<2)) + OnEvent(EVENT_STRAFELEFT,pi,snum, -1); + + if (sync[snum].bits2&(1<<3)) + OnEvent(EVENT_STRAFERIGHT,pi,snum, -1); + + if (sync[snum].bits2&(1<<4) || sync[snum].avel < 0) + OnEvent(EVENT_TURNLEFT,pi,snum, -1); + + if (sync[snum].bits2&(1<<5) || sync[snum].avel > 0) + OnEvent(EVENT_TURNRIGHT,pi,snum, -1); + + p->posxv += ((sync[snum].fvel*doubvel)<<6); + p->posyv += ((sync[snum].svel*doubvel)<<6); + + if( ( aplWeaponWorksLike[p->curr_weapon] == KNEE_WEAPON && *kb > 10 && p->on_ground ) || ( p->on_ground && (sb_snum&2) ) ) + { + p->posxv = mulscale(p->posxv,p->runspeed-0x2000,16); + p->posyv = mulscale(p->posyv,p->runspeed-0x2000,16); + } + else + { + if(psectlotag == 2) + { + p->posxv = mulscale(p->posxv,p->runspeed-0x1400,16); + p->posyv = mulscale(p->posyv,p->runspeed-0x1400,16); + } + else + { + p->posxv = mulscale(p->posxv,p->runspeed,16); + p->posyv = mulscale(p->posyv,p->runspeed,16); + } + } + + if( abs(p->posxv) < 2048 && abs(p->posyv) < 2048 ) + p->posxv = p->posyv = 0; + + if( shrunk ) + { + p->posxv = + mulscale16(p->posxv,p->runspeed-(p->runspeed>>1)+(p->runspeed>>2)); + p->posyv = + mulscale16(p->posyv,p->runspeed-(p->runspeed>>1)+(p->runspeed>>2)); + } + } + +HORIZONLY: + + if(psectlotag == 1 || p->spritebridge == 1) i = (4L<<8); + else i = (20L<<8); + + if(sector[p->cursectnum].lotag == 2) k = 0; + else k = 1; + + if(ud.clipping) + { + j = 0; + p->posx += p->posxv>>14; + p->posy += p->posyv>>14; + updatesector(p->posx,p->posy,&p->cursectnum); + changespritesect(pi,p->cursectnum); + } + else + j = clipmove(&p->posx,&p->posy, + &p->posz,&p->cursectnum, + p->posxv,p->posyv,164L,(4L<<8),i,CLIPMASK0); + + if(p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) + p->posz += 32<<8; + + if(j) + checkplayerhurt(p,j); + + if(p->jetpack_on == 0) + { + if( s->xvel > 16 ) + { + if( psectlotag != 1 && psectlotag != 2 && p->on_ground ) + { + p->pycount += 52; + p->pycount &= 2047; + p->pyoff = + klabs(s->xvel*sintable[p->pycount])/1596; + } + } + else if( psectlotag != 2 && psectlotag != 1 ) + p->pyoff = 0; + } + + // RBG*** + setsprite(pi,p->posx,p->posy,p->posz+PHEIGHT); + + if( psectlotag < 3 ) + { + psect = s->sectnum; + if( ud.clipping == 0 && sector[psect].lotag == 31) + { + if( sprite[sector[psect].hitag].xvel && hittype[sector[psect].hitag].temp_data[0] == 0) + { + quickkill(p); + return; + } + } + } + + if(truefdist < PHEIGHT && p->on_ground && psectlotag != 1 && shrunk == 0 && sector[p->cursectnum].lotag == 1) + if(!isspritemakingsound(pi,DUKE_ONWATER)) + spritesound(DUKE_ONWATER,pi); + + if (p->cursectnum != s->sectnum) + changespritesect(pi,p->cursectnum); + + if(ud.clipping == 0) + j = ( pushmove(&p->posx,&p->posy,&p->posz,&p->cursectnum,164L,(4L<<8),(4L<<8),CLIPMASK0) < 0 && furthestangle(pi,8) < 512 ); + else j = 0; + + if(ud.clipping == 0) + { + if( klabs(hittype[pi].floorz-hittype[pi].ceilingz) < (48<<8) || j ) + { + if ( !(sector[s->sectnum].lotag&0x8000) && ( isanunderoperator(sector[s->sectnum].lotag) || + isanearoperator(sector[s->sectnum].lotag) ) ) + activatebysector(s->sectnum,pi); + if(j) + { + quickkill(p); + return; + } + } + else if( klabs(fz-cz) < (32<<8) && isanunderoperator(sector[psect].lotag) ) + activatebysector(psect,pi); + } + + // center_view + if( sb_snum&(1<<18) || p->hard_landing) + { + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_RETURNTOCENTER,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + p->return_to_center = 9; + } + } + + if( sb_snum&(1<<13) ) + { + // look_up + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_LOOKUP,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + p->return_to_center = 9; + if( sb_snum&(1<<5) ) p->horiz += 12; // running + p->horiz += 12; + } + } + + else if( sb_snum&(1<<14) ) + { + // look_down + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_LOOKDOWN,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + p->return_to_center = 9; + if( sb_snum&(1<<5) ) p->horiz -= 12; + p->horiz -= 12; + } + } + + else if( sb_snum&(1<<3) ) + { // aim_up + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_AIMUP,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + // running + if( sb_snum&(1<<5) ) p->horiz += 6; + p->horiz += 6; + } + } + + else if( sb_snum&(1<<4) ) + { // aim_down + SetGameVarID(g_iReturnVarID,0,pi,snum); + OnEvent(EVENT_AIMDOWN,pi,snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + // running + if( sb_snum&(1<<5) ) p->horiz -= 6; + p->horiz -= 6; + } + } + if(p->return_to_center > 0) + if( (sb_snum&(1<<13)) == 0 && (sb_snum&(1<<14)) == 0 ) + { + p->return_to_center--; + p->horiz += 33-(p->horiz/3); + } + + if(p->hard_landing > 0) + { + p->hard_landing--; + p->horiz -= (p->hard_landing<<4); + } + + if(p->aim_mode) + p->horiz += sync[snum].horz>>1; + else + { + if( p->horiz > 95 && p->horiz < 105) p->horiz = 100; + if( p->horizoff > -5 && p->horizoff < 5) p->horizoff = 0; + } + + if(p->horiz > 299) p->horiz = 299; + else if(p->horiz < -99) p->horiz = -99; + + //Shooting code/changes + + if(p->show_empty_weapon > 0) + { + p->show_empty_weapon--; + if(p->show_empty_weapon == 0 && (p->weaponswitch & 2)) + { + if(p->last_full_weapon == GROW_WEAPON) + p->subweapon |= (1<last_full_weapon == SHRINKER_WEAPON) + p->subweapon &= ~(1<last_full_weapon ); + return; + } + } + + if(p->knee_incs > 0) + { + p->knee_incs++; + p->horiz -= 48; + p->return_to_center = 9; + if(p->knee_incs > 15) + { + p->knee_incs = 0; + p->holster_weapon = 0; + if(p->weapon_pos < 0) + p->weapon_pos = -p->weapon_pos; + if(p->actorsqu >= 0 && dist(&sprite[pi],&sprite[p->actorsqu]) < 1400 ) + { + guts(&sprite[p->actorsqu],JIBS6,7,myconnectindex); + spawn(p->actorsqu,BLOODPOOL); + spritesound(SQUISHED,p->actorsqu); + switch(dynamictostatic[sprite[p->actorsqu].picnum]) + { + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case PODFEM1__STATIC: + case NAKED1__STATIC: + case STATUE__STATIC: + if(sprite[p->actorsqu].yvel) + operaterespawns(sprite[p->actorsqu].yvel); + break; + } + + if(sprite[p->actorsqu].picnum == APLAYER) + { + quickkill(&ps[sprite[p->actorsqu].yvel]); + ps[sprite[p->actorsqu].yvel].frag_ps = snum; + } + else if(badguy(&sprite[p->actorsqu])) + { + deletesprite(p->actorsqu); + p->actors_killed++; + } + else deletesprite(p->actorsqu); + } + p->actorsqu = -1; + } + else if(p->actorsqu >= 0) + p->ang += getincangle(p->ang,getangle(sprite[p->actorsqu].x-p->posx,sprite[p->actorsqu].y-p->posy))>>2; + } + + if( doincrements(p) ) return; + + if(p->weapon_pos != 0) + { + if(p->weapon_pos == -9) + { + if(p->last_weapon >= 0) + { + p->weapon_pos = 10; + // if(p->curr_weapon == KNEE_WEAPON) *kb = 1; + p->last_weapon = -1; + } + else if(p->holster_weapon == 0) + p->weapon_pos = 10; + } + else p->weapon_pos--; + } + + // HACKS + +SHOOTINCODE: + //#define WEAPON2_CLIP 20 + // reload clip + if( sb_snum & (1<<19) ) // 'Holster Weapon + { + SetGameVarID(g_iReturnVarID,0,pi,snum); + SetGameVarID(g_iWeaponVarID,p->curr_weapon,pi,snum); + SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],pi,snum); + OnEvent(EVENT_HOLSTER, pi, snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + + // now it uses the game definitions... + if( aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_HOLSTER_CLEARS_CLIP) + { + if( p->ammo_amount[p->curr_weapon] > aplWeaponClip[p->curr_weapon][snum] + && (p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum]) != 0 ) + { + // throw away the remaining clip + p->ammo_amount[p->curr_weapon]-= + p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum] ; + // (*kb) = aplWeaponFireDelay[p->curr_weapon][snum]+1; // animate, but don't shoot... + (*kb) = aplWeaponTotalTime[p->curr_weapon][snum]; // animate, but don't shoot... + sb_snum &= ~(1<<2); // not firing... + } + return; + } + } + } + + if( aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_GLOWS) + //== SHRINKER_WEAPON || p->curr_weapon == GROW_WEAPON ) + p->random_club_frame += 64; // Glowing + + if(p->rapid_fire_hold == 1) + { + if( sb_snum&(1<<2) ) return; + p->rapid_fire_hold = 0; + } + if(shrunk || p->tipincs || p->access_incs) + sb_snum &= ~(1<<2); + else if ( shrunk == 0 && (sb_snum&(1<<2)) && (*kb) == 0 && p->fist_incs == 0 && + p->last_weapon == -1 && ( p->weapon_pos == 0 || p->holster_weapon == 1 ) ) + { + + p->crack_time = 777; + + if(p->holster_weapon == 1) + { + if( p->last_pissed_time <= (26*218) && p->weapon_pos == -9) + { + p->holster_weapon = 0; + p->weapon_pos = 10; + FTA(74,p); + } + } + else + { + SetGameVarID(g_iReturnVarID,0,pi,snum); + SetGameVarID(g_iWeaponVarID,p->curr_weapon,pi,snum); + SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],pi,snum); + OnEvent(EVENT_FIRE, pi, snum, -1); + if(GetGameVarID(g_iReturnVarID,pi,snum) == 0) + { + + switch(aplWeaponWorksLike[p->curr_weapon][snum]) + { + case HANDBOMB_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + + p->hbomb_hold_delay = 0; + if( p->ammo_amount[p->curr_weapon] > 0 ) + { + (*kb)=1; + if(aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case HANDREMOTE_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + p->hbomb_hold_delay = 0; + (*kb) = 1; + if(aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + break; + + case SHOTGUN_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + if( p->ammo_amount[p->curr_weapon] > 0 && p->random_club_frame == 0 ) + { + (*kb)=1; + if(aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case TRIPBOMB_WEAPON: + if ( p->ammo_amount[p->curr_weapon] > 0 ) + { + long sx,sy,sz; + short sect,hw,hitsp; + + hitscan( p->posx, p->posy, p->posz, + p->cursectnum, sintable[(p->ang+512)&2047], + sintable[p->ang&2047], (100-p->horiz-p->horizoff)*32, + §, &hw, &hitsp, &sx, &sy, &sz,CLIPMASK1); + + if(sect < 0 || hitsp >= 0) + break; + + if( hw >= 0 && sector[sect].lotag > 2 ) + break; + + if(hw >= 0 && wall[hw].overpicnum >= 0) + if(wall[hw].overpicnum == BIGFORCE) + break; + + j = headspritesect[sect]; + while(j >= 0) + { + if( sprite[j].picnum == TRIPBOMB && + klabs(sprite[j].z-sz) < (12<<8) && ((sprite[j].x-sx)*(sprite[j].x-sx)+(sprite[j].y-sy)*(sprite[j].y-sy)) < (290*290) ) + break; + j = nextspritesect[j]; + } + + if(j == -1 && hw >= 0 && (wall[hw].cstat&16) == 0 ) + if( ( wall[hw].nextsector >= 0 && sector[wall[hw].nextsector].lotag <= 2 ) || ( wall[hw].nextsector == -1 && sector[sect].lotag <= 2 ) ) + if( ( (sx-p->posx)*(sx-p->posx) + (sy-p->posy)*(sy-p->posy) ) < (290*290) ) + { + p->posz = p->oposz; + p->poszv = 0; + (*kb) = 1; + if(aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + } + break; + + case PISTOL_WEAPON: + case CHAINGUN_WEAPON: + case SHRINKER_WEAPON: + case GROW_WEAPON: + case FREEZE_WEAPON: + case RPG_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + if ( p->ammo_amount[p->curr_weapon] > 0) + { + (*kb) = 1; + if(aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case DEVISTATOR_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + if( p->ammo_amount[p->curr_weapon] > 0 ) + { + (*kb) = 1; + p->hbomb_hold_delay = !p->hbomb_hold_delay; + if(aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case KNEE_WEAPON: + OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + if(p->quick_kick == 0) + { + (*kb) = 1; + if(aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + } + } + } + } + else if((*kb)) + { + // already firing... + + //Bsprintf(g_szBuf,"%s %ld, kb=%d %ld",__FILE__,__LINE__,*kb,aplWeaponWorksLike[p->curr_weapon][snum]); + //AddLog(g_szBuf); + if(aplWeaponWorksLike[p->curr_weapon][snum] == HANDBOMB_WEAPON) + { + if( aplWeaponHoldDelay[p->curr_weapon][snum] // there is a hold delay + && ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) // and we are 'at' hold + && (sb_snum&(1<<2)) // and 'fire' button is still down + ) + // just hold here... + { + //AddLog("Holding HANDBOMB"); + p->rapid_fire_hold = 1; + return; + } + (*kb)++; + if((*kb)==aplWeaponHoldDelay[p->curr_weapon][snum]) + { + long lPipeBombControl; + + // AddLog("Releasing HANDBOMB"); + p->ammo_amount[p->curr_weapon]--; + + if(p->on_ground && (sb_snum&2) ) + { + k = 15; + i = ((p->horiz+p->horizoff-100)*20); + } + else + { + k = 140; + i = -512-((p->horiz+p->horizoff-100)*20); + } + + j = EGS(p->cursectnum, + p->posx+(sintable[(p->ang+512)&2047]>>6), + p->posy+(sintable[p->ang&2047]>>6), + p->posz,aplWeaponShoots[p->curr_weapon][snum],-16,9,9, + p->ang,(k+(p->hbomb_hold_delay<<5)),i,pi,1); + + lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); + + if(lPipeBombControl & PIPEBOMB_TIMER) + { + long lGrenadeLifetime=GetGameVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, -1, snum); + long lGrenadeLifetimeVar=GetGameVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, snum); + //Bsprintf(g_szBuf,"Lifetime=%ld Var=%ld snum=%d",lGrenadeLifetime, lGrenadeLifetimeVar, snum); + //AddLog(g_szBuf); + // set timer. blows up when at zero.... + hittype[j].temp_data[7]=lGrenadeLifetime + + mulscale(krand(),lGrenadeLifetimeVar, 14) + - lGrenadeLifetimeVar; + hittype[j].temp_data[6]=1; + } + else + hittype[j].temp_data[6]=2; + + if(k == 15) + { + sprite[j].yvel = 3; + sprite[j].z += (8<<8); + } + + k = hits(pi); + if( k < 512 ) + { + sprite[j].ang += 1024; + sprite[j].zvel /= 3; + sprite[j].xvel /= 3; + } + + p->hbomb_on = 1; + + } + else if( (*kb) < aplWeaponHoldDelay[p->curr_weapon][snum] && (sb_snum&(1<<2)) ) + { + p->hbomb_hold_delay++; + } + else if( (*kb) > aplWeaponTotalTime[p->curr_weapon][snum] ) + { + long lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); + + (*kb) = 0; + + if(lPipeBombControl == PIPEBOMB_REMOTE) + { + p->curr_weapon = HANDREMOTE_WEAPON; + p->last_weapon = -1; + p->weapon_pos = 10; + } + else + checkavailweapon(p); + } + } + else if(aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) + { + (*kb)++; + + if((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) + { + if( aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_BOMB_TRIGGER) + { + p->hbomb_on = 0; + } + if(aplWeaponShoots[p->curr_weapon][snum] != 0) + { + if(! (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE )) + { + // make them visible if not set... + lastvisinc = totalclock+32; + p->visibility = 0; + } + SetGameVarID(g_iWeaponVarID,p->curr_weapon,p->i,snum); + SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + } + } + + if((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + long lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); + (*kb) = 0; + /// WHAT THE HELL DOES THIS DO....????????????? + if((p->ammo_amount[HANDBOMB_WEAPON] > 0) && lPipeBombControl == PIPEBOMB_REMOTE) + addweapon(p,HANDBOMB_WEAPON); + else + checkavailweapon(p); + } + } + else + { + // the basic weapon... + (*kb)++; + + if(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) + { + if (aplWeaponWorksLike[p->curr_weapon][snum] == TRIPBOMB_WEAPON) + { + if((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + (*kb) = 0; + checkavailweapon(p); + p->weapon_pos = -9; + } + } + else if(*kb >= aplWeaponReload[p->curr_weapon][snum]) + { + checkavailweapon(p); + } + } + + else if(aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON && *kb >= aplWeaponFireDelay[p->curr_weapon][snum]) + { + checkavailweapon(p); + } + + if( aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_STANDSTILL + && *kb < (aplWeaponFireDelay[p->curr_weapon][snum]+1) ) + { + p->posz = p->oposz; + p->poszv = 0; + } + if(*kb == aplWeaponSound2Time[p->curr_weapon][snum]) + { + //AddLog("Sound2Time"); + if(aplWeaponSound2Sound[p->curr_weapon][snum]) + { + spritesound(aplWeaponSound2Sound[p->curr_weapon][snum],pi); + } + } + if(*kb == aplWeaponSpawnTime[p->curr_weapon][snum]) + { + //AddLog("SpawnTime"); + DoSpawn(snum); + } + + if ( *kb > aplWeaponFireDelay[p->curr_weapon][snum] + && (*kb) < aplWeaponTotalTime[p->curr_weapon][snum] + && (aplWeaponWorksLike[p->curr_weapon][snum] & KNEE_WEAPON ? 1 : p->ammo_amount[p->curr_weapon] > 0)) + { + //Bsprintf(g_szBuf,"%s %ld, kb=%d %ld",__FILE__,__LINE__,*kb,aplWeaponWorksLike[p->curr_weapon][snum]); + //AddLog(g_szBuf); + // we are waiting for initial fire to complete + + if ( aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC) + { // an 'automatic' + //Bsprintf(g_szBuf,"%s %ld, kb=%d %ld",__FILE__,__LINE__,*kb,aplWeaponWorksLike[p->curr_weapon][snum]); + //AddLog(g_szBuf); + if( ( sb_snum&(1<<2) ) == 0 ) + { + // 'fire' not still down... stop... + //Bsprintf(g_szBuf,"%s %ld, kb=%d %ld",__FILE__,__LINE__,*kb,aplWeaponWorksLike[p->curr_weapon][snum]); + //AddLog(g_szBuf); + // *kb = 0; + + // check for clip change... + *kb = aplWeaponTotalTime[p->curr_weapon][snum]; + // break; + } + + if ( aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYTHIRD) + { + if( ((*(kb))%3) == 0 ) + { + DoFire(snum); + DoSpawn(snum); + } + } + if( aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYOTHER) + { + // fire every other... + DoFire(snum); + DoSpawn(snum); + } + + } // 'automatic + } + else if(*kb == aplWeaponFireDelay[p->curr_weapon][snum] + && (aplWeaponWorksLike[p->curr_weapon][snum]==KNEE_WEAPON ? 1 : p->ammo_amount[p->curr_weapon] > 0)) + { + //Bsprintf(g_szBuf,"FireDelayTime:%s %ld, kb=%d %ld",__FILE__,__LINE__,*kb,aplWeaponWorksLike[p->curr_weapon][snum]); + //AddLog(g_szBuf); + //AddLog("FireDelay Time"); + DoFire(snum); + } + else if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + //Bsprintf(g_szBuf,"end of TotalTime(%ld) %s %ld, kb=%d %ld", + // aplWeaponTotalTime[p->curr_weapon][snum], + // __FILE__,__LINE__,*kb, + // aplWeaponWorksLike[p->curr_weapon][snum]); + //AddLog(g_szBuf); + // we are >= total time... + if( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) && + (aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] + && p->ammo_amount[p->curr_weapon] > 0 + && (aplWeaponClip[p->curr_weapon][snum]) + && (((p->ammo_amount[p->curr_weapon]%(aplWeaponClip[p->curr_weapon][snum]))==0))) || p->reloading == 1 ) + { + // reload in progress... + int i; + //Bsprintf(g_szBuf,"C %s %ld, kb=%d",__FILE__,__LINE__,*kb); + //AddLog(g_szBuf); + //Bsprintf(g_szBuf,"ammo=%d clip=%ld mod=%ld",p->ammo_amount[p->curr_weapon], + // aplWeaponClip[p->curr_weapon][snum], + // (p->ammo_amount[p->curr_weapon]%(aplWeaponClip[p->curr_weapon][snum])) + // ); + //AddLog(g_szBuf); + + i=aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]; + // time for 'reload' + p->reloading = 1; + if( (*kb) == (aplWeaponTotalTime[p->curr_weapon][snum] + 1)) + { // eject shortly after 'total time' + if(aplWeaponReloadSound1[p->curr_weapon][snum]) + spritesound(aplWeaponReloadSound1[p->curr_weapon][snum],pi); + } + else if( ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i/3)) && + !(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RELOAD_TIMING)) || + ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - i+4) && + (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RELOAD_TIMING)) ) + { + // insert occurs 2/3 of way through reload delay + if(aplWeaponReloadSound2[p->curr_weapon][snum]) + spritesound(aplWeaponReloadSound2[p->curr_weapon][snum],pi); + } + + else if( (*kb) >= (aplWeaponReload[p->curr_weapon][snum]) ) + { + *kb=0; + p->reloading = 0; + } + + } + else + { + //Bsprintf(g_szBuf,"NC %s %ld, kb=%d",__FILE__,__LINE__,*kb); + //AddLog(g_szBuf); + // no clip reload going on... + if ( aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC + && (aplWeaponWorksLike[p->curr_weapon][snum]==KNEE_WEAPON ? 1 : p->ammo_amount[p->curr_weapon] > 0)) + { // an 'automatic' + if( sb_snum&(1<<2) ) + { + // we are an AUTOMATIC. Fire again... + if(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RANDOMRESTART) + { + *kb = 1+(TRAND&3); + } + else + { + *kb=1; + } + } + else + { + //Bsprintf(g_szBuf,"NC %s %ld, kb=%d",__FILE__,__LINE__,*kb); + //AddLog(g_szBuf); + // time to recycle automatic fire + *kb = 0; + } + } + else + { // not 'automatic' and >totaltime + //Bsprintf(g_szBuf,"NA %s %ld, kb=%d",__FILE__,__LINE__,*kb); + //AddLog(g_szBuf); + *kb=0; + } + } + } + } + + //Bsprintf(g_szBuf,"%s %ld, kb=%d %ld",__FILE__,__LINE__,*kb,aplWeaponWorksLike[p->curr_weapon][snum]); + //AddLog(g_szBuf); + + } + +} + +//UPDATE THIS FILE OVER THE OLD GETSPRITESCORE/COMPUTERGETINPUT FUNCTIONS +int getspritescore(long snum, long dapicnum) +{ + switch(dynamictostatic[dapicnum]) + { + case FIRSTGUNSPRITE__STATIC: return(20); + case CHAINGUNSPRITE__STATIC: return(50); + case RPGSPRITE__STATIC: return(200); + case FREEZESPRITE__STATIC: return(25); + case SHRINKERSPRITE__STATIC: return(80); + case HEAVYHBOMB__STATIC: return(60); + case TRIPBOMBSPRITE__STATIC: return(50); + case SHOTGUNSPRITE__STATIC: return(120); + case DEVISTATORSPRITE__STATIC: return(120); + + case FREEZEAMMO__STATIC: if (ps[snum].ammo_amount[FREEZE_WEAPON] < max_ammo_amount[FREEZE_WEAPON]) return(10); else return(0); + case AMMO__STATIC: if (ps[snum].ammo_amount[PISTOL_WEAPON] < max_ammo_amount[PISTOL_WEAPON]) return(10); else return(0); + case BATTERYAMMO__STATIC: if (ps[snum].ammo_amount[CHAINGUN_WEAPON] < max_ammo_amount[CHAINGUN_WEAPON]) return(20); else return(0); + case DEVISTATORAMMO__STATIC: if (ps[snum].ammo_amount[DEVISTATOR_WEAPON] < max_ammo_amount[DEVISTATOR_WEAPON]) return(25); else return(0); + case RPGAMMO__STATIC: if (ps[snum].ammo_amount[RPG_WEAPON] < max_ammo_amount[RPG_WEAPON]) return(50); else return(0); + case CRYSTALAMMO__STATIC: if (ps[snum].ammo_amount[SHRINKER_WEAPON] < max_ammo_amount[SHRINKER_WEAPON]) return(10); else return(0); + case HBOMBAMMO__STATIC: if (ps[snum].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) return(30); else return(0); + case SHOTGUNAMMO__STATIC: if (ps[snum].ammo_amount[SHOTGUN_WEAPON] < max_ammo_amount[SHOTGUN_WEAPON]) return(25); else return(0); + + case COLA__STATIC: if (sprite[ps[snum].i].extra < 100) return(10); else return(0); + case SIXPAK__STATIC: if (sprite[ps[snum].i].extra < 100) return(30); else return(0); + case FIRSTAID__STATIC: if (ps[snum].firstaid_amount < 100) return(100); else return(0); + case SHIELD__STATIC: if (ps[snum].shield_amount < 100) return(50); else return(0); + case STEROIDS__STATIC: if (ps[snum].steroids_amount < 400) return(30); else return(0); + case AIRTANK__STATIC: if (ps[snum].scuba_amount < 6400) return(30); else return(0); + case JETPACK__STATIC: if (ps[snum].jetpack_amount < 1600) return(100); else return(0); + case HEATSENSOR__STATIC: if (ps[snum].heat_amount < 1200) return(5); else return(0); + case ACCESSCARD__STATIC: return(1); + case BOOTS__STATIC: if (ps[snum].boot_amount < 200) return(15); else return(0); + case ATOMICHEALTH__STATIC: if (sprite[ps[snum].i].extra < max_player_health<<1) return(50); else return(0); + case HOLODUKE__STATIC: if (ps[snum].holoduke_amount < 2400) return(5); else return(0); + + case SECTOREFFECTOR__STATIC: return(1); + case TOUCHPLATE__STATIC: return(1); + case MUSICANDSFX__STATIC: return(1); + } + return(0); +} + +static long fdmatrix[12][12] = + { + //KNEE PIST SHOT CHAIN RPG PIPE SHRI DEVI WALL FREE HAND EXPA + { 128, -1, -1, -1, 128, -1, -1, -1, 128, -1, 128, -1 }, //KNEE + { 1024,1024,1024,1024,2560, 128,2560,2560,1024,2560,2560,2560 }, //PIST + { 512, 512, 512, 512,2560, 128,2560,2560,1024,2560,2560,2560 }, //SHOT + { 512, 512, 512, 512,2560, 128,2560,2560,1024,2560,2560,2560 }, //CHAIN + { 2560,2560,2560,2560,2560,2560,2560,2560,2560,2560,2560,2560 }, //RPG + { 512, 512, 512, 512,2048, 512,2560,2560, 512,2560,2560,2560 }, //PIPE + { 128, 128, 128, 128,2560, 128,2560,2560, 128, 128, 128, 128 }, //SHRI + { 1536,1536,1536,1536,2560,1536,1536,1536,1536,1536,1536,1536 }, //DEVI + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, //WALL + { 128, 128, 128, 128,2560, 128,2560,2560, 128, 128, 128, 128 }, //FREE + { 2560,2560,2560,2560,2560,2560,2560,2560,2560,2560,2560,2560 }, //HAND + { 128, 128, 128, 128,2560, 128,2560,2560, 128, 128, 128, 128 } //EXPA + }; + +static long goalx[MAXPLAYERS], goaly[MAXPLAYERS], goalz[MAXPLAYERS]; +static long goalsect[MAXPLAYERS], goalwall[MAXPLAYERS], goalsprite[MAXPLAYERS]; +static long goalplayer[MAXPLAYERS], clipmovecount[MAXPLAYERS]; +short searchsect[MAXSECTORS], searchparent[MAXSECTORS]; +char dashow2dsector[(MAXSECTORS+7)>>3]; +void computergetinput(long snum, input *syn) +{ + long i, j, k, l, x1, y1, z1, x2, y2, z2, x3, y3, z3, dx, dy; + long dist, daang, zang, fightdist, damyang, damysect; + long startsect, endsect, splc, send, startwall, endwall; + short dasect, dawall, daspr; + struct player_struct *p; + walltype *wal; + + p = &ps[snum]; + syn->fvel = 0; + syn->svel = 0; + syn->avel = 0; + syn->horz = 0; + syn->bits = 0; + + x1 = sprite[p->i].x; + y1 = sprite[p->i].y; + z1 = sprite[p->i].z; + damyang = sprite[p->i].ang; + damysect = sprite[p->i].sectnum; + if ((numplayers >= 2) && (snum == myconnectindex)) + { x1 = myx; y1 = myy; z1 = myz+PHEIGHT; damyang = myang; damysect = mycursectnum; } + + if (!(numframes&7)) + { + x2 = sprite[ps[goalplayer[snum]].i].x; + y2 = sprite[ps[goalplayer[snum]].i].y; + z2 = sprite[ps[goalplayer[snum]].i].z; + + if (!cansee(x1,y1,z1-(48<<8),damysect,x2,y2,z2-(48<<8),sprite[ps[goalplayer[snum]].i].sectnum)) + goalplayer[snum] = snum; + } + + if ((goalplayer[snum] == snum) || (ps[goalplayer[snum]].dead_flag != 0)) + { + j = 0x7fffffff; + for(i=connecthead;i>=0;i=connectpoint2[i]) + if (i != snum) + { + dist = ksqrt((sprite[ps[i].i].x-x1)*(sprite[ps[i].i].x-x1)+(sprite[ps[i].i].y-y1)*(sprite[ps[i].i].y-y1)); + + x2 = sprite[ps[i].i].x; + y2 = sprite[ps[i].i].y; + z2 = sprite[ps[i].i].z; + if (!cansee(x1,y1,z1-(48<<8),damysect,x2,y2,z2-(48<<8),sprite[ps[i].i].sectnum)) + dist <<= 1; + + if (dist < j) { j = dist; goalplayer[snum] = i; } + } + } + + x2 = sprite[ps[goalplayer[snum]].i].x; + y2 = sprite[ps[goalplayer[snum]].i].y; + z2 = sprite[ps[goalplayer[snum]].i].z; + + if (p->dead_flag) syn->bits |= (1<<29); + if ((p->firstaid_amount > 0) && (p->last_extra < 100)) + syn->bits |= (1<<16); + + for(j=headspritestat[4];j>=0;j=nextspritestat[j]) + { + switch (dynamictostatic[sprite[j].picnum]) + { + case TONGUE__STATIC: k = 4; break; + case FREEZEBLAST__STATIC: k = 4; break; + case SHRINKSPARK__STATIC: k = 16; break; + case RPG__STATIC: k = 16; break; + default: k = 0; break; + } + if (k) + { + x3 = sprite[j].x; + y3 = sprite[j].y; + z3 = sprite[j].z; + for(l=0;l<=8;l++) + { + if (tmulscale11(x3-x1,x3-x1,y3-y1,y3-y1,(z3-z1)>>4,(z3-z1)>>4) < 3072) + { + dx = sintable[(sprite[j].ang+512)&2047]; + dy = sintable[sprite[j].ang&2047]; + if ((x1-x3)*dy > (y1-y3)*dx) i = -k*512; else i = k*512; + syn->fvel -= mulscale17(dy,i); + syn->svel += mulscale17(dx,i); + } + if (l < 7) + { + x3 += (mulscale14(sprite[j].xvel,sintable[(sprite[j].ang+512)&2047])<<2); + y3 += (mulscale14(sprite[j].xvel,sintable[sprite[j].ang&2047])<<2); + z3 += (sprite[j].zvel<<2); + } + else + { + hitscan(sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].sectnum, + mulscale14(sprite[j].xvel,sintable[(sprite[j].ang+512)&2047]), + mulscale14(sprite[j].xvel,sintable[sprite[j].ang&2047]), + (long)sprite[j].zvel, + &dasect,&dawall,&daspr,&x3,&y3,&z3,CLIPMASK1); + } + } + } + } + + if ((ps[goalplayer[snum]].dead_flag == 0) && + ((cansee(x1,y1,z1,damysect,x2,y2,z2,sprite[ps[goalplayer[snum]].i].sectnum)) || + (cansee(x1,y1,z1-(24<<8),damysect,x2,y2,z2-(24<<8),sprite[ps[goalplayer[snum]].i].sectnum)) || + (cansee(x1,y1,z1-(48<<8),damysect,x2,y2,z2-(48<<8),sprite[ps[goalplayer[snum]].i].sectnum)))) + { + syn->bits |= (1<<2); + + if ((p->curr_weapon == HANDBOMB_WEAPON) && (!(rand()&7))) + syn->bits &= ~(1<<2); + + if (p->curr_weapon == TRIPBOMB_WEAPON) + syn->bits |= ((rand()%MAX_WEAPONS)<<8); + + if (p->curr_weapon == RPG_WEAPON) + { + hitscan(x1,y1,z1-PHEIGHT,damysect,sintable[(damyang+512)&2047],sintable[damyang&2047], + (100-p->horiz-p->horizoff)*32,&dasect,&dawall,&daspr,&x3,&y3,&z3,CLIPMASK1); + if ((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1) < 2560*2560) syn->bits &= ~(1<<2); + } + + + fightdist = fdmatrix[p->curr_weapon][ps[goalplayer[snum]].curr_weapon]; + if (fightdist < 128) fightdist = 128; + dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); if (dist == 0) dist = 1; + daang = getangle(x2+(ps[goalplayer[snum]].posxv>>14)-x1,y2+(ps[goalplayer[snum]].posyv>>14)-y1); + zang = 100-((z2-z1)*8)/dist; + fightdist = max(fightdist,(klabs(z2-z1)>>4)); + + if (sprite[ps[goalplayer[snum]].i].yrepeat < 32) + { fightdist = 0; syn->bits &= ~(1<<2); } + if (sprite[ps[goalplayer[snum]].i].pal == 1) + { fightdist = 0; syn->bits &= ~(1<<2); } + + if (dist < 256) syn->bits |= (1<<22); + + x3 = x2+((x1-x2)*fightdist/dist); + y3 = y2+((y1-y2)*fightdist/dist); + syn->fvel += (x3-x1)*2047/dist; + syn->svel += (y3-y1)*2047/dist; + + //Strafe attack + if (fightdist) + { + j = totalclock+snum*13468; + i = sintable[(j<<6)&2047]; + i += sintable[((j+4245)<<5)&2047]; + i += sintable[((j+6745)<<4)&2047]; + i += sintable[((j+15685)<<3)&2047]; + dx = sintable[(sprite[ps[goalplayer[snum]].i].ang+512)&2047]; + dy = sintable[sprite[ps[goalplayer[snum]].i].ang&2047]; + if ((x1-x2)*dy > (y1-y2)*dx) i += 8192; else i -= 8192; + syn->fvel += ((sintable[(daang+1024)&2047]*i)>>17); + syn->svel += ((sintable[(daang+512)&2047]*i)>>17); + } + + syn->avel = min(max((((daang+1024-damyang)&2047)-1024)>>1,-127),127); + syn->horz = min(max((zang-p->horiz)>>1,-MAXHORIZ),MAXHORIZ); + syn->bits |= (1<<23); + return; + } + + goalsect[snum] = -1; + if (goalsect[snum] < 0) + { + goalwall[snum] = -1; + startsect = sprite[p->i].sectnum; + endsect = sprite[ps[goalplayer[snum]].i].sectnum; + + clearbufbyte(dashow2dsector,(MAXSECTORS+7)>>3,0L); + searchsect[0] = startsect; + searchparent[0] = -1; + dashow2dsector[startsect>>3] |= (1<<(startsect&7)); + for(splc=0,send=1;splcnextsector; if (j < 0) continue; + + dx = ((wall[wal->point2].x+wal->x)>>1); + dy = ((wall[wal->point2].y+wal->y)>>1); + if ((getceilzofslope(j,dx,dy) > getflorzofslope(j,dx,dy)-(28<<8)) && ((sector[j].lotag < 15) || (sector[j].lotag > 22))) + continue; + if (getflorzofslope(j,dx,dy) < getflorzofslope(searchsect[splc],dx,dy)-(72<<8)) + continue; + if ((dashow2dsector[j>>3]&(1<<(j&7))) == 0) + { + dashow2dsector[j>>3] |= (1<<(j&7)); + searchsect[send] = (short)j; + searchparent[send] = (short)splc; + send++; + if (j == endsect) + { + clearbufbyte(dashow2dsector,(MAXSECTORS+7)>>3,0L); + for(k=send-1;k>=0;k=searchparent[k]) + dashow2dsector[searchsect[k]>>3] |= (1<<(searchsect[k]&7)); + + for(k=send-1;k>=0;k=searchparent[k]) + if (!searchparent[k]) break; + + goalsect[snum] = searchsect[k]; + startwall = sector[goalsect[snum]].wallptr; + endwall = startwall+sector[goalsect[snum]].wallnum; + x3 = y3 = 0; + for(i=startwall;i= dy*(x2-wall[i].x)) + if ((x3-x1)*(wall[i].y-y1) <= (y3-y1)*(wall[i].x-x1)) + if ((x3-x1)*(wall[wall[i].point2].y-y1) >= (y3-y1)*(wall[wall[i].point2].x-x1)) + { k = i; break; } + + dist = ksqrt(dx*dx+dy*dy); + if (dist > l) { l = dist; k = i; } + } + goalwall[snum] = k; + daang = ((getangle(wall[wall[k].point2].x-wall[k].x,wall[wall[k].point2].y-wall[k].y)+1536)&2047); + goalx[snum] = ((wall[k].x+wall[wall[k].point2].x)>>1)+(sintable[(daang+512)&2047]>>8); + goaly[snum] = ((wall[k].y+wall[wall[k].point2].y)>>1)+(sintable[daang&2047]>>8); + goalz[snum] = sector[goalsect[snum]].floorz-(32<<8); + break; + } + } + } + + for(i=headspritesect[searchsect[splc]];i>=0;i=nextspritesect[i]) + if (sprite[i].lotag == 7) + { + j = sprite[sprite[i].owner].sectnum; + if ((dashow2dsector[j>>3]&(1<<(j&7))) == 0) + { + dashow2dsector[j>>3] |= (1<<(j&7)); + searchsect[send] = (short)j; + searchparent[send] = (short)splc; + send++; + if (j == endsect) + { + clearbufbyte(dashow2dsector,(MAXSECTORS+7)>>3,0L); + for(k=send-1;k>=0;k=searchparent[k]) + dashow2dsector[searchsect[k]>>3] |= (1<<(searchsect[k]&7)); + + for(k=send-1;k>=0;k=searchparent[k]) + if (!searchparent[k]) break; + + goalsect[snum] = searchsect[k]; + startwall = sector[startsect].wallptr; + endwall = startwall+sector[startsect].wallnum; + l = 0; k = startwall; + for(i=startwall;i l)) + { l = dist; k = i; } + } + goalwall[snum] = k; + daang = ((getangle(wall[wall[k].point2].x-wall[k].x,wall[wall[k].point2].y-wall[k].y)+1536)&2047); + goalx[snum] = ((wall[k].x+wall[wall[k].point2].x)>>1)+(sintable[(daang+512)&2047]>>8); + goaly[snum] = ((wall[k].y+wall[wall[k].point2].y)>>1)+(sintable[daang&2047]>>8); + goalz[snum] = sector[goalsect[snum]].floorz-(32<<8); + break; + } + } + } + if (goalwall[snum] >= 0) break; + } + } + + if ((goalsect[snum] < 0) || (goalwall[snum] < 0)) + { + if (goalsprite[snum] < 0) + { + for(k=0;k<4;k++) + { + i = (rand()%numsectors); + for(j=headspritesect[i];j>=0;j=nextspritesect[j]) + { + if ((sprite[j].xrepeat <= 0) || (sprite[j].yrepeat <= 0)) continue; + if (getspritescore(snum,sprite[j].picnum) <= 0) continue; + if (cansee(x1,y1,z1-(32<<8),damysect,sprite[j].x,sprite[j].y,sprite[j].z-(4<<8),i)) + { goalx[snum] = sprite[j].x; goaly[snum] = sprite[j].y; goalz[snum] = sprite[j].z; goalsprite[snum] = j; break; } + } + } + } + x2 = goalx[snum]; + y2 = goaly[snum]; + dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); if (!dist) return; + daang = getangle(x2-x1,y2-y1); + syn->fvel += (x2-x1)*2047/dist; + syn->svel += (y2-y1)*2047/dist; + syn->avel = min(max((((daang+1024-damyang)&2047)-1024)>>3,-127),127); + } + else + goalsprite[snum] = -1; + + x3 = p->posx; y3 = p->posy; z3 = p->posz; dasect = p->cursectnum; + i = clipmove(&x3,&y3,&z3,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0); + if (!i) + { + x3 = p->posx; y3 = p->posy; z3 = p->posz+(24<<8); dasect = p->cursectnum; + i = clipmove(&x3,&y3,&z3,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0); + } + if (i) + { + clipmovecount[snum]++; + + j = 0; + if ((i&0xc000) == 32768) //Hit a wall (49152 for sprite) + if (wall[i&(MAXWALLS-1)].nextsector >= 0) + { + if (getflorzofslope(wall[i&(MAXWALLS-1)].nextsector,p->posx,p->posy) <= p->posz+(24<<8)) j |= 1; + if (getceilzofslope(wall[i&(MAXWALLS-1)].nextsector,p->posx,p->posy) >= p->posz-(24<<8)) j |= 2; + } + if ((i&0xc000) == 49152) j = 1; + if (j&1) if (clipmovecount[snum] == 4) syn->bits |= (1<<0); + if (j&2) syn->bits |= (1<<1); + + //Strafe attack + daang = getangle(x2-x1,y2-y1); + if ((i&0xc000) == 32768) + daang = getangle(wall[wall[i&(MAXWALLS-1)].point2].x-wall[i&(MAXWALLS-1)].x,wall[wall[i&(MAXWALLS-1)].point2].y-wall[i&(MAXWALLS-1)].y); + j = totalclock+snum*13468; + i = sintable[(j<<6)&2047]; + i += sintable[((j+4245)<<5)&2047]; + i += sintable[((j+6745)<<4)&2047]; + i += sintable[((j+15685)<<3)&2047]; + syn->fvel += ((sintable[(daang+1024)&2047]*i)>>17); + syn->svel += ((sintable[(daang+512)&2047]*i)>>17); + + if ((clipmovecount[snum]&31) == 2) syn->bits |= (1<<29); + if ((clipmovecount[snum]&31) == 17) syn->bits |= (1<<22); + if (clipmovecount[snum] > 32) { goalsect[snum] = -1; goalwall[snum] = -1; clipmovecount[snum] = 0; } + + goalsprite[snum] = -1; + } + else + clipmovecount[snum] = 0; + + if ((goalsect[snum] >= 0) && (goalwall[snum] >= 0)) + { + x2 = goalx[snum]; + y2 = goaly[snum]; + dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); if (!dist) return; + daang = getangle(x2-x1,y2-y1); + if ((goalwall[snum] >= 0) && (dist < 4096)) + daang = ((getangle(wall[wall[goalwall[snum]].point2].x-wall[goalwall[snum]].x,wall[wall[goalwall[snum]].point2].y-wall[goalwall[snum]].y)+1536)&2047); + syn->fvel += (x2-x1)*2047/dist; + syn->svel += (y2-y1)*2047/dist; + syn->avel = min(max((((daang+1024-damyang)&2047)-1024)>>3,-127),127); + } +} + diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c new file mode 100644 index 000000000..cd64deee3 --- /dev/null +++ b/polymer/eduke32/source/premap.c @@ -0,0 +1,1685 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "duke3d.h" +#include "osd.h" + +extern char pow2char[]; + +extern char everyothertime; +static short which_palookup = 9; +char numl, useprecache = 1; +short spritecache[MAXTILES][3]; + +static char precachehightile[2][MAXTILES>>3]; +static int precachecount; + +static void tloadtile(short tilenume, char type) +{ + if ((picanm[tilenume]&63) > 0) { + int i,j; + + if ((picanm[tilenume]&192)==192) { + i = tilenume - (picanm[tilenume]&63); + j = tilenume; + } else { + i = tilenume; + j = tilenume + (picanm[tilenume]&63); + } + for (;i<=j;i++) { + if (!(gotpic[i>>3] & pow2char[i&7])) precachecount++; + gotpic[i>>3] |= pow2char[i&7]; + precachehightile[type][i>>3] |= pow2char[i&7]; + } + } else { + if (!(gotpic[tilenume>>3] & pow2char[tilenume&7])) precachecount++; + gotpic[tilenume>>3] |= pow2char[tilenume&7]; + precachehightile[type][tilenume>>3] |= pow2char[tilenume&7]; + } +} + +void cachespritenum(short i) +{ + char maxc; + short j; + + if(ud.monsters_off && badguy(&sprite[i])) return; + + maxc = 1; + + if(spritecache[PN][0] == PN) + for(j = PN; j <= spritecache[PN][1]; j++) + tloadtile(j,1); + + switch(dynamictostatic[PN]) + { + case HYDRENT__STATIC: + tloadtile(BROKEFIREHYDRENT,1); + for(j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1); + break; + case TOILET__STATIC: + tloadtile(TOILETBROKE,1); + for(j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1); + break; + case STALL__STATIC: + tloadtile(STALLBROKE,1); + for(j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1); + break; + case RUBBERCAN__STATIC: + maxc = 2; + break; + case TOILETWATER__STATIC: + maxc = 4; + break; + case FEMPIC1__STATIC: + maxc = 44; + break; + case LIZTROOP__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPONTOILET__STATIC: + case LIZTROOPDUCKING__STATIC: + for(j = LIZTROOP; j < (LIZTROOP+72); j++) tloadtile(j,1); + for(j=HEADJIB1;j 1) + { + maxc = 5; + for(j = 1420;j < 1420+106; j++) tloadtile(j,1); + } + break; + case ATOMICHEALTH__STATIC: + maxc = 14; + break; + case DRONE__STATIC: + maxc = 10; + break; + case EXPLODINGBARREL__STATIC: + case SEENINE__STATIC: + case OOZFILTER__STATIC: + maxc = 3; + break; + case NUKEBARREL__STATIC: + case CAMERA1__STATIC: + maxc = 5; + break; + // caching of HUD sprites for weapons that may be in the level + case CHAINGUNSPRITE__STATIC: for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1); break; + case RPGSPRITE__STATIC: for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1); break; + case FREEZESPRITE__STATIC: for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1); break; + case GROWSPRITEICON__STATIC: + case SHRINKERSPRITE__STATIC: for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1); break; + case HBOMBAMMO__STATIC: + case HEAVYHBOMB__STATIC: for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1); break; + case TRIPBOMBSPRITE__STATIC: for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1); break; + case SHOTGUNSPRITE__STATIC: tloadtile(SHOTGUNSHELL,1); for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1); break; + case DEVISTATORSPRITE__STATIC: for (j=DEVISTATOR; j<=DEVISTATOR+1; j++) tloadtile(j,1); break; + + } + + for(j = PN; j < (PN+maxc); j++) tloadtile(j,1); +} + +void cachegoodsprites(void) +{ + short i,j; + + for(i=0;i 1) + tloadtile(FRAGBAR,1); + + tloadtile(VIEWSCREEN,1); + + for(i=STARTALPHANUM;i= NUM_SOUNDS || SoundToggle == 0) return 0; + if (FXDevice < 0) return 0; + + if (!sounds[num][0]) return 0; + fp = kopen4load(sounds[num],loadfromgrouponly); + if(fp == -1) return 0; + + l = kfilelength( fp ); + soundsiz[num] = l; + + if( (ud.level_number == 0 && ud.volume_number == 0 && (num == 189 || num == 232 || num == 99 || num == 233 || num == 17 ) ) || + ( l < 12288 ) ) + { + Sound[num].lock = 199; + allocache((long *)&Sound[num].ptr,l,(char *)&Sound[num].lock); + if(Sound[num].ptr != NULL) + kread( fp, Sound[num].ptr , l); + } + kclose( fp ); + return 1; +} + +void precachenecessarysounds(void) +{ + short i, j; + + if (FXDevice < 0) return; + j = 0; + + for(i=0;i= 0) { + tloadtile(wall[i].overpicnum, 0); + } + } + + for(i=0;i= 0) + { + if(sprite[j].xrepeat != 0 && sprite[j].yrepeat != 0 && (sprite[j].cstat&32768) == 0) + cachespritenum(j); + j = nextspritesect[j]; + } + } + + tc = totalclock; + j = 0; + + for(i=0;i>3]) { + i+=7; + continue; + } + if(gotpic[i>>3] & pow2char[i&7]) { + if (waloff[i] == 0) + loadtile((short)i); + + if (useprecache) { + if (precachehightile[0][i>>3] & pow2char[i&7]) + for (k=0; k>3] & pow2char[i&7]) + for (k=0; k TICRATE/4) { + sprintf(tempbuf,"Loading textures ... %ld%%\n",min(100,100*pc/precachecount)); + dofrontscreens(tempbuf); + tc = totalclock; + } + } + + clearbufbyte(gotpic,sizeof(gotpic),0L); + + endtime = getticks(); + OSD_Printf("Cache time: %dms\n", endtime-starttime); +} + +void xyzmirror(short i,short wn) +{ + //if (waloff[wn] == 0) loadtile(wn); + setviewtotile(wn,tilesizy[wn],tilesizx[wn]); + + drawrooms(SX,SY,SZ,SA,100+sprite[i].shade,SECT); + display_mirror = 1; animatesprites(SX,SY,SA,65536L); display_mirror = 0; + drawmasks(); + + setviewback(); + squarerotatetile(wn); + invalidatetile(wn,-1,255); +} + +void vscrn(void) +{ + long i, j, ss, x1, x2, y1, y2; + + if(ud.screen_size < 0) ud.screen_size = 0; + else if(ud.screen_size > 63) ud.screen_size = 64; + + if(ud.screen_size == 0) flushperms(); + + ss = max(ud.screen_size-8,0); + + x1 = scale(ss,xdim,160); + x2 = xdim-x1; + + y1 = ss; y2 = 200; + if ( ud.screen_size > 0 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_FRAGBAR) && ud.multimode > 1) + { + j = 0; + for(i=connecthead;i>=0;i=connectpoint2[i]) + if(i > j) j = i; + + if (j >= 1) y1 += 8; + if (j >= 4) y1 += 8; + if (j >= 8) y1 += 8; + if (j >= 12) y1 += 8; + } + + if (ud.screen_size >= 8) y2 -= (ss+scale(tilesizy[BOTTOMSTATUSBAR],ud.statusbarscale,100)); + + y1 = scale(y1,ydim,200); + y2 = scale(y2,ydim,200); + + setview(x1,y1,x2-1,y2-1); + + pub = NUMPAGES; + pus = NUMPAGES; +} + +void pickrandomspot(short snum) +{ + struct player_struct *p; + short i; + + p = &ps[snum]; + + if( ud.multimode > 1 && !(gametype_flags[ud.coop] & GAMETYPE_FLAG_FIXEDRESPAWN)) + i = TRAND%numplayersprites; + else i = snum; + + p->bobposx = p->oposx = p->posx = po[i].ox; + p->bobposy = p->oposy = p->posy = po[i].oy; + p->oposz = p->posz = po[i].oz; + p->ang = po[i].oa; + p->cursectnum = po[i].os; +} + +void resetplayerstats(short snum) +{ + struct player_struct *p; + short i; + + p = &ps[snum]; + + ud.show_help = 0; + ud.showallmap = 0; + p->dead_flag = 0; + p->wackedbyactor = -1; + p->falling_counter = 0; + p->quick_kick = 0; + p->subweapon = 0; + p->last_full_weapon = 0; + p->ftq = 0; + p->fta = 0; + p->tipincs = 0; + p->buttonpalette = 0; + p->actorsqu =-1; + p->invdisptime = 0; + p->refresh_inventory= 0; + p->last_pissed_time = 0; + p->holster_weapon = 0; + p->pycount = 0; + p->pyoff = 0; + p->opyoff = 0; + p->loogcnt = 0; + p->angvel = 0; + p->weapon_sway = 0; + // p->select_dir = 0; + p->extra_extra8 = 0; + p->show_empty_weapon= 0; + p->dummyplayersprite=-1; + p->crack_time = 0; + p->hbomb_hold_delay = 0; + p->transporter_hold = 0; + p->wantweaponfire = -1; + p->hurt_delay = 0; + p->footprintcount = 0; + p->footprintpal = 0; + p->footprintshade = 0; + p->jumping_toggle = 0; + p->ohoriz = p->horiz= 140; + p->horizoff = 0; + p->bobcounter = 0; + p->on_ground = 0; + p->player_par = 0; + p->return_to_center = 9; + p->airleft = 15*26; + p->rapid_fire_hold = 0; + p->toggle_key_flag = 0; + p->access_spritenum = -1; + if(ud.multimode > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_ACCESSATSTART)) + p->got_access = 7; + else p->got_access = 0; + p->random_club_frame= 0; + pus = 1; + p->on_warping_sector = 0; + p->spritebridge = 0; + p->sbs = 0; + p->palette = (char *) &palette[0]; + + if(p->steroids_amount < 400 ) + { + p->steroids_amount = 0; + p->inven_icon = 0; + } + p->heat_on = 0; + p->jetpack_on = 0; + p->holoduke_on = -1; + + p->look_ang = 512 - ((ud.level_number&1)<<10); + + p->rotscrnang = 0; + p->orotscrnang = 1; // JBF 20031220 + p->newowner =-1; + p->jumping_counter = 0; + p->hard_landing = 0; + p->posxv = 0; + p->posyv = 0; + p->poszv = 0; + fricxv = 0; + fricyv = 0; + p->somethingonplayer =-1; + p->one_eighty_count = 0; + p->cheat_phase = 0; + + p->on_crane = -1; + + if( (aplWeaponWorksLike[p->curr_weapon][snum] == PISTOL_WEAPON) && + (aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]) ) + p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum]+1; + else p->kickback_pic = 0; + + p->weapon_pos = 6; + p->walking_snd_toggle= 0; + p->weapon_ang = 0; + + p->knuckle_incs = 1; + p->fist_incs = 0; + p->knee_incs = 0; + p->jetpack_on = 0; + p->reloading = 0; + + p->movement_lock[1] = 0; + p->movement_lock[2] = 0; + p->movement_lock[3] = 0; + p->movement_lock[4] = 0; + + setpal(p); + OnEvent(EVENT_RESETPLAYER, p->i, snum, -1); +} + +void resetweapons(short snum) +{ + short weapon; + struct player_struct *p; + + p = &ps[snum]; + + for ( weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++ ) + p->gotweapon[weapon] = 0; + for ( weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++ ) + p->ammo_amount[weapon] = 0; + + p->weapon_pos = 6; + p->kickback_pic = 5; + p->curr_weapon = PISTOL_WEAPON; + p->gotweapon[PISTOL_WEAPON] = 1; + p->gotweapon[KNEE_WEAPON] = 1; + p->ammo_amount[PISTOL_WEAPON] = 48; + p->gotweapon[HANDREMOTE_WEAPON] = 1; + p->last_weapon = -1; + + p->show_empty_weapon= 0; + p->last_pissed_time = 0; + p->holster_weapon = 0; + OnEvent(EVENT_RESETWEAPONS, p->i, snum, -1); +} + +void resetinventory(short snum) +{ + struct player_struct *p; + short i; + + p = &ps[snum]; + + p->inven_icon = 0; + p->boot_amount = 0; + p->scuba_on = 0;p->scuba_amount = 0; + p->heat_amount = 0;p->heat_on = 0; + p->jetpack_on = 0;p->jetpack_amount = 0; + p->shield_amount = max_armour_amount; + p->holoduke_on = -1; + p->holoduke_amount = 0; + p->firstaid_amount = 0; + p->steroids_amount = 0; + p->inven_icon = 0; + OnEvent(EVENT_RESETINVENTORY, p->i, snum, -1); +} + +void resetprestat(short snum,char g) +{ + struct player_struct *p; + short i; + + p = &ps[snum]; + + spriteqloc = 0; + for(i=0;ihbomb_on = 0; + p->cheat_phase = 0; + p->pals_time = 0; + p->toggle_key_flag = 0; + p->secret_rooms = 0; + p->max_secret_rooms = 0; + p->actors_killed = 0; + p->max_actors_killed = 0; + p->lastrandomspot = 0; + p->weapon_pos = 6; + p->kickback_pic = 5; + p->last_weapon = -1; + p->weapreccnt = 0; + p->interface_toggle_flag = 0; + p->show_empty_weapon= 0; + p->holster_weapon = 0; + p->last_pissed_time = 0; + + p->one_parallax_sectnum = -1; + p->visibility = ud.const_visibility; + + screenpeek = myconnectindex; + numanimwalls = 0; + numcyclers = 0; + animatecnt = 0; + parallaxtype = 0; + randomseed = 17L; + ud.pause_on = 0; + ud.camerasprite =-1; + ud.eog = 0; + tempwallptr = 0; + camsprite =-1; + earthquaketime = 0; + + numinterpolations = 0; + startofdynamicinterpolations = 0; + + if( ( (g&MODE_EOL) != MODE_EOL && numplayers < 2) || (!(gametype_flags[ud.coop]&GAMETYPE_FLAG_PRESERVEINVENTORYDEATH) && numplayers > 1) ) + { + resetweapons(snum); + resetinventory(snum); + } + else if(p->curr_weapon == HANDREMOTE_WEAPON) + { + p->ammo_amount[HANDBOMB_WEAPON]++; + p->curr_weapon = HANDBOMB_WEAPON; + } + + p->timebeforeexit = 0; + p->customexitsound = 0; + +} + +void setupbackdrop(short sky) +{ + short i; + + for(i=0;i sector[i].ceilingz) + sector[i].lotag |= 32768; + continue; + } + + if(sector[i].ceilingstat&1) + { + if(waloff[sector[i].ceilingpicnum] == 0) + { + if(sector[i].ceilingpicnum == LA) + for(j=0;j<5;j++) + tloadtile(sector[i].ceilingpicnum+j, 0); + } + setupbackdrop(sector[i].ceilingpicnum); + + if(sector[i].ceilingpicnum == CLOUDYSKIES && numclouds < 127) + clouds[numclouds++] = i; + + if(ps[0].one_parallax_sectnum == -1) + ps[0].one_parallax_sectnum = i; + } + + if(sector[i].lotag == 32767) //Found a secret room + { + ps[0].max_secret_rooms++; + continue; + } + + if(sector[i].lotag == -1) + { + ps[0].exitx = wall[sector[i].wallptr].x; + ps[0].exity = wall[sector[i].wallptr].y; + continue; + } + } + + i = headspritestat[0]; + while(i >= 0) + { + nexti = nextspritestat[i]; + LoadActor(i, -1, -1); + if(sprite[i].lotag == -1 && (sprite[i].cstat&16) ) + { + ps[0].exitx = SX; + ps[0].exity = SY; + } + else switch(dynamictostatic[PN]) + { + case GPSPEED__STATIC: + sector[SECT].extra = SLT; + deletesprite(i); + break; + + case CYCLER__STATIC: + if(numcyclers >= MAXCYCLERS) + { + Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS); + gameexit(tempbuf); + } + cyclers[numcyclers][0] = SECT; + cyclers[numcyclers][1] = SLT; + cyclers[numcyclers][2] = SS; + cyclers[numcyclers][3] = sector[SECT].floorshade; + cyclers[numcyclers][4] = SHT; + cyclers[numcyclers][5] = (SA == 1536); + numcyclers++; + deletesprite(i); + break; + + case SECTOREFFECTOR__STATIC: + case ACTIVATOR__STATIC: + case TOUCHPLATE__STATIC: + case ACTIVATORLOCKED__STATIC: + case MUSICANDSFX__STATIC: + case LOCATORS__STATIC: + case MASTERSWITCH__STATIC: + case RESPAWN__STATIC: + sprite[i].cstat = 0; + break; + } + i = nexti; + } + + for(i=0;i < MAXSPRITES;i++) + { + if(sprite[i].statnum < MAXSTATUS) + { + if(PN == SECTOREFFECTOR && SLT == 14) + continue; + spawn(-1,i); + } + } + + for(i=0;i < MAXSPRITES;i++) + if(sprite[i].statnum < MAXSTATUS) + { + if( PN == SECTOREFFECTOR && SLT == 14 ) + spawn(-1,i); + } + + lotaglist = 0; + + i = headspritestat[0]; + while(i >= 0) + { + switch(dynamictostatic[PN-1]) + { + case DIPSWITCH__STATIC: + case DIPSWITCH2__STATIC: + case PULLSWITCH__STATIC: + case HANDSWITCH__STATIC: + case SLOTDOOR__STATIC: + case LIGHTSWITCH__STATIC: + case SPACELIGHTSWITCH__STATIC: + case SPACEDOORSWITCH__STATIC: + case FRANKENSTINESWITCH__STATIC: + case LIGHTSWITCH2__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: + for(j=0;j 64) + gameexit("\nToo many switches (64 max)."); + + j = headspritestat[3]; + while(j >= 0) + { + if(sprite[j].lotag == 12 && sprite[j].hitag == SLT) + hittype[j].temp_data[0] = 1; + j = nextspritestat[j]; + } + } + break; + } + i = nextspritestat[i]; + } + + mirrorcnt = 0; + + for( i = 0; i < numwalls; i++ ) + { + walltype *wal; + wal = &wall[i]; + + if(wal->overpicnum == MIRROR && (wal->cstat&32) != 0) + { + j = wal->nextsector; + + if(mirrorcnt > 63) + gameexit("\nToo many mirrors (64 max.)"); + if ( (j >= 0) && sector[j].ceilingpicnum != MIRROR ) + { + sector[j].ceilingpicnum = MIRROR; + sector[j].floorpicnum = MIRROR; + mirrorwall[mirrorcnt] = i; + mirrorsector[mirrorcnt] = j; + mirrorcnt++; + continue; + } + } + + if(numanimwalls >= MAXANIMWALLS) + { + Bsprintf(tempbuf,"\nToo many 'anim' walls (%d max).",MAXANIMWALLS); + gameexit(tempbuf); + } + + animwall[numanimwalls].tag = 0; + animwall[numanimwalls].wallnum = 0; + switchpicnum = wal->overpicnum; + if ((wal->overpicnum > W_FORCEFIELD)&&(wal->overpicnum <= W_FORCEFIELD+2)) { + switchpicnum = W_FORCEFIELD; + } + switch(dynamictostatic[switchpicnum]) + { + case FANSHADOW__STATIC: + case FANSPRITE__STATIC: + wall->cstat |= 65; + animwall[numanimwalls].wallnum = i; + numanimwalls++; + break; + + case W_FORCEFIELD__STATIC: + if (wal->overpicnum==W_FORCEFIELD__STATIC) + for(j=0;j<3;j++) + tloadtile(W_FORCEFIELD+j, 0); + if(wal->shade > 31) + wal->cstat = 0; + else wal->cstat |= 85+256; + + + if(wal->lotag && wal->nextwall >= 0) + wall[wal->nextwall].lotag = + wal->lotag; + + case BIGFORCE__STATIC: + + animwall[numanimwalls].wallnum = i; + numanimwalls++; + + continue; + } + + wal->extra = -1; + + switch(dynamictostatic[wal->picnum]) + { + case WATERTILE2__STATIC: + for(j=0;j<3;j++) + tloadtile(wal->picnum+j, 0); + break; + + case TECHLIGHT2__STATIC: + case TECHLIGHT4__STATIC: + tloadtile(wal->picnum, 0); + break; + case W_TECHWALL1__STATIC: + case W_TECHWALL2__STATIC: + case W_TECHWALL3__STATIC: + case W_TECHWALL4__STATIC: + animwall[numanimwalls].wallnum = i; + // animwall[numanimwalls].tag = -1; + numanimwalls++; + break; + case SCREENBREAK6__STATIC: + case SCREENBREAK7__STATIC: + case SCREENBREAK8__STATIC: + for(j=SCREENBREAK6;jextra = wal->picnum; + animwall[numanimwalls].tag = -1; + if(ud.lockout) + { + if(wal->picnum == FEMPIC1) + wal->picnum = BLANKSCREEN; + else wal->picnum = SCREENBREAK6; + } + + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = wal->picnum; + numanimwalls++; + break; + + case SCREENBREAK1__STATIC: + case SCREENBREAK2__STATIC: + case SCREENBREAK3__STATIC: + case SCREENBREAK4__STATIC: + case SCREENBREAK5__STATIC: + + case SCREENBREAK9__STATIC: + case SCREENBREAK10__STATIC: + case SCREENBREAK11__STATIC: + case SCREENBREAK12__STATIC: + case SCREENBREAK13__STATIC: + case SCREENBREAK14__STATIC: + case SCREENBREAK15__STATIC: + case SCREENBREAK16__STATIC: + case SCREENBREAK17__STATIC: + case SCREENBREAK18__STATIC: + case SCREENBREAK19__STATIC: + + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = wal->picnum; + numanimwalls++; + break; + } + } + + //Invalidate textures in sector behind mirror + for(i=0;i= 0) + while(issoundplaying(globalskillsound)) { handleevents(); getpackets(); } + globalskillsound = -1; + + waitforeverybody(); + ready2send = 0; + + if( ud.m_recstat != 2 && ud.last_level >= 0 && ud.multimode > 1 && (ud.coop&GAMETYPE_FLAG_SCORESHEET)) + dobonus(1); + + if( ln == 0 && vn == 3 && ud.multimode < 2 && ud.lockout == 0) + { + playmusic(&env_music_fn[1][0]); + + flushperms(); + setview(0,0,xdim-1,ydim-1); + clearview(0L); + nextpage(); + + playanm("vol41a.anm",6); + clearview(0L); + nextpage(); + + playanm("vol42a.anm",7); + playanm("vol43a.anm",9); + clearview(0L); + nextpage(); + + FX_StopAllSounds(); + } + + show_shareware = 26*34; + + ud.level_number = ln; + ud.volume_number = vn; + ud.player_skill = sk; + ud.secretlevel = 0; + ud.from_bonus = 0; + parallaxyscale = 0; + + ud.last_level = -1; + lastsavedpos = -1; + p->zoom = 768; + p->gm = 0; + + { + int j; + //AddLog("Newgame"); + ResetGameVars(); + + InitGameVarPointers(); + + ResetSystemDefaults(); + + if(ud.m_coop != 1) + { + for(i=0;icurr_weapon = i; + p->gotweapon[i] = 1; + p->ammo_amount[i] = 48; + + } + else if(aplWeaponWorksLike[i][0]==KNEE_WEAPON) + { + p->gotweapon[i] = 1; + } + else if(aplWeaponWorksLike[i][0]==HANDREMOTE_WEAPON) + { + p->gotweapon[i] = 1; + } + } + p->last_weapon = -1; + } + } + display_mirror = 0; + + if(ud.multimode > 1 ) + { + if(numplayers < 2) + { + connecthead = 0; + for(i=0;i 1 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) + { + for(j=0;j 1 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) + { + for(j=0;j= 0) + { + nexti = nextspritestat[i]; + s = &sprite[i]; + + if( numplayersprites == MAXPLAYERS) + gameexit("\nToo many player sprites (max 16.)"); + + if(numplayersprites == 0) + { + firstx = ps[0].posx; + firsty = ps[0].posy; + } + + po[numplayersprites].ox = s->x; + po[numplayersprites].oy = s->y; + po[numplayersprites].oz = s->z; + po[numplayersprites].oa = s->ang; + po[numplayersprites].os = s->sectnum; + + numplayersprites++; + if(j >= 0) + { + s->owner = i; + s->shade = 0; + s->xrepeat = 42; + s->yrepeat = 36; + s->cstat = 1+256; + s->xoffset = 0; + s->clipdist = 64; + + if( (g&MODE_EOL) != MODE_EOL || ps[j].last_extra == 0) + { + ps[j].last_extra = max_player_health; + s->extra = max_player_health; + ps[j].runspeed = dukefriction; + } + else s->extra = ps[j].last_extra; + + s->yvel = j; + + if(s->pal == 0) + { + s->pal = ps[j].palookup = which_palookup; + which_palookup++; + if( which_palookup >= 17 ) which_palookup = 9; + } + else ps[j].palookup = s->pal; + + ps[j].i = i; + ps[j].frag_ps = j; + hittype[i].owner = i; + + hittype[i].bposx = ps[j].bobposx = ps[j].oposx = ps[j].posx = s->x; + hittype[i].bposy = ps[j].bobposy = ps[j].oposy = ps[j].posy = s->y; + hittype[i].bposz = ps[j].oposz = ps[j].posz = s->z; + ps[j].oang = ps[j].ang = s->ang; + + updatesector(s->x,s->y,&ps[j].cursectnum); + + j = connectpoint2[j]; + + } + else deletesprite(i); + i = nexti; + } +} + +void clearfrags(void) +{ + short i; + + for(i = 0;i=0;i=connectpoint2[i]) + { + if (i != myconnectindex) sendpacket(i,packbuf,1); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + playerreadyflag[myconnectindex]++; + + while (1) + { + handleevents(); + AudioUpdate(); + + if (quitevent || keystatus[1]) gameexit(""); + + getpackets(); + + for(i=connecthead;i>=0;i=connectpoint2[i]) + { + if (playerreadyflag[i] < playerreadyflag[myconnectindex]) break; + if ((!networkmode) && (myconnectindex != connecthead)) { i = -1; break; } //slaves in M/S mode only wait for master + } + if (i < 0) return; + } +} + +void dofrontscreens(char *statustext) +{ + long tincs,i=0,j; + + if(ud.recstat != 2) + { + if (!statustext) { + //ps[myconnectindex].palette = palette; + setgamepalette(&ps[myconnectindex], palette, 1); // JBF 20040308 + fadepal(0,0,0, 0,64,7); + i = ud.screen_size; + ud.screen_size = 0; + vscrn(); + clearview(0L); + } + + SetGameVarID(g_iReturnVarID,LOADSCREEN, -1, -1); + OnEvent(EVENT_GETLOADTILE, -1, -1, -1); + rotatesprite(320<<15,200<<15,65536L,0,GetGameVarID(g_iReturnVarID, -1, -1),0,0,2+8+64,0,0,xdim-1,ydim-1); + if( boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0 ) + { + menutext(160,90,0,0,"ENTERING USER MAP"); + gametextpal(160,90+10,boardfilename,14,2); + } + else + { + menutext(160,90,0,0,"ENTERING"); + menutext(160,90+16+8,0,0,level_names[(ud.volume_number*11) + ud.level_number]); + } + + if (statustext) gametext(160,180,statustext,0,2+8+16); + + nextpage(); + + if (!statustext) + { + fadepal(0,0,0, 63,0,-7); + + KB_FlushKeyboardQueue(); + ud.screen_size = i; + } + } + else + { + if (!statustext) + { + clearview(0L); + //ps[myconnectindex].palette = palette; + //palto(0,0,0,0); + setgamepalette(&ps[myconnectindex], palette, 0); // JBF 20040308 + } + SetGameVarID(g_iReturnVarID,LOADSCREEN, -1, -1); + OnEvent(EVENT_GETLOADTILE, -1, -1, -1); + rotatesprite(320<<15,200<<15,65536L,0,GetGameVarID(g_iReturnVarID, -1, -1),0,0,2+8+64,0,0,xdim-1,ydim-1); + menutext(160,105,0,0,"LOADING..."); + if (statustext) gametext(160,180,statustext,0,2+8+16); + nextpage(); + } +} + +void clearfifo(void) +{ + syncvaltail = 0L; + syncvaltottail = 0L; + syncstat = 0; + bufferjitter = 1; + mymaxlag = otherminlag = 0; + + movefifoplc = movefifosendplc = fakemovefifoplc = 0; + avgfvel = avgsvel = avgavel = avghorz = avgbits = 0; + otherminlag = mymaxlag = 0; + + clearbufbyte(myminlag,MAXPLAYERS<<2,0L); + clearbufbyte(&loc,sizeof(input),0L); + clearbufbyte(&sync[0],sizeof(sync),0L); + clearbufbyte(inputfifo,sizeof(input)*MOVEFIFOSIZ*MAXPLAYERS,0L); + + clearbuf(movefifoend,MAXPLAYERS,0L); + clearbuf(syncvalhead,MAXPLAYERS,0L); + clearbuf(myminlag,MAXPLAYERS,0L); + + // clearbufbyte(playerquitflag,MAXPLAYERS,0x01); +} + +void resetmys(void) +{ + myx = omyx = ps[myconnectindex].posx; + myy = omyy = ps[myconnectindex].posy; + myz = omyz = ps[myconnectindex].posz; + myxvel = myyvel = myzvel = 0; + myang = omyang = ps[myconnectindex].ang; + myhoriz = omyhoriz = ps[myconnectindex].horiz; + myhorizoff = omyhorizoff = ps[myconnectindex].horizoff; + mycursectnum = ps[myconnectindex].cursectnum; + myjumpingcounter = ps[myconnectindex].jumping_counter; + myjumpingtoggle = ps[myconnectindex].jumping_toggle; + myonground = ps[myconnectindex].on_ground; + myhardlanding = ps[myconnectindex].hard_landing; + myreturntocenter = ps[myconnectindex].return_to_center; +} + +extern void adduserquote(char *daquote); + +int enterlevel(char g) +{ + short i,j; + long l; + char levname[BMAX_PATH]; + + if( (g&MODE_DEMO) != MODE_DEMO ) ud.recstat = ud.m_recstat; + ud.respawn_monsters = ud.m_respawn_monsters; + ud.respawn_items = ud.m_respawn_items; + ud.respawn_inventory = ud.m_respawn_inventory; + ud.monsters_off = ud.m_monsters_off; + ud.coop = ud.m_coop; + ud.marker = ud.m_marker; + ud.ffire = ud.m_ffire; + + if( (g&MODE_DEMO) == 0 && ud.recstat == 2) + ud.recstat = 0; + + FX_StopAllSounds(); + clearsoundlocks(); + FX_SetReverb(0); + + i = ud.screen_size; + ud.screen_size = 0; + dofrontscreens(NULL); + vscrn(); + ud.screen_size = i; + + if (!VOLUMEONE) { + + if( boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0 ) + { + if ( loadboard( boardfilename,0,&ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang,&ps[0].cursectnum ) == -1 ) + { + initprintf("Map %s not found!\n",boardfilename); + //gameexit(tempbuf); + return 1; + } else { + char *p; + strcpy(levname, boardfilename); + p = Bstrrchr(levname,'.'); + if (!p) strcat(levname,".mhk"); + else { p[1]='m'; p[2]='h'; p[3]='k'; p[4]=0; } + if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname); + } + } + else if ( loadboard( level_file_names[ (ud.volume_number*11)+ud.level_number],0,&ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang,&ps[0].cursectnum ) == -1) + { + initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]); + //gameexit(tempbuf); + return 1; + } else { + char *p; + strcpy(levname, level_file_names[ (ud.volume_number*11)+ud.level_number]); + p = Bstrrchr(levname,'.'); + if (!p) strcat(levname,".mhk"); + else { p[1]='m'; p[2]='h'; p[3]='k'; p[4]=0; } + if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname); + } + + } else { + + l = strlen(level_file_names[ (ud.volume_number*11)+ud.level_number]); + copybufbyte( level_file_names[ (ud.volume_number*11)+ud.level_number],&levname[0],l); + levname[l] = 255; + levname[l+1] = 0; + + if ( loadboard( levname,1,&ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang,&ps[0].cursectnum ) == -1) + { + initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]); + //gameexit(tempbuf); + return 1; + } else { + char *p; + p = Bstrrchr(levname,'.'); + if (!p) strcat(levname,".mhk"); + else { p[1]='m'; p[2]='h'; p[3]='k'; p[4]=0; } + if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname); + } + } + + precachecount = 0; + clearbufbyte(gotpic,sizeof(gotpic),0L); + clearbufbyte(precachehightile, sizeof(precachehightile), 0l); + //clearbufbyte(hittype,sizeof(hittype),0l); // JBF 20040531: yes? no? + + prelevel(g); + + allignwarpelevators(); + resetpspritevars(g); + + cachedebug = 0; + automapping = 0; + + if(ud.recstat != 2) MUSIC_StopSong(); + + cacheit(); + + if(ud.recstat != 2) + { + music_select = (ud.volume_number*11) + ud.level_number; + playmusic(&music_fn[0][music_select][0]); + } + + if( (g&MODE_GAME) || (g&MODE_EOL) ) + ps[myconnectindex].gm = MODE_GAME; + else if(g&MODE_RESTART) + { + if(ud.recstat == 2) + ps[myconnectindex].gm = MODE_DEMO; + else ps[myconnectindex].gm = MODE_GAME; + } + + if( (ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART ) + opendemowrite(); + + if (VOLUMEONE) { + if(ud.level_number == 0 && ud.recstat != 2) FTA(40,&ps[myconnectindex]); + } + + for(i=connecthead;i>=0;i=connectpoint2[i]) + switch(dynamictostatic[sector[sprite[ps[i].i].sectnum].floorpicnum]) + { + case HURTRAIL__STATIC: + case FLOORSLIME__STATIC: + case FLOORPLASMA__STATIC: + resetweapons(i); + resetinventory(i); + ps[i].gotweapon[PISTOL_WEAPON] = 0; + ps[i].ammo_amount[PISTOL_WEAPON] = 0; + ps[i].curr_weapon = KNEE_WEAPON; + ps[i].kickback_pic = 0; + break; + } + + //PREMAP.C - replace near the my's at the end of the file + + resetmys(); + + //ps[myconnectindex].palette = palette; + //palto(0,0,0,0); + setgamepalette(&ps[myconnectindex], palette, 0); // JBF 20040308 + + setpal(&ps[myconnectindex]); + flushperms(); + + everyothertime = 0; + global_random = 0; + + ud.last_level = ud.level_number+1; + + clearfifo(); + + for(i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; + + restorepalette = 1; + + flushpackets(); + waitforeverybody(); + + palto(0,0,0,0); + vscrn(); + clearview(0L); + drawbackground(); + displayrooms(myconnectindex,65536); + + clearbufbyte(playerquitflag,MAXPLAYERS,0x01010101); + ps[myconnectindex].over_shoulder_on = 0; + + clearfrags(); + + resettimevars(); // Here we go + + //Bsprintf(g_szBuf,"ENTERLEVEL L=%d V=%d",ud.level_number, ud.volume_number); + //AddLog(g_szBuf); + // variables are set by pointer... + OnEvent(EVENT_ENTERLEVEL, -1, -1, -1); + return 0; +} + +/* +Duke Nukem V + +Layout: + + Settings: + Suburbs + Duke inflitrating neighborhoods inf. by aliens + Death Valley: + Sorta like a western. Bull-skulls halb buried in the sand + Military compound: Aliens take over nuke-missle silo, duke + must destroy. + Abondend Aircraft field + Vegas: + Blast anything bright! Alien lights camoflauged. + Alien Drug factory. The Blue Liquid + Mountainal Cave: + Interior cave battles. + Jungle: + Trees, canopee, animals, a mysterious hole in the earth + Penetencury: + Good use of spotlights: + Inventory: + Wood, + Metal, + Torch, + Rope, + Plastique, + Cloth, + Wiring, + Glue, + Cigars, + Food, + Duck Tape, + Nails, + Piping, + Petrol, + Uranium, + Gold, + Prism, + Power Cell, + + Hand spikes (Limited usage, they become dull) + Oxygent (Oxygen mixed with stimulant) + + + Player Skills: + R-Left,R-Right,Foward,Back + Strafe, Jump, Double Flip Jump for distance + Help, Escape + Fire/Use + Use Menu + +Programming: + Images: Polys + Actors: + Multi-Object sections for change (head,arms,legs,torsoe,all change) + Facial expressions. Pal lookup per poly? + + struct imagetype + { + int *itable; // AngX,AngY,AngZ,Xoff,Yoff,Zoff; + int *idata; + struct imagetype *prev, *next; + } + +*/ diff --git a/polymer/eduke32/source/rts.c b/polymer/eduke32/source/rts.c new file mode 100644 index 000000000..2386d3461 --- /dev/null +++ b/polymer/eduke32/source/rts.c @@ -0,0 +1,260 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#include "duke3d.h" + +//============= +// STATICS +//============= + +int32 numlumps; +static void **lumpcache; +static lumpinfo_t *lumpinfo; // location of each lump on disk +static boolean RTS_Started = false; + +char lumplockbyte[11]; + +/* +============================================================================ + + LUMP BASED ROUTINES + +============================================================================ +*/ + +/* +==================== += += RTS_AddFile += += All files are optional, but at least one file must be found += Files with a .rts extension are wadlink files with multiple lumps += Other files are single lumps with the base filename for the lump name += +==================== +*/ + +int32 RTS_AddFile (char *filename) +{ + wadinfo_t header; + lumpinfo_t *lump_p; + uint32 i; + int32 handle, length; + int32 startlump; + filelump_t *fileinfo, *fileinfoo; + + // + // read the entire file in + // FIXME: shared opens + + handle = kopen4load(filename, 0); + if (handle < 0) { + initprintf("RTS file %s was not found\n",filename); + return -1; + } + + startlump = numlumps; + + // WAD file + initprintf(" Adding %s.\n",filename); + kread( handle, &header, sizeof( header ) ); + if (strncmp(header.identification,"IWAD",4)) { + initprintf("RTS file %s doesn't have IWAD id\n",filename); + kclose(handle); + return -1; + } + header.numlumps = IntelLong(header.numlumps); + header.infotableofs = IntelLong(header.infotableofs); + length = header.numlumps*sizeof(filelump_t); + fileinfo = fileinfoo = (filelump_t*)malloc (length); + if (!fileinfo) { + initprintf("RTS file could not allocate header info\n"); + kclose(handle); + return -1; + } + klseek (handle, header.infotableofs, SEEK_SET); + kread(handle, fileinfo, length); + + // + // Fill in lumpinfo + // + lump_p = realloc(lumpinfo, (numlumps + header.numlumps)*sizeof(lumpinfo_t)); + if (!lump_p) { + kclose(handle); + return -1; + } + lumpinfo = lump_p; + + numlumps += header.numlumps; + + lump_p = &lumpinfo[startlump]; + + for (i=startlump ; i<(uint32)numlumps ; i++,lump_p++, fileinfo++) + { + lump_p->handle = handle; + lump_p->position = IntelLong(fileinfo->filepos); + lump_p->size = IntelLong(fileinfo->size); + strncpy (lump_p->name, fileinfo->name, 8); + } + + free(fileinfoo); + + return 0; +} + +/* +==================== += += RTS_Init += += Files with a .rts extension are idlink files with multiple lumps += +==================== +*/ + +void RTS_Init (char *filename) +{ + int32 length; + // + // open all the files, load headers, and count lumps + // + numlumps = 0; + lumpinfo = NULL; // will be realloced as lumps are added + + initprintf("RTS Manager Started.\n"); + if (RTS_AddFile (filename)) return; + + if (!numlumps) return; + + // + // set up caching + // + length = (numlumps) * sizeof( *lumpcache ); + lumpcache = SafeMalloc(length); + memset(lumpcache,0,length); + RTS_Started = true; +} + + +/* +==================== += += RTS_NumSounds += +==================== +*/ + +int32 RTS_NumSounds (void) +{ + return numlumps-1; +} + +/* +==================== += += RTS_SoundLength += += Returns the buffer size needed to load the given lump += +==================== +*/ + +int32 RTS_SoundLength (int32 lump) +{ + lump++; + if (lump >= numlumps) + Error ("RTS_SoundLength: %i >= numlumps",lump); + return lumpinfo[lump].size; +} + +/* +==================== += += RTS_GetSoundName += +==================== +*/ + +char * RTS_GetSoundName (int32 i) +{ + i++; + if (i>=numlumps) + Error ("RTS_GetSoundName: %i >= numlumps",i); + return &(lumpinfo[i].name[0]); +} + +/* +==================== += += RTS_ReadLump += += Loads the lump into the given buffer, which must be >= RTS_SoundLength() += +==================== +*/ +void RTS_ReadLump (int32 lump, void *dest) +{ + lumpinfo_t *l; + + if (lump >= numlumps) + Error ("RTS_ReadLump: %i >= numlumps",lump); + if (lump < 0) + Error ("RTS_ReadLump: %i < 0",lump); + l = lumpinfo+lump; + klseek (l->handle, l->position, SEEK_SET); + kread(l->handle,dest,l->size); +} + +/* +==================== += += RTS_GetSound += +==================== +*/ +void *RTS_GetSound (int32 lump) +{ + lump++; + if ((uint32)lump >= (uint32)numlumps) + Error ("RTS_GetSound: %i >= %i\n",lump,numlumps); + + if (lumpcache[lump] == NULL) + { + lumplockbyte[lump] = 200; + allocache((long *)&lumpcache[lump],(long)RTS_SoundLength(lump-1),&lumplockbyte[lump]); // JBF 20030910: char * => long * + RTS_ReadLump(lump, lumpcache[lump]); + } + else + { + if (lumplockbyte[lump] < 200) + lumplockbyte[lump] = 200; + else + lumplockbyte[lump]++; + } + return lumpcache[lump]; +} + diff --git a/polymer/eduke32/source/rts.h b/polymer/eduke32/source/rts.h new file mode 100644 index 000000000..588c29ee4 --- /dev/null +++ b/polymer/eduke32/source/rts.h @@ -0,0 +1,85 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +//*************************************************************************** +// +// RTS.H +// +//*************************************************************************** + +#ifndef __rts_public__ +#define __rts_public__ + +/* +==================== += += RTS_Init += += Files with a .rts extension are idlink files with multiple lumps += +==================== +*/ + +void RTS_Init (char *filename); +/* +==================== += += RTS_NumSounds += +==================== +*/ + +int32 RTS_NumSounds (void); +/* +==================== += += RTS_SoundLength += += Returns the buffer size needed to load the given lump += +==================== +*/ + +int32 RTS_SoundLength (int32 lump); +/* +==================== += += RTS_GetSoundName += +==================== +*/ + +char * RTS_GetSoundName (int32 i); +/* +==================== += += RTS_GetSound += +==================== +*/ +void *RTS_GetSound (int32 lump); +#endif diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c new file mode 100644 index 000000000..ce5387255 --- /dev/null +++ b/polymer/eduke32/source/savegame.c @@ -0,0 +1,646 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "duke3d.h" + +int loadpheader(char spot,struct savehead *saveh) +{ + long i; + char fn[13]; + long fil; + long bv; + + strcpy(fn, "egam0.sav"); + fn[4] = spot+'0'; + + if ((fil = kopen4load(fn,0)) == -1) return(-1); + + walock[TILE_LOADSHOT] = 255; + + if (kdfread(&bv,4,1,fil) != 1) goto corrupt; + if(bv != BYTEVERSION) { + FTA(114,&ps[myconnectindex]); + kclose(fil); + return 1; + } + + if (kdfread(&saveh->numplr,sizeof(int32),1,fil) != 1) goto corrupt; + + if (kdfread(saveh->name,19,1,fil) != 1) goto corrupt; + if (kdfread(&saveh->volnum,sizeof(int32),1,fil) != 1) goto corrupt; + if (kdfread(&saveh->levnum,sizeof(int32),1,fil) != 1) goto corrupt; + if (kdfread(&saveh->plrskl,sizeof(int32),1,fil) != 1) goto corrupt; + if (kdfread(saveh->boardfn,BMAX_PATH,1,fil) != 1) goto corrupt; + + if (waloff[TILE_LOADSHOT] == 0) allocache(&waloff[TILE_LOADSHOT],320*200,&walock[TILE_LOADSHOT]); + tilesizx[TILE_LOADSHOT] = 200; tilesizy[TILE_LOADSHOT] = 320; + if (kdfread((char *)waloff[TILE_LOADSHOT],320,200,fil) != 200) goto corrupt; + invalidatetile(TILE_LOADSHOT,0,255); + + kclose(fil); + + return(0); +corrupt: + kclose(fil); + return 1; +} + +int loadplayer(signed char spot) +{ + short k; + char fn[13]; + char mpfn[13]; + char *fnptr, scriptptrs[MAXSCRIPTSIZE]; + long fil, bv, i, j, x; + int32 nump; + + strcpy(fn, "egam0.sav"); + strcpy(mpfn, "egamA_00.sav"); + + if(spot < 0) + { + multiflag = 1; + multiwhat = 0; + multipos = -spot-1; + return -1; + } + + if( multiflag == 2 && multiwho != myconnectindex ) + { + fnptr = mpfn; + mpfn[4] = spot + 'A'; + + if(ud.multimode > 9) + { + mpfn[6] = (multiwho/10) + '0'; + mpfn[7] = (multiwho%10) + '0'; + } + else mpfn[7] = multiwho + '0'; + } + else + { + fnptr = fn; + fn[4] = spot + '0'; + } + + if ((fil = kopen4load(fnptr,0)) == -1) return(-1); + + ready2send = 0; + + if (kdfread(&bv,4,1,fil) != 1) return -1; + if(bv != BYTEVERSION) + { + FTA(114,&ps[myconnectindex]); + kclose(fil); + ototalclock = totalclock; + ready2send = 1; + return 1; + } + + if (kdfread(&nump,sizeof(nump),1,fil) != 1) return -1; + if(nump != numplayers) + { + kclose(fil); + ototalclock = totalclock; + ready2send = 1; + FTA(124,&ps[myconnectindex]); + return 1; + } + + if(numplayers > 1) + { + pub = NUMPAGES; + pus = NUMPAGES; + vscrn(); + drawbackground(); + menutext(160,100,0,0,"LOADING..."); + nextpage(); + } + + waitforeverybody(); + + FX_StopAllSounds(); + clearsoundlocks(); + MUSIC_StopSong(); + + if(numplayers > 1) { + if (kdfread(&buf,19,1,fil) != 1) goto corrupt; + } else { + if (kdfread(&ud.savegame[spot][0],19,1,fil) != 1) goto corrupt; + } + + + if (kdfread(&ud.volume_number,sizeof(ud.volume_number),1,fil) != 1) goto corrupt; + if (kdfread(&ud.level_number,sizeof(ud.level_number),1,fil) != 1) goto corrupt; + if (kdfread(&ud.player_skill,sizeof(ud.player_skill),1,fil) != 1) goto corrupt; + if (kdfread(&boardfilename[0],BMAX_PATH,1,fil) != 1) goto corrupt; + + ud.m_level_number = ud.level_number; + ud.m_volume_number = ud.volume_number; + ud.m_player_skill = ud.player_skill; + + //Fake read because lseek won't work with compression + walock[TILE_LOADSHOT] = 1; + if (waloff[TILE_LOADSHOT] == 0) allocache(&waloff[TILE_LOADSHOT],320*200,&walock[TILE_LOADSHOT]); + tilesizx[TILE_LOADSHOT] = 200; tilesizy[TILE_LOADSHOT] = 320; + if (kdfread((char *)waloff[TILE_LOADSHOT],320,200,fil) != 200) goto corrupt; + invalidatetile(TILE_LOADSHOT,0,255); + + if (kdfread(&numwalls,2,1,fil) != 1) goto corrupt; + if (kdfread(&wall[0],sizeof(walltype),MAXWALLS,fil) != MAXWALLS) goto corrupt; + if (kdfread(&numsectors,2,1,fil) != 1) goto corrupt; + if (kdfread(§or[0],sizeof(sectortype),MAXSECTORS,fil) != MAXSECTORS) goto corrupt; + if (kdfread(&sprite[0],sizeof(spritetype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&spriteext[0],sizeof(spriteexttype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&headspritesect[0],2,MAXSECTORS+1,fil) != MAXSECTORS+1) goto corrupt; + if (kdfread(&prevspritesect[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&nextspritesect[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&headspritestat[0],2,MAXSTATUS+1,fil) != MAXSTATUS+1) goto corrupt; + if (kdfread(&prevspritestat[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&nextspritestat[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&numcyclers,sizeof(numcyclers),1,fil) != 1) goto corrupt; + if (kdfread(&cyclers[0][0],12,MAXCYCLERS,fil) != MAXCYCLERS) goto corrupt; + if (kdfread(ps,sizeof(ps),1,fil) != 1) goto corrupt; + if (kdfread(po,sizeof(po),1,fil) != 1) goto corrupt; + if (kdfread(&numanimwalls,sizeof(numanimwalls),1,fil) != 1) goto corrupt; + if (kdfread(&animwall,sizeof(animwall),1,fil) != 1) goto corrupt; + if (kdfread(&msx[0],sizeof(long),sizeof(msx)/sizeof(long),fil) != sizeof(msx)/sizeof(long)) goto corrupt; + if (kdfread(&msy[0],sizeof(long),sizeof(msy)/sizeof(long),fil) != sizeof(msy)/sizeof(long)) goto corrupt; + if (kdfread((short *)&spriteqloc,sizeof(short),1,fil) != 1) goto corrupt; + if (kdfread((short *)&spriteqamount,sizeof(short),1,fil) != 1) goto corrupt; + if (kdfread((short *)&spriteq[0],sizeof(short),spriteqamount,fil) != spriteqamount) goto corrupt; + if (kdfread(&mirrorcnt,sizeof(short),1,fil) != 1) goto corrupt; + if (kdfread(&mirrorwall[0],sizeof(short),64,fil) != 64) goto corrupt; + if (kdfread(&mirrorsector[0],sizeof(short),64,fil) != 64) goto corrupt; + if (kdfread(&show2dsector[0],sizeof(char),MAXSECTORS>>3,fil) != (MAXSECTORS>>3)) goto corrupt; + if (kdfread(&actortype[0],sizeof(char),MAXTILES,fil) != MAXTILES) goto corrupt; + + if (kdfread(&numclouds,sizeof(numclouds),1,fil) != 1) goto corrupt; + if (kdfread(&clouds[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; + if (kdfread(&cloudx[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; + if (kdfread(&cloudy[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; + + if (kdfread(&scriptptrs[0],1,MAXSCRIPTSIZE,fil) != MAXSCRIPTSIZE) goto corrupt; + if (kdfread(&script[0],4,MAXSCRIPTSIZE,fil) != MAXSCRIPTSIZE) goto corrupt; + for(i=0;i=0;i--) animateptr[i] = (long *)((long)animateptr[i]+(long)(§or[0])); + if (kdfread(&animategoal[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; + if (kdfread(&animatevel[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; + + if (kdfread(&earthquaketime,sizeof(earthquaketime),1,fil) != 1) goto corrupt; + if (kdfread(&ud.from_bonus,sizeof(ud.from_bonus),1,fil) != 1) goto corrupt; + if (kdfread(&ud.secretlevel,sizeof(ud.secretlevel),1,fil) != 1) goto corrupt; + if (kdfread(&ud.respawn_monsters,sizeof(ud.respawn_monsters),1,fil) != 1) goto corrupt; + ud.m_respawn_monsters = ud.respawn_monsters; + if (kdfread(&ud.respawn_items,sizeof(ud.respawn_items),1,fil) != 1) goto corrupt; + ud.m_respawn_items = ud.respawn_items; + if (kdfread(&ud.respawn_inventory,sizeof(ud.respawn_inventory),1,fil) != 1) goto corrupt; + ud.m_respawn_inventory = ud.respawn_inventory; + + if (kdfread(&ud.god,sizeof(ud.god),1,fil) != 1) goto corrupt; + if (kdfread(&ud.auto_run,sizeof(ud.auto_run),1,fil) != 1) goto corrupt; + if (kdfread(&ud.crosshair,sizeof(ud.crosshair),1,fil) != 1) goto corrupt; + if (kdfread(&ud.monsters_off,sizeof(ud.monsters_off),1,fil) != 1) goto corrupt; + ud.m_monsters_off = ud.monsters_off; + if (kdfread(&ud.last_level,sizeof(ud.last_level),1,fil) != 1) goto corrupt; + if (kdfread(&ud.eog,sizeof(ud.eog),1,fil) != 1) goto corrupt; + + if (kdfread(&ud.coop,sizeof(ud.coop),1,fil) != 1) goto corrupt; + ud.m_coop = ud.coop; + if (kdfread(&ud.marker,sizeof(ud.marker),1,fil) != 1) goto corrupt; + ud.m_marker = ud.marker; + if (kdfread(&ud.ffire,sizeof(ud.ffire),1,fil) != 1) goto corrupt; + ud.m_ffire = ud.ffire; + + if (kdfread(&camsprite,sizeof(camsprite),1,fil) != 1) goto corrupt; + if (kdfread(&connecthead,sizeof(connecthead),1,fil) != 1) goto corrupt; + if (kdfread(connectpoint2,sizeof(connectpoint2),1,fil) != 1) goto corrupt; + if (kdfread(&numplayersprites,sizeof(numplayersprites),1,fil) != 1) goto corrupt; + if (kdfread((short *)&frags[0][0],sizeof(frags),1,fil) != 1) goto corrupt; + + if (kdfread(&randomseed,sizeof(randomseed),1,fil) != 1) goto corrupt; + if (kdfread(&global_random,sizeof(global_random),1,fil) != 1) goto corrupt; + if (kdfread(¶llaxyscale,sizeof(parallaxyscale),1,fil) != 1) goto corrupt; + + if (kdfread(&projectile[0],sizeof(proj_struct),MAXTILES,fil) != MAXTILES) goto corrupt; + if (kdfread(&defaultprojectile[0],sizeof(proj_struct),MAXTILES,fil) != MAXTILES) goto corrupt; + if (kdfread(&thisprojectile[0],sizeof(proj_struct),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + + ReadGameVars(fil); + + kclose(fil); + + if(ps[myconnectindex].over_shoulder_on != 0) + { + cameradist = 0; + cameraclock = 0; + ps[myconnectindex].over_shoulder_on = 1; + } + + screenpeek = myconnectindex; + + clearbufbyte(gotpic,sizeof(gotpic),0L); + clearsoundlocks(); + cacheit(); + + music_select = (ud.volume_number*11) + ud.level_number; + playmusic(&music_fn[0][music_select][0]); + + ps[myconnectindex].gm = MODE_GAME; + ud.recstat = 0; + + if(ps[myconnectindex].jetpack_on) + spritesound(DUKE_JETPACK_IDLE,ps[myconnectindex].i); + + restorepalette = 1; + setpal(&ps[myconnectindex]); + vscrn(); + + FX_SetReverb(0); + + if(ud.lockout == 0) + { + for(x=0;x= 0 ) + wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; + } + else + { + for(x=0;x= 0) + { + switch(sprite[k].lotag) + { + case 31: + setinterpolation(§or[sprite[k].sectnum].floorz); + break; + case 32: + setinterpolation(§or[sprite[k].sectnum].ceilingz); + break; + case 25: + setinterpolation(§or[sprite[k].sectnum].floorz); + setinterpolation(§or[sprite[k].sectnum].ceilingz); + break; + case 17: + setinterpolation(§or[sprite[k].sectnum].floorz); + setinterpolation(§or[sprite[k].sectnum].ceilingz); + break; + case 0: + case 5: + case 6: + case 11: + case 14: + case 15: + case 16: + case 26: + case 30: + setsectinterpolate(k); + break; + } + + k = nextspritestat[k]; + } + + for(i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; + for(i = animatecnt-1;i>=0;i--) + setinterpolation(animateptr[i]); + + show_shareware = 0; + everyothertime = 0; + + clearbufbyte(playerquitflag,MAXPLAYERS,0x01010101); + + resetmys(); + + ready2send = 1; + + flushpackets(); + clearfifo(); + waitforeverybody(); + + resettimevars(); + + return(0); +corrupt: + Bsprintf(tempbuf,"Save game file \"%s\" is corrupt.",fnptr); + gameexit(tempbuf); + return -1; +} + +int saveplayer(signed char spot) +{ + long i, j; + char fn[13]; + char mpfn[13]; + char *fnptr,scriptptrs[MAXSCRIPTSIZE]; + FILE *fil; + long bv = BYTEVERSION; + + strcpy(fn, "egam0.sav"); + strcpy(mpfn, "egamA_00.sav"); + + if(spot < 0) + { + multiflag = 1; + multiwhat = 1; + multipos = -spot-1; + return -1; + } + + waitforeverybody(); + + if( multiflag == 2 && multiwho != myconnectindex ) + { + fnptr = mpfn; + mpfn[4] = spot + 'A'; + + if(ud.multimode > 9) + { + mpfn[6] = (multiwho/10) + '0'; + mpfn[7] = multiwho + '0'; + } + else mpfn[7] = multiwho + '0'; + } + else + { + fnptr = fn; + fn[4] = spot + '0'; + } + + if ((fil = fopen(fnptr,"wb")) == 0) return(-1); + + ready2send = 0; + + dfwrite(&bv,4,1,fil); + dfwrite(&ud.multimode,sizeof(ud.multimode),1,fil); + + dfwrite(&ud.savegame[spot][0],19,1,fil); + dfwrite(&ud.volume_number,sizeof(ud.volume_number),1,fil); + dfwrite(&ud.level_number,sizeof(ud.level_number),1,fil); + dfwrite(&ud.player_skill,sizeof(ud.player_skill),1,fil); + dfwrite(&boardfilename[0],BMAX_PATH,1,fil); + if (!waloff[TILE_SAVESHOT]) { + walock[TILE_SAVESHOT] = 254; + allocache((long *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]); + clearbuf((void*)waloff[TILE_SAVESHOT],(200*320)/4,0); + walock[TILE_SAVESHOT] = 1; + } + dfwrite((char *)waloff[TILE_SAVESHOT],320,200,fil); + + dfwrite(&numwalls,2,1,fil); + dfwrite(&wall[0],sizeof(walltype),MAXWALLS,fil); + dfwrite(&numsectors,2,1,fil); + dfwrite(§or[0],sizeof(sectortype),MAXSECTORS,fil); + dfwrite(&sprite[0],sizeof(spritetype),MAXSPRITES,fil); + dfwrite(&spriteext[0],sizeof(spriteexttype),MAXSPRITES,fil); + dfwrite(&headspritesect[0],2,MAXSECTORS+1,fil); + dfwrite(&prevspritesect[0],2,MAXSPRITES,fil); + dfwrite(&nextspritesect[0],2,MAXSPRITES,fil); + dfwrite(&headspritestat[0],2,MAXSTATUS+1,fil); + dfwrite(&prevspritestat[0],2,MAXSPRITES,fil); + dfwrite(&nextspritestat[0],2,MAXSPRITES,fil); + dfwrite(&numcyclers,sizeof(numcyclers),1,fil); + dfwrite(&cyclers[0][0],12,MAXCYCLERS,fil); + dfwrite(ps,sizeof(ps),1,fil); + dfwrite(po,sizeof(po),1,fil); + dfwrite(&numanimwalls,sizeof(numanimwalls),1,fil); + dfwrite(&animwall,sizeof(animwall),1,fil); + dfwrite(&msx[0],sizeof(long),sizeof(msx)/sizeof(long),fil); + dfwrite(&msy[0],sizeof(long),sizeof(msy)/sizeof(long),fil); + dfwrite(&spriteqloc,sizeof(short),1,fil); + dfwrite(&spriteqamount,sizeof(short),1,fil); + dfwrite(&spriteq[0],sizeof(short),spriteqamount,fil); + dfwrite(&mirrorcnt,sizeof(short),1,fil); + dfwrite(&mirrorwall[0],sizeof(short),64,fil); + dfwrite(&mirrorsector[0],sizeof(short),64,fil); + dfwrite(&show2dsector[0],sizeof(char),MAXSECTORS>>3,fil); + dfwrite(&actortype[0],sizeof(char),MAXTILES,fil); + + dfwrite(&numclouds,sizeof(numclouds),1,fil); + dfwrite(&clouds[0],sizeof(short)<<7,1,fil); + dfwrite(&cloudx[0],sizeof(short)<<7,1,fil); + dfwrite(&cloudy[0],sizeof(short)<<7,1,fil); + + for(i=0;i= (long)(&script[0]) && (long)script[i] < (long)(&script[MAXSCRIPTSIZE]) ) + { + scriptptrs[i] = 1; + j = (long)script[i] - (long)&script[0]; + script[i] = j; + } + else scriptptrs[i] = 0; + } + + dfwrite(&scriptptrs[0],1,MAXSCRIPTSIZE,fil); + dfwrite(&script[0],4,MAXSCRIPTSIZE,fil); + + for(i=0;i= j && T2 < (long)(&script[MAXSCRIPTSIZE]) ) + { + scriptptrs[i] |= 1; + T2 -= j; + } + if(T5 >= j && T5 < (long)(&script[MAXSCRIPTSIZE]) ) + { + scriptptrs[i] |= 2; + T5 -= j; + } + if(T6 >= j && T6 < (long)(&script[MAXSCRIPTSIZE]) ) + { + scriptptrs[i] |= 4; + T6 -= j; + } + } + + dfwrite(&scriptptrs[0],1,MAXSPRITES,fil); + dfwrite(&hittype[0],sizeof(struct weaponhit),MAXSPRITES,fil); + + for(i=0;i=0;i--) animateptr[i] = (long *)((long)animateptr[i]-(long)(§or[0])); + dfwrite(&animateptr[0],4,MAXANIMATES,fil); + for(i = animatecnt-1;i>=0;i--) animateptr[i] = (long *)((long)animateptr[i]+(long)(§or[0])); + dfwrite(&animategoal[0],4,MAXANIMATES,fil); + dfwrite(&animatevel[0],4,MAXANIMATES,fil); + + dfwrite(&earthquaketime,sizeof(earthquaketime),1,fil); + dfwrite(&ud.from_bonus,sizeof(ud.from_bonus),1,fil); + dfwrite(&ud.secretlevel,sizeof(ud.secretlevel),1,fil); + dfwrite(&ud.respawn_monsters,sizeof(ud.respawn_monsters),1,fil); + dfwrite(&ud.respawn_items,sizeof(ud.respawn_items),1,fil); + dfwrite(&ud.respawn_inventory,sizeof(ud.respawn_inventory),1,fil); + dfwrite(&ud.god,sizeof(ud.god),1,fil); + dfwrite(&ud.auto_run,sizeof(ud.auto_run),1,fil); + dfwrite(&ud.crosshair,sizeof(ud.crosshair),1,fil); + dfwrite(&ud.monsters_off,sizeof(ud.monsters_off),1,fil); + dfwrite(&ud.last_level,sizeof(ud.last_level),1,fil); + dfwrite(&ud.eog,sizeof(ud.eog),1,fil); + dfwrite(&ud.coop,sizeof(ud.coop),1,fil); + dfwrite(&ud.marker,sizeof(ud.marker),1,fil); + dfwrite(&ud.ffire,sizeof(ud.ffire),1,fil); + dfwrite(&camsprite,sizeof(camsprite),1,fil); + dfwrite(&connecthead,sizeof(connecthead),1,fil); + dfwrite(connectpoint2,sizeof(connectpoint2),1,fil); + dfwrite(&numplayersprites,sizeof(numplayersprites),1,fil); + dfwrite((short *)&frags[0][0],sizeof(frags),1,fil); + + dfwrite(&randomseed,sizeof(randomseed),1,fil); + dfwrite(&global_random,sizeof(global_random),1,fil); + dfwrite(¶llaxyscale,sizeof(parallaxyscale),1,fil); + + dfwrite(&projectile[0],sizeof(proj_struct),MAXTILES,fil); + dfwrite(&defaultprojectile[0],sizeof(proj_struct),MAXTILES,fil); + dfwrite(&thisprojectile[0],sizeof(proj_struct),MAXSPRITES,fil); + + SaveGameVars(fil); + + fclose(fil); + + if(ud.multimode < 2) + { + strcpy(fta_quotes[122],"GAME SAVED"); + FTA(122,&ps[myconnectindex]); + } + + ready2send = 1; + + waitforeverybody(); + + ototalclock = totalclock; + + return(0); +} diff --git a/polymer/eduke32/source/savegame.what b/polymer/eduke32/source/savegame.what new file mode 100644 index 000000000..bba994335 --- /dev/null +++ b/polymer/eduke32/source/savegame.what @@ -0,0 +1,615 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "duke3d.h" + +int loadpheader(char spot,struct savehead *saveh) +{ + long i; + char fn[13]; + long fil; + long bv; + + strcpy(fn, "game0.sav"); + fn[4] = spot+'0'; + + if ((fil = kopen4load(fn,0)) == -1) return(-1); + + walock[TILE_LOADSHOT] = 255; + + if (kdfread(&bv,4,1,fil) != 1) goto corrupt; + if(bv != BYTEVERSION) { + FTA(114,&ps[myconnectindex]); + kclose(fil); + return 1; + } + + if (kdfread(&saveh->numplr,sizeof(int32),1,fil) != 1) goto corrupt; + + if (kdfread(saveh->name,19,1,fil) != 1) goto corrupt; + if (kdfread(&saveh->volnum,sizeof(int32),1,fil) != 1) goto corrupt; + if (kdfread(&saveh->levnum,sizeof(int32),1,fil) != 1) goto corrupt; + if (kdfread(&saveh->plrskl,sizeof(int32),1,fil) != 1) goto corrupt; + if (kdfread(saveh->boardfn,BMAX_PATH,1,fil) != 1) goto corrupt; + + if (waloff[TILE_LOADSHOT] == 0) allocache(&waloff[TILE_LOADSHOT],320*200,&walock[TILE_LOADSHOT]); + tilesizx[TILE_LOADSHOT] = 200; tilesizy[TILE_LOADSHOT] = 320; + if (kdfread((char *)waloff[TILE_LOADSHOT],320,200,fil) != 200) goto corrupt; + invalidatetile(TILE_LOADSHOT,0,255); + + kclose(fil); + + return(0); +corrupt: + kclose(fil); + return 1; +} + + +int loadplayer(signed char spot) +{ + short k; + char fn[13]; + char mpfn[13]; + char *fnptr, scriptptrs[MAXSCRIPTSIZE]; + long fil, bv, i, j, x; + int32 nump; + + strcpy(fn, "game0.sav"); + strcpy(mpfn, "gameA_00.sav"); + + if(spot < 0) + { + multiflag = 1; + multiwhat = 0; + multipos = -spot-1; + return -1; + } + + if( multiflag == 2 && multiwho != myconnectindex ) + { + fnptr = mpfn; + mpfn[4] = spot + 'A'; + + if(ud.multimode > 9) + { + mpfn[6] = (multiwho/10) + '0'; + mpfn[7] = (multiwho%10) + '0'; + } + else mpfn[7] = multiwho + '0'; + } + else + { + fnptr = fn; + fn[4] = spot + '0'; + } + + if ((fil = kopen4load(fnptr,0)) == -1) return(-1); + + ready2send = 0; + + if (kdfread(&bv,4,1,fil) != 1) return -1; + if(bv != BYTEVERSION) + { + FTA(114,&ps[myconnectindex]); + kclose(fil); + ototalclock = totalclock; + ready2send = 1; + return 1; + } + + if (kdfread(&nump,sizeof(nump),1,fil) != 1) return -1; + if(nump != numplayers) + { + kclose(fil); + ototalclock = totalclock; + ready2send = 1; + FTA(124,&ps[myconnectindex]); + return 1; + } + + if(numplayers > 1) + { + pub = NUMPAGES; + pus = NUMPAGES; + vscrn(); + drawbackground(); + menutext(160,100,0,0,"LOADING..."); + nextpage(); + } + + waitforeverybody(); + + FX_StopAllSounds(); + clearsoundlocks(); + MUSIC_StopSong(); + + if(numplayers > 1) { + if (kdfread(&buf,19,1,fil) != 1) goto corrupt; + } else { + if (kdfread(&ud.savegame[spot][0],19,1,fil) != 1) goto corrupt; + } + +// music_changed = (music_select != (ud.volume_number*11) + ud.level_number); + + if (kdfread(&ud.volume_number,sizeof(ud.volume_number),1,fil) != 1) goto corrupt; + if (kdfread(&ud.level_number,sizeof(ud.level_number),1,fil) != 1) goto corrupt; + if (kdfread(&ud.player_skill,sizeof(ud.player_skill),1,fil) != 1) goto corrupt; + if (kdfread(&boardfilename[0],BMAX_PATH,1,fil) != 1) goto corrupt; + + ud.m_level_number = ud.level_number; + ud.m_volume_number = ud.volume_number; + ud.m_player_skill = ud.player_skill; + + //Fake read because lseek won't work with compression + walock[TILE_LOADSHOT] = 1; + if (waloff[TILE_LOADSHOT] == 0) allocache(&waloff[TILE_LOADSHOT],320*200,&walock[TILE_LOADSHOT]); + tilesizx[TILE_LOADSHOT] = 200; tilesizy[TILE_LOADSHOT] = 320; + if (kdfread((char *)waloff[TILE_LOADSHOT],320,200,fil) != 200) goto corrupt; + invalidatetile(TILE_LOADSHOT,0,255); + + if (kdfread(&numwalls,2,1,fil) != 1) goto corrupt; + if (kdfread(&wall[0],sizeof(walltype),MAXWALLS,fil) != MAXWALLS) goto corrupt; + if (kdfread(&numsectors,2,1,fil) != 1) goto corrupt; + if (kdfread(§or[0],sizeof(sectortype),MAXSECTORS,fil) != MAXSECTORS) goto corrupt; + if (kdfread(&sprite[0],sizeof(spritetype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&spriteext[0],sizeof(spriteexttype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&headspritesect[0],2,MAXSECTORS+1,fil) != MAXSECTORS+1) goto corrupt; + if (kdfread(&prevspritesect[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&nextspritesect[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&headspritestat[0],2,MAXSTATUS+1,fil) != MAXSTATUS+1) goto corrupt; + if (kdfread(&prevspritestat[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&nextspritestat[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&numcyclers,sizeof(numcyclers),1,fil) != 1) goto corrupt; + if (kdfread(&cyclers[0][0],12,MAXCYCLERS,fil) != MAXCYCLERS) goto corrupt; + if (kdfread(ps,sizeof(ps),1,fil) != 1) goto corrupt; + if (kdfread(po,sizeof(po),1,fil) != 1) goto corrupt; + if (kdfread(&numanimwalls,sizeof(numanimwalls),1,fil) != 1) goto corrupt; + if (kdfread(&animwall,sizeof(animwall),1,fil) != 1) goto corrupt; + if (kdfread(&msx[0],sizeof(long),sizeof(msx)/sizeof(long),fil) != sizeof(msx)/sizeof(long)) goto corrupt; + if (kdfread(&msy[0],sizeof(long),sizeof(msy)/sizeof(long),fil) != sizeof(msy)/sizeof(long)) goto corrupt; + if (kdfread((short *)&spriteqloc,sizeof(short),1,fil) != 1) goto corrupt; + if (kdfread((short *)&spriteqamount,sizeof(short),1,fil) != 1) goto corrupt; + if (kdfread((short *)&spriteq[0],sizeof(short),spriteqamount,fil) != spriteqamount) goto corrupt; + if (kdfread(&mirrorcnt,sizeof(short),1,fil) != 1) goto corrupt; + if (kdfread(&mirrorwall[0],sizeof(short),64,fil) != 64) goto corrupt; + if (kdfread(&mirrorsector[0],sizeof(short),64,fil) != 64) goto corrupt; + if (kdfread(&show2dsector[0],sizeof(char),MAXSECTORS>>3,fil) != (MAXSECTORS>>3)) goto corrupt; + if (kdfread(&actortype[0],sizeof(char),MAXTILES,fil) != MAXTILES) goto corrupt; + + if (kdfread(&numclouds,sizeof(numclouds),1,fil) != 1) goto corrupt; + if (kdfread(&clouds[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; + if (kdfread(&cloudx[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; + if (kdfread(&cloudy[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; + + if (kdfread(&scriptptrs[0],1,MAXSCRIPTSIZE,fil) != MAXSCRIPTSIZE) goto corrupt; + if (kdfread(&script[0],4,MAXSCRIPTSIZE,fil) != MAXSCRIPTSIZE) goto corrupt; + for(i=0;i=0;i--) animateptr[i] = (long *)((long)animateptr[i]+(long)(§or[0])); + if (kdfread(&animategoal[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; + if (kdfread(&animatevel[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; + + if (kdfread(&earthquaketime,sizeof(earthquaketime),1,fil) != 1) goto corrupt; + if (kdfread(&ud.from_bonus,sizeof(ud.from_bonus),1,fil) != 1) goto corrupt; + if (kdfread(&ud.secretlevel,sizeof(ud.secretlevel),1,fil) != 1) goto corrupt; + if (kdfread(&ud.respawn_monsters,sizeof(ud.respawn_monsters),1,fil) != 1) goto corrupt; + ud.m_respawn_monsters = ud.respawn_monsters; + if (kdfread(&ud.respawn_items,sizeof(ud.respawn_items),1,fil) != 1) goto corrupt; + ud.m_respawn_items = ud.respawn_items; + if (kdfread(&ud.respawn_inventory,sizeof(ud.respawn_inventory),1,fil) != 1) goto corrupt; + ud.m_respawn_inventory = ud.respawn_inventory; + + if (kdfread(&ud.god,sizeof(ud.god),1,fil) != 1) goto corrupt; + if (kdfread(&ud.auto_run,sizeof(ud.auto_run),1,fil) != 1) goto corrupt; + if (kdfread(&ud.crosshair,sizeof(ud.crosshair),1,fil) != 1) goto corrupt; + if (kdfread(&ud.monsters_off,sizeof(ud.monsters_off),1,fil) != 1) goto corrupt; + ud.m_monsters_off = ud.monsters_off; + if (kdfread(&ud.last_level,sizeof(ud.last_level),1,fil) != 1) goto corrupt; + if (kdfread(&ud.eog,sizeof(ud.eog),1,fil) != 1) goto corrupt; + + if (kdfread(&ud.coop,sizeof(ud.coop),1,fil) != 1) goto corrupt; + ud.m_coop = ud.coop; + if (kdfread(&ud.marker,sizeof(ud.marker),1,fil) != 1) goto corrupt; + ud.m_marker = ud.marker; + if (kdfread(&ud.ffire,sizeof(ud.ffire),1,fil) != 1) goto corrupt; + ud.m_ffire = ud.ffire; + + if (kdfread(&camsprite,sizeof(camsprite),1,fil) != 1) goto corrupt; + if (kdfread(&connecthead,sizeof(connecthead),1,fil) != 1) goto corrupt; + if (kdfread(connectpoint2,sizeof(connectpoint2),1,fil) != 1) goto corrupt; + if (kdfread(&numplayersprites,sizeof(numplayersprites),1,fil) != 1) goto corrupt; + if (kdfread((short *)&frags[0][0],sizeof(frags),1,fil) != 1) goto corrupt; + + if (kdfread(&randomseed,sizeof(randomseed),1,fil) != 1) goto corrupt; + if (kdfread(&global_random,sizeof(global_random),1,fil) != 1) goto corrupt; + if (kdfread(¶llaxyscale,sizeof(parallaxyscale),1,fil) != 1) goto corrupt; + + kclose(fil); + + if(ps[myconnectindex].over_shoulder_on != 0) + { + cameradist = 0; + cameraclock = 0; + ps[myconnectindex].over_shoulder_on = 1; + } + + screenpeek = myconnectindex; + + clearbufbyte(gotpic,sizeof(gotpic),0L); + clearsoundlocks(); + cacheit(); + + music_select = (ud.volume_number*11) + ud.level_number; + playmusic(&music_fn[0][music_select][0]); + + ps[myconnectindex].gm = MODE_GAME; + ud.recstat = 0; + + if(ps[myconnectindex].jetpack_on) + spritesound(DUKE_JETPACK_IDLE,ps[myconnectindex].i); + + restorepalette = 1; + setpal(&ps[myconnectindex]); + vscrn(); + + FX_SetReverb(0); + + if(ud.lockout == 0) + { + for(x=0;x= 0 ) + wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; + } + else + { + for(x=0;x= 0) + { + switch(sprite[k].lotag) + { + case 31: + setinterpolation(§or[sprite[k].sectnum].floorz); + break; + case 32: + setinterpolation(§or[sprite[k].sectnum].ceilingz); + break; + case 25: + setinterpolation(§or[sprite[k].sectnum].floorz); + setinterpolation(§or[sprite[k].sectnum].ceilingz); + break; + case 17: + setinterpolation(§or[sprite[k].sectnum].floorz); + setinterpolation(§or[sprite[k].sectnum].ceilingz); + break; + case 0: + case 5: + case 6: + case 11: + case 14: + case 15: + case 16: + case 26: + case 30: + setsectinterpolate(k); + break; + } + + k = nextspritestat[k]; + } + + for(i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; + for(i = animatecnt-1;i>=0;i--) + setinterpolation(animateptr[i]); + + show_shareware = 0; + everyothertime = 0; + + clearbufbyte(playerquitflag,MAXPLAYERS,0x01010101); + + resetmys(); + + ready2send = 1; + + flushpackets(); + clearfifo(); + waitforeverybody(); + + resettimevars(); + + return(0); +corrupt: + Bsprintf(tempbuf,"Save game file \"%s\" is corrupt.",fnptr); + gameexit(tempbuf); + return -1; +} + +int saveplayer(signed char spot) +{ + long i, j; + char fn[13]; + char mpfn[13]; + char *fnptr,scriptptrs[MAXSCRIPTSIZE]; + FILE *fil; + long bv = BYTEVERSION; + + strcpy(fn, "game0.sav"); + strcpy(mpfn, "gameA_00.sav"); + + if(spot < 0) + { + multiflag = 1; + multiwhat = 1; + multipos = -spot-1; + return -1; + } + + waitforeverybody(); + + if( multiflag == 2 && multiwho != myconnectindex ) + { + fnptr = mpfn; + mpfn[4] = spot + 'A'; + + if(ud.multimode > 9) + { + mpfn[6] = (multiwho/10) + '0'; + mpfn[7] = multiwho + '0'; + } + else mpfn[7] = multiwho + '0'; + } + else + { + fnptr = fn; + fn[4] = spot + '0'; + } + + if ((fil = fopen(fnptr,"wb")) == 0) return(-1); + + ready2send = 0; + + dfwrite(&bv,4,1,fil); + dfwrite(&ud.multimode,sizeof(ud.multimode),1,fil); + + dfwrite(&ud.savegame[spot][0],19,1,fil); + dfwrite(&ud.volume_number,sizeof(ud.volume_number),1,fil); + dfwrite(&ud.level_number,sizeof(ud.level_number),1,fil); + dfwrite(&ud.player_skill,sizeof(ud.player_skill),1,fil); + dfwrite(&boardfilename[0],BMAX_PATH,1,fil); + + if (!waloff[TILE_SAVESHOT]) { + walock[TILE_SAVESHOT] = 254; + allocache((long *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]); + clearbuf((void*)waloff[TILE_SAVESHOT],(200*320)/4,0); + walock[TILE_SAVESHOT] = 1; + } + dfwrite((char *)waloff[TILE_SAVESHOT],320,200,fil); + + dfwrite(&numwalls,2,1,fil); + dfwrite(&wall[0],sizeof(walltype),MAXWALLS,fil); + dfwrite(&numsectors,2,1,fil); + dfwrite(§or[0],sizeof(sectortype),MAXSECTORS,fil); + dfwrite(&sprite[0],sizeof(spritetype),MAXSPRITES,fil); + dfwrite(&spriteext[0],sizeof(spriteexttype),MAXSPRITES,fil); + dfwrite(&headspritesect[0],2,MAXSECTORS+1,fil); + dfwrite(&prevspritesect[0],2,MAXSPRITES,fil); + dfwrite(&nextspritesect[0],2,MAXSPRITES,fil); + dfwrite(&headspritestat[0],2,MAXSTATUS+1,fil); + dfwrite(&prevspritestat[0],2,MAXSPRITES,fil); + dfwrite(&nextspritestat[0],2,MAXSPRITES,fil); + dfwrite(&numcyclers,sizeof(numcyclers),1,fil); + dfwrite(&cyclers[0][0],12,MAXCYCLERS,fil); + dfwrite(ps,sizeof(ps),1,fil); + dfwrite(po,sizeof(po),1,fil); + dfwrite(&numanimwalls,sizeof(numanimwalls),1,fil); + dfwrite(&animwall,sizeof(animwall),1,fil); + dfwrite(&msx[0],sizeof(long),sizeof(msx)/sizeof(long),fil); + dfwrite(&msy[0],sizeof(long),sizeof(msy)/sizeof(long),fil); + dfwrite(&spriteqloc,sizeof(short),1,fil); + dfwrite(&spriteqamount,sizeof(short),1,fil); + dfwrite(&spriteq[0],sizeof(short),spriteqamount,fil); + dfwrite(&mirrorcnt,sizeof(short),1,fil); + dfwrite(&mirrorwall[0],sizeof(short),64,fil); + dfwrite(&mirrorsector[0],sizeof(short),64,fil); + dfwrite(&show2dsector[0],sizeof(char),MAXSECTORS>>3,fil); + dfwrite(&actortype[0],sizeof(char),MAXTILES,fil); + + dfwrite(&numclouds,sizeof(numclouds),1,fil); + dfwrite(&clouds[0],sizeof(short)<<7,1,fil); + dfwrite(&cloudx[0],sizeof(short)<<7,1,fil); + dfwrite(&cloudy[0],sizeof(short)<<7,1,fil); + + for(i=0;i= (long)(&script[0]) && (long)script[i] < (long)(&script[MAXSCRIPTSIZE]) ) + { + scriptptrs[i] = 1; + j = (long)script[i] - (long)&script[0]; + script[i] = j; + } + else scriptptrs[i] = 0; + } + + dfwrite(&scriptptrs[0],1,MAXSCRIPTSIZE,fil); + dfwrite(&script[0],4,MAXSCRIPTSIZE,fil); + + for(i=0;i= j && T2 < (long)(&script[MAXSCRIPTSIZE]) ) + { + scriptptrs[i] |= 1; + T2 -= j; + } + if(T5 >= j && T5 < (long)(&script[MAXSCRIPTSIZE]) ) + { + scriptptrs[i] |= 2; + T5 -= j; + } + if(T6 >= j && T6 < (long)(&script[MAXSCRIPTSIZE]) ) + { + scriptptrs[i] |= 4; + T6 -= j; + } + } + + dfwrite(&scriptptrs[0],1,MAXSPRITES,fil); + dfwrite(&hittype[0],sizeof(struct weaponhit),MAXSPRITES,fil); + + for(i=0;i=0;i--) animateptr[i] = (long *)((long)animateptr[i]-(long)(§or[0])); + dfwrite(&animateptr[0],4,MAXANIMATES,fil); + for(i = animatecnt-1;i>=0;i--) animateptr[i] = (long *)((long)animateptr[i]+(long)(§or[0])); + dfwrite(&animategoal[0],4,MAXANIMATES,fil); + dfwrite(&animatevel[0],4,MAXANIMATES,fil); + + dfwrite(&earthquaketime,sizeof(earthquaketime),1,fil); + dfwrite(&ud.from_bonus,sizeof(ud.from_bonus),1,fil); + dfwrite(&ud.secretlevel,sizeof(ud.secretlevel),1,fil); + dfwrite(&ud.respawn_monsters,sizeof(ud.respawn_monsters),1,fil); + dfwrite(&ud.respawn_items,sizeof(ud.respawn_items),1,fil); + dfwrite(&ud.respawn_inventory,sizeof(ud.respawn_inventory),1,fil); + dfwrite(&ud.god,sizeof(ud.god),1,fil); + dfwrite(&ud.auto_run,sizeof(ud.auto_run),1,fil); + dfwrite(&ud.crosshair,sizeof(ud.crosshair),1,fil); + dfwrite(&ud.monsters_off,sizeof(ud.monsters_off),1,fil); + dfwrite(&ud.last_level,sizeof(ud.last_level),1,fil); + dfwrite(&ud.eog,sizeof(ud.eog),1,fil); + dfwrite(&ud.coop,sizeof(ud.coop),1,fil); + dfwrite(&ud.marker,sizeof(ud.marker),1,fil); + dfwrite(&ud.ffire,sizeof(ud.ffire),1,fil); + dfwrite(&camsprite,sizeof(camsprite),1,fil); + dfwrite(&connecthead,sizeof(connecthead),1,fil); + dfwrite(connectpoint2,sizeof(connectpoint2),1,fil); + dfwrite(&numplayersprites,sizeof(numplayersprites),1,fil); + dfwrite((short *)&frags[0][0],sizeof(frags),1,fil); + + dfwrite(&randomseed,sizeof(randomseed),1,fil); + dfwrite(&global_random,sizeof(global_random),1,fil); + dfwrite(¶llaxyscale,sizeof(parallaxyscale),1,fil); + + fclose(fil); + + if(ud.multimode < 2) + { + strcpy(fta_quotes[122],"GAME SAVED"); + FTA(122,&ps[myconnectindex]); + } + + ready2send = 1; + + waitforeverybody(); + + ototalclock = totalclock; + + return(0); +} diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c new file mode 100644 index 000000000..56f6e3459 --- /dev/null +++ b/polymer/eduke32/source/sector.c @@ -0,0 +1,3522 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#include "duke3d.h" +#include "osd.h" + +// PRIMITIVE + +char haltsoundhack; +short callsound(short sn,short whatsprite) +{ + short i; + + if(haltsoundhack) + { + haltsoundhack = 0; + return -1; + } + + i = headspritesect[sn]; + while(i >= 0) + { + if( PN == MUSICANDSFX && SLT < 1000 ) + { + if(whatsprite == -1) whatsprite = i; + + if(T1 == 0) + { + if( (soundm[SLT]&16) == 0) + { + if(SLT) + { + spritesound(SLT,whatsprite); + if(SHT && SLT != SHT && SHT < NUM_SOUNDS) + stopspritesound(SHT,whatsprite); + } + + if( (sector[SECT].lotag&0xff) != 22) + T1 = 1; + } + } + else if(SHT < NUM_SOUNDS) + { + if(SHT) spritesound(SHT,whatsprite); + if( (soundm[SLT]&1) || ( SHT && SHT != SLT ) ) + stopspritesound(SLT,whatsprite); + T1 = 0; + } + return SLT; + } + i = nextspritesect[i]; + } + return -1; +} + +short check_activator_motion( short lotag ) +{ + short i, j; + spritetype *s; + + i = headspritestat[8]; + while ( i >= 0 ) + { + if ( sprite[i].lotag == lotag ) + { + s = &sprite[i]; + + for ( j = animatecnt-1; j >= 0; j-- ) + if ( s->sectnum == animatesect[j] ) + return( 1 ); + + j = headspritestat[3]; + while ( j >= 0 ) + { + if(s->sectnum == sprite[j].sectnum) + switch(sprite[j].lotag) + { + case 11: + case 30: + if ( hittype[j].temp_data[4] ) + return( 1 ); + break; + case 20: + case 31: + case 32: + case 18: + if ( hittype[j].temp_data[0] ) + return( 1 ); + break; + } + + j = nextspritestat[j]; + } + } + i = nextspritestat[i]; + } + return( 0 ); +} + +char isadoorwall(short dapic) +{ + switch(dynamictostatic[dapic]) + { + case DOORTILE1__STATIC: + case DOORTILE2__STATIC: + case DOORTILE3__STATIC: + case DOORTILE4__STATIC: + case DOORTILE5__STATIC: + case DOORTILE6__STATIC: + case DOORTILE7__STATIC: + case DOORTILE8__STATIC: + case DOORTILE9__STATIC: + case DOORTILE10__STATIC: + case DOORTILE11__STATIC: + case DOORTILE12__STATIC: + case DOORTILE14__STATIC: + case DOORTILE15__STATIC: + case DOORTILE16__STATIC: + case DOORTILE17__STATIC: + case DOORTILE18__STATIC: + case DOORTILE19__STATIC: + case DOORTILE20__STATIC: + case DOORTILE21__STATIC: + case DOORTILE22__STATIC: + case DOORTILE23__STATIC: + return 1; + } + return 0; +} + +char isanunderoperator(short lotag) +{ + switch(lotag&0xff) + { + case 15: + case 16: + case 17: + case 18: + case 19: + case 22: + case 26: + return 1; + } + return 0; +} + +char isanearoperator(short lotag) +{ + switch(lotag&0xff) + { + case 9: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 25: + case 26: + case 29://Toothed door + return 1; + } + return 0; +} + +short checkcursectnums(short sect) +{ + short i; + for(i=connecthead;i>=0;i=connectpoint2[i]) + if( sprite[ps[i].i].sectnum == sect ) return i; + return -1; +} + +long ldist(spritetype *s1,spritetype *s2) +{ + long vx,vy; + vx = s1->x - s2->x; + vy = s1->y - s2->y; + return(FindDistance2D(vx,vy) + 1); +} + +long dist(spritetype *s1,spritetype *s2) +{ + long vx,vy,vz; + vx = s1->x - s2->x; + vy = s1->y - s2->y; + vz = s1->z - s2->z; + return(FindDistance3D(vx,vy,vz>>4)); +} + +long txdist(spritetype *s1,spritetype *s2) +{ + long vx,vy,vz; + vx = s1->x - s2->x; + vy = s1->y - s2->y; + vz = s1->z - s2->z - s2->yrepeat; + return(FindDistance3D(vx,vy,vz>>4)); +} + +short findplayer(spritetype *s,long *d) +{ + short j, closest_player; + long x, closest; + + if(ud.multimode < 2) + { + *d = klabs(ps[myconnectindex].oposx-s->x) + klabs(ps[myconnectindex].oposy-s->y) + ((klabs(ps[myconnectindex].oposz-s->z+(28<<8)))>>4); + return myconnectindex; + } + + closest = 0x7fffffff; + closest_player = 0; + + for(j=connecthead;j>=0;j=connectpoint2[j]) + { + x = klabs(ps[j].oposx-s->x) + klabs(ps[j].oposy-s->y) + ((klabs(ps[j].oposz-s->z+(28<<8)))>>4); + if( x < closest && sprite[ps[j].i].extra > 0 ) + { + closest_player = j; + closest = x; + } + } + + *d = closest; + return closest_player; +} + +short findotherplayer(short p,long *d) +{ + short j, closest_player; + long x, closest; + + closest = 0x7fffffff; + closest_player = p; + + for(j=connecthead;j>=0;j=connectpoint2[j]) + if(p != j && sprite[ps[j].i].extra > 0) + { + x = klabs(ps[j].oposx-ps[p].posx) + klabs(ps[j].oposy-ps[p].posy) + (klabs(ps[j].oposz-ps[p].posz)>>4); + + if( x < closest ) + { + closest_player = j; + closest = x; + } + } + + *d = closest; + return closest_player; +} + +void doanimations(void) +{ + long i, j, a, p, v, dasect; + + for(i=animatecnt-1;i>=0;i--) + { + a = *animateptr[i]; + v = animatevel[i]*TICSPERFRAME; + dasect = animatesect[i]; + + if (a == animategoal[i]) + { + stopinterpolation(animateptr[i]); + + animatecnt--; + animateptr[i] = animateptr[animatecnt]; + animategoal[i] = animategoal[animatecnt]; + animatevel[i] = animatevel[animatecnt]; + animatesect[i] = animatesect[animatecnt]; + if( sector[animatesect[i]].lotag == 18 || sector[animatesect[i]].lotag == 19 ) + if(animateptr[i] == §or[animatesect[i]].ceilingz) + continue; + + if( (sector[dasect].lotag&0xff) != 22 ) + callsound(dasect,-1); + + continue; + } + + if (v > 0) { a = min(a+v,animategoal[i]); } + else { a = max(a+v,animategoal[i]); } + + if( animateptr[i] == §or[animatesect[i]].floorz) + { + for(p=connecthead;p>=0;p=connectpoint2[p]) + if (ps[p].cursectnum == dasect) + if ((sector[dasect].floorz-ps[p].posz) < (64<<8)) + if (sprite[ps[p].i].owner >= 0) + { + ps[p].posz += v; + ps[p].poszv = 0; + if (p == myconnectindex) + { + myz += v; + myzvel = 0; + myzbak[((movefifoplc-1)&(MOVEFIFOSIZ-1))] = ps[p].posz; + } + } + + for(j=headspritesect[dasect];j>=0;j=nextspritesect[j]) + if (sprite[j].statnum != 3) + { + hittype[j].bposz = sprite[j].z; + sprite[j].z += v; + hittype[j].floorz = sector[dasect].floorz+v; + } + } + + *animateptr[i] = a; + } +} + +int getanimationgoal(long *animptr) +{ + long i, j; + + j = -1; + for(i=animatecnt-1;i>=0;i--) + if (animptr == (long *)animateptr[i]) + { + j = i; + break; + } + return(j); +} + +int setanimation(short animsect,long *animptr, long thegoal, long thevel) +{ + long i, j; + + if (animatecnt >= MAXANIMATES-1) + return(-1); + + j = animatecnt; + for(i=0;i= *animptr) + animatevel[j] = thevel; + else + animatevel[j] = -thevel; + + if (j == animatecnt) animatecnt++; + + setinterpolation(animptr); + + return(j); +} + +void animatecamsprite(void) +{ + short i; + + if(camsprite <= 0) return; + + i = camsprite; + + if(T1 >= 11) + { + T1 = 0; + + if(ps[screenpeek].newowner >= 0) + OW = ps[screenpeek].newowner; + + else if(OW >= 0 && dist(&sprite[ps[screenpeek].i],&sprite[i]) < 2048) + { + if (waloff[TILE_VIEWSCR] == 0) + allocatepermanenttile(TILE_VIEWSCR,tilesizx[PN],tilesizy[PN]); + else walock[TILE_VIEWSCR] = 255; + xyzmirror(OW,/*PN*/TILE_VIEWSCR); + } + } + else T1++; +} + +void animatewalls(void) +{ + long i, j, p, t; + + for(p=0;p < numanimwalls ;p++) + // for(p=numanimwalls-1;p>=0;p--) + { + i = animwall[p].wallnum; + j = wall[i].picnum; + + switch(dynamictostatic[j]) + { + case SCREENBREAK1__STATIC: + case SCREENBREAK2__STATIC: + case SCREENBREAK3__STATIC: + case SCREENBREAK4__STATIC: + case SCREENBREAK5__STATIC: + + case SCREENBREAK9__STATIC: + case SCREENBREAK10__STATIC: + case SCREENBREAK11__STATIC: + case SCREENBREAK12__STATIC: + case SCREENBREAK13__STATIC: + case SCREENBREAK14__STATIC: + case SCREENBREAK15__STATIC: + case SCREENBREAK16__STATIC: + case SCREENBREAK17__STATIC: + case SCREENBREAK18__STATIC: + case SCREENBREAK19__STATIC: + + if( (TRAND&255) < 16) + { + animwall[p].tag = wall[i].picnum; + wall[i].picnum = SCREENBREAK6; + } + + continue; + + case SCREENBREAK6__STATIC: + case SCREENBREAK7__STATIC: + case SCREENBREAK8__STATIC: + + if(animwall[p].tag >= 0 && wall[i].extra != FEMPIC2 && wall[i].extra != FEMPIC3 ) + wall[i].picnum = animwall[p].tag; + else + { + wall[i].picnum++; + if(wall[i].picnum == (SCREENBREAK6+3) ) + wall[i].picnum = SCREENBREAK6; + } + continue; + + } + + if(wall[i].cstat&16) + if ((wall[i].overpicnum >= W_FORCEFIELD)&&(wall[i].overpicnum <= W_FORCEFIELD+2)) + { + + t = animwall[p].tag; + + if(wall[i].cstat&254) + { + wall[i].xpanning -= t>>10; // sintable[(t+512)&2047]>>12; + wall[i].ypanning -= t>>10; // sintable[t&2047]>>12; + + if(wall[i].extra == 1) + { + wall[i].extra = 0; + animwall[p].tag = 0; + } + else + animwall[p].tag+=128; + + if( animwall[p].tag < (128<<4) ) + { + if( animwall[p].tag&128 ) + wall[i].overpicnum = W_FORCEFIELD; + else wall[i].overpicnum = W_FORCEFIELD+1; + } + else + { + if( (TRAND&255) < 32 ) + animwall[p].tag = 128<<(TRAND&3); + else wall[i].overpicnum = W_FORCEFIELD+1; + } + } + + } + } +} + +char activatewarpelevators(short s,short d) //Parm = sectoreffectornum +{ + short i, sn; + + sn = sprite[s].sectnum; + + // See if the sector exists + + i = headspritestat[3]; + while(i >= 0) + { + if( SLT == 17 ) + if( SHT == sprite[s].hitag ) + if( (klabs(sector[sn].floorz-hittype[s].temp_data[2]) > SP) || + (sector[SECT].hitag == (sector[sn].hitag-d) ) ) + break; + i = nextspritestat[i]; + } + + if(i==-1) + { + d = 0; + return 1; // No find + } + else + { + if(d == 0) + spritesound(ELEVATOR_OFF,s); + else spritesound(ELEVATOR_ON,s); + } + + + i = headspritestat[3]; + while(i >= 0) + { + if( SLT == 17 ) + if( SHT == sprite[s].hitag ) + { + T1 = d; + T2 = d; //Make all check warp + } + i = nextspritestat[i]; + } + return 0; +} + +void operatesectors(short sn,short ii) +{ + long j=0, l, q, startwall, endwall; + short i; + char sect_error; + sectortype *sptr; + + sect_error = 0; + sptr = §or[sn]; + + switch(sptr->lotag&(0xffff-49152)) + { + + case 30: + j = sector[sn].hitag; + if( hittype[j].tempang == 0 || + hittype[j].tempang == 256) + callsound(sn,ii); + if(sprite[j].extra == 1) + sprite[j].extra = 3; + else sprite[j].extra = 1; + break; + + case 31: + + j = sector[sn].hitag; + if(hittype[j].temp_data[4] == 0) + hittype[j].temp_data[4] = 1; + + callsound(sn,ii); + break; + + case 26: //The split doors + i = getanimationgoal(&sptr->ceilingz); + if(i == -1) //if the door has stopped + { + haltsoundhack = 1; + sptr->lotag &= 0xff00; + sptr->lotag |= 22; + operatesectors(sn,ii); + sptr->lotag &= 0xff00; + sptr->lotag |= 9; + operatesectors(sn,ii); + sptr->lotag &= 0xff00; + sptr->lotag |= 26; + } + return; + + case 9: + { + long dax,day,dax2,day2,sp; + long wallfind[2]; + + startwall = sptr->wallptr; + endwall = startwall+sptr->wallnum-1; + + sp = sptr->extra>>4; + + //first find center point by averaging all points + dax = 0L, day = 0L; + for(i=startwall;i<=endwall;i++) + { + dax += wall[i].x; + day += wall[i].y; + } + dax /= (endwall-startwall+1); + day /= (endwall-startwall+1); + + //find any points with either same x or same y coordinate + // as center (dax, day) - should be 2 points found. + wallfind[0] = -1; + wallfind[1] = -1; + for(i=startwall;i<=endwall;i++) + if ((wall[i].x == dax) || (wall[i].y == day)) + { + if (wallfind[0] == -1) + wallfind[0] = i; + else wallfind[1] = i; + } + + for(j=0;j<2;j++) + { + if ((wall[wallfind[j]].x == dax) && (wall[wallfind[j]].y == day)) + { + //find what direction door should open by averaging the + // 2 neighboring points of wallfind[0] & wallfind[1]. + i = wallfind[j]-1; if (i < startwall) i = endwall; + dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x; + day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; + if (dax2 != 0) + { + dax2 = wall[wall[wall[wallfind[j]].point2].point2].x; + dax2 -= wall[wall[wallfind[j]].point2].x; + setanimation(sn,&wall[wallfind[j]].x,wall[wallfind[j]].x+dax2,sp); + setanimation(sn,&wall[i].x,wall[i].x+dax2,sp); + setanimation(sn,&wall[wall[wallfind[j]].point2].x,wall[wall[wallfind[j]].point2].x+dax2,sp); + callsound(sn,ii); + } + else if (day2 != 0) + { + day2 = wall[wall[wall[wallfind[j]].point2].point2].y; + day2 -= wall[wall[wallfind[j]].point2].y; + setanimation(sn,&wall[wallfind[j]].y,wall[wallfind[j]].y+day2,sp); + setanimation(sn,&wall[i].y,wall[i].y+day2,sp); + setanimation(sn,&wall[wall[wallfind[j]].point2].y,wall[wall[wallfind[j]].point2].y+day2,sp); + callsound(sn,ii); + } + } + else + { + i = wallfind[j]-1; if (i < startwall) i = endwall; + dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x; + day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; + if (dax2 != 0) + { + setanimation(sn,&wall[wallfind[j]].x,dax,sp); + setanimation(sn,&wall[i].x,dax+dax2,sp); + setanimation(sn,&wall[wall[wallfind[j]].point2].x,dax+dax2,sp); + callsound(sn,ii); + } + else if (day2 != 0) + { + setanimation(sn,&wall[wallfind[j]].y,day,sp); + setanimation(sn,&wall[i].y,day+day2,sp); + setanimation(sn,&wall[wall[wallfind[j]].point2].y,day+day2,sp); + callsound(sn,ii); + } + } + } + + } + return; + + case 15://Warping elevators + + if(sprite[ii].picnum != APLAYER) return; + // if(ps[sprite[ii].yvel].select_dir == 1) return; + + i = headspritesect[sn]; + while(i >= 0) + { + if(PN==SECTOREFFECTOR && SLT == 17 ) break; + i = nextspritesect[i]; + } + + if(sprite[ii].sectnum == sn) + { + if( activatewarpelevators(i,-1) ) + activatewarpelevators(i,1); + else if( activatewarpelevators(i,1) ) + activatewarpelevators(i,-1); + return; + } + else + { + if(sptr->floorz > SZ) + activatewarpelevators(i,-1); + else + activatewarpelevators(i,1); + } + + return; + + case 16: + case 17: + + i = getanimationgoal(&sptr->floorz); + + if(i == -1) + { + i = nextsectorneighborz(sn,sptr->floorz,1,1); + if( i == -1 ) + { + i = nextsectorneighborz(sn,sptr->floorz,1,-1); + if( i == -1 ) return; + j = sector[i].floorz; + setanimation(sn,&sptr->floorz,j,sptr->extra); + } + else + { + j = sector[i].floorz; + setanimation(sn,&sptr->floorz,j,sptr->extra); + } + callsound(sn,ii); + } + + return; + + case 18: + case 19: + + i = getanimationgoal(&sptr->floorz); + + if(i==-1) + { + i = nextsectorneighborz(sn,sptr->floorz,1,-1); + if(i==-1) i = nextsectorneighborz(sn,sptr->floorz,1,1); + if(i==-1) return; + j = sector[i].floorz; + q = sptr->extra; + l = sptr->ceilingz-sptr->floorz; + setanimation(sn,&sptr->floorz,j,q); + setanimation(sn,&sptr->ceilingz,j+l,q); + callsound(sn,ii); + } + return; + + case 29: + + if(sptr->lotag&0x8000) + j = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; + else + j = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz; + + i = headspritestat[3]; //Effectors + while(i >= 0) + { + if( (SLT == 22) && + (SHT == sptr->hitag) ) + { + sector[SECT].extra = -sector[SECT].extra; + + T1 = sn; + T2 = 1; + } + i = nextspritestat[i]; + } + + sptr->lotag ^= 0x8000; + + setanimation(sn,&sptr->ceilingz,j,sptr->extra); + + callsound(sn,ii); + + return; + + case 20: + +REDODOOR: + + if(sptr->lotag&0x8000) + { + i = headspritesect[sn]; + while(i >= 0) + { + if(sprite[i].statnum == 3 && SLT==9) + { + j = SZ; + break; + } + i = nextspritesect[i]; + } + if(i==-1) + j = sptr->floorz; + } + else + { + j = nextsectorneighborz(sn,sptr->ceilingz,-1,-1); + + if(j >= 0) j = sector[j].ceilingz; + else + { + sptr->lotag |= 32768; + goto REDODOOR; + } + } + + sptr->lotag ^= 0x8000; + + setanimation(sn,&sptr->ceilingz,j,sptr->extra); + callsound(sn,ii); + + return; + + case 21: + i = getanimationgoal(&sptr->floorz); + if (i >= 0) + { + if (animategoal[sn] == sptr->ceilingz) + animategoal[i] = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; + else animategoal[i] = sptr->ceilingz; + j = animategoal[i]; + } + else + { + if (sptr->ceilingz == sptr->floorz) + j = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; + else j = sptr->ceilingz; + + sptr->lotag ^= 0x8000; + + if(setanimation(sn,&sptr->floorz,j,sptr->extra) >= 0) + callsound(sn,ii); + } + return; + + case 22: + + // REDODOOR22: + + if ( (sptr->lotag&0x8000) ) + { + q = (sptr->ceilingz+sptr->floorz)>>1; + j = setanimation(sn,&sptr->floorz,q,sptr->extra); + j = setanimation(sn,&sptr->ceilingz,q,sptr->extra); + } + else + { + q = sector[nextsectorneighborz(sn,sptr->floorz,1,1)].floorz; + j = setanimation(sn,&sptr->floorz,q,sptr->extra); + q = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz; + j = setanimation(sn,&sptr->ceilingz,q,sptr->extra); + } + + sptr->lotag ^= 0x8000; + + callsound(sn,ii); + + return; + + case 23: //Swingdoor + + j = -1; + q = 0; + + i = headspritestat[3]; + while(i >= 0) + { + if( SLT == 11 && SECT == sn && !T5) + { + j = i; + break; + } + i = nextspritestat[i]; + } + if (i<0) { OSD_Printf("WARNING: SE23 i<0!\n"); return; } // JBF + l = sector[SECT].lotag&0x8000; + + if(j >= 0) + { + i = headspritestat[3]; + while(i >= 0) + { + if( l == (sector[SECT].lotag&0x8000) && SLT == 11 && sprite[j].hitag == SHT && !T5 ) + { + if(sector[SECT].lotag&0x8000) sector[SECT].lotag &= 0x7fff; + else sector[SECT].lotag |= 0x8000; + T5 = 1; + T4 = -T4; + if(q == 0) + { + callsound(sn,i); + q = 1; + } + } + i = nextspritestat[i]; + } + } + return; + + case 25: //Subway type sliding doors + + j = headspritestat[3]; + while(j >= 0)//Find the sprite + { + if( (sprite[j].lotag) == 15 && sprite[j].sectnum == sn ) + break; //Found the sectoreffector. + j = nextspritestat[j]; + } + + if(j < 0) + return; + + i = headspritestat[3]; + while(i >= 0) + { + if( SHT==sprite[j].hitag ) + { + if( SLT == 15 ) + { + sector[SECT].lotag ^= 0x8000; // Toggle the open or close + SA += 1024; + if(T5) callsound(SECT,i); + callsound(SECT,i); + if(sector[SECT].lotag&0x8000) T5 = 1; + else T5 = 2; + } + } + i = nextspritestat[i]; + } + return; + + case 27: //Extended bridge + + j = headspritestat[3]; + while(j >= 0) + { + if( (sprite[j].lotag&0xff)==20 && sprite[j].sectnum == sn) //Bridge + { + + sector[sn].lotag ^= 0x8000; + if(sector[sn].lotag&0x8000) //OPENING + hittype[j].temp_data[0] = 1; + else hittype[j].temp_data[0] = 2; + callsound(sn,ii); + break; + } + j = nextspritestat[j]; + } + return; + + + case 28: + //activate the rest of them + + j = headspritesect[sn]; + while(j >= 0) + { + if(sprite[j].statnum==3 && (sprite[j].lotag&0xff)==21) + break; //Found it + j = nextspritesect[j]; + } + + j = sprite[j].hitag; + + l = headspritestat[3]; + while(l >= 0) + { + if( (sprite[l].lotag&0xff)==21 && !hittype[l].temp_data[0] && + (sprite[l].hitag) == j ) + hittype[l].temp_data[0] = 1; + l = nextspritestat[l]; + } + callsound(sn,ii); + + return; + } +} + +void operaterespawns(short low) +{ + short i, j, nexti; + + i = headspritestat[11]; + while(i >= 0) + { + nexti = nextspritestat[i]; + if ((SLT == low) && (PN == RESPAWN)) + { + if( badguypic(SHT) && ud.monsters_off ) break; + + j = spawn(i,TRANSPORTERSTAR); + sprite[j].z -= (32<<8); + + sprite[i].extra = 66-12; // Just a way to killit + } + i = nexti; + } +} + +void operateactivators(short low,short snum) +{ + short i, j, k, *p, nexti; + walltype *wal; + + for(i=numcyclers-1;i>=0;i--) + { + p = &cyclers[i][0]; + + if(p[4] == low) + { + p[5] = !p[5]; + + sector[p[0]].floorshade = sector[p[0]].ceilingshade = p[3]; + wal = &wall[sector[p[0]].wallptr]; + for(j=sector[p[0]].wallnum;j > 0;j--,wal++) + wal->shade = p[3]; + } + } + + i = headspritestat[8]; + k = -1; + while(i >= 0) + { + if(sprite[i].lotag == low) + { + if( sprite[i].picnum == ACTIVATORLOCKED ) + { + if(sector[SECT].lotag&16384) + sector[SECT].lotag &= 65535-16384; + else + sector[SECT].lotag |= 16384; + + if(snum >= 0) + { + if(sector[SECT].lotag&16384) + FTA(4,&ps[snum]); + else FTA(8,&ps[snum]); + } + } + else + { + switch(SHT) + { + case 0: + break; + case 1: + if(sector[SECT].floorz != sector[SECT].ceilingz) + { + i = nextspritestat[i]; + continue; + } + break; + case 2: + if(sector[SECT].floorz == sector[SECT].ceilingz) + { + i = nextspritestat[i]; + continue; + } + break; + } + + if( sector[sprite[i].sectnum].lotag < 3 ) + { + j = headspritesect[sprite[i].sectnum]; + while(j >= 0) + { + if( sprite[j].statnum == 3 ) switch(sprite[j].lotag) + { + case 36: + case 31: + case 32: + case 18: + hittype[j].temp_data[0] = 1-hittype[j].temp_data[0]; + callsound(SECT,j); + break; + } + j = nextspritesect[j]; + } + } + + if( k == -1 && (sector[SECT].lotag&0xff) == 22 ) + k = callsound(SECT,i); + + operatesectors(SECT,i); + } + } + i = nextspritestat[i]; + } + + operaterespawns(low); +} + +void operatemasterswitches(short low) +{ + short i; + + i = headspritestat[6]; + while(i >= 0) + { + if( PN == MASTERSWITCH && SLT == low && SP == 0 ) + SP = 1; + i = nextspritestat[i]; + } +} + +void operateforcefields(short s, short low) +{ + short i, p; + + for(p=numanimwalls;p>=0;p--) + { + i = animwall[p].wallnum; + + if(low == wall[i].lotag || low == -1) + if (((wall[i].overpicnum >= W_FORCEFIELD)&&(wall[i].overpicnum <= W_FORCEFIELD+2))||(wall[i].overpicnum == BIGFORCE)) { + + + animwall[p].tag = 0; + + if( wall[i].cstat ) + { + wall[i].cstat = 0; + + if( s >= 0 && sprite[s].picnum == SECTOREFFECTOR && + sprite[s].lotag == 30) + wall[i].lotag = 0; + } + else + wall[i].cstat = 85; + } + } +} + +char checkhitswitch(short snum,long w,char switchtype) +{ + char switchpal; + short i, x, lotag,hitag,picnum,correctdips,numdips; + long sx,sy; + int switchpicnum; + + if(w < 0) return 0; + correctdips = 1; + numdips = 0; + + if(switchtype == 1) // A wall sprite + { + lotag = sprite[w].lotag; if(lotag == 0) return 0; + hitag = sprite[w].hitag; + sx = sprite[w].x; + sy = sprite[w].y; + picnum = sprite[w].picnum; + switchpal = sprite[w].pal; + } + else + { + lotag = wall[w].lotag; if(lotag == 0) return 0; + hitag = wall[w].hitag; + sx = wall[w].x; + sy = wall[w].y; + picnum = wall[w].picnum; + switchpal = wall[w].pal; + } + // initprintf("checkhitswitch called picnum=%i switchtype=%i\n",picnum,switchtype); + switchpicnum = picnum; + if ( (picnum==DIPSWITCH+1) + || (picnum==TECHSWITCH+1) + || (picnum==ALIENSWITCH+1) + || (picnum==DIPSWITCH2+1) + || (picnum==DIPSWITCH3+1) + || (picnum==PULLSWITCH+1) + || (picnum==HANDSWITCH+1) + || (picnum==SLOTDOOR+1) + || (picnum==LIGHTSWITCH+1) + || (picnum==SPACELIGHTSWITCH+1) + || (picnum==SPACEDOORSWITCH+1) + || (picnum==FRANKENSTINESWITCH+1) + || (picnum==LIGHTSWITCH2+1) + || (picnum==POWERSWITCH1+1) + || (picnum==LOCKSWITCH1+1) + || (picnum==POWERSWITCH2+1) + || (picnum==LIGHTSWITCH+1) + ) { + switchpicnum--; + } + if ((picnum > MULTISWITCH)&&(picnum <= MULTISWITCH+3)) { + switchpicnum = MULTISWITCH; + } + + switch(dynamictostatic[switchpicnum]) + { + case DIPSWITCH__STATIC: + // case DIPSWITCH+1: + case TECHSWITCH__STATIC: + // case TECHSWITCH+1: + case ALIENSWITCH__STATIC: + // case ALIENSWITCH+1: + break; + case ACCESSSWITCH__STATIC: + case ACCESSSWITCH2__STATIC: + if(ps[snum].access_incs == 0) + { + if( switchpal == 0 ) + { + if( (ps[snum].got_access&1) ) + ps[snum].access_incs = 1; + else FTA(70,&ps[snum]); + } + + else if( switchpal == 21 ) + { + if( ps[snum].got_access&2 ) + ps[snum].access_incs = 1; + else FTA(71,&ps[snum]); + } + + else if( switchpal == 23 ) + { + if( ps[snum].got_access&4 ) + ps[snum].access_incs = 1; + else FTA(72,&ps[snum]); + } + + if( ps[snum].access_incs == 1 ) + { + if(switchtype == 0) + ps[snum].access_wallnum = w; + else + ps[snum].access_spritenum = w; + } + + return 0; + } + case DIPSWITCH2__STATIC: + //case DIPSWITCH2+1: + case DIPSWITCH3__STATIC: + //case DIPSWITCH3+1: + case MULTISWITCH__STATIC: + //case MULTISWITCH+1: + //case MULTISWITCH+2: + //case MULTISWITCH+3: + case PULLSWITCH__STATIC: + //case PULLSWITCH+1: + case HANDSWITCH__STATIC: + //case HANDSWITCH+1: + case SLOTDOOR__STATIC: + //case SLOTDOOR+1: + case LIGHTSWITCH__STATIC: + //case LIGHTSWITCH+1: + case SPACELIGHTSWITCH__STATIC: + //case SPACELIGHTSWITCH+1: + case SPACEDOORSWITCH__STATIC: + //case SPACEDOORSWITCH+1: + case FRANKENSTINESWITCH__STATIC: + //case FRANKENSTINESWITCH+1: + case LIGHTSWITCH2__STATIC: + //case LIGHTSWITCH2+1: + case POWERSWITCH1__STATIC: + //case POWERSWITCH1+1: + case LOCKSWITCH1__STATIC: + //case LOCKSWITCH1+1: + case POWERSWITCH2__STATIC: + //case POWERSWITCH2+1: + if( check_activator_motion( lotag ) ) return 0; + break; + default: + if( isadoorwall(picnum) == 0 ) return 0; + break; + } + + i = headspritestat[0]; + while(i >= 0) + { + + if ( lotag == SLT ) { + int switchpicnum=PN; // put it in a variable so later switches don't trigger on the result of changes + if ((switchpicnum >= MULTISWITCH) && (switchpicnum <=MULTISWITCH+3)) { + sprite[i].picnum++; + if( sprite[i].picnum > (MULTISWITCH+3) ) + sprite[i].picnum = MULTISWITCH; + + } + switch(dynamictostatic[switchpicnum]) { + + case DIPSWITCH__STATIC: + case TECHSWITCH__STATIC: + case ALIENSWITCH__STATIC: + if( switchtype == 1 && w == i ) PN++; + else if( SHT == 0 ) correctdips++; + numdips++; + break; + case ACCESSSWITCH__STATIC: + case ACCESSSWITCH2__STATIC: + case SLOTDOOR__STATIC: + case LIGHTSWITCH__STATIC: + case SPACELIGHTSWITCH__STATIC: + case SPACEDOORSWITCH__STATIC: + case FRANKENSTINESWITCH__STATIC: + case LIGHTSWITCH2__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: + case HANDSWITCH__STATIC: + case PULLSWITCH__STATIC: + case DIPSWITCH2__STATIC: + case DIPSWITCH3__STATIC: + sprite[i].picnum++; + break; + default: + switch(dynamictostatic[switchpicnum-1]) { + + case TECHSWITCH__STATIC: + case DIPSWITCH__STATIC: + case ALIENSWITCH__STATIC: + if( switchtype == 1 && w == i ) PN--; + else if( SHT == 1 ) correctdips++; + numdips++; + break; + case PULLSWITCH__STATIC: + case HANDSWITCH__STATIC: + case LIGHTSWITCH2__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: + case SLOTDOOR__STATIC: + case LIGHTSWITCH__STATIC: + case SPACELIGHTSWITCH__STATIC: + case SPACEDOORSWITCH__STATIC: + case FRANKENSTINESWITCH__STATIC: + case DIPSWITCH2__STATIC: + case DIPSWITCH3__STATIC: + sprite[i].picnum--; + break; + } + break; + } + } + i = nextspritestat[i]; + } + + for(i=0;i= MULTISWITCH) && (wall[x].picnum <=MULTISWITCH+3)) { + wall[x].picnum++; + if(wall[x].picnum > (MULTISWITCH+3) ) + wall[x].picnum = MULTISWITCH; + + } + switch(dynamictostatic[wall[x].picnum]) { + + case DIPSWITCH__STATIC: + case TECHSWITCH__STATIC: + case ALIENSWITCH__STATIC: + if( switchtype == 0 && i == w ) wall[x].picnum++; + else if( wall[x].hitag == 0 ) correctdips++; + numdips++; + break; + case ACCESSSWITCH__STATIC: + case ACCESSSWITCH2__STATIC: + case SLOTDOOR__STATIC: + case LIGHTSWITCH__STATIC: + case SPACELIGHTSWITCH__STATIC: + case SPACEDOORSWITCH__STATIC: + case FRANKENSTINESWITCH__STATIC: + case LIGHTSWITCH2__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: + case HANDSWITCH__STATIC: + case PULLSWITCH__STATIC: + case DIPSWITCH2__STATIC: + case DIPSWITCH3__STATIC: + wall[x].picnum++; + break; + default: + switch(dynamictostatic[wall[x].picnum-1]) { + + case TECHSWITCH__STATIC: + case DIPSWITCH__STATIC: + case ALIENSWITCH__STATIC: + if( switchtype == 0 && i == w ) wall[x].picnum--; + else if( wall[x].hitag == 1 ) correctdips++; + numdips++; + break; + case PULLSWITCH__STATIC: + case HANDSWITCH__STATIC: + case LIGHTSWITCH2__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: + case SLOTDOOR__STATIC: + case LIGHTSWITCH__STATIC: + case SPACELIGHTSWITCH__STATIC: + case SPACEDOORSWITCH__STATIC: + case FRANKENSTINESWITCH__STATIC: + case DIPSWITCH2__STATIC: + case DIPSWITCH3__STATIC: + wall[x].picnum--; + break; + } + break; + } + } + } + + if(lotag == (short) 65535) + { + + ps[myconnectindex].gm = MODE_EOL; + if(ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + ud.level_number++; + if( (ud.volume_number && ud.level_number > 10 ) || ( ud.volume_number == 0 && ud.level_number > 5 ) ) + ud.level_number = 0; + ud.m_level_number = ud.level_number; + } + return 1; + + } + + switchpicnum = picnum; + + if ( (picnum==DIPSWITCH+1) + || (picnum==TECHSWITCH+1) + || (picnum==ALIENSWITCH+1) + || (picnum==DIPSWITCH2+1) + || (picnum==DIPSWITCH3+1) + || (picnum==PULLSWITCH+1) + || (picnum==HANDSWITCH+1) + || (picnum==SLOTDOOR+1) + || (picnum==LIGHTSWITCH+1) + || (picnum==SPACELIGHTSWITCH+1) + || (picnum==SPACEDOORSWITCH+1) + || (picnum==FRANKENSTINESWITCH+1) + || (picnum==LIGHTSWITCH2+1) + || (picnum==POWERSWITCH1+1) + || (picnum==LOCKSWITCH1+1) + || (picnum==POWERSWITCH2+1) + || (picnum==LIGHTSWITCH+1) + ) { + switchpicnum--; + } + if ((picnum > MULTISWITCH)&&(picnum <= MULTISWITCH+3)) { + switchpicnum = MULTISWITCH; + } + + switch(dynamictostatic[switchpicnum]) + { + default: + if(isadoorwall(picnum) == 0) break; + case DIPSWITCH__STATIC: + //case DIPSWITCH+1: + case TECHSWITCH__STATIC: + //case TECHSWITCH+1: + case ALIENSWITCH__STATIC: + //case ALIENSWITCH+1: + if( picnum == DIPSWITCH || picnum == DIPSWITCH+1 || + picnum == ALIENSWITCH || picnum == ALIENSWITCH+1 || + picnum == TECHSWITCH || picnum == TECHSWITCH+1 ) + { + if( picnum == ALIENSWITCH || picnum == ALIENSWITCH+1) + { + if(switchtype == 1) + xyzsound(ALIEN_SWITCH1,w,sx,sy,ps[snum].posz); + else xyzsound(ALIEN_SWITCH1,ps[snum].i,sx,sy,ps[snum].posz); + } + else + { + if(switchtype == 1) + xyzsound(SWITCH_ON,w,sx,sy,ps[snum].posz); + else xyzsound(SWITCH_ON,ps[snum].i,sx,sy,ps[snum].posz); + } + if(numdips != correctdips) break; + xyzsound(END_OF_LEVEL_WARN,ps[snum].i,sx,sy,ps[snum].posz); + } + case DIPSWITCH2__STATIC: + //case DIPSWITCH2+1: + case DIPSWITCH3__STATIC: + //case DIPSWITCH3+1: + case MULTISWITCH__STATIC: + //case MULTISWITCH+1: + //case MULTISWITCH+2: + //case MULTISWITCH+3: + case ACCESSSWITCH__STATIC: + case ACCESSSWITCH2__STATIC: + case SLOTDOOR__STATIC: + //case SLOTDOOR+1: + case LIGHTSWITCH__STATIC: + //case LIGHTSWITCH+1: + case SPACELIGHTSWITCH__STATIC: + //case SPACELIGHTSWITCH+1: + case SPACEDOORSWITCH__STATIC: + //case SPACEDOORSWITCH+1: + case FRANKENSTINESWITCH__STATIC: + //case FRANKENSTINESWITCH+1: + case LIGHTSWITCH2__STATIC: + //case LIGHTSWITCH2+1: + case POWERSWITCH1__STATIC: + //case POWERSWITCH1+1: + case LOCKSWITCH1__STATIC: + //case LOCKSWITCH1+1: + case POWERSWITCH2__STATIC: + //case POWERSWITCH2+1: + case HANDSWITCH__STATIC: + //case HANDSWITCH+1: + case PULLSWITCH__STATIC: + //case PULLSWITCH+1: + + if( picnum == MULTISWITCH || picnum == (MULTISWITCH+1) || + picnum == (MULTISWITCH+2) || picnum == (MULTISWITCH+3) ) + lotag += picnum-MULTISWITCH; + + x = headspritestat[3]; + while(x >= 0) + { + if( ((sprite[x].hitag) == lotag) ) + { + switch(sprite[x].lotag) + { + case 12: + sector[sprite[x].sectnum].floorpal = 0; + hittype[x].temp_data[0]++; + if(hittype[x].temp_data[0] == 2) + hittype[x].temp_data[0]++; + + break; + case 24: + case 34: + case 25: + hittype[x].temp_data[4] = !hittype[x].temp_data[4]; + if(hittype[x].temp_data[4]) + FTA(15,&ps[snum]); + else FTA(2,&ps[snum]); + break; + case 21: + FTA(2,&ps[screenpeek]); + break; + } + } + x = nextspritestat[x]; + } + + operateactivators(lotag,snum); + operateforcefields(ps[snum].i,lotag); + operatemasterswitches(lotag); + + if( picnum == DIPSWITCH || picnum == DIPSWITCH+1 || + picnum == ALIENSWITCH || picnum == ALIENSWITCH+1 || + picnum == TECHSWITCH || picnum == TECHSWITCH+1 ) return 1; + + if( hitag == 0 && isadoorwall(picnum) == 0 ) + { + if(switchtype == 1) + xyzsound(SWITCH_ON,w,sx,sy,ps[snum].posz); + else xyzsound(SWITCH_ON,ps[snum].i,sx,sy,ps[snum].posz); + } + else if(hitag != 0) + { + if(switchtype == 1 && (soundm[hitag]&4) == 0) + xyzsound(hitag,w,sx,sy,ps[snum].posz); + else spritesound(hitag,ps[snum].i); + } + + return 1; + } + return 0; + +} + +void activatebysector(short sect,short j) +{ + short i,didit; + + didit = 0; + + i = headspritesect[sect]; + while(i >= 0) + { + if(PN == ACTIVATOR) + { + operateactivators(SLT,-1); + didit = 1; + // return; + } + i = nextspritesect[i]; + } + + if(didit == 0) + operatesectors(sect,j); +} + +void breakwall(short newpn,short spr,short dawallnum) +{ + wall[dawallnum].picnum = newpn; + spritesound(VENT_BUST,spr); + spritesound(GLASS_HEAVYBREAK,spr); + lotsofglass(spr,dawallnum,10); +} + +void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith) +{ + short j, i, sn = -1, darkestwall; + signed char nfloors,nceilings; + short nextj; + walltype *wal; + spritetype *s; + + wal = &wall[dawallnum]; + + if(wal->overpicnum == MIRROR && checkspriteflagsp(atwith,SPRITE_FLAG_PROJECTILE) && (thisprojectile[spr].workslike & PROJECTILE_FLAG_RPG)) + { + lotsofglass(spr,dawallnum,70); + wal->cstat &= ~16; + wal->overpicnum = MIRRORBROKE; + spritesound(GLASS_HEAVYBREAK,spr); + } + + if(wal->overpicnum == MIRROR) + { + switch(dynamictostatic[atwith]) + { + case HEAVYHBOMB__STATIC: + case RADIUSEXPLOSION__STATIC: + case RPG__STATIC: + case HYDRENT__STATIC: + case SEENINE__STATIC: + case OOZFILTER__STATIC: + case EXPLODINGBARREL__STATIC: + lotsofglass(spr,dawallnum,70); + wal->cstat &= ~16; + wal->overpicnum = MIRRORBROKE; + spritesound(GLASS_HEAVYBREAK,spr); + return; + } + } + + if( ( (wal->cstat&16) || wal->overpicnum == BIGFORCE ) && wal->nextsector >= 0 ) + if( sector[wal->nextsector].floorz > z ) + if( sector[wal->nextsector].floorz-sector[wal->nextsector].ceilingz ) + { + int switchpicnum = wal->overpicnum; + if ((switchpicnum > W_FORCEFIELD)&&(switchpicnum <= W_FORCEFIELD+2)) + switchpicnum = W_FORCEFIELD; + switch(dynamictostatic[switchpicnum]) + { + case W_FORCEFIELD__STATIC: + //case W_FORCEFIELD+1: + //case W_FORCEFIELD+2: + wal->extra = 1; // tell the forces to animate + case BIGFORCE__STATIC: + updatesector(x,y,&sn); + if( sn < 0 ) return; + + if(atwith == -1) + i = EGS(sn,x,y,z,FORCERIPPLE,-127,8,8,0,0,0,spr,5); + else + { + if(atwith == CHAINGUN) + i = EGS(sn,x,y,z,FORCERIPPLE,-127,16+sprite[spr].xrepeat,16+sprite[spr].yrepeat,0,0,0,spr,5); + else i = EGS(sn,x,y,z,FORCERIPPLE,-127,32,32,0,0,0,spr,5); + } + + CS |= 18+128; + SA = getangle(wal->x-wall[wal->point2].x, + wal->y-wall[wal->point2].y)-512; + + spritesound(SOMETHINGHITFORCE,i); + + return; + + case FANSPRITE__STATIC: + wal->overpicnum = FANSPRITEBROKE; + wal->cstat &= 65535-65; + if(wal->nextwall >= 0) + { + wall[wal->nextwall].overpicnum = FANSPRITEBROKE; + wall[wal->nextwall].cstat &= 65535-65; + } + spritesound(VENT_BUST,spr); + spritesound(GLASS_BREAKING,spr); + return; + + case GLASS__STATIC: + updatesector(x,y,&sn); if( sn < 0 ) return; + wal->overpicnum=GLASS2; + lotsofglass(spr,dawallnum,10); + wal->cstat = 0; + + if(wal->nextwall >= 0) + wall[wal->nextwall].cstat = 0; + + i = EGS(sn,x,y,z,SECTOREFFECTOR,0,0,0,ps[0].ang,0,0,spr,3); + SLT = 128; T2 = 5; T3 = dawallnum; + spritesound(GLASS_BREAKING,i); + return; + case STAINGLASS1__STATIC: + updatesector(x,y,&sn); if( sn < 0 ) return; + lotsofcolourglass(spr,dawallnum,80); + wal->cstat = 0; + if(wal->nextwall >= 0) + wall[wal->nextwall].cstat = 0; + spritesound(VENT_BUST,spr); + spritesound(GLASS_BREAKING,spr); + return; + } + } + + switch(dynamictostatic[wal->picnum]) + { + case COLAMACHINE__STATIC: + case VENDMACHINE__STATIC: + breakwall(wal->picnum+2,spr,dawallnum); + spritesound(VENT_BUST,spr); + return; + + case OJ__STATIC: + case FEMPIC2__STATIC: + case FEMPIC3__STATIC: + + case SCREENBREAK6__STATIC: + case SCREENBREAK7__STATIC: + case SCREENBREAK8__STATIC: + + case SCREENBREAK1__STATIC: + case SCREENBREAK2__STATIC: + case SCREENBREAK3__STATIC: + case SCREENBREAK4__STATIC: + case SCREENBREAK5__STATIC: + + case SCREENBREAK9__STATIC: + case SCREENBREAK10__STATIC: + case SCREENBREAK11__STATIC: + case SCREENBREAK12__STATIC: + case SCREENBREAK13__STATIC: + case SCREENBREAK14__STATIC: + case SCREENBREAK15__STATIC: + case SCREENBREAK16__STATIC: + case SCREENBREAK17__STATIC: + case SCREENBREAK18__STATIC: + case SCREENBREAK19__STATIC: + case BORNTOBEWILDSCREEN__STATIC: + + lotsofglass(spr,dawallnum,30); + wal->picnum=W_SCREENBREAK+(TRAND%3); + spritesound(GLASS_HEAVYBREAK,spr); + return; + + case W_TECHWALL5__STATIC: + case W_TECHWALL6__STATIC: + case W_TECHWALL7__STATIC: + case W_TECHWALL8__STATIC: + case W_TECHWALL9__STATIC: + breakwall(wal->picnum+1,spr,dawallnum); + return; + case W_MILKSHELF__STATIC: + breakwall(W_MILKSHELFBROKE,spr,dawallnum); + return; + + case W_TECHWALL10__STATIC: + breakwall(W_HITTECHWALL10,spr,dawallnum); + return; + + case W_TECHWALL1__STATIC: + case W_TECHWALL11__STATIC: + case W_TECHWALL12__STATIC: + case W_TECHWALL13__STATIC: + case W_TECHWALL14__STATIC: + breakwall(W_HITTECHWALL1,spr,dawallnum); + return; + + case W_TECHWALL15__STATIC: + breakwall(W_HITTECHWALL15,spr,dawallnum); + return; + + case W_TECHWALL16__STATIC: + breakwall(W_HITTECHWALL16,spr,dawallnum); + return; + + case W_TECHWALL2__STATIC: + breakwall(W_HITTECHWALL2,spr,dawallnum); + return; + + case W_TECHWALL3__STATIC: + breakwall(W_HITTECHWALL3,spr,dawallnum); + return; + + case W_TECHWALL4__STATIC: + breakwall(W_HITTECHWALL4,spr,dawallnum); + return; + + case ATM__STATIC: + wal->picnum = ATMBROKE; + lotsofmoney(&sprite[spr],1+(TRAND&7)); + spritesound(GLASS_HEAVYBREAK,spr); + break; + + case WALLLIGHT1__STATIC: + case WALLLIGHT2__STATIC: + case WALLLIGHT3__STATIC: + case WALLLIGHT4__STATIC: + case TECHLIGHT2__STATIC: + case TECHLIGHT4__STATIC: + + if( rnd(128) ) + spritesound(GLASS_HEAVYBREAK,spr); + else spritesound(GLASS_BREAKING,spr); + lotsofglass(spr,dawallnum,30); + + if(wal->picnum == WALLLIGHT1) + wal->picnum = WALLLIGHTBUST1; + + if(wal->picnum == WALLLIGHT2) + wal->picnum = WALLLIGHTBUST2; + + if(wal->picnum == WALLLIGHT3) + wal->picnum = WALLLIGHTBUST3; + + if(wal->picnum == WALLLIGHT4) + wal->picnum = WALLLIGHTBUST4; + + if(wal->picnum == TECHLIGHT2) + wal->picnum = TECHLIGHTBUST2; + + if(wal->picnum == TECHLIGHT4) + wal->picnum = TECHLIGHTBUST4; + + if(!wal->lotag) return; + + sn = wal->nextsector; + if(sn < 0) return; + darkestwall = 0; + + wal = &wall[sector[sn].wallptr]; + for(i=sector[sn].wallnum;i > 0;i--,wal++) + if(wal->shade > darkestwall) + darkestwall=wal->shade; + + j = TRAND&1; + i= headspritestat[3]; + while(i >= 0) + { + if(SHT == wall[dawallnum].lotag && SLT == 3 ) + { + T3 = j; + T4 = darkestwall; + T5 = 1; + } + i = nextspritestat[i]; + } + break; + } +} + +void checkplayerhurt(struct player_struct *p,short j) +{ + if( (j&49152) == 49152 ) + { + j &= (MAXSPRITES-1); + + if(sprite[j].picnum==CACTUS){ + + if(p->hurt_delay < 8 ) + { + sprite[p->i].extra -= 5; + + p->hurt_delay = 16; + p->pals_time = 32; + p->pals[0] = 32; + p->pals[1] = 0; + p->pals[2] = 0; + spritesound(DUKE_LONGTERM_PAIN,p->i); + } + + } + return; + } + + if( (j&49152) != 32768) return; + j &= (MAXWALLS-1); + + if( p->hurt_delay > 0 ) p->hurt_delay--; + else if( wall[j].cstat&85 ) { + int switchpicnum = wall[j].overpicnum; + if ((switchpicnum>W_FORCEFIELD)&&(switchpicnum<=W_FORCEFIELD+2)) + switchpicnum=W_FORCEFIELD; + + switch(dynamictostatic[switchpicnum]) + { + case W_FORCEFIELD__STATIC: + // case W_FORCEFIELD+1: + // case W_FORCEFIELD+2: + sprite[p->i].extra -= 5; + + p->hurt_delay = 16; + p->pals_time = 32; + p->pals[0] = 32; + p->pals[1] = 0; + p->pals[2] = 0; + + p->posxv = -(sintable[(p->ang+512)&2047]<<8); + p->posyv = -(sintable[(p->ang)&2047]<<8); + spritesound(DUKE_LONGTERM_PAIN,p->i); + + checkhitwall(p->i,j, + p->posx+(sintable[(p->ang+512)&2047]>>9), + p->posy+(sintable[p->ang&2047]>>9), + p->posz,-1); + + break; + + case BIGFORCE__STATIC: + p->hurt_delay = 26; + checkhitwall(p->i,j, + p->posx+(sintable[(p->ang+512)&2047]>>9), + p->posy+(sintable[p->ang&2047]>>9), + p->posz,-1); + break; + + } + } +} + +char checkhitceiling(short sn) +{ + short i, j, q, darkestwall, darkestceiling; + signed char nfloors,nceilings; + walltype *wal; + + switch(dynamictostatic[sector[sn].ceilingpicnum]) + { + case WALLLIGHT1__STATIC: + case WALLLIGHT2__STATIC: + case WALLLIGHT3__STATIC: + case WALLLIGHT4__STATIC: + case TECHLIGHT2__STATIC: + case TECHLIGHT4__STATIC: + + ceilingglass(ps[myconnectindex].i,sn,10); + spritesound(GLASS_BREAKING,ps[screenpeek].i); + + if(sector[sn].ceilingpicnum == WALLLIGHT1) + sector[sn].ceilingpicnum = WALLLIGHTBUST1; + + if(sector[sn].ceilingpicnum == WALLLIGHT2) + sector[sn].ceilingpicnum = WALLLIGHTBUST2; + + if(sector[sn].ceilingpicnum == WALLLIGHT3) + sector[sn].ceilingpicnum = WALLLIGHTBUST3; + + if(sector[sn].ceilingpicnum == WALLLIGHT4) + sector[sn].ceilingpicnum = WALLLIGHTBUST4; + + if(sector[sn].ceilingpicnum == TECHLIGHT2) + sector[sn].ceilingpicnum = TECHLIGHTBUST2; + + if(sector[sn].ceilingpicnum == TECHLIGHT4) + sector[sn].ceilingpicnum = TECHLIGHTBUST4; + + + if(!sector[sn].hitag) + { + i = headspritesect[sn]; + while(i >= 0) + { + if( PN == SECTOREFFECTOR && SLT == 12 ) + { + j = headspritestat[3]; + while(j >= 0) + { + if( sprite[j].hitag == SHT ) + hittype[j].temp_data[3] = 1; + j = nextspritestat[j]; + } + break; + } + i = nextspritesect[i]; + } + } + + i = headspritestat[3]; + j = TRAND&1; + while(i >= 0) + { + if(SHT == (sector[sn].hitag) && SLT == 3 ) + { + T3 = j; + T5 = 1; + } + i = nextspritestat[i]; + } + + return 1; + } + + return 0; +} + +void checkhitsprite(short i,short sn) +{ + short j, k, l, nextj, p, rpg=0; + spritetype *s; + int switchpicnum; + + i &= (MAXSPRITES-1); + + if(checkspriteflags(sn,SPRITE_FLAG_PROJECTILE)) + if(thisprojectile[sn].workslike & PROJECTILE_FLAG_RPG) + rpg = 1; + switchpicnum = PN; + if ((PN > WATERFOUNTAIN)&&(PN < WATERFOUNTAIN+3)) { + switchpicnum = WATERFOUNTAIN; + } + switch(dynamictostatic[PN]) + { + case OCEANSPRITE1__STATIC: + case OCEANSPRITE2__STATIC: + case OCEANSPRITE3__STATIC: + case OCEANSPRITE4__STATIC: + case OCEANSPRITE5__STATIC: + spawn(i,SMALLSMOKE); + deletesprite(i); + break; + case QUEBALL__STATIC: + case STRIPEBALL__STATIC: + if(sprite[sn].picnum == QUEBALL || sprite[sn].picnum == STRIPEBALL) + { + sprite[sn].xvel = (sprite[i].xvel>>1)+(sprite[i].xvel>>2); + sprite[sn].ang -= (SA<<1)+1024; + SA = getangle(SX-sprite[sn].x,SY-sprite[sn].y)-512; + if(issoundplaying(POOLBALLHIT) < 2) + spritesound(POOLBALLHIT,i); + } + else + { + if( TRAND&3 ) + { + sprite[i].xvel = 164; + sprite[i].ang = sprite[sn].ang; + } + else + { + lotsofglass(i,-1,3); + deletesprite(i); + } + } + break; + case TREE1__STATIC: + case TREE2__STATIC: + case TIRE__STATIC: + case CONE__STATIC: + case BOX__STATIC: + { + if (rpg == 1) + if(T1 == 0) + { + CS &= ~257; + T1 = 1; + spawn(i,BURNING); + } + switch(dynamictostatic[sprite[sn].picnum]) + { + case RADIUSEXPLOSION__STATIC: + case RPG__STATIC: + case FIRELASER__STATIC: + case HYDRENT__STATIC: + case HEAVYHBOMB__STATIC: + if(T1 == 0) + { + CS &= ~257; + T1 = 1; + spawn(i,BURNING); + } + break; + } + break; + } + case CACTUS__STATIC: + { + if (rpg == 1) + for(k=0;k<64;k++) + { + j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + sprite[j].pal = 8; + } + // case CACTUSBROKE: + switch(dynamictostatic[sprite[sn].picnum]) + { + case RADIUSEXPLOSION__STATIC: + case RPG__STATIC: + case FIRELASER__STATIC: + case HYDRENT__STATIC: + case HEAVYHBOMB__STATIC: + for(k=0;k<64;k++) + { + j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + sprite[j].pal = 8; + } + + if(PN == CACTUS) + PN = CACTUSBROKE; + CS &= ~257; + // else deletesprite(i); + break; + } + break; + } + case HANGLIGHT__STATIC: + case GENERICPOLE2__STATIC: + for(k=0;k<6;k++) + EGS(SECT,SX,SY,SZ-(8<<8),SCRAP1+(TRAND&15),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + spritesound(GLASS_HEAVYBREAK,i); + deletesprite(i); + break; + + + case FANSPRITE__STATIC: + PN = FANSPRITEBROKE; + CS &= (65535-257); + if( sector[SECT].floorpicnum == FANSHADOW ) + sector[SECT].floorpicnum = FANSHADOWBROKE; + + spritesound(GLASS_HEAVYBREAK,i); + s = &sprite[i]; + for(j=0;j<16;j++) RANDOMSCRAP; + + break; + case WATERFOUNTAIN__STATIC: + // case WATERFOUNTAIN+1: + // case WATERFOUNTAIN+2: + // case __STATIC: + PN = WATERFOUNTAINBROKE; + spawn(i,TOILETWATER); + break; + case SATELITE__STATIC: + case FUELPOD__STATIC: + case SOLARPANNEL__STATIC: + case ANTENNA__STATIC: + if(sprite[sn].extra != *actorscrptr[SHOTSPARK1] ) + { + for(j=0;j<15;j++) + EGS(SECT,SX,SY,sector[SECT].floorz-(12<<8)-(j<<9),SCRAP1+(TRAND&15),-8,64,64, + TRAND&2047,(TRAND&127)+64,-(TRAND&511)-256,i,5); + spawn(i,EXPLOSION2); + deletesprite(i); + } + break; + case BOTTLE1__STATIC: + case BOTTLE2__STATIC: + case BOTTLE3__STATIC: + case BOTTLE4__STATIC: + case BOTTLE5__STATIC: + case BOTTLE6__STATIC: + case BOTTLE8__STATIC: + case BOTTLE10__STATIC: + case BOTTLE11__STATIC: + case BOTTLE12__STATIC: + case BOTTLE13__STATIC: + case BOTTLE14__STATIC: + case BOTTLE15__STATIC: + case BOTTLE16__STATIC: + case BOTTLE17__STATIC: + case BOTTLE18__STATIC: + case BOTTLE19__STATIC: + case WATERFOUNTAINBROKE__STATIC: + case DOMELITE__STATIC: + case SUSHIPLATE1__STATIC: + case SUSHIPLATE2__STATIC: + case SUSHIPLATE3__STATIC: + case SUSHIPLATE4__STATIC: + case SUSHIPLATE5__STATIC: + case WAITTOBESEATED__STATIC: + case VASE__STATIC: + case STATUEFLASH__STATIC: + case STATUE__STATIC: + if(PN == BOTTLE10) + lotsofmoney(&sprite[i],4+(TRAND&3)); + else if(PN == STATUE || PN == STATUEFLASH) + { + lotsofcolourglass(i,-1,40); + spritesound(GLASS_HEAVYBREAK,i); + } + else if(PN == VASE) + lotsofglass(i,-1,40); + + spritesound(GLASS_BREAKING,i); + SA = TRAND&2047; + lotsofglass(i,-1,8); + deletesprite(i); + break; + case FETUS__STATIC: + PN = FETUSBROKE; + spritesound(GLASS_BREAKING,i); + lotsofglass(i,-1,10); + break; + case FETUSBROKE__STATIC: + for(j=0;j<48;j++) + { + shoot(i,BLOODSPLAT1); + SA += 333; + } + spritesound(GLASS_HEAVYBREAK,i); + spritesound(SQUISHED,i); + case BOTTLE7__STATIC: + spritesound(GLASS_BREAKING,i); + lotsofglass(i,-1,10); + deletesprite(i); + break; + case HYDROPLANT__STATIC: + PN = BROKEHYDROPLANT; + spritesound(GLASS_BREAKING,i); + lotsofglass(i,-1,10); + break; + + case FORCESPHERE__STATIC: + sprite[i].xrepeat = 0; + hittype[OW].temp_data[0] = 32; + hittype[OW].temp_data[1] = !hittype[OW].temp_data[1]; + hittype[OW].temp_data[2] ++; + spawn(i,EXPLOSION2); + break; + + case BROKEHYDROPLANT__STATIC: + if(CS&1) + { + spritesound(GLASS_BREAKING,i); + SZ += 16<<8; + CS = 0; + lotsofglass(i,-1,5); + } + break; + + case TOILET__STATIC: + PN = TOILETBROKE; + CS |= (TRAND&1)<<2; + CS &= ~257; + spawn(i,TOILETWATER); + spritesound(GLASS_BREAKING,i); + break; + + case STALL__STATIC: + PN = STALLBROKE; + CS |= (TRAND&1)<<2; + CS &= ~257; + spawn(i,TOILETWATER); + spritesound(GLASS_HEAVYBREAK,i); + break; + + case HYDRENT__STATIC: + PN = BROKEFIREHYDRENT; + spawn(i,TOILETWATER); + + // for(k=0;k<5;k++) + // { + // j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + // sprite[j].pal = 2; + // } + spritesound(GLASS_HEAVYBREAK,i); + break; + + case GRATE1__STATIC: + PN = BGRATE1; + CS &= (65535-256-1); + spritesound(VENT_BUST,i); + break; + + case CIRCLEPANNEL__STATIC: + PN = CIRCLEPANNELBROKE; + CS &= (65535-256-1); + spritesound(VENT_BUST,i); + break; + case PANNEL1__STATIC: + case PANNEL2__STATIC: + PN = BPANNEL1; + CS &= (65535-256-1); + spritesound(VENT_BUST,i); + break; + case PANNEL3__STATIC: + PN = BPANNEL3; + CS &= (65535-256-1); + spritesound(VENT_BUST,i); + break; + case PIPE1__STATIC: + case PIPE2__STATIC: + case PIPE3__STATIC: + case PIPE4__STATIC: + case PIPE5__STATIC: + case PIPE6__STATIC: + switch(dynamictostatic[PN]) + { + case PIPE1__STATIC:PN=PIPE1B;break; + case PIPE2__STATIC:PN=PIPE2B;break; + case PIPE3__STATIC:PN=PIPE3B;break; + case PIPE4__STATIC:PN=PIPE4B;break; + case PIPE5__STATIC:PN=PIPE5B;break; + case PIPE6__STATIC:PN=PIPE6B;break; + } + + j = spawn(i,STEAM); + sprite[j].z = sector[SECT].floorz-(32<<8); + break; + + case MONK__STATIC: + case LUKE__STATIC: + case INDY__STATIC: + case JURYGUY__STATIC: + spritesound(SLT,i); + spawn(i,SHT); + case SPACEMARINE__STATIC: + sprite[i].extra -= sprite[sn].extra; + if(sprite[i].extra > 0) break; + SA = TRAND&2047; + shoot(i,BLOODSPLAT1); + SA = TRAND&2047; + shoot(i,BLOODSPLAT2); + SA = TRAND&2047; + shoot(i,BLOODSPLAT3); + SA = TRAND&2047; + shoot(i,BLOODSPLAT4); + SA = TRAND&2047; + shoot(i,BLOODSPLAT1); + SA = TRAND&2047; + shoot(i,BLOODSPLAT2); + SA = TRAND&2047; + shoot(i,BLOODSPLAT3); + SA = TRAND&2047; + shoot(i,BLOODSPLAT4); + guts(&sprite[i],JIBS1,1,myconnectindex); + guts(&sprite[i],JIBS2,2,myconnectindex); + guts(&sprite[i],JIBS3,3,myconnectindex); + guts(&sprite[i],JIBS4,4,myconnectindex); + guts(&sprite[i],JIBS5,1,myconnectindex); + guts(&sprite[i],JIBS3,6,myconnectindex); + sound(SQUISHED); + deletesprite(i); + break; + case CHAIR1__STATIC: + case CHAIR2__STATIC: + PN = BROKENCHAIR; + CS = 0; + break; + case CHAIR3__STATIC: + case MOVIECAMERA__STATIC: + case SCALE__STATIC: + case VACUUM__STATIC: + case CAMERALIGHT__STATIC: + case IVUNIT__STATIC: + case POT1__STATIC: + case POT2__STATIC: + case POT3__STATIC: + case TRIPODCAMERA__STATIC: + spritesound(GLASS_HEAVYBREAK,i); + s = &sprite[i]; + for(j=0;j<16;j++) RANDOMSCRAP; + deletesprite(i); + break; + case PLAYERONWATER__STATIC: + i = OW; + default: + if( (sprite[i].cstat&16) && SHT == 0 && SLT == 0 && sprite[i].statnum == 0) + break; + + if( ( sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i ) && sprite[i].statnum != 4) + { + if( badguy(&sprite[i]) == 1) + { + if(sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; + + if( (PN != DRONE) && (PN != ROTATEGUN) && (PN != COMMANDER) && (PN < GREENSLIME || PN > GREENSLIME+7) ) + if(sprite[sn].picnum != FREEZEBLAST ) + if( actortype[PN] == 0 ) + { + j = spawn(sn,JIBS6); + if(sprite[sn].pal == 6) + sprite[j].pal = 6; + sprite[j].z += (4<<8); + sprite[j].xvel = 16; + sprite[j].xrepeat = sprite[j].yrepeat = 24; + sprite[j].ang += 32-(TRAND&63); + } + + j = sprite[sn].owner; + + if( j >= 0 && sprite[j].picnum == APLAYER && PN != ROTATEGUN && PN != DRONE ) + if( ps[sprite[j].yvel].curr_weapon == SHOTGUN_WEAPON ) + { + shoot(i,BLOODSPLAT3); + shoot(i,BLOODSPLAT1); + shoot(i,BLOODSPLAT2); + shoot(i,BLOODSPLAT4); + } + + if( PN != TANK && PN != BOSS1 && PN != BOSS4 && PN != BOSS2 && PN != BOSS3 && PN != RECON && PN != ROTATEGUN ) + { + if( (sprite[i].cstat&48) == 0 ) + SA = (sprite[sn].ang+1024)&2047; + sprite[i].xvel = -(sprite[sn].extra<<2); + j = SECT; + pushmove(&SX,&SY,&SZ,&j,128L,(4L<<8),(4L<<8),CLIPMASK0); + if(j != SECT && j >= 0 && j < MAXSECTORS) + changespritesect(i,j); + } + + if(sprite[i].statnum == 2) + { + changespritestat(i,1); + hittype[i].timetosleep = SLEEPTIME; + } + if( ( RX < 24 || PN == SHARK) && sprite[sn].picnum == SHRINKSPARK) return; + } + + if( sprite[i].statnum != 2 ) + { + if( sprite[sn].picnum == FREEZEBLAST && ( (PN == APLAYER && sprite[i].pal == 1 ) || ( freezerhurtowner == 0 && sprite[sn].owner == i ) ) ) + return; + + hittype[i].picnum = sprite[sn].picnum; + hittype[i].extra += sprite[sn].extra; + hittype[i].ang = sprite[sn].ang; + hittype[i].owner = sprite[sn].owner; + } + + if(sprite[i].statnum == 10) + { + p = sprite[i].yvel; + if(ps[p].newowner >= 0) + { + ps[p].newowner = -1; + ps[p].posx = ps[p].oposx; + ps[p].posy = ps[p].oposy; + ps[p].posz = ps[p].oposz; + ps[p].ang = ps[p].oang; + + updatesector(ps[p].posx,ps[p].posy,&ps[p].cursectnum); + setpal(&ps[p]); + + j = headspritestat[1]; + while(j >= 0) + { + if(sprite[j].picnum==CAMERA1) sprite[j].yvel = 0; + j = nextspritestat[j]; + } + } + + if( RX < 24 && sprite[sn].picnum == SHRINKSPARK) + return; + + if( sprite[hittype[i].owner].picnum != APLAYER) + if(ud.player_skill >= 3) + sprite[sn].extra += (sprite[sn].extra>>1); + } + + } + break; + } +} + +void allignwarpelevators(void) +{ + short i, j; + + i = headspritestat[3]; + while(i >= 0) + { + if( SLT == 17 && SS > 16) + { + j = headspritestat[3]; + while(j >= 0) + { + if( (sprite[j].lotag) == 17 && i != j && + (SHT) == (sprite[j].hitag) ) + { + sector[sprite[j].sectnum].floorz = + sector[SECT].floorz; + sector[sprite[j].sectnum].ceilingz = + sector[SECT].ceilingz; + } + + j = nextspritestat[j]; + } + } + i = nextspritestat[i]; + } +} + +void cheatkeys(short snum) +{ + short i, k; + char dainv; + unsigned long sb_snum, j; + struct player_struct *p; + + sb_snum = sync[snum].bits; + p = &ps[snum]; + + if(p->cheat_phase == 1) return; + + // 1<<0 = jump + // 1<<1 = crouch + // 1<<2 = fire + // 1<<3 = aim up + // 1<<4 = aim down + // 1<<5 = run + // 1<<6 = look left + // 1<<7 = look right + // 15<<8 = !weapon selection (bits 8-11) + // 1<<12 = !steroids + // 1<<13 = look up + // 1<<14 = look down + // 1<<15 = !nightvis + // 1<<16 = !medkit + // 1<<17 = (multiflag==1) ? changes meaning of bits 18 and 19 + // 1<<18 = centre view + // 1<<19 = !holster weapon + // 1<<20 = !inventory left + // 1<<21 = !pause + // 1<<22 = !quick kick + // 1<<23 = aim mode + // 1<<24 = !holoduke + // 1<<25 = !jetpack + // 1<<26 = gamequit + // 1<<27 = !inventory right + // 1<<28 = !turn around + // 1<<29 = !open + // 1<<30 = !inventory + // 1<<31 = !escape + + i = p->aim_mode; + p->aim_mode = (sb_snum>>23)&1; + if(p->aim_mode < i) + p->return_to_center = 9; + + if( (sb_snum&(1<<22)) && p->quick_kick == 0) + if( p->curr_weapon != KNEE_WEAPON || p->kickback_pic == 0 ) + { + SetGameVarID(g_iReturnVarID,0,ps[snum].i,snum); + OnEvent(EVENT_QUICKKICK,ps[snum].i,snum, -1); + if(GetGameVarID(g_iReturnVarID,ps[snum].i,snum) == 0 ) + { + p->quick_kick = 14; + FTA(80,p); + } + } + + j = sb_snum & ((15<<8)|(1<<12)|(1<<15)|(1<<16)|(1<<22)|(1<<19)|(1<<20)|(1<<21)|(1<<24)|(1<<25)|(1<<27)|(1<<28)|(1<<29)|(1<<30)|(1<<31)); + sb_snum = j & ~p->interface_toggle_flag; + p->interface_toggle_flag |= sb_snum | ((sb_snum&0xf00)?0xf00:0); + p->interface_toggle_flag &= j | ((j&0xf00)?0xf00:0); + + if(sb_snum && ( sb_snum&(1<<17) ) == 0) + { + if( sb_snum&(1<<21) ) + { + KB_ClearKeyDown( sc_Pause ); + ud.pause_on = !ud.pause_on; + if( ud.pause_on == 1 && sb_snum&(1<<5) ) ud.pause_on = 2; + if(ud.pause_on) + { + MUSIC_Pause(); + FX_StopAllSounds(); + clearsoundlocks(); + } + else + { + if(MusicToggle) MUSIC_Continue(); + pub = NUMPAGES; + pus = NUMPAGES; + } + } + + if(ud.pause_on) return; + + if(sprite[p->i].extra <= 0) return; // if dead... + + if( sb_snum&(1<<30) && p->newowner == -1 ) // inventory button generates event for selected item + { + SetGameVarID(g_iReturnVarID,0,ps[snum].i,snum); + OnEvent(EVENT_INVENTORY,ps[snum].i,snum, -1); + if(GetGameVarID(g_iReturnVarID,ps[snum].i,snum) == 0 ) + { + switch(p->inven_icon) + { + case 4: sb_snum |= (1<<25);break; + case 3: sb_snum |= (1<<24);break; + case 5: sb_snum |= (1<<15);break; + case 1: sb_snum |= (1<<16);break; + case 2: sb_snum |= (1<<12);break; + } + } + } + + if( sb_snum&(1<<15) ) + { + SetGameVarID(g_iReturnVarID,0,ps[snum].i,snum); + OnEvent(EVENT_USENIGHTVISION,ps[snum].i,snum, -1); + if(GetGameVarID(g_iReturnVarID,ps[snum].i,snum) == 0 + && p->heat_amount > 0) + { + p->heat_on = !p->heat_on; + setpal(p); + p->inven_icon = 5; + spritesound(NITEVISION_ONOFF,p->i); + FTA(106+(!p->heat_on),p); + } + } + + if( (sb_snum&(1<<12)) ) + { + SetGameVarID(g_iReturnVarID,0,ps[snum].i,snum); + OnEvent(EVENT_USESTEROIDS,ps[snum].i,snum, -1); + if(GetGameVarID(g_iReturnVarID,ps[snum].i,snum) == 0) + { + if(p->steroids_amount == 400 ) + { + p->steroids_amount--; + spritesound(DUKE_TAKEPILLS,p->i); + p->inven_icon = 2; + FTA(12,p); + } + } + return; // is there significance to returning? + } + if(p->refresh_inventory) + { + sb_snum|=(1<<20); // emulate move left... + } + if(p->newowner == -1) + if( sb_snum&(1<<20) || sb_snum&(1<<27)) + { + p->invdisptime = 26*2; + + if( sb_snum&(1<<27) ) k = 1; + else k = 0; + + if(p->refresh_inventory) p->refresh_inventory = 0; + dainv = p->inven_icon; + + i = 0; +CHECKINV1: + + if(i < 9) + { + i++; + + switch(dainv) + { + case 4: + if(p->jetpack_amount > 0 && i > 1) + break; + if(k) dainv = 5; + else dainv = 3; + goto CHECKINV1; + case 6: + if(p->scuba_amount > 0 && i > 1) + break; + if(k) dainv = 7; + else dainv = 5; + goto CHECKINV1; + case 2: + if(p->steroids_amount > 0 && i > 1) + break; + if(k) dainv = 3; + else dainv = 1; + goto CHECKINV1; + case 3: + if(p->holoduke_amount > 0 && i > 1) + break; + if(k) dainv = 4; + else dainv = 2; + goto CHECKINV1; + case 0: + case 1: + if(p->firstaid_amount > 0 && i > 1) + break; + if(k) dainv = 2; + else dainv = 7; + goto CHECKINV1; + case 5: + if(p->heat_amount > 0 && i > 1) + break; + if(k) dainv = 6; + else dainv = 4; + goto CHECKINV1; + case 7: + if(p->boot_amount > 0 && i > 1) + break; + if(k) dainv = 1; + else dainv = 6; + goto CHECKINV1; + } + } + else dainv = 0; + + if( sb_snum&(1<<20) ) // Inventory_Left + { + SetGameVarID(g_iReturnVarID,dainv,ps[snum].i,snum); + OnEvent(EVENT_INVENTORYLEFT,ps[snum].i,snum, -1); + dainv=GetGameVarID(g_iReturnVarID,ps[snum].i,snum); + } + if( sb_snum&(1<<27) ) // Inventory_Right + { + SetGameVarID(g_iReturnVarID,dainv,ps[snum].i,snum); + OnEvent(EVENT_INVENTORYRIGHT,ps[snum].i,snum, -1); + dainv=GetGameVarID(g_iReturnVarID,ps[snum].i,snum); + } + + p->inven_icon = dainv; + + switch(dainv) + { + case 1: FTA(3,p);break; + case 2: FTA(90,p);break; + case 3: FTA(91,p);break; + case 4: FTA(88,p);break; + case 5: FTA(101,p);break; + case 6: FTA(89,p);break; + case 7: FTA(6,p);break; + } + } + + j = ( (sb_snum&(15<<8))>>8 ) - 1; + + if (j == 0) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY1,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 1) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY2,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 2) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY3,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 3) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY4,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 4) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY5,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 5) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY6,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 6) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY7,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 7) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY8,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 8) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY9,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 9) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_WEAPKEY10,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 10) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_PREVIOUSWEAPON,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (j == 11) + { + SetGameVarID(g_iReturnVarID,j,p->i,snum); + OnEvent(EVENT_NEXTWEAPON,p->i,snum, -1); + if((unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum) != j) + j = (unsigned long) GetGameVarID(g_iReturnVarID,p->i,snum); + } + + if (p->reloading == 1) + j = -1; + else if( j > 0 && p->kickback_pic == 1 && p->weapon_pos == 1) + { + p->wantweaponfire = j; + p->kickback_pic = 0; + } + if(p->last_pissed_time <= (26*218) && p->show_empty_weapon == 0 && p->kickback_pic == 0 && p->quick_kick == 0 && sprite[p->i].xrepeat > 32 && p->access_incs == 0 && p->knee_incs == 0 ) + { + if( ( p->weapon_pos == 0 || ( p->holster_weapon && p->weapon_pos == -9 ) )) + { + if(j == 10 || j == 11) + { + k = p->curr_weapon; + j = ( j == 10 ? -1 : 1 ); // JBF: prev (-1) or next (1) weapon choice + i = 0; + + while( ( k >= 0 && k < 10 ) || ( PLUTOPAK && k == GROW_WEAPON && (p->subweapon&(1<subweapon&(1<gotweapon[k] && p->ammo_amount[k] > 0 ) + { + if (PLUTOPAK) // JBF 20040116: so we don't select grower with v1.3d + if( k == SHRINKER_WEAPON && (p->subweapon&(1<ammo_amount[GROW_WEAPON] == 0 && p->gotweapon[SHRINKER_WEAPON] && p->ammo_amount[SHRINKER_WEAPON] > 0) // JBF 20040116: added PLUTOPAK so we don't select grower with v1.3d + { + j = SHRINKER_WEAPON; + p->subweapon &= ~(1<ammo_amount[SHRINKER_WEAPON] == 0 && p->gotweapon[SHRINKER_WEAPON] && p->ammo_amount[GROW_WEAPON] > 0) // JBF 20040116: added PLUTOPAK so we don't select grower with v1.3d + { + j = GROW_WEAPON; + p->subweapon |= (1<i, snum); + SetGameVarID(g_iReturnVarID,0,p->i,snum); + OnEvent(EVENT_SELECTWEAPON,p->i,snum, -1); + if(GetGameVarID(g_iReturnVarID,p->i,snum) == 0) + { + if( j == HANDBOMB_WEAPON && p->ammo_amount[HANDBOMB_WEAPON] == 0 ) + { + k = headspritestat[1]; + while(k >= 0) + { + if( sprite[k].picnum == HEAVYHBOMB && sprite[k].owner == p->i ) + { + p->gotweapon[HANDBOMB_WEAPON] = 1; + j = HANDREMOTE_WEAPON; + break; + } + k = nextspritestat[k]; + } + } + + if(j == SHRINKER_WEAPON && PLUTOPAK) // JBF 20040116: so we don't select the grower with v1.3d + { + if(screenpeek == snum) pus = NUMPAGES; + + if( p->curr_weapon != GROW_WEAPON && p->curr_weapon != SHRINKER_WEAPON ) + { + if( p->ammo_amount[GROW_WEAPON] > 0 ) + { + if( (p->subweapon&(1<ammo_amount[SHRINKER_WEAPON] == 0) + { + j = GROW_WEAPON; + p->subweapon |= (1<ammo_amount[SHRINKER_WEAPON] > 0 ) + p->subweapon &= ~(1<curr_weapon == SHRINKER_WEAPON ) + { + p->subweapon |= (1<subweapon &= ~(1<holster_weapon) + { + sb_snum |= 1<<19; + p->weapon_pos = -9; + } + else if( (long)j >= 0 && p->gotweapon[j] && (unsigned long)p->curr_weapon != j ) + switch(j) + { + case KNEE_WEAPON: + addweapon( p, KNEE_WEAPON ); + break; + case PISTOL_WEAPON: + if ( p->ammo_amount[PISTOL_WEAPON] == 0 ) + if(p->show_empty_weapon == 0) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon( p, PISTOL_WEAPON ); + break; + case SHOTGUN_WEAPON: + if( p->ammo_amount[SHOTGUN_WEAPON] == 0 && p->show_empty_weapon == 0) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon( p, SHOTGUN_WEAPON); + break; + case CHAINGUN_WEAPON: + if( p->ammo_amount[CHAINGUN_WEAPON] == 0 && p->show_empty_weapon == 0) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon( p, CHAINGUN_WEAPON); + break; + case RPG_WEAPON: + if( p->ammo_amount[RPG_WEAPON] == 0 ) + if(p->show_empty_weapon == 0) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon( p, RPG_WEAPON ); + break; + case DEVISTATOR_WEAPON: + if( p->ammo_amount[DEVISTATOR_WEAPON] == 0 && p->show_empty_weapon == 0 ) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon( p, DEVISTATOR_WEAPON ); + break; + case FREEZE_WEAPON: + if( p->ammo_amount[FREEZE_WEAPON] == 0 && p->show_empty_weapon == 0) + { + p->last_full_weapon = p->curr_weapon; + p->show_empty_weapon = 32; + } + addweapon( p, FREEZE_WEAPON ); + break; + case GROW_WEAPON: + case SHRINKER_WEAPON: + + if( p->ammo_amount[j] == 0 && p->show_empty_weapon == 0) + { + p->show_empty_weapon = 32; + p->last_full_weapon = p->curr_weapon; + } + + addweapon(p, j); + break; + case HANDREMOTE_WEAPON: + if(k >= 0) // Found in list of [1]'s + { + p->curr_weapon = HANDREMOTE_WEAPON; + p->last_weapon = -1; + p->weapon_pos = 10; + } + break; + case HANDBOMB_WEAPON: + if( p->ammo_amount[HANDBOMB_WEAPON] > 0 && p->gotweapon[HANDBOMB_WEAPON] ) + addweapon( p, HANDBOMB_WEAPON ); + break; + case TRIPBOMB_WEAPON: + if( p->ammo_amount[TRIPBOMB_WEAPON] > 0 && p->gotweapon[TRIPBOMB_WEAPON] ) + addweapon( p, TRIPBOMB_WEAPON ); + break; + } + } + + } + if( sb_snum&(1<<19) ) + { + if( p->curr_weapon > KNEE_WEAPON ) + { + if(p->holster_weapon == 0 && p->weapon_pos == 0) + { + p->holster_weapon = 1; + p->weapon_pos = -1; + FTA(73,p); + } + else if(p->holster_weapon == 1 && p->weapon_pos == -9) + { + p->holster_weapon = 0; + p->weapon_pos = 10; + FTA(74,p); + } + } + } + } + + if( sb_snum&(1<<24) && p->newowner == -1 ) + { + + if( p->holoduke_on == -1 ) + { + + SetGameVarID(g_iReturnVarID,0,ps[snum].i,snum); + OnEvent(EVENT_HOLODUKEON,ps[snum].i,snum, -1); + if(GetGameVarID(g_iReturnVarID,ps[snum].i,snum) == 0) + { + if( p->holoduke_amount > 0 ) + { + p->inven_icon = 3; + + p->holoduke_on = i = + EGS(p->cursectnum, + p->posx, + p->posy, + p->posz+(30<<8),APLAYER,-64,0,0,p->ang,0,0,-1,10); + T4 = T5 = 0; + SP = snum; + sprite[i].extra = 0; + FTA(47,p); + } + else FTA(49,p); + spritesound(TELEPORTER,p->holoduke_on); + } + + } + else + { + SetGameVarID(g_iReturnVarID,0,ps[snum].i,snum); + OnEvent(EVENT_HOLODUKEOFF,ps[snum].i,snum, -1); + if(GetGameVarID(g_iReturnVarID,ps[snum].i,snum) == 0) + { + spritesound(TELEPORTER,p->holoduke_on); + p->holoduke_on = -1; + FTA(48,p); + } + } + } + + if( sb_snum&(1<<16) ) + { + SetGameVarID(g_iReturnVarID,0,ps[snum].i,snum); + OnEvent(EVENT_USEMEDKIT,ps[snum].i,snum, -1); + if(GetGameVarID(g_iReturnVarID,ps[snum].i,snum) == 0) + { + if( p->firstaid_amount > 0 && sprite[p->i].extra < max_player_health ) + { + j = max_player_health-sprite[p->i].extra; + + if((unsigned long)p->firstaid_amount > j) + { + p->firstaid_amount -= j; + sprite[p->i].extra = max_player_health; + p->inven_icon = 1; + } + else + { + sprite[p->i].extra += p->firstaid_amount; + p->firstaid_amount = 0; + checkavailinven(p); + } + spritesound(DUKE_USEMEDKIT,p->i); + } + } + } + + if( sb_snum&(1<<25) && p->newowner == -1) + { + SetGameVarID(g_iReturnVarID,0,ps[snum].i,snum); + OnEvent(EVENT_USEJETPACK,ps[snum].i,snum, -1); + if(GetGameVarID(g_iReturnVarID,ps[snum].i,snum) == 0) + { + if( p->jetpack_amount > 0 ) + { + p->jetpack_on = !p->jetpack_on; + if(p->jetpack_on) + { + p->inven_icon = 4; + if(p->scream_voice > FX_Ok) + { + FX_StopSound(p->scream_voice); + testcallback(DUKE_SCREAM); + p->scream_voice = FX_Ok; + } + + spritesound(DUKE_JETPACK_ON,p->i); + + FTA(52,p); + } + else + { + p->hard_landing = 0; + p->poszv = 0; + spritesound(DUKE_JETPACK_OFF,p->i); + stopspritesound(DUKE_JETPACK_IDLE,p->i); + stopspritesound(DUKE_JETPACK_ON,p->i); + FTA(53,p); + } + } + else FTA(50,p); + } + } + + if(sb_snum&(1<<28) && p->one_eighty_count == 0) + { + SetGameVarID(g_iReturnVarID,0,p->i,snum); + OnEvent(EVENT_TURNAROUND,p->i,snum, -1); + if(GetGameVarID(g_iReturnVarID,p->i,snum) == 0) + { + p->one_eighty_count = -1024; + } + } + } +} + +void checksectors(short snum) +{ + long i = -1,oldz; + struct player_struct *p; + short j,hitscanwall; + + p = &ps[snum]; + + switch(sector[p->cursectnum].lotag) + { + + case 32767: + sector[p->cursectnum].lotag = 0; + FTA(9,p); + p->secret_rooms++; + return; + case -1: + for(i=connecthead;i>=0;i=connectpoint2[i]) + ps[i].gm = MODE_EOL; + sector[p->cursectnum].lotag = 0; + if(ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + ud.level_number++; + if( (ud.volume_number && ud.level_number > 10 ) || ud.level_number > 5 ) + ud.level_number = 0; + ud.m_level_number = ud.level_number; + } + return; + case -2: + sector[p->cursectnum].lotag = 0; + p->timebeforeexit = 26*8; + p->customexitsound = sector[p->cursectnum].hitag; + return; + default: + if(sector[p->cursectnum].lotag >= 10000 && sector[p->cursectnum].lotag < 16383) + { + if(snum == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) + spritesound(sector[p->cursectnum].lotag-10000,p->i); + sector[p->cursectnum].lotag = 0; + } + break; + + } + + //After this point the the player effects the map with space + + if(p->gm&MODE_TYPE || sprite[p->i].extra <= 0) return; + + if((sync[snum].bits&(1<<29))) + { + SetGameVarID(g_iReturnVarID,0,p->i,snum); + OnEvent(EVENT_USE, p->i, snum, -1); + if(GetGameVarID(g_iReturnVarID,p->i,snum) != 0) + sync[snum].bits &= ~(1<<29); + } + + if( ud.cashman && sync[snum].bits&(1<<29) ) + lotsofmoney(&sprite[p->i],2); + + if(p->newowner >= 0) + { + if( klabs(sync[snum].svel) > 768 || klabs(sync[snum].fvel) > 768 ) + { + i = -1; + goto CLEARCAMERAS; + } + } + + if( !(sync[snum].bits&(1<<29)) && !(sync[snum].bits&(1<<31))) + p->toggle_key_flag = 0; + + else if(!p->toggle_key_flag) + { + + if( (sync[snum].bits&(1<<31)) ) + { + if( p->newowner >= 0 ) + { + i = -1; + goto CLEARCAMERAS; + } + return; + } + + neartagsprite = -1; + p->toggle_key_flag = 1; + hitscanwall = -1; + + i = hitawall(p,&hitscanwall); + + if(i < 1280 && hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR) + if( wall[hitscanwall].lotag > 0 && !isspritemakingsound(p->i,wall[hitscanwall].lotag) && snum == screenpeek) + { + spritesound(wall[hitscanwall].lotag,p->i); + return; + } + + if(hitscanwall >= 0 && (wall[hitscanwall].cstat&16) ) + switch(wall[hitscanwall].overpicnum) + { + default: + if(wall[hitscanwall].lotag) + return; + } + + if(p->newowner >= 0) + neartag(p->oposx,p->oposy,p->oposz,sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,1); + else + { + neartag(p->posx,p->posy,p->posz,sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,1); + if(neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + neartag(p->posx,p->posy,p->posz+(8<<8),sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,1); + if(neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + neartag(p->posx,p->posy,p->posz+(16<<8),sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,1); + if(neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + { + neartag(p->posx,p->posy,p->posz+(16<<8),sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,3); + if(neartagsprite >= 0) + { + switch(dynamictostatic[sprite[neartagsprite].picnum]) + { + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case PODFEM1__STATIC: + case NAKED1__STATIC: + case STATUE__STATIC: + case TOUGHGAL__STATIC: + return; + } + } + + neartagsprite = -1; + neartagwall = -1; + neartagsector = -1; + } + } + + if(p->newowner == -1 && neartagsprite == -1 && neartagsector == -1 && neartagwall == -1 ) + if( isanunderoperator(sector[sprite[p->i].sectnum].lotag) ) + neartagsector = sprite[p->i].sectnum; + + if( neartagsector >= 0 && (sector[neartagsector].lotag&16384) ) + return; + + if( neartagsprite == -1 && neartagwall == -1) + if(sector[p->cursectnum].lotag == 2 ) + { + oldz = hitasprite(p->i,&neartagsprite); + if(oldz > 1280) neartagsprite = -1; + } + + if(neartagsprite >= 0) + { + if( checkhitswitch(snum,neartagsprite,1) ) return; + + switch(dynamictostatic[sprite[neartagsprite].picnum]) + { + case TOILET__STATIC: + case STALL__STATIC: + if(p->last_pissed_time == 0) + { + if(ud.lockout == 0) spritesound(DUKE_URINATE,p->i); + + p->last_pissed_time = 26*220; + p->transporter_hold = 29*2; + if(p->holster_weapon == 0) + { + p->holster_weapon = 1; + p->weapon_pos = -1; + } + if(sprite[p->i].extra <= (max_player_health-(max_player_health/10) ) ) + { + sprite[p->i].extra += max_player_health/10; + p->last_extra = sprite[p->i].extra; + } + else if(sprite[p->i].extra < max_player_health ) + sprite[p->i].extra = max_player_health; + } + else if(!isspritemakingsound(neartagsprite,FLUSH_TOILET)) + spritesound(FLUSH_TOILET,neartagsprite); + return; + + case NUKEBUTTON__STATIC: + + hitawall(p,&j); + if(j >= 0 && wall[j].overpicnum == 0) + if(hittype[neartagsprite].temp_data[0] == 0) + { + hittype[neartagsprite].temp_data[0] = 1; + sprite[neartagsprite].owner = p->i; + p->buttonpalette = sprite[neartagsprite].pal; + if(p->buttonpalette) + ud.secretlevel = sprite[neartagsprite].lotag; + else ud.secretlevel = 0; + } + return; + case WATERFOUNTAIN__STATIC: + if(hittype[neartagsprite].temp_data[0] != 1) + { + hittype[neartagsprite].temp_data[0] = 1; + sprite[neartagsprite].owner = p->i; + + if(sprite[p->i].extra < max_player_health) + { + sprite[p->i].extra++; + spritesound(DUKE_DRINKING,p->i); + } + } + return; + case PLUG__STATIC: + spritesound(SHORT_CIRCUIT,p->i); + sprite[p->i].extra -= 2+(TRAND&3); + p->pals[0] = 48; + p->pals[1] = 48; + p->pals[2] = 64; + p->pals_time = 32; + break; + case VIEWSCREEN__STATIC: + case VIEWSCREEN2__STATIC: + { + i = headspritestat[1]; + + while(i >= 0) + { + if( PN == CAMERA1 && SP == 0 && sprite[neartagsprite].hitag == SLT ) + { + SP = 1; //Using this camera + spritesound(MONITOR_ACTIVE,neartagsprite); + + sprite[neartagsprite].owner = i; + sprite[neartagsprite].yvel = 1; + + + j = p->cursectnum; + p->cursectnum = SECT; + setpal(p); + p->cursectnum = j; + + // parallaxtype = 2; + p->newowner = i; + return; + } + i = nextspritestat[i]; + } + } + +CLEARCAMERAS: + + if(i < 0) + { + p->posx = p->oposx; + p->posy = p->oposy; + p->posz = p->oposz; + p->ang = p->oang; + p->newowner = -1; + + updatesector(p->posx,p->posy,&p->cursectnum); + setpal(p); + + + i = headspritestat[1]; + while(i >= 0) + { + if(PN==CAMERA1) SP = 0; + i = nextspritestat[i]; + } + } + else if(p->newowner >= 0) + p->newowner = -1; + + if( KB_KeyPressed(sc_Escape) ) + KB_ClearKeyDown(sc_Escape); + + return; + } + } + + if( (sync[snum].bits&(1<<29)) == 0 ) return; + else if(p->newowner >= 0) { i = -1; goto CLEARCAMERAS; } + + if(neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) + if( klabs(hits(p->i)) < 512 ) + { + if( (TRAND&255) < 16 ) + spritesound(DUKE_SEARCH2,p->i); + else spritesound(DUKE_SEARCH,p->i); + return; + } + + if( neartagwall >= 0 ) + { + if( wall[neartagwall].lotag > 0 && isadoorwall(wall[neartagwall].picnum) ) + { + if(hitscanwall == neartagwall || hitscanwall == -1) + checkhitswitch(snum,neartagwall,0); + return; + } + else if(p->newowner >= 0) + { + i = -1; + goto CLEARCAMERAS; + } + } + + if( neartagsector >= 0 && (sector[neartagsector].lotag&16384) == 0 && isanearoperator(sector[neartagsector].lotag) ) + { + i = headspritesect[neartagsector]; + while(i >= 0) + { + if( PN == ACTIVATOR || PN == MASTERSWITCH ) + return; + i = nextspritesect[i]; + } + operatesectors(neartagsector,p->i); + } + else if( (sector[sprite[p->i].sectnum].lotag&16384) == 0 ) + { + if( isanunderoperator(sector[sprite[p->i].sectnum].lotag) ) + { + i = headspritesect[sprite[p->i].sectnum]; + while(i >= 0) + { + if(PN == ACTIVATOR || PN == MASTERSWITCH) return; + i = nextspritesect[i]; + } + operatesectors(sprite[p->i].sectnum,p->i); + } + else checkhitswitch(snum,neartagwall,0); + } + } +} + diff --git a/polymer/eduke32/source/soundefs.h b/polymer/eduke32/source/soundefs.h new file mode 100644 index 000000000..806e7050e --- /dev/null +++ b/polymer/eduke32/source/soundefs.h @@ -0,0 +1,417 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +#define KICK_HIT 0 +#define PISTOL_RICOCHET 1 +#define PISTOL_BODYHIT 2 +#define PISTOL_FIRE 3 +#define EJECT_CLIP 4 +#define INSERT_CLIP 5 +#define CHAINGUN_FIRE 6 +#define RPG_SHOOT 7 +#define POOLBALLHIT 8 +#define RPG_EXPLODE 9 +#define CAT_FIRE 10 +#define SHRINKER_FIRE 11 +#define ACTOR_SHRINKING 12 +#define PIPEBOMB_BOUNCE 13 +#define PIPEBOMB_EXPLODE 14 +#define LASERTRIP_ONWALL 15 +#define LASERTRIP_ARMING 16 +#define LASERTRIP_EXPLODE 17 +#define VENT_BUST 18 +#define GLASS_BREAKING 19 +#define GLASS_HEAVYBREAK 20 +#define SHORT_CIRCUIT 21 +#define ITEM_SPLASH 22 +#define DUKE_BREATHING 23 +#define DUKE_EXHALING 24 +#define DUKE_GASP 25 +#define SLIM_RECOG 26 +// #define ENDSEQVOL3SND1 27 +#define DUKE_URINATE 28 +#define ENDSEQVOL3SND2 29 +#define ENDSEQVOL3SND3 30 +#define DUKE_PASSWIND 32 +#define DUKE_CRACK 33 +#define SLIM_ATTACK 34 +#define SOMETHINGHITFORCE 35 +#define DUKE_DRINKING 36 +#define DUKE_KILLED1 37 +#define DUKE_GRUNT 38 +#define DUKE_HARTBEAT 39 +#define DUKE_ONWATER 40 +#define DUKE_DEAD 41 +#define DUKE_LAND 42 +#define DUKE_WALKINDUCTS 43 +#define DUKE_GLAD 44 +#define DUKE_YES 45 +#define DUKE_HEHE 46 +#define DUKE_SHUCKS 47 +#define DUKE_UNDERWATER 48 +#define DUKE_JETPACK_ON 49 +#define DUKE_JETPACK_IDLE 50 +#define DUKE_JETPACK_OFF 51 +#define LIZTROOP_GROWL 52 +#define LIZTROOP_TALK1 53 +#define LIZTROOP_TALK2 54 +#define LIZTROOP_TALK3 55 +#define DUKETALKTOBOSS 56 +#define LIZCAPT_GROWL 57 +#define LIZCAPT_TALK1 58 +#define LIZCAPT_TALK2 59 +#define LIZCAPT_TALK3 60 +#define LIZARD_BEG 61 +#define LIZARD_PAIN 62 +#define LIZARD_DEATH 63 +#define LIZARD_SPIT 64 +#define DRONE1_HISSRATTLE 65 +#define DRONE1_HISSSCREECH 66 +#define DUKE_TIP2 67 +#define FLESH_BURNING 68 +#define SQUISHED 69 +#define TELEPORTER 70 +#define ELEVATOR_ON 71 +#define DUKE_KILLED3 72 +#define ELEVATOR_OFF 73 +#define DOOR_OPERATE1 74 +#define SUBWAY 75 +#define SWITCH_ON 76 +#define FAN 77 +#define DUKE_GETWEAPON3 78 +#define FLUSH_TOILET 79 +#define HOVER_CRAFT 80 +#define EARTHQUAKE 81 +#define INTRUDER_ALERT 82 +#define END_OF_LEVEL_WARN 83 +#define ENGINE_OPERATING 84 +#define REACTOR_ON 85 +#define COMPUTER_AMBIENCE 86 +#define GEARS_GRINDING 87 +#define BUBBLE_AMBIENCE 88 +#define MACHINE_AMBIENCE 89 +#define SEWER_AMBIENCE 90 +#define WIND_AMBIENCE 91 +#define SOMETHING_DRIPPING 92 +#define STEAM_HISSING 93 +#define THEATER_BREATH 94 +#define BAR_MUSIC 95 +#define BOS1_ROAM 96 +#define BOS1_RECOG 97 +#define BOS1_ATTACK1 98 +#define BOS1_PAIN 99 +#define BOS1_DYING 100 +#define BOS2_ROAM 101 +#define BOS2_RECOG 102 +#define BOS2_ATTACK 103 +#define BOS2_PAIN 104 +#define BOS2_DYING 105 +#define GETATOMICHEALTH 106 +#define DUKE_GETWEAPON2 107 +#define BOS3_DYING 108 +#define SHOTGUN_FIRE 109 +#define PRED_ROAM 110 +#define PRED_RECOG 111 +#define PRED_ATTACK 112 +#define PRED_PAIN 113 +#define PRED_DYING 114 +#define CAPT_ROAM 115 +#define CAPT_ATTACK 116 +#define CAPT_RECOG 117 +#define CAPT_PAIN 118 +#define CAPT_DYING 119 +#define PIG_ROAM 120 +#define PIG_RECOG 121 +#define PIG_ATTACK 122 +#define PIG_PAIN 123 +#define PIG_DYING 124 +#define RECO_ROAM 125 +#define RECO_RECOG 126 +#define RECO_ATTACK 127 +#define RECO_PAIN 128 +#define RECO_DYING 129 +#define DRON_ROAM 130 +#define DRON_RECOG 131 +#define DRON_ATTACK1 132 +#define DRON_PAIN 133 +#define DRON_DYING 134 +#define COMM_ROAM 135 +#define COMM_RECOG 136 +#define COMM_ATTACK 137 +#define COMM_PAIN 138 +#define COMM_DYING 139 +#define OCTA_ROAM 140 +#define OCTA_RECOG 141 +#define OCTA_ATTACK1 142 +#define OCTA_PAIN 143 +#define OCTA_DYING 144 +#define TURR_ROAM 145 +#define TURR_RECOG 146 +#define TURR_ATTACK 147 +#define DUMPSTER_MOVE 148 +#define SLIM_DYING 149 +#define BOS3_ROAM 150 +#define BOS3_RECOG 151 +#define BOS3_ATTACK1 152 +#define BOS3_PAIN 153 +#define BOS1_ATTACK2 154 +#define COMM_SPIN 155 +#define BOS1_WALK 156 +#define DRON_ATTACK2 157 +#define THUD 158 +#define OCTA_ATTACK2 159 +#define WIERDSHOT_FLY 160 +#define TURR_PAIN 161 +#define TURR_DYING 162 +#define SLIM_ROAM 163 +#define LADY_SCREAM 164 +#define DOOR_OPERATE2 165 +#define DOOR_OPERATE3 166 +#define DOOR_OPERATE4 167 +#define BORNTOBEWILDSND 168 +#define SHOTGUN_COCK 169 +#define GENERIC_AMBIENCE1 170 +#define GENERIC_AMBIENCE2 171 +#define GENERIC_AMBIENCE3 172 +#define GENERIC_AMBIENCE4 173 +#define GENERIC_AMBIENCE5 174 +#define GENERIC_AMBIENCE6 175 +#define BOS3_ATTACK2 176 +#define GENERIC_AMBIENCE17 177 +#define GENERIC_AMBIENCE18 178 +#define GENERIC_AMBIENCE19 179 +#define GENERIC_AMBIENCE20 180 +#define GENERIC_AMBIENCE21 181 +#define GENERIC_AMBIENCE22 182 +#define SECRETLEVELSND 183 +#define GENERIC_AMBIENCE8 184 +#define GENERIC_AMBIENCE9 185 +#define GENERIC_AMBIENCE10 186 +#define GENERIC_AMBIENCE11 187 +#define GENERIC_AMBIENCE12 188 +#define GENERIC_AMBIENCE13 189 +#define GENERIC_AMBIENCE14 190 +#define GENERIC_AMBIENCE15 192 +#define GENERIC_AMBIENCE16 193 +#define FIRE_CRACKLE 194 +#define BONUS_SPEECH1 195 +#define BONUS_SPEECH2 196 +#define BONUS_SPEECH3 197 +#define PIG_CAPTURE_DUKE 198 +#define BONUS_SPEECH4 199 +#define DUKE_LAND_HURT 200 +#define DUKE_HIT_STRIPPER1 201 +#define DUKE_TIP1 202 +#define DUKE_KILLED2 203 +#define PRED_ROAM2 204 +#define PIG_ROAM2 205 +#define DUKE_GETWEAPON1 206 +#define DUKE_SEARCH2 207 +#define DUKE_CRACK2 208 +#define DUKE_SEARCH 209 +#define DUKE_GET 210 +#define DUKE_LONGTERM_PAIN 211 +#define MONITOR_ACTIVE 212 +#define NITEVISION_ONOFF 213 +#define DUKE_HIT_STRIPPER2 214 +#define DUKE_CRACK_FIRST 215 +#define DUKE_USEMEDKIT 216 +#define DUKE_TAKEPILLS 217 +#define DUKE_PISSRELIEF 218 +#define SELECT_WEAPON 219 +#define WATER_GURGLE 220 +#define DUKE_GETWEAPON4 221 +#define JIBBED_ACTOR1 222 +#define JIBBED_ACTOR2 223 +#define JIBBED_ACTOR3 224 +#define JIBBED_ACTOR4 225 +#define JIBBED_ACTOR5 226 +#define JIBBED_ACTOR6 227 +#define JIBBED_ACTOR7 228 +#define DUKE_GOTHEALTHATLOW 229 +#define BOSSTALKTODUKE 230 +#define WAR_AMBIENCE1 231 +#define WAR_AMBIENCE2 232 +#define WAR_AMBIENCE3 233 +#define WAR_AMBIENCE4 234 +#define WAR_AMBIENCE5 235 +#define WAR_AMBIENCE6 236 +#define WAR_AMBIENCE7 237 +#define WAR_AMBIENCE8 238 +#define WAR_AMBIENCE9 239 +#define WAR_AMBIENCE10 240 +#define ALIEN_TALK1 241 +#define ALIEN_TALK2 242 +#define EXITMENUSOUND 243 +#define FLY_BY 244 +#define DUKE_SCREAM 245 +#define SHRINKER_HIT 246 +#define RATTY 247 +#define INTO_MENU 248 +#define BONUSMUSIC 249 +#define DUKE_BOOBY 250 +#define DUKE_TALKTOBOSSFALL 251 +#define DUKE_LOOKINTOMIRROR 252 +#define PIG_ROAM3 253 +#define KILLME 254 +#define DRON_JETSND 255 +#define SPACE_DOOR1 256 +#define SPACE_DOOR2 257 +#define SPACE_DOOR3 258 +#define SPACE_DOOR4 259 +#define SPACE_DOOR5 260 +#define ALIEN_ELEVATOR1 261 +#define VAULT_DOOR 262 +#define JIBBED_ACTOR13 263 +#define DUKE_GETWEAPON6 264 +#define JIBBED_ACTOR8 265 +#define JIBBED_ACTOR9 266 +#define JIBBED_ACTOR10 267 +#define JIBBED_ACTOR11 268 +#define JIBBED_ACTOR12 269 +#define DUKE_KILLED4 270 +#define DUKE_KILLED5 271 +#define ALIEN_SWITCH1 272 +#define DUKE_STEPONFECES 273 +#define DUKE_LONGTERM_PAIN2 274 +#define DUKE_LONGTERM_PAIN3 275 +#define DUKE_LONGTERM_PAIN4 276 +#define COMPANB2 277 +#define KTIT 278 +#define HELICOP_IDLE 279 +#define STEPNIT 280 +#define SPACE_AMBIENCE1 281 +#define SPACE_AMBIENCE2 282 +#define SLIM_HATCH 283 +#define RIPHEADNECK 284 +#define FOUNDJONES 285 +#define ALIEN_DOOR1 286 +#define ALIEN_DOOR2 287 +#define ENDSEQVOL3SND4 288 +#define ENDSEQVOL3SND5 289 +#define ENDSEQVOL3SND6 290 +#define ENDSEQVOL3SND7 291 +#define ENDSEQVOL3SND8 292 +#define ENDSEQVOL3SND9 293 +#define WHIPYOURASS 294 +#define ENDSEQVOL2SND1 295 +#define ENDSEQVOL2SND2 296 +#define ENDSEQVOL2SND3 297 +#define ENDSEQVOL2SND4 298 +#define ENDSEQVOL2SND5 299 +#define ENDSEQVOL2SND6 300 +#define ENDSEQVOL2SND7 301 +#define GENERIC_AMBIENCE23 302 +#define SOMETHINGFROZE 303 +#define DUKE_LONGTERM_PAIN5 304 +#define DUKE_LONGTERM_PAIN6 305 +#define DUKE_LONGTERM_PAIN7 306 +#define DUKE_LONGTERM_PAIN8 307 +#define WIND_REPEAT 308 +#define MYENEMY_ROAM 309 +#define MYENEMY_HURT 310 +#define MYENEMY_DEAD 311 +#define MYENEMY_SHOOT 312 +#define STORE_MUSIC 313 +#define STORE_MUSIC_BROKE 314 +#define ACTOR_GROWING 315 +#define NEWBEAST_ROAM 316 +#define NEWBEAST_RECOG 317 +#define NEWBEAST_ATTACK 318 +#define NEWBEAST_PAIN 319 +#define NEWBEAST_DYING 320 +#define NEWBEAST_SPIT 321 +#define VOL4_1 322 +#define SUPERMARKET 323 +#define MOUSEANNOY 324 +#define BOOKEM 325 +#define SUPERMARKETCRY 326 +#define DESTRUCT 327 +#define EATFOOD 328 +#define MAKEMYDAY 329 +#define WITNESSSTAND 330 +#define VACATIONSPEECH 331 +#define YIPPEE1 332 +#define YOHOO1 333 +#define YOHOO2 334 +#define DOLPHINSND 335 +#define TOUGHGALSND1 336 +#define TOUGHGALSND2 337 +#define TOUGHGALSND3 338 +#define TOUGHGALSND4 339 +#define TANK_ROAM 340 +#define BOS4_ROAM 341 +#define BOS4_RECOG 342 +#define BOS4_ATTACK 343 +#define BOS4_PAIN 344 +#define BOS4_DYING 345 +#define NEWBEAST_ATTACKMISS 346 +#define VOL4_2 347 +#define COOKINGDEEPFRIER 348 +#define WHINING_DOG 349 +#define DEAD_DOG 350 +#define LIGHTNING_SLAP 351 +#define THUNDER 352 +#define HAPPYMOUSESND1 353 +#define HAPPYMOUSESND2 354 +#define HAPPYMOUSESND3 355 +#define HAPPYMOUSESND4 356 +#define ALARM 357 +#define RAIN 358 +#define DTAG_GREENRUN 359 +#define DTAG_BROWNRUN 360 +#define DTAG_GREENSCORE 361 +#define DTAG_BROWNSCORE 362 +#define INTRO4_1 363 +#define INTRO4_2 364 +#define INTRO4_3 365 +#define INTRO4_4 366 +#define INTRO4_5 367 +#define INTRO4_6 368 +#define SCREECH 369 +#define BOSS4_DEADSPEECH 370 +#define BOSS4_FIRSTSEE 371 +#define PARTY_SPEECH 372 +#define POSTAL_SPEECH 373 +#define TGSPEECH 374 +#define DOGROOMSPEECH 375 +#define SMACKED 376 +#define MDEVSPEECH 377 +#define AREA51SPEECH 378 +#define JEEPSOUND 379 +#define BIGDOORSLAM 380 +#define BOS4_LAY 381 +#define WAVESOUND 382 +#define ILLBEBACK 383 +#define VOL4ENDSND1 384 +#define VOL4ENDSND2 385 +#define EXPANDERHIT 386 +#define SNAKESPEECH 387 +#define EXPANDERSHOOT 388 +#define GETBACKTOWORK 389 +#define JIBBED_ACTOR14 390 +#define JIBBED_ACTOR15 391 +#define INTRO4_B 392 +#define BIGBANG 393 +#define SMACKIT 394 +#define BELLSND 395 +// MAXIMUM NUMBER OF SOUNDS: 450 ( 0-449 ) diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c new file mode 100644 index 000000000..693ba9701 --- /dev/null +++ b/polymer/eduke32/source/sounds.c @@ -0,0 +1,632 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2005 - EDuke32 team + +This file is part of EDuke32 + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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. +*/ +//------------------------------------------------------------------------- + +//#include +#include +#include +#include "types.h" +#include "fx_man.h" +#include "music.h" +#include "duke3d.h" +#include "util_lib.h" + + +#define LOUDESTVOLUME 150 + +long backflag,numenvsnds; + +/* +=================== += += SoundStartup += +=================== +*/ + +void SoundStartup( void ) +{ + int32 status; + + // if they chose None lets return + if (FXDevice < 0) return; + + status = FX_Init( FXDevice, NumVoices, NumChannels, NumBits, MixRate ); + if ( status == FX_Ok ) { + FX_SetVolume( FXVolume ); + if (ReverseStereo == 1) { + FX_SetReverseStereo(!FX_GetReverseStereo()); + } + status = FX_SetCallBack( testcallback ); + } + + if ( status != FX_Ok ) { + sprintf(tempbuf, "Sound startup error: %s", FX_ErrorString( FX_Error )); + gameexit(tempbuf); + } +} + +/* +=================== += += SoundShutdown += +=================== +*/ + +void SoundShutdown( void ) +{ + int32 status; + + // if they chose None lets return + if (FXDevice < 0) + return; + + status = FX_Shutdown(); + if ( status != FX_Ok ) { + sprintf(tempbuf, "Sound shutdown error: %s", FX_ErrorString( FX_Error )); + gameexit(tempbuf); + } +} + +/* +=================== += += MusicStartup += +=================== +*/ + +void MusicStartup( void ) +{ + int32 status; + + // if they chose None lets return + if (MusicDevice < 0) + return; + + status = MUSIC_Init( MusicDevice, 0 ); + + if ( status == MUSIC_Ok ) + { + MUSIC_SetVolume( MusicVolume ); + } + else + { + initprintf("Couldn't find selected sound card, or, error w/ sound card itself.\n"); + + SoundShutdown(); + uninittimer(); + uninitengine(); + CONTROL_Shutdown(); + CONFIG_WriteSetup(); + KB_Shutdown(); + uninitgroupfile(); + //unlink("duke3d.tmp"); + exit(-1); + } +} + +/* +=================== += += MusicShutdown += +=================== +*/ + +void MusicShutdown( void ) +{ + int32 status; + + // if they chose None lets return + if (MusicDevice < 0) + return; + + status = MUSIC_Shutdown(); + if ( status != MUSIC_Ok ) + { + Error( MUSIC_ErrorString( MUSIC_ErrorCode )); + } +} + +void MusicUpdate(void) +{ + MUSIC_Update(); +} + +int USRHOOKS_GetMem(char **ptr, unsigned long size ) +{ + *ptr = malloc(size); + + if (*ptr == NULL) + return(USRHOOKS_Error); + + return( USRHOOKS_Ok); + +} + +int USRHOOKS_FreeMem(char *ptr) +{ + free(ptr); + return( USRHOOKS_Ok); +} + +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 %= 17; +} + +void playmusic(char *fn) +{ + short fp; + long l; + + if(MusicToggle == 0) return; + if(MusicDevice < 0) return; + + fp = kopen4load(fn,0); + + if(fp == -1) return; + + l = kfilelength( fp ); + if(l >= (signed long)sizeof(MusicPtr)) + { + kclose(fp); + return; + } + + kread( fp, MusicPtr, l); + kclose( fp ); + MUSIC_PlaySong( MusicPtr, MUSIC_LoopSong ); +} + +char loadsound(unsigned short num) +{ + long fp, l; + + if(num >= NUM_SOUNDS || SoundToggle == 0) return 0; + if (FXDevice < 0) return 0; + + fp = kopen4load(sounds[num],loadfromgrouponly); + if(fp == -1) + { + sprintf(&fta_quotes[113][0],"Sound %s(#%d) not found.",sounds[num],num); + FTA(113,&ps[myconnectindex]); + return 0; + } + + l = kfilelength( fp ); + soundsiz[num] = l; + + Sound[num].lock = 200; + + allocache((long *)&Sound[num].ptr,l,(char *)&Sound[num].lock); + kread( fp, Sound[num].ptr , l); + kclose( fp ); + return 1; +} + +int xyzsound(short num,short i,long x,long y,long z) +{ + long sndist, cx, cy, cz, j,k; + short pitche,pitchs,cs; + int voice, sndang, ca, pitch; + + // if(num != 358) return 0; + + if( num >= NUM_SOUNDS || + FXDevice < 0 || + ( (soundm[num]&8) && ud.lockout ) || + SoundToggle == 0 || + Sound[num].num > 3 || + FX_VoiceAvailable(soundpr[num]) == 0 || + (ps[myconnectindex].timebeforeexit > 0 && ps[myconnectindex].timebeforeexit <= 26*3) || + ps[myconnectindex].gm&MODE_MENU) return -1; + + if( soundm[num]&128 ) + { + sound(num); + return 0; + } + + if( soundm[num]&4 ) + { + if(VoiceToggle==0 || (ud.multimode > 1 && PN == APLAYER && sprite[i].yvel != screenpeek && !(gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) ) return -1; + + for(j=0;j 0) && (soundm[j]&4) ) + return -1; + } + + cx = ps[screenpeek].oposx; + cy = ps[screenpeek].oposy; + cz = ps[screenpeek].oposz; + cs = ps[screenpeek].cursectnum; + ca = ps[screenpeek].ang+ps[screenpeek].look_ang; + + sndist = FindDistance3D((cx-x),(cy-y),(cz-z)>>4); + + if( i >= 0 && (soundm[num]&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9 ) + sndist = divscale14(sndist,(SHT+1)); + + pitchs = soundps[num]; + pitche = soundpe[num]; + cx = klabs(pitche-pitchs); + + if(cx) + { + if( pitchs < pitche ) + pitch = pitchs + ( rand()%cx ); + else pitch = pitche + ( rand()%cx ); + } + else pitch = pitchs; + + sndist += soundvo[num]; + if(sndist < 0) sndist = 0; + if( sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,SX,SY,SZ-(24<<8),SECT) ) + sndist += sndist>>5; + + switch(num) + { + case PIPEBOMB_EXPLODE: + case LASERTRIP_EXPLODE: + case RPG_EXPLODE: + if(sndist > (6144) ) + sndist = 6144; + if(sector[ps[screenpeek].cursectnum].lotag == 2) + pitch -= 1024; + break; + default: + if(sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0) + pitch = -768; + if( sndist > 31444 && PN != MUSICANDSFX) + return -1; + break; + } + + if (ps[screenpeek].sound_pitch) pitch = ps[screenpeek].sound_pitch; + + 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); + } + + if( PN == APLAYER && sprite[i].yvel == screenpeek ) + { + sndang = 0; + sndist = 0; + } + else + { + sndang = 2048 + ca - getangle(cx-x,cy-y); + sndang &= 2047; + } + + if(Sound[num].ptr == 0) { if( loadsound(num) == 0 ) return 0; } + else + { + if (Sound[num].lock < 200) + Sound[num].lock = 200; + else Sound[num].lock++; + } + + if( soundm[num]&16 ) sndist = 0; + + if(sndist < ((255-LOUDESTVOLUME)<<6) ) + sndist = ((255-LOUDESTVOLUME)<<6); + + if( soundm[num]&1 ) + { + unsigned short start; + + if(Sound[num].num > 0) return -1; + + start = *(unsigned short *)(Sound[num].ptr + 0x14); + + if(*Sound[num].ptr == 'C') + voice = FX_PlayLoopedVOC( Sound[num].ptr, start, start + soundsiz[num], + pitch,sndist>>6,sndist>>6,0,soundpr[num],num); + else + voice = FX_PlayLoopedWAV( Sound[num].ptr, start, start + soundsiz[num], + pitch,sndist>>6,sndist>>6,0,soundpr[num],num); + } + else + { + if( *Sound[num].ptr == 'C') + voice = FX_PlayVOC3D( Sound[ num ].ptr,pitch,sndang>>6,sndist>>6, soundpr[num], num ); + else + voice = FX_PlayWAV3D( Sound[ num ].ptr,pitch,sndang>>6,sndist>>6, soundpr[num], num ); + } + + if ( voice > FX_Ok ) + { + SoundOwner[num][Sound[num].num].i = i; + SoundOwner[num][Sound[num].num].voice = voice; + Sound[num].num++; + } + else Sound[num].lock--; + return (voice); +} + +void sound(short num) +{ + short pitch,pitche,pitchs,cx; + int voice; + long start; + + if (FXDevice < 0) return; + if(SoundToggle==0) return; + if(VoiceToggle==0 && (soundm[num]&4) ) return; + if( (soundm[num]&8) && ud.lockout ) return; + if(FX_VoiceAvailable(soundpr[num]) == 0) return; + + pitchs = soundps[num]; + pitche = soundpe[num]; + cx = klabs(pitche-pitchs); + + if(cx) + { + if( pitchs < pitche ) + pitch = pitchs + ( rand()%cx ); + else pitch = pitche + ( rand()%cx ); + } + else pitch = pitchs; + +if(Sound[num].ptr == 0) { if( loadsound(num) == 0 ) return; } + else + { + if (Sound[num].lock < 200) + Sound[num].lock = 200; + else Sound[num].lock++; + } + + if( soundm[num]&1 ) + { + if(*Sound[num].ptr == 'C') + { + start = (long)*(unsigned short *)(Sound[num].ptr + 0x14); + voice = FX_PlayLoopedVOC( Sound[num].ptr, start, start + soundsiz[num], + pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,soundpr[num],num); + } + else + { + start = (long)*(unsigned short *)(Sound[num].ptr + 0x14); + voice = FX_PlayLoopedWAV( Sound[num].ptr, start, start + soundsiz[num], + pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,soundpr[num],num); + } + } + else + { + if(*Sound[num].ptr == 'C') + voice = FX_PlayVOC3D( Sound[ num ].ptr, pitch,0,255-LOUDESTVOLUME,soundpr[num], num ); + else + voice = FX_PlayWAV3D( Sound[ num ].ptr, pitch,0,255-LOUDESTVOLUME,soundpr[num], num ); + } + + if(voice > FX_Ok) return; + Sound[num].lock--; +} + +int spritesound(unsigned short num, short i) +{ + if(num >= NUM_SOUNDS) return -1; + return xyzsound(num,i,SX,SY,SZ); +} + +void stopspritesound(short num, short i) +{ + stopsound(num); +} + +void stopsound(short num) +{ + if(Sound[num].num > 0) + { + FX_StopSound(SoundOwner[num][Sound[num].num-1].voice); + testcallback(num); + } +} + +void stopenvsound(short num,short i) +{ + short j, k; + + if(Sound[num].num > 0) + { + k = Sound[num].num; + for(j=0;j>4); + if( i >= 0 && (soundm[j]&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9 ) + sndist = divscale14(sndist,(SHT+1)); + } + + sndist += soundvo[j]; + if(sndist < 0) sndist = 0; + + if( sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,sx,sy,sz-(24<<8),SECT) ) + sndist += sndist>>5; + + if(PN == MUSICANDSFX && SLT < 999) + numenvsnds++; + + switch(j) + { + case PIPEBOMB_EXPLODE: + case LASERTRIP_EXPLODE: + case RPG_EXPLODE: + if(sndist > (6144)) sndist = (6144); + break; + default: + if( sndist > 31444 && PN != MUSICANDSFX) + { + stopsound(j); + continue; + } + } + + if(Sound[j].ptr == 0 && loadsound(j) == 0 ) continue; + if( soundm[j]&16 ) sndist = 0; + + if(sndist < ((255-LOUDESTVOLUME)<<6) ) + sndist = ((255-LOUDESTVOLUME)<<6); + + FX_Pan3D(SoundOwner[j][k].voice,sndang>>6,sndist>>6); + } +} + +void testcallback(unsigned long num) +{ + short tempi,tempj,tempk; + + if((long)num < 0) + { + if(lumplockbyte[-num] >= 200) + lumplockbyte[-num]--; + return; + } + + tempk = Sound[num].num; + + if(tempk > 0) + { + if( (soundm[num]&16) == 0) + for(tempj=0;tempj= 200) + Sound[i].lock = 199; + + for(i=0;i<11;i++) + if(lumplockbyte[i] >= 200) + lumplockbyte[i] = 199; +} + +int isspritemakingsound(short i, int num) +{ + if (num < 0) num=0; // FIXME + return issoundplaying(num) > 0; +} + +int issoundplaying(int num) +{ + return Sound[num].num; +} diff --git a/polymer/eduke32/source/sounds.h b/polymer/eduke32/source/sounds.h new file mode 100644 index 000000000..d7a26ee42 --- /dev/null +++ b/polymer/eduke32/source/sounds.h @@ -0,0 +1,55 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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 +Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +//**************************************************************************** +// +// sounds.h +// +//**************************************************************************** + +#ifndef _sounds_public_ +#define _sounds_public_ + +extern int32 FXDevice; +extern int32 MusicDevice; +extern int32 FXVolume; +extern int32 MusicVolume; +//extern fx_blaster_config BlasterConfig; +extern int32 NumVoices; +extern int32 NumChannels; +extern int32 NumBits; +extern int32 MixRate; +//extern int32 MidiPort; +extern int32 ReverseStereo; + +void SoundStartup( void ); +void SoundShutdown( void ); +void MusicStartup( void ); +void MusicShutdown( void ); +void AudioUpdate(void); + +#endif diff --git a/polymer/eduke32/source/testcd.c b/polymer/eduke32/source/testcd.c new file mode 100644 index 000000000..e4988e402 --- /dev/null +++ b/polymer/eduke32/source/testcd.c @@ -0,0 +1,75 @@ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +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. + +Replacement cd-auth routine by Jonathon Fowler. +*/ +//------------------------------------------------------------------------- + +#if (defined(RENDERTYPEWIN) || defined(WIN32)) && !defined(NOCOPYPROTECT) +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include "compat.h" +#include "baselayer.h" + +/* + * Why even bother doing this? Because I can. Because it proves the futility + * of it all. Because it's amusing. Who cares? + */ + +char testcd( char *fn, long testsiz ) +{ + DWORD driveletters; + int i, fil, dalen; + char name[32]="x:\\SUPPORT\\",driv[4]="x:\\"; + + strcat(name,fn); + + driveletters = GetLogicalDrives(); + for (i=2; i<26; i++) { + if (!(driveletters & (1ul< +#include +#include +#include + +#include "winlayer.h" + + +int Win_YesNoBox(char *name, char *fmt, ...) +{ + char buf[1000]; + va_list va; + int r; + + va_start(va,fmt); + vsprintf(buf,fmt,va); + va_end(va); + + r = MessageBox((HWND)win_gethwnd(),buf,name,MB_YESNO|MB_TASKMODAL); + if (r==IDYES) return 'y'; + return 'n'; +} + +int Win_MsgBox(char *name, char *fmt, ...) +{ + char buf[1000]; + va_list va; + + va_start(va,fmt); + vsprintf(buf,fmt,va); + va_end(va); + + MessageBox((HWND)win_gethwnd(),buf,name,MB_OK|MB_TASKMODAL); + return 'y'; +} + + +// this replaces the Error() function in jmact/util_lib.c +extern void Shutdown(void ); // game.c +void Error(char *error, ...) +{ + char buf[1000]; + va_list va; + + Shutdown(); + + if (error) { + va_start(va, error); + vsprintf(buf, error, va); + va_end(va); + + MessageBox((HWND)win_gethwnd(),buf,"Fatal Error",MB_OK|MB_TASKMODAL); + } + + exit((error != NULL)); +} + + +#endif