summaryrefslogtreecommitdiff
path: root/z80.c
diff options
context:
space:
mode:
Diffstat (limited to 'z80.c')
-rw-r--r--z80.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/z80.c b/z80.c
index 11e466b..0b74bf5 100644
--- a/z80.c
+++ b/z80.c
@@ -29,6 +29,7 @@
*/
#include <stdlib.h>
+#include <string.h>
#include "z80.h"
#include "z80_private.h"
@@ -310,13 +311,32 @@ Z80Val Z80Cycles(Z80 *cpu)
}
-const char *Z80Disassemble(Z80 *cpu, Z80Word *addr)
+const char *Z80Disassemble(Z80 *cpu, Z80Word *pc)
{
-#ifdef Z80_DISASSEMBLER_ENABLED
- (*addr)+=4;
- return "NO DISASSEMBLER";
+#ifdef ENABLE_DISASSEM
+ static char s[80];
+ Z80Word opc,npc;
+ Z80Byte op;
+ int f;
+
+ opc=*pc;
+ op=Z80_Dis_FetchByte(cpu,pc);
+ dis_opcode_z80[op](cpu,op,pc);
+ npc=*pc;
+
+ strcpy(s,Z80_Dis_Printf("%-5s",Z80_Dis_GetOp()));
+ strcat(s,Z80_Dis_Printf("%-40s ;",Z80_Dis_GetArg()));
+
+ for(f=0;f<5 && opc!=npc;f++)
+ strcat(s,Z80_Dis_Printf(" %.2x",(int)cpu->memory[opc++]));
+
+ if (opc!=npc)
+ for(f=1;f<3;f++)
+ s[strlen(s)-f]='.';
+
+ return s;
#else
- (*addr)+=4;
+ (*pc)+=4;
return "NO DISASSEMBLER";
#endif
}