Skip to content

Commit

Permalink
io view
Browse files Browse the repository at this point in the history
  • Loading branch information
holub committed Jan 19, 2025
1 parent 325644f commit b6070fd
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 38 deletions.
45 changes: 19 additions & 26 deletions src/mame/sinclair/tsconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,27 @@ 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); }));
}

void tsconf_state::tsconf_ioext(address_map &map)
{
map.unmap_value_high();
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(); }))
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));
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(0x00fe, 0x00fe).select(0xff00).rw(FUNC(tsconf_state::spectrum_ula_r), FUNC(tsconf_state::tsconf_ula_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(); }))
.w(FUNC(tsconf_state::tsconf_ay_address_w));

map(0x00000, 0x1ffff).m(m_beta, FUNC(tsconf_beta_device::tsconf_beta_ioext));
// IO: Shadow
map(0x0000, 0xffff).view(m_io_shadow_view);
m_io_shadow_view[0](0x0000, 0xffff).m(m_beta, FUNC(tsconf_beta_device::tsconf_beta_io));
}

void tsconf_state::tsconf_switch(address_map &map)
Expand Down Expand Up @@ -184,7 +179,6 @@ 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");
Expand Down Expand Up @@ -291,9 +285,8 @@ void tsconf_state::tsconf(machine_config &config)

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(m_bankio, AS_PROGRAM);
zxbus.set_iospace("maincpu", AS_IO);
ZXBUS_SLOT(config, "zxbus1", 0, "zxbus", zxbus_cards, nullptr);
//ZXBUS_SLOT(config, "zxbus2", 0, "zxbus", zxbus_cards, nullptr);

Expand All @@ -310,7 +303,7 @@ void tsconf_state::tsconf(machine_config &config)
m_dma->on_ready_callback().set(FUNC(tsconf_state::dma_ready));

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

SPI_SDCARD(config, m_sdcard, 0);
Expand Down
7 changes: 3 additions & 4 deletions src/mame/sinclair/tsconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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_io_shadow_view(*this, "io_shadow_view")
, m_bank0_rom(*this, "bank0_rom")
, m_keyboard(*this, "pc_keyboard")
, m_io_mouse(*this, "mouse_input%u", 1U)
Expand Down Expand Up @@ -190,12 +190,12 @@ class tsconf_state : public spectrum_128_state
void tsconf_ay_address_w(u8 data);

void tsconf_update_bank0();
void update_io(int dos);
u8 beta_neutral_r(offs_t offset);
u8 beta_enable_r(offs_t offset);
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 @@ -216,8 +216,7 @@ 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_io_shadow_view;
memory_view m_bank0_rom;

required_device<at_keyboard_device> m_keyboard;
Expand Down
15 changes: 8 additions & 7 deletions src/mame/sinclair/tsconf_beta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ void beta_disk_floppies(device_slot_interface &device)
// device type definition
DEFINE_DEVICE_TYPE(TSCONF_BETA, tsconf_beta_device, "tsconf_beta", "Virtual TR-DOS")

void tsconf_beta_device::tsconf_beta_ioext(address_map &map)
void tsconf_beta_device::tsconf_beta_io(address_map &map)
{
map(0x1001f, 0x1001f).mirror(0x0ff00).rw(FUNC(tsconf_beta_device::status_r), FUNC(tsconf_beta_device::command_w));
map(0x1003f, 0x1003f).mirror(0x0ff00).rw(FUNC(tsconf_beta_device::track_r), FUNC(tsconf_beta_device::track_w));
map(0x1005f, 0x1005f).mirror(0x0ff00).rw(FUNC(tsconf_beta_device::sector_r), FUNC(tsconf_beta_device::sector_w));
map(0x1007f, 0x1007f).mirror(0x0ff00).rw(FUNC(tsconf_beta_device::data_r), FUNC(tsconf_beta_device::data_w));
map(0x1009f, 0x1009f).select(0x0ff60).rw(FUNC(tsconf_beta_device::state_r), FUNC(tsconf_beta_device::param_w));
map(0x001f, 0x001f).mirror(0xff00).rw(FUNC(tsconf_beta_device::status_r), FUNC(tsconf_beta_device::command_w));
map(0x003f, 0x003f).mirror(0xff00).rw(FUNC(tsconf_beta_device::track_r), FUNC(tsconf_beta_device::track_w));
map(0x005f, 0x005f).mirror(0xff00).rw(FUNC(tsconf_beta_device::sector_r), FUNC(tsconf_beta_device::sector_w));
map(0x007f, 0x007f).mirror(0xff00).rw(FUNC(tsconf_beta_device::data_r), FUNC(tsconf_beta_device::data_w));
map(0x009f, 0x009f).select(0xff60).rw(FUNC(tsconf_beta_device::state_r), FUNC(tsconf_beta_device::param_w));
}


Expand Down Expand Up @@ -203,7 +203,7 @@ void tsconf_beta_device::enable_w(bool state)
if ((state && !m_dos) || (!state && m_dos && !m_vdos))
{
m_dos = state;
m_out_dos_cb(state);
m_out_dos_cb(dos_io_r());
}
}

Expand All @@ -215,6 +215,7 @@ void tsconf_beta_device::fddvirt_w(u8 fddvirt)
void tsconf_beta_device::io_forced_w(bool io_forced)
{
m_io_forced = io_forced;
m_out_dos_cb(dos_io_r());
}

void tsconf_beta_device::fdc_hld_w(int state)
Expand Down
2 changes: 1 addition & 1 deletion src/mame/sinclair/tsconf_beta.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class tsconf_beta_device : public device_t
public:
tsconf_beta_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);

void tsconf_beta_ioext(address_map &map) ATTR_COLD;
void tsconf_beta_io(address_map &map) ATTR_COLD;

auto out_dos_callback() { return m_out_dos_cb.bind(); }
auto out_vdos_m1_callback() { return m_out_vdos_m1_cb.bind(); }
Expand Down
10 changes: 10 additions & 0 deletions src/mame/sinclair/tsconf_m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ void tsconf_state::tsconf_update_bank0()
}
}

void tsconf_state::update_io(int dos)
{
if (m_beta->dos_io_r())
m_io_shadow_view.select(0);
else
m_io_shadow_view.disable();

tsconf_update_bank0();
}

void tsconf_state::tsconf_update_video_mode()
{
rectangle visarea = screen_area[3];
Expand Down

0 comments on commit b6070fd

Please sign in to comment.