EU now stable™️

This commit is contained in:
Fazana
2021-09-10 20:39:49 +01:00
parent 3a315de1c3
commit 3562e6ef60
11 changed files with 84 additions and 24 deletions

View File

@@ -9,7 +9,7 @@ extern struct OSMesgQueue OSMesgQueue2;
extern struct OSMesgQueue OSMesgQueue3;
//Since the audio session is just one now, the reverb settings are duplicated to match the original audio setting scenario.
//It's a bit hacky but whatever lol.
//It's a bit hacky but whatever lol. Index range must be defined, since it's needed by the compiler.
#ifdef VERSION_EU
struct ReverbSettingsEU sReverbSettings[8] = {
{/*Downsample Rate*/ 4,/*Window Size*/ 16,/*Gain*/ 0x2FFF },

View File

@@ -2355,7 +2355,8 @@ void play_music(u8 player, u16 seqArgs, u16 fadeTimer) {
}
// Abort if the queue is already full.
if (sBackgroundMusicQueueSize == MAX_BACKGROUND_MUSIC_QUEUE_SIZE) {
if (sBackgroundMusicQueueSize >= MAX_BACKGROUND_MUSIC_QUEUE_SIZE) {
append_puppyprint_log("Sequence queue full, aborting.");
return;
}

View File

@@ -190,13 +190,9 @@ void reset_bank_and_seq_load_status(void) {
}
}
#else
for (i = 0; i < 64; i++) {
gBankLoadStatus[i] = SOUND_LOAD_STATUS_NOT_LOADED;
}
bzero(&gBankLoadStatus, sizeof(gBankLoadStatus)); //Setting this array to zero is equivilent to SOUND_LOAD_STATUS_NOT_LOADED
bzero(&gSeqLoadStatus, sizeof(gSeqLoadStatus)); //Same dealio
for (i = 0; i < 256; i++) {
gSeqLoadStatus[i] = SOUND_LOAD_STATUS_NOT_LOADED;
}
#endif
}
@@ -254,6 +250,7 @@ void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
u32 alignedSize = ALIGN16(size);
start = pool->cur;
//append_puppyprint_log("Pool %X %X/%X", &pool, pool->cur - pool->start, pool->size);
if (start + alignedSize <= pool->start + pool->size) {
pool->cur += alignedSize;
for (pos = start; pos < pool->cur; pos++) {
@@ -263,9 +260,7 @@ void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
eu_stubbed_printf_1("Heap OverFlow : Not Allocate %d!\n", size);
return NULL;
}
#ifdef VERSION_SH
pool->numAllocatedEntries++;
#endif
return start;
#else
u8 *start;
@@ -883,7 +878,7 @@ void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id) {
struct PersistentPool *persistent = &arg0->persistent;
for (i = 0; i < persistent->numEntries; i++) {
if (id == persistent->entries[i].id) {
eu_stubbed_printf_2("Cache hit %d at stay %d\n", id, i);
//eu_stubbed_printf_2("Cache hit %d at stay %d\n", id, i);
return persistent->entries[i].ptr;
}
}
@@ -1078,7 +1073,10 @@ void wait_for_audio_frames(s32 frames) {
}
#endif
s32 sAudioFirstBoot = 0;
#define VERSION_EU
u8 sAudioFirstBoot = 0;
//Separate the reverb settings into their own func. Bit unstable currently, so still only runs at boot.
#if defined(VERSION_EU) || defined(VERSION_SH)
void init_reverb_eu(void)
@@ -1101,8 +1099,11 @@ void init_reverb_eu(void)
reverb->downsampleRate = reverbSettings->downsampleRate;
reverb->reverbGain = reverbSettings->gain;
reverb->useReverb = 8;
reverb->ringBuffer.left = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
reverb->ringBuffer.right = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
if (!sAudioFirstBoot)
{
reverb->ringBuffer.left = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
reverb->ringBuffer.right = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
}
reverb->nextRingBufferPos = 0;
reverb->unkC = 0;
reverb->curFrame = 0;
@@ -1131,16 +1132,40 @@ void init_reverb_eu(void)
}
#endif
#if defined(VERSION_JP) || defined(VERSION_US)
void audio_reset_session(struct AudioSessionSettings *preset) {
if (sAudioFirstBoot)
{
gAudioSessionPool.cur = gAudioSessionPool.start;
gSeqAndBankPool.cur = gSeqAndBankPool.start;
gPersistentCommonPool.cur = gPersistentCommonPool.start;
gTemporaryCommonPool.cur = gTemporaryCommonPool.start;
persistent_pool_clear(&gSeqLoadedPool.persistent);
persistent_pool_clear(&gBankLoadedPool.persistent);
persistent_pool_clear(&gUnusedLoadedPool.persistent);
temporary_pool_clear(&gSeqLoadedPool.temporary);
temporary_pool_clear(&gBankLoadedPool.temporary);
temporary_pool_clear(&gUnusedLoadedPool.temporary);
return;
}
#else
void audio_reset_session(void) {
if (sAudioFirstBoot)
{
s32 j;
gAudioSessionPool.cur = gAudioSessionPool.start;
gSeqAndBankPool.cur = gSeqAndBankPool.start;
gPersistentCommonPool.cur = gPersistentCommonPool.start;
gTemporaryCommonPool.cur = gTemporaryCommonPool.start;
persistent_pool_clear(&gSeqLoadedPool.persistent);
persistent_pool_clear(&gBankLoadedPool.persistent);
persistent_pool_clear(&gUnusedLoadedPool.persistent);
temporary_pool_clear(&gSeqLoadedPool.temporary);
temporary_pool_clear(&gBankLoadedPool.temporary);
temporary_pool_clear(&gUnusedLoadedPool.temporary);
init_reverb_eu();
return;
}

View File

@@ -84,11 +84,20 @@
#endif
#endif
#include "game/puppyprint.h"
#ifdef VERSION_EU
#if PUPPYPRINT_DEBUG
#define eu_stubbed_printf_0(msg) append_puppyprint_log(msg)
#define eu_stubbed_printf_1(msg, a) append_puppyprint_log(msg, a)
#define eu_stubbed_printf_2(msg, a, b) append_puppyprint_log(msg, a, b)
#define eu_stubbed_printf_3(msg, a, b, c) append_puppyprint_log(msg, a, b, c)
#else
#define eu_stubbed_printf_0(msg) stubbed_printf(msg)
#define eu_stubbed_printf_1(msg, a) stubbed_printf(msg, a)
#define eu_stubbed_printf_2(msg, a, b) stubbed_printf(msg, a, b)
#define eu_stubbed_printf_3(msg, a, b, c) stubbed_printf(msg, a, b, c)
#endif
#else
#define eu_stubbed_printf_0(msg)
#define eu_stubbed_printf_1(msg, a)

View File

@@ -847,7 +847,7 @@ void preload_sequence(u32 seqId, u8 preloadMask) {
if (preloadMask & PRELOAD_SEQUENCE) {
// @bug should be IS_SEQ_LOAD_COMPLETE
if (IS_BANK_LOAD_COMPLETE(seqId) == TRUE) {
if (IS_SEQ_LOAD_COMPLETE(seqId) == TRUE) {
eu_stubbed_printf_1("SEQ %d ALREADY CACHED\n", seqId);
sequenceData = get_bank_or_seq(&gSeqLoadedPool, 2, seqId);
} else {
@@ -929,7 +929,7 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) {
}
}
eu_stubbed_printf_1("SEQ %d ALREADY CACHED\n", seqId);
eu_stubbed_printf_1("SEQ %d ALREADY CACHED2\n", seqId);
init_sequence_player(player);
seqPlayer->scriptState.depth = 0;
seqPlayer->delay = 0;
@@ -1019,7 +1019,7 @@ void audio_init() {
eu_stubbed_printf_1("AudioHeap is %x\n", gAudioHeapSize);
for (i = 0; i < NUMAIBUFFERS; i++) {
gAiBufferLengths[i] = 0xa0;
gAiBufferLengths[i] = 10;
}
gAudioFrameCount = 0;
@@ -1037,12 +1037,13 @@ void audio_init() {
sound_init_main_pools(gAudioInitPoolSize);
bzero(&gAiBuffers, sizeof(gAiBuffers));
for (i = 0; i < NUMAIBUFFERS; i++) {
gAiBuffers[i] = soundAlloc(&gAudioInitPool, AIBUFFER_LEN);
for (j = 0; j < (s32) (AIBUFFER_LEN / sizeof(s16)); j++) {
/*for (j = 0; j < (s32) (AIBUFFER_LEN / sizeof(s16)); j++) {
gAiBuffers[i][j] = 0;
}
}*/
}
#if defined(VERSION_EU)

View File

@@ -13,6 +13,7 @@
#define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gSequenceChannelNone)
extern struct Note *gNotes;
extern u8 sAudioFirstBoot;
// Music in SM64 is played using 3 players:
// gSequencePlayers[0] is level background music

View File

@@ -45,13 +45,13 @@
/**
* This reverb is a much more natural, ambient implementation over vanilla's, though at the cost of some memory and performance.
* These parameters are here to provide maximum control over the usage of the reverb effect, as well as with game performance.
*
*
* To take advantage of the reverb effect, you can change the echo parameters set in levels/level_defines.h to tailor the reverb to each specific level area.
* To adjust reverb presence with individual sound effects, apply the .set_reverb command within sound/sequences/00_sound_player.s (see examples of other sounds that use it).
* To use with M64 sequences, set the Effect parameter for each channel accordingly (CC 91 for MIDI files).
*
*
* Most parameter configuration is to be done here, though BETTER_REVERB_SIZE can be adjusted in audio/synthesis.h.
*
*
* If after changing the parameters, you hear increasing noise followed by a sudden disappearance of reverb and/or scratchy audio, this indicates an s16 overflow.
* If this happens, stop immediately and reduce the parameters at fault. This becomes a ticking time bomb, and may eventually result in very loud noise if it reaches the point of s32 overflow.
* Depending on the violating parameters chosen, you probably won't ever experience s32 overflow, but s16 overflow still isn't a pleasant experience.
@@ -299,6 +299,8 @@ u8 audioString1[] = "pitch %x: delaybytes %d : olddelay %d\n";
u8 audioString2[] = "cont %x: delaybytes %d : olddelay %d\n";
#endif
#define VERSION_EU
#ifdef VERSION_EU
// Equivalent functionality as the US/JP version,
// just that the reverb structure is chosen from an array with index

View File

@@ -3,6 +3,8 @@
#include <stdarg.h>
#include <string.h>
#include "buffers/framebuffers.h"
#include "types.h"
#include "puppyprint.h"
#include "sm64.h"
@@ -189,8 +191,13 @@ void draw_crash_screen(OSThread *thread) {
crash_screen_sleep(2000);
crash_screen_draw_rect(25, 20, 270, 25);
crash_screen_print(30, 25, "THREAD:%d (%s)", thread->id, gCauseDesc[cause]);
#if !PUPPYPRINT_DEBUG
crash_screen_print(30, 35, "PC:%08XH SR:%08XH VA:%08XH", tc->pc, tc->sr, tc->badvaddr);
#else
crash_screen_print(30, 35, "PC:%08XH SR:%08XH RA:%08XH", tc->pc, tc->sr, (u32) tc->ra);
#endif
crash_screen_draw_rect(25, 45, 270, 185);
#ifndef PUPPYPRINT
crash_screen_print(30, 50, "AT:%08XH V0:%08XH V1:%08XH", (u32) tc->at, (u32) tc->v0,
(u32) tc->v1);
crash_screen_print(30, 60, "A0:%08XH A1:%08XH A2:%08XH", (u32) tc->a0, (u32) tc->a1,
@@ -211,6 +218,7 @@ void draw_crash_screen(OSThread *thread) {
(u32) tc->sp);
crash_screen_print(30, 140, "S8:%08XH RA:%08XH", (u32) tc->s8, (u32) tc->ra);
crash_screen_print_fpcsr(tc->fpcsr);
osWritebackDCacheAll();
crash_screen_print_float_reg(30, 170, 0, &tc->fp0.f.f_even);
crash_screen_print_float_reg(120, 170, 2, &tc->fp2.f.f_even);
@@ -228,6 +236,13 @@ void draw_crash_screen(OSThread *thread) {
crash_screen_print_float_reg(120, 210, 26, &tc->fp26.f.f_even);
crash_screen_print_float_reg(210, 210, 28, &tc->fp28.f.f_even);
crash_screen_print_float_reg(30, 220, 30, &tc->fp30.f.f_even);
#else
s32 i;
for (i = 0; i < LOG_BUFFER_SIZE; i++)
{
crash_screen_print(30, 50+(10*i), consoleLogTable[i]);
}
#endif
osWritebackDCacheAll();
osViBlack(FALSE);
osViSwapBuffer(gCrashScreen.framebuffer);

View File

@@ -797,6 +797,11 @@ void thread5_game_loop(UNUSED void *arg) {
{
set_background_music(SEQ_LEVEL_SLIDE, SEQUENCE_ARGS(0xFF, SEQ_LEVEL_SLIDE), 30);
}
if (gPlayer1Controller->buttonPressed & R_TRIG)
{
set_background_music(SEQ_LEVEL_GRASS, SEQUENCE_ARGS(0xFF, SEQ_LEVEL_GRASS), 30);
}
// when debug info is enabled, print the "BUF %d" information.
if (gShowDebugText) {

View File

@@ -328,6 +328,9 @@ void append_puppyprint_log(const char *str, ...)
va_end(arguments);
return;
}
#ifdef UNF
osSyncPrintf(textBytes);
#endif
for (i = 0; i < LOG_BUFFER_SIZE-1; i++)
{
memcpy(consoleLogTable[i], consoleLogTable[i+1], 255);

View File

@@ -259,8 +259,6 @@ static void geo_process_perspective(struct GraphNodePerspective *node) {
#else
aspect = 1.33333f;
#endif
if (!gIsConsole)
aspect *= 3.0f;
if (gCamera)
gWorldScale = MAX(((gCamera->pos[0] * gCamera->pos[0]) + (gCamera->pos[1] * gCamera->pos[1]) + (gCamera->pos[2] * gCamera->pos[2]))/67108864, 1.0f);