DGen/SDL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
dissz80.h
Go to the documentation of this file.
1 /* dZ80 Disassembler Header */
2 
3 #ifndef _MIDISSZ80_
4 #define _MIDISSZ80_
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 #ifndef _DZ80_EXCLUDE_SCRIPT
11 #include "lua.h"
12 #else
13 #define LUA_VERSION "(scripting not included)"
14 #endif
15 
16 #define DZ80_WWW "http://www.inkland.org"
17 #define DZ80_EMAIL "dz80@inkland.org"
18 
19 #define Z80MEMSIZE 65536
20 
21 #define D_CUSTOMSTRING_MAXLEN 6
22 
23 #define DISFLAG_OPCODEDUMP 0x01
24 #define DISFLAG_ADDRDUMP 0x02
25 #define DISFLAG_UPPER 0x04
26 #define DISFLAG_SINGLE 0x08 /* Disassemble a single instruction */
27 #define DISFLAG_VERBOSE 0x10
28 #define DISFLAG_QUIET 0x20
29 #define DISFLAG_LABELLED 0x40
30 #define DISFLAG_REFINPORT 0x80
31 #define DISFLAG_REFOUTPORT 0x100
32 #define DISFLAG_REFADDR 0x200
33 #define DISFLAG_REFINDIRECT 0x400
34 #define DISFLAG_REFLIMITRANGE 0x800
35 #define DISFLAG_USELABELADDRS 0x1000
36 #define DISFLAG_RELCOMMENT 0x2000 /* Relative jump comments */
37 #define DISFLAG_LINECOMMANDS 0x4000 /* Process line commands (auto blank lines) */
38 #define DISFLAG_CALLBACK 0x8000 /* Access memory through a callback */
39 
40 /* Reference listing stuff */
41 #define DISFLAG_ANYREF (DISFLAG_REFINPORT | DISFLAG_REFOUTPORT | DISFLAG_REFADDR | DISFLAG_REFINDIRECT)
42 
43 /* parametersModified flags (used by the GUI when importing a config file) */
44 #define DPM_STARTADDR 0x0001
45 #define DPM_ENDADDR 0x0002
46 #define DPM_HDRSIZE 0x0004
47 #define DPM_FILESTARTADDR 0x0008
48 #define DPM_CPUTYPE 0x0010
49 #define DPM_RADIX 0x0020
50 #define DPM_NUMPREFIX 0x0040
51 #define DPM_NUMSUFFIX 0x0080
52 #define DPM_OPMAP 0x0100
53 
54 /* Configuration file name */
55 #define CONFIGFILENAME "dz80.ini"
56 
58  {
62 
64  };
65 
66 
68  {
72 
74  };
75 
76 
77 
79  {
90 
92  };
93 
94 
95 enum DRADIX
96 {
100 
102 
104 };
105 
106 
108 {
113 
115 };
116 
117 
118 typedef struct DISREFADDR
119 {
121  struct DISREFADDR *pNext;
122 } DISREFADDR;
123 
124 typedef struct DISREF
125 {
126  WORD RefType; /* Reference type */
127  WORD Addr; /* Memory or port address */
128  WORD Hits; /* Number of times referenced */
129  DISREFADDR *pRefAddrHead; /* Pointer to the list of referenced addresses */
130  DISREFADDR *pRefAddrTail; /* Pointer to the last referenced address */
131 
132  struct DISREF *pPrev;
133  struct DISREF *pNext;
134 } DISREF;
135 
136 
137 typedef struct DISZ80
138 {
139  BYTE *mem0Start; /* Pointer to Z80's zero address */
140  BYTE (*memCB)(void *ctx, WORD addr); /* Indirect access through callback (DISFLAG_CALLBACK) */
141  WORD start; /* Starting disassembler address */
142  WORD end; /* Ending disassembler address */
143  DWORD flags; /* See DISFLAG_ defines */
144  DWORD flagsModified; /* Which bits have been modified via config files */
145  DWORD parametersModified; /* Which other parameters have been modified via config file */
146  int numInstructions; /* How many instructions were disassembled */
147  int createdRefOK; /* Set to TRUE if created .ref file OK */
148  char srcFileName[_MAX_PATH]; /* Used only to display the source filename in the report header */
149  char outFileName[_MAX_PATH]; /* Destination assembler file */
150  char opMapFileName[_MAX_PATH]; /* Opcode map file name */
151  char refFileName[_MAX_PATH]; /* Reference file name */
152  char scriptFileName[_MAX_PATH]; /* Lua script file name */
153 
154 /* CPU type */
155  BYTE cpuType; /* See the DCPU_ enums */
156 
157 /* New flexible number formats */
158  BYTE layoutRadix; /* Do ya want hex with that? */
159  char layoutComment[D_CUSTOMSTRING_MAXLEN]; /* The string used as a comment marker */
162  char layoutDefineByte[D_CUSTOMSTRING_MAXLEN];/* Default of "db" */
163 
164 /* Pointer to the function callbacks */
165  void (*fnProgressCallback)(struct DISZ80 *d);
166  void (*fnErrorMessage)(char *msg);
167  void (*fnOutputMessage)(char *msg);
168 
169 /* dZ80 private workspace stuff - hands off ;) */
170  char hexDisBuf[32]; /* Holds the hex. code bytes (easy one!) */
171  char disBuf[128]; /* Holds the disassembly */
172  char commentBuf[128];
176  BYTE (*Z80MemCB)(void *ctx, WORD addr);
177  signed char IXIYDisp; /* The IXIY displacement (-128 to 127) */
178  int Z80Flags;
189  BYTE *pTrapMap; /* Pointer to the trap map */
192  int disBufIndex; /* Index into the disassembly buffer */
193  DWORD fileHeaderSize; /* The size of the file's header (to skip) */
194  WORD fileStartAddr; /* The Z80 address of the start of the file */
195 
196 #ifndef _DZ80_EXCLUDE_SCRIPT
197  lua_State *ls; /* Pointer to the Lua state in which the scripts are run */
198 #endif
199 
200 } DISZ80;
201 
202 
203 int dZ80_LoadConfiguration(DISZ80 *d, char *pConfigFile);
205 int dZ80_Disassemble(DISZ80 *d);
206 void dZ80_SetRadix(DISZ80 *d, int radix);
208 void dZ80_InheritRadix(DISZ80 *dst, DISZ80 *src);
209 char *dZ80_GetVersionString(void);
210 void dZ80_StringToLower(char *s);
211 void dZ80_StringToUpper(char *s);
212 void dZ80_SafeStringCopy(char *dst, char *src, int dstSize);
213 const char *dZ80_GetErrorText(int errNum);
214 int dZ80_LoadZ80File(DISZ80 *d, DWORD *BytesLoaded);
215 void dZ80_Error(DISZ80 *d, char *msg);
216 void dZ80_ShowMsg(DISZ80 *d, char *msg);
217 int dZ80_AllocateOpMap(DISZ80 *d);
218 
219 extern char *dZ80CpuTypeNames[DCPU_TOTAL];
220 
221 #ifdef __cplusplus
222 }
223 #endif
224 
225 #endif /* _MIDISSZ80_ */