Skip to content

Commit c60d4a0

Browse files
committed
h8: add system clock getter (divided clock())
1 parent 31a7aae commit c60d4a0

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/devices/cpu/h8/h8.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class h8_device : public cpu_device, public device_nvram_interface {
6666
void do_sci_tx(int sci, int state) { m_sci_tx[sci](state); }
6767
void do_sci_clk(int sci, int state) { m_sci_clk[sci](state); }
6868

69-
u64 now_as_cycles() const { return machine().time().as_ticks(clock()) - m_cycles_base; }
69+
u64 system_clock() const { return execute_clocks_to_cycles(clock()); }
70+
u64 now_as_cycles() const { return machine().time().as_ticks(system_clock()) - m_cycles_base; }
7071

7172
protected:
7273
enum {

src/devices/cpu/h8/h8_sci.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -253,25 +253,25 @@ void h8_sci_device::clock_update()
253253
std::string new_message;
254254
switch(m_clock_mode) {
255255
case INTERNAL_ASYNC:
256-
new_message = util::string_format("clock internal at %d Hz, async, bitrate %d bps\n", int(m_cpu->clock() / m_divider), int(m_cpu->clock() / (m_divider*16)));
256+
new_message = util::string_format("clock internal at %d Hz, async, bitrate %d bps\n", int(m_cpu->system_clock() / m_divider), int(m_cpu->system_clock() / (m_divider*16)));
257257
break;
258258
case INTERNAL_ASYNC_OUT:
259-
new_message = util::string_format("clock internal at %d Hz, async, bitrate %d bps, output\n", int(m_cpu->clock() / m_divider), int(m_cpu->clock() / (m_divider*16)));
259+
new_message = util::string_format("clock internal at %d Hz, async, bitrate %d bps, output\n", int(m_cpu->system_clock() / m_divider), int(m_cpu->system_clock() / (m_divider*16)));
260260
break;
261261
case EXTERNAL_ASYNC:
262262
new_message = "clock external, async\n";
263263
break;
264264
case EXTERNAL_RATE_ASYNC:
265-
new_message = util::string_format("clock external at %d Hz, async, bitrate %d bps\n", int(m_cpu->clock()*m_internal_to_external_ratio), int(m_cpu->clock()*m_internal_to_external_ratio/16));
265+
new_message = util::string_format("clock external at %d Hz, async, bitrate %d bps\n", int(m_cpu->system_clock()*m_internal_to_external_ratio), int(m_cpu->system_clock()*m_internal_to_external_ratio/16));
266266
break;
267267
case INTERNAL_SYNC_OUT:
268-
new_message = util::string_format("clock internal at %d Hz, sync, output\n", int(m_cpu->clock() / (m_divider*2)));
268+
new_message = util::string_format("clock internal at %d Hz, sync, output\n", int(m_cpu->system_clock() / (m_divider*2)));
269269
break;
270270
case EXTERNAL_SYNC:
271271
new_message = "clock external, sync\n";
272272
break;
273273
case EXTERNAL_RATE_SYNC:
274-
new_message = util::string_format("clock external at %d Hz, sync\n", int(m_cpu->clock()*m_internal_to_external_ratio));
274+
new_message = util::string_format("clock external at %d Hz, sync\n", int(m_cpu->system_clock()*m_internal_to_external_ratio));
275275
break;
276276
}
277277
if(new_message != m_last_clock_message) {
@@ -289,7 +289,7 @@ void h8_sci_device::device_start()
289289
m_internal_to_external_ratio = 0;
290290
m_external_to_internal_ratio = 0;
291291
} else {
292-
m_external_to_internal_ratio = (m_external_clock_period*m_cpu->clock()).as_double();
292+
m_external_to_internal_ratio = (m_external_clock_period*m_cpu->system_clock()).as_double();
293293
m_internal_to_external_ratio = 1/m_external_to_internal_ratio;
294294
}
295295

@@ -413,7 +413,7 @@ u64 h8_sci_device::internal_update(u64 current_time)
413413
m_clock_event = 0;
414414

415415
if(m_clock_event) {
416-
m_sync_timer->adjust(attotime::from_ticks(m_clock_event - m_cpu->now_as_cycles(), m_cpu->clock()));
416+
m_sync_timer->adjust(attotime::from_ticks(m_clock_event - m_cpu->now_as_cycles(), m_cpu->system_clock()));
417417
m_cpu->internal_update();
418418
}
419419

@@ -457,7 +457,7 @@ void h8_sci_device::clock_start(int mode)
457457
m_clock_step = m_divider;
458458
u64 now = mode == CLK_TX ? m_cpu->total_cycles() : m_cpu->now_as_cycles();
459459
m_clock_event = (now / m_clock_step + 1) * m_clock_step;
460-
m_sync_timer->adjust(attotime::from_ticks(m_clock_event - now, m_cpu->clock()));
460+
m_sync_timer->adjust(attotime::from_ticks(m_clock_event - now, m_cpu->system_clock()));
461461
m_cpu->internal_update();
462462
break;
463463
}
@@ -467,7 +467,7 @@ void h8_sci_device::clock_start(int mode)
467467
LOGMASKED(LOG_CLOCK, "Simulating external clock\n", m_clock_mode == EXTERNAL_RATE_ASYNC ? "async" : "sync");
468468
u64 now = mode == CLK_TX ? m_cpu->total_cycles() : m_cpu->now_as_cycles();
469469
m_clock_event = u64(u64(now * m_internal_to_external_ratio + 1) * m_external_to_internal_ratio + 1);
470-
m_sync_timer->adjust(attotime::from_ticks(m_clock_event - now, m_cpu->clock()));
470+
m_sync_timer->adjust(attotime::from_ticks(m_clock_event - now, m_cpu->system_clock()));
471471
m_cpu->internal_update();
472472
break;
473473
}

src/devices/cpu/h8/h8_timer8.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void h8_timer8_channel_device::update_tcr()
8181
case 1: case 2: case 3:
8282
m_clock_type = DIV;
8383
m_clock_divider = m_div_tab[((m_tcr & TCR_CKS)-1)*2 + m_extra_clock_bit];
84-
if(V>=1) util::stream_format(message, "clock %dHz", m_cpu->clock()/m_clock_divider);
84+
if(V>=1) util::stream_format(message, "clock %dHz", m_cpu->system_clock()/m_clock_divider);
8585
break;
8686

8787
case 4:

0 commit comments

Comments
 (0)