Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ GTAGS
# Wii U specific
*.elf
*.rpx
*.wuhb
build/
79 changes: 73 additions & 6 deletions Makefile.wiiu
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,71 @@ ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif

#-------------------------------------------------------------------------------
# APP_NAME sets the long name of the application
# APP_SHORTNAME sets the short name of the application
# APP_AUTHOR sets the author of the application
#-------------------------------------------------------------------------------
APP_NAME := Crispy Doom U
APP_SHORTNAME := Doom
APP_AUTHOR := thearst3rd

TOPDIR ?= $(CURDIR)

include $(DEVKITPRO)/wut/share/wut_rules
# Use environment variables for devkitPro paths
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif

# Default to C:/devkitPro if not set, but allow override
DEVKITPRO_PATH ?= C:/devkitPro
export DEVKITPPC := $(DEVKITPRO_PATH)/devkitPPC

# Override WUT_ROOT to use forward slashes (works on Windows)
WUT_ROOT := $(DEVKITPRO_PATH)/wut

include $(DEVKITPRO_PATH)/wut/share/wut_rules

# Override RPXSPECS to use forward slashes (works on Windows)
RPXSPECS := -specs=$(WUT_ROOT)/share/wut.specs

#-------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# CONTENT is the path to the bundled folder that will be mounted as /vol/content/
# ICON is the game icon, leave blank to use default rule
# TV_SPLASH is the image displayed during bootup on the TV, leave blank to use default rule
# DRC_SPLASH is the image displayed during bootup on the DRC, leave blank to use default rule
#-------------------------------------------------------------------------------
TARGET := crispy-doom-u
BUILD := build
SOURCES := src src/doom opl src/wiiu
DATA := wiiu-data
INCLUDES := src src/doom opl src/wiiu
CONTENT :=
ICON := wiiu/icon.png
TV_SPLASH :=
DRC_SPLASH :=

#-------------------------------------------------------------------------------
# options for code generation
#-------------------------------------------------------------------------------
CFLAGS := -g -Wall -O2 -ffunction-sections \
CFLAGS := -g -Wall -O2 -ffunction-sections -fno-plt \
$(MACHDEP)

CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ \
-DBETTER_ANALOG -DBETTER_JOYWAIT -DDISABLE_SDL2NET
-DBETTER_ANALOG -DBETTER_JOYWAIT -DDISABLE_SDL2NET \
-DHOMEBREW_APP_PATH=\"wiiu/apps/crispy-doom-u\"

CXXFLAGS := $(CFLAGS)

ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map)

LIBS := -lSDL2_mixer -lmpg123 -lmodplug -lvorbisidec -logg `sdl2-config --libs` -lm -lstdc++ -lwut
LIBS := -lSDL2_mixer `$(DEVKITPRO_PATH)/portlibs/wiiu/bin/sdl2-config --libs` -lm -lstdc++ -lwut

#-------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level
Expand Down Expand Up @@ -91,6 +124,34 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \

export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

ifneq (,$(strip $(CONTENT)))
export APP_CONTENT := $(TOPDIR)/$(CONTENT)
endif

ifneq (,$(strip $(ICON)))
export APP_ICON := $(TOPDIR)/$(ICON)
else ifneq (,$(wildcard $(TOPDIR)/$(TARGET).png))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else ifneq (,$(wildcard $(TOPDIR)/icon.png))
export APP_ICON := $(TOPDIR)/icon.png
endif

ifneq (,$(strip $(TV_SPLASH)))
export APP_TV_SPLASH := $(TOPDIR)/$(TV_SPLASH)
else ifneq (,$(wildcard $(TOPDIR)/tv-splash.png))
export APP_TV_SPLASH := $(TOPDIR)/tv-splash.png
else ifneq (,$(wildcard $(TOPDIR)/splash.png))
export APP_TV_SPLASH := $(TOPDIR)/splash.png
endif

ifneq (,$(strip $(DRC_SPLASH)))
export APP_DRC_SPLASH := $(TOPDIR)/$(DRC_SPLASH)
else ifneq (,$(wildcard $(TOPDIR)/drc-splash.png))
export APP_DRC_SPLASH := $(TOPDIR)/drc-splash.png
else ifneq (,$(wildcard $(TOPDIR)/splash.png))
export APP_DRC_SPLASH := $(TOPDIR)/splash.png
endif

.PHONY: $(BUILD) clean all

#-------------------------------------------------------------------------------
Expand All @@ -103,7 +164,7 @@ $(BUILD):
#-------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).rpx $(TARGET).elf
@rm -fr $(BUILD) $(TARGET).wuhb $(TARGET).rpx

#-------------------------------------------------------------------------------
else
Expand All @@ -114,8 +175,9 @@ DEPENDS := $(OFILES:.o=.d)
#-------------------------------------------------------------------------------
# main targets
#-------------------------------------------------------------------------------
all : $(OUTPUT).rpx
all : $(OUTPUT).wuhb

$(OUTPUT).wuhb : $(OUTPUT).rpx
$(OUTPUT).rpx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)

Expand All @@ -129,6 +191,11 @@ $(OFILES_SRC) : $(HFILES_BIN)
@echo $(notdir $<)
@$(bin2o)

%.xml.o %_xml.h : %.xml
#-------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)

-include $(DEPENDS)

#-------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/d_iwad.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ static void AddIWADPath(const char *path, const char *suffix)
// using standard environment variables. See the XDG Base Directory
// Specification:
// <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>
__attribute__((unused))
static void AddXdgDirs(void)
{
const char *env;
Expand Down Expand Up @@ -700,6 +701,7 @@ static void AddXdgDirs(void)
// could parse *.vdf files to more accurately detect installation
// locations, but the defaults are likely to be good enough for just
// about everyone.
__attribute__((unused))
static void AddSteamDirs(void)
{
const char *homedir;
Expand Down
8 changes: 4 additions & 4 deletions src/deh_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static boolean IsWhitespace(char *s)
{
for (; *s; ++s)
{
if (!isspace(*s))
if (!isspace((unsigned char)*s))
return false;
}

Expand All @@ -165,14 +165,14 @@ static char *CleanString(char *s)

// Leading whitespace

while (*s && isspace(*s))
while (*s && isspace((unsigned char)*s))
++s;

// Trailing whitespace

strending = s + strlen(s) - 1;

while (strlen(s) > 0 && isspace(*strending))
while (strlen(s) > 0 && isspace((unsigned char)*strending))
{
*strending = '\0';
--strending;
Expand Down Expand Up @@ -341,7 +341,7 @@ static void DEH_ParseContext(deh_context_t *context)
return;
}

while (line[0] != '\0' && isspace(line[0]))
while (line[0] != '\0' && isspace((unsigned char)line[0]))
++line;

if (line[0] == '#')
Expand Down
57 changes: 39 additions & 18 deletions src/doom/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@

#ifdef __WIIU__
#include <whb/proc.h>
#include <coreinit/screen.h>
#include <sndcore2/core.h>
#include "wiiu_controller.h"
#endif // __WIIU__


Expand All @@ -99,6 +102,10 @@ void D_DoomLoop (void);

static char *gamedescription;

#ifdef __WIIU__
#include "wiiu_exit.h"
#endif // __WIIU__

// Location where savegames are stored

char * savegamedir;
Expand Down Expand Up @@ -522,6 +529,14 @@ void D_RunFrame()
static int wipestart;
static boolean wipe;

#ifdef __WIIU__
// Check for exit request from in-game quit menu
if (g_request_app_exit)
{
return; // Exit immediately, main loop will handle cleanup
}
#endif // __WIIU__

if (wipe)
{
do
Expand Down Expand Up @@ -612,26 +627,24 @@ void D_DoomLoop (void)
}

#ifdef __WIIU__
while (WHBProcIsRunning())
// Use wut's WHBProcIsRunning wrapper for simplified ProcUI handling
// Standard WHB pattern - let SDL and WHB handle everything
while (WHBProcIsRunning() && !g_request_app_exit)
{
D_RunFrame();
}

// Clean shutdown after main loop exits
if (g_request_app_exit)
{
I_Quit_Real(); // Call the real quit function for proper cleanup
WHBProcShutdown();
}
#else
while (1)
#endif // __WIIU__
{
D_RunFrame();
}

#ifdef __WIIU__
extern int quitsounds2[8];
extern int quitsounds[8];

// From m_menu.c, M_QuitResponse
if (gamemode == commercial)
S_StartSound(NULL,quitsounds2[(gametic>>2)&7]);
else
S_StartSound(NULL,quitsounds[(gametic>>2)&7]);
I_WaitVBL(105);

I_Quit();
#endif // __WIIU__
}

Expand Down Expand Up @@ -865,12 +878,12 @@ static char *GetGameName(const char *gamename)
DEH_snprintf(deh_gamename, gamename_size, banners[i],
version / 100, version % 100);

while (deh_gamename[0] != '\0' && isspace(deh_gamename[0]))
while (deh_gamename[0] != '\0' && isspace((unsigned char)deh_gamename[0]))
{
memmove(deh_gamename, deh_gamename + 1, gamename_size - 1);
}

while (deh_gamename[0] != '\0' && isspace(deh_gamename[strlen(deh_gamename)-1]))
while (deh_gamename[0] != '\0' && isspace((unsigned char)deh_gamename[strlen(deh_gamename)-1]))
{
deh_gamename[strlen(deh_gamename) - 1] = '\0';
}
Expand Down Expand Up @@ -1450,7 +1463,7 @@ static void G_CheckDemoStatusAtExit (void)
G_CheckDemoStatus();
}

static const char *const loadparms[] = {"-file", "-merge", NULL};
static const char *const loadparms[] __attribute__((unused)) = {"-file", "-merge", NULL};

//
// D_DoomMain
Expand Down Expand Up @@ -1694,6 +1707,10 @@ void D_DoomMain (void)
modifiedgame = false;

DEH_printf("W_Init: Init WADfiles.\n");
#ifdef __WIIU__
// Present stable black frame before blocking WAD load to prevent garbage scan-out
I_PresentBlackFrame();
#endif // __WIIU__
D_AddFile(iwadfile);
numiwadlumps = numlumps;

Expand Down Expand Up @@ -1840,6 +1857,10 @@ void D_DoomMain (void)
DEH_ParseCommandLine();

// Load PWAD files.
#ifdef __WIIU__
// Present stable black frame before blocking PWAD load to prevent garbage scan-out
I_PresentBlackFrame();
#endif // __WIIU__
modifiedgame = W_ParseCommandLine();

//!
Expand Down
6 changes: 3 additions & 3 deletions src/doom/doom_icon.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
static int doom_icon_w = 128;
static int doom_icon_h = 128;
static int doom_icon_w __attribute__((unused)) = 128;
static int doom_icon_h __attribute__((unused)) = 128;

static const unsigned int doom_icon_data[] = {
static const unsigned int doom_icon_data[] __attribute__((unused)) = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
Expand Down
6 changes: 3 additions & 3 deletions src/doom/f_finale.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ void F_CastTicker (void)
goto stopattack; // Oh, gross hack!
*/
// [crispy] Allow A_RandomJump() in deaths in cast sequence
if (caststate->action.acp1 == A_RandomJump && Crispy_Random() < caststate->misc2)
if ((void*)caststate->action.acp1 == (void*)A_RandomJump && Crispy_Random() < caststate->misc2)
{
st = caststate->misc1;
}
Expand Down Expand Up @@ -671,7 +671,7 @@ void F_CastTicker (void)
if (casttics == -1)
{
// [crispy] Allow A_RandomJump() in deaths in cast sequence
if (caststate->action.acp1 == A_RandomJump)
if ((void*)caststate->action.acp1 == (void*)A_RandomJump)
{
if (Crispy_Random() < caststate->misc2)
{
Expand Down Expand Up @@ -746,7 +746,7 @@ boolean F_CastResponder (event_t* ev)
caststate = &states[mobjinfo[castorder[castnum].type].deathstate];
casttics = caststate->tics;
// [crispy] Allow A_RandomJump() in deaths in cast sequence
if (casttics == -1 && caststate->action.acp1 == A_RandomJump)
if (casttics == -1 && (void*)caststate->action.acp1 == (void*)A_RandomJump)
{
if (Crispy_Random() < caststate->misc2)
{
Expand Down
6 changes: 6 additions & 0 deletions src/doom/m_crispy.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,13 @@ void M_CrispyToggleVsync(int choice)
return;
}

#ifdef __WIIU__
// Prevent disabling VSYNC on Wii U to avoid HOME menu hang issue
// SDL bug: GX2SetSwapInterval(0) causes black screen after HOME menu
return;
#else
crispy->post_rendering_hook = M_CrispyToggleVsyncHook;
#endif // __WIIU__
}

static int hookchoice;
Expand Down
Loading