diff options
| author | 2014-10-13 19:58:15 +0000 | |
|---|---|---|
| committer | 2014-10-13 19:58:15 +0000 | |
| commit | 852b2e8345ba9d72283625b1b05720ebd0251fb0 (patch) | |
| tree | e4b448d002ad3081582dfcf6074550291e740ce1 /src | |
| parent | e828755bce719ccb4e7135c2c4e085f649a62ad5 (diff) | |
removed static config from st0016. nw.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/sound/st0016.c | 10 | ||||
| -rw-r--r-- | src/emu/sound/st0016.h | 17 | ||||
| -rw-r--r-- | src/mame/machine/st0016.c | 21 | ||||
| -rw-r--r-- | src/mame/machine/st0016.h | 4 |
4 files changed, 21 insertions, 31 deletions
diff --git a/src/emu/sound/st0016.c b/src/emu/sound/st0016.c index 84699fa6266..c21c766481d 100644 --- a/src/emu/sound/st0016.c +++ b/src/emu/sound/st0016.c @@ -26,7 +26,7 @@ st0016_device::st0016_device(const machine_config &mconfig, const char *tag, dev : device_t(mconfig, ST0016, "ST0016 (Audio)", tag, owner, clock, "st0016_audio", __FILE__), device_sound_interface(mconfig, *this), m_stream(NULL), - m_sound_ram(NULL) + m_ram_read_cb(*this) { memset(m_vpos, 0, sizeof(int)*8); memset(m_frac, 0, sizeof(int)*8); @@ -41,11 +41,8 @@ st0016_device::st0016_device(const machine_config &mconfig, const char *tag, dev void st0016_device::device_start() { - const st0016_interface *intf = (const st0016_interface *)static_config(); - - m_sound_ram = intf->p_soundram; - m_stream = stream_alloc(0, 2, 44100); + m_ram_read_cb.resolve_safe(0); } @@ -55,7 +52,6 @@ void st0016_device::device_start() void st0016_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) { - UINT8 *sound_ram = *m_sound_ram; int v, i, snum; unsigned char *slot; INT32 mix[48000*2]; @@ -81,7 +77,7 @@ void st0016_device::sound_stream_update(sound_stream &stream, stream_sample_t ** for (snum = 0; snum < samples; snum++) { - sample = sound_ram[(sptr + m_vpos[v])&0x1fffff]<<8; + sample = m_ram_read_cb((sptr + m_vpos[v]) & 0x1fffff) << 8; *mixp++ += (sample * (char)slot[0x14]) >> 8; *mixp++ += (sample * (char)slot[0x15]) >> 8; diff --git a/src/emu/sound/st0016.h b/src/emu/sound/st0016.h index 3e1b1c35b8e..f4f8cb63e1e 100644 --- a/src/emu/sound/st0016.h +++ b/src/emu/sound/st0016.h @@ -8,22 +8,13 @@ // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_ST0016_ADD(_tag, _clock) \ - MCFG_DEVICE_ADD(_tag, ST0016, _clock) -#define MCFG_ST0016_REPLACE(_tag, _clock) \ - MCFG_DEVICE_REPLACE(_tag, ST0016, _clock) - +#define MCFG_ST0016_SOUNDRAM_READ_CB(_devcb) \ + devcb = &st0016_device::set_soundram_callback(*device, DEVCB_##_devcb); //************************************************************************** // TYPE DEFINITIONS //************************************************************************** -struct st0016_interface -{ - UINT8 **p_soundram; -}; - - // ======================> st0016_device class st0016_device : public device_t, @@ -33,6 +24,8 @@ public: st0016_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~st0016_device() { } + template<class _Object> static devcb_base &set_soundram_callback(device_t &device, _Object object) { return downcast<st0016_device &>(device).m_ram_read_cb.set_callback(object); } + protected: // device-level overrides virtual void device_start(); @@ -46,7 +39,7 @@ public: private: sound_stream *m_stream; - UINT8 **m_sound_ram; + devcb_read8 m_ram_read_cb; int m_vpos[8]; int m_frac[8]; int m_lponce[8]; diff --git a/src/mame/machine/st0016.c b/src/mame/machine/st0016.c index ab28fc13e06..e3da9499158 100644 --- a/src/mame/machine/st0016.c +++ b/src/mame/machine/st0016.c @@ -4,7 +4,6 @@ const device_type ST0016_CPU = &device_creator<st0016_cpu_device>; -UINT8 *st0016_charram; // todo, get it in the device UINT8 macs_cart_slot; @@ -103,10 +102,10 @@ void st0016_cpu_device::device_reset() } } -static const st0016_interface st0016_config = +READ8_MEMBER(st0016_cpu_device::soundram_read) { - &st0016_charram -}; + return m_charram[offset]; +} static GFXDECODE_START( st0016 ) GFXDECODE_END @@ -118,8 +117,8 @@ static MACHINE_CONFIG_FRAGMENT( st0016_cpu ) MCFG_GFXDECODE_ADD("gfxdecode", "palette", st0016) MCFG_PALETTE_ADD("palette", 16*16*4+1) - MCFG_ST0016_ADD("stsnd", 0) - MCFG_SOUND_CONFIG(st0016_config) + MCFG_DEVICE_ADD("stsnd", ST0016, 0) + MCFG_ST0016_SOUNDRAM_READ_CB(READ8(st0016_cpu_device, soundram_read)) MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) @@ -223,12 +222,12 @@ WRITE8_MEMBER(st0016_cpu_device::st0016_palette_ram_w) READ8_MEMBER(st0016_cpu_device::st0016_character_ram_r) { - return st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]; + return m_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]; } WRITE8_MEMBER(st0016_cpu_device::st0016_character_ram_w) { - st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data; + m_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data; m_gfxdecode->gfx(st0016_ramgfx)->mark_dirty(st0016_char_bank); } @@ -569,7 +568,7 @@ void st0016_cpu_device::st0016_save_init() save_item(NAME(st0016_char_bank)); //save_item(NAME(st0016_rom_bank)); save_item(NAME(st0016_vregs)); - save_pointer(NAME(st0016_charram), ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE); + save_pointer(NAME(m_charram), ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE); save_pointer(NAME(st0016_paletteram), ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE); save_pointer(NAME(st0016_spriteram), ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE); } @@ -580,7 +579,7 @@ void st0016_cpu_device::startup() int gfx_index=0; macs_cart_slot = 0; - st0016_charram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE); + m_charram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE); st0016_spriteram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE); st0016_paletteram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE); @@ -592,7 +591,7 @@ void st0016_cpu_device::startup() assert(gfx_index != MAX_GFX_ELEMENTS); /* create the char set (gfx will then be updated dynamically from RAM) */ - m_gfxdecode->set_gfx(gfx_index, global_alloc(gfx_element(m_palette, charlayout, (UINT8 *) st0016_charram, 0, 0x40, 0))); + m_gfxdecode->set_gfx(gfx_index, global_alloc(gfx_element(m_palette, charlayout, (UINT8 *) m_charram, 0, 0x40, 0))); st0016_ramgfx = gfx_index; spr_dx=0; diff --git a/src/mame/machine/st0016.h b/src/mame/machine/st0016.h index 1ac134fed5e..3b01ee9a290 100644 --- a/src/mame/machine/st0016.h +++ b/src/mame/machine/st0016.h @@ -51,6 +51,8 @@ public: DECLARE_READ8_MEMBER(st0016_vregs_r); DECLARE_READ8_MEMBER(st0016_dma_r); DECLARE_WRITE8_MEMBER(st0016_vregs_w); + DECLARE_READ8_MEMBER(soundram_read); + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); void st0016_save_init(); @@ -70,7 +72,7 @@ public: UINT8 st0016_vregs[0xc0]; int st0016_ramgfx; - + UINT8 *m_charram; protected: // device-level overrides |
