diff options
-rw-r--r-- | docs/m6502.txt | 14 | ||||
-rw-r--r-- | src/emu/cpu/h8/h8.c | 21 | ||||
-rw-r--r-- | src/emu/cpu/h8/h8.h | 2 | ||||
-rw-r--r-- | src/emu/cpu/h8/h8_adc.c | 2 | ||||
-rw-r--r-- | src/emu/cpu/h8/h8_sci.c | 6 | ||||
-rw-r--r-- | src/emu/cpu/h8/h8_timer16.c | 6 | ||||
-rw-r--r-- | src/emu/cpu/h8/h8_timer8.c | 4 | ||||
-rw-r--r-- | src/emu/cpu/m6502/m6502.c | 13 | ||||
-rw-r--r-- | src/emu/cpu/m6502/m6502.h | 2 | ||||
-rw-r--r-- | src/emu/cpu/m6502/m740.c | 1 | ||||
-rw-r--r-- | src/emu/cpu/mcs96/i8x9x.c | 18 | ||||
-rw-r--r-- | src/emu/cpu/mcs96/mcs96.c | 23 | ||||
-rw-r--r-- | src/emu/cpu/mcs96/mcs96.h | 3 |
13 files changed, 38 insertions, 77 deletions
diff --git a/docs/m6502.txt b/docs/m6502.txt index 56e761ebf5a..2a45a3e172e 100644 --- a/docs/m6502.txt +++ b/docs/m6502.txt @@ -95,13 +95,13 @@ everything goes through normal memory-map read/write calls. The state of the sync line is given by the cpu method get_sync(), making implementing the decryption in the handler possible. -In a final addition, the cpu method get_cycle() gives the current time -in cycles since the start of the machine from the point of view of the -cpu. Or, in other words, what is usually called the cycle number for -the cpu when somebody talks about bus contention or wait states. The -call is designed to be fast (no system-wide sync, usually no call to -machine.time()) and is precise. Cycle number for every access is -exact at the sub-instruction level. +Also, as for every executable device, the cpu method total_cycles() +gives the current time in cycles since the start of the machine from +the point of view of the cpu. Or, in other words, what is usually +called the cycle number for the cpu when somebody talks about bus +contention or wait states. The call is designed to be fast (no +system-wide sync, no call to machine.time()) and is precise. Cycle +number for every access is exact at the sub-instruction level. The 4510 special nomap line is accessible through get_nomap(). diff --git a/src/emu/cpu/h8/h8.c b/src/emu/cpu/h8/h8.c index 3c7b7724df6..98700187240 100644 --- a/src/emu/cpu/h8/h8.c +++ b/src/emu/cpu/h8/h8.c @@ -130,14 +130,12 @@ void h8_device::device_start() MACF = 0; inst_state = STATE_RESET; inst_substate = 0; - end_cycles = 0; } void h8_device::device_reset() { inst_state = STATE_RESET; inst_substate = 0; - end_cycles = 0; irq_vector = 0; irq_level = -1; @@ -162,26 +160,18 @@ UINT32 h8_device::execute_input_lines() const return 0; } -UINT64 h8_device::get_cycle() -{ - return end_cycles == 0 || icount <= 0 ? machine().time().as_ticks(clock()) : end_cycles - icount; -} - void h8_device::recompute_bcount(UINT64 event_time) { - if(!event_time || event_time >= end_cycles) { + if(!event_time || event_time >= total_cycles() + icount) { bcount = 0; return; } - bcount = end_cycles - event_time; + bcount = total_cycles() - event_time; } void h8_device::execute_run() { - start_cycles = machine().time().as_ticks(clock()); - end_cycles = start_cycles + icount; - - internal_update(start_cycles); + internal_update(total_cycles()); if(inst_substate) do_exec_partial(); @@ -196,11 +186,10 @@ void h8_device::execute_run() do_exec_full(); } while(bcount && icount && icount <= bcount) - internal_update(end_cycles - bcount); + internal_update(total_cycles() + icount - bcount); if(inst_substate) do_exec_partial(); } - end_cycles = 0; } void h8_device::add_event(UINT64 &event_time, UINT64 new_event) @@ -213,7 +202,7 @@ void h8_device::add_event(UINT64 &event_time, UINT64 new_event) void h8_device::internal_update() { - internal_update(get_cycle()); + internal_update(total_cycles()); } const address_space_config *h8_device::memory_space_config(address_spacenum spacenum) const diff --git a/src/emu/cpu/h8/h8.h b/src/emu/cpu/h8/h8.h index 38d8b3b9561..0997e37067f 100644 --- a/src/emu/cpu/h8/h8.h +++ b/src/emu/cpu/h8/h8.h @@ -76,7 +76,6 @@ public: h8_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, bool mode_a16, address_map_delegate map_delegate); - UINT64 get_cycle(); void internal_update(); void set_irq(int irq_vector, int irq_level, bool irq_nmi); @@ -214,7 +213,6 @@ protected: int inst_state, inst_substate; int icount, bcount; - UINT64 start_cycles, end_cycles; int irq_vector, taken_irq_vector; int irq_level, taken_irq_level; bool irq_required, irq_nmi; diff --git a/src/emu/cpu/h8/h8_adc.c b/src/emu/cpu/h8/h8_adc.c index 1c52bcb200f..5925bf7e5fb 100644 --- a/src/emu/cpu/h8/h8_adc.c +++ b/src/emu/cpu/h8/h8_adc.c @@ -152,7 +152,7 @@ void h8_adc_device::conversion_wait(bool first, bool poweron, UINT64 current_tim if(current_time) next_event = current_time + conversion_time(first, poweron); else { - next_event = cpu->get_cycle() + conversion_time(first, poweron); + next_event = cpu->total_cycles() + conversion_time(first, poweron); cpu->internal_update(); } } diff --git a/src/emu/cpu/h8/h8_sci.c b/src/emu/cpu/h8/h8_sci.c index d35200158a6..d1e5402c3a1 100644 --- a/src/emu/cpu/h8/h8_sci.c +++ b/src/emu/cpu/h8/h8_sci.c @@ -461,19 +461,19 @@ void h8_sci_device::clock_start(int mode) case CLKM_INTERNAL_ASYNC_OUT: case CLKM_INTERNAL_SYNC_OUT: logerror("%s: Starting internal clock\n", tag()); - clock_base = cpu->get_cycle(); + clock_base = cpu->total_cycles(); cpu->internal_update(); break; case CLKM_EXTERNAL_RATE_ASYNC: logerror("%s: Simulating external clock async\n", tag()); - clock_base = UINT64(cpu->get_cycle()*internal_to_external_ratio); + clock_base = UINT64(cpu->total_cycles()*internal_to_external_ratio); cpu->internal_update(); break; case CLKM_EXTERNAL_RATE_SYNC: logerror("%s: Simulating external clock sync\n", tag()); - clock_base = UINT64(cpu->get_cycle()*2*internal_to_external_ratio); + clock_base = UINT64(cpu->total_cycles()*2*internal_to_external_ratio); cpu->internal_update(); break; diff --git a/src/emu/cpu/h8/h8_timer16.c b/src/emu/cpu/h8/h8_timer16.c index 12baf41c369..251910d9c2e 100644 --- a/src/emu/cpu/h8/h8_timer16.c +++ b/src/emu/cpu/h8/h8_timer16.c @@ -199,7 +199,7 @@ void h8_timer16_channel_device::update_counter(UINT64 cur_time) return; if(!cur_time) - cur_time = cpu->get_cycle(); + cur_time = cpu->total_cycles(); if(!channel_active) { last_clock_update = cur_time; @@ -257,7 +257,7 @@ void h8_timer16_channel_device::recalc_event(UINT64 cur_time) } if(!cur_time) - cur_time = cpu->get_cycle(); + cur_time = cpu->total_cycles(); if(counter_incrementing) { UINT32 event_delay = 0xffffffff; @@ -297,7 +297,7 @@ void h8_timer16_channel_device::recalc_event(UINT64 cur_time) event_time = 0; if(event_time && 0) - logerror("%s: next event in %d cycles (%ld)\n", tag(), int(event_time - cpu->get_cycle()), long(event_time)); + logerror("%s: next event in %d cycles (%ld)\n", tag(), int(event_time - cpu->total_cycles()), long(event_time)); } else { logerror("decrementing counter\n"); diff --git a/src/emu/cpu/h8/h8_timer8.c b/src/emu/cpu/h8/h8_timer8.c index cdec9256e0f..b6e0d478a3b 100644 --- a/src/emu/cpu/h8/h8_timer8.c +++ b/src/emu/cpu/h8/h8_timer8.c @@ -212,7 +212,7 @@ void h8_timer8_channel_device::update_counter(UINT64 cur_time) return; if(!cur_time) - cur_time = cpu->get_cycle(); + cur_time = cpu->total_cycles(); UINT64 base_time = (last_clock_update + clock_divider/2) / clock_divider; UINT64 new_time = (cur_time + clock_divider/2) / clock_divider; @@ -262,7 +262,7 @@ void h8_timer8_channel_device::recalc_event(UINT64 cur_time) } if(!cur_time) - cur_time = cpu->get_cycle(); + cur_time = cpu->total_cycles(); UINT32 event_delay = 0xffffffff; if(clear_type == CLEAR_A || clear_type == CLEAR_B) diff --git a/src/emu/cpu/m6502/m6502.c b/src/emu/cpu/m6502/m6502.c index 4a2d001142f..062560cdbc8 100644 --- a/src/emu/cpu/m6502/m6502.c +++ b/src/emu/cpu/m6502/m6502.c @@ -129,7 +129,6 @@ void m6502_device::init() inst_substate = 0; inst_state_base = 0; sync = false; - end_cycles = 0; inhibit_interrupts = false; } @@ -143,7 +142,6 @@ void m6502_device::device_reset() apu_irq_state = false; irq_taken = false; v_state = false; - end_cycles = 0; sync = false; sync_w(CLEAR_LINE); inhibit_interrupts = false; @@ -400,18 +398,8 @@ UINT8 m6502_device::do_asr(UINT8 v) return v; } -UINT64 m6502_device::get_cycle() -{ - return end_cycles == 0 || icount <= 0 ? machine().time().as_ticks(clock()) : end_cycles - icount; -} - void m6502_device::execute_run() { - // get_cycle() is currently unused, and this precalculation - // enormously slows down drivers with high interleave -#if 0 - end_cycles = machine().time().as_ticks(clock()) + icount; -#endif if(inst_substate) do_exec_partial(); @@ -424,7 +412,6 @@ void m6502_device::execute_run() } do_exec_full(); } - end_cycles = 0; } void m6502_device::execute_set_input(int inputnum, int state) diff --git a/src/emu/cpu/m6502/m6502.h b/src/emu/cpu/m6502/m6502.h index b433c72f9e5..f77a33f6ae8 100644 --- a/src/emu/cpu/m6502/m6502.h +++ b/src/emu/cpu/m6502/m6502.h @@ -61,7 +61,6 @@ public: DECLARE_WRITE_LINE_MEMBER( irq_line ); DECLARE_WRITE_LINE_MEMBER( nmi_line ); - UINT64 get_cycle(); bool get_sync() const { return sync; } void disable_direct() { direct_disabled = true; } @@ -201,7 +200,6 @@ protected: int icount; bool nmi_state, irq_state, apu_irq_state, v_state; bool irq_taken, sync, direct_disabled, inhibit_interrupts; - UINT64 end_cycles; static const disasm_entry disasm_entries[0x100]; diff --git a/src/emu/cpu/m6502/m740.c b/src/emu/cpu/m6502/m740.c index 230ff737ecd..fb1662b49ef 100644 --- a/src/emu/cpu/m6502/m740.c +++ b/src/emu/cpu/m6502/m740.c @@ -77,7 +77,6 @@ void m740_device::device_reset() apu_irq_state = false; irq_taken = false; v_state = false; - end_cycles = 0; sync = false; inhibit_interrupts = false; SP = 0x00ff; diff --git a/src/emu/cpu/mcs96/i8x9x.c b/src/emu/cpu/mcs96/i8x9x.c index 1342b394aa0..e86fa598248 100644 --- a/src/emu/cpu/mcs96/i8x9x.c +++ b/src/emu/cpu/mcs96/i8x9x.c @@ -87,7 +87,7 @@ void i8x9x_device::commit_hso_cam() hso_info[i].active = true; hso_info[i].command = hso_command; hso_info[i].time = hso_time; - internal_update(get_cycle()); + internal_update(total_cycles()); return; } hso_cam_hold.active = true; @@ -105,7 +105,7 @@ void i8x9x_device::ad_start(UINT64 current_time) void i8x9x_device::serial_send(UINT8 data) { serial_send_buf = data; - serial_send_timer = get_cycle() + 9600; + serial_send_timer = total_cycles() + 9600; } void i8x9x_device::serial_send_done() @@ -123,7 +123,7 @@ void i8x9x_device::io_w8(UINT8 adr, UINT8 data) case 0x02: ad_command = data; if(ad_command & 8) - ad_start(get_cycle()); + ad_start(total_cycles()); break; case 0x03: logerror("%s: hsi_mode %02x (%04x)\n", tag(), data, PPC); @@ -229,16 +229,16 @@ UINT8 i8x9x_device::io_r8(UINT8 adr) return pending_irq; case 0x0a: logerror("%s: read timer1 l (%04x)\n", tag(), PPC); - return timer_value(1, get_cycle()); + return timer_value(1, total_cycles()); case 0x0b: logerror("%s: read timer1 h (%04x)\n", tag(), PPC); - return timer_value(1, get_cycle()) >> 8; + return timer_value(1, total_cycles()) >> 8; case 0x0c: logerror("%s: read timer2 l (%04x)\n", tag(), PPC); - return timer_value(2, get_cycle()); + return timer_value(2, total_cycles()); case 0x0d: logerror("%s: read timer2 h (%04x)\n", tag(), PPC); - return timer_value(2, get_cycle()) >> 8; + return timer_value(2, total_cycles()) >> 8; case 0x0e: { static int last = -1; if(io->read_word(P0*2) != last) { @@ -282,10 +282,10 @@ UINT16 i8x9x_device::io_r16(UINT8 adr) logerror("%s: read hsi time (%04x)\n", tag(), PPC); return 0x0000; case 0x0a: - return timer_value(1, get_cycle()); + return timer_value(1, total_cycles()); case 0x0c: logerror("%s: read timer2 (%04x)\n", tag(), PPC); - return timer_value(2, get_cycle()); + return timer_value(2, total_cycles()); default: return io_r8(adr) | (io_r8(adr+1) << 8); } diff --git a/src/emu/cpu/mcs96/mcs96.c b/src/emu/cpu/mcs96/mcs96.c index d487af3e855..51f661e0f94 100644 --- a/src/emu/cpu/mcs96/mcs96.c +++ b/src/emu/cpu/mcs96/mcs96.c @@ -94,18 +94,13 @@ UINT32 mcs96_device::execute_input_lines() const return 1; } -UINT64 mcs96_device::get_cycle() -{ - return end_cycles == 0 || icount <= 0 ? machine().time().as_ticks(clock()) : end_cycles - icount; -} - void mcs96_device::recompute_bcount(UINT64 event_time) { - if(!event_time || event_time >= end_cycles) { + if(!event_time || event_time >= total_cycles()+icount) { bcount = 0; return; } - bcount = end_cycles - event_time; + bcount = total_cycles() - event_time; } void mcs96_device::check_irq() @@ -115,13 +110,10 @@ void mcs96_device::check_irq() void mcs96_device::execute_run() { - UINT64 start_cycles = machine().time().as_ticks(clock()); - end_cycles = start_cycles + icount; - - internal_update(start_cycles); + internal_update(total_cycles()); - if(/*inst_substate*/ 0) - do_exec_partial(); + // if(inst_substate) + // do_exec_partial(); while(icount > 0) { while(icount > bcount) { @@ -132,9 +124,10 @@ void mcs96_device::execute_run() } } while(bcount && icount <= bcount) - internal_update(end_cycles - bcount); + internal_update(total_cycles() + icount - bcount); + // if(inst_substate) + // do_exec_partial(); } - end_cycles = 0; } void mcs96_device::execute_set_input(int inputnum, int state) diff --git a/src/emu/cpu/mcs96/mcs96.h b/src/emu/cpu/mcs96/mcs96.h index f7b11dca14b..22503dff0e0 100644 --- a/src/emu/cpu/mcs96/mcs96.h +++ b/src/emu/cpu/mcs96/mcs96.h @@ -48,8 +48,6 @@ public: mcs96_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, int data_width, const char *shortname, const char *source); - UINT64 get_cycle(); - protected: enum { STATE_FETCH = 0x200, @@ -127,7 +125,6 @@ protected: address_space *program; direct_read_data *direct; - UINT64 end_cycles; int icount, bcount, inst_state, cycles_scaling; UINT8 pending_irq; UINT16 PC, PPC, PSW; |