Cleanup
This commit is contained in:
@@ -47,10 +47,12 @@ errorret_t assetInitDolphinFAT(void) {
|
||||
if(foundPath[0] != '\0') break;
|
||||
} while(*(++dolphinSearchPath) != NULL);
|
||||
|
||||
if(foundPath[0] == '\0') errorThrow("Failed to find asset file on FAT filesystem.");
|
||||
if(foundPath[0] == '\0')
|
||||
errorThrow("Failed to find asset file on FAT filesystem.");
|
||||
|
||||
ASSET.zip = zip_open(foundPath, ZIP_RDONLY, NULL);
|
||||
if(ASSET.zip == NULL) errorThrow("Failed to open asset file on FAT filesystem.");
|
||||
if(ASSET.zip == NULL)
|
||||
errorThrow("Failed to open asset file on FAT filesystem.");
|
||||
|
||||
errorOk();
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#include "error/error.h"
|
||||
#include "display/displaystate.h"
|
||||
|
||||
#define DISPLAY_DOLPHIN_FIFO_SIZE (256*1024)
|
||||
#define DISPLAY_DOLPHIN_FIFO_SIZE (256*1024)
|
||||
|
||||
typedef struct {
|
||||
void *frameBuffer[2];// Double-Bufferred
|
||||
int whichFrameBuffer;
|
||||
void *frameBuffer[2]; // Double-Bufferred
|
||||
int_t whichFrameBuffer;
|
||||
GXRModeObj *screenMode;
|
||||
void *fifoBuffer;
|
||||
} displaydolphin_t;
|
||||
|
||||
@@ -25,14 +25,14 @@ errorret_t textureInitDolphin(
|
||||
|
||||
for(uint32_t y = 0; y < height; ++y) {
|
||||
for(uint32_t x = 0; x < width; ++x) {
|
||||
const int src = y * width + x;
|
||||
const int_t src = y * width + x;
|
||||
|
||||
const int tileX = x >> 2;
|
||||
const int tileY = y >> 2;
|
||||
const int tilesPerRow = width >> 2;
|
||||
const int tileIndex = tileY * tilesPerRow + tileX;
|
||||
const int inTile = ((y & 3) << 2) + (x & 3);
|
||||
const int tileBase = tileIndex * 64;
|
||||
const int_t tileX = x >> 2;
|
||||
const int_t tileY = y >> 2;
|
||||
const int_t tilesPerRow = width >> 2;
|
||||
const int_t tileIndex = tileY * tilesPerRow + tileX;
|
||||
const int_t inTile = ((y & 3) << 2) + (x & 3);
|
||||
const int_t tileBase = tileIndex * 64;
|
||||
|
||||
color_t col = data.rgbaColors[src];
|
||||
|
||||
|
||||
@@ -12,32 +12,84 @@
|
||||
|
||||
inputbuttondata_t INPUT_BUTTON_DATA[] = {
|
||||
#ifdef DUSK_INPUT_GAMEPAD
|
||||
{ .name = "a", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_A } },
|
||||
{ .name = "b", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_B } },
|
||||
{ .name = "x", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_X } },
|
||||
{ .name = "y", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_Y } },
|
||||
{ .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_START } },
|
||||
{ .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_UP } },
|
||||
{ .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_DOWN } },
|
||||
{ .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_LEFT } },
|
||||
{ .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_RIGHT } },
|
||||
{ .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_L } },
|
||||
{ .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_R } },
|
||||
{ .name = "z", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_Z } },
|
||||
{ .name = "menu", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_MENU } },
|
||||
{ .name = "a", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_A } },
|
||||
{ .name = "b", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_B } },
|
||||
{ .name = "x", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_X } },
|
||||
{ .name = "y", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_Y } },
|
||||
{ .name = "start", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_START } },
|
||||
{ .name = "up", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_UP } },
|
||||
{ .name = "down", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_DOWN } },
|
||||
{ .name = "left", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_LEFT } },
|
||||
{ .name = "right", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_RIGHT } },
|
||||
{ .name = "l", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_TRIGGER_L } },
|
||||
{ .name = "r", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_TRIGGER_R } },
|
||||
{ .name = "z", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_TRIGGER_Z } },
|
||||
{ .name = "menu", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
.gpButton = PAD_BUTTON_MENU } },
|
||||
|
||||
{ .name = "lstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = true } } },
|
||||
{ .name = "lstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = false } } },
|
||||
{ .name = "lstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = false } } },
|
||||
{ .name = "lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = true } } },
|
||||
{ .name = "lstick_up", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = true } } },
|
||||
{ .name = "lstick_down", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = false } } },
|
||||
{ .name = "lstick_left", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = false } } },
|
||||
{ .name = "lstick_right", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = true } } },
|
||||
|
||||
{ .name = "rstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = true } } },
|
||||
{ .name = "rstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = false } } },
|
||||
{ .name = "rstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = true } } },
|
||||
{ .name = "rstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = false } } },
|
||||
{ .name = "lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = false } } },
|
||||
{ .name = "ltrigger", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_TRIGGER_LEFT, .positive = true } } },
|
||||
{ .name = "rtrigger", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_TRIGGER_RIGHT, .positive = true } } },
|
||||
{ .name = "rstick_up", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = true } } },
|
||||
{ .name = "rstick_down", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = false } } },
|
||||
{ .name = "rstick_left", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = true } } },
|
||||
{ .name = "rstick_right", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = false } } },
|
||||
{ .name = "lstick_right", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = false } } },
|
||||
{ .name = "ltrigger", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = {
|
||||
.axis = INPUT_GAMEPAD_AXIS_TRIGGER_LEFT,
|
||||
.positive = true } } },
|
||||
{ .name = "rtrigger", {
|
||||
.type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
.gpAxis = {
|
||||
.axis = INPUT_GAMEPAD_AXIS_TRIGGER_RIGHT,
|
||||
.positive = true } } },
|
||||
#endif
|
||||
|
||||
{ .name = NULL }
|
||||
|
||||
@@ -114,7 +114,7 @@ void logError(const char_t *message, ...) {
|
||||
va_end(copy);
|
||||
va_end(args);
|
||||
|
||||
// PAD_Init is idempotent — safe to call even if inputInit already called it,
|
||||
// PAD_Init is idempotent — safe even if inputInit already called it,
|
||||
// and handles the case where the error occurred before inputInit ran.
|
||||
PAD_Init();
|
||||
while(SYS_MainLoop()) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// /**
|
||||
// * Copyright (c) 2026 Dominic Masters
|
||||
// *
|
||||
// * This software is released under the MIT License.
|
||||
// * https://opensource.org/licenses/MIT
|
||||
// */
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "network/network.h"
|
||||
#include "util/memory.h"
|
||||
@@ -103,7 +103,7 @@ networkinfo_t networkDolphinGetInfo() {
|
||||
memoryZero(&info, sizeof(networkinfo_t));
|
||||
|
||||
info.type = NETWORK_TYPE_IPV4;
|
||||
int ret = sscanf(
|
||||
int_t ret = sscanf(
|
||||
NETWORK.platform.ip,
|
||||
"%hhu.%hhu.%hhu.%hhu",
|
||||
&info.ipv4.ip[0],
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
#include "util/memory.h"
|
||||
#include "util/string.h"
|
||||
|
||||
static void _saveGetFileName(const uint8_t slot, char_t *out, const size_t max) {
|
||||
static void _saveGetFileName(
|
||||
const uint8_t slot, char_t *out, const size_t max
|
||||
) {
|
||||
snprintf(out, max, "%s_%u", SAVE_DOLPHIN_GAME_CODE, (uint32_t)slot);
|
||||
}
|
||||
|
||||
@@ -42,7 +44,9 @@ errorret_t saveLoadDolphin(const uint8_t slot, savefile_t *file) {
|
||||
char_t fileName[SAVE_DOLPHIN_FILE_NAME_MAX];
|
||||
_saveGetFileName(slot, fileName, SAVE_DOLPHIN_FILE_NAME_MAX);
|
||||
|
||||
int32_t result = CARD_Open(SAVE_DOLPHIN_CHANNEL, fileName, &SAVE.platform.cardFile);
|
||||
int32_t result = CARD_Open(
|
||||
SAVE_DOLPHIN_CHANNEL, fileName, &SAVE.platform.cardFile
|
||||
);
|
||||
if(result == CARD_ERROR_NOFILE) {
|
||||
file->exists = false;
|
||||
errorOk();
|
||||
@@ -54,17 +58,19 @@ errorret_t saveLoadDolphin(const uint8_t slot, savefile_t *file) {
|
||||
);
|
||||
}
|
||||
|
||||
void *buffer = memalign(32, SAVE_DOLPHIN_SECTOR_SIZE);
|
||||
void *buffer = memoryAlign(32, SAVE_DOLPHIN_SECTOR_SIZE);
|
||||
if(!buffer) {
|
||||
CARD_Close(&SAVE.platform.cardFile);
|
||||
errorThrow("Failed to allocate memory card read buffer");
|
||||
}
|
||||
|
||||
result = CARD_Read(&SAVE.platform.cardFile, buffer, SAVE_DOLPHIN_SECTOR_SIZE, 0);
|
||||
result = CARD_Read(
|
||||
&SAVE.platform.cardFile, buffer, SAVE_DOLPHIN_SECTOR_SIZE, 0
|
||||
);
|
||||
CARD_Close(&SAVE.platform.cardFile);
|
||||
|
||||
if(result < 0) {
|
||||
free(buffer);
|
||||
memoryFree(buffer);
|
||||
file->exists = false;
|
||||
errorThrow("Failed to read memory card data for slot %u (error %d)",
|
||||
(uint32_t)slot, result
|
||||
@@ -72,7 +78,7 @@ errorret_t saveLoadDolphin(const uint8_t slot, savefile_t *file) {
|
||||
}
|
||||
|
||||
memoryCopy(file, buffer, sizeof(savefile_t));
|
||||
free(buffer);
|
||||
memoryFree(buffer);
|
||||
|
||||
file->exists = true;
|
||||
errorOk();
|
||||
@@ -82,15 +88,17 @@ errorret_t saveWriteDolphin(const uint8_t slot, const savefile_t *file) {
|
||||
char_t fileName[SAVE_DOLPHIN_FILE_NAME_MAX];
|
||||
_saveGetFileName(slot, fileName, SAVE_DOLPHIN_FILE_NAME_MAX);
|
||||
|
||||
void *buffer = memalign(32, SAVE_DOLPHIN_SECTOR_SIZE);
|
||||
void *buffer = memoryAlign(32, SAVE_DOLPHIN_SECTOR_SIZE);
|
||||
if(!buffer) {
|
||||
errorThrow("Failed to allocate memory card write buffer");
|
||||
}
|
||||
memset(buffer, 0, SAVE_DOLPHIN_SECTOR_SIZE);
|
||||
memoryZero(buffer, SAVE_DOLPHIN_SECTOR_SIZE);
|
||||
memoryCopy(buffer, file, sizeof(savefile_t));
|
||||
|
||||
// Try open existing file first; create if absent.
|
||||
int32_t result = CARD_Open(SAVE_DOLPHIN_CHANNEL, fileName, &SAVE.platform.cardFile);
|
||||
int32_t result = CARD_Open(
|
||||
SAVE_DOLPHIN_CHANNEL, fileName, &SAVE.platform.cardFile
|
||||
);
|
||||
if(result == CARD_ERROR_NOFILE) {
|
||||
result = CARD_Create(
|
||||
SAVE_DOLPHIN_CHANNEL,
|
||||
@@ -101,15 +109,17 @@ errorret_t saveWriteDolphin(const uint8_t slot, const savefile_t *file) {
|
||||
}
|
||||
|
||||
if(result < 0) {
|
||||
free(buffer);
|
||||
memoryFree(buffer);
|
||||
errorThrow("Failed to open/create memory card file for slot %u (error %d)",
|
||||
(uint32_t)slot, result
|
||||
);
|
||||
}
|
||||
|
||||
result = CARD_Write(&SAVE.platform.cardFile, buffer, SAVE_DOLPHIN_SECTOR_SIZE, 0);
|
||||
result = CARD_Write(
|
||||
&SAVE.platform.cardFile, buffer, SAVE_DOLPHIN_SECTOR_SIZE, 0
|
||||
);
|
||||
CARD_Close(&SAVE.platform.cardFile);
|
||||
free(buffer);
|
||||
memoryFree(buffer);
|
||||
|
||||
if(result < 0) {
|
||||
errorThrow("Failed to write memory card data for slot %u (error %d)",
|
||||
|
||||
Reference in New Issue
Block a user