c80: merged c80h into c80.cpp. Fixed random crash. Removed bogus 9th digit. Documented how to use the cassette.

This commit is contained in:
Robbbert 2022-04-09 02:35:47 +10:00
parent 2775aca725
commit 89ee397622
4 changed files with 96 additions and 106 deletions

View File

@ -2252,7 +2252,6 @@ files {
MAME_DIR .. "src/mame/drivers/ac1.cpp", MAME_DIR .. "src/mame/drivers/ac1.cpp",
MAME_DIR .. "src/mame/drivers/bcs3.cpp", MAME_DIR .. "src/mame/drivers/bcs3.cpp",
MAME_DIR .. "src/mame/drivers/c80.cpp", MAME_DIR .. "src/mame/drivers/c80.cpp",
MAME_DIR .. "src/mame/includes/c80.h",
MAME_DIR .. "src/mame/drivers/huebler.cpp", MAME_DIR .. "src/mame/drivers/huebler.cpp",
MAME_DIR .. "src/mame/includes/huebler.h", MAME_DIR .. "src/mame/includes/huebler.h",
MAME_DIR .. "src/mame/drivers/jtc.cpp", MAME_DIR .. "src/mame/drivers/jtc.cpp",

View File

@ -50,15 +50,76 @@ or press 0 thru C to choose one directly:
When MEM is chosen, enter the address, press UP, enter data, press UP, enter When MEM is chosen, enter the address, press UP, enter data, press UP, enter
data of next byte, and so on. data of next byte, and so on.
Cassette SAVE: Press F1 1 aaaa DOWN bbbb UP
Cassette LOAD: Press F1 2 aaaa DOWN bbbb UP
(where aaaa = 4-digit beginning address, bbbb = 4-digit ending address)
****************************************************************************/ ****************************************************************************/
#include "emu.h" #include "emu.h"
#include "includes/c80.h" #include "cpu/z80/z80.h"
#include "machine/z80daisy.h"
#include "machine/z80pio.h"
#include "imagedev/cassette.h"
#include "speaker.h" #include "speaker.h"
#include "c80.lh" #include "c80.lh"
namespace {
#define Z80_TAG "d2"
#define Z80PIO1_TAG "d11"
#define Z80PIO2_TAG "d12"
// You could use a piezo at 455 kHz, or a crystal 500 to 2500 kHz.
// Cassette successfully tested at 455 kHz
#define MASTER_CLOCK 455000
class c80_state : public driver_device
{
public:
c80_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_maincpu(*this, Z80_TAG)
, m_pio1(*this, Z80PIO1_TAG)
, m_pio2(*this, Z80PIO2_TAG)
, m_cassette(*this, "cassette")
, m_row0(*this, "ROW0")
, m_row1(*this, "ROW1")
, m_row2(*this, "ROW2")
, m_digits(*this, "digit%d", 0U)
{ }
DECLARE_INPUT_CHANGED_MEMBER( trigger_reset );
DECLARE_INPUT_CHANGED_MEMBER( trigger_nmi );
void c80(machine_config &config);
private:
required_device<z80_device> m_maincpu;
required_device<z80pio_device> m_pio1;
required_device<z80pio_device> m_pio2;
required_device<cassette_image_device> m_cassette;
required_ioport m_row0;
required_ioport m_row1;
required_ioport m_row2;
output_finder<8> m_digits;
virtual void machine_start() override;
uint8_t pio1_pa_r();
void pio1_pa_w(uint8_t data);
void pio1_pb_w(uint8_t data);
DECLARE_WRITE_LINE_MEMBER( pio1_brdy_w );
/* keyboard state */
u8 m_keylatch = 0;
/* display state */
u8 m_digit = 0;
bool m_pio1_a5 = false;
u8 m_pio1_brdy = 0;
void c80_io(address_map &map);
void c80_mem(address_map &map);
};
/* Memory Maps */ /* Memory Maps */
@ -72,7 +133,7 @@ void c80_state::c80_mem(address_map &map)
void c80_state::c80_io(address_map &map) void c80_state::c80_io(address_map &map)
{ {
map.global_mask(0xff); map.global_mask(0xff);
map(0x7c, 0x7f).rw(Z80PIO2_TAG, FUNC(z80pio_device::read), FUNC(z80pio_device::write)); map(0x7c, 0x7f).rw(m_pio2, FUNC(z80pio_device::read), FUNC(z80pio_device::write));
map(0xbc, 0xbf).rw(m_pio1, FUNC(z80pio_device::read), FUNC(z80pio_device::write)); map(0xbc, 0xbf).rw(m_pio1, FUNC(z80pio_device::read), FUNC(z80pio_device::write));
} }
@ -143,11 +204,9 @@ uint8_t c80_state::pio1_pa_r()
*/ */
uint8_t data = !m_pio1_brdy << 4 | 0x07; uint8_t data = m_pio1_brdy | 0x07;
int i; for (u8 i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
{ {
if (!BIT(m_keylatch, i)) if (!BIT(m_keylatch, i))
{ {
@ -206,7 +265,7 @@ void c80_state::pio1_pb_w(uint8_t data)
*/ */
if (!m_pio1_a5) if (!m_pio1_a5 && (m_digit < 8))
{ {
m_digits[m_digit] = data; m_digits[m_digit] = data;
} }
@ -216,7 +275,7 @@ void c80_state::pio1_pb_w(uint8_t data)
WRITE_LINE_MEMBER( c80_state::pio1_brdy_w ) WRITE_LINE_MEMBER( c80_state::pio1_brdy_w )
{ {
m_pio1_brdy = state; m_pio1_brdy = state ? 0 : 0x10;
if (state) if (state)
{ {
@ -255,34 +314,31 @@ void c80_state::machine_start()
void c80_state::c80(machine_config &config) void c80_state::c80(machine_config &config)
{ {
/* basic machine hardware */ // CPU
Z80(config, m_maincpu, 2500000); /* U880D */ Z80(config, m_maincpu, MASTER_CLOCK); // U880D
m_maincpu->set_addrmap(AS_PROGRAM, &c80_state::c80_mem); m_maincpu->set_addrmap(AS_PROGRAM, &c80_state::c80_mem);
m_maincpu->set_addrmap(AS_IO, &c80_state::c80_io); m_maincpu->set_addrmap(AS_IO, &c80_state::c80_io);
m_maincpu->set_daisy_config(c80_daisy_chain); m_maincpu->set_daisy_config(c80_daisy_chain);
/* video hardware */ // video
config.set_default_layout(layout_c80); config.set_default_layout(layout_c80);
/* devices */ // devices
Z80PIO(config, m_pio1, 2500000); Z80PIO(config, m_pio1, MASTER_CLOCK); // U855D
m_pio1->out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0); m_pio1->out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);
m_pio1->in_pa_callback().set(FUNC(c80_state::pio1_pa_r)); m_pio1->in_pa_callback().set(FUNC(c80_state::pio1_pa_r));
m_pio1->out_pa_callback().set(FUNC(c80_state::pio1_pa_w)); m_pio1->out_pa_callback().set(FUNC(c80_state::pio1_pa_w));
m_pio1->out_pb_callback().set(FUNC(c80_state::pio1_pb_w)); m_pio1->out_pb_callback().set(FUNC(c80_state::pio1_pb_w));
m_pio1->out_brdy_callback().set(FUNC(c80_state::pio1_brdy_w)); m_pio1->out_brdy_callback().set(FUNC(c80_state::pio1_brdy_w));
z80pio_device& pio2(Z80PIO(config, Z80PIO2_TAG, XTAL(2500000))); Z80PIO(config, m_pio2, MASTER_CLOCK); // U855D
pio2.out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0); m_pio2->out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);
// cassette
SPEAKER(config, "mono").front_center(); SPEAKER(config, "mono").front_center();
CASSETTE(config, m_cassette); CASSETTE(config, m_cassette);
m_cassette->set_default_state(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED); m_cassette->set_default_state(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED);
m_cassette->add_route(ALL_OUTPUTS, "mono", 0.05); m_cassette->add_route(ALL_OUTPUTS, "mono", 0.05);
/* internal ram */
RAM(config, RAM_TAG).set_default_size("1K");
} }
/* ROMs */ /* ROMs */
@ -292,8 +348,7 @@ ROM_START( c80 )
ROM_LOAD( "c80.d3", 0x0000, 0x0400, CRC(ad2b3296) SHA1(14f72cb73a4068b7a5d763cc0e254639c251ce2e) ) ROM_LOAD( "c80.d3", 0x0000, 0x0400, CRC(ad2b3296) SHA1(14f72cb73a4068b7a5d763cc0e254639c251ce2e) )
ROM_END ROM_END
} // Anonymous namespace
/* System Drivers */
/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */ /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */
COMP( 1986, c80, 0, 0, c80, c80, c80_state, empty_init, "Joachim Czepa", "C-80", MACHINE_SUPPORTS_SAVE ) COMP( 1986, c80, 0, 0, c80, c80, c80_state, empty_init, "Joachim Czepa", "C-80", MACHINE_SUPPORTS_SAVE )

View File

@ -1,63 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
#ifndef MAME_INCLUDES_C80_H
#define MAME_INCLUDES_C80_H
#include "cpu/z80/z80.h"
#include "machine/z80daisy.h"
#include "machine/z80pio.h"
#include "imagedev/cassette.h"
#include "machine/ram.h"
#define SCREEN_TAG "screen"
#define Z80_TAG "d2"
#define Z80PIO1_TAG "d11"
#define Z80PIO2_TAG "d12"
class c80_state : public driver_device
{
public:
c80_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_maincpu(*this, Z80_TAG)
, m_pio1(*this, Z80PIO1_TAG)
, m_cassette(*this, "cassette")
, m_row0(*this, "ROW0")
, m_row1(*this, "ROW1")
, m_row2(*this, "ROW2")
, m_digits(*this, "digit%u", 0U)
{ }
DECLARE_INPUT_CHANGED_MEMBER( trigger_reset );
DECLARE_INPUT_CHANGED_MEMBER( trigger_nmi );
void c80(machine_config &config);
private:
required_device<z80_device> m_maincpu;
required_device<z80pio_device> m_pio1;
required_device<cassette_image_device> m_cassette;
required_ioport m_row0;
required_ioport m_row1;
required_ioport m_row2;
output_finder<9> m_digits;
virtual void machine_start() override;
uint8_t pio1_pa_r();
void pio1_pa_w(uint8_t data);
void pio1_pb_w(uint8_t data);
DECLARE_WRITE_LINE_MEMBER( pio1_brdy_w );
/* keyboard state */
int m_keylatch = 0;
/* display state */
int m_digit = 0;
int m_pio1_a5 = 0;
int m_pio1_brdy = 0;
void c80_io(address_map &map);
void c80_mem(address_map &map);
};
#endif

View File

@ -10,33 +10,32 @@ license:CC0
</element> </element>
<view name="Default Layout"> <view name="Default Layout">
<bounds left="5" top="5" right="159" bottom="39" />
<!-- Led address display --> <!-- Led address display -->
<element name="digit0" ref="digit"> <element name="digit0" ref="digit">
<bounds x="0" y="0" width="18" height="24" /> <bounds x="10" y="10" width="18" height="24" />
</element> </element>
<element name="digit1" ref="digit"> <element name="digit1" ref="digit">
<bounds x="18" y="0" width="18" height="24" /> <bounds x="28" y="10" width="18" height="24" />
</element> </element>
<element name="digit2" ref="digit"> <element name="digit2" ref="digit">
<bounds x="36" y="0" width="18" height="24" /> <bounds x="46" y="10" width="18" height="24" />
</element> </element>
<element name="digit3" ref="digit"> <element name="digit3" ref="digit">
<bounds x="54" y="0" width="18" height="24" /> <bounds x="64" y="10" width="18" height="24" />
</element>
<element name="digit4" ref="digit">
<bounds x="82" y="10" width="18" height="24" />
</element>
<element name="digit5" ref="digit">
<bounds x="100" y="10" width="18" height="24" />
</element>
<element name="digit6" ref="digit">
<bounds x="118" y="10" width="18" height="24" />
</element>
<element name="digit7" ref="digit">
<bounds x="136" y="10" width="18" height="24" />
</element> </element>
<element name="digit4" ref="digit">
<bounds x="72" y="0" width="18" height="24" />
</element>
<element name="digit5" ref="digit">
<bounds x="90" y="0" width="18" height="24" />
</element>
<element name="digit6" ref="digit">
<bounds x="108" y="0" width="18" height="24" />
</element>
<element name="digit7" ref="digit">
<bounds x="126" y="0" width="18" height="24" />
</element>
<element name="digit8" ref="digit">
<bounds x="144" y="0" width="18" height="24" />
</element>
</view> </view>
</mamelayout> </mamelayout>