Merge branch 'HarbourMasters:develop' into develop

This commit is contained in:
TAKStation 2022-04-11 13:18:27 +04:30 committed by GitHub
commit ddbf214094
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 1060 additions and 341 deletions

View file

@ -78,6 +78,10 @@ static void ExporterProgramEnd()
auto fileData = File::ReadAllBytes(item); auto fileData = File::ReadAllBytes(item);
otrArchive->AddFile(StringHelper::Split(item, "Extract\\")[1], (uintptr_t)fileData.data(), fileData.size()); otrArchive->AddFile(StringHelper::Split(item, "Extract\\")[1], (uintptr_t)fileData.data(), fileData.size());
} }
otrArchive->AddFile("Audiobank", (uintptr_t)Globals::Instance->GetBaseromFile("Audiobank").data(), Globals::Instance->GetBaseromFile("Audiobank").size());
otrArchive->AddFile("Audioseq", (uintptr_t)Globals::Instance->GetBaseromFile("Audioseq").data(), Globals::Instance->GetBaseromFile("Audioseq").size());
otrArchive->AddFile("Audiotable", (uintptr_t)Globals::Instance->GetBaseromFile("Audiotable").data(), Globals::Instance->GetBaseromFile("Audiotable").size());
} }
} }

View file

@ -4,21 +4,11 @@ import argparse, json, os, signal, time, sys, shutil
from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError
import shutil import shutil
def SignalHandler(sig, frame): def BuildOTR(xmlPath):
print(f'Signal {sig} received. Aborting...')
mainAbort.set()
# Don't exit immediately to update the extracted assets file.
def BuildOTR():
shutil.copyfile("baserom/Audiobank", "Extract/Audiobank")
shutil.copyfile("baserom/Audioseq", "Extract/Audioseq")
shutil.copyfile("baserom/Audiotable", "Extract/Audiotable")
shutil.copytree("assets", "Extract/assets") shutil.copytree("assets", "Extract/assets")
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out" execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out"
execStr += " ed -i %s -b baserom.z64 -fl CFG\\filelists -o placeholder -osf placeholder -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath)
execStr += " botr -se OTR"
print(execStr) print(execStr)
exitValue = os.system(execStr) exitValue = os.system(execStr)
@ -28,52 +18,12 @@ def BuildOTR():
print("Aborting...", file=os.sys.stderr) print("Aborting...", file=os.sys.stderr)
print("\n") print("\n")
def ExtractFile(xmlPath, outputPath, outputSourcePath):
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out"
execStr += " e -eh -i %s -b baserom/ -o %s -osf %s -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, outputPath, outputSourcePath)
if "overlays" in xmlPath:
execStr += " --static"
print(execStr)
exitValue = os.system(execStr)
#exitValue = 0
if exitValue != 0:
print("\n")
print("Error when extracting from file " + xmlPath, file=os.sys.stderr)
print("Aborting...", file=os.sys.stderr)
print("\n")
def ExtractFunc(fullPath):
*pathList, xmlName = fullPath.split(os.sep)
objectName = os.path.splitext(xmlName)[0]
outPath = os.path.join("..\\soh\\assets\\", *pathList[5:], objectName)
os.makedirs(outPath, exist_ok=True)
outSourcePath = outPath
ExtractFile(fullPath, outPath, outSourcePath)
def initializeWorker(abort, test):
global globalAbort
globalAbort = abort
def main(): def main():
parser = argparse.ArgumentParser(description="baserom asset extractor") parser = argparse.ArgumentParser(description="baserom asset extractor")
parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep")
parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones.", action="store_true")
parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true")
parser.add_argument("-v", "--version", help="Sets game version.") parser.add_argument("-v", "--version", help="Sets game version.")
args = parser.parse_args() args = parser.parse_args()
global mainAbort # TODO: Read from makerom file to automatically determine game version
mainAbort = Event()
manager = Manager()
signal.signal(signal.SIGINT, SignalHandler)
extractedAssetsTracker = manager.dict()
xmlVer = "GC_NMQ_D" xmlVer = "GC_NMQ_D"
if (args.version == "gc_pal_nmpq"): if (args.version == "gc_pal_nmpq"):
@ -81,45 +31,10 @@ def main():
elif (args.version == "dbg_mq"): elif (args.version == "dbg_mq"):
xmlVer = "GC_MQ_D" xmlVer = "GC_MQ_D"
asset_path = args.single if (os.path.exists("Extract")):
if asset_path is not None:
fullPath = os.path.join("..\\soh\\assets", "xml", asset_path + ".xml")
if not os.path.exists(fullPath):
print(f"Error. File {fullPath} doesn't exists.", file=os.sys.stderr)
exit(1)
ExtractFunc(fullPath)
else:
extract_text_path = "assets/text/message_data.h"
if os.path.isfile(extract_text_path):
extract_text_path = None
extract_staff_text_path = "assets/text/message_data_staff.h"
if os.path.isfile(extract_staff_text_path):
extract_staff_text_path = None
xmlFiles = []
for currentPath, _, files in os.walk(os.path.join("..\\soh\\assets\\xml\\", xmlVer)):
for file in files:
fullPath = os.path.join(currentPath, file)
if file.endswith(".xml"):
xmlFiles.append(fullPath)
try:
numCores = 2
print("Extracting assets with " + str(numCores) + " CPU cores.")
with Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, 0)) as p:
p.map(ExtractFunc, xmlFiles)
except Exception as e:
print("Warning: Multiprocessing exception ocurred.", file=os.sys.stderr)
print("Disabling mutliprocessing.", file=os.sys.stderr)
initializeWorker(mainAbort, 0)
for singlePath in xmlFiles:
ExtractFunc(singlePath)
BuildOTR()
shutil.rmtree("Extract") shutil.rmtree("Extract")
BuildOTR("..\\soh\\assets\\xml\\" + xmlVer + "\\")
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View file

@ -0,0 +1,125 @@
#!/usr/bin/env python3
import argparse, json, os, signal, time, sys, shutil
from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError
import shutil
def SignalHandler(sig, frame):
print(f'Signal {sig} received. Aborting...')
mainAbort.set()
# Don't exit immediately to update the extracted assets file.
def BuildOTR():
shutil.copyfile("baserom/Audiobank", "Extract/Audiobank")
shutil.copyfile("baserom/Audioseq", "Extract/Audioseq")
shutil.copyfile("baserom/Audiotable", "Extract/Audiotable")
shutil.copytree("assets", "Extract/assets")
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out"
execStr += " botr -se OTR"
print(execStr)
exitValue = os.system(execStr)
if exitValue != 0:
print("\n")
print("Error when building the OTR file...", file=os.sys.stderr)
print("Aborting...", file=os.sys.stderr)
print("\n")
def ExtractFile(xmlPath, outputPath, outputSourcePath):
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out"
execStr += " e -eh -i %s -b baserom/ -o %s -osf %s -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, outputPath, outputSourcePath)
if "overlays" in xmlPath:
execStr += " --static"
print(execStr)
exitValue = os.system(execStr)
#exitValue = 0
if exitValue != 0:
print("\n")
print("Error when extracting from file " + xmlPath, file=os.sys.stderr)
print("Aborting...", file=os.sys.stderr)
print("\n")
def ExtractFunc(fullPath):
*pathList, xmlName = fullPath.split(os.sep)
objectName = os.path.splitext(xmlName)[0]
outPath = os.path.join("..\\soh\\assets\\", *pathList[5:], objectName)
os.makedirs(outPath, exist_ok=True)
outSourcePath = outPath
ExtractFile(fullPath, outPath, outSourcePath)
def initializeWorker(abort, test):
global globalAbort
globalAbort = abort
def main():
parser = argparse.ArgumentParser(description="baserom asset extractor")
parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep")
parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones.", action="store_true")
parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true")
parser.add_argument("-v", "--version", help="Sets game version.")
args = parser.parse_args()
global mainAbort
mainAbort = Event()
manager = Manager()
signal.signal(signal.SIGINT, SignalHandler)
extractedAssetsTracker = manager.dict()
xmlVer = "GC_NMQ_D"
if (args.version == "gc_pal_nmpq"):
xmlVer = "GC_NMQ_PAL_F"
elif (args.version == "dbg_mq"):
xmlVer = "GC_MQ_D"
asset_path = args.single
if asset_path is not None:
fullPath = os.path.join("..\\soh\\assets", "xml", asset_path + ".xml")
if not os.path.exists(fullPath):
print(f"Error. File {fullPath} doesn't exists.", file=os.sys.stderr)
exit(1)
ExtractFunc(fullPath)
else:
extract_text_path = "assets/text/message_data.h"
if os.path.isfile(extract_text_path):
extract_text_path = None
extract_staff_text_path = "assets/text/message_data_staff.h"
if os.path.isfile(extract_staff_text_path):
extract_staff_text_path = None
xmlFiles = []
for currentPath, _, files in os.walk(os.path.join("..\\soh\\assets\\xml\\", xmlVer)):
for file in files:
fullPath = os.path.join(currentPath, file)
if file.endswith(".xml"):
xmlFiles.append(fullPath)
try:
numCores = 2
print("Extracting assets with " + str(numCores) + " CPU cores.")
with Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, 0)) as p:
p.map(ExtractFunc, xmlFiles)
except Exception as e:
print("Warning: Multiprocessing exception ocurred.", file=os.sys.stderr)
print("Disabling mutliprocessing.", file=os.sys.stderr)
initializeWorker(mainAbort, 0)
for singlePath in xmlFiles:
ExtractFunc(singlePath)
BuildOTR()
shutil.rmtree("Extract")
if __name__ == "__main__":
main()

View file

@ -87,10 +87,11 @@ void ExtractRom()
if (MoonUtils::exists("Extract")) MoonUtils::rm("Extract"); if (MoonUtils::exists("Extract")) MoonUtils::rm("Extract");
MoonUtils::mkdir("Extract"); MoonUtils::mkdir("Extract");
MoonUtils::copy("tmp/baserom/Audiobank", "Extract/Audiobank"); //MoonUtils::copy("tmp/baserom/Audiobank", "Extract/Audiobank");
MoonUtils::copy("tmp/baserom/Audioseq", "Extract/Audioseq"); //MoonUtils::copy("tmp/baserom/Audioseq", "Extract/Audioseq");
MoonUtils::copy("tmp/baserom/Audiotable", "Extract/Audiotable"); //MoonUtils::copy("tmp/baserom/Audiotable", "Extract/Audiotable");
MoonUtils::copy("tmp/baserom/version", "Extract/version"); //MoonUtils::copy("tmp/baserom/version", "Extract/version");
MoonUtils::write("Extract/version", (char*)&version.crc, sizeof(version.crc));
MoonUtils::copy("assets/game/", "Extract/assets/"); MoonUtils::copy("assets/game/", "Extract/assets/");

View file

@ -83,7 +83,6 @@ void startWorker(RomVersion version) {
Util::write("tmp/baserom/version", (char*)&version.crc, sizeof(version.crc)); Util::write("tmp/baserom/version", (char*)&version.crc, sizeof(version.crc));
if (oldExtractMode) if (oldExtractMode)
{ {
std::vector<std::string> files; std::vector<std::string> files;

View file

@ -387,18 +387,6 @@ int main(int argc, char* argv[])
{ {
BuildAssetBlob(Globals::Instance->inputPath, Globals::Instance->outputPath); BuildAssetBlob(Globals::Instance->inputPath, Globals::Instance->outputPath);
} }
/*
else if (fileMode == ZFileMode::BuildOverlay)
{
ZOverlay* overlay =
ZOverlay::FromBuild(Path::GetDirectoryName(Globals::Instance->inputPath),
Path::GetDirectoryName(Globals::Instance->cfgPath));
if (overlay != nullptr)
File::WriteAllText(Globals::Instance->outputPath.string(),
overlay->GetSourceOutputCode(""));
}
*/
if (exporterSet != nullptr && exporterSet->endProgramFunc != nullptr) if (exporterSet != nullptr && exporterSet->endProgramFunc != nullptr)
exporterSet->endProgramFunc(); exporterSet->endProgramFunc();

View file

@ -823,6 +823,32 @@ void ZFile::GenerateSourceHeaderFiles()
if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory)
File::WriteAllText(headerFilename, formatter.GetOutput()); File::WriteAllText(headerFilename, formatter.GetOutput());
else if (Globals::Instance->sourceOutputPath != "")
{
std::string xmlPath = xmlFilePath.string();
xmlPath = StringHelper::Replace(xmlPath, "\\", "/");
auto pathList = StringHelper::Split(xmlPath, "/");
std::string outPath = "";
for (int i = 0; i < 3; i++)
outPath += pathList[i] + "/";
for (int i = 5; i < pathList.size(); i++)
{
if (i == pathList.size() - 1)
{
outPath += Path::GetFileNameWithoutExtension(pathList[i]) + "/";
outPath += outName.string() + ".h";
}
else
outPath += pathList[i];
if (i < pathList.size() - 1)
outPath += "/";
}
File::WriteAllText(outPath, formatter.GetOutput());
}
} }
std::string ZFile::GetHeaderInclude() const std::string ZFile::GetHeaderInclude() const

View file

@ -5,16 +5,16 @@
std::map<std::string, CVar*> cvars; std::map<std::string, CVar*> cvars;
CVar* CVar_GetVar(char* name) { CVar* CVar_GetVar(const char* name) {
std::string key(name); std::string key(name);
return cvars.contains(key) ? cvars[key] : nullptr; return cvars.contains(key) ? cvars[key] : nullptr;
} }
extern "C" CVar* CVar_Get(char* name) { extern "C" CVar* CVar_Get(const char* name) {
return CVar_GetVar(name); return CVar_GetVar(name);
} }
extern "C" s32 CVar_GetS32(char* name, s32 defaultValue) { extern "C" s32 CVar_GetS32(const char* name, s32 defaultValue) {
CVar* cvar = CVar_Get(name); CVar* cvar = CVar_Get(name);
if (cvar != nullptr) { if (cvar != nullptr) {
@ -25,7 +25,7 @@ extern "C" s32 CVar_GetS32(char* name, s32 defaultValue) {
return defaultValue; return defaultValue;
} }
extern "C" float CVar_GetFloat(char* name, float defaultValue) { extern "C" float CVar_GetFloat(const char* name, float defaultValue) {
CVar* cvar = CVar_Get(name); CVar* cvar = CVar_Get(name);
if (cvar != nullptr) { if (cvar != nullptr) {
@ -36,7 +36,7 @@ extern "C" float CVar_GetFloat(char* name, float defaultValue) {
return defaultValue; return defaultValue;
} }
extern "C" char* CVar_GetString(char* name, char* defaultValue) { extern "C" char* CVar_GetString(const char* name, char* defaultValue) {
CVar* cvar = CVar_Get(name); CVar* cvar = CVar_Get(name);
if (cvar != nullptr) { if (cvar != nullptr) {
@ -47,7 +47,7 @@ extern "C" char* CVar_GetString(char* name, char* defaultValue) {
return defaultValue; return defaultValue;
} }
extern "C" void CVar_SetS32(char* name, s32 value) { extern "C" void CVar_SetS32(const char* name, s32 value) {
CVar* cvar = CVar_Get(name); CVar* cvar = CVar_Get(name);
if (!cvar) { if (!cvar) {
cvar = new CVar; cvar = new CVar;
@ -57,7 +57,7 @@ extern "C" void CVar_SetS32(char* name, s32 value) {
cvar->value.valueS32 = value; cvar->value.valueS32 = value;
} }
void CVar_SetFloat(char* name, float value) { void CVar_SetFloat(const char* name, float value) {
CVar* cvar = CVar_Get(name); CVar* cvar = CVar_Get(name);
if (!cvar) { if (!cvar) {
cvar = new CVar; cvar = new CVar;
@ -67,7 +67,7 @@ void CVar_SetFloat(char* name, float value) {
cvar->value.valueFloat = value; cvar->value.valueFloat = value;
} }
void CVar_SetString(char* name, char* value) { void CVar_SetString(const char* name, char* value) {
CVar* cvar = CVar_Get(name); CVar* cvar = CVar_Get(name);
if (!cvar) { if (!cvar) {
cvar = new CVar; cvar = new CVar;
@ -78,21 +78,21 @@ void CVar_SetString(char* name, char* value) {
} }
extern "C" void CVar_RegisterS32(char* name, s32 defaultValue) { extern "C" void CVar_RegisterS32(const char* name, s32 defaultValue) {
CVar* cvar = CVar_Get(name); CVar* cvar = CVar_Get(name);
if (cvar == nullptr) if (cvar == nullptr)
CVar_SetS32(name, defaultValue); CVar_SetS32(name, defaultValue);
} }
extern "C" void CVar_RegisterFloat(char* name, float defaultValue) { extern "C" void CVar_RegisterFloat(const char* name, float defaultValue) {
CVar* cvar = CVar_Get(name); CVar* cvar = CVar_Get(name);
if (cvar == nullptr) if (cvar == nullptr)
CVar_SetFloat(name, defaultValue); CVar_SetFloat(name, defaultValue);
} }
extern "C" void CVar_RegisterString(char* name, char* defaultValue) { extern "C" void CVar_RegisterString(const char* name, char* defaultValue) {
CVar* cvar = CVar_Get(name); CVar* cvar = CVar_Get(name);
if (cvar == nullptr) if (cvar == nullptr)

View file

@ -23,15 +23,15 @@ extern "C"
//#include <ultra64.h> //#include <ultra64.h>
CVar* CVar_Get(char* name); CVar* CVar_Get(const char* name);
s32 CVar_GetS32(char* name, s32 defaultValue); s32 CVar_GetS32(const char* name, s32 defaultValue);
float CVar_GetFloat(char* name, float defaultValue); float CVar_GetFloat(const char* name, float defaultValue);
char* CVar_GetString(char* name, char* defaultValue); char* CVar_GetString(const char* name, char* defaultValue);
void CVar_SetS32(char* name, s32 value); void CVar_SetS32(const char* name, s32 value);
void CVar_RegisterS32(char* name, s32 defaultValue); void CVar_RegisterS32(const char* name, s32 defaultValue);
void CVar_RegisterFloat(char* name, float defaultValue); void CVar_RegisterFloat(const char* name, float defaultValue);
void CVar_RegisterString(char* name, char* defaultValue); void CVar_RegisterString(const char* name, char* defaultValue);
#ifdef __cplusplus #ifdef __cplusplus
}; };
@ -42,8 +42,8 @@ void CVar_RegisterString(char* name, char* defaultValue);
#include <string> #include <string>
extern std::map<std::string, CVar*> cvars; extern std::map<std::string, CVar*> cvars;
CVar* CVar_GetVar(char* name); CVar* CVar_GetVar(const char* name);
void CVar_SetFloat(char* name, float value); void CVar_SetFloat(const char* name, float value);
void CVar_SetString(char* name, char* value); void CVar_SetString(const char* name, char* value);
#endif #endif
#endif #endif

View file

@ -50,73 +50,76 @@ namespace Game {
// Enhancements // Enhancements
Settings.enhancements.fast_text = stob(Conf[EnhancementSection]["fast_text"]); Settings.enhancements.fast_text = stob(Conf[EnhancementSection]["fast_text"]);
CVar_SetS32(const_cast<char*>("gFastText"), Settings.enhancements.fast_text); CVar_SetS32("gFastText", Settings.enhancements.fast_text);
Settings.enhancements.disable_lod = stob(Conf[EnhancementSection]["disable_lod"]); Settings.enhancements.disable_lod = stob(Conf[EnhancementSection]["disable_lod"]);
CVar_SetS32(const_cast<char*>("gDisableLOD"), Settings.enhancements.disable_lod); CVar_SetS32("gDisableLOD", Settings.enhancements.disable_lod);
Settings.enhancements.animated_pause_menu = stob(Conf[EnhancementSection]["animated_pause_menu"]); Settings.enhancements.animated_pause_menu = stob(Conf[EnhancementSection]["animated_pause_menu"]);
CVar_SetS32(const_cast<char*>("gPauseLiveLink"), Settings.enhancements.animated_pause_menu); CVar_SetS32("gPauseLiveLink", Settings.enhancements.animated_pause_menu);
Settings.enhancements.minimal_ui = stob(Conf[EnhancementSection]["minimal_ui"]); Settings.enhancements.minimal_ui = stob(Conf[EnhancementSection]["minimal_ui"]);
CVar_SetS32(const_cast<char*>("gMinimalUI"), Settings.enhancements.minimal_ui); CVar_SetS32("gMinimalUI", Settings.enhancements.minimal_ui);
// Audio // Audio
Settings.audio.master = Ship::stof(Conf[AudioSection]["master"]); Settings.audio.master = Ship::stof(Conf[AudioSection]["master"]);
CVar_SetFloat(const_cast<char*>("gGameMasterVolume"), Settings.audio.master); CVar_SetFloat("gGameMasterVolume", Settings.audio.master);
Settings.audio.music_main = Ship::stof(Conf[AudioSection]["music_main"]); Settings.audio.music_main = Ship::stof(Conf[AudioSection]["music_main"]);
CVar_SetFloat(const_cast<char*>("gMainMusicVolume"), Settings.audio.music_main); CVar_SetFloat("gMainMusicVolume", Settings.audio.music_main);
Settings.audio.music_sub = Ship::stof(Conf[AudioSection]["music_sub"]); Settings.audio.music_sub = Ship::stof(Conf[AudioSection]["music_sub"]);
CVar_SetFloat(const_cast<char*>("gSubMusicVolume"), Settings.audio.music_sub); CVar_SetFloat("gSubMusicVolume", Settings.audio.music_sub);
Settings.audio.sfx = Ship::stof(Conf[AudioSection]["sfx"]); Settings.audio.sfx = Ship::stof(Conf[AudioSection]["sfx"]);
CVar_SetFloat(const_cast<char*>("gSFXMusicVolume"), Settings.audio.sfx); CVar_SetFloat("gSFXMusicVolume", Settings.audio.sfx);
Settings.audio.fanfare = Ship::stof(Conf[AudioSection]["fanfare"]); Settings.audio.fanfare = Ship::stof(Conf[AudioSection]["fanfare"]);
CVar_SetFloat(const_cast<char*>("gFanfareVolume"), Settings.audio.fanfare); CVar_SetFloat("gFanfareVolume", Settings.audio.fanfare);
// Controllers // Controllers
Settings.controller.gyro_sensitivity = Ship::stof(Conf[ControllerSection]["gyro_sensitivity"]); Settings.controller.gyro_sensitivity = Ship::stof(Conf[ControllerSection]["gyro_sensitivity"]);
CVar_SetFloat(const_cast<char*>("gGyroSensitivity"), Settings.controller.gyro_sensitivity); CVar_SetFloat("gGyroSensitivity", Settings.controller.gyro_sensitivity);
Settings.controller.rumble_strength = Ship::stof(Conf[ControllerSection]["rumble_strength"]); Settings.controller.rumble_strength = Ship::stof(Conf[ControllerSection]["rumble_strength"]);
CVar_SetFloat(const_cast<char*>("gRumbleStrength"), Settings.controller.rumble_strength); CVar_SetFloat("gRumbleStrength", Settings.controller.rumble_strength);
Settings.controller.input_scale = Ship::stof(Conf[ControllerSection]["input_scale"]); Settings.controller.input_scale = Ship::stof(Conf[ControllerSection]["input_scale"]);
CVar_SetFloat(const_cast<char*>("gInputScale"), Settings.controller.input_scale); CVar_SetFloat("gInputScale", Settings.controller.input_scale);
Settings.controller.input_enabled = stob(Conf[ControllerSection]["input_enabled"]); Settings.controller.input_enabled = stob(Conf[ControllerSection]["input_enabled"]);
CVar_SetS32(const_cast<char*>("gInputEnabled"), Settings.controller.input_enabled); CVar_SetS32("gInputEnabled", Settings.controller.input_enabled);
Settings.controller.dpad_pause_name = stob(Conf[ControllerSection]["dpad_pause_name"]);
CVar_SetS32("gDpadPauseName", Settings.controller.dpad_pause_name);
// Cheats // Cheats
Settings.cheats.debug_mode = stob(Conf[CheatSection]["debug_mode"]); Settings.cheats.debug_mode = stob(Conf[CheatSection]["debug_mode"]);
CVar_SetS32(const_cast<char*>("gDebugEnabled"), Settings.cheats.debug_mode); CVar_SetS32("gDebugEnabled", Settings.cheats.debug_mode);
Settings.cheats.infinite_money = stob(Conf[CheatSection]["infinite_money"]); Settings.cheats.infinite_money = stob(Conf[CheatSection]["infinite_money"]);
CVar_SetS32(const_cast<char*>("gInfiniteMoney"), Settings.cheats.infinite_money); CVar_SetS32("gInfiniteMoney", Settings.cheats.infinite_money);
Settings.cheats.infinite_health = stob(Conf[CheatSection]["infinite_health"]); Settings.cheats.infinite_health = stob(Conf[CheatSection]["infinite_health"]);
CVar_SetS32(const_cast<char*>("gInfiniteHealth"), Settings.cheats.infinite_health); CVar_SetS32("gInfiniteHealth", Settings.cheats.infinite_health);
Settings.cheats.infinite_ammo = stob(Conf[CheatSection]["infinite_ammo"]); Settings.cheats.infinite_ammo = stob(Conf[CheatSection]["infinite_ammo"]);
CVar_SetS32(const_cast<char*>("gInfiniteAmmo"), Settings.cheats.infinite_ammo); CVar_SetS32("gInfiniteAmmo", Settings.cheats.infinite_ammo);
Settings.cheats.infinite_magic = stob(Conf[CheatSection]["infinite_magic"]); Settings.cheats.infinite_magic = stob(Conf[CheatSection]["infinite_magic"]);
CVar_SetS32(const_cast<char*>("gInfiniteMagic"), Settings.cheats.infinite_magic); CVar_SetS32("gInfiniteMagic", Settings.cheats.infinite_magic);
Settings.cheats.no_clip = stob(Conf[CheatSection]["no_clip"]); Settings.cheats.no_clip = stob(Conf[CheatSection]["no_clip"]);
CVar_SetS32(const_cast<char*>("gNoClip"), Settings.cheats.no_clip); CVar_SetS32("gNoClip", Settings.cheats.no_clip);
Settings.cheats.climb_everything = stob(Conf[CheatSection]["climb_everything"]); Settings.cheats.climb_everything = stob(Conf[CheatSection]["climb_everything"]);
CVar_SetS32(const_cast<char*>("gClimbEverything"), Settings.cheats.climb_everything); CVar_SetS32("gClimbEverything", Settings.cheats.climb_everything);
Settings.cheats.moon_jump_on_l = stob(Conf[CheatSection]["moon_jump_on_l"]); Settings.cheats.moon_jump_on_l = stob(Conf[CheatSection]["moon_jump_on_l"]);
CVar_SetS32(const_cast<char*>("gMoonJumpOnL"), Settings.cheats.moon_jump_on_l); CVar_SetS32("gMoonJumpOnL", Settings.cheats.moon_jump_on_l);
Settings.cheats.super_tunic = stob(Conf[CheatSection]["super_tunic"]); Settings.cheats.super_tunic = stob(Conf[CheatSection]["super_tunic"]);
CVar_SetS32(const_cast<char*>("gSuperTunic"), Settings.cheats.super_tunic); CVar_SetS32("gSuperTunic", Settings.cheats.super_tunic);
UpdateAudio(); UpdateAudio();
} }
@ -149,6 +152,7 @@ namespace Game {
Conf[ControllerSection]["rumble_strength"] = std::to_string(Settings.controller.rumble_strength); Conf[ControllerSection]["rumble_strength"] = std::to_string(Settings.controller.rumble_strength);
Conf[ControllerSection]["input_scale"] = std::to_string(Settings.controller.input_scale); Conf[ControllerSection]["input_scale"] = std::to_string(Settings.controller.input_scale);
Conf[ControllerSection]["input_enabled"] = std::to_string(Settings.controller.input_enabled); Conf[ControllerSection]["input_enabled"] = std::to_string(Settings.controller.input_enabled);
Conf[ControllerSection]["dpad_pause_name"] = std::to_string(Settings.controller.dpad_pause_name);
// Cheats // Cheats
Conf[CheatSection]["debug_mode"] = std::to_string(Settings.cheats.debug_mode); Conf[CheatSection]["debug_mode"] = std::to_string(Settings.cheats.debug_mode);

View file

@ -34,6 +34,7 @@ struct SoHConfigType {
float gyroDriftX = 0.0f; float gyroDriftX = 0.0f;
float gyroDriftY = 0.0f; float gyroDriftY = 0.0f;
bool input_enabled = false; bool input_enabled = false;
bool dpad_pause_name = false;
} controller; } controller;
// Cheats // Cheats

View file

@ -531,8 +531,8 @@ static struct ShaderProgram *gfx_d3d11_create_and_load_new_shader(uint64_t shade
blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
blend_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; blend_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
blend_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; blend_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
blend_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; blend_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
} else { } else {
@ -977,8 +977,8 @@ uint16_t gfx_d3d11_get_pixel_depth_old(float x, float y) {
} // namespace } // namespace
void* SohImGui::GetTextureByID(int id) { ImTextureID SohImGui::GetTextureByID(int id) {
return d3d.textures[id].resource_view.Get(); return impl.backend == Backend::DX11 ? d3d.textures[id].resource_view.Get() : reinterpret_cast<ImTextureID>(id);
} }
struct GfxRenderingAPI gfx_direct3d11_api = { struct GfxRenderingAPI gfx_direct3d11_api = {

View file

@ -92,7 +92,7 @@ void Console::Update() {
} }
for (auto [key, var] : BindingToggle) { for (auto [key, var] : BindingToggle) {
if (ImGui::IsKeyPressed(key)) { if (ImGui::IsKeyPressed(key)) {
CVar* cvar = CVar_GetVar(const_cast<char*>(var.c_str())); CVar* cvar = CVar_GetVar(var.c_str());
Dispatch("set " + var + " " + std::to_string(cvar == nullptr ? 0 : !static_cast<bool>(cvar->value.valueS32))); Dispatch("set " + var + " " + std::to_string(cvar == nullptr ? 0 : !static_cast<bool>(cvar->value.valueS32)));
} }
} }

View file

@ -1,6 +1,7 @@
#include "SohImGuiImpl.h" #include "SohImGuiImpl.h"
#include <iostream> #include <iostream>
#include <map>
#include <utility> #include <utility>
#include "Archive.h" #include "Archive.h"
@ -14,9 +15,11 @@
#include "TextureMod.h" #include "TextureMod.h"
#include "Window.h" #include "Window.h"
#include "Cvar.h" #include "Cvar.h"
#include "Texture.h"
#include "../Fast3D/gfx_pc.h" #include "../Fast3D/gfx_pc.h"
#include "Lib/stb/stb_image.h" #include "Lib/stb/stb_image.h"
#include "Lib/Fast3D/gfx_rendering_api.h" #include "Lib/Fast3D/gfx_rendering_api.h"
#include "Lib/spdlog/include/spdlog/common.h"
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#ifdef ENABLE_OPENGL #ifdef ENABLE_OPENGL
@ -51,6 +54,9 @@ namespace SohImGui {
bool p_open = false; bool p_open = false;
bool needs_save = false; bool needs_save = false;
std::map<std::string, std::vector<std::string>> windowCategories;
std::map<std::string, CustomWindow> customWindows;
void ImGuiWMInit() { void ImGuiWMInit() {
switch (impl.backend) { switch (impl.backend) {
case Backend::SDL: case Backend::SDL:
@ -153,7 +159,7 @@ namespace SohImGui {
} }
} }
void LoadTexture(std::string name, std::string path) { void LoadTexture(const std::string& name, const std::string& path) {
GfxRenderingAPI* api = gfx_get_current_rendering_api(); GfxRenderingAPI* api = gfx_get_current_rendering_api();
const auto res = GlobalCtx2::GetInstance()->GetResourceManager()->LoadFile(normalize(path)); const auto res = GlobalCtx2::GetInstance()->GetResourceManager()->LoadFile(normalize(path));
@ -173,6 +179,25 @@ namespace SohImGui {
stbi_image_free(img_data); stbi_image_free(img_data);
} }
void LoadResource(const std::string& name, const std::string& path) {
GfxRenderingAPI* api = gfx_get_current_rendering_api();
const auto res = static_cast<Ship::Texture*>(GlobalCtx2::GetInstance()->GetResourceManager()->LoadResource(normalize(path)).get());
if (res->texType != Ship::TextureType::RGBA32bpp) {
// TODO convert other image types
SPDLOG_WARN("SohImGui::LoadResource: Attempting to load unsupporting image type %s", path.c_str());
return;
}
const auto asset = new GameAsset{ api->new_texture() };
api->select_texture(0, asset->textureId);
api->set_sampler_parameters(0, false, 0, 0);
api->upload_texture(res->imageData, res->width, res->height);
DefaultAssets[name] = asset;
}
void Init(WindowImpl window_impl) { void Init(WindowImpl window_impl) {
impl = window_impl; impl = window_impl;
Game::LoadSettings(); Game::LoadSettings();
@ -219,13 +244,13 @@ namespace SohImGui {
ImGuiProcessEvent(event); ImGuiProcessEvent(event);
} }
#define BindButton(btn, status) ImGui::Image(impl.backend == Backend::DX11 ? GetTextureByID(DefaultAssets[btn]->textureId) : (ImTextureID)(DefaultAssets[btn]->textureId), ImVec2(16.0f * scale, 16.0f * scale), ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, (status) ? 255 : 0)); #define BindButton(btn, status) ImGui::Image(GetTextureByID(DefaultAssets[btn]->textureId), ImVec2(16.0f * scale, 16.0f * scale), ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, (status) ? 255 : 0));
void BindAudioSlider(const char* name, const char* key, float* value, SeqPlayers playerId) { void BindAudioSlider(const char* name, const char* key, float* value, SeqPlayers playerId) {
ImGui::Text(name, static_cast<int>(100 * *(value))); ImGui::Text(name, static_cast<int>(100 * *(value)));
if (ImGui::SliderFloat((std::string("##") + key).c_str(), value, 0.0f, 1.0f, "")) { if (ImGui::SliderFloat((std::string("##") + key).c_str(), value, 0.0f, 1.0f, "")) {
const float volume = floorf(*(value) * 100) / 100; const float volume = floorf(*(value) * 100) / 100;
CVar_SetFloat(const_cast<char*>(key), volume); CVar_SetFloat(key, volume);
needs_save = true; needs_save = true;
Game::SetSeqPlayerVolume(playerId, volume); Game::SetSeqPlayerVolume(playerId, volume);
} }
@ -278,7 +303,7 @@ namespace SohImGui {
if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenuBar()) {
if (DefaultAssets.contains("Game_Icon")) { if (DefaultAssets.contains("Game_Icon")) {
ImGui::SetCursorPos(ImVec2(5, 2.5f)); ImGui::SetCursorPos(ImVec2(5, 2.5f));
ImGui::Image(impl.backend == Backend::DX11 ? GetTextureByID(DefaultAssets["Game_Icon"]->textureId) : reinterpret_cast<ImTextureID>(DefaultAssets["Game_Icon"]->textureId), ImVec2(16.0f, 16.0f)); ImGui::Image(GetTextureByID(DefaultAssets["Game_Icon"]->textureId), ImVec2(16.0f, 16.0f));
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPos(ImVec2(25, 0)); ImGui::SetCursorPos(ImVec2(25, 0));
} }
@ -289,7 +314,7 @@ namespace SohImGui {
const float volume = Game::Settings.audio.master; const float volume = Game::Settings.audio.master;
ImGui::Text("Master Volume: %d %%", static_cast<int>(100 * volume)); ImGui::Text("Master Volume: %d %%", static_cast<int>(100 * volume));
if (ImGui::SliderFloat("##Master_Vol", &Game::Settings.audio.master, 0.0f, 1.0f, "")) { if (ImGui::SliderFloat("##Master_Vol", &Game::Settings.audio.master, 0.0f, 1.0f, "")) {
CVar_SetFloat(const_cast<char*>("gGameMasterVolume"), volume); CVar_SetFloat("gGameMasterVolume", volume);
needs_save = true; needs_save = true;
} }
@ -328,6 +353,13 @@ namespace SohImGui {
needs_save = true; needs_save = true;
} }
ImGui::Separator();
if (ImGui::Checkbox("Dpad Support on Pause and File Select", &Game::Settings.controller.dpad_pause_name)) {
CVar_SetS32("gDpadPauseName", Game::Settings.controller.dpad_pause_name);
needs_save = true;
}
ImGui::EndMenu(); ImGui::EndMenu();
} }
@ -337,12 +369,12 @@ namespace SohImGui {
ImGui::Separator(); ImGui::Separator();
if (ImGui::Checkbox("Fast Text", &Game::Settings.enhancements.fast_text)) { if (ImGui::Checkbox("Fast Text", &Game::Settings.enhancements.fast_text)) {
CVar_SetS32(const_cast<char*>("gFastText"), Game::Settings.enhancements.fast_text); CVar_SetS32("gFastText", Game::Settings.enhancements.fast_text);
needs_save = true; needs_save = true;
} }
if (ImGui::Checkbox("Minimal UI", &Game::Settings.enhancements.minimal_ui)) { if (ImGui::Checkbox("Minimal UI", &Game::Settings.enhancements.minimal_ui)) {
CVar_SetS32(const_cast<char*>("gMinimalUI"), Game::Settings.enhancements.minimal_ui); CVar_SetS32("gMinimalUI", Game::Settings.enhancements.minimal_ui);
needs_save = true; needs_save = true;
} }
@ -354,12 +386,12 @@ namespace SohImGui {
} }
if (ImGui::Checkbox("Animated Link in Pause Menu", &Game::Settings.enhancements.animated_pause_menu)) { if (ImGui::Checkbox("Animated Link in Pause Menu", &Game::Settings.enhancements.animated_pause_menu)) {
CVar_SetS32(const_cast<char*>("gPauseLiveLink"), Game::Settings.enhancements.animated_pause_menu); CVar_SetS32("gPauseLiveLink", Game::Settings.enhancements.animated_pause_menu);
needs_save = true; needs_save = true;
} }
if (ImGui::Checkbox("Disable LOD", &Game::Settings.enhancements.disable_lod)) { if (ImGui::Checkbox("Disable LOD", &Game::Settings.enhancements.disable_lod)) {
CVar_SetS32(const_cast<char*>("gDisableLOD"), Game::Settings.enhancements.disable_lod); CVar_SetS32("gDisableLOD", Game::Settings.enhancements.disable_lod);
needs_save = true; needs_save = true;
} }
@ -374,7 +406,7 @@ namespace SohImGui {
ImGui::Separator(); ImGui::Separator();
if (ImGui::Checkbox("Debug Mode", &Game::Settings.cheats.debug_mode)) { if (ImGui::Checkbox("Debug Mode", &Game::Settings.cheats.debug_mode)) {
CVar_SetS32(const_cast<char*>("gDebugEnabled"), Game::Settings.cheats.debug_mode); CVar_SetS32("gDebugEnabled", Game::Settings.cheats.debug_mode);
needs_save = true; needs_save = true;
} }
@ -383,48 +415,57 @@ namespace SohImGui {
if (ImGui::BeginMenu("Cheats")) { if (ImGui::BeginMenu("Cheats")) {
if (ImGui::Checkbox("Infinite Money", &Game::Settings.cheats.infinite_money)) { if (ImGui::Checkbox("Infinite Money", &Game::Settings.cheats.infinite_money)) {
CVar_SetS32(const_cast<char*>("gInfiniteMoney"), Game::Settings.cheats.infinite_money); CVar_SetS32("gInfiniteMoney", Game::Settings.cheats.infinite_money);
needs_save = true; needs_save = true;
} }
if (ImGui::Checkbox("Infinite Health", &Game::Settings.cheats.infinite_health)) { if (ImGui::Checkbox("Infinite Health", &Game::Settings.cheats.infinite_health)) {
CVar_SetS32(const_cast<char*>("gInfiniteHealth"), Game::Settings.cheats.infinite_health); CVar_SetS32("gInfiniteHealth", Game::Settings.cheats.infinite_health);
needs_save = true; needs_save = true;
} }
if (ImGui::Checkbox("Infinite Ammo", &Game::Settings.cheats.infinite_ammo)) { if (ImGui::Checkbox("Infinite Ammo", &Game::Settings.cheats.infinite_ammo)) {
CVar_SetS32(const_cast<char*>("gInfiniteAmmo"), Game::Settings.cheats.infinite_ammo); CVar_SetS32("gInfiniteAmmo", Game::Settings.cheats.infinite_ammo);
needs_save = true; needs_save = true;
} }
if (ImGui::Checkbox("Infinite Magic", &Game::Settings.cheats.infinite_magic)) { if (ImGui::Checkbox("Infinite Magic", &Game::Settings.cheats.infinite_magic)) {
CVar_SetS32(const_cast<char*>("gInfiniteMagic"), Game::Settings.cheats.infinite_magic); CVar_SetS32("gInfiniteMagic", Game::Settings.cheats.infinite_magic);
needs_save = true; needs_save = true;
} }
if (ImGui::Checkbox("No Clip", &Game::Settings.cheats.no_clip)) { if (ImGui::Checkbox("No Clip", &Game::Settings.cheats.no_clip)) {
CVar_SetS32(const_cast<char*>("gNoClip"), Game::Settings.cheats.no_clip); CVar_SetS32("gNoClip", Game::Settings.cheats.no_clip);
needs_save = true; needs_save = true;
} }
if (ImGui::Checkbox("Climb Everything", &Game::Settings.cheats.climb_everything)) { if (ImGui::Checkbox("Climb Everything", &Game::Settings.cheats.climb_everything)) {
CVar_SetS32(const_cast<char*>("gClimbEverything"), Game::Settings.cheats.climb_everything); CVar_SetS32("gClimbEverything", Game::Settings.cheats.climb_everything);
needs_save = true; needs_save = true;
} }
if (ImGui::Checkbox("Moon Jump on L", &Game::Settings.cheats.moon_jump_on_l)) { if (ImGui::Checkbox("Moon Jump on L", &Game::Settings.cheats.moon_jump_on_l)) {
CVar_SetS32(const_cast<char*>("gMoonJumpOnL"), Game::Settings.cheats.moon_jump_on_l); CVar_SetS32("gMoonJumpOnL", Game::Settings.cheats.moon_jump_on_l);
needs_save = true; needs_save = true;
} }
if (ImGui::Checkbox("Super Tunic", &Game::Settings.cheats.super_tunic)) { if (ImGui::Checkbox("Super Tunic", &Game::Settings.cheats.super_tunic)) {
CVar_SetS32(const_cast<char*>("gSuperTunic"), Game::Settings.cheats.super_tunic); CVar_SetS32("gSuperTunic", Game::Settings.cheats.super_tunic);
needs_save = true; needs_save = true;
} }
ImGui::EndMenu(); ImGui::EndMenu();
} }
for (const auto& category : windowCategories) {
if (ImGui::BeginMenu(category.first.c_str())) {
for (const std::string& name : category.second) {
HOOK(ImGui::MenuItem(name.c_str(), nullptr, &customWindows[name].enabled));
}
ImGui::EndMenu();
}
}
ImGui::EndMenuBar(); ImGui::EndMenuBar();
} }
@ -527,6 +568,13 @@ namespace SohImGui {
console->Draw(); console->Draw();
for (auto& windowIter : customWindows) {
CustomWindow& window = windowIter.second;
if (window.drawFunc != nullptr) {
window.drawFunc(window.enabled);
}
}
ImGui::Render(); ImGui::Render();
ImGuiRenderDrawData(ImGui::GetDrawData()); ImGuiRenderDrawData(ImGui::GetDrawData());
if (UseViewports()) { if (UseViewports()) {
@ -538,4 +586,22 @@ namespace SohImGui {
void BindCmd(const std::string& cmd, CommandEntry entry) { void BindCmd(const std::string& cmd, CommandEntry entry) {
console->Commands[cmd] = std::move(entry); console->Commands[cmd] = std::move(entry);
} }
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc) {
if (customWindows.contains(name)) {
SPDLOG_ERROR("SohImGui::AddWindow: Attempting to add duplicate window name %s", name.c_str());
return;
}
customWindows[name] = {
.enabled = false,
.drawFunc = drawFunc
};
windowCategories[category].emplace_back(name);
}
ImTextureID GetTextureByName(const std::string& name) {
return GetTextureByID(DefaultAssets[name]->textureId);
}
} }

View file

@ -47,11 +47,23 @@ namespace SohImGui {
} sdl; } sdl;
} EventImpl; } EventImpl;
extern WindowImpl impl;
using WindowDrawFunc = void(*)(bool& enabled);
typedef struct {
bool enabled;
WindowDrawFunc drawFunc;
} CustomWindow;
extern Console* console; extern Console* console;
void Init(WindowImpl window_impl); void Init(WindowImpl window_impl);
void Update(EventImpl event); void Update(EventImpl event);
void Draw(void); void Draw(void);
void ShowCursor(bool hide, Dialogues w); void ShowCursor(bool hide, Dialogues w);
void BindCmd(const std::string& cmd, CommandEntry entry); void BindCmd(const std::string& cmd, CommandEntry entry);
void* GetTextureByID(int id); void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc);
void LoadResource(const std::string& name, const std::string& path);
ImTextureID GetTextureByID(int id);
ImTextureID GetTextureByName(const std::string& name);
} }

View file

@ -178,6 +178,8 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="soh\Enhancements\bootcommands.c" /> <ClCompile Include="soh\Enhancements\bootcommands.c" />
<ClCompile Include="soh\Enhancements\debugconsole.cpp" /> <ClCompile Include="soh\Enhancements\debugconsole.cpp" />
<ClCompile Include="soh\Enhancements\debugger\debugger.cpp" />
<ClCompile Include="soh\Enhancements\debugger\debugSaveEditor.cpp" />
<ClCompile Include="soh\Enhancements\gameconsole.c" /> <ClCompile Include="soh\Enhancements\gameconsole.c" />
<ClCompile Include="soh\GbiWrap.cpp" /> <ClCompile Include="soh\GbiWrap.cpp" />
<ClCompile Include="soh\gu_pc.c" /> <ClCompile Include="soh\gu_pc.c" />
@ -922,6 +924,8 @@
<ClInclude Include="soh\Enhancements\bootcommands.h" /> <ClInclude Include="soh\Enhancements\bootcommands.h" />
<ClInclude Include="soh\Enhancements\cvar.h" /> <ClInclude Include="soh\Enhancements\cvar.h" />
<ClInclude Include="soh\Enhancements\debugconsole.h" /> <ClInclude Include="soh\Enhancements\debugconsole.h" />
<ClInclude Include="soh\Enhancements\debugger\debugger.h" />
<ClInclude Include="soh\Enhancements\debugger\debugSaveEditor.h" />
<ClInclude Include="soh\gameconsole.h" /> <ClInclude Include="soh\gameconsole.h" />
<ClInclude Include="soh\OTRGlobals.h" /> <ClInclude Include="soh\OTRGlobals.h" />
<ClInclude Include="src\overlays\actors\ovl_Arms_Hook\z_arms_hook.h" /> <ClInclude Include="src\overlays\actors\ovl_Arms_Hook\z_arms_hook.h" />

View file

@ -76,6 +76,12 @@
<Filter Include="Source Files\src\overlays\actors"> <Filter Include="Source Files\src\overlays\actors">
<UniqueIdentifier>{18b9727f-30de-4ab8-a317-916090d4a110}</UniqueIdentifier> <UniqueIdentifier>{18b9727f-30de-4ab8-a317-916090d4a110}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Header Files\soh\Enhancements\debugger">
<UniqueIdentifier>{9a4378ec-e30f-47b6-9ad6-5ce738b4cf99}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\soh\Enhancements\debugger">
<UniqueIdentifier>{04fc1c52-49ff-48e2-ae23-2c00867374f8}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\boot\assert.c"> <ClCompile Include="src\boot\assert.c">
@ -2169,6 +2175,12 @@
<ClCompile Include="src\overlays\actors\ovl_Shot_Sun\z_shot_sun.c"> <ClCompile Include="src\overlays\actors\ovl_Shot_Sun\z_shot_sun.c">
<Filter>Source Files\src\overlays\actors</Filter> <Filter>Source Files\src\overlays\actors</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="soh\Enhancements\debugger\debugger.cpp">
<Filter>Source Files\soh\Enhancements\debugger</Filter>
</ClCompile>
<ClCompile Include="soh\Enhancements\debugger\debugSaveEditor.cpp">
<Filter>Source Files\soh\Enhancements\debugger</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\overlays\actors\ovl_kaleido_scope\z_kaleido_scope.h"> <ClInclude Include="src\overlays\actors\ovl_kaleido_scope\z_kaleido_scope.h">
@ -3710,6 +3722,12 @@
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="soh\Enhancements\debugger\debugger.h">
<Filter>Header Files\soh\Enhancements\debugger</Filter>
</ClInclude>
<ClInclude Include="soh\Enhancements\debugger\debugSaveEditor.h">
<Filter>Header Files\soh\Enhancements\debugger</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="include\macro.inc"> <None Include="include\macro.inc">

View file

@ -0,0 +1,527 @@
#include "debugSaveEditor.h"
#include "../libultraship/SohImGuiImpl.h"
#include <bit>
#include <map>
#include <string>
extern "C" {
#include <z64.h>
#include "variables.h"
#include "functions.h"
#include "macros.h"
extern GlobalContext* gGlobalCtx;
#include "textures/icon_item_static/icon_item_static.h"
}
typedef struct {
uint32_t id;
std::string name;
std::string texturePath;
} ItemMapEntry;
#define ITEM_MAP_ENTRY(id) \
{ \
id, { \
id, #id, static_cast<char*>(gItemIcons[id]) \
} \
}
// Maps items ids to info for use in ImGui
std::map<uint32_t, ItemMapEntry> itemMapping = {
ITEM_MAP_ENTRY(ITEM_STICK),
ITEM_MAP_ENTRY(ITEM_NUT),
ITEM_MAP_ENTRY(ITEM_BOMB),
ITEM_MAP_ENTRY(ITEM_BOW),
ITEM_MAP_ENTRY(ITEM_ARROW_FIRE),
ITEM_MAP_ENTRY(ITEM_DINS_FIRE),
ITEM_MAP_ENTRY(ITEM_SLINGSHOT),
ITEM_MAP_ENTRY(ITEM_OCARINA_FAIRY),
ITEM_MAP_ENTRY(ITEM_OCARINA_TIME),
ITEM_MAP_ENTRY(ITEM_BOMBCHU),
ITEM_MAP_ENTRY(ITEM_HOOKSHOT),
ITEM_MAP_ENTRY(ITEM_LONGSHOT),
ITEM_MAP_ENTRY(ITEM_ARROW_ICE),
ITEM_MAP_ENTRY(ITEM_FARORES_WIND),
ITEM_MAP_ENTRY(ITEM_BOOMERANG),
ITEM_MAP_ENTRY(ITEM_LENS),
ITEM_MAP_ENTRY(ITEM_BEAN),
ITEM_MAP_ENTRY(ITEM_HAMMER),
ITEM_MAP_ENTRY(ITEM_ARROW_LIGHT),
ITEM_MAP_ENTRY(ITEM_NAYRUS_LOVE),
ITEM_MAP_ENTRY(ITEM_BOTTLE),
ITEM_MAP_ENTRY(ITEM_POTION_RED),
ITEM_MAP_ENTRY(ITEM_POTION_GREEN),
ITEM_MAP_ENTRY(ITEM_POTION_BLUE),
ITEM_MAP_ENTRY(ITEM_FAIRY),
ITEM_MAP_ENTRY(ITEM_FISH),
ITEM_MAP_ENTRY(ITEM_MILK_BOTTLE),
ITEM_MAP_ENTRY(ITEM_LETTER_RUTO),
ITEM_MAP_ENTRY(ITEM_BLUE_FIRE),
ITEM_MAP_ENTRY(ITEM_BUG),
ITEM_MAP_ENTRY(ITEM_BIG_POE),
ITEM_MAP_ENTRY(ITEM_MILK_HALF),
ITEM_MAP_ENTRY(ITEM_POE),
ITEM_MAP_ENTRY(ITEM_WEIRD_EGG),
ITEM_MAP_ENTRY(ITEM_CHICKEN),
ITEM_MAP_ENTRY(ITEM_LETTER_ZELDA),
ITEM_MAP_ENTRY(ITEM_MASK_KEATON),
ITEM_MAP_ENTRY(ITEM_MASK_SKULL),
ITEM_MAP_ENTRY(ITEM_MASK_SPOOKY),
ITEM_MAP_ENTRY(ITEM_MASK_BUNNY),
ITEM_MAP_ENTRY(ITEM_MASK_GORON),
ITEM_MAP_ENTRY(ITEM_MASK_ZORA),
ITEM_MAP_ENTRY(ITEM_MASK_GERUDO),
ITEM_MAP_ENTRY(ITEM_MASK_TRUTH),
ITEM_MAP_ENTRY(ITEM_SOLD_OUT),
ITEM_MAP_ENTRY(ITEM_POCKET_EGG),
ITEM_MAP_ENTRY(ITEM_POCKET_CUCCO),
ITEM_MAP_ENTRY(ITEM_COJIRO),
ITEM_MAP_ENTRY(ITEM_ODD_MUSHROOM),
ITEM_MAP_ENTRY(ITEM_ODD_POTION),
ITEM_MAP_ENTRY(ITEM_SAW),
ITEM_MAP_ENTRY(ITEM_SWORD_BROKEN),
ITEM_MAP_ENTRY(ITEM_PRESCRIPTION),
ITEM_MAP_ENTRY(ITEM_FROG),
ITEM_MAP_ENTRY(ITEM_EYEDROPS),
ITEM_MAP_ENTRY(ITEM_CLAIM_CHECK),
ITEM_MAP_ENTRY(ITEM_BOW_ARROW_FIRE),
ITEM_MAP_ENTRY(ITEM_BOW_ARROW_ICE),
ITEM_MAP_ENTRY(ITEM_BOW_ARROW_LIGHT),
ITEM_MAP_ENTRY(ITEM_SWORD_KOKIRI),
ITEM_MAP_ENTRY(ITEM_SWORD_MASTER),
ITEM_MAP_ENTRY(ITEM_SWORD_BGS),
ITEM_MAP_ENTRY(ITEM_SHIELD_DEKU),
ITEM_MAP_ENTRY(ITEM_SHIELD_HYLIAN),
ITEM_MAP_ENTRY(ITEM_SHIELD_MIRROR),
ITEM_MAP_ENTRY(ITEM_TUNIC_KOKIRI),
ITEM_MAP_ENTRY(ITEM_TUNIC_GORON),
ITEM_MAP_ENTRY(ITEM_TUNIC_ZORA),
ITEM_MAP_ENTRY(ITEM_BOOTS_KOKIRI),
ITEM_MAP_ENTRY(ITEM_BOOTS_IRON),
ITEM_MAP_ENTRY(ITEM_BOOTS_HOVER),
ITEM_MAP_ENTRY(ITEM_BULLET_BAG_30),
ITEM_MAP_ENTRY(ITEM_BULLET_BAG_40),
ITEM_MAP_ENTRY(ITEM_BULLET_BAG_50),
ITEM_MAP_ENTRY(ITEM_QUIVER_30),
ITEM_MAP_ENTRY(ITEM_QUIVER_40),
ITEM_MAP_ENTRY(ITEM_QUIVER_50),
ITEM_MAP_ENTRY(ITEM_BOMB_BAG_20),
ITEM_MAP_ENTRY(ITEM_BOMB_BAG_30),
ITEM_MAP_ENTRY(ITEM_BOMB_BAG_40),
ITEM_MAP_ENTRY(ITEM_BRACELET),
ITEM_MAP_ENTRY(ITEM_GAUNTLETS_SILVER),
ITEM_MAP_ENTRY(ITEM_GAUNTLETS_GOLD),
ITEM_MAP_ENTRY(ITEM_SCALE_SILVER),
ITEM_MAP_ENTRY(ITEM_SCALE_GOLDEN),
ITEM_MAP_ENTRY(ITEM_SWORD_KNIFE),
ITEM_MAP_ENTRY(ITEM_WALLET_ADULT),
ITEM_MAP_ENTRY(ITEM_WALLET_GIANT),
ITEM_MAP_ENTRY(ITEM_SEEDS),
ITEM_MAP_ENTRY(ITEM_FISHING_POLE),
};
// Maps entries in the GS flag array to the area name it represents
std::vector<std::string> gsMapping = {
"Deku Tree",
"Dodongo's Cavern",
"Inside Jabu-Jabu's Belly",
"Forest Temple",
"Fire Temple",
"Water Temple",
"Spirit Temple",
"Shadow Temple",
"Bottom of the Well",
"Ice Cavern",
"Hyrule Field",
"Lon Lon Ranch",
"Kokiri Forest",
"Lost Woods, Sacred Forest Meadow",
"Castle Town and Ganon's Castle",
"Death Mountain Trail, Goron City",
"Kakariko Village",
"Zora Fountain, River",
"Lake Hylia",
"Gerudo Valley",
"Gerudo Fortress",
"Desert Colossus, Haunted Wasteland",
};
extern "C" u8 gAreaGsFlags[];
extern "C" u8 gAmmoItems[];
// Modification of gAmmoItems that replaces ITEM_NONE with the item in inventory slot it represents
u8 gAllAmmoItems[] = {
ITEM_STICK, ITEM_NUT, ITEM_BOMB, ITEM_BOW, ITEM_ARROW_FIRE, ITEM_DINS_FIRE,
ITEM_SLINGSHOT, ITEM_OCARINA_TIME, ITEM_BOMBCHU, ITEM_LONGSHOT, ITEM_ARROW_ICE, ITEM_FARORES_WIND,
ITEM_BOOMERANG, ITEM_LENS, ITEM_BEAN, ITEM_HAMMER,
};
// Adds a text tooltip for the previous ImGui item
void SetLastItemHoverText(const std::string& text) {
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text(text.c_str());
ImGui::EndTooltip();
}
}
// Adds a "?" next to the previous ImGui item with a custom tooltip
void InsertHelpHoverText(const std::string& text) {
ImGui::SameLine();
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?");
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text(text.c_str());
ImGui::EndTooltip();
}
}
void DrawSaveEditor(bool& open) {
if (!open) {
return;
}
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Save Editor", &open)) {
ImGui::End();
return;
}
// TODO This is the bare minimum to get the player name showing
// There will need to be more effort to get it robust and editable
std::string name;
for (int i = 0; i < 8; i++) {
char letter = gSaveContext.playerName[i] + 0x3D;
if (letter == '{') {
letter = '\0';
}
name += letter;
}
name += '\0';
if (ImGui::BeginTabBar("SaveContextTabBar", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) {
if (ImGui::BeginTabItem("Info")) {
ImGui::PushItemWidth(ImGui::GetFontSize() * 6);
ImGui::Text("Name: %s", name.c_str());
InsertHelpHoverText("Player Name");
// Use an intermediary to keep the health from updating (and potentially killing the player)
// until it is done being edited
int16_t healthIntermediary = gSaveContext.healthCapacity;
ImGui::InputScalar("Max Health", ImGuiDataType_S16, &healthIntermediary);
if (ImGui::IsItemDeactivated()) {
gSaveContext.healthCapacity = healthIntermediary;
}
InsertHelpHoverText("Maximum health. 16 units per full heart");
if (gSaveContext.health > gSaveContext.healthCapacity) {
gSaveContext.health = gSaveContext.healthCapacity; // Clamp health to new max
}
const uint16_t healthMin = 0;
const uint16_t healthMax = gSaveContext.healthCapacity;
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 15);
ImGui::SliderScalar("Health", ImGuiDataType_S16, &gSaveContext.health, &healthMin, &healthMax);
InsertHelpHoverText("Current health. 16 units per full heart");
bool doubleDefense = gSaveContext.doubleDefense != 0;
if (ImGui::Checkbox("Double Defense", &doubleDefense)) {
gSaveContext.doubleDefense = doubleDefense;
gSaveContext.inventory.defenseHearts =
gSaveContext.doubleDefense ? 20 : 0; // Set to get the border drawn in the UI
}
InsertHelpHoverText("Is double defense unlocked?");
std::string magicName;
if (gSaveContext.magicLevel == 2) {
magicName = "Double";
} else if (gSaveContext.magicLevel == 1) {
magicName = "Single";
} else {
magicName = "None";
}
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 6);
if (ImGui::BeginCombo("Magic Level", magicName.c_str())) {
if (ImGui::Selectable("Double")) {
gSaveContext.magicLevel = 2;
gSaveContext.magicAcquired = true;
gSaveContext.doubleMagic = true;
}
if (ImGui::Selectable("Single")) {
gSaveContext.magicLevel = 1;
gSaveContext.magicAcquired = true;
gSaveContext.doubleMagic = false;
}
if (ImGui::Selectable("None")) {
gSaveContext.magicLevel = 0;
gSaveContext.magicAcquired = false;
gSaveContext.doubleMagic = false;
}
ImGui::EndCombo();
}
InsertHelpHoverText("Current magic level");
gSaveContext.unk_13F4 = gSaveContext.magicLevel * 0x30; // Set to get the bar drawn in the UI
if (gSaveContext.magic > gSaveContext.unk_13F4) {
gSaveContext.magic = gSaveContext.unk_13F4; // Clamp magic to new max
}
const uint8_t magicMin = 0;
const uint8_t magicMax = gSaveContext.unk_13F4;
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 15);
ImGui::SliderScalar("Magic", ImGuiDataType_S8, &gSaveContext.magic, &magicMin, &magicMax);
InsertHelpHoverText("Current magic. 48 units per magic level");
ImGui::InputScalar("Rupees", ImGuiDataType_S16, &gSaveContext.rupees);
InsertHelpHoverText("Current rupees");
const uint16_t dayTimeMin = 0;
const uint16_t dayTimeMax = 0xFFFF;
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 15);
ImGui::SliderScalar("Time", ImGuiDataType_U16, &gSaveContext.dayTime, &dayTimeMin, &dayTimeMax);
InsertHelpHoverText("Time of day");
if (ImGui::Button("Dawn")) {
gSaveContext.dayTime = 0x4000;
}
ImGui::SameLine();
if (ImGui::Button("Noon")) {
gSaveContext.dayTime = 0x8000;
}
ImGui::SameLine();
if (ImGui::Button("Sunset")) {
gSaveContext.dayTime = 0xC000;
}
ImGui::SameLine();
if (ImGui::Button("Midnight")) {
gSaveContext.dayTime = 0;
}
ImGui::InputScalar("Total Days", ImGuiDataType_S32, &gSaveContext.totalDays);
InsertHelpHoverText("Total number of days elapsed since the start of the game");
ImGui::InputScalar("Deaths", ImGuiDataType_U16, &gSaveContext.deaths);
InsertHelpHoverText("Total number of deaths");
// TODO Move to quest status screen once the page is created
ImGui::InputScalar("GS Count", ImGuiDataType_S16, &gSaveContext.inventory.gsTokens);
InsertHelpHoverText("Number of gold skulltula tokens aquired");
bool bgsFlag = gSaveContext.bgsFlag != 0;
if (ImGui::Checkbox("Has BGS", &bgsFlag)) {
gSaveContext.bgsFlag = bgsFlag;
}
InsertHelpHoverText("Is Biggoron sword unlocked? Replaces Giant's knife");
ImGui::InputScalar("Sword Health", ImGuiDataType_U16, &gSaveContext.swordHealth);
InsertHelpHoverText("Giant's knife health. Default is 8. Must be >0 for Biggoron sword to work");
ImGui::InputScalar("Bgs Day Count", ImGuiDataType_S32, &gSaveContext.bgsDayCount);
InsertHelpHoverText("Total number of days elapsed since giving Biggoron the claim check");
// TODO Changing Link's age is more involved than just setting gSaveContext.linkAge
// It might not fit here and instead should be only changable when changing scenes
/*
if (ImGui::BeginCombo("Link Age", LINK_IS_ADULT ? "Adult" : "Child")) {
if (ImGui::Selectable("Adult")) {
gSaveContext.linkAge = 0;
}
if (ImGui::Selectable("Child")) {
gSaveContext.linkAge = 1;
}
ImGui::EndCombo();
}
*/
ImGui::PopItemWidth();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Inventory")) {
static bool restrictToValid = true;
ImGui::Checkbox("Restrict to valid items", &restrictToValid);
InsertHelpHoverText("Restricts items and ammo to only what is possible to legally acquire in-game");
for (int32_t y = 0; y < 4; y++) {
for (int32_t x = 0; x < 6; x++) {
int32_t index = x + y * 6;
static int32_t selectedIndex = -1;
static const char* itemPopupPicker = "itemPopupPicker";
ImGui::PushID(index);
if (x != 0) {
ImGui::SameLine();
}
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
uint8_t item = gSaveContext.inventory.items[index];
if (item != ITEM_NONE) {
const ItemMapEntry& slotEntry = itemMapping.find(item)->second;
if (ImGui::ImageButton(SohImGui::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f),
ImVec2(0, 0), ImVec2(1, 1), 0)) {
selectedIndex = index;
ImGui::OpenPopup(itemPopupPicker);
}
} else {
if (ImGui::Button("##itemNone", ImVec2(32.0f, 32.0f))) {
selectedIndex = index;
ImGui::OpenPopup(itemPopupPicker);
}
}
ImGui::PopStyleVar();
ImGui::PopStyleColor();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
if (ImGui::BeginPopup(itemPopupPicker)) {
if (ImGui::Button("##itemNonePicker", ImVec2(32.0f, 32.0f))) {
gSaveContext.inventory.items[selectedIndex] = ITEM_NONE;
ImGui::CloseCurrentPopup();
}
SetLastItemHoverText("ITEM_NONE");
std::vector<ItemMapEntry> possibleItems;
if (restrictToValid) {
// Scan gItemSlots to find legal items for this slot. Bottles are a special case
for (int slotIndex = 0; slotIndex < 56; slotIndex++) {
int testIndex = (selectedIndex == SLOT_BOTTLE_1 || selectedIndex == SLOT_BOTTLE_2 ||
selectedIndex == SLOT_BOTTLE_3 || selectedIndex == SLOT_BOTTLE_4)
? SLOT_BOTTLE_1
: selectedIndex;
if (gItemSlots[slotIndex] == testIndex) {
possibleItems.push_back(itemMapping[slotIndex]);
}
}
} else {
for (const auto& entry : itemMapping) {
possibleItems.push_back(entry.second);
}
}
for (int32_t pickerIndex = 0; pickerIndex < possibleItems.size(); pickerIndex++) {
if (((pickerIndex + 1) % 8) != 0) {
ImGui::SameLine();
}
const ItemMapEntry& slotEntry = possibleItems[pickerIndex];
if (ImGui::ImageButton(SohImGui::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f),
ImVec2(0, 0), ImVec2(1, 1), 0)) {
gSaveContext.inventory.items[selectedIndex] = slotEntry.id;
ImGui::CloseCurrentPopup();
}
SetLastItemHoverText(slotEntry.name);
}
ImGui::EndPopup();
}
ImGui::PopStyleVar();
ImGui::PopID();
}
}
ImGui::Text("Ammo");
for (uint32_t ammoIndex = 0, drawnAmmoItems = 0; ammoIndex < 16; ammoIndex++) {
uint8_t item = (restrictToValid) ? gAmmoItems[ammoIndex] : gAllAmmoItems[ammoIndex];
if (item != ITEM_NONE) {
// For legal items, display as 1 row of 7. For unrestricted items, display rows of 6 to match
// inventory
if ((restrictToValid && (drawnAmmoItems != 0)) || ((drawnAmmoItems % 6) != 0)) {
ImGui::SameLine();
}
drawnAmmoItems++;
ImGui::PushID(ammoIndex);
ImGui::PushItemWidth(32.0f);
ImGui::BeginGroup();
ImGui::Image(SohImGui::GetTextureByName(itemMapping[item].name), ImVec2(32.0f, 32.0f));
ImGui::InputScalar("##ammoInput", ImGuiDataType_S8, &AMMO(item));
ImGui::EndGroup();
ImGui::PopItemWidth();
ImGui::PopID();
}
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Flags")) {
static uint32_t selectedGsMap = 0;
ImGui::Text("Gold Skulltulas");
ImGui::Text("Map");
ImGui::SameLine();
if (ImGui::BeginCombo("##Gold Skulltula Map", gsMapping[selectedGsMap].c_str())) {
for (int32_t gsIndex = 0; gsIndex < gsMapping.size(); gsIndex++) {
if (ImGui::Selectable(gsMapping[gsIndex].c_str())) {
selectedGsMap = gsIndex;
}
}
ImGui::EndCombo();
}
// TODO We should write out descriptions for each one... ugh
ImGui::Text("Flags");
uint32_t currentFlags = GET_GS_FLAGS(selectedGsMap);
uint32_t allFlags = gAreaGsFlags[selectedGsMap];
uint32_t setMask = 1;
// Iterate over bitfield and create a checkbox for each skulltula
while (allFlags != 0) {
bool isThisSet = (currentFlags & 0x1) == 0x1;
ImGui::SameLine();
ImGui::PushID(allFlags);
if (ImGui::Checkbox("##gs", &isThisSet)) {
if (isThisSet) {
SET_GS_FLAGS(selectedGsMap, setMask);
} else {
// Have to do this roundabout method as the macro does not support clearing flags
uint32_t currentFlagsBase = GET_GS_FLAGS(selectedGsMap);
gSaveContext.gsFlags[selectedGsMap >> 2] &= ~gGsFlagsMasks[selectedGsMap & 3];
SET_GS_FLAGS(selectedGsMap, currentFlagsBase & ~setMask);
}
}
ImGui::PopID();
allFlags >>= 1;
currentFlags >>= 1;
setMask <<= 1;
}
static bool keepGsCountUpdated = true;
ImGui::Checkbox("Keep GS Count Updated", &keepGsCountUpdated);
InsertHelpHoverText("Automatically adjust the number of gold skulltula tokens acquired based on set flags");
int32_t gsCount = 0;
if (keepGsCountUpdated) {
for (int32_t gsFlagIndex = 0; gsFlagIndex < 6; gsFlagIndex++) {
gsCount += std::popcount(static_cast<uint32_t>(gSaveContext.gsFlags[gsFlagIndex]));
}
gSaveContext.inventory.gsTokens = gsCount;
}
// TODO other flag types, like switch, clear, etc.
// These flags interact with the actor context, so it's a bit more complicated
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
ImGui::End();
}
void InitSaveEditor() {
SohImGui::AddWindow("Debug", "Save Editor", DrawSaveEditor);
// Load item icons into ImGui
for (const auto& entry : itemMapping) {
SohImGui::LoadResource(entry.second.name, entry.second.texturePath);
}
}

View file

@ -0,0 +1,3 @@
#pragma once
void InitSaveEditor();

View file

@ -0,0 +1,6 @@
#include "debugger.h"
#include "debugSaveEditor.h"
void Debug_Init(void) {
InitSaveEditor();
}

View file

@ -0,0 +1,3 @@
#pragma once
void Debug_Init(void);

View file

@ -22,6 +22,7 @@
#include "Lib/stb/stb_image.h" #include "Lib/stb/stb_image.h"
#include "AudioPlayer.h" #include "AudioPlayer.h"
#include "../soh/Enhancements/debugconsole.h" #include "../soh/Enhancements/debugconsole.h"
#include "../soh/Enhancements/debugger/debugger.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
OTRGlobals* OTRGlobals::Instance; OTRGlobals* OTRGlobals::Instance;
@ -54,6 +55,7 @@ extern "C" void InitOTR() {
clearMtx = (uintptr_t)&gMtxClear; clearMtx = (uintptr_t)&gMtxClear;
OTRMessage_Init(); OTRMessage_Init();
DebugConsole_Init(); DebugConsole_Init();
Debug_Init();
} }
extern "C" uint64_t GetFrequency() { extern "C" uint64_t GetFrequency() {
@ -183,9 +185,9 @@ extern "C" char* ResourceMgr_LoadJPEG(char* data, int dataSize)
return (char*)finalBuffer; return (char*)finalBuffer;
} }
extern "C" char* ResourceMgr_LoadTexByName(char* texPath); extern "C" char* ResourceMgr_LoadTexByName(const char* texPath);
extern "C" char* ResourceMgr_LoadTexOrDListByName(char* filePath) { extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) {
auto res = OTRGlobals::Instance->context->GetResourceManager()->LoadResource(filePath); auto res = OTRGlobals::Instance->context->GetResourceManager()->LoadResource(filePath);
if (res->resType == Ship::ResourceType::DisplayList) if (res->resType == Ship::ResourceType::DisplayList)
@ -196,28 +198,28 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(char* filePath) {
return ResourceMgr_LoadTexByName(filePath); return ResourceMgr_LoadTexByName(filePath);
} }
extern "C" char* ResourceMgr_LoadPlayerAnimByName(char* animPath) { extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) {
auto anim = std::static_pointer_cast<Ship::PlayerAnimation>( auto anim = std::static_pointer_cast<Ship::PlayerAnimation>(
OTRGlobals::Instance->context->GetResourceManager()->LoadResource(animPath)); OTRGlobals::Instance->context->GetResourceManager()->LoadResource(animPath));
return (char*)&anim->limbRotData[0]; return (char*)&anim->limbRotData[0];
} }
extern "C" Gfx* ResourceMgr_LoadGfxByName(char* path) extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path)
{ {
auto res = std::static_pointer_cast<Ship::DisplayList>( auto res = std::static_pointer_cast<Ship::DisplayList>(
OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path));
return (Gfx*)&res->instructions[0]; return (Gfx*)&res->instructions[0];
} }
extern "C" char* ResourceMgr_LoadArrayByName(char* path) extern "C" char* ResourceMgr_LoadArrayByName(const char* path)
{ {
auto res = std::static_pointer_cast<Ship::Array>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); auto res = std::static_pointer_cast<Ship::Array>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path));
return (char*)res->scalars.data(); return (char*)res->scalars.data();
} }
extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(char* path) { extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) {
auto res = auto res =
std::static_pointer_cast<Ship::Array>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); std::static_pointer_cast<Ship::Array>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path));
@ -239,7 +241,7 @@ extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(char* path) {
} }
} }
extern "C" CollisionHeader* ResourceMgr_LoadColByName(char* path) extern "C" CollisionHeader* ResourceMgr_LoadColByName(const char* path)
{ {
auto colRes = std::static_pointer_cast<Ship::CollisionHeader>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); auto colRes = std::static_pointer_cast<Ship::CollisionHeader>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path));
@ -333,7 +335,7 @@ extern "C" CollisionHeader* ResourceMgr_LoadColByName(char* path)
return (CollisionHeader*)colHeader; return (CollisionHeader*)colHeader;
} }
extern "C" Vtx * ResourceMgr_LoadVtxByName(char* path) extern "C" Vtx * ResourceMgr_LoadVtxByName(const char* path)
{ {
auto res = std::static_pointer_cast<Ship::Array>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); auto res = std::static_pointer_cast<Ship::Array>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path));
return (Vtx*)res->vertices.data(); return (Vtx*)res->vertices.data();
@ -355,7 +357,7 @@ extern "C" int ResourceMgr_OTRSigCheck(char* imgData)
return 0; return 0;
} }
extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(char* path) { extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) {
auto res = std::static_pointer_cast<Ship::Animation>( auto res = std::static_pointer_cast<Ship::Animation>(
OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path));
@ -424,7 +426,7 @@ extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(char* path) {
return anim; return anim;
} }
extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) { extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path) {
auto res = std::static_pointer_cast<Ship::Skeleton>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); auto res = std::static_pointer_cast<Ship::Skeleton>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path));
if (res->cachedGameAsset != nullptr) if (res->cachedGameAsset != nullptr)
@ -470,14 +472,14 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) {
limbC->sibling = limb->siblingIndex; limbC->sibling = limb->siblingIndex;
if (limb->dListPtr != "") { if (limb->dListPtr != "") {
auto dList = ResourceMgr_LoadGfxByName((char*)limb->dListPtr.c_str()); auto dList = ResourceMgr_LoadGfxByName(limb->dListPtr.c_str());
limbC->dLists[0] = dList; limbC->dLists[0] = dList;
} else { } else {
limbC->dLists[0] = nullptr; limbC->dLists[0] = nullptr;
} }
if (limb->dList2Ptr != "") { if (limb->dList2Ptr != "") {
auto dList = ResourceMgr_LoadGfxByName((char*)limb->dList2Ptr.c_str()); auto dList = ResourceMgr_LoadGfxByName(limb->dList2Ptr.c_str());
limbC->dLists[1] = dList; limbC->dLists[1] = dList;
} else { } else {
limbC->dLists[1] = nullptr; limbC->dLists[1] = nullptr;
@ -496,7 +498,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) {
limbC->dList = nullptr; limbC->dList = nullptr;
if (!limb->dListPtr.empty()) { if (!limb->dListPtr.empty()) {
const auto dList = ResourceMgr_LoadGfxByName(const_cast<char*>(limb->dListPtr.c_str())); const auto dList = ResourceMgr_LoadGfxByName(limb->dListPtr.c_str());
limbC->dList = dList; limbC->dList = dList;
} }
@ -512,12 +514,12 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) {
limbC->dList[1] = nullptr; limbC->dList[1] = nullptr;
if (!limb->dListPtr.empty()) { if (!limb->dListPtr.empty()) {
const auto dList = ResourceMgr_LoadGfxByName(const_cast<char*>(limb->dListPtr.c_str())); const auto dList = ResourceMgr_LoadGfxByName(limb->dListPtr.c_str());
limbC->dList[0] = dList; limbC->dList[0] = dList;
} }
if (!limb->dList2Ptr.empty()) { if (!limb->dList2Ptr.empty()) {
const auto dList = ResourceMgr_LoadGfxByName(const_cast<char*>(limb->dList2Ptr.c_str())); const auto dList = ResourceMgr_LoadGfxByName(limb->dList2Ptr.c_str());
limbC->dList[1] = dList; limbC->dList[1] = dList;
} }
@ -543,7 +545,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) {
limbC->segmentType = 0; limbC->segmentType = 0;
if (limb->skinSegmentType == Ship::ZLimbSkinType::SkinType_DList) if (limb->skinSegmentType == Ship::ZLimbSkinType::SkinType_DList)
limbC->segment = ResourceMgr_LoadGfxByName(const_cast<char*>(limb->skinDList.c_str())); limbC->segment = ResourceMgr_LoadGfxByName(limb->skinDList.c_str());
else if (limb->skinSegmentType == Ship::ZLimbSkinType::SkinType_4) { else if (limb->skinSegmentType == Ship::ZLimbSkinType::SkinType_4) {
const auto animData = new SkinAnimatedLimbData; const auto animData = new SkinAnimatedLimbData;
const int skinDataSize = limb->skinData.size(); const int skinDataSize = limb->skinData.size();
@ -551,7 +553,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) {
animData->totalVtxCount = limb->skinVtxCnt; animData->totalVtxCount = limb->skinVtxCnt;
animData->limbModifCount = skinDataSize; animData->limbModifCount = skinDataSize;
animData->limbModifications = new SkinLimbModif[animData->limbModifCount]; animData->limbModifications = new SkinLimbModif[animData->limbModifCount];
animData->dlist = ResourceMgr_LoadGfxByName(const_cast<char*>(limb->skinDList2.c_str())); animData->dlist = ResourceMgr_LoadGfxByName(limb->skinDList2.c_str());
for (int i = 0; i < skinDataSize; i++) for (int i = 0; i < skinDataSize; i++)
{ {
@ -611,7 +613,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) {
return baseHeader; return baseHeader;
} }
extern "C" s32* ResourceMgr_LoadCSByName(char* path) extern "C" s32* ResourceMgr_LoadCSByName(const char* path)
{ {
auto res = std::static_pointer_cast<Ship::Cutscene>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); auto res = std::static_pointer_cast<Ship::Cutscene>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path));
return (s32*)res->commands.data(); return (s32*)res->commands.data();

View file

@ -31,17 +31,17 @@ uint32_t ResourceMgr_GetGameVersion();
void ResourceMgr_CacheDirectory(const char* resName); void ResourceMgr_CacheDirectory(const char* resName);
void ResourceMgr_LoadFile(const char* resName); void ResourceMgr_LoadFile(const char* resName);
char* ResourceMgr_LoadFileFromDisk(const char* filePath); char* ResourceMgr_LoadFileFromDisk(const char* filePath);
char* ResourceMgr_LoadTexByName(char* texPath); char* ResourceMgr_LoadTexByName(const char* texPath);
char* ResourceMgr_LoadTexOrDListByName(char* filePath); char* ResourceMgr_LoadTexOrDListByName(const char* filePath);
char* ResourceMgr_LoadPlayerAnimByName(char* animPath); char* ResourceMgr_LoadPlayerAnimByName(const char* animPath);
char* ResourceMgr_GetNameByCRC(uint64_t crc, char* alloc); char* ResourceMgr_GetNameByCRC(uint64_t crc, char* alloc);
Gfx* ResourceMgr_LoadGfxByCRC(uint64_t crc); Gfx* ResourceMgr_LoadGfxByCRC(uint64_t crc);
Gfx* ResourceMgr_LoadGfxByName(char* path); Gfx* ResourceMgr_LoadGfxByName(const char* path);
Vtx* ResourceMgr_LoadVtxByCRC(uint64_t crc); Vtx* ResourceMgr_LoadVtxByCRC(uint64_t crc);
Vtx* ResourceMgr_LoadVtxByName(char* path); Vtx* ResourceMgr_LoadVtxByName(const char* path);
CollisionHeader* ResourceMgr_LoadColByName(char* path); CollisionHeader* ResourceMgr_LoadColByName(const char* path);
uint64_t GetPerfCounter(); uint64_t GetPerfCounter();
struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path); struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path);
int ResourceMgr_OTRSigCheck(char* imgData); int ResourceMgr_OTRSigCheck(char* imgData);
uint64_t osGetTime(void); uint64_t osGetTime(void);
uint32_t osGetCount(void); uint32_t osGetCount(void);

View file

@ -768,7 +768,7 @@ void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCt
texture = gSpiritTempleTitleCardENGTex; texture = gSpiritTempleTitleCardENGTex;
break; break;
case SCENE_HAKADAN: case SCENE_HAKADAN:
texture = gSpiritTempleTitleCardENGTex; texture = gShadowTempleTitleCardENGTex;
break; break;
case SCENE_HAKADANCH: case SCENE_HAKADANCH:
texture = gBottomOfTheWellTitleCardENGTex; texture = gBottomOfTheWellTitleCardENGTex;

View file

@ -179,6 +179,7 @@ void FileChoose_UpdateMainMenu(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx; FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx; SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0]; 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 (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_A)) {
if (this->buttonIndex <= FS_BTN_MAIN_FILE_3) { if (this->buttonIndex <= FS_BTN_MAIN_FILE_3) {
@ -237,10 +238,10 @@ void FileChoose_UpdateMainMenu(GameState* thisx) {
} }
} }
} else { } else {
if (ABS(this->stickRelY) > 30) { if ((ABS(this->stickRelY) > 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
if (this->stickRelY > 30) { if ((this->stickRelY > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
this->buttonIndex--; this->buttonIndex--;
if (this->buttonIndex < FS_BTN_MAIN_FILE_1) { if (this->buttonIndex < FS_BTN_MAIN_FILE_1) {
this->buttonIndex = FS_BTN_MAIN_OPTIONS; this->buttonIndex = FS_BTN_MAIN_OPTIONS;
@ -1318,6 +1319,7 @@ void FileChoose_FadeInFileInfo(GameState* thisx) {
void FileChoose_ConfirmFile(GameState* thisx) { void FileChoose_ConfirmFile(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx; FileChooseContext* this = (FileChooseContext*)thisx;
Input* input = &this->state.input[0]; 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 (CHECK_BTN_ALL(input->press.button, BTN_START) || (CHECK_BTN_ALL(input->press.button, BTN_A))) {
if (this->confirmButtonIndex == FS_BTN_CONFIRM_YES) { if (this->confirmButtonIndex == FS_BTN_CONFIRM_YES) {
@ -1332,7 +1334,7 @@ void FileChoose_ConfirmFile(GameState* thisx) {
} else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CLOSE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->selectMode++; this->selectMode++;
} else if (ABS(this->stickRelY) >= 30) { } else if ((ABS(this->stickRelY) >= 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->confirmButtonIndex ^= 1; this->confirmButtonIndex ^= 1;
} }

View file

@ -62,6 +62,7 @@ void FileChoose_SelectCopySource(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx; FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx; SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0]; Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) ||
CHECK_BTN_ALL(input->press.button, BTN_B)) { CHECK_BTN_ALL(input->press.button, BTN_B)) {
@ -82,10 +83,10 @@ void FileChoose_SelectCopySource(GameState* thisx) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} }
} else { } else {
if (ABS(this->stickRelY) >= 30) { if ((ABS(this->stickRelY) >= 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
if (this->stickRelY >= 30) { if ((this->stickRelY >= 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
this->buttonIndex--; this->buttonIndex--;
if (this->buttonIndex < FS_BTN_COPY_FILE_1) { if (this->buttonIndex < FS_BTN_COPY_FILE_1) {
@ -174,6 +175,7 @@ void FileChoose_SelectCopyDest(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx; FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx; SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0]; Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) ||
CHECK_BTN_ALL(input->press.button, BTN_B)) { CHECK_BTN_ALL(input->press.button, BTN_B)) {
@ -194,10 +196,10 @@ void FileChoose_SelectCopyDest(GameState* thisx) {
} }
} else { } else {
if (ABS(this->stickRelY) >= 30) { if ((ABS(this->stickRelY) >= 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
if (this->stickRelY >= 30) { if ((this->stickRelY >= 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
this->buttonIndex--; this->buttonIndex--;
if ((this->buttonIndex == this->selectedFileIndex)) { if ((this->buttonIndex == this->selectedFileIndex)) {
@ -360,6 +362,7 @@ void FileChoose_CopyConfirm(GameState* thisx) {
SramContext* sramCtx = &this->sramCtx; SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0]; Input* input = &this->state.input[0];
u16 dayTime; u16 dayTime;
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (((this->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || if (((this->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) ||
CHECK_BTN_ALL(input->press.button, BTN_B)) { CHECK_BTN_ALL(input->press.button, BTN_B)) {
@ -377,7 +380,7 @@ void FileChoose_CopyConfirm(GameState* thisx) {
this->configMode = CM_COPY_ANIM_1; this->configMode = CM_COPY_ANIM_1;
func_800AA000(300.0f, 0xB4, 0x14, 0x64); func_800AA000(300.0f, 0xB4, 0x14, 0x64);
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else if (ABS(this->stickRelY) >= 30) { } else if ((ABS(this->stickRelY) >= 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->buttonIndex ^= 1; this->buttonIndex ^= 1;
} }
@ -680,6 +683,7 @@ void FileChoose_EraseSelect(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx; FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx; SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0]; Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || if (((this->buttonIndex == FS_BTN_COPY_QUIT) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) ||
CHECK_BTN_ALL(input->press.button, BTN_B)) { CHECK_BTN_ALL(input->press.button, BTN_B)) {
@ -700,10 +704,10 @@ void FileChoose_EraseSelect(GameState* thisx) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} }
} else { } else {
if (ABS(this->stickRelY) >= 30) { if ((ABS(this->stickRelY) >= 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
if (this->stickRelY >= 30) { if ((this->stickRelY >= 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
this->buttonIndex--; this->buttonIndex--;
if (this->buttonIndex < FS_BTN_ERASE_FILE_1) { if (this->buttonIndex < FS_BTN_ERASE_FILE_1) {
this->buttonIndex = FS_BTN_ERASE_QUIT; this->buttonIndex = FS_BTN_ERASE_QUIT;
@ -817,6 +821,7 @@ void FileChoose_SetupEraseConfirm2(GameState* thisx) {
void FileChoose_EraseConfirm(GameState* thisx) { void FileChoose_EraseConfirm(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx; FileChooseContext* this = (FileChooseContext*)thisx;
Input* input = &this->state.input[0]; Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (((this->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) || if (((this->buttonIndex != FS_BTN_CONFIRM_YES) && CHECK_BTN_ANY(input->press.button, BTN_A | BTN_START)) ||
CHECK_BTN_ALL(input->press.button, BTN_B)) { CHECK_BTN_ALL(input->press.button, BTN_B)) {
@ -833,7 +838,7 @@ void FileChoose_EraseConfirm(GameState* thisx) {
this->nextTitleLabel = FS_TITLE_ERASE_COMPLETE; this->nextTitleLabel = FS_TITLE_ERASE_COMPLETE;
func_800AA000(200.0f, 0xFF, 0x14, 0x96); func_800AA000(200.0f, 0xFF, 0x14, 0x96);
sEraseDelayTimer = 15; sEraseDelayTimer = 15;
} else if (ABS(this->stickRelY) >= 30) { } else if ((ABS(this->stickRelY) >= 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->buttonIndex ^= 1; this->buttonIndex ^= 1;
} }

View file

@ -509,12 +509,14 @@ void FileChoose_StartNameEntry(GameState* thisx) {
*/ */
void FileChoose_UpdateKeyboardCursor(GameState* thisx) { void FileChoose_UpdateKeyboardCursor(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx; FileChooseContext* this = (FileChooseContext*)thisx;
Input* input = &this->state.input[0];
s16 prevKbdX; s16 prevKbdX;
bool dpad = CVar_GetS32("gDpadPauseName", 0);
this->kbdButton = 99; this->kbdButton = 99;
if (this->kbdY != 5) { if (this->kbdY != 5) {
if (this->stickRelX < -30) { if ((this->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->charIndex--; this->charIndex--;
this->kbdX--; this->kbdX--;
@ -522,7 +524,7 @@ void FileChoose_UpdateKeyboardCursor(GameState* thisx) {
this->kbdX = 12; this->kbdX = 12;
this->charIndex = (this->kbdY * 13) + this->kbdX; this->charIndex = (this->kbdY * 13) + this->kbdX;
} }
} else if (this->stickRelX > 30) { } else if ((this->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->charIndex++; this->charIndex++;
this->kbdX++; this->kbdX++;
@ -532,13 +534,13 @@ void FileChoose_UpdateKeyboardCursor(GameState* thisx) {
} }
} }
} else { } else {
if (this->stickRelX < -30) { if ((this->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->kbdX--; this->kbdX--;
if (this->kbdX < 3) { if (this->kbdX < 3) {
this->kbdX = 4; this->kbdX = 4;
} }
} else if (this->stickRelX > 30) { } else if ((this->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->kbdX++; this->kbdX++;
if (this->kbdX > 4) { if (this->kbdX > 4) {
@ -547,7 +549,7 @@ void FileChoose_UpdateKeyboardCursor(GameState* thisx) {
} }
} }
if (this->stickRelY > 30) { if ((this->stickRelY > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->kbdY--; this->kbdY--;
@ -578,7 +580,7 @@ void FileChoose_UpdateKeyboardCursor(GameState* thisx) {
this->charIndex += this->kbdX; this->charIndex += this->kbdX;
} }
} }
} else if (this->stickRelY < -30) { } else if ((this->stickRelY < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->kbdY++; this->kbdY++;
@ -655,6 +657,7 @@ void FileChoose_UpdateOptionsMenu(GameState* thisx) {
FileChooseContext* this = (FileChooseContext*)thisx; FileChooseContext* this = (FileChooseContext*)thisx;
SramContext* sramCtx = &this->sramCtx; SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0]; Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (CHECK_BTN_ALL(input->press.button, BTN_B)) { 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); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
@ -675,7 +678,7 @@ void FileChoose_UpdateOptionsMenu(GameState* thisx) {
return; return;
} }
if (this->stickRelX < -30) { if ((this->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
if (sSelectedSetting == FS_SETTING_AUDIO) { if (sSelectedSetting == FS_SETTING_AUDIO) {
@ -688,7 +691,7 @@ void FileChoose_UpdateOptionsMenu(GameState* thisx) {
} else { } else {
gSaveContext.zTargetSetting ^= 1; gSaveContext.zTargetSetting ^= 1;
} }
} else if (this->stickRelX > 30) { } else if ((this->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
if (sSelectedSetting == FS_SETTING_AUDIO) { if (sSelectedSetting == FS_SETTING_AUDIO) {
@ -702,7 +705,7 @@ void FileChoose_UpdateOptionsMenu(GameState* thisx) {
} }
} }
if ((this->stickRelY < -30) || (this->stickRelY > 30)) { if ((ABS(this->stickRelY) > 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
sSelectedSetting ^= 1; sSelectedSetting ^= 1;
} else if (CHECK_BTN_ALL(input->press.button, BTN_A)) { } else if (CHECK_BTN_ALL(input->press.button, BTN_A)) {

View file

@ -74,6 +74,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx
s16 pad2; s16 pad2;
s16 phi_s0_2; s16 phi_s0_2;
s16 sp208[3]; s16 sp208[3];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
OPEN_DISPS(gfxCtx, "../z_kaleido_collect.c", 248); OPEN_DISPS(gfxCtx, "../z_kaleido_collect.c", 248);
@ -83,13 +84,10 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx
if (pauseCtx->cursorSpecialPos == 0) { if (pauseCtx->cursorSpecialPos == 0) {
pauseCtx->nameColorSet = 0; pauseCtx->nameColorSet = 0;
if ((pauseCtx->state != 6) || ((pauseCtx->stickRelX == 0) && (pauseCtx->stickRelY == 0))) {
sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; sp216 = pauseCtx->cursorSlot[PAUSE_QUEST];
} else {
phi_s3 = pauseCtx->cursorPoint[PAUSE_QUEST]; phi_s3 = pauseCtx->cursorPoint[PAUSE_QUEST];
if (pauseCtx->stickRelX < -30) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
phi_s0 = D_8082A1AC[phi_s3][2]; phi_s0 = D_8082A1AC[phi_s3][2];
if (phi_s0 == -3) { if (phi_s0 == -3) {
KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT); KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT);
@ -102,7 +100,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx
phi_s0 = D_8082A1AC[phi_s0][2]; phi_s0 = D_8082A1AC[phi_s0][2];
} }
} }
} else if (pauseCtx->stickRelX > 30) { } else if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
phi_s0 = D_8082A1AC[phi_s3][3]; phi_s0 = D_8082A1AC[phi_s3][3];
if (phi_s0 == -2) { if (phi_s0 == -2) {
KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT);
@ -117,7 +115,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx
} }
} }
if (pauseCtx->stickRelY < -30) { if ((pauseCtx->stickRelY < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) {
phi_s0 = D_8082A1AC[phi_s3][1]; phi_s0 = D_8082A1AC[phi_s3][1];
while (phi_s0 >= 0) { while (phi_s0 >= 0) {
if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) { if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) {
@ -125,7 +123,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx
} }
phi_s0 = D_8082A1AC[phi_s0][1]; phi_s0 = D_8082A1AC[phi_s0][1];
} }
} else if (pauseCtx->stickRelY > 30) { } else if ((pauseCtx->stickRelY > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
phi_s0 = D_8082A1AC[phi_s3][0]; phi_s0 = D_8082A1AC[phi_s3][0];
while (phi_s0 >= 0) { while (phi_s0 >= 0) {
if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) { if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) {
@ -171,7 +169,6 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx
sp216 = pauseCtx->cursorPoint[PAUSE_QUEST]; sp216 = pauseCtx->cursorPoint[PAUSE_QUEST];
pauseCtx->cursorItem[pauseCtx->pageIndex] = phi_s0_2; pauseCtx->cursorItem[pauseCtx->pageIndex] = phi_s0_2;
pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216; pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216;
}
KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx); KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx);
@ -215,7 +212,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx
} }
} }
} else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) {
if (pauseCtx->stickRelX > 30) { if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
pauseCtx->cursorPoint[PAUSE_QUEST] = 0x15; pauseCtx->cursorPoint[PAUSE_QUEST] = 0x15;
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
@ -232,7 +229,7 @@ void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfx
pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216; pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216;
} }
} else { } else {
if (pauseCtx->stickRelX < -30) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
pauseCtx->cursorPoint[PAUSE_QUEST] = 0; pauseCtx->cursorPoint[PAUSE_QUEST] = 0;
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;

View file

@ -140,6 +140,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
s16 cursorX; s16 cursorX;
s16 cursorY; s16 cursorY;
volatile s16 oldCursorPoint; volatile s16 oldCursorPoint;
bool dpad = CVar_GetS32("gDpadPauseName", 0);
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_equipment.c", 219); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_equipment.c", 219);
@ -174,7 +175,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
cursorMoveResult = 0; cursorMoveResult = 0;
while (cursorMoveResult == 0) { while (cursorMoveResult == 0) {
if (pauseCtx->stickRelX < -30) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
if (pauseCtx->cursorX[PAUSE_EQUIP] != 0) { if (pauseCtx->cursorX[PAUSE_EQUIP] != 0) {
pauseCtx->cursorX[PAUSE_EQUIP] -= 1; pauseCtx->cursorX[PAUSE_EQUIP] -= 1;
pauseCtx->cursorPoint[PAUSE_EQUIP] -= 1; pauseCtx->cursorPoint[PAUSE_EQUIP] -= 1;
@ -216,7 +217,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
cursorMoveResult = 3; cursorMoveResult = 3;
} }
} }
} else if (pauseCtx->stickRelX > 30) { } else if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
if (pauseCtx->cursorX[PAUSE_EQUIP] < 3) { if (pauseCtx->cursorX[PAUSE_EQUIP] < 3) {
pauseCtx->cursorX[PAUSE_EQUIP] += 1; pauseCtx->cursorX[PAUSE_EQUIP] += 1;
pauseCtx->cursorPoint[PAUSE_EQUIP] += 1; pauseCtx->cursorPoint[PAUSE_EQUIP] += 1;
@ -264,7 +265,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
cursorMoveResult = 0; cursorMoveResult = 0;
while (cursorMoveResult == 0) { while (cursorMoveResult == 0) {
if (pauseCtx->stickRelY > 30) { if ((pauseCtx->stickRelY > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
if (pauseCtx->cursorY[PAUSE_EQUIP] != 0) { if (pauseCtx->cursorY[PAUSE_EQUIP] != 0) {
pauseCtx->cursorY[PAUSE_EQUIP] -= 1; pauseCtx->cursorY[PAUSE_EQUIP] -= 1;
pauseCtx->cursorPoint[PAUSE_EQUIP] -= 4; pauseCtx->cursorPoint[PAUSE_EQUIP] -= 4;
@ -286,7 +287,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint;
cursorMoveResult = 3; cursorMoveResult = 3;
} }
} else if (pauseCtx->stickRelY < -30) { } else if ((pauseCtx->stickRelY < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) {
if (pauseCtx->cursorY[PAUSE_EQUIP] < 3) { if (pauseCtx->cursorY[PAUSE_EQUIP] < 3) {
pauseCtx->cursorY[PAUSE_EQUIP] += 1; pauseCtx->cursorY[PAUSE_EQUIP] += 1;
pauseCtx->cursorPoint[PAUSE_EQUIP] += 4; pauseCtx->cursorPoint[PAUSE_EQUIP] += 4;
@ -309,7 +310,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
} }
} }
} else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) {
if (pauseCtx->stickRelX > 30) { if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
@ -356,7 +357,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
} }
} }
} else { } else {
if (pauseCtx->stickRelX < -30) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);

View file

@ -96,6 +96,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
s16 cursorY; s16 cursorY;
s16 oldCursorPoint; s16 oldCursorPoint;
s16 moveCursorResult; s16 moveCursorResult;
bool dpad = CVar_GetS32("gDpadPauseName", 0);
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_item.c", 234); OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_item.c", 234);
@ -120,7 +121,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
pauseCtx->stickRelX = 40; pauseCtx->stickRelX = 40;
} }
if (ABS(pauseCtx->stickRelX) > 30) { if ((ABS(pauseCtx->stickRelX) > 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT | BTN_DRIGHT))) {
cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM];
cursorX = pauseCtx->cursorX[PAUSE_ITEM]; cursorX = pauseCtx->cursorX[PAUSE_ITEM];
cursorY = pauseCtx->cursorY[PAUSE_ITEM]; cursorY = pauseCtx->cursorY[PAUSE_ITEM];
@ -132,7 +133,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
if (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]) {} if (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]) {}
while (moveCursorResult == 0) { while (moveCursorResult == 0) {
if (pauseCtx->stickRelX < -30) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
if (pauseCtx->cursorX[PAUSE_ITEM] != 0) { if (pauseCtx->cursorX[PAUSE_ITEM] != 0) {
pauseCtx->cursorX[PAUSE_ITEM] -= 1; pauseCtx->cursorX[PAUSE_ITEM] -= 1;
pauseCtx->cursorPoint[PAUSE_ITEM] -= 1; pauseCtx->cursorPoint[PAUSE_ITEM] -= 1;
@ -164,7 +165,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
moveCursorResult = 2; moveCursorResult = 2;
} }
} }
} else if (pauseCtx->stickRelX > 30) { } else if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
if (pauseCtx->cursorX[PAUSE_ITEM] < 5) { if (pauseCtx->cursorX[PAUSE_ITEM] < 5) {
pauseCtx->cursorX[PAUSE_ITEM] += 1; pauseCtx->cursorX[PAUSE_ITEM] += 1;
pauseCtx->cursorPoint[PAUSE_ITEM] += 1; pauseCtx->cursorPoint[PAUSE_ITEM] += 1;
@ -208,7 +209,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
cursorItem, pauseCtx->cursorSpecialPos); cursorItem, pauseCtx->cursorSpecialPos);
} }
} else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) {
if (pauseCtx->stickRelX > 30) { if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
@ -242,7 +243,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
} }
} }
} else { } else {
if (pauseCtx->stickRelX < -30) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
@ -280,13 +281,13 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
if (pauseCtx->cursorSpecialPos == 0) { if (pauseCtx->cursorSpecialPos == 0) {
if (cursorItem != PAUSE_ITEM_NONE) { if (cursorItem != PAUSE_ITEM_NONE) {
if (ABS(pauseCtx->stickRelY) > 30) { if ((ABS(pauseCtx->stickRelY) > 30) || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
moveCursorResult = 0; moveCursorResult = 0;
cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM];
cursorY = pauseCtx->cursorY[PAUSE_ITEM]; cursorY = pauseCtx->cursorY[PAUSE_ITEM];
while (moveCursorResult == 0) { while (moveCursorResult == 0) {
if (pauseCtx->stickRelY > 30) { if ((pauseCtx->stickRelY > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
if (pauseCtx->cursorY[PAUSE_ITEM] != 0) { if (pauseCtx->cursorY[PAUSE_ITEM] != 0) {
pauseCtx->cursorY[PAUSE_ITEM] -= 1; pauseCtx->cursorY[PAUSE_ITEM] -= 1;
pauseCtx->cursorPoint[PAUSE_ITEM] -= 6; pauseCtx->cursorPoint[PAUSE_ITEM] -= 6;
@ -300,7 +301,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) {
moveCursorResult = 2; moveCursorResult = 2;
} }
} else if (pauseCtx->stickRelY < -30) { } else if ((pauseCtx->stickRelY < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) {
if (pauseCtx->cursorY[PAUSE_ITEM] < 3) { if (pauseCtx->cursorY[PAUSE_ITEM] < 3) {
pauseCtx->cursorY[PAUSE_ITEM] += 1; pauseCtx->cursorY[PAUSE_ITEM] += 1;
pauseCtx->cursorPoint[PAUSE_ITEM] += 6; pauseCtx->cursorPoint[PAUSE_ITEM] += 6;

View file

@ -36,6 +36,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
static u16 mapBgPulseStage = 0; static u16 mapBgPulseStage = 0;
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
PauseContext* pauseCtx = &globalCtx->pauseCtx; PauseContext* pauseCtx = &globalCtx->pauseCtx;
Input* input = &globalCtx->state.input[0];
s16 i; s16 i;
s16 j; s16 j;
s16 oldCursorPoint; s16 oldCursorPoint;
@ -43,6 +44,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
s16 stepG; s16 stepG;
s16 stepB; s16 stepB;
u16 rgba16; u16 rgba16;
bool dpad = CVar_GetS32("gDpadPauseName", 0);
OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 123); OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 123);
@ -51,7 +53,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MAP]; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MAP];
if (pauseCtx->cursorSpecialPos == 0) { if (pauseCtx->cursorSpecialPos == 0) {
if (pauseCtx->stickRelX > 30) { if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
if (pauseCtx->cursorX[PAUSE_MAP] != 0) { if (pauseCtx->cursorX[PAUSE_MAP] != 0) {
KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT);
} else { } else {
@ -67,7 +69,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
} }
} }
} }
} else if (pauseCtx->stickRelX < -30) { } else if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
if (pauseCtx->cursorX[PAUSE_MAP] == 0) { if (pauseCtx->cursorX[PAUSE_MAP] == 0) {
KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT); KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT);
} else { } else {
@ -82,7 +84,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
} }
if (pauseCtx->cursorPoint[PAUSE_MAP] < 3) { if (pauseCtx->cursorPoint[PAUSE_MAP] < 3) {
if (pauseCtx->stickRelY > 30) { if ((pauseCtx->stickRelY > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
if (pauseCtx->cursorPoint[PAUSE_MAP] != 0) { if (pauseCtx->cursorPoint[PAUSE_MAP] != 0) {
for (i = pauseCtx->cursorPoint[PAUSE_MAP] - 1; i >= 0; i--) { for (i = pauseCtx->cursorPoint[PAUSE_MAP] - 1; i >= 0; i--) {
if (CHECK_DUNGEON_ITEM(i, gSaveContext.mapIndex)) { if (CHECK_DUNGEON_ITEM(i, gSaveContext.mapIndex)) {
@ -92,7 +94,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
} }
} }
} else { } else {
if (pauseCtx->stickRelY < -30) { if ((pauseCtx->stickRelY < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) {
if (pauseCtx->cursorPoint[PAUSE_MAP] != 2) { if (pauseCtx->cursorPoint[PAUSE_MAP] != 2) {
for (i = pauseCtx->cursorPoint[PAUSE_MAP] + 1; i < 3; i++) { for (i = pauseCtx->cursorPoint[PAUSE_MAP] + 1; i < 3; i++) {
if (CHECK_DUNGEON_ITEM(i, gSaveContext.mapIndex)) { if (CHECK_DUNGEON_ITEM(i, gSaveContext.mapIndex)) {
@ -104,7 +106,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
} }
} }
} else { } else {
if (pauseCtx->stickRelY > 30) { if ((pauseCtx->stickRelY > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) {
if (pauseCtx->cursorPoint[PAUSE_MAP] >= 4) { if (pauseCtx->cursorPoint[PAUSE_MAP] >= 4) {
for (i = pauseCtx->cursorPoint[PAUSE_MAP] - 3 - 1; i >= 0; i--) { for (i = pauseCtx->cursorPoint[PAUSE_MAP] - 3 - 1; i >= 0; i--) {
if ((gSaveContext.sceneFlags[gSaveContext.mapIndex].floors & gBitFlags[i]) || if ((gSaveContext.sceneFlags[gSaveContext.mapIndex].floors & gBitFlags[i]) ||
@ -115,7 +117,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
} }
} }
} }
} else if (pauseCtx->stickRelY < -30) { } else if ((pauseCtx->stickRelY < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DDOWN))) {
if (pauseCtx->cursorPoint[PAUSE_MAP] != 10) { if (pauseCtx->cursorPoint[PAUSE_MAP] != 10) {
for (i = pauseCtx->cursorPoint[PAUSE_MAP] - 3 + 1; i < 11; i++) { for (i = pauseCtx->cursorPoint[PAUSE_MAP] - 3 + 1; i < 11; i++) {
if ((gSaveContext.sceneFlags[gSaveContext.mapIndex].floors & gBitFlags[i]) || if ((gSaveContext.sceneFlags[gSaveContext.mapIndex].floors & gBitFlags[i]) ||
@ -138,7 +140,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
} }
} }
} else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) {
if (pauseCtx->stickRelX > 30) { if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot; pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot;
@ -148,7 +150,7 @@ void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxC
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} }
} else { } else {
if (pauseCtx->stickRelX < -30) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
pauseCtx->cursorX[PAUSE_MAP] = 1; pauseCtx->cursorX[PAUSE_MAP] = 1;
@ -396,6 +398,7 @@ void KaleidoScope_DrawWorldMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx
}; };
static u16 D_8082A6D4 = 0; static u16 D_8082A6D4 = 0;
PauseContext* pauseCtx = &globalCtx->pauseCtx; PauseContext* pauseCtx = &globalCtx->pauseCtx;
Input* input = &globalCtx->state.input[0];
s16 i; s16 i;
s16 j; s16 j;
s16 t; s16 t;
@ -404,6 +407,7 @@ void KaleidoScope_DrawWorldMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx
s16 stepR; s16 stepR;
s16 stepG; s16 stepG;
s16 stepB; s16 stepB;
bool dpad = CVar_GetS32("gDpadPauseName", 0);
OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 556); OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 556);
@ -412,7 +416,7 @@ void KaleidoScope_DrawWorldMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx
oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP];
if (pauseCtx->cursorSpecialPos == 0) { if (pauseCtx->cursorSpecialPos == 0) {
if (pauseCtx->stickRelX > 30) { if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
D_8082A6D4 = 0; D_8082A6D4 = 0;
do { do {
@ -423,7 +427,7 @@ void KaleidoScope_DrawWorldMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx
break; break;
} }
} while (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]] == 0); } while (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]] == 0);
} else if (pauseCtx->stickRelX < -30) { } else if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
D_8082A6D4 = 0; D_8082A6D4 = 0;
do { do {
@ -444,7 +448,7 @@ void KaleidoScope_DrawWorldMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx
} else { } else {
pauseCtx->cursorItem[PAUSE_MAP] = gSaveContext.worldMapArea + 0x18; pauseCtx->cursorItem[PAUSE_MAP] = gSaveContext.worldMapArea + 0x18;
if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) {
if (pauseCtx->stickRelX > 30) { if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 0; pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
@ -459,7 +463,7 @@ void KaleidoScope_DrawWorldMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx
D_8082A6D4 = 0; D_8082A6D4 = 0;
} }
} else { } else {
if (pauseCtx->stickRelX < -30) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 11; pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 11;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
@ -663,7 +667,7 @@ void KaleidoScope_DrawWorldMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx
gDPLoadTextureBlock(POLY_KAL_DISP++, gWorldMapDotTex, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0, G_TX_WRAP | G_TX_NOMIRROR, gDPLoadTextureBlock(POLY_KAL_DISP++, gWorldMapDotTex, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0, G_TX_WRAP | G_TX_NOMIRROR,
G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
for (j = i = 0; i < 12; i++, t++, j += 4) { for (j = t = i = 0; i < 12; i++, t++, j += 4) {
if (pauseCtx->worldMapPoints[i] != 0) { if (pauseCtx->worldMapPoints[i] != 0) {
gDPPipeSync(POLY_KAL_DISP++); gDPPipeSync(POLY_KAL_DISP++);

View file

@ -7,12 +7,13 @@ void KaleidoScope_UpdatePrompt(GlobalContext* globalCtx) {
Input* input = &globalCtx->state.input[0]; Input* input = &globalCtx->state.input[0];
s8 relStickX = input->rel.stick_x; s8 relStickX = input->rel.stick_x;
s16 step; s16 step;
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (((pauseCtx->state == 7) && (pauseCtx->unk_1EC == 1)) || (pauseCtx->state == 0xE) || (pauseCtx->state == 0x10)) { if (((pauseCtx->state == 7) && (pauseCtx->unk_1EC == 1)) || (pauseCtx->state == 0xE) || (pauseCtx->state == 0x10)) {
if ((pauseCtx->promptChoice == 0) && (relStickX >= 30)) { if ((pauseCtx->promptChoice == 0) && ((relStickX >= 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)))) {
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
pauseCtx->promptChoice = 4; pauseCtx->promptChoice = 4;
} else if ((pauseCtx->promptChoice != 0) && (relStickX <= -30)) { } else if ((pauseCtx->promptChoice != 0) && ((relStickX <= -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT)))) {
Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
pauseCtx->promptChoice = 0; pauseCtx->promptChoice = 0;
} }

View file

@ -936,8 +936,9 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) {
return; return;
} }
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) {
if (pauseCtx->stickRelX < -30) { if ((pauseCtx->stickRelX < -30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DLEFT))) {
pauseCtx->pageSwitchTimer++; pauseCtx->pageSwitchTimer++;
if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) { if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) {
KaleidoScope_SwitchPage(pauseCtx, 0); KaleidoScope_SwitchPage(pauseCtx, 0);
@ -946,7 +947,7 @@ void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) {
pauseCtx->pageSwitchTimer = -1; pauseCtx->pageSwitchTimer = -1;
} }
} else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) { } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) {
if (pauseCtx->stickRelX > 30) { if ((pauseCtx->stickRelX > 30) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DRIGHT))) {
pauseCtx->pageSwitchTimer++; pauseCtx->pageSwitchTimer++;
if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) { if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) {
KaleidoScope_SwitchPage(pauseCtx, 2); KaleidoScope_SwitchPage(pauseCtx, 2);