emu_debug.h
Go to the documentation of this file.
// Suppress SDCC "info 128" warnings that are a non-issue
#pragma disable_warning 218
#ifndef __GBDK_EMU_DEBUG_H_INCLUDE
#define __GBDK_EMU_DEBUG_H_INCLUDE
#include <types.h>
#if defined(__TARGET_gb) || defined(__TARGET_ap) || defined(__TARGET_sms) || defined(__TARGET_gg)
#define EMU_MESSAGE(message_text) EMU_MESSAGE1(EMU_MACRONAME(__LINE__), message_text)
#define BGB_MESSAGE(message_text) EMU_MESSAGE(message_text)
#define EMU_MACRONAME(A) EMU_MACRONAME1(A)
#define EMU_MACRONAME1(A) EMULOG##A
#define EMU_MESSAGE1(name, message_text) \
__asm \
.MACRO name msg_t, ?llbl \
ld d, d \
jr llbl \
.dw 0x6464 \
.dw 0x0000 \
.ascii msg_t \
llbl: \
.ENDM \
name ^/message_text/ \
__endasm
#define EMU_MESSAGE_SUFFIX(message_text, message_suffix) EMU_MESSAGE3(EMU_MACRONAME(__LINE__), message_text, message_suffix)
#define EMU_MESSAGE3(name, message_text, message_suffix) \
__asm \
.MACRO name msg_t, msg_s, ?llbl \
ld d, d \
jr llbl \
.dw 0x6464 \
.dw 0x0000 \
.ascii msg_t \
.ascii msg_s \
llbl: \
.ENDM \
name ^/message_text/, ^/message_suffix/ \
__endasm
#define EMU_PROFILE_BEGIN(MSG) EMU_MESSAGE_SUFFIX(MSG, "%ZEROCLKS%");
#define BGB_PROFILE_BEGIN(MSG) EMU_PROFILE_BEGIN(MSG)
#if defined(NINTENDO)
#define EMU_PROFILE_END(MSG) EMU_MESSAGE_SUFFIX(MSG,"%-8+LASTCLKS%");
#define BGB_PROFILE_END(MSG) EMU_PROFILE_END(MSG)
#elif defined(SEGA)
#define EMU_PROFILE_END(MSG) EMU_MESSAGE_SUFFIX(MSG,"%-16+LASTCLKS%");
#define BGB_PROFILE_END(MSG) EMU_PROFILE_END(MSG)
#endif
#define EMU_TEXT(MSG) EMU_MESSAGE(MSG)
#define BGB_TEXT(MSG) EMU_TEXT(MSG)
#if defined(NINTENDO)
void EMU_profiler_message(void);
#define BGB_profiler_message EMU_profiler_message()
#endif // NINTENDO
void EMU_printf(const char *format, ...) PRESERVES_REGS(a, b, c);
#define BGB_printf(...) EMU_printf(__VA_ARGS__)
void EMU_fmtbuf(const unsigned char * format, void * data) PRESERVES_REGS(a, b, c);
#ifdef NINTENDO
static void * __EMU_PROFILER_INIT = &EMU_profiler_message;
#endif // NINTENDO
#define EMU_BREAKPOINT __asm__("ld b, b");
#define BGB_BREAKPOINT EMU_BREAKPOINT
#elif defined(__TARGET_duck)
#error Not implemented yet
#else
#error Unrecognized port
#endif
#endif
PRESERVES_REGS
#define PRESERVES_REGS(...)
Definition: types.h:32
EMU_fmtbuf
void EMU_fmtbuf(const unsigned char *format, void *data) PRESERVES_REGS(a
EMU_printf
void EMU_printf(const char *format,...) PRESERVES_REGS(a
EMU_profiler_message
void EMU_profiler_message(void)
b
void b
Definition: emu_debug.h:173
c
void c
Definition: emu_debug.h:173