Fix PSP compiled
This commit is contained in:
@@ -10,8 +10,8 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
if(NOT DEFINED DUSK_TARGET_SYSTEM)
|
||||
#set(DUSK_TARGET_SYSTEM "linux")
|
||||
set(DUSK_TARGET_SYSTEM "psp")
|
||||
set(DUSK_TARGET_SYSTEM "linux")
|
||||
#set(DUSK_TARGET_SYSTEM "psp")
|
||||
endif()
|
||||
|
||||
# Prep cache
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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!
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "scene/scenedata.h"
|
||||
|
||||
errorret_t sceneTestInit(scenedata_t *data) {
|
||||
printf("Scene Test Init\n");
|
||||
data->sceneTest.nothing = 0;
|
||||
errorOk();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
Reference in New Issue
Block a user