Skip to content

Commit 7473e74

Browse files
committed
commodore/plus4: Fixed loading from cassette. [Curt Coder]
mos7360: Fixed timer clocks and partially implemented CPU double speed mode. [Curt Coder] Fixes MT 06084, partially fixes MT 08106
1 parent c31aa50 commit 7473e74

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

src/devices/sound/mos7360.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ mos7360_device::mos7360_device(const machine_config &mconfig, const char *tag, d
269269
m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(FUNC(mos7360_device::mos7360_videoram_map), this)),
270270
m_write_irq(*this),
271271
m_read_k(*this, 0xff),
272-
m_stream(nullptr)
272+
m_stream(nullptr),
273+
m_cpu(*this, finder_base::DUMMY_TAG)
273274
{
274275
}
275276

@@ -422,11 +423,11 @@ TIMER_CALLBACK_MEMBER(mos7360_device::timer_expired)
422423
if (param == TIMER_ID_1)
423424
{
424425
// proven by digital sound of several intros like eoroidpro
425-
m_timer[param]->adjust(clocks_to_attotime(TIMER1), param);
426+
m_timer[param]->adjust(attotime::from_ticks(TIMER1, clock()), param);
426427
}
427428
else
428429
{
429-
m_timer[param]->adjust(clocks_to_attotime(0x10000), param);
430+
m_timer[param]->adjust(attotime::from_ticks(0x10000, clock()), param);
430431
}
431432

432433
m_timer_active[param] = true;
@@ -805,22 +806,22 @@ uint8_t mos7360_device::read(offs_t offset, int &cs0, int &cs1)
805806
switch (offset)
806807
{
807808
case 0xff00:
808-
val = attotime_to_clocks(m_timer[0]->remaining()) & 0xff;
809+
val = m_timer_active[0] ? (m_timer[0]->remaining().as_ticks(clock()) & 0xff) : m_reg[offset & 0x1f];
809810
break;
810811
case 0xff01:
811-
val = attotime_to_clocks(m_timer[0]->remaining()) >> 8;
812+
val = m_timer_active[0] ? (m_timer[0]->remaining().as_ticks(clock()) >> 8) : m_reg[offset & 0x1f];
812813
break;
813814
case 0xff02:
814-
val = attotime_to_clocks(m_timer[1]->remaining()) & 0xff;
815+
val = m_timer_active[1] ? (m_timer[1]->remaining().as_ticks(clock()) & 0xff) : m_reg[offset & 0x1f];
815816
break;
816817
case 0xff03:
817-
val = attotime_to_clocks(m_timer[1]->remaining()) >> 8;
818+
val = m_timer_active[1] ? (m_timer[1]->remaining().as_ticks(clock()) >> 8) : m_reg[offset & 0x1f];
818819
break;
819820
case 0xff04:
820-
val = attotime_to_clocks(m_timer[2]->remaining()) & 0xff;
821+
val = m_timer_active[2] ? (m_timer[2]->remaining().as_ticks(clock()) & 0xff) : m_reg[offset & 0x1f];
821822
break;
822823
case 0xff05:
823-
val = attotime_to_clocks(m_timer[2]->remaining()) >> 8;
824+
val = m_timer_active[2] ? (m_timer[2]->remaining().as_ticks(clock()) >> 8) : m_reg[offset & 0x1f];
824825
break;
825826
case 0xff07:
826827
val = (m_reg[offset & 0x1f] & ~0x40);
@@ -904,42 +905,39 @@ void mos7360_device::write(offs_t offset, uint8_t data, int &cs0, int &cs1)
904905

905906
if (m_timer_active[0])
906907
{
907-
m_reg[1] = attotime_to_clocks(m_timer[0]->remaining()) >> 8;
908908
m_timer[0]->reset();
909909
m_timer_active[0] = false;
910910
}
911911
break;
912912
case 0xff01: /* start timer 1 */
913913
m_reg[offset & 0x1f] = data;
914-
m_timer[0]->adjust(clocks_to_attotime(TIMER1), TIMER_ID_1);
914+
m_timer[0]->adjust(attotime::from_ticks(TIMER1, clock()), TIMER_ID_1);
915915
m_timer_active[0] = true;
916916
break;
917917
case 0xff02: /* stop timer 2 */
918918
m_reg[offset & 0x1f] = data;
919919
if (m_timer_active[1])
920920
{
921-
m_reg[3] = attotime_to_clocks(m_timer[1]->remaining()) >> 8;
922921
m_timer[1]->reset();
923922
m_timer_active[1] = false;
924923
}
925924
break;
926925
case 0xff03: /* start timer 2 */
927926
m_reg[offset & 0x1f] = data;
928-
m_timer[1]->adjust(clocks_to_attotime(TIMER2), TIMER_ID_2);
927+
m_timer[1]->adjust(attotime::from_ticks(TIMER2, clock()), TIMER_ID_2);
929928
m_timer_active[1] = true;
930929
break;
931930
case 0xff04: /* stop timer 3 */
932931
m_reg[offset & 0x1f] = data;
933932
if (m_timer_active[2])
934933
{
935-
m_reg[5] = attotime_to_clocks(m_timer[2]->remaining()) >> 8;
936934
m_timer[2]->reset();
937935
m_timer_active[2] = false;
938936
}
939937
break;
940938
case 0xff05: /* start timer 3 */
941939
m_reg[offset & 0x1f] = data;
942-
m_timer[2]->adjust(clocks_to_attotime(TIMER3), TIMER_ID_2);
940+
m_timer[2]->adjust(attotime::from_ticks(TIMER3, clock()), TIMER_ID_3);
943941
m_timer_active[2] = true;
944942
break;
945943
case 0xff06:
@@ -1038,6 +1036,10 @@ void mos7360_device::write(offs_t offset, uint8_t data, int &cs0, int &cs1)
10381036
m_reg[offset & 0x1f] = data;
10391037
m_chargenaddr = CHARGENADDR;
10401038
DBG_LOG(3, "port_w", ("chargen %.4x %s %d\n", CHARGENADDR, data & 2 ? "" : "doubleclock", data & 1));
1039+
if (BIT(data, 1))
1040+
m_cpu->set_clock(clock());
1041+
else
1042+
m_cpu->set_clock(clock() * 2);
10411043
}
10421044
break;
10431045
case 0xff14:

src/devices/sound/mos7360.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class mos7360_device : public device_t,
7878
mos7360_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
7979

8080
// callbacks
81+
template <typename T> void set_cpu_tag(T &&tag) { m_cpu.set_tag(std::forward<T>(tag)); }
8182
auto write_irq_callback() { return m_write_irq.bind(); }
8283
auto read_k_callback() { return m_read_k.bind(); }
8384

@@ -177,6 +178,8 @@ class mos7360_device : public device_t,
177178

178179
emu_timer *m_line_timer;
179180
emu_timer *m_frame_timer;
181+
182+
optional_device<cpu_device> m_cpu;
180183
};
181184

182185

src/mame/commodore/plus4.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ void plus4_state::plus4(machine_config &config)
862862
SPEAKER(config, "mono").front_center();
863863

864864
MOS7360(config, m_ted, 0);
865+
m_ted->set_cpu_tag(m_maincpu);
865866
m_ted->set_addrmap(0, &plus4_state::ted_videoram_map);
866867
m_ted->set_screen(SCREEN_TAG);
867868
m_ted->write_irq_callback().set("mainirq", FUNC(input_merger_device::in_w<0>));
@@ -943,7 +944,7 @@ void c16_state::plus4p(machine_config &config)
943944
{
944945
plus4(config);
945946
m_maincpu->set_clock(XTAL(17'734'470)/20);
946-
m_ted->set_clock(XTAL(17'734'470)/5);
947+
m_ted->set_clock(XTAL(17'734'470)/5/4);
947948

948949
// software list
949950
SOFTWARE_LIST(config, "cart_list").set_original("plus4_cart");
@@ -962,7 +963,7 @@ void c16_state::plus4n(machine_config &config)
962963
{
963964
plus4(config);
964965
m_maincpu->set_clock(XTAL(14'318'181)/16);
965-
m_ted->set_clock(XTAL(14'318'181)/4);
966+
m_ted->set_clock(XTAL(14'318'181)/4/4);
966967

967968
// software list
968969
SOFTWARE_LIST(config, "cart_list").set_original("plus4_cart");

0 commit comments

Comments
 (0)