HackerSM64 Release: v2.3.0

Merge pull request #815 from HackerN64/develop/2.3.0
This commit is contained in:
Gregory Heskett authored and GitHub committed 2024-07-03 23:05:21 -04:00
commit 9ef945296b
53 files changed
+610 -508

No files matched your search

+3
View File
@@ -2149,3 +2149,6 @@ lib/libs2d_engine.a
# :Zone_Identifier files
*Zone.Identifier
# user-specific config file
include/config/config_local.h
+15 -4
View File
@@ -269,7 +269,7 @@ BUILD_DIR_BASE := build
# BUILD_DIR is the location where all build artifacts are placed
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_$(CONSOLE)
COMPRESS ?= rnc1
COMPRESS ?= yay0
$(eval $(call validate-option,COMPRESS,mio0 yay0 gzip rnc1 rnc2 uncomp))
ifeq ($(COMPRESS),gzip)
DEFINES += GZIP=1
@@ -399,6 +399,9 @@ GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c))
S_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.s))
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c
# Ignore all .inc.c files
C_FILES := $(filter-out %.inc.c,$(C_FILES))
# Sound files
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
SOUND_SAMPLE_DIRS := $(wildcard sound/samples/*)
@@ -441,6 +444,8 @@ else ifneq ($(call find-command,mips-linux-gnu-ld),)
CROSS := mips-linux-gnu-
else ifneq ($(call find-command,mips64-linux-gnu-ld),)
CROSS := mips64-linux-gnu-
else ifneq ($(call find-command,mips64-none-elf-ld),)
CROSS := mips64-none-elf-
else ifneq ($(call find-command,mips-ld),)
CROSS := mips-
else
@@ -548,7 +553,13 @@ ifneq (,$(call find-command,armips))
else
RSPASM := $(TOOLS_DIR)/armips
endif
EMULATOR = mupen64plus
ifneq (,$(call find-command,wslview))
EMULATOR = "/mnt/c/Program Files (x86)/parallel-launcher/parallel-launcher.exe"
else
EMULATOR = parallel-launcher
endif
EMU_FLAGS =
ifneq (,$(call find-command,wslview))
@@ -769,7 +780,7 @@ endif
$(BUILD_DIR)/%.table: %.aiff
$(call print,Extracting codebook:,$<,$@)
$(V)$(AIFF_EXTRACT_CODEBOOK) $< >$@
$(V)$(AIFF_EXTRACT_CODEBOOK) $< $@
$(BUILD_DIR)/%.aifc: $(BUILD_DIR)/%.table %.aiff
$(call print,Encoding ADPCM:,$(word 2,$^),$@)
@@ -913,7 +924,7 @@ $(BUILD_DIR)/asm/debug/map.o: asm/debug/map.s $(BUILD_DIR)/sm64_prelim.elf
# Link SM64 ELF file
$(ELF): $(BUILD_DIR)/sm64_prelim.elf $(BUILD_DIR)/asm/debug/map.o $(O_FILES) $(YAY0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) $(BUILD_DIR)/libz.a $(BUILD_DIR)/libgoddard.a
@$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n"
$(V)$(LD) --gc-sections -L $(BUILD_DIR) -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
$(V)$(LD) --gc-sections -L $(BUILD_DIR) -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
# Build ROM
ifeq (n,$(findstring n,$(firstword -$(MAKEFLAGS))))
+1 -1
View File
@@ -1 +1 @@
v2.2.0
v2.3.0
+2
View File
@@ -2474,6 +2474,7 @@ static const Vtx vertex_billboard_num[] = {
// 0x0200EFF0 - 0x0200F038
const Gfx dl_billboard_num_begin[] = {
gsDPPipeSync(),
gsDPSetTextureFilter(G_TF_POINT),
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
gsSPClearGeometryMode(G_LIGHTING),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD),
@@ -2490,6 +2491,7 @@ const Gfx dl_billboard_num_end[] = {
gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0),
gsSPTexture(0x8000, 0x8000, 0, G_TX_RENDERTILE, G_OFF),
gsDPPipeSync(),
gsDPSetTextureFilter(G_TF_BILERP),
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
gsSPSetGeometryMode(G_LIGHTING),
gsSPEndDisplayList(),
+2 -6
View File
@@ -2694,7 +2694,7 @@ const BehaviorScript bhvSushiShark[] = {
const BehaviorScript bhvJrbSlidingBox[] = {
BEGIN(OBJ_LIST_SURFACE),
OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE),
OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE | OBJ_FLAG_NO_AUTO_DISPLACEMENT),
LOAD_COLLISION_DATA(jrb_seg7_collision_floating_box),
SET_HOME(),
BEGIN_LOOP(),
@@ -5437,11 +5437,7 @@ const BehaviorScript bhvTTCPendulum[] = {
const BehaviorScript bhvTTCTreadmill[] = {
BEGIN(OBJ_LIST_SURFACE),
#ifdef PLATFORM_DISPLACEMENT_2
OR_INT(oFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE | OBJ_FLAG_VELOCITY_PLATFORM)),
#else
OR_INT(oFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)),
#endif
OR_INT(oFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE | OBJ_FLAG_NO_AUTO_DISPLACEMENT)),
SET_FLOAT(oCollisionDistance, 750),
CALL_NATIVE(bhv_ttc_treadmill_init),
DELAY(1),
+9 -3
View File
@@ -177,9 +177,15 @@ def main():
# presence of the correct roms automatically
# Make sure tools exist
subprocess.check_call(
["make", "-s", "-C", "tools/", "n64graphics", "skyconv", "mio0", "aifc_decode"]
)
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
# mio0 file still go together).
+5 -1
View File
@@ -19,6 +19,10 @@
#include "config/config_objects.h"
#include "config/config_rom.h"
// Local config - include a gitignore'd config file that's specific to just the user (if the file exists)
#if __has_include("config/config_local.h")
#include "config/config_local.h"
#endif
/* WARNING: Compatibility safeguards - don't remove this file unless you know what you're doing */
// WARNING: Compatibility safeguards - don't remove this file unless you know what you're doing
#include "config/config_safeguards.h"
-6
View File
@@ -136,14 +136,8 @@
*/
#define BUGFIX_DIALOG_TIME_STOP
/**
* Enables Platform Displacement 2, an upgrade to the physics involving moving platforms and how Mario interacts with them.
*/
#define PLATFORM_DISPLACEMENT_2
/**
* Inertia defines; allow Mario to preserve his momemtum when leaving moving platforms.
* These require Platform Displacement 2 to be enabled.
*/
#define MARIO_INERTIA_UPWARD
// #define MARIO_INERTIA_LATERAL
+1 -1
View File
@@ -47,7 +47,7 @@ enum ObjFlags {
OBJ_FLAG_1000 = (1 << 12), // 0x00001000
OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO = (1 << 13), // 0x00002000
OBJ_FLAG_PERSISTENT_RESPAWN = (1 << 14), // 0x00004000
OBJ_FLAG_VELOCITY_PLATFORM = (1 << 15), // 0x00008000
OBJ_FLAG_NO_AUTO_DISPLACEMENT = (1 << 15), // 0x00008000
OBJ_FLAG_DONT_CALC_COLL_DIST = (1 << 16), // 0x00010000
OBJ_FLAG_SILHOUETTE = (1 << 19), // 0x00080000
OBJ_FLAG_OCCLUDE_SILHOUETTE = (1 << 20), // 0x00100000
+15 -1
View File
@@ -36,15 +36,27 @@ enum SoundBank {
SOUND_BANK_MENU,
SOUND_BANK_GENERAL2,
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
};
#define SOUND_BANKS_ALL_BITS 0xffff
#define SOUND_BANKS_ALL ((1 << SOUND_BANK_COUNT) - 1)
#define SOUND_BANKS_FOREGROUND (\
(1 << SOUND_BANK_ACTION) |\
(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_DISABLED_DURING_INTRO_CUTSCENE (\
(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_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
BIN
View File
Binary file not shown.
+8 -12
View File
@@ -175,10 +175,9 @@ SECTIONS
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.text*);
#endif
*/ULTRALIB.a:*.o(.text*);
*ULTRALIB.a:*.o(.text*);
*/libnustd.a:*.o(.text*);
*/libgcc.a:*.o(.text*);
*/librtc.a:*.o(.text*);
*libgcc.a:*.o(.text*);
*/libz.a:*.o(.text*);
*/libhvqm2.a:*.o(.text*);
lib/rspboot.o(.text*);
@@ -198,9 +197,8 @@ SECTIONS
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.*data*);
#endif
*/ULTRALIB.a:*.o(.data*);
*ULTRALIB.a:*.o(.data*);
*/libhvqm2.a:*.o(.data*);
*/librtc.a:*.o(.data*);
*/libz.a:*.o(.data*);
#include "rspdata.inc.ld"
BUILD_DIR/lib/aspMain.o(.data*);
@@ -217,9 +215,8 @@ SECTIONS
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.rodata*);
#endif
*/ULTRALIB.a:*.o(.rodata*);
*/libgcc.a:*.o(.rodata*);
*/librtc.a:*.o(.rodata*);
*ULTRALIB.a:*.o(.rodata*);
*libgcc.a:*.o(.rodata*);
*/libz.a:*.o(.rodata*);
lib/PR/hvqm/hvqm2sp1.o(.rodata*);
@@ -237,11 +234,10 @@ SECTIONS
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.*bss*);
#endif
*/ULTRALIB.a:*.o(COMMON);
*/ULTRALIB.a:*.o(.scommon);
*/ULTRALIB.a:*.o(.*bss*);
*ULTRALIB.a:*.o(COMMON);
*ULTRALIB.a:*.o(.scommon);
*ULTRALIB.a:*.o(.*bss*);
*/libhvqm2.a:*.o(.bss*);
*/librtc.a:*.o(.bss*);
*/libz.a:*.o(.bss*);
. = ALIGN(0x8);
}
+98 -1
View File
@@ -12,7 +12,7 @@ seq_setmutescale 0
seq_setvol 127
#endif
seq_settempo 120
seq_initchannels 0x3ff
seq_initchannels 0xffff
seq_startchannel 0, .channel0
seq_startchannel 1, .channel1
seq_startchannel 2, .channel2
@@ -23,6 +23,12 @@ seq_startchannel 6, .channel6
seq_startchannel 7, .channel7
seq_startchannel 8, .channel38
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_delay 20000
seq_jump .seq_loop
@@ -71,6 +77,72 @@ chan_stereoheadseteffects 1
chan_setdyntable .channel59_table
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_023589:
chan_hang
@@ -7903,6 +7975,31 @@ layer_note0 38, 0x3, 127, 127
layer_delay 0x2a
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
.envelope_32C4:
envelope_line 7 20000
+12 -23
View File
@@ -313,10 +313,10 @@ STATIC_ASSERT(ARRAY_COUNT(sBackgroundMusicDefaultVolume) == SEQ_COUNT,
u8 sCurrentBackgroundMusicSeqId = SEQUENCE_NONE;
u8 sMusicDynamicDelay = 0;
u8 sSoundBankUsedListBack[SOUND_BANK_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
u8 sSoundBankFreeListFront[SOUND_BANK_COUNT] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
u8 sNumSoundsInBank[SOUND_BANK_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // only used for debugging
u8 sMaxChannelsForSoundBank[SOUND_BANK_COUNT] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
u8 sSoundBankUsedListBack[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 0};
u8 sSoundBankFreeListFront[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 1};
u8 sNumSoundsInBank[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 0}; // only used for debugging
u8 sMaxChannelsForSoundBank[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 1};
// sBackgroundMusicMaxTargetVolume and sBackgroundMusicTargetVolume use the 0x80
// 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
struct Sound sSoundRequests[0x100];
// Curiously, this has size 3, despite SEQUENCE_PLAYERS == 4 on EU
struct ChannelVolumeScaleFade D_80360928[3][CHANNELS_MAX];
struct ChannelVolumeScaleFade D_80360928[SEQUENCE_PLAYERS][CHANNELS_MAX];
u8 sUsedChannelsForSoundBank[SOUND_BANK_COUNT];
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);
#endif
break;
case SOUND_BANK_GENERAL:
case SOUND_BANK_ENV:
case SOUND_BANK_OBJ:
case SOUND_BANK_AIR:
case SOUND_BANK_GENERAL2:
case SOUND_BANK_OBJ2:
default:
#if defined(VERSION_EU) || defined(VERSION_SH)
func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8),
get_sound_reverb(bank, soundIndex, channelIndex));
@@ -1507,12 +1501,7 @@ static void update_game_sound(void) {
get_sound_reverb(bank, soundIndex, channelIndex);
#endif
break;
case SOUND_BANK_GENERAL:
case SOUND_BANK_ENV:
case SOUND_BANK_OBJ:
case SOUND_BANK_AIR:
case SOUND_BANK_GENERAL2:
case SOUND_BANK_OBJ2:
default:
#if defined(VERSION_EU) || defined(VERSION_SH)
func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8),
get_sound_reverb(bank, soundIndex, channelIndex));
@@ -1952,7 +1941,7 @@ void sound_init(void) {
for (i = 0; i < SOUND_BANK_COUNT; i++) {
// 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;
}
@@ -1972,7 +1961,7 @@ void sound_init(void) {
sSoundBanks[i][0].next = 0xff;
// 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].next = j + 1;
}
@@ -1980,7 +1969,7 @@ void sound_init(void) {
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++) {
D_80360928[j][i].remainingFrames = 0;
}
@@ -2371,9 +2360,9 @@ void play_secondary_music(u8 seqId, u8 bgMusicVolume, u8 volume, u16 fadeTimer)
/**
* Called from threads: thread5_game_loop
* Seems to be related to music fading based on position, such as sleeping Piranha Plants, BBH Merry-Go-Round, and Endless Stairs
* Plays the primary music and stops playing the secondary music. Call it to cancel the above function.
*/
void func_80321080(u16 fadeTimer) {
void stop_secondary_music(u16 fadeTimer) {
if (sBackgroundMusicTargetVolume != TARGET_VOLUME_UNSET) {
sBackgroundMusicTargetVolume = TARGET_VOLUME_UNSET;
D_80332120 = 0;
+1 -1
View File
@@ -62,7 +62,7 @@ void fadeout_background_music(u16 seqId, u16 fadeOut);
void drop_queued_background_music(void);
u32 get_current_background_music(void);
void play_secondary_music(u8 seqId, u8 bgMusicVolume, u8 volume, u16 fadeTimer);
void func_80321080(u16 fadeTimer);
void stop_secondary_music(u16 fadeTimer);
void func_803210D4(u16 fadeOutTime);
void play_course_clear(s32 isKey);
void play_peachs_jingle(void);
+1
View File
@@ -1062,6 +1062,7 @@ void init_reverb_us(s32 presetId) {
betterReverbPreset = &gBetterReverbSettings[0];
}
activeBetterReverbPreset = gBetterReverbPresetValue;
betterReverbLightweight = betterReverbPreset->useLightweightSettings;
betterReverbDownsampleRate = betterReverbPreset->downsampleRate;
monoReverb = betterReverbPreset->isMono;
+1
View File
@@ -43,6 +43,7 @@
#ifdef BETTER_REVERB
// Do not touch these values manually, unless you want potential for problems.
u8 gBetterReverbPresetValue = 0;
u8 activeBetterReverbPreset = 0;
u8 toggleBetterReverb = FALSE;
u8 betterReverbLightweight = FALSE;
u8 monoReverb;
+1
View File
@@ -55,6 +55,7 @@ enum ChannelIndexes {
extern u8 toggleBetterReverb;
extern u8 gBetterReverbPresetValue;
extern u8 activeBetterReverbPreset;
extern u8 betterReverbLightweight;
extern s8 betterReverbDownsampleRate;
extern u8 monoReverb;
-2
View File
@@ -523,8 +523,6 @@ static void level_cmd_create_warp_node(void) {
warpNode->node.destArea = CMD_GET(u8, 4);
warpNode->node.destNode = CMD_GET(u8, 5);
warpNode->object = NULL;
warpNode->next = gAreas[sCurrAreaIndex].warpNodes;
gAreas[sCurrAreaIndex].warpNodes = warpNode;
}
+8 -8
View File
@@ -921,20 +921,20 @@ void find_surface_on_ray_cell(s32 cellX, s32 cellZ, Vec3f orig, Vec3f normalized
if ((cellX >= 0) && (cellX <= (NUM_CELLS - 1)) && (cellZ >= 0) && (cellZ <= (NUM_CELLS - 1))) {
// Iterate through each surface in this partition
if ((normalized_dir[1] > -NEAR_ONE) && (flags & RAYCAST_FIND_CEIL)) {
find_surface_on_ray_list( gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list( gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ], orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ], orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
}
if ((normalized_dir[1] < NEAR_ONE) && (flags & RAYCAST_FIND_FLOOR)) {
find_surface_on_ray_list( gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list( gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS], orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS], orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
}
if (flags & RAYCAST_FIND_WALL) {
find_surface_on_ray_list( gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list( gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ], orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ], orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
}
if (flags & RAYCAST_FIND_WATER) {
find_surface_on_ray_list( gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next, orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list( gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ], orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
find_surface_on_ray_list(gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ], orig, normalized_dir, dir_length, hit_surface, hit_pos, max_length);
}
}
}
+14 -14
View File
@@ -220,12 +220,12 @@ s32 find_wall_collisions(struct WallCollisionData *colData) {
for (s32 cellZ = minCellZ; cellZ <= maxCellZ; cellZ++) {
if (!(gCollisionFlags & COLLISION_FLAG_EXCLUDE_DYNAMIC)) {
// Check for surfaces belonging to objects.
node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next;
node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS];
numCollisions += find_wall_collisions_from_list(node, colData);
}
// Check for surfaces that are a part of level geometry.
node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next;
node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS];
numCollisions += find_wall_collisions_from_list(node, colData);
}
}
@@ -376,7 +376,7 @@ f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) {
if (includeDynamic) {
// Check for surfaces belonging to objects.
surfaceList = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next;
surfaceList = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS];
dynamicCeil = find_ceil_from_list(surfaceList, x, y, z, &dynamicHeight);
// In the next check, only check for ceilings lower than the previous check.
@@ -384,7 +384,7 @@ f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) {
}
// Check for surfaces that are a part of level geometry.
surfaceList = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next;
surfaceList = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS];
ceil = find_ceil_from_list(surfaceList, x, y, z, &height);
// Use the lower ceiling.
@@ -573,7 +573,7 @@ f32 unused_find_dynamic_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfl
s32 cellX = GET_CELL_COORD(x);
s32 cellZ = GET_CELL_COORD(z);
struct SurfaceNode *surfaceList = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next;
struct SurfaceNode *surfaceList = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS];
*pfloor = find_floor_from_list(surfaceList, x, y, z, &floorHeight);
@@ -615,7 +615,7 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) {
if (includeDynamic) {
// Check for surfaces belonging to objects.
surfaceList = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next;
surfaceList = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS];
dynamicFloor = find_floor_from_list(surfaceList, x, y, z, &dynamicHeight);
// In the next check, only check for floors higher than the previous check.
@@ -623,7 +623,7 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) {
}
// Check for surfaces that are a part of level geometry.
surfaceList = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next;
surfaceList = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS];
floor = find_floor_from_list(surfaceList, x, y, z, &height);
// Use the higher floor.
@@ -690,7 +690,7 @@ f32 find_water_floor(s32 xPos, s32 yPos, s32 zPos, struct Surface **pfloor) {
s32 cellZ = GET_CELL_COORD(z);
// Check for surfaces that are a part of level geometry.
struct SurfaceNode *surfaceList = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER].next;
struct SurfaceNode *surfaceList = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER];
struct Surface *floor = find_water_floor_from_list(surfaceList, x, y, z, &height);
if (floor == NULL) {
@@ -856,22 +856,22 @@ void debug_surface_list_info(f32 xPos, f32 zPos) {
s32 cellX = GET_CELL_COORD(xPos);
s32 cellZ = GET_CELL_COORD(zPos);
list = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next;
list = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS];
numFloors += surface_list_length(list);
list = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next;
list = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS];
numFloors += surface_list_length(list);
list = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next;
list = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS];
numWalls += surface_list_length(list);
list = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next;
list = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS];
numWalls += surface_list_length(list);
list = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next;
list = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS];
numCeils += surface_list_length(list);
list = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next;
list = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS];
numCeils += surface_list_length(list);
print_debug_top_down_mapinfo("area %x", cellZ * NUM_CELLS + cellX);
+27 -34
View File
@@ -87,30 +87,6 @@ static struct Surface *alloc_surface(u32 dynamic) {
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].next = NULL;
(*cells)[SPATIAL_PARTITION_CEILS].next = NULL;
(*cells)[SPATIAL_PARTITION_WALLS].next = NULL;
(*cells)[SPATIAL_PARTITION_WATER].next = 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.
* @param dynamic Determines whether the surface is static or dynamic
@@ -119,7 +95,7 @@ static void clear_static_surfaces(void) {
* @param surface The surface to add
*/
static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surface *surface) {
struct SurfaceNode *list;
struct SurfaceNode **list;
s32 priority;
s32 sortDir = 1; // highest to lowest, then insertion order (water and floors)
s32 listIndex;
@@ -146,7 +122,7 @@ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surfac
if (sNumCellsUsed >= sizeof(sCellsUsed) / sizeof(struct CellCoords)) {
sClearAllCells = TRUE;
} else {
if (list->next == NULL) {
if (*list == NULL) {
sCellsUsed[sNumCellsUsed].z = cellZ;
sCellsUsed[sNumCellsUsed].x = cellX;
sCellsUsed[sNumCellsUsed].partition = listIndex;
@@ -157,19 +133,34 @@ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surfac
list = &gStaticSurfacePartition[cellZ][cellX][listIndex];
}
if (*list == NULL) {
*list = newNode;
return;
}
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.
while (list->next != NULL) {
priority = list->next->surface->upperY * sortDir;
while (curNode->next != NULL) {
priority = curNode->next->surface->upperY * sortDir;
if (surfacePriority > priority) {
break;
}
list = list->next;
curNode = curNode->next;
}
newNode->next = list->next;
list->next = newNode;
newNode->next = curNode->next;
curNode->next = newNode;
}
/**
@@ -497,7 +488,9 @@ void load_area_terrain(s32 index, TerrainData *data, RoomData *surfaceRooms, s16
sNumCellsUsed = 0;
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
gCurrStaticSurfacePool = main_pool_alloc(main_pool_available() - 0x10, MEMORY_POOL_LEFT);
@@ -560,10 +553,10 @@ void clear_dynamic_surfaces(void) {
gSurfaceNodesAllocated = gNumStaticSurfaceNodes;
gDynamicSurfacePoolEnd = gDynamicSurfacePool;
if (sClearAllCells) {
clear_spatial_partition(&gDynamicSurfacePartition[0][0]);
bzero(gDynamicSurfacePartition, sizeof(gDynamicSurfacePartition));
} else {
for (u32 i = 0; i < sNumCellsUsed; i++) {
gDynamicSurfacePartition[sCellsUsed[i].z][sCellsUsed[i].x][sCellsUsed[i].partition].next = NULL;
gDynamicSurfacePartition[sCellsUsed[i].z][sCellsUsed[i].x][sCellsUsed[i].partition] = NULL;
}
}
sNumCellsUsed = 0;
+1 -1
View File
@@ -29,7 +29,7 @@ enum SpatialPartitions {
NUM_SPATIAL_PARTITIONS
};
typedef struct SurfaceNode SpatialPartitionCell[NUM_SPATIAL_PARTITIONS];
typedef struct SurfaceNode *SpatialPartitionCell[NUM_SPATIAL_PARTITIONS];
extern SpatialPartitionCell gStaticSurfacePartition[NUM_CELLS][NUM_CELLS];
extern SpatialPartitionCell gDynamicSurfacePartition[NUM_CELLS][NUM_CELLS];
+7 -13
View File
@@ -139,7 +139,7 @@ u32 get_mario_spawn_type(struct Object *obj) {
s32 i;
const BehaviorScript *behavior = virtual_to_segmented(SEGMENT_BEHAVIOR_DATA, obj->behavior);
for (i = 0; i < 20; i++) {
for (i = 0; i < ARRAY_COUNT(sWarpBhvSpawnTable); i++) {
if (sWarpBhvSpawnTable[i] == behavior) {
return sSpawnTypeFromWarpBhv[i];
}
@@ -158,25 +158,20 @@ struct ObjectWarpNode *area_get_warp_node(u8 id) {
return node;
}
struct ObjectWarpNode *area_get_warp_node_from_params(struct Object *obj) {
return area_get_warp_node(GET_BPARAM2(obj->oBehParams));
}
void load_obj_warp_nodes(void) {
struct ObjectWarpNode *warpNode;
struct Object *get_destination_warp_object(u8 warpDestId) {
struct Object *children = (struct Object *) gObjParentGraphNode.children;
do {
struct Object *obj = children;
if (obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && get_mario_spawn_type(obj) != 0) {
warpNode = area_get_warp_node_from_params(obj);
if (warpNode != NULL) {
warpNode->object = obj;
}
u8 bparam2 = GET_BPARAM2(obj->oBehParams);
if (warpDestId == bparam2 && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && get_mario_spawn_type(obj) != MARIO_SPAWN_NONE) {
return obj;
}
} while ((children = (struct Object *) children->header.gfx.node.next)
!= (struct Object *) gObjParentGraphNode.children);
return NULL;
}
void clear_areas(void) {
@@ -251,7 +246,6 @@ void load_area(s32 index) {
spawn_objects_from_info(0, gCurrentArea->objectSpawnInfos);
}
load_obj_warp_nodes();
geo_call_global_function_nodes(&gCurrentArea->graphNode->node, GEO_CONTEXT_AREA_LOAD);
}
}
+2 -2
View File
@@ -16,8 +16,7 @@ struct WarpNode {
struct ObjectWarpNode {
/*0x00*/ struct WarpNode node;
/*0x04*/ struct Object *object;
/*0x08*/ struct ObjectWarpNode *next;
/*0x04*/ struct ObjectWarpNode *next;
};
struct InstantWarp {
@@ -185,6 +184,7 @@ void override_viewport_and_clip(Vp *a, Vp *b, u8 c, u8 d, u8 e);
void print_intro_text(void);
u32 get_mario_spawn_type(struct Object *obj);
struct ObjectWarpNode *area_get_warp_node(u8 id);
struct Object *get_destination_warp_object(u8 warpDestId);
void clear_areas(void);
void clear_area_graph_nodes(void);
void load_area(s32 index);
+2 -2
View File
@@ -53,7 +53,7 @@ static void handle_merry_go_round_music(void) {
// The merry-go-round is a dynamic surface.
gMarioCurrentRoom != BBH_DYNAMIC_SURFACE_ROOM
&& gMarioCurrentRoom != BBH_NEAR_MERRY_GO_ROUND_ROOM) {
func_80321080(300); //! Switch to BBH music? FIXME: Audio needs labelling
stop_secondary_music(300);
o->oMerryGoRoundMusicShouldPlay = FALSE;
} else {
cur_obj_play_sound_1(SOUND_ENV_MERRY_GO_ROUND_CREAKING);
@@ -94,6 +94,6 @@ void bhv_merry_go_round_loop(void) {
handle_merry_go_round_music();
} else {
o->oAngleVelYaw = 0;
func_80321080(300); //! Switch to BBH music? FIXME: Audio needs labelling
stop_secondary_music(300);
}
}
+11 -7
View File
@@ -49,12 +49,6 @@ void bhv_hidden_blue_coin_loop(void) {
cur_obj_enable_rendering();
cur_obj_become_tangible();
// Delete the coin once collected
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
spawn_object(o, MODEL_SPARKLES, bhvCoinSparklesSpawner);
obj_mark_for_deletion(o);
}
// After 200 frames of waiting and 20 2-frame blinks (for 240 frames total),
// delete the object.
if (cur_obj_wait_then_blink(200, 20)) {
@@ -69,6 +63,12 @@ void bhv_hidden_blue_coin_loop(void) {
break;
}
// Delete the coin once collected
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
spawn_object(o, MODEL_SPARKLES, bhvCoinSparklesSpawner);
obj_mark_for_deletion(o);
}
o->oInteractStatus = INT_STATUS_NONE;
}
@@ -158,7 +158,11 @@ void bhv_blue_coin_switch_loop(void) {
load_object_collision_model();
break;
case BLUE_COIN_SWITCH_ACT_EXTENDING:
if (o->oTimer > 3) {
if (cur_obj_nearest_object_with_behavior(bhvHiddenBlueCoin) == NULL) {
// This code can be executed if the last blue coin is collected at the very end of the timer.
spawn_mist_particles_variable(0, 0, 46.0f);
obj_mark_for_deletion(o);
} else if (o->oTimer > 3) {
// Set to BLUE_COIN_SWITCH_ACT_IDLE
o->oAction = BLUE_COIN_SWITCH_ACT_IDLE;
} else {
+5 -12
View File
@@ -1435,9 +1435,7 @@ s32 bowser_check_fallen_off_stage(void) {
return FALSE;
}
#ifdef PLATFORM_DISPLACEMENT_2
struct PlatformDisplacementInfo sBowserDisplacementInfo;
#endif
/**
* Set Bowser's actions
@@ -1513,18 +1511,13 @@ s8 sBowserHealth[] = { 1, 1, 3 };
*/
void bowser_free_update(void) {
struct Object *platform = o->platform;
#ifdef PLATFORM_DISPLACEMENT_2
s16 tmpOFaceAngleYaw = (s16) o->oFaceAngleYaw;
if (platform != NULL) {
// NOTE: This function was at one point using '&o->oFaceAngleYaw', which is a s32 address. Should tmpOFaceAngleYaw be using the first 16 bits instead, or was that a bug?
apply_platform_displacement(&sBowserDisplacementInfo, &o->oPosVec, &tmpOFaceAngleYaw, platform);
o->oFaceAngleYaw = tmpOFaceAngleYaw;
s16 tempYaw = (s16) o->oFaceAngleYaw;
apply_platform_displacement(&sBowserDisplacementInfo, &o->oPosVec, &tempYaw, platform);
o->oFaceAngleYaw = tempYaw;
}
#else
if (platform != NULL) {
apply_platform_displacement(FALSE, platform);
}
#endif
// Reset grabbed status
o->oBowserGrabbedStatus = BOWSER_GRAB_STATUS_NONE;
// Update positions and actions (default action)
+1 -1
View File
@@ -131,7 +131,7 @@ void bhv_coin_loop(void) {
}
}
if (o->oVelY < 0) {
if (o->oVelY <= 0) {
cur_obj_become_tangible();
}
+3 -3
View File
@@ -38,7 +38,7 @@ s32 piranha_plant_check_interactions(void) {
s32 i;
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
func_80321080(50);
stop_secondary_music(50);
if (o->oInteractStatus & INT_STATUS_WAS_ATTACKED) {
cur_obj_play_sound_2(SOUND_OBJ2_PIRANHA_PLANT_DYING);
@@ -89,7 +89,7 @@ void piranha_plant_act_sleeping(void) {
o->oPiranhaPlantSleepMusicState = PIRANHA_PLANT_SLEEP_MUSIC_PLAYING;
} else if (o->oPiranhaPlantSleepMusicState == PIRANHA_PLANT_SLEEP_MUSIC_PLAYING) {
o->oPiranhaPlantSleepMusicState++;
func_80321080(50);
stop_secondary_music(50);
}
piranha_plant_check_interactions();
}
@@ -104,7 +104,7 @@ void piranha_plant_act_woken_up(void) {
*/
o->oDamageOrCoinValue = 3;
if (o->oTimer == 0) {
func_80321080(50);
stop_secondary_music(50);
}
if (!piranha_plant_check_interactions() && o->oTimer > 10) {
@@ -17,29 +17,13 @@ void bhv_platform_normals_init(void) {
* then gradually tilt back moving Mario with them.
*/
void bhv_tilting_inverted_pyramid_loop(void) {
#ifndef PLATFORM_DISPLACEMENT_2
Vec3f posBeforeRotation, posAfterRotation;
Vec3f marioPos, dist;
#endif
Vec3f targetNormal;
Mat4 *transform = &o->transform;
s32 marioOnPlatform = (gMarioObject->platform == o);
if (marioOnPlatform) {
#ifndef PLATFORM_DISPLACEMENT_2
// Target the normal in Mario's direction
vec3_diff(dist, gMarioStates[0].pos, &o->oPosVec);
// Get Mario's position before the rotation
vec3f_copy(marioPos, gMarioStates[0].pos);
linear_mtxf_mul_vec3f(*transform, posBeforeRotation, dist);
targetNormal[0] = dist[0];
targetNormal[2] = dist[2];
#else // PLATFORM_DISPLACEMENT_2
targetNormal[0] = gMarioStates[0].pos[0] - o->oPosX;
targetNormal[2] = gMarioStates[0].pos[2] - o->oPosZ;
#endif
targetNormal[1] = 500.0f;
vec3f_normalize(targetNormal);
} else {
@@ -54,16 +38,5 @@ void bhv_tilting_inverted_pyramid_loop(void) {
approach_f32_symmetric_bool(&o->oTiltingPyramidNormalZ, targetNormal[2], 0.01f);
mtxf_align_terrain_normal(*transform, &o->oTiltingPyramidNormalVec, &o->oPosVec, 0x0);
#ifndef PLATFORM_DISPLACEMENT_2
// If Mario is on the platform, adjust his position for the platform tilt.
if (marioOnPlatform) {
linear_mtxf_mul_vec3f(*transform, posAfterRotation, dist);
marioPos[0] += posAfterRotation[0] - posBeforeRotation[0];
marioPos[1] += posAfterRotation[1] - posBeforeRotation[1];
marioPos[2] += posAfterRotation[2] - posBeforeRotation[2];
vec3f_copy(gMarioStates[0].pos, marioPos);
}
#endif
o->header.gfx.throwMatrix = transform;
}
+16 -16
View File
@@ -210,14 +210,14 @@ void iterate_surfaces_visual(s32 x, s32 z, Vtx *verts) {
for (i = 0; i < (2 * NUM_SPATIAL_PARTITIONS); i++) {
switch (i) {
case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_GREEN ); break;
case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_GREEN ); break;
case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_BLUE ); break;
case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_BLUE ); break;
case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_RED ); break;
case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_RED ); break;
case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_YELLOW); break;
case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; colorRGB_copy(col, (ColorRGB)COLOR_RGB_YELLOW); break;
case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ]; colorRGB_copy(col, (ColorRGB)COLOR_RGB_GREEN ); break;
case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ]; colorRGB_copy(col, (ColorRGB)COLOR_RGB_GREEN ); break;
case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS]; colorRGB_copy(col, (ColorRGB)COLOR_RGB_BLUE ); break;
case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS]; colorRGB_copy(col, (ColorRGB)COLOR_RGB_BLUE ); break;
case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ]; colorRGB_copy(col, (ColorRGB)COLOR_RGB_RED ); break;
case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ]; colorRGB_copy(col, (ColorRGB)COLOR_RGB_RED ); break;
case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ]; colorRGB_copy(col, (ColorRGB)COLOR_RGB_YELLOW); break;
case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ]; colorRGB_copy(col, (ColorRGB)COLOR_RGB_YELLOW); break;
}
while (node != NULL) {
@@ -318,14 +318,14 @@ s32 iterate_surface_count(s32 x, s32 z) {
for (i = 0; i < (2 * NUM_SPATIAL_PARTITIONS); i++) {
switch (i) {
case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; break;
case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; break;
case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; break;
case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; break;
case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; break;
case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; break;
case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; break;
case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; break;
case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ]; break;
case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ]; break;
case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS]; break;
case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS]; break;
case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ]; break;
case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ]; break;
case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ]; break;
case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ]; break;
}
while (node != NULL) {
+48 -17
View File
@@ -31,6 +31,7 @@
#include "puppycam2.h"
#include "puppyprint.h"
#include "level_commands.h"
#include "debug.h"
#include "config.h"
@@ -200,7 +201,7 @@ void set_play_mode(s16 playMode) {
}
void warp_special(s32 arg) {
sCurrPlayMode = PLAY_MODE_CHANGE_LEVEL;
set_play_mode(PLAY_MODE_CHANGE_LEVEL);
sSpecialWarpDest = arg;
}
@@ -348,16 +349,24 @@ void set_mario_initial_action(struct MarioState *m, u32 spawnType, u32 actionArg
}
void init_mario_after_warp(void) {
struct ObjectWarpNode *spawnNode = area_get_warp_node(sWarpDest.nodeId);
u32 marioSpawnType = get_mario_spawn_type(spawnNode->object);
struct Object *object = get_destination_warp_object(sWarpDest.nodeId);
#ifdef DEBUG_ASSERTIONS
if (!object) {
char errorMsg[40];
sprintf(errorMsg, "No dest warp object found for: 0x%02X", sWarpDest.nodeId);
error(errorMsg);
}
#endif
u32 marioSpawnType = get_mario_spawn_type(object);
if (gMarioState->action != ACT_UNINITIALIZED) {
gPlayerSpawnInfos[0].startPos[0] = (s16) spawnNode->object->oPosX;
gPlayerSpawnInfos[0].startPos[1] = (s16) spawnNode->object->oPosY;
gPlayerSpawnInfos[0].startPos[2] = (s16) spawnNode->object->oPosZ;
gPlayerSpawnInfos[0].startPos[0] = (s16) object->oPosX;
gPlayerSpawnInfos[0].startPos[1] = (s16) object->oPosY;
gPlayerSpawnInfos[0].startPos[2] = (s16) object->oPosZ;
gPlayerSpawnInfos[0].startAngle[0] = 0;
gPlayerSpawnInfos[0].startAngle[1] = spawnNode->object->oMoveAngleYaw;
gPlayerSpawnInfos[0].startAngle[1] = object->oMoveAngleYaw;
gPlayerSpawnInfos[0].startAngle[2] = 0;
if (marioSpawnType == MARIO_SPAWN_DOOR_WARP) {
@@ -372,8 +381,8 @@ void init_mario_after_warp(void) {
init_mario();
set_mario_initial_action(gMarioState, marioSpawnType, sWarpDest.arg);
gMarioState->interactObj = spawnNode->object;
gMarioState->usedObj = spawnNode->object;
gMarioState->interactObj = object;
gMarioState->usedObj = object;
}
reset_camera(gCurrentArea->camera);
@@ -569,6 +578,15 @@ void check_instant_warp(void) {
s16 music_unchanged_through_warp(s16 arg) {
struct ObjectWarpNode *warpNode = area_get_warp_node(arg);
#ifdef DEBUG_ASSERTIONS
if (!warpNode) {
char errorMsg[40];
sprintf(errorMsg, "No source warp node found for: 0x%02X", (u8) arg);
error(errorMsg);
}
#endif
s16 levelNum = warpNode->node.destLevel & 0x7F;
s16 destArea = warpNode->node.destArea;
@@ -896,6 +914,14 @@ void initiate_delayed_warp(void) {
default:
warpNode = area_get_warp_node(sSourceWarpNodeId);
#ifdef DEBUG_ASSERTIONS
if (!warpNode) {
char errorMsg[40];
sprintf(errorMsg, "No source warp node found for: 0x%02X", (u8) sSourceWarpNodeId);
error(errorMsg);
}
#endif
initiate_warp(warpNode->node.destLevel & 0x7F, warpNode->node.destArea,
warpNode->node.destNode, sDelayedWarpArg);
@@ -1062,19 +1088,24 @@ s32 play_mode_paused(void) {
fade_into_special_warp(WARP_SPECIAL_LEVEL_SELECT, 1);
} else {
#ifdef DEATH_ON_EXIT_COURSE
raise_background_noise(1);
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
set_play_mode(PLAY_MODE_NORMAL);
level_trigger_warp(gMarioState, WARP_OP_DEATH);
#else
struct ObjectWarpNode *warpNode = area_get_warp_node(WARP_NODE_DEATH);
assert(warpNode != NULL, "No death warp node could be found!");
initiate_warp(warpNode->node.destLevel & 0x7F, warpNode->node.destArea,
warpNode->node.destNode, WARP_FLAGS_NONE);
#else // DEATH_ON_EXIT_COURSE
initiate_warp(EXIT_COURSE_LEVEL, EXIT_COURSE_AREA, EXIT_COURSE_NODE, WARP_FLAG_EXIT_COURSE);
fade_into_special_warp(WARP_SPECIAL_NONE, 0);
gSavedCourseNum = COURSE_NONE;
#endif
#endif // DEATH_ON_EXIT_COURSE
fade_into_special_warp(WARP_SPECIAL_NONE, 0);
if (sWarpDest.type != WARP_TYPE_CHANGE_LEVEL) {
set_play_mode(PLAY_MODE_CHANGE_AREA);
}
}
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
#endif
#endif // DISABLE_EXIT_COURSE
}
return FALSE;
-9
View File
@@ -429,15 +429,6 @@ u32 common_air_action_step(struct MarioState *m, u32 landAction, s32 animation,
}
s32 act_jump(struct MarioState *m) {
#ifdef EASIER_LONG_JUMPS
if (m->actionTimer < 1) {
m->actionTimer++;
if (m->input & INPUT_Z_PRESSED && m->forwardVel > 10.0f) {
return set_jumping_action(m, ACT_LONG_JUMP, 0);
}
}
#endif
if (check_kick_or_dive_in_air(m)) {
return TRUE;
}
+4
View File
@@ -518,6 +518,10 @@ s32 act_debug_free_move(struct MarioState *m) {
struct Surface *floor, *ceil;
Vec3f pos;
if (gPlayer1Controller->buttonPressed & L_TRIG) {
m->health = 0x880;
}
f32 speed = (gPlayer1Controller->buttonDown & B_BUTTON) ? 4.0f : 1.0f;
if (gPlayer1Controller->buttonDown & Z_TRIG) speed = 0.01f;
if (m->area->camera->mode != CAMERA_MODE_8_DIRECTIONS) set_camera_mode(m->area->camera, CAMERA_MODE_8_DIRECTIONS, 1);
+5
View File
@@ -766,6 +766,11 @@ s32 act_walking(struct MarioState *m) {
}
if (m->input & INPUT_A_PRESSED) {
#ifdef EASIER_LONG_JUMPS
if (m->input & INPUT_Z_PRESSED && m->forwardVel > 10.0f) {
return set_mario_action(m, ACT_CROUCH_SLIDE, 0);
}
#endif
return set_jump_from_landing(m);
}
+50 -169
View File
@@ -10,10 +10,13 @@
#include "types.h"
#include "sm64.h"
#include "behavior_data.h"
#include "game_init.h"
#include "config.h"
struct Object *gMarioPlatform = NULL;
static struct PlatformDisplacementInfo sMarioDisplacementInfo;
static Vec3f sMarioAmountDisplaced;
/**
* Determine if Mario is standing on a platform object, meaning that he is
@@ -48,6 +51,11 @@ void update_mario_platform(void) {
if (floor != NULL && floor->object != NULL) {
gMarioPlatform = floor->object;
gMarioObject->platform = floor->object;
// If this is the first frame of Mario standing on the platform,
// then initialise his platform displacement info struct
if ((floor->object != sMarioDisplacementInfo.prevPlatform) || (gGlobalTimer != sMarioDisplacementInfo.prevTimer)) {
update_platform_displacement_info(&sMarioDisplacementInfo, gMarioState->pos, gMarioState->faceAngle[1], floor->object);
}
} else {
gMarioPlatform = NULL;
gMarioObject->platform = NULL;
@@ -56,42 +64,28 @@ void update_mario_platform(void) {
}
/**
* Get Mario's position and store it in x, y, and z.
* Set the values in the platform displacement struct for use next frame
*/
void get_mario_pos(f32 *x, f32 *y, f32 *z) {
*x = gMarioStates[0].pos[0];
*y = gMarioStates[0].pos[1];
*z = gMarioStates[0].pos[2];
}
void update_platform_displacement_info(struct PlatformDisplacementInfo *displaceInfo, Vec3f pos, s16 yaw, struct Object *platform) {
Vec3f scaledPos, yawVec, localPos;
/**
* Set Mario's position.
*/
void set_mario_pos(f32 x, f32 y, f32 z) {
gMarioStates[0].pos[0] = x;
gMarioStates[0].pos[1] = y;
gMarioStates[0].pos[2] = z;
}
// Avoid a crash if the platform unloaded its collision while stood on or is static
if (platform->header.gfx.throwMatrix == NULL) return;
#ifdef PLATFORM_DISPLACEMENT_2
static struct PlatformDisplacementInfo sMarioDisplacementInfo;
static Vec3f sMarioAmountDisplaced;
// Update position
vec3_diff(localPos, pos, (*platform->header.gfx.throwMatrix)[3]);
linear_mtxf_transpose_mul_vec3(*platform->header.gfx.throwMatrix, scaledPos, localPos);
vec3_quot(displaceInfo->prevTransformedPos, scaledPos, platform->header.gfx.scale);
vec3_copy(displaceInfo->prevPos, pos);
extern s32 gGlobalTimer;
// Update yaw
vec3_set(yawVec, sins(yaw), 0, coss(yaw));
linear_mtxf_transpose_mul_vec3(*platform->header.gfx.throwMatrix, displaceInfo->prevTransformedYawVec, yawVec);
displaceInfo->prevYaw = yaw;
/**
* Upscale or downscale a vector by another vector.
*/
static void scale_vec3f(Vec3f dst, Vec3f src, Vec3f scale, u32 doInverted) {
if (doInverted) {
dst[0] = src[0] / scale[0];
dst[1] = src[1] / scale[1];
dst[2] = src[2] / scale[2];
} else {
dst[0] = src[0] * scale[0];
dst[1] = src[1] * scale[1];
dst[2] = src[2] * scale[2];
}
// Update platform and timer
displaceInfo->prevPlatform = platform;
displaceInfo->prevTimer = gGlobalTimer;
}
/**
@@ -99,74 +93,48 @@ static void scale_vec3f(Vec3f dst, Vec3f src, Vec3f scale, u32 doInverted) {
* platform.
*/
void apply_platform_displacement(struct PlatformDisplacementInfo *displaceInfo, Vec3f pos, s16 *yaw, struct Object *platform) {
Vec3f platformPos;
Vec3f posDifference;
Vec3f yawVec;
Vec3f scaledPos;
// Determine how much Mario turned on his own since last frame
s16 yawDifference = *yaw - displaceInfo->prevYaw;
// Avoid a crash if the platform unloaded its collision while stood on
// Avoid a crash if the platform unloaded its collision while stood on or is static
if (platform->header.gfx.throwMatrix == NULL) return;
vec3f_copy(platformPos, (*platform->header.gfx.throwMatrix)[3]);
// Determine how far Mario moved on his own since last frame
vec3f_copy(posDifference, pos);
vec3f_sub(posDifference, displaceInfo->prevPos);
vec3_diff(posDifference, pos, displaceInfo->prevPos);
if ((platform == displaceInfo->prevPlatform) && (gGlobalTimer == displaceInfo->prevTimer + 1)) {
// Transform from relative positions to world positions
scale_vec3f(scaledPos, displaceInfo->prevTransformedPos, platform->header.gfx.scale, FALSE);
linear_mtxf_mul_vec3f(*platform->header.gfx.throwMatrix, pos, scaledPos);
// For certain objects, only use velocity for displacement rather than the transform
// E.g. TTC treadmills
if (platform->oFlags & OBJ_FLAG_NO_AUTO_DISPLACEMENT) {
pos[0] += platform->oVelX;
pos[1] += platform->oVelY;
pos[2] += platform->oVelZ;
} else {
// Transform from relative positions to world positions
vec3_prod(scaledPos, displaceInfo->prevTransformedPos, platform->header.gfx.scale);
linear_mtxf_mul_vec3(*platform->header.gfx.throwMatrix, pos, scaledPos);
vec3_add(pos, (*platform->header.gfx.throwMatrix)[3]);
// Add on how much Mario moved in the previous frame
vec3f_add(pos, posDifference);
// Add on how much Mario moved in the previous frame
vec3_add(pos, posDifference);
// Calculate new yaw
linear_mtxf_mul_vec3f(*platform->header.gfx.throwMatrix, yawVec, displaceInfo->prevTransformedYawVec);
*yaw = atan2s(yawVec[2], yawVec[0]) + yawDifference;
} else {
// First frame of standing on the platform, don't calculate a new position
vec3f_sub(pos, platformPos);
}
// Apply velocity-based displacement for certain objects (like the TTC Treadmills)
if (platform->oFlags & OBJ_FLAG_VELOCITY_PLATFORM) {
pos[0] += platform->oVelX;
pos[1] += platform->oVelY;
pos[2] += platform->oVelZ;
}
// Transform from world positions to relative positions for use next frame
linear_mtxf_transpose_mul_vec3f(*platform->header.gfx.throwMatrix, scaledPos, pos);
scale_vec3f(displaceInfo->prevTransformedPos, scaledPos, platform->header.gfx.scale, TRUE);
vec3f_add(pos, platformPos);
// If the object is Mario, set inertia
if (pos == gMarioState->pos) {
vec3f_copy(sMarioAmountDisplaced, pos);
vec3f_sub(sMarioAmountDisplaced, displaceInfo->prevPos);
vec3f_sub(sMarioAmountDisplaced, posDifference);
// Make sure inertia isn't set on the first frame otherwise the previous value isn't cleared
if ((platform != displaceInfo->prevPlatform) || (gGlobalTimer != displaceInfo->prevTimer + 1)) {
vec3_zero(sMarioAmountDisplaced);
// Calculate new yaw
linear_mtxf_mul_vec3(*platform->header.gfx.throwMatrix, yawVec, displaceInfo->prevTransformedYawVec);
*yaw = atan2s(yawVec[2], yawVec[0]) + yawDifference;
}
}
// Update info for next frame
// Update position
vec3f_copy(displaceInfo->prevPos, pos);
Vec3f oldPos;
vec3_sum(oldPos, displaceInfo->prevPos, posDifference);
update_platform_displacement_info(displaceInfo, pos, *yaw, platform);
// Set yaw info
vec3f_set(yawVec, sins(*yaw), 0, coss(*yaw));
linear_mtxf_transpose_mul_vec3f(*platform->header.gfx.throwMatrix, displaceInfo->prevTransformedYawVec, yawVec);
displaceInfo->prevYaw = *yaw;
// Update platform and timer
displaceInfo->prevPlatform = platform;
displaceInfo->prevTimer = gGlobalTimer;
// If the object is Mario, set inertia
if (pos == gMarioState->pos) {
vec3_diff(sMarioAmountDisplaced, pos, oldPos);
}
}
// Doesn't change in the code, set this to FALSE if you don't want inertia
@@ -223,93 +191,6 @@ void apply_mario_platform_displacement(void) {
}
}
#else
/**
* Apply one frame of platform rotation to Mario or an object using the given
* platform. If isMario is false, use gCurrentObject.
*/
void apply_platform_displacement(u32 isMario, struct Object *platform) {
f32 x, y, z;
f32 platformPosX, platformPosY, platformPosZ;
Vec3f currentObjectOffset;
Vec3f relativeOffset;
Vec3f newObjectOffset;
Vec3s rotation;
Mat4 displaceMatrix;
rotation[0] = platform->oAngleVelPitch;
rotation[1] = platform->oAngleVelYaw;
rotation[2] = platform->oAngleVelRoll;
if (isMario) {
get_mario_pos(&x, &y, &z);
} else {
x = gCurrentObject->oPosX;
y = gCurrentObject->oPosY;
z = gCurrentObject->oPosZ;
}
x += platform->oVelX;
z += platform->oVelZ;
if (rotation[0] != 0 || rotation[1] != 0 || rotation[2] != 0) {
// unusedPitch = rotation[0];
// unusedRoll = rotation[2];
// unusedYaw = platform->oFaceAngleYaw;
if (isMario) {
gMarioStates[0].faceAngle[1] += rotation[1];
}
platformPosX = platform->oPosX;
platformPosY = platform->oPosY;
platformPosZ = platform->oPosZ;
currentObjectOffset[0] = x - platformPosX;
currentObjectOffset[1] = y - platformPosY;
currentObjectOffset[2] = z - platformPosZ;
rotation[0] = platform->oFaceAnglePitch - platform->oAngleVelPitch;
rotation[1] = platform->oFaceAngleYaw - platform->oAngleVelYaw;
rotation[2] = platform->oFaceAngleRoll - platform->oAngleVelRoll;
mtxf_rotate_zxy_and_translate(displaceMatrix, currentObjectOffset, rotation);
linear_mtxf_transpose_mul_vec3f(displaceMatrix, relativeOffset, currentObjectOffset);
rotation[0] = platform->oFaceAnglePitch;
rotation[1] = platform->oFaceAngleYaw;
rotation[2] = platform->oFaceAngleRoll;
mtxf_rotate_zxy_and_translate(displaceMatrix, currentObjectOffset, rotation);
linear_mtxf_mul_vec3f(displaceMatrix, newObjectOffset, relativeOffset);
x = platformPosX + newObjectOffset[0];
y = platformPosY + newObjectOffset[1];
z = platformPosZ + newObjectOffset[2];
}
if (isMario) {
set_mario_pos(x, y, z);
} else {
gCurrentObject->oPosX = x;
gCurrentObject->oPosY = y;
gCurrentObject->oPosZ = z;
}
}
/**
* If Mario's platform is not null, apply platform displacement.
*/
void apply_mario_platform_displacement(void) {
struct Object *platform = gMarioPlatform;
if (!(gTimeStopState & TIME_STOP_ACTIVE) && gMarioObject != NULL && platform != NULL) {
apply_platform_displacement(TRUE, platform);
}
}
#endif
/**
* Set Mario's platform to NULL.
*/
+11 -16
View File
@@ -6,24 +6,19 @@
#include "types.h"
#include "config.h"
#ifdef PLATFORM_DISPLACEMENT_2
struct PlatformDisplacementInfo {
Vec3f prevPos;
Vec3f prevTransformedPos;
Vec3f prevTransformedYawVec;
s16 prevYaw;
struct Object *prevPlatform;
s32 prevTimer;
};
#endif
struct PlatformDisplacementInfo {
Vec3f prevPos;
Vec3f prevTransformedPos;
Vec3f prevTransformedYawVec;
s16 prevYaw;
struct Object *prevPlatform;
u32 prevTimer;
};
void update_mario_platform(void);
void get_mario_pos(f32 *x, f32 *y, f32 *z);
void set_mario_pos(f32 x, f32 y, f32 z);
#ifdef PLATFORM_DISPLACEMENT_2
void update_platform_displacement_info(struct PlatformDisplacementInfo *displaceInfo, Vec3f pos, s16 yaw, struct Object *platform);
void apply_platform_displacement(struct PlatformDisplacementInfo *displaceInfo, Vec3f pos, s16 *yaw, struct Object *platform);
#else
void apply_platform_displacement(u32 isMario, struct Object *platform);
#endif
void apply_mario_platform_displacement(void);
void clear_mario_platform(void);
+2 -2
View File
@@ -1018,7 +1018,7 @@ static s32 puppycam_check_volume_bounds(struct sPuppyVolume *volume, s32 index)
vec3f_set(debugPos[0], sPuppyVolumeStack[index]->pos[0], sPuppyVolumeStack[index]->pos[1], sPuppyVolumeStack[index]->pos[2]);
vec3f_set(debugPos[1], sPuppyVolumeStack[index]->radius[0], sPuppyVolumeStack[index]->radius[1], sPuppyVolumeStack[index]->radius[2]);
debug_box_color(0x00FF0000);
debug_box_rot(debugPos[0], debugPos[1], sPuppyVolumeStack[index]->rot, DEBUG_SHAPE_BOX | DEBUG_UCODE_DEFAULT);
debug_box_rot(debugPos[0], debugPos[1], sPuppyVolumeStack[index]->rot, DEBUG_SHAPE_BOX);
#endif
// Now compare values.
if (-sPuppyVolumeStack[index]->radius[0] < pos[0] && pos[0] < sPuppyVolumeStack[index]->radius[0] &&
@@ -1036,7 +1036,7 @@ static s32 puppycam_check_volume_bounds(struct sPuppyVolume *volume, s32 index)
vec3f_set(debugPos[0], sPuppyVolumeStack[index]->pos[0], sPuppyVolumeStack[index]->pos[1], sPuppyVolumeStack[index]->pos[2]);
vec3f_set(debugPos[1], sPuppyVolumeStack[index]->radius[0], sPuppyVolumeStack[index]->radius[1], sPuppyVolumeStack[index]->radius[2]);
debug_box_color(0x00FF0000);
debug_box_rot(debugPos[0], debugPos[1], sPuppyVolumeStack[index]->rot, DEBUG_SHAPE_CYLINDER | DEBUG_UCODE_DEFAULT);
debug_box_rot(debugPos[0], debugPos[1], sPuppyVolumeStack[index]->rot, DEBUG_SHAPE_CYLINDER);
#endif
f32 distCheck = (dist < sqr(sPuppyVolumeStack[index]->radius[0]));
+7 -2
View File
@@ -3,6 +3,7 @@
#include "area.h"
#include "audio/external.h"
#include "audio/load.h"
#include "audio/synthesis.h"
#include "engine/graph_node.h"
#include "engine/math_util.h"
#include "level_table.h"
@@ -220,7 +221,7 @@ void play_infinite_stairs_music(void) {
if (shouldPlay) {
play_secondary_music(SEQ_EVENT_ENDLESS_STAIRS, 0, 255, 1000);
} else {
func_80321080(500);
stop_secondary_music(500);
}
}
#endif
@@ -230,7 +231,11 @@ void play_infinite_stairs_music(void) {
* Called from threads: thread5_game_loop
*/
void set_background_music(u16 a, u16 seqArgs, s16 fadeTimer) {
if (gResetTimer == 0 && seqArgs != sCurrentMusic) {
if (gResetTimer == 0 && (seqArgs != sCurrentMusic
#ifdef BETTER_REVERB
|| gBetterReverbPresetValue != activeBetterReverbPreset
#endif
)) {
if (gCurrCreditsEntry != NULL) {
sound_reset(7);
} else {
+1 -30
View File
@@ -109,30 +109,6 @@ public:
#define flipsversion "Floating IPS"
#if defined(FLIPS_WINDOWS)
#define UNICODE
#define _WIN32_WINNT 0x0501
#define _WIN32_IE 0x0600
#define NOMINMAX // this seems automatically on in C++ - crazy.
#ifdef __MINGW32__
#include <stdlib.h>
#undef __USE_MINGW_ANSI_STDIO // must remove this, to avoid a libgcc_s_sjlj-1.dll dependency on 32bit
#endif // comments say libstdc++ demands a POSIX printf, but I'm not using that, so I don't care
#include <windows.h>
#include <windowsx.h>
#include <shlobj.h>
#include <wchar.h>
#include <stdio.h>
#include <commctrl.h>
#include <ctype.h>
#define wcsicmp _wcsicmp // wcsicmp deprecated? okay, have a define
#define wcsdup _wcsdup
#define wtoi _wtoi
#else
#include <string.h>
#include <strings.h>
#include <stdlib.h>
@@ -190,7 +166,6 @@ static inline char* strdup(const char * in)
memcpy(ret, in, len+1);
return ret;
}
#endif
#ifndef __cplusplus
@@ -341,11 +316,7 @@ void bpsdeltaEnd();
int GUIShow(LPCWSTR filename);
void GUILoadConfig();
//LPCWSTR GUIGetFileFor(uint32_t crc32); // use FindRomForPatch instead
#ifdef FLIPS_WINDOWS
void GUIClaimConsole();
#else
#define GUIClaimConsole() // all other platforms have consoles already
#endif
#define GUIClaimConsole()
//the OS port is responsible for main()
//Module name: crc32
+27 -8
View File
@@ -10,6 +10,14 @@ LDFLAGS := -lm
ALL_PROGRAMS := armips filesizer rncpack n64graphics n64graphics_ci mio0 slienc n64cksum textconv aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv flips
LIBAUDIOFILE := audiofile/libaudiofile.a
ifeq ($(OS),Windows_NT)
EXT := .exe
OUTPUTS := $(ALL_PROGRAMS:=.exe)
else
EXT :=
OUTPUTS := $(ALL_PROGRAMS)
endif
# Only build armips from tools if it is not found on the system
ifeq ($(call find-command,armips),)
BUILD_PROGRAMS := $(ALL_PROGRAMS)
@@ -41,9 +49,12 @@ textconv_SOURCES := textconv.c utf8.c hashtable.c
aifc_decode_SOURCES := aifc_decode.c
aiff_extract_codebook_SOURCES := aiff_extract_codebook.c
aiff_extract_codebook: $(LIBAUDIOFILE)
aiff_extract_codebook_SOURCES := aiff_extract_codebook.c sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c
aiff_extract_codebook_CFLAGS := -DEXTRACT_CODEBOOK -Iaudiofile -Wno-uninitialized
aiff_extract_codebook_LDFLAGS := -Laudiofile -laudiofile -lstdc++
tabledesign: $(LIBAUDIOFILE)
tabledesign$(EXT): $(LIBAUDIOFILE)
tabledesign_SOURCES := sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c
tabledesign_CFLAGS := -Iaudiofile -Wno-uninitialized
tabledesign_LDFLAGS := -Laudiofile -laudiofile -lstdc++
@@ -56,22 +67,30 @@ extract_data_for_mio_SOURCES := extract_data_for_mio.c
skyconv_SOURCES := skyconv.c n64graphics.c utils.c
skyconv_CFLAGS := -g -I../include
armips: CC := $(CXX)
armips$(EXT): CC := $(CXX)
armips_SOURCES := armips.cpp
armips_CFLAGS := -std=c++11 -fno-exceptions -fno-rtti -pipe
armips_CFLAGS := -std=gnu++11 -fno-exceptions -fno-rtti -pipe
armips_LDFLAGS := -pthread
ifeq ($(HOST_ENV),MinGW)
armips_LDFLAGS += -municode
endif
flips: CC := $(CXX)
flips$(EXT): CC := $(CXX)
flips_SOURCES := FlipsSrc/Flips.cpp
ifeq ($(OS),Windows_NT)
flips_CFLAGS := -Wall -Wextra -fopenmp -Os -flto -fuse-linker-plugin -fomit-frame-pointer -fmerge-all-constants \
-fvisibility=hidden -fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables \
-ffunction-sections -fdata-sections -Wl,--gc-sections
else
flips_CFLAGS := -Wall -Wextra -fopenmp -Os -flto -fuse-linker-plugin -fomit-frame-pointer -fmerge-all-constants \
-fvisibility=hidden -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables \
-ffunction-sections -fdata-sections -Wl,--gc-sections \
-fvisibility=hidden -fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables \
-ffunction-sections -fdata-sections -Wl,--gc-sections \
-Wl,-z,relro,-z,now,--as-needed,--hash-style=gnu,--relax
endif
all-except-recomp: $(LIBAUDIOFILE) $(BUILD_PROGRAMS)
all-except-recomp: $(LIBAUDIOFILE) $(OUTPUTS)
all: all-except-recomp
@@ -83,8 +102,8 @@ clean:
distclean: clean
define COMPILE
$(1): $($1_SOURCES)
$$(CC) $(CFLAGS) $($1_CFLAGS) $$^ -o $$@ $($1_LDFLAGS) $(LDFLAGS)
$(1)$$(EXT): $($1_SOURCES)
$$(CC) $(CFLAGS) $($1_CFLAGS) $$^ -o $(1) $($1_LDFLAGS) $(LDFLAGS)
endef
$(foreach p,$(BUILD_PROGRAMS),$(eval $(call COMPILE,$(p))))
+27 -7
View File
@@ -9,6 +9,8 @@
#include <stdlib.h>
#include <stdarg.h>
#include "sdk-tools/tabledesign/tabledesign.h"
typedef short s16;
typedef int s32;
typedef unsigned char u8;
@@ -28,8 +30,9 @@ typedef struct
s16 state[16];
} ALADPCMloop;
static const char usage[] = "input.aiff";
static const char *progname, *infilename;
static const char usage[] = "input.aiff, output.table";
static const char *progname;
static char *infilename, *outfilename;
#define checked_fread(a, b, c, d) if (fread(a, b, c, d) != c) fail_parse("error parsing file")
@@ -115,12 +118,13 @@ int main(int argc, char **argv)
FILE *ifile;
progname = argv[0];
if (argc < 2) {
if (argc < 3) {
fprintf(stderr, "%s %s\n", progname, usage);
exit(1);
}
infilename = argv[1];
outfilename = argv[2];
if ((ifile = fopen(infilename, "rb")) == NULL) {
fail_parse("AIFF file could not be opened");
@@ -168,17 +172,33 @@ int main(int argc, char **argv)
fclose(ifile);
if (coefTable == NULL) {
execl("./tools/tabledesign", "tabledesign", "-s", "1", infilename, NULL);
char* arguments[] = {
"tabledesign",
"-s",
"1",
"-p",
outfilename,
infilename
};
return tabledesign_entry(6, arguments);
} else {
printf("%d\n%d\n", order, npredictors);
FILE *fp;
if ((fp = fopen(outfilename, "w")) == NULL) {
fprintf(stderr, "%s: could not write to file: %s", progname, outfilename);
exit(1);
}
fprintf(fp, "%d\n%d\n", order, npredictors);
for (s32 i = 0; i < npredictors; i++) {
for (s32 j = 0; j < order; j++) {
for (s32 k = 0; k < 8; k++) {
printf("% 5d ", coefTable[i][k][j]);
fprintf(fp, "% 5d ", coefTable[i][k][j]);
}
puts("");
fprintf(fp, "\n");
}
}
fclose(fp);
}
return 0;
}
+3 -8
View File
@@ -15496,7 +15496,7 @@ int64_t fileSize(const std::wstring& fileName)
{
#ifdef _WIN32
WIN32_FILE_ATTRIBUTE_DATA attr;
if (!GetFileAttributesEx(fileName.c_str(),GetFileExInfoStandard,&attr)
if (!GetFileAttributesExW(fileName.c_str(),GetFileExInfoStandard,&attr)
|| (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
return 0;
return ((int64_t) attr.nFileSizeHigh << 32) | (int64_t) attr.nFileSizeLow;
@@ -15514,10 +15514,10 @@ bool fileExists(const std::wstring& strFilename)
{
#ifdef _WIN32
#ifdef ARMIPS_WINDOWS_UWP
return GetFileAttributes(strFilename.c_str()) != INVALID_FILE_ATTRIBUTES;
return GetFileAttributesW(strFilename.c_str()) != INVALID_FILE_ATTRIBUTES;
#else
int OldMode = SetErrorMode(SEM_FAILCRITICALERRORS);
bool success = GetFileAttributes(strFilename.c_str()) != INVALID_FILE_ATTRIBUTES;
bool success = GetFileAttributesW(strFilename.c_str()) != INVALID_FILE_ATTRIBUTES;
SetErrorMode(OldMode);
return success;
#endif
@@ -19877,8 +19877,6 @@ int wmain(int argc, wchar_t* argv[])
return runFromCommandLine(arguments);
}
#ifndef _WIN32
int main(int argc, char* argv[])
{
// convert input to wstring
@@ -19901,6 +19899,3 @@ int main(int argc, char* argv[])
delete[] wargv;
return result;
}
#endif
+17 -3
View File
@@ -66,7 +66,7 @@ def validate(cond, msg, forstr=""):
def strip_comments(string):
string = re.sub(re.compile("/\*.*?\*/", re.DOTALL), "", string)
string = re.sub(re.compile(r"/\*.*?\*/", re.DOTALL), "", string)
return re.sub(re.compile("//.*?\n"), "", string)
@@ -781,10 +781,15 @@ def write_sequences(
defines,
is_shindou,
):
bank_names = sorted(
[os.path.splitext(os.path.basename(x))[0] for x in os.listdir(sound_bank_dir)]
bank_names = []
banks = sorted(
[os.path.basename(x) for x in os.listdir(sound_bank_dir)]
)
for x in banks:
if x.endswith(".json"):
bank_names.append(os.path.splitext(x)[0])
try:
with open(seq_json, "r") as inf:
data = inf.read()
@@ -842,6 +847,15 @@ def write_sequences(
while ind_to_name and json.get(ind_to_name[-1]) is None:
ind_to_name.pop()
if ind_to_name:
for x in range(len(ind_to_name)):
if ind_to_name[x] is None:
fail(
"Sequence file index jump detected. "
+ "Please make sure your sequence files are labeled correctly "
+ "in incremental hexadecimal order."
)
def serialize_file(name, ser, is_shindou):
if json.get(name) is None:
return
+17 -6
View File
@@ -3552,6 +3552,17 @@ struct IntTypes<kInt24> { typedef int32_t SignedType; typedef uint32_t UnsignedT
template <>
struct IntTypes<kInt32> { typedef int32_t SignedType; typedef uint32_t UnsignedType; };
namespace compat
{
template<typename Arg, typename R>
class unary_function
{
public:
using argument_type = Arg;
using result_type = R;
};
}
template <FormatCode Format>
struct signConverter
{
@@ -3562,12 +3573,12 @@ struct signConverter
static const int kMaxSignedValue = (((1 << (kScaleBits - 1)) - 1) << 1) + 1;
static const int kMinSignedValue = -kMaxSignedValue - 1;
struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
struct signedToUnsigned : public compat::unary_function<SignedType, UnsignedType>
{
UnsignedType operator()(SignedType x) { return x - kMinSignedValue; }
};
struct unsignedToSigned : public std::unary_function<SignedType, UnsignedType>
struct unsignedToSigned : public compat::unary_function<SignedType, UnsignedType>
{
SignedType operator()(UnsignedType x) { return x + kMinSignedValue; }
};
@@ -3760,7 +3771,7 @@ private:
};
template <typename Arg, typename Result>
struct intToFloat : public std::unary_function<Arg, Result>
struct intToFloat : public compat::unary_function<Arg, Result>
{
Result operator()(Arg x) const { return x; }
};
@@ -3826,13 +3837,13 @@ private:
};
template <typename Arg, typename Result, unsigned shift>
struct lshift : public std::unary_function<Arg, Result>
struct lshift : public compat::unary_function<Arg, Result>
{
Result operator()(const Arg &x) const { return x << shift; }
};
template <typename Arg, typename Result, unsigned shift>
struct rshift : public std::unary_function<Arg, Result>
struct rshift : public compat::unary_function<Arg, Result>
{
Result operator()(const Arg &x) const { return x >> shift; }
};
@@ -3928,7 +3939,7 @@ private:
};
template <typename Arg, typename Result>
struct floatToFloat : public std::unary_function<Arg, Result>
struct floatToFloat : public compat::unary_function<Arg, Result>
{
Result operator()(Arg x) const { return x; }
};
+14 -1
View File
@@ -1,4 +1,17 @@
#include <byteswap.h>
#ifndef _WIN32
#include <byteswap.h>
#else
#define __bswap_constant_32(x) \
((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
(((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
static __inline unsigned int
__bswap_32 (unsigned int __bsx)
{
return __bswap_constant_32 (__bsx);
}
#endif
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
+27 -12
View File
@@ -1,21 +1,37 @@
#!/usr/bin/python3
import sys, subprocess, re
import sys, subprocess, re, shutil
if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} [folder to search]")
sys.exit()
lightFiles = set()
has_rg = shutil.which("rg") is not None
def make_search_cmd(regex, include = None):
cmd = None
if has_rg:
cmd = f"rg -lF {regex}"
else:
cmd = f"grep -Rl {regex}"
if include:
if has_rg:
cmd += f" -g {include}"
else:
cmd += f" --include {include}"
return cmd
# The original command that was run across the entire repo to convert all assets
# cmds = ("grep -Rl \"gsSPSetLight\" levels actors bin","grep -Rl \"gsSPLight\" levels actors bin","grep -Rl \"Lights1\" levels actors bin")
# Operate on the folder passed as an argument to this program
cmds = [
f"grep -Rl \"gsSPSetLight\" {sys.argv[1]}",
f"grep -Rl \"gsSPLight\" {sys.argv[1]}",
f"grep -Rl \"Lights1\" {sys.argv[1]}"
make_search_cmd(f"\"gsSPSetLight\" {sys.argv[1]}"),
make_search_cmd(f"\"gsSPLight\" {sys.argv[1]}"),
make_search_cmd(f"\"Lights1\" {sys.argv[1]}")
]
for cmd in cmds:
@@ -29,7 +45,7 @@ lightStructs = {}
# FIRST PASS: COLLECT LIGHT STRUCT INFO, REMOVE LIGHT STRUCTS
for file in lightFiles:
changed = False
with open(file, "r") as f:
with open(file, "r", encoding='utf-8') as f:
fileLines = f.readlines()
index = 0
@@ -80,7 +96,7 @@ def index_delta(mat_name, orig_index, delta):
# SECOND PASS - CHANGE LIGHT COMMANDS
for file in lightFiles:
changed = False
with open(file, "r") as f:
with open(file, "r", encoding='utf-8') as f:
fileLines = f.readlines()
index = 0
dl_index = -1
@@ -88,7 +104,7 @@ for file in lightFiles:
curLine = fileLines[index].strip()
dl_index += 1
match_result = re.search("Gfx\s*([A-Za-z_]\w+)\s*\[\s*\w*\s*\]\s*=\s*\{", curLine)
match_result = re.search(r"Gfx\s*([A-Za-z_]\w+)\s*\[\s*\w*\s*\]\s*=\s*\{", curLine)
if match_result is not None and len(match_result.groups()) >= 1:
curDL = match_result.group(1)
dl_index = -1
@@ -135,8 +151,7 @@ for file in lightFiles:
def get_texscroll_files():
mat_grep_commands = []
for mat in material_deltas.keys():
print("grep -Rl \"segmented_to_virtual(" + re.escape(mat) + f"\" {sys.argv[1]}**/texscroll.inc.c")
mat_grep_commands.append("grep -Rl \"segmented_to_virtual(" + re.escape(mat) + f"\" {sys.argv[1]} --include \*texscroll*")
mat_grep_commands.append(make_search_cmd("\"segmented_to_virtual(" + re.escape(mat) + rf"\" {sys.argv[1]}", "\"*texscroll*\""))
texscroll_files = set()
for cmd in mat_grep_commands:
@@ -164,7 +179,7 @@ for file in t_files:
curLine = curLineFull.strip()
if not in_func:
match_result = re.search("void \w+\(\) \{", curLine)
match_result = re.search(r"void \w+\(\) \{", curLine)
in_func = match_result is not None
found_mat_match = False
continue
@@ -174,7 +189,7 @@ for file in t_files:
continue
if not found_mat_match:
match_result = re.search("Gfx \*mat = segmented_to_virtual\((\w*)\)", curLine)
match_result = re.search(r"Gfx \*mat = segmented_to_virtual\((\w*)\)", curLine)
if not match_result:
continue
@@ -184,7 +199,7 @@ for file in t_files:
mat_match = seg_mat
continue
match_result = re.search("shift_\w*\(mat, (\d*),", curLine)
match_result = re.search(r"shift_\w*\(mat, (\d*),", curLine)
if match_result is not None and len(match_result.groups()) >= 1:
sts_index_str = match_result.group(1)
sts_index = int(sts_index_str)
+1
View File
@@ -21,6 +21,7 @@
#define SCALE_3_8(VAL_) ((VAL_) * 0x24)
#define SCALE_8_3(VAL_) ((VAL_) / 0x24)
#define bcopy(s1, s2, n) memcpy((s2), (s1), (n))
typedef struct
{
+8
View File
@@ -11,10 +11,18 @@ int print_entry(FILE *out, double *row, int order)
int overflows;
table = malloc(8 * sizeof(double*));
if (table == NULL) {
fprintf(stderr, "print_entry: could not allocate memory for table\n");
exit(1);
}
for (i = 0; i < 8; i++)
{
table[i] = malloc(order * sizeof(double));
if (table[i] == NULL) {
fprintf(stderr, "print_entry: could not allocate memory for table[%d]\n", i);
exit(1);
}
}
for (i = 0; i < order; i++)
+64 -15
View File
@@ -30,9 +30,21 @@ typedef int SampleFormat;
#endif
char usage[80] = "[-o order -s bits -t thresh -i refine_iter -f frame_size] aifcfile";
#define mallocErr(var, size, msg) \
var = malloc(size); \
if (var == NULL) { \
fprintf(stderr, "%s: malloc failed at %s\n", programName, msg); \
exit(1); \
}
char filename[1024] = "";
char usage[80] = "[-o order -s bits -t thresh -i refine_iter -f frame_size -p filename] aifcfile";
#ifndef EXTRACT_CODEBOOK
int main(int argc, char **argv)
#else
int tabledesign_entry(int argc, char **argv)
#endif
{
const char *programName; // sp118
double thresh; // sp110
@@ -64,6 +76,7 @@ int main(int argc, char **argv)
short *temp_s3;
int i;
int dataSize; // s4
FILE *outfile;
order = 2;
bits = 2;
@@ -79,7 +92,7 @@ int main(int argc, char **argv)
exit(1);
}
while ((opt = getopt(argc, argv, "o:s:t:i:f:")) != -1)
while ((opt = getopt(argc, argv, "o:s:t:i:f:p:")) != -1)
{
switch (opt)
{
@@ -103,9 +116,25 @@ int main(int argc, char **argv)
if (sscanf(optarg, "%lf", &thresh) != 1)
thresh = 10.0;
break;
case 'p':
if (sscanf(optarg, "%s", filename) != 1) {
fprintf(stderr, "%s: No valid out file!\n", programName);
exit(1);
} else {
if ((outfile = fopen(filename, "w")) == NULL) {
fprintf(stderr, "%s: Could not open %s for writing\n", programName, filename);
exit(1);
}
}
break;
}
}
if (outfile == NULL) {
fprintf(stderr, "%s: No out file!\n", programName);
exit(1);
}
argv = &argv[optind - 1];
afFile = AFopenfile(argv[1], MODE_READ, NULL);
@@ -114,6 +143,10 @@ int main(int argc, char **argv)
fprintf(stderr,
"%s: input AIFC file [%s] could not be opened.\n",
programName, argv[1]);
fclose(outfile);
outfile = NULL;
exit(1);
}
@@ -123,6 +156,10 @@ int main(int argc, char **argv)
fprintf(stderr,
"%s: file [%s] contains %d channels, only 1 channel supported.\n",
programName, argv[1], channels);
fclose(outfile);
outfile = NULL;
exit(1);
}
@@ -132,6 +169,10 @@ int main(int argc, char **argv)
fprintf(stderr,
"%s: file [%s] contains %d tracks, only 1 track supported.\n",
programName, argv[1], tracks);
fclose(outfile);
outfile = NULL;
exit(1);
}
@@ -141,34 +182,38 @@ int main(int argc, char **argv)
fprintf(stderr,
"%s: file [%s] contains %d bit samples, only 16 bit samples supported.\n",
programName, argv[1], (int)sampleWidth);
fclose(outfile);
outfile = NULL;
exit(1);
}
temp_s1 = malloc((1 << bits) * sizeof(double*));
mallocErr(temp_s1, (1 << bits) * sizeof(double*), "temp_s1");
for (i = 0; i < (1 << bits); i++)
{
temp_s1[i] = malloc((order + 1) * sizeof(double));
mallocErr(temp_s1[i], (order + 1) * sizeof(double), "temp_si[i]");
}
splitDelta = malloc((order + 1) * sizeof(double));
temp_s3 = malloc(frameSize * 2 * sizeof(short));
mallocErr(splitDelta, (order + 1) * sizeof(double), "splitDelta");
mallocErr(temp_s3, frameSize * 2 * sizeof(short), "temp_s3");
for (i = 0; i < frameSize * 2; i++)
{
temp_s3[i] = 0;
}
vec = malloc((order + 1) * sizeof(double));
spF4 = malloc((order + 1) * sizeof(double));
mat = malloc((order + 1) * sizeof(double*));
mallocErr(vec, (order + 1) * sizeof(double), "vec");
mallocErr(spF4, (order + 1) * sizeof(double), "spF4");
mallocErr(mat, (order + 1) * sizeof(double*), "mat");
for (i = 0; i <= order; i++)
{
mat[i] = malloc((order + 1) * sizeof(double));
mallocErr(mat[i], (order + 1) * sizeof(double), "mat[i]");
}
perm = malloc((order + 1) * sizeof(int));
mallocErr(perm, (order + 1) * sizeof(int), "perm");
frameCount = AFgetframecnt(afFile, AF_DEFAULT_TRACK);
rate = AFgetrate(afFile, AF_DEFAULT_TRACK);
data = malloc(frameCount * sizeof(double*));
mallocErr(data, frameCount * sizeof(double*), "data");
dataSize = 0;
while (AFreadframes(afFile, AF_DEFAULT_TRACK, temp_s3 + frameSize, frameSize) == frameSize)
@@ -183,7 +228,7 @@ int main(int argc, char **argv)
vec[0] = 1.0;
if (kfroma(vec, spF4, order) == 0)
{
data[dataSize] = malloc((order + 1) * sizeof(double));
mallocErr(data[dataSize], (order + 1) * sizeof(double), "data[dataSize]");
data[dataSize][0] = 1.0;
for (i = 1; i <= order; i++)
@@ -247,16 +292,20 @@ int main(int argc, char **argv)
}
npredictors = 1 << curBits;
fprintf(stdout, "%d\n%d\n", order, npredictors);
fprintf(outfile, "%d\n%d\n", order, npredictors);
for (i = 0; i < npredictors; i++)
{
numOverflows += print_entry(stdout, temp_s1[i], order);
numOverflows += print_entry(outfile, temp_s1[i], order);
}
if (numOverflows > 0)
{
fprintf(stderr, "There was overflow - check the table\n");
}
fclose(outfile);
outfile = NULL;
return 0;
}
@@ -27,4 +27,8 @@ void refine(double **table, int order, int npredictors, double **data, int dataS
// print.c
int print_entry(FILE *out, double *row, int order);
#ifdef EXTRACT_CODEBOOK
int tabledesign_entry(int, char**);
#endif
#endif