Previous 199869 Revisions Next

r29470 Tuesday 8th April, 2014 at 20:43:13 UTC by O. Galibert
konamigx: Reverb me harder baby! [O. Galibert]
[src/emu]device.h diexec.c sound.c sound.h
[src/emu/cpu/tms57002]tms57002.c tms57002.h
[src/mame/drivers]konamigx.c

trunk/src/mame/drivers/konamigx.c
r29469r29470
10771077/**********************************************************************************/
10781078/* Sound handling */
10791079
1080INTERRUPT_GEN_MEMBER(konamigx_state::tms_sync)
1081{
1082   // DASP is synced to the LRCLK of one of the K054539s
1083   if (m_sound_ctrl & 0x20)
1084      m_dasp->sync_w(1);
1085}
1086
10871080READ16_MEMBER(konamigx_state::tms57002_data_word_r)
10881081{
10891082   return m_dasp->data_r(space, 0);
r29469r29470
16171610
16181611   MCFG_CPU_ADD("dasp", TMS57002, 24000000/2)
16191612   MCFG_CPU_DATA_MAP(gxtmsmap)
1620   MCFG_CPU_PERIODIC_INT_DRIVER(konamigx_state, tms_sync, 48000)
16211613
16221614   MCFG_QUANTUM_TIME(attotime::from_hz(6000))
16231615
r29469r29470
16581650   /* sound hardware */
16591651   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
16601652
1653   MCFG_DEVICE_MODIFY("dasp")
1654   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
1655   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
1656
16611657   MCFG_K056800_ADD("k056800", XTAL_18_432MHz)
16621658   MCFG_K056800_INT_HANDLER(INPUTLINE("soundcpu", M68K_IRQ_1))
16631659
16641660   MCFG_K054539_ADD("k054539_1", XTAL_18_432MHz, k054539_config)
16651661   MCFG_K054539_TIMER_HANDLER(WRITELINE(konamigx_state, k054539_irq_gen))
1666
1662   MCFG_SOUND_ROUTE_EX(0, "dasp", 0.9, 0)
1663   MCFG_SOUND_ROUTE_EX(1, "dasp", 0.9, 1)
16671664   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
16681665   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
16691666
16701667   MCFG_K054539_ADD("k054539_2", XTAL_18_432MHz, k054539_config)
1668   MCFG_SOUND_ROUTE_EX(0, "dasp", 0.9, 2)
1669   MCFG_SOUND_ROUTE_EX(1, "dasp", 0.9, 3)
16711670   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
16721671   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
16731672MACHINE_CONFIG_END
trunk/src/emu/sound.c
r29469r29470
9494      m_device.machine().save().save_item("stream", state_tag, outputnum, NAME(m_output[outputnum].m_gain));
9595   }
9696
97   // Mark synchronous streams as such
98   m_synchronous = m_sample_rate == STREAM_SYNC;
99   if (m_synchronous)
100   {
101      m_sample_rate = 0;
102      m_sync_timer = m_device.machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sound_stream::sync_update), this));
103   }
104   else
105      m_sync_timer = NULL;
106
97107   // force an update to the sample rates; this will cause everything to be recomputed
98108   // and will generate the initial resample buffers for our inputs
99109   recompute_sample_rate_data();
r29469r29470
284294}
285295
286296
297void sound_stream::sync_update(void *, INT32)
298{
299   update();
300   attotime time = m_device.machine().time();
301   attoseconds_t next_edge = m_attoseconds_per_sample - (time.attoseconds % m_attoseconds_per_sample);
302   m_sync_timer->adjust(attotime(0, next_edge));
303}
304
305
287306//-------------------------------------------------
288307//  output_since_last_update - return a pointer to
289308//  the output buffer and the number of samples
r29469r29470
447466
448467void sound_stream::recompute_sample_rate_data()
449468{
469   if (m_synchronous)
470   {
471      m_sample_rate = 0;
472      // When synchronous, pick the sample rate for the inputs, if any
473      for (int inputnum = 0; inputnum < m_input.count(); inputnum++)
474      {
475         stream_input &input = m_input[inputnum];
476         if (input.m_source != NULL)
477         {
478            if (!m_sample_rate)
479               m_sample_rate = input.m_source->m_stream->m_sample_rate;
480            else if (m_sample_rate != input.m_source->m_stream->m_sample_rate)
481               throw emu_fatalerror("Incompatible sample rates as input of a synchronous stream: %d and %d\n", m_sample_rate, input.m_source->m_stream->m_sample_rate);
482         }
483      }
484      if (!m_sample_rate)
485         m_sample_rate = 1000;
486   }
487
488
450489   // recompute the timing parameters
451490   attoseconds_t update_attoseconds = m_device.machine().sound().update_attoseconds();
452491   m_attoseconds_per_sample = ATTOSECONDS_PER_SECOND / m_sample_rate;
r29469r29470
483522         assert(input.m_latency_attoseconds < update_attoseconds);
484523      }
485524   }
525
526   // If synchronous, prime the timer
527   if (m_synchronous)
528   {
529      attotime time = m_device.machine().time();
530      attoseconds_t next_edge = m_attoseconds_per_sample - (time.attoseconds % m_attoseconds_per_sample);
531      m_sync_timer->adjust(attotime(0, next_edge));
532   }
486533}
487534
488535
trunk/src/emu/sound.h
r29469r29470
1919
2020
2121//**************************************************************************
22//  CONSTANTS
23//**************************************************************************
24
25const int STREAM_SYNC       = -1;       // special rate value indicating a one-sample-at-a-time stream
26                                        // with actual rate defined by its input
27
28//**************************************************************************
2229//  MACROS
2330//**************************************************************************
2431
r29469r29470
133140   void postload();
134141   void generate_samples(int samples);
135142   stream_sample_t *generate_resampled_data(stream_input &input, UINT32 numsamples);
143   void sync_update(void *, INT32);
136144
137145   // linking information
138   device_t &          m_device;               // owning device
139   sound_stream *      m_next;                 // next stream in the chain
146   device_t &          m_device;                     // owning device
147   sound_stream *      m_next;                       // next stream in the chain
140148
141149   // general information
142   UINT32              m_sample_rate;          // sample rate of this stream
143   UINT32              m_new_sample_rate;      // newly-set sample rate for the stream
150   UINT32              m_sample_rate;                // sample rate of this stream
151   UINT32              m_new_sample_rate;            // newly-set sample rate for the stream
152   bool                m_synchronous;                // synchronous stream that runs at the rate of its input
144153
145154   // timing information
146   attoseconds_t       m_attoseconds_per_sample;// number of attoseconds per sample
147   INT32               m_max_samples_per_update;// maximum samples per update
155   attoseconds_t       m_attoseconds_per_sample;     // number of attoseconds per sample
156   INT32               m_max_samples_per_update;     // maximum samples per update
157   emu_timer *         m_sync_timer;                 // update timer for synchronous streams
148158
149159   // input information
150   dynamic_array<stream_input> m_input;        // list of streams we directly depend upon
151   dynamic_array<stream_sample_t *> m_input_array; // array of inputs for passing to the callback
160   dynamic_array<stream_input> m_input;              // list of streams we directly depend upon
161   dynamic_array<stream_sample_t *> m_input_array;   // array of inputs for passing to the callback
152162
153163   // resample buffer information
154   UINT32              m_resample_bufalloc;    // allocated size of each resample buffer
164   UINT32              m_resample_bufalloc;          // allocated size of each resample buffer
155165
156166   // output information
157   dynamic_array<stream_output> m_output;      // list of streams which directly depend upon us
158   dynamic_array<stream_sample_t *> m_output_array; // array of outputs for passing to the callback
167   dynamic_array<stream_output> m_output;            // list of streams which directly depend upon us
168   dynamic_array<stream_sample_t *> m_output_array;  // array of outputs for passing to the callback
159169
160170   // output buffer information
161   UINT32              m_output_bufalloc;      // allocated size of each output buffer
162   INT32               m_output_sampindex;     // current position within each output buffer
163   INT32               m_output_update_sampindex;// position at time of last global update
164   INT32               m_output_base_sampindex;// sample at base of buffer, relative to the current emulated second
171   UINT32              m_output_bufalloc;            // allocated size of each output buffer
172   INT32               m_output_sampindex;           // current position within each output buffer
173   INT32               m_output_update_sampindex;    // position at time of last global update
174   INT32               m_output_base_sampindex;      // sample at base of buffer, relative to the current emulated second
165175
166176   // callback information
167   stream_update_func  m_callback;             // callback function
168   void *              m_param;                // callback function parameter
177   stream_update_func  m_callback;                   // callback function
178   void *              m_param;                      // callback function parameter
169179};
170180
171181
trunk/src/emu/device.h
r29469r29470
322322   template<class _InterfaceClass> bool next(_InterfaceClass *&intf) const { return m_device.next(intf); }
323323
324324   // optional operation overrides
325   //
326   // WARNING: interface_pre_start must be callable multiple times in
327   // case another interface throws a missing dependency.  In
328   // particular, state saving registrations should be done in post.
325329   virtual void interface_config_complete();
326330   virtual void interface_validity_check(validity_checker &valid) const;
327331   virtual void interface_pre_start();
trunk/src/emu/diexec.c
r29469r29470
492492   m_profiler = profile_type(index + PROFILER_DEVICE_FIRST);
493493   m_inttrigger = index + TRIGGER_INT;
494494
495   // fill in the input states and IRQ callback information
496   for (int line = 0; line < ARRAY_LENGTH(m_input); line++)
497      m_input[line].start(this, line);
498
499495   // allocate timers if we need them
500496   if (m_timed_interrupt_period != attotime::zero)
501497      m_timedint_timer = device().machine().scheduler().timer_alloc(FUNC(static_trigger_periodic_interrupt), (void *)this);
502
503   // register for save states
504   device().save_item(NAME(m_suspend));
505   device().save_item(NAME(m_nextsuspend));
506   device().save_item(NAME(m_eatcycles));
507   device().save_item(NAME(m_nexteatcycles));
508   device().save_item(NAME(m_trigger));
509   device().save_item(NAME(m_totalcycles));
510   device().save_item(NAME(m_localtime));
511498}
512499
513500
r29469r29470
520507{
521508   // make sure somebody set us up the icount
522509   assert_always(m_icountptr != NULL, "m_icountptr never initialized!");
510
511   // register for save states
512   device().save_item(NAME(m_suspend));
513   device().save_item(NAME(m_nextsuspend));
514   device().save_item(NAME(m_eatcycles));
515   device().save_item(NAME(m_nexteatcycles));
516   device().save_item(NAME(m_trigger));
517   device().save_item(NAME(m_totalcycles));
518   device().save_item(NAME(m_localtime));
519
520   // fill in the input states and IRQ callback information
521   for (int line = 0; line < ARRAY_LENGTH(m_input); line++)
522      m_input[line].start(this, line);
523523}
524524
525525
trunk/src/emu/cpu/tms57002/tms57002.c
r29469r29470
2222
2323tms57002_device::tms57002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2424   : cpu_device(mconfig, TMS57002, "TMS57002", tag, owner, clock, "tms57002", __FILE__),
25      program_config("program", ENDIANNESS_LITTLE, 32, 8, -2, ADDRESS_MAP_NAME(internal_pgm)),
26      data_config("data", ENDIANNESS_LITTLE, 8, 20)
25     device_sound_interface(mconfig, *this),
26     program_config("program", ENDIANNESS_LITTLE, 32, 8, -2, ADDRESS_MAP_NAME(internal_pgm)),
27     data_config("data", ENDIANNESS_LITTLE, 8, 20)
2728{
2829}
2930
r29469r29470
211212   if(st0 & ST0_WORD) {
212213      if(st0 & ST0_SEL) {
213214         int off = 16 - ((adr & 3) << 3);
214         xrd = (xrd & ~(0xff << off)) | (v << off);
215         txrd = (txrd & ~(0xff << off)) | (v << off);
215216         done = off == 0;
216217      } else {
217218         int off = 20 - ((adr & 7) << 2);
218         xrd = (xrd & ~(0xf << off)) | ((v & 0xf) << off);
219         txrd = (txrd & ~(0xf << off)) | ((v & 0xf) << off);
219220         done = off == 0;
220221      }
221222   } else {
222223      if(st0 & ST0_SEL) {
223224         int off = 16 - ((adr & 1) << 3);
224         xrd = (xrd & ~(0xff << off)) | (v << off);
225         txrd = (txrd & ~(0xff << off)) | (v << off);
225226         done = off == 8;
226227         if(done)
227            xrd &= 0xffff00;
228            txrd &= 0xffff00;
228229      } else {
229230         int off = 20 - ((adr & 3) << 2);
230         xrd = (xrd & ~(0xf << off)) | ((v & 0xf) << off);
231         txrd = (txrd & ~(0xf << off)) | ((v & 0xf) << off);
231232         done = off == 8;
232233         if(done)
233            xrd &= 0xffff00;
234            txrd &= 0xffff00;
234235      }
235236   }
236237   if(done) {
238      xrd = txrd;
237239      sti &= ~S_READ;
238240      xm_adr = 0;
239241   } else
r29469r29470
782784      icount = 0;
783785}
784786
787void tms57002_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
788{
789   assert(samples == 1);
790
791   if(st0 & ST0_SIM) {
792      si[0] = (inputs[0][0] << 8) & 0xffffff;
793      si[1] = (inputs[1][0] << 8) & 0xffffff;
794      si[2] = (inputs[2][0] << 8) & 0xffffff;
795      si[3] = (inputs[3][0] << 8) & 0xffffff;
796   } else {
797      si[0] = inputs[0][0] & 0xffffff;
798      si[1] = inputs[1][0] & 0xffffff;
799      si[2] = inputs[2][0] & 0xffffff;
800      si[3] = inputs[3][0] & 0xffffff;
801   }
802   outputs[0][0] = INT16(so[0] >> 8);
803   outputs[1][0] = INT16(so[1] >> 8);
804   outputs[2][0] = INT16(so[2] >> 8);
805   outputs[3][0] = INT16(so[3] >> 8);
806
807   sync_w(1);
808}
809
785810void tms57002_device::device_start()
786811{
787812   sti = S_IDLE;
r29469r29470
812837
813838   m_icountptr = &icount;
814839
840   stream_alloc(4, 4, STREAM_SYNC);
841
815842   save_item(NAME(macc));
816843
817844   save_item(NAME(cmem));
r29469r29470
829856   save_item(NAME(xba));
830857   save_item(NAME(xwr));
831858   save_item(NAME(xrd));
859   save_item(NAME(txrd));
832860   save_item(NAME(creg));
833861
834862   save_item(NAME(pc));
trunk/src/emu/cpu/tms57002/tms57002.h
r29469r29470
1212#ifndef __TMS57002_H__
1313#define __TMS57002_H__
1414
15class tms57002_device : public cpu_device {
15class tms57002_device : public cpu_device, public device_sound_interface {
1616public:
1717   tms57002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
1818
r29469r29470
2929protected:
3030   virtual void device_start();
3131   virtual void device_reset();
32   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
3233   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
3334   virtual UINT32 execute_min_cycles() const;
3435   virtual UINT32 execute_max_cycles() const;
r29469r29470
126127   UINT32 si[4], so[4];
127128
128129   UINT32 st0, st1, sti;
129   UINT32 aacc, xoa, xba, xwr, xrd, creg;
130   UINT32 aacc, xoa, xba, xwr, xrd, txrd, creg;
130131
131132   UINT8 pc, hpc, ca, id, ba0, ba1, rptc, rptc_next, sa;
132133

Previous 199869 Revisions Next


© 1997-2024 The MAME Team