Fixed a bunch of code inconsistencies

This commit is contained in:
2026-08-31 07:02:19 -05:00
parent 320c5e6ce5
commit fcf0de72af
30 changed files with 1033 additions and 619 deletions
+2 -1
View File
@@ -6,6 +6,7 @@
*/
#include "log/log.h"
#include "log/logdolphin.h"
#include "display/display.h"
#include <stdio.h>
#include <stdlib.h>
@@ -20,7 +21,7 @@
static bool_t fatTried = false;
static bool_t fatReady = false;
static void logInitFAT(void) {
void logInitFAT(void) {
if(fatTried) return;
fatTried = true;
fatReady = fatInitDefault();
+18
View File
@@ -0,0 +1,18 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
#if DUSK_DOLPHIN_BUILD_TYPE == DOL
/**
* Lazily mounts the FAT filesystem (via fatInitDefault) the first time
* it's needed, so logDebug/logError can write to a file. Safe to call
* repeatedly - only the first call actually attempts the mount.
*/
void logInitFAT(void);
#endif
+1 -14
View File
@@ -129,20 +129,7 @@ bool_t saveDeviceDolphinCardHasFreeSpace(const int32_t channel) {
return usedBlocks < (uint32_t)blockCount;
}
// One probe result for one of the two ping-pong slots.
typedef struct {
bool_t valid;
uint32_t generation;
uint8_t *buffer;// only set if keepBuffer was requested, else NULL
uint32_t len;
} savedevicedolphincardslot_t;
// Opens the given card file (if it exists) and validates it as a raw save
// blob via saveDeviceRawIsValid(). CARD_Read requires a 32-byte aligned
// buffer, so the read (and any buffer kept for the caller) uses memoryAlign
// rather than memoryAllocate. If keepBuffer is false, or the file doesn't
// exist/validate, no buffer is left allocated.
static savedevicedolphincardslot_t saveDeviceDolphinCardProbeSlot(
savedevicedolphincardslot_t saveDeviceDolphinCardProbeSlot(
const int32_t channel,
const char_t *filename,
const bool_t keepBuffer
@@ -97,6 +97,33 @@ bool_t saveDeviceDolphinCardHasFreeSpace(const int32_t channel);
*/
errorret_t saveDeviceDolphinCardDispose(savedevice_t *device);
// One probe result for one of the two ping-pong slots.
typedef struct {
bool_t valid;
uint32_t generation;
uint8_t *buffer;// only set if keepBuffer was requested, else NULL
uint32_t len;
} savedevicedolphincardslot_t;
/**
* Opens the given card file (if it exists) and validates it as a raw save
* blob via saveDeviceRawIsValid(). CARD_Read requires a 32-byte aligned
* buffer, so the read (and any buffer kept for the caller) uses memoryAlign
* rather than memoryAllocate. If keepBuffer is false, or the file doesn't
* exist/validate, no buffer is left allocated.
*
* @param channel The CARD slot (CARD_SLOTA or CARD_SLOTB) to probe.
* @param filename The card file name to open.
* @param keepBuffer Whether to keep the read buffer allocated on success.
* @return The probe result - valid is false if the file doesn't exist or
* doesn't validate as a raw save blob.
*/
savedevicedolphincardslot_t saveDeviceDolphinCardProbeSlot(
const int32_t channel,
const char_t *filename,
const bool_t keepBuffer
);
/**
* Writes the combined save data blob out to whichever of the two fixed
* card files (see SAVE_DEVICE_DOLPHIN_CARD_FILENAME_0/1 above) is not
+1 -1
View File
@@ -66,7 +66,7 @@ void saveDeviceDolphinNandCheckAvailability(savedevice_t *device) {
saveDeviceFireCallback(device);
}
static errorret_t saveDeviceDolphinNandGetDataPath(
errorret_t saveDeviceDolphinNandGetDataPath(
char_t *dest,
const size_t destSize
) {
@@ -62,6 +62,18 @@ void saveDeviceDolphinNandCheckAvailability(savedevice_t *device);
*/
errorret_t saveDeviceDolphinNandDispose(savedevice_t *device);
/**
* Builds the absolute path to the combined save data file.
*
* @param dest The destination buffer to write the path into.
* @param destSize The size of the destination buffer, exc. null terminator.
* @return Error state if any.
*/
errorret_t saveDeviceDolphinNandGetDataPath(
char_t *dest,
const size_t destSize
);
/**
* Writes the combined save data blob out to the NAND, replacing it
* atomically (write to a temp file, then swap it in via ISFS_Rename) so a
+1 -1
View File
@@ -67,7 +67,7 @@ void saveDeviceDolphinSDCheckAvailability(savedevice_t *device) {
saveDeviceFireCallback(device);
}
static errorret_t saveDeviceDolphinSDGetDataPath(
errorret_t saveDeviceDolphinSDGetDataPath(
char_t *dest,
const size_t destSize
) {
@@ -57,6 +57,15 @@ void saveDeviceDolphinSDCheckAvailability(savedevice_t *device);
*/
errorret_t saveDeviceDolphinSDDispose(savedevice_t *device);
/**
* Builds the absolute path to the combined save data file.
*
* @param dest The destination buffer to write the path into.
* @param destSize The size of the destination buffer, exc. null terminator.
* @return Error state if any.
*/
errorret_t saveDeviceDolphinSDGetDataPath(char_t *dest, const size_t destSize);
/**
* Writes the combined save data blob out to the SD card, replacing it
* atomically (write to a temp file, then swap it in) so a crash mid-write