N64: Save file fix and fix (#1072)

Got rid of the annoying message you get when opening the menu in a game that uses cpak.
It said "Saving..." even when there wasn't anything to save.
Cleaned up and refactored the save file code. Much easier to follow now.
This commit is contained in:
Rikard Bengtsson
2025-12-12 06:18:05 +01:00
committed by GitHub
parent 7d912245c3
commit ba0ae19cd2
3 changed files with 131 additions and 99 deletions

View File

@@ -3069,7 +3069,7 @@ void user_io_poll()
int ack = 0;
int op = 0;
static uint8_t buffer[16][16384];
uint64_t lba;
uint64_t lba = 0;
uint32_t blksz, blks, sz;
if (is_uneon() && i == 3)
@@ -3161,9 +3161,11 @@ void user_io_poll()
else if (op & 1) c64_readGCR(disk, lba, blks-1);
else break;
}
else if ((op == 2) && is_n64() && use_save)
else if (is_n64() && n64_process_save(use_save, op, lba, blksz, ack, buffer_lba[disk], buffer[disk], sizeof(*buffer), sz))
{
n64_save_savedata(lba, ack, buffer_lba[disk], buffer[disk], blksz, sz);
// Handled by N64 core logic.
// If n64_process_save returns false (e.g. use_save is off, or unsupported op),
// it will fall through to the generic handler below.
}
else if (op == 2)
{
@@ -3215,10 +3217,6 @@ void user_io_poll()
}
}
}
else if ((op & 1) && is_n64() && use_save)
{
n64_load_savedata(lba, ack, buffer_lba[disk], buffer[disk], sizeof(*buffer), blksz, sz);
}
else if (op & 1)
{
uint32_t buf_n = sizeof(buffer[0]) / blksz;