botw-completer/source/save_basic.c
badbl0cks 91898b81fb
Expand save system with data access framework
- Add Hashes struct for known save file offsets
- Add Float union for type conversion
- Implement placeholder functions for:
  * Reading u32/float from addresses
  * Writing float to addresses
  * Save file writing
- Add player position hash constant
2023-05-18 14:52:57 -07:00

63 lines
No EOL
1.5 KiB
C

#include <string.h>
#include <stdio.h>
#include <switch.h>
#include "save_basic.h"
static gameDataSav save_data = {0};
static Hashes HASHES = {.PLAYER_POSITION = 0xa40ba103};
void openSave() {
Result rc = 0;
AccountUid uid = {0};
u64 application_id = 0x01007ef00011e000; // BOTW Application ID
printf("Opening BOTW save data...\n");
// Get user account
rc = accountInitialize(AccountServiceType_Application);
if (R_FAILED(rc)) {
printf("accountInitialize() failed: 0x%x\n", rc);
return;
}
rc = accountGetPreselectedUser(&uid);
accountExit();
if (R_FAILED(rc)) {
printf("accountGetPreselectedUser() failed: 0x%x\n", rc);
return;
}
// Mount save data
rc = fsdevMountSaveData("save", application_id, uid);
if (R_FAILED(rc)) {
printf("fsdevMountSaveData() failed: 0x%x\n", rc);
return;
}
printf("Save data mounted successfully!\n");
}
u32 readU32FromAddr(u32 addr) {
// TODO: Implement reading u32 from save file address
return 0;
}
float readF32FromAddr(u32 addr) {
// TODO: Implement reading float from save file address
return 0.0f;
}
void writeF32ToAddr(u32 addr, float value) {
// TODO: Implement writing float to save file address
}
void processSave() {
printf("Processing save data...\n");
// TODO: Load save file into memory for processing
}
void writeSave() {
printf("Writing save data...\n");
// TODO: Write modified data back to save file
}