diff --git a/polymer/build/Makefile b/polymer/build/Makefile index 5c4eda6d5..e144eb912 100644 --- a/polymer/build/Makefile +++ b/polymer/build/Makefile @@ -82,7 +82,6 @@ ENGINEOBJS+= \ $(OBJ)crc32.$o \ $(OBJ)defs.$o \ $(OBJ)engine.$o \ - $(OBJ)engineinfo.$o \ $(OBJ)glbuild.$o \ $(OBJ)kplib.$o \ $(OBJ)lzf_c.$o \ @@ -139,7 +138,8 @@ ifeq ($(RENDERTYPE),SDL) ifeq (1,$(HAVE_GTK2)) OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0) ENGINEOBJS+= $(OBJ)gtkbits.$o - GAMEEXEOBJS+= $(OBJ)game_banner.$o + EDITOROBJS+= $(OBJ)startgtk.editor.$o + GAMEEXEOBJS+= $(OBJ)game_banner.$o $(OBJ)startgtk.game.$o EDITOREXEOBJS+= $(OBJ)editor_banner.$o endif @@ -148,8 +148,8 @@ ifeq ($(RENDERTYPE),SDL) endif ifeq ($(RENDERTYPE),WIN) ENGINEOBJS+= $(OBJ)winlayer.$o - EDITOROBJS+= $(OBJ)buildstartwin.$o - GAMEEXEOBJS+= $(OBJ)gameres.$(res) $(OBJ)gamestartwin.$o + EDITOROBJS+= $(OBJ)startwin.editor.$o + GAMEEXEOBJS+= $(OBJ)gameres.$(res) $(OBJ)startwin.game.$o EDITOREXEOBJS+= $(OBJ)buildres.$(res) endif @@ -160,7 +160,7 @@ endif OURCFLAGS+= $(BUILDCFLAGS) -.PHONY: clean veryclean all utils writeengineinfo enginelib editorlib +.PHONY: clean veryclean all utils enginelib editorlib # TARGETS @@ -221,15 +221,6 @@ enumdisplay$(EXESUFFIX): src/misc/enumdisplay.c # DEPENDENCIES include Makefile.deps -.PHONY: $(OBJ)engineinfo.$o -$(OBJ)engineinfo.$o: - echo "const char _engine_cflags[] = \"$(CFLAGS) $(OURCFLAGS)\";" > $(SRC)tmp/engineinfo.c - echo "const char _engine_libs[] = \"$(LIBS)\";" >> $(SRC)tmp/engineinfo.c - echo "const char _engine_uname[] = \"$(shell uname -a)\";" >> $(SRC)tmp/engineinfo.c - echo "const char _engine_compiler[] = \"$(CC) $(shell $(CC) -dumpversion) $(shell $(CC) -dumpmachine)\";" >> $(SRC)tmp/engineinfo.c - echo "const char _engine_date[] = __DATE__ \" \" __TIME__;" >> $(SRC)tmp/engineinfo.c - $(CC) $(CFLAGS) $(OURCFLAGS) -c $(SRC)tmp/engineinfo.c -o $@ 2>&1 - # RULES $(OBJ)%.$o: $(SRC)%.nasm $(AS) $(ASFLAGS) $< -o $@ @@ -244,7 +235,7 @@ $(OBJ)%.$o: $(SRC)tmp/%.c $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 $(OBJ)%.$o: $(SRC)misc/%.rc - $(RC) -i $^ -o $@ + $(RC) -i $< -o $@ --include-dir=$(INC) --include-dir=$(SRC) $(OBJ)%.$o: $(SRC)util/%.c $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 diff --git a/polymer/build/Makefile.deps b/polymer/build/Makefile.deps index d558f306f..75cf6eeb7 100644 --- a/polymer/build/Makefile.deps +++ b/polymer/build/Makefile.deps @@ -21,7 +21,7 @@ $(OBJ)lzwnew.$o: $(SRC)lzwnew.c $(OBJ)md4.$o: $(SRC)md4.c $(INC)md4.h $(INC)compat.h $(OBJ)mmulti_null.$o: $(SRC)mmulti_null.c $(INC)mmulti.h $(OBJ)mmulti.$o: $(SRC)mmulti.c -$(OBJ)osd.$o: $(SRC)osd.c $(INC)build.h $(INC)osd.h $(INC)compat.h $(INC)engineinfo.h $(INC)baselayer.h +$(OBJ)osd.$o: $(SRC)osd.c $(INC)build.h $(INC)osd.h $(INC)compat.h $(INC)baselayer.h $(OBJ)pragmas.$o: $(SRC)pragmas.c $(INC)compat.h $(OBJ)scriptfile.$o: $(SRC)scriptfile.c $(INC)scriptfile.h $(INC)cache1d.h $(INC)compat.h $(OBJ)sdlayer.$o: $(SRC)sdlayer.c $(INC)compat.h $(INC)sdlayer.h $(INC)baselayer.h $(INC)cache1d.h $(INC)pragmas.h $(INC)a.h $(INC)build.h $(INC)osd.h $(INC)glbuild.h @@ -29,10 +29,12 @@ $(OBJ)sound.$o: $(SRC)sound.c $(INC)osd.h $(INC)compat.h $(INC)cache1d.h $(OBJ)winlayer.$o: $(SRC)winlayer.c $(INC)compat.h $(INC)winlayer.h $(INC)baselayer.h $(INC)pragmas.h $(INC)build.h $(INC)a.h $(INC)osd.h $(INC)dxdidf.h $(INC)glbuild.h $(OBJ)gtkbits.$o: $(SRC)gtkbits.c $(INC)baselayer.h $(INC)build.h -$(OBJ)gameres.$(res): $(SRC)misc/gameres.rc -$(OBJ)buildres.$(res): $(SRC)misc/buildres.rc -$(OBJ)gamestartwin.$o: $(SRC)gamestartwin.c $(INC)winlayer.h $(INC)build.h $(INC)compat.h -$(OBJ)buildstartwin.$o: $(SRC)buildstartwin.c $(INC)winlayer.h $(INC)build.h $(INC)compat.h +$(OBJ)gameres.$(res): $(SRC)misc/gameres.rc $(SRC)startwin.game.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 +$(OBJ)startwin.game.$o: $(SRC)startwin.game.c $(INC)build.h $(INC)editor.h $(INC)winlayer.h $(INC)compat.h $(SRC)startwin.game.h +$(OBJ)startgtk.editor.$o: $(SRC)startgtk.editor.c $(INC)baselayer.h $(INC)build.h $(INC)editor.h $(INC)compat.h +$(OBJ)startgtk.game.$o: $(SRC)startgtk.game.c $(INC)baselayer.h $(INC)build.h $(INC)compat.h $(OBJ)game_icon.$o: $(RSRC)game_icon.c $(OBJ)build_icon.$o: $(RSRC)build_icon.c diff --git a/polymer/build/Makefile.msvc b/polymer/build/Makefile.msvc index 853745cd0..bddf00f1a 100644 --- a/polymer/build/Makefile.msvc +++ b/polymer/build/Makefile.msvc @@ -58,7 +58,6 @@ ENGINEOBJS=$(OBJ)a.$o \ $(OBJ)crc32.$o \ $(OBJ)defs.$o \ $(OBJ)engine.$o \ - $(OBJ)engineinfo.$o \ $(OBJ)glbuild.$o \ $(OBJ)kplib.$o \ $(OBJ)lzf_c.$o \ @@ -72,13 +71,13 @@ ENGINEOBJS=$(OBJ)a.$o \ $(OBJ)winlayer.$o EDITOROBJS=$(OBJ)build.$o \ - $(OBJ)buildstartwin.$o \ + $(OBJ)startwin.editor.$o \ $(OBJ)config.$o GAMEEXEOBJS=$(OBJ)config.$o \ $(OBJ)game.$o \ $(OBJ)gameres.$(res) \ - $(OBJ)gamestartwin.$o \ + $(OBJ)startwin.game.$o \ $(OBJ)sound.$o \ $(OBJ)$(ENGINELIB) @@ -149,17 +148,6 @@ wad2art$(EXESUFFIX): $(OBJ)wad2art.$o $(OBJ)pragmas.$o $(OBJ)compat.$o # DEPENDENCIES !include Makefile.deps -$(OBJ)engineinfo.$o: writeengineinfo $(SRC)tmp\engineinfo.c - -writeengineinfo: - copy /y << $(SRC)tmp\engineinfo.c -const char _engine_cflags[] = "$(CFLAGS:\=\\)"; -const char _engine_libs[] = "$(LIBS)"; -const char _engine_uname[] = "unknown"; -const char _engine_compiler[] = "$(CC)"; -const char _engine_date[] = __DATE__ " " __TIME__; -< $(SRC)tmp\engineinfo.c - echo const char _engine_libs[] = "$(LIBS:\=\\)"; >> $(SRC)tmp\engineinfo.c - echo const char _engine_uname[] = "unknown"; >> $(SRC)tmp\engineinfo.c - echo const char _engine_compiler[] = "$(CC)"; >> $(SRC)tmp\engineinfo.c - echo const char _engine_date[] = __DATE__ " " __TIME__; >> $(SRC)tmp\engineinfo.c - # PHONIES clean: .SYMBOLIC -erase /q $(OBJ)* game$(EXESUFFIX) build$(EXESUFFIX) $(UTILS) *.err diff --git a/polymer/build/build.cfg b/polymer/build/build.cfg deleted file mode 100644 index fd0ff4ec4..000000000 --- a/polymer/build/build.cfg +++ /dev/null @@ -1,104 +0,0 @@ -; Build editor configuration - -; Video mode selection -; 0 - Windowed -; 1 - Fullscreen -fullscreen = 0 - -; Video resolution selection -; 0 - 320 x 200 -; 1 - 360 x 200 -; 2 - 320 x 240 -; 3 - 360 x 240 -; 4 - 320 x 400 -; 5 - 360 x 400 -; 6 - 640 x 350 -; 7 - 640 x 400 -; 8 - 640 x 480 -; 9 - 800 x 600 -; 10 - 1024 x 768 -; 11 - 1280 x 1024 -; 12 - 1600 x 1200 -; You can select a seperate 2D editor resolution by -; removing the semicolon from the second line below -; and selecting a mode number. The minimum 2D mode -; is 640x480 (mode #8) -resolution = 8 -;2dresolution = 8 - -; 3D-mode colour depth -bpp = 8 - -; Maximum OpenGL mode refresh rate (Windows only, in Hertz) -maxrefreshfreq = 60 - -; 3D mode brightness setting -; 0 - lowest -; 15 - highest -brightness = 0 - -; Sound sample frequency -; 0 - 6 KHz -; 1 - 8 KHz -; 2 - 11.025 KHz -; 3 - 16 KHz -; 4 - 22.05 KHz -; 5 - 32 KHz -; 6 - 44.1 KHz -samplerate = 4 - -; Music playback -; 0 - Off -; 1 - On -music = 1 - -; Enable mouse -; 0 - No -; 1 - Yes -mouse = 1 - -; Mouse sensitivity -mousesensitivity = 1.0 - -; Key Settings -; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex! -; +---------------------------------------------------------------------------------------------+ -; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 | -; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL | -; | | -; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A | -; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- | -; | | -; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E | -; |TAB Q W E R T Y U I O P [ ] \ DEL END PGDN KP7 KP8 KP9 KP+ | -; | | -; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D | -; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C | -; | KPENTER| -; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 | -; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 | -; | | -; | 1D 38 39 B8 9D CB D0 CD 52 53 | -; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. | -; +---------------------------------------------------------------------------------------------+ - -keyforward = C8 -keybackward = D0 -keyturnleft = CB -keyturnright = CD -keyrun = 2A -keystrafe = 9D -keyfire = 1D -keyuse = 39 -keystandhigh = 1E -keystandlow = 2C -keylookup = D1 -keylookdown = C9 -keystrafeleft = 33 -keystraferight = 34 -key2dmode = 9C -keyviewcycle = 1C -key2dzoomin = D -key2dzoomout = C -keychat = F - diff --git a/polymer/build/game.cfg b/polymer/build/game.cfg deleted file mode 100644 index 5dc3bf6cd..000000000 --- a/polymer/build/game.cfg +++ /dev/null @@ -1,97 +0,0 @@ -; KenBuild configuration - -; Video mode selection -; 0 - Windowed -; 1 - Fullscreen -fullscreen = 0 - -; Video resolution selection -; 0 - 320 x 200 -; 1 - 360 x 200 -; 2 - 320 x 240 -; 3 - 360 x 240 -; 4 - 320 x 400 -; 5 - 360 x 400 -; 6 - 640 x 350 -; 7 - 640 x 400 -; 8 - 640 x 480 -; 9 - 800 x 600 -; 10 - 1024 x 768 -; 11 - 1280 x 1024 -; 12 - 1600 x 1200 -resolution = 8 - -; 3D-mode colour depth -bpp = 8 - -; 3D mode brightness setting -; 0 - lowest -; 15 - highest -brightness = 0 - -; Maximum OpenGL mode refresh rate (Windows only, in Hertz) -maxrefreshfreq = 60 - -; Sound sample frequency -; 0 - 6 KHz -; 1 - 8 KHz -; 2 - 11.025 KHz -; 3 - 16 KHz -; 4 - 22.05 KHz -; 5 - 32 KHz -; 6 - 44.1 KHz -samplerate = 4 - -; Music playback -; 0 - Off -; 1 - On -music = 1 - -; Enable mouse -; 0 - No -; 1 - Yes -mouse = 1 - -; Key Settings -; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex! -; +---------------------------------------------------------------------------------------------+ -; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 | -; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL | -; | | -; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A | -; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- | -; | | -; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E | -; |TAB Q W E R T Y U I O P [ ] \ DEL END PGDN KP7 KP8 KP9 KP+ | -; | | -; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D | -; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C | -; | KPENTER| -; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 | -; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 | -; | | -; | 1D 38 39 B8 9D CB D0 CD 52 53 | -; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. | -; +---------------------------------------------------------------------------------------------+ - -keyforward = C8 -keybackward = D0 -keyturnleft = CB -keyturnright = CD -keyrun = 2A -keystrafe = 9D -keyfire = 1D -keyuse = 39 -keystandhigh = 1E -keystandlow = 2C -keylookup = D1 -keylookdown = C9 -keystrafeleft = 33 -keystraferight = 34 -key2dmode = 9C -keyviewcycle = 1C -key2dzoomin = D -key2dzoomout = C -keychat = F -keyconsole = 29 - diff --git a/polymer/build/include/baselayer.h b/polymer/build/include/baselayer.h index d4d47cf41..cf3893e33 100644 --- a/polymer/build/include/baselayer.h +++ b/polymer/build/include/baselayer.h @@ -14,8 +14,13 @@ extern char **_buildargv; extern char quitevent, appactive; -extern char *startwin_labeltext; - +// NOTE: these are implemented in game-land so they may be overridden in game specific ways +extern int startwin_open(void); +extern int startwin_close(void); +extern int startwin_puts(const char *); +extern int startwin_settitle(const char *); +extern int startwin_idle(void *); + // video extern long xres, yres, bpp, fullscreen, bytesperline, imageSize, frameplace; extern char offscreenrendering; @@ -96,7 +101,7 @@ unsigned long getticks(void); int gettimerfreq(void); void (*installusertimercallback(void (*callback)(void)))(void); -int checkvideomode(int *x, int *y, int c, int fs); +int checkvideomode(int *x, int *y, int c, int fs, int forced); int setvideomode(int x, int y, int c, int fs); void getvalidmodes(void); void resetvideomode(void); diff --git a/polymer/build/include/compat.h b/polymer/build/include/compat.h index 9d9e82d87..bae819d30 100644 --- a/polymer/build/include/compat.h +++ b/polymer/build/include/compat.h @@ -411,6 +411,7 @@ char *Bgetenv(const char *name); #endif char *Bgethomedir(void); +char *Bgetsupportdir(int global); unsigned int Bgetsysmemsize(void); int Bcorrectfilename(char *filename, int removefn); int Bcanonicalisefilename(char *filename, int removefn); diff --git a/polymer/build/include/editor.h b/polymer/build/include/editor.h index 130dfa3a2..6120e4e43 100644 --- a/polymer/build/include/editor.h +++ b/polymer/build/include/editor.h @@ -22,7 +22,7 @@ extern char somethingintab; extern char buildkeys[NUMBUILDKEYS]; -extern long ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d; +extern long ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d, forcesetup; extern int ExtInit(void); diff --git a/polymer/build/include/engineinfo.h b/polymer/build/include/engineinfo.h deleted file mode 100644 index 75adc1b4f..000000000 --- a/polymer/build/include/engineinfo.h +++ /dev/null @@ -1,6 +0,0 @@ -extern const char _engine_cflags[]; -extern const char _engine_libs[]; -extern const char _engine_uname[]; -extern const char _engine_compiler[]; -extern const char _engine_date[]; - diff --git a/polymer/build/include/gtkbits.h b/polymer/build/include/gtkbits.h index 08581b9c3..d073f2fda 100644 --- a/polymer/build/include/gtkbits.h +++ b/polymer/build/include/gtkbits.h @@ -5,11 +5,5 @@ extern void gtkbuild_init(int *argc, char ***argv); extern void gtkbuild_exit(int r); extern int gtkbuild_msgbox(char *name, char *msg); extern int gtkbuild_ynbox(char *name, char *msg); -extern void gtkbuild_create_startwin(void); -extern void gtkbuild_settitle_startwin(const char *title); -extern void gtkbuild_puts_startwin(const char *str); -extern void gtkbuild_close_startwin(void); -extern void gtkbuild_update_startwin(void); -extern void *gtkbuild_get_app_icon(void); #endif diff --git a/polymer/build/include/osxmain.h b/polymer/build/include/osxmain.h new file mode 100755 index 000000000..4683df57a --- /dev/null +++ b/polymer/build/include/osxmain.h @@ -0,0 +1,11 @@ +/* SDLMain.m - main entry point for our Cocoa-ized SDL app + Initial Version: Darrell Walisser + Non-NIB-Code & other changes: Max Horn + + Feel free to customize this file to suit your needs +*/ + +#import + +@interface SDLMain : NSObject +@end diff --git a/polymer/build/include/pragmas.h b/polymer/build/include/pragmas.h index df51e0f0c..9b4afa429 100644 --- a/polymer/build/include/pragmas.h +++ b/polymer/build/include/pragmas.h @@ -7,107 +7,7 @@ extern long dmval; -#if defined(NOASM) - -// -// Generic C -// - -#define qw(x) ((int64)(x)) // quadword cast -#define dw(x) ((long)(x)) // doubleword cast -#define wo(x) ((short)(x)) // word cast -#define by(x) ((char)(x)) // byte cast - -#define _scaler(a) \ -static inline long mulscale##a(long eax, long edx) \ -{ \ - return dw((qw(eax) * qw(edx)) >> a); \ -} \ -\ -static inline long divscale##a(long eax, long ebx) \ -{ \ - return dw((qw(eax) << a) / qw(ebx)); \ -} \ -\ -static inline long dmulscale##a(long eax, long edx, long esi, long edi) \ -{ \ - return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> a); \ -} \ -\ -static inline long tmulscale##a(long eax, long edx, long ebx, long ecx, long esi, long edi) \ -{ \ - return dw(((qw(eax) * qw(edx)) + (qw(ebx) * qw(ecx)) + (qw(esi) * qw(edi))) >> a); \ -} \ - -_scaler(1) _scaler(2) _scaler(3) _scaler(4) -_scaler(5) _scaler(6) _scaler(7) _scaler(8) -_scaler(9) _scaler(10) _scaler(11) _scaler(12) -_scaler(13) _scaler(14) _scaler(15) _scaler(16) -_scaler(17) _scaler(18) _scaler(19) _scaler(20) -_scaler(21) _scaler(22) _scaler(23) _scaler(24) -_scaler(25) _scaler(26) _scaler(27) _scaler(28) -_scaler(29) _scaler(30) _scaler(31) _scaler(32) - -static inline void swapchar(void* a, void* b) { char t = *((char*)b); *((char*)b) = *((char*)a); *((char*)a) = t; } -static inline void swapchar2(void* a, void* b, long s) { swapchar(a,b); swapchar((char*)a+1,(char*)b+s); } -static inline void swapshort(void* a, void* b) { short t = *((short*)b); *((short*)b) = *((short*)a); *((short*)a) = t; } -static inline void swaplong(void* a, void* b) { long t = *((long*)b); *((long*)b) = *((long*)a); *((long*)a) = t; } -static inline void swap64bit(void* a, void* b) { int64 t = *((int64*)b); *((int64*)b) = *((int64*)a); *((int64*)a) = t; } - -static inline char readpixel(void* s) { return (*((char*)(s))); } -static inline void drawpixel(void* s, char a) { *((char*)(s)) = a; } -static inline void drawpixels(void* s, short a) { *((short*)(s)) = a; } -static inline void drawpixelses(void* s, long a) { *((long*)(s)) = a; } - -static inline long mul3(long a) { return (a<<1)+a; } -static inline long mul5(long a) { return (a<<2)+a; } -static inline long mul9(long a) { return (a<<3)+a; } - -static inline long divmod(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a%_b; return _a/_b; } -static inline long moddiv(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a/_b; return _a%_b; } - -static inline long klabs(long a) { if (a < 0) return -a; return a; } -static inline long ksgn(long a) { if (a > 0) return 1; if (a < 0) return -1; return 0; } - -static inline long umin(long a, long b) { if ((unsigned long)a < (unsigned long)b) return a; return b; } -static inline long umax(long a, long b) { if ((unsigned long)a < (unsigned long)b) return b; return a; } -static inline long kmin(long a, long b) { if ((signed long)a < (signed long)b) return a; return b; } -static inline long kmax(long a, long b) { if ((signed long)a < (signed long)b) return b; return a; } - -static inline long sqr(long eax) { return (eax) * (eax); } -static inline long scale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) / qw(ecx)); } -static inline long mulscale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) >> by(ecx)); } -static inline long divscale(long eax, long ebx, long ecx) { return dw((qw(eax) << by(ecx)) / qw(ebx)); } -static inline long dmulscale(long eax, long edx, long esi, long edi, long ecx) { return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(ecx)); } - -static inline long boundmulscale(long a, long d, long c) -{ // courtesy of Ken - int64 p; - p = (((int64)a)*((int64)d))>>c; - if (p >= longlong(2147483647)) p = longlong(2147483647); - if (p < longlong(-2147483648)) p = longlong(-2147483648); - return((long)p); -} - -#undef qw -#undef dw -#undef wo -#undef by -#undef _scaler - -void qinterpolatedown16 (long bufptr, long num, long val, long add); -void qinterpolatedown16short (long bufptr, long num, long val, long add); - -void clearbuf(void* d, long c, long a); -void copybuf(void* s, void* d, long c); -void swapbuf4(void* a, void* b, long c); - -void clearbufbyte(void *D, long c, long a); -void copybufbyte(void *S, void *D, long c); -void copybufreverse(void *S, void *D, long c); - - -#elif defined(__GNUC__) && defined(__i386__) // NOASM +#if defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // // GCC Inline Assembler version @@ -1164,7 +1064,7 @@ void copybufreverse(void *S, void *D, long c); //}}} -#elif defined(__WATCOMC__) // __GNUC__ && __i386__ +#elif defined(__WATCOMC__) && !defined(NOASM) // __GNUC__ && __i386__ // // Watcom C inline assembler @@ -3014,7 +2914,7 @@ long swap64bit(void*,void*); long swapchar2(void*,void*,long); //}}} -#elif defined(_MSC_VER) // __WATCOMC__ +#elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__ // // Microsoft C inline assembler @@ -3023,31 +2923,39 @@ long swapchar2(void*,void*,long); //{{{ static __inline long sqr(long a) { - _asm mov eax, a - _asm imul eax, eax + _asm { + mov eax, a + imul eax, eax + } } static __inline long scale(long a, long d, long c) { - _asm mov eax, a - _asm imul d - _asm idiv c + _asm { + mov eax, a + imul d + idiv c + } } static __inline long mulscale(long a, long d, long c) { - _asm mov ecx, c - _asm mov eax, a - _asm imul d - _asm shrd eax, edx, cl + _asm { + mov ecx, c + mov eax, a + imul d + shrd eax, edx, cl + } } #define MULSCALE(x) \ static __inline long mulscale##x (long a, long d) \ { \ - _asm mov eax, a \ - _asm imul d \ - _asm shrd eax, edx, x \ + _asm { \ + mov eax, a \ + imul d \ + shrd eax, edx, x \ + } \ } MULSCALE(1) MULSCALE(2) MULSCALE(3) MULSCALE(4) @@ -3061,37 +2969,43 @@ MULSCALE(29) MULSCALE(30) MULSCALE(31) #undef MULSCALE static __inline long mulscale32(long a, long d) { - _asm mov eax, a - _asm imul d - _asm mov eax, edx + _asm { + mov eax, a + imul d + mov eax, edx + } } static __inline long dmulscale(long a, long d, long S, long D, long c) { - _asm mov ecx, c - _asm mov eax, a - _asm imul d - _asm mov ebx, eax - _asm mov eax, S - _asm mov esi, edx - _asm imul D - _asm add eax, ebx - _asm adc edx, esi - _asm shrd eax, edx, cl + _asm { + mov ecx, c + mov eax, a + imul d + mov ebx, eax + mov eax, S + mov esi, edx + imul D + add eax, ebx + adc edx, esi + shrd eax, edx, cl + } } #define DMULSCALE(x) \ static __inline long dmulscale##x (long a, long d, long S, long D) \ { \ - _asm mov eax, a \ - _asm imul d \ - _asm mov ebx, eax \ - _asm mov eax, S \ - _asm mov esi, edx \ - _asm imul D \ - _asm add eax, ebx \ - _asm adc edx, esi \ - _asm shrd eax, edx, x \ + _asm { \ + mov eax, a \ + imul d \ + mov ebx, eax \ + mov eax, S \ + mov esi, edx \ + imul D \ + add eax, ebx \ + adc edx, esi \ + shrd eax, edx, x \ + } \ } DMULSCALE(1) DMULSCALE(2) DMULSCALE(3) DMULSCALE(4) @@ -3105,33 +3019,38 @@ DMULSCALE(29) DMULSCALE(30) DMULSCALE(31) #undef DMULSCALE static __inline long dmulscale32(long a, long d, long S, long D) { - _asm mov eax, a - _asm imul d - _asm mov ebx, eax - _asm mov eax, S - _asm mov esi, edx - _asm imul D - _asm add eax, ebx - _asm adc edx, esi - _asm mov eax, edx + _asm { + mov eax, a + imul d + mov ebx, eax + mov eax, S + mov esi, edx + imul D + add eax, ebx + adc edx, esi + mov eax, edx + } } #define TMULSCALE(x) \ static __inline long tmulscale##x (long a, long d, long b, long c, long S, long D) \ { \ - _asm mov eax, a \ - _asm mov ebx, b \ - _asm imul d \ - _asm xchg eax, ebx \ - _asm mov ecx, c \ - _asm xchg edx, ecx \ - _asm imul edx \ - _asm add ebx, eax \ - _asm adc ecx, edx \ - _asm mov eax, S \ - _asm imul D \ - _asm add eax, ebx \ - _asm adc edx, ecx \ + _asm { \ + mov eax, a \ + mov ebx, b \ + imul d \ + xchg eax, ebx \ + mov ecx, c \ + xchg edx, ecx \ + imul edx \ + add ebx, eax \ + adc ecx, edx \ + mov eax, S \ + imul D \ + add eax, ebx \ + adc edx, ecx \ + shrd eax, edx, x \ + } \ } TMULSCALE(1) TMULSCALE(2) TMULSCALE(3) TMULSCALE(4) @@ -3145,89 +3064,102 @@ TMULSCALE(29) TMULSCALE(30) TMULSCALE(31) #undef TMULSCALE static __inline long tmulscale32(long a, long d, long b, long c, long S, long D) { - _asm mov eax, a - _asm mov ebx, b - _asm imul d - _asm xchg eax, ebx - _asm mov ecx, c - _asm xchg edx, ecx - _asm imul edx - _asm add ebx, eax - _asm adc ecx, edx - _asm mov eax, S - _asm imul D - _asm add eax, ebx - _asm adc edx, ecx - _asm mov eax, edx + _asm { + mov eax, a + mov ebx, b + imul d + xchg eax, ebx + mov ecx, c + xchg edx, ecx + imul edx + add ebx, eax + adc ecx, edx + mov eax, S + imul D + add eax, ebx + adc edx, ecx + mov eax, edx + } } static __inline long boundmulscale(long a, long b, long c) { - _asm mov eax, a - _asm mov ecx, c - _asm imul b - _asm mov ebx, edx - _asm shrd eax, edx, cl - _asm sar edx, cl - _asm xor edx, eax - _asm js checkit - _asm xor edx, eax - _asm jz skipboundit - _asm cmp edx, 0xffffffff - _asm je skipboundit + _asm { + mov eax, a + mov ecx, c + imul b + mov ebx, edx + shrd eax, edx, cl + sar edx, cl + xor edx, eax + js checkit + xor edx, eax + jz skipboundit + cmp edx, 0xffffffff + je skipboundit checkit: - _asm mov eax, ebx - _asm sar eax, 31 - _asm xor eax, 0x7fffffff + mov eax, ebx + sar eax, 31 + xor eax, 0x7fffffff skipboundit: - ; + } } static __inline long divscale(long a, long b, long c) { - _asm mov eax, a - _asm mov ecx, c - _asm mov edx, eax - _asm shl eax, cl - _asm neg cl - _asm sar edx, cl - _asm idiv b + _asm { + mov eax, a + mov ecx, c + mov edx, eax + shl eax, cl + neg cl + sar edx, cl + idiv b + } } static __inline long divscale1(long a, long b) { - _asm mov eax, a - _asm add eax, eax - _asm sbb edx, edx - _asm idiv b + _asm { + mov eax, a + add eax, eax + sbb edx, edx + idiv b + } } static __inline long divscale2(long a, long b) { - _asm mov eax, a - _asm mov edx, eax - _asm sar edx, 30 - _asm lea eax, [eax*4] - _asm idiv b + _asm { + mov eax, a + mov edx, eax + sar edx, 30 + lea eax, [eax*4] + idiv b + } } static __inline long divscale3(long a, long b) { - _asm mov eax, a - _asm mov edx, eax - _asm sar edx, 29 - _asm lea eax, [eax*8] - _asm idiv b + _asm { + mov eax, a + mov edx, eax + sar edx, 29 + lea eax, [eax*8] + idiv b + } } #define DIVSCALE(x,y) \ static __inline long divscale##y(long a, long b) \ { \ - _asm mov eax, a \ - _asm mov edx, eax \ - _asm sar edx, x \ - _asm shl eax, y \ - _asm idiv b \ + _asm { \ + mov eax, a \ + mov edx, eax \ + sar edx, x \ + shl eax, y \ + idiv b \ + } \ } DIVSCALE(28,4) DIVSCALE(27,5) DIVSCALE(26,6) DIVSCALE(25,7) @@ -3240,463 +3172,560 @@ DIVSCALE(4,28) DIVSCALE(3,29) DIVSCALE(2,30) DIVSCALE(1,31) static __inline long divscale32(long d, long b) { - _asm mov edx, d - _asm xor eax, eax - _asm idiv b + _asm { + mov edx, d + xor eax, eax + idiv b + } } static __inline char readpixel(void *d) { - _asm mov edx, d - _asm mov al, byte ptr [edx] + _asm { + mov edx, d + mov al, byte ptr [edx] + } } static __inline void drawpixel(void *d, char a) { - _asm mov edx, d - _asm mov al, a - _asm mov byte ptr [edx], al + _asm { + mov edx, d + mov al, a + mov byte ptr [edx], al + } } static __inline void drawpixels(void *d, short a) { - _asm mov edx, d - _asm mov ax, a - _asm mov word ptr [edx], ax + _asm { + mov edx, d + mov ax, a + mov word ptr [edx], ax + } } static __inline void drawpixelses(void *d, long a) { - _asm mov edx, d - _asm mov eax, a - _asm mov dword ptr [edx], eax + _asm { + mov edx, d + mov eax, a + mov dword ptr [edx], eax + } } static __inline void clearbuf(void *d, long c, long a) { - _asm mov edi, d - _asm mov ecx, c - _asm mov eax, a - _asm rep stosd + _asm { + mov edi, d + mov ecx, c + mov eax, a + rep stosd + } } static __inline void clearbufbyte(void *d, long c, long a) { - _asm mov edi, d - _asm mov ecx, c - _asm mov eax, a _asm { - cmp ecx, 4 - jae longcopy - test cl, 1 - jz preskip - stosb - } + mov edi, d + mov ecx, c + mov eax, a + cmp ecx, 4 + jae longcopy + test cl, 1 + jz preskip + stosb preskip: - _asm { - shr ecx, 1 - rep stosw - jmp endit - } + shr ecx, 1 + rep stosw + jmp endit longcopy: - _asm { - test edi, 1 - jz skip1 - stosb - dec ecx - } + test edi, 1 + jz skip1 + stosb + dec ecx skip1: - _asm { - test edi, 2 - jz skip2 - stosw - sub ecx, 2 - } + test edi, 2 + jz skip2 + stosw + sub ecx, 2 skip2: - _asm { - mov ebx, ecx - shr ecx, 2 - rep stosd - test bl, 2 - jz skip3 - stosw - } + mov ebx, ecx + shr ecx, 2 + rep stosd + test bl, 2 + jz skip3 + stosw skip3: - _asm { - test bl, 1 - jz endit - stosb - } + test bl, 1 + jz endit + stosb endit: - ; + } } static __inline void copybuf(void *s, void *d, long c) { - _asm mov esi, s - _asm mov edi, d - _asm mov ecx, c - _asm rep movsd + _asm { + mov esi, s + mov edi, d + mov ecx, c + rep movsd + } } static __inline void copybufbyte(void *s, void *d, long c) { - _asm mov esi, s - _asm mov edi, d - _asm mov ecx, c _asm { - cmp ecx, 4 - jae longcopy - test cl, 1 - jz preskip - movsb - } + mov esi, s + mov edi, d + mov ecx, c + cmp ecx, 4 + jae longcopy + test cl, 1 + jz preskip + movsb preskip: - _asm { - shr ecx, 1 - rep movsw - jmp endit - } + shr ecx, 1 + rep movsw + jmp endit longcopy: - _asm { - test edi, 1 - jz skip1 - movsb - dec ecx - } + test edi, 1 + jz skip1 + movsb + dec ecx skip1: - _asm { - test edi, 2 - jz skip2 - movsw - sub ecx, 2 - } + test edi, 2 + jz skip2 + movsw + sub ecx, 2 skip2: - _asm { - mov ebx, ecx - shr ecx, 2 - rep movsd - test bl, 2 - jz skip3 - movsw - } + mov ebx, ecx + shr ecx, 2 + rep movsd + test bl, 2 + jz skip3 + movsw skip3: - _asm { - test bl, 1 - jz endit - movsb - } + test bl, 1 + jz endit + movsb endit: - ; + } } static __inline void copybufreverse(void *s, void *d, long c) { - _asm mov esi, s - _asm mov edi, d - _asm mov ecx, c _asm { - shr ecx, 1 - jnc skipit1 - mov al, byte ptr [esi] - dec esi - mov byte ptr [edi], al - inc edi - } + mov esi, s + mov edi, d + mov ecx, c + shr ecx, 1 + jnc skipit1 + mov al, byte ptr [esi] + dec esi + mov byte ptr [edi], al + inc edi skipit1: - _asm { - shr ecx, 1 - jnc skipit2 - mov ax, word ptr [esi-1] - sub esi, 2 - ror ax, 8 - mov word ptr [edi], ax - add edi, 2 - } + shr ecx, 1 + jnc skipit2 + mov ax, word ptr [esi-1] + sub esi, 2 + ror ax, 8 + mov word ptr [edi], ax + add edi, 2 skipit2: - _asm { - test ecx, ecx - jz endloop - } + test ecx, ecx + jz endloop begloop: - _asm { - mov eax, dword ptr [esi-3] - sub esi, 4 - bswap eax - mov dword ptr [edi], eax - add edi, 4 - dec ecx - jnz begloop - } + mov eax, dword ptr [esi-3] + sub esi, 4 + bswap eax + mov dword ptr [edi], eax + add edi, 4 + dec ecx + jnz begloop endloop: - ; + } } static __inline void qinterpolatedown16(long a, long c, long d, long s) { - _asm mov eax, a - _asm mov ecx, c - _asm mov edx, d - _asm mov esi, s _asm { - mov ebx, ecx - shr ecx, 1 - jz skipbegcalc - } + mov eax, a + mov ecx, c + mov edx, d + mov esi, s + mov ebx, ecx + shr ecx, 1 + jz skipbegcalc begqcalc: - _asm { - lea edi, [edx+esi] - sar edx, 16 - mov dword ptr [eax], edx - lea edx, [edi+esi] - sar edi, 16 - mov dword ptr [eax+4], edi - add eax, 8 - dec ecx - jnz begqcalc - test ebx, 1 - jz skipbegqcalc2 - } + lea edi, [edx+esi] + sar edx, 16 + mov dword ptr [eax], edx + lea edx, [edi+esi] + sar edi, 16 + mov dword ptr [eax+4], edi + add eax, 8 + dec ecx + jnz begqcalc + test ebx, 1 + jz skipbegqcalc2 skipbegcalc: - _asm { - sar edx, 16 - mov dword ptr [eax], edx - } + sar edx, 16 + mov dword ptr [eax], edx skipbegqcalc2: - ; + } } static __inline void qinterpolatedown16short(long a, long c, long d, long s) { - _asm mov eax, a - _asm mov ecx, c - _asm mov edx, d - _asm mov esi, s _asm { - test ecx, ecx - jz endit - test al, 2 - jz skipalignit - mov ebx, edx - sar ebx, 16 - mov word ptr [eax], bx - add edx, esi - add eax, 2 - dec ecx - jz endit - } + mov eax, a + mov ecx, c + mov edx, d + mov esi, s + test ecx, ecx + jz endit + test al, 2 + jz skipalignit + mov ebx, edx + sar ebx, 16 + mov word ptr [eax], bx + add edx, esi + add eax, 2 + dec ecx + jz endit skipalignit: - _asm { - sub ecx, 2 - jc finishit - } + sub ecx, 2 + jc finishit begqcalc: - _asm { - mov ebx, edx - add edx, esi - sar ebx, 16 - mov edi, edx - and edi, 0ffff0000h - add edx, esi - add ebx, edi - mov dword ptr [eax], ebx - add eax, 4 - sub ecx, 2 - jnc begqcalc - test cl, 1 - jz endit - } + mov ebx, edx + add edx, esi + sar ebx, 16 + mov edi, edx + and edi, 0ffff0000h + add edx, esi + add ebx, edi + mov dword ptr [eax], ebx + add eax, 4 + sub ecx, 2 + jnc begqcalc + test cl, 1 + jz endit finishit: - _asm { - mov ebx, edx - sar ebx, 16 - mov word ptr [eax], bx - } + mov ebx, edx + sar ebx, 16 + mov word ptr [eax], bx endit: - ; + } } static __inline long mul3(long a) { - _asm mov eax, a - _asm lea eax, [eax+eax*2] + _asm { + mov eax, a + lea eax, [eax+eax*2] + } } static __inline long mul5(long a) { - _asm mov eax, a - _asm lea eax, [eax+eax*4] + _asm { + mov eax, a + lea eax, [eax+eax*4] + } } static __inline long mul9(long a) { - _asm mov eax, a - _asm lea eax, [eax+eax*8] + _asm { + mov eax, a + lea eax, [eax+eax*8] + } } //returns eax/ebx, dmval = eax%edx; static __inline long divmod(long a, long b) { - _asm mov eax, a - _asm xor edx, edx - _asm div b - _asm mov dmval, edx + _asm { + mov eax, a + xor edx, edx + div b + mov dmval, edx + } } //returns eax%ebx, dmval = eax/edx; static __inline long moddiv(long a, long b) { - _asm mov eax, a - _asm xor edx, edx - _asm div b - _asm mov dmval, eax - _asm mov eax, edx + _asm { + mov eax, a + xor edx, edx + div b + mov dmval, eax + mov eax, edx + } } static __inline long klabs(long a) { - _asm mov eax, a - _asm test eax, eax - _asm jns skipnegate - _asm neg eax + _asm { + mov eax, a + test eax, eax + jns skipnegate + neg eax skipnegate: - ; + } } static __inline long ksgn(long b) { - _asm mov ebx, b - _asm add ebx, ebx - _asm sbb eax, eax - _asm cmp eax, ebx - _asm adc al, 0 + _asm { + mov ebx, b + add ebx, ebx + sbb eax, eax + cmp eax, ebx + adc al, 0 + } } //eax = (unsigned min)umin(eax,ebx) static __inline long umin(long a, long b) { - _asm mov eax, a - _asm sub eax, b - _asm sbb ecx, ecx - _asm and eax, ecx - _asm add eax, b + _asm { + mov eax, a + sub eax, b + sbb ecx, ecx + and eax, ecx + add eax, b + } } //eax = (unsigned max)umax(eax,ebx) static __inline long umax(long a, long b) { - _asm mov eax, a - _asm sub eax, b - _asm sbb ecx, ecx - _asm xor ecx, 0xffffffff - _asm and eax, ecx - _asm add eax, b + _asm { + mov eax, a + sub eax, b + sbb ecx, ecx + xor ecx, 0xffffffff + and eax, ecx + add eax, b + } } static __inline long kmin(long a, long b) { - _asm mov eax, a - _asm mov ebx, b - _asm cmp eax, ebx - _asm jl skipit - _asm mov eax, ebx + _asm { + mov eax, a + mov ebx, b + cmp eax, ebx + jl skipit + mov eax, ebx skipit: - ; + } } static __inline long kmax(long a, long b) { - _asm mov eax, a - _asm mov ebx, b - _asm cmp eax, ebx - _asm jg skipit - _asm mov eax, ebx + _asm { + mov eax, a + mov ebx, b + cmp eax, ebx + jg skipit + mov eax, ebx skipit: - ; + } } static __inline void swapchar(void *a, void *b) { - _asm mov eax, a - _asm mov ebx, b - _asm mov cl, [eax] - _asm mov ch, [ebx] - _asm mov [ebx], cl - _asm mov [eax], ch + _asm { + mov eax, a + mov ebx, b + mov cl, [eax] + mov ch, [ebx] + mov [ebx], cl + mov [eax], ch + } } static __inline void swapshort(void *a, void *b) { - _asm mov eax, a - _asm mov ebx, b - _asm mov cx, [eax] - _asm mov dx, [ebx] - _asm mov [ebx], cx - _asm mov [eax], dx + _asm { + mov eax, a + mov ebx, b + mov cx, [eax] + mov dx, [ebx] + mov [ebx], cx + mov [eax], dx + } } static __inline void swaplong(void *a, void *b) { - _asm mov eax, a - _asm mov ebx, b - _asm mov ecx, [eax] - _asm mov edx, [ebx] - _asm mov [ebx], ecx - _asm mov [eax], edx + _asm { + mov eax, a + mov ebx, b + mov ecx, [eax] + mov edx, [ebx] + mov [ebx], ecx + mov [eax], edx + } } static __inline void swapbuf4(void *a, void *b, long c) { - _asm mov eax, a - _asm mov ebx, b - _asm mov ecx, c - begswap: _asm { - mov esi, [eax] - mov edi, [ebx] - mov [ebx], esi - mov [eax], edi - add eax, 4 - add ebx, 4 - dec ecx - jnz short begswap + mov eax, a + mov ebx, b + mov ecx, c + begswap: + mov esi, [eax] + mov edi, [ebx] + mov [ebx], esi + mov [eax], edi + add eax, 4 + add ebx, 4 + dec ecx + jnz short begswap } } static __inline void swap64bit(void *a, void *b) { - _asm mov eax, a - _asm mov ebx, b - _asm mov ecx, [eax] - _asm mov edx, [ebx] - _asm mov [ebx], ecx - _asm mov ecx, [eax+4] - _asm mov [eax], edx - _asm mov edx, [ebx+4] - _asm mov [ebx+4], ecx - _asm mov [eax+4], edx + _asm { + mov eax, a + mov ebx, b + mov ecx, [eax] + mov edx, [ebx] + mov [ebx], ecx + mov ecx, [eax+4] + mov [eax], edx + mov edx, [ebx+4] + mov [ebx+4], ecx + mov [eax+4], edx + } } //swapchar2(ptr1,ptr2,xsiz); is the same as: //swapchar(ptr1,ptr2); swapchar(ptr1+1,ptr2+xsiz); static __inline void swapchar2(void *a, void *b, long s) { - _asm mov eax, a - _asm mov ebx, b - _asm mov esi, s - _asm add esi, ebx - _asm mov cx, [eax] - _asm mov dl, [ebx] - _asm mov [ebx], cl - _asm mov dh, [esi] - _asm mov [esi], ch - _asm mov [eax], dx + _asm { + mov eax, a + mov ebx, b + mov esi, s + add esi, ebx + mov cx, [eax] + mov dl, [ebx] + mov [ebx], cl + mov dh, [esi] + mov [esi], ch + mov [eax], dx + } } //}}} #else // _MSC_VER -#error Unsupported compiler or architecture. +// +// Generic C +// + +#define qw(x) ((int64)(x)) // quadword cast +#define dw(x) ((long)(x)) // doubleword cast +#define wo(x) ((short)(x)) // word cast +#define by(x) ((char)(x)) // byte cast + +#define _scaler(a) \ +static inline long mulscale##a(long eax, long edx) \ +{ \ + return dw((qw(eax) * qw(edx)) >> a); \ +} \ +\ +static inline long divscale##a(long eax, long ebx) \ +{ \ + return dw((qw(eax) << a) / qw(ebx)); \ +} \ +\ +static inline long dmulscale##a(long eax, long edx, long esi, long edi) \ +{ \ + return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> a); \ +} \ +\ +static inline long tmulscale##a(long eax, long edx, long ebx, long ecx, long esi, long edi) \ +{ \ + return dw(((qw(eax) * qw(edx)) + (qw(ebx) * qw(ecx)) + (qw(esi) * qw(edi))) >> a); \ +} \ + +_scaler(1) _scaler(2) _scaler(3) _scaler(4) +_scaler(5) _scaler(6) _scaler(7) _scaler(8) +_scaler(9) _scaler(10) _scaler(11) _scaler(12) +_scaler(13) _scaler(14) _scaler(15) _scaler(16) +_scaler(17) _scaler(18) _scaler(19) _scaler(20) +_scaler(21) _scaler(22) _scaler(23) _scaler(24) +_scaler(25) _scaler(26) _scaler(27) _scaler(28) +_scaler(29) _scaler(30) _scaler(31) _scaler(32) + +static inline void swapchar(void* a, void* b) { char t = *((char*)b); *((char*)b) = *((char*)a); *((char*)a) = t; } +static inline void swapchar2(void* a, void* b, long s) { swapchar(a,b); swapchar((char*)a+1,(char*)b+s); } +static inline void swapshort(void* a, void* b) { short t = *((short*)b); *((short*)b) = *((short*)a); *((short*)a) = t; } +static inline void swaplong(void* a, void* b) { long t = *((long*)b); *((long*)b) = *((long*)a); *((long*)a) = t; } +static inline void swap64bit(void* a, void* b) { int64 t = *((int64*)b); *((int64*)b) = *((int64*)a); *((int64*)a) = t; } + +static inline char readpixel(void* s) { return (*((char*)(s))); } +static inline void drawpixel(void* s, char a) { *((char*)(s)) = a; } +static inline void drawpixels(void* s, short a) { *((short*)(s)) = a; } +static inline void drawpixelses(void* s, long a) { *((long*)(s)) = a; } + +static inline long mul3(long a) { return (a<<1)+a; } +static inline long mul5(long a) { return (a<<2)+a; } +static inline long mul9(long a) { return (a<<3)+a; } + +static inline long divmod(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a%_b; return _a/_b; } +static inline long moddiv(long a, long b) { unsigned long _a=(unsigned long)a, _b=(unsigned long)b; dmval = _a/_b; return _a%_b; } + +static inline long klabs(long a) { if (a < 0) return -a; return a; } +static inline long ksgn(long a) { if (a > 0) return 1; if (a < 0) return -1; return 0; } + +static inline long umin(long a, long b) { if ((unsigned long)a < (unsigned long)b) return a; return b; } +static inline long umax(long a, long b) { if ((unsigned long)a < (unsigned long)b) return b; return a; } +static inline long kmin(long a, long b) { if ((signed long)a < (signed long)b) return a; return b; } +static inline long kmax(long a, long b) { if ((signed long)a < (signed long)b) return b; return a; } + +static inline long sqr(long eax) { return (eax) * (eax); } +static inline long scale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) / qw(ecx)); } +static inline long mulscale(long eax, long edx, long ecx) { return dw((qw(eax) * qw(edx)) >> by(ecx)); } +static inline long divscale(long eax, long ebx, long ecx) { return dw((qw(eax) << by(ecx)) / qw(ebx)); } +static inline long dmulscale(long eax, long edx, long esi, long edi, long ecx) { return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(ecx)); } + +static inline long boundmulscale(long a, long d, long c) +{ // courtesy of Ken + int64 p; + p = (((int64)a)*((int64)d))>>c; + if (p >= longlong(2147483647)) p = longlong(2147483647); + if (p < longlong(-2147483648)) p = longlong(-2147483648); + return((long)p); +} + +#undef qw +#undef dw +#undef wo +#undef by +#undef _scaler + +void qinterpolatedown16 (long bufptr, long num, long val, long add); +void qinterpolatedown16short (long bufptr, long num, long val, long add); + +void clearbuf(void* d, long c, long a); +void copybuf(void* s, void* d, long c); +void swapbuf4(void* a, void* b, long c); + +void clearbufbyte(void *D, long c, long a); +void copybufbyte(void *S, void *D, long c); +void copybufreverse(void *S, void *D, long c); #endif diff --git a/polymer/build/include/startwin.editor.h b/polymer/build/include/startwin.editor.h new file mode 100755 index 000000000..de855590b --- /dev/null +++ b/polymer/build/include/startwin.editor.h @@ -0,0 +1,19 @@ +// resource ids +#define WIN_STARTWIN 1000 +#define WIN_STARTWINPAGE_CONFIG 2000 +#define WIN_STARTWIN_BITMAP 100 // banner bitmap +#define WIN_STARTWIN_TABCTL 101 +#define WIN_STARTWIN_CANCEL 102 +#define WIN_STARTWIN_START 103 + +#define WIN_STARTWIN_MESSAGES 104 // output list box + +#define RSRC_ICON 100 +#define RSRC_BMP 200 + +// config page +#define IDCFULLSCREEN 100 +#define IDC2DVMODE 101 +#define IDC3DVMODE 102 +#define IDCALWAYSSHOW 103 + diff --git a/polymer/build/include/winlayer.h b/polymer/build/include/winlayer.h index 415b4f74c..a25bde625 100644 --- a/polymer/build/include/winlayer.h +++ b/polymer/build/include/winlayer.h @@ -13,37 +13,9 @@ extern int glusecds; long win_gethwnd(void); long win_gethinstance(void); -// resource ids -#define WIN_STARTWIN 1000 -#define WIN_STARTWIN_ITEMBITMAP 100 // banner bitmap -#define WIN_STARTWIN_ITEMTEXT 101 // text header -#define WIN_STARTWIN_ITEMLIST 102 // output list box -#define WIN_STARTWINBMP 200 - - // *hwnd - receives the window handle to the startup dialog box - // saferect[] - receives the safe area to draw controls over (l,t,w,h) - // onclose - called before the startup window closes - // returns 0 if successful, 1 if the window isn't open -int win_getstartupwin(long *hwnd, long saferect[4], void (*onclose)(void)); -int win_getstartupcommand(void); - void win_allowtaskswitching(int onf); int win_checkinstance(void); -/* -#ifdef KENBUILD -#define DISCLAIMER "IMPORTANT:\n" \ - "\tThis is a source port by Jonathon Fowler (jonof@edgenetwk.com) of the Build Engine, " \ - "editor and test game by Ken Silverman to the Windows and Linux operating systems. It is " \ - "distributed under the terms listed in BUILDLIC.TXT included with this package." -#endif -#ifdef DUKE3D -#define DISCLAIMER "IMPORTANT:\n" \ - "\tThis port of Duke Nukem 3D was done by Jonathon Fowler (jonof@edgenetwk.com) and is not " \ - "endorsed or supported by 3D Realms or Apogee. They will not provide support for it. Visit " \ - "http://jonof.edgenetwk.com/buildport/duke3d/ for details." -#endif -*/ #include "baselayer.h" #else diff --git a/polymer/build/src/StartupWinController.editor.m b/polymer/build/src/StartupWinController.editor.m new file mode 100755 index 000000000..9723b8cb2 --- /dev/null +++ b/polymer/build/src/StartupWinController.editor.m @@ -0,0 +1,189 @@ +#import + +#include "baselayer.h" + +@interface StartupWinController : NSWindowController +{ + IBOutlet NSButton *alwaysShowButton; + IBOutlet NSButton *fullscreenButton; + IBOutlet NSTextView *messagesView; + IBOutlet NSTabView *tabView; + IBOutlet NSComboBox *videoModeCbox; + + IBOutlet NSButton *cancelButton; + IBOutlet NSButton *startButton; +} + +- (IBAction)alwaysShowClicked:(id)sender; +- (IBAction)fullscreenClicked:(id)sender; + +- (IBAction)cancel:(id)sender; +- (IBAction)start:(id)sender; + +- (void)setupRunMode; +- (void)setupMessagesMode; +- (void)putsMessage:(NSString *)str; +- (void)setTitle:(NSString *)str; +@end + +@implementation StartupWinController + +- (IBAction)alwaysShowClicked:(id)sender +{ +} + +- (IBAction)fullscreenClicked:(id)sender +{ + // XXX: recalculate the video modes list to take into account the fullscreen status +} + +- (IBAction)cancel:(id)sender +{ + [NSApp abortModal]; +} + +- (IBAction)start:(id)sender +{ + // XXX: write the states of the form controls to their respective homes + [NSApp stopModal]; +} + +- (void)setupRunMode +{ + // XXX: populate the lists and set everything up to represent the current options + + // enable all the controls on the Configuration page + NSEnumerator *enumerator = [[[[tabView tabViewItemAtIndex:0] view] subviews] objectEnumerator]; + NSControl *control; + while (control = [enumerator nextObject]) + [control setEnabled:true]; + + [cancelButton setEnabled:true]; + [startButton setEnabled:true]; + + [tabView selectTabViewItemAtIndex:0]; +} + +- (void)setupMessagesMode +{ + [tabView selectTabViewItemAtIndex:1]; + + // disable all the controls on the Configuration page except "always show", so the + // user can enable it if they want to while waiting for something else to happen + NSEnumerator *enumerator = [[[[tabView tabViewItemAtIndex:0] view] subviews] objectEnumerator]; + NSControl *control; + while (control = [enumerator nextObject]) { + if (control == alwaysShowButton) continue; + [control setEnabled:false]; + } + + [cancelButton setEnabled:false]; + [startButton setEnabled:false]; +} + +- (void)putsMessage:(NSString *)str +{ + NSRange end; + NSTextStorage *text = [messagesView textStorage]; + BOOL shouldAutoScroll; + + shouldAutoScroll = ((int)NSMaxY([messagesView bounds]) == (int)NSMaxY([messagesView visibleRect])); + + end.location = [text length]; + end.length = 0; + + [text beginEditing]; + [messagesView replaceCharactersInRange:end withString:str]; + [text endEditing]; + + if (shouldAutoScroll) { + end.location = [text length]; + end.length = 0; + [messagesView scrollRangeToVisible:end]; + } +} + +- (void)setTitle:(NSString *)str +{ + [[self window] setTitle:str]; +} + +@end + +static StartupWinController *startwin = nil; + +int startwin_open(void) +{ + if (startwin != nil) return 1; + + startwin = [[StartupWinController alloc] initWithWindowNibName:@"startwin.editor"]; + if (startwin == nil) return -1; + + [startwin showWindow:nil]; + [startwin setupMessagesMode]; + + return 0; +} + +int startwin_close(void) +{ + if (startwin == nil) return 1; + + [startwin close]; + startwin = nil; + + return 0; +} + +int startwin_puts(const char *s) +{ + NSString *ns; + + if (!s) return -1; + if (startwin == nil) return 1; + + ns = [[NSString alloc] initWithCString:s]; + [startwin putsMessage:ns]; + [ns release]; + + return 0; +} + +int startwin_settitle(const char *s) +{ + NSString *ns; + + if (!s) return -1; + if (startwin == nil) return 1; + + ns = [[NSString alloc] initWithCString:s]; + [startwin setTitle:ns]; + [ns release]; + + return 0; +} + +int startwin_idle(void *v) +{ + if (startwin) [[startwin window] displayIfNeeded]; + return 0; +} + +int startwin_run(void) +{ + int retval; + + if (startwin == nil) return 0; + + [startwin setupRunMode]; + + switch ([NSApp runModalForWindow:[startwin window]]) { + case NSRunStoppedResponse: retval = 1; break; + case NSRunAbortedResponse: retval = 0; break; + default: retval = -1; + } + + [startwin setupMessagesMode]; + + return retval; +} diff --git a/polymer/build/src/StartupWinController.game.m b/polymer/build/src/StartupWinController.game.m new file mode 100755 index 000000000..2581fbebe --- /dev/null +++ b/polymer/build/src/StartupWinController.game.m @@ -0,0 +1,189 @@ +#import + +#include "baselayer.h" + +@interface StartupWinController : NSWindowController +{ + IBOutlet NSButton *alwaysShowButton; + IBOutlet NSButton *fullscreenButton; + IBOutlet NSTextView *messagesView; + IBOutlet NSTabView *tabView; + IBOutlet NSComboBox *videoModeCbox; + + IBOutlet NSButton *cancelButton; + IBOutlet NSButton *startButton; +} + +- (IBAction)alwaysShowClicked:(id)sender; +- (IBAction)fullscreenClicked:(id)sender; + +- (IBAction)cancel:(id)sender; +- (IBAction)start:(id)sender; + +- (void)setupRunMode; +- (void)setupMessagesMode; +- (void)putsMessage:(NSString *)str; +- (void)setTitle:(NSString *)str; +@end + +@implementation StartupWinController + +- (IBAction)alwaysShowClicked:(id)sender +{ +} + +- (IBAction)fullscreenClicked:(id)sender +{ + // XXX: recalculate the video modes list to take into account the fullscreen status +} + +- (IBAction)cancel:(id)sender +{ + [NSApp abortModal]; +} + +- (IBAction)start:(id)sender +{ + // XXX: write the states of the form controls to their respective homes + [NSApp stopModal]; +} + +- (void)setupRunMode +{ + // XXX: populate the lists and set everything up to represent the current options + + // enable all the controls on the Configuration page + NSEnumerator *enumerator = [[[[tabView tabViewItemAtIndex:0] view] subviews] objectEnumerator]; + NSControl *control; + while (control = [enumerator nextObject]) + [control setEnabled:true]; + + [cancelButton setEnabled:true]; + [startButton setEnabled:true]; + + [tabView selectTabViewItemAtIndex:0]; +} + +- (void)setupMessagesMode +{ + [tabView selectTabViewItemAtIndex:1]; + + // disable all the controls on the Configuration page except "always show", so the + // user can enable it if they want to while waiting for something else to happen + NSEnumerator *enumerator = [[[[tabView tabViewItemAtIndex:0] view] subviews] objectEnumerator]; + NSControl *control; + while (control = [enumerator nextObject]) { + if (control == alwaysShowButton) continue; + [control setEnabled:false]; + } + + [cancelButton setEnabled:false]; + [startButton setEnabled:false]; +} + +- (void)putsMessage:(NSString *)str +{ + NSRange end; + NSTextStorage *text = [messagesView textStorage]; + BOOL shouldAutoScroll; + + shouldAutoScroll = ((int)NSMaxY([messagesView bounds]) == (int)NSMaxY([messagesView visibleRect])); + + end.location = [text length]; + end.length = 0; + + [text beginEditing]; + [messagesView replaceCharactersInRange:end withString:str]; + [text endEditing]; + + if (shouldAutoScroll) { + end.location = [text length]; + end.length = 0; + [messagesView scrollRangeToVisible:end]; + } +} + +- (void)setTitle:(NSString *)str +{ + [[self window] setTitle:str]; +} + +@end + +static StartupWinController *startwin = nil; + +int startwin_open(void) +{ + if (startwin != nil) return 1; + + startwin = [[StartupWinController alloc] initWithWindowNibName:@"startwin.game"]; + if (startwin == nil) return -1; + + [startwin showWindow:nil]; + [startwin setupMessagesMode]; + + return 0; +} + +int startwin_close(void) +{ + if (startwin == nil) return 1; + + [startwin close]; + startwin = nil; + + return 0; +} + +int startwin_puts(const char *s) +{ + NSString *ns; + + if (!s) return -1; + if (startwin == nil) return 1; + + ns = [[NSString alloc] initWithCString:s]; + [startwin putsMessage:ns]; + [ns release]; + + return 0; +} + +int startwin_settitle(const char *s) +{ + NSString *ns; + + if (!s) return -1; + if (startwin == nil) return 1; + + ns = [[NSString alloc] initWithCString:s]; + [startwin setTitle:ns]; + [ns release]; + + return 0; +} + +int startwin_idle(void *v) +{ + if (startwin) [[startwin window] displayIfNeeded]; + return 0; +} + +int startwin_run(void) +{ + int retval; + + if (startwin == nil) return 0; + + [startwin setupRunMode]; + + switch ([NSApp runModalForWindow:[startwin window]]) { + case NSRunStoppedResponse: retval = 1; break; + case NSRunAbortedResponse: retval = 0; break; + default: retval = -1; + } + + [startwin setupMessagesMode]; + + return retval; +} diff --git a/polymer/build/src/baselayer.c b/polymer/build/src/baselayer.c index 98482c283..9999f7479 100644 --- a/polymer/build/src/baselayer.c +++ b/polymer/build/src/baselayer.c @@ -1,7 +1,6 @@ #include "compat.h" #include "osd.h" #include "build.h" -#include "engineinfo.h" #include "baselayer.h" #ifdef RENDERTYPEWIN @@ -25,24 +24,6 @@ struct glinfo glinfo = { }; #endif -static int osdfunc_dumpbuildinfo(const osdfuncparm_t *parm) -{ - OSD_Printf( - "Build engine compilation:\n" - " CFLAGS: %s\n" - " LIBS: %s\n" - " Host: %s\n" - " Compiler: %s\n" - " Built: %s\n", - _engine_cflags, - _engine_libs, - _engine_uname, - _engine_compiler, - _engine_date); - - return OSDCMD_OK; -} - static void onvideomodechange(int newmode) { } void (*baselayer_onvideomodechange)(int) = onvideomodechange; @@ -188,7 +169,6 @@ int baselayer_init(void) , osdfunc_setrendermode); #endif - OSD_RegisterFunction("dumpbuildinfo","dumpbuildinfo: outputs engine compilation information",osdfunc_dumpbuildinfo); OSD_RegisterFunction("screencaptureformat","screencaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars); #ifdef SUPERBUILD OSD_RegisterFunction("novoxmips","novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",osdcmd_vars); diff --git a/polymer/build/src/build.c b/polymer/build/src/build.c index 06279976a..47b62f275 100644 --- a/polymer/build/src/build.c +++ b/polymer/build/src/build.c @@ -81,6 +81,7 @@ extern long startposx, startposy, startposz; extern short startang, startsectnum; extern long frameplace, ydim16, halfxdim16, midydim16; long xdim2d = 640, ydim2d = 480, xdimgame = 640, ydimgame = 480, bppgame = 8; +long forcesetup = 1; extern long cachesize, artsize; @@ -237,14 +238,12 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm) return OSDCMD_OK; } -#ifdef RENDERTYPEWIN -int DoLaunchWindow(int initval); // buildstartwin.c -#endif +extern int startwin_run(void); extern char *defsfilename; // set in bstub.c int app_main(int argc, char **argv) { - char ch, quitflag, forcesetup = 0, grpstoadd = 0; + char ch, quitflag, cmdsetup = 0, grpstoadd = 0; char **grps = NULL; long i, j, k; @@ -267,7 +266,7 @@ int app_main(int argc, char **argv) boardfilename[0] = 0; for (i=1; i 0) { diff --git a/polymer/build/src/buildstartwin.c b/polymer/build/src/buildstartwin.c deleted file mode 100644 index 1971ddd42..000000000 --- a/polymer/build/src/buildstartwin.c +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef RENDERTYPEWIN -#error Only for Windows -#endif - -#include "build.h" -#include "editor.h" -#include "winlayer.h" -#include "compat.h" - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include - - -#define IDCFULLSCREEN 100 -#define IDC2DVMODE 101 -#define IDC3DVMODE 102 - -static void PopulateVideoModeLists(int fs, HWND list2d, HWND list3d) -{ - int i,j; - char buf[64]; - - ComboBox_ResetContent(list2d); - ComboBox_ResetContent(list3d); - for (i=0; i 0) { - if (!IsWindow(hwndLaunch) || quitevent) break; - if (IsDialogMessage(hwndStart, &msg) /*|| IsDialogMessage(hwndLaunch, &msg)*/) continue; - - TranslateMessage(&msg); - DispatchMessage(&msg); - } -#else - while (IsWindow(hwndLaunch) && !quitevent) { - x = win_getstartupcommand(); - if (x != 0) LaunchWindowProc(hwndLaunch, WM_COMMAND, x, 0); - handleevents(); - } -#endif - EnableWindow(GetDlgItem(hwndStart,WIN_STARTWIN_ITEMLIST),TRUE); - } - if (quitevent) return 1; - return 0; -} - diff --git a/polymer/build/src/compat.c b/polymer/build/src/compat.c index c45d7066b..d9ef2c66e 100644 --- a/polymer/build/src/compat.c +++ b/polymer/build/src/compat.c @@ -26,6 +26,11 @@ #include #include +#ifdef __APPLE__ +# include +# include +#endif + #if defined(__WATCOMC__) # include #elif defined(_MSC_VER) @@ -327,15 +332,25 @@ char *Bgethomedir(void) #ifdef _WIN32 TCHAR appdata[MAX_PATH]; - //# if defined SHGetFolderPath - // if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, appdata))) - //# if defined SHGetSpecialFolderPath if (SUCCEEDED(SHGetSpecialFolderPathA(NULL, appdata, CSIDL_APPDATA, FALSE))) - //# else - //# error Cannot find SHGetFolderPath or SHGetSpecialFolderPath. Perhaps your shlobj.h is ancient? - //# endif return strdup(appdata); return NULL; +#elif defined __APPLE__ + FSRef ref; + CFStringRef str; + CFURLRef base; + char *s; + + if (FSFindFolder(kUserDomain, kVolumeRootFolderType, kDontCreateFolder, &ref) < 0) return NULL; + base = CFURLCreateFromFSRef(NULL, &ref); + if (!base) return NULL; + str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle); + CFRelease(base); + if (!str) return NULL; + s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding()); + if (s) s = strdup(s); + CFRelease(str); + return s; #else char *e = getenv("HOME"); if (!e) return NULL; @@ -343,6 +358,31 @@ char *Bgethomedir(void) #endif } +char *Bgetsupportdir(int global) +{ +#ifndef __APPLE__ + return Bgethomedir(); +#else + FSRef ref; + CFStringRef str; + CFURLRef base; + char *s; + + if (FSFindFolder(global ? kLocalDomain : kUserDomain, + kApplicationSupportFolderType, + kDontCreateFolder, &ref) < 0) return NULL; + base = CFURLCreateFromFSRef(NULL, &ref); + if (!base) return NULL; + str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle); + CFRelease(base); + if (!str) return NULL; + s = (char*)CFStringGetCStringPtr(str,CFStringGetSystemEncoding()); + if (s) s = strdup(s); + CFRelease(str); + return s; +#endif +} + int Bcorrectfilename(char *filename, int removefn) { char *fn; diff --git a/polymer/build/src/config.c b/polymer/build/src/config.c index 02a9089f1..b8a38de19 100644 --- a/polymer/build/src/config.c +++ b/polymer/build/src/config.c @@ -106,6 +106,7 @@ int loadsetup(const char *fn) if ((fp = Bfopen(fn, "rt")) == NULL) return -1; +if (readconfig(fp, "forcesetup", val, VL) > 0) { if (Batoi(val) != 0) forcesetup = 1; else forcesetup = 0; } if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; } if (readconfig(fp, "resolution", val, VL) > 0) { i = Batoi(val) & 0x0f; @@ -195,6 +196,11 @@ int writesetup(const char *fn) if (!fp) return -1; Bfprintf(fp, + "; Always show configuration options on startup\n" + "; 0 - No\n" + "; 1 - Yes\n" + "forcesetup = %ld\n" + "\n" "; Video mode selection\n" "; 0 - Windowed\n" "; 1 - Fullscreen\n" @@ -292,7 +298,7 @@ int writesetup(const char *fn) "keyconsole = %X\n" "\n", - fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame, + forcesetup, fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame, #if defined(POLYMOST) && defined(USE_OPENGL) glusetexcache, glusetexcachecompression, #endif diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c index 364e8ca3f..38a162a0f 100644 --- a/polymer/build/src/engine.c +++ b/polymer/build/src/engine.c @@ -123,77 +123,7 @@ static char kensmessage[128]; char *engineerrstr = "No error"; -#if defined(NOASM) - -static inline unsigned long nsqrtasm(unsigned long a) -{ // JBF 20030901: This was a damn lot simpler to reverse engineer than - // msqrtasm was. Really, it was just like simplifying an algebra equation. - unsigned short c; - - if (a & 0xff000000) { // test eax, 0xff000000 / jnz short over24 - c = shlookup[(a >> 24) + 4096]; // mov ebx, eax - // over24: shr ebx, 24 - // mov cx, word ptr shlookup[ebx*2+8192] - } else { - c = shlookup[a >> 12]; // mov ebx, eax - // shr ebx, 12 - // mov cx, word ptr shlookup[ebx*2] - // jmp short under24 - } - a >>= c&0xff; // under24: shr eax, cl - a = (a&0xffff0000)|(sqrtable[a]); // mov ax, word ptr sqrtable[eax*2] - a >>= ((c&0xff00) >> 8); // mov cl, ch - // shr eax, cl - return a; -} - -static inline long msqrtasm(unsigned long c) -{ - unsigned long a,b; - - a = 0x40000000l; // mov eax, 0x40000000 - b = 0x20000000l; // mov ebx, 0x20000000 - do { // begit: - if (c >= a) { // cmp ecx, eax / jl skip - c -= a; // sub ecx, eax - a += b*4; // lea eax, [eax+ebx*4] - } // skip: - a -= b; // sub eax, ebx - a >>= 1; // shr eax, 1 - b >>= 2; // shr ebx, 2 - } while (b); // jnz begit - if (c >= a) // cmp ecx, eax - a++; // sbb eax, -1 - a >>= 1; // shr eax, 1 - return a; -} - -static inline void setgotpic(long tilenume) -{ - if (walock[tilenume] < 200) walock[tilenume] = 199; - gotpic[tilenume>>3] |= pow2char[tilenume&7]; -} - -static inline long krecipasm(long i) -{ // Ken did this - float f = (float)i; i = *(long *)&f; - return((reciptable[(i>>12)&2047]>>(((i-0x3f800000)>>23)&31))^(i>>31)); -} - - -static inline long getclipmask(long a, long b, long c, long d) -{ // Ken did this - d = ((a<0)*8) + ((b<0)*4) + ((c<0)*2) + (d<0); - return(((d<<4)^0xf0)|d); -} - -inline long getkensmessagecrc(long b) -{ - return 0x56c764d4l; - b=b; -} - -#elif defined(__WATCOMC__) +#if defined(__WATCOMC__) && !defined(NOASM) // // Watcom Inline Assembly Routines @@ -297,7 +227,7 @@ long getclipmask(long,long,long,long); modify exact [eax ebx ecx edx] long getkensmessagecrc(long); -#elif defined(_MSC_VER) // __WATCOMC__ +#elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__ // // Microsoft C Inline Assembly Routines @@ -434,7 +364,7 @@ static inline long getkensmessagecrc(void *b) } } -#elif defined(__GNUC__) && defined(__i386__) // _MSC_VER +#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // _MSC_VER // // GCC "Inline" Assembly Routines @@ -539,7 +469,73 @@ static inline long getkensmessagecrc(void *b) #else // __GNUC__ && __i386__ -#error Unsupported compiler or architecture. +static inline unsigned long nsqrtasm(unsigned long a) +{ // JBF 20030901: This was a damn lot simpler to reverse engineer than + // msqrtasm was. Really, it was just like simplifying an algebra equation. + unsigned short c; + + if (a & 0xff000000) { // test eax, 0xff000000 / jnz short over24 + c = shlookup[(a >> 24) + 4096]; // mov ebx, eax + // over24: shr ebx, 24 + // mov cx, word ptr shlookup[ebx*2+8192] + } else { + c = shlookup[a >> 12]; // mov ebx, eax + // shr ebx, 12 + // mov cx, word ptr shlookup[ebx*2] + // jmp short under24 + } + a >>= c&0xff; // under24: shr eax, cl + a = (a&0xffff0000)|(sqrtable[a]); // mov ax, word ptr sqrtable[eax*2] + a >>= ((c&0xff00) >> 8); // mov cl, ch + // shr eax, cl + return a; +} + +static inline long msqrtasm(unsigned long c) +{ + unsigned long a,b; + + a = 0x40000000l; // mov eax, 0x40000000 + b = 0x20000000l; // mov ebx, 0x20000000 + do { // begit: + if (c >= a) { // cmp ecx, eax / jl skip + c -= a; // sub ecx, eax + a += b*4; // lea eax, [eax+ebx*4] + } // skip: + a -= b; // sub eax, ebx + a >>= 1; // shr eax, 1 + b >>= 2; // shr ebx, 2 + } while (b); // jnz begit + if (c >= a) // cmp ecx, eax + a++; // sbb eax, -1 + a >>= 1; // shr eax, 1 + return a; +} + +static inline void setgotpic(long tilenume) +{ + if (walock[tilenume] < 200) walock[tilenume] = 199; + gotpic[tilenume>>3] |= pow2char[tilenume&7]; +} + +static inline long krecipasm(long i) +{ // Ken did this + float f = (float)i; i = *(long *)&f; + return((reciptable[(i>>12)&2047]>>(((i-0x3f800000)>>23)&31))^(i>>31)); +} + + +static inline long getclipmask(long a, long b, long c, long d) +{ // Ken did this + d = ((a<0)*8) + ((b<0)*4) + ((c<0)*2) + (d<0); + return(((d<<4)^0xf0)|d); +} + +inline long getkensmessagecrc(long b) +{ + return 0x56c764d4l; + b=b; +} #endif diff --git a/polymer/build/src/game.c b/polymer/build/src/game.c index 8651ca75c..bca758180 100644 --- a/polymer/build/src/game.c +++ b/polymer/build/src/game.c @@ -131,6 +131,7 @@ char keys[NUMKEYS] = 0x9c,0x1c,0xd,0xc,0xf }; long xdimgame = 320, ydimgame = 200, bppgame = 8, xdim2d = 640, ydim2d = 480; // JBF 20050318: config.c expects to find these +long forcesetup = 1; static long digihz[8] = {6000,8000,11025,16000,22050,32000,44100,48000}; @@ -387,15 +388,11 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm) return OSDCMD_OK; } -#ifdef RENDERTYPEWIN -int DoLaunchWindow(void); // gamestartwin.c -#endif - -char *startwin_labeltext = "Starting KenBuild..."; +extern int startwin_run(void); long app_main(long argc, char *argv[]) { - long i, j, k, l, fil, waitplayers, x1, y1, x2, y2; + long cmdsetup = 0, i, j, k, l, fil, waitplayers, x1, y1, x2, y2; long other, packleng, netparm; #ifdef USE_OPENGL @@ -416,33 +413,31 @@ long app_main(long argc, char *argv[]) } if (isvalidipaddress(argv[i])) continue; } else { - Bstrcpy(boardfilename, argv[i]); - if (!Bstrrchr(boardfilename,'.')) Bstrcat(boardfilename,".map"); + if (!Bstrcasecmp(argv[i], "-setup")) cmdsetup = 1; + else { + Bstrcpy(boardfilename, argv[i]); + if (!Bstrrchr(boardfilename,'.')) Bstrcat(boardfilename,".map"); + } } } OSD_SetLogFile("console.txt"); - /* - if ((fil = open("setup.dat",O_BINARY|O_RDWR,S_IREAD)) != -1) - { - read(fil,&option[0],NUMOPTIONS); - read(fil,&keys[0],NUMKEYS); - close(fil); - } - */ - if (loadsetup("game.cfg") < 0) initprintf("Configuration file not found, using defaults.\n"); - initgroupfile("stuff.dat"); if (initengine()) { initprintf("There was a problem initialising the engine.\n"); return -1; } -#ifdef RENDERTYPEWIN - if (DoLaunchWindow()) return -1; - writesetup("game.cfg"); + if ((i = loadsetup("game.cfg")) < 0) + initprintf("Configuration file not found, using defaults.\n"); + +#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2) + if (i || forcesetup || cmdsetup) { + if (!startwin_run()) return -1; + } #endif + writesetup("game.cfg"); initinput(); if (option[3] != 0) initmouse(); @@ -3633,13 +3628,13 @@ void drawscreen(short snum, long dasmoothratio) y2 = y1 + scale(screensize,ydim-32,xdim)-1; setview(x1,y1,x2,y2); - // (ox1,oy1)ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ - // ³ (x1,y1) ³ - // ³ ÚÄÄÄÄÄ¿ ³ - // ³ ³ ³ ³ - // ³ ÀÄÄÄÄÄÙ ³ - // ³ (x2,y2) ³ - // ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ(ox2,oy2) + // (ox1,oy1)℃ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒø + // ≥ (x1,y1) ≥ + // ≥ ℃ƒƒƒƒø ≥ + // ≥ ≥ ≥ ≥ + // ≥ ¿ƒƒƒƒƒŸ ≥ + // ≥ (x2,y2) ≥ + // ¿ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒŸ(ox2,oy2) drawtilebackground(0L,0L,BACKGROUND,8,ox1,oy1,x1-1,oy2,0); drawtilebackground(0L,0L,BACKGROUND,8,x2+1,oy1,ox2,oy2,0); @@ -3801,7 +3796,7 @@ void drawscreen(short snum, long dasmoothratio) else setviewtotile(MAXTILES-2,320L>>detailmode,320L>>detailmode); if ((tiltlock&1023) == 512) - { //Block off unscreen section of 90ø tilted screen + { //Block off unscreen section of 90¯ tilted screen j = ((320-60)>>detailmode); for(i=(60>>detailmode)-1;i>=0;i--) { @@ -4907,13 +4902,7 @@ void initlava(void) lavanumframes = 0; } -#if defined(NOASM) -inline long addlava(long bx) -{ - char *b = (char *)bx; - return b[-133] + b[-132] + b[-131] + b[1] + b[-1] + b[131] + b[132]; -} -#elif defined(__WATCOMC__) +#if defined(__WATCOMC__) && !defined(NOASM) #pragma aux addlava =\ "mov al, byte ptr [ebx-133]",\ "mov dl, byte ptr [ebx-1]",\ @@ -4926,7 +4915,7 @@ inline long addlava(long bx) parm [ebx]\ modify exact [eax edx] long addlava(long); -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && !defined(NOASM) inline long addlava(long b) { _asm { @@ -4941,7 +4930,7 @@ inline long addlava(long b) add al, dl } } -#elif defined(__GNUC__) && defined(__i386__) +#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) inline long addlava(long b) { long r; @@ -4960,7 +4949,11 @@ inline long addlava(long b) return r; } #else -#error Unsupported compiler or architecture +inline long addlava(long bx) +{ + char *b = (char *)bx; + return b[-133] + b[-132] + b[-131] + b[1] + b[-1] + b[131] + b[132]; +} #endif void movelava(char *dapic) diff --git a/polymer/build/src/gamestartwin.c b/polymer/build/src/gamestartwin.c deleted file mode 100644 index a65b0dcb5..000000000 --- a/polymer/build/src/gamestartwin.c +++ /dev/null @@ -1,144 +0,0 @@ -#ifndef RENDERTYPEWIN -#error Only for Windows -#endif - -#include "build.h" -#include "editor.h" -#include "winlayer.h" -#include "compat.h" - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include - - -#define IDCFULLSCREEN 100 -#define IDCVMODE 101 - -static void PopulateVideoModeLists(int fs, HWND list3d) -{ - int i,j; - char buf[64]; - - ComboBox_ResetContent(list3d); - for (i=0; i 0) { - if (!IsWindow(hwndLaunch) || quitevent) break; - if (IsDialogMessage(hwndStart, &msg) /*|| IsDialogMessage(hwndLaunch, &msg)*/) continue; - - TranslateMessage(&msg); - DispatchMessage(&msg); - } - EnableWindow(GetDlgItem(hwndStart,WIN_STARTWIN_ITEMLIST),TRUE); - } - if (quitevent) return 1; - return 0; -} - diff --git a/polymer/build/src/glbuild.c b/polymer/build/src/glbuild.c index fe97899fd..8e14b0866 100644 --- a/polymer/build/src/glbuild.c +++ b/polymer/build/src/glbuild.c @@ -6,8 +6,12 @@ #if defined USE_OPENGL -#ifdef RENDERTYPESDL -#include "SDL.h" + #ifdef RENDERTYPESDL +# ifdef __APPLE__ +# include +# else + #include "SDL.h" + #endif #endif void (APIENTRY * bglClearColor)( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); @@ -131,8 +135,10 @@ int loadgldriver(const char *driver) #endif if (!driver) { -#ifdef _WIN32 + #ifdef _WIN32 driver = "OPENGL32.DLL"; +#elif defined __APPLE__ + driver = "OpenGLLibrary"; #else driver = "libGL.so"; #endif diff --git a/polymer/build/src/gtkbits.c b/polymer/build/src/gtkbits.c index 83866e5fa..810dbcef2 100644 --- a/polymer/build/src/gtkbits.c +++ b/polymer/build/src/gtkbits.c @@ -13,164 +13,10 @@ #include "baselayer.h" #include "build.h" -static int gtkenabled = 0; +int gtkenabled = 0; -extern const GdkPixdata startbanner_pixdata; -static GtkWidget *startwin = NULL; static GdkPixbuf *appicon = NULL; -#define GLADE_HOOKUP_OBJECT(component,widget,name) \ - g_object_set_data_full (G_OBJECT (component), name, \ - gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) - -#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ - g_object_set_data (G_OBJECT (component), name, widget) - -#define lookup_widget(x,w) \ - (GtkWidget*) g_object_get_data(G_OBJECT(x), w) - -static gboolean on_startwin_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) -{ - quitevent++; - return TRUE; // FALSE would let the event go through. we want the game to decide when to close -} - -void gtkbuild_create_startwin(void) -{ - GtkWidget *banner, *label, *content, *scroll; - GtkWidget *hbox1, *fixed1; - GdkPixbuf *startbanner_pixbuf; - - if (!gtkenabled) return; - - startwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (startwin), apptitle); - gtk_window_set_position (GTK_WINDOW (startwin), GTK_WIN_POS_CENTER); - gtk_window_set_resizable (GTK_WINDOW (startwin), FALSE); - gtk_window_set_type_hint (GTK_WINDOW (startwin), GDK_WINDOW_TYPE_HINT_DIALOG); - - hbox1 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox1); - gtk_container_add (GTK_CONTAINER (startwin), hbox1); - - startbanner_pixbuf = gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); - banner = gtk_image_new_from_pixbuf(startbanner_pixbuf); - g_object_unref((gpointer)startbanner_pixbuf); - gtk_widget_show (banner); - gtk_box_pack_start (GTK_BOX (hbox1), banner, FALSE, FALSE, 0); - - fixed1 = gtk_fixed_new (); - gtk_widget_show (fixed1); - gtk_box_pack_start (GTK_BOX (hbox1), fixed1, TRUE, TRUE, 0); - gtk_widget_set_size_request (fixed1, 390, -1); - - label = gtk_label_new (startwin_labeltext); - gtk_widget_show (label); - gtk_fixed_put (GTK_FIXED (fixed1), label, 6, 6); - gtk_widget_set_size_request (label, 378, 16); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); - - scroll = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scroll); - gtk_fixed_put (GTK_FIXED (fixed1), scroll, 6, 28); - gtk_widget_set_size_request (scroll, 378, 248); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); - - content = gtk_text_view_new (); - gtk_widget_show (content); - gtk_container_add (GTK_CONTAINER(scroll), content); - //gtk_fixed_put (GTK_FIXED (fixed1), content, 6, 28); - gtk_widget_set_size_request (content, 378, 248); - gtk_text_view_set_editable (GTK_TEXT_VIEW (content), FALSE); - gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (content), GTK_WRAP_WORD); - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (content), FALSE); - - g_signal_connect ((gpointer) startwin, "delete_event", - G_CALLBACK (on_startwin_delete_event), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (startwin, startwin, "startwin"); - GLADE_HOOKUP_OBJECT (startwin, banner, "banner"); - GLADE_HOOKUP_OBJECT (startwin, label, "label"); - GLADE_HOOKUP_OBJECT (startwin, scroll, "scroll"); - GLADE_HOOKUP_OBJECT (startwin, content, "content"); - - g_signal_connect((gpointer)startwin, "destroy", G_CALLBACK(gtk_widget_destroyed), (gpointer)&startwin); - gtk_widget_show (startwin); - gtk_main_iteration_do (FALSE); -} - -void gtkbuild_settitle_startwin(const char *title) -{ - if (!gtkenabled || !startwin) return; - gtk_window_set_title (GTK_WINDOW (startwin), title); -} - -void gtkbuild_puts_startwin(const char *str) -{ - GtkWidget *textview; - GtkTextBuffer *textbuffer; - GtkTextIter enditer; - GtkTextMark *mark; - const char *aptr, *bptr; - - if (!gtkenabled || !startwin || !str) return; - if (!(textview = lookup_widget(startwin, "content"))) return; - textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); - - gtk_text_buffer_get_end_iter(textbuffer, &enditer); - for (aptr = bptr = str; *aptr != 0; ) { - switch (*bptr) { - case '\b': - if (bptr > aptr) - gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); -#if GTK_CHECK_VERSION(2,6,0) - gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); -#else - { - GtkTextIter iter2 = enditer; - gtk_text_iter_backward_cursor_position(&iter2); - //FIXME: this seems be deleting one too many chars somewhere! - if (!gtk_text_iter_equal(&iter2, &enditer)) - gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); - } -#endif - aptr = ++bptr; - break; - case 0: - if (bptr > aptr) - gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); - aptr = bptr; - break; - case '\r': // FIXME - default: - bptr++; - break; - } - } - - mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1); - gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0); - gtk_text_buffer_delete_mark(textbuffer, mark); -} - -void gtkbuild_close_startwin(void) -{ - if (!gtkenabled) return; - if (startwin) { - gtk_widget_destroy (startwin); - startwin = NULL; - } -} - -void gtkbuild_update_startwin(void) -{ - if (!gtkenabled) return; - gtk_main_iteration_do (FALSE); -} - - int gtkbuild_msgbox(char *name, char *msg) { GtkWidget *dialog; @@ -213,7 +59,7 @@ int gtkbuild_ynbox(char *name, char *msg) #include "sdlayer.h" extern struct sdlappicon sdlappicon; #endif -void gtkbuild_init(int argc, char **argv) +void gtkbuild_init(int *argc, char ***argv) { gtkenabled = gtk_init_check(argc, argv); if (!gtkenabled) return; @@ -231,8 +77,3 @@ void gtkbuild_exit(int r) if (appicon) g_object_unref((gpointer)appicon); //gtk_exit(r); } - -void *gtkbuild_get_app_icon(void) -{ - return appicon; -} diff --git a/polymer/build/src/kplib.c b/polymer/build/src/kplib.c index 25a5f11ab..eaed118f5 100644 --- a/polymer/build/src/kplib.c +++ b/polymer/build/src/kplib.c @@ -1,10 +1,10 @@ /************************************************************************************************** KPLIB.C: Ken's Picture LIBrary written by Ken Silverman -Copyright (c) 1998-2005 Ken Silverman +Copyright (c) 1998-2006 Ken Silverman Ken Silverman's official web site: http://advsys.net/ken Features of KPLIB.C: - * Routines for decoding JPG, PNG, GIF, PCX, TGA, BMP, CEL. + * Routines for decoding JPG, PNG, GIF, PCX, TGA, BMP, DDS, CEL. See kpgetdim(), kprender(), and optional helper function: kpzload(). * Routines for ZIP decompression. All ZIP functions start with the letters "kz". * Multi-platform support: Dos/Windows/Linux/Mac/etc.. @@ -20,6 +20,7 @@ Brief history: 2003: Added support for BMP 05/18/2004: Added support for 8&24 bit PCX 12/09/2005: Added support for progressive JPEG +01/05/2006: Added support for DDS I offer this code to the community for free use - all I ask is that my name be included in the credits. @@ -153,8 +154,8 @@ static kzfilestate kzfs; // pow2mask 128* // dcflagor 64 -long palcol[256] ASMNAME("palcol"), paleng; -unsigned char coltype, bitdepth; +long palcol[256] ASMNAME("palcol"), paleng, bakcol, numhufblocks, zlibcompflags; +signed char coltype, filtype, bitdepth; //============================ KPNGILIB begins =============================== @@ -169,7 +170,7 @@ unsigned char coltype, bitdepth; // * Some useless ancillary chunks, like: gAMA(gamma) & pHYs(aspect ratio) //.PNG specific variables: -static long bakcol = 0xff808080, bakr = 0x80, bakg = 0x80, bakb = 0x80; //this used to be public... +static long bakr = 0x80, bakg = 0x80, bakb = 0x80; //this used to be public... static long gslidew = 0, gslider = 0, xm, xmn[4], xr0, xr1, xplc, yplc, nfplace; static long clen[320], cclen[19], bitpos, filt, xsiz, ysiz; static long xsizbpl, ixsiz, ixoff, iyoff, ixstp, iystp, intlac, nbpl, trnsrgb ASMNAME("trnsrgb"); @@ -186,25 +187,7 @@ static long gotcmov = -2, abstab10[1024] ASMNAME("abstab10"); static long qhufval0[1<>8) + ((a&0xff00)<<8) + (a<<24) + (a>>24)); -} - -static inline long bitrev (long b, long c) -{ - long i, j; - for(i=1,j=0,c=(1<>8) + ((a&0xff00)<<8) + (a<<24) + (a>>24)); +} + +static inline long bitrev (long b, long c) +{ + long i, j; + for(i=1,j=0,c=(1<xr1;p+=ixstp,x-=3) *(long *)p = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000); - return; - } - for(;x>xr1;p+=ixstp,x-=3) - { - i = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000); - if (i == trnsrgb) i &= LSWAPIB(0xffffff); - *(long *)p = i; - } -} - -static inline void pal8hlineasm (long x, long xr1, long p, long ixstp) -{ - for(;x>xr1;p+=ixstp,x--) *(long *)p = palcol[olinbuf[x]]; -} - -#elif defined(__WATCOMC__) +#if defined(__WATCOMC__) && !defined(NOASM) //NOTE: cmov now has correctly ordered registers (thx to bug fix in 11.0c!) long Paeth686 (long, long, long); @@ -669,7 +638,7 @@ void pal8hlineasm (long, long, long, long); modify exact [eax ecx edi]\ value -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && !defined(NOASM) static _inline long Paeth686 (long a, long b, long c) { @@ -746,7 +715,7 @@ static _inline void pal8hlineasm (long c, long d, long t, long b) } } -#elif defined(__GNUC__) && defined(__i386__) +#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) static inline long Paeth686 (long a, long b, long c) { @@ -791,10 +760,43 @@ static inline void pal8hlineasm (long c, long d, long t, long b) #else -#error Unsupported compiler or architecture. +static inline long Paeth686 (long a, long b, long c) +{ + return(Paeth(a,b,c)); +} + +static inline void rgbhlineasm (long x, long xr1, long p, long ixstp) +{ + long i; + if (!trnsrgb) + { + for(;x>xr1;p+=ixstp,x-=3) *(long *)p = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000); + return; + } + for(;x>xr1;p+=ixstp,x-=3) + { + i = (*(long *)&olinbuf[x])|LSWAPIB(0xff000000); + if (i == trnsrgb) i &= LSWAPIB(0xffffff); + *(long *)p = i; + } +} + +static inline void pal8hlineasm (long x, long xr1, long p, long ixstp) +{ + for(;x>xr1;p+=ixstp,x--) *(long *)p = palcol[olinbuf[x]]; +} #endif +//Autodetect filter +// /f0: 0000000... +// /f1: 1111111... +// /f2: 2222222... +// /f3: 1333333... +// /f3: 3333333... +// /f4: 4444444... +// /f5: 0142321... +static long filter1st, filterest; static void putbuf (const unsigned char *buf, long leng) { long i, x, p; @@ -802,7 +804,9 @@ static void putbuf (const unsigned char *buf, long leng) if (filt < 0) { if (leng <= 0) return; - filt = buf[0]; if (filt == gotcmov) filt = 5; + filt = buf[0]; + if (filter1st < 0) filter1st = filt; else filterest |= (1<= globyoffs+ysiz)) { intlac--; initpass(); } - if (i < leng) { filt = buf[i++]; if (filt == gotcmov) filt = 5; } else filt = -1; + if (i < leng) + { + filt = buf[i++]; + if (filter1st < 0) filter1st = filt; else filterest |= (1<= slider) { putbuf(&slidebuf[(slider-16384)&32767],16384); slider += 16384; - if ((yplc >= yres) && (intlac < 2)) return(0); + if ((yplc >= yres) && (intlac < 2)) goto kpngrend_goodret; } slidebuf[(slidew++)&32767] = (char)getbits(8); } @@ -1153,7 +1163,7 @@ static long kpngrend (const char *kfilebuf, long kfilength, if (slidew >= slider) { putbuf(&slidebuf[(slider-16384)&32767],16384); slider += 16384; - if ((yplc >= yres) && (intlac < 2)) return(0); + if ((yplc >= yres) && (intlac < 2)) goto kpngrend_goodret; } k = peekbits(LOGQHUFSIZ0); @@ -1181,6 +1191,12 @@ static long kpngrend (const char *kfilebuf, long kfilength, putbuf(&slidebuf[slider&32767],(-slider)&32767); putbuf(slidebuf,slidew&32767); } + +kpngrend_goodret:; + if (!(filterest&~(1<>24)); -} - -static inline long mulshr32 (long a, long b) -{ - return((long)((((__int64)a)*((__int64)b))>>32)); -} - -#elif defined(__WATCOMC__) +#if defined(__WATCOMC__) && !defined(NOASM) long mulshr24 (long, long); #pragma aux mulshr24 =\ @@ -1233,7 +1237,7 @@ long mulshr32 (long, long); modify exact [eax edx]\ value [edx] -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && !defined(NOASM) static _inline long mulshr24 (long a, long d) { @@ -1255,7 +1259,7 @@ static _inline long mulshr32 (long a, long d) } } -#elif defined(__GNUC__) && defined(__i386__) +#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) #define mulshr24(a,d) \ ({ long __a=(a), __d=(d); \ @@ -1271,7 +1275,15 @@ static _inline long mulshr32 (long a, long d) #else -#error Unsupported compiler or architecture. +static inline long mulshr24 (long a, long b) +{ + return((long)((((__int64)a)*((__int64)b))>>24)); +} + +static inline long mulshr32 (long a, long b) +{ + return((long)((((__int64)a)*((__int64)b))>>32)); +} #endif @@ -2263,7 +2275,8 @@ if (ysiz < 0) { ysiz = -ysiz; } else { cptr = &cptr[(ysiz-1)*cptrinc]; cptrinc = } return(0); } - +//=============================== BMP ends ================================== +//============================== PCX begins ================================= //Note: currently only supports 8 and 24 bit PCX static long kpcxrend (const char *buf, long fleng, long daframeplace, long dabytesperline, long daxres, long dayres, @@ -2343,7 +2356,127 @@ static long kpcxrend (const char *buf, long fleng, return(0); } -//=============================== BMP ends ================================== +//=============================== PCX ends ================================== +//============================== DDS begins ================================= + +//Note:currently supports: DXT1,DXT2,DXT3,DXT4,DXT5,A8R8G8B8 +static long kddsrend (const char *buf, long leng, + long frameptr, long bpl, long xdim, long ydim, long xoff, long yoff) +{ + long x, y, z, xx, yy, xsiz, ysiz, dxt, al[2], ai, j, k, v, c0, c1, stride; + unsigned long lut[256], r[4], g[4], b[4], a[8], rr, gg, bb; + unsigned char *uptr, *wptr; + + xsiz = LSWAPIB(*(long *)&buf[16]); + ysiz = LSWAPIB(*(long *)&buf[12]); + if ((*(long *)&buf[80])&LSWAPIB(64)) //Uncompressed supports only A8R8G8B8 for now + { + if ((*(long *)&buf[88]) != LSWAPIB(32)) return(-1); + if ((*(long *)&buf[92]) != LSWAPIB(0x00ff0000)) return(-1); + if ((*(long *)&buf[96]) != LSWAPIB(0x0000ff00)) return(-1); + if ((*(long *)&buf[100]) != LSWAPIB(0x000000ff)) return(-1); + if ((*(long *)&buf[104]) != LSWAPIB(0xff000000)) return(-1); + buf += 128; + + j = yoff*bpl + (xoff<<2) + frameptr; xx = (xsiz<<2); + if (xoff < 0) { j -= (xoff<<2); buf -= (xoff<<2); xsiz += xoff; } + xsiz = (min(xsiz,xdim-xoff)<<2); ysiz = min(ysiz,ydim); + for(y=0;y= (unsigned long)ydim) continue; + memcpy((void *)j,(void *)buf,xsiz); + } + return(0); + } + if (!((*(long *)&buf[80])&LSWAPIB(4))) return(-1); //FOURCC invalid + dxt = buf[87]-'0'; + if ((buf[84] != 'D') || (buf[85] != 'X') || (buf[86] != 'T') || (dxt < 1) || (dxt > 5)) return(-1); + buf += 128; + + if (!(dxt&1)) + { + for(z=256-1;z>0;z--) lut[z] = (255<<16)/z; + lut[0] = (1<<16); + } + if (dxt == 1) stride = (xsiz<<1); else stride = (xsiz<<2); + + for(y=0;y>8)&0xf8); g[0] = ((c0>>3)&0xfc); b[0] = ((c0<<3)&0xfc); a[0] = 255; + c1 = SSWAPIB(*(unsigned short *)&uptr[2]); + r[1] = ((c1>>8)&0xf8); g[1] = ((c1>>3)&0xfc); b[1] = ((c1<<3)&0xfc); a[1] = 255; + if ((c0 > c1) || (dxt != 1)) + { + r[2] = (((r[0]*2 + r[1] + 1)*(65536/3))>>16); + g[2] = (((g[0]*2 + g[1] + 1)*(65536/3))>>16); + b[2] = (((b[0]*2 + b[1] + 1)*(65536/3))>>16); a[2] = 255; + r[3] = (((r[0] + r[1]*2 + 1)*(65536/3))>>16); + g[3] = (((g[0] + g[1]*2 + 1)*(65536/3))>>16); + b[3] = (((b[0] + b[1]*2 + 1)*(65536/3))>>16); a[3] = 255; + } + else + { + r[2] = (r[0] + r[1])>>1; + g[2] = (g[0] + g[1])>>1; + b[2] = (b[0] + b[1])>>1; a[2] = 255; + r[3] = g[3] = b[3] = a[3] = 0; //Transparent + } + v = LSWAPIB(*(long *)&uptr[4]); + if (dxt >= 4) + { + a[0] = uptr[-8]; a[1] = uptr[-7]; k = a[1]-a[0]; + if (k < 0) + { + z = a[0]*6 + a[1] + 3; + for(j=2;j<8;j++) { a[j] = ((z*(65536/7))>>16); z += k; } + } + else + { + z = a[0]*4 + a[1] + 2; + for(j=2;j<6;j++) { a[j] = ((z*(65536/5))>>16); z += k; } + a[6] = 0; a[7] = 255; + } + al[0] = LSWAPIB(*(long *)&uptr[-6]); + al[1] = LSWAPIB(*(long *)&uptr[-3]); + } + wptr = (unsigned char *)((y+yoff)*bpl + ((x+xoff)<<2) + frameptr); + ai = 0; + for(yy=0;yy<4;yy++,wptr+=bpl) + { + if ((unsigned long)(y+yy+yoff) >= (unsigned long)ydim) { ai += 4; continue; } + for(xx=0;xx<4;xx++,ai++) + { + if ((unsigned long)(x+xx+xoff) >= (unsigned long)xdim) continue; + + j = ((v>>(ai<<1))&3); + switch(dxt) + { + case 1: z = a[j]; break; + case 2: case 3: z = (( uptr[(ai>>1)-8] >> ((xx&1)<<2) )&15)*17; break; + case 4: case 5: z = a[( al[yy>>1] >> ((ai&7)*3) )&7]; break; + } + rr = r[j]; gg = g[j]; bb = b[j]; + if (!(dxt&1)) + { + bb = min((bb*lut[z])>>16,255); + gg = min((gg*lut[z])>>16,255); + rr = min((rr*lut[z])>>16,255); + } + wptr[(xx<<2)+0] = bb; + wptr[(xx<<2)+1] = gg; + wptr[(xx<<2)+2] = rr; + wptr[(xx<<2)+3] = z; + } + } + } + return(0); +} + +//=============================== DDS ends ================================== //=================== External picture interface begins ====================== void kpgetdim (const char *buf, long leng, long *xsiz, long *ysiz) @@ -2410,6 +2543,11 @@ void kpgetdim (const char *buf, long leng, long *xsiz, long *ysiz) (*xsiz) = SSWAPIB(*(short *)&buf[ 8])-SSWAPIB(*(short *)&buf[4])+1; (*ysiz) = SSWAPIB(*(short *)&buf[10])-SSWAPIB(*(short *)&buf[6])+1; } + else if ((*(long *)ubuf == LSWAPIB(0x20534444)) && (*(long *)&ubuf[4] == LSWAPIB(124))) //.DDS + { + (*xsiz) = LSWAPIB(*(long *)&buf[16]); + (*ysiz) = LSWAPIB(*(long *)&buf[12]); + } else { //Unreliable .TGA identification - this MUST be final case! if ((leng >= 20) && (!(ubuf[1]&0xfe))) @@ -2428,6 +2566,8 @@ long kprender (const char *buf, long leng, long frameptr, long bpl, { unsigned char *ubuf = (unsigned char *)buf; + paleng = 0; bakcol = 0; numhufblocks = zlibcompflags = 0; filtype = -1; + if ((ubuf[0] == 0x89) && (ubuf[1] == 0x50)) //.PNG return(kpngrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff)); @@ -2446,6 +2586,9 @@ long kprender (const char *buf, long leng, long frameptr, long bpl, if (*(long *)ubuf == LSWAPIB(0x0801050a)) //.PCX return(kpcxrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff)); + if ((*(long *)ubuf == LSWAPIB(0x20534444)) && (*(long *)&ubuf[4] == LSWAPIB(124))) //.DDS + return(kddsrend(buf,leng,frameptr,bpl,xdim,ydim,xoff,yoff)); + //Unreliable .TGA identification - this MUST be final case! if ((leng >= 20) && (!(ubuf[1]&0xfe))) if ((ubuf[2] < 12) && ((1<d_name); - if (stat(filnam,&st) < 0) continue; - if (st.st_mode & S_IFDIR) - { if (findata->d_name[0] == '.' && !findata->d_name[1]) continue; } //skip . - else if ((st.st_mode & S_IFREG) || (st.st_mode & S_IFLNK)) - { if (findata->d_name[0] == '.') continue; } //skip hidden (dot) files - else continue; //skip devices and fifos and such - if (!wildmatch(findata->d_name,&wildst[wildstpathleng])) continue; - if (st.st_mode & S_IFDIR) strcat(&filnam[i],"/"); - } + if ((findata = readdir(hfind)) == NULL) + { closedir(hfind); hfind = NULL; if (!kzhashbuf) return 0; srchstat = kzlastfnam; break; } + i = wildstpathleng; + if (findata->d_type == DT_DIR) + { if (findata->d_name[0] == '.' && !findata->d_name[1]) continue; } //skip . + else if ((findata->d_type == DT_REG) || (findata->d_type == DT_LNK)) + { if (findata->d_name[0] == '.') continue; } //skip hidden (dot) files + else continue; //skip devices and fifos and such + if (!wildmatch(findata->d_name,&wildst[wildstpathleng])) continue; + strcpy(&filnam[i],findata->d_name); + if (findata->d_type == DT_DIR) strcat(&filnam[i],"/"); #endif return(1); } diff --git a/polymer/build/src/mdsprite.c b/polymer/build/src/mdsprite.c index e12c18657..374ec4402 100644 --- a/polymer/build/src/mdsprite.c +++ b/polymer/build/src/mdsprite.c @@ -561,7 +561,7 @@ long mdloadskin_trytexcache(char *fn, long len, char effect, texcacheheader *hea return -1; } - md4once(fn, strlen(fn), mdsum); + md4once((unsigned char *)fn, strlen(fn), mdsum); for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++); *(cp++) = '/'; for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2); @@ -2233,9 +2233,9 @@ kread(fil,&i,4); if (B_LITTLE32(i) != 0x6c78764b) { kclose(fil); return(-1); } / kread(fil,&xsiz,4); xsiz = B_LITTLE32(xsiz); kread(fil,&ysiz,4); ysiz = B_LITTLE32(ysiz); kread(fil,&zsiz,4); zsiz = B_LITTLE32(zsiz); - kread(fil,&xpiv,4); xpiv = B_LITTLE32(xpiv); - kread(fil,&ypiv,4); ypiv = B_LITTLE32(ypiv); - kread(fil,&zpiv,4); zpiv = B_LITTLE32(zpiv); + kread(fil,&i,4); xpiv = (float)(B_LITTLE32(i)); + kread(fil,&i,4); ypiv = (float)(B_LITTLE32(i)); + kread(fil,&i,4); zpiv = (float)(B_LITTLE32(i)); kread(fil,&numvoxs,4); numvoxs = B_LITTLE32(numvoxs); ylen = (unsigned short *)malloc(xsiz*ysiz*sizeof(short)); diff --git a/polymer/build/src/misc/buildres.rc b/polymer/build/src/misc/buildres.rc index 0a5c4b6be..22c1ef82c 100644 --- a/polymer/build/src/misc/buildres.rc +++ b/polymer/build/src/misc/buildres.rc @@ -1,31 +1,33 @@ #include +#include +#include "startwin.editor.h" -100 ICON "rsrc/build_icon.ico" -200 BITMAP "rsrc/build.bmp" +RSRC_ICON ICON "rsrc/build_icon.ico" +RSRC_BMP BITMAP "rsrc/build.bmp" -1000 DIALOGEX DISCARDABLE 20, 40, 265, 233 +WIN_STARTWIN DIALOGEX DISCARDABLE 20, 40, 260, 200 STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU CAPTION "Startup" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255 - CONTROL "Starting Build Editor...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8 - //CONTROL "", 102, "LISTBOX", LBS_HASSTRINGS | LBS_NOSEL | LBS_USETABSTOPS | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_DISABLENOSCROLL, 5, 92, 255, 138 - CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138 + CONTROL "", WIN_STARTWIN_BITMAP, "STATIC", SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 32, 32 + CONTROL "", WIN_STARTWIN_TABCTL, WC_TABCONTROL, WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 5, 250, 170 + CONTROL "&Start", WIN_STARTWIN_START, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 154, 180, 48, 14 + CONTROL "&Cancel", WIN_STARTWIN_CANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 207, 180, 48, 14 + + CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32 END -2000 DIALOGEX DISCARDABLE 20, 40, 279, 168 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL +WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD CAPTION "Dialog" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "Video mode", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 3, 128, 64 - CONTROL "&Fullscreen", 100, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 15, 49, 10 - CONTROL "&2D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 30, 37, 8 - CONTROL "", 101, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 28, 75, 56 - CONTROL "&3D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 47, 37, 8 - CONTROL "", 102, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 46, 75, 56 - CONTROL "&Continue", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 140, 145, 64, 17 - CONTROL "E&xit", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 208, 145, 64, 17 + CONTROL "&2D Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 8, 50, 8 + CONTROL "", IDC2DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56 + CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10 + CONTROL "&3D Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 24, 50, 8 + CONTROL "", IDC3DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 22, 80, 56 + CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8 END diff --git a/polymer/build/src/misc/gameres.rc b/polymer/build/src/misc/gameres.rc index 8ea227aea..1e1ebf54a 100644 --- a/polymer/build/src/misc/gameres.rc +++ b/polymer/build/src/misc/gameres.rc @@ -1,29 +1,31 @@ #include +#include +#include "startwin.game.h" -100 ICON "rsrc/game_icon.ico" -200 BITMAP "rsrc/game.bmp" +RSRC_ICON ICON "rsrc/game_icon.ico" +RSRC_BMP BITMAP "rsrc/game.bmp" -1000 DIALOGEX DISCARDABLE 20, 40, 265, 233 +WIN_STARTWIN DIALOGEX DISCARDABLE 20, 40, 260, 200 STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU CAPTION "Startup" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255 - CONTROL "Starting KenBuild...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8 - //CONTROL "", 102, "LISTBOX", LBS_HASSTRINGS | LBS_NOSEL | LBS_USETABSTOPS | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LBS_DISABLENOSCROLL, 5, 92, 255, 138 - CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138 + CONTROL "", WIN_STARTWIN_BITMAP, "STATIC", SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 32, 32 + CONTROL "", WIN_STARTWIN_TABCTL, WC_TABCONTROL, WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 5, 250, 170 + CONTROL "&Start", WIN_STARTWIN_START, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 154, 180, 48, 14 + CONTROL "&Cancel", WIN_STARTWIN_CANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 207, 180, 48, 14 + + CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32 END -2000 DIALOGEX DISCARDABLE 20, 40, 279, 168 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL +WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD CAPTION "Dialog" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "Video mode", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 3, 128, 46 - CONTROL "&Fullscreen", 100, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 15, 49, 10 - CONTROL "&Mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 30, 37, 8 - CONTROL "", 101, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 28, 75, 56 - CONTROL "&Continue", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 140, 145, 64, 17 - CONTROL "E&xit", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 208, 145, 64, 17 + CONTROL "&Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 8, 50, 8 + CONTROL "", IDC3DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56 + CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10 + CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8 END diff --git a/polymer/build/src/misc/gtkstartwin/gtkstartwin.glade b/polymer/build/src/misc/gtkstartwin/gtkstartwin.glade new file mode 100755 index 000000000..ce1187f4d --- /dev/null +++ b/polymer/build/src/misc/gtkstartwin/gtkstartwin.glade @@ -0,0 +1,450 @@ + + + + + + + True + Startup + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + + + + + True + False + 0 + + + + + 0 + False + False + + + + + + True + False + 0 + + + + 4 + True + True + True + True + GTK_POS_TOP + False + False + + + + True + False + 0 + + + + 6 + True + + + + 88 + 29 + True + _2D Video mode: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + vmode2dcombo + + + 0 + 0 + + + + + + 88 + 29 + True + _3D Video mode: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + vmode3dcombo + + + 0 + 32 + + + + + + 85 + 29 + True + True + _Fullscreen + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + + 248 + 0 + + + + + + 150 + 29 + True + + + + + + 96 + 0 + + + + + + 150 + 29 + True + + + + + 96 + 32 + + + + + 0 + True + True + + + + + + True + True + _Always show configuration on start + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + + 0 + False + False + + + + + False + True + + + + + + True + Configuration + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + False + 0 + 0 + 0 + 2 + 2 + 0 + + + + + + False + True + + + + + + True + Messages + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + 3 + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Cancel + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-execute + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Start + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + True + + + + + 0 + True + True + + + + + + + diff --git a/polymer/build/src/misc/gtkstartwin/gtkstartwin.gladep b/polymer/build/src/misc/gtkstartwin/gtkstartwin.gladep new file mode 100755 index 000000000..e27cd5bd5 --- /dev/null +++ b/polymer/build/src/misc/gtkstartwin/gtkstartwin.gladep @@ -0,0 +1,11 @@ + + + + + Gtkstartwin + gtkstartwin + FALSE + FALSE + FALSE + FALSE + diff --git a/polymer/build/src/misc/gtkstartwin/pixmaps/game.bmp b/polymer/build/src/misc/gtkstartwin/pixmaps/game.bmp new file mode 100755 index 000000000..c079eef46 Binary files /dev/null and b/polymer/build/src/misc/gtkstartwin/pixmaps/game.bmp differ diff --git a/polymer/build/src/osxbits.m b/polymer/build/src/osxbits.m index 781dc4b1f..0fdab83e4 100644 --- a/polymer/build/src/osxbits.m +++ b/polymer/build/src/osxbits.m @@ -1,37 +1,52 @@ #include "osxbits.h" -#include +#import + +#ifndef MAC_OS_VERSION_10_3 +# define MAC_OS_VERSION_10_3 1030 +#endif int osx_msgbox(char *name, char *msg) { - NSAlert *alert = [[NSAlert alloc] init]; NSString *mmsg = [[NSString alloc] initWithCString: msg]; + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 + NSAlert *alert = [[NSAlert alloc] init]; [alert addButtonWithTitle: @"OK"]; - [alert setMessageText: mmsg]; + [alert setInformativeText: mmsg]; [alert setAlertStyle: NSInformationalAlertStyle]; [alert runModal]; [alert release]; + +#else + NSRunAlertPanel(nil, mmsg, @"OK", nil, nil); +#endif + [mmsg release]; - return 0; } int osx_ynbox(char *name, char *msg) { - NSAlert *alert = [[NSAlert alloc] init]; NSString *mmsg = [[NSString alloc] initWithCString: msg]; int r; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 + NSAlert *alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle:@"Yes"]; [alert addButtonWithTitle:@"No"]; - [alert setMessageText: mmsg]; + [alert setInformativeText: mmsg]; [alert setAlertStyle: NSInformationalAlertStyle]; r = ([alert runModal] == NSAlertFirstButtonReturn); [alert release]; +#else + r = (NSRunAlertPanel(nil, mmsg, @"Yes", @"No", nil) == NSAlertDefaultReturn); +#endif + [mmsg release]; - return r; } diff --git a/polymer/build/src/polymost.c b/polymer/build/src/polymost.c index 1edc3830e..a9043636a 100644 --- a/polymer/build/src/polymost.c +++ b/polymer/build/src/polymost.c @@ -856,7 +856,7 @@ long trytexcache(char *fn, long len, long dameth, char effect, texcacheheader *h return -1; } - md4once(fn, strlen(fn), mdsum); + md4once((unsigned char *)fn, strlen(fn), mdsum); for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++); *(cp++) = '/'; for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2); @@ -929,7 +929,7 @@ void writexcache(char *fn, long len, long dameth, char effect, texcacheheader *h bglGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &gi); if (gi != GL_TRUE) return; - md4once(fn, strlen(fn), mdsum); + md4once((unsigned char *)fn, strlen(fn), mdsum); for (cp = cachefn, fp = 0; (*cp = TEXCACHEDIR[fp]); cp++,fp++); *(cp++) = '/'; for (fp = 0; fp < 16; phex(mdsum[fp++], cp), cp+=2); @@ -2757,11 +2757,11 @@ static void polymost_drawalls (long bunch) if ((oy < cy0) && (oy < cy1)) domost(x1,oy,x0,oy); else if ((oy < cy0) != (oy < cy1)) { /* cy1 cy0 - // / \ - //oy---------- oy--------- - // / \ - // cy0 cy1 - */ + // / \ + //oy---------- oy--------- + // / \ + // cy0 cy1 + */ ox = (oy-cy0)*(x1-x0)/(cy1-cy0) + x0; if (oy < cy0) { domost(ox,oy,x0,oy); domost(x1,cy1,ox,oy); } else { domost(ox,oy,x0,cy0); domost(x1,oy,ox,oy); } diff --git a/polymer/build/src/pragmas.c b/polymer/build/src/pragmas.c index 5b8edbf70..963f98228 100644 --- a/polymer/build/src/pragmas.c +++ b/polymer/build/src/pragmas.c @@ -12,73 +12,7 @@ long dmval; -#if defined(NOASM) - -// -// Generic C version -// - -void qinterpolatedown16(long bufptr, long num, long val, long add) -{ // gee, I wonder who could have provided this... - long i, *lptr = (long *)bufptr; - for(i=0;i>16); val += add; } -} - -void qinterpolatedown16short(long bufptr, long num, long val, long add) -{ // ...maybe the same person who provided this too? - long i; short *sptr = (short *)bufptr; - for(i=0;i>16); val += add; } -} - -void clearbuf(void *d, long c, long a) -{ - long *p = (long*)d; - while ((c--) > 0) *(p++) = a; -} - -void copybuf(void *s, void *d, long c) -{ - long *p = (long*)s, *q = (long*)d; - while ((c--) > 0) *(q++) = *(p++); -} - -void swapbuf4(void *a, void *b, long c) -{ - long *p = (long*)a, *q = (long*)b; - long x, y; - while ((c--) > 0) { - x = *q; - y = *p; - *(q++) = y; - *(p++) = x; - } -} - -void clearbufbyte(void *D, long c, long a) -{ // Cringe City - char *p = (char*)D; - long m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l }; - long n[4] = { 0,8,16,24 }; - long z=0; - while ((c--) > 0) { - *(p++) = (char)((a & m[z])>>n[z]); - z=(z+1)&3; - } -} - -void copybufbyte(void *S, void *D, long c) -{ - char *p = (char*)S, *q = (char*)D; - while((c--) > 0) *(q++) = *(p++); -} - -void copybufreverse(void *S, void *D, long c) -{ - char *p = (char*)S, *q = (char*)D; - while((c--) > 0) *(q++) = *(p--); -} - -#elif defined(__GNUC__) && defined(__i386__) // NOASM +#if defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // NOASM // // GCC Inline Assembler version @@ -229,13 +163,13 @@ void copybufreverse(void *S, void *D, long c) ); } -#elif defined(__WATCOMC__) // __GNUC__ && __i386__ +#elif defined(__WATCOMC__) && !defined(NOASM) // __GNUC__ && __i386__ // // Watcom C Inline Assembler version // -#elif defined(_MSC_VER) // __WATCOMC__ +#elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__ // // Microsoft C Inline Assembler version @@ -243,7 +177,69 @@ void copybufreverse(void *S, void *D, long c) #else // _MSC_VER -#error Unsupported compiler or architecture. +// +// Generic C version +// + +void qinterpolatedown16(long bufptr, long num, long val, long add) +{ // gee, I wonder who could have provided this... + long i, *lptr = (long *)bufptr; + for(i=0;i>16); val += add; } +} + +void qinterpolatedown16short(long bufptr, long num, long val, long add) +{ // ...maybe the same person who provided this too? + long i; short *sptr = (short *)bufptr; + for(i=0;i>16); val += add; } +} + +void clearbuf(void *d, long c, long a) +{ + long *p = (long*)d; + while ((c--) > 0) *(p++) = a; +} + +void copybuf(void *s, void *d, long c) +{ + long *p = (long*)s, *q = (long*)d; + while ((c--) > 0) *(q++) = *(p++); +} + +void swapbuf4(void *a, void *b, long c) +{ + long *p = (long*)a, *q = (long*)b; + long x, y; + while ((c--) > 0) { + x = *q; + y = *p; + *(q++) = y; + *(p++) = x; + } +} + +void clearbufbyte(void *D, long c, long a) +{ // Cringe City + char *p = (char*)D; + long m[4] = { 0xffl,0xff00l,0xff0000l,0xff000000l }; + long n[4] = { 0,8,16,24 }; + long z=0; + while ((c--) > 0) { + *(p++) = (char)((a & m[z])>>n[z]); + z=(z+1)&3; + } +} + +void copybufbyte(void *S, void *D, long c) +{ + char *p = (char*)S, *q = (char*)D; + while((c--) > 0) *(q++) = *(p++); +} + +void copybufreverse(void *S, void *D, long c) +{ + char *p = (char*)S, *q = (char*)D; + while((c--) > 0) *(q++) = *(p--); +} #endif diff --git a/polymer/build/src/sdlayer.c b/polymer/build/src/sdlayer.c index 70bfcad4e..988953893 100644 --- a/polymer/build/src/sdlayer.c +++ b/polymer/build/src/sdlayer.c @@ -26,6 +26,12 @@ # include "osxbits.h" #elif defined HAVE_GTK2 # include "gtkbits.h" +#else +int startwin_open(void) { return 0; } +int startwin_close(void) { return 0; } +int startwin_puts(const char *s) { s=s; return 0; } +int startwin_idle(void *s) { return 0; } +int startwin_settitle(const char *s) { s=s; return 0; } #endif #define SURFACE_FLAGS (SDL_SWSURFACE|SDL_HWPALETTE|SDL_HWACCEL) @@ -130,9 +136,7 @@ void wm_setapptitle(char *name) SDL_WM_SetCaption(apptitle, NULL); -#ifdef HAVE_GTK2 - gtkbuild_settitle_startwin(apptitle); -#endif + startwin_settitle(apptitle); } @@ -154,8 +158,8 @@ int main(int argc, char *argv[]) #ifdef HAVE_GTK2 gtkbuild_init(&argc, &argv); - gtkbuild_create_startwin(); #endif + startwin_open(); _buildargc = argc; _buildargv = (char**)argv; @@ -165,8 +169,8 @@ int main(int argc, char *argv[]) baselayer_init(); r = app_main(argc, argv); + startwin_close(); #ifdef HAVE_GTK2 - gtkbuild_close_startwin(); gtkbuild_exit(r); #endif return r; @@ -280,10 +284,8 @@ void initprintf(const char *f, ...) va_end(va); OSD_Printf(buf); -#ifdef HAVE_GTK2 - gtkbuild_puts_startwin(buf); - gtkbuild_update_startwin(); -#endif + startwin_puts(buf); + startwin_idle(NULL); } @@ -689,6 +691,9 @@ void getvalidmodes(void) // do fullscreen modes first for (j=0; cdepths[j]; j++) { +#ifdef USE_OPENGL + if (nogl && cdepths[j] > 8) continue; +#endif pf.BitsPerPixel = cdepths[j]; pf.BytesPerPixel = cdepths[j] >> 3; @@ -722,6 +727,9 @@ void getvalidmodes(void) // add windowed modes next for (j=0; cdepths[j]; j++) { +#ifdef USE_OPENGL + if (nogl && cdepths[j] > 8) continue; +#endif if (cdepths[j] < 0) continue; for (i=0; defaultres[i][0]; i++) CHECK(defaultres[i][0],defaultres[i][1]) @@ -740,7 +748,7 @@ void getvalidmodes(void) // // checkvideomode() -- makes sure the video mode passed is legal // -int checkvideomode(int *x, int *y, int c, int fs) +int checkvideomode(int *x, int *y, int c, int fs, int forced) { int i, nearest=-1, dx, dy, odx=9999, ody=9999; @@ -775,10 +783,10 @@ int checkvideomode(int *x, int *y, int c, int fs) } } -#ifdef ANY_WINDOWED_SIZE - if ((fs&1) == 0 && (nearest < 0 || (validmode[nearest].xdim!=*x || validmode[nearest].ydim!=*y))) + #ifdef ANY_WINDOWED_SIZE + if (!forced && (fs&1) == 0 && (nearest < 0 || (validmode[nearest].xdim!=*x || validmode[nearest].ydim!=*y))) return 0x7fffffffl; -#endif + #endif if (nearest < 0) { // no mode that will match (eg. if no fullscreen modes) @@ -806,11 +814,9 @@ int setvideomode(int x, int y, int c, int fs) return 0; } - if (checkvideomode(&x,&y,c,fs) < 0) return -1; + if (checkvideomode(&x,&y,c,fs,0) < 0) return -1; -#ifdef HAVE_GTK2 - gtkbuild_close_startwin(); -#endif + startwin_close(); if (mouseacquired) { regrab = 1; @@ -1365,9 +1371,7 @@ int handleevents(void) sampletimer(); -#ifdef HAVE_GTK2 - gtkbuild_update_startwin(); -#endif + startwin_idle(NULL); #undef SetKey diff --git a/polymer/build/src/startgtk.editor.c b/polymer/build/src/startgtk.editor.c new file mode 100755 index 000000000..2cddd44a8 --- /dev/null +++ b/polymer/build/src/startgtk.editor.c @@ -0,0 +1,607 @@ +/* NOTE: Glade will generate code for a dialogue box which you should + * then patch into this file whenever you make a change to the Glade + * template. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "baselayer.h" +#include "compat.h" +#include "build.h" +#include "editor.h" + +#define TAB_CONFIG 0 +#define TAB_MESSAGES 1 + +static struct { + int fullscreen; + int xdim2d, ydim2d; + int xdim3d, ydim3d, bpp3d; + int forcesetup; +} settings; + +extern int gtkenabled; + +static GtkWidget *startwin = NULL; +static int retval = -1, mode = 0; + +// -- SUPPORT FUNCTIONS ------------------------------------------------------- + +#define GLADE_HOOKUP_OBJECT(component,widget,name) \ + g_object_set_data_full (G_OBJECT (component), name, \ + gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) + +#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ + g_object_set_data (G_OBJECT (component), name, widget) + +#define lookup_widget(x,w) \ + (GtkWidget*) g_object_get_data(G_OBJECT(x), w) + +static GdkPixbuf *load_banner(void) +{ + extern const GdkPixdata startbanner_pixdata; + return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); +} + +static void SetPage(int n) +{ + if (!gtkenabled || !startwin) return; + gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); +} + +static void EnableConfig(int n) +{ + // each control in the config page vertical layout plus the dialogue buttons should be made (in)sensitive + mode = n; + gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"buttons")), + (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); + gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), + (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); +} + +static void on_vmode2dcombo_changed(GtkComboBox *, gpointer); +static void on_vmode3dcombo_changed(GtkComboBox *, gpointer); +static void PopulateForm(void) +{ + int mode2d, mode3d, i; + GtkListStore *modes2d, *modes3d; + GtkTreeIter iter; + GtkComboBox *box2d, *box3d; + char buf[64]; + + mode2d = checkvideomode(&settings.xdim2d, &settings.ydim2d, 8, settings.fullscreen, 1); + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); + if (mode2d < 0) mode2d = 0; + if (mode3d < 0) { + int i, cd[] = { 32, 24, 16, 15, 8, 0 }; + for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; } + for ( ; cd[i]; i++) { + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); + if (mode3d < 0) continue; + settings.bpp3d = cd[i]; + break; + } + } + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup); + + box2d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode2dcombo")); + box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo")); + modes2d = GTK_LIST_STORE(gtk_combo_box_get_model(box2d)); + modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d)); + gtk_list_store_clear(modes2d); + gtk_list_store_clear(modes3d); + + for (i=0; i aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); +#if GTK_CHECK_VERSION(2,6,0) + gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); +#else + { + GtkTextIter iter2 = enditer; + gtk_text_iter_backward_cursor_position(&iter2); + //FIXME: this seems be deleting one too many chars somewhere! + if (!gtk_text_iter_equal(&iter2, &enditer)) + gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); + } +#endif + aptr = ++bptr; + break; + case 0: + if (bptr > aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); + aptr = bptr; + break; + case '\r': // FIXME + default: + bptr++; + break; + } + } + + mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1); + gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0); + gtk_text_buffer_delete_mark(textbuffer, mark); + + return 0; +} + +int startwin_settitle(const char *title) +{ + if (!gtkenabled) return 0; + if (!startwin) return 1; + gtk_window_set_title (GTK_WINDOW (startwin), title); + return 0; +} + +int startwin_idle(void *s) +{ + if (!gtkenabled) return 0; + //if (!startwin) return 1; + gtk_main_iteration_do (FALSE); + return 0; +} + +int startwin_run(void) +{ + if (!gtkenabled) return 0; + if (!startwin) return 1; + + SetPage(TAB_CONFIG); + EnableConfig(TRUE); + + settings.fullscreen = fullscreen; + settings.xdim2d = xdim2d; + settings.ydim2d = ydim2d; + settings.xdim3d = xdimgame; + settings.ydim3d = ydimgame; + settings.bpp3d = bppgame; + settings.forcesetup = forcesetup; + PopulateForm(); + + gtk_main(); + + SetPage(TAB_MESSAGES); + EnableConfig(FALSE); + if (retval) { + fullscreen = settings.fullscreen; + xdim2d = settings.xdim2d; + ydim2d = settings.ydim2d; + xdimgame = settings.xdim3d; + ydimgame = settings.ydim3d; + bppgame = settings.bpp3d; + forcesetup = settings.forcesetup; + } + + return retval; +} + diff --git a/polymer/build/src/startgtk.game.c b/polymer/build/src/startgtk.game.c new file mode 100755 index 000000000..4a4e1d222 --- /dev/null +++ b/polymer/build/src/startgtk.game.c @@ -0,0 +1,540 @@ +/* NOTE: Glade will generate code for a dialogue box which you should + * then patch into this file whenever you make a change to the Glade + * template. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "baselayer.h" +#include "compat.h" +#include "build.h" + +#define TAB_CONFIG 0 +#define TAB_MESSAGES 1 + +static struct { + int fullscreen; + int xdim3d, ydim3d, bpp3d; + int forcesetup; +} settings; + +extern int gtkenabled; + +static GtkWidget *startwin = NULL; +static int retval = -1, mode = 0; + +// -- SUPPORT FUNCTIONS ------------------------------------------------------- + +#define GLADE_HOOKUP_OBJECT(component,widget,name) \ + g_object_set_data_full (G_OBJECT (component), name, \ + gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) + +#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ + g_object_set_data (G_OBJECT (component), name, widget) + +#define lookup_widget(x,w) \ + (GtkWidget*) g_object_get_data(G_OBJECT(x), w) + +static GdkPixbuf *load_banner(void) +{ + extern const GdkPixdata startbanner_pixdata; + return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); +} + +static void SetPage(int n) +{ + if (!gtkenabled || !startwin) return; + gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); +} + +static void EnableConfig(int n) +{ + // each control in the config page vertical layout plus the dialogue buttons should be made (in)sensitive + mode = n; + gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"buttons")), + (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); + gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), + (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); +} + +static void on_vmode3dcombo_changed(GtkComboBox *, gpointer); +static void PopulateForm(void) +{ + int mode3d, i; + GtkListStore *modes3d; + GtkTreeIter iter; + GtkComboBox *box3d; + char buf[64]; + + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); + if (mode3d < 0) { + int i, cd[] = { 32, 24, 16, 15, 8, 0 }; + for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; } + for ( ; cd[i]; i++) { + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); + if (mode3d < 0) continue; + settings.bpp3d = cd[i]; + break; + } + } + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup); + + box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo")); + modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d)); + gtk_list_store_clear(modes3d); + + for (i=0; i aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); +#if GTK_CHECK_VERSION(2,6,0) + gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); +#else + { + GtkTextIter iter2 = enditer; + gtk_text_iter_backward_cursor_position(&iter2); + //FIXME: this seems be deleting one too many chars somewhere! + if (!gtk_text_iter_equal(&iter2, &enditer)) + gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); + } +#endif + aptr = ++bptr; + break; + case 0: + if (bptr > aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); + aptr = bptr; + break; + case '\r': // FIXME + default: + bptr++; + break; + } + } + + mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1); + gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0); + gtk_text_buffer_delete_mark(textbuffer, mark); + + return 0; +} + +int startwin_settitle(const char *title) +{ + if (!gtkenabled) return 0; + if (!startwin) return 1; + gtk_window_set_title (GTK_WINDOW (startwin), title); + return 0; +} + +int startwin_idle(void *s) +{ + if (!gtkenabled) return 0; + //if (!startwin) return 1; + gtk_main_iteration_do (FALSE); + return 0; +} + +extern int xdimgame, ydimgame, bppgame, forcesetup; + +int startwin_run(void) +{ + if (!gtkenabled) return 0; + if (!startwin) return 1; + + SetPage(TAB_CONFIG); + EnableConfig(TRUE); + + settings.fullscreen = fullscreen; + settings.xdim3d = xdimgame; + settings.ydim3d = ydimgame; + settings.bpp3d = bppgame; + settings.forcesetup = forcesetup; + PopulateForm(); + + gtk_main(); + + SetPage(TAB_MESSAGES); + EnableConfig(FALSE); + if (retval) { + fullscreen = settings.fullscreen; + xdimgame = settings.xdim3d; + ydimgame = settings.ydim3d; + bppgame = settings.bpp3d; + forcesetup = settings.forcesetup; + } + + return retval; +} + diff --git a/polymer/build/src/startwin.editor.c b/polymer/build/src/startwin.editor.c new file mode 100755 index 000000000..657b94cb7 --- /dev/null +++ b/polymer/build/src/startwin.editor.c @@ -0,0 +1,442 @@ +#ifndef RENDERTYPEWIN +#error Only for Windows +#endif + +#include "build.h" +#include "editor.h" +#include "winlayer.h" +#include "compat.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include +#define _WIN32_IE 0x0300 +#include +#include + +#include "startwin.editor.h" + +#define TAB_CONFIG 0 +#define TAB_MESSAGES 1 + +static struct { + int fullscreen; + int xdim2d, ydim2d; + int xdim3d, ydim3d, bpp3d; + int forcesetup; +} settings; + +static HWND startupdlg = NULL; +static HWND pages[2] = { NULL, NULL}; +static int done = -1; + +static void PopulateForm(void) +{ + int i,j; + char buf[64]; + int mode2d, mode3d; + HWND hwnd2d, hwnd3d; + + hwnd2d = GetDlgItem(pages[TAB_CONFIG], IDC2DVMODE); + hwnd3d = GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE); + + mode2d = checkvideomode(&settings.xdim2d, &settings.ydim2d, 8, settings.fullscreen, 1); + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); + if (mode2d < 0) mode2d = 0; + if (mode3d < 0) { + int cd[] = { 32, 24, 16, 15, 8, 0 }; + for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; } + for ( ; cd[i]; i++) { + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); + if (mode3d < 0) continue; + settings.bpp3d = cd[i]; + break; + } + } + + Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED)); + Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); + + ComboBox_ResetContent(hwnd2d); + ComboBox_ResetContent(hwnd3d); + for (i=0; iidFrom != WIN_STARTWIN_TABCTL) break; + cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); + switch (nmhdr->code) { + case TCN_SELCHANGING: { + if (cur < 0 || !pages[cur]) break; + ShowWindow(pages[cur],SW_HIDE); + return TRUE; + } + case TCN_SELCHANGE: { + if (cur < 0 || !pages[cur]) break; + ShowWindow(pages[cur],SW_SHOW); + return TRUE; + } + } + break; + } + + case WM_CLOSE: + done = 0; + return TRUE; + + case WM_DESTROY: + if (hbmp) { + DeleteObject(hbmp); + hbmp = NULL; + } + + if (pages[TAB_CONFIG]) { + DestroyWindow(pages[TAB_CONFIG]); + pages[TAB_CONFIG] = NULL; + } + + startupdlg = NULL; + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case WIN_STARTWIN_CANCEL: done = 0; return TRUE; + case WIN_STARTWIN_START: done = 1; return TRUE; + } + return FALSE; + + case WM_CTLCOLORSTATIC: + if ((HWND)lParam == pages[TAB_MESSAGES]) + return (BOOL)GetSysColorBrush(COLOR_WINDOW); + break; + + default: break; + } + + return FALSE; +} + + +int startwin_open(void) +{ + INITCOMMONCONTROLSEX icc; + if (startupdlg) return 1; + icc.dwSize = sizeof(icc); + icc.dwICC = ICC_TAB_CLASSES; + InitCommonControlsEx(&icc); + startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); + if (startupdlg) { + SetPage(TAB_MESSAGES); + EnableConfig(0); + return 0; + } + return -1; +} + +int startwin_close(void) +{ + if (!startupdlg) return 1; + DestroyWindow(startupdlg); + startupdlg = NULL; + return 0; +} + +int startwin_puts(const char *buf) +{ + const char *p = NULL, *q = NULL; + char workbuf[1024]; + static int newline = 0; + int curlen, linesbefore, linesafter; + HWND edctl; + int vis; + + if (!startupdlg) return 1; + + edctl = pages[TAB_MESSAGES]; + if (!edctl) return -1; + + vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES); + + if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0); + curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); + SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); + linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); + p = buf; + while (*p) { + if (newline) { + SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); + newline = 0; + } + q = p; + while (*q && *q != '\n') q++; + memcpy(workbuf, p, q-p); + if (*q == '\n') { + if (!q[1]) { + newline = 1; + workbuf[q-p] = 0; + } else { + workbuf[q-p] = '\r'; + workbuf[q-p+1] = '\n'; + workbuf[q-p+2] = 0; + } + p = q+1; + } else { + workbuf[q-p] = 0; + p = q; + } + SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); + } + linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0); + SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); + if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0); + return 0; +} + +int startwin_settitle(const char *str) +{ + if (!startupdlg) return 1; + SetWindowText(startupdlg, str); + return 0; +} + +int startwin_idle(void *v) +{ + if (!startupdlg || !IsWindow(startupdlg)) return 0; + if (IsDialogMessage(startupdlg, (MSG*)v)) return 1; + return 0; +} + +int startwin_run(void) +{ + MSG msg; + if (!startupdlg) return 1; + + done = -1; + + SetPage(TAB_CONFIG); + EnableConfig(1); + + settings.fullscreen = fullscreen; + settings.xdim2d = xdim2d; + settings.ydim2d = ydim2d; + settings.xdim3d = xdimgame; + settings.ydim3d = ydimgame; + settings.bpp3d = bppgame; + settings.forcesetup = forcesetup; + PopulateForm(); + + while (done < 0) { + switch (GetMessage(&msg, NULL, 0,0)) { + case 0: done = 1; break; + case -1: return -1; + default: + if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; + TranslateMessage(&msg); + DispatchMessage(&msg); + break; + } + } + + SetPage(TAB_MESSAGES); + EnableConfig(0); + if (done) { + fullscreen = settings.fullscreen; + xdim2d = settings.xdim2d; + ydim2d = settings.ydim2d; + xdimgame = settings.xdim3d; + ydimgame = settings.ydim3d; + bppgame = settings.bpp3d; + forcesetup = settings.forcesetup; + } + + return done; +} + diff --git a/polymer/build/src/startwin.game.c b/polymer/build/src/startwin.game.c new file mode 100755 index 000000000..efbe8b8e4 --- /dev/null +++ b/polymer/build/src/startwin.game.c @@ -0,0 +1,415 @@ +#ifndef RENDERTYPEWIN +#error Only for Windows +#endif + +#include "build.h" +#include "winlayer.h" +#include "compat.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include +#define _WIN32_IE 0x0300 +#include +#include + +#include "startwin.game.h" + +#define TAB_CONFIG 0 +#define TAB_MESSAGES 1 + +static struct { + int fullscreen; + int xdim3d, ydim3d, bpp3d; + int forcesetup; +} settings; + +static HWND startupdlg = NULL; +static HWND pages[2] = { NULL, NULL}; +static int done = -1; + +static void PopulateForm(void) +{ + int i,j; + char buf[64]; + int mode3d; + HWND hwnd3d; + + hwnd3d = GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE); + + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); + if (mode3d < 0) { + int cd[] = { 32, 24, 16, 15, 8, 0 }; + for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; } + for ( ; cd[i]; i++) { + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); + if (mode3d < 0) continue; + settings.bpp3d = cd[i]; + break; + } + } + + Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED)); + Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); + + ComboBox_ResetContent(hwnd3d); + for (i=0; iidFrom != WIN_STARTWIN_TABCTL) break; + cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); + switch (nmhdr->code) { + case TCN_SELCHANGING: { + if (cur < 0 || !pages[cur]) break; + ShowWindow(pages[cur],SW_HIDE); + return TRUE; + } + case TCN_SELCHANGE: { + if (cur < 0 || !pages[cur]) break; + ShowWindow(pages[cur],SW_SHOW); + return TRUE; + } + } + break; + } + + case WM_CLOSE: + done = 0; + return TRUE; + + case WM_DESTROY: + if (hbmp) { + DeleteObject(hbmp); + hbmp = NULL; + } + + if (pages[TAB_CONFIG]) { + DestroyWindow(pages[TAB_CONFIG]); + pages[TAB_CONFIG] = NULL; + } + + startupdlg = NULL; + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case WIN_STARTWIN_CANCEL: done = 0; return TRUE; + case WIN_STARTWIN_START: done = 1; return TRUE; + } + return FALSE; + + case WM_CTLCOLORSTATIC: + if ((HWND)lParam == pages[TAB_MESSAGES]) + return (BOOL)GetSysColorBrush(COLOR_WINDOW); + break; + + default: break; + } + + return FALSE; +} + + +int startwin_open(void) +{ + INITCOMMONCONTROLSEX icc; + if (startupdlg) return 1; + icc.dwSize = sizeof(icc); + icc.dwICC = ICC_TAB_CLASSES; + InitCommonControlsEx(&icc); + startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); + if (startupdlg) { + SetPage(TAB_MESSAGES); + EnableConfig(0); + return 0; + } + return -1; +} + +int startwin_close(void) +{ + if (!startupdlg) return 1; + DestroyWindow(startupdlg); + startupdlg = NULL; + return 0; +} + +int startwin_puts(const char *buf) +{ + const char *p = NULL, *q = NULL; + char workbuf[1024]; + static int newline = 0; + int curlen, linesbefore, linesafter; + HWND edctl; + int vis; + + if (!startupdlg) return 1; + + edctl = pages[TAB_MESSAGES]; + if (!edctl) return -1; + + vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES); + + if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0); + curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); + SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); + linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); + p = buf; + while (*p) { + if (newline) { + SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); + newline = 0; + } + q = p; + while (*q && *q != '\n') q++; + memcpy(workbuf, p, q-p); + if (*q == '\n') { + if (!q[1]) { + newline = 1; + workbuf[q-p] = 0; + } else { + workbuf[q-p] = '\r'; + workbuf[q-p+1] = '\n'; + workbuf[q-p+2] = 0; + } + p = q+1; + } else { + workbuf[q-p] = 0; + p = q; + } + SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); + } + linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0); + SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); + if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0); + return 0; +} + +int startwin_settitle(const char *str) +{ + if (!startupdlg) return 1; + SetWindowText(startupdlg, str); + return 0; +} + +int startwin_idle(void *v) +{ + if (!startupdlg || !IsWindow(startupdlg)) return 0; + if (IsDialogMessage(startupdlg, (MSG*)v)) return 1; + return 0; +} + +extern int xdimgame, ydimgame, bppgame, forcesetup; + +int startwin_run(void) +{ + MSG msg; + if (!startupdlg) return 1; + + done = -1; + + SetPage(TAB_CONFIG); + EnableConfig(1); + + settings.fullscreen = fullscreen; + settings.xdim3d = xdimgame; + settings.ydim3d = ydimgame; + settings.bpp3d = bppgame; + settings.forcesetup = forcesetup; + PopulateForm(); + + while (done < 0) { + switch (GetMessage(&msg, NULL, 0,0)) { + case 0: done = 1; break; + case -1: return -1; + default: + if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; + TranslateMessage(&msg); + DispatchMessage(&msg); + break; + } + } + + SetPage(TAB_MESSAGES); + EnableConfig(0); + if (done) { + fullscreen = settings.fullscreen; + xdimgame = settings.xdim3d; + ydimgame = settings.ydim3d; + bppgame = settings.bpp3d; + forcesetup = settings.forcesetup; + } + + return done; +} + diff --git a/polymer/build/src/startwin.game.h b/polymer/build/src/startwin.game.h new file mode 100755 index 000000000..ee446bf2a --- /dev/null +++ b/polymer/build/src/startwin.game.h @@ -0,0 +1,18 @@ +// resource ids +#define WIN_STARTWIN 1000 +#define WIN_STARTWINPAGE_CONFIG 2000 +#define WIN_STARTWIN_BITMAP 100 // banner bitmap +#define WIN_STARTWIN_TABCTL 101 +#define WIN_STARTWIN_CANCEL 102 +#define WIN_STARTWIN_START 103 + +#define WIN_STARTWIN_MESSAGES 104 // output list box + +#define RSRC_ICON 100 +#define RSRC_BMP 200 + +// config page +#define IDCFULLSCREEN 100 +#define IDC3DVMODE 101 +#define IDCALWAYSSHOW 102 + diff --git a/polymer/build/src/winlayer.c b/polymer/build/src/winlayer.c index 90578d368..3160abe3c 100644 --- a/polymer/build/src/winlayer.c +++ b/polymer/build/src/winlayer.c @@ -56,10 +56,6 @@ static HWND hWindow = 0; static BOOL window_class_registered = FALSE; static HANDLE instanceflag = NULL; -static HWND startupdlg = NULL; -static long startupdlgsaferect[4] = { -1,-1,-1,-1 }; -static int startupdlgcommand = 0; -static void (*startupdlgonclose)(void) = NULL; int backgroundidle = 1; static WORD sysgamma[3][256]; @@ -233,11 +229,7 @@ void wm_setapptitle(char *name) } if (hWindow) SetWindowText(hWindow, apptitle); - if (startupdlg) { - char buf[1000]; - Bsnprintf(buf, 1000, "%s Startup", apptitle); - SetWindowText(startupdlg, buf); - } + startwin_settitle(apptitle); } // @@ -256,143 +248,6 @@ static void SignalHandler(int signum) } } - -// -// startup_dlgproc() -- dialog procedure for the initialisation dialog -// -#define FIELDSWIDE 366 -#define PADWIDE 5 // 5 units of padding -// An overlayed child dialog should have the DS_CONTROL style - -static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static HBITMAP hbmp = NULL; - RECT rdlg, rbmp, rtxt; - HDC hdc; - int height=5; - - switch (uMsg) { - case WM_INITDIALOG: - // set the bitmap - hbmp = LoadBitmap(hInstance, MAKEINTRESOURCE(WIN_STARTWINBMP)); - SendDlgItemMessage(hwndDlg, WIN_STARTWIN_ITEMBITMAP, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); - - // fetch the adjusted size - GetClientRect(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMBITMAP), &rbmp); - rbmp.right++; rbmp.bottom++; - - GetClientRect(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMTEXT), &rtxt); - rtxt.bottom++; - - // move the bitmap to the top of the client area - MoveWindow(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMBITMAP), - 0,0, rbmp.right,rbmp.bottom, - FALSE); - - // move the label - MoveWindow(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMTEXT), - rbmp.right+PADWIDE,PADWIDE, FIELDSWIDE,rtxt.bottom, - FALSE); - - // move the list box - MoveWindow(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMLIST), - rbmp.right+PADWIDE,PADWIDE+rtxt.bottom+PADWIDE, - FIELDSWIDE,rbmp.bottom-(PADWIDE+rtxt.bottom+PADWIDE+PADWIDE), - FALSE); - - SendDlgItemMessage(hwndDlg,WIN_STARTWIN_ITEMLIST, EM_LIMITTEXT, 0,0); - { - RECT rg; - GetWindowRect(GetDlgItem(hwndDlg,WIN_STARTWIN_ITEMLIST),&rg); - rg.right -= rg.left + GetSystemMetrics(SM_CXVSCROLL)+4; - rg.bottom -= rg.top; - rg.left = rg.top = 0; - SendDlgItemMessage(hwndDlg,WIN_STARTWIN_ITEMLIST, EM_SETRECTNP,0,(LPARAM)&rg); - } - - rdlg.left = 0; - rdlg.top = 0; - rdlg.right = rbmp.right+PADWIDE+FIELDSWIDE+PADWIDE; - rdlg.bottom = rbmp.bottom; - - AdjustWindowRect(&rdlg, - GetWindowLong(hwndDlg, GWL_STYLE), - FALSE); - - rdlg.right -= rdlg.left; - rdlg.bottom -= rdlg.top; - - hdc = GetDC(NULL); - rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; - rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; - ReleaseDC(NULL, hdc); - - SetWindowPos(hwndDlg,NULL, - rdlg.left,rdlg.top, - rdlg.right,rdlg.bottom, - SWP_NOREPOSITION); - - // save the safe region of the window - startupdlgsaferect[0] = rbmp.right; // left - startupdlgsaferect[1] = 0; // top - startupdlgsaferect[2] = PADWIDE+FIELDSWIDE+PADWIDE; // width - startupdlgsaferect[3] = rbmp.bottom; // height - - return TRUE; - - case WM_CLOSE: - quitevent = 1; - return TRUE; - - case WM_DESTROY: - if (hbmp) { - DeleteObject(hbmp); - hbmp = NULL; - } - - if (startupdlgonclose) startupdlgonclose(); - - startupdlg = NULL; - return TRUE; - - case WM_COMMAND: - startupdlgcommand = LOWORD(wParam); - return FALSE; - - case WM_CTLCOLORSTATIC: - switch (GetDlgCtrlID((HWND)lParam)) { - case WIN_STARTWIN_ITEMLIST: - return (BOOL)GetSysColorBrush(COLOR_WINDOW); - default: break; - } - break; - - default: break; - } - - return FALSE; -} - - -int win_getstartupwin(long *hwnd, long saferect[4], void (*onclose)(void)) -{ - if (!startupdlg) return 1; - - *hwnd = (long)startupdlg; - memcpy(saferect, startupdlgsaferect, sizeof(long)*4); - startupdlgonclose = onclose; - - return 0; -} - -int win_getstartupcommand(void) -{ - int t = startupdlgcommand; - startupdlgcommand = 0; - return t; -} - - // // WinMain() -- main Windows entry point // @@ -502,16 +357,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC atexit(uninitsystem); - baselayer_init(); - instanceflag = CreateSemaphore(NULL, 1,1, WindowClass); - startupdlg = CreateDialog(hInstance, MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); + startwin_open(); + baselayer_init(); r = app_main(_buildargc, _buildargv); fclose(stdout); + startwin_close(); if (instanceflag) CloseHandle(instanceflag); if (argvbuf) free(argvbuf); @@ -593,9 +448,7 @@ void uninitsystem(void) { DestroyAppWindow(); - if (startupdlg) { - DestroyWindow(startupdlg); - } + startwin_close(); uninitinput(); uninittimer(); @@ -615,57 +468,12 @@ void initprintf(const char *f, ...) { va_list va; char buf[1024],*p=NULL,*q=NULL,workbuf[1024]; - //int i = 0; - - static int newline = 0;//1; - // int overwriteline = -1; va_start(va, f); Bvsnprintf(buf, 1024, f, va); va_end(va); OSD_Printf(buf); - if (!startupdlg) return; - - { - int curlen, linesbefore, linesafter; - HWND edctl; - - edctl = GetDlgItem(startupdlg,102); - if (!edctl) return; - - SendMessage(edctl, WM_SETREDRAW, FALSE,0); - curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); - SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); - linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); - p = buf; - while (*p) { - if (newline) { - SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); - newline = 0; - } - q = p; - while (*q && *q != '\n') q++; - memcpy(workbuf, p, q-p); - if (*q == '\n') { - if (!q[1]) { - newline = 1; - workbuf[q-p] = 0; - } else { - workbuf[q-p] = '\r'; - workbuf[q-p+1] = '\n'; - workbuf[q-p+2] = 0; - } - p = q+1; - } else { - workbuf[q-p] = 0; - p = q; - } - SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); - } - linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0); - SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); - SendMessage(edctl, WM_SETREDRAW, TRUE,0); - } + startwin_puts(buf); handleevents(); } @@ -705,7 +513,7 @@ int handleevents(void) if (msg.message == WM_QUIT) quitevent = 1; - if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) continue; + if (startwin_idle((void*)&msg) > 0) continue; TranslateMessage(&msg); DispatchMessage(&msg); @@ -1531,67 +1339,6 @@ static void ProcessInputDevices(void) for (i=0; i shiftkey=1, shiftkeycount=0\n"); - } - } else { - if ((thiskey == (SHIFT|UP)) && (nextkey == (NUMPAD|DOWN))) { - shiftkeycount--; - initprintf("shift is up and next key is numpad and down, shiftkeycount=%d\n", - shiftkeycount); - continue; - } else if (thiskey & SHIFT) { - if (thiskey & DOWN) { - shiftkeycount++; - initprintf("shift key down, shiftkeycount=%d\n", shiftkeycount); - continue; - } else { - if (shiftkeycount == 0) { - shiftkey = 0; - initprintf("shift key up and shiftkeycount == 0, shiftkey=0\n"); - } else { - shiftkeycount--; - initprintf("shift key up and shiftkeycount=%d\n",shiftkeycount); - continue; - } - } - } - } -#undef NUMPAD -#undef SHIFT -#undef UP -#undef DOWN - } -#endif - if (k == DIK_PAUSE) continue; // fucking pause // hook in the osd @@ -1960,7 +1707,7 @@ static int getgammaramp(WORD gt[3][256]); // // checkvideomode() -- makes sure the video mode passed is legal // -int checkvideomode(int *x, int *y, int c, int fs) +int checkvideomode(int *x, int *y, int c, int fs, int forced) { int i, nearest=-1, dx, dy, odx=9999, ody=9999; @@ -1990,7 +1737,7 @@ int checkvideomode(int *x, int *y, int c, int fs) } #ifdef ANY_WINDOWED_SIZE - if ((fs&1) == 0 && (nearest < 0 || validmode[nearest].xdim!=*x || validmode[nearest].ydim!=*y)) { + if (!forced && (fs&1) == 0 && (nearest < 0 || validmode[nearest].xdim!=*x || validmode[nearest].ydim!=*y)) { // check the colour depth is recognised at the very least for (i=0;i&1 $(OBJ)%.$o: $(SRC)misc/%.rc - windres -i $< -o $@ + windres -i $< -o $@ --include-dir=$(EINC) --include-dir=$(SRC) $(OBJ)%.$o: $(SRC)util/%.c $(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1 diff --git a/polymer/eduke32/Makefile.deps b/polymer/eduke32/Makefile.deps index 401b5a001..dbfaf4126 100644 --- a/polymer/eduke32/Makefile.deps +++ b/polymer/eduke32/Makefile.deps @@ -27,8 +27,9 @@ $(OBJ)astub.$o: $(SRC)astub.c $(EINC)build.h $(EINC)pragmas.h $(EINC)compat.h $( $(OBJ)game_icon.$o: $(RSRC)game_icon.c $(OBJ)build_icon.$o: $(RSRC)build_icon.c -$(OBJ)gameres.$o: $(SRC)misc/gameres.rc $(RSRC)game.bmp $(RSRC)game_icon.ico -$(OBJ)buildres.$o: $(SRC)misc/buildres.rc $(RSRC)build.bmp $(RSRC)build_icon.ico +$(OBJ)gameres.$o: $(SRC)misc/gameres.rc $(SRC)startwin.game.h $(RSRC)game.bmp $(RSRC)game_icon.ico +$(OBJ)buildres.$o: $(SRC)misc/buildres.rc $(EINC)startwin.editor.h $(RSRC)build.bmp $(RSRC)build_icon.ico +$(OBJ)startwin.game.$o: $(SRC)startwin.game.c $(duke3d_h) $(EINC)build.h $(EINC)winlayer.h $(EINC)compat.h # jMACT objects $(OBJ)animlib.$o: $(SRC)jmact/animlib.c $(SRC)jmact/types.h $(INC)develop.h $(SRC)jmact/util_lib.h $(SRC)jmact/animlib.h $(EINC)compat.h diff --git a/polymer/eduke32/build.cfg b/polymer/eduke32/build.cfg deleted file mode 100644 index 60c444b2d..000000000 --- a/polymer/eduke32/build.cfg +++ /dev/null @@ -1,104 +0,0 @@ -; Build editor configuration - -; Video mode selection -; 0 - Windowed -; 1 - Fullscreen -fullscreen = 0 - -; Video resolution selection -; 0 - 320 x 200 -; 1 - 360 x 200 -; 2 - 320 x 240 -; 3 - 360 x 240 -; 4 - 320 x 400 -; 5 - 360 x 400 -; 6 - 640 x 350 -; 7 - 640 x 400 -; 8 - 640 x 480 -; 9 - 800 x 600 -; 10 - 1024 x 768 -; 11 - 1280 x 1024 -; 12 - 1600 x 1200 -; You can select a seperate 2D editor resolution by -; removing the semicolon from the second line below -; and selecting a mode number. The minimum 2D mode -; is 640x480 (mode #8) -resolution = 8 -;2dresolution = 8 - -; 3D mode colour depth -bpp = 8 - -; Maximum OpenGL mode refresh rate (Windows only, in Hertz) -maxrefreshfreq = 60 - -; 3D mode brightness setting -; 0 - lowest -; 15 - highest -brightness = 0 - -; Sound sample frequency -; 0 - 6 KHz -; 1 - 8 KHz -; 2 - 11.025 KHz -; 3 - 16 KHz -; 4 - 22.05 KHz -; 5 - 32 KHz -; 6 - 44.1 KHz -samplerate = 4 - -; Music playback -; 0 - Off -; 1 - On -music = 1 - -; Enable mouse -; 0 - No -; 1 - Yes -mouse = 1 - -; Mouse sensitivity -mousesensitivity = 1.0 - -; Key Settings -; Here's a map of all the keyboard scan codes: NOTE: values are listed in hex! -; +---------------------------------------------------------------------------------------------+ -; | 01 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 | -; |ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL | -; | | -; |29 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E D2 C7 C9 45 B5 37 4A | -; | ` '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' - = BACK INS HOME PGUP NUMLK KP/ KP* KP- | -; | | -; | 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 2B D3 CF D1 47 48 49 4E | -; |TAB Q W E R T Y U I O P [ ] \ DEL END PGDN KP7 KP8 KP9 KP+ | -; | | -; | 3A 1E 1F 20 21 22 23 24 25 26 27 28 1C 4B 4C 4D | -; |CAPS A S D F G H J K L ; ' ENTER KP4 KP5 KP6 9C | -; | KPENTER| -; | 2A 2C 2D 2E 2F 30 31 32 33 34 35 36 C8 4F 50 51 | -; |LSHIFT Z X C V B N M , . / RSHIFT UP KP1 KP2 KP3 | -; | | -; | 1D 38 39 B8 9D CB D0 CD 52 53 | -; |LCTRL LALT SPACE RALT RCTRL LEFT DOWN RIGHT KP0 KP. | -; +---------------------------------------------------------------------------------------------+ - -keyforward = C8 -keybackward = D0 -keyturnleft = CB -keyturnright = CD -keyrun = 2A -keystrafe = 9D -keyfire = 1D -keyuse = 39 -keystandhigh = 1E -keystandlow = 2C -keylookup = D1 -keylookdown = C9 -keystrafeleft = 33 -keystraferight = 34 -key2dmode = 9C -keyviewcycle = 1C -key2dzoomin = D -key2dzoomout = C -keychat = F - diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 20858d591..6386467e3 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -2429,7 +2429,7 @@ void moveweapons(void) dax = s->x; day = s->y; daz = s->z; - if(thisprojectile[i].range > 0) + if(thisprojectile[i].workslike & PROJECTILE_FLAG_TIMED && thisprojectile[i].range > 0) { if (!(hittype[i].temp_data[8])) hittype[i].temp_data[8] = 1; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index d3689d8c3..f4835520c 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -4220,7 +4220,7 @@ int ExtInit(void) long rv = 0; char *duke3dgrp = "duke3d.grp"; -#if 1 // defined(_WIN32) +#if defined(_WIN32) if (!access("user_profiles_enabled", F_OK)) #endif { diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 71ebf5fc1..9b1ed1a6d 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -95,6 +95,7 @@ int32 ScreenWidth = 800; int32 ScreenHeight = 600; int32 ScreenBPP = 8; #endif +int32 ForceSetup = 1; static char setupfilename[256]={SETUPFILENAME}; int32 scripthandle = -1; @@ -558,7 +559,7 @@ void readsavenames(void) =================== */ -void CONFIG_ReadSetup( void ) +int32 CONFIG_ReadSetup( void ) { int32 dummy, i; char commmacro[] = "CommbatMacro# "; @@ -572,6 +573,8 @@ void CONFIG_ReadSetup( void ) if (SafeFileExists(setupfilename)) // JBF 20031211 scripthandle = SCRIPT_Load( setupfilename ); + if (scripthandle < 0) return -1; + if (scripthandle >= 0) { for(dummy = 0;dummy < 10;dummy++) @@ -639,6 +642,7 @@ void CONFIG_ReadSetup( void ) SCRIPT_GetNumber( scripthandle, "Misc", "Executions",&ud.executions); ud.executions++; + SCRIPT_GetNumber( scripthandle, "Setup", "ForceSetup",&ForceSetup); SCRIPT_GetNumber( scripthandle, "Misc", "RunMode",&RunMode); SCRIPT_GetNumber( scripthandle, "Misc", "Crosshairs",&ud.crosshair); SCRIPT_GetNumber( scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale); @@ -702,8 +706,8 @@ void CONFIG_ReadSetup( void ) //CONFIG_SetupMouse(scripthandle); //CONFIG_SetupJoystick(scripthandle); - setupread = 1; + return 0; } /* @@ -742,6 +746,7 @@ void CONFIG_WriteSetup( void ) SCRIPT_PutNumber( scripthandle, "Misc", "Crosshairs",ud.crosshair,false,false); SCRIPT_PutNumber( scripthandle, "Misc", "DemoCams",ud.democams,false,false); SCRIPT_PutNumber( scripthandle, "Misc", "Executions",ud.executions,false,false); + SCRIPT_PutNumber( scripthandle, "Setup", "ForceSetup",ForceSetup,false,false); SCRIPT_PutNumber( scripthandle, "Misc", "IDPlayers",ud.idplayers,false,false); SCRIPT_PutNumber( scripthandle, "Misc", "MPMessageDisplayTime",ud.msgdisptime,false,false); SCRIPT_PutNumber( scripthandle, "Misc", "RunMode",RunMode,false,false); diff --git a/polymer/eduke32/source/config.h b/polymer/eduke32/source/config.h index 1f9daffc2..8b0ca323a 100644 --- a/polymer/eduke32/source/config.h +++ b/polymer/eduke32/source/config.h @@ -52,6 +52,7 @@ extern int32 ScreenMode; extern int32 ScreenWidth; extern int32 ScreenHeight; extern int32 ScreenBPP; +extern int32 ForceSetup; extern byte KeyboardKeys[NUMGAMEFUNCTIONS][2]; extern int32 MouseFunctions[MAXMOUSEBUTTONS][2]; @@ -65,7 +66,7 @@ extern int32 JoystickAnalogueScale[MAXJOYAXES]; extern int32 JoystickAnalogueDead[MAXJOYAXES]; extern int32 JoystickAnalogueSaturate[MAXJOYAXES]; -void CONFIG_ReadSetup( void ); +int32 CONFIG_ReadSetup( void ); void CONFIG_GetSetupFilename( void ); void CONFIG_WriteSetup( void ); void CONFIG_SetupMouse( void ); diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index def333cdf..467e9738b 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -260,7 +260,7 @@ extern char *CONFIG_AnalogNumToName(int32 func); extern void CONFIG_SetDefaults(void ); extern void CONFIG_ReadKeys(void ); extern void readsavenames(void ); -extern void CONFIG_ReadSetup(void ); +extern int32 CONFIG_ReadSetup(void ); extern void CONFIG_WriteSetup(void ); extern void CheckAnimStarted(char *funcname); extern uint16 findpage(uint16 framenumber); diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index a991e3738..f903bac16 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "util_lib.h" -#define VERSION " 1.4.0svn" +#define VERSION " 1.4.0 beta 2" #define HEAD "EDuke32"VERSION" (shareware mode)" #define HEAD2 "EDuke32"VERSION @@ -56,8 +56,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. long cameradist = 0, cameraclock = 0; char playerswhenstarted; -char qe,cp; +char qe,cp,usecwd = 0; +static int32 CommandSetup = 0; static int32 CommandSoundToggleOff = 0; static int32 CommandMusicToggleOff = 0; static char *CommandMap = NULL; @@ -7611,7 +7612,11 @@ void comlinehelp(char **argv) "-map FILE\tUse a map FILE\n" "-name NAME\tFoward NAME\n" "-net\t\tNet mode game\n" + "-setup\t\tDisplays the configuration dialog\n" "-nD\t\tDump game definitions to gamevars.txt\n" +#if !defined(_WIN32) + "-usecwd\t\tRead game data and configuration file from working directory\n" +#endif "-condebug, -z#\tLine-by-line CON compilation debugging"; wm_msgbox(apptitle,s); } @@ -7757,6 +7762,11 @@ void checkcommandline(int argc,char **argv) c = argv[i]; if (((*c == '/') || (*c == '-')) && (!firstnet)) { + if (!Bstrcasecmp(c+1,"setup")) { + CommandSetup = 1; + i++; + continue; + } if (!Bstrcasecmp(c+1,"keepaddr")) { keepaddr = 1; i++; @@ -7895,6 +7905,13 @@ void checkcommandline(int argc,char **argv) i++; continue; } +#if !defined(_WIN32) + if (!Bstrcasecmp(c+1,"usecwd")) { + usecwd = 1; + i++; + continue; + } +#endif } if (firstnet > 0) { @@ -8494,6 +8511,8 @@ void sanitizegametype() // initprintf("ud.m_coop=%i after sanitisation\n",ud.m_coop); } +extern int startwin_run(void); + void Startup(void) { int i; @@ -8502,7 +8521,22 @@ void Startup(void) compilecons(); - CONFIG_ReadSetup(); + i = CONFIG_ReadSetup(); + + if (initengine()) { + wm_msgbox("Build Engine Initialisation Error", + "There was a problem initialising the Build engine: %s", engineerrstr); + exit(1); + } + +#if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2) + if (i < 0 || ForceSetup || CommandSetup) { + if (!startwin_run()) { + uninitengine(); + exit(0); + } + } +#endif setupdynamictostatic(); @@ -8558,12 +8592,6 @@ void Startup(void) if(ud.executions >= 50) initprintf("IT IS NOW TIME TO UPGRADE TO THE COMPLETE VERSION!!!\n"); } - if (initengine()) { - wm_msgbox("Build Engine Initialisation Error", - "There was a problem initialising the Build engine: %s", engineerrstr); - exit(1); - } - if (CONTROL_Startup( 1, &GetTime, TICRATE )) { uninitengine(); exit(1); @@ -8811,8 +8839,10 @@ void app_main(int argc,char **argv) OSD_SetLogFile("eduke32.log"); -#if 1 // defined(_WIN32) +#if defined(_WIN32) if (!access("user_profiles_enabled", F_OK)) +#else + if (usecwd == 0) #endif { char cwd[BMAX_PATH]; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 2aae0b5ea..76ed54776 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -2432,7 +2432,7 @@ cheat_for_port_credits: case 2: { int dax = xdim, day = ydim, daz; - curvidmode = newvidmode = checkvideomode(&dax,&day,bpp,fullscreen); + curvidmode = newvidmode = checkvideomode(&dax,&day,bpp,fullscreen,0); if (newvidmode == 0x7fffffffl) newvidmode = validmodecnt; newfullscreen = fullscreen; changesmade = 0; diff --git a/polymer/eduke32/source/misc/buildres.rc b/polymer/eduke32/source/misc/buildres.rc index 5f22e6354..22c1ef82c 100644 --- a/polymer/eduke32/source/misc/buildres.rc +++ b/polymer/eduke32/source/misc/buildres.rc @@ -1,30 +1,33 @@ #include +#include +#include "startwin.editor.h" -100 ICON "rsrc/build_icon.ico" -200 BITMAP "rsrc/build.bmp" +RSRC_ICON ICON "rsrc/build_icon.ico" +RSRC_BMP BITMAP "rsrc/build.bmp" -1000 DIALOGEX DISCARDABLE 20, 40, 265, 233 +WIN_STARTWIN DIALOGEX DISCARDABLE 20, 40, 260, 200 STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU CAPTION "Startup" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255 - CONTROL "Starting Build Editor for Duke Nukem 3D...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8 - CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138 + CONTROL "", WIN_STARTWIN_BITMAP, "STATIC", SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 32, 32 + CONTROL "", WIN_STARTWIN_TABCTL, WC_TABCONTROL, WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 5, 250, 170 + CONTROL "&Start", WIN_STARTWIN_START, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 154, 180, 48, 14 + CONTROL "&Cancel", WIN_STARTWIN_CANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 207, 180, 48, 14 + + CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32 END -2000 DIALOGEX DISCARDABLE 20, 40, 279, 168 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL +WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD CAPTION "Dialog" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "Video mode", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 5, 3, 128, 64 - CONTROL "&Fullscreen", 100, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 15, 49, 10 - CONTROL "&2D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 30, 37, 8 - CONTROL "", 101, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 28, 75, 56 - CONTROL "&3D mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 12, 47, 37, 8 - CONTROL "", 102, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 50, 46, 75, 56 - CONTROL "&Continue", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 140, 145, 64, 17 - CONTROL "E&xit", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 208, 145, 64, 17 + CONTROL "&2D Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 8, 50, 8 + CONTROL "", IDC2DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56 + CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10 + CONTROL "&3D Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 24, 50, 8 + CONTROL "", IDC3DVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 22, 80, 56 + CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8 END diff --git a/polymer/eduke32/source/misc/gameres.rc b/polymer/eduke32/source/misc/gameres.rc index df1d1c2f2..4f720717e 100644 --- a/polymer/eduke32/source/misc/gameres.rc +++ b/polymer/eduke32/source/misc/gameres.rc @@ -1,14 +1,45 @@ #include +#include +#include "startwin.game.h" -100 ICON "rsrc/game_icon.ico" -200 BITMAP "rsrc/game.bmp" +RSRC_ICON ICON "rsrc/game_icon.ico" +RSRC_ICON+1 ICON "rsrc/game_icon.ico" +RSRC_ICON+2 ICON "rsrc/game_icon.ico" +RSRC_BMP BITMAP "rsrc/game.bmp" -1000 DIALOGEX DISCARDABLE 20, 40, 265, 233 +WIN_STARTWIN DIALOGEX DISCARDABLE 20, 40, 260, 200 STYLE DS_MODALFRAME | DS_CENTER | DS_SETFONT | DS_FIXEDSYS | WS_OVERLAPPED | WS_CAPTION | WS_VISIBLE | WS_SYSMENU CAPTION "Startup" FONT 8, "MS Shell Dlg" BEGIN - CONTROL "", 100, "STATIC", SS_BITMAP | SS_SUNKEN | WS_CHILD | WS_VISIBLE, 5, 5, 255, 255 - CONTROL "Starting EDuke32...", 101, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 5, 79, 255, 8 - CONTROL "", 102, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 5, 92, 255, 138 + CONTROL "", WIN_STARTWIN_BITMAP, "STATIC", SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 32, 32 + CONTROL "", WIN_STARTWIN_TABCTL, WC_TABCONTROL, WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 5, 250, 170 + CONTROL "&Start", WIN_STARTWIN_START, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 154, 180, 48, 14 + CONTROL "&Cancel", WIN_STARTWIN_CANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 207, 180, 48, 14 + + CONTROL "", WIN_STARTWIN_MESSAGES, "EDIT", ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VSCROLL, 0, 0, 32, 32 END + +WIN_STARTWINPAGE_CONFIG DIALOGEX DISCARDABLE 20, 40, 279, 168 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +CAPTION "Dialog" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "&Video mode:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 8, 50, 8 + CONTROL "", IDCVMODE, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 6, 80, 56 + CONTROL "&Fullscreen", IDCFULLSCREEN, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 148, 8, 49, 10 + + CONTROL "S&ound driver:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 28, 50, 8 + CONTROL "", IDCSOUNDDRV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 26, 110, 56 + CONTROL "&MIDI device:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 44, 50, 8 + CONTROL "", IDCMIDIDEV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 42, 110, 56 + CONTROL "C&D drive:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 60, 50, 8 + CONTROL "", IDCCDADEV, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 60, 58, 40, 56 + + CONTROL "Input devices:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 80, 50, 8 + CONTROL "Mo&use", IDCINPUTMOUSE, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 60, 80, 49, 8 + CONTROL "&Joystick", IDCINPUTJOY, "BUTTON", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 110, 80, 49, 8 + + CONTROL "&Always show configuration on start", IDCALWAYSSHOW, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 118, 116, 140, 8 +END + diff --git a/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.glade b/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.glade new file mode 100755 index 000000000..f0c32fa17 --- /dev/null +++ b/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.glade @@ -0,0 +1,551 @@ + + + + + + + True + Startup + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + + + + + True + False + 0 + + + + + 0 + False + False + + + + + + True + False + 0 + + + + 4 + True + True + True + True + GTK_POS_TOP + False + False + + + + True + False + 0 + + + + 6 + True + + + + 85 + 29 + True + True + _Fullscreen + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + + 248 + 0 + + + + + + 88 + 29 + True + _Video mode: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + vmode3dcombo + + + 0 + 0 + + + + + + 88 + 20 + True + Input devices: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 120 + + + + + + 88 + 29 + True + S_ound driver: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + sounddrvcombo + + + 0 + 40 + + + + + + 88 + 29 + True + C_D drive: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + cddrvcombo + + + 0 + 72 + + + + + + 31 + 30 + True + + + + + 88 + 40 + + + + + + 31 + 30 + True + + + + 88 + 72 + + + + + + 80 + 20 + True + True + Mo_use + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + + 88 + 120 + + + + + + 80 + 20 + True + True + _Joystick + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + + 168 + 120 + + + + + + 150 + 29 + True + + + + + 88 + 0 + + + + + 0 + True + True + + + + + + True + True + _Always show configuration on start + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + + 0 + False + False + + + + + False + True + + + + + + True + Configuration + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + False + 0 + 0 + 0 + 2 + 2 + 0 + + + + + + False + True + + + + + + True + Messages + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + 3 + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Cancel + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-execute + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Start + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + True + + + + + 0 + True + True + + + + + + + diff --git a/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.gladep b/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.gladep new file mode 100755 index 000000000..e27cd5bd5 --- /dev/null +++ b/polymer/eduke32/source/misc/gtkstartwin/gtkstartwin.gladep @@ -0,0 +1,11 @@ + + + + + Gtkstartwin + gtkstartwin + FALSE + FALSE + FALSE + FALSE + diff --git a/polymer/eduke32/source/misc/gtkstartwin/pixmaps/game.bmp b/polymer/eduke32/source/misc/gtkstartwin/pixmaps/game.bmp new file mode 100755 index 000000000..db0f6b5ba Binary files /dev/null and b/polymer/eduke32/source/misc/gtkstartwin/pixmaps/game.bmp differ diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 3cacd0c83..cff7496a9 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1000,6 +1000,7 @@ void newgame(char vn,char ln,char sk) if(globalskillsound >= 0 && FXDevice >= 0 && SoundToggle) while(issoundplaying(-1,globalskillsound)) { handleevents(); getpackets(); } + else { handleevents(); getpackets(); } globalskillsound = -1; waitforeverybody(); diff --git a/polymer/eduke32/source/startgtk.game.c b/polymer/eduke32/source/startgtk.game.c new file mode 100755 index 000000000..c89dbc9d9 --- /dev/null +++ b/polymer/eduke32/source/startgtk.game.c @@ -0,0 +1,642 @@ +/* NOTE: Glade will generate code for a dialogue box which you should + * then patch into this file whenever you make a change to the Glade + * template. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "duke3d.h" +#include "build.h" +#include "compat.h" +#include "baselayer.h" + +#define TAB_CONFIG 0 +#define TAB_MESSAGES 1 + +static struct { + int fullscreen; + int xdim3d, ydim3d, bpp3d; + int forcesetup; + int usemouse, usejoy; +} settings; + +extern int gtkenabled; + +static GtkWidget *startwin = NULL; +static int retval = -1, mode = 0; + +// -- SUPPORT FUNCTIONS ------------------------------------------------------- + +#define GLADE_HOOKUP_OBJECT(component,widget,name) \ + g_object_set_data_full (G_OBJECT (component), name, \ + gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) + +#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ + g_object_set_data (G_OBJECT (component), name, widget) + +#define lookup_widget(x,w) \ + (GtkWidget*) g_object_get_data(G_OBJECT(x), w) + +static GdkPixbuf *load_banner(void) +{ + extern const GdkPixdata startbanner_pixdata; + return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); +} + +static void SetPage(int n) +{ + if (!gtkenabled || !startwin) return; + gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); +} + +static void EnableConfig(int n) +{ + // each control in the config page vertical layout plus the dialogue buttons should be made (in)sensitive + mode = n; + gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"buttons")), + (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); + gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), + (GtkCallback)gtk_widget_set_sensitive, (gpointer)mode); +} + +static void on_vmode3dcombo_changed(GtkComboBox *, gpointer); +static void PopulateForm(void) +{ + int mode3d, i; + GtkListStore *modes3d; + GtkTreeIter iter; + GtkComboBox *box3d; + char buf[64]; + + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); + if (mode3d < 0) { + int i, cd[] = { 32, 24, 16, 15, 8, 0 }; + for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp3d) i++; else break; } + for ( ; cd[i]; i++) { + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); + if (mode3d < 0) continue; + settings.bpp3d = cd[i]; + break; + } + } + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"fullscreencheck")), settings.fullscreen); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(startwin,"alwaysshowcheck")), settings.forcesetup); + + box3d = GTK_COMBO_BOX(lookup_widget(startwin,"vmode3dcombo")); + modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d)); + gtk_list_store_clear(modes3d); + + for (i=0; i aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); +#if GTK_CHECK_VERSION(2,6,0) + gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); +#else + { + GtkTextIter iter2 = enditer; + gtk_text_iter_backward_cursor_position(&iter2); + //FIXME: this seems be deleting one too many chars somewhere! + if (!gtk_text_iter_equal(&iter2, &enditer)) + gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); + } +#endif + aptr = ++bptr; + break; + case 0: + if (bptr > aptr) + gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); + aptr = bptr; + break; + case '\r': // FIXME + default: + bptr++; + break; + } + } + + mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1); + gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0); + gtk_text_buffer_delete_mark(textbuffer, mark); + + return 0; +} + +int startwin_settitle(const char *title) +{ + if (!gtkenabled) return 0; + if (!startwin) return 1; + gtk_window_set_title (GTK_WINDOW (startwin), title); + return 0; +} + +int startwin_idle(void *s) +{ + if (!gtkenabled) return 0; + //if (!startwin) return 1; + gtk_main_iteration_do (FALSE); + return 0; +} + +extern int xdimgame, ydimgame, bppgame, forcesetup; + +int startwin_run(void) +{ + if (!gtkenabled) return 0; + if (!startwin) return 1; + + SetPage(TAB_CONFIG); + EnableConfig(TRUE); + + settings.fullscreen = ScreenMode; + settings.xdim3d = ScreenWidth; + settings.ydim3d = ScreenHeight; + settings.bpp3d = ScreenBPP; + settings.forcesetup = ForceSetup; + settings.usemouse = UseMouse; + settings.usejoy = UseJoystick; + PopulateForm(); + + gtk_main(); + + SetPage(TAB_MESSAGES); + EnableConfig(FALSE); + if (retval) { + ScreenMode = settings.fullscreen; + ScreenWidth = settings.xdim3d; + ScreenHeight = settings.ydim3d; + ScreenBPP = settings.bpp3d; + ForceSetup = settings.forcesetup; + UseMouse = settings.usemouse; + UseJoystick = settings.usejoy; + } + + return retval; +} + diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c new file mode 100755 index 000000000..b5dc6ceb8 --- /dev/null +++ b/polymer/eduke32/source/startwin.game.c @@ -0,0 +1,431 @@ +#ifndef RENDERTYPEWIN +#error Only for Windows +#endif + +#include "duke3d.h" + +#include "build.h" +#include "winlayer.h" +#include "compat.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include +#define _WIN32_IE 0x0300 +#include +#include + +#include "startwin.game.h" + +#define TAB_CONFIG 0 +#define TAB_MESSAGES 1 + +static struct { + int fullscreen; + int xdim, ydim, bpp; + int forcesetup; + int usemouse, usejoy; +} settings; + +static HWND startupdlg = NULL; +static HWND pages[2] = { NULL, NULL}; +static int done = -1; + +static void PopulateForm(void) +{ + int i,j; + char buf[64]; + int mode; + HWND hwnd; + + hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE); + + mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1); + if (mode < 0) { + int cd[] = { 32, 24, 16, 15, 8, 0 }; + for (i=0; cd[i]; ) { if (cd[i] >= settings.bpp) i++; else break; } + for ( ; cd[i]; i++) { + mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1); + if (mode < 0) continue; + settings.bpp = cd[i]; + break; + } + } + + Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED)); + Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED)); + + ComboBox_ResetContent(hwnd); + for (i=0; iidFrom != WIN_STARTWIN_TABCTL) break; + cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); + switch (nmhdr->code) { + case TCN_SELCHANGING: { + if (cur < 0 || !pages[cur]) break; + ShowWindow(pages[cur],SW_HIDE); + return TRUE; + } + case TCN_SELCHANGE: { + if (cur < 0 || !pages[cur]) break; + ShowWindow(pages[cur],SW_SHOW); + return TRUE; + } + } + break; + } + + case WM_CLOSE: + done = 0; + return TRUE; + + case WM_DESTROY: + if (hbmp) { + DeleteObject(hbmp); + hbmp = NULL; + } + + if (pages[TAB_CONFIG]) { + DestroyWindow(pages[TAB_CONFIG]); + pages[TAB_CONFIG] = NULL; + } + + startupdlg = NULL; + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case WIN_STARTWIN_CANCEL: done = 0; return TRUE; + case WIN_STARTWIN_START: done = 1; return TRUE; + } + return FALSE; + + case WM_CTLCOLORSTATIC: + if ((HWND)lParam == pages[TAB_MESSAGES]) + return (BOOL)GetSysColorBrush(COLOR_WINDOW); + break; + + default: break; + } + + return FALSE; +} + + +int startwin_open(void) +{ + INITCOMMONCONTROLSEX icc; + if (startupdlg) return 1; + icc.dwSize = sizeof(icc); + icc.dwICC = ICC_TAB_CLASSES; + InitCommonControlsEx(&icc); + startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); + if (startupdlg) { + SetPage(TAB_MESSAGES); + EnableConfig(0); + return 0; + } + return -1; +} + +int startwin_close(void) +{ + if (!startupdlg) return 1; + DestroyWindow(startupdlg); + startupdlg = NULL; + return 0; +} + +int startwin_puts(const char *buf) +{ + const char *p = NULL, *q = NULL; + char workbuf[1024]; + static int newline = 0; + int curlen, linesbefore, linesafter; + HWND edctl; + int vis; + + if (!startupdlg) return 1; + + edctl = pages[TAB_MESSAGES]; + if (!edctl) return -1; + + vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES); + + if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0); + curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0); + SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); + linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); + p = buf; + while (*p) { + if (newline) { + SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); + newline = 0; + } + q = p; + while (*q && *q != '\n') q++; + memcpy(workbuf, p, q-p); + if (*q == '\n') { + if (!q[1]) { + newline = 1; + workbuf[q-p] = 0; + } else { + workbuf[q-p] = '\r'; + workbuf[q-p+1] = '\n'; + workbuf[q-p+2] = 0; + } + p = q+1; + } else { + workbuf[q-p] = 0; + p = q; + } + SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf); + } + linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0); + SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore); + if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0); + return 0; +} + +int startwin_settitle(const char *str) +{ + if (!startupdlg) return 1; + SetWindowText(startupdlg, str); + return 0; +} + +int startwin_idle(void *v) +{ + if (!startupdlg || !IsWindow(startupdlg)) return 0; + if (IsDialogMessage(startupdlg, (MSG*)v)) return 1; + return 0; +} + +int startwin_run(void) +{ + MSG msg; + if (!startupdlg) return 1; + + done = -1; + + SetPage(TAB_CONFIG); + EnableConfig(1); + + settings.fullscreen = ScreenMode; + settings.xdim = ScreenWidth; + settings.ydim = ScreenHeight; + settings.bpp = ScreenBPP; + settings.forcesetup = ForceSetup; + settings.usemouse = UseMouse; + settings.usejoy = UseJoystick; + PopulateForm(); + + while (done < 0) { + switch (GetMessage(&msg, NULL, 0,0)) { + case 0: done = 1; break; + case -1: return -1; + default: + if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; + TranslateMessage(&msg); + DispatchMessage(&msg); + break; + } + } + + SetPage(TAB_MESSAGES); + EnableConfig(0); + if (done) { + ScreenMode = settings.fullscreen; + ScreenWidth = settings.xdim; + ScreenHeight = settings.ydim; + ScreenBPP = settings.bpp; + ForceSetup = settings.forcesetup; + UseMouse = settings.usemouse; + UseJoystick = settings.usejoy; + } + + return done; +} + diff --git a/polymer/eduke32/source/startwin.game.h b/polymer/eduke32/source/startwin.game.h new file mode 100755 index 000000000..358ed0135 --- /dev/null +++ b/polymer/eduke32/source/startwin.game.h @@ -0,0 +1,23 @@ +// resource ids +#define WIN_STARTWIN 1000 +#define WIN_STARTWINPAGE_CONFIG 2000 +#define WIN_STARTWIN_BITMAP 100 // banner bitmap +#define WIN_STARTWIN_TABCTL 101 +#define WIN_STARTWIN_CANCEL 102 +#define WIN_STARTWIN_START 103 + +#define WIN_STARTWIN_MESSAGES 104 // output list box + +#define RSRC_ICON 100 +#define RSRC_BMP 200 + +// config page +#define IDCFULLSCREEN 100 +#define IDCVMODE 101 +#define IDCSOUNDDRV 102 +#define IDCMIDIDEV 103 +#define IDCCDADEV 104 +#define IDCINPUTMOUSE 105 +#define IDCINPUTJOY 106 +#define IDCALWAYSSHOW 107 +