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
This commit is contained in:
badblocks 2023-05-18 14:52:57 -07:00
parent 8ddd30bbb4
commit 91898b81fb
No known key found for this signature in database
2 changed files with 34 additions and 1 deletions

View file

@ -4,6 +4,7 @@
#include "save_basic.h" #include "save_basic.h"
static gameDataSav save_data = {0}; static gameDataSav save_data = {0};
static Hashes HASHES = {.PLAYER_POSITION = 0xa40ba103};
void openSave() { void openSave() {
Result rc = 0; Result rc = 0;
@ -37,7 +38,26 @@ void openSave() {
printf("Save data mounted successfully!\n"); 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() { void processSave() {
printf("Processing save data...\n"); printf("Processing save data...\n");
// TODO: Implement actual save processing // TODO: Load save file into memory for processing
}
void writeSave() {
printf("Writing save data...\n");
// TODO: Write modified data back to save file
} }

View file

@ -9,7 +9,20 @@ typedef struct
char * saveFile; char * saveFile;
} gameDataSav; } gameDataSav;
typedef struct {
u32 PLAYER_POSITION;
} Hashes;
typedef union Float {
float m_float;
u8 m_bytes[sizeof(float)];
} Float;
u32 readU32FromAddr(u32 addr);
float readF32FromAddr(u32 addr);
void writeF32ToAddr(u32 addr, float value);
void processSave(); void processSave();
void openSave(); void openSave();
void writeSave();
#endif #endif