From 3503a42a9a7e496534a2bf7fac5988b8d5665629 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sun, 18 Mar 2012 08:48:32 +0000 Subject: [PATCH] Buildtools: Add "unpackssi" and "Build Customization Suite" [Palette Importer/Extractor] (bsuite), both by JonoF. I have rewritten bsuite to use command-line arguments rather than a 16-bit real mode DOS UI. Both programs have had all warnings fixed and whitespace corrected. git-svn-id: https://svn.eduke32.com/eduke32@2493 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/Makefile | 10 +- polymer/eduke32/build/Makefile.deps | 2 + polymer/eduke32/build/Makefile.msvc | 12 +- polymer/eduke32/build/include/compat.h | 2 + polymer/eduke32/build/src/util/bsuite.c | 469 +++++++++++++++++++++ polymer/eduke32/build/src/util/unpackssi.c | 193 +++++++++ 6 files changed, 685 insertions(+), 3 deletions(-) create mode 100644 polymer/eduke32/build/src/util/bsuite.c create mode 100644 polymer/eduke32/build/src/util/unpackssi.c diff --git a/polymer/eduke32/build/Makefile b/polymer/eduke32/build/Makefile index f3b92f158..298a35212 100644 --- a/polymer/eduke32/build/Makefile +++ b/polymer/eduke32/build/Makefile @@ -174,9 +174,11 @@ OURCFLAGS+= $(BUILDCFLAGS) UTILOBJS=$(OBJ)/kextract.$o $(OBJ)/kgroup.$o $(OBJ)/transpal.$o $(OBJ)/wad2art.$o $(OBJ)/wad2map.$o $(OBJ)/md2tool.$o \ $(OBJ)/generateicon.$o $(OBJ)/cacheinfo.$o $(OBJ)/enumdisplay.$o $(OBJ)/arttool.$o $(OBJ)/givedepth.$o $(OBJ)/mkpalette.$o \ + $(OBJ)/unpackssi.$o $(OBJ)/bsuite.$o \ $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(OBJ)/pragmas.$o $(OBJ)/kplib.$o $(OBJ)/cache1d.$o UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) md2tool$(EXESUFFIX) \ - generateicon$(EXESUFFIX) cacheinfo$(EXESUFFIX) arttool$(EXESUFFIX) givedepth$(EXESUFFIX) mkpalette$(EXESUFFIX) + generateicon$(EXESUFFIX) cacheinfo$(EXESUFFIX) arttool$(EXESUFFIX) givedepth$(EXESUFFIX) mkpalette$(EXESUFFIX) \ + unpackssi$(EXESUFFIX) bsuite$(EXESUFFIX) # all: $(OBJ)/$(ENGINELIB) $(OBJ)/$(EDITORLIB) utils: start $(UTILS) finish @@ -242,6 +244,12 @@ givedepth$(EXESUFFIX): $(OBJ)/givedepth.$o $(UTILADDOBJS) mkpalette$(EXESUFFIX): $(OBJ)/mkpalette.$o $(UTILADDOBJS) $(ONESTEP_STATUS) if $(CC) -o $@ $^ $(UTILLIBS); then $(ONESTEP_OK); fi +unpackssi$(EXESUFFIX): $(OBJ)/unpackssi.$o $(UTILADDOBJS) + $(ONESTEP_STATUS) + if $(CC) -o $@ $^ $(UTILLIBS); then $(ONESTEP_OK); fi +bsuite$(EXESUFFIX): $(OBJ)/bsuite.$o $(UTILADDOBJS) + $(ONESTEP_STATUS) + if $(CC) -o $@ $^ $(UTILLIBS); then $(ONESTEP_OK); fi # DEPENDENCIES include Makefile.deps diff --git a/polymer/eduke32/build/Makefile.deps b/polymer/eduke32/build/Makefile.deps index ecf592b77..88af00b79 100644 --- a/polymer/eduke32/build/Makefile.deps +++ b/polymer/eduke32/build/Makefile.deps @@ -51,3 +51,5 @@ $(OBJ)/enumdisplay.$o: $(SRC)/misc/enumdisplay.c $(OBJ)/arttool.$o: $(SRC)/util/arttool.cc $(OBJ)/givedepth.$o: $(SRC)/util/givedepth.c $(OBJ)/mkpalette.$o: $(SRC)/util/mkpalette.c +$(OBJ)/unpackssi.$o: $(SRC)/util/unpackssi.c +$(OBJ)/bsuite.$o: $(SRC)/util/bsuite.c diff --git a/polymer/eduke32/build/Makefile.msvc b/polymer/eduke32/build/Makefile.msvc index 963ca73d9..2af38100c 100644 --- a/polymer/eduke32/build/Makefile.msvc +++ b/polymer/eduke32/build/Makefile.msvc @@ -117,7 +117,7 @@ CFLAGS=$(CFLAGS) /DRENDERTYPE$(RENDERTYPE)=1 /W2 $(CC) /c $(CFLAGS) /Fo$@ $< # TARGETS -UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) md2tool$(EXESUFFIX) generateicon$(EXESUFFIX) cacheinfo$(EXESUFFIX) arttool$(EXESUFFIX) givedepth$(EXESUFFIX) mkpalette$(EXESUFFIX) +UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) md2tool$(EXESUFFIX) generateicon$(EXESUFFIX) cacheinfo$(EXESUFFIX) arttool$(EXESUFFIX) givedepth$(EXESUFFIX) mkpalette$(EXESUFFIX) unpackssi$(EXESUFFIX) bsuite$(EXESUFFIX) all: $(OBJ)\$(ENGINELIB) $(OBJ)\$(EDITORLIB); utils: $(UTILS) ; @@ -175,12 +175,20 @@ mkpalette$(EXESUFFIX): $(OBJ)\mkpalette.$o $(OBJ)\nedmalloc.$o $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS) $(MT) -manifest $@.manifest -outputresource:$@ +unpackssi$(EXESUFFIX): $(OBJ)\unpackssi.$o $(OBJ)\nedmalloc.$o + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS) + $(MT) -manifest $@.manifest -outputresource:$@ + +bsuite$(EXESUFFIX): $(OBJ)\bsuite.$o $(OBJ)\nedmalloc.$o + $(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS) + $(MT) -manifest $@.manifest -outputresource:$@ + # DEPENDENCIES !include Makefile.deps # PHONIES clean: - -del /Q $(ENGINEOBJS) $(EDITOROBJS) $(OBJ)\kextract.$o $(OBJ)\kgroup.$o $(OBJ)\transpal.$o $(OBJ)\wad2art.$o $(OBJ)\wad2map.$o $(OBJ)\md2tool.$o $(OBJ)\generateicon.$o $(OBJ)\cacheinfo.$o $(OBJ)\arttool.$o $(OBJ)\givedepth.$o $(OBJ)\mkpalette.$o $(OBJ)\compat.$o $(OBJ)\compat_tools.$o $(OBJ)\pragmas.$o $(OBJ)\kplib.$o $(OBJ)\cache1d.$o $(OBJ)\nedmalloc.$o + -del /Q $(ENGINEOBJS) $(EDITOROBJS) $(OBJ)\kextract.$o $(OBJ)\kgroup.$o $(OBJ)\transpal.$o $(OBJ)\wad2art.$o $(OBJ)\wad2map.$o $(OBJ)\md2tool.$o $(OBJ)\generateicon.$o $(OBJ)\cacheinfo.$o $(OBJ)\arttool.$o $(OBJ)\givedepth.$o $(OBJ)\mkpalette.$o $(OBJ)\unpackssi.$o $(OBJ)\bsuite.$o $(OBJ)\compat.$o $(OBJ)\compat_tools.$o $(OBJ)\pragmas.$o $(OBJ)\kplib.$o $(OBJ)\cache1d.$o $(OBJ)\nedmalloc.$o veryclean: clean -del /Q $(OBJ)\$(ENGINELIB) $(OBJ)\$(EDITORLIB) $(UTILS) *.map *.manifest *.pdb diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index 48a32e5d6..2e8b52798 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -478,6 +478,8 @@ static inline uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7ff # define Bfread fread # define Bfwrite fwrite # define Bfprintf fprintf +# define Bfscanf fscanf +# define Bfseek fseek # define Bstrcpy strcpy # define Bstrncpy strncpy # define Bstrcmp strcmp diff --git a/polymer/eduke32/build/src/util/bsuite.c b/polymer/eduke32/build/src/util/bsuite.c new file mode 100644 index 000000000..35c18d4b0 --- /dev/null +++ b/polymer/eduke32/build/src/util/bsuite.c @@ -0,0 +1,469 @@ +/* + Build Game Customization Suite + Copyright (c) 1999, 2004 Jonathon Fowler + + 15 September 2004 + + This is the source code to BCS. It was written in Borland Turbo C++ for DOS + and [was] a 16bit real-mode DOS application. I'm releasing the code because + I have no reason to keep it a secret. Some folks might find it interesting. + + BTW, you can use this code for any purpose you want. + + Jonathon Fowler + jf@jonof.id.au + http://www.jonof.id.au/ +*/ +/* + NOTE: This program does not fall under BUILDLIC. +*/ + +#include +#include +#include +#include +#include "compat.h" + +const char APP_NAME[] = "Build Game Customization Suite v0.2-EDuke32"; +const char APP_CPRT[] = "Copyright (c) 1999, 2004 Jonathon Fowler"; + +int bsExtractD3DPalette(int, const char*); +int bsUpdateD3DPalette(int, const char*); + +int bsExtractPalette(const char*); +int bsUpdatePalette(const char*); + +const char *MainMenuStrings[] = { + "Options:", + "Extract Duke Nukem 3D-specific Palettes", + "Update Duke Nukem 3D-specific Palettes", + "Extract Build Game Palette", + "Update Build Game Palette" +}; + +const char *D3DMenuStrings[] = { + "Sub-Option: Duke Nukem 3D-specific Palettes:", + "Water Palette", + "Night-Vision Palette", + "Title Screen Palette", + "3D Realms Logo Palette", + "Episode 1 Ending Animation Palette" +}; + +const char *pal_deffn[] = { + "GAME.PAL", + "D3DWATER.PAL", + "D3DNVIS.PAL", + "D3DTITLE.PAL", + "D3D3DR.PAL", + "D3DEP1.PAL" + }; + +int main(const int32_t argc, const char **argv) +{ + int opt = 0, d3dpal = 0, k = 0; + int16_t i = 1; + char *filename = NULL; // This is only a pointer. Do not strcpy to it. + char *c = NULL; + + Bprintf("%s\n%s\n\n", APP_NAME, APP_CPRT); + + if (argc > 1) + { + opt = Bstrtol(argv[i++],NULL,10); + if ((opt == 1 || opt == 2) && i < argc) // Duke-specific palettes + d3dpal = Bstrtol(argv[i++],NULL,10); + + while (i < argc) + { + c = (char *)argv[i]; + if ((*c == '-') +#ifdef _WIN32 + || (*c == '/') +#endif + ) + { + ++c; + if (!Bstrcasecmp(c,"f")) + { + if (argc > i+1) + filename = (char *)argv[++i]; + ++i; + continue; + } + + } + ++i; + } + } + + if (opt < 1 || opt > 4 || (opt < 3 && (d3dpal < 1 || d3dpal > 5))) + { + Bprintf("usage: %s