Merge branch 'sm64ex/nightly/testing' into ex/nightly

This commit is contained in:
VDavid003
2021-07-11 15:38:09 +02:00
33 changed files with 9362 additions and 455 deletions
+3
View File
@@ -83,3 +83,6 @@ sm64config.txt
# SDL
SDL/include
# libc++ from Termux
android/lib/*/libc++_shared.so
+3 -2
View File
@@ -58,6 +58,7 @@ ULTRA_SRC_DIRS := $(addprefix $(LOCAL_PATH)/,$(ULTRA_SRC_DIRS))
# Source code files
LEVEL_C_FILES := $(wildcard $(LOCAL_PATH)/levels/*/leveldata.c) $(wildcard $(LOCAL_PATH)/levels/*/script.c) $(wildcard $(LOCAL_PATH)/levels/*/geo.c)
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(LEVEL_C_FILES)
CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
ULTRA_C_FILES := \
alBnkfNew.c \
@@ -83,7 +84,7 @@ LOCAL_SHORT_COMMANDS := true
LOCAL_SHARED_LIBRARIES := SDL2
LOCAL_LDLIBS := -lEGL -lGLESv2 -llog
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include $(LOCAL_PATH)/include $(LOCAL_PATH)/src $(PC_BUILD_DIR) $(PC_BUILD_DIR)/include
LOCAL_CFLAGS := -DNON_MATCHING -DAVOID_UB -DTARGET_LINUX -DENABLE_OPENGL -DWIDESCREEN -DF3DEX_GBI_2E -D_LANGUAGE_C -DNO_SEGMENTED_MEMORY -D$(VERSION_DEF) -DSTDC_HEADERS -DUSE_GLES -DRAPI_GL -DWAPI_SDL2 -DAAPI_SDL2 -DCAPI_SDL2 -DHAVE_SDL2
LOCAL_CFLAGS := -DNON_MATCHING -DAVOID_UB -DTARGET_LINUX -DENABLE_OPENGL -DWIDESCREEN -DF3DEX_GBI_2E -D_LANGUAGE_C -DNO_SEGMENTED_MEMORY -D$(VERSION_DEF) -DSTDC_HEADERS -DUSE_GLES -DRAPI_GL -DWAPI_SDL2 -DAAPI_SDL2 -DCAPI_SDL2 -DHAVE_SDL2 -O3
ifeq ($(TOUCH_CONTROLS),1)
LOCAL_CFLAGS += -DTOUCH_CONTROLS
@@ -102,6 +103,6 @@ ifeq ($(EXTERNAL_DATA),1)
LOCAL_CFLAGS += -DEXTERNAL_DATA -DFS_BASEDIR="\"$(BASEDIR)\""
endif
LOCAL_SRC_FILES := $(C_FILES) $(GENERATED_C_FILES) $(ULTRA_C_FILES) $(GODDARD_C_FILES) $(LOCAL_PATH)/sound/sound_data.c
LOCAL_SRC_FILES := $(C_FILES) $(CXX_FILES) $(GENERATED_C_FILES) $(ULTRA_C_FILES) $(GODDARD_C_FILES) $(LOCAL_PATH)/sound/sound_data.c
include $(BUILD_SHARED_LIBRARY)
+112 -30
View File
@@ -30,6 +30,9 @@ TARGET_WEB ?= 0
# Makeflag to enable OSX fixes
OSX_BUILD ?= 0
# Enable -no-pie linker option
NO_PIE ?= 1
# Specify the target you are building for, TARGET_BITS=0 means native
TARGET_ARCH ?= native
TARGET_BITS ?= 0
@@ -59,11 +62,11 @@ NO_LDIV ?= 0
# Renderers: GL, GL_LEGACY, D3D11, D3D12
RENDER_API ?= GL
# Window managers: SDL2, DXGI (forced if D3D11 or D3D12 in RENDER_API)
# Window managers: SDL1, SDL2, DXGI (forced if D3D11 or D3D12 in RENDER_API)
WINDOW_API ?= SDL2
# Audio backends: SDL2
# Audio backends: SDL1, SDL2
AUDIO_API ?= SDL2
# Controller backends (can have multiple, space separated): SDL2
# Controller backends (can have multiple, space separated): SDL2, SDL1
CONTROLLER_API ?= SDL2
# Misc settings for EXTERNAL_DATA
@@ -465,7 +468,7 @@ else
CXX := emcc
endif
LD := $(CC)
LD := $(CXX) #We need some cpp support for DynOS here
ifeq ($(DISCORDRPC),1)
LD := $(CXX)
@@ -501,7 +504,9 @@ SDLCONFIG := $(CROSS)sdl2-config
BACKEND_CFLAGS := -DRAPI_$(RENDER_API)=1 -DWAPI_$(WINDOW_API)=1 -DAAPI_$(AUDIO_API)=1
# can have multiple controller APIs
BACKEND_CFLAGS += $(foreach capi,$(CONTROLLER_API),-DCAPI_$(capi)=1)
BACKEND_LDFLAGS :=
BACKEND_LDFLAG0S :=
SDL1_USED := 0
SDL2_USED := 0
# for now, it's either SDL+GL or DXGI+DirectX, so choose based on WAPI
@@ -512,7 +517,7 @@ ifeq ($(WINDOW_API),DXGI)
endif
BACKEND_LDFLAGS += -ld3dcompiler -ldxgi -ldxguid
BACKEND_LDFLAGS += -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -static
else ifeq ($(WINDOW_API),SDL2)
else ifeq ($(findstring SDL,$(WINDOW_API)),SDL)
ifeq ($(WINDOWS_BUILD),1)
BACKEND_LDFLAGS += -lglew32 -lglu32 -lopengl32
else ifeq ($(TARGET_ANDROID),1)
@@ -524,24 +529,35 @@ else ifeq ($(WINDOW_API),SDL2)
else
BACKEND_LDFLAGS += -lGL
endif
SDL_USED := 2
endif
ifeq ($(AUDIO_API),SDL2)
SDL_USED := 2
ifneq (,$(findstring SDL2,$(AUDIO_API)$(WINDOW_API)$(CONTROLLER_API)))
SDL2_USED := 1
endif
ifneq (,$(findstring SDL,$(CONTROLLER_API)))
SDL_USED := 2
ifneq (,$(findstring SDL1,$(AUDIO_API)$(WINDOW_API)$(CONTROLLER_API)))
SDL1_USED := 1
endif
ifeq ($(SDL1_USED)$(SDL2_USED),11)
$(error Cannot link both SDL1 and SDL2 at the same time)
endif
# SDL can be used by different systems, so we consolidate all of that shit into this
ifeq ($(SDL_USED),2)
ifeq ($(SDL2_USED),1)
SDLCONFIG := $(CROSS)sdl2-config
BACKEND_CFLAGS += -DHAVE_SDL2=1
else ifeq ($(SDL1_USED),1)
SDLCONFIG := $(CROSS)sdl-config
BACKEND_CFLAGS += -DHAVE_SDL1=1
endif
ifneq ($(SDL1_USED)$(SDL2_USED),00)
ifeq ($(TARGET_ANDROID),1)
BACKEND_CFLAGS += -DHAVE_SDL2=1
BACKEND_LDFLAGS += -lhidapi -lSDL2
else
BACKEND_CFLAGS += -DHAVE_SDL2=1 `$(SDLCONFIG) --cflags`
BACKEND_CFLAGS += `$(SDLCONFIG) --cflags`
ifeq ($(WINDOWS_BUILD),1)
BACKEND_LDFLAGS += `$(SDLCONFIG) --static-libs` -lsetupapi -luser32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion
else
@@ -637,7 +653,7 @@ endif
ASFLAGS := -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS)
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']"
LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=64MB -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 $(BACKEND_LDFLAGS) -static
@@ -668,9 +684,13 @@ else ifeq ($(OSX_BUILD),1)
LDFLAGS := -lm $(BACKEND_LDFLAGS) -no-pie -lpthread
else
LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm $(BACKEND_LDFLAGS) -no-pie -lpthread
LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm $(BACKEND_LDFLAGS) -lpthread -ldl
ifeq ($(NO_PIE), 1)
LDFLAGS += -no-pie
endif
ifeq ($(DISCORDRPC),1)
LDFLAGS += -ldl -Wl,-rpath .
LDFLAGS += -Wl,-rpath .
endif
endif # End of LDFLAGS
@@ -734,10 +754,22 @@ res: $(BASEPACK_PATH)
$(BASEPACK_LST): $(EXE_DEPEND)
@mkdir -p $(BUILD_DIR)/$(BASEDIR)
@echo -n > $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/bank_sets sound/bank_sets" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sequences.bin sound/sequences.bin" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.ctl sound/sound_data.ctl" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.tbl sound/sound_data.tbl" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/bank_sets.be.64 sound/bank_sets.be.64" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/bank_sets.be.32 sound/bank_sets.be.32" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/bank_sets.le.64 sound/bank_sets.le.64" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/bank_sets.le.32 sound/bank_sets.le.32" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sequences.bin.be.64 sound/sequences.bin.be.64" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sequences.bin.be.32 sound/sequences.bin.be.32" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sequences.bin.le.64 sound/sequences.bin.le.64" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sequences.bin.le.32 sound/sequences.bin.le.32" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.ctl.be.64 sound/sound_data.ctl.be.64" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.ctl.be.32 sound/sound_data.ctl.be.32" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.ctl.le.64 sound/sound_data.ctl.le.64" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.ctl.le.32 sound/sound_data.ctl.le.32" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.tbl.be.64 sound/sound_data.tbl.be.64" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.tbl.be.32 sound/sound_data.tbl.be.32" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.tbl.le.64 sound/sound_data.tbl.le.64" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.tbl.le.32 sound/sound_data.tbl.le.32" >> $(BASEPACK_LST)
@$(foreach f, $(wildcard $(SKYTILE_DIR)/*), echo $(f) gfx/$(f:$(BUILD_DIR)/%=%) >> $(BASEPACK_LST);)
@find actors -name \*.png -exec echo "{} gfx/{}" >> $(BASEPACK_LST) \;
@find levels -name \*.png -exec echo "{} gfx/{}" >> $(BASEPACK_LST) \;
@@ -901,21 +933,66 @@ $(ENDIAN_BITWIDTH): tools/determine-endian-bitwidth.c
@rm $@.dummy1
@rm $@.dummy2
$(SOUND_BIN_DIR)/sound_data.ctl: sound/sound_banks/ $(SOUND_BANK_FILES) $(SOUND_SAMPLE_AIFCS) $(ENDIAN_BITWIDTH)
$(PYTHON) tools/assemble_sound.py $(BUILD_DIR)/sound/samples/ sound/sound_banks/ $(SOUND_BIN_DIR)/sound_data.ctl $(SOUND_BIN_DIR)/sound_data.tbl $(VERSION_CFLAGS) $$(cat $(ENDIAN_BITWIDTH))
$(SOUND_BIN_DIR)/sound_data.ctl.be.64: sound/sound_banks/ $(SOUND_BANK_FILES) $(SOUND_SAMPLE_AIFCS)
$(PYTHON) tools/assemble_sound.py $(BUILD_DIR)/sound/samples/ sound/sound_banks/ $(SOUND_BIN_DIR)/sound_data.ctl.be.64 $(SOUND_BIN_DIR)/sound_data.tbl.be.64 $(VERSION_CFLAGS) --endian big --bitwidth 64
$(SOUND_BIN_DIR)/sound_data.tbl: $(SOUND_BIN_DIR)/sound_data.ctl
$(SOUND_BIN_DIR)/sound_data.ctl.be.32: sound/sound_banks/ $(SOUND_BANK_FILES) $(SOUND_SAMPLE_AIFCS)
$(PYTHON) tools/assemble_sound.py $(BUILD_DIR)/sound/samples/ sound/sound_banks/ $(SOUND_BIN_DIR)/sound_data.ctl.be.32 $(SOUND_BIN_DIR)/sound_data.tbl.be.32 $(VERSION_CFLAGS) --endian big --bitwidth 32
$(SOUND_BIN_DIR)/sound_data.ctl.le.64: sound/sound_banks/ $(SOUND_BANK_FILES) $(SOUND_SAMPLE_AIFCS)
$(PYTHON) tools/assemble_sound.py $(BUILD_DIR)/sound/samples/ sound/sound_banks/ $(SOUND_BIN_DIR)/sound_data.ctl.le.64 $(SOUND_BIN_DIR)/sound_data.tbl.le.64 $(VERSION_CFLAGS) --endian little --bitwidth 64
$(SOUND_BIN_DIR)/sound_data.ctl.le.32: sound/sound_banks/ $(SOUND_BANK_FILES) $(SOUND_SAMPLE_AIFCS)
$(PYTHON) tools/assemble_sound.py $(BUILD_DIR)/sound/samples/ sound/sound_banks/ $(SOUND_BIN_DIR)/sound_data.ctl.le.32 $(SOUND_BIN_DIR)/sound_data.tbl.le.32 $(VERSION_CFLAGS) --endian little --bitwidth 32
$(SOUND_BIN_DIR)/sound_data.tbl.be.64: $(SOUND_BIN_DIR)/sound_data.ctl.be.64
@true
$(SOUND_BIN_DIR)/sound_data.tbl.be.32: $(SOUND_BIN_DIR)/sound_data.ctl.be.32
@true
$(SOUND_BIN_DIR)/sound_data.tbl.le.64: $(SOUND_BIN_DIR)/sound_data.ctl.le.64
@true
$(SOUND_BIN_DIR)/sound_data.tbl.le.32: $(SOUND_BIN_DIR)/sound_data.ctl.le.32
@true
ifeq ($(VERSION),sh)
$(SOUND_BIN_DIR)/sequences.bin: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/jp/ $(SOUND_SEQUENCE_FILES) $(ENDIAN_BITWIDTH)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) $$(cat $(ENDIAN_BITWIDTH))
$(SOUND_BIN_DIR)/sequences.bin.be.64: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/jp/ $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets.be.64 sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) --endian big --bitwidth 64
$(SOUND_BIN_DIR)/sequences.bin.be.32: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/jp/ $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets.be.32 sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) --endian big --bitwidth 32
$(SOUND_BIN_DIR)/sequences.bin.le.64: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/jp/ $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets.le.64 sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) --endian little --bitwidth 64
$(SOUND_BIN_DIR)/sequences.bin.le.32: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/jp/ $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets.le.32 sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) --endian little --bitwidth 32
else
$(SOUND_BIN_DIR)/sequences.bin: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/$(VERSION)/ $(SOUND_SEQUENCE_FILES) $(ENDIAN_BITWIDTH)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) $$(cat $(ENDIAN_BITWIDTH))
$(SOUND_BIN_DIR)/sequences.bin.be.64: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/$(VERSION)/ $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets.be.64 sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) --endian big --bitwidth 64
$(SOUND_BIN_DIR)/sequences.bin.be.32: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/$(VERSION)/ $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets.be.32 sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) --endian big --bitwidth 32
$(SOUND_BIN_DIR)/sequences.bin.le.64: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/$(VERSION)/ $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets.le.64 sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) --endian little --bitwidth 64
$(SOUND_BIN_DIR)/sequences.bin.le.32: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/$(VERSION)/ $(SOUND_SEQUENCE_FILES)
$(PYTHON) tools/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/bank_sets.le.32 sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) --endian little --bitwidth 32
endif
$(SOUND_BIN_DIR)/bank_sets: $(SOUND_BIN_DIR)/sequences.bin
$(SOUND_BIN_DIR)/bank_sets.be.64: $(SOUND_BIN_DIR)/sequences.bin.be.64
@true
$(SOUND_BIN_DIR)/bank_sets.be.32: $(SOUND_BIN_DIR)/sequences.bin.be.32
@true
$(SOUND_BIN_DIR)/bank_sets.le.64: $(SOUND_BIN_DIR)/sequences.bin.le.64
@true
$(SOUND_BIN_DIR)/bank_sets.le.32: $(SOUND_BIN_DIR)/sequences.bin.le.32
@true
$(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o
@@ -937,7 +1014,11 @@ $(SOUND_BIN_DIR)/%.inc.c: $(SOUND_BIN_DIR)/%
endif
$(SOUND_BIN_DIR)/sound_data.o: $(SOUND_BIN_DIR)/sound_data.ctl.inc.c $(SOUND_BIN_DIR)/sound_data.tbl.inc.c $(SOUND_BIN_DIR)/sequences.bin.inc.c $(SOUND_BIN_DIR)/bank_sets.inc.c
$(SOUND_BIN_DIR)/sound_data.o: \
$(SOUND_BIN_DIR)/sound_data.ctl.be.64.inc.c $(SOUND_BIN_DIR)/sound_data.tbl.be.64.inc.c $(SOUND_BIN_DIR)/sequences.bin.be.64.inc.c $(SOUND_BIN_DIR)/bank_sets.be.64.inc.c \
$(SOUND_BIN_DIR)/sound_data.ctl.be.32.inc.c $(SOUND_BIN_DIR)/sound_data.tbl.be.32.inc.c $(SOUND_BIN_DIR)/sequences.bin.be.32.inc.c $(SOUND_BIN_DIR)/bank_sets.be.32.inc.c \
$(SOUND_BIN_DIR)/sound_data.ctl.le.64.inc.c $(SOUND_BIN_DIR)/sound_data.tbl.le.64.inc.c $(SOUND_BIN_DIR)/sequences.bin.le.64.inc.c $(SOUND_BIN_DIR)/bank_sets.le.64.inc.c \
$(SOUND_BIN_DIR)/sound_data.ctl.le.32.inc.c $(SOUND_BIN_DIR)/sound_data.tbl.le.32.inc.c $(SOUND_BIN_DIR)/sequences.bin.le.32.inc.c $(SOUND_BIN_DIR)/bank_sets.le.32.inc.c
$(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h
@@ -1026,6 +1107,7 @@ APK_FILES := $(shell find android/ -type f)
$(APK): $(EXE) $(APK_FILES)
cp -r android $(BUILD_DIR) && \
cp $(PREFIX)/lib/libc++_shared.so $(BUILD_DIR)/android/lib/$(ARCH_APK)/ && \
cp $(EXE) $(BUILD_DIR)/android/lib/$(ARCH_APK)/ && \
cd $(BUILD_DIR)/android && \
zip -r ../../../$@ ./* && \
+15 -15
View File
@@ -112,7 +112,7 @@ index 802d97a..1b0d677 100644
/** A node that allows an object to specify a different culling radius than the
diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c
index 5b6775f..2c11e25 100644
index 1da535b..49a5c03 100644
--- a/src/engine/surface_collision.c
+++ b/src/engine/surface_collision.c
@@ -8,6 +8,7 @@
@@ -1890,19 +1890,10 @@ index 0467495..fa4eb33 100644
using namespace Microsoft::WRL; // For ComPtr
diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c
index 5f4c690..de96bbd 100644
index 42b8541..388e137 100644
--- a/src/pc/gfx/gfx_sdl2.c
+++ b/src/pc/gfx/gfx_sdl2.c
@@ -61,7 +61,7 @@ static void (*touch_up_callback)(void* event);
// whether to use timer for frame control
static bool use_timer = true;
// time between consequtive game frames
-static const int frame_time = 1000 / FRAMERATE;
+static const int frame_time = 1000 / (2 * FRAMERATE);
const SDL_Scancode windows_scancode_table[] = {
/* 0 1 2 3 4 5 6 7 */
@@ -153,11 +153,11 @@ int test_vsync(void) {
@@ -161,11 +161,11 @@ static int test_vsync(void) {
* On SGI models, turning vsync off will help with framerate, but the best is 60fps patch.
* The actual solution would be to render or copy the buffer to a texture
* and then render that to the screen.*/
@@ -1916,11 +1907,11 @@ index 5f4c690..de96bbd 100644
#endif
}
@@ -165,7 +165,11 @@ static inline void gfx_sdl_set_vsync(const bool enabled) {
@@ -173,7 +173,11 @@ static inline void gfx_sdl_set_vsync(const bool enabled) {
if (enabled) {
// try to detect refresh rate
SDL_GL_SetSwapInterval(1);
- const int vblanks = test_vsync();
- const int vblanks = gCLIOpts.SyncFrames ? (int)gCLIOpts.SyncFrames : test_vsync();
+ int vblanks = test_vsync();
+ if (vblanks & 1)
+ vblanks = 0; // not divisible by 60, fuck that
@@ -1929,8 +1920,17 @@ index 5f4c690..de96bbd 100644
if (vblanks) {
printf("determined swap interval: %d\n", vblanks);
SDL_GL_SetSwapInterval(vblanks);
@@ -258,7 +262,7 @@ static void gfx_sdl_init(const char *window_title) {
gfx_sdl_set_fullscreen();
perf_freq = SDL_GetPerformanceFrequency();
- frame_time = perf_freq / FRAMERATE;
+ frame_time = perf_freq / (2 * FRAMERATE);
for (size_t i = 0; i < sizeof(windows_scancode_table) / sizeof(SDL_Scancode); i++) {
inverted_scancode_table[windows_scancode_table[i]] = i;
diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c
index a3c9817..8c61830 100644
index 5fda297..35d50db 100644
--- a/src/pc/pc_main.c
+++ b/src/pc/pc_main.c
@@ -84,6 +84,25 @@ void send_display_list(struct SPTask *spTask) {
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -14,7 +14,8 @@
// Markers
#define TEXT_OPT_HIGHLIGHT _("O")
#define TEXT_OPT_L_HIGHLIGHT _(">")
#define TEXT_OPT_R_HIGHLIGHT _("<")
#define TEXT_OPT_UNBOUND _("NONE")
// Language specific strings
+38 -4
View File
@@ -1,15 +1,49 @@
#include "platform_info.h"
unsigned char gSoundDataADSR[] = {
#include "sound/sound_data.ctl.inc.c"
#if IS_BIG_ENDIAN && IS_64_BIT
#include "sound/sound_data.ctl.be.64.inc.c"
#elif IS_BIG_ENDIAN && !IS_64_BIT
#include "sound/sound_data.ctl.be.32.inc.c"
#elif !IS_BIG_ENDIAN && IS_64_BIT
#include "sound/sound_data.ctl.le.64.inc.c"
#elif !IS_BIG_ENDIAN && !IS_64_BIT
#include "sound/sound_data.ctl.le.32.inc.c"
#endif
};
unsigned char gSoundDataRaw[] = {
#include "sound/sound_data.tbl.inc.c"
#if IS_BIG_ENDIAN && IS_64_BIT
#include "sound/sound_data.tbl.be.64.inc.c"
#elif IS_BIG_ENDIAN && !IS_64_BIT
#include "sound/sound_data.tbl.be.32.inc.c"
#elif !IS_BIG_ENDIAN && IS_64_BIT
#include "sound/sound_data.tbl.le.64.inc.c"
#elif !IS_BIG_ENDIAN && !IS_64_BIT
#include "sound/sound_data.tbl.le.32.inc.c"
#endif
};
unsigned char gMusicData[] = {
#include "sound/sequences.bin.inc.c"
#if IS_BIG_ENDIAN && IS_64_BIT
#include "sound/sequences.bin.be.64.inc.c"
#elif IS_BIG_ENDIAN && !IS_64_BIT
#include "sound/sequences.bin.be.32.inc.c"
#elif !IS_BIG_ENDIAN && IS_64_BIT
#include "sound/sequences.bin.le.64.inc.c"
#elif !IS_BIG_ENDIAN && !IS_64_BIT
#include "sound/sequences.bin.le.32.inc.c"
#endif
};
unsigned char gBankSetsData[] = {
#include "sound/bank_sets.inc.c"
#if IS_BIG_ENDIAN && IS_64_BIT
#include "sound/bank_sets.be.64.inc.c"
#elif IS_BIG_ENDIAN && !IS_64_BIT
#include "sound/bank_sets.be.32.inc.c"
#elif !IS_BIG_ENDIAN && IS_64_BIT
#include "sound/bank_sets.le.64.inc.c"
#elif !IS_BIG_ENDIAN && !IS_64_BIT
#include "sound/bank_sets.le.32.inc.c"
#endif
};
+12 -5
View File
@@ -851,7 +851,11 @@ void find_surface_on_ray_list(struct SurfaceNode *list, Vec3f orig, Vec3f dir, f
// Reject surface if out of vertical bounds
if (list->surface->lowerY > top || list->surface->upperY < bottom)
continue;
// Reject no-cam collision surfaces
if (gCheckingSurfaceCollisionsForCamera && (list->surface->flags & SURFACE_FLAG_NO_CAM_COLLISION))
continue;
// Check intersection between the ray and this surface
if ((hit = ray_surface_intersect(orig, dir, dir_length, list->surface, chk_hit_pos, &length)) != 0)
{
@@ -919,13 +923,16 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve
find_surface_on_ray_cell(cellX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length);
return;
}
// increase collision checking precision (normally 1)
f32 precision = gCheckingSurfaceCollisionsForCamera ? 3 : 1;
// Get cells we cross using DDA
if (absx(dir[0]) >= absx(dir[2]))
step = absx(dir[0]) / CELL_SIZE;
step = precision * absx(dir[0]) / CELL_SIZE;
else
step = absx(dir[2]) / CELL_SIZE;
step = precision * absx(dir[2]) / CELL_SIZE;
dx = dir[0] / step / CELL_SIZE;
dz = dir[2] / step / CELL_SIZE;
@@ -4,6 +4,14 @@ struct Struct8032F754 D_8032F754[] = { { 145, { 0.7f, 1.5f, 0.7f }, 7.0f },
{ 235, { 1.2f, 2.0f, 1.2f }, 11.6f } };
void bhv_checkerboard_elevator_group_init(void) {
// Added to prevent a crash in the vanish cap stage
cur_obj_hide();
// Here's the theory: Since it is only valid for a few frames, I believe
// the model gets deallocated after removal. Since changing the camera
// precision makes the camera end up in a slightly different spot, it
// could be trying to render the object when `precision` is set to 3 but
// not to 1.
s32 sp3C;
s32 sp38;
s32 sp34;
+2 -3
View File
@@ -181,10 +181,9 @@ void bhv_snufit_balls_loop(void) {
// If far from Mario or in a different room, despawn.
if ((o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)
#ifndef NODRAWINGDISTANCE
|| (o->oTimer != 0 && o->oDistanceToMario > 1500.0f)) {
#else
|| (o->oTimer != 0)) {
|| (o->oTimer != 0 && o->oDistanceToMario > 1500.0f)
#endif
){
obj_mark_for_deletion(o);
}
+71 -15
View File
@@ -10,12 +10,16 @@
#include "engine/surface_collision.h"
#include "pc/configfile.h"
#include "pc/controller/controller_mouse.h"
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
//quick and dirty fix for some older MinGW.org mingwrt
#else
#include <stdio.h>
#endif
#define NEW_CAM_BOUNDING_BOX_RAYS 4
#define NEW_CAM_BOUNDING_BOX_HRADIUS 250
#define NEW_CAM_BOUNDING_BOX_VRADIUS 100
/**
Quick explanation of the camera modes
@@ -269,18 +273,18 @@ static void newcam_rotate_button(void) {
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gDefaultSoundArgs);
#endif
if (newcam_modeflags & NC_FLAG_8D)
newcam_yaw_target = newcam_yaw_target+(ivrt(newcam_invertX)*0x2000);
newcam_yaw_target = newcam_yaw_target+(ivrt(0)*0x2000);
else
newcam_yaw_target = newcam_yaw_target+(ivrt(newcam_invertX)*0x4000);
newcam_yaw_target = newcam_yaw_target+(ivrt(0)*0x4000);
newcam_centering = 1;
} else if ((gPlayer1Controller->buttonPressed & R_CBUTTONS) && newcam_analogue == 0) {
#ifndef nosound
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gDefaultSoundArgs);
#endif
if (newcam_modeflags & NC_FLAG_8D)
newcam_yaw_target = newcam_yaw_target-(ivrt(newcam_invertX)*0x2000);
newcam_yaw_target = newcam_yaw_target-(ivrt(0)*0x2000);
else
newcam_yaw_target = newcam_yaw_target-(ivrt(newcam_invertX)*0x4000);
newcam_yaw_target = newcam_yaw_target-(ivrt(0)*0x4000);
newcam_centering = 1;
}
} else if (newcam_modeflags & NC_FLAG_XTURN) {
@@ -314,7 +318,7 @@ static void newcam_rotate_button(void) {
newcam_framessincec[1] ++;
if ((gPlayer1Controller->buttonPressed & L_CBUTTONS) && newcam_modeflags & NC_FLAG_XTURN && !(newcam_modeflags & NC_FLAG_8D) && newcam_analogue == 0) {
if (newcam_framessincec[0] < 6) {
newcam_yaw_target = newcam_yaw+(ivrt(newcam_invertX)*0x3000);
newcam_yaw_target = newcam_yaw+(ivrt(0)*0x3000);
newcam_centering = 1;
#ifndef nosound
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gDefaultSoundArgs);
@@ -324,7 +328,7 @@ static void newcam_rotate_button(void) {
}
if ((gPlayer1Controller->buttonPressed & R_CBUTTONS) && newcam_modeflags & NC_FLAG_XTURN && !(newcam_modeflags & NC_FLAG_8D) && newcam_analogue == 0) {
if (newcam_framessincec[1] < 6) {
newcam_yaw_target = newcam_yaw-(ivrt(newcam_invertX)*0x3000);
newcam_yaw_target = newcam_yaw-(ivrt(0)*0x3000);
newcam_centering = 1;
#ifndef nosound
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gDefaultSoundArgs);
@@ -350,14 +354,14 @@ static void newcam_rotate_button(void) {
#endif
if (newcam_stick2[0] > 20) {
if (newcam_modeflags & NC_FLAG_8D)
newcam_yaw_target = newcam_yaw_target+(ivrt(newcam_invertX)*0x2000);
newcam_yaw_target = newcam_yaw_target+(ivrt(0)*0x2000);
else
newcam_yaw_target = newcam_yaw_target+(ivrt(newcam_invertX)*0x4000);
newcam_yaw_target = newcam_yaw_target+(ivrt(0)*0x4000);
} else {
if (newcam_modeflags & NC_FLAG_8D)
newcam_yaw_target = newcam_yaw_target-(ivrt(newcam_invertX)*0x2000);
newcam_yaw_target = newcam_yaw_target-(ivrt(0)*0x2000);
else
newcam_yaw_target = newcam_yaw_target-(ivrt(newcam_invertX)*0x4000);
newcam_yaw_target = newcam_yaw_target-(ivrt(0)*0x4000);
}
}
} else {
@@ -425,9 +429,9 @@ static void newcam_update_values(void) {
u8 waterflag = 0;
if (newcam_modeflags & NC_FLAG_XTURN)
newcam_yaw -= ((newcam_yaw_acc*(newcam_sensitivityX/10))*ivrt(newcam_invertX));
newcam_yaw -= ((newcam_yaw_acc*(newcam_sensitivityX/10))*ivrt(0));
if (((newcam_tilt <= 12000) && (newcam_tilt >= -12000)) && newcam_modeflags & NC_FLAG_YTURN)
newcam_tilt += ((newcam_tilt_acc*ivrt(newcam_invertY))*(newcam_sensitivityY/10));
newcam_tilt += ((newcam_tilt_acc*ivrt(1))*(newcam_sensitivityY/10));
if (newcam_tilt > 12000)
newcam_tilt = 12000;
@@ -473,6 +477,47 @@ static void newcam_update_values(void) {
}
}
static void newcam_bounding_box(void) {
Vec3f camdirs[NEW_CAM_BOUNDING_BOX_RAYS] = { 0 };
Vec3f raypos[NEW_CAM_BOUNDING_BOX_RAYS] = { 0 };
s16 antiYaw = newcam_yaw - 0x4000;
// sideways ray 1
camdirs[0][0] = coss(antiYaw) * NEW_CAM_BOUNDING_BOX_HRADIUS;
camdirs[0][2] = sins(antiYaw) * NEW_CAM_BOUNDING_BOX_HRADIUS;
// sideways ray 2
camdirs[1][0] = -coss(antiYaw) * NEW_CAM_BOUNDING_BOX_HRADIUS;
camdirs[1][2] = -sins(antiYaw) * NEW_CAM_BOUNDING_BOX_HRADIUS;
// vertical rays
camdirs[2][1] = -NEW_CAM_BOUNDING_BOX_VRADIUS;
camdirs[3][1] = NEW_CAM_BOUNDING_BOX_VRADIUS;
for (int i = 0; i < NEW_CAM_BOUNDING_BOX_RAYS; i++) {
struct Surface* surf;
Vec3f offset = { 0 };
Vec3f startpos = { 0 };
vec3f_copy(startpos, newcam_pos);
vec3f_add(startpos, offset);
find_surface_on_ray(startpos, camdirs[i], &surf, raypos[i]);
if (!surf) {
vec3f_copy(raypos[i], startpos);
vec3f_add(raypos[i], camdirs[i]);
}
}
Vec3f avg = { 0 };
for (int i = 0; i < NEW_CAM_BOUNDING_BOX_RAYS; i++) {
vec3f_add(avg, raypos[i]);
}
vec3f_mul(avg, 1.0f / ((f32)NEW_CAM_BOUNDING_BOX_RAYS));
vec3f_copy(newcam_pos, avg);
}
static void newcam_collision(void) {
struct Surface *surf;
Vec3f camdir;
@@ -483,11 +528,20 @@ static void newcam_collision(void) {
camdir[2] = newcam_pos[2]-newcam_lookat[2];
find_surface_on_ray(newcam_pos_target, camdir, &surf, hitpos);
newcam_coldist = sqrtf((newcam_pos_target[0] - hitpos[0]) * (newcam_pos_target[0] - hitpos[0]) + (newcam_pos_target[1] - hitpos[1]) * (newcam_pos_target[1] - hitpos[1]) + (newcam_pos_target[2] - hitpos[2]) * (newcam_pos_target[2] - hitpos[2]));
if (surf) {
// offset the hit pos by the hit normal
Vec3f offset = { 0 };
offset[0] = surf->normal.x;
offset[1] = surf->normal.y;
offset[2] = surf->normal.z;
vec3f_mul(offset, 5.0f);
vec3f_add(hitpos, offset);
newcam_pos[0] = hitpos[0];
newcam_pos[1] = approach_f32(hitpos[1],newcam_pos[1],25,-25);
newcam_pos[1] = hitpos[1];
newcam_pos[2] = hitpos[2];
newcam_pan_x = 0;
newcam_pan_z = 0;
@@ -541,8 +595,10 @@ static void newcam_position_cam(void) {
if (newcam_modeflags & NC_FLAG_FOCUSZ)
newcam_lookat[2] = newcam_pos_target[2]-newcam_pan_z;
if (newcam_modeflags & NC_FLAG_COLLISION)
newcam_collision();
if (newcam_modeflags & NC_FLAG_COLLISION) {
newcam_collision();
newcam_bounding_box();
}
}
+1 -1
View File
@@ -1754,7 +1754,7 @@ s32 act_flying(struct MarioState *m) {
set_camera_mode(m->area->camera, CAMERA_MODE_BEHIND_MARIO, 1);
#else
if (newcam_active == 0)
set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
set_camera_mode(m->area->camera, CAMERA_MODE_BEHIND_MARIO, 1);
else
{
m->area->camera->mode = CAMERA_MODE_NEWCAM;
+1
View File
@@ -9,6 +9,7 @@
#define MEMORY_POOL_RIGHT 1
#define GFX_POOL_SIZE (512 * 1024)
#define DEFAULT_POOL_SIZE (0x165000 * 8)
struct AllocOnlyPool
{
+26 -25
View File
@@ -1,7 +1,7 @@
#ifdef EXT_OPTIONS_MENU
#include "sm64.h"
#include "include/text_strings.h"
#include "text_strings.h"
#include "engine/math_util.h"
#include "audio/external.h"
#include "game/camera.h"
@@ -45,10 +45,14 @@ static const u8 toggleStr[][16] = {
{ TEXT_OPT_ENABLED },
};
static const u8 menuStr[][32] = {
{ TEXT_OPT_HIGHLIGHT },
static const u8 optSmallStr[][32] = {
{ TEXT_OPT_BUTTON1 },
{ TEXT_OPT_BUTTON2 },
{ TEXT_OPT_L_HIGHLIGHT },
{ TEXT_OPT_R_HIGHLIGHT },
};
static const u8 menuStr[][32] = {
{ TEXT_OPT_OPTIONS },
{ TEXT_OPT_CAMERA },
{ TEXT_OPT_CONTROLS },
@@ -56,7 +60,6 @@ static const u8 menuStr[][32] = {
{ TEXT_OPT_AUDIO },
{ TEXT_EXIT_GAME },
{ TEXT_OPT_CHEATS },
};
static const u8 optsCameraStr[][32] = {
@@ -122,7 +125,7 @@ static const u8 bindStr[][32] = {
{ TEXT_BIND_LEFT },
{ TEXT_BIND_RIGHT },
{ TEXT_OPT_DEADZONE },
{ TEXT_OPT_RUMBLE }
{ TEXT_OPT_RUMBLE },
};
static const u8 *filterChoices[] = {
@@ -285,28 +288,28 @@ static struct Option optsCheats[] = {
/* submenu definitions */
#ifdef BETTERCAMERA
static struct SubMenu menuCamera = DEF_SUBMENU( menuStr[4], optsCamera );
static struct SubMenu menuCamera = DEF_SUBMENU( menuStr[1], optsCamera );
#endif
static struct SubMenu menuControls = DEF_SUBMENU( menuStr[5], optsControls );
static struct SubMenu menuVideo = DEF_SUBMENU( menuStr[6], optsVideo );
static struct SubMenu menuAudio = DEF_SUBMENU( menuStr[7], optsAudio );
static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[9], optsCheats );
static struct SubMenu menuControls = DEF_SUBMENU( menuStr[2], optsControls );
static struct SubMenu menuVideo = DEF_SUBMENU( menuStr[3], optsVideo );
static struct SubMenu menuAudio = DEF_SUBMENU( menuStr[4], optsAudio );
static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[6], optsCheats );
/* main options menu definition */
static struct Option optsMain[] = {
#ifdef BETTERCAMERA
DEF_OPT_SUBMENU( menuStr[4], &menuCamera ),
DEF_OPT_SUBMENU( menuStr[1], &menuCamera ),
#endif
DEF_OPT_SUBMENU( menuStr[5], &menuControls ),
DEF_OPT_SUBMENU( menuStr[6], &menuVideo ),
DEF_OPT_SUBMENU( menuStr[7], &menuAudio ),
DEF_OPT_BUTTON ( menuStr[8], optmenu_act_exit ),
DEF_OPT_SUBMENU( menuStr[2], &menuControls ),
DEF_OPT_SUBMENU( menuStr[3], &menuVideo ),
DEF_OPT_SUBMENU( menuStr[4], &menuAudio ),
DEF_OPT_BUTTON ( menuStr[5], optmenu_act_exit ),
// NOTE: always keep cheats the last option here because of the half-assed way I toggle them
DEF_OPT_SUBMENU( menuStr[9], &menuCheats )
DEF_OPT_SUBMENU( menuStr[6], &menuCheats )
};
static struct SubMenu menuMain = DEF_SUBMENU( menuStr[3], optsMain );
static struct SubMenu menuMain = DEF_SUBMENU( menuStr[0], optsMain );
/* implementation */
@@ -465,6 +468,7 @@ void optmenu_draw(void) {
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 80, SCREEN_WIDTH, SCREEN_HEIGHT);
for (u8 i = 0; i < currentMenu->numOpts; i++) {
scroll = 140 - 32 * i + currentMenu->scroll * 32;
// FIXME: just start from the first visible option bruh
@@ -473,18 +477,16 @@ void optmenu_draw(void) {
}
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin);
print_hud_lut_string(HUD_LUT_GLOBAL, 80, 90 + (32 * (currentMenu->select - currentMenu->scroll)), menuStr[0]);
print_hud_lut_string(HUD_LUT_GLOBAL, 224, 90 + (32 * (currentMenu->select - currentMenu->scroll)), menuStr[0]);
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end);
print_generic_string(72, 132 - (32 * (currentMenu->select - currentMenu->scroll)), optSmallStr[2]);
print_generic_string(232, 132 - (32 * (currentMenu->select - currentMenu->scroll)), optSmallStr[3]);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
}
//This has been separated for interesting reasons. Don't question it.
void optmenu_draw_prompt(void) {
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
optmenu_draw_text(264, 212, menuStr[1 + optmenu_open], 0);
optmenu_draw_text(264, 212, optSmallStr[optmenu_open], 0);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
}
@@ -506,7 +508,6 @@ void optmenu_toggle(void) {
currentMenu = &menuMain;
optmenu_open = 1;
/* Resets l_counter to 0 every time the options menu is open */
l_counter = 0;
} else {
@@ -538,7 +539,7 @@ void optmenu_check_buttons(void) {
if (gPlayer1Controller->buttonPressed & R_TRIG)
optmenu_toggle();
/* Enables cheats if the user press the L trigger 3 times while in the options menu. Also plays a sound. */
if ((gPlayer1Controller->buttonPressed & L_TRIG) && !Cheats.EnableCheats) {
+6
View File
@@ -615,6 +615,12 @@ u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex) {
return starFlags;
}
u32 save_file_get_cannon_flags(s32 fileIndex, s32 courseIndex) {
if (gSaveBuffer.files[fileIndex][0].courseStars[courseIndex+1] & 0x80){return 1;}
return 0;
}
/**
* Add to the bitset of obtained stars in the specified course.
+1
View File
@@ -135,6 +135,7 @@ void save_file_set_flags(u32 flags);
void save_file_clear_flags(u32 flags);
u32 save_file_get_flags(void);
u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex);
u32 save_file_get_cannon_flags(s32 fileIndex, s32 courseIndex);
void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags);
s32 save_file_get_course_coin_score(s32 fileIndex, s32 courseIndex);
s32 save_file_is_cannon_unlocked(void);
+7 -5
View File
@@ -81,7 +81,7 @@ static s32 write_text_save(s32 fileIndex) {
struct MainMenuSaveData *menudata;
char filename[SYS_MAX_PATH] = { 0 };
char value[64];
u32 i, bit, flags, coins, stars, starFlags;
u32 i, bit, flags, coins, stars, starFlags, cannonFlag;
if (snprintf(filename, sizeof(filename), FILENAME_FORMAT, fs_writepath, fileIndex) < 0)
return -1;
@@ -133,9 +133,10 @@ static s32 write_text_save(s32 fileIndex) {
for (i = 0; i < NUM_COURSES; i++) {
stars = save_file_get_star_flags(fileIndex, i);
coins = save_file_get_course_coin_score(fileIndex, i);
cannonFlag = save_file_get_cannon_flags(fileIndex, i);
starFlags = int_to_bin(stars); // 63 -> 111111
fprintf(file, "%s = \"%d, %07d\"\n", sav_courses[i], coins, starFlags);
fprintf(file, "%s = \"%d, %07d, %d\"\n", sav_courses[i], coins, starFlags,cannonFlag);
}
fprintf(file, "\n[bonus]\n");
@@ -208,7 +209,7 @@ static s32 read_text_save(s32 fileIndex) {
const char *value;
ini_t *savedata;
u32 i, flag, coins, stars, starFlags;
u32 i, flag, coins, stars, starFlags, cannonFlag;
u32 capArea;
if (snprintf(filename, sizeof(filename), FILENAME_FORMAT, fs_writepath, fileIndex) < 0)
@@ -255,9 +256,10 @@ static s32 read_text_save(s32 fileIndex) {
for (i = 0; i < NUM_COURSES; i++) {
value = ini_get(savedata, "courses", sav_courses[i]);
if (value) {
sscanf(value, "%d, %d", &coins, &stars);
sscanf(value, "%d, %d, %d", &coins, &stars, &cannonFlag);
starFlags = bin_to_int(stars); // 111111 -> 63
cannonFlag <<= 7; //Shifts the bit to the most significant bit.
save_file_set_star_flags(fileIndex, i+1, cannonFlag); //
save_file_set_star_flags(fileIndex, i, starFlags);
gSaveBuffer.files[fileIndex][0].courseCoinScores[i] = coins;
}
+190
View File
@@ -0,0 +1,190 @@
#ifdef AAPI_SDL1
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <SDL/SDL.h>
#include "audio_api.h"
#define SNDPACKETLEN (8 * 1024)
// this is basically SDL_dataqueue but slightly less generic
typedef struct sndpacket {
size_t datalen; /* bytes currently in use in this packet. */
size_t startpos; /* bytes currently consumed in this packet. */
struct sndpacket *next; /* next item in linked list. */
Uint8 data[]; /* packet data */
} sndpacket_t;
static sndpacket_t *qhead;
static sndpacket_t *qtail;
static sndpacket_t *qpool;
static size_t queued;
static SDL_AudioSpec aspec;
static int was_init = 0;
static void sndqueue_init(const size_t bufsize) {
const size_t wantpackets = (bufsize + (SNDPACKETLEN - 1)) / SNDPACKETLEN;
for (size_t i = 0; i < wantpackets; ++i) {
sndpacket_t *packet = malloc(sizeof(sndpacket_t) + SNDPACKETLEN);
if (packet) {
packet->datalen = 0;
packet->startpos = 0;
packet->next = qpool;
qpool = packet;
}
}
}
static size_t sndqueue_read(void *buf, size_t len) {
sndpacket_t *packet;
Uint8 *ptr = buf;
while ((len > 0) && ((packet = qhead) != NULL)) {
const size_t avail = packet->datalen - packet->startpos;
const size_t tx = (len < avail) ? len : avail;
memcpy(ptr, packet->data + packet->startpos, tx);
packet->startpos += tx;
ptr += tx;
queued -= tx;
len -= tx;
if (packet->startpos == packet->datalen) {
qhead = packet->next;
packet->next = qpool;
qpool = packet;
}
}
if (qhead == NULL)
qtail = NULL;
return (size_t)(ptr - (Uint8*)buf);
}
static inline sndpacket_t *alloc_sndpacket(void) {
sndpacket_t *packet = qpool;
if (packet) {
qpool = packet->next;
} else {
packet = malloc(sizeof(sndpacket_t) + SNDPACKETLEN);
if (!packet) return NULL;
}
packet->datalen = 0;
packet->startpos = 0;
packet->next = NULL;
if (qtail == NULL)
qhead = packet;
else
qtail->next = packet;
qtail = packet;
return packet;
}
static int sndqueue_push(const void *data, size_t len) {
sndpacket_t *orighead = qhead;
sndpacket_t *origtail = qtail;
size_t origlen = origtail ? origtail->datalen : 0;
Uint8 *ptr = data;
while (len > 0) {
sndpacket_t *packet = qtail;
if (!packet || (packet->datalen >= SNDPACKETLEN)) {
packet = alloc_sndpacket();
if (!packet) {
// out of memory, fuck everything
return -1;
}
}
const size_t room = SNDPACKETLEN - packet->datalen;
const size_t datalen = (len < room) ? len : room;
memcpy(packet->data + packet->datalen, ptr, datalen);
ptr += datalen;
len -= datalen;
packet->datalen += datalen;
queued += datalen;
}
return 0;
}
static void audio_drain(void *user, Uint8 *buf, int len) {
const size_t tx = sndqueue_read(buf, len);
buf += tx;
len -= (int)tx;
if (len > 0) memset(buf, aspec.silence, len);
}
static bool audio_sdl_init(void) {
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
fprintf(stderr, "SDL init error: %s\n", SDL_GetError());
return false;
}
SDL_AudioSpec want, have;
memset(&want, 0, sizeof(want));
want.freq = 32000;
want.format = AUDIO_S16SYS;
want.channels = 2;
want.samples = 512;
want.callback = audio_drain;
if (SDL_OpenAudio(&want, &have) == -1) {
fprintf(stderr, "SDL_OpenAudio error: %s\n", SDL_GetError());
return false;
}
aspec = have;
was_init = 1;
SDL_PauseAudio(0);
return true;
}
static int audio_sdl_buffered(void) {
SDL_LockAudio();
int len = queued / 4;
SDL_UnlockAudio();
return len;
}
static int audio_sdl_get_desired_buffered(void) {
return 1100;
}
static void audio_sdl_play(const uint8_t *buf, size_t len) {
SDL_LockAudio();
// Don't fill the audio buffer too much in case this happens
if (queued / 4 < 6000)
sndqueue_push(buf, len);
SDL_UnlockAudio();
}
static void audio_sdl_shutdown(void) {
if (SDL_WasInit(SDL_INIT_AUDIO)) {
if (was_init) {
SDL_CloseAudio();
was_init = 0;
}
SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
}
struct AudioAPI audio_sdl = {
audio_sdl_init,
audio_sdl_buffered,
audio_sdl_get_desired_buffered,
audio_sdl_play,
audio_sdl_shutdown
};
#endif
@@ -11,10 +11,11 @@ static bool audio_sdl_init(void) {
fprintf(stderr, "SDL init error: %s\n", SDL_GetError());
return false;
}
SDL_AudioSpec want, have;
SDL_zero(want);
want.freq = 32000;
want.format = AUDIO_S16;
want.format = AUDIO_S16SYS;
want.channels = 2;
want.samples = 512;
want.callback = NULL;
+13
View File
@@ -3,6 +3,7 @@
#include "cheats.h"
#include "pc_main.h"
#include "platform.h"
#include "macros.h"
#include <strings.h>
#include <stdlib.h>
@@ -34,6 +35,12 @@ static inline int arg_string(const char *name, const char *value, char *target)
return 1;
}
static inline int arg_uint(UNUSED const char *name, const char *value, unsigned int *target) {
const unsigned long int v = strtoul(value, NULL, 0);
*target = v;
return 1;
}
void parse_cli_opts(int argc, char* argv[]) {
// Initialize options with false values.
memset(&gCLIOpts, 0, sizeof(gCLIOpts));
@@ -51,6 +58,12 @@ void parse_cli_opts(int argc, char* argv[]) {
else if (strcmp(argv[i], "--cheats") == 0) // Enable cheats menu
Cheats.EnableCheats = true;
else if (strcmp(argv[i], "--poolsize") == 0) // Main pool size
arg_uint("--poolsize", argv[++i], &gCLIOpts.PoolSize);
else if (strcmp(argv[i], "--syncframes") == 0) // VBlanks to wait
arg_uint("--syncframes", argv[++i], &gCLIOpts.SyncFrames);
else if (strcmp(argv[i], "--configfile") == 0 && (i + 1) < argc)
arg_string("--configfile", argv[++i], gCLIOpts.ConfigFile);

Some files were not shown because too many files have changed in this diff Show More