summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/devices/bus/z88/z88.cpp34
-rw-r--r--src/devices/bus/z88/z88.h9
-rw-r--r--src/mame/drivers/policetr.cpp2
-rw-r--r--src/mame/drivers/z88.cpp128
-rw-r--r--src/mame/includes/z88.h34
5 files changed, 95 insertions, 112 deletions
diff --git a/src/devices/bus/z88/z88.cpp b/src/devices/bus/z88/z88.cpp
index 9f7b7fb3172..bed0141b012 100644
--- a/src/devices/bus/z88/z88.cpp
+++ b/src/devices/bus/z88/z88.cpp
@@ -55,20 +55,13 @@ device_z88cart_interface::~device_z88cart_interface()
//-------------------------------------------------
// z88cart_slot_device - constructor
//-------------------------------------------------
-z88cart_slot_device::z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- device_t(mconfig, Z88CART_SLOT, tag, owner, clock),
- device_image_interface(mconfig, *this),
- device_slot_interface(mconfig, *this),
- m_out_flp_cb(*this),
- m_cart(nullptr), m_flp_timer(nullptr)
-{
-}
-
-//-------------------------------------------------
-// z88cart_slot_device - destructor
-//-------------------------------------------------
-
-z88cart_slot_device::~z88cart_slot_device()
+z88cart_slot_device::z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, Z88CART_SLOT, tag, owner, clock)
+ , device_image_interface(mconfig, *this)
+ , device_slot_interface(mconfig, *this)
+ , m_out_flp_cb(*this)
+ , m_cart(nullptr)
+ , m_flp_timer(nullptr)
{
}
@@ -109,24 +102,25 @@ image_init_result z88cart_slot_device::call_load()
{
if (m_cart)
{
- offs_t read_length;
uint8_t *cart_base = m_cart->get_cart_base();
if (cart_base != nullptr)
{
if (!loaded_through_softlist())
{
- read_length = length();
+ offs_t read_length = length();
fread(cart_base + (m_cart->get_cart_size() - read_length), read_length);
}
else
{
- read_length = get_software_region_length("rom");
+ offs_t read_length = get_software_region_length("rom");
memcpy(cart_base + (m_cart->get_cart_size() - read_length), get_software_region("rom"), read_length);
}
}
else
+ {
return image_init_result::FAIL;
+ }
}
// open the flap
@@ -147,9 +141,11 @@ void z88cart_slot_device::call_unload()
{
if (m_cart)
{
- auto cart_size = m_cart->get_cart_size();
- if (cart_size>0)
+ size_t cart_size = m_cart->get_cart_size();
+ if (cart_size > 0)
+ {
memset(m_cart->get_cart_base(), 0xff, cart_size);
+ }
}
// open the flap
diff --git a/src/devices/bus/z88/z88.h b/src/devices/bus/z88/z88.h
index 8481c3e7780..c1337cab5cf 100644
--- a/src/devices/bus/z88/z88.h
+++ b/src/devices/bus/z88/z88.h
@@ -90,8 +90,7 @@ class z88cart_slot_device : public device_t,
{
public:
// construction/destruction
- z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual ~z88cart_slot_device();
+ z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
template <class Object> devcb_base &set_out_flp_callback(Object &&cb) { return m_out_flp_cb.set_callback(std::forward<Object>(cb)); }
@@ -125,9 +124,9 @@ protected:
private:
static constexpr device_timer_id TIMER_FLP_CLEAR = 0;
- devcb_write_line m_out_flp_cb;
- device_z88cart_interface* m_cart;
- emu_timer * m_flp_timer;
+ devcb_write_line m_out_flp_cb;
+ device_z88cart_interface* m_cart;
+ emu_timer * m_flp_timer;
};
diff --git a/src/mame/drivers/policetr.cpp b/src/mame/drivers/policetr.cpp
index 4295a3baec9..e8520cb5b89 100644
--- a/src/mame/drivers/policetr.cpp
+++ b/src/mame/drivers/policetr.cpp
@@ -404,7 +404,7 @@ MACHINE_CONFIG_START(policetr_state::policetr)
EEPROM_SERIAL_93C66_16BIT(config, m_eeprom);
/* video hardware */
- MCFG_DEVICE_ADD(m_screen, SCREEN, SCREEN_TYPE_RASTER);
+ device = &SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_video_attributes(VIDEO_UPDATE_BEFORE_VBLANK);
m_screen->set_refresh_hz(60);
m_screen->set_size(400, 262); /* needs to be verified */
diff --git a/src/mame/drivers/z88.cpp b/src/mame/drivers/z88.cpp
index 108ce972bc0..3daa1f4e710 100644
--- a/src/mame/drivers/z88.cpp
+++ b/src/mame/drivers/z88.cpp
@@ -21,10 +21,6 @@
#include "emu.h"
#include "includes/z88.h"
-#include "screen.h"
-#include "speaker.h"
-
-
/* Assumption:
all banks can access the same memory blocks in the same way.
@@ -63,9 +59,6 @@ WRITE8_MEMBER(z88_state::bank3_cart_w) { m_carts[m_bank[3].slot]->write(space, (
UPD65031_MEMORY_UPDATE(z88_state::bankswitch_update)
{
- char bank_tag[6];
- sprintf(bank_tag, "bank%d", bank + 2);
-
// bank 0 is always even
if (bank == 0) page &= 0xfe;
@@ -74,12 +67,12 @@ UPD65031_MEMORY_UPDATE(z88_state::bankswitch_update)
// install read bank
if (m_bank_type[bank] != Z88_BANK_ROM)
{
- m_maincpu->space(AS_PROGRAM).install_read_bank(bank<<14, (bank<<14) + 0x3fff, bank_tag);
+ m_maincpu->space(AS_PROGRAM).install_read_bank(bank<<14, (bank<<14) + 0x3fff, m_banks[bank + 1]);
m_maincpu->space(AS_PROGRAM).unmap_write(bank<<14, (bank<<14) + 0x3fff);
m_bank_type[bank] = Z88_BANK_ROM;
}
- membank(bank_tag)->set_entry(page);
+ m_banks[bank + 1]->set_entry(page);
}
else if (page < 0x40) // internal RAM
{
@@ -88,12 +81,12 @@ UPD65031_MEMORY_UPDATE(z88_state::bankswitch_update)
// install readwrite bank
if (m_bank_type[bank] != Z88_BANK_RAM)
{
- m_maincpu->space(AS_PROGRAM).install_readwrite_bank(bank<<14, (bank<<14) + 0x3fff, bank_tag);
+ m_maincpu->space(AS_PROGRAM).install_readwrite_bank(bank<<14, (bank<<14) + 0x3fff, m_banks[bank + 1]);
m_bank_type[bank] = Z88_BANK_RAM;
}
// set the bank
- membank(bank_tag)->set_entry(page);
+ m_banks[bank + 1]->set_entry(page);
}
else
{
@@ -135,31 +128,31 @@ UPD65031_MEMORY_UPDATE(z88_state::bankswitch_update)
// override setting for lower 8k of bank 0
if (bank == 0)
{
- m_maincpu->space(AS_PROGRAM).install_read_bank(0, 0x1fff, "bank1");
+ m_maincpu->space(AS_PROGRAM).install_read_bank(0, 0x1fff, m_banks[0]);
// enable RAM
if (rams)
- m_maincpu->space(AS_PROGRAM).install_write_bank(0, 0x1fff, "bank1");
+ m_maincpu->space(AS_PROGRAM).install_write_bank(0, 0x1fff, m_banks[0]);
else
m_maincpu->space(AS_PROGRAM).unmap_write(0, 0x1fff);
- membank("bank1")->set_entry(rams & 1);
+ m_banks[0]->set_entry(rams & 1);
}
}
void z88_state::z88_mem(address_map &map)
{
- map(0x0000, 0x1fff).bankrw("bank1");
- map(0x2000, 0x3fff).bankrw("bank2");
- map(0x4000, 0x7fff).bankrw("bank3");
- map(0x8000, 0xbfff).bankrw("bank4");
- map(0xc000, 0xffff).bankrw("bank5");
+ map(0x0000, 0x1fff).bankrw(m_banks[0]);
+ map(0x2000, 0x3fff).bankrw(m_banks[1]);
+ map(0x4000, 0x7fff).bankrw(m_banks[2]);
+ map(0x8000, 0xbfff).bankrw(m_banks[3]);
+ map(0xc000, 0xffff).bankrw(m_banks[4]);
}
void z88_state::z88_io(address_map &map)
{
- map(0x0000, 0xffff).rw("blink", FUNC(upd65031_device::read), FUNC(upd65031_device::write));
+ map(0x0000, 0xffff).rw(m_blink, FUNC(upd65031_device::read), FUNC(upd65031_device::write));
}
@@ -556,24 +549,21 @@ INPUT_PORTS_END
void z88_state::machine_start()
{
- m_bios = (uint8_t*)memregion("bios")->base();
+ m_bios = (uint8_t*)m_bios_region->base();
m_ram_base = (uint8_t*)m_ram->pointer();
// configure the memory banks
- membank("bank1")->configure_entry(0, m_bios);
- membank("bank1")->configure_entry(1, m_ram_base);
- membank("bank2")->configure_entries(0, 32, m_bios, 0x4000);
- membank("bank3")->configure_entries(0, 32, m_bios, 0x4000);
- membank("bank4")->configure_entries(0, 32, m_bios, 0x4000);
- membank("bank5")->configure_entries(0, 32, m_bios, 0x4000);
- membank("bank2")->configure_entries(32, m_ram->size()>>14, m_ram_base, 0x4000);
- membank("bank3")->configure_entries(32, m_ram->size()>>14, m_ram_base, 0x4000);
- membank("bank4")->configure_entries(32, m_ram->size()>>14, m_ram_base, 0x4000);
- membank("bank5")->configure_entries(32, m_ram->size()>>14, m_ram_base, 0x4000);
-
- m_carts[1] = machine().device<z88cart_slot_device>("slot1");
- m_carts[2] = machine().device<z88cart_slot_device>("slot2");
- m_carts[3] = machine().device<z88cart_slot_device>("slot3");
+
+ m_banks[0]->configure_entry(0, m_bios);
+ m_banks[0]->configure_entry(1, m_ram_base);
+ m_banks[1]->configure_entries(0, 32, m_bios, 0x4000);
+ m_banks[2]->configure_entries(0, 32, m_bios, 0x4000);
+ m_banks[3]->configure_entries(0, 32, m_bios, 0x4000);
+ m_banks[4]->configure_entries(0, 32, m_bios, 0x4000);
+ m_banks[1]->configure_entries(32, m_ram->size()>>14, m_ram_base, 0x4000);
+ m_banks[2]->configure_entries(32, m_ram->size()>>14, m_ram_base, 0x4000);
+ m_banks[3]->configure_entries(32, m_ram->size()>>14, m_ram_base, 0x4000);
+ m_banks[4]->configure_entries(32, m_ram->size()>>14, m_ram_base, 0x4000);
}
void z88_state::machine_reset()
@@ -585,29 +575,11 @@ READ8_MEMBER(z88_state::kb_r)
{
uint8_t data = 0xff;
- if (!(offset & 0x80))
- data &= ioport("LINE7")->read();
-
- if (!(offset & 0x40))
- data &= ioport("LINE6")->read();
-
- if (!(offset & 0x20))
- data &= ioport("LINE5")->read();
-
- if (!(offset & 0x10))
- data &= ioport("LINE4")->read();
-
- if (!(offset & 0x08))
- data &= ioport("LINE3")->read();
-
- if (!(offset & 0x04))
- data &= ioport("LINE2")->read();
-
- if (!(offset & 0x02))
- data &= ioport("LINE1")->read();
-
- if (!(offset & 0x01))
- data &= ioport("LINE0")->read();
+ for (int i = 7; i >= 0; i--)
+ {
+ if (!BIT(offset, i))
+ data &= m_lines[i]->read();
+ }
return data;
}
@@ -626,36 +598,36 @@ static void z88_cart(device_slot_interface &device)
MACHINE_CONFIG_START(z88_state::z88)
/* basic machine hardware */
- MCFG_DEVICE_ADD("maincpu", Z80, XTAL(9'830'400)/3) // divided by 3 through the uPD65031
- MCFG_DEVICE_PROGRAM_MAP(z88_mem)
- MCFG_DEVICE_IO_MAP(z88_io)
+ Z80(config, m_maincpu, XTAL(9'830'400)/3); // divided by 3 through the uPD65031
+ m_maincpu->set_addrmap(AS_PROGRAM, &z88_state::z88_mem);
+ m_maincpu->set_addrmap(AS_IO, &z88_state::z88_io);
/* video hardware */
- MCFG_SCREEN_ADD("screen", LCD)
- MCFG_SCREEN_REFRESH_RATE(50)
- MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
- MCFG_SCREEN_SIZE(Z88_SCREEN_WIDTH, Z88_SCREEN_HEIGHT)
- MCFG_SCREEN_VISIBLE_AREA(0, (Z88_SCREEN_WIDTH - 1), 0, (Z88_SCREEN_HEIGHT - 1))
+ device = &SCREEN(config, m_screen, SCREEN_TYPE_LCD);
+ m_screen->set_refresh_hz(50);
+ m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
+ m_screen->set_size(Z88_SCREEN_WIDTH, Z88_SCREEN_HEIGHT);
+ m_screen->set_visarea(0, (Z88_SCREEN_WIDTH - 1), 0, (Z88_SCREEN_HEIGHT - 1));
+ m_screen->set_palette(m_palette);
MCFG_SCREEN_UPDATE_DEVICE("blink", upd65031_device, screen_update)
- MCFG_SCREEN_PALETTE("palette")
- MCFG_PALETTE_ADD("palette", Z88_NUM_COLOURS)
+ MCFG_PALETTE_ADD(m_palette, Z88_NUM_COLOURS)
MCFG_PALETTE_INIT_OWNER(z88_state, z88)
MCFG_DEFAULT_LAYOUT(layout_lcd)
- MCFG_DEVICE_ADD("blink", UPD65031, XTAL(9'830'400))
+ MCFG_DEVICE_ADD(m_blink, UPD65031, XTAL(9'830'400))
MCFG_UPD65031_KB_CALLBACK(READ8(*this, z88_state, kb_r))
- MCFG_UPD65031_INT_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_IRQ0))
- MCFG_UPD65031_NMI_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_NMI))
- MCFG_UPD65031_SPKR_CALLBACK(WRITELINE("speaker", speaker_sound_device, level_w))
+ MCFG_UPD65031_INT_CALLBACK(INPUTLINE(m_maincpu, INPUT_LINE_IRQ0))
+ MCFG_UPD65031_NMI_CALLBACK(INPUTLINE(m_maincpu, INPUT_LINE_NMI))
+ MCFG_UPD65031_SPKR_CALLBACK(WRITELINE(m_speaker, speaker_sound_device, level_w))
MCFG_UPD65031_SCR_UPDATE_CB(z88_state, lcd_update)
MCFG_UPD65031_MEM_UPDATE_CB(z88_state, bankswitch_update)
/* sound hardware */
- SPEAKER(config, "mono").front_center();
- MCFG_DEVICE_ADD("speaker", SPEAKER_SOUND)
- MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
+ SPEAKER(config, m_mono).front_center();
+ SPEAKER_SOUND(config, m_speaker);
+ m_speaker->add_route(ALL_OUTPUTS, "mono", 0.50);
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)
@@ -663,13 +635,13 @@ MACHINE_CONFIG_START(z88_state::z88)
MCFG_RAM_EXTRA_OPTIONS("32K,64K,256K,512k")
/* cartridges */
- MCFG_DEVICE_ADD("slot1", Z88CART_SLOT, 0)
+ MCFG_DEVICE_ADD(m_carts[1], Z88CART_SLOT)
MCFG_DEVICE_SLOT_INTERFACE(z88_cart, nullptr, false)
MCFG_Z88CART_SLOT_OUT_FLP_CB(WRITELINE("blink", upd65031_device, flp_w))
- MCFG_DEVICE_ADD("slot2", Z88CART_SLOT, 0)
+ MCFG_DEVICE_ADD(m_carts[2], Z88CART_SLOT)
MCFG_DEVICE_SLOT_INTERFACE(z88_cart, nullptr, false)
MCFG_Z88CART_SLOT_OUT_FLP_CB(WRITELINE("blink", upd65031_device, flp_w))
- MCFG_DEVICE_ADD("slot3", Z88CART_SLOT, 0)
+ MCFG_DEVICE_ADD(m_carts[3], Z88CART_SLOT)
MCFG_DEVICE_SLOT_INTERFACE(z88_cart, nullptr, false)
MCFG_Z88CART_SLOT_OUT_FLP_CB(WRITELINE("blink", upd65031_device, flp_w))
diff --git a/src/mame/includes/z88.h b/src/mame/includes/z88.h
index 5697cf90672..a9e64efc86e 100644
--- a/src/mame/includes/z88.h
+++ b/src/mame/includes/z88.h
@@ -20,7 +20,8 @@
#include "bus/z88/z88.h"
#include "rendlay.h"
-
+#include "screen.h"
+#include "speaker.h"
#define Z88_NUM_COLOURS 3
@@ -39,10 +40,18 @@ class z88_state : public driver_device
{
public:
z88_state(const machine_config &mconfig, device_type type, const char *tag)
- : driver_device(mconfig, type, tag),
- m_maincpu(*this, "maincpu"),
- m_ram(*this, RAM_TAG),
- m_palette(*this, "palette")
+ : driver_device(mconfig, type, tag)
+ , m_maincpu(*this, "maincpu")
+ , m_bios_region(*this, "bios")
+ , m_ram(*this, RAM_TAG)
+ , m_screen(*this, "screen")
+ , m_palette(*this, "palette")
+ , m_blink(*this, "blink")
+ , m_mono(*this, "mono")
+ , m_speaker(*this, "speaker")
+ , m_lines(*this, "LINE%u", 0U)
+ , m_banks(*this, "bank%u", 1U)
+ , m_carts(*this, "slot%u", 0U)
{ }
void z88(machine_config &config);
@@ -86,8 +95,16 @@ protected:
private:
required_device<cpu_device> m_maincpu;
+ required_memory_region m_bios_region;
required_device<ram_device> m_ram;
+ required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
+ required_device<upd65031_device> m_blink;
+ required_device<speaker_device> m_mono;
+ required_device<speaker_sound_device> m_speaker;
+ required_ioport_array<8> m_lines;
+ required_memory_bank_array<5> m_banks;
+ optional_device_array<z88cart_slot_device, 4> m_carts;
struct
{
@@ -95,10 +112,9 @@ private:
uint8_t page;
} m_bank[4];
- int m_bank_type[4];
- uint8_t * m_bios;
- uint8_t * m_ram_base;
- z88cart_slot_device * m_carts[4];
+ int m_bank_type[4];
+ uint8_t * m_bios;
+ uint8_t * m_ram_base;
};
#endif /* MAME_INCLUDES_Z88_H */