├── config.default
├── wl_play.cpp
├── macosx
├── wolf4sdl.icns
├── English.lproj
│ └── InfoPlist.strings
├── Chocolate Wolfenstein 3D.xcodeproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ ├── Wolf4SDL.xccheckout
│ │ └── Chocolate Wolfenstein 3D.xccheckout
├── SDLMain.h
├── Info.plist
└── SDLMain.m
├── screenshots
├── crt_aspect.png
└── crt_framebuffer.png
├── .gitignore
├── crt.h
├── win32
└── vs2008
│ ├── choco_wold3d.sln
│ └── choco_wold3s
│ └── choco_wold3s.vcproj
├── README.md
├── id_pm.h
├── id_ca.h
├── version.h
├── docs
├── license-mame.txt
├── license-id.txt
├── Changes.Wolf4SDL.txt
└── README.Wolf4SDL.txt
├── Makefile.mingw
├── Makefile
├── f_spear.h
├── id_vh.h
├── id_us.h
├── fmopl.h
├── id_pm.cpp
├── id_sd.h
├── id_vl.h
├── sodpal.inc
├── wolfpal.inc
├── crt.cpp
├── audiosod.h
├── audiowl6.h
├── foreign.h
├── wl_menu.h
├── id_in.h
├── gfxv_wl6.h
├── gfxv_apo.h
├── gfxv_sod.h
├── id_vh.cpp
├── id_in.cpp
└── id_vl.cpp
/config.default:
--------------------------------------------------------------------------------
1 | CFLAGS += -O2
2 |
--------------------------------------------------------------------------------
/wl_play.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marsmining/Chocolate-Wolfenstein-3D/master/wl_play.cpp
--------------------------------------------------------------------------------
/macosx/wolf4sdl.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marsmining/Chocolate-Wolfenstein-3D/master/macosx/wolf4sdl.icns
--------------------------------------------------------------------------------
/screenshots/crt_aspect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marsmining/Chocolate-Wolfenstein-3D/master/screenshots/crt_aspect.png
--------------------------------------------------------------------------------
/screenshots/crt_framebuffer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marsmining/Chocolate-Wolfenstein-3D/master/screenshots/crt_framebuffer.png
--------------------------------------------------------------------------------
/macosx/English.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marsmining/Chocolate-Wolfenstein-3D/master/macosx/English.lproj/InfoPlist.strings
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | */DerivedData/*
2 | .DS_Store
3 | xcuserdata
4 |
5 | #visual studio files
6 | *.sdf
7 | *.suo
8 | *.vcxproj.user
9 | Debug
10 | Release
11 | Backup
12 |
--------------------------------------------------------------------------------
/macosx/Chocolate Wolfenstein 3D.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/macosx/SDLMain.h:
--------------------------------------------------------------------------------
1 | /* SDLMain.m - main entry point for our Cocoa-ized SDL app
2 | Initial Version: Darrell Walisser
3 | Non-NIB-Code & other changes: Max Horn
4 |
5 | Feel free to customize this file to suit your needs
6 | */
7 |
8 | #ifndef _SDLMain_h_
9 | #define _SDLMain_h_
10 |
11 | #import
12 |
13 | @interface SDLMain : NSObject
14 | @end
15 |
16 | #endif /* _SDLMain_h_ */
17 |
--------------------------------------------------------------------------------
/crt.h:
--------------------------------------------------------------------------------
1 | //
2 | // crt.h
3 | // Chocolate Wolfenstein 3D
4 | //
5 | // Created by fabien sanglard on 2014-08-26.
6 | //
7 | //
8 |
9 | #ifndef Chocolate_Wolfenstein_3D_crt_h
10 | #define Chocolate_Wolfenstein_3D_crt_h
11 |
12 |
13 | // Win32
14 | #ifdef _WIN32
15 | #include
16 | #include
17 | #include "SDL.h"
18 | #elif __linux__
19 | #include
20 | #include "SDL/SDL.h"
21 | #else
22 | #include
23 | #include "SDL/SDL.h"
24 | #endif
25 |
26 | extern SDL_Color curpal[256];
27 | /*
28 | * CRT aspect ratio is 4:3, height will be infered.
29 | */
30 | void CRT_Init(int width);
31 |
32 | /*
33 | * Trigger the Digital To Analogic convertion
34 | */
35 | void CRT_DAC(void);
36 |
37 | void CRT_Screenshot(void);
38 |
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/win32/vs2008/choco_wold3d.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "choco_wold3s", "choco_wold3s\choco_wold3s.vcproj", "{C895AC6E-7364-4865-9609-7BE6CABD7841}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {C895AC6E-7364-4865-9609-7BE6CABD7841}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {C895AC6E-7364-4865-9609-7BE6CABD7841}.Debug|Win32.Build.0 = Debug|Win32
14 | {C895AC6E-7364-4865-9609-7BE6CABD7841}.Release|Win32.ActiveCfg = Release|Win32
15 | {C895AC6E-7364-4865-9609-7BE6CABD7841}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Chocolate-Wolfenstein-3D
2 | ========================
3 |
4 | Based on Wolf4SDL by Moritz "Ripper" Kroll (http://www.chaos-software.de.vu).
5 |
6 | Original Wolfenstein 3D by id Software (http://www.idsoftware.com)
7 |
8 | Chocolate Wolf3D removes all the crap that was added over the years
9 | (snow, rain ...) in order to recreate the experience from 1993.
10 |
11 | All other port display the framebuffer as 320x200 without accounting for the CRT 4:3
12 | distortion. Chocolate Wolfenstien 3D has a CRT emulator based on OpenGL:
13 |
14 | Direct framebuffer to window (resulting in compressed image):
15 |
16 | 
17 |
18 | CRT 4:3 aspect ratio emulated to match what gamer saw on their screen in 1993. Image is streched to 320x240 just
19 | like the CRT did :
20 |
21 | 
22 |
23 | Tested on Windows, Linux and Mac OS X
24 |
25 | Fabien Sanglard
26 |
--------------------------------------------------------------------------------
/macosx/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleDocumentTypes
8 |
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIconFile
12 | wolf4sdl.icns
13 | CFBundleIdentifier
14 | com.chrisballinger.wolf4sdl
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | ${PRODUCT_NAME}
19 | CFBundlePackageType
20 | APPL
21 | CFBundleSignature
22 | ????
23 | CFBundleURLTypes
24 |
25 | CFBundleVersion
26 | 1.7
27 | NSMainNibFile
28 | SDLMain
29 | NSPrincipalClass
30 | NSApplication
31 | NSServices
32 |
33 | UTExportedTypeDeclarations
34 |
35 | UTImportedTypeDeclarations
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/id_pm.h:
--------------------------------------------------------------------------------
1 | #ifndef __ID_PM__
2 | #define __ID_PM__
3 |
4 |
5 | #define PMPageSize 4096
6 |
7 | extern int ChunksInFile;
8 | extern int PMSpriteStart;
9 | extern int PMSoundStart;
10 |
11 | extern bool PMSoundInfoPagePadded;
12 |
13 | // ChunksInFile+1 pointers to page starts.
14 | // The last pointer points one byte after the last page.
15 | extern uint8_t **PMPages;
16 |
17 | void PM_Startup();
18 | void PM_Shutdown();
19 |
20 | static inline uint32_t PM_GetPageSize(int page)
21 | {
22 | if(page < 0 || page >= ChunksInFile)
23 | Quit("PM_GetPageSize: Tried to access illegal page: %i", page);
24 | return (uint32_t) (PMPages[page + 1] - PMPages[page]);
25 | }
26 |
27 | static inline uint8_t *PM_GetPage(int page)
28 | {
29 | if(page < 0 || page >= ChunksInFile)
30 | Quit("PM_GetPage: Tried to access illegal page: %i", page);
31 | return PMPages[page];
32 | }
33 |
34 | static inline uint8_t *PM_GetEnd()
35 | {
36 | return PMPages[ChunksInFile];
37 | }
38 |
39 | static inline byte *PM_GetTexture(int wallpic)
40 | {
41 | return PM_GetPage(wallpic);
42 | }
43 |
44 | static inline uint16_t *PM_GetSprite(int shapenum)
45 | {
46 | // correct alignment is enforced by PM_Startup()
47 | return (uint16_t *) (void *) PM_GetPage(PMSpriteStart + shapenum);
48 | }
49 |
50 | static inline byte *PM_GetSound(int soundpagenum)
51 | {
52 | return PM_GetPage(PMSoundStart + soundpagenum);
53 | }
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/macosx/Chocolate Wolfenstein 3D.xcodeproj/project.xcworkspace/xcshareddata/Wolf4SDL.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | BD796D4D-59B7-447F-A690-B41CCDA0E2A1
9 | IDESourceControlProjectName
10 | Wolf4SDL
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | ADB16B6E-8FC4-4159-ADC0-3085AFA729A4
14 | ssh://github.com/mozzwald/wolf4sdl.git
15 |
16 | IDESourceControlProjectPath
17 | macosx/Wolf4SDL.xcodeproj/project.xcworkspace
18 | IDESourceControlProjectRelativeInstallPathDictionary
19 |
20 | ADB16B6E-8FC4-4159-ADC0-3085AFA729A4
21 | ../../..
22 |
23 | IDESourceControlProjectURL
24 | ssh://github.com/mozzwald/wolf4sdl.git
25 | IDESourceControlProjectVersion
26 | 110
27 | IDESourceControlProjectWCCIdentifier
28 | ADB16B6E-8FC4-4159-ADC0-3085AFA729A4
29 | IDESourceControlProjectWCConfigurations
30 |
31 |
32 | IDESourceControlRepositoryExtensionIdentifierKey
33 | public.vcs.git
34 | IDESourceControlWCCIdentifierKey
35 | ADB16B6E-8FC4-4159-ADC0-3085AFA729A4
36 | IDESourceControlWCCName
37 | wolf4sdl
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/id_ca.h:
--------------------------------------------------------------------------------
1 | #ifndef __ID_CA__
2 | #define __ID_CA__
3 |
4 | //===========================================================================
5 |
6 | #define NUMMAPS 60
7 | #define MAPPLANES 2
8 |
9 | #define UNCACHEGRCHUNK(chunk) {if(grsegs[chunk]) {free(grsegs[chunk]); grsegs[chunk]=NULL;}}
10 | #define UNCACHEAUDIOCHUNK(chunk) {if(audiosegs[chunk]) {free(audiosegs[chunk]); audiosegs[chunk]=NULL;}}
11 |
12 | //===========================================================================
13 |
14 | typedef struct
15 | {
16 | int32_t planestart[3];
17 | word planelength[3];
18 | word width,height;
19 | char name[16];
20 | } maptype;
21 |
22 | //===========================================================================
23 |
24 | extern int mapon;
25 |
26 | extern word *mapsegs[MAPPLANES];
27 | extern byte *audiosegs[NUMSNDCHUNKS];
28 | extern byte *grsegs[NUMCHUNKS];
29 |
30 | extern char extension[5];
31 | extern char graphext[5];
32 | extern char audioext[5];
33 |
34 | //===========================================================================
35 |
36 | boolean CA_LoadFile (const char *filename, memptr *ptr);
37 | boolean CA_WriteFile (const char *filename, void *ptr, int32_t length);
38 |
39 | int32_t CA_RLEWCompress (word *source, int32_t length, word *dest, word rlewtag);
40 |
41 | void CA_RLEWexpand (word *source, word *dest, int32_t length, word rlewtag);
42 |
43 | void CA_Startup (void);
44 | void CA_Shutdown (void);
45 |
46 | int32_t CA_CacheAudioChunk (int chunk);
47 | void CA_LoadAllSounds (void);
48 |
49 | void CA_CacheGrChunk (int chunk);
50 | void CA_CacheMap (int mapnum);
51 |
52 | void CA_CacheScreen (int chunk);
53 |
54 | void CA_CannotOpen(const char *name);
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/macosx/Chocolate Wolfenstein 3D.xcodeproj/project.xcworkspace/xcshareddata/Chocolate Wolfenstein 3D.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | 722EC25F-7101-4B8A-95F6-51183F02577C
9 | IDESourceControlProjectName
10 | Chocolate Wolfenstein 3D
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | 3A0F3619-ADF1-42DE-A6B0-E7BE0518FF11
14 | ssh://github.com/fabiensanglard/Chocolate-Wolfenstein-3D.git
15 |
16 | IDESourceControlProjectPath
17 | macosx/Chocolate Wolfenstein 3D.xcodeproj/project.xcworkspace
18 | IDESourceControlProjectRelativeInstallPathDictionary
19 |
20 | 3A0F3619-ADF1-42DE-A6B0-E7BE0518FF11
21 | ../../..
22 |
23 | IDESourceControlProjectURL
24 | ssh://github.com/fabiensanglard/Chocolate-Wolfenstein-3D.git
25 | IDESourceControlProjectVersion
26 | 110
27 | IDESourceControlProjectWCCIdentifier
28 | 3A0F3619-ADF1-42DE-A6B0-E7BE0518FF11
29 | IDESourceControlProjectWCConfigurations
30 |
31 |
32 | IDESourceControlRepositoryExtensionIdentifierKey
33 | public.vcs.git
34 | IDESourceControlWCCIdentifierKey
35 | 3A0F3619-ADF1-42DE-A6B0-E7BE0518FF11
36 | IDESourceControlWCCName
37 | wolf4sdl
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/version.h:
--------------------------------------------------------------------------------
1 | #ifndef _VERSION_H_
2 | #define _VERSION_H_
3 |
4 | #ifndef VERSIONALREADYCHOSEN // used for batch compiling
5 |
6 | /* Defines used for different versions */
7 |
8 | //#define SPEAR
9 | //#define SPEARDEMO
10 | #define UPLOAD
11 | #define GOODTIMES
12 | #define CARMACIZED
13 | //#define APOGEE_1_0
14 | //#define APOGEE_1_1
15 | //#define APOGEE_1_2
16 |
17 | /*
18 | Wolf3d Full v1.1 Apogee (with ReadThis) - define CARMACIZED and APOGEE_1_1
19 | Wolf3d Full v1.4 Apogee (with ReadThis) - define CARMACIZED
20 | Wolf3d Full v1.4 GT/ID/Activision - define CARMACIZED and GOODTIMES
21 | Wolf3d Shareware v1.0 - define UPLOAD and APOGEE_1_0
22 | Wolf3d Shareware v1.1 - define CARMACIZED and UPLOAD and APOGEE_1_1
23 | Wolf3d Shareware v1.2 - define CARMACIZED and UPLOAD and APOGEE_1_2
24 | Wolf3d Shareware v1.4 - define CARMACIZED and UPLOAD
25 | Spear of Destiny Full and Mission Disks - define CARMACIZED and SPEAR
26 | (and GOODTIMES for no FormGen quiz)
27 | Spear of Destiny Demo - define CARMACIZED and SPEAR and SPEARDEMO
28 | */
29 |
30 | #endif
31 |
32 | //#define FIXRAINSNOWLEAKS // Enables leaking ceilings fix (by Adam Biser, only needed if maps with rain/snow and ceilings exist)
33 |
34 | #define DEBUGKEYS // Comment this out to compile without the Tab debug keys
35 | #define ARTSEXTERN
36 | #define DEMOSEXTERN
37 | #define PLAYDEMOLIKEORIGINAL // When playing or recording demos, several bug fixes do not take
38 | // effect to let the original demos work as in the original Wolf3D v1.4
39 | // (actually better, as the second demo rarely worked)
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/docs/license-mame.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 1997-2005, Nicola Salmoria and the MAME team
2 | All rights reserved.
3 |
4 | Redistribution and use of this code or any derivative works are permitted
5 | provided that the following conditions are met:
6 |
7 | * Redistributions may not be sold, nor may they be used in a commercial
8 | product or activity.
9 |
10 | * Redistributions that are modified from the original source must include the
11 | complete source code, including the source code for all components used by a
12 | binary built from the modified sources. However, as a special exception, the
13 | source code distributed need not include anything that is normally distributed
14 | (in either source or binary form) with the major components (compiler, kernel,
15 | and so on) of the operating system on which the executable runs, unless that
16 | component itself accompanies the executable.
17 |
18 | * Redistributions must reproduce the above copyright notice, this list of
19 | conditions and the following disclaimer in the documentation and/or other
20 | materials provided with the distribution.
21 |
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | POSSIBILITY OF SUCH DAMAGE.
33 |
--------------------------------------------------------------------------------
/Makefile.mingw:
--------------------------------------------------------------------------------
1 | # Usage: mingw32-make -f Makefile.mingw
2 | # all: builds all
3 | # depend: generates dependency files
4 | # clean: removes object and binary files
5 | # distclean: removes dependency, object and binary files
6 |
7 | #CXX = gcc -std=c89
8 |
9 | BINARY = Chocolate-Wolfenstein-3D.exe
10 |
11 | VPATH = win32
12 |
13 | CFLAGS = -Wpointer-arith
14 | CFLAGS += -Wreturn-type
15 | CFLAGS += -Wwrite-strings
16 | CFLAGS += -Wcast-align
17 | #CFLAGS = $(INCLUDE)
18 |
19 | CCFLAGS = $(CFLAGS)
20 | CCFLAGS += -std=c++11
21 | CCFLAGS += -Werror-implicit-function-declaration
22 | CCFLAGS += -Wimplicit-int
23 | CCFLAGS += -Wsequence-point
24 | #CCFLAGS = $(INCLUDE)
25 |
26 | CXXFLAGS += $(CFLAGS)
27 |
28 | #LDFLAGS = -Wall
29 | LDFLAGS += -lmingw32
30 | LDFLAGS += -mwindows
31 | LDFLAGS += -mconsole
32 | LDFLAGS += -static-libgcc
33 | LDFLAGS += -static-libstdc++
34 | #LDFLAGS = $(LIB)
35 | LDFLAGS += -lSDLmain -lSDL -lSDL_mixer -lopengl32
36 |
37 | SRCS :=
38 | SRCS += fmopl.cpp
39 | SRCS += id_ca.cpp
40 | SRCS += id_in.cpp
41 | SRCS += id_pm.cpp
42 | SRCS += id_sd.cpp
43 | SRCS += id_us_1.cpp
44 | SRCS += id_vh.cpp
45 | SRCS += id_vl.cpp
46 | SRCS += signon.cpp
47 | SRCS += wl_act1.cpp
48 | SRCS += wl_act2.cpp
49 | SRCS += wl_agent.cpp
50 | SRCS += wl_debug.cpp
51 | SRCS += wl_draw.cpp
52 | SRCS += wl_game.cpp
53 | SRCS += wl_inter.cpp
54 | SRCS += wl_main.cpp
55 | SRCS += wl_menu.cpp
56 | SRCS += wl_play.cpp
57 | SRCS += wl_state.cpp
58 | SRCS += wl_text.cpp
59 | SRCS += crt.cpp
60 | SRCS += sdl_winmain.cpp
61 |
62 | DEPS = $(filter %.d, $(SRCS:.c=.d) $(SRCS:.cpp=.d))
63 | OBJS = $(filter %.o, $(SRCS:.c=.o) $(SRCS:.cpp=.o))
64 |
65 | .SUFFIXES:
66 | .SUFFIXES: .c .cpp .d .o
67 |
68 | REBUILDABLES = $(OBJS) $(BINARY)
69 |
70 | .PHONY: all
71 | all: $(BINARY)
72 | echo All done
73 |
74 | ifndef NO_DEPS
75 | .PHONY: depend
76 | depend: $(DEPS)
77 |
78 | ifeq ($(findstring $(MAKECMDGOALS), clean distclean depend),)
79 | -include $(DEPS)
80 | endif
81 | endif
82 |
83 | $(BINARY): $(OBJS)
84 | $(CXX) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@
85 |
86 | .cpp.o:
87 | $(CXX) $(CXXFLAGS) -c $< -o $@
88 |
89 | .cpp.d:
90 | $(CXX) $(CXXFLAGS) -MM -MF $@ -MT $< -MT $@ -c $<
91 |
92 | .PHONY: clean
93 | clean:
94 | del /S $(REBUILDABLES)
95 |
96 | .PHONY: distclean
97 | distclean:
98 | del /S $(DEPS) $(REBUILDABLES)
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | CONFIG ?= config.default
2 | -include $(CONFIG)
3 |
4 |
5 | BINARY ?= Chocolate-Wolfenstein-3D
6 | PREFIX ?= /usr/local
7 | MANPREFIX ?= $(PREFIX)
8 | UNAME := $(shell uname -s)
9 |
10 | INSTALL ?= install
11 | INSTALL_PROGRAM ?= $(INSTALL) -m 555 -s
12 | INSTALL_MAN ?= $(INSTALL) -m 444
13 | INSTALL_DATA ?= $(INSTALL) -m 444
14 |
15 |
16 | SDL_CONFIG ?= sdl-config
17 | CFLAGS_SDL ?= $(shell $(SDL_CONFIG) --cflags)
18 | LDFLAGS_SDL ?= $(shell $(SDL_CONFIG) --libs)
19 |
20 |
21 | CFLAGS += $(CFLAGS_SDL)
22 |
23 | #CFLAGS += -Wall
24 | #CFLAGS += -W
25 | CFLAGS += -Wpointer-arith
26 | CFLAGS += -Wreturn-type
27 | CFLAGS += -Wwrite-strings
28 | CFLAGS += -Wcast-align
29 |
30 | CCFLAGS += $(CFLAGS)
31 | CCFLAGS += -std=gnu99
32 | CCFLAGS += -Werror-implicit-function-declaration
33 | CCFLAGS += -Wimplicit-int
34 | CCFLAGS += -Wsequence-point
35 |
36 | CXXFLAGS += $(CFLAGS)
37 |
38 | LDFLAGS += $(LDFLAGS_SDL)
39 | ifeq ($(UNAME), Darwin)
40 | LDFLAGS += -lSDL_mixer -framework OpenGL
41 | endif
42 | ifeq ($(UNAME), Linux)
43 | LDFLAGS += -lSDL_mixer -lGL
44 | endif
45 |
46 | SRCS :=
47 | SRCS += fmopl.cpp
48 | SRCS += id_ca.cpp
49 | SRCS += id_in.cpp
50 | SRCS += id_pm.cpp
51 | SRCS += id_sd.cpp
52 | SRCS += id_us_1.cpp
53 | SRCS += id_vh.cpp
54 | SRCS += id_vl.cpp
55 | SRCS += signon.cpp
56 | SRCS += wl_act1.cpp
57 | SRCS += wl_act2.cpp
58 | SRCS += wl_agent.cpp
59 | SRCS += wl_debug.cpp
60 | SRCS += wl_draw.cpp
61 | SRCS += wl_game.cpp
62 | SRCS += wl_inter.cpp
63 | SRCS += wl_main.cpp
64 | SRCS += wl_menu.cpp
65 | SRCS += wl_play.cpp
66 | SRCS += wl_state.cpp
67 | SRCS += wl_text.cpp
68 | SRCS += crt.cpp
69 |
70 | DEPS = $(filter %.d, $(SRCS:.c=.d) $(SRCS:.cpp=.d))
71 | OBJS = $(filter %.o, $(SRCS:.c=.o) $(SRCS:.cpp=.o))
72 |
73 | .SUFFIXES:
74 | .SUFFIXES: .c .cpp .d .o
75 |
76 | Q ?= @
77 |
78 | all: $(BINARY)
79 |
80 | ifndef NO_DEPS
81 | depend: $(DEPS)
82 |
83 | ifeq ($(findstring $(MAKECMDGOALS), clean depend Data),)
84 | -include $(DEPS)
85 | endif
86 | endif
87 |
88 | $(BINARY): $(OBJS)
89 | @echo '===> LD $@'
90 | $(Q)$(CXX) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@
91 |
92 | .c.o:
93 | @echo '===> CC $<'
94 | $(Q)$(CC) $(CCFLAGS) -c $< -o $@
95 |
96 | .cpp.o:
97 | @echo '===> CXX $<'
98 | $(Q)$(CXX) $(CXXFLAGS) -c $< -o $@
99 |
100 | .c.d:
101 | @echo '===> DEP $<'
102 | $(Q)$(CC) $(CCFLAGS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:%.d=%.o):#' > $@
103 |
104 | .cpp.d:
105 | @echo '===> DEP $<'
106 | $(Q)$(CXX) $(CXXFLAGS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:%.d=%.o):#' > $@
107 |
108 | clean distclean:
109 | @echo '===> CLEAN'
110 | $(Q)rm -fr $(DEPS) $(OBJS) $(BINARY)
111 |
112 | install: $(BINARY)
113 | @echo '===> INSTALL'
114 | $(Q)$(INSTALL) -d $(PREFIX)/bin
115 | $(Q)$(INSTALL_PROGRAM) $(BINARY) $(PREFIX)/bin
116 |
--------------------------------------------------------------------------------
/f_spear.h:
--------------------------------------------------------------------------------
1 | #define STR_ENDGAME1 "We owe you a great debt, Mr. Blazkowicz."
2 | #define STR_ENDGAME2 "You have served your country well."
3 | #define STR_ENDGAME3 "With the spear gone, the Allies will finally"
4 | #define STR_ENDGAME4 "by able to destroy Hitler..."
5 |
6 | #define STR_COPY1 "That's close, but not close enough to get"
7 | #define STR_COPY2 "you into the game."
8 |
9 | #define STR_COPY3 "Wow, you must have the early version of the"
10 | #define STR_COPY4 "manual with the totally false information in it."
11 |
12 | #define STR_COPY5 "I would let you into the game, but seeing"
13 | #define STR_COPY6 "as that was not at all the right answer..."
14 |
15 | #define STR_COPY7 "It's just too bad we can't get together on"
16 | #define STR_COPY8 "this one. Sorry."
17 |
18 | #define STR_COPY9 "Hey, you're just SO off base!"
19 |
20 | #define STR_COPY10 "You know, I once typed that myself when"
21 | #define STR_COPY11 "I was your age."
22 |
23 | #define STR_COPY12 "Nops. Zero points. Zugga."
24 |
25 | #define STR_COPY13 "Yeah...right."
26 |
27 | #define STR_COPY14 "You must like these quizzes."
28 |
29 | #define STR_COPY15 "Could be called \"PixelMeister\"?"
30 |
31 | #define STR_COPY16 "Might engineer some software?"
32 |
33 | #define STR_COPY17 "Would be found"
34 | #define STR_COPY18 "directing creatively?"
35 |
36 | #define STR_COPY19 "Might be found"
37 | #define STR_COPY20 "handling operations?"
38 |
39 | #define STR_COPY21 "Has a name familiar"
40 | #define STR_COPY22 "to your weatherman?"
41 |
42 | #define STR_NOPE1 "Welcome to the DOS prompt, pirate!"
43 | #define STR_NOPE2 "Eat hot DOS prompt, goober!"
44 | #define STR_NOPE3 "Ya know, this program doesn't cost that much."
45 | #define STR_NOPE4 "Hey...weren't you just AT this DOS prompt?"
46 | #define STR_NOPE5 "What's a nice user like you doin' at a DOS prompt like this?"
47 | #define STR_NOPE6 "Well, I'm sure you just \"misplaced\" the manual..."
48 | #define STR_NOPE7 "Run me again when you've boned up on your manual a bit."
49 | #define STR_NOPE8 "Nice try, but no Spear."
50 | #define STR_NOPE9 "That information is in the Spear of Destiny manual, by the way."
51 |
52 | #define STR_MISC1 "Under \"Killing the Enemy\", what"
53 | #define STR_MISC2 "type of enemy is pictured?"
54 |
55 | #define STR_MISC3 "How many eyelets are on B.J.'s"
56 | #define STR_MISC4 "boots? (see page 2)"
57 |
58 | #define STR_MISC5 "The word \"minister\" appears in"
59 | #define STR_MISC6 "what gray shape on page 2?"
60 |
61 | #define STR_MISC7 "How many bullets does B.J. have"
62 | #define STR_MISC8 "on the screen-shot in the middle"
63 | #define STR_MISC9 "of page 9?"
64 |
65 | #define STR_STAR "star"
66 | #define STR_DEBRIEF " DEBRIEFING\n SESSION\n"
67 | #define STR_ENEMY1 "Name the member of the"
68 | #define STR_ENEMY2 "enemy forces shown above"
69 |
70 | #define STR_CHECKMAN "CHECK YER MANUAL!"
71 | #define STR_MAN1 "Which manual page"
72 | #define STR_MAN2 "is the Options Menu"
73 | #define STR_MAN3 "function"
74 | #define STR_MAN4 "on?"
75 |
76 | #define STR_ID1 "Which member of Id Software:"
77 |
--------------------------------------------------------------------------------
/id_vh.h:
--------------------------------------------------------------------------------
1 | // ID_VH.H
2 |
3 |
4 | #define WHITE 15 // graphics mode independant colors
5 | #define BLACK 0
6 | #define FIRSTCOLOR 1
7 | #define SECONDCOLOR 12
8 | #define F_WHITE 15
9 | #define F_BLACK 0
10 | #define F_FIRSTCOLOR 1
11 | #define F_SECONDCOLOR 12
12 |
13 | //===========================================================================
14 |
15 | #define MAXSHIFTS 1
16 |
17 | typedef struct
18 | {
19 | int16_t width,height;
20 | } pictabletype;
21 |
22 |
23 | typedef struct
24 | {
25 | int16_t height;
26 | int16_t location[256];
27 | int8_t width[256];
28 | } fontstruct;
29 |
30 |
31 | //===========================================================================
32 |
33 |
34 | extern pictabletype *pictable;
35 | extern pictabletype *picmtable;
36 |
37 | extern byte fontcolor,backcolor;
38 | extern int fontnumber;
39 | extern int px,py;
40 |
41 | #define SETFONTCOLOR(f,b) fontcolor=f;backcolor=b;
42 |
43 | //
44 | // mode independant routines
45 | // coordinates in pixels, rounded to best screen res
46 | // regions marked in double buffer
47 | //
48 |
49 | void VWB_DrawPropString (const char *string);
50 |
51 | void VWB_DrawTile8 (int x, int y, int tile);
52 | void VWB_DrawTile8M (int x, int y, int tile);
53 | void VWB_DrawTile16 (int x, int y, int tile);
54 | void VWB_DrawTile16M (int x, int y, int tile);
55 | void VWB_DrawPic (int x, int y, int chunknum);
56 | void VWB_DrawPicScaledCoord (int x, int y, int chunknum);
57 | void VWB_DrawMPic(int x, int y, int chunknum);
58 | void VWB_Bar (int x, int y, int width, int height, int color);
59 | #define VWB_BarScaledCoord VL_BarScaledCoord
60 | void VWB_Plot (int x, int y, int color);
61 | #define VWB_PlotScaledCoord VW_Plot
62 | void VWB_Hlin (int x1, int x2, int y, int color);
63 | void VWB_Vlin (int y1, int y2, int x, int color);
64 | #define VWB_HlinScaledCoord VW_Hlin
65 | #define VWB_VlinScaledCoord VW_Vlin
66 |
67 | void VH_UpdateScreen();
68 | #define VW_UpdateScreen VH_UpdateScreen
69 |
70 | //
71 | // wolfenstein EGA compatability stuff
72 | //
73 |
74 |
75 | #define VW_Shutdown VL_Shutdown
76 | #define VW_Bar VL_Bar
77 | #define VW_Plot VL_Plot
78 | #define VW_Hlin(x,z,y,c) VL_Hlin(x,y,(z)-(x)+1,c)
79 | #define VW_Vlin(y,z,x,c) VL_Vlin(x,y,(z)-(y)+1,c)
80 | #define VW_DrawPic VH_DrawPic
81 | #define VW_WaitVBL VL_WaitVBL
82 | #define VW_FadeIn() VL_FadeIn(0,255,gamepal,30);
83 | #define VW_FadeOut() VL_FadeOut(0,255,0,0,0,30);
84 | #define VW_ScreenToScreen VL_ScreenToScreen
85 | void VW_MeasurePropString (const char *string, word *width, word *height);
86 |
87 | #define LatchDrawChar(x,y,p) VL_LatchToScreen(latchpics[0],((p)&7)*8,((p)>>3)*8*64,8,8,x,y)
88 | #define LatchDrawTile(x,y,p) VL_LatchToScreen(latchpics[1],(p)*64,0,16,16,x,y)
89 |
90 | void LatchDrawPic (unsigned x, unsigned y, unsigned picnum);
91 | void LatchDrawPicScaledCoord (unsigned scx, unsigned scy, unsigned picnum);
92 | void LoadLatchMem (void);
93 |
94 | void VH_Startup();
95 | boolean FizzleFade (SDL_Surface *source, int x1, int y1,
96 | unsigned width, unsigned height, unsigned frames, boolean abortable);
97 |
98 | #define NUMLATCHPICS 100
99 | extern SDL_Surface *latchpics[NUMLATCHPICS];
100 |
--------------------------------------------------------------------------------
/id_us.h:
--------------------------------------------------------------------------------
1 | //
2 | // ID Engine
3 | // ID_US.h - Header file for the User Manager
4 | // v1.0d1
5 | // By Jason Blochowiak
6 | //
7 |
8 | #ifndef __ID_US__
9 | #define __ID_US__
10 |
11 | #ifdef __DEBUG__
12 | #define __DEBUG_UserMgr__
13 | #endif
14 |
15 | //#define HELPTEXTLINKED
16 |
17 | #define MaxX 320
18 | #define MaxY 200
19 |
20 | #define MaxHelpLines 500
21 |
22 | #define MaxHighName 57
23 | #define MaxScores 7
24 | typedef struct
25 | {
26 | char name[MaxHighName + 1];
27 | int32_t score;
28 | word completed,episode;
29 | } HighScore;
30 |
31 | #define MaxGameName 32
32 | #define MaxSaveGames 6
33 | typedef struct
34 | {
35 | char signature[4];
36 | word *oldtest;
37 | boolean present;
38 | char name[MaxGameName + 1];
39 | } SaveGame;
40 |
41 | #define MaxString 128 // Maximum input string size
42 |
43 | typedef struct
44 | {
45 | int x,y,
46 | w,h,
47 | px,py;
48 | } WindowRec; // Record used to save & restore screen windows
49 |
50 | extern boolean ingame, // Set by game code if a game is in progress
51 | loadedgame; // Set if the current game was loaded
52 | extern word PrintX,PrintY; // Current printing location in the window
53 | extern word WindowX,WindowY,// Current location of window
54 | WindowW,WindowH;// Current size of window
55 |
56 | extern void (*USL_MeasureString)(const char *,word *,word *);
57 | extern void (*USL_DrawString)(const char *);
58 |
59 | extern boolean (*USL_SaveGame)(int),(*USL_LoadGame)(int);
60 | extern void (*USL_ResetGame)(void);
61 | extern SaveGame Games[MaxSaveGames];
62 | extern HighScore Scores[];
63 |
64 | #define US_HomeWindow() {PrintX = WindowX; PrintY = WindowY;}
65 |
66 | void US_Startup(void);
67 | void US_Shutdown(void);
68 | void US_TextScreen(void),
69 | US_UpdateTextScreen(void),
70 | US_FinishTextScreen(void);
71 | void US_DrawWindow(word x,word y,word w,word h);
72 |
73 | void US_SaveWindow(WindowRec *win),
74 | US_RestoreWindow(WindowRec *win);
75 | void US_ClearWindow(void);
76 | void US_SetPrintRoutines(void (*measure)(const char *,word *,word *),
77 | void (*print)(const char *));
78 | void US_PrintCentered(const char *s),
79 | US_CPrint(const char *s),
80 | US_CPrintLine(const char *s),
81 | US_Print(const char *s);
82 | void US_Printf(const char *formatStr, ...);
83 | void US_CPrintf(const char *formatStr, ...);
84 |
85 | void US_PrintUnsigned(longword n);
86 | void US_PrintSigned(int32_t n);
87 | void US_StartCursor(void),
88 | US_ShutCursor(void);
89 | void US_CheckHighScore(int32_t score,word other);
90 | void US_DisplayHighScores(int which);
91 | extern boolean US_UpdateCursor(void);
92 | boolean US_LineInput(int x,int y,char *buf,const char *def,boolean escok,
93 | int maxchars,int maxwidth);
94 |
95 | void USL_PrintInCenter(const char *s,Rect r);
96 | char *USL_GiveSaveName(word game);
97 |
98 | void US_InitRndT(int randomize);
99 | int US_RndT();
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/fmopl.h:
--------------------------------------------------------------------------------
1 | #ifndef __FMOPL_H_
2 | #define __FMOPL_H_
3 |
4 | #define HAS_YM3812 1
5 |
6 | /* --- select emulation chips --- */
7 | #define BUILD_YM3812 (HAS_YM3812)
8 | #define BUILD_YM3526 (HAS_YM3526)
9 | #define BUILD_Y8950 (HAS_Y8950)
10 |
11 | /* select output bits size of output : 8 or 16 */
12 | #define OPL_SAMPLE_BITS 16
13 |
14 | /* compiler dependence */
15 | #ifndef OSD_CPU_H
16 | #define OSD_CPU_H
17 | typedef unsigned char UINT8; /* unsigned 8bit */
18 | typedef unsigned short UINT16; /* unsigned 16bit */
19 | typedef unsigned int UINT32; /* unsigned 32bit */
20 | typedef signed char INT8; /* signed 8bit */
21 | typedef signed short INT16; /* signed 16bit */
22 | typedef signed int INT32; /* signed 32bit */
23 |
24 | typedef int BOOL;
25 | #endif
26 |
27 | #if (OPL_SAMPLE_BITS==16)
28 | typedef INT16 OPLSAMPLE;
29 | #endif
30 | #if (OPL_SAMPLE_BITS==8)
31 | typedef INT8 OPLSAMPLE;
32 | #endif
33 |
34 |
35 | typedef void (*OPL_TIMERHANDLER)(int channel,double interval_Sec);
36 | typedef void (*OPL_IRQHANDLER)(int param,int irq);
37 | typedef void (*OPL_UPDATEHANDLER)(int param,int min_interval_us);
38 | typedef void (*OPL_PORTHANDLER_W)(int param,unsigned char data);
39 | typedef unsigned char (*OPL_PORTHANDLER_R)(int param);
40 |
41 |
42 | #if BUILD_YM3812
43 |
44 | int YM3812Init(int num, int clock, int rate);
45 | void YM3812Shutdown(void);
46 | void YM3812ResetChip(int which);
47 | int YM3812Write(int which, int a, int v);
48 | unsigned char YM3812Read(int which, int a);
49 | void YM3812Mute(int which,int channel,BOOL mute);
50 | int YM3812TimerOver(int which, int c);
51 | void YM3812UpdateOne(int which, INT16 *buffer, int length);
52 |
53 | void YM3812SetTimerHandler(int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
54 | void YM3812SetIRQHandler(int which, OPL_IRQHANDLER IRQHandler, int param);
55 | void YM3812SetUpdateHandler(int which, OPL_UPDATEHANDLER UpdateHandler, int param);
56 |
57 | #endif
58 |
59 |
60 | #if BUILD_YM3526
61 |
62 | /*
63 | ** Initialize YM3526 emulator(s).
64 | **
65 | ** 'num' is the number of virtual YM3526's to allocate
66 | ** 'clock' is the chip clock in Hz
67 | ** 'rate' is sampling rate
68 | */
69 | int YM3526Init(int num, int clock, int rate);
70 | /* shutdown the YM3526 emulators*/
71 | void YM3526Shutdown(void);
72 | void YM3526ResetChip(int which);
73 | int YM3526Write(int which, int a, int v);
74 | unsigned char YM3526Read(int which, int a);
75 | int YM3526TimerOver(int which, int c);
76 | /*
77 | ** Generate samples for one of the YM3526's
78 | **
79 | ** 'which' is the virtual YM3526 number
80 | ** '*buffer' is the output buffer pointer
81 | ** 'length' is the number of samples that should be generated
82 | */
83 | void YM3526UpdateOne(int which, INT16 *buffer, int length);
84 |
85 | void YM3526SetTimerHandler(int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
86 | void YM3526SetIRQHandler(int which, OPL_IRQHANDLER IRQHandler, int param);
87 | void YM3526SetUpdateHandler(int which, OPL_UPDATEHANDLER UpdateHandler, int param);
88 |
89 | #endif
90 |
91 |
92 | #if BUILD_Y8950
93 |
94 | /* Y8950 port handlers */
95 | void Y8950SetPortHandler(int which, OPL_PORTHANDLER_W PortHandler_w, OPL_PORTHANDLER_R PortHandler_r, int param);
96 | void Y8950SetKeyboardHandler(int which, OPL_PORTHANDLER_W KeyboardHandler_w, OPL_PORTHANDLER_R KeyboardHandler_r, int param);
97 | void Y8950SetDeltaTMemory(int which, void * deltat_mem_ptr, int deltat_mem_size );
98 |
99 | int Y8950Init (int num, int clock, int rate);
100 | void Y8950Shutdown (void);
101 | void Y8950ResetChip (int which);
102 | int Y8950Write (int which, int a, int v);
103 | unsigned char Y8950Read (int which, int a);
104 | int Y8950TimerOver (int which, int c);
105 | void Y8950UpdateOne (int which, INT16 *buffer, int length);
106 |
107 | void Y8950SetTimerHandler (int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
108 | void Y8950SetIRQHandler (int which, OPL_IRQHANDLER IRQHandler, int param);
109 | void Y8950SetUpdateHandler (int which, OPL_UPDATEHANDLER UpdateHandler, int param);
110 |
111 | #endif
112 |
113 |
114 | #endif /* __FMOPL_H_ */
115 |
--------------------------------------------------------------------------------
/id_pm.cpp:
--------------------------------------------------------------------------------
1 | #include "wl_def.h"
2 |
3 | int ChunksInFile;
4 | int PMSpriteStart;
5 | int PMSoundStart;
6 |
7 | bool PMSoundInfoPagePadded = false;
8 |
9 | // holds the whole VSWAP
10 | uint32_t *PMPageData;
11 | size_t PMPageDataSize;
12 |
13 | // ChunksInFile+1 pointers to page starts.
14 | // The last pointer points one byte after the last page.
15 | uint8_t **PMPages;
16 |
17 | void PM_Startup()
18 | {
19 | char fname[13] = "vswap.";
20 | strcat(fname,extension);
21 |
22 | FILE *file = fopen(fname,"rb");
23 | if(!file)
24 | CA_CannotOpen(fname);
25 |
26 | ChunksInFile = 0;
27 | fread(&ChunksInFile, sizeof(word), 1, file);
28 | PMSpriteStart = 0;
29 | fread(&PMSpriteStart, sizeof(word), 1, file);
30 | PMSoundStart = 0;
31 | fread(&PMSoundStart, sizeof(word), 1, file);
32 |
33 | uint32_t* pageOffsets = (uint32_t *) malloc((ChunksInFile + 1) * sizeof(int32_t));
34 | CHECKMALLOCRESULT(pageOffsets);
35 | fread(pageOffsets, sizeof(uint32_t), ChunksInFile, file);
36 |
37 | word *pageLengths = (word *) malloc(ChunksInFile * sizeof(word));
38 | CHECKMALLOCRESULT(pageLengths);
39 | fread(pageLengths, sizeof(word), ChunksInFile, file);
40 |
41 | fseek(file, 0, SEEK_END);
42 | long fileSize = ftell(file);
43 | long pageDataSize = fileSize - pageOffsets[0];
44 | if(pageDataSize > (size_t) -1)
45 | Quit("The page file \"%s\" is too large!", fname);
46 |
47 | pageOffsets[ChunksInFile] = fileSize;
48 |
49 | uint32_t dataStart = pageOffsets[0];
50 | int i;
51 |
52 | // Check that all pageOffsets are valid
53 | for(i = 0; i < ChunksInFile; i++)
54 | {
55 | if(!pageOffsets[i]) continue; // sparse page
56 | if(pageOffsets[i] < dataStart || pageOffsets[i] >= (size_t) fileSize)
57 | Quit("Illegal page offset for page %i: %u (filesize: %u)",
58 | i, pageOffsets[i], fileSize);
59 | }
60 |
61 | // Calculate total amount of padding needed for sprites and sound info page
62 | int alignPadding = 0;
63 | for(i = PMSpriteStart; i < PMSoundStart; i++)
64 | {
65 | if(!pageOffsets[i]) continue; // sparse page
66 | uint32_t offs = pageOffsets[i] - dataStart + alignPadding;
67 | if(offs & 1)
68 | alignPadding++;
69 | }
70 |
71 | if((pageOffsets[ChunksInFile - 1] - dataStart + alignPadding) & 1)
72 | alignPadding++;
73 |
74 | PMPageDataSize = (size_t) pageDataSize + alignPadding;
75 | PMPageData = (uint32_t *) malloc(PMPageDataSize);
76 | CHECKMALLOCRESULT(PMPageData);
77 |
78 | PMPages = (uint8_t **) malloc((ChunksInFile + 1) * sizeof(uint8_t *));
79 | CHECKMALLOCRESULT(PMPages);
80 |
81 | // Load pages and initialize PMPages pointers
82 | uint8_t *ptr = (uint8_t *) PMPageData;
83 | for(i = 0; i < ChunksInFile; i++)
84 | {
85 | if(i >= PMSpriteStart && i < PMSoundStart || i == ChunksInFile - 1)
86 | {
87 | size_t offs = ptr - (uint8_t *) PMPageData;
88 |
89 | // pad with zeros to make it 2-byte aligned
90 | if(offs & 1)
91 | {
92 | *ptr++ = 0;
93 | if(i == ChunksInFile - 1) PMSoundInfoPagePadded = true;
94 | }
95 | }
96 |
97 | PMPages[i] = ptr;
98 |
99 | if(!pageOffsets[i])
100 | continue; // sparse page
101 |
102 | // Use specified page length, when next page is sparse page.
103 | // Otherwise, calculate size from the offset difference between this and the next page.
104 | uint32_t size;
105 | if(!pageOffsets[i + 1]) size = pageLengths[i];
106 | else size = pageOffsets[i + 1] - pageOffsets[i];
107 |
108 | fseek(file, pageOffsets[i], SEEK_SET);
109 | fread(ptr, 1, size, file);
110 | ptr += size;
111 | }
112 |
113 | // last page points after page buffer
114 | PMPages[ChunksInFile] = ptr;
115 |
116 | free(pageLengths);
117 | free(pageOffsets);
118 | fclose(file);
119 | }
120 |
121 | void PM_Shutdown()
122 | {
123 | free(PMPages);
124 | free(PMPageData);
125 | }
126 |
--------------------------------------------------------------------------------
/id_sd.h:
--------------------------------------------------------------------------------
1 | //
2 | // ID Engine
3 | // ID_SD.h - Sound Manager Header
4 | // Version for Wolfenstein
5 | // By Jason Blochowiak
6 | //
7 |
8 | #ifndef __ID_SD__
9 | #define __ID_SD__
10 |
11 | #define alOut(n,b) YM3812Write(0, n, b)
12 |
13 | #define TickBase 70 // 70Hz per tick - used as a base for timer 0
14 |
15 | typedef enum
16 | {
17 | sdm_Off,
18 | sdm_PC,sdm_AdLib,
19 | } SDMode;
20 |
21 | typedef enum
22 | {
23 | smm_Off,smm_AdLib
24 | } SMMode;
25 |
26 | typedef enum
27 | {
28 | sds_Off,sds_PC,sds_SoundBlaster
29 | } SDSMode;
30 |
31 | typedef struct
32 | {
33 | longword length;
34 | word priority;
35 | } SoundCommon;
36 |
37 | #define ORIG_SOUNDCOMMON_SIZE 6
38 |
39 | // PC Sound stuff
40 | #define pcTimer 0x42
41 | #define pcTAccess 0x43
42 | #define pcSpeaker 0x61
43 |
44 | #define pcSpkBits 3
45 |
46 | typedef struct
47 | {
48 | SoundCommon common;
49 | byte data[1];
50 | } PCSound;
51 |
52 | // Register addresses
53 | // Operator stuff
54 | #define alChar 0x20
55 | #define alScale 0x40
56 | #define alAttack 0x60
57 | #define alSus 0x80
58 | #define alWave 0xe0
59 | // Channel stuff
60 | #define alFreqL 0xa0
61 | #define alFreqH 0xb0
62 | #define alFeedCon 0xc0
63 | // Global stuff
64 | #define alEffects 0xbd
65 |
66 | typedef struct
67 | {
68 | byte mChar,cChar,
69 | mScale,cScale,
70 | mAttack,cAttack,
71 | mSus,cSus,
72 | mWave,cWave,
73 | nConn,
74 |
75 | // These are only for Muse - these bytes are really unused
76 | voice,
77 | mode;
78 | byte unused[3];
79 | } Instrument;
80 |
81 | #define ORIG_INSTRUMENT_SIZE 16
82 |
83 | typedef struct
84 | {
85 | SoundCommon common;
86 | Instrument inst;
87 | byte block;
88 | byte data[1];
89 | } AdLibSound;
90 |
91 | #define ORIG_ADLIBSOUND_SIZE (ORIG_SOUNDCOMMON_SIZE + ORIG_INSTRUMENT_SIZE + 2)
92 |
93 | //
94 | // Sequencing stuff
95 | //
96 | #define sqMaxTracks 10
97 |
98 | typedef struct
99 | {
100 | word length;
101 | word values[1];
102 | } MusicGroup;
103 |
104 | typedef struct
105 | {
106 | int valid;
107 | fixed globalsoundx, globalsoundy;
108 | } globalsoundpos;
109 |
110 | extern globalsoundpos channelSoundPos[];
111 |
112 | // Global variables
113 | extern boolean AdLibPresent,
114 | SoundBlasterPresent,
115 | SoundPositioned;
116 | extern SDMode SoundMode;
117 | extern SDSMode DigiMode;
118 | extern SMMode MusicMode;
119 | extern int DigiMap[];
120 | extern int DigiChannel[];
121 |
122 | #define GetTimeCount() ((SDL_GetTicks()*7)/100)
123 |
124 | inline void Delay(int wolfticks)
125 | {
126 | if(wolfticks>0) SDL_Delay(wolfticks * 100 / 7);
127 | }
128 |
129 | // Function prototypes
130 | extern void SD_Startup(void),
131 | SD_Shutdown(void);
132 |
133 | extern int SD_GetChannelForDigi(int which);
134 | extern void SD_PositionSound(int leftvol,int rightvol);
135 | extern boolean SD_PlaySound(soundnames sound);
136 | extern void SD_SetPosition(int channel, int leftvol,int rightvol);
137 | extern void SD_StopSound(void),
138 | SD_WaitSoundDone(void);
139 |
140 | extern void SD_StartMusic(int chunk);
141 | extern void SD_ContinueMusic(int chunk, int startoffs);
142 | extern void SD_MusicOn(void),
143 | SD_FadeOutMusic(void);
144 | extern int SD_MusicOff(void);
145 |
146 | extern boolean SD_MusicPlaying(void);
147 | extern boolean SD_SetSoundMode(SDMode mode);
148 | extern boolean SD_SetMusicMode(SMMode mode);
149 | extern word SD_SoundPlaying(void);
150 |
151 | extern void SD_SetDigiDevice(SDSMode);
152 | extern void SD_PrepareSound(int which);
153 | extern int SD_PlayDigitized(word which,int leftpos,int rightpos);
154 | extern void SD_StopDigitized(void);
155 |
156 | #endif
157 |
--------------------------------------------------------------------------------
/id_vl.h:
--------------------------------------------------------------------------------
1 | // ID_VL.H
2 |
3 | // wolf compatability
4 |
5 | // Win32
6 | //#ifndef ID_VL.H
7 | //#define ID_VL.H
8 | #ifndef ID_VL_H
9 | #define ID_VL_H
10 |
11 | #include "wl_def.h"
12 |
13 | void Quit (const char *error,...);
14 |
15 | //===========================================================================
16 |
17 | #define CHARWIDTH 2
18 | #define TILEWIDTH 4
19 |
20 | //===========================================================================
21 |
22 | extern SDL_Surface *screen, *screenBuffer, *curSurface;
23 |
24 | extern boolean fullscreen, usedoublebuffering;
25 | extern unsigned screenWidth, screenHeight, screenBits, screenPitch, bufferPitch, curPitch;
26 | extern unsigned scaleFactor;
27 |
28 | extern boolean screenfaded;
29 | extern unsigned bordercolor;
30 |
31 | extern SDL_Color gamepal[256];
32 |
33 | //===========================================================================
34 |
35 | //
36 | // VGA hardware routines
37 | //
38 |
39 | #define VL_WaitVBL(a) SDL_Delay((a)*8)
40 |
41 | void VL_SetVGAPlaneMode (void);
42 | void VL_SetTextMode (void);
43 | void VL_Shutdown (void);
44 |
45 | void VL_ConvertPalette(byte *srcpal, SDL_Color *destpal, int numColors);
46 | void VL_FillPalette (int red, int green, int blue);
47 | void VL_SetColor (int color, int red, int green, int blue);
48 | void VL_GetColor (int color, int *red, int *green, int *blue);
49 | void VL_SetPalette (SDL_Color *palette, bool forceupdate);
50 | void VL_GetPalette (SDL_Color *palette);
51 | void VL_FadeOut (int start, int end, int red, int green, int blue, int steps);
52 | void VL_FadeIn (int start, int end, SDL_Color *palette, int steps);
53 |
54 | byte *VL_LockSurface(SDL_Surface *surface);
55 | void VL_UnlockSurface(SDL_Surface *surface);
56 |
57 | #define LOCK() VL_LockSurface(curSurface)
58 | #define UNLOCK() VL_UnlockSurface(curSurface)
59 |
60 | byte VL_GetPixel (int x, int y);
61 | void VL_Plot (int x, int y, int color);
62 | void VL_Hlin (unsigned x, unsigned y, unsigned width, int color);
63 | void VL_Vlin (int x, int y, int height, int color);
64 | void VL_BarScaledCoord (int scx, int scy, int scwidth, int scheight, int color);
65 | void inline VL_Bar (int x, int y, int width, int height, int color)
66 | {
67 | VL_BarScaledCoord(scaleFactor*x, scaleFactor*y,
68 | scaleFactor*width, scaleFactor*height, color);
69 | }
70 | void inline VL_ClearScreen(int color)
71 | {
72 | SDL_FillRect(curSurface, NULL, color);
73 | }
74 |
75 | void VL_MungePic (byte *source, unsigned width, unsigned height);
76 | void VL_DrawPicBare (int x, int y, byte *pic, int width, int height);
77 | void VL_MemToLatch (byte *source, int width, int height,
78 | SDL_Surface *destSurface, int x, int y);
79 | void VL_ScreenToScreen (SDL_Surface *source, SDL_Surface *dest);
80 | void VL_MemToScreenScaledCoord (byte *source, int width, int height, int scx, int scy);
81 | void VL_MemToScreenScaledCoord (byte *source, int origwidth, int origheight, int srcx, int srcy,
82 | int destx, int desty, int width, int height);
83 |
84 | void inline VL_MemToScreen (byte *source, int width, int height, int x, int y)
85 | {
86 | VL_MemToScreenScaledCoord(source, width, height, scaleFactor*x, scaleFactor*y);
87 | }
88 |
89 | void VL_MaskedToScreen (byte *source, int width, int height, int x, int y);
90 |
91 | void VL_LatchToScreenScaledCoord (SDL_Surface *source, int xsrc, int ysrc,
92 | int width, int height, int scxdest, int scydest);
93 |
94 | void inline VL_LatchToScreen (SDL_Surface *source, int xsrc, int ysrc,
95 | int width, int height, int xdest, int ydest)
96 | {
97 | VL_LatchToScreenScaledCoord(source,xsrc,ysrc,width,height,
98 | scaleFactor*xdest,scaleFactor*ydest);
99 | }
100 | void inline VL_LatchToScreenScaledCoord (SDL_Surface *source, int scx, int scy)
101 | {
102 | VL_LatchToScreenScaledCoord(source,0,0,source->w,source->h,scx,scy);
103 | }
104 | void inline VL_LatchToScreen (SDL_Surface *source, int x, int y)
105 | {
106 | VL_LatchToScreenScaledCoord(source,0,0,source->w,source->h,
107 | scaleFactor*x,scaleFactor*y);
108 | }
109 |
110 | #endif
111 |
--------------------------------------------------------------------------------
/sodpal.inc:
--------------------------------------------------------------------------------
1 | RGB( 0, 0, 0),RGB( 0, 0, 42),RGB( 0, 42, 0),RGB( 0, 42, 42),RGB( 42, 0, 0),
2 | RGB( 42, 0, 42),RGB( 42, 21, 0),RGB( 42, 42, 42),RGB( 21, 21, 21),RGB( 21, 21, 63),
3 | RGB( 21, 63, 21),RGB( 21, 63, 63),RGB( 63, 21, 21),RGB( 63, 21, 63),RGB( 63, 63, 21),
4 | RGB( 63, 63, 63),RGB( 59, 59, 59),RGB( 55, 55, 55),RGB( 52, 52, 52),RGB( 48, 48, 48),
5 | RGB( 45, 45, 45),RGB( 42, 42, 42),RGB( 38, 38, 38),RGB( 35, 35, 35),RGB( 31, 31, 31),
6 | RGB( 28, 28, 28),RGB( 25, 25, 25),RGB( 21, 21, 21),RGB( 18, 18, 18),RGB( 14, 14, 14),
7 | RGB( 11, 11, 11),RGB( 8, 8, 8),RGB( 63, 0, 0),RGB( 59, 0, 0),RGB( 56, 0, 0),
8 | RGB( 53, 0, 0),RGB( 50, 0, 0),RGB( 47, 0, 0),RGB( 44, 0, 0),RGB( 41, 0, 0),
9 | RGB( 38, 0, 0),RGB( 34, 0, 0),RGB( 31, 0, 0),RGB( 28, 0, 0),RGB( 25, 0, 0),
10 | RGB( 22, 0, 0),RGB( 19, 0, 0),RGB( 16, 0, 0),RGB( 63, 54, 54),RGB( 63, 46, 46),
11 | RGB( 63, 39, 39),RGB( 63, 31, 31),RGB( 63, 23, 23),RGB( 63, 16, 16),RGB( 63, 8, 8),
12 | RGB( 63, 0, 0),RGB( 63, 42, 23),RGB( 63, 38, 16),RGB( 63, 34, 8),RGB( 63, 30, 0),
13 | RGB( 57, 27, 0),RGB( 51, 24, 0),RGB( 45, 21, 0),RGB( 39, 19, 0),RGB( 63, 63, 54),
14 | RGB( 63, 63, 46),RGB( 63, 63, 39),RGB( 63, 63, 31),RGB( 63, 62, 23),RGB( 63, 61, 16),
15 | RGB( 63, 61, 8),RGB( 63, 61, 0),RGB( 57, 54, 0),RGB( 51, 49, 0),RGB( 45, 43, 0),
16 | RGB( 39, 39, 0),RGB( 33, 33, 0),RGB( 28, 27, 0),RGB( 22, 21, 0),RGB( 16, 16, 0),
17 | RGB( 52, 63, 23),RGB( 49, 63, 16),RGB( 45, 63, 8),RGB( 40, 63, 0),RGB( 36, 57, 0),
18 | RGB( 32, 51, 0),RGB( 29, 45, 0),RGB( 24, 39, 0),RGB( 54, 63, 54),RGB( 47, 63, 46),
19 | RGB( 39, 63, 39),RGB( 32, 63, 31),RGB( 24, 63, 23),RGB( 16, 63, 16),RGB( 8, 63, 8),
20 | RGB( 0, 63, 0),RGB( 0, 63, 0),RGB( 0, 59, 0),RGB( 0, 56, 0),RGB( 0, 53, 0),
21 | RGB( 1, 50, 0),RGB( 1, 47, 0),RGB( 1, 44, 0),RGB( 1, 41, 0),RGB( 1, 38, 0),
22 | RGB( 1, 34, 0),RGB( 1, 31, 0),RGB( 1, 28, 0),RGB( 1, 25, 0),RGB( 1, 22, 0),
23 | RGB( 1, 19, 0),RGB( 1, 16, 0),RGB( 54, 63, 63),RGB( 46, 63, 63),RGB( 39, 63, 63),
24 | RGB( 31, 63, 62),RGB( 23, 63, 63),RGB( 16, 63, 63),RGB( 8, 63, 63),RGB( 0, 63, 63),
25 | RGB( 0, 57, 57),RGB( 0, 51, 51),RGB( 0, 45, 45),RGB( 0, 39, 39),RGB( 0, 33, 33),
26 | RGB( 0, 28, 28),RGB( 0, 22, 22),RGB( 0, 16, 16),RGB( 23, 47, 63),RGB( 16, 44, 63),
27 | RGB( 8, 42, 63),RGB( 0, 39, 63),RGB( 0, 35, 57),RGB( 0, 31, 51),RGB( 0, 27, 45),
28 | RGB( 0, 23, 39),RGB( 54, 54, 63),RGB( 46, 47, 63),RGB( 39, 39, 63),RGB( 31, 32, 63),
29 | RGB( 23, 24, 63),RGB( 16, 16, 63),RGB( 8, 9, 63),RGB( 0, 1, 63),RGB( 0, 0, 63),
30 | RGB( 0, 0, 59),RGB( 0, 0, 56),RGB( 0, 0, 53),RGB( 0, 0, 50),RGB( 0, 0, 47),
31 | RGB( 0, 0, 44),RGB( 0, 0, 41),RGB( 0, 0, 38),RGB( 0, 0, 34),RGB( 0, 0, 31),
32 | RGB( 0, 0, 28),RGB( 0, 0, 25),RGB( 0, 0, 22),RGB( 0, 0, 19),RGB( 0, 0, 16),
33 | RGB( 10, 10, 10),RGB( 63, 56, 13),RGB( 63, 53, 9),RGB( 63, 51, 6),RGB( 63, 48, 2),
34 | RGB( 63, 45, 0),RGB( 0, 14, 0),RGB( 0, 10, 0),RGB( 38, 0, 57),RGB( 32, 0, 51),
35 | RGB( 29, 0, 45),RGB( 24, 0, 39),RGB( 20, 0, 33),RGB( 17, 0, 28),RGB( 13, 0, 22),
36 | RGB( 10, 0, 16),RGB( 63, 54, 63),RGB( 63, 46, 63),RGB( 63, 39, 63),RGB( 63, 31, 63),
37 | RGB( 63, 23, 63),RGB( 63, 16, 63),RGB( 63, 8, 63),RGB( 63, 0, 63),RGB( 56, 0, 57),
38 | RGB( 50, 0, 51),RGB( 45, 0, 45),RGB( 39, 0, 39),RGB( 33, 0, 33),RGB( 27, 0, 28),
39 | RGB( 22, 0, 22),RGB( 16, 0, 16),RGB( 63, 58, 55),RGB( 63, 56, 52),RGB( 63, 54, 49),
40 | RGB( 63, 53, 47),RGB( 63, 51, 44),RGB( 63, 49, 41),RGB( 63, 47, 39),RGB( 63, 46, 36),
41 | RGB( 63, 44, 32),RGB( 63, 41, 28),RGB( 63, 39, 24),RGB( 60, 37, 23),RGB( 58, 35, 22),
42 | RGB( 55, 34, 21),RGB( 52, 32, 20),RGB( 50, 31, 19),RGB( 47, 30, 18),RGB( 45, 28, 17),
43 | RGB( 42, 26, 16),RGB( 40, 25, 15),RGB( 39, 24, 14),RGB( 36, 23, 13),RGB( 34, 22, 12),
44 | RGB( 32, 20, 11),RGB( 29, 19, 10),RGB( 27, 18, 9),RGB( 23, 16, 8),RGB( 21, 15, 7),
45 | RGB( 18, 14, 6),RGB( 16, 12, 6),RGB( 14, 11, 5),RGB( 10, 8, 3),RGB( 24, 0, 25),
46 | RGB( 0, 25, 25),RGB( 0, 24, 24),RGB( 0, 0, 7),RGB( 0, 0, 11),RGB( 12, 9, 4),
47 | RGB( 18, 0, 18),RGB( 20, 0, 20),RGB( 0, 0, 13),RGB( 7, 7, 7),RGB( 19, 19, 19),
48 | RGB( 23, 23, 23),RGB( 16, 16, 16),RGB( 12, 12, 12),RGB( 13, 13, 13),RGB( 54, 61, 61),
49 | RGB( 46, 58, 58),RGB( 39, 55, 55),RGB( 29, 50, 50),RGB( 18, 48, 48),RGB( 8, 45, 45),
50 | RGB( 8, 44, 44),RGB( 0, 41, 41),RGB( 0, 38, 38),RGB( 0, 35, 35),RGB( 0, 33, 33),
51 | RGB( 0, 31, 31),RGB( 0, 30, 30),RGB( 0, 29, 29),RGB( 0, 28, 28),RGB( 0, 27, 27),
52 | RGB( 38, 0, 34)
53 |
--------------------------------------------------------------------------------
/wolfpal.inc:
--------------------------------------------------------------------------------
1 | RGB( 0, 0, 0),RGB( 0, 0, 42),RGB( 0, 42, 0),RGB( 0, 42, 42),RGB( 42, 0, 0),
2 | RGB( 42, 0, 42),RGB( 42, 21, 0),RGB( 42, 42, 42),RGB( 21, 21, 21),RGB( 21, 21, 63),
3 | RGB( 21, 63, 21),RGB( 21, 63, 63),RGB( 63, 21, 21),RGB( 63, 21, 63),RGB( 63, 63, 21),
4 | RGB( 63, 63, 63),RGB( 59, 59, 59),RGB( 55, 55, 55),RGB( 52, 52, 52),RGB( 48, 48, 48),
5 | RGB( 45, 45, 45),RGB( 42, 42, 42),RGB( 38, 38, 38),RGB( 35, 35, 35),RGB( 31, 31, 31),
6 | RGB( 28, 28, 28),RGB( 25, 25, 25),RGB( 21, 21, 21),RGB( 18, 18, 18),RGB( 14, 14, 14),
7 | RGB( 11, 11, 11),RGB( 8, 8, 8),RGB( 63, 0, 0),RGB( 59, 0, 0),RGB( 56, 0, 0),
8 | RGB( 53, 0, 0),RGB( 50, 0, 0),RGB( 47, 0, 0),RGB( 44, 0, 0),RGB( 41, 0, 0),
9 | RGB( 38, 0, 0),RGB( 34, 0, 0),RGB( 31, 0, 0),RGB( 28, 0, 0),RGB( 25, 0, 0),
10 | RGB( 22, 0, 0),RGB( 19, 0, 0),RGB( 16, 0, 0),RGB( 63, 54, 54),RGB( 63, 46, 46),
11 | RGB( 63, 39, 39),RGB( 63, 31, 31),RGB( 63, 23, 23),RGB( 63, 16, 16),RGB( 63, 8, 8),
12 | RGB( 63, 0, 0),RGB( 63, 42, 23),RGB( 63, 38, 16),RGB( 63, 34, 8),RGB( 63, 30, 0),
13 | RGB( 57, 27, 0),RGB( 51, 24, 0),RGB( 45, 21, 0),RGB( 39, 19, 0),RGB( 63, 63, 54),
14 | RGB( 63, 63, 46),RGB( 63, 63, 39),RGB( 63, 63, 31),RGB( 63, 62, 23),RGB( 63, 61, 16),
15 | RGB( 63, 61, 8),RGB( 63, 61, 0),RGB( 57, 54, 0),RGB( 51, 49, 0),RGB( 45, 43, 0),
16 | RGB( 39, 39, 0),RGB( 33, 33, 0),RGB( 28, 27, 0),RGB( 22, 21, 0),RGB( 16, 16, 0),
17 | RGB( 52, 63, 23),RGB( 49, 63, 16),RGB( 45, 63, 8),RGB( 40, 63, 0),RGB( 36, 57, 0),
18 | RGB( 32, 51, 0),RGB( 29, 45, 0),RGB( 24, 39, 0),RGB( 54, 63, 54),RGB( 47, 63, 46),
19 | RGB( 39, 63, 39),RGB( 32, 63, 31),RGB( 24, 63, 23),RGB( 16, 63, 16),RGB( 8, 63, 8),
20 | RGB( 0, 63, 0),RGB( 0, 63, 0),RGB( 0, 59, 0),RGB( 0, 56, 0),RGB( 0, 53, 0),
21 | RGB( 1, 50, 0),RGB( 1, 47, 0),RGB( 1, 44, 0),RGB( 1, 41, 0),RGB( 1, 38, 0),
22 | RGB( 1, 34, 0),RGB( 1, 31, 0),RGB( 1, 28, 0),RGB( 1, 25, 0),RGB( 1, 22, 0),
23 | RGB( 1, 19, 0),RGB( 1, 16, 0),RGB( 54, 63, 63),RGB( 46, 63, 63),RGB( 39, 63, 63),
24 | RGB( 31, 63, 62),RGB( 23, 63, 63),RGB( 16, 63, 63),RGB( 8, 63, 63),RGB( 0, 63, 63),
25 | RGB( 0, 57, 57),RGB( 0, 51, 51),RGB( 0, 45, 45),RGB( 0, 39, 39),RGB( 0, 33, 33),
26 | RGB( 0, 28, 28),RGB( 0, 22, 22),RGB( 0, 16, 16),RGB( 23, 47, 63),RGB( 16, 44, 63),
27 | RGB( 8, 42, 63),RGB( 0, 39, 63),RGB( 0, 35, 57),RGB( 0, 31, 51),RGB( 0, 27, 45),
28 | RGB( 0, 23, 39),RGB( 54, 54, 63),RGB( 46, 47, 63),RGB( 39, 39, 63),RGB( 31, 32, 63),
29 | RGB( 23, 24, 63),RGB( 16, 16, 63),RGB( 8, 9, 63),RGB( 0, 1, 63),RGB( 0, 0, 63),
30 | RGB( 0, 0, 59),RGB( 0, 0, 56),RGB( 0, 0, 53),RGB( 0, 0, 50),RGB( 0, 0, 47),
31 | RGB( 0, 0, 44),RGB( 0, 0, 41),RGB( 0, 0, 38),RGB( 0, 0, 34),RGB( 0, 0, 31),
32 | RGB( 0, 0, 28),RGB( 0, 0, 25),RGB( 0, 0, 22),RGB( 0, 0, 19),RGB( 0, 0, 16),
33 | RGB( 10, 10, 10),RGB( 63, 56, 13),RGB( 63, 53, 9),RGB( 63, 51, 6),RGB( 63, 48, 2),
34 | RGB( 63, 45, 0),RGB( 45, 8, 63),RGB( 42, 0, 63),RGB( 38, 0, 57),RGB( 32, 0, 51),
35 | RGB( 29, 0, 45),RGB( 24, 0, 39),RGB( 20, 0, 33),RGB( 17, 0, 28),RGB( 13, 0, 22),
36 | RGB( 10, 0, 16),RGB( 63, 54, 63),RGB( 63, 46, 63),RGB( 63, 39, 63),RGB( 63, 31, 63),
37 | RGB( 63, 23, 63),RGB( 63, 16, 63),RGB( 63, 8, 63),RGB( 63, 0, 63),RGB( 56, 0, 57),
38 | RGB( 50, 0, 51),RGB( 45, 0, 45),RGB( 39, 0, 39),RGB( 33, 0, 33),RGB( 27, 0, 28),
39 | RGB( 22, 0, 22),RGB( 16, 0, 16),RGB( 63, 58, 55),RGB( 63, 56, 52),RGB( 63, 54, 49),
40 | RGB( 63, 53, 47),RGB( 63, 51, 44),RGB( 63, 49, 41),RGB( 63, 47, 39),RGB( 63, 46, 36),
41 | RGB( 63, 44, 32),RGB( 63, 41, 28),RGB( 63, 39, 24),RGB( 60, 37, 23),RGB( 58, 35, 22),
42 | RGB( 55, 34, 21),RGB( 52, 32, 20),RGB( 50, 31, 19),RGB( 47, 30, 18),RGB( 45, 28, 17),
43 | RGB( 42, 26, 16),RGB( 40, 25, 15),RGB( 39, 24, 14),RGB( 36, 23, 13),RGB( 34, 22, 12),
44 | RGB( 32, 20, 11),RGB( 29, 19, 10),RGB( 27, 18, 9),RGB( 23, 16, 8),RGB( 21, 15, 7),
45 | RGB( 18, 14, 6),RGB( 16, 12, 6),RGB( 14, 11, 5),RGB( 10, 8, 3),RGB( 24, 0, 25),
46 | RGB( 0, 25, 25),RGB( 0, 24, 24),RGB( 0, 0, 7),RGB( 0, 0, 11),RGB( 12, 9, 4),
47 | RGB( 18, 0, 18),RGB( 20, 0, 20),RGB( 0, 0, 13),RGB( 7, 7, 7),RGB( 19, 19, 19),
48 | RGB( 23, 23, 23),RGB( 16, 16, 16),RGB( 12, 12, 12),RGB( 13, 13, 13),RGB( 54, 61, 61),
49 | RGB( 46, 58, 58),RGB( 39, 55, 55),RGB( 29, 50, 50),RGB( 18, 48, 48),RGB( 8, 45, 45),
50 | RGB( 8, 44, 44),RGB( 0, 41, 41),RGB( 0, 38, 38),RGB( 0, 35, 35),RGB( 0, 33, 33),
51 | RGB( 0, 31, 31),RGB( 0, 30, 30),RGB( 0, 29, 29),RGB( 0, 28, 28),RGB( 0, 27, 27),
52 | RGB( 38, 0, 34)
53 |
--------------------------------------------------------------------------------
/crt.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // crt.c
3 | // Chocolate Wolfenstein 3D
4 | //
5 | // Created by fabien sanglard on 2014-08-26.
6 | //
7 | //
8 |
9 | #include "crt.h"
10 |
11 | // Win32
12 | #ifdef _WIN32
13 | #include "SDL.h"
14 | #elif __linux__
15 | #include "SDL/SDL.h"
16 | #else
17 | #include "SDL/SDL.h"
18 | #endif
19 |
20 | static int width;
21 | static int height;
22 |
23 | GLuint crtTexture;
24 |
25 | unsigned char coloredFrameBuffer[320*200*3];
26 |
27 | void CRT_Init(int _width){
28 | width = _width;
29 | height = _width * 3.0/4.0;
30 |
31 | //Alloc the OpenGL texture where the screen will be uploaded each frame.
32 | glGenTextures(1, &crtTexture);
33 | glBindTexture(GL_TEXTURE_2D, crtTexture);
34 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
35 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
36 | glTexImage2D(
37 | GL_TEXTURE_2D, // target
38 | 0, // level, 0 = base, no minimap,
39 | GL_RGB, // internalformat
40 | 320, // width
41 | 200, // height
42 | 0, // border, always 0 in OpenGL ES
43 | GL_RGB, // format
44 | GL_UNSIGNED_BYTE, // type
45 | 0
46 | );
47 |
48 | glMatrixMode (GL_PROJECTION);
49 | glLoadIdentity();
50 | glOrtho(0, width, 0, height, -1, 1);
51 | glMatrixMode (GL_MODELVIEW);
52 | glLoadIdentity();
53 |
54 | glEnable(GL_TEXTURE_2D);
55 | glDisable(GL_DEPTH_TEST);
56 |
57 | glClearColor(0, 0, 0, 0);
58 | glClear(GL_COLOR_BUFFER_BIT);
59 | SDL_GL_SwapBuffers();
60 | }
61 |
62 | #include "id_vl.h"
63 | void CRT_DAC(void){
64 | // Grab the screen framebuffer from SDL
65 | SDL_Surface *screen = screenBuffer ;
66 |
67 | //Convert palette based framebuffer to RGB for OpenGL
68 | byte* pixelPointer = coloredFrameBuffer;
69 | for (int i=0; i < 320*200; i++) {
70 | unsigned char paletteIndex;
71 | paletteIndex = ((byte*)screen->pixels)[i];
72 | *pixelPointer++ = curpal[paletteIndex].r;
73 | *pixelPointer++ = curpal[paletteIndex].g;
74 | *pixelPointer++ = curpal[paletteIndex].b;
75 | }
76 |
77 |
78 | //Upload texture
79 | glBindTexture(GL_TEXTURE_2D, crtTexture);
80 | glTexSubImage2D(GL_TEXTURE_2D,
81 | 0,
82 | 0,
83 | 0,
84 | 320,
85 | 200,
86 | GL_RGB,
87 | GL_UNSIGNED_BYTE,
88 | coloredFrameBuffer);
89 |
90 | //Draw a quad with the texture
91 | glBegin(GL_QUADS);
92 | glTexCoord2f(0, 1); glVertex3i(0,0,0);
93 | glTexCoord2f(0, 0); glVertex3i(0,height,0);
94 | glTexCoord2f(1, 0); glVertex3i(width,height,0);
95 | glTexCoord2f(1, 1); glVertex3i(width,0,0);
96 | glEnd();
97 |
98 |
99 | //Flip buffer
100 | SDL_GL_SwapBuffers();
101 |
102 | Uint8 *keystate = SDL_GetKeyState(NULL);
103 | static int wasPressed = 0;
104 | if ( keystate[SDLK_i] ){
105 | if (!wasPressed){
106 | wasPressed = 1;
107 | CRT_Screenshot();
108 | }
109 | }
110 | else
111 | wasPressed = 0;
112 | }
113 |
114 | void CRT_Screenshot(void){
115 |
116 | const char* filename = "screenshot.tga" ;
117 |
118 | printf("Screenshot.\n");
119 |
120 | //This prevents the images getting padded
121 | // when the width multiplied by 3 is not a multiple of 4
122 | glPixelStorei(GL_PACK_ALIGNMENT, 1);
123 |
124 | int nSize = width*height*3;
125 | // First let's create our buffer, 3 channels per Pixel
126 | char* dataBuffer = (char*)malloc(nSize*sizeof(char));
127 |
128 | if (!dataBuffer) return;
129 |
130 | // Let's fetch them from the backbuffer
131 | // We request the pixels in GL_BGR format
132 | #define GL_BGR 0x80E0
133 | glReadPixels((GLint)0, (GLint)0,(GLint)width, (GLint)height, GL_BGR, GL_UNSIGNED_BYTE, dataBuffer);
134 |
135 | //Now the file creation
136 | FILE *filePtr = fopen(filename, "wb");
137 | if (!filePtr) return;
138 |
139 |
140 | unsigned char TGAheader[12]={0,0,2,0,0,0,0,0,0,0,0,0};
141 | unsigned char header[6] = { width%256,width/256,height%256,height/256,24,0};
142 |
143 | // We write the headers
144 | fwrite(TGAheader, sizeof(unsigned char), 12, filePtr);
145 | fwrite(header, sizeof(unsigned char), 6, filePtr);
146 | // And finally our image data
147 | fwrite(dataBuffer, sizeof(GLubyte), nSize, filePtr);
148 | fclose(filePtr);
149 | }
--------------------------------------------------------------------------------
/audiosod.h:
--------------------------------------------------------------------------------
1 | /////////////////////////////////////////////////
2 | //
3 | // MUSE Header for .SOD
4 | // Created Thu Aug 13 09:25:58 1992
5 | //
6 | /////////////////////////////////////////////////
7 |
8 | #define NUMSOUNDS 81
9 | #define NUMSNDCHUNKS 267
10 |
11 | //
12 | // Sound names & indexes
13 | //
14 | typedef enum {
15 | HITWALLSND, // 0
16 | MISSILEHITSND, // 1
17 | SELECTITEMSND, // 2
18 | GHOSTSIGHTSND, // 3
19 | MOVEGUN2SND, // 4
20 | MOVEGUN1SND, // 5
21 | NOWAYSND, // 6
22 | NAZIHITPLAYERSND, // 7
23 | MISSILEFIRESND, // 8
24 | PLAYERDEATHSND, // 9
25 | DOGDEATHSND, // 10
26 | ATKGATLINGSND, // 11
27 | GETKEYSND, // 12
28 | NOITEMSND, // 13
29 | WALK1SND, // 14
30 | WALK2SND, // 15
31 | TAKEDAMAGESND, // 16
32 | GAMEOVERSND, // 17
33 | OPENDOORSND, // 18
34 | CLOSEDOORSND, // 19
35 | DONOTHINGSND, // 20
36 | HALTSND, // 21
37 | DEATHSCREAM2SND, // 22
38 | ATKKNIFESND, // 23
39 | ATKPISTOLSND, // 24
40 | DEATHSCREAM3SND, // 25
41 | ATKMACHINEGUNSND, // 26
42 | HITENEMYSND, // 27
43 | SHOOTDOORSND, // 28
44 | DEATHSCREAM1SND, // 29
45 | GETMACHINESND, // 30
46 | GETAMMOSND, // 31
47 | SHOOTSND, // 32
48 | HEALTH1SND, // 33
49 | HEALTH2SND, // 34
50 | BONUS1SND, // 35
51 | BONUS2SND, // 36
52 | BONUS3SND, // 37
53 | GETGATLINGSND, // 38
54 | ESCPRESSEDSND, // 39
55 | LEVELDONESND, // 40
56 | DOGBARKSND, // 41
57 | ENDBONUS1SND, // 42
58 | ENDBONUS2SND, // 43
59 | BONUS1UPSND, // 44
60 | BONUS4SND, // 45
61 | PUSHWALLSND, // 46
62 | NOBONUSSND, // 47
63 | PERCENT100SND, // 48
64 | BOSSACTIVESND, // 49
65 | DEATHSCREAM4SND, // 50
66 | SCHUTZADSND, // 51
67 | AHHHGSND, // 52
68 | DEATHSCREAM5SND, // 53
69 | DEATHSCREAM7SND, // 54
70 | DEATHSCREAM8SND, // 55
71 | LEBENSND, // 56
72 | DEATHSCREAM6SND, // 57
73 | NAZIFIRESND, // 58
74 | BOSSFIRESND, // 59
75 | SSFIRESND, // 60
76 | SLURPIESND, // 61
77 | GHOSTFADESND, // 62
78 | DEATHSCREAM9SND, // 63
79 | GETAMMOBOXSND, // 64
80 | ANGELSIGHTSND, // 65
81 | SPIONSND, // 66
82 | NEINSOVASSND, // 67
83 | DOGATTACKSND, // 68
84 | ANGELFIRESND, // 69
85 | TRANSSIGHTSND, // 70
86 | TRANSDEATHSND, // 71
87 | WILHELMSIGHTSND, // 72
88 | WILHELMDEATHSND, // 73
89 | UBERDEATHSND, // 74
90 | KNIGHTSIGHTSND, // 75
91 | KNIGHTDEATHSND, // 76
92 | ANGELDEATHSND, // 77
93 | KNIGHTMISSILESND, // 78
94 | GETSPEARSND, // 79
95 | ANGELTIREDSND, // 80
96 | LASTSOUND
97 | } soundnames;
98 |
99 | //
100 | // Base offsets
101 | //
102 | #define STARTPCSOUNDS 0
103 | #define STARTADLIBSOUNDS 81
104 | #define STARTDIGISOUNDS 162
105 | #define STARTMUSIC 243
106 |
107 | //
108 | // Music names & indexes
109 | //
110 | typedef enum {
111 | XFUNKIE_MUS, // 0
112 | DUNGEON_MUS, // 1
113 | XDEATH_MUS, // 2
114 | GETTHEM_MUS, // 3
115 | XTIPTOE_MUS, // 4
116 | GOINGAFT_MUS, // 5
117 | URAHERO_MUS, // 6
118 | XTHEEND_MUS, // 7
119 | NAZI_OMI_MUS, // 8
120 | POW_MUS, // 9
121 | TWELFTH_MUS, // 10
122 | SEARCHN_MUS, // 11
123 | SUSPENSE_MUS, // 12
124 | ZEROHOUR_MUS, // 13
125 | WONDERIN_MUS, // 14
126 | ULTIMATE_MUS, // 15
127 | ENDLEVEL_MUS, // 16
128 | XEVIL_MUS, // 17
129 | XJAZNAZI_MUS, // 18
130 | COPYPRO_MUS, // 19
131 | XAWARD_MUS, // 20
132 | XPUTIT_MUS, // 21
133 | XGETYOU_MUS, // 22
134 | XTOWER2_MUS, // 23
135 | LASTMUSIC
136 | } musicnames;
137 |
138 | /////////////////////////////////////////////////
139 | //
140 | // Thanks for playing with MUSE!
141 | //
142 | /////////////////////////////////////////////////
143 |
--------------------------------------------------------------------------------
/audiowl6.h:
--------------------------------------------------------------------------------
1 | /////////////////////////////////////////////////
2 | //
3 | // MUSE Header for .WL6
4 | // Created Tue Jul 14 15:04:53 1992
5 | //
6 | /////////////////////////////////////////////////
7 |
8 | //
9 | // Sound names & indexes
10 | //
11 | typedef enum {
12 | HITWALLSND, // 0
13 | SELECTWPNSND, // 1
14 | SELECTITEMSND, // 2
15 | HEARTBEATSND, // 3
16 | MOVEGUN2SND, // 4
17 | MOVEGUN1SND, // 5
18 | NOWAYSND, // 6
19 | NAZIHITPLAYERSND, // 7
20 | SCHABBSTHROWSND, // 8
21 | PLAYERDEATHSND, // 9
22 | DOGDEATHSND, // 10
23 | ATKGATLINGSND, // 11
24 | GETKEYSND, // 12
25 | NOITEMSND, // 13
26 | WALK1SND, // 14
27 | WALK2SND, // 15
28 | TAKEDAMAGESND, // 16
29 | GAMEOVERSND, // 17
30 | OPENDOORSND, // 18
31 | CLOSEDOORSND, // 19
32 | DONOTHINGSND, // 20
33 | HALTSND, // 21
34 | DEATHSCREAM2SND, // 22
35 | ATKKNIFESND, // 23
36 | ATKPISTOLSND, // 24
37 | DEATHSCREAM3SND, // 25
38 | ATKMACHINEGUNSND, // 26
39 | HITENEMYSND, // 27
40 | SHOOTDOORSND, // 28
41 | DEATHSCREAM1SND, // 29
42 | GETMACHINESND, // 30
43 | GETAMMOSND, // 31
44 | SHOOTSND, // 32
45 | HEALTH1SND, // 33
46 | HEALTH2SND, // 34
47 | BONUS1SND, // 35
48 | BONUS2SND, // 36
49 | BONUS3SND, // 37
50 | GETGATLINGSND, // 38
51 | ESCPRESSEDSND, // 39
52 | LEVELDONESND, // 40
53 | DOGBARKSND, // 41
54 | ENDBONUS1SND, // 42
55 | ENDBONUS2SND, // 43
56 | BONUS1UPSND, // 44
57 | BONUS4SND, // 45
58 | PUSHWALLSND, // 46
59 | NOBONUSSND, // 47
60 | PERCENT100SND, // 48
61 | BOSSACTIVESND, // 49
62 | MUTTISND, // 50
63 | SCHUTZADSND, // 51
64 | AHHHGSND, // 52
65 | DIESND, // 53
66 | EVASND, // 54
67 | GUTENTAGSND, // 55
68 | LEBENSND, // 56
69 | SCHEISTSND, // 57
70 | NAZIFIRESND, // 58
71 | BOSSFIRESND, // 59
72 | SSFIRESND, // 60
73 | SLURPIESND, // 61
74 | TOT_HUNDSND, // 62
75 | MEINGOTTSND, // 63
76 | SCHABBSHASND, // 64
77 | HITLERHASND, // 65
78 | SPIONSND, // 66
79 | NEINSOVASSND, // 67
80 | DOGATTACKSND, // 68
81 | FLAMETHROWERSND, // 69
82 | MECHSTEPSND, // 70
83 | GOOBSSND, // 71
84 | YEAHSND, // 72
85 | #ifndef APOGEE_1_0
86 | DEATHSCREAM4SND, // 73
87 | DEATHSCREAM5SND, // 74
88 | DEATHSCREAM6SND, // 75
89 | DEATHSCREAM7SND, // 76
90 | DEATHSCREAM8SND, // 77
91 | DEATHSCREAM9SND, // 78
92 | DONNERSND, // 79
93 | EINESND, // 80
94 | ERLAUBENSND, // 81
95 | KEINSND, // 82
96 | MEINSND, // 83
97 | ROSESND, // 84
98 | MISSILEFIRESND, // 85
99 | MISSILEHITSND, // 86
100 | #endif
101 | LASTSOUND
102 | } soundnames;
103 |
104 | //
105 | // Base offsets
106 | //
107 | #define STARTPCSOUNDS 0
108 | #define STARTADLIBSOUNDS LASTSOUND
109 | #define STARTDIGISOUNDS (2*LASTSOUND)
110 | #define STARTMUSIC (3*LASTSOUND)
111 |
112 | //
113 | // Music names & indexes
114 | //
115 | typedef enum {
116 | CORNER_MUS, // 0
117 | DUNGEON_MUS, // 1
118 | WARMARCH_MUS, // 2
119 | GETTHEM_MUS, // 3
120 | HEADACHE_MUS, // 4
121 | HITLWLTZ_MUS, // 5
122 | INTROCW3_MUS, // 6
123 | NAZI_NOR_MUS, // 7
124 | NAZI_OMI_MUS, // 8
125 | POW_MUS, // 9
126 | SALUTE_MUS, // 10
127 | SEARCHN_MUS, // 11
128 | SUSPENSE_MUS, // 12
129 | VICTORS_MUS, // 13
130 | WONDERIN_MUS, // 14
131 | FUNKYOU_MUS, // 15
132 | ENDLEVEL_MUS, // 16
133 | GOINGAFT_MUS, // 17
134 | PREGNANT_MUS, // 18
135 | ULTIMATE_MUS, // 19
136 | NAZI_RAP_MUS, // 20
137 | ZEROHOUR_MUS, // 21
138 | TWELFTH_MUS, // 22
139 | ROSTER_MUS, // 23
140 | URAHERO_MUS, // 24
141 | VICMARCH_MUS, // 25
142 | PACMAN_MUS, // 26
143 | LASTMUSIC
144 | } musicnames;
145 |
146 | #define NUMSOUNDS LASTSOUND
147 | #define NUMSNDCHUNKS (STARTMUSIC + LASTMUSIC)
148 |
149 | /////////////////////////////////////////////////
150 | //
151 | // Thanks for playing with MUSE!
152 | //
153 | /////////////////////////////////////////////////
154 |
--------------------------------------------------------------------------------
/foreign.h:
--------------------------------------------------------------------------------
1 | #define QUITSUR "Are you sure you want\n"\
2 | "to quit this great game?"
3 |
4 | #define CURGAME "You are currently in\n"\
5 | "a game. Continuing will\n"\
6 | "erase old game. Ok?"
7 |
8 | #define GAMESVD "There's already a game\n"\
9 | "saved at this position.\n"\
10 | " Overwrite?"
11 |
12 | #define ENDGAMESTR "Are you sure you want\n"\
13 | "to end the game you\n"\
14 | "are playing? (Y or N):"
15 |
16 | #define STR_NG "New Game"
17 | #define STR_SD "Sound"
18 | #define STR_CL "Control"
19 | #define STR_LG "Load Game"
20 | #define STR_SG "Save Game"
21 | #define STR_CV "Change View"
22 | #define STR_VS "View Scores"
23 | #define STR_EG "End Game"
24 | #define STR_BD "Back to Demo"
25 | #define STR_QT "Quit"
26 |
27 | #define STR_LOADING "Loading"
28 | #define STR_SAVING "Saving"
29 |
30 | #define STR_GAME "Game"
31 | #define STR_DEMO "Demo"
32 | #define STR_LGC "Load Game called\n\""
33 | #define STR_EMPTY "empty"
34 | #define STR_CALIB "Calibrate"
35 | #define STR_JOYST "Joystick"
36 | #define STR_MOVEJOY "Move joystick to\nupper left and\npress button 0\n"
37 | #define STR_MOVEJOY2 "Move joystick to\nlower right and\npress button 1\n"
38 | #define STR_ESCEXIT "ESC to exit"
39 |
40 | #define STR_NONE "None"
41 | #define STR_PC "PC Speaker"
42 | #define STR_ALSB "AdLib/Sound Blaster"
43 | #define STR_DISNEY "Disney Sound Source"
44 | #define STR_SB "Sound Blaster"
45 |
46 | #define STR_MOUSEEN "Mouse Enabled"
47 | #define STR_JOYEN "Joystick Enabled"
48 | #define STR_PORT2 "Use joystick port 2"
49 | #define STR_GAMEPAD "Gravis GamePad Enabled"
50 | #define STR_SENS "Mouse Sensitivity"
51 | #define STR_CUSTOM "Customize controls"
52 |
53 | #define STR_DADDY "Can I play, Daddy?"
54 | #define STR_HURTME "Don't hurt me."
55 | #define STR_BRINGEM "Bring 'em on!"
56 | #define STR_DEATH "I am Death incarnate!"
57 |
58 | #define STR_MOUSEADJ "Adjust Mouse Sensitivity"
59 | #define STR_SLOW "Slow"
60 | #define STR_FAST "Fast"
61 |
62 | #define STR_CRUN "Run"
63 | #define STR_COPEN "Open"
64 | #define STR_CFIRE "Fire"
65 | #define STR_CSTRAFE "Strafe"
66 |
67 | #define STR_LEFT "Left"
68 | #define STR_RIGHT "Right"
69 | #define STR_FRWD "Frwd"
70 | #define STR_BKWD "Bkwrd"
71 | #define STR_THINK "Thinking"
72 |
73 | #define STR_SIZE1 "Use arrows to size"
74 | #define STR_SIZE2 "ENTER to accept"
75 | #define STR_SIZE3 "ESC to cancel"
76 |
77 | #define STR_YOUWIN "you win!"
78 |
79 | #define STR_TOTALTIME "total time"
80 |
81 | #define STR_RATKILL "kill %"
82 | #define STR_RATSECRET "secret %"
83 | #define STR_RATTREASURE "treasure %"
84 |
85 | #define STR_BONUS "bonus"
86 | #define STR_TIME "time"
87 | #define STR_PAR " par"
88 |
89 | #define STR_RAT2KILL "kill ratio %"
90 | #define STR_RAT2SECRET "secret ratio %"
91 | #define STR_RAT2TREASURE "treasure ratio %"
92 |
93 | #define STR_DEFEATED "defeated!"
94 |
95 | #define STR_CHEATER1 "You now have 100% Health,"
96 | #define STR_CHEATER2 "99 Ammo and both Keys!"
97 | #define STR_CHEATER3 "Note that you have basically"
98 | #define STR_CHEATER4 "eliminated your chances of"
99 | #define STR_CHEATER5 "getting a high score!"
100 |
101 | #define STR_NOSPACE1 "There is not enough space"
102 | #define STR_NOSPACE2 "on your disk to Save Game!"
103 |
104 | #define STR_SAVECHT1 "Your Save Game file is,"
105 | #define STR_SAVECHT2 "shall we say, \"corrupted\"."
106 | #define STR_SAVECHT3 "But I'll let you go on and"
107 | #define STR_SAVECHT4 "play anyway...."
108 |
109 | #define STR_SEEAGAIN "Let's see that again!"
110 |
111 | #ifdef SPEAR
112 | #define ENDSTR1 "Heroes don't quit, but\ngo ahead and press " YESBUTTONNAME "\nif you aren't one."
113 | #define ENDSTR2 "Press " YESBUTTONNAME " to quit,\nor press " NOBUTTONNAME " to enjoy\nmore violent diversion."
114 | #define ENDSTR3 "Depressing the " YESBUTTONNAME " key means\nyou must return to the\nhumdrum workday world."
115 | #define ENDSTR4 "Hey, quit or play,\n" YESBUTTONNAME " or " NOBUTTONNAME ":\nit's your choice."
116 | #define ENDSTR5 "Sure you don't want to\nwaste a few more\nproductive hours?"
117 | #define ENDSTR6 "I think you had better\nplay some more. Please\npress " NOBUTTONNAME "...please?"
118 | #define ENDSTR7 "If you are tough, press " NOBUTTONNAME ".\nIf not, press " YESBUTTONNAME " daintily."
119 | #define ENDSTR8 "I'm thinkin' that\nyou might wanna press " NOBUTTONNAME "\nto play more. You do it."
120 | #define ENDSTR9 "Sure. Fine. Quit.\nSee if we care.\nGet it over with.\nPress " YESBUTTONNAME "."
121 | #else
122 | #define ENDSTR1 "Dost thou wish to\nleave with such hasty\nabandon?"
123 | #define ENDSTR2 "Chickening out...\nalready?"
124 | #define ENDSTR3 "Press " NOBUTTONNAME " for more carnage.\nPress " YESBUTTONNAME " to be a weenie."
125 | #define ENDSTR4 "So, you think you can\nquit this easily, huh?"
126 | #define ENDSTR5 "Press " NOBUTTONNAME " to save the world.\nPress " YESBUTTONNAME " to abandon it in\nits hour of need."
127 | #define ENDSTR6 "Press " NOBUTTONNAME " if you are brave.\nPress " YESBUTTONNAME " to cower in shame."
128 | #define ENDSTR7 "Heroes, press " NOBUTTONNAME ".\nWimps, press " YESBUTTONNAME "."
129 | #define ENDSTR8 "You are at an intersection.\nA sign says, 'Press " YESBUTTONNAME " to quit.'\n>"
130 | #define ENDSTR9 "For guns and glory, press " NOBUTTONNAME ".\nFor work and worry, press " YESBUTTONNAME "."
131 | #endif
132 |
--------------------------------------------------------------------------------
/wl_menu.h:
--------------------------------------------------------------------------------
1 | //
2 | // WL_MENU.H
3 | //
4 | #ifdef SPEAR
5 |
6 | #define BORDCOLOR 0x99
7 | #define BORD2COLOR 0x93
8 | #define DEACTIVE 0x9b
9 | #define BKGDCOLOR 0x9d
10 | //#define STRIPE 0x9c
11 |
12 | #define MenuFadeOut() VL_FadeOut(0,255,0,0,51,10)
13 |
14 | #else
15 |
16 | #define BORDCOLOR 0x29
17 | #define BORD2COLOR 0x23
18 | #define DEACTIVE 0x2b
19 | #define BKGDCOLOR 0x2d
20 | #define STRIPE 0x2c
21 |
22 | #define MenuFadeOut() VL_FadeOut(0,255,43,0,0,10)
23 |
24 | #endif
25 |
26 | #define READCOLOR 0x4a
27 | #define READHCOLOR 0x47
28 | #define VIEWCOLOR 0x7f
29 | #define TEXTCOLOR 0x17
30 | #define HIGHLIGHT 0x13
31 | #define MenuFadeIn() VL_FadeIn(0,255,gamepal,10)
32 |
33 |
34 | #define MENUSONG WONDERIN_MUS
35 |
36 | #ifndef SPEAR
37 | #define INTROSONG NAZI_NOR_MUS
38 | #else
39 | #define INTROSONG XTOWER2_MUS
40 | #endif
41 |
42 | #define SENSITIVE 60
43 | #define CENTERX ((int) screenWidth / 2)
44 | #define CENTERY ((int) screenHeight / 2)
45 |
46 | #define MENU_X 76
47 | #define MENU_Y 55
48 | #define MENU_W 178
49 | #ifndef SPEAR
50 | #ifndef GOODTIMES
51 | #define MENU_H 13*10+6
52 | #else
53 | #define MENU_H 13*9+6
54 | #endif
55 | #else
56 | #define MENU_H 13*9+6
57 | #endif
58 |
59 | #define SM_X 48
60 | #define SM_W 250
61 |
62 | #define SM_Y1 20
63 | #define SM_H1 4*13-7
64 | #define SM_Y2 SM_Y1+5*13
65 | #define SM_H2 4*13-7
66 | #define SM_Y3 SM_Y2+5*13
67 | #define SM_H3 3*13-7
68 |
69 | #define CTL_X 24
70 | #define CTL_Y 86
71 | #define CTL_W 284
72 | #define CTL_H 60
73 |
74 | #define LSM_X 85
75 | #define LSM_Y 55
76 | #define LSM_W 175
77 | #define LSM_H 10*13+10
78 |
79 | #define NM_X 50
80 | #define NM_Y 100
81 | #define NM_W 225
82 | #define NM_H 13*4+15
83 |
84 | #define NE_X 10
85 | #define NE_Y 23
86 | #define NE_W 320-NE_X*2
87 | #define NE_H 200-NE_Y*2
88 |
89 | #define CST_X 20
90 | #define CST_Y 48
91 | #define CST_START 60
92 | #define CST_SPC 60
93 |
94 |
95 | //
96 | // TYPEDEFS
97 | //
98 | typedef struct {
99 | short x,y,amount,curpos,indent;
100 | } CP_iteminfo;
101 |
102 | typedef struct {
103 | short active;
104 | char string[36];
105 | int (* routine)(int temp1);
106 | } CP_itemtype;
107 |
108 | typedef struct {
109 | short allowed[4];
110 | } CustomCtrls;
111 |
112 | extern CP_itemtype MainMenu[];
113 | extern CP_iteminfo MainItems;
114 |
115 | //
116 | // FUNCTION PROTOTYPES
117 | //
118 |
119 | void US_ControlPanel(ScanCode);
120 |
121 | void EnableEndGameMenuItem();
122 |
123 | void SetupControlPanel(void);
124 | void SetupSaveGames();
125 | void CleanupControlPanel(void);
126 |
127 | void DrawMenu(CP_iteminfo *item_i,CP_itemtype *items);
128 | int HandleMenu(CP_iteminfo *item_i,
129 | CP_itemtype *items,
130 | void (*routine)(int w));
131 | void ClearMScreen(void);
132 | void DrawWindow(int x,int y,int w,int h,int wcolor);
133 | void DrawOutline(int x,int y,int w,int h,int color1,int color2);
134 | void WaitKeyUp(void);
135 | void ReadAnyControl(ControlInfo *ci);
136 | void TicDelay(int count);
137 | void CacheLump(int lumpstart,int lumpend);
138 | void UnCacheLump(int lumpstart,int lumpend);
139 | int StartCPMusic(int song);
140 | int Confirm(const char *string);
141 | void Message(const char *string);
142 | void CheckPause(void);
143 | void ShootSnd(void);
144 | void CheckSecretMissions(void);
145 | void BossKey(void);
146 |
147 | void DrawGun(CP_iteminfo *item_i,CP_itemtype *items,int x,int *y,int which,int basey,void (*routine)(int w));
148 | void DrawHalfStep(int x,int y);
149 | void EraseGun(CP_iteminfo *item_i,CP_itemtype *items,int x,int y,int which);
150 | void SetTextColor(CP_itemtype *items,int hlight);
151 | void DrawMenuGun(CP_iteminfo *iteminfo);
152 | void DrawStripes(int y);
153 |
154 | void DefineMouseBtns(void);
155 | void DefineJoyBtns(void);
156 | void DefineKeyBtns(void);
157 | void DefineKeyMove(void);
158 | void EnterCtrlData(int index,CustomCtrls *cust,void (*DrawRtn)(int),void (*PrintRtn)(int),int type);
159 |
160 | void DrawMainMenu(void);
161 | void DrawSoundMenu(void);
162 | void DrawLoadSaveScreen(int loadsave);
163 | void DrawNewEpisode(void);
164 | void DrawNewGame(void);
165 | void DrawChangeView(int view);
166 | void DrawMouseSens(void);
167 | void DrawCtlScreen(void);
168 | void DrawCustomScreen(void);
169 | void DrawLSAction(int which);
170 | void DrawCustMouse(int hilight);
171 | void DrawCustJoy(int hilight);
172 | void DrawCustKeybd(int hilight);
173 | void DrawCustKeys(int hilight);
174 | void PrintCustMouse(int i);
175 | void PrintCustJoy(int i);
176 | void PrintCustKeybd(int i);
177 | void PrintCustKeys(int i);
178 |
179 | void PrintLSEntry(int w,int color);
180 | void TrackWhichGame(int w);
181 | void DrawNewGameDiff(int w);
182 | void FixupCustom(int w);
183 |
184 | int CP_NewGame(int);
185 | int CP_Sound(int);
186 | int CP_LoadGame(int quick);
187 | int CP_SaveGame(int quick);
188 | int CP_Control(int);
189 | int CP_ChangeView(int);
190 | int CP_ExitOptions(int);
191 | int CP_Quit(int);
192 | int CP_ViewScores(int);
193 | int CP_EndGame(int);
194 | int CP_CheckQuick(ScanCode scancode);
195 | int CustomControls(int);
196 | int MouseSensitivity(int);
197 |
198 | void CheckForEpisodes(void);
199 |
200 | void FreeMusic(void);
201 |
202 |
203 | enum {MOUSE,JOYSTICK,KEYBOARDBTNS,KEYBOARDMOVE}; // FOR INPUT TYPES
204 |
205 | enum menuitems
206 | {
207 | newgame,
208 | soundmenu,
209 | control,
210 | loadgame,
211 | savegame,
212 | changeview,
213 |
214 | #ifndef GOODTIMES
215 | #ifndef SPEAR
216 | readthis,
217 | #endif
218 | #endif
219 |
220 | viewscores,
221 | backtodemo,
222 | quit
223 | };
224 |
225 | //
226 | // WL_INTER
227 | //
228 | typedef struct {
229 | int kill,secret,treasure;
230 | int32_t time;
231 | } LRstruct;
232 |
233 | extern LRstruct LevelRatios[];
234 |
235 | void Write (int x,int y,const char *string);
236 | void NonShareware(void);
237 | int GetYorN(int x,int y,int pic);
238 |
--------------------------------------------------------------------------------
/id_in.h:
--------------------------------------------------------------------------------
1 | //
2 | // ID Engine
3 | // ID_IN.h - Header file for Input Manager
4 | // v1.0d1
5 | // By Jason Blochowiak
6 | //
7 |
8 | #ifndef __ID_IN__
9 | #define __ID_IN__
10 |
11 | #ifdef __DEBUG__
12 | #define __DEBUG_InputMgr__
13 | #endif
14 |
15 | typedef int ScanCode;
16 | #define sc_None 0
17 | #define sc_Bad 0xff
18 | #define sc_Return SDLK_RETURN
19 | #define sc_Enter sc_Return
20 | #define sc_Escape SDLK_ESCAPE
21 | #define sc_Space SDLK_SPACE
22 | #define sc_BackSpace SDLK_BACKSPACE
23 | #define sc_Tab SDLK_TAB
24 | #define sc_Alt SDLK_LALT
25 | #define sc_Control SDLK_LCTRL
26 | #define sc_CapsLock SDLK_CAPSLOCK
27 | #define sc_LShift SDLK_LSHIFT
28 | #define sc_RShift SDLK_RSHIFT
29 | #define sc_UpArrow SDLK_UP
30 | #define sc_DownArrow SDLK_DOWN
31 | #define sc_LeftArrow SDLK_LEFT
32 | #define sc_RightArrow SDLK_RIGHT
33 | #define sc_Insert SDLK_INSERT
34 | #define sc_Delete SDLK_DELETE
35 | #define sc_Home SDLK_HOME
36 | #define sc_End SDLK_END
37 | #define sc_PgUp SDLK_PAGEUP
38 | #define sc_PgDn SDLK_PAGEDOWN
39 | #define sc_F1 SDLK_F1
40 | #define sc_F2 SDLK_F2
41 | #define sc_F3 SDLK_F3
42 | #define sc_F4 SDLK_F4
43 | #define sc_F5 SDLK_F5
44 | #define sc_F6 SDLK_F6
45 | #define sc_F7 SDLK_F7
46 | #define sc_F8 SDLK_F8
47 | #define sc_F9 SDLK_F9
48 | #define sc_F10 SDLK_F10
49 | #define sc_F11 SDLK_F11
50 | #define sc_F12 SDLK_F12
51 |
52 | #define sc_ScrollLock SDLK_SCROLLOCK
53 | #define sc_PrintScreen SDLK_PRINT
54 |
55 | #define sc_1 SDLK_1
56 | #define sc_2 SDLK_2
57 | #define sc_3 SDLK_3
58 | #define sc_4 SDLK_4
59 | #define sc_5 SDLK_5
60 | #define sc_6 SDLK_6
61 | #define sc_7 SDLK_7
62 | #define sc_8 SDLK_8
63 | #define sc_9 SDLK_9
64 | #define sc_0 SDLK_0
65 |
66 | #define sc_A SDLK_a
67 | #define sc_B SDLK_b
68 | #define sc_C SDLK_c
69 | #define sc_D SDLK_d
70 | #define sc_E SDLK_e
71 | #define sc_F SDLK_f
72 | #define sc_G SDLK_g
73 | #define sc_H SDLK_h
74 | #define sc_I SDLK_i
75 | #define sc_J SDLK_j
76 | #define sc_K SDLK_k
77 | #define sc_L SDLK_l
78 | #define sc_M SDLK_m
79 | #define sc_N SDLK_n
80 | #define sc_O SDLK_o
81 | #define sc_P SDLK_p
82 | #define sc_Q SDLK_q
83 | #define sc_R SDLK_r
84 | #define sc_S SDLK_s
85 | #define sc_T SDLK_t
86 | #define sc_U SDLK_u
87 | #define sc_V SDLK_v
88 | #define sc_W SDLK_w
89 | #define sc_X SDLK_x
90 | #define sc_Y SDLK_y
91 | #define sc_Z SDLK_z
92 |
93 | #define key_None 0
94 |
95 | typedef enum {
96 | demo_Off,demo_Record,demo_Playback,demo_PlayDone
97 | } Demo;
98 | typedef enum {
99 | ctrl_Keyboard,
100 | ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,
101 | ctrl_Joystick,
102 | ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,
103 | ctrl_Mouse
104 | } ControlType;
105 | typedef enum {
106 | motion_Left = -1,motion_Up = -1,
107 | motion_None = 0,
108 | motion_Right = 1,motion_Down = 1
109 | } Motion;
110 | typedef enum {
111 | dir_North,dir_NorthEast,
112 | dir_East,dir_SouthEast,
113 | dir_South,dir_SouthWest,
114 | dir_West,dir_NorthWest,
115 | dir_None
116 | } Direction;
117 | typedef struct {
118 | boolean button0,button1,button2,button3;
119 | short x,y;
120 | Motion xaxis,yaxis;
121 | Direction dir;
122 | } CursorInfo;
123 | typedef CursorInfo ControlInfo;
124 | typedef struct {
125 | ScanCode button0,button1,
126 | upleft, up, upright,
127 | left, right,
128 | downleft, down, downright;
129 | } KeyboardDef;
130 | typedef struct {
131 | word joyMinX,joyMinY,
132 | threshMinX,threshMinY,
133 | threshMaxX,threshMaxY,
134 | joyMaxX,joyMaxY,
135 | joyMultXL,joyMultYL,
136 | joyMultXH,joyMultYH;
137 | } JoystickDef;
138 | // Global variables
139 | extern volatile boolean Keyboard[];;
140 | extern boolean MousePresent;
141 | extern volatile boolean Paused;
142 | extern volatile char LastASCII;
143 | extern volatile ScanCode LastScan;
144 | extern int JoyNumButtons;
145 | extern boolean forcegrabmouse;
146 |
147 |
148 | // Function prototypes
149 | #define IN_KeyDown(code) (Keyboard[(code)])
150 | #define IN_ClearKey(code) {Keyboard[code] = false;\
151 | if (code == LastScan) LastScan = sc_None;}
152 |
153 | // DEBUG - put names in prototypes
154 | extern void IN_Startup(void),IN_Shutdown(void);
155 | extern void IN_ClearKeysDown(void);
156 | extern void IN_ReadControl(int,ControlInfo *);
157 | extern void IN_GetJoyAbs(word joy,word *xp,word *yp);
158 | extern void IN_SetupJoy(word joy,word minx,word maxx,
159 | word miny,word maxy);
160 | extern void IN_StopDemo(void),IN_FreeDemoBuffer(void),
161 | IN_Ack(void);
162 | extern boolean IN_UserInput(longword delay);
163 | extern word IN_GetJoyButtonsDB(word joy);
164 | extern const char *IN_GetScanName(ScanCode);
165 |
166 | void IN_WaitAndProcessEvents();
167 | void IN_ProcessEvents();
168 |
169 | int IN_MouseButtons (void);
170 |
171 | boolean IN_JoyPresent();
172 | void IN_SetJoyCurrent(int joyIndex);
173 | int IN_JoyButtons (void);
174 | void IN_GetJoyDelta(int *dx,int *dy);
175 | void IN_GetJoyFineDelta(int *dx, int *dy);
176 |
177 | void IN_StartAck(void);
178 | boolean IN_CheckAck (void);
179 | bool IN_IsInputGrabbed();
180 | void IN_CenterMouse();
181 |
182 | #endif
183 |
--------------------------------------------------------------------------------
/docs/license-id.txt:
--------------------------------------------------------------------------------
1 | LIMITED USE SOFTWARE LICENSE AGREEMENT
2 |
3 | This Limited Use Software License Agreement (the "Agreement")
4 | is a legal agreement between you, the end-user, and Id Software, Inc.
5 | ("ID"). By continuing the downloading of this Wolfenstein 3D
6 | (the "Trademark") software material, which includes source code
7 | (the "Source Code"), artwork data, music and software tools
8 | (collectively, the "Software"), you are agreeing to be bound by the
9 | terms of this Agreement. If you do not agree to the terms of this
10 | Agreement, promptly destroy the Software you may have downloaded.
11 |
12 | ID SOFTWARE LICENSE
13 |
14 | Grant of License. ID grants to you the right to use one (1)
15 | copy of the Software on a single computer. You have no ownership or
16 | proprietary rights in or to the Software, or the Trademark. For purposes
17 | of this section, "use" means loading the Software into RAM, as well as
18 | installation on a hard disk or other storage device. The Software,
19 | together with any archive copy thereof, shall be destroyed when no longer
20 | used in accordance with this Agreement, or when the right to use the
21 | Software is terminated. You agree that the Software will not be shipped,
22 | transferred or exported into any country in violation of the U.S.
23 | Export Administration Act (or any other law governing such matters) and
24 | that you will not utilize, in any other manner, the Software in violation
25 | of any applicable law.
26 |
27 | Permitted Uses. For educational purposes only, you, the end-user,
28 | may use portions of the Source Code, such as particular routines, to
29 | develop your own software, but may not duplicate the Source Code, except
30 | as noted in paragraph 4. The limited right referenced in the preceding
31 | sentence is hereinafter referred to as "Educational Use." By so exercising
32 | the Educational Use right you shall not obtain any ownership, copyright,
33 | proprietary or other interest in or to the Source Code, or any portion of
34 | the Source Code. You may dispose of your own software in your sole
35 | discretion. With the exception of the Educational Use right, you may not
36 | otherwise use the Software, or an portion of the Software, which includes
37 | the Source Code, for commercial gain.
38 |
39 | Prohibited Uses: Under no circumstances shall you, the end-user,
40 | be permitted, allowed or authorized to commercially exploit the Software.
41 | Neither you nor anyone at your direction shall do any of the following acts
42 | with regard to the Software, or any portion thereof:
43 |
44 | Rent;
45 |
46 | Sell;
47 |
48 | Lease;
49 |
50 | Offer on a pay-per-play basis;
51 |
52 | Distribute for money or any other consideration; or
53 |
54 | In any other manner and through any medium whatsoever commercially
55 | exploit or use for any commercial purpose.
56 |
57 | Notwithstanding the foregoing prohibitions, you may commercially exploit the
58 | software you develop by exercising the Educational Use right, referenced in
59 | paragraph 2. hereinabove.
60 |
61 | Copyright. The Software and all copyrights related thereto
62 | (including all characters and other images generated by the Software
63 | or depicted in the Software) are owned by ID and is protected by
64 | United States copyright laws and international treaty provisions.
65 | Id shall retain exclusive ownership and copyright in and to the Software
66 | and all portions of the Software and you shall have no ownership or other
67 | proprietary interest in such materials. You must treat the Software like
68 | any other copyrighted material, except that you may either (a) make one
69 | copy of the Software solely for back-up or archival purposes, or (b)
70 | transfer the Software to a single hard disk provided you keep the original
71 | solely for back-up or archival purposes. You may not otherwise reproduce,
72 | copy or disclose to others, in whole or in any part, the Software. You
73 | may not copy the written materials accompanying the Software. You agree
74 | to use your best efforts to see that any user of the Software licensed
75 | hereunder complies with this Agreement.
76 |
77 | NO WARRANTIES. ID DISCLAIMS ALL WARRANTIES, BOTH EXPRESS IMPLIED,
78 | INCLUDING BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND
79 | FITNESS FOR A PARTICULAR PURPOSE WITH RESPECT TO THE SOFTWARE. THIS LIMITED
80 | WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS. YOU MAY HAVE OTHER RIGHTS WHICH
81 | VARY FROM JURISDICTION TO JURISDICTION. ID DOES NOT WARRANT THAT THE
82 | OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED, ERROR FREE OR MEET YOUR
83 | SPECIFIC REQUIREMENTS. THE WARRANTY SET FORTH ABOVE IS IN LIEU OF ALL OTHER
84 | EXPRESS WARRANTIES WHETHER ORAL OR WRITTEN. THE AGENTS, EMPLOYEES,
85 | DISTRIBUTORS, AND DEALERS OF ID ARE NOT AUTHORIZED TO MAKE MODIFICATIONS TO
86 | THIS WARRANTY, OR ADDITIONAL WARRANTIES ON BEHALF OF ID.
87 |
88 | Exclusive Remedies. The Software is being offered to you free of any
89 | charge. You agree that you have no remedy against ID, its affiliates,
90 | contractors, suppliers, and agents for loss or damage caused by any defect
91 | or failure in the Software regardless of the form of action, whether in
92 | contract, tort, includinegligence, strict liability or otherwise, with
93 | regard to the Software. This Agreement shall be construed in accordance
94 | with and governed by the laws of the State of Texas. Copyright and other
95 | proprietary matters will be governed by United States laws and international
96 | treaties. IN ANY CASE, ID SHALL NOT BE LIABLE FOR LOSS OF DATA, LOSS OF
97 | PROFITS, LOST SAVINGS, SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT OR OTHER
98 | SIMILAR DAMAGES ARISING FROM BREACH OF WARRANTY, BREACH OF CONTRACT,
99 | NEGLIGENCE, OR OTHER LEGAL THEORY EVEN IF ID OR ITS AGENT HAS BEEN ADVISED
100 | OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
101 | Some jurisdictions do not allow the exclusion or limitation of incidental or
102 | consequential damages, so the above limitation or exclusion may not apply to
103 | you.
104 |
105 | General Provisions. Neither this Agreement nor any part or portion
106 | hereof shall be assigned, sublicensed or otherwise transferred by you.
107 | Should any provision of this Agreement be held to be void, invalid,
108 | unenforceable or illegal by a court, the validity and enforceability of the
109 | other provisions shall not be affected thereby. If any provision is
110 | determined to be unenforceable, you agree to a modification of such
111 | provision to provide for enforcement of the provision's intent, to the
112 | extent permitted by applicable law. Failure of a party to enforce any
113 | provision of this Agreement shall not constitute or be construed as a
114 | waiver of such provision or of the right to enforce such provision. If
115 | you fail to comply with any terms of this Agreement, YOUR LICENSE IS
116 | AUTOMATICALLY TERMINATED and you agree to the issuance of an injunction
117 | against you in favor of Id. You agree that Id shall not have to post
118 | bond or other security to obtain an injunction against you to prohibit
119 | you from violating Id's rights.
120 |
121 | YOU ACKNOWLEDGE THAT YOU HAVE READ THIS AGREEMENT, THAT YOU
122 | UNDERSTAND THIS AGREEMENT, AND UNDERSTAND THAT BY CONTINUING THE
123 | DOWNLOADING OF THE SOFTWARE, YOU AGREE TO BE BOUND BY THIS AGREEMENT'S
124 | TERMS AND CONDITIONS. YOU FURTHER AGREE THAT, EXCEPT FOR WRITTEN SEPARATE
125 | AGREEMENTS BETWEEN ID AND YOU, THIS AGREEMENT IS A COMPLETE AND EXCLUSIVE
126 | STATEMENT OF THE RIGHTS AND LIABILITIES OF THE PARTIES. THIS AGREEMENT
127 | SUPERSEDES ALL PRIOR ORAL AGREEMENTS, PROPOSALS OR UNDERSTANDINGS, AND
128 | ANY OTHER COMMUNICATIONS BETWEEN ID AND YOU RELATING TO THE SUBJECT MATTER
129 | OF THIS AGREEMENT
130 |
--------------------------------------------------------------------------------
/win32/vs2008/choco_wold3s/choco_wold3s.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
26 |
29 |
32 |
35 |
38 |
41 |
53 |
56 |
59 |
62 |
71 |
74 |
77 |
80 |
83 |
86 |
89 |
92 |
93 |
101 |
104 |
107 |
110 |
113 |
116 |
127 |
130 |
133 |
136 |
145 |
148 |
151 |
154 |
157 |
160 |
163 |
166 |
167 |
168 |
169 |
170 |
171 |
176 |
179 |
180 |
183 |
184 |
187 |
188 |
191 |
192 |
195 |
196 |
199 |
200 |
203 |
204 |
207 |
208 |
211 |
212 |
215 |
216 |
219 |
220 |
223 |
224 |
227 |
228 |
231 |
232 |
235 |
236 |
239 |
240 |
243 |
244 |
247 |
248 |
251 |
252 |
255 |
256 |
259 |
260 |
263 |
264 |
265 |
270 |
273 |
274 |
277 |
278 |
281 |
282 |
285 |
286 |
289 |
290 |
293 |
294 |
297 |
298 |
301 |
302 |
305 |
306 |
309 |
310 |
313 |
314 |
317 |
318 |
321 |
322 |
325 |
326 |
329 |
330 |
333 |
334 |
337 |
338 |
341 |
342 |
345 |
346 |
347 |
352 |
353 |
354 |
355 |
356 |
357 |
--------------------------------------------------------------------------------
/docs/Changes.Wolf4SDL.txt:
--------------------------------------------------------------------------------
1 | Wolf4SDL v1.7 (released 2011-05-15, revision 256)
2 | - Added support for Mac OS X
3 | (thanks to Chris Ballinger)
4 | - Added support for .sd1 SOD game files as delivered by Steam
5 | by changing --mission parameter slightly
6 | (thanks to Pickle)
7 | - Added --windowed-mouse parameter to start windowed mode with grabbed mouse
8 | (thanks to Jared Breland)
9 | - Rain and snow speed fix (thanks to Tricob)
10 | - Floor/ceiling fix (thanks to Tricob / Adam Biser)
11 | - Fixed moon out of screen bug (thanks to Tricob)
12 | - Rain/snow leaking ceilings fix (thanks to Adam Biser / Tricob)
13 | - Per-user configuration/savegame directories (~/.wolf4sdl) on
14 | Linux like systems per default (thanks to Jared Breland)
15 | - Added --configdir parameter
16 | - Use SDL_DOUBLEBUF for vsync to avoid or at least reduce flickering
17 | (thanks to Greg Ayrton for the hint, use --nodblbuf to disable it)
18 | - Removed remainings of the frame rate counter on screen, when disabled
19 | - Don't quit game when using TAB+E with --tedlevel
20 | - Added --extravbls parameter
21 | - Changed default for "extra VBLs" from 1 to 0
22 | - Fixed missing umask parameter for open with O_CREAT
23 | (bug reported by Daniel Fass)
24 | - Fixed support for 1.0 shareware data files
25 | (bug reported by Marcus Naylor)
26 | - Fixed xtile and ytile not being valid in HitHorizWall and HitVertWall,
27 | respectively. This caused problems with some tutorials.
28 | - Removed unused HitHorizPWall and HitVertPWall.
29 |
30 | Wolf4SDL v1.6 (released 2008-09-01, revision 233)
31 | - Fixed songs not really supporting more than 64kb
32 | - Try to recognize whether data files don't fit to program version
33 | instead of just using them and probably crash
34 | (can be disabled with --ignorenumchunks)
35 | - Fizzle fade now works for resolutions up to 8191x4095
36 | (thanks to Xilinx, Inc. for the list of maximum-length LFSR counters)
37 | - Fixed demos being dependent on actual duration of GETGATLINGSND
38 | (fixes second demo, which even rarely worked in vanilla Wolf3D)
39 | - Fixed demos by disabling some bugfixes during recording and playback
40 | (see PLAYDEMOLIKEORIGINAL define in version.h)
41 | - Removed system menu on Windows in windowed mode to avoid ALT to open it
42 | - Fixed palette issues occurring on some Windows systems by using the
43 | "best" color depth reported by libSDL per default (also see --bits option)
44 | - Fixed directional 3d sprites on architectures only allowing aligned memory
45 | access (bug reported by Pickle)
46 | - Fixed remaining status bar after end of demo in 320x240s resolutions
47 | (bug reported by Pickle)
48 | - Removed last busy waiting (fixes very unstable framerates on machines with
49 | stricter schedulers like FreeBSD; thanks to Tron for making me notice)
50 | - Fixed compiling of SOD on case sensitive file systems
51 | (thanks to Michael)
52 |
53 | Wolf4SDL v1.5 (released 2008-05-25, revision 215)
54 | - Reduced minimum distance to back of moving pushwall to PLAYERSIZE
55 | - Fixed pushwall rendering when player's eye is in the pushwall back tile
56 | (bug reported by Pickle)
57 | - Enable 'End game' menu item also when using --tedlevel
58 | - Removed some unneccessary fade outs
59 | (DrawPlayScreen does not call VW_FadeOut anymore!!)
60 | - When using 'End game', 'View scores' does not directly show up anymore
61 | - Fixed quickload/quicksave not working when started with --tedlevel (vanilla
62 | bug). This now also only checks for save games once at startup (may speed
63 | up entering the menu on Dreamcast)
64 | - Fixed drawing moving pushwalls viewed at acute angles near the level border
65 | - Fixed vanilla bug hiding bonus items on same tile as player, when he cannot
66 | pick them up (e.g. medikit at 100% health) (thanks to Pickle for noticing)
67 | - Added GP2X specific code by Pickle
68 | - Reimplemented picture grabber to support all screen resolutions
69 | (+P in debug mode)
70 | - Added --resf option to force to use unsupported resolutions >= 320x200
71 | - Added support for resolutions being a multiple of 320x240
72 | (thanks for your help, Pickle!)
73 | - Fixed crash when cheat-hurting oneself to death (bug reported by Tricob)
74 | - Cleaned up id_sd.cpp (kept PC speaker stuff for future reference)
75 | - Added move buttons (invalidates config file, only hardcoded yet)
76 | - Added joystick support to US_LineInput used for highscore names
77 | and save games
78 | - Added US_Printf and US_CPrintf (works just like printf)
79 | - Fixed wrong surface locks/unlocks
80 | - Added Visual C++ 6 support
81 | - Removed some useless VW_WaitVBLs (Thanks to TexZK)
82 | - Added some asserts in id_vl.cpp to check for screen access out of bounds
83 | - Fixed BJ face popping up in fullsize mode sometimes
84 | (Thanks to Andy_Nonymous)
85 | - Rewrote page manager to support page >= 64kB
86 | and to correctly handle sounds >= 4kB
87 | - Improved SOD mission packs support (Thanks to fackue)
88 | - Updated Code::Blocks search paths to ..\SDL-devel\
89 | - Added version.h to Dev-C++ and Code::Blocks project file
90 | - Fixed some files being read in text mode on MinGW
91 |
92 | Wolf4SDL v1.4 (released 2008-03-10, revision 164)
93 | - Added MinGW/MSYS compatibility
94 | - Updated Code::Blocks project
95 | - Updated Dev-C++ project and added a README-devcpp.txt
96 | - Fixed some busy waiting situations
97 | - Added directional 3D sprites support (USE_DIR3DSPR)
98 | - Added support for Spear mission packs (by fackue)
99 | - Added support for Wolf3D full v1.1 and shareware v1.0, v1.1 and v1.2
100 | - Added shading support (USE_SHADING)
101 | - Added object flags (see objflag_t enum in wl_def.h)
102 | - Reintroduced version.h
103 | - Increased MAXVISABLE from 50 to 250
104 | - Added outside atmosphere features (USE_STARSKY, USE_RAIN, USE_SNOW)
105 | - Added cloud sky support (USE_CLOUDSKY)
106 | - Added support for SoD demo
107 | - Fixed SoD on systems with case sensitive filenames
108 | - Added DarkOne's/Adam's multi-textured floors/ceiling (USE_FLOORCEILINGTEX)
109 | - Added parallax sky support (USE_PARALLAX define)
110 | - Introduced level feature flags (USE_FEATUREFLAGS define)
111 | - Added high resolution support (USE_HIRES define)
112 | - Added support for music > 64 kB as supported by WDC
113 | - Added --samplerate and --audiobuffer parameters
114 | - Added support for GP2X (ARM processor, thanks to Pickle)
115 | - Added support for Dreamcast (SH-4 processor, thanks to fackue)
116 | - Added joystick support (up to 32 buttons)
117 |
118 | Wolf4SDL v1.3 (released 2008-01-20, revision 113)
119 | - Added parameter for SOD to disable copy protection quiz
120 | - F12 now also grabs the mouse (for keyboards without scrolllock)
121 | - Fixed out of bounds array access in key processing
122 |
123 | Wolf4SDL v1.2 (released 2008-01-09, revision 108)
124 | - Fixed fading for 'End Game'
125 | - Corrected fading speed
126 | - Added Spear of Destiny compile support
127 | - Reimplemented palette file (Sorry...)
128 | - Fixed end game crash, when player did not die yet
129 | (Thanks to Agent87 for noticing this bug!)
130 | - Added full size screen feature
131 | - Added project files for Code::Blocks and Dev-C++
132 | (Thanks to Codetech84!)
133 | - Made it MinGW compatible
134 | - Fixed demo fading issues
135 | - Reformatted many source code files
136 | - Resolved all warnings reported by VC++ 8 and GCC
137 | - Fixed crash when starting the game with no sound >effects<
138 | (Thanks to Agent87 for noticing this bug!)
139 | - Always grab mouse when started in fullscreen
140 | - Map left and right alt, shift and ctrl keys to the same keys
141 | - Fix numpad keys with numlock off
142 | - Fixed a buffer overflow causing a crash
143 |
144 | Wolf4SDL v1.1 (released 2007-12-28, revision 70)
145 | - Fixed Pause
146 | - Fixed IN_Ack()
147 | - Added command line parameters for windowed mode and screen resolution
148 | - Reimplemented command line parameters (try --help)
149 | - Improved scaled "Get Psyched" progress bar graphic
150 | - Improved scaled screen borders
151 | - Fixed "Fade in black screen" bug
152 | - Avoid asserts when shutting down with an error
153 | - Use software surfaces to reduce problems with palette on Windows
154 | - Windows: Statically links to MSVCR80.DLL now to avoid missing files
155 |
156 | Wolf4SDL v1.0 (released 2007-12-26, revision 53)
157 | - Initial release
158 |
--------------------------------------------------------------------------------
/gfxv_wl6.h:
--------------------------------------------------------------------------------
1 | //////////////////////////////////////
2 | //
3 | // Graphics .H file for .WL6
4 | // IGRAB-ed on Wed Apr 13 06:58:44 1994
5 | //
6 | //////////////////////////////////////
7 |
8 | typedef enum {
9 | // Lump Start
10 | H_BJPIC=3,
11 | H_CASTLEPIC, // 4
12 | H_BLAZEPIC, // 5
13 | H_TOPWINDOWPIC, // 6
14 | H_LEFTWINDOWPIC, // 7
15 | H_RIGHTWINDOWPIC, // 8
16 | H_BOTTOMINFOPIC, // 9
17 | // Lump Start
18 | C_OPTIONSPIC, // 10
19 | C_CURSOR1PIC, // 11
20 | C_CURSOR2PIC, // 12
21 | C_NOTSELECTEDPIC, // 13
22 | C_SELECTEDPIC, // 14
23 | C_FXTITLEPIC, // 15
24 | C_DIGITITLEPIC, // 16
25 | C_MUSICTITLEPIC, // 17
26 | C_MOUSELBACKPIC, // 18
27 | C_BABYMODEPIC, // 19
28 | C_EASYPIC, // 20
29 | C_NORMALPIC, // 21
30 | C_HARDPIC, // 22
31 | C_LOADSAVEDISKPIC, // 23
32 | C_DISKLOADING1PIC, // 24
33 | C_DISKLOADING2PIC, // 25
34 | C_CONTROLPIC, // 26
35 | C_CUSTOMIZEPIC, // 27
36 | C_LOADGAMEPIC, // 28
37 | C_SAVEGAMEPIC, // 29
38 | C_EPISODE1PIC, // 30
39 | C_EPISODE2PIC, // 31
40 | C_EPISODE3PIC, // 32
41 | C_EPISODE4PIC, // 33
42 | C_EPISODE5PIC, // 34
43 | C_EPISODE6PIC, // 35
44 | C_CODEPIC, // 36
45 | C_TIMECODEPIC, // 37
46 | C_LEVELPIC, // 38
47 | C_NAMEPIC, // 39
48 | C_SCOREPIC, // 40
49 | C_JOY1PIC, // 41
50 | C_JOY2PIC, // 42
51 | // Lump Start
52 | L_GUYPIC, // 43
53 | L_COLONPIC, // 44
54 | L_NUM0PIC, // 45
55 | L_NUM1PIC, // 46
56 | L_NUM2PIC, // 47
57 | L_NUM3PIC, // 48
58 | L_NUM4PIC, // 49
59 | L_NUM5PIC, // 50
60 | L_NUM6PIC, // 51
61 | L_NUM7PIC, // 52
62 | L_NUM8PIC, // 53
63 | L_NUM9PIC, // 54
64 | L_PERCENTPIC, // 55
65 | L_APIC, // 56
66 | L_BPIC, // 57
67 | L_CPIC, // 58
68 | L_DPIC, // 59
69 | L_EPIC, // 60
70 | L_FPIC, // 61
71 | L_GPIC, // 62
72 | L_HPIC, // 63
73 | L_IPIC, // 64
74 | L_JPIC, // 65
75 | L_KPIC, // 66
76 | L_LPIC, // 67
77 | L_MPIC, // 68
78 | L_NPIC, // 69
79 | L_OPIC, // 70
80 | L_PPIC, // 71
81 | L_QPIC, // 72
82 | L_RPIC, // 73
83 | L_SPIC, // 74
84 | L_TPIC, // 75
85 | L_UPIC, // 76
86 | L_VPIC, // 77
87 | L_WPIC, // 78
88 | L_XPIC, // 79
89 | L_YPIC, // 80
90 | L_ZPIC, // 81
91 | L_EXPOINTPIC, // 82
92 | L_APOSTROPHEPIC, // 83
93 | L_GUY2PIC, // 84
94 | L_BJWINSPIC, // 85
95 | STATUSBARPIC, // 86
96 | TITLEPIC, // 87
97 | PG13PIC, // 88
98 | CREDITSPIC, // 89
99 | HIGHSCORESPIC, // 90
100 | // Lump Start
101 | KNIFEPIC, // 91
102 | GUNPIC, // 92
103 | MACHINEGUNPIC, // 93
104 | GATLINGGUNPIC, // 94
105 | NOKEYPIC, // 95
106 | GOLDKEYPIC, // 96
107 | SILVERKEYPIC, // 97
108 | N_BLANKPIC, // 98
109 | N_0PIC, // 99
110 | N_1PIC, // 100
111 | N_2PIC, // 101
112 | N_3PIC, // 102
113 | N_4PIC, // 103
114 | N_5PIC, // 104
115 | N_6PIC, // 105
116 | N_7PIC, // 106
117 | N_8PIC, // 107
118 | N_9PIC, // 108
119 | FACE1APIC, // 109
120 | FACE1BPIC, // 110
121 | FACE1CPIC, // 111
122 | FACE2APIC, // 112
123 | FACE2BPIC, // 113
124 | FACE2CPIC, // 114
125 | FACE3APIC, // 115
126 | FACE3BPIC, // 116
127 | FACE3CPIC, // 117
128 | FACE4APIC, // 118
129 | FACE4BPIC, // 119
130 | FACE4CPIC, // 120
131 | FACE5APIC, // 121
132 | FACE5BPIC, // 122
133 | FACE5CPIC, // 123
134 | FACE6APIC, // 124
135 | FACE6BPIC, // 125
136 | FACE6CPIC, // 126
137 | FACE7APIC, // 127
138 | FACE7BPIC, // 128
139 | FACE7CPIC, // 129
140 | FACE8APIC, // 130
141 | GOTGATLINGPIC, // 131
142 | MUTANTBJPIC, // 132
143 | PAUSEDPIC, // 133
144 | GETPSYCHEDPIC, // 134
145 |
146 |
147 |
148 | ORDERSCREEN=136,
149 | ERRORSCREEN, // 137
150 | T_HELPART, // 138
151 | T_DEMO0, // 139
152 | T_DEMO1, // 140
153 | T_DEMO2, // 141
154 | T_DEMO3, // 142
155 | T_ENDART1, // 143
156 | T_ENDART2, // 144
157 | T_ENDART3, // 145
158 | T_ENDART4, // 146
159 | T_ENDART5, // 147
160 | T_ENDART6, // 148
161 | ENUMEND
162 | } graphicnums;
163 |
164 | //
165 | // Data LUMPs
166 | //
167 | #define README_LUMP_START 3
168 | #define README_LUMP_END 9
169 |
170 | #define CONTROLS_LUMP_START 10
171 | #define CONTROLS_LUMP_END 42
172 |
173 | #define LEVELEND_LUMP_START 43
174 | #define LEVELEND_LUMP_END 85
175 |
176 | #define LATCHPICS_LUMP_START 91
177 | #define LATCHPICS_LUMP_END 134
178 |
179 |
180 | //
181 | // Amount of each data item
182 | //
183 | #define NUMCHUNKS 149
184 | #define NUMFONT 2
185 | #define NUMFONTM 0
186 | #define NUMPICS 132
187 | #define NUMPICM 0
188 | #define NUMSPRITES 0
189 | #define NUMTILE8 72
190 | #define NUMTILE8M 0
191 | #define NUMTILE16 0
192 | #define NUMTILE16M 0
193 | #define NUMTILE32 0
194 | #define NUMTILE32M 0
195 | #define NUMEXTERNS 13
196 | //
197 | // File offsets for data items
198 | //
199 | #define STRUCTPIC 0
200 |
201 | #define STARTFONT 1
202 | #define STARTFONTM 3
203 | #define STARTPICS 3
204 | #define STARTPICM 135
205 | #define STARTSPRITES 135
206 | #define STARTTILE8 135
207 | #define STARTTILE8M 136
208 | #define STARTTILE16 136
209 | #define STARTTILE16M 136
210 | #define STARTTILE32 136
211 | #define STARTTILE32M 136
212 | #define STARTEXTERNS 136
213 |
214 | //
215 | // Thank you for using IGRAB!
216 | //
217 |
--------------------------------------------------------------------------------
/gfxv_apo.h:
--------------------------------------------------------------------------------
1 | //////////////////////////////////////
2 | //
3 | // Graphics .H file for Apogee v1.4
4 | // IGRAB-ed on Sun May 03 01:19:32 1992
5 | //
6 | //////////////////////////////////////
7 |
8 | typedef enum {
9 | // Lump Start
10 | H_BJPIC=3,
11 | H_CASTLEPIC, // 4
12 | H_KEYBOARDPIC, // 5
13 | H_JOYPIC, // 6
14 | H_HEALPIC, // 7
15 | H_TREASUREPIC, // 8
16 | H_GUNPIC, // 9
17 | H_KEYPIC, // 10
18 | H_BLAZEPIC, // 11
19 | H_WEAPON1234PIC, // 12
20 | H_WOLFLOGOPIC, // 13
21 | H_VISAPIC, // 14
22 | H_MCPIC, // 15
23 | H_IDLOGOPIC, // 16
24 | H_TOPWINDOWPIC, // 17
25 | H_LEFTWINDOWPIC, // 18
26 | H_RIGHTWINDOWPIC, // 19
27 | H_BOTTOMINFOPIC, // 20
28 | #if !defined(APOGEE_1_0) && !defined(APOGEE_1_1) && !defined(APOGEE_1_2)
29 | H_SPEARADPIC, // 21
30 | #endif
31 | // Lump Start
32 | C_OPTIONSPIC, // 22
33 | C_CURSOR1PIC, // 23
34 | C_CURSOR2PIC, // 24
35 | C_NOTSELECTEDPIC, // 25
36 | C_SELECTEDPIC, // 26
37 | C_FXTITLEPIC, // 27
38 | C_DIGITITLEPIC, // 28
39 | C_MUSICTITLEPIC, // 29
40 | C_MOUSELBACKPIC, // 30
41 | C_BABYMODEPIC, // 31
42 | C_EASYPIC, // 32
43 | C_NORMALPIC, // 33
44 | C_HARDPIC, // 34
45 | C_LOADSAVEDISKPIC, // 35
46 | C_DISKLOADING1PIC, // 36
47 | C_DISKLOADING2PIC, // 37
48 | C_CONTROLPIC, // 38
49 | C_CUSTOMIZEPIC, // 39
50 | C_LOADGAMEPIC, // 40
51 | C_SAVEGAMEPIC, // 41
52 | C_EPISODE1PIC, // 42
53 | C_EPISODE2PIC, // 43
54 | C_EPISODE3PIC, // 44
55 | C_EPISODE4PIC, // 45
56 | C_EPISODE5PIC, // 46
57 | C_EPISODE6PIC, // 47
58 | C_CODEPIC, // 48
59 | #ifndef APOGEE_1_0
60 | C_TIMECODEPIC, // 49
61 | C_LEVELPIC, // 50
62 | C_NAMEPIC, // 51
63 | C_SCOREPIC, // 52
64 | #if !defined(APOGEE_1_1) && !defined(APOGEE_1_2)
65 | C_JOY1PIC, // 53
66 | C_JOY2PIC, // 54
67 | #endif
68 | #else
69 | C_TIMECODEPIC=C_CODEPIC, // 47
70 | #endif
71 | // Lump Start
72 | L_GUYPIC, // 55
73 | L_COLONPIC, // 56
74 | L_NUM0PIC, // 57
75 | L_NUM1PIC, // 58
76 | L_NUM2PIC, // 59
77 | L_NUM3PIC, // 60
78 | L_NUM4PIC, // 61
79 | L_NUM5PIC, // 62
80 | L_NUM6PIC, // 63
81 | L_NUM7PIC, // 64
82 | L_NUM8PIC, // 65
83 | L_NUM9PIC, // 66
84 | L_PERCENTPIC, // 67
85 | L_APIC, // 68
86 | L_BPIC, // 69
87 | L_CPIC, // 70
88 | L_DPIC, // 71
89 | L_EPIC, // 72
90 | L_FPIC, // 73
91 | L_GPIC, // 74
92 | L_HPIC, // 75
93 | L_IPIC, // 76
94 | L_JPIC, // 77
95 | L_KPIC, // 78
96 | L_LPIC, // 79
97 | L_MPIC, // 80
98 | L_NPIC, // 81
99 | L_OPIC, // 82
100 | L_PPIC, // 83
101 | L_QPIC, // 84
102 | L_RPIC, // 85
103 | L_SPIC, // 86
104 | L_TPIC, // 87
105 | L_UPIC, // 88
106 | L_VPIC, // 89
107 | L_WPIC, // 90
108 | L_XPIC, // 91
109 | L_YPIC, // 92
110 | L_ZPIC, // 93
111 | L_EXPOINTPIC, // 94
112 | #ifndef APOGEE_1_0
113 | L_APOSTROPHEPIC, // 95
114 | #endif
115 | L_GUY2PIC, // 96
116 | L_BJWINSPIC, // 97
117 | STATUSBARPIC, // 98
118 | TITLEPIC, // 99
119 | PG13PIC, // 100
120 | CREDITSPIC, // 101
121 | HIGHSCORESPIC, // 102
122 | // Lump Start
123 | KNIFEPIC, // 103
124 | GUNPIC, // 104
125 | MACHINEGUNPIC, // 105
126 | GATLINGGUNPIC, // 106
127 | NOKEYPIC, // 107
128 | GOLDKEYPIC, // 108
129 | SILVERKEYPIC, // 109
130 | N_BLANKPIC, // 110
131 | N_0PIC, // 111
132 | N_1PIC, // 112
133 | N_2PIC, // 113
134 | N_3PIC, // 114
135 | N_4PIC, // 115
136 | N_5PIC, // 116
137 | N_6PIC, // 117
138 | N_7PIC, // 118
139 | N_8PIC, // 119
140 | N_9PIC, // 120
141 | FACE1APIC, // 121
142 | FACE1BPIC, // 122
143 | FACE1CPIC, // 123
144 | FACE2APIC, // 124
145 | FACE2BPIC, // 125
146 | FACE2CPIC, // 126
147 | FACE3APIC, // 127
148 | FACE3BPIC, // 128
149 | FACE3CPIC, // 129
150 | FACE4APIC, // 130
151 | FACE4BPIC, // 131
152 | FACE4CPIC, // 132
153 | FACE5APIC, // 133
154 | FACE5BPIC, // 134
155 | FACE5CPIC, // 135
156 | FACE6APIC, // 136
157 | FACE6BPIC, // 137
158 | FACE6CPIC, // 138
159 | FACE7APIC, // 139
160 | FACE7BPIC, // 140
161 | FACE7CPIC, // 141
162 | FACE8APIC, // 142
163 | GOTGATLINGPIC, // 143
164 | MUTANTBJPIC, // 144
165 | PAUSEDPIC, // 145
166 | GETPSYCHEDPIC, // 146
167 |
168 | TILE8, // 147
169 |
170 | ORDERSCREEN, // 148
171 | ERRORSCREEN, // 149
172 | T_HELPART, // 150
173 | #ifdef APOGEE_1_0
174 | T_ENDART1, // 143
175 | #endif
176 | T_DEMO0, // 151
177 | T_DEMO1, // 152
178 | T_DEMO2, // 153
179 | T_DEMO3, // 154
180 | #ifndef APOGEE_1_0
181 | T_ENDART1, // 155
182 | T_ENDART2, // 156
183 | T_ENDART3, // 157
184 | T_ENDART4, // 158
185 | T_ENDART5, // 159
186 | T_ENDART6, // 160
187 | #endif
188 |
189 | ENUMEND
190 | } graphicnums;
191 |
192 | //
193 | // Data LUMPs
194 | //
195 | #define README_LUMP_START H_BJPIC
196 | #define README_LUMP_END H_BOTTOMINFOPIC
197 |
198 | #define CONTROLS_LUMP_START C_OPTIONSPIC
199 | #define CONTROLS_LUMP_END (L_GUYPIC - 1)
200 |
201 | #define LEVELEND_LUMP_START L_GUYPIC
202 | #define LEVELEND_LUMP_END L_BJWINSPIC
203 |
204 | #define LATCHPICS_LUMP_START KNIFEPIC
205 | #define LATCHPICS_LUMP_END GETPSYCHEDPIC
206 |
207 |
208 | //
209 | // Amount of each data item
210 | //
211 | #define NUMCHUNKS ENUMEND
212 | #define NUMFONT 2
213 | #define NUMFONTM 0
214 | #define NUMPICS (GETPSYCHEDPIC - NUMFONT)
215 | #define NUMPICM 0
216 | #define NUMSPRITES 0
217 | #define NUMTILE8 72
218 | #define NUMTILE8M 0
219 | #define NUMTILE16 0
220 | #define NUMTILE16M 0
221 | #define NUMTILE32 0
222 | #define NUMTILE32M 0
223 | #define NUMEXTERNS 13
224 | //
225 | // File offsets for data items
226 | //
227 | #define STRUCTPIC 0
228 |
229 | #define STARTFONT 1
230 | #define STARTFONTM 3
231 | #define STARTPICS 3
232 | #define STARTPICM TILE8
233 | #define STARTSPRITES TILE8
234 | #define STARTTILE8 TILE8
235 | #define STARTTILE8M ORDERSCREEN
236 | #define STARTTILE16 ORDERSCREEN
237 | #define STARTTILE16M ORDERSCREEN
238 | #define STARTTILE32 ORDERSCREEN
239 | #define STARTTILE32M ORDERSCREEN
240 | #define STARTEXTERNS ORDERSCREEN
241 |
242 | //
243 | // Thank you for using IGRAB!
244 | //
245 |
--------------------------------------------------------------------------------
/docs/README.Wolf4SDL.txt:
--------------------------------------------------------------------------------
1 | Wolf4SDL by Moritz "Ripper" Kroll (http://www.chaos-software.de.vu)
2 | Original Wolfenstein 3D by id Software (http://www.idsoftware.com)
3 | =============================================================================
4 |
5 | Wolf4SDL is an open-source port of id Software's classic first-person shooter
6 | Wolfenstein 3D to the cross-plattform multimedia library "Simple DirectMedia
7 | Layer (SDL)" (http://www.libsdl.org). It is meant to keep the original feel
8 | while taking advantage of some improvements mentioned in the list below.
9 |
10 |
11 | Main features:
12 | --------------
13 |
14 | - Cross-plattform:
15 | Supported operating systems are at least:
16 | - Windows 98, Windows ME, Windows 2000, Windows XP, Windows Vista
17 | (32 and 64 bit), Windows 7 (32 and 64 bit)
18 | - Linux
19 | - BSD variants
20 | - Mac OS X (x86)
21 | - KallistiOS (used for Dreamcast)
22 | Only little endian platforms like x86, ARM and SH-4 are supported, yet.
23 |
24 | - AdLib sounds and music:
25 | This port includes the OPL2 emulator from MAME, so you can not only
26 | hear the AdLib sounds but also music without any AdLib-compatible
27 | soundcard in near to perfect quality!
28 |
29 | - Multichannel digitized sounds:
30 | Digitized sounds play on 8 channels! So in a fire fight you will
31 | always hear, when a guard opens the door behind you ;)
32 |
33 | - Higher screen resolutions:
34 | Aside from the original 320x200 resolution, Wolf4SDL currently
35 | supports any resolutions being multiples of 320x200 or 320x240,
36 | the default being 640x400.
37 | Unlike some other ports, Wolf4SDL does NOT apply any bilinear
38 | or similar filtering, so the graphics are NOT blurred but
39 | pixelated just as we love it.
40 |
41 | - Fully playable with only a game controller:
42 | Wolf4SDL can be played completely without a keyboard. At least two
43 | buttons are required (shoot/YES and open door/NO), but five or more
44 | are recommended (run, strafe, ESC).
45 |
46 | Additional features:
47 | --------------------
48 |
49 | - Two additional view sizes:
50 | Wolf4SDL supports one view size using the full width of the screen
51 | and showing the status bar, like in Mac-enstein, and one view size
52 | filling the whole screen (press TAB to see the status bar).
53 |
54 | - (Nearly) unlimited sound and song lengths:
55 | Mod developers are not restricted to 64kB for digitized sounds and
56 | IMF songs anymore, so longer songs and digitized sounds with better
57 | quality are possible.
58 |
59 | - Resuming ingame music:
60 | When you come back to the game from the menu or load a save game, the
61 | music will be resumed where it was suspended rather than started from
62 | the beginning.
63 |
64 | - Freely movable pushwalls:
65 | Moving pushwalls can be viewed from all sides, allowing mod developers
66 | to place them with fewer restrictions. The player can also follow the
67 | pushwall directly instead of having to wait until the pushwall has left
68 | a whole tile.
69 |
70 | - Optional integrated features for mod developers:
71 | Wolf4SDL already contains the shading, directional 3D sprites,
72 | floor and ceiling textures, high resolution textures/sprites,
73 | parallax sky, cloud sky and outside atmosphere features, which
74 | can be easily activated in version.h.
75 |
76 |
77 | The following versions of Wolfenstein 3D data files are currently supported
78 | by the source code (choose the version by commenting/uncommenting lines in
79 | version.h as described in that file):
80 |
81 | - Wolfenstein 3D v1.1 full Apogee
82 | - Wolfenstein 3D v1.4 full Apogee (not tested)
83 | - Wolfenstein 3D v1.4 full GT/ID/Activision
84 | - Wolfenstein 3D v1.0 shareware Apogee
85 | - Wolfenstein 3D v1.1 shareware Apogee
86 | - Wolfenstein 3D v1.2 shareware Apogee
87 | - Wolfenstein 3D v1.4 shareware
88 | - Spear of Destiny full
89 | - Spear of Destiny demo
90 | - Spear of Destiny - Mission 2: Return to Danger (not tested)
91 | - Spear of Destiny - Mission 3: Ultimate Challenge (not tested)
92 |
93 |
94 | How to play:
95 | ------------
96 |
97 | To play Wolfenstein 3D with Wolf4SDL, you just have to copy the original data
98 | files (e.g. *.WL6) into the same directory as the Wolf4SDL executable.
99 | Please make sure, that you use the correct version of the executable with the
100 | according data files version as the differences are hardcoded into the binary!
101 |
102 | On Windows SDL.dll and SDL_mixer.dll must also be copied into this directory.
103 | They are also available at http://www.chaos-software.de.vu
104 |
105 | If you play in windowed mode (--windowed parameter), press SCROLLLOCK or F12
106 | to grab the mouse. Press it again to release the mouse.
107 |
108 |
109 | Usage:
110 | ------
111 |
112 | Wolf4SDL supports the following command line options:
113 | --help This help page
114 | --tedlevel Starts the game in the given level
115 | --baby Sets the difficulty to baby for tedlevel
116 | --easy Sets the difficulty to easy for tedlevel
117 | --normal Sets the difficulty to normal for tedlevel
118 | --hard Sets the difficulty to hard for tedlevel
119 | --nowait Skips intro screens
120 | --windowed[-mouse] Starts the game in a window [and grabs mouse]
121 | --res Sets the screen resolution
122 | (must be multiple of 320x200 or 320x240)
123 | --resf Sets any screen resolution >= 320x200
124 | (which may result in graphic errors)
125 | --bits Sets the screen color depth
126 | (Use this when you have palette/fading problem
127 | or perhaps to optimize speed on old systems.
128 | Allowed: 8, 16, 24, 32, default: "best" depth)
129 | --nodblbuf Don't use SDL's double buffering
130 | --extravbls Sets a delay after each frame, which may help to
131 | reduce flickering (SDL does not support vsync...)
132 | (unit is currently 8 ms, default: 0)
133 | --joystick Use the index-th joystick if available
134 | --joystickhat Enables movement with the given coolie hat
135 | --samplerate Sets the sound sample rate (given in Hz)
136 | --audiobuffer Sets the size of the audio buffer (-> sound latency)
137 | (given in bytes)
138 | --ignorenumchunks Ignores the number of chunks in VGAHEAD.*
139 | (may be useful for some broken mods)
140 | --configdir Directory where config file and save games are stored
141 | (Windows default: current directory,
142 | others: $HOME/.wolf4sdl)
143 |
144 | For Spear of Destiny the following additional options are available:
145 | --mission Mission number to play (1-3)
146 | --goodtimes Disable copy protection quiz
147 |
148 |
149 | Compiling from source code:
150 | ---------------------------
151 |
152 | The current version of the source code is available in the svn repository at:
153 | svn://tron.homeunix.org:3690/wolf3d/trunk
154 |
155 | The following ways of compiling the source code are supported:
156 | - Makefile (for Linux, BSD variants and MinGW/MSYS)
157 | - Visual C++ 2008 (Wolf4SDL.VC9.sln and Wolf4SDL.VC9.vcproj)
158 | - Visual C++ 2005 (Wolf4SDL.sln and Wolf4SDL.vcproj)
159 | - Visual C++ 6 (Wolf4SDL.dsw and Wolf4SDL.dsp)
160 | - Code::Blocks 8.02 (Wolf4SDL.cbp)
161 | - Dev-C++ 5.0 Beta 9.2 (4.9.9.2) (Wolf4SDL.dev) (see README-devcpp.txt)
162 | - Xcode (for Mac OS X, macosx/Wolf4SDL.xcodeproj/project.pbxproj)
163 | - Special compiling for Dreamcast (see README-dc.txt)
164 | - Special compiling for GP2X (see README-GP2X.txt)
165 |
166 | To compile the source code you need the development libraries of
167 | - SDL (http://www.libsdl.org/download-1.2.php) and
168 | - SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/)
169 | and have to adjust the include and library paths in the projects accordingly.
170 |
171 | Please note, that there is no official SDL_mixer development pack for MinGW,
172 | yet, but you can get the needed files from a Dev-C++ package here:
173 | http://sourceforge.net/project/showfiles.php?group_id=94270&package_id=151751
174 | Just rename the file extension from ".devpack" to ".tar.bz2" and unpack it
175 | with for example WinRAR. Then add the directories include/SDL and lib to the
176 | according search paths in your project.
177 |
178 | IMPORTANT: Do not forget to take care of version.h!
179 | By default it compiles for "Wolfenstein 3D v1.4 full GT/ID/Activision"!
180 |
181 |
182 | TODOs:
183 | ------
184 |
185 | - Add PC speaker emulation
186 | - Center non-ingame screens for resolutions being a multiple of 320x240
187 | - Add support for any graphic resolution >= 320x200
188 |
189 |
190 | Known bugs:
191 | -----------
192 |
193 | - None! ;D
194 |
195 |
196 | Troubleshooting:
197 | ----------------
198 |
199 | - If your frame rate is low, consider using the original screen resolution
200 | (--res 320 200) or lowering the sound quality (--samplerate 22050)
201 |
202 |
203 | Credits:
204 | --------
205 |
206 | - Special thanks to id Software! Without the source code we would still have
207 | to pelt Wolfenstein 3D with hex editors and disassemblers ;D
208 | - Special thanks to the MAME developer team for providing the source code
209 | of the OPL2 emulator!
210 | - Many thanks to "Der Tron" for hosting the svn repository, making Wolf4SDL
211 | FreeBSD compatible, testing, bugfixing and cleaning up the code!
212 | - Thanks to Chris for his improvements on Wolf4GW, on which Wolf4SDL bases.
213 | - Thanks to Pickle for the GP2X support and help on 320x240 support
214 | - Thanks to fackue for the Dreamcast support
215 | - Thanks to Chris Ballinger for the Mac OS X support
216 | - Thanks to Xilinx, Inc. for providing a list of maximum-length LFSR counters
217 | used for higher resolutions of fizzle fade
218 |
219 |
220 | Licenses:
221 | ---------
222 |
223 | - The original source code of Wolfenstein 3D: license-id.txt
224 | - The OPL2 emulator (fmopl.cpp): license-mame.txt
225 |
--------------------------------------------------------------------------------
/gfxv_sod.h:
--------------------------------------------------------------------------------
1 | //////////////////////////////////////
2 | //
3 | // Graphics .H file for .SOD
4 | // IGRAB-ed on Thu Oct 08 20:38:29 1992
5 | //
6 | //////////////////////////////////////
7 |
8 | typedef enum {
9 | // Lump Start
10 | C_BACKDROPPIC=3,
11 | C_MOUSELBACKPIC, // 4
12 | C_CURSOR1PIC, // 5
13 | C_CURSOR2PIC, // 6
14 | C_NOTSELECTEDPIC, // 7
15 | C_SELECTEDPIC, // 8
16 | // Lump Start
17 | C_CUSTOMIZEPIC, // 9
18 | C_JOY1PIC, // 10
19 | C_JOY2PIC, // 11
20 | C_MOUSEPIC, // 12
21 | C_JOYSTICKPIC, // 13
22 | C_KEYBOARDPIC, // 14
23 | C_CONTROLPIC, // 15
24 | // Lump Start
25 | C_OPTIONSPIC, // 16
26 | // Lump Start
27 | C_FXTITLEPIC, // 17
28 | C_DIGITITLEPIC, // 18
29 | C_MUSICTITLEPIC, // 19
30 | // Lump Start
31 | C_HOWTOUGHPIC, // 20
32 | C_BABYMODEPIC, // 21
33 | C_EASYPIC, // 22
34 | C_NORMALPIC, // 23
35 | C_HARDPIC, // 24
36 | // Lump Start
37 | C_DISKLOADING1PIC, // 25
38 | C_DISKLOADING2PIC, // 26
39 | C_LOADGAMEPIC, // 27
40 | C_SAVEGAMEPIC, // 28
41 | // Lump Start
42 | HIGHSCORESPIC, // 29
43 | C_WONSPEARPIC, // 30
44 | #ifndef SPEARDEMO
45 | // Lump Start
46 | BJCOLLAPSE1PIC, // 31
47 | BJCOLLAPSE2PIC, // 32
48 | BJCOLLAPSE3PIC, // 33
49 | BJCOLLAPSE4PIC, // 34
50 | ENDPICPIC, // 35
51 | #endif
52 | // Lump Start
53 | L_GUYPIC, // 36
54 | L_COLONPIC, // 37
55 | L_NUM0PIC, // 38
56 | L_NUM1PIC, // 39
57 | L_NUM2PIC, // 40
58 | L_NUM3PIC, // 41
59 | L_NUM4PIC, // 42
60 | L_NUM5PIC, // 43
61 | L_NUM6PIC, // 44
62 | L_NUM7PIC, // 45
63 | L_NUM8PIC, // 46
64 | L_NUM9PIC, // 47
65 | L_PERCENTPIC, // 48
66 | L_APIC, // 49
67 | L_BPIC, // 50
68 | L_CPIC, // 51
69 | L_DPIC, // 52
70 | L_EPIC, // 53
71 | L_FPIC, // 54
72 | L_GPIC, // 55
73 | L_HPIC, // 56
74 | L_IPIC, // 57
75 | L_JPIC, // 58
76 | L_KPIC, // 59
77 | L_LPIC, // 60
78 | L_MPIC, // 61
79 | L_NPIC, // 62
80 | L_OPIC, // 63
81 | L_PPIC, // 64
82 | L_QPIC, // 65
83 | L_RPIC, // 66
84 | L_SPIC, // 67
85 | L_TPIC, // 68
86 | L_UPIC, // 69
87 | L_VPIC, // 70
88 | L_WPIC, // 71
89 | L_XPIC, // 72
90 | L_YPIC, // 73
91 | L_ZPIC, // 74
92 | L_EXPOINTPIC, // 75
93 | L_APOSTROPHEPIC, // 76
94 | L_GUY2PIC, // 77
95 | L_BJWINSPIC, // 78
96 | // Lump Start
97 | TITLE1PIC, // 79
98 | TITLE2PIC, // 80
99 | #ifndef SPEARDEMO
100 | // Lump Start
101 | ENDSCREEN11PIC, // 81
102 | // Lump Start
103 | ENDSCREEN12PIC, // 82
104 | ENDSCREEN3PIC, // 83
105 | ENDSCREEN4PIC, // 84
106 | ENDSCREEN5PIC, // 85
107 | ENDSCREEN6PIC, // 86
108 | ENDSCREEN7PIC, // 87
109 | ENDSCREEN8PIC, // 88
110 | ENDSCREEN9PIC, // 89
111 | #endif
112 | STATUSBARPIC, // 90
113 | PG13PIC, // 91
114 | CREDITSPIC, // 92
115 | #ifndef SPEARDEMO
116 | // Lump Start
117 | IDGUYS1PIC, // 93
118 | IDGUYS2PIC, // 94
119 | // Lump Start
120 | COPYPROTTOPPIC, // 95
121 | COPYPROTBOXPIC, // 96
122 | BOSSPIC1PIC, // 97
123 | BOSSPIC2PIC, // 98
124 | BOSSPIC3PIC, // 99
125 | BOSSPIC4PIC, // 100
126 | #endif
127 | // Lump Start
128 | KNIFEPIC, // 101
129 | GUNPIC, // 102
130 | MACHINEGUNPIC, // 103
131 | GATLINGGUNPIC, // 104
132 | NOKEYPIC, // 105
133 | GOLDKEYPIC, // 106
134 | SILVERKEYPIC, // 107
135 | N_BLANKPIC, // 108
136 | N_0PIC, // 109
137 | N_1PIC, // 110
138 | N_2PIC, // 111
139 | N_3PIC, // 112
140 | N_4PIC, // 113
141 | N_5PIC, // 114
142 | N_6PIC, // 115
143 | N_7PIC, // 116
144 | N_8PIC, // 117
145 | N_9PIC, // 118
146 | FACE1APIC, // 119
147 | FACE1BPIC, // 120
148 | FACE1CPIC, // 121
149 | FACE2APIC, // 122
150 | FACE2BPIC, // 123
151 | FACE2CPIC, // 124
152 | FACE3APIC, // 125
153 | FACE3BPIC, // 126
154 | FACE3CPIC, // 127
155 | FACE4APIC, // 128
156 | FACE4BPIC, // 129
157 | FACE4CPIC, // 130
158 | FACE5APIC, // 131
159 | FACE5BPIC, // 132
160 | FACE5CPIC, // 133
161 | FACE6APIC, // 134
162 | FACE6BPIC, // 135
163 | FACE6CPIC, // 136
164 | FACE7APIC, // 137
165 | FACE7BPIC, // 138
166 | FACE7CPIC, // 139
167 | FACE8APIC, // 140
168 | GOTGATLINGPIC, // 141
169 | GODMODEFACE1PIC, // 142
170 | GODMODEFACE2PIC, // 143
171 | GODMODEFACE3PIC, // 144
172 | BJWAITING1PIC, // 145
173 | BJWAITING2PIC, // 146
174 | BJOUCHPIC, // 147
175 | PAUSEDPIC, // 148
176 | GETPSYCHEDPIC, // 149
177 |
178 | TILE8, // 150
179 |
180 | ORDERSCREEN, // 151
181 | ERRORSCREEN, // 152
182 | TITLEPALETTE, // 153
183 | #ifndef SPEARDEMO
184 | END1PALETTE, // 154
185 | END2PALETTE, // 155
186 | END3PALETTE, // 156
187 | END4PALETTE, // 157
188 | END5PALETTE, // 158
189 | END6PALETTE, // 159
190 | END7PALETTE, // 160
191 | END8PALETTE, // 161
192 | END9PALETTE, // 162
193 | IDGUYSPALETTE, // 163
194 | #endif
195 | T_DEMO0, // 164
196 | #ifndef SPEARDEMO
197 | T_DEMO1, // 165
198 | T_DEMO2, // 166
199 | T_DEMO3, // 167
200 | T_ENDART1, // 168
201 | #endif
202 | ENUMEND
203 | } graphicnums;
204 |
205 | //
206 | // Data LUMPs
207 | //
208 | #define BACKDROP_LUMP_START 3
209 | #define BACKDROP_LUMP_END 8
210 |
211 | #define CONTROL_LUMP_START 9
212 | #define CONTROL_LUMP_END 15
213 |
214 | #define OPTIONS_LUMP_START 16
215 | #define OPTIONS_LUMP_END 16
216 |
217 | #define SOUND_LUMP_START 17
218 | #define SOUND_LUMP_END 19
219 |
220 | #define NEWGAME_LUMP_START 20
221 | #define NEWGAME_LUMP_END 24
222 |
223 | #define LOADSAVE_LUMP_START 25
224 | #define LOADSAVE_LUMP_END 28
225 |
226 | #define HIGHSCORES_LUMP_START 29
227 | #define HIGHSCORES_LUMP_END 30
228 |
229 | #define ENDGAME_LUMP_START 31
230 | #define ENDGAME_LUMP_END 35
231 |
232 | #define LEVELEND_LUMP_START L_GUYPIC
233 | #define LEVELEND_LUMP_END L_BJWINSPIC
234 |
235 | #define TITLESCREEN_LUMP_START TITLE1PIC
236 | #define TITLESCREEN_LUMP_END TITLE2PIC
237 |
238 | #define ENDGAME1_LUMP_START ENDSCREEN11PIC
239 | #define ENDGAME1_LUMP_END ENDSCREEN11PIC
240 |
241 | #define ENDGAME2_LUMP_START ENDSCREEN12PIC
242 | #define ENDGAME2_LUMP_END ENDSCREEN12PIC
243 |
244 | #define EASTEREGG_LUMP_START IDGUYS1PIC
245 | #define EASTEREGG_LUMP_END IDGUYS2PIC
246 |
247 | #define COPYPROT_LUMP_START COPYPROTTOPPIC
248 | #define COPYPROT_LUMP_END BOSSPIC4PIC
249 |
250 | #define LATCHPICS_LUMP_START KNIFEPIC
251 | #define LATCHPICS_LUMP_END GETPSYCHEDPIC
252 |
253 |
254 | //
255 | // Amount of each data item
256 | //
257 | #define NUMCHUNKS ENUMEND
258 | #define NUMFONT 2
259 | #define NUMFONTM 0
260 | #define NUMPICS (GETPSYCHEDPIC - NUMFONT)
261 | #define NUMPICM 0
262 | #define NUMSPRITES 0
263 | #define NUMTILE8 72
264 | #define NUMTILE8M 0
265 | #define NUMTILE16 0
266 | #define NUMTILE16M 0
267 | #define NUMTILE32 0
268 | #define NUMTILE32M 0
269 | #define NUMEXTERNS 18
270 | //
271 | // File offsets for data items
272 | //
273 | #define STRUCTPIC 0
274 |
275 | #define STARTFONT 1
276 | #define STARTFONTM 3
277 | #define STARTPICS 3
278 | #define STARTPICM TILE8
279 | #define STARTSPRITES TILE8
280 | #define STARTTILE8 TILE8
281 | #define STARTTILE8M ORDERSCREEN
282 | #define STARTTILE16 ORDERSCREEN
283 | #define STARTTILE16M ORDERSCREEN
284 | #define STARTTILE32 ORDERSCREEN
285 | #define STARTTILE32M ORDERSCREEN
286 | #define STARTEXTERNS ORDERSCREEN
287 |
288 | //
289 | // Thank you for using IGRAB!
290 | //
291 |
--------------------------------------------------------------------------------
/macosx/SDLMain.m:
--------------------------------------------------------------------------------
1 | /* SDLMain.m - main entry point for our Cocoa-ized SDL app
2 | Initial Version: Darrell Walisser
3 | Non-NIB-Code & other changes: Max Horn
4 |
5 | Feel free to customize this file to suit your needs
6 | */
7 |
8 | #include "SDL/SDL.h"
9 | #include "SDLMain.h"
10 | #include /* for MAXPATHLEN */
11 | #include
12 |
13 | /* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
14 | but the method still is there and works. To avoid warnings, we declare
15 | it ourselves here. */
16 | @interface NSApplication(SDL_Missing_Methods)
17 | - (void)setAppleMenu:(NSMenu *)menu;
18 | @end
19 |
20 | /* Use this flag to determine whether we use SDLMain.nib or not */
21 | #define SDL_USE_NIB_FILE 0
22 |
23 | /* Use this flag to determine whether we use CPS (docking) or not */
24 | #define SDL_USE_CPS 1
25 | #ifdef SDL_USE_CPS
26 | /* Portions of CPS.h */
27 | typedef struct CPSProcessSerNum
28 | {
29 | UInt32 lo;
30 | UInt32 hi;
31 | } CPSProcessSerNum;
32 |
33 | extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
34 | extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
35 | extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
36 |
37 | #endif /* SDL_USE_CPS */
38 |
39 | static int gArgc;
40 | static char **gArgv;
41 | static BOOL gFinderLaunch;
42 | static BOOL gCalledAppMainline = FALSE;
43 |
44 | static NSString *getApplicationName(void)
45 | {
46 | const NSDictionary *dict;
47 | NSString *appName = 0;
48 |
49 | /* Determine the application name */
50 | dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
51 | if (dict)
52 | appName = [dict objectForKey: @"CFBundleName"];
53 |
54 | if (![appName length])
55 | appName = [[NSProcessInfo processInfo] processName];
56 |
57 | return appName;
58 | }
59 |
60 | #if SDL_USE_NIB_FILE
61 | /* A helper category for NSString */
62 | @interface NSString (ReplaceSubString)
63 | - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
64 | @end
65 | #endif
66 |
67 | @interface NSApplication (SDLApplication)
68 | @end
69 |
70 | @implementation NSApplication (SDLApplication)
71 | /* Invoked from the Quit menu item */
72 | - (void)terminate:(id)sender
73 | {
74 | /* Post a SDL_QUIT event */
75 | SDL_Event event;
76 | event.type = SDL_QUIT;
77 | SDL_PushEvent(&event);
78 | }
79 | @end
80 |
81 | /* The main class of the application, the application's delegate */
82 | @implementation SDLMain
83 |
84 | /* Set the working directory to the .app's parent directory */
85 | - (void) setupWorkingDirectory:(BOOL)shouldChdir
86 | {
87 | if (shouldChdir)
88 | {
89 | char parentdir[MAXPATHLEN];
90 | CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
91 | CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
92 | if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
93 | chdir(parentdir); /* chdir to the binary app's parent */
94 | }
95 | CFRelease(url);
96 | CFRelease(url2);
97 | }
98 | }
99 |
100 | #if SDL_USE_NIB_FILE
101 |
102 | /* Fix menu to contain the real app name instead of "SDL App" */
103 | - (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
104 | {
105 | NSRange aRange;
106 | NSEnumerator *enumerator;
107 | NSMenuItem *menuItem;
108 |
109 | aRange = [[aMenu title] rangeOfString:@"SDL App"];
110 | if (aRange.length != 0)
111 | [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
112 |
113 | enumerator = [[aMenu itemArray] objectEnumerator];
114 | while ((menuItem = [enumerator nextObject]))
115 | {
116 | aRange = [[menuItem title] rangeOfString:@"SDL App"];
117 | if (aRange.length != 0)
118 | [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
119 | if ([menuItem hasSubmenu])
120 | [self fixMenu:[menuItem submenu] withAppName:appName];
121 | }
122 | }
123 |
124 | #else
125 |
126 | static void setApplicationMenu(void)
127 | {
128 | /* warning: this code is very odd */
129 | NSMenu *appleMenu;
130 | NSMenuItem *menuItem;
131 | NSString *title;
132 | NSString *appName;
133 |
134 | appName = getApplicationName();
135 | appleMenu = [[NSMenu alloc] initWithTitle:@""];
136 |
137 | /* Add menu items */
138 | title = [@"About " stringByAppendingString:appName];
139 | [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
140 |
141 | [appleMenu addItem:[NSMenuItem separatorItem]];
142 |
143 | title = [@"Hide " stringByAppendingString:appName];
144 | [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
145 |
146 | menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
147 | [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
148 |
149 | [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
150 |
151 | [appleMenu addItem:[NSMenuItem separatorItem]];
152 |
153 | title = [@"Quit " stringByAppendingString:appName];
154 | [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
155 |
156 |
157 | /* Put menu into the menubar */
158 | menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
159 | [menuItem setSubmenu:appleMenu];
160 | [[NSApp mainMenu] addItem:menuItem];
161 |
162 | /* Tell the application object that this is now the application menu */
163 | [NSApp setAppleMenu:appleMenu];
164 |
165 | /* Finally give up our references to the objects */
166 | [appleMenu release];
167 | [menuItem release];
168 | }
169 |
170 | /* Create a window menu */
171 | static void setupWindowMenu(void)
172 | {
173 | NSMenu *windowMenu;
174 | NSMenuItem *windowMenuItem;
175 | NSMenuItem *menuItem;
176 |
177 | windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
178 |
179 | /* "Minimize" item */
180 | menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
181 | [windowMenu addItem:menuItem];
182 | [menuItem release];
183 |
184 | /* Put menu into the menubar */
185 | windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
186 | [windowMenuItem setSubmenu:windowMenu];
187 | [[NSApp mainMenu] addItem:windowMenuItem];
188 |
189 | /* Tell the application object that this is now the window menu */
190 | [NSApp setWindowsMenu:windowMenu];
191 |
192 | /* Finally give up our references to the objects */
193 | [windowMenu release];
194 | [windowMenuItem release];
195 | }
196 |
197 | /* Replacement for NSApplicationMain */
198 | static void CustomApplicationMain (int argc, char **argv)
199 | {
200 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
201 | SDLMain *sdlMain;
202 |
203 | /* Ensure the application object is initialised */
204 | [NSApplication sharedApplication];
205 |
206 | #ifdef SDL_USE_CPS
207 | {
208 | CPSProcessSerNum PSN;
209 | /* Tell the dock about us */
210 | if (!CPSGetCurrentProcess(&PSN))
211 | if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
212 | if (!CPSSetFrontProcess(&PSN))
213 | [NSApplication sharedApplication];
214 | }
215 | #endif /* SDL_USE_CPS */
216 |
217 | /* Set up the menubar */
218 | [NSApp setMainMenu:[[NSMenu alloc] init]];
219 | setApplicationMenu();
220 | setupWindowMenu();
221 |
222 | /* Create SDLMain and make it the app delegate */
223 | sdlMain = [[SDLMain alloc] init];
224 | [NSApp setDelegate:sdlMain];
225 |
226 | /* Start the main event loop */
227 | [NSApp run];
228 |
229 | [sdlMain release];
230 | [pool release];
231 | }
232 |
233 | #endif
234 |
235 |
236 | /*
237 | * Catch document open requests...this lets us notice files when the app
238 | * was launched by double-clicking a document, or when a document was
239 | * dragged/dropped on the app's icon. You need to have a
240 | * CFBundleDocumentsType section in your Info.plist to get this message,
241 | * apparently.
242 | *
243 | * Files are added to gArgv, so to the app, they'll look like command line
244 | * arguments. Previously, apps launched from the finder had nothing but
245 | * an argv[0].
246 | *
247 | * This message may be received multiple times to open several docs on launch.
248 | *
249 | * This message is ignored once the app's mainline has been called.
250 | */
251 | - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
252 | {
253 | const char *temparg;
254 | size_t arglen;
255 | char *arg;
256 | char **newargv;
257 |
258 | if (!gFinderLaunch) /* MacOS is passing command line args. */
259 | return FALSE;
260 |
261 | if (gCalledAppMainline) /* app has started, ignore this document. */
262 | return FALSE;
263 |
264 | temparg = [filename UTF8String];
265 | arglen = SDL_strlen(temparg) + 1;
266 | arg = (char *) SDL_malloc(arglen);
267 | if (arg == NULL)
268 | return FALSE;
269 |
270 | newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
271 | if (newargv == NULL)
272 | {
273 | SDL_free(arg);
274 | return FALSE;
275 | }
276 | gArgv = newargv;
277 |
278 | SDL_strlcpy(arg, temparg, arglen);
279 | gArgv[gArgc++] = arg;
280 | gArgv[gArgc] = NULL;
281 | return TRUE;
282 | }
283 |
284 |
285 | /* Called when the internal event loop has just started running */
286 | - (void) applicationDidFinishLaunching: (NSNotification *) note
287 | {
288 | int status;
289 |
290 | /* Set the working directory to the .app's parent directory */
291 | [self setupWorkingDirectory:gFinderLaunch];
292 |
293 | #if SDL_USE_NIB_FILE
294 | /* Set the main menu to contain the real app name instead of "SDL App" */
295 | [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
296 | #endif
297 |
298 | /* Hand off to main application code */
299 | gCalledAppMainline = TRUE;
300 | status = SDL_main (gArgc, gArgv);
301 |
302 | /* We're done, thank you for playing */
303 | exit(status);
304 | }
305 | @end
306 |
307 |
308 | @implementation NSString (ReplaceSubString)
309 |
310 | - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
311 | {
312 | unsigned int bufferSize;
313 | unsigned int selfLen = [self length];
314 | unsigned int aStringLen = [aString length];
315 | unichar *buffer;
316 | NSRange localRange;
317 | NSString *result;
318 |
319 | bufferSize = selfLen + aStringLen - aRange.length;
320 | buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
321 |
322 | /* Get first part into buffer */
323 | localRange.location = 0;
324 | localRange.length = aRange.location;
325 | [self getCharacters:buffer range:localRange];
326 |
327 | /* Get middle part into buffer */
328 | localRange.location = 0;
329 | localRange.length = aStringLen;
330 | [aString getCharacters:(buffer+aRange.location) range:localRange];
331 |
332 | /* Get last part into buffer */
333 | localRange.location = aRange.location + aRange.length;
334 | localRange.length = selfLen - localRange.location;
335 | [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
336 |
337 | /* Build output string */
338 | result = [NSString stringWithCharacters:buffer length:bufferSize];
339 |
340 | NSDeallocateMemoryPages(buffer, bufferSize);
341 |
342 | return result;
343 | }
344 |
345 | @end
346 |
347 |
348 |
349 | #ifdef main
350 | # undef main
351 | #endif
352 |
353 |
354 | /* Main entry point to executable - should *not* be SDL_main! */
355 | int main (int argc, char **argv)
356 | {
357 | /* Copy the arguments into a global variable */
358 | /* This is passed if we are launched by double-clicking */
359 | if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
360 | gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
361 | gArgv[0] = argv[0];
362 | gArgv[1] = NULL;
363 | gArgc = 1;
364 | gFinderLaunch = YES;
365 | } else {
366 | int i;
367 | gArgc = argc;
368 | gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
369 | for (i = 0; i <= argc; i++)
370 | gArgv[i] = argv[i];
371 | gFinderLaunch = NO;
372 | }
373 |
374 | #if SDL_USE_NIB_FILE
375 | NSApplicationMain (argc, argv);
376 | #else
377 | CustomApplicationMain (argc, argv);
378 | #endif
379 | return 0;
380 | }
381 |
382 |
--------------------------------------------------------------------------------
/id_vh.cpp:
--------------------------------------------------------------------------------
1 | #include "wl_def.h"
2 |
3 |
4 | pictabletype *pictable;
5 | SDL_Surface *latchpics[NUMLATCHPICS];
6 |
7 | int px,py;
8 | byte fontcolor,backcolor;
9 | int fontnumber;
10 |
11 | //==========================================================================
12 |
13 | void VWB_DrawPropString(const char* string)
14 | {
15 | fontstruct *font;
16 | int width, step, height;
17 | byte *source, *dest;
18 | byte ch;
19 |
20 | byte *vbuf = LOCK();
21 |
22 | font = (fontstruct *) grsegs[STARTFONT+fontnumber];
23 | height = font->height;
24 | dest = vbuf + scaleFactor * (py * curPitch + px);
25 |
26 | while ((ch = (byte)*string++)!=0)
27 | {
28 | width = step = font->width[ch];
29 | source = ((byte *)font)+font->location[ch];
30 | while (width--)
31 | {
32 | for(int i=0;iheight;
99 | for (*width = 0;*string;string++)
100 | *width += font->width[*((byte *)string)]; // proportional width
101 | }
102 |
103 | void VW_MeasurePropString (const char *string, word *width, word *height)
104 | {
105 | VWL_MeasureString(string,width,height,(fontstruct *)grsegs[STARTFONT+fontnumber]);
106 | }
107 |
108 | /*
109 | =============================================================================
110 |
111 | Double buffer management routines
112 |
113 | =============================================================================
114 | */
115 |
116 | void VH_UpdateScreen()
117 | {
118 | SDL_BlitSurface(screenBuffer, NULL, screen, NULL);
119 | SDL_Flip(screen);
120 | }
121 |
122 |
123 | void VWB_DrawTile8 (int x, int y, int tile)
124 | {
125 | LatchDrawChar(x,y,tile);
126 | }
127 |
128 | void VWB_DrawTile8M (int x, int y, int tile)
129 | {
130 | VL_MemToScreen (((byte *)grsegs[STARTTILE8M])+tile*64,8,8,x,y);
131 | }
132 |
133 | void VWB_DrawPic (int x, int y, int chunknum)
134 | {
135 | int picnum = chunknum - STARTPICS;
136 | unsigned width,height;
137 |
138 | x &= ~7;
139 |
140 | width = pictable[picnum].width;
141 | height = pictable[picnum].height;
142 |
143 | VL_MemToScreen (grsegs[chunknum],width,height,x,y);
144 | }
145 |
146 | void VWB_DrawPicScaledCoord (int scx, int scy, int chunknum)
147 | {
148 | int picnum = chunknum - STARTPICS;
149 | unsigned width,height;
150 |
151 | width = pictable[picnum].width;
152 | height = pictable[picnum].height;
153 |
154 | VL_MemToScreenScaledCoord (grsegs[chunknum],width,height,scx,scy);
155 | }
156 |
157 |
158 | void VWB_Bar (int x, int y, int width, int height, int color)
159 | {
160 | VW_Bar (x,y,width,height,color);
161 | }
162 |
163 | void VWB_Plot (int x, int y, int color)
164 | {
165 | if(scaleFactor == 1)
166 | VW_Plot(x,y,color);
167 | else
168 | VW_Bar(x, y, 1, 1, color);
169 | }
170 |
171 | void VWB_Hlin (int x1, int x2, int y, int color)
172 | {
173 | if(scaleFactor == 1)
174 | VW_Hlin(x1,x2,y,color);
175 | else
176 | VW_Bar(x1, y, x2-x1+1, 1, color);
177 | }
178 |
179 | void VWB_Vlin (int y1, int y2, int x, int color)
180 | {
181 | if(scaleFactor == 1)
182 | VW_Vlin(y1,y2,x,color);
183 | else
184 | VW_Bar(x, y1, 1, y2-y1+1, color);
185 | }
186 |
187 |
188 | /*
189 | =============================================================================
190 |
191 | WOLFENSTEIN STUFF
192 |
193 | =============================================================================
194 | */
195 |
196 | /*
197 | =====================
198 | =
199 | = LatchDrawPic
200 | =
201 | =====================
202 | */
203 |
204 | void LatchDrawPic (unsigned x, unsigned y, unsigned picnum)
205 | {
206 | VL_LatchToScreen (latchpics[2+picnum-LATCHPICS_LUMP_START], x*8, y);
207 | }
208 |
209 | void LatchDrawPicScaledCoord (unsigned scx, unsigned scy, unsigned picnum)
210 | {
211 | VL_LatchToScreenScaledCoord (latchpics[2+picnum-LATCHPICS_LUMP_START], scx*8, scy);
212 | }
213 |
214 |
215 | //==========================================================================
216 |
217 | /*
218 | ===================
219 | =
220 | = LoadLatchMem
221 | =
222 | ===================
223 | */
224 |
225 | void LoadLatchMem (void)
226 | {
227 | int i,width,height,start,end;
228 | byte *src;
229 | SDL_Surface *surf;
230 |
231 | //
232 | // tile 8s
233 | //
234 |
235 | surf = SDL_CreateRGBSurface(SDL_HWSURFACE, 8*8,
236 | ((NUMTILE8 + 7) / 8) * 8, 8, 0, 0, 0, 0);
237 | if(surf == NULL)
238 | {
239 | Quit("Unable to create surface for tiles!");
240 | }
241 | SDL_SetColors(surf, gamepal, 0, 256);
242 |
243 | latchpics[0] = surf;
244 | CA_CacheGrChunk (STARTTILE8);
245 | src = grsegs[STARTTILE8];
246 |
247 | for (i=0;i> 3) * 8);
250 | src += 64;
251 | }
252 | UNCACHEGRCHUNK (STARTTILE8);
253 |
254 | //
255 | // pics
256 | //
257 | start = LATCHPICS_LUMP_START;
258 | end = LATCHPICS_LUMP_END;
259 |
260 | for (i=start;i<=end;i++)
261 | {
262 | width = pictable[i-STARTPICS].width;
263 | height = pictable[i-STARTPICS].height;
264 | surf = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, 8, 0, 0, 0, 0);
265 | if(surf == NULL)
266 | {
267 | Quit("Unable to create surface for picture!");
268 | }
269 | SDL_SetColors(surf, gamepal, 0, 256);
270 |
271 | latchpics[2+i-start] = surf;
272 | CA_CacheGrChunk (i);
273 | VL_MemToLatch (grsegs[i], width, height, surf, 0, 0);
274 | UNCACHEGRCHUNK(i);
275 | }
276 | }
277 |
278 | //==========================================================================
279 |
280 | /*
281 | ===================
282 | =
283 | = FizzleFade
284 | =
285 | = returns true if aborted
286 | =
287 | = It uses maximum-length Linear Feedback Shift Registers (LFSR) counters.
288 | = You can find a list of them with lengths from 3 to 168 at:
289 | = http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf
290 | = Many thanks to Xilinx for this list!!!
291 | =
292 | ===================
293 | */
294 |
295 | // XOR masks for the pseudo-random number sequence starting with n=17 bits
296 | static const uint32_t rndmasks[] = {
297 | // n XNOR from (starting at 1, not 0 as usual)
298 | 0x00012000, // 17 17,14
299 | 0x00020400, // 18 18,11
300 | 0x00040023, // 19 19,6,2,1
301 | 0x00090000, // 20 20,17
302 | 0x00140000, // 21 21,19
303 | 0x00300000, // 22 22,21
304 | 0x00420000, // 23 23,18
305 | 0x00e10000, // 24 24,23,22,17
306 | 0x01200000, // 25 25,22 (this is enough for 8191x4095)
307 | };
308 |
309 | static unsigned int rndbits_y;
310 | static unsigned int rndmask;
311 |
312 | extern SDL_Color curpal[256];
313 |
314 | // Returns the number of bits needed to represent the given value
315 | static int log2_ceil(uint32_t x)
316 | {
317 | int n = 0;
318 | uint32_t v = 1;
319 | while(v < x)
320 | {
321 | n++;
322 | v <<= 1;
323 | }
324 | return n;
325 | }
326 |
327 | void VH_Startup()
328 | {
329 | int rndbits_x = log2_ceil(screenWidth);
330 | rndbits_y = log2_ceil(screenHeight);
331 |
332 | int rndbits = rndbits_x + rndbits_y;
333 | if(rndbits < 17)
334 | rndbits = 17; // no problem, just a bit slower
335 | else if(rndbits > 25)
336 | rndbits = 25; // fizzle fade will not fill whole screen
337 |
338 | rndmask = rndmasks[rndbits - 17];
339 | }
340 |
341 | boolean FizzleFade (SDL_Surface *source, int x1, int y1,
342 | unsigned width, unsigned height, unsigned frames, boolean abortable)
343 | {
344 |
345 | unsigned x, y, frame, pixperframe;
346 | int32_t rndval, lastrndval;
347 | int first = 1;
348 |
349 | lastrndval = 0;
350 | pixperframe = width * height / frames;
351 |
352 | IN_StartAck ();
353 |
354 | frame = GetTimeCount();
355 |
356 | //can't rely on screen as dest b/c crt.cpp writes over it with screenBuffer
357 | //can't rely on screenBuffer as source for same reason: every flip it has to be updated
358 | SDL_Surface *source_copy = SDL_ConvertSurface(source, source->format, source->flags);
359 | SDL_Surface *screen_copy = SDL_ConvertSurface(screen, screen->format, screen->flags);
360 |
361 | byte *srcptr = VL_LockSurface(source_copy);
362 | do
363 | {
364 | if(abortable && IN_CheckAck ())
365 | {
366 | VL_UnlockSurface(source_copy);
367 | SDL_BlitSurface(screen_copy, NULL, screenBuffer, NULL);
368 | SDL_BlitSurface(screenBuffer, NULL, screen, NULL);
369 | SDL_Flip(screen);
370 | SDL_FreeSurface(source_copy);
371 | SDL_FreeSurface(screen_copy);
372 | return true;
373 | }
374 |
375 | byte *destptr = VL_LockSurface(screen_copy);
376 |
377 | rndval = lastrndval;
378 |
379 | // When using double buffering, we have to copy the pixels of the last AND the current frame.
380 | // Only for the first frame, there is no "last frame"
381 | for(int i = first; i < 2; i++)
382 | {
383 | for(unsigned p = 0; p < pixperframe; p++)
384 | {
385 | //
386 | // seperate random value into x/y pair
387 | //
388 |
389 | x = rndval >> rndbits_y;
390 | y = rndval & ((1 << rndbits_y) - 1);
391 |
392 | //
393 | // advance to next random element
394 | //
395 |
396 | rndval = (rndval >> 1) ^ (rndval & 1 ? 0 : rndmask);
397 |
398 | if(x >= width || y >= height)
399 | {
400 | if(rndval == 0) // entire sequence has been completed
401 | goto finished;
402 | p--;
403 | continue;
404 | }
405 |
406 | //
407 | // copy one pixel
408 | //
409 |
410 | if(screenBits == 8)
411 | {
412 | *(destptr + (y1 + y) * screen->pitch + x1 + x)
413 | = *(srcptr + (y1 + y) * source->pitch + x1 + x);
414 | }
415 | else
416 | {
417 | byte col = *(srcptr + (y1 + y) * source->pitch + x1 + x);
418 | uint32_t fullcol = SDL_MapRGB(screen->format, curpal[col].r, curpal[col].g, curpal[col].b);
419 | memcpy(destptr + (y1 + y) * screen->pitch + (x1 + x) * screen->format->BytesPerPixel,
420 | &fullcol, screen->format->BytesPerPixel);
421 | }
422 |
423 | if(rndval == 0) // entire sequence has been completed
424 | goto finished;
425 | }
426 |
427 | if(!i || first) lastrndval = rndval;
428 | }
429 |
430 | // If there is no double buffering, we always use the "first frame" case
431 | if(usedoublebuffering) first = 0;
432 |
433 | VL_UnlockSurface(screen_copy);
434 | SDL_BlitSurface(screen_copy, NULL, screenBuffer, NULL);
435 | SDL_BlitSurface(screenBuffer, NULL, screen, NULL);
436 | SDL_Flip(screen);
437 |
438 | frame++;
439 | Delay(frame - GetTimeCount()); // don't go too fast
440 | } while (1);
441 |
442 | finished:
443 | VL_UnlockSurface(source_copy);
444 | VL_UnlockSurface(screen_copy);
445 | SDL_BlitSurface(screen_copy, NULL, screenBuffer, NULL);
446 | SDL_BlitSurface(screenBuffer, NULL, screen, NULL);
447 | SDL_Flip(screen);
448 | SDL_FreeSurface(source_copy);
449 | SDL_FreeSurface(screen_copy);
450 | return false;
451 | }
452 |
--------------------------------------------------------------------------------
/id_in.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // ID Engine
3 | // ID_IN.c - Input Manager
4 | // v1.0d1
5 | // By Jason Blochowiak
6 | //
7 |
8 | //
9 | // This module handles dealing with the various input devices
10 | //
11 | // Depends on: Memory Mgr (for demo recording), Sound Mgr (for timing stuff),
12 | // User Mgr (for command line parms)
13 | //
14 | // Globals:
15 | // LastScan - The keyboard scan code of the last key pressed
16 | // LastASCII - The ASCII value of the last key pressed
17 | // DEBUG - there are more globals
18 | //
19 |
20 | #include "wl_def.h"
21 |
22 |
23 | /*
24 | =============================================================================
25 |
26 | GLOBAL VARIABLES
27 |
28 | =============================================================================
29 | */
30 |
31 |
32 | //
33 | // configuration variables
34 | //
35 | boolean MousePresent;
36 | boolean forcegrabmouse;
37 |
38 |
39 | // Global variables
40 | volatile boolean Keyboard[SDLK_LAST];
41 | volatile boolean Paused;
42 | volatile char LastASCII;
43 | volatile ScanCode LastScan;
44 |
45 | //KeyboardDef KbdDefs = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};
46 | static KeyboardDef KbdDefs = {
47 | sc_Control, // button0
48 | sc_Alt, // button1
49 | sc_Home, // upleft
50 | sc_UpArrow, // up
51 | sc_PgUp, // upright
52 | sc_LeftArrow, // left
53 | sc_RightArrow, // right
54 | sc_End, // downleft
55 | sc_DownArrow, // down
56 | sc_PgDn // downright
57 | };
58 |
59 | static SDL_Joystick *Joystick;
60 | int JoyNumButtons;
61 | static int JoyNumHats;
62 |
63 | static bool GrabInput = false;
64 |
65 | /*
66 | =============================================================================
67 |
68 | LOCAL VARIABLES
69 |
70 | =============================================================================
71 | */
72 | byte ASCIINames[] = // Unshifted ASCII for scan codes // TODO: keypad
73 | {
74 | // 0 1 2 3 4 5 6 7 8 9 A B C D E F
75 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,8 ,9 ,0 ,0 ,0 ,13 ,0 ,0 , // 0
76 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,27 ,0 ,0 ,0 , // 1
77 | ' ',0 ,0 ,0 ,0 ,0 ,0 ,39 ,0 ,0 ,'*','+',',','-','.','/', // 2
78 | '0','1','2','3','4','5','6','7','8','9',0 ,';',0 ,'=',0 ,0 , // 3
79 | '`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o', // 4
80 | 'p','q','r','s','t','u','v','w','x','y','z','[',92 ,']',0 ,0 , // 5
81 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
82 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
83 | };
84 | byte ShiftNames[] = // Shifted ASCII for scan codes
85 | {
86 | // 0 1 2 3 4 5 6 7 8 9 A B C D E F
87 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,8 ,9 ,0 ,0 ,0 ,13 ,0 ,0 , // 0
88 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,27 ,0 ,0 ,0 , // 1
89 | ' ',0 ,0 ,0 ,0 ,0 ,0 ,34 ,0 ,0 ,'*','+','<','_','>','?', // 2
90 | ')','!','@','#','$','%','^','&','*','(',0 ,':',0 ,'+',0 ,0 , // 3
91 | '~','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O', // 4
92 | 'P','Q','R','S','T','U','V','W','X','Y','Z','{','|','}',0 ,0 , // 5
93 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
94 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
95 | };
96 | byte SpecialNames[] = // ASCII for 0xe0 prefixed codes
97 | {
98 | // 0 1 2 3 4 5 6 7 8 9 A B C D E F
99 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 0
100 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,13 ,0 ,0 ,0 , // 1
101 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 2
102 | 0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3
103 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4
104 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
105 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
106 | 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
107 | };
108 |
109 |
110 | static boolean IN_Started;
111 |
112 | static Direction DirTable[] = // Quick lookup for total direction
113 | {
114 | dir_NorthWest, dir_North, dir_NorthEast,
115 | dir_West, dir_None, dir_East,
116 | dir_SouthWest, dir_South, dir_SouthEast
117 | };
118 |
119 |
120 | ///////////////////////////////////////////////////////////////////////////
121 | //
122 | // INL_GetMouseButtons() - Gets the status of the mouse buttons from the
123 | // mouse driver
124 | //
125 | ///////////////////////////////////////////////////////////////////////////
126 | static int
127 | INL_GetMouseButtons(void)
128 | {
129 | int buttons = SDL_GetMouseState(NULL, NULL);
130 | int middlePressed = buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE);
131 | int rightPressed = buttons & SDL_BUTTON(SDL_BUTTON_RIGHT);
132 | buttons &= ~(SDL_BUTTON(SDL_BUTTON_MIDDLE) | SDL_BUTTON(SDL_BUTTON_RIGHT));
133 | if(middlePressed) buttons |= 1 << 2;
134 | if(rightPressed) buttons |= 1 << 1;
135 |
136 | return buttons;
137 | }
138 |
139 | ///////////////////////////////////////////////////////////////////////////
140 | //
141 | // IN_GetJoyDelta() - Returns the relative movement of the specified
142 | // joystick (from +/-127)
143 | //
144 | ///////////////////////////////////////////////////////////////////////////
145 | void IN_GetJoyDelta(int *dx,int *dy)
146 | {
147 | if(!Joystick)
148 | {
149 | *dx = *dy = 0;
150 | return;
151 | }
152 |
153 | SDL_JoystickUpdate();
154 |
155 | int x = SDL_JoystickGetAxis(Joystick, 0) >> 8;
156 | int y = SDL_JoystickGetAxis(Joystick, 1) >> 8;
157 |
158 | if(param_joystickhat != -1)
159 | {
160 | uint8_t hatState = SDL_JoystickGetHat(Joystick, param_joystickhat);
161 | if(hatState & SDL_HAT_RIGHT)
162 | x += 127;
163 | else if(hatState & SDL_HAT_LEFT)
164 | x -= 127;
165 | if(hatState & SDL_HAT_DOWN)
166 | y += 127;
167 | else if(hatState & SDL_HAT_UP)
168 | y -= 127;
169 |
170 | if(x < -128) x = -128;
171 | else if(x > 127) x = 127;
172 |
173 | if(y < -128) y = -128;
174 | else if(y > 127) y = 127;
175 | }
176 |
177 | *dx = x;
178 | *dy = y;
179 | }
180 |
181 | ///////////////////////////////////////////////////////////////////////////
182 | //
183 | // IN_GetJoyFineDelta() - Returns the relative movement of the specified
184 | // joystick without dividing the results by 256 (from +/-127)
185 | //
186 | ///////////////////////////////////////////////////////////////////////////
187 | void IN_GetJoyFineDelta(int *dx, int *dy)
188 | {
189 | if(!Joystick)
190 | {
191 | *dx = 0;
192 | *dy = 0;
193 | return;
194 | }
195 |
196 | SDL_JoystickUpdate();
197 | int x = SDL_JoystickGetAxis(Joystick, 0);
198 | int y = SDL_JoystickGetAxis(Joystick, 1);
199 |
200 | if(x < -128) x = -128;
201 | else if(x > 127) x = 127;
202 |
203 | if(y < -128) y = -128;
204 | else if(y > 127) y = 127;
205 |
206 | *dx = x;
207 | *dy = y;
208 | }
209 |
210 | /*
211 | ===================
212 | =
213 | = IN_JoyButtons
214 | =
215 | ===================
216 | */
217 |
218 | int IN_JoyButtons()
219 | {
220 | if(!Joystick) return 0;
221 |
222 | SDL_JoystickUpdate();
223 |
224 | int res = 0;
225 | for(int i = 0; i < JoyNumButtons && i < 32; i++)
226 | res |= SDL_JoystickGetButton(Joystick, i) << i;
227 | return res;
228 | }
229 |
230 | boolean IN_JoyPresent()
231 | {
232 | return Joystick != NULL;
233 | }
234 |
235 | static void processEvent(SDL_Event *event)
236 | {
237 | switch (event->type)
238 | {
239 | // exit if the window is closed
240 | case SDL_QUIT:
241 | Quit(NULL);
242 |
243 | // check for keypresses
244 | case SDL_KEYDOWN:
245 | {
246 | if(event->key.keysym.sym==SDLK_SCROLLOCK || event->key.keysym.sym==SDLK_F12)
247 | {
248 | GrabInput = !GrabInput;
249 | SDL_WM_GrabInput(GrabInput ? SDL_GRAB_ON : SDL_GRAB_OFF);
250 | return;
251 | }
252 |
253 | LastScan = event->key.keysym.sym;
254 | SDLMod mod = SDL_GetModState();
255 | if(Keyboard[sc_Alt])
256 | {
257 | if(LastScan==SDLK_F4)
258 | Quit(NULL);
259 | }
260 |
261 | if(LastScan == SDLK_KP_ENTER) LastScan = SDLK_RETURN;
262 | else if(LastScan == SDLK_RSHIFT) LastScan = SDLK_LSHIFT;
263 | else if(LastScan == SDLK_RALT) LastScan = SDLK_LALT;
264 | else if(LastScan == SDLK_RCTRL) LastScan = SDLK_LCTRL;
265 | else
266 | {
267 | if((mod & KMOD_NUM) == 0)
268 | {
269 | switch(LastScan)
270 | {
271 | case SDLK_KP2: LastScan = SDLK_DOWN; break;
272 | case SDLK_KP4: LastScan = SDLK_LEFT; break;
273 | case SDLK_KP6: LastScan = SDLK_RIGHT; break;
274 | case SDLK_KP8: LastScan = SDLK_UP; break;
275 | }
276 | }
277 | }
278 |
279 | int sym = LastScan;
280 | if(sym >= 'a' && sym <= 'z')
281 | sym -= 32; // convert to uppercase
282 |
283 | if(mod & (KMOD_SHIFT | KMOD_CAPS))
284 | {
285 | if(sym < lengthof(ShiftNames) && ShiftNames[sym])
286 | LastASCII = ShiftNames[sym];
287 | }
288 | else
289 | {
290 | if(sym < lengthof(ASCIINames) && ASCIINames[sym])
291 | LastASCII = ASCIINames[sym];
292 | }
293 |
294 | if (LastScankey.keysym.sym;
308 | if(key == SDLK_KP_ENTER) key = SDLK_RETURN;
309 | else if(key == SDLK_RSHIFT) key = SDLK_LSHIFT;
310 | else if(key == SDLK_RALT) key = SDLK_LALT;
311 | else if(key == SDLK_RCTRL) key = SDLK_LCTRL;
312 | else
313 | {
314 | if((SDL_GetModState() & KMOD_NUM) == 0)
315 | {
316 | switch(key)
317 | {
318 | case SDLK_KP2: key = SDLK_DOWN; break;
319 | case SDLK_KP4: key = SDLK_LEFT; break;
320 | case SDLK_KP6: key = SDLK_RIGHT; break;
321 | case SDLK_KP8: key = SDLK_UP; break;
322 | }
323 | }
324 | }
325 |
326 | if(key= 0 && param_joystickindex < SDL_NumJoysticks())
371 | {
372 | Joystick = SDL_JoystickOpen(param_joystickindex);
373 | if(Joystick)
374 | {
375 | JoyNumButtons = SDL_JoystickNumButtons(Joystick);
376 | if(JoyNumButtons > 32) JoyNumButtons = 32; // only up to 32 buttons are supported
377 | JoyNumHats = SDL_JoystickNumHats(Joystick);
378 | if(param_joystickhat < -1 || param_joystickhat >= JoyNumHats)
379 | Quit("The joystickhat param must be between 0 and %i!", JoyNumHats - 1);
380 | }
381 | }
382 |
383 | SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
384 |
385 | if(fullscreen || forcegrabmouse)
386 | {
387 | GrabInput = true;
388 | SDL_WM_GrabInput(SDL_GRAB_ON);
389 | }
390 |
391 | // I didn't find a way to ask libSDL whether a mouse is present, yet...
392 |
393 | MousePresent = true;
394 |
395 | IN_Started = true;
396 | }
397 |
398 | ///////////////////////////////////////////////////////////////////////////
399 | //
400 | // IN_Shutdown() - Shuts down the Input Mgr
401 | //
402 | ///////////////////////////////////////////////////////////////////////////
403 | void
404 | IN_Shutdown(void)
405 | {
406 | if (!IN_Started)
407 | return;
408 |
409 | if(Joystick)
410 | SDL_JoystickClose(Joystick);
411 |
412 | IN_Started = false;
413 | }
414 |
415 | ///////////////////////////////////////////////////////////////////////////
416 | //
417 | // IN_ClearKeysDown() - Clears the keyboard array
418 | //
419 | ///////////////////////////////////////////////////////////////////////////
420 | void
421 | IN_ClearKeysDown(void)
422 | {
423 | LastScan = sc_None;
424 | LastASCII = key_None;
425 | memset ((void *) Keyboard,0,sizeof(Keyboard));
426 | }
427 |
428 |
429 | ///////////////////////////////////////////////////////////////////////////
430 | //
431 | // IN_ReadControl() - Reads the device associated with the specified
432 | // player and fills in the control info struct
433 | //
434 | ///////////////////////////////////////////////////////////////////////////
435 | void
436 | IN_ReadControl(int player,ControlInfo *info)
437 | {
438 | word buttons;
439 | int dx,dy;
440 | Motion mx,my;
441 |
442 | dx = dy = 0;
443 | mx = my = motion_None;
444 | buttons = 0;
445 |
446 | IN_ProcessEvents();
447 |
448 | if (Keyboard[KbdDefs.upleft])
449 | mx = motion_Left,my = motion_Up;
450 | else if (Keyboard[KbdDefs.upright])
451 | mx = motion_Right,my = motion_Up;
452 | else if (Keyboard[KbdDefs.downleft])
453 | mx = motion_Left,my = motion_Down;
454 | else if (Keyboard[KbdDefs.downright])
455 | mx = motion_Right,my = motion_Down;
456 |
457 | if (Keyboard[KbdDefs.up])
458 | my = motion_Up;
459 | else if (Keyboard[KbdDefs.down])
460 | my = motion_Down;
461 |
462 | if (Keyboard[KbdDefs.left])
463 | mx = motion_Left;
464 | else if (Keyboard[KbdDefs.right])
465 | mx = motion_Right;
466 |
467 | if (Keyboard[KbdDefs.button0])
468 | buttons += 1 << 0;
469 | if (Keyboard[KbdDefs.button1])
470 | buttons += 1 << 1;
471 |
472 | dx = mx * 127;
473 | dy = my * 127;
474 |
475 | info->x = dx;
476 | info->xaxis = mx;
477 | info->y = dy;
478 | info->yaxis = my;
479 | info->button0 = (buttons & (1 << 0)) != 0;
480 | info->button1 = (buttons & (1 << 1)) != 0;
481 | info->button2 = (buttons & (1 << 2)) != 0;
482 | info->button3 = (buttons & (1 << 3)) != 0;
483 | info->dir = DirTable[((my + 1) * 3) + (mx + 1)];
484 | }
485 |
486 | ///////////////////////////////////////////////////////////////////////////
487 | //
488 | // IN_Ack() - waits for a button or key press. If a button is down, upon
489 | // calling, it must be released for it to be recognized
490 | //
491 | ///////////////////////////////////////////////////////////////////////////
492 |
493 | boolean btnstate[NUMBUTTONS];
494 |
495 | void IN_StartAck(void)
496 | {
497 | IN_ProcessEvents();
498 | //
499 | // get initial state of everything
500 | //
501 | IN_ClearKeysDown();
502 | memset(btnstate, 0, sizeof(btnstate));
503 |
504 | int buttons = IN_JoyButtons() << 4;
505 |
506 | if(MousePresent)
507 | buttons |= IN_MouseButtons();
508 |
509 | for(int i = 0; i < NUMBUTTONS; i++, buttons >>= 1)
510 | if(buttons & 1)
511 | btnstate[i] = true;
512 | }
513 |
514 |
515 | boolean IN_CheckAck (void)
516 | {
517 | IN_ProcessEvents();
518 | //
519 | // see if something has been pressed
520 | //
521 | if(LastScan)
522 | return true;
523 |
524 | int buttons = IN_JoyButtons() << 4;
525 |
526 | if(MousePresent)
527 | buttons |= IN_MouseButtons();
528 |
529 | for(int i = 0; i < NUMBUTTONS; i++, buttons >>= 1)
530 | {
531 | if(buttons & 1)
532 | {
533 | if(!btnstate[i])
534 | {
535 | // Wait until button has been released
536 | do
537 | {
538 | IN_WaitAndProcessEvents();
539 | buttons = IN_JoyButtons() << 4;
540 |
541 | if(MousePresent)
542 | buttons |= IN_MouseButtons();
543 | }
544 | while(buttons & (1 << i));
545 |
546 | return true;
547 | }
548 | }
549 | else
550 | btnstate[i] = false;
551 | }
552 |
553 | return false;
554 | }
555 |
556 |
557 | void IN_Ack (void)
558 | {
559 | IN_StartAck ();
560 |
561 | do
562 | {
563 | IN_WaitAndProcessEvents();
564 | }
565 | while(!IN_CheckAck ());
566 | }
567 |
568 |
569 | ///////////////////////////////////////////////////////////////////////////
570 | //
571 | // IN_UserInput() - Waits for the specified delay time (in ticks) or the
572 | // user pressing a key or a mouse button. If the clear flag is set, it
573 | // then either clears the key or waits for the user to let the mouse
574 | // button up.
575 | //
576 | ///////////////////////////////////////////////////////////////////////////
577 | boolean IN_UserInput(longword delay)
578 | {
579 | longword lasttime;
580 |
581 | lasttime = GetTimeCount();
582 | IN_StartAck ();
583 | do
584 | {
585 | IN_ProcessEvents();
586 | if (IN_CheckAck())
587 | return true;
588 | SDL_Delay(5);
589 | } while (GetTimeCount() - lasttime < delay);
590 | return(false);
591 | }
592 |
593 | //===========================================================================
594 |
595 | /*
596 | ===================
597 | =
598 | = IN_MouseButtons
599 | =
600 | ===================
601 | */
602 | int IN_MouseButtons (void)
603 | {
604 | if (MousePresent)
605 | return INL_GetMouseButtons();
606 | else
607 | return 0;
608 | }
609 |
610 | bool IN_IsInputGrabbed()
611 | {
612 | return GrabInput;
613 | }
614 |
615 | void IN_CenterMouse()
616 | {
617 | SDL_WarpMouse(screenWidth / 2, screenHeight / 2);
618 | }
619 |
--------------------------------------------------------------------------------
/id_vl.cpp:
--------------------------------------------------------------------------------
1 | // ID_VL.C
2 |
3 | #include
4 | #include "wl_def.h"
5 | #include "crt.h"
6 | #pragma hdrstop
7 |
8 | // Uncomment the following line, if you get destination out of bounds
9 | // assertion errors and want to ignore them during debugging
10 | //#define IGNORE_BAD_DEST
11 |
12 | #ifdef IGNORE_BAD_DEST
13 | #undef assert
14 | #define assert(x) if(!(x)) return
15 | #define assert_ret(x) if(!(x)) return 0
16 | #else
17 | #define assert_ret(x) assert(x)
18 | #endif
19 |
20 | boolean fullscreen = false;
21 |
22 |
23 | boolean usedoublebuffering = true;
24 | unsigned screenWidth = 640;
25 | unsigned screenHeight = 480;
26 | unsigned screenBits = -1; // use "best" color depth according to libSDL
27 |
28 |
29 | SDL_Surface *screen = NULL;
30 | unsigned screenPitch;
31 |
32 | SDL_Surface *screenBuffer = NULL;
33 | unsigned bufferPitch;
34 |
35 | SDL_Surface *curSurface = NULL;
36 | unsigned curPitch;
37 |
38 | unsigned scaleFactor;
39 |
40 | boolean screenfaded;
41 | unsigned bordercolor;
42 |
43 | SDL_Color palette1[256], palette2[256];
44 | SDL_Color curpal[256];
45 |
46 |
47 | #define CASSERT(x) extern int ASSERT_COMPILE[((x) != 0) * 2 - 1];
48 | #define RGB(r, g, b) {(r)*255/63, (g)*255/63, (b)*255/63, 0}
49 |
50 | SDL_Color gamepal[]={
51 | #ifdef SPEAR
52 | #include "sodpal.inc"
53 | #else
54 | #include "wolfpal.inc"
55 | #endif
56 | };
57 |
58 | CASSERT(lengthof(gamepal) == 256)
59 |
60 | //===========================================================================
61 |
62 |
63 | /*
64 | =======================
65 | =
66 | = VL_Shutdown
67 | =
68 | =======================
69 | */
70 |
71 | void VL_Shutdown (void)
72 | {
73 | //VL_SetTextMode ();
74 | }
75 |
76 |
77 | /*
78 | =======================
79 | =
80 | = VL_SetVGAPlaneMode
81 | =
82 | =======================
83 | */
84 |
85 | void VL_SetVGAPlaneMode (void)
86 | {
87 | #ifdef SPEAR
88 | SDL_WM_SetCaption("Spear of Destiny", NULL);
89 | #else
90 | SDL_WM_SetCaption("Wolfenstein 3D", NULL);
91 | #endif
92 |
93 | if(screenBits == -1)
94 | {
95 | const SDL_VideoInfo *vidInfo = SDL_GetVideoInfo();
96 | screenBits = vidInfo->vfmt->BitsPerPixel;
97 | }
98 |
99 | //Fab's CRT Hack
100 | //Adjust height so the screen is 4:3 aspect ratio
101 | screenHeight=screenWidth * 3.0/4.0;
102 |
103 | screen = SDL_SetVideoMode(screenWidth, screenHeight, screenBits,
104 | (usedoublebuffering ? SDL_HWSURFACE | SDL_DOUBLEBUF : 0)
105 | | (screenBits == 8 ? SDL_HWPALETTE : 0)
106 | | (fullscreen ? SDL_FULLSCREEN : 0) | SDL_OPENGL | SDL_OPENGLBLIT);
107 |
108 |
109 | if(!screen)
110 | {
111 | printf("Unable to set %ix%ix%i video mode: %s\n", screenWidth, screenHeight, screenBits, SDL_GetError());
112 | exit(1);
113 | }
114 | if((screen->flags & SDL_DOUBLEBUF) != SDL_DOUBLEBUF)
115 | usedoublebuffering = false;
116 | SDL_ShowCursor(SDL_DISABLE);
117 |
118 | SDL_SetColors(screen, gamepal, 0, 256);
119 | memcpy(curpal, gamepal, sizeof(SDL_Color) * 256);
120 |
121 | //Fab's CRT Hack
122 | CRT_Init(screenWidth);
123 |
124 | //Fab's CRT Hack
125 | screenWidth=320;
126 | screenHeight=200;
127 |
128 | screenBuffer = SDL_CreateRGBSurface(SDL_SWSURFACE, screenWidth,
129 | screenHeight, 8, 0, 0, 0, 0);
130 | if(!screenBuffer)
131 | {
132 | printf("Unable to create screen buffer surface: %s\n", SDL_GetError());
133 | exit(1);
134 | }
135 | SDL_SetColors(screenBuffer, gamepal, 0, 256);
136 |
137 | screenPitch = screen->pitch;
138 | bufferPitch = screenBuffer->pitch;
139 |
140 | curSurface = screenBuffer;
141 | curPitch = bufferPitch;
142 |
143 | scaleFactor = screenWidth/320;
144 | if(screenHeight/200 < scaleFactor) scaleFactor = screenHeight/200;
145 |
146 |
147 | pixelangle = (short *) malloc(screenWidth * sizeof(short));
148 | CHECKMALLOCRESULT(pixelangle);
149 | wallheight = (int *) malloc(screenWidth * sizeof(int));
150 | CHECKMALLOCRESULT(wallheight);
151 |
152 |
153 | }
154 |
155 | /*
156 | =============================================================================
157 |
158 | PALETTE OPS
159 |
160 | To avoid snow, do a WaitVBL BEFORE calling these
161 |
162 | =============================================================================
163 | */
164 |
165 | /*
166 | =================
167 | =
168 | = VL_ConvertPalette
169 | =
170 | =================
171 | */
172 |
173 | void VL_ConvertPalette(byte *srcpal, SDL_Color *destpal, int numColors)
174 | {
175 | for(int i=0; ir;
245 | *green = col->g;
246 | *blue = col->b;
247 | }
248 |
249 | //===========================================================================
250 |
251 | /*
252 | =================
253 | =
254 | = VL_SetPalette
255 | =
256 | =================
257 | */
258 |
259 | void VL_SetPalette (SDL_Color *palette, bool forceupdate)
260 | {
261 | memcpy(curpal, palette, sizeof(SDL_Color) * 256);
262 |
263 | if(screenBits == 8)
264 | SDL_SetPalette(screen, SDL_PHYSPAL, palette, 0, 256);
265 | else
266 | {
267 | SDL_SetPalette(curSurface, SDL_LOGPAL, palette, 0, 256);
268 | if(forceupdate)
269 | {
270 | SDL_BlitSurface(screenBuffer, NULL, screen, NULL);
271 | SDL_Flip(screen);
272 | }
273 | }
274 | }
275 |
276 |
277 | //===========================================================================
278 |
279 | /*
280 | =================
281 | =
282 | = VL_GetPalette
283 | =
284 | =================
285 | */
286 |
287 | void VL_GetPalette (SDL_Color *palette)
288 | {
289 | memcpy(palette, curpal, sizeof(SDL_Color) * 256);
290 | }
291 |
292 |
293 | //===========================================================================
294 |
295 | /*
296 | =================
297 | =
298 | = VL_FadeOut
299 | =
300 | = Fades the current palette to the given color in the given number of steps
301 | =
302 | =================
303 | */
304 |
305 | void VL_FadeOut (int start, int end, int red, int green, int blue, int steps)
306 | {
307 | int i,j,orig,delta;
308 | SDL_Color *origptr, *newptr;
309 |
310 | red = red * 255 / 63;
311 | green = green * 255 / 63;
312 | blue = blue * 255 / 63;
313 |
314 | VL_WaitVBL(1);
315 | VL_GetPalette(palette1);
316 | memcpy(palette2, palette1, sizeof(SDL_Color) * 256);
317 |
318 | //
319 | // fade through intermediate frames
320 | //
321 | for (i=0;ir;
328 | delta = red-orig;
329 | newptr->r = orig + delta * i / steps;
330 | orig = origptr->g;
331 | delta = green-orig;
332 | newptr->g = orig + delta * i / steps;
333 | orig = origptr->b;
334 | delta = blue-orig;
335 | newptr->b = orig + delta * i / steps;
336 | origptr++;
337 | newptr++;
338 | }
339 |
340 | if(!usedoublebuffering || screenBits == 8) VL_WaitVBL(1);
341 | VL_SetPalette (palette2, true);
342 | }
343 |
344 | //
345 | // final color
346 | //
347 | VL_FillPalette (red,green,blue);
348 |
349 | screenfaded = true;
350 | }
351 |
352 |
353 | /*
354 | =================
355 | =
356 | = VL_FadeIn
357 | =
358 | =================
359 | */
360 |
361 | void VL_FadeIn (int start, int end, SDL_Color *palette, int steps)
362 | {
363 | int i,j,delta;
364 |
365 | VL_WaitVBL(1);
366 | VL_GetPalette(palette1);
367 | memcpy(palette2, palette1, sizeof(SDL_Color) * 256);
368 |
369 | //
370 | // fade through intermediate frames
371 | //
372 | for (i=0;ipixels;
411 | }
412 |
413 | void VL_UnlockSurface(SDL_Surface *surface)
414 | {
415 | if(SDL_MUSTLOCK(surface))
416 | {
417 | SDL_UnlockSurface(surface);
418 | }
419 | }
420 |
421 | /*
422 | =================
423 | =
424 | = VL_Plot
425 | =
426 | =================
427 | */
428 |
429 | void VL_Plot (int x, int y, int color)
430 | {
431 | assert(x >= 0 && (unsigned) x < screenWidth
432 | && y >= 0 && (unsigned) y < screenHeight
433 | && "VL_Plot: Pixel out of bounds!");
434 |
435 | VL_LockSurface(curSurface);
436 | ((byte *) curSurface->pixels)[y * curPitch + x] = color;
437 | VL_UnlockSurface(curSurface);
438 | }
439 |
440 | /*
441 | =================
442 | =
443 | = VL_GetPixel
444 | =
445 | =================
446 | */
447 |
448 | byte VL_GetPixel (int x, int y)
449 | {
450 | assert_ret(x >= 0 && (unsigned) x < screenWidth
451 | && y >= 0 && (unsigned) y < screenHeight
452 | && "VL_GetPixel: Pixel out of bounds!");
453 |
454 | VL_LockSurface(curSurface);
455 | byte col = ((byte *) curSurface->pixels)[y * curPitch + x];
456 | VL_UnlockSurface(curSurface);
457 | return col;
458 | }
459 |
460 |
461 | /*
462 | =================
463 | =
464 | = VL_Hlin
465 | =
466 | =================
467 | */
468 |
469 | void VL_Hlin (unsigned x, unsigned y, unsigned width, int color)
470 | {
471 | assert(x >= 0 && x + width <= screenWidth
472 | && y >= 0 && y < screenHeight
473 | && "VL_Hlin: Destination rectangle out of bounds!");
474 |
475 | VL_LockSurface(curSurface);
476 | Uint8 *dest = ((byte *) curSurface->pixels) + y * curPitch + x;
477 | memset(dest, color, width);
478 | VL_UnlockSurface(curSurface);
479 | }
480 |
481 |
482 | /*
483 | =================
484 | =
485 | = VL_Vlin
486 | =
487 | =================
488 | */
489 |
490 | void VL_Vlin (int x, int y, int height, int color)
491 | {
492 | assert(x >= 0 && (unsigned) x < screenWidth
493 | && y >= 0 && (unsigned) y + height <= screenHeight
494 | && "VL_Vlin: Destination rectangle out of bounds!");
495 |
496 | VL_LockSurface(curSurface);
497 | Uint8 *dest = ((byte *) curSurface->pixels) + y * curPitch + x;
498 |
499 | while (height--)
500 | {
501 | *dest = color;
502 | dest += curPitch;
503 | }
504 | VL_UnlockSurface(curSurface);
505 | }
506 |
507 |
508 | /*
509 | =================
510 | =
511 | = VL_Bar
512 | =
513 | =================
514 | */
515 |
516 | void VL_BarScaledCoord (int scx, int scy, int scwidth, int scheight, int color)
517 | {
518 | assert(scx >= 0 && (unsigned) scx + scwidth <= screenWidth
519 | && scy >= 0 && (unsigned) scy + scheight <= screenHeight
520 | && "VL_BarScaledCoord: Destination rectangle out of bounds!");
521 |
522 | VL_LockSurface(curSurface);
523 | Uint8 *dest = ((byte *) curSurface->pixels) + scy * curPitch + scx;
524 |
525 | while (scheight--)
526 | {
527 | memset(dest, color, scwidth);
528 | dest += curPitch;
529 | }
530 | VL_UnlockSurface(curSurface);
531 | }
532 |
533 | /*
534 | ============================================================================
535 |
536 | MEMORY OPS
537 |
538 | ============================================================================
539 | */
540 |
541 | /*
542 | =================
543 | =
544 | = VL_MemToLatch
545 | =
546 | =================
547 | */
548 |
549 | void VL_MemToLatch(byte *source, int width, int height,
550 | SDL_Surface *destSurface, int x, int y)
551 | {
552 | assert(x >= 0 && (unsigned) x + width <= screenWidth
553 | && y >= 0 && (unsigned) y + height <= screenHeight
554 | && "VL_MemToLatch: Destination rectangle out of bounds!");
555 |
556 | VL_LockSurface(destSurface);
557 | int pitch = destSurface->pitch;
558 | byte *dest = (byte *) destSurface->pixels + y * pitch + x;
559 | for(int ysrc = 0; ysrc < height; ysrc++)
560 | {
561 | for(int xsrc = 0; xsrc < width; xsrc++)
562 | {
563 | dest[ysrc * pitch + xsrc] = source[(ysrc * (width >> 2) + (xsrc >> 2))
564 | + (xsrc & 3) * (width >> 2) * height];
565 | }
566 | }
567 | VL_UnlockSurface(destSurface);
568 | }
569 |
570 | //===========================================================================
571 |
572 |
573 | /*
574 | =================
575 | =
576 | = VL_MemToScreenScaledCoord
577 | =
578 | = Draws a block of data to the screen with scaling according to scaleFactor.
579 | =
580 | =================
581 | */
582 |
583 | void VL_MemToScreenScaledCoord (byte *source, int width, int height, int destx, int desty)
584 | {
585 | assert(destx >= 0 && destx + width * scaleFactor <= screenWidth
586 | && desty >= 0 && desty + height * scaleFactor <= screenHeight
587 | && "VL_MemToScreenScaledCoord: Destination rectangle out of bounds!");
588 |
589 | VL_LockSurface(curSurface);
590 | byte *vbuf = (byte *) curSurface->pixels;
591 | for(int j=0,scj=0; j>2)+(i>>2))+(i&3)*(width>>2)*height];
596 | for(unsigned m=0; m= 0 && destx + width * scaleFactor <= screenWidth
625 | && desty >= 0 && desty + height * scaleFactor <= screenHeight
626 | && "VL_MemToScreenScaledCoord: Destination rectangle out of bounds!");
627 |
628 | VL_LockSurface(curSurface);
629 | byte *vbuf = (byte *) curSurface->pixels;
630 | for(int j=0,scj=0; j>2)+((i+srcx)>>2))+((i+srcx)&3)*(origwidth>>2)*origheight];
635 | for(unsigned m=0; m= 0 && scxdest + width * scaleFactor <= screenWidth
661 | && scydest >= 0 && scydest + height * scaleFactor <= screenHeight
662 | && "VL_LatchToScreenScaledCoord: Destination rectangle out of bounds!");
663 |
664 | if(scaleFactor == 1)
665 | {
666 | // HACK: If screenBits is not 8 and the screen is faded out, the
667 | // result will be black when using SDL_BlitSurface. The reason
668 | // is that the logical palette needed for the transformation
669 | // to the screen color depth is not equal to the logical
670 | // palette of the latch (the latch is not faded). Therefore,
671 | // SDL tries to map the colors...
672 | // The result: All colors are mapped to black.
673 | // So, we do the blit on our own...
674 | if(screenBits != 8)
675 | {
676 | VL_LockSurface(source);
677 | byte *src = (byte *) source->pixels;
678 | unsigned srcPitch = source->pitch;
679 |
680 | VL_LockSurface(curSurface);
681 | byte *vbuf = (byte *) curSurface->pixels;
682 | for(int j=0,scj=0; jpixels;
704 | unsigned srcPitch = source->pitch;
705 |
706 | VL_LockSurface(curSurface);
707 | byte *vbuf = (byte *) curSurface->pixels;
708 | for(int j=0,scj=0; j