Previous 15994 Revisions Next

r14992 Sunday 22nd April, 2012 at 00:14:36 UTC by R. Belmont
Apple II: Preliminary support for AE Phasor, not working yet (nw)
[src/mess/machine]a2mockingboard.c a2mockingboard.h

src/mess/machine/a2mockingboard.c
r14991r14992
1818#define VIA2_TAG "mockbd_via2"
1919#define AY1_TAG "mockbd_ay1"
2020#define AY2_TAG "mockbd_ay2"
21#define AY3_TAG "mockbd_ay3"
22#define AY4_TAG "mockbd_ay4"
2123
2224//**************************************************************************
2325//  GLOBAL VARIABLES
2426//**************************************************************************
2527
2628const device_type A2BUS_MOCKINGBOARD = &device_creator<a2bus_mockingboard_device>;
29const device_type A2BUS_PHASOR = &device_creator<a2bus_phasor_device>;
2730
2831static const ay8910_interface mockingboard_ay8910_interface =
2932{
r14991r14992
3437
3538const via6522_interface mockingboard_via1_intf =
3639{
37   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via1_in_a), DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via1_in_b),
40   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via1_in_a), DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via1_in_b),
3841   DEVCB_NULL, DEVCB_NULL,
3942   DEVCB_NULL, DEVCB_NULL,
40   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via1_out_a), DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via1_out_b),
43   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via1_out_a), DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via1_out_b),
4144   DEVCB_NULL, DEVCB_NULL,
4245   DEVCB_NULL, DEVCB_NULL,
43   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via1_irq_w)
46   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via1_irq_w)
4447};
4548
4649const via6522_interface mockingboard_via2_intf =
4750{
48   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via2_in_a), DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via2_in_b),
51   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via2_in_a), DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via2_in_b),
4952   DEVCB_NULL, DEVCB_NULL,
5053   DEVCB_NULL, DEVCB_NULL,
51   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via2_out_a), DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via2_out_b),
54   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via2_out_a), DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via2_out_b),
5255   DEVCB_NULL, DEVCB_NULL,
5356   DEVCB_NULL, DEVCB_NULL,
54   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, a2bus_mockingboard_device, via2_irq_w)
57   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, a2bus_ayboard_device, via2_irq_w)
5558};
5659
5760MACHINE_CONFIG_FRAGMENT( mockingboard )
r14991r14992
6770    MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
6871MACHINE_CONFIG_END
6972
73MACHINE_CONFIG_FRAGMENT( phasor )
74   MCFG_VIA6522_ADD(VIA1_TAG, 1022727, mockingboard_via1_intf)
75   MCFG_VIA6522_ADD(VIA2_TAG, 1022727, mockingboard_via2_intf)
76
77    MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
78    MCFG_SOUND_ADD(AY1_TAG, AY8913, 1022727)
79    MCFG_SOUND_CONFIG(mockingboard_ay8910_interface)
80    MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.5)
81    MCFG_SOUND_ADD(AY2_TAG, AY8913, 1022727)
82    MCFG_SOUND_CONFIG(mockingboard_ay8910_interface)
83    MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.5)
84    MCFG_SOUND_ADD(AY3_TAG, AY8913, 1022727)
85    MCFG_SOUND_CONFIG(mockingboard_ay8910_interface)
86    MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.5)
87    MCFG_SOUND_ADD(AY4_TAG, AY8913, 1022727)
88    MCFG_SOUND_CONFIG(mockingboard_ay8910_interface)
89    MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.5)
90MACHINE_CONFIG_END
91
7092//-------------------------------------------------
7193//  machine_config_additions - device-specific
7294//  machine configurations
7395//-------------------------------------------------
7496
75machine_config_constructor a2bus_mockingboard_device::device_mconfig_additions() const
97machine_config_constructor a2bus_ayboard_device::device_mconfig_additions() const
7698{
7799   return MACHINE_CONFIG_NAME( mockingboard );
78100}
79101
102machine_config_constructor a2bus_phasor_device::device_mconfig_additions() const
103{
104   return MACHINE_CONFIG_NAME( phasor );
105}
106
80107//**************************************************************************
81108//  LIVE DEVICE
82109//**************************************************************************
83110
84a2bus_mockingboard_device::a2bus_mockingboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
85    device_t(mconfig, A2BUS_MOCKINGBOARD, "Sweet Micro Systems Mockingboard", tag, owner, clock),
111a2bus_ayboard_device::a2bus_ayboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) :
112    device_t(mconfig, type, name, tag, owner, clock),
86113    device_a2bus_card_interface(mconfig, *this),
87114    m_via1(*this, VIA1_TAG),
88115    m_via2(*this, VIA2_TAG),
89116    m_ay1(*this, AY1_TAG),
90    m_ay2(*this, AY2_TAG)
117    m_ay2(*this, AY2_TAG),
118    m_ay3(*this, AY3_TAG),
119    m_ay4(*this, AY4_TAG)
91120{
92   m_shortname = "a2mockbd";
93121}
94122
95a2bus_mockingboard_device::a2bus_mockingboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) :
96    device_t(mconfig, type, name, tag, owner, clock),
97    device_a2bus_card_interface(mconfig, *this),
98    m_via1(*this, VIA1_TAG),
99    m_via2(*this, VIA2_TAG),
100    m_ay1(*this, AY1_TAG),
101    m_ay2(*this, AY2_TAG)
123a2bus_mockingboard_device::a2bus_mockingboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
124    a2bus_ayboard_device(mconfig, A2BUS_MOCKINGBOARD, "Sweet Micro Systems Mockingboard", tag, owner, clock)
102125{
103126   m_shortname = "a2mockbd";
127    m_isPhasor = false;
128    m_PhasorNative = false;
104129}
105130
131a2bus_phasor_device::a2bus_phasor_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
132    a2bus_ayboard_device(mconfig, A2BUS_PHASOR, "Applied Engineering Phasor", tag, owner, clock)
133{
134   m_shortname = "a2phasor";
135    m_isPhasor = true;
136    m_PhasorNative = false;
137}
138
106139//-------------------------------------------------
107140//  device_start - device-specific startup
108141//-------------------------------------------------
109142
110void a2bus_mockingboard_device::device_start()
143void a2bus_ayboard_device::device_start()
111144{
112145   // set_a2bus_device makes m_slot valid
113146   set_a2bus_device();
r14991r14992
116149   save_item(NAME(m_porta2));
117150}
118151
119void a2bus_mockingboard_device::device_reset()
152void a2bus_ayboard_device::device_reset()
120153{
121154    m_porta1 = m_porta2 = 0;
122155}
r14991r14992
125158    read_cnxx - called for reads from this card's c0nx space
126159-------------------------------------------------*/
127160
128UINT8 a2bus_mockingboard_device::read_cnxx(address_space &space, UINT8 offset)
161UINT8 a2bus_ayboard_device::read_cnxx(address_space &space, UINT8 offset)
129162{
130    if (offset <= 0x10)
163//    printf("Mockingboard(%d): read @ Cn%02X (PC=%x)\n", m_slot, offset, cpu_get_pc(&space.device()));
164    if (m_isPhasor)
131165    {
132        return m_via1->read(space, offset);
166        UINT8 retVal = 0;
167        int viaSel;
168
169        if (m_PhasorNative)
170        {
171            viaSel = ((offset & 0x80)>> 6) | ((offset & 0x10)>> 4);
172        }
173        else
174        {
175            viaSel = (offset & 0x80) ? 2 : 1;
176        }
177
178        if ((offset <= 0x20) || (offset >= 0x80 && offset <= 0xa0))
179        {
180            if (viaSel & 1)
181            {
182                retVal |= m_via1->read(space, offset & 0xf);
183            }
184
185            if (viaSel & 2)
186            {
187                retVal |=  m_via2->read(space, offset & 0xf);
188            }
189        }
190
191        return retVal;
133192    }
134    if (offset >= 0x80 && offset <= 0x90)
193    else
135194    {
136        return m_via2->read(space, offset & 0xf);
195        if (offset <= 0x10)
196        {
197            return m_via1->read(space, offset & 0xf);
198        }
199        else if (offset >= 0x80 && offset <= 0x90)
200        {
201            return m_via2->read(space, offset & 0xf);
202        }
137203    }
138204
139205    return 0;
r14991r14992
143209    write_cnxx - called for writes to this card's c0nx space
144210-------------------------------------------------*/
145211
146void a2bus_mockingboard_device::write_cnxx(address_space &space, UINT8 offset, UINT8 data)
212void a2bus_ayboard_device::write_cnxx(address_space &space, UINT8 offset, UINT8 data)
147213{
148    if (offset <= 0x10)
214    if (m_isPhasor)
149215    {
150        m_via1->write(space, offset, data);
216        if ((offset <= 0x20) || (offset >= 0x80 && offset <= 0xa0))
217        {
218            int viaSel;
219
220            if (m_PhasorNative)
221            {
222                viaSel = ((offset & 0x80)>> 6) | ((offset & 0x10)>> 4);
223            }
224            else
225            {
226                viaSel = (offset & 0x80) ? 2 : 1;
227            }
228
229//            printf("Phasor(%d): write %02x to Cn%02X (PC=%x) (native %d viaSel %d)\n", m_slot, data, offset, cpu_get_pc(&space.device()), m_PhasorNative ? 1 : 0, viaSel);
230
231            if (viaSel & 1)
232            {
233                m_via1->write(space, offset&0xf, data);
234            }
235            if (viaSel & 2)
236            {
237                m_via2->write(space, offset&0xf, data);
238            }
239        }
151240    }
152    else if (offset >= 0x80 && offset <= 0x90)
153    {
154        m_via2->write(space, offset & 0xf, data);
155    }
156241    else
157242    {
158        printf("Mockingboard(%d): unk write %02x to Cn%02X\n", m_slot, data, offset);
243        if (offset <= 0x10)
244        {
245            m_via1->write(space, offset & 0xf, data);
246        }
247        else if (offset >= 0x80 && offset <= 0x90)
248        {
249            m_via2->write(space, offset & 0xf, data);
250        }
251        else
252        {
253            printf("Mockingboard(%d): unk write %02x to Cn%02X (PC=%x)\n", m_slot, data, offset, cpu_get_pc(&space.device()));
254        }
159255    }
160256}
161257
162258
163WRITE_LINE_MEMBER( a2bus_mockingboard_device::via1_irq_w )
259WRITE_LINE_MEMBER( a2bus_ayboard_device::via1_irq_w )
164260{
165261    if (state)
166262    {
r14991r14992
172268    }
173269}
174270
175WRITE_LINE_MEMBER( a2bus_mockingboard_device::via2_irq_w )
271WRITE_LINE_MEMBER( a2bus_ayboard_device::via2_irq_w )
176272{
177273    if (state)
178274    {
r14991r14992
184280    }
185281}
186282
187READ8_MEMBER( a2bus_mockingboard_device::via1_in_a )
283READ8_MEMBER( a2bus_ayboard_device::via1_in_a )
188284{
189285   return 0;
190286}
191287
192WRITE8_MEMBER( a2bus_mockingboard_device::via1_out_a )
288WRITE8_MEMBER( a2bus_ayboard_device::via1_out_a )
193289{
194290    m_porta1 = data;
195291}
196292
197READ8_MEMBER( a2bus_mockingboard_device::via1_in_b )
293READ8_MEMBER( a2bus_ayboard_device::via1_in_b )
198294{
199295   return 0;
200296}
201297
202WRITE8_MEMBER( a2bus_mockingboard_device::via1_out_b )
298WRITE8_MEMBER( a2bus_ayboard_device::via1_out_b )
203299{
204300    if (!(data & 8))
205301    {
r14991r14992
207303    }
208304    else
209305    {
210        switch (data & 3)
306        if (!m_isPhasor)
211307        {
212            case 0: // BDIR=0, BC1=0 (inactive)
213                break;
308            switch (data & 3)
309            {
310                case 0: // BDIR=0, BC1=0 (inactive)
311                    break;
214312
215            case 1: // BDIR=0, BC1=1 (read PSG)
216                m_porta1 = ay8910_r(m_ay1, 0);
217                break;
313                case 1: // BDIR=0, BC1=1 (read PSG)
314                    m_porta1 = ay8910_r(m_ay1, 0);
315                    break;
218316
219            case 2: // BDIR=1, BC1=0 (write PSG)
220                ay8910_data_w(m_ay1, 0, m_porta1);
221                break;
317                case 2: // BDIR=1, BC1=0 (write PSG)
318                    ay8910_data_w(m_ay1, 0, m_porta1);
319                    break;
222320
223            case 3: // BDIR=1, BC1=1 (latch)
224                ay8910_address_w(m_ay1, 0, m_porta1);
225                break;
321                case 3: // BDIR=1, BC1=1 (latch)
322                    ay8910_address_w(m_ay1, 0, m_porta1);
323                    break;
324            }
226325        }
326        else
327        {
328            int chipSel;
329
330            if (m_PhasorNative)
331            {
332                chipSel = (~(data >> 3) & 3);
333            }
334            else
335            {
336                chipSel = 1;
337            }
338
339//            printf("Phasor: %02x to AY1/2 CS %02x (BDIR/BC1 %02x, data %02x)\n", m_porta1, chipSel, data & 3, data);
340
341            switch (data & 3)
342            {
343                case 0: // BDIR=0, BC1=0 (inactive)
344                    break;
345
346                case 1: // BDIR=0, BC1=1 (read PSG)
347                    if (chipSel & 1)
348                    {
349                        m_porta1 = ay8910_r(m_ay1, 0);
350                    }
351                    if (chipSel & 2)
352                    {
353                        m_porta1 = ay8910_r(m_ay2, 0);
354                    }
355                    break;
356
357                case 2: // BDIR=1, BC1=0 (write PSG)
358                    if (chipSel & 1)
359                    {
360                        ay8910_data_w(m_ay1, 0, m_porta1);
361                    }
362                    if (chipSel & 2)
363                    {
364                        ay8910_data_w(m_ay2, 0, m_porta1);
365                    }
366                    break;
367
368                case 3: // BDIR=1, BC1=1 (latch)
369                    if (chipSel & 1)
370                    {
371                        ay8910_address_w(m_ay1, 0, m_porta1);
372                    }
373                    if (chipSel & 2)
374                    {
375                        ay8910_address_w(m_ay2, 0, m_porta1);
376                    }
377                    break;
378            }
379        }
227380    }
228381}
229382
230READ8_MEMBER( a2bus_mockingboard_device::via2_in_a )
383READ8_MEMBER( a2bus_ayboard_device::via2_in_a )
231384{
232385   return 0;
233386}
234387
235WRITE8_MEMBER( a2bus_mockingboard_device::via2_out_a )
388WRITE8_MEMBER( a2bus_ayboard_device::via2_out_a )
236389{
237390    m_porta2 = data;
238391}
239392
240READ8_MEMBER( a2bus_mockingboard_device::via2_in_b )
393READ8_MEMBER( a2bus_ayboard_device::via2_in_b )
241394{
242395   return 0;
243396}
244397
245WRITE8_MEMBER( a2bus_mockingboard_device::via2_out_b )
398WRITE8_MEMBER( a2bus_ayboard_device::via2_out_b )
246399{
247400    if (!(data & 8))
248401    {
r14991r14992
250403    }
251404    else
252405    {
253        switch (data & 3)
406        if (!m_isPhasor)
254407        {
255            case 0: // BDIR=0, BC1=0 (inactive)
256                break;
408            switch (data & 3)
409            {
410                case 0: // BDIR=0, BC1=0 (inactive)
411                    break;
257412
258            case 1: // BDIR=0, BC1=1 (read PSG)
259                m_porta2 = ay8910_r(m_ay2, 0);
260                break;
413                case 1: // BDIR=0, BC1=1 (read PSG)
414                    m_porta2 = ay8910_r(m_ay2, 0);
415                    break;
261416
262            case 2: // BDIR=1, BC1=0 (write PSG)
263                ay8910_data_w(m_ay2, 0, m_porta2);
264                break;
417                case 2: // BDIR=1, BC1=0 (write PSG)
418                    ay8910_data_w(m_ay2, 0, m_porta2);
419                    break;
265420
266            case 3: // BDIR=1, BC1=1 (latch)
267                ay8910_address_w(m_ay2, 0, m_porta2);
268                break;
421                case 3: // BDIR=1, BC1=1 (latch)
422                    ay8910_address_w(m_ay2, 0, m_porta2);
423                    break;
424            }
269425        }
426        else
427        {
428            int chipSel;
429
430            if (m_PhasorNative)
431            {
432                chipSel = (~(data >> 3) & 3);
433            }
434            else
435            {
436                chipSel = 1;
437            }
438
439//            printf("Phasor: %02x to AY3/4 CS %02x (BDIR/BC1 %02x, data %02x)\n", m_porta2, chipSel, data & 3, data);
440            switch (data & 3)
441            {
442                case 0: // BDIR=0, BC1=0 (inactive)
443                    break;
444
445                case 1: // BDIR=0, BC1=1 (read PSG)
446                    if (chipSel & 1)
447                    {
448                        m_porta2 = ay8910_r(m_ay3, 0);
449                    }
450                    if (chipSel & 2)
451                    {
452                        m_porta2 = ay8910_r(m_ay4, 0);
453                    }
454                    break;
455
456                case 2: // BDIR=1, BC1=0 (write PSG)
457                    if (chipSel & 1)
458                    {
459                        ay8910_data_w(m_ay3, 0, m_porta2);
460                    }
461                    if (chipSel & 2)
462                    {
463                        ay8910_data_w(m_ay4, 0, m_porta2);
464                    }
465                    break;
466
467                case 3: // BDIR=1, BC1=1 (latch)
468                    if (chipSel & 1)
469                    {
470                        ay8910_address_w(m_ay3, 0, m_porta2);
471                    }
472                    if (chipSel & 2)
473                    {
474                        ay8910_address_w(m_ay4, 0, m_porta2);
475                    }
476                    break;
477            }
478        }
270479    }
271480}
481
482UINT8 a2bus_ayboard_device::read_c0nx(address_space &space, UINT8 offset)
483{
484    if (m_isPhasor)
485    {
486        m_PhasorNative = (offset & 1) ? true : false;
487    }
488
489    return 0xff;
490}
491
492void a2bus_ayboard_device::write_c0nx(address_space &space, UINT8 offset, UINT8 data)
493{
494    if (m_isPhasor)
495    {
496        m_PhasorNative = (offset & 1) ? true : false;
497    }
498}
src/mess/machine/a2mockingboard.h
r14991r14992
1818//  TYPE DEFINITIONS
1919//**************************************************************************
2020
21class a2bus_mockingboard_device:
21class a2bus_ayboard_device:
2222    public device_t,
2323    public device_a2bus_card_interface
2424{
2525public:
2626    // construction/destruction
27    a2bus_mockingboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
28    a2bus_mockingboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
27    a2bus_ayboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
2928
3029    // optional information overrides
3130    virtual machine_config_constructor device_mconfig_additions() const;
r14991r14992
4645    virtual void device_reset();
4746
4847    // overrides of standard a2bus slot functions
48    virtual UINT8 read_c0nx(address_space &space, UINT8 offset);
49    virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data);
4950    virtual UINT8 read_cnxx(address_space &space, UINT8 offset);
5051    virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data);
5152
r14991r14992
5354   required_device<via6522_device> m_via2;
5455    required_device<device_t> m_ay1;
5556    required_device<device_t> m_ay2;
57    optional_device<device_t> m_ay3;
58    optional_device<device_t> m_ay4;
5659
60    bool m_isPhasor, m_PhasorNative;
61
5762private:
5863    UINT8 m_porta1, m_porta2;
5964};
6065
66class a2bus_mockingboard_device : public a2bus_ayboard_device
67{
68public:
69    a2bus_mockingboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
70};
71
72class a2bus_phasor_device : public a2bus_ayboard_device
73{
74public:
75    a2bus_phasor_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
76
77    virtual machine_config_constructor device_mconfig_additions() const;
78};
79
6180// device type definition
6281extern const device_type A2BUS_MOCKINGBOARD;
82extern const device_type A2BUS_PHASOR;
6383
6484#endif  /* __A2BUS_MOCKINGBOARD__ */
6585

Previous 15994 Revisions Next


© 1998-2018 The MESS Team