mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-09-03 11:01:32 -04:00
Merge pull request #3756 from HarbourMasters/develop
develop -> develop-rando
This commit is contained in:
@@ -4735,7 +4735,7 @@ void Audio_SetSequenceMode(u8 seqMode) {
|
||||
seqMode = SEQ_MODE_IGNORE;
|
||||
}
|
||||
|
||||
seqId = D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254;
|
||||
seqId = gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId;
|
||||
|
||||
if (seqId == NA_BGM_FIELD_LOGIC && func_800FA0B4(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) {
|
||||
seqMode = SEQ_MODE_IGNORE;
|
||||
@@ -4746,10 +4746,10 @@ void Audio_SetSequenceMode(u8 seqMode) {
|
||||
if (seqMode != (sPrevSeqMode & 0x7F)) {
|
||||
if (seqMode == SEQ_MODE_ENEMY) {
|
||||
// Start playing enemy bgm
|
||||
if (D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol < 0) {
|
||||
volumeFadeInTimer = -(D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol);
|
||||
if (gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol < 0) {
|
||||
volumeFadeInTimer = -(gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol);
|
||||
} else {
|
||||
volumeFadeInTimer = D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol;
|
||||
volumeFadeInTimer = gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol;
|
||||
}
|
||||
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 3, sAudioEnemyVol, volumeFadeInTimer);
|
||||
@@ -4812,11 +4812,11 @@ void Audio_SetBgmEnemyVolume(f32 dist) {
|
||||
|
||||
sAudioEnemyVol = ((350.0f - adjDist) * 127.0f) / 350.0f;
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 3, sAudioEnemyVol, 10);
|
||||
if (D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 != NA_BGM_NATURE_AMBIENCE) {
|
||||
if (gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId != NA_BGM_NATURE_AMBIENCE) {
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sAudioEnemyVol), 10);
|
||||
}
|
||||
}
|
||||
if (D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 != NA_BGM_NATURE_AMBIENCE) {
|
||||
if (gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId != NA_BGM_NATURE_AMBIENCE) {
|
||||
Audio_SplitBgmChannels(sAudioEnemyVol);
|
||||
}
|
||||
}
|
||||
@@ -4973,7 +4973,7 @@ void Audio_SetExtraFilter(u8 filter) {
|
||||
|
||||
sAudioExtraFilter2 = filter;
|
||||
sAudioExtraFilter = filter;
|
||||
if (D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 == NA_BGM_NATURE_AMBIENCE) {
|
||||
if (gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId == NA_BGM_NATURE_AMBIENCE) {
|
||||
for (i = 0; i < 16; i++) {
|
||||
t = i;
|
||||
// CHAN_UPD_SCRIPT_IO (seq player 0, all channels, slot 6)
|
||||
@@ -5097,7 +5097,7 @@ void Audio_SetNatureAmbienceChannelIO(u8 channelIdxRange, u8 port, u8 val) {
|
||||
u8 lastChannelIdx;
|
||||
u8 channelIdx;
|
||||
|
||||
if ((D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 != NA_BGM_NATURE_AMBIENCE) && func_800FA11C(1, 0xF00000FF)) {
|
||||
if ((gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId != NA_BGM_NATURE_AMBIENCE) && func_800FA11C(1, 0xF00000FF)) {
|
||||
sAudioNatureFailed = true;
|
||||
return;
|
||||
}
|
||||
@@ -5159,8 +5159,8 @@ void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId) {
|
||||
u8 port;
|
||||
u8 val;
|
||||
|
||||
if ((D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 == NA_BGM_DISABLED) ||
|
||||
!(sSeqFlags[((u8)D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254) & 0xFF] & 0x80)) {
|
||||
if ((gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId == NA_BGM_DISABLED) ||
|
||||
!(sSeqFlags[((u8)gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId) & 0xFF] & 0x80)) {
|
||||
|
||||
Audio_StartNatureAmbienceSequence(sNatureAmbienceDataIO[natureAmbienceId].playerIO,
|
||||
sNatureAmbienceDataIO[natureAmbienceId].channelMask);
|
||||
@@ -5202,12 +5202,12 @@ void func_800F71BC(s32 arg0) {
|
||||
func_800F6C34();
|
||||
func_800EE930();
|
||||
Audio_ResetSfxChannelState();
|
||||
func_800FADF8();
|
||||
Audio_ResetActiveSequences();
|
||||
Audio_ResetSounds();
|
||||
}
|
||||
|
||||
void func_800F7208(void) {
|
||||
func_800FADF8();
|
||||
Audio_ResetActiveSequences();
|
||||
Audio_QueueCmdS32(0xF2000000, 1);
|
||||
func_800F6C34();
|
||||
Audio_ResetSfxChannelState();
|
||||
|
||||
+161
-158
@@ -12,9 +12,9 @@ typedef struct {
|
||||
#define GET_PLAYER_IDX(cmd) (cmd & 0xF000000) >> 24
|
||||
|
||||
Struct_8016E320 D_8016E320[4][5];
|
||||
u8 D_8016E348[4];
|
||||
u8 sNumSeqRequests[4];
|
||||
u32 sAudioSeqCmds[0x100];
|
||||
unk_D_8016E750 D_8016E750[4];
|
||||
ActiveSequence gActiveSeqs[4];
|
||||
|
||||
u8 sSeqCmdWrPos = 0;
|
||||
u8 sSeqCmdRdPos = 0;
|
||||
@@ -51,33 +51,33 @@ void func_800F9280(u8 playerIdx, u8 seqId, u8 arg2, u16 fadeTimer) {
|
||||
(fadeTimer * (u16)gAudioContext.audioBufferParameters.updatesPerFrame) / 4);
|
||||
}
|
||||
|
||||
D_8016E750[playerIdx].unk_254 = seqId | (arg2 << 8);
|
||||
D_8016E750[playerIdx].unk_256 = seqId | (arg2 << 8);
|
||||
gActiveSeqs[playerIdx].seqId = seqId | (arg2 << 8);
|
||||
gActiveSeqs[playerIdx].prevSeqId = seqId | (arg2 << 8);
|
||||
|
||||
if (D_8016E750[playerIdx].volCur != 1.0f) {
|
||||
Audio_QueueCmdF32(0x41000000 | _SHIFTL(playerIdx, 16, 8), D_8016E750[playerIdx].volCur);
|
||||
if (gActiveSeqs[playerIdx].volCur != 1.0f) {
|
||||
Audio_QueueCmdF32(0x41000000 | _SHIFTL(playerIdx, 16, 8), gActiveSeqs[playerIdx].volCur);
|
||||
}
|
||||
|
||||
D_8016E750[playerIdx].unk_28 = 0;
|
||||
D_8016E750[playerIdx].unk_18 = 0;
|
||||
D_8016E750[playerIdx].unk_14 = 0;
|
||||
gActiveSeqs[playerIdx].tempoTimer = 0;
|
||||
gActiveSeqs[playerIdx].tempoOriginal = 0;
|
||||
gActiveSeqs[playerIdx].tempoCmd = 0;
|
||||
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
D_8016E750[playerIdx].unk_50[i].unk_00 = 1.0f;
|
||||
D_8016E750[playerIdx].unk_50[i].unk_0C = 0;
|
||||
D_8016E750[playerIdx].unk_50[i].unk_10 = 1.0f;
|
||||
D_8016E750[playerIdx].unk_50[i].unk_1C = 0;
|
||||
gActiveSeqs[playerIdx].channelData[i].volCur = 1.0f;
|
||||
gActiveSeqs[playerIdx].channelData[i].volTimer = 0;
|
||||
gActiveSeqs[playerIdx].channelData[i].freqScaleCur = 1.0f;
|
||||
gActiveSeqs[playerIdx].channelData[i].freqScaleTimer = 0;
|
||||
}
|
||||
|
||||
D_8016E750[playerIdx].unk_250 = 0;
|
||||
D_8016E750[playerIdx].unk_252 = 0;
|
||||
gActiveSeqs[playerIdx].freqScaleChannelFlags = 0;
|
||||
gActiveSeqs[playerIdx].volChannelFlags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void func_800F9474(u8 playerIdx, u16 arg1) {
|
||||
Audio_QueueCmdS32(0x83000000 | ((u8)playerIdx << 16),
|
||||
(arg1 * (u16)gAudioContext.audioBufferParameters.updatesPerFrame) / 4);
|
||||
D_8016E750[playerIdx].unk_254 = NA_BGM_DISABLED;
|
||||
gActiveSeqs[playerIdx].seqId = NA_BGM_DISABLED;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
@@ -133,7 +133,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
seqId = cmd & 0xFF;
|
||||
seqArgs = (cmd & 0xFF00) >> 8;
|
||||
fadeTimer = (cmd & 0xFF0000) >> 13;
|
||||
if ((D_8016E750[playerIdx].unk_260 == 0) && (seqArgs < 0x80)) {
|
||||
if ((gActiveSeqs[playerIdx].isWaitingForFonts == 0) && (seqArgs < 0x80)) {
|
||||
func_800F9280(playerIdx, seqId, seqArgs, fadeTimer);
|
||||
}
|
||||
break;
|
||||
@@ -150,7 +150,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
seqArgs = (cmd & 0xFF00) >> 8;
|
||||
fadeTimer = (cmd & 0xFF0000) >> 13;
|
||||
new_var = seqArgs;
|
||||
for (i = 0; i < D_8016E348[playerIdx]; i++) {
|
||||
for (i = 0; i < sNumSeqRequests[playerIdx]; i++) {
|
||||
if (D_8016E320[playerIdx][i].unk_0 == seqId) {
|
||||
if (i == 0) {
|
||||
func_800F9280(playerIdx, seqId, seqArgs, fadeTimer);
|
||||
@@ -159,18 +159,18 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
found = D_8016E348[playerIdx];
|
||||
for (i = 0; i < D_8016E348[playerIdx]; i++) {
|
||||
found = sNumSeqRequests[playerIdx];
|
||||
for (i = 0; i < sNumSeqRequests[playerIdx]; i++) {
|
||||
if (D_8016E320[playerIdx][i].unk_1 <= new_var) {
|
||||
found = i;
|
||||
i = D_8016E348[playerIdx]; // "break;"
|
||||
i = sNumSeqRequests[playerIdx]; // "break;"
|
||||
}
|
||||
}
|
||||
|
||||
if (D_8016E348[playerIdx] < 5) {
|
||||
D_8016E348[playerIdx]++;
|
||||
if (sNumSeqRequests[playerIdx] < 5) {
|
||||
sNumSeqRequests[playerIdx]++;
|
||||
}
|
||||
for (i = D_8016E348[playerIdx] - 1; i != found; i--) {
|
||||
for (i = sNumSeqRequests[playerIdx] - 1; i != found; i--) {
|
||||
D_8016E320[playerIdx][i].unk_1 = D_8016E320[playerIdx][i - 1].unk_1;
|
||||
D_8016E320[playerIdx][i].unk_0 = D_8016E320[playerIdx][i - 1].unk_0;
|
||||
}
|
||||
@@ -187,25 +187,25 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
seqId = cmd & 0xFF;
|
||||
fadeTimer = (cmd & 0xFF0000) >> 13;
|
||||
|
||||
found = D_8016E348[playerIdx];
|
||||
for (i = 0; i < D_8016E348[playerIdx]; i++) {
|
||||
found = sNumSeqRequests[playerIdx];
|
||||
for (i = 0; i < sNumSeqRequests[playerIdx]; i++) {
|
||||
if (D_8016E320[playerIdx][i].unk_0 == seqId) {
|
||||
found = i;
|
||||
i = D_8016E348[playerIdx]; // "break;"
|
||||
i = sNumSeqRequests[playerIdx]; // "break;"
|
||||
}
|
||||
}
|
||||
|
||||
if (found != D_8016E348[playerIdx]) {
|
||||
for (i = found; i < D_8016E348[playerIdx] - 1; i++) {
|
||||
if (found != sNumSeqRequests[playerIdx]) {
|
||||
for (i = found; i < sNumSeqRequests[playerIdx] - 1; i++) {
|
||||
D_8016E320[playerIdx][i].unk_1 = D_8016E320[playerIdx][i + 1].unk_1;
|
||||
D_8016E320[playerIdx][i].unk_0 = D_8016E320[playerIdx][i + 1].unk_0;
|
||||
}
|
||||
D_8016E348[playerIdx]--;
|
||||
sNumSeqRequests[playerIdx]--;
|
||||
}
|
||||
|
||||
if (found == 0) {
|
||||
func_800F9474(playerIdx, fadeTimer);
|
||||
if (D_8016E348[playerIdx] != 0) {
|
||||
if (sNumSeqRequests[playerIdx] != 0) {
|
||||
func_800F9280(playerIdx, D_8016E320[playerIdx][0].unk_0, D_8016E320[playerIdx][0].unk_1, fadeTimer);
|
||||
}
|
||||
}
|
||||
@@ -218,11 +218,11 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
if (duration == 0) {
|
||||
duration++;
|
||||
}
|
||||
D_8016E750[playerIdx].volTarget = (f32)val / 127.0f;
|
||||
if (D_8016E750[playerIdx].volCur != D_8016E750[playerIdx].volTarget) {
|
||||
D_8016E750[playerIdx].unk_08 =
|
||||
(D_8016E750[playerIdx].volCur - D_8016E750[playerIdx].volTarget) / (f32)duration;
|
||||
D_8016E750[playerIdx].unk_0C = duration;
|
||||
gActiveSeqs[playerIdx].volTarget = (f32)val / 127.0f;
|
||||
if (gActiveSeqs[playerIdx].volCur != gActiveSeqs[playerIdx].volTarget) {
|
||||
gActiveSeqs[playerIdx].volStep =
|
||||
(gActiveSeqs[playerIdx].volCur - gActiveSeqs[playerIdx].volTarget) / (f32)duration;
|
||||
gActiveSeqs[playerIdx].volTimer = duration;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -235,12 +235,12 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
}
|
||||
freqScale = (f32)val / 1000.0f;
|
||||
for (i = 0; i < 16; i++) {
|
||||
D_8016E750[playerIdx].unk_50[i].unk_14 = freqScale;
|
||||
D_8016E750[playerIdx].unk_50[i].unk_1C = duration;
|
||||
D_8016E750[playerIdx].unk_50[i].unk_18 =
|
||||
(D_8016E750[playerIdx].unk_50[i].unk_10 - freqScale) / (f32)duration;
|
||||
gActiveSeqs[playerIdx].channelData[i].freqScaleTarget = freqScale;
|
||||
gActiveSeqs[playerIdx].channelData[i].freqScaleTimer = duration;
|
||||
gActiveSeqs[playerIdx].channelData[i].freqScaleStep =
|
||||
(gActiveSeqs[playerIdx].channelData[i].freqScaleCur - freqScale) / (f32)duration;
|
||||
}
|
||||
D_8016E750[playerIdx].unk_250 = 0xFFFF;
|
||||
gActiveSeqs[playerIdx].freqScaleChannelFlags = 0xFFFF;
|
||||
break;
|
||||
|
||||
case 0xD:
|
||||
@@ -252,11 +252,11 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
duration++;
|
||||
}
|
||||
freqScale = (f32)val / 1000.0f;
|
||||
D_8016E750[playerIdx].unk_50[chanIdx].unk_14 = freqScale;
|
||||
D_8016E750[playerIdx].unk_50[chanIdx].unk_18 =
|
||||
(D_8016E750[playerIdx].unk_50[chanIdx].unk_10 - freqScale) / (f32)duration;
|
||||
D_8016E750[playerIdx].unk_50[chanIdx].unk_1C = duration;
|
||||
D_8016E750[playerIdx].unk_250 |= 1 << chanIdx;
|
||||
gActiveSeqs[playerIdx].channelData[chanIdx].freqScaleTarget = freqScale;
|
||||
gActiveSeqs[playerIdx].channelData[chanIdx].freqScaleStep =
|
||||
(gActiveSeqs[playerIdx].channelData[chanIdx].freqScaleCur - freqScale) / (f32)duration;
|
||||
gActiveSeqs[playerIdx].channelData[chanIdx].freqScaleTimer = duration;
|
||||
gActiveSeqs[playerIdx].freqScaleChannelFlags |= 1 << chanIdx;
|
||||
break;
|
||||
|
||||
case 0x6:
|
||||
@@ -267,13 +267,13 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
if (duration == 0) {
|
||||
duration++;
|
||||
}
|
||||
D_8016E750[playerIdx].unk_50[chanIdx].unk_04 = (f32)val / 127.0f;
|
||||
if (D_8016E750[playerIdx].unk_50[chanIdx].unk_00 != D_8016E750[playerIdx].unk_50[chanIdx].unk_04) {
|
||||
D_8016E750[playerIdx].unk_50[chanIdx].unk_08 =
|
||||
(D_8016E750[playerIdx].unk_50[chanIdx].unk_00 - D_8016E750[playerIdx].unk_50[chanIdx].unk_04) /
|
||||
gActiveSeqs[playerIdx].channelData[chanIdx].volTarget = (f32)val / 127.0f;
|
||||
if (gActiveSeqs[playerIdx].channelData[chanIdx].volCur != gActiveSeqs[playerIdx].channelData[chanIdx].volTarget) {
|
||||
gActiveSeqs[playerIdx].channelData[chanIdx].volStep =
|
||||
(gActiveSeqs[playerIdx].channelData[chanIdx].volCur - gActiveSeqs[playerIdx].channelData[chanIdx].volTarget) /
|
||||
(f32)duration;
|
||||
D_8016E750[playerIdx].unk_50[chanIdx].unk_0C = duration;
|
||||
D_8016E750[playerIdx].unk_252 |= 1 << chanIdx;
|
||||
gActiveSeqs[playerIdx].channelData[chanIdx].volTimer = duration;
|
||||
gActiveSeqs[playerIdx].volChannelFlags |= 1 << chanIdx;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -289,7 +289,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
chanIdx = (cmd & 0xF00) >> 8;
|
||||
port = (cmd & 0xFF0000) >> 16;
|
||||
val = cmd & 0xFF;
|
||||
if ((D_8016E750[playerIdx].unk_258 & (1 << chanIdx)) == 0) {
|
||||
if ((gActiveSeqs[playerIdx].channelPortMask & (1 << chanIdx)) == 0) {
|
||||
Audio_QueueCmdS8(0x06000000 | _SHIFTL(playerIdx, 16, 8) | _SHIFTL(chanIdx, 8, 8) | _SHIFTL(port, 0, 8),
|
||||
val);
|
||||
}
|
||||
@@ -297,7 +297,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
|
||||
case 0x9:
|
||||
// set channel mask for command 0x8
|
||||
D_8016E750[playerIdx].unk_258 = cmd & 0xFFFF;
|
||||
gActiveSeqs[playerIdx].channelPortMask = cmd & 0xFFFF;
|
||||
break;
|
||||
|
||||
case 0xA:
|
||||
@@ -319,22 +319,22 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
||||
|
||||
case 0xB:
|
||||
// update tempo
|
||||
D_8016E750[playerIdx].unk_14 = cmd;
|
||||
gActiveSeqs[playerIdx].tempoCmd = cmd;
|
||||
break;
|
||||
|
||||
case 0xC:
|
||||
// start sequence with setup commands
|
||||
subOp = (cmd & 0xF00000) >> 20;
|
||||
if (subOp != 0xF) {
|
||||
if (D_8016E750[playerIdx].unk_4D < 7) {
|
||||
found = D_8016E750[playerIdx].unk_4D++;
|
||||
if (gActiveSeqs[playerIdx].setupCmdNum < 7) {
|
||||
found = gActiveSeqs[playerIdx].setupCmdNum++;
|
||||
if (found < 8) {
|
||||
D_8016E750[playerIdx].unk_2C[found] = cmd;
|
||||
D_8016E750[playerIdx].unk_4C = 2;
|
||||
gActiveSeqs[playerIdx].setupCmd[found] = cmd;
|
||||
gActiveSeqs[playerIdx].setupCmdTimer = 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
D_8016E750[playerIdx].unk_4D = 0;
|
||||
gActiveSeqs[playerIdx].setupCmdNum = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -400,7 +400,7 @@ u16 func_800FA0B4(u8 playerIdx) {
|
||||
if (!gAudioContext.seqPlayers[playerIdx].enabled) {
|
||||
return NA_BGM_DISABLED;
|
||||
}
|
||||
return D_8016E750[playerIdx].unk_254;
|
||||
return gActiveSeqs[playerIdx].seqId;
|
||||
}
|
||||
|
||||
s32 func_800FA11C(u32 arg0, u32 arg1) {
|
||||
@@ -416,17 +416,17 @@ s32 func_800FA11C(u32 arg0, u32 arg1) {
|
||||
}
|
||||
|
||||
void func_800FA174(u8 playerIdx) {
|
||||
D_8016E348[playerIdx] = 0;
|
||||
sNumSeqRequests[playerIdx] = 0;
|
||||
}
|
||||
|
||||
void func_800FA18C(u8 playerIdx, u8 arg1) {
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < D_8016E750[playerIdx].unk_4D; i++) {
|
||||
u8 unkb = (D_8016E750[playerIdx].unk_2C[i] & 0xF00000) >> 20;
|
||||
for (i = 0; i < gActiveSeqs[playerIdx].setupCmdNum; i++) {
|
||||
u8 unkb = (gActiveSeqs[playerIdx].setupCmd[i] & 0xF00000) >> 20;
|
||||
|
||||
if (unkb == arg1) {
|
||||
D_8016E750[playerIdx].unk_2C[i] = 0xFF000000;
|
||||
gActiveSeqs[playerIdx].setupCmd[i] = 0xFF000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,14 +435,14 @@ void Audio_SetVolScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer)
|
||||
f32 volScale;
|
||||
u8 i;
|
||||
|
||||
D_8016E750[playerIdx].volScales[scaleIdx] = targetVol & 0x7F;
|
||||
gActiveSeqs[playerIdx].volScales[scaleIdx] = targetVol & 0x7F;
|
||||
|
||||
if (volFadeTimer != 0) {
|
||||
D_8016E750[playerIdx].fadeVolUpdate = 1;
|
||||
D_8016E750[playerIdx].volFadeTimer = volFadeTimer;
|
||||
gActiveSeqs[playerIdx].fadeVolUpdate = 1;
|
||||
gActiveSeqs[playerIdx].volFadeTimer = volFadeTimer;
|
||||
} else {
|
||||
for (i = 0, volScale = 1.0f; i < 4; i++) {
|
||||
volScale *= D_8016E750[playerIdx].volScales[i] / 127.0f;
|
||||
volScale *= gActiveSeqs[playerIdx].volScales[i] / 127.0f;
|
||||
}
|
||||
|
||||
Audio_SetVolScaleNow(playerIdx, volFadeTimer, volScale);
|
||||
@@ -468,41 +468,41 @@ void func_800FA3DC(void) {
|
||||
u8 k;
|
||||
|
||||
for (playerIdx = 0; playerIdx < 4; playerIdx++) {
|
||||
if (D_8016E750[playerIdx].unk_260 != 0) {
|
||||
if (gActiveSeqs[playerIdx].isWaitingForFonts != 0) {
|
||||
switch (func_800E5E20(&dummy)) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
D_8016E750[playerIdx].unk_260 = 0;
|
||||
Audio_ProcessSeqCmd(D_8016E750[playerIdx].unk_25C);
|
||||
gActiveSeqs[playerIdx].isWaitingForFonts = 0;
|
||||
Audio_ProcessSeqCmd(gActiveSeqs[playerIdx].startSeqCmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (D_8016E750[playerIdx].fadeVolUpdate) {
|
||||
if (gActiveSeqs[playerIdx].fadeVolUpdate) {
|
||||
phi_f0 = 1.0f;
|
||||
for (j = 0; j < 4; j++) {
|
||||
phi_f0 *= (D_8016E750[playerIdx].volScales[j] / 127.0f);
|
||||
phi_f0 *= (gActiveSeqs[playerIdx].volScales[j] / 127.0f);
|
||||
}
|
||||
Audio_SeqCmd4(playerIdx, D_8016E750[playerIdx].volFadeTimer, (u8)(phi_f0 * 127.0f));
|
||||
D_8016E750[playerIdx].fadeVolUpdate = 0;
|
||||
Audio_SeqCmd4(playerIdx, gActiveSeqs[playerIdx].volFadeTimer, (u8)(phi_f0 * 127.0f));
|
||||
gActiveSeqs[playerIdx].fadeVolUpdate = 0;
|
||||
}
|
||||
|
||||
if (D_8016E750[playerIdx].unk_0C != 0) {
|
||||
D_8016E750[playerIdx].unk_0C--;
|
||||
if (gActiveSeqs[playerIdx].volTimer != 0) {
|
||||
gActiveSeqs[playerIdx].volTimer--;
|
||||
|
||||
if (D_8016E750[playerIdx].unk_0C != 0) {
|
||||
D_8016E750[playerIdx].volCur = D_8016E750[playerIdx].volCur - D_8016E750[playerIdx].unk_08;
|
||||
if (gActiveSeqs[playerIdx].volTimer != 0) {
|
||||
gActiveSeqs[playerIdx].volCur = gActiveSeqs[playerIdx].volCur - gActiveSeqs[playerIdx].volStep;
|
||||
} else {
|
||||
D_8016E750[playerIdx].volCur = D_8016E750[playerIdx].volTarget;
|
||||
gActiveSeqs[playerIdx].volCur = gActiveSeqs[playerIdx].volTarget;
|
||||
}
|
||||
|
||||
Audio_QueueCmdF32(0x41000000 | _SHIFTL(playerIdx, 16, 8), D_8016E750[playerIdx].volCur);
|
||||
Audio_QueueCmdF32(0x41000000 | _SHIFTL(playerIdx, 16, 8), gActiveSeqs[playerIdx].volCur);
|
||||
}
|
||||
|
||||
if (D_8016E750[playerIdx].unk_14 != 0) {
|
||||
temp_a1 = D_8016E750[playerIdx].unk_14;
|
||||
if (gActiveSeqs[playerIdx].tempoCmd != 0) {
|
||||
temp_a1 = gActiveSeqs[playerIdx].tempoCmd;
|
||||
phi_t0 = (temp_a1 & 0xFF0000) >> 15;
|
||||
phi_a2 = temp_a1 & 0xFFF;
|
||||
if (phi_t0 == 0) {
|
||||
@@ -525,8 +525,8 @@ void func_800FA3DC(void) {
|
||||
phi_a2 = temp_lo * (phi_a2 / 100.0f);
|
||||
break;
|
||||
case 4:
|
||||
if (D_8016E750[playerIdx].unk_18) {
|
||||
phi_a2 = D_8016E750[playerIdx].unk_18;
|
||||
if (gActiveSeqs[playerIdx].tempoOriginal) {
|
||||
phi_a2 = gActiveSeqs[playerIdx].tempoOriginal;
|
||||
} else {
|
||||
phi_a2 = temp_lo;
|
||||
}
|
||||
@@ -537,71 +537,71 @@ void func_800FA3DC(void) {
|
||||
phi_a2 = 300;
|
||||
}
|
||||
|
||||
if (D_8016E750[playerIdx].unk_18 == 0) {
|
||||
D_8016E750[playerIdx].unk_18 = temp_lo;
|
||||
if (gActiveSeqs[playerIdx].tempoOriginal == 0) {
|
||||
gActiveSeqs[playerIdx].tempoOriginal = temp_lo;
|
||||
}
|
||||
|
||||
D_8016E750[playerIdx].unk_20 = phi_a2;
|
||||
D_8016E750[playerIdx].unk_1C = gAudioContext.seqPlayers[playerIdx].tempo / 0x30;
|
||||
D_8016E750[playerIdx].unk_24 = (D_8016E750[playerIdx].unk_1C - D_8016E750[playerIdx].unk_20) / phi_t0;
|
||||
D_8016E750[playerIdx].unk_28 = phi_t0;
|
||||
D_8016E750[playerIdx].unk_14 = 0;
|
||||
gActiveSeqs[playerIdx].tempoTarget = phi_a2;
|
||||
gActiveSeqs[playerIdx].tempoCur = gAudioContext.seqPlayers[playerIdx].tempo / 0x30;
|
||||
gActiveSeqs[playerIdx].tempoStep = (gActiveSeqs[playerIdx].tempoCur - gActiveSeqs[playerIdx].tempoTarget) / phi_t0;
|
||||
gActiveSeqs[playerIdx].tempoTimer = phi_t0;
|
||||
gActiveSeqs[playerIdx].tempoCmd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (D_8016E750[playerIdx].unk_28 != 0) {
|
||||
D_8016E750[playerIdx].unk_28--;
|
||||
if (D_8016E750[playerIdx].unk_28 != 0) {
|
||||
D_8016E750[playerIdx].unk_1C = D_8016E750[playerIdx].unk_1C - D_8016E750[playerIdx].unk_24;
|
||||
if (gActiveSeqs[playerIdx].tempoTimer != 0) {
|
||||
gActiveSeqs[playerIdx].tempoTimer--;
|
||||
if (gActiveSeqs[playerIdx].tempoTimer != 0) {
|
||||
gActiveSeqs[playerIdx].tempoCur = gActiveSeqs[playerIdx].tempoCur - gActiveSeqs[playerIdx].tempoStep;
|
||||
} else {
|
||||
D_8016E750[playerIdx].unk_1C = D_8016E750[playerIdx].unk_20;
|
||||
gActiveSeqs[playerIdx].tempoCur = gActiveSeqs[playerIdx].tempoTarget;
|
||||
}
|
||||
// set tempo
|
||||
Audio_QueueCmdS32(0x47000000 | _SHIFTL(playerIdx, 16, 8), D_8016E750[playerIdx].unk_1C);
|
||||
Audio_QueueCmdS32(0x47000000 | _SHIFTL(playerIdx, 16, 8), gActiveSeqs[playerIdx].tempoCur);
|
||||
}
|
||||
|
||||
if (D_8016E750[playerIdx].unk_252 != 0) {
|
||||
if (gActiveSeqs[playerIdx].volChannelFlags != 0) {
|
||||
for (k = 0; k < 0x10; k++) {
|
||||
if (D_8016E750[playerIdx].unk_50[k].unk_0C != 0) {
|
||||
D_8016E750[playerIdx].unk_50[k].unk_0C--;
|
||||
if (D_8016E750[playerIdx].unk_50[k].unk_0C != 0) {
|
||||
D_8016E750[playerIdx].unk_50[k].unk_00 -= D_8016E750[playerIdx].unk_50[k].unk_08;
|
||||
if (gActiveSeqs[playerIdx].channelData[k].volTimer != 0) {
|
||||
gActiveSeqs[playerIdx].channelData[k].volTimer--;
|
||||
if (gActiveSeqs[playerIdx].channelData[k].volTimer != 0) {
|
||||
gActiveSeqs[playerIdx].channelData[k].volCur -= gActiveSeqs[playerIdx].channelData[k].volStep;
|
||||
} else {
|
||||
D_8016E750[playerIdx].unk_50[k].unk_00 = D_8016E750[playerIdx].unk_50[k].unk_04;
|
||||
D_8016E750[playerIdx].unk_252 ^= (1 << k);
|
||||
gActiveSeqs[playerIdx].channelData[k].volCur = gActiveSeqs[playerIdx].channelData[k].volTarget;
|
||||
gActiveSeqs[playerIdx].volChannelFlags ^= (1 << k);
|
||||
}
|
||||
// CHAN_UPD_VOL_SCALE (playerIdx = seq, k = chan)
|
||||
Audio_QueueCmdF32(0x01000000 | _SHIFTL(playerIdx, 16, 8) | _SHIFTL(k, 8, 8),
|
||||
D_8016E750[playerIdx].unk_50[k].unk_00);
|
||||
gActiveSeqs[playerIdx].channelData[k].volCur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (D_8016E750[playerIdx].unk_250 != 0) {
|
||||
if (gActiveSeqs[playerIdx].freqScaleChannelFlags != 0) {
|
||||
for (k = 0; k < 0x10; k++) {
|
||||
if (D_8016E750[playerIdx].unk_50[k].unk_1C != 0) {
|
||||
D_8016E750[playerIdx].unk_50[k].unk_1C--;
|
||||
if (D_8016E750[playerIdx].unk_50[k].unk_1C != 0) {
|
||||
D_8016E750[playerIdx].unk_50[k].unk_10 -= D_8016E750[playerIdx].unk_50[k].unk_18;
|
||||
if (gActiveSeqs[playerIdx].channelData[k].freqScaleTimer != 0) {
|
||||
gActiveSeqs[playerIdx].channelData[k].freqScaleTimer--;
|
||||
if (gActiveSeqs[playerIdx].channelData[k].freqScaleTimer != 0) {
|
||||
gActiveSeqs[playerIdx].channelData[k].freqScaleCur -= gActiveSeqs[playerIdx].channelData[k].freqScaleStep;
|
||||
} else {
|
||||
D_8016E750[playerIdx].unk_50[k].unk_10 = D_8016E750[playerIdx].unk_50[k].unk_14;
|
||||
D_8016E750[playerIdx].unk_250 ^= (1 << k);
|
||||
gActiveSeqs[playerIdx].channelData[k].freqScaleCur = gActiveSeqs[playerIdx].channelData[k].freqScaleTarget;
|
||||
gActiveSeqs[playerIdx].freqScaleChannelFlags ^= (1 << k);
|
||||
}
|
||||
// CHAN_UPD_FREQ_SCALE
|
||||
Audio_QueueCmdF32(0x04000000 | _SHIFTL(playerIdx, 16, 8) | _SHIFTL(k, 8, 8),
|
||||
D_8016E750[playerIdx].unk_50[k].unk_10);
|
||||
gActiveSeqs[playerIdx].channelData[k].freqScaleCur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (D_8016E750[playerIdx].unk_4D != 0) {
|
||||
if (gActiveSeqs[playerIdx].setupCmdNum != 0) {
|
||||
if (func_800FA11C(0xF0000000, 0xF0000000) == 0) {
|
||||
D_8016E750[playerIdx].unk_4D = 0;
|
||||
gActiveSeqs[playerIdx].setupCmdNum = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (D_8016E750[playerIdx].unk_4C != 0) {
|
||||
D_8016E750[playerIdx].unk_4C--;
|
||||
if (gActiveSeqs[playerIdx].setupCmdTimer != 0) {
|
||||
gActiveSeqs[playerIdx].setupCmdTimer--;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -609,28 +609,28 @@ void func_800FA3DC(void) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < D_8016E750[playerIdx].unk_4D; j++) {
|
||||
temp_a0 = (D_8016E750[playerIdx].unk_2C[j] & 0x00F00000) >> 20;
|
||||
temp_s1 = (D_8016E750[playerIdx].unk_2C[j] & 0x000F0000) >> 16;
|
||||
temp_s0_3 = (D_8016E750[playerIdx].unk_2C[j] & 0xFF00) >> 8;
|
||||
temp_a3_3 = D_8016E750[playerIdx].unk_2C[j] & 0xFF;
|
||||
for (j = 0; j < gActiveSeqs[playerIdx].setupCmdNum; j++) {
|
||||
temp_a0 = (gActiveSeqs[playerIdx].setupCmd[j] & 0x00F00000) >> 20;
|
||||
temp_s1 = (gActiveSeqs[playerIdx].setupCmd[j] & 0x000F0000) >> 16;
|
||||
temp_s0_3 = (gActiveSeqs[playerIdx].setupCmd[j] & 0xFF00) >> 8;
|
||||
temp_a3_3 = gActiveSeqs[playerIdx].setupCmd[j] & 0xFF;
|
||||
|
||||
switch (temp_a0) {
|
||||
case 0:
|
||||
Audio_SetVolScale(temp_s1, 1, 0x7F, temp_a3_3);
|
||||
break;
|
||||
case 7:
|
||||
if (D_8016E348[playerIdx] == temp_a3_3) {
|
||||
if (sNumSeqRequests[playerIdx] == temp_a3_3) {
|
||||
Audio_SetVolScale(temp_s1, 1, 0x7F, temp_s0_3);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
Audio_SeqCmd3(playerIdx, D_8016E750[playerIdx].unk_254);
|
||||
Audio_SeqCmd3(playerIdx, gActiveSeqs[playerIdx].seqId);
|
||||
break;
|
||||
case 2:
|
||||
Audio_StartSeq(temp_s1, 1, D_8016E750[temp_s1].unk_254);
|
||||
D_8016E750[temp_s1].fadeVolUpdate = 1;
|
||||
D_8016E750[temp_s1].volScales[1] = 0x7F;
|
||||
Audio_StartSeq(temp_s1, 1, gActiveSeqs[temp_s1].seqId);
|
||||
gActiveSeqs[temp_s1].fadeVolUpdate = 1;
|
||||
gActiveSeqs[temp_s1].volScales[1] = 0x7F;
|
||||
break;
|
||||
case 3:
|
||||
Audio_SeqCmdB30(temp_s1, temp_s0_3, temp_a3_3);
|
||||
@@ -639,13 +639,13 @@ void func_800FA3DC(void) {
|
||||
Audio_SeqCmdB40(temp_s1, temp_a3_3, 0);
|
||||
break;
|
||||
case 5:
|
||||
temp_v1 = D_8016E750[playerIdx].unk_2C[j] & 0xFFFF;
|
||||
Audio_StartSeq(temp_s1, D_8016E750[temp_s1].unk_4E, temp_v1);
|
||||
temp_v1 = gActiveSeqs[playerIdx].setupCmd[j] & 0xFFFF;
|
||||
Audio_StartSeq(temp_s1, gActiveSeqs[temp_s1].setupFadeTimer, temp_v1);
|
||||
Audio_SetVolScale(temp_s1, 1, 0x7F, 0);
|
||||
D_8016E750[temp_s1].unk_4E = 0;
|
||||
gActiveSeqs[temp_s1].setupFadeTimer = 0;
|
||||
break;
|
||||
case 6:
|
||||
D_8016E750[playerIdx].unk_4E = temp_s0_3;
|
||||
gActiveSeqs[playerIdx].setupFadeTimer = temp_s0_3;
|
||||
break;
|
||||
case 8:
|
||||
Audio_SetVolScale(temp_s1, temp_s0_3, 0x7F, temp_a3_3);
|
||||
@@ -662,7 +662,7 @@ void func_800FA3DC(void) {
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
temp_v1 = D_8016E750[playerIdx].unk_2C[j] & 0xFFFF;
|
||||
temp_v1 = gActiveSeqs[playerIdx].setupCmd[j] & 0xFFFF;
|
||||
Audio_SeqCmdA(temp_s1, temp_v1);
|
||||
break;
|
||||
case 10:
|
||||
@@ -671,7 +671,7 @@ void func_800FA3DC(void) {
|
||||
}
|
||||
}
|
||||
|
||||
D_8016E750[playerIdx].unk_4D = 0;
|
||||
gActiveSeqs[playerIdx].setupCmdNum = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -695,26 +695,29 @@ u8 func_800FAD34(void) {
|
||||
return D_80133418;
|
||||
}
|
||||
|
||||
void func_800FADF8(void) {
|
||||
u8 playerIdx, j;
|
||||
void Audio_ResetActiveSequences(void) {
|
||||
u8 seqPlayerIndex;
|
||||
u8 scaleIndex;
|
||||
|
||||
for (playerIdx = 0; playerIdx < 4; playerIdx++) {
|
||||
D_8016E348[playerIdx] = 0;
|
||||
D_8016E750[playerIdx].unk_254 = NA_BGM_DISABLED;
|
||||
D_8016E750[playerIdx].unk_256 = NA_BGM_DISABLED;
|
||||
D_8016E750[playerIdx].unk_28 = 0;
|
||||
D_8016E750[playerIdx].unk_18 = 0;
|
||||
D_8016E750[playerIdx].unk_14 = 0;
|
||||
D_8016E750[playerIdx].unk_258 = 0;
|
||||
D_8016E750[playerIdx].unk_4D = 0;
|
||||
D_8016E750[playerIdx].unk_4E = 0;
|
||||
D_8016E750[playerIdx].unk_250 = 0;
|
||||
D_8016E750[playerIdx].unk_252 = 0;
|
||||
for (j = 0; j < 4; j++) {
|
||||
D_8016E750[playerIdx].volScales[j] = 0x7F;
|
||||
for (seqPlayerIndex = 0; seqPlayerIndex < 4; seqPlayerIndex++) {
|
||||
sNumSeqRequests[seqPlayerIndex] = 0;
|
||||
|
||||
gActiveSeqs[seqPlayerIndex].seqId = NA_BGM_DISABLED;
|
||||
gActiveSeqs[seqPlayerIndex].prevSeqId = NA_BGM_DISABLED;
|
||||
gActiveSeqs[seqPlayerIndex].tempoTimer = 0;
|
||||
gActiveSeqs[seqPlayerIndex].tempoOriginal = 0;
|
||||
gActiveSeqs[seqPlayerIndex].tempoCmd = 0;
|
||||
gActiveSeqs[seqPlayerIndex].channelPortMask = 0;
|
||||
gActiveSeqs[seqPlayerIndex].setupCmdNum = 0;
|
||||
gActiveSeqs[seqPlayerIndex].setupFadeTimer = 0;
|
||||
gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags = 0;
|
||||
gActiveSeqs[seqPlayerIndex].volChannelFlags = 0;
|
||||
for (scaleIndex = 0; scaleIndex < 4; scaleIndex++) {
|
||||
gActiveSeqs[seqPlayerIndex].volScales[scaleIndex] = 0x7F;
|
||||
}
|
||||
D_8016E750[playerIdx].volFadeTimer = 1;
|
||||
D_8016E750[playerIdx].fadeVolUpdate = 1;
|
||||
|
||||
gActiveSeqs[seqPlayerIndex].volFadeTimer = 1;
|
||||
gActiveSeqs[seqPlayerIndex].fadeVolUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -722,12 +725,12 @@ void func_800FAEB4(void) {
|
||||
u8 playerIdx, j;
|
||||
|
||||
for (playerIdx = 0; playerIdx < 4; playerIdx++) {
|
||||
D_8016E750[playerIdx].volCur = 1.0f;
|
||||
D_8016E750[playerIdx].unk_0C = 0;
|
||||
D_8016E750[playerIdx].fadeVolUpdate = 0;
|
||||
gActiveSeqs[playerIdx].volCur = 1.0f;
|
||||
gActiveSeqs[playerIdx].volTimer = 0;
|
||||
gActiveSeqs[playerIdx].fadeVolUpdate = 0;
|
||||
for (j = 0; j < 4; j++) {
|
||||
D_8016E750[playerIdx].volScales[j] = 0x7F;
|
||||
gActiveSeqs[playerIdx].volScales[j] = 0x7F;
|
||||
}
|
||||
}
|
||||
func_800FADF8();
|
||||
Audio_ResetActiveSequences();
|
||||
}
|
||||
|
||||
+80
-20
@@ -662,26 +662,32 @@ s32 Flags_GetSwitch(PlayState* play, s32 flag) {
|
||||
* Sets current scene switch flag.
|
||||
*/
|
||||
void Flags_SetSwitch(PlayState* play, s32 flag) {
|
||||
lusprintf(__FILE__, __LINE__, 2, "Switch Flag Set - %#x", flag);
|
||||
u8 previouslyOff = !Flags_GetSwitch(play, flag);
|
||||
if (flag < 0x20) {
|
||||
play->actorCtx.flags.swch |= (1 << flag);
|
||||
} else {
|
||||
play->actorCtx.flags.tempSwch |= (1 << (flag - 0x20));
|
||||
}
|
||||
GameInteractor_ExecuteOnSceneFlagSet(play->sceneNum, FLAG_SCENE_SWITCH, flag);
|
||||
if (previouslyOff) {
|
||||
LUSLOG_INFO("Switch Flag Set - %#x", flag);
|
||||
GameInteractor_ExecuteOnSceneFlagSet(play->sceneNum, FLAG_SCENE_SWITCH, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets current scene switch flag.
|
||||
*/
|
||||
void Flags_UnsetSwitch(PlayState* play, s32 flag) {
|
||||
lusprintf(__FILE__, __LINE__, 2, "Switch Flag Unset - %#x", flag);
|
||||
u8 previouslyOn = Flags_GetSwitch(play, flag);
|
||||
if (flag < 0x20) {
|
||||
play->actorCtx.flags.swch &= ~(1 << flag);
|
||||
} else {
|
||||
play->actorCtx.flags.tempSwch &= ~(1 << (flag - 0x20));
|
||||
}
|
||||
GameInteractor_ExecuteOnSceneFlagUnset(play->sceneNum, FLAG_SCENE_SWITCH, flag);
|
||||
if (previouslyOn) {
|
||||
LUSLOG_INFO("Switch Flag Unset - %#x", flag);
|
||||
GameInteractor_ExecuteOnSceneFlagUnset(play->sceneNum, FLAG_SCENE_SWITCH, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -728,9 +734,12 @@ s32 Flags_GetTreasure(PlayState* play, s32 flag) {
|
||||
* Sets current scene chest flag.
|
||||
*/
|
||||
void Flags_SetTreasure(PlayState* play, s32 flag) {
|
||||
lusprintf(__FILE__, __LINE__, 2, "Treasure Flag Set - %#x", flag);
|
||||
u8 previouslyOff = !Flags_GetTreasure(play, flag);
|
||||
play->actorCtx.flags.chest |= (1 << flag);
|
||||
GameInteractor_ExecuteOnSceneFlagSet(play->sceneNum, FLAG_SCENE_TREASURE, flag);
|
||||
if (previouslyOff) {
|
||||
LUSLOG_INFO("Treasure Flag Set - %#x", flag);
|
||||
GameInteractor_ExecuteOnSceneFlagSet(play->sceneNum, FLAG_SCENE_TREASURE, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -744,16 +753,24 @@ s32 Flags_GetClear(PlayState* play, s32 flag) {
|
||||
* Sets current scene clear flag.
|
||||
*/
|
||||
void Flags_SetClear(PlayState* play, s32 flag) {
|
||||
u8 previouslyOff = !Flags_GetClear(play, flag);
|
||||
play->actorCtx.flags.clear |= (1 << flag);
|
||||
GameInteractor_ExecuteOnSceneFlagSet(play->sceneNum, FLAG_SCENE_CLEAR, flag);
|
||||
if (previouslyOff) {
|
||||
LUSLOG_INFO("Clear Flag Set - %#x", flag);
|
||||
GameInteractor_ExecuteOnSceneFlagSet(play->sceneNum, FLAG_SCENE_CLEAR, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets current scene clear flag.
|
||||
*/
|
||||
void Flags_UnsetClear(PlayState* play, s32 flag) {
|
||||
u8 previouslyOn = Flags_GetClear(play, flag);
|
||||
play->actorCtx.flags.clear &= ~(1 << flag);
|
||||
GameInteractor_ExecuteOnSceneFlagUnset(play->sceneNum, FLAG_SCENE_CLEAR, flag);
|
||||
if (previouslyOn) {
|
||||
LUSLOG_INFO("Clear Flag Unset - %#x", flag);
|
||||
GameInteractor_ExecuteOnSceneFlagUnset(play->sceneNum, FLAG_SCENE_CLEAR, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -792,7 +809,7 @@ s32 Flags_GetCollectible(PlayState* play, s32 flag) {
|
||||
* Sets current scene collectible flag.
|
||||
*/
|
||||
void Flags_SetCollectible(PlayState* play, s32 flag) {
|
||||
lusprintf(__FILE__, __LINE__, 2, "Collectible Flag Set - %#x", flag);
|
||||
u8 previouslyOff = !Flags_GetCollectible(play, flag);
|
||||
if (flag != 0) {
|
||||
if (flag < 0x20) {
|
||||
play->actorCtx.flags.collect |= (1 << flag);
|
||||
@@ -800,7 +817,10 @@ void Flags_SetCollectible(PlayState* play, s32 flag) {
|
||||
play->actorCtx.flags.tempCollect |= (1 << (flag - 0x20));
|
||||
}
|
||||
}
|
||||
GameInteractor_ExecuteOnSceneFlagSet(play->sceneNum, FLAG_SCENE_COLLECTIBLE, flag);
|
||||
if (previouslyOff) {
|
||||
LUSLOG_INFO("Collectible Flag Set - %#x", flag);
|
||||
GameInteractor_ExecuteOnSceneFlagSet(play->sceneNum, FLAG_SCENE_COLLECTIBLE, flag);
|
||||
}
|
||||
}
|
||||
|
||||
void func_8002CDE4(PlayState* play, TitleCardContext* titleCtx) {
|
||||
@@ -4723,16 +4743,24 @@ s32 Flags_GetEventChkInf(s32 flag) {
|
||||
* Sets "eventChkInf" flag.
|
||||
*/
|
||||
void Flags_SetEventChkInf(s32 flag) {
|
||||
u8 previouslyOff = !Flags_GetEventChkInf(flag);
|
||||
gSaveContext.eventChkInf[flag >> 4] |= (1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_EVENT_CHECK_INF, flag);
|
||||
if (previouslyOff) {
|
||||
LUSLOG_INFO("EventChkInf Flag Set - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_EVENT_CHECK_INF, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets "eventChkInf" flag.
|
||||
*/
|
||||
void Flags_UnsetEventChkInf(s32 flag) {
|
||||
u8 previouslyOn = Flags_GetEventChkInf(flag);
|
||||
gSaveContext.eventChkInf[flag >> 4] &= ~(1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_EVENT_CHECK_INF, flag);
|
||||
if (previouslyOn) {
|
||||
LUSLOG_INFO("EventChkInf Flag Unset - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_EVENT_CHECK_INF, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4746,16 +4774,24 @@ s32 Flags_GetItemGetInf(s32 flag) {
|
||||
* Sets "itemGetInf" flag.
|
||||
*/
|
||||
void Flags_SetItemGetInf(s32 flag) {
|
||||
u8 previouslyOff = !Flags_GetItemGetInf(flag);
|
||||
gSaveContext.itemGetInf[flag >> 4] |= (1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_ITEM_GET_INF, flag);
|
||||
if (previouslyOff) {
|
||||
LUSLOG_INFO("ItemGetInf Flag Set - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_ITEM_GET_INF, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets "itemGetInf" flag.
|
||||
*/
|
||||
void Flags_UnsetItemGetInf(s32 flag) {
|
||||
u8 previouslyOn = Flags_GetItemGetInf(flag);
|
||||
gSaveContext.itemGetInf[flag >> 4] &= ~(1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_ITEM_GET_INF, flag);
|
||||
if (previouslyOn) {
|
||||
LUSLOG_INFO("ItemGetInf Flag Unset - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_ITEM_GET_INF, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4769,16 +4805,24 @@ s32 Flags_GetInfTable(s32 flag) {
|
||||
* Sets "infTable" flag.
|
||||
*/
|
||||
void Flags_SetInfTable(s32 flag) {
|
||||
u8 previouslyOff = !Flags_GetInfTable(flag);
|
||||
gSaveContext.infTable[flag >> 4] |= (1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_INF_TABLE, flag);
|
||||
if (previouslyOff) {
|
||||
LUSLOG_INFO("InfTable Flag Set - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_INF_TABLE, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets "infTable" flag.
|
||||
*/
|
||||
void Flags_UnsetInfTable(s32 flag) {
|
||||
u8 previouslyOn = Flags_GetInfTable(flag);
|
||||
gSaveContext.infTable[flag >> 4] &= ~(1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_INF_TABLE, flag);
|
||||
if (previouslyOn) {
|
||||
LUSLOG_INFO("InfTable Flag Unset - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_INF_TABLE, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4792,16 +4836,24 @@ s32 Flags_GetEventInf(s32 flag) {
|
||||
* Sets "eventInf" flag.
|
||||
*/
|
||||
void Flags_SetEventInf(s32 flag) {
|
||||
u8 previouslyOff = !Flags_GetEventInf(flag);
|
||||
gSaveContext.eventInf[flag >> 4] |= (1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_EVENT_INF, flag);
|
||||
if (previouslyOff) {
|
||||
LUSLOG_INFO("EventInf Flag Set - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_EVENT_INF, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets "eventInf" flag.
|
||||
*/
|
||||
void Flags_UnsetEventInf(s32 flag) {
|
||||
u8 previouslyOn = Flags_GetEventInf(flag);
|
||||
gSaveContext.eventInf[flag >> 4] &= ~(1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_EVENT_INF, flag);
|
||||
if (previouslyOn) {
|
||||
LUSLOG_INFO("EventInf Flag Unset - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_EVENT_INF, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4815,16 +4867,24 @@ s32 Flags_GetRandomizerInf(RandomizerInf flag) {
|
||||
* Sets "randomizerInf" flag.
|
||||
*/
|
||||
void Flags_SetRandomizerInf(RandomizerInf flag) {
|
||||
u8 previouslyOff = !Flags_GetRandomizerInf(flag);
|
||||
gSaveContext.randomizerInf[flag >> 4] |= (1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_RANDOMIZER_INF, flag);
|
||||
if (previouslyOff) {
|
||||
LUSLOG_INFO("RandomizerInf Flag Set - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagSet(FLAG_RANDOMIZER_INF, flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets "randomizerInf" flag.
|
||||
*/
|
||||
void Flags_UnsetRandomizerInf(RandomizerInf flag) {
|
||||
u8 previouslyOn = Flags_GetRandomizerInf(flag);
|
||||
gSaveContext.randomizerInf[flag >> 4] &= ~(1 << (flag & 0xF));
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_RANDOMIZER_INF, flag);
|
||||
if (previouslyOn) {
|
||||
LUSLOG_INFO("RandomizerInf Flag Unset - %#x", flag);
|
||||
GameInteractor_ExecuteOnFlagUnset(FLAG_RANDOMIZER_INF, flag);
|
||||
}
|
||||
}
|
||||
|
||||
u32 func_80035BFC(PlayState* play, s16 arg1) {
|
||||
|
||||
@@ -18,9 +18,10 @@ s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input) {
|
||||
frameAdvCtx->enabled = !frameAdvCtx->enabled;
|
||||
}
|
||||
|
||||
if (!frameAdvCtx->enabled || (CHECK_BTN_ALL(input->cur.button, BTN_Z) &&
|
||||
if (!frameAdvCtx->enabled || CVarGetInteger("gFrameAdvance", 0) || (CHECK_BTN_ALL(input->cur.button, BTN_Z) &&
|
||||
(CHECK_BTN_ALL(input->press.button, BTN_R) ||
|
||||
(CHECK_BTN_ALL(input->cur.button, BTN_R) && (++frameAdvCtx->timer >= 9))))) {
|
||||
CVarClear("gFrameAdvance");
|
||||
frameAdvCtx->timer = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ void func_80AB6D08(EnNiw* this, PlayState* play) {
|
||||
}
|
||||
|
||||
this->path = 1;
|
||||
this->timer5 = 80;
|
||||
this->timer5 = 80 * CVarGetInteger("gCuccoStayDurationMultiplier", 1);
|
||||
this->actor.speedXZ = 0.0f;
|
||||
this->actor.velocity.y = 4.0f;
|
||||
} else {
|
||||
|
||||
@@ -14,8 +14,6 @@ u8 gAmmoItems[] = {
|
||||
static s16 sEquipState = 0;
|
||||
static s16 sEquipAnimTimer = 0;
|
||||
static s16 sEquipMoveTimer = 10;
|
||||
bool gSelectingMask;
|
||||
bool gSelectingAdultTrade;
|
||||
|
||||
static s16 sAmmoVtxOffset[] = {
|
||||
0, 2, 4, 6, 99, 99, 8, 99, 10, 99, 99, 99, 99, 99, 12,
|
||||
@@ -87,6 +85,10 @@ void KaleidoScope_SetItemCursorVtx(PauseContext* pauseCtx) {
|
||||
KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_ITEM] * 4, pauseCtx->itemVtx);
|
||||
}
|
||||
|
||||
#pragma region Item Cycling
|
||||
|
||||
s8 gCurrentItemCyclingSlot;
|
||||
|
||||
// Vertices for the extra items
|
||||
static Vtx sCycleExtraItemVtx[] = {
|
||||
// Left Item
|
||||
@@ -127,9 +129,11 @@ static Vtx sCycleAButtonVtx[] = {
|
||||
static sSlotCycleActiveAnimTimer[24] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
// Renders a left and/or right item for any item slot that can support cycling
|
||||
void KaleidoScope_DrawItemCycleExtras(PlayState* play, u8 slot, u8 isCycling, u8 canCycle, u8 leftItem, u8 rightItem) {
|
||||
void KaleidoScope_DrawItemCycleExtras(PlayState* play, u8 slot, u8 canCycle, u8 leftItem, u8 rightItem) {
|
||||
PauseContext* pauseCtx = &play->pauseCtx;
|
||||
|
||||
u8 isCycling = gCurrentItemCyclingSlot == slot;
|
||||
|
||||
OPEN_DISPS(play->state.gfxCtx);
|
||||
|
||||
// Update active cycling animation timer
|
||||
@@ -208,10 +212,20 @@ void KaleidoScope_DrawItemCycleExtras(PlayState* play, u8 slot, u8 isCycling, u8
|
||||
gSPVertex(POLY_KAL_DISP++, sCycleExtraItemVtx, 8, 0);
|
||||
|
||||
if (showLeftItem) {
|
||||
if (!CHECK_AGE_REQ_ITEM(leftItem)) {
|
||||
gDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255);
|
||||
gSPGrayscale(POLY_KAL_DISP++, true);
|
||||
}
|
||||
KaleidoScope_DrawQuadTextureRGBA32(play->state.gfxCtx, gItemIcons[leftItem], 32, 32, 0);
|
||||
gSPGrayscale(POLY_KAL_DISP++, false);
|
||||
}
|
||||
if (showRightItem) {
|
||||
if (!CHECK_AGE_REQ_ITEM(rightItem)) {
|
||||
gDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255);
|
||||
gSPGrayscale(POLY_KAL_DISP++, true);
|
||||
}
|
||||
KaleidoScope_DrawQuadTextureRGBA32(play->state.gfxCtx, gItemIcons[rightItem], 32, 32, 4);
|
||||
gSPGrayscale(POLY_KAL_DISP++, false);
|
||||
}
|
||||
|
||||
Matrix_Pop();
|
||||
@@ -220,6 +234,155 @@ void KaleidoScope_DrawItemCycleExtras(PlayState* play, u8 slot, u8 isCycling, u8
|
||||
CLOSE_DISPS(play->state.gfxCtx);
|
||||
}
|
||||
|
||||
void KaleidoScope_HandleItemCycleExtras(PlayState* play, u8 slot, bool canCycle, u8 leftItem, u8 rightItem, bool replaceCButtons) {
|
||||
Input* input = &play->state.input[0];
|
||||
PauseContext* pauseCtx = &play->pauseCtx;
|
||||
bool dpad = (CVarGetInteger("gDpadPause", 0) && !CHECK_BTN_ALL(input->cur.button, BTN_CUP));
|
||||
u8 slotItem = gSaveContext.inventory.items[slot];
|
||||
u8 hasLeftItem = leftItem != ITEM_NONE && slotItem != leftItem;
|
||||
u8 hasRightItem = rightItem != ITEM_NONE && slotItem != rightItem && leftItem != rightItem;
|
||||
|
||||
if (
|
||||
canCycle &&
|
||||
pauseCtx->cursorSlot[PAUSE_ITEM] == slot &&
|
||||
CHECK_BTN_ALL(input->press.button, BTN_A) &&
|
||||
(hasLeftItem || hasRightItem)
|
||||
) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
gCurrentItemCyclingSlot = gCurrentItemCyclingSlot == slot ? -1 : slot;
|
||||
}
|
||||
if (gCurrentItemCyclingSlot == slot) {
|
||||
pauseCtx->cursorColorSet = 8;
|
||||
if ((pauseCtx->stickRelX > 30 || pauseCtx->stickRelY > 30) ||
|
||||
dpad && CHECK_BTN_ANY(input->press.button, BTN_DRIGHT | BTN_DUP)) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
if (replaceCButtons) {
|
||||
for (int i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) {
|
||||
if (gSaveContext.equips.buttonItems[i] == gSaveContext.inventory.items[slot]) {
|
||||
if (CHECK_AGE_REQ_ITEM(rightItem)) {
|
||||
gSaveContext.equips.buttonItems[i] = rightItem;
|
||||
Interface_LoadItemIcon1(play, i);
|
||||
} else {
|
||||
gSaveContext.equips.buttonItems[i] = ITEM_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
gSaveContext.inventory.items[slot] = rightItem;
|
||||
} else if ((pauseCtx->stickRelX < -30 || pauseCtx->stickRelY < -30) ||
|
||||
dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT | BTN_DDOWN)) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
if (replaceCButtons) {
|
||||
for (int i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) {
|
||||
if (gSaveContext.equips.buttonItems[i] == gSaveContext.inventory.items[slot]) {
|
||||
if (CHECK_AGE_REQ_ITEM(leftItem)) {
|
||||
gSaveContext.equips.buttonItems[i] = leftItem;
|
||||
Interface_LoadItemIcon1(play, i);
|
||||
} else {
|
||||
gSaveContext.equips.buttonItems[i] = ITEM_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
gSaveContext.inventory.items[slot] = leftItem;
|
||||
}
|
||||
gCurrentItemCyclingSlot = pauseCtx->cursorSlot[PAUSE_ITEM] == slot ? slot : -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool CanMaskSelect() {
|
||||
// only allow mask select when:
|
||||
// the shop is open:
|
||||
// * zelda's letter check: Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_ZELDAS_LETTER)
|
||||
// * kak gate check: Flags_GetInfTable(INFTABLE_SHOWED_ZELDAS_LETTER_TO_GATE_GUARD)
|
||||
// and the mask quest is complete: Flags_GetEventChkInf(EVENTCHKINF_PAID_BACK_BUNNY_HOOD_FEE)
|
||||
return CVarGetInteger("gMaskSelect", 0) &&
|
||||
Flags_GetEventChkInf(EVENTCHKINF_PAID_BACK_BUNNY_HOOD_FEE) &&
|
||||
Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_ZELDAS_LETTER) &&
|
||||
Flags_GetInfTable(INFTABLE_SHOWED_ZELDAS_LETTER_TO_GATE_GUARD);
|
||||
}
|
||||
|
||||
void KaleidoScope_HandleItemCycles(PlayState* play) {
|
||||
//handle the mask select
|
||||
KaleidoScope_HandleItemCycleExtras(
|
||||
play,
|
||||
SLOT_TRADE_CHILD,
|
||||
CanMaskSelect(),
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) <= ITEM_MASK_KEATON || INV_CONTENT(ITEM_TRADE_CHILD) > ITEM_MASK_TRUTH ?
|
||||
ITEM_MASK_TRUTH :
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) - 1,
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) >= ITEM_MASK_TRUTH || INV_CONTENT(ITEM_TRADE_CHILD) < ITEM_MASK_KEATON ?
|
||||
ITEM_MASK_KEATON :
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) + 1,
|
||||
true
|
||||
);
|
||||
|
||||
//the slot age requirement for the child trade slot has to be updated
|
||||
//in case it currently holds the bunny hood
|
||||
//to allow adult link to wear it if the setting is enabled
|
||||
gSlotAgeReqs[SLOT_TRADE_CHILD] =
|
||||
(
|
||||
((CVarGetInteger("gMMBunnyHood", BUNNY_HOOD_VANILLA) != BUNNY_HOOD_VANILLA) && CVarGetInteger("gAdultBunnyHood", 0)) ||
|
||||
CVarGetInteger("gTimelessEquipment", 0)
|
||||
) &&
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_MASK_BUNNY
|
||||
? AGE_REQ_NONE
|
||||
: AGE_REQ_CHILD;
|
||||
|
||||
//also update the age requirement for the bunny hood itself
|
||||
gItemAgeReqs[ITEM_MASK_BUNNY] =
|
||||
((CVarGetInteger("gMMBunnyHood", BUNNY_HOOD_VANILLA) != BUNNY_HOOD_VANILLA) && CVarGetInteger("gAdultBunnyHood", 0)) ||
|
||||
CVarGetInteger("gTimelessEquipment", 0)
|
||||
? AGE_REQ_NONE
|
||||
: AGE_REQ_CHILD;
|
||||
|
||||
//handle the adult trade select
|
||||
KaleidoScope_HandleItemCycleExtras(
|
||||
play,
|
||||
SLOT_TRADE_ADULT,
|
||||
IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE),
|
||||
Randomizer_GetPrevAdultTradeItem(),
|
||||
Randomizer_GetNextAdultTradeItem(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
void KaleidoScope_DrawItemCycles(PlayState* play) {
|
||||
//draw the mask select
|
||||
KaleidoScope_DrawItemCycleExtras(
|
||||
play,
|
||||
SLOT_TRADE_CHILD,
|
||||
CanMaskSelect(),
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) <= ITEM_MASK_KEATON || INV_CONTENT(ITEM_TRADE_CHILD) > ITEM_MASK_TRUTH ?
|
||||
ITEM_MASK_TRUTH :
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) - 1,
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) >= ITEM_MASK_TRUTH || INV_CONTENT(ITEM_TRADE_CHILD) < ITEM_MASK_KEATON ?
|
||||
ITEM_MASK_KEATON :
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) + 1
|
||||
);
|
||||
|
||||
//draw the adult trade select
|
||||
KaleidoScope_DrawItemCycleExtras(
|
||||
play,
|
||||
SLOT_TRADE_ADULT,
|
||||
IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE),
|
||||
Randomizer_GetPrevAdultTradeItem(),
|
||||
Randomizer_GetNextAdultTradeItem()
|
||||
);
|
||||
}
|
||||
|
||||
bool IsItemCycling() {
|
||||
return gCurrentItemCyclingSlot != -1;
|
||||
}
|
||||
|
||||
void KaleidoScope_ResetItemCycling() {
|
||||
gCurrentItemCyclingSlot = -1;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
void KaleidoScope_DrawItemSelect(PlayState* play) {
|
||||
static s16 magicArrowEffectsR[] = { 255, 100, 255 };
|
||||
static s16 magicArrowEffectsG[] = { 0, 100, 255 };
|
||||
@@ -240,16 +403,6 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
|
||||
bool pauseAnyCursor = (CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_RANDO_ONLY && IS_RANDO) ||
|
||||
(CVarGetInteger("gPauseAnyCursor", 0) == PAUSE_ANY_CURSOR_ALWAYS_ON);
|
||||
|
||||
// only allow mask select when:
|
||||
// the shop is open:
|
||||
// * zelda's letter check: Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_ZELDAS_LETTER)
|
||||
// * kak gate check: Flags_GetInfTable(INFTABLE_SHOWED_ZELDAS_LETTER_TO_GATE_GUARD)
|
||||
// and the mask quest is complete: Flags_GetEventChkInf(EVENTCHKINF_PAID_BACK_BUNNY_HOOD_FEE)
|
||||
bool canMaskSelect = CVarGetInteger("gMaskSelect", 0) &&
|
||||
Flags_GetEventChkInf(EVENTCHKINF_PAID_BACK_BUNNY_HOOD_FEE) &&
|
||||
Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_ZELDAS_LETTER) &&
|
||||
Flags_GetInfTable(INFTABLE_SHOWED_ZELDAS_LETTER_TO_GATE_GUARD);
|
||||
|
||||
OPEN_DISPS(play->state.gfxCtx);
|
||||
|
||||
Gfx_SetupDL_42Opa(play->state.gfxCtx);
|
||||
@@ -260,7 +413,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
|
||||
pauseCtx->nameColorSet = 0;
|
||||
|
||||
if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM)) {
|
||||
moveCursorResult = 0 || gSelectingMask || gSelectingAdultTrade;
|
||||
moveCursorResult = 0 || IsItemCycling();
|
||||
oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM];
|
||||
|
||||
cursorItem = pauseCtx->cursorItem[PAUSE_ITEM];
|
||||
@@ -434,7 +587,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
|
||||
if (pauseCtx->cursorSpecialPos == 0) {
|
||||
if (cursorItem != PAUSE_ITEM_NONE) {
|
||||
if ((ABS(pauseCtx->stickRelY) > 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
|
||||
moveCursorResult = 0 || gSelectingMask || gSelectingAdultTrade;
|
||||
moveCursorResult = 0 || IsItemCycling();
|
||||
|
||||
cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM];
|
||||
cursorY = pauseCtx->cursorY[PAUSE_ITEM];
|
||||
@@ -499,68 +652,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
|
||||
KaleidoScope_SetCursorVtx(pauseCtx, index, pauseCtx->itemVtx);
|
||||
|
||||
if ((pauseCtx->debugState == 0) && (pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) {
|
||||
if (canMaskSelect && cursorSlot == SLOT_TRADE_CHILD && CHECK_BTN_ALL(input->press.button, BTN_A)) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
gSelectingMask = !gSelectingMask;
|
||||
}
|
||||
if (gSelectingMask) {
|
||||
pauseCtx->cursorColorSet = 8;
|
||||
if (((pauseCtx->stickRelX > 30 || pauseCtx->stickRelY > 30) ||
|
||||
dpad && CHECK_BTN_ANY(input->press.button, BTN_DRIGHT | BTN_DUP)) &&
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) < ITEM_MASK_TRUTH) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
++INV_CONTENT(ITEM_TRADE_CHILD);
|
||||
} else if (((pauseCtx->stickRelX < -30 || pauseCtx->stickRelY < -30) ||
|
||||
dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT | BTN_DDOWN)) &&
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) > ITEM_MASK_KEATON) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
--INV_CONTENT(ITEM_TRADE_CHILD);
|
||||
} else if ((pauseCtx->stickRelX < -30 || pauseCtx->stickRelX > 30 || pauseCtx->stickRelY < -30 || pauseCtx->stickRelY > 30) ||
|
||||
dpad && CHECK_BTN_ANY(input->press.button, BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT)) {
|
||||
// Change to keaton mask if no mask is in child trade slot. Catches Zelda's letter and bottle duping over this slot.
|
||||
if (INV_CONTENT(ITEM_TRADE_CHILD) < ITEM_MASK_KEATON || INV_CONTENT(ITEM_TRADE_CHILD) > ITEM_MASK_TRUTH) {
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) = ITEM_MASK_KEATON;
|
||||
} else {
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) ^= ITEM_MASK_KEATON ^ ITEM_MASK_TRUTH;
|
||||
}
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
}
|
||||
for (uint16_t cSlotIndex = 0; cSlotIndex < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); cSlotIndex++) {
|
||||
if (gSaveContext.equips.cButtonSlots[cSlotIndex] == SLOT_TRADE_CHILD) {
|
||||
if (!LINK_IS_ADULT || CVarGetInteger("gTimelessEquipment", 0)) {
|
||||
gSaveContext.equips.buttonItems[cSlotIndex+1] = INV_CONTENT(ITEM_TRADE_CHILD);
|
||||
} else if (INV_CONTENT(ITEM_TRADE_CHILD) != gSaveContext.equips.buttonItems[cSlotIndex+1]) {
|
||||
gSaveContext.equips.cButtonSlots[cSlotIndex] = SLOT_NONE;
|
||||
gSaveContext.equips.buttonItems[cSlotIndex+1] = ITEM_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
gSelectingMask = cursorSlot == SLOT_TRADE_CHILD;
|
||||
|
||||
gSlotAgeReqs[SLOT_TRADE_CHILD] = gItemAgeReqs[ITEM_MASK_BUNNY] =
|
||||
((((CVarGetInteger("gMMBunnyHood", BUNNY_HOOD_VANILLA) != BUNNY_HOOD_VANILLA) && CVarGetInteger("gAdultBunnyHood", 0)) || CVarGetInteger("gTimelessEquipment", 0)) &&
|
||||
INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_MASK_BUNNY)
|
||||
? AGE_REQ_NONE
|
||||
: AGE_REQ_CHILD;
|
||||
}
|
||||
if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE) &&
|
||||
cursorSlot == SLOT_TRADE_ADULT && CHECK_BTN_ALL(input->press.button, BTN_A)) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
gSelectingAdultTrade = !gSelectingAdultTrade;
|
||||
}
|
||||
if (gSelectingAdultTrade) {
|
||||
pauseCtx->cursorColorSet = 8;
|
||||
if (((pauseCtx->stickRelX > 30 || pauseCtx->stickRelY > 30) ||
|
||||
dpad && CHECK_BTN_ANY(input->press.button, BTN_DRIGHT | BTN_DUP))) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
Inventory_ReplaceItem(play, INV_CONTENT(ITEM_TRADE_ADULT), Randomizer_GetNextAdultTradeItem());
|
||||
} else if (((pauseCtx->stickRelX < -30 || pauseCtx->stickRelY < -30) ||
|
||||
dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT | BTN_DDOWN))) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
Inventory_ReplaceItem(play, INV_CONTENT(ITEM_TRADE_ADULT), Randomizer_GetPrevAdultTradeItem());
|
||||
}
|
||||
gSelectingAdultTrade = cursorSlot == SLOT_TRADE_ADULT;
|
||||
}
|
||||
KaleidoScope_HandleItemCycles(play);
|
||||
u16 buttonsToCheck = BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT;
|
||||
if (CVarGetInteger("gDpadEquips", 0) && (!CVarGetInteger("gDpadPause", 0) || CHECK_BTN_ALL(input->cur.button, BTN_CUP))) {
|
||||
buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT;
|
||||
@@ -678,15 +770,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
|
||||
}
|
||||
}
|
||||
|
||||
// Adult trade item cycle
|
||||
KaleidoScope_DrawItemCycleExtras(play, SLOT_TRADE_ADULT, gSelectingAdultTrade,
|
||||
IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE),
|
||||
Randomizer_GetPrevAdultTradeItem(), Randomizer_GetNextAdultTradeItem());
|
||||
// Child mask item cycle (mimics the left/right item behavior from the cycling logic above)
|
||||
u8 childTradeItem = INV_CONTENT(ITEM_TRADE_CHILD);
|
||||
KaleidoScope_DrawItemCycleExtras(play, SLOT_TRADE_CHILD, gSelectingMask, canMaskSelect,
|
||||
childTradeItem <= ITEM_MASK_KEATON ? ITEM_MASK_TRUTH : childTradeItem - 1,
|
||||
childTradeItem >= ITEM_MASK_TRUTH ? ITEM_MASK_KEATON : childTradeItem + 1);
|
||||
KaleidoScope_DrawItemCycles(play);
|
||||
|
||||
CLOSE_DISPS(play->state.gfxCtx);
|
||||
}
|
||||
@@ -694,8 +778,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
|
||||
void KaleidoScope_SetupItemEquip(PlayState* play, u16 item, u16 slot, s16 animX, s16 animY) {
|
||||
Input* input = &play->state.input[0];
|
||||
PauseContext* pauseCtx = &play->pauseCtx;
|
||||
gSelectingMask = false;
|
||||
gSelectingAdultTrade = false;
|
||||
KaleidoScope_ResetItemCycling();
|
||||
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) {
|
||||
pauseCtx->equipTargetCBtn = 0;
|
||||
@@ -1079,9 +1162,4 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) {
|
||||
pauseCtx->equipAnimAlpha = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KaleidoScope_ResetTradeSelect() {
|
||||
gSelectingMask = false;
|
||||
gSelectingAdultTrade = false;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ extern u8 gEquipAgeReqs[][4];
|
||||
extern u8 gSlotAgeReqs[];
|
||||
extern u8 gItemAgeReqs[];
|
||||
extern u8 gAreaGsFlags[];
|
||||
extern bool gSelectingMask;
|
||||
|
||||
#define MAP_48x85_TEX_WIDTH 48
|
||||
#define MAP_48x85_TEX_HEIGHT 85
|
||||
@@ -50,6 +49,6 @@ void PauseMapMark_Draw(PlayState* play);
|
||||
|
||||
void KaleidoScope_UpdateCursorSize(PauseContext* pauseCtx);
|
||||
|
||||
void KaleidoScope_ResetTradeSelect();
|
||||
void KaleidoScope_ResetItemCycling();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1008,7 +1008,7 @@ void KaleidoScope_SetDefaultCursor(PlayState* play) {
|
||||
PauseContext* pauseCtx = &play->pauseCtx;
|
||||
s16 s;
|
||||
s16 i;
|
||||
gSelectingMask = false;
|
||||
KaleidoScope_ResetItemCycling();
|
||||
|
||||
switch (pauseCtx->pageIndex) {
|
||||
case PAUSE_ITEM:
|
||||
@@ -1042,7 +1042,6 @@ void KaleidoScope_SetDefaultCursor(PlayState* play) {
|
||||
void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) {
|
||||
pauseCtx->unk_1E4 = 1;
|
||||
pauseCtx->unk_1EA = 0;
|
||||
gSelectingMask = false;
|
||||
|
||||
if (!pt) {
|
||||
pauseCtx->mode = pauseCtx->pageIndex * 2 + 1;
|
||||
@@ -1074,7 +1073,7 @@ void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) {
|
||||
gSaveContext.unk_13EA = 0;
|
||||
Interface_ChangeAlpha(50);
|
||||
|
||||
KaleidoScope_ResetTradeSelect();
|
||||
KaleidoScope_ResetItemCycling();
|
||||
}
|
||||
|
||||
void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) {
|
||||
@@ -3857,7 +3856,7 @@ void KaleidoScope_Update(PlayState* play)
|
||||
}
|
||||
}
|
||||
|
||||
KaleidoScope_ResetTradeSelect();
|
||||
KaleidoScope_ResetItemCycling();
|
||||
|
||||
pauseCtx->state = 4;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user