You've already forked HackerSM64
mirror of
https://github.com/HackerN64/HackerSM64.git
synced 2026-01-21 10:35:32 -08:00
Compare commits
1 Commits
someone263
...
develop/2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5382e57a44 |
2126
.gitignore
vendored
2126
.gitignore
vendored
File diff suppressed because it is too large
Load Diff
2
.vscode/c_cpp_properties.json
vendored
2
.vscode/c_cpp_properties.json
vendored
@@ -33,7 +33,7 @@
|
||||
"compilerPath": "/usr/bin/mips-linux-gnu-gcc",
|
||||
"cStandard": "gnu17",
|
||||
"cppStandard": "gnu++14",
|
||||
"intelliSenseMode": "linux-gcc-x86"
|
||||
"intelliSenseMode": "linux-gcc-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# These owners will be the default owners for everything in the repo.
|
||||
* @Reonu
|
||||
* @thecozies
|
||||
* @gheskett
|
||||
* @Mr-Wiseguy
|
||||
|
||||
# Order is important. The last matching pattern has the most precedence.
|
||||
# So if a pull request only touches javascript files, only these owners
|
||||
|
||||
23
Makefile
23
Makefile
@@ -135,14 +135,10 @@ LINK_LIBRARIES = $(foreach i,$(LIBRARIES),-l$(i))
|
||||
|
||||
# Default non-gcc opt flags
|
||||
DEFAULT_OPT_FLAGS = -Ofast
|
||||
# Note: -fno-associative-math is used here to suppress warnings, ideally we would enable this as an optimization but
|
||||
# this conflicts with -ftrapping-math apparently.
|
||||
# TODO: Figure out how to allow -fassociative-math to be enabled
|
||||
SAFETY_OPT_FLAGS = -ftrapping-math -fno-associative-math
|
||||
|
||||
# Main opt flags
|
||||
GCC_MAIN_OPT_FLAGS = \
|
||||
$(DEFAULT_OPT_FLAGS) $(SAFETY_OPT_FLAGS) \
|
||||
-Ofast \
|
||||
--param case-values-threshold=20 \
|
||||
--param max-completely-peeled-insns=10 \
|
||||
--param max-unrolled-insns=10 \
|
||||
@@ -153,7 +149,7 @@ GCC_MAIN_OPT_FLAGS = \
|
||||
|
||||
# Surface Collision
|
||||
GCC_COLLISION_OPT_FLAGS = \
|
||||
$(DEFAULT_OPT_FLAGS) $(SAFETY_OPT_FLAGS) \
|
||||
-Ofast \
|
||||
--param case-values-threshold=20 \
|
||||
--param max-completely-peeled-insns=100 \
|
||||
--param max-unrolled-insns=100 \
|
||||
@@ -166,7 +162,7 @@ GCC_COLLISION_OPT_FLAGS = \
|
||||
|
||||
# Math Util
|
||||
GCC_MATH_UTIL_OPT_FLAGS = \
|
||||
$(DEFAULT_OPT_FLAGS) $(SAFETY_OPT_FLAGS) \
|
||||
-Ofast \
|
||||
-fno-unroll-loops \
|
||||
-fno-peel-loops \
|
||||
--param case-values-threshold=20 \
|
||||
@@ -178,7 +174,7 @@ GCC_MATH_UTIL_OPT_FLAGS = \
|
||||
|
||||
# Rendering graph node
|
||||
GCC_GRAPH_NODE_OPT_FLAGS = \
|
||||
$(DEFAULT_OPT_FLAGS) $(SAFETY_OPT_FLAGS) \
|
||||
-Ofast \
|
||||
--param case-values-threshold=20 \
|
||||
--param max-completely-peeled-insns=100 \
|
||||
--param max-unrolled-insns=100 \
|
||||
@@ -634,8 +630,7 @@ $(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: CFLAGS += -Wno-unused-parameter -Wno-maybe-uninitialized
|
||||
# File specific opt flags
|
||||
$(BUILD_DIR)/src/audio/heap.o: OPT_FLAGS := -Os -fno-jump-tables
|
||||
$(BUILD_DIR)/src/audio/synthesis.o: OPT_FLAGS := -Os -fno-jump-tables
|
||||
$(BUILD_DIR)/src/audio/*.o: OPT_FLAGS := -Os -fno-jump-tables
|
||||
|
||||
$(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)
|
||||
@@ -874,16 +869,8 @@ $(ELF): $(BUILD_DIR)/sm64_prelim.elf $(BUILD_DIR)/asm/debug/map.o $(O_FILES) $(Y
|
||||
$(V)$(LD) --gc-sections -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -T goddard.txt -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -L$(LIBS_DIR) -l$(ULTRALIB) -Llib $(LINK_LIBRARIES) -u sprintf -u osMapTLB -Llib/gcclib/$(LIBGCCDIR) -lgcc -lrtc
|
||||
|
||||
# Build ROM
|
||||
ifeq (n,$(findstring n,$(firstword -$(MAKEFLAGS))))
|
||||
# run with -n / --dry-run
|
||||
$(ROM):
|
||||
@$(PRINT) "$(BLUE)DRY RUNS ARE DISABLED$(NO_COL)\n"
|
||||
else
|
||||
# not running with -n / --dry-run
|
||||
$(ROM): $(ELF)
|
||||
$(call print,Building ROM:,$<,$@)
|
||||
endif
|
||||
|
||||
ifeq ($(CONSOLE),n64)
|
||||
$(V)$(OBJCOPY) --pad-to=0x101000 --gap-fill=0xFF $< $@ -O binary
|
||||
else ifeq ($(CONSOLE),bb)
|
||||
|
||||
@@ -14,7 +14,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin
|
||||
- **ArcticJaguar725**: Most audio configuration and layout changes, colored ia4 text, floombas, various bugfixes, and more
|
||||
- **CowQuack**: Adjustable skybox sizes, area-specific skybox function
|
||||
- **thecozies**: Water surface types, general maintenance, and time
|
||||
- **MrComit**: General use object defines, JUMP_KICK_FIX
|
||||
- **MrComit**: General use object defines, JUMP_KICK_FIX, LEDGE_GRABS_CHECK_SLOPE_ANGLE
|
||||
- **aglab2**: Bugfixes (particularly puppycam), refactor stuff
|
||||
- **someone2639**: math.s and crash screen disam, stack trace, map packing, shiftable segments 2, S2DEX engine
|
||||
- **Arthurtilly**: Platform Displacement 2
|
||||
@@ -34,7 +34,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin
|
||||
Thanks to Frame#5375 and AloXado320 for also helping with silhouette stuff
|
||||
|
||||
**Lighting Engine by Wiseguy**
|
||||
- Lighting Engine is available on a separate branch ([base/lighting-engine](https://github.com/Reonu/HackerSM64/tree/base/lighting-engine)). Instructions on how to use it are in the readme of that branch.
|
||||
- Lighting Engine is available on a separate branch ([base/lighting-engine-wip](https://github.com/Reonu/HackerSM64/tree/base/lighting-engine-wip)). Instructions on how to use it are in the readme of that branch.
|
||||
- Alternatively, the main repo has `Puppylights` available, which is a more lightweight, but limited lighting library intended to be used to modify existing light properties. You can look at `puppylights.c` to find out how to use it.
|
||||
|
||||
**Puppycam**
|
||||
@@ -61,6 +61,7 @@ Thanks to Frame#5375 and AloXado320 for also helping with silhouette stuff
|
||||
- Toggle to disable fall damage and the fall damage sound *
|
||||
- Nonstop stars *
|
||||
- Removed course-specific camera processing *
|
||||
- You can increase the number of frames that you have to perform a firsty *
|
||||
- Ability to set Mario's movement speed when hanging from a ceiling *
|
||||
- Tighter hanging controls (Mario will face the direction of the analog stick directly while hanging from a ceiling) *
|
||||
- reonucam3: custom camera by Reonu. This is included as a .patch file in the enhancements folder, you need to apply it if you want this camera.
|
||||
|
||||
@@ -1 +1 @@
|
||||
v2.0.8
|
||||
v2.0.1
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
// Disables all debug options (except PUPPYPRINT).
|
||||
#define DISABLE_ALL
|
||||
|
||||
// Enables a comprehensive standalone profiler. Automatically enabled by PUPPYPRINT_DEBUG.
|
||||
// If not using PUPPYPRINT_DEBUG, press L to toggle the profiler.
|
||||
// #define USE_PROFILER
|
||||
|
||||
// TEST LEVEL
|
||||
// Uncomment this define and set a test level in order to boot straight into said level.
|
||||
// This allows you to quickly test the level you're working on.
|
||||
|
||||
@@ -68,11 +68,14 @@
|
||||
// Allows Mario to grab hangable ceilings from any state.
|
||||
#define HANGING_FIX
|
||||
|
||||
// The last frame after hitting a wall that will be considered a firsty when wallkicking.
|
||||
#define FIRSTY_LAST_FRAME 1
|
||||
|
||||
// The maximum angle the player can wall kick, in degrees. 0..90. To allow 45 degree wall kicks, you must supply `46` to allow 45 and under.
|
||||
#define WALL_KICK_DEGREES 45
|
||||
|
||||
// Makes Mario unable to ledge grab steep slopes to prevent false ledge grabs.
|
||||
#define DONT_LEDGE_GRAB_STEEP_SLOPES
|
||||
// This is vanilla behavior, disable it to allow ledge grabbing regardless of floor pitch.
|
||||
// #define LEDGE_GRABS_CHECK_SLOPE_ANGLE
|
||||
|
||||
// Disables BLJs and crushes SimpleFlips's dreams.
|
||||
// #define DISABLE_BLJ
|
||||
|
||||
@@ -40,8 +40,9 @@
|
||||
|
||||
// -- WATER RING --
|
||||
|
||||
// Fix the water rings in DDD by checking for interaction rather than normals.
|
||||
#define FIX_WATER_RINGS
|
||||
// Fix DDD water rings by checking for interaction rather than normals.
|
||||
//! NOT IMPLEMENTED
|
||||
// #define FIX_WATER_RINGS
|
||||
|
||||
// -- POWER STAR --
|
||||
|
||||
|
||||
@@ -33,21 +33,15 @@
|
||||
* config_debug.h
|
||||
*/
|
||||
|
||||
#ifdef DISABLE_ALL
|
||||
#undef DEBUG_ALL
|
||||
#undef TEST_LEVEL
|
||||
#undef DEBUG_LEVEL_SELECT
|
||||
#undef ENABLE_DEBUG_FREE_MOVE
|
||||
#undef VANILLA_DEBUG
|
||||
#undef VANILLA_STYLE_CUSTOM_DEBUG
|
||||
#undef PUPPYPRINT_DEBUG
|
||||
#undef PUPPYPRINT_DEBUG_CYCLES
|
||||
#undef VISUAL_DEBUG
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
#undef PUPPYPRINT
|
||||
#define PUPPYPRINT
|
||||
#endif // PUPPYPRINT_DEBUG
|
||||
|
||||
#ifdef COMPLETE_SAVE_FILE
|
||||
#undef UNLOCK_ALL
|
||||
#undef COMPLETE_SAVE_FILE
|
||||
#undef DEBUG_FORCE_CRASH_ON_BOOT
|
||||
#undef USE_PROFILER
|
||||
#endif // DISABLE_ALL
|
||||
#define UNLOCK_ALL
|
||||
#endif // COMPLETE_SAVE_FILE
|
||||
|
||||
#ifdef DEBUG_ALL
|
||||
#undef DEBUG_LEVEL_SELECT
|
||||
@@ -72,17 +66,20 @@
|
||||
#define COMPLETE_SAVE_FILE
|
||||
#endif // DEBUG_ALL
|
||||
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
#undef PUPPYPRINT
|
||||
#define PUPPYPRINT
|
||||
#undef USE_PROFILER
|
||||
#define USE_PROFILER
|
||||
#endif // PUPPYPRINT_DEBUG
|
||||
|
||||
#ifdef COMPLETE_SAVE_FILE
|
||||
#ifdef DISABLE_ALL
|
||||
#undef DEBUG_ALL
|
||||
#undef TEST_LEVEL
|
||||
#undef DEBUG_LEVEL_SELECT
|
||||
#undef ENABLE_DEBUG_FREE_MOVE
|
||||
#undef VANILLA_DEBUG
|
||||
#undef VANILLA_STYLE_CUSTOM_DEBUG
|
||||
#undef PUPPYPRINT_DEBUG
|
||||
#undef PUPPYPRINT_DEBUG_CYCLES
|
||||
#undef VISUAL_DEBUG
|
||||
#undef UNLOCK_ALL
|
||||
#define UNLOCK_ALL
|
||||
#endif // COMPLETE_SAVE_FILE
|
||||
#undef COMPLETE_SAVE_FILE
|
||||
#undef DEBUG_FORCE_CRASH_ON_BOOT
|
||||
#endif // DISABLE_ALL
|
||||
|
||||
|
||||
/*****************
|
||||
|
||||
@@ -973,7 +973,11 @@
|
||||
#define /*0x104*/ oSnufitBodyScalePeriod OBJECT_FIELD_S32(0x1F)
|
||||
#define /*0x108*/ oSnufitBodyBaseScale OBJECT_FIELD_S32(0x20)
|
||||
#define /*0x10C*/ oSnufitBullets OBJECT_FIELD_S32(0x21)
|
||||
#define /*0x1AC*/ oSnufitBodyScale OBJECT_FIELD_S16(0x49, 0)
|
||||
#define /*0x1AC*/ oSnufitOffsetVec OBJECT_FIELD_S16(0x49, 0) // start pos of s16 vec
|
||||
#define /*0x1AC*/ oSnufitXOffset OBJECT_FIELD_S16(0x49, 0)
|
||||
#define /*0x1AE*/ oSnufitYOffset OBJECT_FIELD_S16(0x49, 1)
|
||||
#define /*0x1B0*/ oSnufitZOffset OBJECT_FIELD_S16(0x4A, 0)
|
||||
#define /*0x1B2*/ oSnufitBodyScale OBJECT_FIELD_S16(0x4A, 1)
|
||||
|
||||
/* Spindel */
|
||||
#define /*0x0F4*/ oSpindelMoveTimer OBJECT_FIELD_S32(0x1B)
|
||||
@@ -1043,6 +1047,7 @@
|
||||
#define /*0x0F4*/ oTiltingPyramidNormalX OBJECT_FIELD_F32(O_TILTING_PYRAMID_NORMAL_X_INDEX)
|
||||
#define /*0x0F8*/ oTiltingPyramidNormalY OBJECT_FIELD_F32(O_TILTING_PYRAMID_NORMAL_Y_INDEX)
|
||||
#define /*0x0FC*/ oTiltingPyramidNormalZ OBJECT_FIELD_F32(O_TILTING_PYRAMID_NORMAL_Z_INDEX)
|
||||
#define /*0x10C*/ oTiltingPyramidMarioOnPlatform OBJECT_FIELD_S32(0x21)
|
||||
|
||||
/* Toad Message */
|
||||
#define /*0x108*/ oToadMessageDialogId OBJECT_FIELD_U32(0x20)
|
||||
|
||||
71
include/rtc.h
Executable file
71
include/rtc.h
Executable file
@@ -0,0 +1,71 @@
|
||||
/*---------------------------------------------------------------------
|
||||
Copyright (C) 1997, 1998 Nintendo.
|
||||
|
||||
File rtc.h
|
||||
Coded by Shigeo Kimura. Oct 14, 1997.
|
||||
Modified by Koji Mitsunari. Jan 22, 2001.
|
||||
Comments Real Time Clock Library
|
||||
---------------------------------------------------------------------*/
|
||||
#ifndef _rtc_h_
|
||||
#define _rtc_h_
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Macro & constant definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
/* Controller type */
|
||||
#define CONT_TYPE_RTC 0x1000 /* from os.h */
|
||||
#define RTC_WAIT 300
|
||||
|
||||
/* RTC status signed 32bits */
|
||||
#define RTC_NG_NOTHING 0x8000
|
||||
#define RTC_NG_WRITE 0x0100
|
||||
#define RTC_NG_ADDR 0x0200
|
||||
#define RTC_STATUS_BUSY 0x0080
|
||||
#define RTC_STATUS_DDOWN 0x0002
|
||||
#define RTC_STATUS_BDOWN 0x0001
|
||||
|
||||
/* RTC Error Code */
|
||||
#define CONT_ERR_RTC_BUSY 16
|
||||
#define CONT_ERR_RTC_BDOWN 17
|
||||
#define CONT_ERR_RTC_DDOWN 18
|
||||
#define CONT_ERR_RTC_BDDOWN 19
|
||||
|
||||
/* RTC bit status */
|
||||
#define RTC_EALM 0x80
|
||||
#define RTC_ALM 0x20
|
||||
#define RTC_WPB1 0x02
|
||||
#define RTC_WPB0 0x01
|
||||
#define RTC_MOD 0x04
|
||||
#define RTC_CHLD 0x02
|
||||
#define RTC_ADJ 0x01
|
||||
|
||||
#define RTC_ADDR_FLAG 0
|
||||
#define RTC_ADDR_RAM 1
|
||||
#define RTC_ADDR_TIME 2
|
||||
|
||||
typedef struct{
|
||||
u8 sec; /* second 0-59 */
|
||||
u8 min; /* minute 0-59 */
|
||||
u8 hour; /* hour 0-23 */
|
||||
u8 day; /* day 1-31 */
|
||||
u8 week; /* week 0-6(sun,mon,..,sat) */
|
||||
u8 month; /* month 1-12 */
|
||||
u16 year; /* year 1901-2099 */
|
||||
} OSRTCTime;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* externs
|
||||
*-----------------------------------------------------------------------*/
|
||||
|
||||
extern s32 osRTCInit( OSMesgQueue *mq);
|
||||
extern s32 osRTCReadData( OSMesgQueue *mq, u8 *);
|
||||
extern s32 osRTCWriteData( OSMesgQueue *mq, u8 *);
|
||||
extern s32 osRTCGetTime( OSMesgQueue *mq, OSRTCTime *);
|
||||
extern s32 osRTCSetTime( OSMesgQueue *mq, OSRTCTime *);
|
||||
extern u32 osRTCGetIntervalTime(OSRTCTime *, OSRTCTime *);
|
||||
extern s32 osRTCGetLaterTime(OSMesgQueue *mq, u32, OSRTCTime *);
|
||||
extern s32 osRTCSetAlarm( OSMesgQueue *mq, u8, u8);
|
||||
extern s32 osRTCGetAlarmStat(OSMesgQueue *mq, u8 *, u8 *, int *);
|
||||
extern s32 osRTCProbe( OSMesgQueue *mq);
|
||||
|
||||
#endif /* _rtc_h_ */
|
||||
@@ -244,7 +244,7 @@ enum SurfaceTypes {
|
||||
|
||||
enum SurfaceClass {
|
||||
SURFACE_CLASS_DEFAULT,
|
||||
SURFACE_CLASS_VERY_SLIPPERY,
|
||||
SURFACE_CLASS_VERY_SLIPPERY = 0x0013,
|
||||
SURFACE_CLASS_SLIPPERY,
|
||||
SURFACE_CLASS_NOT_SLIPPERY
|
||||
};
|
||||
|
||||
@@ -98,6 +98,12 @@ typedef s8 ObjAction8;
|
||||
typedef s32 ObjAction32;
|
||||
typedef s16 ColFlags;
|
||||
|
||||
// -- Angle --
|
||||
typedef s16 Angle;
|
||||
typedef u16 UAngle;
|
||||
typedef s32 Angle32;
|
||||
typedef Angle Vec3a[3];
|
||||
|
||||
// -- Collision --
|
||||
typedef ROOM_DATA_TYPE RoomData;
|
||||
typedef COLLISION_DATA_TYPE Collision; // Collision is by default an s16, but it's best to have it match the type of COLLISION_DATA_TYPE
|
||||
@@ -483,10 +489,10 @@ struct MarioState {
|
||||
Vec3f prevPos;
|
||||
f32 lateralSpeed;
|
||||
f32 moveSpeed;
|
||||
s16 movePitch;
|
||||
s16 moveYaw;
|
||||
s16 ceilYaw;
|
||||
s16 wallYaw;
|
||||
Angle movePitch;
|
||||
Angle moveYaw;
|
||||
Angle ceilYaw;
|
||||
Angle wallYaw;
|
||||
// -- HackerSM64 MarioState fields end --
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#ifdef VERSION_EU
|
||||
#include "levels/ending/cake_eu.inc.c"
|
||||
|
||||
#ifndef EU_CUSTOM_CAKE_FIX
|
||||
// 0x07023000 - 0x07023FFF
|
||||
ALIGNED8 static const Texture cake_end_texture_eu_35_thank_you[] = {
|
||||
#include "levels/ending/eu_023000.rgba16.inc.c"
|
||||
@@ -39,7 +38,6 @@ ALIGNED8 static const Texture cake_end_texture_eu_39_fin[] = {
|
||||
ALIGNED8 static const Texture cake_end_texture_eu_40_ende[] = {
|
||||
#include "levels/ending/eu_028000.rgba16.inc.c"
|
||||
};
|
||||
#endif // !EU_CUSTOM_CAKE_FIX
|
||||
|
||||
// 0x07029000 - 0x070296D8
|
||||
const Gfx dl_cake_end_screen[] = {
|
||||
|
||||
@@ -72,11 +72,11 @@ const GeoLayout intro_geo_mario_head_regular[] = {
|
||||
GEO_CLOSE_NODE(),
|
||||
#endif
|
||||
GEO_CLOSE_NODE(),
|
||||
#if defined(ENABLE_RUMBLE)
|
||||
GEO_ZBUFFER(0),
|
||||
GEO_OPEN_NODE(),
|
||||
GEO_ASM(INTRO_CONTEXT_NORMAL, geo_intro_rumble_pak_graphic),
|
||||
GEO_CLOSE_NODE(),
|
||||
#if defined(VERSION_SH)
|
||||
GEO_ZBUFFER(0),
|
||||
GEO_OPEN_NODE(),
|
||||
GEO_ASM(INTRO_CONTEXT_NORMAL, geo_intro_rumble_pak_graphic),
|
||||
GEO_CLOSE_NODE(),
|
||||
#endif
|
||||
GEO_CLOSE_NODE(),
|
||||
GEO_END(),
|
||||
@@ -105,7 +105,7 @@ const GeoLayout intro_geo_mario_head_dizzy[] = {
|
||||
GEO_CLOSE_NODE(),
|
||||
#endif
|
||||
GEO_CLOSE_NODE(),
|
||||
#if defined(ENABLE_RUMBLE)
|
||||
#if defined(VERSION_SH)
|
||||
GEO_ZBUFFER(0),
|
||||
GEO_OPEN_NODE(),
|
||||
GEO_ASM(INTRO_CONTEXT_GAME_OVER, geo_intro_rumble_pak_graphic),
|
||||
|
||||
@@ -343,12 +343,16 @@ f32 adsr_update(struct AdsrState *adsr) {
|
||||
s32 adsr_update(struct AdsrState *adsr) {
|
||||
#endif
|
||||
u8 action = adsr->action;
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
u8 state = adsr->state;
|
||||
switch (state) {
|
||||
#else
|
||||
switch (adsr->state) {
|
||||
#endif
|
||||
case ADSR_STATE_DISABLED:
|
||||
return 0;
|
||||
|
||||
case ADSR_STATE_INITIAL:
|
||||
case ADSR_STATE_INITIAL: {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
adsr->current = adsr->initial;
|
||||
adsr->target = adsr->initial;
|
||||
@@ -357,7 +361,8 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
adsr->state = ADSR_STATE_HANG;
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_START_LOOP:
|
||||
adsr->envIndex = 0;
|
||||
@@ -365,12 +370,11 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
adsr->currentHiRes = (adsr->current << 0x10);
|
||||
#endif
|
||||
adsr->state = ADSR_STATE_LOOP;
|
||||
|
||||
#ifdef VERSION_SH
|
||||
// fallthrough
|
||||
restart:
|
||||
#endif
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_LOOP:
|
||||
adsr->delay = BSWAP16(adsr->envelope[adsr->envIndex].delay);
|
||||
switch (adsr->delay) {
|
||||
@@ -395,23 +399,25 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
if (adsr->delay >= 4) {
|
||||
adsr->delay = adsr->delay * gAudioBufferParameters.updatesPerFrame
|
||||
#ifdef VERSION_SH
|
||||
#ifdef VERSION_SH
|
||||
/ gAudioBufferParameters.presetUnk4
|
||||
#endif
|
||||
#endif
|
||||
/ 4;
|
||||
}
|
||||
#ifdef VERSION_SH
|
||||
#if defined(VERSION_SH)
|
||||
if (adsr->delay == 0) {
|
||||
adsr->delay = 1;
|
||||
}
|
||||
#endif
|
||||
adsr->target = (f32) BSWAP16(adsr->envelope[adsr->envIndex].arg) / 32767.0f;
|
||||
#elif defined(VERSION_EU)
|
||||
adsr->target = (f32) BSWAP16(adsr->envelope[adsr->envIndex].arg) / 32767.0;
|
||||
#endif
|
||||
adsr->target = adsr->target * adsr->target;
|
||||
adsr->velocity = (adsr->target - adsr->current) / adsr->delay;
|
||||
#else // !(VERSION_EU || VERSION_SH)
|
||||
#else
|
||||
adsr->target = BSWAP16(adsr->envelope[adsr->envIndex].arg);
|
||||
adsr->velocity = ((adsr->target - adsr->current) << 0x10) / adsr->delay;
|
||||
#endif // !(VERSION_EU || VERSION_SH)
|
||||
#endif
|
||||
adsr->state = ADSR_STATE_FADE;
|
||||
adsr->envIndex++;
|
||||
break;
|
||||
|
||||
@@ -1262,7 +1262,7 @@ static void update_game_sound(void) {
|
||||
#endif
|
||||
} else {
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
func_802ad728(0x04020000 | ((channelIndex & 0xff) << 8),
|
||||
func_802ad728((x04020000 | ((channelIndex & 0xff) << 8),
|
||||
get_sound_freq_scale(bank, soundIndex) + ((f32) sSoundMovingSpeed[bank] / 400.0f));
|
||||
#else
|
||||
value = get_sound_freq_scale(bank, soundIndex);
|
||||
|
||||
@@ -169,7 +169,7 @@ void reset_bank_and_seq_load_status(void) {
|
||||
#ifdef VERSION_SH
|
||||
bzero(&gBankLoadStatus, sizeof(gBankLoadStatus));
|
||||
bzero(&gUnkLoadStatus, sizeof(gUnkLoadStatus));
|
||||
bzero(&gSeqLoadStatus, sizeof(gSeqLoadStatus));
|
||||
bzero(&gSeqLoadStatus, sizeof(gBankLoadStatus));
|
||||
#else
|
||||
bzero(&gBankLoadStatus, sizeof(gBankLoadStatus)); // Setting this array to zero is equivilent to SOUND_LOAD_STATUS_NOT_LOADED
|
||||
bzero(&gSeqLoadStatus, sizeof(gSeqLoadStatus)); // Same dealio
|
||||
@@ -274,7 +274,7 @@ void sound_alloc_pool_init(struct SoundAllocPool *pool, void *memAddr, u32 size)
|
||||
#ifdef VERSION_SH
|
||||
pool->size = size - ((uintptr_t) memAddr & 0xf);
|
||||
#else
|
||||
pool->size = ALIGN16(size);
|
||||
pool->size = size;
|
||||
#endif
|
||||
pool->numAllocatedEntries = 0;
|
||||
}
|
||||
@@ -380,7 +380,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
// arg3 = 0, 1 or 2?
|
||||
|
||||
#ifdef VERSION_SH
|
||||
struct SoundMultiPool *arg0 = NULL;
|
||||
struct SoundMultiPool *arg0;
|
||||
#define isSound poolIdx
|
||||
#endif
|
||||
struct TemporaryPool *tp;
|
||||
@@ -408,8 +408,6 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
u32 leftAvail, rightAvail;
|
||||
#endif
|
||||
|
||||
size = ALIGN16(size);
|
||||
|
||||
#ifdef VERSION_SH
|
||||
switch (poolIdx) {
|
||||
case 0:
|
||||
@@ -658,7 +656,7 @@ size = ALIGN16(size);
|
||||
#if defined(VERSION_SH)
|
||||
tp->entries[1].ptr = (u8 *) ((uintptr_t) (pool->start + pool->size - size) & ~0x0f);
|
||||
#else
|
||||
tp->entries[1].ptr = pool->start + pool->size - size;
|
||||
tp->entries[1].ptr = pool->start + pool->size - size - 0x10;
|
||||
#endif
|
||||
tp->entries[1].id = id;
|
||||
tp->entries[1].size = size;
|
||||
@@ -760,7 +758,7 @@ void *get_bank_or_seq(s32 poolIdx, s32 arg1, s32 id) {
|
||||
}
|
||||
void *get_bank_or_seq_inner(s32 poolIdx, s32 arg1, s32 bankId) {
|
||||
u32 i;
|
||||
struct SoundMultiPool* loadedPool = NULL;
|
||||
struct SoundMultiPool* loadedPool;
|
||||
struct TemporaryPool* temporary;
|
||||
struct PersistentPool* persistent;
|
||||
|
||||
@@ -933,7 +931,7 @@ void decrease_reverb_gain(void) {
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
s32 audio_shut_down_and_reset_step(void) {
|
||||
s32 i;
|
||||
s32 i, j;
|
||||
|
||||
switch (gAudioResetStatus) {
|
||||
case 5:
|
||||
@@ -969,6 +967,22 @@ s32 audio_shut_down_and_reset_step(void) {
|
||||
}
|
||||
return (gAudioResetStatus < 3);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* Waits until a specified number of audio frames have been created
|
||||
*/
|
||||
void wait_for_audio_frames(s32 frames) {
|
||||
// VC emulator stubs this function because busy loops are not supported
|
||||
// Technically we can put infinite loop that _looks_ like -O0 for emu but this is cleaner
|
||||
//if (gIsVC) {
|
||||
return;
|
||||
//}
|
||||
gAudioFrameCount = 0;
|
||||
// Sound thread will update gAudioFrameCount
|
||||
while (gAudioFrameCount < frames) {
|
||||
// spin
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
u8 sAudioFirstBoot = 0;
|
||||
@@ -993,7 +1007,7 @@ void init_reverb_eu(void) {
|
||||
gNumSynthesisReverbs = preset->numReverbs;
|
||||
for (j = 0; j < gNumSynthesisReverbs; j++) {
|
||||
reverb = &gSynthesisReverbs[j];
|
||||
reverbSettings = &sReverbSettings[MIN((u32)(gAudioResetPresetIdToLoad + j), (sizeof(sReverbSettings) / sizeof(struct ReverbSettingsEU)) - 1)];
|
||||
reverbSettings = &sReverbSettings[MIN((gAudioResetPresetIdToLoad + j), (sizeof(sReverbSettings) / sizeof(struct ReverbSettingsEU)) - 1)];
|
||||
reverb->windowSize = (reverbSettings->windowSize * 0x40);
|
||||
reverb->downsampleRate = reverbSettings->downsampleRate;
|
||||
reverb->reverbGain = reverbSettings->gain;
|
||||
@@ -1153,33 +1167,22 @@ void init_reverb_us(s32 presetId) {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
void audio_reset_session(struct AudioSessionSettings *preset, s32 presetId) {
|
||||
if (sAudioFirstBoot) {
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
gAudioLoadLock = AUDIO_LOCK_LOADING;
|
||||
bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS));
|
||||
persistent_pool_clear(&gSeqLoadedPool.persistent);
|
||||
persistent_pool_clear(&gBankLoadedPool.persistent);
|
||||
temporary_pool_clear( &gSeqLoadedPool.temporary);
|
||||
temporary_pool_clear( &gBankLoadedPool.temporary);
|
||||
reset_bank_and_seq_load_status();
|
||||
|
||||
if (!gIsVC) {
|
||||
gAudioFrameCount = 0;
|
||||
while (gAudioFrameCount < 1) {
|
||||
// spin
|
||||
}
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
gNotes[i].enabled = FALSE;
|
||||
}
|
||||
|
||||
persistent_pool_clear(&gSeqLoadedPool.persistent);
|
||||
persistent_pool_clear(&gBankLoadedPool.persistent);
|
||||
temporary_pool_clear( &gSeqLoadedPool.temporary);
|
||||
temporary_pool_clear( &gBankLoadedPool.temporary);
|
||||
reset_bank_and_seq_load_status();
|
||||
|
||||
init_reverb_us(presetId);
|
||||
bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS));
|
||||
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
init_reverb_us(presetId);
|
||||
bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS));
|
||||
gAudioFrameCount = 0;
|
||||
if (!gIsVC) {
|
||||
while (gAudioFrameCount < 1) {
|
||||
// spin
|
||||
}
|
||||
}
|
||||
bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS));
|
||||
return;
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -38,14 +38,8 @@ struct SeqOrBankEntry {
|
||||
struct PersistentPool {
|
||||
/*0x00*/ u32 numEntries;
|
||||
/*0x04*/ struct SoundAllocPool pool;
|
||||
#ifdef EXPAND_AUDIO_HEAP // TODO: Make this a configurable define rather than using static values
|
||||
/*0x14*/ struct SeqOrBankEntry entries[64];
|
||||
// size = 0x314
|
||||
#else
|
||||
/*0x14*/ struct SeqOrBankEntry entries[32];
|
||||
// size = 0x194
|
||||
#endif
|
||||
};
|
||||
}; // size = 0x194
|
||||
|
||||
struct TemporaryPool {
|
||||
/*EU, SH*/
|
||||
@@ -70,14 +64,9 @@ struct SoundMultiPool {
|
||||
/* */ u32 pad2[4];
|
||||
}; // size = 0x1D0
|
||||
|
||||
#ifdef VERSION_SH
|
||||
struct Unk1Pool {
|
||||
struct SoundAllocPool pool;
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
struct SeqOrBankEntry entries[64];
|
||||
#else
|
||||
struct SeqOrBankEntry entries[32];
|
||||
#endif
|
||||
};
|
||||
|
||||
struct UnkEntry {
|
||||
@@ -96,7 +85,6 @@ struct UnkPool {
|
||||
/*0x510*/ s32 numEntries;
|
||||
/*0x514*/ u32 unk514;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern u8 gAudioHeap[];
|
||||
extern s16 gVolume;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user