Skip to content

sinclair/spectrum_ula.cpp: Moved ULA contention related code to separate helper device. Added preliminary ULA early/late timings configuration #14036

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

Open
wants to merge 2 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
10 changes: 5 additions & 5 deletions src/mame/sinclair/atm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ void atm_state::video_start()
m_screen_location = m_ram->pointer() + (5 << 14);
m_char_location = m_char_rom;
subdevice<gfxdecode_device>("gfxdecode")->gfx(0)->set_source(m_char_location);
m_contention_pattern = {};
}

/* F4 Character Displayer */
Expand Down Expand Up @@ -508,6 +507,7 @@ void atm_state::atm(machine_config &config)

m_screen->set_raw(X1_128_SINCLAIR / 5, 448, 312, {get_screen_area().left() - 40, get_screen_area().right() + 40, get_screen_area().top() - 40, get_screen_area().bottom() + 40});
subdevice<gfxdecode_device>("gfxdecode")->set_info(gfx_atm);
SPECTRUM_ULA_UNCONTENDED(config.replace(), m_ula);

BETA_DISK(config, m_beta, 0);
ATA_INTERFACE(config, m_ata).options(atm_ata_devices, nullptr, nullptr, false);
Expand Down Expand Up @@ -596,7 +596,7 @@ ROM_START( atmtb2plus )
ROM_LOAD( "sgen.rom", 0x0000, 0x0800, CRC(1f4387d6) SHA1(93b3774dc8a486643a1bdd48c606b0c84fa0e22b))
ROM_END

/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */
COMP( 1991, atm, spec128, 0, atm, spec_plus, atm_state, empty_init, "MicroART", "ATM-Turbo (ATM-CP)", MACHINE_NOT_WORKING)
COMP( 1992, atmtb2, spec128, 0, atmtb2, spec_plus, atm_state, empty_init, "MicroART", "ATM-Turbo 2", MACHINE_SUPPORTS_SAVE)
COMP( 1993, atmtb2plus, spec128, 0, atmtb2plus, spec_plus, atm_state, empty_init, "MicroART", "ATM-Turbo 2+", MACHINE_SUPPORTS_SAVE)
/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */
COMP( 1991, atm, spec128, 0, atm, spec_plus2a, atm_state, empty_init, "MicroART", "ATM-Turbo (ATM-CP)", MACHINE_NOT_WORKING)
COMP( 1992, atmtb2, spec128, 0, atmtb2, spec_plus2a, atm_state, empty_init, "MicroART", "ATM-Turbo 2", MACHINE_SUPPORTS_SAVE)
COMP( 1993, atmtb2plus, spec128, 0, atmtb2plus, spec_plus2a, atm_state, empty_init, "MicroART", "ATM-Turbo 2+", MACHINE_SUPPORTS_SAVE)
6 changes: 1 addition & 5 deletions src/mame/sinclair/byte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ void byte_state::map_io(address_map &map)

u8 byte_state::kbd_fe_r(offs_t offset)
{
if (!machine().side_effects_disabled())
{
if (is_contended(offset)) content_early();
content_early(1);
}
m_ula->ula_r(offset);

u8 lines = offset >> 8;
u8 data = 0xff;
Expand Down
22 changes: 11 additions & 11 deletions src/mame/sinclair/chloe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class chloe_state : public spectrum_128_state
, m_bank1_view(*this, "bank1_view")
, m_regs_map(*this, "regs_map")
, m_palette(*this, "palette")
, m_ula(*this, "ula")
, m_ula_scr(*this, "ula_scr")
, m_sdcard(*this, "sdcard")
, m_io_line(*this, "IO_LINE%u", 0U)
, m_io_mouse(*this, "mouse_input%u", 1U)
Expand Down Expand Up @@ -103,7 +103,7 @@ class chloe_state : public spectrum_128_state
memory_view m_bank0_view, m_bank1_view;
required_device<address_map_bank_device> m_regs_map;
required_device<device_palette_interface> m_palette;
required_device<screen_ula_plus_device> m_ula;
required_device<screen_ula_plus_device> m_ula_scr;
required_device<spi_sdcard_device> m_sdcard;
required_ioport_array<8> m_io_line;
required_ioport_array<3> m_io_mouse;
Expand Down Expand Up @@ -139,7 +139,7 @@ class chloe_state : public spectrum_128_state
void chloe_state::update_memory()
{
m_screen->update_now();
m_ula->ula_shadow_en_w(BIT(m_port_7ffd_data, 3));
m_ula_scr->ula_shadow_en_w(BIT(m_port_7ffd_data, 3));

const bool ext = BIT(m_port_ff_data, 7); // 0 - DOC 7xxxx=28+; 1 - EXT 6xxxx=24+
m_bank0_view.disable();
Expand Down Expand Up @@ -225,10 +225,10 @@ u32 chloe_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, cons
clip256x192 &= cliprect;

screen.priority().fill(0, cliprect);
m_ula->draw_border(bitmap, cliprect, m_port_fe_data & 0x07);
m_ula_scr->draw_border(bitmap, cliprect, m_port_fe_data & 0x07);

const bool flash = u64(screen.frame_number() / m_frame_invert_count) & 1;
m_ula->draw(screen, bitmap, clip256x192, flash, 0);
m_ula_scr->draw(screen, bitmap, clip256x192, flash, 0);

return 0;
}
Expand All @@ -246,7 +246,7 @@ void chloe_state::port_7ffd_w(u8 data)

void chloe_state::port_ff_w(u8 data)
{
m_ula->port_ff_reg_w(data);
m_ula_scr->port_ff_reg_w(data);

m_port_ff_data = data;
update_memory();
Expand Down Expand Up @@ -525,7 +525,7 @@ void chloe_state::map_io(address_map &map)
}
else if ((m_palpen_selected & 0xc0) == 0x40)
{
m_ula->ulap_en_w(data & 1);
m_ula_scr->ulap_en_w(data & 1);
}
}));
map(0xfc3b, 0xfc3b).lrw8(NAME([this]() { return m_reg_selected; })
Expand Down Expand Up @@ -889,10 +889,9 @@ GFXDECODE_END
void chloe_state::video_start()
{
spectrum_128_state::video_start();
m_contention_pattern = {}; // Has no contention

const u8 *ram = m_ram->pointer();
m_ula->set_host_ram_ptr(ram);
m_ula_scr->set_host_ram_ptr(ram);
}


Expand Down Expand Up @@ -931,9 +930,10 @@ void chloe_state::chloe(machine_config &config)
m_screen->set_raw(25.175_MHz_XTAL, CYCLES_HORIZ, CYCLES_VERT, SCR_FULL); // VGA
m_screen->set_screen_update(FUNC(chloe_state::screen_update));
m_screen->set_no_palette();

PALETTE(config, m_palette, FUNC(chloe_state::spectrum_palette), 256);
SCREEN_ULA_PLUS(config, m_ula, 0).set_raster_offset(SCR_256x192.left(), SCR_256x192.top()).set_palette(m_palette->device().tag(), 0x000, 0x000);
SPECTRUM_ULA_UNCONTENDED(config.replace(), m_ula);

SCREEN_ULA_PLUS(config, m_ula_scr, 0).set_raster_offset(SCR_256x192.left(), SCR_256x192.top()).set_palette(m_palette->device().tag(), 0x000, 0x000);

SPEAKER(config.replace(), "speakers", 2).front();

Expand Down
2 changes: 2 additions & 0 deletions src/mame/sinclair/elwro800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,8 @@ void elwro800_state::elwro800(machine_config &config)
screen.set_palette("palette");
screen.screen_vblank().set_inputline(m_maincpu, 0, HOLD_LINE);

SPECTRUM_ULA_UNCONTENDED(config, m_ula); // dummy for required

PALETTE(config, "palette", FUNC(elwro800_state::spectrum_palette), 16);
GFXDECODE(config, "gfxdecode", "palette", gfx_elwro800);

Expand Down
8 changes: 4 additions & 4 deletions src/mame/sinclair/pentagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ void pentagon_state::machine_reset()
void pentagon_state::video_start()
{
spectrum_128_state::video_start();
m_contention_pattern = {};
}

static const gfx_layout spectrum_charlayout =
Expand Down Expand Up @@ -200,6 +199,7 @@ void pentagon_state::pentagon(machine_config &config)

m_screen->set_raw(14_MHz_XTAL / 2, 448, 320, {get_screen_area().left() - 48, get_screen_area().right() + 48, get_screen_area().top() - 48, get_screen_area().bottom() + 48});
subdevice<gfxdecode_device>("gfxdecode")->set_info(gfx_pentagon);
SPECTRUM_ULA_UNCONTENDED(config.replace(), m_ula);

BETA_DISK(config, m_beta, 0);

Expand Down Expand Up @@ -329,6 +329,6 @@ ROM_END
} // Anonymous namespace


// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
COMP( 1991, pentagon, spec128, 0, pentagon, spec_plus, pentagon_state, empty_init, "Vladimir Drozdov", "Pentagon 128K", 0 )
COMP( 2005, pent1024, spec128, 0, pent1024, spec_plus, pent1024_state, empty_init, "Alex Zhabin", "Pentagon 1024SL", 0 )
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
COMP( 1991, pentagon, spec128, 0, pentagon, spec_plus2a, pentagon_state, empty_init, "Vladimir Drozdov", "Pentagon 128K", 0 )
COMP( 2005, pent1024, spec128, 0, pent1024, spec_plus2a, pent1024_state, empty_init, "Alex Zhabin", "Pentagon 1024SL", 0 )
2 changes: 1 addition & 1 deletion src/mame/sinclair/scorpion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ void scorpion_state::video_start()
{
spectrum_state::video_start();
m_screen_location = m_ram->pointer() + (5 << 14);
m_contention_pattern = {};
}

/* F4 Character Displayer */
Expand Down Expand Up @@ -489,6 +488,7 @@ void scorpion_state::scorpion(machine_config &config)
m_maincpu->nomreq_cb().remove();

subdevice<gfxdecode_device>("gfxdecode")->set_info(gfx_scorpion);
SPECTRUM_ULA_UNCONTENDED(config.replace(), m_ula);

SPEAKER(config.replace(), "speakers", 2).front();

Expand Down
30 changes: 11 additions & 19 deletions src/mame/sinclair/spec128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,11 @@ void spectrum_128_state::video_start()
{
spectrum_state::video_start();
m_screen_location = m_ram->pointer() + (5 << 14);
m_border4t_render_at = 3;
}

uint8_t spectrum_128_state::spectrum_128_pre_opcode_fetch_r(offs_t offset)
{
m_is_m1_rd_contended = false;
if (!machine().side_effects_disabled() && is_contended(offset)) content_early();
m_ula->m1(offset);

/* this allows expansion devices to act upon opcode fetches from MEM addresses
for example, interface1 detection fetches requires fetches at 0008 / 0708 to
Expand All @@ -202,7 +200,7 @@ u8 spectrum_128_state::spectrum_128_rom_r(offs_t offset)
template <u8 Bank> void spectrum_128_state::spectrum_128_ram_w(offs_t offset, u8 data)
{
u16 addr = 0x4000 * Bank + offset;
if (is_contended(addr)) content_early();
m_ula->data_w(addr);
if (is_vram_write(addr)) m_screen->update_now();

((u8*)m_bank_ram[Bank]->base())[offset] = data;
Expand All @@ -214,7 +212,7 @@ template void spectrum_128_state::spectrum_128_ram_w<0>(offs_t offset, u8 data);
template <u8 Bank> u8 spectrum_128_state::spectrum_128_ram_r(offs_t offset)
{
u16 addr = 0x4000 * Bank + offset;
if (!machine().side_effects_disabled() && is_contended(addr)) content_early();
m_ula->data_r(addr);

return ((u8*)m_bank_ram[Bank]->base())[offset];
}
Expand All @@ -225,8 +223,7 @@ template <u8 Bank> u8 spectrum_128_state::spectrum_128_ram_r(offs_t offset)
// D5: Disable paging
void spectrum_128_state::spectrum_128_port_7ffd_w(offs_t offset, uint8_t data)
{
if (is_contended(offset)) content_early();
content_early(1);
m_ula->ula_w(offset);

// disable paging?
if (m_port_7ffd_data & 0x20) return;
Expand All @@ -245,6 +242,7 @@ void spectrum_128_state::spectrum_128_update_memory()
m_bank_rom[0]->set_entry(BIT(m_port_7ffd_data, 4));
// select ram at 0x0c000-0x0ffff
m_bank_ram[3]->set_entry(m_port_7ffd_data & 0x07);
m_ula->bank3_pg_w(m_port_7ffd_data & 0x07);

m_screen->update_now();
if (BIT(m_port_7ffd_data, 3))
Expand All @@ -255,11 +253,7 @@ void spectrum_128_state::spectrum_128_update_memory()

uint8_t spectrum_128_state::spectrum_port_r(offs_t offset)
{
if (!machine().side_effects_disabled() && is_contended(offset))
{
content_early();
content_late();
}
m_ula->io_r(offset);

// Pass through to expansion device if present
if (m_exp->get_card_device())
Expand Down Expand Up @@ -381,12 +375,6 @@ bool spectrum_128_state::is_vram_write(offs_t offset) {
: spectrum_state::is_vram_write(offset);
}

bool spectrum_128_state::is_contended(offs_t offset) {
u8 pg = m_bank_ram[3]->entry();
return spectrum_state::is_contended(offset)
|| ((offset >= 0xc000 && offset <= 0xffff) && (pg & 1)); // Memory pages 1,3,5 and 7 are contended
}

u8 *spectrum_128_state::snow_pattern1_base(u8 i_reg)
{
const bool is_alt_scr_selected = BIT(m_port_7ffd_data, 3);
Expand Down Expand Up @@ -427,7 +415,7 @@ void spectrum_128_state::spectrum_128(machine_config &config)
m_maincpu->set_m1_map(&spectrum_128_state::spectrum_128_fetch);
m_maincpu->set_vblank_int("screen", FUNC(spectrum_128_state::spec_interrupt));
m_maincpu->refresh_cb().set(FUNC(spectrum_128_state::spectrum_refresh_w));
m_maincpu->nomreq_cb().set(FUNC(spectrum_128_state::spectrum_nomreq));
m_maincpu->nomreq_cb().set("ula", FUNC(spectrum_ula_device::nomem_rq));
m_maincpu->busack_cb().set("dma", FUNC(dma_slot_device::bai_w));

config.set_maximum_quantum(attotime::from_hz(60));
Expand All @@ -439,6 +427,10 @@ void spectrum_128_state::spectrum_128(machine_config &config)

subdevice<gfxdecode_device>("gfxdecode")->set_info(spec128);

SPECTRUM_ULA_128K(config.replace(), m_ula);
m_ula->set_z80(m_maincpu);
m_ula->set_screen(m_screen, get_screen_area());

// sound hardware
AY_SLOT(config, "ay_slot", X1_128_SINCLAIR / 20, default_ay_slot_devices, "ay_ay8912")
.add_route(ALL_OUTPUTS, "speakers", 0.25);
Expand Down
1 change: 0 additions & 1 deletion src/mame/sinclair/spec128.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class spectrum_128_state : public spectrum_state
virtual void spectrum_128_update_memory() override;
virtual rectangle get_screen_area() override;

virtual bool is_contended(offs_t offset) override;
virtual bool is_vram_write(offs_t offset) override;
virtual u8 *snow_pattern1_base(u8 i_reg) override;

Expand Down
Loading
Loading