Merge branch 'develop' into 3DProjectiles

This commit is contained in:
Baoulettes
2022-06-20 22:32:45 +02:00
committed by GitHub
489 changed files with 125389 additions and 1776 deletions
-6
View File
@@ -544,16 +544,10 @@ u8 gDefaultShortNoteGateTimeTable[] = {
};
AdsrEnvelope gDefaultEnvelope[] = {
// OTRTODO: Byteswapped manually for quick audio support.
{ 0x0100, 0x007D },
{ 0xE803, 0x007D },
{ 0xFFFF, 0x0000 },
{ 0x0000, 0x0000 },
/* { 1, 32000 },
{ 1000, 32000 },
{ -1, 0 },
{ 0, 0 },
*/
};
NoteSubEu gZeroNoteSub = { 0 };
+7 -1
View File
@@ -10,6 +10,8 @@ void AudioHeap_DiscardSampleCaches(void);
void AudioHeap_DiscardSampleBank(s32 sampleBankId);
void AudioHeap_DiscardSampleBanks(void);
extern bool gUseLegacySD;
f32 func_800DDE20(f32 arg0) {
return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0;
}
@@ -1201,7 +1203,11 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) {
}
}
void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) {
void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample)
{
if (!gUseLegacySD)
return;
if (sample != NULL) {
if (sample->sampleAddr == entry->allocatedAddr) {
sample->sampleAddr = entry->sampleAddr;
+19 -18
View File
@@ -10,7 +10,8 @@ const s16 D_8014A6C0[] = {
0x0030, // gTatumsPerBeat
};
const AudioContextInitSizes D_8014A6C4 = { 0x37F00, 0xE0E0, 0xBCE0 };
//const AudioContextInitSizes D_8014A6C4 = { 0x37F00, 0xE0E0, 0xBCE0 };
const AudioContextInitSizes D_8014A6C4 = { 0x37F000, 0xE0E00, 0xBCE00 }; // OTRTODO: This might be overkill...
ReverbSettings D_80133420[][3] = {
{
@@ -67,22 +68,22 @@ ReverbSettings D_80133420[][3] = {
};
AudioSpec gAudioSpecs[18] = {
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x4000, 0x2880, 0, 0, 0 },
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[1], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 23, 4, 0, 0, 2, D_80133420[4], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 23, 4, 0, 0, 2, D_80133420[5], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[6], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[7], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[9], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 28, 3, 0, 0, 2, D_80133420[10], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x2800, 0x2880, 0, 0, 0 },
{ 32000, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0x4800, 0, 0x4000, 0, 0, 0, 0 },
{ 32000, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0, 0, 0x4000, 0x4800, 0, 0, 0 },
{ 32000, 1, 22, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 22, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 16, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x4000, 0x2880, 0, 0, 0 },
{ 44100, 1, 24, 4, 0, 0, 2, D_80133420[1], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 23, 4, 0, 0, 2, D_80133420[4], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 23, 4, 0, 0, 2, D_80133420[5], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 24, 4, 0, 0, 2, D_80133420[6], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 24, 4, 0, 0, 2, D_80133420[7], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 24, 4, 0, 0, 2, D_80133420[9], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 28, 3, 0, 0, 2, D_80133420[10], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x2800, 0x2880, 0, 0, 0 },
{ 44100, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0x4800, 0, 0x4000, 0, 0, 0, 0 },
{ 44100, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0, 0, 0x4000, 0x4800, 0, 0, 0 },
{ 44100, 1, 22, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 22, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 44100, 1, 16, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 22050, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
{ 32000, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3600, 0x2600, 0, 0, 0 },
{ 44100, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3600, 0x2600, 0, 0, 0 },
};
+353 -111
View File
@@ -4,6 +4,7 @@
#include "ultra64.h"
#include "global.h"
#include "soh/OTRGlobals.h"
#define MK_ASYNC_MSG(retData, tableType, id, status) (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (status))
#define ASYNC_TBLTYPE(v) ((u8)(v >> 16))
@@ -37,14 +38,14 @@ void AudioLoad_ProcessAsyncLoads(s32 resetStatus);
void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus);
void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus);
void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo, s32 temporary);
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo);
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo, int fontId);
void AudioLoad_DiscardFont(s32 fontId);
u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad);
void* AudioLoad_SyncLoad(u32 tableType, u32 tableId, s32* didAllocate);
u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 tableId);
void* AudioLoad_SearchCaches(s32 tableType, s32 id);
AudioTable* AudioLoad_GetLoadTable(s32 tableType);
void AudioLoad_SyncDma(u32 devAddr, u8* addr, size_t size, s32 medium);
void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium);
void AudioLoad_SyncDmaUnkMedium(u32 devAddr, u8* addr, size_t size, s32 unkMediumParam);
s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void* ramAddr, size_t size,
OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType);
@@ -74,6 +75,14 @@ void* sUnusedHandler = NULL;
s32 gAudioContextInitalized = false;
char* sequenceMap[256];
char* fontMap[256];
uintptr_t fontStart;
uint32_t fontOffsets[8192];
bool gUseLegacySD = false;
void AudioLoad_DecreaseSampleDmaTtls(void) {
u32 i;
@@ -278,8 +287,11 @@ void AudioLoad_InitSampleDmaBuffers(s32 arg0) {
}
s32 AudioLoad_IsFontLoadComplete(s32 fontId) {
return true;
if (fontId == 0xFF) {
return true;
} else if (gAudioContext.fontLoadStatus[fontId] >= 2) {
return true;
} else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= 2) {
@@ -352,6 +364,9 @@ void AudioLoad_InitTable(AudioTable* table, uintptr_t romAddr, u16 unkMediumPara
for (i = 0; i < table->numEntries; i++) {
if ((table->entries[i].size != 0) && (table->entries[i].medium == MEDIUM_CART)) {
if (romAddr == fontStart)
fontOffsets[i] = table->entries[i].romAddr;
table->entries[i].romAddr += romAddr;
}
}
@@ -360,7 +375,7 @@ void AudioLoad_InitTable(AudioTable* table, uintptr_t romAddr, u16 unkMediumPara
SoundFontData* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outDefaultFontId) {
char pad[0x8];
s32 index;
SoundFontData* font;
SoundFontData* font = NULL;
s32 numFonts;
s32 fontId;
s32 i;
@@ -375,6 +390,7 @@ SoundFontData* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outDefaultFontId) {
while (numFonts > 0) {
fontId = gAudioContext.sequenceFontTable[index++];
font = AudioLoad_SyncLoadFont(fontId);
numFonts--;
}
@@ -400,7 +416,8 @@ void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1) {
s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) {
void* sampleAddr;
if (sample->unk_bit25 == 1) {
if (sample->unk_bit25 == 1)
{
if (sample->medium != MEDIUM_RAM) {
sampleAddr = AudioHeap_AllocSampleCache(sample->size, fontId, (void*)sample->sampleAddr, sample->medium,
CACHE_PERSISTENT);
@@ -466,13 +483,26 @@ void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* ret
u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
s32 index;
index = ((u16*)gAudioContext.sequenceFontTable)[seqId];
if (!gUseLegacySD)
{
if (seqId == 255)
return NULL;
*outNumFonts = gAudioContext.sequenceFontTable[index++];
if (*outNumFonts == 0) {
return NULL;
SequenceData sDat = ResourceMgr_LoadSeqByName(sequenceMap[seqId]);
if (sDat.numFonts == 0)
return NULL;
return sDat.fonts;
} else {
index = ((u16*)gAudioContext.sequenceFontTable)[seqId];
*outNumFonts = gAudioContext.sequenceFontTable[index++];
if (*outNumFonts == 0) {
return NULL;
}
return &gAudioContext.sequenceFontTable[index];
}
return &gAudioContext.sequenceFontTable[index];
}
void AudioLoad_DiscardSeqFonts(s32 seqId) {
@@ -544,30 +574,52 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) {
s32 numFonts;
s32 fontId;
if (seqId >= gAudioContext.numSequences) {
if (gUseLegacySD && seqId >= gAudioContext.numSequences) {
return 0;
}
AudioSeq_SequencePlayerDisable(seqPlayer);
fontId = 0xFF;
index = ((u16*)gAudioContext.sequenceFontTable)[seqId];
numFonts = gAudioContext.sequenceFontTable[index++];
while (numFonts > 0) {
fontId = gAudioContext.sequenceFontTable[index++];
AudioLoad_SyncLoadFont(fontId);
numFonts--;
if (gUseLegacySD) {
index = ((u16*)gAudioContext.sequenceFontTable)[seqId];
numFonts = gAudioContext.sequenceFontTable[index++];
while (numFonts > 0) {
fontId = gAudioContext.sequenceFontTable[index++];
AudioLoad_SyncLoadFont(fontId); // NOTE: If this is commented out, then enemies will play child link sounds...
numFonts--;
}
}
else
{
SequenceData seqData2 = ResourceMgr_LoadSeqByName(sequenceMap[seqId]);
for (int i = 0; i < seqData2.numFonts; i++)
{
fontId = seqData2.fonts[i];
AudioLoad_SyncLoadFont(fontId); // NOTE: If this is commented out, then enemies will play child link sounds...
numFonts--;
}
}
seqData = AudioLoad_SyncLoadSeq(seqId);
if (seqData == NULL) {
return 0;
}
AudioSeq_ResetSequencePlayer(seqPlayer);
seqPlayer->seqId = seqId;
seqPlayer->defaultFont = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId);
if (gUseLegacySD)
seqPlayer->defaultFont = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId);
else
seqPlayer->defaultFont = fontId;
seqPlayer->seqData = seqData;
seqPlayer->enabled = 1;
seqPlayer->scriptState.pc = seqData;
@@ -637,8 +689,18 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) {
if (gAudioContext.fontLoadStatus[realFontId] == 1) {
return NULL;
}
sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1;
sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2;
if (!gUseLegacySD) {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont
(fontMap[fontId]);
sampleBankId1 = sf->sampleBankId1;
sampleBankId2 = sf->sampleBankId2;
} else {
sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1;
sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2;
}
relocInfo.sampleBankId1 = sampleBankId1;
relocInfo.sampleBankId2 = sampleBankId2;
@@ -681,13 +743,38 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
if (ret != NULL) {
*didAllocate = false;
status = 2;
} else {
table = AudioLoad_GetLoadTable(tableType);
size = table->entries[realId].size;
size = ALIGN16(size);
medium = table->entries[id].medium;
cachePolicy = table->entries[id].cachePolicy;
romAddr = table->entries[realId].romAddr;
} else
{
char* seqData = 0;
SoundFont* fnt;
if (!gUseLegacySD && tableType == SEQUENCE_TABLE)
{
SequenceData sData = ResourceMgr_LoadSeqByName(sequenceMap[id]);
seqData = sData.seqData;
size = sData.seqDataSize;
medium = sData.medium;
cachePolicy = sData.cachePolicy;
romAddr = 0;
}
else if (!gUseLegacySD && tableType == FONT_TABLE)
{
fnt = ResourceMgr_LoadAudioSoundFont(fontMap[id]);
size = sizeof(SoundFont);
medium = 2;
cachePolicy = 0;
romAddr = 0;
}
else
{
table = AudioLoad_GetLoadTable(tableType);
size = table->entries[realId].size;
size = ALIGN16(size);
medium = table->entries[id].medium;
cachePolicy = table->entries[id].cachePolicy;
romAddr = table->entries[realId].romAddr;
}
switch (cachePolicy) {
case 0:
ret = AudioHeap_AllocPermanent(tableType, realId, size);
@@ -720,7 +807,14 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
if (medium == MEDIUM_UNK) {
AudioLoad_SyncDmaUnkMedium(romAddr, ret, size, (s16)table->unkMediumParam);
} else {
AudioLoad_SyncDma(romAddr, ret, size, medium);
if (!gUseLegacySD && tableType == SEQUENCE_TABLE && seqData != NULL) {
AudioLoad_SyncDma(seqData, ret, size, medium);
} else if (!gUseLegacySD && tableType == FONT_TABLE) {
AudioLoad_SyncDma(fnt, ret, size, medium);
}
else {
AudioLoad_SyncDma(romAddr, ret, size, medium);
}
}
status = cachePolicy == 0 ? 5 : 2;
@@ -743,9 +837,16 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
return ret;
}
u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) {
u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id)
{
if ((tableType == SEQUENCE_TABLE || tableType == FONT_TABLE) && !gUseLegacySD) {
return id;
}
AudioTable* table = AudioLoad_GetLoadTable(tableType);
// If the size is 0, then this entry actually redirects to another entry.
// The rom address is actually an index into the same table where the "real" data is.
if (table->entries[id].size == 0) {
id = table->entries[id].romAddr;
}
@@ -796,29 +897,64 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
Drum* drum;
SoundFontSound* sfx;
s32 i;
s32 numDrums = gAudioContext.soundFonts[fontId].numDrums;
s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments;
s32 numSfx = gAudioContext.soundFonts[fontId].numSfx;
SoundFont* sf = NULL;
s32 numDrums = 0;
s32 numInstruments = 0;
s32 numSfx = 0;
if (gUseLegacySD) {
numDrums = gAudioContext.soundFonts[fontId].numDrums;
numInstruments = gAudioContext.soundFonts[fontId].numInstruments;
numSfx = gAudioContext.soundFonts[fontId].numSfx;
} else {
sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]);
numDrums = sf->numDrums;
numInstruments = sf->numInstruments;
numSfx = sf->numSfx;
}
void** ptrs = (void**)mem;
#define BASE_OFFSET(x) (void*)((u32)(x) + (u32)(mem))
reloc2 = ptrs[0];
if (1) {}
if ((reloc2 != 0) && (numDrums != 0)) {
if ((reloc2 != 0 || !gUseLegacySD) && (numDrums != 0))
{
ptrs[0] = BASE_OFFSET(reloc2);
for (i = 0; i < numDrums; i++) {
reloc = ((Drum**)ptrs[0])[i];
for (i = 0; i < numDrums; i++)
{
if (gUseLegacySD)
reloc = ((Drum**)ptrs[0])[i];
if (reloc != 0) {
reloc = BASE_OFFSET(reloc);
if (reloc != 0 || !gUseLegacySD)
{
if (gUseLegacySD)
{
reloc = BASE_OFFSET(reloc);
((Drum**)ptrs[0])[i] = drum = reloc;
}
((Drum**)ptrs[0])[i] = drum = reloc;
if (!drum->loaded) {
AudioLoad_RelocateSample(&drum->sound, mem, relocInfo);
reloc = drum->envelope;
drum->envelope = BASE_OFFSET(reloc);
drum->loaded = 1;
if (!gUseLegacySD)
drum = sf->drums[i];
if (!drum->loaded)
{
if (!gUseLegacySD)
{
AudioLoad_RelocateSample(&sf->drums[i]->sound, mem, relocInfo, fontOffsets[fontId]);
//reloc = drum->envelope;
drum->loaded = 1;
}
else
{
AudioLoad_RelocateSample(&drum->sound, mem, relocInfo, fontOffsets[fontId]);
reloc = drum->envelope;
drum->envelope = BASE_OFFSET(reloc);
drum->loaded = 1;
}
}
}
}
@@ -826,39 +962,56 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
reloc2 = ptrs[1];
if (1) {}
if ((reloc2 != 0) && (numSfx != 0)) {
if ((reloc2 != 0 || !gUseLegacySD) && (numSfx != 0)) {
ptrs[1] = BASE_OFFSET(reloc2);
for (i = 0; i < numSfx; i++) {
reloc = (SoundFontSound*)ptrs[1] + i;
if (reloc != 0) {
sfx = reloc;
if (sfx->sample != NULL) {
AudioLoad_RelocateSample(sfx, mem, relocInfo);
if (reloc != 0 || !gUseLegacySD)
{
if (!gUseLegacySD) {
AudioLoad_RelocateSample(&sf->soundEffects[i].sample, mem, relocInfo, fontOffsets[fontId]);
} else {
sfx = reloc;
if (sfx->sample != NULL) {
AudioLoad_RelocateSample(sfx, mem, relocInfo, fontOffsets[fontId]);
}
}
}
}
}
if (numInstruments > 0x7E) {
numInstruments = 0x7E;
}
for (i = 2; i <= 2 + numInstruments - 1; i++) {
if (ptrs[i] != NULL) {
int startI = gUseLegacySD ? 2 : 0;
int startEC = gUseLegacySD ? 2 + numInstruments - 1 : numInstruments - 1;
//for (i = 2; i <= 2 + numInstruments - 1; i++) {
for (i = startI; i <= startEC; i++) {
if (!gUseLegacySD || ptrs[i] != NULL)
{
ptrs[i] = BASE_OFFSET(ptrs[i]);
inst = ptrs[i];
if (!inst->loaded) {
if (inst->normalRangeLo != 0) {
AudioLoad_RelocateSample(&inst->lowNotesSound, mem, relocInfo);
if (gUseLegacySD)
inst = ptrs[i];
else
inst = sf->instruments[i];
if (inst != NULL && !inst->loaded) {
if (inst->normalRangeLo != 0)
{
AudioLoad_RelocateSample(&inst->lowNotesSound, mem, relocInfo, fontOffsets[fontId]);
}
AudioLoad_RelocateSample(&inst->normalNotesSound, mem, relocInfo);
AudioLoad_RelocateSample(&inst->normalNotesSound, mem, relocInfo, fontOffsets[fontId]);
if (inst->normalRangeHi != 0x7F) {
AudioLoad_RelocateSample(&inst->highNotesSound, mem, relocInfo);
AudioLoad_RelocateSample(&inst->highNotesSound, mem, relocInfo, fontOffsets[fontId]);
}
reloc = inst->envelope;
inst->envelope = BASE_OFFSET(reloc);
if (gUseLegacySD)
inst->envelope = BASE_OFFSET(reloc);
inst->loaded = 1;
}
}
@@ -866,12 +1019,14 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
#undef BASE_OFFSET
gAudioContext.soundFonts[fontId].drums = ptrs[0];
gAudioContext.soundFonts[fontId].soundEffects = ptrs[1];
gAudioContext.soundFonts[fontId].instruments = (Instrument**)(ptrs + 2);
if (gUseLegacySD) {
gAudioContext.soundFonts[fontId].drums = ptrs[0];
gAudioContext.soundFonts[fontId].soundEffects = ptrs[1];
gAudioContext.soundFonts[fontId].instruments = (Instrument**)(ptrs + 2);
}
}
void AudioLoad_SyncDma(u32 devAddr, u8* addr, size_t size, s32 medium) {
void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium) {
OSMesgQueue* msgQueue = &gAudioContext.syncDmaQueue;
OSIoMesg* ioMesg = &gAudioContext.syncDmaIoMesg;
size = ALIGN16(size);
@@ -1054,7 +1209,6 @@ s32 AudioLoad_AssertValidAddr(uintptr_t ramAddr, uintptr_t startAddr, size_t siz
#define BASE_ROM_OFFSET(x) (void*)((u32)(x) + (u32)(romAddr))
void AudioLoad_InitSwapFontSampleHeaders(SoundFontSample* sample, uintptr_t romAddr) {
// OTRTODO: This will be removed when we actually extract the data.
size_t maxSoundFontSize = 0x3AA0; // soundFont 0 is the largest size at 0x3AA0
AdpcmLoop* loop;
AdpcmBook* book;
@@ -1270,17 +1424,64 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
uintptr_t bankStart = ResourceMgr_LoadFileRaw(_AudiobankSegmentRomStart);
uintptr_t tableStart = ResourceMgr_LoadFileRaw(_AudiotableSegmentRomStart);
// If we have the old audioseq files present (and this is a 32-bit build), use the legacy audio system
if (seqStart != NULL && bankStart != NULL && tableStart != NULL)
gUseLegacySD = true;
fontStart = bankStart;
AudioLoad_InitTable(gAudioContext.sequenceTable, seqStart, 0);
AudioLoad_InitTable(gAudioContext.soundFontTable, bankStart, 0);
AudioLoad_InitTable(gAudioContext.sampleBankTable, tableStart, 0);
numFonts = gAudioContext.soundFontTable->numEntries;
gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont));
for (i = 0; i < numFonts; i++) {
AudioLoad_InitSoundFontMeta(i);
if (gUseLegacySD)
numFonts = gAudioContext.soundFontTable->numEntries;
if (gUseLegacySD)
{
gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont));
for (i = 0; i < numFonts; i++) {
AudioLoad_InitSoundFontMeta(i);
}
AudioLoad_InitSwapFont();
} else {
int seqListSize = 0;
char** seqList = ResourceMgr_ListFiles("audio/sequences*", &seqListSize);
for (int i = 0; i < seqListSize; i++)
{
SequenceData sDat = ResourceMgr_LoadSeqByName(seqList[i]);
char* str = malloc(strlen(seqList[i]) + 1);
strcpy(str, seqList[i]);
sequenceMap[sDat.seqNumber] = str;
}
free(seqList);
int fntListSize = 0;
char** fntList = ResourceMgr_ListFiles("audio/fonts*", &fntListSize);
for (int i = 0; i < fntListSize; i++)
{
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fntList[i]);
char* str = malloc(strlen(fntList[i]) + 1);
strcpy(str, fntList[i]);
fontMap[sf->fntIndex] = str;
}
numFonts = fntListSize;
free(fntList);
gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont));
}
AudioLoad_InitSwapFont();
if (temp_v0_3 = AudioHeap_Alloc(&gAudioContext.audioInitPool, D_8014A6C4.permanentPoolSize), temp_v0_3 == NULL) {
// cast away const from D_8014A6C4
@@ -1300,7 +1501,6 @@ void AudioLoad_InitSlowLoads(void) {
s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) {
SoundFontSample* sample;
AudioSlowLoad* slowLoad;
sample = AudioLoad_GetFontSample(fontId, instId);
if (sample == NULL) {
*isDone = 0;
@@ -1454,28 +1654,42 @@ s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) {
AudioTable* seqTable;
size_t size;
if (seqId >= gAudioContext.numSequences) {
if (gUseLegacySD && seqId >= gAudioContext.numSequences) {
*isDone = 0;
return -1;
}
seqId = AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId);
seqTable = AudioLoad_GetLoadTable(SEQUENCE_TABLE);
slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos];
if (slowLoad->status == LOAD_STATUS_DONE) {
slowLoad->status = LOAD_STATUS_WAITING;
}
slowLoad->sample.sampleAddr = NULL;
slowLoad->isDone = isDone;
size = seqTable->entries[seqId].size;
size = ALIGN16(size);
if (!gUseLegacySD)
{
SequenceData sData = ResourceMgr_LoadSeqByName(sequenceMap[seqId]);
char* seqData = sData.seqData;
size = sData.seqDataSize;
slowLoad->curDevAddr = seqData;
slowLoad->medium = sData.medium;
} else {
size = seqTable->entries[seqId].size;
size = ALIGN16(size);
slowLoad->curDevAddr = seqTable->entries[seqId].romAddr;
slowLoad->medium = seqTable->entries[seqId].medium;
}
slowLoad->curRamAddr = ramAddr;
slowLoad->status = LOAD_STATUS_START;
slowLoad->bytesRemaining = size;
slowLoad->ramAddr = ramAddr;
slowLoad->curDevAddr = seqTable->entries[seqId].romAddr;
slowLoad->medium = seqTable->entries[seqId].medium;
slowLoad->seqOrFontId = seqId;
if (slowLoad->medium == MEDIUM_UNK) {
@@ -1687,44 +1901,52 @@ void AudioLoad_AsyncDmaUnkMedium(u32 devAddr, void* ramAddr, size_t size, s16 ar
#define RELOC(v, base) (reloc = (void*)((u32)(v) + (u32)(base)))
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo) {
// OTRTODO: This is hack to detect whether or not the sample has been relocated.
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo, int fontId) {
size_t maxSoundBankSize = 0x3EB2A0; // sample bank 0 is largest size at 0x3EB2A0
if ((uintptr_t)mem <= maxSoundBankSize) {
// OTRTODO: This can be removed once we have properly byteswapped files on the disk.
assert("mem for sound font bank is too low.");
if (gUseLegacySD)
{
// NOTE: This is hack to detect whether or not the sample has been relocated.
if ((uintptr_t)mem <= maxSoundBankSize) {
assert("mem for sound font bank is too low.");
}
}
SoundFontSample* sample;
void* reloc;
// OTRTODO: Seems precarious to assume the RAM is never <= 0x3EB2A0, but it largely works.
if ((uintptr_t)sound->sample < maxSoundBankSize) {
sample = sound->sample = RELOC(sound->sample, mem);
if (sample->size != 0 && sample->unk_bit25 != 1) {
sample->loop = RELOC(sample->loop, mem);
sample->book = RELOC(sample->book, mem);
// NOTE: Seems precarious to assume the RAM is never <= 0x3EB2A0, but it largely works.
if ((uintptr_t)sound->sample < maxSoundBankSize || !gUseLegacySD)
{
if (!gUseLegacySD) {
SoundFontSample* sample2 = sound;
} else {
sample = sound->sample = RELOC(sound->sample, mem);
// Resolve the sample medium 2-bit bitfield into a real value based on relocInfo.
switch (sample->medium) {
case 0:
sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1);
sample->medium = relocInfo->medium1;
break;
case 1:
sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2);
sample->medium = relocInfo->medium2;
break;
case 2:
case 3:
// Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE
// respectively, and the sampleAddr unrelocated.
break;
}
if (sample->size != 0 && sample->unk_bit25 != 1) {
sample->loop = RELOC(sample->loop, mem);
sample->book = RELOC(sample->book, mem);
sample->unk_bit25 = 1;
if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) {
gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample;
// Resolve the sample medium 2-bit bitfield into a real value based on relocInfo.
switch (sample->medium) {
case 0:
sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1);
sample->medium = relocInfo->medium1;
break;
case 1:
sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2);
sample->medium = relocInfo->medium2;
break;
case 2:
case 3:
// Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE
// respectively, and the sampleAddr unrelocated.
break;
}
sample->unk_bit25 = 1;
if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) {
gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample;
}
}
}
}
@@ -1949,8 +2171,10 @@ s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) {
void AudioLoad_AddUsedSample(SoundFontSound* sound) {
SoundFontSample* sample = sound->sample;
if ((sample->size != 0) && (sample->unk_bit26) && (sample->medium != MEDIUM_RAM)) {
gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample;
if (sample != NULL) {
if ((sample->size != 0) && (sample->unk_bit26) && (sample->medium != MEDIUM_RAM)) {
gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample;
}
}
}
@@ -1977,9 +2201,17 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo
gAudioContext.numUsedSamples = 0;
numDrums = gAudioContext.soundFonts[fontId].numDrums;
numInstruments = gAudioContext.soundFonts[fontId].numInstruments;
numSfx = gAudioContext.soundFonts[fontId].numSfx;
if (!gUseLegacySD) {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]);
numDrums = sf->numDrums;
numInstruments = sf->numInstruments;
numSfx = sf->numSfx;
} else {
numDrums = gAudioContext.soundFonts[fontId].numDrums;
numInstruments = gAudioContext.soundFonts[fontId].numInstruments;
numSfx = gAudioContext.soundFonts[fontId].numSfx;
}
for (i = 0; i < numInstruments; i++) {
instrument = Audio_GetInstrumentInner(fontId, i);
@@ -2024,6 +2256,7 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo
}
sample = gAudioContext.usedSamples[i];
if (sample->medium == MEDIUM_RAM) {
continue;
}
@@ -2100,10 +2333,19 @@ void AudioLoad_LoadPermanentSamples(void) {
for (i = 0; i < gAudioContext.permanentPool.count; i++) {
RelocInfo relocInfo;
if (gAudioContext.permanentCache[i].tableType == FONT_TABLE) {
if (gAudioContext.permanentCache[i].tableType == FONT_TABLE)
{
fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.permanentCache[i].id);
relocInfo.sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1;
relocInfo.sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2;
//fontId = gAudioContext.permanentCache[i].id;
if (!gUseLegacySD) {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]);
relocInfo.sampleBankId1 = sf->sampleBankId1;
relocInfo.sampleBankId2 = sf->sampleBankId2;
} else {
relocInfo.sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1;
relocInfo.sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2;
}
if (relocInfo.sampleBankId1 != 0xFF) {
relocInfo.sampleBankId1 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId1);
+54 -16
View File
@@ -1,6 +1,8 @@
#include "global.h"
#include "Cvar.h"
extern bool gUseLegacySD;
void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
f32 volRight, volLeft;
s32 smallPanIndex;
@@ -284,7 +286,18 @@ void Audio_ProcessNotes(void) {
}
subAttrs.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale;
subAttrs.frequency *= gAudioContext.audioBufferParameters.resampleRate;
f32 resampRate = gAudioContext.audioBufferParameters.resampleRate;
if (!gUseLegacySD && !noteSubEu2->bitField1.isSyntheticWave && noteSubEu2->sound.soundFontSound != NULL &&
noteSubEu2->sound.soundFontSound->sample != NULL &&
noteSubEu2->sound.soundFontSound->sample->sampleRateMagicValue == 'RIFF') {
resampRate = CALC_RESAMPLE_FREQ(noteSubEu2->sound.soundFontSound->sample->sampleRate);
}
subAttrs.frequency *= resampRate;
subAttrs.velocity *= scale;
Audio_InitNoteSub(note, noteSubEu2, &subAttrs);
noteSubEu->bitField1.bookOffset = bookOffset;
@@ -307,7 +320,7 @@ SoundFontSound* Audio_InstrumentGetSound(Instrument* instrument, s32 semitone) {
Instrument* Audio_GetInstrumentInner(s32 fontId, s32 instId) {
Instrument* inst;
if (fontId == 0xFF) {
return NULL;
}
@@ -317,16 +330,31 @@ Instrument* Audio_GetInstrumentInner(s32 fontId, s32 instId) {
return NULL;
}
if (instId >= gAudioContext.soundFonts[fontId].numInstruments) {
gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x3000000;
return NULL;
int instCnt = 0;
if (gUseLegacySD) {
instCnt = gAudioContext.soundFonts[fontId].numInstruments;
inst = gAudioContext.soundFonts[fontId].instruments[instId];
if (instId >= gAudioContext.soundFonts[fontId].numInstruments)
if (instId >= instCnt) {
gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x3000000;
return NULL;
}
} else {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]);
if (instId >= sf->numInstruments)
return NULL;
inst = sf->instruments[instId];
}
inst = gAudioContext.soundFonts[fontId].instruments[instId];
if (inst == NULL) {
gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x1000000;
return inst;
}
return inst;
}
@@ -343,12 +371,17 @@ Drum* Audio_GetDrum(s32 fontId, s32 drumId) {
return NULL;
}
if (drumId >= gAudioContext.soundFonts[fontId].numDrums) {
gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x4000000;
return NULL;
}
if (gUseLegacySD) {
if (drumId >= gAudioContext.soundFonts[fontId].numDrums) {
gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x4000000;
return NULL;
}
drum = gAudioContext.soundFonts[fontId].drums[drumId];
drum = gAudioContext.soundFonts[fontId].drums[drumId];
} else {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]);
drum = sf->drums[drumId];
}
if (drum == NULL) {
gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x5000000;
@@ -369,12 +402,17 @@ SoundFontSound* Audio_GetSfx(s32 fontId, s32 sfxId) {
return NULL;
}
if (sfxId >= gAudioContext.soundFonts[fontId].numSfx) {
gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x4000000;
return NULL;
}
if (gUseLegacySD) {
if (sfxId >= gAudioContext.soundFonts[fontId].numSfx) {
gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x4000000;
return NULL;
}
sfx = &gAudioContext.soundFonts[fontId].soundEffects[sfxId];
sfx = &gAudioContext.soundFonts[fontId].soundEffects[sfxId];
} else {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]);
sfx = &sf->soundEffects[sfxId];
}
if (sfx == NULL) {
gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x5000000;
+33 -11
View File
@@ -3,6 +3,9 @@
#include "ultra64.h"
#include "global.h"
extern bool gUseLegacySD;
extern char* sequenceMap[256];
#define PORTAMENTO_IS_SPECIAL(x) ((x).mode & 0x80)
#define PORTAMENTO_MODE(x) ((x).mode & ~0x80)
#define PORTAMENTO_MODE_1 1
@@ -938,8 +941,16 @@ u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** inst
*instOut = NULL;
return 0;
}
adsr->envelope = inst->envelope;
adsr->releaseRate = inst->releaseRate;
if (inst->envelope != NULL)
{
adsr->envelope = inst->envelope;
adsr->releaseRate = (inst->releaseRate);
}
else {
adsr->envelope = gDefaultEnvelope;
}
*instOut = inst;
instId += 2;
return instId;
@@ -1052,9 +1063,15 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
command = (u8)parameters[0];
if (seqPlayer->defaultFont != 0xFF) {
offset = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId];
lowBits = gAudioContext.sequenceFontTable[offset];
command = gAudioContext.sequenceFontTable[offset + lowBits - result];
if (gUseLegacySD) {
offset = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId];
lowBits = gAudioContext.sequenceFontTable[offset];
command = gAudioContext.sequenceFontTable[offset + lowBits - result];
}
else {
SequenceData sDat = ResourceMgr_LoadSeqByName(sequenceMap[seqPlayer->seqId]);
command = sDat.fonts[sDat.numFonts - result - 1];
}
}
if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, command)) {
@@ -1162,10 +1179,17 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
result = (u8)parameters[0];
command = (u8)parameters[0];
if (seqPlayer->defaultFont != 0xFF) {
offset = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId];
lowBits = gAudioContext.sequenceFontTable[offset];
command = gAudioContext.sequenceFontTable[offset + lowBits - result];
if (seqPlayer->defaultFont != 0xFF)
{
if (gUseLegacySD) {
offset = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId];
lowBits = gAudioContext.sequenceFontTable[offset];
command = gAudioContext.sequenceFontTable[offset + lowBits - result];
}
else {
SequenceData sDat = ResourceMgr_LoadSeqByName(sequenceMap[seqPlayer->seqId]);
command = sDat.fonts[sDat.numFonts - result - 1];
}
}
if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, command)) {
@@ -1322,14 +1346,12 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
break;
case 0xB2:
offset = (u16)parameters[0];
// OTRTODO: Byteswap added for quick audio
channel->unk_22 = BOMSWAP16(*(u16*)(seqPlayer->seqData + (uintptr_t)(offset + scriptState->value * 2)));
break;
case 0xB4:
channel->dynTable = (void*)&seqPlayer->seqData[channel->unk_22];
break;
case 0xB5:
// OTRTODO: Byteswap added for quick audio
channel->unk_22 = BOMSWAP16(((u16*)(channel->dynTable))[scriptState->value]);
break;
case 0xB6:
+16 -5
View File
@@ -440,11 +440,11 @@ void func_800DBE64(void) {
void func_800DBE6C(void) {
}
void AudioSynth_LoadFilter(Acmd* cmd, s32 flags, s32 countOrBuf, s32 addr) {
void AudioSynth_LoadFilter(Acmd* cmd, s32 flags, s32 countOrBuf, uintptr_t addr) {
aFilter(cmd, flags, countOrBuf, addr);
}
void AudioSynth_LoadFilterCount(Acmd* cmd, s32 count, s32 addr) {
void AudioSynth_LoadFilterCount(Acmd* cmd, s32 count, uintptr_t addr) {
aFilter(cmd, 2, count, addr);
}
@@ -561,6 +561,9 @@ Acmd* AudioSynth_DoOneAudioUpdate(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updat
NoteSubEu* noteSubEu2;
s32 unk14;
//if (aiBufLen == 0)
//return;
t = gAudioContext.numNotes * updateIndex;
count = 0;
if (gAudioContext.numSynthesisReverbs == 0) {
@@ -749,8 +752,10 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
cmd = AudioSynth_LoadWaveSamples(cmd, noteSubEu, synthState, nSamplesToLoad);
noteSamplesDmemAddrBeforeResampling = DMEM_UNCOMPRESSED_NOTE + (synthState->samplePosInt * 2);
synthState->samplePosInt += nSamplesToLoad;
} else {
} else
{
audioFontSample = noteSubEu->sound.soundFontSound->sample;
loopInfo = audioFontSample->loop;
loopEndPos = loopInfo->end;
sampleAddr = audioFontSample->sampleAddr;
@@ -822,6 +827,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
noteFinished = true;
}
}
switch (audioFontSample->codec) {
case CODEC_ADPCM:
@@ -848,6 +854,9 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
goto skip;
case CODEC_S16:
AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, (samplesLenAdjusted * 2) + 0x20);
AudioSynth_LoadBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, ALIGN16(nSamplesToLoad * 2),
audioFontSample->sampleAddr + (synthState->samplePosInt * 2));
flags = A_CONTINUE;
skipBytes = 0;
nSamplesProcessed = samplesLenAdjusted;
@@ -860,7 +869,8 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
if (nFramesToDecode != 0) {
frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / 16;
sampleDataOffset = frameIndex * frameSize;
if (audioFontSample->medium == MEDIUM_RAM) {
if (audioFontSample->medium == MEDIUM_RAM)
{
sampleData = (u8*)(sampleDataStart + sampleDataOffset + sampleAddr);
} else if (audioFontSample->medium == MEDIUM_UNK) {
return cmd;
@@ -1024,7 +1034,8 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
unk7 = noteSubEu->unk_07;
unkE = noteSubEu->unk_0E;
buf = &synthState->synthesisBuffers->panSamplesBuffer[0x18];
if (unk7 != 0 && noteSubEu->unk_0E != 0) {
if (unk7 != 0 && noteSubEu->unk_0E != 0)
{
AudioSynth_DMemMove(cmd++, DMEM_TEMP, DMEM_SCRATCH2, aiBufLen * 2);
thing = DMEM_SCRATCH2 - unk7;
if (synthState->unk_1A != 0) {
-4
View File
@@ -213,11 +213,7 @@ AudioTask* func_800E5000(void) {
task = &gAudioContext.currTask->task.t;
task->type = M_AUDTASK;
task->flags = 0;
//task->ucode_boot = D_801120C0;
task->ucode_boot_size = 0x1000;
//task->ucode_data_size = ((rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64)) - 1;
//task->ucode = D_801120C0;
//task->ucode_data = rspAspMainDataStart;
task->ucode_size = 0x1000;
task->dram_stack = NULL;
task->dram_stack_size = 0;
+5 -1
View File
@@ -363,7 +363,11 @@ void Audio_ProcessSeqCmd(u32 cmd) {
}
}
void Audio_QueueSeqCmd(u32 cmd) {
extern f32 D_80130F24;
extern f32 D_80130F28;
void Audio_QueueSeqCmd(u32 cmd)
{
sAudioSeqCmds[sSeqCmdWrPos++] = cmd;
}
+8
View File
@@ -6,6 +6,10 @@ s32 sShrinkWindowVal = 0;
s32 sShrinkWindowCurrentVal = 0;
void ShrinkWindow_SetVal(s32 value) {
if (CVar_GetS32("gDisableBlackBars", 0)) {
sShrinkWindowVal = 0;
return;
}
if (HREG(80) == 0x13 && HREG(81) == 1) {
osSyncPrintf("shrink_window_setval(%d)\n", value);
}
@@ -17,6 +21,10 @@ u32 ShrinkWindow_GetVal(void) {
}
void ShrinkWindow_SetCurrentVal(s32 currentVal) {
if (CVar_GetS32("gDisableBlackBars", 0)) {
sShrinkWindowCurrentVal = 0;
return;
}
if (HREG(80) == 0x13 && HREG(81) == 1) {
osSyncPrintf("shrink_window_setnowval(%d)\n", currentVal);
}
+12 -8
View File
@@ -339,19 +339,19 @@ void func_8002BF60(TargetContext* targetCtx, Actor* actor, s32 actorCategory, Gl
if (CVar_GetS32("gUseNaviCol",0) != 1 ) {
if (actorCategory == ACTORCAT_PLAYER) {
naviColor->inner.r = 255; naviColor->inner.g = 255; naviColor->inner.b = 255;
naviColor->outer.r = 115; naviColor->outer.g = 230; naviColor->outer.b = 255;
naviColor->outer.r = 0; naviColor->outer.g = 0; naviColor->outer.b = 255;
}
if (actorCategory == ACTORCAT_NPC) {
naviColor->inner.r = 100; naviColor->inner.g = 100; naviColor->inner.b = 255;
naviColor->outer.r = 90; naviColor->outer.g = 90; naviColor->outer.b = 255;
naviColor->inner.r = 150; naviColor->inner.g = 150; naviColor->inner.b = 255;
naviColor->outer.r = 150; naviColor->outer.g = 150; naviColor->outer.b = 255;
}
if (actorCategory == ACTORCAT_BOSS || actorCategory == ACTORCAT_ENEMY) {
naviColor->inner.r = 255; naviColor->inner.g = 255; naviColor->inner.b = 0;
naviColor->outer.r = 220; naviColor->outer.g = 220; naviColor->outer.b = 0;
naviColor->outer.r = 220; naviColor->outer.g = 155; naviColor->outer.b = 0;
}
if (actorCategory == ACTORCAT_PROP) {
naviColor->inner.r = 0; naviColor->inner.g = 255; naviColor->inner.b = 90;
naviColor->outer.r = 0; naviColor->outer.g = 220; naviColor->outer.b = 0;
naviColor->inner.r = 0; naviColor->inner.g = 255; naviColor->inner.b = 0;
naviColor->outer.r = 0; naviColor->outer.g = 255; naviColor->outer.b = 0;
}
} else {
if (actorCategory == ACTORCAT_PLAYER) {
@@ -1163,7 +1163,9 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) {
actor->uncullZoneForward = 1000.0f;
actor->uncullZoneScale = 350.0f;
actor->uncullZoneDownward = 700.0f;
if (CVar_GetS32("gDisableDrawDistance", 0) != 0) {
if (CVar_GetS32("gDisableDrawDistance", 0) != 0 && actor->id != ACTOR_EN_TORCH2 && actor->id != ACTOR_EN_BLKOBJ // Extra check for Dark Link and his room
&& actor->id != ACTOR_EN_HORSE // Check for Epona, else if we call her she will spawn at the other side of the map + we can hear her during the title screen sequence
&& actor->id != ACTOR_EN_HORSE_GANON && actor->id != ACTOR_EN_HORSE_ZELDA) { // check for Zelda's and Ganondorf's horses that will always be scene during cinematic whith camera paning
actor->uncullZoneForward = 32767.0f;
actor->uncullZoneScale = 32767.0f;
actor->uncullZoneDownward = 32767.0f;
@@ -2690,7 +2692,9 @@ s32 func_800314B0(GlobalContext* globalCtx, Actor* actor) {
s32 func_800314D4(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, f32 arg3) {
f32 var;
if (CVar_GetS32("gDisableDrawDistance", 0) != 0) {
if (CVar_GetS32("gDisableDrawDistance", 0) != 0 && actor->id != ACTOR_EN_TORCH2 && actor->id != ACTOR_EN_BLKOBJ // Extra check for Dark Link and his room
&& actor->id != ACTOR_EN_HORSE // Check for Epona, else if we call her she will spawn at the other side of the map + we can hear her during the title screen sequence
&& actor->id != ACTOR_EN_HORSE_GANON && actor->id != ACTOR_EN_HORSE_ZELDA) { // check for Zelda's and Ganondorf's horses that will always be scene during cinematic whith camera paning
return true;
}
+1 -1
View File
@@ -7532,7 +7532,7 @@ Vec3s Camera_Update(Camera* camera) {
BINANG_TO_DEGF(camera->camDir.x), camera->camDir.y, BINANG_TO_DEGF(camera->camDir.y));
}
if (camera->timer != -1 && CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_DRIGHT)) {
if (camera->timer != -1 && CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_DRIGHT) && CVar_GetS32("gDebugCamera", 0)) {
camera->timer = 0;
}
-4
View File
@@ -2,13 +2,9 @@
#include <string.h>
SaveContext gSaveContext;
u32 D_8015FA88;
u32 D_8015FA8C;
void SaveContext_Init(void) {
memset(&gSaveContext, 0, sizeof(gSaveContext));
D_8015FA88 = 0;
D_8015FA8C = 0;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = NATURE_ID_DISABLED;
gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX;
+3
View File
@@ -896,6 +896,9 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
if (this->unk_15A > 0) {
this->unk_15A--;
if (CVar_GetS32("gDropsDontDie", 0) && (this->unk_154 <= 0)) {
this->unk_15A++;
}
}
if ((this->unk_15A > 0) && (this->unk_15A < 41) && (this->unk_154 <= 0)) {
+8 -3
View File
@@ -2093,9 +2093,14 @@ void func_80075B44(GlobalContext* globalCtx) {
case 7:
Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_1 << 4 | NATURE_CHANNEL_CRITTER_3,
CHANNEL_IO_PORT_1, 0);
if (globalCtx->envCtx.unk_EE[0] == 0 && globalCtx->envCtx.unk_F2[0] == 0) {
Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_4 << 4 | NATURE_CHANNEL_CRITTER_5,
CHANNEL_IO_PORT_1, 1);
if (globalCtx->envCtx.unk_EE[0] == 0 && globalCtx->envCtx.unk_F2[0] == 0)
{
// OTRTODO: This is where corrupt audio happens. Commenting this out seems to not introduce any side effects?
// Further investigation is needed...
if (gUseLegacySD)
Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_4 << 4 | NATURE_CHANNEL_CRITTER_5,
CHANNEL_IO_PORT_1, 1);
}
globalCtx->envCtx.unk_E0++;
break;
+7 -6
View File
@@ -755,22 +755,23 @@ void Minimap_Draw(GlobalContext* globalCtx) {
if (((globalCtx->sceneNum != SCENE_SPOT01) && (globalCtx->sceneNum != SCENE_SPOT04) &&
(globalCtx->sceneNum != SCENE_SPOT08)) ||
(LINK_AGE_IN_YEARS != YEARS_ADULT)) {
bool Map0 = gMapData->owEntranceIconPosY[sEntranceIconMapIndex] << 2 == 0;
s16 IconSize = 8;
s16 PosX = gMapData->owEntranceIconPosX[sEntranceIconMapIndex]+Right_MM_Margin;
s16 PosY = gMapData->owEntranceIconPosY[sEntranceIconMapIndex]+Bottom_MM_Margin;
s16 PosX = gMapData->owEntranceIconPosX[sEntranceIconMapIndex] + (Map0 ? 0 : Right_MM_Margin);
s16 PosY = gMapData->owEntranceIconPosY[sEntranceIconMapIndex] + (Map0 ? 0 : Bottom_MM_Margin);
//gFixDungeonMinimapIcon fix both Y position of visible icon and hide these non needed.
if (CVar_GetS32("gFixDungeonMinimapIcon", 1) != 0){
if (CVar_GetS32("gFixDungeonMinimapIcon", 0) != 0){
//No idea why and how Original value work but this does actually fix them all.
PosY = PosY+1024;
}
s16 TopLeftX = OTRGetRectDimensionFromRightEdge(PosX) << 2;
s16 TopLeftX = (Map0 ? OTRGetRectDimensionFromLeftEdge(PosX) : OTRGetRectDimensionFromRightEdge(PosX)) << 2;
s16 TopLeftY = PosY << 2;
s16 TopLeftW = OTRGetRectDimensionFromRightEdge(PosX + IconSize) << 2;
s16 TopLeftW = (Map0 ? OTRGetRectDimensionFromLeftEdge(PosX + IconSize) : OTRGetRectDimensionFromRightEdge(PosX + IconSize)) << 2;
s16 TopLeftH = (PosY + IconSize) << 2;
if ((gMapData->owEntranceFlag[sEntranceIconMapIndex] == 0xFFFF) ||
((gMapData->owEntranceFlag[sEntranceIconMapIndex] != 0xFFFF) &&
(gSaveContext.infTable[26] & gBitFlags[gMapData->owEntranceFlag[mapIndex]]))) {
if (gMapData->owEntranceIconPosY[sEntranceIconMapIndex] << 2 != 0 && CVar_GetS32("gFixDungeonMinimapIcon", 1) != 0){
if (!Map0 || !CVar_GetS32("gFixDungeonMinimapIcon", 0)) {
gDPLoadTextureBlock(OVERLAY_DISP++, gMapDungeonEntranceIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b,
IconSize, IconSize, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
+1 -1
View File
@@ -2935,7 +2935,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) {
}
const s16 rCUpBtnX = OTRGetRectDimensionFromRightEdge(R_C_UP_BTN_X+Right_HUD_Margin);
const s16 rCUPIconX = OTRGetRectDimensionFromRightEdge(R_C_UP_ICON_X+Right_HUD_Margin);
const s16 rCUPIconX = OTRGetRectDimensionFromRightEdge(R_C_UP_ICON_X+Right_HUD_Margin-!!CVar_GetS32("gNaviTextFix", 0));
if (CVar_GetS32("gHudColors", 1) == 0) {
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, R_C_BTN_COLOR(0), R_C_BTN_COLOR(1), R_C_BTN_COLOR(2), temp);
} else if (CVar_GetS32("gHudColors", 1) == 1) {
-1
View File
@@ -240,7 +240,6 @@ void Gameplay_Init(GameState* thisx) {
globalCtx->cameraPtrs[MAIN_CAM]->uid = 0;
globalCtx->activeCamera = MAIN_CAM;
func_8005AC48(&globalCtx->mainCamera, 0xFF);
Sram_Init(globalCtx, &globalCtx->sramCtx);
func_80112098(globalCtx);
Message_Init(globalCtx);
GameOver_Init(globalCtx);
+2 -1
View File
@@ -360,7 +360,8 @@ s32 Player_ActionToModelGroup(Player* this, s32 actionParam) {
void Player_SetModelsForHoldingShield(Player* this) {
if ((this->stateFlags1 & 0x400000) &&
((this->itemActionParam < 0) || (this->itemActionParam == this->heldItemActionParam))) {
if (!Player_HoldsTwoHandedWeapon(this) && !Player_IsChildWithHylianShield(this)) {
if ((CVar_GetS32("gShieldTwoHanded", 0) && (this->heldItemActionParam != PLAYER_AP_STICK) ||
!Player_HoldsTwoHandedWeapon(this)) && !Player_IsChildWithHylianShield(this)) {
this->rightHandType = 10;
this->rightHandDLists = &sPlayerDListGroups[10][(void)0, gSaveContext.linkAge];
if (this->sheathType == 18) {
+9 -678
View File
@@ -3,242 +3,14 @@
#include <string.h>
// these are the main substructs of save context.
// we are going to hold off on splitting save context until later on,
// so these temporary structs will live here for now.
typedef struct {
/* 0x00 */ char newf[6]; // string "ZELDAZ"
/* 0x06 */ s16 deaths;
/* 0x08 */ char playerName[8];
/* 0x10 */ s16 n64ddFlag;
/* 0x12 */ s16 healthCapacity; // "max_life"
/* 0x14 */ s16 health; // "now_life"
/* 0x16 */ s8 magicLevel;
/* 0x17 */ s8 magic;
/* 0x18 */ s16 rupees;
/* 0x1A */ u16 swordHealth;
/* 0x1C */ u16 naviTimer;
/* 0x1E */ u8 magicAcquired;
/* 0x1F */ u8 unk_1F;
/* 0x20 */ u8 doubleMagic;
/* 0x21 */ u8 doubleDefense;
/* 0x22 */ u8 bgsFlag;
/* 0x23 */ u8 ocarinaGameRoundNum;
/* 0x24 */ ItemEquips childEquips;
/* 0x2E */ ItemEquips adultEquips;
/* 0x38 */ u32 unk_38; // this may be incorrect, currently used for alignement
/* 0x3C */ char unk_3C[0x0E];
/* 0x4A */ s16 savedSceneNum;
} SavePlayerData; // size = 0x4C
typedef struct {
/* 0x0000 */ SavePlayerData playerData; // "S_Private" substruct name
/* 0x004C */ ItemEquips equips;
/* 0x0058 */ Inventory inventory;
/* 0x00B8 */ SavedSceneFlags sceneFlags[124];
/* 0x0E48 */ FaroresWindData fw;
/* 0x0E70 */ char unk_E70[0x10];
/* 0x0E80 */ s32 gsFlags[6];
/* 0x0E98 */ char unk_E98[0x10];
/* 0x0EA8 */ s32 horseRaceRecord;
/* 0x0EAC */ char unk_EAC[0x0C];
/* 0x0EB8 */ u16 eventChkInf[14]; // "event_chk_inf"
/* 0x0ED4 */ u16 itemGetInf[4]; // "item_get_inf"
/* 0x0EDC */ u16 infTable[30]; // "inf_table"
/* 0x0F18 */ char unk_F18[0x04];
/* 0x0F1C */ u32 worldMapAreaData; // "area_arrival"
/* 0x0F20 */ char unk_F20[0x4];
/* 0x0F24 */ u8 scarecrowCustomSongSet;
/* 0x0F25 */ u8 scarecrowCustomSong[0x360];
/* 0x1285 */ char unk_1285[0x24];
/* 0x12A9 */ u8 scarecrowSpawnSongSet;
/* 0x12AA */ u8 scarecrowSpawnSong[0x80];
/* 0x132A */ char unk_132A[0x02];
/* 0x132C */ HorseData horseData;
/* 0x1336 */ u16 checksum; // "check_sum"
} SaveInfo; // size = 0x1338
typedef struct {
/* 0x00 */ s32 entranceIndex;
/* 0x04 */ s32 linkAge; // 0: Adult; 1: Child
/* 0x08 */ s32 cutsceneIndex;
/* 0x0C */ u16 dayTime; // "zelda_time"
/* 0x10 */ s32 nightFlag;
/* 0x14 */ s32 totalDays;
/* 0x18 */ s32 unk_18; // increments with totalDays, gets reset by goron for bgs and one other use
/* 0x1C */ SaveInfo info; // "information"
} Save; // size = 0x1354
#define SAVE_PLAYER_DATA (*((SavePlayerData*)&gSaveContext.newf))
#define SAVE_INFO (*((SaveInfo*)&gSaveContext.newf))
#define SLOT_SIZE (sizeof(SaveContext) + 0x28)
#define CHECKSUM_SIZE (sizeof(Save) / 2)
#define DEATHS OFFSETOF(SaveContext, deaths)
#define NAME OFFSETOF(SaveContext, playerName)
#define N64DD OFFSETOF(SaveContext, n64ddFlag)
#define HEALTH_CAP OFFSETOF(SaveContext, healthCapacity)
#define QUEST OFFSETOF(SaveContext, inventory.questItems)
#define DEFENSE OFFSETOF(SaveContext, inventory.defenseHearts)
#define HEALTH OFFSETOF(SaveContext, health)
#define SLOT_OFFSET(index) (SRAM_HEADER_SIZE + 0x10 + (index * SLOT_SIZE))
u16 gSramSlotOffsets[] = {
SLOT_OFFSET(0),
SLOT_OFFSET(1),
SLOT_OFFSET(2),
// the latter three saves are backup saves for the former saves
SLOT_OFFSET(3),
SLOT_OFFSET(4),
SLOT_OFFSET(5),
};
static u8 sZeldaMagic[] = { '\0', '\0', '\0', '\x98', '\x09', '\x10', '\x21', 'Z', 'E', 'L', 'D', 'A' };
static SavePlayerData sNewSavePlayerData = {
{ '\0', '\0', '\0', '\0', '\0', '\0' }, // newf
0, // deaths
{ 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName
0, // n64ddFlag
0x30, // healthCapacity
0x30, // defense
0, // magicLevel
0x30, // magic
0, // rupees
0, // swordHealth
0, // naviTimer
0, // magicAcquired
0, // unk_1F
0, // doubleMagic
0, // doubleDefense
0, // bgsFlag
0, // ocarinaGameRoundNum
{
{ ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE }, // buttonItems
{ SLOT_NONE, SLOT_NONE, SLOT_NONE }, // cButtonSlots
0, // equipment
}, // childEquips
{
{ ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE }, // buttonItems
{ SLOT_NONE, SLOT_NONE, SLOT_NONE }, // cButtonSlots
0, // equipment
}, // adultEquips
0, // unk_38
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // unk_3C
0x34, // savedSceneNum
};
static ItemEquips sNewSaveEquips = {
{ ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE }, // buttonItems
{ SLOT_NONE, SLOT_NONE, SLOT_NONE }, // cButtonSlots
0x1100, // equipment
};
static Inventory sNewSaveInventory = {
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, // items
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // ammo
0x1100, // equipment
0, // upgrades
0, // questItems
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // dungeonItems
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
}, // dungeonKeys
0, // defenseHearts
0, // gsTokens
};
static u16 sNewSaveChecksum = 0;
/**
* Initialize new save.
* This save has an empty inventory with 3 hearts and single magic.
*/
void Sram_InitNewSave(void) {
SaveContext* temp = &gSaveContext;
memset(&SAVE_INFO, 0, sizeof(SaveInfo));
gSaveContext.totalDays = 0;
gSaveContext.bgsDayCount = 0;
SAVE_PLAYER_DATA = sNewSavePlayerData;
gSaveContext.equips = sNewSaveEquips;
gSaveContext.inventory = sNewSaveInventory;
temp->checksum = sNewSaveChecksum;
gSaveContext.horseData.scene = SCENE_SPOT00;
gSaveContext.horseData.pos.x = -1840;
gSaveContext.horseData.pos.y = 72;
gSaveContext.horseData.pos.z = 5497;
gSaveContext.horseData.angle = -0x6AD9;
gSaveContext.magicLevel = 0;
gSaveContext.infTable[29] = 1;
gSaveContext.sceneFlags[5].swch = 0x40000000;
Save_InitFile(false);
}
static SavePlayerData sDebugSavePlayerData = {
{ 'Z', 'E', 'L', 'D', 'A', 'Z' }, // newf
0, // deaths
{ 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName ( "LINK" )
0, // n64ddFlag
0xE0, // healthCapacity
0xE0, // health
0, // magicLevel
0x30, // magic
150, // rupees
8, // swordHealth
0, // naviTimer
1, // magicAcquired
0, // unk_1F
0, // doubleMagic
0, // doubleDefense
0, // bgsFlag
0, // ocarinaGameRoundNum
{
{ ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE }, // buttonItems
{ SLOT_NONE, SLOT_NONE, SLOT_NONE }, // cButtonSlots
0, // equipment
}, // childEquips
{
{ ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE }, // buttonItems
{ SLOT_NONE, SLOT_NONE, SLOT_NONE }, // cButtonSlots
0, // equipment
}, // adultEquips
0, // unk_38
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // unk_3C
0x51, // savedSceneNum
};
static ItemEquips sDebugSaveEquips = {
{ ITEM_SWORD_MASTER, ITEM_BOW, ITEM_BOMB, ITEM_OCARINA_FAIRY }, // buttonItems
{ SLOT_BOW, SLOT_BOMB, SLOT_OCARINA }, // cButtonSlots
0x1122, // equipment
};
static Inventory sDebugSaveInventory = {
{
ITEM_STICK, ITEM_NUT, ITEM_BOMB, ITEM_BOW, ITEM_ARROW_FIRE, ITEM_DINS_FIRE,
ITEM_SLINGSHOT, ITEM_OCARINA_FAIRY, ITEM_BOMBCHU, ITEM_HOOKSHOT, ITEM_ARROW_ICE, ITEM_FARORES_WIND,
ITEM_BOOMERANG, ITEM_LENS, ITEM_BEAN, ITEM_HAMMER, ITEM_ARROW_LIGHT, ITEM_NAYRUS_LOVE,
ITEM_BOTTLE, ITEM_POTION_RED, ITEM_POTION_GREEN, ITEM_POTION_BLUE, ITEM_POCKET_EGG, ITEM_WEIRD_EGG,
}, // items
{ 50, 50, 10, 30, 1, 1, 30, 1, 50, 1, 1, 1, 1, 1, 1, 1 }, // ammo
0x7777, // equipment
0x125249, // upgrades
0x1E3FFFF, // questItems
{ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // dungeonItems
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, // dungeonKeys
0, // defenseHearts
0, // gsTokens
};
static u16 sDebugSaveChecksum = 0;
/**
* Initialize debug save. This is also used on the Title Screen
* This save has a mostly full inventory with 10 hearts and single magic.
@@ -249,40 +21,7 @@ static u16 sDebugSaveChecksum = 0;
* and set water level in Water Temple to lowest level.
*/
void Sram_InitDebugSave(void) {
SaveContext* temp = &gSaveContext;
memset(&SAVE_INFO, 0, sizeof(SaveInfo));
gSaveContext.totalDays = 0;
gSaveContext.bgsDayCount = 0;
SAVE_PLAYER_DATA = sDebugSavePlayerData;
gSaveContext.equips = sDebugSaveEquips;
gSaveContext.inventory = sDebugSaveInventory;
temp->checksum = sDebugSaveChecksum;
gSaveContext.horseData.scene = SCENE_SPOT00;
gSaveContext.horseData.pos.x = -1840;
gSaveContext.horseData.pos.y = 72;
gSaveContext.horseData.pos.z = 5497;
gSaveContext.horseData.angle = -0x6AD9;
gSaveContext.infTable[0] |= 0x5009;
gSaveContext.eventChkInf[0] |= 0x123F;
gSaveContext.eventChkInf[8] |= 1;
gSaveContext.eventChkInf[12] |= 0x10;
if (LINK_AGE_IN_YEARS == YEARS_CHILD) {
gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KOKIRI;
Inventory_ChangeEquipment(EQUIP_SWORD, 1);
if (gSaveContext.fileNum == 0xFF) {
gSaveContext.equips.buttonItems[1] = ITEM_SLINGSHOT;
gSaveContext.equips.cButtonSlots[0] = SLOT_SLINGSHOT;
Inventory_ChangeEquipment(EQUIP_SHIELD, 1);
}
}
gSaveContext.entranceIndex = 0xCD;
gSaveContext.magicLevel = 0;
gSaveContext.sceneFlags[5].swch = 0x40000000;
Save_InitFile(true);
}
/**
@@ -295,7 +34,7 @@ void Sram_InitDebugSave(void) {
* - Give and equip master sword if player is adult and doesnt have kokiri sword (bug?)
* - Revert any trade items that spoil
*/
void Sram_OpenSave(SramContext* sramCtx) {
void Sram_OpenSave() {
static s16 dungeonEntrances[] = {
0x0000, 0x0004, 0x0028, 0x0169, 0x0165, 0x0010, 0x0082, 0x0037,
0x0098, 0x0088, 0x041B, 0x0008, 0x0486, 0x0467, 0x0179, 0x056C,
@@ -304,15 +43,7 @@ void Sram_OpenSave(SramContext* sramCtx) {
u16 j;
u8* ptr;
osSyncPrintf("個人File作成\n"); // "Create personal file"
i = gSramSlotOffsets[gSaveContext.fileNum];
osSyncPrintf("ぽいんと=%x(%d)\n", i, gSaveContext.fileNum); // "Point="
memcpy(&gSaveContext, sramCtx->readBuff + i, sizeof(Save));
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("SCENE_DATA_ID = %d SceneNo = %d\n", gSaveContext.savedSceneNum,
((void)0, gSaveContext.entranceIndex));
Save_LoadFile();
switch (gSaveContext.savedSceneNum) {
case SCENE_YDAN:
@@ -446,232 +177,7 @@ void Sram_OpenSave(SramContext* sramCtx) {
gSaveContext.magicLevel = 0;
}
/**
* Write the contents of the Save Context to a main and backup slot in SRAM.
* Note: The whole Save Context is written even though only the `save` substruct is read back later
*/
void Sram_WriteSave(SramContext* sramCtx) {
u16 offset;
u16 checksum;
u16 j;
u16* ptr;
gSaveContext.checksum = 0;
ptr = (u16*)&gSaveContext;
checksum = 0;
j = 0;
for (offset = 0; offset < CHECKSUM_SIZE; offset++) {
if (++j == 0x20) {
j = 0;
}
checksum += *ptr++;
}
gSaveContext.checksum = checksum;
ptr = (u16*)&gSaveContext;
checksum = 0;
for (offset = 0; offset < CHECKSUM_SIZE; offset++) {
if (++j == 0x20) {
j = 0;
}
checksum += *ptr++;
}
offset = gSramSlotOffsets[gSaveContext.fileNum];
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000) + offset, &gSaveContext, SLOT_SIZE, OS_WRITE);
ptr = (u16*)&gSaveContext;
checksum = 0;
for (offset = 0; offset < CHECKSUM_SIZE; offset++) {
if (++j == 0x20) {
j = 0;
}
checksum += *ptr++;
}
offset = gSramSlotOffsets[gSaveContext.fileNum + 3];
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000) + offset, &gSaveContext, SLOT_SIZE, OS_WRITE);
}
/**
* For all 3 slots, verify that the checksum is correct. If corrupted, attempt to load a backup save.
* If backup is also corrupted, default to a new save (or debug save for slot 0 on debug rom).
*
* After verifying all 3 saves, pass relevant data to File Select to be displayed.
*/
void Sram_VerifyAndLoadAllSaves(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
u16 i;
u16 newChecksum;
u16 slotNum;
u16 offset;
u16 j;
u16 oldChecksum;
u16* ptr;
u16 dayTime;
osSyncPrintf("SRAM START─LOAD\n");
memset(sramCtx->readBuff,0, SRAM_SIZE);
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ);
dayTime = ((void)0, gSaveContext.dayTime);
for (slotNum = 0; slotNum < 3; slotNum++) {
offset = gSramSlotOffsets[slotNum];
osSyncPrintf("ぽいんと=%x(%d) SAVE_MAX=%d\n", offset, gSaveContext.fileNum, sizeof(Save));
memcpy(&gSaveContext, sramCtx->readBuff + offset, sizeof(Save));
oldChecksum = gSaveContext.checksum;
gSaveContext.checksum = 0;
ptr = (u16*)&gSaveContext;
osSyncPrintf("\n============= S(%d) =============\n", slotNum);
for (i = newChecksum = j = 0; i < CHECKSUM_SIZE; i++, offset += 2) {
newChecksum += *ptr++;
}
// "SAVE checksum calculation"
osSyncPrintf("\nSAVEチェックサム計算 j=%x mmm=%x ", newChecksum, oldChecksum);
if (newChecksum != oldChecksum) {
// checksum didnt match, try backup save
osSyncPrintf("ERROR!!! %x(%d)\n", gSramSlotOffsets[slotNum], slotNum);
offset = gSramSlotOffsets[slotNum + 3];
memcpy(&gSaveContext, sramCtx->readBuff + offset, sizeof(Save));
oldChecksum = gSaveContext.checksum;
gSaveContext.checksum = 0;
ptr = (u16*)&gSaveContext;
osSyncPrintf("================= BACK─UP ========================\n");
for (i = newChecksum = j = 0; i < CHECKSUM_SIZE; i++, offset += 2) {
newChecksum += *ptr++;
}
// "(B) SAVE checksum calculation"
osSyncPrintf("\n(B)SAVEチェックサム計算 j=%x mmm=%x ", newChecksum, oldChecksum);
if (newChecksum != oldChecksum) {
// backup save didnt work, make new save
osSyncPrintf("ERROR!!! %x(%d+3)\n", gSramSlotOffsets[slotNum + 3], slotNum);
memset(&gSaveContext.entranceIndex, 0, sizeof(s32));
memset(&gSaveContext.linkAge, 0, sizeof(s32));
memset(&gSaveContext.cutsceneIndex, 0, sizeof(s32));
// note that gSaveContext.dayTime is not actually the sizeof(s32)
memset(&gSaveContext.dayTime, 0, sizeof(s32));
memset(&gSaveContext.nightFlag, 0, sizeof(s32));
memset(&gSaveContext.totalDays, 0, sizeof(s32));
memset(&gSaveContext.bgsDayCount, 0, sizeof(s32));
if (!slotNum && CVar_GetS32("gDebugEnabled", 0)) {
Sram_InitDebugSave();
gSaveContext.newf[0] = 'Z';
gSaveContext.newf[1] = 'E';
gSaveContext.newf[2] = 'L';
gSaveContext.newf[3] = 'D';
gSaveContext.newf[4] = 'A';
gSaveContext.newf[5] = 'Z';
osSyncPrintf("newf=%x,%x,%x,%x,%x,%x\n", gSaveContext.newf[0], gSaveContext.newf[1],
gSaveContext.newf[2], gSaveContext.newf[3], gSaveContext.newf[4],
gSaveContext.newf[5]);
} else {
Sram_InitNewSave();
}
ptr = (u16*)&gSaveContext;
osSyncPrintf("\n--------------------------------------------------------------\n");
for (i = newChecksum = j = 0; i < CHECKSUM_SIZE; i++) {
osSyncPrintf("%x ", *ptr);
if (++j == 0x20) {
osSyncPrintf("\n");
j = 0;
}
newChecksum += *ptr++;
}
gSaveContext.checksum = newChecksum;
osSyncPrintf("\nCheck_Sum=%x(%x)\n", gSaveContext.checksum, newChecksum);
i = gSramSlotOffsets[slotNum + 3];
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000) + i, &gSaveContext, SLOT_SIZE, OS_WRITE);
osSyncPrintf("????#%x,%x,%x,%x,%x,%x\n", gSaveContext.newf[0], gSaveContext.newf[1],
gSaveContext.newf[2], gSaveContext.newf[3], gSaveContext.newf[4], gSaveContext.newf[5]);
osSyncPrintf("\nぽいんと=%x(%d+3) check_sum=%x(%x)\n", i, slotNum, gSaveContext.checksum,
newChecksum);
}
i = gSramSlotOffsets[slotNum];
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000) + i, &gSaveContext, SLOT_SIZE, OS_WRITE);
osSyncPrintf("ぽいんと=%x(%d) check_sum=%x(%x)\n", i, slotNum, gSaveContext.checksum, newChecksum);
} else {
osSyncPrintf("\nSAVEデータ OK!!!!\n"); // "SAVE data OK! ! ! !"
}
}
memset(sramCtx->readBuff,0, SRAM_SIZE);
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ);
gSaveContext.dayTime = dayTime;
osSyncPrintf("SAVECT=%x, NAME=%x, LIFE=%x, ITEM=%x, 64DD=%x, HEART=%x\n", DEATHS, NAME, HEALTH_CAP, QUEST, N64DD,
DEFENSE);
memcpy(&fileChooseCtx->deaths[0], sramCtx->readBuff + SLOT_OFFSET(0) + DEATHS, sizeof(fileChooseCtx->deaths[0]));
memcpy(&fileChooseCtx->deaths[1], sramCtx->readBuff + SLOT_OFFSET(1) + DEATHS, sizeof(fileChooseCtx->deaths[0]));
memcpy(&fileChooseCtx->deaths[2], sramCtx->readBuff + SLOT_OFFSET(2) + DEATHS, sizeof(fileChooseCtx->deaths[0]));
memcpy(&fileChooseCtx->fileNames[0], sramCtx->readBuff + SLOT_OFFSET(0) + NAME,
sizeof(fileChooseCtx->fileNames[0]));
memcpy(&fileChooseCtx->fileNames[1], sramCtx->readBuff + SLOT_OFFSET(1) + NAME,
sizeof(fileChooseCtx->fileNames[0]));
memcpy(&fileChooseCtx->fileNames[2], sramCtx->readBuff + SLOT_OFFSET(2) + NAME,
sizeof(fileChooseCtx->fileNames[0]));
memcpy(&fileChooseCtx->healthCapacities[0], sramCtx->readBuff + SLOT_OFFSET(0) + HEALTH_CAP,
sizeof(fileChooseCtx->healthCapacities[0]));
memcpy(&fileChooseCtx->healthCapacities[1], sramCtx->readBuff + SLOT_OFFSET(1) + HEALTH_CAP,
sizeof(fileChooseCtx->healthCapacities[0]));
memcpy(&fileChooseCtx->healthCapacities[2], sramCtx->readBuff + SLOT_OFFSET(2) + HEALTH_CAP,
sizeof(fileChooseCtx->healthCapacities[0]));
memcpy(&fileChooseCtx->questItems[0], sramCtx->readBuff + SLOT_OFFSET(0) + QUEST,
sizeof(fileChooseCtx->questItems[0]));
memcpy(&fileChooseCtx->questItems[1], sramCtx->readBuff + SLOT_OFFSET(1) + QUEST,
sizeof(fileChooseCtx->questItems[0]));
memcpy(&fileChooseCtx->questItems[2], sramCtx->readBuff + SLOT_OFFSET(2) + QUEST,
sizeof(fileChooseCtx->questItems[0]));
memcpy(&fileChooseCtx->n64ddFlags[0], sramCtx->readBuff + SLOT_OFFSET(0) + N64DD,
sizeof(fileChooseCtx->n64ddFlags[0]));
memcpy(&fileChooseCtx->n64ddFlags[1], sramCtx->readBuff + SLOT_OFFSET(1) + N64DD,
sizeof(fileChooseCtx->n64ddFlags[0]));
memcpy(&fileChooseCtx->n64ddFlags[2], sramCtx->readBuff + SLOT_OFFSET(2) + N64DD,
sizeof(fileChooseCtx->n64ddFlags[0]));
memcpy(&fileChooseCtx->defense[0], sramCtx->readBuff + SLOT_OFFSET(0) + DEFENSE,
sizeof(fileChooseCtx->defense[0]));
memcpy(&fileChooseCtx->defense[1], sramCtx->readBuff + SLOT_OFFSET(1) + DEFENSE,
sizeof(fileChooseCtx->defense[0]));
memcpy(&fileChooseCtx->defense[2], sramCtx->readBuff + SLOT_OFFSET(2) + DEFENSE,
sizeof(fileChooseCtx->defense[0]));
memcpy(&fileChooseCtx->health[0], sramCtx->readBuff + SLOT_OFFSET(0) + HEALTH, sizeof(fileChooseCtx->health[0]));
memcpy(&fileChooseCtx->health[1], sramCtx->readBuff + SLOT_OFFSET(1) + HEALTH, sizeof(fileChooseCtx->health[0]));
memcpy(&fileChooseCtx->health[2], sramCtx->readBuff + SLOT_OFFSET(2) + HEALTH, sizeof(fileChooseCtx->health[0]));
osSyncPrintf("f_64dd=%d, %d, %d\n", fileChooseCtx->n64ddFlags[0], fileChooseCtx->n64ddFlags[1],
fileChooseCtx->n64ddFlags[2]);
osSyncPrintf("heart_status=%d, %d, %d\n", fileChooseCtx->defense[0], fileChooseCtx->defense[1],
fileChooseCtx->defense[2]);
osSyncPrintf("now_life=%d, %d, %d\n", fileChooseCtx->health[0], fileChooseCtx->health[1], fileChooseCtx->health[2]);
}
void Sram_InitSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
void Sram_InitSave(FileChooseContext* fileChooseCtx) {
u16 offset;
u16 j;
u16* ptr;
@@ -693,189 +199,14 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
}
for (offset = 0; offset < 8; offset++) {
gSaveContext.playerName[offset] = fileChooseCtx->fileNames[fileChooseCtx->buttonIndex][offset];
gSaveContext.playerName[offset] = Save_GetSaveMetaInfo(fileChooseCtx->buttonIndex)->playerName[offset];
}
gSaveContext.newf[0] = 'Z';
gSaveContext.newf[1] = 'E';
gSaveContext.newf[2] = 'L';
gSaveContext.newf[3] = 'D';
gSaveContext.newf[4] = 'A';
gSaveContext.newf[5] = 'Z';
gSaveContext.n64ddFlag = fileChooseCtx->n64ddFlag;
osSyncPrintf("64DDフラグ=%d\n", fileChooseCtx->n64ddFlag);
osSyncPrintf("newf=%x,%x,%x,%x,%x,%x\n", gSaveContext.newf[0], gSaveContext.newf[1], gSaveContext.newf[2],
gSaveContext.newf[3], gSaveContext.newf[4], gSaveContext.newf[5]);
osSyncPrintf("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
ptr = (u16*)&gSaveContext;
j = 0;
checksum = 0;
for (offset = 0; offset < CHECKSUM_SIZE; offset++) {
osSyncPrintf("%x ", *ptr);
checksum += *ptr++;
if (++j == 0x20) {
osSyncPrintf("\n");
j = 0;
}
}
gSaveContext.checksum = checksum;
osSyncPrintf("\nチェックサム=%x\n", gSaveContext.checksum); // "Checksum = %x"
offset = gSramSlotOffsets[gSaveContext.fileNum];
osSyncPrintf("I=%x no=%d\n", offset, gSaveContext.fileNum);
memcpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
offset = gSramSlotOffsets[gSaveContext.fileNum + 3];
osSyncPrintf("I=%x no=%d\n", offset, gSaveContext.fileNum + 3);
memcpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_WRITE);
osSyncPrintf("SAVE終了\n"); // "SAVE end"
osSyncPrintf("z_common_data.file_no = %d\n", gSaveContext.fileNum);
osSyncPrintf("SAVECT=%x, NAME=%x, LIFE=%x, ITEM=%x, SAVE_64DD=%x\n", DEATHS, NAME, HEALTH_CAP, QUEST, N64DD);
j = gSramSlotOffsets[gSaveContext.fileNum];
memcpy(&fileChooseCtx->deaths[gSaveContext.fileNum], sramCtx->readBuff + j + DEATHS,
sizeof(fileChooseCtx->deaths[0]));
memcpy(&fileChooseCtx->fileNames[gSaveContext.fileNum], sramCtx->readBuff + j + NAME,
sizeof(fileChooseCtx->fileNames[0]));
memcpy(&fileChooseCtx->healthCapacities[gSaveContext.fileNum], sramCtx->readBuff + j + HEALTH_CAP,
sizeof(fileChooseCtx->healthCapacities[0]));
memcpy(&fileChooseCtx->questItems[gSaveContext.fileNum], sramCtx->readBuff + j + QUEST,
sizeof(fileChooseCtx->questItems[0]));
memcpy(&fileChooseCtx->n64ddFlags[gSaveContext.fileNum], sramCtx->readBuff + j + N64DD,
sizeof(fileChooseCtx->n64ddFlags[0]));
memcpy(&fileChooseCtx->defense[gSaveContext.fileNum], sramCtx->readBuff + j + DEFENSE,
sizeof(fileChooseCtx->defense[0]));
memcpy(&fileChooseCtx->health[gSaveContext.fileNum], sramCtx->readBuff + j + HEALTH,
sizeof(fileChooseCtx->health[0]));
osSyncPrintf("f_64dd[%d]=%d\n", gSaveContext.fileNum, fileChooseCtx->n64ddFlags[gSaveContext.fileNum]);
osSyncPrintf("heart_status[%d]=%d\n", gSaveContext.fileNum, fileChooseCtx->defense[gSaveContext.fileNum]);
osSyncPrintf("now_life[%d]=%d\n", gSaveContext.fileNum, fileChooseCtx->health[gSaveContext.fileNum]);
Save_SaveFile();
}
void Sram_EraseSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
s32 offset;
void Sram_InitSram(GameState* gameState) {
Save_Init();
Sram_InitNewSave();
offset = gSramSlotOffsets[fileChooseCtx->selectedFileIndex];
memcpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000) + offset, &gSaveContext, SLOT_SIZE, OS_WRITE);
memcpy(&fileChooseCtx->n64ddFlags[fileChooseCtx->selectedFileIndex], sramCtx->readBuff + offset + N64DD,
sizeof(fileChooseCtx->n64ddFlags[0]));
offset = gSramSlotOffsets[fileChooseCtx->selectedFileIndex + 3];
memcpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000) + offset, &gSaveContext, SLOT_SIZE, OS_WRITE);
osSyncPrintf("CLEAR終了\n");
}
void Sram_CopySave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
s32 offset;
osSyncPrintf("READ=%d(%x) COPY=%d(%x)\n", fileChooseCtx->selectedFileIndex,
gSramSlotOffsets[fileChooseCtx->selectedFileIndex], fileChooseCtx->copyDestFileIndex,
gSramSlotOffsets[fileChooseCtx->copyDestFileIndex]);
offset = gSramSlotOffsets[fileChooseCtx->selectedFileIndex];
memcpy(&gSaveContext, sramCtx->readBuff + offset, sizeof(Save));
offset = gSramSlotOffsets[fileChooseCtx->copyDestFileIndex];
memcpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
offset = gSramSlotOffsets[fileChooseCtx->copyDestFileIndex + 3];
memcpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_WRITE);
offset = gSramSlotOffsets[fileChooseCtx->copyDestFileIndex];
memcpy(&fileChooseCtx->deaths[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + DEATHS,
sizeof(fileChooseCtx->deaths[0]));
memcpy(&fileChooseCtx->fileNames[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + NAME,
sizeof(fileChooseCtx->fileNames[0]));
memcpy(&fileChooseCtx->healthCapacities[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + HEALTH_CAP,
sizeof(fileChooseCtx->healthCapacities[0]));
memcpy(&fileChooseCtx->questItems[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + QUEST,
sizeof(fileChooseCtx->questItems[0]));
memcpy(&fileChooseCtx->n64ddFlags[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + N64DD,
sizeof(fileChooseCtx->n64ddFlags[0]));
memcpy(&fileChooseCtx->defense[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + DEFENSE,
sizeof(fileChooseCtx->defense[0]));
memcpy(&fileChooseCtx->health[fileChooseCtx->copyDestFileIndex], (sramCtx->readBuff + offset) + HEALTH,
sizeof(fileChooseCtx->health[0]));
osSyncPrintf("f_64dd[%d]=%d\n", gSaveContext.fileNum, fileChooseCtx->n64ddFlags[gSaveContext.fileNum]);
osSyncPrintf("heart_status[%d]=%d\n", gSaveContext.fileNum, fileChooseCtx->defense[gSaveContext.fileNum]);
osSyncPrintf("COPY終了\n"); // "Copy end"
}
/**
* Write the first 16 bytes of the read buffer to the SRAM header
*/
void Sram_WriteSramHeader(SramContext* sramCtx) {
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_HEADER_SIZE, OS_WRITE);
}
void Sram_InitSram(GameState* gameState, SramContext* sramCtx) {
u16 i;
osSyncPrintf("sram_initialize( Game *game, Sram *sram )\n");
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ);
for (i = 0; i < ARRAY_COUNTU(sZeldaMagic) - 3; i++) {
if (sZeldaMagic[i + SRAM_HEADER_MAGIC] != sramCtx->readBuff[i + SRAM_HEADER_MAGIC]) {
osSyncPrintf("SRAM破壊!!!!!!\n"); // "SRAM destruction! ! ! ! ! !"
gSaveContext.language = CVar_GetS32("gLanguages", 0);
memcpy(sramCtx->readBuff, sZeldaMagic, sizeof(sZeldaMagic));
sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language;
Sram_WriteSramHeader(sramCtx);
}
}
gSaveContext.audioSetting = sramCtx->readBuff[SRAM_HEADER_SOUND] & 3;
gSaveContext.zTargetSetting = sramCtx->readBuff[SRAM_HEADER_ZTARGET] & 1;
gSaveContext.language = CVar_GetS32("gLanguages", 0);
if (gSaveContext.language >= LANGUAGE_MAX) {
gSaveContext.language = LANGUAGE_ENG;
sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language;
Sram_WriteSramHeader(sramCtx);
}
if (CHECK_BTN_ANY(gameState->input[2].cur.button, BTN_DRIGHT)) {
memset(sramCtx->readBuff, 0,SRAM_SIZE);
for (i = 0; i < CHECKSUM_SIZE; i++) {
sramCtx->readBuff[i] = i;
}
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_WRITE);
osSyncPrintf("SRAM破壊!!!!!!\n"); // "SRAM destruction! ! ! ! ! !"
}
// "GOOD! GOOD! Size = %d + %d = %d"
osSyncPrintf("GOOD!GOOD! サイズ=%d + %d = %d\n", sizeof(SaveInfo), 4, sizeof(SaveInfo) + 4);
osSyncPrintf(VT_FGCOL(BLUE));
osSyncPrintf("Na_SetSoundOutputMode = %d\n", gSaveContext.audioSetting);
osSyncPrintf("Na_SetSoundOutputMode = %d\n", gSaveContext.audioSetting);
osSyncPrintf("Na_SetSoundOutputMode = %d\n", gSaveContext.audioSetting);
osSyncPrintf(VT_RST);
func_800F6700(gSaveContext.audioSetting);
}
void Sram_Alloc(GameState* gameState, SramContext* sramCtx) {
sramCtx->readBuff = GameState_Alloc(gameState, SRAM_SIZE, "../z_sram.c", 1294);
ASSERT(sramCtx->readBuff != NULL, "sram->read_buff != NULL", "../z_sram.c", 1295);
}
void Sram_Init(GlobalContext* globalCtx, SramContext* sramCtx) {
}
+3 -28
View File
@@ -58,38 +58,13 @@ void SsSram_Dma(void* dramAddr, size_t size, s32 direction) {
void SsSram_ReadWrite(uintptr_t addr, void* dramAddr, size_t size, s32 direction) {
osSyncPrintf("ssSRAMReadWrite:%08x %08x %08x %d\n", addr, (uintptr_t)dramAddr, size, direction);
//Check to see if the file exists
FILE* saveFile;
saveFile = fopen("oot_save.sav", "rb");
if (saveFile == NULL) {
saveFile = fopen("oot_save.sav", "wb");
fseek(saveFile, 0, SEEK_SET);
assert(saveFile != NULL); // OTRTODO LOG
uint8_t zero = 0;
for (uint32_t i = 0; i < SRAM_SIZE; i++) {
fwrite(&zero, 1, 1, saveFile);
}
fclose(saveFile);
} else {
fclose(saveFile);
}
switch (direction) {
case OS_WRITE: {
saveFile = fopen("oot_save.sav", "r+b");
rewind(saveFile);
fseek(saveFile, addr, SEEK_SET);
fwrite(dramAddr, size, 1, saveFile);
fclose(saveFile);
Ctx_WriteSaveFile(addr, dramAddr, size);
} break;
case OS_READ: {
saveFile = fopen("oot_save.sav", "rb+");
rewind(saveFile);
fseek(saveFile, addr, SEEK_SET);
fread(dramAddr, size, 1, saveFile);
fclose(saveFile);
Ctx_ReadSaveFile(addr, dramAddr, size);
} break;
}
//SsSram_Init(addr, DEVICE_TYPE_SRAM, PI_DOMAIN2, 5, 0xD, 2, 0xC, 0);
@@ -1209,19 +1209,15 @@ void BossGanon_ShatterWindows(u8 windowShatterState) {
}
void BossGanon_DeathAndTowerCutscene(BossGanon* this, GlobalContext* globalCtx) {
const bool originalBlood = CVar_GetS32("gOriginalBlood", 1);
static Color_RGBA8 bloodPrimColor = { 0, 120, 0, 255 };
static Color_RGBA8 bloodEnvColor = { 0, 120, 0, 255 };
static Color_RGBA8 bloodPrimColor = { 120, 0, 0, 255 };
static Color_RGBA8 bloodEnvColor = { 120, 0, 0, 255 };
if(CVar_GetS32("gRedGanonBlood", 0)) {
bloodPrimColor.r = 120;
bloodPrimColor.g = 0;
if(!originalBlood) {
bloodPrimColor.r = 0;
bloodPrimColor.g = 120;
bloodPrimColor.b = 0;
bloodEnvColor.r = 0;
bloodEnvColor.g = 120;
bloodEnvColor.b = 0;
bloodEnvColor.r = 120;
bloodEnvColor.g = 0;
}
s16 i;
@@ -1456,6 +1456,17 @@ void func_80901020(BossGanon2* this, GlobalContext* globalCtx) {
void func_8090109C(BossGanon2* this, GlobalContext* globalCtx) {
u8 i;
static Color_RGBA8 sPrimColor = { 0, 120, 0, 255 };
static Color_RGBA8 sEnvColor = { 0, 120, 0, 255 };
if(CVar_GetS32("gRedGanonBlood", 0)) {
sPrimColor.r = 120;
sPrimColor.g = 0;
sEnvColor.r = 120;
sEnvColor.g = 0;
}
for (i = 0; i < 70; i++) {
Vec3f velocity;
Vec3f accel;
@@ -238,10 +238,6 @@ static ColliderJntSphInit sJntSphInit2 = {
sJntSphItemsInit2,
};
static Color_RGBA8 sPrimColor = { 0, 120, 0, 255 };
static Color_RGBA8 sEnvColor = { 0, 120, 0, 255 };
static Vec3f D_8090702C[] = {
{ 10.0f, -10.0f, 0.0f },
{ 0.0f, 0.0f, -60.0f },
@@ -110,7 +110,7 @@ void ElfMsg_Destroy(Actor* thisx, GlobalContext* globalCtx) {
s32 ElfMsg_GetMessageId(ElfMsg* this) {
// Negative message ID forces link to talk to Navi
if (this->actor.params & 0x8000) {
if (this->actor.params & 0x8000 || CVar_GetS32("gNoForcedNavi", 0) != 0) {
return (this->actor.params & 0xFF) + 0x100;
} else {
return -((this->actor.params & 0xFF) + 0x100);
@@ -118,7 +118,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) {
func_809DEE9C(this);
this->actionFunc = func_809DF96C;
if (globalCtx->sceneNum == SCENE_LINK_HOME) {
if (!LINK_IS_ADULT) {
if (!LINK_IS_ADULT && !CVar_GetS32("gCowOfTime", 0)) {
Actor_Kill(&this->actor);
return;
}
@@ -452,7 +452,7 @@ s32 EnGirlA_CanBuy_DekuNuts(GlobalContext* globalCtx, EnGirlA* this) {
if (gSaveContext.rupees < this->basePrice) {
return CANBUY_RESULT_NEED_RUPEES;
}
if (Item_CheckObtainability(ITEM_NUT) == ITEM_NONE) {
if ((Item_CheckObtainability(ITEM_NUT) == ITEM_NONE) && !CVar_GetS32("gFastDrops", 0)) {
return CANBUY_RESULT_SUCCESS_FANFARE;
}
return CANBUY_RESULT_SUCCESS;
@@ -465,7 +465,7 @@ s32 EnGirlA_CanBuy_DekuSticks(GlobalContext* globalCtx, EnGirlA* this) {
if (gSaveContext.rupees < this->basePrice) {
return CANBUY_RESULT_NEED_RUPEES;
}
if (Item_CheckObtainability(ITEM_STICK) == ITEM_NONE) {
if ((Item_CheckObtainability(ITEM_STICK) == ITEM_NONE) && !CVar_GetS32("gFastDrops", 0)) {
return CANBUY_RESULT_SUCCESS_FANFARE;
}
return CANBUY_RESULT_SUCCESS;
@@ -652,7 +652,7 @@ s32 EnGirlA_CanBuy_DekuSeeds(GlobalContext* globalCtx, EnGirlA* this) {
if (gSaveContext.rupees < this->basePrice) {
return CANBUY_RESULT_NEED_RUPEES;
}
if (Item_CheckObtainability(ITEM_SEEDS) == ITEM_NONE) {
if ((Item_CheckObtainability(ITEM_SEEDS) == ITEM_NONE) && !CVar_GetS32("gFastDrops", 0)) {
return CANBUY_RESULT_SUCCESS_FANFARE;
}
return CANBUY_RESULT_SUCCESS;
@@ -29,7 +29,7 @@ void EnHeishi1_TurnTowardLink(EnHeishi1* this, GlobalContext* globalCtx);
void EnHeishi1_Kick(EnHeishi1* this, GlobalContext* globalCtx);
void EnHeishi1_WaitNight(EnHeishi1* this, GlobalContext* globalCtx);
static s32 sPlayerIsCaught = false;
s32 sHeishi1PlayerIsCaught = false;
const ActorInit En_Heishi1_InitVars = {
0,
@@ -154,7 +154,7 @@ void EnHeishi1_Walk(EnHeishi1* this, GlobalContext* globalCtx) {
Audio_PlayActorSound2(&this->actor, NA_SE_EV_KNIGHT_WALK);
}
if (!sPlayerIsCaught) {
if (!sHeishi1PlayerIsCaught) {
path = &globalCtx->setupPathList[this->path];
pointPos = SEGMENTED_TO_VIRTUAL(path->points);
pointPos += this->waypoint;
@@ -259,7 +259,7 @@ void EnHeishi1_Wait(EnHeishi1* this, GlobalContext* globalCtx) {
s32 i;
SkelAnime_Update(&this->skelAnime);
if (!sPlayerIsCaught) {
if (!sHeishi1PlayerIsCaught) {
switch (this->headBehaviorDecided) {
case false:
this->headDirection++;
@@ -352,7 +352,7 @@ void EnHeishi1_Kick(EnHeishi1* this, GlobalContext* globalCtx) {
globalCtx->nextEntranceIndex = 0x4FA;
globalCtx->sceneLoadFlag = 0x14;
this->loadStarted = true;
sPlayerIsCaught = false;
sHeishi1PlayerIsCaught = false;
globalCtx->fadeTransition = 0x2E;
gSaveContext.nextTransition = 0x2E;
}
@@ -413,7 +413,7 @@ void EnHeishi1_Update(Actor* thisx, GlobalContext* globalCtx) {
if (this->type != 5) {
path = this->path * 2;
if ((sCamDataIdxs[path] == activeCam->camDataIdx) || (sCamDataIdxs[path + 1] == activeCam->camDataIdx)) {
if (!sPlayerIsCaught) {
if (!sHeishi1PlayerIsCaught) {
if ((this->actionFunc == EnHeishi1_Walk) || (this->actionFunc == EnHeishi1_Wait)) {
Vec3f searchBallVel;
Vec3f searchBallAccel = { 0.0f, 0.0f, 0.0f };
@@ -459,7 +459,7 @@ void EnHeishi1_Update(Actor* thisx, GlobalContext* globalCtx) {
// "Discovered!"
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST);
func_8002DF54(globalCtx, &this->actor, 1);
sPlayerIsCaught = true;
sHeishi1PlayerIsCaught = true;
this->actionFunc = EnHeishi1_SetupMoveToLink;
}
}
+9 -1
View File
@@ -1080,7 +1080,15 @@ void func_80A98DB4(EnKo* this, GlobalContext* globalCtx) {
dist = this->actor.xzDistToPlayer;
}
Math_SmoothStepToF(&this->modelAlpha, (this->appearDist < dist) ? 0.0f : 255.0f, 0.3f, 40.0f, 1.0f);
if (CVar_GetS32("gDisableKokiriDrawDistance", 0) != 0) {
this->appearDist = 32767.0f;
Math_SmoothStepToF(&this->modelAlpha, (this->appearDist < dist) ? 0.0f : 255.0f, 0.3f, 40.0f, 1.0f);
f32 test = this->appearDist;
} else {
this->appearDist = 180.0f;
Math_SmoothStepToF(&this->modelAlpha, (this->appearDist < dist) ? 0.0f : 255.0f, 0.3f, 40.0f, 1.0f);
}
if (this->modelAlpha < 10.0f) {
this->actor.flags &= ~ACTOR_FLAG_0;
} else {
+12 -4
View File
@@ -613,10 +613,18 @@ void func_80AAB5A4(EnMd* this, GlobalContext* globalCtx) {
f32 temp;
if (globalCtx->sceneNum != SCENE_KOKIRI_HOME4) {
temp = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) &&
(globalCtx->sceneNum == SCENE_SPOT04))
? 100.0f
: 400.0f;
if (CVar_GetS32("gDisableKokiriDrawDistance", 0) != 0) {
temp = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) &&
(globalCtx->sceneNum == SCENE_SPOT04))
? 100.0f
: 32767.0f;
} else {
temp = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) &&
(globalCtx->sceneNum == SCENE_SPOT04))
? 100.0f
: 400.0f;
}
this->alpha = func_80034DD4(&this->actor, globalCtx, this->alpha, temp);
this->actor.shape.shadowAlpha = this->alpha;
} else {
+6 -1
View File
@@ -727,7 +727,12 @@ void EnSa_Update(Actor* thisx, GlobalContext* globalCtx) {
}
if (this->actionFunc != func_80AF68E4) {
this->alpha = func_80034DD4(&this->actor, globalCtx, this->alpha, 400.0f);
if (CVar_GetS32("gDisableKokiriDrawDistance", 0) != 0) {
this->alpha = func_80034DD4(&this->actor, globalCtx, this->alpha, 32767);
}
else {
this->alpha = func_80034DD4(&this->actor, globalCtx, this->alpha, 400.0f);
}
} else {
this->alpha = 255;
}
+4 -3
View File
@@ -94,7 +94,9 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) {
if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) {
this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER;
Item_Give(globalCtx, ITEM_SKULL_TOKEN);
player->actor.freezeTimer = 10;
if (CVar_GetS32("gSkulltulaFreeze", 0) != 1) {
player->actor.freezeTimer = 20;
}
Message_StartTextbox(globalCtx, 0xB4, NULL);
Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET);
this->actionFunc = func_80AFB950;
@@ -116,7 +118,6 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) {
if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) {
Item_Give(globalCtx, ITEM_SKULL_TOKEN);
player->actor.freezeTimer = 10;
Message_StartTextbox(globalCtx, 0xB4, NULL);
Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET);
this->actionFunc = func_80AFB950;
@@ -126,7 +127,7 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) {
void func_80AFB950(EnSi* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_CLOSING) {
if (Message_GetState(&globalCtx->msgCtx) != TEXT_STATE_CLOSING && CVar_GetS32("gSkulltulaFreeze", 0) != 1) {
player->actor.freezeTimer = 10;
} else {
SET_GS_FLAGS((this->actor.params & 0x1F00) >> 8, this->actor.params & 0xFF);
+18 -3
View File
@@ -9,6 +9,10 @@
#include "objects/object_tk/object_tk.h"
#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3)
#define COLLECTFLAG_GRAVEDIGGING_HEART_PIECE 0x19
#define ITEMGETINFFLAG_GRAVEDIGGING_HEART_PIECE 0x1000
bool heartPieceSpawned;
void EnTk_Init(Actor* thisx, GlobalContext* globalCtx);
void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx);
@@ -505,6 +509,7 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) {
this->currentReward = -1;
this->currentSpot = NULL;
this->actionFunc = EnTk_Rest;
heartPieceSpawned = false;
}
void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx) {
@@ -611,13 +616,23 @@ void EnTk_Dig(EnTk* this, GlobalContext* globalCtx) {
* Upgrade the purple rupee reward to the heart piece if this
* is the first grand prize dig.
*/
if (!(gSaveContext.itemGetInf[1] & 0x1000)) {
gSaveContext.itemGetInf[1] |= 0x1000;
// If vanilla itemGetInf flag is not set, it's impossible for the new flag to be set, so return true.
// Otherwise if the gGravediggingTourFix is enabled and the new flag hasn't been set, return true.
// If true, spawn the heart piece and set the vanilla itemGetInf flag and new temp clear flag.
if (!heartPieceSpawned &&
(!(gSaveContext.itemGetInf[1] & ITEMGETINFFLAG_GRAVEDIGGING_HEART_PIECE) ||
CVar_GetS32("gGravediggingTourFix", 0) &&
!Flags_GetCollectible(globalCtx, COLLECTFLAG_GRAVEDIGGING_HEART_PIECE))) {
this->currentReward = 4;
gSaveContext.itemGetInf[1] |= ITEMGETINFFLAG_GRAVEDIGGING_HEART_PIECE;
heartPieceSpawned = true;
}
}
Item_DropCollectible(globalCtx, &rewardPos, rewardParams[this->currentReward]);
EnItem00* reward = Item_DropCollectible(globalCtx, &rewardPos, rewardParams[this->currentReward]);
if (this->currentReward == 4) {
reward->collectibleFlag = COLLECTFLAG_GRAVEDIGGING_HEART_PIECE;
}
}
}
@@ -140,8 +140,9 @@ void OceffStorm_Draw2(Actor* thisx, GlobalContext* globalCtx) {
gSPDisplayList(POLY_XLU_DISP++, sMaterialDL);
gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, scroll * 8, scroll * 4, 64, 64, 1,
scroll * 4, scroll * 4, 64, 64));
gSPTextureRectangle(POLY_XLU_DISP++, 0, 0, (SCREEN_WIDTH << 2), (SCREEN_HEIGHT << 2), G_TX_RENDERTILE, 0, 0, 140,
(1 << 15) | (31 << 10) | 884);
gSPWideTextureRectangle(POLY_XLU_DISP++, OTRGetRectDimensionFromLeftEdge(0) << 2, 0,
OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) << 2, 0x03C0, G_TX_RENDERTILE, 0, 0, 0x008C,
-0x008C);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_oceff_storm.c", 477);
}
@@ -351,6 +351,7 @@ s32 func_80852F38(GlobalContext* globalCtx, Player* this);
s32 func_80852FFC(GlobalContext* globalCtx, Actor* actor, s32 csMode);
void func_80853080(Player* this, GlobalContext* globalCtx);
s32 Player_InflictDamage(GlobalContext* globalCtx, s32 damage);
s32 Player_InflictDamageModified(GlobalContext* globalCtx, s32 damage, u8 modified);
void func_80853148(GlobalContext* globalCtx, Actor* actor);
// .bss part 1
@@ -2106,10 +2107,10 @@ LinkAnimationHeader* func_808346C4(GlobalContext* globalCtx, Player* this) {
func_808323B4(globalCtx, this);
if (this->unk_870 < 0.5f) {
return D_808543A4[Player_HoldsTwoHandedWeapon(this)];
return D_808543A4[Player_HoldsTwoHandedWeapon(this) && !(CVar_GetS32("gShieldTwoHanded", 0) && (this->heldItemActionParam != PLAYER_AP_STICK))];
}
else {
return D_808543AC[Player_HoldsTwoHandedWeapon(this)];
return D_808543AC[Player_HoldsTwoHandedWeapon(this) && !(CVar_GetS32("gShieldTwoHanded", 0) && (this->heldItemActionParam != PLAYER_AP_STICK))];
}
}
@@ -2779,22 +2780,24 @@ void func_80835F44(GlobalContext* globalCtx, Player* this, s32 item) {
if (actionParam >= PLAYER_AP_BOOTS_KOKIRI) {
u16 bootsValue = actionParam - PLAYER_AP_BOOTS_KOKIRI + 1;
if (CUR_EQUIP_VALUE(EQUIP_BOOTS) == bootsValue) {
Inventory_ChangeEquipment(EQUIP_BOOTS, 1);
Inventory_ChangeEquipment(EQUIP_BOOTS, PLAYER_BOOTS_KOKIRI + 1);
} else {
Inventory_ChangeEquipment(EQUIP_BOOTS, bootsValue);
}
Player_SetEquipmentData(globalCtx, this);
func_808328EC(this, CUR_EQUIP_VALUE(EQUIP_BOOTS) == PLAYER_BOOTS_IRON + 1 ? NA_SE_PL_WALK_HEAVYBOOTS : NA_SE_PL_CHANGE_ARMS);
return;
}
if (actionParam >= PLAYER_AP_TUNIC_KOKIRI) {
u16 tunicValue = actionParam - PLAYER_AP_TUNIC_KOKIRI + 1;
if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == tunicValue) {
Inventory_ChangeEquipment(EQUIP_TUNIC, 1);
Inventory_ChangeEquipment(EQUIP_TUNIC, PLAYER_TUNIC_KOKIRI + 1);
} else {
Inventory_ChangeEquipment(EQUIP_TUNIC, tunicValue);
}
Player_SetEquipmentData(globalCtx, this);
func_808328EC(this, NA_SE_PL_CHANGE_ARMS);
return;
}
@@ -3514,12 +3517,22 @@ void func_80837AFC(Player* this, s32 timer) {
this->unk_88F = 0;
}
s32 func_80837B18(GlobalContext* globalCtx, Player* this, s32 damage) {
s32 func_80837B18_modified(GlobalContext* globalCtx, Player* this, s32 damage, u8 modified) {
if ((this->invincibilityTimer != 0) || (this->actor.category != ACTORCAT_PLAYER)) {
return 1;
}
return Health_ChangeBy(globalCtx, damage);
s32 modifiedDamage = damage;
if (modified)
{
modifiedDamage *= CVar_GetS32("gDamageMul", 1);
}
return Health_ChangeBy(globalCtx, modifiedDamage);
}
s32 func_80837B18(GlobalContext* globalCtx, Player* this, s32 damage) {
return func_80837B18_modified(globalCtx, this, damage, true);
}
void func_80837B60(Player* this) {
@@ -3707,7 +3720,7 @@ s32 func_8083816C(s32 arg0) {
}
void func_8083819C(Player* this, GlobalContext* globalCtx) {
if (this->currentShield == PLAYER_SHIELD_DEKU) {
if (this->currentShield == PLAYER_SHIELD_DEKU && (CVar_GetS32("gFireproofDekuShield", 0) == 0)) {
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_SHIELD, this->actor.world.pos.x,
this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1);
Inventory_DeleteEquipment(globalCtx, EQUIP_SHIELD);
@@ -3745,7 +3758,7 @@ s32 func_808382DC(Player* this, GlobalContext* globalCtx) {
if (this->unk_A86 != 0) {
if (!Player_InBlockingCsMode(globalCtx, this)) {
Player_InflictDamage(globalCtx, -16);
Player_InflictDamageModified(globalCtx, -16 * CVar_GetS32("gVoidDamageMul", 1), false);
this->unk_A86 = 0;
}
}
@@ -5468,8 +5481,8 @@ s32 func_8083C6B8(GlobalContext* globalCtx, Player* this) {
sp24 = this->actor.world.pos;
sp24.y += 50.0f;
if (!(this->actor.bgCheckFlags & 1) || (this->actor.world.pos.z > 1300.0f) ||
BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sp24, 20.0f)) {
if (CVar_GetS32("gHoverFishing", 0) ? 0 : !(this->actor.bgCheckFlags & 1) ||
(this->actor.world.pos.z > 1300.0f) || BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sp24, 20.0f)) {
func_80078884(NA_SE_SY_ERROR);
return 0;
}
@@ -6155,7 +6168,12 @@ s32 func_8083E5A8(Player* this, GlobalContext* globalCtx) {
iREG(67) = false;
if ((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) || (globalCtx->sceneNum == SCENE_BOWLING)) {
s32 drop = giEntry->objectId;
if ((globalCtx->sceneNum == SCENE_BOWLING) || !(CVar_GetS32("gFastDrops", 0) &&
((drop == OBJECT_GI_BOMB_1) || (drop == OBJECT_GI_NUTS) || (drop == OBJECT_GI_STICK) ||
(drop == OBJECT_GI_SEED) || (drop == OBJECT_GI_MAGICPOT) || (drop == OBJECT_GI_ARROW))) &&
(Item_CheckObtainability(giEntry->itemId) == ITEM_NONE)) {
func_808323B4(globalCtx, this);
func_8083AE40(this, giEntry->objectId);
@@ -6179,6 +6197,9 @@ s32 func_8083E5A8(Player* this, GlobalContext* globalCtx) {
if (this->getItemId != GI_NONE) {
GetItemEntry* giEntry = &sGetItemTable[-this->getItemId - 1];
EnBox* chest = (EnBox*)interactedActor;
if(CVar_GetS32("gFastChests", 0) != 0) {
giEntry->gi = -1 * abs(giEntry->gi);
}
if (giEntry->itemId != ITEM_NONE) {
if (((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) && (giEntry->field & 0x40)) ||
@@ -8274,7 +8295,7 @@ s32 func_80843E64(GlobalContext* globalCtx, Player* this) {
impactInfo = &D_80854600[impactIndex];
if (Player_InflictDamage(globalCtx, impactInfo->damage)) {
if (Player_InflictDamageModified(globalCtx, impactInfo->damage * CVar_GetS32("gFallDamageMul", 1), false)) {
return -1;
}
@@ -11621,7 +11642,7 @@ void func_8084BF1C(Player* this, GlobalContext* globalCtx) {
phi_f2 = -1.0f;
}
this->skelAnime.playSpeed = phi_f2 * phi_f0;
this->skelAnime.playSpeed = phi_f2 * phi_f0 + phi_f2 * CVar_GetS32("gClimbSpeed", 0);
if (this->unk_850 >= 0) {
if ((this->actor.wallPoly != NULL) && (this->actor.wallBgId != BGCHECK_SCENE)) {
@@ -14824,9 +14845,13 @@ void func_80853080(Player* this, GlobalContext* globalCtx) {
}
s32 Player_InflictDamage(GlobalContext* globalCtx, s32 damage) {
return Player_InflictDamageModified(globalCtx, damage, true);
}
s32 Player_InflictDamageModified(GlobalContext* globalCtx, s32 damage, u8 modified) {
Player* this = GET_PLAYER(globalCtx);
if (!Player_InBlockingCsMode(globalCtx, this) && !func_80837B18(globalCtx, this, damage)) {
if (!Player_InBlockingCsMode(globalCtx, this) && !func_80837B18_modified(globalCtx, this, damage, modified)) {
this->stateFlags2 &= ~PLAYER_STATE2_7;
return 1;
}
@@ -5,11 +5,14 @@
*/
#include "z_eff_ss_solder_srch_ball.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#include <math.h>
#define rUnused regs[1]
u32 EffectSsSolderSrchBall_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx);
void EffectSsSolderSrchBall_Update(GlobalContext* globalCtx, u32 index, EffectSs* this);
void EffectSsSolderSrchBall_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this);
EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars = {
EFFECT_SS_SOLDER_SRCH_BALL,
@@ -23,6 +26,7 @@ u32 EffectSsSolderSrchBall_Init(GlobalContext* globalCtx, u32 index, EffectSs* t
this->velocity = initParams->velocity;
this->accel = initParams->accel;
this->update = EffectSsSolderSrchBall_Update;
this->draw = EffectSsSolderSrchBall_Draw;
this->life = 100;
this->rUnused = initParams->unused;
this->actor = initParams->linkDetected; // actor field was incorrectly used as a pointer to something else
@@ -53,3 +57,198 @@ void EffectSsSolderSrchBall_Update(GlobalContext* globalCtx, u32 index, EffectSs
}
}
}
static void vtxn_f2l(Vtx* r, Vec3f* v) {
r->n.ob[0] = floorf(0.5f + v->x * 128.f);
r->n.ob[1] = floorf(0.5f + v->y * 128.f);
r->n.ob[2] = floorf(0.5f + v->z * 128.f);
r->n.flag = 0;
r->n.tc[0] = 0;
r->n.tc[1] = 0;
r->n.n[0] = v->x * 127.f;
r->n.n[1] = v->y * 127.f;
r->n.n[2] = v->z * 127.f;
r->n.a = 0xFF;
}
static void ico_sph_subdivide_edge(Vec3f* r, Vec3f* a, Vec3f* b) {
Math_Vec3f_Sum(a, b, r);
Math_Vec3f_Scale(r, (1.0f / Math3D_Vec3fMagnitude(r)));
}
static void draw_ico_sphere(Gfx** p_gfx_p, f32 x, f32 y, f32 z, f32 radius, GraphicsContext* gfxCtx) {
static Gfx* p_sph_gfx = NULL;
static Vtx sph_vtx[42];
static Gfx sph_gfx[45];
Gfx* sph_gfx_p;
s32 i;
if (!p_sph_gfx) {
Vec3f vtx[42];
s32 r0_n = 1, r0_m = r0_n / 5, r0_i = 0 + 0;
s32 r1_n = 5, r1_m = r1_n / 5, r1_i = r0_i + r0_n;
s32 r2_n = 10, r2_m = r2_n / 5, r2_i = r1_i + r1_n;
s32 r3_n = 10, r3_m = r3_n / 5, r3_i = r2_i + r2_n;
s32 r4_n = 10, r4_m = r4_n / 5, r4_i = r3_i + r3_n;
s32 r5_n = 5, r5_m = r5_n / 5, r5_i = r4_i + r4_n;
s32 r6_n = 1, r6_m = r6_n / 5, r6_i = r5_i + r5_n;
vtx[r0_i + (0 * r0_m + 0) % r0_n].x = 0.0f;
vtx[r0_i + (0 * r0_m + 0) % r0_n].y = 1.0f;
vtx[r0_i + (0 * r0_m + 0) % r0_n].z = 0.0f;
vtx[r6_i + (0 * r6_m + 0) % r6_n].x = 0.0f;
vtx[r6_i + (0 * r6_m + 0) % r6_n].y = -1.0f;
vtx[r6_i + (0 * r6_m + 0) % r6_n].z = 0.0f;
for (i = 0; i < 5; ++i) {
f32 a_xz = 2.f * M_PI / 10.f;
f32 a_y = atanf(1.0f / 2.0f);
vtx[r2_i + (i * r2_m + 0) % r2_n].x = cosf(a_xz * (i * r2_m + 0)) * cosf(a_y * 1.f);
vtx[r2_i + (i * r2_m + 0) % r2_n].y = sinf(a_y * 1.f);
vtx[r2_i + (i * r2_m + 0) % r2_n].z = -sinf(a_xz * (i * r2_m + 0)) * cosf(a_y * 1.f);
vtx[r4_i + (i * r4_m + 0) % r4_n].x = cosf(a_xz * (i * r4_m + 1)) * cosf(a_y * -1.f);
vtx[r4_i + (i * r4_m + 0) % r4_n].y = sinf(a_y * -1.f);
vtx[r4_i + (i * r4_m + 0) % r4_n].z = -sinf(a_xz * (i * r4_m + 1)) * cosf(a_y * -1.f);
}
for (i = 0; i < 5; ++i) {
ico_sph_subdivide_edge(&vtx[r1_i + (i * r1_m + 0) % r1_n], &vtx[r0_i + (i * r0_m + 0) % r0_n],
&vtx[r2_i + (i * r2_m + 0) % r2_n]);
ico_sph_subdivide_edge(&vtx[r2_i + (i * r2_m + 1) % r2_n], &vtx[r2_i + (i * r2_m + 0) % r2_n],
&vtx[r2_i + (i * r2_m + 2) % r2_n]);
ico_sph_subdivide_edge(&vtx[r3_i + (i * r3_m + 0) % r3_n], &vtx[r2_i + (i * r2_m + 0) % r2_n],
&vtx[r4_i + (i * r4_m + 0) % r4_n]);
ico_sph_subdivide_edge(&vtx[r3_i + (i * r3_m + 1) % r3_n], &vtx[r4_i + (i * r4_m + 0) % r4_n],
&vtx[r2_i + (i * r2_m + 2) % r2_n]);
ico_sph_subdivide_edge(&vtx[r4_i + (i * r4_m + 1) % r4_n], &vtx[r4_i + (i * r4_m + 0) % r4_n],
&vtx[r4_i + (i * r4_m + 2) % r4_n]);
ico_sph_subdivide_edge(&vtx[r5_i + (i * r5_m + 0) % r5_n], &vtx[r4_i + (i * r4_m + 0) % r4_n],
&vtx[r6_i + (i * r6_m + 0) % r6_n]);
}
for (i = 0; i < 42; ++i)
vtxn_f2l(&sph_vtx[i], &vtx[i]);
p_sph_gfx = sph_gfx;
sph_gfx_p = p_sph_gfx;
gSPSetGeometryMode(sph_gfx_p++, G_CULL_BACK | G_SHADING_SMOOTH);
gSPVertex(sph_gfx_p++, &sph_vtx[r0_i], r0_n + r1_n + r2_n + r3_n, r0_i - r0_i);
r3_i -= r0_i;
r2_i -= r0_i;
r1_i -= r0_i;
r0_i -= r0_i;
for (i = 0; i < 5; ++i) {
s32 v[24];
v[0] = r0_i + (i * r0_m + 0) % r0_n;
v[1] = r1_i + (i * r1_m + 0) % r1_n;
v[2] = r1_i + (i * r1_m + 1) % r1_n;
v[3] = r1_i + (i * r1_m + 0) % r1_n;
v[4] = r2_i + (i * r2_m + 0) % r2_n;
v[5] = r2_i + (i * r2_m + 1) % r2_n;
v[6] = r1_i + (i * r1_m + 0) % r1_n;
v[7] = r2_i + (i * r2_m + 1) % r2_n;
v[8] = r1_i + (i * r1_m + 1) % r1_n;
v[9] = r1_i + (i * r1_m + 1) % r1_n;
v[10] = r2_i + (i * r2_m + 1) % r2_n;
v[11] = r2_i + (i * r2_m + 2) % r2_n;
v[12] = r2_i + (i * r2_m + 0) % r2_n;
v[13] = r3_i + (i * r3_m + 0) % r3_n;
v[14] = r2_i + (i * r2_m + 1) % r2_n;
v[15] = r2_i + (i * r2_m + 1) % r2_n;
v[16] = r3_i + (i * r3_m + 0) % r3_n;
v[17] = r3_i + (i * r3_m + 1) % r3_n;
v[18] = r2_i + (i * r2_m + 1) % r2_n;
v[19] = r3_i + (i * r3_m + 1) % r3_n;
v[20] = r2_i + (i * r2_m + 2) % r2_n;
v[21] = r2_i + (i * r2_m + 2) % r2_n;
v[22] = r3_i + (i * r3_m + 1) % r3_n;
v[23] = r3_i + (i * r3_m + 2) % r3_n;
gSP2Triangles(sph_gfx_p++, v[0], v[1], v[2], 0, v[3], v[4], v[5], 0);
gSP2Triangles(sph_gfx_p++, v[6], v[7], v[8], 0, v[9], v[10], v[11], 0);
gSP2Triangles(sph_gfx_p++, v[12], v[13], v[14], 0, v[15], v[16], v[17], 0);
gSP2Triangles(sph_gfx_p++, v[18], v[19], v[20], 0, v[21], v[22], v[23], 0);
}
gSPVertex(sph_gfx_p++, &sph_vtx[r4_i], r4_n + r5_n + r6_n, r4_i - r4_i);
r6_i -= r4_i;
r5_i -= r4_i;
r4_i -= r4_i;
for (i = 0; i < 5; ++i) {
s32 v[24];
v[0] = r3_i + (i * r3_m + 1) % r3_n;
v[1] = r4_i + (i * r4_m + 0) % r4_n;
v[2] = r4_i + (i * r4_m + 1) % r4_n;
v[3] = r3_i + (i * r3_m + 1) % r3_n;
v[4] = r4_i + (i * r4_m + 1) % r4_n;
v[5] = r3_i + (i * r3_m + 2) % r3_n;
v[6] = r3_i + (i * r3_m + 2) % r3_n;
v[7] = r4_i + (i * r4_m + 1) % r4_n;
v[8] = r4_i + (i * r4_m + 2) % r4_n;
v[9] = r3_i + (i * r3_m + 2) % r3_n;
v[10] = r4_i + (i * r4_m + 2) % r4_n;
v[11] = r3_i + (i * r3_m + 3) % r3_n;
v[12] = r4_i + (i * r4_m + 0) % r4_n;
v[13] = r5_i + (i * r5_m + 0) % r5_n;
v[14] = r4_i + (i * r4_m + 1) % r4_n;
v[15] = r4_i + (i * r4_m + 1) % r4_n;
v[16] = r5_i + (i * r5_m + 0) % r5_n;
v[17] = r5_i + (i * r5_m + 1) % r5_n;
v[18] = r4_i + (i * r4_m + 1) % r4_n;
v[19] = r5_i + (i * r5_m + 1) % r5_n;
v[20] = r4_i + (i * r4_m + 2) % r4_n;
v[21] = r5_i + (i * r5_m + 0) % r5_n;
v[22] = r6_i + (i * r6_m + 0) % r6_n;
v[23] = r5_i + (i * r5_m + 1) % r5_n;
gSP2Triangles(sph_gfx_p++, v[0], v[1], v[2], 0, v[3], v[4], v[5], 0);
gSP2Triangles(sph_gfx_p++, v[6], v[7], v[8], 0, v[9], v[10], v[11], 0);
gSP2Triangles(sph_gfx_p++, v[12], v[13], v[14], 0, v[15], v[16], v[17], 0);
gSP2Triangles(sph_gfx_p++, v[18], v[19], v[20], 0, v[21], v[22], v[23], 0);
}
gSPClearGeometryMode(sph_gfx_p++, G_CULL_BACK | G_SHADING_SMOOTH);
gSPEndDisplayList(sph_gfx_p++);
}
Matrix_Push();
Matrix_Translate(x, y, z, MTXMODE_NEW);
Matrix_Scale(radius / 128.0f, radius / 128.0f, radius / 128.0f, MTXMODE_APPLY);
gSPMatrix((*p_gfx_p)++, Matrix_NewMtx(gfxCtx, __FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_PUSH);
gSPDisplayList((*p_gfx_p)++, p_sph_gfx);
gSPPopMatrix((*p_gfx_p)++, G_MTX_MODELVIEW);
Matrix_Pop();
}
void EffectSsSolderSrchBall_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) {
if (CVar_GetS32("gGuardVision", 0) == 0) {
return;
}
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
u32 rm;
u32 blc1;
u32 blc2;
s16* seenLink = this->actor;
OPEN_DISPS(globalCtx->state.gfxCtx, __FILE__, __LINE__);
rm = Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_XLU;
blc1 = GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA);
blc2 = GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA);
gSPLoadGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_LIGHTING);
gSPTexture(POLY_XLU_DISP++, 0, 0, 0, G_TX_RENDERTILE, G_OFF);
gDPPipeSync(POLY_XLU_DISP++);
gDPSetCycleType(POLY_XLU_DISP++, G_CYC_1CYCLE);
gDPSetRenderMode(POLY_XLU_DISP++, rm | blc1, rm | blc2);
gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, 0, SHADE, 0, 0, 0, 0, ENVIRONMENT, PRIMITIVE, 0, SHADE, 0, 0, 0,
0, ENVIRONMENT);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255);
if (*seenLink) {
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 0, 0, 255);
}
draw_ico_sphere(&POLY_XLU_DISP, this->pos.x, this->pos.y, this->pos.z, 30.0f, gfxCtx);
CLOSE_DISPS(globalCtx->state.gfxCtx, __FILE__, __LINE__);
}
@@ -5,17 +5,6 @@
#include "global.h"
#include "vt.h"
#define GET_NEWF(sramCtx, slotNum, index) (sramCtx->readBuff[gSramSlotOffsets[slotNum] + OFFSETOF(SaveContext, newf[index])])
#define SLOT_OCCUPIED(sramCtx, slotNum) \
((GET_NEWF(sramCtx, slotNum, 0) == 'Z') || \
(GET_NEWF(sramCtx, slotNum, 1) == 'E') || \
(GET_NEWF(sramCtx, slotNum, 2) == 'L') || \
(GET_NEWF(sramCtx, slotNum, 3) == 'D') || \
(GET_NEWF(sramCtx, slotNum, 4) == 'A') || \
(GET_NEWF(sramCtx, slotNum, 5) == 'Z'))
// Init mode: Initial setup as the file select is starting up, fades and slides in various menu elements
// Config mode: Handles the bulk of the file select, various configuration tasks like picking a file, copy/erase, and the options menu
// Select mode: Displays the selected file with various details about it, and allows the player to confirm and open it
@@ -64,9 +64,6 @@ void FileChoose_InitModeUpdate(GameState* thisx) {
this->menuMode = FS_MENU_MODE_CONFIG;
this->configMode = CM_FADE_IN_START;
this->nextTitleLabel = FS_TITLE_OPEN_FILE;
osSyncPrintf("Sram Start─Load 》》》》》 ");
Sram_VerifyAndLoadAllSaves(this, &this->sramCtx);
osSyncPrintf("終了!!!\n");
}
}
@@ -80,7 +77,6 @@ void FileChoose_InitModeDraw(GameState* thisx) {
*/
void FileChoose_FadeInMenuElements(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 i;
this->titleAlpha[0] += VREG(1);
@@ -89,7 +85,7 @@ void FileChoose_FadeInMenuElements(GameState* thisx) {
for (i = 0; i < 3; i++) {
this->fileButtonAlpha[i] = this->windowAlpha;
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->windowAlpha;
this->connectorAlpha[i] += VREG(1);
if (this->connectorAlpha[i] >= 255) {
@@ -176,18 +172,12 @@ void FileChoose_FinishFadeIn(GameState* thisx) {
void FileChoose_UpdateMainMenu(GameState* thisx) {
static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E };
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_A)) {
if (this->buttonIndex <= FS_BTN_MAIN_FILE_3) {
osSyncPrintf("REGCK_ALL[%x]=%x,%x,%x,%x,%x,%x\n", this->buttonIndex,
GET_NEWF(sramCtx, this->buttonIndex, 0), GET_NEWF(sramCtx, this->buttonIndex, 1),
GET_NEWF(sramCtx, this->buttonIndex, 2), GET_NEWF(sramCtx, this->buttonIndex, 3),
GET_NEWF(sramCtx, this->buttonIndex, 4), GET_NEWF(sramCtx, this->buttonIndex, 5));
if (!SLOT_OCCUPIED(sramCtx, this->buttonIndex)) {
if (!Save_GetSaveMetaInfo(this->buttonIndex)->valid) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->configMode = CM_ROTATE_TO_NAME_ENTRY;
this->kbdButton = FS_KBD_BTN_NONE;
@@ -199,16 +189,14 @@ void FileChoose_UpdateMainMenu(GameState* thisx) {
this->newFileNameCharCount = 0;
this->nameEntryBoxPosX = 120;
this->nameEntryBoxAlpha = 0;
memcpy(&this->fileNames[this->buttonIndex][0], &emptyName, 8);
} else if (this->n64ddFlags[this->buttonIndex] == this->n64ddFlag) {
memcpy(Save_GetSaveMetaInfo(this->buttonIndex)->playerName, &emptyName, 8);
} else {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->actionTimer = 8;
this->selectMode = SM_FADE_MAIN_TO_SELECT;
this->selectedFileIndex = this->buttonIndex;
this->menuMode = FS_MENU_MODE_SELECT;
this->nextTitleLabel = FS_TITLE_OPEN_FILE;
} else if (!this->n64ddFlags[this->buttonIndex]) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
} else {
if (this->warningLabel == FS_WARNING_NONE) {
@@ -254,11 +242,12 @@ void FileChoose_UpdateMainMenu(GameState* thisx) {
}
if (this->buttonIndex == FS_BTN_MAIN_COPY) {
if (!SLOT_OCCUPIED(sramCtx, 0) && !SLOT_OCCUPIED(sramCtx, 1) && !SLOT_OCCUPIED(sramCtx, 2)) {
if (!Save_GetSaveMetaInfo(0)->valid && !Save_GetSaveMetaInfo(1)->valid && !Save_GetSaveMetaInfo(2)->valid) {
this->warningButtonIndex = this->buttonIndex;
this->warningLabel = FS_WARNING_NO_FILE_COPY;
this->emptyFileTextAlpha = 255;
} else if (SLOT_OCCUPIED(sramCtx, 0) && SLOT_OCCUPIED(sramCtx, 1) && SLOT_OCCUPIED(sramCtx, 2)) {
} else if (Save_GetSaveMetaInfo(0)->valid && Save_GetSaveMetaInfo(1)->valid &&
Save_GetSaveMetaInfo(2)->valid) {
this->warningButtonIndex = this->buttonIndex;
this->warningLabel = FS_WARNING_NO_EMPTY_FILES;
this->emptyFileTextAlpha = 255;
@@ -266,7 +255,7 @@ void FileChoose_UpdateMainMenu(GameState* thisx) {
this->warningLabel = FS_WARNING_NONE;
}
} else if (this->buttonIndex == FS_BTN_MAIN_ERASE) {
if (!SLOT_OCCUPIED(sramCtx, 0) && !SLOT_OCCUPIED(sramCtx, 1) && !SLOT_OCCUPIED(sramCtx, 2)) {
if (!Save_GetSaveMetaInfo(0)->valid && !Save_GetSaveMetaInfo(1)->valid && !Save_GetSaveMetaInfo(2)->valid) {
this->warningButtonIndex = this->buttonIndex;
this->warningLabel = FS_WARNING_NO_FILE_ERASE;
this->emptyFileTextAlpha = 255;
@@ -379,48 +368,6 @@ void FileChoose_PulsateCursor(GameState* thisx) {
static s16 cursorAlphaTargets[] = { 70, 200 };
FileChooseContext* this = (FileChooseContext*)thisx;
s16 alphaStep;
SramContext* sramCtx = &this->sramCtx;
Input* debugInput = &this->state.input[2];
if (CHECK_BTN_ALL(debugInput->press.button, BTN_DLEFT)) {
sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_ENG;
*((u8*)0x80000002) = LANGUAGE_ENG;
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, 3, OS_WRITE);
osSyncPrintf("1:read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND],
sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE],
sramCtx->readBuff[SRAM_HEADER_MAGIC]);
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ);
osSyncPrintf("read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND],
sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE],
sramCtx->readBuff[SRAM_HEADER_MAGIC]);
} else if (CHECK_BTN_ALL(debugInput->press.button, BTN_DUP)) {
sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_GER;
*((u8*)0x80000002) = LANGUAGE_GER;
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, 3, OS_WRITE);
osSyncPrintf("1:read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND],
sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE],
sramCtx->readBuff[SRAM_HEADER_MAGIC]);
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ);
osSyncPrintf("read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND],
sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE],
sramCtx->readBuff[SRAM_HEADER_MAGIC]);
} else if (CHECK_BTN_ALL(debugInput->press.button, BTN_DRIGHT)) {
sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_FRA;
*((u8*)0x80000002) = LANGUAGE_FRA;
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, 3, OS_WRITE);
osSyncPrintf("1:read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND],
sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE],
sramCtx->readBuff[SRAM_HEADER_MAGIC]);
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ);
osSyncPrintf("read_buff[]=%x, %x, %x, %x\n", sramCtx->readBuff[SRAM_HEADER_SOUND],
sramCtx->readBuff[SRAM_HEADER_ZTARGET], sramCtx->readBuff[SRAM_HEADER_LANGUAGE],
sramCtx->readBuff[SRAM_HEADER_MAGIC]);
}
alphaStep = ABS(this->highlightColor[3] - cursorAlphaTargets[this->highlightPulseDir]) / XREG(35);
@@ -510,7 +457,6 @@ void FileChoose_SetWindowContentVtx(GameState* thisx) {
s16 phi_a1;
s16 phi_ra;
s16 temp_t1;
SramContext* sramCtx = &this->sramCtx;
this->windowContentVtx = Graph_Alloc(this->state.gfxCtx, 0x288 * sizeof(Vtx));
@@ -648,7 +594,7 @@ void FileChoose_SetWindowContentVtx(GameState* thisx) {
phi_ra = 0x2C;
for (phi_t5 = 0; phi_t5 < 3; phi_t5++, phi_ra -= WREG(38)) {
if (SLOT_OCCUPIED(sramCtx, phi_t5)) {
if (Save_GetSaveMetaInfo(phi_t5)->valid) {
phi_t0 = this->windowPosX - WREG(39);
if ((this->configMode == 0xF) && (phi_t5 == this->copyDestFileIndex)) {
@@ -822,8 +768,9 @@ void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) {
sNamePrimColors[isActive][2], this->nameAlpha[fileIndex]);
for (i = 0, vtxOffset = 0; vtxOffset < 0x20; i++, vtxOffset += 4) {
FileChoose_DrawCharacter(this->state.gfxCtx,
sp54->fontBuf + this->fileNames[fileIndex][i] * FONT_CHAR_TEX_SIZE, vtxOffset);
FileChoose_DrawCharacter(
this->state.gfxCtx, sp54->fontBuf + Save_GetSaveMetaInfo(fileIndex)->playerName[i] * FONT_CHAR_TEX_SIZE,
vtxOffset);
}
}
@@ -834,7 +781,8 @@ void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) {
gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 255, 255, 255, this->fileInfoAlpha[fileIndex]);
gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[D_8081284C[fileIndex]] + 0x24, 12, 0);
FileChoose_SplitNumber(this->deaths[fileIndex], &deathCountSplit[0], &deathCountSplit[1], &deathCountSplit[2]);
FileChoose_SplitNumber(Save_GetSaveMetaInfo(fileIndex)->deaths, &deathCountSplit[0], &deathCountSplit[1],
&deathCountSplit[2]);
// draw death count
for (i = 0, vtxOffset = 0; i < 3; i++, vtxOffset += 4) {
@@ -844,7 +792,7 @@ void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) {
gDPPipeSync(POLY_OPA_DISP++);
heartType = (this->defense[fileIndex] == 0) ? 0 : 1;
heartType = (Save_GetSaveMetaInfo(fileIndex)->defense == 0) ? 0 : 1;
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0,
@@ -854,7 +802,7 @@ void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) {
gDPSetEnvColor(POLY_OPA_DISP++, sHeartEnvColors[heartType][0], sHeartEnvColors[heartType][1],
sHeartEnvColors[heartType][2], 255);
i = this->healthCapacities[fileIndex] / 0x10;
i = Save_GetSaveMetaInfo(fileIndex)->healthCapacity / 0x10;
// draw hearts
for (vtxOffset = 0, j = 0; j < i; j++, vtxOffset += 4) {
@@ -867,7 +815,7 @@ void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) {
// draw quest items
for (vtxOffset = 0, j = 0; j < 9; j++, vtxOffset += 4) {
if (this->questItems[fileIndex] & gBitFlags[sQuestItemFlags[j]]) {
if (Save_GetSaveMetaInfo(fileIndex)->questItems & gBitFlags[sQuestItemFlags[j]]) {
gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[D_8081284C[fileIndex] + vtxOffset] + 0x80, 4, 0);
gDPPipeSync(POLY_OPA_DISP++);
gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, sQuestItemRed[j], sQuestItemGreen[j], sQuestItemBlue[j],
@@ -976,8 +924,14 @@ void FileChoose_DrawWindowContents(GameState* thisx) {
// draw file info box (large box when a file is selected)
for (fileIndex = 0; fileIndex < 3; fileIndex++, temp += 20) {
gDPPipeSync(POLY_OPA_DISP++);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->fileInfoAlpha[fileIndex]);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->fileInfoAlpha[fileIndex]);
}
gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[temp], 20, 0);
for (quadVtxIndex = 0, i = 0; i < 5; i++, quadVtxIndex += 4) {
@@ -992,27 +946,46 @@ void FileChoose_DrawWindowContents(GameState* thisx) {
// draw file button
gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[temp], 20, 0);
isActive = ((this->n64ddFlag == this->n64ddFlags[i]) || (this->nameBoxAlpha[i] == 0)) ? 0 : 1;
isActive = ((this->n64ddFlag == Save_GetSaveMetaInfo(i)->n64ddFlag) || (this->nameBoxAlpha[i] == 0)) ? 0 : 1;
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->fileButtonAlpha[i]);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1],
sWindowContentColors[isActive][2], this->fileButtonAlpha[i]);
}
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1],
sWindowContentColors[isActive][2], this->fileButtonAlpha[i]);
gDPLoadTextureBlock(POLY_OPA_DISP++, sFileButtonTextures[gSaveContext.language][i], G_IM_FMT_IA, G_IM_SIZ_16b,
64, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD);
gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0);
// draw file name box
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1],
sWindowContentColors[isActive][2], this->nameBoxAlpha[i]);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->nameBoxAlpha[i]);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1],
sWindowContentColors[isActive][2], this->nameBoxAlpha[i]);
}
gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelNameBoxTex, G_IM_FMT_IA, G_IM_SIZ_16b, 108, 16, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOLOD);
gSP1Quadrangle(POLY_OPA_DISP++, 4, 6, 7, 5, 0);
// draw disk label for 64DD
if (this->n64ddFlags[i]) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1],
sWindowContentColors[isActive][2], this->nameAlpha[i]);
if (Save_GetSaveMetaInfo(i)->n64ddFlag) {
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 0),
CVar_GetS32("gCCFileChoosePrimG", 200), CVar_GetS32("gCCFileChoosePrimB", 255),
this->nameAlpha[i]);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0],
sWindowContentColors[isActive][1], sWindowContentColors[isActive][2],
this->nameAlpha[i]);
}
gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelDISKButtonTex, G_IM_FMT_IA, G_IM_SIZ_16b, 44, 16, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD);
@@ -1020,21 +993,27 @@ void FileChoose_DrawWindowContents(GameState* thisx) {
}
// draw connectors
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1],
sWindowContentColors[isActive][2], this->connectorAlpha[i]);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100),
CVar_GetS32("gCCFileChoosePrimG", 150), CVar_GetS32("gCCFileChoosePrimB", 255),
this->connectorAlpha[i]);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWindowContentColors[isActive][0], sWindowContentColors[isActive][1],
sWindowContentColors[isActive][2], this->connectorAlpha[i]);
}
gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelConnectorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 24, 16, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOLOD);
gSP1Quadrangle(POLY_OPA_DISP++, 12, 14, 15, 13, 0);
if (this->n64ddFlags[i]) {
if (Save_GetSaveMetaInfo(i)->n64ddFlag) {
gSP1Quadrangle(POLY_OPA_DISP++, 16, 18, 19, 17, 0);
}
}
// draw file info
for (fileIndex = 0; fileIndex < 3; fileIndex++) {
isActive = ((this->n64ddFlag == this->n64ddFlags[fileIndex]) || (this->nameBoxAlpha[fileIndex] == 0)) ? 0 : 1;
isActive = ((this->n64ddFlag == Save_GetSaveMetaInfo(fileIndex)->n64ddFlag) || (this->nameBoxAlpha[fileIndex] == 0)) ? 0 : 1;
FileChoose_DrawFileInfo(&this->state, fileIndex, isActive);
}
@@ -1047,8 +1026,14 @@ void FileChoose_DrawWindowContents(GameState* thisx) {
// draw primary action buttons (copy/erase)
for (quadVtxIndex = 0, i = 0; i < 2; i++, quadVtxIndex += 4) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->actionButtonAlpha[i]);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->actionButtonAlpha[i]);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->actionButtonAlpha[i]);
}
gDPLoadTextureBlock(POLY_OPA_DISP++, sActionButtonTextures[gSaveContext.language][i], G_IM_FMT_IA, G_IM_SIZ_16b,
64, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD);
@@ -1061,8 +1046,13 @@ void FileChoose_DrawWindowContents(GameState* thisx) {
for (quadVtxIndex = 0, i = 0; i < 2; i++, quadVtxIndex += 4) {
temp = this->confirmButtonTexIndices[i];
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->confirmButtonAlpha[i]);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->confirmButtonAlpha[i]);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->confirmButtonAlpha[i]);
}
gDPLoadTextureBlock(POLY_OPA_DISP++, sActionButtonTextures[gSaveContext.language][temp], G_IM_FMT_IA,
G_IM_SIZ_16b, 64, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK,
G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
@@ -1071,8 +1061,14 @@ void FileChoose_DrawWindowContents(GameState* thisx) {
// draw options button
gDPPipeSync(POLY_OPA_DISP++);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->optionButtonAlpha);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->optionButtonAlpha);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->optionButtonAlpha);
}
gDPLoadTextureBlock(POLY_OPA_DISP++, sOptionsButtonTextures[gSaveContext.language], G_IM_FMT_IA, G_IM_SIZ_16b, 64,
16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD);
@@ -1087,8 +1083,15 @@ void FileChoose_DrawWindowContents(GameState* thisx) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0,
PRIMITIVE, 0);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->highlightColor[0], this->highlightColor[1],
this->highlightColor[2], this->highlightColor[3]);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 155),
CVar_GetS32("gCCFileChoosePrimG", 255), CVar_GetS32("gCCFileChoosePrimB", 255),
this->highlightColor[3]);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->highlightColor[0], this->highlightColor[1],
this->highlightColor[2], this->highlightColor[3]);
}
gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelBigButtonHighlightTex, G_IM_FMT_I, G_IM_SIZ_8b, 72, 24, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOLOD);
@@ -1143,8 +1146,14 @@ void FileChoose_ConfigModeDraw(GameState* thisx) {
if ((this->configMode != CM_NAME_ENTRY) && (this->configMode != CM_START_NAME_ENTRY)) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->windowAlpha);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->windowAlpha);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->windowAlpha);
}
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0);
Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW);
@@ -1175,8 +1184,14 @@ void FileChoose_ConfigModeDraw(GameState* thisx) {
if ((this->configMode >= CM_ROTATE_TO_NAME_ENTRY) && (this->configMode <= CM_NAME_ENTRY_TO_MAIN)) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->windowAlpha);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->windowAlpha);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->windowAlpha);
}
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0);
Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW);
@@ -1203,8 +1218,14 @@ void FileChoose_ConfigModeDraw(GameState* thisx) {
if ((this->configMode >= CM_MAIN_TO_OPTIONS) && (this->configMode <= CM_OPTIONS_TO_MAIN)) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->windowAlpha);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->windowAlpha);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->windowAlpha);
}
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0);
Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW);
@@ -1242,7 +1263,6 @@ void FileChoose_ConfigModeDraw(GameState* thisx) {
*/
void FileChoose_FadeMainToSelect(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 i;
for (i = 0; i < 3; i++) {
@@ -1251,7 +1271,7 @@ void FileChoose_FadeMainToSelect(GameState* thisx) {
this->actionButtonAlpha[FS_BTN_ACTION_COPY] = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] =
this->optionButtonAlpha = this->fileButtonAlpha[i];
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->nameAlpha[i] = this->nameBoxAlpha[i] = this->fileButtonAlpha[i];
this->connectorAlpha[i] -= 31;
}
@@ -1372,7 +1392,6 @@ void FileChoose_FadeOutFileInfo(GameState* thisx) {
*/
void FileChoose_MoveSelectedFileToSlot(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 yStep;
s16 i;
@@ -1394,7 +1413,7 @@ void FileChoose_MoveSelectedFileToSlot(GameState* thisx) {
this->actionButtonAlpha[FS_BTN_ACTION_COPY] = this->actionButtonAlpha[FS_BTN_ACTION_ERASE] =
this->optionButtonAlpha = this->fileButtonAlpha[i];
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i];
this->connectorAlpha[i] += 31;
}
@@ -1445,14 +1464,14 @@ void FileChoose_LoadGame(GameState* thisx) {
if (this->buttonIndex == FS_BTN_SELECT_FILE_1 && CVar_GetS32("gDebugEnabled", 0)) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
gSaveContext.fileNum = this->buttonIndex;
Sram_OpenSave(&this->sramCtx);
Sram_OpenSave();
gSaveContext.gameMode = 0;
SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext);
this->state.running = false;
} else {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
gSaveContext.fileNum = this->buttonIndex;
Sram_OpenSave(&this->sramCtx);
Sram_OpenSave();
gSaveContext.gameMode = 0;
SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext);
this->state.running = false;
@@ -1555,8 +1574,14 @@ void FileChoose_SelectModeDraw(GameState* thisx) {
FileChoose_SetWindowContentVtx(&this->state);
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->windowAlpha);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), this->windowAlpha);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->windowAlpha);
}
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0);
Matrix_Translate(0.0f, 0.0f, -93.6f, MTXMODE_NEW);
@@ -1601,6 +1626,10 @@ void FileChoose_Main(GameState* thisx) {
};
FileChooseContext* this = (FileChooseContext*)thisx;
Input* input = &this->state.input[0];
if (CVar_GetS32("gTimeFlowFileSelect", 0) != 0) {
gSaveContext.skyboxTime += 0x10;
}
OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2898);
@@ -1615,6 +1644,52 @@ void FileChoose_Main(GameState* thisx) {
this->stickRelX = input->rel.stick_x;
this->stickRelY = input->rel.stick_y;
if (CVar_GetS32("gDpadHoldChange", 1) && CVar_GetS32("gDpadPauseName", 0)) {
if (CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) {
if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) {
this->inputTimerX = 10;
this->stickXDir = -1;
} else if (--(this->inputTimerX) < 0) {
this->inputTimerX = XREG(6);
input->press.button |= BTN_DLEFT;
}
} else if (CHECK_BTN_ALL(input->rel.button, BTN_DLEFT)) {
this->stickXDir = 0;
} else if (CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT)) {
if (CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) {
this->inputTimerX = 10;
this->stickXDir = 1;
} else if (--(this->inputTimerX) < 0) {
this->inputTimerX = XREG(6);
input->press.button |= BTN_DRIGHT;
}
} else if (CHECK_BTN_ALL(input->rel.button, BTN_DRIGHT)) {
this->stickXDir = 0;
}
if (CHECK_BTN_ALL(input->cur.button, BTN_DDOWN)) {
if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) {
this->inputTimerY = 10;
this->stickYDir = -1;
} else if (--(this->inputTimerY) < 0) {
this->inputTimerY = XREG(6);
input->press.button |= BTN_DDOWN;
}
} else if (CHECK_BTN_ALL(input->rel.button, BTN_DDOWN)) {
this->stickYDir = 0;
} else if (CHECK_BTN_ALL(input->cur.button, BTN_DUP)) {
if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) {
this->inputTimerY = 10;
this->stickYDir = -1;
} else if (--(this->inputTimerY) < 0) {
this->inputTimerY = XREG(6);
input->press.button |= BTN_DUP;
}
} else if (CHECK_BTN_ALL(input->rel.button, BTN_DUP)) {
this->stickYDir = 0;
}
}
if (this->stickRelX < -30) {
if (this->stickXDir == -1) {
this->inputTimerX--;
@@ -1645,7 +1720,7 @@ void FileChoose_Main(GameState* thisx) {
if (this->stickRelY < -30) {
if (this->stickYDir == -1) {
this->inputTimerY -= 1;
this->inputTimerY--;
if (this->inputTimerY < 0) {
this->inputTimerY = 2;
} else {
@@ -1657,7 +1732,7 @@ void FileChoose_Main(GameState* thisx) {
}
} else if (this->stickRelY > 30) {
if (this->stickYDir == 1) {
this->inputTimerY -= 1;
this->inputTimerY--;
if (this->inputTimerY < 0) {
this->inputTimerY = 2;
} else {
@@ -1685,7 +1760,14 @@ void FileChoose_Main(GameState* thisx) {
gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0,
PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 255, 255, this->controlsAlpha);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChooseTextPrimR", 0),
CVar_GetS32("gCCFileChooseTextPrimG", 100), CVar_GetS32("gCCFileChooseTextPrimB", 255),
this->controlsAlpha);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 255, 255, this->controlsAlpha);
}
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0);
gDPLoadTextureBlock(POLY_OPA_DISP++, controlsTextures[gSaveContext.language], G_IM_FMT_IA, G_IM_SIZ_8b, 144, 16,
0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
@@ -1704,9 +1786,6 @@ void FileChoose_Main(GameState* thisx) {
void FileChoose_InitContext(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
EnvironmentContext* envCtx = &this->envCtx;
SramContext* sramCtx = &this->sramCtx;
Sram_Alloc(&this->state, sramCtx);
ZREG(7) = 32;
ZREG(8) = 22;
@@ -1859,17 +1938,6 @@ void FileChoose_InitContext(GameState* thisx) {
gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] =
gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED;
this->n64ddFlags[0] = this->n64ddFlags[1] = this->n64ddFlags[2] = this->defense[0] = this->defense[1] =
this->defense[2] = 0;
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_READ);
gSaveContext.language = sramCtx->readBuff[SRAM_HEADER_LANGUAGE];
if (gSaveContext.language >= LANGUAGE_MAX) {
sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language = LANGUAGE_ENG;
}
}
void FileChoose_Destroy(GameState* thisx) {
@@ -60,7 +60,6 @@ void FileChoose_SetupCopySource(GameState* thisx) {
*/
void FileChoose_SelectCopySource(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
@@ -73,7 +72,7 @@ void FileChoose_SelectCopySource(GameState* thisx) {
this->warningLabel = FS_WARNING_NONE;
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) {
if (SLOT_OCCUPIED(sramCtx, this->buttonIndex)) {
if (Save_GetSaveMetaInfo(this->buttonIndex)->valid) {
this->actionTimer = 8;
this->selectedFileIndex = this->buttonIndex;
this->configMode = CM_SETUP_COPY_DEST_1;
@@ -102,7 +101,7 @@ void FileChoose_SelectCopySource(GameState* thisx) {
}
if (this->buttonIndex != FS_BTN_COPY_QUIT) {
if (!SLOT_OCCUPIED(sramCtx, this->buttonIndex)) {
if (!Save_GetSaveMetaInfo(this->buttonIndex)->valid) {
this->warningLabel = FS_WARNING_FILE_EMPTY;
this->warningButtonIndex = this->buttonIndex;
this->emptyFileTextAlpha = 255;
@@ -173,7 +172,6 @@ void FileChoose_SetupCopyDest2(GameState* thisx) {
*/
void FileChoose_SelectCopyDest(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
@@ -185,7 +183,7 @@ void FileChoose_SelectCopyDest(GameState* thisx) {
this->configMode = CM_EXIT_TO_COPY_SOURCE_1;
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) {
if (!SLOT_OCCUPIED(sramCtx, this->buttonIndex)) {
if (!Save_GetSaveMetaInfo(this->buttonIndex)->valid) {
this->copyDestFileIndex = this->buttonIndex;
this->nextTitleLabel = FS_TITLE_COPY_CONFIRM;
this->actionTimer = 8;
@@ -227,7 +225,7 @@ void FileChoose_SelectCopyDest(GameState* thisx) {
}
if (this->buttonIndex != FS_BTN_COPY_QUIT) {
if (SLOT_OCCUPIED(sramCtx, this->buttonIndex)) {
if (Save_GetSaveMetaInfo(this->buttonIndex)->valid) {
this->warningLabel = FS_WARNING_FILE_IN_USE;
this->warningButtonIndex = this->buttonIndex;
this->emptyFileTextAlpha = 255;
@@ -264,7 +262,6 @@ void FileChoose_ExitToCopySource1(GameState* thisx) {
*/
void FileChoose_ExitToCopySource2(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 i;
s16 yStep;
@@ -298,7 +295,6 @@ void FileChoose_ExitToCopySource2(GameState* thisx) {
void FileChoose_SetupCopyConfirm1(GameState* thisx) {
static s16 D_808124A4[] = { -56, -40, -24, 0 };
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 i;
s16 yStep;
@@ -309,7 +305,7 @@ void FileChoose_SetupCopyConfirm1(GameState* thisx) {
if ((i != this->copyDestFileIndex) && (i != this->selectedFileIndex)) {
this->fileButtonAlpha[i] -= 25;
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->connectorAlpha[i] -= 31;
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i];
}
@@ -359,7 +355,6 @@ void FileChoose_SetupCopyConfirm2(GameState* thisx) {
*/
void FileChoose_CopyConfirm(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0];
u16 dayTime;
bool dpad = CVar_GetS32("gDpadPauseName", 0);
@@ -372,7 +367,7 @@ void FileChoose_CopyConfirm(GameState* thisx) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) {
dayTime = gSaveContext.dayTime;
Sram_CopySave(this, sramCtx);
Save_CopyFile(this->selectedFileIndex, this->copyDestFileIndex);
gSaveContext.dayTime = dayTime;
this->fileInfoAlpha[this->copyDestFileIndex] = this->nameAlpha[this->copyDestFileIndex] = 0;
this->nextTitleLabel = FS_TITLE_COPY_COMPLETE;
@@ -392,7 +387,6 @@ void FileChoose_CopyConfirm(GameState* thisx) {
*/
void FileChoose_ReturnToCopyDest(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 i;
s16 yStep;
@@ -404,7 +398,7 @@ void FileChoose_ReturnToCopyDest(GameState* thisx) {
if ((i != this->copyDestFileIndex) && (i != this->selectedFileIndex)) {
this->fileButtonAlpha[i] += 25;
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i];
this->connectorAlpha[i] += 31;
}
@@ -535,7 +529,6 @@ void FileChoose_CopyAnim4(GameState* thisx) {
*/
void FileChoose_CopyAnim5(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 i;
s16 yStep;
@@ -553,7 +546,7 @@ void FileChoose_CopyAnim5(GameState* thisx) {
if (i != this->buttonIndex) {
this->fileButtonAlpha[i] += 25;
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i];
this->connectorAlpha[i] += 31;
}
@@ -572,7 +565,7 @@ void FileChoose_CopyAnim5(GameState* thisx) {
this->fileButtonAlpha[i] = 200;
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->connectorAlpha[i];
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->connectorAlpha[i] = 255;
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i];
}
@@ -681,7 +674,6 @@ void FileChoose_SetupEraseSelect(GameState* thisx) {
*/
void FileChoose_EraseSelect(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
@@ -694,7 +686,7 @@ void FileChoose_EraseSelect(GameState* thisx) {
this->warningLabel = FS_WARNING_NONE;
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) {
if (SLOT_OCCUPIED(sramCtx, this->buttonIndex)) {
if (Save_GetSaveMetaInfo(this->buttonIndex)->valid) {
this->actionTimer = 8;
this->selectedFileIndex = this->buttonIndex;
this->configMode = CM_SETUP_ERASE_CONFIRM_1;
@@ -721,7 +713,7 @@ void FileChoose_EraseSelect(GameState* thisx) {
}
if (this->buttonIndex != FS_BTN_ERASE_QUIT) {
if (!SLOT_OCCUPIED(sramCtx, this->buttonIndex)) {
if (!Save_GetSaveMetaInfo(this->buttonIndex)->valid) {
this->warningLabel = FS_WARNING_FILE_EMPTY;
this->warningButtonIndex = this->buttonIndex;
this->emptyFileTextAlpha = 255;
@@ -741,7 +733,6 @@ void FileChoose_EraseSelect(GameState* thisx) {
void FileChoose_SetupEraseConfirm1(GameState* thisx) {
static s16 D_808124AC[] = { 0, 16, 32 };
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 i;
s16 yStep;
@@ -749,7 +740,7 @@ void FileChoose_SetupEraseConfirm1(GameState* thisx) {
if (i != this->buttonIndex) {
this->fileButtonAlpha[i] -= 25;
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->connectorAlpha[i] -= 31;
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i];
}
@@ -775,7 +766,7 @@ void FileChoose_SetupEraseConfirm1(GameState* thisx) {
if (i != this->buttonIndex) {
this->fileButtonAlpha[i] = 0;
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->connectorAlpha[i] = 0;
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i] = 0;
}
@@ -831,7 +822,7 @@ void FileChoose_EraseConfirm(GameState* thisx) {
this->actionTimer = 8;
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else if (CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) {
this->n64ddFlags[this->selectedFileIndex] = this->connectorAlpha[this->selectedFileIndex] = 0;
Save_GetSaveMetaInfo(this->selectedFileIndex)->n64ddFlag = this->connectorAlpha[this->selectedFileIndex] = 0;
Audio_PlaySoundGeneral(NA_SE_EV_DIAMOND_SWITCH, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->actionTimer = 8;
this->configMode = CM_ERASE_ANIM_1;
@@ -869,7 +860,6 @@ void FileChoose_ExitToEraseSelect1(GameState* thisx) {
*/
void FileChoose_ExitToEraseSelect2(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 i;
s16 yStep;
@@ -885,7 +875,7 @@ void FileChoose_ExitToEraseSelect2(GameState* thisx) {
if (i != this->buttonIndex) {
this->fileButtonAlpha[i] += 25;
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i];
this->connectorAlpha[i] += 31;
}
@@ -915,7 +905,6 @@ void FileChoose_ExitToEraseSelect2(GameState* thisx) {
void FileChoose_EraseAnim1(GameState* thisx) {
static s16 D_80813800;
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
if (sEraseDelayTimer == 0) {
if (this->actionTimer == 8) {
@@ -935,7 +924,7 @@ void FileChoose_EraseAnim1(GameState* thisx) {
D_80813800 += 2;
if (this->actionTimer == 0) {
Sram_EraseSave(this, sramCtx);
Save_DeleteFile(this->selectedFileIndex);
this->titleLabel = this->nextTitleLabel;
this->titleAlpha[0] = 255;
this->titleAlpha[1] = this->connectorAlpha[this->selectedFileIndex] = 0;
@@ -981,7 +970,6 @@ void FileChoose_EraseAnim2(GameState* thisx) {
*/
void FileChoose_EraseAnim3(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
s16 i;
s16 yStep;
@@ -998,7 +986,7 @@ void FileChoose_EraseAnim3(GameState* thisx) {
for (i = 0; i < 3; i++) {
this->fileButtonAlpha[i] += 25;
if (SLOT_OCCUPIED(sramCtx, i)) {
if (Save_GetSaveMetaInfo(i)->valid) {
this->nameBoxAlpha[i] = this->nameAlpha[i] = this->fileButtonAlpha[i];
this->connectorAlpha[i] += 31;
}
@@ -113,6 +113,7 @@ void FileChoose_SetNameEntryVtx(GameState* thisx) {
s16 phi_t1;
u8 temp;
s16 phi_v0;
char* filename = Save_GetSaveMetaInfo(this->buttonIndex)->playerName;
if (1) {}
if (1) {}
@@ -133,7 +134,14 @@ void FileChoose_SetNameEntryVtx(GameState* thisx) {
phi_s0 = 0x10;
for (phi_t1 = 0; phi_t1 < 2; phi_t1++, phi_s0 += 4) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2], 255);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100), CVar_GetS32("gCCFileChoosePrimG", 150),
CVar_GetS32("gCCFileChoosePrimB", 255), 255);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
255);
}
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0);
gDPLoadTextureBlock(POLY_OPA_DISP++, sBackspaceEndTextures[gSaveContext.language][phi_t1], G_IM_FMT_IA,
G_IM_SIZ_16b, sBackspaceEndWidths[phi_t1], 16, 0, G_TX_NOMIRROR | G_TX_WRAP,
@@ -145,7 +153,7 @@ void FileChoose_SetNameEntryVtx(GameState* thisx) {
for (phi_s0 = 0, phi_t1 = 0; phi_t1 < 44; phi_t1 += 4, phi_s0++) {
if ((phi_s0 > 0) && (phi_s0 < 9)) {
temp = this->fileNames[this->buttonIndex][phi_s0 - 1];
temp = filename[phi_s0 - 1];
this->nameEntryVtx[phi_t1].v.ob[0] = this->nameEntryVtx[phi_t1 + 2].v.ob[0] =
D_808125EC[phi_s0] + this->nameEntryBoxPosX + D_808124C0[temp];
@@ -195,8 +203,15 @@ void FileChoose_SetNameEntryVtx(GameState* thisx) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE,
ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->nameEntryBoxAlpha);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100),
CVar_GetS32("gCCFileChoosePrimG", 150), CVar_GetS32("gCCFileChoosePrimB", 255),
this->nameEntryBoxAlpha);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->windowColor[0], this->windowColor[1], this->windowColor[2],
this->nameEntryBoxAlpha);
}
gSPVertex(POLY_OPA_DISP++, this->nameEntryVtx, 4, 0);
gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelNameBoxTex, G_IM_FMT_IA, G_IM_SIZ_16b, 108, 16, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
@@ -209,8 +224,7 @@ void FileChoose_SetNameEntryVtx(GameState* thisx) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->nameEntryBoxAlpha);
for (phi_v0 = 0, phi_s0 = 0; phi_s0 < 0x20; phi_s0 += 4, phi_v0++) {
FileChoose_DrawCharacter(this->state.gfxCtx,
font->fontBuf + this->fileNames[this->buttonIndex][phi_v0] * FONT_CHAR_TEX_SIZE,
FileChoose_DrawCharacter(this->state.gfxCtx, font->fontBuf + filename[phi_v0] * FONT_CHAR_TEX_SIZE,
phi_s0);
}
@@ -267,6 +281,7 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
s16 tmp;
u16 dayTime;
s16 validName;
char* filename = Save_GetSaveMetaInfo(this->buttonIndex)->playerName;
OPEN_DISPS(this->state.gfxCtx, "../z_file_nameset_PAL.c", 368);
@@ -318,8 +333,15 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0,
PRIMITIVE, 0);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->highlightColor[0], this->highlightColor[1], this->highlightColor[2],
this->highlightColor[3]);
if (CVar_GetS32("gHudColors", 1) == 2) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, CVar_GetS32("gCCFileChoosePrimR", 100),
CVar_GetS32("gCCFileChoosePrimG", 150), CVar_GetS32("gCCFileChoosePrimB", 255),
this->highlightColor[3]);
} else {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->highlightColor[0], this->highlightColor[1],
this->highlightColor[2], this->highlightColor[3]);
}
gDPLoadTextureBlock(POLY_OPA_DISP++, gFileSelCharHighlightTex, G_IM_FMT_I, G_IM_SIZ_8b, 24, 24, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOLOD);
@@ -354,12 +376,12 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
this->kbdY = 5;
this->kbdX = 4;
} else if (CHECK_BTN_ALL(input->press.button, BTN_B)) {
if ((this->newFileNameCharCount == 7) && (this->fileNames[this->buttonIndex][7] != 0x3E)) {
if ((this->newFileNameCharCount == 7) && (filename[7] != 0x3E)) {
for (i = this->newFileNameCharCount; i < 7; i++) {
this->fileNames[this->buttonIndex][i] = this->fileNames[this->buttonIndex][i + 1];
filename[i] = filename[i + 1];
}
this->fileNames[this->buttonIndex][i] = 0x3E;
filename[i] = 0x3E;
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else {
this->newFileNameCharCount--;
@@ -369,10 +391,10 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
this->configMode = CM_NAME_ENTRY_TO_MAIN;
} else {
for (i = this->newFileNameCharCount; i < 7; i++) {
this->fileNames[this->buttonIndex][i] = this->fileNames[this->buttonIndex][i + 1];
filename[i] = filename[i + 1];
}
this->fileNames[this->buttonIndex][i] = 0x3E;
filename[i] = 0x3E;
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0,
&D_801333E8);
}
@@ -390,7 +412,7 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
if (CHECK_BTN_ALL(input->press.button, BTN_A)) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0,
&D_801333E8);
this->fileNames[this->buttonIndex][this->newFileNameCharCount] = D_808123F0[this->charIndex];
filename[this->newFileNameCharCount] = D_808123F0[this->charIndex];
this->newFileNameCharCount++;
if (this->newFileNameCharCount > 7) {
@@ -399,12 +421,12 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
}
} else if (CHECK_BTN_ALL(input->press.button, BTN_A) && (this->charPage != this->kbdButton)) {
if (this->kbdButton == FS_KBD_BTN_BACKSPACE) {
if ((this->newFileNameCharCount == 7) && (this->fileNames[this->buttonIndex][7] != 0x3E)) {
if ((this->newFileNameCharCount == 7) && (filename[7] != 0x3E)) {
for (i = this->newFileNameCharCount; i < 7; i++) {
this->fileNames[this->buttonIndex][i] = this->fileNames[this->buttonIndex][i + 1];
filename[i] = filename[i + 1];
}
this->fileNames[this->buttonIndex][i] = 0x3E;
filename[i] = 0x3E;
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0,
&D_801333E8);
} else {
@@ -415,10 +437,10 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
}
for (i = this->newFileNameCharCount; i < 7; i++) {
this->fileNames[this->buttonIndex][i] = this->fileNames[this->buttonIndex][i + 1];
filename[i] = filename[i + 1];
}
this->fileNames[this->buttonIndex][i] = 0x3E;
filename[i] = 0x3E;
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_S, &D_801333D4, 4, &D_801333E0, &D_801333E0,
&D_801333E8);
}
@@ -426,7 +448,7 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
validName = false;
for (i = 0; i < 8; i++) {
if (this->fileNames[this->buttonIndex][i] != 0x3E) {
if (filename[i] != 0x3E) {
validName = true;
break;
}
@@ -437,7 +459,7 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
&D_801333E8);
gSaveContext.fileNum = this->buttonIndex;
dayTime = ((void)0, gSaveContext.dayTime);
Sram_InitSave(this, &this->sramCtx);
Sram_InitSave(this);
gSaveContext.dayTime = dayTime;
this->configMode = CM_NAME_ENTRY_TO_MAIN;
this->nameBoxAlpha[this->buttonIndex] = this->nameAlpha[this->buttonIndex] = 200;
@@ -655,20 +677,15 @@ static u8 sSelectedSetting;
*/
void FileChoose_UpdateOptionsMenu(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (CHECK_BTN_ALL(input->press.button, BTN_B)) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->configMode = CM_OPTIONS_TO_MAIN;
sramCtx->readBuff[0] = gSaveContext.audioSetting;
sramCtx->readBuff[1] = gSaveContext.zTargetSetting;
osSyncPrintf("SAVE");
Sram_WriteSramHeader(sramCtx);
Save_SaveGlobal();
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("sram->read_buff[2] = J_N = %x\n", sramCtx->readBuff[2]);
osSyncPrintf("sram->read_buff[2] = J_N = %x\n", &sramCtx->readBuff[2]);
osSyncPrintf("Na_SetSoundOutputMode = %d\n", gSaveContext.audioSetting);
osSyncPrintf("Na_SetSoundOutputMode = %d\n", gSaveContext.audioSetting);
osSyncPrintf("Na_SetSoundOutputMode = %d\n", gSaveContext.audioSetting);
@@ -224,7 +224,7 @@ void Title_Main(GameState* thisx) {
if (CVar_GetS32("gSkipLogoTitle",0)!=0) {
gSaveContext.language = CVar_GetS32("gLanguages", 0);
Sram_InitSram(&this->state, &this->sramCtx);
Sram_InitSram(&this->state);
s16 selectedfile = CVar_GetS32("gSaveFileID", 0);
if (selectedfile == 4) {
selectedfile = 0xFF;
@@ -242,13 +242,13 @@ void Title_Main(GameState* thisx) {
}
if (selectedfile == 0xFF) {
gSaveContext.fileNum = selectedfile;
Sram_OpenSave(&this->sramCtx);
Sram_OpenSave();
gSaveContext.gameMode = 0;
this->state.running = false;
SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext);
} else {
gSaveContext.fileNum = selectedfile;
Sram_OpenSave(&this->sramCtx);
Sram_OpenSave();
gSaveContext.gameMode = 0;
this->state.running = false;
//return;
@@ -322,7 +322,7 @@ void Title_Main(GameState* thisx) {
void Title_Destroy(GameState* thisx) {
TitleContext* this = (TitleContext*)thisx;
Sram_InitSram(&this->state, &this->sramCtx);
Sram_InitSram(&this->state);
}
void Title_Init(GameState* thisx) {
@@ -346,7 +346,6 @@ void Title_Init(GameState* thisx) {
this->state.destroy = Title_Destroy;
this->exit = false;
gSaveContext.fileNum = 0xFF;
Sram_Alloc(&this->state, &this->sramCtx);
this->ult = 0;
this->unk_1D4 = 0x14;
this->coverAlpha = 255;
@@ -640,9 +640,13 @@ void KaleidoScope_DrawDebugEditor(GlobalContext* globalCtx) {
// Handles exiting the inventory editor with the L button
// The editor is opened with `debugState` set to 1, and becomes closable after a frame once `debugState` is set to 2
s16 Debug_BTN = BTN_L;
if (CVar_GetS32("gNGCKaleidoSwitcher", 0) != 0) {
Debug_BTN = BTN_Z;
}
if (pauseCtx->debugState == 1) {
pauseCtx->debugState = 2;
} else if ((pauseCtx->debugState == 2) && CHECK_BTN_ALL(input->press.button, BTN_L)) {
} else if ((pauseCtx->debugState == 2) && CHECK_BTN_ALL(input->press.button, Debug_BTN)) {
pauseCtx->debugState = 0;
}
@@ -98,8 +98,8 @@ void KaleidoScope_DrawPlayerWork(GlobalContext* globalCtx) {
f32 scale;
Input* input = &globalCtx->state.input[0];
s16 RotationSpeed = 150 * CVar_GetS32("gPauseLiveLinkRotationSpeed", 0);
bool AllowCRotation = (CVar_GetS32("gPauseLiveLinkRotation", 0) == 2) ? true : false;
bool AllowDPadRotation = (CVar_GetS32("gPauseLiveLinkRotation", 0) == 1) ? true : false;
u8 AllowCRotation = (CVar_GetS32("gPauseLiveLinkRotation", 0) == 2) ? true : false;
u8 AllowDPadRotation = (CVar_GetS32("gPauseLiveLinkRotation", 0) == 1) ? true : false;
if (LINK_AGE_IN_YEARS == YEARS_CHILD) {
pos.x = 2.0f;
@@ -120,19 +120,19 @@ void KaleidoScope_DrawPlayerWork(GlobalContext* globalCtx) {
link_kaleido_rot.x = link_kaleido_rot.z = 0;
if (AllowDPadRotation && CHECK_BTN_ALL(input->cur.button, BTN_DLEFT) ||
AllowCRotation && CHECK_BTN_ALL(input->cur.button, BTN_CLEFT)) {
if ((AllowDPadRotation && CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) ||
(AllowCRotation && CHECK_BTN_ALL(input->cur.button, BTN_CLEFT))) {
link_kaleido_rot.y = link_kaleido_rot.y - RotationSpeed;
} else if (AllowDPadRotation && CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT) ||
AllowCRotation && CHECK_BTN_ALL(input->cur.button, BTN_CRIGHT)) {
} else if ((AllowDPadRotation && CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT)) ||
(AllowCRotation && CHECK_BTN_ALL(input->cur.button, BTN_CRIGHT))) {
link_kaleido_rot.y = link_kaleido_rot.y + RotationSpeed;
}
if (AllowDPadRotation && CHECK_BTN_ALL(input->press.button, BTN_DUP) ||
AllowDPadRotation && CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) {
if ((AllowDPadRotation && CHECK_BTN_ALL(input->press.button, BTN_DUP)) ||
(AllowDPadRotation && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) {
link_kaleido_rot.y = 32300;
} else if (AllowCRotation && CHECK_BTN_ALL(input->press.button, BTN_CUP) ||
AllowCRotation && CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) {
} else if ((AllowCRotation && CHECK_BTN_ALL(input->press.button, BTN_CUP)) ||
(AllowCRotation && CHECK_BTN_ALL(input->press.button, BTN_CDOWN))) {
link_kaleido_rot.y = 32300;
}
@@ -635,7 +635,8 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gBiggoronSwordIconTex, 32, 32, point);
} else if ((i == 0) && (k == 2) && (gBitFlags[bit + 1] & gSaveContext.inventory.equipment)) {
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gBrokenGiantsKnifeIconTex, 32, 32, point);
} else if (gBitFlags[bit] & gSaveContext.inventory.equipment) {
}
if (gBitFlags[bit] & gSaveContext.inventory.equipment) {
int itemId = ITEM_SWORD_KOKIRI + temp;
bool not_acquired = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge);
if (not_acquired) {
@@ -930,7 +930,14 @@ void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) {
}
void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) {
if (CVar_GetS32("gDebugEnabled", 0) && (pauseCtx->debugState == 0) && CHECK_BTN_ALL(input->press.button, BTN_L)) {
s16 Debug_BTN = BTN_L;
s16 PageLeft_BTN = BTN_Z;
if (CVar_GetS32("gNGCKaleidoSwitcher", 0) != 0) {
Debug_BTN = BTN_Z;
PageLeft_BTN = BTN_L;
}
if (CVar_GetS32("gDebugEnabled", 0) && (pauseCtx->debugState == 0) && CHECK_BTN_ALL(input->press.button, Debug_BTN)) {
pauseCtx->debugState = 1;
return;
}
@@ -940,14 +947,14 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) {
return;
}
if (CHECK_BTN_ALL(input->press.button, BTN_Z)) {
if (CHECK_BTN_ALL(input->press.button, PageLeft_BTN)) {
KaleidoScope_SwitchPage(pauseCtx, 0);
return;
}
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) {
if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->cur.button, BTN_DLEFT))) {
pauseCtx->pageSwitchTimer++;
if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) {
KaleidoScope_SwitchPage(pauseCtx, 0);
@@ -956,7 +963,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) {
pauseCtx->pageSwitchTimer = -1;
}
} else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) {
if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT))) {
pauseCtx->pageSwitchTimer++;
if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) {
KaleidoScope_SwitchPage(pauseCtx, 2);
@@ -1115,6 +1122,7 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) {
static s16 D_8082AD4C = 0;
static s16 D_8082AD50 = 0;
PauseContext* pauseCtx = &globalCtx->pauseCtx;
Input* input = &globalCtx->state.input[0];
s16 stepR;
s16 stepG;
s16 stepB;
@@ -1155,6 +1163,52 @@ void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) {
}
}
if (CVar_GetS32("gDpadHoldChange", 1) && CVar_GetS32("gDpadPauseName", 0)) {
if (CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) {
if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) {
D_8082AD44 = XREG(8);
D_8082AD4C = -1;
} else if (--D_8082AD44 < 0) {
D_8082AD44 = XREG(6);
input->press.button |= BTN_DLEFT;
}
} else if (CHECK_BTN_ALL(input->rel.button, BTN_DLEFT)) {
D_8082AD4C = 0;
} else if (CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT)) {
if (CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) {
D_8082AD44 = XREG(8);
D_8082AD4C = 1;
} else if (--D_8082AD44 < 0) {
D_8082AD44 = XREG(6);
input->press.button |= BTN_DRIGHT;
}
} else if (CHECK_BTN_ALL(input->rel.button, BTN_DRIGHT)) {
D_8082AD4C = 0;
}
if (CHECK_BTN_ALL(input->cur.button, BTN_DDOWN)) {
if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) {
D_8082AD48 = XREG(8);
D_8082AD50 = -1;
} else if (--D_8082AD48 < 0) {
D_8082AD48 = XREG(6);
input->press.button |= BTN_DDOWN;
}
} else if (CHECK_BTN_ALL(input->rel.button, BTN_DDOWN)) {
D_8082AD50 = 0;
} else if (CHECK_BTN_ALL(input->cur.button, BTN_DUP)) {
if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) {
D_8082AD48 = XREG(8);
D_8082AD50 = 1;
} else if (--D_8082AD48 < 0) {
D_8082AD48 = XREG(6);
input->press.button |= BTN_DUP;
}
} else if (CHECK_BTN_ALL(input->rel.button, BTN_DUP)) {
D_8082AD50 = 0;
}
}
if (pauseCtx->stickRelX < -30) {
if (D_8082AD4C == -1) {
if (--D_8082AD44 < 0) {
@@ -3725,7 +3779,7 @@ void KaleidoScope_Update(GlobalContext* globalCtx)
&D_801333E8);
Gameplay_SaveSceneFlags(globalCtx);
gSaveContext.savedSceneNum = globalCtx->sceneNum;
Sram_WriteSave(&globalCtx->sramCtx);
Save_SaveFile();
pauseCtx->unk_1EC = 4;
D_8082B25C = 3;
}
@@ -3965,7 +4019,7 @@ void KaleidoScope_Update(GlobalContext* globalCtx)
pauseCtx->promptChoice = 0;
Gameplay_SaveSceneFlags(globalCtx);
gSaveContext.savedSceneNum = globalCtx->sceneNum;
Sram_WriteSave(&globalCtx->sramCtx);
Save_SaveFile();
pauseCtx->state = 0xF;
D_8082B25C = 3;
}