// license:BSD-3-Clause
// copyright-holders:Miodrag Milanovic, Robbbert
/***************************************************************************
Chaos2
2010-04-08 Skeleton driver.
2012-05-19 Connected to a terminal, system is usable [Robbbert]
This is a homebrew system: http://koo.corpus.cam.ac.uk/chaos/
There are no schematics or manuals, so the results might not be
totally accurate.
With the DOS config switch turned off, the only accepted input
is a line starting with '&'. The actual commands are unknown.
With DOS enabled, a large number of commands become available.
These are:
access, ask, ascdis, bpclr, bpset, close, control, copy, devfive, dir,
end, exec, execute, fill, find, goto, if, input, let, list, load, lowercase,
memdis, memset, open, port, read, reboot, runhex, run, save, type, typesl,
verify.
An example is: memdis 0 8 (memory dump starting at 0, show 8 lines)
Don't try 'fill' - it fills all memory with zeroes, crashing the system.
ToDo:
- Connect up floppy disk (WD1771 fdc, 5.25", single density,
no other info available)
****************************************************************************/
#include "emu.h"
#include "cpu/s2650/s2650.h"
#include "machine/terminal.h"
class chaos_state : public driver_device
{
public:
chaos_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_terminal(*this, "terminal")
, m_p_ram(*this, "ram")
, m_maincpu(*this, "maincpu")
{
}
DECLARE_READ8_MEMBER(port1e_r);
DECLARE_WRITE8_MEMBER(port1f_w);
DECLARE_READ8_MEMBER(port90_r);
DECLARE_READ8_MEMBER(port91_r);
void kbd_put(u8 data);
void chaos(machine_config &config);
void data_map(address_map &map);
void io_map(address_map &map);
void mem_map(address_map &map);
private:
uint8_t m_term_data;
virtual void machine_reset() override;
required_device<generic_terminal_device> m_terminal;
required_shared_ptr<uint8_t> m_p_ram;
required_device<cpu_device> m_maincpu;
};
void chaos_state::mem_map(address_map &map)
{
map.unmap_value_high();
map(0x0000, 0x7fff).ram().share("ram");
}
void chaos_state::io_map(address_map &map)
{
map.unmap_value_high();
map(0x1e, 0x1e).r(this, FUNC(chaos_state::port1e_r));
map(0x1f, 0x1f).rw(this, FUNC(chaos_state::port90_r), FUNC(chaos_state::port1f_w));
map(0x90, 0x90).r(this, FUNC(chaos_state::port90_r));
map(0x91, 0x91).r(this, FUNC(chaos_state::port91_r));
map(0x92, 0x92).w(m_terminal, FUNC(generic_terminal_device::write));
}
void chaos_state::data_map(address_map &map)
{
map(S2650_DATA_PORT, S2650_DATA_PORT).noprw(); // stops error log filling up while using debug
}
/* Input ports */
static INPUT_PORTS_START( chaos )
PORT_START("CONFIG")
PORT_CONFNAME( 0x01, 0x00, "Enable DOS")
PORT_CONFSETTING( 0x01, DEF_STR(No))
PORT_CONFSETTING( 0x00, DEF_STR(Yes))
INPUT_PORTS_END
// Port 1E - Bit 0 indicates key pressed, Bit 1 indicates ok to output
READ8_MEMBER( chaos_state::port1e_r )
{
return (m_term_data) ? 1 : 0;
}
WRITE8_MEMBER( chaos_state::port1f_w )
{
// make the output readable on our terminal
if (data == 0x09)
return;
else
if (!data)
data = 0x24;
m_terminal->write(space, 0, data);
if (data == 0x0d)
m_terminal->write(space, 0, 0x0a);
}
READ8_MEMBER( chaos_state::port90_r )
{
uint8_t ret = m_term_data;
m_term_data = 0;
return ret;
}
// Status port
// Bit 0 = L use ports 1E & 1F; H use ports 90 & 92
// Bit 3 = key pressed
// Bit 7 = ok to output
READ8_MEMBER( chaos_state::port91_r )
{
uint8_t ret = 0x80 | ioport("CONFIG")->read();
ret |= (m_term_data) ? 8 : 0;
return ret;
}
void chaos_state::kbd_put(u8 data)
{
m_term_data = data;
}
void chaos_state::machine_reset()
{
// copy the roms into ram
uint8_t* ROM = memregion("roms")->base();
memcpy(m_p_ram, ROM, 0x3000);
memcpy(m_p_ram+0x7000, ROM+0x3000, 0x1000);
}
MACHINE_CONFIG_START(chaos_state::chaos)
/* basic machine hardware */
MCFG_DEVICE_ADD("maincpu", S2650, XTAL(1'000'000))
MCFG_DEVICE_PROGRAM_MAP(mem_map)
MCFG_DEVICE_IO_MAP(io_map)
MCFG_DEVICE_DATA_MAP(data_map)
/* video hardware */
MCFG_DEVICE_ADD("terminal", GENERIC_TERMINAL, 0)
MCFG_GENERIC_TERMINAL_KEYBOARD_CB(PUT(chaos_state, kbd_put))
MACHINE_CONFIG_END
/* ROM definition */
ROM_START( chaos )
ROM_REGION( 0x4000, "roms", ROMREGION_ERASEFF )
ROM_LOAD( "chaos.001", 0x0000, 0x1000, CRC(3b433e72) SHA1(5b487337d71253d0e64e123f405da9eaf20e87ac))
ROM_LOAD( "chaos.002", 0x1000, 0x1000, CRC(8b0b487f) SHA1(0d167cf3004a81c87446f2f1464e3debfa7284fe))
ROM_LOAD( "chaos.003", 0x2000, 0x1000, CRC(5880db81) SHA1(29b8f1b03c83953f66464ad1fbbfe2e019637ce1))
ROM_LOAD( "chaos.004", 0x3000, 0x1000, CRC(5d6839d6) SHA1(237f52f0780ac2e29d57bf06d0f7a982eb523084))
ROM_END
/* Driver */
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
COMP( 1983, chaos, 0, 0, chaos, chaos, chaos_state, empty_init, "David Greaves", "Chaos 2", MACHINE_NO_SOUND_HW )