From 45d93544a6a169688b0c8ca6bdba3500091cd764 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 2 May 2010 23:27:30 +0000 Subject: [PATCH] Source code "cleanup," herein referred to as "rape" git-svn-id: https://svn.eduke32.com/eduke32@1625 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/MakeDistributions | 3 +- polymer/eduke32/Makefile | 5 +- polymer/eduke32/Makefile.msvc | 18 +- polymer/eduke32/build/Makefile | 10 +- polymer/eduke32/build/Makefile.deps | 14 +- polymer/eduke32/build/Makefile.msvc | 23 +- polymer/eduke32/build/include/baselayer.h | 7 +- polymer/eduke32/build/include/build.h | 3 +- polymer/eduke32/build/include/cache1d.h | 2 + polymer/eduke32/build/include/dxdidf.h | 380 +-- polymer/eduke32/build/include/m32script.h | 20 +- polymer/eduke32/build/include/malloc.c.h | 2 +- polymer/eduke32/build/include/mutex.h | 21 + polymer/eduke32/build/include/osd.h | 67 +- polymer/eduke32/build/include/polymost.h | 2 +- polymer/eduke32/build/include/rawinput.h | 26 + polymer/eduke32/build/include/scancodes.h | 123 + polymer/eduke32/build/include/winlayer.h | 4 + polymer/eduke32/build/makegnu.bat | 1 - polymer/eduke32/build/makemsc.bat | 1 - polymer/eduke32/build/makew.bat | 1 - polymer/eduke32/build/src/a.masm | 2 +- polymer/eduke32/build/src/baselayer.c | 16 +- polymer/eduke32/build/src/build.c | 118 +- polymer/eduke32/build/src/cache1d.c | 10 + polymer/eduke32/build/src/compat.c | 2 +- polymer/eduke32/build/src/engine.c | 5 +- polymer/eduke32/build/src/mdsprite.c | 2 +- polymer/eduke32/build/src/mutex.c | 35 + polymer/eduke32/build/src/nedmalloc.c | 16 +- polymer/eduke32/build/src/osd.c | 788 +++-- polymer/eduke32/build/src/polymost.c | 198 +- polymer/eduke32/build/src/rawinput.c | 265 ++ polymer/eduke32/build/src/sdlayer.c | 55 +- polymer/eduke32/build/src/winlayer.c | 832 +---- polymer/eduke32/eduke32.sln | 6 +- polymer/eduke32/eduke32.vcxproj | 263 ++ polymer/eduke32/eduke32.vcxproj.filters | 603 ++++ polymer/eduke32/eduke32.vcxproj.user | 3 + polymer/eduke32/makemsc.bat | 1 - polymer/eduke32/makew.bat | 1 - polymer/eduke32/source/actors.c | 1016 +++--- polymer/eduke32/source/astub.c | 24 +- polymer/eduke32/source/config.c | 186 +- polymer/eduke32/source/duke3d.h | 288 +- .../source/enet/include/enet/callbacks.h | 2 +- .../eduke32/source/enet/include/enet/enet.h | 14 +- polymer/eduke32/source/funct.h | 8 +- polymer/eduke32/source/game.c | 1410 ++++---- polymer/eduke32/source/gamedef.c | 131 +- polymer/eduke32/source/gamedef.h | 27 +- polymer/eduke32/source/gameexec.c | 907 +++--- polymer/eduke32/source/gamestructures.c | 262 +- polymer/eduke32/source/gamevars.c | 42 +- polymer/eduke32/source/global.c | 6 +- polymer/eduke32/source/jmact/control.c | 138 +- polymer/eduke32/source/jmact/keyboard.h | 125 +- polymer/eduke32/source/m32def.c | 74 +- polymer/eduke32/source/m32exec.c | 150 +- polymer/eduke32/source/m32structures.c | 8 +- polymer/eduke32/source/m32vars.c | 28 +- polymer/eduke32/source/macros.h | 18 +- polymer/eduke32/source/menus.c | 10 +- polymer/eduke32/source/namesdyn.c | 11 +- polymer/eduke32/source/osdcmds.c | 169 +- polymer/eduke32/source/player.c | 2900 ++++++++--------- polymer/eduke32/source/premap.c | 188 +- polymer/eduke32/source/savegame.c | 34 +- polymer/eduke32/source/sector.c | 191 +- polymer/eduke32/source/sounds.c | 80 +- polymer/eduke32/source/sounds_mapster32.c | 2 +- polymer/eduke32/source/sounds_mapster32.h | 2 +- 72 files changed, 6489 insertions(+), 5916 deletions(-) create mode 100644 polymer/eduke32/build/include/mutex.h create mode 100644 polymer/eduke32/build/include/rawinput.h create mode 100644 polymer/eduke32/build/include/scancodes.h delete mode 100644 polymer/eduke32/build/makegnu.bat delete mode 100644 polymer/eduke32/build/makemsc.bat delete mode 100644 polymer/eduke32/build/makew.bat create mode 100644 polymer/eduke32/build/src/mutex.c create mode 100644 polymer/eduke32/build/src/rawinput.c create mode 100644 polymer/eduke32/eduke32.vcxproj create mode 100644 polymer/eduke32/eduke32.vcxproj.filters create mode 100644 polymer/eduke32/eduke32.vcxproj.user delete mode 100644 polymer/eduke32/makemsc.bat delete mode 100644 polymer/eduke32/makew.bat diff --git a/polymer/eduke32/MakeDistributions b/polymer/eduke32/MakeDistributions index 2f4d24cca..a30641076 100644 --- a/polymer/eduke32/MakeDistributions +++ b/polymer/eduke32/MakeDistributions @@ -3,8 +3,7 @@ SOURCEFILES=GNU.TXT buildlic.txt \ Makefile Makefile.deps Makefile.msvc Makefile.watcom MakeDistributions \ - makemsc.bat makew.bat ChangeLog.html duke3d.def.sample \ - SEHELP.HLP STHELP.HLP ChangeLog enhance.con.sample names.h + duke3d.def.sample SEHELP.HLP STHELP.HLP enhance.con.sample names.h BINARYFILES=mapster32.exe eduke32.exe GNU.TXT buildlic.txt \ ChangeLog.html setup.exe duke3d.def.sample SEHELP.HLP STHELP.HLP \ diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index 2fc10acfc..3d1bb52fe 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -80,6 +80,9 @@ ifeq (4,$(GCC_MAJOR)) # debug += -finline-small-functions -fpredictive-commoning endif endif + ifeq (5,$(GCC_MINOR)) + debug += -flto + endif endif endif @@ -89,7 +92,7 @@ OURCFLAGS=$(debug) -W -Wall -Wimplicit -Werror-implicit-function-declaration \ -fjump-tables -fno-stack-protector # -march=pentium3 -mtune=generic -mmmx -m3dnow -msse -mfpmath=sse OURCXXFLAGS=-fno-exceptions -fno-rtti -LIBS=-lm +LIBS=-lm -ldl -pthread NASMFLAGS = -s EXESUFFIX= diff --git a/polymer/eduke32/Makefile.msvc b/polymer/eduke32/Makefile.msvc index dde77a171..59a089e3b 100644 --- a/polymer/eduke32/Makefile.msvc +++ b/polymer/eduke32/Makefile.msvc @@ -24,14 +24,12 @@ flags_cl= /Od /Zi flags_link=/DEBUG !else # release options -flags_cl=/Ox /GL /arch:SSE +flags_cl=/O2 /GL /arch:SSE /MP flags_link=/RELEASE /LTCG !endif -DXROOT="U:\SDKs\Microsoft DirectX SDK (April 2007) -MSSDKROOT="N:\Program Files\Microsoft Visual Studio 9.0\VC -PLATFORMSDK="N:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK +DXROOT="C:\Program Files\Microsoft DirectX SDK (February 2010)" ENGINEOPTS=/DSUPERBUILD /DPOLYMOST /DUSE_OPENGL /DPOLYMER @@ -40,10 +38,10 @@ AS=ml LINK=link /nologo /opt:ref MT=mt CFLAGS= /MT /J /nologo $(flags_cl) \ - /I$(INC) /I$(EINC)\msvc /I$(EINC)\ /I$(SRC)\jmact /I$(JAUDIOLIBDIR)\include /I$(ENETDIR)\include /I$(MSSDKROOT)\include" /I$(PLATFORMSDK)\include" \ + /I$(INC) /I$(EINC)\msvc /I$(EINC)\ /I$(SRC)\jmact /I$(JAUDIOLIBDIR)\include /I$(ENETDIR)\include \ /D "_CRT_SECURE_NO_DEPRECATE" /W2 $(ENGINEOPTS) \ - /I$(DXROOT)\include" /DRENDERTYPEWIN=1 -LIBS=user32.lib gdi32.lib shell32.lib dxguid.lib winmm.lib ws2_32.lib comctl32.lib \ + /I$(DXROOT)\include /DRENDERTYPEWIN=1 +LIBS=user32.lib gdi32.lib shell32.lib winmm.lib ws2_32.lib dxguid.lib comctl32.lib \ /NODEFAULTLIB:glu32.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib LIBS=vorbisfile_static.lib vorbis_static.lib ogg_static.lib dsound.lib advapi32.lib $(LIBS) @@ -128,18 +126,18 @@ EDITOROBJS=$(OBJ)\astub.$o \ $(CC) /c $(CFLAGS) /Fo$@ $< {$(SRC)\misc}.rc{$(OBJ)\}.res: - $(RC) /i$(EINC)\ /i$(SRC)\ /I$(MSSDKROOT)\include" /I$(PLATFORMSDK)\include" /DPOLYMER /fo$@ /r $< + $(RC) /i$(EINC)\ /i$(SRC)\ /DPOLYMER /fo$@ /r $< # TARGETS all: eduke32$(EXESUFFIX) mapster32$(EXESUFFIX) # duke3d_w32$(EXESUFFIX); eduke32$(EXESUFFIX): $(GAMEOBJS) $(EOBJ)\$(ENGINELIB) $(JAUDIOLIBDIR)\$(JAUDIOLIB) $(ENETDIR)\$(ENETLIB) - $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib\x86" /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) + $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib\x86 $(flags_link) /MAP $** $(LIBS) $(MT) -manifest $(RSRC)\manifest.game.xml -hashupdate -outputresource:$@ -out:$@.manifest mapster32$(EXESUFFIX): $(EDITOROBJS) $(EOBJ)\$(ENGINELIB) $(EOBJ)\$(EDITORLIB) $(JAUDIOLIBDIR)\$(JAUDIOLIB) - $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib\x86" /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) + $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib\x86 $(flags_link) /MAP $** $(LIBS) $(MT) -manifest $(RSRC)\manifest.build.xml -hashupdate -outputresource:$@ -out:$@.manifest !include Makefile.deps diff --git a/polymer/eduke32/build/Makefile b/polymer/eduke32/build/Makefile index cb8085366..f33a0e9bb 100644 --- a/polymer/eduke32/build/Makefile +++ b/polymer/eduke32/build/Makefile @@ -102,6 +102,9 @@ ifeq (4,$(GCC_MAJOR)) # debug += -finline-small-functions -fpredictive-commoning endif endif + ifeq (5,$(GCC_MINOR)) + debug += -flto + endif endif endif @@ -111,7 +114,7 @@ OURCFLAGS=$(debug) -W -Wall -Wimplicit -Werror-implicit-function-declaration \ -fjump-tables -fno-stack-protector # -march=pentium3 -mtune=generic -mmmx -m3dnow -msse -mfpmath=sse OURCXXFLAGS=-fno-exceptions -fno-rtti -LIBS=-pthread +LIBS=-pthread -ldl ASFLAGS=-s #-g EXESUFFIX= @@ -140,7 +143,8 @@ ENGINEOBJS+= \ $(OBJ)/osd.$o \ $(OBJ)/pragmas.$o \ $(OBJ)/scriptfile.$o \ - $(OBJ)/nedmalloc.$o + $(OBJ)/nedmalloc.$o \ + $(OBJ)/mutex.$o ifeq (1,$(USE_OPENGL)) ENGINEOBJS+= $(OBJ)/mdsprite.$o @@ -202,7 +206,7 @@ ifeq ($(RENDERTYPE),SDL) endif endif ifeq ($(RENDERTYPE),WIN) - ENGINEOBJS+= $(OBJ)/winlayer.$o + ENGINEOBJS+= $(OBJ)/winlayer.$o $(OBJ)/rawinput.$o EDITOROBJS+= $(OBJ)/startwin.editor.$o endif diff --git a/polymer/eduke32/build/Makefile.deps b/polymer/eduke32/build/Makefile.deps index 0bbf3991f..00f2632ce 100644 --- a/polymer/eduke32/build/Makefile.deps +++ b/polymer/eduke32/build/Makefile.deps @@ -9,12 +9,12 @@ $(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 $(INC)/compat.h $(INC)/build.h $(INC)/pragmas.h $(INC)/cache1d.h $(INC)/a.h $(INC)/osd.h $(INC)/baselayer.h $(SRC)/engine_priv.h $(INC)/polymost.h $(INC)/hightile.h $(INC)/mdsprite.h $(INC)/polymer.h -$(OBJ)/polymost.$o: $(SRC)/polymost.c $(INC)/md4.h $(INC)/quicklz.h $(INC)/lzwnew.h $(SRC)/engine_priv.h $(INC)/polymost.h $(INC)/hightile.h $(INC)/mdsprite.h -$(OBJ)/hightile.$o: $(SRC)/hightile.c $(INC)/kplib.h $(INC)/hightile.h -$(OBJ)/mdsprite.$o: $(SRC)/mdsprite.c $(SRC)/engine_priv.h $(INC)/polymost.h $(INC)/hightile.h $(INC)/mdsprite.h -$(OBJ)/textfont.$o: $(SRC)/textfont.c -$(OBJ)/smalltextfont.$o: $(SRC)/smalltextfont.c +$(OBJ)/engine.$o: $(SRC)/engine.c $(INC)/compat.h $(INC)/build.h $(INC)/pragmas.h $(INC)/cache1d.h $(INC)/a.h $(INC)/osd.h $(INC)/baselayer.h $(SRC)/engine_priv.h $(INC)/polymost.h $(INC)/hightile.h $(INC)/mdsprite.h $(INC)/polymer.h +$(OBJ)/polymost.$o: $(SRC)/polymost.c $(INC)/md4.h $(INC)/quicklz.h $(INC)/lzwnew.h $(SRC)/engine_priv.h $(INC)/polymost.h $(INC)/hightile.h $(INC)/mdsprite.h +$(OBJ)/hightile.$o: $(SRC)/hightile.c $(INC)/kplib.h $(INC)/hightile.h +$(OBJ)/mdsprite.$o: $(SRC)/mdsprite.c $(SRC)/engine_priv.h $(INC)/polymost.h $(INC)/hightile.h $(INC)/mdsprite.h +$(OBJ)/textfont.$o: $(SRC)/textfont.c +$(OBJ)/smalltextfont.$o: $(SRC)/smalltextfont.c $(OBJ)/glbuild.$o: $(SRC)/glbuild.c $(INC)/glbuild.h $(INC)/baselayer.h $(OBJ)/kplib.$o: $(SRC)/kplib.c $(INC)/compat.h $(OBJ)/quicklz.$o: $(SRC)/quicklz.c $(INC)/quicklz.h @@ -29,6 +29,8 @@ $(OBJ)/gtkbits.$o: $(SRC)/gtkbits.c $(INC)/baselayer.h $(INC)/build.h $(INC)/dyn $(OBJ)/dynamicgtk.$o: $(SRC)/dynamicgtk.c $(INC)/dynamicgtk.h $(OBJ)/polymer.$o: $(SRC)/polymer.c $(INC)/polymer.h $(INC)/compat.h $(INC)/build.h $(INC)/glbuild.h $(INC)/osd.h $(INC)/pragmas.h $(INC)/mdsprite.h $(INC)/polymost.h $(OBJ)/nedmalloc.$o: $(SRC)/nedmalloc.c $(INC)/nedmalloc.h $(INC)/malloc.c.h +$(OBJ)/mutex.$o: $(SRC)/mutex.c $(INC)/mutex.h +$(OBJ)/rawinput.$o: $(SRC)/rawinput.c $(INC)/rawinput.h $(OBJ)/buildres.$(res): $(SRC)/misc/buildres.rc $(INC)/startwin.editor.h $(OBJ)/startwin.editor.$o: $(SRC)/startwin.editor.c $(INC)/build.h $(INC)/editor.h $(INC)/winlayer.h $(INC)/compat.h $(INC)/startwin.editor.h diff --git a/polymer/eduke32/build/Makefile.msvc b/polymer/eduke32/build/Makefile.msvc index b81b4cb02..e71260ac5 100644 --- a/polymer/eduke32/build/Makefile.msvc +++ b/polymer/eduke32/build/Makefile.msvc @@ -19,9 +19,6 @@ asm=masm ENGINELIB=engine.lib EDITORLIB=build.lib -DXROOT="U:\SDKs\Microsoft DirectX SDK (April 2007) -MSSDKROOT="N:\Program Files\Microsoft Visual Studio 9.0\VC -PLATFORMSDK="N:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK # ENETROOT=$(SRC)\enet # /D these to enable certain features of the port's compile process @@ -37,7 +34,7 @@ flags_link=/DEBUG flags_lib= !else # release options -flags_cl=/Ox /GL /arch:SSE +flags_cl=/O2 /GL /arch:SSE /MP flags_link=/RELEASE /LTCG flags_lib=/LTCG !endif @@ -46,7 +43,7 @@ CC=cl AS=ml RC=rc LINK=link /opt:ref /nologo -CFLAGS=$(CFLAGS) /nologo /MT /J $(flags_cl) $(TARGETOPTS) /I$(INC) /I$(MSSDKROOT)\include" /I$(PLATFORMSDK)\include" /I$(DXROOT)\include" # /I$(ENETROOT)\include" +CFLAGS=$(CFLAGS) /nologo /MT /J $(flags_cl) $(TARGETOPTS) /I$(INC) # /I$(ENETROOT)\include" ASFLAGS=/nologo /coff /c EXESUFFIX=.exe !ifdef DEBUG @@ -80,14 +77,16 @@ ENGINEOBJS= \ $(OBJ)\scriptfile.$o \ $(OBJ)\winlayer.$o \ $(OBJ)\polymer.$o \ - $(OBJ)\nedmalloc.$o + $(OBJ)\nedmalloc.$o \ + $(OBJ)\mutex.$o \ + $(OBJ)\rawinput.$o EDITOROBJS=$(OBJ)\build.$o \ $(OBJ)\startwin.editor.$o \ $(OBJ)\config.$o RENDERTYPE=WIN -LIBS=$(LIBS) user32.lib gdi32.lib shell32.lib dxguid.lib wsock32.lib comctl32.lib +LIBS=$(LIBS) user32.lib gdi32.lib shell32.lib wsock32.lib comctl32.lib dxguid.lib CFLAGS=$(CFLAGS) /DRENDERTYPE$(RENDERTYPE)=1 /D "_CRT_SECURE_NO_DEPRECATE" /W2 # RULES @@ -127,23 +126,23 @@ $(OBJ)\$(EDITORLIB): $(EDITOROBJS) # the tools kextract$(EXESUFFIX): $(OBJ)\kextract.$o $(OBJ)\compat.$o $(OBJ)\nedmalloc.$o - $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE /LIBPATH:$(DXROOT)\lib\x86" /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS) $(MT) -manifest $@.manifest -outputresource:$@ kgroup$(EXESUFFIX): $(OBJ)\kgroup.$o $(OBJ)\compat.$o $(OBJ)\nedmalloc.$o - $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE /LIBPATH:$(DXROOT)\lib\x86" /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS) $(MT) -manifest $@.manifest -outputresource:$@ transpal$(EXESUFFIX): $(OBJ)\transpal.$o $(OBJ)\pragmas.$o $(OBJ)\compat.$o $(OBJ)\nedmalloc.$o - $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE /LIBPATH:$(DXROOT)\lib\x86" /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS) $(MT) -manifest $@.manifest -outputresource:$@ wad2map$(EXESUFFIX): $(OBJ)\wad2map.$o $(OBJ)\pragmas.$o $(OBJ)\compat.$o $(OBJ)\nedmalloc.$o - $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE /LIBPATH:$(DXROOT)\lib\x86" /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS) $(MT) -manifest $@.manifest -outputresource:$@ wad2art$(EXESUFFIX): $(OBJ)\wad2art.$o $(OBJ)\pragmas.$o $(OBJ)\compat.$o $(OBJ)\nedmalloc.$o - $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE /LIBPATH:$(DXROOT)\lib\x86" /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS) $(MT) -manifest $@.manifest -outputresource:$@ # DEPENDENCIES diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index e9526c842..5176b1ae3 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -38,7 +38,7 @@ extern void (*baselayer_onvideomodechange)(int32_t); #ifdef USE_OPENGL extern int32_t osdcmd_glinfo(const osdfuncparm_t *parm); -struct glinfo { +struct glinfo_t { const char *vendor; const char *renderer; const char *version; @@ -66,7 +66,7 @@ struct glinfo { char dumped; }; -extern struct glinfo glinfo; +extern struct glinfo_t glinfo; extern void setvsync(int32_t sync); #endif @@ -113,7 +113,8 @@ const char *getjoyname(int32_t what, int32_t num); // what: 0=axis, 1=button, 2= char *strtolower(char *str, int32_t len); char bgetchar(void); -int32_t bkbhit(void); +#define bkbhit() (keyasciififoplc != keyasciififoend) + void bflushchars(void); int32_t initmouse(void); diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index ea78332cc..f2746638d 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -158,8 +158,7 @@ typedef struct typedef struct { uint32_t mdanimtims; int16_t mdanimcur; - int16_t angoff; - int16_t pitch, roll; + int16_t angoff, pitch, roll; int32_t xoff, yoff, zoff; uint8_t flags; uint8_t xpanning, ypanning; diff --git a/polymer/eduke32/build/include/cache1d.h b/polymer/eduke32/build/include/cache1d.h index 59485ddf9..02b56f9fe 100644 --- a/polymer/eduke32/build/include/cache1d.h +++ b/polymer/eduke32/build/include/cache1d.h @@ -4,6 +4,7 @@ #define __cache1d_h__ #include "compat.h" +#include "mutex.h" #ifdef __cplusplus extern "C" { @@ -19,6 +20,7 @@ void allocache(intptr_t *newhandle, int32_t newbytes, char *newlockptr); void suckcache(intptr_t *suckptr); void agecache(void); +mutex_t cachemutex; extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode) int32_t addsearchpath(const char *p); int32_t findfrompath(const char *fn, char **where); diff --git a/polymer/eduke32/build/include/dxdidf.h b/polymer/eduke32/build/include/dxdidf.h index 7c54e4646..be29e6218 100644 --- a/polymer/eduke32/build/include/dxdidf.h +++ b/polymer/eduke32/build/include/dxdidf.h @@ -1,345 +1,53 @@ #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 }; -*/ -static DIOBJECTDATAFORMAT c_dfDIMouse2_odf[] = { - {&GUID_XAxis, 0, 16776963, 0}, - {&GUID_YAxis, 4, 16776963, 0}, - {&GUID_ZAxis, 8, -2130706685, 0}, - {0, 12, 16776972, 0}, - {0, 13, 16776972, 0}, - {0, 14, -2130706676, 0}, - {0, 15, -2130706676, 0}, - {0, 16, -2130706676, 0}, - {0, 17, -2130706676, 0}, - {0, 18, -2130706676,0}, - {0, 19, -2130706676, 0} -}; -const DIDATAFORMAT c_dfDIMouse2 = {24, 16, 2, 20, 11, c_dfDIMouse2_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 } + { &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 }; diff --git a/polymer/eduke32/build/include/m32script.h b/polymer/eduke32/build/include/m32script.h index e2ba1abc8..9b2e5fa72 100644 --- a/polymer/eduke32/build/include/m32script.h +++ b/polymer/eduke32/build/include/m32script.h @@ -46,11 +46,11 @@ extern int32_t g_numQuoteRedefinitions; //extern int16_t neartagsector, neartagwall, neartagsprite; //extern int32_t neartaghitdist; -extern int32_t X_DoExecute(int32_t once); -extern void X_OnEvent(register int32_t iEventID, register int32_t iActor); +extern int32_t VM_Execute(int32_t once); +extern void VM_OnEvent(register int32_t iEventID, register int32_t iActor); -extern void X_ScriptInfo(void); -extern void X_Disasm(ofstype beg, int32_t size); +extern void VM_ScriptInfo(void); +extern void VM_Disasm(ofstype beg, int32_t size); extern void C_ReportError(int32_t iError); extern int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags); @@ -77,12 +77,12 @@ extern int32_t g_scriptSize; extern char *label; //extern int32_t label_allocsize; -extern hashtable_t labelH; +extern hashtable_t h_labels; #define MAXLABELLEN 32 //extern uint8_t waterpal[768],slimepal[768],titlepal[768],drealms[768],endingpal[768],animpal[768]; -//extern char currentboardfilename[BMAX_PATH]; +//extern char currentboardfilename[BMAVM_PATH]; enum GameEvent_t { @@ -180,10 +180,10 @@ extern int32_t g_iThisActorID; // var ID of "I" ///"THISACTOR" extern int32_t g_numQuoteRedefinitions; -extern hashtable_t gamevarH; -extern hashtable_t arrayH; -extern hashtable_t keywH; -extern hashtable_t gamefuncH; +extern hashtable_t h_gamevars; +extern hashtable_t h_arrays; +extern hashtable_t h_keywords; +extern hashtable_t h_gamefuncs; extern int16_t asksave; diff --git a/polymer/eduke32/build/include/malloc.c.h b/polymer/eduke32/build/include/malloc.c.h index 29455bd0c..4a1bb7adb 100644 --- a/polymer/eduke32/build/include/malloc.c.h +++ b/polymer/eduke32/build/include/malloc.c.h @@ -1937,7 +1937,7 @@ struct win32_mlock_t { #define TRY_LOCK(sl) win32_try_lock(sl) #define SPINS_PER_YIELD 63 -static MLOCK_T malloc_global_mutex = { 0, 0, 0}; +static MLOCK_T malloc_global_mutex = { 0, "", 0, 0}; static FORCEINLINE int win32_acquire_lock (MLOCK_T *sl) { int spins = 0; diff --git a/polymer/eduke32/build/include/mutex.h b/polymer/eduke32/build/include/mutex.h new file mode 100644 index 000000000..2d4b1bf58 --- /dev/null +++ b/polymer/eduke32/build/include/mutex.h @@ -0,0 +1,21 @@ +#ifndef __mutex_h__ +#define __mutex_h__ + +#if defined(_WIN32) +#include +#include +#else +#include +#endif + +#if defined(_WIN32) +typedef HANDLE mutex_t; +#else +typedef pthread_mutex_t mutex_t; +#endif + +extern int32_t mutex_init(mutex_t *mutex); +extern int32_t mutex_lock(mutex_t *mutex); +extern int32_t mutex_unlock(mutex_t *mutex); + +#endif \ No newline at end of file diff --git a/polymer/eduke32/build/include/osd.h b/polymer/eduke32/build/include/osd.h index 6fe5a63ef..399561d2c 100644 --- a/polymer/eduke32/build/include/osd.h +++ b/polymer/eduke32/build/include/osd.h @@ -24,20 +24,20 @@ typedef struct _symbol symbol_t *symbols; -const char *stripcolorcodes(char *out, const char *in); +const char *OSD_StripColors(char *out, const char *in); -enum cvartypes +enum cvartype_t { - CVAR_FLOAT = 1, - CVAR_INT = 2, - CVAR_UINT = 4, - CVAR_BOOL = 8, - CVAR_STRING = 16, - CVAR_DOUBLE = 32, - CVAR_NOMULTI = 128, - CVAR_MULTI = 256, - CVAR_NOSAVE = 512, - CVAR_FUNCPTR = 1024, + CVAR_FLOAT = 0x00000001, + CVAR_INT = 0x00000002, + CVAR_UINT = 0x00000004, + CVAR_BOOL = 0x00000008, + CVAR_STRING = 0x00000010, + CVAR_DOUBLE = 0x00000020, + CVAR_NOMULTI = 0x00000040, + CVAR_MULTI = 0x00000080, + CVAR_NOSAVE = 0x00000100, + CVAR_FUNCPTR = 0x00000200, }; typedef struct @@ -45,15 +45,24 @@ typedef struct char *name; char *helpstr; void *var; - int32_t type; // 0 = integer, 1 = unsigned integer, 2 = boolean, 3 = string, |128 = not in multiplayer, |256 = update multi - int32_t extra; // for string, is the length + int32_t type; // see cvartype_t int32_t min; - int32_t max; + int32_t max; // for string, is the length } cvar_t; +enum osdflags_t +{ + OSD_INITIALIZED = 0x00000001, + OSD_DRAW = 0x00000002, + OSD_CAPTURE = 0x00000004, + OSD_OVERTYPE = 0x00000008, + OSD_SHIFT = 0x00000010, + OSD_CTRL = 0x00000020, + OSD_CAPS = 0x00000040 +}; -#define OSD_ALIAS 1337 -#define OSD_UNALIASED 1338 +#define OSD_ALIAS (void *)0x1337 +#define OSD_UNALIASED (void *)0xDEAD #define OSDCMD_OK 0 #define OSDCMD_SHOWHELP 1 @@ -112,7 +121,7 @@ void OSD_ResizeDisplay(int32_t w,int32_t h); void OSD_CaptureInput(int32_t cap); // sets the console version string -void OSD_SetVersionString(const char *version, int32_t shade, int32_t pal); +void OSD_SetVersion(const char *version, int32_t shade, int32_t pal); // shows or hides the onscreen display void OSD_ShowDisplay(int32_t onf); @@ -143,19 +152,19 @@ void OSD_WriteCvars(FILE *fp); // these correspond to the Duke palettes, so they shouldn't really be here // ...but I don't care -#define OSDTEXT_BLUE "^00" -#define OSDTEXT_GOLD "^07" -#define OSDTEXT_DARKRED "^10" -#define OSDTEXT_GREEN "^11" -#define OSDTEXT_GRAY "^12" -#define OSDTEXT_DARKGRAY "^13" +#define OSDTEXT_BLUE "^00" +#define OSDTEXT_GOLD "^07" +#define OSDTEXT_DARKRED "^10" +#define OSDTEXT_GREEN "^11" +#define OSDTEXT_GRAY "^12" +#define OSDTEXT_DARKGRAY "^13" #define OSDTEXT_DARKGREEN "^14" -#define OSDTEXT_BROWN "^15" -#define OSDTEXT_DARKBLUE "^16" -#define OSDTEXT_RED "^21" -#define OSDTEXT_YELLOW "^23" +#define OSDTEXT_BROWN "^15" +#define OSDTEXT_DARKBLUE "^16" +#define OSDTEXT_RED "^21" +#define OSDTEXT_YELLOW "^23" -#define OSDTEXT_BRIGHT "^S0" +#define OSDTEXT_BRIGHT "^S0" #define OSD_ERROR OSDTEXT_DARKRED OSDTEXT_BRIGHT #define TEXTSIZE 32768 diff --git a/polymer/eduke32/build/include/polymost.h b/polymer/eduke32/build/include/polymost.h index 66633a0de..2aad8bfb7 100644 --- a/polymer/eduke32/build/include/polymost.h +++ b/polymer/eduke32/build/include/polymost.h @@ -67,7 +67,7 @@ extern GLuint peelprogram[2]; extern int32_t cachefilehandle; extern FILE *cacheindexptr; -extern hashtable_t cacheH; +extern hashtable_t h_texcache; struct cacheitem_t { diff --git a/polymer/eduke32/build/include/rawinput.h b/polymer/eduke32/build/include/rawinput.h new file mode 100644 index 000000000..aa25d2dea --- /dev/null +++ b/polymer/eduke32/build/include/rawinput.h @@ -0,0 +1,26 @@ +#ifndef rawinput_h__ +#define rawinput_h__ + +#include "compat.h" + +void RI_PollDevices(); + +uint8_t RI_MouseState( uint8_t Button ); + +int8_t RI_WheelState(); + +int32_t RI_CaptureInput(int32_t grab, HWND target); + +#define VK_LBUTTON 0x01 +#define VK_RBUTTON 0x02 +#define VK_CANCEL 0x03 +#define VK_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */ + +// mouse states for RI_MouseState + +#define BUTTON_PRESSED 0x01 +#define BUTTON_RELEASED 0x02 +#define BUTTON_HELD 0x03 + +#endif // rawinput_h__ + diff --git a/polymer/eduke32/build/include/scancodes.h b/polymer/eduke32/build/include/scancodes.h new file mode 100644 index 000000000..28760d96b --- /dev/null +++ b/polymer/eduke32/build/include/scancodes.h @@ -0,0 +1,123 @@ + +#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 + diff --git a/polymer/eduke32/build/include/winlayer.h b/polymer/eduke32/build/include/winlayer.h index a93610fff..ac2352ede 100644 --- a/polymer/eduke32/build/include/winlayer.h +++ b/polymer/eduke32/build/include/winlayer.h @@ -16,6 +16,10 @@ int32_t win_gethinstance(void); void win_allowtaskswitching(int32_t onf); int32_t win_checkinstance(void); +extern void (*keypresscallback)(int32_t,int32_t); +extern void (*mousepresscallback)(int32_t,int32_t); +extern void (*joypresscallback)(int32_t,int32_t); + #include "baselayer.h" #else diff --git a/polymer/eduke32/build/makegnu.bat b/polymer/eduke32/build/makegnu.bat deleted file mode 100644 index 027d85aa6..000000000 --- a/polymer/eduke32/build/makegnu.bat +++ /dev/null @@ -1 +0,0 @@ -make -f Makefile %1 %2 %3 %4 %5 diff --git a/polymer/eduke32/build/makemsc.bat b/polymer/eduke32/build/makemsc.bat deleted file mode 100644 index 19243ed20..000000000 --- a/polymer/eduke32/build/makemsc.bat +++ /dev/null @@ -1 +0,0 @@ -nmake /f Makefile.msvc %1 %2 %3 %4 %5 diff --git a/polymer/eduke32/build/makew.bat b/polymer/eduke32/build/makew.bat deleted file mode 100644 index 7184b0f08..000000000 --- a/polymer/eduke32/build/makew.bat +++ /dev/null @@ -1 +0,0 @@ -wmake -f Makefile.watcom %1 %2 %3 %4 %5 diff --git a/polymer/eduke32/build/src/a.masm b/polymer/eduke32/build/src/a.masm index 97daee539..d2fdfbda7 100644 --- a/polymer/eduke32/build/src/a.masm +++ b/polymer/eduke32/build/src/a.masm @@ -3,7 +3,7 @@ ; See the included license file "BUILDLIC.TXT" for license info. .586P -.8087 +;.8087 ;include mmx.inc ;Include this if using < WATCOM 11.0 WASM ;Warning: IN THIS FILE, ALL SEGMENTS ARE REMOVED. THIS MEANS THAT DS:[] diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index 25047f2e5..4b62233d2 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -22,7 +22,7 @@ char scantoasc[128] = }; #ifdef USE_OPENGL -struct glinfo glinfo = +struct glinfo_t glinfo = { "Unknown", // vendor "Unknown", // renderer @@ -230,17 +230,19 @@ int32_t baselayer_init(void) cvar_t cvars_engine[] = { #ifdef SUPERBUILD - { "r_novoxmips","r_novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",(void *)&novoxmips, CVAR_BOOL, 0, 0, 1 }, - { "r_voxels","r_voxels: enable/disable automatic sprite->voxel rendering",(void *)&usevoxels, CVAR_BOOL, 0, 0, 1 }, - { "r_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_novoxmips","r_novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",(void *)&novoxmips, CVAR_BOOL, 0, 1 }, + { "r_voxels","r_voxels: enable/disable automatic sprite->voxel rendering",(void *)&usevoxels, CVAR_BOOL, 0, 1 }, + { "r_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars, CVAR_FUNCPTR, 0, 0 }, #endif }; for (i=0; i>1) == 0) { + if ((keystatus[buildkeys[BK_MOVEUP]] || (bstatus&(16|32)) || keystatus[buildkeys[BK_MOVEDOWN]]) == 0) + idle_waitevent(); + if (handleevents()) { if (quitevent) @@ -1297,11 +1300,10 @@ void overheadeditor(void) } } - idle(); OSD_DispatchQueued(); if (totalclock < 120*3) - printmessage16("Based on BUILD by Ken Silverman."); + printmessage16("Uses BUILD technology by Ken Silverman."); else if (totalclock < 120*6) { printmessage16("Press F1 for help. This is a test release; always keep backups of your maps."); @@ -1319,6 +1321,7 @@ void overheadeditor(void) } searchx += mousx; searchy += mousy; + if (searchx < 8) searchx = 8; if (searchx > xdim-8-1) searchx = xdim-8-1; if (searchy < 8) searchy = 8; @@ -1422,7 +1425,7 @@ void overheadeditor(void) } draw2dscreen(pos.x,pos.y,ang,zoom,grid); - X_OnEvent(EVENT_DRAW2DSCREEN, -1); + VM_OnEvent(EVENT_DRAW2DSCREEN, -1); begindrawing(); //{{{ if (showtags == 1) @@ -1620,7 +1623,7 @@ void overheadeditor(void) OSD_Draw(); } - X_OnEvent(EVENT_PREKEYS2D, -1); + VM_OnEvent(EVENT_PREKEYS2D, -1); 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 @@ -2864,7 +2867,7 @@ SKIP: if ((keystatus[buildkeys[BK_MOVEUP]] || (bstatus&16)) && (zoom < 65536)) { - zoom += synctics*(zoom>>4); + zoom += (synctics>>1)*(zoom>>3); if (zoom < 24) zoom += 2; if (bstatus&16 && (keystatus[0x38] || keystatus[0xb8])) { @@ -2878,7 +2881,7 @@ SKIP: } if ((keystatus[buildkeys[BK_MOVEDOWN]] || (bstatus&32)) && (zoom > 8)) { - zoom -= synctics*(zoom>>4); + zoom -= (synctics>>1)*(zoom>>3); if (bstatus&32 && (keystatus[0x38] || keystatus[0xb8])) { searchx = halfxdim16; @@ -3193,7 +3196,7 @@ SKIP: updatenumsprites(); asksave = 1; - X_OnEvent(EVENT_INSERTSPRITE2D, i); + VM_OnEvent(EVENT_INSERTSPRITE2D, i); } keystatus[0x1f] = 0; @@ -4747,7 +4750,7 @@ CANCEL: clearkeys(); } - X_OnEvent(EVENT_KEYS2D, -1); + VM_OnEvent(EVENT_KEYS2D, -1); //nextpage(); } @@ -4783,7 +4786,7 @@ CANCEL: searchx = scale(searchx,xdimgame,xdim2d); searchy = scale(searchy,ydimgame,ydim2d-STATUS2DSIZ); - X_OnEvent(EVENT_ENTER3DMODE, -1); + VM_OnEvent(EVENT_ENTER3DMODE, -1); } void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y) @@ -6142,27 +6145,15 @@ void showsectordata(int16_t sectnum) int32_t mode = (sectnum & 16384); int32_t color = mode?whitecol:editorcolors[11]; - if (mode) - { - int32_t i; - - row = 2; - begindrawing(); - col = whitecol - 21; - for (i=ydim-(row*96)-STATUS2DSIZ+16; i 0) col--; - } - enddrawing(); - col = 1; - } sectnum &= ~16384; - Bsprintf(snotbuf,"^10Sector %d",sectnum); if (mode) - Bstrcat(snotbuf," ^O(F7 to edit)"); + { + _printmessage16("^10Sector %d ^O(F7 to edit)",sectnum); + return; + } + + Bsprintf(snotbuf,"^10Sector %d",sectnum); printext16(8,ydim-(row*96)-STATUS2DSIZ+32,color,-1,snotbuf,0); Bsprintf(snotbuf,"Firstwall: %d",sector[sectnum].wallptr); printext16(8,ydim-(row*96)-STATUS2DSIZ+48,color,-1,snotbuf,0); @@ -6181,9 +6172,7 @@ void showsectordata(int16_t sectnum) Bsprintf(snotbuf,"Pixel height: %d",(sector[sectnum].floorz-sector[sectnum].ceilingz)>>8); printext16(8,ydim-(row*96)-STATUS2DSIZ+104,color,-1,snotbuf,0); - if (mode) - row--; - else col++; + col++; printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+32,color,-1,"^10CEILING:^O",0); Bsprintf(snotbuf,"Flags (hex): %x",sector[sectnum].ceilingstat); @@ -6201,9 +6190,7 @@ void showsectordata(int16_t sectnum) Bsprintf(snotbuf,"Palookup number: %d",sector[sectnum].ceilingpal); printext16(8+((col-1)*200),ydim-(row*96)-STATUS2DSIZ+96,color,-1,snotbuf,0); - if (mode) - row--; - else col++; + col++; printext16(8+((col-1)*200),ydim-STATUS2DSIZ+32,color,-1,"^10FLOOR:^O",0); Bsprintf(snotbuf,"Flags (hex): %x",sector[sectnum].floorstat); @@ -6230,27 +6217,15 @@ void showwalldata(int16_t wallnum) int32_t mode = (wallnum & 16384); int32_t color = mode?whitecol:editorcolors[11]; - if (mode) - { - int32_t i; - - row = 2; - begindrawing(); - col = whitecol - 21; - for (i=ydim-(row*80)-STATUS2DSIZ+16; i 0) col--; - } - enddrawing(); - col = 1; - } - wallnum &= ~16384; + if (mode) + { + _printmessage16("^10Wall %d ^O(F8 to edit)",wallnum); + return; + } + Bsprintf(snotbuf,"^10Wall %d",wallnum); - if (mode) Bstrcat(snotbuf," ^O(F8 to edit)"); printext16(8,ydim-(row*80)-STATUS2DSIZ+32,color,-1,snotbuf,0); Bsprintf(snotbuf,"X-coordinate: %d",wall[wallnum].x); printext16(8,ydim-(row*80)-STATUS2DSIZ+48,color,-1,snotbuf,0); @@ -6266,9 +6241,7 @@ void showwalldata(int16_t wallnum) Bsprintf(snotbuf," (0x%x), (0x%x)",wall[wallnum].hitag,wall[wallnum].lotag); printext16(8,ydim-(row*80)-STATUS2DSIZ+96,color,-1,snotbuf,0); - if (mode) - row--; - else col++; + col++; Bsprintf(snotbuf,"^10%s^O",names[wall[wallnum].picnum]); printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+32,color,-1,snotbuf,0); @@ -6287,9 +6260,7 @@ void showwalldata(int16_t wallnum) Bsprintf(snotbuf,"OverTile number: %d",wall[wallnum].overpicnum); printext16(8+((col-1)*200),ydim-(row*80)-STATUS2DSIZ+96,color,-1,snotbuf,0); - if (mode) - row--; - else col++; + col++; Bsprintf(snotbuf,"nextsector: %d",wall[wallnum].nextsector); printext16(8+((col-1)*200),ydim-STATUS2DSIZ+48-(mode?16:0),color,-1,snotbuf,0); @@ -6320,26 +6291,15 @@ void showspritedata(int16_t spritenum) int32_t mode = (spritenum & 16384); int32_t color = mode?whitecol:editorcolors[11]; - if (mode) - { - int32_t i; - - row = 2; - begindrawing(); - col = whitecol - 21; - for (i=ydim-(row*80)-STATUS2DSIZ+16; i 0) col--; - } - enddrawing(); - col = 1; - } spritenum &= ~16384; + if (mode) + { + _printmessage16("^10Sprite %d ^O(F8 to edit)",spritenum); + return; + } + Bsprintf(snotbuf,"^10Sprite %d",spritenum); - if (mode) Bstrcat(snotbuf," ^O(F8 to edit)"); printext16(8,ydim-(row*80)-STATUS2DSIZ+32,color,-1,snotbuf,0); Bsprintf(snotbuf,"X-coordinate: %d",sprite[spritenum].x); printext16(8,ydim-(row*80)-STATUS2DSIZ+48,color,-1,snotbuf,0); @@ -6358,9 +6318,7 @@ void showspritedata(int16_t spritenum) Bsprintf(snotbuf," (0x%x), (0x%x)",sprite[spritenum].hitag,sprite[spritenum].lotag); printext16(8,ydim-(row*80)-STATUS2DSIZ+104,color,-1,snotbuf,0); - if (mode) - row--; - else col++; + col++; Bsprintf(snotbuf,"^10%s^O",names[sprite[spritenum].picnum]); printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+32,color,-1,snotbuf,0); @@ -6377,9 +6335,7 @@ void showspritedata(int16_t spritenum) Bsprintf(snotbuf,"Tile number: %d",sprite[spritenum].picnum); printext16(8+((col-1)*200),ydim-(row*72)-STATUS2DSIZ+88,color,-1,snotbuf,0); - if (mode) - row--; - else col++; + col++; Bsprintf(snotbuf,"Angle (2048 degrees): %d",sprite[spritenum].ang); printext16(8+((col-1)*200),ydim-STATUS2DSIZ+48,color,-1,snotbuf,0); diff --git a/polymer/eduke32/build/src/cache1d.c b/polymer/eduke32/build/src/cache1d.c index 62d55038c..7cc5f4cf1 100644 --- a/polymer/eduke32/build/src/cache1d.c +++ b/polymer/eduke32/build/src/cache1d.c @@ -9,6 +9,7 @@ #include "cache1d.h" #include "pragmas.h" #include "baselayer.h" +#include "mutex.h" #ifdef WITHKPLIB #include "kplib.h" @@ -59,6 +60,7 @@ static intptr_t kzipopen(char *filnam) #define MAXCACHEOBJECTS 9216 +mutex_t cachemutex; static int32_t cachesize = 0; int32_t cachecount = 0; char zerochar = 0; @@ -99,6 +101,7 @@ void initcache(intptr_t dacachestart, int32_t dacachesize) cac[0].lock = &zerochar; cacnum = 1; + mutex_init(&cachemutex); initprintf("Initialized %.1fM cache\n", (float)(dacachesize/1024.f/1024.f)); } @@ -186,8 +189,10 @@ void suckcache(intptr_t *suckptr) { int32_t i; + while(mutex_lock(&cachemutex)); //Can't exit early, because invalid pointer might be same even though lock = 0 for (i=0; i= cacnum) agecount = cacnum-1; if (agecount < 0 || !cnt) return; + while(mutex_lock(&cachemutex)); for (; cnt>=0; cnt--) { if ((((*cac[agecount].lock)-2)&255) < 198) @@ -222,6 +231,7 @@ void agecache(void) agecount--; if (agecount < 0) agecount = cacnum-1; } + mutex_unlock(&cachemutex); } static void reportandexit(char *errormessage) diff --git a/polymer/eduke32/build/src/compat.c b/polymer/eduke32/build/src/compat.c index 044cbbff8..3deccdf76 100644 --- a/polymer/eduke32/build/src/compat.c +++ b/polymer/eduke32/build/src/compat.c @@ -15,7 +15,7 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #define _WIN32_IE 0x0400 -#define _WIN32_WINNT 0x0500 +#define _WIN32_WINNT 0x0501 #include #include #include diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 0643dfbff..059220d4b 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -7805,7 +7805,7 @@ void nextpage(void) per->dashade,per->dapalnum,per->dastat, per->cx1,per->cy1,per->cx2,per->cy2,per->uniqid); } - enddrawing(); //}}} + enddrawing(); //}}} OSD_Draw(); showframe(0); @@ -10039,7 +10039,7 @@ void setbrightness(char dabrightness, uint8_t *dapal, char noapply) // void setpalettefade(char r, char g, char b, char offset) { - int32_t i,k; + int32_t i; palette_t p; palfadergb.r = min(63,r) << 2; @@ -10047,7 +10047,6 @@ void setpalettefade(char r, char g, char b, char offset) palfadergb.b = min(63,b) << 2; palfadedelta = min(63,offset) << 2; - k = 0; for (i=0; i<256; i++) { if (gammabrightness) p = curpalette[i]; diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 7c7f701a2..c8b2c31eb 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -550,7 +550,7 @@ int32_t mdloadskin_trytexcache(char *fn, int32_t len, int32_t pal, char effect, } while (cacheindexptr->next); */ - i = hash_find(&cacheH,cachefn); + i = hash_find(&h_texcache,cachefn); if (i != -1) { texcacheindex *cacheindexptr = cacheptrs[i]; diff --git a/polymer/eduke32/build/src/mutex.c b/polymer/eduke32/build/src/mutex.c new file mode 100644 index 000000000..6f7c78c3c --- /dev/null +++ b/polymer/eduke32/build/src/mutex.c @@ -0,0 +1,35 @@ +#include "compat.h" +#include "mutex.h" + +int32_t mutex_init(mutex_t *mutex) +{ +#ifdef _WIN32 + *mutex = CreateMutex(0, FALSE, 0); + return (*mutex == 0); +#else + return pthread_mutex_init(mutex, NULL); +#endif + return -1; +} + +int32_t mutex_lock(mutex_t *mutex) +{ +#ifdef _WIN32 + return (WaitForSingleObject(*mutex, INFINITE) == WAIT_FAILED); +#else + return pthread_mutex_lock(mutex); +#endif + return -1; +} + +int32_t mutex_unlock(mutex_t *mutex) +{ +#ifdef _WIN32 + return (ReleaseMutex(*mutex) == 0); +#else + return pthread_mutex_unlock(mutex); +#endif + return -1; +} + + diff --git a/polymer/eduke32/build/src/nedmalloc.c b/polymer/eduke32/build/src/nedmalloc.c index 73be86dbe..62284b038 100644 --- a/polymer/eduke32/build/src/nedmalloc.c +++ b/polymer/eduke32/build/src/nedmalloc.c @@ -44,7 +44,7 @@ DEALINGS IN THE SOFTWARE. #define ENABLE_FAST_HEAP_DETECTION 1 #define NDEBUG 1 #define THREADCACHEMAX 32768 -#define THREADCACHEMAXBINS ((15-4)*2) +#define THREADCACHEMAXBINS ((15-4)*2) /*#define ENABLE_TOLERANT_NEDMALLOC 1*/ /*#define ENABLE_FAST_HEAP_DETECTION 1*/ /*#define NEDMALLOC_DEBUG 1*/ @@ -450,9 +450,13 @@ static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC } #else #ifdef WIN32 - __try +#ifdef _MSC_VER + __try +#elif defined(__MINGW32__) + __try1 #endif - { +#endif + { /* We try to return zero here if it isn't one of our own blocks, however the current block annotation scheme used by dlmalloc makes it impossible to be absolutely sure of avoiding a segfault. @@ -493,7 +497,11 @@ static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC } } #ifdef WIN32 - __except(1) { } +#ifdef _MSC_VER + __except(1) { } +#elif defined(__MINGW32__) + __except1(1) { } +#endif #endif #endif #endif diff --git a/polymer/eduke32/build/src/osd.c b/polymer/eduke32/build/src/osd.c index 6c0deaa9c..6eeae3e58 100644 --- a/polymer/eduke32/build/src/osd.c +++ b/polymer/eduke32/build/src/osd.c @@ -8,6 +8,7 @@ #include "baselayer.h" #include "cache1d.h" #include "pragmas.h" +#include "scancodes.h" symbol_t *symbols = NULL; static symbol_t *addnewsymbol(const char *name); @@ -32,13 +33,15 @@ static void _internal_clearbackground(int32_t,int32_t); static int32_t _internal_gettime(void); static void _internal_onshowosd(int32_t); +static uint32_t osdflags = 0; + // history display static char osdtext[TEXTSIZE]; static char osdfmt[TEXTSIZE]; -static char osdversionstring[32]; -static int32_t osdversionstringlen; -static int32_t osdversionstringshade; -static int32_t osdversionstringpal; +static char osdver[32]; +static int32_t osdverlen; +static int32_t osdvershade; +static int32_t osdverpal; static int32_t osdpos=0; // position next character will be written at static int32_t osdlines=1; // # lines of text in the buffer static int32_t osdrows=20; // # lines of the buffer that are visible @@ -47,25 +50,18 @@ static int32_t osdscroll=0; static int32_t osdcols=60; // width of onscreen display in text columns static int32_t osdmaxrows=20; // maximum number of lines which can fit on the screen static int32_t osdmaxlines=TEXTSIZE/60; // maximum lines which can fit in the buffer -static char osdvisible=0; // onscreen display visible? -static char osdinput=0; // capture input? static int32_t osdhead=0; // topmost visible line number static BFILE *osdlog=NULL; // log filehandle -static char osdinited=0; // text buffer initialized? -static int32_t osdkey=0x29; // tilde shows the osd +static int32_t osdkey=sc_Tilde; static int32_t keytime=0; static int32_t osdscrtime = 0; // command prompt editing #define EDITLENGTH 511 -static int32_t osdovertype=0; // insert (0) or overtype (1) static char osdeditbuf[EDITLENGTH+1]; // editing buffer static char osdedittmp[EDITLENGTH+1]; // editing buffer temporary workspace static int32_t osdeditlen=0; // length of characters in edit buffer static int32_t osdeditcursor=0; // position of cursor in edit buffer -static int32_t osdeditshift=0; // shift state -static int32_t osdeditcontrol=0; // control state -static int32_t osdeditcaps=0; // capslock static int32_t osdeditwinstart=0; static int32_t osdeditwinend=60-1-3; #define editlinewidth (osdcols-1-3) @@ -105,7 +101,7 @@ static int32_t osdcursorpal=0; */ static symbol_t *osdsymbptrs[MAXSYMBOLS]; static int32_t osdnumsymbols = 0; -static hashtable_t osdsymbolsH = { MAXSYMBOLS<<1, NULL }; +static hashtable_t h_osd = { MAXSYMBOLS<<1, NULL }; // application callbacks static void (*drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar; @@ -125,27 +121,24 @@ static int32_t (*_getrowheight)(int32_t) = _internal_getrowheight; static cvar_t *cvars = NULL; static uint32_t osdnumcvars = 0; -static hashtable_t osdcvarsH = { MAXSYMBOLS<<1, NULL }; - -// color code format is as follows: -// ^## sets a color, where ## is the palette number -// ^S# sets a shade, range is 0-7 equiv to shades 0-14 -// ^O resets formatting to defaults +static hashtable_t h_cvars = { MAXSYMBOLS<<1, NULL }; int32_t OSD_RegisterCvar(const cvar_t *cvar) { const char *cp; - if (!osdinited) OSD_Init(); + if ((osdflags & OSD_INITIALIZED) == 0) + OSD_Init(); - if (!cvar->name) + if (!cvar->name || !cvar->name[0]) { - OSD_Printf("OSD_RegisterCvar(): may not register a cvar with a null name\n"); + OSD_Printf("OSD_RegisterCvar(): can't register cvar with null name\n"); return -1; } - if (!cvar->name[0]) + + if (!cvar->var) { - OSD_Printf("OSD_RegisterCvar(): may not register a cvar with no name\n"); + OSD_Printf("OSD_RegisterCvar(): can't register null cvar\n"); return -1; } @@ -167,22 +160,21 @@ int32_t OSD_RegisterCvar(const cvar_t *cvar) } } - if (!cvar->var) - { - OSD_Printf("OSD_RegisterCvar(): may not register a null cvar\n"); - return -1; - } - cvars = Brealloc(cvars, (osdnumcvars + 1) * sizeof(cvar_t)); - hash_add(&osdcvarsH, cvar->name, osdnumcvars); + hash_add(&h_cvars, cvar->name, osdnumcvars); Bmemcpy(&cvars[osdnumcvars++], cvar, sizeof(cvar_t)); return 0; } -const char *stripcolorcodes(char *out, const char *in) +// color code format is as follows: +// ^## sets a color, where ## is the palette number +// ^S# sets a shade, range is 0-7 equiv to shades 0-14 +// ^O resets formatting to defaults + +const char * OSD_StripColors(char *out, const char *in) { - char *ptr = out; + const char *ptr = out; do { @@ -203,12 +195,12 @@ const char *stripcolorcodes(char *out, const char *in) in += 2; continue; } - *(out++) = *(in++); + *(out++) = *in; } - while (*in); + while (*(++in)); *out = '\0'; - return(ptr); + return (ptr); } int32_t OSD_Exec(const char *szScript) @@ -221,7 +213,7 @@ int32_t OSD_Exec(const char *szScript) OSD_Printf("Executing \"%s\"\n", szScript); osdexecscript++; - while (fgets(line ,sizeof(line)-1, fp) != NULL) + while (fgets(line, sizeof(line)-1, fp) != NULL) OSD_Dispatch(strtok(line,"\r\n")); osdexecscript--; fclose(fp); @@ -240,17 +232,17 @@ int32_t OSD_OSDKey(void) return osdkey; } -char *OSD_GetTextPtr(void) +char * OSD_GetTextPtr(void) { return (&osdtext[0]); } -char *OSD_GetFmtPtr(void) +char * OSD_GetFmtPtr(void) { return (&osdfmt[0]); } -char *OSD_GetFmt(char *ptr) +char * OSD_GetFmt(char *ptr) { return (ptr - &osdtext[0] + &osdfmt[0]); } @@ -308,7 +300,6 @@ static int32_t _internal_osdfunc_exec(const osdfuncparm_t *parm) static void _internal_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal) { - int32_t i,j,k; char st[2] = { 0,0 }; UNREFERENCED_PARAMETER(shade); @@ -316,23 +307,11 @@ static void _internal_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, st[0] = ch; - if (white<0) - { - // find the palette index closest to white - k=0; - for (i=0; i<256; i++) - { - j = ((int32_t)curpalette[i].r)+((int32_t)curpalette[i].g)+((int32_t)curpalette[i].b); - if (j > k) { k = j; white = i; } - } - } - printext256(4+(x<<3),4+(y<<3), white, -1, st, 0); } static void _internal_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, int32_t shade, int32_t pal) { - int32_t i,j,k; char st[1024]; UNREFERENCED_PARAMETER(shade); @@ -342,8 +321,25 @@ static void _internal_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, in Bmemcpy(st,ch,len); st[len]=0; - if (white<0) + printext256(4+(x<<3),4+(y<<3), white, -1, st, 0); +} + +static void _internal_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress) +{ + char st[2] = { '_',0 }; + + UNREFERENCED_PARAMETER(lastkeypress); + + if (type) st[0] = '#'; + + if (white > -1) { + printext256(4+(x<<3),4+(y<<3)+2, white, -1, st, 0); + return; + } + + { + int32_t i, j, k; // find the palette index closest to white k=0; for (i=0; i<256; i++) @@ -353,30 +349,6 @@ static void _internal_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, in } } - printext256(4+(x<<3),4+(y<<3), white, -1, st, 0); -} - -static void _internal_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress) -{ - int32_t i,j,k; - char st[2] = { '_',0 }; - - UNREFERENCED_PARAMETER(lastkeypress); - - if (type) st[0] = '#'; - - if (white<0) - { - // find the palette index closest to white - k=0; - for (i=0; i<256; i++) - { - j = ((int32_t)palette[i*3])+((int32_t)palette[i*3+1])+((int32_t)palette[i*3+2]); - if (j > k) { k = j; white = i; } - } - } - - printext256(4+(x<<3),4+(y<<3)+2, white, -1, st, 0); } static int32_t _internal_getcolumnwidth(int32_t w) @@ -416,7 +388,7 @@ static int32_t _internal_osdfunc_alias(const osdfuncparm_t *parm) int32_t j = 0; OSD_Printf("Alias listing:\n"); for (i=symbols; i!=NULL; i=i->next) - if (i->func == (void *)OSD_ALIAS) + if (i->func == OSD_ALIAS) { j++; OSD_Printf(" %s \"%s\"\n", i->name, i->help); @@ -432,12 +404,12 @@ static int32_t _internal_osdfunc_alias(const osdfuncparm_t *parm) { if (parm->numparms < 2) { - if (i->func == (void *)OSD_ALIAS) + if (i->func == OSD_ALIAS) OSD_Printf("alias %s \"%s\"\n", i->name, i->help); else OSD_Printf("%s is a function, not an alias\n",i->name); return OSDCMD_OK; } - if (i->func != (void *)OSD_ALIAS && i->func != (void *)OSD_UNALIASED) + if (i->func != OSD_ALIAS && i->func != OSD_UNALIASED) { OSD_Printf("Cannot override function \"%s\" with alias\n",i->name); return OSDCMD_OK; @@ -445,7 +417,7 @@ static int32_t _internal_osdfunc_alias(const osdfuncparm_t *parm) } } - OSD_RegisterFunction(Bstrdup(parm->parms[0]),Bstrdup(parm->parms[1]),(void *)OSD_ALIAS); + OSD_RegisterFunction(Bstrdup(parm->parms[0]),Bstrdup(parm->parms[1]),OSD_ALIAS); if (!osdexecscript) OSD_Printf("%s\n",parm->raw); return OSDCMD_OK; @@ -464,10 +436,10 @@ static int32_t _internal_osdfunc_unalias(const osdfuncparm_t *parm) { if (parm->numparms < 2) { - if (i->func == (void *)OSD_ALIAS) + if (i->func == OSD_ALIAS) { OSD_Printf("Removed alias %s (\"%s\")\n", i->name, i->help); - i->func = (void *)OSD_UNALIASED; + i->func = OSD_UNALIASED; } else OSD_Printf("Invalid alias %s\n",i->name); return OSDCMD_OK; @@ -486,7 +458,7 @@ static int32_t _internal_osdfunc_listsymbols(const osdfuncparm_t *parm) UNREFERENCED_PARAMETER(parm); for (i=symbols; i!=NULL; i=i->next) - if (i->func != (void *)OSD_UNALIASED) + if (i->func != OSD_UNALIASED) maxwidth = max((unsigned)maxwidth,Bstrlen(i->name)); if (maxwidth > 0) @@ -496,7 +468,7 @@ static int32_t _internal_osdfunc_listsymbols(const osdfuncparm_t *parm) OSD_Printf(OSDTEXT_RED "Symbol listing:\n"); for (i=symbols; i!=NULL; i=i->next) { - if (i->func != (void *)OSD_UNALIASED) + if (i->func != OSD_UNALIASED) { OSD_Printf("%-*s",maxwidth,i->name); x += maxwidth; @@ -562,8 +534,8 @@ void OSD_Cleanup(void) { symbol_t *s; - hash_free(&osdsymbolsH); - hash_free(&osdcvarsH); + hash_free(&h_osd); + hash_free(&h_cvars); for (; symbols; symbols=s) { @@ -580,7 +552,7 @@ void OSD_Cleanup(void) cvars = NULL; } - osdinited=0; + osdflags &= ~OSD_INITIALIZED; } @@ -613,32 +585,35 @@ void OSD_Init(void) uint32_t i; cvar_t cvars_osd[] = { - { "osdeditpal","osdeditpal: sets the palette of the OSD input text",(void *)&osdeditpal, CVAR_INT, 0, 0, MAXPALOOKUPS-1 }, - { "osdpromptpal","osdpromptpal: sets the palette of the OSD prompt",(void *)&osdpromptpal, CVAR_INT, 0, 0, MAXPALOOKUPS-1 }, - { "osdtextpal","osdtextpal: sets the palette of the OSD text",(void *)&osdtextpal, CVAR_INT, 0, 0, MAXPALOOKUPS-1 }, - { "osdeditshade","osdeditshade: sets the shade of the OSD input text",(void *)&osdeditshade, CVAR_INT, 0, 0, 7 }, - { "osdtextshade","osdtextshade: sets the shade of the OSD text",(void *)&osdtextshade, CVAR_INT, 0, 0, 7 }, - { "osdpromptshade","osdpromptshade: sets the shade of the OSD prompt",(void *)&osdpromptshade, CVAR_INT, 0, -128, 127 }, - { "osdrows","osdrows: sets the number of visible lines of the OSD",(void *)&osdrows, CVAR_INT|CVAR_FUNCPTR, 0, 0, MAXPALOOKUPS-1 }, - { "osdtextmode","osdtextmode: set OSD text mode (0:graphical, 1:fast)",(void *)&osdtextmode, CVAR_BOOL|CVAR_FUNCPTR, 0, 0, 1 }, - { "logcutoff","logcutoff: sets the maximal line count of the log file",(void *)&logcutoff, CVAR_INT, 0, 0, 262144 }, + { "osdeditpal","osdeditpal: sets the palette of the OSD input text",(void *)&osdeditpal, CVAR_INT, 0, MAXPALOOKUPS-1 }, + { "osdpromptpal","osdpromptpal: sets the palette of the OSD prompt",(void *)&osdpromptpal, CVAR_INT, 0, MAXPALOOKUPS-1 }, + { "osdtextpal","osdtextpal: sets the palette of the OSD text",(void *)&osdtextpal, CVAR_INT, 0, MAXPALOOKUPS-1 }, + { "osdeditshade","osdeditshade: sets the shade of the OSD input text",(void *)&osdeditshade, CVAR_INT, 0, 7 }, + { "osdtextshade","osdtextshade: sets the shade of the OSD text",(void *)&osdtextshade, CVAR_INT, 0, 7 }, + { "osdpromptshade","osdpromptshade: sets the shade of the OSD prompt",(void *)&osdpromptshade, CVAR_INT, -128, 127 }, + { "osdrows","osdrows: sets the number of visible lines of the OSD",(void *)&osdrows, CVAR_INT|CVAR_FUNCPTR, 0, MAXPALOOKUPS-1 }, + { "osdtextmode","osdtextmode: set OSD text mode (0:graphical, 1:fast)",(void *)&osdtextmode, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, + { "logcutoff","logcutoff: sets the maximal line count of the log file",(void *)&logcutoff, CVAR_INT, 0, 262144 }, }; - Bmemset(osdtext, 32, TEXTSIZE); + Bmemset(osdtext, asc_Space, TEXTSIZE); Bmemset(osdfmt, osdtextpal+(osdtextshade<<5), TEXTSIZE); Bmemset(osdsymbptrs, 0, sizeof(osdsymbptrs)); osdnumsymbols = osdnumcvars = 0; - osdlines = osdinited = 1; + osdlines = 1; + osdflags |= OSD_INITIALIZED; - hash_init(&osdsymbolsH); - hash_init(&osdcvarsH); + hash_init(&h_osd); + hash_init(&h_cvars); for (i=0; i: executes a script", _internal_osdfunc_exec); OSD_RegisterFunction("help","help: displays help for the specified cvar or command; \"listsymbols\" to show all commands",_internal_osdfunc_help); OSD_RegisterFunction("history","history: displays the console command history",_internal_osdfunc_history); - OSD_RegisterFunction("listsymbols","listsymbols: lists all the recognized symbols",_internal_osdfunc_listsymbols); - OSD_RegisterFunction("unalias","unalias: removes an alias created with \"alias\"",_internal_osdfunc_unalias); + OSD_RegisterFunction("listsymbols","listsymbols: lists all registered functions and cvars",_internal_osdfunc_listsymbols); + OSD_RegisterFunction("unalias","unalias: removes a command alias",_internal_osdfunc_unalias); atexit(OSD_Cleanup); } @@ -739,32 +714,33 @@ static int32_t OSD_FindDiffPoint(const char *str1, const char *str2) return i; } -// -// 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. -// - static void OSD_HistoryPrev(void) { if (osdhistorypos >= osdhistorysize-1) return; osdhistorypos++; Bmemcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); - osdeditlen = osdeditcursor = 0; - while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; + + osdeditcursor = 0; + while (osdeditbuf[osdeditcursor]) osdeditcursor++; + osdeditlen = osdeditcursor; + if (osdeditcursor=osdeditwinend) - osdeditwinstart+=(osdeditcursor-osdeditwinend), - osdeditwinend+=(osdeditcursor-osdeditwinend); + { + osdeditwinstart+=(osdeditcursor-osdeditwinend); + osdeditwinend+=(osdeditcursor-osdeditwinend); + } } static void OSD_HistoryNext(void) @@ -783,43 +759,58 @@ static void OSD_HistoryNext(void) osdhistorypos--; Bmemcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1); - osdeditlen = osdeditcursor = 0; - while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++; + + osdeditcursor = 0; + while (osdeditbuf[osdeditcursor]) osdeditcursor++; + osdeditlen = osdeditcursor; + if (osdeditcursor=osdeditwinend) - osdeditwinstart+=(osdeditcursor-osdeditwinend), - osdeditwinend+=(osdeditcursor-osdeditwinend); + { + osdeditwinstart+=(osdeditcursor-osdeditwinend); + osdeditwinend+=(osdeditcursor-osdeditwinend); + } } +// +// 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. +// + int32_t OSD_HandleChar(char ch) { int32_t i,j; symbol_t *tabc = NULL; static symbol_t *lastmatch = NULL; - if (!osdinited || !osdinput) return ch; + if ((osdflags & (OSD_INITIALIZED|OSD_CAPTURE)) != (OSD_INITIALIZED|OSD_CAPTURE)) + return ch; - if (ch != 9) lastmatch = NULL; // tab - if (ch == 1) // control a. jump to beginning of line + if (ch != 9) // tab + lastmatch = NULL; + + switch (ch) { + case 1: // control a. jump to beginning of line osdeditcursor=0; osdeditwinstart=0; osdeditwinend=editlinewidth; - } - else if (ch == 2) // control b, move one character left - { + return 0; + case 2: // control b, move one character left if (osdeditcursor > 0) osdeditcursor--; - } - else if (ch == 3) // control c - { + return 0; + case 3: // control c osdeditbuf[osdeditlen] = 0; OSD_Printf("%s\n",osdeditbuf); osdeditlen=0; @@ -827,9 +818,8 @@ int32_t OSD_HandleChar(char ch) osdeditwinstart=0; osdeditwinend=editlinewidth; osdeditbuf[0] = 0; - } - else if (ch == 5) // control e, jump to end of line - { + return 0; + case 5: // control e, jump to end of line osdeditcursor = osdeditlen; osdeditwinend = osdeditcursor; osdeditwinstart = osdeditwinend-editlinewidth; @@ -838,15 +828,14 @@ int32_t OSD_HandleChar(char ch) osdeditwinstart=0; osdeditwinend = editlinewidth; } - } - else if (ch == 6) // control f, move one character right - { + return 0; + case 6: // control f, move one character right if (osdeditcursor < osdeditlen) osdeditcursor++; - } - else if (ch == 8 || ch == 127) // control h, backspace - { + return 0; + case 8: + case 127: // control h, backspace if (!osdeditcursor || !osdeditlen) return 0; - if (!osdovertype) + if ((osdflags & OSD_OVERTYPE) == 0) { if (osdeditcursor < osdeditlen) Bmemmove(osdeditbuf+osdeditcursor-1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); @@ -854,105 +843,103 @@ int32_t OSD_HandleChar(char ch) } 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; + int32_t commonsize = 512; - if (j > 0) + if (!lastmatch) { - tabc = findsymbol(osdedittmp, NULL); + for (i=osdeditcursor; i>0; i--) if (osdeditbuf[i-1] == ' ') break; + for (j=0; osdeditbuf[i] != ' ' && i < osdeditlen; j++,i++) + osdedittmp[j] = osdeditbuf[i]; + osdedittmp[j] = 0; - if (tabc && tabc->next && findsymbol(osdedittmp, tabc->next)) + if (j > 0) { - symbol_t *symb=tabc; - int32_t maxwidth = 0, x = 0, num = 0, diffpt; + tabc = findsymbol(osdedittmp, NULL); - while (symb && symb != lastmatch) + if (tabc && tabc->next && findsymbol(osdedittmp, tabc->next)) { - num++; + symbol_t *symb=tabc; + int32_t maxwidth = 0, x = 0, num = 0, diffpt; - if (lastmatch) + while (symb && symb != lastmatch) { - diffpt = OSD_FindDiffPoint(symb->name,lastmatch->name); - if (diffpt < commonsize) - commonsize = diffpt; - } + num++; - maxwidth = max((unsigned)maxwidth,Bstrlen(symb->name)); - lastmatch = symb; - if (!lastmatch->next) break; - symb=findsymbol(osdedittmp, lastmatch->next); - } - OSD_Printf(OSDTEXT_RED "Found %d possible completions for '%s':\n",num,osdedittmp); - maxwidth += 3; - symb = tabc; - OSD_Printf(" "); - while (symb && (symb != lastmatch)) - { - tabc = lastmatch = symb; - OSD_Printf("%-*s",maxwidth,symb->name); - if (!lastmatch->next) break; - symb=findsymbol(osdedittmp, lastmatch->next); - x += maxwidth; - if (x > (osdcols - maxwidth)) - { - x = 0; - OSD_Printf("\n"); - if (symb && (symb != lastmatch)) - OSD_Printf(" "); + if (lastmatch) + { + diffpt = OSD_FindDiffPoint(symb->name,lastmatch->name); + if (diffpt < commonsize) + commonsize = diffpt; + } + + maxwidth = max((unsigned)maxwidth,Bstrlen(symb->name)); + lastmatch = symb; + if (!lastmatch->next) break; + symb=findsymbol(osdedittmp, lastmatch->next); } + OSD_Printf(OSDTEXT_RED "Found %d possible completions for '%s':\n",num,osdedittmp); + maxwidth += 3; + symb = tabc; + OSD_Printf(" "); + while (symb && (symb != lastmatch)) + { + tabc = lastmatch = symb; + OSD_Printf("%-*s",maxwidth,symb->name); + if (!lastmatch->next) break; + symb=findsymbol(osdedittmp, lastmatch->next); + x += maxwidth; + if (x > (osdcols - maxwidth)) + { + x = 0; + OSD_Printf("\n"); + if (symb && (symb != lastmatch)) + OSD_Printf(" "); + } + } + if (x) OSD_Printf("\n"); + OSD_Printf(OSDTEXT_RED "Press TAB again to cycle through matches\n"); } - if (x) OSD_Printf("\n"); - OSD_Printf(OSDTEXT_RED "Press TAB again to cycle through matches\n"); } } - } - 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 - && (osdeditlen < commonsize); i++,j++,osdeditlen++) - osdeditbuf[i] = tabc->name[j]; - osdeditcursor = osdeditlen; - osdeditwinend = osdeditcursor; - osdeditwinstart = osdeditwinend-editlinewidth; - if (osdeditwinstart<0) + else { - osdeditwinstart=0; - osdeditwinend = editlinewidth; + tabc = findsymbol(osdedittmp, lastmatch->next); + if (!tabc && lastmatch) + tabc = findsymbol(osdedittmp, NULL); // wrap */ } - lastmatch = tabc; + if (tabc) + { + for (i=osdeditcursor; i>0; i--) if (osdeditbuf[i-1] == ' ') break; + osdeditlen = i; + for (j=0; tabc->name[j] && osdeditlen <= EDITLENGTH + && (osdeditlen < commonsize); 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 - { + return 0; + case 11: // control k, delete all to end of line Bmemset(osdeditbuf+osdeditcursor,0,sizeof(osdeditbuf)-osdeditcursor); - } - else if (ch == 12) // control l, clear screen - { + return 0; + case 12: // control l, clear screen Bmemset(osdtext,0,sizeof(osdtext)); Bmemset(osdfmt,osdtextpal+(osdtextshade<<5),sizeof(osdfmt)); osdlines = 1; - } - else if (ch == 13) // control m, enter - { + return 0; + case 13: // control m, enter if (osdeditlen>0) { osdeditbuf[osdeditlen] = 0; @@ -964,7 +951,7 @@ int32_t OSD_HandleChar(char ch) osdhistorytotal++; if (osdexeccount == HISTORYDEPTH) OSD_Printf("Command Buffer Warning: Failed queueing command " - "for execution. Buffer full.\n"); + "for execution. Buffer full.\n"); else osdexeccount++; } @@ -972,7 +959,7 @@ int32_t OSD_HandleChar(char ch) { if (osdexeccount == HISTORYDEPTH) OSD_Printf("Command Buffer Warning: Failed queueing command " - "for execution. Buffer full.\n"); + "for execution. Buffer full.\n"); else osdexeccount++; } @@ -983,20 +970,14 @@ int32_t OSD_HandleChar(char ch) osdeditcursor=0; osdeditwinstart=0; osdeditwinend=editlinewidth; - } - else if (ch == 14) // control n, next (ie. down arrow) - { + return 0; + case 14: // control n, next (ie. down arrow) OSD_HistoryNext(); - } - else if (ch == 16) // control p, previous (ie. up arrow) - { + return 0; + case 16: // control p, previous (ie. up arrow) OSD_HistoryPrev(); - } - else if (ch == 20) // control t, swap previous two chars - { - } - else if (ch == 21) // control u, delete all to beginning - { + return 0; + case 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--; + while (i>0 && osdeditbuf[i-1]==asc_Space) i--; + while (i>0 && osdeditbuf[i-1]!=asc_Space) i--; if (osdeditcursor= 32) // text char - { - if (!osdovertype && osdeditlen == EDITLENGTH) // buffer full, can't insert another char - return 0; - - if (!osdovertype) + return 0; + default: + if (ch >= asc_Space) // text char { - if (osdeditcursor < osdeditlen) - Bmemmove(osdeditbuf+osdeditcursor+1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); - osdeditlen++; - } - else - { - if (osdeditcursor == osdeditlen) + if ((osdflags & OSD_OVERTYPE) == 0) + { + if (osdeditlen == EDITLENGTH) // buffer full, can't insert another char + return 0; + if (osdeditcursor < osdeditlen) + Bmemmove(osdeditbuf+osdeditcursor+1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor); osdeditlen++; + } + else if (osdeditcursor == osdeditlen) + osdeditlen++; + + osdeditbuf[osdeditcursor++] = ch; + + if (osdeditcursor > osdeditwinend) + osdeditwinstart++, osdeditwinend++; } - osdeditbuf[osdeditcursor] = ch; - osdeditcursor++; - if (osdeditcursor>osdeditwinend) osdeditwinstart++,osdeditwinend++; + return 0; } return 0; } int32_t OSD_HandleScanCode(int32_t sc, int32_t press) { - if (!osdinited) return sc; + if ((osdflags & OSD_INITIALIZED) == 0) + return sc; if (sc == osdkey) { @@ -1065,64 +1047,52 @@ int32_t OSD_HandleScanCode(int32_t sc, int32_t press) OSD_CaptureInput(osdscroll == 1); osdscrtime = getticks(); } - return 0;//sc; + return 0; } - else if (!osdinput) - { + else if ((osdflags & OSD_CAPTURE) == 0) return sc; - } if (!press) { - if (sc == 42 || sc == 54) // shift - osdeditshift = 0; - if (sc == 29 || sc == 157) // control - osdeditcontrol = 0; - return 0;//sc; + if (sc == sc_LeftShift || sc == sc_RightShift) + osdflags &= ~OSD_SHIFT; + if (sc == sc_LeftControl || sc == sc_RightControl) + osdflags &= ~OSD_CTRL; + return 0; } keytime = gettime(); - if (sc == 15) // tab - { - } - else if (sc == 1) // escape + switch (sc) { + case sc_Escape: // OSD_ShowDisplay(0); osdscroll = -1; - osdrowscur += osdscroll; + osdrowscur--; OSD_CaptureInput(0); osdscrtime = getticks(); - } - else if (sc == 201) // page up - { + break; + case sc_PgUp: if (osdhead < osdlines-1) osdhead++; - } - else if (sc == 209) // page down - { + break; + case sc_PgDn: if (osdhead > 0) osdhead--; - } - else if (sc == 199) // home - { - if (osdeditcontrol) - { + break; + case sc_Home: + if (osdflags & OSD_CTRL) osdhead = osdlines-1; - } else { osdeditcursor = 0; osdeditwinstart = osdeditcursor; osdeditwinend = osdeditwinstart+editlinewidth; } - } - else if (sc == 207) // end - { - if (osdeditcontrol) - { + break; + case sc_End: + if (osdflags & OSD_CTRL) osdhead = 0; - } else { osdeditcursor = osdeditlen; @@ -1134,90 +1104,87 @@ int32_t OSD_HandleScanCode(int32_t sc, int32_t press) osdeditwinend = editlinewidth; } } - } - else if (sc == 210) // insert - { - osdovertype ^= 1; - } - else if (sc == 203) // left - { + break; + case sc_Insert: + osdflags = (osdflags & ~OSD_OVERTYPE) | (-((osdflags & OSD_OVERTYPE) == 0) & OSD_OVERTYPE); + break; + case sc_LeftArrow: if (osdeditcursor>0) { - if (osdeditcontrol) + if (osdflags & OSD_CTRL) { while (osdeditcursor>0) { - if (osdeditbuf[osdeditcursor-1] != 32) break; + if (osdeditbuf[osdeditcursor-1] != asc_Space) + break; osdeditcursor--; } while (osdeditcursor>0) { - if (osdeditbuf[osdeditcursor-1] == 32) break; + if (osdeditbuf[osdeditcursor-1] == asc_Space) + break; osdeditcursor--; } } else osdeditcursor--; } if (osdeditcursor=osdeditwinend) - osdeditwinstart+=(osdeditcursor-osdeditwinend), - osdeditwinend+=(osdeditcursor-osdeditwinend); - } - else if (sc == 200) // up - { + { + osdeditwinstart+=(osdeditcursor-osdeditwinend); + osdeditwinend+=(osdeditcursor-osdeditwinend); + } + break; + case sc_UpArrow: OSD_HistoryPrev(); - } - else if (sc == 208) // down - { + break; + case sc_DownArrow: OSD_HistoryNext(); - } - 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); + break; + case sc_LeftShift: + case sc_RightShift: + osdflags |= OSD_SHIFT; + break; + case sc_LeftControl: + case sc_RightControl: + osdflags |= OSD_CTRL; + break; + case sc_CapsLock: + osdflags = (osdflags & ~OSD_CAPS) | (-((osdflags & OSD_CAPS) == 0) & OSD_CAPS); + break; + case sc_Delete: + if (osdeditcursor == osdeditlen || !osdeditlen) + return 0; + if (osdeditcursor <= osdeditlen-1) + Bmemmove(osdeditbuf+osdeditcursor, osdeditbuf+osdeditcursor+1, osdeditlen-osdeditcursor-1); osdeditlen--; + break; } - return 0; } @@ -1240,7 +1207,7 @@ void OSD_ResizeDisplay(int32_t w, int32_t h) j = min(newmaxlines, osdmaxlines); k = min(newcols, osdcols); - memset(newtext, 32, TEXTSIZE); + Bmemset(newtext, asc_Space, TEXTSIZE); for (i=j-1; i>=0; i--) { Bmemcpy(newtext+newcols*i, osdtext+osdcols*i, k); @@ -1268,23 +1235,25 @@ void OSD_ResizeDisplay(int32_t w, int32_t h) // void OSD_CaptureInput(int32_t cap) { - osdinput = (cap != 0); - osdeditcontrol = 0; - osdeditshift = 0; + osdflags = (osdflags & ~(OSD_CAPTURE|OSD_CTRL|OSD_SHIFT)) | (-cap & OSD_CAPTURE); + + grabmouse(cap == 0); + onshowosd(cap); + + if (cap) + releaseallbuttons(); - grabmouse(osdinput == 0); - onshowosd(osdinput); - if (osdinput) releaseallbuttons(); bflushchars(); } + // // OSD_ShowDisplay() -- Shows or hides the onscreen display // void OSD_ShowDisplay(int32_t onf) { - osdvisible = (onf != 0); - OSD_CaptureInput(osdvisible); + osdflags = (osdflags & ~OSD_DRAW) | (-onf & OSD_DRAW); + OSD_CaptureInput(onf); } @@ -1297,10 +1266,11 @@ void OSD_Draw(void) uint32_t topoffs; int32_t row, lines, x, len; - if (!osdinited) return; + if ((osdflags & OSD_INITIALIZED) == 0) + return; if (osdrowscur == 0) - OSD_ShowDisplay(osdvisible ^ 1); + OSD_ShowDisplay(osdflags & OSD_DRAW ? 0 : 1); if (osdrowscur == osdrows) osdscroll = 0; @@ -1333,7 +1303,7 @@ void OSD_Draw(void) osdscrtime = getticks(); } - if (!osdvisible || !osdrowscur) return; + if ((osdflags & OSD_DRAW) == 0 || !osdrowscur) return; topoffs = osdhead * osdcols; row = osdrowscur-1; @@ -1343,8 +1313,8 @@ void OSD_Draw(void) clearbackground(osdcols,osdrowscur+1); - if (osdversionstring[0]) - drawosdstr(osdcols-osdversionstringlen,osdrowscur,osdversionstring,osdversionstringlen,(sintable[(totalclock<<4)&2047]>>11),osdversionstringpal); + if (osdver[0]) + drawosdstr(osdcols-osdverlen,osdrowscur,osdver,osdverlen,(sintable[(totalclock<<4)&2047]>>11),osdverpal); for (; lines>0; lines--, row--) { @@ -1353,13 +1323,13 @@ void OSD_Draw(void) } { - int32_t offset = (osdeditcaps && osdeditshift && osdhead > 0); + int32_t offset = ((osdflags & (OSD_CAPS|OSD_SHIFT)) == (OSD_CAPS|OSD_SHIFT) && osdhead > 0); int32_t shade = osdpromptshade?osdpromptshade:(sintable[(totalclock<<4)&2047]>>11); if (osdhead == osdlines-1) drawosdchar(0,osdrowscur,'~',shade,osdpromptpal); else if (osdhead > 0) drawosdchar(0,osdrowscur,'^',shade,osdpromptpal); - if (osdeditcaps) drawosdchar(0+(osdhead > 0),osdrowscur,'C',shade,osdpromptpal); - if (osdeditshift) drawosdchar(1+(osdeditcaps && osdhead > 0),osdrowscur,'H',shade,osdpromptpal); + if (osdflags & OSD_CAPS) drawosdchar(0+(osdhead > 0),osdrowscur,'C',shade,osdpromptpal); + if (osdflags & OSD_SHIFT) drawosdchar(1+(osdflags & OSD_CAPS && osdhead > 0),osdrowscur,'H',shade,osdpromptpal); drawosdchar(2+offset,osdrowscur,'>',shade,osdpromptpal); @@ -1367,7 +1337,7 @@ void OSD_Draw(void) for (x=len-1; x>=0; x--) drawosdchar(3+x+offset,osdrowscur,osdeditbuf[osdeditwinstart+x],osdeditshade<<1,osdeditpal); - drawosdcursor(3+osdeditcursor-osdeditwinstart+offset,osdrowscur,osdovertype,keytime); + drawosdcursor(3+osdeditcursor-osdeditwinstart+offset,osdrowscur,osdflags & OSD_OVERTYPE,keytime); } enddrawing(); @@ -1379,10 +1349,10 @@ void OSD_Draw(void) // and write it to the log file // -static inline void linefeed(void) +static inline void OSD_LineFeed(void) { Bmemmove(osdtext+osdcols, osdtext, TEXTSIZE-osdcols); - Bmemset(osdtext, 32, osdcols); + Bmemset(osdtext, asc_Space, osdcols); Bmemmove(osdfmt+osdcols, osdfmt, TEXTSIZE-osdcols); Bmemset(osdfmt, osdtextpal, osdcols); if (osdlines < osdmaxlines) osdlines++; @@ -1394,7 +1364,8 @@ void OSD_Printf(const char *fmt, ...) char *chp, p=osdtextpal, s=osdtextshade; va_list va; - if (!osdinited) OSD_Init(); + if ((osdflags & OSD_INITIALIZED) == 0) + OSD_Init(); va_start(va, fmt); Bvsnprintf(tmpstr, 8192, fmt, va); @@ -1415,7 +1386,7 @@ void OSD_Printf(const char *fmt, ...) if (osdlog&&(!logcutoff||linecntfunc == (void *)OSD_ALIAS) + if (symb->func == OSD_ALIAS) OSD_Dispatch(symb->help); - else if (symb->func != (void *)OSD_UNALIASED) + else if (symb->func != OSD_UNALIASED) { switch (symb->func(&ofp)) { @@ -1680,7 +1651,8 @@ int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func) symbol_t *symb; const char *cp; - if (!osdinited) OSD_Init(); + if ((osdflags & OSD_INITIALIZED) == 0) + OSD_Init(); if (!name) { @@ -1721,7 +1693,7 @@ int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func) symb = findexactsymbol(name); if (symb) // allow this now for reusing an alias name { - if (symb->func != (void *)OSD_ALIAS && symb->func != (void *)OSD_UNALIASED) + if (symb->func != OSD_ALIAS && symb->func != OSD_UNALIASED) { OSD_Printf("OSD_RegisterFunction(): \"%s\" is already defined\n", name); return -1; @@ -1749,14 +1721,12 @@ int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func) // // OSD_SetVersionString() // -void OSD_SetVersionString(const char *version, int32_t shade, int32_t pal) +void OSD_SetVersion(const char *version, int32_t shade, int32_t pal) { -// if (!osdinited) OSD_Init(); - - Bstrcpy(osdversionstring,version); - osdversionstringlen = Bstrlen(osdversionstring); - osdversionstringshade = shade; - osdversionstringpal = pal; + Bstrcpy(osdver,version); + osdverlen = Bstrlen(osdver); + osdvershade = shade; + osdverpal = pal; } // @@ -1767,7 +1737,6 @@ void OSD_SetVersionString(const char *version, int32_t shade, int32_t pal) static symbol_t *addnewsymbol(const char *name) { symbol_t *newsymb, *s, *t; - char *lname; if (osdnumsymbols >= MAXSYMBOLS) return NULL; newsymb = (symbol_t *)Bmalloc(sizeof(symbol_t)); @@ -1800,10 +1769,10 @@ static symbol_t *addnewsymbol(const char *name) newsymb->next = t; } } - hash_add(&osdsymbolsH, name, osdnumsymbols); - lname = strtolower(Bstrdup(name),Bstrlen(name)); - hash_add(&osdsymbolsH, lname, osdnumsymbols); - Bfree(lname); + hash_add(&h_osd, name, osdnumsymbols); + name = strtolower(Bstrdup(name), Bstrlen(name)); + hash_add(&h_osd, name, osdnumsymbols); + Bfree((void *)name); osdsymbptrs[osdnumsymbols++] = newsymb; return newsymb; } @@ -1818,7 +1787,7 @@ static symbol_t *findsymbol(const char *name, symbol_t *startingat) if (!startingat) return NULL; for (; startingat; startingat=startingat->next) - if (startingat->func != (void *)OSD_UNALIASED && !Bstrncasecmp(name, startingat->name, Bstrlen(name))) return startingat; + if (startingat->func != OSD_UNALIASED && !Bstrncasecmp(name, startingat->name, Bstrlen(name))) return startingat; return NULL; } @@ -1832,10 +1801,10 @@ static symbol_t *findexactsymbol(const char *name) char *lname = Bstrdup(name); if (!symbols) return NULL; - i = hash_find(&osdsymbolsH,lname); + i = hash_find(&h_osd,lname); if (i > -1) { -// if ((symbol_t *)osdsymbptrs[i]->func == (void *)OSD_UNALIASED) +// if ((symbol_t *)osdsymbptrs[i]->func == OSD_UNALIASED) // return NULL; Bfree(lname); return osdsymbptrs[i]; @@ -1843,7 +1812,7 @@ static symbol_t *findexactsymbol(const char *name) // try it again lname = strtolower(lname, Bstrlen(name)); - i = hash_find(&osdsymbolsH,lname); + i = hash_find(&h_osd,lname); Bfree(lname); if (i > -1) @@ -1856,8 +1825,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) int32_t showval = (parm->numparms == 0); int32_t i; - i = hash_find(&osdcvarsH, parm->name); - + i = hash_find(&h_cvars, parm->name); if (i < 0) for (i = osdnumcvars-1; i >= 0; i--) @@ -1948,8 +1916,8 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) return OSDCMD_OK; } - Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].extra-1); - ((char*)cvars[i].var)[cvars[i].extra-1] = 0; + Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].max-1); + ((char*)cvars[i].var)[cvars[i].max-1] = 0; if (!OSD_ParsingScript()) OSD_Printf("%s %s",cvars[i].name,(char*)cvars[i].var); } @@ -1969,30 +1937,30 @@ void OSD_WriteCvars(FILE *fp) { uint32_t i; - if (fp) + if (!fp) + return; + + for (i=0; i