(MESS) zx.c: tagmap cleanups

This commit is contained in:
Wilbert Pol 2013-01-26 15:44:48 +00:00
parent 71bd65a9c1
commit 9e11d7aa10
3 changed files with 127 additions and 100 deletions

View File

@ -20,7 +20,24 @@ class zx_state : public driver_device
{
public:
zx_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag) { }
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_ram(*this, RAM_TAG)
, m_screen(*this, "screen")
, m_cassette(*this, CASSETTE_TAG)
, m_speaker(*this, SPEAKER_TAG)
, m_region_maincpu(*this, "maincpu")
, m_region_gfx1(*this, "gfx1")
, m_io_row0(*this, "ROW0")
, m_io_row1(*this, "ROW1")
, m_io_row2(*this, "ROW2")
, m_io_row3(*this, "ROW3")
, m_io_row4(*this, "ROW4")
, m_io_row5(*this, "ROW5")
, m_io_row6(*this, "ROW6")
, m_io_row7(*this, "ROW7")
, m_io_config(*this, "CONFIG")
{ }
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
@ -61,10 +78,26 @@ public:
TIMER_CALLBACK_MEMBER(zx_tape_pulse);
TIMER_CALLBACK_MEMBER(zx_ula_nmi);
TIMER_CALLBACK_MEMBER(zx_ula_irq);
};
/*----------- defined in video/zx.c -----------*/
void zx_ula_bkgnd(running_machine &machine, int color);
void zx_ula_r(running_machine &machine, int offs, const char *region, const UINT8 param);
protected:
required_device<cpu_device> m_maincpu;
required_device<ram_device> m_ram;
required_device<screen_device> m_screen;
required_device<cassette_image_device> m_cassette;
required_device<device_t> m_speaker;
required_memory_region m_region_maincpu;
optional_memory_region m_region_gfx1;
required_ioport m_io_row0;
required_ioport m_io_row1;
required_ioport m_io_row2;
required_ioport m_io_row3;
required_ioport m_io_row4;
required_ioport m_io_row5;
required_ioport m_io_row6;
required_ioport m_io_row7;
optional_ioport m_io_config;
void zx_ula_r(int offs, memory_region *region, const UINT8 param);
};
#endif /* ZX_H_ */

View File

@ -20,7 +20,7 @@
WRITE8_MEMBER(zx_state::zx_ram_w)
{
UINT8 *RAM = memregion("maincpu")->base();
UINT8 *RAM = m_region_maincpu->base();
RAM[offset + 0x4000] = data;
if (data & 0x40)
@ -38,55 +38,55 @@ WRITE8_MEMBER(zx_state::zx_ram_w)
/* I know this looks really pointless... but it has to be here */
READ8_MEMBER( zx_state::zx_ram_r )
{
UINT8 *RAM = memregion("maincpu")->base();
UINT8 *RAM = m_region_maincpu->base();
return RAM[offset | 0xc000];
}
DRIVER_INIT_MEMBER(zx_state,zx)
{
address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
address_space &space = m_maincpu->space(AS_PROGRAM);
space.install_read_bank(0x4000, 0x4000 + machine().device<ram_device>(RAM_TAG)->size() - 1, "bank1");
space.install_write_handler(0x4000, 0x4000 + machine().device<ram_device>(RAM_TAG)->size() - 1, write8_delegate(FUNC(zx_state::zx_ram_w),this));
membank("bank1")->set_base(memregion("maincpu")->base() + 0x4000);
space.install_read_bank(0x4000, 0x4000 + m_ram->size() - 1, "bank1");
space.install_write_handler(0x4000, 0x4000 + m_ram->size() - 1, write8_delegate(FUNC(zx_state::zx_ram_w),this));
membank("bank1")->set_base(m_region_maincpu->base() + 0x4000);
}
DIRECT_UPDATE_MEMBER(zx_state::zx_setdirect)
{
if (address & 0xc000)
zx_ula_r(machine(), address, "maincpu", 0);
zx_ula_r(address, m_region_maincpu, 0);
return address;
}
DIRECT_UPDATE_MEMBER(zx_state::pc8300_setdirect)
{
if (address & 0xc000)
zx_ula_r(machine(), address, "gfx1", 0);
zx_ula_r(address, m_region_gfx1, 0);
return address;
}
DIRECT_UPDATE_MEMBER(zx_state::pow3000_setdirect)
{
if (address & 0xc000)
zx_ula_r(machine(), address, "gfx1", 1);
zx_ula_r(address, m_region_gfx1, 1);
return address;
}
void zx_state::machine_reset()
{
machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::zx_setdirect), this));
m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::zx_setdirect), this));
m_tape_bit = 0x80;
}
MACHINE_RESET_MEMBER(zx_state,pow3000)
{
machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::pow3000_setdirect), this));
m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::pow3000_setdirect), this));
m_tape_bit = 0x80;
}
MACHINE_RESET_MEMBER(zx_state,pc8300)
{
machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::pc8300_setdirect), this));
m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::pc8300_setdirect), this));
m_tape_bit = 0x80;
}
@ -106,26 +106,26 @@ READ8_MEMBER( zx_state::zx80_io_r )
if (offs == 0xfe)
{
if ((offset & 0x0100) == 0)
data &= ioport("ROW0")->read();
data &= m_io_row0->read();
if ((offset & 0x0200) == 0)
data &= ioport("ROW1")->read();
data &= m_io_row1->read();
if ((offset & 0x0400) == 0)
data &= ioport("ROW2")->read();
data &= m_io_row2->read();
if ((offset & 0x0800) == 0)
data &= ioport("ROW3")->read();
data &= m_io_row3->read();
if ((offset & 0x1000) == 0)
data &= ioport("ROW4")->read();
data &= m_io_row4->read();
if ((offset & 0x2000) == 0)
data &= ioport("ROW5")->read();
data &= m_io_row5->read();
if ((offset & 0x4000) == 0)
data &= ioport("ROW6")->read();
data &= m_io_row6->read();
if ((offset & 0x8000) == 0)
data &= ioport("ROW7")->read();
data &= m_io_row7->read();
if (!ioport("CONFIG")->read())
if (!m_io_config->read())
data &= ~0x40;
machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0);
m_cassette->output(+1.0);
if (m_ula_irq_active)
{
@ -134,7 +134,7 @@ READ8_MEMBER( zx_state::zx80_io_r )
}
// else
// {
if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
if ((m_cassette->input() < -0.75) && m_tape_bit)
{
m_tape_bit = 0x00;
machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
@ -163,26 +163,26 @@ READ8_MEMBER( zx_state::zx81_io_r )
if (offs == 0xfe)
{
if ((offset & 0x0100) == 0)
data &= ioport("ROW0")->read();
data &= m_io_row0->read();
if ((offset & 0x0200) == 0)
data &= ioport("ROW1")->read();
data &= m_io_row1->read();
if ((offset & 0x0400) == 0)
data &= ioport("ROW2")->read();
data &= m_io_row2->read();
if ((offset & 0x0800) == 0)
data &= ioport("ROW3")->read();
data &= m_io_row3->read();
if ((offset & 0x1000) == 0)
data &= ioport("ROW4")->read();
data &= m_io_row4->read();
if ((offset & 0x2000) == 0)
data &= ioport("ROW5")->read();
data &= m_io_row5->read();
if ((offset & 0x4000) == 0)
data &= ioport("ROW6")->read();
data &= m_io_row6->read();
if ((offset & 0x8000) == 0)
data &= ioport("ROW7")->read();
data &= m_io_row7->read();
if (!ioport("CONFIG")->read())
if (!m_io_config->read())
data &= ~0x40;
machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0);
m_cassette->output(+1.0);
if (m_ula_irq_active)
{
@ -191,7 +191,7 @@ READ8_MEMBER( zx_state::zx81_io_r )
}
else
{
if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
if ((m_cassette->input() < -0.75) && m_tape_bit)
{
m_tape_bit = 0x00;
machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
@ -219,34 +219,33 @@ READ8_MEMBER( zx_state::pc8300_io_r )
UINT8 data = 0xff;
UINT8 offs = offset & 0xff;
device_t *speaker = machine().device(SPEAKER_TAG);
if (offs == 0xf5)
{
m_speaker_state ^= 1;
speaker_level_w(speaker, m_speaker_state);
speaker_level_w(m_speaker, m_speaker_state);
}
else
if (offs == 0xfe)
{
if ((offset & 0x0100) == 0)
data &= ioport("ROW0")->read();
data &= m_io_row0->read();
if ((offset & 0x0200) == 0)
data &= ioport("ROW1")->read();
data &= m_io_row1->read();
if ((offset & 0x0400) == 0)
data &= ioport("ROW2")->read();
data &= m_io_row2->read();
if ((offset & 0x0800) == 0)
data &= ioport("ROW3")->read();
data &= m_io_row3->read();
if ((offset & 0x1000) == 0)
data &= ioport("ROW4")->read();
data &= m_io_row4->read();
if ((offset & 0x2000) == 0)
data &= ioport("ROW5")->read();
data &= m_io_row5->read();
if ((offset & 0x4000) == 0)
data &= ioport("ROW6")->read();
data &= m_io_row6->read();
if ((offset & 0x8000) == 0)
data &= ioport("ROW7")->read();
data &= m_io_row7->read();
machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0);
m_cassette->output(+1.0);
if (m_ula_irq_active)
{
@ -255,7 +254,7 @@ READ8_MEMBER( zx_state::pc8300_io_r )
}
else
{
if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
if ((m_cassette->input() < -0.75) && m_tape_bit)
{
m_tape_bit = 0x00;
machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
@ -283,39 +282,38 @@ READ8_MEMBER( zx_state::pow3000_io_r )
UINT8 data = 0xff;
UINT8 offs = offset & 0xff;
device_t *speaker = machine().device(SPEAKER_TAG);
if (offs == 0x7e)
{
data = (ioport("CONFIG")->read());
data = (m_io_config->read());
}
else
if (offs == 0xf5)
{
m_speaker_state ^= 1;
speaker_level_w(speaker, m_speaker_state);
speaker_level_w(m_speaker, m_speaker_state);
}
else
if (offs == 0xfe)
{
if ((offset & 0x0100) == 0)
data &= ioport("ROW0")->read();
data &= m_io_row0->read();
if ((offset & 0x0200) == 0)
data &= ioport("ROW1")->read();
data &= m_io_row1->read();
if ((offset & 0x0400) == 0)
data &= ioport("ROW2")->read();
data &= m_io_row2->read();
if ((offset & 0x0800) == 0)
data &= ioport("ROW3")->read();
data &= m_io_row3->read();
if ((offset & 0x1000) == 0)
data &= ioport("ROW4")->read();
data &= m_io_row4->read();
if ((offset & 0x2000) == 0)
data &= ioport("ROW5")->read();
data &= m_io_row5->read();
if ((offset & 0x4000) == 0)
data &= ioport("ROW6")->read();
data &= m_io_row6->read();
if ((offset & 0x8000) == 0)
data &= ioport("ROW7")->read();
data &= m_io_row7->read();
machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0);
m_cassette->output(+1.0);
if (m_ula_irq_active)
{
@ -324,7 +322,7 @@ READ8_MEMBER( zx_state::pow3000_io_r )
}
else
{
if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
if ((m_cassette->input() < -0.75) && m_tape_bit)
{
m_tape_bit = 0x00;
machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
@ -348,12 +346,11 @@ WRITE8_MEMBER( zx_state::zx80_io_w )
UINT8 offs = offset & 0xff;
if (offs == 0xff)
machine().device<cassette_image_device>(CASSETTE_TAG)->output(-1.0);
m_cassette->output(-1.0);
}
WRITE8_MEMBER( zx_state::zx81_io_w )
{
address_space &mem = machine().device("maincpu")->memory().space(AS_PROGRAM);
/* port F5 = unknown, pc8300/pow3000/lambda only
F6 = unknown, pc8300/pow3000/lambda only
FB = write data to printer, not emulated
@ -361,8 +358,7 @@ WRITE8_MEMBER( zx_state::zx81_io_w )
FE = turn on NMI generator
FF = write HSYNC and cass data */
screen_device *screen = machine().first_screen();
int height = screen->height();
int height = m_screen->height();
UINT8 offs = offset & 0xff;
if (offs == 0xfd)
@ -372,7 +368,7 @@ WRITE8_MEMBER( zx_state::zx81_io_w )
else
if (offs == 0xfe)
{
m_ula_nmi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(207));
m_ula_nmi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(207));
/* remove the IRQ */
m_ula_irq_active = 0;
@ -380,13 +376,13 @@ WRITE8_MEMBER( zx_state::zx81_io_w )
else
if (offs == 0xff)
{
machine().device<cassette_image_device>(CASSETTE_TAG)->output(-1.0);
m_cassette->output(-1.0);
zx_ula_bkgnd(1);
if (m_ula_frame_vsync == 2)
{
mem.device().execute().spin_until_time(machine().primary_screen->time_until_pos(height - 1, 0));
m_maincpu->spin_until_time(m_screen->time_until_pos(height - 1, 0));
m_ula_scanline_count = height - 1;
logerror ("S: %d B: %d\n", machine().primary_screen->vpos(), machine().primary_screen->hpos());
logerror ("S: %d B: %d\n", m_screen->vpos(), m_screen->hpos());
}
}
}

View File

@ -120,55 +120,53 @@ TIMER_CALLBACK_MEMBER(zx_state::zx_ula_irq)
}
}
void zx_ula_r(running_machine &machine, int offs, const char *region, const UINT8 param)
void zx_state::zx_ula_r(int offs, memory_region *region, const UINT8 param)
{
zx_state *state = machine.driver_data<zx_state>();
screen_device *screen = machine.first_screen();
int offs0 = offs & 0x7fff;
UINT8 *rom = machine.root_device().memregion("maincpu")->base();
UINT8 *rom = m_region_maincpu->base();
UINT8 chr = rom[offs0];
if ((!state->m_ula_irq_active) && (chr == 0x76))
if ((!m_ula_irq_active) && (chr == 0x76))
{
bitmap_ind16 &bitmap = state->m_bitmap;
bitmap_ind16 &bitmap = m_bitmap;
UINT16 y, *scanline;
UINT16 ireg = machine.device("maincpu")->state().state_int(Z80_I) << 8;
UINT16 ireg = m_maincpu->state_int(Z80_I) << 8;
UINT8 data, *chrgen, creg;
if (param)
creg = machine.device("maincpu")->state().state_int(Z80_B);
creg = m_maincpu->state_int(Z80_B);
else
creg = machine.device("maincpu")->state().state_int(Z80_C);
creg = m_maincpu->state_int(Z80_C);
chrgen = state->memregion(region)->base();
chrgen = region->base();
if ((++state->m_ula_scanline_count == screen->height()) || (creg == 32))
if ((++m_ula_scanline_count == m_screen->height()) || (creg == 32))
{
state->m_ula_scanline_count = 0;
state->m_offs1 = offs0;
m_ula_scanline_count = 0;
m_offs1 = offs0;
}
state->m_ula_frame_vsync = 3;
m_ula_frame_vsync = 3;
state->m_charline_ptr = 0;
m_charline_ptr = 0;
for (y = state->m_offs1+1; ((y < offs0) && (state->m_charline_ptr < ARRAY_LENGTH(state->m_charline))); y++)
for (y = m_offs1+1; ((y < offs0) && (m_charline_ptr < ARRAY_LENGTH(m_charline))); y++)
{
state->m_charline[state->m_charline_ptr] = rom[y];
state->m_charline_ptr++;
m_charline[m_charline_ptr] = rom[y];
m_charline_ptr++;
}
for (y = state->m_charline_ptr; y < ARRAY_LENGTH(state->m_charline); y++)
state->m_charline[y] = 0;
for (y = m_charline_ptr; y < ARRAY_LENGTH(m_charline); y++)
m_charline[y] = 0;
machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(((32 - state->m_charline_ptr) << 2)), timer_expired_delegate(FUNC(zx_state::zx_ula_irq),state));
state->m_ula_irq_active++;
machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(((32 - m_charline_ptr) << 2)), timer_expired_delegate(FUNC(zx_state::zx_ula_irq),this));
m_ula_irq_active++;
scanline = &bitmap.pix16(state->m_ula_scanline_count);
scanline = &bitmap.pix16(m_ula_scanline_count);
y = 0;
for (state->m_charline_ptr = 0; state->m_charline_ptr < ARRAY_LENGTH(state->m_charline); state->m_charline_ptr++)
for (m_charline_ptr = 0; m_charline_ptr < ARRAY_LENGTH(m_charline); m_charline_ptr++)
{
chr = state->m_charline[state->m_charline_ptr];
chr = m_charline[m_charline_ptr];
data = chrgen[ireg | ((chr & 0x3f) << 3) | ((8 - creg)&7) ];
if (chr & 0x80) data ^= 0xff;
@ -180,10 +178,10 @@ void zx_ula_r(running_machine &machine, int offs, const char *region, const UINT
scanline[y++] = (data >> 2) & 1;
scanline[y++] = (data >> 1) & 1;
scanline[y++] = (data >> 0) & 1;
state->m_charline[state->m_charline_ptr] = 0;
m_charline[m_charline_ptr] = 0;
}
if (creg == 1) state->m_offs1 = offs0;
if (creg == 1) m_offs1 = offs0;
}
}
@ -191,7 +189,7 @@ void zx_state::video_start()
{
m_ula_nmi = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(zx_state::zx_ula_nmi),this));
m_ula_irq_active = 0;
machine().primary_screen->register_screen_bitmap(m_bitmap);
m_screen->register_screen_bitmap(m_bitmap);
}
void zx_state::screen_eof_zx(screen_device &screen, bool state)