trunk/src/mame/machine/st0016.c
r32709 | r32710 | |
4 | 4 | |
5 | 5 | const device_type ST0016_CPU = &device_creator<st0016_cpu_device>; |
6 | 6 | |
7 | | UINT8 *st0016_charram; // todo, get it in the device |
8 | 7 | UINT8 macs_cart_slot; |
9 | 8 | |
10 | 9 | |
r32709 | r32710 | |
103 | 102 | } |
104 | 103 | } |
105 | 104 | |
106 | | static const st0016_interface st0016_config = |
| 105 | READ8_MEMBER(st0016_cpu_device::soundram_read) |
107 | 106 | { |
108 | | &st0016_charram |
109 | | }; |
| 107 | return m_charram[offset]; |
| 108 | } |
110 | 109 | |
111 | 110 | static GFXDECODE_START( st0016 ) |
112 | 111 | GFXDECODE_END |
r32709 | r32710 | |
118 | 117 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", st0016) |
119 | 118 | MCFG_PALETTE_ADD("palette", 16*16*4+1) |
120 | 119 | |
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)) |
123 | 122 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
124 | 123 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |
125 | 124 | |
r32709 | r32710 | |
223 | 222 | |
224 | 223 | READ8_MEMBER(st0016_cpu_device::st0016_character_ram_r) |
225 | 224 | { |
226 | | return st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]; |
| 225 | return m_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]; |
227 | 226 | } |
228 | 227 | |
229 | 228 | WRITE8_MEMBER(st0016_cpu_device::st0016_character_ram_w) |
230 | 229 | { |
231 | | st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data; |
| 230 | m_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data; |
232 | 231 | m_gfxdecode->gfx(st0016_ramgfx)->mark_dirty(st0016_char_bank); |
233 | 232 | } |
234 | 233 | |
r32709 | r32710 | |
569 | 568 | save_item(NAME(st0016_char_bank)); |
570 | 569 | //save_item(NAME(st0016_rom_bank)); |
571 | 570 | 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); |
573 | 572 | save_pointer(NAME(st0016_paletteram), ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE); |
574 | 573 | save_pointer(NAME(st0016_spriteram), ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE); |
575 | 574 | } |
r32709 | r32710 | |
580 | 579 | int gfx_index=0; |
581 | 580 | |
582 | 581 | 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); |
584 | 583 | st0016_spriteram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE); |
585 | 584 | st0016_paletteram=auto_alloc_array_clear(machine(), UINT8, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE); |
586 | 585 | |
r32709 | r32710 | |
592 | 591 | assert(gfx_index != MAX_GFX_ELEMENTS); |
593 | 592 | |
594 | 593 | /* 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))); |
596 | 595 | st0016_ramgfx = gfx_index; |
597 | 596 | |
598 | 597 | spr_dx=0; |
trunk/src/emu/sound/st0016.c
r32709 | r32710 | |
26 | 26 | : device_t(mconfig, ST0016, "ST0016 (Audio)", tag, owner, clock, "st0016_audio", __FILE__), |
27 | 27 | device_sound_interface(mconfig, *this), |
28 | 28 | m_stream(NULL), |
29 | | m_sound_ram(NULL) |
| 29 | m_ram_read_cb(*this) |
30 | 30 | { |
31 | 31 | memset(m_vpos, 0, sizeof(int)*8); |
32 | 32 | memset(m_frac, 0, sizeof(int)*8); |
r32709 | r32710 | |
41 | 41 | |
42 | 42 | void st0016_device::device_start() |
43 | 43 | { |
44 | | const st0016_interface *intf = (const st0016_interface *)static_config(); |
45 | | |
46 | | m_sound_ram = intf->p_soundram; |
47 | | |
48 | 44 | m_stream = stream_alloc(0, 2, 44100); |
| 45 | m_ram_read_cb.resolve_safe(0); |
49 | 46 | } |
50 | 47 | |
51 | 48 | |
r32709 | r32710 | |
55 | 52 | |
56 | 53 | void st0016_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
57 | 54 | { |
58 | | UINT8 *sound_ram = *m_sound_ram; |
59 | 55 | int v, i, snum; |
60 | 56 | unsigned char *slot; |
61 | 57 | INT32 mix[48000*2]; |
r32709 | r32710 | |
81 | 77 | |
82 | 78 | for (snum = 0; snum < samples; snum++) |
83 | 79 | { |
84 | | sample = sound_ram[(sptr + m_vpos[v])&0x1fffff]<<8; |
| 80 | sample = m_ram_read_cb((sptr + m_vpos[v]) & 0x1fffff) << 8; |
85 | 81 | |
86 | 82 | *mixp++ += (sample * (char)slot[0x14]) >> 8; |
87 | 83 | *mixp++ += (sample * (char)slot[0x15]) >> 8; |
trunk/src/emu/sound/st0016.h
r32709 | r32710 | |
8 | 8 | // INTERFACE CONFIGURATION MACROS |
9 | 9 | //************************************************************************** |
10 | 10 | |
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); |
15 | 13 | |
16 | | |
17 | 14 | //************************************************************************** |
18 | 15 | // TYPE DEFINITIONS |
19 | 16 | //************************************************************************** |
20 | 17 | |
21 | | struct st0016_interface |
22 | | { |
23 | | UINT8 **p_soundram; |
24 | | }; |
25 | | |
26 | | |
27 | 18 | // ======================> st0016_device |
28 | 19 | |
29 | 20 | class st0016_device : public device_t, |
r32709 | r32710 | |
33 | 24 | st0016_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
34 | 25 | ~st0016_device() { } |
35 | 26 | |
| 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 | |
36 | 29 | protected: |
37 | 30 | // device-level overrides |
38 | 31 | virtual void device_start(); |
r32709 | r32710 | |
46 | 39 | |
47 | 40 | private: |
48 | 41 | sound_stream *m_stream; |
49 | | UINT8 **m_sound_ram; |
| 42 | devcb_read8 m_ram_read_cb; |
50 | 43 | int m_vpos[8]; |
51 | 44 | int m_frac[8]; |
52 | 45 | int m_lponce[8]; |