Skip to content
Closed
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
111 changes: 47 additions & 64 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ TARGET_BITS ?= 0
BETTERCAMERA ?= 0
# Disable no drawing distance by default
NODRAWINGDISTANCE ?= 0
# Disable texture fixes by default (helps with them purists)
TEXTURE_FIX ?= 0
# Disable quality-of-life fixes by default (helps with them purists)
QOL_FIXES ?= 0
# Enable extended options menu by default
EXT_OPTIONS_MENU ?= 1
# Disable text-based save-files by default
# Disable text-based save files by default
TEXTSAVES ?= 0
# Load textures from external PNG files
EXTERNAL_TEXTURES ?= 0
Expand Down Expand Up @@ -74,7 +74,7 @@ ifeq ($(WINDOWS_BUILD),1)
TARGET_BITS = 32
NO_BZERO_BCOPY := 1
else ifeq ($(CROSS),x86_64-w64-mingw32.static-)
TARGET_ARCH = i386pe
TARGET_ARCH = i386pep
TARGET_BITS = 64
NO_BZERO_BCOPY := 1
endif
Expand All @@ -94,22 +94,19 @@ ifeq ($(VERSION),jp)
GRUCODE_CFLAGS := -DF3D_OLD
GRUCODE_ASFLAGS := --defsym F3D_OLD=1
TARGET := sm64.jp
else
ifeq ($(VERSION),us)
else ifeq ($(VERSION),us)
VERSION_CFLAGS := -DVERSION_US
VERSION_ASFLAGS := --defsym VERSION_US=1
GRUCODE_CFLAGS := -DF3D_OLD
GRUCODE_ASFLAGS := --defsym F3D_OLD=1
TARGET := sm64.us
else
ifeq ($(VERSION),eu)
else ifeq ($(VERSION),eu)
VERSION_CFLAGS := -DVERSION_EU
VERSION_ASFLAGS := --defsym VERSION_EU=1
GRUCODE_CFLAGS := -DF3D_NEW
GRUCODE_ASFLAGS := --defsym F3D_NEW=1
TARGET := sm64.eu
else
ifeq ($(VERSION),sh)
else ifeq ($(VERSION),sh)
$(warning Building SH is experimental and is prone to breaking. Try at your own risk.)
VERSION_CFLAGS := -DVERSION_SH
VERSION_ASFLAGS := --defsym VERSION_SH=1
Expand All @@ -121,9 +118,6 @@ ifeq ($(VERSION),sh)
else
$(error unknown version "$(VERSION)")
endif
endif
endif
endif

# Stuff for showing the git hash in the intro on nightly builds
# From https://stackoverflow.com/questions/44038428/include-git-commit-hash-and-or-branch-name-in-c-c-source
Expand All @@ -140,35 +134,27 @@ ifeq ($(GRUCODE),f3dex) # Fast3DEX
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DEX_GBI=1
TARGET := $(TARGET).f3dex
COMPARE := 0
else
ifeq ($(GRUCODE), f3dex2) # Fast3DEX2
else ifeq ($(GRUCODE), f3dex2) # Fast3DEX2
GRUCODE_CFLAGS := -DF3DEX_GBI_2
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DEX_GBI_2=1
TARGET := $(TARGET).f3dex2
COMPARE := 0
else
ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (PC default)
else ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (PC default)
GRUCODE_CFLAGS := -DF3DEX_GBI_2E
TARGET := $(TARGET).f3dex2e
COMPARE := 0
else
ifeq ($(GRUCODE),f3d_new) # Fast3D 2.0H (Shindou)
else ifeq ($(GRUCODE),f3d_new) # Fast3D 2.0H (Shindou)
GRUCODE_CFLAGS := -DF3D_NEW
GRUCODE_ASFLAGS := --defsym F3D_NEW=1
TARGET := $(TARGET).f3d_new
COMPARE := 0
else
ifeq ($(GRUCODE),f3dzex) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori)
else ifeq ($(GRUCODE),f3dzex) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori)
$(warning Fast3DZEX is experimental. Try at your own risk.)
GRUCODE_CFLAGS := -DF3DEX_GBI_2
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DZEX_GBI=1
TARGET := $(TARGET).f3dzex
COMPARE := 0
endif
endif
endif
endif
endif

# Default build is for PC now
VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB
Expand All @@ -194,8 +180,7 @@ endif
# on tools and assets, and we use directory globs further down
# in the makefile that we want should cover assets.)

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
ifeq (,$(findstring clean,$(MAKECMDGOALS)))

# Make sure assets exist
NOEXTRACT ?= 0
Expand All @@ -212,7 +197,6 @@ ifeq ($(DUMMY),FAIL)
$(error Failed to build tools)
endif

endif
endif

################ Target Executable and Sources ###############
Expand All @@ -230,17 +214,12 @@ LIBULTRA := $(BUILD_DIR)/libultra.a

ifeq ($(TARGET_WEB),1)
EXE := $(BUILD_DIR)/$(TARGET).html
else
ifeq ($(WINDOWS_BUILD),1)
EXE := $(BUILD_DIR)/$(TARGET).exe

else # Linux builds/binary namer
ifeq ($(TARGET_RPI),1)
EXE := $(BUILD_DIR)/$(TARGET).arm
else
EXE := $(BUILD_DIR)/$(TARGET)
endif
endif
else ifeq ($(WINDOWS_BUILD),1)
EXE := $(BUILD_DIR)/$(TARGET).exe
else ifeq ($(TARGET_RPI),1) # Linux builds/binary namer
EXE := $(BUILD_DIR)/$(TARGET).arm
else
EXE := $(BUILD_DIR)/$(TARGET)
endif

ELF := $(BUILD_DIR)/$(TARGET).elf
Expand Down Expand Up @@ -270,13 +249,11 @@ MIPSBIT := -32

ifeq ($(VERSION),eu)
OPT_FLAGS := -O2
else
ifeq ($(VERSION),sh)
else ifeq ($(VERSION),sh)
OPT_FLAGS := -O2
else
OPT_FLAGS := -g
endif
endif

# Set BITS (32/64) to compile for
OPT_FLAGS += $(BITS)
Expand Down Expand Up @@ -468,6 +445,10 @@ ifeq ($(WINDOWS_BUILD),1)
LD := $(CC)
else ifeq ($(CROSS),x86_64-w64-mingw32.static-)
LD := $(CC)
else ifeq ($(CROSS),mxe-i686-w64-mingw32.static-)
LD := $(CC)
else ifeq ($(CROSS),mxe-x86_64-w64-mingw32.static-)
LD := $(CC)
else
LD := $(CXX)
endif
Expand All @@ -479,8 +460,8 @@ ifeq ($(WINDOWS_BUILD),1) # fixes compilation in MXE on Linux and WSL
OBJDUMP := $(CROSS)objdump
else ifeq ($(OSX_BUILD),1)
CPP := cpp-9 -P
OBJDUMP := i686-w64-mingw32-objdump
OBJCOPY := i686-w64-mingw32-objcopy
OBJDUMP := i686-w64-mingw32-objdump
else # Linux & other builds
CPP := $(CROSS)cpp -P
OBJCOPY := $(CROSS)objcopy
Expand All @@ -491,16 +472,15 @@ PYTHON := python3
SDLCONFIG := $(CROSS)sdl2-config

ifeq ($(WINDOWS_BUILD),1)
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` -DUSE_SDL=2
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` -DUSE_SDL=2
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` -DUSE_SDL=2

else ifeq ($(TARGET_WEB),1)
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv -s USE_SDL=2

# Linux / Other builds below
else
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` -DUSE_SDL=2
else # Linux / Other builds below
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` -DUSE_SDL=2
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` -DUSE_SDL=2
endif

Expand All @@ -513,6 +493,7 @@ ifeq ($(BETTERCAMERA),1)
EXT_OPTIONS_MENU := 1
endif

# Check for text-based save option
ifeq ($(TEXTSAVES),1)
CC_CHECK += -DTEXTSAVES
CFLAGS += -DTEXTSAVES
Expand All @@ -524,10 +505,10 @@ ifeq ($(NODRAWINGDISTANCE),1)
CFLAGS += -DNODRAWINGDISTANCE
endif

# Check for texture fix option
ifeq ($(TEXTURE_FIX),1)
CC_CHECK += -DTEXTURE_FIX
CFLAGS += -DTEXTURE_FIX
# Check for QoL fix option
ifeq ($(QOL_FIXES),1)
CC_CHECK += -DQOL_FIXES
CFLAGS += -DQOL_FIXES
endif

# Check for extended options menu option
Expand Down Expand Up @@ -568,21 +549,16 @@ ifeq ($(TARGET_WEB),1)
LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base http://localhost:8080/ -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']"
else ifeq ($(WINDOWS_BUILD),1)
LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static
ifeq ($(CROSS),)
LDFLAGS += -no-pie
endif
ifeq ($(WINDOWS_CONSOLE),1)
LDFLAGS += -mconsole
endif
else ifeq ($(TARGET_RPI),1)
# Linux / Other builds below
LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(SDLCONFIG) --libs` -no-pie
else
ifeq ($(OSX_BUILD),1)
else ifeq ($(OSX_BUILD),1)
LDFLAGS := -lm -framework OpenGL `$(SDLCONFIG) --libs` -no-pie -lpthread `pkg-config --libs libusb-1.0 glfw3 glew`
else
LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm -lGL `$(SDLCONFIG) --libs` -no-pie -lpthread
endif
endif # End of LDFLAGS

# Prevent a crash with -sopt
Expand Down Expand Up @@ -630,12 +606,21 @@ clean:
$(RM) -r $(BUILD_DIR_BASE)

cleantools:
$(MAKE) -s -C tools clean
$(MAKE) -C tools clean

cleanall:
$(RM) -r $(BUILD_DIR_BASE)
$(MAKE) -C tools clean

distclean:
$(RM) -r $(BUILD_DIR_BASE)
./extract_assets.py --clean

distcleanall:
$(RM) -r $(BUILD_DIR_BASE)
./extract_assets.py --clean
$(MAKE) -C tools clean

test: $(ROM)
$(EMULATOR) $(EMU_FLAGS) $<

Expand Down Expand Up @@ -673,8 +658,7 @@ $(BUILD_DIR)/levels/menu/leveldata.o: $(BUILD_DIR)/text/us/define_courses.inc.c
$(BUILD_DIR)/levels/menu/leveldata.o: $(BUILD_DIR)/text/de/define_courses.inc.c
$(BUILD_DIR)/levels/menu/leveldata.o: $(BUILD_DIR)/text/fr/define_courses.inc.c

else
ifeq ($(VERSION),sh)
else ifeq ($(VERSION),sh)
TEXT_DIRS := text/jp
$(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/jp/define_text.inc.c

Expand All @@ -684,14 +668,13 @@ TEXT_DIRS := text/$(VERSION)
# non-EU encoded text inserted into segment 0x02
$(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/$(VERSION)/define_text.inc.c
endif
endif

$(BUILD_DIR)/text/%/define_courses.inc.c: text/define_courses.inc.c text/%/courses.h
$(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/
$(TEXTCONV) charmap.txt $@ $@

$(BUILD_DIR)/text/%/define_text.inc.c: text/define_text.inc.c text/%/courses.h text/%/dialogs.h
$(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/
$(CPP) $(VERSION_CFLAGS) -Wno-trigraphs $< -o $@ -I text/$*/
$(TEXTCONV) charmap.txt $@ $@

ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(GODDARD_SRC_DIRS) $(ULTRA_SRC_DIRS) $(ULTRA_ASM_DIRS) $(ULTRA_BIN_DIRS) $(BIN_DIRS) $(TEXTURE_DIRS) $(TEXT_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION)
Expand Down Expand Up @@ -884,7 +867,7 @@ $(BUILD_DIR)/%.o: %.s
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES)
$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)

.PHONY: all clean distclean default diff test load libultra res
.PHONY: all clean cleantools cleanall distclean distcleanall default diff test load libultra res
.PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/%
.DELETE_ON_ERROR:

Expand Down
4 changes: 1 addition & 3 deletions Makefile.split
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,11 @@ define level_rules =
$$(BUILD_DIR)/levels/$(1)/leveldata.elf: TEXTURE_BIN := $(2)
endef

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
$(BUILD_DIR)/level_rules.mk: levels/level_rules.mk levels/level_defines.h
$(CPP) $(VERSION_CFLAGS) -I . -o $@ $<
include $(BUILD_DIR)/level_rules.mk
endif
endif

# --------------------------------------
# Extra Level Rules
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Please contribute **first** to the [nightly branch](https://github.com/sm64pc/sm
* Native xinput controller support. On Linux, DualShock 4 has been confirmed to work plug-and-play.
* Analog camera control and mouse look. (Activate with `make BETTERCAMERA=1`.)
* An option to disable drawing distances. (Activate with `make NODRAWINGDISTANCE=1`.)
* Model and texture fixes. (Activate with `make TEXTURE_FIX=1`.)
* Quality-of-life fixes. (Activate with `make QOL_FIXES=1`.)
* In-game control binding.
* Skip introductory Peach & Lakitu cutscenes with the `--skip-intro` CLI option
* Disabling the HUD.
Expand Down
6 changes: 3 additions & 3 deletions actors/burn_smoke/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ static const Vtx burn_smoke_seg4_vertex_040217C0[] = {

// //! Wrong texture format. Called as rgba16, which makes the burn smoke appear
// as a transparent black burn smoke. Probably meant to show up as white-ish
// burn smoke, but mistakened for being intended as black smoke.
// burn smoke, but mistaken for being intended as black smoke.
// Due to debate in the Koopa shorts PR surrounding the fix to a similar bug,
// said fix is on a compile-time variable. Use TEXTURE_FIX=1 at compile time
// said fix is on a compile-time variable. Use QOL_FIXES=1 at compile time
// to fix this.
// 0x04021800
ALIGNED8 static const u8 burn_smoke_seg4_texture_04021800[] = {
Expand Down Expand Up @@ -47,7 +47,7 @@ const Gfx burn_smoke_seg4_dl_04022048[] = {
// 0x04022070 - 0x040220C8
const Gfx burn_smoke_seg4_dl_04022070[] = {
gsSPDisplayList(burn_smoke_seg4_dl_04022000),
#ifdef TEXTURE_FIX
#ifdef QOL_FIXES
gsDPLoadTextureBlock(burn_smoke_seg4_texture_04021800, G_IM_FMT_IA, G_IM_SIZ_16b, 32, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 5, 5, G_TX_NOLOD, G_TX_NOLOD),
#else
gsDPLoadTextureBlock(burn_smoke_seg4_texture_04021800, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 5, 5, G_TX_NOLOD, G_TX_NOLOD),
Expand Down
4 changes: 2 additions & 2 deletions actors/koopa/model.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static const Lights1 koopa_seg6_lights_06002630 = gdSPDefLights1(
// the rest of its body. This is evident because once the mistake is corrected
// it turns back to being white like the other polygons.
// Due to debate in the PR surrounding the fix to this, said fix is on
// a compile-time variable. Use TEXTURE_FIX=1 at compile time to fix this.
// a compile-time variable. Use QOL_FIXES=1 at compile time to fix this.
// 0x06002648
ALIGNED8 static const u8 koopa_seg6_texture_06002648[] = {
#include "actors/koopa/koopa_shell_front.rgba16.inc.c"
Expand Down Expand Up @@ -2079,7 +2079,7 @@ const Gfx koopa_seg6_dl_0600C498[] = {
gsSPVertex(koopa_seg6_vertex_0600B560, 9, 0),
gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0),
gsSP1Triangle( 6, 7, 8, 0x0),
#ifdef TEXTURE_FIX
#ifdef QOL_FIXES
gsSPLight(&koopa_seg6_lights_06002630.l, 1),
gsSPLight(&koopa_seg6_lights_06002630.a, 2),
#else
Expand Down
8 changes: 4 additions & 4 deletions bin/segment2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2492,10 +2492,10 @@ ALIGNED8 const u8 texture_waterbox_lava[] = {
};

// Unreferenced light group
static const Lights1 segment2_lights_unused = gdSPDefLights1(
0x40, 0x40, 0x40,
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
);
//static const Lights1 segment2_lights_unused = gdSPDefLights1(
// 0x40, 0x40, 0x40,
// 0xff, 0xff, 0xff, 0x28, 0x28, 0x28
//);

// 0x02014470 - 0x020144B0
static const Mtx matrix_identity = {
Expand Down
Loading