Previous 199869 Revisions Next

r29631 Monday 14th April, 2014 at 09:43:48 UTC by Fabio Priuli
adc083x: updated to use delegates and slightly reduced tagmap lookups in
konamigx and zr107 while at it. nw.
[src/emu/machine]adc083x.c adc083x.h
[src/mame/drivers]konamigx.c ksys573.c zr107.c
[src/mame/includes]konamigx.h
[src/mame/machine]k573cass.h

trunk/src/mame/drivers/zr107.c
r29630r29631
191191      m_k056800(*this, "k056800"),
192192      m_k056832(*this, "k056832"),
193193      m_workram(*this, "workram"),
194      m_in0(*this, "IN0"),
195      m_in1(*this, "IN1"),
196      m_in2(*this, "IN2"),
197      m_in3(*this, "IN3"),
198      m_in4(*this, "IN4"),
199      m_out4(*this, "OUT4"),
200      m_eepromout(*this, "EEPROMOUT"),
201      m_analog1(*this, "ANALOG1"),
202      m_analog2(*this, "ANALOG2"),
203      m_analog3(*this, "ANALOG3"),
194204      m_palette(*this, "palette") { }
195205
196206   required_device<cpu_device> m_maincpu;
r29630r29631
200210   required_device<k056800_device> m_k056800;
201211   optional_device<k056832_device> m_k056832;
202212   optional_shared_ptr<UINT32> m_workram;
213   required_ioport m_in0, m_in1, m_in2, m_in3, m_in4, m_out4, m_eepromout, m_analog1, m_analog2, m_analog3;
203214   required_device<palette_device> m_palette;
204215
205216   UINT32 *m_sharc_dataram;
r29630r29631
229240   UINT32 screen_update_jetwave(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
230241   INTERRUPT_GEN_MEMBER(zr107_vblank);
231242   WRITE_LINE_MEMBER(k054539_irq_gen);
243   ADC083X_INPUT_CB(adc0838_callback);
232244
233245protected:
234246   virtual void machine_start();
r29630r29631
316328READ8_MEMBER(zr107_state::sysreg_r)
317329{
318330   UINT32 r = 0;
319   static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3", "IN4" };
320331
321332   switch (offset)
322333   {
323334      case 0: /* I/O port 0 */
335         r = m_in0->read();
336         break;
324337      case 1: /* I/O port 1 */
338         r = m_in1->read();
339         break;
325340      case 2: /* I/O port 2 */
341         r = m_in2->read();
342         break;
326343      case 3: /* System Port 0 */
344         r = m_in3->read();
345         break;
327346      case 4: /* System Port 1 */
328         r = ioport(portnames[offset])->read();
347         r = m_in4->read();
329348         break;
330
331349      case 5: /* Parallel data port */
332350         break;
333351   }
r29630r29631
361379             0x02 = EEPCLK
362380             0x01 = EEPDI
363381         */
364         ioport("EEPROMOUT")->write(data & 0x07, 0xff);
382         m_eepromout->write(data & 0x07, 0xff);
365383         m_audiocpu->set_input_line(INPUT_LINE_RESET, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE);
366384         mame_printf_debug("System register 0 = %02X\n", data);
367385         break;
r29630r29631
382400         if (data & 0x40)    /* CG Board 0 IRQ Ack */
383401            m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
384402         set_cgboard_id((data >> 4) & 3);
385         ioport("OUT4")->write(data, 0xff);
403         m_out4->write(data, 0xff);
386404         mame_printf_debug("System register 1 = %02X\n", data);
387405         break;
388406
r29630r29631
675693
676694/* ADC0838 Interface */
677695
678static double adc0838_callback( device_t *device, UINT8 input )
696ADC083X_INPUT_CB(zr107_state::adc0838_callback)
679697{
680698   switch (input)
681699   {
682700   case ADC083X_CH0:
683      return (double)(5 * device->machine().root_device().ioport("ANALOG1")->read()) / 255.0;
701      return (double)(5 * m_analog1->read()) / 255.0;
684702   case ADC083X_CH1:
685      return (double)(5 * device->machine().root_device().ioport("ANALOG2")->read()) / 255.0;
703      return (double)(5 * m_analog2->read()) / 255.0;
686704   case ADC083X_CH2:
687      return (double)(5 * device->machine().root_device().ioport("ANALOG3")->read()) / 255.0;
705      return (double)(5 * m_analog3->read()) / 255.0;
688706   case ADC083X_CH3:
689707      return 0;
690708   case ADC083X_COM:
r29630r29631
791809   MCFG_SOUND_ROUTE(1, "rspeaker", 0.75)
792810
793811   MCFG_DEVICE_ADD("adc0838", ADC0838, 0)
794   MCFG_ADC083X_INPUT_CALLBACK(adc0838_callback)
812   MCFG_ADC083X_INPUT_CB(zr107_state, adc0838_callback)
795813MACHINE_CONFIG_END
796814
797815
r29630r29631
855873   MCFG_SOUND_ROUTE(1, "rspeaker", 0.75)
856874
857875   MCFG_DEVICE_ADD("adc0838", ADC0838, 0)
858   MCFG_ADC083X_INPUT_CALLBACK(adc0838_callback)
876   MCFG_ADC083X_INPUT_CB(zr107_state, adc0838_callback)
859877MACHINE_CONFIG_END
860878
861879/*****************************************************************************/
trunk/src/mame/drivers/ksys573.c
r29630r29631
451451   DECLARE_WRITE8_MEMBER( dmx_output_callback );
452452   DECLARE_WRITE8_MEMBER( mamboagg_output_callback );
453453   DECLARE_WRITE8_MEMBER( punchmania_output_callback );
454   ADC083X_INPUT_CB(analogue_inputs_callback);
454455
455456   void cdrom_dma_read( UINT32 *ram, UINT32 n_address, INT32 n_size );
456457   void cdrom_dma_write( UINT32 *ram, UINT32 n_address, INT32 n_size );
r29630r29631
16801681/* punch mania */
16811682
16821683
1683static double punchmania_inputs_callback( device_t *device, UINT8 input )
1684ADC083X_INPUT_CB(konami573_cassette_xi_device::punchmania_inputs_callback)
16841685{
1685   ksys573_state *state = device->machine().driver_data<ksys573_state>();
1686
1686   ksys573_state *state = machine().driver_data<ksys573_state>();
16871687   double *pad_position = state->m_pad_position;
16881688   int pads = state->m_pads->read();
16891689   for( int i = 0; i < 6; i++ )
r29630r29631
17191719
17201720static MACHINE_CONFIG_FRAGMENT( punchmania_cassette_install )
17211721   MCFG_DEVICE_MODIFY( "adc0838" )
1722   MCFG_ADC083X_INPUT_CALLBACK( punchmania_inputs_callback )
1722   MCFG_ADC083X_INPUT_CB( konami573_cassette_xi_device, punchmania_inputs_callback )
17231723MACHINE_CONFIG_END
17241724
17251725
r29630r29631
19871987
19881988/* ADC0834 Interface */
19891989
1990static double analogue_inputs_callback( device_t *device, UINT8 input )
1990ADC083X_INPUT_CB(ksys573_state::analogue_inputs_callback)
19911991{
1992   ksys573_state *state = device->machine().driver_data<ksys573_state>();
1993
19941992   switch( input )
19951993   {
19961994   case ADC083X_CH0:
1997      return (double)( 5 * state->m_analog0->read() ) / 255.0;
1995      return (double)( 5 * m_analog0->read() ) / 255.0;
19981996   case ADC083X_CH1:
1999      return (double)( 5 * state->m_analog1->read() ) / 255.0;
1997      return (double)( 5 * m_analog1->read() ) / 255.0;
20001998   case ADC083X_CH2:
2001      return (double)( 5 * state->m_analog2->read() ) / 255.0;
1999      return (double)( 5 * m_analog2->read() ) / 255.0;
20022000   case ADC083X_CH3:
2003      return (double)( 5 * state->m_analog3->read() ) / 255.0;
2001      return (double)( 5 * m_analog3->read() ) / 255.0;
20042002   case ADC083X_AGND:
20052003      return 0;
20062004   case ADC083X_VREF:
r29630r29631
20762074   MCFG_M48T58_ADD( "m48t58" )
20772075
20782076   MCFG_DEVICE_ADD( "adc0834", ADC0834, 0 )
2079   MCFG_ADC083X_INPUT_CALLBACK( analogue_inputs_callback )
2077   MCFG_ADC083X_INPUT_CB( ksys573_state, analogue_inputs_callback )
20802078MACHINE_CONFIG_END
20812079
20822080// Variants with additional digital sound board
trunk/src/mame/drivers/konamigx.c
r29630r29631
102102#include "sound/k056800.h"
103103#include "sound/k054539.h"
104104#include "includes/konamigx.h"
105#include "machine/adc083x.h"
106105#include "rendlay.h"
107106
108107#define GX_DEBUG     0
r29630r29631
463462        bit 0: eeprom data
464463      */
465464
466      ioport("EEPROMOUT")->write(odata, 0xff);
465      m_eepromout->write(odata, 0xff);
467466
468467      konamigx_wrport1_0 = odata;
469468   }
r29630r29631
708707
709708/* National Semiconductor ADC0834 4-channel serial ADC emulation */
710709
711static double adc0834_callback( device_t *device, UINT8 input )
710ADC083X_INPUT_CB(konamigx_state::adc0834_callback)
712711{
713712   switch (input)
714713   {
715714   case ADC083X_CH0:
716      return (double)(5 * device->machine().root_device().ioport("AN0")->read()) / 255.0; // steer
715      return (double)(5 * m_an0->read()) / 255.0; // steer
717716   case ADC083X_CH1:
718      return (double)(5 * device->machine().root_device().ioport("AN1")->read()) / 255.0; // gas
717      return (double)(5 * m_an1->read()) / 255.0; // gas
719718   case ADC083X_VREF:
720719      return 5;
721720   }
r29630r29631
725724
726725READ32_MEMBER(konamigx_state::le2_gun_H_r)
727726{
728   int p1x = ioport("LIGHT0_X")->read()*290/0xff+20;
729   int p2x = ioport("LIGHT1_X")->read()*290/0xff+20;
727   int p1x = m_light0_x->read()*290/0xff+20;
728   int p2x = m_light1_x->read()*290/0xff+20;
730729
731730   return (p1x<<16)|p2x;
732731}
733732
734733READ32_MEMBER(konamigx_state::le2_gun_V_r)
735734{
736   int p1y = ioport("LIGHT0_Y")->read()*224/0xff;
737   int p2y = ioport("LIGHT1_Y")->read()*224/0xff;
735   int p1y = m_light0_y->read()*224/0xff;
736   int p2y = m_light1_y->read()*224/0xff;
738737
739738   // make "off the bottom" reload too
740739   if (p1y >= 0xdf) p1y = 0;
r29630r29631
17001699   MCFG_CPU_PROGRAM_MAP(gx_type1_map)
17011700
17021701   MCFG_DEVICE_ADD("adc0834", ADC0834, 0)
1703   MCFG_ADC083X_INPUT_CALLBACK(adc0834_callback)
1702   MCFG_ADC083X_INPUT_CB(konamigx_state, adc0834_callback)
17041703MACHINE_CONFIG_END
17051704
17061705static MACHINE_CONFIG_DERIVED( racinfrc, konamigx )
r29630r29631
17141713   MCFG_CPU_PROGRAM_MAP(gx_type1_map)
17151714
17161715   MCFG_DEVICE_ADD("adc0834", ADC0834, 0)
1717   MCFG_ADC083X_INPUT_CALLBACK(adc0834_callback)
1716   MCFG_ADC083X_INPUT_CB(konamigx_state, adc0834_callback)
17181717MACHINE_CONFIG_END
17191718
17201719static MACHINE_CONFIG_DERIVED( gxtype3, konamigx )
trunk/src/mame/machine/k573cass.h
r29630r29631
8080   virtual DECLARE_READ_LINE_MEMBER(read_line_adc083x_sars);
8181   virtual DECLARE_WRITE_LINE_MEMBER(write_line_d5);
8282
83   ADC083X_INPUT_CB(punchmania_inputs_callback);
84
8385protected:
8486   virtual machine_config_constructor device_mconfig_additions() const;
8587
trunk/src/mame/includes/konamigx.h
r29630r29631
11#include "sound/k056800.h"
22#include "sound/k054539.h"
33#include "cpu/tms57002/tms57002.h"
4#include "machine/adc083x.h"
45#include "video/k054156_k054157_k056832.h"
56#include "video/k053246_k053247_k055673.h"
67#include "video/k055555.h"
r29630r29631
2930      m_k056800(*this, "k056800"),
3031      m_k054539_1(*this,"k054539_1"),
3132      m_k054539_2(*this,"k054539_2"),
33      m_an0(*this, "AN0"),
34      m_an1(*this, "AN1"),
35      m_light0_x(*this, "LIGHT0_X"),
36      m_light0_y(*this, "LIGHT0_Y"),   
37      m_light1_x(*this, "LIGHT1_X"),
38      m_light1_y(*this, "LIGHT1_Y"),   
39      m_eepromout(*this, "EEPROMOUT"),
3240      m_gfxdecode(*this, "gfxdecode"),
3341      m_screen(*this, "screen"),
3442      m_palette(*this, "palette")
r29630r29631
5260   optional_device<k056800_device> m_k056800;
5361   optional_device<k054539_device> m_k054539_1;
5462   optional_device<k054539_device> m_k054539_2;
63   optional_ioport m_an0, m_an1, m_light0_x, m_light0_y, m_light1_x, m_light1_y, m_eepromout;
5564   required_device<gfxdecode_device> m_gfxdecode;
5665   required_device<screen_device> m_screen;
5766   required_device<palette_device> m_palette;
r29630r29631
119128   TIMER_CALLBACK_MEMBER(dmaend_callback);
120129   TIMER_CALLBACK_MEMBER(boothack_callback);
121130   TIMER_DEVICE_CALLBACK_MEMBER(konamigx_hbinterrupt);
131   ADC083X_INPUT_CB(adc0834_callback);
122132
123133   void _gxcommoninitnosprites(running_machine &machine);
124134   void _gxcommoninit(running_machine &machine);
trunk/src/emu/machine/adc083x.c
r29630r29631
9898{
9999   clear_sars();
100100
101   /* resolve callbacks */
102   m_input_callback.bind_relative_to(*owner());
103
101104   /* register for state saving */
102105   save_item( NAME(m_cs) );
103106   save_item( NAME(m_clk) );
r29630r29631
178181   int negative_channel = ADC083X_AGND;
179182   double positive = 0;
180183   double negative = 0;
181   double gnd = m_input_callback( this, ADC083X_AGND );
182   double vref = m_input_callback( this, ADC083X_VREF );
184   double gnd = m_input_callback(ADC083X_AGND);
185   double vref = m_input_callback(ADC083X_VREF);
183186
184187   if( type() == ADC0831 )
185188   {
r29630r29631
225228
226229   if( positive_channel != ADC083X_AGND )
227230   {
228      positive = m_input_callback( this, positive_channel ) - gnd;
231      positive = m_input_callback(positive_channel) - gnd;
229232   }
230233
231234   if( negative_channel != ADC083X_AGND )
232235   {
233      negative = m_input_callback( this, negative_channel ) - gnd;
236      negative = m_input_callback(negative_channel) - gnd;
234237   }
235238
236239   result = (int) ( ( ( positive - negative ) * 255 ) / vref );
trunk/src/emu/machine/adc083x.h
r29630r29631
1515    TYPE DEFINITIONS
1616***************************************************************************/
1717
18typedef double (*adc083x_input_callback)(device_t *device, UINT8 input);
18typedef device_delegate<double (UINT8 input)> adc083x_input_delegate;
19#define ADC083X_INPUT_CB(name)  double name(UINT8 input)
1920
20#define MCFG_ADC083X_INPUT_CALLBACK(input_callback) \
21   adc083x_device::set_input_callback(*device, input_callback);
21#define MCFG_ADC083X_INPUT_CB(_class, _method) \
22   adc083x_device::set_input_callback(*device, adc083x_input_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
2223
2324/***************************************************************************
2425    CONSTANTS
r29630r29631
4647   adc083x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
4748
4849   // static configuration helpers
49   static void set_input_callback(device_t &device, adc083x_input_callback input_callback) { downcast<adc083x_device &>(device).m_input_callback = input_callback; }
50   static void set_input_callback(device_t &device, adc083x_input_delegate input_callback) { downcast<adc083x_device &>(device).m_input_callback = input_callback; }
5051
5152   DECLARE_WRITE_LINE_MEMBER( cs_write );
5253   DECLARE_WRITE_LINE_MEMBER( clk_write );
r29630r29631
8182   INT32 m_bit;
8283   INT32 m_output;
8384
84   adc083x_input_callback m_input_callback;
85   adc083x_input_delegate m_input_callback;
8586};
8687
8788class adc0831_device : public adc083x_device

Previous 199869 Revisions Next


© 1997-2024 The MAME Team