Previous 199869 Revisions Next

r23882 Sunday 23rd June, 2013 at 16:09:04 UTC by Fabio Priuli
Modernized MSM5232 device. [Osso]
[src/emu/sound]msm5232.c msm5232.h
[src/mame/drivers]40love.c bigevglf.c buggychl.c equites.c flstory.c ladyfrog.c msisaac.c nycaptor.c
[src/mame/includes]40love.h bigevglf.h buggychl.h ladyfrog.h nycaptor.h

trunk/src/mame/includes/buggychl.h
r23881r23882
22    buggychl
33*/
44
5#include "sound/msm5232.h"
6
57class buggychl_state : public driver_device
68{
79public:
r23881r23882
1416      m_scrollh(*this, "scrollh"),
1517      m_audiocpu(*this, "audiocpu"),
1618      m_maincpu(*this, "maincpu"),
17      m_mcu(*this, "mcu") { }
19      m_mcu(*this, "mcu"),
20      m_msm(*this, "msm") { }
1821
1922   /* memory pointers */
2023   required_shared_ptr<UINT8> m_charram;
r23881r23882
6669   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6770   required_device<cpu_device> m_maincpu;
6871   required_device<cpu_device> m_mcu;
72   required_device<msm5232_device> m_msm;
6973};
trunk/src/mame/includes/nycaptor.h
r23881r23882
1#include "sound/msm5232.h"
12
23class nycaptor_state : public driver_device
34{
r23881r23882
1011      m_maincpu(*this, "maincpu"),
1112      m_audiocpu(*this, "audiocpu"),
1213      m_subcpu(*this, "sub"),
13      m_mcu(*this, "mcu"){ }
14      m_mcu(*this, "mcu"),
15      m_msm(*this, "msm") { }
1416
1517   /* memory pointers */
1618   required_shared_ptr<UINT8> m_videoram;
r23881r23882
5456   required_device<cpu_device> m_audiocpu;
5557   required_device<cpu_device> m_subcpu;
5658   optional_device<cpu_device> m_mcu;
59   required_device<msm5232_device> m_msm;
5760   DECLARE_WRITE8_MEMBER(sub_cpu_halt_w);
5861   DECLARE_READ8_MEMBER(from_snd_r);
5962   DECLARE_WRITE8_MEMBER(to_main_w);
trunk/src/mame/includes/40love.h
r23881r23882
109109   void draw_pixram( bitmap_ind16 &bitmap, const rectangle &cliprect );
110110   required_device<cpu_device> m_maincpu;
111111   optional_device<cpu_device> m_mcu;
112   optional_device<msm5232_device> m_msm;
112   required_device<msm5232_device> m_msm;
113113};
trunk/src/mame/includes/bigevglf.h
r23881r23882
1#include "sound/msm5232.h"
12
23class bigevglf_state : public driver_device
34{
r23881r23882
910      m_spriteram2(*this, "spriteram2"),
1011      m_audiocpu(*this, "audiocpu"),
1112      m_mcu(*this, "mcu"),
12      m_maincpu(*this, "maincpu") { }
13      m_maincpu(*this, "maincpu"),
14      m_msm(*this, "msm") { }
1315
1416   /* memory pointers */
1517   required_shared_ptr<UINT8> m_paletteram;
r23881r23882
98100   TIMER_CALLBACK_MEMBER(deferred_ls74_w);
99101   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
100102   required_device<cpu_device> m_maincpu;
103   required_device<msm5232_device> m_msm;
101104};
trunk/src/mame/includes/ladyfrog.h
r23881r23882
44
55*************************************************************************/
66
7#include "sound/msm5232.h"
8
79class ladyfrog_state : public driver_device
810{
911public:
r23881r23882
1214      m_videoram(*this, "videoram"),
1315      m_scrlram(*this, "scrlram"),
1416      m_audiocpu(*this, "audiocpu"),
15      m_maincpu(*this, "maincpu") { }
17      m_maincpu(*this, "maincpu"),
18      m_msm(*this, "msm")   { }
1619
1720   /* memory pointers */
1821   required_shared_ptr<UINT8> m_videoram;
r23881r23882
6467   TIMER_CALLBACK_MEMBER(nmi_callback);
6568   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6669   required_device<cpu_device> m_maincpu;
70   required_device<msm5232_device> m_msm;
6771};
trunk/src/mame/drivers/flstory.c
r23881r23882
1313#include "cpu/z80/z80.h"
1414#include "cpu/m6805/m6805.h"
1515#include "sound/ay8910.h"
16#include "sound/msm5232.h"
1716#include "sound/dac.h"
1817#include "includes/flstory.h"
1918
r23881r23882
429428   AM_RANGE(0x0000, 0xbfff) AM_ROM
430429   AM_RANGE(0xc000, 0xc7ff) AM_RAM
431430   AM_RANGE(0xc800, 0xc801) AM_DEVWRITE("aysnd", ay8910_device, address_data_w)
432   AM_RANGE(0xca00, 0xca0d) AM_DEVWRITE_LEGACY("msm", msm5232_w)
431   AM_RANGE(0xca00, 0xca0d) AM_DEVWRITE("msm", msm5232_device, write)
433432   AM_RANGE(0xcc00, 0xcc00) AM_WRITE(sound_control_0_w)
434433   AM_RANGE(0xce00, 0xce00) AM_WRITE(sound_control_1_w)
435434   AM_RANGE(0xd800, 0xd800) AM_READ(soundlatch_byte_r) AM_WRITE(to_main_w)
trunk/src/mame/drivers/buggychl.c
r23881r23882
7979#include "cpu/z80/z80.h"
8080#include "cpu/m6805/m6805.h"
8181#include "sound/ay8910.h"
82#include "sound/msm5232.h"
8382#include "machine/buggychl.h"
8483#include "includes/buggychl.h"
8584
r23881r23882
164163   AM_RANGE(0x4000, 0x47ff) AM_RAM
165164   AM_RANGE(0x4800, 0x4801) AM_DEVWRITE("ay1", ay8910_device, address_data_w)
166165   AM_RANGE(0x4802, 0x4803) AM_DEVWRITE("ay2", ay8910_device, address_data_w)
167   AM_RANGE(0x4810, 0x481d) AM_DEVWRITE_LEGACY("msm", msm5232_w)
166   AM_RANGE(0x4810, 0x481d) AM_DEVWRITE("msm", msm5232_device, write)
168167   AM_RANGE(0x4820, 0x4820) AM_RAM /* VOL/BAL   for the 7630 on the MSM5232 output */
169168   AM_RANGE(0x4830, 0x4830) AM_RAM /* TRBL/BASS for the 7630 on the MSM5232 output  */
170169   AM_RANGE(0x5000, 0x5000) AM_READ(soundlatch_byte_r)
trunk/src/mame/drivers/40love.c
r23881r23882
227227#include "cpu/m6805/m6805.h"
228228#include "sound/ay8910.h"
229229#include "sound/dac.h"
230#include "sound/msm5232.h"
231230#include "machine/buggychl.h"
232231#include "includes/40love.h"
233232
r23881r23882
739738   AM_RANGE(0x0000, 0xbfff) AM_ROM
740739   AM_RANGE(0xc000, 0xc7ff) AM_RAM
741740   AM_RANGE(0xc800, 0xc801) AM_DEVWRITE("aysnd", ay8910_device, address_data_w)
742   AM_RANGE(0xca00, 0xca0d) AM_DEVWRITE_LEGACY("msm", msm5232_w)
741   AM_RANGE(0xca00, 0xca0d) AM_DEVWRITE("msm", msm5232_device, write)
743742   AM_RANGE(0xcc00, 0xcc00) AM_WRITE(sound_control_0_w)
744743   AM_RANGE(0xce00, 0xce00) AM_WRITE(sound_control_1_w)
745744   AM_RANGE(0xd800, 0xd800) AM_READ(soundlatch_byte_r) AM_WRITE(to_main_w)
trunk/src/mame/drivers/msisaac.c
r23881r23882
1010#include "cpu/z80/z80.h"
1111#include "cpu/m6805/m6805.h"
1212#include "sound/ay8910.h"
13#include "sound/msm5232.h"
1413#include "machine/buggychl.h"
1514#include "includes/msisaac.h"
1615
r23881r23882
259258   AM_RANGE(0x4000, 0x47ff) AM_RAM
260259   AM_RANGE(0x8000, 0x8001) AM_DEVWRITE("ay1", ay8910_device, address_data_w)
261260   AM_RANGE(0x8002, 0x8003) AM_DEVWRITE("ay2", ay8910_device, address_data_w)
262   AM_RANGE(0x8010, 0x801d) AM_DEVWRITE_LEGACY("msm", msm5232_w)
261   AM_RANGE(0x8010, 0x801d) AM_DEVWRITE("msm", msm5232_device, write)
263262   AM_RANGE(0x8020, 0x8020) AM_WRITE(sound_control_0_w)
264263   AM_RANGE(0x8030, 0x8030) AM_WRITE(sound_control_1_w)
265264   AM_RANGE(0xc000, 0xc000) AM_READ(soundlatch_byte_r)
trunk/src/mame/drivers/equites.c
r23881r23882
368368#include "cpu/alph8201/alph8201.h"
369369#include "cpu/i8085/i8085.h"
370370#include "sound/ay8910.h"
371#include "sound/msm5232.h"
372371#include "sound/dac.h"
373372#include "sound/samples.h"
374373#include "machine/nvram.h"
r23881r23882
404403{
405404   UINT8 frq = ioport(FRQ_ADJUSTER_TAG)->read();
406405
407   msm5232_set_clock(m_msm, MSM5232_MIN_CLOCK + frq * (MSM5232_MAX_CLOCK - MSM5232_MIN_CLOCK) / 100);
406   m_msm->set_clock(MSM5232_MIN_CLOCK + frq * (MSM5232_MAX_CLOCK - MSM5232_MIN_CLOCK) / 100);
408407//popmessage("8155: C %02x A %02x  AY: A %02x B %02x Unk:%x", m_eq8155_port_c, m_eq8155_port_a, m_ay_port_a, m_ay_port_b, m_eq_cymbal_ctrl & 15);
409408
410409   m_cymvol *= 0.94f;
r23881r23882
740739static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, equites_state )
741740   AM_RANGE(0x0000, 0xbfff) AM_ROM
742741   AM_RANGE(0xc000, 0xc000) AM_READ(soundlatch_byte_r)
743   AM_RANGE(0xc080, 0xc08d) AM_DEVWRITE_LEGACY("msm", msm5232_w)
742   AM_RANGE(0xc080, 0xc08d) AM_DEVWRITE("msm", msm5232_device, write)
744743   AM_RANGE(0xc0a0, 0xc0a1) AM_DEVWRITE("aysnd", ay8910_device, data_address_w)
745744   AM_RANGE(0xc0b0, 0xc0b0) AM_WRITENOP // n.c.
746745   AM_RANGE(0xc0c0, 0xc0c0) AM_WRITE(equites_cymbal_ctrl_w)
trunk/src/mame/drivers/bigevglf.c
r23881r23882
5858#include "emu.h"
5959#include "cpu/z80/z80.h"
6060#include "sound/ay8910.h"
61#include "sound/msm5232.h"
6261#include "cpu/m6805/m6805.h"
6362#include "includes/bigevglf.h"
6463
r23881r23882
364363   AM_RANGE(0x0000, 0xbfff) AM_ROM
365364   AM_RANGE(0xc000, 0xc7ff) AM_RAM
366365   AM_RANGE(0xc800, 0xc801) AM_DEVWRITE("aysnd", ay8910_device, address_data_w)
367   AM_RANGE(0xca00, 0xca0d) AM_DEVWRITE_LEGACY("msm", msm5232_w)
366   AM_RANGE(0xca00, 0xca0d) AM_DEVWRITE("msm", msm5232_device, write)
368367   AM_RANGE(0xcc00, 0xcc00) AM_WRITENOP
369368   AM_RANGE(0xce00, 0xce00) AM_WRITENOP
370369   AM_RANGE(0xd800, 0xd800) AM_READWRITE(sound_command_r, beg_fromsound_w) /* write to D800 sets bit 1 in status */
trunk/src/mame/drivers/ladyfrog.c
r23881r23882
4949#include "emu.h"
5050#include "cpu/z80/z80.h"
5151#include "sound/ay8910.h"
52#include "sound/msm5232.h"
5352#include "includes/ladyfrog.h"
5453
5554
r23881r23882
150149   AM_RANGE(0xc000, 0xc7ff) AM_RAM
151150   AM_RANGE(0xc800, 0xc801) AM_WRITENOP
152151   AM_RANGE(0xc802, 0xc803) AM_DEVWRITE("aysnd", ay8910_device, address_data_w)
153   AM_RANGE(0xc900, 0xc90d) AM_DEVWRITE_LEGACY("msm", msm5232_w)
152   AM_RANGE(0xc900, 0xc90d) AM_DEVWRITE("msm", msm5232_device, write)
154153   AM_RANGE(0xca00, 0xca00) AM_WRITENOP
155154   AM_RANGE(0xcb00, 0xcb00) AM_WRITENOP
156155   AM_RANGE(0xcc00, 0xcc00) AM_WRITENOP
trunk/src/mame/drivers/nycaptor.c
r23881r23882
196196#include "cpu/m6805/m6805.h"
197197#include "includes/taitoipt.h"
198198#include "sound/ay8910.h"
199#include "sound/msm5232.h"
200199#include "includes/nycaptor.h"
201200
202201
r23881r23882
382381   AM_RANGE(0xc000, 0xc7ff) AM_RAM
383382   AM_RANGE(0xc800, 0xc801) AM_DEVWRITE("ay1", ay8910_device, address_data_w)
384383   AM_RANGE(0xc802, 0xc803) AM_DEVWRITE("ay2", ay8910_device, address_data_w)
385   AM_RANGE(0xc900, 0xc90d) AM_DEVWRITE_LEGACY("msm", msm5232_w)
384   AM_RANGE(0xc900, 0xc90d) AM_DEVWRITE("msm", msm5232_device, write)
386385   AM_RANGE(0xca00, 0xca00) AM_WRITENOP
387386   AM_RANGE(0xcb00, 0xcb00) AM_WRITENOP
388387   AM_RANGE(0xcc00, 0xcc00) AM_WRITENOP
trunk/src/emu/sound/msm5232.c
r23881r23882
99    8 channel tone generator
1010*/
1111
12struct VOICE {
13   UINT8 mode;
12const device_type MSM5232 = &device_creator<msm5232_device>;
1413
15   int     TG_count_period;
16   int     TG_count;
14msm5232_device::msm5232_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
15   : device_t(mconfig, MSM5232, "MSM5232", tag, owner, clock, "msm5232", __FILE__),
16      device_sound_interface(mconfig, *this)
17{
18}
1719
18   UINT8   TG_cnt;     /* 7 bits binary counter (frequency output) */
19   UINT8   TG_out16;   /* bit number (of TG_cnt) for 16' output */
20   UINT8   TG_out8;    /* bit number (of TG_cnt) for  8' output */
21   UINT8   TG_out4;    /* bit number (of TG_cnt) for  4' output */
22   UINT8   TG_out2;    /* bit number (of TG_cnt) for  2' output */
20//-------------------------------------------------
21//  device_config_complete - perform any
22//  operations now that the configuration is
23//  complete
24//-------------------------------------------------
2325
24   int     egvol;
25   int     eg_sect;
26   int     counter;
27   int     eg;
26void msm5232_device::device_config_complete()
27{
28   // inherit a copy of the static data
29   const msm5232_interface *intf = reinterpret_cast<const msm5232_interface *>(static_config());
30   if (intf != NULL)
31   *static_cast<msm5232_interface *>(this) = *intf;
32   
33   // or initialize to defaults if none provided
34   else
35   {
36   memset(&m_gate_handler_cb, 0, sizeof(m_gate_handler_cb));
37   }
38}
2839
29   UINT8   eg_arm;     /* attack/release mode */
40//-------------------------------------------------
41//  device_start - device-specific startup
42//-------------------------------------------------
3043
31   double  ar_rate;
32   double  dr_rate;
33   double  rr_rate;
44void msm5232_device::device_start()
45{
46   int rate = clock()/CLOCK_RATE_DIVIDER;
47   int voicenum;
3448
35   int     pitch;          /* current pitch data */
49   init(clock(), rate);
3650
37   int GF;
38};
51   m_stream = machine().sound().stream_alloc(*this, 0, 11, rate, this);
3952
53   /* register with the save state system */
54   machine().save().register_postload(save_prepost_delegate(FUNC(msm5232_device::postload), this));
55   save_item(NAME(m_EN_out16));
56   save_item(NAME(m_EN_out8));
57   save_item(NAME(m_EN_out4));
58   save_item(NAME(m_EN_out2));
59   save_item(NAME(m_noise_cnt));
60   save_item(NAME(m_noise_rng));
61   save_item(NAME(m_noise_clocks));
62   save_item(NAME(m_control1));
63   save_item(NAME(m_control2));
64   save_item(NAME(m_gate));
65   save_item(NAME(m_chip_clock));
66   save_item(NAME(m_rate));
4067
41struct msm5232_state {
42   sound_stream *stream;
68   /* register voice-specific data for save states */
69   for (voicenum = 0; voicenum < 8; voicenum++)
70   {
71      VOICE *voice = &m_voi[voicenum];
4372
44   VOICE   voi[8];
73      save_item(NAME(voice->mode), voicenum);
74      save_item(NAME(voice->TG_count_period), voicenum);
75      save_item(NAME(voice->TG_cnt), voicenum);
76      save_item(NAME(voice->TG_out16), voicenum);
77      save_item(NAME(voice->TG_out8), voicenum);
78      save_item(NAME(voice->TG_out4), voicenum);
79      save_item(NAME(voice->TG_out2), voicenum);
80      save_item(NAME(voice->egvol), voicenum);
81      save_item(NAME(voice->eg_sect), voicenum);
82      save_item(NAME(voice->counter), voicenum);
83      save_item(NAME(voice->eg), voicenum);
84      save_item(NAME(voice->eg_arm), voicenum);
85      save_item(NAME(voice->ar_rate), voicenum);
86      save_item(NAME(voice->dr_rate), voicenum);
87      save_item(NAME(voice->pitch), voicenum);
88      save_item(NAME(voice->GF), voicenum);
89   }
90}
4591
46   UINT32 EN_out16[2]; /* enable 16' output masks for both groups (0-disabled ; ~0 -enabled) */
47   UINT32 EN_out8[2];  /* enable 8'  output masks */
48   UINT32 EN_out4[2];  /* enable 4'  output masks */
49   UINT32 EN_out2[2];  /* enable 2'  output masks */
92//-------------------------------------------------
93//  device_reset - device-specific reset
94//-------------------------------------------------
5095
51   int noise_cnt;
52   int noise_step;
53   int noise_rng;
54   int noise_clocks;   /* number of the noise_rng (output) level changes */
96void msm5232_device::device_reset()
97{
98   int i;
5599
56   unsigned int UpdateStep;
100   for (i=0; i<8; i++)
101   {
102      write(machine().driver_data()->generic_space(),i,0x80);
103      write(machine().driver_data()->generic_space(),i,0x00);
104   }
105   m_noise_cnt     = 0;
106   m_noise_rng     = 1;
107   m_noise_clocks  = 0;
57108
58   /* rate tables */
59   double  ar_tbl[8];
60   double  dr_tbl[16];
109   m_control1      = 0;
110   m_EN_out16[0]   = 0;
111   m_EN_out8[0]    = 0;
112   m_EN_out4[0]    = 0;
113   m_EN_out2[0]    = 0;
61114
62   UINT8   control1;
63   UINT8   control2;
115   m_control2      = 0;
116   m_EN_out16[1]   = 0;
117   m_EN_out8[1]    = 0;
118   m_EN_out4[1]    = 0;
119   m_EN_out2[1]    = 0;
64120
65   int     gate;       /* current state of the GATE output */
121   gate_update();
122}
66123
67   int     clock;      /* chip clock in Hz */
68   int     rate;       /* sample rate in Hz */
124//-------------------------------------------------
125//  device_stop - device-specific stop
126//-------------------------------------------------
69127
70   double  external_capacity[8]; /* in Farads, eg 0.39e-6 = 0.36 uF (microFarads) */
71   device_t *device;
72   devcb_resolved_write_line gate_handler;/* callback called when the GATE output pin changes state */
73
74};
75
76
77INLINE msm5232_state *get_safe_token(device_t *device)
128void msm5232_device::device_stop()
78129{
79   assert(device != NULL);
80   assert(device->type() == MSM5232);
81   return (msm5232_state *)downcast<msm5232_device *>(device)->token();
130   #ifdef SAVE_SAMPLE
131   fclose(sample[8]);
132#endif
133#ifdef SAVE_SEPARATE_CHANNELS
134   fclose(sample[0]);
135   fclose(sample[1]);
136   fclose(sample[2]);
137   fclose(sample[3]);
138   fclose(sample[4]);
139   fclose(sample[5]);
140   fclose(sample[6]);
141   fclose(sample[7]);
142#endif
82143}
83144
84145
r23881r23882
171232
172233
173234
174static void msm5232_init_tables( msm5232_state *chip )
235void msm5232_device::init_tables()
175236{
176237   int i;
177238   double scale;
r23881r23882
180241   /* highest possible frequency is chipclock/13/16 (pitch data=0x57) */
181242   /* at 2MHz : 2000000/13/16 = 9615 Hz */
182243
183   i = ((double)(1<<STEP_SH) * (double)chip->rate) / (double)chip->clock;
184   chip->UpdateStep = i;
244   i = ((double)(1<<STEP_SH) * (double)m_rate) / (double)m_chip_clock;
245   m_UpdateStep = i;
185246   /* logerror("clock=%i Hz rate=%i Hz, UpdateStep=%i\n",
186           chip->clock, chip->rate, chip->UpdateStep); */
247           m_chip_clock, m_rate, m_UpdateStep); */
187248
188   scale = ((double)chip->clock) / (double)chip->rate;
189   chip->noise_step = ((1<<STEP_SH)/128.0) * scale; /* step of the rng reg in 16.16 format */
190   /* logerror("noise step=%8x\n", chip->noise_step); */
249   scale = ((double)m_chip_clock) / (double)m_rate;
250   m_noise_step = ((1<<STEP_SH)/128.0) * scale; /* step of the rng reg in 16.16 format */
251   /* logerror("noise step=%8x\n", m_noise_step); */
191252
192253#if 0
193254{
r23881r23882
197258                     333,500,1000,2000, 4000,8000, 4000,8000};
198259   for (i=0; i<8; i++)
199260   {
200      double clockscale = (double)chip->clock / 2119040.0;
261      double clockscale = (double)m_chip_clock / 2119040.0;
201262      double time = (ATBL[i] / 1000.0) / clockscale;  /* attack time in seconds */
202      chip->ar_tbl[i] = 0.50 * ( (1.0/time) / (double)chip->rate );
203      /* logerror("ATBL[%i] = %20.16f time = %f s\n",i, chip->ar_tbl[i], time); */
263      m_ar_tbl[i] = 0.50 * ( (1.0/time) / (double)m_rate );
264      /* logerror("ATBL[%i] = %20.16f time = %f s\n",i, m_ar_tbl[i], time); */
204265   }
205266
206267   for (i=0; i<16; i++)
207268   {
208      double clockscale = (double)chip->clock / 2119040.0;
269      double clockscale = (double)m_chip_clock / 2119040.0;
209270      double time = (DTBL[i] / 1000.0) / clockscale;  /* decay time in seconds */
210      chip->dr_tbl[i] = 0.50 * ( (1.0/time) / (double)chip->rate );
211      /* logerror("DTBL[%i] = %20.16f time = %f s\n",i, chip->dr_tbl[i], time); */
271      m_dr_tbl[i] = 0.50 * ( (1.0/time) / (double)m_rate );
272      /* logerror("DTBL[%i] = %20.16f time = %f s\n",i, m_dr_tbl[i], time); */
212273   }
213274}
214275#endif
r23881r23882
216277
217278   for (i=0; i<8; i++)
218279   {
219      double clockscale = (double)chip->clock / 2119040.0;
220      chip->ar_tbl[i]   = ((1<<i) / clockscale) * (double)R51;
280      double clockscale = (double)m_chip_clock / 2119040.0;
281      m_ar_tbl[i]   = ((1<<i) / clockscale) * (double)R51;
221282   }
222283
223284   for (i=0; i<8; i++)
224285   {
225      double clockscale = (double)chip->clock / 2119040.0;
226      chip->dr_tbl[i]   = (     (1<<i) / clockscale) * (double)R52;
227      chip->dr_tbl[i+8] = (6.25*(1<<i) / clockscale) * (double)R52;
286      double clockscale = (double)m_chip_clock / 2119040.0;
287      m_dr_tbl[i]   = (     (1<<i) / clockscale) * (double)R52;
288      m_dr_tbl[i+8] = (6.25*(1<<i) / clockscale) * (double)R52;
228289   }
229290
230291
r23881r23882
244305}
245306
246307
247static void msm5232_init_voice(msm5232_state *chip, int i)
308void msm5232_device::init_voice(int i)
248309{
249   chip->voi[i].ar_rate= chip->ar_tbl[0] * chip->external_capacity[i];
250   chip->voi[i].dr_rate= chip->dr_tbl[0] * chip->external_capacity[i];
251   chip->voi[i].rr_rate= chip->dr_tbl[0] * chip->external_capacity[i]; /* this is constant value */
252   chip->voi[i].eg_sect= -1;
253   chip->voi[i].eg     = 0.0;
254   chip->voi[i].eg_arm = 0;
255   chip->voi[i].pitch  = -1.0;
310   m_voi[i].ar_rate= m_ar_tbl[0] * m_external_capacity[i];
311   m_voi[i].dr_rate= m_dr_tbl[0] * m_external_capacity[i];
312   m_voi[i].rr_rate= m_dr_tbl[0] * m_external_capacity[i]; /* this is constant value */
313   m_voi[i].eg_sect= -1;
314   m_voi[i].eg     = 0.0;
315   m_voi[i].eg_arm = 0;
316   m_voi[i].pitch  = -1.0;
256317}
257318
258319
259static void msm5232_gate_update(msm5232_state *chip)
320void msm5232_device::gate_update()
260321{
261   int new_state = (chip->control2 & 0x20) ? chip->voi[7].GF : 0;
322   int new_state = (m_control2 & 0x20) ? m_voi[7].GF : 0;
262323
263   if (chip->gate != new_state && !chip->gate_handler.isnull())
324   if (m_gate != new_state && !m_gate_handler_func.isnull())
264325   {
265      chip->gate = new_state;
266      chip->gate_handler(new_state);
326      m_gate = new_state;
327      m_gate_handler_func(new_state);
267328   }
268329}
269330
270
271static DEVICE_RESET( msm5232 )
331void msm5232_device::init(int clock, int rate)
272332{
273   msm5232_state *chip = get_safe_token(device);
274   int i;
275
276   for (i=0; i<8; i++)
277   {
278      msm5232_w(device,device->machine().driver_data()->generic_space(),i,0x80);
279      msm5232_w(device,device->machine().driver_data()->generic_space(),i,0x00);
280   }
281   chip->noise_cnt     = 0;
282   chip->noise_rng     = 1;
283   chip->noise_clocks  = 0;
284
285   chip->control1      = 0;
286   chip->EN_out16[0]   = 0;
287   chip->EN_out8[0]    = 0;
288   chip->EN_out4[0]    = 0;
289   chip->EN_out2[0]    = 0;
290
291   chip->control2      = 0;
292   chip->EN_out16[1]   = 0;
293   chip->EN_out8[1]    = 0;
294   chip->EN_out4[1]    = 0;
295   chip->EN_out2[1]    = 0;
296
297   msm5232_gate_update(chip);
298}
299
300static void msm5232_init(msm5232_state *chip, const msm5232_interface *intf, int clock, int rate)
301{
302333   int j;
303334
304   chip->clock = clock;
305   chip->rate  = rate ? rate : 44100;  /* avoid division by 0 */
335   m_chip_clock = clock;
336   m_rate  = rate ? rate : 44100;  /* avoid division by 0 */
306337
307338   for (j=0; j<8; j++)
308339   {
309      chip->external_capacity[j] = intf->capacity[j];
340      m_external_capacity[j] = m_capacity[j];
310341   }
311342
312   chip->gate_handler.resolve(intf->gate_handler_cb, *chip->device);
343   m_gate_handler_func.resolve(m_gate_handler_cb, *this);
313344
314   msm5232_init_tables( chip );
345   init_tables();
315346
316347   for (j=0; j<8; j++)
317348   {
318      memset(&chip->voi[j],0,sizeof(VOICE));
319      msm5232_init_voice(chip,j);
349      memset(&m_voi[j],0,sizeof(VOICE));
350      init_voice(j);
320351   }
321352}
322353
323static DEVICE_STOP( msm5232 )
324{
325#ifdef SAVE_SAMPLE
326   fclose(sample[8]);
327#endif
328#ifdef SAVE_SEPARATE_CHANNELS
329   fclose(sample[0]);
330   fclose(sample[1]);
331   fclose(sample[2]);
332   fclose(sample[3]);
333   fclose(sample[4]);
334   fclose(sample[5]);
335   fclose(sample[6]);
336   fclose(sample[7]);
337#endif
338}
339354
340WRITE8_DEVICE_HANDLER( msm5232_w )
355WRITE8_MEMBER( msm5232_device::write )
341356{
342   msm5232_state *chip = get_safe_token(device);
343
344357   if (offset > 0x0d)
345358      return;
346359
347   chip->stream->update ();
360   m_stream->update ();
348361
349362   if (offset < 0x08) /* pitch */
350363   {
351364      int ch = offset&7;
352365
353      chip->voi[ch].GF = ((data&0x80)>>7);
366      m_voi[ch].GF = ((data&0x80)>>7);
354367      if (ch == 7)
355         msm5232_gate_update(chip);
368         gate_update();
356369
357370      if(data&0x80)
358371      {
359372         if(data >= 0xd8)
360373         {
361374            /*if ((data&0x7f) != 0x5f) logerror("MSM5232: WRONG PITCH CODE = %2x\n",data&0x7f);*/
362            chip->voi[ch].mode = 1;     /* noise mode */
363            chip->voi[ch].eg_sect = 0;  /* Key On */
375            m_voi[ch].mode = 1;     /* noise mode */
376            m_voi[ch].eg_sect = 0;  /* Key On */
364377         }
365378         else
366379         {
367            if ( chip->voi[ch].pitch != (data&0x7f) )
380            if ( m_voi[ch].pitch != (data&0x7f) )
368381            {
369382               int n;
370383               UINT16 pg;
371384
372               chip->voi[ch].pitch = data&0x7f;
385               m_voi[ch].pitch = data&0x7f;
373386
374387               pg = MSM5232_ROM[ data&0x7f ];
375388
376               chip->voi[ch].TG_count_period = (pg & 0x1ff) * chip->UpdateStep / 2;
389               m_voi[ch].TG_count_period = (pg & 0x1ff) * m_UpdateStep / 2;
377390
378391               n = (pg>>9) & 7;    /* n = bit number for 16' output */
379               chip->voi[ch].TG_out16 = 1<<n;
392               m_voi[ch].TG_out16 = 1<<n;
380393                              /* for 8' it is bit n-1 (bit 0 if n-1<0) */
381394                              /* for 4' it is bit n-2 (bit 0 if n-2<0) */
382395                              /* for 2' it is bit n-3 (bit 0 if n-3<0) */
383396               n = (n>0)? n-1: 0;
384               chip->voi[ch].TG_out8  = 1<<n;
397               m_voi[ch].TG_out8  = 1<<n;
385398
386399               n = (n>0)? n-1: 0;
387               chip->voi[ch].TG_out4  = 1<<n;
400               m_voi[ch].TG_out4  = 1<<n;
388401
389402               n = (n>0)? n-1: 0;
390               chip->voi[ch].TG_out2  = 1<<n;
403               m_voi[ch].TG_out2  = 1<<n;
391404            }
392            chip->voi[ch].mode = 0;     /* tone mode */
393            chip->voi[ch].eg_sect = 0;  /* Key On */
405            m_voi[ch].mode = 0;     /* tone mode */
406            m_voi[ch].eg_sect = 0;  /* Key On */
394407         }
395408      }
396409      else
397410      {
398         if ( !chip->voi[ch].eg_arm )    /* arm = 0 */
399            chip->voi[ch].eg_sect = 2;  /* Key Off -> go to release */
411         if ( !m_voi[ch].eg_arm )    /* arm = 0 */
412            m_voi[ch].eg_sect = 2;  /* Key Off -> go to release */
400413         else                            /* arm = 1 */
401            chip->voi[ch].eg_sect = 1;  /* Key Off -> go to decay */
414            m_voi[ch].eg_sect = 1;  /* Key Off -> go to decay */
402415      }
403416   }
404417   else
r23881r23882
408421      {
409422      case 0x08:  /* group1 attack */
410423         for (i=0; i<4; i++)
411            chip->voi[i].ar_rate   = chip->ar_tbl[data&0x7] * chip->external_capacity[i];
424            m_voi[i].ar_rate   = m_ar_tbl[data&0x7] * m_external_capacity[i];
412425         break;
413426
414427      case 0x09:  /* group2 attack */
415428         for (i=0; i<4; i++)
416            chip->voi[i+4].ar_rate = chip->ar_tbl[data&0x7] * chip->external_capacity[i+4];
429            m_voi[i+4].ar_rate = m_ar_tbl[data&0x7] * m_external_capacity[i+4];
417430         break;
418431
419432      case 0x0a:  /* group1 decay */
420433         for (i=0; i<4; i++)
421            chip->voi[i].dr_rate   = chip->dr_tbl[data&0xf] * chip->external_capacity[i];
434            m_voi[i].dr_rate   = m_dr_tbl[data&0xf] * m_external_capacity[i];
422435         break;
423436
424437      case 0x0b:  /* group2 decay */
425438         for (i=0; i<4; i++)
426            chip->voi[i+4].dr_rate = chip->dr_tbl[data&0xf] * chip->external_capacity[i+4];
439            m_voi[i+4].dr_rate = m_dr_tbl[data&0xf] * m_external_capacity[i+4];
427440         break;
428441
429442      case 0x0c:  /* group1 control */
430443
431         /*if (chip->control1 != data)
444         /*if (m_control1 != data)
432445             logerror("msm5232: control1 ctrl=%x OE=%x\n", data&0xf0, data&0x0f);*/
433446
434447         /*if (data & 0x10)
435448             popmessage("msm5232: control1 ctrl=%2x\n", data);*/
436449
437         chip->control1 = data;
450         m_control1 = data;
438451
439452         for (i=0; i<4; i++)
440            chip->voi[i].eg_arm = data&0x10;
453            m_voi[i].eg_arm = data&0x10;
441454
442         chip->EN_out16[0] = (data&1) ? ~0:0;
443         chip->EN_out8[0]  = (data&2) ? ~0:0;
444         chip->EN_out4[0]  = (data&4) ? ~0:0;
445         chip->EN_out2[0]  = (data&8) ? ~0:0;
455         m_EN_out16[0] = (data&1) ? ~0:0;
456         m_EN_out8[0]  = (data&2) ? ~0:0;
457         m_EN_out4[0]  = (data&4) ? ~0:0;
458         m_EN_out2[0]  = (data&8) ? ~0:0;
446459
447460         break;
448461
449462      case 0x0d:  /* group2 control */
450463
451         /*if (chip->control2 != data)
464         /*if (m_control2 != data)
452465             logerror("msm5232: control2 ctrl=%x OE=%x\n", data&0xf0, data&0x0f);*/
453466
454467         /*if (data & 0x10)
455468             popmessage("msm5232: control2 ctrl=%2x\n", data);*/
456469
457         chip->control2 = data;
458         msm5232_gate_update(chip);
470         m_control2 = data;
471         gate_update();
459472
460473         for (i=0; i<4; i++)
461            chip->voi[i+4].eg_arm = data&0x10;
474            m_voi[i+4].eg_arm = data&0x10;
462475
463         chip->EN_out16[1] = (data&1) ? ~0:0;
464         chip->EN_out8[1]  = (data&2) ? ~0:0;
465         chip->EN_out4[1]  = (data&4) ? ~0:0;
466         chip->EN_out2[1]  = (data&8) ? ~0:0;
476         m_EN_out16[1] = (data&1) ? ~0:0;
477         m_EN_out8[1]  = (data&2) ? ~0:0;
478         m_EN_out4[1]  = (data&4) ? ~0:0;
479         m_EN_out2[1]  = (data&8) ? ~0:0;
467480
468481         break;
469482      }
r23881r23882
476489#define VMAX    32768
477490
478491
479INLINE void EG_voices_advance(msm5232_state *chip)
492void msm5232_device::EG_voices_advance()
480493{
481   VOICE *voi = &chip->voi[0];
482   int samplerate = chip->rate;
494   VOICE *voi = &m_voi[0];
495   int samplerate = m_rate;
483496   int i;
484497
485498   i = 8;
r23881r23882
578591
579592static int o2,o4,o8,o16,solo8,solo16;
580593
581INLINE void TG_group_advance(msm5232_state *chip, int groupidx)
594void msm5232_device::TG_group_advance(int groupidx)
582595{
583   VOICE *voi = &chip->voi[groupidx*4];
596   VOICE *voi = &m_voi[groupidx*4];
584597   int i;
585598
586599   o2 = o4 = o8 = o16 = solo8 = solo16 = 0;
r23881r23882
636649      }
637650      else    /* generate noise */
638651      {
639         if (chip->noise_clocks&8)   out16+=(1<<STEP_SH);
640         if (chip->noise_clocks&4)   out8 +=(1<<STEP_SH);
641         if (chip->noise_clocks&2)   out4 +=(1<<STEP_SH);
642         if (chip->noise_clocks&1)   out2 +=(1<<STEP_SH);
652         if (m_noise_clocks&8)   out16+=(1<<STEP_SH);
653         if (m_noise_clocks&4)   out8 +=(1<<STEP_SH);
654         if (m_noise_clocks&2)   out4 +=(1<<STEP_SH);
655         if (m_noise_clocks&1)   out2 +=(1<<STEP_SH);
643656      }
644657
645658      /* calculate signed output */
r23881r23882
659672   }while (i>0);
660673
661674   /* cut off disabled output lines */
662   o16 &= chip->EN_out16[groupidx];
663   o8  &= chip->EN_out8 [groupidx];
664   o4  &= chip->EN_out4 [groupidx];
665   o2  &= chip->EN_out2 [groupidx];
675   o16 &= m_EN_out16[groupidx];
676   o8  &= m_EN_out8 [groupidx];
677   o4  &= m_EN_out4 [groupidx];
678   o2  &= m_EN_out2 [groupidx];
666679}
667680
668681
r23881r23882
705718#endif
706719
707720
708static STREAM_UPDATE( MSM5232_update_one )
721/* MAME Interface */
722void msm5232_device::postload()
709723{
710   msm5232_state * chip = (msm5232_state *)param;
724   init_tables();
725}
726
727void msm5232_device::set_clock(int clock)
728{
729   if (m_chip_clock != clock)
730   {
731      m_stream->update ();
732      m_chip_clock = clock;
733      m_rate = clock/CLOCK_RATE_DIVIDER;
734      init_tables();
735      m_stream->set_sample_rate(m_rate);
736   }
737}
738
739
740//-------------------------------------------------
741//  sound_stream_update - handle a stream update
742//-------------------------------------------------
743
744void msm5232_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
745{
711746   stream_sample_t *buf1 = outputs[0];
712747   stream_sample_t *buf2 = outputs[1];
713748   stream_sample_t *buf3 = outputs[2];
r23881r23882
724759   for (i=0; i<samples; i++)
725760   {
726761      /* calculate all voices' envelopes */
727      EG_voices_advance(chip);
762      EG_voices_advance();
728763
729      TG_group_advance(chip,0);   /* calculate tones group 1 */
764      TG_group_advance(0);   /* calculate tones group 1 */
730765      buf1[i] = o2;
731766      buf2[i] = o4;
732767      buf3[i] = o8;
r23881r23882
737772      SAVE_SINGLE_CHANNEL(2,o8)
738773      SAVE_SINGLE_CHANNEL(3,o16)
739774
740      TG_group_advance(chip,1);   /* calculate tones group 2 */
775      TG_group_advance(1);   /* calculate tones group 2 */
741776      buf5[i] = o2;
742777      buf6[i] = o4;
743778      buf7[i] = o8;
r23881r23882
755790
756791      /* update noise generator */
757792      {
758         int cnt = (chip->noise_cnt+=chip->noise_step) >> STEP_SH;
759         chip->noise_cnt &= ((1<<STEP_SH)-1);
793         int cnt = (m_noise_cnt+=m_noise_step) >> STEP_SH;
794         m_noise_cnt &= ((1<<STEP_SH)-1);
760795         while (cnt > 0)
761796         {
762            int tmp = chip->noise_rng & (1<<16);        /* store current level */
797            int tmp = m_noise_rng & (1<<16);        /* store current level */
763798
764            if (chip->noise_rng&1)
765               chip->noise_rng ^= 0x24000;
766            chip->noise_rng>>=1;
799            if (m_noise_rng&1)
800               m_noise_rng ^= 0x24000;
801            m_noise_rng>>=1;
767802
768            if ( (chip->noise_rng & (1<<16)) != tmp )   /* level change detect */
769               chip->noise_clocks++;
803            if ( (m_noise_rng & (1<<16)) != tmp )   /* level change detect */
804               m_noise_clocks++;
770805
771806            cnt--;
772807         }
773808      }
774809
775      bufnoise[i] = (chip->noise_rng & (1<<16)) ? 32767 : 0;
810      bufnoise[i] = (m_noise_rng & (1<<16)) ? 32767 : 0;
776811   }
777812}
778
779
780
781/* MAME Interface */
782static void msm5232_postload(msm5232_state *chip)
783{
784   msm5232_init_tables(chip);
785}
786
787static DEVICE_START( msm5232 )
788{
789   const msm5232_interface *intf = (const msm5232_interface *)device->static_config();
790   int rate = device->clock()/CLOCK_RATE_DIVIDER;
791   msm5232_state *chip = get_safe_token(device);
792   int voicenum;
793
794   chip->device = device;
795
796   msm5232_init(chip, intf, device->clock(), rate);
797
798   chip->stream = device->machine().sound().stream_alloc(*device, 0, 11, rate, chip, MSM5232_update_one);
799
800   /* register with the save state system */
801   device->machine().save().register_postload(save_prepost_delegate(FUNC(msm5232_postload), chip));
802   device->save_item(NAME(chip->EN_out16));
803   device->save_item(NAME(chip->EN_out8));
804   device->save_item(NAME(chip->EN_out4));
805   device->save_item(NAME(chip->EN_out2));
806   device->save_item(NAME(chip->noise_cnt));
807   device->save_item(NAME(chip->noise_rng));
808   device->save_item(NAME(chip->noise_clocks));
809   device->save_item(NAME(chip->control1));
810   device->save_item(NAME(chip->control2));
811   device->save_item(NAME(chip->gate));
812   device->save_item(NAME(chip->clock));
813   device->save_item(NAME(chip->rate));
814
815   /* register voice-specific data for save states */
816   for (voicenum = 0; voicenum < 8; voicenum++)
817   {
818      VOICE *voice = &chip->voi[voicenum];
819
820      device->save_item(NAME(voice->mode), voicenum);
821      device->save_item(NAME(voice->TG_count_period), voicenum);
822      device->save_item(NAME(voice->TG_cnt), voicenum);
823      device->save_item(NAME(voice->TG_out16), voicenum);
824      device->save_item(NAME(voice->TG_out8), voicenum);
825      device->save_item(NAME(voice->TG_out4), voicenum);
826      device->save_item(NAME(voice->TG_out2), voicenum);
827      device->save_item(NAME(voice->egvol), voicenum);
828      device->save_item(NAME(voice->eg_sect), voicenum);
829      device->save_item(NAME(voice->counter), voicenum);
830      device->save_item(NAME(voice->eg), voicenum);
831      device->save_item(NAME(voice->eg_arm), voicenum);
832      device->save_item(NAME(voice->ar_rate), voicenum);
833      device->save_item(NAME(voice->dr_rate), voicenum);
834      device->save_item(NAME(voice->pitch), voicenum);
835      device->save_item(NAME(voice->GF), voicenum);
836   }
837}
838
839void msm5232_set_clock(device_t *device, int clock)
840{
841   msm5232_state *chip = get_safe_token(device);
842
843   if (chip->clock != clock)
844   {
845      chip->stream->update ();
846      chip->clock = clock;
847      chip->rate = clock/CLOCK_RATE_DIVIDER;
848      msm5232_init_tables( chip );
849      chip->stream->set_sample_rate(chip->rate);
850   }
851}
852
853const device_type MSM5232 = &device_creator<msm5232_device>;
854
855msm5232_device::msm5232_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
856   : device_t(mconfig, MSM5232, "MSM5232", tag, owner, clock, "msm5232", __FILE__),
857      device_sound_interface(mconfig, *this)
858{
859   m_token = global_alloc_clear(msm5232_state);
860}
861
862//-------------------------------------------------
863//  device_config_complete - perform any
864//  operations now that the configuration is
865//  complete
866//-------------------------------------------------
867
868void msm5232_device::device_config_complete()
869{
870}
871
872//-------------------------------------------------
873//  device_start - device-specific startup
874//-------------------------------------------------
875
876void msm5232_device::device_start()
877{
878   DEVICE_START_NAME( msm5232 )(this);
879}
880
881//-------------------------------------------------
882//  device_reset - device-specific reset
883//-------------------------------------------------
884
885void msm5232_device::device_reset()
886{
887   DEVICE_RESET_NAME( msm5232 )(this);
888}
889
890//-------------------------------------------------
891//  device_stop - device-specific stop
892//-------------------------------------------------
893
894void msm5232_device::device_stop()
895{
896   DEVICE_STOP_NAME( msm5232 )(this);
897}
898
899//-------------------------------------------------
900//  sound_stream_update - handle a stream update
901//-------------------------------------------------
902
903void msm5232_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
904{
905   // should never get here
906   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
907}
trunk/src/emu/sound/msm5232.h
r23881r23882
33#ifndef __MSM5232_H__
44#define __MSM5232_H__
55
6#include "devlegcy.h"
76
7struct VOICE {
8   UINT8 mode;
9
10   int     TG_count_period;
11   int     TG_count;
12
13   UINT8   TG_cnt;     /* 7 bits binary counter (frequency output) */
14   UINT8   TG_out16;   /* bit number (of TG_cnt) for 16' output */
15   UINT8   TG_out8;    /* bit number (of TG_cnt) for  8' output */
16   UINT8   TG_out4;    /* bit number (of TG_cnt) for  4' output */
17   UINT8   TG_out2;    /* bit number (of TG_cnt) for  2' output */
18
19   int     egvol;
20   int     eg_sect;
21   int     counter;
22   int     eg;
23
24   UINT8   eg_arm;     /* attack/release mode */
25
26   double  ar_rate;
27   double  dr_rate;
28   double  rr_rate;
29
30   int     pitch;          /* current pitch data */
31
32   int GF;
33};
34
35
836struct msm5232_interface
937{
10   double capacity[8]; /* in Farads, capacitors connected to pins: 24,25,26,27 and 37,38,39,40 */
11   devcb_write_line gate_handler_cb; /* callback called when the GATE output pin changes state */
38   double m_capacity[8]; /* in Farads, capacitors connected to pins: 24,25,26,27 and 37,38,39,40 */
39   devcb_write_line m_gate_handler_cb; /* callback called when the GATE output pin changes state */
1240};
1341
14DECLARE_WRITE8_DEVICE_HANDLER( msm5232_w );
1542
16void msm5232_set_clock(device_t *device, int clock);
17
1843class msm5232_device : public device_t,
19                           public device_sound_interface
44                           public device_sound_interface,
45                           public msm5232_interface
2046{
2147public:
2248   msm5232_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
23   ~msm5232_device() { global_free(m_token); }
49   ~msm5232_device() {}
2450
25   // access to legacy token
26   void *token() const { assert(m_token != NULL); return m_token; }
51   DECLARE_WRITE8_MEMBER( write );
52   void set_clock(int clock);   
53
2754protected:
2855   // device-level overrides
2956   virtual void device_config_complete();
r23881r23882
3360
3461   // sound stream update overrides
3562   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
36private:
63
64   private:
3765   // internal state
38   void *m_token;
66   sound_stream *m_stream;
67
68   VOICE   m_voi[8];
69
70   UINT32 m_EN_out16[2]; /* enable 16' output masks for both groups (0-disabled ; ~0 -enabled) */
71   UINT32 m_EN_out8[2];  /* enable 8'  output masks */
72   UINT32 m_EN_out4[2];  /* enable 4'  output masks */
73   UINT32 m_EN_out2[2];  /* enable 2'  output masks */
74
75   int m_noise_cnt;
76   int m_noise_step;
77   int m_noise_rng;
78   int m_noise_clocks;   /* number of the noise_rng (output) level changes */
79
80   unsigned int m_UpdateStep;
81
82   /* rate tables */
83   double  m_ar_tbl[8];
84   double  m_dr_tbl[16];
85
86   UINT8   m_control1;
87   UINT8   m_control2;
88
89   int     m_gate;       /* current state of the GATE output */
90
91   int     m_chip_clock;      /* chip clock in Hz */
92   int     m_rate;       /* sample rate in Hz */
93
94   double  m_external_capacity[8]; /* in Farads, eg 0.39e-6 = 0.36 uF (microFarads) */
95   devcb_resolved_write_line m_gate_handler_func;/* callback called when the GATE output pin changes state */
96   
97   void init_tables();
98   void init_voice(int i);
99   void gate_update();
100   void init(int clock, int rate);
101   void EG_voices_advance();
102   void TG_group_advance(int groupidx);
103   void postload();
39104};
40105
41106extern const device_type MSM5232;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team