Skip to content

Commit 2fe2cb6

Browse files
committed
m6502/m5074x.cpp: Modernized logging, fixed Timer X mixing up the prescale and countdown values. [R. Belmont]
* Fixes several PowerBooks that were auto-polling ADB at 5 Hz instead of 70 Hz.
1 parent e83123d commit 2fe2cb6

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/devices/cpu/m6502/m5074x.cpp

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
#include "emu.h"
88
#include "m5074x.h"
99

10+
#define LOG_ADC (1U << 1)
11+
#define LOG_PORTS (1U << 2)
12+
#define LOG_TIMER (1U << 3)
13+
14+
#define VERBOSE (0)
15+
#include "logmacro.h"
16+
1017
//**************************************************************************
1118
// MACROS / CONSTANTS
1219
//**************************************************************************
@@ -147,7 +154,7 @@ TIMER_CALLBACK_MEMBER(m5074x_device::timerx_tick)
147154
{
148155
m_tmrx--;
149156

150-
if (m_tmrx <= 0)
157+
if (m_tmrx == 0)
151158
{
152159
m_tmrctrl |= TMRC_TMRXREQ;
153160
m_tmrx = m_tmrxlatch;
@@ -230,12 +237,14 @@ void m5074x_device::recalc_timer(int timer)
230237
case 0:
231238
hz = clock() / 16;
232239
hz /= (m_tmr12pre + 2);
240+
LOGMASKED(LOG_TIMER, "%s: timer 1, prescale %02x, fire at %d Hz\n", machine().describe_context(), m_tmr12pre, hz);
233241
m_timers[TIMER_1]->adjust(attotime::from_hz(hz), 0, attotime::from_hz(hz));
234242
break;
235243

236244
case 1:
237245
hz = clock() / 16;
238246
hz /= (m_tmr12pre + 2);
247+
LOGMASKED(LOG_TIMER, "%s: timer 2, prescale %02x, fire at %d Hz\n", machine().describe_context(), m_tmr12pre, hz);
239248
m_timers[TIMER_2]->adjust(attotime::from_hz(hz), 0, attotime::from_hz(hz));
240249
break;
241250

@@ -247,12 +256,14 @@ void m5074x_device::recalc_timer(int timer)
247256
// stop bit?
248257
if (m_tmrctrl & TMRC_TMRXHLT)
249258
{
259+
LOGMASKED(LOG_TIMER, "%s: timer X halted\n", machine().describe_context());
250260
m_timers[TIMER_X]->adjust(attotime::never, 0, attotime::never);
251261
}
252262
else
253263
{
254264
hz = clock() / 16;
255265
hz /= (m_tmrxpre + 2);
266+
LOGMASKED(LOG_TIMER, "%s: timer X, prescale %02x, fire at %d Hz\n", machine().describe_context(), m_tmrxpre, hz);
256267
m_timers[TIMER_X]->adjust(attotime::from_hz(hz), 0, attotime::from_hz(hz));
257268
}
258269
}
@@ -266,6 +277,9 @@ void m5074x_device::recalc_timer(int timer)
266277

267278
void m5074x_device::send_port(uint8_t offset, uint8_t data)
268279
{
280+
LOGMASKED(LOG_PORTS, "%s: Write port %d, data %02x DDR %02x pull-ups %02x\n", machine().describe_context(), offset,
281+
data, m_ddrs[offset], m_pullups[offset]);
282+
269283
m_write_p[offset](data);
270284
}
271285

@@ -278,6 +292,9 @@ uint8_t m5074x_device::read_port(uint8_t offset)
278292
// OR in ddr-masked version of port writes
279293
incoming |= (m_ports[offset] & m_ddrs[offset]);
280294

295+
LOGMASKED(LOG_PORTS, "%s: Read port %d, incoming %02x DDR %02x output latch %02x\n", machine().describe_context(), offset,
296+
m_read_p[offset](), m_ddrs[offset], m_ports[offset]);
297+
281298
return incoming;
282299
}
283300

@@ -406,31 +423,34 @@ uint8_t m5074x_device::tmrirq_r(offs_t offset)
406423

407424
void m5074x_device::tmrirq_w(offs_t offset, uint8_t data)
408425
{
409-
// printf("%02x to tmrirq @ %d\n", data, offset);
410-
411426
switch (offset)
412427
{
413428
case 0:
414429
m_tmr12pre = data;
430+
LOGMASKED(LOG_TIMER, "%s: timer 1/2 prescale %02x\n", machine().describe_context(), data);
415431
recalc_timer(0);
416432
recalc_timer(1);
417433
break;
418434

419435
case 1:
420436
m_tmr1 = m_tmr1latch = data;
437+
LOGMASKED(LOG_TIMER, "%s: timer 1 latch %02x\n", machine().describe_context(), data);
421438
break;
422439

423440
case 2:
424441
m_tmr2 = m_tmr2latch = data;
442+
LOGMASKED(LOG_TIMER, "%s: timer 2 latch %02x\n", machine().describe_context(), data);
425443
break;
426444

427445
case 3:
428-
m_tmrxpre = m_tmrxlatch = data;
446+
m_tmrxpre = data;
447+
LOGMASKED(LOG_TIMER, "%s: timer X prescale %02x\n", machine().describe_context(), data);
429448
recalc_timer(2);
430449
break;
431450

432451
case 4:
433-
m_tmrx = data;
452+
m_tmrx = m_tmrxlatch = data;
453+
LOGMASKED(LOG_TIMER, "%s: timer X latch %02x\n", machine().describe_context(), data);
434454
break;
435455

436456
case 5:
@@ -548,7 +568,7 @@ uint8_t m50753_device::ad_r()
548568

549569
void m50753_device::ad_start_w(uint8_t data)
550570
{
551-
logerror("%s: A-D start (IN%d)\n", machine().describe_context(), m_ad_control & 0x07);
571+
LOGMASKED(LOG_ADC, "%s: A-D start (IN%d)\n", machine().describe_context(), m_ad_control & 0x07);
552572

553573
// starting a conversion. M50753 documentation says conversion time is 72 microseconds.
554574
m_timers[TIMER_ADC]->adjust(attotime::from_usec(72));
@@ -561,6 +581,7 @@ uint8_t m50753_device::ad_control_r()
561581

562582
void m50753_device::ad_control_w(uint8_t data)
563583
{
584+
LOGMASKED(LOG_ADC, "%s: %02x to A-D control\n", machine().describe_context(), data);
564585
m_ad_control = data & 0x0f;
565586
}
566587

0 commit comments

Comments
 (0)