#endif
}
+#ifndef HAS_I8085
+#define RET(c) { \
+ if(c) { \
+ count -= 6; \
+ PC = POP16(); \
+ } \
+}
+#endif
void I8080::INSN_0xd9(void)
{
#ifdef HAS_I8085
if(clock == -1) {
if(BUSREQ) {
// don't run cpu!
+#ifdef USE_DEBUGGER
+ total_count += 1;
+#endif
return 1;
} else {
// run only one opcode
}
// if busreq is raised, spin cpu while remained clock
if(count > 0 && BUSREQ) {
+#ifdef USE_DEBUGGER
+ total_count += count;
+#endif
count = 0;
}
return first_count - count;
d_debugger->check_break_points(PC);
if(d_debugger->now_suspended) {
emu->mute_sound();
+ d_debugger->now_waiting = true;
while(d_debugger->now_debugging && d_debugger->now_suspended) {
emu->sleep(10);
}
+ d_debugger->now_waiting = false;
}
if(d_debugger->now_debugging) {
d_mem = d_io = d_debugger;
now_debugging = false;
}
- afterEI = false;
+ afterHALT = afterEI = false;
+ d_debugger->add_cpu_trace(PC);
+ int first_count = count;
OP(FETCHOP());
+ total_count += first_count - count;
+ if(!afterEI) {
+ check_interrupt();
+ }
if(now_debugging) {
if(!d_debugger->now_going) {
}
} else {
#endif
- afterEI = false;
+ afterHALT = afterEI = false;
+#ifdef USE_DEBUGGER
+ d_debugger->add_cpu_trace(PC);
+ int first_count = count;
+#endif
OP(FETCHOP());
#ifdef USE_DEBUGGER
+ total_count += first_count - count;
+#endif
+ if(!afterEI) {
+ check_interrupt();
+ }
+#ifdef USE_DEBUGGER
}
#endif
d_debugger->check_break_points(PC);
if(d_debugger->now_suspended) {
emu->mute_sound();
+ d_debugger->now_waiting = true;
while(d_debugger->now_debugging && d_debugger->now_suspended) {
emu->sleep(10);
}
+ d_debugger->now_waiting = false;
}
if(d_debugger->now_debugging) {
d_mem = d_io = d_debugger;
now_debugging = false;
}
+ afterHALT = false;
+ d_debugger->add_cpu_trace(PC);
+ int first_count = count;
OP(FETCHOP());
+ total_count += first_count - count;
d_pic->notify_intr_ei();
+ check_interrupt();
if(now_debugging) {
if(!d_debugger->now_going) {
}
} else {
#endif
+ afterHALT = false;
+#ifdef USE_DEBUGGER
+ d_debugger->add_cpu_trace(PC);
+ int first_count = count;
+#endif
OP(FETCHOP());
+#ifdef USE_DEBUGGER
+ total_count += first_count - count;
+#endif
d_pic->notify_intr_ei();
+ check_interrupt();
#ifdef USE_DEBUGGER
}
#endif
}
-
+}
+
+void I8080::check_interrupt()
+{
+#ifdef USE_DEBUGGER
+ int first_count = count;
+#endif
// check interrupt
if(IM & IM_REQ) {
if(IM & IM_NMI) {
}
}
}
+#ifdef USE_DEBUGGER
+ total_count += first_count - count;
+#endif
+
}
+#define STATE_VERSION 2
-
-#define STATE_VERSION 1
-
-void I8080::save_state(FILEIO* state_fio)
+bool I8080::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->FputInt32(count);
- state_fio->Fwrite(regs, sizeof(regs), 1);
- state_fio->FputUint16(SP);
- state_fio->FputUint16(PC);
- state_fio->FputUint16(prevPC);
- state_fio->FputUint16(IM);
- state_fio->FputUint16(RIM_IEN);
- state_fio->FputBool(HALT);
- state_fio->FputBool(BUSREQ);
- state_fio->FputBool(SID);
- state_fio->FputBool(afterEI);
-}
-
-bool I8080::load_state(FILEIO* state_fio)
-{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- count = state_fio->FgetInt32();
- state_fio->Fread(regs, sizeof(regs), 1);
- SP = state_fio->FgetUint16();
- PC = state_fio->FgetUint16();
- prevPC = state_fio->FgetUint16();
- IM = state_fio->FgetUint16();
- RIM_IEN = state_fio->FgetUint16();
- HALT = state_fio->FgetBool();
- BUSREQ = state_fio->FgetBool();
- SID = state_fio->FgetBool();
- afterEI = state_fio->FgetBool();
+#ifdef USE_DEBUGGER
+ state_fio->StateUint64(total_count);
+#endif
+ state_fio->StateInt32(count);
+ state_fio->StateBuffer(regs, sizeof(regs), 1); // ToDo:
+ state_fio->StateUint16(SP);
+ state_fio->StateUint16(PC);
+ state_fio->StateUint16(prevPC);
+ state_fio->StateUint16(IM);
+ state_fio->StateUint16(RIM_IEN);
+ state_fio->StateBool(afterHALT);
+ state_fio->StateBool(BUSREQ);
+ state_fio->StateBool(SID);
+ state_fio->StateBool(afterEI);
+
+#ifdef USE_DEBUGGER
+ // post process
+ if(loading) {
+ prev_total_count = total_count;
+ }
+#endif
return true;
}