Previous 15994 Revisions Next

r14033 Sunday 15th January, 2012 at 05:23:11 UTC by R. Belmont
isa_sblaster: modernized, added preliminary support for protection command 0xe2
[src/mess/machine]isa_sblaster.c isa_sblaster.h

src/mess/machine/isa_sblaster.c
r14032r14033
3737*/
3838#define ym3812_StdClock XTAL_3_579545MHz
3939
40static struct {
41   UINT8 reset_latch;
42   UINT8 rbuf_status;
43   UINT8 wbuf_status;
44   UINT8 fifo[16],fifo_ptr;
45   UINT8 fifo_r[16],fifo_r_ptr;
46   UINT16 version;
47   UINT8 test_reg;
48   UINT8 speaker_on;
49}m_dsp;
50
51
5240static const int m_cmd_fifo_length[256] =
5341{
5442/*   0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F        */
r14032r14033
6654   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, /* Bx */
6755   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, /* Cx */
6856   -1,  1, -1,  1, -1, -1, -1, -1,  1, -1, -1,   -1, -1, -1, -1, -1, /* Dx */
69    2,  1, -1, -1,  2, -1, -1, -1,  1, -1, -1,   -1, -1, -1, -1, -1, /* Ex */
57    2,  1, 1, -1,  2, -1, -1, -1,  1, -1, -1,   -1, -1, -1, -1, -1, /* Ex */
7058   -1, -1,  1, -1, -1, -1, -1, -1,  1, -1, -1,   -1, -1, -1, -1, -1  /* Fx */
7159};
7260
61static const int protection_magic[4][9] =
62{
63    {  1, -2, -4,  8, -16,  32,  64, -128, -106 },
64    { -1,  2, -4,  8,  16, -32,  64, -128,  165 },
65    { -1,  2,  4, -8,  16, -32, -64,  128, -151 },
66    {  1, -2,  4, -8, -16,  32, -64,  128,  90 }
67};
68
7369static const ym3812_interface pc_ym3812_interface =
7470{
7571   NULL
r14032r14033
129125   }
130126}
131127
132static void queue(UINT8 data)
128void sb8_device::queue(UINT8 data)
133129{
134130   if (m_dsp.fifo_ptr < 15)
135131   {
r14032r14033
144140   }
145141}
146142
147static void queue_r(UINT8 data)
143void sb8_device::queue_r(UINT8 data)
148144{
149145   m_dsp.rbuf_status |= 0x80;
150146
r14032r14033
161157   }
162158}
163159
164static UINT8 dequeue_r()
160UINT8 sb8_device::dequeue_r()
165161{
166162   UINT8 data = m_dsp.fifo_r[0];
167163
r14032r14033
182178}
183179
184180
185static READ8_DEVICE_HANDLER( dsp_reset_r )
181READ8_MEMBER( sb8_device::dsp_reset_r )
186182{
187183   if(offset)
188184      return 0xff;
r14032r14033
190186   return 0xff;
191187}
192188
193static WRITE8_DEVICE_HANDLER( dsp_reset_w )
189WRITE8_MEMBER( sb8_device::dsp_reset_w )
194190{
195191   if(offset)
196192      return;
r14032r14033
206202   //printf("%02x\n",data);
207203}
208204
209static READ8_DEVICE_HANDLER( dsp_data_r )
205READ8_MEMBER( sb8_device::dsp_data_r )
210206{
211207   if(offset)
212208      return 0xff;
r14032r14033
214210   return dequeue_r();
215211}
216212
217static WRITE8_DEVICE_HANDLER( dsp_data_w )
213WRITE8_MEMBER( sb8_device::dsp_data_w )
218214{
219215   if(offset)
220216      return;
221217   logerror("Soundblaster DSP data port undocumented write\n");
222218}
223219
224static READ8_DEVICE_HANDLER(dsp_rbuf_status_r)
220READ8_MEMBER(sb8_device::dsp_rbuf_status_r)
225221{
226222   if(offset)
227223      return 0xff;
r14032r14033
229225   return m_dsp.rbuf_status;
230226}
231227
232static READ8_DEVICE_HANDLER(dsp_wbuf_status_r)
228READ8_MEMBER(sb8_device::dsp_wbuf_status_r)
233229{
234230   if(offset)
235231      return 0xff;
r14032r14033
237233   return m_dsp.wbuf_status;
238234}
239235
240static WRITE8_DEVICE_HANDLER(dsp_rbuf_status_w)
236WRITE8_MEMBER(sb8_device::dsp_rbuf_status_w)
241237{
242238   if(offset)
243239      return;
r14032r14033
245241   logerror("Soundblaster DSP Read Buffer status undocumented write\n");
246242}
247243
248static void process_fifo(running_machine &machine, UINT8 cmd)
244void sb8_device::process_fifo(UINT8 cmd)
249245{
250246   if (m_cmd_fifo_length[cmd] == -1)
251247   {
r14032r14033
254250   else if(m_dsp.fifo_ptr == m_cmd_fifo_length[cmd])
255251   {
256252      /* get FIFO params */
253        printf("SB FIFO command: %02x\n", cmd);
257254      switch(cmd)
258255      {
259256         case 0xd1: // speaker on
r14032r14033
274271            queue_r(m_dsp.version >> 8);
275272            queue_r(m_dsp.version & 0xff);
276273            break;
274            case 0xe2: // DSP protection
275                for (int i = 0; i < 8; i++)
276                {
277                    if ((m_dsp.fifo[1] >> i) & 0x01)
278                    {
279                        m_dsp.prot_value += protection_magic[m_dsp.prot_count % 4][i];
280                    }
281
282                    m_dsp.prot_value += protection_magic[m_dsp.prot_count % 4][8];
283                    m_dsp.prot_count++;
284                }
285               
286                // this wants to return prot_data by DMA.  how does ISA DMA work?
287                m_isa->drq1_w(1);
288                break;
277289         case 0xe4: // write test register
278290            m_dsp.test_reg = m_dsp.fifo[1];
279291            break;
r14032r14033
281293            queue_r(m_dsp.test_reg);
282294            break;
283295         case 0xf2: // send PIC irq
284            //m_isa->irq5_w(1);
285            pic8259_ir5_w(machine.device("pic8259_master"), 1);
296            m_isa->irq5_w(1);
286297            break;
287298         case 0xf8: // ???
288299            logerror("SB: Unknown command write 0xf8");
r14032r14033
294305   }
295306}
296307
297static WRITE8_DEVICE_HANDLER(dsp_cmd_w)
308WRITE8_MEMBER(sb8_device::dsp_cmd_w)
298309{
299310   if(offset)
300311      return;
301312
302313   queue(data);
303314
304   process_fifo(device->machine(),m_dsp.fifo[0]);
315   process_fifo(m_dsp.fifo[0]);
305316}
306317
307318//**************************************************************************
r14032r14033
317328//-------------------------------------------------
318329
319330machine_config_constructor isa8_sblaster1_0_device::device_mconfig_additions() const
320{
331{                                                         
321332   return MACHINE_CONFIG_NAME( sblaster1_0_config );
322333}
323334
r14032r14033
330341//  LIVE DEVICE
331342//**************************************************************************
332343
344sb8_device::sb8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, const char *name) :
345    device_t(mconfig, type, name, tag, owner, clock),
346    device_isa8_card_interface(mconfig, *this)
347{
348}
349
350
333351//-------------------------------------------------
334352//  isa8_sblaster_device - constructor
335353//-------------------------------------------------
336354
337355isa8_sblaster1_0_device::isa8_sblaster1_0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
338        device_t(mconfig, ISA8_SOUND_BLASTER_1_0, "ISA8_SOUND_BLASTER_1_0", tag, owner, clock),
339      device_isa8_card_interface(mconfig, *this)
356    sb8_device(mconfig, ISA8_SOUND_BLASTER_1_0, tag, owner, clock, "Sound Blaster 1.0")
340357{
341358}
342359
343360isa8_sblaster1_5_device::isa8_sblaster1_5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
344        device_t(mconfig, ISA8_SOUND_BLASTER_1_5, "ISA8_SOUND_BLASTER_1_5", tag, owner, clock),
345      device_isa8_card_interface(mconfig, *this)
361    sb8_device(mconfig, ISA8_SOUND_BLASTER_1_5, tag, owner, clock, "Sound Blaster 1.5")
346362{
347363}
348364
r14032r14033
350366//  device_start - device-specific startup
351367//-------------------------------------------------
352368
369void sb8_device::device_start()
370{
371}
372
353373void isa8_sblaster1_0_device::device_start()
354374{
355375    set_isa_device();
356376   m_isa->install_device(subdevice("saa1099.1"), 0x0220, 0x0221, 0, 0, FUNC(saa1099_16_r), FUNC(saa1099_16_w) );
357377   m_isa->install_device(subdevice("saa1099.2"), 0x0222, 0x0223, 0, 0, FUNC(saa1099_16_r), FUNC(saa1099_16_w) );
358   m_isa->install_device(this,                   0x0226, 0x0227, 0, 0, FUNC(dsp_reset_r), FUNC(dsp_reset_w) );
378   m_isa->install_device(                   0x0226, 0x0227, 0, 0, read8_delegate(FUNC(sb8_device::dsp_reset_r), this), write8_delegate(FUNC(sb8_device::dsp_reset_w), this));
359379   m_isa->install_device(subdevice("ym3812"),    0x0228, 0x0229, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
360   m_isa->install_device(this,                   0x022a, 0x022b, 0, 0, FUNC(dsp_data_r),  FUNC(dsp_data_w) );
361   m_isa->install_device(this,                   0x022c, 0x022d, 0, 0, FUNC(dsp_wbuf_status_r),  FUNC(dsp_cmd_w) );
362   m_isa->install_device(this,                   0x022e, 0x022f, 0, 0, FUNC(dsp_rbuf_status_r),  FUNC(dsp_rbuf_status_w) );
380   m_isa->install_device(                   0x022a, 0x022b, 0, 0, read8_delegate(FUNC(sb8_device::dsp_data_r), this), write8_delegate(FUNC(sb8_device::dsp_data_w), this) );
381   m_isa->install_device(                   0x022c, 0x022d, 0, 0, read8_delegate(FUNC(sb8_device::dsp_wbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_cmd_w), this) );
382   m_isa->install_device(                   0x022e, 0x022f, 0, 0, read8_delegate(FUNC(sb8_device::dsp_rbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_rbuf_status_w), this) );
363383   m_isa->install_device(subdevice("ym3812"),    0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
364384   m_dsp.version = 0x0105;
365385}
r14032r14033
367387void isa8_sblaster1_5_device::device_start()
368388{
369389    set_isa_device();
370   /* 1.5 ditches CM/S support (empty sockets) */
371   m_isa->install_device(this,                   0x0226, 0x0227, 0, 0, FUNC(dsp_reset_r), FUNC(dsp_reset_w) );
390   /* 1.5 makes CM/S support optional (empty sockets, but they work if the user populates them!) */
391   m_isa->install_device(                   0x0226, 0x0227, 0, 0, read8_delegate(FUNC(sb8_device::dsp_reset_r), this), write8_delegate(FUNC(sb8_device::dsp_reset_w), this));
372392   m_isa->install_device(subdevice("ym3812"),    0x0228, 0x0229, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
373   m_isa->install_device(this,                   0x022a, 0x022b, 0, 0, FUNC(dsp_data_r),  FUNC(dsp_data_w) );
374   m_isa->install_device(this,                   0x022c, 0x022d, 0, 0, FUNC(dsp_wbuf_status_r),  FUNC(dsp_cmd_w) );
375   m_isa->install_device(this,                   0x022e, 0x022f, 0, 0, FUNC(dsp_rbuf_status_r),  FUNC(dsp_rbuf_status_w) );
393   m_isa->install_device(                   0x022a, 0x022b, 0, 0, read8_delegate(FUNC(sb8_device::dsp_data_r), this), write8_delegate(FUNC(sb8_device::dsp_data_w), this) );
394   m_isa->install_device(                   0x022c, 0x022d, 0, 0, read8_delegate(FUNC(sb8_device::dsp_wbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_cmd_w), this) );
395   m_isa->install_device(                   0x022e, 0x022f, 0, 0, read8_delegate(FUNC(sb8_device::dsp_rbuf_status_r), this), write8_delegate(FUNC(sb8_device::dsp_rbuf_status_w), this) );
376396   m_isa->install_device(subdevice("ym3812"),    0x0388, 0x0389, 0, 0, FUNC(ym3812_16_r), FUNC(ym3812_16_w) );
377397   m_dsp.version = 0x0200;
378398}
r14032r14033
381401//  device_reset - device-specific reset
382402//-------------------------------------------------
383403
384void isa8_sblaster1_0_device::device_reset()
404void sb8_device::device_reset()
385405{
386//   ...
406    m_dsp.prot_value = 0xaa;
407    m_dsp.prot_count = 0;
387408}
388409
389void isa8_sblaster1_5_device::device_reset()
390{
391// ...
392}
393
src/mess/machine/isa_sblaster.h
r14032r14033
1010//  TYPE DEFINITIONS
1111//**************************************************************************
1212
13// ======================> isa8_sblaster_device
13struct sb8_dsp_state
14{
15    UINT8 reset_latch;
16    UINT8 rbuf_status;
17    UINT8 wbuf_status;
18    UINT8 fifo[16],fifo_ptr;
19    UINT8 fifo_r[16],fifo_r_ptr;
20    UINT16 version;
21    UINT8 test_reg;
22    UINT8 speaker_on;
23    UINT8 prot_count;
24    INT8 prot_value;
25};
1426
15class isa8_sblaster1_0_device :
27// ======================> sb8_device (parent)
28
29class sb8_device :
1630      public device_t,
1731      public device_isa8_card_interface
1832{
1933public:
2034        // construction/destruction
35        sb8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, const char *name);
36
37        void process_fifo(UINT8 cmd);
38        void queue(UINT8 data);
39        void queue_r(UINT8 data);
40        UINT8 dequeue_r();
41
42        DECLARE_READ8_MEMBER(dsp_reset_r);
43        DECLARE_WRITE8_MEMBER(dsp_reset_w);
44        DECLARE_READ8_MEMBER(dsp_data_r);
45        DECLARE_WRITE8_MEMBER(dsp_data_w);
46        DECLARE_READ8_MEMBER(dsp_rbuf_status_r);
47        DECLARE_READ8_MEMBER(dsp_wbuf_status_r);
48        DECLARE_WRITE8_MEMBER(dsp_rbuf_status_w);
49        DECLARE_WRITE8_MEMBER(dsp_cmd_w);
50
51protected:
52        // device-level overrides
53        virtual void device_start();
54        virtual void device_reset();
55
56        struct sb8_dsp_state m_dsp;
57
58private:
59};
60
61class isa8_sblaster1_0_device : public sb8_device
62{
63public:
64        // construction/destruction
2165        isa8_sblaster1_0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2266
2367      // optional information overrides
r14032r14033
2569protected:
2670        // device-level overrides
2771        virtual void device_start();
28        virtual void device_reset();
2972
3073private:
3174        // internal state
3275};
3376
34class isa8_sblaster1_5_device :
35      public device_t,
36      public device_isa8_card_interface
77class isa8_sblaster1_5_device : public sb8_device
3778{
3879public:
3980        // construction/destruction
r14032r14033
4485protected:
4586        // device-level overrides
4687        virtual void device_start();
47        virtual void device_reset();
4888
4989private:
5090        // internal state

Previous 15994 Revisions Next


© 1998-2018 The MESS Team