GBDK 2020 Docs  4.0.6
API Documentation for GBDK 2020
emu_debug.h
Go to the documentation of this file.
1 
12 #ifndef __EMU_DEBUG_INCLUDE
13 #define __EMU_DEBUG_INCLUDE
14 
15 #include <types.h>
16 
40 #define EMU_MESSAGE(message_text) EMU_MESSAGE1(EMU_MACRONAME(__LINE__), message_text)
41 #define BGB_MESSAGE(message_text) EMU_MESSAGE(message_text)
42 
44 #define EMU_MACRONAME(A) EMU_MACRONAME1(A)
45 #define EMU_MACRONAME1(A) EMULOG##A
46 
47 #define EMU_MESSAGE1(name, message_text) \
48 __asm \
49 .MACRO name msg_t, ?llbl\
50  ld d, d \
51  jr llbl \
52  .dw 0x6464 \
53  .dw 0x0000 \
54  .ascii msg_t \
55 llbl: \
56 .ENDM \
57 name ^/message_text/ \
58 __endasm
59 
60 #define EMU_MESSAGE_SUFFIX(message_text, message_suffix) EMU_MESSAGE3(EMU_MACRONAME(__LINE__), message_text, message_suffix)
61 #define EMU_MESSAGE3(name, message_text, message_suffix) \
62 __asm \
63 .MACRO name msg_t, msg_s, ?llbl\
64  ld d, d \
65  jr llbl \
66  .dw 0x6464 \
67  .dw 0x0000 \
68  .ascii msg_t \
69  .ascii msg_s \
70 llbl: \
71 .ENDM \
72 name ^/message_text/, ^/message_suffix/ \
73 __endasm
74 
86 #define EMU_PROFILE_BEGIN(MSG) EMU_MESSAGE_SUFFIX(MSG, "%ZEROCLKS%");
87 #define BGB_PROFILE_BEGIN(MSG) EMU_PROFILE_BEGIN(MSG)
88 
113 #define EMU_PROFILE_END(MSG) EMU_MESSAGE_SUFFIX(MSG,"%-8+LASTCLKS%");
114 #define BGB_PROFILE_END(MSG) EMU_PROFILE_END(MSG)
115 
116 #define EMU_TEXT(MSG) EMU_MESSAGE(MSG)
117 #define BGB_TEXT(MSG) EMU_TEXT(MSG)
118 
128 #define BGB_profiler_message() EMU_profiler_message()
129 
151 void EMU_printf(const char *format, ...) OLDCALL;
152 #define BGB_printf(...) EMU_printf(__VA_ARGS__)
153 
154 static void * __EMU_PROFILER_INIT = &EMU_profiler_message;
155 
158 #define EMU_BREAKPOINT __asm__("ld b, b");
159 #define BGB_BREAKPOINT EMU_BREAKPOINT
160 
161 #endif
EMU_printf
void EMU_printf(const char *format,...) OLDCALL
EMU_profiler_message
void EMU_profiler_message()
OLDCALL
#define OLDCALL
Definition: types.h:19