summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/devices/sound/es5506.cpp37
-rw-r--r--src/devices/sound/namco.cpp31
-rw-r--r--src/devices/sound/namco.h3
-rw-r--r--src/devices/sound/scsp.cpp16
-rw-r--r--src/devices/sound/scsp.h1
-rw-r--r--src/devices/sound/tms5110.cpp34
-rw-r--r--src/devices/sound/tms5110.h3
-rw-r--r--src/mame/drivers/cps3.cpp37
-rw-r--r--src/mame/drivers/jaguar.cpp14
-rw-r--r--src/mame/drivers/segac2.cpp22
-rw-r--r--src/mame/includes/cps3.h45
-rw-r--r--src/mame/includes/jaguar.h2
-rw-r--r--src/mame/machine/amstrad.cpp71
-rw-r--r--src/mame/video/avgdvg.cpp12
14 files changed, 220 insertions, 108 deletions
diff --git a/src/devices/sound/es5506.cpp b/src/devices/sound/es5506.cpp
index 282ee217e15..792da85298b 100644
--- a/src/devices/sound/es5506.cpp
+++ b/src/devices/sound/es5506.cpp
@@ -195,10 +195,39 @@ void es5506_device::device_start()
m_stream = machine().sound().stream_alloc(*this, 0, 2 * channels, clock() / (16*32));
/* initialize the regions */
- m_region_base[0] = m_region0 ? (UINT16 *)machine().root_device().memregion(m_region0)->base() : nullptr;
- m_region_base[1] = m_region1 ? (UINT16 *)machine().root_device().memregion(m_region1)->base() : nullptr;
- m_region_base[2] = m_region2 ? (UINT16 *)machine().root_device().memregion(m_region2)->base() : nullptr;
- m_region_base[3] = m_region3 ? (UINT16 *)machine().root_device().memregion(m_region3)->base() : nullptr;
+ m_region_base[0] = m_region_base[1] = m_region_base[2] = m_region_base[3] = nullptr;
+ if (m_region0)
+ {
+ memory_region *region0 = machine().root_device().memregion(m_region0);
+ if (region0 != nullptr)
+ {
+ m_region_base[0] = (UINT16 *)region0->base();
+ }
+ }
+ if (m_region1)
+ {
+ memory_region *region1 = machine().root_device().memregion(m_region1);
+ if (region1 != nullptr)
+ {
+ m_region_base[1] = (UINT16 *)region1->base();
+ }
+ }
+ if (m_region2)
+ {
+ memory_region *region2 = machine().root_device().memregion(m_region2);
+ if (region2 != nullptr)
+ {
+ m_region_base[2] = (UINT16 *)region2->base();
+ }
+ }
+ if (m_region3)
+ {
+ memory_region *region3 = machine().root_device().memregion(m_region3);
+ if (region3 != nullptr)
+ {
+ m_region_base[3] = (UINT16 *)region3->base();
+ }
+ }
/* initialize the rest of the structure */
m_master_clock = clock();
diff --git a/src/devices/sound/namco.cpp b/src/devices/sound/namco.cpp
index 070ae056597..cc71d81ab16 100644
--- a/src/devices/sound/namco.cpp
+++ b/src/devices/sound/namco.cpp
@@ -37,18 +37,19 @@ const device_type NAMCO_CUS30 = &device_creator<namco_cus30_device>;
namco_audio_device::namco_audio_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, __FILE__),
- device_sound_interface(mconfig, *this),
- m_last_channel(nullptr),
- m_soundregs(nullptr),
- m_wavedata(nullptr),
- m_wave_size(0),
- m_sound_enable(0),
- m_stream(nullptr),
- m_namco_clock(0),
- m_sample_rate(0),
- m_f_fracbits(0),
- m_voices(0),
- m_stereo(0)
+ , device_sound_interface(mconfig, *this)
+ , m_wave_region(*this, tag)
+ , m_last_channel(nullptr)
+ , m_soundregs(nullptr)
+ , m_wavedata(nullptr)
+ , m_wave_size(0)
+ , m_sound_enable(0)
+ , m_stream(nullptr)
+ , m_namco_clock(0)
+ , m_sample_rate(0)
+ , m_f_fracbits(0)
+ , m_voices(0)
+ , m_stereo(0)
{
}
@@ -95,7 +96,7 @@ void namco_audio_device::device_start()
logerror("Namco: freq fractional bits = %d: internal freq = %d, output freq = %d\n", m_f_fracbits, m_namco_clock, m_sample_rate);
/* build the waveform table */
- build_decoded_waveform(region()->base());
+ build_decoded_waveform(m_wave_region != NULL ? m_wave_region->base() : NULL);
/* get stream channels */
if (m_stereo)
@@ -109,7 +110,11 @@ void namco_audio_device::device_start()
/* register with the save state system */
save_pointer(NAME(m_soundregs), 0x400);
+<<<<<<< HEAD
if (region() == nullptr)
+=======
+ if (m_wave_region == NULL)
+>>>>>>> Yet more this==NULL fixes
save_pointer(NAME(m_wavedata), 0x400);
save_item(NAME(m_voices));
diff --git a/src/devices/sound/namco.h b/src/devices/sound/namco.h
index e79484e4f4a..9277ac9323b 100644
--- a/src/devices/sound/namco.h
+++ b/src/devices/sound/namco.h
@@ -53,6 +53,9 @@ protected:
void update_namco_waveform(int offset, UINT8 data);
UINT32 namco_update_one(stream_sample_t *buffer, int length, const INT16 *wave, UINT32 counter, UINT32 freq);
+ /* waveform region */
+ optional_memory_region m_wave_region;
+
/* data about the sound system */
sound_channel m_channel_list[MAX_VOICES];
sound_channel *m_last_channel;
diff --git a/src/devices/sound/scsp.cpp b/src/devices/sound/scsp.cpp
index 7a20010714d..ac4020852af 100644
--- a/src/devices/sound/scsp.cpp
+++ b/src/devices/sound/scsp.cpp
@@ -149,6 +149,7 @@ scsp_device::scsp_device(const machine_config &mconfig, const char *tag, device_
m_roffset(0),
m_irq_cb(*this),
m_main_irq_cb(*this),
+ m_ram_region(*this, tag),
m_BUFPTR(0),
m_SCSPRAM(nullptr),
m_SCSPRAM_LENGTH(0),
@@ -515,13 +516,16 @@ void scsp_device::init()
m_Master=0;
}
- m_SCSPRAM = region()->base();
- if (m_SCSPRAM)
+ if (m_ram_region)
{
- m_SCSPRAM_LENGTH = region()->bytes();
- m_DSP.SCSPRAM = (UINT16 *)m_SCSPRAM;
- m_DSP.SCSPRAM_LENGTH = m_SCSPRAM_LENGTH/2;
- m_SCSPRAM += m_roffset;
+ m_SCSPRAM = m_ram_region->base();
+ if (m_SCSPRAM)
+ {
+ m_SCSPRAM_LENGTH = m_ram_region->bytes();
+ m_DSP.SCSPRAM = (UINT16 *)m_SCSPRAM;
+ m_DSP.SCSPRAM_LENGTH = m_SCSPRAM_LENGTH/2;
+ m_SCSPRAM += m_roffset;
+ }
}
m_timerA = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(scsp_device::timerA_cb), this));
diff --git a/src/devices/sound/scsp.h b/src/devices/sound/scsp.h
index 981936f37db..1ad46c7028d 100644
--- a/src/devices/sound/scsp.h
+++ b/src/devices/sound/scsp.h
@@ -104,6 +104,7 @@ private:
int m_roffset; /* offset in the region */
devcb_write8 m_irq_cb; /* irq callback */
devcb_write_line m_main_irq_cb;
+ optional_memory_region m_ram_region;
union
{
diff --git a/src/devices/sound/tms5110.cpp b/src/devices/sound/tms5110.cpp
index b2472563c3a..6ac5628f135 100644
--- a/src/devices/sound/tms5110.cpp
+++ b/src/devices/sound/tms5110.cpp
@@ -1049,7 +1049,11 @@ static const unsigned int example_word_TEN[619]={
void tms5110_device::device_start()
{
- m_table = region()->base();
+ m_table = NULL;
+ if (m_table_region != NULL)
+ {
+ m_table = m_table_region->base();
+ }
set_variant(TMS5110_IS_TMS5110A);
@@ -1532,23 +1536,25 @@ const device_type TMS5110 = &device_creator<tms5110_device>;
tms5110_device::tms5110_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, TMS5110, "TMS5110", tag, owner, clock, "tms5110", __FILE__),
- device_sound_interface(mconfig, *this),
- m_m0_cb(*this),
- m_m1_cb(*this),
- m_addr_cb(*this),
- m_data_cb(*this),
- m_romclk_cb(*this)
+ , device_sound_interface(mconfig, *this)
+ , m_table_region(*this, tag)
+ , m_m0_cb(*this)
+ , m_m1_cb(*this)
+ , m_addr_cb(*this)
+ , m_data_cb(*this)
+ , m_romclk_cb(*this)
{
}
tms5110_device::tms5110_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_sound_interface(mconfig, *this),
- m_m0_cb(*this),
- m_m1_cb(*this),
- m_addr_cb(*this),
- m_data_cb(*this),
- m_romclk_cb(*this)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
+ , device_sound_interface(mconfig, *this)
+ , m_table_region(*this, tag)
+ , m_m0_cb(*this)
+ , m_m1_cb(*this)
+ , m_addr_cb(*this)
+ , m_data_cb(*this)
+ , m_romclk_cb(*this)
{
}
diff --git a/src/devices/sound/tms5110.h b/src/devices/sound/tms5110.h
index e36c57b2d50..2a53b218323 100644
--- a/src/devices/sound/tms5110.h
+++ b/src/devices/sound/tms5110.h
@@ -97,6 +97,9 @@ private:
void parse_frame();
// internal state
+ /* table region */
+ optional_memory_region m_table_region;
+
/* coefficient tables */
int m_variant; /* Variant of the 5110 - see tms5110.h */
diff --git a/src/mame/drivers/cps3.cpp b/src/mame/drivers/cps3.cpp
index af0104474a6..8ec2c17c68a 100644
--- a/src/mame/drivers/cps3.cpp
+++ b/src/mame/drivers/cps3.cpp
@@ -788,12 +788,25 @@ void cps3_state::init_crypt(UINT32 key1, UINT32 key2, int altEncryption)
m_altEncryption = altEncryption;
// cache pointers to regions
- m_user4region = memregion("user4")->base();
- m_user5region = memregion("user5")->base();
+ if (m_user4_region)
+ {
+ m_user4 = m_user4_region->base();
+ }
+ else
+ {
+ m_user4 = auto_alloc_array(machine(), UINT8, USER4REGION_LENGTH);
+ }
+
+ if (m_user5_region)
+ {
+ m_user5 = m_user5_region->base();
+ }
+ else
+ {
+ m_user5 = auto_alloc_array(machine(), UINT8, USER5REGION_LENGTH);
+ }
- if (!m_user4region) m_user4region = auto_alloc_array(machine(), UINT8, USER4REGION_LENGTH);
- if (!m_user5region) m_user5region = auto_alloc_array(machine(), UINT8, USER5REGION_LENGTH);
- m_cps3sound->set_base((INT8*)m_user5region);
+ m_cps3sound->set_base((INT8*)m_user5);
// set strict verify
m_maincpu->sh2drc_set_options(SH2DRC_STRICT_VERIFY);
@@ -1468,7 +1481,7 @@ WRITE32_MEMBER(cps3_state::cps3_gfxflash_w)
/* make a copy in the linear memory region we actually use for drawing etc. having it stored in interleaved flash roms isnt' very useful */
{
- UINT32* romdata = (UINT32*)m_user5region;
+ UINT32* romdata = (UINT32*)m_user5;
int real_offset = 0;
UINT32 newdata;
@@ -1575,7 +1588,7 @@ void cps3_state::cps3_flashmain_w(int which, UINT32 offset, UINT32 data, UINT32
/* copy data into regions to execute from */
{
- UINT32* romdata = (UINT32*)m_user4region;
+ UINT32* romdata = (UINT32*)m_user4;
UINT32* romdata2 = (UINT32*)m_decrypted_gamerom;
int real_offset = 0;
UINT32 newdata;
@@ -1799,7 +1812,7 @@ WRITE32_MEMBER(cps3_state::cps3_palettedma_w)
if (data & 0x0002)
{
int i;
- UINT16* src = (UINT16*)m_user5region;
+ UINT16* src = (UINT16*)m_user5;
// if(DEBUG_PRINTF) printf("CPS3 pal dma start %08x (real: %08x) dest %08x fade %08x other2 %08x (length %04x)\n", m_paldma_source, m_paldma_realsource, m_paldma_dest, m_paldma_fade, m_paldma_other2, m_paldma_length);
for (i=0;i<m_paldma_length;i++)
@@ -1873,7 +1886,7 @@ UINT32 cps3_state::process_byte( UINT8 real_byte, UINT32 destination, int max_le
void cps3_state::cps3_do_char_dma( UINT32 real_source, UINT32 real_destination, UINT32 real_length )
{
- UINT8* sourcedata = (UINT8*)m_user5region;
+ UINT8* sourcedata = (UINT8*)m_user5;
int length_remaining;
m_last_normal_byte = 0;
@@ -1956,7 +1969,7 @@ UINT32 cps3_state::ProcessByte8(UINT8 b,UINT32 dst_offset)
void cps3_state::cps3_do_alt_char_dma( UINT32 src, UINT32 real_dest, UINT32 real_length )
{
- UINT8* px = (UINT8*)m_user5region;
+ UINT8* px = (UINT8*)m_user5;
UINT32 start = real_dest;
UINT32 ds = real_dest;
@@ -2299,7 +2312,7 @@ void cps3_state::machine_reset()
// make a copy in the regions we execute code / draw gfx from
void cps3_state::copy_from_nvram()
{
- UINT32* romdata = (UINT32*)m_user4region;
+ UINT32* romdata = (UINT32*)m_user4;
UINT32* romdata2 = (UINT32*)m_decrypted_gamerom;
int i;
/* copy + decrypt program roms which have been loaded from flashroms/nvram */
@@ -2336,7 +2349,7 @@ void cps3_state::copy_from_nvram()
int flashnum = 0;
int countoffset = 0;
- romdata = (UINT32*)m_user5region;
+ romdata = (UINT32*)m_user5;
for (thebase = 0;thebase < len/2; thebase+=0x200000)
{
// printf("flashnums %d. %d\n",flashnum, flashnum+1);
diff --git a/src/mame/drivers/jaguar.cpp b/src/mame/drivers/jaguar.cpp
index 17fa609b29c..e2fe252fe93 100644
--- a/src/mame/drivers/jaguar.cpp
+++ b/src/mame/drivers/jaguar.cpp
@@ -427,9 +427,10 @@ void jaguar_state::machine_reset()
}
/* configure banks for gfx/sound ROMs */
- UINT8 *romboard = memregion("romboard")->base();
- if (romboard != nullptr)
+ if (m_romboard_region != nullptr)
{
+ UINT8 *romboard = m_romboard_region->base();
+
/* graphics banks */
if (m_is_r3000)
{
@@ -617,7 +618,7 @@ WRITE32_MEMBER(jaguar_state::misc_control_w)
}
/* adjust banking */
- if (memregion("romboard")->base())
+ if (m_romboard_region != NULL)
{
membank("mainsndbank")->set_entry((data >> 1) & 7);
membank("dspsndbank")->set_entry((data >> 1) & 7);
@@ -776,10 +777,12 @@ WRITE32_MEMBER(jaguar_state::latch_w)
logerror("%08X:latch_w(%X)\n", space.device().safe_pcbase(), data);
/* adjust banking */
- if (memregion("romboard")->base())
+ if (m_romboard_region != NULL)
{
if (m_is_r3000)
+ {
membank("maingfxbank")->set_entry(data & 1);
+ }
membank("gpugfxbank")->set_entry(data & 1);
}
}
@@ -1915,7 +1918,8 @@ MACHINE_CONFIG_END
void jaguar_state::fix_endian( UINT32 addr, UINT32 size )
{
- UINT8 j[4], *ram = memregion("maincpu")->base();
+ UINT8 j[4];
+ UINT8 *ram = memregion("maincpu")->base();
UINT32 i;
size += addr;
logerror("File Loaded to address range %X to %X\n",addr,size-1);
diff --git a/src/mame/drivers/segac2.cpp b/src/mame/drivers/segac2.cpp
index d96fd2cef69..2bcd3d094d6 100644
--- a/src/mame/drivers/segac2.cpp
+++ b/src/mame/drivers/segac2.cpp
@@ -98,11 +98,14 @@ class segac2_state : public md_base_state
{
public:
segac2_state(const machine_config &mconfig, device_type type, const char *tag)
- : md_base_state(mconfig, type, tag),
- m_paletteram(*this, "paletteram"),
- m_upd7759(*this, "upd"),
- m_screen(*this, "screen"),
- m_palette(*this, "palette") { }
+ : md_base_state(mconfig, type, tag)
+ , m_paletteram(*this, "paletteram")
+ , m_upd_region(*this, "upd")
+ , m_upd7759(*this, "upd")
+ , m_screen(*this, "screen")
+ , m_palette(*this, "palette")
+ {
+ }
// for Print Club only
int m_cam_data;
@@ -110,6 +113,7 @@ public:
int m_segac2_enable_display;
required_shared_ptr<UINT16> m_paletteram;
+ optional_memory_region m_upd_region;
/* protection-related tracking */
segac2_prot_delegate m_prot_func; /* emulation of protection chip */
@@ -244,8 +248,10 @@ MACHINE_RESET_MEMBER(segac2_state,segac2)
/* determine how many sound banks */
m_sound_banks = 0;
- if (memregion("upd")->base())
- m_sound_banks = memregion("upd")->bytes() / 0x20000;
+ if (m_upd_region != NULL)
+ {
+ m_sound_banks = m_upd_region->bytes() / 0x20000;
+ }
/* reset the protection */
m_prot_write_buf = 0;
@@ -934,7 +940,7 @@ INPUT_PORTS_END
static INPUT_PORTS_START( wwmarine )
PORT_INCLUDE( systemc_generic )
-
+
PORT_MODIFY("P1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) // Button 1
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) // Button 2
diff --git a/src/mame/includes/cps3.h b/src/mame/includes/cps3.h
index 4f954dbdb9d..fda7f55da2c 100644
--- a/src/mame/includes/cps3.h
+++ b/src/mame/includes/cps3.h
@@ -14,24 +14,28 @@
class cps3_state : public driver_device
{
public:
+<<<<<<< HEAD
cps3_state(const machine_config &mconfig, device_type type, const char *tag)
- : driver_device(mconfig, type, tag),
- m_maincpu(*this, "maincpu"),
- m_gfxdecode(*this, "gfxdecode"),
- m_palette(*this, "palette"),
- m_cps3sound(*this, "cps3sound"),
- m_mainram(*this, "mainram"),
- m_spriteram(*this, "spriteram"),
- m_colourram(*this, "colourram"),
- m_tilemap20_regs_base(*this, "tmap20_regs"),
- m_tilemap30_regs_base(*this, "tmap30_regs"),
- m_tilemap40_regs_base(*this, "tmap40_regs"),
- m_tilemap50_regs_base(*this, "tmap50_regs"),
- m_fullscreenzoom(*this, "fullscreenzoom"),
- m_0xc0000000_ram(*this, "0xc0000000_ram"),
- m_decrypted_gamerom(*this, "decrypted_gamerom"),
- m_0xc0000000_ram_decrypted(*this, "0xc0000000_ram_decrypted")
- { }
+ : driver_device(mconfig, type, tag)
+ , m_maincpu(*this, "maincpu")
+ , m_gfxdecode(*this, "gfxdecode")
+ , m_palette(*this, "palette")
+ , m_cps3sound(*this, "cps3sound")
+ , m_mainram(*this, "mainram")
+ , m_spriteram(*this, "spriteram")
+ , m_colourram(*this, "colourram")
+ , m_tilemap20_regs_base(*this, "tmap20_regs")
+ , m_tilemap30_regs_base(*this, "tmap30_regs")
+ , m_tilemap40_regs_base(*this, "tmap40_regs")
+ , m_tilemap50_regs_base(*this, "tmap50_regs")
+ , m_fullscreenzoom(*this, "fullscreenzoom")
+ , m_0xc0000000_ram(*this, "0xc0000000_ram")
+ , m_decrypted_gamerom(*this, "decrypted_gamerom")
+ , m_0xc0000000_ram_decrypted(*this, "0xc0000000_ram_decrypted")
+ , m_user4_region(*this, "user4")
+ , m_user5_region(*this, "user5")
+ {
+ }
required_device<sh2_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
@@ -50,6 +54,9 @@ public:
required_shared_ptr<UINT32> m_decrypted_gamerom;
required_shared_ptr<UINT32> m_0xc0000000_ram_decrypted;
+ optional_memory_region m_user4_region;
+ optional_memory_region m_user5_region;
+
fujitsu_29f016a_device *m_simm[7][8];
UINT32 m_cram_gfxflash_bank;
std::unique_ptr<UINT32[]> m_char_ram;
@@ -61,7 +68,7 @@ public:
std::unique_ptr<UINT32[]> m_mame_colours;
bitmap_rgb32 m_renderbuffer_bitmap;
rectangle m_renderbuffer_clip;
- UINT8* m_user4region;
+ UINT8* m_user4;
UINT32 m_key1;
UINT32 m_key2;
int m_altEncryption;
@@ -81,7 +88,7 @@ public:
int m_last_normal_byte;
unsigned short m_lastb;
unsigned short m_lastb2;
- UINT8* m_user5region;
+ UINT8* m_user5;
DECLARE_READ32_MEMBER(cps3_ssram_r);
DECLARE_WRITE32_MEMBER(cps3_ssram_w);
diff --git a/src/mame/includes/jaguar.h b/src/mame/includes/jaguar.h
index cbee2eafd21..75379c695ec 100644
--- a/src/mame/includes/jaguar.h
+++ b/src/mame/includes/jaguar.h
@@ -43,6 +43,7 @@ public:
m_shared_ram(*this, "sharedram"),
m_gpu_ram(*this, "gpuram"),
m_gpu_clut(*this, "gpuclut"),
+ m_romboard_region(*this, "romboard"),
m_is_r3000(false),
m_is_cojag(false),
m_hacks_enabled(false),
@@ -83,6 +84,7 @@ public:
required_shared_ptr<UINT32> m_shared_ram;
required_shared_ptr<UINT32> m_gpu_ram;
required_shared_ptr<UINT32> m_gpu_clut;
+ optional_memory_region m_romboard_region;
// configuration
bool m_is_r3000;
diff --git a/src/mame/machine/amstrad.cpp b/src/mame/machine/amstrad.cpp
index 3e89d234271..e8ed9a6e266 100644
--- a/src/mame/machine/amstrad.cpp
+++ b/src/mame/machine/amstrad.cpp
@@ -1106,7 +1106,7 @@ static device_t* get_expansion_device(running_machine &machine, const char* tag)
amstrad_state *state = machine.driver_data<amstrad_state>();
cpc_expansion_slot_device* exp_port = state->m_exp;
- while(exp_port != nullptr)
+ while (exp_port != nullptr)
{
device_t* temp;
@@ -1117,11 +1117,16 @@ static device_t* get_expansion_device(running_machine &machine, const char* tag)
// if it's not what we're looking for, then check the expansion port on this expansion device. if it exists.
temp = dynamic_cast<device_t*>(exp_port->get_card_device());
- if(temp == nullptr)
+ if (temp == nullptr)
+ {
return nullptr; // no device attached
+ }
+
exp_port = temp->subdevice<cpc_expansion_slot_device>("exp");
- if(exp_port == nullptr)
+ if (exp_port == nullptr)
+ {
return nullptr; // we're at the end of the chain
+ }
}
return nullptr;
}
@@ -2000,18 +2005,22 @@ WRITE8_MEMBER(amstrad_state::rom_select)
// expansion devices know the selected ROM by monitoring I/O writes to DFxx
// there are no signals related to which ROM is selected
cpc_expansion_slot_device* exp_port = m_exp;
- while(exp_port != nullptr)
+ while (exp_port != nullptr)
{
device_cpc_expansion_card_interface* temp;
device_t* temp_dev;
temp = dynamic_cast<device_cpc_expansion_card_interface*>(exp_port->get_card_device());
temp_dev = dynamic_cast<device_t*>(exp_port->get_card_device());
- if(temp != nullptr)
+ if (temp != nullptr)
{
temp->set_rom_bank(data);
+ exp_port = temp_dev->subdevice<cpc_expansion_slot_device>("exp");
+ }
+ else
+ {
+ exp_port = NULL;
}
- exp_port = temp_dev->subdevice<cpc_expansion_slot_device>("exp");
}
amstrad_rethinkMemory();
@@ -2906,37 +2915,42 @@ static const UINT8 amstrad_cycle_table_ex[256]=
void amstrad_state::enumerate_roms()
{
UINT8 m_rom_count = 1;
- device_t* romexp;
- rom_image_device* romimage;
UINT8 *rom = m_region_maincpu->base();
- char str[20];
- int i;
- bool slot3 = false,slot7 = false;
+ bool slot7 = false;
if (m_system_type == SYSTEM_PLUS || m_system_type == SYSTEM_GX4000)
{
UINT8 *crt = m_region_cart->base();
int bank_mask = (m_cart->get_rom_size() / 0x4000) - 1;
/* ROMs are stored on the inserted cartridge in the Plus/GX4000 */
- for(i=0; i<128; i++) // fill ROM table
+ for (int i = 0; i < 128; i++) // fill ROM table
+ {
m_Amstrad_ROM_Table[i] = &crt[0x4000];
- for(i=128;i<160;i++)
+ }
+
+ for(int i = 128; i < 160; i++)
+ {
m_Amstrad_ROM_Table[i] = &crt[((i - 128) & bank_mask) * 0x4000];
+ }
m_Amstrad_ROM_Table[7] = &crt[0xc000];
slot7 = true;
}
else
{
/* slot 0 is always BASIC, as is any unused slot */
- for(i=0; i<256; i++)
+ for (int i = 0; i<256; i++)
+ {
m_Amstrad_ROM_Table[i] = &rom[0x014000];
+ }
+
/* AMSDOS ROM -- TODO: exclude from 464 unless a DDI-1 device is connected */
m_Amstrad_ROM_Table[7] = &rom[0x018000];
slot7 = true;
}
/* MSX-DOS BIOS - Aleste MSX emulation */
+ bool slot3 = false;
if(m_system_type == SYSTEM_ALESTE)
{
m_Amstrad_ROM_Table[3] = &rom[0x01c000];
@@ -2955,36 +2969,41 @@ void amstrad_state::enumerate_roms()
temp = dynamic_cast<device_t*>(exp_port->get_card_device());
if(temp != nullptr)
{
- if(temp->memregion("exp_rom")->base() != nullptr)
+ memory_region *temp_region = temp->memregion("exp_rom");
+ if(temp_region != nullptr && temp_region->base() != nullptr)
{
- int num = temp->memregion("exp_rom")->bytes() / 0x4000;
- for(i=0;i<num;i++)
+ int num = temp_region->bytes() / 0x4000;
+ for (int i = 0; i < num; i++)
{
- m_Amstrad_ROM_Table[m_rom_count] = temp->memregion("exp_rom")->base()+0x4000*i;
+ m_Amstrad_ROM_Table[m_rom_count] = temp_region->base()+0x4000*i;
NEXT_ROM_SLOT
}
}
+ exp_port = temp->subdevice<cpc_expansion_slot_device>("exp");
+ }
+ else
+ {
+ exp_port = NULL;
}
- exp_port = temp->subdevice<cpc_expansion_slot_device>("exp");
}
/* add ROMs from ROMbox expansion */
- romexp = get_expansion_device(machine(),"rom");
+ device_t* romexp = get_expansion_device(machine(),"rom");
if(romexp)
{
- for(i=0;i<8;i++)
+ for(int i = 0; i < 8; i++)
{
- sprintf(str,"rom%i",i+1);
- romimage = romexp->subdevice<rom_image_device>(str);
- if(romimage->base() != nullptr)
+ char str[20];
+ sprintf(str, "rom%i", i + 1);
+ rom_image_device* romimage = romexp->subdevice<rom_image_device>(str);
+ if(romimage != NULL && romimage->base() != nullptr)
{
m_Amstrad_ROM_Table[m_rom_count] = romimage->base();
NEXT_ROM_SLOT
}
}
}
-
}
void amstrad_state::amstrad_common_init()
@@ -3106,7 +3125,9 @@ MACHINE_START_MEMBER(amstrad_state,plus)
std::string region_tag;
m_region_cart = memregion(region_tag.assign(m_cart->tag()).append(GENERIC_ROM_REGION_TAG).c_str());
if (!m_region_cart) // this should never happen, since we make carts mandatory!
+ {
m_region_cart = memregion("maincpu");
+ }
}
diff --git a/src/mame/video/avgdvg.cpp b/src/mame/video/avgdvg.cpp
index 96718f4728d..d125198c158 100644
--- a/src/mame/video/avgdvg.cpp
+++ b/src/mame/video/avgdvg.cpp
@@ -1344,7 +1344,11 @@ void avg_device::device_start()
avgdvg_vectorram = reinterpret_cast<UINT8 *>(machine().root_device().memshare("vectorram")->ptr());
avgdvg_vectorram_size = machine().root_device().memshare("vectorram")->bytes();
- avgdvg_colorram = reinterpret_cast<UINT8 *>(machine().root_device().memshare("colorram")->ptr());
+ memory_share *colorram = machine().root_device().memshare("colorram");
+ if (colorram != NULL)
+ {
+ avgdvg_colorram = reinterpret_cast<UINT8 *>(colorram->ptr());
+ }
xmin = visarea.min_x;
ymin = visarea.min_y;
@@ -1380,7 +1384,11 @@ void dvg_device::device_start()
avgdvg_vectorram = reinterpret_cast<UINT8 *>(machine().root_device().memshare("vectorram")->ptr());
avgdvg_vectorram_size = machine().root_device().memshare("vectorram")->bytes();
- avgdvg_colorram = reinterpret_cast<UINT8 *>(machine().root_device().memshare("colorram")->ptr());
+ memory_share *colorram = machine().root_device().memshare("colorram");
+ if (colorram != NULL)
+ {
+ avgdvg_colorram = reinterpret_cast<UINT8 *>(colorram->ptr());
+ }
xmin = visarea.min_x;
ymin = visarea.min_y;