| 1 |
#ifndef _MAMEDBG_H |
| 2 |
#define _MAMEDBG_H |
| 3 |
|
| 4 |
#include "driver.h" |
| 5 |
|
| 6 |
#define DEBUGGER_TOTAL_COLORS 16 |
| 7 |
|
| 8 |
/* If this flag is set, a CPU core should call MAME_Debug from it's execution loop */ |
| 9 |
extern int mame_debug; |
| 10 |
|
| 11 |
#ifdef MAME_DEBUG |
| 12 |
|
| 13 |
enum { |
| 14 |
DBG_BLACK, |
| 15 |
DBG_BLUE, |
| 16 |
DBG_GREEN, |
| 17 |
DBG_CYAN, |
| 18 |
DBG_RED, |
| 19 |
DBG_MAGENTA, |
| 20 |
DBG_BROWN, |
| 21 |
DBG_LIGHTGRAY, |
| 22 |
DBG_GRAY, |
| 23 |
DBG_LIGHTBLUE, |
| 24 |
DBG_LIGHTGREEN, |
| 25 |
DBG_LIGHTCYAN, |
| 26 |
DBG_LIGHTRED, |
| 27 |
DBG_LIGHTMAGENTA, |
| 28 |
DBG_YELLOW, |
| 29 |
DBG_WHITE |
| 30 |
}; |
| 31 |
|
| 32 |
#define COLOR_TITLE DBG_YELLOW |
| 33 |
#define COLOR_FRAME DBG_LIGHTCYAN |
| 34 |
#define COLOR_REGS DBG_WHITE |
| 35 |
#define COLOR_DASM DBG_WHITE |
| 36 |
#define COLOR_MEM1 DBG_WHITE |
| 37 |
#define COLOR_MEM2 DBG_WHITE |
| 38 |
#define COLOR_CMDS DBG_WHITE |
| 39 |
#define COLOR_BRK_EXEC DBG_YELLOW |
| 40 |
#define COLOR_BRK_DATA (DBG_YELLOW+DBG_BLUE*16) |
| 41 |
#define COLOR_BRK_REGS (DBG_YELLOW+DBG_BLUE*16) |
| 42 |
#define COLOR_ERROR (DBG_YELLOW+DBG_RED*16) |
| 43 |
#define COLOR_HELP (DBG_WHITE+DBG_BLUE*16) |
| 44 |
#define COLOR_PROMPT DBG_CYAN |
| 45 |
#define COLOR_CHANGES DBG_LIGHTCYAN |
| 46 |
#define COLOR_PC (DBG_WHITE+DBG_BLUE*16) /* MB 980103 */ |
| 47 |
#define COLOR_CURSOR (DBG_WHITE+DBG_RED*16) /* MB 980103 */ |
| 48 |
|
| 49 |
/*************************************************************************** |
| 50 |
* |
| 51 |
* The following functions are defined in mamedbg.c |
| 52 |
* |
| 53 |
***************************************************************************/ |
| 54 |
/* What EA address to set with debug_ea_info (origin) */ |
| 55 |
enum { |
| 56 |
EA_DST, |
| 57 |
EA_SRC |
| 58 |
}; |
| 59 |
|
| 60 |
/* Size of the data element accessed (or the immediate value) */ |
| 61 |
enum { |
| 62 |
EA_DEFAULT, |
| 63 |
EA_INT8, |
| 64 |
EA_UINT8, |
| 65 |
EA_INT16, |
| 66 |
EA_UINT16, |
| 67 |
EA_INT32, |
| 68 |
EA_UINT32, |
| 69 |
EA_SIZE |
| 70 |
}; |
| 71 |
|
| 72 |
/* Access modes for effective addresses to debug_ea_info */ |
| 73 |
enum { |
| 74 |
EA_NONE, /* no EA mode */ |
| 75 |
EA_VALUE, /* immediate value */ |
| 76 |
EA_ABS_PC, /* change PC absolute (JMP or CALL type opcodes) */ |
| 77 |
EA_REL_PC, /* change PC relative (BRA or JR type opcodes) */ |
| 78 |
EA_ZPG_RD, /* read zero page memory */ |
| 79 |
EA_ZPG_WR, /* write zero page memory */ |
| 80 |
EA_ZPG_RDWR, /* read then write zero page memory */ |
| 81 |
EA_MEM_RD, /* read memory */ |
| 82 |
EA_MEM_WR, /* write memory */ |
| 83 |
EA_MEM_RDWR, /* read then write memory */ |
| 84 |
EA_PORT_RD, /* read i/o port */ |
| 85 |
EA_PORT_WR, /* write i/o port */ |
| 86 |
EA_COUNT |
| 87 |
}; |
| 88 |
|
| 89 |
/*************************************************************************** |
| 90 |
* This function can (should) be called by a disassembler to set |
| 91 |
* information for the debugger. It sets the address, size and type |
| 92 |
* of a memory or port access, an absolute or relative branch or |
| 93 |
* an immediate value and at the same time returns a string that |
| 94 |
* contains a literal hex string for that address. |
| 95 |
* Later it could also return a symbol for that address and access. |
| 96 |
***************************************************************************/ |
| 97 |
extern const char *set_ea_info( int what, unsigned address, int size, int acc ); |
| 98 |
|
| 99 |
/* Startup and shutdown functions; called from cpu_run */ |
| 100 |
extern void mame_debug_init(void); |
| 101 |
extern void mame_debug_exit(void); |
| 102 |
|
| 103 |
/* This is the main entry into the mame debugger */ |
| 104 |
extern void MAME_Debug(void); |
| 105 |
|
| 106 |
extern int debug_trace_delay; /* set to 0 to force a screen update */ |
| 107 |
|
| 108 |
/*************************************************************************** |
| 109 |
* Convenience macro for the CPU cores, this is defined to empty |
| 110 |
* if MAME_DEBUG is not specified, so a CPU core can simply add |
| 111 |
* CALL_MAME_DEBUG; before executing an instruction |
| 112 |
***************************************************************************/ |
| 113 |
#define CALL_MAME_DEBUG if( mame_debug ) MAME_Debug() |
| 114 |
|
| 115 |
#ifndef DECL_SPEC |
| 116 |
#define DECL_SPEC |
| 117 |
#endif |
| 118 |
|
| 119 |
#ifndef TRUE |
| 120 |
#define TRUE 1 |
| 121 |
#endif |
| 122 |
|
| 123 |
#ifndef FALSE |
| 124 |
#define FALSE 0 |
| 125 |
#endif |
| 126 |
|
| 127 |
#ifndef INVALID |
| 128 |
#define INVALID 0xffffffff |
| 129 |
#endif |
| 130 |
|
| 131 |
|
| 132 |
extern UINT8 debugger_palette[DEBUGGER_TOTAL_COLORS*3]; |
| 133 |
extern UINT8 debugger_idle; |
| 134 |
struct GfxElement *build_debugger_font(void); |
| 135 |
void dbg_put_screen_char (int ch, int attr, int x, int y); |
| 136 |
|
| 137 |
#else /* MAME_DEBUG */ |
| 138 |
|
| 139 |
#define CALL_MAME_DEBUG |
| 140 |
#define debugger_idle 0 |
| 141 |
|
| 142 |
#endif /* !MAME_DEBUG */ |
| 143 |
|
| 144 |
#endif |