Compare commits

...

27 Commits

Author SHA1 Message Date
Gregory Heskett
8676898ae9 Implement sdata 2024-11-02 22:59:04 -04:00
Lila
c4c18b3d0e Check for opensuse's cross mips gcc package (#842)
Makes it possible to rely on the official repo.
Ideally the following instructions would also be added to the wiki for opensuse:
```
sudo zypper install cross-mips-binutils git capstone pkgconf python311 cross-mips-gcc14
# install packages under devel_basis, equivalent to build-essential in deb
sudo zypper install --type pattern devel_basis
```
2024-10-31 14:08:08 -04:00
thecozies
7298e94a1f reset adjacent rooms when loading a new area (#704) 2024-09-05 01:48:26 -04:00
Gregory Heskett
27d328f86a Dialogs in dialogs.h no longer have to be in order (#832) 2024-09-05 01:13:05 -04:00
Gregory Heskett
27372fe74a Merge pull request #795 from gheskett/develop/2.3.0_update-unf
Update to newest UNF (d5f2ad100b76e372036453f8d25f9b6fbbbd2d1a) (November 22, 2023)
2024-09-05 01:07:23 -04:00
Reonu
3f1f7f41be Add Arthurtilly to the CODEOWNERS file (#821)
* Add Arthurtilly to the CODEOWNERS file

* Update CODEOWNERS file to list each global owner on the same line

This should (allegedly) fix the issues of only the last entry being treated as an owner for reviews.

* Remove thecozies from CODEOWNERS file :(

---------

Co-authored-by: Gregory Heskett <gheskett@gmail.com>
2024-09-04 23:24:02 -04:00
Denis Kopyrin
bf70500b4d Merge pull request #825 from Lilaa3/fast64-repo-settings
Add Fast64 repo settings file (fast64.json)
2024-09-05 07:51:25 +08:00
Lila
27fedee76f Update fast64.json 2024-09-04 10:38:21 +01:00
Lila
a918785a92 Aglab requested change 2024-08-25 19:26:57 +01:00
Lila
10720ea056 Fall back on fast64 default draw layers 2024-08-24 13:05:36 +01:00
Lila
8dc47095e2 Add repo settings file
Allows fast64 to know a repo's ideal settings as soon as decomp path is picked.
Settings are the default except for:
Matstack is on
Microcode is set to EX2
Force Extended RAM is off because hackersm64 already has it enabled by default
Refresh is set to Refresh 13
2024-08-19 15:44:53 +01:00
Gregory Heskett
e3472e05cf Add option for .local/share/HackerSM64/UNFLoader-dir.txt
This allows referencing a custom UNFLoader path to be used, ideally for placing on the C drive for WSL instances. UNFLoader tends to hang for an unbearably long time when saved somewhere within the WSL directory structure, and simply using the Linux build isn't an option because it can't access Windows USB devices trivially.
2024-08-03 19:57:50 -04:00
Gregory Heskett
74cb8ce062 Update to newest UNF (d5f2ad100b76e372036453f8d25f9b6fbbbd2d1a) (November 22 2023) 2024-08-03 19:33:09 -04:00
Gregory Heskett
9ef945296b HackerSM64 Release: v2.3.0
Merge pull request #815 from HackerN64/develop/2.3.0
2024-07-03 23:05:21 -04:00
Gregory Heskett
e1c00d4bef HackerSM64 v2.3.0 2024-07-03 22:50:27 -04:00
Reonu
aacf2c5e6d Add more audio banks and add some occasional mappings for audio macros (#777)
* Add more audio banks and add some occasional mappings for audio macros

* Remove config define for extra sound banks

---------

Co-authored-by: gheskett <gheskett@gmail.com>
2024-07-03 22:50:27 -04:00
Gregory Heskett
4500ffb579 Bugfix: assemble_sound.py build corruption issues (#813) 2024-07-03 22:50:27 -04:00
Gregory Heskett
a6782e6912 Fix seg faulting issue with MinGW build system, most likely caused by use of execl (#812) 2024-07-03 22:50:27 -04:00
Denis Kopyrin
750ba10cb1 Fixed audiofile warnings properly (#814)
* Revert "Fixed audiofile warnings (#811)"

This reverts commit 500507509b.

* Fixed audiofile warnings properly
2024-07-03 22:50:01 -04:00
Denis Kopyrin
500507509b Fixed audiofile warnings (#811) 2024-07-01 21:53:54 -04:00
Gregory Heskett
7381e35db4 Bugfix: Surfaces not able to be placed at the beginning of a partition (#805)
* Bugfix: Surfaces not able to be placed at the beginning of a partition

* Replace clear_spacial_partition calls with a bzero
2024-07-01 21:48:26 -04:00
Gregory Heskett
6a3e7e7a87 Bugfix: Missed purging of debug box flags that no longer exist in Puppycam (#804) 2024-07-01 21:47:38 -04:00
Gregory Heskett
9adb8c6de8 EASIER_LONG_JUMPS: only long jump with A+Z while running (#801)
Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com>
2024-07-01 21:47:15 -04:00
Gregory Heskett
03ba81b5e3 Improve DEATH_ON_EXIT_COURSE define (#808) 2024-07-01 21:46:46 -04:00
Gregory Heskett
98b6231216 Pressing L in debug fly mode heals Mario (#809) 2024-07-01 21:46:12 -04:00
Denis Kopyrin
252a900b91 Added support for windows MinGW build (#800) 2024-07-01 21:45:36 -04:00
Denis Kopyrin
92822c6412 fixlights: added support for ripgrep (#802) 2024-07-01 21:44:54 -04:00
59 changed files with 2050 additions and 531 deletions

View File

@@ -27,7 +27,8 @@
"F3DEX_GBI_2=1", "F3DEX_GBI_2=1",
"F3DZEX_NON_GBI_2=1", "F3DZEX_NON_GBI_2=1",
"F3DEX_GBI_SHARED=1", "F3DEX_GBI_SHARED=1",
"LIBPL=1" "LIBPL=1",
"SDATA=1"
], ],
"compilerPath": "/usr/bin/mips-linux-gnu-gcc", "compilerPath": "/usr/bin/mips-linux-gnu-gcc",
"cStandard": "gnu17", "cStandard": "gnu17",

View File

@@ -2,9 +2,7 @@
# Each line is a file pattern followed by one or more owners. # Each line is a file pattern followed by one or more owners.
# These owners will be the default owners for everything in the repo. # These owners will be the default owners for everything in the repo.
* @Reonu * @Reonu @gheskett @arthurtilly
* @thecozies
* @gheskett
# Order is important. The last matching pattern has the most precedence. # Order is important. The last matching pattern has the most precedence.
# So if a pull request only touches javascript files, only these owners # So if a pull request only touches javascript files, only these owners

View File

@@ -265,6 +265,15 @@ ifeq ($(LIBPL),1)
SRC_DIRS += $(LIBPL_DIR) SRC_DIRS += $(LIBPL_DIR)
endif endif
# SDATA - use 64kb sdata and sbss sections to enhance performance (requires some housekeeping; recommended for experienced hackers only)
# 1 - includes sdata and sbss in ROM
# 0 - does not
SDATA ?= 0
$(eval $(call validate-option,SDATA,0 1))
ifeq ($(SDATA),1)
DEFINES += SDATA=1
endif
BUILD_DIR_BASE := build BUILD_DIR_BASE := build
# BUILD_DIR is the location where all build artifacts are placed # BUILD_DIR is the location where all build artifacts are placed
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_$(CONSOLE) BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_$(CONSOLE)
@@ -448,6 +457,8 @@ else ifneq ($(call find-command,mips64-none-elf-ld),)
CROSS := mips64-none-elf- CROSS := mips64-none-elf-
else ifneq ($(call find-command,mips-ld),) else ifneq ($(call find-command,mips-ld),)
CROSS := mips- CROSS := mips-
else ifneq ($(call find-command,mips-suse-linux-ld ),)
CROSS := mips-suse-linux-
else else
$(error Unable to detect a suitable MIPS toolchain installed) $(error Unable to detect a suitable MIPS toolchain installed)
endif endif
@@ -464,6 +475,10 @@ ifeq ($(COMPILER),gcc)
CXX := $(CROSS)g++ CXX := $(CROSS)g++
$(BUILD_DIR)/actors/%.o: OPT_FLAGS := -Ofast -mlong-calls $(BUILD_DIR)/actors/%.o: OPT_FLAGS := -Ofast -mlong-calls
$(BUILD_DIR)/levels/%.o: OPT_FLAGS := -Ofast -mlong-calls $(BUILD_DIR)/levels/%.o: OPT_FLAGS := -Ofast -mlong-calls
ifeq ($(SDATA),1)
$(BUILD_DIR)/actors/%.o: CFLAGS += -G 0
$(BUILD_DIR)/levels/%.o: CFLAGS += -G 0
endif
else ifeq ($(COMPILER),clang) else ifeq ($(COMPILER),clang)
CC := clang CC := clang
CXX := clang++ CXX := clang++
@@ -504,17 +519,25 @@ C_DEFINES := $(foreach d,$(DEFINES),-D$(d))
DEF_INC_CFLAGS := $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(C_DEFINES) DEF_INC_CFLAGS := $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(C_DEFINES)
# C compiler options # C compiler options
CFLAGS = -G 0 $(OPT_FLAGS) $(TARGET_CFLAGS) $(MIPSISET) $(DEF_INC_CFLAGS) CFLAGS = $(OPT_FLAGS) $(TARGET_CFLAGS) $(MIPSISET) $(DEF_INC_CFLAGS)
ifeq ($(COMPILER),gcc) ifeq ($(COMPILER),gcc)
CFLAGS += -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra CFLAGS += -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra -Wno-missing-braces
CFLAGS += -Wno-missing-braces
else ifeq ($(COMPILER),clang) else ifeq ($(COMPILER),clang)
CFLAGS += -mfpxx -target mips -mabi=32 -G 0 -mhard-float -fomit-frame-pointer -fno-stack-protector -fno-common -I include -I src/ -I $(BUILD_DIR)/include -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra CFLAGS += -mfpxx -target mips -mabi=32 -mhard-float -fomit-frame-pointer -fno-stack-protector -fno-common -I include -I src/ -I $(BUILD_DIR)/include -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra -Wno-missing-braces
CFLAGS += -Wno-missing-braces
else else
CFLAGS += -non_shared -Wab,-r4300_mul -Xcpluscomm -Xfullwarn -signed -32 CFLAGS += -non_shared -Wab,-r4300_mul -Xcpluscomm -Xfullwarn -signed -32
endif endif
ASMFLAGS = -G 0 $(OPT_FLAGS) $(TARGET_CFLAGS) -mips3 $(DEF_INC_CFLAGS) -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra ASMFLAGS = -G 3 $(OPT_FLAGS) $(TARGET_CFLAGS) -mips3 $(DEF_INC_CFLAGS) -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra
ifeq ($(SDATA),1)
ASMFLAGS += -G 3
else
CFLAGS += -G 0
ifeq ($(COMPILER),gcc)
CFLAGS += -fno-zero-initialized-in-bss
endif
ASMFLAGS += -G 0
endif
ASFLAGS := -march=vr4300 -mabi=32 $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(foreach d,$(DEFINES),--defsym $(d)) ASFLAGS := -march=vr4300 -mabi=32 $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(foreach d,$(DEFINES),--defsym $(d))
RSPASMFLAGS := $(foreach d,$(DEFINES),-definelabel $(subst =, ,$(d))) RSPASMFLAGS := $(foreach d,$(DEFINES),-definelabel $(subst =, ,$(d)))
@@ -562,10 +585,19 @@ endif
EMU_FLAGS = EMU_FLAGS =
# Adding a txt file to this location will then reference a UNFLoader path specified in the file, instead of locally.
# This is expecially important for WSL users because UNFLoader.exe is incredibly slow when run within WSL's filesystem, so this can be used to point to the C drive.
# The file should only contain the directory path that contains UNFLoader[.exe] (do not specify the filename).
LOADER_DIR_FILE_SPECIFICATION_PATH = ~/.local/share/HackerSM64/UNFLoader-dir.txt
LOADER_DIR = ./$(TOOLS_DIR)
ifneq (,$(wildcard $(LOADER_DIR_FILE_SPECIFICATION_PATH)))
LOADER_DIR = $(shell cat $(LOADER_DIR_FILE_SPECIFICATION_PATH))
endif
ifneq (,$(call find-command,wslview)) ifneq (,$(call find-command,wslview))
LOADER = ./$(TOOLS_DIR)/UNFLoader.exe LOADER_EXEC = $(LOADER_DIR)/UNFLoader.exe
else else
LOADER = ./$(TOOLS_DIR)/UNFLoader LOADER_EXEC = $(LOADER_DIR)/UNFLoader
endif endif
SHA1SUM = sha1sum SHA1SUM = sha1sum
@@ -621,17 +653,17 @@ test-pj64: $(ROM)
# someone2639 # someone2639
# download and extract most recent unfloader build if needed # download and extract most recent unfloader build if needed
$(LOADER): $(LOADER_EXEC):
ifeq (,$(wildcard $(LOADER))) ifeq (,$(wildcard $(LOADER_EXEC)))
@$(PRINT) "Downloading latest UNFLoader...$(NO_COL)\n" @$(PRINT) "Downloading latest UNFLoader...$(NO_COL)\n"
$(PYTHON) $(TOOLS_DIR)/get_latest_unfloader.py $(TOOLS_DIR) $(PYTHON) $(TOOLS_DIR)/get_latest_unfloader.py $(LOADER_DIR)
endif endif
load: $(ROM) $(LOADER) load: $(ROM) $(LOADER_EXEC)
$(LOADER) -r $< $(LOADER_EXEC) -r $<
unf: $(ROM) $(LOADER) unf: $(ROM) $(LOADER_EXEC)
$(LOADER) -d -r $< $(LOADER_EXEC) -d -r $<
libultra: $(BUILD_DIR)/libultra.a libultra: $(BUILD_DIR)/libultra.a
@@ -685,8 +717,13 @@ $(BUILD_DIR)/src/usb/usb.o: CFLAGS += -Wno-unused-variable -Wno-sign-compare -Wn
$(BUILD_DIR)/src/usb/debug.o: OPT_FLAGS := -O0 $(BUILD_DIR)/src/usb/debug.o: OPT_FLAGS := -O0
$(BUILD_DIR)/src/usb/debug.o: CFLAGS += -Wno-unused-parameter -Wno-maybe-uninitialized $(BUILD_DIR)/src/usb/debug.o: CFLAGS += -Wno-unused-parameter -Wno-maybe-uninitialized
# File specific opt flags # File specific opt flags
$(BUILD_DIR)/src/audio/heap.o: OPT_FLAGS := -Os -fno-jump-tables ifeq ($(SDATA),1)
$(BUILD_DIR)/src/audio/synthesis.o: OPT_FLAGS := -Os -fno-jump-tables $(BUILD_DIR)/src/audio/heap.o: OPT_FLAGS := -Os -fno-jump-tables -ffunction-sections -fdata-sections
$(BUILD_DIR)/src/audio/synthesis.o: OPT_FLAGS := -Os -fno-jump-tables -ffunction-sections -fdata-sections
else
$(BUILD_DIR)/src/audio/heap.o: OPT_FLAGS := -Os -fno-jump-tables
$(BUILD_DIR)/src/audio/synthesis.o: OPT_FLAGS := -Os -fno-jump-tables
endif
$(BUILD_DIR)/src/engine/surface_collision.o: OPT_FLAGS := $(COLLISION_OPT_FLAGS) $(BUILD_DIR)/src/engine/surface_collision.o: OPT_FLAGS := $(COLLISION_OPT_FLAGS)
$(BUILD_DIR)/src/engine/math_util.o: OPT_FLAGS := $(MATH_UTIL_OPT_FLAGS) $(BUILD_DIR)/src/engine/math_util.o: OPT_FLAGS := $(MATH_UTIL_OPT_FLAGS)
@@ -780,7 +817,7 @@ endif
$(BUILD_DIR)/%.table: %.aiff $(BUILD_DIR)/%.table: %.aiff
$(call print,Extracting codebook:,$<,$@) $(call print,Extracting codebook:,$<,$@)
$(V)$(AIFF_EXTRACT_CODEBOOK) $< >$@ $(V)$(AIFF_EXTRACT_CODEBOOK) $< $@
$(BUILD_DIR)/%.aifc: $(BUILD_DIR)/%.table %.aiff $(BUILD_DIR)/%.aifc: $(BUILD_DIR)/%.table %.aiff
$(call print,Encoding ADPCM:,$(word 2,$^),$@) $(call print,Encoding ADPCM:,$(word 2,$^),$@)
@@ -868,9 +905,23 @@ ifeq ($(FIXLIGHTS),1)
DUMMY != $(PYTHON) $(FIXLIGHTS_PY) actors DUMMY != $(PYTHON) $(FIXLIGHTS_PY) actors
DUMMY != $(PYTHON) $(FIXLIGHTS_PY) levels DUMMY != $(PYTHON) $(FIXLIGHTS_PY) levels
endif endif
ifeq ($(SDATA),1)
$(BUILD_DIR)/src/boot/%.o: src/boot/%.c
$(call print,Compiling Boot:,$<,$@)
$(V)$(CC) -c -G 0 $(CFLAGS) -MMD -MF $(BUILD_DIR)/src/boot/$*.d -o $@ $<
$(BUILD_DIR)/src/%.o: src/%.c
$(call print,Compiling:,$<,$@)
$(V)$(CC) -c -G 64 $(CFLAGS) -MMD -MF $(BUILD_DIR)/src/$*.d -o $@ $<
$(BUILD_DIR)/%.o: %.c
$(call print,Compiling:,$<,$@)
$(V)$(CC) -c -G 0 -fno-zero-initialized-in-bss $(CFLAGS) -MMD -MF $(BUILD_DIR)/$*.d -o $@ $<
else
$(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/%.o: %.c
$(call print,Compiling:,$<,$@) $(call print,Compiling:,$<,$@)
$(V)$(CC) -c $(CFLAGS) -MMD -MF $(BUILD_DIR)/$*.d -o $@ $< $(V)$(CC) -c $(CFLAGS) -MMD -MF $(BUILD_DIR)/$*.d -o $@ $<
endif
$(BUILD_DIR)/%.o: %.cpp $(BUILD_DIR)/%.o: %.cpp
$(call print,Compiling (C++):,$<,$@) $(call print,Compiling (C++):,$<,$@)
$(V)$(CXX) -c $(CFLAGS) -std=c++17 -Wno-register -MMD -MF $(BUILD_DIR)/$*.d -o $@ $< $(V)$(CXX) -c $(CFLAGS) -std=c++17 -Wno-register -MMD -MF $(BUILD_DIR)/$*.d -o $@ $<

View File

@@ -1 +1 @@
v2.2.0 v2.3.0

18
asm/setgp.s Normal file
View File

@@ -0,0 +1,18 @@
#ifdef SDATA
// assembler directives
.set noat // allow manual use of $at
.set noreorder // don't insert nops after branches
.set gp=64
#include "macros.inc"
.section .text, "ax"
glabel setgp
lui $gp, %hi(_gp)
jr $ra
addiu $gp, %lo(_gp)
#endif

View File

@@ -177,9 +177,15 @@ def main():
# presence of the correct roms automatically # presence of the correct roms automatically
# Make sure tools exist # Make sure tools exist
subprocess.check_call( tools = [ "n64graphics", "skyconv", "mio0", "aifc_decode" ]
["make", "-s", "-C", "tools/", "n64graphics", "skyconv", "mio0", "aifc_decode"] if os.name == 'nt':
) tools = [tool + ".exe" for tool in tools]
make = "mingw32-make"
else:
make = "make"
cmd = [make, "-s", "-C", "tools/"] + tools
subprocess.check_call(cmd)
# Go through the assets in roughly alphabetical order (but assets in the same # Go through the assets in roughly alphabetical order (but assets in the same
# mio0 file still go together). # mio0 file still go together).

28
fast64.json Normal file
View File

@@ -0,0 +1,28 @@
{
"version": 1.0,
"autoLoad": true,
"microcode": "F3DEX2/LX2",
"rdpDefaults": {
"geometryMode": {
"zBuffer": true,
"shade": true,
"cullBack": true,
"lighting": true,
"shadeSmooth": true
},
"otherModeH": {
"textureConvert": "G_TC_FILT",
"textureFilter": "G_TF_BILERP",
"perspectiveCorrection": "G_TP_PERSP",
"pipelineMode": "G_PM_1PRIMITIVE"
},
"otherModeL": {},
"other": {}
},
"sm64": {
"refresh_version": "HackerSM64 2.3.0",
"compression_format": "yay0",
"force_extended_ram": false,
"matstack_fix": true
}
}

View File

@@ -103,6 +103,17 @@
#define ALIGNED64 #define ALIGNED64
#endif #endif
// Assign to a section type.
#if defined(SDATA) && defined(__GNUC__)
#define SECTION(x) __attribute__((section(x)))
#define SECTION_BSS SECTION(".bss")
#define SECTION_DATA SECTION(".data")
#else
#define SECTION(x)
#define SECTION_BSS
#define SECTION_DATA
#endif
#ifndef ALIGN #ifndef ALIGN
#define ALIGN(VAL_, ALIGNMENT_) (((VAL_) + ((ALIGNMENT_) - 1)) & ~((ALIGNMENT_) - 1)) #define ALIGN(VAL_, ALIGNMENT_) (((VAL_) + ((ALIGNMENT_) - 1)) & ~((ALIGNMENT_) - 1))
#endif #endif

View File

@@ -81,6 +81,20 @@ extern "C" {
* *
*/ */
#if defined(SDATA) && defined(__GNUC__)
extern __attribute__((section(".data"))) s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */
extern __attribute__((section(".data"))) void *osRomBase; /* Rom base address of the game image */
extern __attribute__((section(".data"))) s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */
extern __attribute__((section(".data"))) s32 osResetType; /* 0 = cold reset, 1 = NMI */
extern __attribute__((section(".data"))) s32 osCicId;
extern __attribute__((section(".data"))) s32 osVersion;
extern __attribute__((section(".data"))) u32 osMemSize; /* Memory Size */
extern s32 osAppNMIBuffer[];
extern __attribute__((section(".data"))) u64 osClockRate;
extern __attribute__((section(".data"))) OSIntMask __OSGlobalIntMask; /* global interrupt mask */
#else
extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */ extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */
extern void *osRomBase; /* Rom base address of the game image */ extern void *osRomBase; /* Rom base address of the game image */
extern s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */ extern s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */
@@ -93,6 +107,7 @@ extern s32 osAppNMIBuffer[];
extern u64 osClockRate; extern u64 osClockRate;
extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */ extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */
#endif
/************************************************************************** /**************************************************************************

View File

@@ -53,10 +53,13 @@ DECLARE_SEGMENT(assets)
extern u8 _goddardSegmentStart[]; extern u8 _goddardSegmentStart[];
extern u8 _goddardSegmentEnd[]; extern u8 _goddardSegmentEnd[];
extern u8 _engineSegmentStart[]; extern u8 _engineSegmentStart[];
extern u8 _engineSegmentEnd[];
extern u8 _engineSegmentBssStart[];
extern u8 _engineSegmentBssEnd[]; extern u8 _engineSegmentBssEnd[];
extern u8 _mainSegmentStart[]; extern u8 _mainSegmentStart[];
extern u8 _mainSegmentEnd[]; extern u8 _mainSegmentEnd[];
extern u8 _engineSegmentEnd[]; extern u8 _mainSegmentBssStart[];
extern u8 _mainSegmentBssEnd[];
extern u8 _framebuffersSegmentBssStart[]; extern u8 _framebuffersSegmentBssStart[];
extern u8 _framebuffersSegmentBssEnd[]; extern u8 _framebuffersSegmentBssEnd[];
extern u8 _zbufferSegmentBssStart[]; extern u8 _zbufferSegmentBssStart[];
@@ -64,6 +67,16 @@ extern u8 _zbufferSegmentBssEnd[];
extern u8 _buffersSegmentBssStart[]; extern u8 _buffersSegmentBssStart[];
extern u8 _buffersSegmentBssEnd[]; extern u8 _buffersSegmentBssEnd[];
#ifdef SDATA
extern u8 _sbssSegmentBssStart[];
extern u8 _sbssSegmentBssEnd[];
extern u8 _sdataSegmentStart[];
extern u8 _sdataSegmentEnd[];
extern u8 _sdataSegmentRomStart[];
extern u8 _sdataSegmentRomEnd[];
extern u8 _gp[];
#endif
DECLARE_LEVEL_SEGMENT(menu) DECLARE_LEVEL_SEGMENT(menu)
DECLARE_LEVEL_SEGMENT(intro) DECLARE_LEVEL_SEGMENT(intro)
DECLARE_LEVEL_SEGMENT(ending) DECLARE_LEVEL_SEGMENT(ending)

View File

@@ -36,15 +36,27 @@ enum SoundBank {
SOUND_BANK_MENU, SOUND_BANK_MENU,
SOUND_BANK_GENERAL2, SOUND_BANK_GENERAL2,
SOUND_BANK_OBJ2, SOUND_BANK_OBJ2,
SOUND_BANK_CUSTOM_FOREGROUND_1,
SOUND_BANK_CUSTOM_FOREGROUND_2,
SOUND_BANK_CUSTOM_FOREGROUND_3,
SOUND_BANK_CUSTOM_BACKGROUND_1,
SOUND_BANK_CUSTOM_BACKGROUND_2,
SOUND_BANK_CUSTOM_BACKGROUND_3,
SOUND_BANK_COUNT SOUND_BANK_COUNT
}; };
#define SOUND_BANKS_ALL_BITS 0xffff #define SOUND_BANKS_ALL_BITS 0xffff
#define SOUND_BANKS_ALL ((1 << SOUND_BANK_COUNT) - 1) #define SOUND_BANKS_ALL ((1 << SOUND_BANK_COUNT) - 1)
#define SOUND_BANKS_FOREGROUND (\ #define SOUND_BANKS_FOREGROUND (\
(1 << SOUND_BANK_ACTION) |\ (1 << SOUND_BANK_ACTION) |\
(1 << SOUND_BANK_VOICE) |\ (1 << SOUND_BANK_VOICE) |\
(1 << SOUND_BANK_MENU)) (1 << SOUND_BANK_MENU) |\
(1 << SOUND_BANK_CUSTOM_FOREGROUND_1) |\
(1 << SOUND_BANK_CUSTOM_FOREGROUND_2) |\
(1 << SOUND_BANK_CUSTOM_FOREGROUND_3))
#define SOUND_BANKS_BACKGROUND (SOUND_BANKS_ALL & ~SOUND_BANKS_FOREGROUND) #define SOUND_BANKS_BACKGROUND (SOUND_BANKS_ALL & ~SOUND_BANKS_FOREGROUND)
#define SOUND_BANKS_DISABLED_DURING_INTRO_CUTSCENE (\ #define SOUND_BANKS_DISABLED_DURING_INTRO_CUTSCENE (\
(1 << SOUND_BANK_ENV) |\ (1 << SOUND_BANK_ENV) |\
@@ -589,4 +601,6 @@ enum SoundBank {
#define SOUND_OBJ2_BOSS_DIALOG_GRUNT /* 0x90694081 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ2, 0x69, 0x40, SOUND_DISCRETE) #define SOUND_OBJ2_BOSS_DIALOG_GRUNT /* 0x90694081 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ2, 0x69, 0x40, SOUND_DISCRETE)
#define SOUND_OBJ2_MRI_SPINNING /* 0x906B0081 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ2, 0x6B, 0x00, SOUND_DISCRETE) #define SOUND_OBJ2_MRI_SPINNING /* 0x906B0081 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ2, 0x6B, 0x00, SOUND_DISCRETE)
// Add defines for sounds using extra custom banks here!
#endif // SOUNDS_H #endif // SOUNDS_H

78
sm64.ld
View File

@@ -53,10 +53,10 @@ OUTPUT_ARCH (mips)
END_SEG(name##_segment_7) \ END_SEG(name##_segment_7) \
BEGIN_SEG(name, 0x0E000000) \ BEGIN_SEG(name, 0x0E000000) \
{ \ { \
KEEP(BUILD_DIR/levels/name/script.o(.*data*)); \ KEEP(BUILD_DIR/levels/name/script.o(.data*)); \
KEEP(BUILD_DIR/levels/name/script.o(.text*)); \ KEEP(BUILD_DIR/levels/name/script.o(.text*)); \
KEEP(BUILD_DIR/levels/name/script.o(.rodata*)); \ KEEP(BUILD_DIR/levels/name/script.o(.rodata*)); \
KEEP(BUILD_DIR/levels/name/geo.o(.*data*)); \ KEEP(BUILD_DIR/levels/name/geo.o(.data*)); \
KEEP(BUILD_DIR/levels/name/geo.o(.text*)); \ KEEP(BUILD_DIR/levels/name/geo.o(.text*)); \
KEEP(BUILD_DIR/levels/name/geo.o(.rodata*)); \ KEEP(BUILD_DIR/levels/name/geo.o(.rodata*)); \
} \ } \
@@ -77,7 +77,7 @@ OUTPUT_ARCH (mips)
END_SEG(name##_yay0) \ END_SEG(name##_yay0) \
BEGIN_SEG(name##_geo, geoAddr) \ BEGIN_SEG(name##_geo, geoAddr) \
{ \ { \
KEEP(BUILD_DIR/actors/name##_geo.o(.*data*)); \ KEEP(BUILD_DIR/actors/name##_geo.o(.data*)); \
KEEP(BUILD_DIR/actors/name##_geo.o(.rodata*)); \ KEEP(BUILD_DIR/actors/name##_geo.o(.rodata*)); \
KEEP(BUILD_DIR/actors/name##_geo.o(.text*)); \ KEEP(BUILD_DIR/actors/name##_geo.o(.text*)); \
} \ } \
@@ -157,6 +157,7 @@ SECTIONS
{ {
KEEP(BUILD_DIR/asm/entry.o(.text*)); KEEP(BUILD_DIR/asm/entry.o(.text*));
KEEP(BUILD_DIR/asm/n64_assert.o(.text*)); KEEP(BUILD_DIR/asm/n64_assert.o(.text*));
KEEP(BUILD_DIR/asm/setgp.o(.text*));
#ifdef EEP #ifdef EEP
KEEP(BUILD_DIR/asm/vc_bin.o(.text*)); KEEP(BUILD_DIR/asm/vc_bin.o(.text*));
#endif #endif
@@ -175,9 +176,9 @@ SECTIONS
#ifdef LIBPL #ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.text*); BUILD_DIR/lib/libpl*.o(.text*);
#endif #endif
*/ULTRALIB.a:*.o(.text*); *ULTRALIB.a:*.o(.text*);
*/libnustd.a:*.o(.text*); */libnustd.a:*.o(.text*);
*/libgcc.a:*.o(.text*); *libgcc.a:*.o(.text*);
*/libz.a:*.o(.text*); */libz.a:*.o(.text*);
*/libhvqm2.a:*.o(.text*); */libhvqm2.a:*.o(.text*);
lib/rspboot.o(.text*); lib/rspboot.o(.text*);
@@ -188,16 +189,16 @@ SECTIONS
_mainSegmentTextEnd = .; _mainSegmentTextEnd = .;
/* data */ /* data */
BUILD_DIR/asm/n64_assert.o(.*data*); BUILD_DIR/asm/n64_assert.o(.data*);
BUILD_DIR/src/boot*.o(.*data*); BUILD_DIR/src/boot*.o(.data*);
BUILD_DIR/src/audio*.o(.*data*); BUILD_DIR/src/audio*.o(.data*);
#ifdef S2DEX_TEXT_ENGINE #ifdef S2DEX_TEXT_ENGINE
BUILD_DIR/src/s2d_engine*.o(.*data*); BUILD_DIR/src/s2d_engine*.o(.data*);
#endif #endif
#ifdef LIBPL #ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.*data*); BUILD_DIR/lib/libpl*.o(.data*);
#endif #endif
*/ULTRALIB.a:*.o(.data*); *ULTRALIB.a:*.o(.data*);
*/libhvqm2.a:*.o(.data*); */libhvqm2.a:*.o(.data*);
*/libz.a:*.o(.data*); */libz.a:*.o(.data*);
#include "rspdata.inc.ld" #include "rspdata.inc.ld"
@@ -215,8 +216,8 @@ SECTIONS
#ifdef LIBPL #ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.rodata*); BUILD_DIR/lib/libpl*.o(.rodata*);
#endif #endif
*/ULTRALIB.a:*.o(.rodata*); *ULTRALIB.a:*.o(.rodata*);
*/libgcc.a:*.o(.rodata*); *libgcc.a:*.o(.rodata*);
*/libz.a:*.o(.rodata*); */libz.a:*.o(.rodata*);
lib/PR/hvqm/hvqm2sp1.o(.rodata*); lib/PR/hvqm/hvqm2sp1.o(.rodata*);
@@ -224,19 +225,19 @@ SECTIONS
END_SEG(main) END_SEG(main)
BEGIN_NOLOAD(main) BEGIN_NOLOAD(main)
{ {
BUILD_DIR/src/boot*.o(.*bss*); BUILD_DIR/src/boot*.o(.bss*);
BUILD_DIR/src/hvqm*.o(.*bss*); BUILD_DIR/src/hvqm*.o(.bss*);
BUILD_DIR/src/usb*.o(.*bss*); BUILD_DIR/src/usb*.o(.bss*);
BUILD_DIR/src/audio*.o(.*bss*); BUILD_DIR/src/audio*.o(.bss*);
#ifdef S2DEX_TEXT_ENGINE #ifdef S2DEX_TEXT_ENGINE
BUILD_DIR/src/s2d_engine*.o(.*bss*); BUILD_DIR/src/s2d_engine*.o(.bss*);
#endif #endif
#ifdef LIBPL #ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.*bss*); BUILD_DIR/lib/libpl*.o(.bss*);
#endif #endif
*/ULTRALIB.a:*.o(COMMON); *ULTRALIB.a:*.o(COMMON);
*/ULTRALIB.a:*.o(.scommon); *ULTRALIB.a:*.o(.scommon);
*/ULTRALIB.a:*.o(.*bss*); *ULTRALIB.a:*.o(.bss*);
*/libhvqm2.a:*.o(.bss*); */libhvqm2.a:*.o(.bss*);
*/libz.a:*.o(.bss*); */libz.a:*.o(.bss*);
. = ALIGN(0x8); . = ALIGN(0x8);
@@ -263,10 +264,6 @@ SECTIONS
BUILD_DIR/src/game*.o(.data*); BUILD_DIR/src/game*.o(.data*);
BUILD_DIR/src/engine*.o(.data*); BUILD_DIR/src/engine*.o(.data*);
BUILD_DIR/src/usb*.o(.data*); BUILD_DIR/src/usb*.o(.data*);
/* sdata */
BUILD_DIR/src/game*.o(.sdata*);
BUILD_DIR/src/engine*.o(.sdata*);
BUILD_DIR/src/usb*.o(.data*);
/* rodata */ /* rodata */
BUILD_DIR/src/game*.o(.rodata*); BUILD_DIR/src/game*.o(.rodata*);
BUILD_DIR/src/engine*.o(.rodata*); BUILD_DIR/src/engine*.o(.rodata*);
@@ -276,13 +273,36 @@ SECTIONS
END_SEG(engine) END_SEG(engine)
BEGIN_NOLOAD(engine) BEGIN_NOLOAD(engine)
{ {
BUILD_DIR/src/game*.o(.*bss*); BUILD_DIR/src/game*.o(.bss*);
BUILD_DIR/src/engine*.o(.bss*); BUILD_DIR/src/engine*.o(.bss*);
. = ALIGN(0x40); . = ALIGN(0x40);
} }
END_NOLOAD(engine) END_NOLOAD(engine)
. = _engineSegmentBssEnd; #ifdef SDATA
_gp = . + 0x8000;
BEGIN_SEG(sdata, .)
{
BUILD_DIR/src/game*.o(.sdata*);
BUILD_DIR/src/audio*.o(.sdata*);
BUILD_DIR/src/engine*.o(.sdata*);
BUILD_DIR/src/usb*.o(.sdata*);
BUILD_DIR/src/menu*.o(.sdata*);
. = ALIGN(0x10);
}
END_SEG(sdata)
BEGIN_NOLOAD(sbss)
{
BUILD_DIR/src/game*.o(.sbss*);
BUILD_DIR/src/audio*.o(.sbss*);
BUILD_DIR/src/engine*.o(.sbss*);
BUILD_DIR/src/usb*.o(.sbss*);
BUILD_DIR/src/menu*.o(.sbss*);
. = ALIGN(0x40);
}
END_NOLOAD(sbss)
#endif
BEGIN_NOLOAD(framebuffers) BEGIN_NOLOAD(framebuffers)
{ {
BUILD_DIR/src/buffers/framebuffers.o(.bss*); BUILD_DIR/src/buffers/framebuffers.o(.bss*);
@@ -409,7 +429,7 @@ SECTIONS
/* 0x268020 0x268020-0 [0] */ /* 0x268020 0x268020-0 [0] */
BEGIN_SEG(intro, 0x14000000) BEGIN_SEG(intro, 0x14000000)
{ {
KEEP(BUILD_DIR/levels/intro/script.o(.*data)); KEEP(BUILD_DIR/levels/intro/script.o(.data*));
KEEP(BUILD_DIR/levels/intro/script.o(.rodata*)); KEEP(BUILD_DIR/levels/intro/script.o(.rodata*));
KEEP(BUILD_DIR/levels/intro/script.o(.text*)); KEEP(BUILD_DIR/levels/intro/script.o(.text*));
KEEP(BUILD_DIR/levels/intro/geo.o(.data*)); KEEP(BUILD_DIR/levels/intro/geo.o(.data*));

View File

@@ -12,7 +12,7 @@ seq_setmutescale 0
seq_setvol 127 seq_setvol 127
#endif #endif
seq_settempo 120 seq_settempo 120
seq_initchannels 0x3ff seq_initchannels 0xffff
seq_startchannel 0, .channel0 seq_startchannel 0, .channel0
seq_startchannel 1, .channel1 seq_startchannel 1, .channel1
seq_startchannel 2, .channel2 seq_startchannel 2, .channel2
@@ -23,6 +23,12 @@ seq_startchannel 6, .channel6
seq_startchannel 7, .channel7 seq_startchannel 7, .channel7
seq_startchannel 8, .channel38 seq_startchannel 8, .channel38
seq_startchannel 9, .channel59 seq_startchannel 9, .channel59
seq_startchannel 10, .channelA
seq_startchannel 11, .channelB
seq_startchannel 12, .channelC
seq_startchannel 13, .channelD
seq_startchannel 14, .channelE
seq_startchannel 15, .channelF
.seq_loop: .seq_loop:
seq_delay 20000 seq_delay 20000
seq_jump .seq_loop seq_jump .seq_loop
@@ -71,6 +77,72 @@ chan_stereoheadseteffects 1
chan_setdyntable .channel59_table chan_setdyntable .channel59_table
chan_jump .main_loop_023589 chan_jump .main_loop_023589
.channelA:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelA_table
chan_jump .main_loop_023589
.channelB:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelB_table
chan_jump .main_loop_023589
.channelC:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelC_table
chan_jump .main_loop_023589
.channelD:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelD_table
chan_jump .main_loop_023589
.channelE:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelE_table
chan_jump .main_loop_023589
.channelF:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelF_table
chan_jump .main_loop_023589
// Main loop for standard, non-continuous sound effects // Main loop for standard, non-continuous sound effects
.main_loop_023589: .main_loop_023589:
chan_hang chan_hang
@@ -7903,6 +7975,31 @@ layer_note0 38, 0x3, 127, 127
layer_delay 0x2a layer_delay 0x2a
layer_jump .layer_32B7 layer_jump .layer_32B7
.channelA_table:
// Add custom sounds for Channel A here!
.channelB_table:
// Add custom sounds for Channel B here!
.channelC_table:
// Add custom sounds for Channel C here!
.channelD_table:
// Add custom sounds for Channel D here!
.channelE_table:
// Add custom sounds for Channel E here!
.channelF_table:
// Add custom sounds for Channel F here!
.align 2, 0 .align 2, 0
.envelope_32C4: .envelope_32C4:
envelope_line 7 20000 envelope_line 7 20000

View File

@@ -313,10 +313,10 @@ STATIC_ASSERT(ARRAY_COUNT(sBackgroundMusicDefaultVolume) == SEQ_COUNT,
u8 sCurrentBackgroundMusicSeqId = SEQUENCE_NONE; u8 sCurrentBackgroundMusicSeqId = SEQUENCE_NONE;
u8 sMusicDynamicDelay = 0; u8 sMusicDynamicDelay = 0;
u8 sSoundBankUsedListBack[SOUND_BANK_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; u8 sSoundBankUsedListBack[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 0};
u8 sSoundBankFreeListFront[SOUND_BANK_COUNT] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; u8 sSoundBankFreeListFront[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 1};
u8 sNumSoundsInBank[SOUND_BANK_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // only used for debugging u8 sNumSoundsInBank[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 0}; // only used for debugging
u8 sMaxChannelsForSoundBank[SOUND_BANK_COUNT] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; u8 sMaxChannelsForSoundBank[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 1};
// sBackgroundMusicMaxTargetVolume and sBackgroundMusicTargetVolume use the 0x80 // sBackgroundMusicMaxTargetVolume and sBackgroundMusicTargetVolume use the 0x80
// bit to indicate that they are set, and the rest of the bits for the actual value // bit to indicate that they are set, and the rest of the bits for the actual value
@@ -347,8 +347,7 @@ struct UnkStruct80343D00 D_SH_80343D00;
#endif #endif
struct Sound sSoundRequests[0x100]; struct Sound sSoundRequests[0x100];
// Curiously, this has size 3, despite SEQUENCE_PLAYERS == 4 on EU struct ChannelVolumeScaleFade D_80360928[SEQUENCE_PLAYERS][CHANNELS_MAX];
struct ChannelVolumeScaleFade D_80360928[3][CHANNELS_MAX];
u8 sUsedChannelsForSoundBank[SOUND_BANK_COUNT]; u8 sUsedChannelsForSoundBank[SOUND_BANK_COUNT];
u8 sCurrentSound[SOUND_BANK_COUNT][MAX_CHANNELS_PER_SOUND_BANK]; // index into sSoundBanks u8 sCurrentSound[SOUND_BANK_COUNT][MAX_CHANNELS_PER_SOUND_BANK]; // index into sSoundBanks
@@ -1341,12 +1340,7 @@ static void update_game_sound(void) {
get_sound_reverb(bank, soundIndex, channelIndex); get_sound_reverb(bank, soundIndex, channelIndex);
#endif #endif
break; break;
case SOUND_BANK_GENERAL: default:
case SOUND_BANK_ENV:
case SOUND_BANK_OBJ:
case SOUND_BANK_AIR:
case SOUND_BANK_GENERAL2:
case SOUND_BANK_OBJ2:
#if defined(VERSION_EU) || defined(VERSION_SH) #if defined(VERSION_EU) || defined(VERSION_SH)
func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8), func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8),
get_sound_reverb(bank, soundIndex, channelIndex)); get_sound_reverb(bank, soundIndex, channelIndex));
@@ -1507,12 +1501,7 @@ static void update_game_sound(void) {
get_sound_reverb(bank, soundIndex, channelIndex); get_sound_reverb(bank, soundIndex, channelIndex);
#endif #endif
break; break;
case SOUND_BANK_GENERAL: default:
case SOUND_BANK_ENV:
case SOUND_BANK_OBJ:
case SOUND_BANK_AIR:
case SOUND_BANK_GENERAL2:
case SOUND_BANK_OBJ2:
#if defined(VERSION_EU) || defined(VERSION_SH) #if defined(VERSION_EU) || defined(VERSION_SH)
func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8), func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8),
get_sound_reverb(bank, soundIndex, channelIndex)); get_sound_reverb(bank, soundIndex, channelIndex));
@@ -1952,7 +1941,7 @@ void sound_init(void) {
for (i = 0; i < SOUND_BANK_COUNT; i++) { for (i = 0; i < SOUND_BANK_COUNT; i++) {
// Set each sound in the bank to STOPPED // Set each sound in the bank to STOPPED
for (j = 0; j < 40; j++) { for (j = 0; j < ARRAY_COUNT(sSoundBanks[0]); j++) {
sSoundBanks[i][j].soundStatus = SOUND_STATUS_STOPPED; sSoundBanks[i][j].soundStatus = SOUND_STATUS_STOPPED;
} }
@@ -1972,7 +1961,7 @@ void sound_init(void) {
sSoundBanks[i][0].next = 0xff; sSoundBanks[i][0].next = 0xff;
// Set free list to contain every sound slot // Set free list to contain every sound slot
for (j = 1; j < 40 - 1; j++) { for (j = 1; j < ARRAY_COUNT(sSoundBanks[0]) - 1; j++) {
sSoundBanks[i][j].prev = j - 1; sSoundBanks[i][j].prev = j - 1;
sSoundBanks[i][j].next = j + 1; sSoundBanks[i][j].next = j + 1;
} }
@@ -1980,7 +1969,7 @@ void sound_init(void) {
sSoundBanks[i][j].next = 0xff; sSoundBanks[i][j].next = 0xff;
} }
for (j = 0; j < 3; j++) { for (j = 0; j < SEQUENCE_PLAYERS; j++) {
for (i = 0; i < CHANNELS_MAX; i++) { for (i = 0; i < CHANNELS_MAX; i++) {
D_80360928[j][i].remainingFrames = 0; D_80360928[j][i].remainingFrames = 0;
} }

View File

@@ -342,11 +342,18 @@ void check_stack_validity(void) {
} }
#endif #endif
#ifdef SDATA
extern void load_sdata(void);
#else
#define load_sdata()
#endif
extern void crash_screen_init(void); extern void crash_screen_init(void);
extern OSViMode VI; extern OSViMode VI;
void thread3_main(UNUSED void *arg) { void thread3_main(UNUSED void *arg) {
setgp();
setup_mesg_queues(); setup_mesg_queues();
load_sdata();
alloc_pool(); alloc_pool();
load_engine_code_segment(); load_engine_code_segment();
detect_emulator(); detect_emulator();
@@ -504,6 +511,8 @@ void change_vi(OSViMode *mode, int width, int height) {
} }
void get_audio_frequency(void) { void get_audio_frequency(void) {
gConfig.audioFrequency = 1.0f;
switch (gConfig.tvType) { switch (gConfig.tvType) {
#if defined(VERSION_JP) || defined(VERSION_US) #if defined(VERSION_JP) || defined(VERSION_US)
case MODE_NTSC: gConfig.audioFrequency = 1.0f; break; case MODE_NTSC: gConfig.audioFrequency = 1.0f; break;
@@ -521,6 +530,7 @@ void get_audio_frequency(void) {
* Initialize hardware, start main thread, then idle. * Initialize hardware, start main thread, then idle.
*/ */
void thread1_idle(UNUSED void *arg) { void thread1_idle(UNUSED void *arg) {
setgp();
osCreateViManager(OS_PRIORITY_VIMGR); osCreateViManager(OS_PRIORITY_VIMGR);
switch (osTvType) { switch (osTvType) {
case OS_TV_NTSC: case OS_TV_NTSC:
@@ -579,6 +589,7 @@ void osInitialize_fakeisv() {
#endif #endif
void main_func(void) { void main_func(void) {
setgp();
ClearRAM(); ClearRAM();
__osInitialize_common(); __osInitialize_common();
#ifdef ISVPRINT #ifdef ISVPRINT

View File

@@ -421,6 +421,23 @@ void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
return dest; return dest;
} }
#ifdef SDATA
extern u8 _gp[];
extern u8 _sdataSegmentStart[];
extern u8 _sdataSegmentEnd[];
extern u8 _sdataSegmentRomStart[];
extern u8 _sdataSegmentRomEnd[];
void load_sdata(void) {
void *startAddr = (void *) _sdataSegmentStart;
u32 totalSize = _sdataSegmentEnd - _sdataSegmentStart;
bzero(startAddr, totalSize);
osWritebackDCacheAll();
dma_read(startAddr, _sdataSegmentRomStart, _sdataSegmentRomEnd);
osInvalDCache(startAddr, totalSize);
}
#endif
void load_engine_code_segment(void) { void load_engine_code_segment(void) {
void *startAddr = (void *) _engineSegmentStart; void *startAddr = (void *) _engineSegmentStart;
u32 totalSize = _engineSegmentEnd - _engineSegmentStart; u32 totalSize = _engineSegmentEnd - _engineSegmentStart;

View File

@@ -334,8 +334,8 @@ static void level_cmd_init_level(void) {
sCurrentCmd = CMD_NEXT; sCurrentCmd = CMD_NEXT;
} }
extern s32 gTlbEntries; extern SECTION_DATA s32 gTlbEntries;
extern u8 gTlbSegments[NUM_TLB_SEGMENTS]; extern SECTION_DATA u8 gTlbSegments[NUM_TLB_SEGMENTS];
// This clears all the temporary bank TLB maps. group0, common1 and behavourdata are always loaded, // This clears all the temporary bank TLB maps. group0, common1 and behavourdata are always loaded,
// and they're also loaded first, so that means we just leave the first 3 indexes mapped. // and they're also loaded first, so that means we just leave the first 3 indexes mapped.

View File

@@ -87,30 +87,6 @@ static struct Surface *alloc_surface(u32 dynamic) {
return surface; return surface;
} }
/**
* Iterates through the entire partition, clearing the surfaces.
*/
static void clear_spatial_partition(SpatialPartitionCell *cells) {
register s32 i = sqr(NUM_CELLS);
while (i--) {
(*cells)[SPATIAL_PARTITION_FLOORS] = NULL;
(*cells)[SPATIAL_PARTITION_CEILS] = NULL;
(*cells)[SPATIAL_PARTITION_WALLS] = NULL;
(*cells)[SPATIAL_PARTITION_WATER] = NULL;
cells++;
}
}
/**
* Clears the static (level) surface partitions for new use.
*/
static void clear_static_surfaces(void) {
gTotalStaticSurfaceData = 0;
clear_spatial_partition(&gStaticSurfacePartition[0][0]);
}
/** /**
* Add a surface to the correct cell list of surfaces. * Add a surface to the correct cell list of surfaces.
* @param dynamic Determines whether the surface is static or dynamic * @param dynamic Determines whether the surface is static or dynamic
@@ -164,6 +140,14 @@ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surfac
struct SurfaceNode *curNode = *list; struct SurfaceNode *curNode = *list;
// Check if surface should be placed at the beginning of the list.
priority = curNode->surface->upperY * sortDir;
if (surfacePriority > priority) {
*list = newNode;
newNode->next = curNode;
return;
}
// Loop until we find the appropriate place for the surface in the list. // Loop until we find the appropriate place for the surface in the list.
while (curNode->next != NULL) { while (curNode->next != NULL) {
priority = curNode->next->surface->upperY * sortDir; priority = curNode->next->surface->upperY * sortDir;
@@ -504,7 +488,9 @@ void load_area_terrain(s32 index, TerrainData *data, RoomData *surfaceRooms, s16
sNumCellsUsed = 0; sNumCellsUsed = 0;
sClearAllCells = TRUE; sClearAllCells = TRUE;
clear_static_surfaces(); // Clear the static (level) surface partitions for new use.
bzero(gStaticSurfacePartition, sizeof(gStaticSurfacePartition));
gTotalStaticSurfaceData = 0;
// Initialise a new surface pool for this block of static surface data // Initialise a new surface pool for this block of static surface data
gCurrStaticSurfacePool = main_pool_alloc(main_pool_available() - 0x10, MEMORY_POOL_LEFT); gCurrStaticSurfacePool = main_pool_alloc(main_pool_available() - 0x10, MEMORY_POOL_LEFT);
@@ -567,7 +553,7 @@ void clear_dynamic_surfaces(void) {
gSurfaceNodesAllocated = gNumStaticSurfaceNodes; gSurfaceNodesAllocated = gNumStaticSurfaceNodes;
gDynamicSurfacePoolEnd = gDynamicSurfacePool; gDynamicSurfacePoolEnd = gDynamicSurfacePool;
if (sClearAllCells) { if (sClearAllCells) {
clear_spatial_partition(&gDynamicSurfacePartition[0][0]); bzero(gDynamicSurfacePartition, sizeof(gDynamicSurfacePartition));
} else { } else {
for (u32 i = 0; i < sNumCellsUsed; i++) { for (u32 i = 0; i < sNumCellsUsed; i++) {
gDynamicSurfacePartition[sCellsUsed[i].z][sCellsUsed[i].x][sCellsUsed[i].partition] = NULL; gDynamicSurfacePartition[sCellsUsed[i].z][sCellsUsed[i].x][sCellsUsed[i].partition] = NULL;

View File

@@ -237,6 +237,10 @@ void load_area(s32 index) {
gMarioCurrentRoom = 0; gMarioCurrentRoom = 0;
if (gCurrentArea->surfaceRooms != NULL) {
bzero(gDoorAdjacentRooms, sizeof(gDoorAdjacentRooms));
}
if (gCurrentArea->terrainData != NULL) { if (gCurrentArea->terrainData != NULL) {
load_area_terrain(index, gCurrentArea->terrainData, gCurrentArea->surfaceRooms, load_area_terrain(index, gCurrentArea->terrainData, gCurrentArea->surfaceRooms,
gCurrentArea->macroObjects); gCurrentArea->macroObjects);

View File

@@ -402,6 +402,7 @@ extern struct SequenceQueueItem sBackgroundMusicQueue[6];
void thread2_crash_screen(UNUSED void *arg) { void thread2_crash_screen(UNUSED void *arg) {
OSMesg mesg; OSMesg mesg;
OSThread *thread = NULL; OSThread *thread = NULL;
setgp();
osSetEventMesg(OS_EVENT_CPU_BREAK, &gCrashScreen.mesgQueue, (OSMesg) 1); osSetEventMesg(OS_EVENT_CPU_BREAK, &gCrashScreen.mesgQueue, (OSMesg) 1);
osSetEventMesg(OS_EVENT_FAULT, &gCrashScreen.mesgQueue, (OSMesg) 2); osSetEventMesg(OS_EVENT_FAULT, &gCrashScreen.mesgQueue, (OSMesg) 2);

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