From ddf842c86d3998146e779b17149d217c5c5ce303 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 29 Apr 2024 21:13:37 +1000 Subject: [PATCH] Xbox: Fix singleplayer mode not rendering properly --- .gitignore | 6 ++++++ src/Graphics_Xbox.c | 4 ++-- src/Platform_NDS.c | 24 +++++++++++++----------- src/Window_NDS.c | 2 ++ src/Window_PS2.c | 2 ++ src/Window_PS3.c | 2 ++ 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 38efbcdc3..48865746a 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,12 @@ build-saturn/ cd/ # Microsoft console build results build-360/ +main.exe +main.lib +misc/xbox/ps_coloured.inl +misc/xbox/ps_textured.inl +misc/xbox/vs_coloured.inl +misc/xbox/vs_textured.inl # Sony console build results build-ps2/ build-ps3/ diff --git a/src/Graphics_Xbox.c b/src/Graphics_Xbox.c index 5580892bd..e4c0d9378 100644 --- a/src/Graphics_Xbox.c +++ b/src/Graphics_Xbox.c @@ -536,8 +536,8 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f void Gfx_OnWindowResize(void) { } -static struct Vec4 vp_offset = { 320, -240, 8388608, 1 }; -static struct Vec4 vp_scale = { 320, 240, 8388608, 1 }; +static struct Vec4 vp_scale = { 320, -240, 8388608, 1 }; +static struct Vec4 vp_offset = { 320, 240, 8388608, 1 }; static struct Matrix _view, _proj, _mvp; static void UpdateVSConstants(void) { diff --git a/src/Platform_NDS.c b/src/Platform_NDS.c index 78e3bb0f2..ac1062752 100644 --- a/src/Platform_NDS.c +++ b/src/Platform_NDS.c @@ -108,16 +108,15 @@ static bool fat_available; static void GetNativePath(char* str, const cc_string* path) { Mem_Copy(str, root_path.buffer, root_path.length); - str += root_path.length; + str += root_path.length; String_EncodeUtf8(str, path); - Platform_Log1("Open %c", str - root_path.length); } cc_result Directory_Create(const cc_string* path) { - if (!fat_available) return ENOTSUP; - char str[NATIVE_STR_LEN]; GetNativePath(str, path); + Platform_Log1("mkdir %c", str); + return mkdir(str, 0) == -1 ? errno : 0; } @@ -127,6 +126,8 @@ int File_Exists(const cc_string* path) { char str[NATIVE_STR_LEN]; struct stat sb; GetNativePath(str, path); + Platform_Log1("Check %c", str); + return stat(str, &sb) == 0 && S_ISREG(sb.st_mode); } @@ -137,6 +138,8 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall static cc_result File_Do(cc_file* file, const cc_string* path, int mode) { char str[NATIVE_STR_LEN]; GetNativePath(str, path); + Platform_Log1("Open %c", str); + *file = open(str, mode, 0); return *file == -1 ? errno : 0; } @@ -187,6 +190,12 @@ cc_result File_Length(cc_file file, cc_uint32* len) { } static void InitFilesystem(cc_bool dsiMode) { + char* dir = fatGetDefaultCwd(); + if (dir && dir[0]) { + root_path.buffer = dir; + root_path.length = String_Length(dir); + } + // I don't know why I have to call this function, but if I don't, // then when running in DSi mode AND an SD card is readable, // fatInitDefault gets stuck somewhere (in disk_initialize it seems) @@ -197,13 +206,6 @@ static void InitFilesystem(cc_bool dsiMode) { fat_available = fatInitDefault(); Platform_ReadonlyFilesystem = !fat_available; - if (!fat_available) return; - - char* dir = fatGetDefaultCwd(); - if (dir && dir[0]) { - root_path.buffer = dir; - root_path.length = String_Length(dir); - } } diff --git a/src/Window_NDS.c b/src/Window_NDS.c index 498d40888..71cb74fd2 100644 --- a/src/Window_NDS.c +++ b/src/Window_NDS.c @@ -68,6 +68,8 @@ static void consoleNewLine(void) { } static void consolePrintChar(char c) { + if (c < ' ') return; // only ASCII supported + if (conCursorX >= CON_WIDTH) consoleNewLine(); diff --git a/src/Window_PS2.c b/src/Window_PS2.c index 3e691ae09..74428180f 100644 --- a/src/Window_PS2.c +++ b/src/Window_PS2.c @@ -110,6 +110,8 @@ static void HandleButtons(int port, int buttons) { Gamepad_SetButton(port, CCPAD_START, buttons & PAD_START); Gamepad_SetButton(port, CCPAD_SELECT, buttons & PAD_SELECT); + Gamepad_SetButton(port, CCPAD_LSTICK, buttons & PAD_L3); + Gamepad_SetButton(port, CCPAD_RSTICK, buttons & PAD_L3); Gamepad_SetButton(port, CCPAD_LEFT, buttons & PAD_LEFT); Gamepad_SetButton(port, CCPAD_RIGHT, buttons & PAD_RIGHT); diff --git a/src/Window_PS3.c b/src/Window_PS3.c index ef06422a2..445e271bc 100644 --- a/src/Window_PS3.c +++ b/src/Window_PS3.c @@ -276,6 +276,8 @@ static void HandleButtons(int port, padData* data) { Gamepad_SetButton(port, CCPAD_START, data->BTN_START); Gamepad_SetButton(port, CCPAD_SELECT, data->BTN_SELECT); + Gamepad_SetButton(port, CCPAD_LSTICK, data->BTN_L3); + Gamepad_SetButton(port, CCPAD_RSTICK, data->BTN_R3); Gamepad_SetButton(port, CCPAD_LEFT, data->BTN_LEFT); Gamepad_SetButton(port, CCPAD_RIGHT, data->BTN_RIGHT);