Previous 199869 Revisions Next

r32710 Monday 13th October, 2014 at 19:58:15 UTC by Fabio Priuli
removed static config from st0016. nw.
[src/emu/sound]st0016.c st0016.h
[src/mame/machine]st0016.c st0016.h

trunk/src/mame/machine/st0016.c
r32709r32710
44
55const device_type ST0016_CPU = &device_creator<st0016_cpu_device>;
66
7UINT8 *st0016_charram; // todo, get it in the device
87UINT8 macs_cart_slot;
98
109
r32709r32710
103102   }
104103}
105104
106static const st0016_interface st0016_config =
105READ8_MEMBER(st0016_cpu_device::soundram_read)
107106{
108   &st0016_charram
109};
107   return m_charram[offset];
108}
110109
111110static GFXDECODE_START( st0016 )
112111GFXDECODE_END
r32709r32710
118117   MCFG_GFXDECODE_ADD("gfxdecode", "palette", st0016)
119118   MCFG_PALETTE_ADD("palette", 16*16*4+1)
120119
121   MCFG_ST0016_ADD("stsnd", 0)
122   MCFG_SOUND_CONFIG(st0016_config)
120   MCFG_DEVICE_ADD("stsnd", ST0016, 0)
121   MCFG_ST0016_SOUNDRAM_READ_CB(READ8(st0016_cpu_device, soundram_read))
123122   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
124123   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
125124
r32709r32710
223222
224223READ8_MEMBER(st0016_cpu_device::st0016_character_ram_r)
225224{
226   return st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset];
225   return m_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset];
227226}
228227
229228WRITE8_MEMBER(st0016_cpu_device::st0016_character_ram_w)
230229{
231   st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data;
230   m_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data;
232231   m_gfxdecode->gfx(st0016_ramgfx)->mark_dirty(st0016_char_bank);
233232}
234233
r32709r32710
569568   save_item(NAME(st0016_char_bank));
570569   //save_item(NAME(st0016_rom_bank));
571570   save_item(NAME(st0016_vregs));
572   save_pointer(NAME(st0016_charram), ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE);
571   save_pointer(NAME(m_charram), ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE);
573572   save_pointer(NAME(st0016_paletteram), ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE);
574573   save_pointer(NAME(st0016_spriteram), ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE);
575574}
r32709r32710
580579   int gfx_index=0;
581580
582581   macs_cart_slot = 0;
583   st0016_charram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE);
582   m_charram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE);
584583   st0016_spriteram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE);
585584   st0016_paletteram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE);
586585
r32709r32710
592591   assert(gfx_index != MAX_GFX_ELEMENTS);
593592
594593   /* create the char set (gfx will then be updated dynamically from RAM) */
595   m_gfxdecode->set_gfx(gfx_index, global_alloc(gfx_element(m_palette, charlayout, (UINT8 *) st0016_charram, 0, 0x40, 0)));
594   m_gfxdecode->set_gfx(gfx_index, global_alloc(gfx_element(m_palette, charlayout, (UINT8 *) m_charram, 0, 0x40, 0)));
596595   st0016_ramgfx = gfx_index;
597596
598597   spr_dx=0;
trunk/src/mame/machine/st0016.h
r32709r32710
5151   DECLARE_READ8_MEMBER(st0016_vregs_r);
5252   DECLARE_READ8_MEMBER(st0016_dma_r);
5353   DECLARE_WRITE8_MEMBER(st0016_vregs_w);
54   DECLARE_READ8_MEMBER(soundram_read);
55
5456   
5557   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
5658   void st0016_save_init();
r32709r32710
7072
7173   UINT8 st0016_vregs[0xc0];
7274   int st0016_ramgfx;
75   UINT8 *m_charram;
7376
74
7577protected:
7678   // device-level overrides
7779   virtual machine_config_constructor device_mconfig_additions() const;
trunk/src/emu/sound/st0016.c
r32709r32710
2626   : device_t(mconfig, ST0016, "ST0016 (Audio)", tag, owner, clock, "st0016_audio", __FILE__),
2727      device_sound_interface(mconfig, *this),
2828      m_stream(NULL),
29      m_sound_ram(NULL)
29      m_ram_read_cb(*this)
3030{
3131   memset(m_vpos, 0, sizeof(int)*8);
3232   memset(m_frac, 0, sizeof(int)*8);
r32709r32710
4141
4242void st0016_device::device_start()
4343{
44   const st0016_interface *intf = (const st0016_interface *)static_config();
45
46   m_sound_ram = intf->p_soundram;
47
4844   m_stream = stream_alloc(0, 2, 44100);
45   m_ram_read_cb.resolve_safe(0);
4946}
5047
5148
r32709r32710
5552
5653void st0016_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
5754{
58   UINT8 *sound_ram = *m_sound_ram;
5955   int v, i, snum;
6056   unsigned char *slot;
6157   INT32 mix[48000*2];
r32709r32710
8177
8278         for (snum = 0; snum < samples; snum++)
8379         {
84            sample = sound_ram[(sptr + m_vpos[v])&0x1fffff]<<8;
80            sample = m_ram_read_cb((sptr + m_vpos[v]) & 0x1fffff) << 8;
8581
8682            *mixp++ += (sample * (char)slot[0x14]) >> 8;
8783            *mixp++ += (sample * (char)slot[0x15]) >> 8;
trunk/src/emu/sound/st0016.h
r32709r32710
88//  INTERFACE CONFIGURATION MACROS
99//**************************************************************************
1010
11#define MCFG_ST0016_ADD(_tag, _clock) \
12   MCFG_DEVICE_ADD(_tag, ST0016, _clock)
13#define MCFG_ST0016_REPLACE(_tag, _clock) \
14   MCFG_DEVICE_REPLACE(_tag, ST0016, _clock)
11#define MCFG_ST0016_SOUNDRAM_READ_CB(_devcb) \
12   devcb = &st0016_device::set_soundram_callback(*device, DEVCB_##_devcb);
1513
16
1714//**************************************************************************
1815//  TYPE DEFINITIONS
1916//**************************************************************************
2017
21struct st0016_interface
22{
23   UINT8 **p_soundram;
24};
25
26
2718// ======================> st0016_device
2819
2920class st0016_device : public device_t,
r32709r32710
3324   st0016_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
3425   ~st0016_device() { }
3526
27   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); }
28
3629protected:
3730   // device-level overrides
3831   virtual void device_start();
r32709r32710
4639
4740private:
4841   sound_stream *m_stream;
49   UINT8 **m_sound_ram;
42   devcb_read8 m_ram_read_cb;
5043   int m_vpos[8];
5144   int m_frac[8];
5245   int m_lponce[8];

Previous 199869 Revisions Next


© 1997-2024 The MAME Team