From fd9e57b71ec0faa6feaaccf508940619b6b4e839 Mon Sep 17 00:00:00 2001
From: Cameron Cawley <[EMAIL REDACTED]>
Date: Sat, 12 Oct 2024 21:54:16 +0100
Subject: [PATCH] 3DS: Support simple message boxes
---
src/SDL_assert.c | 4 +++-
src/video/SDL_video.c | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/SDL_assert.c b/src/SDL_assert.c
index c60737f24326b..9d022dd37eb58 100644
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -283,7 +283,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
break;
}
}
-#elif defined(HAVE_STDIO_H)
+#elif defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_3DS)
// this is a little hacky.
for (;;) {
char buf[32];
@@ -310,6 +310,8 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
break;
}
}
+#else
+ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Assertion Failed", message, window);
#endif // HAVE_STDIO_H
}
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index b12f865b091c3..4b58b65235ff9 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -59,6 +59,10 @@
#include <emscripten.h>
#endif
+#ifdef SDL_PLATFORM_3DS
+#include <3ds.h>
+#endif
+
#ifdef SDL_PLATFORM_LINUX
#include <sys/types.h>
#include <sys/stat.h>
@@ -5518,6 +5522,23 @@ bool SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, cons
},
title, message);
return true;
+#elif defined(SDL_PLATFORM_3DS)
+ errorConf errCnf;
+ bool hasGpuRight;
+
+ // If the video subsystem has not been initialised, set up graphics temporarily
+ hasGpuRight = gspHasGpuRight();
+ if (!hasGpuRight)
+ gfxInitDefault();
+
+ errorInit(&errCnf, ERROR_TEXT_WORD_WRAP, CFG_LANGUAGE_EN);
+ errorText(&errCnf, message);
+ errorDisp(&errCnf);
+
+ if (!hasGpuRight)
+ gfxExit();
+
+ return true;
#else
SDL_MessageBoxData data;
SDL_MessageBoxButtonData button;