diff options
author | 2018-03-28 05:25:15 +1100 | |
---|---|---|
committer | 2018-03-28 05:25:15 +1100 | |
commit | 010155a3c51aa80dcf736b52ec89ffd890f795ef (patch) | |
tree | a732be4076a467e5dc25f088f9296544f364f858 | |
parent | 703564beccc92a6b6b33ab9562732a4e7ceaae8d (diff) |
Reshuffle some stuff:
* Move around the debugger hooks to get a small but measurable performance increase
* Remove emucore from external tools
* Improve performance of DSP16 interpreter a little by generating six variants of execution loop
182 files changed, 1277 insertions, 1410 deletions
diff --git a/scripts/src/tools.lua b/scripts/src/tools.lua index ba9ea8a1274..4073f9c7336 100644 --- a/scripts/src/tools.lua +++ b/scripts/src/tools.lua @@ -41,7 +41,6 @@ includedirs { files { MAME_DIR .. "src/tools/romcmp.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -88,7 +87,6 @@ includedirs { files { MAME_DIR .. "src/tools/chdman.cpp", - MAME_DIR .. "src/emu/emucore.cpp", GEN_DIR .. "version.cpp", } @@ -130,7 +128,6 @@ includedirs { files { MAME_DIR .. "src/tools/jedutil.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -177,7 +174,6 @@ includedirs { files { MAME_DIR .. "src/tools/unidasm.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -224,7 +220,6 @@ includedirs { files { MAME_DIR .. "src/tools/ldresample.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -271,7 +266,6 @@ includedirs { files { MAME_DIR .. "src/tools/ldverify.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -312,7 +306,6 @@ includedirs { files { MAME_DIR .. "src/tools/regrep.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -353,7 +346,6 @@ includedirs { files { MAME_DIR .. "src/tools/srcclean.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -394,7 +386,6 @@ includedirs { files { MAME_DIR .. "src/tools/src2html.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -437,7 +428,6 @@ includedirs { files { MAME_DIR .. "src/tools/split.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -478,7 +468,6 @@ includedirs { files { MAME_DIR .. "src/tools/pngcmp.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -611,7 +600,6 @@ includedirs { files { MAME_DIR .. "src/tools/castool.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } @@ -657,7 +645,6 @@ includedirs { files { MAME_DIR .. "src/tools/floptool.cpp", - MAME_DIR .. "src/emu/emucore.cpp", } configuration { "mingw*" or "vs*" } diff --git a/src/devices/cpu/8x300/8x300.cpp b/src/devices/cpu/8x300/8x300.cpp index 3c44d47c313..761ad4310e4 100644 --- a/src/devices/cpu/8x300/8x300.cpp +++ b/src/devices/cpu/8x300/8x300.cpp @@ -152,7 +152,7 @@ void n8x300_cpu_device::device_start() state_add(STATE_GENPC, "GENPC", m_genPC).mask(0x3ffe).callimport().noshow(); state_add(STATE_GENPCBASE, "CURPC", m_genPC).mask(0x3ffe).callimport().noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } //------------------------------------------------- @@ -206,7 +206,7 @@ void n8x300_cpu_device::execute_run() /* fetch the opcode */ m_genPC = m_AR << 1; - debugger_instruction_hook(this, m_genPC); + debugger_instruction_hook(m_genPC); opcode = FETCHOP(m_genPC); if (m_increment_pc) diff --git a/src/devices/cpu/adsp2100/adsp2100.cpp b/src/devices/cpu/adsp2100/adsp2100.cpp index a04d4521727..ed17f8b8405 100644 --- a/src/devices/cpu/adsp2100/adsp2100.cpp +++ b/src/devices/cpu/adsp2100/adsp2100.cpp @@ -588,7 +588,7 @@ void adsp21xx_device::device_start() state_add(ADSP2100_FL2, "FL2", m_fl2).mask(1); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -1156,7 +1156,7 @@ void adsp21xx_device::execute_set_input(int inputnum, int state) void adsp21xx_device::execute_run() { // Return if CPU is halted - if (m_input[INPUT_LINE_HALT].m_curstate) { + if (current_input_state(INPUT_LINE_HALT)) { m_icount = 0; return; } @@ -1170,7 +1170,7 @@ void adsp21xx_device::execute_run() // debugging m_ppc = m_pc; // copy PC to previous PC if (check_debugger) - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); #if ADSP_TRACK_HOTSPOTS m_pcbucket[m_pc & 0x3fff]++; diff --git a/src/devices/cpu/alph8201/8201dasm.cpp b/src/devices/cpu/alph8201/8201dasm.cpp index a987d5ededd..76a1d0d98a8 100644 --- a/src/devices/cpu/alph8201/8201dasm.cpp +++ b/src/devices/cpu/alph8201/8201dasm.cpp @@ -23,6 +23,8 @@ cpu/alph8201/ will be removed when the alpha 8304 has been dumped. #include "8201dasm.h" #include <ctype.h> +#include <stdexcept> + #define FMT(a,b) a, b #define PTRS_PER_FORMAT 2 @@ -299,16 +301,16 @@ alpha8201_disassembler::alpha8201_disassembler() pmask |= 1<<bit; pdown = bit; case 'x': - bit --; + bit--; break; case '_': continue; default: - fatalerror("Invalid instruction encoding '%s %s'\n", Formats[i*2],Formats[i*2+1]); + throw std::logic_error(util::string_format("Invalid instruction encoding '%s %s'\n", Formats[i*2],Formats[i*2+1])); } } - if (bit != -1 ) { - fatalerror("not enough bits in encoding '%s %s' %d\n", Formats[i*2],Formats[i*2+1],bit); + if (bit != -1) { + throw std::logic_error(util::string_format("not enough bits in encoding '%s %s' %d\n", Formats[i*2],Formats[i*2+1],bit)); } Op[i].mask = mask; diff --git a/src/devices/cpu/alph8201/alph8201.cpp b/src/devices/cpu/alph8201/alph8201.cpp index 61da750fe7d..81c1e6df4aa 100644 --- a/src/devices/cpu/alph8201/alph8201.cpp +++ b/src/devices/cpu/alph8201/alph8201.cpp @@ -440,7 +440,7 @@ void alpha8201_cpu_device::device_start() save_item(NAME(m_savec)); save_item(NAME(m_savez)); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -665,7 +665,7 @@ osd_printf_debug("alpha8201 START ENTRY=%02X PC=%03X\n",pcptr,m_pc.w.l); /* run */ m_PREVPC = m_pc.w.l; - debugger_instruction_hook(this, m_pc.w.l); + debugger_instruction_hook(m_pc.w.l); opcode =M_RDOP(m_pc.w.l); #if TRACE_PC osd_printf_debug("alpha8201: PC = %03x, opcode = %02x\n", m_pc.w.l, opcode); diff --git a/src/devices/cpu/alto2/alto2cpu.cpp b/src/devices/cpu/alto2/alto2cpu.cpp index cfe4d1a2fc4..07c836e72ee 100644 --- a/src/devices/cpu/alto2/alto2cpu.cpp +++ b/src/devices/cpu/alto2/alto2cpu.cpp @@ -992,7 +992,7 @@ void alto2_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_mpc).noshow(); state_add(STATE_GENFLAGS, "CURFLAGS", m_aluc0).formatstr("%5s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } //------------------------------------------------- @@ -2318,7 +2318,7 @@ void alto2_cpu_device::execute_run() m_rsel = rsel(); - debugger_instruction_hook(this, m_mpc); + debugger_instruction_hook(m_mpc); m_cycle++; if (f1() == f1_load_mar && check_mem_load_mar_stall(m_rsel)) { diff --git a/src/devices/cpu/am29000/am29000.cpp b/src/devices/cpu/am29000/am29000.cpp index 36563ae5a81..3f5faedf0d2 100644 --- a/src/devices/cpu/am29000/am29000.cpp +++ b/src/devices/cpu/am29000/am29000.cpp @@ -409,7 +409,7 @@ void am29000_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).callimport().noshow(); state_add(STATE_GENFLAGS, "CURFLAGS", m_alu).formatstr("%13s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -673,7 +673,7 @@ void am29000_cpu_device::execute_run() } if (call_debugger) - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); fetch_decode(); diff --git a/src/devices/cpu/amis2000/amis2000.cpp b/src/devices/cpu/amis2000/amis2000.cpp index fa092f0304b..43adeec3b35 100644 --- a/src/devices/cpu/amis2000/amis2000.cpp +++ b/src/devices/cpu/amis2000/amis2000.cpp @@ -182,7 +182,7 @@ void amis2000_base_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).noshow(); state_add(STATE_GENFLAGS, "CURFLAGS", m_f).formatstr("%6s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -246,7 +246,7 @@ void amis2000_base_device::execute_run() // remember previous opcode m_prev_op = m_op; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_op = m_program->read_byte(m_pc); m_pc = (m_pc + 1) & 0x1fff; diff --git a/src/devices/cpu/apexc/apexc.cpp b/src/devices/cpu/apexc/apexc.cpp index 85b9a398853..c759cb7b988 100644 --- a/src/devices/cpu/apexc/apexc.cpp +++ b/src/devices/cpu/apexc/apexc.cpp @@ -787,7 +787,7 @@ void apexc_cpu_device::device_start() state_add( STATE_GENPC, "PC", m_pc ).mask(0x7ffc).callimport().formatstr("%04X"); state_add( STATE_GENPCBASE, "CURPC", m_pc ).mask(0x7ffc).callimport().noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -846,7 +846,7 @@ void apexc_cpu_device::execute_run() { do { - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); if (m_running) execute(); diff --git a/src/devices/cpu/arc/arc.cpp b/src/devices/cpu/arc/arc.cpp index 3553f328c6c..70a2b274b57 100644 --- a/src/devices/cpu/arc/arc.cpp +++ b/src/devices/cpu/arc/arc.cpp @@ -66,7 +66,7 @@ void arc_cpu_device::device_start() state_add(ARC_PC, "PC", m_debugger_temp).callimport().callexport().formatstr("%08X"); state_add(STATE_GENPCBASE, "CURPC", m_debugger_temp).callimport().callexport().noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -122,7 +122,7 @@ void arc_cpu_device::execute_run() while (m_icount > 0) { - debugger_instruction_hook(this, m_pc<<2); + debugger_instruction_hook(m_pc<<2); //uint32_t op = READ32(m_pc); diff --git a/src/devices/cpu/arcompact/arcompact.cpp b/src/devices/cpu/arcompact/arcompact.cpp index bbae63217cf..46431b1865a 100644 --- a/src/devices/cpu/arcompact/arcompact.cpp +++ b/src/devices/cpu/arcompact/arcompact.cpp @@ -107,7 +107,7 @@ void arcompact_device::device_start() } - m_icountptr = &m_icount; + set_icountptr(m_icount); } diff --git a/src/devices/cpu/arcompact/arcompact_execute.cpp b/src/devices/cpu/arcompact/arcompact_execute.cpp index fc4dcca37a6..c341a856853 100644 --- a/src/devices/cpu/arcompact/arcompact_execute.cpp +++ b/src/devices/cpu/arcompact/arcompact_execute.cpp @@ -25,7 +25,7 @@ void arcompact_device::execute_run() while (m_icount > 0) { - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); // printf("new pc %04x\n", m_pc); diff --git a/src/devices/cpu/arm/arm.cpp b/src/devices/cpu/arm/arm.cpp index 4c5d058a009..5e8bf859d7d 100644 --- a/src/devices/cpu/arm/arm.cpp +++ b/src/devices/cpu/arm/arm.cpp @@ -342,7 +342,7 @@ void arm_cpu_device::execute_run() do { - debugger_instruction_hook(this, R15 & ADDRESS_MASK); + debugger_instruction_hook(R15 & ADDRESS_MASK); /* load instruction */ pc = R15; @@ -550,7 +550,7 @@ void arm_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_sArmRegister[15]).mask(ADDRESS_MASK).formatstr("%8s").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_sArmRegister[15]).formatstr("%11s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } diff --git a/src/devices/cpu/arm7/arm7.cpp b/src/devices/cpu/arm7/arm7.cpp index 06625c8c344..357938d61e8 100644 --- a/src/devices/cpu/arm7/arm7.cpp +++ b/src/devices/cpu/arm7/arm7.cpp @@ -592,7 +592,7 @@ void arm7_cpu_device::device_start() save_item(NAME(m_decoded_access_control)); machine().save().register_postload(save_prepost_delegate(FUNC(arm7_cpu_device::postload), this)); - m_icountptr = &m_icount; + set_icountptr(m_icount); state_add( ARM7_PC, "PC", m_pc).callexport().formatstr("%08X"); state_add(STATE_GENPC, "GENPC", m_pc).callexport().noshow(); @@ -804,7 +804,7 @@ void arm7_cpu_device::execute_run() update_insn_prefetch(pc); - debugger_instruction_hook(this, pc); + debugger_instruction_hook(pc); /* handle Thumb instructions if active */ if (T_IS_SET(m_r[eCPSR])) diff --git a/src/devices/cpu/asap/asap.cpp b/src/devices/cpu/asap/asap.cpp index 15da646c3b3..a0baeb3467f 100644 --- a/src/devices/cpu/asap/asap.cpp +++ b/src/devices/cpu/asap/asap.cpp @@ -209,7 +209,7 @@ void asap_device::device_start() save_item(NAME(m_irq_state)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -484,7 +484,7 @@ inline void asap_device::fetch_instruction_debug() { // debugging m_ppc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); // instruction fetch m_op = readop(m_pc); diff --git a/src/devices/cpu/avr8/avr8.cpp b/src/devices/cpu/avr8/avr8.cpp index f76825e9cb1..c10f2756cf4 100644 --- a/src/devices/cpu/avr8/avr8.cpp +++ b/src/devices/cpu/avr8/avr8.cpp @@ -820,7 +820,7 @@ void avr8_device::device_start() save_item(NAME(m_elapsed_cycles)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } //------------------------------------------------- @@ -2954,7 +2954,7 @@ void avr8_device::execute_run() m_pc &= m_addr_mask; m_shifted_pc &= (m_addr_mask << 1) | 1; - debugger_instruction_hook(this, m_shifted_pc); + debugger_instruction_hook(m_shifted_pc); op = (uint32_t)m_program->read_word(m_shifted_pc); diff --git a/src/devices/cpu/capricorn/capricorn.cpp b/src/devices/cpu/capricorn/capricorn.cpp index 76bef9fdbf8..5a18141157d 100644 --- a/src/devices/cpu/capricorn/capricorn.cpp +++ b/src/devices/cpu/capricorn/capricorn.cpp @@ -178,7 +178,7 @@ void capricorn_cpu_device::device_start() save_item(NAME(m_reg_E)); save_item(NAME(m_flags)); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void capricorn_cpu_device::device_reset() @@ -201,7 +201,7 @@ void capricorn_cpu_device::execute_run() // Handle interrupt take_interrupt(); } else { - debugger_instruction_hook(this, m_genpc); + debugger_instruction_hook(m_genpc); uint8_t opcode = fetch(); execute_one(opcode); diff --git a/src/devices/cpu/ccpu/ccpu.cpp b/src/devices/cpu/ccpu/ccpu.cpp index f32ae53885d..02bf0b123fd 100644 --- a/src/devices/cpu/ccpu/ccpu.cpp +++ b/src/devices/cpu/ccpu/ccpu.cpp @@ -146,7 +146,7 @@ void ccpu_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_PC).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_flags).formatstr("%6s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -220,7 +220,7 @@ void ccpu_cpu_device::execute_run() opcode = READOP(m_PC); if (opcode == 0x51 || opcode == 0x59) m_extinput = m_external_input(); - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); m_PC++; switch (opcode) diff --git a/src/devices/cpu/clipper/clipper.cpp b/src/devices/cpu/clipper/clipper.cpp index 096c2968335..fe0f2190849 100644 --- a/src/devices/cpu/clipper/clipper.cpp +++ b/src/devices/cpu/clipper/clipper.cpp @@ -122,7 +122,7 @@ void clipper_device::device_start() get_dcammu().set_spaces(spaces); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); save_item(NAME(m_pc)); save_item(NAME(m_psw)); @@ -225,7 +225,7 @@ void clipper_device::execute_run() while (m_icount > 0) { - debugger_instruction_hook(this, m_ip); + debugger_instruction_hook(m_ip); // fetch and decode an instruction if (decode_instruction()) diff --git a/src/devices/cpu/cop400/cop400.cpp b/src/devices/cpu/cop400/cop400.cpp index ffc9662d582..36e8cadc173 100644 --- a/src/devices/cpu/cop400/cop400.cpp +++ b/src/devices/cpu/cop400/cop400.cpp @@ -1143,7 +1143,7 @@ void cop400_cpu_device::device_start() state_add(COP400_SKIP, "SKIP", m_skip).mask(1); #endif - m_icountptr = &m_icount; + set_icountptr(m_icount); m_q = 0; m_sa = 0; @@ -1218,7 +1218,7 @@ void cop400_cpu_device::execute_run() { // debugger hook m_prevpc = PC; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); } // halt logic diff --git a/src/devices/cpu/cosmac/cosmac.cpp b/src/devices/cpu/cosmac/cosmac.cpp index e4a320cd8d1..7be0ae0dd76 100644 --- a/src/devices/cpu/cosmac/cosmac.cpp +++ b/src/devices/cpu/cosmac/cosmac.cpp @@ -385,7 +385,7 @@ void cosmac_device::device_start() save_item(NAME(m_q)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -766,7 +766,7 @@ inline void cosmac_device::debug() { if (device_t::machine().debug_flags & DEBUG_FLAG_ENABLED) { - debugger_instruction_hook(this, R[P]); + debugger_instruction_hook(R[P]); } } diff --git a/src/devices/cpu/cp1610/cp1610.cpp b/src/devices/cpu/cp1610/cp1610.cpp index e60f3376797..784281f71d8 100644 --- a/src/devices/cpu/cp1610/cp1610.cpp +++ b/src/devices/cpu/cp1610/cp1610.cpp @@ -2122,7 +2122,7 @@ void cp1610_cpu_device::execute_run() do { - debugger_instruction_hook(this, m_r[7]); + debugger_instruction_hook(m_r[7]); m_mask_interrupts = 0; @@ -3363,7 +3363,7 @@ void cp1610_cpu_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_r[7]).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_flags ).noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void cp1610_cpu_device::device_reset() diff --git a/src/devices/cpu/cubeqcpu/cubeqcpu.cpp b/src/devices/cpu/cubeqcpu/cubeqcpu.cpp index db5ccf9eba8..270ac0e29c8 100644 --- a/src/devices/cpu/cubeqcpu/cubeqcpu.cpp +++ b/src/devices/cpu/cubeqcpu/cubeqcpu.cpp @@ -243,7 +243,7 @@ void cquestsnd_cpu_device::device_start() state_add(STATE_GENPC, "GENPC", m_pc).formatstr("%02X").noshow(); state_add(STATE_GENPCBASE, "CURPC", m_pc).formatstr("%02X").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -347,7 +347,7 @@ void cquestrot_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).formatstr("%02X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_flags).formatstr("%3s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -480,7 +480,7 @@ void cquestlin_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_curpc).formatstr("%02X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_flags).formatstr("%6s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -563,7 +563,7 @@ void cquestsnd_cpu_device::execute_run() int rtn = (inslow >> 27) & 1; int _rin = (inslow >> 26) & 1; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); /* Don't think this matters, but just in case */ if (rtn) @@ -821,7 +821,7 @@ void cquestrot_cpu_device::execute_run() int dsrclatch; uint16_t data_in = 0xffff; - debugger_instruction_hook(this, ROT_PC); + debugger_instruction_hook(ROT_PC); /* Handle DRAM accesses - I ought to check this... */ if (!(m_clkcnt & 3)) @@ -1238,7 +1238,7 @@ void cquestlin_cpu_device::execute_run() uint16_t data_in = 0; - debugger_instruction_hook(this, m_pc[prog]); + debugger_instruction_hook(m_pc[prog]); /* Handle accesses to and from shared SRAM */ if (prog == FOREGROUND) diff --git a/src/devices/cpu/diablo/diablo1300.cpp b/src/devices/cpu/diablo/diablo1300.cpp index 2e04796a582..582320c37b8 100644 --- a/src/devices/cpu/diablo/diablo1300.cpp +++ b/src/devices/cpu/diablo/diablo1300.cpp @@ -109,7 +109,7 @@ void diablo1300_cpu_device::device_start() save_item(NAME(m_power_on)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } void diablo1300_cpu_device::device_stop() @@ -190,7 +190,7 @@ void diablo1300_cpu_device::execute_run() while (m_icount > 0) { - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); if( m_power_on == ASSERT_LINE ) { diff --git a/src/devices/cpu/drcbec.cpp b/src/devices/cpu/drcbec.cpp index 41566614233..5dc7499988a 100644 --- a/src/devices/cpu/drcbec.cpp +++ b/src/devices/cpu/drcbec.cpp @@ -519,7 +519,8 @@ int drcbe_c::execute(code_handle &entry) fatalerror("Unexpected opcode\n"); case MAKE_OPCODE_SHORT(OP_DEBUG, 4, 0): // DEBUG pc - debugger_instruction_hook(&m_device, PARAM0); + if (m_device.machine().debug_flags & DEBUG_FLAG_CALL_HOOK) + m_device.debug()->instruction_hook(PARAM0); break; case MAKE_OPCODE_SHORT(OP_HASHJMP, 4, 0): // HASHJMP mode,pc,handle diff --git a/src/devices/cpu/drcbex64.cpp b/src/devices/cpu/drcbex64.cpp index 1f85f470cd3..0a32b265bc7 100644 --- a/src/devices/cpu/drcbex64.cpp +++ b/src/devices/cpu/drcbex64.cpp @@ -651,7 +651,9 @@ drcbe_x64::drcbe_x64(drcuml_state &drcuml, device_t &device, drc_cache &cache, u m_absmask64[0] = m_absmask64[1] = 0x7fffffffffffffffU; // get pointers to C functions we need to call - m_near.debug_cpu_instruction_hook = (x86code *)debugger_instruction_hook; + using debugger_hook_func = void (*)(device_debug *, offs_t); + static const debugger_hook_func debugger_inst_hook = [] (device_debug *dbg, offs_t pc) { dbg->instruction_hook(pc); }; // TODO: kill trampoline if possible + m_near.debug_cpu_instruction_hook = (x86code *)debugger_inst_hook; if (LOG_HASHJMPS) { m_near.debug_log_hashjmp = (x86code *)debug_log_hashjmp; @@ -2797,17 +2799,17 @@ void drcbe_x64::op_debug(x86code *&dst, const instruction &inst) be_parameter pcp(*this, inst.param(0), PTYPE_MRI); // test and branch - emit_mov_r64_imm(dst, REG_RAX, (uintptr_t)&m_device.machine().debug_flags); // mov rax,&debug_flags + emit_mov_r64_imm(dst, REG_RAX, (uintptr_t)&m_device.machine().debug_flags); // mov rax,&debug_flags emit_test_m32_imm(dst, MBD(REG_RAX, 0), DEBUG_FLAG_CALL_HOOK); // test [debug_flags],DEBUG_FLAG_CALL_HOOK emit_link skip = { nullptr }; emit_jcc_short_link(dst, x64emit::COND_Z, skip); // jz skip // push the parameter - emit_mov_r64_imm(dst, REG_PARAM1, (uintptr_t)&m_device); // mov param1,device + emit_mov_r64_imm(dst, REG_PARAM1, (uintptr_t)m_device.debug()); // mov param1,device.debug emit_mov_r32_p32(dst, REG_PARAM2, pcp); // mov param2,pcp emit_smart_call_m64(dst, &m_near.debug_cpu_instruction_hook); // call debug_cpu_instruction_hook - resolve_link(dst, skip); // skip: + resolve_link(dst, skip); // skip: } } diff --git a/src/devices/cpu/drcbex86.cpp b/src/devices/cpu/drcbex86.cpp index cb70ea0bf00..f1a39068ee1 100644 --- a/src/devices/cpu/drcbex86.cpp +++ b/src/devices/cpu/drcbex86.cpp @@ -3000,6 +3000,9 @@ void drcbe_x86::op_debug(x86code *&dst, const instruction &inst) assert_no_condition(inst); assert_no_flags(inst); + using debugger_hook_func = void (*)(device_debug *, offs_t); + static const debugger_hook_func debugger_inst_hook = [] (device_debug *dbg, offs_t pc) { dbg->instruction_hook(pc); }; // TODO: kill trampoline if possible + if ((m_device.machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) { // normalize parameters @@ -3008,14 +3011,14 @@ void drcbe_x86::op_debug(x86code *&dst, const instruction &inst) // test and branch emit_test_m32_imm(dst, MABS(&m_device.machine().debug_flags), DEBUG_FLAG_CALL_HOOK); // test [debug_flags],DEBUG_FLAG_CALL_HOOK emit_link skip = { nullptr }; - emit_jcc_short_link(dst, x86emit::COND_Z, skip); // jz skip + emit_jcc_short_link(dst, x86emit::COND_Z, skip); // jz skip // push the parameter emit_mov_m32_p32(dst, MBD(REG_ESP, 4), pcp); // mov [esp+4],pcp - emit_mov_m32_imm(dst, MBD(REG_ESP, 0), (uintptr_t)&m_device); // mov [esp],device - emit_call(dst, (x86code *)debugger_instruction_hook); // call debug_cpu_instruction_hook + emit_mov_m32_imm(dst, MBD(REG_ESP, 0), (uintptr_t)m_device.debug()); // mov [esp],device.debug + emit_call(dst, (x86code *)debugger_inst_hook); // call debugger_inst_hook - track_resolve_link(dst, skip); // skip: + track_resolve_link(dst, skip); // skip: } } diff --git a/src/devices/cpu/dsp16/dsp16.cpp b/src/devices/cpu/dsp16/dsp16.cpp index 21cddebbf0a..ff31edc361c 100644 --- a/src/devices/cpu/dsp16/dsp16.cpp +++ b/src/devices/cpu/dsp16/dsp16.cpp @@ -226,7 +226,7 @@ void dsp16_device_base::device_start() { m_core.reset(reinterpret_cast<core_state *>(m_drc_cache.alloc_near(sizeof(core_state)))); new (m_core.get()) core_state(m_yaau_bits); - m_icountptr = &m_core->icount; + set_icountptr(m_core->icount); m_spaces[AS_PROGRAM] = &space(AS_PROGRAM); m_spaces[AS_DATA] = &space(AS_DATA); @@ -381,79 +381,41 @@ void dsp16_device_base::device_reset() void dsp16_device_base::execute_run() { - while (m_core->icount_remaining()) + if (machine().debug_flags & DEBUG_FLAG_ENABLED) { - // execute one cycle of an instruction - switch (m_cache_mode) + while (m_core->icount_remaining()) { - case cache::NONE: - case cache::LOAD: - execute_one_rom(); - break; - case cache::EXECUTE: - execute_one_cache(); - break; - } - m_core->decrement_icount(); - - // step the serial I/O clock divider - if (m_sio_clk_div) - { - --m_sio_clk_div; - } - else - { - bool const active(!m_sio_clk); - m_sio_clk = active ? 1U : 0U; - if (sio_ick_active()) + switch (m_cache_mode) { - if (active) - sio_ick_active_edge(); - m_ick_cb(m_sio_clk); - } - if (sio_ock_active()) - { - m_ock_cb(m_sio_clk); - if (active) - sio_ock_active_edge(); - } - m_sio_clk_div = m_sio_clk_res; - } - - // udpate parallel input strobe - if (m_pio_pids_cnt) - { - assert(!m_pids_out); - if (!--m_pio_pids_cnt) - { - if (!m_pio_r_cb.isnull()) - m_pio_pdx_in = m_pio_r_cb(machine().dummy_space(), m_psel_out, 0xffffU); - m_pids_cb(m_pids_out = 1U); - LOGPIO("DSP16: PIO read active edge PSEL = %u, PDX = %04X (PC = %04X)\n", m_psel_out, m_pio_pdx_in, m_st_pcbase); + case cache::NONE: + execute_some_rom<true, false>(); + break; + case cache::LOAD: + execute_some_rom<true, true>(); + break; + case cache::EXECUTE: + execute_some_cache<true>(); + break; } } - else - { - assert(m_pids_out); - } - - // udpate parallel output strobe - if (m_pio_pods_cnt) + } + else + { + while (m_core->icount_remaining()) { - assert(!m_pods_out); - if (!--m_pio_pods_cnt) + switch (m_cache_mode) { - LOGPIO("DSP16: PIO write active edge PSEL = %u, PDX = %04X (PC = %04X)\n", m_psel_out, m_pio_pdx_out, m_st_pcbase); - m_pods_cb(1U); - m_pio_w_cb(machine().dummy_space(), m_psel_out, m_pio_pdx_out, 0xffffU); - m_pods_out = 1U; - m_pdb_w_cb(machine().dummy_space(), m_psel_out, 0xffffU, 0x0000U); + case cache::NONE: + execute_some_rom<false, false>(); + break; + case cache::LOAD: + execute_some_rom<false, true>(); + break; + case cache::EXECUTE: + execute_some_cache<false>(); + break; } } - else - { - assert(m_pods_out); - } } } @@ -691,605 +653,644 @@ void dsp16_device_base::program_map(address_map &map) instruction execution ***********************************************************************/ -inline void dsp16_device_base::execute_one_rom() +template <bool Debugger, bool Caching> inline void dsp16_device_base::execute_some_rom() { - u16 const op(m_cache[m_cache_ptr]); - bool const cache_load(cache::LOAD == m_cache_mode); - bool const last_cache_load(cache_load && (m_cache_ptr == m_cache_limit)); - u16 const cache_next((m_cache_ptr + (cache_load ? 1 : 0)) & 0x0fU); - u16 *fetch_target(&m_cache[cache_next]); - u16 fetch_addr(0U); - flags predicate(FLAGS_PRED_NONE); - - switch (m_phase) + assert(bool(machine().debug_flags & DEBUG_FLAG_ENABLED) == Debugger); + for (bool mode_change = false; !mode_change && m_core->icount_remaining(); m_core->decrement_icount()) { - case phase::PURGE: - fetch_addr = m_core->xaau_pc; - m_phase = phase::OP1; - break; + assert((cache::LOAD == m_cache_mode) == Caching); - case phase::OP1: - if (machine().debug_flags & DEBUG_FLAG_ENABLED) + u16 const op(m_cache[m_cache_ptr]); + bool const last_cache_load(Caching && (m_cache_ptr == m_cache_limit)); + u16 const cache_next((m_cache_ptr + (Caching ? 1 : 0)) & 0x0fU); + u16 *fetch_target(&m_cache[cache_next]); + u16 fetch_addr(0U); + flags predicate(FLAGS_PRED_NONE); + + switch (m_phase) { - if (FLAGS_PRED_NONE == (m_flags & FLAGS_PRED_MASK)) - { - debugger_instruction_hook(this, m_st_pcbase); - } - else + case phase::PURGE: + fetch_addr = m_core->xaau_pc; + m_phase = phase::OP1; + break; + + case phase::OP1: + if (Debugger) { - switch (op >> 11) + if (FLAGS_PRED_NONE == (m_flags & FLAGS_PRED_MASK)) { - case 0x00: // goto JA - case 0x01: - case 0x10: // call JA - case 0x11: - break; - case 0x18: // goto B - switch (op_b(op)) + debugger_instruction_hook(m_st_pcbase); + } + else + { + switch (op >> 11) { - case 0x0: // return - case 0x2: // goto pt - case 0x3: // call pt + case 0x00: // goto JA + case 0x01: + case 0x10: // call JA + case 0x11: + break; + case 0x18: // goto B + switch (op_b(op)) + { + case 0x0: // return + case 0x2: // goto pt + case 0x3: // call pt + break; + default: + debugger_instruction_hook(m_st_pcbase); + } break; default: - debugger_instruction_hook(this, m_st_pcbase); + debugger_instruction_hook(m_st_pcbase); } - break; - default: - debugger_instruction_hook(this, m_st_pcbase); } } - } - // IACK is updated for the next instruction - switch (m_flags & FLAGS_IACK_MASK) - { - case FLAGS_IACK_SET: - if (m_iack_out) - { - LOGINT("DSP16: asserting IACK (PC = %04X)\n", m_st_pcbase); - m_iack_cb(m_iack_out = 0U); - standard_irq_callback(DSP16_INT_LINE); - } - break; - case FLAGS_IACK_CLEAR: - if (!m_iack_out) + // IACK is updated for the next instruction + switch (m_flags & FLAGS_IACK_MASK) { - LOGINT("DSP16: de-asserting IACK (PC = %04X)\n", m_st_pcbase); - m_iack_cb(m_iack_out = 1U); - m_pio_pioc &= 0xfffeU; + case FLAGS_IACK_SET: + if (m_iack_out) + { + LOGINT("DSP16: asserting IACK (PC = %04X)\n", m_st_pcbase); + m_iack_cb(m_iack_out = 0U); + standard_irq_callback(DSP16_INT_LINE); + } + break; + case FLAGS_IACK_CLEAR: + if (!m_iack_out) + { + LOGINT("DSP16: de-asserting IACK (PC = %04X)\n", m_st_pcbase); + m_iack_cb(m_iack_out = 1U); + m_pio_pioc &= 0xfffeU; + } + break; + default: + break; } - break; - default: - break; - } - set_iack(FLAGS_IACK_NONE); + set_iack(FLAGS_IACK_NONE); - // if we're not servicing an interrupt or caching - if (m_iack_out && (cache::NONE == m_cache_mode)) - { - // TODO: is INT sampled on any instruction or only interruptible instructions? - // if an unmasked interrupt is pending - if ((m_pio_pioc & m_int_enable[0] & 0x001eU) || (BIT(m_int_enable[0], 0) && (CLEAR_LINE != m_int_in))) + // if we're not servicing an interrupt or caching + if (m_iack_out && !Caching) { - // if the current instruction is interruptible - if (op_interruptible(op)) + // TODO: is INT sampled on any instruction or only interruptible instructions? + // if an unmasked interrupt is pending + if ((m_pio_pioc & m_int_enable[0] & 0x001eU) || (BIT(m_int_enable[0], 0) && (CLEAR_LINE != m_int_in))) { - if (pio_int_enable() && (CLEAR_LINE != m_int_in)) + // if the current instruction is interruptible + if (op_interruptible(op)) { - if (ASSERT_LINE != m_int_in) - m_int_in = CLEAR_LINE; - m_pio_pioc |= 0x0001U; + if (pio_int_enable() && (CLEAR_LINE != m_int_in)) + { + if (ASSERT_LINE != m_int_in) + m_int_in = CLEAR_LINE; + m_pio_pioc |= 0x0001U; + } + LOGINT( + "DSP16: servicing interrupts%s%s%s%s%s (PC = %04X)\n", + (pio_ibf_enable() && pio_ibf_status()) ? " IBF" : "", + (pio_obe_enable() && pio_obe_status()) ? " OBE" : "", + (pio_pids_enable() && pio_pids_status()) ? " PIDS" : "", + (pio_pods_enable() && pio_pods_status()) ? " PODS" : "", + (pio_int_enable() && pio_int_status()) ? " INT" : "", + m_st_pcbase); + set_iack(FLAGS_IACK_SET); + fetch_addr = m_core->xaau_next_pc(); + m_int_enable[0] = m_int_enable[1]; + m_core->xaau_pc = 0x0001U; + m_phase = phase::PURGE; + break; } - LOGINT( - "DSP16: servicing interrupts%s%s%s%s%s (PC = %04X)\n", - (pio_ibf_enable() && pio_ibf_status()) ? " IBF" : "", - (pio_obe_enable() && pio_obe_status()) ? " OBE" : "", - (pio_pids_enable() && pio_pids_status()) ? " PIDS" : "", - (pio_pods_enable() && pio_pods_status()) ? " PODS" : "", - (pio_int_enable() && pio_int_status()) ? " INT" : "", - m_st_pcbase); - set_iack(FLAGS_IACK_SET); - fetch_addr = m_core->xaau_next_pc(); - m_int_enable[0] = m_int_enable[1]; - m_core->xaau_pc = 0x0001U; - m_phase = phase::PURGE; - break; } } - } - // normal opcode execution - fetch_addr = set_xaau_pc_offset(m_core->xaau_pc + 1); - m_int_enable[0] = m_int_enable[1]; - switch (op >> 11) - { - case 0x00: // goto JA - case 0x01: - case 0x10: // call JA - case 0x11: - if (check_predicate()) + // normal opcode execution + fetch_addr = set_xaau_pc_offset(m_core->xaau_pc + 1); + m_int_enable[0] = m_int_enable[1]; + switch (op >> 11) { - if (BIT(op, 15)) - m_core->xaau_pr = m_core->xaau_pc; - set_xaau_pc_offset(op_ja(op)); - } - m_phase = phase::PURGE; - break; - - case 0x02: // R = M - case 0x03: - yaau_short_immediate_load(op); - break; + case 0x00: // goto JA + case 0x01: + case 0x10: // call JA + case 0x11: + if (check_predicate()) + { + if (BIT(op, 15)) + m_core->xaau_pr = m_core->xaau_pc; + set_xaau_pc_offset(op_ja(op)); + } + m_phase = phase::PURGE; + break; - case 0x04: // F1 ; Y = a1[l] - case 0x1c: // F1 ; Y = a0[l] - fetch_target = nullptr; - m_phase = phase::OP2; - break; + case 0x02: // R = M + case 0x03: + yaau_short_immediate_load(op); + break; - case 0x05: // F1 ; Z : aT[l] - { + case 0x04: // F1 ; Y = a1[l] + case 0x1c: // F1 ; Y = a0[l] fetch_target = nullptr; - s64 const d(m_core->dau_f1(op)); - m_core->dau_temp = u16(u64(dau_saturate(op_d(~op))) >> (op_x(op) ? 16 : 0)); - m_core->op_dau_ad(op) = d; - m_core->dau_set_at(op, yaau_read(op)); m_phase = phase::OP2; - } - break; + break; - case 0x06: // F1 ; Y - m_core->op_dau_ad(op) = m_core->dau_f1(op); - yaau_read(op); - break; + case 0x05: // F1 ; Z : aT[l] + { + fetch_target = nullptr; + s64 const d(m_core->dau_f1(op)); + m_core->dau_temp = u16(u64(dau_saturate(op_d(~op))) >> (op_x(op) ? 16 : 0)); + m_core->op_dau_ad(op) = d; + m_core->dau_set_at(op, yaau_read(op)); + m_phase = phase::OP2; + } + break; - case 0x07: // F1 ; aT[l] = Y - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_set_at(op, yaau_read(op)); - break; + case 0x06: // F1 ; Y + m_core->op_dau_ad(op) = m_core->dau_f1(op); + yaau_read(op); + break; - case 0x08: // aT = R - assert(!(op & 0x000fU)); // reserved field? - fetch_target = nullptr; - m_core->dau_set_at(op, get_r(op)); - m_phase = phase::OP2; - break; + case 0x07: // F1 ; aT[l] = Y + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_set_at(op, yaau_read(op)); + break; - case 0x09: // R = a0 - case 0x0b: // R = a1 - assert(!(op & 0x040fU)); // reserved fields? - fetch_target = nullptr; - set_r(op, u16(u64(dau_saturate(BIT(op, 12))) >> 16)); - m_phase = phase::OP2; - break; + case 0x08: // aT = R + assert(!(op & 0x000fU)); // reserved field? + fetch_target = nullptr; + m_core->dau_set_at(op, get_r(op)); + m_phase = phase::OP2; + break; - case 0x0a: // R = N - assert(!(op & 0x040fU)); // reserved fields? - m_phase = phase::OP2; - fetch_target = &m_rom_data; - break; + case 0x09: // R = a0 + case 0x0b: // R = a1 + assert(!(op & 0x040fU)); // reserved fields? + fetch_target = nullptr; + set_r(op, u16(u64(dau_saturate(BIT(op, 12))) >> 16)); + m_phase = phase::OP2; + break; - case 0x0c: // Y = R - assert(!(op & 0x0400U)); // reserved field? - fetch_target = nullptr; - m_phase = phase::OP2; - break; + case 0x0a: // R = N + assert(!(op & 0x040fU)); // reserved fields? + m_phase = phase::OP2; + fetch_target = &m_rom_data; + break; - case 0x0d: // Z : R - fetch_target = nullptr; - m_core->dau_temp = get_r(op); - set_r(op, yaau_read(op)); - m_phase = phase::OP2; - break; + case 0x0c: // Y = R + assert(!(op & 0x0400U)); // reserved field? + fetch_target = nullptr; + m_phase = phase::OP2; + break; - case 0x0e: // do K { instr1...instrIN } # redo K - { - u16 const ni(op_ni(op)); - if (ni) - { - m_cache_mode = cache::LOAD; - fetch_target = &m_cache[m_cache_ptr = 1U]; - m_cache_limit = ni; - m_cache_pcbase = m_st_pcbase; - } - else + case 0x0d: // Z : R + fetch_target = nullptr; + m_core->dau_temp = get_r(op); + set_r(op, yaau_read(op)); + m_phase = phase::OP2; + break; + + case 0x0e: // do K { instr1...instrIN } # redo K { - fetch_target = nullptr; - m_cache_mode = cache::EXECUTE; - m_phase = phase::PREFETCH; - m_cache_ptr = 1U; + u16 const ni(op_ni(op)); + if (ni) + { + mode_change = true; + fetch_target = &m_cache[m_cache_ptr = 1U]; + m_cache_mode = cache::LOAD; + m_cache_limit = ni; + m_cache_pcbase = m_st_pcbase; + } + else + { + mode_change = true; + fetch_target = nullptr; + m_cache_mode = cache::EXECUTE; + m_phase = phase::PREFETCH; + m_cache_ptr = 1U; + } + m_cache_iterations = op_k(op); + assert(m_cache_iterations >= 2U); // p3-25: "The iteration count can be between 2 and 127, inclusive" } - m_cache_iterations = op_k(op); - assert(m_cache_iterations >= 2U); // p3-25: "The iteration count can be between 2 and 127, inclusive" - } - break; + break; - case 0x0f: // R = Y - assert(!(op & 0x0400U)); // reserved field? - fetch_target = nullptr; - set_r(op, yaau_read(op)); - m_phase = phase::OP2; - break; + case 0x0f: // R = Y + assert(!(op & 0x0400U)); // reserved field? + fetch_target = nullptr; + set_r(op, yaau_read(op)); + m_phase = phase::OP2; + break; - case 0x12: // ifc CON F2 - { - bool const con(op_dau_con(op, false)); - ++m_core->dau_c[1]; - if (con) + case 0x12: // ifc CON F2 { - m_core->dau_f2(op); - m_core->dau_c[2] = m_core->dau_c[1]; + bool const con(op_dau_con(op, false)); + ++m_core->dau_c[1]; + if (con) + { + m_core->dau_f2(op); + m_core->dau_c[2] = m_core->dau_c[1]; + } } - } - break; - - case 0x13: // if CON F2 - if (op_dau_con(op, true)) - m_core->dau_f2(op); - break; + break; - case 0x14: // F1 ; Y = y[l] - fetch_target = nullptr; - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_phase = phase::OP2; - break; + case 0x13: // if CON F2 + if (op_dau_con(op, true)) + m_core->dau_f2(op); + break; - case 0x15: // F1 ; Z : y[l] - fetch_target = nullptr; - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_temp = m_core->dau_get_y(op); - m_core->dau_set_y(op, yaau_read(op)); - m_phase = phase::OP2; - break; + case 0x14: // F1 ; Y = y[l] + fetch_target = nullptr; + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_phase = phase::OP2; + break; - case 0x16: // F1 ; x = Y - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_x = yaau_read(op); - break; + case 0x15: // F1 ; Z : y[l] + fetch_target = nullptr; + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_temp = m_core->dau_get_y(op); + m_core->dau_set_y(op, yaau_read(op)); + m_phase = phase::OP2; + break; - case 0x17: // F1 ; y[l] = Y - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_set_y(op, yaau_read(op)); - break; + case 0x16: // F1 ; x = Y + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_x = yaau_read(op); + break; - case 0x18: // goto B - assert(!(op & 0x00ffU)); // reserved field? - switch (op_b(op)) - { - case 0x0: // return - if (check_predicate()) - m_core->xaau_pc = m_core->xaau_pr; + case 0x17: // F1 ; y[l] = Y + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_set_y(op, yaau_read(op)); break; - case 0x1: // ireturn + + case 0x18: // goto B + assert(!(op & 0x00ffU)); // reserved field? + switch (op_b(op)) + { + case 0x0: // return + if (check_predicate()) + m_core->xaau_pc = m_core->xaau_pr; + break; + case 0x1: // ireturn + if (m_iack_out) + logerror("DSP16: ireturn when not servicing interrupt (PC = %04X)\n", m_st_pcbase); + LOGINT("DSP16: return from interrupt (PC = %04X)\n", m_st_pcbase); + set_iack(FLAGS_IACK_CLEAR); + m_core->xaau_pc = m_core->xaau_pi; + break; + case 0x2: // goto pt + if (check_predicate()) + m_core->xaau_pc = m_core->xaau_pt; + break; + case 0x3: // call pt + if (check_predicate()) + { + m_core->xaau_pr = m_core->xaau_pc; + m_core->xaau_pc = m_core->xaau_pt; + } + break; + case 0x4: // Reserved + case 0x5: + case 0x6: + case 0x7: + throw emu_fatalerror("DSP16: reserved B value %01X (PC = %04X)\n", op_b(op), m_st_pcbase); + } if (m_iack_out) - logerror("DSP16: ireturn when not servicing interrupt (PC = %04X)\n", m_st_pcbase); - LOGINT("DSP16: return from interrupt (PC = %04X)\n", m_st_pcbase); - set_iack(FLAGS_IACK_CLEAR); - m_core->xaau_pc = m_core->xaau_pi; + m_core->xaau_pi = m_core->xaau_pc; + m_phase = phase::PURGE; break; - case 0x2: // goto pt - if (check_predicate()) - m_core->xaau_pc = m_core->xaau_pt; + + case 0x19: // F1 ; y = a0 ; x = *pt++[i] + case 0x1b: // F1 ; y = a1 ; x = *pt++[i] + { + assert(!(op & 0x000fU)); // reserved field? + s64 const d(m_core->dau_f1(op)); + s64 a(m_core->dau_a[BIT(op, 12)]); + // FIXME: is saturation applied when transferring a to y? + m_core->dau_y = u32(u64(a)); + m_core->op_dau_ad(op) = d; + fetch_target = nullptr; + m_rom_data = m_spaces[AS_PROGRAM]->read_word(m_core->xaau_pt); + m_phase = phase::OP2; + } break; - case 0x3: // call pt - if (check_predicate()) + + case 0x1a: // if CON # icall + assert(!(op & 0x03e0U)); // reserved field? + predicate = op_dau_con(op, true) ? FLAGS_PRED_TRUE : FLAGS_PRED_FALSE; + if (BIT(op, 10)) { - m_core->xaau_pr = m_core->xaau_pc; - m_core->xaau_pc = m_core->xaau_pt; + fetch_target = nullptr; + assert(0x000eU == op_con(op)); // CON must be true for icall? + m_phase = phase::OP2; } break; - case 0x4: // Reserved - case 0x5: - case 0x6: - case 0x7: - throw emu_fatalerror("DSP16: reserved B value %01X (PC = %04X)\n", op_b(op), m_st_pcbase); - } - if (m_iack_out) - m_core->xaau_pi = m_core->xaau_pc; - m_phase = phase::PURGE; - break; - case 0x19: // F1 ; y = a0 ; x = *pt++[i] - case 0x1b: // F1 ; y = a1 ; x = *pt++[i] - { - assert(!(op & 0x000fU)); // reserved field? - s64 const d(m_core->dau_f1(op)); - s64 a(m_core->dau_a[BIT(op, 12)]); - // FIXME: is saturation applied when transferring a to y? - m_core->dau_y = u32(u64(a)); - m_core->op_dau_ad(op) = d; + case 0x1d: // F1 ; Z : y ; x = *pt++[i] + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_temp = s16(m_core->dau_y >> 16); + m_core->dau_set_y(yaau_read(op)); fetch_target = nullptr; m_rom_data = m_spaces[AS_PROGRAM]->read_word(m_core->xaau_pt); m_phase = phase::OP2; - } - break; + break; - case 0x1a: // if CON # icall - assert(!(op & 0x03e0U)); // reserved field? - predicate = op_dau_con(op, true) ? FLAGS_PRED_TRUE : FLAGS_PRED_FALSE; - if (BIT(op, 10)) - { + case 0x1e: // Reserved + throw emu_fatalerror("DSP16: reserved op %u (PC = %04X)\n", op >> 11, m_st_pcbase); + break; + + case 0x1f: // F1 ; y = Y ; x = *pt++[i] + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_set_y(yaau_read(op)); fetch_target = nullptr; - assert(0x000eU == op_con(op)); // CON must be true for icall? + m_rom_data = m_spaces[AS_PROGRAM]->read_word(m_core->xaau_pt); m_phase = phase::OP2; - } - break; + break; - case 0x1d: // F1 ; Z : y ; x = *pt++[i] - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_temp = s16(m_core->dau_y >> 16); - m_core->dau_set_y(yaau_read(op)); - fetch_target = nullptr; - m_rom_data = m_spaces[AS_PROGRAM]->read_word(m_core->xaau_pt); - m_phase = phase::OP2; - break; + default: + throw emu_fatalerror("DSP16: unimplemented op %u (PC = %04X)\n", op >> 11, m_st_pcbase); + } - case 0x1e: // Reserved - throw emu_fatalerror("DSP16: reserved op %u (PC = %04X)\n", op >> 11, m_st_pcbase); + if (Caching && (phase::OP1 == m_phase)) + { + // if the last instruction loaded to the cache completes in a single cycle, there's an extra cycle for a data fetch + if (last_cache_load) + { + mode_change = true; + fetch_target = nullptr; + m_cache_mode = cache::EXECUTE; + m_phase = phase::PREFETCH; + m_cache_ptr = 1U; + --m_cache_iterations; + } + else + { + m_cache_ptr = cache_next; + } + } break; - case 0x1f: // F1 ; y = Y ; x = *pt++[i] - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_set_y(yaau_read(op)); - fetch_target = nullptr; - m_rom_data = m_spaces[AS_PROGRAM]->read_word(m_core->xaau_pt); - m_phase = phase::OP2; - break; + case phase::OP2: + m_phase = phase::OP1; + switch (op >> 11) + { + case 0x04: // F1 ; Y = a1[l] + case 0x1c: // F1 ; Y = a0[l] + yaau_write(op, u16(u64(dau_saturate(BIT(~op, 14))) >> (op_x(op) ? 16 : 0))); + m_core->op_dau_ad(op) = m_core->dau_f1(op); + break; - default: - throw emu_fatalerror("DSP16: unimplemented op %u (PC = %04X)\n", op >> 11, m_st_pcbase); - } + case 0x05: // F1 ; Z : aT[l] + case 0x0d: // Z : R + case 0x15: // F1 ; Z : y[l] + yaau_write_z(op); + break; - if (cache_load && (phase::OP1 == m_phase)) - { - // if the last instruction loaded to the cache completes in a single cycle, there's an extra cycle for a data fetch - if (last_cache_load) - { - fetch_target = nullptr; - m_cache_mode = cache::EXECUTE; - m_phase = phase::PREFETCH; - m_cache_ptr = 1U; - --m_cache_iterations; - } - else - { - m_cache_ptr = cache_next; - } - } - break; + case 0x08: // aT = R + case 0x09: // R = a0 + case 0x0b: // R = a1 + break; - case phase::OP2: - m_phase = phase::OP1; - switch (op >> 11) - { - case 0x04: // F1 ; Y = a1[l] - case 0x1c: // F1 ; Y = a0[l] - yaau_write(op, u16(u64(dau_saturate(BIT(~op, 14))) >> (op_x(op) ? 16 : 0))); - m_core->op_dau_ad(op) = m_core->dau_f1(op); - break; + case 0x0a: // R = N + set_xaau_pc_offset(m_core->xaau_pc + 1); + set_r(op, m_rom_data); + break; - case 0x05: // F1 ; Z : aT[l] - case 0x0d: // Z : R - case 0x15: // F1 ; Z : y[l] - yaau_write_z(op); - break; + case 0x0c: // Y = R + yaau_write(op, get_r(op)); + break; - case 0x08: // aT = R - case 0x09: // R = a0 - case 0x0b: // R = a1 - break; + case 0x0f: // R = Y + break; - case 0x0a: // R = N - set_xaau_pc_offset(m_core->xaau_pc + 1); - set_r(op, m_rom_data); - break; + case 0x14: // F1 ; Y = y[l] + yaau_write(op, m_core->dau_get_y(op)); + break; - case 0x0c: // Y = R - yaau_write(op, get_r(op)); - break; + case 0x19: // F1 ; y = a0 ; x = *pt++[i] + case 0x1b: // F1 ; y = a1 ; x = *pt++[i] + case 0x1f: // F1 ; y = Y ; x = *pt++[i] + m_core->xaau_increment_pt(op); + m_core->dau_x = m_rom_data; + break; - case 0x0f: // R = Y - break; + case 0x1a: // icall + // TODO: does INT get sampled or could an external interrupt be lost here? + assert(BIT(op, 10)); + assert(FLAGS_PRED_TRUE == (m_flags & FLAGS_PRED_MASK)); + if (check_predicate()) + { + LOGINT( + "DSP16: servicing software interrupt%s%s%s%s%s (PC = %04X)\n", + (pio_ibf_enable() && pio_ibf_status()) ? " IBF" : "", + (pio_obe_enable() && pio_obe_status()) ? " OBE" : "", + (pio_pids_enable() && pio_pids_status()) ? " PIDS" : "", + (pio_pods_enable() && pio_pods_status()) ? " PODS" : "", + (pio_int_enable() && pio_int_status()) ? " INT" : "", + m_st_pcbase); + set_iack(FLAGS_IACK_SET); + m_core->xaau_pc = 0x0002U; + } + m_phase = phase::PURGE; + break; - case 0x14: // F1 ; Y = y[l] - yaau_write(op, m_core->dau_get_y(op)); - break; + case 0x1d: // F1 ; Z : y ; x = *pt++[i] + m_core->xaau_increment_pt(op); + m_core->dau_x = m_rom_data; + yaau_write_z(op); + break; - case 0x19: // F1 ; y = a0 ; x = *pt++[i] - case 0x1b: // F1 ; y = a1 ; x = *pt++[i] - case 0x1f: // F1 ; y = Y ; x = *pt++[i] - m_core->xaau_increment_pt(op); - m_core->dau_x = m_rom_data; - break; + default: + throw emu_fatalerror("DSP16: op %u doesn't take two cycles to run from ROM\n", op >> 11); + } - case 0x1a: // icall - // TODO: does INT get sampled or could an external interrupt be lost here? - assert(BIT(op, 10)); - assert(FLAGS_PRED_TRUE == (m_flags & FLAGS_PRED_MASK)); - if (check_predicate()) + if (last_cache_load) { - LOGINT( - "DSP16: servicing software interrupt%s%s%s%s%s (PC = %04X)\n", - (pio_ibf_enable() && pio_ibf_status()) ? " IBF" : "", - (pio_obe_enable() && pio_obe_status()) ? " OBE" : "", - (pio_pids_enable() && pio_pids_status()) ? " PIDS" : "", - (pio_pods_enable() && pio_pods_status()) ? " PODS" : "", - (pio_int_enable() && pio_int_status()) ? " INT" : "", - m_st_pcbase); - set_iack(FLAGS_IACK_SET); - m_core->xaau_pc = 0x0002U; + mode_change = true; + fetch_target = nullptr; + m_cache_mode = cache::EXECUTE; + m_cache_ptr = 1U; + --m_cache_iterations; + overlap_rom_data_read(); + } + else + { + fetch_addr = m_core->xaau_pc; + if (Caching) + m_cache_ptr = cache_next; } - m_phase = phase::PURGE; - break; - - case 0x1d: // F1 ; Z : y ; x = *pt++[i] - m_core->xaau_increment_pt(op); - m_core->dau_x = m_rom_data; - yaau_write_z(op); break; default: - throw emu_fatalerror("DSP16: op %u doesn't take two cycles to run from ROM\n", op >> 11); - } - - if (last_cache_load) - { - fetch_target = nullptr; - m_cache_mode = cache::EXECUTE; - m_cache_ptr = 1U; - --m_cache_iterations; - overlap_rom_data_read(); + throw emu_fatalerror("DSP16: inappropriate phase for ROM execution\n"); } - else - { - fetch_addr = m_core->xaau_pc; - if (cache_load) - m_cache_ptr = cache_next; - } - break; - default: - throw emu_fatalerror("DSP16: inappropriate phase for ROM execution\n"); - } + if (FLAGS_PRED_NONE != (m_flags & FLAGS_PRED_MASK)) + throw emu_fatalerror("DSP16: predicate applied to ineligible op %u (PC = %04X)\n", op >> 11, m_st_pcbase); + set_predicate(predicate); - if (FLAGS_PRED_NONE != (m_flags & FLAGS_PRED_MASK)) - throw emu_fatalerror("DSP16: predicate applied to ineligible op %u (PC = %04X)\n", op >> 11, m_st_pcbase); - set_predicate(predicate); + if (fetch_target) + *fetch_target = m_direct->read_word(fetch_addr); - if (fetch_target) - *fetch_target = m_direct->read_word(fetch_addr); + if (phase::OP1 == m_phase) + { + if (cache::EXECUTE != m_cache_mode) + m_st_pcbase = m_core->xaau_pc; + else + m_st_pcbase = (m_cache_pcbase & 0xf000U) | ((m_cache_pcbase + m_cache_ptr) & 0x0fffU); + } - if (phase::OP1 == m_phase) - { - if (cache::EXECUTE != m_cache_mode) - m_st_pcbase = m_core->xaau_pc; - else - m_st_pcbase = (m_cache_pcbase & 0xf000U) | ((m_cache_pcbase + m_cache_ptr) & 0x0fffU); + sio_step(); + pio_step(); } } -inline void dsp16_device_base::execute_one_cache() +template <bool Debugger> inline void dsp16_device_base::execute_some_cache() { - u16 const op(m_cache[m_cache_ptr]); - bool const at_limit(m_cache_ptr == m_cache_limit); - bool const last_instruction(at_limit && (1U == m_cache_iterations)); - switch (m_phase) + assert(bool(machine().debug_flags & DEBUG_FLAG_ENABLED) == Debugger); + for (bool mode_change = false; !mode_change && m_core->icount_remaining(); m_core->decrement_icount()) { - case phase::OP1: - if (machine().debug_flags & DEBUG_FLAG_ENABLED) - debugger_instruction_hook(this, m_st_pcbase); - m_int_enable[0] = m_int_enable[1]; - switch (op >> 11) + u16 const op(m_cache[m_cache_ptr]); + bool const at_limit(m_cache_ptr == m_cache_limit); + bool const last_instruction(at_limit && (1U == m_cache_iterations)); + switch (m_phase) { - case 0x02: // R = M - case 0x03: - yaau_short_immediate_load(op); - break; - - case 0x04: // F1 ; Y = a1[l] - case 0x1c: // F1 ; Y = a0[l] - m_phase = phase::OP2; - break; - - case 0x05: // F1 ; Z : aT[l] + case phase::OP1: + if (Debugger) + debugger_instruction_hook(m_st_pcbase); + m_int_enable[0] = m_int_enable[1]; + switch (op >> 11) { - s64 const d(m_core->dau_f1(op)); - m_core->dau_temp = u16(u64(dau_saturate(op_d(~op))) >> (op_x(op) ? 16 : 0)); - m_core->op_dau_ad(op) = d; - m_core->dau_set_at(op, yaau_read(op)); + case 0x02: // R = M + case 0x03: + yaau_short_immediate_load(op); + break; + + case 0x04: // F1 ; Y = a1[l] + case 0x1c: // F1 ; Y = a0[l] m_phase = phase::OP2; - } - break; + break; - case 0x06: // F1 ; Y - m_core->op_dau_ad(op) = m_core->dau_f1(op); - yaau_read(op); - break; + case 0x05: // F1 ; Z : aT[l] + { + s64 const d(m_core->dau_f1(op)); + m_core->dau_temp = u16(u64(dau_saturate(op_d(~op))) >> (op_x(op) ? 16 : 0)); + m_core->op_dau_ad(op) = d; + m_core->dau_set_at(op, yaau_read(op)); + m_phase = phase::OP2; + } + break; - case 0x07: // F1 ; aT[l] = Y - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_set_at(op, yaau_read(op)); - break; + case 0x06: // F1 ; Y + m_core->op_dau_ad(op) = m_core->dau_f1(op); + yaau_read(op); + break; - case 0x08: // aT = R - assert(!(op & 0x000fU)); // reserved field? - m_core->dau_set_at(op, get_r(op)); - m_phase = phase::OP2; - break; + case 0x07: // F1 ; aT[l] = Y + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_set_at(op, yaau_read(op)); + break; - case 0x09: // R = a0 - case 0x0b: // R = a1 - assert(!(op & 0x040fU)); // reserved fields? - set_r(op, u16(u64(dau_saturate(BIT(op, 12))) >> 16)); - m_phase = phase::OP2; - break; + case 0x08: // aT = R + assert(!(op & 0x000fU)); // reserved field? + m_core->dau_set_at(op, get_r(op)); + m_phase = phase::OP2; + break; - case 0x0c: // Y = R - assert(!(op & 0x0400U)); // reserved field? - m_phase = phase::OP2; - break; + case 0x09: // R = a0 + case 0x0b: // R = a1 + assert(!(op & 0x040fU)); // reserved fields? + set_r(op, u16(u64(dau_saturate(BIT(op, 12))) >> 16)); + m_phase = phase::OP2; + break; - case 0x0d: // Z : R - m_core->dau_temp = get_r(op); - set_r(op, yaau_read(op)); - m_phase = phase::OP2; - break; + case 0x0c: // Y = R + assert(!(op & 0x0400U)); // reserved field? + m_phase = phase::OP2; + break; - case 0x0f: // R = Y - assert(!(op & 0x0400U)); // reserved field? - set_r(op, yaau_read(op)); - m_phase = phase::OP2; - break; + case 0x0d: // Z : R + m_core->dau_temp = get_r(op); + set_r(op, yaau_read(op)); + m_phase = phase::OP2; + break; - case 0x12: // ifc CON F2 - { - bool const con(op_dau_con(op, false)); - ++m_core->dau_c[1]; - if (con) + case 0x0f: // R = Y + assert(!(op & 0x0400U)); // reserved field? + set_r(op, yaau_read(op)); + m_phase = phase::OP2; + break; + + case 0x12: // ifc CON F2 { - m_core->dau_f2(op); - m_core->dau_c[2] = m_core->dau_c[1]; + bool const con(op_dau_con(op, false)); + ++m_core->dau_c[1]; + if (con) + { + m_core->dau_f2(op); + m_core->dau_c[2] = m_core->dau_c[1]; + } } - } - break; + break; - case 0x13: // if CON F2 - if (op_dau_con(op, true)) - m_core->dau_f2(op); - break; + case 0x13: // if CON F2 + if (op_dau_con(op, true)) + m_core->dau_f2(op); + break; - case 0x14: // F1 ; Y = y[l] - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_phase = phase::OP2; - break; + case 0x14: // F1 ; Y = y[l] + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_phase = phase::OP2; + break; - case 0x15: // F1 ; Z : y[l] - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_temp = m_core->dau_get_y(op); - m_core->dau_set_y(op, yaau_read(op)); - m_phase = phase::OP2; - break; + case 0x15: // F1 ; Z : y[l] + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_temp = m_core->dau_get_y(op); + m_core->dau_set_y(op, yaau_read(op)); + m_phase = phase::OP2; + break; - case 0x16: // F1 ; x = Y - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_x = yaau_read(op); - break; + case 0x16: // F1 ; x = Y + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_x = yaau_read(op); + break; - case 0x17: // F1 ; y[l] = Y - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_set_y(op, yaau_read(op)); - break; + case 0x17: // F1 ; y[l] = Y + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_set_y(op, yaau_read(op)); + break; - case 0x19: // F1 ; y = a0 ; x = *pt++[i] - case 0x1b: // F1 ; y = a1 ; x = *pt++[i] - { - assert(!(op & 0x000fU)); // reserved field? - s64 const d(m_core->dau_f1(op)); - s64 a(m_core->dau_a[BIT(op, 12)]); - // FIXME: is saturation applied when transferring a to y? - m_core->dau_y = u32(u64(a)); - m_core->op_dau_ad(op) = d; + case 0x19: // F1 ; y = a0 ; x = *pt++[i] + case 0x1b: // F1 ; y = a1 ; x = *pt++[i] + { + assert(!(op & 0x000fU)); // reserved field? + s64 const d(m_core->dau_f1(op)); + s64 a(m_core->dau_a[BIT(op, 12)]); + // FIXME: is saturation applied when transferring a to y? + m_core->dau_y = u32(u64(a)); + m_core->op_dau_ad(op) = d; + if (last_instruction) + { + m_rom_data = m_direct->read_word(m_core->xaau_pt); + m_phase = phase::OP2; + } + else + { + m_core->xaau_increment_pt(op); + m_core->dau_x = m_rom_data; + } + } + break; + + case 0x1d: // F1 ; Z : y ; x = *pt++[i] + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_temp = s16(m_core->dau_y >> 16); + m_core->dau_set_y(yaau_read(op)); + m_rom_data = m_direct->read_word(m_core->xaau_pt); + m_phase = phase::OP2; + break; + + case 0x1f: // F1 ; y = Y ; x = *pt++[i] + m_core->op_dau_ad(op) = m_core->dau_f1(op); + m_core->dau_set_y(yaau_read(op)); if (last_instruction) { m_rom_data = m_direct->read_word(m_core->xaau_pt); @@ -1300,126 +1301,107 @@ inline void dsp16_device_base::execute_one_cache() m_core->xaau_increment_pt(op); m_core->dau_x = m_rom_data; } - } - break; + break; - case 0x1d: // F1 ; Z : y ; x = *pt++[i] - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_temp = s16(m_core->dau_y >> 16); - m_core->dau_set_y(yaau_read(op)); - m_rom_data = m_direct->read_word(m_core->xaau_pt); - m_phase = phase::OP2; + default: + throw emu_fatalerror("DSP16: inelligible op %u in cache (PC = %04X)\n", op >> 11, m_st_pcbase); + } break; - case 0x1f: // F1 ; y = Y ; x = *pt++[i] - m_core->op_dau_ad(op) = m_core->dau_f1(op); - m_core->dau_set_y(yaau_read(op)); - if (last_instruction) - { - m_rom_data = m_direct->read_word(m_core->xaau_pt); - m_phase = phase::OP2; - } - else + case phase::OP2: + m_phase = phase::OP1; + switch (op >> 11) { - m_core->xaau_increment_pt(op); - m_core->dau_x = m_rom_data; - } - break; + case 0x04: // F1 ; Y = a1[l] + case 0x1c: // F1 ; Y = a0[l] + yaau_write(op, u16(u64(dau_saturate(BIT(~op, 14))) >> (op_x(op) ? 16 : 0))); + m_core->op_dau_ad(op) = m_core->dau_f1(op); + break; - default: - throw emu_fatalerror("DSP16: inelligible op %u in cache (PC = %04X)\n", op >> 11, m_st_pcbase); - } - break; + case 0x05: // F1 ; Z : aT[l] + case 0x0d: // Z : R + case 0x15: // F1 ; Z : y[l] + yaau_write_z(op); + break; - case phase::OP2: - m_phase = phase::OP1; - switch (op >> 11) - { - case 0x04: // F1 ; Y = a1[l] - case 0x1c: // F1 ; Y = a0[l] - yaau_write(op, u16(u64(dau_saturate(BIT(~op, 14))) >> (op_x(op) ? 16 : 0))); - m_core->op_dau_ad(op) = m_core->dau_f1(op); - break; + case 0x08: // aT = R + case 0x09: // R = a0 + case 0x0b: // R = a1 + break; - case 0x05: // F1 ; Z : aT[l] - case 0x0d: // Z : R - case 0x15: // F1 ; Z : y[l] - yaau_write_z(op); - break; + case 0x0c: // Y = R + yaau_write(op, get_r(op)); + break; - case 0x08: // aT = R - case 0x09: // R = a0 - case 0x0b: // R = a1 - break; + case 0x0f: // R = Y + break; - case 0x0c: // Y = R - yaau_write(op, get_r(op)); - break; + case 0x14: // F1 ; Y = y[l] + yaau_write(op, m_core->dau_get_y(op)); + break; - case 0x0f: // R = Y - break; + case 0x19: // F1 ; y = a0 ; x = *pt++[i] + case 0x1b: // F1 ; y = a1 ; x = *pt++[i] + case 0x1f: // F1 ; y = Y ; x = *pt++[i] + assert(last_instruction); + m_core->xaau_increment_pt(op); + m_core->dau_x = m_rom_data; + break; - case 0x14: // F1 ; Y = y[l] - yaau_write(op, m_core->dau_get_y(op)); - break; + case 0x1d: // F1 ; Z : y ; x = *pt++[i] + m_core->xaau_increment_pt(op); + m_core->dau_x = m_rom_data; + yaau_write_z(op); + break; - case 0x19: // F1 ; y = a0 ; x = *pt++[i] - case 0x1b: // F1 ; y = a1 ; x = *pt++[i] - case 0x1f: // F1 ; y = Y ; x = *pt++[i] - assert(last_instruction); - m_core->xaau_increment_pt(op); - m_core->dau_x = m_rom_data; + default: + throw emu_fatalerror("DSP16: op %u doesn't take two cycles to run from cache\n", op >> 11); + } break; - case 0x1d: // F1 ; Z : y ; x = *pt++[i] - m_core->xaau_increment_pt(op); - m_core->dau_x = m_rom_data; - yaau_write_z(op); + case phase::PREFETCH: break; default: - throw emu_fatalerror("DSP16: op %u doesn't take two cycles to run from cache\n", op >> 11); + throw emu_fatalerror("DSP16: inappropriate phase for cache execution\n"); } - break; - - case phase::PREFETCH: - break; - - default: - throw emu_fatalerror("DSP16: inappropriate phase for cache execution\n"); - } - if (phase::PREFETCH == m_phase) - { - m_phase = phase::OP1; - overlap_rom_data_read(); - m_st_pcbase = (m_cache_pcbase & 0xf000U) | ((m_cache_pcbase + m_cache_ptr) & 0x0fffU); - } - else if (phase::OP1 == m_phase) - { - if (last_instruction) + if (phase::PREFETCH == m_phase) { - // overlapped fetch of next instruction from ROM - m_cache_mode = cache::NONE; - m_cache[m_cache_ptr = 0] = m_direct->read_word(m_core->xaau_pc); - m_st_pcbase = m_core->xaau_pc; + m_phase = phase::OP1; + overlap_rom_data_read(); + m_st_pcbase = (m_cache_pcbase & 0xf000U) | ((m_cache_pcbase + m_cache_ptr) & 0x0fffU); } - else + else if (phase::OP1 == m_phase) { - if (at_limit) + if (last_instruction) { - // loop to first cached instruction - m_cache_ptr = 1U; - --m_cache_iterations; + // overlapped fetch of next instruction from ROM + mode_change = true; + m_cache_mode = cache::NONE; + m_cache[m_cache_ptr = 0] = m_direct->read_word(m_core->xaau_pc); + m_st_pcbase = m_core->xaau_pc; } else { - // move to next cached instruction - m_cache_ptr = (m_cache_ptr + 1) & 0x0fU; + if (at_limit) + { + // loop to first cached instruction + m_cache_ptr = 1U; + --m_cache_iterations; + } + else + { + // move to next cached instruction + m_cache_ptr = (m_cache_ptr + 1) & 0x0fU; + } + overlap_rom_data_read(); + m_st_pcbase = (m_cache_pcbase & 0xf000U) | ((m_cache_pcbase + m_cache_ptr) & 0x0fffU); } - overlap_rom_data_read(); - m_st_pcbase = (m_cache_pcbase & 0xf000U) | ((m_cache_pcbase + m_cache_ptr) & 0x0fffU); } + + sio_step(); + pio_step(); } } @@ -1503,6 +1485,75 @@ void dsp16_device_base::yaau_write_z(u16 op) } /*********************************************************************** + built-in peripherals +***********************************************************************/ + +inline void dsp16_device_base::sio_step() +{ + // step the serial I/O clock divider + if (m_sio_clk_div) + { + --m_sio_clk_div; + } + else + { + bool const active(!m_sio_clk); + m_sio_clk = active ? 1U : 0U; + if (sio_ick_active()) + { + if (active) + sio_ick_active_edge(); + m_ick_cb(m_sio_clk); + } + if (sio_ock_active()) + { + m_ock_cb(m_sio_clk); + if (active) + sio_ock_active_edge(); + } + m_sio_clk_div = m_sio_clk_res; + } +} + +inline void dsp16_device_base::pio_step() +{ + // udpate parallel input strobe + if (m_pio_pids_cnt) + { + assert(!m_pids_out); + if (!--m_pio_pids_cnt) + { + if (!m_pio_r_cb.isnull()) + m_pio_pdx_in = m_pio_r_cb(machine().dummy_space(), m_psel_out, 0xffffU); + m_pids_cb(m_pids_out = 1U); + LOGPIO("DSP16: PIO read active edge PSEL = %u, PDX = %04X (PC = %04X)\n", m_psel_out, m_pio_pdx_in, m_st_pcbase); + } + } + else + { + assert(m_pids_out); + } + + // udpate parallel output strobe + if (m_pio_pods_cnt) + { + assert(!m_pods_out); + if (!--m_pio_pods_cnt) + { + LOGPIO("DSP16: PIO write active edge PSEL = %u, PDX = %04X (PC = %04X)\n", m_psel_out, m_pio_pdx_out, m_st_pcbase); + m_pods_cb(1U); + m_pio_w_cb(machine().dummy_space(), m_psel_out, m_pio_pdx_out, 0xffffU); + m_pods_out = 1U; + m_pdb_w_cb(machine().dummy_space(), m_psel_out, 0xffffU, 0x0000U); + } + } + else + { + assert(m_pods_out); + } +} + +/*********************************************************************** inline helpers ***********************************************************************/ diff --git a/src/devices/cpu/dsp16/dsp16.h b/src/devices/cpu/dsp16/dsp16.h index 49ec622d392..3777208d972 100644 --- a/src/devices/cpu/dsp16/dsp16.h +++ b/src/devices/cpu/dsp16/dsp16.h @@ -234,14 +234,18 @@ private: void program_map(address_map &map); // instruction execution - void execute_one_rom(); - void execute_one_cache(); + template <bool Debugger, bool Caching> void execute_some_rom(); + template <bool Debugger> void execute_some_cache(); void overlap_rom_data_read(); void yaau_short_immediate_load(u16 op); s16 yaau_read(u16 op); void yaau_write(u16 op, s16 value); void yaau_write_z(u16 op); + // built-in peripherals + void sio_step(); + void pio_step(); + // inline helpers static bool op_interruptible(u16 op); bool check_predicate(); diff --git a/src/devices/cpu/dsp32/dsp32.cpp b/src/devices/cpu/dsp32/dsp32.cpp index f8749290604..388484975e9 100644 --- a/src/devices/cpu/dsp32/dsp32.cpp +++ b/src/devices/cpu/dsp32/dsp32.cpp @@ -179,7 +179,7 @@ dsp32c_device::dsp32c_device(const machine_config &mconfig, const char *tag, dev m_output_pins_changed(*this) { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } //------------------------------------------------- diff --git a/src/devices/cpu/dsp32/dsp32ops.hxx b/src/devices/cpu/dsp32/dsp32ops.hxx index f8970c55405..ecffcde443c 100644 --- a/src/devices/cpu/dsp32/dsp32ops.hxx +++ b/src/devices/cpu/dsp32/dsp32ops.hxx @@ -126,7 +126,7 @@ inline void dsp32c_device::execute_one() PROCESS_DEFERRED_MEMORY(); m_ppc = PC; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); op = ROPCODE(PC); m_icount -= 4; // 4 clocks per cycle PC += 4; diff --git a/src/devices/cpu/dsp56k/dsp56k.cpp b/src/devices/cpu/dsp56k/dsp56k.cpp index 6276bd5f586..bbf8b8282d0 100644 --- a/src/devices/cpu/dsp56k/dsp56k.cpp +++ b/src/devices/cpu/dsp56k/dsp56k.cpp @@ -346,7 +346,7 @@ void dsp56k_device::device_start() state_add(STATE_GENSP, "GENSP", m_dsp56k_core.PCU.sp).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_dsp56k_core.PCU.sr).formatstr("%14s").noshow(); - m_icountptr = &m_dsp56k_core.icount; + set_icountptr(m_dsp56k_core.icount); } @@ -462,7 +462,8 @@ static size_t execute_one_new(dsp56k_core* cpustate) { // For MAME cpustate->ppc = PC; - debugger_instruction_hook(cpustate->device, PC); + if (cpustate->device->machine().debug_flags & DEBUG_FLAG_CALL_HOOK) // FIXME: if this was a member, the helper would work + cpustate->device->debug()->instruction_hook(PC); cpustate->op = ROPCODE(PC); uint16_t w0 = ROPCODE(PC); diff --git a/src/devices/cpu/dsp56k/dsp56ops.hxx b/src/devices/cpu/dsp56k/dsp56ops.hxx index a7815da5a4d..7e52d1b2cd0 100644 --- a/src/devices/cpu/dsp56k/dsp56ops.hxx +++ b/src/devices/cpu/dsp56k/dsp56ops.hxx @@ -240,7 +240,8 @@ static void execute_one(dsp56k_core* cpustate) /* For MAME */ cpustate->ppc = PC; - debugger_instruction_hook(cpustate->device, PC); + if (cpustate->device->machine().debug_flags & DEBUG_FLAG_CALL_HOOK) // FIXME: if this was a member, the helper would work + cpustate->device->debug()->instruction_hook(PC); cpustate->op = ROPCODE(PC); /* The words we're going to be working with */ diff --git a/src/devices/cpu/e0c6200/e0c6200.cpp b/src/devices/cpu/e0c6200/e0c6200.cpp index 8b890d1c41b..fa8a241f9ec 100644 --- a/src/devices/cpu/e0c6200/e0c6200.cpp +++ b/src/devices/cpu/e0c6200/e0c6200.cpp @@ -132,7 +132,7 @@ void e0c6200_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_f).formatstr("%4s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -210,7 +210,7 @@ void e0c6200_cpu_device::execute_run() m_jpc = ((m_prev_op & 0xfe0) == 0xe40) ? m_npc : (m_prev_pc & 0x1f00); // fetch next opcode - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_op = m_program->read_word(m_pc) & 0xfff; m_pc = (m_pc & 0x1000) | ((m_pc + 1) & 0x0fff); diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp index 9f7222b5dfb..7791425bb9f 100644 --- a/src/devices/cpu/e132xs/e132xs.cpp +++ b/src/devices/cpu/e132xs/e132xs.cpp @@ -1293,7 +1293,7 @@ void hyperstone_device::init(int scale_mask) save_item(NAME(m_core->clock_cycles_36)); // set our instruction counter - m_icountptr = &m_core->icount; + set_icountptr(m_core->icount); } void e116t_device::device_start() @@ -1641,7 +1641,7 @@ void hyperstone_device::execute_run() dump_registers(); #endif - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); OP = READ_OP(PC); PC += 2; diff --git a/src/devices/cpu/es5510/es5510.cpp b/src/devices/cpu/es5510/es5510.cpp index 1e22ff4c8e1..d461645dec8 100644 --- a/src/devices/cpu/es5510/es5510.cpp +++ b/src/devices/cpu/es5510/es5510.cpp @@ -553,7 +553,7 @@ void es5510_device::device_start() { gpr = std::make_unique<int32_t[]>(0xc0); // 24 bits, right justified instr = std::make_unique<uint64_t[]>(160); // 48 bits, right justified dram = std::make_unique<int16_t[]>(DRAM_SIZE); // there are up to 20 address bits (at least 16 expected), left justified within the 24 bits of a gpr or dadr; we preallocate all of it. - m_icountptr = &icount; + set_icountptr(icount); state_add(STATE_GENPC,"GENPC", pc).noshow(); state_add(STATE_GENPCBASE, "CURPC", pc).noshow(); diff --git a/src/devices/cpu/esrip/esrip.cpp b/src/devices/cpu/esrip/esrip.cpp index 61783fde59e..b4cfa1f0d01 100644 --- a/src/devices/cpu/esrip/esrip.cpp +++ b/src/devices/cpu/esrip/esrip.cpp @@ -297,7 +297,7 @@ void esrip_device::device_start() save_item(NAME(m_ipt_ram)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); m_icount = 0; } @@ -1953,7 +1953,7 @@ void esrip_device::execute_run() m_ipt_cnt = (m_ipt_cnt + 1) & 0x1fff; if (calldebugger) - debugger_instruction_hook(this, RIP_PC); + debugger_instruction_hook(RIP_PC); m_pc = next_pc; m_rip_pc = (m_pc | ((m_status_out & 1) << 8)); diff --git a/src/devices/cpu/f8/f8.cpp b/src/devices/cpu/f8/f8.cpp index 54364ebddf3..1f98ed1fe76 100644 --- a/src/devices/cpu/f8/f8.cpp +++ b/src/devices/cpu/f8/f8.cpp @@ -170,7 +170,7 @@ void f8_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_debug_pc).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_w).formatstr("%5s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void f8_cpu_device::device_reset() @@ -1655,7 +1655,7 @@ void f8_cpu_device::execute_run() u8 op = m_dbus; m_debug_pc = (m_pc0 - 1) & 0xffff; - debugger_instruction_hook(this, m_debug_pc); + debugger_instruction_hook(m_debug_pc); switch( op ) { diff --git a/src/devices/cpu/g65816/g65816.cpp b/src/devices/cpu/g65816/g65816.cpp index e6f2b5329a1..312bf88eebb 100644 --- a/src/devices/cpu/g65816/g65816.cpp +++ b/src/devices/cpu/g65816/g65816.cpp @@ -909,7 +909,7 @@ void g65816_device::device_start() state_add( STATE_GENSP, "GENSP", m_debugger_temp).callimport().callexport().formatstr("%06X").noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%8s").noshow(); - m_icountptr = &m_ICount; + set_icountptr(m_ICount); } void g65816_device::state_import(const device_state_entry &entry) diff --git a/src/devices/cpu/g65816/g65816cm.h b/src/devices/cpu/g65816/g65816cm.h index 499de7f1aa0..5eea37da37d 100644 --- a/src/devices/cpu/g65816/g65816cm.h +++ b/src/devices/cpu/g65816/g65816cm.h @@ -11,7 +11,7 @@ #undef G65816_CALL_DEBUGGER -#define G65816_CALL_DEBUGGER(x) debugger_instruction_hook(this, x) +#define G65816_CALL_DEBUGGER(x) debugger_instruction_hook(x) #define g65816_read_8(addr) m_data_space->read_byte(addr) #define g65816_write_8(addr,data) m_data_space->write_byte(addr,data) diff --git a/src/devices/cpu/h6280/h6280.cpp b/src/devices/cpu/h6280/h6280.cpp index d8dd1c7db80..14705c93dd7 100644 --- a/src/devices/cpu/h6280/h6280.cpp +++ b/src/devices/cpu/h6280/h6280.cpp @@ -269,7 +269,7 @@ void h6280_device::device_start() save_item(NAME(m_io_buffer)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); m_icount = 0; /* clear pending interrupts */ @@ -2406,7 +2406,7 @@ void h6280_device::execute_run() { m_ppc = m_pc; - debugger_instruction_hook(this, PCW); + debugger_instruction_hook(PCW); /* Execute 1 instruction */ in = read_opcode(); diff --git a/src/devices/cpu/h8/h8.cpp b/src/devices/cpu/h8/h8.cpp index 06fa7991c06..f8588a55b66 100644 --- a/src/devices/cpu/h8/h8.cpp +++ b/src/devices/cpu/h8/h8.cpp @@ -100,7 +100,7 @@ void h8_device::device_start() save_item(NAME(taken_irq_level)); save_item(NAME(irq_nmi)); - m_icountptr = &icount; + set_icountptr(icount); PC = 0; PPC = 0; @@ -208,7 +208,7 @@ void h8_device::execute_run() if(inst_state < 0x10000) { PPC = NPC; if(machine().debug_flags & DEBUG_FLAG_ENABLED) - debugger_instruction_hook(this, NPC); + debugger_instruction_hook(NPC); } do_exec_full(); } diff --git a/src/devices/cpu/hcd62121/hcd62121.cpp b/src/devices/cpu/hcd62121/hcd62121.cpp index 374743788e2..53e9a1ed5da 100644 --- a/src/devices/cpu/hcd62121/hcd62121.cpp +++ b/src/devices/cpu/hcd62121/hcd62121.cpp @@ -377,7 +377,7 @@ void hcd62121_cpu_device::device_start() state_add(HCD62121_R78, "R78", m_reg[0x00]).callimport().callexport().formatstr("%8s"); state_add(HCD62121_R7C, "R7C", m_reg[0x00]).callimport().callexport().formatstr("%8s"); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -820,7 +820,7 @@ void hcd62121_cpu_device::execute_run() { offs_t pc = (m_cseg << 16) | m_ip; - debugger_instruction_hook(this, pc); + debugger_instruction_hook(pc); m_prev_pc = pc; u8 op = read_op(); diff --git a/src/devices/cpu/hd61700/hd61700.cpp b/src/devices/cpu/hd61700/hd61700.cpp index 0d2e5aeb1d5..88dd1756d72 100644 --- a/src/devices/cpu/hd61700/hd61700.cpp +++ b/src/devices/cpu/hd61700/hd61700.cpp @@ -200,7 +200,7 @@ void hd61700_cpu_device::device_start() state_add(STATE_GENFLAGS, "GENFLAGS", m_flags).mask(0xff).formatstr("%8s").noshow(); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -341,7 +341,7 @@ void hd61700_cpu_device::execute_run() { m_ppc = m_curpc; - debugger_instruction_hook(this, m_curpc); + debugger_instruction_hook(m_curpc); // verify that CPU is not in sleep if (m_state & CPU_SLP) diff --git a/src/devices/cpu/hmcs40/hmcs40.cpp b/src/devices/cpu/hmcs40/hmcs40.cpp index dc64959475b..1b8615e1e0c 100644 --- a/src/devices/cpu/hmcs40/hmcs40.cpp +++ b/src/devices/cpu/hmcs40/hmcs40.cpp @@ -295,7 +295,7 @@ void hmcs40_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_s).formatstr("%2s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -617,7 +617,7 @@ void hmcs40_cpu_device::execute_run() } // fetch next opcode - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_icount--; m_op = m_program->read_word(m_pc) & 0x3ff; m_i = bitswap<8>(m_op,7,6,5,4,0,1,2,3) & 0xf; // reversed bit-order for 4-bit immediate param (except for XAMR) diff --git a/src/devices/cpu/hphybrid/hphybrid.cpp b/src/devices/cpu/hphybrid/hphybrid.cpp index d726f7d6191..1104e146a7b 100644 --- a/src/devices/cpu/hphybrid/hphybrid.cpp +++ b/src/devices/cpu/hphybrid/hphybrid.cpp @@ -223,7 +223,7 @@ void hp_hybrid_cpu_device::device_start() save_item(NAME(m_reg_I)); save_item(NAME(m_forced_bsc_25)); - m_icountptr = &m_icount; + set_icountptr(m_icount); m_pa_changed_func.resolve_safe(); } @@ -241,7 +241,7 @@ void hp_hybrid_cpu_device::execute_run() if (BIT(m_flags , HPHYBRID_DMAEN_BIT) && BIT(m_flags , HPHYBRID_DMAR_BIT)) { handle_dma(); } else { - debugger_instruction_hook(this, m_genpc); + debugger_instruction_hook(m_genpc); m_reg_I = execute_one(m_reg_I); diff --git a/src/devices/cpu/i386/i386.cpp b/src/devices/cpu/i386/i386.cpp index a3242c1d8bf..479f1f463f0 100644 --- a/src/devices/cpu/i386/i386.cpp +++ b/src/devices/cpu/i386/i386.cpp @@ -3329,7 +3329,7 @@ void i386_device::i386_common_init() m_ferr_handler.resolve_safe(); m_ferr_handler(0); - m_icountptr = &m_cycles; + set_icountptr(m_cycles); } void i386_device::device_start() @@ -3964,7 +3964,7 @@ void i386_device::execute_run() m_segment_prefix = 0; m_prev_eip = m_eip; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); if(m_delayed_interrupt_enable != 0) { diff --git a/src/devices/cpu/i8008/i8008.cpp b/src/devices/cpu/i8008/i8008.cpp index bd5796394bd..1964c8a4307 100644 --- a/src/devices/cpu/i8008/i8008.cpp +++ b/src/devices/cpu/i8008/i8008.cpp @@ -42,7 +42,7 @@ i8008_device::i8008_device(const machine_config &mconfig, const char *tag, devic , m_direct(nullptr) { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } //------------------------------------------------- @@ -257,7 +257,7 @@ void i8008_device::execute_run() if (m_irq_state != CLEAR_LINE) { take_interrupt(); } - debugger_instruction_hook(this, m_PC.d); + debugger_instruction_hook(m_PC.d); execute_one(rop()); } while (m_icount > 0); } diff --git a/src/devices/cpu/i8085/i8085.cpp b/src/devices/cpu/i8085/i8085.cpp index 4249cbd99b1..de8c120d19e 100644 --- a/src/devices/cpu/i8085/i8085.cpp +++ b/src/devices/cpu/i8085/i8085.cpp @@ -372,7 +372,7 @@ void i8085a_cpu_device::device_start() save_item(NAME(m_trap_im_copy)); save_item(NAME(m_sod_state)); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -854,7 +854,7 @@ void i8085a_cpu_device::execute_run() do { - debugger_instruction_hook(this, m_PC.d); + debugger_instruction_hook(m_PC.d); /* the instruction after an EI does not take an interrupt, so we cannot check immediately; handle post-EI behavior here */ diff --git a/src/devices/cpu/i8089/i8089.cpp b/src/devices/cpu/i8089/i8089.cpp index 025a31978c4..df577224e78 100644 --- a/src/devices/cpu/i8089/i8089.cpp +++ b/src/devices/cpu/i8089/i8089.cpp @@ -58,7 +58,7 @@ i8089_device::i8089_device(const machine_config &mconfig, const char *tag, devic void i8089_device::device_start() { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // resolve callbacks m_write_sintr1.resolve_safe(); diff --git a/src/devices/cpu/i8089/i8089_channel.cpp b/src/devices/cpu/i8089/i8089_channel.cpp index 99547fb20f8..b34bd98e16a 100644 --- a/src/devices/cpu/i8089/i8089_channel.cpp +++ b/src/devices/cpu/i8089/i8089_channel.cpp @@ -422,7 +422,7 @@ int i8089_channel_device::execute_run() else if (executing()) { // call debugger - debugger_instruction_hook(m_iop, m_iop->m_current_tp); + m_iop->debugger_instruction_hook(m_iop->m_current_tp); // dma transfer pending? if (m_xfer_pending) diff --git a/src/devices/cpu/i86/i186.cpp b/src/devices/cpu/i86/i186.cpp index 1fcfa081a94..9aeb4759bbb 100644 --- a/src/devices/cpu/i86/i186.cpp +++ b/src/devices/cpu/i86/i186.cpp @@ -230,7 +230,7 @@ void i80186_cpu_device::execute_run() } } - debugger_instruction_hook( this, update_pc() ); + debugger_instruction_hook( update_pc() ); uint8_t op = fetch_op(); diff --git a/src/devices/cpu/i86/i286.cpp b/src/devices/cpu/i86/i286.cpp index 541a06cf702..623c2070ff5 100644 --- a/src/devices/cpu/i86/i286.cpp +++ b/src/devices/cpu/i86/i286.cpp @@ -1101,7 +1101,7 @@ void i80286_cpu_device::execute_run() } } - debugger_instruction_hook( this, update_pc() & m_amask ); + debugger_instruction_hook( update_pc() & m_amask ); uint8_t op = fetch_op(); diff --git a/src/devices/cpu/i86/i86.cpp b/src/devices/cpu/i86/i86.cpp index f63e667d9da..4ce0bffc431 100644 --- a/src/devices/cpu/i86/i86.cpp +++ b/src/devices/cpu/i86/i86.cpp @@ -237,7 +237,7 @@ void i8086_cpu_device::execute_run() if (!m_seg_prefix) { - debugger_instruction_hook( this, update_pc() ); + debugger_instruction_hook( update_pc() ); } uint8_t op = fetch_op(); @@ -504,7 +504,7 @@ void i8086_common_cpu_device::device_start() state_add(STATE_GENFLAGS, "GENFLAGS", m_TF).formatstr("%16s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); m_lock_handler.resolve_safe(); } diff --git a/src/devices/cpu/i860/i860.cpp b/src/devices/cpu/i860/i860.cpp index 9a008513dfd..08ae974f277 100644 --- a/src/devices/cpu/i860/i860.cpp +++ b/src/devices/cpu/i860/i860.cpp @@ -138,7 +138,7 @@ void i860_cpu_device::device_start() state_add(STATE_GENPC, "GENPC", m_pc).noshow(); state_add(STATE_GENPCBASE, "CURPC", m_pc).noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } diff --git a/src/devices/cpu/i860/i860dec.hxx b/src/devices/cpu/i860/i860dec.hxx index c33f2d0b7e8..dedf86028cc 100644 --- a/src/devices/cpu/i860/i860dec.hxx +++ b/src/devices/cpu/i860/i860dec.hxx @@ -4448,7 +4448,7 @@ void i860_cpu_device::execute_run() #endif savepc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); decode_exec (ifetch (m_pc), 1); m_exiting_ifetch = 0; diff --git a/src/devices/cpu/i960/i960.cpp b/src/devices/cpu/i960/i960.cpp index 373e58522bc..4ca93637de0 100644 --- a/src/devices/cpu/i960/i960.cpp +++ b/src/devices/cpu/i960/i960.cpp @@ -2096,7 +2096,7 @@ void i960_cpu_device::execute_run() while(m_icount > 0) { m_PIP = m_IP; - debugger_instruction_hook(this, m_IP); + debugger_instruction_hook(m_IP); m_bursting = 0; @@ -2259,7 +2259,7 @@ void i960_cpu_device::device_start() memset(m_fp, 0, sizeof(m_fp)); m_PIP = 0; - m_icountptr = &m_icount; + set_icountptr(m_icount); } void i960_cpu_device::state_string_export(const device_state_entry &entry, std::string &str) const diff --git a/src/devices/cpu/ie15/ie15.cpp b/src/devices/cpu/ie15/ie15.cpp index eea0ef17db7..9b101558139 100644 --- a/src/devices/cpu/ie15/ie15.cpp +++ b/src/devices/cpu/ie15/ie15.cpp @@ -38,7 +38,7 @@ ie15_cpu_device::ie15_cpu_device(const machine_config &mconfig, const char *tag, , m_program(nullptr), m_io(nullptr), m_direct(nullptr) { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } //------------------------------------------------- @@ -193,7 +193,7 @@ void ie15_cpu_device::execute_run() { do { - debugger_instruction_hook(this, m_PC.d); + debugger_instruction_hook(m_PC.d); execute_one(rop()); } while (m_icount > 0); } diff --git a/src/devices/cpu/jaguar/jaguar.cpp b/src/devices/cpu/jaguar/jaguar.cpp index 7b016dce40b..69f5b80ca94 100644 --- a/src/devices/cpu/jaguar/jaguar.cpp +++ b/src/devices/cpu/jaguar/jaguar.cpp @@ -405,7 +405,7 @@ void jaguar_cpu_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_ppc).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", FLAGS).formatstr("%11s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -480,7 +480,7 @@ void jaguargpu_cpu_device::execute_run() /* debugging */ //if (PC < 0xf03000 || PC > 0xf04000) { fatalerror("GPU: PC = %06X (ppc = %06X)\n", PC, m_ppc); } m_ppc = PC; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); /* instruction fetch */ op = ROPCODE(PC); @@ -517,7 +517,7 @@ void jaguardsp_cpu_device::execute_run() /* debugging */ //if (PC < 0xf1b000 || PC > 0xf1d000) { fatalerror(stderr, "DSP: PC = %06X\n", PC); } m_ppc = PC; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); /* instruction fetch */ op = ROPCODE(PC); @@ -728,7 +728,7 @@ void jaguar_cpu_device::jr_cc_n(uint16_t op) { int32_t r1 = (int8_t)((op >> 2) & 0xf8) >> 2; uint32_t newpc = PC + r1; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); op = ROPCODE(PC); PC = newpc; (this->*m_table[op >> 10])(op); @@ -745,7 +745,7 @@ void jaguar_cpu_device::jump_cc_rn(uint16_t op) /* special kludge for risky code in the cojag DSP interrupt handlers */ uint32_t newpc = (m_icount == m_bankswitch_icount) ? m_a[reg] : m_r[reg]; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); op = ROPCODE(PC); PC = newpc; (this->*m_table[op >> 10])(op); diff --git a/src/devices/cpu/lc8670/lc8670.cpp b/src/devices/cpu/lc8670/lc8670.cpp index 5d0ff589928..3d6db33c030 100644 --- a/src/devices/cpu/lc8670/lc8670.cpp +++ b/src/devices/cpu/lc8670/lc8670.cpp @@ -198,7 +198,7 @@ void lc8670_cpu_device::device_start() m_direct = m_program->direct<0>(); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // resolve callbacks m_bankswitch_func.resolve(); @@ -420,7 +420,7 @@ void lc8670_cpu_device::execute_run() check_irqs(); m_ppc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); int cycles; diff --git a/src/devices/cpu/lh5801/lh5801.cpp b/src/devices/cpu/lh5801/lh5801.cpp index e9a60dfaeb1..07876db8ed1 100644 --- a/src/devices/cpu/lh5801/lh5801.cpp +++ b/src/devices/cpu/lh5801/lh5801.cpp @@ -149,7 +149,7 @@ void lh5801_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_p.w.l).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_t).noshow().formatstr("%8s"); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void lh5801_cpu_device::state_string_export(const device_state_entry &entry, std::string &str) const @@ -225,7 +225,7 @@ void lh5801_cpu_device::execute_run() { m_oldpc = P; - debugger_instruction_hook(this, P); + debugger_instruction_hook(P); lh5801_instruction(); } diff --git a/src/devices/cpu/lr35902/lr35902.cpp b/src/devices/cpu/lr35902/lr35902.cpp index 7709952bd04..59b8b45f601 100644 --- a/src/devices/cpu/lr35902/lr35902.cpp +++ b/src/devices/cpu/lr35902/lr35902.cpp @@ -185,7 +185,7 @@ void lr35902_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_PC).formatstr("%8s").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_F).mask(0xf0).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -362,7 +362,7 @@ void lr35902_cpu_device::execute_run() /* Fetch and count cycles */ bool was_halted = (m_enable & HALTED); check_interrupts(); - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); if ( m_enable & HALTED ) { cycles_passed(m_has_halt_bug ? 2 : 4); m_execution_state = 1; diff --git a/src/devices/cpu/m37710/m37710.cpp b/src/devices/cpu/m37710/m37710.cpp index 2416a7b5b10..b817ed847dc 100644 --- a/src/devices/cpu/m37710/m37710.cpp +++ b/src/devices/cpu/m37710/m37710.cpp @@ -1074,7 +1074,7 @@ void m37710_cpu_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_debugger_pc ).callimport().callexport().noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_p ).formatstr("%8s").noshow(); - m_icountptr = &m_ICount; + set_icountptr(m_ICount); } diff --git a/src/devices/cpu/m37710/m37710cm.h b/src/devices/cpu/m37710/m37710cm.h index 90f35d7ba4e..80b294ac277 100644 --- a/src/devices/cpu/m37710/m37710cm.h +++ b/src/devices/cpu/m37710/m37710cm.h @@ -20,7 +20,7 @@ #undef M37710_CALL_DEBUGGER -#define M37710_CALL_DEBUGGER(x) debugger_instruction_hook(this, x) +#define M37710_CALL_DEBUGGER(x) debugger_instruction_hook(x) #define m37710_read_8(addr) m_program->read_byte(addr) #define m37710_write_8(addr,data) m_program->write_byte(addr,data) #define m37710_read_8_immediate(A) m_direct->read_byte(A, BYTE_XOR_LE(0)) diff --git a/src/devices/cpu/m6502/m6502.cpp b/src/devices/cpu/m6502/m6502.cpp index 9604f6c55a4..38459863003 100644 --- a/src/devices/cpu/m6502/m6502.cpp +++ b/src/devices/cpu/m6502/m6502.cpp @@ -85,7 +85,7 @@ void m6502_device::init() save_item(NAME(irq_taken)); save_item(NAME(inhibit_interrupts)); - m_icountptr = &icount; + set_icountptr(icount); PC = 0x0000; NPC = 0x0000; @@ -390,7 +390,7 @@ void m6502_device::execute_run() PPC = NPC; inst_state = IR | inst_state_base; if(machine().debug_flags & DEBUG_FLAG_ENABLED) - debugger_instruction_hook(this, pc_to_external(NPC)); + debugger_instruction_hook(pc_to_external(NPC)); } do_exec_full(); } diff --git a/src/devices/cpu/m6800/m6800.cpp b/src/devices/cpu/m6800/m6800.cpp index b4cb4106094..9182b899ffe 100644 --- a/src/devices/cpu/m6800/m6800.cpp +++ b/src/devices/cpu/m6800/m6800.cpp @@ -153,13 +153,13 @@ TODO: /* operate one instruction for */ #define ONE_MORE_INSN() { \ - uint8_t ireg; \ + uint8_t ireg; \ pPPC = pPC; \ - debugger_instruction_hook(this, PCD); \ + debugger_instruction_hook(PCD); \ ireg=M_RDOP(PCD); \ PC++; \ - (this->*m_insn[ireg])(); \ - increment_counter(m_cycles[ireg]); \ + (this->*m_insn[ireg])(); \ + increment_counter(m_cycles[ireg]); \ } /* CC masks HI NZVC @@ -499,7 +499,7 @@ void m6800_cpu_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_pc.w.l).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_cc).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void m6800_cpu_device::state_string_export(const device_state_entry &entry, std::string &str) const @@ -570,7 +570,7 @@ void m6800_cpu_device::execute_run() else { pPPC = pPC; - debugger_instruction_hook(this, PCD); + debugger_instruction_hook(PCD); ireg=M_RDOP(PCD); PC++; (this->*m_insn[ireg])(); diff --git a/src/devices/cpu/m68000/m68kcpu.cpp b/src/devices/cpu/m68000/m68kcpu.cpp index 2e34f8bea61..a0c74be63b2 100644 --- a/src/devices/cpu/m68000/m68kcpu.cpp +++ b/src/devices/cpu/m68000/m68kcpu.cpp @@ -794,7 +794,7 @@ void m68000_base_device::execute_run() m_ppc = m_pc; /* Call external hook to peek at CPU */ - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); try { @@ -981,7 +981,7 @@ void m68000_base_device::init_cpu_common(void) machine().save().register_presave(save_prepost_delegate(FUNC(m68000_base_device::presave), this)); machine().save().register_postload(save_prepost_delegate(FUNC(m68000_base_device::postload), this)); - m_icountptr = &m_remaining_cycles; + set_icountptr(m_remaining_cycles); m_remaining_cycles = 0; } diff --git a/src/devices/cpu/m6805/m6805.cpp b/src/devices/cpu/m6805/m6805.cpp index 3cc562d7825..a1275b8088a 100644 --- a/src/devices/cpu/m6805/m6805.cpp +++ b/src/devices/cpu/m6805/m6805.cpp @@ -266,7 +266,7 @@ void m6805_base_device::device_start() m_direct = m_program->direct<0>(); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // register our state for the debugger state_add(STATE_GENPC, "GENPC", m_pc.w.l).noshow(); @@ -492,7 +492,7 @@ void m6805_base_device::execute_run() interrupt(); } - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); u8 const ireg = rdop(PC++); diff --git a/src/devices/cpu/m6809/hd6309.ops b/src/devices/cpu/m6809/hd6309.ops index 9752460175b..c96e3082d4f 100644 --- a/src/devices/cpu/m6809/hd6309.ops +++ b/src/devices/cpu/m6809/hd6309.ops @@ -11,7 +11,7 @@ MAIN: // debugger hook m_ppc = m_pc; - debugger_instruction_hook(this, m_pc.w); + debugger_instruction_hook(m_pc.w); // opcode fetch @m_opcode = read_opcode(); diff --git a/src/devices/cpu/m6809/konami.ops b/src/devices/cpu/m6809/konami.ops index d2df5273c00..130e58c67d0 100644 --- a/src/devices/cpu/m6809/konami.ops +++ b/src/devices/cpu/m6809/konami.ops @@ -11,7 +11,7 @@ MAIN: // debugger hook m_ppc = m_pc; - debugger_instruction_hook(this, m_pc.w); + debugger_instruction_hook(m_pc.w); // opcode fetch @m_opcode = read_opcode(); diff --git a/src/devices/cpu/m6809/m6809.cpp b/src/devices/cpu/m6809/m6809.cpp index 892a23c2872..c5eba10d5f1 100644 --- a/src/devices/cpu/m6809/m6809.cpp +++ b/src/devices/cpu/m6809/m6809.cpp @@ -219,7 +219,7 @@ void m6809_base_device::device_start() save_item(NAME(m_cond)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); m_icount = 0; } diff --git a/src/devices/cpu/m6809/m6809.ops b/src/devices/cpu/m6809/m6809.ops index 125be180ce5..634c0b896eb 100644 --- a/src/devices/cpu/m6809/m6809.ops +++ b/src/devices/cpu/m6809/m6809.ops @@ -11,7 +11,7 @@ MAIN: // debugger hook m_ppc = m_pc; - debugger_instruction_hook(this, m_pc.w); + debugger_instruction_hook(m_pc.w); // opcode fetch m_lic_func(ASSERT_LINE); diff --git a/src/devices/cpu/m6809/m6809inl.h b/src/devices/cpu/m6809/m6809inl.h index 71bd4f22ec9..2103babc6ce 100644 --- a/src/devices/cpu/m6809/m6809inl.h +++ b/src/devices/cpu/m6809/m6809inl.h @@ -238,7 +238,7 @@ inline void m6809_base_device::eat_remaining() eat(m_icount); m_pc.w = m_ppc.w; - debugger_instruction_hook(this, m_pc.w); + debugger_instruction_hook(m_pc.w); m_pc.w = real_pc; } diff --git a/src/devices/cpu/mb86233/mb86233.cpp b/src/devices/cpu/mb86233/mb86233.cpp index 4c0921795f4..68cf6a8fe6f 100644 --- a/src/devices/cpu/mb86233/mb86233.cpp +++ b/src/devices/cpu/mb86233/mb86233.cpp @@ -167,7 +167,7 @@ void mb86233_cpu_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_pc).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_sr).formatstr("%2s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -1004,7 +1004,7 @@ void mb86233_cpu_device::execute_run() uint32_t val; uint32_t opcode; - debugger_instruction_hook(this, GETPC()); + debugger_instruction_hook(GETPC()); opcode = ROPCODE(GETPC()); diff --git a/src/devices/cpu/mb86235/mb86235.cpp b/src/devices/cpu/mb86235/mb86235.cpp index f61c7c4fd14..0987b1e1b20 100644 --- a/src/devices/cpu/mb86235/mb86235.cpp +++ b/src/devices/cpu/mb86235/mb86235.cpp @@ -65,7 +65,7 @@ void mb86235_device::execute_run() curpc = check_previous_op_stall() ? m_core->cur_fifo_state.pc : m_core->pc; - debugger_instruction_hook(this, curpc); + debugger_instruction_hook(curpc); opcode = m_direct->read_qword(curpc); m_core->ppc = curpc; @@ -217,7 +217,7 @@ void mb86235_device::device_start() state_add(STATE_GENPC, "GENPC", m_core->pc ).noshow(); state_add(STATE_GENPCBASE, "CURPC", m_core->pc).noshow(); - m_icountptr = &m_core->icount; + set_icountptr(m_core->icount); m_core->fp0 = 0.0f; save_pointer(NAME(m_core->pr), 24); diff --git a/src/devices/cpu/mb88xx/mb88xx.cpp b/src/devices/cpu/mb88xx/mb88xx.cpp index 80a5b6d37bb..512ba8c287c 100644 --- a/src/devices/cpu/mb88xx/mb88xx.cpp +++ b/src/devices/cpu/mb88xx/mb88xx.cpp @@ -232,7 +232,7 @@ void mb88_cpu_device::device_start() state_add( STATE_GENPC, "GENPC", m_debugger_pc ).callimport().callexport().noshow(); state_add( STATE_GENPCBASE, "CURPC", m_debugger_pc ).callimport().callexport().noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_flags ).callimport().callexport().formatstr("%6s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -471,7 +471,7 @@ void mb88_cpu_device::execute_run() uint8_t opcode, arg, oc; /* fetch the opcode */ - debugger_instruction_hook(this, GETPC()); + debugger_instruction_hook(GETPC()); opcode = READOP(GETPC()); /* increment the PC */ diff --git a/src/devices/cpu/mc68hc11/mc68hc11.cpp b/src/devices/cpu/mc68hc11/mc68hc11.cpp index a48f3eed4c2..2a3fa7c36be 100644 --- a/src/devices/cpu/mc68hc11/mc68hc11.cpp +++ b/src/devices/cpu/mc68hc11/mc68hc11.cpp @@ -452,7 +452,7 @@ void mc68hc11_cpu_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_pc).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_ccr).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -599,7 +599,7 @@ void mc68hc11_cpu_device::execute_run() check_irq_lines(); m_ppc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); op = FETCH(); (this->*hc11_optable[op])(); diff --git a/src/devices/cpu/mcs40/mcs40.cpp b/src/devices/cpu/mcs40/mcs40.cpp index 3285e795dba..c04715bcdb1 100644 --- a/src/devices/cpu/mcs40/mcs40.cpp +++ b/src/devices/cpu/mcs40/mcs40.cpp @@ -134,7 +134,7 @@ mcs40_cpu_device_base::mcs40_cpu_device_base( void mcs40_cpu_device_base::device_start() { - m_icountptr = &m_icount; + set_icountptr(m_icount); m_spaces[AS_ROM] = &space(AS_ROM); m_spaces[AS_RAM_MEMORY] = &space(AS_RAM_MEMORY); @@ -594,7 +594,7 @@ inline void mcs40_cpu_device_base::do_a1() { m_pcbase = rom_bank() | m_rom_addr; if (machine().debug_flags & DEBUG_FLAG_ENABLED) - debugger_instruction_hook(this, pc()); + debugger_instruction_hook(pc()); if (m_stop_latch) { m_stp = (ASSERT_LINE == m_stp) ? ASSERT_LINE : CLEAR_LINE; diff --git a/src/devices/cpu/mcs48/mcs48.cpp b/src/devices/cpu/mcs48/mcs48.cpp index d19f92dadb6..7b10be18924 100644 --- a/src/devices/cpu/mcs48/mcs48.cpp +++ b/src/devices/cpu/mcs48/mcs48.cpp @@ -1149,7 +1149,7 @@ void mcs48_cpu_device::device_start() save_item(NAME(m_a11)); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -1293,7 +1293,7 @@ void mcs48_cpu_device::execute_run() /* fetch next opcode */ m_prevpc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); opcode = opcode_fetch(); /* process opcode and count cycles */ diff --git a/src/devices/cpu/mcs51/mcs51.cpp b/src/devices/cpu/mcs51/mcs51.cpp index b5037cae522..b89ebca10ac 100644 --- a/src/devices/cpu/mcs51/mcs51.cpp +++ b/src/devices/cpu/mcs51/mcs51.cpp @@ -1986,7 +1986,7 @@ void mcs51_cpu_device::execute_run() { /* Read next opcode */ PPC = PC; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); op = m_direct->read_byte(PC++); /* process opcode and count cycles */ @@ -2163,7 +2163,7 @@ void mcs51_cpu_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_pc ).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_rtemp).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void mcs51_cpu_device::state_string_export(const device_state_entry &entry, std::string &str) const diff --git a/src/devices/cpu/mcs96/mcs96.cpp b/src/devices/cpu/mcs96/mcs96.cpp index fa7e75498b3..ca5bfafad69 100644 --- a/src/devices/cpu/mcs96/mcs96.cpp +++ b/src/devices/cpu/mcs96/mcs96.cpp @@ -24,7 +24,7 @@ void mcs96_device::device_start() { program = &space(AS_PROGRAM); direct = program->direct<0>(); - m_icountptr = &icount; + set_icountptr(icount); state_add(STATE_GENPC, "GENPC", PC).noshow(); state_add(STATE_GENPCBASE, "CURPC", PPC).noshow(); diff --git a/src/devices/cpu/mcs96/mcs96ops.lst b/src/devices/cpu/mcs96/mcs96ops.lst index 062b70706bf..3cc5d2286bb 100644 --- a/src/devices/cpu/mcs96/mcs96ops.lst +++ b/src/devices/cpu/mcs96/mcs96ops.lst @@ -17,7 +17,7 @@ fetch } PPC = PC; if(machine().debug_flags & DEBUG_FLAG_ENABLED) - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); OP1 = read_pc(); if(OP1 == 0xfe) { OP1 = read_pc(); @@ -28,7 +28,7 @@ fetch fetch_noirq PPC = PC; if(machine().debug_flags & DEBUG_FLAG_ENABLED) - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); OP1 = read_pc(); if(OP1 == 0xfe) { OP1 = read_pc(); diff --git a/src/devices/cpu/melps4/melps4.cpp b/src/devices/cpu/melps4/melps4.cpp index b809e914489..e179c331de2 100644 --- a/src/devices/cpu/melps4/melps4.cpp +++ b/src/devices/cpu/melps4/melps4.cpp @@ -232,7 +232,7 @@ void melps4_cpu_device::device_start() state_add(MELPS4_V, "V", m_v).formatstr("%1X"); state_add(MELPS4_W, "W", m_w).formatstr("%1X"); - m_icountptr = &m_icount; + set_icountptr(m_icount); } device_memory_interface::space_config_vector melps4_cpu_device::memory_space_config() const @@ -452,7 +452,7 @@ void melps4_cpu_device::execute_run() m_prohibit_irq = false; // fetch next opcode - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_icount--; m_op = m_program->read_word(m_pc) & 0x1ff; m_bitmask = 1 << (m_op & 3); diff --git a/src/devices/cpu/minx/minx.cpp b/src/devices/cpu/minx/minx.cpp index 76d7df4c0dd..a78ee20a92c 100644 --- a/src/devices/cpu/minx/minx.cpp +++ b/src/devices/cpu/minx/minx.cpp @@ -125,7 +125,7 @@ void minx_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_curpc).formatstr("%06X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_flags).formatstr("%14s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -190,7 +190,7 @@ void minx_cpu_device::execute_run() do { m_curpc = GET_MINX_PC; - debugger_instruction_hook(this, m_curpc); + debugger_instruction_hook(m_curpc); if ( m_interrupt_pending ) { diff --git a/src/devices/cpu/mips/mips3.cpp b/src/devices/cpu/mips/mips3.cpp index c46f02207e2..ca8a621dc72 100644 --- a/src/devices/cpu/mips/mips3.cpp +++ b/src/devices/cpu/mips/mips3.cpp @@ -636,7 +636,7 @@ void mips3_device::device_start() state_add( STATE_GENSP, "CURSP", m_core->r[31]).noshow(); state_add( STATE_GENFLAGS, "CURFLAGS", m_debugger_temp).formatstr("%1s").noshow(); - m_icountptr = &m_core->icount; + set_icountptr(m_core->icount); } @@ -2770,7 +2770,7 @@ void mips3_device::execute_run() /* debugging */ m_ppc = m_core->pc; - debugger_instruction_hook(this, m_core->pc); + debugger_instruction_hook(m_core->pc); /* instruction fetch */ if(!RWORD(m_core->pc, &op)) diff --git a/src/devices/cpu/mips/r3000.cpp b/src/devices/cpu/mips/r3000.cpp index 57f0dfe0d96..60ddfc1b594 100644 --- a/src/devices/cpu/mips/r3000.cpp +++ b/src/devices/cpu/mips/r3000.cpp @@ -148,7 +148,7 @@ r3000_device::r3000_device(const machine_config &mconfig, device_type type, cons m_in_brcond3(*this) { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // clear some additional state memset(m_r, 0, sizeof(m_r)); @@ -1028,7 +1028,7 @@ void r3000_device::execute_run() // debugging m_ppc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); // instruction fetch m_op = readop(m_pc); diff --git a/src/devices/cpu/mn10200/mn10200.cpp b/src/devices/cpu/mn10200/mn10200.cpp index 2ffd397ed2c..f984a789c5e 100644 --- a/src/devices/cpu/mn10200/mn10200.cpp +++ b/src/devices/cpu/mn10200/mn10200.cpp @@ -251,7 +251,7 @@ void mn10200_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_pc ).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_psw).formatstr("%26s").noshow(); - m_icountptr = &m_cycles; + set_icountptr(m_cycles); } @@ -565,7 +565,7 @@ void mn10200_device::execute_run() check_irq(); } - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_cycles -= 1; uint8_t op = read_arg8(m_pc); diff --git a/src/devices/cpu/nanoprocessor/nanoprocessor.cpp b/src/devices/cpu/nanoprocessor/nanoprocessor.cpp index 802663f86c1..941eb3f95e1 100644 --- a/src/devices/cpu/nanoprocessor/nanoprocessor.cpp +++ b/src/devices/cpu/nanoprocessor/nanoprocessor.cpp @@ -90,7 +90,7 @@ void hp_nanoprocessor_device::device_start() save_item(NAME(m_reg_ISR)); save_item(NAME(m_flags)); - m_icountptr = &m_icount; + set_icountptr(m_icount); m_dc_changed_func.resolve_safe(); m_read_dc_func.resolve_safe(0xff); @@ -132,7 +132,7 @@ void hp_nanoprocessor_device::execute_run() // Need this to propagate the clearing of DC7 to the clearing of int. line yield(); } else { - debugger_instruction_hook(this, m_reg_PA); + debugger_instruction_hook(m_reg_PA); uint8_t opcode = fetch(); execute_one(opcode); diff --git a/src/devices/cpu/nec/nec.cpp b/src/devices/cpu/nec/nec.cpp index f7ca3da75b1..5b95f818d78 100644 --- a/src/devices/cpu/nec/nec.cpp +++ b/src/devices/cpu/nec/nec.cpp @@ -443,7 +443,7 @@ void nec_common_device::device_start() state_add( STATE_GENSP, "GENSP", m_debugger_temp).callimport().callexport().noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%16s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void nec_common_device::state_string_export(const device_state_entry &entry, std::string &str) const @@ -525,7 +525,7 @@ void nec_common_device::execute_run() if (m_halted) { m_icount = 0; - debugger_instruction_hook(this, (Sreg(PS)<<4) + m_ip); + debugger_instruction_hook((Sreg(PS)<<4) + m_ip); return; } @@ -543,7 +543,7 @@ void nec_common_device::execute_run() if (m_no_interrupt) m_no_interrupt--; - debugger_instruction_hook(this, (Sreg(PS)<<4) + m_ip); + debugger_instruction_hook((Sreg(PS)<<4) + m_ip); prev_ICount = m_icount; (this->*s_nec_instruction[fetchop()])(); do_prefetch(prev_ICount); diff --git a/src/devices/cpu/nec/v25.cpp b/src/devices/cpu/nec/v25.cpp index 617a3af9366..48f3e1d9e27 100644 --- a/src/devices/cpu/nec/v25.cpp +++ b/src/devices/cpu/nec/v25.cpp @@ -546,7 +546,7 @@ void v25_common_device::device_start() state_add( STATE_GENSP, "GENSP", m_debugger_temp).callimport().callexport().noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%16s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -755,7 +755,7 @@ void v25_common_device::execute_run() if (m_halted) { m_icount = 0; - debugger_instruction_hook(this, (Sreg(PS)<<4) + m_ip); + debugger_instruction_hook((Sreg(PS)<<4) + m_ip); return; } @@ -773,7 +773,7 @@ void v25_common_device::execute_run() if (m_no_interrupt) m_no_interrupt--; - debugger_instruction_hook(this, (Sreg(PS)<<4) + m_ip); + debugger_instruction_hook((Sreg(PS)<<4) + m_ip); prev_ICount = m_icount; (this->*s_nec_instruction[fetchop()])(); do_prefetch(prev_ICount); diff --git a/src/devices/cpu/patinhofeio/patinho_feio.cpp b/src/devices/cpu/patinhofeio/patinho_feio.cpp index 489271d3ae9..3a88df1d49a 100644 --- a/src/devices/cpu/patinhofeio/patinho_feio.cpp +++ b/src/devices/cpu/patinhofeio/patinho_feio.cpp @@ -145,7 +145,7 @@ void patinho_feio_cpu_device::device_start() m_iodev_write_cb[i].resolve(); } - m_icountptr = &m_icount; + set_icountptr(m_icount); } void patinho_feio_cpu_device::device_reset() @@ -175,7 +175,7 @@ void patinho_feio_cpu_device::execute_run() { m_ext = READ_ACC_EXTENSION_REG(); m_idx = READ_INDEX_REG(); ((patinho_feio_state*) owner())->update_panel(ACC, READ_BYTE_PATINHO(PC), READ_BYTE_PATINHO(m_addr), m_addr, PC, FLAGS, RC, m_mode); - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); if (!m_run){ if (!m_buttons_read_cb.isnull()){ diff --git a/src/devices/cpu/pdp1/pdp1.cpp b/src/devices/cpu/pdp1/pdp1.cpp index 5f56755d6df..a8704ad29d3 100644 --- a/src/devices/cpu/pdp1/pdp1.cpp +++ b/src/devices/cpu/pdp1/pdp1.cpp @@ -649,7 +649,7 @@ void pdp1_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_pc ).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_pf ).formatstr("%13s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); /* reset CPU flip-flops */ pulse_start_clear(); @@ -796,7 +796,7 @@ void pdp1_device::execute_run() { do { - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); /* ioh should be cleared at the end of the instruction cycle, and ios at the diff --git a/src/devices/cpu/pdp1/tx0.cpp b/src/devices/cpu/pdp1/tx0.cpp index b4c3c693675..99636fcb9c2 100644 --- a/src/devices/cpu/pdp1/tx0.cpp +++ b/src/devices/cpu/pdp1/tx0.cpp @@ -220,7 +220,7 @@ void tx0_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).formatstr("0%06O").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_ir).noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -255,7 +255,7 @@ void tx0_64kw_device::execute_run() { do { - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); if (m_ioh && m_ios) @@ -358,7 +358,7 @@ void tx0_8kw_device::execute_run() { do { - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); if (m_ioh && m_ios) diff --git a/src/devices/cpu/pdp8/pdp8.cpp b/src/devices/cpu/pdp8/pdp8.cpp index 341a7d3c997..39f909b03e4 100644 --- a/src/devices/cpu/pdp8/pdp8.cpp +++ b/src/devices/cpu/pdp8/pdp8.cpp @@ -94,7 +94,7 @@ void pdp8_device::device_start() save_item(NAME(m_halt)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } void pdp8_device::device_stop() @@ -216,7 +216,7 @@ void pdp8_device::execute_run() { m_pc &= 07777; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); uint16_t op = m_program->read_word(m_pc); diff --git a/src/devices/cpu/pic16c5x/16c5xdsm.cpp b/src/devices/cpu/pic16c5x/16c5xdsm.cpp index 4768cbb12e8..a748b553cd3 100644 --- a/src/devices/cpu/pic16c5x/16c5xdsm.cpp +++ b/src/devices/cpu/pic16c5x/16c5xdsm.cpp @@ -25,7 +25,10 @@ #include "emu.h" #include "16c5xdsm.h" + #include <ctype.h> +#include <stdexcept> + const char *const pic16c5x_disassembler::regfile[32] = { "Reg$00 (IND)", "Reg$01 (TMR)", "Reg$02 (PCL)", "Reg$03 (ST)", "Reg$04 (FSR)", "Reg$05 (PTA)", "Reg$06 (PTB)", "Reg$07 (PTC)", "Reg$08", "Reg$09", "Reg$0A", "Reg$0B", "Reg$0C", "Reg$0D", "Reg$0E", "Reg$0F", @@ -98,16 +101,15 @@ pic16c5x_disassembler::pic16c5x_disassembler() case 'd': case 'f': case 'k': - bit --; + bit--; break; - default: fatalerror("Invalid instruction encoding '%s %s'\n", - ops[0],ops[1]); + default: + throw std::logic_error(util::string_format("Invalid instruction encoding '%s %s'\n", ops[0],ops[1])); } } if (bit != -1 ) { - fatalerror("not enough bits in encoding '%s %s' %d\n", - ops[0],ops[1],bit); + throw std::logic_error(util::string_format("not enough bits in encoding '%s %s' %d\n", ops[0],ops[1],bit)); } while (isspace((uint8_t)*p)) p++; Op.emplace_back(mask, bits, *p, ops[0], ops[1]); @@ -168,16 +170,16 @@ offs_t pic16c5x_disassembler::disassemble(std::ostream &stream, offs_t pc, const while (bit >= 0) { /* osd_printf_debug("{%c/%d}",*cp,bit); */ - switch(*cp) + switch (*cp) { - case 'a': a <<=1; a |= ((code & (1<<bit)) ? 1 : 0); bit--; break; - case 'b': b <<=1; b |= ((code & (1<<bit)) ? 1 : 0); bit--; break; - case 'd': d <<=1; d |= ((code & (1<<bit)) ? 1 : 0); bit--; break; - case 'f': f <<=1; f |= ((code & (1<<bit)) ? 1 : 0); bit--; break; - case 'k': k <<=1; k |= ((code & (1<<bit)) ? 1 : 0); bit--; break; - case ' ': break; - case '1': case '0': bit--; break; - case '\0': fatalerror("premature end of parse string, opcode %x, bit = %d\n",code,bit); + case 'a': a <<=1; a |= ((code & (1<<bit)) ? 1 : 0); bit--; break; + case 'b': b <<=1; b |= ((code & (1<<bit)) ? 1 : 0); bit--; break; + case 'd': d <<=1; d |= ((code & (1<<bit)) ? 1 : 0); bit--; break; + case 'f': f <<=1; f |= ((code & (1<<bit)) ? 1 : 0); bit--; break; + case 'k': k <<=1; k |= ((code & (1<<bit)) ? 1 : 0); bit--; break; + case ' ': break; + case '1': case '0': bit--; break; + case '\0': throw std::logic_error(util::string_format("premature end of parse string, opcode %x, bit = %d\n",code,bit)); } cp++; } @@ -202,7 +204,7 @@ offs_t pic16c5x_disassembler::disassemble(std::ostream &stream, offs_t pc, const case 'F': util::stream_format(stream, "%s", regfile[f]); break; case 'K': util::stream_format(stream, "%02Xh", k); break; default: - fatalerror("illegal escape character in format '%s'\n",Op[op].fmt); + throw std::logic_error(util::string_format("illegal escape character in format '%s'\n",Op[op].fmt)); } } else diff --git a/src/devices/cpu/pic16c5x/pic16c5x.cpp b/src/devices/cpu/pic16c5x/pic16c5x.cpp index f467e221805..3453401ecd8 100644 --- a/src/devices/cpu/pic16c5x/pic16c5x.cpp +++ b/src/devices/cpu/pic16c5x/pic16c5x.cpp @@ -945,7 +945,7 @@ void pic16c5x_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_PREVPC).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_OPTION).formatstr("%13s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -1167,7 +1167,7 @@ void pic16c5x_device::execute_run() { m_count_pending = false; m_inst_cycles = 1; - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); if (WDTE) { pic16c5x_update_watchdog(1); } @@ -1181,7 +1181,7 @@ void pic16c5x_device::execute_run() m_PREVPC = m_PC; - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); m_opcode.d = M_RDOP(m_PC); m_PC++; diff --git a/src/devices/cpu/pic16c62x/16c62xdsm.cpp b/src/devices/cpu/pic16c62x/16c62xdsm.cpp index 69072a4ada9..3b1dcdfca57 100644 --- a/src/devices/cpu/pic16c62x/16c62xdsm.cpp +++ b/src/devices/cpu/pic16c62x/16c62xdsm.cpp @@ -30,6 +30,8 @@ #include "16c62xdsm.h" #include <ctype.h> +#include <stdexcept> + /* Registers bank 0/1 */ const char *const pic16c62x_disassembler::regfile[32] = { "Reg$00 (INDF)", "Reg$01 (TMR0/OPTION)", "Reg$02 (PCL)", "Reg$03 (STATUS)", "Reg$04 (FSR)", "Reg$05 (PORTA/TRISA)", "Reg$06 (PORTB/TRISB)", "Reg$07", @@ -112,14 +114,13 @@ pic16c62x_disassembler::pic16c62x_disassembler() case 'x': bit --; break; - default: fatalerror("Invalid instruction encoding '%s %s'\n", - ops[0],ops[1]); + default: + throw std::logic_error(util::string_format("Invalid instruction encoding '%s %s'\n", ops[0],ops[1])); } } if (bit != -1 ) { - fatalerror("not enough bits in encoding '%s %s' %d\n", - ops[0],ops[1],bit); + throw std::logic_error(util::string_format("not enough bits in encoding '%s %s' %d\n", ops[0],ops[1],bit)); } while (isspace((uint8_t)*p)) p++; Op.emplace_back(mask, bits, *p, ops[0], ops[1]); @@ -190,7 +191,7 @@ offs_t pic16c62x_disassembler::disassemble(std::ostream &stream, offs_t pc, cons case 'k': k <<=1; k |= ((code & (1<<bit)) ? 1 : 0); bit--; break; case ' ': break; case '1': case '0': case 'x': bit--; break; - case '\0': fatalerror("premature end of parse string, opcode %x, bit = %d\n",code,bit); + case '\0': throw std::logic_error(util::string_format("premature end of parse string, opcode %x, bit = %d\n",code,bit)); } cp++; } @@ -215,7 +216,7 @@ offs_t pic16c62x_disassembler::disassemble(std::ostream &stream, offs_t pc, cons case 'F': if (f < 0x20) util::stream_format(stream, "%s",regfile[f]); else util::stream_format(stream, "Reg$%02X",f); break; case 'K': util::stream_format(stream, "%02Xh", k); break; default: - fatalerror("illegal escape character in format '%s'\n",Op[op].fmt); + throw std::logic_error(util::string_format("illegal escape character in format '%s'\n",Op[op].fmt)); } } else diff --git a/src/devices/cpu/pic16c62x/pic16c62x.cpp b/src/devices/cpu/pic16c62x/pic16c62x.cpp index f21f52b89c9..93935220e05 100644 --- a/src/devices/cpu/pic16c62x/pic16c62x.cpp +++ b/src/devices/cpu/pic16c62x/pic16c62x.cpp @@ -927,7 +927,7 @@ void pic16c62x_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_PREVPC).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_OPTION).formatstr("%13s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void pic16c62x_device::state_import(const device_state_entry &entry) @@ -1115,7 +1115,7 @@ void pic16c62x_device::execute_run() if (PD == 0) /* Sleep Mode */ { m_inst_cycles = 1; - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); if (WDTE) { pic16c62x_update_watchdog(1); } @@ -1124,7 +1124,7 @@ void pic16c62x_device::execute_run() { m_PREVPC = m_PC; - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); m_opcode.d = M_RDOP(m_PC); m_PC++; diff --git a/src/devices/cpu/powerpc/ppccom.cpp b/src/devices/cpu/powerpc/ppccom.cpp index e56ed8554e4..1e065030a3e 100644 --- a/src/devices/cpu/powerpc/ppccom.cpp +++ b/src/devices/cpu/powerpc/ppccom.cpp @@ -814,7 +814,7 @@ void ppc_device::device_start() state_add(STATE_GENSP, "GENSP", m_core->r[31]).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).noshow().formatstr("%1s"); - m_icountptr = &m_core->icount; + set_icountptr(m_core->icount); uint32_t flags = 0; /* initialize the UML generator */ diff --git a/src/devices/cpu/pps4/pps4.cpp b/src/devices/cpu/pps4/pps4.cpp index d018f97a733..82c6c9b42f9 100644 --- a/src/devices/cpu/pps4/pps4.cpp +++ b/src/devices/cpu/pps4/pps4.cpp @@ -1556,7 +1556,7 @@ void pps4_device::execute_run() { do { - debugger_instruction_hook(this, m_P); + debugger_instruction_hook(m_P); execute_one(); } while (m_icount > 0); @@ -1603,7 +1603,7 @@ void pps4_device::device_start() state_add( STATE_GENPCBASE,"CURPC", m_P ).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_C).formatstr("%3s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); m_dia_cb.resolve_safe(0); m_dib_cb.resolve_safe(0); diff --git a/src/devices/cpu/psx/psx.cpp b/src/devices/cpu/psx/psx.cpp index 062e78219dd..0a7d3a7b0ae 100644 --- a/src/devices/cpu/psx/psx.cpp +++ b/src/devices/cpu/psx/psx.cpp @@ -309,7 +309,7 @@ WRITE32_MEMBER( psxcpu_device::biu_w ) void psxcpu_device::stop() { machine().debug_break(); - debugger_instruction_hook( this, m_pc ); + debugger_instruction_hook( m_pc ); } uint32_t psxcpu_device::cache_readword( uint32_t offset ) @@ -1964,7 +1964,7 @@ void psxcpu_device::device_start() state_add( PSXCPU_CP2CR31, "flag", m_gte.m_cp2cr[ 31 ].d ); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); m_gpu_read_handler.resolve_safe( 0 ); m_gpu_write_handler.resolve_safe(); @@ -2316,7 +2316,7 @@ void psxcpu_device::execute_run() do { if( LOG_BIOSCALL ) log_bioscall(); - debugger_instruction_hook( this, m_pc ); + debugger_instruction_hook( m_pc ); int breakpoint = program_counter_breakpoint(); diff --git a/src/devices/cpu/rsp/rsp.cpp b/src/devices/cpu/rsp/rsp.cpp index 0f904fe45df..cf04e8a2bf5 100644 --- a/src/devices/cpu/rsp/rsp.cpp +++ b/src/devices/cpu/rsp/rsp.cpp @@ -502,7 +502,7 @@ void rsp_device::device_start() state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%1s").noshow(); state_add( STATE_GENSP, "GENSP", m_rsp_state->r[31]).noshow(); - m_icountptr = &m_rsp_state->icount; + set_icountptr(m_rsp_state->icount); } void rsp_device::state_import(const device_state_entry &entry) @@ -626,7 +626,7 @@ void rsp_device::execute_run() while (m_rsp_state->icount > 0) { m_ppc = m_rsp_state->pc; - debugger_instruction_hook(this, m_rsp_state->pc); + debugger_instruction_hook(m_rsp_state->pc); uint32_t op = ROPCODE(m_rsp_state->pc); if (m_nextpc != ~0) diff --git a/src/devices/cpu/s2650/s2650.cpp b/src/devices/cpu/s2650/s2650.cpp index a11f768c12d..46229053837 100644 --- a/src/devices/cpu/s2650/s2650.cpp +++ b/src/devices/cpu/s2650/s2650.cpp @@ -858,7 +858,7 @@ void s2650_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_ppc).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%16s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void s2650_device::state_import(const device_state_entry &entry) @@ -1002,7 +1002,7 @@ void s2650_device::execute_run() { m_ppc = m_page + m_iar; - debugger_instruction_hook(this, m_page + m_iar); + debugger_instruction_hook(m_page + m_iar); m_ir = ROP(); m_r = m_ir & 3; /* register / value */ diff --git a/src/devices/cpu/saturn/saturn.cpp b/src/devices/cpu/saturn/saturn.cpp index b6dbf0b98f9..591b0ff57c9 100644 --- a/src/devices/cpu/saturn/saturn.cpp +++ b/src/devices/cpu/saturn/saturn.cpp @@ -179,7 +179,7 @@ void saturn_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_pc ).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%2s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void saturn_device::state_string_export(const device_state_entry &entry, std::string &str) const @@ -349,7 +349,7 @@ void saturn_device::execute_run() { m_oldpc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); if ( m_sleeping ) { diff --git a/src/devices/cpu/sc61860/sc61860.cpp b/src/devices/cpu/sc61860/sc61860.cpp index c6898c181e0..00095916644 100644 --- a/src/devices/cpu/sc61860/sc61860.cpp +++ b/src/devices/cpu/sc61860/sc61860.cpp @@ -172,7 +172,7 @@ void sc61860_device::device_start() state_add(STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%2s").noshow(); state_add(STATE_GENSP, "GENSP", m_r).mask(0x7f).formatstr("%02X").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -234,7 +234,7 @@ void sc61860_device::execute_run() { m_oldpc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); sc61860_instruction(); diff --git a/src/devices/cpu/scmp/scmp.cpp b/src/devices/cpu/scmp/scmp.cpp index de3b46217ed..4c78a0a8e9c 100644 --- a/src/devices/cpu/scmp/scmp.cpp +++ b/src/devices/cpu/scmp/scmp.cpp @@ -475,7 +475,7 @@ void scmp_device::execute_run() if ((m_SR & 0x08) && (m_sensea_func())) { take_interrupt(); } - debugger_instruction_hook(this, m_PC.d); + debugger_instruction_hook(m_PC.d); execute_one(ROP()); } while (m_icount > 0); @@ -520,7 +520,7 @@ void scmp_device::device_start() save_item(NAME(m_ER)); save_item(NAME(m_SR)); - m_icountptr = &m_icount; + set_icountptr(m_icount); } diff --git a/src/devices/cpu/score/score.cpp b/src/devices/cpu/score/score.cpp index 1244160d9c7..a12ee32185b 100644 --- a/src/devices/cpu/score/score.cpp +++ b/src/devices/cpu/score/score.cpp @@ -76,7 +76,7 @@ void score7_cpu_device::device_start() m_direct = m_program->direct<0>(); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // register state for debugger state_add(SCORE_PC , "PC" , m_pc).callimport().callexport().formatstr("%08X"); @@ -172,7 +172,7 @@ void score7_cpu_device::execute_run() do { m_ppc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); check_irq(); @@ -325,7 +325,7 @@ void score7_cpu_device::check_irq() if (m_pending_interrupt[i]) { m_pending_interrupt[i] = false; - debugger_interrupt_hook(this, i); + debugger_interrupt_hook(i); gen_exception(EXCEPTION_INTERRUPT, i); return; } @@ -335,7 +335,7 @@ void score7_cpu_device::check_irq() void score7_cpu_device::gen_exception(int cause, uint32_t param) { - debugger_exception_hook(this, cause); + debugger_exception_hook(cause); REG_ECR = (REG_ECR & ~0x0000001f) | (cause & 0x1f); // set exception cause REG_PSR = (REG_PSR & ~0x0000000f) | ((REG_PSR << 2) & 0x0c); // push status bits diff --git a/src/devices/cpu/scudsp/scudsp.cpp b/src/devices/cpu/scudsp/scudsp.cpp index ef7f5294af9..eb98c934ab8 100644 --- a/src/devices/cpu/scudsp/scudsp.cpp +++ b/src/devices/cpu/scudsp/scudsp.cpp @@ -841,7 +841,7 @@ void scudsp_cpu_device::execute_run() { m_update_mul = 0; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); if ( m_delay ) { @@ -993,7 +993,7 @@ void scudsp_cpu_device::device_start() m_in_dma_cb.resolve_safe(0); m_out_dma_cb.resolve_safe(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void scudsp_cpu_device::device_reset() diff --git a/src/devices/cpu/se3208/se3208.cpp b/src/devices/cpu/se3208/se3208.cpp index ff872b03340..d0823d3f7af 100644 --- a/src/devices/cpu/se3208/se3208.cpp +++ b/src/devices/cpu/se3208/se3208.cpp @@ -1763,7 +1763,7 @@ void se3208_device::execute_run() uint16_t Opcode=m_direct->read_word(m_PC, WORD_XOR_LE(0)); m_PPC = m_PC; - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); (this->*OpTable[Opcode])(Opcode); m_PC+=2; @@ -1815,7 +1815,7 @@ void se3208_device::device_start() state_add(STATE_GENSP, "GENSP", m_SP).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_SR).formatstr("%10s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } diff --git a/src/devices/cpu/sh/sh.cpp b/src/devices/cpu/sh/sh.cpp index c6fa52e37d1..6bcb1a6fea7 100644 --- a/src/devices/cpu/sh/sh.cpp +++ b/src/devices/cpu/sh/sh.cpp @@ -80,7 +80,7 @@ void sh_common_execution::device_start() state_add(STATE_GENSP, "GENSP", m_sh2_state->r[15]).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_sh2_state->sr).formatstr("%20s").noshow(); - m_icountptr = &m_sh2_state->icount; + set_icountptr(m_sh2_state->icount); m_program = &space(AS_PROGRAM); } diff --git a/src/devices/cpu/sh/sh2.cpp b/src/devices/cpu/sh/sh2.cpp index 40259f420d5..dd7564b0268 100644 --- a/src/devices/cpu/sh/sh2.cpp +++ b/src/devices/cpu/sh/sh2.cpp @@ -393,7 +393,7 @@ void sh2_device::execute_run() do { - debugger_instruction_hook(this, m_sh2_state->pc); + debugger_instruction_hook(m_sh2_state->pc); const uint16_t opcode = m_program->read_word(m_sh2_state->pc & SH12_AM); diff --git a/src/devices/cpu/sh/sh4.cpp b/src/devices/cpu/sh/sh4.cpp index 31da75a896b..ba411100e64 100644 --- a/src/devices/cpu/sh/sh4.cpp +++ b/src/devices/cpu/sh/sh4.cpp @@ -1880,7 +1880,7 @@ void sh34_base_device::execute_run() do { m_ppc = m_sh2_state->pc & SH34_AM; - debugger_instruction_hook(this, m_sh2_state->pc & SH34_AM); + debugger_instruction_hook(m_sh2_state->pc & SH34_AM); uint16_t opcode; @@ -1923,7 +1923,7 @@ void sh3be_device::execute_run() do { m_ppc = m_sh2_state->pc & SH34_AM; - debugger_instruction_hook(this, m_sh2_state->pc & SH34_AM); + debugger_instruction_hook(m_sh2_state->pc & SH34_AM); const uint16_t opcode = m_direct->read_word(m_sh2_state->pc & SH34_AM, WORD_XOR_LE(6)); @@ -1963,7 +1963,7 @@ void sh4be_device::execute_run() do { m_ppc = m_sh2_state->pc & SH34_AM; - debugger_instruction_hook(this, m_sh2_state->pc & SH34_AM); + debugger_instruction_hook(m_sh2_state->pc & SH34_AM); const uint16_t opcode = m_direct->read_word(m_sh2_state->pc & SH34_AM, WORD_XOR_LE(6)); diff --git a/src/devices/cpu/sharc/sharc.cpp b/src/devices/cpu/sharc/sharc.cpp index bda0c6e6910..940deb1d5b1 100644 --- a/src/devices/cpu/sharc/sharc.cpp +++ b/src/devices/cpu/sharc/sharc.cpp @@ -863,7 +863,7 @@ void adsp21062_device::device_start() state_add( STATE_GENPC, "GENPC", m_core->pc).noshow(); state_add( STATE_GENPCBASE, "CURPC", m_core->pc).noshow(); - m_icountptr = &m_core->icount; + set_icountptr(m_core->icount); } void adsp21062_device::device_reset() @@ -1014,7 +1014,7 @@ void adsp21062_device::execute_run() if (m_core->idle && m_core->irq_pending == 0) { m_core->icount = 0; - debugger_instruction_hook(this, m_core->daddr); + debugger_instruction_hook(m_core->daddr); } if (m_core->irq_pending != 0) { @@ -1033,7 +1033,7 @@ void adsp21062_device::execute_run() m_core->astat_old_old = m_core->astat_old; m_core->astat_old = m_core->astat; - debugger_instruction_hook(this, m_core->pc); + debugger_instruction_hook(m_core->pc); m_core->opcode = m_program->read_qword(m_core->pc); diff --git a/src/devices/cpu/sharc/sharcdsm.cpp b/src/devices/cpu/sharc/sharcdsm.cpp index ebab8add599..e5fd3c62f24 100644 --- a/src/devices/cpu/sharc/sharcdsm.cpp +++ b/src/devices/cpu/sharc/sharcdsm.cpp @@ -9,6 +9,9 @@ #include "emu.h" #include "sharcdsm.h" +#include <stdexcept> + + const char sharc_disassembler::ureg_names[256][16] = { "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", @@ -1215,7 +1218,7 @@ sharc_disassembler::sharc_disassembler() { if (sharcdasm_table[i] != &sharc_disassembler::dasm_invalid) { - fatalerror("build_dasm_table: table already filled! (i=%04X, j=%d)\n", i, j); + throw std::logic_error(util::string_format("build_dasm_table: table already filled! (i=%04X, j=%d)\n", i, j)); } else { diff --git a/src/devices/cpu/sm510/sm510base.cpp b/src/devices/cpu/sm510/sm510base.cpp index 58b16abd11f..a54eb433862 100644 --- a/src/devices/cpu/sm510/sm510base.cpp +++ b/src/devices/cpu/sm510/sm510base.cpp @@ -130,7 +130,7 @@ void sm510_base_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_c).formatstr("%1s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); // init peripherals init_divider(); @@ -300,7 +300,7 @@ void sm510_base_device::execute_run() m_prev_pc = m_pc; // fetch next opcode - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_op = m_program->read_byte(m_pc); increment_pc(); get_opcode_param(); diff --git a/src/devices/cpu/sm8500/sm8500.cpp b/src/devices/cpu/sm8500/sm8500.cpp index c5ab3aeccfe..483cd29707b 100644 --- a/src/devices/cpu/sm8500/sm8500.cpp +++ b/src/devices/cpu/sm8500/sm8500.cpp @@ -146,7 +146,7 @@ void sm8500_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_PC).formatstr("%8s").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_PS1).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -365,7 +365,7 @@ void sm8500_cpu_device::execute_run() uint32_t d1,d2; uint32_t res; - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); m_oldpc = m_PC; process_interrupts(); if ( !m_halted ) { diff --git a/src/devices/cpu/sparc/mb86901.cpp b/src/devices/cpu/sparc/mb86901.cpp index fa226356bb2..977455e72f0 100644 --- a/src/devices/cpu/sparc/mb86901.cpp +++ b/src/devices/cpu/sparc/mb86901.cpp @@ -360,7 +360,7 @@ void mb86901_device::device_start() save_item(NAME(m_hold_bus)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -2953,7 +2953,7 @@ void mb86901_device::execute_step() { execute_trap(); BREAK_PSR; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); } if (m_execute_mode) @@ -3076,7 +3076,7 @@ void mb86901_device::execute_run() } BREAK_PSR; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); if (m_reset_mode) { diff --git a/src/devices/cpu/spc700/spc700.cpp b/src/devices/cpu/spc700/spc700.cpp index 97596d00fa8..3118d97e810 100644 --- a/src/devices/cpu/spc700/spc700.cpp +++ b/src/devices/cpu/spc700/spc700.cpp @@ -1249,7 +1249,7 @@ void spc700_device::device_start() state_add(STATE_GENSP, "GENSP", m_debugger_temp).mask(0x1ff).callexport().formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%8s").noshow(); - m_icountptr = &m_ICount; + set_icountptr(m_ICount); } @@ -1371,7 +1371,7 @@ void spc700_device::execute_run() while(CLOCKS > 0) { REG_PPC = REG_PC; - debugger_instruction_hook(this, REG_PC); + debugger_instruction_hook(REG_PC); REG_PC++; switch(REG_IR = read_8_immediate(REG_PPC)) diff --git a/src/devices/cpu/ssem/ssem.cpp b/src/devices/cpu/ssem/ssem.cpp index 354bda3cb85..88ceab819ed 100644 --- a/src/devices/cpu/ssem/ssem.cpp +++ b/src/devices/cpu/ssem/ssem.cpp @@ -112,7 +112,7 @@ void ssem_device::device_start() save_item(NAME(m_halt)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } void ssem_device::device_stop() @@ -230,7 +230,7 @@ void ssem_device::execute_run() while (m_icount > 0) { - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); op = program_read32(m_pc); diff --git a/src/devices/cpu/ssp1601/ssp1601.cpp b/src/devices/cpu/ssp1601/ssp1601.cpp index 0c414d4d46e..43bb84a8ffe 100644 --- a/src/devices/cpu/ssp1601/ssp1601.cpp +++ b/src/devices/cpu/ssp1601/ssp1601.cpp @@ -552,7 +552,7 @@ void ssp1601_device::device_start() state_add(STATE_GENPCBASE, "CURPC", PPC).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", rST).formatstr("%4s").noshow(); - m_icountptr = &m_g_cycles; + set_icountptr(m_g_cycles); } @@ -589,7 +589,7 @@ void ssp1601_device::execute_run() PPC = rPC; - debugger_instruction_hook(this, rPC); + debugger_instruction_hook(rPC); op = FETCH(); diff --git a/src/devices/cpu/superfx/superfx.cpp b/src/devices/cpu/superfx/superfx.cpp index d3985d4645d..1e82376458b 100644 --- a/src/devices/cpu/superfx/superfx.cpp +++ b/src/devices/cpu/superfx/superfx.cpp @@ -704,7 +704,7 @@ void superfx_device::device_start() state_add( STATE_GENPC, "GENPC", m_debugger_temp).callexport().formatstr("%06X"); state_add( STATE_GENPCBASE, "CURPC", m_debugger_temp).callexport().formatstr("%06X"); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -787,7 +787,7 @@ void superfx_device::execute_run() break; } - debugger_instruction_hook(this, (m_pbr << 16) | m_r[15]); + debugger_instruction_hook((m_pbr << 16) | m_r[15]); op = superfx_peekpipe(); diff --git a/src/devices/cpu/t11/t11.cpp b/src/devices/cpu/t11/t11.cpp index f77400acf53..80894f2cb73 100644 --- a/src/devices/cpu/t11/t11.cpp +++ b/src/devices/cpu/t11/t11.cpp @@ -293,7 +293,7 @@ void t11_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_ppc.w.l).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_psw.b.l).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void t11_device::state_string_export(const device_state_entry &entry, std::string &str) const @@ -415,7 +415,7 @@ void t11_device::execute_run() m_ppc = m_reg[7]; /* copy PC to previous PC */ - debugger_instruction_hook(this, PCD); + debugger_instruction_hook(PCD); op = ROPCODE(); (this->*s_opcode_table[op >> 3])(op); diff --git a/src/devices/cpu/tlcs870/tlcs870.cpp b/src/devices/cpu/tlcs870/tlcs870.cpp index 86cdac439c6..bf846e61f4b 100644 --- a/src/devices/cpu/tlcs870/tlcs870.cpp +++ b/src/devices/cpu/tlcs870/tlcs870.cpp @@ -2518,7 +2518,7 @@ void tlcs870_device::execute_run() do { m_prvpc.d = m_pc.d; - debugger_instruction_hook(this, m_pc.d); + debugger_instruction_hook(m_pc.d); //check_interrupts(); m_temppc = m_pc.d; @@ -3141,7 +3141,7 @@ void tlcs870_device::device_start() state_add(STATE_GENSP, "GENSP", m_sp.w.l).formatstr("%04X"); state_add(STATE_GENFLAGS, "GENFLAGS", m_F ).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } diff --git a/src/devices/cpu/tlcs90/tlcs90.cpp b/src/devices/cpu/tlcs90/tlcs90.cpp index b6a01d81178..1e109c0048e 100644 --- a/src/devices/cpu/tlcs90/tlcs90.cpp +++ b/src/devices/cpu/tlcs90/tlcs90.cpp @@ -1366,7 +1366,7 @@ void tlcs90_device::execute_run() do { m_prvpc.d = m_pc.d; - debugger_instruction_hook(this, m_pc.d); + debugger_instruction_hook(m_pc.d); check_interrupts(); @@ -2849,7 +2849,7 @@ void tlcs90_device::device_start() state_add(STATE_GENSP, "GENSP", m_sp.w.l).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", F ).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } diff --git a/src/devices/cpu/tlcs90/tlcs90d.cpp b/src/devices/cpu/tlcs90/tlcs90d.cpp index 66787e84528..662eaf8b88d 100644 --- a/src/devices/cpu/tlcs90/tlcs90d.cpp +++ b/src/devices/cpu/tlcs90/tlcs90d.cpp @@ -928,13 +928,10 @@ bool tlcs90_disassembler::stream_arg(std::ostream &stream, uint32_t pc, const ch case e_mode::R16R8: util::stream_format(stream, "%s%s+%s", pre, r16_names[r], r8_names[rb] ); return true; case e_mode::R16D8: util::stream_format(stream, "%s%s%c$%02X", pre, r16_names[r], (rb&0x80)?'-':'+', (rb&0x80)?((rb^0xff)+1):rb ); return true; - - default: - fatalerror("%04x: unimplemented addr mode = %d\n",pc,std::underlying_type_t<e_mode>(mode)); } // never executed - return false; + throw std::logic_error(util::string_format("%04x: unimplemented addr mode = %d\n",pc,std::underlying_type_t<e_mode>(mode))); } offs_t tlcs90_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) diff --git a/src/devices/cpu/tlcs900/tlcs900.cpp b/src/devices/cpu/tlcs900/tlcs900.cpp index 64e7e928f7a..56e8dc1e472 100644 --- a/src/devices/cpu/tlcs900/tlcs900.cpp +++ b/src/devices/cpu/tlcs900/tlcs900.cpp @@ -388,7 +388,7 @@ void tlcs900h_device::device_start() state_add( STATE_GENPCBASE, "CURPC", m_pc.d ).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_sr.w.l ).formatstr("%12s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -1052,7 +1052,7 @@ void tlcs900h_device::execute_run() m_check_irqs = 0; } - debugger_instruction_hook( this, m_pc.d ); + debugger_instruction_hook( m_pc.d ); if ( m_halted ) { diff --git a/src/devices/cpu/tms1000/tms0980.cpp b/src/devices/cpu/tms1000/tms0980.cpp index acb8d7ef249..dbf9d10d8de 100644 --- a/src/devices/cpu/tms1000/tms0980.cpp +++ b/src/devices/cpu/tms1000/tms0980.cpp @@ -173,7 +173,7 @@ u32 tms0980_cpu_device::read_micro() void tms0980_cpu_device::read_opcode() { - debugger_instruction_hook(this, m_rom_address); + debugger_instruction_hook(m_rom_address); m_opcode = m_program->read_word(m_rom_address) & 0x1ff; m_c4 = bitswap<8>(m_opcode,7,6,5,4,0,1,2,3) & 0xf; // opcode operand is bitswapped for most opcodes diff --git a/src/devices/cpu/tms1000/tms1k_base.cpp b/src/devices/cpu/tms1000/tms1k_base.cpp index 62ff54cdd0d..432e43e0d7b 100644 --- a/src/devices/cpu/tms1000/tms1k_base.cpp +++ b/src/devices/cpu/tms1000/tms1k_base.cpp @@ -226,7 +226,7 @@ void tms1k_base_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_rom_address).formatstr("%03X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_sr).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } device_memory_interface::space_config_vector tms1k_base_device::memory_space_config() const @@ -295,7 +295,7 @@ void tms1k_base_device::next_pc() void tms1k_base_device::read_opcode() { - debugger_instruction_hook(this, m_rom_address); + debugger_instruction_hook(m_rom_address); m_opcode = m_program->read_byte(m_rom_address); m_c4 = bitswap<8>(m_opcode,7,6,5,4,0,1,2,3) & 0xf; // opcode operand is bitswapped for most opcodes diff --git a/src/devices/cpu/tms32010/32010dsm.cpp b/src/devices/cpu/tms32010/32010dsm.cpp index a1dfade63b4..4601498ce64 100644 --- a/src/devices/cpu/tms32010/32010dsm.cpp +++ b/src/devices/cpu/tms32010/32010dsm.cpp @@ -26,7 +26,10 @@ #include "emu.h" #include "32010dsm.h" + #include <ctype.h> +#include <stdexcept> + const char *const tms32010_disassembler::arith[4] = { "*" , "*-" , "*+" , "??" } ; const char *const tms32010_disassembler::nextar[4] = { ",AR0" , ",AR1" , "" , "" } ; @@ -174,16 +177,15 @@ tms32010_disassembler::tms32010_disassembler() case 'r': case 's': case 'w': - bit --; + bit--; break; - default: fatalerror("Invalid instruction encoding '%s %s'\n", - ops[0],ops[1]); + default: + throw std::logic_error(util::string_format("Invalid instruction encoding '%s %s'\n", ops[0],ops[1])); } } if (bit != -1 ) { - fatalerror("not enough bits in encoding '%s %s' %d\n", - ops[0],ops[1],bit); + throw std::logic_error(util::string_format("not enough bits in encoding '%s %s' %d\n", ops[0],ops[1],bit)); } while (isspace((uint8_t)*p)) p++; Op.emplace_back(mask, bits, *p, ops[0], ops[1]); @@ -258,7 +260,7 @@ offs_t tms32010_disassembler::disassemble(std::ostream &stream, offs_t pc, const case 'w': w <<=1; w |= ((code & (1<<bit)) ? 1 : 0); bit--; break; case ' ': break; case '1': case '0': bit--; break; - case '\0': fatalerror("premature end of parse string, opcode %x, bit = %d\n",code,bit); + case '\0': throw std::logic_error(util::string_format("premature end of parse string, opcode %x, bit = %d\n",code,bit)); } cp++; } @@ -290,7 +292,7 @@ offs_t tms32010_disassembler::disassemble(std::ostream &stream, offs_t pc, const case 'S': sprintf(num,",%d",s); break; case 'W': sprintf(num,"%04Xh",w); break; default: - fatalerror("illegal escape character in format '%s'\n",Op[op].fmt); + throw std::logic_error(util::string_format("illegal escape character in format '%s'\n",Op[op].fmt)); } stream << num; } diff --git a/src/devices/cpu/tms32010/tms32010.cpp b/src/devices/cpu/tms32010/tms32010.cpp index c5e15660a6f..8b336a9d401 100644 --- a/src/devices/cpu/tms32010/tms32010.cpp +++ b/src/devices/cpu/tms32010/tms32010.cpp @@ -871,7 +871,7 @@ void tms32010_device::device_start() state_add(STATE_GENSP, "GENSP", m_STACK[3]).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_STR).formatstr("%16s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -965,7 +965,7 @@ void tms32010_device::execute_run() m_PREVPC = m_PC; - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); m_opcode.d = M_RDOP(m_PC); m_PC++; diff --git a/src/devices/cpu/tms32025/32025dsm.cpp b/src/devices/cpu/tms32025/32025dsm.cpp index b8ad14415c3..c2ae6f96b2a 100644 --- a/src/devices/cpu/tms32025/32025dsm.cpp +++ b/src/devices/cpu/tms32025/32025dsm.cpp @@ -32,7 +32,10 @@ #include "emu.h" #include "32025dsm.h" + #include <ctype.h> +#include <stdexcept> + const char *const tms32025_disassembler::arith[8] = { "*", "*-", "*+", "??", "BR0-", "*0-", "*0+", "*BR0+" } ; const char *const tms32025_disassembler::nextar[16] = { "", "", "", "", "", "", "", "", ",AR0", ",AR1", ",AR2", ",AR3", ",AR4", ",AR5", ",AR6", ",AR7" } ; @@ -339,16 +342,15 @@ tms32025_disassembler::tms32025_disassembler() case 't': case 'w': case 'x': - bit --; + bit--; break; - default: fatalerror("Invalid instruction encoding '%s %s'\n", - ops[0],ops[1]); + default: + throw std::logic_error(util::string_format("Invalid instruction encoding '%s %s'\n", ops[0],ops[1])); } } if (bit != -1 ) { - fatalerror("not enough bits in encoding '%s %s' %d\n", - ops[0],ops[1],bit); + throw std::logic_error(util::string_format("not enough bits in encoding '%s %s' %d\n", ops[0],ops[1],bit)); } while (isspace((uint8_t)*p)) p++; Op.emplace_back(mask, bits, *p, ops[0], ops[1]); @@ -426,7 +428,7 @@ offs_t tms32025_disassembler::disassemble(std::ostream &stream, offs_t pc, const case 'x': bit--; break; case ' ': break; case '1': case '0': bit--; break; - case '\0': fatalerror("premature end of parse string, opcode %x, bit = %d\n",code,bit); + case '\0': throw std::logic_error(util::string_format("premature end of parse string, opcode %x, bit = %d\n",code,bit)); } cp++; } @@ -461,7 +463,7 @@ offs_t tms32025_disassembler::disassemble(std::ostream &stream, offs_t pc, const case 'W': sprintf(num,"%04Xh",w); break; case 'X': break; default: - fatalerror("illegal escape character in format '%s'\n",Op[op].fmt); + throw std::logic_error(util::string_format("illegal escape character in format '%s'\n",Op[op].fmt)); } stream << num; } diff --git a/src/devices/cpu/tms32025/tms32025.cpp b/src/devices/cpu/tms32025/tms32025.cpp index db83ca7f3aa..e430f0ac927 100644 --- a/src/devices/cpu/tms32025/tms32025.cpp +++ b/src/devices/cpu/tms32025/tms32025.cpp @@ -1725,7 +1725,7 @@ void tms32025_device::device_start() state_add(STATE_GENSP, "GENSP", m_STACK[7]).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_STR0).formatstr("%33s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -1952,7 +1952,7 @@ void tms32025_device::execute_run() while (m_idle && m_icount > 0) process_timer(m_icount); - if (m_icount <= 0) debugger_instruction_hook(this, m_PC); + if (m_icount <= 0) debugger_instruction_hook(m_PC); while (m_icount > 0) @@ -1965,7 +1965,7 @@ void tms32025_device::execute_run() m_PREVPC = m_PC; - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); m_opcode.d = m_direct->read_word(m_PC); m_PC++; @@ -1999,7 +1999,7 @@ void tms32025_device::execute_run() \****************************************************/ m_PREVPC = m_PC; - debugger_instruction_hook(this, m_PC); + debugger_instruction_hook(m_PC); m_opcode.d = m_direct->read_word(m_PC); m_PC++; diff --git a/src/devices/cpu/tms32031/32031ops.hxx b/src/devices/cpu/tms32031/32031ops.hxx index b6d085f0325..c97512b52b3 100644 --- a/src/devices/cpu/tms32031/32031ops.hxx +++ b/src/devices/cpu/tms32031/32031ops.hxx @@ -5490,11 +5490,11 @@ inline void tms3203x_device::execute_delayed(uint32_t newpc) } else { - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); execute_one(); - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); execute_one(); - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); execute_one(); } diff --git a/src/devices/cpu/tms32031/tms32031.cpp b/src/devices/cpu/tms32031/tms32031.cpp index 713a511f304..c8d1d0b363e 100644 --- a/src/devices/cpu/tms32031/tms32031.cpp +++ b/src/devices/cpu/tms32031/tms32031.cpp @@ -274,7 +274,7 @@ tms3203x_device::tms3203x_device(const machine_config &mconfig, device_type type memset(&m_r, 0, sizeof(m_r)); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); #if (TMS_3203X_LOG_OPCODE_USAGE) memset(m_hits, 0, sizeof(m_hits)); @@ -805,7 +805,7 @@ void tms3203x_device::execute_run() continue; } - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); execute_one(); } } diff --git a/src/devices/cpu/tms32051/tms32051.cpp b/src/devices/cpu/tms32051/tms32051.cpp index 89ec626de71..ed620425891 100644 --- a/src/devices/cpu/tms32051/tms32051.cpp +++ b/src/devices/cpu/tms32051/tms32051.cpp @@ -251,7 +251,7 @@ void tms32051_device::device_start() state_add(STATE_GENPC, "GENPC", m_pc).formatstr("%04X").noshow(); state_add(STATE_GENPCBASE, "CURPC", m_pc).formatstr("%04X").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void tms32051_device::device_reset() @@ -377,7 +377,7 @@ void tms32051_device::execute_run() if (m_idle) { - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); CYCLES(1); } else @@ -401,7 +401,7 @@ void tms32051_device::execute_run() } ppc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_op = ROPCODE(); (this->*s_opcode_table[m_op >> 8])(); diff --git a/src/devices/cpu/tms32082/tms32082.cpp b/src/devices/cpu/tms32082/tms32082.cpp index a3b0c47a565..226304261a7 100644 --- a/src/devices/cpu/tms32082/tms32082.cpp +++ b/src/devices/cpu/tms32082/tms32082.cpp @@ -223,7 +223,7 @@ void tms32082_mp_device::device_start() m_program = &space(AS_PROGRAM); m_direct = m_program->direct<0>(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void tms32082_mp_device::state_string_export(const device_state_entry &entry, std::string &str) const @@ -445,7 +445,7 @@ uint32_t tms32082_mp_device::fetch() void tms32082_mp_device::delay_slot() { - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_ir = fetch(); execute(); @@ -460,7 +460,7 @@ void tms32082_mp_device::execute_run() check_interrupts(); - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_ir = fetch(); execute(); @@ -521,7 +521,7 @@ void tms32082_pp_device::device_start() m_program = &space(AS_PROGRAM); m_direct = m_program->direct<0>(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void tms32082_pp_device::state_string_export(const device_state_entry &entry, std::string &str) const @@ -543,7 +543,7 @@ void tms32082_pp_device::device_reset() void tms32082_pp_device::execute_run() { m_pc = m_fetchpc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_icount = 0; diff --git a/src/devices/cpu/tms34010/tms34010.cpp b/src/devices/cpu/tms34010/tms34010.cpp index 3ce41c05d7c..1d9dd640cd0 100644 --- a/src/devices/cpu/tms34010/tms34010.cpp +++ b/src/devices/cpu/tms34010/tms34010.cpp @@ -627,7 +627,7 @@ void tms340x0_device::device_start() save_pointer(NAME(&m_regs[0].reg), ARRAY_LENGTH(m_regs)); machine().save().register_postload(save_prepost_delegate(FUNC(tms340x0_device::tms34010_state_postload), this)); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void tms340x0_device::device_reset() @@ -751,7 +751,7 @@ void tms340x0_device::execute_run() { uint16_t op; m_ppc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); op = ROPCODE(); (this->*s_opcode_table[op >> 4])(op); } while (m_icount > 0); diff --git a/src/devices/cpu/tms57002/tms57002.cpp b/src/devices/cpu/tms57002/tms57002.cpp index 9343439671a..95f1822b1cc 100644 --- a/src/devices/cpu/tms57002/tms57002.cpp +++ b/src/devices/cpu/tms57002/tms57002.cpp @@ -724,7 +724,7 @@ void tms57002_device::execute_run() while(icount > 0 && !(sti & (S_IDLE | IN_PLOAD | IN_CLOAD))) { int iipc; - debugger_instruction_hook(this, pc); + debugger_instruction_hook(pc); if(ipc == -1) ipc = decode_get_pc(); @@ -842,7 +842,7 @@ void tms57002_device::device_start() state_add(TMS57002_HOST2, "HOST2", host[2]); state_add(TMS57002_HOST3, "HOST3", host[3]); - m_icountptr = &icount; + set_icountptr(icount); stream_alloc(4, 4, STREAM_SYNC); diff --git a/src/devices/cpu/tms7000/tms7000.cpp b/src/devices/cpu/tms7000/tms7000.cpp index eebc111cbaa..bcbebcce3ba 100644 --- a/src/devices/cpu/tms7000/tms7000.cpp +++ b/src/devices/cpu/tms7000/tms7000.cpp @@ -190,7 +190,7 @@ void tms7000_device::device_start() m_program = &space(AS_PROGRAM); m_direct = m_program->direct<0>(); - m_icountptr = &m_icount; + set_icountptr(m_icount); m_irq_state[TMS7000_INT1_LINE] = false; m_irq_state[TMS7000_INT3_LINE] = false; @@ -622,7 +622,7 @@ void tms7000_device::execute_run() do { - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_op = m_direct->read_byte(m_pc++); execute_one(m_op); diff --git a/src/devices/cpu/tms9900/ti990_10.cpp b/src/devices/cpu/tms9900/ti990_10.cpp index ecccef75942..06bab5b1d94 100644 --- a/src/devices/cpu/tms9900/ti990_10.cpp +++ b/src/devices/cpu/tms9900/ti990_10.cpp @@ -62,7 +62,7 @@ void ti990_10_device::device_start() m_cru = &space(AS_IO); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); state_add(STATE_GENPC, "GENPC", PC).formatstr("%4s").noshow(); state_add(STATE_GENPCBASE, "CURPC", PC).formatstr("%4s").noshow(); diff --git a/src/devices/cpu/tms9900/tms9900.cpp b/src/devices/cpu/tms9900/tms9900.cpp index c5240e16e47..21760205aff 100644 --- a/src/devices/cpu/tms9900/tms9900.cpp +++ b/src/devices/cpu/tms9900/tms9900.cpp @@ -226,7 +226,7 @@ void tms99xx_device::device_start() m_cru = &space(AS_IO); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); m_state_any = 0; PC = 0; @@ -1504,7 +1504,7 @@ void tms99xx_device::acquire_instruction() { decode(m_current_value); if (TRACE_EXEC) logerror("%04x: %04x (%s)\n", PC, IR, opname[m_command]); - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); PC = (PC + 2) & 0xfffe & m_prgaddr_mask; // IAQ will be cleared in the main loop } diff --git a/src/devices/cpu/tms9900/tms9980a.cpp b/src/devices/cpu/tms9900/tms9980a.cpp index 0c316b8efee..e63b1b76d5b 100644 --- a/src/devices/cpu/tms9900/tms9980a.cpp +++ b/src/devices/cpu/tms9900/tms9980a.cpp @@ -253,7 +253,7 @@ void tms9980a_device::acquire_instruction() { decode(m_current_value); if (TRACE_OP) logerror("tms9980a: ===== Next operation %04x (%s) at %04x =====\n", IR, opname[m_command], PC); - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); PC = (PC + 2) & 0xfffe & m_prgaddr_mask; } // IAQ will be cleared in the main loop diff --git a/src/devices/cpu/tms9900/tms9995.cpp b/src/devices/cpu/tms9900/tms9995.cpp index 2c03b30b911..ce854d82c04 100644 --- a/src/devices/cpu/tms9900/tms9995.cpp +++ b/src/devices/cpu/tms9900/tms9995.cpp @@ -228,7 +228,7 @@ void tms9995_device::device_start() m_dbin_line.resolve(); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // Clear the interrupt flags m_int_pending = 0; @@ -1606,7 +1606,7 @@ void tms9995_device::next_command() else logerror("%04x\n", PC-2); } PC_debug = PC - 2; - debugger_instruction_hook(this, PC_debug); + debugger_instruction_hook(PC_debug); m_first_cycle = m_icount; } } diff --git a/src/devices/cpu/ucom4/ucom4.cpp b/src/devices/cpu/ucom4/ucom4.cpp index 72cd1cc4dfd..103e78e5d2b 100644 --- a/src/devices/cpu/ucom4/ucom4.cpp +++ b/src/devices/cpu/ucom4/ucom4.cpp @@ -224,7 +224,7 @@ void ucom4_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).formatstr("%04X").noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", m_carry_f).formatstr("%5s").noshow(); // dummy - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -409,7 +409,7 @@ void ucom4_cpu_device::execute_run() m_prev_pc = m_pc; // fetch next opcode - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_icount--; m_op = m_program->read_byte(m_pc); m_bitmask = 1 << (m_op & 0x03); diff --git a/src/devices/cpu/unsp/unsp.cpp b/src/devices/cpu/unsp/unsp.cpp index 894186b0c31..3916505fd90 100644 --- a/src/devices/cpu/unsp/unsp.cpp +++ b/src/devices/cpu/unsp/unsp.cpp @@ -154,7 +154,7 @@ void unsp_device::device_start() state_add(STATE_GENPC, "GENPC", m_debugger_temp).callexport().noshow(); state_add(STATE_GENPCBASE, "CURPC", m_debugger_temp).callexport().noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void unsp_device::state_export(const device_state_entry &entry) @@ -238,7 +238,7 @@ void unsp_device::execute_run() while (m_icount > 0) { - debugger_instruction_hook(this, UNSP_LPC); + debugger_instruction_hook(UNSP_LPC); op = READ16(UNSP_LPC); UNSP_REG(PC)++; diff --git a/src/devices/cpu/upd7725/upd7725.cpp b/src/devices/cpu/upd7725/upd7725.cpp index 6d66f0420cd..7103453dd66 100644 --- a/src/devices/cpu/upd7725/upd7725.cpp +++ b/src/devices/cpu/upd7725/upd7725.cpp @@ -150,7 +150,7 @@ void necdsp_device::device_start() save_item(NAME(m_irq)); save_item(NAME(m_irq_firing)); - m_icountptr = &m_icount; + set_icountptr(m_icount); for (auto & elem : dataRAM) { @@ -335,7 +335,7 @@ void necdsp_device::execute_run() // call debugger hook if necessary if (device_t::machine().debug_flags & DEBUG_FLAG_ENABLED) { - debugger_instruction_hook(this, regs.pc); + debugger_instruction_hook(regs.pc); } if (m_irq_firing == 0) // normal opcode diff --git a/src/devices/cpu/upd7810/upd7810.cpp b/src/devices/cpu/upd7810/upd7810.cpp index 93d4e83f474..38e1f54dd4f 100644 --- a/src/devices/cpu/upd7810/upd7810.cpp +++ b/src/devices/cpu/upd7810/upd7810.cpp @@ -1669,7 +1669,7 @@ void upd7810_device::base_device_start() save_item(NAME(m_int1)); save_item(NAME(m_int2)); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void upd7810_device::device_start() @@ -1900,7 +1900,7 @@ void upd7810_device::execute_run() { int cc; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); PPC = PC; RDOP(OP); diff --git a/src/devices/cpu/v30mz/v30mz.cpp b/src/devices/cpu/v30mz/v30mz.cpp index 6357f9d09b2..0ea963f297f 100644 --- a/src/devices/cpu/v30mz/v30mz.cpp +++ b/src/devices/cpu/v30mz/v30mz.cpp @@ -191,7 +191,7 @@ void v30mz_cpu_device::device_start() state_add(STATE_GENPCBASE, "CURPC", m_pc).callexport().formatstr("%05X"); state_add(STATE_GENFLAGS, "GENFLAGS", m_TF).callimport().callexport().formatstr("%16s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -1361,7 +1361,7 @@ void v30mz_cpu_device::execute_run() } } - debugger_instruction_hook( this, pc() ); + debugger_instruction_hook( pc() ); uint8_t op = fetch_op(); diff --git a/src/devices/cpu/v60/v60.cpp b/src/devices/cpu/v60/v60.cpp index e1fead227e9..187e12a065f 100644 --- a/src/devices/cpu/v60/v60.cpp +++ b/src/devices/cpu/v60/v60.cpp @@ -498,7 +498,7 @@ void v60_device::device_start() state_add( STATE_GENSP, "GENSP", SP ).noshow(); state_add( STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -606,7 +606,7 @@ void v60_device::execute_run() { uint32_t inc; m_PPC = PC; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); m_icount -= 8; /* fix me -- this is just an average */ inc = (this->*s_OpCodeTable[OpRead8(PC)])(); PC += inc; diff --git a/src/devices/cpu/v810/v810.cpp b/src/devices/cpu/v810/v810.cpp index 46d914f7fa9..823b65626e0 100644 --- a/src/devices/cpu/v810/v810.cpp +++ b/src/devices/cpu/v810/v810.cpp @@ -1319,7 +1319,7 @@ void v810_device::device_start() state_add(STATE_GENSP, "GENSP", SP).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", PSW).formatstr("%8s").noshow(); - m_icountptr = &m_icount; + set_icountptr(m_icount); } void v810_device::state_string_export(const device_state_entry &entry, std::string &str) const @@ -1383,7 +1383,7 @@ void v810_device::execute_run() uint32_t op; m_PPC=PC; - debugger_instruction_hook(this, PC); + debugger_instruction_hook(PC); op=R_OP(PC); PC+=2; int cnt; diff --git a/src/devices/cpu/z180/z180.cpp b/src/devices/cpu/z180/z180.cpp index 9a39cb3996d..118b0371475 100644 --- a/src/devices/cpu/z180/z180.cpp +++ b/src/devices/cpu/z180/z180.cpp @@ -2162,7 +2162,7 @@ void z180_device::device_start() save_item(NAME(m_mmu)); - m_icountptr = &m_icount; + set_icountptr(m_icount); } /**************************************************************************** @@ -2420,7 +2420,7 @@ again: if ((IO_DSTAT & Z180_DSTAT_DE0) == Z180_DSTAT_DE0 && (IO_DMODE & Z180_DMODE_MMOD) == Z180_DMODE_MMOD) { - debugger_instruction_hook(this, _PCD); + debugger_instruction_hook(_PCD); /* FIXME z180_dma0 should be handled in handle_io_timers */ curcycles = z180_dma0(m_icount); @@ -2437,7 +2437,7 @@ again: m_after_EI = 0; _PPC = _PCD; - debugger_instruction_hook(this, _PCD); + debugger_instruction_hook(_PCD); if (!m_HALT) { @@ -2495,7 +2495,7 @@ again: m_after_EI = 0; _PPC = _PCD; - debugger_instruction_hook(this, _PCD); + debugger_instruction_hook(_PCD); if (!m_HALT) { diff --git a/src/devices/cpu/z8/z8.cpp b/src/devices/cpu/z8/z8.cpp index b2ef0f36d76..c7b1c8cdf09 100644 --- a/src/devices/cpu/z8/z8.cpp +++ b/src/devices/cpu/z8/z8.cpp @@ -270,7 +270,7 @@ uint8_t z8_device::fetch() uint8_t z8_device::fetch_opcode() { m_ppc = (m_pc < m_rom_size) ? m_pc : mask_external_address(m_pc); - debugger_instruction_hook(this, m_ppc); + debugger_instruction_hook(m_ppc); uint8_t data = m_direct->read_byte(m_ppc); @@ -809,7 +809,7 @@ void z8_device::device_start() save_item(NAME(m_irq_line)); save_item(NAME(m_irq_taken)); - m_icountptr = &m_icount; + set_icountptr(m_icount); } /*************************************************************************** diff --git a/src/devices/cpu/z80/z80.cpp b/src/devices/cpu/z80/z80.cpp index 81bfd9c5634..f59a61847cd 100644 --- a/src/devices/cpu/z80/z80.cpp +++ b/src/devices/cpu/z80/z80.cpp @@ -3446,7 +3446,7 @@ void z80_device::device_start() state_add(Z80_HALT, "HALT", m_halt).mask(0x1); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); /* setup cycle tables */ m_cc_op = cc_op; @@ -3517,7 +3517,7 @@ void z80_device::execute_run() m_after_ldair = false; PRVPC = PCD; - debugger_instruction_hook(this, PCD); + debugger_instruction_hook(PCD); m_r++; EXEC(op,rop()); } while (m_icount > 0); @@ -3546,7 +3546,7 @@ void nsc800_device::execute_run() m_after_ldair = false; PRVPC = PCD; - debugger_instruction_hook(this, PCD); + debugger_instruction_hook(PCD); m_r++; EXEC(op,rop()); } while (m_icount > 0); diff --git a/src/devices/cpu/z8000/z8000.cpp b/src/devices/cpu/z8000/z8000.cpp index feae93fcbfa..ae49854fb2f 100644 --- a/src/devices/cpu/z8000/z8000.cpp +++ b/src/devices/cpu/z8000/z8000.cpp @@ -670,7 +670,7 @@ void z8001_device::device_start() register_debug_state(); - m_icountptr = &m_icount; + set_icountptr(m_icount); m_mo_out.resolve_safe(); m_mi = CLEAR_LINE; } @@ -693,7 +693,7 @@ void z8002_device::device_start() register_debug_state(); - m_icountptr = &m_icount; + set_icountptr(m_icount); m_mo_out.resolve_safe(); m_mi = CLEAR_LINE; } @@ -732,7 +732,7 @@ void z8002_device::execute_run() Interrupt(); m_ppc = m_pc; - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); if (m_irq_req & Z8000_HALT) { diff --git a/src/devices/machine/53c7xx.cpp b/src/devices/machine/53c7xx.cpp index 737731ad251..4373aba1206 100644 --- a/src/devices/machine/53c7xx.cpp +++ b/src/devices/machine/53c7xx.cpp @@ -105,7 +105,7 @@ ncr53c7xx_device::ncr53c7xx_device(const machine_config &mconfig, const char *ta void ncr53c7xx_device::device_start() { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // resolve line callbacks m_irq_handler.resolve_safe(); diff --git a/src/devices/machine/am9517a.cpp b/src/devices/machine/am9517a.cpp index b39ab007252..cd6955b63ed 100644 --- a/src/devices/machine/am9517a.cpp +++ b/src/devices/machine/am9517a.cpp @@ -447,7 +447,7 @@ pcxport_dmac_device::pcxport_dmac_device(const machine_config &mconfig, const ch void am9517a_device::device_start() { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // resolve callbacks m_out_hreq_cb.resolve_safe(); diff --git a/src/devices/machine/i8257.cpp b/src/devices/machine/i8257.cpp index 6d78357b463..fb3c1a692ed 100644 --- a/src/devices/machine/i8257.cpp +++ b/src/devices/machine/i8257.cpp @@ -286,7 +286,7 @@ void i8257_device::device_start() { LOG("%s\n", FUNCNAME); // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // resolve callbacks m_out_hrq_cb.resolve_safe(); diff --git a/src/devices/machine/mb89374.cpp b/src/devices/machine/mb89374.cpp index 32c95b38b05..561d0bf34df 100644 --- a/src/devices/machine/mb89374.cpp +++ b/src/devices/machine/mb89374.cpp @@ -129,7 +129,7 @@ mb89374_device::mb89374_device( const machine_config &mconfig, const char *tag, void mb89374_device::device_start() { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // resolve callbacks m_out_irq_cb.resolve_safe(); diff --git a/src/devices/machine/mos6526.cpp b/src/devices/machine/mos6526.cpp index 9109eedc5b5..9df653c4c5f 100644 --- a/src/devices/machine/mos6526.cpp +++ b/src/devices/machine/mos6526.cpp @@ -625,7 +625,7 @@ mos5710_device::mos5710_device(const machine_config &mconfig, const char *tag, d void mos6526_device::device_start() { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); m_flag = 1; m_cnt = 1; diff --git a/src/devices/machine/mos8726.cpp b/src/devices/machine/mos8726.cpp index f046cf5b294..0c2286788a7 100644 --- a/src/devices/machine/mos8726.cpp +++ b/src/devices/machine/mos8726.cpp @@ -57,7 +57,7 @@ mos8726_device::mos8726_device(const machine_config &mconfig, const char *tag, d void mos8726_device::device_start() { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // save state save_item(NAME(m_bs)); diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index 0ecf6b62acc..648d435ace8 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -1011,7 +1011,7 @@ void netlist_mame_cpu_device::device_start() } // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); } @@ -1041,7 +1041,7 @@ ATTR_HOT void netlist_mame_cpu_device::execute_run() { m_genPC++; m_genPC &= 255; - debugger_instruction_hook(this, m_genPC); + debugger_instruction_hook(m_genPC); netlist().process_queue(m_div); update_time_x(); } diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp index b82463a3e8e..6664e684933 100644 --- a/src/devices/sound/pokey.cpp +++ b/src/devices/sound/pokey.cpp @@ -289,16 +289,11 @@ void pokey_device::device_start() save_item(NAME(m_channel[i].m_AUDC), i); } - save_item(NAME(m_divisor)); save_item(NAME(m_clock_cnt)); save_item(NAME(m_p4)); save_item(NAME(m_p5)); save_item(NAME(m_p9)); save_item(NAME(m_p17)); - save_item(NAME(m_pot_counter)); - save_item(NAME(m_kbd_cnt)); - save_item(NAME(m_kbd_latch)); - save_item(NAME(m_kbd_state)); save_item(NAME(m_POTx)); save_item(NAME(m_AUDCTL)); @@ -311,6 +306,11 @@ void pokey_device::device_start() save_item(NAME(m_SKSTAT)); save_item(NAME(m_SKCTL)); + save_item(NAME(m_pot_counter)); + save_item(NAME(m_kbd_cnt)); + save_item(NAME(m_kbd_latch)); + save_item(NAME(m_kbd_state)); + // State support state_add(AUDF1_C, "AUDF1", m_channel[0].m_AUDF); @@ -332,8 +332,7 @@ void pokey_device::device_start() state_add(SKCTL_C, "SKCTL", m_SKCTL); // set our instruction counter - m_icountptr = &m_icount; - + set_icountptr(m_icount); } //------------------------------------------------- @@ -1271,7 +1270,6 @@ pokey_device::pokey_channel::pokey_channel() m_borrow_cnt(0), m_counter(0), m_output(0), - m_filter_sample(0), - m_div2(0) + m_filter_sample(0) { } diff --git a/src/devices/sound/pokey.h b/src/devices/sound/pokey.h index 668eb34230c..ff69c3da035 100644 --- a/src/devices/sound/pokey.h +++ b/src/devices/sound/pokey.h @@ -265,7 +265,6 @@ private: int32_t m_counter; /* channel counter */ uint8_t m_output; /* channel output signal (1 active, 0 inactive) */ uint8_t m_filter_sample; /* high-pass filter sample */ - uint8_t m_div2; /* division by 2 */ inline void sample(void) { m_filter_sample = m_output; } inline void reset_channel(void) { m_counter = m_AUDF ^ 0xff; } diff --git a/src/devices/video/mos6566.cpp b/src/devices/video/mos6566.cpp index 75997c84d27..c634491a85c 100644 --- a/src/devices/video/mos6566.cpp +++ b/src/devices/video/mos6566.cpp @@ -646,7 +646,7 @@ mos8566_device::mos8566_device(const machine_config &mconfig, const char *tag, d void mos6566_device::device_start() { // set our instruction counter - m_icountptr = &m_icount; + set_icountptr(m_icount); // resolve callbacks m_write_irq.resolve_safe(); diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index afd8884cad9..37dcdc4bc93 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -29,12 +29,6 @@ #include <fstream> -enum -{ - EXECUTION_STATE_STOPPED, - EXECUTION_STATE_RUNNING -}; - const size_t debugger_cpu::NUM_TEMP_VARIABLES = 10; /*------------------------------------------------- @@ -49,7 +43,7 @@ debugger_cpu::debugger_cpu(running_machine &machine) , m_breakcpu(nullptr) , m_symtable(nullptr) , m_vblank_occurred(false) - , m_execution_state(EXECUTION_STATE_STOPPED) + , m_execution_state(exec_state::STOPPED) , m_stop_when_not_device(nullptr) , m_bpindex(1) , m_wpindex(1) @@ -144,58 +138,10 @@ void debugger_cpu::flush_traces() /*************************************************************************** - DEBUGGING STATUS AND INFORMATION -***************************************************************************/ - -/*------------------------------------------------- - get_visible_cpu - return the visible CPU - device (the one that commands should apply to) --------------------------------------------------*/ - -device_t* debugger_cpu::get_visible_cpu() -{ - return m_visiblecpu; -} - - -/*------------------------------------------------- - within_instruction_hook - true if the debugger - is currently live --------------------------------------------------*/ - -bool debugger_cpu::within_instruction_hook() -{ - return m_within_instruction_hook; -} - - -/*------------------------------------------------- - is_stopped - return true if the - current execution state is stopped --------------------------------------------------*/ - -bool debugger_cpu::is_stopped() -{ - return m_execution_state == EXECUTION_STATE_STOPPED; -} - - -/*************************************************************************** SYMBOL TABLE INTERFACES ***************************************************************************/ /*------------------------------------------------- - get_global_symtable - return the global - symbol table --------------------------------------------------*/ - -symbol_table* debugger_cpu::get_global_symtable() -{ - return m_symtable.get(); -} - - -/*------------------------------------------------- get_visible_symtable - return the locally-visible symbol table -------------------------------------------------*/ @@ -775,7 +721,7 @@ void debugger_cpu::process_source_file() std::string buf; // loop until the file is exhausted or until we are executing again - while (m_execution_state == EXECUTION_STATE_STOPPED + while (m_execution_state == exec_state::STOPPED && m_source_file && std::getline(*m_source_file, buf)) { @@ -1372,12 +1318,12 @@ void debugger_cpu::start_hook(device_t *device, bool stop_on_vblank) if (m_stop_when_not_device != nullptr && m_stop_when_not_device != device) { m_stop_when_not_device = nullptr; - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; reset_transient_flags(); } // if we're running, do some periodic updating - if (m_execution_state != EXECUTION_STATE_STOPPED) + if (m_execution_state != exec_state::STOPPED) { if (device == m_visiblecpu && osd_ticks() > m_last_periodic_update_time + osd_ticks_per_second() / 4) { // check for periodic updates @@ -1387,7 +1333,7 @@ void debugger_cpu::start_hook(device_t *device, bool stop_on_vblank) } else if (device == m_breakcpu) { // check for pending breaks - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; m_breakcpu = nullptr; } @@ -1399,7 +1345,7 @@ void debugger_cpu::start_hook(device_t *device, bool stop_on_vblank) // if we were waiting for a VBLANK, signal it now if (stop_on_vblank) { - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; m_machine.debugger().console().printf("Stopped at VBLANK\n"); } } @@ -1435,13 +1381,13 @@ void debugger_cpu::ensure_comments_loaded() void debugger_cpu::go_next_device(device_t *device) { m_stop_when_not_device = device; - m_execution_state = EXECUTION_STATE_RUNNING; + m_execution_state = exec_state::RUNNING; } void debugger_cpu::go_vblank() { m_vblank_occurred = false; - m_execution_state = EXECUTION_STATE_RUNNING; + m_execution_state = exec_state::RUNNING; } void debugger_cpu::halt_on_next_instruction(device_t *device, util::format_argument_pack<std::ostream> &&args) @@ -1456,7 +1402,7 @@ void debugger_cpu::halt_on_next_instruction(device_t *device, util::format_argum // if we are live, stop now, otherwise note that we want to break there if (device == m_livecpu) { - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; if (m_livecpu != nullptr) m_livecpu->debug()->compute_debug_flags(); } @@ -1634,7 +1580,7 @@ void device_debug::interrupt_hook(int irqline) // see if this matches a pending interrupt request if ((m_flags & DEBUG_FLAG_STOP_INTERRUPT) != 0 && (m_stopirq == -1 || m_stopirq == irqline)) { - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_STOPPED); + m_device.machine().debugger().cpu().set_execution_stopped(); m_device.machine().debugger().console().printf("Stopped on interrupt (CPU '%s', IRQ %d)\n", m_device.tag(), irqline); compute_debug_flags(); } @@ -1651,7 +1597,7 @@ void device_debug::exception_hook(int exception) // see if this matches a pending interrupt request if ((m_flags & DEBUG_FLAG_STOP_EXCEPTION) != 0 && (m_stopexception == -1 || m_stopexception == exception)) { - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_STOPPED); + m_device.machine().debugger().cpu().set_execution_stopped(); m_device.machine().debugger().console().printf("Stopped on exception (CPU '%s', exception %d)\n", m_device.tag(), exception); compute_debug_flags(); } @@ -1690,11 +1636,11 @@ void device_debug::instruction_hook(offs_t curpc) m_trace->update(curpc); // per-instruction hook? - if (debugcpu.execution_state() != EXECUTION_STATE_STOPPED && (m_flags & DEBUG_FLAG_HOOKED) != 0 && (*m_instrhook)(m_device, curpc)) - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + if (!debugcpu.is_stopped() && (m_flags & DEBUG_FLAG_HOOKED) != 0 && (*m_instrhook)(m_device, curpc)) + debugcpu.set_execution_stopped(); // handle single stepping - if (debugcpu.execution_state() != EXECUTION_STATE_STOPPED && (m_flags & DEBUG_FLAG_STEPPING_ANY) != 0) + if (!debugcpu.is_stopped() && (m_flags & DEBUG_FLAG_STEPPING_ANY) != 0) { // is this an actual step? if (m_stepaddr == ~0 || curpc == m_stepaddr) @@ -1705,7 +1651,7 @@ void device_debug::instruction_hook(offs_t curpc) // if we hit 0, stop if (m_stepsleft == 0) - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); // update every 100 steps until we are within 200 of the end else if ((m_flags & DEBUG_FLAG_STEPPING_OUT) == 0 && (m_stepsleft < 200 || m_stepsleft % 100 == 0)) @@ -1718,20 +1664,20 @@ void device_debug::instruction_hook(offs_t curpc) } // handle breakpoints - if (debugcpu.execution_state() != EXECUTION_STATE_STOPPED && (m_flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) + if (!debugcpu.is_stopped() && (m_flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) { // see if we hit a target time if ((m_flags & DEBUG_FLAG_STOP_TIME) != 0 && machine.time() >= m_stoptime) { machine.debugger().console().printf("Stopped at time interval %.1g\n", machine.time().as_double()); - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); } // check the temp running breakpoint and break if we hit it else if ((m_flags & DEBUG_FLAG_STOP_PC) != 0 && m_stopaddr == curpc) { machine.debugger().console().printf("Stopped at temporary breakpoint %X on CPU '%s'\n", m_stopaddr, m_device.tag()); - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); } // check for execution breakpoints @@ -1740,7 +1686,7 @@ void device_debug::instruction_hook(offs_t curpc) } // if we are supposed to halt, do it now - if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + if (debugcpu.is_stopped()) { bool firststop = true; @@ -1760,7 +1706,7 @@ void device_debug::instruction_hook(offs_t curpc) // wait for the debugger; during this time, disable sound output m_device.machine().sound().debugger_mute(true); - while (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + while (debugcpu.is_stopped()) { // flush any pending updates before waiting again machine.debug_view().flush_osd_updates(); @@ -1785,7 +1731,7 @@ void device_debug::instruction_hook(offs_t curpc) // if an event got scheduled, resume if (machine.scheduled_event_pending()) - debugcpu.set_execution_state(EXECUTION_STATE_RUNNING); + debugcpu.set_execution_stopped(); } m_device.machine().sound().debugger_mute(false); @@ -1888,7 +1834,7 @@ void device_debug::single_step(int numsteps) m_stepsleft = numsteps; m_stepaddr = ~0; m_flags |= DEBUG_FLAG_STEPPING; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -1905,7 +1851,7 @@ void device_debug::single_step_over(int numsteps) m_stepsleft = numsteps; m_stepaddr = ~0; m_flags |= DEBUG_FLAG_STEPPING_OVER; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -1922,7 +1868,7 @@ void device_debug::single_step_out() m_stepsleft = 100; m_stepaddr = ~0; m_flags |= DEBUG_FLAG_STEPPING_OUT; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -1938,7 +1884,7 @@ void device_debug::go(offs_t targetpc) m_device.machine().rewind_invalidate(); m_stopaddr = targetpc; m_flags |= DEBUG_FLAG_STOP_PC; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -1968,7 +1914,7 @@ void device_debug::go_interrupt(int irqline) m_device.machine().rewind_invalidate(); m_stopirq = irqline; m_flags |= DEBUG_FLAG_STOP_INTERRUPT; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } void device_debug::go_next_device() @@ -1988,7 +1934,7 @@ void device_debug::go_exception(int exception) m_device.machine().rewind_invalidate(); m_stopexception = exception; m_flags |= DEBUG_FLAG_STOP_EXCEPTION; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -2004,7 +1950,7 @@ void device_debug::go_milliseconds(u64 milliseconds) m_device.machine().rewind_invalidate(); m_stoptime = m_device.machine().time() + attotime::from_msec(milliseconds); m_flags |= DEBUG_FLAG_STOP_TIME; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -2556,7 +2502,7 @@ void device_debug::compute_debug_flags() return; // if we're stopped, keep calling the hook - if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + if (debugcpu.is_stopped()) machine.debug_flags |= DEBUG_FLAG_CALL_HOOK; // if we're tracking history, or we're hooked, or stepping, or stopping at a breakpoint @@ -2659,14 +2605,14 @@ void device_debug::breakpoint_check(offs_t pc) if (bp->hit(pc)) { // halt in the debugger by default - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); // if we hit, evaluate the action if (!bp->m_action.empty()) m_device.machine().debugger().console().execute_command(bp->m_action, false); // print a notification, unless the action made us go again - if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + if (debugcpu.is_stopped()) m_device.machine().debugger().console().printf("Stopped at breakpoint %X\n", bp->m_index); break; } @@ -2677,7 +2623,7 @@ void device_debug::breakpoint_check(offs_t pc) if (rp->hit()) { // halt in the debugger by default - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); // if we hit, evaluate the action if (!rp->m_action.empty()) @@ -2686,7 +2632,7 @@ void device_debug::breakpoint_check(offs_t pc) } // print a notification, unless the action made us go again - if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + if (debugcpu.is_stopped()) { m_device.machine().debugger().console().printf("Stopped at registerpoint %X\n", rp->m_index); } @@ -2794,14 +2740,14 @@ void debugger_cpu::watchpoint_check(address_space& space, int type, offs_t addre if (wp->hit(type, address, size)) { // halt in the debugger by default - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; // if we hit, evaluate the action if (!wp->action().empty()) m_machine.debugger().console().execute_command(wp->action(), false); // print a notification, unless the action made us go again - if (m_execution_state == EXECUTION_STATE_STOPPED) + if (m_execution_state == exec_state::STOPPED) { static const char *const sizes[] = { diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 388e497cb0a..43384566da8 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -51,12 +51,13 @@ public: public: // construction/destruction - breakpoint(device_debug* debugInterface, - symbol_table &symbols, - int index, - offs_t address, - const char *condition = nullptr, - const char *action = nullptr); + breakpoint( + device_debug* debugInterface, + symbol_table &symbols, + int index, + offs_t address, + const char *condition = nullptr, + const char *action = nullptr); // getters const device_debug *debugInterface() const { return m_debugInterface; } @@ -90,15 +91,16 @@ public: public: // construction/destruction - watchpoint(device_debug* debugInterface, - symbol_table &symbols, - int index, - address_space &space, - int type, - offs_t address, - offs_t length, - const char *condition = nullptr, - const char *action = nullptr); + watchpoint( + device_debug* debugInterface, + symbol_table &symbols, + int index, + address_space &space, + int type, + offs_t address, + offs_t length, + const char *condition = nullptr, + const char *action = nullptr); // getters const device_debug *debugInterface() const { return m_debugInterface; } @@ -460,6 +462,8 @@ private: class debugger_cpu { public: + enum class exec_state { STOPPED, RUNNING }; + debugger_cpu(running_machine &machine); /* ----- initialization and cleanup ----- */ @@ -473,19 +477,17 @@ public: /* ----- debugging status & information ----- */ /* return the visible CPU device (the one that commands should apply to) */ - device_t *get_visible_cpu(); - - /* true if the debugger is currently stopped within an instruction hook callback */ - bool within_instruction_hook(); + device_t *get_visible_cpu() { return m_visiblecpu; } /* return true if the current execution state is stopped */ - bool is_stopped(); + bool is_stopped() const { return m_execution_state == exec_state::STOPPED; } + bool is_running() const { return m_execution_state == exec_state::RUNNING; } /* ----- symbol table interfaces ----- */ /* return the global symbol table */ - symbol_table *get_global_symtable(); + symbol_table *get_global_symtable() { return m_symtable.get(); } /* return the locally-visible symbol table */ symbol_table *get_visible_symtable(); @@ -544,7 +546,7 @@ public: // getters bool within_instruction_hook() const { return m_within_instruction_hook; } bool memory_modified() const { return m_memory_modified; } - int execution_state() const { return m_execution_state; } + exec_state execution_state() const { return m_execution_state; } device_t *live_cpu() { return m_livecpu; } u32 get_breakpoint_index() { return m_bpindex++; } u32 get_watchpoint_index() { return m_wpindex++; } @@ -555,7 +557,8 @@ public: void set_break_cpu(device_t * breakcpu) { m_breakcpu = breakcpu; } void set_within_instruction(bool within_instruction) { m_within_instruction_hook = within_instruction; } void set_memory_modified(bool memory_modified) { m_memory_modified = memory_modified; } - void set_execution_state(int execution_state) { m_execution_state = execution_state; } + void set_execution_stopped() { m_execution_state = exec_state::STOPPED; } + void set_execution_running() { m_execution_state = exec_state::RUNNING; } // device_debug helpers // [TODO] [RH]: Look into this more later, can possibly merge these two classes @@ -605,7 +608,7 @@ private: bool m_vblank_occurred; bool m_memory_modified; - int m_execution_state; + exec_state m_execution_state; device_t * m_stop_when_not_device; // stop execution when the device ceases to be this u32 m_bpindex; diff --git a/src/emu/debugger.cpp b/src/emu/debugger.cpp index de73c976dc4..b7ddea04137 100644 --- a/src/emu/debugger.cpp +++ b/src/emu/debugger.cpp @@ -23,68 +23,6 @@ static running_machine *g_machine = nullptr; static bool g_atexit_registered = false; -/*------------------------------------------------- - debugger_instruction_hook - CPU cores call - this once per instruction from CPU cores --------------------------------------------------*/ - -void debugger_instruction_hook(device_t *device, offs_t curpc) -{ -#ifndef MAME_DEBUG_FAST - if ((device->machine().debug_flags & DEBUG_FLAG_CALL_HOOK) != 0) - device->debug()->instruction_hook(curpc); -#endif -} - - -/*------------------------------------------------- - debugger_exception_hook - CPU cores call this - anytime an exception is generated --------------------------------------------------*/ - -void debugger_exception_hook(device_t *device, int exception) -{ - if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) - device->debug()->exception_hook(exception); -} - -/*------------------------------------------------- - debugger_start_cpu_hook - the CPU execution - system calls this hook before beginning - execution for the given CPU --------------------------------------------------*/ - -void debugger_start_cpu_hook(device_t *device, const attotime &endtime) -{ - if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) - device->debug()->start_hook(endtime); -} - - -/*------------------------------------------------- - debugger_stop_cpu_hook - the CPU execution - system calls this hook when ending execution - for the given CPU --------------------------------------------------*/ - -void debugger_stop_cpu_hook(device_t *device) -{ - if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) - device->debug()->stop_hook(); -} - - -/*------------------------------------------------- - debugger_interrupt_hook - the CPU execution - system calls this hook when an interrupt is - acknowledged --------------------------------------------------*/ - -void debugger_interrupt_hook(device_t *device, int irqline) -{ - if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) - device->debug()->interrupt_hook(irqline); -} /*------------------------------------------------- debug_break - stop in the debugger at the next diff --git a/src/emu/debugger.h b/src/emu/debugger.h index 91431d31631..95658eb8250 100644 --- a/src/emu/debugger.h +++ b/src/emu/debugger.h @@ -52,24 +52,4 @@ private: /* OSD can call this to safely flush all traces in the event of a crash */ void debugger_flush_all_traces_on_abnormal_exit(); - - -/*************************************************************************** - CPU CORE STATIC FUNCTIONS -***************************************************************************/ - -void debugger_instruction_hook(device_t *device, offs_t curpc); -void debugger_exception_hook(device_t *device, int exception); - - - -/*************************************************************************** - CPU EXECUTION SYSTEM STATIC FUNCTIONS -***************************************************************************/ - -void debugger_start_cpu_hook(device_t *device, const attotime &endtime); -void debugger_stop_cpu_hook(device_t *device); -void debugger_interrupt_hook(device_t *device, int irqline); - - #endif // MAME_EMU_DEBUGGER_H diff --git a/src/emu/devcpu.h b/src/emu/devcpu.h index 3a9f218776b..8d73127e1f7 100644 --- a/src/emu/devcpu.h +++ b/src/emu/devcpu.h @@ -7,17 +7,14 @@ CPU device definitions. ***************************************************************************/ - -#pragma once - -#ifndef __EMU_H__ -#error Dont include this file directly; include emu.h instead. -#endif - #ifndef MAME_EMU_DEVCPU_H #define MAME_EMU_DEVCPU_H +#pragma once + #include "didisasm.h" +#include "diexec.h" + //************************************************************************** // CPU DEVICE CONFIGURATION MACROS @@ -47,7 +44,7 @@ // recompilation parameters #define MCFG_CPU_FORCE_NO_DRC() \ - dynamic_cast<cpu_device &>(*device).set_force_no_drc(true); + dynamic_cast<cpu_device &>(*device).set_force_no_drc(true); @@ -64,6 +61,8 @@ class cpu_device : public device_t, public device_disasm_interface { public: + virtual ~cpu_device(); + // configuration helpers void set_force_no_drc(bool value) { m_force_no_drc = value; } bool allow_drc() const; @@ -71,12 +70,10 @@ public: protected: // construction/destruction cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); - virtual ~cpu_device(); private: // configured state bool m_force_no_drc; // whether or not to force DRC off }; - -#endif /* MAME_EMU_DEVCPU_H */ +#endif // MAME_EMU_DEVCPU_H diff --git a/src/emu/didisasm.h b/src/emu/didisasm.h index 53a078c3492..407fb69f399 100644 --- a/src/emu/didisasm.h +++ b/src/emu/didisasm.h @@ -59,4 +59,4 @@ private: // iterator typedef device_interface_iterator<device_disasm_interface> disasm_interface_iterator; -#endif // MAME_EMU_DIDISASM_H +#endif // MAME_EMU_DIDISASM_H diff --git a/src/emu/diexec.cpp b/src/emu/diexec.cpp index d6885201a66..6b6964dbb0d 100644 --- a/src/emu/diexec.cpp +++ b/src/emu/diexec.cpp @@ -43,31 +43,33 @@ const int TRIGGER_SUSPENDTIME = -4000; //------------------------------------------------- device_execute_interface::device_execute_interface(const machine_config &mconfig, device_t &device) - : device_interface(device, "execute"), - m_disabled(false), - m_vblank_interrupt_screen(nullptr), - m_timed_interrupt_period(attotime::zero), - m_nextexec(nullptr), - m_timedint_timer(nullptr), - m_profiler(PROFILER_IDLE), - m_icountptr(nullptr), - m_cycles_running(0), - m_cycles_stolen(0), - m_suspend(0), - m_nextsuspend(0), - m_eatcycles(0), - m_nexteatcycles(0), - m_trigger(0), - m_inttrigger(0), - m_totalcycles(0), - m_divisor(0), - m_divshift(0), - m_cycles_per_second(0), - m_attoseconds_per_cycle(0) + : device_interface(device, "execute") + , m_scheduler(nullptr) + , m_disabled(false) + , m_vblank_interrupt_screen(nullptr) + , m_timed_interrupt_period(attotime::zero) + , m_nextexec(nullptr) + , m_timedint_timer(nullptr) + , m_profiler(PROFILER_IDLE) + , m_icountptr(nullptr) + , m_cycles_running(0) + , m_cycles_stolen(0) + , m_suspend(0) + , m_nextsuspend(0) + , m_eatcycles(0) + , m_nexteatcycles(0) + , m_trigger(0) + , m_inttrigger(0) + , m_totalcycles(0) + , m_divisor(0) + , m_divshift(0) + , m_cycles_per_second(0) + , m_attoseconds_per_cycle(0) { memset(&m_localtime, 0, sizeof(m_localtime)); // configure the fast accessor + assert(!device.interfaces().m_execute); device.interfaces().m_execute = this; } @@ -82,62 +84,6 @@ device_execute_interface::~device_execute_interface() //------------------------------------------------- -// executing - return true if this device is -// within its execute function -//------------------------------------------------- - -bool device_execute_interface::executing() const -{ - return (this == m_scheduler->currently_executing()); -} - - -//------------------------------------------------- -// cycles_remaining - return the number of cycles -// remaining in this timeslice -//------------------------------------------------- - -s32 device_execute_interface::cycles_remaining() const -{ - return executing() ? *m_icountptr : 0; -} - - -//------------------------------------------------- -// eat_cycles - safely eats cycles so we don't -// cross a timeslice boundary -//------------------------------------------------- - -void device_execute_interface::eat_cycles(int cycles) -{ - // ignore if not the executing device - if (!executing()) - return; - - // clamp cycles to the icount and update - if (cycles > *m_icountptr) - cycles = *m_icountptr; - *m_icountptr -= cycles; -} - - -//------------------------------------------------- -// adjust_icount - apply a +/- to the current -// icount -//------------------------------------------------- - -void device_execute_interface::adjust_icount(int delta) -{ - // ignore if not the executing device - if (!executing()) - return; - - // apply the delta directly - *m_icountptr += delta; -} - - -//------------------------------------------------- // abort_timeslice - abort execution for the // current timeslice, allowing other devices to // run before we run again @@ -419,7 +365,7 @@ void device_execute_interface::interface_pre_start() m_driver_irq.bind_relative_to(*device().owner()); // fill in the initial states - int index = device_iterator(device().machine().root_device()).indexof(*this); + int const index = device_iterator(device().machine().root_device()).indexof(*this); m_suspend = SUSPEND_REASON_RESET; m_profiler = profile_type(index + PROFILER_DEVICE_FIRST); m_inttrigger = index + TRIGGER_INT; @@ -438,7 +384,8 @@ void device_execute_interface::interface_pre_start() void device_execute_interface::interface_post_start() { // make sure somebody set us up the icount - assert_always(m_icountptr != nullptr, "m_icountptr never initialized!"); + if (!m_icountptr) + throw emu_fatalerror("m_icountptr never initialized!"); // register for save states device().save_item(NAME(m_suspend)); @@ -561,10 +508,10 @@ int device_execute_interface::standard_irq_callback(int irqline) // if there's a driver callback, run it to get the vector if (!m_driver_irq.isnull()) - vector = m_driver_irq(device(),irqline); + vector = m_driver_irq(device(), irqline); // notify the debugger - debugger_interrupt_hook(&device(), irqline); + debugger_interrupt_hook(irqline); return vector; } @@ -591,17 +538,6 @@ attoseconds_t device_execute_interface::minimum_quantum() const //------------------------------------------------- -// static_timed_trigger_callback - signal a timed -// trigger -//------------------------------------------------- - -TIMER_CALLBACK_MEMBER( device_execute_interface::timed_trigger_callback ) -{ - trigger(param); -} - - -//------------------------------------------------- // on_vblank - calls any external callbacks // for this screen //------------------------------------------------- @@ -638,17 +574,6 @@ TIMER_CALLBACK_MEMBER(device_execute_interface::trigger_periodic_interrupt) //------------------------------------------------- -// irq_pulse_clear - clear a "pulsed" input line -//------------------------------------------------- - -TIMER_CALLBACK_MEMBER(device_execute_interface::irq_pulse_clear) -{ - int irqline = param; - set_input_line(irqline, CLEAR_LINE); -} - - -//------------------------------------------------- // pulse_input_line - "pulse" an input line by // asserting it and then clearing it later //------------------------------------------------- @@ -689,14 +614,14 @@ void device_execute_interface::pulse_input_line_and_vector(int irqline, int vect //------------------------------------------------- device_execute_interface::device_input::device_input() - : m_execute(nullptr), - m_linenum(0), - m_stored_vector(0), - m_curvector(0), - m_curstate(CLEAR_LINE), - m_qindex(0) + : m_execute(nullptr) + , m_linenum(0) + , m_stored_vector(0) + , m_curvector(0) + , m_curstate(CLEAR_LINE) + , m_qindex(0) { - memset(m_queue, 0, sizeof(m_queue)); + std::fill(std::begin(m_queue), std::end(m_queue), 0); } @@ -862,7 +787,7 @@ if (TEMPLOG) printf(" (%d,%d)\n", m_curstate, m_curvector); int device_execute_interface::device_input::default_irq_callback() { - int vector = m_curvector; + int const vector = m_curvector; // if the IRQ state is HOLD_LINE, clear it if (m_curstate == HOLD_LINE) diff --git a/src/emu/diexec.h b/src/emu/diexec.h index ded5a024d06..eb99b8241c8 100644 --- a/src/emu/diexec.h +++ b/src/emu/diexec.h @@ -7,15 +7,12 @@ Device execution interfaces. ***************************************************************************/ +#ifndef MAME_EMU_DIEXEC_H +#define MAME_EMU_DIEXEC_H #pragma once -#ifndef __EMU_H__ -#error Dont include this file directly; include emu.h instead. -#endif - -#ifndef MAME_EMU_DIEXEC_H -#define MAME_EMU_DIEXEC_H +#include "debug/debugcpu.h" //************************************************************************** @@ -71,8 +68,6 @@ enum // MACROS //************************************************************************** -#define TIMER_CALLBACK_MEMBER(name) void name(void *ptr, s32 param) - // IRQ callback to be called by device implementations when an IRQ is actually taken #define IRQ_CALLBACK_MEMBER(func) int func(device_t &device, int irqline) @@ -159,10 +154,10 @@ public: // execution management device_scheduler &scheduler() const { assert(m_scheduler != nullptr); return *m_scheduler; } - bool executing() const; - s32 cycles_remaining() const; - void eat_cycles(int cycles); - void adjust_icount(int delta); + bool executing() const { return scheduler().currently_executing() == this; } + s32 cycles_remaining() const { return executing() ? *m_icountptr : 0; } // cycles remaining in this timeslice + void eat_cycles(int cycles) { if (executing()) *m_icountptr = (cycles > *m_icountptr) ? 0 : (*m_icountptr - cycles); } + void adjust_icount(int delta) { if (executing()) *m_icountptr += delta; } void abort_timeslice(); // input and interrupt management @@ -224,9 +219,29 @@ protected: virtual void interface_clock_changed() override; // for use by devcpu for now... + int current_input_state(unsigned i) const { return m_input[i].m_curstate; } + void set_icountptr(int &icount) { assert(!m_icountptr); m_icountptr = &icount; } IRQ_CALLBACK_MEMBER(standard_irq_callback_member); int standard_irq_callback(int irqline); + // debugger hooks + void debugger_instruction_hook(offs_t curpc) + { + if (device().machine().debug_flags & DEBUG_FLAG_CALL_HOOK) + device().debug()->instruction_hook(curpc); + } + void debugger_exception_hook(int exception) + { + if (device().machine().debug_flags & DEBUG_FLAG_ENABLED) + device().debug()->exception_hook(exception); + } + void debugger_interrupt_hook(int irqline) + { + if (device().machine().debug_flags & DEBUG_FLAG_ENABLED) + device().debug()->interrupt_hook(irqline); + } + +private: // internal information about the state of inputs class device_input { @@ -255,6 +270,18 @@ protected: TIMER_CALLBACK_MEMBER(empty_event_queue); }; + // internal debugger hooks + void debugger_start_cpu_hook(const attotime &endtime) + { + if (device().machine().debug_flags & DEBUG_FLAG_ENABLED) + device().debug()->start_hook(endtime); + } + void debugger_stop_cpu_hook() + { + if (device().machine().debug_flags & DEBUG_FLAG_ENABLED) + device().debug()->stop_hook(); + } + // scheduler device_scheduler * m_scheduler; // pointer to the machine scheduler @@ -288,21 +315,22 @@ protected: s32 m_inttrigger; // interrupt trigger index // clock and timing information +protected: // FIXME: MIPS3 accesses m_totalcycles directly from execute_burn - devise a better solution u64 m_totalcycles; // total device cycles executed +private: attotime m_localtime; // local time, relative to the timer system's global time s32 m_divisor; // 32-bit attoseconds_per_cycle divisor u8 m_divshift; // right shift amount to fit the divisor into 32 bits u32 m_cycles_per_second; // cycles per second, adjusted for multipliers attoseconds_t m_attoseconds_per_cycle; // attoseconds per adjusted clock cycle -private: // callbacks - TIMER_CALLBACK_MEMBER(timed_trigger_callback); + TIMER_CALLBACK_MEMBER(timed_trigger_callback) { trigger(param); } void on_vblank(screen_device &screen, bool vblank_state); TIMER_CALLBACK_MEMBER(trigger_periodic_interrupt); - TIMER_CALLBACK_MEMBER(irq_pulse_clear); + TIMER_CALLBACK_MEMBER(irq_pulse_clear) { set_input_line(int(param), CLEAR_LINE); } void suspend_resume_changed(); attoseconds_t minimum_quantum() const; @@ -314,5 +342,4 @@ public: // iterator typedef device_interface_iterator<device_execute_interface> execute_interface_iterator; - -#endif /* MAME_EMU_DIEXEC_H */ +#endif // MAME_EMU_DIEXEC_H diff --git a/src/emu/diserial.h b/src/emu/diserial.h index 553385f76f3..924ffb08824 100644 --- a/src/emu/diserial.h +++ b/src/emu/diserial.h @@ -1,14 +1,10 @@ // license:BSD-3-Clause // copyright-holders:Carl, Miodrag Milanovic, Vas Crabb -#pragma once - -#ifndef __EMU_H__ -#error Dont include this file directly; include emu.h instead. -#endif - #ifndef MAME_EMU_DISERIAL_H #define MAME_EMU_DISERIAL_H +#pragma once + // Windows headers are crap, let me count the ways #undef PARITY_NONE #undef PARITY_ODD @@ -262,4 +258,4 @@ private: u8 m_empty = 1U; }; -#endif // MAME_EMU_DISERIAL_H +#endif // MAME_EMU_DISERIAL_H diff --git a/src/emu/driver.h b/src/emu/driver.h index 88b57b8efc4..d4216325ce7 100644 --- a/src/emu/driver.h +++ b/src/emu/driver.h @@ -130,32 +130,32 @@ public: // output heler output_manager &output() const { return machine().output(); } - INTERRUPT_GEN_MEMBER( nmi_line_pulse ); - INTERRUPT_GEN_MEMBER( nmi_line_assert ); + void nmi_line_pulse(device_t &device); + void nmi_line_assert(device_t &device); - INTERRUPT_GEN_MEMBER( irq0_line_hold ); - INTERRUPT_GEN_MEMBER( irq0_line_assert ); + void irq0_line_hold(device_t &device); + void irq0_line_assert(device_t &device); - INTERRUPT_GEN_MEMBER( irq1_line_hold ); - INTERRUPT_GEN_MEMBER( irq1_line_assert ); + void irq1_line_hold(device_t &device); + void irq1_line_assert(device_t &device); - INTERRUPT_GEN_MEMBER( irq2_line_hold ); - INTERRUPT_GEN_MEMBER( irq2_line_assert ); + void irq2_line_hold(device_t &device); + void irq2_line_assert(device_t &device); - INTERRUPT_GEN_MEMBER( irq3_line_hold ); - INTERRUPT_GEN_MEMBER( irq3_line_assert ); + void irq3_line_hold(device_t &device); + void irq3_line_assert(device_t &device); - INTERRUPT_GEN_MEMBER( irq4_line_hold ); - INTERRUPT_GEN_MEMBER( irq4_line_assert ); + void irq4_line_hold(device_t &device); + void irq4_line_assert(device_t &device); - INTERRUPT_GEN_MEMBER( irq5_line_hold ); - INTERRUPT_GEN_MEMBER( irq5_line_assert ); + void irq5_line_hold(device_t &device); + void irq5_line_assert(device_t &device); - INTERRUPT_GEN_MEMBER( irq6_line_hold ); - INTERRUPT_GEN_MEMBER( irq6_line_assert ); + void irq6_line_hold(device_t &device); + void irq6_line_assert(device_t &device); - INTERRUPT_GEN_MEMBER( irq7_line_hold ); - INTERRUPT_GEN_MEMBER( irq7_line_assert ); + void irq7_line_hold(device_t &device); + void irq7_line_assert(device_t &device); // generic input port helpers diff --git a/src/emu/emu.h b/src/emu/emu.h index 630a6af1951..a1f72c051f3 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -68,12 +68,10 @@ class address_map; // Forward declaration #include "distate.h" #include "dimemory.h" #include "dirom.h" -#include "diexec.h" #include "opresolv.h" #include "dipalette.h" #include "digfx.h" #include "diimage.h" -#include "diserial.h" #include "dislot.h" #include "disound.h" #include "divideo.h" @@ -86,14 +84,16 @@ class address_map; // Forward declaration #include "gamedrv.h" #include "parameters.h" -// timers, CPU and scheduling -#include "devcpu.h" - // the running machine #include "main.h" #include "machine.h" #include "driver.h" +// common device interfaces +#include "diexec.h" +#include "diserial.h" +#include "devcpu.h" + // video-related #include "drawgfx.h" #include "emupal.h" diff --git a/src/emu/emucore.cpp b/src/emu/emucore.cpp index 26c23ac19fe..1dbc5446d55 100644 --- a/src/emu/emucore.cpp +++ b/src/emu/emucore.cpp @@ -12,8 +12,7 @@ #include "emucore.h" #include "osdcore.h" -emu_fatalerror::emu_fatalerror(const char *format, ...) -: code(0) +emu_fatalerror::emu_fatalerror(const char *format, ...) : code(0) { if (format == nullptr) { @@ -29,8 +28,7 @@ emu_fatalerror::emu_fatalerror(const char *format, ...) osd_break_into_debugger(text); } -emu_fatalerror::emu_fatalerror(const char *format, va_list ap) -: code(0) +emu_fatalerror::emu_fatalerror(const char *format, va_list ap) : code(0) { if (format == nullptr) { @@ -43,8 +41,7 @@ emu_fatalerror::emu_fatalerror(const char *format, va_list ap) osd_break_into_debugger(text); } -emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, ...) -: code(_exitcode) +emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, ...) : code(_exitcode) { if (format == nullptr) { @@ -59,8 +56,7 @@ emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, ...) } } -emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, va_list ap) -: code(_exitcode) +emu_fatalerror::emu_fatalerror(int _exitcode, const char *format, va_list ap) : code(_exitcode) { if (format == nullptr) { diff --git a/src/emu/emufwd.h b/src/emu/emufwd.h index 2293474574e..20330d3c84d 100644 --- a/src/emu/emufwd.h +++ b/src/emu/emufwd.h @@ -108,6 +108,9 @@ class finder_base; class device_interface; class device_t; +// declared in didisasm.h +class device_disasm_interface; + // declared in diexec.h class device_execute_interface; diff --git a/src/emu/schedule.cpp b/src/emu/schedule.cpp index cc97a696a78..42552f5f5de 100644 --- a/src/emu/schedule.cpp +++ b/src/emu/schedule.cpp @@ -481,9 +481,9 @@ void device_scheduler::timeslice() exec->run(); else { - debugger_start_cpu_hook(&exec->device(), target); + exec->debugger_start_cpu_hook(target); exec->run(); - debugger_stop_cpu_hook(&exec->device()); + exec->debugger_stop_cpu_hook(); } // adjust for any cycles we took back diff --git a/src/emu/schedule.h b/src/emu/schedule.h index de50fe5e4f5..fea68690360 100644 --- a/src/emu/schedule.h +++ b/src/emu/schedule.h @@ -22,6 +22,8 @@ // MACROS //************************************************************************** +#define TIMER_CALLBACK_MEMBER(name) void name(void *ptr, s32 param) + // macro for the RC time constant on a 74LS123 with C > 1000pF // R is in ohms, C is in farads #define TIME_OF_74LS123(r,c) (0.45 * (double)(r) * (double)(c)) diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index fe9bdc553ea..0711f5efc2d 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -1231,16 +1231,13 @@ void lua_engine::initialize() "visible_cpu", sol::property([](debugger_manager &debug) { debug.cpu().get_visible_cpu(); }, [](debugger_manager &debug, device_t &dev) { debug.cpu().set_visible_cpu(&dev); }), "execution_state", sol::property([](debugger_manager &debug) { - int execstate = debug.cpu().execution_state(); - if(execstate == 0) - return "stop"; - return "run"; + return debug.cpu().is_stopped() ? "stop" : "run"; }, [](debugger_manager &debug, const std::string &state) { - int execstate = 1; if(state == "stop") - execstate = 0; - debug.cpu().set_execution_state(execstate); + debug.cpu().set_execution_stopped(); + else + debug.cpu().set_execution_running(); })); sol().registry().new_usertype<wrap_textbuf>("text_buffer", "new", sol::no_constructor, diff --git a/src/mame/drivers/vgmplay.cpp b/src/mame/drivers/vgmplay.cpp index e2f3916a9e1..77431d11932 100644 --- a/src/mame/drivers/vgmplay.cpp +++ b/src/mame/drivers/vgmplay.cpp @@ -253,7 +253,7 @@ vgmplay_device::vgmplay_device(const machine_config &mconfig, const char *tag, d void vgmplay_device::device_start() { - m_icountptr = &m_icount; + set_icountptr(m_icount); m_file = &space(AS_PROGRAM); m_io = &space(AS_IO); m_io16 = &space(AS_IO16); @@ -356,7 +356,7 @@ void vgmplay_device::execute_run() } case RUN: { if(machine().debug_flags & DEBUG_FLAG_ENABLED) - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); uint8_t code = m_file->read_byte(m_pc); switch(code) { case 0x4f: @@ -641,7 +641,7 @@ void vgmplay_device::execute_run() done = true; } if(machine().debug_flags & DEBUG_FLAG_ENABLED) - debugger_instruction_hook(this, m_pc); + debugger_instruction_hook(m_pc); m_icount = 0; break; } diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp index 5d8044573ed..72c6f01d876 100644 --- a/src/tools/unidasm.cpp +++ b/src/tools/unidasm.cpp @@ -10,9 +10,6 @@ #include "emu.h" -#include <algorithm> -#include <cstring> - #include <ctype.h> #include "cpu/8x300/8x300dasm.h" @@ -150,6 +147,10 @@ #include "cpu/z80/z80dasm.h" #include "cpu/z8000/8000dasm.h" +#include <algorithm> +#include <cstring> +#include <stdexcept> + // Configuration classes // Selected through dasm name @@ -532,7 +533,7 @@ unidasm_data_buffer::unidasm_data_buffer(util::disasm_interface *_disasm, const if(flags & util::disasm_interface::NONLINEAR_PC) { switch(entry->pcshift) { case -1: - lr8 = [](offs_t pc) -> u8 { throw emu_fatalerror("debug_disasm_buffer::debug_data_buffer: r8 access on 16-bits granularity bus\n"); }; + lr8 = [](offs_t pc) -> u8 { throw std::logic_error("debug_disasm_buffer::debug_data_buffer: r8 access on 16-bits granularity bus\n"); }; lr16 = [this](offs_t pc) -> u16 { const u16 *src = get_ptr<u16>(pc); return src[0]; |