MAME uPD7810
---------------------------------------------------------------------------- */
-#define PAIR pair_t
+#define PAIR pair32_t
#define offs_t UINT16
/*****************************************************************************/
#define CPU_EXECUTE_CALL(name) CPU_EXECUTE_NAME(name)(cpustate)
#define CPU_DISASSEMBLE_NAME(name) cpu_disassemble_##name
-#define CPU_DISASSEMBLE(name) int CPU_DISASSEMBLE_NAME(name)(_TCHAR *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
-#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(buffer, pc, oprom, oprom)
+#define CPU_DISASSEMBLE(name) int CPU_DISASSEMBLE_NAME(name)(_TCHAR *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, symbol_t *first_symbol)
+#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(buffer, pc, oprom, oprom, d_debugger->first_symbol)
/*****************************************************************************/
/* src/emu/didisasm.h */
#define logerror(...)
#define fatalerror(...)
+#undef IN
+#undef OUT
+
#include "mame/emu/cpu/upd7810/upd7810.c"
#ifdef USE_DEBUGGER
+#undef _DOFF
#include "mame/emu/cpu/upd7810/7810dasm.c"
#endif
void UPD7810::initialize()
{
+ DEVICE::initialize();
opaque = CPU_INIT_CALL(upd7810);
upd7810_state *cpustate = (upd7810_state *)opaque;
#elif defined(HAS_UPD7907)
cpustate->config.type = TYPE_78C06;
#endif
- cpustate->config.io_callback = this;
cpustate->program = d_mem;
cpustate->io = d_io;
+ cpustate->outputs_to = (void*)&outputs_to;
+ cpustate->outputs_txd = (void*)&outputs_txd;
#ifdef USE_DEBUGGER
cpustate->emu = emu;
cpustate->debugger = d_debugger;
cpustate->program = d_mem;
cpustate->io = d_io;
+ cpustate->outputs_to = (void*)&outputs_to;
+ cpustate->outputs_txd = (void*)&outputs_txd;
#ifdef USE_DEBUGGER
cpustate->emu = emu;
cpustate->debugger = d_debugger;
if(clock == -1) {
if(busreq) {
// don't run cpu!
+#ifdef USE_DEBUGGER
+ total_icount += 1;
+#endif
return 1;
} else {
// run only one opcode
- return CPU_EXECUTE_CALL(upd7810);
+ return run_one_opecode();
}
} else {
icount += clock;
// run cpu while given clocks
while(icount > 0 && !busreq) {
- icount -= CPU_EXECUTE_CALL(upd7810);
+ icount -= run_one_opecode();
}
// if busreq is raised, spin cpu while remained clock
if(icount > 0 && busreq) {
+#ifdef USE_DEBUGGER
+ total_icount += icount;
+#endif
icount = 0;
}
return first_icount - icount;
}
}
+int UPD7810::run_one_opecode()
+{
+#ifdef USE_DEBUGGER
+ upd7810_state *cpustate = (upd7810_state *)opaque;
+ d_debugger->add_cpu_trace(cpustate->pc.w.l);
+#endif
+ int passed_icount = CPU_EXECUTE_CALL(upd7810);
+#ifdef USE_DEBUGGER
+ total_icount += passed_icount;
+#endif
+ return passed_icount;
+}
+
void UPD7810::write_signal(int id, uint32_t data, uint32_t mask)
{
upd7810_state *cpustate = (upd7810_state *)opaque;
case SIG_UPD7810_NMI:
set_irq_line(cpustate, INPUT_LINE_NMI, (data & mask) ? ASSERT_LINE : CLEAR_LINE);
break;
- case SIG_UPD7810_RXD:
- rxd_status = ((data & mask) != 0);
- break;
case SIG_CPU_BUSREQ:
busreq = ((data & mask) != 0);
break;
- // from upd7810.c
- case UPD7810_TXD:
- write_signals(&outputs_txd, (data & mask) ? 0xffffffff : 0);
- break;
- case UPD7810_RXD:
- write_signals(&outputs_rxd, (data & mask) ? 0xffffffff : 0);
- break;
- case UPD7810_TO:
- write_signals(&outputs_to, (data & mask) ? 0xffffffff : 0);
- break;
- }
-}
-
-uint32_t UPD7810::read_signal(int id)
-{
- switch(id) {
- // from upd7801.c
- case UPD7810_RXD:
- return rxd_status ? 1 : 0;
}
- return 0;
}
uint32_t UPD7810::get_pc()
bool UPD7810::write_debug_reg(const _TCHAR *reg, uint32_t data)
{
upd7810_state *cpustate = (upd7810_state *)opaque;
- return false;
+
+ if(_tcsicmp(reg, _T("PC")) == 0) {
+ PC = data;
+ } else if(_tcsicmp(reg, _T("SP")) == 0) {
+ SP = data;
+ } else if(_tcsicmp(reg, _T("VA")) == 0) {
+ VA = data;
+ } else if(_tcsicmp(reg, _T("BC")) == 0) {
+ BC = data;
+ } else if(_tcsicmp(reg, _T("DE")) == 0) {
+ DE = data;
+ } else if(_tcsicmp(reg, _T("HL")) == 0) {
+ HL = data;
+ } else if(_tcsicmp(reg, _T("V")) == 0) {
+ V = data;
+ } else if(_tcsicmp(reg, _T("A")) == 0) {
+ A = data;
+ } else if(_tcsicmp(reg, _T("B")) == 0) {
+ B = data;
+ } else if(_tcsicmp(reg, _T("C")) == 0) {
+ C = data;
+ } else if(_tcsicmp(reg, _T("D")) == 0) {
+ D = data;
+ } else if(_tcsicmp(reg, _T("E")) == 0) {
+ E = data;
+ } else if(_tcsicmp(reg, _T("H")) == 0) {
+ H = data;
+ } else if(_tcsicmp(reg, _T("L")) == 0) {
+ L = data;
+ } else if(_tcsicmp(reg, _T("VA'")) == 0) {
+ VA2 = data;
+ } else if(_tcsicmp(reg, _T("BC'")) == 0) {
+ BC2 = data;
+ } else if(_tcsicmp(reg, _T("DE'")) == 0) {
+ DE2 = data;
+ } else if(_tcsicmp(reg, _T("HL'")) == 0) {
+ HL2 = data;
+ } else if(_tcsicmp(reg, _T("V'")) == 0) {
+ V2 = data;
+ } else if(_tcsicmp(reg, _T("A'")) == 0) {
+ A2 = data;
+ } else if(_tcsicmp(reg, _T("B'")) == 0) {
+ B2 = data;
+ } else if(_tcsicmp(reg, _T("C'")) == 0) {
+ C2 = data;
+ } else if(_tcsicmp(reg, _T("D'")) == 0) {
+ D2 = data;
+ } else if(_tcsicmp(reg, _T("E'")) == 0) {
+ E2 = data;
+ } else if(_tcsicmp(reg, _T("H'")) == 0) {
+ H2 = data;
+ } else if(_tcsicmp(reg, _T("L'")) == 0) {
+ L2 = data;
+ } else {
+ return false;
+ }
+ return true;
}
void UPD7810::get_debug_regs_info(_TCHAR *buffer, size_t buffer_len)
{
+/*
+VA = 0000 BC = 0000 DE = 0000 HL = 0000 PSW= 00 [Z SK HC L1 L0 CY]
+VA'= 0000 BC'= 0000 DE'= 0000 HL'= 0000 SP = 0000 PC = 0000
+ (BC)= 0000 (DE)=0000 (HL)= 0000 (SP)= 0000 <DI>
+Clocks = 0 (0) Since Scanline = 0/0 (0/0)
+*/
upd7810_state *cpustate = (upd7810_state *)opaque;
+ int wait;
+ my_stprintf_s(buffer, buffer_len,
+ _T("VA = %04X BC = %04X DE = %04X HL = %04X PSW= %02x [%s %s %s %s %s %s]\nVA'= %04X BC'= %04X DE'= %04X HL'= %04X SP = %04X PC = %04X\n (BC)= %04X (DE)=%04X (HL)= %04X (SP)= %04X <%s>\nClocks = %llu (%llu) Since Scanline = %d/%d (%d/%d)"),
+ VA, BC, DE, HL, PSW,
+ (PSW & Z) ? _T("Z") : _T("-"), (PSW & SK) ? _T("SK") : _T("--"), (PSW & HC) ? _T("HC") : _T("--"), (PSW & L1) ? _T("L1") : _T("--"), (PSW & L0) ? _T("L0") : _T("--"), (PSW & CY) ? _T("CY") : _T("--"),
+ VA2, BC2, DE2, HL2, SP, PC,
+ d_mem->read_data16w(BC, &wait), d_mem->read_data16w(DE, &wait), d_mem->read_data16w(HL, &wait), d_mem->read_data16w(SP, &wait),
+ IFF ? _T("EI") : _T("DI"),
+ total_icount, total_icount - prev_total_icount,
+ get_passed_clock_since_vline(), get_cur_vline_clocks(), get_cur_vline(), get_lines_per_frame());
+ prev_total_icount = total_icount;
}
// disassembler
}
#endif
-#define STATE_VERSION 3
-
-void UPD7810::save_state(FILEIO* state_fio)
-{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->Fwrite(opaque, sizeof(upd7810_state), 1);
- state_fio->FputInt32(icount);
- state_fio->FputBool(busreq);
-}
+#define STATE_VERSION 5
-bool UPD7810::load_state(FILEIO* state_fio)
+bool UPD7810::process_state(FILEIO* state_fio, bool loading)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
- }
- if(state_fio->FgetInt32() != this_device_id) {
- return false;
- }
- state_fio->Fread(opaque, sizeof(upd7810_state), 1);
- icount = state_fio->FgetInt32();
- busreq = state_fio->FgetBool();
-
- // post process
upd7810_state *cpustate = (upd7810_state *)opaque;
- cpustate->program = d_mem;
- cpustate->io = d_io;
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateValue(cpustate->ppc);
+ state_fio->StateValue(cpustate->pc);
+ state_fio->StateValue(cpustate->sp);
+ state_fio->StateValue(cpustate->op);
+ state_fio->StateValue(cpustate->op2);
+ state_fio->StateValue(cpustate->iff);
+ state_fio->StateValue(cpustate->softi);
+ state_fio->StateValue(cpustate->psw);
+ state_fio->StateValue(cpustate->ea);
+ state_fio->StateValue(cpustate->va);
+ state_fio->StateValue(cpustate->bc);
+ state_fio->StateValue(cpustate->de);
+ state_fio->StateValue(cpustate->hl);
+ state_fio->StateValue(cpustate->ea2);
+ state_fio->StateValue(cpustate->va2);
+ state_fio->StateValue(cpustate->bc2);
+ state_fio->StateValue(cpustate->de2);
+ state_fio->StateValue(cpustate->hl2);
+ state_fio->StateValue(cpustate->cnt);
+ state_fio->StateValue(cpustate->tm);
+ state_fio->StateValue(cpustate->ecnt);
+ state_fio->StateValue(cpustate->etm);
+ state_fio->StateValue(cpustate->ma);
+ state_fio->StateValue(cpustate->mb);
+ state_fio->StateValue(cpustate->mcc);
+ state_fio->StateValue(cpustate->mc);
+ state_fio->StateValue(cpustate->mm);
+ state_fio->StateValue(cpustate->mf);
+ state_fio->StateValue(cpustate->tmm);
+ state_fio->StateValue(cpustate->etmm);
+ state_fio->StateValue(cpustate->eom);
+ state_fio->StateValue(cpustate->sml);
+ state_fio->StateValue(cpustate->smh);
+ state_fio->StateValue(cpustate->anm);
+ state_fio->StateValue(cpustate->mkl);
+ state_fio->StateValue(cpustate->mkh);
+ state_fio->StateValue(cpustate->zcm);
+ state_fio->StateValue(cpustate->pa_in);
+ state_fio->StateValue(cpustate->pb_in);
+ state_fio->StateValue(cpustate->pc_in);
+ state_fio->StateValue(cpustate->pd_in);
+ state_fio->StateValue(cpustate->pf_in);
+ state_fio->StateValue(cpustate->pa_out);
+ state_fio->StateValue(cpustate->pb_out);
+ state_fio->StateValue(cpustate->pc_out);
+ state_fio->StateValue(cpustate->pd_out);
+ state_fio->StateValue(cpustate->pf_out);
+ state_fio->StateValue(cpustate->cr0);
+ state_fio->StateValue(cpustate->cr1);
+ state_fio->StateValue(cpustate->cr2);
+ state_fio->StateValue(cpustate->cr3);
+ state_fio->StateValue(cpustate->txb);
+ state_fio->StateValue(cpustate->rxb);
+ state_fio->StateValue(cpustate->txd);
+ state_fio->StateValue(cpustate->rxd);
+ state_fio->StateValue(cpustate->sck);
+ state_fio->StateValue(cpustate->ti);
+ state_fio->StateValue(cpustate->to);
+ state_fio->StateValue(cpustate->ci);
+ state_fio->StateValue(cpustate->co0);
+ state_fio->StateValue(cpustate->co1);
+ state_fio->StateValue(cpustate->irr);
+ state_fio->StateValue(cpustate->itf);
+ state_fio->StateValue(cpustate->int1);
+ state_fio->StateValue(cpustate->int2);
+ state_fio->StateValue(cpustate->txs);
+ state_fio->StateValue(cpustate->rxs);
+ state_fio->StateValue(cpustate->txcnt);
+ state_fio->StateValue(cpustate->rxcnt);
+ state_fio->StateValue(cpustate->txbuf);
+ state_fio->StateValue(cpustate->ovc0);
+ state_fio->StateValue(cpustate->ovc1);
+ state_fio->StateValue(cpustate->ovce);
+ state_fio->StateValue(cpustate->ovcf);
+ state_fio->StateValue(cpustate->ovcs);
+ state_fio->StateValue(cpustate->ovcsio);
+ state_fio->StateValue(cpustate->edges);
+ state_fio->StateValue(cpustate->icount);
#ifdef USE_DEBUGGER
- cpustate->emu = emu;
- cpustate->debugger = d_debugger;
- cpustate->program_stored = d_mem;
- cpustate->io_stored = d_io;
+ state_fio->StateValue(total_icount);
#endif
- return true;
+ state_fio->StateValue(icount);
+ state_fio->StateValue(busreq);
+ state_fio->StateValue(icount);
+ state_fio->StateValue(busreq);
+
+#ifdef USE_DEBUGGER
+ // post process
+ if(loading) {
+ prev_total_icount = total_icount;
+ }
+#endif
+ return true;
}