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 committed 2022-06-28 12:43:02 -07:00
commit e6d68e6d76
89 files changed
+3205 -1095

No files matched your search

+10 -16
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;
+7 -3
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;
+1 -1
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);
+5 -5
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;
-30
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
}
+6 -10
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;
+6 -8
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"?)
+2 -2
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);
+5 -3
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;
+37 -25
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();
-6
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
}
/**
+6 -13
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);
+7 -3
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
+7 -13
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));
}
-48
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;
}
-12
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
}
+3 -7
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
}
+5 -8
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);
+2 -2
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);
+3 -3
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));
@@ -8,9 +8,8 @@
* Initialize the object's transform matrix with Y being up.
*/
void bhv_platform_normals_init(void) {
Mat4 *transform = &o->transform;
vec3f_set(&o->oTiltingPyramidNormalVec, 0.0f, 1.0f, 0.0f);
mtxf_align_terrain_normal(*transform, &o->oTiltingPyramidNormalVec, &o->oPosVec, 0);
mtxf_align_terrain_normal(o->transform, &o->oTiltingPyramidNormalVec, &o->oPosVec, 0);
}
/**
@@ -20,24 +19,32 @@ void bhv_platform_normals_init(void) {
void bhv_tilting_inverted_pyramid_loop(void) {
#ifndef PLATFORM_DISPLACEMENT_2
Vec3f posBeforeRotation, posAfterRotation;
// Mario's position
Vec3f m;
Vec3f marioPos, dist;
#endif
Vec3f targetNormal;
Mat4 *transform = &o->transform;
s32 marioOnPlatform = (gMarioObject->platform == o);
if (gMarioObject->platform == o) {
vec3_diff(targetNormal, &gMarioObject->oPosVec, &o->oPosVec);
if (marioOnPlatform) {
#ifndef PLATFORM_DISPLACEMENT_2
vec3f_copy(m, gMarioStates[0].pos);
linear_mtxf_mul_vec3f(*transform, posBeforeRotation, targetNormal);
// 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);
o->oTiltingPyramidMarioOnPlatform = TRUE;
} else {
// Target normal is directly upwards when Mario is not on the platform.
vec3f_set(targetNormal, 0.0f, 1.0f, 0.0f);
o->oTiltingPyramidMarioOnPlatform = FALSE;
}
// Approach the normals by 0.01f towards the new goal, then create a transform matrix and orient the object.
@@ -45,16 +52,16 @@ void bhv_tilting_inverted_pyramid_loop(void) {
approach_f32_symmetric_bool(&o->oTiltingPyramidNormalX, targetNormal[0], 0.01f);
approach_f32_symmetric_bool(&o->oTiltingPyramidNormalY, targetNormal[1], 0.01f);
approach_f32_symmetric_bool(&o->oTiltingPyramidNormalZ, targetNormal[2], 0.01f);
mtxf_align_terrain_normal(*transform, &o->oTiltingPyramidNormalVec, &o->oPosVec, 0);
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 (o->oTiltingPyramidMarioOnPlatform) {
linear_mtxf_mul_vec3f(*transform, posAfterRotation, targetNormal);
m[0] += posAfterRotation[0] - posBeforeRotation[0];
m[1] += posAfterRotation[1] - posBeforeRotation[1];
m[2] += posAfterRotation[2] - posBeforeRotation[2];
vec3f_copy(gMarioStates[0].pos, m);
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
+23 -12
View File
@@ -1,14 +1,13 @@
// water_ring.inc.c
#ifndef FIX_WATER_RINGS
f32 water_ring_calc_mario_dist(void) {
f32 marioDistX = o->oPosX - gMarioObject->header.gfx.pos[0];
f32 marioDistY = o->oPosY - (gMarioObject->header.gfx.pos[1] + 80.0f);
f32 marioDistZ = o->oPosZ - gMarioObject->header.gfx.pos[2];
f32 marioDistInFront = marioDistX * o->oWaterRingNormalX + marioDistY * o->oWaterRingNormalY
+ marioDistZ * o->oWaterRingNormalZ;
return marioDistInFront;
Vec3f marioDist;
vec3_diff(marioDist, &o->oPosVec, gMarioObject->header.gfx.pos);
marioDist[1] += 80.0f;
return vec3_dot(marioDist, &o->oWaterRingNormalVec);
}
#endif
void water_ring_init(void) {
cur_obj_init_animation(WATER_RING_ANIM_WOBBLE);
@@ -16,6 +15,7 @@ void water_ring_init(void) {
o->oWaterRingScalePhaseY = (s32)(random_float() * 4096.0f) + 0x1000;
o->oWaterRingScalePhaseZ = (s32)(random_float() * 4096.0f) + 0x1000;
#ifndef FIX_WATER_RINGS
//! This normal calculation assumes a facing yaw of 0, which is not the case
// for the manta ray rings. It also errs by multiplying the normal X by -1.
// This cause the ring's orientation for the purposes of collision to be
@@ -32,6 +32,7 @@ void water_ring_init(void) {
//
// o->oFaceAngleYaw = 0;
// o->oFaceAngleRoll *= -1;
#endif
}
void bhv_jet_stream_water_ring_init(void) {
@@ -42,16 +43,21 @@ void bhv_jet_stream_water_ring_init(void) {
}
void water_ring_check_collection(UNUSED f32 avgScale, struct Object *ringManager) {
#ifdef FIX_WATER_RINGS
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
#else
f32 marioDistInFront = water_ring_calc_mario_dist();
if (!is_point_close_to_object(o, gMarioObject->header.gfx.pos[0],
gMarioObject->header.gfx.pos[1] + 80.0f,
gMarioObject->header.gfx.pos[2], (avgScale + 0.2f) * 120.0f)) {
gMarioObject->header.gfx.pos[1] + 80.0f,
gMarioObject->header.gfx.pos[2],
(avgScale + 0.2f) * 120.0f)) {
o->oWaterRingMarioDistInFront = marioDistInFront;
return;
}
if (o->oWaterRingMarioDistInFront * marioDistInFront < 0.0f) {
#endif
struct Object *ringSpawner = o->parentObj;
if (ringSpawner) {
@@ -73,7 +79,9 @@ void water_ring_check_collection(UNUSED f32 avgScale, struct Object *ringManager
o->oAction = WATER_RING_ACT_COLLECTED;
}
#ifndef FIX_WATER_RINGS
o->oWaterRingMarioDistInFront = marioDistInFront;
#endif
}
void water_ring_set_scale(f32 avgScale) {
@@ -154,8 +162,11 @@ void water_ring_spawner_act_inactive(void) {
o->oTimer = 0;
}
if ((o->oTimer == 0) || (o->oTimer == 50) || (o->oTimer == 150) || (o->oTimer == 200)
|| (o->oTimer == 250)) {
if ((o->oTimer == 0)
|| (o->oTimer == 50)
|| (o->oTimer == 150)
|| (o->oTimer == 200)
|| (o->oTimer == 250)) {
struct Object *waterRing = spawn_object(o, MODEL_WATER_RING, bhvJetStreamWaterRing);
waterRing->oWaterRingIndex = o->oWaterRingMgrNextRingIndex;
o->oWaterRingMgrNextRingIndex++;
@@ -199,7 +210,7 @@ void manta_water_ring_act_not_collected(void) {
if (o->oTimer > 150) {
o->oOpacity -= 2;
if (o->oOpacity < 3) {
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
obj_mark_for_deletion(o);
}
}
-8
View File
@@ -2871,10 +2871,6 @@ void update_lakitu(struct Camera *c) {
* Gets controller input, checks for cutscenes, handles mode changes, and moves the camera
*/
void update_camera(struct Camera *c) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
OSTime colTime = collisionTime[perfIteration];
#endif
gCamera = c;
update_camera_hud_status(c);
if (c->cutscene == CUTSCENE_NONE
@@ -3117,10 +3113,6 @@ void update_camera(struct Camera *c) {
}
#endif
gLakituState.lastFrameAction = sMarioCamState->action;
#if PUPPYPRINT_DEBUG
profiler_update(cameraTime, first);
cameraTime[perfIteration] -= collisionTime[perfIteration]-colTime;
#endif
}
/**
-6
View File
@@ -402,9 +402,6 @@ void thread2_crash_screen(UNUSED void *arg) {
osSetEventMesg(OS_EVENT_CPU_BREAK, &gCrashScreen.mesgQueue, (OSMesg) 1);
osSetEventMesg(OS_EVENT_FAULT, &gCrashScreen.mesgQueue, (OSMesg) 2);
while (TRUE) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
if (thread == NULL) {
osRecvMesg(&gCrashScreen.mesgQueue, &mesg, 1);
thread = get_crashed_thread();
@@ -433,9 +430,6 @@ void thread2_crash_screen(UNUSED void *arg) {
read_controller_inputs(THREAD_2_CRASH_SCREEN);
draw_crash_screen(thread);
}
#if PUPPYPRINT_DEBUG
profiler_update(faultTime, first);
#endif
}
}
+87
View File
@@ -0,0 +1,87 @@
// This file is a modification of a file from https://github.com/danbolt/n64-jam-1, which was licensed under the MPL-2.0 License
// See the original repo for more details.
#include <ultra64.h>
#define TEX_ASCII_START '!'
#define TAB_WIDTH 16
#define G_CC_TEXT PRIMITIVE, 0, TEXEL0, 0, 0, 0, 0, TEXEL0
__asm__(
".section \".rodata\", \"a\", @progbits\n"
".global fast_font\n"
"fast_font:\n"
".incbin \"src/game/newfont2_swapped.bin\"\n"
".previous\n"
);
extern u8 fast_font[];
int computeS(unsigned char letter) {
int idx = letter;
if (letter > 'z') {
idx -= (3 + 2 + 3 + 1 + 3);
} else if (letter > '^') {
idx -= (2 + 3 + 1 + 3);
} else if (letter > 'Z') {
idx -= (3 + 1 + 3);
} else if (letter > '?') {
idx -= (1 + 3);
} else if (letter > ';') {
idx -= (3);
}
return (idx - TEX_ASCII_START) * 8;
}
static const u8 fast_text_font_kerning[] = {
/* */ 2, /*!*/ 4, /*"*/ 5, /*#*/ 0, /*$*/ 0, /*%*/ 7, /*&*/ 7, /*'*/ 2, /*(*/ 5, /*)*/ 5, /***/ 0, /*+*/ 7, /*,*/ 3, /*-*/ 7, /*.*/ 3, /*/*/ 7,
/*0*/ 7, /*1*/ 7, /*2*/ 7, /*3*/ 7, /*4*/ 7, /*5*/ 7, /*6*/ 7, /*7*/ 7, /*8*/ 7, /*9*/ 7, /*:*/ 3, /*;*/ 3, /*<*/ 0, /*=*/ 0, /*>*/ 0, /*?*/ 7,
/*@*/ 0, /*A*/ 7, /*B*/ 7, /*C*/ 7, /*D*/ 7, /*E*/ 7, /*F*/ 7, /*G*/ 7, /*H*/ 7, /*I*/ 6, /*J*/ 5, /*K*/ 7, /*L*/ 7, /*M*/ 7, /*N*/ 7, /*O*/ 7,
/*P*/ 7, /*Q*/ 7, /*R*/ 7, /*S*/ 7, /*T*/ 7, /*U*/ 7, /*V*/ 7, /*W*/ 7, /*X*/ 7, /*Y*/ 7, /*Z*/ 7, /*[*/ 0, /*\*/ 0, /*]*/ 0, /*^*/ 6, /*_*/ 0,
/*`*/ 0, /*a*/ 6, /*b*/ 6, /*c*/ 6, /*d*/ 6, /*e*/ 6, /*f*/ 6, /*g*/ 6, /*h*/ 6, /*i*/ 2, /*j*/ 6, /*k*/ 5, /*l*/ 3, /*m*/ 6, /*n*/ 6, /*o*/ 6,
/*p*/ 6, /*q*/ 6, /*r*/ 6, /*s*/ 6, /*t*/ 6, /*u*/ 6, /*v*/ 6, /*w*/ 6, /*x*/ 6, /*y*/ 6, /*z*/ 6, /*{*/ 0, /*|*/ 0, /*}*/ 0, /*~*/ 7,
};
void drawSmallString_impl(Gfx **dl, int x, int y, const char* string, int r, int g, int b) {
int i = 0;
int xPos = x;
int yPos = y;
int s = 0;
Gfx *dlHead = *dl;
gDPLoadTextureBlock_4bS(dlHead++, fast_font, G_IM_FMT_IA, 672, 12, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
gDPSetPrimColor(dlHead++, 0, 0, r, g, b, 255);
gDPSetCombineMode(dlHead++, G_CC_TEXT, G_CC_TEXT);
gDPPipeSync(dlHead++);
while (string[i] != '\0') {
unsigned int cur_char = string[i];
if (cur_char == '\n') {
xPos = x;
yPos += 12;
i++;
continue;
}
if (cur_char == '\t') {
int xDist = xPos - x + 1;
int tabCount = (xDist + TAB_WIDTH - 1) / TAB_WIDTH;
xPos = tabCount * TAB_WIDTH + x;
} else {
if (cur_char != ' ') {
s = computeS(cur_char);
gSPTextureRectangle(dlHead++, (xPos + 0) << 2, (yPos + 0) << 2, (xPos + 8) << 2, (yPos + 12) << 2, 0, s << 5, 0, 1 << 10, 1 << 10);
}
xPos += fast_text_font_kerning[cur_char - ' '];
}
i++;
}
gDPSetPrimColor(dlHead++, 0, 0, 255, 255, 255, 255);
gDPPipeSync(dlHead++);
*dl = dlHead;
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef __FASTTEXT_H__
#define __FASTTEXT_H__
void drawSmallString_impl(Gfx**, int, int, const char*, int, int , int);
static inline void drawSmallString(Gfx **dl, int x, int y, const char* string) {
drawSmallString_impl(dl, x, y, string, 255, 255, 255);
}
static inline void drawSmallStringCol(Gfx **dl, int x, int y, const char* string, int r, int g, int b) {
drawSmallString_impl(dl, x, y, string, r, g, b);
}
#endif
+8 -29
View File
@@ -30,6 +30,7 @@
#include "debug_box.h"
#include "vc_check.h"
#include "vc_ultra.h"
#include "profiling.h"
// First 3 controller slots
struct Controller gControllers[3];
@@ -45,6 +46,7 @@ OSContStatus gControllerStatuses[4];
OSContPad gControllerPads[4];
u8 gControllerBits;
u8 gIsConsole = TRUE; // Needs to be initialized before audio_reset_session is called
u8 gCacheEmulated = TRUE;
u8 gBorderHeight;
#ifdef VANILLA_STYLE_CUSTOM_DEBUG
u8 gCustomDebugMode;
@@ -409,7 +411,8 @@ void render_init(void) {
// Skip incrementing the initial framebuffer index on emulators so that they display immediately as the Gfx task finishes
// VC probably emulates osViSwapBuffer accurately so instant patch breaks VC compatibility
if (gIsConsole || gIsVC) { // Read RDP Clock Register, has a value of zero on emulators
// Currently, Ares passes the cache emulation test and has issues with single buffering so disable it there as well.
if (gIsConsole || gIsVC || gCacheEmulated) {
sRenderingFramebuffer++;
}
gGlobalTimer++;
@@ -447,8 +450,8 @@ void display_and_vsync(void) {
#ifndef UNLOCK_FPS
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
#endif
// Skip swapping buffers on emulator so that they display immediately as the Gfx task finishes
if (gIsConsole || gIsVC) { // Read RDP Clock Register, has a value of zero on emulators
// Skip swapping buffers on inaccurate emulators other than VC so that they display immediately as the Gfx task finishes
if (gIsConsole || gIsVC || gCacheEmulated) {
if (++sRenderedFramebuffer == 3) {
sRenderedFramebuffer = 0;
}
@@ -725,10 +728,6 @@ void setup_game_memory(void) {
* Main game loop thread. Runs forever as long as the game continues.
*/
void thread5_game_loop(UNUSED void *arg) {
#if PUPPYPRINT_DEBUG
OSTime lastTime = 0;
#endif
setup_game_memory();
#if ENABLE_RUMBLE
init_rumble_pak_scheduler_queue();
@@ -758,19 +757,12 @@ void thread5_game_loop(UNUSED void *arg) {
render_init();
while (TRUE) {
profiler_frame_setup();
// If the reset timer is active, run the process to reset the game.
if (gResetTimer != 0) {
draw_reset_bars();
continue;
}
#if PUPPYPRINT_DEBUG
while (TRUE) {
lastTime = osGetTime();
collisionTime[perfIteration] = 0;
// graphTime[perfIteration] = 0;
behaviourTime[perfIteration] = 0;
dmaTime[perfIteration] = 0;
#endif
// If any controllers are plugged in, start read the data for when
// read_controller_inputs is called later.
@@ -784,25 +776,12 @@ void thread5_game_loop(UNUSED void *arg) {
audio_game_loop_tick();
select_gfx_pool();
read_controller_inputs(THREAD_5_GAME_LOOP);
profiler_update(PROFILER_TIME_CONTROLLERS);
addr = level_script_execute(addr);
#if !PUPPYPRINT_DEBUG && defined(VISUAL_DEBUG)
debug_box_input();
#endif
#if PUPPYPRINT_DEBUG
profiler_update(scriptTime, lastTime);
scriptTime[perfIteration] -= profilerTime[perfIteration];
scriptTime[perfIteration] -= profilerTime2[perfIteration];
if (benchmarkLoop > 0 && benchOption == 0) {
benchmarkLoop--;
benchMark[benchmarkLoop] = (osGetTime() - lastTime);
if (benchmarkLoop == 0) {
puppyprint_profiler_finished();
break;
}
} else {
break;
}
}
puppyprint_profiler_process();
#endif
+1
View File
@@ -48,6 +48,7 @@ extern u8 *gGfxPoolEnd;
extern struct GfxPool *gGfxPool;
extern u8 gControllerBits;
extern u8 gIsConsole;
extern u8 gCacheEmulated;
extern u8 gBorderHeight;
#ifdef VANILLA_STYLE_CUSTOM_DEBUG
extern u8 gCustomDebugMode;
+12 -13
View File
@@ -26,11 +26,6 @@
* cannon reticle, and the unused keys.
**/
#define HUD_POWER_METER_X 140
#define HUD_POWER_METER_EMPHASIZED_Y 166
#define HUD_POWER_METER_Y 200
#define HUD_POWER_METER_HIDDEN_Y 300
#ifdef BREATH_METER
// #ifdef DISABLE_LIVES
// #define HUD_BREATH_METER_X 64
@@ -52,6 +47,9 @@ u8 curFrameTimeIndex = 0;
#include "PR/os_convert.h"
#ifdef USE_PROFILER
float profiler_get_fps();
#else
// Call once per frame
f32 calculate_and_update_fps() {
OSTime newTime = osGetTime();
@@ -64,9 +62,14 @@ f32 calculate_and_update_fps() {
}
return ((f32)FRAMETIME_COUNT * 1000000.0f) / (s32)OS_CYCLES_TO_USEC(newTime - oldTime);
}
#endif
void print_fps(s32 x, s32 y) {
#ifdef USE_PROFILER
f32 fps = profiler_get_fps();
#else
f32 fps = calculate_and_update_fps();
#endif
char text[14];
sprintf(text, "FPS %2.2f", fps);
@@ -75,7 +78,6 @@ void print_fps(s32 x, s32 y) {
#else
print_text(x, y, text);
#endif
}
// ------------ END OF FPS COUNER -----------------
@@ -388,7 +390,6 @@ void render_hud_breath_meter(void) {
}
#endif
#define HUD_TOP_Y 209
/**
* Renders the amount of lives Mario has.
@@ -415,13 +416,11 @@ void render_debug_mode(void) {
* Renders the amount of coins collected.
*/
void render_hud_coins(void) {
print_text(168, HUD_TOP_Y, "$"); // 'Coin' glyph
print_text(184, HUD_TOP_Y, "*"); // 'X' glyph
print_text_fmt_int(198, HUD_TOP_Y, "%d", gHudDisplay.coins);
print_text(HUD_COINS_X, HUD_TOP_Y, "$"); // 'Coin' glyph
print_text((HUD_COINS_X + 16), HUD_TOP_Y, "*"); // 'X' glyph
print_text_fmt_int((HUD_COINS_X + 30), HUD_TOP_Y, "%d", gHudDisplay.coins);
}
#define HUD_STARS_X 78
/**
* Renders the amount of stars collected.
* Disables "X" glyph when Mario has 100 stars or more.
@@ -491,7 +490,7 @@ void set_hud_camera_status(s16 status) {
*/
void render_hud_camera_status(void) {
Texture *(*cameraLUT)[6] = segmented_to_virtual(&main_hud_camera_lut);
s32 x = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(54);
s32 x = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(HUD_CAMERA_X);
s32 y = 205;
if (sCameraHUD.status == CAM_STATUS_NONE) {
+12
View File
@@ -4,6 +4,18 @@
#include <PR/ultratypes.h>
#include <PR/gbi.h>
#define HUD_POWER_METER_X 140
#define HUD_POWER_METER_EMPHASIZED_Y 166
#define HUD_POWER_METER_Y 200
#define HUD_POWER_METER_HIDDEN_Y 300
#define HUD_TOP_Y 209
#define HUD_BOTTOM_Y 19 // Same height as the Lakitu icon
#define HUD_COINS_X 168
#define HUD_STARS_X 78 // This starts counting from the right edge
#define HUD_CAMERA_X 54 // This starts counting from the right edge
enum PowerMeterAnimation {
POWER_METER_HIDDEN,
POWER_METER_EMPHASIZED,
+7 -3
View File
@@ -87,7 +87,6 @@ enum DialogBoxType {
#define DEFAULT_DIALOG_BOX_ANGLE 90.0f
#define DEFAULT_DIALOG_BOX_SCALE 19.0f
#if defined(VERSION_US) || defined(VERSION_EU)
u8 gDialogCharWidths[256] = { // TODO: Is there a way to auto generate this?
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
6, 6, 5, 6, 6, 5, 8, 8, 6, 6, 6, 6, 6, 5, 6, 6,
@@ -118,7 +117,6 @@ u8 gDialogCharWidths[256] = { // TODO: Is there a way to auto generate this?
#endif
0, 0, 5, 7, 7, 6, 6, 8, 0, 8, 10, 6, 4, 10, 0, 0
};
#endif
s8 gDialogBoxState = DIALOG_STATE_OPENING;
f32 gDialogBoxOpenTimer = DEFAULT_DIALOG_BOX_ANGLE;
@@ -1369,6 +1367,7 @@ void print_peach_letter_message(void) {
void **dialogTable;
gInGameLanguage = eu_get_language();
switch (gInGameLanguage) {
default:
case LANGUAGE_ENGLISH: dialogTable = segmented_to_virtual(dialog_table_eu_en); break;
case LANGUAGE_FRENCH: dialogTable = segmented_to_virtual(dialog_table_eu_fr); break;
case LANGUAGE_GERMAN: dialogTable = segmented_to_virtual(dialog_table_eu_de); break;
@@ -1388,10 +1387,15 @@ void print_peach_letter_message(void) {
gDPSetEnvColor(gDisplayListHead++, 20, 20, 20, gCutsceneMsgFade);
print_generic_string(STR_X, STR_Y, str);
#ifdef VERSION_JP
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
#else
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
gDPSetEnvColor(gDisplayListHead++, 200, 80, 120, gCutsceneMsgFade);
gSPDisplayList(gDisplayListHead++, castle_grounds_seg7_us_dl_0700F2E8);
#endif
// at the start/end of message, reset the fade.
if (gCutsceneMsgTimer == 0) {
@@ -1448,7 +1452,7 @@ void render_hud_cannon_reticle(void) {
gSPDisplayList(gDisplayListHead++, dl_draw_triangle);
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
// gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
}
void reset_red_coins_collected(void) {
-2
View File
@@ -112,11 +112,9 @@ enum DialogSpecialChars {
DIALOG_CHAR_I_NO_DIA = 0xEB, // 'i' without diacritic
DIALOG_CHAR_DOUBLE_LOW_QUOTE = 0xF0, // German opening quotation mark
#endif
#if defined(VERSION_US) || defined(VERSION_EU)
DIALOG_CHAR_SLASH = 0xD0,
DIALOG_CHAR_MULTI_THE = 0xD1, // 'the'
DIALOG_CHAR_MULTI_YOU = 0xD2, // 'you'
#endif
DIALOG_CHAR_PERIOD = 0x6E,
DIALOG_CHAR_COMMA = 0x6F,
DIALOG_CHAR_COLOR = 0xDF,
+6 -2
View File
@@ -764,10 +764,14 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
u32 starIndex;
u32 starGrabAction = ACT_STAR_DANCE_EXIT;
#ifdef NON_STOP_STARS
#ifdef KEYS_EXIT_LEVEL
u32 noExit = !obj_has_model(obj, MODEL_BOWSER_KEY);
#else
u32 noExit = TRUE;
#else
#endif
#else // !NON_STOP_STARS
u32 noExit = (obj->oInteractionSubtype & INT_SUBTYPE_NO_EXIT) != 0;
#endif
#endif // !NON_STOP_STARS
u32 grandStar = (obj->oInteractionSubtype & INT_SUBTYPE_GRAND_STAR) != 0;
if (m->health >= 0x100) {
+12
View File
@@ -65,6 +65,17 @@ const char *credits06[] = { "2COURSE DIRECTORS", "YOICHI YAMADA", "YASUHISA YAMA
const char *credits07[] = { "2COURSE DESIGNERS", "KENTA USUI", "NAOKI MORI" };
const char *credits08[] = { "3COURSE DESIGNERS", "YOSHIKI HARUHANA", "MAKOTO MIYANAGA", "KATSUHIKO KANNO" };
#ifdef VERSION_US
const char *credits09[] = { "1SOUND COMPOSER", "KOJI KONDO" };
// ...as well as sound effects and sound programmer in order to make room for screen text writer, Mario voice, and Peach voice
const char *credits10[] = { "4SOUND EFFECTS", "SOUND PROGRAMMER", "YOJI INAGAKI", "HIDEAKI SHIMIZU" };
const char *credits11[] = { "23-D ANIMATORS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA" };
const char *credits12[] = { "1ADDITIONAL GRAPHICS", "MASANAO ARIMOTO" };
const char *credits13[] = { "3TECHNICAL SUPPORT", "TAKAO SAWANO", "HIROHITO YOSHIMOTO", "HIROTO YADA" };
const char *credits14[] = { "1TECHNICAL SUPPORT", "SGI N64 PROJECT STAFF" };
const char *credits15[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" };
const char *credits16[] = { "5SCREEN TEXT WRITER", "TRANSLATION", "LESLIE SWAN", "MINA AKINO", "HIRO YAMADA" };
#else // VERSION_EU
// ...as well as sound composer, sound effects, and sound programmer, and...
const char *credits09[] = { "7SOUND COMPOSER", "SOUND EFFECTS", "SOUND PROGRAMMER", "KOJI KONDO", "YOJI INAGAKI", "HIDEAKI SHIMIZU" };
// ...3D animators and additional graphics in order to make room for screen text writer(s), Mario voice, and Peach voice
@@ -75,6 +86,7 @@ const char *credits13[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KA
const char *credits14[] = { "5SCREEN TEXT WRITER", "ENGLISH TRANSLATION", "LESLIE SWAN", "MINA AKINO", "HIRO YAMADA" };
const char *credits15[] = { "4SCREEN TEXT WRITER", "FRENCH TRANSLATION", "JULIEN BARDAKOFF", "KENJI HARAGUCHI" };
const char *credits16[] = { "4SCREEN TEXT WRITER", "GERMAN TRANSLATION", "THOMAS GOERG", "THOMAS SPINDLER" };
#endif
#endif
+8 -23
View File
@@ -28,7 +28,7 @@ void play_far_fall_sound(struct MarioState *m) {
u32 action = m->action;
if (!(action & ACT_FLAG_INVULNERABLE) && action != ACT_TWIRLING && action != ACT_FLYING
&& !(m->flags & MARIO_FALL_SOUND_PLAYED)) {
if (m->peakHeight - m->pos[1] > 1150.0f) {
if (m->peakHeight - m->pos[1] > FALL_DAMAGE_HEIGHT_SMALL) {
play_sound(SOUND_MARIO_WAAAOOOW, m->marioObj->header.gfx.cameraToObject);
m->flags |= MARIO_FALL_SOUND_PLAYED;
}
@@ -63,30 +63,14 @@ s32 check_fall_damage(struct MarioState *m, u32 hardFallAction) {
#ifdef NO_FALL_DAMAGE
return FALSE;
#endif
f32 fallHeight;
f32 damageHeight;
fallHeight = m->peakHeight - m->pos[1];
f32 fallHeight = m->peakHeight - m->pos[1];
#pragma GCC diagnostic push
#if defined(__clang__)
#pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif
//! Never true
if (m->actionState == ACT_GROUND_POUND) {
damageHeight = 600.0f;
} else {
damageHeight = 1150.0f;
}
#pragma GCC diagnostic pop
f32 damageHeight = FALL_DAMAGE_HEIGHT_SMALL;
if (m->action != ACT_TWIRLING && m->floor->type != SURFACE_BURNING) {
if (m->vel[1] < -55.0f) {
if (fallHeight > 3000.0f) {
if (fallHeight > FALL_DAMAGE_HEIGHT_LARGE) {
m->hurtCounter += (m->flags & MARIO_CAP_ON_HEAD) ? 16 : 24;
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
@@ -116,11 +100,12 @@ s32 check_kick_or_dive_in_air(struct MarioState *m) {
return FALSE;
}
s32 should_get_stuck_in_ground(struct MarioState *m) {
#ifdef NO_GETTING_BURIED
s32 should_get_stuck_in_ground(UNUSED struct MarioState *m) {
return FALSE;
}
#else
s32 should_get_stuck_in_ground(struct MarioState *m) {
u32 terrainType = m->area->terrainType & TERRAIN_MASK;
struct Surface *floor = m->floor;
s32 flags = floor->flags;
@@ -134,8 +119,8 @@ s32 should_get_stuck_in_ground(struct MarioState *m) {
}
return FALSE;
#endif
}
#endif
s32 check_fall_damage_or_get_stuck(struct MarioState *m, u32 hardFallAction) {
if (should_get_stuck_in_ground(m)) {
+15 -3
View File
@@ -582,15 +582,27 @@ s32 act_debug_free_move(struct MarioState *m) {
}
void general_star_dance_handler(struct MarioState *m, s32 isInWater) {
struct Object *celebStar = NULL;
if (m->actionState == ACT_STATE_STAR_DANCE_CUTSCENE) {
switch (++m->actionTimer) {
case 1:
spawn_object(m->marioObj, MODEL_STAR, bhvCelebrationStar);
celebStar = spawn_object(m->marioObj, MODEL_STAR, bhvCelebrationStar);
#ifdef STAR_DANCE_USES_STARS_MODEL
celebStar->header.gfx.sharedChild = m->interactObj->header.gfx.sharedChild;
#else
if (obj_has_model(m->interactObj, MODEL_BOWSER_KEY)) {
obj_set_model(celebStar, MODEL_BOWSER_KEY);
}
#endif
disable_background_sound();
//! TODO: Is this check necessary? Both seem to do the exact same thing.
if (m->actionArg & 1) {
play_course_clear();
// No exit
play_course_clear(obj_has_model(celebStar, MODEL_BOWSER_KEY));
} else {
if (gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2) {
// Exit
if (obj_has_model(celebStar, MODEL_BOWSER_KEY)) {
play_music(SEQ_PLAYER_ENV, SEQUENCE_ARGS(15, SEQ_EVENT_CUTSCENE_COLLECT_KEY), 0);
} else {
play_music(SEQ_PLAYER_ENV, SEQUENCE_ARGS(15, SEQ_EVENT_CUTSCENE_COLLECT_STAR), 0);
Binary file not shown.
+12 -20
View File
@@ -21,6 +21,7 @@
#include "spawn_object.h"
#include "puppyprint.h"
#include "puppylights.h"
#include "profiling.h"
/**
@@ -547,7 +548,10 @@ void clear_objects(void) {
*/
void update_terrain_objects(void) {
gObjectCounter = update_objects_in_list(&gObjectLists[OBJ_LIST_SPAWNER]);
profiler_update(PROFILER_TIME_SPAWNER);
gObjectCounter += update_objects_in_list(&gObjectLists[OBJ_LIST_SURFACE]);
profiler_update(PROFILER_TIME_DYNAMIC);
}
/**
@@ -559,7 +563,13 @@ void update_non_terrain_objects(void) {
s32 i = 2;
while ((listIndex = sObjectListUpdateOrder[i]) != -1) {
if (listIndex == OBJ_LIST_PLAYER) {
profiler_update(PROFILER_TIME_BEHAVIOR_BEFORE_MARIO);
}
gObjectCounter += update_objects_in_list(&gObjectLists[listIndex]);
if (listIndex == OBJ_LIST_PLAYER) {
profiler_update(PROFILER_TIME_MARIO);
}
i++;
}
}
@@ -606,13 +616,6 @@ UNUSED static u16 unused_get_elapsed_time(u64 *cycleCounts, s32 index) {
* and object surface management.
*/
void update_objects(UNUSED s32 unused) {
//s64 cycleCounts[30];
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
OSTime colTime = collisionTime[perfIteration];
#endif
// cycleCounts[0] = get_current_clock();
gTimeStopState &= ~TIME_STOP_MARIO_OPENED_DOOR;
@@ -626,11 +629,9 @@ void update_objects(UNUSED s32 unused) {
gObjectLists = gObjectListArray;
// If time stop is not active, unload object surfaces
// cycleCounts[1] = get_clock_difference(cycleCounts[0]);
clear_dynamic_surfaces();
// Update spawners and objects with surfaces
// cycleCounts[2] = get_clock_difference(cycleCounts[0]);
update_terrain_objects();
// If Mario was touching a moving platform at the end of last frame, apply
@@ -640,24 +641,17 @@ void update_objects(UNUSED s32 unused) {
apply_mario_platform_displacement();
// Detect which objects are intersecting
// cycleCounts[3] = get_clock_difference(cycleCounts[0]);
detect_object_collisions();
// Update all other objects that haven't been updated yet
// cycleCounts[4] = get_clock_difference(cycleCounts[0]);
update_non_terrain_objects();
// Unload any objects that have been deactivated
// cycleCounts[5] = get_clock_difference(cycleCounts[0]);
unload_deactivated_objects();
// Check if Mario is on a platform object and save this object
// cycleCounts[6] = get_clock_difference(cycleCounts[0]);
update_mario_platform();
// cycleCounts[7] = get_clock_difference(cycleCounts[0]);
// cycleCounts[0] = 0;
try_print_debug_mario_object_info();
// If time stop was enabled this frame, activate it now so that it will
@@ -669,8 +663,6 @@ void update_objects(UNUSED s32 unused) {
}
gPrevFrameObjectCount = gObjectCounter;
#if PUPPYPRINT_DEBUG
profiler_update(behaviourTime, first);
behaviourTime[perfIteration] -= collisionTime[perfIteration] - colTime;
#endif
profiler_update(PROFILER_TIME_BEHAVIOR_AFTER_MARIO);
}
+279
View File
@@ -0,0 +1,279 @@
#include <ultra64.h>
#include <PR/os_internal_reg.h>
#include "game_init.h"
#include "profiling.h"
#include "fasttext.h"
#ifdef USE_PROFILER
#define RDP_CYCLE_CONV(x) ((10 * (x)) / 625) // 62.5 million cycles per frame
typedef struct {
u32 counts[PROFILING_BUFFER_SIZE];
u32 total;
} ProfileTimeData;
ProfileTimeData all_profiling_data[PROFILER_TIME_COUNT];
int profile_buffer_index = -1;
int rsp_buffer_indices[PROFILER_RSP_COUNT];
// Holds either the start time if the task is running, or the amount of time the task has run for so far if yielded
u32 rsp_pending_times[PROFILER_RSP_COUNT];
u32 prev_start;
u32 start;
u32 prev_time;
u32 audio_start;
u32 audio_buffer_index;
u32 preempted_time;
static void buffer_update(ProfileTimeData* data, u32 new, int buffer_index) {
u32 old = data->counts[buffer_index];
data->total -= old;
data->total += new;
data->counts[buffer_index] = new;
}
void profiler_update(enum ProfilerTime which) {
u32 cur_time = osGetCount();
u32 diff;
ProfileTimeData* cur_data = &all_profiling_data[which];
diff = cur_time - prev_time;
u32 saved = __osDisableInt();
u32 cur_preempted_time = preempted_time;
preempted_time = 0;
__osRestoreInt(saved);
if (cur_preempted_time > 0) {
diff -= cur_preempted_time;
start += cur_preempted_time;
}
buffer_update(cur_data, diff, profile_buffer_index);
prev_time = cur_time;
}
void profiler_rsp_started(enum ProfilerRSPTime which) {
rsp_pending_times[which] = osGetCount();
}
void profiler_rsp_completed(enum ProfilerRSPTime which) {
ProfileTimeData* cur_data = &all_profiling_data[PROFILER_TIME_RSP_GFX + which];
int cur_index = rsp_buffer_indices[which];
u32 time = osGetCount() - rsp_pending_times[which];
rsp_pending_times[which] = 0;
buffer_update(cur_data, time, cur_index);
cur_index++;
if (cur_index >= PROFILING_BUFFER_SIZE) {
cur_index = 0;
}
rsp_buffer_indices[which] = cur_index;
}
void profiler_rsp_resumed() {
rsp_pending_times[PROFILER_RSP_GFX] = osGetCount() - rsp_pending_times[PROFILER_RSP_GFX];
}
// This ends up being the same math as resumed, so we just use resumed for both
// void profiler_rsp_yielded() {
// rsp_pending_times[PROFILER_RSP_GFX] = osGetCount() - rsp_pending_times[PROFILER_RSP_GFX];
// }
void profiler_audio_started() {
audio_start = osGetCount();
}
void profiler_audio_completed() {
ProfileTimeData* cur_data = &all_profiling_data[PROFILER_TIME_AUDIO];
u32 time = osGetCount() - audio_start;
u32 cur_index = audio_buffer_index;
preempted_time = time;
buffer_update(cur_data, time, cur_index);
cur_index++;
if (cur_index >= PROFILING_BUFFER_SIZE) {
cur_index = 0;
}
audio_buffer_index = cur_index;
}
static void update_fps_timer() {
u32 diff = start - prev_start;
buffer_update(&all_profiling_data[PROFILER_TIME_FPS], diff, profile_buffer_index);
prev_start = start;
}
static void update_total_timer() {
u32 saved = __osDisableInt();
u32 cur_preempted_time = preempted_time;
preempted_time = 0;
__osRestoreInt(saved);
prev_time = start + cur_preempted_time;
profiler_update(PROFILER_TIME_TOTAL);
}
static void update_rdp_timers() {
u32 tmem = IO_READ(DPC_TMEM_REG);
u32 cmd = IO_READ(DPC_BUFBUSY_REG);
u32 pipe = IO_READ(DPC_PIPEBUSY_REG);
if (gGlobalTimer > 5) {
IO_WRITE(DPC_STATUS_REG, (DPC_CLR_CLOCK_CTR | DPC_CLR_CMD_CTR | DPC_CLR_PIPE_CTR | DPC_CLR_TMEM_CTR));
}
buffer_update(&all_profiling_data[PROFILER_TIME_TMEM], tmem, profile_buffer_index);
buffer_update(&all_profiling_data[PROFILER_TIME_CMD], cmd, profile_buffer_index);
buffer_update(&all_profiling_data[PROFILER_TIME_PIPE], pipe, profile_buffer_index);
}
#ifdef PUPPYPRINT_DEBUG
extern u8 sPPDebugPage;
extern u8 fDebug;
#endif
float profiler_get_fps() {
return (1000000.0f * PROFILING_BUFFER_SIZE) / (OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_FPS].total));
}
u32 profiler_get_cpu_cycles() {
u32 cpu_normal_time = all_profiling_data[PROFILER_TIME_TOTAL].total / PROFILING_BUFFER_SIZE;
u32 cpu_audio_time = all_profiling_data[PROFILER_TIME_AUDIO].total / PROFILING_BUFFER_SIZE;
return cpu_normal_time + cpu_audio_time * 2;
}
u32 profiler_get_rsp_cycles() {
u32 rsp_graphics_time = all_profiling_data[PROFILER_TIME_RSP_GFX].total / PROFILING_BUFFER_SIZE;
u32 rsp_audio_time = all_profiling_data[PROFILER_TIME_RSP_AUDIO].total / PROFILING_BUFFER_SIZE;
return rsp_graphics_time + rsp_audio_time;
}
u32 profiler_get_rdp_cycles() {
u32 rdp_pipe_cycles = all_profiling_data[PROFILER_TIME_PIPE].total;
u32 rdp_tmem_cycles = all_profiling_data[PROFILER_TIME_TMEM].total;
u32 rdp_cmd_cycles = all_profiling_data[PROFILER_TIME_CMD].total;
u32 rdp_max_cycles = MAX(MAX(rdp_pipe_cycles, rdp_tmem_cycles), rdp_cmd_cycles);
return rdp_max_cycles / PROFILING_BUFFER_SIZE;
}
u32 profiler_get_cpu_microseconds() {
u32 cpu_normal_time = OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_TOTAL].total / PROFILING_BUFFER_SIZE);
u32 cpu_audio_time = OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_AUDIO].total / PROFILING_BUFFER_SIZE);
return cpu_normal_time + cpu_audio_time * 2;
}
u32 profiler_get_rsp_microseconds() {
u32 rsp_graphics_time = OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_RSP_GFX].total / PROFILING_BUFFER_SIZE);
u32 rsp_audio_time = OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_RSP_AUDIO].total / PROFILING_BUFFER_SIZE);
return rsp_graphics_time + rsp_audio_time;
}
u32 profiler_get_rdp_microseconds() {
u32 rdp_pipe_cycles = all_profiling_data[PROFILER_TIME_PIPE].total;
u32 rdp_tmem_cycles = all_profiling_data[PROFILER_TIME_TMEM].total;
u32 rdp_cmd_cycles = all_profiling_data[PROFILER_TIME_CMD].total;
u32 rdp_max_cycles = MAX(MAX(rdp_pipe_cycles, rdp_tmem_cycles), rdp_cmd_cycles);
return RDP_CYCLE_CONV(rdp_max_cycles / PROFILING_BUFFER_SIZE);
}
void profiler_print_times() {
u32 microseconds[PROFILER_TIME_COUNT];
char text_buffer[196];
update_fps_timer();
update_total_timer();
update_rdp_timers();
#ifndef PUPPYPRINT_DEBUG
static u8 show_profiler = 0;
if (gPlayer1Controller->buttonPressed & L_TRIG) {
show_profiler ^= 1;
}
#endif
#ifdef PUPPYPRINT_DEBUG
if (fDebug && sPPDebugPage == 0) {
#else
if (show_profiler) {
#endif
for (int i = 0; i < PROFILER_TIME_COUNT; i++) {
if (i < PROFILER_TIME_TMEM) {
microseconds[i] = OS_CYCLES_TO_USEC(all_profiling_data[i].total / PROFILING_BUFFER_SIZE);
} else {
microseconds[i] = RDP_CYCLE_CONV(all_profiling_data[i].total / PROFILING_BUFFER_SIZE);
}
}
// audio time is removed from the main thread profiling, so add it back here
u32 total_cpu = microseconds[PROFILER_TIME_TOTAL] + microseconds[PROFILER_TIME_AUDIO] * 2;
u32 total_rsp = microseconds[PROFILER_TIME_RSP_GFX] + microseconds[PROFILER_TIME_RSP_AUDIO];
u32 max_rdp = MAX(MAX(microseconds[PROFILER_TIME_TMEM], microseconds[PROFILER_TIME_CMD]), microseconds[PROFILER_TIME_PIPE]);
sprintf(text_buffer,
"FPS: %5.2f\n"
"\n"
"CPU\t\t%d (%d%%)\n"
" Input\t\t%d\n"
" Dynamic\t\t%d\n"
" Mario\t\t\t%d\n"
" Behavior\t\t%d\n"
" Graph\t\t%d\n"
" Audio\t\t\t%d\n"
"\n"
"RDP\t\t%d (%d%%)\n"
" Tmem\t\t\t%d\n"
" Cmd\t\t\t%d\n"
" Pipe\t\t\t%d\n"
"\n"
"RSP\t\t%d (%d%%)\n"
" Gfx\t\t\t%d\n"
" Audio\t\t\t%d\n",
1000000.0f / microseconds[PROFILER_TIME_FPS],
total_cpu, total_cpu / 333,
microseconds[PROFILER_TIME_CONTROLLERS],
microseconds[PROFILER_TIME_DYNAMIC],
microseconds[PROFILER_TIME_MARIO],
microseconds[PROFILER_TIME_BEHAVIOR_BEFORE_MARIO] + microseconds[PROFILER_TIME_BEHAVIOR_AFTER_MARIO],
microseconds[PROFILER_TIME_GFX],
microseconds[PROFILER_TIME_AUDIO] * 2, // audio is 60Hz, so double the average
max_rdp, max_rdp / 333,
microseconds[PROFILER_TIME_TMEM],
microseconds[PROFILER_TIME_CMD],
microseconds[PROFILER_TIME_PIPE],
total_rsp, total_rsp / 333,
microseconds[PROFILER_TIME_RSP_GFX],
microseconds[PROFILER_TIME_RSP_AUDIO]
);
Gfx* dlHead = gDisplayListHead;
gDPPipeSync(dlHead++);
gDPSetCycleType(dlHead++, G_CYC_1CYCLE);
gDPSetRenderMode(dlHead++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
gDPSetTexturePersp(dlHead++, G_TP_NONE);
gDPSetTextureFilter(dlHead++, G_TF_POINT);
gDPSetTextureLUT(dlHead++, G_TT_NONE);
drawSmallStringCol(&dlHead, 10, 10, text_buffer, 255, 255, 255);
gDisplayListHead = dlHead;
}
}
void profiler_frame_setup() {
profile_buffer_index++;
preempted_time = 0;
if (profile_buffer_index >= PROFILING_BUFFER_SIZE) {
profile_buffer_index = 0;
}
prev_time = start = osGetCount();
}
#endif
+61
View File
@@ -0,0 +1,61 @@
#ifndef __PROFILING_H__
#define __PROFILING_H__
#include <ultra64.h>
#include "macros.h"
#include "config/config_debug.h"
#include "config/config_safeguards.h"
#define PROFILING_BUFFER_SIZE 64
enum ProfilerTime {
PROFILER_TIME_FPS,
PROFILER_TIME_CONTROLLERS,
PROFILER_TIME_SPAWNER,
PROFILER_TIME_DYNAMIC,
PROFILER_TIME_BEHAVIOR_BEFORE_MARIO,
PROFILER_TIME_MARIO,
PROFILER_TIME_BEHAVIOR_AFTER_MARIO,
PROFILER_TIME_GFX,
PROFILER_TIME_AUDIO,
PROFILER_TIME_TOTAL,
PROFILER_TIME_RSP_GFX,
PROFILER_TIME_RSP_AUDIO,
PROFILER_TIME_TMEM,
PROFILER_TIME_PIPE,
PROFILER_TIME_CMD,
PROFILER_TIME_COUNT,
};
enum ProfilerRSPTime {
PROFILER_RSP_GFX,
PROFILER_RSP_AUDIO,
PROFILER_RSP_COUNT
};
#ifdef USE_PROFILER
void profiler_update(enum ProfilerTime which);
void profiler_print_times();
void profiler_frame_setup();
void profiler_rsp_started(enum ProfilerRSPTime which);
void profiler_rsp_completed(enum ProfilerRSPTime which);
void profiler_rsp_resumed();
void profiler_audio_started();
void profiler_audio_completed();
// See profiling.c to see why profiler_rsp_yielded isn't its own function
static ALWAYS_INLINE void profiler_rsp_yielded() {
profiler_rsp_resumed();
}
#else
#define profiler_update(which)
#define profiler_print_times()
#define profiler_frame_setup()
#define profiler_rsp_started(which)
#define profiler_rsp_completed(which)
#define profiler_rsp_resumed()
#define profiler_audio_started()
#define profiler_audio_completed()
#define profiler_rsp_yielded()
#endif
#endif
+2
View File
@@ -1204,6 +1204,8 @@ static void puppycam_script(void) {
gPuppyCam.yaw = volume.angles->yaw;
gPuppyCam.flags &= ~PUPPYCAM_BEHAVIOUR_YAW_ROTATION;
} else {
gPuppyCam.yaw = atan2s(gPuppyCam.pos[2] - gPuppyCam.focus[2], gPuppyCam.pos[0] - gPuppyCam.focus[0]);
}
if (volume.angles->pitch != PUPPY_NULL) {
+2 -2
View File
@@ -34,13 +34,13 @@
#include "include/command_macros_base.h"
#define PUPPYVOLUME(x, y, z, length, height, width, yaw, functionptr, anglesptr, addflags, removeflags, flagpersistance, room, shape, fov) \
CMD_BBH(0x3D, 0x24, x), \
CMD_BBH(0x3D, 0x28, x), \
CMD_HHHHHH(y, z, length, height, width, yaw), \
CMD_PTR(functionptr), \
CMD_PTR(anglesptr), \
CMD_W(addflags), \
CMD_W(removeflags), \
CMD_BBH(flagpersistance, shape, room) \
CMD_BBH(flagpersistance, shape, room), \
CMD_BBH(fov, 0x0, 0x0)
struct gPuppyOptions
+56 -191
View File
@@ -68,34 +68,9 @@ s32 benchmarkTimer = 0;
s32 benchmarkProgramTimer = 0;
s8 benchmarkType = 0;
// General
u32 cpuTime = 0;
u32 rspTime = 0;
u32 rdpTime = 0;
u32 ramTime = 0;
u32 loadTime = 0;
u32 gLastOSTime = 0;
u32 rspDelta = 0;
s32 benchMark[NUM_BENCH_ITERATIONS + 2];
// CPU
u32 collisionTime[NUM_PERF_ITERATIONS + 1];
u32 behaviourTime[NUM_PERF_ITERATIONS + 1];
u32 scriptTime[NUM_PERF_ITERATIONS + 1];
u32 graphTime[NUM_PERF_ITERATIONS + 1];
u32 audioTime[NUM_PERF_ITERATIONS + 1];
u32 dmaTime[NUM_PERF_ITERATIONS + 1];
u32 dmaAudioTime[NUM_PERF_ITERATIONS + 1];
u32 faultTime[NUM_PERF_ITERATIONS + 1];
u32 taskTime[NUM_PERF_ITERATIONS + 1];
u32 profilerTime[NUM_PERF_ITERATIONS + 1];
u32 profilerTime2[NUM_PERF_ITERATIONS + 1];
u32 cameraTime[NUM_PERF_ITERATIONS + 1];
// RSP
u32 audioTime[NUM_PERF_ITERATIONS + 1];
u32 rspGenTime[NUM_PERF_ITERATIONS + 1];
// RDP
u32 bufferTime[NUM_PERF_ITERATIONS + 1];
u32 tmemTime[NUM_PERF_ITERATIONS + 1];
u32 busTime[NUM_PERF_ITERATIONS + 1];
// RAM
s8 ramViewer = FALSE;
s32 ramsizeSegment[NUM_TLB_SEGMENTS + 1] = {
@@ -306,6 +281,7 @@ void print_ram_overview(void) {
sprintf(textBytes, "RAM: %06X/%06X (%d_)", main_pool_available(), mempool, (s32)(((f32)main_pool_available() / (f32)mempool) * 100));
print_small_text(SCREEN_CENTER_X, (SCREEN_HEIGHT - 16), textBytes, PRINT_TEXT_ALIGN_CENTRE, PRINT_ALL, FONT_OUTLINE);
puppyprint_calculate_ram_usage();
print_ram_bar();
}
@@ -477,12 +453,6 @@ extern s16 gVisualSurfaceCount;
void puppyprint_render_collision(void) {
char textBytes[200];
#ifdef PUPPYPRINT_DEBUG_CYCLES
sprintf(textBytes, "Collision:<COL_99505099> %dc", collisionTime[NUM_PERF_ITERATIONS]);
#else
sprintf(textBytes, "Collision:<COL_99505099> %dus", collisionTime[NUM_PERF_ITERATIONS]);
#endif
print_small_text(304, 48, textBytes, PRINT_TEXT_ALIGN_RIGHT, PRINT_ALL, 1);
sprintf(textBytes, "Pool Size: %X#Node Size: %X#Surfaces Allocated: %d#Nodes Allocated: %d#Current Cell: %d", (SURFACE_NODE_POOL_SIZE * sizeof(struct SurfaceNode)), (SURFACE_POOL_SIZE * sizeof(struct Surface)),
gSurfacesAllocated, gSurfaceNodesAllocated, gVisualSurfaceCount);
@@ -512,55 +482,47 @@ void puppyprint_render_collision(void) {
#endif
}
struct CPUBar {
u32 *time;
ColorRGB colour;
const char str[32];
};
extern void print_fps(s32 x, s32 y);
struct CPUBar cpu_ordering_table[] = {
{ collisionTime, COLOR_RGB_RED, { "Collision: <COL_99505099>" }},
{ graphTime, COLOR_RGB_BLUE, { "Graph: <COL_50509999>" }},
{ behaviourTime, COLOR_RGB_GREEN, { "Behaviour: <COL_50995099>" }},
{ audioTime, COLOR_RGB_YELLOW, { "Audio: <COL_99995099>" }},
{ cameraTime, COLOR_RGB_CYAN, { "Camera: <COL_50999999>" }},
{ dmaTime, COLOR_RGB_MAGENTA, { "DMA: <COL_99509999>" }},
};
u32 profiler_get_cpu_cycles();
u32 profiler_get_rsp_cycles();
u32 profiler_get_rdp_cycles();
#define CPU_TABLE_MAX (sizeof(cpu_ordering_table) / sizeof(struct CPUBar))
#define ADDTIMES MAX(((collisionTime[MX] + graphTime[MX] + behaviourTime[MX] + audioTime[MX] + cameraTime[MX] + dmaTime[MX]) / 80), 1)
u32 profiler_get_cpu_microseconds();
u32 profiler_get_rsp_microseconds();
u32 profiler_get_rdp_microseconds();
void print_basic_profiling(void) {
u32 cpuTime;
u32 rspTime;
u32 rdpTime;
char textBytes[90];
print_fps(16, 40);
print_fps(16, 16);
#ifdef PUPPYPRINT_DEBUG_CYCLES
cpuTime = profiler_get_cpu_cycles();
rspTime = profiler_get_rsp_cycles();
rdpTime = profiler_get_rdp_cycles();
sprintf(textBytes, "CPU: %dc (%d_)#RSP: %dc (%d_)#RDP: %dc (%d_)",
cpuTime, (cpuTime / 15625),
rspTime, (rspTime / 15625),
rdpTime, (rdpTime / 15625));
#else
cpuTime = profiler_get_cpu_microseconds();
rspTime = profiler_get_rsp_microseconds();
rdpTime = profiler_get_rdp_microseconds();
sprintf(textBytes, "CPU: %dus (%d_)#RSP: %dus (%d_)#RDP: %dus (%d_)",
cpuTime, (cpuTime / 333),
rspTime, (rspTime / 333),
rdpTime, (rdpTime / 333));
#endif
print_small_text(16, 52, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
print_small_text(16, 28, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
}
void puppyprint_render_standard(void) {
s32 perfPercentage[CPU_TABLE_MAX];
s32 graphPos;
s32 prevGraph;
u32 i;
s32 viewedNums;
char textBytes[80];
print_basic_profiling();
sprintf(textBytes, "OBJ: %d/%d", gObjectCounter, OBJECT_POOL_CAPACITY);
print_small_text(16, 124, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
print_small_text((SCREEN_WIDTH - 16), 16, textBytes, PRINT_TEXT_ALIGN_RIGHT, PRINT_ALL, FONT_OUTLINE);
#ifndef ENABLE_CREDITS_BENCHMARK
// Very little point printing useless info if Mario doesn't even exist.
@@ -571,7 +533,7 @@ void puppyprint_render_standard(void) {
(s32)(gMarioState->pos[2]),
(u16)(gMarioState->faceAngle[1]),
(u32)(gMarioState->action & ACT_ID_MASK));
print_small_text(16, 140, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
print_small_text((SCREEN_WIDTH - 16), 32, textBytes, PRINT_TEXT_ALIGN_RIGHT, PRINT_ALL, FONT_OUTLINE);
}
// Same for the camera, especially so because this will crash otherwise.
if (gCamera) {
@@ -584,64 +546,47 @@ void puppyprint_render_standard(void) {
}
#endif
// Just to keep screen estate a little friendlier.
#define MX NUM_PERF_ITERATIONS
for (i = 0; i < CPU_TABLE_MAX; i++) {
perfPercentage[i] = MAX((cpu_ordering_table[i].time[MX] / ADDTIMES), 0);
}
#undef ADDTIMES
#undef MX
// Old profiler bar code, can be restored one day if desired to work with new profiler
// s32 graphPos;
// s32 prevGraph;
// u32 i;
// s32 viewedNums;
viewedNums = 0;
for (i = 0; i < CPU_TABLE_MAX; i++) {
s32 num = cpu_ordering_table[i].time[NUM_PERF_ITERATIONS];
if (num != 0) {
#ifdef PUPPYPRINT_DEBUG_CYCLES
sprintf(textBytes, "%s%dc", cpu_ordering_table[i].str, num);
#else
sprintf(textBytes, "%s%dus", cpu_ordering_table[i].str, num);
#endif
print_small_text((SCREEN_WIDTH - 16), (40 + (viewedNums * 12)), textBytes, PRINT_TEXT_ALIGN_RIGHT, PRINT_ALL, FONT_OUTLINE);
viewedNums++;
}
}
// prepare_blank_box();
// viewedNums = 0;
s32 barY = (28 + (viewedNums * 12)) + 16;
prepare_blank_box();
viewedNums = 0;
// // Render CPU breakdown bar.
// for (i = 0; i < CPU_TABLE_MAX; i++) {
// if (perfPercentage[i] == 0
// && (i != CPU_TABLE_MAX - 1)) {
// continue;
// }
// Render CPU breakdown bar.
for (i = 0; i < CPU_TABLE_MAX; i++) {
if (perfPercentage[i] == 0
&& (i != CPU_TABLE_MAX - 1)) {
continue;
}
// if (viewedNums == 0) {
// graphPos = ((SCREEN_WIDTH - 96) + perfPercentage[i]);
// render_blank_box((SCREEN_WIDTH - 96), barY, graphPos, (barY + 8),
// cpu_ordering_table[i].colour[0],
// cpu_ordering_table[i].colour[1],
// cpu_ordering_table[i].colour[2], 255);
// } else if (i == (CPU_TABLE_MAX - 1)) {
// graphPos = ((SCREEN_WIDTH - 96) + perfPercentage[i]);
// render_blank_box(prevGraph, barY, (SCREEN_WIDTH - 16), (barY + 8),
// cpu_ordering_table[i].colour[0],
// cpu_ordering_table[i].colour[1],
// cpu_ordering_table[i].colour[2], 255);
// } else {
// graphPos += perfPercentage[i];
// render_blank_box(prevGraph, barY, graphPos, (barY + 8),
// cpu_ordering_table[i].colour[0],
// cpu_ordering_table[i].colour[1],
// cpu_ordering_table[i].colour[2], 255);
// }
if (viewedNums == 0) {
graphPos = ((SCREEN_WIDTH - 96) + perfPercentage[i]);
render_blank_box((SCREEN_WIDTH - 96), barY, graphPos, (barY + 8),
cpu_ordering_table[i].colour[0],
cpu_ordering_table[i].colour[1],
cpu_ordering_table[i].colour[2], 255);
} else if (i == (CPU_TABLE_MAX - 1)) {
graphPos = ((SCREEN_WIDTH - 96) + perfPercentage[i]);
render_blank_box(prevGraph, barY, (SCREEN_WIDTH - 16), (barY + 8),
cpu_ordering_table[i].colour[0],
cpu_ordering_table[i].colour[1],
cpu_ordering_table[i].colour[2], 255);
} else {
graphPos += perfPercentage[i];
render_blank_box(prevGraph, barY, graphPos, (barY + 8),
cpu_ordering_table[i].colour[0],
cpu_ordering_table[i].colour[1],
cpu_ordering_table[i].colour[2], 255);
}
// viewedNums++;
// prevGraph = graphPos;
// }
viewedNums++;
prevGraph = graphPos;
}
finish_blank_box();
// finish_blank_box();
}
void puppyprint_render_minimal(void) {
@@ -686,12 +631,10 @@ void render_page_menu(void) {
}
void puppyprint_render_profiler(void) {
OSTime first = osGetTime();
print_set_envcolour(255, 255, 255, 255);
if (!fDebug) {
profiler_update(profilerTime, first);
return;
}
@@ -700,39 +643,9 @@ void puppyprint_render_profiler(void) {
if (sDebugMenu) {
render_page_menu();
}
profiler_update(profilerTime, first);
}
void profiler_update(u32 *time, OSTime time2) {
time[perfIteration] = (osGetTime() - time2);
}
void get_average_perf_time(u32 *time, s32 is_rdp) {
// This takes all but the last index of the timer array, and creates an average value, which is written to the last index.
s32 i = 0;
s32 total = 0;
for (i = 0; i < NUM_PERF_ITERATIONS; i++) {
total += time[i];
}
total /= NUM_PERF_ITERATIONS;
total = MAX(total, 0);
if (is_rdp)
{
time[NUM_PERF_ITERATIONS] = RDP_CYCLE_CONV(total);
}
else
{
time[NUM_PERF_ITERATIONS] = CYCLE_CONV(total);
}
}
void puppyprint_profiler_process(void) {
bufferTime[perfIteration] = (IO_READ(DPC_BUFBUSY_REG));
tmemTime[perfIteration] = (IO_READ(DPC_TMEM_REG));
busTime[perfIteration] = (IO_READ(DPC_PIPEBUSY_REG));
OSTime newTime = osGetTime();
if (fDebug && (gPlayer1Controller->buttonPressed & L_TRIG)) {
sDebugMenu ^= TRUE;
if (sDebugMenu == FALSE) {
@@ -760,54 +673,6 @@ void puppyprint_profiler_process(void) {
sDebugOption = 0;
}
}
if (!(gGlobalTimer % NUM_PERF_ITERATIONS)) {
get_average_perf_time( scriptTime, FALSE);
get_average_perf_time( behaviourTime, FALSE);
get_average_perf_time( collisionTime, FALSE);
get_average_perf_time( graphTime, FALSE);
get_average_perf_time( audioTime, FALSE);
get_average_perf_time( dmaTime, FALSE);
get_average_perf_time( dmaAudioTime, FALSE);
get_average_perf_time( faultTime, FALSE);
get_average_perf_time( taskTime, FALSE);
get_average_perf_time( profilerTime, FALSE);
get_average_perf_time( profilerTime2, FALSE);
get_average_perf_time( cameraTime, FALSE);
// Performed twice a frame without fail, so doubled to have a more representative value.
audioTime[NUM_PERF_ITERATIONS] *= 2;
dmaAudioTime[NUM_PERF_ITERATIONS] *= 2;
dmaTime[NUM_PERF_ITERATIONS] += dmaAudioTime[NUM_PERF_ITERATIONS];
get_average_perf_time(rspGenTime, FALSE);
get_average_perf_time(bufferTime, TRUE);
get_average_perf_time( tmemTime, TRUE);
get_average_perf_time( busTime, TRUE);
rdpTime = bufferTime[NUM_PERF_ITERATIONS];
rdpTime = MAX(rdpTime, tmemTime[NUM_PERF_ITERATIONS]);
rdpTime = MAX(rdpTime, busTime[NUM_PERF_ITERATIONS]);
#if BBPLAYER == 1 // iQue RDP registers need to be halved to be correct.
rdpTime /= 2;
#endif
cpuTime = (scriptTime[NUM_PERF_ITERATIONS]
+ taskTime[NUM_PERF_ITERATIONS]
+ faultTime[NUM_PERF_ITERATIONS]
+ audioTime[NUM_PERF_ITERATIONS]);
rspTime = rspGenTime[NUM_PERF_ITERATIONS];
puppyprint_calculate_ram_usage();
}
gLastOSTime = newTime;
if (gGlobalTimer > 5) {
IO_WRITE(DPC_STATUS_REG, (DPC_CLR_CLOCK_CTR | DPC_CLR_CMD_CTR | DPC_CLR_PIPE_CTR | DPC_CLR_TMEM_CTR));
}
if (perfIteration++ == (NUM_PERF_ITERATIONS - 1)) {
perfIteration = 0;
}
profiler_update(profilerTime2, newTime);
}
#endif
+1 -36
View File
@@ -2,17 +2,9 @@
#include "segment2.h"
// This is how many indexes of timers are saved at once. higher creates a smoother average, but naturally uses more RAM. 15's fine.
// #define NUM_PERF_ITERATIONS 15
#define NUM_PERF_ITERATIONS 16
#define NUM_BENCH_ITERATIONS 150
#define LOG_BUFFER_SIZE 16
#ifdef ENABLE_CREDITS_BENCHMARK
#undef NUM_PERF_ITERATIONS
#define NUM_PERF_ITERATIONS 60
#endif
struct PuppyPrintPage{
void (*func)();
char name[32];
@@ -58,35 +50,8 @@ extern s32 mempool;
extern u8 benchOption;
// General
extern u32 cpuTime;
extern u32 rspTime;
extern u32 rdpTime;
extern u32 ramTime;
extern u32 loadTime;
extern u32 rspDelta;
extern s32 benchMark[NUM_BENCH_ITERATIONS + 2];
extern s32 benchMark[NUM_BENCH_ITERATIONS + 2];
// CPU
extern u32 collisionTime[NUM_PERF_ITERATIONS + 1];
extern u32 behaviourTime[NUM_PERF_ITERATIONS + 1];
extern u32 scriptTime[NUM_PERF_ITERATIONS + 1];
extern u32 graphTime[NUM_PERF_ITERATIONS + 1];
extern u32 audioTime[NUM_PERF_ITERATIONS + 1];
extern u32 dmaTime[NUM_PERF_ITERATIONS + 1];
extern u32 dmaAudioTime[NUM_PERF_ITERATIONS + 1];
extern u32 faultTime[NUM_PERF_ITERATIONS + 1];
extern u32 taskTime[NUM_PERF_ITERATIONS + 1];
extern u32 cameraTime[NUM_PERF_ITERATIONS + 1];
extern u32 profilerTime[NUM_PERF_ITERATIONS + 1];
extern u32 profilerTime2[NUM_PERF_ITERATIONS + 1];
// RSP
extern u32 rspGenTime[NUM_PERF_ITERATIONS + 1];
// RDP
extern u32 bufferTime[NUM_PERF_ITERATIONS + 1];
extern u32 tmemTime[NUM_PERF_ITERATIONS + 1];
extern u32 busTime[NUM_PERF_ITERATIONS + 1];
extern void profiler_update(u32 *time, OSTime time2);
extern void puppyprint_profiler_process(void);
extern void puppyprint_render_profiler(void);
extern void puppyprint_profiler_finished(void);
+1 -1
View File
@@ -248,7 +248,7 @@ void switch_ucode(s32 ucode) {
switch (ucode) {
default: // GRAPH_NODE_UCODE_DEFAULT
case GRAPH_NODE_UCODE_DEFAULT:
gSPLoadUcodeL(gDisplayListHead++, gspF3DZEX2_PosLight_fifo); // F3DZEX2_PosLight
gSPLoadUcodeL(gDisplayListHead++, gspF3DZEX2_NoN_PosLight_fifo); // F3DZEX2_PosLight
// Reload the necessary RSP settings
gSPDisplayList(gDisplayListHead++, init_rsp);
break;
+9 -10
View File
@@ -368,16 +368,6 @@ void save_file_load_all(void) {
}
#ifdef PUPPYCAM
void puppycam_check_save(void) {
if (gSaveBuffer.menuData.firstBoot != 4
|| gSaveBuffer.menuData.saveOptions.sensitivityX < 5
|| gSaveBuffer.menuData.saveOptions.sensitivityY < 5) {
wipe_main_menu_data();
gSaveBuffer.menuData.firstBoot = 4;
puppycam_default_config();
}
}
void puppycam_get_save(void) {
gPuppyCam.options = gSaveBuffer.menuData.saveOptions;
@@ -401,6 +391,15 @@ void puppycam_set_save(void) {
gMainMenuDataModified = TRUE;
save_main_menu_data();
}
void puppycam_check_save(void) {
if (gSaveBuffer.menuData.firstBoot != 4) {
wipe_main_menu_data();
gSaveBuffer.menuData.firstBoot = 4;
puppycam_default_config();
puppycam_set_save();
}
}
#endif
/**
+8
View File
@@ -12,6 +12,14 @@
*/
enum ShadowType {
#ifdef LEGACY_SHADOW_IDS
LEGACY_SHADOW_CIRCLE_9_VERTS = 0,
LEGACY_SHADOW_CIRCLE_4_VERTS = 1,
LEGACY_SHADOW_CIRCLE_4_VERTS_FLAT_UNUSED = 2,
LEGACY_SHADOW_SQUARE_PERMANENT = 10,
LEGACY_SHADOW_SQUARE_SCALABLE = 11,
LEGACY_SHADOW_SQUARE_TOGGLABLE = 12,
LEGACY_SHADOW_CIRCLE_PLAYER = 99,
SHADOW_CIRCLE = 5,
SHADOW_CIRCLE_PLAYER = SHADOW_CIRCLE,
SHADOW_CIRCLE_4_VERTS = SHADOW_CIRCLE,
+3 -1
View File
@@ -61,7 +61,7 @@ struct Skybox {
struct Skybox sSkyBoxInfo[2];
typedef const Texture *const SkyboxTexture[80 * SKYBOX_SIZE];
typedef const Texture *const SkyboxTexture[80 * sqr(SKYBOX_SIZE)];
extern SkyboxTexture bbh_skybox_ptrlist;
extern SkyboxTexture bidw_skybox_ptrlist;
@@ -290,10 +290,12 @@ Gfx *create_skybox_facing_camera(s8 player, s8 background, f32 fov, Vec3f pos, V
s8 colorIndex = 1;
// If the "Plunder in the Sunken Ship" star in JRB is collected, make the sky darker and slightly green
#ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS
if (background == BACKGROUND_ABOVE_CLOUDS
&& !(save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_JRB)) & STAR_FLAG_ACT_1)) {
colorIndex = 0;
}
#endif
//! fov is always set to 90.0f. If this line is removed, then the game crashes because fov is 0 on
//! the first frame, which causes a floating point divide by 0
+8 -31
View File
@@ -15,6 +15,7 @@
#include "sound_init.h"
#include "rumble_init.h"
#include "puppyprint.h"
#include "profiling.h"
#include "config/config_audio.h"
@@ -359,10 +360,6 @@ void thread4_sound(UNUSED void *arg) {
audio_init();
sound_init();
#if PUPPYPRINT_DEBUG
OSTime lastTime;
#endif
osCreateMesgQueue(&sSoundMesgQueue, sSoundMesgBuf, ARRAY_COUNT(sSoundMesgBuf));
set_vblank_handler(1, &sSoundVblankHandler, &sSoundMesgQueue, (OSMesg) 512);
@@ -370,34 +367,14 @@ void thread4_sound(UNUSED void *arg) {
OSMesg msg;
osRecvMesg(&sSoundMesgQueue, &msg, OS_MESG_BLOCK);
#if PUPPYPRINT_DEBUG
while (TRUE) {
lastTime = osGetTime();
dmaAudioTime[perfIteration] = 0;
#endif
if (gResetTimer < 25) {
struct SPTask *spTask;
spTask = create_next_audio_frame_task();
if (spTask != NULL) {
dispatch_audio_sptask(spTask);
}
#if PUPPYPRINT_DEBUG
profiler_update(audioTime, lastTime);
audioTime[perfIteration] -= dmaAudioTime[perfIteration];
if (benchmarkLoop > 0 && benchOption == 1) {
benchmarkLoop--;
benchMark[benchmarkLoop] = osGetTime() - lastTime;
if (benchmarkLoop == 0) {
puppyprint_profiler_finished();
break;
}
} else {
break;
}
#endif
profiler_audio_started();
if (gResetTimer < 25) {
struct SPTask *spTask;
spTask = create_next_audio_frame_task();
if (spTask != NULL) {
dispatch_audio_sptask(spTask);
}
#if PUPPYPRINT_DEBUG
}
#endif
profiler_audio_completed();
}
}
+2 -1
View File
@@ -1,7 +1,8 @@
#include "version.h"
#include "src/game/version_data.h"
#if 0 // if your PC username isn't your real name feel free to uncomment
char __username__[] = __USERNAME__;
char __datetime__[] = __DATETIME__;
#endif
char __compiler__[] = __COMPILER__;
char __linker__[] = __LINKER__;
+2 -1
View File
@@ -1,8 +1,9 @@
#ifndef VER_H
#define VER_H
#if 0 // if your PC username isn't your real name feel free to uncomment
extern char __username__[];
extern char __datetime__[];
#endif
extern char __compiler__[];
extern char __linker__[];
+71 -163
View File
@@ -122,7 +122,7 @@ unsigned char textEraseFileButton[] = { TEXT_ERASE_FILE_BUTTON };
unsigned char textSoundModes[][8] = { { TEXT_STEREO }, { TEXT_MONO }, { TEXT_HEADSET } };
#if MULTILANG
unsigned char textLanguageSelect[][17] = { { TEXT_LANGUAGE_SELECT }};
unsigned char textLanguageSelect[][17] = { { TEXT_LANGUAGE_SELECT } };
#endif
unsigned char textSoundSelect[] = { TEXT_SOUND_SELECT };
@@ -463,38 +463,44 @@ static const Vec3s sSaveFileButtonPositions[] = {
#define MENU_BUTTON_SCALE 0.11111111f
/**
* Render buttons for the score menu.
* Render buttons for the menu.
* Also check if the save file exists to render a different Mario button.
*/
void render_score_menu_buttons(struct Object *scoreButton) {
void render_menu_buttons(s32 selectedButtonID) {
struct Object *button = sMainMenuButtons[selectedButtonID];
// MENU_BUTTON_SCORE -> 7
// MENU_BUTTON_COPY -> 14
// MENU_BUTTON_ERASE -> 21
s32 idx = (selectedButtonID - 3) * 7;
// File A
sMainMenuButtons[MENU_BUTTON_SCORE_FILE_A] = SPAWN_FILE_SELECT_FILE_BUTTON(scoreButton, SAVE_FILE_A);
sMainMenuButtons[MENU_BUTTON_SCORE_FILE_A]->oMenuButtonScale = MENU_BUTTON_SCALE;
sMainMenuButtons[idx + 0] = SPAWN_FILE_SELECT_FILE_BUTTON(button, SAVE_FILE_A);
sMainMenuButtons[idx + 0]->oMenuButtonScale = MENU_BUTTON_SCALE;
// File B
sMainMenuButtons[MENU_BUTTON_SCORE_FILE_B] = SPAWN_FILE_SELECT_FILE_BUTTON(scoreButton, SAVE_FILE_B);
sMainMenuButtons[MENU_BUTTON_SCORE_FILE_B]->oMenuButtonScale = MENU_BUTTON_SCALE;
sMainMenuButtons[idx + 1] = SPAWN_FILE_SELECT_FILE_BUTTON(button, SAVE_FILE_B);
sMainMenuButtons[idx + 1]->oMenuButtonScale = MENU_BUTTON_SCALE;
// File C
sMainMenuButtons[MENU_BUTTON_SCORE_FILE_C] = SPAWN_FILE_SELECT_FILE_BUTTON(scoreButton, SAVE_FILE_C);
sMainMenuButtons[MENU_BUTTON_SCORE_FILE_C]->oMenuButtonScale = MENU_BUTTON_SCALE;
sMainMenuButtons[idx + 2] = SPAWN_FILE_SELECT_FILE_BUTTON(button, SAVE_FILE_C);
sMainMenuButtons[idx + 2]->oMenuButtonScale = MENU_BUTTON_SCALE;
// File D
sMainMenuButtons[MENU_BUTTON_SCORE_FILE_D] = SPAWN_FILE_SELECT_FILE_BUTTON(scoreButton, SAVE_FILE_D);
sMainMenuButtons[MENU_BUTTON_SCORE_FILE_D]->oMenuButtonScale = MENU_BUTTON_SCALE;
sMainMenuButtons[idx + 3] = SPAWN_FILE_SELECT_FILE_BUTTON(button, SAVE_FILE_D);
sMainMenuButtons[idx + 3]->oMenuButtonScale = MENU_BUTTON_SCALE;
// Return to main menu button
sMainMenuButtons[MENU_BUTTON_SCORE_RETURN] =
spawn_object_rel_with_rot(scoreButton, MODEL_MAIN_MENU_YELLOW_FILE_BUTTON,
sMainMenuButtons[idx + 4] =
spawn_object_rel_with_rot(button, MODEL_MAIN_MENU_YELLOW_FILE_BUTTON,
bhvMenuButton, 711, -388, -100, 0x0, -0x8000, 0x0);
sMainMenuButtons[MENU_BUTTON_SCORE_RETURN]->oMenuButtonScale = MENU_BUTTON_SCALE;
sMainMenuButtons[idx + 4]->oMenuButtonScale = MENU_BUTTON_SCALE;
// Switch to copy menu button
sMainMenuButtons[MENU_BUTTON_SCORE_COPY_FILE] =
spawn_object_rel_with_rot(scoreButton, MODEL_MAIN_MENU_BLUE_COPY_BUTTON,
sMainMenuButtons[idx + 5] =
spawn_object_rel_with_rot(button, selectedButtonID == MENU_BUTTON_SCORE ? MODEL_MAIN_MENU_BLUE_COPY_BUTTON : MODEL_MAIN_MENU_GREEN_SCORE_BUTTON,
bhvMenuButton, 0, -388, -100, 0x0, -0x8000, 0x0);
sMainMenuButtons[MENU_BUTTON_SCORE_COPY_FILE]->oMenuButtonScale = MENU_BUTTON_SCALE;
sMainMenuButtons[idx + 5]->oMenuButtonScale = MENU_BUTTON_SCALE;
// Switch to erase menu button
sMainMenuButtons[MENU_BUTTON_SCORE_ERASE_FILE] =
spawn_object_rel_with_rot(scoreButton, MODEL_MAIN_MENU_RED_ERASE_BUTTON,
sMainMenuButtons[idx + 6] =
spawn_object_rel_with_rot(button, selectedButtonID == MENU_BUTTON_ERASE ? MODEL_MAIN_MENU_BLUE_COPY_BUTTON : MODEL_MAIN_MENU_RED_ERASE_BUTTON,
bhvMenuButton, -711, -388, -100, 0x0, -0x8000, 0x0);
sMainMenuButtons[MENU_BUTTON_SCORE_ERASE_FILE]->oMenuButtonScale = MENU_BUTTON_SCALE;
sMainMenuButtons[idx + 6]->oMenuButtonScale = MENU_BUTTON_SCALE;
}
#define SCORE_TIMER 31
@@ -555,40 +561,6 @@ void check_score_menu_clicked_buttons(struct Object *scoreButton) {
#undef SCORE_TIMER
/**
* Render buttons for the copy menu.
* Also check if the save file exists to render a different Mario button.
*/
void render_copy_menu_buttons(struct Object *copyButton) {
// File A
sMainMenuButtons[MENU_BUTTON_COPY_FILE_A] = SPAWN_FILE_SELECT_FILE_BUTTON(copyButton, SAVE_FILE_A);
sMainMenuButtons[MENU_BUTTON_COPY_FILE_A]->oMenuButtonScale = MENU_BUTTON_SCALE;
// File B
sMainMenuButtons[MENU_BUTTON_COPY_FILE_B] = SPAWN_FILE_SELECT_FILE_BUTTON(copyButton, SAVE_FILE_B);
sMainMenuButtons[MENU_BUTTON_COPY_FILE_B]->oMenuButtonScale = MENU_BUTTON_SCALE;
// File C
sMainMenuButtons[MENU_BUTTON_COPY_FILE_C] = SPAWN_FILE_SELECT_FILE_BUTTON(copyButton, SAVE_FILE_C);
sMainMenuButtons[MENU_BUTTON_COPY_FILE_C]->oMenuButtonScale = MENU_BUTTON_SCALE;
// File D
sMainMenuButtons[MENU_BUTTON_COPY_FILE_D] = SPAWN_FILE_SELECT_FILE_BUTTON(copyButton, SAVE_FILE_D);
sMainMenuButtons[MENU_BUTTON_COPY_FILE_D]->oMenuButtonScale = MENU_BUTTON_SCALE;
// Return to main menu button
sMainMenuButtons[MENU_BUTTON_COPY_RETURN] =
spawn_object_rel_with_rot(copyButton, MODEL_MAIN_MENU_YELLOW_FILE_BUTTON,
bhvMenuButton, 711, -388, -100, 0x0, -0x8000, 0x0);
sMainMenuButtons[MENU_BUTTON_COPY_RETURN]->oMenuButtonScale = MENU_BUTTON_SCALE;
// Switch to scire menu button
sMainMenuButtons[MENU_BUTTON_COPY_CHECK_SCORE] =
spawn_object_rel_with_rot(copyButton, MODEL_MAIN_MENU_GREEN_SCORE_BUTTON,
bhvMenuButton, 0, -388, -100, 0x0, -0x8000, 0x0);
sMainMenuButtons[MENU_BUTTON_COPY_CHECK_SCORE]->oMenuButtonScale = MENU_BUTTON_SCALE;
// Switch to erase menu button
sMainMenuButtons[MENU_BUTTON_COPY_ERASE_FILE] =
spawn_object_rel_with_rot(copyButton, MODEL_MAIN_MENU_RED_ERASE_BUTTON,
bhvMenuButton, -711, -388, -100, 0x0, -0x8000, 0x0);
sMainMenuButtons[MENU_BUTTON_COPY_ERASE_FILE]->oMenuButtonScale = MENU_BUTTON_SCALE;
}
#define BUZZ_TIMER 21
/**
@@ -709,40 +681,6 @@ void check_copy_menu_clicked_buttons(struct Object *copyButton) {
}
}
/**
* Render buttons for the erase menu.
* Also check if the save file exists to render a different Mario button.
*/
void render_erase_menu_buttons(struct Object *eraseButton) {
// File A
sMainMenuButtons[MENU_BUTTON_ERASE_FILE_A] = SPAWN_FILE_SELECT_FILE_BUTTON(eraseButton, SAVE_FILE_A);
sMainMenuButtons[MENU_BUTTON_ERASE_FILE_A]->oMenuButtonScale = MENU_BUTTON_SCALE;
// File B
sMainMenuButtons[MENU_BUTTON_ERASE_FILE_B] = SPAWN_FILE_SELECT_FILE_BUTTON(eraseButton, SAVE_FILE_B);
sMainMenuButtons[MENU_BUTTON_ERASE_FILE_B]->oMenuButtonScale = MENU_BUTTON_SCALE;
// File C
sMainMenuButtons[MENU_BUTTON_ERASE_FILE_C] = SPAWN_FILE_SELECT_FILE_BUTTON(eraseButton, SAVE_FILE_C);
sMainMenuButtons[MENU_BUTTON_ERASE_FILE_C]->oMenuButtonScale = MENU_BUTTON_SCALE;
// File D
sMainMenuButtons[MENU_BUTTON_ERASE_FILE_D] = SPAWN_FILE_SELECT_FILE_BUTTON(eraseButton, SAVE_FILE_D);
sMainMenuButtons[MENU_BUTTON_ERASE_FILE_D]->oMenuButtonScale = MENU_BUTTON_SCALE;
// Return to main menu button
sMainMenuButtons[MENU_BUTTON_ERASE_RETURN] =
spawn_object_rel_with_rot(eraseButton, MODEL_MAIN_MENU_YELLOW_FILE_BUTTON,
bhvMenuButton, 711, -388, -100, 0x0, -0x8000, 0x0);
sMainMenuButtons[MENU_BUTTON_ERASE_RETURN]->oMenuButtonScale = MENU_BUTTON_SCALE;
// Switch to score menu button
sMainMenuButtons[MENU_BUTTON_ERASE_CHECK_SCORE] =
spawn_object_rel_with_rot(eraseButton, MODEL_MAIN_MENU_GREEN_SCORE_BUTTON,
bhvMenuButton, 0, -388, -100, 0x0, -0x8000, 0x0);
sMainMenuButtons[MENU_BUTTON_ERASE_CHECK_SCORE]->oMenuButtonScale = MENU_BUTTON_SCALE;
// Switch to copy menu button
sMainMenuButtons[MENU_BUTTON_ERASE_COPY_FILE] =
spawn_object_rel_with_rot(eraseButton, MODEL_MAIN_MENU_BLUE_COPY_BUTTON,
bhvMenuButton, -711, -388, -100, 0x0, -0x8000, 0x0);
sMainMenuButtons[MENU_BUTTON_ERASE_COPY_FILE]->oMenuButtonScale = MENU_BUTTON_SCALE;
}
/**
* Erase Menu phase actions that handles what to do when a file button is clicked.
*/
@@ -1029,7 +967,7 @@ void load_menu_from_submenu(s16 prevMenuButtonID, s16 selectedButtonID, struct O
sSelectedButtonID = selectedButtonID;
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
sMainMenuButtons[selectedButtonID]->oMenuButtonState = MENU_BUTTON_STATE_GROWING;
render_score_menu_buttons(sMainMenuButtons[selectedButtonID]);
render_menu_buttons(selectedButtonID);
}
}
@@ -1114,89 +1052,59 @@ void bhv_menu_button_manager_init(void) {
* Also play a sound and/or render buttons depending of the button ID selected.
*/
void check_main_menu_clicked_buttons(void) {
// Sound mode menu is handled separately because the button ID for it
// is not grouped with the IDs of the other submenus.
if (check_clicked_button(sMainMenuButtons[MENU_BUTTON_SOUND_MODE]->oPosX,
sMainMenuButtons[MENU_BUTTON_SOUND_MODE]->oPosY, 200.0f)) {
sMainMenuButtons[MENU_BUTTON_SOUND_MODE]->oMenuButtonState = MENU_BUTTON_STATE_GROWING;
sSelectedButtonID = MENU_BUTTON_SOUND_MODE;
} else {
// Main Menu buttons
s8 buttonID;
// Configure Main Menu button group
for (buttonID = MENU_BUTTON_MAIN_MIN; buttonID < MENU_BUTTON_MAIN_MAX; buttonID++) {
s16 buttonX = sMainMenuButtons[buttonID]->oPosX;
s16 buttonY = sMainMenuButtons[buttonID]->oPosY;
// Sound mode menu is handled separately because the button ID for it
// is not grouped with the IDs of the other submenus.
if (check_clicked_button(sMainMenuButtons[MENU_BUTTON_SOUND_MODE]->oPosX,
sMainMenuButtons[MENU_BUTTON_SOUND_MODE]->oPosY, 200.0f)) {
sMainMenuButtons[MENU_BUTTON_SOUND_MODE]->oMenuButtonState = MENU_BUTTON_STATE_GROWING;
sSelectedButtonID = MENU_BUTTON_SOUND_MODE;
} else {
// Main Menu buttons
s8 buttonID;
// Configure Main Menu button group
for (buttonID = MENU_BUTTON_MAIN_MIN; buttonID < MENU_BUTTON_MAIN_MAX; buttonID++) {
s16 buttonX = sMainMenuButtons[buttonID]->oPosX;
s16 buttonY = sMainMenuButtons[buttonID]->oPosY;
if (check_clicked_button(buttonX, buttonY, 200.0f)) {
// If menu button clicked, select it
sMainMenuButtons[buttonID]->oMenuButtonState = MENU_BUTTON_STATE_GROWING;
sSelectedButtonID = buttonID;
break;
}
if (check_clicked_button(buttonX, buttonY, 200.0f)) {
// If menu button clicked, select it
sMainMenuButtons[buttonID]->oMenuButtonState = MENU_BUTTON_STATE_GROWING;
sSelectedButtonID = buttonID;
break;
}
}
}
// Play sound of the save file clicked
switch (sSelectedButtonID) {
case MENU_BUTTON_PLAY_FILE_A:
play_sound(SAVE_FILE_SOUND, gGlobalSoundSource);
// Play sound of the save file clicked
switch (sSelectedButtonID) {
case MENU_BUTTON_PLAY_FILE_A:
case MENU_BUTTON_PLAY_FILE_B:
case MENU_BUTTON_PLAY_FILE_C:
case MENU_BUTTON_PLAY_FILE_D:
play_sound(SAVE_FILE_SOUND, gGlobalSoundSource);
#if ENABLE_RUMBLE
queue_rumble_data(60, 70);
queue_rumble_decay(1);
queue_rumble_data(60, 70);
queue_rumble_decay(1);
#endif
break;
case MENU_BUTTON_PLAY_FILE_B:
play_sound(SAVE_FILE_SOUND, gGlobalSoundSource);
break;
// Play sound of the button clicked and render buttons of that menu.
case MENU_BUTTON_SCORE:
case MENU_BUTTON_COPY:
case MENU_BUTTON_ERASE:
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
#if ENABLE_RUMBLE
queue_rumble_data(60, 70);
queue_rumble_decay(1);
queue_rumble_data(5, 80);
#endif
break;
case MENU_BUTTON_PLAY_FILE_C:
play_sound(SAVE_FILE_SOUND, gGlobalSoundSource);
render_menu_buttons(sSelectedButtonID);
break;
case MENU_BUTTON_SOUND_MODE:
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
#if ENABLE_RUMBLE
queue_rumble_data(60, 70);
queue_rumble_decay(1);
queue_rumble_data(5, 80);
#endif
break;
case MENU_BUTTON_PLAY_FILE_D:
play_sound(SAVE_FILE_SOUND, gGlobalSoundSource);
#if ENABLE_RUMBLE
queue_rumble_data(60, 70);
queue_rumble_decay(1);
#endif
break;
// Play sound of the button clicked and render buttons of that menu.
case MENU_BUTTON_SCORE:
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
render_score_menu_buttons(sMainMenuButtons[MENU_BUTTON_SCORE]);
break;
case MENU_BUTTON_COPY:
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
render_copy_menu_buttons(sMainMenuButtons[MENU_BUTTON_COPY]);
break;
case MENU_BUTTON_ERASE:
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
render_erase_menu_buttons(sMainMenuButtons[MENU_BUTTON_ERASE]);
break;
case MENU_BUTTON_SOUND_MODE:
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
render_sound_mode_menu_buttons(sMainMenuButtons[MENU_BUTTON_SOUND_MODE]);
break;
}
render_sound_mode_menu_buttons(sMainMenuButtons[MENU_BUTTON_SOUND_MODE]);
break;
}
}
#undef SAVE_FILE_SOUND
@@ -1880,7 +1788,7 @@ void print_sound_mode_menu_strings(void) {
print_hud_lut_string(HUD_LUT_DIFF, SOUND_HUD_X, 32, LANGUAGE_ARRAY(textSoundSelect));
#if MULTILANG
print_hud_lut_string(HUD_LUT_DIFF, 47, 101, LANGUAGE_ARRAY(textLanguageSelect));
print_hud_lut_string(HUD_LUT_DIFF, 47, 101, LANGUAGE_ARRAY(textLanguageSelect[0]));
#endif
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end);
+1
View File
@@ -313,6 +313,7 @@ void print_act_selector_strings(void) {
#if MULTILANG
switch (language) {
default:
case LANGUAGE_ENGLISH:
actNameTbl = segmented_to_virtual(act_name_table_eu_en);
levelNameTbl = segmented_to_virtual(course_name_table_eu_en);