Fix PSP compiled

This commit is contained in:
2025-11-09 20:42:03 -06:00
parent f23e26d9da
commit d6c497731f
10 changed files with 48 additions and 34 deletions

View File

@@ -6,6 +6,7 @@
*/
#include "assert.h"
#include "debug/debug.h"
#ifndef ASSERTIONS_FAKED
void assertTrueImpl(
@@ -15,13 +16,13 @@
const char *message
) {
if(x != true) {
fprintf(
stderr,
debugPrint(
"Assertion Failed in %s:%i\n\n%s\n",
file,
line,
message
);
abort();
}
}

View File

@@ -11,6 +11,7 @@
#include "assert/assert.h"
#include "asset/assettype.h"
#include "engine/engine.h"
#include "debug/debug.h"
errorret_t assetInit(void) {
memoryZero(&ASSET, sizeof(asset_t));
@@ -59,7 +60,10 @@ errorret_t assetInit(void) {
assertTrue(ENGINE.argc >= 1, "PSP requires launch argument.");
// PSP is given either host0:/Dusk.prx (debugging) OR the PBP file.
if(stringEndsWith(ENGINE.argv[0], ".pbp") || ASSET_PBP_READ_PBP_FROM_HOST) {
if(
stringEndsWithCaseInsensitive(ENGINE.argv[0], ".pbp") ||
ASSET_PBP_READ_PBP_FROM_HOST
) {
const char_t *pbpPath = (
ASSET_PBP_READ_PBP_FROM_HOST ? "./EBOOT.PBP" : ENGINE.argv[0]
);
@@ -152,7 +156,6 @@ errorret_t assetInit(void) {
);
// Try open
printf("Trying to open asset at: %s\n", searchPath);
ASSET.zip = zip_open(searchPath, ZIP_RDONLY, NULL);
if(ASSET.zip == NULL) continue;
break;// Found!

View File

@@ -30,7 +30,6 @@ errorret_t assetLanguageInit(
// We now own the zip file handle.
lang->zip = zipFile;
printf("Initialized language asset.\n");
// Read in the header.
zip_int64_t bytesRead = zip_fread(
@@ -108,6 +107,4 @@ void assetLanguageDispose(assetlanguage_t *lang) {
if(lang->zip) {
zip_fclose(lang->zip);
}
printf("Disposed language asset.\n");
}

View File

@@ -8,28 +8,6 @@
#include "debug.h"
void debugPrint(const char_t *message, ...) {
// char_t buffer[CONSOLE_LINE_MAX];
// va_list args;
// va_start(args, message);
// int32_t len = stringFormatVA(buffer, CONSOLE_LINE_MAX, message, args);
// va_end(args);
// // Move all lines back
// memoryMove(
// CONSOLE.line[0],
// CONSOLE.line[1],
// (CONSOLE_HISTORY_MAX - 1) * CONSOLE_LINE_MAX
// );
// // Copy the new line
// memoryCopy(
// CONSOLE.line[CONSOLE_HISTORY_MAX - 1],
// buffer,
// len + 1
// );
// printf("%s\n", buffer);
va_list args;
va_start(args, message);
vprintf(message, args);
@@ -37,4 +15,14 @@ void debugPrint(const char_t *message, ...) {
// For the time being just use standard printing functions.
printf(message, args);
#if PSP
FILE *file = fopen("ms0:/PSP/GAME/Dusk/debug.log", "a");
if(file) {
va_start(args, message);
vfprintf(file, message, args);
va_end(args);
fclose(file);
}
#endif
}

View File

@@ -15,6 +15,7 @@
#include "asset/asset.h"
#include "ui/ui.h"
#include "rpg/rpg.h"
#include "debug/debug.h"
engine_t ENGINE;
@@ -24,6 +25,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
ENGINE.argc = argc;
ENGINE.argv = argv;
// Init systems. Order is important.
timeInit();
inputInit();
@@ -46,6 +48,7 @@ errorret_t engineUpdate(void) {
sceneManagerUpdate();
errorChain(displayUpdate());
if(inputPressed(INPUT_ACTION_RAGEQUIT)) ENGINE.running = false;
errorOk();

View File

@@ -9,6 +9,7 @@
#include "error.h"
#include "util/memory.h"
#include "util/string.h"
#include "debug/debug.h"
errorret_t errorThrowImpl(
errorstate_t *state,
@@ -120,7 +121,7 @@ errorret_t errorPrint(const errorret_t retval) {
assertNotNull(retval.state, "Error state cannot be NULL");
assertNotNull(retval.state->message, "Message cannot be NULL");
printf(
debugPrint(
ERROR_PRINT_FORMAT,
retval.state->code,
retval.state->message,

View File

@@ -9,7 +9,6 @@
#include "scene/scenedata.h"
errorret_t sceneTestInit(scenedata_t *data) {
printf("Scene Test Init\n");
data->sceneTest.nothing = 0;
errorOk();
}

View File

@@ -155,4 +155,17 @@ bool_t stringEndsWith(const char_t *str, const char_t *suffix) {
size_t suffixLen = strlen(suffix);
if(suffixLen > strLen) return false;
return strcmp(str + strLen - suffixLen, suffix) == 0;
}
bool_t stringEndsWithCaseInsensitive(
const char_t *str,
const char_t *suffix
) {
assertNotNull(str, "str must not be NULL");
assertNotNull(suffix, "suffix must not be NULL");
size_t strLen = strlen(str);
size_t suffixLen = strlen(suffix);
if(suffixLen > strLen) return false;
return strcasecmp(str + strLen - suffixLen, suffix) == 0;
}

View File

@@ -143,4 +143,13 @@ bool_t stringToF32(const char_t *str, float_t *out);
* @param suffix The suffix to check for.
* @return TRUE if the string ends with the suffix, FALSE otherwise.
*/
bool_t stringEndsWith(const char_t *str, const char_t *suffix);
bool_t stringEndsWith(const char_t *str, const char_t *suffix);
/**
* Determines if a string ends with a specified suffix, ignoring case.
*
* @param str The string to check.
* @param suffix The suffix to check for.
* @return TRUE if the string ends with the suffix, FALSE otherwise.
*/
bool_t stringEndsWithCaseInsensitive(const char_t *str, const char_t *suffix);