3DS: Fix down/up being swapped (Thanks Pear), remove spammy 'draw framebuffer' log message, also log whether creating root directories succeeds or not

This commit is contained in:
UnknownShadow200 2023-07-25 08:41:10 +10:00
parent e76fb5e95f
commit 205b7c97ec
5 changed files with 25 additions and 13 deletions

View File

@ -32,7 +32,7 @@ CC_API double Math_Sin(double x);
CC_API double Math_Cos(double x);
float Math_SinF(float x);
float Math_CosF(float x);
double Math_Atan2(double x, double y);\
double Math_Atan2(double x, double y);
/* Computes loge(x). Can also be used to approximate logy(x). */
/* e.g. for log3(x), use: Math_Log(x)/log(3) */

View File

@ -81,7 +81,7 @@ static void CreateD3D9Instance(void) {
}
static void FindCompatibleViewFormat(void) {
static const D3DFORMAT formats[4] = { D3DFMT_X8R8G8B8, D3DFMT_R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5 };
static const D3DFORMAT formats[] = { D3DFMT_X8R8G8B8, D3DFMT_R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5 };
cc_result res;
int i;
@ -94,7 +94,7 @@ static void FindCompatibleViewFormat(void) {
}
static void FindCompatibleDepthFormat(void) {
static const D3DFORMAT formats[6] = { D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D24S8, D3DFMT_D24X4S4, D3DFMT_D16, D3DFMT_D15S1 };
static const D3DFORMAT formats[] = { D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D24S8, D3DFMT_D24X4S4, D3DFMT_D16, D3DFMT_D15S1 };
cc_result res;
int i;

View File

@ -187,9 +187,12 @@ static cc_result File_Do(cc_file* file, const cc_string* path, int mode) {
char str[NATIVE_STR_LEN];
GetNativePath(str, path);
Platform_Log1("Opening file: %c", str);
*file = open(str, mode, 0666); // FS has no permissions anyways
return *file == -1 ? errno : 0;
//return *file == -1 ? errno : 0;
int ERR = *file == -1 ? errno : 0;
Platform_Log2("Open %s = %i", path, &ERR);
return ERR;
}
cc_result File_Open(cc_file* file, const cc_string* path) {
@ -518,13 +521,21 @@ cc_bool DynamicLib_DescribeError(cc_string* dst) {
*#########################################################################################################################*/
#define SOC_CTX_ALIGN 0x1000
#define SOC_CTX_SIZE 0x1000 * 128
static void CreateRootDirectory(const char* path) {
// create root directories (no permissions anyways)
int res = mkdir(path, 0666);
if (res >= 0) return;
int err = errno;
Platform_Log2("mkdir %c FAILED: %i", path, &err);
}
void Platform_Init(void) {
Platform_SingleProcess = true;
// create root directories (no permissions anyways)
mkdir("sdmc://3ds", 0666);
mkdir("sdmc://3ds/ClassiCube", 0666);
CreateRootDirectory("sdmc://3ds");
CreateRootDirectory("sdmc://3ds/ClassiCube");
// See https://github.com/devkitPro/libctru/blob/master/libctru/include/3ds/services/soc.h
// * @param context_addr Address of a page-aligned (0x1000) buffer to be used.
@ -567,4 +578,4 @@ cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
return ERR_NOT_SUPPORTED;
}
#endif
#endif

View File

@ -194,6 +194,7 @@ static int iLog(int x) {
return bits;
}
/* https://en.wikipedia.org/wiki/Single-precision_floating-point_format */
/* Float consists of: */
/* - 1 bit for sign */
/* - 8 bits for biased exponent */

View File

@ -88,10 +88,11 @@ void Window_ProcessEvents(double delta) {
Input_SetNonRepeatable(KeyBinds[KEYBIND_RIGHT], mods & KEY_DRIGHT);
Input_SetNonRepeatable(IPT_RIGHT, mods & KEY_DRIGHT);
Input_SetNonRepeatable(KeyBinds[KEYBIND_FORWARD], mods & KEY_DUP);
Input_SetNonRepeatable(IPT_UP, mods & KEY_DUP);
Input_SetNonRepeatable(KeyBinds[KEYBIND_BACK], mods & KEY_DDOWN);
Input_SetNonRepeatable(IPT_DOWN, mods & KEY_DDOWN);
// NOTE: KEY_DUP and KEY_DDOWN are deliberately swapped here
Input_SetNonRepeatable(KeyBinds[KEYBIND_FORWARD], mods & KEY_DDOWN);
Input_SetNonRepeatable(IPT_UP, mods & KEY_DDOWN);
Input_SetNonRepeatable(KeyBinds[KEYBIND_BACK], mods & KEY_DUP);
Input_SetNonRepeatable(IPT_DOWN, mods & KEY_DUP);
if (hidKeysHeld() & KEY_TOUCH) {
int x, y;
@ -155,7 +156,6 @@ void Window_DrawFramebuffer(Rect2D r) {
}
// TODO implement
// TODO gspWaitForVBlank();
Platform_LogConst("DRAW FB!!!");
gfxFlushBuffers();
//gfxSwapBuffers();
// TODO: tearing??