Merge branch 'master' of https://github.com/Reonu/HackerSM64 into develop/merge-master-2.0.1-into-2.1.0

This commit is contained in:
Arceveti
2022-06-28 12:43:02 -07:00
89 changed files with 3205 additions and 1095 deletions

View File

@@ -343,16 +343,12 @@ 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;
@@ -361,8 +357,7 @@ s32 adsr_update(struct AdsrState *adsr) {
adsr->state = ADSR_STATE_HANG;
break;
}
}
// fallthrough
// fallthrough
case ADSR_STATE_START_LOOP:
adsr->envIndex = 0;
@@ -370,11 +365,12 @@ 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) {
@@ -399,25 +395,23 @@ 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;
}
#if defined(VERSION_SH)
#ifdef 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
#else // !(VERSION_EU || VERSION_SH)
adsr->target = BSWAP16(adsr->envelope[adsr->envIndex].arg);
adsr->velocity = ((adsr->target - adsr->current) << 0x10) / adsr->delay;
#endif
#endif // !(VERSION_EU || VERSION_SH)
adsr->state = ADSR_STATE_FADE;
adsr->envIndex++;
break;

View File

@@ -1271,7 +1271,7 @@ static void update_game_sound(void) {
#endif
} else {
#if defined(VERSION_EU) || defined(VERSION_SH)
func_802ad728((x04020000 | ((channelIndex & 0xff) << 8),
func_802ad728(0x04020000 | ((channelIndex & 0xff) << 8),
get_sound_freq_scale(bank, soundIndex) + ((f32) sSoundMovingSpeed[bank] / 400.0f));
#else
value = get_sound_freq_scale(bank, soundIndex);
@@ -2411,8 +2411,12 @@ void func_803210D4(u16 fadeDuration) {
/**
* Called from threads: thread5_game_loop
*/
void play_course_clear(void) {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_CUTSCENE_COLLECT_STAR, 0);
void play_course_clear(s32 isKey) {
if (isKey) {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_CUTSCENE_COLLECT_KEY, 0);
} else {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_CUTSCENE_COLLECT_STAR, 0);
}
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 0;
#if defined(VERSION_EU) || defined(VERSION_SH)
D_EU_80300558 = 2;

View File

@@ -59,7 +59,7 @@ u32 get_current_background_music(void);
void play_secondary_music(u8 seqId, u8 bgMusicVolume, u8 volume, u16 fadeTimer);
void func_80321080(u16 fadeTimer);
void func_803210D4(u16 fadeOutTime);
void play_course_clear(void);
void play_course_clear(s32 isKey);
void play_peachs_jingle(void);
void play_puzzle_jingle(void);
void play_star_fanfare(void);

View File

@@ -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(gBankLoadStatus));
bzero(&gSeqLoadStatus, sizeof(gSeqLoadStatus));
#else
bzero(&gBankLoadStatus, sizeof(gBankLoadStatus)); // Setting this array to zero is equivilent to SOUND_LOAD_STATUS_NOT_LOADED
bzero(&gSeqLoadStatus, sizeof(gSeqLoadStatus)); // Same dealio
@@ -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;
struct SoundMultiPool *arg0 = NULL;
#define isSound poolIdx
#endif
struct TemporaryPool *tp;
@@ -758,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;
struct SoundMultiPool* loadedPool = NULL;
struct TemporaryPool* temporary;
struct PersistentPool* persistent;
@@ -931,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, j;
s32 i;
switch (gAudioResetStatus) {
case 5:
@@ -1007,7 +1007,7 @@ void init_reverb_eu(void) {
gNumSynthesisReverbs = preset->numReverbs;
for (j = 0; j < gNumSynthesisReverbs; j++) {
reverb = &gSynthesisReverbs[j];
reverbSettings = &sReverbSettings[MIN((gAudioResetPresetIdToLoad + j), (sizeof(sReverbSettings) / sizeof(struct ReverbSettingsEU)) - 1)];
reverbSettings = &sReverbSettings[MIN((u32)(gAudioResetPresetIdToLoad + j), (sizeof(sReverbSettings) / sizeof(struct ReverbSettingsEU)) - 1)];
reverb->windowSize = (reverbSettings->windowSize * 0x40);
reverb->downsampleRate = reverbSettings->downsampleRate;
reverb->reverbGain = reverbSettings->gain;

View File

@@ -137,14 +137,8 @@ u8 audioString49[] = "BANK LOAD MISS! FOR %d\n";
* Performs an asynchronus (normal priority) DMA copy
*/
void audio_dma_copy_async(uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQueue *queue, OSIoMesg *mesg) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
osInvalDCache(vAddr, nbytes);
osPiStartDma(mesg, OS_MESG_PRI_NORMAL, OS_READ, devAddr, vAddr, nbytes, queue);
#if PUPPYPRINT_DEBUG
dmaAudioTime[perfIteration] += (osGetTime() - first);
#endif
}
/**
@@ -152,18 +146,12 @@ void audio_dma_copy_async(uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQ
* to 0x1000 bytes transfer at once.
*/
void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
ssize_t transfer = MIN(*remaining, 0x1000);
*remaining -= transfer;
osInvalDCache(*vAddr, transfer);
osPiStartDma(mesg, OS_MESG_PRI_NORMAL, OS_READ, *devAddr, *vAddr, transfer, queue);
*devAddr += transfer;
*vAddr += transfer;
#if PUPPYPRINT_DEBUG
dmaAudioTime[perfIteration] += (osGetTime() - first);
#endif
}
void decrease_sample_dma_ttls() {
@@ -208,9 +196,6 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
u32 i;
u32 dmaIndex;
ssize_t bufferPos;
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
if (arg2 != 0 || *dmaIndexRef >= sSampleDmaListSize1) {
for (i = sSampleDmaListSize1; i < gSampleDmaNumListItems; i++) {
@@ -235,9 +220,6 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
}
dma->ttl = 60;
*dmaIndexRef = (u8) i;
#if PUPPYPRINT_DEBUG
dmaAudioTime[perfIteration] += (osGetTime() - first);
#endif
#if defined(VERSION_EU)
return &dma->buffer[(devAddr - dma->source)];
#else
@@ -277,14 +259,8 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
}
dma->ttl = 2;
#if defined(VERSION_EU)
#if PUPPYPRINT_DEBUG
dmaAudioTime[perfIteration] += (osGetTime() - first);
#endif
return dma->buffer + (devAddr - dma->source);
#else
#if PUPPYPRINT_DEBUG
dmaAudioTime[perfIteration] += (osGetTime() - first);
#endif
return (devAddr - dma->source) + dma->buffer;
#endif
}
@@ -310,18 +286,12 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount++], OS_MESG_PRI_NORMAL,
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
*dmaIndexRef = dmaIndex;
#if PUPPYPRINT_DEBUG
dmaAudioTime[perfIteration] += (osGetTime() - first);
#endif
return (devAddr - dmaDevAddr) + dma->buffer;
#else
gCurrAudioFrameDmaCount++;
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount - 1], OS_MESG_PRI_NORMAL,
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
*dmaIndexRef = dmaIndex;
#if PUPPYPRINT_DEBUG
dmaAudioTime[perfIteration] += (osGetTime() - first);
#endif
return dma->buffer + (devAddr - dmaDevAddr);
#endif
}

View File

@@ -315,7 +315,7 @@ struct AudioBank *load_banks_immediate(s32 seqId, s32 *outDefaultBank) {
u8 bank;
s32 offset;
s32 i;
void *ret;
void *ret = NULL;
offset = ((u16 *)gAlBankSets)[canonicalize_index(0, seqId)];
bank = 0xFF;
@@ -471,7 +471,6 @@ void load_sequence_internal(s32 player, s32 seqId, UNUSED s32 loadAsync) {
u32 s0;
s32 count;
u8 bank;
s32 i;
seqPlayer = &gSequencePlayers[player];
@@ -569,7 +568,7 @@ void *func_sh_802f3688(s32 bankId) {
patchInfo.baseAddr2 = NULL;
}
ret = func_sh_802f3764(1, bankId, &sp38)
ret = func_sh_802f3764(1, bankId, &sp38);
if (ret != NULL && sp38 == 1) {
func_sh_802f5310(bankId, ret, &patchInfo, 0);
@@ -796,8 +795,7 @@ void func_sh_802f3c38(uintptr_t devAddr, void *vAddr, size_t nbytes, s32 medium)
}
}
void func_sh_802f3d78(uintptr_t devAddr, void *vAddr, size_t nbytes, s32 arg3) {
uintptr_t sp1C = devAddr;
void func_sh_802f3d78(UNUSED uintptr_t devAddr, void *vAddr, size_t nbytes, UNUSED s32 arg3) {
osInvalDCache(vAddr, nbytes);
}
@@ -1168,8 +1166,7 @@ void func_sh_802f4bd8(struct PendingDmaSample *arg0, s32 len) { // len must be s
func_sh_802f3dd0(&arg0->ioMesg, 0, 0, arg0->devAddr, arg0->vAddr, len, &arg0->queue, arg0->medium, shindouDebugPrint102);
}
void func_sh_802f4c5c(uintptr_t devAddr, void *vAddr, size_t nbytes, s32 arg3) {
uintptr_t sp1C = devAddr;
void func_sh_802f4c5c(UNUSED uintptr_t devAddr, void *vAddr, size_t nbytes, UNUSED s32 arg3) {
osInvalDCache(vAddr, nbytes);
}
@@ -1319,8 +1316,7 @@ void func_sh_802f50ec(struct PendingDmaAudioBank *arg0, size_t len) {
}
void func_sh_802f517c(uintptr_t devAddr, void *vAddr, size_t nbytes, s32 arg3) {
uintptr_t sp1C = devAddr;
void func_sh_802f517c(UNUSED uintptr_t devAddr, void *vAddr, size_t nbytes, UNUSED s32 arg3) {
osInvalDCache(vAddr, nbytes);
}
@@ -1359,7 +1355,7 @@ void patch_sound(struct AudioBankSound *sound, struct AudioBank *memBase, struct
}
void func_sh_802f5310(s32 bankId, struct AudioBank *mem, struct PatchStruct *patchInfo, s32 arg3) {
u8 *addr;
u8 *addr = NULL;
s32 sp4C;
struct AudioBankSample *temp_s0;
s32 i;

View File

@@ -448,19 +448,16 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
struct Instrument *instrument;
struct Drum *drum;
s32 temp_a0_5;
u16 sp3A = 0;
#ifdef VERSION_EU
u16 sp3A;
s32 sameSound = TRUE;
#else
u8 sameSound = TRUE;
#endif
u8 cmd;
UNUSED u8 cmdSemitone;
#ifndef VERSION_EU
u16 sp3A;
#endif
f32 tuning;
s32 vel;
s32 vel = 0;
UNUSED s32 usedSemitone;
f32 freqScale;
#ifndef VERSION_EU
@@ -1139,6 +1136,7 @@ s32 seq_channel_layer_process_script_part2(struct SequenceChannelLayer *layer) {
cmd = m64_read_u8(state) + 0x80;
layer->freqScaleMultiplier = unk_sh_data_1[cmd];
// missing break :)
FALL_THROUGH;
default:
switch (cmd & 0xf0) {
@@ -1286,8 +1284,8 @@ s32 seq_channel_layer_process_script_part4(struct SequenceChannelLayer *layer, s
s32 seq_channel_layer_process_script_part3(struct SequenceChannelLayer *layer, s32 cmd) {
struct M64ScriptState *state = &layer->scriptState;
u16 sp3A;
s32 vel;
u16 sp3A = 0;
s32 vel = 0;
struct SequenceChannel *seqChannel = layer->seqChannel;
struct SequencePlayer *seqPlayer = seqChannel->seqPlayer;
@@ -1653,7 +1651,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
} else {
eu_stubbed_printf_1("SUB:ERR:BANK %d NOT CACHED.\n", cmd);
}
// fallthrough
FALL_THROUGH;
#endif
case 0xc1: // chan_setinstr ("set program"?)

View File

@@ -537,7 +537,7 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) {
u32 *aiBufPtr;
u64 *cmd = cmdBuf;
s32 chunkLen;
s32 nextVolRampTable;
s32 nextVolRampTable = 0;
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
process_sequences(i - 1);
@@ -671,7 +671,7 @@ u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s1
aMix(cmd++, 0, 0x7fff, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH);
aMix(cmd++, 0, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH);
} else {
startPad = (item->startPos & 0x7) * 2
startPad = (item->startPos & 0x7) * 2;
paddedLengthA = AUDIO_ALIGN(startPad + item->lengthA, 4);
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED, (item->startPos - startPad / 2), DEFAULT_LEN_1CH, reverbIndex);

View File

@@ -33,6 +33,7 @@
aSetBuffer(pkt, 0, 0, c + DMEM_ADDR_WET_RIGHT_CH, d); \
aSaveBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.right + (off)));
#undef ALIGN
#define ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1))
struct VolumeChange {
@@ -62,6 +63,7 @@ struct NoteSubEu *gNoteSubsEu;
// just that the reverb structure is chosen from an array with index
// Identical in EU.
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex) {
struct ReverbRingBufferItem *item;
struct SynthesisReverb *reverb = &gSynthesisReverbs[reverbIndex];
s32 srcPos, dstPos;
if (reverb->downsampleRate != 1) {
@@ -85,7 +87,7 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
}
}
struct ReverbRingBufferItem *item = &reverb->items[reverb->curFrame][updateIndex];
item = &reverb->items[reverb->curFrame][updateIndex];
s32 nSamples = chunkLen / reverb->downsampleRate;
s32 excessiveSamples = (nSamples + reverb->nextRingBufferPos) - reverb->bufSizePerChannel;
if (excessiveSamples < 0) {
@@ -374,7 +376,7 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
s32 flags; // sp148, sp11C, t8
u16 resamplingRateFixedPoint; // sp5c, sp11A
s32 nSamplesToLoad; //s0, Ec
s32 sp130; //sp128, sp104
s32 sp130 = 0; //sp128, sp104
UNUSED s32 tempBufLen;
s32 t0;
u8 *sampleAddr; // sp120, spF4
@@ -394,7 +396,7 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
s32 nSamplesInThisIteration; // v1_2
u32 a3;
u8 *v0_2;
s32 unk_s6; // sp90
s32 unk_s6 = 0; // sp90
s32 s5Aligned;
s32 sp88;
s32 sp84;

View File

@@ -1,4 +1,5 @@
#include <ultra64.h>
#include <PR/os_internal_reg.h>
#include <PR/os_system.h>
#include <PR/os_vi.h>
#include <stdio.h>
@@ -20,6 +21,7 @@
#endif
#include "game/puppyprint.h"
#include "game/puppylights.h"
#include "game/profiling.h"
#include "game/vc_check.h"
@@ -188,10 +190,8 @@ void start_gfx_sptask(void) {
if (gActiveSPTask == NULL
&& sCurrentDisplaySPTask != NULL
&& sCurrentDisplaySPTask->state == SPTASK_STATE_NOT_STARTED) {
#if PUPPYPRINT_DEBUG
rspDelta = osGetTime();
#endif
start_sptask(M_GFXTASK);
profiler_rsp_started(PROFILER_RSP_GFX);
}
}
@@ -223,15 +223,14 @@ void handle_vblank(void) {
} else {
pretend_audio_sptask_done();
}
profiler_rsp_started(PROFILER_RSP_AUDIO);
}
} else {
if (gActiveSPTask == NULL
&& sCurrentDisplaySPTask != NULL
&& sCurrentDisplaySPTask->state != SPTASK_STATE_FINISHED) {
#if PUPPYPRINT_DEBUG
rspDelta = osGetTime();
#endif
start_sptask(M_GFXTASK);
profiler_rsp_started(PROFILER_RSP_GFX);
}
}
#if ENABLE_RUMBLE
@@ -256,9 +255,9 @@ void handle_sp_complete(void) {
// The gfx task completed before we had time to interrupt it.
// Mark it finished, just like below.
curSPTask->state = SPTASK_STATE_FINISHED;
#if PUPPYPRINT_DEBUG
profiler_update(rspGenTime, rspDelta);
#endif
profiler_rsp_completed(PROFILER_RSP_GFX);
} else {
profiler_rsp_yielded();
}
// Start the audio task, as expected by handle_vblank.
@@ -267,12 +266,19 @@ void handle_sp_complete(void) {
} else {
pretend_audio_sptask_done();
}
profiler_rsp_started(PROFILER_RSP_AUDIO);
} else {
curSPTask->state = SPTASK_STATE_FINISHED;
if (curSPTask->task.t.type == M_AUDTASK) {
profiler_rsp_completed(PROFILER_RSP_AUDIO);
// After audio tasks come gfx tasks.
if ((sCurrentDisplaySPTask != NULL)
&& (sCurrentDisplaySPTask->state != SPTASK_STATE_FINISHED)) {
if (sCurrentDisplaySPTask->state == SPTASK_STATE_INTERRUPTED) {
profiler_rsp_resumed();
} else {
profiler_rsp_started(PROFILER_RSP_GFX);
}
start_sptask(M_GFXTASK);
}
sCurrentAudioSPTask = NULL;
@@ -283,9 +289,7 @@ void handle_sp_complete(void) {
// The SP process is done, but there is still a Display Processor notification
// that needs to arrive before we can consider the task completely finished and
// null out sCurrentDisplaySPTask. That happens in handle_dp_complete.
#if PUPPYPRINT_DEBUG
profiler_update(rspGenTime, rspDelta);
#endif
profiler_rsp_completed(PROFILER_RSP_GFX);
}
}
}
@@ -298,6 +302,22 @@ void handle_dp_complete(void) {
sCurrentDisplaySPTask->state = SPTASK_STATE_FINISHED_DP;
sCurrentDisplaySPTask = NULL;
}
void check_cache_emulation() {
// Disable interrupts to ensure that nothing evicts the variable from cache while we're using it.
u32 saved = __osDisableInt();
// Create a variable with an initial value of 1. This value will remain cached.
volatile u8 sCachedValue = 1;
// Overwrite the variable directly in RDRAM without going through cache.
// This should preserve its value of 1 in dcache if dcache is emulated correctly.
*(u8*)(K0_TO_K1(&sCachedValue)) = 0;
// Read the variable back from dcache, if it's still 1 then cache is emulated correctly.
// If it's zero, then dcache is not emulated correctly.
gCacheEmulated = sCachedValue;
// Restore interrupts
__osRestoreInt(saved);
}
extern void crash_screen_init(void);
void thread3_main(UNUSED void *arg) {
@@ -315,8 +335,9 @@ void thread3_main(UNUSED void *arg) {
#ifdef DEBUG
osSyncPrintf("Super Mario 64\n");
#if 0 // if your PC username isn't your real name feel free to uncomment
osSyncPrintf("Built by: %s\n", __username__);
osSyncPrintf("Date : %s\n", __datetime__);
#endif
osSyncPrintf("Compiler: %s\n", __compiler__);
osSyncPrintf("Linker : %s\n", __linker__);
#endif
@@ -325,6 +346,7 @@ void thread3_main(UNUSED void *arg) {
gIsConsole = FALSE;
gBorderHeight = BORDER_HEIGHT_EMULATOR;
gIsVC = IS_VC();
check_cache_emulation();
} else {
gIsConsole = TRUE;
gBorderHeight = BORDER_HEIGHT_CONSOLE;
@@ -338,9 +360,6 @@ void thread3_main(UNUSED void *arg) {
while (TRUE) {
OSMesg msg;
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
osRecvMesg(&gIntrMesgQueue, &msg, OS_MESG_BLOCK);
switch ((uintptr_t) msg) {
case MESG_VI_VBLANK:
@@ -359,9 +378,6 @@ void thread3_main(UNUSED void *arg) {
handle_nmi_request();
break;
}
#if PUPPYPRINT_DEBUG
profiler_update(taskTime, first);
#endif
}
}
@@ -491,12 +507,10 @@ void thread1_idle(UNUSED void *arg) {
}
}
#if CLEARRAM
void ClearRAM(void)
{
// Clear RAM on boot
void ClearRAM(void) {
bzero(_mainSegmentEnd, (size_t)osMemSize - (size_t)OS_K0_TO_PHYSICAL(_mainSegmentEnd));
}
#endif
#ifdef ISVPRINT
extern u32 gISVDbgPrnAdrs;
@@ -515,9 +529,7 @@ void osInitialize_fakeisv() {
#endif
void main_func(void) {
#if CLEARRAM
ClearRAM();
#endif
__osInitialize_common();
#ifdef ISVPRINT
osInitialize_fakeisv();

View File

@@ -259,9 +259,6 @@ u32 main_pool_pop_state(void) {
*/
void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) {
u32 size = ALIGN16(srcEnd - srcStart);
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
osInvalDCache(dest, size);
while (size != 0) {
@@ -275,9 +272,6 @@ void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) {
srcStart += copySize;
size -= copySize;
}
#if PUPPYPRINT_DEBUG
dmaTime[perfIteration] += (osGetTime() - first);
#endif
}
/**

View File

@@ -894,25 +894,18 @@ void cur_obj_update(void) {
}
#if SILHOUETTE
COND_BIT(( objFlags & OBJ_FLAG_SILHOUETTE ), o->header.gfx.node.flags, GRAPH_RENDER_SILHOUETTE );
COND_BIT(( objFlags & OBJ_FLAG_OCCLUDE_SILHOUETTE ), o->header.gfx.node.flags, GRAPH_RENDER_OCCLUDE_SILHOUETTE);
COND_BIT((objFlags & OBJ_FLAG_SILHOUETTE ), o->header.gfx.node.flags, GRAPH_RENDER_SILHOUETTE );
COND_BIT((objFlags & OBJ_FLAG_OCCLUDE_SILHOUETTE), o->header.gfx.node.flags, GRAPH_RENDER_OCCLUDE_SILHOUETTE);
#endif
#ifdef OBJECTS_REJ
s32 objListIndex = OBJ_LIST_PLAYER;
BehaviorScript *bhvScript = segmented_to_virtual(o->behavior);
if ((bhvScript[0] >> 24) == 0) {
objListIndex = ((bhvScript[0] >> 16) & 0xFFFF);
}
if (objFlags & OBJ_FLAG_UCODE_SMALL) {
if ((objFlags & OBJ_FLAG_SILHOUETTE) || (objFlags & OBJ_FLAG_UCODE_SMALL)) {
o->header.gfx.ucode = GRAPH_NODE_UCODE_REJ;
}
else {
} else {
o->header.gfx.ucode = GRAPH_NODE_UCODE_DEFAULT;
}
#endif
#ifdef OBJ_OPACITY_BY_CAM_DIST
if (objFlags & OBJ_FLAG_OPACITY_FROM_CAMERA_DIST) {
obj_set_opacity_from_cam_dist(o);

View File

@@ -430,11 +430,15 @@ struct GraphNodeShadow *init_graph_node_shadow(struct AllocOnlyPool *pool,
if (graphNode != NULL) {
#ifdef LEGACY_SHADOW_IDS
if (shadowType == 1 || shadowType == 2 || shadowType == 99) {
if (shadowType == LEGACY_SHADOW_CIRCLE_9_VERTS
|| shadowType == LEGACY_SHADOW_CIRCLE_4_VERTS
|| shadowType == LEGACY_SHADOW_CIRCLE_4_VERTS_FLAT_UNUSED
|| shadowType == LEGACY_SHADOW_CIRCLE_PLAYER) {
shadowType = SHADOW_CIRCLE;
} else if (shadowType == 11 || shadowType == 12) {
} else if (shadowType == LEGACY_SHADOW_SQUARE_SCALABLE
|| shadowType == LEGACY_SHADOW_SQUARE_TOGGLABLE) {
shadowType = SHADOW_SQUARE;
} else if (shadowType == 10) {
} else if (shadowType == LEGACY_SHADOW_SQUARE_PERMANENT) {
shadowType = SHADOW_SQUARE_PERMANENT;
}
#endif

View File

@@ -100,7 +100,7 @@ void min_max_3f(f32 a, f32 b, f32 c, f32 *min, f32 *max) { min_max_3_func(a, b,
void min_max_3i(s32 a, s32 b, s32 c, s32 *min, s32 *max) { min_max_3_func(a, b, c, min, max); }
void min_max_3s(s16 a, s16 b, s16 c, s16 *min, s16 *max) { min_max_3_func(a, b, c, min, max); }
/// Copy vector 'src' to 'dest'
/// Perform a bitwise copy from vector 'src' to 'dest'
#define vec3_copy_bits(destFmt, dest, srcFmt, src) { \
register destFmt x = ((srcFmt *) src)[0]; \
register destFmt y = ((srcFmt *) src)[1]; \
@@ -255,7 +255,7 @@ void vec3s_prod(Vec3s dest, const Vec3s a, const Vec3s b) { vec3_prod_func(s16,
#undef vec3_prod_func
/// Add vector 'a' to 'dest'
/// Performs element-wise division of two 3-vectors
#define vec3_div_func(fmt, dest, a) { \
register fmt x = ((fmt *) a)[0]; \
register fmt y = ((fmt *) a)[1]; \
@@ -269,7 +269,7 @@ void vec3i_div(Vec3i dest, const Vec3i a) { vec3_div_func(s32, dest, a); }
void vec3s_div(Vec3s dest, const Vec3s a) { vec3_div_func(s16, dest, a); }
#undef vec3_div_func
/// Make 'dest' the sum of vectors a and b.
/// Make 'dest' the quotient of vectors a and b.
#define vec3_quot_func(fmt, dest, a, b) { \
register fmt x1 = ((fmt *) a)[0]; \
register fmt y1 = ((fmt *) a)[1]; \
@@ -1339,8 +1339,8 @@ s32 ray_surface_intersect(Vec3f orig, Vec3f dir, f32 dir_length, struct Surface
vec3f_cross(h, dir, e2);
// Determine the cos(angle) difference between ray and surface normals.
f32 det = vec3f_dot(e1, h);
// Check if we're perpendicular from the surface.
if ((det > -NEAR_ZERO) && (det < NEAR_ZERO)) return FALSE;
// Check if we're perpendicular or pointing away from the surface.
if (det < NEAR_ZERO) return FALSE;
// Check if we're making contact with the surface.
// Make f the inverse of the cos(angle) between ray and surface normals.
f32 f = 1.0f / det; // invDet
@@ -1377,9 +1377,6 @@ void find_surface_on_ray_list(struct SurfaceNode *list, Vec3f orig, Vec3f dir, f
f32 length;
Vec3f chk_hit_pos;
f32 top, bottom;
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
// Get upper and lower bounds of ray
if (dir[1] >= 0.0f) {
// Ray is upwards.
@@ -1403,9 +1400,6 @@ void find_surface_on_ray_list(struct SurfaceNode *list, Vec3f orig, Vec3f dir, f
*max_length = length;
}
}
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += osGetTime() - first;
#endif
}
void find_surface_on_ray_cell(s32 cellX, s32 cellZ, Vec3f orig, Vec3f normalized_dir, f32 dir_length, struct Surface **hit_surface, Vec3f hit_pos, f32 *max_length, s32 flags) {
@@ -1512,14 +1506,14 @@ static ALWAYS_INLINE float construct_float(const float f)
: "=r"(r)
: "K"(upper));
} else if ((i & 0xFFFF0000) == 0) {
__asm__ ("addiu %0, $0, %1"
__asm__ ("ori %0, $0, %1"
: "+r"(r)
: "K"(lower));
} else {
__asm__ ("lui %0, %1"
: "=r"(r)
: "K"(upper));
__asm__ ("addiu %0, %0, %1"
__asm__ ("ori %0, %0, %1"
: "+r"(r)
: "K"(lower));
}

View File

@@ -175,16 +175,10 @@ s32 find_wall_collisions(struct WallCollisionData *colData) {
s32 numCollisions = 0;
s32 x = colData->x;
s32 z = colData->z;
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
colData->numWalls = 0;
if (is_outside_level_bounds(x, z)) {
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += osGetTime() - first;
#endif
return numCollisions;
}
@@ -207,9 +201,6 @@ s32 find_wall_collisions(struct WallCollisionData *colData) {
// Increment the debug tracker.
gNumCalls.wall++;
#endif
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += osGetTime() - first;
#endif
return numCollisions;
}
@@ -326,18 +317,12 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) {
f32 height = CELL_HEIGHT_LIMIT;
f32 dynamicHeight = CELL_HEIGHT_LIMIT;
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
s32 x = posX;
s32 y = posY;
s32 z = posZ;
*pceil = NULL;
if (is_outside_level_bounds(x, z)) {
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += (osGetTime() - first);
#endif
return height;
}
@@ -379,9 +364,6 @@ f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) {
// Increment the debug tracker.
gNumCalls.ceil++;
#endif
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += osGetTime() - first;
#endif
return height;
}
@@ -563,10 +545,6 @@ f32 unused_find_dynamic_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfl
* Find the highest floor under a given position and return the height.
*/
f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
f32 height = FLOOR_LOWER_LIMIT;
f32 dynamicHeight = FLOOR_LOWER_LIMIT;
@@ -580,9 +558,6 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) {
*pfloor = NULL;
if (is_outside_level_bounds(x, z)) {
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += (osGetTime() - first);
#endif
return height;
}
// Each level is split into cells to limit load, find the appropriate cell.
@@ -626,9 +601,6 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) {
#ifdef VANILLA_DEBUG
// Increment the debug tracker.
gNumCalls.floor++;
#endif
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += (osGetTime() - first);
#endif
return height;
}
@@ -682,9 +654,6 @@ s32 find_water_level_and_floor(s32 x, s32 y, s32 z, struct Surface **pfloor) {
s32 loX, hiX, loZ, hiZ;
TerrainData *p = gEnvironmentRegions;
struct Surface *floor = NULL;
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
s32 waterLevel = find_water_floor(x, y, z, &floor);
if (p != NULL && waterLevel == FLOOR_LOWER_LIMIT) {
@@ -710,9 +679,6 @@ s32 find_water_level_and_floor(s32 x, s32 y, s32 z, struct Surface **pfloor) {
*pfloor = floor;
}
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += (osGetTime() - first);
#endif
return waterLevel;
}
@@ -724,9 +690,6 @@ s32 find_water_level(s32 x, s32 z) { // TODO: Allow y pos
s32 loX, hiX, loZ, hiZ;
TerrainData *p = gEnvironmentRegions;
struct Surface *floor = NULL;
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
s32 waterLevel = find_water_floor(x, ((gCollisionFlags & COLLISION_FLAG_CAMERA) ? gLakituState.pos[1] : gMarioState->pos[1]), z, &floor);
if ((p != NULL) && (waterLevel == FLOOR_LOWER_LIMIT)) {
@@ -750,10 +713,6 @@ s32 find_water_level(s32 x, s32 z) { // TODO: Allow y pos
}
}
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += osGetTime() - first;
#endif
return waterLevel;
}
@@ -765,9 +724,6 @@ s32 find_poison_gas_level(s32 x, s32 z) {
s32 loX, hiX, loZ, hiZ;
s32 gasLevel = FLOOR_LOWER_LIMIT;
TerrainData *p = gEnvironmentRegions;
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
if (p != NULL) {
s32 numRegions = *p++;
@@ -794,10 +750,6 @@ s32 find_poison_gas_level(s32 x, s32 z) {
}
}
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += osGetTime() - first;
#endif
return gasLevel;
}

View File

@@ -470,9 +470,6 @@ u32 get_area_terrain_size(TerrainData *data) {
void load_area_terrain(s32 index, TerrainData *data, RoomData *surfaceRooms, s16 *macroObjects) {
s32 terrainLoadType;
TerrainData *vertexData = NULL;
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
// Initialize the data for this.
gEnvironmentRegions = NULL;
@@ -519,9 +516,6 @@ void load_area_terrain(s32 index, TerrainData *data, RoomData *surfaceRooms, s16
gNumStaticSurfaceNodes = gSurfaceNodesAllocated;
gNumStaticSurfaces = gSurfacesAllocated;
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += osGetTime() - first;
#endif
}
/**
@@ -646,9 +640,6 @@ static void get_optimal_coll_dist(struct Object *obj) {
*/
void load_object_collision_model(void) {
TerrainData vertexData[600];
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
TerrainData *collisionData = o->collisionData;
f32 marioDist = o->oDistanceToMario;
@@ -686,7 +677,4 @@ void load_object_collision_model(void) {
}
}
COND_BIT((marioDist < o->oDrawingDistance), o->header.gfx.node.flags, GRAPH_RENDER_ACTIVE);
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += osGetTime() - first;
#endif
}

View File

@@ -25,6 +25,7 @@
#include "puppyprint.h"
#include "debug_box.h"
#include "engine/colors.h"
#include "profiling.h"
struct SpawnInfo gPlayerSpawnInfos[1];
struct GraphNode *gGraphNodePointers[MODEL_ID_COUNT];
@@ -375,10 +376,6 @@ void play_transition_after_delay(s16 transType, s16 time, u8 red, u8 green, u8 b
}
void render_game(void) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
OSTime colTime = collisionTime[perfIteration];
#endif
if (gCurrentArea != NULL && !gWarpTransition.pauseRendering) {
if (gCurrentArea->graphNode) {
geo_process_root(gCurrentArea->graphNode, gViewportOverride, gViewportClip, gFBSetColor);
@@ -435,10 +432,9 @@ void render_game(void) {
gViewportOverride = NULL;
gViewportClip = NULL;
profiler_update(PROFILER_TIME_GFX);
profiler_print_times();
#if PUPPYPRINT_DEBUG
profiler_update(graphTime, first);
graphTime[perfIteration] -= (collisionTime[perfIteration] - colTime);
// graphTime[perfIteration] -= profilerTime[perfIteration]; //! Graph time is inaccurate and wrongly reaches 0 sometimes
puppyprint_render_profiler();
#endif
}

View File

@@ -6,18 +6,15 @@ void bhv_celebration_star_init(void) {
o->oHomeZ = gMarioObject->header.gfx.pos[2];
o->oMoveAngleYaw = gMarioObject->header.gfx.angle[1] + 0x8000;
o->oCelebStarDiameterOfRotation = 100;
if (gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2) {
o->header.gfx.sharedChild = gLoadedGraphNodes[MODEL_BOWSER_KEY];
o->oFaceAnglePitch = 0;
o->oFaceAnglePitch = 0;
if (obj_has_model(gMarioState->interactObj, MODEL_BOWSER_KEY)) {
o->oFaceAngleRoll = 0xC000;
cur_obj_scale(0.1f);
o->oCelebStarIsBowserKey = 1;
o->oCelebStarIsBowserKey = TRUE;
} else {
o->header.gfx.sharedChild = gLoadedGraphNodes[MODEL_STAR];
o->oFaceAnglePitch = 0;
o->oFaceAngleRoll = 0;
cur_obj_scale(0.4f);
o->oCelebStarIsBowserKey = 0;
o->oCelebStarIsBowserKey = FALSE;
}
}
@@ -42,7 +39,7 @@ void celeb_star_act_spin_around_mario(void) {
void celeb_star_act_face_camera(void) {
if (o->oTimer < 10) {
if (o->oCelebStarIsBowserKey == 0) {
if (o->oCelebStarIsBowserKey == FALSE) {
cur_obj_scale((f32) o->oTimer / 10.0f);
} else {
cur_obj_scale((f32) o->oTimer / 30.0f);

View File

@@ -76,7 +76,7 @@ void bhv_mr_i_iris_loop(void) {
obj_build_transform_from_pos_and_angle(o, O_PARENT_RELATIVE_POS_INDEX, O_MOVE_ANGLE_INDEX);
obj_translate_local(o, O_POS_INDEX, O_PARENT_RELATIVE_POS_INDEX);
o->oFaceAnglePitch = o->oMoveAnglePitch;
o->oGraphYOffset = o->header.gfx.scale[1] * 100.0f;
o->oGraphYOffset = o->parentObj->oGraphYOffset;
}
if (!o->parentObj->oMrIBlinking) {
@@ -128,7 +128,7 @@ void mr_i_body_act_spin_death(void) {
cur_obj_become_intangible();
spawn_mist_particles();
o->oMrIScale = scaleModifier * 0.6f;
if (o->oBehParams2ndByte != 0) {
if (o->oBehParams2ndByte != MR_I_BP_NORMAL) {
o->oPosY += 100.0f;
spawn_default_star(1370, 2000.0f, -320.0f);
obj_mark_for_deletion(o);

View File

@@ -38,7 +38,9 @@ Gfx *geo_snufit_move_mask(s32 callContext, struct GraphNode *node, UNUSED Mat4 *
if (callContext == GEO_CONTEXT_RENDER) {
struct Object *obj = (struct Object *) gCurGraphNodeObject;
struct GraphNodeTranslationRotation *transNode = (struct GraphNodeTranslationRotation *) node->next;
vec3s_copy(transNode->translation, &obj->oSnufitOffsetVec);
transNode->translation[0] = 0;
transNode->translation[1] = -32;
transNode->translation[2] = obj->oSnufitRecoil + 180;
}
return NULL;
@@ -147,8 +149,6 @@ void bhv_snufit_loop(void) {
o->oPosY = o->oHomeY + 8.0f * coss(4000 * gGlobalTimer);
o->oPosZ = o->oHomeZ + 100.0f * sins(o->oSnufitCircularPeriod);
o->oSnufitYOffset = -0x20;
o->oSnufitZOffset = o->oSnufitRecoil + 180;
o->oSnufitBodyScale
= (s16)(o->oSnufitBodyBaseScale + 666
+ o->oSnufitBodyBaseScale * coss(o->oSnufitBodyScalePeriod));

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