- Consolidate development files into final implementation - Replace basic prototypes with full feature implementations - Add complete hash-based save data access system - Implement advanced map pin management algorithms - Add comprehensive error handling and user feedback - Complete Korok seed database with all 908 locations
82 lines
2.6 KiB
C
82 lines
2.6 KiB
C
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <dirent.h>
|
|
#include <stdlib.h>
|
|
#include <math.h>
|
|
#include <switch.h>
|
|
#include "save.h"
|
|
#include "ui.h"
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
setvbuf(stdout, NULL, _IONBF, BUFSIZ); //do not line-buffer stdout
|
|
|
|
Result rc=0;
|
|
bool exit = false;
|
|
|
|
AccountUid uid={0};
|
|
u64 application_id=0x01007ef00011e000;//ApplicationId of the save to mount, in this case BOTW.
|
|
|
|
consoleInit(NULL);
|
|
|
|
// Configure our supported input layout: a single player with standard controller styles
|
|
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
|
|
|
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
|
PadState pad;
|
|
padInitializeDefault(&pad);
|
|
|
|
//draw main screen and menu
|
|
initUI();
|
|
|
|
//Get the userID for save mounting. To mount common savedata, use an all-zero userID.
|
|
|
|
//Try to find savedata to use with the above hard-coded TID + the userID from accountGetPreselectedUser(). Note that you can use either method.
|
|
//See the account example for getting account info for an userID.
|
|
//See also the app_controldata example for getting info for an application_id.
|
|
rc = accountInitialize(AccountServiceType_Application);
|
|
if (R_FAILED(rc)) {
|
|
printMessage("accountInitialize() failed: 0x%x\n", rc);
|
|
exit = true;
|
|
}
|
|
|
|
rc = accountGetPreselectedUser(&uid);
|
|
accountExit();
|
|
|
|
if (R_FAILED(rc)) {
|
|
printMessage("accountGetPreselectedUser() failed: 0x%x\n", rc);
|
|
exit = true;
|
|
}
|
|
|
|
//You can use any device-name. If you want multiple saves mounted at the same time, you must use different device-names for each one.
|
|
rc = fsdevMountSaveData("save", application_id, uid);//See also libnx fs.h/fs_dev.h
|
|
if (R_FAILED(rc)) {
|
|
printMessage("fsdevMountSaveData() failed: 0x%x\n", rc);
|
|
exit = true;
|
|
}
|
|
|
|
//At this point you can use the mounted device with standard stdio.
|
|
//After modifying savedata, in order for the changes to take affect you must use: rc = fsdevCommitDevice("save");
|
|
//See also libnx fs_dev.h for fsdevCommitDevice.
|
|
|
|
openSave();
|
|
processSave();
|
|
|
|
// Main loop
|
|
while(appletMainLoop() && !exit)
|
|
{
|
|
// Scan the gamepad. This should be done once for each frame
|
|
padUpdate(&pad);
|
|
|
|
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
|
u64 kDown = padGetButtonsDown(&pad);
|
|
|
|
exit = handleButtonPress(kDown);
|
|
|
|
consoleUpdate(NULL);
|
|
}
|
|
|
|
fsdevUnmountDevice("save");
|
|
consoleExit(NULL);
|
|
return 0;
|
|
}
|