icount = extra_icount = 0;
}
+void Z80::debugger_hook(void)
+{
+#ifdef USE_DEBUGGER
+ bool now_debugging = d_debugger->now_debugging;
+ if(now_debugging) {
+ d_debugger->check_break_points(PC);
+ if(d_debugger->now_suspended) {
+ osd->mute_sound();
+ d_debugger->now_waiting = true;
+ while(d_debugger->now_debugging && d_debugger->now_suspended) {
+ osd->sleep(10);
+ }
+ d_debugger->now_waiting = false;
+ }
+ if(d_debugger->now_debugging) {
+ d_mem = d_debugger;
+ } else {
+ now_debugging = false;
+ }
+
+ //d_debugger->add_cpu_trace(PC);
+ int first_icount = icount;
+ //pPPC = pPC;
+ if(now_debugging) {
+ if(!d_debugger->now_going) {
+ d_debugger->now_suspended = true;
+ }
+ d_mem = d_mem_stored;
+ }
+ }
+#endif
+}
+
int Z80::run(int clock)
{
if(clock == -1) {
/*icount = */extra_icount = 0;
#ifdef USE_DEBUGGER
total_icount += passed_icount;
+ debugger_hook();
#endif
return passed_icount;
} else {
if(busreq) {
// run dma once
+ #ifdef USE_DEBUGGER
+ debugger_hook();
+ #endif
#ifdef SINGLE_MODE_DMA
if(d_dma) {
d_dma->do_dma();
}
}
+
void Z80::run_one_opecode()
{
// rune one opecode
d_dma->do_dma();
}
#endif
- d_pic->notify_intr_ei();
+ if(d_pic != NULL) d_pic->notify_intr_ei();
check_interrupt();
if(now_debugging) {
d_dma->do_dma();
}
#endif
- d_pic->notify_intr_ei();
+ if(d_pic != NULL) d_pic->notify_intr_ei();
check_interrupt();
#ifdef USE_DEBUGGER
}
// INTR
LEAVE_HALT();
PUSH(pc);
- PCD = WZ = d_pic->get_intr_ack() & 0xffff;
+ if(d_pic != NULL) { // OK?
+ PCD = WZ = d_pic->get_intr_ack() & 0xffff;
+ } else {
+ PCD = WZ = (PCD & 0xff00) | 0xcd;
+ }
icount -= cc_op[0xcd] + cc_ex[0xff];
iff1 = iff2 = 0;
intr_req_bit &= ~1;
// interrupt
LEAVE_HALT();
- uint32_t vector = d_pic->get_intr_ack();
+ uint32_t vector = 0xcd;
+ if(d_pic != NULL) vector = d_pic->get_intr_ack();
if(im == 0) {
// mode 0 (support NOP/JMP/CALL/RST only)
switch(vector & 0xff) {
void OP_ED(uint8_t code);
void OP(uint8_t code);
virtual void run_one_opecode();
+ virtual void debugger_hook(void);
uint8_t SZ[256]; /* zero and sign flags */
uint8_t SZ_BIT[256]; /* zero, sign and parity/overflow (=zero) flags for BIT opcode */
d_debugger = NULL;
d_mem_stored = NULL;
d_io_stored = NULL;
-
+ d_pic = NULL;
has_nsc800 = false;
has_io_wait = false;
has_memory_wait = false;
protected:
void check_interrupt();
void run_one_opecode() override;
+ void debugger_hook(void) override;
public:
Z80(VM* parent_vm, EMU* parent_emu);
~Z80();
POP(pc); \
WZ = PC; \
iff1 = iff2; \
- d_pic->notify_intr_reti(); \
+ if(d_pic != NULL) d_pic->notify_intr_reti(); \
} while(0)
#define LD_R_A() do { \
if(busreq) {
// run dma once
+ // run dma once
+ #ifdef USE_DEBUGGER
+ debugger_hook();
+ #endif
//#ifdef SINGLE_MODE_DMA
if(d_dma) {
d_dma->do_dma();
}
}
+void Z80_BASE::debugger_hook(void)
+{
+}
+
void Z80_BASE::run_one_opecode()
{
// rune one opecode
#if HAS_LDAIR_QUIRK
if(after_ldair) F &= ~PF; // reset parity flag after LD A,I or LD A,R
#endif
- d_pic->notify_intr_ei();
+ if(d_pic != NULL) d_pic->notify_intr_ei();
}
// check interrupt
// INTR
LEAVE_HALT();
PUSH(pc);
- PCD = WZ = d_pic->get_intr_ack() & 0xffff;
+ if(d_pic != NULL) { // OK?
+ PCD = WZ = d_pic->get_intr_ack() & 0xffff;
+ } else {
+ PCD = WZ = (PCD & 0xff00) | 0xcd;
+ }
icount -= cc_op[0xcd] + cc_ex[0xff];
iff1 = iff2 = 0;
intr_req_bit &= ~1;
// interrupt
LEAVE_HALT();
- uint32_t vector = d_pic->get_intr_ack();
+ uint32_t vector = 0xcd; // Default
+ if(d_pic != NULL) vector = d_pic->get_intr_ack();
if(im == 0) {
// mode 0 (support NOP/JMP/CALL/RST only)
switch(vector & 0xff) {