13#define MGBA_REG_DEBUG_ENABLE ((vu16*)0x4FFF780)
14#define MGBA_REG_DEBUG_FLAGS ((vu16*)0x4FFF700)
15#define MGBA_REG_DEBUG_STRING ((char*)0x4FFF600)
17static const u32 MGBA_ENABLE_MAGIC = 0xC0DE;
18static const u32 MGBA_ENABLE_OK = 0x1DEA;
19static const u32 MGBA_LOG_SEND = 0x100;
20static const u32 MGBA_LOG_BUFFER_SIZE = 0x100;
21static const u16 MGBA_LOG_LEVEL_MASK = 0x7;
23static bool s_mgba_logger_available =
false;
27 *MGBA_REG_DEBUG_ENABLE = MGBA_ENABLE_MAGIC;
28 s_mgba_logger_available = (*MGBA_REG_DEBUG_ENABLE == MGBA_ENABLE_OK);
29 return s_mgba_logger_available;
32static void mgba_vprintf(MgbaLogLevel level,
const char* fmt, va_list args)
34 if (!s_mgba_logger_available)
45 vsnprintf(MGBA_REG_DEBUG_STRING, MGBA_LOG_BUFFER_SIZE, fmt, args);
47 *MGBA_REG_DEBUG_FLAGS = ((uint16_t)level & MGBA_LOG_LEVEL_MASK) | MGBA_LOG_SEND;
50void mgba_printf(MgbaLogLevel level,
const char* fmt, ...)
54 mgba_vprintf(level, fmt, args);
58void mgba_func_printf(MgbaLogLevel level,
const char* func_name,
const char* fmt, ...)
60 if (!s_mgba_logger_available)
74 "%s() passed NULL message at log level %d",
79 char printed_str_buff[MGBA_LOG_BUFFER_SIZE];
84 vsnprintf(printed_str_buff,
sizeof(printed_str_buff), fmt, args);
86 mgba_printf(level,
"%s(): %s", func_name, printed_str_buff);
Interface to interact with the mgba logger.
bool mgba_logger_init(void)
Initialize mgba logger.
void mgba_func_printf(MgbaLogLevel level, const char *func_name, const char *fmt,...)
Print to mgba log with a format string and function name.
void mgba_printf(MgbaLogLevel level, const char *fmt,...)
Print to mgba log with a format string.
Utilities relating around number string representation and protected arithmatic helper functions.
#define GBAL_CUST_MSG_RETURN_IF_NULL(param, ret_val, message,...)
Returns ret_val and prints error message if param is equal to NULL. Useful for checking arguments or ...
#define GBAL_RETURN_IF_NULL(param, ret_val)
Returns ret_val and prints a default error message if param is equal to NULL. Useful for checking arg...
#define RET_NONE
An empty return value for RETURN_IF macros when used in void functions Expands to nothing because mac...