From 0ee8c2f1bed5fe873896a05526e5922cae61a8de Mon Sep 17 00:00:00 2001 From: eukos Date: Thu, 6 Aug 2015 21:59:01 +0200 Subject: [PATCH] some major speed enhancements --- Makefile | 246 ++- TODO | 2 + asm/lcc_lib_gl_step1.bat | 18 - asm/lcc_lib_gl_step2.bat | 19 - asm/lcc_lib_gl_step3.bat | 16 - asm/lcc_lib_gl_step4.bat | 18 - asm/lcc_lib_gl_step5.bat | 15 - asm/lcc_lib_wq_step1.bat | 32 - asm/lcc_lib_wq_step2.bat | 19 - asm/lcc_lib_wq_step3.bat | 30 - asm/lcc_lib_wq_step4.bat | 32 - asm/lcc_lib_wq_step5.bat | 15 - asm/ue_replace.mac | Bin 161 -> 0 bytes engine/progdefs.h | 147 +- engine/progdefs.q1 | 143 -- engine/progdefs.q2 | 157 -- engine/quakedef.h | 297 ++-- engine/r_surf.c | 26 +- engine/snd_mix.c | 6 +- engine/sv_main.c | 27 - engine/vid_win_old.c | 3516 -------------------------------------- 21 files changed, 413 insertions(+), 4368 deletions(-) create mode 100644 TODO delete mode 100644 asm/lcc_lib_gl_step1.bat delete mode 100644 asm/lcc_lib_gl_step2.bat delete mode 100644 asm/lcc_lib_gl_step3.bat delete mode 100644 asm/lcc_lib_gl_step4.bat delete mode 100644 asm/lcc_lib_gl_step5.bat delete mode 100644 asm/lcc_lib_wq_step1.bat delete mode 100644 asm/lcc_lib_wq_step2.bat delete mode 100644 asm/lcc_lib_wq_step3.bat delete mode 100644 asm/lcc_lib_wq_step4.bat delete mode 100644 asm/lcc_lib_wq_step5.bat delete mode 100644 asm/ue_replace.mac delete mode 100644 engine/progdefs.q1 delete mode 100644 engine/progdefs.q2 delete mode 100644 engine/vid_win_old.c diff --git a/Makefile b/Makefile index ea92095..f213d32 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ BUILD_RELEASE_DIR=release CC=gcc -m32 -BASE_CFLAGS=-Dstricmp=strcasecmp -I./dumb/include/ +BASE_CFLAGS=-Dstricmp=strcasecmp -Wunused RELEASE_CFLAGS=$(BASE_CFLAGS) -O6 -ffast-math -funroll-loops DEBUG_CFLAGS=$(BASE_CFLAGS) -g LDFLAGS=-lm -ldl @@ -45,13 +45,11 @@ XCFLAGS=-DX11 DO_CC=$(CC) $(CFLAGS) -o $@ -c $< DO_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) -o $@ -c $< -DO_GL_CC=$(CC) $(CFLAGS) $(GLCFLAGS) -o $@ -c $< -DO_GL_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) $(GLCFLAGS) -o $@ -c $< DO_X11_CC=$(CC) $(CFLAGS) $(XCFLAGS) -o $@ -c $< DO_X11_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) $(XCFLAGS) -o $@ -c $< DO_O_CC=$(CC) -O $(CFLAGS) -o $@ -c $< DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $< -DO_GL_AS=$(CC) $(CFLAGS) $(GLCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $< +DO_DUMB=$(CC) $(CFLAGS) -I./dumb/include/ -o $@ -c $< ############################################################################# # SETUP AND BUILD @@ -77,7 +75,7 @@ targets: $(TARGETS) # X11 Quake ############################################################################# -X11_OBJS = \ +NGUNIX_OBJS = \ $(BUILDDIR)/atexit.o \ $(BUILDDIR)/duhlen.o \ $(BUILDDIR)/duhtag.o \ @@ -216,362 +214,362 @@ X11_OBJS = \ $(BUILDDIR)/snd_mixa.o \ $(BUILDDIR)/sys_dosa.o -$(MASTER_DIR)/engoo.x11 : $(X11_OBJS) - $(CC) $(CFLAGS) -o $@ $(X11_OBJS) $(XLDFLAGS) $(LDFLAGS) +$(MASTER_DIR)/engoo.x11 : $(NGUNIX_OBJS) + $(CC) $(CFLAGS) -o $@ $(NGUNIX_OBJS) $(XLDFLAGS) $(LDFLAGS) $(BUILDDIR)/atexit.o : $(MOUNT_DIR)/../dumb/core/atexit.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/duhlen.o : $(MOUNT_DIR)/../dumb/core/duhlen.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/duhtag.o : $(MOUNT_DIR)/../dumb/core/duhtag.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/dumbfile.o : $(MOUNT_DIR)/../dumb/core/dumbfile.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/loadduh.o : $(MOUNT_DIR)/../dumb/core/loadduh.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/makeduh.o : $(MOUNT_DIR)/../dumb/core/makeduh.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/rawsig.o : $(MOUNT_DIR)/../dumb/core/rawsig.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/readduh.o : $(MOUNT_DIR)/../dumb/core/readduh.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/register.o : $(MOUNT_DIR)/../dumb/core/register.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/rendduh.o : $(MOUNT_DIR)/../dumb/core/rendduh.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/rendsig.o : $(MOUNT_DIR)/../dumb/core/rendsig.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/unload.o : $(MOUNT_DIR)/../dumb/core/unload.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/clickrem.o : $(MOUNT_DIR)/../dumb/helpers/clickrem.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/memfile.o : $(MOUNT_DIR)/../dumb/helpers/memfile.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/resample.o : $(MOUNT_DIR)/../dumb/helpers/resample.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/sampbuf.o : $(MOUNT_DIR)/../dumb/helpers/sampbuf.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/silence.o : $(MOUNT_DIR)/../dumb/helpers/silence.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/stdfile.o : $(MOUNT_DIR)/../dumb/helpers/stdfile.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/itload.o : $(MOUNT_DIR)/../dumb/it/itload.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/itread.o : $(MOUNT_DIR)/../dumb/it/itread.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/itload2.o : $(MOUNT_DIR)/../dumb/it/itload2.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/itread2.o : $(MOUNT_DIR)/../dumb/it/itread2.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/itrender.o : $(MOUNT_DIR)/../dumb/it/itrender.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/itunload.o : $(MOUNT_DIR)/../dumb/it/itunload.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/loads3m.o : $(MOUNT_DIR)/../dumb/it/loads3m.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/reads3m.o : $(MOUNT_DIR)/../dumb/it/reads3m.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/loadxm.o : $(MOUNT_DIR)/../dumb/it/loadxm.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/readxm.o : $(MOUNT_DIR)/../dumb/it/readxm.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/loadmod.o : $(MOUNT_DIR)/../dumb/it/loadmod.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/readmod.o : $(MOUNT_DIR)/../dumb/it/readmod.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/loads3m2.o : $(MOUNT_DIR)/../dumb/it/loads3m2.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/reads3m2.o : $(MOUNT_DIR)/../dumb/it/reads3m2.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/loadxm2.o : $(MOUNT_DIR)/../dumb/it/loadxm2.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/readxm2.o : $(MOUNT_DIR)/../dumb/it/readxm2.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/loadmod2.o : $(MOUNT_DIR)/../dumb/it/loadmod2.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/readmod2.o : $(MOUNT_DIR)/../dumb/it/readmod2.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/xmeffect.o : $(MOUNT_DIR)/../dumb/it/xmeffect.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/itorder.o : $(MOUNT_DIR)/../dumb/it/itorder.c - $(DO_CC) + $(DO_DUMB) $(BUILDDIR)/itmisc.o : $(MOUNT_DIR)/../dumb/it/itmisc.c - $(DO_CC) + $(DO_DUMB) #### $(BUILDDIR)/cl_demo.o : $(MOUNT_DIR)/cl_demo.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/cl_input.o : $(MOUNT_DIR)/cl_input.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/cl_main.o : $(MOUNT_DIR)/cl_main.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/cl_parse.o : $(MOUNT_DIR)/cl_parse.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/cl_tent.o : $(MOUNT_DIR)/cl_tent.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/chase.o : $(MOUNT_DIR)/chase.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/cmd.o : $(MOUNT_DIR)/cmd.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/common.o : $(MOUNT_DIR)/common.c - $(DO_X11_DEBUG_CC) + $(DO_CC) $(BUILDDIR)/console.o : $(MOUNT_DIR)/console.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/crc.o : $(MOUNT_DIR)/crc.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/cvar.o : $(MOUNT_DIR)/cvar.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/draw.o : $(MOUNT_DIR)/draw.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_edge.o : $(MOUNT_DIR)/d_edge.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_fill.o : $(MOUNT_DIR)/d_fill.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_init.o : $(MOUNT_DIR)/d_init.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_modech.o : $(MOUNT_DIR)/d_modech.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_part.o : $(MOUNT_DIR)/d_part.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_polyse.o : $(MOUNT_DIR)/d_polyse.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_scan.o : $(MOUNT_DIR)/d_scan.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_sky.o : $(MOUNT_DIR)/d_sky.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_sprite.o : $(MOUNT_DIR)/d_sprite.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_surf.o : $(MOUNT_DIR)/d_surf.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_vars.o : $(MOUNT_DIR)/d_vars.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/d_zpoint.o : $(MOUNT_DIR)/d_zpoint.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/host.o : $(MOUNT_DIR)/host.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/host_cmd.o : $(MOUNT_DIR)/host_cmd.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/keys.o : $(MOUNT_DIR)/keys.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/menu.o : $(MOUNT_DIR)/menu.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/mathlib.o : $(MOUNT_DIR)/mathlib.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/model.o : $(MOUNT_DIR)/model.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/model_common.o :$(MOUNT_DIR)/model_common.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/net_dgrm.o : $(MOUNT_DIR)/net_dgrm.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/net_loop.o : $(MOUNT_DIR)/net_loop.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/net_main.o : $(MOUNT_DIR)/net_main.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/net_vcr.o : $(MOUNT_DIR)/net_vcr.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/net_udp.o : $(MOUNT_DIR)/net_udp.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/net_bsd.o : $(MOUNT_DIR)/net_bsd.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/nonintel.o : $(MOUNT_DIR)/nonintel.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/pr_cmds.o : $(MOUNT_DIR)/pr_cmds.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/pr_edict.o : $(MOUNT_DIR)/pr_edict.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/pr_exec.o : $(MOUNT_DIR)/pr_exec.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_aclip.o : $(MOUNT_DIR)/r_aclip.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_alias.o : $(MOUNT_DIR)/r_alias.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_bsp.o : $(MOUNT_DIR)/r_bsp.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_light.o : $(MOUNT_DIR)/r_light.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_draw.o : $(MOUNT_DIR)/r_draw.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_efrag.o : $(MOUNT_DIR)/r_efrag.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_edge.o : $(MOUNT_DIR)/r_edge.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_misc.o : $(MOUNT_DIR)/r_misc.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_main.o : $(MOUNT_DIR)/r_main.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_sky.o : $(MOUNT_DIR)/r_sky.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_sprite.o : $(MOUNT_DIR)/r_sprite.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_surf.o : $(MOUNT_DIR)/r_surf.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_part.o : $(MOUNT_DIR)/r_part.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/r_vars.o : $(MOUNT_DIR)/r_vars.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/screen.o : $(MOUNT_DIR)/screen.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/sbar.o : $(MOUNT_DIR)/sbar.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/sv_main.o : $(MOUNT_DIR)/sv_main.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/sv_phys.o : $(MOUNT_DIR)/sv_phys.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/sv_move.o : $(MOUNT_DIR)/sv_move.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/sv_user.o : $(MOUNT_DIR)/sv_user.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/zone.o : $(MOUNT_DIR)/zone.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/view.o : $(MOUNT_DIR)/view.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/wad.o : $(MOUNT_DIR)/wad.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/world.o : $(MOUNT_DIR)/world.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/tracker_linux.o : $(MOUNT_DIR)/tracker_linux.c - $(DO_X11_CC) + $(DO_DUMB) $(BUILDDIR)/cd_null.o : $(MOUNT_DIR)/cd_null.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/sys_linux.o :$(MOUNT_DIR)/sys_linux.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/vid_x.o: $(MOUNT_DIR)/vid_x.c $(DO_O_CC) $(BUILDDIR)/snd_dma.o : $(MOUNT_DIR)/snd_dma.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/snd_mem.o : $(MOUNT_DIR)/snd_mem.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/snd_mix.o : $(MOUNT_DIR)/snd_mix.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/snd_linux.o :$(MOUNT_DIR)/snd_linux.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/bot.o :$(MOUNT_DIR)/bot.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/nvs_client.o :$(MOUNT_DIR)/nvs_client.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/nvs_common.o :$(MOUNT_DIR)/nvs_common.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/nvs_server.o :$(MOUNT_DIR)/nvs_server.c - $(DO_X11_CC) + $(DO_CC) $(BUILDDIR)/nvs_server_data.o :$(MOUNT_DIR)/nvs_server_data.c - $(DO_X11_CC) + $(DO_CC) ##### @@ -649,4 +647,4 @@ clean-release: $(MAKE) clean2 BUILDDIR=$(BUILD_RELEASE_DIR) CFLAGS="$(DEBUG_CFLAGS)" clean2: - -rm -f $(X11_OBJS) + -rm -f $(NGUNIX_OBJS) diff --git a/TODO b/TODO new file mode 100644 index 0000000..c25ae7a --- /dev/null +++ b/TODO @@ -0,0 +1,2 @@ +- Cleanup of d_scan, d_polyse and d_surf +- Fixing up of coloured statusbars diff --git a/asm/lcc_lib_gl_step1.bat b/asm/lcc_lib_gl_step1.bat deleted file mode 100644 index 747590a..0000000 --- a/asm/lcc_lib_gl_step1.bat +++ /dev/null @@ -1,18 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_gl -cls -echo This script assumes that LCC is in your path -echo. -echo Creating preprocessor assembler files (.i) of all GAS files (.s) for GLQuake in %OUTPUT_DIR% -pause -mkdir %OUTPUT_DIR% -del "%OUTPUT_DIR%\*.i" -@echo on -lcc -EP -DGLQUAKE math.s -Fo%OUTPUT_DIR%/math.i -lcc -EP -DGLQUAKE snd_mixa.s -Fo%OUTPUT_DIR%/snd_mixa.i -lcc -EP -DGLQUAKE sys_wina.s -Fo%OUTPUT_DIR%/sys_wina.i -lcc -EP -DGLQUAKE worlda.s -Fo%OUTPUT_DIR%/worlda.i -@echo off -echo. -echo Step #1 for GLQuake is done -echo. diff --git a/asm/lcc_lib_gl_step2.bat b/asm/lcc_lib_gl_step2.bat deleted file mode 100644 index 20b2459..0000000 --- a/asm/lcc_lib_gl_step2.bat +++ /dev/null @@ -1,19 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_gl -cls -echo Step #2: Go through all .i files in %OUTPUT_DIR% and remove additional spaces from -echo A) Jump points, before the name and between it and the colon (:) -echo Example: " _Invert24To16 :" -echo B) Calculations -echo Example: "addl _paintbuffer + 0 - 8 *2(,%ecx,8),%edi" -echo. -echo After this you can go on to the next step. -echo. -echo Tips: -echo If you use UltraEdit use regular expressions: -echo for A replace "^(_*^) :" with "^1:" -echo for B search " +", " -", " *" and "+ ", "- ", "* " -echo. -echo URL: -echo UltraEdit - http://www.ultraedit.com/ -echo. diff --git a/asm/lcc_lib_gl_step3.bat b/asm/lcc_lib_gl_step3.bat deleted file mode 100644 index 8c57884..0000000 --- a/asm/lcc_lib_gl_step3.bat +++ /dev/null @@ -1,16 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_gl -cls -echo This script assumes that GAS2MASM is in ..\..\gas2masm\lcc_release -echo. -echo Creating MASM assembler files (.asm) of all precompiler files (.i) for GLQuake in %OUTPUT_DIR% -pause -@echo on -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\math.i >%OUTPUT_DIR%\math.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\snd_mixa.i >%OUTPUT_DIR%\snd_mixa.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\sys_wina.i >%OUTPUT_DIR%\sys_wina.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\worlda.i >%OUTPUT_DIR%\worlda.asm -@echo off -echo. -echo Step #3 for GLQuake is done -echo. diff --git a/asm/lcc_lib_gl_step4.bat b/asm/lcc_lib_gl_step4.bat deleted file mode 100644 index 846a5ca..0000000 --- a/asm/lcc_lib_gl_step4.bat +++ /dev/null @@ -1,18 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_gl -cls -echo This script assumes that MASM is in your path -echo. -echo Creating object files (.obj) of all MASM assembler files (.asm) for GLQuake in %OUTPUT_DIR% -pause -cd %OUTPUT_DIR% -@echo on -ml /c /Cp /coff /Zm /Zi math.asm -ml /c /Cp /coff /Zm /Zi snd_mixa.asm -ml /c /Cp /coff /Zm /Zi sys_wina.asm -ml /c /Cp /coff /Zm /Zi worlda.asm -@echo off -cd .. -echo. -echo Step #4 for GLQuake is done -echo. diff --git a/asm/lcc_lib_gl_step5.bat b/asm/lcc_lib_gl_step5.bat deleted file mode 100644 index 8a98492..0000000 --- a/asm/lcc_lib_gl_step5.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_gl -cls -echo This script assumes that LCC is in your path -echo. -echo Creating library (.lib) of object files for GLQuake in %OUTPUT_DIR% -pause -cd %OUTPUT_DIR% -@echo on -lcclib quakeasm_gl.lib *.obj -@echo off -cd .. -echo. -echo Step #5 for GLQuake is done -echo. diff --git a/asm/lcc_lib_wq_step1.bat b/asm/lcc_lib_wq_step1.bat deleted file mode 100644 index e957f05..0000000 --- a/asm/lcc_lib_wq_step1.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_wq -cls -echo This script assumes that LCC is in your path -echo. -echo Creating preprocessor assembler files (.i) of all GAS files (.s) for WinQuake in %OUTPUT_DIR% -pause -mkdir %OUTPUT_DIR% -del "%OUTPUT_DIR%\*.i" -@echo on -lcc -EP d_draw.s -Fo%OUTPUT_DIR%/d_draw.i -lcc -EP d_draw16.s -Fo%OUTPUT_DIR%/d_draw16.i -lcc -EP d_parta.s -Fo%OUTPUT_DIR%/d_parta.i -lcc -EP d_polysa.s -Fo%OUTPUT_DIR%/d_polysa.i -lcc -EP d_scana.s -Fo%OUTPUT_DIR%/d_scana.i -lcc -EP d_spr8.s -Fo%OUTPUT_DIR%/d_spr8.i -lcc -EP d_varsa.s -Fo%OUTPUT_DIR%/d_varsa.i -lcc -EP math.s -Fo%OUTPUT_DIR%/math.i -lcc -EP r_aclipa.s -Fo%OUTPUT_DIR%/r_aclipa.i -lcc -EP r_aliasa.s -Fo%OUTPUT_DIR%/r_aliasa.i -lcc -EP r_drawa.s -Fo%OUTPUT_DIR%/r_drawa.i -lcc -EP r_edgea.s -Fo%OUTPUT_DIR%/r_edgea.i -lcc -EP r_varsa.s -Fo%OUTPUT_DIR%/r_varsa.i -lcc -EP snd_mixa.s -Fo%OUTPUT_DIR%/snd_mixa.i -lcc -EP surf16.s -Fo%OUTPUT_DIR%/surf16.i -lcc -EP surf8.s -Fo%OUTPUT_DIR%/surf8.i -lcc -EP sys_wina.s -Fo%OUTPUT_DIR%/sys_wina.i -lcc -EP worlda.s -Fo%OUTPUT_DIR%/worlda.i -@echo off -echo. -echo Step #1 for WinQuake is done -echo. diff --git a/asm/lcc_lib_wq_step2.bat b/asm/lcc_lib_wq_step2.bat deleted file mode 100644 index 4019423..0000000 --- a/asm/lcc_lib_wq_step2.bat +++ /dev/null @@ -1,19 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_wq -cls -echo Step #2: Go through all .i files in %OUTPUT_DIR% and remove additional spaces from -echo A) Jump points, before the name and between it and the colon (:) -echo Example: " _Invert24To16 :" -echo B) Calculations -echo Example: "addl _paintbuffer + 0 - 8 *2(,%ecx,8),%edi" -echo. -echo After this you can go on to the next step. -echo. -echo Tips: -echo If you use UltraEdit use regular expressions: -echo for A replace "^(_*^) :" with "^1:" -echo for B search " +", " -", " *" and "+ ", "- ", "* " -echo. -echo URL: -echo UltraEdit - http://www.ultraedit.com/ -echo. diff --git a/asm/lcc_lib_wq_step3.bat b/asm/lcc_lib_wq_step3.bat deleted file mode 100644 index a3c5b85..0000000 --- a/asm/lcc_lib_wq_step3.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_wq -cls -echo This script assumes that GAS2MASM is in ..\..\gas2masm\lcc_release -echo. -echo Creating MASM assembler files (.asm) of all precompiler files (.i) for WinQuake in %OUTPUT_DIR% -pause -@echo on -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\d_draw.i >%OUTPUT_DIR%\d_draw.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\d_draw16.i >%OUTPUT_DIR%\d_draw16.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\d_parta.i >%OUTPUT_DIR%\d_parta.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\d_polysa.i >%OUTPUT_DIR%\d_polysa.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\d_scana.i >%OUTPUT_DIR%\d_scana.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\d_spr8.i >%OUTPUT_DIR%\d_spr8.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\d_varsa.i >%OUTPUT_DIR%\d_varsa.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\math.i >%OUTPUT_DIR%\math.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\r_aclipa.i >%OUTPUT_DIR%\r_aclipa.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\r_aliasa.i >%OUTPUT_DIR%\r_aliasa.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\r_drawa.i >%OUTPUT_DIR%\r_drawa.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\r_edgea.i >%OUTPUT_DIR%\r_edgea.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\r_varsa.i >%OUTPUT_DIR%\r_varsa.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\snd_mixa.i >%OUTPUT_DIR%\snd_mixa.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\surf16.i >%OUTPUT_DIR%\surf16.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\surf8.i >%OUTPUT_DIR%\surf8.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\sys_wina.i >%OUTPUT_DIR%\sys_wina.asm -..\gas2masm\lcc_release\gas2masm.exe <%OUTPUT_DIR%\worlda.i >%OUTPUT_DIR%\worlda.asm -@echo off -echo. -echo Step #3 for WinQuake is done -echo. diff --git a/asm/lcc_lib_wq_step4.bat b/asm/lcc_lib_wq_step4.bat deleted file mode 100644 index 3bf96de..0000000 --- a/asm/lcc_lib_wq_step4.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_wq -cls -echo This script assumes that MASM is in your path -echo. -echo Creating object files (.obj) of all MASM assembler files (.asm) for WinQuake in %OUTPUT_DIR% -pause -cd %OUTPUT_DIR% -@echo on -ml /c /Cp /coff /Zm /Zi d_draw.asm -ml /c /Cp /coff /Zm /Zi d_draw16.asm -ml /c /Cp /coff /Zm /Zi d_parta.asm -ml /c /Cp /coff /Zm /Zi d_polysa.asm -ml /c /Cp /coff /Zm /Zi d_scana.asm -ml /c /Cp /coff /Zm /Zi d_spr8.asm -ml /c /Cp /coff /Zm /Zi d_varsa.asm -ml /c /Cp /coff /Zm /Zi math.asm -ml /c /Cp /coff /Zm /Zi r_aclipa.asm -ml /c /Cp /coff /Zm /Zi r_aliasa.asm -ml /c /Cp /coff /Zm /Zi r_drawa.asm -ml /c /Cp /coff /Zm /Zi r_edgea.asm -ml /c /Cp /coff /Zm /Zi r_varsa.asm -ml /c /Cp /coff /Zm /Zi snd_mixa.asm -ml /c /Cp /coff /Zm /Zi surf16.asm -ml /c /Cp /coff /Zm /Zi surf8.asm -ml /c /Cp /coff /Zm /Zi sys_wina.asm -ml /c /Cp /coff /Zm /Zi worlda.asm -@echo off -cd .. -echo. -echo Step #4 for WinQuake is done -echo. diff --git a/asm/lcc_lib_wq_step5.bat b/asm/lcc_lib_wq_step5.bat deleted file mode 100644 index a4bb82d..0000000 --- a/asm/lcc_lib_wq_step5.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -set OUTPUT_DIR=lcc_lib_wq -cls -echo This script assumes that LCC is in your path -echo. -echo Creating library (.lib) of object files for WinQuake in %OUTPUT_DIR% -pause -cd %OUTPUT_DIR% -@echo on -lcclib quakeasm_wq.lib *.obj -@echo off -cd .. -echo. -echo Step #5 for WinQuake is done -echo. diff --git a/asm/ue_replace.mac b/asm/ue_replace.mac deleted file mode 100644 index a8b6adf2d7b0a02e4854baba1b3add237d95d6a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 161 zcmWG_)%8tGF3LA#NMQ&pP0UVJ@Nsrl$Vkm8U{Fv{U}13huaK|MuHd2IreLX{5T_BZ z6{o3SrC@BX5TszN5NBuwlrU0I&{Z%t28tL086du{0xDlY8^+fL%WK2sA$$cbn7kHP JUJEX-1ptQQAh!Sj diff --git a/engine/progdefs.h b/engine/progdefs.h index 11c8f73..dd0748b 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -17,9 +17,144 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef QUAKE2 -#include "progdefs.q2" -#else -#include "progdefs.q1" -//#include "progdefs.qb" -#endif + +typedef struct +{ int pad[28]; + int self; + int other; + int world; + float time; + float frametime; + float force_retouch; + string_t mapname; + float deathmatch; + float coop; + float teamplay; + float serverflags; + float total_secrets; + float total_monsters; + float found_secrets; + float killed_monsters; + float parm1; + float parm2; + float parm3; + float parm4; + float parm5; + float parm6; + float parm7; + float parm8; + float parm9; + float parm10; + float parm11; + float parm12; + float parm13; + float parm14; + float parm15; + float parm16; + vec3_t v_forward; + vec3_t v_up; + vec3_t v_right; + float trace_allsolid; + float trace_startsolid; + float trace_fraction; + vec3_t trace_endpos; + vec3_t trace_plane_normal; + float trace_plane_dist; + int trace_ent; + float trace_inopen; + float trace_inwater; + int msg_entity; + func_t main; + func_t StartFrame; + func_t PlayerPreThink; + func_t PlayerPostThink; + func_t ClientKill; + func_t ClientConnect; + func_t PutClientInServer; + func_t ClientDisconnect; + func_t SetNewParms; + func_t SetChangeParms; +} globalvars_t; + +typedef struct +{ + float modelindex; + vec3_t absmin; + vec3_t absmax; + float ltime; + float movetype; + float solid; + vec3_t origin; + vec3_t oldorigin; + vec3_t velocity; + vec3_t angles; + vec3_t avelocity; + vec3_t punchangle; + string_t classname; + string_t model; + float frame; + float skin; + float effects; + vec3_t mins; + vec3_t maxs; + vec3_t size; + func_t touch; + func_t use; + func_t think; + func_t blocked; + float nextthink; + int groundentity; + float health; + float frags; + float weapon; + string_t weaponmodel; + float weaponframe; + float currentammo; + float ammo_shells; + float ammo_nails; + float ammo_rockets; + float ammo_cells; + float items; + float takedamage; + int chain; + float deadflag; + vec3_t view_ofs; + float button0; + float button1; + float button2; + float impulse; + float fixangle; + vec3_t v_angle; + float idealpitch; + string_t netname; + int enemy; + float flags; + float colormap; + float team; + float max_health; + float teleport_time; + float armortype; + float armorvalue; + float waterlevel; + float watertype; + float ideal_yaw; + float yaw_speed; + int aiment; + int goalentity; + float spawnflags; + string_t target; + string_t targetname; + float dmg_take; + float dmg_save; + int dmg_inflictor; + int owner; + vec3_t movedir; + string_t message; + float sounds; + string_t noise; + string_t noise1; + string_t noise2; + string_t noise3; +} entvars_t; + +#define PROGHEADER_CRC 5927 diff --git a/engine/progdefs.q1 b/engine/progdefs.q1 deleted file mode 100644 index c976cf8..0000000 --- a/engine/progdefs.q1 +++ /dev/null @@ -1,143 +0,0 @@ - -/* file generated by qcc, do not modify */ - -typedef struct -{ int pad[28]; - int self; - int other; - int world; - float time; - float frametime; - float force_retouch; - string_t mapname; - float deathmatch; - float coop; - float teamplay; - float serverflags; - float total_secrets; - float total_monsters; - float found_secrets; - float killed_monsters; - float parm1; - float parm2; - float parm3; - float parm4; - float parm5; - float parm6; - float parm7; - float parm8; - float parm9; - float parm10; - float parm11; - float parm12; - float parm13; - float parm14; - float parm15; - float parm16; - vec3_t v_forward; - vec3_t v_up; - vec3_t v_right; - float trace_allsolid; - float trace_startsolid; - float trace_fraction; - vec3_t trace_endpos; - vec3_t trace_plane_normal; - float trace_plane_dist; - int trace_ent; - float trace_inopen; - float trace_inwater; - int msg_entity; - func_t main; - func_t StartFrame; - func_t PlayerPreThink; - func_t PlayerPostThink; - func_t ClientKill; - func_t ClientConnect; - func_t PutClientInServer; - func_t ClientDisconnect; - func_t SetNewParms; - func_t SetChangeParms; -} globalvars_t; - -typedef struct -{ - float modelindex; - vec3_t absmin; - vec3_t absmax; - float ltime; - float movetype; - float solid; - vec3_t origin; - vec3_t oldorigin; - vec3_t velocity; - vec3_t angles; - vec3_t avelocity; - vec3_t punchangle; - string_t classname; - string_t model; - float frame; - float skin; - float effects; - vec3_t mins; - vec3_t maxs; - vec3_t size; - func_t touch; - func_t use; - func_t think; - func_t blocked; - float nextthink; - int groundentity; - float health; - float frags; - float weapon; - string_t weaponmodel; - float weaponframe; - float currentammo; - float ammo_shells; - float ammo_nails; - float ammo_rockets; - float ammo_cells; - float items; - float takedamage; - int chain; - float deadflag; - vec3_t view_ofs; - float button0; - float button1; - float button2; - float impulse; - float fixangle; - vec3_t v_angle; - float idealpitch; - string_t netname; - int enemy; - float flags; - float colormap; - float team; - float max_health; - float teleport_time; - float armortype; - float armorvalue; - float waterlevel; - float watertype; - float ideal_yaw; - float yaw_speed; - int aiment; - int goalentity; - float spawnflags; - string_t target; - string_t targetname; - float dmg_take; - float dmg_save; - int dmg_inflictor; - int owner; - vec3_t movedir; - string_t message; - float sounds; - string_t noise; - string_t noise1; - string_t noise2; - string_t noise3; -} entvars_t; - -#define PROGHEADER_CRC 5927 diff --git a/engine/progdefs.q2 b/engine/progdefs.q2 deleted file mode 100644 index 8fe62ee..0000000 --- a/engine/progdefs.q2 +++ /dev/null @@ -1,157 +0,0 @@ - -/* file generated by qcc, do not modify */ - -typedef struct -{ int pad[28]; - int self; - int other; - int world; - float time; - float frametime; - float force_retouch; - string_t mapname; - string_t startspot; - float deathmatch; - float coop; float teamplay; - float serverflags; - float total_secrets; - float total_monsters; - float found_secrets; - float killed_monsters; - float parm1; - float parm2; - float parm3; - float parm4; - float parm5; - float parm6; - float parm7; - float parm8; - float parm9; - float parm10; - float parm11; - float parm12; - float parm13; - float parm14; - float parm15; - float parm16; - vec3_t v_forward; - vec3_t v_up; - vec3_t v_right; - float trace_allsolid; - float trace_startsolid; - float trace_fraction; - vec3_t trace_endpos; - vec3_t trace_plane_normal; - float trace_plane_dist; - int trace_ent; - float trace_inopen; - float trace_inwater; - int msg_entity; - string_t null; - func_t main; - func_t StartFrame; - func_t PlayerPreThink; - func_t PlayerPostThink; - func_t ClientKill; - func_t ClientConnect; - func_t PutClientInServer; - func_t ClientDisconnect; - func_t SetNewParms; - func_t SetChangeParms; -} globalvars_t; - -typedef struct -{ - float modelindex; - vec3_t absmin; - vec3_t absmax; - float ltime; - float movetype; - float solid; - vec3_t origin; - vec3_t oldorigin; - vec3_t velocity; - vec3_t angles; - vec3_t avelocity; - vec3_t basevelocity; - vec3_t punchangle; - string_t classname; - string_t model; - float frame; - float skin; - float effects; - float drawPercent; - float gravity; - float mass; - float light_level; - vec3_t mins; - vec3_t maxs; - vec3_t size; - func_t touch; - func_t use; - func_t think; - func_t blocked; - float nextthink; - int groundentity; - float health; - float frags; - float weapon; - string_t weaponmodel; - float weaponframe; - float currentammo; - float ammo_shells; - float ammo_nails; - float ammo_rockets; - float ammo_cells; - float items; - float items2; - float takedamage; - int chain; - float deadflag; - vec3_t view_ofs; - float button0; - float button1; - float button2; - float impulse; - float fixangle; - vec3_t v_angle; - float idealpitch; - float pitch_speed; - string_t netname; - int enemy; - float flags; - float colormap; - float team; - float max_health; - float teleport_time; - float armortype; - float armorvalue; - float waterlevel; - float watertype; - float ideal_yaw; - float yaw_speed; - int aiment; - int goalentity; - float spawnflags; - string_t target; - string_t targetname; - float dmg_take; - float dmg_save; - int dmg_inflictor; - int owner; - vec3_t movedir; - string_t message; - float sounds; - string_t noise; - string_t noise1; - string_t noise2; - string_t noise3; - float dmg; - float dmgtime; - float air_finished; - float pain_finished; - float radsuit_finished; - float speed; -} entvars_t; - -#define PROGHEADER_CRC 31586 diff --git a/engine/quakedef.h b/engine/quakedef.h index cf3bb5e..149a5c9 100644 --- a/engine/quakedef.h +++ b/engine/quakedef.h @@ -42,16 +42,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // to a stupidly high amount for debugging. Please read below // for why. // EXPERIMENTALY HACKS -#define twentyfourbithack // Converts textures to 24-bit for dithered rendering. Doesn't work +//#define twentyfourbithack // Converts textures to 24-bit for dithered rendering. Doesn't work //#define dithermodelhack // Attempts dithered lighting on models //#define statictest // uses Static for the tables used by rgb surfaceblocks -//#define LOOKANGLE // adds aimangle (crude pointing of the viewmodel to autoaim angle) +//#define LOOKANGLE // adds aimangle (crude pointing of the viewmodel to autoaim angle) #define ITSFIX //#define ANTIPACKETOVERFLOW // argh //#define WINDOWS31 // to allow the engine to be run in windows 3 w/ win32s - // it doesn't work right now (and latest win32s aborts it too) - // but theoretically it is broken at the TIMER level, at least - // in older mid-1995 win32s versions + // it doesn't work right now (and latest win32s aborts it too) + // but theoretically it is broken at the TIMER level, at least + // in older mid-1995 win32s versions //#define SPLIT // Splitscreen hack (NOTE: Depends on GLOBOT for now, for client functionality) #define REALLYCRASHESITHINK @@ -59,29 +59,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Video Features // ----------------------------------------- -//#define EGA // EGA 4-bit colors experiment *WIP* -//#define EGAHACK // EGA Palette Hackup Test -//#define VGA // VGA 4-bit colors experiment to allow game running in safe mode *WIP* -//#define INTERPOL // buggy interpolation (ToChriS/makaqu port - this will crash.) -//#define MHINTERPOL // other interpolation (still buggy)*WIP* -#define INTERPOL7 // other interpolation again (still buggy)*WIP* +//#define EGA // EGA 4-bit colors experiment *WIP* +//#define EGAHACK // EGA Palette Hackup Test +//#define VGA // VGA 4-bit colors experiment to allow game running in safe mode *WIP* +//#define INTERPOL // buggy interpolation (ToChriS/makaqu port - this will crash.) +//#define MHINTERPOL // other interpolation (still buggy)*WIP* +#define INTERPOL7 // other interpolation again (still buggy)*WIP* //#define NOFULLSCREENEVER // absolutely force windowed mode -//#define INTERPOL2 // Tochris interpolation -//#define ALPHASCALE // enable .alpha and .scale*WIP* (may break protocol?) -//#define SCALEE // enable just the scale ocde, no protocols -#define SCALED2D // enables scaled hud/menu etc. adapted from siggi's uhexen2 patch -//#define THIRTYTWOBITHACK -//#define MMXHACK // try to shove in MMX intrinsics to some functions +//#define INTERPOL2 // Tochris interpolation +//#define ALPHASCALE // enable .alpha and .scale*WIP* (may break protocol?) +//#define SCALEE // enable just the scale ocde, no protocols +#define SCALED2D // enables scaled hud/menu etc. adapted from siggi's uhexen2 patch +//#define THIRTYTWOBITHACK +//#define MMXHACK // try to shove in MMX intrinsics to some functions -//#define DECALS // Port of FTEQW's disabled SW DECALS feature. Probably doesn't work. +//#define DECALS // Port of FTEQW's disabled SW DECALS feature. Probably doesn't work. //#define COMBINED -//#define STAINMAPS // I don't like this common feature much, but we'll try it anyway. -//#define WATERLOW // Use a warpbuffer clone for storing the reflection in, rendering it stretched to the buffer (why) -//#define EXPREND // Experimental shadowmap rendering mode -#define WATERREFLECTIONS -//#define INTERPOLENTITIES - -//#define VOODOO // vid_win.c only - try to mock 3dfx Voodoo 4x1 filter +//#define STAINMAPS // I don't like this common feature much, but we'll try it anyway. +//#define WATERLOW // Use a warpbuffer clone for storing the reflection in, rendering it stretched to the buffer (why) +//#define EXPREND // Experimental shadowmap rendering mode +//#define WATERREFLECTIONS +//#define INTERPOLENTITIES +//#define VOODOO // vid_win.c only - try to mock 3dfx Voodoo 4x1 filter // ----------------------------------------- // Audio Features @@ -89,13 +88,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //#define DUMB // Use DUMB Module playback library *WIP* #ifndef linux -#define ASS_MIDI // Use Apogee Sound System for MIDI playback only*WIP* + #define ASS_MIDI // Use Apogee Sound System for MIDI playback only*WIP* #endif int inthedos; //#define NOASM #define EFFINGMOUSE // disables "Enhance Pointer Precision" - // a definite MUST for debugging + // a definite MUST for debugging // ----------------------------------------- // Gameplay Features @@ -104,34 +103,32 @@ int inthedos; #define GLOBOT // tomaz globots //#define VMTOC // viewmodelforclient changes #define SONOFABITS // Bits workaround :( -//#define BITSAGAIN // qip way +//#define BITSAGAIN // qip way // ----------------------------------------- // Versioning // ----------------------------------------- -int qbeta; // when 1, it tries to force guestimated pre-1.00 behaviors -int protocol; // OK. -int Nehahrademcompatibility; // LordHavoc: to allow playback of the early Nehahra movie segments -int dpprotocol; +int qbeta; // when 1, it tries to force guestimated pre-1.00 behaviors +int protocol; // OK. +int Nehahrademcompatibility; // LordHavoc: to allow playback of the early Nehahra movie segments +int dpprotocol; + #define DPPROTOCOLS -#define QIP_VERSION "Build 278" -#define QIP_URL "nowhere" -#define VERSION 1.08 -#define TNQ_VERSION 240 // todo: increment build numbers +#define QIP_VERSION "Build 278" +#define QIP_URL "nowhere" +#define VERSION 1.08 +#define TNQ_VERSION 240 // todo: increment build numbers #define GLQUAKE_VERSION 1.00 #define D3DQUAKE_VERSION 0.01 #define WINQUAKE_VERSION 2.78 // was 0.996, but WinQuake was already final #define LINUX_VERSION 1.30 -#define X11_VERSION 1.10 - +#define X11_VERSION 1.10 #define PROTOCOL_STOCK 0 // old 1.09 #define PROTOCOL_QUAKEDP 1 // dp105 #define PROTOCOL_TQ 2 // Tomazquake - - //define PARANOID // speed sapping error checking // ----------------------------------------- @@ -170,14 +167,14 @@ int gamemode; #define GAME_TRANSFUSION 5 // 2002 #define GAME_CIA_OPERATIVE 6 // 2001 - trainwreck #define GAME_JESUSTHEFPS 7 // 2003 - very jesusy -#define GAME_GRASS 8 // 2002 +#define GAME_GRASS 8 // 2002 #define GAME_MINIRACER 9 // 2002 //#define GAME_HEXEN_II 10 // 1997 - too many system vars changes atm #define GAME_FIEND_HUNTER 11 // 2001 v0.64 #define GAME_NEHAHRA 12 // 2000 #define GAME_URBANMERC 13 // 2000 - profits are "emulated" -#define GAME_KUROK 14 // 2008 -#define GAME_FIGHT 15 // 2015? +#define GAME_KUROK 14 // 2008 +#define GAME_FIGHT 15 // 2015? #include #include @@ -198,80 +195,61 @@ int gamemode; // #if defined(_WIN32) && !defined(WINDED) + #if defined(_M_IX86) + #define __i386__ 1 + #endif -#if defined(_M_IX86) -#define __i386__ 1 -#endif - -void VID_LockBuffer (void); -void VID_UnlockBuffer (void); - + void VID_LockBuffer (void); + void VID_UnlockBuffer (void); #else - -#define VID_LockBuffer() -#define VID_UnlockBuffer() - + #define VID_LockBuffer() + #define VID_UnlockBuffer() #endif #if defined __i386__ && !defined NOASM // && !defined __sun__ -#define id386 1 -#define id386poly 0 -#define id386rgb 0 + #define id386 1 + #define id386poly 0 + #define id386rgb 0 #else -#define id386 0 -#define id386poly 0 -#define id386rgb 0 + #define id386 0 + #define id386poly 0 + #define id386rgb 0 #endif #if id386 -#define UNALIGNED_OK 1 // set to 0 if unaligned accesses are not supported + #define UNALIGNED_OK 1 // set to 0 if unaligned accesses are not supported #else -#define UNALIGNED_OK 0 + #define UNALIGNED_OK 0 #endif // !!! if this is changed, it must be changed in d_ifacea.h too !!! #define CACHE_SIZE 32 // used to align key data structures #define UNUSED(x) (x = x) // for pesky compiler / lint warnings -#ifdef BENCH -#define MINIMUM_MEMORY 0x0186A0 // 100kb hack test -#else -#define MINIMUM_MEMORY 0x550000 -#endif -#define MINIMUM_MEMORY_LEVELPAK (MINIMUM_MEMORY + 0x100000) +#ifdef BENCH + #define MINIMUM_MEMORY 0x0186A0 // 100kb hack test +#else + #define MINIMUM_MEMORY 0x550000 +#endif + +#define MINIMUM_MEMORY_LEVELPAK (MINIMUM_MEMORY + 0x100000) #define MAX_NUM_ARGVS 50 -// up / down -#define PITCH 0 +#define PITCH 0 // up / down +#define YAW 1 // left / right +#define ROLL 2 // fall over -// left / right -#define YAW 1 +#define MAX_QPATH 64 // max length of a quake game pathname +#define MAX_OSPATH 128 // max length of a filesystem pathname +#define ON_EPSILON 0.1 // point on plane side epsilon -// fall over -#define ROLL 2 - - -#define MAX_QPATH 64 // max length of a quake game pathname -#define MAX_OSPATH 128 // max length of a filesystem pathname - -#define ON_EPSILON 0.1 // point on plane side epsilon #ifdef QSB_NET -#define MAX_MSGLEN 65536 // max length of a reliable message -//#define MAX_DATAGRAM 1400 // max length of unreliable message -#define MAX_DATAGRAM 16000 // max length of unreliable message - // leilei - I only raised this just to - // have fun with excessive entity stress. - // (craploads of monsters) because it's nice - // to not see "PACKET OVERFLOW" spammed. - // please lower this to 1400 for serious - // QSB standard use. + #define MAX_MSGLEN 65536 // max length of a reliable message + #define MAX_DATAGRAM 1400 // max length of unreliable message #else - - -#define MAX_MSGLEN 8000 // max length of a reliable message -#define MAX_DATAGRAM 1024 // max length of unreliable message - + #define MAX_MSGLEN 8000 // max length of a reliable message + #define MAX_DATAGRAM 1024 // max length of unreliable message #endif @@ -286,26 +264,26 @@ void VID_UnlockBuffer (void); #ifdef QSB_NET #define MAX_MODELS 4096 // these are sent over the net as bytes -#define MAX_SOUNDS 4096 // so they cannot be blindly increased +#define MAX_SOUNDS 4096 // so they cannot be blindly increased -#define MIN_EDICTS 600 // must be the original default value: 600 +#define MIN_EDICTS 600 // must be the original default value: 600 #define MAX_EDICTS 8192 // Maximum without network changes, as entity number is send as signed short (2 bytes) -#define MIN_TEMP_ENTITIES 1024 // lightning bolts, etc -#define MIN_STATIC_ENTITIES 1024 // torches, etc +#define MIN_TEMP_ENTITIES 1024 // lightning bolts, etc +#define MIN_STATIC_ENTITIES 1024 // torches, etc // 2001-09-20 Configurable entity limits by Maddes end #define MAX_LIGHTSTYLES 64 #else -#define MAX_MODELS 256 // these are sent over the net as bytes -#define MAX_SOUNDS 256 // so they cannot be blindly increased +#define MAX_MODELS 256 // these are sent over the net as bytes +#define MAX_SOUNDS 256 // so they cannot be blindly increased -#define MIN_EDICTS 600 // must be the original default value: 600 -#define MAX_EDICTS 0x7FFF // Maximum without network changes, as entity number is send as signed short (2 bytes) +#define MIN_EDICTS 600 // must be the original default value: 600 +#define MAX_EDICTS 0x7FFF // Maximum without network changes, as entity number is send as signed short (2 bytes) -#define MIN_TEMP_ENTITIES 64 // lightning bolts, etc -#define MIN_STATIC_ENTITIES 128 // torches, etc +#define MIN_TEMP_ENTITIES 64 // lightning bolts, etc +#define MIN_STATIC_ENTITIES 128 // torches, etc // 2001-09-20 Configurable entity limits by Maddes end #define MAX_LIGHTSTYLES 64 @@ -319,16 +297,16 @@ void VID_UnlockBuffer (void); // stats are integers communicated to the client by the server // #define MAX_CL_STATS 32 -#define STAT_HEALTH 0 -#define STAT_FRAGS 1 -#define STAT_WEAPON 2 -#define STAT_AMMO 3 -#define STAT_ARMOR 4 +#define STAT_HEALTH 0 +#define STAT_FRAGS 1 +#define STAT_WEAPON 2 +#define STAT_AMMO 3 +#define STAT_ARMOR 4 #define STAT_WEAPONFRAME 5 -#define STAT_SHELLS 6 -#define STAT_NAILS 7 +#define STAT_SHELLS 6 +#define STAT_NAILS 7 #define STAT_ROCKETS 8 -#define STAT_CELLS 9 +#define STAT_CELLS 9 #define STAT_ACTIVEWEAPON 10 #define STAT_TOTALSECRETS 11 #define STAT_TOTALMONSTERS 12 @@ -337,54 +315,54 @@ void VID_UnlockBuffer (void); // stock defines -#define IT_SHOTGUN 1 -#define IT_SUPER_SHOTGUN 2 -#define IT_NAILGUN 4 -#define IT_SUPER_NAILGUN 8 -#define IT_GRENADE_LAUNCHER 16 -#define IT_ROCKET_LAUNCHER 32 -#define IT_LIGHTNING 64 -#define IT_SUPER_LIGHTNING 128 -#define IT_SHELLS 256 -#define IT_NAILS 512 -#define IT_ROCKETS 1024 -#define IT_CELLS 2048 -#define IT_AXE 4096 -#define IT_ARMOR1 8192 -#define IT_ARMOR2 16384 -#define IT_ARMOR3 32768 -#define IT_SUPERHEALTH 65536 -#define IT_KEY1 131072 -#define IT_KEY2 262144 -#define IT_INVISIBILITY 524288 -#define IT_INVULNERABILITY 1048576 -#define IT_SUIT 2097152 -#define IT_QUAD 4194304 -#define IT_SIGIL1 (1<<28) -#define IT_SIGIL2 (1<<29) -#define IT_SIGIL3 (1<<30) -#define IT_SIGIL4 (1<<31) +#define IT_SHOTGUN 1 +#define IT_SUPER_SHOTGUN 2 +#define IT_NAILGUN 4 +#define IT_SUPER_NAILGUN 8 +#define IT_GRENADE_LAUNCHER 16 +#define IT_ROCKET_LAUNCHER 32 +#define IT_LIGHTNING 64 +#define IT_SUPER_LIGHTNING 128 +#define IT_SHELLS 256 +#define IT_NAILS 512 +#define IT_ROCKETS 1024 +#define IT_CELLS 2048 +#define IT_AXE 4096 +#define IT_ARMOR1 8192 +#define IT_ARMOR2 16384 +#define IT_ARMOR3 32768 +#define IT_SUPERHEALTH 65536 +#define IT_KEY1 131072 +#define IT_KEY2 262144 +#define IT_INVISIBILITY 524288 +#define IT_INVULNERABILITY 1048576 +#define IT_SUIT 2097152 +#define IT_QUAD 4194304 +#define IT_SIGIL1 (1<<28) +#define IT_SIGIL2 (1<<29) +#define IT_SIGIL3 (1<<30) +#define IT_SIGIL4 (1<<31) //=========================================== //rogue changed and added defines -#define RIT_SHELLS 128 -#define RIT_NAILS 256 -#define RIT_ROCKETS 512 -#define RIT_CELLS 1024 -#define RIT_AXE 2048 +#define RIT_SHELLS 128 +#define RIT_NAILS 256 +#define RIT_ROCKETS 512 +#define RIT_CELLS 1024 +#define RIT_AXE 2048 #define RIT_LAVA_NAILGUN 4096 -#define RIT_LAVA_SUPER_NAILGUN 8192 +#define RIT_LAVA_SUPER_NAILGUN 8192 #define RIT_MULTI_GRENADE 16384 #define RIT_MULTI_ROCKET 32768 #define RIT_PLASMA_GUN 65536 -#define RIT_ARMOR1 8388608 -#define RIT_ARMOR2 16777216 -#define RIT_ARMOR3 33554432 +#define RIT_ARMOR1 8388608 +#define RIT_ARMOR2 16777216 +#define RIT_ARMOR3 33554432 #define RIT_LAVA_NAILS 67108864 #define RIT_PLASMA_AMMO 134217728 #define RIT_MULTI_ROCKETS 268435456 -#define RIT_SHIELD 536870912 +#define RIT_SHIELD 536870912 #define RIT_ANTIGRAV 1073741824 #define RIT_SUPERHEALTH 2147483648 @@ -392,13 +370,13 @@ void VID_UnlockBuffer (void); //=========================================== //hipnotic added defines #define HIT_PROXIMITY_GUN_BIT 16 -#define HIT_MJOLNIR_BIT 7 +#define HIT_MJOLNIR_BIT 7 #define HIT_LASER_CANNON_BIT 23 -#define HIT_PROXIMITY_GUN (1<offsets[r_drawsurf.surfmip]; - - // the fractional light values should range from 0 to (VID_GRADES - 1) << 16 // from a source range of 0 - 255 diff --git a/engine/snd_mix.c b/engine/snd_mix.c index 4622b28..c1eef05 100644 --- a/engine/snd_mix.c +++ b/engine/snd_mix.c @@ -29,12 +29,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define PAINTBUFFER_SIZE 2048 portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE]; -int snd_scaletable[32][256]; +int snd_scaletable[32][256]; int *snd_p, snd_linear_count, snd_vol; short *snd_out; extern cvar_t *s_underwater; void Snd_WriteLinearBlastStereo16 (void); -int playersnd; // leilei - dsp effects +int playersnd; // leilei - dsp effects #if !id386 void Snd_WriteLinearBlastStereo16 (void) { @@ -461,7 +461,7 @@ void // leilei - VERY BAD attempt at stereo sound support - sfx = (unsigned char *)sc->data; +// sfx = (unsigned char *)sc->data; sfx = (unsigned char *)sc->data; for (i = 0; i < count; i++) diff --git a/engine/sv_main.c b/engine/sv_main.c index ede706d..75b8cba 100644 --- a/engine/sv_main.c +++ b/engine/sv_main.c @@ -900,9 +900,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) int i; edict_t *other; int items; -#ifndef QUAKE2 eval_t *val; -#endif // // send a damage message @@ -958,21 +956,12 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) if (ent->v.idealpitch) bits |= SU_IDEALPITCH; -// stuff the sigil bits into the high bits of items for sbar, or else -// mix in items2 -#ifdef QUAKE2 - items = (int)ent->v.items | ((int)ent->v.items2 << 23); -#else -// 2001-11-15 Better GetEdictFieldValue performance by LordHavoc/Maddes start -// val = GetEdictFieldValue(ent, "items2"); val = GETEDICTFIELDVALUE(ent, pr_field_items2); -// 2001-11-15 Better GetEdictFieldValue performance by LordHavoc/Maddes end if (val) items = (int)ent->v.items | ((int)val->_float << 23); else items = (int)ent->v.items | ((int)pr_global_struct->serverflags << 28); -#endif bits |= SU_ITEMS; @@ -1342,11 +1331,7 @@ void SV_SendReconnect (void) NET_SendToAll (&msg, 5); if (cls.state != ca_dedicated) -#ifdef QUAKE2 - Cbuf_InsertText ("reconnect\n"); -#else Cmd_ExecuteString ("reconnect\n", src_command); -#endif } @@ -1387,11 +1372,7 @@ This is called at the start of each level */ extern float scr_centertime_off; -#ifdef QUAKE2 -void SV_SpawnServer (char *server, char *startspot) -#else void SV_SpawnServer (char *server) -#endif { edict_t *ent; int i; @@ -1433,10 +1414,6 @@ void SV_SpawnServer (char *server) memset (&sv, 0, sizeof(sv)); strcpy (sv.name, server); -#ifdef QUAKE2 - if (startspot) - strcpy(sv.startspot, startspot); -#endif // load progs to get entity field count PR_LoadProgs (); @@ -1534,10 +1511,6 @@ void SV_SpawnServer (char *server) pr_global_struct->deathmatch = deathmatch->value; pr_global_struct->mapname = sv.name - pr_strings; -#ifdef QUAKE2 - pr_global_struct->startspot = sv.startspot - pr_strings; -#endif - // serverflags are for cross level information (sigils) pr_global_struct->serverflags = svs.serverflags; diff --git a/engine/vid_win_old.c b/engine/vid_win_old.c deleted file mode 100644 index 49058e2..0000000 --- a/engine/vid_win_old.c +++ /dev/null @@ -1,3516 +0,0 @@ -/* -Copyright (C) 1996-1997 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -// vid_win.c -- Win32 video driver - -#include "quakedef.h" -#include "winquake.h" -#include "d_local.h" -#include "resource.h" - -#define MAX_MODE_LIST 70 -#define VID_ROW_SIZE 3 - -qboolean dibonly; -byte globalcolormap[VID_GRADES*256], lastglobalcolor = 0; -byte *lastsourcecolormap = NULL; -//extern int Minimized; //wrong, and correct in winquake.h // 2001-12-10 Compilable with LCC-Win32 by Jeff Ford - -HWND mainwindow; - -HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow); - -int vidmodetweak; // leilei -int DIBWidth, DIBHeight; -qboolean DDActive; -RECT WindowRect; -DWORD WindowStyle, ExWindowStyle; -int yeahimconsoled; -int window_center_x, window_center_y, window_x, window_y, window_width, window_height; -RECT window_rect; - -static DEVMODE gdevmode; -static qboolean startwindowed = 0, windowed_mode_set; -static int firstupdate = 1; -static qboolean vid_initialized = false, vid_palettized; -static int lockcount; -static int vid_fulldib_on_focus_mode; -static qboolean force_minimized, in_mode_set, is_mode0x13, force_mode_set; -static int vid_stretched, windowed_mouse; - -static qboolean palette_changed, syscolchg, vid_mode_set, hide_window, pal_is_nostatic; -static HICON hIcon; - -viddef_t vid; // global video state - -#define MODE_WINDOWED 0 -#define MODE_SETTABLE_WINDOW 2 -#define NO_MODE (MODE_WINDOWED - 1) -#define MODE_FULLSCREEN_DEFAULT (MODE_WINDOWED + 3) - -// Note that 0 is MODE_WINDOWED -cvar_t *vid_mode; -// Note that 0 is MODE_WINDOWED -cvar_t *_vid_default_mode; -// Note that 3 is MODE_FULLSCREEN_DEFAULT -cvar_t *_vid_default_mode_win; -cvar_t *vid_wait; -cvar_t *vid_nopageflip; -cvar_t *_vid_wait_override; -cvar_t *vid_config_x; -cvar_t *vid_config_y; -cvar_t *vid_stretch_by_2; -cvar_t *_windowed_mouse; -cvar_t *vid_fullscreen_mode; -cvar_t *vid_windowed_mode; -cvar_t *block_switch; -cvar_t *vid_window_x; -cvar_t *vid_window_y; - -typedef struct { - int width; - int height; -} lmode_t; - -lmode_t lowresmodes[] = { - {320, 200}, - {320, 240}, - {400, 300}, - {512, 384}, -}; - -int vid_modenum = NO_MODE; -int vid_testingmode, vid_realmode; -double vid_testendtime; -int vid_default = MODE_WINDOWED; -static int windowed_default; - -modestate_t modestate = MS_UNINIT; - -static byte *vid_surfcache; -static int vid_surfcachesize; -static int VID_highhunkmark; - -unsigned char vid_curpal[256*3]; - -unsigned short d_8to16table[256]; -unsigned d_8to24table[256]; - -int driver = grDETECT,mode; -bool useWinDirect = true, useDirectDraw = true; -MGLDC *mgldc = NULL,*memdc = NULL,*dibdc = NULL,*windc = NULL; - -typedef struct { - modestate_t type; - int width; - int height; - int modenum; - int mode13; - int stretched; - int dib; - int fullscreen; - int bpp; - int halfscreen; - char modedesc[13]; -} vmode_t; - -static vmode_t modelist[MAX_MODE_LIST]; -static int nummodes; -static vmode_t *pcurrentmode; - -int aPage; // Current active display page -int vPage; // Current visible display page -int waitVRT = true; // True to wait for retrace on flip - -static vmode_t badmode; - -static byte backingbuf[48*24]; - -void VID_MenuDraw (void); -void VID_MenuKey (int key); - -LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -void AppActivate(BOOL fActive, BOOL minimize); - - -/* -================ -VID_RememberWindowPos -================ -*/ -void VID_RememberWindowPos (void) -{ - RECT rect; - - if (GetWindowRect (mainwindow, &rect)) - { - if ((rect.left < GetSystemMetrics (SM_CXSCREEN)) && - (rect.top < GetSystemMetrics (SM_CYSCREEN)) && - (rect.right > 0) && - (rect.bottom > 0)) - { - Cvar_SetValue (vid_window_x, (float)rect.left); - Cvar_SetValue (vid_window_y, (float)rect.top); - } - } -} - - -/* -================ -VID_CheckWindowXY -================ -*/ -void VID_CheckWindowXY (void) -{ - - if (((int)vid_window_x->value > (GetSystemMetrics (SM_CXSCREEN) - 160)) || - ((int)vid_window_y->value > (GetSystemMetrics (SM_CYSCREEN) - 120)) || - ((int)vid_window_x->value < 0) || - ((int)vid_window_y->value < 0)) - { - Cvar_Set (vid_window_x, "0"); - Cvar_Set (vid_window_y, "0" ); - } -} - - -/* -================ -VID_UpdateWindowStatus -================ -*/ -void VID_UpdateWindowStatus (void) -{ - - window_rect.left = window_x; - window_rect.top = window_y; - window_rect.right = window_x + window_width; - window_rect.bottom = window_y + window_height; - window_center_x = (window_rect.left + window_rect.right) / 2; - window_center_y = (window_rect.top + window_rect.bottom) / 2; - - - IN_UpdateClipCursor (); -} - - -/* -================ -ClearAllStates -================ -*/ -void ClearAllStates (void) -{ - int i; - -// send an up event for each key, to make sure the server clears them all - for (i=0 ; i<256 ; i++) - { - Key_Event (i, false); - } - - Key_ClearStates (); - IN_ClearStates (); -} - - -/* -================ -VID_CheckAdequateMem -================ -*/ -qboolean VID_CheckAdequateMem (int width, int height) -{ - int tbuffersize; - - tbuffersize = width * height * sizeof (*d_pzbuffer); - - tbuffersize += D_SurfaceCacheForRes (width, height); - -// see if there's enough memory, allowing for the normal mode 0x13 pixel, -// z, and surface buffers - if ((host_parms.memsize - tbuffersize + SURFCACHE_SIZE_AT_320X200 + - 0x10000 * 3) < minimum_memory) - { - return false; // not enough memory for mode - } - - return true; -} - - -/* -================ -VID_AllocBuffers -================ -*/ -qboolean VID_AllocBuffers (int width, int height) -{ - int tsize, tbuffersize; - - tbuffersize = width * height * sizeof (*d_pzbuffer); - - tsize = D_SurfaceCacheForRes (width, height); - - tbuffersize += tsize; - -// see if there's enough memory, allowing for the normal mode 0x13 pixel, -// z, and surface buffers - if ((host_parms.memsize - tbuffersize + SURFCACHE_SIZE_AT_320X200 + - 0x10000 * 3) < minimum_memory) - { - Con_SafePrintf ("Not enough memory for video mode\n"); - return false; // not enough memory for mode - } - - vid_surfcachesize = tsize; - - if (d_pzbuffer) - { - D_FlushCaches (); - Hunk_FreeToHighMark (VID_highhunkmark); - d_pzbuffer = NULL; - } - - VID_highhunkmark = Hunk_HighMark (); - - d_pzbuffer = Hunk_HighAllocName (tbuffersize, "video"); - - vid_surfcache = (byte *)d_pzbuffer + - width * height * sizeof (*d_pzbuffer); - - return true; -} - - -void initFatalError(void) -{ - MGL_exit(); - MGL_fatalError(MGL_errorMsg(MGL_result())); - exit(EXIT_FAILURE); -} - - -int VID_Suspend (MGLDC *dc,m_int flags) -{ - - if (flags & MGL_DEACTIVATE) - { - // FIXME: this doesn't currently work on NT - if (block_switch->value && !WinNT) - { - return MGL_NO_DEACTIVATE; - } - - S_BlockSound (); - S_ClearBuffer (); - - IN_RestoreOriginalMouseState (); - CDAudio_Pause (); - - // keep WM_PAINT from trying to redraw - in_mode_set = true; - - block_drawing = true; // so we don't try to draw while switched away - -// return MGL_NO_SUSPEND_APP; // 2000-01-31 Valid result correction by Maddes - } - else if (flags & MGL_REACTIVATE) - { - IN_SetQuakeMouseState (); - // fix the leftover Alt from any Alt-Tab or the like that switched us away - ClearAllStates (); - CDAudio_Resume (); - S_UnblockSound (); - - in_mode_set = false; - - vid.recalc_refdef = 1; - - block_drawing = false; - -// return MGL_NO_SUSPEND_APP; // 2000-01-31 Valid result correction by Maddes - } - - return MGL_NO_SUSPEND_APP; // 2000-01-31 Valid result correction by Maddes - // changed like bounce.c example from SciTech -} - - -void registerAllDispDrivers(void) -{ - /* Event though these driver require WinDirect, we register - * them so that they will still be available even if DirectDraw - * is present and the user has disable the high performance - * WinDirect modes. - */ - MGL_registerDriver(MGL_VGA8NAME,VGA8_driver); -// MGL_registerDriver(MGL_VGAXNAME,VGAX_driver); - - /* Register display drivers */ - if (useWinDirect) - { -//we don't want VESA 1.X drivers MGL_registerDriver(MGL_SVGA8NAME,SVGA8_driver); - MGL_registerDriver(MGL_LINEAR8NAME,LINEAR8_driver); - - if (!COM_CheckParm ("-novbeaf")) - MGL_registerDriver(MGL_ACCEL8NAME,ACCEL8_driver); - } - - if (useDirectDraw) - { - MGL_registerDriver(MGL_DDRAW8NAME,DDRAW8_driver); - } -} - - -void registerAllMemDrivers(void) -{ - /* Register memory context drivers */ - MGL_registerDriver(MGL_PACKED8NAME,PACKED8_driver); -} - - -void VID_InitMGLFull (HINSTANCE hInstance) -{ - int i, xRes, yRes, bits, vMode, lowres, curmode, temp; - int lowstretchedres, stretchedmode, lowstretched; - uchar *m; - -// FIXME: NT is checked for because MGL currently has a bug that causes it -// to try to use WinDirect modes even on NT - if (COM_CheckParm("-nowindirect") || - COM_CheckParm("-nowd") || - COM_CheckParm("-novesa") || - WinNT) - { - useWinDirect = false; - } - - if (WinNT) - useDirectDraw = false; // this sucks on nt - - - if (COM_CheckParm("-nodirectdraw") || COM_CheckParm("-noddraw") || COM_CheckParm("-nodd")) - useDirectDraw = false; - if (COM_CheckParm("-directdraw") || COM_CheckParm("-ddraw") || COM_CheckParm("-dd")) - useDirectDraw = true; - - // Initialise the MGL - MGL_unregisterAllDrivers(); - registerAllDispDrivers(); - registerAllMemDrivers(); - MGL_detectGraph(&driver,&mode); - m = MGL_availableModes(); - - if (m[0] != 0xFF) - { - lowres = lowstretchedres = 99999; - lowstretched = 0; - curmode = 0; - - // find the lowest-res mode, or a mode we can stretch up to and get - // lowest-res that way - for (i = 0; m[i] != 0xFF; i++) - { - MGL_modeResolution(m[i], &xRes, &yRes,&bits); - - if ((bits == 8) && - (xRes <= MAXWIDTH) && - (yRes <= MAXHEIGHT) && - (curmode < MAX_MODE_LIST)) - { - if (m[i] == grVGA_320x200x256) - is_mode0x13 = true; - - if (!COM_CheckParm("-noforcevga")) - { - if (m[i] == grVGA_320x200x256) - { - mode = i; - break; - } - } - - if (xRes < lowres) - { - lowres = xRes; - mode = i; - } - - if ((xRes < lowstretchedres) && ((xRes >> 1) >= 320)) - { - lowstretchedres = xRes >> 1; - stretchedmode = i; - } - } - - curmode++; - } - - // if there's a mode we can stretch by 2 up to, thereby effectively getting - // a lower-res mode than the lowest-res real but still at least 320x200, that - // will be our default mode - if (lowstretchedres < lowres) - { - mode = stretchedmode; - lowres = lowstretchedres; - lowstretched = 1; - } - - // build the mode list, leaving room for the low-res stretched mode, if any - nummodes++; // leave room for default mode - - for (i = 0; m[i] != 0xFF; i++) - { - MGL_modeResolution(m[i], &xRes, &yRes,&bits); - - if ((bits == 8) && - (xRes <= MAXWIDTH) && - (yRes <= MAXHEIGHT) && - (nummodes < MAX_MODE_LIST)) - { - if (i == mode) - { - if (lowstretched) - { - stretchedmode = nummodes; - curmode = nummodes++; - } - else - { - curmode = MODE_FULLSCREEN_DEFAULT; - } - } - else - { - curmode = nummodes++; - } - - modelist[curmode].type = MS_FULLSCREEN; - modelist[curmode].width = xRes; - modelist[curmode].height = yRes; - sprintf (modelist[curmode].modedesc, "%dx%d", xRes, yRes); - - if (m[i] == grVGA_320x200x256) - modelist[curmode].mode13 = 1; - else - modelist[curmode].mode13 = 0; - - modelist[curmode].modenum = m[i]; - modelist[curmode].stretched = 0; - modelist[curmode].dib = 0; - modelist[curmode].fullscreen = 1; - modelist[curmode].halfscreen = 0; - modelist[curmode].bpp = 8; - } - } - - if (lowstretched == 2) - { - modelist[MODE_FULLSCREEN_DEFAULT] = modelist[stretchedmode]; - modelist[MODE_FULLSCREEN_DEFAULT].stretched = 2; - modelist[MODE_FULLSCREEN_DEFAULT].width >>= 1; - sprintf (modelist[MODE_FULLSCREEN_DEFAULT].modedesc, "%dx%dtwk", - modelist[MODE_FULLSCREEN_DEFAULT].width, - modelist[MODE_FULLSCREEN_DEFAULT].height); - } - - else if (lowstretched) - { - modelist[MODE_FULLSCREEN_DEFAULT] = modelist[stretchedmode]; - modelist[MODE_FULLSCREEN_DEFAULT].stretched = 1; - modelist[MODE_FULLSCREEN_DEFAULT].width >>= 1; - modelist[MODE_FULLSCREEN_DEFAULT].height >>= 1; - sprintf (modelist[MODE_FULLSCREEN_DEFAULT].modedesc, "%dx%dstr", - modelist[MODE_FULLSCREEN_DEFAULT].width, - modelist[MODE_FULLSCREEN_DEFAULT].height); - } - - vid_default = MODE_FULLSCREEN_DEFAULT; - - temp = m[0]; - - if (!MGL_init(&driver, &temp, "")) - { - initFatalError(); - } - } - - MGL_setSuspendAppCallback(VID_Suspend); -} - - -MGLDC *createDisplayDC(int forcemem) -/**************************************************************************** -* -* Function: createDisplayDC -* Returns: Pointer to the MGL device context to use for the application -* -* Description: Initialises the MGL and creates an appropriate display -* device context to be used by the GUI. This creates and -* apropriate device context depending on the system being -* compile for, and should be the only place where system -* specific code is required. -* -****************************************************************************/ -{ - MGLDC *dc; - pixel_format_t pf; - int npages; - - // Start the specified video mode - if (!MGL_changeDisplayMode(mode)) - initFatalError(); - - npages = MGL_availablePages(mode); - - if (npages > 3) - npages = 3; - - if (!COM_CheckParm ("-notriplebuf")) - { - if (npages > 2) - { - npages = 2; - } - } - - if ((dc = MGL_createDisplayDC(npages)) == NULL) - return NULL; - - if (!forcemem && (MGL_surfaceAccessType(dc)) == MGL_LINEAR_ACCESS && (dc->mi.maxPage > 0)) - { - MGL_makeCurrentDC(dc); - memdc = NULL; - } - else - { - // Set up for blitting from a memory buffer - memdc = MGL_createMemoryDC(MGL_sizex(dc)+1,MGL_sizey(dc)+1,8,&pf); - MGL_makeCurrentDC(memdc); - } - - // Enable page flipping even for even for blitted surfaces - if (forcemem) - { - vid.numpages = 1; - } - else - { - vid.numpages = dc->mi.maxPage + 1; - - if (vid.numpages > 1) - { - // Set up for page flipping - MGL_setActivePage(dc, aPage = 1); - MGL_setVisualPage(dc, vPage = 0, false); - } - - if (vid.numpages > 3) - vid.numpages = 3; - } - - if (vid.numpages == 2) - waitVRT = true; - else - waitVRT = false; - - return dc; -} - - -void VID_InitMGLDIB (HINSTANCE hInstance) -{ - WNDCLASS wc; - HDC hdc; - int i; - - hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDI_ICON1)); - - /* Register the frame class */ - wc.style = 0; - wc.lpfnWndProc = (WNDPROC)MainWndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = 0; - wc.hCursor = LoadCursor (NULL,IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = 0; - wc.lpszClassName = "WinQuake"; - - if (!RegisterClass (&wc) ) - Sys_Error ("Couldn't register window class"); - - /* Find the size for the DIB window */ - /* Initialise the MGL for windowed operation */ - MGL_setAppInstance(hInstance); - registerAllMemDrivers(); - MGL_initWindowed(""); - - modelist[0].type = MS_WINDOWED; - modelist[0].width = 320; - modelist[0].height = 240; - strcpy (modelist[0].modedesc, "320x240"); - modelist[0].mode13 = 0; - modelist[0].modenum = MODE_WINDOWED; - modelist[0].stretched = 0; - modelist[0].dib = 1; - modelist[0].fullscreen = 0; - modelist[0].halfscreen = 0; - modelist[0].bpp = 8; - - modelist[1].type = MS_WINDOWED; - modelist[1].width = 640; - modelist[1].height = 480; - strcpy (modelist[1].modedesc, "640x480"); - modelist[1].mode13 = 0; - modelist[1].modenum = MODE_WINDOWED + 1; - modelist[1].stretched = 1; - modelist[1].dib = 1; - modelist[1].fullscreen = 0; - modelist[1].halfscreen = 0; - modelist[1].bpp = 8; - - modelist[2].type = MS_WINDOWED; - modelist[2].width = 800; - modelist[2].height = 600; - strcpy (modelist[2].modedesc, "800x600"); - modelist[2].mode13 = 0; - modelist[2].modenum = MODE_WINDOWED + 2; - modelist[2].stretched = 1; - modelist[2].dib = 1; - modelist[2].fullscreen = 0; - modelist[2].halfscreen = 0; - modelist[2].bpp = 8; - - -// automatically stretch the default mode up if > 640x480 desktop resolution - hdc = GetDC(NULL); - - if ((GetDeviceCaps(hdc, HORZRES) > 640) && !COM_CheckParm("-noautostretch")) - { - vid_default = MODE_WINDOWED + 1; - } - else - { - vid_default = MODE_WINDOWED; - } - - windowed_default = vid_default; - - ReleaseDC(NULL,hdc); - - nummodes = 3; // reserve space for windowed mode - - DDActive = 0; -} - - -/* -================= -VID_InitFullDIB -================= -*/ -void VID_InitFullDIB (HINSTANCE hInstance) -{ - DEVMODE devmode; - int i, j, modenum, cmodes, existingmode, originalnummodes, lowestres; - int numlowresmodes, bpp, done; - int cstretch, istretch, mstretch; - BOOL stat; - -// enumerate 8 bpp modes - originalnummodes = nummodes; - modenum = 0; - lowestres = 99999; - - do - { - stat = EnumDisplaySettings (NULL, modenum, &devmode); - - if ((devmode.dmBitsPerPel == 8) && - (devmode.dmPelsWidth <= MAXWIDTH) && - (devmode.dmPelsHeight <= MAXHEIGHT) && - (nummodes < MAX_MODE_LIST)) - { - devmode.dmFields = DM_BITSPERPEL | - DM_PELSWIDTH | - DM_PELSHEIGHT; - - if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) == - DISP_CHANGE_SUCCESSFUL) - { - modelist[nummodes].type = MS_FULLDIB; - modelist[nummodes].width = devmode.dmPelsWidth; - modelist[nummodes].height = devmode.dmPelsHeight; - modelist[nummodes].modenum = 0; - modelist[nummodes].mode13 = 0; - modelist[nummodes].stretched = 0; - modelist[nummodes].halfscreen = 0; - modelist[nummodes].dib = 1; - modelist[nummodes].fullscreen = 1; - modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%dx%d", - devmode.dmPelsWidth, devmode.dmPelsHeight); - - // if the width is more than twice the height, reduce it by half because this - // is probably a dual-screen monitor - if (!COM_CheckParm("-noadjustaspect")) - { - if (modelist[nummodes].width > (modelist[nummodes].height << 1)) - { - modelist[nummodes].width >>= 1; - modelist[nummodes].halfscreen = 1; - sprintf (modelist[nummodes].modedesc, "%dx%d", - modelist[nummodes].width, - modelist[nummodes].height); - } - } - - for (i=originalnummodes, existingmode = 0 ; i 8 bpp - if (nummodes == originalnummodes) - { - modenum = 0; - lowestres = 99999; - - Con_SafePrintf ("No 8-bpp fullscreen DIB modes found\n"); - - do - { - stat = EnumDisplaySettings (NULL, modenum, &devmode); - - if ((((devmode.dmPelsWidth <= MAXWIDTH) && - (devmode.dmPelsHeight <= MAXHEIGHT)) || - (!COM_CheckParm("-noadjustaspect") && - (devmode.dmPelsWidth <= (MAXWIDTH*2)) && - (devmode.dmPelsWidth > (devmode.dmPelsHeight*2)))) && - (nummodes < MAX_MODE_LIST) && - (devmode.dmBitsPerPel > 8)) - { - devmode.dmFields = DM_BITSPERPEL | - DM_PELSWIDTH | - DM_PELSHEIGHT; - - if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) == - DISP_CHANGE_SUCCESSFUL) - { - modelist[nummodes].type = MS_FULLDIB; - modelist[nummodes].width = devmode.dmPelsWidth; - modelist[nummodes].height = devmode.dmPelsHeight; - modelist[nummodes].modenum = 0; - modelist[nummodes].mode13 = 0; - modelist[nummodes].stretched = 0; - modelist[nummodes].halfscreen = 0; - modelist[nummodes].dib = 1; - modelist[nummodes].fullscreen = 1; - modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%dx%d", - devmode.dmPelsWidth, devmode.dmPelsHeight); - - // if the width is more than twice the height, reduce it by half because this - // is probably a dual-screen monitor - if (!COM_CheckParm("-noadjustaspect")) - { - if (modelist[nummodes].width > (modelist[nummodes].height*2)) - { - modelist[nummodes].width >>= 1; - modelist[nummodes].halfscreen = 1; - sprintf (modelist[nummodes].modedesc, "%dx%d", - modelist[nummodes].width, - modelist[nummodes].height); - } - } - - for (i=originalnummodes, existingmode = 0 ; i= modelist[i].bpp)) - { - existingmode = 1; - break; - } - } - - if (!existingmode) - { - if (modelist[nummodes].width < lowestres) - lowestres = modelist[nummodes].width; - - nummodes++; - } - } - } - - switch (bpp) - { - case 8: - bpp = 16; - break; - - case 16: - bpp = 32; - break; - - case 32: - done = 1; - break; - } - } - -// now add the lowest stretch-by-2 pseudo-modes between 320-wide -// (inclusive) and lowest real res (not inclusive) -// don't bother if we have a real VGA mode 0x13 mode - if (!is_mode0x13) - { - for (i=originalnummodes, cstretch=0 ; i> 1) < lowestres) && - ((modelist[i].width >> 1) >= 320)) - { - lowestres = modelist[i].width >> 1; - cstretch = 1; - mstretch = i; - } - } - - if ((nummodes + cstretch) > MAX_MODE_LIST) - cstretch = MAX_MODE_LIST - nummodes; - - if (cstretch > 0) - { - for (i=(nummodes-1) ; i>=originalnummodes ; i--) - modelist[i+cstretch] = modelist[i]; - - nummodes += cstretch; - istretch = originalnummodes; - - modelist[istretch] = modelist[mstretch]; - modelist[istretch].width >>= 1; - modelist[istretch].height >>= 1; - modelist[istretch].stretched = 1; - sprintf (modelist[istretch].modedesc, "%dx%d", - modelist[istretch].width, modelist[istretch].height); - } - } - - if (nummodes != originalnummodes) - vid_default = MODE_FULLSCREEN_DEFAULT; - else - Con_SafePrintf ("No fullscreen DIB modes found\n"); -} - - -/* -================= -VID_NumModes -================= -*/ -int VID_NumModes (void) -{ - return nummodes; -} - - -/* -================= -VID_GetModePtr -================= -*/ -vmode_t *VID_GetModePtr (int modenum) -{ - - if ((modenum >= 0) && (modenum < nummodes)) - return &modelist[modenum]; - else - return &badmode; -} - - -/* -================= -VID_CheckModedescFixup -================= -*/ -void VID_CheckModedescFixup (int mode) -{ - int x, y, stretch; - - if (mode == MODE_SETTABLE_WINDOW) - { - modelist[mode].stretched = (int)vid_stretch_by_2->value; - stretch = modelist[mode].stretched; - if (!stretch == 3){ - if (vid_config_x->value < (320 << stretch)) - vid_config_x->value = 320 << stretch; - } - if (!stretch == 2){ - if (vid_config_y->value < (200 << stretch)) - vid_config_y->value = 200 << stretch; - } - x = (int)vid_config_x->value; - y = (int)vid_config_y->value; - sprintf (modelist[mode].modedesc, "%dx%d", x, y); - modelist[mode].width = x; - modelist[mode].height = y; - } -} - - -/* -================= -VID_GetModeDescriptionMemCheck -================= -*/ -char *VID_GetModeDescriptionMemCheck (int mode) -{ - char *pinfo; - vmode_t *pv; - - if ((mode < 0) || (mode >= nummodes)) - return NULL; - - VID_CheckModedescFixup (mode); - - pv = VID_GetModePtr (mode); - pinfo = pv->modedesc; - - if (VID_CheckAdequateMem (pv->width, pv->height)) - { - return pinfo; - } - else - { - return NULL; - } -} - - -/* -================= -VID_GetModeDescription -================= -*/ -char *VID_GetModeDescription (int mode) -{ - char *pinfo; - vmode_t *pv; - - if ((mode < 0) || (mode >= nummodes)) - return NULL; - - VID_CheckModedescFixup (mode); - - pv = VID_GetModePtr (mode); - pinfo = pv->modedesc; - return pinfo; -} - - -/* -================= -VID_GetModeDescription2 - -Tacks on "windowed" or "fullscreen" -================= -*/ -char *VID_GetModeDescription2 (int mode) -{ - static char pinfo[40]; - vmode_t *pv; - - if ((mode < 0) || (mode >= nummodes)) - return NULL; - - VID_CheckModedescFixup (mode); - - pv = VID_GetModePtr (mode); - - if (modelist[mode].type == MS_FULLSCREEN) - { - sprintf(pinfo,"%s fullscreen", pv->modedesc); - } - else if (modelist[mode].type == MS_FULLDIB) - { - sprintf(pinfo,"%s fullscreen", pv->modedesc); - } - else - { - sprintf(pinfo, "%s windowed", pv->modedesc); - } - - return pinfo; -} - - -// KJB: Added this to return the mode driver name in description for console - -char *VID_GetExtModeDescription (int mode) -{ - static char pinfo[40]; - vmode_t *pv; - - if ((mode < 0) || (mode >= nummodes)) - return NULL; - - VID_CheckModedescFixup (mode); - - pv = VID_GetModePtr (mode); - if (modelist[mode].type == MS_FULLSCREEN) - { - sprintf(pinfo,"%s fullscreen %s",pv->modedesc, - MGL_modeDriverName(pv->modenum)); - } - else if (modelist[mode].type == MS_FULLDIB) - { - sprintf(pinfo,"%s fullscreen DIB", pv->modedesc); - } - else - { - sprintf(pinfo, "%s windowed", pv->modedesc); - } - - return pinfo; -} - - -void DestroyDIBWindow (void) -{ - - if (modestate == MS_WINDOWED) - { - // destroy the associated MGL DC's; the window gets reused - if (windc) - MGL_destroyDC(windc); - if (dibdc) - MGL_destroyDC(dibdc); - windc = dibdc = NULL; - } -} - - -void DestroyFullscreenWindow (void) -{ - - if (modestate == MS_FULLSCREEN) - { - // destroy the existing fullscreen mode and DC's - if (mgldc) - MGL_destroyDC (mgldc); - if (memdc) - MGL_destroyDC (memdc); - mgldc = memdc = NULL; - } -} - - - -void DestroyFullDIBWindow (void) -{ - if (modestate == MS_FULLDIB) - { - ChangeDisplaySettings (NULL, CDS_FULLSCREEN); - - // Destroy the fullscreen DIB window and associated MGL DC's - if (windc) - MGL_destroyDC(windc); - if (dibdc) - MGL_destroyDC(dibdc); - windc = dibdc = NULL; - } -} - - - -void VID_SetAspect (void) -{ - // 12/01/15 LEILEI - new Aspect hack - // If we are using something not wide screen, stick to the old aspect - - if (COM_CheckParm ("-169")){ - vid.aspect = ((float)vid.height / (float)vid.width) * - (1280.0 / 720.0); - } - else if (COM_CheckParm ("-1610")){ - vid.aspect = ((float)vid.height / (float)vid.width) * - (1280.0 / 800.0); - } - else if (COM_CheckParm ("-43")) - { - vid.aspect = ((float)vid.height / (float)vid.width) * - (320.0 / 240.0); -} - - - else - { - //if (vid.height < 720) - vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0); - // else - // vid.aspect = ((float)vid.height / (float)vid.width) * ((float)vid.height / (float)vid.width); - //vid.aspect = ((float)vid.height / (float)vid.width) * (1280 / 720); - - - } -} - - -qboolean VID_SetWindowedMode (int modenum) -{ - HDC hdc; - pixel_format_t pf; - qboolean stretched; -// int lastmodestate; // 2001-12-10 Reduced compiler warnings by Jeff Ford - LONG wlong; - - if (!windowed_mode_set) - { - if (COM_CheckParm ("-resetwinpos")) - { - Cvar_Set (vid_window_x, "0"); - Cvar_Set (vid_window_y, "0"); - } - -// windowed_mode_set; // 2001-12-10 Reduced compiler warnings by Jeff Ford - } - - VID_CheckModedescFixup (modenum); - - DDActive = 0; -// lastmodestate = modestate; // 2001-12-10 Reduced compiler warnings by Jeff Ford - - DestroyFullscreenWindow (); - DestroyFullDIBWindow (); - - if (windc) - MGL_destroyDC(windc); - if (dibdc) - MGL_destroyDC(dibdc); - windc = dibdc = NULL; - -// KJB: Signal to the MGL that we are going back to windowed mode - if (!MGL_changeDisplayMode(grWINDOWED)) - initFatalError(); - - WindowRect.top = WindowRect.left = 0; - - WindowRect.right = modelist[modenum].width; - WindowRect.bottom = modelist[modenum].height; - stretched = modelist[modenum].stretched; - - DIBWidth = modelist[modenum].width; - DIBHeight = modelist[modenum].height; - - if (stretched) - { - if (stretched == 2){ - DIBWidth >>= 1; - vidmodetweak = 2; - } - else if (stretched == 3){ - vidmodetweak = 4; - DIBHeight >>= 1; - } - else { - DIBWidth >>= 1; - DIBHeight >>= 1; - vidmodetweak = 0; - } - } - - WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | - WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | - WS_CLIPCHILDREN; - ExWindowStyle = 0; - AdjustWindowRectEx(&WindowRect, WindowStyle, FALSE, 0); - -// the first time we're called to set the mode, create the window we'll use -// for the rest of the session - if (!vid_mode_set) - { - mainwindow = CreateWindowEx ( - ExWindowStyle, - "WinQuake", - "WinQuake", - WindowStyle, - 0, 0, - WindowRect.right - WindowRect.left, - WindowRect.bottom - WindowRect.top, - NULL, - NULL, - global_hInstance, - NULL); - - if (!mainwindow) - Sys_Error ("Couldn't create DIB window"); - - // tell MGL to use this window for fullscreen modes - MGL_registerFullScreenWindow (mainwindow); - - vid_mode_set = true; - } - else - { - SetWindowLong(mainwindow, GWL_STYLE, WindowStyle | WS_VISIBLE); - SetWindowLong(mainwindow, GWL_EXSTYLE, ExWindowStyle); - } - - if (!SetWindowPos (mainwindow, - NULL, - 0, 0, - WindowRect.right - WindowRect.left, - WindowRect.bottom - WindowRect.top, - SWP_NOCOPYBITS | SWP_NOZORDER | - SWP_HIDEWINDOW)) - { - Sys_Error ("Couldn't resize DIB window"); - } - - if (hide_window) - return true; - -// position and show the DIB window - VID_CheckWindowXY (); - SetWindowPos (mainwindow, NULL, (int)vid_window_x->value, - (int)vid_window_y->value, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME); - - if (force_minimized) - ShowWindow (mainwindow, SW_MINIMIZE); - else - ShowWindow (mainwindow, SW_SHOWDEFAULT); - - UpdateWindow (mainwindow); - - modestate = MS_WINDOWED; - vid_fulldib_on_focus_mode = 0; - -// because we have set the background brush for the window to NULL -// (to avoid flickering when re-sizing the window on the desktop), -// we clear the window to black when created, otherwise it will be -// empty while Quake starts up. - hdc = GetDC(mainwindow); - PatBlt(hdc,0,0,WindowRect.right,WindowRect.bottom,BLACKNESS); - ReleaseDC(mainwindow, hdc); - - /* Create the MGL window DC and the MGL memory DC */ - if ((windc = MGL_createWindowedDC(mainwindow)) == NULL) - MGL_fatalError("Unable to create Windowed DC!"); - - if ((dibdc = MGL_createMemoryDC(DIBWidth,DIBHeight,8,&pf)) == NULL) - MGL_fatalError("Unable to create Memory DC!"); - - MGL_makeCurrentDC(dibdc); - - vid.buffer = vid.conbuffer = vid.direct = dibdc->surface; - vid.rowbytes = vid.conrowbytes = dibdc->mi.bytesPerLine; - vid.numpages = 1; - vid.maxwarpwidth = WARP_WIDTH; - vid.maxwarpheight = WARP_HEIGHT; - vid.maxlowwidth = 160; - vid.maxlowheight = 200; - vid.height = vid.conheight = DIBHeight; - vid.width = vid.conwidth = DIBWidth; - - VID_SetAspect(); - - vid_stretched = stretched; - vid.stretched = stretched; - - SendMessage (mainwindow, WM_SETICON, (WPARAM)TRUE, (LPARAM)hIcon); - SendMessage (mainwindow, WM_SETICON, (WPARAM)FALSE, (LPARAM)hIcon); - - return true; -} - - -qboolean VID_SetFullscreenMode (int modenum) -{ - - DDActive = 1; - - DestroyDIBWindow (); - DestroyFullDIBWindow (); - - mode = modelist[modenum].modenum; - - // Destroy old DC's, resetting back to fullscreen mode - if (mgldc) - MGL_destroyDC (mgldc); - if (memdc) - MGL_destroyDC (memdc); - mgldc = memdc = NULL; - - if ((mgldc = createDisplayDC (modelist[modenum].stretched || - (int)vid_nopageflip->value)) == NULL) - { - return false; - } - - modestate = MS_FULLSCREEN; - vid_fulldib_on_focus_mode = 0; - - vid.buffer = vid.conbuffer = vid.direct = NULL; - vid.maxwarpwidth = WARP_WIDTH; - vid.maxwarpheight = WARP_HEIGHT; - vid.maxlowwidth = LOW_WIDTH; - vid.maxlowheight = LOW_HEIGHT; - DIBHeight = vid.height = vid.conheight = modelist[modenum].height; - DIBWidth = vid.width = vid.conwidth = modelist[modenum].width; - #ifdef SCALED2D - vid.height = vid.conheight = DIBHeight; - vid.width = vid.conwidth = DIBWidth; - //vid.vconwidth = 320; - //vid.vconheight = 200; - if (!yeahimconsoled){ - vid.vconheight = DIBHeight; - vid.vconwidth = DIBWidth;} -#else - vid.height = vid.conheight = DIBHeight; - vid.width = vid.conwidth = DIBWidth; -#endif - VID_SetAspect(); - vid_stretched = modelist[modenum].stretched; - -// needed because we're not getting WM_MOVE messages fullscreen on NT - window_x = 0; - window_y = 0; - -// set the large icon, so the Quake icon will show up in the taskbar - SendMessage (mainwindow, WM_SETICON, (WPARAM)1, (LPARAM)hIcon); - SendMessage (mainwindow, WM_SETICON, (WPARAM)0, (LPARAM)hIcon); - -// shouldn't be needed, but Kendall needs to let us get the activation -// message for this not to be needed on NT - AppActivate (true, false); - - return true; -} - - -qboolean VID_SetFullDIBMode (int modenum) -{ - HDC hdc; - pixel_format_t pf; -// int lastmodestate; // 2001-12-10 Reduced compiler warnings by Jeff Ford - - DDActive = 0; - - DestroyFullscreenWindow (); - DestroyDIBWindow (); - - if (windc) - MGL_destroyDC(windc); - if (dibdc) - MGL_destroyDC(dibdc); - windc = dibdc = NULL; - -// KJB: Signal to the MGL that we are going back to windowed mode - if (!MGL_changeDisplayMode(grWINDOWED)) - initFatalError(); - - gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - gdevmode.dmBitsPerPel = modelist[modenum].bpp; - - gdevmode.dmPelsWidth = modelist[modenum].width << modelist[modenum].stretched << - modelist[modenum].halfscreen; - - gdevmode.dmPelsHeight = modelist[modenum].height << modelist[modenum].stretched; - gdevmode.dmSize = sizeof (gdevmode); - - if (ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) - Sys_Error ("Couldn't set fullscreen DIB mode"); - -// lastmodestate = modestate; // 2001-12-10 Reduced compiler warnings by Jeff Ford - modestate = MS_FULLDIB; - vid_fulldib_on_focus_mode = modenum; - - WindowRect.top = WindowRect.left = 0; - - hdc = GetDC(NULL); - - WindowRect.right = modelist[modenum].width << modelist[modenum].stretched; - WindowRect.bottom = modelist[modenum].height << modelist[modenum].stretched; - - ReleaseDC(NULL,hdc); - - DIBWidth = modelist[modenum].width; - DIBHeight = modelist[modenum].height; - - WindowStyle = WS_POPUP | WS_SYSMENU | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - ExWindowStyle = 0; - AdjustWindowRectEx(&WindowRect, WindowStyle, FALSE, 0); - - SetWindowLong(mainwindow, GWL_STYLE, WindowStyle | WS_VISIBLE); - SetWindowLong(mainwindow, GWL_EXSTYLE, ExWindowStyle); - - if (!SetWindowPos (mainwindow, - NULL, - 0, 0, - WindowRect.right - WindowRect.left, - WindowRect.bottom - WindowRect.top, - SWP_NOCOPYBITS | SWP_NOZORDER)) - { - Sys_Error ("Couldn't resize DIB window"); - } - -// position and show the DIB window - SetWindowPos (mainwindow, HWND_TOPMOST, 0, 0, 0, 0, - SWP_NOSIZE | SWP_SHOWWINDOW | SWP_DRAWFRAME); - ShowWindow (mainwindow, SW_SHOWDEFAULT); - UpdateWindow (mainwindow); - - // Because we have set the background brush for the window to NULL - // (to avoid flickering when re-sizing the window on the desktop), we - // clear the window to black when created, otherwise it will be - // empty while Quake starts up. - hdc = GetDC(mainwindow); - PatBlt(hdc,0,0,WindowRect.right,WindowRect.bottom,BLACKNESS); - ReleaseDC(mainwindow, hdc); - - /* Create the MGL window DC and the MGL memory DC */ - if ((windc = MGL_createWindowedDC(mainwindow)) == NULL) - MGL_fatalError("Unable to create Fullscreen DIB DC!"); - - if ((dibdc = MGL_createMemoryDC(DIBWidth,DIBHeight,8,&pf)) == NULL) - MGL_fatalError("Unable to create Memory DC!"); - - MGL_makeCurrentDC(dibdc); - - vid.buffer = vid.conbuffer = vid.direct = dibdc->surface; - vid.rowbytes = vid.conrowbytes = dibdc->mi.bytesPerLine; - vid.numpages = 1; - vid.maxwarpwidth = WARP_WIDTH; - vid.maxwarpheight = WARP_HEIGHT; - vid.maxlowwidth = 160; - vid.maxlowheight = 200; - vid.height = vid.conheight = DIBHeight; - vid.width = vid.conwidth = DIBWidth; -// vid.aspect = ((float)vid.height / (float)vid.width) * -// (320.0 / 240.0); - VID_SetAspect(); - vid_stretched = modelist[modenum].stretched; - -// needed because we're not getting WM_MOVE messages fullscreen on NT - window_x = 0; - window_y = 0; - - return true; -} - - -void VID_RestoreOldMode (int original_mode) -{ - static qboolean inerror = false; - - if (inerror) - return; - - in_mode_set = false; - inerror = true; - -// make sure mode set happens (video mode changes) - vid_modenum = original_mode - 1; - - if (!VID_SetMode (original_mode, vid_curpal)) - { - vid_modenum = MODE_WINDOWED - 1; - - if (!VID_SetMode (windowed_default, vid_curpal)) - Sys_Error ("Can't set any video mode"); - } - - inerror = false; -} - - -void VID_SetDefaultMode (void) -{ - - if (vid_initialized) - VID_SetMode (0, vid_curpal); - - IN_DeactivateMouse (); -} - - -int VID_SetMode (int modenum, unsigned char *palette) -{ - int original_mode, temp, dummy; - qboolean stat; - MSG msg; - HDC hdc; - - while ((modenum >= nummodes) || (modenum < 0)) - { - if (vid_modenum == NO_MODE) - { - if (modenum == vid_default) - { - modenum = windowed_default; - } - else - { - modenum = vid_default; - } - - Cvar_SetValue (vid_mode, (float)modenum); - } - else - { - Cvar_SetValue (vid_mode, (float)vid_modenum); - return 0; - } - } - - if (!force_mode_set && (modenum == vid_modenum)) - return true; - -// so Con_Printfs don't mess us up by forcing vid and snd updates - temp = scr_disabled_for_loading; - scr_disabled_for_loading = true; - in_mode_set = true; - - CDAudio_Pause (); - S_ClearBuffer (); - - if (vid_modenum == NO_MODE) - original_mode = windowed_default; - else - original_mode = vid_modenum; - - // Set either the fullscreen or windowed mode - if (modelist[modenum].type == MS_WINDOWED) - { - if (_windowed_mouse->value) - { - stat = VID_SetWindowedMode(modenum); - IN_ActivateMouse (); - IN_HideMouse (); - } - else - { - IN_DeactivateMouse (); - IN_ShowMouse (); - stat = VID_SetWindowedMode(modenum); - } - } - else if (modelist[modenum].type == MS_FULLDIB) - { - stat = VID_SetFullDIBMode(modenum); - IN_ActivateMouse (); - IN_HideMouse (); - } - else - { - stat = VID_SetFullscreenMode(modenum); - IN_ActivateMouse (); - IN_HideMouse (); - } - - if (vid_stretched == 2){ - window_width = vid.width << 1; - window_height = vid.height; - - } - else if (vid_stretched == 3){ - window_width = vid.width; - window_height = vid.height << 1; - - } - else{ - - window_width = vid.width << vid_stretched; - window_height = vid.height << vid_stretched; - SCR_StretchInit(); - } - VID_UpdateWindowStatus (); - - CDAudio_Resume (); - scr_disabled_for_loading = temp; - - if (!stat) - { - VID_RestoreOldMode (original_mode); - return false; - } - - if (hide_window) - return true; - -// now we try to make sure we get the focus on the mode switch, because -// sometimes in some systems we don't. We grab the foreground, then -// finish setting up, pump all our messages, and sleep for a little while -// to let messages finish bouncing around the system, then we put -// ourselves at the top of the z order, then grab the foreground again, -// Who knows if it helps, but it probably doesn't hurt - if (!force_minimized) - SetForegroundWindow (mainwindow); - - hdc = GetDC(NULL); - - if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) - vid_palettized = true; - else - vid_palettized = false; - - VID_SetPalette (palette); - - ReleaseDC(NULL,hdc); - - vid_modenum = modenum; - Cvar_SetValue (vid_mode, (float)vid_modenum); - - if (!VID_AllocBuffers (vid.width, vid.height)) - { - // couldn't get memory for this mode; try to fall back to previous mode - VID_RestoreOldMode (original_mode); - return false; - } - - D_InitCaches (vid_surfcache, vid_surfcachesize); - - while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage (&msg); - DispatchMessage (&msg); - } - - Sleep (100); - - if (!force_minimized) - { - SetWindowPos (mainwindow, HWND_TOP, 0, 0, 0, 0, - SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | - SWP_NOCOPYBITS); - - SetForegroundWindow (mainwindow); - } - -// fix the leftover Alt from any Alt-Tab or the like that switched us away - ClearAllStates (); - - if (!msg_suppress_1) - Con_SafePrintf ("%s\n", VID_GetModeDescription (vid_modenum)); - - VID_SetPalette (palette); - - in_mode_set = false; - vid.recalc_refdef = 1; - - return true; -} - -void VID_LockBuffer (void) -{ - - if (dibdc) - return; - - lockcount++; - - if (lockcount > 1) - return; - - MGL_beginDirectAccess(); - - if (memdc) - { - // Update surface pointer for linear access modes - vid.buffer = vid.conbuffer = vid.direct = memdc->surface; - vid.rowbytes = vid.conrowbytes = memdc->mi.bytesPerLine; - } - else if (mgldc) - { - // Update surface pointer for linear access modes - vid.buffer = vid.conbuffer = vid.direct = mgldc->surface; - vid.rowbytes = vid.conrowbytes = mgldc->mi.bytesPerLine; - } - - if (r_docrap) - d_viewbuffer = r_lowbuffer; - else if (!r_docrap) - d_viewbuffer = (void *)(byte *)vid.buffer; - else - if (r_dowarp) - d_viewbuffer = r_warpbuffer; - else - d_viewbuffer = (void *)(byte *)vid.buffer; - - - if (r_docrap) - screenwidth = LOW_WIDTH; - else - if (r_dowarp) - screenwidth = WARP_WIDTH; - else - screenwidth = vid.rowbytes; - - if (lcd_x->value) - screenwidth <<= 1; -} - - -void VID_UnlockBuffer (void) -{ - if (dibdc) - return; - - lockcount--; - - if (lockcount > 0) - return; - - if (lockcount < 0) - Sys_Error ("Unbalanced unlock"); - - MGL_endDirectAccess(); - -// to turn up any unlocked accesses - vid.buffer = vid.conbuffer = vid.direct = d_viewbuffer = NULL; - -} - - -int VID_ForceUnlockedAndReturnState (void) -{ - int lk; - - if (!lockcount) - return 0; - - lk = lockcount; - - if (dibdc) - { - lockcount = 0; - } - else - { - lockcount = 1; - VID_UnlockBuffer (); - } - - return lk; -} - - -void VID_ForceLockState (int lk) -{ - - if (!dibdc && lk) - { - lockcount = 0; - VID_LockBuffer (); - } - - lockcount = lk; -} - - - -void VID_SetPalette (unsigned char *palette) -{ - INT i; - palette_t pal[256]; - HDC hdc; - - if (!Minimized) - { - palette_changed = true; - - // make sure we have the static colors if we're the active app - hdc = GetDC(NULL); - - if (vid_palettized && ActiveApp) - { - if (GetSystemPaletteUse(hdc) == SYSPAL_STATIC) - { - // switch to SYSPAL_NOSTATIC and remap the colors - SetSystemPaletteUse(hdc, SYSPAL_NOSTATIC); - syscolchg = true; - pal_is_nostatic = true; - } - } - - ReleaseDC(NULL,hdc); - - // Translate the palette values to an MGL palette array and - // set the values. - for (i = 0; i < 256; i++) - { - pal[i].red = palette[i*3]; - pal[i].green = palette[i*3+1]; - pal[i].blue = palette[i*3+2]; - } - - if (DDActive) - { - if (!mgldc) - return; - - MGL_setPalette(mgldc,pal,256,0); - MGL_realizePalette(mgldc,256,0,false); - if (memdc) - MGL_setPalette(memdc,pal,256,0); - } - else - { - if (!windc) - return; - - MGL_setPalette(windc,pal,256,0); - MGL_realizePalette(windc,256,0,false); - if (dibdc) - { - MGL_setPalette(dibdc,pal,256,0); - MGL_realizePalette(dibdc,256,0,false); - } - } - } - - memcpy (vid_curpal, palette, sizeof(vid_curpal)); - - if (syscolchg) - { - PostMessage (HWND_BROADCAST, WM_SYSCOLORCHANGE, (WPARAM)0, (LPARAM)0); - syscolchg = false; - } -} - - -void VID_ShiftPalette (unsigned char *palette) -{ - VID_SetPalette (palette); -} - - -/* -================= -VID_DescribeCurrentMode_f -================= -*/ -void VID_DescribeCurrentMode_f (void) -{ - Con_Printf ("%s\n", VID_GetExtModeDescription (vid_modenum)); -} - - -/* -================= -VID_NumModes_f -================= -*/ -void VID_NumModes_f (void) -{ - - if (nummodes == 1) - Con_Printf ("%d video mode is available\n", nummodes); - else - Con_Printf ("%d video modes are available\n", nummodes); -} - - -/* -================= -VID_DescribeMode_f -================= -*/ -void VID_DescribeMode_f (void) -{ - int modenum; - - modenum = Q_atoi (Cmd_Argv(1)); - - Con_Printf ("%s\n", VID_GetExtModeDescription (modenum)); -} - - -/* -================= -VID_DescribeModes_f -================= -*/ -void VID_DescribeModes_f (void) -{ - int i, lnummodes; - char *pinfo; - qboolean na; - vmode_t *pv; - - na = false; - - lnummodes = VID_NumModes (); - - for (i=0 ; iwidth, pv->height)) - { - Con_Printf ("%2d: %s\n", i, pinfo); - } - else - { - Con_Printf ("**: %s\n", pinfo); - na = true; - } - } - - if (na) - { - Con_Printf ("\n[**: not enough system RAM for mode]\n"); - } -} - - -/* -================= -VID_TestMode_f -================= -*/ -void VID_TestMode_f (void) -{ - int modenum; - double testduration; - - if (!vid_testingmode) - { - modenum = Q_atoi (Cmd_Argv(1)); - - if (VID_SetMode (modenum, vid_curpal)) - { - vid_testingmode = 1; - testduration = Q_atof (Cmd_Argv(2)); - if (testduration == 0) - testduration = 5.0; - vid_testendtime = realtime + testduration; - } - } -} - - -/* -================= -VID_Windowed_f -================= -*/ -void VID_Windowed_f (void) -{ - - VID_SetMode ((int)vid_windowed_mode->value, vid_curpal); -} - - -/* -================= -VID_Fullscreen_f -================= -*/ -void VID_Fullscreen_f (void) -{ - - VID_SetMode ((int)vid_fullscreen_mode->value, vid_curpal); -} - - -/* -================= -VID_Minimize_f -================= -*/ -void VID_Minimize_f (void) -{ - -// we only support minimizing windows; if you're fullscreen, -// switch to windowed first - if (modestate == MS_WINDOWED) - ShowWindow (mainwindow, SW_MINIMIZE); -} - - - -/* -================= -VID_ForceMode_f -================= -*/ -void VID_ForceMode_f (void) -{ - int modenum; - double testduration; - - if (!vid_testingmode) - { - modenum = Q_atoi (Cmd_Argv(1)); - - force_mode_set = 1; - VID_SetMode (modenum, vid_curpal); - force_mode_set = 0; - } -} - -// 2001-09-18 New cvar system by Maddes (Init) start -void VID_Init_Cvars (void) -{ - vid_mode = Cvar_Get ("vid_mode", "0", CVAR_ORIGINAL); - vid_wait = Cvar_Get ("vid_wait", "0", CVAR_ORIGINAL); - vid_nopageflip = Cvar_Get ("vid_nopageflip", "0", CVAR_ARCHIVE|CVAR_ORIGINAL); - _vid_wait_override = Cvar_Get ("_vid_wait_override", "0", CVAR_ARCHIVE|CVAR_ORIGINAL); - _vid_default_mode = Cvar_Get ("_vid_default_mode", "0", CVAR_ARCHIVE|CVAR_ORIGINAL); - _vid_default_mode_win = Cvar_Get ("_vid_default_mode_win", "3", CVAR_ARCHIVE|CVAR_ORIGINAL); - vid_config_x = Cvar_Get ("vid_config_x", "800", CVAR_ARCHIVE|CVAR_ORIGINAL); - vid_config_y = Cvar_Get ("vid_config_y", "600", CVAR_ARCHIVE|CVAR_ORIGINAL); - vid_stretch_by_2 = Cvar_Get ("vid_stretch_by_2", "1", CVAR_ARCHIVE|CVAR_ORIGINAL); - _windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE|CVAR_ORIGINAL); - vid_fullscreen_mode = Cvar_Get ("vid_fullscreen_mode", "3", CVAR_ARCHIVE|CVAR_ORIGINAL); - vid_windowed_mode = Cvar_Get ("vid_windowed_mode", "0", CVAR_ARCHIVE|CVAR_ORIGINAL); - block_switch = Cvar_Get ("block_switch", "0", CVAR_ARCHIVE|CVAR_ORIGINAL); - vid_window_x = Cvar_Get ("vid_window_x", "0", CVAR_ARCHIVE|CVAR_ORIGINAL); - vid_window_y = Cvar_Get ("vid_window_y", "0", CVAR_ARCHIVE|CVAR_ORIGINAL); -} -// 2001-09-18 New cvar system by Maddes (Init) end - - -void VID_Init (unsigned char *palette) -{ - int i, bestmatch, bestmatchmetric, t, dr, dg, db; - int basenummodes; - byte *ptmp; - - Cmd_AddCommand ("vid_testmode", VID_TestMode_f); - Cmd_AddCommand ("vid_nummodes", VID_NumModes_f); - Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f); - Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f); - Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f); - Cmd_AddCommand ("vid_forcemode", VID_ForceMode_f); - Cmd_AddCommand ("vid_windowed", VID_Windowed_f); - Cmd_AddCommand ("vid_fullscreen", VID_Fullscreen_f); - Cmd_AddCommand ("vid_minimize", VID_Minimize_f); - - if (COM_CheckParm ("-dibonly")) // leilei says FORCE DIBONLY BECAUSE MGL IS CRAAAAAP - dibonly = true; - - if (WinNT) - dibonly = true; // nt suks - if (COM_CheckParm("-directdraw") || COM_CheckParm("-ddraw") || COM_CheckParm("-dd")) - dibonly = false; - - VID_InitMGLDIB (global_hInstance); - - basenummodes = nummodes; -#ifndef NOFULLSCREENEVER - if (!dibonly) - VID_InitMGLFull (global_hInstance); - -// if there are no non-windowed modes, or only windowed and mode 0x13, then use -// fullscreen DIBs as well - if (((nummodes == basenummodes) || - ((nummodes == (basenummodes + 1)) && is_mode0x13)) && - !COM_CheckParm ("-nofulldib")) - - { - VID_InitFullDIB (global_hInstance); - } -#endif - vid.maxwarpwidth = WARP_WIDTH; - vid.maxwarpheight = WARP_HEIGHT; - - vid.maxlowwidth = LOW_WIDTH; - vid.maxlowheight = LOW_HEIGHT; - vid.colormap = host_colormap; - vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048)); - vid_testingmode = 0; - SCR_StretchInit(); -// GDI doesn't let us remap palette index 0, so we'll remap color -// mappings from that black to another one - bestmatchmetric = 256*256*3; - - for (i=1 ; i<256 ; i++) - { - dr = palette[0] - palette[i*3]; - dg = palette[1] - palette[i*3+1]; - db = palette[2] - palette[i*3+2]; - - t = (dr * dr) + (dg * dg) + (db * db); - - if (t < bestmatchmetric) - { - bestmatchmetric = t; - bestmatch = i; - - if (t == 0) - break; - } - } - - for (i=0, ptmp = vid.colormap ; i<(1<<(VID_CBITS+8)) ; i++, ptmp++) - { - if (*ptmp == 0) - *ptmp = bestmatch; - } - - if (COM_CheckParm("-startwindowed")) - { - startwindowed = 1; - vid_default = windowed_default; - } -#ifndef NOFULLSCREENEVER - startwindowed = 1; - vid_default = windowed_default; -#endif - if (hwnd_dialog) - DestroyWindow (hwnd_dialog); - -// sound initialization has to go here, preceded by a windowed mode set, -// so there's a window for DirectSound to work with but we're not yet -// fullscreen so the "hardware already in use" dialog is visible if it -// gets displayed - -// keep the window minimized until we're ready for the first real mode set - hide_window = true; - VID_SetMode (MODE_WINDOWED, palette); - hide_window = false; - S_Init (); - - vid_initialized = true; - - force_mode_set = true; - VID_SetMode (vid_default, palette); - force_mode_set = false; - - vid_realmode = vid_modenum; - - VID_SetPalette (palette); - - vid_menudrawfn = VID_MenuDraw; - vid_menukeyfn = VID_MenuKey; - - strcpy (badmode.modedesc, "Bad mode"); -} - - -void VID_Shutdown (void) -{ - HDC hdc; - int dummy; - - if (vid_initialized) - { - if (modestate == MS_FULLDIB) - ChangeDisplaySettings (NULL, CDS_FULLSCREEN); - - PostMessage (HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)mainwindow, (LPARAM)0); - PostMessage (HWND_BROADCAST, WM_SYSCOLORCHANGE, (WPARAM)0, (LPARAM)0); - - AppActivate(false, false); - DestroyDIBWindow (); - DestroyFullscreenWindow (); - DestroyFullDIBWindow (); - - if (hwnd_dialog) - DestroyWindow (hwnd_dialog); - - if (mainwindow) - DestroyWindow(mainwindow); - - MGL_exit(); - - vid_testingmode = 0; - vid_initialized = 0; - } -} - - -/* -================ -FlipScreen -================ -*/ -void FlipScreen(vrect_t *rects) -{ - HRESULT ddrval; - - // Flip the surfaces - - if (DDActive) - { - if (mgldc) - { - if (memdc) - { - while (rects) - { - if (vid_stretched == 2) - { - MGL_stretchBltCoord(mgldc, memdc, - rects->x, - rects->y, - rects->x + rects->width, - rects->y + rects->height, - rects->x << 1, - rects->y << 1, - (rects->x + rects->width) << 1, - (rects->y + rects->height)); - } - else if (vid_stretched == 3) - { - MGL_stretchBltCoord(mgldc, memdc, - rects->x, - rects->y, - rects->x + rects->width, - rects->y + rects->height, - rects->x << 1, - rects->y << 1, - (rects->x + rects->width), - (rects->y + rects->height) << 1); - } - else if (vid_stretched) - { - MGL_stretchBltCoord(mgldc, memdc, - rects->x, - rects->y, - rects->x + rects->width, - rects->y + rects->height, - rects->x << 1, - rects->y << 1, - (rects->x + rects->width) << 1, - (rects->y + rects->height) << 1); - } - else - { - MGL_bitBltCoord(mgldc, memdc, - rects->x, rects->y, - (rects->x + rects->width), - (rects->y + rects->height), - rects->x, rects->y, MGL_REPLACE_MODE); - } - - rects = rects->pnext; - } - } - - if (vid.numpages > 1) - { - // We have a flipping surface, so do a hard page flip - aPage = (aPage+1) % vid.numpages; - vPage = (vPage+1) % vid.numpages; - MGL_setActivePage(mgldc,aPage); - MGL_setVisualPage(mgldc,vPage,waitVRT); - } - } - } - else - { - HDC hdcScreen; - - hdcScreen = GetDC(mainwindow); - - if (windc && dibdc) - { - MGL_setWinDC(windc,hdcScreen); - - while (rects) - { - if (vid_stretched == 2) - { - MGL_stretchBltCoord(windc,dibdc, - rects->x, rects->y, - rects->x + rects->width, rects->y + rects->height, - rects->x << 1, rects->y << 1, - (rects->x + rects->width) << 1, - (rects->y + rects->height)); - - } - else if (vid_stretched == 3) - { - MGL_stretchBltCoord(windc,dibdc, - rects->x, rects->y, - rects->x + rects->width, rects->y + rects->height, - rects->x << 1, rects->y << 1, - (rects->x + rects->width), - (rects->y + rects->height) << 1); - - - } - else if (vid_stretched) - { - MGL_stretchBltCoord(windc,dibdc, - rects->x, rects->y, - rects->x + rects->width, rects->y + rects->height, - rects->x << 1, rects->y << 1, - (rects->x + rects->width) << 1, - (rects->y + rects->height) << 1); - } - else - { - MGL_bitBltCoord(windc,dibdc, - rects->x, rects->y, - rects->x + rects->width, rects->y + rects->height, - rects->x, rects->y, MGL_REPLACE_MODE); - } - - rects = rects->pnext; - } - } - - ReleaseDC(mainwindow, hdcScreen); - } -} - - -void VID_Update (vrect_t *rects) -{ - vrect_t rect; - RECT trect; - - if (!vid_palettized && palette_changed) - { - palette_changed = false; - rect.x = 0; - rect.y = 0; - rect.width = vid.width; - rect.height = vid.height; - rect.pnext = NULL; - rects = ▭ - } - - if (firstupdate) - { - if (modestate == MS_WINDOWED) - { - GetWindowRect (mainwindow, &trect); - - if ((trect.left != (int)vid_window_x->value) || - (trect.top != (int)vid_window_y->value)) - { - if (COM_CheckParm ("-resetwinpos")) - { - Cvar_Set (vid_window_x, "0"); - Cvar_Set (vid_window_y, "0"); - } - - VID_CheckWindowXY (); - SetWindowPos (mainwindow, NULL, (int)vid_window_x->value, - (int)vid_window_y->value, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME); - } - } - - if ((_vid_default_mode_win->value != vid_default) && - (!startwindowed || (_vid_default_mode_win->value < MODE_FULLSCREEN_DEFAULT))) - { - firstupdate = 0; - - if (COM_CheckParm ("-resetwinpos")) - { - Cvar_Set (vid_window_x, "0"); - Cvar_Set (vid_window_y, "0"); - } - - if ((_vid_default_mode_win->value < 0) || - (_vid_default_mode_win->value >= nummodes)) - { - Cvar_SetValue (_vid_default_mode_win, windowed_default); - } - - Cvar_SetValue (vid_mode, _vid_default_mode_win->value); - } - } - - // We've drawn the frame; copy it to the screen - FlipScreen (rects); - - if (vid_testingmode) - { - if (realtime >= vid_testendtime) - { - VID_SetMode (vid_realmode, vid_curpal); - vid_testingmode = 0; - } - } - else - { - if ((int)vid_mode->value != vid_realmode) - { - VID_SetMode ((int)vid_mode->value, vid_curpal); - Cvar_SetValue (vid_mode, (float)vid_modenum); - // so if mode set fails, we don't keep on - // trying to set that mode - vid_realmode = vid_modenum; - } - } - -// handle the mouse state when windowed if that's changed - if (modestate == MS_WINDOWED) - { - if ((int)_windowed_mouse->value != windowed_mouse) - { - if (_windowed_mouse->value) - { - IN_ActivateMouse (); - IN_HideMouse (); - } - else - { - IN_DeactivateMouse (); - IN_ShowMouse (); - } - - windowed_mouse = (int)_windowed_mouse->value; - } - } -} - - -/* -================ -D_BeginDirectRect -================ -*/ -void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height) -{ - int i, j, reps, repshift; - vrect_t rect; - - if (!vid_initialized) - return; - - if (vid.aspect > 1.5) - { - reps = 2; - repshift = 1; - } - else - { - reps = 1; - repshift = 0; - } - - if (vid.numpages == 1) - { - VID_LockBuffer (); - - if (!vid.direct) - Sys_Error ("NULL vid.direct pointer"); - - for (i=0 ; i<(height << repshift) ; i += reps) - { - for (j=0 ; j> repshift) * width], - width); - } - } - - VID_UnlockBuffer (); - - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height << repshift; - rect.pnext = NULL; - - FlipScreen (&rect); - } - else - { - // unlock if locked - if (lockcount > 0) - MGL_endDirectAccess(); - - // set the active page to the displayed page - MGL_setActivePage (mgldc, vPage); - - // lock the screen - MGL_beginDirectAccess (); - - // save from and draw to screen - for (i=0 ; i<(height << repshift) ; i += reps) - { - for (j=0 ; jsurface + x + - ((y << repshift) + i + j) * mgldc->mi.bytesPerLine, - width); - memcpy ((byte *)mgldc->surface + x + - ((y << repshift) + i + j) * mgldc->mi.bytesPerLine, - &pbitmap[(i >> repshift) * width], - width); - } - } - - // unlock the screen - MGL_endDirectAccess (); - - // restore the original active page - MGL_setActivePage (mgldc, aPage); - - // relock the screen if it was locked - if (lockcount > 0) - MGL_beginDirectAccess(); - } -} - - -/* -================ -D_EndDirectRect -================ -*/ -void D_EndDirectRect (int x, int y, int width, int height) -{ - int i, j, reps, repshift; - vrect_t rect; - - if (!vid_initialized) - return; - - if (vid.aspect > 1.5) - { - reps = 2; - repshift = 1; - } - else - { - reps = 1; - repshift = 0; - } - - if (vid.numpages == 1) - { - VID_LockBuffer (); - - if (!vid.direct) - Sys_Error ("NULL vid.direct pointer"); - - for (i=0 ; i<(height << repshift) ; i += reps) - { - for (j=0 ; j 0) - MGL_endDirectAccess(); - - // set the active page to the displayed page - MGL_setActivePage (mgldc, vPage); - - // lock the screen - MGL_beginDirectAccess (); - - // restore to the screen - for (i=0 ; i<(height << repshift) ; i += reps) - { - for (j=0 ; jsurface + x + - ((y << repshift) + i + j) * mgldc->mi.bytesPerLine, - &backingbuf[(i + j) * 24], - width); - } - } - - // unlock the screen - MGL_endDirectAccess (); - - // restore the original active page - MGL_setActivePage (mgldc, aPage); - - // relock the screen if it was locked - if (lockcount > 0) - MGL_beginDirectAccess(); - } -} - - -//========================================================================== - -byte scantokey[128] = -{ -// 0 1 2 3 4 5 6 7 -// 8 9 A B C D E F - 0 , 27, '1', '2', '3', '4', '5', '6', - '7', '8', '9', '0', '-', '=', K_BACKSPACE, 9, // 0 - 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', - 'o', 'p', '[', ']', 13 , K_CTRL,'a', 's', // 1 - 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', - '\'' , '`', K_SHIFT,'\\', 'z', 'x', 'c', 'v', // 2 - 'b', 'n', 'm', ',', '.', '/', K_SHIFT,'*', - K_ALT,' ', 0 , K_F1, K_F2, K_F3, K_F4, K_F5, // 3 - K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE, 0 , K_HOME, - K_UPARROW,K_PGUP,'-',K_LEFTARROW,'5',K_RIGHTARROW,'+',K_END, //4 - K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0, 0, K_F11, - K_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5 - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6 - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7 -}; - -/* -======= -MapKey - -Map from windows to quake keynums -======= -*/ -int MapKey (int key) -{ - key = (key>>16)&255; - if (key > 127) - return 0; - - return scantokey[key]; -} - -void AppActivate(BOOL fActive, BOOL minimize) -/**************************************************************************** -* -* Function: AppActivate -* Parameters: fActive - True if app is activating -* -* Description: If the application is activating, then swap the system -* into SYSPAL_NOSTATIC mode so that our palettes will display -* correctly. -* -****************************************************************************/ -{ - HDC hdc; - int i, t; - static BOOL sound_active; - - ActiveApp = fActive; - -// messy, but it seems to work - if (vid_fulldib_on_focus_mode) - { - Minimized = minimize; - - if (Minimized) - ActiveApp = false; - } - - MGL_appActivate(windc, ActiveApp); - - if (vid_initialized) - { - // yield the palette if we're losing the focus - hdc = GetDC(NULL); - - if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) - { - if (ActiveApp) - { - if ((modestate == MS_WINDOWED) || (modestate == MS_FULLDIB)) - { - if (GetSystemPaletteUse(hdc) == SYSPAL_STATIC) - { - // switch to SYSPAL_NOSTATIC and remap the colors - SetSystemPaletteUse(hdc, SYSPAL_NOSTATIC); - syscolchg = true; - pal_is_nostatic = true; - } - } - } - else if (pal_is_nostatic) - { - if (GetSystemPaletteUse(hdc) == SYSPAL_NOSTATIC) - { - // switch back to SYSPAL_STATIC and the old mapping - SetSystemPaletteUse(hdc, SYSPAL_STATIC); - syscolchg = true; - } - - pal_is_nostatic = false; - } - } - - if (!Minimized) - VID_SetPalette (vid_curpal); - - scr_fullupdate = 0; - - ReleaseDC(NULL,hdc); - } - -// enable/disable sound on focus gain/loss - if (!ActiveApp && sound_active) - { - S_BlockSound (); - S_ClearBuffer (); - sound_active = false; - } - else if (ActiveApp && !sound_active) - { - S_UnblockSound (); - S_ClearBuffer (); - sound_active = true; - } - -// minimize/restore fulldib windows/mouse-capture normal windows on demand - if (!in_mode_set) - { - if (ActiveApp) - { - if (vid_fulldib_on_focus_mode) - { - if (vid_initialized) - { - msg_suppress_1 = true; // don't want to see normal mode set message - VID_SetMode (vid_fulldib_on_focus_mode, vid_curpal); - msg_suppress_1 = false; - - t = in_mode_set; - in_mode_set = true; - AppActivate (true, false); - in_mode_set = t; - } - - IN_ActivateMouse (); - IN_HideMouse (); - } - else if ((modestate == MS_WINDOWED) && _windowed_mouse->value) - { - IN_ActivateMouse (); - IN_HideMouse (); - } - } - - if (!ActiveApp) - { - if (modestate == MS_FULLDIB) - { - if (vid_initialized) - { - force_minimized = true; - i = vid_fulldib_on_focus_mode; - msg_suppress_1 = true; // don't want to see normal mode set message - VID_SetMode (windowed_default, vid_curpal); - msg_suppress_1 = false; - vid_fulldib_on_focus_mode = i; - force_minimized = false; - - // we never seem to get WM_ACTIVATE inactive from this mode set, so we'll - // do it manually - t = in_mode_set; - in_mode_set = true; - AppActivate (false, true); - in_mode_set = t; - } - - IN_DeactivateMouse (); - IN_ShowMouse (); - } - else if ((modestate == MS_WINDOWED) && _windowed_mouse->value) - { - IN_DeactivateMouse (); - IN_ShowMouse (); - } - } - } -} - - -/* -================ -VID_HandlePause -================ -*/ -void VID_HandlePause (qboolean pause) -{ - - if ((modestate == MS_WINDOWED) && _windowed_mouse->value) - { - if (pause) - { - IN_DeactivateMouse (); - IN_ShowMouse (); - } - else - { - IN_ActivateMouse (); - IN_HideMouse (); - } - } -} - - -/* -=================================================================== - -MAIN WINDOW - -=================================================================== -*/ - -//LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); // 2001-12-10 Reduced compiler warnings by Jeff Ford - -/* main window procedure */ -LONG WINAPI MainWndProc ( - HWND hWnd, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - LONG lRet = 0; - int fwKeys, xPos, yPos, fActive, fMinimized, temp; - HDC hdc; - PAINTSTRUCT ps; -// static int recursiveflag; // 2001-12-10 Reduced compiler warnings by Jeff Ford - - switch (uMsg) - { - case WM_CREATE: - break; - - case WM_SYSCOMMAND: - - // Check for maximize being hit - switch (wParam & ~0x0F) - { - case SC_MAXIMIZE: - // if minimized, bring up as a window before going fullscreen, - // so MGL will have the right state to restore - if (Minimized) - { - force_mode_set = true; - VID_SetMode (vid_modenum, vid_curpal); - force_mode_set = false; - } - - VID_SetMode ((int)vid_fullscreen_mode->value, vid_curpal); - break; - - case SC_SCREENSAVE: - case SC_MONITORPOWER: - if (modestate != MS_WINDOWED) - { - // don't call DefWindowProc() because we don't want to start - // the screen saver fullscreen - break; - } - - // fall through windowed and allow the screen saver to start - - default: - if (!in_mode_set) - { - S_BlockSound (); - S_ClearBuffer (); - } - - lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); - - if (!in_mode_set) - { - S_UnblockSound (); - } - } - break; - - case WM_MOVE: - window_x = (int) LOWORD(lParam); - window_y = (int) HIWORD(lParam); - VID_UpdateWindowStatus (); - - if ((modestate == MS_WINDOWED) && !in_mode_set && !Minimized) - VID_RememberWindowPos (); - - break; - - case WM_SIZE: - Minimized = false; - - if (!(wParam & SIZE_RESTORED)) - { - if (wParam & SIZE_MINIMIZED) - Minimized = true; - } - break; - - case WM_SYSCHAR: - // keep Alt-Space from happening - break; - - case WM_ACTIVATE: - fActive = LOWORD(wParam); - fMinimized = (BOOL) HIWORD(wParam); - AppActivate(!(fActive == WA_INACTIVE), fMinimized); - - // fix the leftover Alt from any Alt-Tab or the like that switched us away - ClearAllStates (); - - if (!in_mode_set) - { - if (windc) - MGL_activatePalette(windc,true); - - VID_SetPalette(vid_curpal); - } - - break; - - case WM_PAINT: - hdc = BeginPaint(hWnd, &ps); - - if (!in_mode_set && host_initialized) - SCR_UpdateWholeScreen (); - - EndPaint(hWnd, &ps); - break; - - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - if (!in_mode_set) - Key_Event (MapKey(lParam), true); - break; - - case WM_KEYUP: - case WM_SYSKEYUP: - if (!in_mode_set) - Key_Event (MapKey(lParam), false); - break; - - // this is complicated because Win32 seems to pack multiple mouse events into - // one update sometimes, so we always check all states and look for events - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_RBUTTONDOWN: - case WM_RBUTTONUP: - case WM_MBUTTONDOWN: - case WM_MBUTTONUP: - case WM_MOUSEMOVE: - if (!in_mode_set) - { - temp = 0; - - if (wParam & MK_LBUTTON) - temp |= 1; - - if (wParam & MK_RBUTTON) - temp |= 2; - - if (wParam & MK_MBUTTON) - temp |= 4; - - IN_MouseEvent (temp); - } - break; - - // JACK: This is the mouse wheel with the Intellimouse - // Its delta is either positive or neg, and we generate the proper - // Event. - case WM_MOUSEWHEEL: - if ((short) HIWORD(wParam) > 0) { - Key_Event(K_MWHEELUP, true); - Key_Event(K_MWHEELUP, false); - } else { - Key_Event(K_MWHEELDOWN, true); - Key_Event(K_MWHEELDOWN, false); - } - break; - // KJB: Added these new palette functions - case WM_PALETTECHANGED: - if ((HWND)wParam == hWnd) - break; - /* Fall through to WM_QUERYNEWPALETTE */ - case WM_QUERYNEWPALETTE: - hdc = GetDC(NULL); - - if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) - vid_palettized = true; - else - vid_palettized = false; - - ReleaseDC(NULL,hdc); - - scr_fullupdate = 0; - - if (vid_initialized && !in_mode_set && windc && MGL_activatePalette(windc,false) && !Minimized) - { - VID_SetPalette (vid_curpal); - InvalidateRect (mainwindow, NULL, false); - - // specifically required if WM_QUERYNEWPALETTE realizes a new palette - lRet = TRUE; - } - break; - - case WM_DISPLAYCHANGE: - if (!in_mode_set && (modestate == MS_WINDOWED) && !vid_fulldib_on_focus_mode) - { - force_mode_set = true; - VID_SetMode (vid_modenum, vid_curpal); - force_mode_set = false; - } - break; - - case WM_CLOSE: - // this causes Close in the right-click task bar menu not to work, but right - // now bad things happen if Close is handled in that case (garbage and a - // crash on Win95) - if (!in_mode_set) - { - if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit", - MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES) - { - Sys_Quit (); - } - } - break; - - case MM_MCINOTIFY: - lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam); - break; - - default: - /* pass all unhandled messages to DefWindowProc */ - lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); - break; - } - - /* return 0 if handled message, 1 if not */ - return lRet; -} - - -extern void M_Menu_Options_f (void); -extern void M_Print (int cx, int cy, char *str); -extern void M_PrintWhite (int cx, int cy, char *str); -extern void M_DrawCharacter (int cx, int line, int num); -extern void M_DrawTransPic (int x, int y, qpic_t *pic); -extern void M_DrawPic (int x, int y, qpic_t *pic); - -static int vid_line, vid_wmodes; - -typedef struct -{ - int modenum; - char *desc; - int iscur; - int ismode13; - int width; -} modedesc_t; - -#define MAX_COLUMN_SIZE 5 -#define MODE_AREA_HEIGHT (MAX_COLUMN_SIZE + 6) -#define MAX_MODEDESCS (MAX_COLUMN_SIZE*3) - -static modedesc_t modedescs[MAX_MODEDESCS]; - -/* -================ -VID_MenuDraw -================ -*/ -void VID_MenuDraw (void) -{ - qpic_t *p; - char *ptr; - int lnummodes, i, j, k, column, row, dup, dupmode; - char temp[100]; - vmode_t *pv; - modedesc_t tmodedesc; - - p = Draw_CachePic ("gfx/vidmodes.lmp"); - M_DrawPic ( (320-p->width)/2, 4, p); - - for (i=0 ; i<3 ; i++) - { - ptr = VID_GetModeDescriptionMemCheck (i); - modedescs[i].modenum = modelist[i].modenum; - modedescs[i].desc = ptr; - modedescs[i].ismode13 = 0; - modedescs[i].iscur = 0; - - if (vid_modenum == i) - modedescs[i].iscur = 1; - } - - vid_wmodes = 3; - lnummodes = VID_NumModes (); - - for (i=3 ; iwidth != 360) || COM_CheckParm("-allow360"))) - { - dup = 0; - - for (j=3 ; jmode13; - modedescs[k].iscur = 0; - modedescs[k].width = pv->width; - - if (i == vid_modenum) - modedescs[k].iscur = 1; - - if (!dup) - vid_wmodes++; - } - } - } - } - -// sort the modes on width (to handle picking up oddball dibonly modes -// after all the others) - for (i=3 ; i<(vid_wmodes-1) ; i++) - { - for (j=(i+1) ; j modedescs[j].width) - { - tmodedesc = modedescs[i]; - modedescs[i] = modedescs[j]; - modedescs[j] = tmodedesc; - } - } - } - - - M_Print (13*8, 36, "Windowed Modes"); - - column = 16; - row = 36+2*8; - - for (i=0 ; i<3; i++) - { - if (modedescs[i].iscur) - M_PrintWhite (column, row, modedescs[i].desc); - else - M_Print (column, row, modedescs[i].desc); - - column += 13*8; - } - - if (vid_wmodes > 3) - { - M_Print (12*8, 36+4*8, "Fullscreen Modes"); - - column = 16; - row = 36+6*8; - - for (i=3 ; ivalue); - - if (ptr) - { - sprintf (temp, "Current default: %s", ptr); - M_Print (3*8, 36 + MODE_AREA_HEIGHT * 8 + 8*6, temp); - } - - M_Print (15*8, 36 + MODE_AREA_HEIGHT * 8 + 8*8, - "Esc to exit"); - - row = 36 + 2*8 + (vid_line / VID_ROW_SIZE) * 8; - column = 8 + (vid_line % VID_ROW_SIZE) * 13*8; - - if (vid_line >= 3) - row += 3*8; - - M_DrawCharacter (column, row, 12+((int)(realtime*4)&1)); - } -} - - -/* -================ -VID_MenuKey -================ -*/ -void VID_MenuKey (int key) -{ - if (vid_testingmode) - return; - - switch (key) - { - case K_ESCAPE: - S_LocalSound ("misc/menu1.wav"); - M_Menu_Options_f (); - break; - - case K_LEFTARROW: - S_LocalSound ("misc/menu1.wav"); - vid_line = ((vid_line / VID_ROW_SIZE) * VID_ROW_SIZE) + - ((vid_line + 2) % VID_ROW_SIZE); - - if (vid_line >= vid_wmodes) - vid_line = vid_wmodes - 1; - break; - - case K_RIGHTARROW: - S_LocalSound ("misc/menu1.wav"); - vid_line = ((vid_line / VID_ROW_SIZE) * VID_ROW_SIZE) + - ((vid_line + 4) % VID_ROW_SIZE); - - if (vid_line >= vid_wmodes) - vid_line = (vid_line / VID_ROW_SIZE) * VID_ROW_SIZE; - break; - - case K_UPARROW: - S_LocalSound ("misc/menu1.wav"); - vid_line -= VID_ROW_SIZE; - - if (vid_line < 0) - { - vid_line += ((vid_wmodes + (VID_ROW_SIZE - 1)) / - VID_ROW_SIZE) * VID_ROW_SIZE; - - while (vid_line >= vid_wmodes) - vid_line -= VID_ROW_SIZE; - } - break; - - case K_DOWNARROW: - S_LocalSound ("misc/menu1.wav"); - vid_line += VID_ROW_SIZE; - - if (vid_line >= vid_wmodes) - { - vid_line -= ((vid_wmodes + (VID_ROW_SIZE - 1)) / - VID_ROW_SIZE) * VID_ROW_SIZE; - - while (vid_line < 0) - vid_line += VID_ROW_SIZE; - } - break; - - case K_ENTER: - S_LocalSound ("misc/menu1.wav"); - VID_SetMode (modedescs[vid_line].modenum, vid_curpal); - break; - - case 'T': - case 't': - S_LocalSound ("misc/menu1.wav"); - // have to set this before setting the mode because WM_PAINT - // happens during the mode set and does a VID_Update, which - // checks vid_testingmode - vid_testingmode = 1; - vid_testendtime = realtime + 5.0; - - if (!VID_SetMode (modedescs[vid_line].modenum, vid_curpal)) - { - vid_testingmode = 0; - } - break; - - case 'D': - case 'd': - S_LocalSound ("misc/menu1.wav"); - firstupdate = 0; - Cvar_SetValue (_vid_default_mode_win, vid_modenum); - break; - - default: - break; - } -}