Starship/src/main/sys_save.c
petrie911 af26374677
Match Matrix_Scale, change some file names (#52)
* stuff

* three whole files

* format

* format and such

* a switch in time

* merge prep

* nintendo switch

* format

* the great switch statement of our time

* 43AC0 matched

* stuff

* Enums everywhere

* oh god the switch

* knakyo

* new headers

* format

* fox

* everyone hates recursion

* format

* one more thing

* one more one more thing

* renames

* matches

* matrix scale why

* names and such

* cleanup

* name back
2023-12-15 17:09:49 -03:00

66 lines
1.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "global.h"
SaveFile gSaveIOBuffer;
SaveFile sPrevSaveData;
s32 Save_ReadBlock(s32 arg0, u8* arg1) {
if (osEepromRead(&gSerialEventQueue, arg0, arg1)) {
(void) " インターフェース回路反応なし ()\n";
return -1;
}
(void) "EEPROM READ %02X: %02X %02X %02X %02X %02X %02X %02X %02X\n";
return 0;
}
s32 Save_WriteBlock(s32 arg0, u8* arg1) {
if (osEepromWrite(&gSerialEventQueue, arg0, arg1)) {
(void) " インターフェース回路反応なし ()\n";
return -1;
}
Timer_Wait(MSEC_TO_CYCLES(15));
(void) "EEPROM WRITE %02X: %02X %02X %02X %02X %02X %02X %02X %02X\n";
return 0;
}
s32 Save_WriteEeprom(SaveFile* arg0) {
s32 var_a2;
s32 i;
s32 j;
if (osEepromProbe(&gSerialEventQueue) != 1) {
(void) " が ありません\n";
return -1;
}
for (i = 0; i < EEPROM_MAXBLOCKS; i++) {
var_a2 = 0;
for (j = 0; j < EEPROM_BLOCK_SIZE; j++) {
if (((char*) &sPrevSaveData)[EEPROM_BLOCK_SIZE * i + j] != ((char*) arg0)[EEPROM_BLOCK_SIZE * i + j]) {
((char*) &sPrevSaveData)[EEPROM_BLOCK_SIZE * i + j] = ((char*) arg0)[EEPROM_BLOCK_SIZE * i + j];
var_a2 = 1;
}
}
if ((var_a2 == 1) && Save_WriteBlock(i, &((char*) arg0)[EEPROM_BLOCK_SIZE * i])) {
return -1;
}
}
return 0;
}
s32 Save_ReadEeprom(SaveFile* arg0) {
s32 i;
if (osEepromProbe(&gSerialEventQueue) != 1) {
(void) " が ありません\n";
return -1;
}
for (i = 0; i < EEPROM_MAXBLOCKS; i++) {
if (Save_ReadBlock(i, &((char*) arg0)[EEPROM_BLOCK_SIZE * i]) != 0) {
return -1;
}
}
sPrevSaveData = *arg0;
return 0;
}