Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sinclair/tsconf.cpp: Added TR-DOS with virutal drives #13202

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions src/mame/sinclair/beta_m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@
#include "formats/trd_dsk.h"


namespace {

void floppy_formats(format_registration &fr)
{
fr.add_mfm_containers();
fr.add_pc_formats();
fr.add(FLOPPY_TRD_FORMAT);
}

void beta_disk_floppies(device_slot_interface &device)
{
device.option_add("525hd", FLOPPY_525_HD);
device.option_add("525qd", FLOPPY_525_QD);
device.option_add("35hd", FLOPPY_35_HD);
device.option_add("35dd", FLOPPY_35_DD);
}

} // anonymous namespace


/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
Expand Down Expand Up @@ -205,21 +225,6 @@ void beta_disk_device::motors_control()
}
}

void beta_disk_device::floppy_formats(format_registration &fr)
{
fr.add_mfm_containers();
fr.add_pc_formats();
fr.add(FLOPPY_TRD_FORMAT);
}

static void beta_disk_floppies(device_slot_interface &device)
{
device.option_add("525hd", FLOPPY_525_HD);
device.option_add("525qd", FLOPPY_525_QD);
device.option_add("35hd", FLOPPY_35_HD);
device.option_add("35dd", FLOPPY_35_DD);
}


ROM_START( beta_disk )
ROM_REGION( 0x60000, "beta", 0 )
Expand Down Expand Up @@ -312,7 +317,7 @@ void beta_disk_device::device_add_mconfig(machine_config &config)
KR1818VG93(config, m_wd179x, 8_MHz_XTAL / 8);
m_wd179x->hld_wr_callback().set(FUNC(beta_disk_device::fdc_hld_w));
for (auto &floppy : m_floppy)
FLOPPY_CONNECTOR(config, floppy, beta_disk_floppies, "525qd", beta_disk_device::floppy_formats).enable_sound(true);
FLOPPY_CONNECTOR(config, floppy, beta_disk_floppies, "525qd", floppy_formats).enable_sound(true);
}

//-------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions src/mame/sinclair/beta_m.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class beta_disk_device : public device_t
void motors_control();
u8 m_control;
bool m_motor_active;

static void floppy_formats(format_registration &fr);
};

DECLARE_DEVICE_TYPE(BETA_DISK, beta_disk_device)
Expand Down
63 changes: 37 additions & 26 deletions src/mame/sinclair/tsconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ FAQ-RUS: https://forum.tslabs.info/viewtopic.php?f=35&t=157

TODO:
- Ram cache
- VDos

****************************************************************************/

Expand Down Expand Up @@ -81,27 +80,32 @@ void tsconf_state::tsconf_mem(address_map &map)
}

void tsconf_state::tsconf_io(address_map &map)
{
map(0x0000, 0xffff).lrw8(
NAME([this](offs_t offset) { return m_ioext.read_byte((m_beta->dos_io_r() << 16) | offset); }),
NAME([this](offs_t offset, u8 data) { m_ioext.write_byte((m_beta->dos_io_r() << 16) | offset, data); }));
}
Comment on lines +83 to +87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you find a way to do this with a memory_view, rather than effectively creating an address_map_bank_device in all but name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is mainly to support configuration through zxbus. I took this approach previously because zxbus is required to handle 17 bit IO where all 3 combinations are available: shadow only, only !shadow, and both.
It's not clear if such case is possible to implement using banks or memviews.


void tsconf_state::tsconf_ioext(address_map &map)
{
map.unmap_value_high();
map(0x0000, 0x0000).mirror(0x7ffd).w(FUNC(tsconf_state::tsconf_port_7ffd_w));
map(0x001f, 0x001f).mirror(0xff00).r(FUNC(tsconf_state::tsconf_port_xx1f_r)).w(m_beta, FUNC(beta_disk_device::command_w));
map(0x003f, 0x003f).mirror(0xff00).rw(m_beta, FUNC(beta_disk_device::track_r), FUNC(beta_disk_device::track_w));
map(0x0057, 0x0057).mirror(0xff00).rw(FUNC(tsconf_state::tsconf_port_57_zctr_r), FUNC(tsconf_state::tsconf_port_57_zctr_w)); // spi config
map(0x0077, 0x0077).mirror(0xff00).rw(FUNC(tsconf_state::tsconf_port_77_zctr_r), FUNC(tsconf_state::tsconf_port_77_zctr_w)); // spi data
map(0x005f, 0x005f).mirror(0xff00).rw(m_beta, FUNC(beta_disk_device::sector_r), FUNC(beta_disk_device::sector_w));
map(0x007f, 0x007f).mirror(0xff00).rw(m_beta, FUNC(beta_disk_device::data_r), FUNC(beta_disk_device::data_w));
map(0x00fe, 0x00fe).select(0xff00).rw(FUNC(tsconf_state::spectrum_ula_r), FUNC(tsconf_state::tsconf_ula_w));
map(0x00ff, 0x00ff).mirror(0xff00).rw(m_beta, FUNC(beta_disk_device::state_r), FUNC(beta_disk_device::param_w));
map(0x00af, 0x00af).select(0xff00).rw(FUNC(tsconf_state::tsconf_port_xxaf_r), FUNC(tsconf_state::tsconf_port_xxaf_w));
map(0xfadf, 0xfadf).lr8(NAME([this]() -> u8 { return 0x80 | (m_io_mouse[2]->read() & 0x07); }));
map(0xfbdf, 0xfbdf).lr8(NAME([this]() -> u8 { return m_io_mouse[0]->read(); }));
map(0xffdf, 0xffdf).lr8(NAME([this]() -> u8 { return ~m_io_mouse[1]->read(); }));
map(0x8ff7, 0x8ff7).select(0x7000).w(FUNC(tsconf_state::tsconf_port_f7_w)); // 3:bff7 5:dff7 6:eff7
map(0xbff7, 0xbff7).r(FUNC(tsconf_state::tsconf_port_f7_r));
map(0x00fb, 0x00fb).mirror(0xff00).w(m_dac, FUNC(dac_byte_interface::data_w));
map(0x80fd, 0x80fd).mirror(0x3f00).lw8(NAME([this](u8 data) { return m_ay[m_ay_selected]->data_w(data); }));
map(0xc0fd, 0xc0fd).mirror(0x3f00).lr8(NAME([this]() { return m_ay[m_ay_selected]->data_r(); }))
map(0x00000, 0x00000).mirror(0x17ffd).w(FUNC(tsconf_state::tsconf_port_7ffd_w));
map(0x0001f, 0x0001f).mirror(0x0ff00).r(FUNC(tsconf_state::tsconf_port_xx1f_r));
map(0x00057, 0x00057).mirror(0x1ff00).rw(FUNC(tsconf_state::tsconf_port_57_zctr_r), FUNC(tsconf_state::tsconf_port_57_zctr_w)); // spi config
map(0x00077, 0x00077).mirror(0x1ff00).rw(FUNC(tsconf_state::tsconf_port_77_zctr_r), FUNC(tsconf_state::tsconf_port_77_zctr_w)); // spi data
map(0x000fe, 0x000fe).select(0x1ff00).rw(FUNC(tsconf_state::spectrum_ula_r), FUNC(tsconf_state::tsconf_ula_w));
map(0x000af, 0x000af).select(0x1ff00).rw(FUNC(tsconf_state::tsconf_port_xxaf_r), FUNC(tsconf_state::tsconf_port_xxaf_w));
map(0x0fadf, 0x0fadf).mirror(0x10000).lr8(NAME([this]() -> u8 { return 0x80 | (m_io_mouse[2]->read() & 0x07); }));
map(0x0fbdf, 0x0fbdf).mirror(0x10000).lr8(NAME([this]() -> u8 { return m_io_mouse[0]->read(); }));
map(0x0ffdf, 0x0ffdf).mirror(0x10000).lr8(NAME([this]() -> u8 { return ~m_io_mouse[1]->read(); }));
map(0x08ff7, 0x08ff7).select(0x17000).w(FUNC(tsconf_state::tsconf_port_f7_w)); // 3:bff7 5:dff7 6:eff7
map(0x0bff7, 0x0bff7).mirror(0x10000).r(FUNC(tsconf_state::tsconf_port_f7_r));
map(0x000fb, 0x000fb).mirror(0x1ff00).w(m_dac, FUNC(dac_byte_interface::data_w));
map(0x080fd, 0x080fd).mirror(0x13f00).lw8(NAME([this](u8 data) { return m_ay[m_ay_selected]->data_w(data); }));
map(0x0c0fd, 0x0c0fd).mirror(0x13f00).lr8(NAME([this]() { return m_ay[m_ay_selected]->data_r(); }))
.w(FUNC(tsconf_state::tsconf_ay_address_w));

map(0x00000, 0x1ffff).m(m_beta, FUNC(tsconf_beta_device::tsconf_beta_ioext));
}

void tsconf_state::tsconf_switch(address_map &map)
Expand Down Expand Up @@ -180,13 +184,15 @@ void tsconf_state::machine_start()
{
spectrum_128_state::machine_start();
m_maincpu->space(AS_PROGRAM).specific(m_program);
m_bankio->space(AS_PROGRAM).specific(m_ioext);

// reconfigure ROMs
memory_region *rom = memregion("maincpu");
m_bank_rom[0]->configure_entries(0, rom->bytes() / 0x4000, rom->base(), 0x4000);
m_bank_ram[0]->configure_entries(0, m_ram->size() / 0x4000, m_ram->pointer(), 0x4000);

save_item(NAME(m_int_mask));
save_item(NAME(m_update_on_m1));
save_pointer(NAME(m_regs), 0x100);
save_item(NAME(m_zctl_di));
save_item(NAME(m_zctl_cs));
Expand All @@ -197,6 +203,8 @@ void tsconf_state::machine_start()

void tsconf_state::machine_reset()
{
m_update_on_m1 = false;

m_frame_irq_timer->adjust(attotime::never);
m_scanline_irq_timer->adjust(attotime::never);
m_int_mask = 0;
Expand Down Expand Up @@ -228,8 +236,7 @@ void tsconf_state::machine_reset()
m_regs[INT_MASK] = 0x01; // xxxxx001
m_regs[CACHE_CONFIG] &= 0xf0; // xxxx0000

if (m_beta->started())
m_beta->enable();
m_beta->fddvirt_w(m_regs[FDD_VIRT] & 0x0f);

m_zctl_cs = 1;
m_zctl_di = 0xff;
Expand Down Expand Up @@ -277,15 +284,16 @@ void tsconf_state::tsconf(machine_config &config)
config.device_remove("palette");

Z80(config.replace(), m_maincpu, 14_MHz_XTAL / 4);
m_maincpu->set_addrmap(AS_PROGRAM, &tsconf_state::tsconf_mem);
m_maincpu->set_addrmap(AS_IO, &tsconf_state::tsconf_io);
m_maincpu->set_addrmap(AS_OPCODES, &tsconf_state::tsconf_switch);
m_maincpu->set_memory_map(&tsconf_state::tsconf_mem);
m_maincpu->set_io_map(&tsconf_state::tsconf_io);
m_maincpu->set_m1_map(&tsconf_state::tsconf_switch);
m_maincpu->set_irq_acknowledge_callback(FUNC(tsconf_state::irq_vector));

m_maincpu->set_vblank_int("screen", FUNC(tsconf_state::tsconf_vblank_interrupt));

ADDRESS_MAP_BANK(config, m_bankio).set_map(&tsconf_state::tsconf_ioext).set_options(ENDIANNESS_LITTLE, 8, 17, 0);
zxbus_device &zxbus(ZXBUS(config, "zxbus", 0));
zxbus.set_iospace("maincpu", AS_IO);
zxbus.set_iospace(m_bankio, AS_PROGRAM);
ZXBUS_SLOT(config, "zxbus1", 0, "zxbus", zxbus_cards, nullptr);
//ZXBUS_SLOT(config, "zxbus2", 0, "zxbus", zxbus_cards, nullptr);

Expand All @@ -301,7 +309,10 @@ void tsconf_state::tsconf(machine_config &config)
m_dma->out_sfile_callback().set(FUNC(tsconf_state::sfile_write16));
m_dma->on_ready_callback().set(FUNC(tsconf_state::dma_ready));

BETA_DISK(config, m_beta, 0);
TSCONF_BETA(config, m_beta, 0);
m_beta->out_dos_callback().set([this](int state) { tsconf_update_bank0(); });
m_beta->out_vdos_m1_callback().set([this](int state) { m_update_on_m1 = true; });

SPI_SDCARD(config, m_sdcard, 0);
m_sdcard->set_prefer_sdhc();
m_sdcard->spi_miso_callback().set(FUNC(tsconf_state::tsconf_spi_miso_w));
Expand Down
11 changes: 8 additions & 3 deletions src/mame/sinclair/tsconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include "spec128.h"

#include "glukrs.h"
#include "tsconf_beta.h"
#include "tsconfdma.h"

#include "beta_m.h"
#include "machine/pckeybrd.h"
#include "machine/spi_sdcard.h"
#include "sound/ay8910.h"
Expand All @@ -28,10 +28,11 @@ class tsconf_state : public spectrum_128_state
public:
tsconf_state(const machine_config &mconfig, device_type type, const char *tag)
: spectrum_128_state(mconfig, type, tag)
, m_bankio(*this, "bankio")
, m_bank0_rom(*this, "bank0_rom")
, m_keyboard(*this, "pc_keyboard")
, m_io_mouse(*this, "mouse_input%u", 1U)
, m_beta(*this, BETA_DISK_TAG)
, m_beta(*this, "beta")
, m_dma(*this, "dma")
, m_sdcard(*this, "sdcard")
, m_glukrs(*this, "glukrs")
Expand Down Expand Up @@ -155,6 +156,7 @@ class tsconf_state : public spectrum_128_state
INTERRUPT_GEN_MEMBER(tsconf_vblank_interrupt);
IRQ_CALLBACK_MEMBER(irq_vector);
u8 m_int_mask;
bool m_update_on_m1;

DECLARE_VIDEO_START(tsconf);
TILE_GET_INFO_MEMBER(get_tile_info_txt);
Expand Down Expand Up @@ -193,6 +195,7 @@ class tsconf_state : public spectrum_128_state
u8 beta_disable_r(offs_t offset);

void tsconf_io(address_map &map) ATTR_COLD;
void tsconf_ioext(address_map &map) ATTR_COLD;
void tsconf_mem(address_map &map) ATTR_COLD;
void tsconf_switch(address_map &map) ATTR_COLD;

Expand All @@ -213,12 +216,14 @@ class tsconf_state : public spectrum_128_state
u8 m_regs[0x100];

memory_access<16, 0, 0, ENDIANNESS_LITTLE>::specific m_program;
memory_access<17, 0, 0, ENDIANNESS_LITTLE>::specific m_ioext;
required_device<address_map_bank_device> m_bankio;
memory_view m_bank0_rom;

required_device<at_keyboard_device> m_keyboard;
required_ioport_array<3> m_io_mouse;

required_device<beta_disk_device> m_beta;
required_device<tsconf_beta_device> m_beta;
required_device<tsconfdma_device> m_dma;
required_device<spi_sdcard_device> m_sdcard;
u8 m_zctl_di = 0;
Expand Down
Loading
Loading