Skip to content

Commit b0f6984

Browse files
committed
sinclair/spectrum_ula.cpp: Moved ULA contention related code to separate helper device. Added preliminary ULA early/late timings configuration
1 parent eb8676c commit b0f6984

18 files changed

+499
-210
lines changed

src/mame/sinclair/atm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ void atm_state::video_start()
453453
m_screen_location = m_ram->pointer() + (5 << 14);
454454
m_char_location = m_char_rom;
455455
subdevice<gfxdecode_device>("gfxdecode")->gfx(0)->set_source(m_char_location);
456-
m_contention_pattern = {};
457456
}
458457

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

509508
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});
510509
subdevice<gfxdecode_device>("gfxdecode")->set_info(gfx_atm);
510+
SPECTRUM_ULA_UNCONTENDED(config.replace(), m_ula);
511511

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

599-
/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */
600-
COMP( 1991, atm, spec128, 0, atm, spec_plus, atm_state, empty_init, "MicroART", "ATM-Turbo (ATM-CP)", MACHINE_NOT_WORKING)
601-
COMP( 1992, atmtb2, spec128, 0, atmtb2, spec_plus, atm_state, empty_init, "MicroART", "ATM-Turbo 2", MACHINE_SUPPORTS_SAVE)
602-
COMP( 1993, atmtb2plus, spec128, 0, atmtb2plus, spec_plus, atm_state, empty_init, "MicroART", "ATM-Turbo 2+", MACHINE_SUPPORTS_SAVE)
599+
/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */
600+
COMP( 1991, atm, spec128, 0, atm, spec_plus2a, atm_state, empty_init, "MicroART", "ATM-Turbo (ATM-CP)", MACHINE_NOT_WORKING)
601+
COMP( 1992, atmtb2, spec128, 0, atmtb2, spec_plus2a, atm_state, empty_init, "MicroART", "ATM-Turbo 2", MACHINE_SUPPORTS_SAVE)
602+
COMP( 1993, atmtb2plus, spec128, 0, atmtb2plus, spec_plus2a, atm_state, empty_init, "MicroART", "ATM-Turbo 2+", MACHINE_SUPPORTS_SAVE)

src/mame/sinclair/byte.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ void byte_state::map_io(address_map &map)
8585

8686
u8 byte_state::kbd_fe_r(offs_t offset)
8787
{
88-
if (!machine().side_effects_disabled())
89-
{
90-
if (is_contended(offset)) content_early();
91-
content_early(1);
92-
}
88+
m_ula->ula_r(offset);
9389

9490
u8 lines = offset >> 8;
9591
u8 data = 0xff;

src/mame/sinclair/chloe.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class chloe_state : public spectrum_128_state
5050
, m_bank1_view(*this, "bank1_view")
5151
, m_regs_map(*this, "regs_map")
5252
, m_palette(*this, "palette")
53-
, m_ula(*this, "ula")
53+
, m_ula_scr(*this, "ula_scr")
5454
, m_sdcard(*this, "sdcard")
5555
, m_io_line(*this, "IO_LINE%u", 0U)
5656
, m_io_mouse(*this, "mouse_input%u", 1U)
@@ -103,7 +103,7 @@ class chloe_state : public spectrum_128_state
103103
memory_view m_bank0_view, m_bank1_view;
104104
required_device<address_map_bank_device> m_regs_map;
105105
required_device<device_palette_interface> m_palette;
106-
required_device<screen_ula_plus_device> m_ula;
106+
required_device<screen_ula_plus_device> m_ula_scr;
107107
required_device<spi_sdcard_device> m_sdcard;
108108
required_ioport_array<8> m_io_line;
109109
required_ioport_array<3> m_io_mouse;
@@ -139,7 +139,7 @@ class chloe_state : public spectrum_128_state
139139
void chloe_state::update_memory()
140140
{
141141
m_screen->update_now();
142-
m_ula->ula_shadow_en_w(BIT(m_port_7ffd_data, 3));
142+
m_ula_scr->ula_shadow_en_w(BIT(m_port_7ffd_data, 3));
143143

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

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

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

233233
return 0;
234234
}
@@ -246,7 +246,7 @@ void chloe_state::port_7ffd_w(u8 data)
246246

247247
void chloe_state::port_ff_w(u8 data)
248248
{
249-
m_ula->port_ff_reg_w(data);
249+
m_ula_scr->port_ff_reg_w(data);
250250

251251
m_port_ff_data = data;
252252
update_memory();
@@ -525,7 +525,7 @@ void chloe_state::map_io(address_map &map)
525525
}
526526
else if ((m_palpen_selected & 0xc0) == 0x40)
527527
{
528-
m_ula->ulap_en_w(data & 1);
528+
m_ula_scr->ulap_en_w(data & 1);
529529
}
530530
}));
531531
map(0xfc3b, 0xfc3b).lrw8(NAME([this]() { return m_reg_selected; })
@@ -889,10 +889,9 @@ GFXDECODE_END
889889
void chloe_state::video_start()
890890
{
891891
spectrum_128_state::video_start();
892-
m_contention_pattern = {}; // Has no contention
893892

894893
const u8 *ram = m_ram->pointer();
895-
m_ula->set_host_ram_ptr(ram);
894+
m_ula_scr->set_host_ram_ptr(ram);
896895
}
897896

898897

@@ -931,9 +930,10 @@ void chloe_state::chloe(machine_config &config)
931930
m_screen->set_raw(25.175_MHz_XTAL, CYCLES_HORIZ, CYCLES_VERT, SCR_FULL); // VGA
932931
m_screen->set_screen_update(FUNC(chloe_state::screen_update));
933932
m_screen->set_no_palette();
934-
935933
PALETTE(config, m_palette, FUNC(chloe_state::spectrum_palette), 256);
936-
SCREEN_ULA_PLUS(config, m_ula, 0).set_raster_offset(SCR_256x192.left(), SCR_256x192.top()).set_palette(m_palette->device().tag(), 0x000, 0x000);
934+
SPECTRUM_ULA_UNCONTENDED(config.replace(), m_ula);
935+
936+
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);
937937

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

src/mame/sinclair/elwro800.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,8 @@ void elwro800_state::elwro800(machine_config &config)
567567
screen.set_palette("palette");
568568
screen.screen_vblank().set_inputline(m_maincpu, 0, HOLD_LINE);
569569

570+
SPECTRUM_ULA_UNCONTENDED(config, m_ula); // dummy for required
571+
570572
PALETTE(config, "palette", FUNC(elwro800_state::spectrum_palette), 16);
571573
GFXDECODE(config, "gfxdecode", "palette", gfx_elwro800);
572574

src/mame/sinclair/pentagon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ void pentagon_state::machine_reset()
167167
void pentagon_state::video_start()
168168
{
169169
spectrum_128_state::video_start();
170-
m_contention_pattern = {};
171170
}
172171

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

201200
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});
202201
subdevice<gfxdecode_device>("gfxdecode")->set_info(gfx_pentagon);
202+
SPECTRUM_ULA_UNCONTENDED(config.replace(), m_ula);
203203

204204
BETA_DISK(config, m_beta, 0);
205205

@@ -329,6 +329,6 @@ ROM_END
329329
} // Anonymous namespace
330330

331331

332-
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
333-
COMP( 1991, pentagon, spec128, 0, pentagon, spec_plus, pentagon_state, empty_init, "Vladimir Drozdov", "Pentagon 128K", 0 )
334-
COMP( 2005, pent1024, spec128, 0, pent1024, spec_plus, pent1024_state, empty_init, "Alex Zhabin", "Pentagon 1024SL", 0 )
332+
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
333+
COMP( 1991, pentagon, spec128, 0, pentagon, spec_plus2a, pentagon_state, empty_init, "Vladimir Drozdov", "Pentagon 128K", 0 )
334+
COMP( 2005, pent1024, spec128, 0, pent1024, spec_plus2a, pent1024_state, empty_init, "Alex Zhabin", "Pentagon 1024SL", 0 )

src/mame/sinclair/scorpion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ void scorpion_state::video_start()
400400
{
401401
spectrum_state::video_start();
402402
m_screen_location = m_ram->pointer() + (5 << 14);
403-
m_contention_pattern = {};
404403
}
405404

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

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

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

src/mame/sinclair/spec128.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,11 @@ void spectrum_128_state::video_start()
169169
{
170170
spectrum_state::video_start();
171171
m_screen_location = m_ram->pointer() + (5 << 14);
172-
m_border4t_render_at = 3;
173172
}
174173

175174
uint8_t spectrum_128_state::spectrum_128_pre_opcode_fetch_r(offs_t offset)
176175
{
177-
m_is_m1_rd_contended = false;
178-
if (!machine().side_effects_disabled() && is_contended(offset)) content_early();
176+
m_ula->m1(offset);
179177

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

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

219217
return ((u8*)m_bank_ram[Bank]->base())[offset];
220218
}
@@ -225,8 +223,7 @@ template <u8 Bank> u8 spectrum_128_state::spectrum_128_ram_r(offs_t offset)
225223
// D5: Disable paging
226224
void spectrum_128_state::spectrum_128_port_7ffd_w(offs_t offset, uint8_t data)
227225
{
228-
if (is_contended(offset)) content_early();
229-
content_early(1);
226+
m_ula->ula_w(offset);
230227

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

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

256254
uint8_t spectrum_128_state::spectrum_port_r(offs_t offset)
257255
{
258-
if (!machine().side_effects_disabled() && is_contended(offset))
259-
{
260-
content_early();
261-
content_late();
262-
}
256+
m_ula->io_r(offset);
263257

264258
// Pass through to expansion device if present
265259
if (m_exp->get_card_device())
@@ -381,12 +375,6 @@ bool spectrum_128_state::is_vram_write(offs_t offset) {
381375
: spectrum_state::is_vram_write(offset);
382376
}
383377

384-
bool spectrum_128_state::is_contended(offs_t offset) {
385-
u8 pg = m_bank_ram[3]->entry();
386-
return spectrum_state::is_contended(offset)
387-
|| ((offset >= 0xc000 && offset <= 0xffff) && (pg & 1)); // Memory pages 1,3,5 and 7 are contended
388-
}
389-
390378
u8 *spectrum_128_state::snow_pattern1_base(u8 i_reg)
391379
{
392380
const bool is_alt_scr_selected = BIT(m_port_7ffd_data, 3);
@@ -427,7 +415,7 @@ void spectrum_128_state::spectrum_128(machine_config &config)
427415
m_maincpu->set_m1_map(&spectrum_128_state::spectrum_128_fetch);
428416
m_maincpu->set_vblank_int("screen", FUNC(spectrum_128_state::spec_interrupt));
429417
m_maincpu->refresh_cb().set(FUNC(spectrum_128_state::spectrum_refresh_w));
430-
m_maincpu->nomreq_cb().set(FUNC(spectrum_128_state::spectrum_nomreq));
418+
m_maincpu->nomreq_cb().set("ula", FUNC(spectrum_ula_device::nomem_rq));
431419
m_maincpu->busack_cb().set("dma", FUNC(dma_slot_device::bai_w));
432420

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

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

430+
SPECTRUM_ULA_128K(config.replace(), m_ula);
431+
m_ula->set_z80(m_maincpu);
432+
m_ula->set_screen(m_screen, get_screen_area());
433+
442434
// sound hardware
443435
AY_SLOT(config, "ay_slot", X1_128_SINCLAIR / 20, default_ay_slot_devices, "ay_ay8912")
444436
.add_route(ALL_OUTPUTS, "speakers", 0.25);

src/mame/sinclair/spec128.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class spectrum_128_state : public spectrum_state
3636
virtual void spectrum_128_update_memory() override;
3737
virtual rectangle get_screen_area() override;
3838

39-
virtual bool is_contended(offs_t offset) override;
4039
virtual bool is_vram_write(offs_t offset) override;
4140
virtual u8 *snow_pattern1_base(u8 i_reg) override;
4241

0 commit comments

Comments
 (0)