From bc522b27e064fe0b1e2a54f546e940a5f4eac9d6 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 16 Mar 2024 12:45:07 +0900 Subject: [PATCH] Android: Report ERROR() with a message box --- include/vm.h | 5 +++++ src/system4.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/vm.h b/include/vm.h index 3849142..80682b5 100644 --- a/include/vm.h +++ b/include/vm.h @@ -129,8 +129,13 @@ void vm_stack_trace(void); _Noreturn void _vm_error(const char *fmt, ...); _Noreturn void vm_exit(int code); +#ifdef __ANDROID__ +// Report the error with a message box and exit. +#define VM_ERROR ERROR +#else #define VM_ERROR(fmt, ...) \ _vm_error("*ERROR*(%s:%s:%d): " fmt "\n", __FILE__, __func__, __LINE__, ##__VA_ARGS__) +#endif #ifdef VM_PRIVATE #include "little_endian.h" diff --git a/src/system4.c b/src/system4.c index 6f6fd0c..cd9570f 100644 --- a/src/system4.c +++ b/src/system4.c @@ -401,11 +401,22 @@ static void windows_error_handler(const char *msg) } #endif +#ifdef __ANDROID__ +static void android_error_handler(const char *msg) +{ + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "xsystem4", msg, NULL); +} +#endif + int main(int argc, char *argv[]) { #ifdef _WIN32 sys_error_handler = windows_error_handler; #endif +#ifdef __ANDROID__ + sys_error_handler = android_error_handler; +#endif + initialize_instructions(); char *ainfile; int err = AIN_SUCCESS;