GBDK 2020 Docs  4.3.0
API Documentation for GBDK 2020
emu_debug.h
Go to the documentation of this file.
1 
13 // Suppress SDCC "info 128" warnings that are a non-issue
14 #pragma disable_warning 218
15 
16 #ifndef __GBDK_EMU_DEBUG_H_INCLUDE
17 #define __GBDK_EMU_DEBUG_H_INCLUDE
18 
19 #include <types.h>
20 
21 #if defined(__TARGET_gb) || defined(__TARGET_ap) || defined(__TARGET_sms) || defined(__TARGET_gg)
22 
46 #define EMU_MESSAGE(message_text) EMU_MESSAGE1(EMU_MACRONAME(__LINE__), message_text)
47 #define BGB_MESSAGE(message_text) EMU_MESSAGE(message_text)
48 
50 #define EMU_MACRONAME(A) EMU_MACRONAME1(A)
51 #define EMU_MACRONAME1(A) EMULOG##A
52 
53 #define EMU_MESSAGE1(name, message_text) \
54 __asm \
55 .MACRO name msg_t, ?llbl \
56  ld d, d \
57  jr llbl \
58  .dw 0x6464 \
59  .dw 0x0000 \
60  .ascii msg_t \
61 llbl: \
62 .ENDM \
63 name ^/message_text/ \
64 __endasm
65 
66 #define EMU_MESSAGE_SUFFIX(message_text, message_suffix) EMU_MESSAGE3(EMU_MACRONAME(__LINE__), message_text, message_suffix)
67 #define EMU_MESSAGE3(name, message_text, message_suffix) \
68 __asm \
69 .MACRO name msg_t, msg_s, ?llbl \
70  ld d, d \
71  jr llbl \
72  .dw 0x6464 \
73  .dw 0x0000 \
74  .ascii msg_t \
75  .ascii msg_s \
76 llbl: \
77 .ENDM \
78 name ^/message_text/, ^/message_suffix/ \
79 __endasm
81 
92 #define EMU_PROFILE_BEGIN(MSG) EMU_MESSAGE_SUFFIX(MSG, "%ZEROCLKS%");
93 #define BGB_PROFILE_BEGIN(MSG) EMU_PROFILE_BEGIN(MSG)
119 #if defined(NINTENDO)
120 #define EMU_PROFILE_END(MSG) EMU_MESSAGE_SUFFIX(MSG,"%-8+LASTCLKS%");
121 #define BGB_PROFILE_END(MSG) EMU_PROFILE_END(MSG)
122 #elif defined(SEGA)
123 #define EMU_PROFILE_END(MSG) EMU_MESSAGE_SUFFIX(MSG,"%-16+LASTCLKS%");
124 #define BGB_PROFILE_END(MSG) EMU_PROFILE_END(MSG)
125 #endif
126 
127 #define EMU_TEXT(MSG) EMU_MESSAGE(MSG)
128 #define BGB_TEXT(MSG) EMU_TEXT(MSG)
129 
130 #if defined(NINTENDO)
140 #define BGB_profiler_message EMU_profiler_message()
141 #endif // NINTENDO
142 
164 void EMU_printf(const char *format, ...) PRESERVES_REGS(a, b, c);
165 #define BGB_printf(...) EMU_printf(__VA_ARGS__)
166 
176 void EMU_fmtbuf(const unsigned char * format, void * data) PRESERVES_REGS(a, b, c);
177 
178 #ifdef NINTENDO
179 static void * __EMU_PROFILER_INIT = &EMU_profiler_message;
180 #endif // NINTENDO
181 
184 #define EMU_BREAKPOINT __asm__("ld b, b");
185 #define BGB_BREAKPOINT EMU_BREAKPOINT
186 
187 #elif defined(__TARGET_duck)
188  #error Not implemented yet
189 #else
190  #error Unrecognized port
191 #endif
192 
193 #endif
#define PRESERVES_REGS(...)
Definition: types.h:32
void c
Definition: emu_debug.h:164
void EMU_fmtbuf(const unsigned char *format, void *data) PRESERVES_REGS(a
void b
Definition: emu_debug.h:164
void EMU_printf(const char *format,...) PRESERVES_REGS(a
void EMU_profiler_message(void)