├── Doom64DS.sln ├── Doom64DS.vcproj ├── Makefile ├── arm7 ├── Makefile └── source │ ├── arm7.c │ ├── arm7.h │ ├── common.c │ ├── d_player.h │ ├── d_think.h │ ├── doomdata.h │ ├── doomdef.h │ ├── doomtype.h │ ├── info.h │ ├── m_fixed.h │ ├── p_mobj.h │ ├── p_pspr.h │ ├── t_bsp.h │ └── tables.h ├── arm9 ├── Makefile └── source │ ├── am_main.c │ ├── d_base.s │ ├── d_englsh.h │ ├── d_main.c │ ├── d_main.h │ ├── d_player.h │ ├── d_think.h │ ├── doomdata.h │ ├── doomdef.h │ ├── doomtype.h │ ├── ds.c │ ├── ds.h │ ├── f_finale.c │ ├── g_game.c │ ├── g_game.h │ ├── info.c │ ├── info.h │ ├── m_fixed.c │ ├── m_fixed.h │ ├── m_main.c │ ├── p_ceilng.c │ ├── p_doors.c │ ├── p_enemy.c │ ├── p_floor.c │ ├── p_inter.c │ ├── p_lights.c │ ├── p_local.h │ ├── p_macros.c │ ├── p_map.c │ ├── p_maputl.c │ ├── p_mobj.c │ ├── p_mobj.h │ ├── p_plats.c │ ├── p_pspr.c │ ├── p_pspr.h │ ├── p_setup.c │ ├── p_sight.c │ ├── p_spec.c │ ├── p_spec.h │ ├── p_telept.c │ ├── p_tick.c │ ├── p_user.c │ ├── r_bsp.c │ ├── r_data.c │ ├── r_draw.c │ ├── r_lights.c │ ├── r_local.h │ ├── r_main.c │ ├── s_sound.c │ ├── s_sound.h │ ├── sc_main.c │ ├── sc_main.h │ ├── sounds.h │ ├── st_main.c │ ├── st_main.h │ ├── t_bsp.h │ ├── tables.c │ ├── tables.h │ ├── tonc_asminc.h │ ├── tonc_memcpy.s │ ├── tonc_memset.s │ ├── w_file.c │ ├── w_file.h │ ├── w_merge.c │ ├── w_merge.h │ ├── w_wad.c │ ├── w_wad.h │ ├── wi_stuff.c │ ├── z_zone.c │ └── z_zone.h └── wadgen ├── CMakeLists.txt ├── Content ├── ANIMDEFS.TXT ├── BUTTONS.PNG ├── CONFONT.PNG ├── CRSHAIRS.PNG ├── FANCRED.PNG ├── IDLOGO.LMP ├── LOADING.BIN ├── MAPINFO.TXT ├── PALPLAY3.ACT └── SKYDEFS.TXT ├── DeflateN64.c ├── DeflateN64.h ├── Files.c ├── Files.h ├── Gfx.c ├── Gfx.h ├── Level.c ├── Level.h ├── MD5.c ├── MD5.h ├── Mem.c ├── Mem.h ├── Rom.c ├── Rom.h ├── SndFont.c ├── SndFont.h ├── Sound.c ├── Sound.h ├── Sprite.c ├── Sprite.h ├── Texture.c ├── Texture.h ├── Wad.c ├── Wad.h ├── WadGen.c ├── WadGen.h └── msvc6 ├── WadGen.aps ├── WadGen.dsp ├── WadGen.dsw ├── WadGen.rc ├── bin ├── WadGen.exe ├── libpng13.dll └── zlib1.dll ├── icon.ico └── resource.h /Doom64DS.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Doom64DS", "Doom64DS.vcproj", "{DA4C47C6-E234-4FB6-9CCC-A2F2F03415C7}" 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 | {DA4C47C6-E234-4FB6-9CCC-A2F2F03415C7}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {DA4C47C6-E234-4FB6-9CCC-A2F2F03415C7}.Debug|Win32.Build.0 = Debug|Win32 14 | {DA4C47C6-E234-4FB6-9CCC-A2F2F03415C7}.Release|Win32.ActiveCfg = Release|Win32 15 | {DA4C47C6-E234-4FB6-9CCC-A2F2F03415C7}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | ifeq ($(strip $(DEVKITARM)),) 5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 6 | endif 7 | 8 | include $(DEVKITARM)/ds_rules 9 | 10 | export TARGET := $(shell basename $(CURDIR)) 11 | export TOPDIR := $(CURDIR) 12 | 13 | 14 | .PHONY: arm7/$(TARGET).elf arm9/$(TARGET).elf 15 | 16 | #--------------------------------------------------------------------------------- 17 | # main targets 18 | #--------------------------------------------------------------------------------- 19 | all: $(TARGET).nds 20 | 21 | #--------------------------------------------------------------------------------- 22 | $(TARGET).nds : arm7/$(TARGET).elf arm9/$(TARGET).elf 23 | ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf 24 | 25 | #--------------------------------------------------------------------------------- 26 | arm7/$(TARGET).elf: 27 | $(MAKE) -C arm7 28 | 29 | #--------------------------------------------------------------------------------- 30 | arm9/$(TARGET).elf: 31 | $(MAKE) -C arm9 32 | 33 | #--------------------------------------------------------------------------------- 34 | clean: 35 | $(MAKE) -C arm9 clean 36 | $(MAKE) -C arm7 clean 37 | rm -f $(TARGET).nds $(TARGET).arm7 $(TARGET).arm9 38 | -------------------------------------------------------------------------------- /arm7/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | ifeq ($(strip $(DEVKITARM)),) 5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 6 | endif 7 | 8 | include $(DEVKITARM)/ds_rules 9 | 10 | #--------------------------------------------------------------------------------- 11 | # BUILD is the directory where object files & intermediate files will be placed 12 | # SOURCES is a list of directories containing source code 13 | # INCLUDES is a list of directories containing extra header files 14 | # DATA is a list of directories containing binary files 15 | # all directories are relative to this makefile 16 | #--------------------------------------------------------------------------------- 17 | BUILD := build 18 | SOURCES := source 19 | INCLUDES := include build 20 | DATA := 21 | 22 | #--------------------------------------------------------------------------------- 23 | # options for code generation 24 | #--------------------------------------------------------------------------------- 25 | ARCH := -mthumb-interwork 26 | 27 | CFLAGS := -g -Wall -O3\ 28 | -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ 29 | -ffast-math \ 30 | $(ARCH) 31 | 32 | CFLAGS += $(INCLUDE) -DARM7 33 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fno-rtti 34 | 35 | 36 | ASFLAGS := -g $(ARCH) 37 | LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -Wl,-Map,$(notdir $*).map 38 | 39 | LIBS := -ldswifi7 -lmm7 -lnds7 40 | 41 | #--------------------------------------------------------------------------------- 42 | # list of directories containing libraries, this must be the top level containing 43 | # include and lib 44 | #--------------------------------------------------------------------------------- 45 | LIBDIRS := $(LIBNDS) 46 | 47 | 48 | #--------------------------------------------------------------------------------- 49 | # no real need to edit anything past this point unless you need to add additional 50 | # rules for different file extensions 51 | #--------------------------------------------------------------------------------- 52 | ifneq ($(BUILD),$(notdir $(CURDIR))) 53 | #--------------------------------------------------------------------------------- 54 | 55 | export ARM7ELF := $(CURDIR)/$(TARGET).elf 56 | export DEPSDIR := $(CURDIR)/$(BUILD) 57 | 58 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) 59 | 60 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 61 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 62 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 63 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 64 | 65 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 66 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 67 | 68 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 70 | -I$(CURDIR)/$(BUILD) 71 | 72 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 73 | 74 | #--------------------------------------------------------------------------------- 75 | # use CXX for linking C++ projects, CC for standard C 76 | #--------------------------------------------------------------------------------- 77 | ifeq ($(strip $(CPPFILES)),) 78 | #--------------------------------------------------------------------------------- 79 | export LD := $(CC) 80 | #--------------------------------------------------------------------------------- 81 | else 82 | #--------------------------------------------------------------------------------- 83 | export LD := $(CXX) 84 | #--------------------------------------------------------------------------------- 85 | endif 86 | #--------------------------------------------------------------------------------- 87 | 88 | .PHONY: $(BUILD) clean 89 | 90 | #--------------------------------------------------------------------------------- 91 | $(BUILD): 92 | @[ -d $@ ] || mkdir -p $@ 93 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 94 | 95 | #--------------------------------------------------------------------------------- 96 | clean: 97 | @echo clean ... 98 | @rm -fr $(BUILD) *.elf 99 | 100 | 101 | #--------------------------------------------------------------------------------- 102 | else 103 | 104 | DEPENDS := $(OFILES:.o=.d) 105 | 106 | #--------------------------------------------------------------------------------- 107 | # main targets 108 | #--------------------------------------------------------------------------------- 109 | $(ARM7ELF) : $(OFILES) 110 | @echo linking $(notdir $@) 111 | @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ 112 | 113 | 114 | #--------------------------------------------------------------------------------- 115 | # you need a rule like this for each extension you use as binary data 116 | #--------------------------------------------------------------------------------- 117 | %.bin.o : %.bin 118 | #--------------------------------------------------------------------------------- 119 | @echo $(notdir $<) 120 | @$(bin2o) 121 | 122 | -include $(DEPENDS) 123 | 124 | #--------------------------------------------------------------------------------------- 125 | endif 126 | #--------------------------------------------------------------------------------------- 127 | -------------------------------------------------------------------------------- /arm7/source/arm7.c: -------------------------------------------------------------------------------- 1 | #include "arm7.h" 2 | #include 3 | #include 4 | #include "doomtype.h" 5 | #include "d_player.h" 6 | #include "t_bsp.h" 7 | 8 | // 9 | // IRQ_VBlank 10 | // 11 | 12 | void IRQ_VBlank(void) 13 | { 14 | Wifi_Update(); 15 | } 16 | 17 | // 18 | // IRQ_VCount 19 | // 20 | 21 | void IRQ_VCount() 22 | { 23 | inputGetAndSend(); 24 | } 25 | 26 | // 27 | // powerButtonCB 28 | // 29 | 30 | volatile bool exitflag = false; 31 | 32 | void powerButtonCB() 33 | { 34 | exitflag = true; 35 | } 36 | 37 | // 38 | // I_PollArm9Messages 39 | // 40 | 41 | static void I_PollArm9Messages(int bytes, void *userdata) 42 | { 43 | fifomsg_t msg; 44 | 45 | fifoGetDatamsg(FIFO_USER_01, bytes, (u8*)&msg); 46 | 47 | switch(msg.type) 48 | { 49 | case FIFO_MSG_PLAYERDATA: 50 | player = (player_t*)msg.arg[0].arg_p; 51 | break; 52 | case FIFO_MSG_LINEDEFDATA: 53 | lines = (line_t*)msg.arg[0].arg_p; 54 | numlines = msg.arg[1].arg_i; 55 | break; 56 | case FIFO_MSG_SSECTDATA: 57 | subsectors = (subsector_t*)msg.arg[0].arg_p; 58 | numsubsectors = msg.arg[1].arg_i; 59 | break; 60 | case FIFO_MSG_VERTEXDATA: 61 | vertexes = (vertex_t*)msg.arg[0].arg_p; 62 | numvertexes = msg.arg[1].arg_i; 63 | break; 64 | case FIFO_MSG_FINESINEDATA: 65 | finesine = (fixed_t*)msg.arg[0].arg_p; 66 | break; 67 | case FIFO_MSG_FINECOSINEDATA: 68 | finecosine = (fixed_t*)msg.arg[0].arg_p; 69 | break; 70 | default: 71 | break; 72 | } 73 | } 74 | 75 | // 76 | // ARM7 MAIN 77 | // 78 | 79 | int ARM7_MAIN(void) 80 | { 81 | readUserSettings(); 82 | 83 | // init irq 84 | irqInit(); 85 | initClockIRQ(); 86 | 87 | // init irq callback 88 | irqSet(IRQ_VCOUNT, IRQ_VCount); 89 | irqSet(IRQ_VBLANK, IRQ_VBlank); 90 | irqEnable(IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK); 91 | 92 | // init fifo system 93 | fifoInit(); 94 | 95 | // install fifo subsystems 96 | installWifiFIFO(); 97 | installSoundFIFO(); 98 | installSystemFIFO(); 99 | mmInstall(FIFO_MAXMOD); 100 | 101 | // init fifo callback for arm9 communication 102 | fifoSetDatamsgHandler(FIFO_USER_01, I_PollArm9Messages, 0); 103 | 104 | SetYtrigger(80); 105 | setPowerButtonCB(powerButtonCB); 106 | 107 | // Keep the ARM7 mostly idle 108 | while(!exitflag) 109 | { 110 | if(0 == (REG_KEYINPUT & (KEY_SELECT | KEY_START | KEY_L | KEY_R))) 111 | exitflag = true; 112 | 113 | swiIntrWait(1, IRQ_FIFO_NOT_EMPTY | IRQ_VBLANK); 114 | } 115 | 116 | return 0; 117 | } 118 | -------------------------------------------------------------------------------- /arm7/source/arm7.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARM7_MAIN__ 2 | #define __ARM7_MAIN__ 3 | 4 | #include 5 | 6 | #define ARM7_MAIN main 7 | 8 | #define FIFO_MSG_PLAYERDATA 0 9 | #define FIFO_MSG_LINEDEFDATA 1 10 | #define FIFO_MSG_SSECTDATA 2 11 | #define FIFO_MSG_VERTEXDATA 3 12 | #define FIFO_MSG_FINESINEDATA 4 13 | #define FIFO_MSG_FINECOSINEDATA 5 14 | 15 | typedef union 16 | { 17 | void* arg_p; 18 | int arg_i; 19 | } fifoargs_t; 20 | 21 | typedef struct 22 | { 23 | int type; 24 | fifoargs_t arg[3]; 25 | } fifomsg_t; 26 | 27 | static inline uint16_t I_Swap16(x) 28 | { 29 | return((x<<8)|(x>>8)); 30 | } 31 | 32 | static inline uint32_t I_Swap32(x) 33 | { 34 | return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24)); 35 | } 36 | 37 | #endif // __ARM7_MAIN__ -------------------------------------------------------------------------------- /arm7/source/common.c: -------------------------------------------------------------------------------- 1 | #include "d_player.h" 2 | #include "t_bsp.h" 3 | 4 | int numvertexes; 5 | vertex_t* vertexes; 6 | int numsegs; 7 | seg_t* segs; 8 | int numsectors; 9 | sector_t* sectors; 10 | int numsubsectors; 11 | subsector_t* subsectors; 12 | int numnodes; 13 | node_t* nodes; 14 | int numleafs; 15 | leaf_t* leafs; 16 | int numlines; 17 | line_t* lines; 18 | int numsides; 19 | side_t* sides; 20 | light_t* lights; 21 | int numlights; 22 | macroinfo_t macros; 23 | player_t* player; 24 | fixed_t* finecosine; 25 | fixed_t* finesine; -------------------------------------------------------------------------------- /arm7/source/d_player.h: -------------------------------------------------------------------------------- 1 | #ifndef __D_PLAYER__ 2 | #define __D_PLAYER__ 3 | 4 | #include "p_pspr.h" 5 | #include "p_mobj.h" 6 | #include "doomdef.h" 7 | 8 | // The data sampled per tick (single player) 9 | // and transmitted to other peers (multiplayer). 10 | // Mainly movements/button commands per game tick, 11 | // plus a checksum for internal state consistency. 12 | typedef struct 13 | { 14 | short forwardmove; // *2048 for move 15 | short sidemove; // *2048 for move 16 | short angleturn; // <<16 for angle delta 17 | short pitch; 18 | byte consistancy; // checks for net game 19 | byte buttons; 20 | } ticcmd_t; 21 | 22 | // 23 | // Player states. 24 | // 25 | typedef enum 26 | { 27 | PST_LIVE, // Playing or camping. 28 | PST_DEAD, // Dead on the ground, view follows killer. 29 | PST_REBORN // Ready to restart/respawn??? 30 | 31 | } playerstate_t; 32 | 33 | 34 | // 35 | // Player internal flags, for cheats and debug. 36 | // 37 | typedef enum 38 | { 39 | CF_NOCLIP = 1, // No clipping, walk through barriers. 40 | CF_GODMODE = 2, // No damage, no health loss. 41 | CF_UNDYING = 4, // Take damage but not die 42 | CF_SPECTATOR = 8, // Specator mode 43 | CF_CHASECAM = 16, // Chase cam mode 44 | CF_FLOATCAM = 32 // Floating camera 45 | 46 | } cheat_t; 47 | 48 | typedef enum 49 | { 50 | ART_FAST = 0, 51 | ART_DOUBLE, 52 | ART_TRIPLE 53 | 54 | } artifacts_t; 55 | 56 | 57 | // 58 | // Extended player object info: player_t 59 | // 60 | typedef struct player_s 61 | { 62 | mobj_t* mo; 63 | playerstate_t playerstate; 64 | ticcmd_t cmd; 65 | 66 | // Determine POV, 67 | // including viewpoint bobbing during movement. 68 | // Focal origin above r.z 69 | fixed_t viewz; 70 | // Base height above floor for viewz. 71 | fixed_t viewheight; 72 | // Bob/squat speed. 73 | fixed_t deltaviewheight; 74 | // bounded/scaled total momentum. 75 | fixed_t bob; 76 | 77 | // [d64] extra pitch for recoil/knockback 78 | angle_t recoilpitch; 79 | 80 | // This is only used between levels, 81 | // mo->health is used during levels. 82 | int health; 83 | int armorpoints; 84 | // Armor type is 0-2. 85 | int armortype; 86 | 87 | // Power ups. invinc and invis are tic counters. 88 | int powers[NUMPOWERS]; 89 | dboolean cards[NUMCARDS]; 90 | 91 | // [kex] for hud when trying to open a locked door 92 | dboolean tryopen[NUMCARDS]; 93 | 94 | // [d64] laser artifact flags 95 | int artifacts; 96 | 97 | dboolean backpack; 98 | 99 | weapontype_t readyweapon; 100 | 101 | // Is wp_nochange if not changing. 102 | weapontype_t pendingweapon; 103 | 104 | dboolean weaponowned[NUMWEAPONS]; 105 | int ammo[NUMAMMO]; 106 | int maxammo[NUMAMMO]; 107 | 108 | // True if button down last tic. 109 | int attackdown; 110 | int usedown; 111 | 112 | // [kex] true if jump button down last tic 113 | int jumpdown; 114 | 115 | // Bit flags, for cheats and debug. 116 | // See cheat_t, above. 117 | int cheats; 118 | 119 | // Refired shots are less accurate. 120 | int refire; 121 | 122 | // For intermission stats. 123 | int killcount; 124 | int itemcount; 125 | int secretcount; 126 | 127 | // Hint messages. 128 | char* message; 129 | 130 | // [d64] tic for how long message should stay on hud...not used in d64ex 131 | // int messagetic; 132 | 133 | // For screen flashing (red or bright). 134 | int damagecount; 135 | int bonuscount; 136 | int bfgcount; 137 | 138 | // Who did damage (NULL for floors/ceilings). 139 | mobj_t* attacker; 140 | 141 | // [kex] which mobj to use as the view camera (defaults to player->mo) 142 | mobj_t* cameratarget; 143 | 144 | // Overlay view sprites (gun, etc). 145 | pspdef_t psprites[NUMPSPRITES]; 146 | 147 | // Translation palettes for multiplayer 148 | int palette; 149 | 150 | // [d64] Track if player is on the ground or not 151 | dboolean onground; 152 | 153 | // [kex] allow autoaim? 154 | dboolean autoaim; 155 | 156 | // [kex] display pic as message instead of text 157 | int messagepic; 158 | 159 | } player_t; 160 | 161 | extern player_t* player; 162 | 163 | #endif 164 | 165 | -------------------------------------------------------------------------------- /arm7/source/d_think.h: -------------------------------------------------------------------------------- 1 | #ifndef __D_THINK__ 2 | #define __D_THINK__ 3 | 4 | // 5 | // Experimental stuff. 6 | // To compile this as "ANSI C with classes" 7 | // we will need to handle the various 8 | // action functions cleanly. 9 | // 10 | typedef void(*actionf_v)(void); 11 | typedef void(*actionf_p1)(void*); 12 | typedef void(*actionf_p2)(void*, void*); 13 | 14 | typedef union 15 | { 16 | actionf_p1 acp1; 17 | actionf_v acv; 18 | actionf_p2 acp2; 19 | 20 | } actionf_t; 21 | 22 | 23 | 24 | 25 | 26 | // Historically, "think_t" is yet another 27 | // function pointer to a routine to handle 28 | // an actor. 29 | typedef actionf_t think_t; 30 | 31 | 32 | // Doubly linked list of actors. 33 | typedef struct thinker_s 34 | { 35 | struct thinker_s* prev; 36 | struct thinker_s* next; 37 | think_t function; 38 | 39 | } thinker_t; 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /arm7/source/doomdef.h: -------------------------------------------------------------------------------- 1 | #ifndef __DOOMDEF__ 2 | #define __DOOMDEF__ 3 | 4 | #include 5 | #include "doomtype.h" 6 | #include "tables.h" 7 | 8 | void *dmemcpy(void *s1, const void *s2, unsigned int n); 9 | void *dmemset(void *s, unsigned int c, unsigned int n); 10 | 11 | #define dcos(angle) finecosine[(angle) >> ANGLETOFINESHIFT] 12 | #define dsin(angle) finesine[(angle) >> ANGLETOFINESHIFT] 13 | 14 | // 15 | // The packed attribute forces structures to be packed into the minimum 16 | // space necessary. If this is not done, the compiler may align structure 17 | // fields differently to optimise memory access, inflating the overall 18 | // structure size. It is important to use the packed attribute on certain 19 | // structures where alignment is important, particularly data read/written 20 | // to disk. 21 | // 22 | 23 | #define PACKEDATTR __attribute__((packed)) 24 | #define PUREFUNC __attribute__((pure)) 25 | #define NOINLINE __attribute__((noinline)) 26 | 27 | // 28 | // Global parameters/defines. 29 | // 30 | 31 | #define SCREENWIDTH 320 32 | #define SCREENHEIGHT 240 33 | 34 | #define MAX_MESSAGE_SIZE 1024 35 | 36 | // The maximum number of players, multiplayer/networking. 37 | // remember to add settings for extra skins if increase:) 38 | #define MAXPLAYERS 4 39 | 40 | // State updates, number of tics / second. 41 | #define TICRATE 30 42 | 43 | // Networking and tick handling related. 44 | #define BACKUPTICS 128 45 | 46 | typedef enum 47 | { 48 | sk_baby, 49 | sk_easy, 50 | sk_medium, 51 | sk_hard, 52 | sk_nightmare 53 | } skill_t; 54 | 55 | // 56 | // Key cards. 57 | // 58 | typedef enum 59 | { 60 | it_bluecard, 61 | it_yellowcard, 62 | it_redcard, 63 | it_blueskull, 64 | it_yellowskull, 65 | it_redskull, 66 | 67 | NUMCARDS 68 | 69 | } card_t; 70 | 71 | // The defined weapons, 72 | // including a marker indicating 73 | // user has not changed weapon. 74 | typedef enum 75 | { 76 | wp_chainsaw, 77 | wp_fist, 78 | wp_pistol, 79 | wp_shotgun, 80 | wp_supershotgun, 81 | wp_chaingun, 82 | wp_missile, 83 | wp_plasma, 84 | wp_bfg, 85 | wp_laser, 86 | NUMWEAPONS, 87 | 88 | // No pending weapon change. 89 | wp_nochange 90 | 91 | } weapontype_t; 92 | 93 | // Ammunition types defined. 94 | typedef enum 95 | { 96 | am_clip, // Pistol / chaingun ammo. 97 | am_shell, // Shotgun / double barreled shotgun. 98 | am_cell, // Plasma rifle, BFG. 99 | am_misl, // Missile launcher. 100 | NUMAMMO, 101 | am_noammo // Unlimited for chainsaw / fist. 102 | 103 | } ammotype_t; 104 | 105 | // Power up artifacts. 106 | typedef enum 107 | { 108 | pw_invulnerability, 109 | pw_strength, 110 | pw_invisibility, 111 | pw_ironfeet, 112 | pw_allmap, 113 | pw_infrared, 114 | NUMPOWERS 115 | 116 | } powertype_t; 117 | 118 | #define BONUSADD 4 119 | 120 | // 121 | // Power up durations, 122 | // how many seconds till expiration, 123 | // 124 | typedef enum 125 | { 126 | INVULNTICS = (30*TICRATE), 127 | INVISTICS = (60*TICRATE), 128 | INFRATICS = (120*TICRATE), 129 | IRONTICS = (60*TICRATE), 130 | STRTICS = (3*TICRATE) 131 | 132 | } powerduration_t; 133 | 134 | // 135 | // MISC 136 | // 137 | 138 | // bbox coordinates 139 | enum 140 | { 141 | BOXTOP, 142 | BOXBOTTOM, 143 | BOXLEFT, 144 | BOXRIGHT 145 | }; 146 | 147 | #endif // __DOOMDEF__ 148 | -------------------------------------------------------------------------------- /arm7/source/doomtype.h: -------------------------------------------------------------------------------- 1 | #ifndef __DOOMTYPE__ 2 | #define __DOOMTYPE__ 3 | 4 | #include 5 | 6 | #undef true 7 | 8 | #define false 0 9 | #define true (!false) 10 | 11 | typedef int dboolean; 12 | typedef unsigned char byte; 13 | typedef unsigned short word; 14 | typedef unsigned long dword; 15 | typedef unsigned int rcolor; 16 | typedef int dtexture; 17 | typedef int8_t int8; 18 | typedef uint8_t uint8; 19 | typedef int16_t int16; 20 | typedef uint16_t uint16; 21 | typedef int32_t int32; 22 | typedef uint32_t uint32; 23 | 24 | #include 25 | #define MININT INT_MIN 26 | #define MAXINT INT_MAX 27 | #endif 28 | 29 | #ifndef MAX 30 | #define MAX(a,b) ((a)>(b)?(a):(b)) 31 | #endif 32 | 33 | #ifndef MIN 34 | #define MIN(a,b) ((a)<(b)?(a):(b)) 35 | #endif 36 | 37 | #ifndef BETWEEN 38 | #define BETWEEN(l,u,x) ((l)>(x)?(l):(x)>(u)?(u):(x)) 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /arm7/source/m_fixed.h: -------------------------------------------------------------------------------- 1 | #ifndef __M_FIXED__ 2 | #define __M_FIXED__ 3 | 4 | // 5 | // Fixed point, 32bit as 16.16. 6 | // 7 | #define FRACBITS 16 8 | #define FRACUNIT (1<>FRACBITS) 12 | #define F2D3D(x) (((float)(x))/FRACUNIT) 13 | #define F2DSFIXED(x) ((x)>>14) 14 | #define INT2DSFIXED(x) ((x)<<2) 15 | 16 | typedef int fixed_t; 17 | 18 | fixed_t FixedMul (fixed_t a, fixed_t b); 19 | fixed_t FixedDiv (fixed_t a, fixed_t b); 20 | fixed_t FixedDiv2 (fixed_t a, fixed_t b); 21 | 22 | static inline fixed_t FixedDot(fixed_t a1, fixed_t b1, 23 | fixed_t c1, fixed_t a2, 24 | fixed_t b2, fixed_t c2) 25 | { 26 | return 27 | FixedMul(a1, a2) + 28 | FixedMul(b1, b2) + 29 | FixedMul(c1, c2); 30 | } 31 | 32 | #endif -------------------------------------------------------------------------------- /arm7/source/p_pspr.h: -------------------------------------------------------------------------------- 1 | #ifndef __P_PSPR__ 2 | #define __P_PSPR__ 3 | 4 | #include "doomdef.h" 5 | #include "tables.h" 6 | #include "info.h" 7 | #include "m_fixed.h" 8 | 9 | // 10 | // Frame flags: 11 | // handles maximum brightness (torches, muzzle flare, light sources) 12 | // 13 | 14 | #define FF_FULLBRIGHT 0x8000 // flag in thing->frame 15 | #define FF_FRAMEMASK 0x7fff 16 | 17 | 18 | 19 | // 20 | // Overlay psprites are scaled shapes 21 | // drawn directly on the view screen, 22 | // coordinates are given for a 320*200 view screen. 23 | // 24 | typedef enum 25 | { 26 | ps_weapon, 27 | ps_flash, 28 | NUMPSPRITES 29 | 30 | } psprnum_t; 31 | 32 | typedef struct 33 | { 34 | state_t* state; // a NULL state means not active 35 | int tics; 36 | fixed_t sx; 37 | fixed_t sy; 38 | int alpha; // [d64] for rendering 39 | } pspdef_t; 40 | 41 | typedef struct 42 | { 43 | ammotype_t ammo; 44 | int upstate; 45 | int downstate; 46 | int readystate; 47 | int atkstate; 48 | int flashstate; 49 | } weaponinfo_t; 50 | 51 | // Weapon info: sprite frames, ammunition use. 52 | extern weaponinfo_t weaponinfo[NUMWEAPONS]; 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /arm7/source/tables.h: -------------------------------------------------------------------------------- 1 | #ifndef __TABLES__ 2 | #define __TABLES__ 3 | 4 | #include "m_fixed.h" 5 | 6 | #define M_PI 3.14159265358979323846 7 | 8 | #define FINEANGLES 8192 9 | #define FINEMASK (FINEANGLES-1) 10 | 11 | 12 | // 0x100000000 to 0x2000 13 | #define ANGLETOFINESHIFT 19 14 | 15 | // Binary Angle Measument, BAM. 16 | #define ANG45 0x20000000 17 | #define ANG90 0x40000000 18 | #define ANG180 0x80000000 19 | #define ANG270 0xc0000000 20 | #define ANG1 (ANG45/45) 21 | #define ANG5 (ANG90/18) 22 | #define ANGLE_MAX (0xffffffff) 23 | 24 | 25 | #define SLOPERANGE 2048 26 | #define SLOPEBITS 11 27 | #define DBITS (FRACBITS-SLOPEBITS) 28 | 29 | #define TRUEANGLES(x) (((x) >> ANGLETOFINESHIFT) * 360.0f / FINEANGLES) 30 | 31 | typedef unsigned angle_t; 32 | 33 | extern fixed_t* finecosine; 34 | extern fixed_t* finesine; 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /arm9/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | ifeq ($(strip $(DEVKITARM)),) 5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 6 | endif 7 | 8 | include $(DEVKITARM)/ds_rules 9 | 10 | #--------------------------------------------------------------------------------- 11 | # BUILD is the directory where object files & intermediate files will be placed 12 | # SOURCES is a list of directories containing source code 13 | # INCLUDES is a list of directories containing extra header files 14 | # DATA is a list of directories containing binary files 15 | # all directories are relative to this makefile 16 | #--------------------------------------------------------------------------------- 17 | BUILD := build 18 | SOURCES := source 19 | INCLUDES := include 20 | DATA := 21 | 22 | 23 | #--------------------------------------------------------------------------------- 24 | # options for code generation 25 | #--------------------------------------------------------------------------------- 26 | ARCH := -mthumb -mthumb-interwork 27 | 28 | CFLAGS := -g -Wall -O3\ 29 | -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\ 30 | -ffast-math \ 31 | $(ARCH) 32 | 33 | CFLAGS += $(INCLUDE) -DARM9 34 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 35 | 36 | ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s 37 | 38 | LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) 39 | 40 | #--------------------------------------------------------------------------------- 41 | # any extra libraries we wish to link with the project 42 | #--------------------------------------------------------------------------------- 43 | LIBS := -lm -lfat -lnds9 44 | 45 | #--------------------------------------------------------------------------------- 46 | # list of directories containing libraries, this must be the top level containing 47 | # include and lib 48 | #--------------------------------------------------------------------------------- 49 | LIBDIRS := $(LIBNDS) 50 | 51 | #--------------------------------------------------------------------------------- 52 | # no real need to edit anything past this point unless you need to add additional 53 | # rules for different file extensions 54 | #--------------------------------------------------------------------------------- 55 | ifneq ($(BUILD),$(notdir $(CURDIR))) 56 | #--------------------------------------------------------------------------------- 57 | 58 | export ARM9ELF := $(CURDIR)/$(TARGET).elf 59 | export DEPSDIR := $(CURDIR)/$(BUILD) 60 | 61 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 62 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 63 | 64 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 65 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 66 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 67 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 68 | 69 | #--------------------------------------------------------------------------------- 70 | # use CXX for linking C++ projects, CC for standard C 71 | #--------------------------------------------------------------------------------- 72 | ifeq ($(strip $(CPPFILES)),) 73 | #--------------------------------------------------------------------------------- 74 | export LD := $(CC) 75 | #--------------------------------------------------------------------------------- 76 | else 77 | #--------------------------------------------------------------------------------- 78 | export LD := $(CXX) 79 | #--------------------------------------------------------------------------------- 80 | endif 81 | #--------------------------------------------------------------------------------- 82 | 83 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 84 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 85 | 86 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 87 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 88 | -I$(CURDIR)/$(BUILD) 89 | 90 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 91 | 92 | .PHONY: $(BUILD) clean 93 | 94 | #--------------------------------------------------------------------------------- 95 | $(BUILD): 96 | @[ -d $@ ] || mkdir -p $@ 97 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 98 | 99 | #--------------------------------------------------------------------------------- 100 | clean: 101 | @echo clean ... 102 | @rm -fr $(BUILD) *.elf *.nds* *.bin 103 | 104 | 105 | #--------------------------------------------------------------------------------- 106 | else 107 | 108 | #--------------------------------------------------------------------------------- 109 | # main targets 110 | #--------------------------------------------------------------------------------- 111 | $(ARM9ELF) : $(OFILES) 112 | @echo linking $(notdir $@) 113 | @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ 114 | 115 | #--------------------------------------------------------------------------------- 116 | # you need a rule like this for each extension you use as binary data 117 | #--------------------------------------------------------------------------------- 118 | %.bin.o : %.bin 119 | #--------------------------------------------------------------------------------- 120 | @echo $(notdir $<) 121 | @$(bin2o) 122 | 123 | -include $(DEPSDIR)/*.d 124 | 125 | #--------------------------------------------------------------------------------------- 126 | endif 127 | #--------------------------------------------------------------------------------------- 128 | -------------------------------------------------------------------------------- /arm9/source/d_base.s: -------------------------------------------------------------------------------- 1 | @d_base.s 2 | @arm routines for doom64 DS 3 | 4 | .section .rodata 5 | 6 | .align 4 7 | .arm 8 | 9 | @========================================================================== 10 | @Functions 11 | @========================================================================== 12 | .global _DivInt 13 | .global _SlopeDiv 14 | .global _R_PointToAngle 15 | .global _R_PointOnSide 16 | .global FixedMul 17 | .global FixedDiv 18 | .global FixedDiv2 19 | 20 | @===================================== 21 | @_DivInt/_DivIntU 22 | @regular int divide 23 | @===================================== 24 | .pool 25 | _DivInt: 26 | @set r12 to address of DIV_NUMERATOR32 27 | ldr r12, =67109520 28 | 29 | @set DIV_CR DIV_32_32 bit 30 | mov r2, #0 31 | strh r2, [r12, #-16] 32 | 33 | @move a to DIV_NUMERATOR32 34 | str r0, [r12] 35 | @move b to DIV_DENOMINATOR32 36 | str r1, [r12, #8] 37 | 38 | @hang around until busy bit is clear 39 | .regWaitA: 40 | ldrh r0, [r12, #-16] 41 | ands r0, r0, #32768 42 | bne .regWaitA 43 | 44 | @put result from DIV_RESULT32 into r0 45 | ldr r0, [r12, #16] 46 | 47 | bx lr 48 | 49 | @===================================== 50 | @_SlopeDiv 51 | @===================================== 52 | _SlopeDiv: 53 | push {lr} 54 | cmp r1, #512 55 | movls r0, #2048 56 | bls .sdEnd1 57 | 58 | sub sp, sp, #4 59 | mov r0, r0, lsl #3 60 | mov r1, r1, lsr #8 61 | bl _DivInt 62 | add sp, sp, #4 63 | 64 | cmp r0, #2048 65 | movhi r0, #2048 66 | 67 | .sdEnd1: 68 | pop {pc} 69 | 70 | @===================================== 71 | @_R_PointToAngle 72 | @===================================== 73 | _R_PointToAngle: 74 | push {lr} 75 | mov r2, r1 76 | sub sp, sp, #4 77 | mov r3, r0 78 | orr r2, r0 79 | beq .L234 80 | 81 | cmp r0, #0 82 | blt .L226 83 | 84 | cmp r1, #0 85 | blt .L227 86 | 87 | cmp r0, r1 88 | ble .L228 89 | 90 | mov r0, r1 91 | mov r1, r3 92 | bl _SlopeDiv 93 | ldr r3, .L236 94 | lsl r0, r0, #2 95 | ldr r0, [r0, r3] 96 | add sp, sp, #4 97 | pop {pc} 98 | 99 | .L234: 100 | mov r0, #0 101 | .L225: 102 | add sp, sp, #4 103 | pop {pc} 104 | .L226: 105 | neg r3, r0 106 | cmp r1, #0 107 | 108 | blt .L230 109 | cmp r1, r3 110 | 111 | bge .L231 112 | mov r0, r1 113 | mov r1, r3 114 | bl _SlopeDiv 115 | ldr r3, .L236 116 | lsl r0, r0, #2 117 | ldr r2, [r0, r3] 118 | ldr r3, .L236+4 119 | sub r0, r3, r2 120 | add sp, sp, #4 121 | pop {pc} 122 | 123 | .L228: 124 | bl _SlopeDiv 125 | ldr r3, .L236 126 | lsl r0, r0, #2 127 | ldr r2, [r0, r3] 128 | ldr r3, .L236+8 129 | sub r0, r3, r2 130 | add sp, sp, #4 131 | pop {pc} 132 | 133 | .L227: 134 | neg r1, r1 135 | cmp r0, r1 136 | ble .L229 137 | 138 | mov r0, r1 139 | mov r1, r3 140 | bl _SlopeDiv 141 | ldr r3, .L236 142 | 143 | lsl r0, r0, #2 144 | ldr r3, [r0, r3] 145 | neg r0, r3 146 | add sp, sp, #4 147 | pop {pc} 148 | 149 | .L231: 150 | mov r0, r3 151 | bl _SlopeDiv 152 | ldr r3, .L236 153 | 154 | lsl r0, r0, #2 155 | ldr r3, [r0, r3] 156 | mov r2, #128 157 | lsl r2, r2, #23 158 | add r0, r3, r2 159 | add sp, sp, #4 160 | pop {pc} 161 | 162 | .L229: 163 | bl _SlopeDiv 164 | ldr r3, .L236 165 | 166 | lsl r0, r0, #2 167 | ldr r3, [r0, r3] 168 | ldr r2, .L236+12 169 | add r0, r3, r2 170 | add sp, sp, #4 171 | pop {pc} 172 | 173 | .L230: 174 | neg r1, r1 175 | cmp r3, r1 176 | bgt .L235 177 | 178 | mov r0, r3 179 | bl _SlopeDiv 180 | ldr r3, .L236 181 | 182 | lsl r0, r0, #2 183 | ldr r2, [r0, r3] 184 | ldr r3, .L236+16 185 | sub r0, r3, r2 186 | add sp, sp, #4 187 | pop {pc} 188 | 189 | .L235: 190 | mov r0, r1 191 | mov r1, r3 192 | bl _SlopeDiv 193 | ldr r3, .L236 194 | 195 | lsl r0, r0, #2 196 | ldr r3, [r0, r3] 197 | ldr r2, .L236+20 198 | add r0, r3, r2 199 | add sp, sp, #4 200 | pop {pc} 201 | 202 | .L237: 203 | .align 2 204 | .L236: 205 | .word tantoangle 206 | .word 2147483647 207 | .word 1073741823 208 | .word -1073741824 209 | .word -1073741825 210 | .word -2147483648 211 | 212 | @===================================== 213 | @_R_PointOnSide 214 | @===================================== 215 | 216 | _R_PointOnSide: 217 | push {r4, r5, r6, lr} 218 | mov r4, r0 219 | ldr r0, [r2, #8] 220 | 221 | mov r6, r1 222 | mov r5, r2 223 | cmp r0, #0 224 | bne .L182 225 | 226 | ldr r3, [r2] 227 | cmp r3, r4 228 | bge .L189 229 | 230 | ldr r3, [r2, #12] 231 | lsr r0, r3, #31 232 | .L184: 233 | pop {r4, r5, r6, pc} 234 | 235 | .L182: 236 | ldr r1, [r2, #12] 237 | cmp r1, #0 238 | bne .L185 239 | 240 | ldr r3, [r2, #4] 241 | cmp r3, r6 242 | blt .L186 243 | lsr r0, r0, #31 244 | pop {r4, r5, r6, pc} 245 | 246 | .L185: 247 | ldr r3, [r2] 248 | sub r2, r4, r3 249 | 250 | ldr r3, [r5, #4] 251 | sub r6, r6, r3 252 | 253 | mov r3, r1 254 | eor r3, r3, r0 255 | eor r3, r3, r2 256 | eor r3, r3, r6 257 | cmp r3, #0 258 | blt .L190 259 | asr r0, r1, #16 260 | mov r1, r2 261 | bl FixedMul 262 | 263 | ldr r1, [r5, #8] 264 | mov r4, r0 265 | 266 | asr r1, r1, #16 267 | mov r0, r6 268 | bl FixedMul 269 | lsr r2, r4, #31 270 | asr r3, r0, #31 271 | 272 | cmp r0, r4 273 | adc r2, r2, r3 274 | mov r0, r2 275 | 276 | pop {r4, r5, r6, pc} 277 | 278 | .L189: 279 | ldr r2, [r2, #12] 280 | 281 | asr r3, r2, #31 282 | sub r3, r3, r2 283 | lsr r0, r3, #31 284 | pop {r4, r5, r6, pc} 285 | 286 | .L186: 287 | asr r3, r0, #31 288 | sub r3, r3, r0 289 | lsr r0, r3, #31 290 | pop {r4, r5, r6, pc} 291 | 292 | .L190: 293 | mov r3, r2 294 | eor r3, r3, r1 295 | lsr r0, r3, #31 296 | pop {r4, r5, r6, pc} 297 | 298 | @===================================== 299 | @FixedMul 300 | @fast fixed multiply 301 | @===================================== 302 | FixedMul: 303 | smull r2, r3, r0, r1 304 | 305 | @shift by FRACBITS 306 | mov r1, r2, lsr #16 307 | mov r2, r3, lsl #16 308 | orr r0, r1, r2 309 | 310 | bx lr 311 | 312 | @===================================== 313 | @FixedDiv 314 | @bounds checking prefrace to FixedDiv2 315 | @===================================== 316 | .pool 317 | FixedDiv: 318 | mov r2, r0 319 | mov r3, r1 320 | 321 | @abs a, b 322 | cmp r2, #0 323 | rsblt r2, r2, #0 324 | cmp r3, #0 325 | rsblt r3, r3, #0 326 | 327 | mov r2, r2, lsr #14 328 | 329 | @if abs(a)>>14 >= abs(b) 330 | cmp r2, r3 331 | 332 | blt FixedDiv2 333 | 334 | @then return (a^b)<0 ? MININT : MAXINT 335 | eors r2, r0, r1 336 | movpl r0, #2147483647 337 | movmi r0, #2147483648 338 | 339 | bx lr 340 | 341 | @===================================== 342 | @FixedDiv2 343 | @fast fixed divide 344 | @===================================== 345 | FixedDiv2: 346 | @store low 32 bits in r2 347 | mov r2, r0 348 | 349 | @extend to r3 350 | ands r3, r0, #2147483648 351 | movmi r3, #-1 352 | 353 | @shift over 2 registers 354 | mov r3, r3, lsl #16 355 | mov r0, r2, lsr #16 356 | orr r3, r3, r0 357 | mov r2, r2, asl #16 358 | 359 | @set r12 to address of DIV_NUMERATOR64 360 | ldr r12, =67109520 361 | 362 | @set DIV_CR DIV_64_32 bit 363 | mov r0, #1 364 | strh r0, [r12, #-16] 365 | 366 | @move expanded a into DIV_NUMERATOR64 367 | stmia r12, {r2-r3} 368 | 369 | @move b into DIV_DENOMINATOR32 370 | str r1, [r12, #8] 371 | 372 | @hang around until busy bit is clear 373 | .regWaitB: 374 | ldrh r0, [r12, #-16] 375 | ands r0, r0, #32768 376 | bne .regWaitB 377 | 378 | @put result from DIV_RESULT32 into r0 379 | ldr r0, [r12, #16] 380 | 381 | bx lr -------------------------------------------------------------------------------- /arm9/source/d_englsh.h: -------------------------------------------------------------------------------- 1 | #ifndef __D_ENGLSH__ 2 | #define __D_ENGLSH__ 3 | 4 | // 5 | // Printed strings for translation 6 | // 7 | 8 | // Misc. other strings. 9 | #define SAVEGAMENAME "doomsav" 10 | 11 | 12 | #define DEVMAPS "devmaps" 13 | #define DEVDATA "devdata" 14 | 15 | // 16 | // D_Main.C 17 | // 18 | #define D_DEVSTR "Development mode ON.\n" 19 | 20 | // 21 | // M_Menu.C 22 | // 23 | 24 | #define MSGOFF "Messages OFF" 25 | #define MSGON "Messages ON" 26 | 27 | #define DOSY "(press y to quit)" 28 | 29 | #define GAMMALVL0 "Gamma correction OFF" 30 | #define GAMMALVL1 "Gamma correction level 1.1" 31 | #define GAMMALVL2 "Gamma correction level 1.2" 32 | #define GAMMALVL3 "Gamma correction level 1.3" 33 | #define GAMMALVL4 "Gamma correction level 1.4" 34 | #define GAMMALVL5 "Gamma correction level 1.5" 35 | #define GAMMALVL6 "Gamma correction level 1.6" 36 | #define GAMMALVL7 "Gamma correction level 1.7" 37 | #define GAMMALVL8 "Gamma correction level 1.8" 38 | #define GAMMALVL9 "Gamma correction level 1.9" 39 | #define GAMMALVL10 "Gamma correction level 2.0" 40 | #define GAMMALVL11 "Gamma correction level 2.1" 41 | #define GAMMALVL12 "Gamma correction level 2.2" 42 | #define GAMMALVL13 "Gamma correction level 2.3" 43 | #define GAMMALVL14 "Gamma correction level 2.4" 44 | #define GAMMALVL15 "Gamma correction level 2.5" 45 | #define GAMMALVL16 "Gamma correction level 2.6" 46 | #define GAMMALVL17 "Gamma correction level 2.7" 47 | #define GAMMALVL18 "Gamma correction level 2.8" 48 | #define GAMMALVL19 "Gamma correction level 2.9" 49 | #define GAMMALVL20 "Gamma correction level 3.0" 50 | 51 | #define EMPTYSTRING "NO SAVE" 52 | 53 | // 54 | // P_inter.C 55 | // 56 | #define GOTARMOR "You pick up the armor." 57 | #define GOTMEGA "You got the MegaArmor!" 58 | #define GOTHTHBONUS "You pick up a health bonus." 59 | #define GOTARMBONUS "You pick up an armor bonus." 60 | #define GOTSTIM "You pick up a stimpack." 61 | #define GOTMEDINEED "You pick up a medikit that you REALLY need!" 62 | #define GOTMEDIKIT "You pick up a medikit." 63 | #define GOTSUPER "Supercharge!" 64 | 65 | #define GOTBLUECARD "You pick up a blue keycard." 66 | #define GOTYELWCARD "You pick up a yellow keycard." 67 | #define GOTREDCARD "You pick up a red keycard." 68 | #define GOTBLUESKUL "You pick up a blue skull key." 69 | #define GOTYELWSKUL "You pick up a yellow skull key." 70 | #define GOTREDSKULL "You pick up a red skull key." 71 | 72 | #define GOTARTIFACT1 "You have a feeling that\nit wasn't to be touched..." 73 | #define GOTARTIFACT2 "Whatever it is, it doesn't\nbelong in this world..." 74 | #define GOTARTIFACT3 "It must do something..." 75 | 76 | #define GOTINVUL "Invulnerability!" 77 | #define GOTBERSERK "Berserk!" 78 | #define GOTINVIS "Partial Invisibility!" 79 | #define GOTSUIT "Radiation Shield" 80 | #define GOTMAP "Computer Area Map" 81 | #define GOTVISOR "Light Amplification Goggles" 82 | #define GOTMSPHERE "Mega Sphere!" 83 | 84 | #define GOTCLIP "Picked up a clip." 85 | #define GOTCLIPBOX "Picked up a box of bullets." 86 | #define GOTROCKET "Picked up a rocket." 87 | #define GOTROCKBOX "Picked up a box of rockets." 88 | #define GOTCELL "Picked up an energy cell." 89 | #define GOTCELLBOX "Picked up an energy cell pack." 90 | #define GOTSHELLS "Picked up 4 shotgun shells." 91 | #define GOTSHELLS2 "Picked up 8 shotgun shells." 92 | #define GOTSHELLBOX "Picked up a box of shells." 93 | #define GOTBACKPACK "You got the backpack!" 94 | 95 | #define GOTBFG9000 "You got the BFG9000! Oh, yes." 96 | #define GOTCHAINGUN "You got the chaingun!" 97 | #define GOTCHAINSAW "A chainsaw! Find some meat!" 98 | #define GOTLAUNCHER "You got the rocket launcher!" 99 | #define GOTPLASMA "You got the plasma gun!" 100 | #define GOTSHOTGUN "You got the shotgun!" 101 | #define GOTSHOTGUN2 "You got the super shotgun!" 102 | #define GOTLASER "What the heck is this?!" 103 | 104 | #define FOUNDSECRET "You found a secret area!" 105 | 106 | #define MOCKPLAYER1 "HAHAHAHA!" 107 | #define MOCKPLAYER2 "YOU SHOULDN'T HAVE DONE THAT." 108 | #define MOCKPLAYER3 "TRY AN EASIER LEVEL..." 109 | #define MOCKPLAYER4 "WOW! LOOK AT THOSE DEMON FEET." 110 | #define MOCKPLAYER5 "I PLAY DOOM AND I CAN'T GET UP." 111 | #define MOCKPLAYER6 "OUCH! THAT HAD TO HURT." 112 | #define MOCKPLAYER7 "LOOK AT ME! I'M FLAT!" 113 | #define MOCKPLAYER8 "THANKS FOR PLAYING!" 114 | #define MOCKPLAYER9 "YOU LAZY @&$#!" 115 | #define MOCKPLAYER10 "HAVE YOU HAD ENOUGH?" 116 | #define MOCKPLAYER11 "THE DEMONS GAVE YOU THE BOOT!" 117 | #define MOCKPLAYER12 "THE LEAD DEMON VANQUISHED YOU!" 118 | #define MOCKPLAYER13 "AT LEAST YOU PLAY BETTER THAN KAISER!" 119 | 120 | #define DEVKILLALL "Boy I Suck!" 121 | 122 | 123 | // 124 | // P_Doors.C 125 | // 126 | 127 | #define PD_BLUE "You need a blue key." 128 | #define PD_YELLOW "You need a yellow key." 129 | #define PD_RED "You need a red key." 130 | #define PD_ARTIFACT "You lack the ability to activate it." 131 | 132 | // 133 | // G_game.C 134 | // 135 | #define GGSAVED "game saved." 136 | #define GGAUTORUNON "Autorun ON" 137 | #define GGAUTORUNOFF "Autorun OFF" 138 | #define GGSCREENSHOT "Screenshot saved" 139 | 140 | #define HUSTR_CHATMACRO1 "I'm ready to kick butt!" 141 | #define HUSTR_CHATMACRO2 "I'm OK." 142 | #define HUSTR_CHATMACRO3 "I'm not looking too good!" 143 | #define HUSTR_CHATMACRO4 "Help!" 144 | #define HUSTR_CHATMACRO5 "You suck!" 145 | #define HUSTR_CHATMACRO6 "Next time, scumbag..." 146 | #define HUSTR_CHATMACRO7 "Come here!" 147 | #define HUSTR_CHATMACRO8 "I'll take care of it." 148 | #define HUSTR_CHATMACRO9 "Yes" 149 | #define HUSTR_CHATMACRO0 "No" 150 | 151 | #define HUSTR_TALKTOSELF1 "You mumble to yourself" 152 | #define HUSTR_TALKTOSELF2 "Who's there?" 153 | #define HUSTR_TALKTOSELF3 "You scare yourself" 154 | #define HUSTR_TALKTOSELF4 "You start to rave" 155 | #define HUSTR_TALKTOSELF5 "You've lost it..." 156 | 157 | #define HUSTR_MESSAGESENT "[Message Sent]" 158 | 159 | #define HUSTR_PLR1 "Green" 160 | #define HUSTR_PLR2 "Red" 161 | #define HUSTR_PLR3 "Aqua" 162 | #define HUSTR_PLR4 "Blue" 163 | 164 | #define HUSTR_KEYPLR1 'g' 165 | #define HUSTR_KEYPLR2 'r' 166 | #define HUSTR_KEYPLR3 'a' 167 | #define HUSTR_KEYPLR4 'b' 168 | 169 | // 170 | // AM_map.C 171 | // 172 | 173 | #define AMSTR_FOLLOWON "Follow Mode ON" 174 | #define AMSTR_FOLLOWOFF "Follow Mode OFF" 175 | 176 | // 177 | // ST_stuff.C 178 | // 179 | 180 | #define STSTR_DQDON "All Powerful Mode ON" 181 | #define STSTR_DQDOFF "All Powerful Mode OFF" 182 | 183 | #define STSTR_KFAADDED "Lots of Goodies!" 184 | #define STSTR_FAADDED "Lots of Ammo!" 185 | 186 | #define STSTR_NCON "No Clipping Mode ON" 187 | #define STSTR_NCOFF "No Clipping Mode OFF" 188 | 189 | 190 | // 191 | // Character cast strings F_FINALE.C 192 | // 193 | 194 | #define CC_ZOMBIE "Zombieman" 195 | #define CC_SHOTGUN "Shotgun Guy" 196 | #define CC_IMP "Imp" 197 | #define CC_IMP2 "Nightmare Imp" 198 | #define CC_DEMON "Demon" 199 | #define CC_DEMON2 "Spectre" 200 | #define CC_LOST "Lost Soul" 201 | #define CC_CACO "Cacodemon" 202 | #define CC_HELL "Hell Knight" 203 | #define CC_BARON "Baron Of Hell" 204 | #define CC_ARACH "Arachnotron" 205 | #define CC_PAIN "Pain Elemental" 206 | #define CC_MANCU "Mancubus" 207 | #define CC_CYBER "The Cyberdemon" 208 | #define CC_HERO "Our Hero" 209 | 210 | #endif 211 | 212 | -------------------------------------------------------------------------------- /arm9/source/d_main.h: -------------------------------------------------------------------------------- 1 | #ifndef __D_MAIN__ 2 | #define __D_MAIN__ 3 | 4 | #include "doomtype.h" 5 | #include "doomdef.h" 6 | #include "m_fixed.h" 7 | #include "d_player.h" 8 | 9 | typedef enum 10 | { 11 | ga_nothing, 12 | ga_loadlevel, 13 | ga_newgame, 14 | ga_loadgame, 15 | ga_exitdemo, 16 | ga_completed, 17 | ga_victory, 18 | ga_finale, 19 | ga_screenshot, 20 | ga_warplevel, 21 | ga_warpquick, 22 | ga_title 23 | } gameaction_t; 24 | 25 | // 26 | // EVENT HANDLING 27 | // 28 | 29 | // Input event types. 30 | typedef enum 31 | { 32 | ev_btndown, 33 | ev_btnup, 34 | ev_btnheld 35 | } evtype_t; 36 | 37 | // Event structure. 38 | typedef struct 39 | { 40 | evtype_t type; 41 | int data; 42 | } event_t; 43 | 44 | // 45 | // Button/action code definitions. 46 | // 47 | typedef enum 48 | { 49 | // Press "Fire". 50 | BT_ATTACK = (1 << 0), 51 | // Use button, to open doors, activate switches. 52 | BT_USE = (1 << 1), 53 | // Flag, weapon change pending. 54 | // If true, the next 3 bits hold weapon num. 55 | BT_CHANGE = (1 << 2), 56 | BT_NEXTWEAP = (1 << 3), 57 | BT_PREVWEAP = (1 << 4), 58 | // Flag: game events, not really buttons. 59 | BT_SPECIAL = (1 << 7), 60 | BT_SPECIALMASK = 3, 61 | 62 | // Pause the game. 63 | BTS_PAUSE = 1 64 | } buttoncode_t; 65 | 66 | #define MAXEVENTS 64 67 | 68 | extern event_t events[MAXEVENTS]; 69 | extern int eventhead; 70 | extern int eventtail; 71 | 72 | void D_PostEvent(event_t* ev); 73 | 74 | // Defaults for menu, methinks. 75 | extern skill_t startskill; 76 | extern int startmap; 77 | extern gameaction_t gameaction; 78 | extern gamestate_t gamestate; 79 | extern skill_t gameskill; 80 | extern int gamemap; 81 | extern int nextmap; 82 | extern int gametic; 83 | extern int validcount; 84 | extern int totalkills; 85 | extern int totalitems; 86 | extern int totalsecret; 87 | extern dboolean nomonsters; 88 | extern dboolean lockmonsters; 89 | extern dboolean respawnmonsters; 90 | extern dboolean respawnspecials; 91 | extern dboolean fastparm; 92 | extern dboolean demoplayback; 93 | extern dboolean respawnparm; // checkparm of -respawn 94 | extern dboolean respawnitem; 95 | extern dboolean paused; 96 | extern dboolean nolights; 97 | extern dboolean devparm; 98 | extern int dsvertices; 99 | extern int dspolygons; 100 | extern int gfxdmasize; 101 | 102 | extern player_t players[MAXPLAYERS]; 103 | extern dboolean playeringame[MAXPLAYERS]; 104 | // Player spawn spots. 105 | extern mapthing_t playerstarts[MAXPLAYERS]; 106 | 107 | // 1'st Player taking events 108 | extern int consoleplayer; 109 | 110 | // tics in game play for par 111 | extern int leveltime; 112 | 113 | // only true if packets are broadcast 114 | extern dboolean netgame; 115 | 116 | extern byte rndtable[256]; 117 | extern int rndindex; 118 | 119 | extern int maketic; 120 | extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; 121 | extern int ticdup; 122 | extern int extratics; 123 | 124 | static inline void D_IncValidCount(void) 125 | { 126 | validcount++; 127 | } 128 | 129 | void D_Printf(const char *s, ...); 130 | void D_DoomMain(void); 131 | void D_UpdateTiccmd(void); 132 | int D_MiniLoop(void(*start)(void), void(*stop)(void), 133 | void (*draw)(void), dboolean(*tick)(void)); 134 | 135 | int datoi(const char *str); 136 | int dhtoi(char* str); 137 | float datof(char *str); 138 | dboolean dfcmp(float f1, float f2); 139 | 140 | static inline int D_abs(x) 141 | { 142 | fixed_t _t = (x),_s; 143 | _s = _t >> (8*sizeof _t-1); 144 | return (_t^_s)-_s; 145 | } 146 | 147 | static inline float D_fabs(float x) 148 | { 149 | return x < 0 ? -x : x; 150 | } 151 | 152 | // 153 | // AUTOMAP 154 | // 155 | extern int amCheating; 156 | extern dboolean automapactive; 157 | 158 | void AM_Start(void); 159 | void AM_Stop(void); 160 | void AM_Ticker(void); 161 | void AM_Drawer(void); 162 | dboolean AM_Responder(event_t* ev); 163 | 164 | // 165 | // PLAY 166 | // 167 | void P_Start(void); 168 | void P_Stop(void); 169 | void P_Drawer(void); 170 | int P_Ticker(void); 171 | 172 | // 173 | // INTERMISSION 174 | // 175 | void WI_Start(void); 176 | void WI_Drawer(void); 177 | void WI_Stop(void); 178 | int WI_Ticker(void); 179 | 180 | // 181 | // FINALE 182 | // 183 | void F_Start(void); 184 | void F_Stop(void); 185 | int F_Ticker(void); 186 | void F_Drawer (void); 187 | 188 | // 189 | // FINALE2 190 | // 191 | void IN_Start(void); 192 | void IN_Stop(void); 193 | void IN_Drawer(void); 194 | int IN_Ticker(void); 195 | 196 | // 197 | // MENU 198 | // 199 | extern dboolean menuactive; 200 | 201 | void M_Ticker(void); 202 | void M_Drawer(void); 203 | void M_SetMainMenu(void); 204 | dboolean M_Responder(event_t* ev); 205 | 206 | #endif // __D_MAIN__ -------------------------------------------------------------------------------- /arm9/source/d_player.h: -------------------------------------------------------------------------------- 1 | #ifndef __D_PLAYER__ 2 | #define __D_PLAYER__ 3 | 4 | #include "p_pspr.h" 5 | #include "p_mobj.h" 6 | 7 | // The data sampled per tick (single player) 8 | // and transmitted to other peers (multiplayer). 9 | // Mainly movements/button commands per game tick, 10 | // plus a checksum for internal state consistency. 11 | typedef struct 12 | { 13 | short forwardmove; // *2048 for move 14 | short sidemove; // *2048 for move 15 | short angleturn; // <<16 for angle delta 16 | short pitch; 17 | byte consistancy; // checks for net game 18 | byte buttons; 19 | } ticcmd_t; 20 | 21 | // 22 | // Player states. 23 | // 24 | typedef enum 25 | { 26 | PST_LIVE, // Playing or camping. 27 | PST_DEAD, // Dead on the ground, view follows killer. 28 | PST_REBORN // Ready to restart/respawn??? 29 | 30 | } playerstate_t; 31 | 32 | 33 | // 34 | // Player internal flags, for cheats and debug. 35 | // 36 | typedef enum 37 | { 38 | CF_NOCLIP = 1, // No clipping, walk through barriers. 39 | CF_GODMODE = 2, // No damage, no health loss. 40 | CF_UNDYING = 4, // Take damage but not die 41 | CF_SPECTATOR = 8, // Specator mode 42 | CF_CHASECAM = 16, // Chase cam mode 43 | CF_FLOATCAM = 32 // Floating camera 44 | 45 | } cheat_t; 46 | 47 | typedef enum 48 | { 49 | ART_FAST = 0, 50 | ART_DOUBLE, 51 | ART_TRIPLE 52 | 53 | } artifacts_t; 54 | 55 | 56 | // 57 | // Extended player object info: player_t 58 | // 59 | typedef struct player_s 60 | { 61 | mobj_t* mo; 62 | playerstate_t playerstate; 63 | ticcmd_t cmd; 64 | 65 | // Determine POV, 66 | // including viewpoint bobbing during movement. 67 | // Focal origin above r.z 68 | fixed_t viewz; 69 | // Base height above floor for viewz. 70 | fixed_t viewheight; 71 | // Bob/squat speed. 72 | fixed_t deltaviewheight; 73 | // bounded/scaled total momentum. 74 | fixed_t bob; 75 | 76 | // [d64] extra pitch for recoil/knockback 77 | angle_t recoilpitch; 78 | 79 | // This is only used between levels, 80 | // mo->health is used during levels. 81 | int health; 82 | int armorpoints; 83 | // Armor type is 0-2. 84 | int armortype; 85 | 86 | // Power ups. invinc and invis are tic counters. 87 | int powers[NUMPOWERS]; 88 | dboolean cards[NUMCARDS]; 89 | 90 | // [kex] for hud when trying to open a locked door 91 | dboolean tryopen[NUMCARDS]; 92 | 93 | // [d64] laser artifact flags 94 | int artifacts; 95 | 96 | dboolean backpack; 97 | 98 | weapontype_t readyweapon; 99 | 100 | // Is wp_nochange if not changing. 101 | weapontype_t pendingweapon; 102 | 103 | dboolean weaponowned[NUMWEAPONS]; 104 | int ammo[NUMAMMO]; 105 | int maxammo[NUMAMMO]; 106 | 107 | // True if button down last tic. 108 | int attackdown; 109 | int usedown; 110 | 111 | // [kex] true if jump button down last tic 112 | int jumpdown; 113 | 114 | // Bit flags, for cheats and debug. 115 | // See cheat_t, above. 116 | int cheats; 117 | 118 | // Refired shots are less accurate. 119 | int refire; 120 | 121 | // For intermission stats. 122 | int killcount; 123 | int itemcount; 124 | int secretcount; 125 | 126 | // Hint messages. 127 | char* message; 128 | 129 | // [d64] tic for how long message should stay on hud...not used in d64ex 130 | // int messagetic; 131 | 132 | // For screen flashing (red or bright). 133 | int damagecount; 134 | int bonuscount; 135 | int bfgcount; 136 | 137 | // Who did damage (NULL for floors/ceilings). 138 | mobj_t* attacker; 139 | 140 | // [kex] which mobj to use as the view camera (defaults to player->mo) 141 | mobj_t* cameratarget; 142 | 143 | // Overlay view sprites (gun, etc). 144 | pspdef_t psprites[NUMPSPRITES]; 145 | 146 | // Translation palettes for multiplayer 147 | int palette; 148 | 149 | // [d64] Track if player is on the ground or not 150 | dboolean onground; 151 | 152 | // [kex] allow autoaim? 153 | dboolean autoaim; 154 | 155 | // [kex] display pic as message instead of text 156 | int messagepic; 157 | 158 | } player_t; 159 | 160 | #endif 161 | 162 | -------------------------------------------------------------------------------- /arm9/source/d_think.h: -------------------------------------------------------------------------------- 1 | #ifndef __D_THINK__ 2 | #define __D_THINK__ 3 | 4 | // 5 | // Experimental stuff. 6 | // To compile this as "ANSI C with classes" 7 | // we will need to handle the various 8 | // action functions cleanly. 9 | // 10 | typedef void(*actionf_v)(void); 11 | typedef void(*actionf_p1)(void*); 12 | typedef void(*actionf_p2)(void*, void*); 13 | 14 | typedef union 15 | { 16 | actionf_p1 acp1; 17 | actionf_v acv; 18 | actionf_p2 acp2; 19 | 20 | } actionf_t; 21 | 22 | 23 | 24 | 25 | 26 | // Historically, "think_t" is yet another 27 | // function pointer to a routine to handle 28 | // an actor. 29 | typedef actionf_t think_t; 30 | 31 | 32 | // Doubly linked list of actors. 33 | typedef struct thinker_s 34 | { 35 | struct thinker_s* prev; 36 | struct thinker_s* next; 37 | think_t function; 38 | 39 | } thinker_t; 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /arm9/source/doomdef.h: -------------------------------------------------------------------------------- 1 | #ifndef __DOOMDEF__ 2 | #define __DOOMDEF__ 3 | 4 | #include 5 | #include "ds.h" 6 | #include "doomtype.h" 7 | #include "tables.h" 8 | 9 | #define dcos(angle) finecosine[(angle) >> ANGLETOFINESHIFT] 10 | #define dsin(angle) finesine[(angle) >> ANGLETOFINESHIFT] 11 | 12 | // 13 | // The packed attribute forces structures to be packed into the minimum 14 | // space necessary. If this is not done, the compiler may align structure 15 | // fields differently to optimise memory access, inflating the overall 16 | // structure size. It is important to use the packed attribute on certain 17 | // structures where alignment is important, particularly data read/written 18 | // to disk. 19 | // 20 | 21 | #define PACKEDATTR __attribute__((packed)) 22 | #define PUREFUNC __attribute__((pure)) 23 | #define NOINLINE __attribute__((noinline)) 24 | 25 | // 26 | // Global parameters/defines. 27 | // 28 | 29 | #define SCREENWIDTH 320 30 | #define SCREENHEIGHT 240 31 | 32 | #define MAX_MESSAGE_SIZE 1024 33 | 34 | // The maximum number of players, multiplayer/networking. 35 | // remember to add settings for extra skins if increase:) 36 | #define MAXPLAYERS 4 37 | 38 | // State updates, number of tics / second. 39 | #define TICRATE 30 40 | 41 | // Networking and tick handling related. 42 | #define BACKUPTICS 128 43 | 44 | // The current state of the game: whether we are 45 | // playing, gazing at the intermission screen, 46 | // the game final animation, or a demo. 47 | typedef enum 48 | { 49 | GS_NONE, 50 | GS_LEVEL, 51 | GS_WISTATS, 52 | GS_FINALE, 53 | GS_SKIPPABLE 54 | } gamestate_t; 55 | 56 | // 57 | // Difficulty/skill settings/filters. 58 | // 59 | 60 | // Skill flags. 61 | #define MTF_EASY 1 62 | #define MTF_NORMAL 2 63 | #define MTF_HARD 4 64 | #define MTF_AMBUSH 8 // Deaf monsters/do not react to sound. 65 | #define MTF_MULTI 16 // Multiplayer specific 66 | #define MTF_SPAWN 32 // Don't spawn until triggered in level 67 | #define MTF_ONTOUCH 64 // Trigger something when picked up 68 | #define MTF_ONDEATH 128 // Trigger something when killed 69 | #define MTF_SECRET 256 // Count as secret for intermission when picked up 70 | #define MTF_NOINFIGHTING 512 // Ignore other attackers 71 | #define MTF_NODEATHMATCH 1024 // Don't spawn in deathmatch games 72 | #define MTF_NONETGAME 2048 // Don't spawn in standard netgame mode 73 | 74 | // 75 | // MAPINFO 76 | // 77 | 78 | typedef struct 79 | { 80 | char mapname[64]; 81 | int mapid; 82 | int music; 83 | int type; 84 | int cluster; 85 | int exitdelay; 86 | dboolean nointermission; 87 | dboolean clearchts; 88 | dboolean forcegodmode; 89 | dboolean contmusexit; 90 | int oldcollision; 91 | int allowjump; 92 | } mapdef_t; 93 | 94 | typedef struct 95 | { 96 | int id; 97 | int music; 98 | dboolean enteronly; 99 | short pic_x; 100 | short pic_y; 101 | dboolean nointermission; 102 | dboolean scrolltextend; 103 | char text[512]; 104 | char pic[9]; 105 | } clusterdef_t; 106 | 107 | // 108 | // [kex] mapinfo 109 | // 110 | mapdef_t* P_GetMapInfo(int map); 111 | clusterdef_t* P_GetCluster(int map); 112 | 113 | // 114 | // [kex] sky definitions 115 | // 116 | typedef enum 117 | { 118 | SKF_CLOUD = 0x1, 119 | SKF_THUNDER = 0x2, 120 | SKF_FIRE = 0x4, 121 | SKF_BACKGROUND = 0x8, 122 | SKF_FADEBACK = 0x10, 123 | SKF_VOID = 0x20 124 | } skyflags_e; 125 | 126 | typedef struct 127 | { 128 | char flat[9]; 129 | int flags; 130 | char pic[9]; 131 | char backdrop[9]; 132 | rcolor fogcolor; 133 | rcolor skycolor[3]; 134 | int fognear; 135 | } skydef_t; 136 | 137 | typedef enum 138 | { 139 | sk_baby, 140 | sk_easy, 141 | sk_medium, 142 | sk_hard, 143 | sk_nightmare 144 | } skill_t; 145 | 146 | // 147 | // Key cards. 148 | // 149 | typedef enum 150 | { 151 | it_bluecard, 152 | it_yellowcard, 153 | it_redcard, 154 | it_blueskull, 155 | it_yellowskull, 156 | it_redskull, 157 | 158 | NUMCARDS 159 | 160 | } card_t; 161 | 162 | // The defined weapons, 163 | // including a marker indicating 164 | // user has not changed weapon. 165 | typedef enum 166 | { 167 | wp_chainsaw, 168 | wp_fist, 169 | wp_pistol, 170 | wp_shotgun, 171 | wp_supershotgun, 172 | wp_chaingun, 173 | wp_missile, 174 | wp_plasma, 175 | wp_bfg, 176 | wp_laser, 177 | NUMWEAPONS, 178 | 179 | // No pending weapon change. 180 | wp_nochange 181 | 182 | } weapontype_t; 183 | 184 | // Ammunition types defined. 185 | typedef enum 186 | { 187 | am_clip, // Pistol / chaingun ammo. 188 | am_shell, // Shotgun / double barreled shotgun. 189 | am_cell, // Plasma rifle, BFG. 190 | am_misl, // Missile launcher. 191 | NUMAMMO, 192 | am_noammo // Unlimited for chainsaw / fist. 193 | 194 | } ammotype_t; 195 | 196 | // Power up artifacts. 197 | typedef enum 198 | { 199 | pw_invulnerability, 200 | pw_strength, 201 | pw_invisibility, 202 | pw_ironfeet, 203 | pw_allmap, 204 | pw_infrared, 205 | NUMPOWERS 206 | 207 | } powertype_t; 208 | 209 | #define BONUSADD 4 210 | 211 | // 212 | // Power up durations, 213 | // how many seconds till expiration, 214 | // 215 | typedef enum 216 | { 217 | INVULNTICS = (30*TICRATE), 218 | INVISTICS = (60*TICRATE), 219 | INFRATICS = (120*TICRATE), 220 | IRONTICS = (60*TICRATE), 221 | STRTICS = (3*TICRATE) 222 | 223 | } powerduration_t; 224 | 225 | // 226 | // MISC 227 | // 228 | 229 | // bbox coordinates 230 | enum 231 | { 232 | BOXTOP, 233 | BOXBOTTOM, 234 | BOXLEFT, 235 | BOXRIGHT 236 | }; 237 | 238 | // Bounding box functions. 239 | void M_ClearBox (fixed_t* box); 240 | void M_AddToBox(fixed_t* box, fixed_t x, fixed_t y); 241 | 242 | // Randomizer functions 243 | int P_Random(void); // tic dependent 244 | int M_Random(void); // not tic dependent 245 | void M_ClearRandom(void); 246 | int P_RandomShift(int shift); 247 | 248 | extern int compatflags; 249 | 250 | // 20120209 villsa - compatibility flags 251 | enum 252 | { 253 | COMPATF_COLLISION = (1 << 0), // don't use maxradius for mobj position checks 254 | COMPATF_MOBJPASS = (1 << 1), // allow mobjs to stand on top one another 255 | COMPATF_LIMITPAIN = (1 << 2), // pain elemental limited to 17 lost souls? 256 | }; 257 | 258 | #endif // __DOOMDEF__ 259 | -------------------------------------------------------------------------------- /arm9/source/doomtype.h: -------------------------------------------------------------------------------- 1 | #ifndef __DOOMTYPE__ 2 | #define __DOOMTYPE__ 3 | 4 | #include 5 | 6 | #undef true 7 | 8 | #define false 0 9 | #define true (!false) 10 | 11 | typedef int dboolean; 12 | typedef unsigned char byte; 13 | typedef unsigned short word; 14 | typedef unsigned long dword; 15 | typedef unsigned int rcolor; 16 | typedef int dtexture; 17 | typedef int8_t int8; 18 | typedef uint8_t uint8; 19 | typedef int16_t int16; 20 | typedef uint16_t uint16; 21 | typedef int32_t int32; 22 | typedef uint32_t uint32; 23 | 24 | #include 25 | #define MININT INT_MIN 26 | #define MAXINT INT_MAX 27 | #endif 28 | 29 | #ifndef MAX 30 | #define MAX(a,b) ((a)>(b)?(a):(b)) 31 | #endif 32 | 33 | #ifndef MIN 34 | #define MIN(a,b) ((a)<(b)?(a):(b)) 35 | #endif 36 | 37 | #ifndef BETWEEN 38 | #define BETWEEN(l,u,x) ((l)>(x)?(l):(x)>(u)?(u):(x)) 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /arm9/source/ds.h: -------------------------------------------------------------------------------- 1 | #ifndef __DS_MAIN__ 2 | #define __DS_MAIN__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "doomtype.h" 8 | #include "doomdef.h" 9 | #include "z_zone.h" 10 | 11 | #define ARM9_MAIN main 12 | 13 | void I_Init(void); 14 | void I_Error(const char *s, ...); 15 | void I_Printf(const char *s, ...); 16 | void I_PrintWait(const char *s, ...); 17 | void I_StartTic(void); 18 | int I_GetTime(void); 19 | int I_GetTimeMS(void); 20 | void I_Sleep(uint32 ms); 21 | int I_GetTimeTicks(void); 22 | void I_FinishFrame(void); 23 | 24 | #define FIFO_MSG_PLAYERDATA 0 25 | #define FIFO_MSG_LINEDEFDATA 1 26 | #define FIFO_MSG_SSECTDATA 2 27 | #define FIFO_MSG_VERTEXDATA 3 28 | #define FIFO_MSG_FINESINEDATA 4 29 | #define FIFO_MSG_FINECOSINEDATA 5 30 | 31 | typedef union 32 | { 33 | void* arg_p; 34 | int arg_i; 35 | } fifoargs_t; 36 | 37 | typedef struct 38 | { 39 | int type; 40 | fifoargs_t arg[3]; 41 | } fifomsg_t; 42 | 43 | typedef struct 44 | { 45 | uint32 params; 46 | vramblock_t* vram; 47 | } gfx_t; 48 | 49 | #define BGMAIN_WIDTH 256 50 | #define BGMAIN_HEIGHT 192 51 | 52 | // 53 | // disable for debug/testing only 54 | // 55 | #define CHECKGFX_ABORT 56 | 57 | dboolean (I_CheckGFX)(char* file, int line); 58 | 59 | #ifdef CHECKGFX_ABORT 60 | #define I_CheckGFX() (I_CheckGFX) (__FILE__, __LINE__) 61 | #else 62 | #define I_CheckGFX() if(!(I_CheckGFX)(__FILE__, __LINE__)) return 63 | #endif 64 | 65 | extern byte bg_buffer[BGMAIN_WIDTH * BGMAIN_HEIGHT]; 66 | 67 | static inline void I_PlotSubBGPixel(int x, int y, int c) 68 | { 69 | bg_buffer[(y * BGMAIN_WIDTH) + x] = c; 70 | } 71 | 72 | #define FIFO_SEND_MSG(msg) fifoSendDatamsg(FIFO_USER_01, sizeof(msg), (u8*)&msg) 73 | 74 | static inline void I_SendDataToArm7(int type, void* data, int arg) 75 | { 76 | fifomsg_t send; 77 | 78 | send.type = type; 79 | send.arg[0].arg_p = data; 80 | send.arg[1].arg_i = arg; 81 | fifoSendDatamsg(FIFO_USER_01, sizeof(send), (u8*)&send); 82 | } 83 | 84 | byte* I_GetBackground(void); 85 | void I_RefreshBG(void); 86 | dboolean I_DmaBGBusy(void); 87 | uint32 I_SetPalette(uint16* data, int offset, int size); 88 | dboolean I_AllocVBlock(gfx_t* gfx, byte* data, int size, 89 | int flags, int texel_w, int texel_h, int type); 90 | 91 | const char* I_FilePath(const char* file); 92 | int I_ReadFile(char const* name, byte** buffer); 93 | long I_FileLength(FILE *handle); 94 | int I_FileExists(char *filename); 95 | 96 | static inline uint16_t I_Swap16(x) 97 | { 98 | return((x<<8)|(x>>8)); 99 | } 100 | 101 | static inline uint32_t I_Swap32(x) 102 | { 103 | return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24)); 104 | } 105 | 106 | void memcpy32(void *dst, const void *src, uint wdcount) ITCM_CODE; 107 | void memcpy16(void *dst, const void *src, uint wdcount) ITCM_CODE; 108 | 109 | #define SHORT(x) x 110 | #define LONG(x) x 111 | 112 | #define POLY_NEW_DEPTH (1 << 11) 113 | #define POLY_DEPTHTEST_EQUAL (1 << 14) 114 | #define COORD_PACK(u, v) ((((u) << 4) & 0xFFFF) | (((v) << 4) << 16)) 115 | 116 | #define GFX_MTX_STACK_LEVEL ((GFX_STATUS >> 8) & 0x1F) 117 | #define GFX_MTX_PROJ_STACK (1 << 13) 118 | #define GFX_MTX_BUSY (1 << 14) 119 | #define GFX_MTX_STACK_RESET (1 << 15) 120 | #define GFX_SIZE_S(x) (x << 20) 121 | #define GFX_SIZE_T(x) (x << 23) 122 | #define GFX_FORMAT(x) (x << 26) 123 | #define GFX_VRAM_OFFSET(x) (((uint32)x >> 3) & 0xFFFF) 124 | 125 | #define GFX_TEXTURE(f, w, h, fmt, offs) \ 126 | f | \ 127 | GFX_SIZE_S(w) | \ 128 | GFX_SIZE_T(h) | \ 129 | GFX_FORMAT(fmt) | \ 130 | GFX_VRAM_OFFSET(offs) 131 | 132 | #define GFX_ORTHO() \ 133 | MATRIX_CONTROL = GL_PROJECTION; \ 134 | MATRIX_IDENTITY = 0; \ 135 | MATRIX_CONTROL = GL_MODELVIEW; \ 136 | MATRIX_IDENTITY = 0; \ 137 | MATRIX_MULT4x4 = 0x20000; \ 138 | MATRIX_MULT4x4 = 0; \ 139 | MATRIX_MULT4x4 = 0; \ 140 | MATRIX_MULT4x4 = 0; \ 141 | MATRIX_MULT4x4 = 0; \ 142 | MATRIX_MULT4x4 = 0xFFFD5556; \ 143 | MATRIX_MULT4x4 = 0; \ 144 | MATRIX_MULT4x4 = 0; \ 145 | MATRIX_MULT4x4 = 0; \ 146 | MATRIX_MULT4x4 = 0; \ 147 | MATRIX_MULT4x4 = 0xFFFFF7FF; \ 148 | MATRIX_MULT4x4 = 0; \ 149 | MATRIX_MULT4x4 = 0xFFFFF000; \ 150 | MATRIX_MULT4x4 = 0x1000; \ 151 | MATRIX_MULT4x4 = 0xFFFFEFFF; \ 152 | MATRIX_MULT4x4 = 0x1000 153 | 154 | #define GFX_SCREENRECT() \ 155 | GFX_BEGIN = GL_QUADS; \ 156 | GFX_VERTEX16 = VERTEX_PACK(0, 0); \ 157 | GFX_VERTEX16 = VERTEX_PACK(-2, 0); \ 158 | GFX_VERTEX16 = VERTEX_PACK(SCREENWIDTH, 0); \ 159 | GFX_VERTEX16 = VERTEX_PACK(-2, 0); \ 160 | GFX_VERTEX16 = VERTEX_PACK(SCREENWIDTH, SCREENHEIGHT); \ 161 | GFX_VERTEX16 = VERTEX_PACK(-2, 0); \ 162 | GFX_VERTEX16 = VERTEX_PACK(0, SCREENHEIGHT); \ 163 | GFX_VERTEX16 = VERTEX_PACK(-2, 0) 164 | 165 | #endif // __DS_MAIN__ -------------------------------------------------------------------------------- /arm9/source/g_game.h: -------------------------------------------------------------------------------- 1 | #ifndef __G_GAME__ 2 | #define __G_GAME__ 3 | 4 | #include "doomdef.h" 5 | #include "d_main.h" 6 | 7 | extern dboolean sendpause; 8 | extern int buttons; 9 | 10 | // 11 | // GAME 12 | // 13 | 14 | void G_InitNew(skill_t skill, int map); 15 | void G_DeferedInitNew(skill_t skill, int map); 16 | void G_PlayDemo(const char* name); 17 | void G_CompleteLevel(void); 18 | void G_ExitLevel(void); 19 | void G_SecretExitLevel(int map); 20 | void G_Ticker(void); 21 | void G_ScreenShot(void); 22 | void G_RunTitleMap(void); 23 | void G_RunGame(void); 24 | void G_BuildTiccmd(ticcmd_t* cmd); 25 | 26 | dboolean G_CheckDemoStatus(void); 27 | dboolean G_Responder(event_t* ev); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /arm9/source/m_fixed.c: -------------------------------------------------------------------------------- 1 | #include "stdlib.h" 2 | #include "ds.h" 3 | #include "doomtype.h" 4 | #include "doomdef.h" 5 | #include "m_fixed.h" 6 | #include "d_main.h" 7 | 8 | // Fixme. __USE_C_FIXED__ or something. 9 | 10 | #if 0 11 | 12 | fixed_t 13 | FixedMul 14 | ( fixed_t a, 15 | fixed_t b ) 16 | { 17 | #ifdef USE_ASM 18 | fixed_t c; 19 | _asm 20 | { 21 | mov eax, [a] 22 | mov ecx, [b] 23 | imul ecx 24 | shr eax, 16 25 | shl edx, 16 26 | or eax, edx 27 | mov [c], eax 28 | } 29 | return(c); 30 | #else 31 | return (fixed_t)(((int64) a * (int64) b) >> FRACBITS); 32 | #endif 33 | } 34 | 35 | 36 | 37 | // 38 | // FixedDiv, C version. 39 | // 40 | 41 | fixed_t 42 | FixedDiv 43 | ( fixed_t a, 44 | fixed_t b ) 45 | { 46 | if ( (D_abs(a)>>14) >= D_abs(b)) 47 | return (a^b)<0 ? MININT : MAXINT; 48 | return FixedDiv2 (a,b); 49 | 50 | } 51 | 52 | 53 | 54 | fixed_t 55 | FixedDiv2 56 | ( fixed_t a, 57 | fixed_t b ) 58 | { 59 | return (fixed_t)((((int64)a)<>FRACBITS) 12 | #define F2D3D(x) (((float)(x))/FRACUNIT) 13 | #define F2DSFIXED(x) ((x)>>14) 14 | #define INT2DSFIXED(x) ((x)<<2) 15 | 16 | typedef int fixed_t; 17 | 18 | fixed_t FixedMul (fixed_t a, fixed_t b); 19 | fixed_t FixedDiv (fixed_t a, fixed_t b); 20 | fixed_t FixedDiv2 (fixed_t a, fixed_t b); 21 | 22 | static inline fixed_t FixedDot(fixed_t a1, fixed_t b1, 23 | fixed_t c1, fixed_t a2, 24 | fixed_t b2, fixed_t c2) 25 | { 26 | return 27 | FixedMul(a1, a2) + 28 | FixedMul(b1, b2) + 29 | FixedMul(c1, c2); 30 | } 31 | 32 | #endif -------------------------------------------------------------------------------- /arm9/source/p_ceilng.c: -------------------------------------------------------------------------------- 1 | #include "z_zone.h" 2 | #include "doomdef.h" 3 | #include "p_local.h" 4 | #include "p_spec.h" 5 | #include "s_sound.h" 6 | #include "sounds.h" 7 | #include "r_local.h" 8 | #include "d_main.h" 9 | 10 | // 11 | // CEILINGS 12 | // 13 | 14 | 15 | ceiling_t* activeceilings[MAXCEILINGS]; 16 | 17 | 18 | // 19 | // T_MoveCeiling 20 | // 21 | 22 | void T_MoveCeiling (ceiling_t* ceiling) 23 | { 24 | result_e res; 25 | 26 | switch(ceiling->direction) 27 | { 28 | case 0: 29 | // IN STASIS 30 | break; 31 | case 1: 32 | // UP 33 | res = T_MovePlane(ceiling->sector, ceiling->speed, 34 | ceiling->topheight, false,1,ceiling->direction); 35 | 36 | if(!ceiling->instant) 37 | { 38 | if(!(leveltime & 7)) 39 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_secmove); 40 | } 41 | 42 | if(res == pastdest) 43 | { 44 | switch(ceiling->type) 45 | { 46 | case lowerToFloor: 47 | case customCeiling: 48 | case crushAndRaiseOnce: 49 | case customCeilingToHeight: 50 | P_RemoveActiveCeiling(ceiling); 51 | break; 52 | case lowerAndCrush: 53 | case crushAndRaise: 54 | case silentCrushAndRaise: 55 | case fastCrushAndRaise: 56 | ceiling->direction = -1; 57 | break; 58 | default: 59 | break; 60 | } 61 | } 62 | break; 63 | case -1: 64 | // DOWN 65 | res = T_MovePlane(ceiling->sector, ceiling->speed, 66 | ceiling->bottomheight, ceiling->crush, 1, ceiling->direction); 67 | 68 | if(!ceiling->instant) 69 | { 70 | if(!(leveltime & 7)) 71 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_secmove); 72 | } 73 | 74 | if(res == pastdest) 75 | { 76 | switch(ceiling->type) 77 | { 78 | case crushAndRaise: 79 | case silentCrushAndRaise: 80 | ceiling->speed = CEILSPEED; 81 | case fastCrushAndRaise: 82 | case crushAndRaiseOnce: 83 | ceiling->direction = 1; 84 | break; 85 | case lowerToFloor: 86 | case lowerAndCrush: 87 | case customCeiling: 88 | case customCeilingToHeight: 89 | P_RemoveActiveCeiling(ceiling); 90 | break; 91 | default: 92 | break; 93 | } 94 | } 95 | else 96 | { 97 | if(res == crushed) 98 | { 99 | if(ceiling->type == lowerAndCrush || ceiling->type == crushAndRaise) 100 | ceiling->speed = CEILSPEED / 8; 101 | } 102 | } 103 | break; 104 | } 105 | } 106 | 107 | 108 | // 109 | // EV_DoCeiling 110 | // Move a ceiling up/down and all around! 111 | // 112 | 113 | int EV_DoCeiling(line_t* line, ceiling_e type, fixed_t speed) 114 | { 115 | int secnum; 116 | int rtn; 117 | sector_t* sec; 118 | ceiling_t* ceiling; 119 | 120 | secnum = -1; 121 | rtn = 0; 122 | 123 | // Reactivate in-stasis ceilings...for certain types. 124 | switch(type) 125 | { 126 | case crushAndRaise: 127 | case fastCrushAndRaise: 128 | case silentCrushAndRaise: 129 | P_ActivateInStasisCeiling(line); 130 | default: 131 | break; 132 | } 133 | 134 | while((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) 135 | { 136 | sec = §ors[secnum]; 137 | if (sec->specialdata) 138 | continue; 139 | 140 | // new door thinker 141 | rtn = 1; 142 | ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0); 143 | P_AddThinker (&ceiling->thinker); 144 | sec->specialdata = ceiling; 145 | // Midway assumed that ceiling->instant is true only if the 146 | // speed is equal to 2048*FRACUNIT, which doesn't seem very sufficient 147 | ceiling->instant = (speed >= (CEILSPEED * 1024)); 148 | ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; 149 | ceiling->sector = sec; 150 | ceiling->crush = false; 151 | 152 | switch(type) 153 | { 154 | case silentCrushAndRaise: 155 | ceiling->instant = true; 156 | case fastCrushAndRaise: 157 | case crushAndRaiseOnce: 158 | ceiling->crush = true; 159 | ceiling->topheight = sec->ceilingheight; 160 | ceiling->bottomheight = sec->floorheight + (8*FRACUNIT); 161 | ceiling->direction = -1; 162 | ceiling->speed = speed; 163 | break; 164 | 165 | case crushAndRaise: 166 | ceiling->crush = true; 167 | ceiling->topheight = sec->ceilingheight; 168 | case lowerAndCrush: 169 | case lowerToFloor: 170 | ceiling->bottomheight = sec->floorheight; 171 | if(type != lowerToFloor) 172 | ceiling->bottomheight += 8*FRACUNIT; 173 | ceiling->direction = -1; 174 | ceiling->speed = speed; 175 | break; 176 | 177 | case raiseToHighest: 178 | ceiling->topheight = P_FindHighestCeilingSurrounding(sec); 179 | ceiling->direction = 1; 180 | ceiling->speed = speed; 181 | break; 182 | 183 | case customCeiling: 184 | ceiling->speed = speed; 185 | if(globalint >= 0) 186 | { 187 | ceiling->direction = 1; 188 | ceiling->topheight = ceiling->sector->ceilingheight + (globalint * FRACUNIT); 189 | } 190 | else 191 | { 192 | ceiling->direction = -1; 193 | ceiling->bottomheight = ceiling->sector->ceilingheight + (globalint * FRACUNIT); 194 | } 195 | break; 196 | 197 | case customCeilingToHeight: 198 | ceiling->speed = speed; 199 | if((globalint * FRACUNIT) < ceiling->sector->ceilingheight) 200 | { 201 | ceiling->bottomheight = (globalint * FRACUNIT); 202 | ceiling->direction = -1; 203 | } 204 | else 205 | { 206 | ceiling->topheight = (globalint * FRACUNIT); 207 | ceiling->direction = 1; 208 | } 209 | break; 210 | 211 | } 212 | 213 | ceiling->tag = sec->tag; 214 | ceiling->type = type; 215 | P_AddActiveCeiling(ceiling); 216 | } 217 | return rtn; 218 | } 219 | 220 | 221 | // 222 | // P_AddActiveCeiling 223 | // Add an active ceiling 224 | // 225 | 226 | void P_AddActiveCeiling(ceiling_t* c) 227 | { 228 | int i; 229 | 230 | for(i = 0; i < MAXCEILINGS; i++) 231 | { 232 | if(activeceilings[i] == NULL) 233 | { 234 | activeceilings[i] = c; 235 | return; 236 | } 237 | } 238 | 239 | // [d64] added error message 240 | I_Error("P_AddActiveCeiling: no more ceiling slots"); 241 | } 242 | 243 | 244 | 245 | // 246 | // P_RemoveActiveCeiling 247 | // Remove a ceiling's thinker 248 | // 249 | 250 | void P_RemoveActiveCeiling(ceiling_t* c) 251 | { 252 | int i; 253 | 254 | for(i = 0; i < MAXCEILINGS; i++) 255 | { 256 | if(activeceilings[i] == c) 257 | { 258 | activeceilings[i]->sector->specialdata = NULL; 259 | P_RemoveThinker (&activeceilings[i]->thinker); 260 | activeceilings[i] = NULL; 261 | return; 262 | } 263 | } 264 | 265 | // [d64] added error message 266 | I_Error("P_RemoveActiveCeiling: ceiling not found"); 267 | } 268 | 269 | 270 | 271 | // 272 | // P_ActivateInStasisCeiling 273 | // Restart a ceiling that's in-stasis 274 | // 275 | 276 | void P_ActivateInStasisCeiling(line_t* line) 277 | { 278 | int i; 279 | for(i = 0; i < MAXCEILINGS; i++) 280 | { 281 | if(activeceilings[i] && (activeceilings[i]->tag == line->tag) 282 | && (activeceilings[i]->direction == 0)) 283 | { 284 | activeceilings[i]->direction = activeceilings[i]->olddirection; 285 | activeceilings[i]->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; 286 | } 287 | } 288 | } 289 | 290 | 291 | 292 | // 293 | // EV_CeilingCrushStop 294 | // Stop a ceiling from crushing! 295 | // 296 | 297 | int EV_CeilingCrushStop(line_t* line) 298 | { 299 | int i; 300 | int rtn; 301 | 302 | rtn = 0; 303 | for (i = 0; i < MAXCEILINGS; i++) 304 | { 305 | if(activeceilings[i] && (activeceilings[i]->tag == line->tag) 306 | && (activeceilings[i]->direction != 0)) 307 | { 308 | activeceilings[i]->olddirection = activeceilings[i]->direction; 309 | activeceilings[i]->thinker.function.acv = (actionf_v)NULL; 310 | activeceilings[i]->direction = 0; // in-stasis 311 | rtn = 1; 312 | } 313 | } 314 | 315 | return rtn; 316 | } 317 | -------------------------------------------------------------------------------- /arm9/source/p_macros.c: -------------------------------------------------------------------------------- 1 | #include "z_zone.h" 2 | #include "doomdef.h" 3 | #include "p_local.h" 4 | #include "p_spec.h" 5 | #include "r_local.h" 6 | #include "d_main.h" 7 | 8 | thinker_t *macrothinker = NULL; 9 | macrodef_t *macro = NULL; 10 | macrodata_t *nextmacro = NULL; 11 | mobj_t *mobjmacro = NULL; 12 | short macrocounter = -1; 13 | short macroid = -1; 14 | 15 | int taglist[MAXQUEUELIST]; 16 | int taglistidx = 0; 17 | 18 | static dboolean bTriggerOnce = false; 19 | 20 | // 21 | // P_QueueSpecial 22 | // 23 | 24 | void P_QueueSpecial(mobj_t* mobj) 25 | { 26 | if(!P_ActivateLineByTag(mobj->tid, mobj)) 27 | { 28 | taglist[taglistidx] = mobj->tid; 29 | taglistidx = (taglistidx + 1) & (MAXQUEUELIST - 1); 30 | } 31 | } 32 | 33 | // 34 | // P_RestartMacro 35 | // 36 | 37 | void P_RestartMacro(int id) 38 | { 39 | macrodata_t *m; 40 | 41 | m = macro->data; 42 | 43 | for(; m != ¯o->data[macro->count]; m++) 44 | { 45 | if(m->id == id) 46 | { 47 | nextmacro = m; 48 | return; 49 | } 50 | } 51 | } 52 | 53 | // 54 | // P_InitMacroCounter 55 | // 56 | 57 | int P_InitMacroCounter(int counts) 58 | { 59 | if(macrocounter == -1) 60 | macrocounter = counts; 61 | else 62 | { 63 | if(macrocounter-- > 0) 64 | P_RestartMacro(globalint); 65 | else 66 | macrocounter = 0; 67 | } 68 | 69 | return -1; 70 | } 71 | 72 | // 73 | // P_MacroDetachThinker 74 | // 75 | 76 | void P_MacroDetachThinker(thinker_t* thinker) 77 | { 78 | if(thinker == macrothinker) 79 | macrothinker = NULL; 80 | } 81 | 82 | // 83 | // P_ToggleMacros 84 | // 85 | // Enable/disable a macro by setting its first ID to a negative value 86 | // The purpose for this function remains a mystery but it has 87 | // something to do with the elusive easter egg found in Breakdown. 88 | // 89 | 90 | void P_ToggleMacros(int tag, dboolean toggleon) 91 | { 92 | macrodef_t* macro = ¯os.def[MACROMASK(tag)]; 93 | 94 | if(toggleon) 95 | { 96 | if(macro->data[0].id >= 0) 97 | return; 98 | } 99 | else 100 | { 101 | if(macro->data[0].id <= 0) 102 | return; 103 | } 104 | 105 | macro->data[0].id = !macro->data[0].id; 106 | } 107 | 108 | // 109 | // P_InitMacroVars 110 | // 111 | 112 | void P_InitMacroVars(void) 113 | { 114 | macro = NULL; 115 | macrothinker = NULL; 116 | nextmacro = NULL; 117 | mobjmacro = NULL; 118 | macroid = -1; 119 | macrocounter = -1; 120 | 121 | bTriggerOnce = false; 122 | } 123 | 124 | // 125 | // P_StartMacro 126 | // 127 | 128 | int P_StartMacro(mobj_t* thing, line_t* line) 129 | { 130 | if(macro) 131 | return 0; 132 | 133 | macro = ¯os.def[MACROMASK(line->special)]; 134 | 135 | if(macro->data[0].id <= 0) 136 | { 137 | if(macro->data[0].id == 0) 138 | line->special = 0; 139 | 140 | P_InitMacroVars(); 141 | 142 | return 0; 143 | } 144 | 145 | // true if line can only be triggered once 146 | if(!(line->special & MLU_REPEAT)) 147 | bTriggerOnce = true; 148 | else 149 | bTriggerOnce = false; 150 | 151 | macroid = MACROMASK(line->special); 152 | nextmacro = NULL; 153 | if(thing->flags & MF_SPECIAL) 154 | mobjmacro = players[0].mo; 155 | else 156 | mobjmacro = thing; 157 | macrocounter = -1; 158 | 159 | return 1; 160 | } 161 | 162 | // 163 | // P_SuspendMacro 164 | // 165 | 166 | int P_SuspendMacro(int tag) 167 | { 168 | int id = MACROMASK(tag); // not used? 169 | 170 | if(id < 0) 171 | return 0; 172 | 173 | if(!macro) 174 | return 0; 175 | 176 | if(!macrothinker) 177 | return 0; 178 | 179 | P_RemoveThinker(macrothinker); 180 | P_InitMacroVars(); 181 | 182 | return 1; 183 | } 184 | 185 | // 186 | // P_RunMacros 187 | // 188 | // Process behind this is to trigger all specials in a batch and then 189 | // wait until all thinkers are done before starting the next batch. 190 | // 191 | // This is runned at every P_Tick 192 | // 193 | 194 | void P_RunMacros(void) 195 | { 196 | int currentID = 0; 197 | macrodata_t* m; 198 | thinker_t* thinker; 199 | line_t l; 200 | 201 | if(!macro) 202 | { 203 | for(currentID = 0; currentID < MAXQUEUELIST; currentID++) 204 | { 205 | if(taglist[currentID]) 206 | { 207 | P_ActivateLineByTag(taglist[currentID], players[0].mo); 208 | taglist[currentID] = 0; 209 | return; 210 | } 211 | } 212 | return; 213 | } 214 | 215 | if(macrothinker) 216 | return; 217 | 218 | if(!nextmacro) 219 | m = macro->data; 220 | else 221 | m = nextmacro; 222 | 223 | thinker = NULL; 224 | 225 | for(currentID = m->id; m != ¯o->data[macro->count]; m++) 226 | { 227 | if(m->id != currentID) 228 | break; // end of batch 229 | 230 | if(m->special == 0) 231 | continue; 232 | 233 | l.special = m->special; 234 | l.tag = m->tag; 235 | 236 | thinker = thinkercap.prev; 237 | 238 | if(P_DoSpecialLine(mobjmacro, &l, 0) == -1 && macrocounter) 239 | return; 240 | 241 | // Look for any new thinkers that need to be watched 242 | if(thinker != thinkercap.prev) 243 | thinker = thinkercap.prev; 244 | else 245 | thinker = NULL; 246 | } 247 | 248 | nextmacro = m; 249 | macrothinker = thinker; 250 | 251 | if(m == ¯o->data[macro->count]) 252 | { 253 | if(bTriggerOnce) 254 | macro->data[0].id = 0; 255 | 256 | P_InitMacroVars(); // End of macro. Reset vars 257 | } 258 | } 259 | 260 | -------------------------------------------------------------------------------- /arm9/source/p_pspr.h: -------------------------------------------------------------------------------- 1 | #ifndef __P_PSPR__ 2 | #define __P_PSPR__ 3 | 4 | #include "doomdef.h" 5 | #include "tables.h" 6 | #include "info.h" 7 | #include "m_fixed.h" 8 | 9 | // 10 | // Frame flags: 11 | // handles maximum brightness (torches, muzzle flare, light sources) 12 | // 13 | 14 | #define FF_FULLBRIGHT 0x8000 // flag in thing->frame 15 | #define FF_FRAMEMASK 0x7fff 16 | 17 | 18 | 19 | // 20 | // Overlay psprites are scaled shapes 21 | // drawn directly on the view screen, 22 | // coordinates are given for a 320*200 view screen. 23 | // 24 | typedef enum 25 | { 26 | ps_weapon, 27 | ps_flash, 28 | NUMPSPRITES 29 | 30 | } psprnum_t; 31 | 32 | typedef struct 33 | { 34 | state_t* state; // a NULL state means not active 35 | int tics; 36 | fixed_t sx; 37 | fixed_t sy; 38 | int alpha; // [d64] for rendering 39 | } pspdef_t; 40 | 41 | typedef struct 42 | { 43 | ammotype_t ammo; 44 | int upstate; 45 | int downstate; 46 | int readystate; 47 | int atkstate; 48 | int flashstate; 49 | } weaponinfo_t; 50 | 51 | // Weapon info: sprite frames, ammunition use. 52 | extern weaponinfo_t weaponinfo[NUMWEAPONS]; 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /arm9/source/p_telept.c: -------------------------------------------------------------------------------- 1 | #include "doomdef.h" 2 | #include "s_sound.h" 3 | #include "p_local.h" 4 | #include "sounds.h" 5 | #include "tables.h" 6 | #include "d_main.h" 7 | #include "r_local.h" 8 | 9 | 10 | // 11 | // TELEPORTATION 12 | // 13 | 14 | // 15 | // P_Telefrag 16 | // 17 | 18 | static void P_Telefrag(mobj_t *thing, fixed_t x, fixed_t y) 19 | { 20 | int delta; 21 | int size; 22 | mobj_t* m; 23 | 24 | for(m = mobjhead.next; m != &mobjhead; m = m->next) 25 | { 26 | if(!(m->flags & MF_SHOOTABLE)) 27 | continue; 28 | 29 | size = m->radius + thing->radius + 4*FRACUNIT; 30 | 31 | delta = m->x - x; 32 | if(delta < -size || delta > size) 33 | continue; 34 | 35 | delta = m->y - y; 36 | if(delta < -size || delta > size) 37 | continue; 38 | 39 | P_DamageMobj(m, thing, thing, 10000); 40 | m->flags &= ~(MF_SOLID|MF_SHOOTABLE); 41 | } 42 | } 43 | 44 | // 45 | // EV_Teleport 46 | // 47 | 48 | int EV_Teleport(line_t* line, int side, mobj_t* thing) 49 | { 50 | int tag; 51 | mobj_t* m; 52 | mobj_t* fog; 53 | angle_t an; 54 | fixed_t oldx; 55 | fixed_t oldy; 56 | fixed_t oldz; 57 | 58 | // don't teleport missiles 59 | if(thing->flags & MF_MISSILE) 60 | return 0; 61 | 62 | // Don't teleport if hit back of line, so you can get out of teleporter. 63 | if(side == 1) 64 | return 0; 65 | 66 | tag = line->tag; 67 | for(m = mobjhead.next; m != &mobjhead; m = m->next) 68 | { 69 | // not a teleportman 70 | if(m->type != MT_DEST_TELEPORT) 71 | continue; 72 | 73 | // not matching the tid 74 | if(m->tid != tag) 75 | continue; 76 | 77 | // no use teleporting if the thing has no room 78 | if(m->ceilingz - m->floorz < m->height) 79 | continue; 80 | 81 | oldx = thing->x; 82 | oldy = thing->y; 83 | oldz = thing->z + (thing->height >> 1); 84 | 85 | if(thing->player) 86 | P_Telefrag(thing, m->x, m->y); 87 | 88 | if(!P_TeleportMove(thing, m->x, m->y)) 89 | return 0; 90 | 91 | thing->z = thing->floorz; 92 | 93 | if(thing->player) 94 | thing->player->viewz = thing->z + thing->player->viewheight; 95 | 96 | // spawn teleport fog at source and destination 97 | fog = P_SpawnMobj(oldx, oldy, oldz, MT_TELEPORTFOG); 98 | 99 | S_StartSound(fog, sfx_telept); 100 | 101 | an = m->angle >> ANGLETOFINESHIFT; 102 | fog = P_SpawnMobj(m->x + 20 * finecosine[an], m->y + 20 * finesine[an], 103 | thing->z + (thing->height >> 1), MT_TELEPORTFOG); 104 | 105 | // emit sound, where? 106 | S_StartSound(fog, sfx_telept); 107 | 108 | // don't move for a bit 109 | if(thing->player) 110 | thing->reactiontime = 9; // [d64] changed to 9 111 | 112 | thing->angle = m->angle; 113 | thing->momx = thing->momy = thing->momz = 0; 114 | 115 | return 1; 116 | } 117 | 118 | return 0; 119 | } 120 | 121 | // 122 | // EV_SilentTeleport 123 | // 124 | 125 | int EV_SilentTeleport(line_t* line, mobj_t* thing) 126 | { 127 | int tag; 128 | mobj_t* m; 129 | 130 | tag = line->tag; 131 | for(m = mobjhead.next; m != &mobjhead; m = m->next) 132 | { 133 | // not a teleportman 134 | if(m->type != MT_DEST_TELEPORT) 135 | continue; 136 | 137 | // not matching the tid 138 | if(m->tid != tag) 139 | continue; 140 | 141 | if(thing->player) 142 | P_Telefrag(thing, m->x, m->y); 143 | 144 | // don't bother checking for position, just move it 145 | P_TeleportMove(thing, m->x, m->y); 146 | 147 | if(thing->player) 148 | thing->player->viewz = thing->z + thing->player->viewheight; 149 | 150 | thing->angle = m->angle; 151 | thing->z = m->z; 152 | thing->momx = thing->momy = thing->momz = 0; 153 | 154 | return 1; 155 | } 156 | 157 | return 0; 158 | } 159 | 160 | -------------------------------------------------------------------------------- /arm9/source/p_tick.c: -------------------------------------------------------------------------------- 1 | #include "doomdef.h" 2 | #include "z_zone.h" 3 | #include "p_local.h" 4 | #include "d_main.h" 5 | #include "s_sound.h" 6 | #include "p_spec.h" 7 | #include "r_local.h" 8 | #include "st_main.h" 9 | 10 | void G_PlayerFinishLevel(int player); 11 | void G_DoReborn(int playernum); 12 | 13 | // 14 | // THINKERS 15 | // 16 | // All thinkers should be allocated by Z_Malloc 17 | // so they can be operated on uniformly. 18 | // The actual structures will vary in size, 19 | // but the first element must be thinker_t. 20 | // 21 | // Mobjs are now kept seperate for more optimal 22 | // list processing. 23 | // 24 | 25 | thinker_t thinkercap; // Both the head and tail of the thinker list. 26 | mobj_t mobjhead; // Both the head and tail of the mobj list. 27 | mobj_t *currentmobj; 28 | thinker_t *currentthinker; 29 | 30 | 31 | // 32 | // P_InitThinkers 33 | // 34 | 35 | void P_InitThinkers(void) 36 | { 37 | thinkercap.prev = thinkercap.next = &thinkercap; 38 | mobjhead.next = mobjhead.prev = &mobjhead; 39 | } 40 | 41 | // 42 | // P_AddThinker 43 | // Adds a new thinker at the end of the list. 44 | // 45 | 46 | void P_AddThinker(thinker_t* thinker) 47 | { 48 | thinkercap.prev->next = thinker; 49 | thinker->next = &thinkercap; 50 | thinker->prev = thinkercap.prev; 51 | thinkercap.prev = thinker; 52 | } 53 | 54 | // 55 | // P_UnlinkThinker 56 | // 57 | 58 | static void P_UnlinkThinker(thinker_t* thinker) 59 | { 60 | thinker_t* next = currentthinker->next; 61 | (next->prev = currentthinker = thinker->prev)->next = next; 62 | 63 | Z_Free(thinker); 64 | } 65 | 66 | // 67 | // P_RemoveThinker 68 | // Deallocation is lazy -- it will not actually be freed 69 | // until its thinking turn comes up. 70 | // 71 | 72 | void P_RemoveThinker(thinker_t* thinker) 73 | { 74 | thinker->function.acp1 = (actionf_p1)P_UnlinkThinker; 75 | P_MacroDetachThinker(thinker); 76 | } 77 | 78 | // 79 | // P_LinkMobj 80 | // 81 | 82 | void P_LinkMobj(mobj_t* mobj) 83 | { 84 | mobjhead.prev->next = mobj; 85 | mobj->next = &mobjhead; 86 | mobj->prev = mobjhead.prev; 87 | mobjhead.prev = mobj; 88 | } 89 | 90 | // 91 | // P_UnlinkMobj 92 | // 93 | 94 | void P_UnlinkMobj(mobj_t* mobj) 95 | { 96 | /* Remove from main mobj list */ 97 | mobj_t* next = currentmobj->next; 98 | 99 | /* Note that currentmobj is guaranteed to point to us, 100 | * and since we're freeing our memory, we had better change that. So 101 | * point it to mobj->prev, so the iterator will correctly move on to 102 | * mobj->prev->next = mobj->next */ 103 | (next->prev = currentmobj = mobj->prev)->next = next; 104 | } 105 | 106 | // 107 | // P_RunMobjs 108 | // 109 | 110 | void P_RunMobjs(void) 111 | { 112 | for(currentmobj = mobjhead.next; currentmobj != &mobjhead; currentmobj = currentmobj->next) 113 | { 114 | // Special case only 115 | if(currentmobj->flags & MF_NOSECTOR) 116 | continue; 117 | 118 | if(!currentmobj->player) 119 | { 120 | // [kex] don't bother if about to be removed 121 | if(currentmobj->mobjfunc != P_SafeRemoveMobj) 122 | { 123 | // [kex] don't clear callback if mobj is going to be respawning 124 | if(currentmobj->mobjfunc != P_RespawnSpecials) 125 | currentmobj->mobjfunc = NULL; 126 | 127 | if(lockmonsters && currentmobj->flags & MF_COUNTKILL) 128 | continue; 129 | 130 | P_MobjThinker(currentmobj); 131 | } 132 | 133 | if(currentmobj->mobjfunc) 134 | currentmobj->mobjfunc(currentmobj); 135 | } 136 | } 137 | } 138 | 139 | // 140 | // P_RunThinkers 141 | // 142 | 143 | void P_RunThinkers(void) 144 | { 145 | for(currentthinker = thinkercap.next; 146 | currentthinker != &thinkercap; 147 | currentthinker = currentthinker->next) 148 | { 149 | if(currentthinker->function.acp1) 150 | currentthinker->function.acp1(currentthinker); 151 | } 152 | } 153 | 154 | // 155 | // P_Start 156 | // 157 | 158 | void P_Start(void) 159 | { 160 | int i; 161 | mapdef_t* map; 162 | 163 | map = P_GetMapInfo(gamemap); 164 | 165 | for(i = 0; i < MAXPLAYERS; i++) 166 | { 167 | // players can't be hurt on title map 168 | if(map->forcegodmode) 169 | players[i].cheats |= CF_GODMODE; 170 | // turn off godmode on hectic map 171 | else if(map->clearchts) 172 | players[i].cheats &= ~CF_GODMODE; 173 | else 174 | break; 175 | } 176 | 177 | // turn off/clear some things 178 | AM_Stop(); 179 | AM_Start(); 180 | M_ClearRandom(); 181 | 182 | // do a nice little fade in effect 183 | //P_FadeInBrightness(); // TODO 184 | 185 | // autoactivate line specials 186 | P_ActivateLineByTag(999, players[0].mo); 187 | 188 | // enable menu and set gamestate 189 | //allowmenu = true; // TODO 190 | gamestate = GS_LEVEL; 191 | 192 | S_StartMusic(map->music); 193 | } 194 | 195 | // 196 | // P_Stop 197 | // 198 | 199 | void P_Stop(void) 200 | { 201 | int i = 0; 202 | int action = gameaction; 203 | 204 | // 205 | // [d64] stop plasma buzz 206 | // 207 | S_StopSound(NULL, sfx_electric); 208 | 209 | for(i = 0; i < MAXPLAYERS; i++) 210 | { 211 | // take away cards and stuff 212 | if(playeringame[i]) 213 | G_PlayerFinishLevel(i); 214 | } 215 | 216 | // TODO 217 | /* 218 | // [kex] reset damage indicators 219 | if(p_damageindicator.value) 220 | ST_ClearDamageMarkers();*/ 221 | 222 | // free level tags 223 | Z_FreeTags(PU_AUDIO, PU_PURGELEVEL); 224 | 225 | // TODO 226 | if(automapactive) 227 | AM_Stop(); 228 | 229 | // music continues on exit if defined 230 | if(!P_GetMapInfo(gamemap)->contmusexit) 231 | S_StopMusic(); 232 | 233 | if(demoplayback) 234 | demoplayback = false; 235 | 236 | // TODO 237 | /* 238 | // do wipe/melt effect 239 | if(gameaction != ga_loadgame) 240 | { 241 | if(gameaction != ga_warpquick) 242 | WIPE_MeltScreen(); 243 | else 244 | { 245 | S_StopMusic(); 246 | WIPE_FadeScreen(8); 247 | } 248 | }*/ 249 | 250 | S_ResetSound(); 251 | 252 | gamestate = GS_NONE; 253 | gameaction = action; 254 | } 255 | 256 | // 257 | // P_Drawer 258 | // 259 | 260 | void P_Drawer(void) 261 | { 262 | // [kex] don't draw on first tic 263 | if(!leveltime) 264 | return; 265 | 266 | if(!I_DmaBGBusy() && automapactive) 267 | AM_Drawer(); 268 | 269 | R_DrawFrame(); 270 | ST_Drawer(); 271 | 272 | if(automapactive) 273 | I_RefreshBG(); 274 | } 275 | 276 | // 277 | // P_Ticker 278 | // 279 | 280 | extern int ptic; 281 | 282 | int P_Ticker(void) 283 | { 284 | int i; 285 | 286 | if(paused) 287 | return 0; 288 | 289 | // pause if in menu and at least one tic has been run 290 | if(!netgame && menuactive && 291 | !demoplayback && players[consoleplayer].viewz != 1) 292 | return 0; 293 | 294 | for(i = 0; i < MAXPLAYERS; i++) 295 | { 296 | if(playeringame[i]) 297 | { 298 | // do player reborns if needed 299 | if(players[i].playerstate == PST_REBORN) 300 | G_DoReborn(i); 301 | 302 | P_PlayerThink(&players[i]); 303 | } 304 | } 305 | 306 | if(devparm) 307 | cpuStartTiming(2); 308 | 309 | P_RunThinkers(); 310 | P_ScanSights(); 311 | P_RunMobjs(); 312 | P_UpdateSpecials(); 313 | P_RunMacros(); 314 | 315 | ST_Ticker(); 316 | AM_Ticker(); 317 | 318 | if(devparm) 319 | ptic = timerTicks2msec(cpuEndTiming()); 320 | 321 | // for par times 322 | leveltime++; 323 | 324 | return gameaction; 325 | } 326 | 327 | -------------------------------------------------------------------------------- /arm9/source/r_lights.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "r_local.h" 4 | #include "p_local.h" 5 | #include "d_main.h" 6 | 7 | // 8 | // R_LightGetHSV 9 | // Set HSV values based on given RGB 10 | // 11 | 12 | void R_LightGetHSV(int r, int g, int b, int *h, int *s, int *v) 13 | { 14 | int min = r; 15 | int max = r; 16 | float delta = 0.0f; 17 | float j = 0.0f; 18 | float x = 0.0f; 19 | float xr = 0.0f; 20 | float xg = 0.0f; 21 | float xb = 0.0f; 22 | float sum = 0.0f; 23 | 24 | if(g < min) min = g; 25 | if(b < min) min = b; 26 | 27 | if(g > max) max = g; 28 | if(b > max) max = b; 29 | 30 | delta = ((float)max / 255.0f); 31 | 32 | if(dfcmp(delta, 0.0f)) 33 | delta = 0; 34 | else 35 | { 36 | j = ((delta - ((float)min / 255.0f)) / delta); 37 | } 38 | 39 | if(!dfcmp(j, 0.0f)) 40 | { 41 | xr = ((float)r / 255.0f); 42 | 43 | if(!dfcmp(xr, delta)) 44 | { 45 | xg = ((float)g / 255.0f); 46 | 47 | if(!dfcmp(xg, delta)) 48 | { 49 | xb = ((float)b / 255.0f); 50 | 51 | if(dfcmp(xb, delta)) 52 | { 53 | sum = ((((delta - xg) / (delta - (min / 255.0f))) + 4.0f) - 54 | ((delta - xr) / (delta - (min / 255.0f)))); 55 | } 56 | } 57 | else 58 | { 59 | sum = ((((delta - xr) / (delta - (min / 255.0f))) + 2.0f) - 60 | ((delta - (b / 255.0f)) /(delta - (min / 255.0f)))); 61 | } 62 | } 63 | else 64 | { 65 | sum = (((delta - (b / 255.0f))) / (delta - (min / 255.0f))) - 66 | ((delta - (g / 255.0f)) / (delta - (min / 255.0f))); 67 | } 68 | 69 | x = (sum * 60.0f); 70 | 71 | if(x < 0) 72 | x += 360.0f; 73 | } 74 | else 75 | j = 0.0f; 76 | 77 | *h = (int)((x / 360.0f) * 255.0f); 78 | *s = (int)(j * 255.0f); 79 | *v = (int)(delta * 255.0f); 80 | } 81 | 82 | // 83 | // R_LightGetRGB 84 | // Set RGB values based on given HSV 85 | // 86 | 87 | void R_LightGetRGB(int h, int s, int v, int *r, int *g, int *b) 88 | { 89 | float x = 0.0f; 90 | float j = 0.0f; 91 | float i = 0.0f; 92 | int table = 0; 93 | float xr = 0.0f; 94 | float xg = 0.0f; 95 | float xb = 0.0f; 96 | 97 | j = (h / 255.0f) * 360.0f; 98 | 99 | if(360.0f <= j) 100 | j -= 360.0f; 101 | 102 | x = (s / 255.0f); 103 | i = (v / 255.0f); 104 | 105 | if(!dfcmp(x, 0.0f)) 106 | { 107 | table = (int)(j / 60.0f); 108 | if(table < 6) 109 | { 110 | float t = (j / 60.0f); 111 | switch(table) 112 | { 113 | case 0: 114 | xr = i; 115 | xg = ((1.0f - ((1.0f - (t - (float)table)) * x)) * i); 116 | xb = ((1.0f - x) * i); 117 | break; 118 | case 1: 119 | xr = ((1.0f - (x * (t - (float)table))) * i); 120 | xg = i; 121 | xb = ((1.0f - x) * i); 122 | break; 123 | case 2: 124 | xr = ((1.0f - x) * i); 125 | xg = i; 126 | xb = ((1.0f - ((1.0f - (t - (float)table)) * x)) * i); 127 | break; 128 | case 3: 129 | xr = ((1.0f - x) * i); 130 | xg = ((1.0f - (x * (t - (float)table))) * i); 131 | xb = i; 132 | break; 133 | case 4: 134 | xr = ((1.0f - ((1.0f - (t - (float)table)) * x)) * i); 135 | xg = ((1.0f - x) * i); 136 | xb = i; 137 | break; 138 | case 5: 139 | xr = i; 140 | xg = ((1.0f - x) * i); 141 | xb = ((1.0f - (x * (t - (float)table))) * i); 142 | break; 143 | } 144 | } 145 | } 146 | else 147 | xr = xg = xb = i; 148 | 149 | *r = (int)(xr * 255.0f); 150 | *g = (int)(xg * 255.0f); 151 | *b = (int)(xb * 255.0f); 152 | } 153 | 154 | // 155 | // R_SetLightFactor 156 | // 157 | 158 | void R_SetLightFactor(float lightfactor) 159 | { 160 | int l; 161 | light_t* light; 162 | float f; 163 | 164 | f = lightfactor / 100.0f; 165 | 166 | for(l = 0; l < numlights; l++) 167 | { 168 | light = &lights[l]; 169 | 170 | if(l >= 256) 171 | { 172 | int h, s, v; 173 | int r, g, b; 174 | 175 | R_LightGetHSV(light->r, light->g, light->b, &h, &s, &v); 176 | 177 | v = MIN((int)((float)v * f), 255); 178 | 179 | R_LightGetRGB(h, s, v, &r, &g, &b); 180 | 181 | light->base_r = r; 182 | light->base_g = g; 183 | light->base_b = b; 184 | } 185 | else 186 | light->base_r = light->base_g = light->base_b = MIN((int)((float)l * f), 255); 187 | 188 | light->active_r = light->base_r; 189 | light->active_g = light->base_g; 190 | light->active_b = light->base_b; 191 | } 192 | } 193 | 194 | // 195 | // R_RefreshBrightness 196 | // 197 | 198 | void R_RefreshBrightness(void) 199 | { 200 | float factor; 201 | float brightness = 100; 202 | 203 | factor = (((infraredFactor > brightness) ? infraredFactor : brightness) + 100.0f); 204 | R_SetLightFactor(factor); 205 | } 206 | 207 | 208 | -------------------------------------------------------------------------------- /arm9/source/r_local.h: -------------------------------------------------------------------------------- 1 | #ifndef __R_LOCAL__ 2 | #define __R_LOCAL__ 3 | 4 | #include "doomdata.h" 5 | #include "t_bsp.h" 6 | #include "tables.h" 7 | #include "p_pspr.h" 8 | #include "d_player.h" 9 | #include "w_wad.h" 10 | 11 | #define CLIPSPACE 160 12 | #define CLIP_NEAR_Z (8*FRACUNIT) 13 | 14 | extern fixed_t viewx; 15 | extern fixed_t viewy; 16 | extern fixed_t viewz; 17 | extern angle_t viewangle; 18 | extern angle_t viewpitch; 19 | extern fixed_t quakeviewx; 20 | extern fixed_t quakeviewy; 21 | extern angle_t viewangleoffset; 22 | extern fixed_t viewsin[2]; 23 | extern fixed_t viewcos[2]; 24 | extern int frametic; 25 | extern byte occludeBuffer[SCREENWIDTH]; 26 | 27 | extern int numvertexes; 28 | extern vertex_t *vertexes; 29 | extern int numsegs; 30 | extern seg_t *segs; 31 | extern int numsectors; 32 | extern sector_t *sectors; 33 | extern int numsubsectors; 34 | extern subsector_t *subsectors; 35 | extern int numnodes; 36 | extern node_t *nodes; 37 | extern int numleafs; 38 | extern leaf_t *leafs; 39 | extern int numsides; 40 | extern side_t *sides; 41 | extern int numlines; 42 | extern line_t *lines; 43 | extern light_t *lights; 44 | extern int numlights; 45 | extern macroinfo_t macros; 46 | 47 | // 48 | // R_MAIN 49 | // 50 | 51 | extern spritedef_t *spriteinfo; 52 | extern short *spritewidth; 53 | extern short *spriteheight; 54 | extern short *spriteoffset; 55 | extern short *spritetopoffset; 56 | extern byte *spritetiles; 57 | extern short **spritetilelist; 58 | 59 | subsector_t* R_PointInSubsector(fixed_t x, fixed_t y); 60 | angle_t R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); 61 | angle_t _R_PointToAngle(fixed_t x, fixed_t y); 62 | angle_t R_PointToPitch(fixed_t z1, fixed_t z2, fixed_t dist); 63 | int PUREFUNC R_PointOnSide(fixed_t x, fixed_t y, node_t* node); 64 | void R_Init(void); 65 | void R_DrawFrame(void); 66 | 67 | // 68 | // R_DATA 69 | // 70 | 71 | #define GFX_BUFFER_SIZE 0x80000 72 | 73 | extern int t_start; 74 | extern int t_end; 75 | extern int numtextures; 76 | extern int swx_start; 77 | extern int s_start; 78 | extern int s_end; 79 | extern int numgfxsprites; 80 | extern int g_start; 81 | extern int g_end; 82 | extern int numgfximgs; 83 | extern uint32* gfx_base; 84 | extern byte gfx_tex_buffer[GFX_BUFFER_SIZE]; 85 | extern gfx_t* gfx_images; 86 | extern uint32* gfx_imgpal_params; 87 | 88 | void R_PrecacheLevel(void); 89 | uint32 R_CachePalette(const char* name); 90 | int R_PadTextureDims(int n); 91 | int R_GetTextureSize(int size); 92 | int R_GetDSTextureSize(int size); 93 | void R_LoadTexture(dtexture texture, dboolean flip_s, dboolean flip_t, dboolean masked); 94 | void R_SetTextureFrame(int texture, int frame, dboolean palette); 95 | dboolean R_LoadSprite(int sprite, int frame, int rotation, int palindex, int *x, int *y, int *w, int *h); 96 | void R_InitData(void); 97 | byte* R_CopyPic(byte* pic, int x, int y, int rows, int colsize, 98 | int copysize, int mainwidth); 99 | 100 | // 101 | // R_BSP 102 | // 103 | #define MAXSUBSECTORS 1024 104 | #define MAXSPRITES 128 105 | 106 | extern subsector_t *ssectlist[MAXSUBSECTORS]; 107 | extern subsector_t **nextssect; 108 | extern mobj_t *visspritelist[MAXSPRITES]; 109 | extern mobj_t **vissprite; 110 | extern sector_t *frontsector; 111 | 112 | void R_RenderBSPNode(int bspnum); 113 | void R_RenderBSPNodeNoClip(int bspnum); 114 | 115 | // 116 | // R_DRAW 117 | // 118 | // Needed to store the number of the dummy sky flat. 119 | // Used for rendering, as well as tracking projectiles etc. 120 | // 121 | extern dboolean skyvisible; 122 | extern int skyflatnum; 123 | extern skydef_t* sky; 124 | extern int skypicnum; 125 | extern int skybackdropnum; 126 | extern dboolean skyfadeback; 127 | extern fixed_t scrollfrac; 128 | extern int thunderCounter; 129 | 130 | void R_DrawScene(void); 131 | void R_DrawSky(void); 132 | void R_DrawPSprite(pspdef_t *psp, sector_t* sector, player_t *player); 133 | void R_SlamBackground(const char* name, int x, int y, rcolor color); 134 | 135 | // 136 | // R_COLORS 137 | // 138 | enum 139 | { 140 | LIGHT_FLOOR, 141 | LIGHT_CEILING, 142 | LIGHT_THING, 143 | LIGHT_UPRWALL, 144 | LIGHT_LWRWALL 145 | }; 146 | 147 | void R_RefreshBrightness(void); 148 | void R_SetLightFactor(float lightfactor); 149 | 150 | #endif -------------------------------------------------------------------------------- /arm9/source/r_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "m_fixed.h" 4 | #include "tables.h" 5 | #include "r_local.h" 6 | #include "z_zone.h" 7 | #include "w_wad.h" 8 | #include "p_local.h" 9 | #include "d_main.h" 10 | 11 | // render view globals 12 | fixed_t viewx; 13 | fixed_t viewy; 14 | fixed_t viewz; 15 | angle_t viewangle; 16 | angle_t viewpitch; 17 | fixed_t quakeviewx; 18 | fixed_t quakeviewy; 19 | angle_t viewangleoffset; 20 | fixed_t viewsin[2]; 21 | fixed_t viewcos[2]; 22 | int frametic = 0; 23 | byte occludeBuffer[SCREENWIDTH]; 24 | 25 | // sprite info globals 26 | spritedef_t *spriteinfo; 27 | 28 | // gfx texture globals 29 | int t_start; 30 | int t_end; 31 | int numtextures; 32 | int swx_start; 33 | 34 | // gfx sprite globals 35 | int s_start; 36 | int s_end; 37 | int numgfxsprites; 38 | short *spriteoffset; 39 | short *spritetopoffset; 40 | short *spritewidth; 41 | short *spriteheight; 42 | byte *spritetiles; 43 | short **spritetilelist; 44 | 45 | // gfx img globals 46 | int g_start; 47 | int g_end; 48 | int numgfximgs; 49 | 50 | extern int bsptic; 51 | extern int rendertic; 52 | 53 | // 54 | // R_PointToAngle2 55 | // 56 | angle_t R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) 57 | { 58 | return _R_PointToAngle(x2 - x1, y2 - y1); 59 | } 60 | 61 | // 62 | // R_PointToPitch 63 | // 64 | 65 | angle_t R_PointToPitch(fixed_t z1, fixed_t z2, fixed_t dist) 66 | { 67 | return R_PointToAngle2(0, z1, dist, z2); 68 | } 69 | 70 | // 71 | // R_PointOnSide 72 | // Traverse BSP (sub) tree, 73 | // check point against partition plane. 74 | // Returns side 0 (front) or 1 (back). 75 | // 76 | 77 | int PUREFUNC R_PointOnSide(fixed_t x, fixed_t y, node_t* node) 78 | { 79 | fixed_t dx; 80 | fixed_t dy; 81 | fixed_t left; 82 | fixed_t right; 83 | 84 | if(!node->dx) 85 | { 86 | if(x <= node->x) 87 | return node->dy > 0; 88 | 89 | return node->dy < 0; 90 | } 91 | if(!node->dy) 92 | { 93 | if(y <= node->y) 94 | return node->dx < 0; 95 | 96 | return node->dx > 0; 97 | } 98 | 99 | dx = (x - node->x); 100 | dy = (y - node->y); 101 | 102 | left = F2INT(node->dy) * F2INT(dx); 103 | right = F2INT(dy) * F2INT(node->dx); 104 | 105 | if(right < left) 106 | { 107 | // front side 108 | return 0; 109 | } 110 | 111 | // back side 112 | return 1; 113 | } 114 | 115 | // 116 | // R_PointInSubsector 117 | // 118 | 119 | subsector_t* R_PointInSubsector(fixed_t x, fixed_t y) 120 | { 121 | node_t* node; 122 | int side; 123 | int nodenum; 124 | 125 | // single subsector is a special case 126 | if (!numnodes) 127 | return subsectors; 128 | 129 | nodenum = numnodes-1; 130 | 131 | while (!(nodenum & NF_SUBSECTOR)) 132 | { 133 | node = &nodes[nodenum]; 134 | side = R_PointOnSide (x, y, node); 135 | nodenum = node->children[side]; 136 | } 137 | 138 | return &subsectors[nodenum & ~NF_SUBSECTOR]; 139 | } 140 | 141 | // 142 | // R_RenderView 143 | // 144 | 145 | static void R_RenderView(player_t* player) 146 | { 147 | nextssect = ssectlist; 148 | vissprite = visspritelist; 149 | 150 | memset(occludeBuffer, 0, SCREENWIDTH); 151 | skyvisible = false; 152 | 153 | if(devparm) 154 | cpuStartTiming(2); 155 | 156 | if(player->cameratarget != player->mo && gamemap == 33) 157 | R_RenderBSPNodeNoClip(numnodes - 1); 158 | else 159 | R_RenderBSPNode(numnodes - 1); 160 | 161 | if(devparm) 162 | bsptic = timerTicks2msec(cpuEndTiming()); 163 | } 164 | 165 | // 166 | // R_Init 167 | // 168 | 169 | void R_Init(void) 170 | { 171 | int i = 0; 172 | int a = 0; 173 | double an; 174 | 175 | // 176 | // [d64] build finesine table 177 | // 178 | for(i = 0; i < (5 * FINEANGLES / 4); i++) 179 | { 180 | an = a * M_PI / (double)FINEANGLES; 181 | finesine[i] = (fixed_t)(sin(an) * (double)FRACUNIT); 182 | a += 2; 183 | } 184 | 185 | I_SendDataToArm7(FIFO_MSG_FINESINEDATA, (void*)finesine, 0); 186 | I_SendDataToArm7(FIFO_MSG_FINECOSINEDATA, (void*)finecosine, 0); 187 | R_InitData(); 188 | } 189 | 190 | // 191 | // R_DrawFrame 192 | // 193 | 194 | void R_DrawFrame(void) 195 | { 196 | angle_t pitch; 197 | angle_t angle; 198 | fixed_t cam_z; 199 | mobj_t* viewcamera; 200 | player_t* player; 201 | pspdef_t* psp; 202 | int i; 203 | 204 | for(i = 0; i < 32; i++) 205 | GFX_FOG_TABLE[i] = (i * 4); 206 | 207 | GFX_FOG_TABLE[31] = 0x7F; 208 | GFX_CONTROL = (GFX_CONTROL & 0xF0FF) | 0x700; 209 | 210 | if(automapactive) 211 | { 212 | GFX_CLEAR_COLOR = 0x1F0000; 213 | return; 214 | } 215 | else if(sky != NULL) 216 | { 217 | if(sky->flags & SKF_CLOUD) 218 | GFX_CLEAR_COLOR = sky->skycolor[1]; 219 | else if(sky->flags & SKF_VOID) 220 | GFX_CLEAR_COLOR = sky->skycolor[2]; 221 | else 222 | GFX_CLEAR_COLOR = 0x1F0000; 223 | 224 | GFX_FOG_COLOR = sky->fogcolor; 225 | GFX_FOG_OFFSET = GL_MAX_DEPTH - ((1000 - sky->fognear) * 10); 226 | } 227 | else 228 | { 229 | GFX_CLEAR_COLOR = 0x1F0000; 230 | GFX_FOG_COLOR = 0; 231 | GFX_FOG_OFFSET = GL_MAX_DEPTH - 192; 232 | } 233 | 234 | // 235 | // setup view rotation/position 236 | // 237 | player = &players[consoleplayer]; 238 | viewcamera = player->cameratarget; 239 | angle = (viewcamera->angle + quakeviewx) + viewangleoffset; 240 | pitch = viewcamera->pitch + ANG90; 241 | cam_z = (viewcamera == player->mo ? player->viewz : viewcamera->z) + quakeviewy; 242 | 243 | if(viewcamera == player->mo) 244 | pitch += player->recoilpitch; 245 | 246 | viewangle = angle; 247 | viewpitch = pitch; 248 | viewx = viewcamera->x; 249 | viewy = viewcamera->y; 250 | viewz = cam_z; 251 | 252 | viewsin[0] = dsin(viewangle + ANG90); 253 | viewsin[1] = dsin(viewpitch - ANG90); 254 | viewcos[0] = dcos(viewangle + ANG90); 255 | viewcos[1] = dcos(viewpitch - ANG90); 256 | 257 | MATRIX_CONTROL = GL_PROJECTION; 258 | MATRIX_IDENTITY = 0; 259 | MATRIX_CONTROL = GL_MODELVIEW; 260 | MATRIX_IDENTITY = 0; 261 | 262 | if(skyvisible) 263 | R_DrawSky(); 264 | 265 | MATRIX_PUSH = 0; 266 | 267 | MATRIX_TRANSLATE = -(16 << 4); 268 | MATRIX_TRANSLATE = -0; 269 | MATRIX_TRANSLATE = -0; 270 | 271 | MATRIX_PUSH = 0; 272 | 273 | gluPerspective(74, 256.0f / 192.0f, 0.002f, 1000); 274 | 275 | glRotatef(-TRUEANGLES(viewpitch) + 90, 1.0f, 0.0f, 0.0f); 276 | glRotatef(-TRUEANGLES(viewangle) + 90, 0.0f, 1.0f, 0.0f); 277 | 278 | MATRIX_SCALE = 0x1000; 279 | MATRIX_SCALE = 0x1000; 280 | MATRIX_SCALE = -0x1000; 281 | MATRIX_TRANSLATE = -F2DSFIXED(viewx); 282 | MATRIX_TRANSLATE = -F2DSFIXED(viewz); 283 | MATRIX_TRANSLATE = -F2DSFIXED(viewy); 284 | 285 | D_IncValidCount(); 286 | D_UpdateTiccmd(); 287 | 288 | R_RenderView(player); 289 | 290 | if(devparm) 291 | cpuStartTiming(2); 292 | 293 | R_DrawScene(); 294 | 295 | if(devparm) 296 | rendertic = timerTicks2msec(cpuEndTiming()); 297 | 298 | MATRIX_POP = GFX_MTX_STACK_LEVEL; 299 | 300 | for(psp = player->psprites; psp < &player->psprites[NUMPSPRITES]; psp++) 301 | { 302 | if(psp->state && player->cameratarget == player->mo) 303 | R_DrawPSprite(psp, player->mo->subsector->sector, player); 304 | } 305 | } 306 | 307 | -------------------------------------------------------------------------------- /arm9/source/s_sound.c: -------------------------------------------------------------------------------- 1 | #include "sounds.h" 2 | #include "s_sound.h" 3 | #include "z_zone.h" 4 | #include "m_fixed.h" 5 | #include "p_local.h" 6 | #include "tables.h" 7 | #include "r_local.h" 8 | #include "d_main.h" 9 | 10 | // Adjustable by menu. 11 | #define NORM_VOLUME 127 12 | #define NORM_SEP 128 13 | 14 | // when to clip out sounds 15 | // Does not fit the large outdoor areas. 16 | #define S_CLIPPING_DIST (1200<> FRACBITS)) // [d64] 23 | #define S_CLOSE_DIST (200 << FRACBITS) 24 | #define S_ATTENUATOR ((S_CLIPPING_DIST - S_CLOSE_DIST) >> FRACBITS) 25 | 26 | #define S_PITCH_PERTURB 1 27 | #define S_STEREO_SWING (96*0x10000) 28 | 29 | // percent attenuation from front to back 30 | #define S_IFRACVOL 30 31 | 32 | dboolean nosound = false; 33 | dboolean nomusic = false; 34 | 35 | static int lastmusic = 0; 36 | 37 | typedef struct 38 | { 39 | int handle; 40 | int starttic; 41 | fixed_t org_x; 42 | fixed_t org_y; 43 | } sfxchannel_t; 44 | 45 | static sfxchannel_t sfxchannels[NUMSFX]; 46 | static sfxchannel_t* sfxchan_ptr[16]; 47 | 48 | // 49 | // Internals. 50 | // 51 | int S_AdjustSoundParams(fixed_t x, fixed_t y, int* vol, int* sep); 52 | 53 | // 54 | // S_Init 55 | // 56 | // Initializes sound stuff, including volume 57 | // and the sequencer 58 | // 59 | 60 | void S_Init(void) 61 | { 62 | if(nosound && nomusic) 63 | return; 64 | 65 | soundEnable(); 66 | 67 | S_SetMusicVolume(80); 68 | S_SetSoundVolume(80); 69 | } 70 | 71 | // 72 | // S_SetSoundVolume 73 | // 74 | 75 | void S_SetSoundVolume(float volume) 76 | { 77 | } 78 | 79 | // 80 | // S_SetMusicVolume 81 | // 82 | 83 | void S_SetMusicVolume(float volume) 84 | { 85 | } 86 | 87 | // 88 | // S_StartMusic 89 | // 90 | 91 | void S_StartMusic(int mnum) 92 | { 93 | if(nomusic) 94 | return; 95 | 96 | if(mnum <= -1) 97 | return; 98 | 99 | lastmusic = mnum; 100 | } 101 | 102 | // 103 | // S_StopMusic 104 | // 105 | 106 | void S_StopMusic(void) 107 | { 108 | lastmusic = 0; 109 | } 110 | 111 | // 112 | // S_ResetSound 113 | // 114 | 115 | void S_ResetSound(void) 116 | { 117 | if(nosound && nomusic) 118 | return; 119 | } 120 | 121 | // 122 | // S_PauseSound 123 | // 124 | 125 | void S_PauseSound(void) 126 | { 127 | if(nosound && nomusic) 128 | return; 129 | } 130 | 131 | // 132 | // S_ResumeSound 133 | // 134 | 135 | void S_ResumeSound(void) 136 | { 137 | if(nosound && nomusic) 138 | return; 139 | } 140 | 141 | // 142 | // S_StopSound 143 | // 144 | 145 | void S_StopSound(mobj_t* origin, int sfx_id) 146 | { 147 | sfxchannel_t* sfxchan = &sfxchannels[sfx_id]; 148 | // TODO 149 | // TEMP 150 | if(sfx_id == 0) return; 151 | sfxchan_ptr[sfxchan->handle] = NULL; 152 | soundKill(sfxchan->handle); 153 | } 154 | 155 | // 156 | // S_GetActiveSounds 157 | // 158 | 159 | int S_GetActiveSounds(void) 160 | { 161 | return 0; 162 | } 163 | 164 | // 165 | // S_RemoveOrigin 166 | // 167 | 168 | void S_RemoveOrigin(mobj_t* origin) 169 | { 170 | } 171 | 172 | // 173 | // S_UpdateSounds 174 | // 175 | 176 | void S_UpdateSounds(void) 177 | { 178 | // TODO - do this on ARM7 179 | /*int i; 180 | 181 | for(i = 0; i < 16; i++) 182 | { 183 | sfxchannel_t* sfxchan = sfxchan_ptr[i]; 184 | 185 | if(!sfxchan) 186 | continue; 187 | 188 | if(sfxchan->data == NULL) 189 | continue; 190 | 191 | if(sfxchan->org_x | sfxchan->org_y) 192 | { 193 | int volume = NORM_VOLUME; 194 | int sep = NORM_SEP; 195 | 196 | if(!S_AdjustSoundParams(sfxchan->org_x, sfxchan->org_y, &volume, &sep)) 197 | { 198 | sfxchan_ptr[sfxchan->handle] = NULL; 199 | soundKill(sfxchan->handle); 200 | return; 201 | } 202 | 203 | soundSetVolume(sfxchan->handle, volume); 204 | soundSetPan(sfxchan->handle, sep / 2); 205 | } 206 | }*/ 207 | } 208 | 209 | // 210 | // S_StartSound 211 | // 212 | 213 | void S_StartSound(mobj_t* origin, int sfx_id) 214 | { 215 | int volume; 216 | int sep; 217 | //int reverb; 218 | 219 | if(nosound) 220 | return; 221 | 222 | if(sfx_id == sfx_None) 223 | return; 224 | 225 | if(origin && origin != players[consoleplayer].cameratarget) 226 | { 227 | if(!S_AdjustSoundParams(origin->x, origin->y, &volume, &sep)) 228 | return; 229 | } 230 | else 231 | { 232 | sep = NORM_SEP; 233 | volume = NORM_VOLUME; 234 | } 235 | 236 | // TODO 237 | /*reverb = 0; 238 | 239 | if(origin) 240 | { 241 | subsector_t* subsector; 242 | 243 | subsector = R_PointInSubsector(origin->x, origin->y); 244 | 245 | if(subsector->sector->flags & MS_REVERB) 246 | reverb = 16; 247 | else if(subsector->sector->flags & MS_REVERBHEAVY) 248 | reverb = 32; 249 | }*/ 250 | 251 | // Assigns the handle to one of the channels in the mix/output buffer. 252 | 253 | { 254 | char name[9]; 255 | int lump; 256 | sfxchannel_t* sfxchan; 257 | 258 | sprintf(name, "SFX_%03d", sfx_id - 1); 259 | lump = W_GetNumForName(name); 260 | 261 | sfxchan = &sfxchannels[sfx_id]; 262 | 263 | if(sfxchan->starttic == gametic) 264 | return; 265 | 266 | sfxchan->starttic = gametic; 267 | if(origin) 268 | { 269 | sfxchan->org_x = origin->x; 270 | sfxchan->org_y = origin->y; 271 | } 272 | else 273 | { 274 | sfxchan->org_x = 0; 275 | sfxchan->org_y = 0; 276 | } 277 | 278 | sfxchan->handle = soundPlaySample( 279 | W_CacheLumpNum(lump, PU_AUDIO), 280 | SoundFormat_16Bit, 281 | W_LumpLength(lump), 282 | sfx_id == sfx_itemup ? 22050 : 11025, 283 | sfx_id == sfx_electric ? 20 : volume, 284 | sep / 2, 285 | sfx_id == sfx_electric ? 1 : 0, 286 | 0 287 | ); 288 | 289 | sfxchan_ptr[sfxchan->handle] = &sfxchannels[sfx_id]; 290 | } 291 | } 292 | 293 | // 294 | // S_AdjustSoundParams 295 | // 296 | // Changes volume, stereo-separation, and pitch variables 297 | // from the norm of a sound effect to be played. 298 | // If the sound is not audible, returns a 0. 299 | // Otherwise, modifies parameters and returns 1. 300 | // 301 | 302 | int S_AdjustSoundParams(fixed_t x, fixed_t y, int* vol, int* sep) 303 | { 304 | fixed_t approx_dist; 305 | angle_t angle; 306 | mobj_t* listener; 307 | player_t* player; 308 | 309 | player = &players[consoleplayer]; 310 | 311 | listener = player->cameratarget; 312 | 313 | // calculate the distance to sound origin 314 | // and clip it if necessary 315 | 316 | // From _GG1_ p.428. Appox. eucledian distance fast. 317 | approx_dist = P_AproxDistance(listener->x - x, listener->y - y); 318 | 319 | if(approx_dist > S_CLIPPING_DIST) 320 | return 0; 321 | 322 | if(listener->x != x || listener->y != y) 323 | { 324 | // angle of source to listener 325 | angle = R_PointToAngle2(listener->x, listener->y, x, y); 326 | 327 | if(angle <= listener->angle) 328 | angle += 0xffffffff; 329 | angle -= listener->angle; 330 | 331 | // stereo separation 332 | *sep = (NORM_VOLUME + 1) - (FixedMul(S_STEREO_SWING, dsin(angle)) >> FRACBITS); 333 | } 334 | else 335 | *sep = NORM_SEP; 336 | 337 | // volume calculation 338 | if (approx_dist < S_CLOSE_DIST) 339 | *vol = NORM_VOLUME; 340 | else 341 | { 342 | // distance effect 343 | approx_dist >>= FRACBITS; 344 | *vol = (((-approx_dist << 7) + (approx_dist)) + S_MAX_DIST) / S_ATTENUATOR; 345 | } 346 | 347 | return (*vol > 0); 348 | } 349 | 350 | 351 | 352 | 353 | -------------------------------------------------------------------------------- /arm9/source/s_sound.h: -------------------------------------------------------------------------------- 1 | #ifndef __S_SOUND__ 2 | #define __S_SOUND__ 3 | 4 | #include "p_mobj.h" 5 | #include "sounds.h" 6 | 7 | extern dboolean nosound; 8 | extern dboolean nomusic; 9 | 10 | // 11 | // Initializes sound stuff, including volume 12 | // Sets channels, SFX and music volume, 13 | // allocates channel buffer 14 | // 15 | void S_Init(void); 16 | void S_SetSoundVolume(float volume); 17 | void S_SetMusicVolume(float volume); 18 | void S_ResetSound(void); 19 | void S_PauseSound(void); 20 | void S_ResumeSound(void); 21 | 22 | // 23 | // Start sound for thing at 24 | // using from sounds.h 25 | // 26 | void S_StartSound(mobj_t* origin, int sound_id); 27 | void S_UpdateSounds(void); 28 | void S_RemoveOrigin(mobj_t* origin); 29 | // Will start a sound at a given volume. 30 | void S_StartSoundAtVolume(mobj_t* origin, int sound_id, int volume); 31 | // Stop sound for thing at 32 | void S_StopSound(mobj_t* origin, int sfx_id); 33 | int S_GetActiveSounds(void); 34 | // Start music using from sounds.h 35 | void S_StartMusic(int mnum); 36 | void S_StopMusic(void); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /arm9/source/sc_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ds.h" 4 | #include "doomdef.h" 5 | #include "doomtype.h" 6 | #include "z_zone.h" 7 | #include "w_wad.h" 8 | #include "sc_main.h" 9 | 10 | scparser_t sc_parser; 11 | 12 | // 13 | // SC_Open 14 | // 15 | 16 | void SC_Open(char* name) 17 | { 18 | int lump; 19 | 20 | lump = W_CheckNumForName(name); 21 | 22 | if(lump <= -1) 23 | { 24 | sc_parser.buffsize = I_ReadFile(name, (byte**)&sc_parser.buffer); 25 | 26 | if(sc_parser.buffsize == -1) 27 | I_Error("SC_Open: %s not found", name); 28 | } 29 | else 30 | { 31 | sc_parser.buffer = W_CacheLumpNum(lump, PU_STATIC); 32 | sc_parser.buffsize = W_LumpLength(lump); 33 | } 34 | 35 | sc_parser.pointer_start = sc_parser.buffer; 36 | sc_parser.pointer_end = sc_parser.buffer + sc_parser.buffsize; 37 | sc_parser.linepos = 1; 38 | sc_parser.rowpos = 1; 39 | sc_parser.buffpos = 0; 40 | } 41 | 42 | // 43 | // SC_Close 44 | // 45 | 46 | void SC_Close(void) 47 | { 48 | Z_Free(sc_parser.buffer); 49 | 50 | sc_parser.buffer = NULL; 51 | sc_parser.buffsize = 0; 52 | sc_parser.pointer_start = NULL; 53 | sc_parser.pointer_end = NULL; 54 | sc_parser.linepos = 0; 55 | sc_parser.rowpos = 0; 56 | sc_parser.buffpos = 0; 57 | } 58 | 59 | // 60 | // SC_Compare 61 | // 62 | 63 | void SC_Compare(char* token) 64 | { 65 | SC_Find(false); 66 | if(stricmp(sc_parser.token, token)) 67 | { 68 | I_Error("SC_Compare: Expected '%s', found '%s' (line = %i, pos = %i)", 69 | token, sc_parser.token, sc_parser.linepos, sc_parser.rowpos); 70 | } 71 | } 72 | 73 | // 74 | // SC_ReadTokens 75 | // 76 | 77 | int SC_ReadTokens(void) 78 | { 79 | return (sc_parser.buffpos < sc_parser.buffsize); 80 | } 81 | 82 | // 83 | // SC_GetString 84 | // 85 | 86 | char* SC_GetString(void) 87 | { 88 | SC_Compare("="); // expect a '=' 89 | SC_Find(false); // get next token which should be a string 90 | 91 | return sc_parser.token; 92 | } 93 | 94 | // 95 | // SC_GetInteger 96 | // 97 | 98 | int SC_GetInteger(void) 99 | { 100 | SC_Compare("="); // expect a '=' 101 | SC_Find(false); // get next token which should be an integer 102 | 103 | return atoi(sc_parser.token); 104 | } 105 | 106 | // 107 | // SC_SetData 108 | // 109 | 110 | int SC_SetData(byte* data, const scdatatable_t* table) 111 | { 112 | int i; 113 | dboolean ok = false; 114 | 115 | for(i = 0; table[i].token; i++) 116 | { 117 | if(!stricmp(table[i].token, sc_parser.token)) 118 | { 119 | byte* pointer = ((byte*)data + table[i].ptroffset); 120 | char* name; 121 | byte rgb[3]; 122 | 123 | ok = true; 124 | 125 | switch(table[i].type) 126 | { 127 | case 's': 128 | name = SC_GetString(); 129 | strncpy((char*)pointer, name, strlen(name)); 130 | break; 131 | case 'S': 132 | name = SC_GetString(); 133 | strupr(name); 134 | strncpy((char*)pointer, name, strlen(name)); 135 | break; 136 | case 'i': 137 | *(int*)pointer = SC_GetInteger(); 138 | break; 139 | case 'b': 140 | *(int*)pointer = true; 141 | break; 142 | case 'c': 143 | SC_Compare("="); // expect a '=' 144 | SC_Find(false); 145 | rgb[0] = dhtoi(sc_parser.token) >> 3; 146 | SC_Find(false); 147 | rgb[1] = dhtoi(sc_parser.token) >> 3; 148 | SC_Find(false); 149 | rgb[2] = dhtoi(sc_parser.token) >> 3; 150 | *(rcolor*)pointer = ARGB16(0xff, rgb[0], rgb[1], rgb[2]); 151 | break; 152 | } 153 | 154 | break; 155 | } 156 | } 157 | 158 | return ok; 159 | } 160 | 161 | // 162 | // SC_Find 163 | // 164 | 165 | int SC_Find(dboolean forceupper) 166 | { 167 | char c = 0; 168 | int i = 0; 169 | dboolean comment = false; 170 | dboolean havetoken = false; 171 | dboolean string = false; 172 | 173 | memset(sc_parser.token, 0, 256); 174 | 175 | while(SC_ReadTokens()) 176 | { 177 | c = SC_GetChar(); 178 | 179 | if(c == '/') 180 | comment = true; 181 | 182 | if(comment == false) 183 | { 184 | if(c == '"') 185 | { 186 | if(!string) 187 | { 188 | string = true; 189 | continue; 190 | } 191 | else if(havetoken) 192 | { 193 | c = SC_GetChar(); 194 | 195 | if(c != ',') 196 | return true; 197 | else 198 | { 199 | havetoken = false; 200 | continue; 201 | } 202 | } 203 | else 204 | { 205 | if(SC_GetChar() == '"') 206 | { 207 | if(SC_GetChar() == ',') 208 | continue; 209 | else 210 | { 211 | SC_Rewind(); 212 | SC_Rewind(); 213 | } 214 | } 215 | else 216 | SC_Rewind(); 217 | } 218 | } 219 | 220 | if(!string) 221 | { 222 | if(c > ' ') 223 | { 224 | havetoken = true; 225 | sc_parser.token[i++] = 226 | forceupper ? toupper((int)c) : c; 227 | } 228 | else if(havetoken) 229 | return true; 230 | } 231 | else 232 | { 233 | if(c >= ' ' && c != '"') 234 | { 235 | havetoken = true; 236 | sc_parser.token[i++] = 237 | forceupper ? toupper((int)c) : c; 238 | } 239 | } 240 | } 241 | 242 | if(c == '\n') 243 | { 244 | sc_parser.linepos++; 245 | sc_parser.rowpos = 1; 246 | comment = false; 247 | if(string) 248 | sc_parser.token[i++] = c; 249 | } 250 | } 251 | 252 | return false; 253 | } 254 | 255 | // 256 | // SC_GetChar 257 | // 258 | 259 | char SC_GetChar(void) 260 | { 261 | sc_parser.rowpos++; 262 | return sc_parser.buffer[sc_parser.buffpos++]; 263 | } 264 | 265 | // 266 | // SC_Rewind 267 | // 268 | 269 | void SC_Rewind(void) 270 | { 271 | sc_parser.rowpos--; 272 | sc_parser.buffpos--; 273 | } 274 | 275 | // 276 | // SC_Error 277 | // 278 | 279 | void SC_Error(char* function) 280 | { 281 | if(sc_parser.token[0] < ' ') 282 | return; 283 | 284 | I_Error("%s: Unknown token: '%s' (line = %i, pos = %i)", 285 | function, sc_parser.token, sc_parser.linepos, sc_parser.rowpos); 286 | } 287 | 288 | // 289 | // SC_Init 290 | // 291 | 292 | void SC_Init(void) 293 | { 294 | // 295 | // clear variables 296 | // 297 | memset(&sc_parser, 0, sizeof(scparser_t)); 298 | } 299 | -------------------------------------------------------------------------------- /arm9/source/sc_main.h: -------------------------------------------------------------------------------- 1 | #ifndef __SC_MAIN__ 2 | #define __SC_MAIN__ 3 | 4 | typedef struct 5 | { 6 | char token[512]; 7 | char* buffer; 8 | char* pointer_start; 9 | char* pointer_end; 10 | int linepos; 11 | int rowpos; 12 | int buffpos; 13 | int buffsize; 14 | } scparser_t; 15 | 16 | extern scparser_t sc_parser; 17 | 18 | typedef struct 19 | { 20 | char* token; 21 | int32 ptroffset; 22 | char type; 23 | } scdatatable_t; 24 | 25 | void SC_Init(void); 26 | void SC_Open(char* name); 27 | void SC_Close(void); 28 | void SC_Compare(char* token); 29 | int SC_ReadTokens(void); 30 | char* SC_GetString(void); 31 | int SC_GetInteger(void); 32 | int SC_SetData(byte* data, const scdatatable_t* table); 33 | int SC_Find(dboolean forceupper); 34 | char SC_GetChar(void); 35 | void SC_Rewind(void); 36 | void SC_Error(char* function); 37 | 38 | #endif // __SC_MAIN__ 39 | -------------------------------------------------------------------------------- /arm9/source/sounds.h: -------------------------------------------------------------------------------- 1 | #ifndef __SOUNDS__ 2 | #define __SOUNDS__ 3 | 4 | // 5 | // Identifiers for all sfx in game. 6 | // 7 | 8 | typedef enum 9 | { 10 | sfx_None, 11 | sfx_inst00, 12 | sfx_inst01, 13 | sfx_inst02, 14 | sfx_inst03, 15 | sfx_inst04, 16 | sfx_inst05, 17 | sfx_inst06, 18 | sfx_inst07, 19 | sfx_inst08, 20 | sfx_inst09, 21 | sfx_inst10, 22 | sfx_inst11, 23 | sfx_inst12, 24 | sfx_inst13, 25 | sfx_inst14, 26 | sfx_inst15, 27 | sfx_inst16, 28 | sfx_inst17, 29 | sfx_inst18, 30 | sfx_inst19, 31 | sfx_inst20, 32 | sfx_inst21, 33 | sfx_inst22, 34 | sfx_inst23, 35 | sfx_inst24, 36 | sfx_inst25, 37 | sfx_inst26, 38 | sfx_inst27, 39 | sfx_inst28, 40 | sfx_inst29, 41 | sfx_inst30, 42 | sfx_inst31, 43 | sfx_inst32, 44 | sfx_pistol, //pistol 45 | sfx_shotgun, //shotgun 46 | sfx_plasma, //plasma 47 | sfx_bfg, //bfg 48 | sfx_sawup, //sawup 49 | sfx_sawidle, //sawidle 50 | sfx_saw1, //saw1 51 | sfx_saw2, //saw2 52 | sfx_missile, //missile 53 | sfx_spawn, //spawn 54 | sfx_bfgexp, //bfgexplode 55 | sfx_implod, //impact 56 | sfx_pstart, //platup 57 | sfx_pstop, //platdown 58 | sfx_doorup, //doorup 59 | sfx_doordown, //doordown 60 | sfx_secmove, //secmove 61 | sfx_switch1, //switch1 62 | sfx_switch2, //switch2 63 | sfx_plrpain, //playerpain 64 | sfx_dbpain2, //pain2 65 | sfx_dbpain1, //pain1 66 | sfx_slop, //slop 67 | sfx_itemup, //itemup 68 | sfx_oof, //oof 69 | sfx_telept, //teleport 70 | sfx_possit1, //posssit1 71 | sfx_possit2, //posssit2 72 | sfx_possit3, //posssit3 73 | sfx_impsit1, //impsit1 74 | sfx_impsit2, //impsit2 75 | sfx_sargsit, //sargsit 76 | sfx_headsit, //headsit 77 | sfx_bos1sit, //boss1sit 78 | sfx_cybsit, //cybsit 79 | sfx_skullatk, //skullatk 80 | sfx_sargatk, //sargatk 81 | sfx_scratch, //scratch 82 | sfx_plrdie, //playerdie 83 | sfx_posdie1, //possdie1 84 | sfx_posdie2, //possdie2 85 | sfx_posdie3, //possdie3 86 | sfx_impdth1, //impdeath1 87 | sfx_impdth2, //impdeath2 88 | sfx_sargdie, //sargdie 89 | sfx_headdie, //headdie 90 | sfx_bos1die, //boss1die 91 | sfx_cybdth, //cybdeath 92 | sfx_posact, //possact 93 | sfx_impact, //impact 94 | sfx_dbact, //monsteract 95 | sfx_explode, //explode 96 | sfx_punch, //punch 97 | sfx_cybhoof, //hoof 98 | sfx_metal, //metal 99 | sfx_sht2fire, //shot2fire 100 | sfx_sht2load1, //shot2load1 101 | sfx_sht2load2, //shot2load2 102 | sfx_bos2sit, //boss2sit 103 | sfx_bos2die, //boss2die 104 | sfx_pesit, //painsit 105 | sfx_pepain, //painhit 106 | sfx_pedie, //paindie 107 | sfx_bspisit, //bspisit 108 | sfx_bspidie, //bspidie 109 | sfx_bspilift, //bspilift 110 | sfx_bspistomp, //bspistomp 111 | sfx_fattatk, //fattatk 112 | sfx_fattsit, //fattsit 113 | sfx_fatthit, //fatthit 114 | sfx_fattdie, //fattdie 115 | sfx_skelact, //revenantact?? 116 | sfx_tracer, //tracer 117 | sfx_dart, //dart 118 | sfx_dartshoot, //revenantpunch?? 119 | sfx_door2up, //door2up 120 | sfx_door2dwn, //door2down 121 | sfx_powerup, //powerup 122 | sfx_laser, //laser 123 | sfx_electric, //electric (loop) 124 | sfx_thndrlow, //thunderlow 125 | sfx_thndrhigh, //thunderhigh 126 | sfx_quake, //quake (loop) 127 | sfx_darthit, //darthit 128 | sfx_rectact, //rectact 129 | sfx_rectatk, //rectatk 130 | sfx_rectdie, //rectdie 131 | sfx_rectpain, //rectpain 132 | sfx_rectsit, //rectsit 133 | sfx_sgcock, //sgcock 134 | sfx_bdmissile, //projectile 135 | NUMSFX 136 | } sfxenum_t; 137 | 138 | typedef enum 139 | { 140 | mus_amb01, 141 | mus_amb02, 142 | mus_amb03, 143 | mus_amb04, 144 | mus_amb05, 145 | mus_amb06, 146 | mus_amb07, 147 | mus_amb08, 148 | mus_amb09, 149 | mus_amb10, 150 | mus_amb11, 151 | mus_amb12, 152 | mus_amb13, 153 | mus_amb14, 154 | mus_amb15, 155 | mus_amb16, 156 | mus_amb17, 157 | mus_amb18, 158 | mus_amb19, 159 | mus_amb20, 160 | mus_final, 161 | mus_complete, 162 | mus_intro, 163 | mus_title, 164 | NUMMUS 165 | } musenum_t; 166 | 167 | #endif 168 | 169 | -------------------------------------------------------------------------------- /arm9/source/st_main.h: -------------------------------------------------------------------------------- 1 | #ifndef __ST_MAIN_H__ 2 | #define __ST_MAIN_H__ 3 | 4 | #include "doomtype.h" 5 | 6 | void ST_ClearMessage(void); 7 | void ST_Ticker(void); 8 | void ST_Drawer(void); 9 | void ST_UpdateFlash(void); 10 | void ST_Init(void); 11 | int ST_DrawBigFont(int x, int y, rcolor color, const char* string); 12 | int ST_DrawMessage(int x, int y, rcolor color, const char* string, ...); 13 | void ST_DrawNumber(int x, int y, int num, int type, rcolor c); 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /arm9/source/tables.h: -------------------------------------------------------------------------------- 1 | #ifndef __TABLES__ 2 | #define __TABLES__ 3 | 4 | #include "m_fixed.h" 5 | 6 | #define M_PI 3.14159265358979323846 7 | 8 | #define FINEANGLES 8192 9 | #define FINEMASK (FINEANGLES-1) 10 | 11 | 12 | // 0x100000000 to 0x2000 13 | #define ANGLETOFINESHIFT 19 14 | 15 | // Binary Angle Measument, BAM. 16 | #define ANG45 0x20000000 17 | #define ANG90 0x40000000 18 | #define ANG180 0x80000000 19 | #define ANG270 0xc0000000 20 | #define ANG1 (ANG45/45) 21 | #define ANG5 (ANG90/18) 22 | #define ANGLE_MAX (0xffffffff) 23 | 24 | 25 | #define SLOPERANGE 2048 26 | #define SLOPEBITS 11 27 | #define DBITS (FRACBITS-SLOPEBITS) 28 | 29 | #define TRUEANGLES(x) (((x) >> ANGLETOFINESHIFT) * 360.0f / FINEANGLES) 30 | 31 | typedef unsigned angle_t; 32 | 33 | // Effective size is 10240. 34 | extern fixed_t finesine[5*FINEANGLES/4]; 35 | 36 | // Re-use data, is just PI/2 pahse shift. 37 | extern fixed_t* finecosine; 38 | 39 | // Effective size is 2049; 40 | // The +1 size is to handle the case when x==y 41 | // without additional checking. 42 | extern angle_t tantoangle[SLOPERANGE+1]; 43 | 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /arm9/source/tonc_asminc.h: -------------------------------------------------------------------------------- 1 | // 2 | // tonc_asminc.h : header file with goodies for assembly. 3 | // 4 | //! \file tonc_asminc.h 5 | //! \author J Vijn 6 | //! \date 20081019 - 20090801 7 | // 8 | /* === NOTES === 9 | * Cleaned up the macros so that they work with comma-directives as well. 10 | * For use in assembly only! 11 | */ 12 | 13 | #ifndef TONC_ASMINC_H 14 | #define TONC_ASMINC_H 15 | 16 | #if !__ASSEMBLER__ 17 | #error This header file is for use in assembly only! 18 | #endif // /asm only 19 | 20 | 21 | // -------------------------------------------------------------------- 22 | // MACROS 23 | // -------------------------------------------------------------------- 24 | 25 | #define DEF_SIZE(_name) .size _name, .-_name 26 | 27 | //! \name Section definitions for assembly. 28 | //\{ 29 | 30 | #define CSEC_TEXT .text //!< Standard code section directive. 31 | #define CSEC_EWRAM .section .ewram , "ax", %progbits //!< EWRAM code section directive. 32 | #define CSEC_IWRAM .section .iwram, "ax", %progbits //!< IWRAM code section directive. 33 | 34 | #define DSEC_DATA .data //must be word aligned. 34 | \note \a r0 and \a r1 return as \a dst + \a wdn and \a src + \a wdn. 35 | */ 36 | /* Reglist: 37 | r0, r1: dst, src 38 | r2: wdn, then wdn>>3 39 | r3-r10: data buffer 40 | r12: wdn&7 41 | */ 42 | BEGIN_FUNC_ARM(memcpy32, CSEC_IWRAM) 43 | and r12, r2, #7 44 | movs r2, r2, lsr #3 45 | beq .Lres_cpy32 46 | push {r4-r10} 47 | @ copy 32byte chunks with 8fold xxmia 48 | .Lmain_cpy32: 49 | ldmia r1!, {r3-r10} 50 | stmia r0!, {r3-r10} 51 | subs r2, r2, #1 52 | bhi .Lmain_cpy32 53 | pop {r4-r10} 54 | @ and the residual 0-7 words 55 | .Lres_cpy32: 56 | subs r12, r12, #1 57 | ldmcsia r1!, {r3} 58 | stmcsia r0!, {r3} 59 | bhi .Lres_cpy32 60 | bx lr 61 | END_FUNC(memcpy32) 62 | 63 | @ === void memcpy16(void *dst, const void *src, u32 hwn); ============= 64 | /*! \fn void memcpy16(void *dst, const void *src, u32 hwn); 65 | \brief Copy for halfwords. 66 | Uses memcpy32() if \a hwn>6 and 67 | \a src and \a dst are aligned equally. 68 | \param dst Destination address. 69 | \param src Source address. 70 | \param wdn Number of halfwords to fill. 71 | \note \a dst and \a src must be halfword aligned. 72 | \note \a r0 and \a r1 return as \a dst + \a hwn and \a src + \a hwn. 73 | */ 74 | /* Reglist: 75 | r0, r1: dst, src 76 | r2, r4: wdn 77 | r3: tmp; and data buffer 78 | */ 79 | 80 | BEGIN_FUNC_THUMB(memcpy16, CSEC_TEXT) 81 | push {r4, lr} 82 | @ under 5 hwords -> std cpy 83 | cmp r2, #5 84 | bls .Ltail_cpy16 85 | @ unreconcilable alignment -> std cpy 86 | @ if (dst^src)&2 -> alignment impossible 87 | mov r3, r0 88 | eor r3, r1 89 | lsl r3, r3, #31 @ (dst^src), bit 1 into carry 90 | bcs .Ltail_cpy16 @ (dst^src)&2 : must copy by halfword 91 | @ src and dst have same alignment -> word align 92 | lsl r3, r0, #31 93 | bcc .Lmain_cpy16 @ ~src&2 : already word aligned 94 | @ aligning is necessary: copy 1 hword and align 95 | ldrh r3, [r1] 96 | strh r3, [r0] 97 | add r0, #2 98 | add r1, #2 99 | sub r2, r2, #1 100 | @ right, and for the REAL work, we're gonna use memcpy32 101 | .Lmain_cpy16: 102 | lsl r4, r2, #31 103 | lsr r2, r2, #1 104 | ldr r3, =memcpy32 105 | bl .Llong_bl 106 | @ NOTE: r0,r1 are altered by memcpy32, but in exactly the right 107 | @ way, so we can use them as is. 108 | lsr r2, r4, #31 109 | beq .Lend_cpy16 110 | .Ltail_cpy16: 111 | sub r2, #1 112 | bcc .Lend_cpy16 @ r2 was 0, bug out 113 | lsl r2, r2, #1 114 | .Lres_cpy16: 115 | ldrh r3, [r1, r2] 116 | strh r3, [r0, r2] 117 | sub r2, r2, #2 118 | bcs .Lres_cpy16 119 | .Lend_cpy16: 120 | pop {r4} 121 | pop {r3} 122 | .Llong_bl: 123 | bx r3 124 | END_FUNC(memcpy16) 125 | 126 | @ EOF 127 | -------------------------------------------------------------------------------- /arm9/source/tonc_memset.s: -------------------------------------------------------------------------------- 1 | // 2 | // Alignment-safe and fast memset routines 3 | // 4 | //! \file tonc_memcpy.s 5 | //! \author J Vijn 6 | //! \date 20060508 - 20090801 7 | // 8 | // === NOTES === 9 | @ * 20050924: Lower overhead for all; reduced i-count for u16 loops. 10 | @ * These are 16/32bit memset and memcpy. The 32bit versions are in 11 | @ iwram for maximum effect and pretty much do what CpuFastSet does, 12 | @ except that it'll work for non multiples of 8 words too. Speed 13 | @ is as good as CpuFastSet, but with a little less overhead. 14 | @ * The 16bit versions call the 32bit ones if possible and/or desirable. 15 | @ They are thumb/ROM functions but did them in asm anyway because 16 | @ GCC goes haywire with the use of registers resulting in a much 17 | @ higher overhead (i.e., detrimental for low counts) 18 | @ * Crossover with inline while(nn--) loops (not for(ii++), which are 19 | @ much slower): 20 | @ memset32: ~5 21 | @ memset16: ~8 22 | 23 | .file "tonc_memset.s" 24 | 25 | #include "tonc_asminc.h" 26 | 27 | @ === void memset32(void *dst, u32 src, u32 wdn); ===================== 28 | /*! \fn void memset32(void *dst, u32 src, u32 wdn) IWRAM_CODE; 29 | \brief Fast-fill by words. 30 | \param dst Destination address. 31 | \param src Fill word (not address). 32 | \param wdn Number of words to fill. 33 | \note \a dst must be word aligned. 34 | \note \a r0 returns as \a dst + \a wdn. 35 | */ 36 | /* Reglist: 37 | r0, r1: dst, src 38 | r2: wdn, then wdn>>3 39 | r3-r10: data buffer 40 | r12: wdn&7 41 | */ 42 | BEGIN_FUNC_ARM(memset32, CSEC_IWRAM) 43 | and r12, r2, #7 44 | movs r2, r2, lsr #3 45 | beq .Lres_set32 46 | push {r4-r9} 47 | @ set 32byte chunks with 8fold xxmia 48 | mov r3, r1 49 | mov r4, r1 50 | mov r5, r1 51 | mov r6, r1 52 | mov r7, r1 53 | mov r8, r1 54 | mov r9, r1 55 | .Lmain_set32: 56 | stmia r0!, {r1, r3-r9} 57 | subs r2, r2, #1 58 | bhi .Lmain_set32 59 | pop {r4-r9} 60 | @ residual 0-7 words 61 | .Lres_set32: 62 | subs r12, r12, #1 63 | stmhsia r0!, {r1} 64 | bhi .Lres_set32 65 | bx lr 66 | END_FUNC(memset32) 67 | 68 | @ === void memset16(void *dst, u16 src, u32 hwn); ===================== 69 | /*! \fn void memset16(void *dst, u16 src, u32 hwn); 70 | \brief Fill for halfwords. 71 | Uses memset32() if \a hwn>5 72 | \param dst Destination address. 73 | \param src Source halfword (not address). 74 | \param wdn Number of halfwords to fill. 75 | \note \a dst must be halfword aligned. 76 | \note \a r0 returns as \a dst + \a hwn. 77 | */ 78 | /* Reglist: 79 | r0, r1: dst, src 80 | r2, r4: wdn 81 | r3: tmp; and data buffer 82 | */ 83 | BEGIN_FUNC_THUMB(memset16, CSEC_TEXT) 84 | push {r4, lr} 85 | @ under 6 hwords -> std set 86 | cmp r2, #5 87 | bls .Ltail_set16 88 | @ dst not word aligned: copy 1 hword and align 89 | lsl r3, r0, #31 90 | bcc .Lmain_set16 91 | strh r1, [r0] 92 | add r0, #2 93 | sub r2, r2, #1 94 | @ Again, memset32 does the real work 95 | .Lmain_set16: 96 | lsl r4, r1, #16 97 | orr r1, r4 98 | lsl r4, r2, #31 99 | lsr r2, r2, #1 100 | ldr r3, =memset32 101 | bl .Llong_bl 102 | @ NOTE: r0 is altered by memset32, but in exactly the right 103 | @ way, so we can use is as is. r1 is now doubled though. 104 | lsr r2, r4, #31 105 | beq .Lend_set16 106 | lsr r1, #16 107 | .Ltail_set16: 108 | sub r2, #1 109 | bcc .Lend_set16 @ r2 was 0, bug out 110 | lsl r2, r2, #1 111 | .Lres_set16: 112 | strh r1, [r0, r2] 113 | sub r2, r2, #2 114 | bcs .Lres_set16 115 | .Lend_set16: 116 | pop {r4} 117 | pop {r3} 118 | .Llong_bl: 119 | bx r3 120 | END_FUNC(memset16) 121 | 122 | 123 | @ EOF 124 | -------------------------------------------------------------------------------- /arm9/source/w_file.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ds.h" 7 | #include "doomtype.h" 8 | #include "z_zone.h" 9 | #include "w_file.h" 10 | 11 | typedef struct 12 | { 13 | wad_file_t wad; 14 | FILE *fstream; 15 | } stdc_wad_file_t; 16 | 17 | wad_file_class_t stdc_wad_file; 18 | 19 | static wad_file_t *W_StdC_OpenFile(char *path) 20 | { 21 | stdc_wad_file_t *result; 22 | FILE *fstream; 23 | 24 | fstream = fopen(I_FilePath(path), "rb"); 25 | 26 | if(fstream == NULL) 27 | return NULL; 28 | 29 | // Create a new stdc_wad_file_t to hold the file handle. 30 | 31 | result = Z_Malloc(sizeof(stdc_wad_file_t), PU_STATIC, 0); 32 | result->wad.file_class = &stdc_wad_file; 33 | result->wad.mapped = NULL; 34 | result->wad.length = I_FileLength(fstream); 35 | result->fstream = fstream; 36 | 37 | return &result->wad; 38 | } 39 | 40 | static void W_StdC_CloseFile(wad_file_t *wad) 41 | { 42 | stdc_wad_file_t *stdc_wad; 43 | 44 | stdc_wad = (stdc_wad_file_t *) wad; 45 | 46 | fclose(stdc_wad->fstream); 47 | Z_Free(stdc_wad); 48 | } 49 | 50 | // Read data from the specified position in the file into the 51 | // provided buffer. Returns the number of bytes read. 52 | 53 | size_t W_StdC_Read(wad_file_t *wad, unsigned int offset, 54 | void *buffer, size_t buffer_len) 55 | { 56 | stdc_wad_file_t *stdc_wad; 57 | size_t result; 58 | 59 | stdc_wad = (stdc_wad_file_t *) wad; 60 | 61 | // Jump to the specified position in the file. 62 | 63 | fseek(stdc_wad->fstream, offset, SEEK_SET); 64 | 65 | // Read into the buffer. 66 | 67 | result = fread(buffer, 1, buffer_len, stdc_wad->fstream); 68 | 69 | return result; 70 | } 71 | 72 | 73 | wad_file_class_t stdc_wad_file = 74 | { 75 | W_StdC_OpenFile, 76 | W_StdC_CloseFile, 77 | W_StdC_Read, 78 | }; 79 | 80 | wad_file_t *W_OpenFile(char *path) 81 | { 82 | return stdc_wad_file.OpenFile(path); 83 | } 84 | 85 | void W_CloseFile(wad_file_t *wad) 86 | { 87 | wad->file_class->CloseFile(wad); 88 | } 89 | 90 | size_t W_Read(wad_file_t *wad, unsigned int offset, 91 | void *buffer, size_t buffer_len) 92 | { 93 | return wad->file_class->Read(wad, offset, buffer, buffer_len); 94 | } 95 | 96 | // Array of locations to search for IWAD files 97 | // 98 | // "128 IWAD search directories should be enough for anybody". 99 | 100 | #define MAX_IWAD_DIRS 128 101 | 102 | static dboolean iwad_dirs_built = false; 103 | static char *iwad_dirs[MAX_IWAD_DIRS]; 104 | static int num_iwad_dirs = 0; 105 | 106 | static void AddIWADDir(char *dir) 107 | { 108 | if(num_iwad_dirs < MAX_IWAD_DIRS) 109 | { 110 | iwad_dirs[num_iwad_dirs] = dir; 111 | ++num_iwad_dirs; 112 | } 113 | } 114 | 115 | // 116 | // BuildIWADDirList 117 | // Build a list of IWAD files 118 | // 119 | 120 | static void BuildIWADDirList(void) 121 | { 122 | if(iwad_dirs_built) 123 | return; 124 | 125 | // Look in the current directory. Doom always does this. 126 | 127 | AddIWADDir("."); 128 | 129 | #ifndef _WIN32 130 | 131 | // Standard places where IWAD files are installed under Unix. 132 | 133 | AddIWADDir("/usr/share/games/doom64"); 134 | AddIWADDir("/usr/local/share/games/doom64"); 135 | 136 | #endif 137 | 138 | // Don't run this function again. 139 | 140 | iwad_dirs_built = true; 141 | } 142 | 143 | // 144 | // SearchDirectoryForIWAD 145 | // Search a directory to try to find an IWAD 146 | // Returns the location of the IWAD if found, otherwise NULL. 147 | 148 | static char *SearchDirectoryForIWAD(char *dir) 149 | { 150 | char *filename; 151 | char *iwadname; 152 | 153 | iwadname = "DOOM64.WAD"; 154 | filename = malloc(strlen(dir) + strlen(iwadname) + 3); 155 | 156 | if(!strcmp(dir, ".")) 157 | strcpy(filename, iwadname); 158 | else 159 | sprintf(filename, "%s%c%s", dir, '/', iwadname); 160 | 161 | if(I_FileExists(filename)) 162 | return filename; 163 | 164 | free(filename); 165 | 166 | return NULL; 167 | } 168 | 169 | // 170 | // W_FindWADByName 171 | // Searches WAD search paths for an WAD with a specific filename. 172 | // 173 | 174 | char *W_FindWADByName(char *name) 175 | { 176 | char *buf; 177 | int i; 178 | dboolean exists; 179 | 180 | // Absolute path? 181 | if(I_FileExists(name)) 182 | return name; 183 | 184 | BuildIWADDirList(); 185 | 186 | // Search through all IWAD paths for a file with the given name. 187 | 188 | for(i = 0; i < num_iwad_dirs; ++i) 189 | { 190 | // Construct a string for the full path 191 | 192 | buf = malloc(strlen(iwad_dirs[i]) + strlen(name) + 5); 193 | sprintf(buf, "%s%c%s", iwad_dirs[i], '/', name); 194 | 195 | exists = I_FileExists(buf); 196 | 197 | if(exists) 198 | return buf; 199 | 200 | free(buf); 201 | } 202 | 203 | // File not found 204 | 205 | return NULL; 206 | } 207 | 208 | // 209 | // W_TryFindWADByName 210 | // 211 | // Searches for a WAD by its filename, or passes through the filename 212 | // if not found. 213 | // 214 | 215 | char *W_TryFindWADByName(char *filename) 216 | { 217 | char *result; 218 | 219 | result = W_FindWADByName(filename); 220 | 221 | if(result != NULL) 222 | return result; 223 | else 224 | return filename; 225 | } 226 | 227 | // 228 | // W_FindIWAD 229 | // Checks availability of IWAD files by name, 230 | // 231 | 232 | char *W_FindIWAD(void) 233 | { 234 | char *result; 235 | int i; 236 | 237 | result = NULL; 238 | BuildIWADDirList(); 239 | 240 | for(i = 0; result == NULL && i < num_iwad_dirs; ++i) 241 | result = SearchDirectoryForIWAD(iwad_dirs[i]); 242 | 243 | return result; 244 | } 245 | 246 | -------------------------------------------------------------------------------- /arm9/source/w_file.h: -------------------------------------------------------------------------------- 1 | #ifndef __W_FILE__ 2 | #define __W_FILE__ 3 | 4 | #include 5 | #include "doomtype.h" 6 | 7 | typedef struct _wad_file_s wad_file_t; 8 | 9 | typedef struct 10 | { 11 | // Open a file for reading. 12 | 13 | wad_file_t *(*OpenFile)(char *path); 14 | 15 | // Close the specified file. 16 | 17 | void (*CloseFile)(wad_file_t *file); 18 | 19 | // Read data from the specified position in the file into the 20 | // provided buffer. Returns the number of bytes read. 21 | 22 | size_t (*Read)(wad_file_t *file, unsigned int offset, 23 | void *buffer, size_t buffer_len); 24 | 25 | } wad_file_class_t; 26 | 27 | struct _wad_file_s 28 | { 29 | // Class of this file. 30 | 31 | wad_file_class_t *file_class; 32 | 33 | // If this is NULL, the file cannot be mapped into memory. If this 34 | // is non-NULL, it is a pointer to the mapped file. 35 | 36 | byte *mapped; 37 | 38 | // Length of the file, in bytes. 39 | 40 | unsigned int length; 41 | }; 42 | 43 | // Open the specified file. Returns a pointer to a new wad_file_t 44 | // handle for the WAD file, or NULL if it could not be opened. 45 | 46 | wad_file_t *W_OpenFile(char *path); 47 | 48 | // Close the specified WAD file. 49 | 50 | void W_CloseFile(wad_file_t *wad); 51 | 52 | // Read data from the specified file into the provided buffer. The 53 | // data is read from the specified offset from the start of the file. 54 | // Returns the number of bytes read. 55 | 56 | size_t W_Read(wad_file_t *wad, unsigned int offset, 57 | void *buffer, size_t buffer_len); 58 | 59 | char *W_FindWADByName(char *filename); 60 | char *W_TryFindWADByName(char *filename); 61 | char *W_FindIWAD(void); 62 | 63 | #endif /*__W_FILE__*/ 64 | 65 | -------------------------------------------------------------------------------- /arm9/source/w_merge.h: -------------------------------------------------------------------------------- 1 | #ifndef W_MERGE_H 2 | #define W_MERGE_H 3 | 4 | #define W_NWT_MERGE_SPRITES 0x1 5 | #define W_NWT_MERGE_FLATS 0x2 6 | 7 | // Add a new WAD and merge it into the main directory 8 | 9 | void W_MergeFile(char *filename); 10 | 11 | // NWT-style merging 12 | 13 | void W_NWTMergeFile(char *filename, int flags); 14 | 15 | // Acts the same as NWT's "-merge" option. 16 | 17 | void W_NWTDashMerge(char *filename); 18 | 19 | // Debug function that prints the WAD directory. 20 | 21 | void W_PrintDirectory(void); 22 | 23 | #endif /* #ifndef W_MERGE_H */ 24 | 25 | -------------------------------------------------------------------------------- /arm9/source/w_wad.h: -------------------------------------------------------------------------------- 1 | #ifndef __W_WAD__ 2 | #define __W_WAD__ 3 | 4 | #include "d_main.h" 5 | #include "w_file.h" 6 | #include "w_merge.h" 7 | 8 | // 9 | // WADFILE I/O related stuff. 10 | // 11 | typedef struct 12 | { 13 | char name[8]; 14 | wad_file_t* wadfile; 15 | int position; 16 | int size; 17 | int next; 18 | int index; 19 | void* cache; 20 | } lumpinfo_t; 21 | 22 | extern lumpinfo_t* lumpinfo; 23 | extern int numlumps; 24 | 25 | void W_Init(void); 26 | wad_file_t* W_AddFile(char *filename); 27 | unsigned int W_HashLumpName(const char* str); 28 | int W_CheckNumForName(const char* name); 29 | int W_FindNumForName(const char* match); 30 | int W_GetNumForName(const char* name); 31 | int W_LumpLength(int lump); 32 | void W_ReadLump(int lump, void *dest); 33 | void* W_GetMapLump(int lump); 34 | void W_CacheMapLump(int map); 35 | void W_FreeMapLump(void); 36 | int W_MapLumpLength(int lump); 37 | void* W_CacheLumpNum(int lump, int tag); 38 | void* W_CacheLumpName(const char* name, int tag); 39 | 40 | 41 | #endif -------------------------------------------------------------------------------- /arm9/source/z_zone.h: -------------------------------------------------------------------------------- 1 | #ifndef __Z_ZONE__ 2 | #define __Z_ZONE__ 3 | 4 | #undef strdup 5 | 6 | // Include system definitions so that prototypes become 7 | // active before macro replacements below are in effect. 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "doomtype.h" 15 | 16 | // ZONE MEMORY 17 | 18 | // PU - purge tags. 19 | enum 20 | { 21 | PU_STATIC, // block is static (remains until explicitly freed) 22 | PU_MAPLUMP, // block is allocated for data stored in map wads 23 | PU_AUTO, 24 | PU_AUDIO, // allocation of midi data 25 | PU_LEVEL, // allocation belongs to level (freed at next level load) 26 | PU_LEVSPEC, // used for thinker_t's (same as PU_LEVEL basically) 27 | PU_CACHE, // block is cached (may be implicitly freed at any time!) 28 | PU_MAX, // Must always be last -- killough 29 | PU_NEWBLOCK 30 | }; 31 | 32 | #define PU_PURGELEVEL PU_CACHE /* First purgable tag's level */ 33 | #define PU_FREE -1 34 | 35 | void* (Z_Malloc)(int size, int tag, void *user, const char *, int); 36 | void (Z_Free)(void *ptr, const char *, int); 37 | void (Z_FreeTags)(int lowtag, int hightag, const char *, int); 38 | void (Z_ChangeTag)(void *ptr, int tag, const char *, int); 39 | void (Z_Init)(void); 40 | void* (Z_Calloc)(int n, int tag, void *user, const char *, int); 41 | void* (Z_Realloc)(void *ptr, int size, int tag, void *user, const char *, int); 42 | char* (Z_Strdup)(const char *s, int tag, void *user, const char *, int); 43 | char* (Z_Strdupa)(const char *s, const char *file, int line); 44 | void* (Z_Alloca)(int n, const char *file, int line); 45 | void (Z_FreeAlloca)(const char *file, int line); 46 | void (Z_CheckHeap)(const char *,int); // killough 3/22/98: add file/line info 47 | int (Z_CheckTag)(void *,const char *,int); 48 | void (Z_Touch)(void *ptr, const char *, int); 49 | 50 | #define Z_Free(a) (Z_Free) (a, __FILE__,__LINE__) 51 | #define Z_FreeTags(a,b) (Z_FreeTags) (a,b, __FILE__,__LINE__) 52 | #define Z_ChangeTag(a,b) (Z_ChangeTag) (a,b, __FILE__,__LINE__) 53 | #define Z_Malloc(a,b,c) (Z_Malloc) (a,b,c, __FILE__,__LINE__) 54 | #define Z_Strdup(a,b,c) (Z_Strdup) (a,b,c, __FILE__,__LINE__) 55 | #define Z_Strdupa(a) (Z_Strdupa) (a, __FILE__,__LINE__) 56 | #define Z_Calloc(a,b,c) (Z_Calloc) (a,b,c, __FILE__,__LINE__) 57 | #define Z_Realloc(a,b,c,d) (Z_Realloc) (a,b,c,d,__FILE__,__LINE__) 58 | #define Z_Alloca(a) (Z_Alloca) (a, __FILE__,__LINE__) 59 | #define Z_CheckHeap() (Z_CheckHeap) ( __FILE__,__LINE__) 60 | #define Z_CheckTag(a) (Z_CheckTag) (a, __FILE__,__LINE__) 61 | #define Z_Touch(a) (Z_Touch) (a, __FILE__,__LINE__) 62 | #define Z_FreeAlloca() (Z_FreeAlloca) ( __FILE__,__LINE__) 63 | 64 | #define strdup(s) (Z_Strdup) (s, PU_STATIC,0,__FILE__,__LINE__) 65 | 66 | int Z_TagUsage(int tag); 67 | int Z_FreeMemory(void); 68 | 69 | typedef struct vramblock_s vramblock_t; 70 | 71 | struct vramblock_s 72 | { 73 | int size; 74 | short id; 75 | short tag; 76 | int prevtic; 77 | void **gfx; 78 | byte *block; 79 | vramblock_t *prev; 80 | vramblock_t *next; 81 | }; 82 | 83 | typedef struct 84 | { 85 | int size; // total bytes malloced, including header 86 | int free; 87 | vramblock_t blocklist; // start / end cap for linked list 88 | vramblock_t* rover; 89 | } vramzone_t; 90 | 91 | extern vramzone_t* vramzone; 92 | 93 | void Z_VFree(vramzone_t* vram, vramblock_t* block); 94 | vramblock_t* Z_VAlloc(vramzone_t* vram, int size, int tag, void* gfx); 95 | void Z_SetVAllocList(vramzone_t* vram); 96 | void Z_VTouch(vramzone_t* vram, vramblock_t *block); 97 | int Z_FreeVMemory(vramzone_t* vram); 98 | 99 | #endif 100 | 101 | 102 | -------------------------------------------------------------------------------- /wadgen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | project(WadGen) 3 | 4 | find_package(PNG REQUIRED) 5 | 6 | include_directories(${PNG_INCLUDE_DIR}) 7 | 8 | add_executable(WadGen 9 | DeflateN64.c 10 | Files.c 11 | Gfx.c 12 | Level.c 13 | Mem.c 14 | Png.c 15 | Rom.c 16 | SndFont.c 17 | Sound.c 18 | Sprite.c 19 | Texture.c 20 | Wad.c 21 | WadGen.c 22 | ) 23 | 24 | target_link_libraries(WadGen ${PNG_LIBRARY}) 25 | if(WIN32) 26 | target_link_libraries(WadGen comctl32) 27 | endif(WIN32) 28 | -------------------------------------------------------------------------------- /wadgen/Content/ANIMDEFS.TXT: -------------------------------------------------------------------------------- 1 | // 2 | // ANIMATION DEFINITIONS FOR DOOM 64 3 | // 4 | 5 | 6 | animpic "SMONAA" 7 | { 8 | restartdelay = 15 9 | frames = 4 10 | speed = 7 11 | } 12 | 13 | animpic "SMONBA" 14 | { 15 | restartdelay = 0 16 | frames = 4 17 | speed = 1 18 | } 19 | 20 | animpic "SMONCA" 21 | { 22 | restartdelay = 0 23 | frames = 4 24 | speed = 7 25 | } 26 | 27 | animpic "CFACEA" 28 | { 29 | restartdelay = 90 30 | frames = 3 31 | speed = 3 32 | rewind 33 | } 34 | 35 | animpic "SMONDA" 36 | { 37 | restartdelay = 0 38 | frames = 4 39 | speed = 3 40 | } 41 | 42 | animpic "SMONEA" 43 | { 44 | restartdelay = 10 45 | frames = 4 46 | speed = 7 47 | } 48 | 49 | animpic "SPORTA" 50 | { 51 | restartdelay = 0 52 | frames = 9 53 | speed = 3 54 | cyclepalettes 55 | } 56 | 57 | animpic "SMONF" 58 | { 59 | restartdelay = 10 60 | frames = 5 61 | speed = 1 62 | rewind 63 | cyclepalettes 64 | } 65 | 66 | animpic "STRAKR" 67 | { 68 | restartdelay = 10 69 | frames = 5 70 | speed = 1 71 | rewind 72 | cyclepalettes 73 | } 74 | 75 | animpic "STRAKB" 76 | { 77 | restartdelay = 10 78 | frames = 5 79 | speed = 1 80 | rewind 81 | cyclepalettes 82 | } 83 | 84 | animpic "STRAKY" 85 | { 86 | restartdelay = 10 87 | frames = 5 88 | speed = 1 89 | rewind 90 | cyclepalettes 91 | } 92 | 93 | animpic "C307B" 94 | { 95 | restartdelay = 50 96 | frames = 5 97 | speed = 1 98 | rewind 99 | cyclepalettes 100 | } 101 | 102 | animpic "CTEL" 103 | { 104 | restartdelay = 0 105 | frames = 8 106 | speed = 3 107 | cyclepalettes 108 | } 109 | 110 | animpic "CASFL98" 111 | { 112 | restartdelay = 0 113 | frames = 5 114 | speed = 7 115 | rewind 116 | cyclepalettes 117 | } 118 | 119 | animpic "HTELA" 120 | { 121 | restartdelay = 0 122 | frames = 4 123 | speed = 1 124 | rewind 125 | } 126 | 127 | -------------------------------------------------------------------------------- /wadgen/Content/BUTTONS.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/Content/BUTTONS.PNG -------------------------------------------------------------------------------- /wadgen/Content/CONFONT.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/Content/CONFONT.PNG -------------------------------------------------------------------------------- /wadgen/Content/CRSHAIRS.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/Content/CRSHAIRS.PNG -------------------------------------------------------------------------------- /wadgen/Content/FANCRED.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/Content/FANCRED.PNG -------------------------------------------------------------------------------- /wadgen/Content/IDLOGO.LMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/Content/IDLOGO.LMP -------------------------------------------------------------------------------- /wadgen/Content/LOADING.BIN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/Content/LOADING.BIN -------------------------------------------------------------------------------- /wadgen/Content/MAPINFO.TXT: -------------------------------------------------------------------------------- 1 | // 2 | // MAPINFO FOR DOOM 64 3 | // 4 | 5 | map MAP01 "Staging Area" 6 | { 7 | levelnum = 1 8 | music = "MUSAMB04" 9 | classtype = 0 10 | cluster = 0 11 | exitdelay = 15 12 | } 13 | 14 | map MAP02 "The Terraformer" 15 | { 16 | levelnum = 2 17 | music = "MUSAMB05" 18 | classtype = 0 19 | cluster = 0 20 | exitdelay = 15 21 | } 22 | 23 | map MAP03 "Main Engineering" 24 | { 25 | levelnum = 3 26 | music = "MUSAMB13" 27 | classtype = 0 28 | cluster = 0 29 | exitdelay = 15 30 | } 31 | 32 | map MAP04 "Holding Area" 33 | { 34 | levelnum = 4 35 | music = "MUSAMB12" 36 | classtype = 0 37 | cluster = 0 38 | exitdelay = 15 39 | } 40 | 41 | map MAP05 "Tech Center" 42 | { 43 | levelnum = 5 44 | music = "MUSAMB09" 45 | classtype = 0 46 | cluster = 0 47 | exitdelay = 15 48 | } 49 | 50 | map MAP06 "Alpha Quadrant" 51 | { 52 | levelnum = 6 53 | music = "MUSAMB15" 54 | classtype = 0 55 | cluster = 0 56 | exitdelay = 15 57 | } 58 | 59 | map MAP07 "Research Lab" 60 | { 61 | levelnum = 7 62 | music = "MUSAMB16" 63 | classtype = 0 64 | cluster = 0 65 | exitdelay = 15 66 | } 67 | 68 | map MAP08 "Final Outpost" 69 | { 70 | levelnum = 8 71 | music = "MUSAMB18" 72 | classtype = 0 73 | cluster = 0 74 | exitdelay = 15 75 | } 76 | 77 | map MAP09 "Even Simpler" 78 | { 79 | levelnum = 9 80 | music = "MUSAMB03" 81 | classtype = 0 82 | cluster = 1 83 | exitdelay = 15 84 | } 85 | 86 | map MAP10 "The Bleeding" 87 | { 88 | levelnum = 10 89 | music = "MUSAMB06" 90 | classtype = 0 91 | cluster = 0 92 | exitdelay = 15 93 | } 94 | 95 | map MAP11 "Terror Core" 96 | { 97 | levelnum = 11 98 | music = "MUSAMB07" 99 | classtype = 0 100 | cluster = 0 101 | exitdelay = 15 102 | } 103 | 104 | map MAP12 "Altar of Pain" 105 | { 106 | levelnum = 12 107 | music = "MUSAMB10" 108 | classtype = 0 109 | cluster = 0 110 | exitdelay = 15 111 | } 112 | 113 | map MAP13 "Dark Citadel" 114 | { 115 | levelnum = 13 116 | music = "MUSAMB01" 117 | classtype = 0 118 | cluster = 0 119 | exitdelay = 15 120 | } 121 | 122 | map MAP14 "Eye of the Storm" 123 | { 124 | levelnum = 14 125 | music = "MUSAMB14" 126 | classtype = 0 127 | cluster = 0 128 | exitdelay = 15 129 | } 130 | 131 | map MAP15 "Dark Entries" 132 | { 133 | levelnum = 15 134 | music = "MUSAMB19" 135 | classtype = 0 136 | cluster = 0 137 | exitdelay = 15 138 | } 139 | 140 | map MAP16 "Blood Keep" 141 | { 142 | levelnum = 16 143 | music = "MUSAMB05" 144 | classtype = 0 145 | cluster = 0 146 | exitdelay = 15 147 | } 148 | 149 | map MAP17 "Watch Your Step" 150 | { 151 | levelnum = 17 152 | music = "MUSAMB11" 153 | classtype = 0 154 | cluster = 0 155 | exitdelay = 15 156 | } 157 | 158 | map MAP18 "Spawned Fear" 159 | { 160 | levelnum = 18 161 | music = "MUSAMB02" 162 | classtype = 0 163 | cluster = 0 164 | exitdelay = 15 165 | } 166 | 167 | map MAP19 "The Spiral" 168 | { 169 | levelnum = 19 170 | music = "MUSAMB08" 171 | classtype = 0 172 | cluster = 0 173 | exitdelay = 15 174 | } 175 | 176 | map MAP20 "Breakdown" 177 | { 178 | levelnum = 20 179 | music = "MUSAMB20" 180 | classtype = 0 181 | cluster = 0 182 | exitdelay = 15 183 | } 184 | 185 | map MAP21 "Pitfalls" 186 | { 187 | levelnum = 21 188 | music = "MUSAMB17" 189 | classtype = 0 190 | cluster = 0 191 | exitdelay = 15 192 | } 193 | 194 | map MAP22 "Burnt Offerings" 195 | { 196 | levelnum = 22 197 | music = "MUSAMB09" 198 | classtype = 0 199 | cluster = 0 200 | exitdelay = 15 201 | } 202 | 203 | map MAP23 "Unholy Temple" 204 | { 205 | levelnum = 23 206 | music = "MUSAMB16" 207 | classtype = 0 208 | cluster = 0 209 | exitdelay = 15 210 | } 211 | 212 | map MAP24 "No Escape" 213 | { 214 | levelnum = 24 215 | music = "MUSAMB06" 216 | classtype = 0 217 | cluster = 0 218 | exitdelay = 15 219 | } 220 | 221 | map MAP25 "Cat And Mouse" 222 | { 223 | levelnum = 25 224 | music = "MUSAMB05" 225 | classtype = 1 226 | cluster = 0 227 | exitdelay = 15 228 | } 229 | 230 | map MAP26 "HardCore" 231 | { 232 | levelnum = 26 233 | music = "MUSAMB06" 234 | classtype = 1 235 | cluster = 0 236 | exitdelay = 15 237 | } 238 | 239 | map MAP27 "Playground" 240 | { 241 | levelnum = 27 242 | music = "MUSAMB02" 243 | classtype = 1 244 | cluster = 0 245 | exitdelay = 15 246 | } 247 | 248 | map MAP28 "The Absolution" 249 | { 250 | levelnum = 28 251 | music = "MUSAMB07" 252 | classtype = 0 253 | cluster = 6 254 | exitdelay = 120 255 | } 256 | 257 | map MAP29 "Outpost Omega" 258 | { 259 | levelnum = 29 260 | music = "MUSAMB09" 261 | classtype = 0 262 | cluster = 2 263 | exitdelay = 15 264 | } 265 | 266 | map MAP30 "The Lair" 267 | { 268 | levelnum = 30 269 | music = "MUSAMB10" 270 | classtype = 0 271 | cluster = 3 272 | exitdelay = 15 273 | } 274 | 275 | map MAP31 "In The Void" 276 | { 277 | levelnum = 31 278 | music = "MUSAMB11" 279 | classtype = 0 280 | cluster = 4 281 | exitdelay = 15 282 | } 283 | 284 | map MAP32 "Hectic" 285 | { 286 | levelnum = 32 287 | music = "MUSAMB12" 288 | classtype = 0 289 | cluster = 5 290 | exitdelay = 15 291 | clearcheats 292 | } 293 | 294 | map MAP33 "TITLE" 295 | { 296 | levelnum = 33 297 | music = "MUSINTRO" 298 | classtype = 0 299 | cluster = 0 300 | exitdelay = 15 301 | compat_collision = 1 302 | nointermission 303 | continuemusiconexit 304 | forcegodmode 305 | } 306 | 307 | cluster 1 308 | { 309 | pic = "EVIL" 310 | pic_x = 31 311 | pic_y = 1 312 | entertext = "you cackle as the", 313 | "familiarity of the", 314 | "situation occurs to you.", 315 | "The gateway to the Demons", 316 | "domain was too accessible.", 317 | "You realize the demons mock", 318 | "you with their invitation.", 319 | "It does not matter...", 320 | "The demons spawn like rats", 321 | "and you have the grade AAA", 322 | "U.A.C. poison they crave.", 323 | "Your bloodthirsty scream", 324 | "shatters the teleport haze.", 325 | "Once again you find yourself", 326 | "amidst..." 327 | } 328 | 329 | cluster 2 330 | { 331 | pic = "EVIL" 332 | pic_x = 31 333 | pic_y = 1 334 | entertext = "The vast silence", 335 | "reminds you of the", 336 | "military morgue.", 337 | "You knew the", 338 | "installation had a", 339 | "classified level.", 340 | "The U.A.C. had some", 341 | "good reason to hide", 342 | "this place.", 343 | "You wonder what", 344 | "it could be..." 345 | } 346 | 347 | cluster 3 348 | { 349 | pic = "EVIL" 350 | pic_x = 31 351 | pic_y = 1 352 | entertext = "You smile.", 353 | "", 354 | "What strange place have", 355 | "you stumbled upon?", 356 | "", 357 | "The Demons did not expect", 358 | "you to survive this far.", 359 | "You feel their demonic", 360 | "presence waiting for you...", 361 | "", 362 | "Let them taste their guts!" 363 | } 364 | 365 | cluster 4 366 | { 367 | pic = "EVIL" 368 | pic_x = 31 369 | pic_y = 1 370 | entertext = "You wretch as a strange", 371 | "acrid odor assaults you.", 372 | "", 373 | "Death and Demon carcass!", 374 | "", 375 | "No nightmare could have", 376 | "prepared you for this.", 377 | "", 378 | "You realize that this", 379 | "place was not meant for", 380 | "living humans." 381 | } 382 | 383 | cluster 5 384 | { 385 | pic = "EVIL" 386 | pic_x = 31 387 | pic_y = 1 388 | nointermission 389 | entertext = "Congratulations!", 390 | "You found...", 391 | "", 392 | "HECTIC", 393 | "", 394 | "Only the best will reap", 395 | "its rewards." 396 | } 397 | 398 | cluster 6 399 | { 400 | pic = "FINAL" 401 | music = "MUSFINAL" 402 | pic_x = 0 403 | pic_y = 0 404 | scrolltextend 405 | exittext = "Finally...", 406 | "The mother of all demons", 407 | "is dead!", 408 | "", 409 | "The blood pours from", 410 | "your eyes as you stand", 411 | "in defiance.", 412 | "", 413 | "As the only marine to", 414 | "endure the slaughter-", 415 | "you decide to remain", 416 | "in Hell and ensure no", 417 | "demon ever rises again.", 418 | "", 419 | "The End." 420 | } 421 | 422 | -------------------------------------------------------------------------------- /wadgen/Content/PALPLAY3.ACT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/Content/PALPLAY3.ACT -------------------------------------------------------------------------------- /wadgen/Content/SKYDEFS.TXT: -------------------------------------------------------------------------------- 1 | // 2 | // SKY DEFINITIONS FOR DOOM 64 3 | // 4 | 5 | sky "F_SKYA" 6 | { 7 | pic = "CLOUD" 8 | fogcolor = 0 0 0 9 | basecolor = b0 80 ff 10 | highcolor = 0 0 0 11 | lowcolor = 0 0 15 12 | cloud 13 | thunder 14 | fogfactor = 985 15 | } 16 | 17 | sky "F_SKYB" 18 | { 19 | pic = "CLOUD" 20 | fogcolor = 0 0 0 21 | basecolor = ff 30 30 22 | highcolor = 10 0 0 23 | lowcolor = 10 0 0 24 | cloud 25 | fogfactor = 985 26 | } 27 | 28 | sky "F_SKYC" 29 | { 30 | pic = "CLOUD" 31 | backpic = "MOUNTB" 32 | fogcolor = 0 0 0 33 | basecolor = d0 70 40 34 | highcolor = 0 0 0 35 | lowcolor = 40 10 0 36 | cloud 37 | fogfactor = 985 38 | } 39 | 40 | sky "F_SKYD" 41 | { 42 | fogcolor = 0 0 0 43 | basecolor = 0 0 0 44 | highcolor = ff 0 0 45 | lowcolor = ff 60 0 46 | fire 47 | fogfactor = 985 48 | } 49 | 50 | sky "F_SKYE" 51 | { 52 | pic = "CLOUD" 53 | fogcolor = 30 10 8 54 | basecolor = d0 70 40 55 | highcolor = 0 0 0 56 | lowcolor = 40 10 0 57 | cloud 58 | fogfactor = 975 59 | } 60 | 61 | sky "F_SKYF" 62 | { 63 | pic = "SPACE" 64 | fogcolor = 0 0 0 65 | basecolor = 0 0 0 66 | highcolor = 0 0 0 67 | lowcolor = 0 0 0 68 | fogfactor = 985 69 | } 70 | 71 | sky "F_SKYG" 72 | { 73 | pic = "SPACE" 74 | backpic = "EVIL" 75 | fogcolor = 0 0 0 76 | basecolor = 0 0 0 77 | highcolor = 0 0 0 78 | lowcolor = 0 0 0 79 | fadeinbackground 80 | fogfactor = 995 81 | } 82 | 83 | sky "F_SKYH" 84 | { 85 | fogcolor = 0 40 40 86 | basecolor = 0 38 38 87 | highcolor = 0 0 0 88 | lowcolor = 0 0 0 89 | void 90 | fogfactor = 975 91 | } 92 | 93 | sky "F_SKYI" 94 | { 95 | fogcolor = 0 0 0 96 | basecolor = 0 0 0 97 | highcolor = 0 ff 0 98 | lowcolor = 70 70 0 99 | fire 100 | fogfactor = 985 101 | } 102 | 103 | sky "F_SKYJ" 104 | { 105 | pic = "CLOUD" 106 | backpic = "MOUNTC" 107 | fogcolor = 0 0 0 108 | basecolor = b0 80 ff 109 | highcolor = 0 0 0 110 | lowcolor = 0 0 15 111 | cloud 112 | thunder 113 | fogfactor = 985 114 | } 115 | 116 | sky "F_SKYK" 117 | { 118 | pic = "SPACE" 119 | backpic = "MOUNTA" 120 | fogcolor = 0 0 0 121 | basecolor = 0 0 0 122 | highcolor = 0 0 0 123 | lowcolor = 0 0 0 124 | fogfactor = 985 125 | } 126 | 127 | -------------------------------------------------------------------------------- /wadgen/DeflateN64.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_DEFLATE_H_ 2 | #define _WADGEN_DEFLATE_H_ 3 | 4 | void Deflate_Decompress(byte *input, byte *output); 5 | 6 | #endif -------------------------------------------------------------------------------- /wadgen/Files.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_FILES_H_ 2 | #define _WADGEN_FILES_H_ 3 | 4 | typedef struct 5 | { 6 | path filePath; 7 | path fileNoExt; 8 | path fileName; 9 | path basePath; 10 | } wgenfile_t; 11 | 12 | extern wgenfile_t wgenfile; 13 | 14 | #ifdef _WIN32 15 | #define FILEDLGTYPE "Doom64 Rom File (.n64;.z64;.v64) \0*.n64;*.z64;*.v64\0All Files (*.*)\0*.*\0" 16 | 17 | bool File_Dialog(wgenfile_t *wgenfile, const char *type, const char *title, HWND hwnd); 18 | #else 19 | bool File_Prepare(wgenfile_t *wgenfile, const char *filename); 20 | #endif 21 | int File_Open(char const* name); 22 | void File_SetReadOnly(char* name); 23 | void File_Close(int handle); 24 | void File_StripExt(char *name); 25 | void File_Write(int handle, void* source, int length); 26 | int File_Read(char const* name, cache* buffer); 27 | bool File_Poke(const char *file); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /wadgen/Gfx.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_GFX_H_ 2 | #define _WADGEN_GFX_H_ 3 | 4 | #define MAXGFXEXITEMS 128 5 | 6 | typedef struct 7 | { 8 | word compressed; //-1 = not compressed (all gfx lumps are not compressed anyways) 9 | word u2; //unknown 10 | word width; //width (short swapped) 11 | word height; //height (short swapped) 12 | } gfxRomHeader_t; 13 | 14 | typedef struct 15 | { 16 | gfxRomHeader_t header; 17 | cache data; 18 | word palette[256]; //n64 format (16 bit rgb) 19 | } gfxRom_t; 20 | 21 | typedef struct 22 | { 23 | word width; 24 | word height; 25 | word size; //no longer used 26 | word palPos; //no longer used 27 | cache data; 28 | dPalette_t palette[256]; 29 | short dspalette[256]; 30 | int lumpRef; 31 | } gfxEx_t; 32 | 33 | extern gfxEx_t gfxEx[MAXGFXEXITEMS]; 34 | 35 | void Gfx_Setup(void); 36 | 37 | #endif -------------------------------------------------------------------------------- /wadgen/Level.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_LEVEL_H_ 2 | #define _WADGEN_LEVEL_H_ 3 | 4 | #define MAXLEVELWADS 33 5 | 6 | extern cache levelData[MAXLEVELWADS]; 7 | extern int levelSize[MAXLEVELWADS]; 8 | 9 | void Level_Setup(void); 10 | 11 | #endif -------------------------------------------------------------------------------- /wadgen/MD5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is the header file for the MD5 message-digest algorithm. 3 | * The algorithm is due to Ron Rivest. This code was 4 | * written by Colin Plumb in 1993, no copyright is claimed. 5 | * This code is in the public domain; do with it what you wish. 6 | * 7 | * Equivalent code is available from RSA Data Security, Inc. 8 | * This code has been tested against that, and is equivalent, 9 | * except that you don't need to include two pages of legalese 10 | * with every copy. 11 | * 12 | * To compute the message digest of a chunk of bytes, declare an 13 | * md5_context_s structure, pass it to MD5_Init, call MD5_Update as 14 | * needed on buffers full of bytes, and then call MD5_Final, which 15 | * will fill a supplied 16-byte array with the digest. 16 | * 17 | * Changed so as no longer to depend on Colin Plumb's `usual.h' 18 | * header definitions; now uses stuff from dpkg's config.h 19 | * - Ian Jackson . 20 | * Still in the public domain. 21 | */ 22 | 23 | #ifndef MD5_H 24 | #define MD5_H 25 | 26 | #include "WadGen.h" 27 | 28 | #ifdef HAVE_STDINT_H 29 | #include 30 | #endif 31 | 32 | typedef struct md5_context_s md5_context_t; 33 | typedef byte md5_digest_t[16]; 34 | 35 | struct md5_context_s { 36 | uint32_t buf[4]; 37 | uint32_t bytes[2]; 38 | uint32_t in[16]; 39 | }; 40 | 41 | void MD5_Init(md5_context_t *context); 42 | void MD5_Update(md5_context_t *context, byte const *buf, unsigned len); 43 | void MD5_UpdateInt32(md5_context_t *context, unsigned int val); 44 | void MD5_UpdateString(md5_context_t *context, char *str); 45 | void MD5_Final(unsigned char digest[16], md5_context_t *context); 46 | void MD5_Transform(uint32_t buf[4], uint32_t const in[16]); 47 | 48 | #endif /* !MD5_H */ 49 | 50 | -------------------------------------------------------------------------------- /wadgen/Mem.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id: Mem.c 744 2010-08-01 05:13:52Z svkaiser $ 5 | // 6 | // This program is free software; you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation; either version 2 of the License, or 9 | // (at your option) any later version. 10 | 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program; if not, write to the Free Software 18 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | // 20 | // $Author: svkaiser $ 21 | // $Revision: 744 $ 22 | // $Date: 2010-08-01 00:13:52 -0500 (Sun, 01 Aug 2010) $ 23 | // 24 | // DESCRIPTION: Memory allocation stuff 25 | // 26 | //----------------------------------------------------------------------------- 27 | #ifdef RCSID 28 | static const char rcsid[] = "$Id: Mem.c 744 2010-08-01 05:13:52Z svkaiser $"; 29 | #endif 30 | 31 | #include "WadGen.h" 32 | #include 33 | 34 | //************************************************************** 35 | //************************************************************** 36 | // Mem_Alloc 37 | //************************************************************** 38 | //************************************************************** 39 | 40 | void* Mem_Alloc(int size) 41 | { 42 | void *ret = calloc(1, size); 43 | if(!ret) 44 | WGen_Complain("Mem_Alloc: Out of memory"); 45 | 46 | return ret; 47 | } 48 | 49 | //************************************************************** 50 | //************************************************************** 51 | // Mem_Free 52 | //************************************************************** 53 | //************************************************************** 54 | 55 | void Mem_Free(void **ptr) 56 | { 57 | if(!*ptr) 58 | WGen_Complain("Mem_Free: Tried to free NULL"); 59 | 60 | free(*ptr); 61 | *ptr = NULL; 62 | } 63 | -------------------------------------------------------------------------------- /wadgen/Mem.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEM_H_ 2 | #define _MEM_H_ 3 | 4 | void* Mem_Alloc(int size); 5 | void Mem_Free(void **ptr); 6 | 7 | #endif -------------------------------------------------------------------------------- /wadgen/Rom.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_ROM_H_ 2 | #define _WADGEN_ROM_H_ 3 | 4 | #define ROMHEADERSIZE 64 5 | 6 | /* From Daedalus */ 7 | typedef struct 8 | { 9 | byte x1; /* initial PI_BSB_DOM1_LAT_REG value */ 10 | byte x2; /* initial PI_BSB_DOM1_PGS_REG value */ 11 | byte x3; /* initial PI_BSB_DOM1_PWD_REG value */ 12 | byte x4; /* initial PI_BSB_DOM1_RLS_REG value */ 13 | unsigned int ClockRate; 14 | unsigned int BootAddress; 15 | unsigned int Release; 16 | unsigned int CRC1; 17 | unsigned int CRC2; 18 | unsigned int Unknown0; 19 | unsigned int Unknown1; 20 | char Name[20]; 21 | unsigned int Unknown2; 22 | unsigned short int Unknown3; 23 | byte Unknown4; 24 | byte Manufacturer; 25 | unsigned short int CartID; 26 | char CountryID; 27 | byte VersionID; 28 | } romHeader_t; 29 | 30 | typedef struct 31 | { 32 | romHeader_t header; 33 | cache data; 34 | uint length; 35 | } rom_t; 36 | 37 | typedef struct 38 | { 39 | char* name; 40 | char* countryID; // E = US, J = Japan, P = PAL/Europe, X = US (v1.1) 41 | } romLumpSpecial_t; 42 | 43 | extern rom_t RomFile; 44 | 45 | void Rom_Open(void); 46 | void Rom_Close(void); 47 | bool Rom_VerifyRomCode(const romLumpSpecial_t* l); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /wadgen/Sound.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_SOUND_H_ 2 | #define _WADGEN_SOUND_H_ 3 | 4 | #define SFX_DATASIZE 0x1716D0 5 | 6 | extern byte* sfxdata; 7 | 8 | typedef struct 9 | { 10 | char id[4]; 11 | uint game_id; // must be 2 12 | uint pad1; 13 | uint version_id; // always 100. not read or used in game 14 | uint pad2; 15 | uint pad3; 16 | uint len1; // length of file minus header size 17 | uint pad4; 18 | uint ninst; // number of instruments (31) 19 | word npatch; // number of patches 20 | word patchsiz; // sizeof patch struct 21 | word nsubpatch; // number of subpatches 22 | word subpatchsiz; // sizeof subpatch struct 23 | word nsfx; // number of sfx 24 | word sfxsiz; // sizeof sfx struct 25 | uint pad5; 26 | uint pad6; 27 | } sn64_t; 28 | 29 | extern sn64_t* sn64; 30 | extern uint sn64size; 31 | 32 | typedef struct 33 | { 34 | word length; // length (little endian) 35 | word offset; // offset in sn64 file 36 | } patch_t; 37 | 38 | typedef struct 39 | { 40 | byte unitypitch; // unknown; used by N64 library 41 | byte attenuation; // attenuation 42 | byte pan; // left/right panning 43 | byte instrument; // (boolean) treat this as an instrument? 44 | byte rootkey; // instrument's root key 45 | byte detune; // detune key (20120327 villsa - identified) 46 | byte minnote; // use this subpatch if played note > minnote 47 | byte maxnote; // use this subpatch if played note < maxnote 48 | byte pwheelrange_l; // pitch wheel low range (20120326 villsa - identified) 49 | byte pwheelrange_h; // pitch wheel high range (20120326 villsa - identified) 50 | word id; // sfx id 51 | short attacktime; // attack time (fade in) 52 | byte unk_0e; 53 | byte unk_0f; 54 | short decaytime; // decay time (fade out) 55 | byte volume1; // volume (unknown purpose) 56 | byte volume2; // volume (unused?) 57 | } subpatch_t; 58 | 59 | typedef struct 60 | { 61 | uint start; // start of rom offset 62 | uint size; // size of sfx 63 | uint wavsize; // suppose to be pad1 but used as temp size for wavdata 64 | uint pitch; // correction pitch 65 | uint loopid; // index id for loop table 66 | uint ptrindex; // suppose to be pad3 but used as pointer index by wadgen 67 | } wavtable_t; 68 | 69 | extern wavtable_t* sfx; 70 | extern cache* wavtabledata; 71 | 72 | typedef struct 73 | { 74 | word nsfx1; // sfx count (124) 75 | word pad1; 76 | word ncount; // loop data count (23) 77 | word nsfx2; // sfx count again?? (124) 78 | } loopinfo_t; 79 | 80 | typedef struct 81 | { 82 | uint loopstart; 83 | uint loopend; 84 | uint data[10]; // its nothing but pure initialized garbage in rom but changed/set in game 85 | } looptable_t; 86 | 87 | extern looptable_t* looptable; 88 | 89 | typedef struct 90 | { 91 | uint order; // order id 92 | uint npredictors; // number of predictors 93 | short preds[128]; // predictor array 94 | } predictor_t; 95 | 96 | typedef struct 97 | { 98 | char id[4]; 99 | uint game_id; // must be 2 100 | uint pad1; 101 | uint nentry; // number of entries 102 | uint pad2; 103 | uint pad3; 104 | uint entrysiz; // sizeof(entry) * nentry 105 | uint pad4; 106 | } sseq_t; 107 | 108 | extern sseq_t* sseq; 109 | extern uint sseqsize; 110 | 111 | typedef struct 112 | { 113 | word ntrack; // number of tracks 114 | word pad1; 115 | uint length; // length of entry 116 | uint offset; // offset in sseq file 117 | uint pad2; 118 | } entry_t; 119 | 120 | extern entry_t* entries; 121 | 122 | typedef struct 123 | { 124 | word flag; // usually 0 on sounds, 0x100 on musics 125 | word id; // subpatch id 126 | word pad1; 127 | byte volume; // default volume 128 | byte pan; // default pan 129 | word pad2; 130 | word bpm; // beats per minute 131 | word timediv; 132 | word loop; // 0 if no looping, 1 if yes 133 | word pad3; 134 | word datalen; // length of midi data 135 | } track_t; 136 | 137 | typedef struct 138 | { 139 | char header[4]; 140 | int length; 141 | byte* data; 142 | } miditrack_t; 143 | 144 | typedef struct 145 | { 146 | char header[4]; 147 | int chunksize; 148 | short type; 149 | word ntracks; 150 | word delta; 151 | uint size; 152 | miditrack_t* tracks; 153 | } midiheader_t; 154 | 155 | extern midiheader_t* midis; 156 | extern const char* sndlumpnames[]; 157 | 158 | void Sound_Setup(void); 159 | 160 | #endif -------------------------------------------------------------------------------- /wadgen/Sprite.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_SPRITE_H_ 2 | #define _WADGEN_SPRITE_H_ 3 | 4 | #define MAX_SPRITES 2048 5 | #define CMPPALCOUNT 16 6 | 7 | extern int spriteExCount; 8 | extern int hudSpriteExCount; 9 | extern int extPalLumpCount; 10 | 11 | #define INSPRITELIST(x) (x >= Wad_GetLumpNum("S_START") && x <= Wad_GetLumpNum("S_END")) 12 | 13 | //N64 sprite format 14 | typedef struct 15 | { 16 | short tiles; // how many tiles the sprite is divided into 17 | short compressed; // >=0 = 'two for one' byte compression, -1 = not compressed 18 | short cmpsize; // actual compressed size (0 if not compressed) 19 | short xoffs; // draw x offset 20 | short yoffs; // draw y offset 21 | short width; // draw width 22 | short height; // draw height 23 | short tileheight; // y height per tile piece 24 | } d64RawSprite_t; 25 | 26 | //D64EX sprite format 27 | typedef struct 28 | { 29 | short width; // draw width 30 | short height; // draw height 31 | short offsetx; // draw x offset 32 | short offsety; // draw y offset 33 | short useExtPal; // true = use internal palette, false = use external lump palette (for hi colored sprites) 34 | } d64ExSprite_t; 35 | 36 | typedef struct 37 | { 38 | d64ExSprite_t sprite; 39 | cache data; 40 | dPalette_t palette[256]; 41 | short dspalette[256]; 42 | word numtiles; 43 | short* tiles; 44 | int size; 45 | int lumpRef; 46 | } d64ExSpriteLump_t; 47 | 48 | extern d64ExSpriteLump_t exSpriteLump[MAX_SPRITES]; 49 | 50 | typedef struct 51 | { 52 | dPalette_t extPalLumps[256]; 53 | char name[8]; 54 | } d64PaletteLump_t; 55 | 56 | extern d64PaletteLump_t d64PaletteLump[24]; 57 | 58 | void Sprite_Setup(void); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /wadgen/Texture.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id: Texture.c 1096 2012-03-31 18:28:01Z svkaiser $ 5 | // 6 | // This program is free software; you can redistribute it and/or modify 7 | // it under the terms of the GNU General Public License as published by 8 | // the Free Software Foundation; either version 2 of the License, or 9 | // (at your option) any later version. 10 | 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program; if not, write to the Free Software 18 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | // 20 | // $Author: svkaiser $ 21 | // $Revision: 1096 $ 22 | // $Date: 2012-03-31 13:28:01 -0500 (Sat, 31 Mar 2012) $ 23 | // 24 | // DESCRIPTION: Texture parsing and converting 25 | // 26 | //----------------------------------------------------------------------------- 27 | #ifdef RCSID 28 | static const char rcsid[] = "$Id: Texture.c 1096 2012-03-31 18:28:01Z svkaiser $"; 29 | #endif 30 | 31 | #include "WadGen.h" 32 | #include "Wad.h" 33 | #include "Texture.h" 34 | 35 | static d64RawTexture_t d64RomTexture[MAXTEXTURES]; 36 | d64ExTexture_t d64ExTexture[MAXTEXTURES]; 37 | 38 | //************************************************************** 39 | //************************************************************** 40 | // Texture_CreateRomLump 41 | // Bytes are read differently on the N64, so flip the nibbles per byte 42 | // Depending on the width, each number of rows would have each four bytes 43 | // flipped like the sprites. 44 | //************************************************************** 45 | //************************************************************** 46 | 47 | void Texture_CreateRomLump(d64RawTexture_t *tex, cache data) 48 | { 49 | int size = 0; 50 | int palsize = 0; 51 | int mask = 0; 52 | int i = 0; 53 | int *tmpSrc; 54 | 55 | memset(tex, 0, sizeof(d64RawTexture_t)); 56 | memcpy(&tex->header, data, sizeof(d64RawTextureHeader_t)); 57 | 58 | tex->header.hshift = _SWAP16(tex->header.hshift); 59 | tex->header.id = _SWAP16(tex->header.id); 60 | tex->header.numpal = _SWAP16(tex->header.numpal); 61 | tex->header.wshift = _SWAP16(tex->header.wshift); 62 | 63 | size = ((1<header.wshift) * (1<header.hshift))>>1; 64 | mask = (1<header.wshift) / 8; 65 | 66 | _PAD8(size); 67 | 68 | tex->data = (byte*)Mem_Alloc(size); 69 | memcpy(tex->data, data + (sizeof(d64RawTextureHeader_t)), size); 70 | 71 | palsize = sizeof(short) * (NUMTEXPALETTES * tex->header.numpal); 72 | tex->palette = (word*)Mem_Alloc(palsize); 73 | memcpy(tex->palette, data + (sizeof(d64RawTextureHeader_t) + size), palsize); 74 | 75 | // Flip nibbles per byte 76 | for(i = 0; i < size; i++) 77 | { 78 | byte tmp = tex->data[i]; 79 | 80 | tex->data[i] = (tmp >> 4); 81 | tex->data[i] |= ((tmp & 0xf) << 4); 82 | } 83 | 84 | tmpSrc = (int*)(tex->data); 85 | 86 | // Flip each sets of dwords based on texture width 87 | for(i = 0; i < size/4; i+=2) 88 | { 89 | int x1; 90 | int x2; 91 | 92 | if(i & mask) 93 | { 94 | x1 = *(int*)(tmpSrc+i); 95 | x2 = *(int*)(tmpSrc+i+1); 96 | 97 | *(int*)(tmpSrc+i) = x2; 98 | *(int*)(tmpSrc+i+1) = x1; 99 | } 100 | } 101 | } 102 | 103 | //************************************************************** 104 | //************************************************************** 105 | // Texture_CreateExLump 106 | // Setup a new Doom64 EX texture 107 | //************************************************************** 108 | //************************************************************** 109 | 110 | void Texture_CreateExLump(d64ExTexture_t *pcTex, d64RawTexture_t *romTex) 111 | { 112 | int i = 0; 113 | int j; 114 | int w, h; 115 | int dw, dh; 116 | 117 | memset(pcTex, 0, sizeof(d64ExTexture_t)); 118 | 119 | w = 1 << romTex->header.wshift; 120 | h = 1 << romTex->header.hshift; 121 | 122 | dw = WGen_GetSizeDS(w); 123 | dh = WGen_GetSizeDS(h); 124 | 125 | pcTex->header.dsw = dw; 126 | pcTex->header.dsh = dh; 127 | pcTex->header.numpal = romTex->header.numpal; 128 | pcTex->size = (w * h) >> 1; 129 | 130 | pcTex->data = (byte*)Mem_Alloc(pcTex->size); 131 | memcpy(pcTex->data, romTex->data, pcTex->size); 132 | 133 | for(i = 0; i < romTex->header.numpal; i++) 134 | WGen_ConvertN64Pal(pcTex->palette[i], romTex->palette + (i * NUMTEXPALETTES), NUMTEXPALETTES); 135 | 136 | for(i = 0; i < romTex->header.numpal; i++) 137 | { 138 | for(j = 0; j < 16; j++) 139 | pcTex->dspalette[i][j] = 140 | RGBDS( 141 | pcTex->palette[i][j].r, 142 | pcTex->palette[i][j].g, 143 | pcTex->palette[i][j].b 144 | ); 145 | } 146 | } 147 | 148 | //************************************************************** 149 | //************************************************************** 150 | // Texture_Setup 151 | //************************************************************** 152 | //************************************************************** 153 | 154 | void Texture_Setup(void) 155 | { 156 | int i = 0; 157 | int pos = 0; 158 | 159 | for(i = Wad_GetLumpNum("T_START")+1; i < Wad_GetLumpNum("T_END"); i++) 160 | { 161 | romWadFile.lumpcache[i] = Wad_GetLump(romWadFile.lump[i].name, true); 162 | 163 | Texture_CreateRomLump(&d64RomTexture[pos], romWadFile.lumpcache[i]); 164 | Texture_CreateExLump(&d64ExTexture[pos], &d64RomTexture[pos]); 165 | 166 | // Masked textures are identified by having its first palette color all 0s, but 167 | // the nukage textures appear to have 0 RGB for its first palette color.. which 168 | // causes them to be masked or see-through. This hack will prevent that.. 169 | 170 | if(i == Wad_GetLumpNum("SLIMEA") || i == Wad_GetLumpNum("SLIMEB")) 171 | { 172 | d64ExTexture[pos].palette[0][0].r = 173 | d64ExTexture[pos].palette[0][0].g = 174 | d64ExTexture[pos].palette[0][0].b = 1; 175 | } 176 | 177 | d64ExTexture[pos++].lumpRef = i; 178 | 179 | WGen_UpdateProgress("Converting Textures..."); 180 | } 181 | } -------------------------------------------------------------------------------- /wadgen/Texture.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_TEX_H_ 2 | #define _WADGEN_TEX_H_ 3 | 4 | #define MAXPALETTES 16 5 | #define NUMTEXPALETTES 16 6 | #define MAXTEXTURES 800 7 | 8 | // N64 Texture format 9 | 10 | typedef struct 11 | { 12 | word id; 13 | word numpal; 14 | word wshift; 15 | word hshift; 16 | } d64RawTextureHeader_t; 17 | 18 | typedef struct 19 | { 20 | d64RawTextureHeader_t header; 21 | cache data; 22 | word *palette; 23 | } d64RawTexture_t; 24 | 25 | // D64EX texture format 26 | 27 | typedef struct 28 | { 29 | byte dsw; 30 | byte dsh; 31 | short numpal; 32 | } d64ExTextureHeader_t; 33 | 34 | typedef struct 35 | { 36 | d64ExTextureHeader_t header; 37 | cache data; 38 | dPalette_t palette[MAXPALETTES][NUMTEXPALETTES]; 39 | short dspalette[MAXPALETTES][NUMTEXPALETTES]; 40 | int size; 41 | int lumpRef; 42 | } d64ExTexture_t; 43 | 44 | extern d64ExTexture_t d64ExTexture[MAXTEXTURES]; 45 | 46 | void Texture_Setup(void); 47 | 48 | #endif -------------------------------------------------------------------------------- /wadgen/Wad.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_WAD_H_ 2 | #define _WADGEN_WAD_H_ 3 | 4 | #include "Sprite.h" 5 | #include "Gfx.h" 6 | #include "Texture.h" 7 | #include "Sound.h" 8 | 9 | #define MAX_LUMPS 4096 10 | 11 | #ifdef _MSC_VER 12 | #pragma pack(push, 1) 13 | #endif 14 | 15 | typedef struct 16 | { 17 | char id[4]; 18 | int lmpcount; 19 | int lmpdirpos; 20 | } wadheader_t; 21 | 22 | typedef struct 23 | { 24 | int filepos; 25 | int size; 26 | char name[8]; 27 | } lump_t; 28 | 29 | #ifdef _MSC_VER 30 | #pragma pack(pop) 31 | #endif 32 | 33 | typedef struct 34 | { 35 | wadheader_t header; 36 | lump_t lump[MAX_LUMPS]; 37 | cache lumpcache[MAX_LUMPS]; 38 | uint size; 39 | } wadFile_t; 40 | 41 | extern wadFile_t romWadFile; 42 | extern wadFile_t outWadFile; 43 | 44 | void Wad_GetIwad(void); 45 | int Wad_GetLumpNum(const char* name); 46 | void* Wad_GetLump(char* name, bool dcmpType); 47 | void Wad_CreateOutput(void); 48 | void Wad_WriteOutput(path outFile); 49 | void Wad_AddOutputSprite(d64ExSpriteLump_t* sprite); 50 | void Wad_AddOutputTexture(d64ExTexture_t* tex); 51 | void Wad_AddOutputGfx(gfxEx_t* gfx); 52 | void Wad_AddOutputHudSprite(d64ExSpriteLump_t* sprite); 53 | void Wad_AddOutputPalette(d64PaletteLump_t* palette); 54 | void Wad_AddOutputMidi(midiheader_t* mthd, int index); 55 | void Wad_AddOutputLump(const char* name, int size, cache data); 56 | 57 | #endif -------------------------------------------------------------------------------- /wadgen/WadGen.h: -------------------------------------------------------------------------------- 1 | #ifndef _WADGEN_H_ 2 | #define _WADGEN_H_ 3 | 4 | #ifdef _WIN32 5 | #include "SDL_config.h" 6 | #else 7 | #include 8 | #endif 9 | 10 | //#define PLATFORM_PC 11 | #define PLATFORM_DS 12 | 13 | #ifdef _WIN32 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #else 20 | #include 21 | #define MAX_PATH PATH_MAX 22 | #define ZeroMemory(a,l) memset(a, 0, l) 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Mem.h" 32 | 33 | //#define USE_SOUNDFONTS 34 | 35 | #pragma warning(disable:4996) 36 | 37 | typedef unsigned char byte; 38 | typedef unsigned short word; 39 | typedef unsigned int uint; 40 | typedef int32_t int32; 41 | typedef uint32_t uint32; 42 | typedef int bool; 43 | typedef byte* cache; 44 | typedef char path[MAX_PATH]; 45 | 46 | #define false 0 47 | #define true 1 48 | 49 | typedef struct 50 | { 51 | byte r; 52 | byte g; 53 | byte b; 54 | byte a; 55 | } dPalette_t; 56 | 57 | #define RGBDS(r,g,b) (((r)>>3)|(((g)>>3)<<5)|(((b)>>3)<<10)) 58 | 59 | #ifdef _WIN32 60 | extern HWND hwnd; 61 | extern HWND hwndWait; 62 | #endif 63 | extern int myargc; 64 | extern char** myargv; 65 | 66 | int WGen_Swap16(int x); 67 | uint WGen_Swap32(unsigned int x); 68 | 69 | #define _SWAP16(x) WGen_Swap16(x) 70 | #define _SWAP32(x) WGen_Swap32(x) 71 | #define _PAD4(x) x += (4 - ((uint) x & 3)) & 3 72 | #define _PAD8(x) x += (8 - ((uint) x & 7)) & 7 73 | #define _PAD16(x) x += (16 - ((uint) x & 15)) & 15 74 | 75 | void WGen_Printf(char* s, ...); 76 | void WGen_Complain(char *fmt, ...); 77 | void WGen_UpdateProgress(char *fmt, ...); 78 | void WGen_ConvertN64Pal(dPalette_t* palette, word* data, int indexes); 79 | void WGen_AddDigest(char* name, int lump, int size); 80 | int WGen_GetSizeDS(int size); 81 | 82 | #define TOTALSTEPS 3500 83 | 84 | #ifndef _WIN32 85 | static inline char* strupr(char* in) 86 | { 87 | char* ptr = in; 88 | while(*ptr != '\0') 89 | { 90 | *ptr = toupper(*ptr); 91 | ptr++; 92 | } 93 | return in; 94 | } 95 | #endif 96 | 97 | #include "MD5.h" 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /wadgen/msvc6/WadGen.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/msvc6/WadGen.aps -------------------------------------------------------------------------------- /wadgen/msvc6/WadGen.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="WadGen" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=WadGen - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "WadGen.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "WadGen.mak" CFG="WadGen - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "WadGen - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "WadGen - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "WadGen - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c 46 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR /YX /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 50 | # ADD RSC /l 0x409 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 56 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib libpng13.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"MSVCRT" /out:"bin/WadGen.exe" 57 | # SUBTRACT LINK32 /nodefaultlib 58 | 59 | !ELSEIF "$(CFG)" == "WadGen - Win32 Debug" 60 | 61 | # PROP BASE Use_MFC 0 62 | # PROP BASE Use_Debug_Libraries 1 63 | # PROP BASE Output_Dir "Debug" 64 | # PROP BASE Intermediate_Dir "Debug" 65 | # PROP BASE Target_Dir "" 66 | # PROP Use_MFC 0 67 | # PROP Use_Debug_Libraries 1 68 | # PROP Output_Dir "Debug" 69 | # PROP Intermediate_Dir "Debug" 70 | # PROP Ignore_Export_Lib 0 71 | # PROP Target_Dir "" 72 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c 73 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /YX /FD /GZ /c 74 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 75 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 76 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 77 | # ADD RSC /l 0x409 /d "_DEBUG" 78 | BSC32=bscmake.exe 79 | # ADD BASE BSC32 /nologo 80 | # ADD BSC32 /nologo 81 | LINK32=link.exe 82 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 83 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"MSVCRT" /out:"bin/WadGen.exe" /pdbtype:sept 84 | 85 | !ENDIF 86 | 87 | # Begin Target 88 | 89 | # Name "WadGen - Win32 Release" 90 | # Name "WadGen - Win32 Debug" 91 | # Begin Group "Source Files" 92 | 93 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 94 | # Begin Source File 95 | 96 | SOURCE=.\..\DeflateN64.c 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=.\..\Files.c 101 | # End Source File 102 | # Begin Source File 103 | 104 | SOURCE=.\..\Gfx.c 105 | # End Source File 106 | # Begin Source File 107 | 108 | SOURCE=.\..\Level.c 109 | # End Source File 110 | # Begin Source File 111 | 112 | SOURCE=..\MD5.c 113 | # End Source File 114 | # Begin Source File 115 | 116 | SOURCE=.\..\Mem.c 117 | # End Source File 118 | # Begin Source File 119 | 120 | SOURCE=.\..\Rom.c 121 | # End Source File 122 | # Begin Source File 123 | 124 | SOURCE=.\..\SndFont.c 125 | # End Source File 126 | # Begin Source File 127 | 128 | SOURCE=.\..\Sound.c 129 | # End Source File 130 | # Begin Source File 131 | 132 | SOURCE=.\..\Sprite.c 133 | # End Source File 134 | # Begin Source File 135 | 136 | SOURCE=.\..\Texture.c 137 | # End Source File 138 | # Begin Source File 139 | 140 | SOURCE=.\..\Wad.c 141 | # End Source File 142 | # Begin Source File 143 | 144 | SOURCE=.\..\WadGen.c 145 | # End Source File 146 | # End Group 147 | # Begin Group "Header Files" 148 | 149 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 150 | # Begin Source File 151 | 152 | SOURCE=.\..\DeflateN64.h 153 | # End Source File 154 | # Begin Source File 155 | 156 | SOURCE=.\..\Files.h 157 | # End Source File 158 | # Begin Source File 159 | 160 | SOURCE=.\..\Gfx.h 161 | # End Source File 162 | # Begin Source File 163 | 164 | SOURCE=.\..\Level.h 165 | # End Source File 166 | # Begin Source File 167 | 168 | SOURCE=..\MD5.h 169 | # End Source File 170 | # Begin Source File 171 | 172 | SOURCE=.\..\Mem.h 173 | # End Source File 174 | # Begin Source File 175 | 176 | SOURCE=.\..\Rom.h 177 | # End Source File 178 | # Begin Source File 179 | 180 | SOURCE=.\..\SndFont.h 181 | # End Source File 182 | # Begin Source File 183 | 184 | SOURCE=.\..\Sound.h 185 | # End Source File 186 | # Begin Source File 187 | 188 | SOURCE=.\..\Sprite.h 189 | # End Source File 190 | # Begin Source File 191 | 192 | SOURCE=.\..\Texture.h 193 | # End Source File 194 | # Begin Source File 195 | 196 | SOURCE=.\..\Wad.h 197 | # End Source File 198 | # Begin Source File 199 | 200 | SOURCE=.\..\WadGen.h 201 | # End Source File 202 | # End Group 203 | # Begin Group "Resource Files" 204 | 205 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 206 | # Begin Source File 207 | 208 | SOURCE=.\icon.ico 209 | # End Source File 210 | # Begin Source File 211 | 212 | SOURCE=..\..\kex\msvc6\resource.h 213 | # End Source File 214 | # Begin Source File 215 | 216 | SOURCE=.\WadGen.rc 217 | # End Source File 218 | # End Group 219 | # End Target 220 | # End Project 221 | -------------------------------------------------------------------------------- /wadgen/msvc6/WadGen.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "WadGen"=.\WadGen.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /wadgen/msvc6/WadGen.rc: -------------------------------------------------------------------------------- 1 | //Microsoft Developer Studio generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (U.S.) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | #pragma code_page(1252) 22 | #endif //_WIN32 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Dialog 27 | // 28 | 29 | IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 242, 51 30 | STYLE DS_SYSMODAL | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE 31 | FONT 8, "MS Sans Serif" 32 | BEGIN 33 | CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | 34 | WS_BORDER,15,33,210,11 35 | CTEXT "",IDC_PROGRESSTEXT,73,19,95,9 36 | CTEXT "Creating game files from ROM",IDC_STATIC,73,4,95,9 37 | END 38 | 39 | 40 | #ifdef APSTUDIO_INVOKED 41 | ///////////////////////////////////////////////////////////////////////////// 42 | // 43 | // TEXTINCLUDE 44 | // 45 | 46 | 1 TEXTINCLUDE DISCARDABLE 47 | BEGIN 48 | "resource.h\0" 49 | END 50 | 51 | 2 TEXTINCLUDE DISCARDABLE 52 | BEGIN 53 | "#include ""afxres.h""\r\n" 54 | "\0" 55 | END 56 | 57 | 3 TEXTINCLUDE DISCARDABLE 58 | BEGIN 59 | "\r\n" 60 | "\0" 61 | END 62 | 63 | #endif // APSTUDIO_INVOKED 64 | 65 | 66 | ///////////////////////////////////////////////////////////////////////////// 67 | // 68 | // Icon 69 | // 70 | 71 | // Icon with lowest ID value placed first to ensure application icon 72 | // remains consistent on all systems. 73 | IDI_ICON1 ICON DISCARDABLE "icon.ico" 74 | #endif // English (U.S.) resources 75 | ///////////////////////////////////////////////////////////////////////////// 76 | 77 | 78 | 79 | #ifndef APSTUDIO_INVOKED 80 | ///////////////////////////////////////////////////////////////////////////// 81 | // 82 | // Generated from the TEXTINCLUDE 3 resource. 83 | // 84 | 85 | 86 | ///////////////////////////////////////////////////////////////////////////// 87 | #endif // not APSTUDIO_INVOKED 88 | 89 | -------------------------------------------------------------------------------- /wadgen/msvc6/bin/WadGen.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/msvc6/bin/WadGen.exe -------------------------------------------------------------------------------- /wadgen/msvc6/bin/libpng13.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/msvc6/bin/libpng13.dll -------------------------------------------------------------------------------- /wadgen/msvc6/bin/zlib1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/msvc6/bin/zlib1.dll -------------------------------------------------------------------------------- /wadgen/msvc6/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svkaiser/doom64DS/b28e5060a0d2fcda9475910f74323a446483986d/wadgen/msvc6/icon.ico -------------------------------------------------------------------------------- /wadgen/msvc6/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by WadGen.rc 4 | // 5 | #define IDD_DIALOG1 101 6 | #define IDI_ICON1 103 7 | #define IDD_DIALOG2 104 8 | #define IDC_PROGRESS 1002 9 | #define IDC_PROGRESSTEXT 1003 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NEXT_RESOURCE_VALUE 105 16 | #define _APS_NEXT_COMMAND_VALUE 40001 17 | #define _APS_NEXT_CONTROL_VALUE 1004 18 | #define _APS_NEXT_SYMED_VALUE 101 19 | #endif 20 | #endif 21 | --------------------------------------------------------------------------------