From 526bd40646bdf37ab4cb44c3e0927844694dc34b Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 22 Mar 2024 23:55:17 +1100 Subject: [PATCH] DS: Fix UI sort of to work --- src/Graphics_NDS.c | 18 +++++++++++------- src/Platform_NDS.c | 13 +++++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Graphics_NDS.c b/src/Graphics_NDS.c index 2e9fba5fb..47766a068 100644 --- a/src/Graphics_NDS.c +++ b/src/Graphics_NDS.c @@ -27,6 +27,8 @@ void Gfx_Create(void) { glViewport(0, 0, 255, 191); vramSetBankA(VRAM_A_TEXTURE); + vramSetBankB(VRAM_B_TEXTURE); + vramSetBankC(VRAM_C_TEXTURE); // setup memory for textures glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); @@ -168,6 +170,8 @@ void Gfx_CalcOrthoMatrix(struct Matrix* matrix, float width, float height, float /* Transposed, source https://learn.microsoft.com/en-us/windows/win32/opengl/glortho */ /* The simplified calculation below uses: L = 0, R = width, T = 0, B = height */ *matrix = Matrix_Identity; + width /= 32.0f; + height /= 32.0f; matrix->row1.x = 2.0f / width; matrix->row2.y = -2.0f / height; @@ -224,9 +228,9 @@ static void PreprocessTexturedVertices(void) { for (int i = 0; i < buf_count; i++, src++, dst++) { struct VertexTextured v = *src; - dst->x = floattov16(v.x / 16.0f); - dst->y = floattov16(v.y / 16.0f); - dst->z = floattov16(v.z / 16.0f); + dst->x = floattov16(v.x / 32.0f); + dst->y = floattov16(v.y / 32.0f); + dst->z = floattov16(v.z / 32.0f); dst->u = v.U; dst->v = v.V; dst->r = PackedCol_R(v.Col); @@ -242,9 +246,9 @@ static void PreprocessColouredVertices(void) { for (int i = 0; i < buf_count; i++, src++, dst++) { struct VertexColoured v = *src; - dst->x = floattov16(v.x / 16.0f); - dst->y = floattov16(v.y / 16.0f); - dst->z = floattov16(v.z / 16.0f); + dst->x = floattov16(v.x / 32.0f); + dst->y = floattov16(v.y / 32.0f); + dst->z = floattov16(v.z / 32.0f); dst->r = PackedCol_R(v.Col); dst->g = PackedCol_G(v.Col); dst->b = PackedCol_B(v.Col); @@ -355,7 +359,7 @@ void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) { // That's way too small to be useful, so counteract that by scaling down // vertices and then scaling up the matrix multiplication if (type == MATRIX_VIEW) - glScalef32(floattof32(16.0f), floattof32(16.0f), floattof32(16.0f)); + glScalef32(floattof32(32.0f), floattof32(32.0f), floattof32(32.0f)); } void Gfx_LoadIdentityMatrix(MatrixType type) { diff --git a/src/Platform_NDS.c b/src/Platform_NDS.c index 859a1de72..8fe46adf7 100644 --- a/src/Platform_NDS.c +++ b/src/Platform_NDS.c @@ -94,11 +94,20 @@ static void GetNativePath(char* str, const cc_string* path) { } cc_result Directory_Create(const cc_string* path) { - return ERR_NOT_SUPPORTED; + if (!fat_available) return ENOSYS; + + char str[NATIVE_STR_LEN]; + GetNativePath(str, path); + return mkdir(str, 0) == -1 ? errno : 0; } int File_Exists(const cc_string* path) { - return false; + if (!fat_available) return false; + + char str[NATIVE_STR_LEN]; + struct stat sb; + GetNativePath(str, path); + return stat(str, &sb) == 0 && S_ISREG(sb.st_mode); } cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCallback callback) {