summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
author therealmogminer@gmail.com <therealmogminer@gmail.com>2015-12-08 13:43:31 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2016-01-23 17:30:14 +0100
commit707e5dddbd508412869303dc002bbf404f0f7505 (patch)
tree1c62415493badead8c1be1227ece8cee78f07df5 /src/devices
parent2820f1c2773011c397db07a5968982ba65073f9e (diff)
Refix some of the this==NULL stuff
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/machine/timekpr.cpp14
-rw-r--r--src/devices/machine/timekpr.h2
-rw-r--r--src/devices/sound/c140.cpp25
-rw-r--r--src/devices/sound/c140.h2
-rw-r--r--src/devices/sound/namco.cpp6
-rw-r--r--src/devices/sound/namco.h2
-rw-r--r--src/devices/sound/scsp.cpp2
-rw-r--r--src/devices/sound/scsp.h34
-rw-r--r--src/devices/sound/tms5110.cpp10
-rw-r--r--src/devices/sound/tms5110.h5
-rw-r--r--src/devices/sound/upd7759.cpp18
-rw-r--r--src/devices/sound/upd7759.h3
-rw-r--r--src/devices/sound/ymf271.cpp16
-rw-r--r--src/devices/sound/ymf271.h4
14 files changed, 62 insertions, 81 deletions
diff --git a/src/devices/machine/timekpr.cpp b/src/devices/machine/timekpr.cpp
index bf2dbf2d62f..7b602c896c6 100644
--- a/src/devices/machine/timekpr.cpp
+++ b/src/devices/machine/timekpr.cpp
@@ -120,9 +120,9 @@ static int counter_from_ram( UINT8 *data, int offset )
//-------------------------------------------------
timekeeper_device::timekeeper_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_nvram_interface(mconfig, *this)
- , m_default_data(NULL)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
+ , device_nvram_interface(mconfig, *this)
+ , m_default_data(*this, DEVICE_SELF)
{
}
@@ -231,13 +231,9 @@ void timekeeper_device::device_start()
m_century = make_bcd( systime.local_time.year / 100 );
m_data.resize( m_size );
- if (region())
+ if (m_default_data)
{
- m_default_data = region()->base();
- if (m_default_data)
- {
- assert( region()->bytes() == m_size );
- }
+ assert(m_default_data.bytes() == m_size);
}
save_item( NAME(m_control) );
diff --git a/src/devices/machine/timekpr.h b/src/devices/machine/timekpr.h
index 4cb11f6ea86..84c969b076d 100644
--- a/src/devices/machine/timekpr.h
+++ b/src/devices/machine/timekpr.h
@@ -88,7 +88,7 @@ private:
UINT8 m_century;
dynamic_buffer m_data;
- UINT8 *m_default_data;
+ optional_region_ptr<UINT8> m_default_data;
protected:
int m_size;
diff --git a/src/devices/sound/c140.cpp b/src/devices/sound/c140.cpp
index 907d09a85e9..a111a54d937 100644
--- a/src/devices/sound/c140.cpp
+++ b/src/devices/sound/c140.cpp
@@ -95,7 +95,7 @@ c140_device::c140_device(const machine_config &mconfig, const char *tag, device_
, m_mixer_buffer_left(nullptr),
, m_mixer_buffer_right(nullptr),
, m_baserate(0),
- , m_rom_region(*this, this->tag())
+ , m_rom_region(*this, DEVICE_SELF)
, m_pRom(nullptr)
{
memset(m_REG, 0, sizeof(UINT8)*0x200);
@@ -109,30 +109,29 @@ c140_device::c140_device(const machine_config &mconfig, const char *tag, device_
void c140_device::device_start()
{
- m_sample_rate=m_baserate=clock();
+ m_sample_rate = m_baserate = clock();
m_stream = stream_alloc(0, 2, m_sample_rate);
- if (m_rom_region)
+ if (m_rom_ptr != NULL)
{
- m_pRom = (INT8 *)m_rom_region->base();
+ printf("asdf\n");
+ m_pRom = m_rom_ptr;
}
/* make decompress pcm table */ //2000.06.26 CAB
+ INT32 segbase = 0;
+ for(int i = 0; i < 8; i++)
{
- int i;
- INT32 segbase=0;
- for(i=0;i<8;i++)
- {
- m_pcmtbl[i]=segbase; //segment base value
- segbase += 16<<i;
- }
+ m_pcmtbl[i]=segbase; //segment base value
+ segbase += 16<<i;
}
memset(m_REG,0,sizeof(m_REG));
+
+ for(int i = 0; i < C140_MAX_VOICE; i++)
{
- int i;
- for(i=0;i<C140_MAX_VOICE;i++) init_voice( &m_voi[i] );
+ init_voice(&m_voi[i]);
}
/* allocate a pair of buffers to mix into - 1 second's worth should be more than enough */
diff --git a/src/devices/sound/c140.h b/src/devices/sound/c140.h
index e1fd8dcb8f0..a7662daae1e 100644
--- a/src/devices/sound/c140.h
+++ b/src/devices/sound/c140.h
@@ -110,7 +110,7 @@ private:
std::unique_ptr<INT16[]> m_mixer_buffer_right;
int m_baserate;
- optional_memory_region m_rom_region;
+ optional_region_ptr<INT8> m_rom_ptr;
INT8 *m_pRom;
UINT8 m_REG[0x200];
diff --git a/src/devices/sound/namco.cpp b/src/devices/sound/namco.cpp
index 13ef8ea1851..68c37f6f4ac 100644
--- a/src/devices/sound/namco.cpp
+++ b/src/devices/sound/namco.cpp
@@ -38,7 +38,7 @@ 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_wave_region(*this, this->tag())
+ , m_wave_ptr(*this, DEVICE_SELF)
, m_last_channel(nullptr)
, m_soundregs(nullptr)
, m_wavedata(nullptr)
@@ -96,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(m_wave_region != NULL ? m_wave_region->base() : NULL);
+ build_decoded_waveform(m_wave_ptr);
/* get stream channels */
if (m_stereo)
@@ -110,7 +110,7 @@ void namco_audio_device::device_start()
/* register with the save state system */
save_pointer(NAME(m_soundregs), 0x400);
- if (m_wave_region == nullptr)
+ if (m_wave_ptr == nullptr)
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 9277ac9323b..4bd09c5d3a1 100644
--- a/src/devices/sound/namco.h
+++ b/src/devices/sound/namco.h
@@ -54,7 +54,7 @@ protected:
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;
+ optional_region_ptr<UINT8> m_wave_ptr;
/* data about the sound system */
sound_channel m_channel_list[MAX_VOICES];
diff --git a/src/devices/sound/scsp.cpp b/src/devices/sound/scsp.cpp
index b81cde8b223..fe0ac3b13ae 100644
--- a/src/devices/sound/scsp.cpp
+++ b/src/devices/sound/scsp.cpp
@@ -149,7 +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, this->tag()),
+ m_ram_region(*this, DEVICE_SELF),
m_BUFPTR(0),
m_SCSPRAM(nullptr),
m_SCSPRAM_LENGTH(0),
diff --git a/src/devices/sound/scsp.h b/src/devices/sound/scsp.h
index 360d2498c7e..8397985026f 100644
--- a/src/devices/sound/scsp.h
+++ b/src/devices/sound/scsp.h
@@ -45,7 +45,7 @@ struct SCSP_EG_t
struct SCSP_LFO_t
{
- unsigned short phase;
+ UINT16 phase;
UINT32 phase_step;
int *table;
int *scale;
@@ -69,7 +69,7 @@ struct SCSP_SLOT
SCSP_LFO_t PLFO; //Phase LFO
SCSP_LFO_t ALFO; //Amplitude LFO
int slot;
- signed short Prev; //Previous sample (for interpolation)
+ INT16 Prev; //Previous sample (for interpolation)
};
@@ -113,13 +113,13 @@ private:
} m_udata;
SCSP_SLOT m_Slots[32];
- signed short m_RINGBUF[128];
- unsigned char m_BUFPTR;
+ INT16 m_RINGBUF[128];
+ UINT8 m_BUFPTR;
#if FM_DELAY
- signed short m_DELAYBUF[FM_DELAY];
- unsigned char m_DELAYPTR;
+ INT16 m_DELAYBUF[FM_DELAY];
+ UINT8 m_DELAYPTR;
#endif
- unsigned char *m_SCSPRAM;
+ UINT8 *m_SCSPRAM;
UINT32 m_SCSPRAM_LENGTH;
char m_Master;
sound_stream * m_stream;
@@ -168,7 +168,7 @@ private:
int m_length;
- signed short *m_RBUFDST; //this points to where the sample will be stored in the RingBuf
+ INT16 *m_RBUFDST; //this points to where the sample will be stored in the RingBuf
//LFO
int m_PLFO_TRI[256], m_PLFO_SQR[256], m_PLFO_SAW[256], m_PLFO_NOI[256];
@@ -177,7 +177,7 @@ private:
int m_ASCALES[8][256];
void exec_dma(address_space &space); /*state DMA transfer function*/
- unsigned char DecodeSCI(unsigned char irq);
+ UINT8 DecodeSCI(UINT8 irq);
void CheckPendingIRQ();
void MainCheckPendingIRQ(UINT16 irq_type);
void ResetInterrupts();
@@ -192,22 +192,22 @@ private:
UINT32 Step(SCSP_SLOT *slot);
void Compute_LFO(SCSP_SLOT *slot);
void StartSlot(SCSP_SLOT *slot);
- void StopSlot(SCSP_SLOT *slot,int keyoff);
+ void StopSlot(SCSP_SLOT *slot, int keyoff);
void init();
- void UpdateSlotReg(int s,int r);
+ void UpdateSlotReg(int s, int r);
void UpdateReg(address_space &space, int reg);
- void UpdateSlotRegR(int slot,int reg);
+ void UpdateSlotRegR(int slot, int reg);
void UpdateRegR(address_space &space, int reg);
- void w16(address_space &space,unsigned int addr,unsigned short val);
- unsigned short r16(address_space &space, unsigned int addr);
+ void w16(address_space &space, UINT32 addr, UINT16 val);
+ UINT16 r16(address_space &space, UINT32 addr);
inline INT32 UpdateSlot(SCSP_SLOT *slot);
void DoMasterSamples(int nsamples);
//LFO
void LFO_Init();
- signed int PLFO_Step(SCSP_LFO_t *LFO);
- signed int ALFO_Step(SCSP_LFO_t *LFO);
- void LFO_ComputeStep(SCSP_LFO_t *LFO,UINT32 LFOF,UINT32 LFOWS,UINT32 LFOS,int ALFO);
+ INT32 PLFO_Step(SCSP_LFO_t *LFO);
+ INT32 ALFO_Step(SCSP_LFO_t *LFO);
+ void LFO_ComputeStep(SCSP_LFO_t *LFO, UINT32 LFOF, UINT32 LFOWS, UINT32 LFOS, int ALFO);
};
extern const device_type SCSP;
diff --git a/src/devices/sound/tms5110.cpp b/src/devices/sound/tms5110.cpp
index 26573ec2f4c..80f1fd00c3a 100644
--- a/src/devices/sound/tms5110.cpp
+++ b/src/devices/sound/tms5110.cpp
@@ -1049,12 +1049,6 @@ static const unsigned int example_word_TEN[619]={
void tms5110_device::device_start()
{
- m_table = NULL;
- if (m_table_region != NULL)
- {
- m_table = m_table_region->base();
- }
-
set_variant(TMS5110_IS_TMS5110A);
/* resolve lines */
@@ -1537,7 +1531,7 @@ 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_table_region(*this, this->tag())
+ , m_table(*this, DEVICE_SELF)
, m_m0_cb(*this)
, m_m1_cb(*this)
, m_addr_cb(*this)
@@ -1549,7 +1543,7 @@ tms5110_device::tms5110_device(const machine_config &mconfig, const char *tag, d
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_table_region(*this, this->tag())
+ , m_table(*this, DEVICE_SELF)
, m_m0_cb(*this)
, m_m1_cb(*this)
, m_addr_cb(*this)
diff --git a/src/devices/sound/tms5110.h b/src/devices/sound/tms5110.h
index 2a53b218323..8eb5306eaf9 100644
--- a/src/devices/sound/tms5110.h
+++ b/src/devices/sound/tms5110.h
@@ -97,8 +97,8 @@ private:
void parse_frame();
// internal state
- /* table region */
- optional_memory_region m_table_region;
+ /* table */
+ optional_region_ptr<UINT8> m_table;
/* coefficient tables */
int m_variant; /* Variant of the 5110 - see tms5110.h */
@@ -194,7 +194,6 @@ private:
UINT8 m_romclk_hack_state;
emu_timer *m_romclk_hack_timer;
- const UINT8 *m_table;
};
extern const device_type TMS5110;
diff --git a/src/devices/sound/upd7759.cpp b/src/devices/sound/upd7759.cpp
index 12b17faa20a..a409d77e03e 100644
--- a/src/devices/sound/upd7759.cpp
+++ b/src/devices/sound/upd7759.cpp
@@ -171,7 +171,7 @@ upd775x_device::upd775x_device(const machine_config &mconfig, device_type type,
, m_adpcm_state(0)
, m_adpcm_data(0)
, m_sample(0)
- , m_rom_region(*this, this->tag())
+ , m_rom_region(*this, DEVICE_SELF)
, m_rom(nullptr)
, m_rombase(nullptr)
, m_romoffset(0)
@@ -232,11 +232,10 @@ void upd7759_device::device_start()
/* compute the ROM base or allocate a timer */
m_romoffset = 0;
- if (m_rom_region != nullptr)
+ m_rom = m_rombase;
+ if (m_rombase != nullptr)
{
- m_rom = m_rombase = m_rom_region->base();
-
- UINT32 romsize = m_rom_region->bytes();
+ UINT32 romsize = m_rombase.bytes();
if (romsize >= 0x20000)
{
m_rommask = 0x1ffff;
@@ -314,11 +313,10 @@ void upd7756_device::device_start()
/* compute the ROM base or allocate a timer */
m_romoffset = 0;
- if (m_rom_region != nullptr)
+ m_rom = m_rombase;
+ if (m_rombase != nullptr)
{
- m_rom = m_rombase = m_rom_region->base();
-
- UINT32 romsize = region()->bytes();
+ UINT32 romsize = m_rombase.bytes();
if (romsize >= 0x20000)
{
m_rommask = 0x1ffff;
@@ -735,7 +733,9 @@ void upd7759_device::device_timer(emu_timer &timer, device_timer_id id, int para
void upd775x_device::postload()
{
if (m_rombase)
+ {
m_rom = m_rombase + m_romoffset;
+ }
}
/************************************************************
diff --git a/src/devices/sound/upd7759.h b/src/devices/sound/upd7759.h
index f42039a785a..5dbd03dd2ac 100644
--- a/src/devices/sound/upd7759.h
+++ b/src/devices/sound/upd7759.h
@@ -95,9 +95,8 @@ protected:
INT16 m_sample; /* current sample value */
/* ROM access */
- optional_memory_region m_rom_region; /* ROM data region which may or may not be present */
+ optional_region_ptr<UINT8> m_rombase; /* pointer to ROM data or NULL for slave mode */
UINT8 * m_rom; /* pointer to ROM data or NULL for slave mode */
- UINT8 * m_rombase; /* pointer to ROM data or NULL for slave mode */
UINT32 m_romoffset; /* ROM offset to make save/restore easier */
UINT32 m_rommask; /* maximum address offset */
diff --git a/src/devices/sound/ymf271.cpp b/src/devices/sound/ymf271.cpp
index 7a4b5bf2c70..653285f18a1 100644
--- a/src/devices/sound/ymf271.cpp
+++ b/src/devices/sound/ymf271.cpp
@@ -1706,11 +1706,8 @@ void ymf271_device::device_start()
m_timA = timer_alloc(0);
m_timB = timer_alloc(1);
- if (m_mem_region != NULL)
- {
- m_mem_base = m_mem_region->base();
- m_mem_size = m_mem_region->bytes();
- }
+ m_mem_size = m_mem_base.bytes();
+
m_irq_handler.resolve();
m_ext_read_handler.resolve();
@@ -1760,17 +1757,16 @@ ymf271_device::ymf271_device(const machine_config &mconfig, const char *tag, dev
, m_ext_address(0)
, m_ext_rw(0)
, m_ext_readlatch(0)
- , m_mem_base(NULL)
+ , m_mem_base(*this, DEVICE_SELF)
, m_mem_size(0)
- , m_irq_handler(*this)
- , m_ext_read_handler(*this)
- , m_ext_write_handler(*this)
- , m_mem_region(*this, this->tag())
, m_clock(0)
, m_timA(nullptr)
, m_timB(nullptr)
, m_stream(nullptr)
, m_mix_buffer(nullptr)
+ , m_irq_handler(*this)
+ , m_ext_read_handler(*this)
+ , m_ext_write_handler(*this)
{
memset(m_slots, 0, sizeof(m_slots));
memset(m_groups, 0, sizeof(m_groups));
diff --git a/src/devices/sound/ymf271.h b/src/devices/sound/ymf271.h
index a3fb8b635c1..e0b6f77ef0a 100644
--- a/src/devices/sound/ymf271.h
+++ b/src/devices/sound/ymf271.h
@@ -147,7 +147,7 @@ private:
UINT8 m_ext_rw;
UINT8 m_ext_readlatch;
- UINT8 *m_mem_base;
+ optional_region_ptr<UINT8> m_mem_base;
UINT32 m_mem_size;
UINT32 m_clock;
@@ -159,8 +159,6 @@ private:
devcb_write_line m_irq_handler;
devcb_read8 m_ext_read_handler;
devcb_write8 m_ext_write_handler;
-
- optional_memory_region m_mem_region;
};
extern const device_type YMF271;